Search in sources :

Example 71 with PiAction

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();
    }
}
Also used : OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) ModEtherInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction) PortNumber(org.onosproject.net.PortNumber) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 72 with PiAction

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

Example 73 with PiAction

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());
}
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 74 with PiAction

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());
}
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 75 with PiAction

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

Aggregations

PiAction (org.onosproject.net.pi.runtime.PiAction)117 PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)74 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)69 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)68 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)57 TrafficSelector (org.onosproject.net.flow.TrafficSelector)57 Test (org.junit.Test)44 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)44 FlowRule (org.onosproject.net.flow.FlowRule)39 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)33 GroupDescription (org.onosproject.net.group.GroupDescription)22 List (java.util.List)15 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)14 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)14 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)13 PortNumber (org.onosproject.net.PortNumber)9 NextObjective (org.onosproject.net.flowobjective.NextObjective)9 GroupBucket (org.onosproject.net.group.GroupBucket)9 PiActionId (org.onosproject.net.pi.model.PiActionId)9 PiTableAction (org.onosproject.net.pi.runtime.PiTableAction)9