Search in sources :

Example 56 with GroupBucket

use of org.onosproject.net.group.GroupBucket in project fabric-tna by stratum.

the class NextObjectiveTranslatorTest method testMplsHashedOutput.

/**
 * Test program mpls ecmp output group for Hashed table.
 */
@Test
public void testMplsHashedOutput() throws Exception {
    TrafficTreatment treatment1 = DefaultTrafficTreatment.builder().setEthSrc(ROUTER_MAC).setEthDst(SPINE1_MAC).pushMpls().copyTtlOut().setMpls(MPLS_10).popVlan().setOutput(PORT_1).build();
    TrafficTreatment treatment2 = DefaultTrafficTreatment.builder().setEthSrc(ROUTER_MAC).setEthDst(SPINE2_MAC).pushMpls().copyTtlOut().setMpls(MPLS_10).popVlan().setOutput(PORT_2).build();
    NextObjective nextObjective = DefaultNextObjective.builder().withId(NEXT_ID_1).withPriority(PRIORITY).withMeta(VLAN_META).addTreatment(treatment1).addTreatment(treatment2).withType(NextObjective.Type.HASHED).makePermanent().fromApp(APP_ID).add();
    ObjectiveTranslation actualTranslation = translatorHashed.doTranslate(nextObjective);
    // Expected hashed table flow rule.
    PiCriterion nextIdCriterion = PiCriterion.builder().matchExact(P4InfoConstants.HDR_NEXT_ID, NEXT_ID_1).build();
    TrafficSelector nextIdSelector = DefaultTrafficSelector.builder().matchPi(nextIdCriterion).build();
    PiActionProfileGroupId actionGroupId = PiActionProfileGroupId.of(NEXT_ID_1);
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(actionGroupId).build();
    FlowRule expectedFlowRule = DefaultFlowRule.builder().forDevice(DEVICE_ID).fromApp(APP_ID).makePermanent().withPriority(0).forTable(P4InfoConstants.FABRIC_INGRESS_NEXT_HASHED).withSelector(nextIdSelector).withTreatment(treatment).build();
    // First egress rule - port1
    PortNumber outPort = outputPort(treatment1);
    PiCriterion egressVlanTableMatch = PiCriterion.builder().matchExact(P4InfoConstants.HDR_EG_PORT, outPort.toLong()).build();
    TrafficSelector selectorForEgressVlan = DefaultTrafficSelector.builder().matchPi(egressVlanTableMatch).matchVlanId(VLAN_100).build();
    PiAction piActionForEgressVlan = PiAction.builder().withId(P4InfoConstants.FABRIC_EGRESS_EGRESS_NEXT_POP_VLAN).build();
    TrafficTreatment treatmentForEgressVlan = DefaultTrafficTreatment.builder().piTableAction(piActionForEgressVlan).build();
    FlowRule expectedEgressVlanPopRule1 = DefaultFlowRule.builder().withSelector(selectorForEgressVlan).withTreatment(treatmentForEgressVlan).forTable(P4InfoConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN).makePermanent().withPriority(nextObjective.priority()).forDevice(DEVICE_ID).fromApp(APP_ID).build();
    // Second egress rule - port2
    outPort = outputPort(treatment2);
    egressVlanTableMatch = PiCriterion.builder().matchExact(P4InfoConstants.HDR_EG_PORT, outPort.toLong()).build();
    selectorForEgressVlan = DefaultTrafficSelector.builder().matchPi(egressVlanTableMatch).matchVlanId(VLAN_100).build();
    FlowRule expectedEgressVlanPopRule2 = DefaultFlowRule.builder().withSelector(selectorForEgressVlan).withTreatment(treatmentForEgressVlan).forTable(P4InfoConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN).makePermanent().withPriority(nextObjective.priority()).forDevice(DEVICE_ID).fromApp(APP_ID).build();
    // Expected group
    PiAction piAction1 = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_NEXT_ROUTING_HASHED).withParameter(new PiActionParam(P4InfoConstants.SMAC, ROUTER_MAC.toBytes())).withParameter(new PiActionParam(P4InfoConstants.DMAC, SPINE1_MAC.toBytes())).withParameter(new PiActionParam(P4InfoConstants.PORT_NUM, PORT_1.toLong())).build();
    PiAction piAction2 = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_NEXT_ROUTING_HASHED).withParameter(new PiActionParam(P4InfoConstants.SMAC, ROUTER_MAC.toBytes())).withParameter(new PiActionParam(P4InfoConstants.DMAC, SPINE2_MAC.toBytes())).withParameter(new PiActionParam(P4InfoConstants.PORT_NUM, PORT_2.toLong())).build();
    treatment1 = DefaultTrafficTreatment.builder().piTableAction(piAction1).build();
    treatment2 = DefaultTrafficTreatment.builder().piTableAction(piAction2).build();
    List<TrafficTreatment> treatments = ImmutableList.of(treatment1, treatment2);
    List<GroupBucket> buckets = treatments.stream().map(DefaultGroupBucket::createSelectGroupBucket).collect(Collectors.toList());
    GroupBuckets groupBuckets = new GroupBuckets(buckets);
    PiGroupKey groupKey = new PiGroupKey(P4InfoConstants.FABRIC_INGRESS_NEXT_HASHED, P4InfoConstants.FABRIC_INGRESS_NEXT_HASHED_PROFILE, NEXT_ID_1);
    GroupDescription expectedGroup = new DefaultGroupDescription(DEVICE_ID, GroupDescription.Type.SELECT, groupBuckets, groupKey, NEXT_ID_1, APP_ID);
    ObjectiveTranslation expectedTranslation = ObjectiveTranslation.builder().addFlowRule(expectedFlowRule).addFlowRule(vlanMetaFlowRule).addFlowRule(mplsFlowRule).addGroup(expectedGroup).addFlowRule(expectedEgressVlanPopRule1).addFlowRule(expectedEgressVlanPopRule2).build();
    assertEquals(expectedTranslation, actualTranslation);
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) PiActionProfileGroupId(org.onosproject.net.pi.runtime.PiActionProfileGroupId) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) PiAction(org.onosproject.net.pi.runtime.PiAction) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) PiGroupKey(org.onosproject.net.pi.runtime.PiGroupKey) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) PortNumber(org.onosproject.net.PortNumber) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) Test(org.junit.Test)

Example 57 with GroupBucket

use of org.onosproject.net.group.GroupBucket in project fabric-tna by stratum.

the class FabricPipeliner method handleVerify.

private ObjectiveError handleVerify(NextObjective nextObjective) {
    Map<GroupBucket, FlowRule> bucketsToFlows = getBucketToFlowMapping(nextObjective);
    if (bucketsToFlows.isEmpty() && !nextObjective.nextTreatments().isEmpty()) {
        log.warn("VERIFY failed due to translation error, bucketsToFlows is empty");
        return ObjectiveError.BADPARAMS;
    }
    if (log.isTraceEnabled()) {
        log.trace("Mapping bucketsToFlows {} has been generated ", bucketsToFlows);
    }
    GroupKey groupKey = nextTranslator.getGroupKey(nextObjective);
    if (groupKey == null) {
        log.warn("VERIFY failed due to translation error, unable to determine group key");
        return ObjectiveError.BADPARAMS;
    }
    Group groupFromStore = groupService.getGroup(deviceId, groupKey);
    if (groupFromStore == null) {
        log.warn("VERIFY failed due to missing group in the store");
        return ObjectiveError.GROUPMISSING;
    }
    // Looking for duplicate buckets - remove them by using a set and comparing size after/before
    Set<GroupBucket> bucketsFromStore = Sets.newHashSet(groupFromStore.buckets().buckets());
    if (groupFromStore.buckets().buckets().size() > bucketsFromStore.size()) {
        log.warn("Duplicated buckets detected in device:{}, nextId:{}, before-size" + ":{} after-size:{} .. correcting", deviceId, nextObjective.id(), groupFromStore.buckets().buckets().size(), bucketsFromStore.size());
        final GroupBuckets bucketToSet = new GroupBuckets(Lists.newArrayList(bucketsFromStore));
        groupService.setBucketsForGroup(deviceId, groupKey, bucketToSet, groupKey, nextObjective.appId());
        // Forge temporary the group to avoid race condition with the store
        groupFromStore = new DefaultGroup(groupFromStore.id(), deviceId, groupFromStore.type(), bucketToSet);
    }
    // Looking for buckets missing in the group but defined in the next
    Map<GroupBucket, FlowRule> toAdd = Maps.newHashMap();
    for (Map.Entry<GroupBucket, FlowRule> entry : bucketsToFlows.entrySet()) {
        if (!groupFromStore.buckets().buckets().contains(entry.getKey())) {
            toAdd.put(entry.getKey(), entry.getValue());
        }
    }
    // Looking for buckets missing in the next but defined in the group
    // FIXME SDFAB-250 we cannot remove associated egress flows
    List<GroupBucket> toRemove = Lists.newArrayList();
    groupFromStore.buckets().buckets().forEach(bucket -> {
        if (!bucketsToFlows.containsKey(bucket)) {
            toRemove.add(bucket);
        }
    });
    if (!toAdd.isEmpty() || !toRemove.isEmpty()) {
        log.warn("Mismatch detected in device:{}, nextId:{}, groupFromTranslation-size:{} " + "groupFromStore-size:{} toAdd-size:{} toRemove-size: {} .. correcting", deviceId, nextObjective.id(), bucketsToFlows.size(), groupFromStore.buckets().buckets().size(), toAdd.size(), toRemove.size());
    }
    if (!toAdd.isEmpty()) {
        if (log.isTraceEnabled()) {
            log.trace("Adding missing buckets {} and flows {}", toAdd.keySet(), toAdd.values());
        }
        final FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
        final FlowRule dummyFlow = getDummyFlow(nextObjective);
        toAdd.values().stream().filter(flowRule -> !flowRule.equals(dummyFlow)).forEach(ops::add);
        final GroupBuckets bucketsToAdd = new GroupBuckets(Lists.newArrayList(toAdd.keySet()));
        groupService.addBucketsToGroup(deviceId, groupKey, bucketsToAdd, groupKey, nextObjective.appId());
        flowRuleService.apply(ops.build());
    }
    if (!toRemove.isEmpty()) {
        if (log.isTraceEnabled()) {
            log.trace("Removing stale buckets {}", toRemove);
        }
        final GroupBuckets bucketsToRemove = new GroupBuckets(toRemove);
        groupService.removeBucketsFromGroup(deviceId, groupKey, bucketsToRemove, groupKey, nextObjective.appId());
    }
    return null;
}
Also used : DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) CoreService(org.onosproject.core.CoreService) PortNumber(org.onosproject.net.PortNumber) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError) Ethernet(org.onlab.packet.Ethernet) FabricUtils.outputPort(org.stratumproject.fabric.tna.behaviour.FabricUtils.outputPort) FlowRuleService(org.onosproject.net.flow.FlowRuleService) SharedExecutors(org.onlab.util.SharedExecutors) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) NextObjective(org.onosproject.net.flowobjective.NextObjective) RECIRC_PORTS(org.stratumproject.fabric.tna.Constants.RECIRC_PORTS) V1MODEL_RECIRC_PORT(org.stratumproject.fabric.tna.Constants.V1MODEL_RECIRC_PORT) PipelinerContext(org.onosproject.net.behaviour.PipelinerContext) FabricCapabilities(org.stratumproject.fabric.tna.behaviour.FabricCapabilities) PKT_IN_MIRROR_SESSION_ID(org.stratumproject.fabric.tna.Constants.PKT_IN_MIRROR_SESSION_ID) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) Collection(java.util.Collection) Set(java.util.Set) FlowObjectiveStore(org.onosproject.net.flowobjective.FlowObjectiveStore) Constants(org.stratumproject.fabric.tna.Constants) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) String.format(java.lang.String.format) DEFAULT_VLAN(org.stratumproject.fabric.tna.Constants.DEFAULT_VLAN) PORT_TYPE_INTERNAL(org.stratumproject.fabric.tna.Constants.PORT_TYPE_INTERNAL) Objects(java.util.Objects) List(java.util.List) FlowRule(org.onosproject.net.flow.FlowRule) GroupBuckets(org.onosproject.net.group.GroupBuckets) DeviceId(org.onosproject.net.DeviceId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) FWD_IPV4_ROUTING(org.stratumproject.fabric.tna.Constants.FWD_IPV4_ROUTING) Pipeliner(org.onosproject.net.behaviour.Pipeliner) NextTreatment(org.onosproject.net.flowobjective.NextTreatment) ZERO(org.stratumproject.fabric.tna.Constants.ZERO) CompletableFuture(java.util.concurrent.CompletableFuture) DefaultGroup(org.onosproject.net.group.DefaultGroup) GroupBucket(org.onosproject.net.group.GroupBucket) NextGroup(org.onosproject.net.behaviour.NextGroup) GroupKey(org.onosproject.net.group.GroupKey) P4InfoConstants(org.stratumproject.fabric.tna.behaviour.P4InfoConstants) Group(org.onosproject.net.group.Group) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultGroupBucket.createCloneGroupBucket(org.onosproject.net.group.DefaultGroupBucket.createCloneGroupBucket) ImmutableList(com.google.common.collect.ImmutableList) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) FWD_MPLS(org.stratumproject.fabric.tna.Constants.FWD_MPLS) Criteria(org.onosproject.net.flow.criteria.Criteria) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ExecutorService(java.util.concurrent.ExecutorService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FlowRuleOperations(org.onosproject.net.flow.FlowRuleOperations) Logger(org.slf4j.Logger) GroupService(org.onosproject.net.group.GroupService) AbstractFabricHandlerBehavior(org.stratumproject.fabric.tna.behaviour.AbstractFabricHandlerBehavior) Maps(com.google.common.collect.Maps) IdNextTreatment(org.onosproject.net.flowobjective.IdNextTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction) KRYO(org.stratumproject.fabric.tna.behaviour.FabricUtils.KRYO) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Objective(org.onosproject.net.flowobjective.Objective) Collections(java.util.Collections) ONE(org.stratumproject.fabric.tna.Constants.ONE) DefaultGroup(org.onosproject.net.group.DefaultGroup) NextGroup(org.onosproject.net.behaviour.NextGroup) Group(org.onosproject.net.group.Group) FlowRuleOperations(org.onosproject.net.flow.FlowRuleOperations) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultGroup(org.onosproject.net.group.DefaultGroup) GroupBuckets(org.onosproject.net.group.GroupBuckets) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket.createCloneGroupBucket(org.onosproject.net.group.DefaultGroupBucket.createCloneGroupBucket) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) Map(java.util.Map)

Example 58 with GroupBucket

use of org.onosproject.net.group.GroupBucket in project fabric-tna by stratum.

the class FabricPipeliner method getBucketToFlowMapping.

private Map<GroupBucket, FlowRule> getBucketToFlowMapping(NextObjective nextObjective) {
    Map<GroupBucket, FlowRule> mapping = Maps.newHashMap();
    NextObjective newNextObjective;
    ObjectiveTranslation result;
    FlowRule dummyFlow = getDummyFlow(nextObjective);
    FlowRule egFlow;
    GroupBucket groupBucket;
    GroupDescription group;
    for (NextTreatment nextTreatment : nextObjective.nextTreatments()) {
        newNextObjective = DefaultNextObjective.builder().withId(nextObjective.id()).withType(nextObjective.type()).fromApp(nextObjective.appId()).withMeta(nextObjective.meta()).addTreatment(nextTreatment).verify();
        result = nextTranslator.translate(newNextObjective);
        if ((result.groups().isEmpty() && result.flowRules().isEmpty()) || result.groups().size() > 1) {
            return Collections.emptyMap();
        }
        group = result.groups().iterator().next();
        egFlow = result.flowRules().stream().filter(flowRule -> flowRule.table().equals(P4InfoConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN)).findFirst().orElse(null);
        if (group.buckets().buckets().isEmpty() || group.buckets().buckets().size() > 1) {
            return Collections.emptyMap();
        }
        groupBucket = group.buckets().buckets().iterator().next();
        if (egFlow == null) {
            mapping.put(groupBucket, dummyFlow);
        } else {
            mapping.put(groupBucket, egFlow);
        }
    }
    return mapping;
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) CoreService(org.onosproject.core.CoreService) PortNumber(org.onosproject.net.PortNumber) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError) Ethernet(org.onlab.packet.Ethernet) FabricUtils.outputPort(org.stratumproject.fabric.tna.behaviour.FabricUtils.outputPort) FlowRuleService(org.onosproject.net.flow.FlowRuleService) SharedExecutors(org.onlab.util.SharedExecutors) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) NextObjective(org.onosproject.net.flowobjective.NextObjective) RECIRC_PORTS(org.stratumproject.fabric.tna.Constants.RECIRC_PORTS) V1MODEL_RECIRC_PORT(org.stratumproject.fabric.tna.Constants.V1MODEL_RECIRC_PORT) PipelinerContext(org.onosproject.net.behaviour.PipelinerContext) FabricCapabilities(org.stratumproject.fabric.tna.behaviour.FabricCapabilities) PKT_IN_MIRROR_SESSION_ID(org.stratumproject.fabric.tna.Constants.PKT_IN_MIRROR_SESSION_ID) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) Collection(java.util.Collection) Set(java.util.Set) FlowObjectiveStore(org.onosproject.net.flowobjective.FlowObjectiveStore) Constants(org.stratumproject.fabric.tna.Constants) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) String.format(java.lang.String.format) DEFAULT_VLAN(org.stratumproject.fabric.tna.Constants.DEFAULT_VLAN) PORT_TYPE_INTERNAL(org.stratumproject.fabric.tna.Constants.PORT_TYPE_INTERNAL) Objects(java.util.Objects) List(java.util.List) FlowRule(org.onosproject.net.flow.FlowRule) GroupBuckets(org.onosproject.net.group.GroupBuckets) DeviceId(org.onosproject.net.DeviceId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) FWD_IPV4_ROUTING(org.stratumproject.fabric.tna.Constants.FWD_IPV4_ROUTING) Pipeliner(org.onosproject.net.behaviour.Pipeliner) NextTreatment(org.onosproject.net.flowobjective.NextTreatment) ZERO(org.stratumproject.fabric.tna.Constants.ZERO) CompletableFuture(java.util.concurrent.CompletableFuture) DefaultGroup(org.onosproject.net.group.DefaultGroup) GroupBucket(org.onosproject.net.group.GroupBucket) NextGroup(org.onosproject.net.behaviour.NextGroup) GroupKey(org.onosproject.net.group.GroupKey) P4InfoConstants(org.stratumproject.fabric.tna.behaviour.P4InfoConstants) Group(org.onosproject.net.group.Group) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultGroupBucket.createCloneGroupBucket(org.onosproject.net.group.DefaultGroupBucket.createCloneGroupBucket) ImmutableList(com.google.common.collect.ImmutableList) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) FWD_MPLS(org.stratumproject.fabric.tna.Constants.FWD_MPLS) Criteria(org.onosproject.net.flow.criteria.Criteria) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ExecutorService(java.util.concurrent.ExecutorService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FlowRuleOperations(org.onosproject.net.flow.FlowRuleOperations) Logger(org.slf4j.Logger) GroupService(org.onosproject.net.group.GroupService) AbstractFabricHandlerBehavior(org.stratumproject.fabric.tna.behaviour.AbstractFabricHandlerBehavior) Maps(com.google.common.collect.Maps) IdNextTreatment(org.onosproject.net.flowobjective.IdNextTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction) KRYO(org.stratumproject.fabric.tna.behaviour.FabricUtils.KRYO) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Objective(org.onosproject.net.flowobjective.Objective) Collections(java.util.Collections) ONE(org.stratumproject.fabric.tna.Constants.ONE) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket.createCloneGroupBucket(org.onosproject.net.group.DefaultGroupBucket.createCloneGroupBucket) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) NextTreatment(org.onosproject.net.flowobjective.NextTreatment) IdNextTreatment(org.onosproject.net.flowobjective.IdNextTreatment)

Example 59 with GroupBucket

use of org.onosproject.net.group.GroupBucket 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 60 with GroupBucket

use of org.onosproject.net.group.GroupBucket 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)

Aggregations

GroupBucket (org.onosproject.net.group.GroupBucket)108 GroupBuckets (org.onosproject.net.group.GroupBuckets)87 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)75 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)66 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)66 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)62 GroupKey (org.onosproject.net.group.GroupKey)62 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)56 GroupDescription (org.onosproject.net.group.GroupDescription)55 ArrayList (java.util.ArrayList)42 Group (org.onosproject.net.group.Group)40 GroupId (org.onosproject.core.GroupId)35 PortNumber (org.onosproject.net.PortNumber)32 DefaultGroup (org.onosproject.net.group.DefaultGroup)26 List (java.util.List)21 DeviceId (org.onosproject.net.DeviceId)20 TrafficSelector (org.onosproject.net.flow.TrafficSelector)20 OfdpaGroupHandlerUtility.l2MulticastGroupKey (org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.l2MulticastGroupKey)17 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)16 ArrayDeque (java.util.ArrayDeque)15