[v1] net/mlx5: fix meter creation default state

Message ID 20220307080035.1140326-1-rongweil@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series [v1] net/mlx5: fix meter creation default state |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-broadcom-Functional fail Functional Testing issues
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Rongwei Liu March 7, 2022, 8 a.m. UTC
  Disable means there is no packet drop in the meter. Meter is
active always but programmed with another CIR/CBS value.

If the user wants to disable the meter in creation, PMD calls
the disable() API manually after meter initialized.

Fixes: 444320186393 ("net/mlx5: support meter creation with policy")
Cc: stable@dpdk.org
Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_meter.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
  

Comments

Matan Azrad March 7, 2022, 10:11 a.m. UTC | #1
From: Rongwei Liu
> Disable means there is no packet drop in the meter. Meter is active always but
> programmed with another CIR/CBS value.
> 
> If the user wants to disable the meter in creation, PMD calls the disable() API
> manually after meter initialized.
> 
> Fixes: 444320186393 ("net/mlx5: support meter creation with policy")
> Cc: stable@dpdk.org
> Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
  
Raslan Darawsheh March 7, 2022, 8:56 p.m. UTC | #2
Hi,

> -----Original Message-----
> From: Rongwei Liu <rongweil@nvidia.com>
> Sent: Monday, March 7, 2022 10:01 AM
> To: Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; NBU-Contact-
> Thomas Monjalon (EXTERNAL) <thomas@monjalon.net>; Li Zhang
> <lizh@nvidia.com>
> Cc: dev@dpdk.org; Raslan Darawsheh <rasland@nvidia.com>;
> stable@dpdk.org
> Subject: [PATCH v1] net/mlx5: fix meter creation default state
> 
> Disable means there is no packet drop in the meter. Meter is
> active always but programmed with another CIR/CBS value.
> 
> If the user wants to disable the meter in creation, PMD calls
> the disable() API manually after meter initialized.
> 
> Fixes: 444320186393 ("net/mlx5: support meter creation with policy")
> Cc: stable@dpdk.org
> Signed-off-by: Rongwei Liu <rongweil@nvidia.com>

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c
index 06ab7c4a88..7b24948ab5 100644
--- a/drivers/net/mlx5/mlx5_flow_meter.c
+++ b/drivers/net/mlx5/mlx5_flow_meter.c
@@ -15,6 +15,10 @@ 
 #include "mlx5.h"
 #include "mlx5_flow.h"
 
+static int
+mlx5_flow_meter_disable(struct rte_eth_dev *dev,
+			uint32_t meter_id,
+			struct rte_mtr_error *error);
 /**
  * Create the meter action.
  *
@@ -1288,7 +1292,7 @@  mlx5_flow_meter_create(struct rte_eth_dev *dev, uint32_t meter_id,
 	}
 	/* Add to the flow meter list. */
 	fm->active_state = 1; /* Config meter starts as active. */
-	fm->is_enable = 1;
+	fm->is_enable = params->meter_enable;
 	fm->shared = !!shared;
 	__atomic_add_fetch(&fm->profile->ref_cnt, 1, __ATOMIC_RELAXED);
 	if (params->meter_policy_id == priv->sh->mtrmng->def_policy_id) {
@@ -1313,7 +1317,10 @@  mlx5_flow_meter_create(struct rte_eth_dev *dev, uint32_t meter_id,
 		data.dword = mtr_idx;
 		if (mlx5_l3t_set_entry(priv->mtr_idx_tbl, meter_id, &data))
 			goto error;
+	} else if (!params->meter_enable && mlx5_flow_meter_disable(dev, meter_id, error)) {
+		goto error;
 	}
+	fm->active_state = params->meter_enable;
 	if (mtr_policy)
 		__atomic_add_fetch(&mtr_policy->ref_cnt, 1, __ATOMIC_RELAXED);
 	return 0;