X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fnet%2Fbnxt%2Ftf_ulp%2Fbnxt_ulp_flow.c;h=dbec8cecf2b3e2699cf8dc54a7d7fb70d22a9635;hb=ac2df046a0cabd68e520fafbeaccd35e3e1b86ef;hp=7f7aa24e6561986d50383a34e023458216215c76;hpb=2bbcdee826ffd5dc4d05f4aaab88375832577fb4;p=dpdk.git diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c index 7f7aa24e65..dbec8cecf2 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c @@ -69,7 +69,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev, { struct bnxt_ulp_mapper_create_parms mapper_cparms = { 0 }; struct ulp_rte_parser_params params; - struct bnxt_ulp_context *ulp_ctx = NULL; + struct bnxt_ulp_context *ulp_ctx; uint32_t class_id, act_tmpl; struct rte_flow *flow_id; uint32_t fid; @@ -90,6 +90,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev, /* Initialize the parser params */ memset(¶ms, 0, sizeof(struct ulp_rte_parser_params)); + params.ulp_ctx = ulp_ctx; if (attr->egress) params.dir = ULP_DIR_EGRESS; @@ -110,7 +111,6 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev, goto parse_error; ret = ulp_matcher_pattern_match(¶ms, &class_id); - if (ret != BNXT_TF_RC_SUCCESS) goto parse_error; @@ -125,11 +125,11 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev, mapper_cparms.act_prop = ¶ms.act_prop; mapper_cparms.class_tid = class_id; mapper_cparms.act_tid = act_tmpl; + mapper_cparms.func_id = bnxt_get_fw_func_id(dev->data->port_id); + mapper_cparms.dir = params.dir; - /* call the ulp mapper to create the flow in the hardware */ - ret = ulp_mapper_flow_create(ulp_ctx, - &mapper_cparms, - &fid); + /* Call the ulp mapper to create the flow in the hardware. */ + ret = ulp_mapper_flow_create(ulp_ctx, &mapper_cparms, &fid); if (!ret) { flow_id = (struct rte_flow *)((uintptr_t)fid); return flow_id; @@ -143,7 +143,7 @@ parse_error: /* Function to validate the rte flow. */ static int -bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused, +bnxt_ulp_flow_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], @@ -152,6 +152,7 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused, struct ulp_rte_parser_params params; uint32_t class_id, act_tmpl; int ret; + struct bnxt_ulp_context *ulp_ctx; if (bnxt_ulp_flow_validate_args(attr, pattern, actions, @@ -160,8 +161,15 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused, return -EINVAL; } + ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(dev); + if (!ulp_ctx) { + BNXT_TF_DBG(ERR, "ULP context is not initialized\n"); + return -EINVAL; + } + /* Initialize the parser params */ memset(¶ms, 0, sizeof(struct ulp_rte_parser_params)); + params.ulp_ctx = ulp_ctx; if (attr->egress) params.dir = ULP_DIR_EGRESS; @@ -202,7 +210,8 @@ bnxt_ulp_flow_destroy(struct rte_eth_dev *dev, { int ret = 0; struct bnxt_ulp_context *ulp_ctx; - uint32_t fid; + uint32_t flow_id; + uint16_t func_id; ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(dev); if (!ulp_ctx) { @@ -213,9 +222,19 @@ bnxt_ulp_flow_destroy(struct rte_eth_dev *dev, return -EINVAL; } - fid = (uint32_t)(uintptr_t)flow; + flow_id = (uint32_t)(uintptr_t)flow; + func_id = bnxt_get_fw_func_id(dev->data->port_id); - ret = ulp_mapper_flow_destroy(ulp_ctx, fid); + if (ulp_flow_db_validate_flow_func(ulp_ctx, flow_id, func_id) == + false) { + BNXT_TF_DBG(ERR, "Incorrect device params\n"); + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_HANDLE, NULL, + "Failed to destroy flow."); + return -EINVAL; + } + + ret = ulp_mapper_flow_destroy(ulp_ctx, flow_id); if (ret) rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, @@ -230,8 +249,9 @@ bnxt_ulp_flow_flush(struct rte_eth_dev *eth_dev, struct rte_flow_error *error) { struct bnxt_ulp_context *ulp_ctx; - int32_t ret; + int32_t ret = 0; struct bnxt *bp; + uint16_t func_id; ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(eth_dev); if (!ulp_ctx) { @@ -244,10 +264,12 @@ bnxt_ulp_flow_flush(struct rte_eth_dev *eth_dev, bp = eth_dev->data->dev_private; /* Free the resources for the last device */ - if (!ulp_ctx_deinit_allowed(bp)) - return 0; - - ret = ulp_flow_db_flush_flows(ulp_ctx, BNXT_ULP_REGULAR_FLOW_TABLE); + if (ulp_ctx_deinit_allowed(bp)) { + ret = ulp_flow_db_session_flow_flush(ulp_ctx); + } else if (bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctx)) { + func_id = bnxt_get_fw_func_id(eth_dev->data->port_id); + ret = ulp_flow_db_function_flow_flush(ulp_ctx, func_id); + } if (ret) rte_flow_error_set(error, ret, RTE_FLOW_ERROR_TYPE_HANDLE, NULL,