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/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileGroup.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileGroup.java
index 3fd7e08..f8036f5 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileGroup.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileGroup.java
@@ -111,7 +111,11 @@
final PiActionProfileGroup other = (PiActionProfileGroup) obj;
return Objects.equal(this.groupId, other.groupId)
&& Objects.equal(this.members, other.members)
- && Objects.equal(this.maxSize, other.maxSize)
+ // FIXME: re-enable when this PI bug will be fixed:
+ // https://github.com/p4lang/PI/issues/452
+ // Currently PI-based devices always return max_group_size 0,
+ // event if we set a different one.
+ // && Objects.equal(this.maxSize, other.maxSize)
&& Objects.equal(this.actionProfileId, other.actionProfileId);
}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiEntity.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiEntity.java
index 531a6a2..1d1e7e0 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiEntity.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiEntity.java
@@ -20,8 +20,7 @@
import org.onosproject.net.DeviceId;
/**
- * Abstraction of an entity of a protocol-independent that can be read or write
- * at runtime.
+ * Abstraction of a runtime entity of a protocol-independent pipeline.
*/
@Beta
public interface PiEntity {
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()));
}
diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/AbstractDistributedP4RuntimeMirror.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/AbstractDistributedP4RuntimeMirror.java
index e869cbd..f955706 100644
--- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/AbstractDistributedP4RuntimeMirror.java
+++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/AbstractDistributedP4RuntimeMirror.java
@@ -185,8 +185,8 @@
}
});
if (removeCount.get() + updateCount.get() + addCount.get() > 0) {
- log.info("Synchronized mirror entries for {}: {} removed, {} updated, {} added",
- deviceId, removeCount, updateCount, addCount);
+ log.info("Synchronized {} mirror for {}: {} removed, {} updated, {} added",
+ entityType, deviceId, removeCount, updateCount, addCount);
}
}