net/mlx5: fix meter cleaning in stop operation
PATCH 1/1 net/mlx5: fix meter cleaning in stop operation
A meter may handle Rx queue reference in his sub-policies. In stop operation, all the Rx queues are released.
Wrongly, the meter reference was not released before destroying the Rx queues what cause an error in stop.
Release the Rx queues meter references in stop operation.
--- drivers/net/mlx5/mlx5.h | 5 ++ drivers/net/mlx5/mlx5_flow.c | 77 ++++++++++++++------ drivers/net/mlx5/mlx5_flow.h | 6 ++ drivers/net/mlx5/mlx5_flow_dv.c | 109 +++++++++++++++++++---------- drivers/net/mlx5/mlx5_flow_meter.c | 36 +++++++++- drivers/net/mlx5/mlx5_trigger.c | 2 +- 6 files changed, 175 insertions(+), 60 deletions(-)
drivers/net/mlx5/mlx5.h +5 -0
@@ -668,6 +668,8 @@ struct mlx5_meter_policy_action_container {/* Index to port ID action resource. */ void *dr_jump_action[MLX5_MTR_DOMAIN_MAX ];/* Jump/drop action per color. */ +uint16_t queue; +/* Queue action configuration. */ }; };
@@ -681,6 +683,8 @@ struct mlx5_flow_meter_policy {/* Rule applies to egress domain. */ uint32_t transfer:1;/* Rule applies to transfer domain. */ + uint32_t is_queue:1; +/* Is queue action in policy table. */ rte_spinlock_t sl;uint32_t ref_cnt;/* Use count. */
@@ -1655,6 +1659,7 @@ struct mlx5_flow_meter_policy *mlx5_flow_meter_policy_find uint32_t *policy_idx);int mlx5_flow_meter_flush (struct rte_eth_dev *dev,struct rte_mtr_error *error); +void mlx5_flow_meter_rxq_flush (struct rte_eth_dev *dev);/* mlx5_os.c */ struct rte_pci_driver ;
drivers/net/mlx5/mlx5_flow.c +56 -21
103 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +6 -0
@@ -1156,6 +1156,9 @@ typedef struct mlx5_flow_meter_sub_policy * (struct rte_eth_dev *dev, struct mlx5_flow_meter_policy *mtr_policy, struct mlx5_flow_rss_desc *rss_desc[MLX5_MTR_RTE_COLORS]); +typedef void (*mlx5_flow_destroy_sub_policy_with_rxq_t ) + (struct rte_eth_dev *dev, +struct mlx5_flow_meter_policy *mtr_policy);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,
@@ -1249,6 +1252,7 @@ struct mlx5_flow_driver_ops {mlx5_flow_create_def_policy_t create_def_policy;mlx5_flow_destroy_def_policy_t destroy_def_policy;mlx5_flow_meter_sub_policy_rss_prepare_t meter_sub_policy_rss_prepare; +mlx5_flow_destroy_sub_policy_with_rxq_t destroy_sub_policy_with_rxq;mlx5_flow_counter_alloc_t counter_alloc;mlx5_flow_counter_free_t counter_free;mlx5_flow_counter_query_t counter_query;
@@ -1562,6 +1566,8 @@ struct mlx5_flow_meter_sub_policy *mlx5_flow_meter_sub_policy_rss_prepare (struct rte_eth_dev *dev, struct mlx5_flow_meter_policy *mtr_policy, struct mlx5_flow_rss_desc *rss_desc[MLX5_MTR_RTE_COLORS]); +void mlx5_flow_destroy_sub_policy_with_rxq (struct rte_eth_dev *dev, +struct mlx5_flow_meter_policy *mtr_policy);int mlx5_flow_dv_discover_counter_offset_support (struct rte_eth_dev *dev);int mlx5_action_handle_flush (struct rte_eth_dev *dev);void mlx5_release_tunnel_hub (struct mlx5_dev_ctx_shared *sh,uint16_t port_id);
drivers/net/mlx5/mlx5_flow_dv.c +72 -37
149 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +35 -1
@@ -748,7 +748,7 @@ mlx5_flow_meter_policy_add(struct rte_eth_dev *dev, policy->actions, error);if (ret) goto policy_add_err; -if (!is_rss) { +if (!is_rss && !mtr_policy->is_queue) {/* Create policy rules in HW. */ ret =mlx5_flow_create_policy_rules (dev, mtr_policy);if (ret)
@@ -1808,6 +1808,40 @@ mlx5_flow_meter_detach(struct mlx5_priv *priv,#endif } +/** +* Flush meter with Rx queue configuration. +* +* @param[in] dev +* Pointer to Ethernet device. +*/ +void +mlx5_flow_meter_rxq_flush (struct rte_eth_dev *dev) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_flow_meter_sub_policy *sub_policy; +struct mlx5_flow_meter_policy *mtr_policy; +void *entry; +uint32_t i, policy_idx; + +if (!priv->mtr_en) +return ; +if (priv->sh->mtrmng->policy_idx_tbl && priv->sh->refcnt ==1 ) { +MLX5_L3T_FOREACH (priv->sh->mtrmng->policy_idx_tbl, + i, entry) { + policy_idx = *(uint32_t *)entry; + sub_policy =mlx5_ipool_get + (priv->sh->ipool[MLX5_IPOOL_MTR_POLICY ], + policy_idx); +if (!sub_policy || !sub_policy->main_policy) +continue ; + mtr_policy = sub_policy->main_policy; +if (mtr_policy->is_queue || mtr_policy->is_rss) +mlx5_flow_destroy_sub_policy_with_rxq (dev, + mtr_policy); + } + } +} +/** * Flush meter configuration. *
drivers/net/mlx5/mlx5_trigger.c +1 -1
@@ -1180,7 +1180,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)mlx5_traffic_disable (dev);/* All RX queue flags will be cleared in the flush interface. */ mlx5_flow_list_flush (dev, &priv->flows, true); -mlx5_flow_meter_flush (dev,NULL ); +mlx5_flow_meter_rxq_flush (dev);mlx5_rx_intr_vec_disable (dev); priv->sh->port[priv->dev_port -1 ].ih_port_id =RTE_MAX_ETHPORTS ; priv->sh->port[priv->dev_port -1 ].devx_ih_port_id =RTE_MAX_ETHPORTS ;
Signature · 1 line
2.27.0
PATCH v2 1/1 net/mlx5: fix meter cleaning in stop operation
A meter may handle Rx queue reference in his sub-policies. In stop operation, all the Rx queues are released.
Wrongly, the meter reference was not released before destroying the Rx queues what cause an error in stop.
Release the Rx queues meter references in stop operation.
--- drivers/net/mlx5/mlx5.h | 5 ++ drivers/net/mlx5/mlx5_flow.c | 77 ++++++++++++++------ drivers/net/mlx5/mlx5_flow.h | 6 ++ drivers/net/mlx5/mlx5_flow_dv.c | 109 +++++++++++++++++++---------- drivers/net/mlx5/mlx5_flow_meter.c | 36 +++++++++- drivers/net/mlx5/mlx5_trigger.c | 2 +- 6 files changed, 175 insertions(+), 60 deletions(-)
drivers/net/mlx5/mlx5.h +5 -0
@@ -668,6 +668,8 @@ struct mlx5_meter_policy_action_container {/* Index to port ID action resource. */ void *dr_jump_action[MLX5_MTR_DOMAIN_MAX ];/* Jump/drop action per color. */ +uint16_t queue; +/* Queue action configuration. */ }; };
@@ -681,6 +683,8 @@ struct mlx5_flow_meter_policy {/* Rule applies to egress domain. */ uint32_t transfer:1;/* Rule applies to transfer domain. */ + uint32_t is_queue:1; +/* Is queue action in policy table. */ rte_spinlock_t sl;uint32_t ref_cnt;/* Use count. */
@@ -1655,6 +1659,7 @@ struct mlx5_flow_meter_policy *mlx5_flow_meter_policy_find uint32_t *policy_idx);int mlx5_flow_meter_flush (struct rte_eth_dev *dev,struct rte_mtr_error *error); +void mlx5_flow_meter_rxq_flush (struct rte_eth_dev *dev);/* mlx5_os.c */ struct rte_pci_driver ;
drivers/net/mlx5/mlx5_flow.c +56 -21
103 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +6 -0
@@ -1156,6 +1156,9 @@ typedef struct mlx5_flow_meter_sub_policy * (struct rte_eth_dev *dev, struct mlx5_flow_meter_policy *mtr_policy, struct mlx5_flow_rss_desc *rss_desc[MLX5_MTR_RTE_COLORS]); +typedef void (*mlx5_flow_destroy_sub_policy_with_rxq_t ) + (struct rte_eth_dev *dev, +struct mlx5_flow_meter_policy *mtr_policy);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,
@@ -1249,6 +1252,7 @@ struct mlx5_flow_driver_ops {mlx5_flow_create_def_policy_t create_def_policy;mlx5_flow_destroy_def_policy_t destroy_def_policy;mlx5_flow_meter_sub_policy_rss_prepare_t meter_sub_policy_rss_prepare; +mlx5_flow_destroy_sub_policy_with_rxq_t destroy_sub_policy_with_rxq;mlx5_flow_counter_alloc_t counter_alloc;mlx5_flow_counter_free_t counter_free;mlx5_flow_counter_query_t counter_query;
@@ -1562,6 +1566,8 @@ struct mlx5_flow_meter_sub_policy *mlx5_flow_meter_sub_policy_rss_prepare (struct rte_eth_dev *dev, struct mlx5_flow_meter_policy *mtr_policy, struct mlx5_flow_rss_desc *rss_desc[MLX5_MTR_RTE_COLORS]); +void mlx5_flow_destroy_sub_policy_with_rxq (struct rte_eth_dev *dev, +struct mlx5_flow_meter_policy *mtr_policy);int mlx5_flow_dv_discover_counter_offset_support (struct rte_eth_dev *dev);int mlx5_action_handle_flush (struct rte_eth_dev *dev);void mlx5_release_tunnel_hub (struct mlx5_dev_ctx_shared *sh,uint16_t port_id);
drivers/net/mlx5/mlx5_flow_dv.c +72 -37
149 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +35 -1
@@ -748,7 +748,7 @@ mlx5_flow_meter_policy_add(struct rte_eth_dev *dev, policy->actions, error);if (ret) goto policy_add_err; -if (!is_rss) { +if (!is_rss && !mtr_policy->is_queue) {/* Create policy rules in HW. */ ret =mlx5_flow_create_policy_rules (dev, mtr_policy);if (ret)
@@ -1808,6 +1808,40 @@ mlx5_flow_meter_detach(struct mlx5_priv *priv,#endif } +/** +* Flush meter with Rx queue configuration. +* +* @param[in] dev +* Pointer to Ethernet device. +*/ +void +mlx5_flow_meter_rxq_flush (struct rte_eth_dev *dev) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_flow_meter_sub_policy *sub_policy; +struct mlx5_flow_meter_policy *mtr_policy; +void *entry; +uint32_t i, policy_idx; + +if (!priv->mtr_en) +return ; +if (priv->sh->mtrmng->policy_idx_tbl && priv->sh->refcnt ==1 ) { +MLX5_L3T_FOREACH (priv->sh->mtrmng->policy_idx_tbl, + i, entry) { + policy_idx = *(uint32_t *)entry; + sub_policy =mlx5_ipool_get + (priv->sh->ipool[MLX5_IPOOL_MTR_POLICY ], + policy_idx); +if (!sub_policy || !sub_policy->main_policy) +continue ; + mtr_policy = sub_policy->main_policy; +if (mtr_policy->is_queue || mtr_policy->is_rss) +mlx5_flow_destroy_sub_policy_with_rxq (dev, + mtr_policy); + } + } +} +/** * Flush meter configuration. *
drivers/net/mlx5/mlx5_trigger.c +1 -1
@@ -1180,7 +1180,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)mlx5_traffic_disable (dev);/* All RX queue flags will be cleared in the flush interface. */ mlx5_flow_list_flush (dev, &priv->flows, true); -mlx5_flow_meter_flush (dev,NULL ); +mlx5_flow_meter_rxq_flush (dev);mlx5_rx_intr_vec_disable (dev); priv->sh->port[priv->dev_port -1 ].ih_port_id =RTE_MAX_ETHPORTS ; priv->sh->port[priv->dev_port -1 ].devx_ih_port_id =RTE_MAX_ETHPORTS ;
Signature · 1 line
2.27.0
Thomas Monjalon
Applied13/05/2021 10:35, Li Zhang:
Quoted 6 lines
A meter may handle Rx queue reference in his sub-policies. In stop operation, all the Rx queues are released.
Wrongly, the meter reference was not released before destroying the Rx queues what cause an error in stop.
Quoted 6 lines
Release the Rx queues meter references in stop operation.
Fixes fc6ce56bba ("net/mlx5: prepare sub-policy for flow with meter")Signed-off-by Li Zhang <[email protected]>Acked-by Matan Azrad <[email protected]>
Applied in next-net-mlx, thanks.
From: Li Zhang
Quoted 11 lines
A meter may handle Rx queue reference in his sub-policies. In stop operation, all the Rx queues are released.
Wrongly, the meter reference was not released before destroying the Rx queues what cause an error in stop.
Release the Rx queues meter references in stop operation.
Fixes fc6ce56bba ("net/mlx5: prepare sub-policy for flow with meter")Signed-off-by Li Zhang <[email protected]>