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