Search in sources :

Example 1 with FabricUtils

use of org.onosproject.pipelines.fabric.impl.behaviour.FabricUtils in project onos by opennetworkinglab.

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.onosproject.pipelines.fabric.impl.behaviour.FabricUtils) PortNumber(org.onosproject.net.PortNumber) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription)

Example 2 with FabricUtils

use of org.onosproject.pipelines.fabric.impl.behaviour.FabricUtils in project onos by opennetworkinglab.

the class NextObjectiveTranslator method xconnectNext.

private void xconnectNext(NextObjective obj, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
    final Collection<DefaultNextTreatment> defaultNextTreatments = defaultNextTreatments(obj.nextTreatments(), true);
    final List<PortNumber> outPorts = defaultNextTreatments.stream().map(DefaultNextTreatment::treatment).map(FabricUtils::outputPort).filter(Objects::nonNull).collect(Collectors.toList());
    if (outPorts.size() != 2) {
        throw new FabricPipelinerException(format("Handling XCONNECT with %d treatments (ports), but expected is 2", defaultNextTreatments.size()), ObjectiveError.UNSUPPORTED);
    }
    final PortNumber port1 = outPorts.get(0);
    final PortNumber port2 = outPorts.get(1);
    final TrafficSelector selector1 = nextIdSelectorBuilder(obj.id()).matchInPort(port1).build();
    final TrafficTreatment treatment1 = DefaultTrafficTreatment.builder().setOutput(port2).build();
    final TrafficSelector selector2 = nextIdSelectorBuilder(obj.id()).matchInPort(port2).build();
    final TrafficTreatment treatment2 = DefaultTrafficTreatment.builder().setOutput(port1).build();
    resultBuilder.addFlowRule(flowRule(obj, FabricConstants.FABRIC_INGRESS_NEXT_XCONNECT, selector1, treatment1));
    resultBuilder.addFlowRule(flowRule(obj, FabricConstants.FABRIC_INGRESS_NEXT_XCONNECT, selector2, treatment2));
}
Also used : DefaultNextTreatment(org.onosproject.net.flowobjective.DefaultNextTreatment) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) FabricUtils(org.onosproject.pipelines.fabric.impl.behaviour.FabricUtils) PortNumber(org.onosproject.net.PortNumber) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Aggregations

PortNumber (org.onosproject.net.PortNumber)2 DefaultNextTreatment (org.onosproject.net.flowobjective.DefaultNextTreatment)2 FabricUtils (org.onosproject.pipelines.fabric.impl.behaviour.FabricUtils)2 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)1 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)1 TrafficSelector (org.onosproject.net.flow.TrafficSelector)1 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)1 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)1 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)1 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)1 GroupBucket (org.onosproject.net.group.GroupBucket)1 GroupBuckets (org.onosproject.net.group.GroupBuckets)1 GroupKey (org.onosproject.net.group.GroupKey)1 PiGroupKey (org.onosproject.net.pi.runtime.PiGroupKey)1