net/bnxt: support flow API destroy
authorKishore Padmanabha <kishore.padmanabha@broadcom.com>
Wed, 15 Apr 2020 08:19:06 +0000 (13:49 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Apr 2020 11:57:08 +0000 (13:57 +0200)
This patch does the following
1. Gets the ulp session information from eth_dev
2. Fetches the flow associated with the flow id from the flow table
3. Calls ulp_mapper_resources_free which releases the key & action
   tables associated with that flow

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c

index 490b2ba..35099a3 100644 (file)
@@ -232,10 +232,40 @@ parse_error:
        return -EINVAL;
 }
 
+/* Function to destroy the rte flow. */
+static int
+bnxt_ulp_flow_destroy(struct rte_eth_dev *dev,
+                     struct rte_flow *flow,
+                     struct rte_flow_error *error)
+{
+       int ret = 0;
+       struct bnxt_ulp_context *ulp_ctx;
+       uint32_t fid;
+
+       ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(dev);
+       if (!ulp_ctx) {
+               BNXT_TF_DBG(ERR, "ULP context is not initialized\n");
+               rte_flow_error_set(error, EINVAL,
+                                  RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+                                  "Failed to destroy flow.");
+               return -EINVAL;
+       }
+
+       fid = (uint32_t)(uintptr_t)flow;
+
+       ret = ulp_mapper_flow_destroy(ulp_ctx, fid);
+       if (ret)
+               rte_flow_error_set(error, -ret,
+                                  RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+                                  "Failed to destroy flow.");
+
+       return ret;
+}
+
 const struct rte_flow_ops bnxt_ulp_rte_flow_ops = {
        .validate = bnxt_ulp_flow_validate,
        .create = bnxt_ulp_flow_create,
-       .destroy = NULL,
+       .destroy = bnxt_ulp_flow_destroy,
        .flush = NULL,
        .query = NULL,
        .isolate = NULL