Refactor of UpfProgrammable APIs
Change-Id: I792659ad4a163d7115d7320bb33c11534edd484a
Signed-off-by: Daniele Moro <daniele@opennetworking.org>
(cherry picked from commit a57652d92bdd01b1e77bffbac78a44f96fb385f3)
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/upf/UpfDevice.java b/core/api/src/main/java/org/onosproject/net/behaviour/upf/UpfDevice.java
index e0d9fb4..2b17421 100644
--- a/core/api/src/main/java/org/onosproject/net/behaviour/upf/UpfDevice.java
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/upf/UpfDevice.java
@@ -28,157 +28,94 @@
public interface UpfDevice {
/**
- * Remove any state previously created by this API.
+ * Removes any state previously created by this API.
*/
void cleanUp();
/**
- * Remove all interfaces currently installed on the UPF-programmable device.
- */
- void clearInterfaces();
-
- /**
- * Remove all UE flows (PDRs, FARs) currently installed on the UPF-programmable device.
- */
- void clearFlows();
-
- /**
- * Get all ForwardingActionRules currently installed on the UPF-programmable device.
+ * Applies the given UPF entity to the UPF-programmable device.
*
- * @return a collection of installed FARs
- * @throws UpfProgrammableException if FARs are unable to be read
+ * @param entity The UPF entity to be applied.
+ * @throws UpfProgrammableException if the given UPF entity can not be applied or
+ * the operation is not supported on the given UPF entity.
*/
- Collection<ForwardingActionRule> getFars() throws UpfProgrammableException;
+ void apply(UpfEntity entity) throws UpfProgrammableException;
/**
- * Get all PacketDetectionRules currently installed on the UPF-programmable device.
+ * Reads all the UPF entities of the given type from the UPF-programmable device.
*
- * @return a collection of installed PDRs
- * @throws UpfProgrammableException if PDRs are unable to be read
+ * @param entityType The type of entities to read.
+ * @return A collection of installed UPF entities.
+ * @throws UpfProgrammableException if UPF entity type is not available to be read or
+ * the operation is not supported on the given UPF entity type.
*/
- Collection<PacketDetectionRule> getPdrs() throws UpfProgrammableException;
+ Collection<? extends UpfEntity> readAll(UpfEntityType entityType) throws UpfProgrammableException;
/**
- * Get all UPF interface lookup entries currently installed on the UPF-programmable device.
+ * Reads the given UPF counter ID from the UPF-programmable device.
*
- * @return a collection of installed interfaces
- * @throws UpfProgrammableException if interfaces are unable to be read
+ * @param counterId The counter ID from which to read.
+ * @return The content of the UPF counter.
+ * @throws UpfProgrammableException if the counter ID is out of bounds.
*/
- Collection<UpfInterface> getInterfaces() throws UpfProgrammableException;
+ UpfCounter readCounter(int counterId) throws UpfProgrammableException;
/**
- * Add a Packet Detection Rule (PDR) to the given device.
- *
- * @param pdr The PDR to be added
- * @throws UpfProgrammableException if the PDR cannot be installed, or the counter index is out
- * of bounds
- */
- void addPdr(PacketDetectionRule pdr) throws UpfProgrammableException;
-
- /**
- * Remove a previously installed Packet Detection Rule (PDR) from the target device.
- *
- * @param pdr The PDR to be removed
- * @throws UpfProgrammableException if the PDR cannot be found
- */
- void removePdr(PacketDetectionRule pdr) throws UpfProgrammableException;
-
- /**
- * Add a Forwarding Action Rule (FAR) to the given device.
- *
- * @param far The FAR to be added
- * @throws UpfProgrammableException if the FAR cannot be installed
- */
- void addFar(ForwardingActionRule far) throws UpfProgrammableException;
-
- /**
- * Remove a previously installed Forwarding Action Rule (FAR) from the target device.
- *
- * @param far The FAR to be removed
- * @throws UpfProgrammableException if the FAR cannot be found
- */
- void removeFar(ForwardingActionRule far) throws UpfProgrammableException;
-
- /**
- * Install a new interface on the UPF device's interface lookup tables.
- *
- * @param upfInterface the interface to install
- * @throws UpfProgrammableException if the interface cannot be installed
- */
- void addInterface(UpfInterface upfInterface) throws UpfProgrammableException;
-
- /**
- * Remove a previously installed UPF interface from the target device.
- *
- * @param upfInterface the interface to be removed
- * @throws UpfProgrammableException if the interface cannot be found
- */
- void removeInterface(UpfInterface upfInterface) throws UpfProgrammableException;
-
- /**
- * Read the the given cell (Counter index) of the PDR counters from the given device.
- *
- * @param counterIdx The counter cell index from which to read
- * @return A structure containing ingress and egress packet and byte counts for the given
- * cellId.
- * @throws UpfProgrammableException if the cell ID is out of bounds
- */
- PdrStats readCounter(int counterIdx) throws UpfProgrammableException;
-
- /**
- * Return the number of PDR counter cells available. The number of cells in the ingress and
- * egress PDR counters are equivalent.
- *
- * @return PDR counter size
- */
- long pdrCounterSize();
-
- /**
- * Return the number of maximum number of table entries the FAR table supports.
- *
- * @return the number of FARs that can be installed
- */
- long farTableSize();
-
- /**
- * Return the total number of table entries the downlink and uplink PDR tables support. Both
- * tables support an equal number of entries, so the total is twice the size of either.
- *
- * @return the total number of PDRs that can be installed
- */
- long pdrTableSize();
-
- /**
- * Read the counter contents for all cell indices that are valid on the hardware switch.
- * {@code maxCounterId} parameter is used to limit the number of counters
- * retrieved from the UPF device. If the limit given is larger than the
- * physical limit, the physical limit will be used. A limit of -1 removes
- * limitations.
+ * Reads the UPF counter contents for all indices that are valid on the
+ * UPF-programmable device. {@code maxCounterId} parameter is used to limit
+ * the number of counters retrieved from the UPF. If the limit given is
+ * larger than the physical limit, the physical limit will be used.
+ * A limit of -1 removes limitations, and it is equivalent of calling
+ * {@link #readAll(UpfEntityType)} passing the {@code COUNTER} {@link UpfEntityType}.
*
* @param maxCounterId Maximum counter ID to retrieve from the UPF device.
- * @return A collection of counter values for all valid hardware counter cells
- * @throws UpfProgrammableException if the counters are unable to be read
+ * @return A collection of UPF counters for all valid hardware counter cells.
+ * @throws UpfProgrammableException if the counters are unable to be read.
*/
- Collection<PdrStats> readAllCounters(long maxCounterId) throws UpfProgrammableException;
+ Collection<UpfCounter> readCounters(long maxCounterId) throws UpfProgrammableException;
+
+ /**
+ * Deletes the given UPF entity from the UPF-programmable device.
+ *
+ * @param entity The UPF entity to be removed.
+ * @throws UpfProgrammableException if the given UPF entity is not found or
+ * the operation is not supported on the given UPF entity.
+ */
+ void delete(UpfEntity entity) throws UpfProgrammableException;
+
+ /**
+ * Deletes the given UPF entity from the UPF-programmable device.
+ *
+ * @param entityType The UPF entity type to be removed.
+ * @throws UpfProgrammableException if the given UPF entity is not found or
+ * the operation is not supported on the given UPF entity.
+ */
+ void deleteAll(UpfEntityType entityType) throws UpfProgrammableException;
+
+ /**
+ * Returns the total number of UPF entities of the given type supported by
+ * the UPF-programmable device. For entities that have a direction,returns
+ * the total amount of entities including both the downlink and the uplink
+ * directions.
+ * @param entityType The type of UPF programmable entities to retrieve the size from.
+ * @return The total number of supported UPF entities.
+ * @throws UpfProgrammableException if the operation is not supported on the given UPF entity.
+ */
+ long tableSize(UpfEntityType entityType) throws UpfProgrammableException;
/**
* Instructs the UPF-programmable device to use GTP-U extension PDU Session Container (PSC) when
* doing encap of downlink packets, with the given QoS Flow Identifier (QFI).
*
- * @param defaultQfi QFI to be used by default for all encapped packets.
* @throws UpfProgrammableException if operation is not available
*/
- // FIXME: remove once we expose QFI in logical pipeline
- // QFI should be set by the SMF using PFCP
- void enablePscEncap(int defaultQfi) throws UpfProgrammableException;
+ void enablePscEncap() throws UpfProgrammableException;
/**
- * Disable PSC encap previously enabled with {@link #enablePscEncap(int)}.
+ * Disable PSC encap previously enabled with {@link #enablePscEncap()}.
*
* @throws UpfProgrammableException if operation is not available
*/
- // FIXME: remove once we expose QFI in logical pipeline
- // QFI should be set by the SMF using PFCP
void disablePscEncap() throws UpfProgrammableException;
/**