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());
}
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();
}
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();
}
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);
}
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);
}
Aggregations