: ethdev: add pre-defined meter policy API
PATCH v6 1/2 ethdev: add pre-defined meter policy API
In reply to Li ZhangCurrently, 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.
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.
net/mlx5: clean meter creation management Cleans and breaks part of the current meter management in order to allow better design with policy API.
--- 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/prog_guide/rte_flow.rst | 21 + .../traffic_metering_and_policing.rst | 16 +- doc/guides/rel_notes/release_21_05.rst | 22 +- 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 | 8 +- drivers/net/mlx5/mlx5_flow_dv.c | 461 +----------------- 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 | 22 + lib/librte_ethdev/rte_mtr.c | 55 ++- lib/librte_ethdev/rte_mtr.h | 162 ++++-- lib/librte_ethdev/rte_mtr_driver.h | 44 +- lib/librte_ethdev/version.map | 5 +- 22 files changed, 515 insertions(+), 1258 deletions(-)
app/test-flow-perf/main.c +0 -7
@@ -928,13 +928,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, ¶ms,1 , &error);if (ret !=0 ) { printf("Port %u create meter idx(%d) error(%d) message: %s\n",
app/test-pmd/cmdline.c +0 -1
@@ -17071,7 +17071,6 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_del_port_meter, (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, - (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, (cmdline_parse_inst_t *)&cmd_mcast_addr,
app/test-pmd/cmdline_mtr.c +0 -172
196 lines not on this page · raw message
app/test-pmd/cmdline_mtr.h +0 -1
@@ -17,7 +17,6 @@ extern cmdline_parse_inst_t cmd_disable_port_meter;extern cmdline_parse_inst_t cmd_del_port_meter;extern cmdline_parse_inst_t cmd_set_port_meter_profile;extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table; -extern cmdline_parse_inst_t cmd_set_port_meter_policer_action;extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;extern cmdline_parse_inst_t cmd_show_port_meter_stats;
doc/guides/prog_guide/rte_flow.rst +21 -0
@@ -2841,6 +2841,27 @@ for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. | ``value`` | immediate value or a pointer to this value | +---------------+----------------------------------------------------------+ +Action: ``METER_COLOR`` +^^^^^^^^^^^^^^^^^^^^^^^ + +Color the packet to reflect the meter color result. + +The meter action must be configured before meter color action. +Meter color action is set to a color to reflect the meter color result. +Set the meter color in the mbuf to the selected color. +The meter color action output color is the output color of the packet, +which is set in the packet meta-data (i.e. struct ``rte_mbuf::sched::color``) + +.. _table_rte_flow_action_meter_color: + +.. table:: METER_COLOR + + +-----------------+--------------+ + | Field | Value | + +=================+==============+ + | ``meter_color`` | Packet color | + +-----------------+--------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/prog_guide/traffic_metering_and_policing.rst +4 -12
@@ -56,18 +56,10 @@ The processing done for each input packet hitting an MTR object is: color blind mode, which is equivalent to considering all input packets initially colored as green. -* Policing: There is a separate policer action configured for each meter - output color, which can: - - * Drop the packet. - - * Keep the same packet color: the policer output color matches the meter - output color (essentially a no-op action). - - * Recolor the packet: the policer output color is set to a different color - than the meter output color. The policer output color is the output color - of the packet, which is set in the packet meta-data (i.e. struct - ``rte_mbuf::sched::color``). +* There is a meter policy API to manage pre-defined policies for meter. + Any rte_flow action list can be configured per color for each policy. + A meter object configured with a policy executes the actions per packet + according to the packet color. * Statistics: The set of counters maintained for each MTR object is configurable and subject to the implementation support. This set includes
doc/guides/rel_notes/release_21_05.rst +21 -1
@@ -174,7 +174,27 @@ New Features ``dpdk-testpmd -- --eth-link-speed N`` * Added command to display Rx queue used descriptor count. ``show port (port_id) rxq (queue_id) desc used count`` - + * deleted the port meter policer action command . + ``set port meter policer action (port_id) (mtr_id) (action_mask) ...`` + * Added command to create meter policy. + ``add port meter policy (port_id) (policy_id) g_actions {action} end y_actions {action} end r_actions {action} end`` + * Added command to delete meter policy. + ``del port meter policy (port_id) (policy_id)`` + +* **Updated meter API.** + + * ethdev: Deleted meter policer API to support policy API. + ``rte_mtr_policer_actions_update()`` + * ethdev: Added meter API to support pre-defined policy, rte_flow action list per color. + ``rte_mtr_meter_policy_add()``, ``rte_mtr_meter_policy_delete()`` and + ``rte_mtr_create_with_policy()`` + * ethdev: Removed rte_mtr_policer_action from rte_mtr_params structures. + * ethdev: Added rte_mtr_meter_policy_params structures to support policy API. + * ethdev: Added meter_policy_id into rte_mtr_params structures. + * ethdev: Removed policer_action_recolor_supported and policer_action_drop_supported from rte_mtr_capabilities structures. + * ethdev: Added meter_policy_n_max into rte_mtr_capabilities structures. + * ethdev: Added RTE_FLOW_ACTION_TYPE_METER_COLOR in enum rte_flow_action_type. + * ethdev: Added RTE_MTR_ERROR_TYPE_METER_POLICY_ID and RTE_MTR_ERROR_TYPE_METER_POLICY_ID into rte_mtr_error_type. Removed Items -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -18
@@ -2830,24 +2830,6 @@ Set meter dscp table for the ethernet device:: testpmd> set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0) \ (dscp_tbl_entry1)...(dscp_tbl_entry63)] -set port meter policer action -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Set meter policer action for the ethernet device:: - - testpmd> set port meter policer action (port_id) (mtr_id) (action_mask) \ - (action0) [(action1) (action1)] - -where: - -* ``action_mask``: Bit mask indicating which policer actions need to be - updated. One or more policer actions can be updated in a single function - invocation. To update the policer action associated with color C, bit - (1 << C) needs to be set in *action_mask* and element at position C - in the *actions* array needs to be valid. -* ``actionx``: Policer action for the color x, - RTE_MTR_GREEN <= x < RTE_MTR_COLORS - set port meter stats mask ~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/mlx5/mlx5.h +2 -22
@@ -584,14 +584,6 @@ struct mlx5_dev_shared_port {/* Modify this value if enum rte_mtr_color changes. */ #define RTE_MTR_DROPPED RTE_COLORS -/* Meter policer statistics */ -struct mlx5_flow_policer_stats { -uint32_t pass_cnt; -/**< Color counter for pass. */ -uint32_t drop_cnt; -/**< Color counter for drop. */ -}; -/* Meter table structure. */ struct mlx5_meter_domain_info {struct mlx5_flow_tbl_resource *tbl;
@@ -630,24 +622,12 @@ struct mlx5_meter_domains_infos {/* Meter parameter structure. */ struct mlx5_flow_meter_info { -uint32_t meter_id; -/**< Meter id. */ struct mlx5_flow_meter_profile *profile;/**< Meter profile parameters. */ rte_spinlock_t sl;/**< Meter action spinlock. */ -/** Policer actions (per meter output color). */ -enum rte_mtr_policer_action action[RTE_COLORS ];/** Set of stats counters to be enabled. * @see enum rte_mtr_stats_type */ -uint32_t green_bytes:1 ; -/** Set green bytes stats to be enabled. */ -uint32_t green_pkts:1 ; -/** Set green packets stats to be enabled. */ -uint32_t red_bytes:1 ; -/** Set red bytes stats to be enabled. */ -uint32_t red_pkts:1 ; -/** Set red packets stats to be enabled. */ uint32_t bytes_dropped:1 ;/** Set bytes dropped stats to be enabled. */ uint32_t pkts_dropped:1 ;
@@ -682,8 +662,8 @@ struct mlx5_flow_meter_info { uint32_t transfer:1;struct mlx5_meter_domains_infos *mfts;/**< Flow table created for this meter. */ -struct mlx5_flow_policer_stats policer_stats; -/**< Meter policer statistics. */ +uint32_t drop_cnt; +/**< Color counter for drop. */ uint32_t ref_cnt;/**< Use count. */ struct mlx5_indexed_pool *flow_ipool;
drivers/net/mlx5/mlx5_flow.c +0 -46
52 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +2 -16
@@ -839,6 +839,8 @@ struct mlx5_legacy_flow_meter {/* Must be the first in struct. */ TAILQ_ENTRY (mlx5_legacy_flow_meter) next;/**< Pointer to the next flow meter structure. */ +uint32_t meter_id; +/**< Meter id. */ uint32_t idx;/* Index to meter object. */ };
@@ -1097,14 +1099,6 @@ typedef struct mlx5_meter_domains_infos *(*mlx5_flow_create_mtr_tbls_t) (struct rte_eth_dev *dev);typedef int (*mlx5_flow_destroy_mtr_tbls_t )(struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbls); -typedef int (*mlx5_flow_create_policer_rules_t ) - (struct rte_eth_dev *dev, -struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr); -typedef int (*mlx5_flow_destroy_policer_rules_t ) - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr);typedef uint32_t (*mlx5_flow_mtr_alloc_t ) (struct rte_eth_dev *dev); typedef void (*mlx5_flow_mtr_free_t)(struct rte_eth_dev *dev,
@@ -1161,8 +1155,6 @@ struct mlx5_flow_driver_ops {mlx5_flow_query_t query;mlx5_flow_create_mtr_tbls_t create_mtr_tbls;mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls; -mlx5_flow_create_policer_rules_t prepare_policer_rules; -mlx5_flow_destroy_policer_rules_t destroy_policer_rules;mlx5_flow_mtr_alloc_t create_meter;mlx5_flow_mtr_free_t free_meter;mlx5_flow_counter_alloc_t counter_alloc;
@@ -1392,12 +1384,6 @@ struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls (struct rte_eth_dev *dev);int mlx5_flow_destroy_mtr_tbls (struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbl); -int mlx5_flow_prepare_policer_rules (struct rte_eth_dev *dev, -struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr); -int mlx5_flow_destroy_policer_rules (struct rte_eth_dev *dev, -struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr);int mlx5_flow_meter_flush (struct rte_eth_dev *dev,struct rte_mtr_error *error);int mlx5_flow_dv_discover_counter_offset_support (struct rte_eth_dev *dev);
drivers/net/mlx5/mlx5_flow_aso.c +4 -4
@@ -808,8 +808,8 @@ mlx5_aso_meter_update_by_wqe(struct mlx5_dev_ctx_shared *sh,/* Waiting for wqe resource. */ rte_delay_us_sleep (MLX5_ASO_WQE_CQE_RESPONSE_DELAY ); }while (--poll_wqe_times); -DRV_LOG (ERR ,"Fail to send WQE for ASO meter %d" , - mtr->fm.meter_id); +DRV_LOG (ERR ,"Fail to send WQE for ASO meter offset %d" , + mtr->offset);return -1 ; }
@@ -844,7 +844,7 @@ mlx5_aso_mtr_wait(struct mlx5_dev_ctx_shared *sh,/* Waiting for CQE ready. */ rte_delay_us_sleep (MLX5_ASO_WQE_CQE_RESPONSE_DELAY ); }while (--poll_cqe_times); -DRV_LOG (ERR ,"Fail to poll CQE ready for ASO meter %d" , - mtr->fm.meter_id); +DRV_LOG (ERR ,"Fail to poll CQE ready for ASO meter offset %d" , + mtr->offset);return -1 ; }
drivers/net/mlx5/mlx5_flow_dv.c +2 -459
501 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +11 -358
491 lines not on this page · raw message
drivers/net/softnic/rte_eth_softnic_flow.c +15 -4
@@ -1166,6 +1166,7 @@ flow_rule_action_get(struct pmd_internals *softnic, {struct softnic_table_action_profile *profile;struct softnic_table_action_profile_params *params; +struct softnic_mtr_meter_policy *policy;int n_jump_queue_rss_drop =0 ;int n_count =0 ;int n_mark =0 ;
@@ -1621,15 +1622,25 @@ flow_rule_action_get(struct pmd_internals *softnic,return -1 ; } } - +/* Meter policy must exist */ + policy =softnic_mtr_meter_policy_find (softnic, + m->params.meter_policy_id); +if (policy ==NULL ) { +rte_flow_error_set (error, +EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL , +"METER: fail to find meter policy" ); +return -1 ; + }/* RTE_TABLE_ACTION_METER */ rule_action->mtr.mtr[0 ].meter_profile_id = meter_profile_id; rule_action->mtr.mtr[0 ].policer[RTE_COLOR_GREEN ] = -softnic_table_action_policer (m->params.action[RTE_COLOR_GREEN ]); + policy->policer[RTE_COLOR_GREEN ]; rule_action->mtr.mtr[0 ].policer[RTE_COLOR_YELLOW ] = -softnic_table_action_policer (m->params.action[RTE_COLOR_YELLOW ]); + policy->policer[RTE_COLOR_YELLOW ]; rule_action->mtr.mtr[0 ].policer[RTE_COLOR_RED ] = -softnic_table_action_policer (m->params.action[RTE_COLOR_RED ]); + policy->policer[RTE_COLOR_RED ]; rule_action->mtr.tc_mask =1 ; rule_action->action_mask |=1 <<RTE_TABLE_ACTION_MTR ;break ;
drivers/net/softnic/rte_eth_softnic_internals.h +15 -3
@@ -83,6 +83,16 @@ struct softnic_mtr_meter_profile {TAILQ_HEAD (softnic_mtr_meter_profile_list, softnic_mtr_meter_profile); +/* MTR meter policy */ +struct softnic_mtr_meter_policy { +TAILQ_ENTRY (softnic_mtr_meter_policy) node; +uint32_t meter_policy_id; +enum rte_table_action_policer policer[RTE_COLORS ]; +uint32_t n_users; +}; + +TAILQ_HEAD (softnic_mtr_meter_policy_list, softnic_mtr_meter_policy); +/* MTR meter object */ struct softnic_mtr {TAILQ_ENTRY (softnic_mtr) node;
@@ -95,6 +105,7 @@ TAILQ_HEAD(softnic_mtr_list, softnic_mtr);struct mtr_internals {struct softnic_mtr_meter_profile_list meter_profiles; +struct softnic_mtr_meter_policy_list meter_policies;struct softnic_mtr_list mtrs; };
@@ -678,6 +689,10 @@ struct softnic_mtr_meter_profile * softnic_mtr_meter_profile_find(struct pmd_internals *p, uint32_t meter_profile_id); +struct softnic_mtr_meter_policy * +softnic_mtr_meter_policy_find (struct pmd_internals *p, +uint32_t meter_policy_id); +extern const struct rte_mtr_ops pmd_mtr_ops;/**
@@ -841,9 +856,6 @@ softnic_table_action_profile_create(struct pmd_internals *p,const char *name, struct softnic_table_action_profile_params *params); -enum rte_table_action_policer -softnic_table_action_policer (enum rte_mtr_policer_action action); -/** * Pipeline */
drivers/net/softnic/rte_eth_softnic_meter.c +201 -63
396 lines not on this page · raw message
lib/librte_ethdev/rte_flow.h +22 -0
@@ -32,6 +32,7 @@#include <rte_ecpri.h> #include <rte_mbuf.h> #include <rte_mbuf_dyn.h> +#include <rte_meter.h> #ifdef __cplusplusextern "C" {
@@ -2267,6 +2268,14 @@ 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. +* Set the meter color in the mbuf to the selected color. +* +* See struct rte_flow_action_meter_color. +*/ + RTE_FLOW_ACTION_TYPE_METER_COLOR, };/**
@@ -2859,6 +2868,19 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_METER_COLOR +* +* The meter color should be set in the packet meta-data +* (i.e. struct rte_mbuf::sched::color). +*/ +struct rte_flow_action_meter_color { +enum rte_color color;/**< Packet color. */ +}; +/** * Field IDs for MODIFY_FIELD action. */
lib/librte_ethdev/rte_mtr.c +44 -11
79 lines not on this page · raw message
lib/librte_ethdev/rte_mtr.h +113 -49
242 lines not on this page · raw message
lib/librte_ethdev/rte_mtr_driver.h +34 -10
72 lines not on this page · raw message
lib/librte_ethdev/version.map +4 -1
@@ -138,7 +138,6 @@ EXPERIMENTAL { rte_mtr_meter_profile_add; rte_mtr_meter_profile_delete; rte_mtr_meter_profile_update; - rte_mtr_policer_actions_update; rte_mtr_stats_read; rte_mtr_stats_update;
@@ -246,6 +245,10 @@ EXPERIMENTAL { # added in 21.05 rte_eth_representor_info_get; + rte_mtr_meter_policy_add; + rte_mtr_meter_policy_delete; + rte_mtr_meter_policy_update; + rte_mtr_meter_policy_validate; }; INTERNAL {
Signature · 1 line
2.27.0
Re: [dpdk-dev] [PATCH v6 1/2] ethdev: add pre-defined meter policy API
Hi Li,
Following the API changes, there are lots of changes in the drivers, as expected, so we'll have to take the necessary time to review them.
Here are just a few comments below, please expect more during the next few days.
<snip>
Quoted 13 lines
drivers/net/softnic/rte_eth_softnic_meter.c +10
-0+ +/* MTR meter policy add */ +static int +pmd_mtr_meter_policy_add (struct rte_eth_dev *dev, +uint32_t meter_policy_id, +struct rte_mtr_meter_policy_params *policy, +struct rte_mtr_error *error) +{ +struct pmd_internals *p = dev->data->dev_private; + struct softnic_mtr_meter_policy_list *mpl = &p-Quoted 1 line
mtr.meter_policies;
drivers/net/softnic/rte_eth_softnic_meter.c +2
-0+struct softnic_mtr_meter_policy *mp; +const struct rte_flow_action *act;
drivers/net/softnic/rte_eth_softnic_meter.c pmd_mtr_meter_profile_delete(struct rte_eth_dev *dev, · line 216
Quoted 10 lines
drivers/net/softnic/rte_eth_softnic_meter.c +10
-0+const struct rte_flow_action_meter_color *recolor; +uint32_t i; + +/* Meter policy ID must be valid. */ +if (meter_policy_id ==UINT32_MAX ) +return -rte_mtr_error_set (error, +EINVAL , +RTE_MTR_ERROR_TYPE_METER_POLICY_ID , +NULL , +"Meter policy id not valid" );
This is obviously not correct, we need to check whether the meter_policy_id provided by the user is already in use (by a policy previously added) or not. You can do this with the policy find function that you have already implemented.
drivers/net/softnic/rte_eth_softnic_meter.c pmd_mtr_meter_profile_delete(struct rte_eth_dev *dev, · line 227
Quoted 12 lines
drivers/net/softnic/rte_eth_softnic_meter.c +4
-0+ + for (i = 0; i < RTE_COLORS; i++) { + act = policy->actions[i]; + if (act && act->type !=
RTE_FLOW_ACTION_TYPE_METER_COLOR&&drivers/net/softnic/rte_eth_softnic_meter.c +7
-0+ act->type != RTE_FLOW_ACTION_TYPE_DROP) +return -rte_mtr_error_set (error, +EINVAL , +RTE_MTR_ERROR_TYPE_METER_POLICY , +NULL , +"Action invalid" ); + }
This check does not look right either: obviously we cannot accept a null action list for any color, plus the action list should contain only those action types we support (RTE_FLOW_ACTION_TYPE_METER_COLOR or RTE_FLOW_ACTION_TYPE_DROP).
I agree, fist you need to check that the linked list of policy actions for each color is non-NULL, then you need to traverse it until you meet the END action, skip any PAD actions, then check that exactly one (and one only) of METER_COLOR or DROP exist, but not both at the same time, and also we don't have the same action showing up multiple times. Makes sense?
Regards,
Cristian
Re: [dpdk-dev] [PATCH v6 1/2] ethdev: add pre-defined meter policy API
Thanks Cristian.
Will change it in V7 patch.
Regards,
Li Zhang
Quoted 87 lines
-----Original Message-----
From: Dumitrescu, Cristian <[email protected]>
Sent: Thursday, April 15, 2021 12:16 AM
To: Li Zhang <[email protected]>; [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; Wisam Monther <[email protected]>; Li, Xiaoyun <[email protected]>; Singh, Jasvinder <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Andrew Rybchenko <[email protected]>; Ray Kinsella <[email protected]>; Neil Horman <[email protected]>; Jerin Jacob <[email protected]>; Hemant Agrawal <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Roni Bar Yanai <[email protected]>; Haifei Luo <[email protected]>; Jiawei(Jonny) Wang <[email protected]>
Subject: RE: [PATCH v6 1/2] ethdev: add pre-defined meter policy APIExternal email: Use caution opening links or attachments
Hi Li,
Following the API changes, there are lots of changes in the drivers, as expected, so we'll have to take the necessary time to review them.
Here are just a few comments below, please expect more during the next few days.
<snip>
Quoted 13 lines
drivers/net/softnic/rte_eth_softnic_meter.c +10
-0+ +/* MTR meter policy add */ +static int +pmd_mtr_meter_policy_add (struct rte_eth_dev *dev, +uint32_t meter_policy_id, +struct rte_mtr_meter_policy_params *policy, +struct rte_mtr_error *error) +{ +struct pmd_internals *p = dev->data->dev_private; + struct softnic_mtr_meter_policy_list *mpl = &p-Quoted 1 line
mtr.meter_policies;
drivers/net/softnic/rte_eth_softnic_meter.c +2
-0+struct softnic_mtr_meter_policy *mp; +const struct rte_flow_action *act;drivers/net/softnic/rte_eth_softnic_meter.c pmd_mtr_meter_profile_delete(struct rte_eth_dev *dev, · line 216
Quoted 10 lines
drivers/net/softnic/rte_eth_softnic_meter.c +10
-0+const struct rte_flow_action_meter_color *recolor; +uint32_t i; + +/* Meter policy ID must be valid. */ +if (meter_policy_id ==UINT32_MAX ) +return -rte_mtr_error_set (error, +EINVAL , +RTE_MTR_ERROR_TYPE_METER_POLICY_ID , +NULL , +"Meter policy id not valid" );This is obviously not correct, we need to check whether the
meter_policy_idprovided by the user is already in use (by a policy previously added) or not. You can do this with the policy find function that you have already implemented.drivers/net/softnic/rte_eth_softnic_meter.c pmd_mtr_meter_profile_delete(struct rte_eth_dev *dev, · line 227
Quoted 12 lines
drivers/net/softnic/rte_eth_softnic_meter.c +4
-0+ + for (i = 0; i < RTE_COLORS; i++) { + act = policy->actions[i]; + if (act && act->type !=
RTE_FLOW_ACTION_TYPE_METER_COLOR&&drivers/net/softnic/rte_eth_softnic_meter.c +7
-0+ act->type != RTE_FLOW_ACTION_TYPE_DROP) +return -rte_mtr_error_set (error, +EINVAL , +RTE_MTR_ERROR_TYPE_METER_POLICY , +NULL , +"Action invalid" ); + }This check does not look right either: obviously we cannot accept a null action list for any color, plus the action list should contain only those action types we support (
RTE_FLOW_ACTION_TYPE_METER_COLORorRTE_FLOW_ACTION_TYPE_DROP).I agree, fist you need to check that the linked list of policy actions for each color is non-NULL, then you need to traverse it until you meet the END action, skip any PAD actions, then check that exactly one (and one only) of
METER_COLORor DROP exist, but not both at the same time, and also we don't have the same action showing up multiple times. Makes sense?Regards,
Cristian
Re: [dpdk-dev] [PATCH v6 1/2] ethdev: add pre-defined meter policy API
In reply to Li Zhang<snip>
Quoted 12 lines
drivers/net/softnic/rte_eth_softnic_meter.c +9
-0+/* MTR meter policy add */ +static int +pmd_mtr_meter_policy_add (struct rte_eth_dev *dev, +uint32_t meter_policy_id, +struct rte_mtr_meter_policy_params *policy, +struct rte_mtr_error *error) +{ +struct pmd_internals *p = dev->data->dev_private; + struct softnic_mtr_meter_policy_list *mpl = &p-Quoted 1 line
mtr.meter_policies;
drivers/net/softnic/rte_eth_softnic_meter.c +2
-0+struct softnic_mtr_meter_policy *mp; +const struct rte_flow_action *act;
drivers/net/softnic/rte_eth_softnic_meter.c pmd_mtr_meter_profile_delete(struct rte_eth_dev *dev, · line 216
Quoted 10 lines
drivers/net/softnic/rte_eth_softnic_meter.c +10
-0+const struct rte_flow_action_meter_color *recolor; +uint32_t i; + +/* Meter policy ID must be valid. */ +if (meter_policy_id ==UINT32_MAX ) +return -rte_mtr_error_set (error, +EINVAL , +RTE_MTR_ERROR_TYPE_METER_POLICY_ID , +NULL , +"Meter policy id not valid" );
Add check for "policy", could be null, before dereferencing this.
<snip>
Quoted 51 lines
drivers/net/softnic/rte_eth_softnic_meter.c +8
-13-/* MTR object policer action update */ +/* MTR object policy update */ static int -pmd_mtr_policer_actions_update (struct rte_eth_dev *dev, +pmd_mtr_meter_policy_update (struct rte_eth_dev *dev,uint32_t mtr_id, -uint32_t action_mask, -enum rte_mtr_policer_action *actions, +uint32_t meter_policy_id,struct rte_mtr_error *error) {struct pmd_internals *p = dev->data->dev_private;struct softnic_mtr *m;uint32_t i;int status; +struct softnic_mtr_meter_policy *mp_new, *mp_old;/* MTR object id must be valid */ m =softnic_mtr_find (p, mtr_id);@@ -527,29 +652,14 @@ pmd_mtr_policer_actions_update(struct rte_eth_dev *dev,RTE_MTR_ERROR_TYPE_MTR_ID ,NULL , "MTR object id not valid"); - -/* Valid policer actions */ -if (actions ==NULL ) +/* Meter policy must exist */ + mp_new =softnic_mtr_meter_policy_find (p, meter_policy_id); +if (mp_new ==NULL ) return -rte_mtr_error_set(error, EINVAL, -RTE_MTR_ERROR_TYPE_UNSPECIFIED , + RTE_MTR_ERROR_TYPE_METER_POLICY_ID, NULL, -"Invalid actions" ); - -for (i =0 ; i <RTE_COLORS ; i++) { -if (action_mask & (1 << i)) { - if (actions[i] !=
MTR_POLICER_ACTION_COLOR_GREEN&&(quoted diff) +0
-1- actions[i] !=
MTR_POLICER_ACTION_COLOR_YELLOW&&(quoted diff) +0
-1- actions[i] !=
MTR_POLICER_ACTION_COLOR_RED&&drivers/net/softnic/rte_eth_softnic_meter.c +0
-4- actions[i] != MTR_POLICER_ACTION_DROP) { - return -rte_mtr_error_set(error, - EINVAL, -
RTE_MTR_ERROR_TYPE_UNSPECIFIED,
drivers/net/softnic/rte_eth_softnic_meter.c pmd_mtr_policer_actions_update(struct rte_eth_dev *dev, · line 662
Quoted 6 lines
drivers/net/softnic/rte_eth_softnic_meter.c +1
-5-NULL , - " Invalid action value"); - } - } - } + "Meter policy id invalid");
Please add check whether MTR object is already set to meter policy id, return success if true, no need to continue. if (m->params.meter_policy_id == meter_policy_id)
return 0;
drivers/net/softnic/rte_eth_softnic_meter.c pmd_mtr_policer_actions_update(struct rte_eth_dev *dev, · line 665
Quoted 2 lines
drivers/net/softnic/rte_eth_softnic_meter.c +0
-0/* MTR object owner valid? */ if (m->flow) {
Regards,
Jasvinder
Re: [dpdk-dev] [PATCH v6 1/2] ethdev: add pre-defined meter policy API
Thanks Jasvinder.
Will change it in V7 patch.
Regards,
Li Zhang
Quoted 120 lines
-----Original Message-----
From: Singh, Jasvinder <[email protected]>
Sent: Thursday, April 15, 2021 6:22 AM
To: Li Zhang <[email protected]>; [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>; Dumitrescu, Cristian <[email protected]>; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; Wisam Monther <[email protected]>; Li, Xiaoyun <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Andrew Rybchenko <[email protected]>; Ray Kinsella <[email protected]>; Neil Horman <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Roni Bar Yanai <[email protected]>; Haifei Luo <[email protected]>; Jiawei(Jonny) Wang <[email protected]>
Subject: RE: [PATCH v6 1/2] ethdev: add pre-defined meter policy APIExternal email: Use caution opening links or attachments
<snip>
Quoted 12 lines
drivers/net/softnic/rte_eth_softnic_meter.c +9
-0+/* MTR meter policy add */ +static int +pmd_mtr_meter_policy_add (struct rte_eth_dev *dev, +uint32_t meter_policy_id, +struct rte_mtr_meter_policy_params *policy, +struct rte_mtr_error *error) +{ +struct pmd_internals *p = dev->data->dev_private; + struct softnic_mtr_meter_policy_list *mpl = &p-Quoted 1 line
mtr.meter_policies;
drivers/net/softnic/rte_eth_softnic_meter.c +2
-0+struct softnic_mtr_meter_policy *mp; +const struct rte_flow_action *act;drivers/net/softnic/rte_eth_softnic_meter.c pmd_mtr_meter_profile_delete(struct rte_eth_dev *dev, · line 216
Quoted 10 lines
drivers/net/softnic/rte_eth_softnic_meter.c +10
-0+const struct rte_flow_action_meter_color *recolor; +uint32_t i; + +/* Meter policy ID must be valid. */ +if (meter_policy_id ==UINT32_MAX ) +return -rte_mtr_error_set (error, +EINVAL , +RTE_MTR_ERROR_TYPE_METER_POLICY_ID , +NULL , +"Meter policy id not valid" );Add check for "policy", could be null, before dereferencing this.
<snip>
Quoted 47 lines
drivers/net/softnic/rte_eth_softnic_meter.c +4
-4-/* MTR object policer action update */ +/* MTR object policy update */ static int -pmd_mtr_policer_actions_update (struct rte_eth_dev *dev, +pmd_mtr_meter_policy_update (struct rte_eth_dev *dev,uint32_t mtr_id, -uint32_t action_mask, -enum rte_mtr_policer_action *actions, +uint32_t meter_policy_id,struct rte_mtr_error *error) {struct pmd_internals *p = dev->data->dev_private;struct softnic_mtr *m;uint32_t i;int status; +struct softnic_mtr_meter_policy *mp_new, *mp_old;/* MTR object id must be valid */ m = softnic_mtr_find(p, mtr_id); @@ -527,29 +652,14 @@pmd_mtr_policer_actions_update(struct
rte_eth_dev*dev,RTE_MTR_ERROR_TYPE_MTR_ID, NULL, "MTR object id not valid");drivers/net/softnic/rte_eth_softnic_meter.c +4
-9- -/* Valid policer actions */ -if (actions ==NULL ) +/* Meter policy must exist */ + mp_new =softnic_mtr_meter_policy_find (p, meter_policy_id); +if (mp_new ==NULL ) return -rte_mtr_error_set(error, EINVAL, -RTE_MTR_ERROR_TYPE_UNSPECIFIED , + RTE_MTR_ERROR_TYPE_METER_POLICY_ID, NULL, -"Invalid actions" ); - -for (i =0 ; i <RTE_COLORS ; i++) { -if (action_mask & (1 << i)) { - if (actions[i] !=
MTR_POLICER_ACTION_COLOR_GREEN&&
- actions[i] !=MTR_POLICER_ACTION_COLOR_YELLOW&&
- actions[i] !=MTR_POLICER_ACTION_COLOR_RED&&drivers/net/softnic/rte_eth_softnic_meter.c +0
-1- actions[i] != MTR_POLICER_ACTION_DROP) {drivers/net/softnic/rte_eth_softnic_meter.c pmd_mtr_policer_actions_update(struct rte_eth_dev *dev, · line 662
Quoted 10 lines
drivers/net/softnic/rte_eth_softnic_meter.c +1
-8-return -rte_mtr_error_set (error, -EINVAL , -RTE_MTR_ERROR_TYPE_UNSPECIFIED , -NULL , -" Invalid action value" ); - } - } - } + "Meter policy id invalid");Please add check whether MTR object is already set to meter policy id, return success if true, no need to continue.
if (m->params.meter_policy_id==meter_policy_id)return 0;Quoted 2 lines
/* MTR object owner valid? */ if (m->flow) {Regards,
Jasvinder
PATCH v6 2/2 app/testpmd: support policy actions per color
In reply to Li ZhangFrom: Haifei Luo <[email protected]>
Add the create/del policy CLIs to support actions per color. The CLIs are:
Create: add port meter policy (port_id) (policy_id) g_actions (actions) y_actions (actions) r_actions (actions)
Delete: del port meter policy (port_id) (policy_id)
Examples:
testpmd> add port meter policy 0 1 g_actions rss / end y_actions end r_actions drop / end
testpmd> del port meter policy 0 1
--- app/test-pmd/cmdline.c | 13 ++- app/test-pmd/cmdline_flow.c | 118 +++++++++++++++++++- app/test-pmd/cmdline_mtr.c | 85 +++++++++++++- app/test-pmd/cmdline_mtr.h | 3 + app/test-pmd/config.c | 32 ++++++ app/test-pmd/testpmd.h | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 30 ++++- 7 files changed, 269 insertions(+), 14 deletions(-)
app/test-pmd/cmdline.c +10 -3
@@ -705,9 +705,8 @@ static void cmd_help_long_parsed(void *parsed_result,"del port meter profile (port_id) (profile_id)\n" " meter profile delete\n\n" -"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" -"(g_action) (y_action) (r_action) (stats_mask) (shared)\n" -"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" +"create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n" +"(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" "(dscp_tbl_entry63)]\n" " meter create\n\n"
@@ -720,6 +719,13 @@ static void cmd_help_long_parsed(void *parsed_result,"del port meter (port_id) (mtr_id)\n" " meter delete\n\n" +"add port meter policy (port_id) (policy_id) g_actions (actions)\n" +"y_actions (actions) r_actions (actions)\n" +" meter policy add\n\n" + +"del port meter policy (port_id) (policy_id)\n" +" meter policy delete\n\n" +"set port meter profile (port_id) (mtr_id) (profile_id)\n" " meter update meter profile\n\n"
@@ -17069,6 +17075,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_enable_port_meter, (cmdline_parse_inst_t *)&cmd_disable_port_meter, (cmdline_parse_inst_t *)&cmd_del_port_meter, + (cmdline_parse_inst_t *)&cmd_del_port_meter_policy, (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
app/test-pmd/cmdline_flow.c +117 -1
178 lines not on this page · raw message
app/test-pmd/cmdline_mtr.c +79 -6
140 lines not on this page · raw message
app/test-pmd/cmdline_mtr.h +3 -0
@@ -4,6 +4,7 @@#ifndef _CMDLINE_MTR_H_#define _CMDLINE_MTR_H_ +#include <rte_mtr.h> /* Traffic Metering and Policing */ extern cmdline_parse_inst_t cmd_show_port_meter_cap;
@@ -15,9 +16,11 @@ extern cmdline_parse_inst_t cmd_create_port_meter;extern cmdline_parse_inst_t cmd_enable_port_meter;extern cmdline_parse_inst_t cmd_disable_port_meter;extern cmdline_parse_inst_t cmd_del_port_meter; +extern cmdline_parse_inst_t cmd_del_port_meter_policy;extern cmdline_parse_inst_t cmd_set_port_meter_profile;extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table;extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;extern cmdline_parse_inst_t cmd_show_port_meter_stats; +void print_mtr_err_msg (struct rte_mtr_error *error);#endif /* _CMDLINE_MTR_H_ */
app/test-pmd/config.c +32 -0
@@ -38,6 +38,7 @@#include <rte_string_fns.h> #include <rte_cycles.h> #include <rte_flow.h> +#include <rte_mtr.h> #include <rte_errno.h> #ifdef RTE_NET_IXGBE #include <rte_pmd_ixgbe.h>
@@ -52,6 +53,7 @@#include <rte_hexdump.h> #include "testpmd.h" +#include "cmdline_mtr.h" #define ETHDEV_FWVERS_LEN 32
@@ -1465,6 +1467,36 @@ action_alloc(portid_t port_id, uint32_t id,return 0 ; } +/** Add port meter policy */ +int +port_meter_policy_add (portid_t port_id,uint32_t policy_id, +const struct rte_flow_action *actions) +{ +struct rte_mtr_error error; +const struct rte_flow_action *act = actions; +const struct rte_flow_action *start; +struct rte_mtr_meter_policy_params policy; +uint32_t i =0 , act_n; +int ret; + +for (i =0 ; i <RTE_COLORS ; i++) { +for (act_n =0 , start = act; + act->type !=RTE_FLOW_ACTION_TYPE_END ; act++) + act_n++; +if (act_n && act->type ==RTE_FLOW_ACTION_TYPE_END ) + policy.actions[i] = start; +else + policy.actions[i] =NULL ; + act++; + } + ret =rte_mtr_meter_policy_add (port_id, + policy_id, + &policy, &error); +if (ret) +print_mtr_err_msg (&error); +return ret; +} +/** Create shared action */ int port_shared_action_create(portid_t port_id, uint32_t id,
app/test-pmd/testpmd.h +2 -0
@@ -837,6 +837,8 @@ void port_flow_tunnel_list(portid_t port_id);void port_flow_tunnel_destroy (portid_t port_id,uint32_t tunnel_id);void port_flow_tunnel_create (portid_t port_id,const struct tunnel_ops *ops);int port_flow_isolate (portid_t port_id,int set); +int port_meter_policy_add (portid_t port_id,uint32_t policy_id, +const struct rte_flow_action *actions);void rx_ring_desc_display (portid_t port_id,queueid_t rxq_id,uint16_t rxd_id);void tx_ring_desc_display (portid_t port_id,queueid_t txq_id,uint16_t txd_id);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +26 -4
@@ -2764,13 +2764,37 @@ Delete meter profile from the ethernet device:: testpmd> del port meter profile (port_id) (profile_id) +create port policy +~~~~~~~~~~~~~~~~~~ + +Create new policy object for the ethernet device:: + + testpmd> add port meter policy (port_id) (policy_id) g_actions \ + {action} y_actions {action} r_actions {action} + +where: + +* ``policy_id``: policy ID. +* ``action``: action lists for green/yellow/red colors. + +delete port policy +~~~~~~~~~~~~~~~~~~ + +Delete policy object for the ethernet device:: + + testpmd> del port meter policy (port_id) (policy_id) + +where: + +* ``policy_id``: policy ID. + create port meter ~~~~~~~~~~~~~~~~~ Create new meter object for the ethernet device:: testpmd> create port meter (port_id) (mtr_id) (profile_id) \ - (meter_enable) (g_action) (y_action) (r_action) (stats_mask) (shared) \ + (policy_id) (meter_enable) (stats_mask) (shared) \ (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\ (dscp_tbl_entry63)]
@@ -2778,11 +2802,9 @@ where: * ``mtr_id``: meter object ID. * ``profile_id``: ID for the meter profile. +* ``policy_id``: ID for the policy. * ``meter_enable``: When this parameter has a non-zero value, the meter object gets enabled at the time of creation, otherwise remains disabled. -* ``g_action``: Policer action for the packet with green color. -* ``y_action``: Policer action for the packet with yellow color. -* ``r_action``: Policer action for the packet with red color. * ``stats_mask``: Mask of statistics counter types to be enabled for the meter object. * ``shared``: When this parameter has a non-zero value, the meter object is
Signature · 1 line
2.27.0
v7 cover Support meter policy API
In reply to Li ZhangCurrently, 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.
Add two common policy template as macros in the header file,
RFC ("ethdev: add pre-defined meter policy API")
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
Depends-on: series=16351 ("Add ASO meter support in MLX5 PMD ")
https://patchwork.dpdk.org/project/dpdk/list/?series=16351
V2: Delete default policy and change relation doc files.
V3: Fix coding style issues.
V4: Fix comments about Depends-on
V5: Fix comments about rte_mtr_meter_policy_add.
V6: Delete policy example.
V7: Fix comments and place two common policy template as macros.
Haifei Luo (1):
app/testpmd: support policy actions per color
Li Zhang (1):
ethdev: add pre-defined meter policy API
app/test-flow-perf/main.c | 7 - app/test-pmd/cmdline.c | 14 +- app/test-pmd/cmdline_flow.c | 118 ++++- app/test-pmd/cmdline_mtr.c | 257 +++------- app/test-pmd/cmdline_mtr.h | 4 +- app/test-pmd/config.c | 32 ++ app/test-pmd/testpmd.h | 2 + doc/guides/prog_guide/rte_flow.rst | 21 + .../traffic_metering_and_policing.rst | 16 +- doc/guides/rel_notes/release_21_05.rst | 22 +- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 48 +- 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 | 8 +- drivers/net/mlx5/mlx5_flow_dv.c | 461 +----------------- 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 | 290 ++++++++--- lib/librte_ethdev/rte_flow.h | 22 + lib/librte_ethdev/rte_mtr.c | 55 ++- lib/librte_ethdev/rte_mtr.h | 224 +++++++-- lib/librte_ethdev/rte_mtr_driver.h | 44 +- lib/librte_ethdev/version.map | 5 +- 25 files changed, 873 insertions(+), 1271 deletions(-)
Signature · 1 line
2.27.0
PATCH v7 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.
Allow coloring the packet using a new rte_flow_action_color as could be done by the old policy API.
Add two common policy template as macros in the head file.
The next API function were added:
- rte_mtr_meter_policy_add
- 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.
net/mlx5: clean meter creation management Cleans and breaks part of the current meter management in order to allow better design with policy API.
--- 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/prog_guide/rte_flow.rst | 21 + .../traffic_metering_and_policing.rst | 16 +- doc/guides/rel_notes/release_21_05.rst | 22 +- 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 | 8 +- drivers/net/mlx5/mlx5_flow_dv.c | 461 +----------------- 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 | 290 ++++++++--- lib/librte_ethdev/rte_flow.h | 22 + lib/librte_ethdev/rte_mtr.c | 55 ++- lib/librte_ethdev/rte_mtr.h | 224 +++++++-- lib/librte_ethdev/rte_mtr_driver.h | 44 +- lib/librte_ethdev/version.map | 5 +- 22 files changed, 604 insertions(+), 1257 deletions(-)
app/test-flow-perf/main.c +0 -7
@@ -928,13 +928,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, ¶ms,1 , &error);if (ret !=0 ) { printf("Port %u create meter idx(%d) error(%d) message: %s\n",
app/test-pmd/cmdline.c +0 -1
@@ -17071,7 +17071,6 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_del_port_meter, (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, - (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, (cmdline_parse_inst_t *)&cmd_mcast_addr,
app/test-pmd/cmdline_mtr.c +0 -172
196 lines not on this page · raw message
app/test-pmd/cmdline_mtr.h +0 -1
@@ -17,7 +17,6 @@ extern cmdline_parse_inst_t cmd_disable_port_meter;extern cmdline_parse_inst_t cmd_del_port_meter;extern cmdline_parse_inst_t cmd_set_port_meter_profile;extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table; -extern cmdline_parse_inst_t cmd_set_port_meter_policer_action;extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;extern cmdline_parse_inst_t cmd_show_port_meter_stats;
doc/guides/prog_guide/rte_flow.rst +21 -0
@@ -2841,6 +2841,27 @@ for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. | ``value`` | immediate value or a pointer to this value | +---------------+----------------------------------------------------------+ +Action: ``METER_COLOR`` +^^^^^^^^^^^^^^^^^^^^^^^ + +Color the packet to reflect the meter color result. + +The meter action must be configured before meter color action. +Meter color action is set to a color to reflect the meter color result. +Set the meter color in the mbuf to the selected color. +The meter color action output color is the output color of the packet, +which is set in the packet meta-data (i.e. struct ``rte_mbuf::sched::color``) + +.. _table_rte_flow_action_meter_color: + +.. table:: METER_COLOR + + +-----------------+--------------+ + | Field | Value | + +=================+==============+ + | ``meter_color`` | Packet color | + +-----------------+--------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/prog_guide/traffic_metering_and_policing.rst +4 -12
@@ -56,18 +56,10 @@ The processing done for each input packet hitting an MTR object is: color blind mode, which is equivalent to considering all input packets initially colored as green. -* Policing: There is a separate policer action configured for each meter - output color, which can: - - * Drop the packet. - - * Keep the same packet color: the policer output color matches the meter - output color (essentially a no-op action). - - * Recolor the packet: the policer output color is set to a different color - than the meter output color. The policer output color is the output color - of the packet, which is set in the packet meta-data (i.e. struct - ``rte_mbuf::sched::color``). +* There is a meter policy API to manage pre-defined policies for meter. + Any rte_flow action list can be configured per color for each policy. + A meter object configured with a policy executes the actions per packet + according to the packet color. * Statistics: The set of counters maintained for each MTR object is configurable and subject to the implementation support. This set includes
doc/guides/rel_notes/release_21_05.rst +21 -1
@@ -174,7 +174,27 @@ New Features ``dpdk-testpmd -- --eth-link-speed N`` * Added command to display Rx queue used descriptor count. ``show port (port_id) rxq (queue_id) desc used count`` - + * deleted the port meter policer action command . + ``set port meter policer action (port_id) (mtr_id) (action_mask) ...`` + * Added command to create meter policy. + ``add port meter policy (port_id) (policy_id) g_actions {action} end y_actions {action} end r_actions {action} end`` + * Added command to delete meter policy. + ``del port meter policy (port_id) (policy_id)`` + +* **Updated meter API.** + + * ethdev: Deleted meter policer API to support policy API. + ``rte_mtr_policer_actions_update()`` + * ethdev: Added meter API to support pre-defined policy, rte_flow action list per color. + ``rte_mtr_meter_policy_add()``, ``rte_mtr_meter_policy_delete()`` and + ``rte_mtr_create_with_policy()`` + * ethdev: Removed rte_mtr_policer_action from rte_mtr_params structures. + * ethdev: Added rte_mtr_meter_policy_params structures to support policy API. + * ethdev: Added meter_policy_id into rte_mtr_params structures. + * ethdev: Removed policer_action_recolor_supported and policer_action_drop_supported from rte_mtr_capabilities structures. + * ethdev: Added meter_policy_n_max into rte_mtr_capabilities structures. + * ethdev: Added RTE_FLOW_ACTION_TYPE_METER_COLOR in enum rte_flow_action_type. + * ethdev: Added RTE_MTR_ERROR_TYPE_METER_POLICY_ID and RTE_MTR_ERROR_TYPE_METER_POLICY_ID into rte_mtr_error_type. Removed Items -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -18
@@ -2830,24 +2830,6 @@ Set meter dscp table for the ethernet device:: testpmd> set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0) \ (dscp_tbl_entry1)...(dscp_tbl_entry63)] -set port meter policer action -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Set meter policer action for the ethernet device:: - - testpmd> set port meter policer action (port_id) (mtr_id) (action_mask) \ - (action0) [(action1) (action1)] - -where: - -* ``action_mask``: Bit mask indicating which policer actions need to be - updated. One or more policer actions can be updated in a single function - invocation. To update the policer action associated with color C, bit - (1 << C) needs to be set in *action_mask* and element at position C - in the *actions* array needs to be valid. -* ``actionx``: Policer action for the color x, - RTE_MTR_GREEN <= x < RTE_MTR_COLORS - set port meter stats mask ~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/mlx5/mlx5.h +2 -22
@@ -584,14 +584,6 @@ struct mlx5_dev_shared_port {/* Modify this value if enum rte_mtr_color changes. */ #define RTE_MTR_DROPPED RTE_COLORS -/* Meter policer statistics */ -struct mlx5_flow_policer_stats { -uint32_t pass_cnt; -/**< Color counter for pass. */ -uint32_t drop_cnt; -/**< Color counter for drop. */ -}; -/* Meter table structure. */ struct mlx5_meter_domain_info {struct mlx5_flow_tbl_resource *tbl;
@@ -630,24 +622,12 @@ struct mlx5_meter_domains_infos {/* Meter parameter structure. */ struct mlx5_flow_meter_info { -uint32_t meter_id; -/**< Meter id. */ struct mlx5_flow_meter_profile *profile;/**< Meter profile parameters. */ rte_spinlock_t sl;/**< Meter action spinlock. */ -/** Policer actions (per meter output color). */ -enum rte_mtr_policer_action action[RTE_COLORS ];/** Set of stats counters to be enabled. * @see enum rte_mtr_stats_type */ -uint32_t green_bytes:1 ; -/** Set green bytes stats to be enabled. */ -uint32_t green_pkts:1 ; -/** Set green packets stats to be enabled. */ -uint32_t red_bytes:1 ; -/** Set red bytes stats to be enabled. */ -uint32_t red_pkts:1 ; -/** Set red packets stats to be enabled. */ uint32_t bytes_dropped:1 ;/** Set bytes dropped stats to be enabled. */ uint32_t pkts_dropped:1 ;
@@ -682,8 +662,8 @@ struct mlx5_flow_meter_info { uint32_t transfer:1;struct mlx5_meter_domains_infos *mfts;/**< Flow table created for this meter. */ -struct mlx5_flow_policer_stats policer_stats; -/**< Meter policer statistics. */ +uint32_t drop_cnt; +/**< Color counter for drop. */ uint32_t ref_cnt;/**< Use count. */ struct mlx5_indexed_pool *flow_ipool;
drivers/net/mlx5/mlx5_flow.c +0 -46
52 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +2 -16
@@ -839,6 +839,8 @@ struct mlx5_legacy_flow_meter {/* Must be the first in struct. */ TAILQ_ENTRY (mlx5_legacy_flow_meter) next;/**< Pointer to the next flow meter structure. */ +uint32_t meter_id; +/**< Meter id. */ uint32_t idx;/* Index to meter object. */ };
@@ -1097,14 +1099,6 @@ typedef struct mlx5_meter_domains_infos *(*mlx5_flow_create_mtr_tbls_t) (struct rte_eth_dev *dev);typedef int (*mlx5_flow_destroy_mtr_tbls_t )(struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbls); -typedef int (*mlx5_flow_create_policer_rules_t ) - (struct rte_eth_dev *dev, -struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr); -typedef int (*mlx5_flow_destroy_policer_rules_t ) - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr);typedef uint32_t (*mlx5_flow_mtr_alloc_t ) (struct rte_eth_dev *dev); typedef void (*mlx5_flow_mtr_free_t)(struct rte_eth_dev *dev,
@@ -1161,8 +1155,6 @@ struct mlx5_flow_driver_ops {mlx5_flow_query_t query;mlx5_flow_create_mtr_tbls_t create_mtr_tbls;mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls; -mlx5_flow_create_policer_rules_t prepare_policer_rules; -mlx5_flow_destroy_policer_rules_t destroy_policer_rules;mlx5_flow_mtr_alloc_t create_meter;mlx5_flow_mtr_free_t free_meter;mlx5_flow_counter_alloc_t counter_alloc;
@@ -1392,12 +1384,6 @@ struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls (struct rte_eth_dev *dev);int mlx5_flow_destroy_mtr_tbls (struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbl); -int mlx5_flow_prepare_policer_rules (struct rte_eth_dev *dev, -struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr); -int mlx5_flow_destroy_policer_rules (struct rte_eth_dev *dev, -struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr);int mlx5_flow_meter_flush (struct rte_eth_dev *dev,struct rte_mtr_error *error);int mlx5_flow_dv_discover_counter_offset_support (struct rte_eth_dev *dev);
drivers/net/mlx5/mlx5_flow_aso.c +4 -4
@@ -808,8 +808,8 @@ mlx5_aso_meter_update_by_wqe(struct mlx5_dev_ctx_shared *sh,/* Waiting for wqe resource. */ rte_delay_us_sleep (MLX5_ASO_WQE_CQE_RESPONSE_DELAY ); }while (--poll_wqe_times); -DRV_LOG (ERR ,"Fail to send WQE for ASO meter %d" , - mtr->fm.meter_id); +DRV_LOG (ERR ,"Fail to send WQE for ASO meter offset %d" , + mtr->offset);return -1 ; }
@@ -844,7 +844,7 @@ mlx5_aso_mtr_wait(struct mlx5_dev_ctx_shared *sh,/* Waiting for CQE ready. */ rte_delay_us_sleep (MLX5_ASO_WQE_CQE_RESPONSE_DELAY ); }while (--poll_cqe_times); -DRV_LOG (ERR ,"Fail to poll CQE ready for ASO meter %d" , - mtr->fm.meter_id); +DRV_LOG (ERR ,"Fail to poll CQE ready for ASO meter offset %d" , + mtr->offset);return -1 ; }
drivers/net/mlx5/mlx5_flow_dv.c +2 -459
501 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +11 -358
491 lines not on this page · raw message
drivers/net/softnic/rte_eth_softnic_flow.c +15 -4
@@ -1166,6 +1166,7 @@ flow_rule_action_get(struct pmd_internals *softnic, {struct softnic_table_action_profile *profile;struct softnic_table_action_profile_params *params; +struct softnic_mtr_meter_policy *policy;int n_jump_queue_rss_drop =0 ;int n_count =0 ;int n_mark =0 ;
@@ -1621,15 +1622,25 @@ flow_rule_action_get(struct pmd_internals *softnic,return -1 ; } } - +/* Meter policy must exist */ + policy =softnic_mtr_meter_policy_find (softnic, + m->params.meter_policy_id); +if (policy ==NULL ) { +rte_flow_error_set (error, +EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL , +"METER: fail to find meter policy" ); +return -1 ; + }/* RTE_TABLE_ACTION_METER */ rule_action->mtr.mtr[0 ].meter_profile_id = meter_profile_id; rule_action->mtr.mtr[0 ].policer[RTE_COLOR_GREEN ] = -softnic_table_action_policer (m->params.action[RTE_COLOR_GREEN ]); + policy->policer[RTE_COLOR_GREEN ]; rule_action->mtr.mtr[0 ].policer[RTE_COLOR_YELLOW ] = -softnic_table_action_policer (m->params.action[RTE_COLOR_YELLOW ]); + policy->policer[RTE_COLOR_YELLOW ]; rule_action->mtr.mtr[0 ].policer[RTE_COLOR_RED ] = -softnic_table_action_policer (m->params.action[RTE_COLOR_RED ]); + policy->policer[RTE_COLOR_RED ]; rule_action->mtr.tc_mask =1 ; rule_action->action_mask |=1 <<RTE_TABLE_ACTION_MTR ;break ;
drivers/net/softnic/rte_eth_softnic_internals.h +15 -3
@@ -83,6 +83,16 @@ struct softnic_mtr_meter_profile {TAILQ_HEAD (softnic_mtr_meter_profile_list, softnic_mtr_meter_profile); +/* MTR meter policy */ +struct softnic_mtr_meter_policy { +TAILQ_ENTRY (softnic_mtr_meter_policy) node; +uint32_t meter_policy_id; +enum rte_table_action_policer policer[RTE_COLORS ]; +uint32_t n_users; +}; + +TAILQ_HEAD (softnic_mtr_meter_policy_list, softnic_mtr_meter_policy); +/* MTR meter object */ struct softnic_mtr {TAILQ_ENTRY (softnic_mtr) node;
@@ -95,6 +105,7 @@ TAILQ_HEAD(softnic_mtr_list, softnic_mtr);struct mtr_internals {struct softnic_mtr_meter_profile_list meter_profiles; +struct softnic_mtr_meter_policy_list meter_policies;struct softnic_mtr_list mtrs; };
@@ -678,6 +689,10 @@ struct softnic_mtr_meter_profile * softnic_mtr_meter_profile_find(struct pmd_internals *p, uint32_t meter_profile_id); +struct softnic_mtr_meter_policy * +softnic_mtr_meter_policy_find (struct pmd_internals *p, +uint32_t meter_policy_id); +extern const struct rte_mtr_ops pmd_mtr_ops;/**
@@ -841,9 +856,6 @@ softnic_table_action_profile_create(struct pmd_internals *p,const char *name, struct softnic_table_action_profile_params *params); -enum rte_table_action_policer -softnic_table_action_policer (enum rte_mtr_policer_action action); -/** * Pipeline */
drivers/net/softnic/rte_eth_softnic_meter.c +228 -62
422 lines not on this page · raw message
lib/librte_ethdev/rte_flow.h +22 -0
@@ -32,6 +32,7 @@#include <rte_ecpri.h> #include <rte_mbuf.h> #include <rte_mbuf_dyn.h> +#include <rte_meter.h> #ifdef __cplusplusextern "C" {
@@ -2267,6 +2268,14 @@ 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. +* Set the meter color in the mbuf to the selected color. +* +* See struct rte_flow_action_meter_color. +*/ + RTE_FLOW_ACTION_TYPE_METER_COLOR, };/**
@@ -2859,6 +2868,19 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_METER_COLOR +* +* The meter color should be set in the packet meta-data +* (i.e. struct rte_mbuf::sched::color). +*/ +struct rte_flow_action_meter_color { +enum rte_color color;/**< Packet color. */ +}; +/** * Field IDs for MODIFY_FIELD action. */
lib/librte_ethdev/rte_mtr.c +44 -11
79 lines not on this page · raw message
lib/librte_ethdev/rte_mtr.h +175 -49
304 lines not on this page · raw message
lib/librte_ethdev/rte_mtr_driver.h +34 -10
72 lines not on this page · raw message
lib/librte_ethdev/version.map +4 -1
@@ -138,7 +138,6 @@ EXPERIMENTAL { rte_mtr_meter_profile_add; rte_mtr_meter_profile_delete; rte_mtr_meter_profile_update; - rte_mtr_policer_actions_update; rte_mtr_stats_read; rte_mtr_stats_update;
@@ -246,6 +245,10 @@ EXPERIMENTAL { # added in 21.05 rte_eth_representor_info_get; + rte_mtr_meter_policy_add; + rte_mtr_meter_policy_delete; + rte_mtr_meter_policy_update; + rte_mtr_meter_policy_validate; }; INTERNAL {
Signature · 1 line
2.27.0
PATCH v7 2/2 app/testpmd: support policy actions per color
In reply to Li ZhangFrom: Haifei Luo <[email protected]>
Add the create/del policy CLIs to support actions per color. The CLIs are:
Create: add port meter policy (port_id) (policy_id) g_actions (actions) y_actions (actions) r_actions (actions)
Delete: del port meter policy (port_id) (policy_id)
Examples:
testpmd> add port meter policy 0 1 g_actions rss / end y_actions end r_actions drop / end
testpmd> del port meter policy 0 1
--- app/test-pmd/cmdline.c | 13 ++- app/test-pmd/cmdline_flow.c | 118 +++++++++++++++++++- app/test-pmd/cmdline_mtr.c | 85 +++++++++++++- app/test-pmd/cmdline_mtr.h | 3 + app/test-pmd/config.c | 32 ++++++ app/test-pmd/testpmd.h | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 30 ++++- 7 files changed, 269 insertions(+), 14 deletions(-)
app/test-pmd/cmdline.c +10 -3
@@ -705,9 +705,8 @@ static void cmd_help_long_parsed(void *parsed_result,"del port meter profile (port_id) (profile_id)\n" " meter profile delete\n\n" -"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" -"(g_action) (y_action) (r_action) (stats_mask) (shared)\n" -"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" +"create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n" +"(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" "(dscp_tbl_entry63)]\n" " meter create\n\n"
@@ -720,6 +719,13 @@ static void cmd_help_long_parsed(void *parsed_result,"del port meter (port_id) (mtr_id)\n" " meter delete\n\n" +"add port meter policy (port_id) (policy_id) g_actions (actions)\n" +"y_actions (actions) r_actions (actions)\n" +" meter policy add\n\n" + +"del port meter policy (port_id) (policy_id)\n" +" meter policy delete\n\n" +"set port meter profile (port_id) (mtr_id) (profile_id)\n" " meter update meter profile\n\n"
@@ -17069,6 +17075,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_enable_port_meter, (cmdline_parse_inst_t *)&cmd_disable_port_meter, (cmdline_parse_inst_t *)&cmd_del_port_meter, + (cmdline_parse_inst_t *)&cmd_del_port_meter_policy, (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
app/test-pmd/cmdline_flow.c +117 -1
178 lines not on this page · raw message
app/test-pmd/cmdline_mtr.c +79 -6
140 lines not on this page · raw message
app/test-pmd/cmdline_mtr.h +3 -0
@@ -4,6 +4,7 @@#ifndef _CMDLINE_MTR_H_#define _CMDLINE_MTR_H_ +#include <rte_mtr.h> /* Traffic Metering and Policing */ extern cmdline_parse_inst_t cmd_show_port_meter_cap;
@@ -15,9 +16,11 @@ extern cmdline_parse_inst_t cmd_create_port_meter;extern cmdline_parse_inst_t cmd_enable_port_meter;extern cmdline_parse_inst_t cmd_disable_port_meter;extern cmdline_parse_inst_t cmd_del_port_meter; +extern cmdline_parse_inst_t cmd_del_port_meter_policy;extern cmdline_parse_inst_t cmd_set_port_meter_profile;extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table;extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;extern cmdline_parse_inst_t cmd_show_port_meter_stats; +void print_mtr_err_msg (struct rte_mtr_error *error);#endif /* _CMDLINE_MTR_H_ */
app/test-pmd/config.c +32 -0
@@ -38,6 +38,7 @@#include <rte_string_fns.h> #include <rte_cycles.h> #include <rte_flow.h> +#include <rte_mtr.h> #include <rte_errno.h> #ifdef RTE_NET_IXGBE #include <rte_pmd_ixgbe.h>
@@ -52,6 +53,7 @@#include <rte_hexdump.h> #include "testpmd.h" +#include "cmdline_mtr.h" #define ETHDEV_FWVERS_LEN 32
@@ -1465,6 +1467,36 @@ action_alloc(portid_t port_id, uint32_t id,return 0 ; } +/** Add port meter policy */ +int +port_meter_policy_add (portid_t port_id,uint32_t policy_id, +const struct rte_flow_action *actions) +{ +struct rte_mtr_error error; +const struct rte_flow_action *act = actions; +const struct rte_flow_action *start; +struct rte_mtr_meter_policy_params policy; +uint32_t i =0 , act_n; +int ret; + +for (i =0 ; i <RTE_COLORS ; i++) { +for (act_n =0 , start = act; + act->type !=RTE_FLOW_ACTION_TYPE_END ; act++) + act_n++; +if (act_n && act->type ==RTE_FLOW_ACTION_TYPE_END ) + policy.actions[i] = start; +else + policy.actions[i] =NULL ; + act++; + } + ret =rte_mtr_meter_policy_add (port_id, + policy_id, + &policy, &error); +if (ret) +print_mtr_err_msg (&error); +return ret; +} +/** Create shared action */ int port_shared_action_create(portid_t port_id, uint32_t id,
app/test-pmd/testpmd.h +2 -0
@@ -837,6 +837,8 @@ void port_flow_tunnel_list(portid_t port_id);void port_flow_tunnel_destroy (portid_t port_id,uint32_t tunnel_id);void port_flow_tunnel_create (portid_t port_id,const struct tunnel_ops *ops);int port_flow_isolate (portid_t port_id,int set); +int port_meter_policy_add (portid_t port_id,uint32_t policy_id, +const struct rte_flow_action *actions);void rx_ring_desc_display (portid_t port_id,queueid_t rxq_id,uint16_t rxd_id);void tx_ring_desc_display (portid_t port_id,queueid_t txq_id,uint16_t txd_id);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +26 -4
@@ -2764,13 +2764,37 @@ Delete meter profile from the ethernet device:: testpmd> del port meter profile (port_id) (profile_id) +create port policy +~~~~~~~~~~~~~~~~~~ + +Create new policy object for the ethernet device:: + + testpmd> add port meter policy (port_id) (policy_id) g_actions \ + {action} y_actions {action} r_actions {action} + +where: + +* ``policy_id``: policy ID. +* ``action``: action lists for green/yellow/red colors. + +delete port policy +~~~~~~~~~~~~~~~~~~ + +Delete policy object for the ethernet device:: + + testpmd> del port meter policy (port_id) (policy_id) + +where: + +* ``policy_id``: policy ID. + create port meter ~~~~~~~~~~~~~~~~~ Create new meter object for the ethernet device:: testpmd> create port meter (port_id) (mtr_id) (profile_id) \ - (meter_enable) (g_action) (y_action) (r_action) (stats_mask) (shared) \ + (policy_id) (meter_enable) (stats_mask) (shared) \ (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\ (dscp_tbl_entry63)]
@@ -2778,11 +2802,9 @@ where: * ``mtr_id``: meter object ID. * ``profile_id``: ID for the meter profile. +* ``policy_id``: ID for the policy. * ``meter_enable``: When this parameter has a non-zero value, the meter object gets enabled at the time of creation, otherwise remains disabled. -* ``g_action``: Policer action for the packet with green color. -* ``y_action``: Policer action for the packet with yellow color. -* ``r_action``: Policer action for the packet with red color. * ``stats_mask``: Mask of statistics counter types to be enabled for the meter object. * ``shared``: When this parameter has a non-zero value, the meter object is
Signature · 1 line
2.27.0
v8 cover Support meter policy API
In reply to Li ZhangCurrently, 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.
Add two common policy template as macros in the header file,
RFC ("ethdev: add pre-defined meter policy API")
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
Depends-on: series=16351 ("Add ASO meter support in MLX5 PMD ")
https://patchwork.dpdk.org/project/dpdk/list/?series=16351
V2: Delete default policy and change relation doc files.
V3: Fix coding style issues.
V4: Fix comments about Depends-on
V5: Fix comments about rte_mtr_meter_policy_add.
V6: Delete policy example.
V7: Fix comments and place two common policy template as macros.
V8: Fix rebase conflict issues and CI warning
Haifei Luo (1):
app/testpmd: support policy actions per color
Li Zhang (1):
ethdev: add pre-defined meter policy API
app/test-flow-perf/main.c | 7 - app/test-pmd/cmdline.c | 14 +- app/test-pmd/cmdline_flow.c | 118 ++++- app/test-pmd/cmdline_mtr.c | 257 +++------- app/test-pmd/cmdline_mtr.h | 4 +- app/test-pmd/config.c | 32 ++ app/test-pmd/testpmd.h | 2 + doc/guides/prog_guide/rte_flow.rst | 21 + .../traffic_metering_and_policing.rst | 16 +- doc/guides/rel_notes/release_21_05.rst | 21 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 48 +- 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 | 8 +- drivers/net/mlx5/mlx5_flow_dv.c | 461 +----------------- 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 | 290 ++++++++--- lib/librte_ethdev/rte_flow.h | 22 + lib/librte_ethdev/rte_mtr.c | 55 ++- lib/librte_ethdev/rte_mtr.h | 223 +++++++-- lib/librte_ethdev/rte_mtr_driver.h | 44 +- lib/librte_ethdev/version.map | 5 +- 25 files changed, 872 insertions(+), 1270 deletions(-)
Signature · 1 line
2.27.0
PATCH v8 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.
Allow coloring the packet using a new rte_flow_action_color as could be done by the old policy API.
Add two common policy template as macros in the head file.
The next API function were added:
- rte_mtr_meter_policy_add
- 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.
net/mlx5: clean meter creation management Cleans and breaks part of the current meter management in order to allow better design with policy API.
--- 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/prog_guide/rte_flow.rst | 21 + .../traffic_metering_and_policing.rst | 16 +- doc/guides/rel_notes/release_21_05.rst | 21 + 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 | 8 +- drivers/net/mlx5/mlx5_flow_dv.c | 461 +----------------- 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 | 290 ++++++++--- lib/librte_ethdev/rte_flow.h | 22 + lib/librte_ethdev/rte_mtr.c | 55 ++- lib/librte_ethdev/rte_mtr.h | 223 +++++++-- lib/librte_ethdev/rte_mtr_driver.h | 44 +- lib/librte_ethdev/version.map | 5 +- 22 files changed, 603 insertions(+), 1256 deletions(-)
app/test-flow-perf/main.c +0 -7
@@ -928,13 +928,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, ¶ms,1 , &error);if (ret !=0 ) { printf("Port %u create meter idx(%d) error(%d) message: %s\n",
app/test-pmd/cmdline.c +0 -1
@@ -17074,7 +17074,6 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_del_port_meter, (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, - (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, (cmdline_parse_inst_t *)&cmd_mcast_addr,
app/test-pmd/cmdline_mtr.c +0 -172
196 lines not on this page · raw message
app/test-pmd/cmdline_mtr.h +0 -1
@@ -17,7 +17,6 @@ extern cmdline_parse_inst_t cmd_disable_port_meter;extern cmdline_parse_inst_t cmd_del_port_meter;extern cmdline_parse_inst_t cmd_set_port_meter_profile;extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table; -extern cmdline_parse_inst_t cmd_set_port_meter_policer_action;extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;extern cmdline_parse_inst_t cmd_show_port_meter_stats;
doc/guides/prog_guide/rte_flow.rst +21 -0
@@ -2841,6 +2841,27 @@ for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. | ``value`` | immediate value or a pointer to this value | +---------------+----------------------------------------------------------+ +Action: ``METER_COLOR`` +^^^^^^^^^^^^^^^^^^^^^^^ + +Color the packet to reflect the meter color result. + +The meter action must be configured before meter color action. +Meter color action is set to a color to reflect the meter color result. +Set the meter color in the mbuf to the selected color. +The meter color action output color is the output color of the packet, +which is set in the packet meta-data (i.e. struct ``rte_mbuf::sched::color``) + +.. _table_rte_flow_action_meter_color: + +.. table:: METER_COLOR + + +-----------------+--------------+ + | Field | Value | + +=================+==============+ + | ``meter_color`` | Packet color | + +-----------------+--------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/prog_guide/traffic_metering_and_policing.rst +4 -12
@@ -56,18 +56,10 @@ The processing done for each input packet hitting an MTR object is: color blind mode, which is equivalent to considering all input packets initially colored as green. -* Policing: There is a separate policer action configured for each meter - output color, which can: - - * Drop the packet. - - * Keep the same packet color: the policer output color matches the meter - output color (essentially a no-op action). - - * Recolor the packet: the policer output color is set to a different color - than the meter output color. The policer output color is the output color - of the packet, which is set in the packet meta-data (i.e. struct - ``rte_mbuf::sched::color``). +* There is a meter policy API to manage pre-defined policies for meter. + Any rte_flow action list can be configured per color for each policy. + A meter object configured with a policy executes the actions per packet + according to the packet color. * Statistics: The set of counters maintained for each MTR object is configurable and subject to the implementation support. This set includes
doc/guides/rel_notes/release_21_05.rst +21 -0
@@ -192,6 +192,27 @@ New Features * Added command to dump internal representation information of single flow. ``flow dump (port_id) rule (rule_id)`` + * deleted the port meter policer action command . + ``set port meter policer action (port_id) (mtr_id) (action_mask) ...`` + * Added command to create meter policy. + ``add port meter policy (port_id) (policy_id) g_actions {action} end y_actions {action} end r_actions {action} end`` + * Added command to delete meter policy. + ``del port meter policy (port_id) (policy_id)`` + +* **Updated meter API.** + + * ethdev: Deleted meter policer API to support policy API. + ``rte_mtr_policer_actions_update()`` + * ethdev: Added meter API to support pre-defined policy, rte_flow action list per color. + ``rte_mtr_meter_policy_add()``, ``rte_mtr_meter_policy_delete()`` and + ``rte_mtr_create_with_policy()`` + * ethdev: Removed rte_mtr_policer_action from rte_mtr_params structures. + * ethdev: Added rte_mtr_meter_policy_params structures to support policy API. + * ethdev: Added meter_policy_id into rte_mtr_params structures. + * ethdev: Removed policer_action_recolor_supported and policer_action_drop_supported from rte_mtr_capabilities structures. + * ethdev: Added meter_policy_n_max into rte_mtr_capabilities structures. + * ethdev: Added RTE_FLOW_ACTION_TYPE_METER_COLOR in enum rte_flow_action_type. + * ethdev: Added RTE_MTR_ERROR_TYPE_METER_POLICY_ID and RTE_MTR_ERROR_TYPE_METER_POLICY_ID into rte_mtr_error_type. Removed Items -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -18
@@ -2833,24 +2833,6 @@ Set meter dscp table for the ethernet device:: testpmd> set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0) \ (dscp_tbl_entry1)...(dscp_tbl_entry63)] -set port meter policer action -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Set meter policer action for the ethernet device:: - - testpmd> set port meter policer action (port_id) (mtr_id) (action_mask) \ - (action0) [(action1) (action1)] - -where: - -* ``action_mask``: Bit mask indicating which policer actions need to be - updated. One or more policer actions can be updated in a single function - invocation. To update the policer action associated with color C, bit - (1 << C) needs to be set in *action_mask* and element at position C - in the *actions* array needs to be valid. -* ``actionx``: Policer action for the color x, - RTE_MTR_GREEN <= x < RTE_MTR_COLORS - set port meter stats mask ~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/mlx5/mlx5.h +2 -22
@@ -584,14 +584,6 @@ struct mlx5_dev_shared_port {/* Modify this value if enum rte_mtr_color changes. */ #define RTE_MTR_DROPPED RTE_COLORS -/* Meter policer statistics */ -struct mlx5_flow_policer_stats { -uint32_t pass_cnt; -/**< Color counter for pass. */ -uint32_t drop_cnt; -/**< Color counter for drop. */ -}; -/* Meter table structure. */ struct mlx5_meter_domain_info {struct mlx5_flow_tbl_resource *tbl;
@@ -630,24 +622,12 @@ struct mlx5_meter_domains_infos {/* Meter parameter structure. */ struct mlx5_flow_meter_info { -uint32_t meter_id; -/**< Meter id. */ struct mlx5_flow_meter_profile *profile;/**< Meter profile parameters. */ rte_spinlock_t sl;/**< Meter action spinlock. */ -/** Policer actions (per meter output color). */ -enum rte_mtr_policer_action action[RTE_COLORS ];/** Set of stats counters to be enabled. * @see enum rte_mtr_stats_type */ -uint32_t green_bytes:1 ; -/** Set green bytes stats to be enabled. */ -uint32_t green_pkts:1 ; -/** Set green packets stats to be enabled. */ -uint32_t red_bytes:1 ; -/** Set red bytes stats to be enabled. */ -uint32_t red_pkts:1 ; -/** Set red packets stats to be enabled. */ uint32_t bytes_dropped:1 ;/** Set bytes dropped stats to be enabled. */ uint32_t pkts_dropped:1 ;
@@ -682,8 +662,8 @@ struct mlx5_flow_meter_info { uint32_t transfer:1;struct mlx5_meter_domains_infos *mfts;/**< Flow table created for this meter. */ -struct mlx5_flow_policer_stats policer_stats; -/**< Meter policer statistics. */ +uint32_t drop_cnt; +/**< Color counter for drop. */ uint32_t ref_cnt;/**< Use count. */ struct mlx5_indexed_pool *flow_ipool;
drivers/net/mlx5/mlx5_flow.c +0 -46
52 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +2 -16
@@ -839,6 +839,8 @@ struct mlx5_legacy_flow_meter {/* Must be the first in struct. */ TAILQ_ENTRY (mlx5_legacy_flow_meter) next;/**< Pointer to the next flow meter structure. */ +uint32_t meter_id; +/**< Meter id. */ uint32_t idx;/* Index to meter object. */ };
@@ -1097,14 +1099,6 @@ typedef struct mlx5_meter_domains_infos *(*mlx5_flow_create_mtr_tbls_t) (struct rte_eth_dev *dev);typedef int (*mlx5_flow_destroy_mtr_tbls_t )(struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbls); -typedef int (*mlx5_flow_create_policer_rules_t ) - (struct rte_eth_dev *dev, -struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr); -typedef int (*mlx5_flow_destroy_policer_rules_t ) - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr);typedef uint32_t (*mlx5_flow_mtr_alloc_t ) (struct rte_eth_dev *dev); typedef void (*mlx5_flow_mtr_free_t)(struct rte_eth_dev *dev,
@@ -1161,8 +1155,6 @@ struct mlx5_flow_driver_ops {mlx5_flow_query_t query;mlx5_flow_create_mtr_tbls_t create_mtr_tbls;mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls; -mlx5_flow_create_policer_rules_t prepare_policer_rules; -mlx5_flow_destroy_policer_rules_t destroy_policer_rules;mlx5_flow_mtr_alloc_t create_meter;mlx5_flow_mtr_free_t free_meter;mlx5_flow_counter_alloc_t counter_alloc;
@@ -1392,12 +1384,6 @@ struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls (struct rte_eth_dev *dev);int mlx5_flow_destroy_mtr_tbls (struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbl); -int mlx5_flow_prepare_policer_rules (struct rte_eth_dev *dev, -struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr); -int mlx5_flow_destroy_policer_rules (struct rte_eth_dev *dev, -struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr);int mlx5_flow_meter_flush (struct rte_eth_dev *dev,struct rte_mtr_error *error);int mlx5_flow_dv_discover_counter_offset_support (struct rte_eth_dev *dev);
drivers/net/mlx5/mlx5_flow_aso.c +4 -4
@@ -808,8 +808,8 @@ mlx5_aso_meter_update_by_wqe(struct mlx5_dev_ctx_shared *sh,/* Waiting for wqe resource. */ rte_delay_us_sleep (MLX5_ASO_WQE_CQE_RESPONSE_DELAY ); }while (--poll_wqe_times); -DRV_LOG (ERR ,"Fail to send WQE for ASO meter %d" , - mtr->fm.meter_id); +DRV_LOG (ERR ,"Fail to send WQE for ASO meter offset %d" , + mtr->offset);return -1 ; }
@@ -844,7 +844,7 @@ mlx5_aso_mtr_wait(struct mlx5_dev_ctx_shared *sh,/* Waiting for CQE ready. */ rte_delay_us_sleep (MLX5_ASO_WQE_CQE_RESPONSE_DELAY ); }while (--poll_cqe_times); -DRV_LOG (ERR ,"Fail to poll CQE ready for ASO meter %d" , - mtr->fm.meter_id); +DRV_LOG (ERR ,"Fail to poll CQE ready for ASO meter offset %d" , + mtr->offset);return -1 ; }
drivers/net/mlx5/mlx5_flow_dv.c +2 -459
501 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +11 -358
491 lines not on this page · raw message
drivers/net/softnic/rte_eth_softnic_flow.c +15 -4
@@ -1166,6 +1166,7 @@ flow_rule_action_get(struct pmd_internals *softnic, {struct softnic_table_action_profile *profile;struct softnic_table_action_profile_params *params; +struct softnic_mtr_meter_policy *policy;int n_jump_queue_rss_drop =0 ;int n_count =0 ;int n_mark =0 ;
@@ -1621,15 +1622,25 @@ flow_rule_action_get(struct pmd_internals *softnic,return -1 ; } } - +/* Meter policy must exist */ + policy =softnic_mtr_meter_policy_find (softnic, + m->params.meter_policy_id); +if (policy ==NULL ) { +rte_flow_error_set (error, +EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL , +"METER: fail to find meter policy" ); +return -1 ; + }/* RTE_TABLE_ACTION_METER */ rule_action->mtr.mtr[0 ].meter_profile_id = meter_profile_id; rule_action->mtr.mtr[0 ].policer[RTE_COLOR_GREEN ] = -softnic_table_action_policer (m->params.action[RTE_COLOR_GREEN ]); + policy->policer[RTE_COLOR_GREEN ]; rule_action->mtr.mtr[0 ].policer[RTE_COLOR_YELLOW ] = -softnic_table_action_policer (m->params.action[RTE_COLOR_YELLOW ]); + policy->policer[RTE_COLOR_YELLOW ]; rule_action->mtr.mtr[0 ].policer[RTE_COLOR_RED ] = -softnic_table_action_policer (m->params.action[RTE_COLOR_RED ]); + policy->policer[RTE_COLOR_RED ]; rule_action->mtr.tc_mask =1 ; rule_action->action_mask |=1 <<RTE_TABLE_ACTION_MTR ;break ;
drivers/net/softnic/rte_eth_softnic_internals.h +15 -3
@@ -83,6 +83,16 @@ struct softnic_mtr_meter_profile {TAILQ_HEAD (softnic_mtr_meter_profile_list, softnic_mtr_meter_profile); +/* MTR meter policy */ +struct softnic_mtr_meter_policy { +TAILQ_ENTRY (softnic_mtr_meter_policy) node; +uint32_t meter_policy_id; +enum rte_table_action_policer policer[RTE_COLORS ]; +uint32_t n_users; +}; + +TAILQ_HEAD (softnic_mtr_meter_policy_list, softnic_mtr_meter_policy); +/* MTR meter object */ struct softnic_mtr {TAILQ_ENTRY (softnic_mtr) node;
@@ -95,6 +105,7 @@ TAILQ_HEAD(softnic_mtr_list, softnic_mtr);struct mtr_internals {struct softnic_mtr_meter_profile_list meter_profiles; +struct softnic_mtr_meter_policy_list meter_policies;struct softnic_mtr_list mtrs; };
@@ -678,6 +689,10 @@ struct softnic_mtr_meter_profile * softnic_mtr_meter_profile_find(struct pmd_internals *p, uint32_t meter_profile_id); +struct softnic_mtr_meter_policy * +softnic_mtr_meter_policy_find (struct pmd_internals *p, +uint32_t meter_policy_id); +extern const struct rte_mtr_ops pmd_mtr_ops;/**
@@ -841,9 +856,6 @@ softnic_table_action_profile_create(struct pmd_internals *p,const char *name, struct softnic_table_action_profile_params *params); -enum rte_table_action_policer -softnic_table_action_policer (enum rte_mtr_policer_action action); -/** * Pipeline */
drivers/net/softnic/rte_eth_softnic_meter.c +228 -62
422 lines not on this page · raw message
lib/librte_ethdev/rte_flow.h +22 -0
@@ -32,6 +32,7 @@#include <rte_ecpri.h> #include <rte_mbuf.h> #include <rte_mbuf_dyn.h> +#include <rte_meter.h> #ifdef __cplusplusextern "C" {
@@ -2267,6 +2268,14 @@ 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. +* Set the meter color in the mbuf to the selected color. +* +* See struct rte_flow_action_meter_color. +*/ + RTE_FLOW_ACTION_TYPE_METER_COLOR, };/**
@@ -2859,6 +2868,19 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_METER_COLOR +* +* The meter color should be set in the packet meta-data +* (i.e. struct rte_mbuf::sched::color). +*/ +struct rte_flow_action_meter_color { +enum rte_color color;/**< Packet color. */ +}; +/** * Field IDs for MODIFY_FIELD action. */
lib/librte_ethdev/rte_mtr.c +44 -11
79 lines not on this page · raw message
lib/librte_ethdev/rte_mtr.h +174 -49
303 lines not on this page · raw message
lib/librte_ethdev/rte_mtr_driver.h +34 -10
72 lines not on this page · raw message
lib/librte_ethdev/version.map +4 -1
@@ -138,7 +138,6 @@ EXPERIMENTAL { rte_mtr_meter_profile_add; rte_mtr_meter_profile_delete; rte_mtr_meter_profile_update; - rte_mtr_policer_actions_update; rte_mtr_stats_read; rte_mtr_stats_update;
@@ -246,6 +245,10 @@ EXPERIMENTAL { # added in 21.05 rte_eth_representor_info_get; + rte_mtr_meter_policy_add; + rte_mtr_meter_policy_delete; + rte_mtr_meter_policy_update; + rte_mtr_meter_policy_validate; }; INTERNAL {
Signature · 1 line
2.27.0
Re: [dpdk-dev] [PATCH v8 1/2] ethdev: add pre-defined meter policy API
Hi Li
Quoted 52 lines
-----Original Message-----
From: Li Zhang <[email protected]>
Sent: Thursday, April 15, 2021 12:20 PM
Subject: [PATCH v8 1/2] ethdev: add pre-defined meter policy APICurrently, 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_flowaction definition.
A list ofrte_flowactions 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_idis added into structrte_mtr_params. So that it can get the policy during the meters creation.Allow coloring the packet using a new
rte_flow_action_coloras could be done by the old policy API.Add two common policy template as macros in the head file.
The next API function were added:
-rte_mtr_meter_policy_add
-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_updateTo support this API the following app were changed:
app/test-flow-perf: clean meter policer app/testpmd: clean meter policerTo support this API the following drivers were changed:
net/softnic: support meter policy API
1. cleans meterrte_mtr_policer_action.
2. Support policy API to get color action as policer action did. The color action will be mapped intorte_table_action_policer.net/mlx5: clean meter creation management Cleans and breaks part of the current meter management in order to allow better design with policy API.
Quoted 6 lines
Signed-off-by Li Zhang <[email protected]>Signed-off-by Haifei Luo <[email protected]>Signed-off-by Jiawei Wang <[email protected]>Acked-by Matan Azrad <[email protected]>Acked-by Ray Kinsella <[email protected]>---
Thanks,
Ori
Re: [dpdk-dev] [PATCH v8 1/2] ethdev: add pre-defined meter policy API
In reply to Li Zhang<Snip>
Quoted 32 lines
drivers/net/softnic/rte_eth_softnic_meter.c +9
-0+/* MTR meter policy add */ +static int +pmd_mtr_meter_policy_add (struct rte_eth_dev *dev, +uint32_t meter_policy_id, +struct rte_mtr_meter_policy_params *policy, +struct rte_mtr_error *error) +{ +struct pmd_internals *p = dev->data->dev_private; + struct softnic_mtr_meter_policy_list *mpl = &p-Quoted 1 line
mtr.meter_policies;
drivers/net/softnic/rte_eth_softnic_meter.c +22
-0+struct softnic_mtr_meter_policy *mp; +const struct rte_flow_action *act; +const struct rte_flow_action_meter_color *recolor; +uint32_t i; +bool valid_act_found; + +if (policy ==NULL ) +return -rte_mtr_error_set (error, +EINVAL , +RTE_MTR_ERROR_TYPE_METER_POLICY , +NULL , +"Null meter policy invalid" ); + +/* Meter policy must not exist. */ + mp =softnic_mtr_meter_policy_find (p, meter_policy_id); +if (mp !=NULL ) +return -rte_mtr_error_set (error, +EINVAL , +RTE_MTR_ERROR_TYPE_METER_POLICY_ID , +NULL , +"Meter policy already exists" ); +
drivers/net/softnic/rte_eth_softnic_meter.c pmd_mtr_meter_profile_delete(struct rte_eth_dev *dev, · line 244
Quoted 10 lines
drivers/net/softnic/rte_eth_softnic_meter.c +10
-0+for (i =0 ; i <RTE_COLORS ; i++) { +if (policy->actions[i] ==NULL ) +return -rte_mtr_error_set (error, +EINVAL , +RTE_MTR_ERROR_TYPE_METER_POLICY , +NULL , +"Null action list" ); +for (act = policy->actions[i], valid_act_found = false; + act && act->type !=RTE_FLOW_ACTION_TYPE_END ; + act++) {
Hi Li,
No need to check "act" in for loop instruction as it is validated before the for loop. Also, would be good to skip all the steps inside this loop for the actions like RTE_FLOW_ACTION_TYPE_VOID. After for loop, will be good to check "valid_act_found" is true else return an error for that color action.
Rest seems good to me
With above fix for softnic-
Re: [dpdk-dev] [PATCH v8 1/2] ethdev: add pre-defined meter policy API
Thanks Jasvinder's comments!
Li is on vacation so I help to update the code changes based on your comments, V9 is sent with your ack.
Quoted 75 lines
-----Original Message-----
From: Singh, Jasvinder <[email protected]>
Sent: Monday, April 19, 2021 8:35 PM
To: Li Zhang <[email protected]>; [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>; Dumitrescu, Cristian <[email protected]>; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; Wisam Monther <[email protected]>; Li, Xiaoyun <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Andrew Rybchenko <[email protected]>; Ray Kinsella <[email protected]>; Neil Horman <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Roni Bar Yanai <[email protected]>; Haifei Luo <[email protected]>; Jiawei(Jonny) Wang <[email protected]>
Subject: RE: [PATCH v8 1/2] ethdev: add pre-defined meter policy API<Snip>
Quoted 32 lines
drivers/net/softnic/rte_eth_softnic_meter.c +9
-0+/* MTR meter policy add */ +static int +pmd_mtr_meter_policy_add (struct rte_eth_dev *dev, +uint32_t meter_policy_id, +struct rte_mtr_meter_policy_params *policy, +struct rte_mtr_error *error) +{ +struct pmd_internals *p = dev->data->dev_private; + struct softnic_mtr_meter_policy_list *mpl = &p-Quoted 1 line
mtr.meter_policies;
drivers/net/softnic/rte_eth_softnic_meter.c +22
-0+struct softnic_mtr_meter_policy *mp; +const struct rte_flow_action *act; +const struct rte_flow_action_meter_color *recolor; +uint32_t i; +bool valid_act_found; + +if (policy ==NULL ) +return -rte_mtr_error_set (error, +EINVAL , +RTE_MTR_ERROR_TYPE_METER_POLICY , +NULL , +"Null meter policy invalid" ); + +/* Meter policy must not exist. */ + mp =softnic_mtr_meter_policy_find (p, meter_policy_id); +if (mp !=NULL ) +return -rte_mtr_error_set (error, +EINVAL , +RTE_MTR_ERROR_TYPE_METER_POLICY_ID , +NULL , +"Meter policy already exists" ); +drivers/net/softnic/rte_eth_softnic_meter.c pmd_mtr_meter_profile_delete(struct rte_eth_dev *dev, · line 244
Quoted 10 lines
drivers/net/softnic/rte_eth_softnic_meter.c +10
-0+for (i =0 ; i <RTE_COLORS ; i++) { +if (policy->actions[i] ==NULL ) +return -rte_mtr_error_set (error, +EINVAL , +RTE_MTR_ERROR_TYPE_METER_POLICY , +NULL , +"Null action list" ); +for (act = policy->actions[i], valid_act_found = false; + act && act->type !=RTE_FLOW_ACTION_TYPE_END ; + act++) {Hi Li,
No need to check "act" in for loop instruction as it is validated before the for loop. Also, would be good to skip all the steps inside this loop for the actions likeRTE_FLOW_ACTION_TYPE_VOID. After for loop, will be good to check "valid_act_found" is true else return an error for that color action.Rest seems good to me
With above fix for softnic-
Acked-by Jasvinder Singh <[email protected]>
PATCH v8 2/2 app/testpmd: support policy actions per color
In reply to Li ZhangFrom: Haifei Luo <[email protected]>
Add the create/del policy CLIs to support actions per color. The CLIs are:
Create: add port meter policy (port_id) (policy_id) g_actions (actions) y_actions (actions) r_actions (actions)
Delete: del port meter policy (port_id) (policy_id)
Examples:
testpmd> add port meter policy 0 1 g_actions rss / end y_actions end r_actions drop / end
testpmd> del port meter policy 0 1
--- app/test-pmd/cmdline.c | 13 ++- app/test-pmd/cmdline_flow.c | 118 +++++++++++++++++++- app/test-pmd/cmdline_mtr.c | 85 +++++++++++++- app/test-pmd/cmdline_mtr.h | 3 + app/test-pmd/config.c | 32 ++++++ app/test-pmd/testpmd.h | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 30 ++++- 7 files changed, 269 insertions(+), 14 deletions(-)
app/test-pmd/cmdline.c +10 -3
@@ -705,9 +705,8 @@ static void cmd_help_long_parsed(void *parsed_result,"del port meter profile (port_id) (profile_id)\n" " meter profile delete\n\n" -"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" -"(g_action) (y_action) (r_action) (stats_mask) (shared)\n" -"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" +"create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n" +"(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" "(dscp_tbl_entry63)]\n" " meter create\n\n"
@@ -720,6 +719,13 @@ static void cmd_help_long_parsed(void *parsed_result,"del port meter (port_id) (mtr_id)\n" " meter delete\n\n" +"add port meter policy (port_id) (policy_id) g_actions (actions)\n" +"y_actions (actions) r_actions (actions)\n" +" meter policy add\n\n" + +"del port meter policy (port_id) (policy_id)\n" +" meter policy delete\n\n" +"set port meter profile (port_id) (mtr_id) (profile_id)\n" " meter update meter profile\n\n"
@@ -17072,6 +17078,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_enable_port_meter, (cmdline_parse_inst_t *)&cmd_disable_port_meter, (cmdline_parse_inst_t *)&cmd_del_port_meter, + (cmdline_parse_inst_t *)&cmd_del_port_meter_policy, (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
app/test-pmd/cmdline_flow.c +117 -1
178 lines not on this page · raw message
app/test-pmd/cmdline_mtr.c +79 -6
140 lines not on this page · raw message
app/test-pmd/cmdline_mtr.h +3 -0
@@ -4,6 +4,7 @@#ifndef _CMDLINE_MTR_H_#define _CMDLINE_MTR_H_ +#include <rte_mtr.h> /* Traffic Metering and Policing */ extern cmdline_parse_inst_t cmd_show_port_meter_cap;
@@ -15,9 +16,11 @@ extern cmdline_parse_inst_t cmd_create_port_meter;extern cmdline_parse_inst_t cmd_enable_port_meter;extern cmdline_parse_inst_t cmd_disable_port_meter;extern cmdline_parse_inst_t cmd_del_port_meter; +extern cmdline_parse_inst_t cmd_del_port_meter_policy;extern cmdline_parse_inst_t cmd_set_port_meter_profile;extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table;extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;extern cmdline_parse_inst_t cmd_show_port_meter_stats; +void print_mtr_err_msg (struct rte_mtr_error *error);#endif /* _CMDLINE_MTR_H_ */
app/test-pmd/config.c +32 -0
@@ -38,6 +38,7 @@#include <rte_string_fns.h> #include <rte_cycles.h> #include <rte_flow.h> +#include <rte_mtr.h> #include <rte_errno.h> #ifdef RTE_NET_IXGBE #include <rte_pmd_ixgbe.h>
@@ -52,6 +53,7 @@#include <rte_hexdump.h> #include "testpmd.h" +#include "cmdline_mtr.h" #define ETHDEV_FWVERS_LEN 32
@@ -1465,6 +1467,36 @@ action_alloc(portid_t port_id, uint32_t id,return 0 ; } +/** Add port meter policy */ +int +port_meter_policy_add (portid_t port_id,uint32_t policy_id, +const struct rte_flow_action *actions) +{ +struct rte_mtr_error error; +const struct rte_flow_action *act = actions; +const struct rte_flow_action *start; +struct rte_mtr_meter_policy_params policy; +uint32_t i =0 , act_n; +int ret; + +for (i =0 ; i <RTE_COLORS ; i++) { +for (act_n =0 , start = act; + act->type !=RTE_FLOW_ACTION_TYPE_END ; act++) + act_n++; +if (act_n && act->type ==RTE_FLOW_ACTION_TYPE_END ) + policy.actions[i] = start; +else + policy.actions[i] =NULL ; + act++; + } + ret =rte_mtr_meter_policy_add (port_id, + policy_id, + &policy, &error); +if (ret) +print_mtr_err_msg (&error); +return ret; +} +/** Create shared action */ int port_shared_action_create(portid_t port_id, uint32_t id,
app/test-pmd/testpmd.h +2 -0
@@ -838,6 +838,8 @@ void port_flow_tunnel_list(portid_t port_id);void port_flow_tunnel_destroy (portid_t port_id,uint32_t tunnel_id);void port_flow_tunnel_create (portid_t port_id,const struct tunnel_ops *ops);int port_flow_isolate (portid_t port_id,int set); +int port_meter_policy_add (portid_t port_id,uint32_t policy_id, +const struct rte_flow_action *actions);void rx_ring_desc_display (portid_t port_id,queueid_t rxq_id,uint16_t rxd_id);void tx_ring_desc_display (portid_t port_id,queueid_t txq_id,uint16_t txd_id);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +26 -4
@@ -2767,13 +2767,37 @@ Delete meter profile from the ethernet device:: testpmd> del port meter profile (port_id) (profile_id) +create port policy +~~~~~~~~~~~~~~~~~~ + +Create new policy object for the ethernet device:: + + testpmd> add port meter policy (port_id) (policy_id) g_actions \ + {action} y_actions {action} r_actions {action} + +where: + +* ``policy_id``: policy ID. +* ``action``: action lists for green/yellow/red colors. + +delete port policy +~~~~~~~~~~~~~~~~~~ + +Delete policy object for the ethernet device:: + + testpmd> del port meter policy (port_id) (policy_id) + +where: + +* ``policy_id``: policy ID. + create port meter ~~~~~~~~~~~~~~~~~ Create new meter object for the ethernet device:: testpmd> create port meter (port_id) (mtr_id) (profile_id) \ - (meter_enable) (g_action) (y_action) (r_action) (stats_mask) (shared) \ + (policy_id) (meter_enable) (stats_mask) (shared) \ (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\ (dscp_tbl_entry63)]
@@ -2781,11 +2805,9 @@ where: * ``mtr_id``: meter object ID. * ``profile_id``: ID for the meter profile. +* ``policy_id``: ID for the policy. * ``meter_enable``: When this parameter has a non-zero value, the meter object gets enabled at the time of creation, otherwise remains disabled. -* ``g_action``: Policer action for the packet with green color. -* ``y_action``: Policer action for the packet with yellow color. -* ``r_action``: Policer action for the packet with red color. * ``stats_mask``: Mask of statistics counter types to be enabled for the meter object. * ``shared``: When this parameter has a non-zero value, the meter object is
Signature · 1 line
2.27.0
v9 cover Support meter policy API
In reply to Li ZhangCurrently, 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.
Add two common policy template as macros in the header file,
RFC ("ethdev: add pre-defined meter policy API")
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
Depends-on: series=16351 ("Add ASO meter support in MLX5 PMD ")
https://patchwork.dpdk.org/project/dpdk/list/?series=16351
V2: Delete default policy and change relation doc files.
V3: Fix coding style issues.
V4: Fix comments about Depends-on
V5: Fix comments about rte_mtr_meter_policy_add.
V6: Delete policy example.
V7: Fix comments and place two common policy template as macros.
V8: Fix rebase conflict issues and CI warning
V9: Rebase and Fix the comments for softnic driver.
Haifei Luo (1):
app/testpmd: support policy actions per color
Li Zhang (1):
ethdev: add pre-defined meter policy API
app/test-flow-perf/main.c | 7 - app/test-pmd/cmdline.c | 14 +- app/test-pmd/cmdline_flow.c | 118 +++++- app/test-pmd/cmdline_mtr.c | 257 ++++-------- app/test-pmd/cmdline_mtr.h | 4 +- app/test-pmd/config.c | 32 ++ app/test-pmd/testpmd.h | 2 + doc/guides/prog_guide/rte_flow.rst | 21 + .../prog_guide/traffic_metering_and_policing.rst | 16 +- doc/guides/rel_notes/release_21_05.rst | 21 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 48 ++- 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 | 8 +- drivers/net/mlx5/mlx5_flow_dv.c | 461 +-------------------- drivers/net/mlx5/mlx5_flow_meter.c | 369 +---------------- drivers/net/softnic/rte_eth_softnic_flow.c | 19 +- drivers/net/softnic/rte_eth_softnic_internals.h | 18 +- drivers/net/softnic/rte_eth_softnic_meter.c | 297 ++++++++++--- lib/librte_ethdev/rte_flow.h | 22 + lib/librte_ethdev/rte_mtr.c | 55 ++- lib/librte_ethdev/rte_mtr.h | 223 +++++++--- lib/librte_ethdev/rte_mtr_driver.h | 44 +- lib/librte_ethdev/version.map | 5 +- 25 files changed, 879 insertions(+), 1270 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v9 1/2 ethdev: add pre-defined meter policy API
From: Li Zhang <[email protected]>
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.
Allow coloring the packet using a new rte_flow_action_color as could be done by the old policy API.
Add two common policy template as macros in the head file.
The next API function were added:
- rte_mtr_meter_policy_add
- 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. Supports policy API to get color action as policer action did. The color action will be mapped into rte_table_action_policer.
net/mlx5: clean meter creation management Cleans and breaks part of the current meter management in order to allow better design with policy API.
--- 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/prog_guide/rte_flow.rst | 21 + .../prog_guide/traffic_metering_and_policing.rst | 16 +- doc/guides/rel_notes/release_21_05.rst | 21 + 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 | 8 +- drivers/net/mlx5/mlx5_flow_dv.c | 461 +-------------------- drivers/net/mlx5/mlx5_flow_meter.c | 369 +---------------- drivers/net/softnic/rte_eth_softnic_flow.c | 19 +- drivers/net/softnic/rte_eth_softnic_internals.h | 18 +- drivers/net/softnic/rte_eth_softnic_meter.c | 297 ++++++++++--- lib/librte_ethdev/rte_flow.h | 22 + lib/librte_ethdev/rte_mtr.c | 55 ++- lib/librte_ethdev/rte_mtr.h | 223 +++++++--- lib/librte_ethdev/rte_mtr_driver.h | 44 +- lib/librte_ethdev/version.map | 5 +- 22 files changed, 610 insertions(+), 1256 deletions(-)
app/test-flow-perf/main.c +0 -7
@@ -928,13 +928,6 @@ struct multi_cores_pool {/*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, ¶ms,1 , &error);if (ret !=0 ) { printf("Port %u create meter idx(%d) error(%d) message: %s\n",
app/test-pmd/cmdline.c +0 -1
@@ -17074,7 +17074,6 @@ struct cmd_showport_macs_result { (cmdline_parse_inst_t *)&cmd_del_port_meter, (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, - (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, (cmdline_parse_inst_t *)&cmd_mcast_addr,
app/test-pmd/cmdline_mtr.c +0 -172
196 lines not on this page · raw message
app/test-pmd/cmdline_mtr.h +0 -1
@@ -17,7 +17,6 @@extern cmdline_parse_inst_t cmd_del_port_meter;extern cmdline_parse_inst_t cmd_set_port_meter_profile;extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table; -extern cmdline_parse_inst_t cmd_set_port_meter_policer_action;extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;extern cmdline_parse_inst_t cmd_show_port_meter_stats;
doc/guides/prog_guide/rte_flow.rst +21 -0
@@ -2841,6 +2841,27 @@ for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. | ``value`` | immediate value or a pointer to this value | +---------------+----------------------------------------------------------+ +Action: ``METER_COLOR`` +^^^^^^^^^^^^^^^^^^^^^^^ + +Color the packet to reflect the meter color result. + +The meter action must be configured before meter color action. +Meter color action is set to a color to reflect the meter color result. +Set the meter color in the mbuf to the selected color. +The meter color action output color is the output color of the packet, +which is set in the packet meta-data (i.e. struct ``rte_mbuf::sched::color``) + +.. _table_rte_flow_action_meter_color: + +.. table:: METER_COLOR + + +-----------------+--------------+ + | Field | Value | + +=================+==============+ + | ``meter_color`` | Packet color | + +-----------------+--------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/prog_guide/traffic_metering_and_policing.rst +4 -12
@@ -56,18 +56,10 @@ The processing done for each input packet hitting an MTR object is: color blind mode, which is equivalent to considering all input packets initially colored as green. -* Policing: There is a separate policer action configured for each meter - output color, which can: - - * Drop the packet. - - * Keep the same packet color: the policer output color matches the meter - output color (essentially a no-op action). - - * Recolor the packet: the policer output color is set to a different color - than the meter output color. The policer output color is the output color - of the packet, which is set in the packet meta-data (i.e. struct - ``rte_mbuf::sched::color``). +* There is a meter policy API to manage pre-defined policies for meter. + Any rte_flow action list can be configured per color for each policy. + A meter object configured with a policy executes the actions per packet + according to the packet color. * Statistics: The set of counters maintained for each MTR object is configurable and subject to the implementation support. This set includes
doc/guides/rel_notes/release_21_05.rst +21 -0
@@ -224,6 +224,27 @@ New Features * Added support for crypto adapter forward mode in octeontx2 event and crypto device driver. + * deleted the port meter policer action command . + ``set port meter policer action (port_id) (mtr_id) (action_mask) ...`` + * Added command to create meter policy. + ``add port meter policy (port_id) (policy_id) g_actions {action} end y_actions {action} end r_actions {action} end`` + * Added command to delete meter policy. + ``del port meter policy (port_id) (policy_id)`` + +* **Updated meter API.** + + * ethdev: Deleted meter policer API to support policy API. + ``rte_mtr_policer_actions_update()`` + * ethdev: Added meter API to support pre-defined policy, rte_flow action list per color. + ``rte_mtr_meter_policy_add()``, ``rte_mtr_meter_policy_delete()`` and + ``rte_mtr_create_with_policy()`` + * ethdev: Removed rte_mtr_policer_action from rte_mtr_params structures. + * ethdev: Added rte_mtr_meter_policy_params structures to support policy API. + * ethdev: Added meter_policy_id into rte_mtr_params structures. + * ethdev: Removed policer_action_recolor_supported and policer_action_drop_supported from rte_mtr_capabilities structures. + * ethdev: Added meter_policy_n_max into rte_mtr_capabilities structures. + * ethdev: Added RTE_FLOW_ACTION_TYPE_METER_COLOR in enum rte_flow_action_type. + * ethdev: Added RTE_MTR_ERROR_TYPE_METER_POLICY_ID and RTE_MTR_ERROR_TYPE_METER_POLICY_ID into rte_mtr_error_type. Removed Items -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -18
@@ -2831,24 +2831,6 @@ Set meter dscp table for the ethernet device:: testpmd> set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0) \ (dscp_tbl_entry1)...(dscp_tbl_entry63)] -set port meter policer action -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Set meter policer action for the ethernet device:: - - testpmd> set port meter policer action (port_id) (mtr_id) (action_mask) \ - (action0) [(action1) (action1)] - -where: - -* ``action_mask``: Bit mask indicating which policer actions need to be - updated. One or more policer actions can be updated in a single function - invocation. To update the policer action associated with color C, bit - (1 << C) needs to be set in *action_mask* and element at position C - in the *actions* array needs to be valid. -* ``actionx``: Policer action for the color x, - RTE_MTR_GREEN <= x < RTE_MTR_COLORS - set port meter stats mask ~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/mlx5/mlx5.h +2 -22
@@ -593,14 +593,6 @@ struct mlx5_dev_shared_port {/* Modify this value if enum rte_mtr_color changes. */ #define RTE_MTR_DROPPED RTE_COLORS -/* Meter policer statistics */ -struct mlx5_flow_policer_stats { -uint32_t pass_cnt; -/**< Color counter for pass. */ -uint32_t drop_cnt; -/**< Color counter for drop. */ -}; -/* Meter table structure. */ struct mlx5_meter_domain_info {struct mlx5_flow_tbl_resource *tbl;
@@ -639,24 +631,12 @@ struct mlx5_meter_domains_infos {/* Meter parameter structure. */ struct mlx5_flow_meter_info { -uint32_t meter_id; -/**< Meter id. */ struct mlx5_flow_meter_profile *profile;/**< Meter profile parameters. */ rte_spinlock_t sl;/**< Meter action spinlock. */ -/** Policer actions (per meter output color). */ -enum rte_mtr_policer_action action[RTE_COLORS ];/** Set of stats counters to be enabled. * @see enum rte_mtr_stats_type */ -uint32_t green_bytes:1 ; -/** Set green bytes stats to be enabled. */ -uint32_t green_pkts:1 ; -/** Set green packets stats to be enabled. */ -uint32_t red_bytes:1 ; -/** Set red bytes stats to be enabled. */ -uint32_t red_pkts:1 ; -/** Set red packets stats to be enabled. */ uint32_t bytes_dropped:1 ;/** Set bytes dropped stats to be enabled. */ uint32_t pkts_dropped:1 ;
@@ -691,8 +671,8 @@ struct mlx5_flow_meter_info { uint32_t transfer:1;struct mlx5_meter_domains_infos *mfts;/**< Flow table created for this meter. */ -struct mlx5_flow_policer_stats policer_stats; -/**< Meter policer statistics. */ +uint32_t drop_cnt; +/**< Color counter for drop. */ uint32_t ref_cnt;/**< Use count. */ struct mlx5_indexed_pool *flow_ipool;
drivers/net/mlx5/mlx5_flow.c +0 -46
52 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +2 -16
@@ -838,6 +838,8 @@ struct mlx5_legacy_flow_meter {/* Must be the first in struct. */ TAILQ_ENTRY (mlx5_legacy_flow_meter) next;/**< Pointer to the next flow meter structure. */ +uint32_t meter_id; +/**< Meter id. */ uint32_t idx;/* Index to meter object. */ };
@@ -1096,14 +1098,6 @@ typedef int (*mlx5_flow_query_t)(struct rte_eth_dev *dev, (struct rte_eth_dev *dev);typedef int (*mlx5_flow_destroy_mtr_tbls_t )(struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbls); -typedef int (*mlx5_flow_create_policer_rules_t ) - (struct rte_eth_dev *dev, -struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr); -typedef int (*mlx5_flow_destroy_policer_rules_t ) - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr);typedef uint32_t (*mlx5_flow_mtr_alloc_t ) (struct rte_eth_dev *dev); typedef void (*mlx5_flow_mtr_free_t)(struct rte_eth_dev *dev,
@@ -1160,8 +1154,6 @@ struct mlx5_flow_driver_ops {mlx5_flow_query_t query;mlx5_flow_create_mtr_tbls_t create_mtr_tbls;mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls; -mlx5_flow_create_policer_rules_t prepare_policer_rules; -mlx5_flow_destroy_policer_rules_t destroy_policer_rules;mlx5_flow_mtr_alloc_t create_meter;mlx5_flow_mtr_free_t free_meter;mlx5_flow_counter_alloc_t counter_alloc;
@@ -1391,12 +1383,6 @@ struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls (struct rte_eth_dev *dev);int mlx5_flow_destroy_mtr_tbls (struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbl); -int mlx5_flow_prepare_policer_rules (struct rte_eth_dev *dev, -struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr); -int mlx5_flow_destroy_policer_rules (struct rte_eth_dev *dev, -struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr);int mlx5_flow_meter_flush (struct rte_eth_dev *dev,struct rte_mtr_error *error);int mlx5_flow_dv_discover_counter_offset_support (struct rte_eth_dev *dev);
drivers/net/mlx5/mlx5_flow_aso.c +4 -4
@@ -808,8 +808,8 @@/* Waiting for wqe resource. */ rte_delay_us_sleep (MLX5_ASO_WQE_CQE_RESPONSE_DELAY ); }while (--poll_wqe_times); -DRV_LOG (ERR ,"Fail to send WQE for ASO meter %d" , - mtr->fm.meter_id); +DRV_LOG (ERR ,"Fail to send WQE for ASO meter offset %d" , + mtr->offset);return -1 ; }
@@ -844,7 +844,7 @@/* Waiting for CQE ready. */ rte_delay_us_sleep (MLX5_ASO_WQE_CQE_RESPONSE_DELAY ); }while (--poll_cqe_times); -DRV_LOG (ERR ,"Fail to poll CQE ready for ASO meter %d" , - mtr->fm.meter_id); +DRV_LOG (ERR ,"Fail to poll CQE ready for ASO meter offset %d" , + mtr->offset);return -1 ; }
drivers/net/mlx5/mlx5_flow_dv.c +2 -459
501 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +11 -358
491 lines not on this page · raw message
drivers/net/softnic/rte_eth_softnic_flow.c +15 -4
@@ -1166,6 +1166,7 @@ struct flow_attr_map * {struct softnic_table_action_profile *profile;struct softnic_table_action_profile_params *params; +struct softnic_mtr_meter_policy *policy;int n_jump_queue_rss_drop =0 ;int n_count =0 ;int n_mark =0 ;
@@ -1621,15 +1622,25 @@ struct flow_attr_map *return -1 ; } } - +/* Meter policy must exist */ + policy =softnic_mtr_meter_policy_find (softnic, + m->params.meter_policy_id); +if (policy ==NULL ) { +rte_flow_error_set (error, +EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL , +"METER: fail to find meter policy" ); +return -1 ; + }/* RTE_TABLE_ACTION_METER */ rule_action->mtr.mtr[0 ].meter_profile_id = meter_profile_id; rule_action->mtr.mtr[0 ].policer[RTE_COLOR_GREEN ] = -softnic_table_action_policer (m->params.action[RTE_COLOR_GREEN ]); + policy->policer[RTE_COLOR_GREEN ]; rule_action->mtr.mtr[0 ].policer[RTE_COLOR_YELLOW ] = -softnic_table_action_policer (m->params.action[RTE_COLOR_YELLOW ]); + policy->policer[RTE_COLOR_YELLOW ]; rule_action->mtr.mtr[0 ].policer[RTE_COLOR_RED ] = -softnic_table_action_policer (m->params.action[RTE_COLOR_RED ]); + policy->policer[RTE_COLOR_RED ]; rule_action->mtr.tc_mask =1 ; rule_action->action_mask |=1 <<RTE_TABLE_ACTION_MTR ;break ;
drivers/net/softnic/rte_eth_softnic_internals.h +15 -3
@@ -83,6 +83,16 @@ struct softnic_mtr_meter_profile {TAILQ_HEAD (softnic_mtr_meter_profile_list, softnic_mtr_meter_profile); +/* MTR meter policy */ +struct softnic_mtr_meter_policy { +TAILQ_ENTRY (softnic_mtr_meter_policy) node; +uint32_t meter_policy_id; +enum rte_table_action_policer policer[RTE_COLORS ]; +uint32_t n_users; +}; + +TAILQ_HEAD (softnic_mtr_meter_policy_list, softnic_mtr_meter_policy); +/* MTR meter object */ struct softnic_mtr {TAILQ_ENTRY (softnic_mtr) node;
@@ -95,6 +105,7 @@ struct softnic_mtr {struct mtr_internals {struct softnic_mtr_meter_profile_list meter_profiles; +struct softnic_mtr_meter_policy_list meter_policies;struct softnic_mtr_list mtrs; };
@@ -678,6 +689,10 @@ struct softnic_mtr_meter_profile * softnic_mtr_meter_profile_find(struct pmd_internals *p, uint32_t meter_profile_id); +struct softnic_mtr_meter_policy * +softnic_mtr_meter_policy_find (struct pmd_internals *p, +uint32_t meter_policy_id); +extern const struct rte_mtr_ops pmd_mtr_ops;/**
@@ -841,9 +856,6 @@ struct softnic_table_action_profile *const char *name, struct softnic_table_action_profile_params *params); -enum rte_table_action_policer -softnic_table_action_policer (enum rte_mtr_policer_action action); -/** * Pipeline */
drivers/net/softnic/rte_eth_softnic_meter.c +235 -62
429 lines not on this page · raw message
lib/librte_ethdev/rte_flow.h +22 -0
@@ -32,6 +32,7 @@#include <rte_ecpri.h> #include <rte_mbuf.h> #include <rte_mbuf_dyn.h> +#include <rte_meter.h> #ifdef __cplusplusextern "C" {
@@ -2267,6 +2268,14 @@ 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. +* Set the meter color in the mbuf to the selected color. +* +* See struct rte_flow_action_meter_color. +*/ + RTE_FLOW_ACTION_TYPE_METER_COLOR, };/**
@@ -2860,6 +2869,19 @@ struct rte_flow_action_set_dscp {struct rte_flow_shared_action ;/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_METER_COLOR +* +* The meter color should be set in the packet meta-data +* (i.e. struct rte_mbuf::sched::color). +*/ +struct rte_flow_action_meter_color { +enum rte_color color;/**< Packet color. */ +}; + +/** * Field IDs for MODIFY_FIELD action. */ enum rte_flow_field_id {
lib/librte_ethdev/rte_mtr.c +44 -11
79 lines not on this page · raw message
lib/librte_ethdev/rte_mtr.h +174 -49
303 lines not on this page · raw message
lib/librte_ethdev/rte_mtr_driver.h +34 -10
72 lines not on this page · raw message
lib/librte_ethdev/version.map +4 -1
@@ -138,7 +138,6 @@ EXPERIMENTAL { rte_mtr_meter_profile_add; rte_mtr_meter_profile_delete; rte_mtr_meter_profile_update; - rte_mtr_policer_actions_update; rte_mtr_stats_read; rte_mtr_stats_update;
@@ -246,6 +245,10 @@ EXPERIMENTAL { # added in 21.05 rte_eth_representor_info_get; + rte_mtr_meter_policy_add; + rte_mtr_meter_policy_delete; + rte_mtr_meter_policy_update; + rte_mtr_meter_policy_validate; }; INTERNAL {
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v9 1/2] ethdev: add pre-defined meter policy API
Quoted 65 lines
-----Original Message-----
From: Jiawei Wang <[email protected]>
Sent: Monday, April 19, 2021 5:08 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; Wisam Jaddo <[email protected]>; Li, Xiaoyun <[email protected]>; Singh, Jasvinder <[email protected]>; Dumitrescu, Cristian <[email protected]>; Thomas Monjalon <[email protected]>; Yigit, Ferruh <[email protected]>; Andrew Rybchenko <[email protected]>; Ray Kinsella <[email protected]>; Neil Horman <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Li Zhang <[email protected]>; Haifei Luo <[email protected]>
Subject: [PATCH v9 1/2] ethdev: add pre-defined meter policy APIFrom: Li Zhang <[email protected]>
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_flowaction definition.
A list ofrte_flowactions 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_idis added into structrte_mtr_params. So that it can get the policy during the meters creation.Allow coloring the packet using a new
rte_flow_action_coloras could be done by the old policy API.Add two common policy template as macros in the head file.
The next API function were added:
-rte_mtr_meter_policy_add
-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_updateTo support this API the following app were changed:
app/test-flow-perf: clean meter policer app/testpmd: clean meter policerTo support this API the following drivers were changed:
net/softnic: support meter policy API
1. Cleans meterrte_mtr_policer_action.
2. Supports policy API to get color action as policer action did. The color action will be mapped intorte_table_action_policer.net/mlx5: clean meter creation management Cleans and breaks part of the current meter management in order to allow better design with policy API.
Quoted 7 lines
Signed-off-by Li Zhang <[email protected]>Signed-off-by Haifei Luo <[email protected]>Signed-off-by Jiawei Wang <[email protected]>Acked-by Matan Azrad <[email protected]>Acked-by Ray Kinsella <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Jasvinder Singh <[email protected]>
Re: [dpdk-dev] [PATCH v9 1/2] ethdev: add pre-defined meter policy API
Thank you, Cristian, appreciate this extra effort!
Regards,
Asaf Penso
Quoted 91 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Dumitrescu, Cristian
Sent: Tuesday, April 20, 2021 2:18 PM
To: Jiawei(Jonny) Wang <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Shahaf Shuler <[email protected]>; Wisam Monther <[email protected]>; Li, Xiaoyun <[email protected]>; Singh, Jasvinder <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Yigit, Ferruh <[email protected]>; Andrew Rybchenko <[email protected]>; Ray Kinsella <[email protected]>; Neil Horman <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Roni Bar Yanai <[email protected]>; Li Zhang <[email protected]>; Haifei Luo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v9 1/2] ethdev: add pre-defined meter policy APIQuoted 63 lines
-----Original Message-----
From: Jiawei Wang <[email protected]>
Sent: Monday, April 19, 2021 5:08 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; Wisam Jaddo <[email protected]>; Li, Xiaoyun <[email protected]>; Singh, Jasvinder <[email protected]>; Dumitrescu, Cristian <[email protected]>; Thomas Monjalon <[email protected]>; Yigit, Ferruh <[email protected]>; Andrew Rybchenko <[email protected]>; Ray Kinsella <[email protected]>; Neil Horman <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Li Zhang <[email protected]>; Haifei Luo <[email protected]>
Subject: [PATCH v9 1/2] ethdev: add pre-defined meter policy APIFrom: Li Zhang <[email protected]>
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_flowaction definition.
A list ofrte_flowactions 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_idis added into structrte_mtr_params. So that it can get the policy during the meters creation.Allow coloring the packet using a new
rte_flow_action_coloras could be done by the old policy API.Add two common policy template as macros in the head file.
The next API function were added:
-rte_mtr_meter_policy_add
-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_updateTo support this API the following app were changed:
app/test-flow-perf: clean meter policer app/testpmd: clean meter policerTo support this API the following drivers were changed:
net/softnic: support meter policy API
1. Cleans meterrte_mtr_policer_action.
2. Supports policy API to get color action as policer action did. The color action will be mapped intorte_table_action_policer.net/mlx5: clean meter creation management Cleans and breaks part of the current meter management in order to allow better design with policy API.
Quoted 7 lines
Signed-off-by Li Zhang <[email protected]>Signed-off-by Haifei Luo <[email protected]>Signed-off-by Jiawei Wang <[email protected]>Acked-by Matan Azrad <[email protected]>Acked-by Ray Kinsella <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Jasvinder Singh <[email protected]>
Re: [dpdk-dev] [PATCH v9 1/2] ethdev: add pre-defined meter policy API
Quoted 19 lines
-----Original Message-----
From: Asaf Penso <[email protected]>
Sent: Tuesday, April 20, 2021 1:55 PM
To: Dumitrescu, Cristian <[email protected]>; Jiawei(Jonny) Wang <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Shahaf Shuler <[email protected]>; Wisam Monther <[email protected]>; Li, Xiaoyun <[email protected]>; Singh, Jasvinder <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Yigit, Ferruh <[email protected]>; Andrew Rybchenko <[email protected]>; Ray Kinsella <[email protected]>; Neil Horman <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Roni Bar Yanai <[email protected]>; Li Zhang <[email protected]>; Haifei Luo <[email protected]>
Subject: RE: [PATCH v9 1/2] ethdev: add pre-defined meter policy API
Quoted 5 lines
Thank you, Cristian, appreciate this extra effort!
Regards,
Asaf Penso
My pleasure, Asaf, thank you! :)
Regards,
Cristian
PATCH v9 2/2 app/testpmd: support policy actions per color
In reply to Jiawei WangFrom: Haifei Luo <[email protected]>
Add the create/del policy CLIs to support actions per color. The CLIs are:
Create: add port meter policy (port_id) (policy_id) g_actions (actions) y_actions (actions) r_actions (actions)
Delete: del port meter policy (port_id) (policy_id)
Examples:
testpmd> add port meter policy 0 1 g_actions rss / end y_actions end r_actions drop / end
testpmd> del port meter policy 0 1
--- app/test-pmd/cmdline.c | 13 ++- app/test-pmd/cmdline_flow.c | 118 +++++++++++++++++++++++++++- app/test-pmd/cmdline_mtr.c | 85 ++++++++++++++++++-- app/test-pmd/cmdline_mtr.h | 3 + app/test-pmd/config.c | 32 ++++++++ app/test-pmd/testpmd.h | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 30 ++++++- 7 files changed, 269 insertions(+), 14 deletions(-)
app/test-pmd/cmdline.c +10 -3
@@ -705,9 +705,8 @@ static void cmd_help_long_parsed(void *parsed_result,"del port meter profile (port_id) (profile_id)\n" " meter profile delete\n\n" -"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" -"(g_action) (y_action) (r_action) (stats_mask) (shared)\n" -"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" +"create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n" +"(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" "(dscp_tbl_entry63)]\n" " meter create\n\n"
@@ -720,6 +719,13 @@ static void cmd_help_long_parsed(void *parsed_result,"del port meter (port_id) (mtr_id)\n" " meter delete\n\n" +"add port meter policy (port_id) (policy_id) g_actions (actions)\n" +"y_actions (actions) r_actions (actions)\n" +" meter policy add\n\n" + +"del port meter policy (port_id) (policy_id)\n" +" meter policy delete\n\n" +"set port meter profile (port_id) (mtr_id) (profile_id)\n" " meter update meter profile\n\n"
@@ -17072,6 +17078,7 @@ struct cmd_showport_macs_result { (cmdline_parse_inst_t *)&cmd_enable_port_meter, (cmdline_parse_inst_t *)&cmd_disable_port_meter, (cmdline_parse_inst_t *)&cmd_del_port_meter, + (cmdline_parse_inst_t *)&cmd_del_port_meter_policy, (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
app/test-pmd/cmdline_flow.c +117 -1
178 lines not on this page · raw message
app/test-pmd/cmdline_mtr.c +79 -6
140 lines not on this page · raw message
app/test-pmd/cmdline_mtr.h +3 -0
@@ -4,6 +4,7 @@#ifndef _CMDLINE_MTR_H_#define _CMDLINE_MTR_H_ +#include <rte_mtr.h> /* Traffic Metering and Policing */ extern cmdline_parse_inst_t cmd_show_port_meter_cap;
@@ -15,9 +16,11 @@extern cmdline_parse_inst_t cmd_enable_port_meter;extern cmdline_parse_inst_t cmd_disable_port_meter;extern cmdline_parse_inst_t cmd_del_port_meter; +extern cmdline_parse_inst_t cmd_del_port_meter_policy;extern cmdline_parse_inst_t cmd_set_port_meter_profile;extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table;extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;extern cmdline_parse_inst_t cmd_show_port_meter_stats; +void print_mtr_err_msg (struct rte_mtr_error *error);#endif /* _CMDLINE_MTR_H_ */
app/test-pmd/config.c +32 -0
@@ -38,6 +38,7 @@#include <rte_string_fns.h> #include <rte_cycles.h> #include <rte_flow.h> +#include <rte_mtr.h> #include <rte_errno.h> #ifdef RTE_NET_IXGBE #include <rte_pmd_ixgbe.h>
@@ -52,6 +53,7 @@#include <rte_hexdump.h> #include "testpmd.h" +#include "cmdline_mtr.h" #define ETHDEV_FWVERS_LEN 32
@@ -1464,6 +1466,36 @@ void port_flow_tunnel_create(portid_t port_id, const struct tunnel_ops *ops)return 0 ; } +/** Add port meter policy */ +int +port_meter_policy_add (portid_t port_id,uint32_t policy_id, +const struct rte_flow_action *actions) +{ +struct rte_mtr_error error; +const struct rte_flow_action *act = actions; +const struct rte_flow_action *start; +struct rte_mtr_meter_policy_params policy; +uint32_t i =0 , act_n; +int ret; + +for (i =0 ; i <RTE_COLORS ; i++) { +for (act_n =0 , start = act; + act->type !=RTE_FLOW_ACTION_TYPE_END ; act++) + act_n++; +if (act_n && act->type ==RTE_FLOW_ACTION_TYPE_END ) + policy.actions[i] = start; +else + policy.actions[i] =NULL ; + act++; + } + ret =rte_mtr_meter_policy_add (port_id, + policy_id, + &policy, &error); +if (ret) +print_mtr_err_msg (&error); +return ret; +} +/** Create shared action */ int port_shared_action_create(portid_t port_id, uint32_t id,
app/test-pmd/testpmd.h +2 -0
@@ -838,6 +838,8 @@ struct port_flow_tunnel *void port_flow_tunnel_destroy (portid_t port_id,uint32_t tunnel_id);void port_flow_tunnel_create (portid_t port_id,const struct tunnel_ops *ops);int port_flow_isolate (portid_t port_id,int set); +int port_meter_policy_add (portid_t port_id,uint32_t policy_id, +const struct rte_flow_action *actions);void rx_ring_desc_display (portid_t port_id,queueid_t rxq_id,uint16_t rxd_id);void tx_ring_desc_display (portid_t port_id,queueid_t txq_id,uint16_t txd_id);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +26 -4
@@ -2765,13 +2765,37 @@ Delete meter profile from the ethernet device:: testpmd> del port meter profile (port_id) (profile_id) +create port policy +~~~~~~~~~~~~~~~~~~ + +Create new policy object for the ethernet device:: + + testpmd> add port meter policy (port_id) (policy_id) g_actions \ + {action} y_actions {action} r_actions {action} + +where: + +* ``policy_id``: policy ID. +* ``action``: action lists for green/yellow/red colors. + +delete port policy +~~~~~~~~~~~~~~~~~~ + +Delete policy object for the ethernet device:: + + testpmd> del port meter policy (port_id) (policy_id) + +where: + +* ``policy_id``: policy ID. + create port meter ~~~~~~~~~~~~~~~~~ Create new meter object for the ethernet device:: testpmd> create port meter (port_id) (mtr_id) (profile_id) \ - (meter_enable) (g_action) (y_action) (r_action) (stats_mask) (shared) \ + (policy_id) (meter_enable) (stats_mask) (shared) \ (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\ (dscp_tbl_entry63)]
@@ -2779,11 +2803,9 @@ where: * ``mtr_id``: meter object ID. * ``profile_id``: ID for the meter profile. +* ``policy_id``: ID for the policy. * ``meter_enable``: When this parameter has a non-zero value, the meter object gets enabled at the time of creation, otherwise remains disabled. -* ``g_action``: Policer action for the packet with green color. -* ``y_action``: Policer action for the packet with yellow color. -* ``r_action``: Policer action for the packet with red color. * ``stats_mask``: Mask of statistics counter types to be enabled for the meter object. * ``shared``: When this parameter has a non-zero value, the meter object is
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v9 0/2] Support meter policy API
In reply to Jiawei WangQuoted 34 lines · Jiawei Wang
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_flowaction definition.
A list ofrte_flowactions 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_idis added into structrte_mtr_params. So that it can get the policy during the meters creation.Add two common policy template as macros in the header file,
RFC ("ethdev: add pre-defined meter policy API")
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/Depends-on: series=16351 ("Add ASO meter support in MLX5 PMD ")
https://patchwork.dpdk.org/project/dpdk/list/?series=16351V2: Delete default policy and change relation doc files.
V3: Fix coding style issues.
V4: Fix comments about Depends-on
V5: Fix comments aboutrte_mtr_meter_policy_add.
V6: Delete policy example.
V7: Fix comments and place two common policy template as macros.
V8: Fix rebase conflict issues and CI warning
V9: Rebase and Fix the comments for softnic driver.
Quoted 6 lines
Haifei Luo (1):
app/testpmd: support policy actions per colorLi Zhang (1):
ethdev: add pre-defined meter policy API
Hi Li, Haifei,
This patch conflicts with merged integrity check/conntrack features, also the dependent mlx5 ASO set send a new version.
Can you please send a new version rebasing on latest versions?
Re: [dpdk-dev] [PATCH v9 0/2] Support meter policy API
Hi,
Quoted 55 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, April 20, 2021 7:37 PM
To: Jiawei(Jonny) Wang <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Shahaf Shuler <[email protected]>
Cc: [email protected]; NBU-Contact-Thomas Monjalon <[email protected]>; Raslan Darawsheh <[email protected]>; Roni Bar Yanai <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v9 0/2] Support meter policy APIQuoted 14 lines · Jiawei Wang
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_flowaction definition.
A list ofrte_flowactions 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.Quoted 7 lines
meter_policy_idis added into structrte_mtr_params. So that it can get the policy during the meters creation.Add two common policy template as macros in the header file,
RFC ("ethdev: add pre-defined meter policy API")
https://patchwork.dpdk.org/project/dpdk/patch/20210318085815.804896-1-
Quoted 14 lines
Depends-on: series=16351 ("Add ASO meter support in MLX5 PMD ")
https://patchwork.dpdk.org/project/dpdk/list/?series=16351V2: Delete default policy and change relation doc files.
V3: Fix coding style issues.
V4: Fix comments about Depends-on
V5: Fix comments aboutrte_mtr_meter_policy_add.
V6: Delete policy example.
V7: Fix comments and place two common policy template as macros.
V8: Fix rebase conflict issues and CI warning
V9: Rebase and Fix the comments for softnic driver.Quoted 6 lines
Haifei Luo (1):
app/testpmd: support policy actions per colorLi Zhang (1):
ethdev: add pre-defined meter policy API
Quoted 8 lines
Hi Li, Haifei,
This patch conflicts with merged integrity check/conntrack features, also the dependent mlx5 ASO set send a new version.
Can you please send a new version rebasing on latest versions?
Thanks Ferruh point it, I had rebased and also update the new mlx5 ASO series link. The latest v10 already been sent.
Thanks.
v10 cover Support meter policy API
In reply to Jiawei WangCurrently, 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.
Add two common policy template as macros in the header file,
RFC ("ethdev: add pre-defined meter policy API")
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
Depends-on: series=16520 ("Add ASO meter support in MLX5 PMD ")
https://patchwork.dpdk.org/project/dpdk/list/?series=16520
v10:
* Rebase.
v9:
* Rebase.
* Fix the comments for softnic driver.
v8:
* Fix rebase conflict issues and CI warning.
v7:
* Fix comments and place two common policy template as macros.
v6:
* Delete policy example.
v5:
* Fix comments about rte_mtr_meter_policy_add.
v4:
* Fix comments about Depends-on.
v3:
* Fix coding style issues.
v2:
* Delete default policy and change relation doc files.
Haifei Luo (1):
app/testpmd: support policy actions per color
Li Zhang (1):
ethdev: add pre-defined meter policy API
app/test-flow-perf/main.c | 7 - app/test-pmd/cmdline.c | 14 +- app/test-pmd/cmdline_flow.c | 118 +++++- app/test-pmd/cmdline_mtr.c | 257 ++++-------- app/test-pmd/cmdline_mtr.h | 4 +- app/test-pmd/config.c | 32 ++ app/test-pmd/testpmd.h | 2 + doc/guides/prog_guide/rte_flow.rst | 21 + .../prog_guide/traffic_metering_and_policing.rst | 16 +- doc/guides/rel_notes/release_21_05.rst | 21 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 48 ++- 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 | 8 +- drivers/net/mlx5/mlx5_flow_dv.c | 461 +-------------------- drivers/net/mlx5/mlx5_flow_meter.c | 369 +---------------- drivers/net/softnic/rte_eth_softnic_flow.c | 19 +- drivers/net/softnic/rte_eth_softnic_internals.h | 18 +- drivers/net/softnic/rte_eth_softnic_meter.c | 297 ++++++++++--- lib/librte_ethdev/rte_flow.h | 22 + lib/librte_ethdev/rte_mtr.c | 55 ++- lib/librte_ethdev/rte_mtr.h | 223 +++++++--- lib/librte_ethdev/rte_mtr_driver.h | 44 +- lib/librte_ethdev/version.map | 5 +- 25 files changed, 879 insertions(+), 1270 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v10 1/2 ethdev: add pre-defined meter policy API
From: Li Zhang <[email protected]>
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.
Allow coloring the packet using a new rte_flow_action_color as could be done by the old policy API.
Add two common policy template as macros in the head file.
The next API function were added:
- rte_mtr_meter_policy_add
- 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. Supports policy API to get color action as policer action did. The color action will be mapped into rte_table_action_policer.
net/mlx5: clean meter creation management Cleans and breaks part of the current meter management in order to allow better design with policy API.
--- 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/prog_guide/rte_flow.rst | 21 + .../prog_guide/traffic_metering_and_policing.rst | 16 +- doc/guides/rel_notes/release_21_05.rst | 21 + 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 | 8 +- drivers/net/mlx5/mlx5_flow_dv.c | 461 +-------------------- drivers/net/mlx5/mlx5_flow_meter.c | 369 +---------------- drivers/net/softnic/rte_eth_softnic_flow.c | 19 +- drivers/net/softnic/rte_eth_softnic_internals.h | 18 +- drivers/net/softnic/rte_eth_softnic_meter.c | 297 ++++++++++--- lib/librte_ethdev/rte_flow.h | 22 + lib/librte_ethdev/rte_mtr.c | 55 ++- lib/librte_ethdev/rte_mtr.h | 223 +++++++--- lib/librte_ethdev/rte_mtr_driver.h | 44 +- lib/librte_ethdev/version.map | 5 +- 22 files changed, 610 insertions(+), 1256 deletions(-)
app/test-flow-perf/main.c +0 -7
@@ -928,13 +928,6 @@ struct multi_cores_pool {/*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, ¶ms,1 , &error);if (ret !=0 ) { printf("Port %u create meter idx(%d) error(%d) message: %s\n",
app/test-pmd/cmdline.c +0 -1
@@ -17510,7 +17510,6 @@ struct cmd_showport_macs_result { (cmdline_parse_inst_t *)&cmd_del_port_meter, (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, - (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, (cmdline_parse_inst_t *)&cmd_mcast_addr,
app/test-pmd/cmdline_mtr.c +0 -172
196 lines not on this page · raw message
app/test-pmd/cmdline_mtr.h +0 -1
@@ -17,7 +17,6 @@extern cmdline_parse_inst_t cmd_del_port_meter;extern cmdline_parse_inst_t cmd_set_port_meter_profile;extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table; -extern cmdline_parse_inst_t cmd_set_port_meter_policer_action;extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;extern cmdline_parse_inst_t cmd_show_port_meter_stats;
doc/guides/prog_guide/rte_flow.rst +21 -0
@@ -2982,6 +2982,27 @@ The current conntrack context information could be queried via the | ``reserved`` | reserved bits | +----------------+-------------------------------------------------+ +Action: ``METER_COLOR`` +^^^^^^^^^^^^^^^^^^^^^^^ + +Color the packet to reflect the meter color result. + +The meter action must be configured before meter color action. +Meter color action is set to a color to reflect the meter color result. +Set the meter color in the mbuf to the selected color. +The meter color action output color is the output color of the packet, +which is set in the packet meta-data (i.e. struct ``rte_mbuf::sched::color``) + +.. _table_rte_flow_action_meter_color: + +.. table:: METER_COLOR + + +-----------------+--------------+ + | Field | Value | + +=================+==============+ + | ``meter_color`` | Packet color | + +-----------------+--------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/prog_guide/traffic_metering_and_policing.rst +4 -12
@@ -56,18 +56,10 @@ The processing done for each input packet hitting an MTR object is: color blind mode, which is equivalent to considering all input packets initially colored as green. -* Policing: There is a separate policer action configured for each meter - output color, which can: - - * Drop the packet. - - * Keep the same packet color: the policer output color matches the meter - output color (essentially a no-op action). - - * Recolor the packet: the policer output color is set to a different color - than the meter output color. The policer output color is the output color - of the packet, which is set in the packet meta-data (i.e. struct - ``rte_mbuf::sched::color``). +* There is a meter policy API to manage pre-defined policies for meter. + Any rte_flow action list can be configured per color for each policy. + A meter object configured with a policy executes the actions per packet + according to the packet color. * Statistics: The set of counters maintained for each MTR object is configurable and subject to the implementation support. This set includes
doc/guides/rel_notes/release_21_05.rst +21 -0
@@ -244,6 +244,27 @@ New Features * Added support for crypto adapter forward mode in octeontx2 event and crypto device driver. + * deleted the port meter policer action command . + ``set port meter policer action (port_id) (mtr_id) (action_mask) ...`` + * Added command to create meter policy. + ``add port meter policy (port_id) (policy_id) g_actions {action} end y_actions {action} end r_actions {action} end`` + * Added command to delete meter policy. + ``del port meter policy (port_id) (policy_id)`` + +* **Updated meter API.** + + * ethdev: Deleted meter policer API to support policy API. + ``rte_mtr_policer_actions_update()`` + * ethdev: Added meter API to support pre-defined policy, rte_flow action list per color. + ``rte_mtr_meter_policy_add()``, ``rte_mtr_meter_policy_delete()`` and + ``rte_mtr_create_with_policy()`` + * ethdev: Removed rte_mtr_policer_action from rte_mtr_params structures. + * ethdev: Added rte_mtr_meter_policy_params structures to support policy API. + * ethdev: Added meter_policy_id into rte_mtr_params structures. + * ethdev: Removed policer_action_recolor_supported and policer_action_drop_supported from rte_mtr_capabilities structures. + * ethdev: Added meter_policy_n_max into rte_mtr_capabilities structures. + * ethdev: Added RTE_FLOW_ACTION_TYPE_METER_COLOR in enum rte_flow_action_type. + * ethdev: Added RTE_MTR_ERROR_TYPE_METER_POLICY_ID and RTE_MTR_ERROR_TYPE_METER_POLICY_ID into rte_mtr_error_type. Removed Items -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -18
@@ -2838,24 +2838,6 @@ Set meter dscp table for the ethernet device:: testpmd> set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0) \ (dscp_tbl_entry1)...(dscp_tbl_entry63)] -set port meter policer action -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Set meter policer action for the ethernet device:: - - testpmd> set port meter policer action (port_id) (mtr_id) (action_mask) \ - (action0) [(action1) (action1)] - -where: - -* ``action_mask``: Bit mask indicating which policer actions need to be - updated. One or more policer actions can be updated in a single function - invocation. To update the policer action associated with color C, bit - (1 << C) needs to be set in *action_mask* and element at position C - in the *actions* array needs to be valid. -* ``actionx``: Policer action for the color x, - RTE_MTR_GREEN <= x < RTE_MTR_COLORS - set port meter stats mask ~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/mlx5/mlx5.h +2 -22
@@ -593,14 +593,6 @@ struct mlx5_dev_shared_port {/* Modify this value if enum rte_mtr_color changes. */ #define RTE_MTR_DROPPED RTE_COLORS -/* Meter policer statistics */ -struct mlx5_flow_policer_stats { -uint32_t pass_cnt; -/**< Color counter for pass. */ -uint32_t drop_cnt; -/**< Color counter for drop. */ -}; -/* Meter table structure. */ struct mlx5_meter_domain_info {struct mlx5_flow_tbl_resource *tbl;
@@ -639,24 +631,12 @@ struct mlx5_meter_domains_infos {/* Meter parameter structure. */ struct mlx5_flow_meter_info { -uint32_t meter_id; -/**< Meter id. */ struct mlx5_flow_meter_profile *profile;/**< Meter profile parameters. */ rte_spinlock_t sl;/**< Meter action spinlock. */ -/** Policer actions (per meter output color). */ -enum rte_mtr_policer_action action[RTE_COLORS ];/** Set of stats counters to be enabled. * @see enum rte_mtr_stats_type */ -uint32_t green_bytes:1 ; -/** Set green bytes stats to be enabled. */ -uint32_t green_pkts:1 ; -/** Set green packets stats to be enabled. */ -uint32_t red_bytes:1 ; -/** Set red bytes stats to be enabled. */ -uint32_t red_pkts:1 ; -/** Set red packets stats to be enabled. */ uint32_t bytes_dropped:1 ;/** Set bytes dropped stats to be enabled. */ uint32_t pkts_dropped:1 ;
@@ -691,8 +671,8 @@ struct mlx5_flow_meter_info { uint32_t transfer:1;struct mlx5_meter_domains_infos *mfts;/**< Flow table created for this meter. */ -struct mlx5_flow_policer_stats policer_stats; -/**< Meter policer statistics. */ +uint32_t drop_cnt; +/**< Color counter for drop. */ uint32_t ref_cnt;/**< Use count. */ struct mlx5_indexed_pool *flow_ipool;
drivers/net/mlx5/mlx5_flow.c +0 -46
52 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +2 -16
@@ -838,6 +838,8 @@ struct mlx5_legacy_flow_meter {/* Must be the first in struct. */ TAILQ_ENTRY (mlx5_legacy_flow_meter) next;/**< Pointer to the next flow meter structure. */ +uint32_t meter_id; +/**< Meter id. */ uint32_t idx;/* Index to meter object. */ };
@@ -1096,14 +1098,6 @@ typedef int (*mlx5_flow_query_t)(struct rte_eth_dev *dev, (struct rte_eth_dev *dev);typedef int (*mlx5_flow_destroy_mtr_tbls_t )(struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbls); -typedef int (*mlx5_flow_create_policer_rules_t ) - (struct rte_eth_dev *dev, -struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr); -typedef int (*mlx5_flow_destroy_policer_rules_t ) - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr);typedef uint32_t (*mlx5_flow_mtr_alloc_t ) (struct rte_eth_dev *dev); typedef void (*mlx5_flow_mtr_free_t)(struct rte_eth_dev *dev,
@@ -1160,8 +1154,6 @@ struct mlx5_flow_driver_ops {mlx5_flow_query_t query;mlx5_flow_create_mtr_tbls_t create_mtr_tbls;mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls; -mlx5_flow_create_policer_rules_t prepare_policer_rules; -mlx5_flow_destroy_policer_rules_t destroy_policer_rules;mlx5_flow_mtr_alloc_t create_meter;mlx5_flow_mtr_free_t free_meter;mlx5_flow_counter_alloc_t counter_alloc;
@@ -1391,12 +1383,6 @@ struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls (struct rte_eth_dev *dev);int mlx5_flow_destroy_mtr_tbls (struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbl); -int mlx5_flow_prepare_policer_rules (struct rte_eth_dev *dev, -struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr); -int mlx5_flow_destroy_policer_rules (struct rte_eth_dev *dev, -struct mlx5_flow_meter_info *fm, -const struct rte_flow_attr *attr);int mlx5_flow_meter_flush (struct rte_eth_dev *dev,struct rte_mtr_error *error);int mlx5_flow_dv_discover_counter_offset_support (struct rte_eth_dev *dev);
drivers/net/mlx5/mlx5_flow_aso.c +4 -4
@@ -808,8 +808,8 @@/* Waiting for wqe resource. */ rte_delay_us_sleep (MLX5_ASO_WQE_CQE_RESPONSE_DELAY ); }while (--poll_wqe_times); -DRV_LOG (ERR ,"Fail to send WQE for ASO meter %d" , - mtr->fm.meter_id); +DRV_LOG (ERR ,"Fail to send WQE for ASO meter offset %d" , + mtr->offset);return -1 ; }
@@ -844,7 +844,7 @@/* Waiting for CQE ready. */ rte_delay_us_sleep (MLX5_ASO_WQE_CQE_RESPONSE_DELAY ); }while (--poll_cqe_times); -DRV_LOG (ERR ,"Fail to poll CQE ready for ASO meter %d" , - mtr->fm.meter_id); +DRV_LOG (ERR ,"Fail to poll CQE ready for ASO meter offset %d" , + mtr->offset);return -1 ; }
drivers/net/mlx5/mlx5_flow_dv.c +2 -459
501 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +11 -358
491 lines not on this page · raw message
drivers/net/softnic/rte_eth_softnic_flow.c +15 -4
@@ -1166,6 +1166,7 @@ struct flow_attr_map * {struct softnic_table_action_profile *profile;struct softnic_table_action_profile_params *params; +struct softnic_mtr_meter_policy *policy;int n_jump_queue_rss_drop =0 ;int n_count =0 ;int n_mark =0 ;
@@ -1621,15 +1622,25 @@ struct flow_attr_map *return -1 ; } } - +/* Meter policy must exist */ + policy =softnic_mtr_meter_policy_find (softnic, + m->params.meter_policy_id); +if (policy ==NULL ) { +rte_flow_error_set (error, +EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL , +"METER: fail to find meter policy" ); +return -1 ; + }/* RTE_TABLE_ACTION_METER */ rule_action->mtr.mtr[0 ].meter_profile_id = meter_profile_id; rule_action->mtr.mtr[0 ].policer[RTE_COLOR_GREEN ] = -softnic_table_action_policer (m->params.action[RTE_COLOR_GREEN ]); + policy->policer[RTE_COLOR_GREEN ]; rule_action->mtr.mtr[0 ].policer[RTE_COLOR_YELLOW ] = -softnic_table_action_policer (m->params.action[RTE_COLOR_YELLOW ]); + policy->policer[RTE_COLOR_YELLOW ]; rule_action->mtr.mtr[0 ].policer[RTE_COLOR_RED ] = -softnic_table_action_policer (m->params.action[RTE_COLOR_RED ]); + policy->policer[RTE_COLOR_RED ]; rule_action->mtr.tc_mask =1 ; rule_action->action_mask |=1 <<RTE_TABLE_ACTION_MTR ;break ;
drivers/net/softnic/rte_eth_softnic_internals.h +15 -3
@@ -83,6 +83,16 @@ struct softnic_mtr_meter_profile {TAILQ_HEAD (softnic_mtr_meter_profile_list, softnic_mtr_meter_profile); +/* MTR meter policy */ +struct softnic_mtr_meter_policy { +TAILQ_ENTRY (softnic_mtr_meter_policy) node; +uint32_t meter_policy_id; +enum rte_table_action_policer policer[RTE_COLORS ]; +uint32_t n_users; +}; + +TAILQ_HEAD (softnic_mtr_meter_policy_list, softnic_mtr_meter_policy); +/* MTR meter object */ struct softnic_mtr {TAILQ_ENTRY (softnic_mtr) node;
@@ -95,6 +105,7 @@ struct softnic_mtr {struct mtr_internals {struct softnic_mtr_meter_profile_list meter_profiles; +struct softnic_mtr_meter_policy_list meter_policies;struct softnic_mtr_list mtrs; };
@@ -678,6 +689,10 @@ struct softnic_mtr_meter_profile * softnic_mtr_meter_profile_find(struct pmd_internals *p, uint32_t meter_profile_id); +struct softnic_mtr_meter_policy * +softnic_mtr_meter_policy_find (struct pmd_internals *p, +uint32_t meter_policy_id); +extern const struct rte_mtr_ops pmd_mtr_ops;/**
@@ -841,9 +856,6 @@ struct softnic_table_action_profile *const char *name, struct softnic_table_action_profile_params *params); -enum rte_table_action_policer -softnic_table_action_policer (enum rte_mtr_policer_action action); -/** * Pipeline */
drivers/net/softnic/rte_eth_softnic_meter.c +235 -62
429 lines not on this page · raw message
lib/librte_ethdev/rte_flow.h +22 -0
@@ -33,6 +33,7 @@#include <rte_bitops.h> #include <rte_mbuf.h> #include <rte_mbuf_dyn.h> +#include <rte_meter.h> #ifdef __cplusplusextern "C" {
@@ -2392,6 +2393,14 @@ enum rte_flow_action_type {* @see struct rte_flow_action_conntrack. */ RTE_FLOW_ACTION_TYPE_CONNTRACK , + +/** +* Color the packet to reflect the meter color result. +* Set the meter color in the mbuf to the selected color. +* +* See struct rte_flow_action_meter_color. +*/ + RTE_FLOW_ACTION_TYPE_METER_COLOR, };/**
@@ -3139,6 +3148,19 @@ struct rte_flow_modify_conntrack { };/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_METER_COLOR +* +* The meter color should be set in the packet meta-data +* (i.e. struct rte_mbuf::sched::color). +*/ +struct rte_flow_action_meter_color { +enum rte_color color;/**< Packet color. */ +}; + +/** * Field IDs for MODIFY_FIELD action. */ enum rte_flow_field_id {
lib/librte_ethdev/rte_mtr.c +44 -11
79 lines not on this page · raw message
lib/librte_ethdev/rte_mtr.h +174 -49
303 lines not on this page · raw message
lib/librte_ethdev/rte_mtr_driver.h +34 -10
72 lines not on this page · raw message
lib/librte_ethdev/version.map +4 -1
@@ -138,7 +138,6 @@ EXPERIMENTAL { rte_mtr_meter_profile_add; rte_mtr_meter_profile_delete; rte_mtr_meter_profile_update; - rte_mtr_policer_actions_update; rte_mtr_stats_read; rte_mtr_stats_update;
@@ -246,6 +245,10 @@ EXPERIMENTAL { rte_flow_action_handle_destroy; rte_flow_action_handle_update; rte_flow_action_handle_query; + rte_mtr_meter_policy_add; + rte_mtr_meter_policy_delete; + rte_mtr_meter_policy_update; + rte_mtr_meter_policy_validate; }; INTERNAL {
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v10 1/2] ethdev: add pre-defined meter policy API
Quoted 50 lines · Jiawei Wang
From: Li Zhang <[email protected]>
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_flowaction definition.
A list ofrte_flowactions 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_idis added into structrte_mtr_params. So that it can get the policy during the meters creation.Allow coloring the packet using a new
rte_flow_action_coloras could be done by the old policy API.Add two common policy template as macros in the head file.
The next API function were added:
-rte_mtr_meter_policy_add
-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_updateTo support this API the following app were changed:
app/test-flow-perf: clean meter policer app/testpmd: clean meter policerTo support this API the following drivers were changed:
net/softnic: support meter policy API
1. Cleans meterrte_mtr_policer_action.
2. Supports policy API to get color action as policer action did. The color action will be mapped intorte_table_action_policer.net/mlx5: clean meter creation management Cleans and breaks part of the current meter management in order to allow better design with policy API.
Quoted 8 lines
Signed-off-by Li Zhang <[email protected]>Signed-off-by Haifei Luo <[email protected]>Signed-off-by Jiawei Wang <[email protected]>Acked-by Matan Azrad <[email protected]>Acked-by Ray Kinsella <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Jasvinder Singh <[email protected]>
Quoted 3 lines
--
1.8.3.1
Re: [dpdk-dev] [PATCH v10 1/2] ethdev: add pre-defined meter policy API
In reply to Jiawei Wang20/04/2021 16:04, Jiawei Wang:
Quoted 17 lines
doc/guides/rel_notes/release_21_05.rst +11
-0@@ -244,6 +244,27 @@ New Features * Added support for crypto adapter forward mode in octeontx2 event and crypto device driver. + * deleted the port meter policer action command . + ``set port meter policer action (port_id) (mtr_id) (action_mask) ...`` + * Added command to create meter policy. + ``add port meter policy (port_id) (policy_id) g_actions {action} end y_actions {action} end r_actions {action} end`` + * Added command to delete meter policy. + ``del port meter policy (port_id) (policy_id)`` + +* **Updated meter API.** + + * ethdev: Deleted meter policer API to support policy API. + ``rte_mtr_policer_actions_update()``
doc/guides/rel_notes/release_21_05.rst New Features · line 267
Quoted 10 lines
doc/guides/rel_notes/release_21_05.rst +10
-0+ * ethdev: Added meter API to support pre-defined policy, rte_flow action list per color. + ``rte_mtr_meter_policy_add()``, ``rte_mtr_meter_policy_delete()`` and + ``rte_mtr_create_with_policy()`` + * ethdev: Removed rte_mtr_policer_action from rte_mtr_params structures. + * ethdev: Added rte_mtr_meter_policy_params structures to support policy API. + * ethdev: Added meter_policy_id into rte_mtr_params structures. + * ethdev: Removed policer_action_recolor_supported and policer_action_drop_supported from rte_mtr_capabilities structures. + * ethdev: Added meter_policy_n_max into rte_mtr_capabilities structures. + * ethdev: Added RTE_FLOW_ACTION_TYPE_METER_COLOR in enum rte_flow_action_type. + * ethdev: Added RTE_MTR_ERROR_TYPE_METER_POLICY_ID and RTE_MTR_ERROR_TYPE_METER_POLICY_ID into rte_mtr_error_type.
What is this garbage?
Wrong place, wrong format, wrong everything.
I would like to see a bit more attention to details, especially in a rush to close the -rc1.
Re: [dpdk-dev] [PATCH v10 1/2] ethdev: add pre-defined meter policy API
Hi Thomas,
Thanks for your comments.
Since this patch already accepted, I will fix it in RC2.
Regards,
Li Zhang
Quoted 63 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, April 22, 2021 3:44 AM
To: Jiawei(Jonny) Wang <[email protected]>
Cc: Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Shahaf Shuler <[email protected]>; [email protected]; Wisam Monther <[email protected]>; Xiaoyun Li <[email protected]>; Jasvinder Singh <[email protected]>; Cristian Dumitrescu <[email protected]>; Andrew Rybchenko <[email protected]>; Ray Kinsella <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>; Roni Bar Yanai <[email protected]>; Asaf Penso <[email protected]>; Li Zhang <[email protected]>; Haifei Luo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v10 1/2] ethdev: add pre-defined meter policy APIExternal email: Use caution opening links or attachments
20/04/2021 16:04, Jiawei Wang:
doc/guides/rel_notes/release_21_05.rst New Features · line 244
Quoted 4 lines
doc/guides/rel_notes/release_21_05.rst +0
-0@@ -244,6 +244,27 @@ New Features * Added support for crypto adapter forward mode in octeontx2 event andcrypto
Quoted 6 lines
doc/guides/rel_notes/release_21_05.rst +4
-0device driver. + * deleted the port meter policer action command . + ``set port meter policer action (port_id) (mtr_id) (action_mask) + ...`` + * Added command to create meter policy.doc/guides/rel_notes/release_21_05.rst New Features
Quoted 10 lines
doc/guides/rel_notes/release_21_05.rst +10
-0+ ``add port meter policy (port_id) (policy_id) g_actions {action} + end y_actions {action} end r_actions {action} end`` + * Added command to delete meter policy. + ``del port meter policy (port_id) (policy_id)`` + +* **Updated meter API.** + + * ethdev: Deleted meter policer API to support policy API. + ``rte_mtr_policer_actions_update()`` + * ethdev: Added meter API to support pre-defined policy, rte_flow actionlist per color.
doc/guides/rel_notes/release_21_05.rst New Features
Quoted 3 lines
doc/guides/rel_notes/release_21_05.rst +3
-0+ ``rte_mtr_meter_policy_add()``, ``rte_mtr_meter_policy_delete()`` and + ``rte_mtr_create_with_policy()`` + * ethdev: Removed rte_mtr_policer_action from rte_mtr_paramsstructures.
doc/guides/rel_notes/release_21_05.rst New Features · line 264
Quoted 1 line
doc/guides/rel_notes/release_21_05.rst +1
-0+ * ethdev: Added rte_mtr_meter_policy_params structures to supportpolicy API.
doc/guides/rel_notes/release_21_05.rst New Features · line 266
Quoted 2 lines
doc/guides/rel_notes/release_21_05.rst +2
-0+ * ethdev: Added meter_policy_id into rte_mtr_params structures. + * ethdev: Removed policer_action_recolor_supported and
policer_action_drop_supportedfromrte_mtr_capabilitiesstructures.doc/guides/rel_notes/release_21_05.rst New Features · line 268
Quoted 2 lines
doc/guides/rel_notes/release_21_05.rst +2
-0+ * ethdev: Added meter_policy_n_max into rte_mtr_capabilities structures. + * ethdev: Added RTE_FLOW_ACTION_TYPE_METER_COLOR in enum
rte_flow_action_type.doc/guides/rel_notes/release_21_05.rst New Features · line 269
Quoted 1 line
doc/guides/rel_notes/release_21_05.rst +1
-0+ * ethdev: Added RTE_MTR_ERROR_TYPE_METER_POLICY_ID and
RTE_MTR_ERROR_TYPE_METER_POLICY_IDintorte_mtr_error_type.What is this garbage?
Wrong place, wrong format, wrong everything.I would like to see a bit more attention to details, especially in a rush to close the -rc1.
PATCH v10 2/2 app/testpmd: support policy actions per color
In reply to Jiawei WangFrom: Haifei Luo <[email protected]>
Add the create/del policy CLIs to support actions per color. The CLIs are:
Create: add port meter policy (port_id) (policy_id) g_actions (actions) y_actions (actions) r_actions (actions)
Delete: del port meter policy (port_id) (policy_id)
Examples:
testpmd> add port meter policy 0 1 g_actions rss / end y_actions end r_actions drop / end
testpmd> del port meter policy 0 1
--- app/test-pmd/cmdline.c | 13 ++- app/test-pmd/cmdline_flow.c | 118 +++++++++++++++++++++++++++- app/test-pmd/cmdline_mtr.c | 85 ++++++++++++++++++-- app/test-pmd/cmdline_mtr.h | 3 + app/test-pmd/config.c | 32 ++++++++ app/test-pmd/testpmd.h | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 30 ++++++- 7 files changed, 269 insertions(+), 14 deletions(-)
app/test-pmd/cmdline.c +10 -3
@@ -708,9 +708,8 @@ static void cmd_help_long_parsed(void *parsed_result,"del port meter profile (port_id) (profile_id)\n" " meter profile delete\n\n" -"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" -"(g_action) (y_action) (r_action) (stats_mask) (shared)\n" -"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" +"create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n" +"(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" "(dscp_tbl_entry63)]\n" " meter create\n\n"
@@ -723,6 +722,13 @@ static void cmd_help_long_parsed(void *parsed_result,"del port meter (port_id) (mtr_id)\n" " meter delete\n\n" +"add port meter policy (port_id) (policy_id) g_actions (actions)\n" +"y_actions (actions) r_actions (actions)\n" +" meter policy add\n\n" + +"del port meter policy (port_id) (policy_id)\n" +" meter policy delete\n\n" +"set port meter profile (port_id) (mtr_id) (profile_id)\n" " meter update meter profile\n\n"
@@ -17508,6 +17514,7 @@ struct cmd_showport_macs_result { (cmdline_parse_inst_t *)&cmd_enable_port_meter, (cmdline_parse_inst_t *)&cmd_disable_port_meter, (cmdline_parse_inst_t *)&cmd_del_port_meter, + (cmdline_parse_inst_t *)&cmd_del_port_meter_policy, (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
app/test-pmd/cmdline_flow.c +117 -1
178 lines not on this page · raw message
app/test-pmd/cmdline_mtr.c +79 -6
140 lines not on this page · raw message
app/test-pmd/cmdline_mtr.h +3 -0
@@ -4,6 +4,7 @@#ifndef _CMDLINE_MTR_H_#define _CMDLINE_MTR_H_ +#include <rte_mtr.h> /* Traffic Metering and Policing */ extern cmdline_parse_inst_t cmd_show_port_meter_cap;
@@ -15,9 +16,11 @@extern cmdline_parse_inst_t cmd_enable_port_meter;extern cmdline_parse_inst_t cmd_disable_port_meter;extern cmdline_parse_inst_t cmd_del_port_meter; +extern cmdline_parse_inst_t cmd_del_port_meter_policy;extern cmdline_parse_inst_t cmd_set_port_meter_profile;extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table;extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;extern cmdline_parse_inst_t cmd_show_port_meter_stats; +void print_mtr_err_msg (struct rte_mtr_error *error);#endif /* _CMDLINE_MTR_H_ */
app/test-pmd/config.c +32 -0
@@ -38,6 +38,7 @@#include <rte_string_fns.h> #include <rte_cycles.h> #include <rte_flow.h> +#include <rte_mtr.h> #include <rte_errno.h> #ifdef RTE_NET_IXGBE #include <rte_pmd_ixgbe.h>
@@ -52,6 +53,7 @@#include <rte_hexdump.h> #include "testpmd.h" +#include "cmdline_mtr.h" #define ETHDEV_FWVERS_LEN 32
@@ -1798,6 +1800,36 @@ struct rte_flow_action_handle * } } +/** Add port meter policy */ +int +port_meter_policy_add (portid_t port_id,uint32_t policy_id, +const struct rte_flow_action *actions) +{ +struct rte_mtr_error error; +const struct rte_flow_action *act = actions; +const struct rte_flow_action *start; +struct rte_mtr_meter_policy_params policy; +uint32_t i =0 , act_n; +int ret; + +for (i =0 ; i <RTE_COLORS ; i++) { +for (act_n =0 , start = act; + act->type !=RTE_FLOW_ACTION_TYPE_END ; act++) + act_n++; +if (act_n && act->type ==RTE_FLOW_ACTION_TYPE_END ) + policy.actions[i] = start; +else + policy.actions[i] =NULL ; + act++; + } + ret =rte_mtr_meter_policy_add (port_id, + policy_id, + &policy, &error); +if (ret) +print_mtr_err_msg (&error); +return ret; +} +/** Validate flow rule. */ int port_flow_validate(portid_t port_id,
app/test-pmd/testpmd.h +2 -0
@@ -840,6 +840,8 @@ struct port_flow_tunnel *void port_flow_tunnel_destroy (portid_t port_id,uint32_t tunnel_id);void port_flow_tunnel_create (portid_t port_id,const struct tunnel_ops *ops);int port_flow_isolate (portid_t port_id,int set); +int port_meter_policy_add (portid_t port_id,uint32_t policy_id, +const struct rte_flow_action *actions);void rx_ring_desc_display (portid_t port_id,queueid_t rxq_id,uint16_t rxd_id);void tx_ring_desc_display (portid_t port_id,queueid_t txq_id,uint16_t txd_id);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +26 -4
@@ -2772,13 +2772,37 @@ Delete meter profile from the ethernet device:: testpmd> del port meter profile (port_id) (profile_id) +create port policy +~~~~~~~~~~~~~~~~~~ + +Create new policy object for the ethernet device:: + + testpmd> add port meter policy (port_id) (policy_id) g_actions \ + {action} y_actions {action} r_actions {action} + +where: + +* ``policy_id``: policy ID. +* ``action``: action lists for green/yellow/red colors. + +delete port policy +~~~~~~~~~~~~~~~~~~ + +Delete policy object for the ethernet device:: + + testpmd> del port meter policy (port_id) (policy_id) + +where: + +* ``policy_id``: policy ID. + create port meter ~~~~~~~~~~~~~~~~~ Create new meter object for the ethernet device:: testpmd> create port meter (port_id) (mtr_id) (profile_id) \ - (meter_enable) (g_action) (y_action) (r_action) (stats_mask) (shared) \ + (policy_id) (meter_enable) (stats_mask) (shared) \ (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\ (dscp_tbl_entry63)]
@@ -2786,11 +2810,9 @@ where: * ``mtr_id``: meter object ID. * ``profile_id``: ID for the meter profile. +* ``policy_id``: ID for the policy. * ``meter_enable``: When this parameter has a non-zero value, the meter object gets enabled at the time of creation, otherwise remains disabled. -* ``g_action``: Policer action for the packet with green color. -* ``y_action``: Policer action for the packet with yellow color. -* ``r_action``: Policer action for the packet with red color. * ``stats_mask``: Mask of statistics counter types to be enabled for the meter object. * ``shared``: When this parameter has a non-zero value, the meter object is
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v10 2/2] app/testpmd: support policy actions per color
Quoted 9 lines · Jiawei Wang
From: Haifei Luo <[email protected]>
Add the create/del policy CLIs to support actions per color. The CLIs are:
Create: add port meter policy (port_id) (policy_id)g_actions(actions)y_actions(actions)r_actions(actions)
Delete: del port meter policy (port_id) (policy_id)
Quoted 7 lines
Examples:
testpmd> add port meter policy 0 1g_actionsrss / endy_actionsendr_actionsdrop / end
testpmd> del port meter policy 0 1Signed-off-by Haifei Luo <[email protected]>Acked-by Matan Azrad <[email protected]>
Re: [dpdk-dev] [PATCH v10 0/2] Support meter policy API
In reply to Jiawei WangQuoted 50 lines · Jiawei Wang
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_flowaction definition.
A list ofrte_flowactions 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_idis added into structrte_mtr_params. So that it can get the policy during the meters creation.Add two common policy template as macros in the header file,
RFC ("ethdev: add pre-defined meter policy API")
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/Depends-on: series=16520 ("Add ASO meter support in MLX5 PMD ")
https://patchwork.dpdk.org/project/dpdk/list/?series=16520v10:
* Rebase.v9:
* Rebase.
* Fix the comments for softnic driver.v8:
* Fix rebase conflict issues and CI warning.v7:
* Fix comments and place two common policy template as macros.v6:
* Delete policy example.v5:
* Fix comments aboutrte_mtr_meter_policy_add.v4:
* Fix comments about Depends-on.v3:
* Fix coding style issues.
Quoted 9 lines
v2:
* Delete default policy and change relation doc files.Haifei Luo (1):
app/testpmd: support policy actions per colorLi Zhang (1):
ethdev: add pre-defined meter policy API
Series applied to dpdk-next-net/main, thanks.
lib/librte_ethdev/rte_flow.h enum rte_flow_action_type { · line 2246
Quoted 7 lines · On Thu, 18 Mar 2021 10:58:14 +0200 Li Zhang <[email protected]> wrote:
lib/librte_ethdev/rte_flow.h +7
-0+ +/** +* Color the packet to reflect the meter color result. +* +* See struct rte_flow_action_color. +*/ + RTE_FLOW_ACTION_TYPE_COlOR,
Why the odd use of lower case here? Shouldn't it be RTE_FLOW_ACTION_TYPE_COLOR
Hi Stephen
Thanks your comments.
We already change it in the following series and please take a look:
https://patchwork.dpdk.org/project/dpdk/list/?series=16524
+ /**
+ * Color the packet to reflect the meter color result.
+ * Set the meter color in the mbuf to the selected color.
+ *
+ * See struct rte_flow_action_meter_color.
+ */
+ RTE_FLOW_ACTION_TYPE_METER_COLOR,
Regards,
Li Zhang
Quoted 31 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, April 21, 2021 1:56 AM
To: Li Zhang <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>; [email protected]; [email protected]; NBU-Contact-Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>; Cristian Dumitrescu <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>; Roni Bar Yanai <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 1/2] [RFC]: ethdev: add pre-defined meter policy APIExternal email: Use caution opening links or attachments
lib/librte_ethdev/rte_flow.h enum rte_flow_action_type { · line 2246
Quoted 7 lines · On Thu, 18 Mar 2021 10:58:14 +0200 Li Zhang <[email protected]> wrote:
lib/librte_ethdev/rte_flow.h +7
-0+ +/** +* Color the packet to reflect the meter color result. +* +* See struct rte_flow_action_color. +*/ + RTE_FLOW_ACTION_TYPE_COlOR,Why the odd use of lower case here? Shouldn't it be
RTE_FLOW_ACTION_TYPE_COLOR