Fix meter hierarchy issue for represented port
cover Fix meter hierarchy issue for represented port
When the represented port item was introduced, there's an issue that if a flow matching represented port item uses a meter hierarchy action, it will fail due to the represented port item not supported correctly in meter hierarchy creation.
This patch set is adding the correct handling to support represented port. And there're some limitation for the support that when matching all ports, the meter hierarchy should not contain any meter having drop count.
Shun Hao (3):
net/mlx5: fix meter hierarchy with represented port item net/mlx5: add meter flow limitation when matching all ports net/mlx5: fix meter ID tag for meter hierarchy
doc/guides/nics/mlx5.rst | 1 + drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_flow.c | 27 +++++++++---- drivers/net/mlx5/mlx5_flow.h | 4 ++ drivers/net/mlx5/mlx5_flow_dv.c | 71 ++++++++++++++++++++++----------- 5 files changed, 73 insertions(+), 32 deletions(-)
Signature · 1 line
2.20.0
PATCH 1/3 net/mlx5: fix meter hierarchy with represented port item
There is a new item type represented_port, and currently it will fail when using meter hierarchy in flow using represented_port match.
This patch fixes this fail by adding support for represented_port item in meter hierarchy flow split.
--- drivers/net/mlx5/mlx5_flow.c | 10 +++++++--- drivers/net/mlx5/mlx5_flow.h | 3 +++ drivers/net/mlx5/mlx5_flow_dv.c | 20 ++++++++++++++++---- 3 files changed, 26 insertions(+), 7 deletions(-)
drivers/net/mlx5/mlx5_flow.c +7 -3
@@ -5337,7 +5337,7 @@ flow_meter_split_prep(struct rte_eth_dev *dev,switch (item_type) {case RTE_FLOW_ITEM_TYPE_PORT_ID : -if (mlx5_flow_get_item_vport_id (dev, items, &flow_src_port, error)) +case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT :return -rte_errno;if (!fm->def_policy && wks->policy->is_hierarchy && flow_src_port != priv->representor_id) {
@@ -11025,14 +11025,18 @@ int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev, {struct mlx5_priv *port_priv;const struct rte_flow_item_port_id *pid_v; +uint32_t esw_mgr_port; -if (item->type !=RTE_FLOW_ITEM_TYPE_PORT_ID ) +if (item->type !=RTE_FLOW_ITEM_TYPE_PORT_ID && + item->type !=RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT )return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM_SPEC ,NULL ,"Incorrect item type." ); pid_v = item->spec;if (!pid_v)return 0 ; -if (pid_v->id ==MLX5_PORT_ESW_MGR ) { + esw_mgr_port = (item->type ==RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT ) ? +MLX5_REPRESENTED_PORT_ESW_MGR :MLX5_PORT_ESW_MGR ; +if (pid_v->id == esw_mgr_port) { *vport_id =mlx5_flow_get_esw_manager_vport_id (dev); }else { port_priv =mlx5_port_to_eswitch_info (pid_v->id, false);
drivers/net/mlx5/mlx5_flow.h +3 -0
@@ -21,6 +21,9 @@/* E-Switch Manager port, used for rte_flow_item_port_id. */ #define MLX5_PORT_ESW_MGR UINT32_MAX +/* E-Switch Manager port, used for rte_flow_item_ethdev. */ +#define MLX5_REPRESENTED_PORT_ESW_MGR UINT16_MAX +/* Private rte flow items. */ enum mlx5_rte_flow_item_type {MLX5_RTE_FLOW_ITEM_TYPE_END =INT_MIN ,
drivers/net/mlx5/mlx5_flow_dv.c +16 -4
@@ -7055,6 +7055,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,if (ret <0 )return ret; last_item =MLX5_FLOW_ITEM_REPRESENTED_PORT ; + port_id_item = items;break ;case RTE_FLOW_ITEM_TYPE_ETH : ret = mlx5_flow_validate_item_eth(items, item_flags,
@@ -16642,8 +16643,13 @@ __flow_dv_create_policy_flow(struct rte_eth_dev *dev,uint8_t misc_mask;if (match_src_port && priv->sh->esw_mode) { -if (flow_dv_translate_item_port_id (dev, matcher.buf, - value.buf, item, attr)) { +if (item && item->type ==RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT ) + ret =flow_dv_translate_item_represented_port (dev, matcher.buf, value.buf, + item, attr); +else + ret =flow_dv_translate_item_port_id (dev, matcher.buf, value.buf, + item, attr); +if (ret) {DRV_LOG (ERR ,"Failed to create meter policy%d flow's" " value with port." , color);return -1 ;
@@ -16692,10 +16698,16 @@ __flow_dv_create_policy_matcher(struct rte_eth_dev *dev,struct mlx5_flow_tbl_data_entry *tbl_data;struct mlx5_priv *priv = dev->data->dev_private;const uint32_t color_mask = (UINT32_C (1 ) <<MLX5_MTR_COLOR_BITS ) -1 ; +int ret;if (match_src_port && priv->sh->esw_mode) { -if (flow_dv_translate_item_port_id (dev, matcher.mask.buf, - value.buf, item, attr)) { +if (item && item->type ==RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT ) + ret =flow_dv_translate_item_represented_port (dev, matcher.mask.buf, + value.buf, item, attr); +else + ret =flow_dv_translate_item_port_id (dev, matcher.mask.buf, value.buf, + item, attr); +if (ret) {DRV_LOG (ERR ,"Failed to register meter policy%d matcher" " with port." , priority);return -1 ;
Signature · 1 line
2.20.0
PATCH 2/3 net/mlx5: add meter flow limitation when matching all ports
In reply to Shun HaoIf there's no param in represented_port item, it will be treated as matching all ports by default. But there's some limitation when using it with meter hierarchy.
This patch adds the limitation that when matching all ports, the meter hierarchy should not contain any meter having drop count.
--- doc/guides/nics/mlx5.rst | 1 + drivers/net/mlx5/mlx5.h | 2 ++ drivers/net/mlx5/mlx5_flow.c | 11 ++++++- drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 51 ++++++++++++++++++++------------- 5 files changed, 45 insertions(+), 21 deletions(-)
doc/guides/nics/mlx5.rst +1 -0
@@ -473,6 +473,7 @@ Limitations - meter profile packet mode is supported. - meter profiles of RFC2697, RFC2698 and RFC4115 are supported. - RFC4115 implementation is following MEF, meaning yellow traffic may reclaim unused green bandwidth when green token bucket is full. + - When using DV flow engine (``dv_flow_en`` = 1), if meter has drop count or meter hierarchy contains any meter that uses drop count, it cannot be used by flow matching all ports. - Integrity:
drivers/net/mlx5/mlx5.h +2 -0
@@ -775,6 +775,8 @@ struct mlx5_flow_meter_policy {/* Is queue action in policy table. */ uint32_t is_hierarchy:1;/* Is meter action in policy table. */ + uint32_t hierarchy_drop_cnt:1; +/* Is any meter in hierarchy contains drop_cnt. */ uint32_t skip_y:1;/* If yellow color policy is skipped. */ uint32_t skip_g:1;
drivers/net/mlx5/mlx5_flow.c +10 -1
@@ -5338,6 +5338,7 @@ flow_meter_split_prep(struct rte_eth_dev *dev,switch (item_type) {case RTE_FLOW_ITEM_TYPE_PORT_ID :case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT : +if (mlx5_flow_get_item_vport_id (dev, items, &flow_src_port,NULL , error))return -rte_errno;if (!fm->def_policy && wks->policy->is_hierarchy && flow_src_port != priv->representor_id) {
@@ -11012,6 +11013,8 @@ int16_t mlx5_flow_get_esw_manager_vport_id(struct rte_eth_dev *dev)* The src port id match item. * @param[out] vport_id * Pointer to put the vport id. +* @param[out] all_ports +* Indicate if the item matches all ports. * @param[out] error * Pointer to error structure. *
@@ -11021,6 +11024,7 @@ int16_t mlx5_flow_get_esw_manager_vport_id(struct rte_eth_dev *dev)int mlx5_flow_get_item_vport_id (struct rte_eth_dev *dev,const struct rte_flow_item *item,uint16_t *vport_id, +bool *all_ports,struct rte_flow_error *error) {struct mlx5_priv *port_priv;
@@ -11032,8 +11036,13 @@ int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev,return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM_SPEC ,NULL ,"Incorrect item type." ); pid_v = item->spec; -if (!pid_v) +if (!pid_v) { +if (all_ports) + *all_ports = (item->type ==RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT );return 0 ; + } +if (all_ports) + *all_ports = false; esw_mgr_port = (item->type ==RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT ) ?MLX5_REPRESENTED_PORT_ESW_MGR :MLX5_PORT_ESW_MGR ;if (pid_v->id == esw_mgr_port) {
drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -2087,6 +2087,7 @@ int16_t mlx5_flow_get_esw_manager_vport_id(struct rte_eth_dev *dev);int mlx5_flow_get_item_vport_id (struct rte_eth_dev *dev,const struct rte_flow_item *item,uint16_t *vport_id, +bool *all_ports,struct rte_flow_error *error);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +31 -20
70 lines not on this page · raw message
Signature · 1 line
2.20.0
PATCH 3/3 net/mlx5: fix meter ID tag for meter hierarchy
In reply to Shun HaoCurrently, when flow usese meter hierarchy, a tag action is always applied to set the first meter's meter id, so as to update the first meter's drop count. But it's not considered if first meter doesn't have drop count.
This patch fixes it, that in hierarchy, if the first meter doesn't have drop count, no need to add the meter id tag action. No change for non-hierarchy meter.
--- drivers/net/mlx5/mlx5_flow.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_flow.c +2 -4
@@ -6438,14 +6438,12 @@ flow_create_split_meter(struct rte_eth_dev *dev, }/* * If it isn't default-policy Meter, and -* 1. There's no action in flow to change +* 1. Not meter hierarchy and there's no action in flow to change * packet (modify/encap/decap etc.), OR * 2. No drop count needed for this meter. -* 3. It's not meter hierarchy. * Then no need to use regC to save meter id anymore. */ -if (!fm->def_policy && !is_mtr_hierarchy && - (!has_modify || !fm->drop_cnt)) +if (!fm->def_policy && ((!has_modify && !is_mtr_hierarchy) || !fm->drop_cnt)) set_mtr_reg = false;/* Prefix actions: meter, decap, encap, tag, jump, end, cnt. */ #define METER_PREFIX_ACTION 7
Signature · 1 line
2.20.0
Hi,
Quoted 30 lines
-----Original Message-----
From: Shun Hao <[email protected]>
Sent: Saturday, September 17, 2022 9:02 AM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>
Subject: [PATCH v1 0/3] Fix meter hierarchy issue for represented portWhen the represented port item was introduced, there's an issue that if a flow matching represented port item uses a meter hierarchy action, it will fail due to the represented port item not supported correctly in meter hierarchy creation.
This patch set is adding the correct handling to support represented port. And there're some limitation for the support that when matching all ports, the meter hierarchy should not contain any meter having drop count.
Shun Hao (3):
net/mlx5: fix meter hierarchy with represented port item net/mlx5: add meter flow limitation when matching all ports net/mlx5: fix meter ID tag for meter hierarchydoc/guides/nics/mlx5.rst | 1 + drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_flow.c | 27 +++++++++---- drivers/net/mlx5/mlx5_flow.h | 4 ++ drivers/net/mlx5/mlx5_flow_dv.c | 71 ++++++++++++++++++++++---------- - 5 files changed, 73 insertions(+), 32 deletions(-)
Quoted 2 lines
--
2.20.0
Series applied to next-net-mlx,
Kindest regards
Raslan Darawsheh