[dpdk-dev] [PATCH v4 21/28] net/cnxk: support ops to delete meter policy
skori at marvell.com
skori at marvell.com
Mon Oct 11 17:50:49 CEST 2021
From: Sunil Kumar Kori <skori at marvell.com>
Implement API to delete meter policy for CNXK platform.
Signed-off-by: Sunil Kumar Kori <skori at marvell.com>
Signed-off-by: Rakesh Kudurumalla <rkudurumalla at marvell.com>
---
v4:
- Rebase support on dpdk-next-net-mrvl branch
- Handled meter action during flow destroy
- Handled meter cleanup during port shutdown
v3:
- Rebase support on latest DPDK
- Handled multilevel chaining for tree hierarchy
- Fix naming convention
v2:
- Rebase support on latest DPDK
- Handled multilevel chaining for linear hierarchy
- Review comments incorporated
drivers/net/cnxk/cnxk_ethdev_mtr.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/net/cnxk/cnxk_ethdev_mtr.c b/drivers/net/cnxk/cnxk_ethdev_mtr.c
index 187a0b90b2..c3739749fc 100644
--- a/drivers/net/cnxk/cnxk_ethdev_mtr.c
+++ b/drivers/net/cnxk/cnxk_ethdev_mtr.c
@@ -349,12 +349,38 @@ cnxk_nix_mtr_policy_add(struct rte_eth_dev *eth_dev, uint32_t policy_id,
return rc;
}
+static int
+cnxk_nix_mtr_policy_delete(struct rte_eth_dev *eth_dev, uint32_t policy_id,
+ struct rte_mtr_error *error)
+{
+ struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+ struct cnxk_mtr_policy_node *fmp;
+
+ fmp = nix_mtr_policy_find(dev, policy_id);
+ if (fmp == NULL) {
+ return -rte_mtr_error_set(error, ENOENT,
+ RTE_MTR_ERROR_TYPE_METER_POLICY_ID,
+ NULL, "No policy found");
+ }
+
+ if (fmp->ref_cnt)
+ return -rte_mtr_error_set(error, EBUSY,
+ RTE_MTR_ERROR_TYPE_METER_POLICY_ID,
+ NULL, "Meter policy is in use.");
+
+ TAILQ_REMOVE(&dev->mtr_policy, fmp, next);
+ plt_free(fmp);
+
+ return 0;
+}
+
const struct rte_mtr_ops nix_mtr_ops = {
.capabilities_get = cnxk_nix_mtr_capabilities_get,
.meter_profile_add = cnxk_nix_mtr_profile_add,
.meter_profile_delete = cnxk_nix_mtr_profile_delete,
.meter_policy_validate = cnxk_nix_mtr_policy_validate,
.meter_policy_add = cnxk_nix_mtr_policy_add,
+ .meter_policy_delete = cnxk_nix_mtr_policy_delete,
};
int
--
2.25.1
More information about the dev
mailing list