88import org .onlab .packet .Ip4Prefix ;
99import org .onosproject .core .ApplicationId ;
1010import org .onosproject .net .DeviceId ;
11- import org .onosproject .net .behaviour .upf .GtpTunnelPeer ;
12- import org .onosproject .net .behaviour .upf .SessionDownlink ;
13- import org .onosproject .net .behaviour .upf .SessionUplink ;
11+ import org .onosproject .net .behaviour .upf .UpfGtpTunnelPeer ;
12+ import org .onosproject .net .behaviour .upf .UpfSessionDownlink ;
13+ import org .onosproject .net .behaviour .upf .UpfSessionUplink ;
1414import org .onosproject .net .behaviour .upf .UpfApplication ;
1515import org .onosproject .net .behaviour .upf .UpfInterface ;
1616import org .onosproject .net .behaviour .upf .UpfProgrammableException ;
9595 */
9696public class FabricUpfTranslator {
9797
98- // FIXME: slice ID should come from UP4
99- private static final SliceId SLICE_MOBILE = SliceId .DEFAULT ;
100-
10198 /**
10299 * Returns true if the given table entry is a GTP tunnel peer rule from the
103100 * physical fabric pipeline, and false otherwise.
@@ -107,7 +104,7 @@ public class FabricUpfTranslator {
107104 */
108105 public boolean isFabricGtpTunnelPeer (FlowRule entry ) {
109106 // we return egress tunnel_peers table, because only this table
110- // contains all necessary information to create GtpTunnelPeer instance.
107+ // contains all necessary information to create UpfGtpTunnelPeer instance.
111108 return entry .table ().equals (FABRIC_EGRESS_SPGW_EG_TUNNEL_PEERS );
112109 }
113110
@@ -186,16 +183,16 @@ private void assertTableId(FlowRule entry, PiTableId tableId) throws UpfProgramm
186183 }
187184
188185 /**
189- * Translate a fabric.p4 GTP tunnel peer table entry to a GtpTunnelPeer instance for easier handling.
186+ * Translate a fabric.p4 GTP tunnel peer table entry to a UpfGtpTunnelPeer instance for easier handling.
190187 *
191188 * @param entry the fabric.p4 entry to translate, the method expects FlowRule from eg_tunnel_peers table.
192- * @return the corresponding GtpTunnelPeer
189+ * @return the corresponding UpfGtpTunnelPeer
193190 * @throws UpfProgrammableException if the entry cannot be translated
194191 */
195- public GtpTunnelPeer fabricEntryToGtpTunnelPeer (FlowRule entry )
192+ public UpfGtpTunnelPeer fabricEntryToGtpTunnelPeer (FlowRule entry )
196193 throws UpfProgrammableException {
197194 assertTableId (entry , FABRIC_EGRESS_SPGW_EG_TUNNEL_PEERS );
198- GtpTunnelPeer .Builder builder = GtpTunnelPeer .builder ();
195+ UpfGtpTunnelPeer .Builder builder = UpfGtpTunnelPeer .builder ();
199196
200197 Pair <PiCriterion , PiTableAction > matchActionPair = FabricUpfTranslatorUtil .fabricEntryToPiPair (entry );
201198 PiCriterion match = matchActionPair .getLeft ();
@@ -204,7 +201,7 @@ public GtpTunnelPeer fabricEntryToGtpTunnelPeer(FlowRule entry)
204201
205202 if (!action .id ().equals (FABRIC_EGRESS_SPGW_LOAD_TUNNEL_PARAMS )) {
206203 throw new UpfProgrammableException (
207- "Invalid action provided, cannot build GtpTunnelPeer instance: " + action .id ());
204+ "Invalid action provided, cannot build UpfGtpTunnelPeer instance: " + action .id ());
208205 }
209206
210207 builder .withSrcAddr (FabricUpfTranslatorUtil .getParamAddress (action , TUNNEL_SRC_ADDR ))
@@ -221,10 +218,10 @@ public GtpTunnelPeer fabricEntryToGtpTunnelPeer(FlowRule entry)
221218 * @return the corresponding UeSession
222219 * @throws UpfProgrammableException if the entry cannot be translated
223220 */
224- public SessionUplink fabricEntryToUeSessionUplink (FlowRule entry )
221+ public UpfSessionUplink fabricEntryToUeSessionUplink (FlowRule entry )
225222 throws UpfProgrammableException {
226223 assertTableId (entry , FABRIC_INGRESS_SPGW_UPLINK_SESSIONS );
227- SessionUplink .Builder builder = SessionUplink .builder ();
224+ UpfSessionUplink .Builder builder = UpfSessionUplink .builder ();
228225
229226 Pair <PiCriterion , PiTableAction > matchActionPair = FabricUpfTranslatorUtil .fabricEntryToPiPair (entry );
230227 PiCriterion match = matchActionPair .getLeft ();
@@ -250,10 +247,10 @@ public SessionUplink fabricEntryToUeSessionUplink(FlowRule entry)
250247 * @return the corresponding UeSession
251248 * @throws UpfProgrammableException if the entry cannot be translated
252249 */
253- public SessionDownlink fabricEntryToUeSessionDownlink (FlowRule entry )
250+ public UpfSessionDownlink fabricEntryToUeSessionDownlink (FlowRule entry )
254251 throws UpfProgrammableException {
255252 assertTableId (entry , FABRIC_INGRESS_SPGW_DOWNLINK_SESSIONS );
256- SessionDownlink .Builder builder = SessionDownlink .builder ();
253+ UpfSessionDownlink .Builder builder = UpfSessionDownlink .builder ();
257254 Pair <PiCriterion , PiTableAction > matchActionPair = FabricUpfTranslatorUtil .fabricEntryToPiPair (entry );
258255 PiCriterion match = matchActionPair .getLeft ();
259256 PiAction action = (PiAction ) matchActionPair .getRight ();
@@ -365,7 +362,8 @@ public UpfInterface fabricEntryToInterface(FlowRule entry)
365362 PiAction action = (PiAction ) matchActionPair .getRight ();
366363
367364 var ifaceBuilder = UpfInterface .builder ()
368- .setPrefix (FabricUpfTranslatorUtil .getFieldPrefix (match , HDR_IPV4_DST_ADDR ));
365+ .setPrefix (FabricUpfTranslatorUtil .getFieldPrefix (match , HDR_IPV4_DST_ADDR ))
366+ .setSliceId (FabricUpfTranslatorUtil .getParamByte (action , SLICE_ID ));
369367
370368 if (action .id ().equals (FABRIC_INGRESS_SPGW_IFACE_ACCESS )) {
371369 ifaceBuilder .setAccess ();
@@ -388,6 +386,7 @@ public UpfApplication fabricEntryToUpfApplication(FlowRule entry)
388386 PiAction action = (PiAction ) matchActionPair .getRight ();
389387 UpfApplication .Builder appFilteringBuilder = UpfApplication .builder ()
390388 .withAppId (FabricUpfTranslatorUtil .getParamByte (action , APP_ID ))
389+ .withSliceId (FabricUpfTranslatorUtil .getFieldInt (match , HDR_SLICE_ID ))
391390 .withPriority (entry .priority ());
392391 if (FabricUpfTranslatorUtil .fieldIsPresent (match , HDR_APP_IPV4_ADDR )) {
393392 appFilteringBuilder .withIp4Prefix (FabricUpfTranslatorUtil .getFieldPrefix (match , HDR_APP_IPV4_ADDR ));
@@ -402,7 +401,7 @@ public UpfApplication fabricEntryToUpfApplication(FlowRule entry)
402401 }
403402
404403 /**
405- * Translate a GtpTunnelPeer to two FlowRules to be inserted into the fabric.p4 pipeline.
404+ * Translate a UpfGtpTunnelPeer to two FlowRules to be inserted into the fabric.p4 pipeline.
406405 *
407406 * @param gtpTunnelPeer the GTP tunnel peer to be translated
408407 * @param deviceId the ID of the device the FlowRule should be installed on
@@ -411,7 +410,7 @@ public UpfApplication fabricEntryToUpfApplication(FlowRule entry)
411410 * @return a pair of FlowRules translated from GTP tunnel peer
412411 * @throws UpfProgrammableException if the interface cannot be translated
413412 */
414- public Pair <FlowRule , FlowRule > gtpTunnelPeerToFabricEntry (GtpTunnelPeer gtpTunnelPeer , DeviceId deviceId ,
413+ public Pair <FlowRule , FlowRule > gtpTunnelPeerToFabricEntry (UpfGtpTunnelPeer gtpTunnelPeer , DeviceId deviceId ,
415414 ApplicationId appId , int priority )
416415 throws UpfProgrammableException {
417416 FlowRule ingressEntry ;
@@ -465,7 +464,7 @@ public Pair<FlowRule, FlowRule> gtpTunnelPeerToFabricEntry(GtpTunnelPeer gtpTunn
465464 * @return the uplink ue session translated to a FlowRule
466465 * @throws UpfProgrammableException if the UE session cannot be translated
467466 */
468- public FlowRule sessionUplinkToFabricEntry (SessionUplink ueSession , DeviceId deviceId ,
467+ public FlowRule sessionUplinkToFabricEntry (UpfSessionUplink ueSession , DeviceId deviceId ,
469468 ApplicationId appId , int priority )
470469 throws UpfProgrammableException {
471470 final PiCriterion match ;
@@ -501,7 +500,7 @@ public FlowRule sessionUplinkToFabricEntry(SessionUplink ueSession, DeviceId dev
501500 * @return the downlink ue session translated to a FlowRule
502501 * @throws UpfProgrammableException if the UE session cannot be translated
503502 */
504- public FlowRule sessionDownlinkToFabricEntry (SessionDownlink ueSession , DeviceId deviceId ,
503+ public FlowRule sessionDownlinkToFabricEntry (UpfSessionDownlink ueSession , DeviceId deviceId ,
505504 ApplicationId appId , int priority )
506505 throws UpfProgrammableException {
507506 final PiCriterion match ;
@@ -662,7 +661,7 @@ public FlowRule interfaceToFabricEntry(UpfInterface upfInterface, DeviceId devic
662661 .build ();
663662 PiAction action = PiAction .builder ()
664663 .withId (actionId )
665- .withParameter (new PiActionParam (SLICE_ID , SLICE_MOBILE .id ()))
664+ .withParameter (new PiActionParam (SLICE_ID , SliceId . of ( upfInterface . sliceId ()) .id ()))
666665 .build ();
667666 return DefaultFlowRule .builder ()
668667 .forDevice (deviceId ).fromApp (appId ).makePermanent ()
@@ -692,7 +691,7 @@ public FlowRule upfApplicationToFabricEntry(
692691
693692 public PiCriterion buildApplicationCriterion (UpfApplication appFilter ) {
694693 PiCriterion .Builder matchBuilder = PiCriterion .builder ();
695- matchBuilder .matchExact (HDR_SLICE_ID , SLICE_MOBILE .id ());
694+ matchBuilder .matchExact (HDR_SLICE_ID , SliceId . of ( appFilter . sliceId ()) .id ());
696695 if (appFilter .ip4Prefix ().isPresent ()) {
697696 Ip4Prefix ip4Prefix = appFilter .ip4Prefix ().get ();
698697 matchBuilder .matchLpm (HDR_APP_IPV4_ADDR , ip4Prefix .address ().toOctets (), ip4Prefix .prefixLength ());
0 commit comments