Search in sources :

Example 6 with PiAction

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

the class IntProgrammableImpl method buildWatchlistEntry.

private FlowRule buildWatchlistEntry(IntObjective obj) {
    int instructionBitmap = buildInstructionBitmap(obj.metadataTypes());
    PiActionParam hopMetaLenParam = new PiActionParam(IntConstants.HOP_METADATA_LEN, ImmutableByteSequence.copyFrom(Integer.bitCount(instructionBitmap)));
    PiActionParam hopCntParam = new PiActionParam(IntConstants.REMAINING_HOP_CNT, ImmutableByteSequence.copyFrom(MAXHOP));
    PiActionParam inst0003Param = new PiActionParam(IntConstants.INS_MASK0003, ImmutableByteSequence.copyFrom((instructionBitmap >> 12) & 0xF));
    PiActionParam inst0407Param = new PiActionParam(IntConstants.INS_MASK0407, ImmutableByteSequence.copyFrom((instructionBitmap >> 8) & 0xF));
    PiAction intSourceAction = PiAction.builder().withId(IntConstants.INGRESS_PROCESS_INT_SOURCE_INT_SOURCE_DSCP).withParameter(hopMetaLenParam).withParameter(hopCntParam).withParameter(inst0003Param).withParameter(inst0407Param).build();
    TrafficTreatment instTreatment = DefaultTrafficTreatment.builder().piTableAction(intSourceAction).build();
    TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
    for (Criterion criterion : obj.selector().criteria()) {
        switch(criterion.type()) {
            case IPV4_SRC:
                sBuilder.matchIPSrc(((IPCriterion) criterion).ip());
                break;
            case IPV4_DST:
                sBuilder.matchIPDst(((IPCriterion) criterion).ip());
                break;
            case TCP_SRC:
                sBuilder.matchPi(PiCriterion.builder().matchTernary(IntConstants.HDR_LOCAL_METADATA_L4_SRC_PORT, ((TcpPortCriterion) criterion).tcpPort().toInt(), PORTMASK).build());
                break;
            case UDP_SRC:
                sBuilder.matchPi(PiCriterion.builder().matchTernary(IntConstants.HDR_LOCAL_METADATA_L4_SRC_PORT, ((UdpPortCriterion) criterion).udpPort().toInt(), PORTMASK).build());
                break;
            case TCP_DST:
                sBuilder.matchPi(PiCriterion.builder().matchTernary(IntConstants.HDR_LOCAL_METADATA_L4_DST_PORT, ((TcpPortCriterion) criterion).tcpPort().toInt(), PORTMASK).build());
                break;
            case UDP_DST:
                sBuilder.matchPi(PiCriterion.builder().matchTernary(IntConstants.HDR_LOCAL_METADATA_L4_DST_PORT, ((UdpPortCriterion) criterion).udpPort().toInt(), PORTMASK).build());
                break;
            default:
                log.warn("Unsupported criterion type: {}", criterion.type());
        }
    }
    return DefaultFlowRule.builder().forDevice(this.data().deviceId()).withSelector(sBuilder.build()).withTreatment(instTreatment).withPriority(DEFAULT_PRIORITY).forTable(IntConstants.INGRESS_PROCESS_INT_SOURCE_TB_INT_SOURCE).fromApp(appId).withIdleTimeout(IDLE_TIMEOUT).build();
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) 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 7 with PiAction

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

the class FabricIntProgrammable method init.

@Override
public boolean init() {
    if (!setupBehaviour()) {
        return false;
    }
    // FIXME: create config class for INT to allow specifying arbitrary
    // switch IDs. The one for the GeneralDeviceProvider was temporary and
    // now has been removed. For now we use the chassis ID.
    // final GeneralProviderDeviceConfig cfg = cfgService.getConfig(
    // deviceId, GeneralProviderDeviceConfig.class);
    // if (cfg == null) {
    // log.warn("Missing GeneralProviderDevice config for {}", deviceId);
    // return false;
    // }
    // final String switchId = cfg.protocolsInfo().containsKey("int") ?
    // cfg.protocolsInfo().get("int").configValues().get("switchId")
    // : null;
    // if (switchId == null || switchId.isEmpty()) {
    // log.warn("Missing INT device config for {}", deviceId);
    // return false;
    // }
    PiActionParam transitIdParam = new PiActionParam(FabricConstants.SWITCH_ID, copyFrom(handler().get(DeviceService.class).getDevice(deviceId).chassisId().id()));
    PiAction transitAction = PiAction.builder().withId(FabricConstants.FABRIC_EGRESS_PROCESS_INT_MAIN_PROCESS_INT_TRANSIT_INIT_METADATA).withParameter(transitIdParam).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(transitAction).build();
    TrafficSelector selector = DefaultTrafficSelector.builder().matchPi(PiCriterion.builder().matchExact(FabricConstants.HDR_INT_IS_VALID, (byte) 0x01).build()).build();
    FlowRule transitFlowRule = DefaultFlowRule.builder().withSelector(selector).withTreatment(treatment).fromApp(appId).withPriority(DEFAULT_PRIORITY).makePermanent().forDevice(deviceId).forTable(FabricConstants.FABRIC_EGRESS_PROCESS_INT_MAIN_PROCESS_INT_TRANSIT_TB_INT_INSERT).build();
    flowRuleService.applyFlowRules(transitFlowRule);
    return true;
}
Also used : DeviceService(org.onosproject.net.device.DeviceService) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) 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 8 with PiAction

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

the class FabricIntProgrammable method setSourcePort.

@Override
public boolean setSourcePort(PortNumber port) {
    if (!setupBehaviour()) {
        return false;
    }
    PiCriterion ingressCriterion = PiCriterion.builder().matchExact(FabricConstants.HDR_IG_PORT, port.toLong()).build();
    TrafficSelector srcSelector = DefaultTrafficSelector.builder().matchPi(ingressCriterion).build();
    PiAction setSourceAct = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_PROCESS_SET_SOURCE_SINK_INT_SET_SOURCE).build();
    TrafficTreatment srcTreatment = DefaultTrafficTreatment.builder().piTableAction(setSourceAct).build();
    FlowRule srcFlowRule = DefaultFlowRule.builder().withSelector(srcSelector).withTreatment(srcTreatment).fromApp(appId).withPriority(DEFAULT_PRIORITY).makePermanent().forDevice(deviceId).forTable(FabricConstants.FABRIC_INGRESS_PROCESS_SET_SOURCE_SINK_TB_SET_SOURCE).build();
    flowRuleService.applyFlowRules(srcFlowRule);
    return true;
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 9 with PiAction

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

the class NextObjectiveTranslator method multicastNext.

private void multicastNext(NextObjective obj, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
    // Create ALL group that will be translated to a PRE multicast entry.
    final int groupId = allGroup(obj, resultBuilder);
    if (isGroupModifyOp(obj)) {
        // No changes to flow rules.
        return;
    }
    final TrafficSelector selector = nextIdSelector(obj.id());
    final PiActionParam groupIdParam = new PiActionParam(FabricConstants.GROUP_ID, groupId);
    final PiAction setMcGroupAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_NEXT_SET_MCAST_GROUP_ID).withParameter(groupIdParam).build();
    final TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(setMcGroupAction).build();
    resultBuilder.addFlowRule(flowRule(obj, FabricConstants.FABRIC_INGRESS_NEXT_MULTICAST, selector, treatment));
}
Also used : 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 10 with PiAction

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

the class FabricInterpreterTest method testNextMplsTreatment.

/**
 * Map treatment to set_mpls action.
 */
@Test
public void testNextMplsTreatment() throws Exception {
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setMpls(MPLS_10).build();
    PiAction mappedAction = interpreter.mapTreatment(treatment, FabricConstants.FABRIC_INGRESS_PRE_NEXT_NEXT_MPLS);
    PiActionParam mplsParam = new PiActionParam(FabricConstants.LABEL, MPLS_10.toInt());
    PiAction expectedAction = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_PRE_NEXT_SET_MPLS_LABEL).withParameter(mplsParam).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)

Aggregations

PiAction (org.onosproject.net.pi.runtime.PiAction)57 PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)42 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)39 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)39 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)31 TrafficSelector (org.onosproject.net.flow.TrafficSelector)31 Test (org.junit.Test)25 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)19 FlowRule (org.onosproject.net.flow.FlowRule)19 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)17 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)10 GroupDescription (org.onosproject.net.group.GroupDescription)10 ImmutableList (com.google.common.collect.ImmutableList)6 List (java.util.List)6 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)6 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)6 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)5 NextObjective (org.onosproject.net.flowobjective.NextObjective)5 GroupBucket (org.onosproject.net.group.GroupBucket)5 PiActionProfileGroupId (org.onosproject.net.pi.runtime.PiActionProfileGroupId)5