From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 921D0A0352; Fri, 17 Dec 2021 10:22:23 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A7FF3411B6; Fri, 17 Dec 2021 10:21:37 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 435444114F for ; Fri, 17 Dec 2021 10:21:36 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1BH3l1x0015014 for ; Fri, 17 Dec 2021 01:21:35 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=Goj5xAoeseeAM9xu2jYxBMSoxAfGgekZIQ9y6kmtU7A=; b=CV1PBlf9IYgQ42CxHfskNbeuqGihOPkcpNjwORJx07MjxyOerQE/j6sS6VAUJWV0Xlfw c4DnQRjdb3b7BaMixPW28iqLinFMr+UCj6DqsBVyhPMTZjE2A/EMWLHW9Hy1lkw3v7rx NfLBrFXt+D0PKG7f15mB9QAVxODXp9szW7mYiGuPTkja5q1/PTX4OaGQv7CTPFc7MxnQ +LaKVtCcBRF0D2IAbqCSmeV/4Z1Rz4NWFNj+FUM+bWZWlqrOkFH+K8V94DlWEDoHm8Im TOGWczNSt++VWh0cfztexeCtWFgb++nt8aJRO35TSF6KKP/Cudhk+FyirqfJSV6JxvaH EQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3d0b372tfb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 17 Dec 2021 01:21:35 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 17 Dec 2021 01:21:33 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 17 Dec 2021 01:21:33 -0800 Received: from HY-LT1002.marvell.com (HY-LT1002.marvell.com [10.28.176.218]) by maili.marvell.com (Postfix) with ESMTP id 2D2683F70A4; Fri, 17 Dec 2021 01:21:30 -0800 (PST) From: Anoob Joseph To: Akhil Goyal , Jerin Jacob CC: Anoob Joseph , Archana Muniganti , Tejasree Kondoj , Subject: [PATCH v3 19/29] crypto/cnxk: fix inflight cnt calculation Date: Fri, 17 Dec 2021 14:50:01 +0530 Message-ID: <1639732811-1440-20-git-send-email-anoobj@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1639732811-1440-1-git-send-email-anoobj@marvell.com> References: <1639676975-1316-1-git-send-email-anoobj@marvell.com> <1639732811-1440-1-git-send-email-anoobj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: 8bPQD7Rr7p3l56XU-XXfKSuRuNzvJhKR X-Proofpoint-GUID: 8bPQD7Rr7p3l56XU-XXfKSuRuNzvJhKR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-17_03,2021-12-16_01,2021-12-02_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Inflight count calculation is updated to cover wrap around cases where head can become smaller than tail. Reported-by: Kiran Kumar K Signed-off-by: Anoob Joseph --- drivers/crypto/cnxk/cnxk_cryptodev_ops.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h index ca363bb..0336ae1 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h @@ -156,7 +156,11 @@ pending_queue_retreat(uint64_t *index, const uint64_t mask, uint64_t nb_entry) static __rte_always_inline uint64_t pending_queue_infl_cnt(uint64_t head, uint64_t tail, const uint64_t mask) { - return (head - tail) & mask; + /* + * Mask is nb_desc - 1. Add nb_desc to head and mask to account for + * cases when tail > head, which happens during wrap around. + */ + return ((head + mask + 1) - tail) & mask; } static __rte_always_inline uint64_t -- 2.7.4