Search in sources :

Example 1 with MPLS_LABEL

use of org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.MPLS_LABEL in project fabric-tna by stratum.

the class NextObjectiveTranslator method nextMpls.

private void nextMpls(NextObjective obj, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
    // Next objective can contain only one mpls push and one mpls label
    // instruction. Pipeliner does not support other configurations.
    final List<List<ModMplsLabelInstruction>> mplsInstructions = defaultNextTreatments(obj.nextTreatments(), false).stream().map(defaultNextTreatment -> l2Instructions(defaultNextTreatment.treatment(), MPLS_LABEL).stream().map(v -> (ModMplsLabelInstruction) v).collect(Collectors.toList())).filter(l -> !l.isEmpty()).collect(Collectors.toList());
    if (mplsInstructions.isEmpty()) {
        // No need to apply next mpls table
        return;
    }
    // We expect one mpls label for each treatment and the label has to be the same
    final Set<MplsLabel> mplsLabels = mplsInstructions.stream().flatMap(Collection::stream).map(ModMplsLabelInstruction::label).collect(Collectors.toSet());
    if (obj.nextTreatments().size() != mplsInstructions.size() || mplsLabels.size() != 1) {
        throw new FabricPipelinerException("Inconsistent MPLS_LABEL instructions, cannot process " + "next_mpls rule. It is required that all " + "treatments have the same MPLS_LABEL instructions.");
    }
    final TrafficSelector selector = nextIdSelector(obj.id());
    final TrafficTreatment treatment = DefaultTrafficTreatment.builder().setMpls(mplsLabels.iterator().next()).build();
    resultBuilder.addFlowRule(flowRule(obj, P4InfoConstants.FABRIC_INGRESS_PRE_NEXT_NEXT_MPLS, selector, treatment));
}
Also used : PiTableId(org.onosproject.net.pi.model.PiTableId) FabricUtils.criterion(org.stratumproject.fabric.tna.behaviour.FabricUtils.criterion) FabricUtils.l2Instruction(org.stratumproject.fabric.tna.behaviour.FabricUtils.l2Instruction) PortNumber(org.onosproject.net.PortNumber) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError) FabricUtils.outputPort(org.stratumproject.fabric.tna.behaviour.FabricUtils.outputPort) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) NextObjective(org.onosproject.net.flowobjective.NextObjective) MPLS_LABEL(org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.MPLS_LABEL) FabricCapabilities(org.stratumproject.fabric.tna.behaviour.FabricCapabilities) FabricUtils(org.stratumproject.fabric.tna.behaviour.FabricUtils) Collection(java.util.Collection) Set(java.util.Set) ModVlanIdInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction) PiGroupKey(org.onosproject.net.pi.runtime.PiGroupKey) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Objects(java.util.Objects) List(java.util.List) GroupBuckets(org.onosproject.net.group.GroupBuckets) DeviceId(org.onosproject.net.DeviceId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) PiActionProfileGroupId(org.onosproject.net.pi.runtime.PiActionProfileGroupId) FabricUtils.l2Instructions(org.stratumproject.fabric.tna.behaviour.FabricUtils.l2Instructions) VLAN_POP(org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.VLAN_POP) ModMplsLabelInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction) NextTreatment(org.onosproject.net.flowobjective.NextTreatment) DefaultNextTreatment(org.onosproject.net.flowobjective.DefaultNextTreatment) GroupBucket(org.onosproject.net.group.GroupBucket) GroupKey(org.onosproject.net.group.GroupKey) P4InfoConstants(org.stratumproject.fabric.tna.behaviour.P4InfoConstants) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) VLAN_ID(org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.VLAN_ID) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Criterion(org.onosproject.net.flow.criteria.Criterion) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) MplsLabel(org.onlab.packet.MplsLabel) Instruction(org.onosproject.net.flow.instructions.Instruction) VlanId(org.onlab.packet.VlanId) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) PiAction(org.onosproject.net.pi.runtime.PiAction) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) KRYO(org.stratumproject.fabric.tna.behaviour.FabricUtils.KRYO) Objective(org.onosproject.net.flowobjective.Objective) Collections(java.util.Collections) MplsLabel(org.onlab.packet.MplsLabel) Collection(java.util.Collection) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) List(java.util.List) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 2 with MPLS_LABEL

use of org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.MPLS_LABEL in project onos by opennetworkinglab.

the class NextObjectiveTranslator method nextMpls.

private void nextMpls(NextObjective obj, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
    // Next objective can contain only one mpls push and one mpls label
    // instruction. Pipeliner does not support other configurations.
    final List<List<ModMplsLabelInstruction>> mplsInstructions = defaultNextTreatments(obj.nextTreatments(), false).stream().map(defaultNextTreatment -> l2Instructions(defaultNextTreatment.treatment(), MPLS_LABEL).stream().map(v -> (ModMplsLabelInstruction) v).collect(Collectors.toList())).filter(l -> !l.isEmpty()).collect(Collectors.toList());
    if (mplsInstructions.isEmpty()) {
        // No need to apply next mpls table
        return;
    }
    // We expect one mpls label for each treatment and the label has to be the same
    final Set<MplsLabel> mplsLabels = mplsInstructions.stream().flatMap(Collection::stream).map(ModMplsLabelInstruction::label).collect(Collectors.toSet());
    if (obj.nextTreatments().size() != mplsInstructions.size() || mplsLabels.size() != 1) {
        throw new FabricPipelinerException("Inconsistent MPLS_LABEL instructions, cannot process " + "next_mpls rule. It is required that all " + "treatments have the same MPLS_LABEL instructions.");
    }
    final TrafficSelector selector = nextIdSelector(obj.id());
    final TrafficTreatment treatment = DefaultTrafficTreatment.builder().setMpls(mplsLabels.iterator().next()).build();
    resultBuilder.addFlowRule(flowRule(obj, FabricConstants.FABRIC_INGRESS_PRE_NEXT_NEXT_MPLS, selector, treatment));
}
Also used : PiTableId(org.onosproject.net.pi.model.PiTableId) PortNumber(org.onosproject.net.PortNumber) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError) FabricUtils.l2Instructions(org.onosproject.pipelines.fabric.impl.behaviour.FabricUtils.l2Instructions) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) NextObjective(org.onosproject.net.flowobjective.NextObjective) FabricUtils.l2Instruction(org.onosproject.pipelines.fabric.impl.behaviour.FabricUtils.l2Instruction) MPLS_LABEL(org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.MPLS_LABEL) Collection(java.util.Collection) Set(java.util.Set) ModVlanIdInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction) PiGroupKey(org.onosproject.net.pi.runtime.PiGroupKey) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Objects(java.util.Objects) List(java.util.List) FabricUtils.outputPort(org.onosproject.pipelines.fabric.impl.behaviour.FabricUtils.outputPort) GroupBuckets(org.onosproject.net.group.GroupBuckets) DeviceId(org.onosproject.net.DeviceId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) PiActionProfileGroupId(org.onosproject.net.pi.runtime.PiActionProfileGroupId) VLAN_POP(org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.VLAN_POP) ModMplsLabelInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction) NextTreatment(org.onosproject.net.flowobjective.NextTreatment) DefaultNextTreatment(org.onosproject.net.flowobjective.DefaultNextTreatment) GroupBucket(org.onosproject.net.group.GroupBucket) GroupKey(org.onosproject.net.group.GroupKey) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) VLAN_ID(org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.VLAN_ID) FabricUtils(org.onosproject.pipelines.fabric.impl.behaviour.FabricUtils) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Criterion(org.onosproject.net.flow.criteria.Criterion) FabricCapabilities(org.onosproject.pipelines.fabric.impl.behaviour.FabricCapabilities) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) MplsLabel(org.onlab.packet.MplsLabel) Instruction(org.onosproject.net.flow.instructions.Instruction) FabricUtils.criterion(org.onosproject.pipelines.fabric.impl.behaviour.FabricUtils.criterion) VlanId(org.onlab.packet.VlanId) FabricConstants(org.onosproject.pipelines.fabric.FabricConstants) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) PiAction(org.onosproject.net.pi.runtime.PiAction) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) Objective(org.onosproject.net.flowobjective.Objective) Collections(java.util.Collections) MplsLabel(org.onlab.packet.MplsLabel) Collection(java.util.Collection) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) List(java.util.List) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Aggregations

Lists (com.google.common.collect.Lists)2 String.format (java.lang.String.format)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 List (java.util.List)2 Objects (java.util.Objects)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 MplsLabel (org.onlab.packet.MplsLabel)2 VlanId (org.onlab.packet.VlanId)2 DeviceId (org.onosproject.net.DeviceId)2 PortNumber (org.onosproject.net.PortNumber)2 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)2 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)2 TrafficSelector (org.onosproject.net.flow.TrafficSelector)2 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)2 Criterion (org.onosproject.net.flow.criteria.Criterion)2 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)2 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)2 Instruction (org.onosproject.net.flow.instructions.Instruction)2