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 C80FFA0577; Tue, 14 Apr 2020 10:19:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id ACCF41D159; Tue, 14 Apr 2020 10:15:01 +0200 (CEST) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id 487781D156 for ; Tue, 14 Apr 2020 10:15:00 +0200 (CEST) Received: by mail-pf1-f195.google.com with SMTP id l1so5724029pff.10 for ; Tue, 14 Apr 2020 01:15:00 -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=YOLrEyBH6atknqGPT9su4iL/87erjlBL0eKrep+IjhCqAyJC6I1ZR22E3iYhqkzL9R Yu+HJsH52/qOKeDAFYXr8MI2G+yjZMkbzsU/goN/nZM9q6CbyxwHzOC2zbfGxAd/TC+E HVUVcVRgi/4uRrDmS3L6MBSV2O9XTg/oiJmuA= 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=NYwk1sUfHAX3VphDg8nodCqbc35gknPgK+SIkYd+VlIDDtIksGV837FFh3Y/V+5ThW 5kJKbKflQZWO61vFO44X1fQQAV7MSuVoa5FFseRBEVAkRg2xvBUMjrSoSvkW3AMW5Q/J bhYTkNky37HF/YASRKCjWUMBLm0lJrK06ApIiDfcTz0/8+1rXule/ENRTXZxWrOGXPHV tS08aAKLzmJHPtAaB1XWP+YZ9q5vNnA9l+ZNSDPIJdDQZFduvbX8X/MGXv/gNcVakcLi +Qbb6rpYfmgBRH3vscsFpu7oy8XVqTjs/FdEbqS+jUgFv6UMP9lJ3vEtwboUlL6M/VIM lVlg== X-Gm-Message-State: AGi0Pub8rRan3ilQhNxsxj9hkdSe9C0TdETJtoKOhImRBsHsua/KmeVe q67aBXa6Opr5jeYnYf17pVAmxXb/oh8pvCYxPQEFjy+XMFht42+hVjYB9dQXCwDxYHvvMCzL2Iz o7lVpwRlx/d2uOook2vg82dHuOaP9YhPLqdR74x0DMcFjR2GBBFswFbY58NPjSWI8PU8G X-Google-Smtp-Source: APiQypLI5wcdutlK2Ts+zWZQXgEJYSREW57z1z7b5HHuNNmpfsJmbzOFdyjVWySPf5x2+cgHoZnkuA== X-Received: by 2002:a62:7547:: with SMTP id q68mr5095233pfc.55.1586852099050; Tue, 14 Apr 2020 01:14:59 -0700 (PDT) Received: from S60.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id e196sm671176pfh.43.2020.04.14.01.14.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Apr 2020 01:14:58 -0700 (PDT) From: Venkat Duvvuru To: dev@dpdk.org Cc: Kishore Padmanabha , Venkat Duvvuru Date: Tue, 14 Apr 2020 13:43:25 +0530 Message-Id: <1586852011-37536-29-git-send-email-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586852011-37536-1-git-send-email-venkatkumar.duvvuru@broadcom.com> References: <1586806811-21736-1-git-send-email-venkatkumar.duvvuru@broadcom.com> <1586852011-37536-1-git-send-email-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH v3 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