use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class FabricIntProgrammableTest method buildReportAction.
private PiAction buildReportAction(boolean setMpls, short reportType, short bmdType) {
final PiActionParam srcIpParam = new PiActionParam(P4InfoConstants.SRC_IP, ROUTER_IP.toOctets());
final PiActionParam monIpParam = new PiActionParam(P4InfoConstants.MON_IP, COLLECTOR_IP.toOctets());
final PiActionParam monPortParam = new PiActionParam(P4InfoConstants.MON_PORT, COLLECTOR_PORT.toInt());
final PiActionParam switchIdParam = new PiActionParam(P4InfoConstants.SWITCH_ID, NODE_SID_IPV4);
final PiAction.Builder reportAction = PiAction.builder().withParameter(srcIpParam).withParameter(monIpParam).withParameter(monPortParam).withParameter(switchIdParam);
if (setMpls) {
reportAction.withParameter(new PiActionParam(P4InfoConstants.MON_LABEL, NODE_SID_IPV4));
if ((reportType & (INT_REPORT_TYPE_FLOW | INT_REPORT_TYPE_QUEUE)) != 0) {
reportAction.withId(P4InfoConstants.FABRIC_EGRESS_INT_EGRESS_DO_LOCAL_REPORT_ENCAP_MPLS);
} else {
reportAction.withId(P4InfoConstants.FABRIC_EGRESS_INT_EGRESS_DO_DROP_REPORT_ENCAP_MPLS);
}
} else {
if ((reportType & (INT_REPORT_TYPE_FLOW | INT_REPORT_TYPE_QUEUE)) != 0) {
reportAction.withId(P4InfoConstants.FABRIC_EGRESS_INT_EGRESS_DO_LOCAL_REPORT_ENCAP);
} else {
reportAction.withId(P4InfoConstants.FABRIC_EGRESS_INT_EGRESS_DO_DROP_REPORT_ENCAP);
}
}
return reportAction.build();
}
use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class FabricInterpreterTest method testNextTreatmentHashedRoutingV4.
/* Next control block */
// TODO: add profile with simple next or remove test
// /**
// * Map treatment to output action for simple next.
// */
// @Test
// public void testNextTreatmentSimpleOutput() throws Exception {
// TrafficTreatment treatment = DefaultTrafficTreatment.builder()
// .setOutput(PORT_1)
// .build();
// PiAction mappedAction = interpreter.mapTreatment(
// treatment, P4InfoConstants.FABRIC_INGRESS_NEXT_SIMPLE);
// PiActionParam param = new PiActionParam(P4InfoConstants.PORT_NUM, PORT_1.toLong());
// PiAction expectedAction = PiAction.builder()
// .withId(P4InfoConstants.FABRIC_INGRESS_NEXT_OUTPUT_SIMPLE)
// .withParameter(param)
// .build();
// assertEquals(expectedAction, mappedAction);
// }
/**
* Map treatment for hashed table to routing v4 action.
*/
@Test
public void testNextTreatmentHashedRoutingV4() throws Exception {
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setEthSrc(SRC_MAC).setEthDst(DST_MAC).setOutput(PORT_1).build();
PiAction mappedAction = interpreter.mapTreatment(treatment, P4InfoConstants.FABRIC_INGRESS_NEXT_HASHED);
PiActionParam ethSrcParam = new PiActionParam(P4InfoConstants.SMAC, SRC_MAC.toBytes());
PiActionParam ethDstParam = new PiActionParam(P4InfoConstants.DMAC, DST_MAC.toBytes());
PiActionParam portParam = new PiActionParam(P4InfoConstants.PORT_NUM, PORT_1.toLong());
PiAction expectedAction = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_NEXT_ROUTING_HASHED).withParameters(ImmutableList.of(ethSrcParam, ethDstParam, portParam)).build();
assertEquals(expectedAction, mappedAction);
}
use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class FabricPipelinerTest method buildIngressVlanRule.
private FlowRule buildIngressVlanRule(long port) {
final TrafficSelector cpuIgVlanSelector = DefaultTrafficSelector.builder().add(Criteria.matchInPort(PortNumber.portNumber(port))).add(PiCriterion.builder().matchExact(P4InfoConstants.HDR_VLAN_IS_VALID, ZERO).build()).build();
final TrafficTreatment igVlanTreatment = DefaultTrafficTreatment.builder().piTableAction(PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_FILTERING_PERMIT_WITH_INTERNAL_VLAN).withParameter(new PiActionParam(P4InfoConstants.VLAN_ID, DEFAULT_VLAN)).withParameter(new PiActionParam(P4InfoConstants.PORT_TYPE, PORT_TYPE_INTERNAL)).build()).build();
return DefaultFlowRule.builder().withSelector(cpuIgVlanSelector).withTreatment(igVlanTreatment).forTable(P4InfoConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN).makePermanent().withPriority(DEFAULT_FLOW_PRIORITY).forDevice(DEVICE_ID).fromApp(APP_ID).build();
}
use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class SlicingManagerTest method buildQueuesFlowRuleSlice1ElasticNotRed.
private FlowRule buildQueuesFlowRuleSlice1ElasticNotRed() {
PiCriterion.Builder piCriterionBuilder = PiCriterion.builder().matchExact(P4InfoConstants.HDR_SLICE_TC, sliceTcConcat(SLICE_IDS.get(1).id(), TrafficClass.ELASTIC.toInt()));
PiAction.Builder piTableActionBuilder = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_QOS_SET_QUEUE).withParameter(new PiActionParam(P4InfoConstants.QID, QUEUE_ID_ELASTIC.id()));
return DefaultFlowRule.builder().forDevice(SlicingManagerTest.DEVICE_ID).forTable(PiTableId.of(FABRIC_INGRESS_QOS_QUEUES.id())).fromApp(APP_ID).withPriority(QUEUES_FLOW_PRIORITY_LOW).withSelector(DefaultTrafficSelector.builder().matchPi(piCriterionBuilder.build()).build()).withTreatment(DefaultTrafficTreatment.builder().piTableAction(piTableActionBuilder.build()).build()).makePermanent().build();
}
use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class SlicingManagerTest method buildQueuesFlowRuleSlice1BestEffort.
private FlowRule buildQueuesFlowRuleSlice1BestEffort() {
PiCriterion.Builder piCriterionBuilder = PiCriterion.builder().matchExact(P4InfoConstants.HDR_SLICE_TC, sliceTcConcat(SLICE_IDS.get(1).id(), TrafficClass.BEST_EFFORT.toInt()));
PiAction.Builder piTableActionBuilder = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_QOS_SET_QUEUE).withParameter(new PiActionParam(P4InfoConstants.QID, QueueId.BEST_EFFORT.id()));
return DefaultFlowRule.builder().forDevice(DEVICE_ID).forTable(PiTableId.of(FABRIC_INGRESS_QOS_QUEUES.id())).fromApp(APP_ID).withPriority(QUEUES_FLOW_PRIORITY_LOW).withSelector(DefaultTrafficSelector.builder().matchPi(piCriterionBuilder.build()).build()).withTreatment(DefaultTrafficTreatment.builder().piTableAction(piTableActionBuilder.build()).build()).makePermanent().build();
}
Aggregations