use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class FabricInterpreterTest method testNextVlanTreatment.
/**
* Map treatment to set_vlan_output action.
*/
@Test
public void testNextVlanTreatment() throws Exception {
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setVlanId(VLAN_100).build();
PiAction mappedAction = interpreter.mapTreatment(treatment, P4InfoConstants.FABRIC_INGRESS_PRE_NEXT_NEXT_VLAN);
PiActionParam vlanParam = new PiActionParam(P4InfoConstants.VLAN_ID, VLAN_100.toShort());
PiAction expectedAction = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_PRE_NEXT_SET_VLAN).withParameter(vlanParam).build();
assertEquals(expectedAction, mappedAction);
}
use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class FabricPipelinerTest method buildFwdClsRule.
private FlowRule buildFwdClsRule(long port, Short etherType, short ipEtherType, byte fwdType, int priority) {
final TrafficSelector.Builder fwdClsSelector = DefaultTrafficSelector.builder().matchInPort(PortNumber.portNumber(port)).matchPi(PiCriterion.builder().matchExact(P4InfoConstants.HDR_IP_ETH_TYPE, ipEtherType).build());
if (etherType != null) {
fwdClsSelector.matchEthType(etherType);
}
final TrafficTreatment cpuFwdClsTreatment = 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(fwdClsSelector.build()).withTreatment(cpuFwdClsTreatment).forTable(P4InfoConstants.FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER).makePermanent().withPriority(priority).forDevice(DEVICE_ID).fromApp(APP_ID).build();
}
use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class FabricUpfTranslator method upfTerminationUplinkToFabricEntry.
/**
* Translate a Uplink UpfTermination to a FlowRule to be inserted into the fabric.p4 pipeline.
*
* @param upfTermination The uplink 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 uplink UPF Termination translated to a FlowRule
* @throws UpfProgrammableException if the UPF Termination cannot be translated
*/
public FlowRule upfTerminationUplinkToFabricEntry(UpfTerminationUplink 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_UPLINK_DROP);
} else {
actionBuilder.withId(FABRIC_INGRESS_UPF_APP_FWD);
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_UPLINK_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 gtpTunnelPeerToFabricEntry.
/**
* Translate a UpfGtpTunnelPeer to two FlowRules to be inserted into the fabric.p4 pipeline.
*
* @param gtpTunnelPeer the GTP tunnel peer 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 FlowRules' priority
* @return a pair of FlowRules translated from GTP tunnel peer
* @throws UpfProgrammableException if the interface cannot be translated
*/
public Pair<FlowRule, FlowRule> gtpTunnelPeerToFabricEntry(UpfGtpTunnelPeer gtpTunnelPeer, DeviceId deviceId, ApplicationId appId, int priority) throws UpfProgrammableException {
FlowRule ingressEntry;
FlowRule egressEntry;
if (gtpTunnelPeer.src() == null || gtpTunnelPeer.dst() == null) {
throw new UpfProgrammableException("Not all action parameters present when translating " + "intermediate GTP tunnel peer to physical representation!");
}
PiCriterion match = PiCriterion.builder().matchExact(HDR_TUN_PEER_ID, gtpTunnelPeer.tunPeerId()).build();
FlowRule.Builder base = DefaultFlowRule.builder().forDevice(deviceId).fromApp(appId).makePermanent().withPriority(priority).withSelector(DefaultTrafficSelector.builder().matchPi(match).build());
PiAction ingressAction = PiAction.builder().withId(FABRIC_INGRESS_UPF_SET_ROUTING_IPV4_DST).withParameter(new PiActionParam(TUN_DST_ADDR, gtpTunnelPeer.dst().toInt())).build();
ingressEntry = base.forTable(FABRIC_INGRESS_UPF_IG_TUNNEL_PEERS).withTreatment(DefaultTrafficTreatment.builder().piTableAction(ingressAction).build()).build();
PiAction egressAction = PiAction.builder().withId(FABRIC_EGRESS_UPF_LOAD_TUNNEL_PARAMS).withParameters(Arrays.asList(new PiActionParam(TUNNEL_SRC_ADDR, gtpTunnelPeer.src().toInt()), new PiActionParam(TUNNEL_DST_ADDR, gtpTunnelPeer.dst().toInt()), new PiActionParam(TUNNEL_SRC_PORT, gtpTunnelPeer.srcPort()))).build();
egressEntry = base.forTable(FABRIC_EGRESS_UPF_EG_TUNNEL_PEERS).withTreatment(DefaultTrafficTreatment.builder().piTableAction(egressAction).build()).build();
return Pair.of(ingressEntry, egressEntry);
}
use of org.onosproject.net.pi.runtime.PiActionParam in project fabric-tna by stratum.
the class FabricUpfTranslator method sessionDownlinkToFabricEntry.
/**
* Translate a downlink session to a FlowRule to be inserted into the fabric.p4 pipeline.
*
* @param ueSession The downlink 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 downlink ue session translated to a FlowRule
* @throws UpfProgrammableException if the UE session cannot be translated
*/
public FlowRule sessionDownlinkToFabricEntry(UpfSessionDownlink ueSession, DeviceId deviceId, ApplicationId appId, int priority) throws UpfProgrammableException {
final PiCriterion match;
final PiAction.Builder actionBuilder = PiAction.builder();
match = PiCriterion.builder().matchExact(HDR_UE_ADDR, ueSession.ueAddress().toOctets()).build();
if (ueSession.needsDropping() && ueSession.needsBuffering()) {
actionBuilder.withId(FABRIC_INGRESS_UPF_SET_DOWNLINK_SESSION_BUF_DROP);
} else if (ueSession.needsDropping()) {
actionBuilder.withId(FABRIC_INGRESS_UPF_SET_DOWNLINK_SESSION_DROP);
} else {
actionBuilder.withParameter(new PiActionParam(TUN_PEER_ID, ueSession.tunPeerId())).withParameter(new PiActionParam(SESSION_METER_IDX, (short) ueSession.sessionMeterIdx()));
if (ueSession.needsBuffering()) {
actionBuilder.withId(FABRIC_INGRESS_UPF_SET_DOWNLINK_SESSION_BUF);
} else {
actionBuilder.withId(FABRIC_INGRESS_UPF_SET_DOWNLINK_SESSION);
}
}
return DefaultFlowRule.builder().forDevice(deviceId).fromApp(appId).makePermanent().forTable(FABRIC_INGRESS_UPF_DOWNLINK_SESSIONS).withSelector(DefaultTrafficSelector.builder().matchPi(match).build()).withTreatment(DefaultTrafficTreatment.builder().piTableAction(actionBuilder.build()).build()).withPriority(priority).build();
}
Aggregations