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 89755A04B3; Tue, 28 Jan 2020 22:02:43 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 457441D5B1; Tue, 28 Jan 2020 22:02:14 +0100 (CET) Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id BFFDF1D5A7; Tue, 28 Jan 2020 22:02:05 +0100 (CET) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.242.48]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 2A20830C1FD; Tue, 28 Jan 2020 12:55:11 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 2A20830C1FD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1580244911; bh=Q1Oh2iCTmRkx0AEEH6O90SUu8hvHJFQ7ffELSjTz6Co=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qnFWxaCk0panYFfxAYIySPb7Hq04MbvgEatKWop7CrkFjDP0auwhmsVDfNFRfDMsV hyBwXmmtBhUrnc0AqVFjibgU2cg+kc5JQpV3+DoSpjXKRwAJNmLMYnTVnpRu4YPV/M 4guARNV+oNHD0g33yRN18aVonk8Kznkm7KGuzkg8= Received: from C02VPB22HTD6.wifi.broadcom.net (c02vpb22htd6.wifi.broadcom.net [10.69.74.102]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id B100914008B; Tue, 28 Jan 2020 13:02:04 -0800 (PST) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Somnath Kotur , stable@dpdk.org Date: Tue, 28 Jan 2020 13:01:53 -0800 Message-Id: <20200128210159.6972-4-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20200128210159.6972-1-ajit.khaparde@broadcom.com> References: <20200128072923.9912-1-somnath.kotur@broadcom.com> <20200128210159.6972-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 3/9] net/bnxt: fix to allow group ID 0 for RSS action 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: Somnath Kotur Allow RSS action with group ID 0. The RSS match check will ensure if requested RSS action configuration parameters should be allowed as per the VNIC's RSS configuration or not and if it does match as it is by design in OVS-DPDK use case, the default vnic can be used to create the filter. As part of this ensure that rx_queue_cnt for the default vnic is setup during init as this field was being set only for non-zero vnics while handling RSS action for flow create. Check for outofboundds erorr while accessing the vnic array. Fixes: adc0f81c6552d ("net/bnxt: support RSS action") Cc: stable@dpdk.org Reviewed-by: Ajit Khaparde Signed-off-by: Somnath Kotur --- drivers/net/bnxt/bnxt.h | 14 +++++++++++++- drivers/net/bnxt/bnxt_ethdev.c | 4 ++++ drivers/net/bnxt/bnxt_flow.c | 33 ++++----------------------------- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index ddb26814c..bca9ad418 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -696,11 +696,23 @@ extern const struct rte_flow_ops bnxt_flow_ops; #define bnxt_release_flow_lock(bp) \ pthread_mutex_unlock(&(bp)->flow_lock) +#define BNXT_VALID_VNIC_OR_RET(bp, vnic_id) do { \ + if ((vnic_id) >= (bp)->max_vnics) { \ + rte_flow_error_set(error, \ + EINVAL, \ + RTE_FLOW_ERROR_TYPE_ATTR_GROUP, \ + NULL, \ + "Group id is invalid!"); \ + rc = -rte_errno; \ + goto ret; \ + } \ +} while (0) + extern int bnxt_logtype_driver; #define PMD_DRV_LOG_RAW(level, fmt, args...) \ rte_log(RTE_LOG_ ## level, bnxt_logtype_driver, "%s(): " fmt, \ __func__, ## args) #define PMD_DRV_LOG(level, fmt, args...) \ - PMD_DRV_LOG_RAW(level, fmt, ## args) + PMD_DRV_LOG_RAW(level, fmt, ## args) #endif diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 2ef1169b8..fc3f1a8db 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -295,8 +295,12 @@ static int bnxt_setup_one_vnic(struct bnxt *bp, uint16_t vnic_id) if (BNXT_HAS_RING_GRPS(bp) && rxq->rx_deferred_start) rxq->vnic->fw_grp_ids[j] = INVALID_HW_RING_ID; + else + vnic->rx_queue_cnt++; } + PMD_DRV_LOG(DEBUG, "vnic->rx_queue_cnt = %d\n", vnic->rx_queue_cnt); + rc = bnxt_vnic_rss_configure(bp, vnic); if (rc) goto err_out; diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c index 4b3b59795..bd6c72623 100644 --- a/drivers/net/bnxt/bnxt_flow.c +++ b/drivers/net/bnxt/bnxt_flow.c @@ -1059,16 +1059,9 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, vnic_id = act_q->index; } + BNXT_VALID_VNIC_OR_RET(bp, vnic_id); + vnic = &bp->vnic_info[vnic_id]; - if (vnic == NULL) { - rte_flow_error_set(error, - EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - act, - "No matching VNIC found."); - rc = -rte_errno; - goto ret; - } if (vnic->rx_queue_cnt) { if (vnic->start_grp_id != act_q->index) { PMD_DRV_LOG(ERR, @@ -1268,28 +1261,10 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, rss = (const struct rte_flow_action_rss *)act->conf; vnic_id = attr->group; - if (!vnic_id) { - PMD_DRV_LOG(ERR, "Group id cannot be 0\n"); - rte_flow_error_set(error, - EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR, - NULL, - "Group id cannot be 0"); - rc = -rte_errno; - goto ret; - } + + BNXT_VALID_VNIC_OR_RET(bp, vnic_id); vnic = &bp->vnic_info[vnic_id]; - if (vnic == NULL) { - rte_flow_error_set(error, - EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - act, - "No matching VNIC for RSS group."); - rc = -rte_errno; - goto ret; - } - PMD_DRV_LOG(DEBUG, "VNIC found\n"); /* Check if requested RSS config matches RSS config of VNIC * only if it is not a fresh VNIC configuration. -- 2.21.0 (Apple Git-122.2)