From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A885DA0563; Wed, 15 Apr 2020 10:26:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6AEAF1D608; Wed, 15 Apr 2020 10:20:44 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id D83BE1D607 for ; Wed, 15 Apr 2020 10:20:38 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id i3so1176230pgk.1 for ; Wed, 15 Apr 2020 01:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4NJ5hgUNFmX5oj6PEGdetBLdvm7yjNfaacABjhJrKxI=; b=ThTxy283AmdCHnNjxhSzNmh1c2rZSBf+CqrwfgM1O1VEMzh6gKJgH3fUyl4n0VdJQw s0EFefsp5cXNw0JgMAduJCd4ry3HxFEtlkPtWmYZlEZNWIccS9qp72wvZq+jIWXursjA Tl/dWIF3QqOVl4EO9EhmFLhhSMkl8selvzAJY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4NJ5hgUNFmX5oj6PEGdetBLdvm7yjNfaacABjhJrKxI=; b=Tnvu2OU4ekkXTY4ZOoBYK1WgkEmexu6ii6V0gIU7/wL/fvpuzVSKH1tMF7/qHhgsVT j1E3UNtx40LpsY/j9swq3eYNDYr/UXf9zyEZ6HM+PDv64mqHWJvsZfLiNpRid/oX+/ys cLEdB9hM88bw25pOewnZY0yLeP4Se6nSZZwQzBEgW+F4bG3bOmR9UWURCpY+DpDShiyY x7MHQ1tooL7oAXf3CbsdRt0bPQmCBur7NR9k0jSlw7E6pYjJVkb5FAjHh7wuLG41Ou/Z qdU6Nw3cC+1gHLDYtmHv4FSedgzGM4AgshZu6DchxCRalHnVzqRcg7bl3QomjXXLPxGf GraA== X-Gm-Message-State: AGi0PuZZpdxuwUksc5n0BIqKRBfF3GOkl0nPlVx7gfUR2VAP41HXiOS6 wExx3nYHf6nDoo7yHQNVnFy7T6/vba7rJe1jlBqIkaJAQ/IU4Kl6mxa1Y4V/yU3YRlWp84XORRV FS6HCzmF7JV2EFR9dU8dSaSeRmJ5qP3+WkclDQOHO6muyjt9BAW1cs0oyUOMo8TtHp5ha X-Google-Smtp-Source: APiQypLJIZ2F1/mcsbzWfiP0OeeOPzYWFSV0kZj/LJtpUBsaLG04W4QO71cE+uOul+ZUNV7/M3YqdA== X-Received: by 2002:a63:794d:: with SMTP id u74mr25925639pgc.15.1586938837599; Wed, 15 Apr 2020 01:20:37 -0700 (PDT) Received: from S60.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id fy21sm3819019pjb.25.2020.04.15.01.20.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Apr 2020 01:20:36 -0700 (PDT) From: Venkat Duvvuru To: dev@dpdk.org Cc: Kishore Padmanabha , Venkat Duvvuru Date: Wed, 15 Apr 2020 13:49:05 +0530 Message-Id: <1586938751-32808-29-git-send-email-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586938751-32808-1-git-send-email-venkatkumar.duvvuru@broadcom.com> References: <1586852011-37536-1-git-send-email-venkatkumar.duvvuru@broadcom.com> <1586938751-32808-1-git-send-email-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH v4 28/34] net/bnxt: add support for rte flow validate driver hook X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Kishore Padmanabha 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 Kumar Khaparde Reviewed-by: Somnath Kotur --- drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 67 ++++++++++++++++++++++++++++++++- 1 file changed, 66 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 6402dd3..490b2ba 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 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev, 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, -- 2.7.4