Search in sources :

Example 41 with GroupBuckets

use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.

the class OpenFlowGroupProvider method buildGroupMetrics.

private Collection<Group> buildGroupMetrics(DeviceId deviceId, OFGroupStatsReply groupStatsReply, OFGroupDescStatsReply groupDescStatsReply) {
    Map<Integer, Group> groups = Maps.newHashMap();
    Dpid dpid = Dpid.dpid(deviceId.uri());
    for (OFGroupDescStatsEntry entry : groupDescStatsReply.getEntries()) {
        int id = entry.getGroup().getGroupNumber();
        GroupId groupId = new GroupId(id);
        GroupDescription.Type type = getGroupType(entry.getGroupType());
        GroupBuckets buckets = new GroupBucketEntryBuilder(dpid, entry.getBuckets(), entry.getGroupType(), driverService).build();
        DefaultGroup group = new DefaultGroup(groupId, deviceId, type, buckets);
        groups.put(id, group);
    }
    if (groupStatsReply == null) {
        return groups.values();
    }
    for (OFGroupStatsEntry entry : groupStatsReply.getEntries()) {
        int groupId = entry.getGroup().getGroupNumber();
        DefaultGroup group = (DefaultGroup) groups.get(groupId);
        if (group != null) {
            group.setBytes(entry.getByteCount().getValue());
            group.setLife(entry.getDurationSec());
            group.setPackets(entry.getPacketCount().getValue());
            group.setReferenceCount(entry.getRefCount());
            int bucketIndex = 0;
            for (OFBucketCounter bucketStats : entry.getBucketStats()) {
                ((StoredGroupBucketEntry) group.buckets().buckets().get(bucketIndex)).setPackets(bucketStats.getPacketCount().getValue());
                ((StoredGroupBucketEntry) group.buckets().buckets().get(bucketIndex)).setBytes(entry.getBucketStats().get(bucketIndex).getByteCount().getValue());
                bucketIndex++;
            }
        }
    }
    return groups.values();
}
Also used : DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) OFGroupDescStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry) Dpid(org.onosproject.openflow.controller.Dpid) DefaultGroup(org.onosproject.net.group.DefaultGroup) GroupBuckets(org.onosproject.net.group.GroupBuckets) GroupId(org.onosproject.core.GroupId) GroupDescription(org.onosproject.net.group.GroupDescription) OFGroupStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupStatsEntry) OFBucketCounter(org.projectfloodlight.openflow.protocol.OFBucketCounter) StoredGroupBucketEntry(org.onosproject.net.group.StoredGroupBucketEntry)

Example 42 with GroupBuckets

use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.

the class OpenFlowGroupProviderTest method addGroup.

@Test
public void addGroup() {
    GroupId groupId = new GroupId(1);
    List<GroupBucket> bucketList = Lists.newArrayList();
    TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
    builder.setOutput(PortNumber.portNumber(1));
    GroupBucket bucket = DefaultGroupBucket.createSelectGroupBucket(builder.build());
    bucketList.add(bucket);
    GroupBuckets buckets = new GroupBuckets(bucketList);
    List<GroupOperation> operationList = Lists.newArrayList();
    GroupOperation operation = GroupOperation.createAddGroupOperation(groupId, GroupDescription.Type.SELECT, buckets);
    operationList.add(operation);
    GroupOperations operations = new GroupOperations(operationList);
    provider.performGroupOperation(deviceId, operations);
    final Dpid dpid = Dpid.dpid(deviceId.uri());
    TestOpenFlowSwitch sw = (TestOpenFlowSwitch) controller.getSwitch(dpid);
    assertNotNull("Switch should not be nul", sw);
    assertNotNull("OFGroupMsg should not be null", sw.msg);
}
Also used : GroupOperations(org.onosproject.net.group.GroupOperations) Dpid(org.onosproject.openflow.controller.Dpid) 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) GroupOperation(org.onosproject.net.group.GroupOperation) GroupId(org.onosproject.core.GroupId) Test(org.junit.Test)

Example 43 with GroupBuckets

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

use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.

the class NextObjectiveTranslator method selectGroup.

private int selectGroup(NextObjective obj, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
    final PiTableId hashedTableId = FabricConstants.FABRIC_INGRESS_NEXT_HASHED;
    final List<DefaultNextTreatment> defaultNextTreatments = defaultNextTreatments(obj.nextTreatments(), true);
    final List<TrafficTreatment> piTreatments = Lists.newArrayList();
    for (DefaultNextTreatment t : defaultNextTreatments) {
        // Map treatment to PI...
        piTreatments.add(mapTreatmentToPiIfNeeded(t.treatment(), hashedTableId));
        // ...and handle egress if necessary.
        handleEgress(obj, t.treatment(), resultBuilder, false);
    }
    final List<GroupBucket> bucketList = piTreatments.stream().map(DefaultGroupBucket::createSelectGroupBucket).collect(Collectors.toList());
    final int groupId = obj.id();
    final PiGroupKey groupKey = (PiGroupKey) getGroupKey(obj);
    resultBuilder.addGroup(new DefaultGroupDescription(deviceId, GroupDescription.Type.SELECT, new GroupBuckets(bucketList), 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 45 with GroupBuckets

use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.

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 = FabricConstants.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)

Aggregations

GroupBuckets (org.onosproject.net.group.GroupBuckets)90 GroupBucket (org.onosproject.net.group.GroupBucket)82 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)69 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)63 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)58 GroupKey (org.onosproject.net.group.GroupKey)58 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)57 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)56 GroupDescription (org.onosproject.net.group.GroupDescription)53 Group (org.onosproject.net.group.Group)35 ArrayList (java.util.ArrayList)31 GroupId (org.onosproject.core.GroupId)28 PortNumber (org.onosproject.net.PortNumber)27 DefaultGroup (org.onosproject.net.group.DefaultGroup)22 OfdpaGroupHandlerUtility.l2MulticastGroupKey (org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.l2MulticastGroupKey)17 ArrayDeque (java.util.ArrayDeque)15 Deque (java.util.Deque)15 TrafficSelector (org.onosproject.net.flow.TrafficSelector)15 PiGroupKey (org.onosproject.net.pi.runtime.PiGroupKey)14 NextObjective (org.onosproject.net.flowobjective.NextObjective)13