Add support for one shot action profile programming in PI
A P4 table annotated with @oneshot annotation can be programmed
only with the action profile action set. For these kind of tables
we don't issue read request for action profile groups and members.
Change-Id: I7b6a743f4f4df4190f17d958ebb4807aca5feda5
diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeActionGroupProgrammable.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeActionGroupProgrammable.java
index e0805a6..d1d6902 100644
--- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeActionGroupProgrammable.java
+++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeActionGroupProgrammable.java
@@ -131,8 +131,17 @@
// Dump groups and members from device for all action profiles.
final P4RuntimeReadClient.ReadRequest request = client.read(
p4DeviceId, pipeconf);
- pipeconf.pipelineModel().actionProfiles()
- .stream().map(PiActionProfileModel::id)
+
+ pipeconf.pipelineModel().actionProfiles().stream()
+ // Do not issue groups and members reads for one-shot tables.
+ // Those tables won't use separate groups and members, but the
+ // action profile elements are embedded in the table entry via
+ // action sets and weighted actions.
+ .filter(piActionProfileModel -> piActionProfileModel.tables().stream()
+ .map(tableId -> pipeconf.pipelineModel().table(tableId))
+ .allMatch(piTableModel -> piTableModel.isPresent() &&
+ !piTableModel.get().oneShotOnly()))
+ .map(PiActionProfileModel::id)
.forEach(id -> request.actionProfileGroups(id)
.actionProfileMembers(id));
final P4RuntimeReadClient.ReadResponse response = request.submitSync();