[dpdk-dev] [PATCH v2 1/2] ethdev: add pre-defined meter policy API

Ori Kam orika at nvidia.com
Thu Apr 8 15:55:03 CEST 2021


Hi Li,

> -----Original Message-----
> From: Li Zhang <lizh at nvidia.com>
> Sent: Friday, April 2, 2021 1:36 PM
> Subject: [PATCH v2 1/2] ethdev: add pre-defined meter policy API
> 
> Currently, the flow meter policy does not support multiple actions
> per color; also the allowed action types per color are very limited.
> In addition, the policy cannot be pre-defined.
> 
> Due to the growing in flow actions offload abilities there is a potential
> for the user to use variety of actions per color differently.
> This new meter policy API comes to allow this potential in the most ethdev
> common way using rte_flow action definition.
> A list of rte_flow actions will be provided by the user per color
> in order to create a meter policy.
> In addition, the API forces to pre-define the policy before
> the meters creation in order to allow sharing of single policy
> with multiple meters efficiently.
> 
> meter_policy_id is added into struct rte_mtr_params.
> So that it can get the policy during the meters creation.
> 
> Policy id 0 is default policy. Action per color as below:
> green - nothing, yellow - nothing, red - drop
> 
> Allow coloring the packet using a new rte_flow_action_color
> as could be done by the old policy API,
> 
> The next API function were added:
> - rte_mtr_meter_policy_create
> - rte_mtr_meter_policy_delete
> - rte_mtr_meter_policy_update
> - rte_mtr_meter_policy_validate
> The next struct was changed:
> - rte_mtr_params
> - rte_mtr_capabilities
> The next API was deleted:
> - rte_mtr_policer_actions_update
> 
> To support this API the following app were changed:
> app/test-flow-perf: clean meter policer
> app/testpmd: clean meter policer
> 
> To support this API the following drivers were changed:
> net/softnic: support meter policy API
> 1. cleans meter rte_mtr_policer_action.
> 2. Support policy API to get color action as policer action did.
>    The color action will be mapped into rte_table_action_policer.
> 3. Create default policy if policy id is RTE_MTR_DEFAULT_POLICY_ID.
>    default policy actoins:
>    green - do nothing, yellow - do nothing, red - drop
> 
> net/mlx5: clean meter creation management
> Cleans and breaks part of the current meter management
> in order to allow better design with policy API.
> 
> Signed-off-by: Li Zhang <lizh at nvidia.com>
> Signed-off-by: Haifei Luo <haifeil at nvidia.com>
> ---
>  app/test-flow-perf/main.c                     |   7 -
>  app/test-pmd/cmdline.c                        |   1 -
>  app/test-pmd/cmdline_mtr.c                    | 172 -------
>  app/test-pmd/cmdline_mtr.h                    |   1 -
>  doc/guides/nics/mlx5.rst                      |  12 +
>  doc/guides/prog_guide/rte_flow.rst            |  20 +
>  .../traffic_metering_and_policing.rst         |   9 +-
>  doc/guides/rel_notes/release_21_05.rst        |  14 +-
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst   |  18 -
>  drivers/net/mlx5/mlx5.h                       |  24 +-
>  drivers/net/mlx5/mlx5_flow.c                  |  46 --
>  drivers/net/mlx5/mlx5_flow.h                  |  18 +-
>  drivers/net/mlx5/mlx5_flow_aso.c              |  15 +-
>  drivers/net/mlx5/mlx5_flow_dv.c               | 463 +-----------------
>  drivers/net/mlx5/mlx5_flow_meter.c            | 369 +-------------
>  drivers/net/softnic/rte_eth_softnic_flow.c    |  19 +-
>  .../net/softnic/rte_eth_softnic_internals.h   |  18 +-
>  drivers/net/softnic/rte_eth_softnic_meter.c   | 264 +++++++---
>  lib/librte_ethdev/rte_flow.h                  |  18 +
>  lib/librte_ethdev/rte_mtr.c                   |  55 ++-
>  lib/librte_ethdev/rte_mtr.h                   | 157 ++++--
>  lib/librte_ethdev/rte_mtr_driver.h            |  44 +-
>  lib/librte_ethdev/version.map                 |   4 +
>  23 files changed, 510 insertions(+), 1258 deletions(-)
> 
> diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c
> index 99d0463456..66ec776017 100644
> --- a/app/test-flow-perf/main.c
> +++ b/app/test-flow-perf/main.c
> @@ -924,13 +924,6 @@ create_meter_rule(int port_id, uint32_t counter)
> 
>  	/*create meter*/
>  	params.meter_profile_id = default_prof_id;
> -	params.action[RTE_COLOR_GREEN] =
> -		MTR_POLICER_ACTION_COLOR_GREEN;
> -	params.action[RTE_COLOR_YELLOW] =
> -		MTR_POLICER_ACTION_COLOR_YELLOW;
> -	params.action[RTE_COLOR_RED] =
> -		MTR_POLICER_ACTION_DROP;
> -
>  	ret = rte_mtr_create(port_id, counter, &params, 1, &error);
>  	if (ret != 0) {
>  		printf("Port %u create meter idx(%d) error(%d) message:
> %s\n",
,

[snip]

> 
>  	.stats_read = pmd_mtr_stats_read,
> diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
> index 6cc57136ac..0c5807deea 100644
> --- a/lib/librte_ethdev/rte_flow.h
> +++ b/lib/librte_ethdev/rte_flow.h
> @@ -32,6 +32,7 @@
>  #include <rte_ecpri.h>
>  #include <rte_mbuf.h>
>  #include <rte_mbuf_dyn.h>
> +#include <rte_meter.h>
> 
>  #ifdef __cplusplus
>  extern "C" {
> @@ -2267,6 +2268,13 @@ enum rte_flow_action_type {
>  	 * See struct rte_flow_action_modify_field.
>  	 */
>  	RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
> +
> +	/**
> +	 * Color the packet to reflect the meter color result.
> +	 *
> +	 * See struct rte_flow_action_meter_color.
> +	 */
> +	RTE_FLOW_ACTION_TYPE_METER_COLOR,

Following previous discussion in the ML
I agree to this change with few comments:
1. This action will be experimental and we might change it later
to adjust to other rte_flow actions.
2. please make sure in the doc and comment above that it is documented
That this goes to mbuf field 
Something like:
Set the meter color in the mbuf to the selected color.
Since it doesn't color the packet for the rest of the rte_flow.

[snip]
Best
Ori


More information about the dev mailing list