Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.pipelines.fabric.impl.behaviour.upf; |
| 18 | |
pierventre | 1eb9871 | 2021-07-13 18:03:22 +0200 | [diff] [blame] | 19 | import com.google.common.hash.Hashing; |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 20 | import org.onlab.packet.Ip4Address; |
| 21 | import org.onlab.packet.Ip4Prefix; |
| 22 | import org.onlab.util.ImmutableByteSequence; |
| 23 | import org.onosproject.core.ApplicationId; |
| 24 | import org.onosproject.core.DefaultApplicationId; |
| 25 | import org.onosproject.net.DeviceId; |
| 26 | import org.onosproject.net.behaviour.upf.ForwardingActionRule; |
| 27 | import org.onosproject.net.behaviour.upf.PacketDetectionRule; |
| 28 | import org.onosproject.net.behaviour.upf.UpfInterface; |
| 29 | import org.onosproject.net.flow.DefaultFlowRule; |
| 30 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 31 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 32 | import org.onosproject.net.flow.FlowRule; |
| 33 | import org.onosproject.net.flow.criteria.PiCriterion; |
| 34 | import org.onosproject.net.pi.runtime.PiAction; |
| 35 | import org.onosproject.net.pi.runtime.PiActionParam; |
| 36 | |
| 37 | import java.util.Arrays; |
| 38 | |
| 39 | import static org.onosproject.pipelines.fabric.FabricConstants.CTR_ID; |
| 40 | import static org.onosproject.pipelines.fabric.FabricConstants.DROP; |
| 41 | import static org.onosproject.pipelines.fabric.FabricConstants.FABRIC_INGRESS_SPGW_DOWNLINK_PDRS; |
| 42 | import static org.onosproject.pipelines.fabric.FabricConstants.FABRIC_INGRESS_SPGW_FARS; |
| 43 | import static org.onosproject.pipelines.fabric.FabricConstants.FABRIC_INGRESS_SPGW_INTERFACES; |
| 44 | import static org.onosproject.pipelines.fabric.FabricConstants.FABRIC_INGRESS_SPGW_LOAD_IFACE; |
| 45 | import static org.onosproject.pipelines.fabric.FabricConstants.FABRIC_INGRESS_SPGW_LOAD_NORMAL_FAR; |
| 46 | import static org.onosproject.pipelines.fabric.FabricConstants.FABRIC_INGRESS_SPGW_LOAD_PDR; |
| 47 | import static org.onosproject.pipelines.fabric.FabricConstants.FABRIC_INGRESS_SPGW_LOAD_PDR_QOS; |
| 48 | import static org.onosproject.pipelines.fabric.FabricConstants.FABRIC_INGRESS_SPGW_LOAD_TUNNEL_FAR; |
| 49 | import static org.onosproject.pipelines.fabric.FabricConstants.FABRIC_INGRESS_SPGW_UPLINK_PDRS; |
| 50 | import static org.onosproject.pipelines.fabric.FabricConstants.FAR_ID; |
| 51 | import static org.onosproject.pipelines.fabric.FabricConstants.HDR_FAR_ID; |
| 52 | import static org.onosproject.pipelines.fabric.FabricConstants.HDR_GTPU_IS_VALID; |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 53 | import static org.onosproject.pipelines.fabric.FabricConstants.HDR_HAS_QFI; |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 54 | import static org.onosproject.pipelines.fabric.FabricConstants.HDR_IPV4_DST_ADDR; |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 55 | import static org.onosproject.pipelines.fabric.FabricConstants.HDR_QFI; |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 56 | import static org.onosproject.pipelines.fabric.FabricConstants.HDR_TEID; |
| 57 | import static org.onosproject.pipelines.fabric.FabricConstants.HDR_TUNNEL_IPV4_DST; |
| 58 | import static org.onosproject.pipelines.fabric.FabricConstants.HDR_UE_ADDR; |
| 59 | import static org.onosproject.pipelines.fabric.FabricConstants.NEEDS_GTPU_DECAP; |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 60 | import static org.onosproject.pipelines.fabric.FabricConstants.NEEDS_QFI_PUSH; |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 61 | import static org.onosproject.pipelines.fabric.FabricConstants.NOTIFY_CP; |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 62 | import static org.onosproject.pipelines.fabric.FabricConstants.QFI; |
| 63 | import static org.onosproject.pipelines.fabric.FabricConstants.SLICE_ID; |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 64 | import static org.onosproject.pipelines.fabric.FabricConstants.SRC_IFACE; |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 65 | import static org.onosproject.pipelines.fabric.FabricConstants.TC; |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 66 | import static org.onosproject.pipelines.fabric.FabricConstants.TEID; |
| 67 | import static org.onosproject.pipelines.fabric.FabricConstants.TUNNEL_DST_ADDR; |
| 68 | import static org.onosproject.pipelines.fabric.FabricConstants.TUNNEL_SRC_ADDR; |
| 69 | import static org.onosproject.pipelines.fabric.FabricConstants.TUNNEL_SRC_PORT; |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 70 | import static org.onosproject.pipelines.fabric.impl.behaviour.Constants.DEFAULT_QFI; |
| 71 | import static org.onosproject.pipelines.fabric.impl.behaviour.Constants.DEFAULT_SLICE_ID; |
| 72 | import static org.onosproject.pipelines.fabric.impl.behaviour.Constants.DEFAULT_TC; |
| 73 | import static org.onosproject.pipelines.fabric.impl.behaviour.Constants.FALSE; |
| 74 | import static org.onosproject.pipelines.fabric.impl.behaviour.Constants.TRUE; |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 75 | import static org.onosproject.pipelines.fabric.impl.behaviour.upf.FabricUpfTranslator.INTERFACE_ACCESS; |
| 76 | import static org.onosproject.pipelines.fabric.impl.behaviour.upf.FabricUpfTranslator.INTERFACE_CORE; |
| 77 | |
| 78 | |
| 79 | public final class TestUpfConstants { |
| 80 | public static final DeviceId DEVICE_ID = DeviceId.deviceId("CoolSwitch91"); |
| 81 | public static final ApplicationId APP_ID = new DefaultApplicationId(5000, "up4"); |
| 82 | public static final int DEFAULT_PRIORITY = 10; |
| 83 | // SESSION_ID_BITWIDTH / 8 = 12 |
| 84 | public static final ImmutableByteSequence SESSION_ID = ImmutableByteSequence.ofOnes(12); |
| 85 | public static final int UPLINK_COUNTER_CELL_ID = 1; |
| 86 | public static final int DOWNLINK_COUNTER_CELL_ID = 2; |
| 87 | public static final int PDR_ID = 0; // TODO: PDR ID currently not stored on writes, so all reads are 0 |
| 88 | public static final int UPLINK_FAR_ID = 1; |
pierventre | 1eb9871 | 2021-07-13 18:03:22 +0200 | [diff] [blame] | 89 | public static final int UPLINK_PHYSICAL_FAR_ID = Hashing.murmur3_32() |
| 90 | .newHasher() |
| 91 | .putInt(UPLINK_FAR_ID) |
| 92 | .putBytes(SESSION_ID.asArray()) |
| 93 | .hash() |
| 94 | .asInt(); |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 95 | public static final int DOWNLINK_FAR_ID = 2; |
pierventre | 1eb9871 | 2021-07-13 18:03:22 +0200 | [diff] [blame] | 96 | public static final int DOWNLINK_PHYSICAL_FAR_ID = Hashing.murmur3_32() |
| 97 | .newHasher() |
| 98 | .putInt(DOWNLINK_FAR_ID) |
| 99 | .putBytes(SESSION_ID.asArray()) |
| 100 | .hash() |
| 101 | .asInt(); |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 102 | |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 103 | public static final byte UPLINK_QFI = 1; |
| 104 | public static final byte DOWNLINK_QFI = 5; |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 105 | |
| 106 | public static final ImmutableByteSequence TEID_VALUE = ImmutableByteSequence.copyFrom(0xff); |
| 107 | public static final Ip4Address UE_ADDR = Ip4Address.valueOf("17.0.0.1"); |
| 108 | public static final Ip4Address S1U_ADDR = Ip4Address.valueOf("192.168.0.1"); |
| 109 | public static final Ip4Address ENB_ADDR = Ip4Address.valueOf("192.168.0.2"); |
| 110 | public static final Ip4Prefix UE_POOL = Ip4Prefix.valueOf("17.0.0.0/16"); |
| 111 | // TODO: tunnel source port currently not stored on writes, so all reads are 0 |
| 112 | public static final short TUNNEL_SPORT = 2160; |
| 113 | public static final int PHYSICAL_COUNTER_SIZE = 512; |
| 114 | public static final int PHYSICAL_MAX_PDRS = 512; |
| 115 | public static final int PHYSICAL_MAX_FARS = 512; |
| 116 | |
| 117 | public static final long COUNTER_BYTES = 12; |
| 118 | public static final long COUNTER_PKTS = 15; |
| 119 | |
| 120 | public static final PacketDetectionRule UPLINK_PDR = PacketDetectionRule.builder() |
| 121 | .withTunnelDst(S1U_ADDR) |
| 122 | .withTeid(TEID_VALUE) |
| 123 | .withLocalFarId(UPLINK_FAR_ID) |
| 124 | .withSessionId(SESSION_ID) |
| 125 | .withCounterId(UPLINK_COUNTER_CELL_ID) |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 126 | .build(); |
| 127 | |
| 128 | public static final PacketDetectionRule DOWNLINK_PDR = PacketDetectionRule.builder() |
| 129 | .withUeAddr(UE_ADDR) |
| 130 | .withLocalFarId(DOWNLINK_FAR_ID) |
| 131 | .withSessionId(SESSION_ID) |
| 132 | .withCounterId(DOWNLINK_COUNTER_CELL_ID) |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 133 | .build(); |
| 134 | |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 135 | public static final PacketDetectionRule UPLINK_QOS_PDR = PacketDetectionRule.builder() |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 136 | .withTunnelDst(S1U_ADDR) |
| 137 | .withTeid(TEID_VALUE) |
| 138 | .withLocalFarId(UPLINK_FAR_ID) |
| 139 | .withSessionId(SESSION_ID) |
| 140 | .withCounterId(UPLINK_COUNTER_CELL_ID) |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 141 | .withQfi(UPLINK_QFI) |
| 142 | .withQfiMatch() |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 143 | .build(); |
| 144 | |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 145 | public static final PacketDetectionRule UPLINK_QOS_4G_PDR = PacketDetectionRule.builder() |
| 146 | .withTunnelDst(S1U_ADDR) |
| 147 | .withTeid(TEID_VALUE) |
| 148 | .withLocalFarId(UPLINK_FAR_ID) |
| 149 | .withSessionId(SESSION_ID) |
| 150 | .withCounterId(UPLINK_COUNTER_CELL_ID) |
| 151 | .withQfi(UPLINK_QFI) |
| 152 | .build(); |
| 153 | |
| 154 | public static final PacketDetectionRule DOWNLINK_QOS_PDR = PacketDetectionRule.builder() |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 155 | .withUeAddr(UE_ADDR) |
| 156 | .withLocalFarId(DOWNLINK_FAR_ID) |
| 157 | .withSessionId(SESSION_ID) |
| 158 | .withCounterId(DOWNLINK_COUNTER_CELL_ID) |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 159 | .withQfi(DOWNLINK_QFI) |
| 160 | .withQfiPush() |
| 161 | .build(); |
| 162 | |
| 163 | public static final PacketDetectionRule DOWNLINK_QOS_4G_PDR = PacketDetectionRule.builder() |
| 164 | .withUeAddr(UE_ADDR) |
| 165 | .withLocalFarId(DOWNLINK_FAR_ID) |
| 166 | .withSessionId(SESSION_ID) |
| 167 | .withCounterId(DOWNLINK_COUNTER_CELL_ID) |
| 168 | .withQfi(DOWNLINK_QFI) |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 169 | .build(); |
| 170 | |
| 171 | public static final ForwardingActionRule UPLINK_FAR = ForwardingActionRule.builder() |
| 172 | .setFarId(UPLINK_FAR_ID) |
| 173 | .withSessionId(SESSION_ID).build(); |
| 174 | |
| 175 | public static final ForwardingActionRule DOWNLINK_FAR = ForwardingActionRule.builder() |
| 176 | .setFarId(DOWNLINK_FAR_ID) |
| 177 | .withSessionId(SESSION_ID) |
| 178 | .setTunnel(S1U_ADDR, ENB_ADDR, TEID_VALUE, TUNNEL_SPORT) |
| 179 | .build(); |
| 180 | |
| 181 | public static final UpfInterface UPLINK_INTERFACE = UpfInterface.createS1uFrom(S1U_ADDR); |
| 182 | |
| 183 | public static final UpfInterface DOWNLINK_INTERFACE = UpfInterface.createUePoolFrom(UE_POOL); |
| 184 | |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 185 | public static final FlowRule FABRIC_UPLINK_QOS_PDR = DefaultFlowRule.builder() |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 186 | .forDevice(DEVICE_ID).fromApp(APP_ID).makePermanent() |
| 187 | .forTable(FABRIC_INGRESS_SPGW_UPLINK_PDRS) |
| 188 | .withSelector(DefaultTrafficSelector.builder() |
| 189 | .matchPi(PiCriterion.builder() |
| 190 | .matchExact(HDR_TEID, TEID_VALUE.asArray()) |
| 191 | .matchExact(HDR_TUNNEL_IPV4_DST, S1U_ADDR.toInt()) |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 192 | .matchExact(HDR_HAS_QFI, TRUE) |
| 193 | .matchExact(HDR_QFI, UPLINK_QFI) |
| 194 | .build()).build()) |
| 195 | .withTreatment(DefaultTrafficTreatment.builder() |
| 196 | .piTableAction(PiAction.builder() |
| 197 | .withId(FABRIC_INGRESS_SPGW_LOAD_PDR) |
| 198 | .withParameters(Arrays.asList( |
| 199 | new PiActionParam(CTR_ID, UPLINK_COUNTER_CELL_ID), |
| 200 | new PiActionParam(FAR_ID, UPLINK_PHYSICAL_FAR_ID), |
| 201 | new PiActionParam(NEEDS_GTPU_DECAP, TRUE), |
| 202 | new PiActionParam(TC, DEFAULT_TC) |
| 203 | )) |
| 204 | .build()).build()) |
| 205 | .withPriority(DEFAULT_PRIORITY) |
| 206 | .build(); |
| 207 | |
| 208 | public static final FlowRule FABRIC_UPLINK_QOS_4G_PDR = DefaultFlowRule.builder() |
| 209 | .forDevice(DEVICE_ID).fromApp(APP_ID).makePermanent() |
| 210 | .forTable(FABRIC_INGRESS_SPGW_UPLINK_PDRS) |
| 211 | .withSelector(DefaultTrafficSelector.builder() |
| 212 | .matchPi(PiCriterion.builder() |
| 213 | .matchExact(HDR_TEID, TEID_VALUE.asArray()) |
| 214 | .matchExact(HDR_TUNNEL_IPV4_DST, S1U_ADDR.toInt()) |
| 215 | .matchExact(HDR_HAS_QFI, FALSE) |
| 216 | .matchExact(HDR_QFI, DEFAULT_QFI) |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 217 | .build()).build()) |
| 218 | .withTreatment(DefaultTrafficTreatment.builder() |
| 219 | .piTableAction(PiAction.builder() |
| 220 | .withId(FABRIC_INGRESS_SPGW_LOAD_PDR_QOS) |
| 221 | .withParameters(Arrays.asList( |
| 222 | new PiActionParam(CTR_ID, UPLINK_COUNTER_CELL_ID), |
| 223 | new PiActionParam(FAR_ID, UPLINK_PHYSICAL_FAR_ID), |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 224 | new PiActionParam(NEEDS_GTPU_DECAP, TRUE), |
| 225 | new PiActionParam(NEEDS_QFI_PUSH, FALSE), |
| 226 | new PiActionParam(QFI, |
| 227 | UPLINK_QFI), |
| 228 | new PiActionParam(TC, DEFAULT_TC) |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 229 | )) |
| 230 | .build()).build()) |
| 231 | .withPriority(DEFAULT_PRIORITY) |
| 232 | .build(); |
| 233 | |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 234 | public static final FlowRule FABRIC_DOWNLINK_QOS_PDR = DefaultFlowRule.builder() |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 235 | .forDevice(DEVICE_ID).fromApp(APP_ID).makePermanent() |
| 236 | .forTable(FABRIC_INGRESS_SPGW_DOWNLINK_PDRS) |
| 237 | .withSelector(DefaultTrafficSelector.builder() |
| 238 | .matchPi(PiCriterion.builder() |
| 239 | .matchExact(HDR_UE_ADDR, UE_ADDR.toInt()) |
| 240 | .build()).build()) |
| 241 | .withTreatment(DefaultTrafficTreatment.builder() |
| 242 | .piTableAction(PiAction.builder() |
| 243 | .withId(FABRIC_INGRESS_SPGW_LOAD_PDR_QOS) |
| 244 | .withParameters(Arrays.asList( |
| 245 | new PiActionParam(CTR_ID, DOWNLINK_COUNTER_CELL_ID), |
| 246 | new PiActionParam(FAR_ID, DOWNLINK_PHYSICAL_FAR_ID), |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 247 | new PiActionParam(QFI, DOWNLINK_QFI), |
| 248 | new PiActionParam(NEEDS_GTPU_DECAP, FALSE), |
| 249 | new PiActionParam(NEEDS_QFI_PUSH, TRUE), |
| 250 | new PiActionParam(TC, DEFAULT_TC) |
| 251 | )) |
| 252 | .build()).build()) |
| 253 | .withPriority(DEFAULT_PRIORITY) |
| 254 | .build(); |
| 255 | |
| 256 | public static final FlowRule FABRIC_DOWNLINK_QOS_4G_PDR = DefaultFlowRule.builder() |
| 257 | .forDevice(DEVICE_ID).fromApp(APP_ID).makePermanent() |
| 258 | .forTable(FABRIC_INGRESS_SPGW_DOWNLINK_PDRS) |
| 259 | .withSelector(DefaultTrafficSelector.builder() |
| 260 | .matchPi(PiCriterion.builder() |
| 261 | .matchExact(HDR_UE_ADDR, UE_ADDR.toInt()) |
| 262 | .build()).build()) |
| 263 | .withTreatment(DefaultTrafficTreatment.builder() |
| 264 | .piTableAction(PiAction.builder() |
| 265 | .withId(FABRIC_INGRESS_SPGW_LOAD_PDR_QOS) |
| 266 | .withParameters(Arrays.asList( |
| 267 | new PiActionParam(CTR_ID, DOWNLINK_COUNTER_CELL_ID), |
| 268 | new PiActionParam(FAR_ID, DOWNLINK_PHYSICAL_FAR_ID), |
| 269 | new PiActionParam(QFI, DOWNLINK_QFI), |
| 270 | new PiActionParam(NEEDS_GTPU_DECAP, FALSE), |
| 271 | new PiActionParam(NEEDS_QFI_PUSH, FALSE), |
| 272 | new PiActionParam(TC, DEFAULT_TC) |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 273 | )) |
| 274 | .build()).build()) |
| 275 | .withPriority(DEFAULT_PRIORITY) |
| 276 | .build(); |
| 277 | |
| 278 | public static final FlowRule FABRIC_UPLINK_PDR = DefaultFlowRule.builder() |
| 279 | .forDevice(DEVICE_ID).fromApp(APP_ID).makePermanent() |
| 280 | .forTable(FABRIC_INGRESS_SPGW_UPLINK_PDRS) |
| 281 | .withSelector(DefaultTrafficSelector.builder() |
| 282 | .matchPi(PiCriterion.builder() |
| 283 | .matchExact(HDR_TEID, TEID_VALUE.asArray()) |
| 284 | .matchExact(HDR_TUNNEL_IPV4_DST, S1U_ADDR.toInt()) |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 285 | .matchExact(HDR_HAS_QFI, FALSE) |
| 286 | .matchExact(HDR_QFI, DEFAULT_QFI) |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 287 | .build()).build()) |
| 288 | .withTreatment(DefaultTrafficTreatment.builder() |
| 289 | .piTableAction(PiAction.builder() |
| 290 | .withId(FABRIC_INGRESS_SPGW_LOAD_PDR) |
| 291 | .withParameters(Arrays.asList( |
| 292 | new PiActionParam(CTR_ID, UPLINK_COUNTER_CELL_ID), |
| 293 | new PiActionParam(FAR_ID, UPLINK_PHYSICAL_FAR_ID), |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 294 | new PiActionParam(NEEDS_GTPU_DECAP, TRUE), |
| 295 | new PiActionParam(TC, DEFAULT_TC) |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 296 | )) |
| 297 | .build()).build()) |
| 298 | .withPriority(DEFAULT_PRIORITY) |
| 299 | .build(); |
| 300 | |
| 301 | public static final FlowRule FABRIC_DOWNLINK_PDR = DefaultFlowRule.builder() |
| 302 | .forDevice(DEVICE_ID).fromApp(APP_ID).makePermanent() |
| 303 | .forTable(FABRIC_INGRESS_SPGW_DOWNLINK_PDRS) |
| 304 | .withSelector(DefaultTrafficSelector.builder() |
| 305 | .matchPi(PiCriterion.builder() |
| 306 | .matchExact(HDR_UE_ADDR, UE_ADDR.toInt()) |
| 307 | .build()).build()) |
| 308 | .withTreatment(DefaultTrafficTreatment.builder() |
| 309 | .piTableAction(PiAction.builder() |
| 310 | .withId(FABRIC_INGRESS_SPGW_LOAD_PDR) |
| 311 | .withParameters(Arrays.asList( |
| 312 | new PiActionParam(CTR_ID, DOWNLINK_COUNTER_CELL_ID), |
| 313 | new PiActionParam(FAR_ID, DOWNLINK_PHYSICAL_FAR_ID), |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 314 | new PiActionParam(NEEDS_GTPU_DECAP, FALSE), |
| 315 | new PiActionParam(TC, DEFAULT_TC) |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 316 | )) |
| 317 | .build()).build()) |
| 318 | .withPriority(DEFAULT_PRIORITY) |
| 319 | .build(); |
| 320 | |
| 321 | public static final FlowRule FABRIC_UPLINK_FAR = DefaultFlowRule.builder() |
| 322 | .forDevice(DEVICE_ID).fromApp(APP_ID).makePermanent() |
| 323 | .forTable(FABRIC_INGRESS_SPGW_FARS) |
| 324 | .withSelector(DefaultTrafficSelector.builder() |
| 325 | .matchPi(PiCriterion.builder() |
| 326 | .matchExact(HDR_FAR_ID, UPLINK_PHYSICAL_FAR_ID) |
| 327 | .build()).build()) |
| 328 | .withTreatment(DefaultTrafficTreatment.builder() |
| 329 | .piTableAction(PiAction.builder() |
| 330 | .withId(FABRIC_INGRESS_SPGW_LOAD_NORMAL_FAR) |
| 331 | .withParameters(Arrays.asList( |
| 332 | new PiActionParam(DROP, 0), |
| 333 | new PiActionParam(NOTIFY_CP, 0) |
| 334 | )) |
| 335 | .build()).build()) |
| 336 | .withPriority(DEFAULT_PRIORITY) |
| 337 | .build(); |
| 338 | |
| 339 | public static final FlowRule FABRIC_DOWNLINK_FAR = DefaultFlowRule.builder() |
| 340 | .forDevice(DEVICE_ID).fromApp(APP_ID).makePermanent() |
| 341 | .forTable(FABRIC_INGRESS_SPGW_FARS) |
| 342 | .withSelector(DefaultTrafficSelector.builder() |
| 343 | .matchPi(PiCriterion.builder() |
| 344 | .matchExact(HDR_FAR_ID, DOWNLINK_PHYSICAL_FAR_ID) |
| 345 | .build()).build()) |
| 346 | .withTreatment(DefaultTrafficTreatment.builder() |
| 347 | .piTableAction(PiAction.builder() |
| 348 | .withId(FABRIC_INGRESS_SPGW_LOAD_TUNNEL_FAR) |
| 349 | .withParameters(Arrays.asList( |
| 350 | new PiActionParam(DROP, 0), |
| 351 | new PiActionParam(NOTIFY_CP, 0), |
| 352 | new PiActionParam(TEID, TEID_VALUE), |
| 353 | new PiActionParam(TUNNEL_SRC_ADDR, S1U_ADDR.toInt()), |
| 354 | new PiActionParam(TUNNEL_DST_ADDR, ENB_ADDR.toInt()), |
| 355 | new PiActionParam(TUNNEL_SRC_PORT, TUNNEL_SPORT) |
| 356 | )) |
| 357 | .build()).build()) |
| 358 | .withPriority(DEFAULT_PRIORITY) |
| 359 | .build(); |
| 360 | |
| 361 | public static final FlowRule FABRIC_UPLINK_INTERFACE = DefaultFlowRule.builder() |
| 362 | .forDevice(DEVICE_ID).fromApp(APP_ID).makePermanent() |
| 363 | .forTable(FABRIC_INGRESS_SPGW_INTERFACES) |
| 364 | .withSelector(DefaultTrafficSelector.builder() |
| 365 | .matchPi(PiCriterion.builder() |
| 366 | .matchLpm(HDR_IPV4_DST_ADDR, |
| 367 | S1U_ADDR.toInt(), |
| 368 | 32) |
| 369 | .matchExact(HDR_GTPU_IS_VALID, 1) |
| 370 | .build()).build()) |
| 371 | .withTreatment(DefaultTrafficTreatment.builder() |
| 372 | .piTableAction( |
| 373 | PiAction.builder() |
| 374 | .withId(FABRIC_INGRESS_SPGW_LOAD_IFACE) |
| 375 | .withParameter(new PiActionParam(SRC_IFACE, INTERFACE_ACCESS)) |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 376 | .withParameter(new PiActionParam(SLICE_ID, DEFAULT_SLICE_ID)) |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 377 | .build()).build()) |
| 378 | .withPriority(DEFAULT_PRIORITY) |
| 379 | .build(); |
| 380 | |
| 381 | public static final FlowRule FABRIC_DOWNLINK_INTERFACE = DefaultFlowRule.builder() |
| 382 | .forDevice(DEVICE_ID).fromApp(APP_ID).makePermanent() |
| 383 | .forTable(FABRIC_INGRESS_SPGW_INTERFACES) |
| 384 | .withSelector(DefaultTrafficSelector.builder() |
| 385 | .matchPi(PiCriterion.builder() |
| 386 | .matchLpm(HDR_IPV4_DST_ADDR, |
| 387 | UE_POOL.address().toInt(), |
| 388 | UE_POOL.prefixLength()) |
| 389 | .matchExact(HDR_GTPU_IS_VALID, 0) |
| 390 | .build()).build()) |
| 391 | .withTreatment(DefaultTrafficTreatment.builder() |
| 392 | .piTableAction(PiAction.builder() |
| 393 | .withId(FABRIC_INGRESS_SPGW_LOAD_IFACE) |
| 394 | .withParameter(new PiActionParam(SRC_IFACE, INTERFACE_CORE)) |
Daniele Moro | 08c9e7f | 2021-07-28 18:53:34 +0200 | [diff] [blame^] | 395 | .withParameter(new PiActionParam(SLICE_ID, DEFAULT_SLICE_ID)) |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 396 | .build()).build()) |
| 397 | .withPriority(DEFAULT_PRIORITY) |
| 398 | .build(); |
| 399 | |
| 400 | /** |
| 401 | * Hidden constructor for utility class. |
| 402 | */ |
| 403 | private TestUpfConstants() { |
| 404 | } |
| 405 | } |