DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Mody, Rasesh" <Rasesh.Mody@cavium.com>
To: "dev@dpdk.org" <dev@dpdk.org>
Cc: "Mody, Rasesh" <Rasesh.Mody@cavium.com>,
	"ferruh.yigit@intel.com" <ferruh.yigit@intel.com>,
	Dept-Eng DPDK Dev <Dept-EngDPDKDev@cavium.com>
Subject: [dpdk-dev] [PATCH 08/18] net/qede/base: adjust queue manager idx greater than max
Date: Sat, 29 Sep 2018 08:14:32 +0000	[thread overview]
Message-ID: <1538208822-9726-9-git-send-email-rasesh.mody@cavium.com> (raw)
In-Reply-To: <1538208822-9726-1-git-send-email-rasesh.mody@cavium.com>

Modified queue manager getter APIs to cycle through their range if
index is higher than max. This prevents accessing index out of bounds.

Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
---
 drivers/net/qede/base/ecore_dev.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/qede/base/ecore_dev.c b/drivers/net/qede/base/ecore_dev.c
index da312b4..f0adf18 100644
--- a/drivers/net/qede/base/ecore_dev.c
+++ b/drivers/net/qede/base/ecore_dev.c
@@ -569,12 +569,11 @@ u16 ecore_init_qm_get_num_pf_rls(struct ecore_hwfn *p_hwfn)
 {
 	u16 num_pf_rls, num_vfs = ecore_init_qm_get_num_vfs(p_hwfn);
 
-	/* @DPDK */
 	/* num RLs can't exceed resource amount of rls or vports or the
 	 * dcqcn qps
 	 */
 	num_pf_rls = (u16)OSAL_MIN_T(u32, RESC_NUM(p_hwfn, ECORE_RL),
-				     (u16)RESC_NUM(p_hwfn, ECORE_VPORT));
+				     RESC_NUM(p_hwfn, ECORE_VPORT));
 
 	/* make sure after we reserve the default and VF rls we'll have
 	 * something left
@@ -835,7 +834,7 @@ u16 ecore_get_cm_pq_idx_mcos(struct ecore_hwfn *p_hwfn, u8 tc)
 	if (tc > max_tc)
 		DP_ERR(p_hwfn, "tc %d must be smaller than %d\n", tc, max_tc);
 
-	return ecore_get_cm_pq_idx(p_hwfn, PQ_FLAGS_MCOS) + tc;
+	return ecore_get_cm_pq_idx(p_hwfn, PQ_FLAGS_MCOS) + (tc % max_tc);
 }
 
 u16 ecore_get_cm_pq_idx_vf(struct ecore_hwfn *p_hwfn, u16 vf)
@@ -845,17 +844,17 @@ u16 ecore_get_cm_pq_idx_vf(struct ecore_hwfn *p_hwfn, u16 vf)
 	if (vf > max_vf)
 		DP_ERR(p_hwfn, "vf %d must be smaller than %d\n", vf, max_vf);
 
-	return ecore_get_cm_pq_idx(p_hwfn, PQ_FLAGS_VFS) + vf;
+	return ecore_get_cm_pq_idx(p_hwfn, PQ_FLAGS_VFS) + (vf % max_vf);
 }
 
 u16 ecore_get_cm_pq_idx_rl(struct ecore_hwfn *p_hwfn, u16 rl)
 {
 	u16 max_rl = ecore_init_qm_get_num_pf_rls(p_hwfn);
 
-	if (rl > max_rl)
-		DP_ERR(p_hwfn, "rl %d must be smaller than %d\n", rl, max_rl);
-
-	return ecore_get_cm_pq_idx(p_hwfn, PQ_FLAGS_RLS) + rl;
+	/* for rate limiters, it is okay to use the modulo behavior - no
+	 * DP_ERR
+	 */
+	return ecore_get_cm_pq_idx(p_hwfn, PQ_FLAGS_RLS) + (rl % max_rl);
 }
 
 u16 ecore_get_qm_vport_idx_rl(struct ecore_hwfn *p_hwfn, u16 rl)
-- 
1.7.10.3

  parent reply	other threads:[~2018-09-29  8:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-29  8:13 [dpdk-dev] [PATCH 00/18] net/qede: base driver update Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 01/18] net/qede/base: upgrade to FW 8.37.7.0 Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 03/18] net/qede/base: add DPC sync after PF stop Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 02/18] net/qede/base: check for EDPM enabled in DB recovery Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 04/18] net/qede/base: workaround to indicate SHMEM data ready Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 05/18] net/qede/base: add API to update FW RSS indirection table Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 06/18] net/qede/base: add mf-bit/API for FIP special mode Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 07/18] net/qede/base: add error handling for mutex allocation Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 09/18] net/qede/base: add pretend function for port/PF Mody, Rasesh
2018-09-29  8:14 ` Mody, Rasesh [this message]
2018-09-29  8:14 ` [dpdk-dev] [PATCH 12/18] net/qede/base: get pre-negotiated OEM values Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 10/18] net/qede/base: add support for SRIOV VF min rate Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 11/18] net/qede/base: add periodic Doorbell Recovery support Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 13/18] net/qede/base: enable control frame filtering Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 15/18] net/qede/base: add RL update params Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 14/18] net/qede/base: changes for 100G Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 16/18] net/qede/base: add APIs for dscp priority map configuration Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 17/18] net/qede/base: semantic changes Mody, Rasesh
2018-09-29  8:14 ` [dpdk-dev] [PATCH 18/18] net/qede: bump PMD version to 2.10.0.1 Mody, Rasesh
2018-10-03 10:32 ` [dpdk-dev] [PATCH 00/18] net/qede: base driver update Ferruh Yigit

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=1538208822-9726-9-git-send-email-rasesh.mody@cavium.com \
    --to=rasesh.mody@cavium.com \
    --cc=Dept-EngDPDKDev@cavium.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).