Add P4 info to java constant tool
Change-Id: I73a451404e8b657845bfc9b6a37abd824a10910e
diff --git a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricConstants.java b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricConstants.java
index 5bb6a5d..4bb1d92 100644
--- a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricConstants.java
+++ b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricConstants.java
@@ -32,192 +32,160 @@
private FabricConstants() {
}
- public static final String DOT = ".";
- // Header IDs
- public static final String HDR = "hdr";
- public static final String STANDARD_METADATA = "standard_metadata";
- public static final String MPLS = "mpls";
- public static final String FABRIC_METADATA = "fabric_metadata";
- public static final String IPV4 = "ipv4";
- public static final String IPV6 = "ipv6";
- public static final String ETHERNET = "ethernet";
- public static final String VLAN_TAG = "vlan_tag";
- public static final String ICMP = "icmp";
-
// Header field IDs
- public static final PiMatchFieldId HF_FABRIC_METADATA_L4_SRC_PORT_ID =
- buildPiMatchField(FABRIC_METADATA, "l4_src_port", false);
- public static final PiMatchFieldId HF_IPV4_SRC_ADDR_ID =
- buildPiMatchField(IPV4, "src_addr", true);
- public static final PiMatchFieldId HF_VLAN_TAG_VLAN_ID_ID =
- buildPiMatchField(VLAN_TAG, "vlan_id", true);
- public static final PiMatchFieldId HF_MPLS_LABEL_ID =
- buildPiMatchField(MPLS, "label", true);
- public static final PiMatchFieldId HF_IPV6_DST_ADDR_ID =
- buildPiMatchField(IPV6, "dst_addr", true);
- public static final PiMatchFieldId HF_ETHERNET_SRC_ADDR_ID =
- buildPiMatchField(ETHERNET, "src_addr", true);
- public static final PiMatchFieldId HF_ICMP_ICMP_TYPE_ID =
- buildPiMatchField(ICMP, "icmp_type", true);
- public static final PiMatchFieldId HF_STANDARD_METADATA_EGRESS_PORT_ID =
- buildPiMatchField(STANDARD_METADATA, "egress_port", false);
- public static final PiMatchFieldId HF_FABRIC_METADATA_NEXT_ID_ID =
- buildPiMatchField(FABRIC_METADATA, "next_id", false);
- public static final PiMatchFieldId HF_FABRIC_METADATA_L4_DST_PORT_ID =
- buildPiMatchField(FABRIC_METADATA, "l4_dst_port", false);
- public static final PiMatchFieldId HF_STANDARD_METADATA_INGRESS_PORT_ID =
- buildPiMatchField(STANDARD_METADATA, "ingress_port", false);
- public static final PiMatchFieldId HF_FABRIC_METADATA_ORIGINAL_ETHER_TYPE_ID =
- buildPiMatchField(FABRIC_METADATA, "original_ether_type", false);
- public static final PiMatchFieldId HF_IPV4_DST_ADDR_ID =
- buildPiMatchField(IPV4, "dst_addr", true);
- public static final PiMatchFieldId HF_VLAN_TAG_IS_VALID_ID =
- buildPiMatchField(VLAN_TAG, "is_valid", true);
- public static final PiMatchFieldId HF_FABRIC_METADATA_IP_PROTO_ID =
- buildPiMatchField(FABRIC_METADATA, "ip_proto", false);
- public static final PiMatchFieldId HF_ETHERNET_DST_ADDR_ID =
- buildPiMatchField(ETHERNET, "dst_addr", true);
- public static final PiMatchFieldId HF_ICMP_ICMP_CODE_ID =
- buildPiMatchField(ICMP, "icmp_code", true);
-
- private static PiMatchFieldId buildPiMatchField(String header, String field, boolean withHdrPrefix) {
- if (withHdrPrefix) {
- return PiMatchFieldId.of(HDR + DOT + header + DOT + field);
- } else {
- return PiMatchFieldId.of(header + DOT + field);
- }
- }
-
+ public static final PiMatchFieldId FABRIC_METADATA_L4_SRC_PORT =
+ PiMatchFieldId.of("fabric_metadata.l4_src_port");
+ public static final PiMatchFieldId HDR_IPV4_SRC_ADDR =
+ PiMatchFieldId.of("hdr.ipv4.src_addr");
+ public static final PiMatchFieldId HDR_VLAN_TAG_VLAN_ID =
+ PiMatchFieldId.of("hdr.vlan_tag.vlan_id");
+ public static final PiMatchFieldId HDR_MPLS_LABEL =
+ PiMatchFieldId.of("hdr.mpls.label");
+ public static final PiMatchFieldId HDR_IPV6_DST_ADDR =
+ PiMatchFieldId.of("hdr.ipv6.dst_addr");
+ public static final PiMatchFieldId HDR_ETHERNET_SRC_ADDR =
+ PiMatchFieldId.of("hdr.ethernet.src_addr");
+ public static final PiMatchFieldId HDR_ICMP_ICMP_TYPE =
+ PiMatchFieldId.of("hdr.icmp.icmp_type");
+ public static final PiMatchFieldId STANDARD_METADATA_EGRESS_PORT =
+ PiMatchFieldId.of("standard_metadata.egress_port");
+ public static final PiMatchFieldId FABRIC_METADATA_NEXT_ID =
+ PiMatchFieldId.of("fabric_metadata.next_id");
+ public static final PiMatchFieldId FABRIC_METADATA_L4_DST_PORT =
+ PiMatchFieldId.of("fabric_metadata.l4_dst_port");
+ public static final PiMatchFieldId STANDARD_METADATA_INGRESS_PORT =
+ PiMatchFieldId.of("standard_metadata.ingress_port");
+ public static final PiMatchFieldId FABRIC_METADATA_ORIGINAL_ETHER_TYPE =
+ PiMatchFieldId.of("fabric_metadata.original_ether_type");
+ public static final PiMatchFieldId HDR_IPV4_DST_ADDR =
+ PiMatchFieldId.of("hdr.ipv4.dst_addr");
+ public static final PiMatchFieldId HDR_VLAN_TAG_IS_VALID =
+ PiMatchFieldId.of("hdr.vlan_tag.is_valid");
+ public static final PiMatchFieldId FABRIC_METADATA_IP_PROTO =
+ PiMatchFieldId.of("fabric_metadata.ip_proto");
+ public static final PiMatchFieldId HDR_ETHERNET_DST_ADDR =
+ PiMatchFieldId.of("hdr.ethernet.dst_addr");
+ public static final PiMatchFieldId HDR_ICMP_ICMP_CODE =
+ PiMatchFieldId.of("hdr.icmp.icmp_code");
// Table IDs
- public static final PiTableId TBL_ACL_ID =
+ public static final PiTableId FABRIC_INGRESS_FORWARDING_ACL =
PiTableId.of("FabricIngress.forwarding.acl");
- public static final PiTableId TBL_HASHED_ID =
+ public static final PiTableId FABRIC_INGRESS_NEXT_HASHED =
PiTableId.of("FabricIngress.next.hashed");
- public static final PiTableId TBL_EGRESS_VLAN_ID =
+ public static final PiTableId FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN =
PiTableId.of("FabricEgress.egress_next.egress_vlan");
- public static final PiTableId TBL_MPLS_ID =
+ public static final PiTableId FABRIC_INGRESS_FORWARDING_MPLS =
PiTableId.of("FabricIngress.forwarding.mpls");
- public static final PiTableId TBL_MULTICAST_ID =
+ public static final PiTableId FABRIC_INGRESS_NEXT_MULTICAST =
PiTableId.of("FabricIngress.next.multicast");
- public static final PiTableId TBL_MULTICAST_V4_ID =
+ public static final PiTableId FABRIC_INGRESS_FORWARDING_MULTICAST_V4 =
PiTableId.of("FabricIngress.forwarding.multicast_v4");
- public static final PiTableId TBL_MULTICAST_V6_ID =
+ public static final PiTableId FABRIC_INGRESS_FORWARDING_MULTICAST_V6 =
PiTableId.of("FabricIngress.forwarding.multicast_v6");
- public static final PiTableId TBL_UNICAST_V4_ID =
+ public static final PiTableId FABRIC_INGRESS_FORWARDING_UNICAST_V4 =
PiTableId.of("FabricIngress.forwarding.unicast_v4");
- public static final PiTableId TBL_FWD_CLASSIFIER_ID =
+ public static final PiTableId FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER =
PiTableId.of("FabricIngress.filtering.fwd_classifier");
- public static final PiTableId TBL_BRIDGING_ID =
+ public static final PiTableId FABRIC_INGRESS_FORWARDING_BRIDGING =
PiTableId.of("FabricIngress.forwarding.bridging");
- public static final PiTableId TBL_SIMPLE_ID =
+ public static final PiTableId FABRIC_INGRESS_NEXT_SIMPLE =
PiTableId.of("FabricIngress.next.simple");
- public static final PiTableId TBL_INGRESS_PORT_VLAN_ID =
+ public static final PiTableId FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN =
PiTableId.of("FabricIngress.filtering.ingress_port_vlan");
- public static final PiTableId TBL_UNICAST_V6_ID =
+ public static final PiTableId FABRIC_INGRESS_FORWARDING_UNICAST_V6 =
PiTableId.of("FabricIngress.forwarding.unicast_v6");
- public static final PiTableId TBL_VLAN_META_ID =
+ public static final PiTableId FABRIC_INGRESS_NEXT_VLAN_META =
PiTableId.of("FabricIngress.next.vlan_meta");
-
// Indirect Counter IDs
- public static final PiCounterId CNT_EGRESS_PORT_COUNTER_ID =
+ public static final PiCounterId FABRIC_INGRESS_PORT_COUNTERS_CONTROL_EGRESS_PORT_COUNTER =
PiCounterId.of("FabricIngress.port_counters_control.egress_port_counter");
- public static final PiCounterId CNT_INGRESS_PORT_COUNTER_ID =
+ public static final PiCounterId FABRIC_INGRESS_PORT_COUNTERS_CONTROL_INGRESS_PORT_COUNTER =
PiCounterId.of("FabricIngress.port_counters_control.ingress_port_counter");
-
// Direct Counter IDs
- public static final PiCounterId CNT_ACL_COUNTER_ID =
+ public static final PiCounterId FABRIC_INGRESS_FORWARDING_ACL_COUNTER =
PiCounterId.of("FabricIngress.forwarding.acl_counter");
- public static final PiCounterId CNT_MULTICAST_COUNTER_ID =
+ public static final PiCounterId FABRIC_INGRESS_NEXT_MULTICAST_COUNTER =
PiCounterId.of("FabricIngress.next.multicast_counter");
- public static final PiCounterId CNT_VLAN_META_COUNTER_ID =
+ public static final PiCounterId FABRIC_INGRESS_NEXT_VLAN_META_COUNTER =
PiCounterId.of("FabricIngress.next.vlan_meta_counter");
- public static final PiCounterId CNT_FWD_CLASSIFIER_COUNTER_ID =
+ public static final PiCounterId FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER_COUNTER =
PiCounterId.of("FabricIngress.filtering.fwd_classifier_counter");
- public static final PiCounterId CNT_BRIDGING_COUNTER_ID =
+ public static final PiCounterId FABRIC_INGRESS_FORWARDING_BRIDGING_COUNTER =
PiCounterId.of("FabricIngress.forwarding.bridging_counter");
- public static final PiCounterId CNT_MULTICAST_V6_COUNTER_ID =
+ public static final PiCounterId FABRIC_INGRESS_FORWARDING_MULTICAST_V6_COUNTER =
PiCounterId.of("FabricIngress.forwarding.multicast_v6_counter");
- public static final PiCounterId CNT_MULTICAST_V4_COUNTER_ID =
+ public static final PiCounterId FABRIC_INGRESS_FORWARDING_MULTICAST_V4_COUNTER =
PiCounterId.of("FabricIngress.forwarding.multicast_v4_counter");
- public static final PiCounterId CNT_UNICAST_V6_COUNTER_ID =
+ public static final PiCounterId FABRIC_INGRESS_FORWARDING_UNICAST_V6_COUNTER =
PiCounterId.of("FabricIngress.forwarding.unicast_v6_counter");
- public static final PiCounterId CNT_UNICAST_V4_COUNTER_ID =
+ public static final PiCounterId FABRIC_INGRESS_FORWARDING_UNICAST_V4_COUNTER =
PiCounterId.of("FabricIngress.forwarding.unicast_v4_counter");
- public static final PiCounterId CNT_SIMPLE_COUNTER_ID =
+ public static final PiCounterId FABRIC_INGRESS_NEXT_SIMPLE_COUNTER =
PiCounterId.of("FabricIngress.next.simple_counter");
- public static final PiCounterId CNT_INGRESS_PORT_VLAN_COUNTER_ID =
+ public static final PiCounterId FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN_COUNTER =
PiCounterId.of("FabricIngress.filtering.ingress_port_vlan_counter");
- public static final PiCounterId CNT_MPLS_COUNTER_ID =
+ public static final PiCounterId FABRIC_INGRESS_FORWARDING_MPLS_COUNTER =
PiCounterId.of("FabricIngress.forwarding.mpls_counter");
- public static final PiCounterId CNT_HASHED_COUNTER_ID =
+ public static final PiCounterId FABRIC_INGRESS_NEXT_HASHED_COUNTER =
PiCounterId.of("FabricIngress.next.hashed_counter");
-
// Action IDs
- public static final PiActionId ACT_FABRICINGRESS_FILTERING_DROP_ID =
+ public static final PiActionId FABRIC_INGRESS_FILTERING_DROP =
PiActionId.of("FabricIngress.filtering.drop");
- public static final PiActionId ACT_FABRICINGRESS_NEXT_SET_VLAN_ID =
+ public static final PiActionId FABRIC_INGRESS_NEXT_SET_VLAN =
PiActionId.of("FabricIngress.next.set_vlan");
- public static final PiActionId ACT_FABRICINGRESS_FORWARDING_POP_MPLS_AND_NEXT_ID =
+ public static final PiActionId FABRIC_INGRESS_FORWARDING_POP_MPLS_AND_NEXT =
PiActionId.of("FabricIngress.forwarding.pop_mpls_and_next");
- public static final PiActionId ACT_FABRICEGRESS_EGRESS_NEXT_POP_VLAN_ID =
+ public static final PiActionId FABRIC_EGRESS_EGRESS_NEXT_POP_VLAN =
PiActionId.of("FabricEgress.egress_next.pop_vlan");
- public static final PiActionId ACT_FABRICINGRESS_FILTERING_SET_FORWARDING_TYPE_ID =
+ public static final PiActionId FABRIC_INGRESS_FILTERING_SET_FORWARDING_TYPE =
PiActionId.of("FabricIngress.filtering.set_forwarding_type");
- public static final PiActionId ACT_NOP_ID = PiActionId.of("nop");
- public static final PiActionId ACT_FABRICINGRESS_FILTERING_SET_VLAN_ID =
+ public static final PiActionId NOP = PiActionId.of("nop");
+ public static final PiActionId FABRIC_INGRESS_FILTERING_SET_VLAN =
PiActionId.of("FabricIngress.filtering.set_vlan");
- public static final PiActionId ACT_FABRICINGRESS_NEXT_MPLS_ROUTING_V6_ID =
+ public static final PiActionId FABRIC_INGRESS_NEXT_MPLS_ROUTING_V6 =
PiActionId.of("FabricIngress.next.mpls_routing_v6");
- public static final PiActionId ACT_FABRICEGRESS_PKT_IO_EGRESS_POP_VLAN_ID =
+ public static final PiActionId FABRIC_EGRESS_PKT_IO_EGRESS_POP_VLAN =
PiActionId.of("FabricEgress.pkt_io_egress.pop_vlan");
- public static final PiActionId ACT_FABRICINGRESS_NEXT_L3_ROUTING_VLAN_ID =
+ public static final PiActionId FABRIC_INGRESS_NEXT_L3_ROUTING_VLAN =
PiActionId.of("FabricIngress.next.l3_routing_vlan");
- public static final PiActionId ACT_NOACTION_ID = PiActionId.of("NoAction");
- public static final PiActionId ACT_FABRICINGRESS_NEXT_SET_MCAST_GROUP_ID =
+ public static final PiActionId NO_ACTION = PiActionId.of("NoAction");
+ public static final PiActionId FABRIC_INGRESS_NEXT_SET_MCAST_GROUP =
PiActionId.of("FabricIngress.next.set_mcast_group");
- public static final PiActionId ACT_FABRICINGRESS_FORWARDING_DUPLICATE_TO_CONTROLLER_ID =
+ public static final PiActionId FABRIC_INGRESS_FORWARDING_DUPLICATE_TO_CONTROLLER =
PiActionId.of("FabricIngress.forwarding.duplicate_to_controller");
- public static final PiActionId ACT_FABRICINGRESS_NEXT_L3_ROUTING_ID =
+ public static final PiActionId FABRIC_INGRESS_NEXT_L3_ROUTING =
PiActionId.of("FabricIngress.next.l3_routing");
- public static final PiActionId ACT_FABRICINGRESS_NEXT_MPLS_ROUTING_V4_ID =
+ public static final PiActionId FABRIC_INGRESS_NEXT_MPLS_ROUTING_V4 =
PiActionId.of("FabricIngress.next.mpls_routing_v4");
- public static final PiActionId ACT_FABRICINGRESS_NEXT_SET_VLAN_OUTPUT_ID =
+ public static final PiActionId FABRIC_INGRESS_NEXT_SET_VLAN_OUTPUT =
PiActionId.of("FabricIngress.next.set_vlan_output");
- public static final PiActionId ACT_FABRICINGRESS_FORWARDING_SET_NEXT_ID_ID =
+ public static final PiActionId FABRIC_INGRESS_FORWARDING_SET_NEXT_ID =
PiActionId.of("FabricIngress.forwarding.set_next_id");
- public static final PiActionId ACT_FABRICINGRESS_FILTERING_PUSH_INTERNAL_VLAN_ID =
+ public static final PiActionId FABRIC_INGRESS_FILTERING_PUSH_INTERNAL_VLAN =
PiActionId.of("FabricIngress.filtering.push_internal_vlan");
- public static final PiActionId ACT_FABRICINGRESS_FORWARDING_DROP_ID =
+ public static final PiActionId FABRIC_INGRESS_FORWARDING_DROP =
PiActionId.of("FabricIngress.forwarding.drop");
- public static final PiActionId ACT_FABRICINGRESS_NEXT_OUTPUT_ID =
+ public static final PiActionId FABRIC_INGRESS_NEXT_OUTPUT =
PiActionId.of("FabricIngress.next.output");
-
// Action Param IDs
- public static final PiActionParamId ACT_PRM_DMAC_ID =
- PiActionParamId.of("dmac");
- public static final PiActionParamId ACT_PRM_PORT_NUM_ID =
+ public static final PiActionParamId DMAC = PiActionParamId.of("dmac");
+ public static final PiActionParamId PORT_NUM =
PiActionParamId.of("port_num");
- public static final PiActionParamId ACT_PRM_LABEL_ID =
- PiActionParamId.of("label");
- public static final PiActionParamId ACT_PRM_SMAC_ID =
- PiActionParamId.of("smac");
- public static final PiActionParamId ACT_PRM_GID_ID =
- PiActionParamId.of("gid");
- public static final PiActionParamId ACT_PRM_NEW_VLAN_ID_ID =
+ public static final PiActionParamId LABEL = PiActionParamId.of("label");
+ public static final PiActionParamId SMAC = PiActionParamId.of("smac");
+ public static final PiActionParamId GID = PiActionParamId.of("gid");
+ public static final PiActionParamId NEW_VLAN_ID =
PiActionParamId.of("new_vlan_id");
- public static final PiActionParamId ACT_PRM_FWD_TYPE_ID =
+ public static final PiActionParamId FWD_TYPE =
PiActionParamId.of("fwd_type");
- public static final PiActionParamId ACT_PRM_NEXT_ID_ID =
- PiActionParamId.of("next_id");
-
+ public static final PiActionParamId NEXT_ID = PiActionParamId.of("next_id");
// Action Profile IDs
- public static final PiActionProfileId ACT_PRF_FABRICINGRESS_NEXT_ECMP_SELECTOR_ID =
+ public static final PiActionProfileId FABRIC_INGRESS_NEXT_ECMP_SELECTOR =
PiActionProfileId.of("FabricIngress.next.ecmp_selector");
-
// Packet Metadata IDs
- public static final PiControlMetadataId CTRL_META_INGRESS_PORT_ID =
+ public static final PiControlMetadataId INGRESS_PORT =
PiControlMetadataId.of("ingress_port");
- public static final PiControlMetadataId CTRL_META_EGRESS_PORT_ID =
+ public static final PiControlMetadataId EGRESS_PORT =
PiControlMetadataId.of("egress_port");
public static final int PORT_BITWIDTH = 9;
-}
+}
\ No newline at end of file
diff --git a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricInterpreter.java b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricInterpreter.java
index fb85ff3..2c698a5 100644
--- a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricInterpreter.java
+++ b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricInterpreter.java
@@ -63,75 +63,79 @@
private static final ImmutableBiMap<Integer, PiTableId> TABLE_ID_MAP =
ImmutableBiMap.<Integer, PiTableId>builder()
// Filtering
- .put(0, FabricConstants.TBL_INGRESS_PORT_VLAN_ID)
- .put(1, FabricConstants.TBL_FWD_CLASSIFIER_ID)
+ .put(0, FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN)
+ .put(1, FabricConstants.FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER)
// Forwarding
- .put(2, FabricConstants.TBL_MPLS_ID)
- .put(3, FabricConstants.TBL_UNICAST_V4_ID)
- .put(4, FabricConstants.TBL_UNICAST_V6_ID)
- .put(5, FabricConstants.TBL_MULTICAST_V4_ID)
- .put(6, FabricConstants.TBL_MULTICAST_V6_ID)
- .put(7, FabricConstants.TBL_BRIDGING_ID)
- .put(8, FabricConstants.TBL_ACL_ID)
+ .put(2, FabricConstants.FABRIC_INGRESS_FORWARDING_MPLS)
+ .put(3, FabricConstants.FABRIC_INGRESS_FORWARDING_UNICAST_V4)
+ .put(4, FabricConstants.FABRIC_INGRESS_FORWARDING_UNICAST_V6)
+ .put(5, FabricConstants.FABRIC_INGRESS_FORWARDING_MULTICAST_V4)
+ .put(6, FabricConstants.FABRIC_INGRESS_FORWARDING_MULTICAST_V6)
+ .put(7, FabricConstants.FABRIC_INGRESS_FORWARDING_BRIDGING)
+ .put(8, FabricConstants.FABRIC_INGRESS_FORWARDING_ACL)
// Next
- .put(9, FabricConstants.TBL_SIMPLE_ID)
- .put(10, FabricConstants.TBL_HASHED_ID)
- .put(11, FabricConstants.TBL_MULTICAST_ID)
+ .put(9, FabricConstants.FABRIC_INGRESS_NEXT_VLAN_META)
+ .put(10, FabricConstants.FABRIC_INGRESS_NEXT_SIMPLE)
+ .put(11, FabricConstants.FABRIC_INGRESS_NEXT_HASHED)
+ .put(12, FabricConstants.FABRIC_INGRESS_NEXT_MULTICAST)
+ .put(13, FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN)
.build();
- private static final Set<PiTableId> FILTERING_CTRL_TBLS = ImmutableSet.of(FabricConstants.TBL_INGRESS_PORT_VLAN_ID,
- FabricConstants.TBL_FWD_CLASSIFIER_ID);
- private static final Set<PiTableId> FORWARDING_CTRL_TBLS = ImmutableSet.of(FabricConstants.TBL_MPLS_ID,
- FabricConstants.TBL_UNICAST_V4_ID,
- FabricConstants.TBL_UNICAST_V6_ID,
- FabricConstants.TBL_MULTICAST_V4_ID,
- FabricConstants.TBL_MULTICAST_V6_ID,
- FabricConstants.TBL_BRIDGING_ID,
- FabricConstants.TBL_ACL_ID);
- private static final Set<PiTableId> NEXT_CTRL_TBLS = ImmutableSet.of(FabricConstants.TBL_SIMPLE_ID,
- FabricConstants.TBL_HASHED_ID,
- FabricConstants.TBL_MULTICAST_ID,
- FabricConstants.TBL_VLAN_META_ID);
-
- private static final Set<PiTableId> E_NEXT_CTRL_TBLS = ImmutableSet.of(FabricConstants.TBL_EGRESS_VLAN_ID);
+ private static final Set<PiTableId> FILTERING_CTRL_TBLS =
+ ImmutableSet.of(FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN,
+ FabricConstants.FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER);
+ private static final Set<PiTableId> FORWARDING_CTRL_TBLS =
+ ImmutableSet.of(FabricConstants.FABRIC_INGRESS_FORWARDING_MPLS,
+ FabricConstants.FABRIC_INGRESS_FORWARDING_UNICAST_V4,
+ FabricConstants.FABRIC_INGRESS_FORWARDING_UNICAST_V6,
+ FabricConstants.FABRIC_INGRESS_FORWARDING_MULTICAST_V4,
+ FabricConstants.FABRIC_INGRESS_FORWARDING_MULTICAST_V6,
+ FabricConstants.FABRIC_INGRESS_FORWARDING_BRIDGING,
+ FabricConstants.FABRIC_INGRESS_FORWARDING_ACL);
+ private static final Set<PiTableId> NEXT_CTRL_TBLS =
+ ImmutableSet.of(FabricConstants.FABRIC_INGRESS_NEXT_SIMPLE,
+ FabricConstants.FABRIC_INGRESS_NEXT_HASHED,
+ FabricConstants.FABRIC_INGRESS_NEXT_MULTICAST);
+ private static final Set<PiTableId> E_NEXT_CTRL_TBLS =
+ ImmutableSet.of(FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN);
private static final ImmutableMap<Criterion.Type, PiMatchFieldId> CRITERION_MAP =
ImmutableMap.<Criterion.Type, PiMatchFieldId>builder()
- .put(Criterion.Type.IN_PORT, FabricConstants.HF_STANDARD_METADATA_INGRESS_PORT_ID)
- .put(Criterion.Type.ETH_DST, FabricConstants.HF_ETHERNET_DST_ADDR_ID)
- .put(Criterion.Type.ETH_SRC, FabricConstants.HF_ETHERNET_SRC_ADDR_ID)
- .put(Criterion.Type.ETH_TYPE, FabricConstants.HF_FABRIC_METADATA_ORIGINAL_ETHER_TYPE_ID)
- .put(Criterion.Type.MPLS_LABEL, FabricConstants.HF_MPLS_LABEL_ID)
- .put(Criterion.Type.VLAN_VID, FabricConstants.HF_VLAN_TAG_VLAN_ID_ID)
- .put(Criterion.Type.IPV4_DST, FabricConstants.HF_IPV4_DST_ADDR_ID)
- .put(Criterion.Type.IPV4_SRC, FabricConstants.HF_IPV4_SRC_ADDR_ID)
- .put(Criterion.Type.IPV6_DST, FabricConstants.HF_IPV6_DST_ADDR_ID)
- .put(Criterion.Type.TCP_SRC, FabricConstants.HF_FABRIC_METADATA_L4_SRC_PORT_ID)
- .put(Criterion.Type.TCP_DST, FabricConstants.HF_FABRIC_METADATA_L4_DST_PORT_ID)
- .put(Criterion.Type.UDP_SRC, FabricConstants.HF_FABRIC_METADATA_L4_SRC_PORT_ID)
- .put(Criterion.Type.UDP_DST, FabricConstants.HF_FABRIC_METADATA_L4_DST_PORT_ID)
- .put(Criterion.Type.IP_PROTO, FabricConstants.HF_FABRIC_METADATA_IP_PROTO_ID)
- .put(Criterion.Type.ICMPV6_TYPE, FabricConstants.HF_ICMP_ICMP_TYPE_ID)
- .put(Criterion.Type.ICMPV6_CODE, FabricConstants.HF_ICMP_ICMP_CODE_ID)
+ .put(Criterion.Type.IN_PORT, FabricConstants.STANDARD_METADATA_INGRESS_PORT)
+ .put(Criterion.Type.ETH_DST, FabricConstants.HDR_ETHERNET_DST_ADDR)
+ .put(Criterion.Type.ETH_SRC, FabricConstants.HDR_ETHERNET_SRC_ADDR)
+ .put(Criterion.Type.ETH_TYPE, FabricConstants.FABRIC_METADATA_ORIGINAL_ETHER_TYPE)
+ .put(Criterion.Type.MPLS_LABEL, FabricConstants.HDR_MPLS_LABEL)
+ .put(Criterion.Type.VLAN_VID, FabricConstants.HDR_VLAN_TAG_VLAN_ID)
+ .put(Criterion.Type.IPV4_DST, FabricConstants.HDR_IPV4_DST_ADDR)
+ .put(Criterion.Type.IPV4_SRC, FabricConstants.HDR_IPV4_SRC_ADDR)
+ .put(Criterion.Type.IPV6_DST, FabricConstants.HDR_IPV6_DST_ADDR)
+ .put(Criterion.Type.TCP_SRC, FabricConstants.FABRIC_METADATA_L4_SRC_PORT)
+ .put(Criterion.Type.TCP_DST, FabricConstants.FABRIC_METADATA_L4_DST_PORT)
+ .put(Criterion.Type.UDP_SRC, FabricConstants.FABRIC_METADATA_L4_SRC_PORT)
+ .put(Criterion.Type.UDP_DST, FabricConstants.FABRIC_METADATA_L4_DST_PORT)
+ .put(Criterion.Type.IP_PROTO, FabricConstants.FABRIC_METADATA_IP_PROTO)
+ .put(Criterion.Type.ICMPV6_TYPE, FabricConstants.HDR_ICMP_ICMP_TYPE)
+ .put(Criterion.Type.ICMPV6_CODE, FabricConstants.HDR_ICMP_ICMP_CODE)
.build();
private static final ImmutableMap<PiMatchFieldId, Criterion.Type> INVERSE_CRITERION_MAP =
ImmutableMap.<PiMatchFieldId, Criterion.Type>builder()
- .put(FabricConstants.HF_STANDARD_METADATA_INGRESS_PORT_ID, Criterion.Type.IN_PORT)
- .put(FabricConstants.HF_ETHERNET_DST_ADDR_ID, Criterion.Type.ETH_DST)
- .put(FabricConstants.HF_ETHERNET_SRC_ADDR_ID, Criterion.Type.ETH_SRC)
- .put(FabricConstants.HF_FABRIC_METADATA_ORIGINAL_ETHER_TYPE_ID, Criterion.Type.ETH_TYPE)
- .put(FabricConstants.HF_MPLS_LABEL_ID, Criterion.Type.MPLS_LABEL)
- .put(FabricConstants.HF_VLAN_TAG_VLAN_ID_ID, Criterion.Type.VLAN_VID)
- .put(FabricConstants.HF_IPV4_DST_ADDR_ID, Criterion.Type.IPV4_DST)
- .put(FabricConstants.HF_IPV4_SRC_ADDR_ID, Criterion.Type.IPV4_SRC)
- .put(FabricConstants.HF_IPV6_DST_ADDR_ID, Criterion.Type.IPV6_DST)
+ .put(FabricConstants.STANDARD_METADATA_INGRESS_PORT, Criterion.Type.IN_PORT)
+ .put(FabricConstants.HDR_ETHERNET_DST_ADDR, Criterion.Type.ETH_DST)
+ .put(FabricConstants.HDR_ETHERNET_SRC_ADDR, Criterion.Type.ETH_SRC)
+ .put(FabricConstants.FABRIC_METADATA_ORIGINAL_ETHER_TYPE, Criterion.Type.ETH_TYPE)
+ .put(FabricConstants.HDR_MPLS_LABEL, Criterion.Type.MPLS_LABEL)
+ .put(FabricConstants.HDR_VLAN_TAG_VLAN_ID, Criterion.Type.VLAN_VID)
+ .put(FabricConstants.HDR_IPV4_DST_ADDR, Criterion.Type.IPV4_DST)
+ .put(FabricConstants.HDR_IPV4_SRC_ADDR, Criterion.Type.IPV4_SRC)
+ .put(FabricConstants.HDR_IPV6_DST_ADDR, Criterion.Type.IPV6_DST)
// FIXME: might be incorrect if we inverse the map....
- .put(FabricConstants.HF_FABRIC_METADATA_L4_SRC_PORT_ID, Criterion.Type.UDP_SRC)
- .put(FabricConstants.HF_FABRIC_METADATA_L4_DST_PORT_ID, Criterion.Type.UDP_DST)
- .put(FabricConstants.HF_FABRIC_METADATA_IP_PROTO_ID, Criterion.Type.IP_PROTO)
- .put(FabricConstants.HF_ICMP_ICMP_TYPE_ID, Criterion.Type.ICMPV6_TYPE)
- .put(FabricConstants.HF_ICMP_ICMP_CODE_ID, Criterion.Type.ICMPV6_CODE)
+ .put(FabricConstants.FABRIC_METADATA_L4_SRC_PORT, Criterion.Type.UDP_SRC)
+ .put(FabricConstants.FABRIC_METADATA_L4_DST_PORT, Criterion.Type.UDP_DST)
+ .put(FabricConstants.FABRIC_METADATA_IP_PROTO, Criterion.Type.IP_PROTO)
+ .put(FabricConstants.HDR_ICMP_ICMP_TYPE, Criterion.Type.ICMPV6_TYPE)
+ .put(FabricConstants.HDR_ICMP_ICMP_CODE, Criterion.Type.ICMPV6_CODE)
.build();
@Override
@@ -185,7 +189,7 @@
private PiControlMetadata createPacketMetadata(long portNumber) throws PiInterpreterException {
try {
return PiControlMetadata.builder()
- .withId(FabricConstants.CTRL_META_EGRESS_PORT_ID)
+ .withId(FabricConstants.EGRESS_PORT)
.withValue(copyFrom(portNumber).fit(FabricConstants.PORT_BITWIDTH))
.build();
} catch (ImmutableByteSequence.ByteSequenceTrimException e) {
@@ -247,7 +251,7 @@
// Returns the ingress port packet metadata.
Optional<PiControlMetadata> packetMetadata = packetIn.metadatas()
- .stream().filter(m -> m.id().equals(FabricConstants.CTRL_META_INGRESS_PORT_ID))
+ .stream().filter(m -> m.id().equals(FabricConstants.INGRESS_PORT))
.findFirst();
if (packetMetadata.isPresent()) {
@@ -259,7 +263,7 @@
} else {
throw new PiInterpreterException(format(
"Missing metadata '%s' in packet-in received from '%s': %s",
- FabricConstants.CTRL_META_INGRESS_PORT_ID, deviceId, packetIn));
+ FabricConstants.INGRESS_PORT, deviceId, packetIn));
}
}
}
diff --git a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricPortStatisticsDiscovery.java b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricPortStatisticsDiscovery.java
index a9e3f3b..ab44040 100644
--- a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricPortStatisticsDiscovery.java
+++ b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricPortStatisticsDiscovery.java
@@ -32,7 +32,7 @@
*/
@Override
public PiCounterId ingressCounterId() {
- return FabricConstants.CNT_INGRESS_PORT_COUNTER_ID;
+ return FabricConstants.FABRIC_INGRESS_PORT_COUNTERS_CONTROL_INGRESS_PORT_COUNTER;
}
/**
@@ -42,6 +42,6 @@
*/
@Override
public PiCounterId egressCounterId() {
- return FabricConstants.CNT_EGRESS_PORT_COUNTER_ID;
+ return FabricConstants.FABRIC_INGRESS_PORT_COUNTERS_CONTROL_EGRESS_PORT_COUNTER;
}
}
diff --git a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricTreatmentInterpreter.java b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricTreatmentInterpreter.java
index 3be56bb..2c41985 100644
--- a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricTreatmentInterpreter.java
+++ b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/FabricTreatmentInterpreter.java
@@ -51,11 +51,11 @@
private static final Logger log = getLogger(FabricTreatmentInterpreter.class);
private static final String INVALID_TREATMENT = "Invalid treatment for %s block: %s";
private static final PiAction NOP = PiAction.builder()
- .withId(FabricConstants.ACT_NOP_ID)
+ .withId(FabricConstants.NOP)
.build();
private static final PiAction POP_VLAN = PiAction.builder()
- .withId(FabricConstants.ACT_FABRICEGRESS_EGRESS_NEXT_POP_VLAN_ID)
+ .withId(FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_POP_VLAN)
.build();
// Hide default constructor
@@ -103,14 +103,14 @@
}
VlanId vlanId = setVlanInst.vlanId();
- PiActionParam param = new PiActionParam(FabricConstants.ACT_PRM_NEW_VLAN_ID_ID,
+ PiActionParam param = new PiActionParam(FabricConstants.NEW_VLAN_ID,
ImmutableByteSequence.copyFrom(vlanId.toShort()));
PiActionId actionId;
if (pushVlanInst != null) {
// push_internal_vlan
- actionId = FabricConstants.ACT_FABRICINGRESS_FILTERING_PUSH_INTERNAL_VLAN_ID;
+ actionId = FabricConstants.FABRIC_INGRESS_FILTERING_PUSH_INTERNAL_VLAN;
} else {
- actionId = FabricConstants.ACT_FABRICINGRESS_FILTERING_SET_VLAN_ID;
+ actionId = FabricConstants.FABRIC_INGRESS_FILTERING_SET_VLAN;
}
// set_vlan
@@ -155,7 +155,7 @@
}
return PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_FORWARDING_DUPLICATE_TO_CONTROLLER_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_FORWARDING_DUPLICATE_TO_CONTROLLER)
.build();
}
@@ -219,11 +219,10 @@
// set_vlan
VlanId vlanId = modVlanIdInst.vlanId();
PiActionParam newVlanParam =
- new PiActionParam(FabricConstants.ACT_PRM_NEW_VLAN_ID_ID,
+ new PiActionParam(FabricConstants.NEW_VLAN_ID,
ImmutableByteSequence.copyFrom(vlanId.toShort()));
- // set_vlan_output
return PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_NEXT_SET_VLAN_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_NEXT_SET_VLAN)
.withParameter(newVlanParam)
.build();
} else {
@@ -232,23 +231,23 @@
}
short portNum = (short) outInst.port().toLong();
- PiActionParam portNumParam = new PiActionParam(FabricConstants.ACT_PRM_PORT_NUM_ID,
+ PiActionParam portNumParam = new PiActionParam(FabricConstants.PORT_NUM,
ImmutableByteSequence.copyFrom(portNum));
if (modEthDstInst == null && modEthSrcInst == null) {
if (modVlanIdInst != null) {
VlanId vlanId = modVlanIdInst.vlanId();
PiActionParam vlanParam =
- new PiActionParam(FabricConstants.ACT_PRM_NEW_VLAN_ID_ID,
+ new PiActionParam(FabricConstants.NEW_VLAN_ID,
ImmutableByteSequence.copyFrom(vlanId.toShort()));
// set_vlan_output
return PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_NEXT_SET_VLAN_OUTPUT_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_NEXT_SET_VLAN_OUTPUT)
.withParameters(ImmutableList.of(portNumParam, vlanParam))
.build();
} else {
// output
return PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_NEXT_OUTPUT_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_NEXT_OUTPUT)
.withParameter(portNumParam)
.build();
}
@@ -257,9 +256,9 @@
if (modEthDstInst != null && modEthSrcInst != null) {
MacAddress srcMac = modEthSrcInst.mac();
MacAddress dstMac = modEthDstInst.mac();
- PiActionParam srcMacParam = new PiActionParam(FabricConstants.ACT_PRM_SMAC_ID,
+ PiActionParam srcMacParam = new PiActionParam(FabricConstants.SMAC,
ImmutableByteSequence.copyFrom(srcMac.toBytes()));
- PiActionParam dstMacParam = new PiActionParam(FabricConstants.ACT_PRM_DMAC_ID,
+ PiActionParam dstMacParam = new PiActionParam(FabricConstants.DMAC,
ImmutableByteSequence.copyFrom(dstMac.toBytes()));
if (modMplsInst != null) {
@@ -268,10 +267,10 @@
try {
ImmutableByteSequence mplsValue =
ImmutableByteSequence.copyFrom(mplsLabel.toInt()).fit(20);
- PiActionParam mplsParam = new PiActionParam(FabricConstants.ACT_PRM_LABEL_ID, mplsValue);
+ PiActionParam mplsParam = new PiActionParam(FabricConstants.LABEL, mplsValue);
return PiAction.builder()
// FIXME: fins a way to determine v4 or v6
- .withId(FabricConstants.ACT_FABRICINGRESS_NEXT_MPLS_ROUTING_V4_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_NEXT_MPLS_ROUTING_V4)
.withParameters(ImmutableList.of(portNumParam,
srcMacParam,
dstMacParam,
@@ -287,17 +286,17 @@
if (modVlanIdInst != null) {
VlanId vlanId = modVlanIdInst.vlanId();
PiActionParam vlanParam =
- new PiActionParam(FabricConstants.ACT_PRM_NEW_VLAN_ID_ID,
+ new PiActionParam(FabricConstants.NEW_VLAN_ID,
ImmutableByteSequence.copyFrom(vlanId.toShort()));
// L3 routing and set VLAN
return PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_NEXT_L3_ROUTING_VLAN_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_NEXT_L3_ROUTING_VLAN)
.withParameters(ImmutableList.of(srcMacParam, dstMacParam, portNumParam, vlanParam))
.build();
} else {
// L3 routing
return PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_NEXT_L3_ROUTING_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_NEXT_L3_ROUTING)
.withParameters(ImmutableList.of(portNumParam,
srcMacParam,
dstMacParam))
diff --git a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/FabricFilteringPipeliner.java b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/FabricFilteringPipeliner.java
index d46d354..a8515e5 100644
--- a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/FabricFilteringPipeliner.java
+++ b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/FabricFilteringPipeliner.java
@@ -58,10 +58,10 @@
private static final byte FWD_IPV6_UNICAST = 4;
private static final byte FWD_IPV6_MULTICAST = 5;
private static final PiCriterion VLAN_VALID = PiCriterion.builder()
- .matchExact(FabricConstants.HF_VLAN_TAG_IS_VALID_ID, new byte[]{1})
+ .matchExact(FabricConstants.HDR_VLAN_TAG_IS_VALID, new byte[]{1})
.build();
private static final PiCriterion VLAN_INVALID = PiCriterion.builder()
- .matchExact(FabricConstants.HF_VLAN_TAG_IS_VALID_ID, new byte[]{0})
+ .matchExact(FabricConstants.HDR_VLAN_TAG_IS_VALID, new byte[]{0})
.build();
protected DeviceId deviceId;
@@ -147,7 +147,7 @@
.withSelector(selector.build())
.withTreatment(treatment)
.withPriority(filterObjective.priority())
- .forTable(FabricConstants.TBL_INGRESS_PORT_VLAN_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN)
.forDevice(deviceId)
.makePermanent()
.build();
@@ -225,15 +225,15 @@
.withPriority(filterObjective.priority())
.forDevice(deviceId)
.makePermanent()
- .forTable(FabricConstants.TBL_FWD_CLASSIFIER_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER)
.build();
}
private TrafficTreatment createFwdClassifierTreatment(byte fwdType) {
- PiActionParam param = new PiActionParam(FabricConstants.ACT_PRM_FWD_TYPE_ID,
+ PiActionParam param = new PiActionParam(FabricConstants.FWD_TYPE,
ImmutableByteSequence.copyFrom(fwdType));
PiAction action = PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_FILTERING_SET_FORWARDING_TYPE_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_FILTERING_SET_FORWARDING_TYPE)
.withParameter(param)
.build();
return DefaultTrafficTreatment.builder()
diff --git a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/FabricForwardingPipeliner.java b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/FabricForwardingPipeliner.java
index 6f87e79..785870e 100644
--- a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/FabricForwardingPipeliner.java
+++ b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/FabricForwardingPipeliner.java
@@ -84,7 +84,7 @@
FlowRule flowRule = DefaultFlowRule.builder()
.withSelector(fwd.selector())
.withTreatment(fwd.treatment())
- .forTable(FabricConstants.TBL_ACL_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_FORWARDING_ACL)
.withPriority(fwd.priority())
.forDevice(deviceId)
.makePermanent()
@@ -188,7 +188,7 @@
.withPriority(fwd.priority())
.makePermanent()
.forDevice(deviceId)
- .forTable(FabricConstants.TBL_BRIDGING_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_FORWARDING_BRIDGING)
.build();
resultBuilder.addFlowRule(flowRule);
@@ -215,7 +215,7 @@
.withPriority(fwd.priority())
.makePermanent()
.forDevice(deviceId)
- .forTable(FabricConstants.TBL_BRIDGING_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_FORWARDING_BRIDGING)
.build();
resultBuilder.addFlowRule(flowRule);
@@ -238,7 +238,7 @@
.withPriority(fwd.priority())
.makePermanent()
.forDevice(deviceId)
- .forTable(FabricConstants.TBL_UNICAST_V4_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_FORWARDING_UNICAST_V4)
.build();
resultBuilder.addFlowRule(flowRule);
@@ -251,10 +251,10 @@
treatment = fwd.treatment();
if (fwd.nextId() != null) {
- PiActionParam nextIdParam = new PiActionParam(FabricConstants.ACT_PRM_NEXT_ID_ID,
+ PiActionParam nextIdParam = new PiActionParam(FabricConstants.NEXT_ID,
ImmutableByteSequence.copyFrom(fwd.nextId().byteValue()));
PiAction nextIdAction = PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_FORWARDING_POP_MPLS_AND_NEXT_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_FORWARDING_POP_MPLS_AND_NEXT)
.withParameter(nextIdParam)
.build();
treatment = DefaultTrafficTreatment.builder()
@@ -273,7 +273,7 @@
.withPriority(fwd.priority())
.makePermanent()
.forDevice(deviceId)
- .forTable(FabricConstants.TBL_MPLS_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_FORWARDING_MPLS)
.build();
resultBuilder.addFlowRule(flowRule);
@@ -287,10 +287,10 @@
* @return treatment with set_next_id action; empty treatment if next id is null
*/
private static TrafficTreatment buildSetNextIdTreatment(Integer nextId) {
- PiActionParam nextIdParam = new PiActionParam(FabricConstants.ACT_PRM_NEXT_ID_ID,
+ PiActionParam nextIdParam = new PiActionParam(FabricConstants.NEXT_ID,
ImmutableByteSequence.copyFrom(nextId.byteValue()));
PiAction nextIdAction = PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_FORWARDING_SET_NEXT_ID_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_FORWARDING_SET_NEXT_ID)
.withParameter(nextIdParam)
.build();
diff --git a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/FabricNextPipeliner.java b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/FabricNextPipeliner.java
index 12602b4..3b66b1b 100644
--- a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/FabricNextPipeliner.java
+++ b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/FabricNextPipeliner.java
@@ -42,18 +42,12 @@
import org.onosproject.net.group.GroupDescription;
import org.onosproject.net.pi.runtime.PiActionGroupId;
import org.onosproject.net.pi.runtime.PiGroupKey;
+import org.onosproject.pipelines.fabric.FabricConstants;
import org.slf4j.Logger;
import java.util.List;
import java.util.stream.Collectors;
-import static org.onosproject.pipelines.fabric.FabricConstants.ACT_PRF_FABRICINGRESS_NEXT_ECMP_SELECTOR_ID;
-import static org.onosproject.pipelines.fabric.FabricConstants.HF_FABRIC_METADATA_NEXT_ID_ID;
-import static org.onosproject.pipelines.fabric.FabricConstants.HF_STANDARD_METADATA_EGRESS_PORT_ID;
-import static org.onosproject.pipelines.fabric.FabricConstants.TBL_EGRESS_VLAN_ID;
-import static org.onosproject.pipelines.fabric.FabricConstants.TBL_HASHED_ID;
-import static org.onosproject.pipelines.fabric.FabricConstants.TBL_SIMPLE_ID;
-import static org.onosproject.pipelines.fabric.FabricConstants.TBL_VLAN_META_ID;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -116,7 +110,7 @@
resultBuilder.addFlowRule(DefaultFlowRule.builder()
.withSelector(selector)
.withTreatment(treatment)
- .forTable(TBL_VLAN_META_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_NEXT_VLAN_META)
.makePermanent()
.withPriority(next.priority())
.forDevice(deviceId)
@@ -146,7 +140,7 @@
resultBuilder.addFlowRule(DefaultFlowRule.builder()
.withSelector(selector)
.withTreatment(treatment)
- .forTable(TBL_SIMPLE_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_NEXT_SIMPLE)
.makePermanent()
.withPriority(next.priority())
.forDevice(deviceId)
@@ -184,7 +178,7 @@
VlanId vlanId = vlanIdCriterion.vlanId();
PiCriterion egressVlanTableMatch = PiCriterion.builder()
- .matchExact(HF_STANDARD_METADATA_EGRESS_PORT_ID,
+ .matchExact(FabricConstants.STANDARD_METADATA_EGRESS_PORT,
(short) port.toLong())
.build();
// Add VLAN pop rule to egress pipeline table
@@ -198,7 +192,7 @@
resultBuilder.addFlowRule(DefaultFlowRule.builder()
.withSelector(selector)
.withTreatment(treatment)
- .forTable(TBL_EGRESS_VLAN_ID)
+ .forTable(FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN)
.makePermanent()
.withPriority(next.priority())
.forDevice(deviceId)
@@ -256,8 +250,8 @@
}
GroupBuckets buckets = new GroupBuckets(bucketList);
- PiGroupKey groupKey = new PiGroupKey(TBL_HASHED_ID,
- ACT_PRF_FABRICINGRESS_NEXT_ECMP_SELECTOR_ID,
+ PiGroupKey groupKey = new PiGroupKey(FabricConstants.FABRIC_INGRESS_NEXT_HASHED,
+ FabricConstants.FABRIC_INGRESS_NEXT_ECMP_SELECTOR,
groupId);
resultBuilder.addGroup(new DefaultGroupDescription(deviceId,
@@ -282,7 +276,7 @@
resultBuilder.addFlowRule(DefaultFlowRule.builder()
.withSelector(selector)
.withTreatment(treatment)
- .forTable(TBL_HASHED_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_NEXT_HASHED)
.makePermanent()
.withPriority(next.priority())
.forDevice(deviceId)
@@ -292,7 +286,7 @@
private TrafficSelector buildNextIdSelector(int nextId) {
PiCriterion nextIdCriterion = PiCriterion.builder()
- .matchExact(HF_FABRIC_METADATA_NEXT_ID_ID, nextId)
+ .matchExact(FabricConstants.FABRIC_METADATA_NEXT_ID, nextId)
.build();
return DefaultTrafficSelector.builder()
.matchPi(nextIdCriterion)
diff --git a/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/FabricInterpreterTest.java b/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/FabricInterpreterTest.java
index dc20728..b56d904 100644
--- a/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/FabricInterpreterTest.java
+++ b/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/FabricInterpreterTest.java
@@ -61,11 +61,11 @@
.setVlanId(VLAN_100)
.build();
PiAction mappedAction = interpreter.mapTreatment(treatment,
- FabricConstants.TBL_INGRESS_PORT_VLAN_ID);
- PiActionParam param = new PiActionParam(FabricConstants.ACT_PRM_NEW_VLAN_ID_ID,
+ FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN);
+ PiActionParam param = new PiActionParam(FabricConstants.NEW_VLAN_ID,
ImmutableByteSequence.copyFrom(VLAN_100.toShort()));
PiAction expectedAction = PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_FILTERING_PUSH_INTERNAL_VLAN_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_FILTERING_PUSH_INTERNAL_VLAN)
.withParameter(param)
.build();
@@ -81,11 +81,11 @@
.setVlanId(VLAN_100)
.build();
PiAction mappedAction = interpreter.mapTreatment(treatment,
- FabricConstants.TBL_INGRESS_PORT_VLAN_ID);
- PiActionParam param = new PiActionParam(FabricConstants.ACT_PRM_NEW_VLAN_ID_ID,
+ FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN);
+ PiActionParam param = new PiActionParam(FabricConstants.NEW_VLAN_ID,
ImmutableByteSequence.copyFrom(VLAN_100.toShort()));
PiAction expectedAction = PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_FILTERING_SET_VLAN_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_FILTERING_SET_VLAN)
.withParameter(param)
.build();
@@ -99,9 +99,9 @@
public void testFilteringTreatment3() throws Exception {
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
PiAction mappedAction = interpreter.mapTreatment(treatment,
- FabricConstants.TBL_INGRESS_PORT_VLAN_ID);
+ FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN);
PiAction expectedAction = PiAction.builder()
- .withId(FabricConstants.ACT_NOP_ID)
+ .withId(FabricConstants.NOP)
.build();
assertEquals(expectedAction, mappedAction);
@@ -118,9 +118,9 @@
.punt()
.build();
PiAction mappedAction = interpreter.mapTreatment(treatment,
- FabricConstants.TBL_ACL_ID);
+ FabricConstants.FABRIC_INGRESS_FORWARDING_ACL);
PiAction expectedAction = PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_FORWARDING_DUPLICATE_TO_CONTROLLER_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_FORWARDING_DUPLICATE_TO_CONTROLLER)
.build();
assertEquals(expectedAction, mappedAction);
@@ -133,7 +133,7 @@
public void testEmptyForwardingTreatment() throws Exception {
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
PiAction mappedAction = interpreter.mapTreatment(treatment,
- FabricConstants.TBL_UNICAST_V4_ID);
+ FabricConstants.FABRIC_INGRESS_FORWARDING_UNICAST_V4);
assertNull(mappedAction);
}
@@ -148,12 +148,12 @@
.setOutput(PORT_1)
.build();
PiAction mappedAction = interpreter.mapTreatment(treatment,
- FabricConstants.TBL_SIMPLE_ID);
+ FabricConstants.FABRIC_INGRESS_NEXT_SIMPLE);
short portNumVal = (short) PORT_1.toLong();
- PiActionParam param = new PiActionParam(FabricConstants.ACT_PRM_PORT_NUM_ID,
+ PiActionParam param = new PiActionParam(FabricConstants.PORT_NUM,
ImmutableByteSequence.copyFrom(portNumVal));
PiAction expectedAction = PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_NEXT_OUTPUT_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_NEXT_OUTPUT)
.withParameter(param)
.build();
@@ -171,16 +171,16 @@
.setOutput(PORT_1)
.build();
PiAction mappedAction = interpreter.mapTreatment(treatment,
- FabricConstants.TBL_HASHED_ID);
+ FabricConstants.FABRIC_INGRESS_NEXT_HASHED);
short portNumVal = (short) PORT_1.toLong();
- PiActionParam ethSrcParam = new PiActionParam(FabricConstants.ACT_PRM_SMAC_ID,
+ PiActionParam ethSrcParam = new PiActionParam(FabricConstants.SMAC,
ImmutableByteSequence.copyFrom(SRC_MAC.toBytes()));
- PiActionParam ethDstParam = new PiActionParam(FabricConstants.ACT_PRM_DMAC_ID,
+ PiActionParam ethDstParam = new PiActionParam(FabricConstants.DMAC,
ImmutableByteSequence.copyFrom(DST_MAC.toBytes()));
- PiActionParam portParam = new PiActionParam(FabricConstants.ACT_PRM_PORT_NUM_ID,
+ PiActionParam portParam = new PiActionParam(FabricConstants.PORT_NUM,
ImmutableByteSequence.copyFrom(portNumVal));
PiAction expectedAction = PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_NEXT_L3_ROUTING_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_NEXT_L3_ROUTING)
.withParameters(ImmutableList.of(ethSrcParam, ethDstParam, portParam))
.build();
@@ -197,16 +197,16 @@
.setOutput(PORT_1)
.build();
PiAction mappedAction = interpreter.mapTreatment(treatment,
- FabricConstants.TBL_SIMPLE_ID);
+ FabricConstants.FABRIC_INGRESS_NEXT_SIMPLE);
short portNumVal = (short) PORT_1.toLong();
- PiActionParam portParam = new PiActionParam(FabricConstants.ACT_PRM_PORT_NUM_ID,
+ PiActionParam portParam = new PiActionParam(FabricConstants.PORT_NUM,
ImmutableByteSequence.copyFrom(portNumVal));
short vlanVal = VLAN_100.toShort();
- PiActionParam vlanParam = new PiActionParam(FabricConstants.ACT_PRM_NEW_VLAN_ID_ID,
+ PiActionParam vlanParam = new PiActionParam(FabricConstants.NEW_VLAN_ID,
ImmutableByteSequence.copyFrom(vlanVal));
PiAction expectedAction = PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_NEXT_SET_VLAN_OUTPUT_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_NEXT_SET_VLAN_OUTPUT)
.withParameters(ImmutableList.of(vlanParam, portParam))
.build();
@@ -224,19 +224,19 @@
.setOutput(PORT_1)
.build();
PiAction mappedAction = interpreter.mapTreatment(treatment,
- FabricConstants.TBL_HASHED_ID);
+ FabricConstants.FABRIC_INGRESS_NEXT_HASHED);
short portNumVal = (short) PORT_1.toLong();
- PiActionParam ethSrcParam = new PiActionParam(FabricConstants.ACT_PRM_SMAC_ID,
+ PiActionParam ethSrcParam = new PiActionParam(FabricConstants.SMAC,
ImmutableByteSequence.copyFrom(SRC_MAC.toBytes()));
- PiActionParam ethDstParam = new PiActionParam(FabricConstants.ACT_PRM_DMAC_ID,
+ PiActionParam ethDstParam = new PiActionParam(FabricConstants.DMAC,
ImmutableByteSequence.copyFrom(DST_MAC.toBytes()));
- PiActionParam portParam = new PiActionParam(FabricConstants.ACT_PRM_PORT_NUM_ID,
+ PiActionParam portParam = new PiActionParam(FabricConstants.PORT_NUM,
ImmutableByteSequence.copyFrom(portNumVal));
ImmutableByteSequence mplsVal =
ImmutableByteSequence.copyFrom(MPLS_10.toInt()).fit(20);
- PiActionParam mplsParam = new PiActionParam(FabricConstants.ACT_PRM_LABEL_ID, mplsVal);
+ PiActionParam mplsParam = new PiActionParam(FabricConstants.LABEL, mplsVal);
PiAction expectedAction = PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_NEXT_MPLS_ROUTING_V4_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_NEXT_MPLS_ROUTING_V4)
.withParameters(ImmutableList.of(ethSrcParam, ethDstParam, portParam, mplsParam))
.build();
assertEquals(expectedAction, mappedAction);
diff --git a/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricFilteringPipelinerTest.java b/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricFilteringPipelinerTest.java
index b62c3c2..5769e8f 100644
--- a/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricFilteringPipelinerTest.java
+++ b/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricFilteringPipelinerTest.java
@@ -65,10 +65,11 @@
// in port vlan flow rule
FlowRule actualFlowRule = flowRulesInstalled.get(0);
- FlowRule flowRuleExpected = buildExpectedVlanInPortRule(PORT_1,
- VlanId.NONE,
- VLAN_100,
- FabricConstants.TBL_INGRESS_PORT_VLAN_ID);
+ FlowRule flowRuleExpected =
+ buildExpectedVlanInPortRule(PORT_1,
+ VlanId.NONE,
+ VLAN_100,
+ FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN);
assertTrue(flowRuleExpected.exactMatch(actualFlowRule));
// forwarding classifier ipv4
@@ -125,10 +126,11 @@
// in port vlan flow rule
FlowRule actualFlowRule = flowRulesInstalled.get(0);
- FlowRule flowRuleExpected = buildExpectedVlanInPortRule(PORT_1,
- VlanId.NONE,
- VLAN_100,
- FabricConstants.TBL_INGRESS_PORT_VLAN_ID);
+ FlowRule flowRuleExpected =
+ buildExpectedVlanInPortRule(PORT_1,
+ VlanId.NONE,
+ VLAN_100,
+ FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN);
assertTrue(flowRuleExpected.exactMatch(actualFlowRule));
// forwarding classifier
@@ -169,10 +171,11 @@
// in port vlan flow rule
FlowRule actualFlowRule = flowRulesInstalled.get(0);
- FlowRule flowRuleExpected = buildExpectedVlanInPortRule(PORT_1,
- VlanId.NONE,
- VLAN_100,
- FabricConstants.TBL_INGRESS_PORT_VLAN_ID);
+ FlowRule flowRuleExpected =
+ buildExpectedVlanInPortRule(PORT_1,
+ VlanId.NONE,
+ VLAN_100,
+ FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN);
assertTrue(flowRuleExpected.exactMatch(actualFlowRule));
// forwarding classifier
@@ -200,10 +203,11 @@
// in port vlan flow rule
FlowRule actualFlowRule = flowRulesInstalled.get(0);
- FlowRule flowRuleExpected = buildExpectedVlanInPortRule(PORT_1,
- VlanId.NONE,
- VLAN_100,
- FabricConstants.TBL_INGRESS_PORT_VLAN_ID);
+ FlowRule flowRuleExpected =
+ buildExpectedVlanInPortRule(PORT_1,
+ VlanId.NONE,
+ VLAN_100,
+ FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN);
assertTrue(flowRuleExpected.exactMatch(actualFlowRule));
// No rules in forwarding classifier, will do default action: set fwd type to bridging
@@ -332,10 +336,10 @@
.matchInPort(inPort)
.matchEthType(ethType)
.build();
- PiActionParam classParam = new PiActionParam(FabricConstants.ACT_PRM_FWD_TYPE_ID,
+ PiActionParam classParam = new PiActionParam(FabricConstants.FWD_TYPE,
ImmutableByteSequence.copyFrom(fwdClass));
PiAction fwdClassifierAction = PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_FILTERING_SET_FORWARDING_TYPE_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_FILTERING_SET_FORWARDING_TYPE)
.withParameter(classParam)
.build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
@@ -349,7 +353,7 @@
.fromApp(APP_ID)
.forDevice(DEVICE_ID)
.makePermanent()
- .forTable(FabricConstants.TBL_FWD_CLASSIFIER_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER)
.build();
}
}
diff --git a/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricForwardingPipelineTest.java b/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricForwardingPipelineTest.java
index c471ede..a4e2195 100644
--- a/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricForwardingPipelineTest.java
+++ b/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricForwardingPipelineTest.java
@@ -79,7 +79,7 @@
FlowRule actualFlowRule = flowRulesInstalled.get(0);
FlowRule expectedFlowRule = DefaultFlowRule.builder()
.forDevice(DEVICE_ID)
- .forTable(FabricConstants.TBL_ACL_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_FORWARDING_ACL)
.withPriority(PRIORITY)
.makePermanent()
.withSelector(selector)
@@ -125,7 +125,7 @@
FlowRule actualFlowRule = flowRulesInstalled.get(0);
FlowRule expectedFlowRule = DefaultFlowRule.builder()
.forDevice(DEVICE_ID)
- .forTable(FabricConstants.TBL_ACL_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_FORWARDING_ACL)
.withPriority(PRIORITY)
.makePermanent()
.withSelector(selector)
@@ -145,7 +145,8 @@
.matchVlanId(VLAN_100)
.matchEthDst(HOST_MAC)
.build();
- testSpecificForward(FabricConstants.TBL_BRIDGING_ID, selector, selector, NEXT_ID_1);
+ testSpecificForward(FabricConstants.FABRIC_INGRESS_FORWARDING_BRIDGING,
+ selector, selector, NEXT_ID_1);
}
@Test
@@ -153,7 +154,8 @@
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchVlanId(VLAN_100)
.build();
- testSpecificForward(FabricConstants.TBL_BRIDGING_ID, selector, selector, NEXT_ID_1);
+ testSpecificForward(FabricConstants.FABRIC_INGRESS_FORWARDING_BRIDGING,
+ selector, selector, NEXT_ID_1);
}
@Test
@@ -165,7 +167,8 @@
TrafficSelector expectedSelector = DefaultTrafficSelector.builder()
.matchIPDst(IPV4_UNICAST_ADDR)
.build();
- testSpecificForward(FabricConstants.TBL_UNICAST_V4_ID, expectedSelector, selector, NEXT_ID_1);
+ testSpecificForward(FabricConstants.FABRIC_INGRESS_FORWARDING_UNICAST_V4,
+ expectedSelector, selector, NEXT_ID_1);
}
@Test
@@ -177,7 +180,8 @@
TrafficSelector expectedSelector = DefaultTrafficSelector.builder()
.matchIPDst(IPV4_UNICAST_ADDR)
.build();
- testSpecificForward(FabricConstants.TBL_UNICAST_V4_ID, expectedSelector, selector, null);
+ testSpecificForward(FabricConstants.FABRIC_INGRESS_FORWARDING_UNICAST_V4,
+ expectedSelector, selector, null);
}
@Test
@@ -191,7 +195,8 @@
TrafficSelector expectedSelector = DefaultTrafficSelector.builder()
.matchIPDst(IPV4_MCAST_ADDR)
.build();
- testSpecificForward(FabricConstants.TBL_MULTICAST_V4_ID, expectedSelector, selector, NEXT_ID_1);
+ testSpecificForward(FabricConstants.FABRIC_INGRESS_FORWARDING_UNICAST_V4,
+ expectedSelector, selector, NEXT_ID_1);
}
@Test
@@ -204,7 +209,9 @@
TrafficSelector expectedSelector = DefaultTrafficSelector.builder()
.matchIPDst(IPV6_UNICAST_ADDR)
.build();
- testSpecificForward(FabricConstants.TBL_UNICAST_V6_ID, expectedSelector, selector, NEXT_ID_1);
+ testSpecificForward(FabricConstants.FABRIC_INGRESS_FORWARDING_UNICAST_V6,
+ expectedSelector, selector, NEXT_ID_1);
+
}
@Test
@@ -218,7 +225,8 @@
TrafficSelector expectedSelector = DefaultTrafficSelector.builder()
.matchIPDst(IPV6_MCAST_ADDR)
.build();
- testSpecificForward(FabricConstants.TBL_MULTICAST_V6_ID, expectedSelector, selector, NEXT_ID_1);
+ testSpecificForward(FabricConstants.FABRIC_INGRESS_FORWARDING_UNICAST_V6,
+ expectedSelector, selector, NEXT_ID_1);
}
@Test
@@ -232,16 +240,17 @@
.matchMplsLabel(MPLS_10)
.build();
- PiActionParam nextIdParam = new PiActionParam(FabricConstants.ACT_PRM_NEXT_ID_ID,
+ PiActionParam nextIdParam = new PiActionParam(FabricConstants.NEXT_ID,
ImmutableByteSequence.copyFrom(NEXT_ID_1.byteValue()));
PiAction setNextIdAction = PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_FORWARDING_POP_MPLS_AND_NEXT_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_FORWARDING_POP_MPLS_AND_NEXT)
.withParameter(nextIdParam)
.build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.piTableAction(setNextIdAction)
.build();
- testSpecificForward(FabricConstants.TBL_MPLS_ID, expectedSelector, selector, NEXT_ID_1, treatment);
+ testSpecificForward(FabricConstants.FABRIC_INGRESS_FORWARDING_MPLS,
+ expectedSelector, selector, NEXT_ID_1, treatment);
}
private void testSpecificForward(PiTableId expectedTableId, TrafficSelector expectedSelector,
@@ -251,10 +260,10 @@
// Ref: RoutingRulePopulator.java->revokeIpRuleForRouter
setNextIdTreatment = DefaultTrafficTreatment.builder().build();
} else {
- PiActionParam nextIdParam = new PiActionParam(FabricConstants.ACT_PRM_NEXT_ID_ID,
+ PiActionParam nextIdParam = new PiActionParam(FabricConstants.NEXT_ID,
ImmutableByteSequence.copyFrom(nextId.byteValue()));
PiAction setNextIdAction = PiAction.builder()
- .withId(FabricConstants.ACT_FABRICINGRESS_FORWARDING_SET_NEXT_ID_ID)
+ .withId(FabricConstants.FABRIC_INGRESS_FORWARDING_SET_NEXT_ID)
.withParameter(nextIdParam)
.build();
setNextIdTreatment = DefaultTrafficTreatment.builder()
diff --git a/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricNextPipelinerTest.java b/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricNextPipelinerTest.java
index a797a83..e2a6af8 100644
--- a/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricNextPipelinerTest.java
+++ b/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricNextPipelinerTest.java
@@ -42,9 +42,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.onosproject.pipelines.fabric.FabricConstants.ACT_PRF_FABRICINGRESS_NEXT_ECMP_SELECTOR_ID;
-import static org.onosproject.pipelines.fabric.FabricConstants.TBL_HASHED_ID;
-import static org.onosproject.pipelines.fabric.FabricConstants.TBL_VLAN_META_ID;
/**
* Test cases for fabric.p4 pipeline next control block.
@@ -54,7 +51,7 @@
public FabricNextPipelinerTest() {
PiCriterion nextIdCriterion = PiCriterion.builder()
- .matchExact(FabricConstants.HF_FABRIC_METADATA_NEXT_ID_ID, NEXT_ID_1)
+ .matchExact(FabricConstants.FABRIC_METADATA_NEXT_ID, NEXT_ID_1)
.build();
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchPi(nextIdCriterion)
@@ -66,7 +63,7 @@
vlanMetaFlowRule = DefaultFlowRule.builder()
.withSelector(selector)
.withTreatment(treatment)
- .forTable(TBL_VLAN_META_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_NEXT_VLAN_META)
.makePermanent()
// FIXME: currently next objective doesn't support priority, ignore this
.withPriority(0)
@@ -145,7 +142,7 @@
// Simple table
PiCriterion nextIdCriterion = PiCriterion.builder()
- .matchExact(FabricConstants.HF_FABRIC_METADATA_NEXT_ID_ID, NEXT_ID_1)
+ .matchExact(FabricConstants.FABRIC_METADATA_NEXT_ID, NEXT_ID_1)
.build();
TrafficSelector nextIdSelector = DefaultTrafficSelector.builder()
.matchPi(nextIdCriterion)
@@ -162,7 +159,7 @@
.makePermanent()
// FIXME: currently next objective doesn't support priority, ignore this
.withPriority(0)
- .forTable(FabricConstants.TBL_SIMPLE_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_NEXT_SIMPLE)
.withSelector(nextIdSelector)
.withTreatment(treatment)
.build();
@@ -206,7 +203,7 @@
// Hashed table
PiCriterion nextIdCriterion = PiCriterion.builder()
- .matchExact(FabricConstants.HF_FABRIC_METADATA_NEXT_ID_ID, NEXT_ID_1)
+ .matchExact(FabricConstants.FABRIC_METADATA_NEXT_ID, NEXT_ID_1)
.build();
TrafficSelector nextIdSelector = DefaultTrafficSelector.builder()
.matchPi(nextIdCriterion)
@@ -227,7 +224,7 @@
.makePermanent()
// FIXME: currently next objective doesn't support priority, ignore this
.withPriority(0)
- .forTable(TBL_HASHED_ID)
+ .forTable(FabricConstants.FABRIC_INGRESS_NEXT_HASHED)
.withSelector(nextIdSelector)
.withTreatment(treatment)
.build();
@@ -241,7 +238,9 @@
.map(DefaultGroupBucket::createSelectGroupBucket)
.collect(Collectors.toList());
GroupBuckets groupBuckets = new GroupBuckets(buckets);
- PiGroupKey groupKey = new PiGroupKey(TBL_HASHED_ID, ACT_PRF_FABRICINGRESS_NEXT_ECMP_SELECTOR_ID, NEXT_ID_1);
+ PiGroupKey groupKey = new PiGroupKey(FabricConstants.FABRIC_INGRESS_NEXT_HASHED,
+ FabricConstants.FABRIC_INGRESS_NEXT_ECMP_SELECTOR,
+ NEXT_ID_1);
GroupDescription expectedGroup = new DefaultGroupDescription(
DEVICE_ID,
GroupDescription.Type.SELECT,
diff --git a/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricPipelinerTest.java b/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricPipelinerTest.java
index c605e99..b907bdf 100644
--- a/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricPipelinerTest.java
+++ b/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricPipelinerTest.java
@@ -68,17 +68,11 @@
static final byte FWD_IPV6_UNICAST = 4;
static final byte FWD_IPV6_MULTICAST = 5;
- // Next types
- static final byte NEXT_TYPE_SIMPLE = 0;
- static final byte NEXT_TYPE_HASHED = 1;
- static final byte NEXT_TYPE_BROADCAST = 2;
- static final byte NEXT_TYPE_PUNT = 3;
-
static final PiCriterion VLAN_VALID = PiCriterion.builder()
- .matchExact(FabricConstants.HF_VLAN_TAG_IS_VALID_ID, new byte[]{1})
+ .matchExact(FabricConstants.HDR_VLAN_TAG_IS_VALID, new byte[]{1})
.build();
static final PiCriterion VLAN_INVALID = PiCriterion.builder()
- .matchExact(FabricConstants.HF_VLAN_TAG_IS_VALID_ID, new byte[]{0})
+ .matchExact(FabricConstants.HDR_VLAN_TAG_IS_VALID, new byte[]{0})
.build();
FabricPipeliner pipeliner;
diff --git a/tools/dev/bin/onos-gen-p4-constants b/tools/dev/bin/onos-gen-p4-constants
new file mode 100755
index 0000000..8e68acc
--- /dev/null
+++ b/tools/dev/bin/onos-gen-p4-constants
@@ -0,0 +1,219 @@
+#!/usr/bin/env python2.7
+# -*- utf-8 -*-
+import argparse
+import re
+import google.protobuf.text_format as tf
+from p4.config import p4info_pb2
+
+
+copyright = '''/*
+ * 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.
+ */
+'''
+
+imports = '''
+import org.onosproject.net.pi.model.PiActionId;
+import org.onosproject.net.pi.model.PiActionParamId;
+import org.onosproject.net.pi.model.PiActionProfileId;
+import org.onosproject.net.pi.model.PiControlMetadataId;
+import org.onosproject.net.pi.model.PiCounterId;
+import org.onosproject.net.pi.model.PiMatchFieldId;
+import org.onosproject.net.pi.model.PiTableId;'''
+
+PKG_FMT = 'package org.onosproject.pipelines.%s;'
+
+CLASS_OPEN = 'public final class %s {'
+CLASS_CLOSE = '}'
+
+DEFAULT_CONSTRUCTOR = '''
+ // hide default constructor
+ private %s() {
+ }
+'''
+
+CONST_FMT = ' public static final %s %s = %s;'
+SHORT_CONST_FMT =''' public static final %s %s =
+ %s;'''
+JAVA_STR = 'String'
+EMPTY_STR = ''
+JAVA_DOC_FMT = '''/**
+ * Constants for %s pipeline.
+ */'''
+
+
+PI_HF_FIELD_ID = 'PiMatchFieldId'
+PI_HF_FIELD_ID_CST = 'PiMatchFieldId.of("%s")'
+
+PI_TBL_ID = 'PiTableId'
+PI_TBL_ID_CST = 'PiTableId.of("%s")'
+
+PI_CTR_ID = 'PiCounterId'
+PI_CTR_ID_CST = 'PiCounterId.of("%s")'
+
+PI_ACT_ID = 'PiActionId'
+PI_ACT_ID_CST = 'PiActionId.of("%s")'
+
+PI_ACT_PRM_ID = 'PiActionParamId'
+PI_ACT_PRM_ID_CST = 'PiActionParamId.of("%s")'
+
+PI_ACT_PROF_ID = 'PiActionProfileId'
+PI_ACT_PROF_ID_CST = 'PiActionProfileId.of("%s")'
+
+PI_PKT_META_ID = 'PiControlMetadataId'
+PI_PKT_META_ID_CST = 'PiControlMetadataId.of("%s")'
+
+class ConstantClassGenerator(object):
+ headers = set()
+ header_fields = set()
+ tables = set()
+ counters = set()
+ direct_counters = set()
+ actions = set()
+ action_params = set()
+ action_profiles = set()
+ packet_metadata = set()
+
+ # https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case
+ def convert_camel_to_all_caps(self, name):
+ s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
+ s1 = re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).upper()
+ return s1.replace('.', '_')
+
+ def __init__(self, base_name):
+
+ self.class_name = base_name.title() + 'Constants'
+ self.package_name = PKG_FMT % (base_name, )
+ self.java_doc = JAVA_DOC_FMT % (base_name, )
+
+ def parse(self, p4info):
+ for tbl in p4info.tables:
+ for mf in tbl.match_fields:
+ self.header_fields.add(mf.name)
+
+ self.tables.add(tbl.preamble.name)
+
+ for ctr in p4info.counters:
+ self.counters.add(ctr.preamble.name)
+
+ for dir_ctr in p4info.direct_counters:
+ self.direct_counters.add(dir_ctr.preamble.name)
+
+ for act in p4info.actions:
+ self.actions.add(act.preamble.name)
+
+ for param in act.params:
+ self.action_params.add(param.name)
+
+ for act_prof in p4info.action_profiles:
+ self.action_profiles.add(act_prof.preamble.name)
+
+ for cpm in p4info.controller_packet_metadata:
+ for mta in cpm.metadata:
+ self.packet_metadata.add(mta.name)
+
+ def const_line(self, name, type, constructor):
+ var_name = self.convert_camel_to_all_caps(name)
+ val = constructor % (name, )
+
+ line = CONST_FMT % (type, var_name, val)
+ if len(line) > 80:
+ line = SHORT_CONST_FMT % (type, var_name, val)
+ return line
+
+ def generate_java(self):
+ lines = list()
+ lines.append(copyright)
+ lines.append(self.package_name)
+ lines.append(imports)
+ lines.append(self.java_doc)
+ # generate the class
+ lines.append(CLASS_OPEN % (self.class_name, ))
+ lines.append(DEFAULT_CONSTRUCTOR % (self.class_name, ))
+
+ if len(self.header_fields) is not 0:
+ lines.append(' // Header field IDs')
+ for hf in self.header_fields:
+ lines.append(self.const_line(hf, PI_HF_FIELD_ID, PI_HF_FIELD_ID_CST))
+
+ if len(self.tables) is not 0:
+ lines.append(' // Table IDs')
+ for tbl in self.tables:
+ lines.append(self.const_line(tbl, PI_TBL_ID, PI_TBL_ID_CST))
+
+ if len(self.counters) is not 0:
+ lines.append(' // Indirect Counter IDs')
+ for ctr in self.counters:
+ lines.append(self.const_line(ctr, PI_CTR_ID, PI_CTR_ID_CST))
+
+ if len(self.direct_counters) is not 0:
+ lines.append(' // Direct Counter IDs')
+ for dctr in self.direct_counters:
+ lines.append(self.const_line(dctr, PI_CTR_ID, PI_CTR_ID_CST))
+
+ if len(self.actions) is not 0:
+ lines.append(' // Action IDs')
+ for act in self.actions:
+ lines.append(self.const_line(act, PI_ACT_ID, PI_ACT_ID_CST))
+
+ if len(self.action_params) is not 0:
+ lines.append(' // Action Param IDs')
+ for act_prm in self.action_params:
+ lines.append(self.const_line(act_prm, PI_ACT_PRM_ID, PI_ACT_PRM_ID_CST))
+
+ if len(self.action_profiles) is not 0:
+ lines.append(' // Action Profile IDs')
+ for act_prof in self.action_profiles:
+ lines.append(self.const_line(act_prof, PI_ACT_PROF_ID, PI_ACT_PROF_ID_CST))
+
+ if len(self.packet_metadata) is not 0:
+ lines.append(' // Packet Metadata IDs')
+ for pmeta in self.packet_metadata:
+ lines.append(self.const_line(pmeta, PI_PKT_META_ID, PI_PKT_META_ID_CST))
+ lines.append(CLASS_CLOSE)
+ # end of class
+
+ return '\n'.join(lines)
+
+
+def main():
+ parser = argparse.ArgumentParser(prog='onos-gen-p4-constants',
+ description='ONOS P4Info to Java constant generator.')
+ parser.add_argument('name', help='Name of the constant, will be used as class name')
+ parser.add_argument('p4info', help='P4Info file')
+ parser.add_argument('-o', '--output', help='output path', default='-')
+ args = parser.parse_args()
+
+ base_name = args.name
+ file_name = args.p4info
+ p4info = p4info_pb2.P4Info()
+ with open(file_name, 'r') as intput_file:
+ s = intput_file.read()
+ tf.Merge(s, p4info)
+
+ gen = ConstantClassGenerator(base_name)
+ gen.parse(p4info)
+
+ java_code = gen.generate_java()
+
+ if args.output == '-':
+ # std output
+ print java_code
+ else:
+ with open(args.output, 'w') as output_file:
+ output_file.write(java_code)
+
+
+if __name__ == '__main__':
+ main()