Search in sources :

Example 56 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class FabricBngProgrammable method buildTLineSessionMapFlowRule.

/**
 * Build the Flow Rule for the table t_line_session_map of the ingress
 * downstream.
 */
private FlowRule buildTLineSessionMapFlowRule(Attachment attachment) throws BngProgrammableException {
    PiCriterion criterion = PiCriterion.builder().matchExact(FabricConstants.HDR_LINE_ID, lineId(attachment)).build();
    TrafficSelector trafficSelector = DefaultTrafficSelector.builder().matchPi(criterion).build();
    PiAction action;
    if (attachment.lineActive()) {
        action = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_BNG_INGRESS_DOWNSTREAM_SET_SESSION).withParameter(new PiActionParam(FabricConstants.PPPOE_SESSION_ID, attachment.pppoeSessionId())).build();
    } else {
        action = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_BNG_INGRESS_DOWNSTREAM_DROP).build();
    }
    TrafficTreatment instTreatment = DefaultTrafficTreatment.builder().piTableAction(action).build();
    return buildFlowRule(trafficSelector, instTreatment, FabricConstants.FABRIC_INGRESS_BNG_INGRESS_DOWNSTREAM_T_LINE_SESSION_MAP, attachment.appId());
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 57 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class FabricPipeliner method fwdClassifierRule.

public FlowRule fwdClassifierRule(long port, Short ethType, short ipEthType, byte fwdType, int priority) {
    final TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder().matchInPort(PortNumber.portNumber(port)).matchPi(PiCriterion.builder().matchExact(FabricConstants.HDR_IP_ETH_TYPE, ipEthType).build());
    if (ethType != null) {
        selectorBuilder.matchEthType(ethType);
    }
    final TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_FILTERING_SET_FORWARDING_TYPE).withParameter(new PiActionParam(FabricConstants.FWD_TYPE, fwdType)).build()).build();
    return DefaultFlowRule.builder().withSelector(selectorBuilder.build()).withTreatment(treatment).forTable(FabricConstants.FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER).makePermanent().withPriority(priority).forDevice(deviceId).fromApp(appId).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 58 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class FilteringObjectiveTranslator method fwdClassifierTreatment.

private TrafficTreatment fwdClassifierTreatment(byte fwdType) {
    final PiActionParam param = new PiActionParam(FabricConstants.FWD_TYPE, fwdType);
    final PiAction action = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_FILTERING_SET_FORWARDING_TYPE).withParameter(param).build();
    return DefaultTrafficTreatment.builder().piTableAction(action).build();
}
Also used : PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 59 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class NextObjectiveTranslatorTest method testSimpleOutputWithVlanAndMacTranslation.

/**
 * Test program set mac, set vlan, and output rule for Simple table.
 */
@Test
public void testSimpleOutputWithVlanAndMacTranslation() throws FabricPipelinerException {
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setEthSrc(ROUTER_MAC).setEthDst(HOST_MAC).setVlanId(VLAN_100).setOutput(PORT_1).build();
    PiAction piAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_NEXT_ROUTING_SIMPLE).withParameter(new PiActionParam(FabricConstants.SMAC, ROUTER_MAC.toBytes())).withParameter(new PiActionParam(FabricConstants.DMAC, HOST_MAC.toBytes())).withParameter(new PiActionParam(FabricConstants.PORT_NUM, PORT_1.toLong())).build();
    testSimple(treatment, piAction);
}
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 60 with PiActionParam

use of org.onosproject.net.pi.runtime.PiActionParam in project onos by opennetworkinglab.

the class NextObjectiveTranslatorTest method testBroadcastOutput.

/**
 * Test program output group for Broadcast table.
 */
@Test
public void testBroadcastOutput() throws FabricPipelinerException {
    TrafficTreatment treatment1 = DefaultTrafficTreatment.builder().setOutput(PORT_1).build();
    TrafficTreatment treatment2 = DefaultTrafficTreatment.builder().popVlan().setOutput(PORT_2).build();
    NextObjective nextObjective = DefaultNextObjective.builder().withId(NEXT_ID_1).withPriority(PRIORITY).addTreatment(treatment1).addTreatment(treatment2).withMeta(VLAN_META).withType(NextObjective.Type.BROADCAST).makePermanent().fromApp(APP_ID).add();
    ObjectiveTranslation actualTranslation = translatorHashed.doTranslate(nextObjective);
    // Should generate 3 flows:
    // - Multicast table flow that matches on next-id and set multicast group (1)
    // - Egress VLAN pop handling for treatment2 (0)
    // - Next VLAN flow (2)
    // And 2 groups:
    // - Multicast group
    // Expected multicast table flow rule.
    PiCriterion nextIdCriterion = PiCriterion.builder().matchExact(FabricConstants.HDR_NEXT_ID, NEXT_ID_1).build();
    TrafficSelector nextIdSelector = DefaultTrafficSelector.builder().matchPi(nextIdCriterion).build();
    PiAction setMcGroupAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_NEXT_SET_MCAST_GROUP_ID).withParameter(new PiActionParam(FabricConstants.GROUP_ID, NEXT_ID_1)).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(setMcGroupAction).build();
    FlowRule expectedHashedFlowRule = DefaultFlowRule.builder().forDevice(DEVICE_ID).fromApp(APP_ID).makePermanent().withPriority(nextObjective.priority()).forTable(FabricConstants.FABRIC_INGRESS_NEXT_MULTICAST).withSelector(nextIdSelector).withTreatment(treatment).build();
    // Expected egress VLAN_PUSH flow rule.
    PiCriterion egressVlanTableMatch = PiCriterion.builder().matchExact(FabricConstants.HDR_EG_PORT, PORT_1.toLong()).build();
    TrafficSelector selectorForEgressVlan = DefaultTrafficSelector.builder().matchPi(egressVlanTableMatch).matchVlanId(VLAN_100).build();
    PiAction piActionForEgressVlan = PiAction.builder().withId(FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_PUSH_VLAN).build();
    TrafficTreatment treatmentForEgressVlan = DefaultTrafficTreatment.builder().piTableAction(piActionForEgressVlan).build();
    FlowRule expectedEgressVlanPushRule = DefaultFlowRule.builder().withSelector(selectorForEgressVlan).withTreatment(treatmentForEgressVlan).forTable(FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN).makePermanent().withPriority(nextObjective.priority()).forDevice(DEVICE_ID).fromApp(APP_ID).build();
    // Expected egress VLAN POP flow rule.
    egressVlanTableMatch = PiCriterion.builder().matchExact(FabricConstants.HDR_EG_PORT, PORT_2.toLong()).build();
    selectorForEgressVlan = DefaultTrafficSelector.builder().matchPi(egressVlanTableMatch).matchVlanId(VLAN_100).build();
    piActionForEgressVlan = PiAction.builder().withId(FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_POP_VLAN).build();
    treatmentForEgressVlan = DefaultTrafficTreatment.builder().piTableAction(piActionForEgressVlan).build();
    FlowRule expectedEgressVlanPopRule = DefaultFlowRule.builder().withSelector(selectorForEgressVlan).withTreatment(treatmentForEgressVlan).forTable(FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN).makePermanent().withPriority(nextObjective.priority()).forDevice(DEVICE_ID).fromApp(APP_ID).build();
    // Expected ALL group.
    TrafficTreatment allGroupTreatment1 = DefaultTrafficTreatment.builder().setOutput(PORT_1).build();
    TrafficTreatment allGroupTreatment2 = DefaultTrafficTreatment.builder().setOutput(PORT_2).build();
    List<TrafficTreatment> allTreatments = ImmutableList.of(allGroupTreatment1, allGroupTreatment2);
    List<GroupBucket> allBuckets = allTreatments.stream().map(DefaultGroupBucket::createAllGroupBucket).collect(Collectors.toList());
    GroupBuckets allGroupBuckets = new GroupBuckets(allBuckets);
    GroupKey allGroupKey = new DefaultGroupKey(FabricPipeliner.KRYO.serialize(NEXT_ID_1));
    GroupDescription expectedAllGroup = new DefaultGroupDescription(DEVICE_ID, GroupDescription.Type.ALL, allGroupBuckets, allGroupKey, NEXT_ID_1, APP_ID);
    ObjectiveTranslation expectedTranslation = ObjectiveTranslation.builder().addFlowRule(expectedHashedFlowRule).addFlowRule(vlanMetaFlowRule).addFlowRule(expectedEgressVlanPushRule).addFlowRule(expectedEgressVlanPopRule).addGroup(expectedAllGroup).build();
    assertEquals(expectedTranslation, actualTranslation);
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) PiGroupKey(org.onosproject.net.pi.runtime.PiGroupKey) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) PiAction(org.onosproject.net.pi.runtime.PiAction) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) Test(org.junit.Test)

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