Daniele Moro | 5e66f98 | 2021-06-11 16:41:48 +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.net.behaviour.upf; |
| 18 | |
| 19 | import com.google.common.annotations.Beta; |
Daniele Moro | 5e66f98 | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 20 | |
| 21 | import java.nio.ByteBuffer; |
| 22 | import java.util.Collection; |
| 23 | |
| 24 | /** |
| 25 | * Provides means to update forwarding state to implement a 3GPP User Plane Function. |
| 26 | */ |
| 27 | @Beta |
| 28 | public interface UpfDevice { |
| 29 | |
| 30 | /** |
| 31 | * Remove any state previously created by this API. |
| 32 | */ |
| 33 | void cleanUp(); |
| 34 | |
| 35 | /** |
| 36 | * Remove all interfaces currently installed on the UPF-programmable device. |
| 37 | */ |
| 38 | void clearInterfaces(); |
| 39 | |
| 40 | /** |
| 41 | * Remove all UE flows (PDRs, FARs) currently installed on the UPF-programmable device. |
| 42 | */ |
| 43 | void clearFlows(); |
| 44 | |
| 45 | /** |
| 46 | * Get all ForwardingActionRules currently installed on the UPF-programmable device. |
| 47 | * |
| 48 | * @return a collection of installed FARs |
| 49 | * @throws UpfProgrammableException if FARs are unable to be read |
| 50 | */ |
| 51 | Collection<ForwardingActionRule> getFars() throws UpfProgrammableException; |
| 52 | |
| 53 | /** |
| 54 | * Get all PacketDetectionRules currently installed on the UPF-programmable device. |
| 55 | * |
| 56 | * @return a collection of installed PDRs |
| 57 | * @throws UpfProgrammableException if PDRs are unable to be read |
| 58 | */ |
| 59 | Collection<PacketDetectionRule> getPdrs() throws UpfProgrammableException; |
| 60 | |
| 61 | /** |
| 62 | * Get all UPF interface lookup entries currently installed on the UPF-programmable device. |
| 63 | * |
| 64 | * @return a collection of installed interfaces |
| 65 | * @throws UpfProgrammableException if interfaces are unable to be read |
| 66 | */ |
| 67 | Collection<UpfInterface> getInterfaces() throws UpfProgrammableException; |
| 68 | |
| 69 | /** |
| 70 | * Add a Packet Detection Rule (PDR) to the given device. |
| 71 | * |
| 72 | * @param pdr The PDR to be added |
| 73 | * @throws UpfProgrammableException if the PDR cannot be installed, or the counter index is out |
| 74 | * of bounds |
| 75 | */ |
| 76 | void addPdr(PacketDetectionRule pdr) throws UpfProgrammableException; |
| 77 | |
| 78 | /** |
| 79 | * Remove a previously installed Packet Detection Rule (PDR) from the target device. |
| 80 | * |
| 81 | * @param pdr The PDR to be removed |
| 82 | * @throws UpfProgrammableException if the PDR cannot be found |
| 83 | */ |
| 84 | void removePdr(PacketDetectionRule pdr) throws UpfProgrammableException; |
| 85 | |
| 86 | /** |
| 87 | * Add a Forwarding Action Rule (FAR) to the given device. |
| 88 | * |
| 89 | * @param far The FAR to be added |
| 90 | * @throws UpfProgrammableException if the FAR cannot be installed |
| 91 | */ |
| 92 | void addFar(ForwardingActionRule far) throws UpfProgrammableException; |
| 93 | |
| 94 | /** |
| 95 | * Remove a previously installed Forwarding Action Rule (FAR) from the target device. |
| 96 | * |
| 97 | * @param far The FAR to be removed |
| 98 | * @throws UpfProgrammableException if the FAR cannot be found |
| 99 | */ |
| 100 | void removeFar(ForwardingActionRule far) throws UpfProgrammableException; |
| 101 | |
| 102 | /** |
| 103 | * Install a new interface on the UPF device's interface lookup tables. |
| 104 | * |
| 105 | * @param upfInterface the interface to install |
| 106 | * @throws UpfProgrammableException if the interface cannot be installed |
| 107 | */ |
| 108 | void addInterface(UpfInterface upfInterface) throws UpfProgrammableException; |
| 109 | |
| 110 | /** |
| 111 | * Remove a previously installed UPF interface from the target device. |
| 112 | * |
| 113 | * @param upfInterface the interface to be removed |
| 114 | * @throws UpfProgrammableException if the interface cannot be found |
| 115 | */ |
| 116 | void removeInterface(UpfInterface upfInterface) throws UpfProgrammableException; |
| 117 | |
| 118 | /** |
| 119 | * Read the the given cell (Counter index) of the PDR counters from the given device. |
| 120 | * |
| 121 | * @param counterIdx The counter cell index from which to read |
| 122 | * @return A structure containing ingress and egress packet and byte counts for the given |
| 123 | * cellId. |
| 124 | * @throws UpfProgrammableException if the cell ID is out of bounds |
| 125 | */ |
| 126 | PdrStats readCounter(int counterIdx) throws UpfProgrammableException; |
| 127 | |
| 128 | /** |
| 129 | * Return the number of PDR counter cells available. The number of cells in the ingress and |
| 130 | * egress PDR counters are equivalent. |
| 131 | * |
| 132 | * @return PDR counter size |
| 133 | */ |
| 134 | long pdrCounterSize(); |
| 135 | |
| 136 | /** |
| 137 | * Return the number of maximum number of table entries the FAR table supports. |
| 138 | * |
| 139 | * @return the number of FARs that can be installed |
| 140 | */ |
| 141 | long farTableSize(); |
| 142 | |
| 143 | /** |
| 144 | * Return the total number of table entries the downlink and uplink PDR tables support. Both |
| 145 | * tables support an equal number of entries, so the total is twice the size of either. |
| 146 | * |
| 147 | * @return the total number of PDRs that can be installed |
| 148 | */ |
| 149 | long pdrTableSize(); |
| 150 | |
| 151 | /** |
| 152 | * Read the counter contents for all cell indices that are valid on the hardware switch. |
Daniele Moro | f8517ca | 2021-06-23 18:09:39 +0200 | [diff] [blame^] | 153 | * {@code maxCounterId} parameter is used to limit the number of counters |
Daniele Moro | 5e66f98 | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 154 | * retrieved from the UPF device. If the limit given is larger than the |
| 155 | * physical limit, the physical limit will be used. A limit of -1 removes |
| 156 | * limitations. |
| 157 | * |
| 158 | * @param maxCounterId Maximum counter ID to retrieve from the UPF device. |
| 159 | * @return A collection of counter values for all valid hardware counter cells |
| 160 | * @throws UpfProgrammableException if the counters are unable to be read |
| 161 | */ |
| 162 | Collection<PdrStats> readAllCounters(long maxCounterId) throws UpfProgrammableException; |
| 163 | |
| 164 | /** |
Daniele Moro | 5e66f98 | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 165 | * Instructs the UPF-programmable device to use GTP-U extension PDU Session Container (PSC) when |
| 166 | * doing encap of downlink packets, with the given QoS Flow Identifier (QFI). |
| 167 | * |
| 168 | * @param defaultQfi QFI to be used by default for all encapped packets. |
| 169 | * @throws UpfProgrammableException if operation is not available |
| 170 | */ |
| 171 | // FIXME: remove once we expose QFI in logical pipeline |
| 172 | // QFI should be set by the SMF using PFCP |
| 173 | void enablePscEncap(int defaultQfi) throws UpfProgrammableException; |
| 174 | |
| 175 | /** |
| 176 | * Disable PSC encap previously enabled with {@link #enablePscEncap(int)}. |
| 177 | * |
| 178 | * @throws UpfProgrammableException if operation is not available |
| 179 | */ |
| 180 | // FIXME: remove once we expose QFI in logical pipeline |
| 181 | // QFI should be set by the SMF using PFCP |
| 182 | void disablePscEncap() throws UpfProgrammableException; |
| 183 | |
| 184 | /** |
| 185 | * Sends the given data as a data plane packet-out through this device. Data is expected to |
| 186 | * contain an Ethernet frame. |
Daniele Moro | f8517ca | 2021-06-23 18:09:39 +0200 | [diff] [blame^] | 187 | * <p> |
Daniele Moro | 5e66f98 | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 188 | * The device should process the packet through the pipeline tables to select an output port |
| 189 | * and to apply eventual modifications (e.g., MAC rewrite for routing, pushing a VLAN tag, |
| 190 | * etc.). |
| 191 | * |
| 192 | * @param data Ethernet frame bytes |
| 193 | */ |
| 194 | void sendPacketOut(ByteBuffer data); |
Daniele Moro | 5e66f98 | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 195 | } |