From: Kishore Padmanabha Date: Wed, 15 Apr 2020 08:19:05 +0000 (+0530) Subject: net/bnxt: support flow API validate X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f88b99c9a139c2d36598ea6e4771be8626fb7ff0;p=dpdk.git net/bnxt: support flow API validate This patch does the following 1. Validates rte_flow_create arguments 2. Parses rte_flow_item types 3. Parses rte_flow_action types 4. Calls ulp_matcher_pattern_match to see if the flow is supported 5. If there is a match, returns success otherwise failure Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru Reviewed-by: Lance Richardson Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur --- diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c index 6402dd3f62..490b2ba03c 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c @@ -167,8 +167,73 @@ parse_error: return NULL; } +/* Function to validate the rte flow. */ +static int +bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused, + const struct rte_flow_attr *attr, + const struct rte_flow_item pattern[], + const struct rte_flow_action actions[], + struct rte_flow_error *error) +{ + struct ulp_rte_hdr_bitmap hdr_bitmap; + struct ulp_rte_hdr_field hdr_field[BNXT_ULP_PROTO_HDR_MAX]; + struct ulp_rte_act_bitmap act_bitmap; + struct ulp_rte_act_prop act_prop; + enum ulp_direction_type dir = ULP_DIR_INGRESS; + uint32_t class_id, act_tmpl; + int ret; + + if (bnxt_ulp_flow_validate_args(attr, + pattern, actions, + error) == BNXT_TF_RC_ERROR) { + BNXT_TF_DBG(ERR, "Invalid arguments being passed\n"); + return -EINVAL; + } + + /* clear the header bitmap and field structure */ + memset(&hdr_bitmap, 0, sizeof(struct ulp_rte_hdr_bitmap)); + memset(hdr_field, 0, sizeof(hdr_field)); + memset(&act_bitmap, 0, sizeof(act_bitmap)); + memset(&act_prop, 0, sizeof(act_prop)); + + /* Parse the rte flow pattern */ + ret = bnxt_ulp_rte_parser_hdr_parse(pattern, + &hdr_bitmap, + hdr_field); + if (ret != BNXT_TF_RC_SUCCESS) + goto parse_error; + + /* Parse the rte flow action */ + ret = bnxt_ulp_rte_parser_act_parse(actions, + &act_bitmap, + &act_prop); + if (ret != BNXT_TF_RC_SUCCESS) + goto parse_error; + + if (attr->egress) + dir = ULP_DIR_EGRESS; + + ret = ulp_matcher_pattern_match(dir, &hdr_bitmap, hdr_field, + &act_bitmap, &class_id); + + if (ret != BNXT_TF_RC_SUCCESS) + goto parse_error; + + ret = ulp_matcher_action_match(dir, &act_bitmap, &act_tmpl); + if (ret != BNXT_TF_RC_SUCCESS) + goto parse_error; + + /* all good return success */ + return ret; + +parse_error: + rte_flow_error_set(error, ret, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, + "Failed to validate flow."); + return -EINVAL; +} + const struct rte_flow_ops bnxt_ulp_rte_flow_ops = { - .validate = NULL, + .validate = bnxt_ulp_flow_validate, .create = bnxt_ulp_flow_create, .destroy = NULL, .flush = NULL,