From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0063.outbound.protection.outlook.com [104.47.37.63]) by dpdk.org (Postfix) with ESMTP id 660D52C37 for ; Sat, 29 Sep 2018 10:14:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BqJ6LuDcsRiEbCCO7Ef6Eso2+UfmCRjtx9lm6BTuvto=; b=Scf0R1TSdvLn8Ygwd4pM0Gxy4uCJbKV8S0M6ZmWWEnSs/JrBEhqjNK//C3mexLDqsEJdmiOzgebbD6+Tfo3UI4QKy6Xeobi2l5wJDUx0N2ssXpoHAQEwqQ+P/uH3IHjGxe7kxK+lhqxki+/yshGG/soQfR2EyHuyAuLqqVAFFHE= Received: from BYAPR07MB5365.namprd07.prod.outlook.com (20.177.125.18) by BYAPR07MB4806.namprd07.prod.outlook.com (20.176.248.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.20; Sat, 29 Sep 2018 08:14:32 +0000 Received: from BYAPR07MB5365.namprd07.prod.outlook.com ([fe80::2047:9647:f196:bde0]) by BYAPR07MB5365.namprd07.prod.outlook.com ([fe80::2047:9647:f196:bde0%6]) with mapi id 15.20.1143.022; Sat, 29 Sep 2018 08:14:32 +0000 From: "Mody, Rasesh" To: "dev@dpdk.org" CC: "Mody, Rasesh" , "ferruh.yigit@intel.com" , Dept-Eng DPDK Dev Thread-Topic: [PATCH 08/18] net/qede/base: adjust queue manager idx greater than max Thread-Index: AQHUV8xzQUeEgGUelUWE/BIRUKE/4A== Date: Sat, 29 Sep 2018 08:14:32 +0000 Message-ID: <1538208822-9726-9-git-send-email-rasesh.mody@cavium.com> References: <1538208822-9726-1-git-send-email-rasesh.mody@cavium.com> In-Reply-To: <1538208822-9726-1-git-send-email-rasesh.mody@cavium.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR11CA0059.namprd11.prod.outlook.com (2603:10b6:a03:80::36) To BYAPR07MB5365.namprd07.prod.outlook.com (2603:10b6:a03:64::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Rasesh.Mody@cavium.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [198.186.1.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR07MB4806; 6:pgFv6H4Jf/Fs3Eq9pwz8nUjWpd4nrj2cKnIfOqioM31wbP2Fs1NlPHIp9Sq0rrIPRLu1wEEPMCf6DqtIcHj+Snx9j9MS77pMzZER1oSNS1lDKyFK9GTuD4I+KivLjb3N6hOcwddYuYp83+XLc3ADjFQADMk1EHLxPTg5Sgupf20cTMNxfZLZ4R4DBvMqQ6llCOXSu3O6NM+CMZ7eZN1BAasYhWuLUNmuQ4iE0N5w0omFLmW+BC5d4o2D2HJCNAarHgje2IqHG5s/YC7j7RvaTHqRLkq8IHTeRWUlx17CEs5ICWDP0wt+2KmFJF3YFfK7Ohc/BCeBImvvY0JfrHiRFXy8ZwOSZ2ZEWBGDo4LZMq3PqbqItR+8N6vyBEA6MK3tQD/2gIwm+JpxblNicL7qV4sKwiopXNtuQ5x57o3/nkcx44tM0JGSMPQhT6ZQKUlm0GUDAPe05awgjnS8mKxaAg==; 5:IcLGo6cbkuGdg/Fk2KZqsdly/GghNxLCxBfsj3NBjy4u3+EviMXycAQHgAlMKl2La94nAONO6BYsTu1XHunlFJsfP4QjaceitNkvlq08i0bLtvpzuSPtfUNgK53zgUoJrET4tY9pmw2SamzAx2VMnRwKLu2PY4YoRMUk7a4M0pc=; 7:tueKFwzEA5/Wn6cpgT+KG1rwBvYXf3mTfs0b2PukWT3h4e6g1MrkHx56g94fpxePJnThKmAr3TTzzDzqOa71ESFNSeUh7c5WIcsLTswE3nMc7EQOYM56X8rfUxY2M6Bto2xvrVUpGWE1GRhrH4YEEQ5fwTgRKuHX9N56P1m/yGS94ZQI114dtdWjpxRo+bVy12/7LQU+O+is9Fdum15U2jgfbzlNFd3LvOgfCB6XqL9bVxWAbguIr0Rp/tej1CZ8 x-ms-office365-filtering-correlation-id: 66decac2-58e3-4772-7f7c-08d625e395a4 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BYAPR07MB4806; x-ms-traffictypediagnostic: BYAPR07MB4806: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(93006095)(93001095)(3002001)(3231355)(944501410)(52105095)(10201501046)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:BYAPR07MB4806; BCL:0; PCL:0; RULEID:; SRVR:BYAPR07MB4806; x-forefront-prvs: 0810818DA0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(376002)(396003)(366004)(136003)(39860400002)(199004)(189003)(26005)(4326008)(102836004)(14444005)(256004)(2616005)(66066001)(446003)(476003)(71190400001)(71200400001)(6116002)(11346002)(3846002)(316002)(5660300001)(36756003)(486006)(2906002)(107886003)(25786009)(8936002)(68736007)(6512007)(8676002)(106356001)(14454004)(5640700003)(81156014)(81166006)(105586002)(1730700003)(6436002)(6486002)(52116002)(76176011)(53936002)(72206003)(2351001)(7736002)(305945005)(478600001)(54906003)(6916009)(2501003)(186003)(575784001)(86362001)(6506007)(386003)(5250100002)(2900100001)(34290500001)(99286004)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR07MB4806; H:BYAPR07MB5365.namprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 1vDzN2zc8dkZnJ372NtXe/FNaJLWFZ2oG7zC7Iii3EQnXQR8UA/EKc6pZB2GrhGaMBKPvF2Y1NXj9H1jYdyZQadoaPAXyFLS6FG+8ZdPjmJ/L3JVtqiA7V0mKRHU3Qt/NNv07HGa+GzgYU4tJFJsS9KNgJZ9QUZU7+/mUr3fStTMnq2jsoW/mV9wE+31eDstNfBJM2sLFmIi4tPcN7KOfsZ03JIKINV7oL8nLfKlJFR2f57HbpYUPPOF/UbXm+pdnScEZOiRYShsL8qoXzwAOl3oFHlZaUTLjqvagUqIZxR8gsZyv+XTOsN/pGy+6MiJT7o+QujW67bd8PwiH05uskggwRj5UC3yaaLJ9N3ovT0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66decac2-58e3-4772-7f7c-08d625e395a4 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Sep 2018 08:14:32.0945 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR07MB4806 Subject: [dpdk-dev] [PATCH 08/18] net/qede/base: adjust queue manager idx greater than max 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: , X-List-Received-Date: Sat, 29 Sep 2018 08:14:34 -0000 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 --- 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/ecor= e_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 =3D ecore_init_qm_get_num_vfs(p_hwfn); =20 - /* @DPDK */ /* num RLs can't exceed resource amount of rls or vports or the * dcqcn qps */ num_pf_rls =3D (u16)OSAL_MIN_T(u32, RESC_NUM(p_hwfn, ECORE_RL), - (u16)RESC_NUM(p_hwfn, ECORE_VPORT)); + RESC_NUM(p_hwfn, ECORE_VPORT)); =20 /* 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); =20 - 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); } =20 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); =20 - 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); } =20 u16 ecore_get_cm_pq_idx_rl(struct ecore_hwfn *p_hwfn, u16 rl) { u16 max_rl =3D ecore_init_qm_get_num_pf_rls(p_hwfn); =20 - 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); } =20 u16 ecore_get_qm_vport_idx_rl(struct ecore_hwfn *p_hwfn, u16 rl) --=20 1.7.10.3