Daniele Moro | dbcffda | 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 | dbcffda | 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 | /** |
tosinski | a57652d | 2021-11-22 16:53:00 +0100 | [diff] [blame] | 31 | * Removes any state previously created by this API. |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 32 | */ |
| 33 | void cleanUp(); |
| 34 | |
| 35 | /** |
tosinski | a57652d | 2021-11-22 16:53:00 +0100 | [diff] [blame] | 36 | * Applies the given UPF entity to the UPF-programmable device. |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 37 | * |
tosinski | a57652d | 2021-11-22 16:53:00 +0100 | [diff] [blame] | 38 | * @param entity The UPF entity to be applied. |
| 39 | * @throws UpfProgrammableException if the given UPF entity can not be applied or |
| 40 | * the operation is not supported on the given UPF entity. |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 41 | */ |
tosinski | a57652d | 2021-11-22 16:53:00 +0100 | [diff] [blame] | 42 | void apply(UpfEntity entity) throws UpfProgrammableException; |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 43 | |
| 44 | /** |
tosinski | a57652d | 2021-11-22 16:53:00 +0100 | [diff] [blame] | 45 | * Reads all the UPF entities of the given type from the UPF-programmable device. |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 46 | * |
tosinski | a57652d | 2021-11-22 16:53:00 +0100 | [diff] [blame] | 47 | * @param entityType The type of entities to read. |
| 48 | * @return A collection of installed UPF entities. |
| 49 | * @throws UpfProgrammableException if UPF entity type is not available to be read or |
| 50 | * the operation is not supported on the given UPF entity type. |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 51 | */ |
tosinski | a57652d | 2021-11-22 16:53:00 +0100 | [diff] [blame] | 52 | Collection<? extends UpfEntity> readAll(UpfEntityType entityType) throws UpfProgrammableException; |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 53 | |
| 54 | /** |
Daniele Moro | db0e125 | 2022-04-28 19:37:32 +0200 | [diff] [blame^] | 55 | * Reads the given UPF counter type and index from the UPF-programmable device. |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 56 | * |
Daniele Moro | db0e125 | 2022-04-28 19:37:32 +0200 | [diff] [blame^] | 57 | * @param counterIdx The counter index from which to read. |
| 58 | * @param type {@link UpfEntityType} of UPF counter to read |
| 59 | * ({@code COUNTER, INGRESS_COUNTER, EGRESS_COUNTER}) |
tosinski | a57652d | 2021-11-22 16:53:00 +0100 | [diff] [blame] | 60 | * @return The content of the UPF counter. |
| 61 | * @throws UpfProgrammableException if the counter ID is out of bounds. |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 62 | */ |
Daniele Moro | db0e125 | 2022-04-28 19:37:32 +0200 | [diff] [blame^] | 63 | UpfCounter readCounter(int counterIdx, UpfEntityType type) throws UpfProgrammableException; |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 64 | |
| 65 | /** |
Daniele Moro | db0e125 | 2022-04-28 19:37:32 +0200 | [diff] [blame^] | 66 | * Reads the given UPF counter type contents for all indices that are valid |
| 67 | * on the UPF-programmable device. {@code maxCounterId} parameter is used to |
| 68 | * limit the number of counters retrieved from the UPF. If the limit given is |
tosinski | a57652d | 2021-11-22 16:53:00 +0100 | [diff] [blame] | 69 | * larger than the physical limit, the physical limit will be used. |
| 70 | * A limit of -1 removes limitations, and it is equivalent of calling |
Daniele Moro | db0e125 | 2022-04-28 19:37:32 +0200 | [diff] [blame^] | 71 | * {@link #readAll(UpfEntityType)} passing the given {@link UpfEntityType}. |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 72 | * |
Daniele Moro | db0e125 | 2022-04-28 19:37:32 +0200 | [diff] [blame^] | 73 | * @param maxCounterIdx Maximum counter index to retrieve from the UPF device. |
| 74 | * @param type {@link UpfEntityType} of UPF counter to read |
| 75 | * ({@code COUNTER, INGRESS_COUNTER, EGRESS_COUNTER}) |
tosinski | a57652d | 2021-11-22 16:53:00 +0100 | [diff] [blame] | 76 | * @return A collection of UPF counters for all valid hardware counter cells. |
| 77 | * @throws UpfProgrammableException if the counters are unable to be read. |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 78 | */ |
Daniele Moro | db0e125 | 2022-04-28 19:37:32 +0200 | [diff] [blame^] | 79 | Collection<UpfCounter> readCounters(long maxCounterIdx, UpfEntityType type) throws UpfProgrammableException; |
tosinski | a57652d | 2021-11-22 16:53:00 +0100 | [diff] [blame] | 80 | |
| 81 | /** |
| 82 | * Deletes the given UPF entity from the UPF-programmable device. |
| 83 | * |
| 84 | * @param entity The UPF entity to be removed. |
| 85 | * @throws UpfProgrammableException if the given UPF entity is not found or |
| 86 | * the operation is not supported on the given UPF entity. |
| 87 | */ |
| 88 | void delete(UpfEntity entity) throws UpfProgrammableException; |
| 89 | |
| 90 | /** |
| 91 | * Deletes the given UPF entity from the UPF-programmable device. |
| 92 | * |
| 93 | * @param entityType The UPF entity type to be removed. |
| 94 | * @throws UpfProgrammableException if the given UPF entity is not found or |
| 95 | * the operation is not supported on the given UPF entity. |
| 96 | */ |
| 97 | void deleteAll(UpfEntityType entityType) throws UpfProgrammableException; |
| 98 | |
| 99 | /** |
| 100 | * Returns the total number of UPF entities of the given type supported by |
| 101 | * the UPF-programmable device. For entities that have a direction,returns |
| 102 | * the total amount of entities including both the downlink and the uplink |
| 103 | * directions. |
Daniele Moro | db0e125 | 2022-04-28 19:37:32 +0200 | [diff] [blame^] | 104 | * |
tosinski | a57652d | 2021-11-22 16:53:00 +0100 | [diff] [blame] | 105 | * @param entityType The type of UPF programmable entities to retrieve the size from. |
| 106 | * @return The total number of supported UPF entities. |
| 107 | * @throws UpfProgrammableException if the operation is not supported on the given UPF entity. |
| 108 | */ |
| 109 | long tableSize(UpfEntityType entityType) throws UpfProgrammableException; |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 110 | |
| 111 | /** |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 112 | * Instructs the UPF-programmable device to use GTP-U extension PDU Session Container (PSC) when |
| 113 | * doing encap of downlink packets, with the given QoS Flow Identifier (QFI). |
| 114 | * |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 115 | * @throws UpfProgrammableException if operation is not available |
| 116 | */ |
tosinski | a57652d | 2021-11-22 16:53:00 +0100 | [diff] [blame] | 117 | void enablePscEncap() throws UpfProgrammableException; |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 118 | |
| 119 | /** |
tosinski | a57652d | 2021-11-22 16:53:00 +0100 | [diff] [blame] | 120 | * Disable PSC encap previously enabled with {@link #enablePscEncap()}. |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 121 | * |
| 122 | * @throws UpfProgrammableException if operation is not available |
| 123 | */ |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 124 | void disablePscEncap() throws UpfProgrammableException; |
| 125 | |
| 126 | /** |
| 127 | * Sends the given data as a data plane packet-out through this device. Data is expected to |
| 128 | * contain an Ethernet frame. |
Daniele Moro | ac94678 | 2021-06-23 18:09:39 +0200 | [diff] [blame] | 129 | * <p> |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 130 | * The device should process the packet through the pipeline tables to select an output port |
| 131 | * and to apply eventual modifications (e.g., MAC rewrite for routing, pushing a VLAN tag, |
| 132 | * etc.). |
| 133 | * |
| 134 | * @param data Ethernet frame bytes |
Daniele Moro | 6a7cb47 | 2021-07-20 15:18:32 +0200 | [diff] [blame] | 135 | * @throws UpfProgrammableException if operation is not available |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 136 | */ |
Daniele Moro | 6a7cb47 | 2021-07-20 15:18:32 +0200 | [diff] [blame] | 137 | void sendPacketOut(ByteBuffer data) throws UpfProgrammableException; |
Daniele Moro | dbcffda | 2021-06-11 16:41:48 +0200 | [diff] [blame] | 138 | } |