use of org.onosproject.net.pi.runtime.PiAction in project onos by opennetworkinglab.
the class FabricTreatmentInterpreter method mapNextHashedOrSimpleTreatment.
private static PiAction mapNextHashedOrSimpleTreatment(TrafficTreatment treatment, PiTableId tableId, boolean simple) throws PiInterpreterException {
// Provide mapping for output_hashed and routing_hashed; multicast_hashed
// can only be invoked with PiAction, hence no mapping. outPort required for
// all actions. Presence of other instructions will determine which action to map to.
final PortNumber outPort = ((OutputInstruction) instructionOrFail(treatment, OUTPUT, tableId)).port();
final ModEtherInstruction ethDst = (ModEtherInstruction) l2Instruction(treatment, ETH_DST);
final ModEtherInstruction ethSrc = (ModEtherInstruction) l2Instruction(treatment, ETH_SRC);
final PiAction.Builder actionBuilder = PiAction.builder().withParameter(new PiActionParam(FabricConstants.PORT_NUM, outPort.toLong()));
if (ethDst != null && ethSrc != null) {
actionBuilder.withParameter(new PiActionParam(FabricConstants.SMAC, ethSrc.mac().toBytes()));
actionBuilder.withParameter(new PiActionParam(FabricConstants.DMAC, ethDst.mac().toBytes()));
// routing_hashed
return actionBuilder.withId(simple ? FabricConstants.FABRIC_INGRESS_NEXT_ROUTING_SIMPLE : FabricConstants.FABRIC_INGRESS_NEXT_ROUTING_HASHED).build();
} else {
// output_hashed
return actionBuilder.withId(simple ? FabricConstants.FABRIC_INGRESS_NEXT_OUTPUT_SIMPLE : FabricConstants.FABRIC_INGRESS_NEXT_OUTPUT_HASHED).build();
}
}
use of org.onosproject.net.pi.runtime.PiAction in project onos by opennetworkinglab.
the class FabricBngProgrammable method buildTPppoeTermV4FlowRule.
/**
* Build the Flow Rule for the table t_pppoe_term_v4 of the ingress
* upstream.
*/
private FlowRule buildTPppoeTermV4FlowRule(Attachment attachment) throws BngProgrammableException {
PiCriterion criterion = PiCriterion.builder().matchExact(FabricConstants.HDR_LINE_ID, lineId(attachment)).matchExact(FabricConstants.HDR_IPV4_SRC, attachment.ipAddress().toOctets()).matchExact(FabricConstants.HDR_PPPOE_SESSION_ID, attachment.pppoeSessionId()).build();
TrafficSelector trafficSelector = DefaultTrafficSelector.builder().matchPi(criterion).build();
PiAction action = PiAction.builder().withId(attachment.lineActive() ? FabricConstants.FABRIC_INGRESS_BNG_INGRESS_UPSTREAM_TERM_ENABLED_V4 : FabricConstants.FABRIC_INGRESS_BNG_INGRESS_UPSTREAM_TERM_DISABLED).build();
TrafficTreatment instTreatment = DefaultTrafficTreatment.builder().piTableAction(action).build();
return buildFlowRule(trafficSelector, instTreatment, FabricConstants.FABRIC_INGRESS_BNG_INGRESS_UPSTREAM_T_PPPOE_TERM_V4, attachment.appId());
}
use of org.onosproject.net.pi.runtime.PiAction in project onos by opennetworkinglab.
the class FabricBngProgrammable method buildTLineMapFlowRule.
/**
* Build the flow rule for the table t_line_map of the BNG-U (common to both
* upstream and downstream).
*/
private FlowRule buildTLineMapFlowRule(Attachment attachment) throws BngProgrammableException {
PiCriterion criterion = PiCriterion.builder().matchExact(FabricConstants.HDR_S_TAG, attachment.sTag().toShort()).matchExact(FabricConstants.HDR_C_TAG, attachment.cTag().toShort()).build();
TrafficSelector trafficSelector = DefaultTrafficSelector.builder().matchPi(criterion).build();
PiAction action = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_BNG_INGRESS_SET_LINE).withParameter(new PiActionParam(FabricConstants.LINE_ID, lineId(attachment))).build();
TrafficTreatment instTreatment = DefaultTrafficTreatment.builder().piTableAction(action).build();
return buildFlowRule(trafficSelector, instTreatment, FabricConstants.FABRIC_INGRESS_BNG_INGRESS_T_LINE_MAP, attachment.appId());
}
use of org.onosproject.net.pi.runtime.PiAction 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.PiAction 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();
}
Aggregations