Bumped supported revisions of P4 tools
Includes:
- Use new P4Runtime "v1" package names
- Removed VALID match
- New table entry priority spec (1 is min priority, not 0)
- Fixed p4c-bm2-ss to include arch flag
- Re-compiled P4 programs with more recent p4c (with updated p4info)
Change-Id: I05908f40eda0f0c755009268fd261fb8bcc9be35
diff --git a/core/api/src/main/java/org/onosproject/net/flow/criteria/PiCriterion.java b/core/api/src/main/java/org/onosproject/net/flow/criteria/PiCriterion.java
index 23102dd..a346927 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/criteria/PiCriterion.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/criteria/PiCriterion.java
@@ -25,7 +25,6 @@
import org.onosproject.net.pi.runtime.PiLpmFieldMatch;
import org.onosproject.net.pi.runtime.PiRangeFieldMatch;
import org.onosproject.net.pi.runtime.PiTernaryFieldMatch;
-import org.onosproject.net.pi.runtime.PiValidFieldMatch;
import java.util.Collection;
import java.util.Optional;
@@ -274,18 +273,6 @@
}
/**
- * Adds a valid field match for the given fieldId and flag.
- *
- * @param fieldId protocol-independent header field Id
- * @param flag a boolean value
- * @return this
- */
- public Builder matchValid(PiMatchFieldId fieldId, boolean flag) {
- fieldMatchMapBuilder.put(fieldId, new PiValidFieldMatch(fieldId, flag));
- return this;
- }
-
- /**
* Adds a range field match for the given fieldId, low and high.
*
* @param fieldId protocol-independent header field Id
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiMatchType.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiMatchType.java
index 1e24fce..f4fce3e 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiMatchType.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiMatchType.java
@@ -40,11 +40,6 @@
LPM,
/**
- * Valid match type.
- */
- VALID,
-
- /**
* Range match type.
*/
RANGE
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiValidFieldMatch.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiValidFieldMatch.java
deleted file mode 100644
index 7894ba82..0000000
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiValidFieldMatch.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.net.pi.runtime;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Objects;
-import org.onosproject.net.pi.model.PiMatchFieldId;
-import org.onosproject.net.pi.model.PiMatchType;
-
-/**
- * Instance of a valid field match in a protocol-independent pipeline.
- */
-@Beta
-public final class PiValidFieldMatch extends PiFieldMatch {
-
- private final boolean isValid;
-
- /**
- * Creates a new valid field match.
- *
- * @param fieldId field identifier
- * @param isValid validity flag
- */
- public PiValidFieldMatch(PiMatchFieldId fieldId, boolean isValid) {
- super(fieldId);
- this.isValid = isValid;
- }
-
- @Override
- public final PiMatchType type() {
- return PiMatchType.VALID;
- }
-
- /**
- * Returns the boolean flag of this valid match parameter.
- *
- * @return valid match flag
- */
- public boolean isValid() {
- return isValid;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- PiValidFieldMatch that = (PiValidFieldMatch) o;
- return Objects.equal(this.fieldId(), that.fieldId()) &&
- isValid == that.isValid;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(this.fieldId(), isValid);
- }
-
- @Override
- public String toString() {
- return this.fieldId().toString() + '=' + (isValid ? "VALID" : "NOT_VALID");
- }
-}
diff --git a/core/api/src/test/java/org/onosproject/net/flow/criteria/PiCriteriaTest.java b/core/api/src/test/java/org/onosproject/net/flow/criteria/PiCriteriaTest.java
index ab0446d..bd11252 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/criteria/PiCriteriaTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/criteria/PiCriteriaTest.java
@@ -24,7 +24,6 @@
import org.onosproject.net.pi.runtime.PiLpmFieldMatch;
import org.onosproject.net.pi.runtime.PiRangeFieldMatch;
import org.onosproject.net.pi.runtime.PiTernaryFieldMatch;
-import org.onosproject.net.pi.runtime.PiValidFieldMatch;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
@@ -154,10 +153,6 @@
private Criterion matchPiTernaryLong2 = PiCriterion.builder()
.matchTernary(ipv4MatchFieldId, matchTernaryLong2, matchTernaryMaskLong).build();
- private Criterion matchPiValid1 = PiCriterion.builder().matchValid(ipv4MatchFieldId, false).build();
- private Criterion sameAsMatchPiValid1 = PiCriterion.builder().matchValid(ipv4MatchFieldId, false).build();
- private Criterion matchPiValid2 = PiCriterion.builder().matchValid(ipv4MatchFieldId, true).build();
-
private byte[] matchRangeBytes1 = {0x10};
private byte[] matchRangeBytes2 = {0x20};
private byte[] matchRangeHighBytes = {0x30};
@@ -321,19 +316,6 @@
}
/**
- * Test the ValidMatchPi method.
- */
- @Test
- public void testValidMatchPiMethod() {
-
- Criterion matchPiBytes = PiCriterion.builder().matchValid(ipv4MatchFieldId, true).build();
- PiCriterion piCriterionBytes = checkAndConvert(matchPiBytes, Criterion.Type.PROTOCOL_INDEPENDENT,
- PiCriterion.class);
- PiFieldMatch expectedMatch = new PiValidFieldMatch(ipv4MatchFieldId, true);
- assertThat(piCriterionBytes.fieldMatches().iterator().next(), is(expectedMatch));
- }
-
- /**
* Test the RangeMatchPi method.
*/
@Test
@@ -458,17 +440,6 @@
* Test the equals() method of the PiCriterion class.
*/
@Test
- public void testPiValidCriterionEquals() {
- new EqualsTester()
- .addEqualityGroup(matchPiValid1, sameAsMatchPiValid1)
- .addEqualityGroup(matchPiValid2)
- .testEquals();
- }
-
- /**
- * Test the equals() method of the PiCriterion class.
- */
- @Test
public void testPiRangeCriterionEquals() {
new EqualsTester()
.addEqualityGroup(matchPiRangeByte1, sameAsMatchPiRangeByte1)
diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiValidFieldMatchTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiValidFieldMatchTest.java
deleted file mode 100644
index a62588a..0000000
--- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiValidFieldMatchTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.net.pi.runtime;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-import org.onosproject.net.pi.model.PiMatchFieldId;
-import org.onosproject.net.pi.model.PiMatchType;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-import static org.onosproject.net.pi.runtime.PiConstantsTest.DOT;
-import static org.onosproject.net.pi.runtime.PiConstantsTest.VID;
-import static org.onosproject.net.pi.runtime.PiConstantsTest.VLAN_HEADER_NAME;
-
-/**
- * Unit tests for PiValidFieldMatch class.
- */
-public class PiValidFieldMatchTest {
- private final boolean isValid1 = true;
- private final boolean isValid2 = false;
- private final PiMatchFieldId piMatchField = PiMatchFieldId.of(VLAN_HEADER_NAME + DOT + VID);
- private PiValidFieldMatch piValidFieldMatch1 = new PiValidFieldMatch(piMatchField, isValid1);
- private PiValidFieldMatch sameAsPiValidFieldMatch1 = new PiValidFieldMatch(piMatchField, isValid1);
- private PiValidFieldMatch piValidFieldMatch2 = new PiValidFieldMatch(piMatchField, isValid2);
-
- /**
- * Checks that the PiValidFieldMatch class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(PiValidFieldMatch.class);
- }
-
- /**
- * Checks the operation of equals(), hashCode() and toString() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester()
- .addEqualityGroup(piValidFieldMatch1, sameAsPiValidFieldMatch1)
- .addEqualityGroup(piValidFieldMatch2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a PiValidFieldMatch object.
- */
- @Test
- public void testConstruction() {
- assertThat(piValidFieldMatch1, is(notNullValue()));
- assertThat(piValidFieldMatch1.isValid(), is(isValid1));
- assertThat(piValidFieldMatch1.type(), is(PiMatchType.VALID));
- }
-}
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/DecodeCriterionCodecHelper.java b/core/common/src/main/java/org/onosproject/codec/impl/DecodeCriterionCodecHelper.java
index 9b1b7c2..ac88527 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/DecodeCriterionCodecHelper.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/DecodeCriterionCodecHelper.java
@@ -647,16 +647,6 @@
MISSING_MEMBER_MESSAGE).asText(), null)
);
break;
- case VALID:
- builder.matchValid(
- PiMatchFieldId.of(
- nullIsIllegal(node.get(CriterionCodec.PI_MATCH_FIELD_ID),
- CriterionCodec.PI_MATCH_FIELD_ID +
- MISSING_MEMBER_MESSAGE).asText()),
- nullIsIllegal(node.get(CriterionCodec.PI_MATCH_VALUE),
- CriterionCodec.PI_MATCH_VALUE +
- MISSING_MEMBER_MESSAGE).asBoolean());
- break;
default:
throw new IllegalArgumentException("Type " + type + " is unsupported");
}
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java b/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java
index efdc9ff..83b25a7 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java
@@ -57,7 +57,6 @@
import org.onosproject.net.pi.runtime.PiLpmFieldMatch;
import org.onosproject.net.pi.runtime.PiRangeFieldMatch;
import org.onosproject.net.pi.runtime.PiTernaryFieldMatch;
-import org.onosproject.net.pi.runtime.PiValidFieldMatch;
import java.util.EnumMap;
@@ -542,16 +541,6 @@
return matchRangeNode;
}
- private ObjectNode parsePiMatchValid(PiValidFieldMatch validFieldMatch) {
-
- ObjectNode matchValidNode = context.mapper().createObjectNode();
- matchValidNode.put(CriterionCodec.PI_MATCH_FIELD_ID, validFieldMatch.fieldId().id());
- matchValidNode.put(CriterionCodec.PI_MATCH_TYPE, PiMatchType.VALID.name().toLowerCase());
- matchValidNode.put(CriterionCodec.PI_MATCH_VALUE, validFieldMatch.isValid());
-
- return matchValidNode;
- }
-
private class FormatProtocolIndependent implements CriterionTypeFormatter {
@Override
public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
@@ -569,13 +558,8 @@
matchNodes.add(parsePiMatchTernary((PiTernaryFieldMatch) fieldMatch));
break;
case RANGE:
-
matchNodes.add(parsePiMatchRange((PiRangeFieldMatch) fieldMatch));
break;
- case VALID:
-
- matchNodes.add(parsePiMatchValid((PiValidFieldMatch) fieldMatch));
- break;
default:
throw new IllegalArgumentException("Type " + fieldMatch.type().name() + " is unsupported");
}
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/CriterionCodecTest.java b/core/common/src/test/java/org/onosproject/codec/impl/CriterionCodecTest.java
index c748ab6..2a615c7 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/CriterionCodecTest.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/CriterionCodecTest.java
@@ -51,7 +51,6 @@
import org.onosproject.net.pi.runtime.PiLpmFieldMatch;
import org.onosproject.net.pi.runtime.PiRangeFieldMatch;
import org.onosproject.net.pi.runtime.PiTernaryFieldMatch;
-import org.onosproject.net.pi.runtime.PiValidFieldMatch;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@@ -508,10 +507,6 @@
.matchRange(ipv4MatchFieldId, matchRangeBytes1, matchRangeHighBytes).build();
ObjectNode rangeResult = criterionCodec.encode(rangeBytesCriterion, context);
assertThat(rangeResult, matchesCriterion(rangeBytesCriterion));
-
- Criterion validCriterion = PiCriterion.builder().matchValid(ipv4MatchFieldId, false).build();
- ObjectNode validResult = criterionCodec.encode(validCriterion, context);
- assertThat(validResult, matchesCriterion(validCriterion));
}
/**
@@ -549,12 +544,8 @@
Assert.assertThat(((PiRangeFieldMatch) piFieldMatch).lowValue(),
is(copyFrom((byte) 0x10)));
break;
- case VALID:
- Assert.assertThat(piFieldMatch.fieldId().id(), is("ethernet_t.etherType"));
- Assert.assertThat(((PiValidFieldMatch) piFieldMatch).isValid(), is(true));
- break;
default:
- Assert.assertTrue(false);
+ Assert.fail();
}
}
}
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java b/core/common/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java
index 0b38729..bda5515 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/CriterionJsonMatcher.java
@@ -59,7 +59,6 @@
import org.onosproject.net.pi.runtime.PiLpmFieldMatch;
import org.onosproject.net.pi.runtime.PiRangeFieldMatch;
import org.onosproject.net.pi.runtime.PiTernaryFieldMatch;
-import org.onosproject.net.pi.runtime.PiValidFieldMatch;
import static org.onlab.util.ImmutableByteSequence.copyFrom;
@@ -626,13 +625,6 @@
return false;
}
break;
- case VALID:
- if (!Objects.equals(matchNode.get("value").asBoolean(),
- ((PiValidFieldMatch) fieldMatch).isValid())) {
- description.appendText("match value was " + ((PiValidFieldMatch) fieldMatch).isValid());
- return false;
- }
- break;
default:
description.appendText("match type was " + fieldMatch.type().name().toLowerCase());
return false;
diff --git a/core/common/src/test/resources/org/onosproject/codec/impl/PiCriterion.json b/core/common/src/test/resources/org/onosproject/codec/impl/PiCriterion.json
index 01d9226..d1df49e 100644
--- a/core/common/src/test/resources/org/onosproject/codec/impl/PiCriterion.json
+++ b/core/common/src/test/resources/org/onosproject/codec/impl/PiCriterion.json
@@ -23,11 +23,6 @@
"match": "range",
"highValue": "20",
"lowValue": "10"
- },
- {
- "field": "ethernet_t.etherType",
- "match": "valid",
- "value": true
}
]
-}
\ No newline at end of file
+}
diff --git a/core/net/src/main/java/org/onosproject/net/pi/impl/PiFlowRuleTranslatorImpl.java b/core/net/src/main/java/org/onosproject/net/pi/impl/PiFlowRuleTranslatorImpl.java
index 46238c4e..40a150f 100644
--- a/core/net/src/main/java/org/onosproject/net/pi/impl/PiFlowRuleTranslatorImpl.java
+++ b/core/net/src/main/java/org/onosproject/net/pi/impl/PiFlowRuleTranslatorImpl.java
@@ -71,6 +71,7 @@
final class PiFlowRuleTranslatorImpl {
public static final int MAX_PI_PRIORITY = (int) Math.pow(2, 24);
+ public static final int MIN_PI_PRIORITY = 1;
private static final Logger log = LoggerFactory.getLogger(PiFlowRuleTranslatorImpl.class);
private PiFlowRuleTranslatorImpl() {
@@ -129,15 +130,14 @@
}
if (needPriority) {
- // In the P4 world 0 is the highest priority, in ONOS the lowest one.
- // FIXME: move priority conversion to the P4Runtime driver
+ // FIXME: move priority check to P4Runtime driver.
final int newPriority;
if (rule.priority() > MAX_PI_PRIORITY) {
log.warn("Flow rule priority too big, setting translated priority to max value {}: {}",
MAX_PI_PRIORITY, rule);
- newPriority = 0;
+ newPriority = MAX_PI_PRIORITY;
} else {
- newPriority = MAX_PI_PRIORITY - rule.priority();
+ newPriority = MIN_PI_PRIORITY + rule.priority();
}
tableEntryBuilder.withPriority(newPriority);
}
@@ -441,8 +441,6 @@
return new PiRangeFieldMatch(fieldMatch.fieldId(),
((PiRangeFieldMatch) fieldMatch).lowValue().fit(modelBitWidth),
((PiRangeFieldMatch) fieldMatch).highValue().fit(modelBitWidth));
- case VALID:
- return fieldMatch;
default:
// Should never be here.
throw new IllegalArgumentException(
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
index 47bcd27..f4d15b6 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
@@ -244,7 +244,6 @@
import org.onosproject.net.pi.runtime.PiTableAction;
import org.onosproject.net.pi.runtime.PiTableEntry;
import org.onosproject.net.pi.runtime.PiTernaryFieldMatch;
-import org.onosproject.net.pi.runtime.PiValidFieldMatch;
import org.onosproject.net.pi.runtime.PiTableEntryHandle;
import org.onosproject.net.pi.service.PiTranslatable;
import org.onosproject.net.pi.service.PiTranslatedEntity;
@@ -696,7 +695,6 @@
PiTableAction.class,
PiTableEntry.class,
PiTernaryFieldMatch.class,
- PiValidFieldMatch.class,
// PI service
PiTableEntryHandle.class,
PiTranslatedEntity.class,