Search in sources :

Example 86 with PiActionParam

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();
}
Also used : PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 87 with PiActionParam

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);
}
Also used : DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction) Test(org.junit.Test)

Example 88 with PiActionParam

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();
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam)

Example 89 with PiActionParam

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();
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 90 with PiActionParam

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();
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction)

Aggregations

PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)102 PiAction (org.onosproject.net.pi.runtime.PiAction)90 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)50 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)50 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)39 TrafficSelector (org.onosproject.net.flow.TrafficSelector)39 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)39 Test (org.junit.Test)30 FlowRule (org.onosproject.net.flow.FlowRule)27 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)21 GroupDescription (org.onosproject.net.group.GroupDescription)11 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)10 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)8 NextObjective (org.onosproject.net.flowobjective.NextObjective)8 PortNumber (org.onosproject.net.PortNumber)7 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)7 GroupBucket (org.onosproject.net.group.GroupBucket)7 GroupBuckets (org.onosproject.net.group.GroupBuckets)7 PiActionProfileGroupId (org.onosproject.net.pi.runtime.PiActionProfileGroupId)7 PiGroupKey (org.onosproject.net.pi.runtime.PiGroupKey)6