net/mlx5: add C++ include guard to public header
[dpdk.git] / drivers / net / cnxk / cn10k_rte_flow.c
index 00c0b17..529fb0e 100644 (file)
@@ -12,6 +12,14 @@ cn10k_mtr_connect(struct rte_eth_dev *eth_dev, uint32_t mtr_id)
        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[])
@@ -28,20 +36,20 @@ cn10k_mtr_configure(struct rte_eth_dev *eth_dev,
        for (i = 0; actions[i].type != RTE_FLOW_ACTION_TYPE_END; i++) {
                if (actions[i].type == RTE_FLOW_ACTION_TYPE_METER) {
                        mtr_conf = (const struct rte_flow_action_meter
-                                           *)(actions->conf);
+                                           *)(actions[i].conf);
                        mtr_id = mtr_conf->mtr_id;
                        is_mtr_act = true;
                }
                if (actions[i].type == RTE_FLOW_ACTION_TYPE_QUEUE) {
                        q_conf = (const struct rte_flow_action_queue
-                                         *)(actions->conf);
+                                         *)(actions[i].conf);
                        if (is_mtr_act)
                                nix_mtr_rq_update(eth_dev, mtr_id, 1,
                                                  &q_conf->index);
                }
                if (actions[i].type == RTE_FLOW_ACTION_TYPE_RSS) {
                        rss_conf = (const struct rte_flow_action_rss
-                                           *)(actions->conf);
+                                           *)(actions[i].conf);
                        if (is_mtr_act)
                                nix_mtr_rq_update(eth_dev, mtr_id,
                                                  rss_conf->queue_num,
@@ -90,7 +98,7 @@ cn10k_rss_action_validate(struct rte_eth_dev *eth_dev,
                return -EINVAL;
        }
 
-       if (eth_dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_RSS) {
+       if (eth_dev->data->dev_conf.rxmode.mq_mode != RTE_ETH_MQ_RX_RSS) {
                plt_err("multi-queue mode is disabled");
                return -ENOTSUP;
        }
@@ -163,7 +171,6 @@ cn10k_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
                        return NULL;
                }
        }
-
        for (i = 0; actions[i].type != RTE_FLOW_ACTION_TYPE_END; i++) {
                if (actions[i].type == RTE_FLOW_ACTION_TYPE_METER) {
                        mtr = (const struct rte_flow_action_meter *)actions[i]
@@ -215,6 +222,8 @@ cn10k_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *rte_flow,
        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) {
@@ -237,5 +246,15 @@ cn10k_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *rte_flow,
                }
        }
 
-       return cnxk_flow_destroy(eth_dev, flow, error);
+       mtr_id = flow->mtr_id;
+       rc = cnxk_flow_destroy(eth_dev, flow, error);
+       if (!rc && mtr_id != ROC_NIX_MTR_ID_INVALID) {
+               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;
 }