use of org.onosproject.net.group.GroupBuckets in project TFG by mattinelorza.
the class Utils method buildSelectGroup.
public static GroupDescription buildSelectGroup(DeviceId deviceId, String tableId, String actionProfileId, int groupId, Collection<PiAction> actions, ApplicationId appId) {
final GroupKey groupKey = new PiGroupKey(PiTableId.of(tableId), PiActionProfileId.of(actionProfileId), groupId);
final List<GroupBucket> buckets = actions.stream().map(action -> DefaultTrafficTreatment.builder().piTableAction(action).build()).map(DefaultGroupBucket::createSelectGroupBucket).collect(Collectors.toList());
return new DefaultGroupDescription(deviceId, GroupDescription.Type.SELECT, new GroupBuckets(buckets), groupKey, groupId, appId);
}
use of org.onosproject.net.group.GroupBuckets in project fabric-tna by stratum.
the class NextObjectiveTranslatorTest method testHashedOutput.
/**
* Test program ecmp output group for Hashed table.
*/
@Test
public void testHashedOutput() throws Exception {
PiAction piAction1 = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_NEXT_ROUTING_HASHED).withParameter(new PiActionParam(P4InfoConstants.SMAC, ROUTER_MAC.toBytes())).withParameter(new PiActionParam(P4InfoConstants.DMAC, HOST_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, HOST_MAC.toBytes())).withParameter(new PiActionParam(P4InfoConstants.PORT_NUM, PORT_1.toLong())).build();
TrafficTreatment treatment1 = DefaultTrafficTreatment.builder().piTableAction(piAction1).build();
TrafficTreatment treatment2 = DefaultTrafficTreatment.builder().piTableAction(piAction2).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();
// Expected group
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).addGroup(expectedGroup).build();
assertEquals(expectedTranslation, actualTranslation);
}
use of org.onosproject.net.group.GroupBuckets in project fabric-tna by stratum.
the class FabricIntProgrammableTest method testInit.
private void testInit() {
final List<GroupDescription> expectedGroups = Lists.newArrayList();
final Capture<GroupDescription> capturedGroup = newCapture(CaptureType.ALL);
final Map<Integer, Long> recircPorts = intProgrammable.capabilities.isArchV1model() ? V1MODEL_MIRROR_SESS_TO_RECIRC_PORTS : QUAD_PIPE_MIRROR_SESS_TO_RECIRC_PORTS;
recircPorts.forEach((sessionId, port) -> {
// Set up mirror sessions
final List<GroupBucket> buckets = ImmutableList.of(getCloneBucket(port));
expectedGroups.add(new DefaultGroupDescription(LEAF_DEVICE_ID, GroupDescription.Type.CLONE, new GroupBuckets(buckets), new DefaultGroupKey(KRYO.serialize(sessionId)), sessionId, APP_ID));
groupService.addGroup(capture(capturedGroup));
});
replay(groupService, flowRuleService);
assertTrue(intProgrammable.init());
for (int i = 0; i < recircPorts.size(); i++) {
GroupDescription expectGroup = expectedGroups.get(i);
GroupDescription actualGroup = capturedGroup.getValues().get(i);
assertEquals(expectGroup, actualGroup);
}
verify(groupService, flowRuleService);
reset(groupService, flowRuleService);
}
use of org.onosproject.net.group.GroupBuckets in project fabric-tna by stratum.
the class FabricIntProgrammable method init.
@Override
public boolean init() {
if (!setupBehaviour()) {
return false;
}
Map<Integer, Long> sessionToPortMap = null;
if (capabilities.isArchTna()) {
final int hwPipeCount = capabilities.hwPipeCount();
switch(hwPipeCount) {
case 4:
sessionToPortMap = QUAD_PIPE_MIRROR_SESS_TO_RECIRC_PORTS;
break;
case 2:
sessionToPortMap = DUAL_PIPE_MIRROR_SESS_TO_RECIRC_PORTS;
break;
default:
log.error("{} it not a valid HW pipe count", hwPipeCount);
return false;
}
} else if (capabilities.isArchV1model()) {
sessionToPortMap = V1MODEL_MIRROR_SESS_TO_RECIRC_PORT;
}
// Mirroring sessions for report cloning.
sessionToPortMap.forEach((sessionId, port) -> {
// Set up mirror sessions
TrafficTreatment.Builder trafficTreatment = DefaultTrafficTreatment.builder().setOutput(PortNumber.portNumber(port));
if (capabilities.isArchTna()) {
trafficTreatment.truncate(INT_MIRROR_TRUNCATE_MAX_LEN);
}
final List<GroupBucket> buckets = ImmutableList.of(createCloneGroupBucket(trafficTreatment.build()));
groupService.addGroup(new DefaultGroupDescription(deviceId, GroupDescription.Type.CLONE, new GroupBuckets(buckets), new DefaultGroupKey(KRYO.serialize(sessionId)), sessionId, appId));
});
return true;
}
use of org.onosproject.net.group.GroupBuckets in project fabric-tna by stratum.
the class NextObjectiveTranslator method selectGroup.
private int selectGroup(NextObjective obj, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
final PiTableId hashedTableId = P4InfoConstants.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;
}
Aggregations