Search in sources :

Example 6 with DefaultNextTreatment

use of org.onosproject.net.flowobjective.DefaultNextTreatment in project fabric-tna by stratum.

the class NextObjectiveTranslator method allGroup.

private int allGroup(NextObjective obj, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
    final Collection<DefaultNextTreatment> defaultNextTreatments = defaultNextTreatments(obj.nextTreatments(), true);
    // multicast entries is based solely on the output port.
    for (DefaultNextTreatment t : defaultNextTreatments) {
        handleEgress(obj, t.treatment(), resultBuilder, true);
    }
    // FIXME: this implementation supports only the case in which each
    // switch interface is associated with only one VLAN, otherwise we would
    // need to support replicating multiple times the same packet for the
    // same port while setting different VLAN IDs. Hence, collect in a set.
    final Set<PortNumber> outPorts = defaultNextTreatments.stream().map(DefaultNextTreatment::treatment).map(FabricUtils::outputPort).filter(Objects::nonNull).collect(Collectors.toSet());
    if (outPorts.size() != defaultNextTreatments.size()) {
        throw new FabricPipelinerException(format("Found BROADCAST NextObjective with %d treatments but " + "found only %d distinct OUTPUT port numbers, cannot " + "translate to ALL groups", defaultNextTreatments.size(), outPorts.size()), ObjectiveError.UNSUPPORTED);
    }
    final List<GroupBucket> bucketList = outPorts.stream().map(p -> DefaultTrafficTreatment.builder().setOutput(p).build()).map(DefaultGroupBucket::createAllGroupBucket).collect(Collectors.toList());
    final int groupId = obj.id();
    // Use DefaultGroupKey instead of PiGroupKey as we don't have any
    // action profile to apply to the groups of ALL type.
    final GroupKey groupKey = getGroupKey(obj);
    resultBuilder.addGroup(new DefaultGroupDescription(deviceId, GroupDescription.Type.ALL, new GroupBuckets(bucketList), groupKey, groupId, obj.appId()));
    return groupId;
}
Also used : DefaultNextTreatment(org.onosproject.net.flowobjective.DefaultNextTreatment) PiGroupKey(org.onosproject.net.pi.runtime.PiGroupKey) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) FabricUtils(org.stratumproject.fabric.tna.behaviour.FabricUtils) PortNumber(org.onosproject.net.PortNumber) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription)

Example 7 with DefaultNextTreatment

use of org.onosproject.net.flowobjective.DefaultNextTreatment in project fabric-tna by stratum.

the class NextObjectiveTranslator method indirectGroup.

private int indirectGroup(NextObjective obj, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
    if (isGroupModifyOp(obj)) {
        throw new FabricPipelinerException("Simple next objective does not support" + "*_TO_EXISTING operations");
    }
    final PiTableId hashedTableId = P4InfoConstants.FABRIC_INGRESS_NEXT_HASHED;
    final List<DefaultNextTreatment> defaultNextTreatments = defaultNextTreatments(obj.nextTreatments(), true);
    if (defaultNextTreatments.size() != 1) {
        throw new FabricPipelinerException("Simple next objective must have a single" + " treatment");
    }
    final TrafficTreatment piTreatment;
    final DefaultNextTreatment defaultNextTreatment = defaultNextTreatments.get(0);
    piTreatment = mapTreatmentToPiIfNeeded(defaultNextTreatment.treatment(), hashedTableId);
    handleEgress(obj, defaultNextTreatment.treatment(), resultBuilder, false);
    final GroupBucket groupBucket = DefaultGroupBucket.createIndirectGroupBucket(piTreatment);
    final int groupId = obj.id();
    final PiGroupKey groupKey = (PiGroupKey) getGroupKey(obj);
    resultBuilder.addGroup(new DefaultGroupDescription(deviceId, GroupDescription.Type.INDIRECT, new GroupBuckets(Collections.singletonList(groupBucket)), groupKey, groupId, obj.appId()));
    return groupId;
}
Also used : DefaultNextTreatment(org.onosproject.net.flowobjective.DefaultNextTreatment) PiGroupKey(org.onosproject.net.pi.runtime.PiGroupKey) PiTableId(org.onosproject.net.pi.model.PiTableId) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription)

Example 8 with DefaultNextTreatment

use of org.onosproject.net.flowobjective.DefaultNextTreatment in project fabric-tna by stratum.

the class NextObjectiveTranslator method defaultNextTreatments.

private List<DefaultNextTreatment> defaultNextTreatments(Collection<NextTreatment> nextTreatments, boolean strict) throws FabricPipelinerException {
    final List<DefaultNextTreatment> defaultNextTreatments = Lists.newArrayList();
    final List<NextTreatment> unsupportedNextTreatments = Lists.newArrayList();
    for (NextTreatment n : nextTreatments) {
        if (n.type() == NextTreatment.Type.TREATMENT) {
            defaultNextTreatments.add((DefaultNextTreatment) n);
        } else {
            unsupportedNextTreatments.add(n);
        }
    }
    if (strict && !unsupportedNextTreatments.isEmpty()) {
        throw new FabricPipelinerException(format("Unsupported NextTreatments: %s", unsupportedNextTreatments));
    }
    return defaultNextTreatments;
}
Also used : DefaultNextTreatment(org.onosproject.net.flowobjective.DefaultNextTreatment) NextTreatment(org.onosproject.net.flowobjective.NextTreatment) DefaultNextTreatment(org.onosproject.net.flowobjective.DefaultNextTreatment)

Example 9 with DefaultNextTreatment

use of org.onosproject.net.flowobjective.DefaultNextTreatment in project fabric-tna by stratum.

the class NextObjectiveTranslator method simpleNext.

private void simpleNext(NextObjective obj, ObjectiveTranslation.Builder resultBuilder, boolean forceSimple) throws FabricPipelinerException {
    if (capabilities.hasHashedTable()) {
        // Use hashed table when possible.
        hashedNext(obj, resultBuilder);
        return;
    }
    if (obj.nextTreatments().isEmpty()) {
        // Do nothing.
        return;
    } else if (!forceSimple && obj.nextTreatments().size() != 1) {
        throw new FabricPipelinerException(format("SIMPLE NextObjective should contain only 1 treatment, found %d", obj.nextTreatments().size()), ObjectiveError.BADPARAMS);
    }
    final TrafficSelector selector = nextIdSelector(obj.id());
    final List<DefaultNextTreatment> treatments = defaultNextTreatments(obj.nextTreatments(), true);
    if (forceSimple && treatments.size() > 1) {
        log.warn("Forcing SIMPLE behavior for NextObjective with {} treatments [{}]", treatments.size(), obj);
    }
    // handleEgress(obj, treatment, resultBuilder, false);
    throw new FabricPipelinerException("Simple next table not supported", ObjectiveError.UNSUPPORTED);
}
Also used : DefaultNextTreatment(org.onosproject.net.flowobjective.DefaultNextTreatment) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector)

Example 10 with DefaultNextTreatment

use of org.onosproject.net.flowobjective.DefaultNextTreatment 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)

Aggregations

DefaultNextTreatment (org.onosproject.net.flowobjective.DefaultNextTreatment)18 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)13 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)12 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)12 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)12 GroupBucket (org.onosproject.net.group.GroupBucket)12 GroupBuckets (org.onosproject.net.group.GroupBuckets)12 TrafficSelector (org.onosproject.net.flow.TrafficSelector)10 PiGroupKey (org.onosproject.net.pi.runtime.PiGroupKey)10 PortNumber (org.onosproject.net.PortNumber)9 NextTreatment (org.onosproject.net.flowobjective.NextTreatment)8 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)8 GroupKey (org.onosproject.net.group.GroupKey)8 PiTableId (org.onosproject.net.pi.model.PiTableId)8 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)7 Lists (com.google.common.collect.Lists)6 Collection (java.util.Collection)6 Collections (java.util.Collections)6 List (java.util.List)6 Objects (java.util.Objects)6