blob: 2b17421cac428c92964f2c975a81fb071c1360f7 [file] [log] [blame]
Daniele Moro5e66f982021-06-11 16:41:48 +02001/*
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
17package org.onosproject.net.behaviour.upf;
18
19import com.google.common.annotations.Beta;
Daniele Moro5e66f982021-06-11 16:41:48 +020020
21import java.nio.ByteBuffer;
22import java.util.Collection;
23
24/**
25 * Provides means to update forwarding state to implement a 3GPP User Plane Function.
26 */
27@Beta
28public interface UpfDevice {
29
30 /**
tosinski36ba33a2021-11-22 16:53:00 +010031 * Removes any state previously created by this API.
Daniele Moro5e66f982021-06-11 16:41:48 +020032 */
33 void cleanUp();
34
35 /**
tosinski36ba33a2021-11-22 16:53:00 +010036 * Applies the given UPF entity to the UPF-programmable device.
Daniele Moro5e66f982021-06-11 16:41:48 +020037 *
tosinski36ba33a2021-11-22 16:53:00 +010038 * @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 Moro5e66f982021-06-11 16:41:48 +020041 */
tosinski36ba33a2021-11-22 16:53:00 +010042 void apply(UpfEntity entity) throws UpfProgrammableException;
Daniele Moro5e66f982021-06-11 16:41:48 +020043
44 /**
tosinski36ba33a2021-11-22 16:53:00 +010045 * Reads all the UPF entities of the given type from the UPF-programmable device.
Daniele Moro5e66f982021-06-11 16:41:48 +020046 *
tosinski36ba33a2021-11-22 16:53:00 +010047 * @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 Moro5e66f982021-06-11 16:41:48 +020051 */
tosinski36ba33a2021-11-22 16:53:00 +010052 Collection<? extends UpfEntity> readAll(UpfEntityType entityType) throws UpfProgrammableException;
Daniele Moro5e66f982021-06-11 16:41:48 +020053
54 /**
tosinski36ba33a2021-11-22 16:53:00 +010055 * Reads the given UPF counter ID from the UPF-programmable device.
Daniele Moro5e66f982021-06-11 16:41:48 +020056 *
tosinski36ba33a2021-11-22 16:53:00 +010057 * @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 Moro5e66f982021-06-11 16:41:48 +020060 */
tosinski36ba33a2021-11-22 16:53:00 +010061 UpfCounter readCounter(int counterId) throws UpfProgrammableException;
Daniele Moro5e66f982021-06-11 16:41:48 +020062
63 /**
tosinski36ba33a2021-11-22 16:53:00 +010064 * 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 Moro5e66f982021-06-11 16:41:48 +020070 *
71 * @param maxCounterId Maximum counter ID to retrieve from the UPF device.
tosinski36ba33a2021-11-22 16:53:00 +010072 * @return A collection of UPF counters for all valid hardware counter cells.
73 * @throws UpfProgrammableException if the counters are unable to be read.
Daniele Moro5e66f982021-06-11 16:41:48 +020074 */
tosinski36ba33a2021-11-22 16:53:00 +010075 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 Moro5e66f982021-06-11 16:41:48 +0200105
106 /**
Daniele Moro5e66f982021-06-11 16:41:48 +0200107 * 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 Moro5e66f982021-06-11 16:41:48 +0200110 * @throws UpfProgrammableException if operation is not available
111 */
tosinski36ba33a2021-11-22 16:53:00 +0100112 void enablePscEncap() throws UpfProgrammableException;
Daniele Moro5e66f982021-06-11 16:41:48 +0200113
114 /**
tosinski36ba33a2021-11-22 16:53:00 +0100115 * Disable PSC encap previously enabled with {@link #enablePscEncap()}.
Daniele Moro5e66f982021-06-11 16:41:48 +0200116 *
117 * @throws UpfProgrammableException if operation is not available
118 */
Daniele Moro5e66f982021-06-11 16:41:48 +0200119 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 Morof8517ca2021-06-23 18:09:39 +0200124 * <p>
Daniele Moro5e66f982021-06-11 16:41:48 +0200125 * 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 Moro0d8aef52021-07-20 15:18:32 +0200130 * @throws UpfProgrammableException if operation is not available
Daniele Moro5e66f982021-06-11 16:41:48 +0200131 */
Daniele Moro0d8aef52021-07-20 15:18:32 +0200132 void sendPacketOut(ByteBuffer data) throws UpfProgrammableException;
Daniele Moro5e66f982021-06-11 16:41:48 +0200133}