Meters are configured per flow using rte_flow_create API.
Patch adds support for destroy operation for meter action
applied on the flow.
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
return nix_mtr_connect(eth_dev, mtr_id);
}
+static int
+cn10k_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t mtr_id)
+{
+ struct rte_mtr_error mtr_error;
+
+ return nix_mtr_destroy(eth_dev, mtr_id, &mtr_error);
+}
+
static int
cn10k_mtr_configure(struct rte_eth_dev *eth_dev,
const struct rte_flow_action actions[])
struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
int mark_actions = 0, vtag_actions = 0;
struct roc_npc *npc = &dev->npc;
+ uint32_t mtr_id;
+ int rc;
mark_actions = roc_npc_mark_actions_get(npc);
if (mark_actions) {
}
}
- return cnxk_flow_destroy(eth_dev, flow, error);
+ mtr_id = flow->mtr_id;
+ rc = cnxk_flow_destroy(eth_dev, flow, error);
+ if (!rc) {
+ rc = cn10k_mtr_destroy(eth_dev, mtr_id);
+ if (rc) {
+ rte_flow_error_set(error, ENXIO,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+ "Meter attached to this flow does not exist");
+ }
+ }
+ return rc;
}
return rc;
}
+static int
+nix_meter_fini(struct cnxk_eth_dev *dev)
+{
+ struct cnxk_meter_node *next_mtr = NULL;
+ struct roc_nix_bpf_objs profs = {0};
+ struct cnxk_meter_node *mtr = NULL;
+ struct cnxk_mtr *fms = &dev->mtr;
+ struct roc_nix *nix = &dev->nix;
+ struct roc_nix_rq *rq;
+ uint32_t i;
+ int rc;
+
+ RTE_TAILQ_FOREACH_SAFE(mtr, fms, next, next_mtr) {
+ for (i = 0; i < mtr->rq_num; i++) {
+ rq = &dev->rqs[mtr->rq_id[i]];
+ rc |= roc_nix_bpf_ena_dis(nix, mtr->bpf_id, rq, false);
+ }
+
+ profs.level = mtr->level;
+ profs.count = 1;
+ profs.ids[0] = mtr->bpf_id;
+ rc = roc_nix_bpf_free(nix, &profs, 1);
+
+ if (rc)
+ return rc;
+
+ TAILQ_REMOVE(fms, mtr, next);
+ plt_free(mtr);
+ }
+ return 0;
+}
+
static int
nix_security_release(struct cnxk_eth_dev *dev)
{
if (rc)
goto fail_configure;
+ /* Disable and free rte_meter entries */
+ rc = nix_meter_fini(dev);
+ if (rc)
+ goto fail_configure;
+
/* Cleanup security support */
rc = nix_security_release(dev);
if (rc)
roc_nix_npc_rx_ena_dis(nix, false);
+ /* Disable and free rte_meter entries */
+ nix_meter_fini(dev);
+
/* Disable and free rte_flow entries */
roc_npc_fini(&dev->npc);
uint32_t level);
int nix_mtr_configure(struct rte_eth_dev *eth_dev, uint32_t id);
int nix_mtr_connect(struct rte_eth_dev *eth_dev, uint32_t id);
+int nix_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t id,
+ struct rte_mtr_error *error);
int nix_mtr_color_action_validate(struct rte_eth_dev *eth_dev, uint32_t id,
uint32_t *prev_id, uint32_t *next_id,
struct cnxk_mtr_policy_node *policy,
}
}
+int
+nix_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t id,
+ struct rte_mtr_error *error)
+{
+ return cnxk_nix_mtr_destroy(eth_dev, id, error);
+}
+
int
nix_mtr_connect(struct rte_eth_dev *eth_dev, uint32_t id)
{