blob: 738d6b6f4bdf7bc62d68a085b99d1b78ca3b99fd [file] [log] [blame]
Daniele Morodbcffda2021-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 Morodbcffda2021-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 /**
tosinskia57652d2021-11-22 16:53:00 +010031 * Removes any state previously created by this API.
Daniele Morodbcffda2021-06-11 16:41:48 +020032 */
33 void cleanUp();
34
35 /**
tosinskia57652d2021-11-22 16:53:00 +010036 * Applies the given UPF entity to the UPF-programmable device.
Daniele Morodbcffda2021-06-11 16:41:48 +020037 *
tosinskia57652d2021-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 Morodbcffda2021-06-11 16:41:48 +020041 */
tosinskia57652d2021-11-22 16:53:00 +010042 void apply(UpfEntity entity) throws UpfProgrammableException;
Daniele Morodbcffda2021-06-11 16:41:48 +020043
44 /**
tosinskia57652d2021-11-22 16:53:00 +010045 * Reads all the UPF entities of the given type from the UPF-programmable device.
Daniele Morodbcffda2021-06-11 16:41:48 +020046 *
tosinskia57652d2021-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 Morodbcffda2021-06-11 16:41:48 +020051 */
tosinskia57652d2021-11-22 16:53:00 +010052 Collection<? extends UpfEntity> readAll(UpfEntityType entityType) throws UpfProgrammableException;
Daniele Morodbcffda2021-06-11 16:41:48 +020053
54 /**
Daniele Morodb0e1252022-04-28 19:37:32 +020055 * Reads the given UPF counter type and index from the UPF-programmable device.
Daniele Morodbcffda2021-06-11 16:41:48 +020056 *
Daniele Morodb0e1252022-04-28 19:37:32 +020057 * @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})
tosinskia57652d2021-11-22 16:53:00 +010060 * @return The content of the UPF counter.
61 * @throws UpfProgrammableException if the counter ID is out of bounds.
Daniele Morodbcffda2021-06-11 16:41:48 +020062 */
Daniele Morodb0e1252022-04-28 19:37:32 +020063 UpfCounter readCounter(int counterIdx, UpfEntityType type) throws UpfProgrammableException;
Daniele Morodbcffda2021-06-11 16:41:48 +020064
65 /**
Daniele Morodb0e1252022-04-28 19:37:32 +020066 * 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
tosinskia57652d2021-11-22 16:53:00 +010069 * 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 Morodb0e1252022-04-28 19:37:32 +020071 * {@link #readAll(UpfEntityType)} passing the given {@link UpfEntityType}.
Daniele Morodbcffda2021-06-11 16:41:48 +020072 *
Daniele Morodb0e1252022-04-28 19:37:32 +020073 * @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})
tosinskia57652d2021-11-22 16:53:00 +010076 * @return A collection of UPF counters for all valid hardware counter cells.
77 * @throws UpfProgrammableException if the counters are unable to be read.
Daniele Morodbcffda2021-06-11 16:41:48 +020078 */
Daniele Morodb0e1252022-04-28 19:37:32 +020079 Collection<UpfCounter> readCounters(long maxCounterIdx, UpfEntityType type) throws UpfProgrammableException;
tosinskia57652d2021-11-22 16:53:00 +010080
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 Morodb0e1252022-04-28 19:37:32 +0200104 *
tosinskia57652d2021-11-22 16:53:00 +0100105 * @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 Morodbcffda2021-06-11 16:41:48 +0200110
111 /**
Daniele Morodbcffda2021-06-11 16:41:48 +0200112 * 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 Morodbcffda2021-06-11 16:41:48 +0200115 * @throws UpfProgrammableException if operation is not available
116 */
tosinskia57652d2021-11-22 16:53:00 +0100117 void enablePscEncap() throws UpfProgrammableException;
Daniele Morodbcffda2021-06-11 16:41:48 +0200118
119 /**
tosinskia57652d2021-11-22 16:53:00 +0100120 * Disable PSC encap previously enabled with {@link #enablePscEncap()}.
Daniele Morodbcffda2021-06-11 16:41:48 +0200121 *
122 * @throws UpfProgrammableException if operation is not available
123 */
Daniele Morodbcffda2021-06-11 16:41:48 +0200124 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 Moroac946782021-06-23 18:09:39 +0200129 * <p>
Daniele Morodbcffda2021-06-11 16:41:48 +0200130 * 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 Moro6a7cb472021-07-20 15:18:32 +0200135 * @throws UpfProgrammableException if operation is not available
Daniele Morodbcffda2021-06-11 16:41:48 +0200136 */
Daniele Moro6a7cb472021-07-20 15:18:32 +0200137 void sendPacketOut(ByteBuffer data) throws UpfProgrammableException;
Daniele Morodbcffda2021-06-11 16:41:48 +0200138}