[ONOS-7255] Remove next id mapping table from fabric.p4

Change-Id: Ibcdc49f7c802cb4a4175d51314713725d8b05a77
This commit is contained in:
Yi Tseng 2017-11-29 15:51:28 -08:00 committed by Carmelo Cascone
parent 6cbce02de2
commit f55eaa8112
10 changed files with 233 additions and 574 deletions

View File

@ -91,7 +91,6 @@ public final class FabricConstants {
public static final PiTableId TBL_HASHED_ID = PiTableId.of("next.hashed");
public static final PiTableId TBL_INGRESS_PORT_VLAN_ID = PiTableId.of("filtering.ingress_port_vlan");
public static final PiTableId TBL_FWD_CLASSIFIER_ID = PiTableId.of("filtering.fwd_classifier");
public static final PiTableId TBL_NEXT_ID_MAPPING_ID = PiTableId.of("next.next_id_mapping");
public static final PiTableId TBL_UNICAST_V6_ID = PiTableId.of("forwarding.unicast_v6");
public static final PiTableId TBL_SIMPLE_ID = PiTableId.of("next.simple");
public static final PiTableId TBL_BRIDGING_ID = PiTableId.of("forwarding.bridging");
@ -113,7 +112,6 @@ public final class FabricConstants {
public static final PiCounterId CNT_FWD_CLASSIFIER_COUNTER_ID = PiCounterId.of("filtering.fwd_classifier_counter");
public static final PiCounterId CNT_UNICAST_V6_COUNTER_ID = PiCounterId.of("forwarding.unicast_v6_counter");
public static final PiCounterId CNT_BRIDGING_COUNTER_ID = PiCounterId.of("forwarding.bridging_counter");
public static final PiCounterId CNT_NEXT_ID_MAPPING_COUNTER_ID = PiCounterId.of("next.next_id_mapping_counter");
public static final PiCounterId CNT_SIMPLE_COUNTER_ID = PiCounterId.of("next.simple_counter");
public static final PiCounterId CNT_HASHED_COUNTER_ID = PiCounterId.of("next.hashed_counter");
public static final PiCounterId CNT_BROADCAST_COUNTER_ID = PiCounterId.of("next.broadcast_counter");
@ -130,7 +128,6 @@ public final class FabricConstants {
public static final PiActionId ACT_MPLS_ROUTING_V6_ID = PiActionId.of("next.mpls_routing_v6");
public static final PiActionId ACT_SET_FORWARDING_TYPE_ID = PiActionId.of("filtering.set_forwarding_type");
public static final PiActionId ACT_POP_MPLS_AND_NEXT_ID = PiActionId.of("forwarding.pop_mpls_and_next");
public static final PiActionId ACT_SET_NEXT_TYPE_ID = PiActionId.of("next.set_next_type");
public static final PiActionId ACT_L3_ROUTING_ID = PiActionId.of("next.l3_routing");
public static final PiActionId ACT_OUTPUT_ID = PiActionId.of("next.output");
public static final PiActionId ACT_NOP_ID = PiActionId.of("nop");
@ -146,11 +143,10 @@ public final class FabricConstants {
public static final PiActionParamId ACT_PRM_GID_ID = PiActionParamId.of("gid");
public static final PiActionParamId ACT_PRM_NEW_VLAN_ID_ID = PiActionParamId.of("new_vlan_id");
public static final PiActionParamId ACT_PRM_FWD_TYPE_ID = PiActionParamId.of("fwd_type");
public static final PiActionParamId ACT_PRM_NEXT_TYPE_ID = PiActionParamId.of("next_type");
public static final PiActionParamId ACT_PRM_NEXT_ID_ID = PiActionParamId.of("next_id");
// Action Profile IDs
public static final PiActionProfileId ACT_PRF_ECMP_SELECTOR_ID = PiActionProfileId.of("next.ecmp_selector");
public static final PiActionProfileId ACT_PRF_NEXT_ECMP_SELECTOR_ID = PiActionProfileId.of("next.ecmp_selector");
// Packet Metadata IDs
public static final PiControlMetadataId CTRL_META_EGRESS_PORT_ID = PiControlMetadataId.of("egress_port");

View File

@ -75,10 +75,9 @@ public class FabricInterpreter extends AbstractHandlerBehaviour
.put(7, FabricConstants.TBL_BRIDGING_ID)
.put(8, FabricConstants.TBL_ACL_ID)
// Next
.put(9, FabricConstants.TBL_NEXT_ID_MAPPING_ID)
.put(10, FabricConstants.TBL_SIMPLE_ID)
.put(11, FabricConstants.TBL_HASHED_ID)
.put(12, FabricConstants.TBL_BROADCAST_ID)
.put(9, FabricConstants.TBL_SIMPLE_ID)
.put(10, FabricConstants.TBL_HASHED_ID)
.put(11, FabricConstants.TBL_BROADCAST_ID)
.build();
private static final Set<PiTableId> FILTERING_CTRL_TBLS = ImmutableSet.of(FabricConstants.TBL_INGRESS_PORT_VLAN_ID,
@ -90,8 +89,7 @@ public class FabricInterpreter extends AbstractHandlerBehaviour
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_NEXT_ID_MAPPING_ID,
FabricConstants.TBL_SIMPLE_ID,
private static final Set<PiTableId> NEXT_CTRL_TBLS = ImmutableSet.of(FabricConstants.TBL_SIMPLE_ID,
FabricConstants.TBL_HASHED_ID,
FabricConstants.TBL_BROADCAST_ID);
@ -104,7 +102,6 @@ public class FabricInterpreter extends AbstractHandlerBehaviour
.put(FabricConstants.TBL_BROADCAST_ID, FabricConstants.CNT_BROADCAST_COUNTER_ID)
.put(FabricConstants.TBL_HASHED_ID, FabricConstants.CNT_HASHED_COUNTER_ID)
.put(FabricConstants.TBL_INGRESS_PORT_VLAN_ID, FabricConstants.CNT_INGRESS_PORT_VLAN_COUNTER_ID)
.put(FabricConstants.TBL_NEXT_ID_MAPPING_ID, FabricConstants.CNT_NEXT_ID_MAPPING_COUNTER_ID)
.put(FabricConstants.TBL_UNICAST_V6_ID, FabricConstants.CNT_UNICAST_V6_COUNTER_ID)
.put(FabricConstants.TBL_SIMPLE_ID, FabricConstants.CNT_SIMPLE_COUNTER_ID)
.put(FabricConstants.TBL_BRIDGING_ID, FabricConstants.CNT_BRIDGING_COUNTER_ID)

View File

@ -16,7 +16,6 @@
package org.onosproject.pipelines.fabric.pipeliner;
import com.google.common.collect.ImmutableMap;
import org.onosproject.net.DeviceId;
import org.onosproject.net.flow.DefaultFlowRule;
import org.onosproject.net.flow.DefaultTrafficSelector;
@ -33,23 +32,16 @@ import org.onosproject.net.group.DefaultGroupDescription;
import org.onosproject.net.group.GroupBucket;
import org.onosproject.net.group.GroupBuckets;
import org.onosproject.net.group.GroupDescription;
import org.onosproject.net.pi.runtime.PiAction;
import org.onosproject.net.pi.runtime.PiActionGroupId;
import org.onosproject.net.pi.runtime.PiActionParam;
import org.onosproject.net.pi.runtime.PiGroupKey;
import org.slf4j.Logger;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static org.onlab.util.ImmutableByteSequence.copyFrom;
import static org.onosproject.pipelines.fabric.FabricConstants.ACT_PRF_ECMP_SELECTOR_ID;
import static org.onosproject.pipelines.fabric.FabricConstants.ACT_PRM_NEXT_TYPE_ID;
import static org.onosproject.pipelines.fabric.FabricConstants.ACT_SET_NEXT_TYPE_ID;
import static org.onosproject.pipelines.fabric.FabricConstants.ACT_PRF_NEXT_ECMP_SELECTOR_ID;
import static org.onosproject.pipelines.fabric.FabricConstants.HF_FABRIC_METADATA_NEXT_ID_ID;
import static org.onosproject.pipelines.fabric.FabricConstants.TBL_HASHED_ID;
import static org.onosproject.pipelines.fabric.FabricConstants.TBL_NEXT_ID_MAPPING_ID;
import static org.onosproject.pipelines.fabric.FabricConstants.TBL_SIMPLE_ID;
import static org.slf4j.LoggerFactory.getLogger;
@ -59,18 +51,6 @@ import static org.slf4j.LoggerFactory.getLogger;
public class FabricNextPipeliner {
private static final Logger log = getLogger(FabricNextPipeliner.class);
// Next types
private static final byte NXT_TYPE_SIMPLE = 0;
private static final byte NXT_TYPE_HASHED = 1;
private static final byte NXT_TYPE_BROADCAST = 2;
private static final byte NXT_TYPE_PUNT = 3;
private static final Map<NextObjective.Type, Byte> NEXT_TYPE_MAP =
ImmutableMap.<NextObjective.Type, Byte>builder()
.put(NextObjective.Type.SIMPLE, NXT_TYPE_SIMPLE)
.put(NextObjective.Type.HASHED, NXT_TYPE_HASHED)
.put(NextObjective.Type.BROADCAST, NXT_TYPE_BROADCAST)
.build();
protected DeviceId deviceId;
public FabricNextPipeliner(DeviceId deviceId) {
@ -79,7 +59,6 @@ public class FabricNextPipeliner {
public PipelinerTranslationResult next(NextObjective nextObjective) {
PipelinerTranslationResult.Builder resultBuilder = PipelinerTranslationResult.builder();
processNextIdMapping(nextObjective, resultBuilder);
switch (nextObjective.type()) {
case SIMPLE:
@ -97,23 +76,6 @@ public class FabricNextPipeliner {
return resultBuilder.build();
}
private void processNextIdMapping(NextObjective next,
PipelinerTranslationResult.Builder resultBuilder) {
// program the next id mapping table
TrafficSelector nextIdSelector = buildNextIdSelector(next.id());
TrafficTreatment setNextTypeTreatment = buildSetNextTypeTreatment(next.type());
resultBuilder.addFlowRule(DefaultFlowRule.builder()
.withSelector(nextIdSelector)
.withTreatment(setNextTypeTreatment)
.forDevice(deviceId)
.forTable(TBL_NEXT_ID_MAPPING_ID)
.makePermanent()
.withPriority(next.priority())
.fromApp(next.appId())
.build());
}
private void processSimpleNext(NextObjective next,
PipelinerTranslationResult.Builder resultBuilder) {
@ -165,7 +127,7 @@ public class FabricNextPipeliner {
GroupBuckets buckets = new GroupBuckets(bucketList);
PiGroupKey groupKey = new PiGroupKey(TBL_HASHED_ID,
ACT_PRF_ECMP_SELECTOR_ID,
ACT_PRF_NEXT_ECMP_SELECTOR_ID,
groupId);
resultBuilder.addGroup(new DefaultGroupDescription(deviceId,
@ -200,17 +162,4 @@ public class FabricNextPipeliner {
.matchPi(nextIdCriterion)
.build();
}
private TrafficTreatment buildSetNextTypeTreatment(NextObjective.Type nextType) {
byte nextTypeVal = NEXT_TYPE_MAP.getOrDefault(nextType, NXT_TYPE_PUNT);
PiActionParam nextTypeParam = new PiActionParam(ACT_PRM_NEXT_TYPE_ID,
copyFrom(nextTypeVal));
PiAction nextTypeAction = PiAction.builder()
.withId(ACT_SET_NEXT_TYPE_ID)
.withParameter(nextTypeParam)
.build();
return DefaultTrafficTreatment.builder()
.piTableAction(nextTypeAction)
.build();
}
}

View File

@ -50,7 +50,6 @@ control Forwarding (
}
action duplicate_to_controller() {
fabric_metadata.next_type = NEXT_TYPE_PUNT;
standard_metadata.egress_spec = CPU_PORT;
}

View File

@ -24,16 +24,11 @@ control Next (
inout parsed_headers_t hdr,
inout fabric_metadata_t fabric_metadata,
inout standard_metadata_t standard_metadata) {
direct_counter(CounterType.packets_and_bytes) next_id_mapping_counter;
direct_counter(CounterType.packets_and_bytes) simple_counter;
direct_counter(CounterType.packets_and_bytes) hashed_counter;
direct_counter(CounterType.packets_and_bytes) broadcast_counter;
action_selector(HashAlgorithm.crc16, 32w64, 32w16) ecmp_selector;
action set_next_type(next_type_t next_type) {
fabric_metadata.next_type = next_type;
}
action output(port_num_t port_num) {
standard_metadata.egress_spec = port_num;
if(!hdr.mpls.isValid()) {
@ -95,17 +90,6 @@ control Next (
push_mpls(label, hdr.ipv6.traffic_class[7:5]);
}
table next_id_mapping {
key = {
fabric_metadata.next_id: exact;
}
actions = {
set_next_type;
}
counters = next_id_mapping_counter;
}
table simple {
key = {
fabric_metadata.next_id: exact;
@ -156,11 +140,9 @@ control Next (
}
apply {
next_id_mapping.apply();
if (fabric_metadata.next_type == NEXT_TYPE_SIMPLE) simple.apply();
else if (fabric_metadata.next_type == NEXT_TYPE_HASHED) hashed.apply();
else if (fabric_metadata.next_type == NEXT_TYPE_BROADCAST) broadcast.apply();
// next_type == PUNT, leave it to packet-io egress
simple.apply();
hashed.apply();
broadcast.apply();
}
}

View File

@ -21,7 +21,6 @@
typedef bit<3> fwd_type_t;
typedef bit<32> next_id_t;
typedef bit<3> next_type_t;
typedef bit<20> mpls_label_t;
typedef bit<9> port_num_t;
typedef bit<48> mac_addr_t;
@ -55,11 +54,6 @@ const fwd_type_t FWD_IPV4_MULTICAST = 3;
const fwd_type_t FWD_IPV6_UNICAST = 4;
const fwd_type_t FWD_IPV6_MULTICAST = 5;
const next_type_t NEXT_TYPE_SIMPLE = 0;
const next_type_t NEXT_TYPE_HASHED = 1;
const next_type_t NEXT_TYPE_BROADCAST = 2;
const next_type_t NEXT_TYPE_PUNT = 3;
const bit<8> DEFAULT_MPLS_TTL = 64;
#endif

View File

@ -117,7 +117,6 @@ header icmp_t {
struct fabric_metadata_t {
fwd_type_t fwd_type;
next_id_t next_id;
next_type_t next_type;
bool pop_vlan_at_egress;
bit<8> ip_proto;
bit<16> l4_src_port;

File diff suppressed because it is too large Load Diff

View File

@ -373,28 +373,6 @@ tables {
direct_resource_ids: 302000008
size: 1024
}
tables {
preamble {
id: 33589605
name: "next.next_id_mapping"
alias: "next_id_mapping"
}
match_fields {
id: 1
name: "fabric_metadata.next_id"
bitwidth: 32
match_type: EXACT
}
action_refs {
id: 16800774
}
action_refs {
id: 16800567
annotations: "@defaultonly()"
}
direct_resource_ids: 302015538
size: 1024
}
tables {
preamble {
id: 33615740
@ -562,18 +540,6 @@ actions {
alias: "duplicate_to_controller"
}
}
actions {
preamble {
id: 16800774
name: "next.set_next_type"
alias: "set_next_type"
}
params {
id: 1
name: "next_type"
bitwidth: 3
}
}
actions {
preamble {
id: 16818315
@ -827,17 +793,6 @@ direct_counters {
}
direct_table_id: 33587782
}
direct_counters {
preamble {
id: 302015538
name: "next.next_id_mapping_counter"
alias: "next_id_mapping_counter"
}
spec {
unit: BOTH
}
direct_table_id: 33589605
}
direct_counters {
preamble {
id: 301991179

View File

@ -19,7 +19,6 @@ package org.onosproject.pipelines.fabric.pipeliner;
import com.google.common.collect.ImmutableList;
import org.junit.Ignore;
import org.junit.Test;
import org.onlab.util.ImmutableByteSequence;
import org.onosproject.net.flow.DefaultFlowRule;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
@ -34,9 +33,7 @@ import org.onosproject.net.group.DefaultGroupDescription;
import org.onosproject.net.group.GroupBucket;
import org.onosproject.net.group.GroupBuckets;
import org.onosproject.net.group.GroupDescription;
import org.onosproject.net.pi.runtime.PiAction;
import org.onosproject.net.pi.runtime.PiActionGroupId;
import org.onosproject.net.pi.runtime.PiActionParam;
import org.onosproject.net.pi.runtime.PiGroupKey;
import org.onosproject.pipelines.fabric.FabricConstants;
@ -45,7 +42,7 @@ import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.onosproject.pipelines.fabric.FabricConstants.ACT_PRF_ECMP_SELECTOR_ID;
import static org.onosproject.pipelines.fabric.FabricConstants.ACT_PRF_NEXT_ECMP_SELECTOR_ID;
import static org.onosproject.pipelines.fabric.FabricConstants.TBL_HASHED_ID;
/**
@ -103,11 +100,9 @@ public class FabricNextPipelinerTest extends FabricPipelinerTest {
List<FlowRule> flowRulesInstalled = (List<FlowRule>) result.flowRules();
List<GroupDescription> groupsInstalled = (List<GroupDescription>) result.groups();
assertEquals(2, flowRulesInstalled.size());
assertEquals(1, flowRulesInstalled.size());
assertTrue(groupsInstalled.isEmpty());
verifyNextIdMapping(flowRulesInstalled.get(0), NEXT_TYPE_SIMPLE);
// Simple table
PiCriterion nextIdCriterion = PiCriterion.builder()
.matchExact(FabricConstants.HF_FABRIC_METADATA_NEXT_ID_ID, NEXT_ID_1)
@ -115,7 +110,7 @@ public class FabricNextPipelinerTest extends FabricPipelinerTest {
TrafficSelector nextIdSelector = DefaultTrafficSelector.builder()
.matchPi(nextIdCriterion)
.build();
FlowRule actualFlowRule = flowRulesInstalled.get(1);
FlowRule actualFlowRule = flowRulesInstalled.get(0);
FlowRule expectedFlowRule = DefaultFlowRule.builder()
.forDevice(DEVICE_ID)
.fromApp(APP_ID)
@ -129,36 +124,6 @@ public class FabricNextPipelinerTest extends FabricPipelinerTest {
assertTrue(expectedFlowRule.exactMatch(actualFlowRule));
}
private void verifyNextIdMapping(FlowRule flowRule, byte nextType) {
FlowRule expectedFlowRule;
PiCriterion nextIdCriterion = PiCriterion.builder()
.matchExact(FabricConstants.HF_FABRIC_METADATA_NEXT_ID_ID, NEXT_ID_1)
.build();
TrafficSelector nextIdSelector = DefaultTrafficSelector.builder()
.matchPi(nextIdCriterion)
.build();
PiActionParam setNextToSimpleParam = new PiActionParam(FabricConstants.ACT_PRM_NEXT_TYPE_ID,
ImmutableByteSequence.copyFrom(nextType));
PiAction setNextToSimpleAction = PiAction.builder()
.withId(FabricConstants.ACT_SET_NEXT_TYPE_ID)
.withParameter(setNextToSimpleParam)
.build();
TrafficTreatment setNextTypeTreatment = DefaultTrafficTreatment.builder()
.piTableAction(setNextToSimpleAction)
.build();
expectedFlowRule = DefaultFlowRule.builder()
.forDevice(DEVICE_ID)
.fromApp(APP_ID)
.makePermanent()
// FIXME: currently next objective doesn't support priority, set priority to zero
.withPriority(0)
.forTable(FabricConstants.TBL_NEXT_ID_MAPPING_ID)
.withSelector(nextIdSelector)
.withTreatment(setNextTypeTreatment)
.build();
assertTrue(expectedFlowRule.exactMatch(flowRule));
}
/**
* Test program ecmp output group for Hashed table.
*/
@ -190,11 +155,9 @@ public class FabricNextPipelinerTest extends FabricPipelinerTest {
// Should generates 2 flows and 1 group
List<FlowRule> flowRulesInstalled = (List<FlowRule>) result.flowRules();
List<GroupDescription> groupsInstalled = (List<GroupDescription>) result.groups();
assertEquals(2, flowRulesInstalled.size());
assertEquals(1, flowRulesInstalled.size());
assertEquals(1, groupsInstalled.size());
verifyNextIdMapping(flowRulesInstalled.get(0), NEXT_TYPE_HASHED);
// Hashed table
PiCriterion nextIdCriterion = PiCriterion.builder()
.matchExact(FabricConstants.HF_FABRIC_METADATA_NEXT_ID_ID, NEXT_ID_1)
@ -206,7 +169,7 @@ public class FabricNextPipelinerTest extends FabricPipelinerTest {
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.piTableAction(actionGroupId)
.build();
FlowRule actualFlowRule = flowRulesInstalled.get(1);
FlowRule actualFlowRule = flowRulesInstalled.get(0);
FlowRule expectedFlowRule = DefaultFlowRule.builder()
.forDevice(DEVICE_ID)
.fromApp(APP_ID)
@ -227,7 +190,7 @@ public class FabricNextPipelinerTest extends FabricPipelinerTest {
.map(DefaultGroupBucket::createSelectGroupBucket)
.collect(Collectors.toList());
GroupBuckets groupBuckets = new GroupBuckets(buckets);
PiGroupKey groupKey = new PiGroupKey(TBL_HASHED_ID, ACT_PRF_ECMP_SELECTOR_ID, NEXT_ID_1);
PiGroupKey groupKey = new PiGroupKey(TBL_HASHED_ID, ACT_PRF_NEXT_ECMP_SELECTOR_ID, NEXT_ID_1);
GroupDescription expectedGroup = new DefaultGroupDescription(
DEVICE_ID,
GroupDescription.Type.SELECT,