Various fixes for P4Runtime group handling
- Workaround for PI bug that ignores max_group_size
- Use max_group_size and not buckets size when translating groups
Change-Id: Id12a12311b20ca8fb4e785e1c5a4f0f4215d1bbf
diff --git a/core/net/src/main/java/org/onosproject/net/pi/impl/PiGroupTranslatorImpl.java b/core/net/src/main/java/org/onosproject/net/pi/impl/PiGroupTranslatorImpl.java
index 6e7e2d7..14e2b5c 100644
--- a/core/net/src/main/java/org/onosproject/net/pi/impl/PiGroupTranslatorImpl.java
+++ b/core/net/src/main/java/org/onosproject/net/pi/impl/PiGroupTranslatorImpl.java
@@ -106,7 +106,7 @@
// model, however this might be highly inefficient for some HW targets
// which pre-allocate resources for the whole group.
final int maxGroupSize = group.type() == GroupDescription.Type.INDIRECT
- ? 1 : group.buckets().buckets().size();
+ ? 1 : actionProfileModel.maxGroupSize();
final PiActionProfileGroup.Builder piActionGroupBuilder = PiActionProfileGroup.builder()
.withId(PiActionProfileGroupId.of(group.id().id()))
diff --git a/core/net/src/main/java/org/onosproject/net/pi/impl/PiTranslationServiceImpl.java b/core/net/src/main/java/org/onosproject/net/pi/impl/PiTranslationServiceImpl.java
index acfb535..510ad01 100644
--- a/core/net/src/main/java/org/onosproject/net/pi/impl/PiTranslationServiceImpl.java
+++ b/core/net/src/main/java/org/onosproject/net/pi/impl/PiTranslationServiceImpl.java
@@ -45,6 +45,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static com.google.common.base.Preconditions.checkNotNull;
+
/**
* Implementation of the PI translation service.
*/
@@ -131,6 +133,8 @@
@Override
public PiTableEntry translate(FlowRule original, PiPipeconf pipeconf)
throws PiTranslationException {
+ checkNotNull(original);
+ checkNotNull(pipeconf);
return PiFlowRuleTranslatorImpl
.translate(original, pipeconf, getDevice(original.deviceId()));
}
@@ -147,6 +151,8 @@
@Override
public PiActionProfileGroup translate(Group original, PiPipeconf pipeconf)
throws PiTranslationException {
+ checkNotNull(original);
+ checkNotNull(pipeconf);
return PiGroupTranslatorImpl
.translate(original, pipeconf, getDevice(original.deviceId()));
}
@@ -163,6 +169,8 @@
@Override
public PiMulticastGroupEntry translate(Group original, PiPipeconf pipeconf)
throws PiTranslationException {
+ checkNotNull(original);
+ checkNotNull(pipeconf);
return PiMulticastGroupTranslatorImpl.translate(
original, pipeconf, getDevice(original.deviceId()));
}
@@ -179,6 +187,8 @@
@Override
public PiMeterCellConfig translate(Meter original, PiPipeconf pipeconf)
throws PiTranslationException {
+ checkNotNull(original);
+ checkNotNull(pipeconf);
return PiMeterTranslatorImpl
.translate(original, pipeconf, getDevice(original.deviceId()));
}