DPDK patches and discussions
 help / color / mirror / Atom feed
From: Somnath Kotur <somnath.kotur@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com
Subject: [dpdk-dev] [PATCH 3/8] net/bnxt: fix to allow group ID 0 for RSS action
Date: Tue, 28 Jan 2020 11:53:52 +0530	[thread overview]
Message-ID: <20200128062357.9316-4-somnath.kotur@broadcom.com> (raw)
In-Reply-To: <20200128062357.9316-1-somnath.kotur@broadcom.com>

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")

Reviewed-by: Ajit Kumar Khaparde <ajit.khaparde@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 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 ddb2681..bca9ad4 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -696,11 +696,23 @@ int bnxt_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete,
 #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 2ef1169..fc3f1a8 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 4b3b597..bd6c726 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -1059,16 +1059,9 @@ static int match_vnic_rss_cfg(struct bnxt *bp,
 			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 @@ static int match_vnic_rss_cfg(struct bnxt *bp,
 		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.
-- 
1.8.3.1


  parent reply	other threads:[~2020-01-28  6:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-28  6:23 [dpdk-dev] [PATCH 0/8] bnxt patch set Somnath Kotur
2020-01-28  6:23 ` [dpdk-dev] [PATCH 1/8] net/bnxt: fix bnxt_alloc_filter() to use a common routine Somnath Kotur
2020-01-28  6:23 ` [dpdk-dev] [PATCH 2/8] net/bnxt: fix bumping of L2 filter reference count Somnath Kotur
2020-01-28  6:23 ` Somnath Kotur [this message]
2020-01-28  6:23 ` [dpdk-dev] [PATCH 4/8] net/bnxt: remove redundant if statement Somnath Kotur
2020-01-28  6:23 ` [dpdk-dev] [PATCH 5/8] net/bnxt: remove redundant macro Somnath Kotur
2020-01-28  6:23 ` [dpdk-dev] [PATCH 6/8] net/bnxt: remove unnecessary structure variable Somnath Kotur
2020-01-28  6:23 ` [dpdk-dev] [PATCH 7/8] net/bnxt: remove a redundant variable Somnath Kotur
2020-01-28  6:23 ` [dpdk-dev] [PATCH 8/8] net/bnxt: fix to support zero mark id along with RSS action Somnath Kotur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200128062357.9316-4-somnath.kotur@broadcom.com \
    --to=somnath.kotur@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).