use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class FabricUpfTranslator method upfApplicationToFabricEntry.
public FlowRule upfApplicationToFabricEntry(UpfApplication appFilter, DeviceId deviceId, ApplicationId appId) throws UpfProgrammableException {
PiCriterion match = buildApplicationCriterion(appFilter);
PiAction action = PiAction.builder().withId(FABRIC_INGRESS_UPF_SET_APP_ID).withParameter(new PiActionParam(APP_ID, appFilter.appId())).build();
return DefaultFlowRule.builder().forDevice(deviceId).fromApp(appId).makePermanent().forTable(FABRIC_INGRESS_UPF_APPLICATIONS).withSelector(DefaultTrafficSelector.builder().matchPi(match).build()).withTreatment(DefaultTrafficTreatment.builder().piTableAction(action).build()).withPriority(appFilter.priority()).build();
}
use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class SlicingManager method buildQueuesFlowRule.
private FlowRule buildQueuesFlowRule(DeviceId deviceId, SliceId sliceId, TrafficClass tc, QueueId queueId, Integer color, int priority) {
PiCriterion.Builder piCriterionBuilder = PiCriterion.builder().matchExact(P4InfoConstants.HDR_SLICE_TC, sliceTcConcat(sliceId.id(), tc.toInt()));
if (color != null) {
piCriterionBuilder.matchTernary(HDR_COLOR, color, 1 << HDR_COLOR_BITWIDTH - 1);
}
PiAction.Builder piTableActionBuilder;
if (queueId != null) {
piTableActionBuilder = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_QOS_SET_QUEUE).withParameter(new PiActionParam(P4InfoConstants.QID, queueId.id()));
} else {
// Drop
piTableActionBuilder = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_QOS_METER_DROP);
}
FlowRule flowRule = DefaultFlowRule.builder().forDevice(deviceId).forTable(PiTableId.of(FABRIC_INGRESS_QOS_QUEUES.id())).fromApp(appId).withPriority(priority).withSelector(DefaultTrafficSelector.builder().matchPi(piCriterionBuilder.build()).build()).withTreatment(DefaultTrafficTreatment.builder().piTableAction(piTableActionBuilder.build()).build()).makePermanent().build();
log.debug("buildFlowRule: {}", flowRule);
return flowRule;
}
use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class SlicingManager method buildDefaultTcFlowRule.
private FlowRule buildDefaultTcFlowRule(DeviceId deviceId, SliceId sliceId, TrafficClass tc) {
PiCriterion.Builder piCriterionBuilder = PiCriterion.builder().matchTernary(P4InfoConstants.HDR_SLICE_TC, sliceTcConcat(sliceId.id(), 0x00), 0x3C).matchExact(P4InfoConstants.HDR_TC_UNKNOWN, 1);
PiAction.Builder piTableActionBuilder = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_QOS_SET_DEFAULT_TC).withParameter(new PiActionParam(P4InfoConstants.TC, tc.toInt()));
FlowRule flowRule = DefaultFlowRule.builder().forDevice(deviceId).forTable(FABRIC_INGRESS_QOS_DEFAULT_TC).fromApp(appId).withPriority(DEFAULT_TC_PRIORITY).withSelector(DefaultTrafficSelector.builder().matchPi(piCriterionBuilder.build()).build()).withTreatment(DefaultTrafficTreatment.builder().piTableAction(piTableActionBuilder.build()).build()).makePermanent().build();
log.debug("buildDefaultTcFlowRule: {}", flowRule);
return flowRule;
}
use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class StatisticManager method buildFlowRules.
// Prepare flow rules for both ingress and egress
protected List<FlowRule> buildFlowRules(StatisticKey key) {
// All possible ports in current topology
List<Port> ports = StreamSupport.stream(deviceService.getAvailableDevices().spliterator(), true).map(Device::id).map(deviceService::getPorts).flatMap(List<Port>::stream).collect(Collectors.toList());
// Prepare ingress and egress flow rule per port
List<FlowRule> flowRules = Lists.newArrayList();
ports.stream().forEach(port -> {
DeviceId deviceId = (DeviceId) port.element().id();
PortNumber portNumber = port.number();
log.debug("Processing flow rule for {}/{}", deviceId, portNumber);
// Prepare PiCriterion
PiCriterion ingressPiCriterion = PiCriterion.builder().matchExact(P4InfoConstants.HDR_IG_PORT, portNumber.toLong()).build();
PiCriterion egressPiCriterion = PiCriterion.builder().matchExact(P4InfoConstants.HDR_STATS_FLOW_ID, key.id()).matchExact(P4InfoConstants.HDR_EG_PORT, portNumber.toLong()).build();
// Prepare PiTableAction
PiTableAction ingressPiTableAction = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_STATS_COUNT).withParameter(new PiActionParam(P4InfoConstants.FLOW_ID, key.id())).build();
PiTableAction egressPiTableAction = PiAction.builder().withId(P4InfoConstants.FABRIC_EGRESS_STATS_COUNT).build();
// Prepare FlowRule
FlowRule ingressFlowRule = DefaultFlowRule.builder().forDevice(deviceId).forTable(PiTableId.of(FABRIC_INGRESS_STATS_FLOWS.id())).fromApp(appId).withPriority(key.id()).withSelector(DefaultTrafficSelector.builder(key.selector()).matchPi(ingressPiCriterion).build()).withTreatment(DefaultTrafficTreatment.builder().piTableAction(ingressPiTableAction).build()).makePermanent().build();
FlowRule egressFlowRule = DefaultFlowRule.builder().forDevice(deviceId).forTable(PiTableId.of(FABRIC_EGRESS_STATS_FLOWS.id())).fromApp(appId).withPriority(key.id()).withSelector(DefaultTrafficSelector.builder().matchPi(egressPiCriterion).build()).withTreatment(DefaultTrafficTreatment.builder().piTableAction(egressPiTableAction).build()).makePermanent().build();
flowRules.add(ingressFlowRule);
flowRules.add(egressFlowRule);
});
log.debug("Total {} flow rules", flowRules.size());
return flowRules;
}
use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class NextObjectiveTranslator method multicastNext.
// TODO: re-enable support for xconnext
// 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, P4InfoConstants.FABRIC_INGRESS_NEXT_XCONNECT,
// selector1, treatment1));
// resultBuilder.addFlowRule(flowRule(
// obj, P4InfoConstants.FABRIC_INGRESS_NEXT_XCONNECT,
// selector2, treatment2));
//
// }
private void multicastNext(NextObjective obj, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
// Create ALL group that will be translated to a PRE multicast entry.
final int groupId = allGroup(obj, resultBuilder);
if (isGroupModifyOp(obj)) {
// No changes to flow rules.
return;
}
final TrafficSelector selector = nextIdSelector(obj.id());
final PiActionParam groupIdParam = new PiActionParam(P4InfoConstants.GROUP_ID, groupId);
final PiAction setMcGroupAction = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_NEXT_SET_MCAST_GROUP_ID).withParameter(groupIdParam).build();
final TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(setMcGroupAction).build();
resultBuilder.addFlowRule(flowRule(obj, P4InfoConstants.FABRIC_INGRESS_NEXT_MULTICAST, selector, treatment));
}
Aggregations