From 778472331e05fbb76ea1b60e7a0dfc101722d2e4 Mon Sep 17 00:00:00 2001 From: Kishore Padmanabha Date: Wed, 15 Apr 2020 13:49:06 +0530 Subject: [PATCH] net/bnxt: support flow API destroy 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 Signed-off-by: Venkat Duvvuru Reviewed-by: Lance Richardson Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 32 ++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c index 490b2ba03c..35099a383e 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c @@ -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 -- 2.20.1