ethdev: get meter profile/policy objects
Introduce a new Meter API to retrieve a Meter profile and policy objects using the profile/policy ID previously created with meter_profile_add() and meter_policy_create() functions. That allows to save the pointer and avoid any lookups in the corresponding lists for quick access during a flow rule creation. Also, it eliminates the need for CIR, CBS and EBS calculations and conversion to a PMD-specific format when the profile is used. Pointers are destroyed and cannot be used after the corresponding meter_profile_delete() or meter_policy_delete() are called. Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com> Acked-by: Ori Kam <orika@nvidia.com> Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
This commit is contained in:
parent
443401d0f8
commit
ece19cca30
@ -107,6 +107,13 @@ traffic meter and policing library.
|
||||
to the list of meter actions (``struct rte_mtr_meter_policy_params::actions``)
|
||||
specified per color as show in :numref:`figure_rte_mtr_chaining`.
|
||||
|
||||
#. The ``rte_mtr_meter_profile_get()`` and ``rte_mtr_meter_policy_get()``
|
||||
API functions are available for getting the object pointers directly.
|
||||
These pointers allow quick access to profile/policy objects and are
|
||||
required by the ``RTE_FLOW_ACTION_TYPE_METER_MARK`` action.
|
||||
This action may omit the policy definition to provide flexibility
|
||||
to match a color later with the ``RTE_FLOW_ITEM_TYPE_METER_COLOR`` item.
|
||||
|
||||
Protocol based input color selection
|
||||
------------------------------------
|
||||
|
||||
|
@ -78,6 +78,7 @@ New Features
|
||||
|
||||
* Added METER_COLOR item to match color marker set by a meter.
|
||||
* Added ability to set color marker via modify field flow API.
|
||||
* Added meter API to get a pointer to profile/policy by their ID.
|
||||
|
||||
* **Updated Intel iavf driver.**
|
||||
|
||||
|
@ -3688,6 +3688,20 @@ struct rte_flow_action {
|
||||
*/
|
||||
struct rte_flow;
|
||||
|
||||
/**
|
||||
* Opaque type for Meter profile object returned by MTR API.
|
||||
*
|
||||
* This handle can be used to create Meter actions instead of profile ID.
|
||||
*/
|
||||
struct rte_flow_meter_profile;
|
||||
|
||||
/**
|
||||
* Opaque type for Meter policy object returned by MTR API.
|
||||
*
|
||||
* This handle can be used to create Meter actions instead of policy ID.
|
||||
*/
|
||||
struct rte_flow_meter_policy;
|
||||
|
||||
/**
|
||||
* @warning
|
||||
* @b EXPERIMENTAL: this structure may change without prior notice
|
||||
|
@ -56,6 +56,25 @@ rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error)
|
||||
ops->func; \
|
||||
})
|
||||
|
||||
#define RTE_MTR_HNDL_FUNC(port_id, func) \
|
||||
({ \
|
||||
const struct rte_mtr_ops *ops = \
|
||||
rte_mtr_ops_get(port_id, error); \
|
||||
if (ops == NULL) \
|
||||
return NULL; \
|
||||
\
|
||||
if (ops->func == NULL) { \
|
||||
rte_mtr_error_set(error, \
|
||||
ENOSYS, \
|
||||
RTE_MTR_ERROR_TYPE_UNSPECIFIED, \
|
||||
NULL, \
|
||||
rte_strerror(ENOSYS)); \
|
||||
return NULL; \
|
||||
} \
|
||||
\
|
||||
ops->func; \
|
||||
})
|
||||
|
||||
/* MTR capabilities get */
|
||||
int
|
||||
rte_mtr_capabilities_get(uint16_t port_id,
|
||||
@ -90,6 +109,17 @@ rte_mtr_meter_profile_delete(uint16_t port_id,
|
||||
meter_profile_id, error);
|
||||
}
|
||||
|
||||
/** MTR meter profile get */
|
||||
struct rte_flow_meter_profile *
|
||||
rte_mtr_meter_profile_get(uint16_t port_id,
|
||||
uint32_t meter_profile_id,
|
||||
struct rte_mtr_error *error)
|
||||
{
|
||||
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
|
||||
return RTE_MTR_HNDL_FUNC(port_id, meter_profile_get)(dev,
|
||||
meter_profile_id, error);
|
||||
}
|
||||
|
||||
/* MTR meter policy validate */
|
||||
int
|
||||
rte_mtr_meter_policy_validate(uint16_t port_id,
|
||||
@ -124,6 +154,17 @@ rte_mtr_meter_policy_delete(uint16_t port_id,
|
||||
policy_id, error);
|
||||
}
|
||||
|
||||
/** MTR meter policy get */
|
||||
struct rte_flow_meter_policy *
|
||||
rte_mtr_meter_policy_get(uint16_t port_id,
|
||||
uint32_t policy_id,
|
||||
struct rte_mtr_error *error)
|
||||
{
|
||||
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
|
||||
return RTE_MTR_HNDL_FUNC(port_id, meter_policy_get)(dev,
|
||||
policy_id, error);
|
||||
}
|
||||
|
||||
/** MTR object create */
|
||||
int
|
||||
rte_mtr_create(uint16_t port_id,
|
||||
|
@ -623,6 +623,26 @@ rte_mtr_meter_profile_delete(uint16_t port_id,
|
||||
uint32_t meter_profile_id,
|
||||
struct rte_mtr_error *error);
|
||||
|
||||
/**
|
||||
* Meter profile object get
|
||||
*
|
||||
* Get meter profile object for a given meter profile ID.
|
||||
*
|
||||
* @param[in] port_id
|
||||
* The port identifier of the Ethernet device.
|
||||
* @param[in] meter_profile_id
|
||||
* Meter profile ID. Needs to be the valid.
|
||||
* @param[out] error
|
||||
* Error details. Filled in only on error, when not NULL.
|
||||
* @return
|
||||
* A valid handle in case of success, NULL otherwise.
|
||||
*/
|
||||
__rte_experimental
|
||||
struct rte_flow_meter_profile *
|
||||
rte_mtr_meter_profile_get(uint16_t port_id,
|
||||
uint32_t meter_profile_id,
|
||||
struct rte_mtr_error *error);
|
||||
|
||||
/**
|
||||
* Check whether a meter policy can be created on a given port.
|
||||
*
|
||||
@ -679,6 +699,26 @@ rte_mtr_meter_policy_add(uint16_t port_id,
|
||||
struct rte_mtr_meter_policy_params *policy,
|
||||
struct rte_mtr_error *error);
|
||||
|
||||
/**
|
||||
* Meter policy object get
|
||||
*
|
||||
* Get meter policy object for a given meter policy ID.
|
||||
*
|
||||
* @param[in] port_id
|
||||
* The port identifier of the Ethernet device.
|
||||
* @param[in] policy_id
|
||||
* Meter policy ID. Needs to be the valid.
|
||||
* @param[out] error
|
||||
* Error details. Filled in only on error, when not NULL.
|
||||
* @return
|
||||
* A valid handle in case of success, NULL otherwise.
|
||||
*/
|
||||
__rte_experimental
|
||||
struct rte_flow_meter_policy *
|
||||
rte_mtr_meter_policy_get(uint16_t port_id,
|
||||
uint32_t policy_id,
|
||||
struct rte_mtr_error *error);
|
||||
|
||||
/**
|
||||
* Define meter policy action list:
|
||||
* GREEN - GREEN, YELLOW - YELLOW, RED - RED
|
||||
|
@ -41,6 +41,12 @@ typedef int (*rte_mtr_meter_profile_delete_t)(struct rte_eth_dev *dev,
|
||||
uint32_t meter_profile_id,
|
||||
struct rte_mtr_error *error);
|
||||
|
||||
/** @internal MTR meter profile get. */
|
||||
typedef struct rte_flow_meter_profile *
|
||||
(*rte_mtr_meter_profile_get_t)(struct rte_eth_dev *dev,
|
||||
uint32_t meter_profile_id,
|
||||
struct rte_mtr_error *error);
|
||||
|
||||
/** @internal MTR meter policy validate. */
|
||||
typedef int (*rte_mtr_meter_policy_validate_t)(struct rte_eth_dev *dev,
|
||||
struct rte_mtr_meter_policy_params *policy,
|
||||
@ -57,6 +63,13 @@ typedef int (*rte_mtr_meter_policy_delete_t)(struct rte_eth_dev *dev,
|
||||
uint32_t policy_id,
|
||||
struct rte_mtr_error *error);
|
||||
|
||||
/** @internal MTR meter policy get. */
|
||||
typedef struct rte_flow_meter_policy *
|
||||
(*rte_mtr_meter_policy_get_t)(struct rte_eth_dev *dev,
|
||||
uint32_t policy_id,
|
||||
struct rte_mtr_error *error);
|
||||
|
||||
|
||||
/** @internal MTR object create. */
|
||||
typedef int (*rte_mtr_create_t)(struct rte_eth_dev *dev,
|
||||
uint32_t mtr_id,
|
||||
@ -194,6 +207,12 @@ struct rte_mtr_ops {
|
||||
|
||||
/** MTR object meter policy update */
|
||||
rte_mtr_meter_policy_update_t meter_policy_update;
|
||||
|
||||
/** MTR meter profile get */
|
||||
rte_mtr_meter_profile_get_t meter_profile_get;
|
||||
|
||||
/** MTR meter policy get */
|
||||
rte_mtr_meter_policy_get_t meter_policy_get;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -288,6 +288,8 @@ EXPERIMENTAL {
|
||||
|
||||
# added in 22.11
|
||||
rte_flow_async_action_handle_query;
|
||||
rte_mtr_meter_policy_get;
|
||||
rte_mtr_meter_profile_get;
|
||||
};
|
||||
|
||||
INTERNAL {
|
||||
|
Loading…
Reference in New Issue
Block a user