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 ED6D0A04B5 for ; Tue, 3 Dec 2019 19:29:24 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E63FD1BFCE; Tue, 3 Dec 2019 19:29:24 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by dpdk.org (Postfix) with ESMTP id 039E337AF for ; Tue, 3 Dec 2019 19:29:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575397762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H4oYHemCA9yrKUk0s+WNv4Fr9ZPmAsqRsZCwM26Y3eA=; b=AAjW5Dn1Ef8bznvAvhmzo4ha8zJqIpLxaM1ZnGSG3Xlh4PASB710WdgZU853rUB18bO0i1 jpk48ULngiIH9gWrG7Z0Fn7WM26mlwu3HmQsfI6fcywl3eLt6aO/qEIl5K6ZDVAuHAurVg JVpWWnEpXnQ14dGNC0wanswlG34MTFc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-45-51zswmumOOWhbfBaIx3Qcw-1; Tue, 03 Dec 2019 13:29:21 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2DFE0477; Tue, 3 Dec 2019 18:29:20 +0000 (UTC) Received: from rh.redhat.com (ovpn-117-10.ams2.redhat.com [10.36.117.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50A335C554; Tue, 3 Dec 2019 18:29:19 +0000 (UTC) From: Kevin Traynor To: Rasesh Mody Cc: dpdk stable Date: Tue, 3 Dec 2019 18:27:12 +0000 Message-Id: <20191203182714.17297-63-ktraynor@redhat.com> In-Reply-To: <20191203182714.17297-1-ktraynor@redhat.com> References: <20191203182714.17297-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: 51zswmumOOWhbfBaIx3Qcw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] patch 'net/qede/base: fix page index for PBL chains' has been queued to LTS release 18.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/10/19. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasi= ng (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/ca9e7fab8cbd768a94= 5ea6993c4551f63fe7f6c8 Thanks. Kevin. --- >From ca9e7fab8cbd768a945ea6993c4551f63fe7f6c8 Mon Sep 17 00:00:00 2001 From: Rasesh Mody Date: Sun, 6 Oct 2019 13:14:01 -0700 Subject: [PATCH] net/qede/base: fix page index for PBL chains [ upstream commit 766d68ac2d116f5a08de0b8667939408ce362c44 ] ecore_chain_set_prod/cons() sets the wrong page index in chains with non-power of 2 page count. Fix ecore_chain_set_prod/cons() for PBL chains with non power of 2 page count. Calculate the right page index according to current indexes. Fixes: ec94dbc57362 ("qede: add base driver") Signed-off-by: Rasesh Mody --- drivers/net/qede/base/ecore_chain.h | 84 ++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 26 deletions(-) diff --git a/drivers/net/qede/base/ecore_chain.h b/drivers/net/qede/base/ec= ore_chain.h index 6d0382d3a..c69920be5 100644 --- a/drivers/net/qede/base/ecore_chain.h +++ b/drivers/net/qede/base/ecore_chain.h @@ -87,6 +87,6 @@ struct ecore_chain { =20 =09=09union { -=09=09=09struct ecore_chain_pbl_u16=09u16; -=09=09=09struct ecore_chain_pbl_u32=09u32; +=09=09=09struct ecore_chain_pbl_u16=09pbl_u16; +=09=09=09struct ecore_chain_pbl_u32=09pbl_u32; =09=09} c; =09} pbl; @@ -406,5 +406,5 @@ static OSAL_INLINE void *ecore_chain_produce(struct eco= re_chain *p_chain) =09=09 p_chain->elem_per_page_mask) =3D=3D p_chain->next_page_mask) { =09=09=09p_prod_idx =3D &p_chain->u.chain16.prod_idx; -=09=09=09p_prod_page_idx =3D &p_chain->pbl.c.u16.prod_page_idx; +=09=09=09p_prod_page_idx =3D &p_chain->pbl.c.pbl_u16.prod_page_idx; =09=09=09ecore_chain_advance_page(p_chain, &p_chain->p_prod_elem, =09=09=09=09=09=09 p_prod_idx, p_prod_page_idx); @@ -415,5 +415,5 @@ static OSAL_INLINE void *ecore_chain_produce(struct eco= re_chain *p_chain) =09=09 p_chain->elem_per_page_mask) =3D=3D p_chain->next_page_mask) { =09=09=09p_prod_idx =3D &p_chain->u.chain32.prod_idx; -=09=09=09p_prod_page_idx =3D &p_chain->pbl.c.u32.prod_page_idx; +=09=09=09p_prod_page_idx =3D &p_chain->pbl.c.pbl_u32.prod_page_idx; =09=09=09ecore_chain_advance_page(p_chain, &p_chain->p_prod_elem, =09=09=09=09=09=09 p_prod_idx, p_prod_page_idx); @@ -480,5 +480,5 @@ static OSAL_INLINE void *ecore_chain_consume(struct eco= re_chain *p_chain) =09=09 p_chain->elem_per_page_mask) =3D=3D p_chain->next_page_mask) { =09=09=09p_cons_idx =3D &p_chain->u.chain16.cons_idx; -=09=09=09p_cons_page_idx =3D &p_chain->pbl.c.u16.cons_page_idx; +=09=09=09p_cons_page_idx =3D &p_chain->pbl.c.pbl_u16.cons_page_idx; =09=09=09ecore_chain_advance_page(p_chain, &p_chain->p_cons_elem, =09=09=09=09=09=09 p_cons_idx, p_cons_page_idx); @@ -489,5 +489,5 @@ static OSAL_INLINE void *ecore_chain_consume(struct eco= re_chain *p_chain) =09=09 p_chain->elem_per_page_mask) =3D=3D p_chain->next_page_mask) { =09=09=09p_cons_idx =3D &p_chain->u.chain32.cons_idx; -=09=09=09p_cons_page_idx =3D &p_chain->pbl.c.u32.cons_page_idx; +=09=09=09p_cons_page_idx =3D &p_chain->pbl.c.pbl_u32.cons_page_idx; =09=09=09ecore_chain_advance_page(p_chain, &p_chain->p_cons_elem, =09=09=09=09=09=09 p_cons_idx, p_cons_page_idx); @@ -533,9 +533,9 @@ static OSAL_INLINE void ecore_chain_reset(struct ecore_= chain *p_chain) =20 =09=09if (is_chain_u16(p_chain)) { -=09=09=09p_chain->pbl.c.u16.prod_page_idx =3D (u16)reset_val; -=09=09=09p_chain->pbl.c.u16.cons_page_idx =3D (u16)reset_val; +=09=09=09p_chain->pbl.c.pbl_u16.prod_page_idx =3D (u16)reset_val; +=09=09=09p_chain->pbl.c.pbl_u16.cons_page_idx =3D (u16)reset_val; =09=09} else { -=09=09=09p_chain->pbl.c.u32.prod_page_idx =3D reset_val; -=09=09=09p_chain->pbl.c.u32.cons_page_idx =3D reset_val; +=09=09=09p_chain->pbl.c.pbl_u32.prod_page_idx =3D reset_val; +=09=09=09p_chain->pbl.c.pbl_u32.cons_page_idx =3D reset_val; =09=09} =09} @@ -726,16 +726,32 @@ static OSAL_INLINE void ecore_chain_set_prod(struct e= core_chain *p_chain, { =09if (p_chain->mode =3D=3D ECORE_CHAIN_MODE_PBL) { -=09=09/* Use "prod_idx-1" since ecore_chain_produce() advances the -=09=09 * page index before the producer index when getting to -=09=09 * "next_page_mask". +=09=09u32 cur_prod, page_mask, page_cnt, page_diff; + +=09=09cur_prod =3D is_chain_u16(p_chain) ? p_chain->u.chain16.prod_idx +=09=09=09=09=09=09 : p_chain->u.chain32.prod_idx; + +=09=09/* Assume that number of elements in a page is power of 2 */ +=09=09page_mask =3D ~p_chain->elem_per_page_mask; + +=09=09/* Use "cur_prod - 1" and "prod_idx - 1" since producer index +=09=09 * reaches the first element of next page before the page index +=09=09 * is incremented. See ecore_chain_produce(). +=09=09 * Index wrap around is not a problem because the difference +=09=09 * between current and given producer indexes is always +=09=09 * positive and lower than the chain's capacity. =09=09 */ -=09=09u32 elem_idx =3D -=09=09=09(prod_idx - 1 + p_chain->capacity) % p_chain->capacity; -=09=09u32 page_idx =3D elem_idx / p_chain->elem_per_page; +=09=09page_diff =3D (((cur_prod - 1) & page_mask) - +=09=09=09 ((prod_idx - 1) & page_mask)) / +=09=09=09 p_chain->elem_per_page; =20 +=09=09page_cnt =3D ecore_chain_get_page_cnt(p_chain); =09=09if (is_chain_u16(p_chain)) -=09=09=09p_chain->pbl.c.u16.prod_page_idx =3D (u16)page_idx; +=09=09=09p_chain->pbl.c.pbl_u16.prod_page_idx =3D +=09=09=09=09(p_chain->pbl.c.pbl_u16.prod_page_idx - +=09=09=09=09 page_diff + page_cnt) % page_cnt; =09=09else -=09=09=09p_chain->pbl.c.u32.prod_page_idx =3D page_idx; +=09=09=09p_chain->pbl.c.pbl_u32.prod_page_idx =3D +=09=09=09=09(p_chain->pbl.c.pbl_u32.prod_page_idx - +=09=09=09=09 page_diff + page_cnt) % page_cnt; =09} =20 @@ -757,16 +773,32 @@ static OSAL_INLINE void ecore_chain_set_cons(struct e= core_chain *p_chain, { =09if (p_chain->mode =3D=3D ECORE_CHAIN_MODE_PBL) { -=09=09/* Use "cons_idx-1" since ecore_chain_consume() advances the -=09=09 * page index before the consumer index when getting to -=09=09 * "next_page_mask". +=09=09u32 cur_cons, page_mask, page_cnt, page_diff; + +=09=09cur_cons =3D is_chain_u16(p_chain) ? p_chain->u.chain16.cons_idx +=09=09=09=09=09=09 : p_chain->u.chain32.cons_idx; + +=09=09/* Assume that number of elements in a page is power of 2 */ +=09=09page_mask =3D ~p_chain->elem_per_page_mask; + +=09=09/* Use "cur_cons - 1" and "cons_idx - 1" since consumer index +=09=09 * reaches the first element of next page before the page index +=09=09 * is incremented. See ecore_chain_consume(). +=09=09 * Index wrap around is not a problem because the difference +=09=09 * between current and given consumer indexes is always +=09=09 * positive and lower than the chain's capacity. =09=09 */ -=09=09u32 elem_idx =3D -=09=09=09(cons_idx - 1 + p_chain->capacity) % p_chain->capacity; -=09=09u32 page_idx =3D elem_idx / p_chain->elem_per_page; +=09=09page_diff =3D (((cur_cons - 1) & page_mask) - +=09=09=09 ((cons_idx - 1) & page_mask)) / +=09=09=09 p_chain->elem_per_page; =20 +=09=09page_cnt =3D ecore_chain_get_page_cnt(p_chain); =09=09if (is_chain_u16(p_chain)) -=09=09=09p_chain->pbl.c.u16.cons_page_idx =3D (u16)page_idx; +=09=09=09p_chain->pbl.c.pbl_u16.cons_page_idx =3D +=09=09=09=09(p_chain->pbl.c.pbl_u16.cons_page_idx - +=09=09=09=09 page_diff + page_cnt) % page_cnt; =09=09else -=09=09=09p_chain->pbl.c.u32.cons_page_idx =3D page_idx; +=09=09=09p_chain->pbl.c.pbl_u32.cons_page_idx =3D +=09=09=09=09(p_chain->pbl.c.pbl_u32.cons_page_idx - +=09=09=09=09 page_diff + page_cnt) % page_cnt; =09} =20 --=20 2.21.0 --- Diff of the applied patch vs upstream commit (please double-check if non-= empty: --- --- -=092019-12-03 17:29:55.387004259 +0000 +++ 0063-net-qede-base-fix-page-index-for-PBL-chains.patch=092019-12-03 17:= 29:51.797748974 +0000 @@ -1 +1 @@ -From 766d68ac2d116f5a08de0b8667939408ce362c44 Mon Sep 17 00:00:00 2001 +From ca9e7fab8cbd768a945ea6993c4551f63fe7f6c8 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 766d68ac2d116f5a08de0b8667939408ce362c44 ] + @@ -12 +13,0 @@ -Cc: stable@dpdk.org