net/mlx5: add non-template flow metadata split
Subsystems (2)
PATCH 1/1 net/mlx5: add non-template flow metadata split
The method will not create any new flow rule implicitly during split stage, but only generate needed items, actions and attributes based on the detection.
All the rules will still be created in the flow_hw_list_create().
In the meanwhile, once the mark action is specified in the FDB rule, a new rule in the NIC Rx will be created to:
1. match the mark value on REG_C_x in FDB and set it into Rx flow tag field.
2. copy the metadata in REG_C_x' into the REG_B.
If there is no mark, the default rule with only copying metadata will be hit if there is Queue or RSS action in the NIC Rx rule.
Regarding the NIC Tx, only the metadata is relevant and it will be copied in NIC Tx from REG_A into some REG_C_x. The current HWS implementation already has already supported in the default copy rule or the default SQ miss rule in the NIC Tx root table.
---
Depends-on: patch-141122 ("net/mlx5: fix mlx5 device start failure")
--- drivers/net/mlx5/linux/mlx5_os.c | 19 +- drivers/net/mlx5/meson.build | 1 + drivers/net/mlx5/mlx5.c | 5 +- drivers/net/mlx5/mlx5_flow.c | 16 + drivers/net/mlx5/mlx5_flow.h | 51 ++- drivers/net/mlx5/mlx5_flow_hw.c | 121 ++++++- drivers/net/mlx5/mlx5_nta_split.c | 568 ++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_trigger.c | 7 +- 8 files changed, 758 insertions(+), 30 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_nta_split.c
drivers/net/mlx5/linux/mlx5_os.c +18 -1
@@ -503,8 +503,25 @@ mlx5_alloc_shared_dr(struct rte_eth_dev *eth_dev) mlx5_flex_parser_clone_free_cb);if (!sh->flex_parsers_dv) goto error; -if (priv->sh->config.dv_flow_en ==2 ) +if (priv->sh->config.dv_flow_en ==2 ) { +if (sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && + sh->dv_regc0_mask) { +/* Reuse DV callback functions. */ + sh->mreg_cp_tbl =mlx5_hlist_create (MLX5_FLOW_MREG_HNAME , +MLX5_FLOW_MREG_HTABLE_SZ , + false, true, eth_dev, + flow_nta_mreg_create_cb, + flow_dv_mreg_match_cb, + flow_nta_mreg_remove_cb, + flow_dv_mreg_clone_cb, + flow_dv_mreg_clone_free_cb); +if (!sh->mreg_cp_tbl) { + err =ENOMEM ; + goto error; + } + }return 0 ; + }/* Init port id action list. */ snprintf (s,sizeof (s),"%s_port_id_action_list" , sh->ibdev_name); sh->port_id_action_list = mlx5_list_create(s, sh, true,
drivers/net/mlx5/meson.build +1 -0
@@ -52,6 +52,7 @@ if is_linux 'mlx5_hws_cnt.c', 'mlx5_flow_quota.c', 'mlx5_flow_verbs.c', + 'mlx5_nta_split.c', ) endif
drivers/net/mlx5/mlx5.c +2 -3
@@ -2335,8 +2335,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)* If default mreg copy action is removed at the stop stage, * the search will return none and nothing will be done anymore. */ -if (priv->sh->config.dv_flow_en !=2 ) -mlx5_flow_stop_default (dev); +mlx5_flow_stop_default (dev);mlx5_traffic_disable (dev);/* * If all the flows are already flushed in the device stop stage,
@@ -3297,7 +3296,7 @@ mlx5_set_metadata_mask(struct rte_eth_dev *dev)break ;case MLX5_XMETA_MODE_META32_HWS : meta =UINT32_MAX ; - mark =MLX5_FLOW_MARK_MASK ; + mark = (reg_c0 >>rte_bsf32 (reg_c0)) &MLX5_FLOW_MARK_MASK ;break ;default : meta =0 ;
drivers/net/mlx5/mlx5_flow.c +16 -0
@@ -8125,6 +8125,17 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,void mlx5_flow_stop_default (struct rte_eth_dev *dev) { +#ifdef HAVE_MLX5_HWS_SUPPORT +struct mlx5_priv *priv = dev->data->dev_private; + +if (priv->sh->config.dv_flow_en ==2 ) { +mlx5_flow_nta_del_default_copy_action (dev); +if (!rte_atomic_load_explicit (&priv->hws_mark_refcnt, + rte_memory_order_relaxed)) +flow_hw_rxq_flag_set (dev, false); +return ; + } +#endif flow_mreg_del_default_copy_action (dev);flow_rxq_flags_clear (dev); }
@@ -8169,7 +8180,12 @@ int mlx5_flow_start_default(struct rte_eth_dev *dev) {struct rte_flow_error error; +#ifdef HAVE_MLX5_HWS_SUPPORT +struct mlx5_priv *priv = dev->data->dev_private; +if (priv->sh->config.dv_flow_en ==2 ) +return mlx5_flow_nta_add_default_copy_action (dev, &error); +#endif /* Make sure default copy action (reg_c[0] -> reg_b) is created. */ return flow_mreg_add_default_copy_action (dev, &error); }
drivers/net/mlx5/mlx5_flow.h +50 -1
75 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +102 -19
232 lines not on this page · raw message
drivers/net/mlx5/mlx5_nta_split.c new file +568 -0
568 lines not on this page · raw message
drivers/net/mlx5/mlx5_trigger.c +1 -6
@@ -1446,12 +1446,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)mlx5_mp_os_req_stop_rxtx (dev);rte_delay_us_sleep (1000 * priv->rxqs_n);DRV_LOG (DEBUG ,"port %u stopping device" , dev->data->port_id); -if (priv->sh->config.dv_flow_en ==2 ) { -if (!rte_atomic_load_explicit (&priv->hws_mark_refcnt, rte_memory_order_relaxed)) -flow_hw_rxq_flag_set (dev, false); - }else { -mlx5_flow_stop_default (dev); - } +mlx5_flow_stop_default (dev);/* Control flows for default traffic can be removed firstly. */ mlx5_traffic_disable (dev);/* All RX queue flags will be cleared in the flush interface. */
Signature · 1 line
2.34.1
PATCH v2 1/1 net/mlx5: add metadata split for compatibility API
The method will not create any new flow rule implicitly during split stage, but only generate needed items, actions and attributes based on the detection.
All the rules will still be created in the flow_hw_list_create().
In the meanwhile, once the mark action is specified in the FDB rule, a new rule in the NIC Rx will be created to:
1. match the mark value on REG_C_x in FDB and set it into Rx flow tag field.
2. copy the metadata in REG_C_x' into the REG_B.
If there is no mark, the default rule with only copying metadata will be hit if there is Queue or RSS action in the NIC Rx rule.
Regarding the NIC Tx, only the metadata is relevant and it will be copied in NIC Tx from REG_A into some REG_C_x. The current HWS implementation already has already supported in the default copy rule or the default SQ miss rule in the NIC Tx root table.
--- drivers/net/mlx5/linux/mlx5_os.c | 19 +- drivers/net/mlx5/meson.build | 1 + drivers/net/mlx5/mlx5.c | 5 +- drivers/net/mlx5/mlx5_flow.c | 16 + drivers/net/mlx5/mlx5_flow.h | 51 ++- drivers/net/mlx5/mlx5_flow_hw.c | 112 +++++- drivers/net/mlx5/mlx5_nta_split.c | 568 ++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_trigger.c | 7 +- 8 files changed, 754 insertions(+), 25 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_nta_split.c
drivers/net/mlx5/linux/mlx5_os.c +18 -1
@@ -503,8 +503,25 @@ mlx5_alloc_shared_dr(struct rte_eth_dev *eth_dev) mlx5_flex_parser_clone_free_cb);if (!sh->flex_parsers_dv) goto error; -if (priv->sh->config.dv_flow_en ==2 ) +if (priv->sh->config.dv_flow_en ==2 ) { +if (sh->config.dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY && + sh->dv_regc0_mask) { +/* Reuse DV callback functions. */ + sh->mreg_cp_tbl =mlx5_hlist_create (MLX5_FLOW_MREG_HNAME , +MLX5_FLOW_MREG_HTABLE_SZ , + false, true, eth_dev, + flow_nta_mreg_create_cb, + flow_dv_mreg_match_cb, + flow_nta_mreg_remove_cb, + flow_dv_mreg_clone_cb, + flow_dv_mreg_clone_free_cb); +if (!sh->mreg_cp_tbl) { + err =ENOMEM ; + goto error; + } + }return 0 ; + }/* Init port id action list. */ snprintf (s,sizeof (s),"%s_port_id_action_list" , sh->ibdev_name); sh->port_id_action_list = mlx5_list_create(s, sh, true,
drivers/net/mlx5/meson.build +1 -0
@@ -52,6 +52,7 @@ if is_linux 'mlx5_hws_cnt.c', 'mlx5_flow_quota.c', 'mlx5_flow_verbs.c', + 'mlx5_nta_split.c', ) endif
drivers/net/mlx5/mlx5.c +2 -3
@@ -2335,8 +2335,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)* If default mreg copy action is removed at the stop stage, * the search will return none and nothing will be done anymore. */ -if (priv->sh->config.dv_flow_en !=2 ) -mlx5_flow_stop_default (dev); +mlx5_flow_stop_default (dev);mlx5_traffic_disable (dev);/* * If all the flows are already flushed in the device stop stage,
@@ -3301,7 +3300,7 @@ mlx5_set_metadata_mask(struct rte_eth_dev *dev)break ;case MLX5_XMETA_MODE_META32_HWS : meta =UINT32_MAX ; - mark =MLX5_FLOW_MARK_MASK ; + mark = (reg_c0 >>rte_bsf32 (reg_c0)) &MLX5_FLOW_MARK_MASK ;break ;default : meta =0 ;
drivers/net/mlx5/mlx5_flow.c +16 -0
@@ -8152,6 +8152,17 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,void mlx5_flow_stop_default (struct rte_eth_dev *dev) { +#ifdef HAVE_MLX5_HWS_SUPPORT +struct mlx5_priv *priv = dev->data->dev_private; + +if (priv->sh->config.dv_flow_en ==2 ) { +mlx5_flow_nta_del_default_copy_action (dev); +if (!rte_atomic_load_explicit (&priv->hws_mark_refcnt, + rte_memory_order_relaxed)) +flow_hw_rxq_flag_set (dev, false); +return ; + } +#endif flow_mreg_del_default_copy_action (dev);flow_rxq_flags_clear (dev); }
@@ -8196,7 +8207,12 @@ int mlx5_flow_start_default(struct rte_eth_dev *dev) {struct rte_flow_error error; +#ifdef HAVE_MLX5_HWS_SUPPORT +struct mlx5_priv *priv = dev->data->dev_private; +if (priv->sh->config.dv_flow_en ==2 ) +return mlx5_flow_nta_add_default_copy_action (dev, &error); +#endif /* Make sure default copy action (reg_c[0] -> reg_b) is created. */ return flow_mreg_add_default_copy_action (dev, &error); }
drivers/net/mlx5/mlx5_flow.h +50 -1
75 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +98 -14
224 lines not on this page · raw message
drivers/net/mlx5/mlx5_nta_split.c new file +568 -0
568 lines not on this page · raw message
drivers/net/mlx5/mlx5_trigger.c +1 -6
@@ -1446,12 +1446,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)mlx5_mp_os_req_stop_rxtx (dev);rte_delay_us_sleep (1000 * priv->rxqs_n);DRV_LOG (DEBUG ,"port %u stopping device" , dev->data->port_id); -if (priv->sh->config.dv_flow_en ==2 ) { -if (!rte_atomic_load_explicit (&priv->hws_mark_refcnt, rte_memory_order_relaxed)) -flow_hw_rxq_flag_set (dev, false); - }else { -mlx5_flow_stop_default (dev); - } +mlx5_flow_stop_default (dev);/* Control flows for default traffic can be removed firstly. */ mlx5_traffic_disable (dev);/* All RX queue flags will be cleared in the flush interface. */
Signature · 1 line
2.34.1
Re: [PATCH v2] net/mlx5: add metadata split for compatibility API
Hi,
From: Bing Zhao <[email protected]>
Sent: Thursday, July 4, 2024 1:26 PM
To: Slava Ovsiienko; [email protected]; Raslan Darawsheh
Cc: Ori Kam; Dariusz Sosnowski; Suanming Mou; Matan Azrad
Subject: [PATCH v2] net/mlx5: add metadata split for compatibility API
The method will not create any new flow rule implicitly during split stage, but only generate needed items, actions and attributes based on the detection.
All the rules will still be created in the flow_hw_list_create().
In the meanwhile, once the mark action is specified in the FDB rule, a new rule in the NIC Rx will be created to:
1. match the mark value on REG_C_x in FDB and set it into Rx flow tag field.
2. copy the metadata in REG_C_x' into the REG_B.
If there is no mark, the default rule with only copying metadata will be hit if there is Queue or RSS action in the NIC Rx rule.
Regarding the NIC Tx, only the metadata is relevant and it will be copied in NIC Tx from REG_A into some REG_C_x. The current HWS implementation already has already supported in the default copy rule or the default SQ miss rule in the NIC Tx root table.
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
Re: [PATCH v2] net/mlx5: add metadata split for compatibility API
09/07/2024 11:36, Raslan Darawsheh:
Quoted 28 lines
Hi,
From: Bing Zhao <[email protected]>
Sent: Thursday, July 4, 2024 1:26 PM
To: Slava Ovsiienko; [email protected]; Raslan Darawsheh
Cc: Ori Kam; Dariusz Sosnowski; Suanming Mou; Matan Azrad
Subject: [PATCH v2] net/mlx5: add metadata split for compatibility APIThe method will not create any new flow rule implicitly during split stage, but only generate needed items, actions and attributes based on the detection.
All the rules will still be created in the
flow_hw_list_create().In the meanwhile, once the mark action is specified in the FDB rule, a new rule in the NIC Rx will be created to:
1. match the mark value onREG_C_xin FDB and set it into Rx flow tag field.
2. copy the metadata inREG_C_x' into theREG_B.If there is no mark, the default rule with only copying metadata will be hit if there is Queue or RSS action in the NIC Rx rule.
Regarding the NIC Tx, only the metadata is relevant and it will be copied in NIC Tx from
REG_Ainto someREG_C_x. The current HWS implementation already has already supported in the default copy rule or the default SQ miss rule in the NIC Tx root table.
Quoted 4 lines
Signed-off-by Bing Zhao <[email protected]>Patch applied to next-net-mlx,
It looks like this patch was missed,
probably not pushed in the branch.
Please send a v3 for integration in 24.11.
Re: [PATCH v2] net/mlx5: add metadata split for compatibility API
In reply to Bing Zhaohi,
From: Bing Zhao <[email protected]>
Sent: Thursday, July 4, 2024 1:26 PM
To: Slava Ovsiienko; [email protected]; Raslan Darawsheh
Cc: Ori Kam; Dariusz Sosnowski; Suanming Mou; Matan Azrad
Subject: [PATCH v2] net/mlx5: add metadata split for compatibility API
The method will not create any new flow rule implicitly during split stage, but only generate needed items, actions and attributes based on the detection.
All the rules will still be created in the flow_hw_list_create().
In the meanwhile, once the mark action is specified in the FDB rule, a new rule in the NIC Rx will be created to:
1. match the mark value on REG_C_x in FDB and set it into Rx flow tag field.
2. copy the metadata in REG_C_x' into the REG_B.
If there is no mark, the default rule with only copying metadata will be hit if there is Queue or RSS action in the NIC Rx rule.
Regarding the NIC Tx, only the metadata is relevant and it will be copied in NIC Tx from REG_A into some REG_C_x. The current HWS implementation already has already supported in the default copy rule or the default SQ miss rule in the NIC Tx root table.
Patch applied to next-net-mlx,
Kindest regards
Raslan Darawsheh