use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class FabricPipeliner method fwdClassifierRule.
public FlowRule fwdClassifierRule(long port, Short ethType, short ipEthType, byte fwdType, int priority) {
final TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder().matchInPort(PortNumber.portNumber(port)).matchPi(PiCriterion.builder().matchExact(P4InfoConstants.HDR_IP_ETH_TYPE, ipEthType).build());
if (ethType != null) {
selectorBuilder.matchEthType(ethType);
}
final TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_FILTERING_SET_FORWARDING_TYPE).withParameter(new PiActionParam(P4InfoConstants.FWD_TYPE, fwdType)).build()).build();
return DefaultFlowRule.builder().withSelector(selectorBuilder.build()).withTreatment(treatment).forTable(P4InfoConstants.FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER).makePermanent().withPriority(priority).forDevice(deviceId).fromApp(appId).build();
}
use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class FabricPipeliner method ingressVlanRule.
public FlowRule ingressVlanRule(long port, boolean vlanValid, int vlanId, byte portType) {
final TrafficSelector selector = DefaultTrafficSelector.builder().add(Criteria.matchInPort(PortNumber.portNumber(port))).add(PiCriterion.builder().matchExact(P4InfoConstants.HDR_VLAN_IS_VALID, vlanValid ? ONE : ZERO).build()).build();
final TrafficTreatment treatment = DefaultTrafficTreatment.builder().piTableAction(PiAction.builder().withId(vlanValid ? P4InfoConstants.FABRIC_INGRESS_FILTERING_PERMIT : P4InfoConstants.FABRIC_INGRESS_FILTERING_PERMIT_WITH_INTERNAL_VLAN).withParameter(new PiActionParam(P4InfoConstants.VLAN_ID, vlanId)).withParameter(new PiActionParam(P4InfoConstants.PORT_TYPE, portType)).build()).build();
return DefaultFlowRule.builder().withSelector(selector).withTreatment(treatment).forTable(P4InfoConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN).makePermanent().withPriority(DEFAULT_FLOW_PRIORITY).forDevice(deviceId).fromApp(appId).build();
}
use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class FilteringObjectiveTranslator method fwdClassifierTreatment.
private TrafficTreatment fwdClassifierTreatment(byte fwdType) {
final PiActionParam param = new PiActionParam(P4InfoConstants.FWD_TYPE, fwdType);
final PiAction action = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_FILTERING_SET_FORWARDING_TYPE).withParameter(param).build();
return DefaultTrafficTreatment.builder().piTableAction(action).build();
}
use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class FabricUpfTranslator method upfTerminationDownlinkToFabricEntry.
/**
* Translate a downlink UpfTermination to a FlowRule to be inserted into the fabric.p4 pipeline.
*
* @param upfTermination The downlink UPF Termination to be translated
* @param deviceId the ID of the device the FlowRule should be installed on
* @param appId the ID of the application that will insert the FlowRule
* @param priority the FlowRule's priority
* @return the downlink UPF Termination translated to a FlowRule
* @throws UpfProgrammableException if the UPF Termination cannot be translated
*/
public FlowRule upfTerminationDownlinkToFabricEntry(UpfTerminationDownlink upfTermination, DeviceId deviceId, ApplicationId appId, int priority) throws UpfProgrammableException {
final PiCriterion match = PiCriterion.builder().matchExact(HDR_UE_SESSION_ID, upfTermination.ueSessionId().toInt()).matchExact(HDR_APP_ID, upfTermination.applicationId()).build();
final PiAction.Builder actionBuilder = PiAction.builder();
List<PiActionParam> paramList = new ArrayList<>(Arrays.asList(new PiActionParam(CTR_ID, upfTermination.counterId())));
if (upfTermination.needsDropping()) {
actionBuilder.withId(FABRIC_INGRESS_UPF_DOWNLINK_DROP);
} else {
actionBuilder.withId(FABRIC_INGRESS_UPF_DOWNLINK_FWD_ENCAP);
paramList.add(new PiActionParam(TEID, upfTermination.teid()));
paramList.add(new PiActionParam(QFI, upfTermination.qfi()));
paramList.add(new PiActionParam(APP_METER_IDX, (short) upfTermination.appMeterIdx()));
paramList.add(new PiActionParam(TC, upfTermination.trafficClass()));
}
actionBuilder.withParameters(paramList);
return DefaultFlowRule.builder().forDevice(deviceId).fromApp(appId).makePermanent().forTable(FABRIC_INGRESS_UPF_DOWNLINK_TERMINATIONS).withSelector(DefaultTrafficSelector.builder().matchPi(match).build()).withTreatment(DefaultTrafficTreatment.builder().piTableAction(actionBuilder.build()).build()).withPriority(priority).build();
}
use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class FabricUpfTranslator method sessionUplinkToFabricEntry.
/**
* Translate a uplink session to a FlowRule to be inserted into the fabric.p4 pipeline.
*
* @param ueSession The uplink UE Session to be translated
* @param deviceId the ID of the device the FlowRule should be installed on
* @param appId the ID of the application that will insert the FlowRule
* @param priority the FlowRule's priority
* @return the uplink ue session translated to a FlowRule
* @throws UpfProgrammableException if the UE session cannot be translated
*/
public FlowRule sessionUplinkToFabricEntry(UpfSessionUplink ueSession, DeviceId deviceId, ApplicationId appId, int priority) throws UpfProgrammableException {
final PiCriterion match;
final PiAction.Builder actionBuilder = PiAction.builder();
match = PiCriterion.builder().matchExact(HDR_TEID, ueSession.teid()).matchExact(HDR_TUNNEL_IPV4_DST, ueSession.tunDstAddr().toOctets()).build();
if (ueSession.needsDropping()) {
actionBuilder.withId(FABRIC_INGRESS_UPF_SET_UPLINK_SESSION_DROP);
} else {
actionBuilder.withId(FABRIC_INGRESS_UPF_SET_UPLINK_SESSION);
actionBuilder.withParameter(new PiActionParam(SESSION_METER_IDX, (short) ueSession.sessionMeterIdx()));
}
return DefaultFlowRule.builder().forDevice(deviceId).fromApp(appId).makePermanent().forTable(FABRIC_INGRESS_UPF_UPLINK_SESSIONS).withSelector(DefaultTrafficSelector.builder().matchPi(match).build()).withTreatment(DefaultTrafficTreatment.builder().piTableAction(actionBuilder.build()).build()).withPriority(priority).build();
}
Aggregations