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 7FC20A0565; Tue, 17 Mar 2020 16:45:46 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C33B51C1D5; Tue, 17 Mar 2020 16:40:04 +0100 (CET) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by dpdk.org (Postfix) with ESMTP id A5F9F1C1CA for ; Tue, 17 Mar 2020 16:40:00 +0100 (CET) Received: by mail-wm1-f65.google.com with SMTP id x3so169680wmj.1 for ; Tue, 17 Mar 2020 08:40: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=O1uSSt58lUeih4duNhNp8Dz6NyW5S9PhqEXQHfpz/uxVK8YFbbCAb9BpSYI7SHnLR6 0HQzL/UKUFF11tlQbCtHCmSzIRJ2AHWoQFOGps/IZ/2kuiKDW//PPC9UQspolneuJprV jNFPM9wgIOGUvMsn+XJV4Y5jy54FTp5kuWWxU= 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=evnt0f6ijN5dR2oCCXRBdMXT4vSsIc/jdiIyIAaZvzSNse57k1AEZWNz5HZY3wRbPU 9Psejw7v/B2HPdFH7pZTX8nn8cVi6odmHGsPs45XbGZOk7dPpz8Afk4VaoVEU0v2Phfh hx4jUHa1JU5bK+rN3hv0/Ye14gP+u6cKd1FDRvsaBomBSx036l3Utab77DYtei/0ueSu tzNUuFM/50nPwPBm8nnYBwedO34vLJO+wZJR0yC4+CpIvLKX9+uMm2HQJ8ibbh/HtQjt IVgBdKbsCD6jMXbW4n/dLXHY/7u0KQnwnvuJy1DxHwnZAcv8rZyYKZ2pzQK+CVJqFo16 SZoQ== X-Gm-Message-State: ANhLgQ3ItMV9QQh5ENMSX6orGToMZO9i49OheM0jJxleW1vVOKl6us/v JqxfmDSPfWcbrZ04mysVL19QKmY7bdVajvA2XhGi69NO2i2+Si060OH/WRGz3br1g0QsY3mt71e kU2k+L7PkwdXBRi5S4uU92Ss+Ra0ccYKNs+RgPjr1fk1K2AuMSw9N2QqIkG9bmK2dSG3S X-Google-Smtp-Source: ADFU+vuSs3cN/uT3MPwnPtRkjV3xpqdq0NEhhCX1TFMJeBVOJUeJ8ycMSooIKAB+U/vuTyjO0Up/JA== X-Received: by 2002:a1c:e913:: with SMTP id q19mr6188458wmc.31.1584459600154; Tue, 17 Mar 2020 08:40:00 -0700 (PDT) Received: from S60.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id q4sm5052142wro.56.2020.03.17.08.39.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Mar 2020 08:39:59 -0700 (PDT) From: Venkat Duvvuru To: dev@dpdk.org Cc: Kishore Padmanabha , Venkat Duvvuru Date: Tue, 17 Mar 2020 21:08:25 +0530 Message-Id: <1584459511-5353-28-git-send-email-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1584459511-5353-1-git-send-email-venkatkumar.duvvuru@broadcom.com> References: <1584459511-5353-1-git-send-email-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH 27/33] 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