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 072F242B3A; Thu, 18 May 2023 13:03:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 939F440E25; Thu, 18 May 2023 13:03:11 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2110.outbound.protection.outlook.com [40.107.237.110]) by mails.dpdk.org (Postfix) with ESMTP id 12BCB4014F; Thu, 18 May 2023 13:03:10 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ix0rUPWGFsTjvVaY3TBLTdyMtolTgrBFMt/+F3LELuitFZRGF9E+x5X0YtOYwTDSLoY9mRw4xv+g6vTsoiH4a0C1KY/Dgwv71/aXqCPwzMdCp6jYnwRbl8v2D1OHftuHej5pbC0HaVnpFZUSYlN6hrr+U7tuONMYr1HMu/5fcNHMAx5ol5U19OHdp9eqB0TI4b1yO/cbL9QCdXBKxx0dSk8y9VCwY6inhXMtN4LPX+U2reozASuEodI7ZH8p483fF4cYy/95xle2QJghIJZS3a6qVlSC8wsiH80a/HBQYlTFex2RrpqkMCf1R/SgDmZAzXEhVEgRTmDzdIcS6m2NUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=d0XiFMaIyWoVhWUL3uqR/wRBbKXG7x8uznzxiCASrOg=; b=B3FWQeLVv6lAqK17Pis9GDk6rKWjJd/Sj5tJPiFGcQbbQ3JotUjoQJyViDCTs+8Ei6Z9RLq6OLyl9Kgb+/NtJw75JVipIim3dMuIt2GchLp5xMoG4JEe5g9dIKnGPrjpQqCl/NlgsNLaOQzXmidOHlsfuqi3P+HhmgUHM71Xr4vBV4nD+jJSMHD3Y44b7pAiWQGu82hES4TvoiKXR9/DLIRjwZxVm5ysXuTsUOwzAVbwP0+lEJRc+UkHes1ilp97yxhkmg18RKisjUdyI6ikVDqGVL/6e2/nhgJtgwfRkQnt3BsyO8/uMSndXnd0SHJndr6atq7ZVpZGpC5R2+cruA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=d0XiFMaIyWoVhWUL3uqR/wRBbKXG7x8uznzxiCASrOg=; b=ISMyeLY1kGLtwgxgxfRpNYFfuA9DE94MJqj/3MwNgSt2vveQHwCxi7o5gRy3v7W+zxDank83ZNYpQIY+sf0a88jmKUBETAP/i7CjjdtxMSm9rq6iH9/R0ISX5xNi2fv5AH3jLr41i1I+hLe4QlZKeNobOa9YCHlZVL3gy17w5ws= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by LV8PR13MB6422.namprd13.prod.outlook.com (2603:10b6:408:192::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.5; Thu, 18 May 2023 11:03:07 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ac2e:52b6:82ec:4994]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ac2e:52b6:82ec:4994%3]) with mapi id 15.20.6411.017; Thu, 18 May 2023 11:03:07 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He , stable@dpdk.org Subject: [PATCH v2] net/nfp: fix the Tx descriptor free logic of nfd3 Date: Thu, 18 May 2023 19:02:47 +0800 Message-Id: <20230518110247.1559733-1-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230512020712.616206-1-chaoyong.he@corigine.com> References: <20230512020712.616206-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SJ0PR03CA0210.namprd03.prod.outlook.com (2603:10b6:a03:2ef::35) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|LV8PR13MB6422:EE_ X-MS-Office365-Filtering-Correlation-Id: e439b550-81d2-4578-8d75-08db578f7562 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t2shjMABgDyVaBukY5rPl9Xow0ve52prqgh80s/w2OJZMnGYtXKyRwGBxKaTAp3i7bSKL6OKEjAugNJqBfbsqZ1ZHSIlqDJ16MRWn09pHjcvBxALH3rhvhqFfK7mZuLdrHpzNHcnWwR0wUUegvDveZ3AClBZag/4OZ6ltx7ikAxr3oBr4+1kveJlwpFwEd3OzV3NUe4cMlAPSDNbuWhNNdPP/3n5WJSAPRF042wAltSaLfEqVtM4WG71AkwxMevN5IDel3A8Ut1Iohnr7hqMAKywaOe0XDtq+wG12SG/TYzucLd7ngFIK09XC45q5f018QA0copBAbfFWV1q3nkVuwl+H0+GOWFYtq3eZTPULU2m1uWRyONDqtEI/V7LaSv8dsLXH8aAQubUm1Z/QwvjhdkaNq93G+M9Qc2+XRuD20ijY+LmoWhVu9MVvIJWA2YowRcpz0xLF1RcIxA7SPIrXcaLMituUibiY9RTRKSwplB+mmgYuOMyWdP55SRRm8NNZMg85TOQJ847FGIBMGlAhxD6cyhwQ9dII+3WheXTxhpfx6O8Dklyl+sunm0FdNSOHYUFJD+gN26NrFN8AxZ+32mYxu+2S3/VPhZNUsgFOmsf9MUngIg5ESCyAf0O2wwDugKs5qvjtoUYJghXO4j1np3CpA/ourjWrSS4fskpTKw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(366004)(39840400004)(346002)(376002)(136003)(451199021)(66556008)(316002)(66946007)(52116002)(4326008)(66476007)(450100002)(6916009)(36756003)(478600001)(86362001)(6666004)(83380400001)(186003)(2616005)(1076003)(26005)(6512007)(6506007)(8936002)(8676002)(44832011)(2906002)(5660300002)(6486002)(38100700002)(38350700002)(41300700001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?c0VFR1FkdXpnN09TbVFsdE5HZk5Zc09iRVlRTGl2ZTRSRDBxM1JmZ0VsOUNi?= =?utf-8?B?Uys5N3JDWnFseGxDNFpmT2NZZDZSM2pxS3FNY0FUQ3lwU1NUZTl6QU4veGFO?= =?utf-8?B?d21iaUlVNFBNMVI1ZnJaZmdBdkVsMGZFWEZEREtNM29abHF1UHNLWmUrdFA5?= =?utf-8?B?Mzdkenc0ZDNxUkc2UFZUQ1o4dmt3SjZNdnFCOGo3d2dFbzdjUlZ5WEZjWEFK?= =?utf-8?B?UnZXc09rUXl3eUxLK2Y2SFZqbldqdkR3dGFQc3k4YnJrLzlaemFRRjhJWm1E?= =?utf-8?B?UVhFZjhnbVgySjVJZWc4REI0QjJRUldMalpUVWxYdXowa2VRRFR1UTJKSXpu?= =?utf-8?B?WlVMd1Fhdko0WHdMbGRyYnZieDltcFBsODYzK3gvUDJNSWExNTFxWHhLRGlE?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com X-MS-Exchange-CrossTenant-Network-Message-Id: e439b550-81d2-4578-8d75-08db578f7562 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 11:03:06.9683 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0npq36Mw9rIv0tvUMouKI0HckMWoR8GMj+9qLlsSrKw2KVpATOZ8KDGhJvgsW/GhmD9Y62/9db6onTyjVNrF/tRQqoAVzJuY2Y5e+00auXo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR13MB6422 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 In the Tx descriptor free logic of nfd3, the former logic might force cast a negative number into a very big unsigned number, and which will cause potential problem in the xmit loop. The xmit loop will continue in the place where it should break, and will overwrite the Tx descriptor which is not free to use by the PMD. Fixes: 74a640dac864 ("net/nfp: avoid modulo operations for handling ring wrapping") Cc: stable@dpdk.org Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- v2: * Rebase to the latest main branch. --- drivers/net/nfp/nfd3/nfp_nfd3.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/nfp/nfd3/nfp_nfd3.h b/drivers/net/nfp/nfd3/nfp_nfd3.h index 7bf2349904..e772bc4711 100644 --- a/drivers/net/nfp/nfd3/nfp_nfd3.h +++ b/drivers/net/nfp/nfd3/nfp_nfd3.h @@ -52,10 +52,14 @@ struct nfp_net_nfd3_tx_desc { static inline uint32_t nfp_net_nfd3_free_tx_desc(struct nfp_net_txq *txq) { + uint32_t free_desc; + if (txq->wr_p >= txq->rd_p) - return txq->tx_count - (txq->wr_p - txq->rd_p) - 8; + free_desc = txq->tx_count - (txq->wr_p - txq->rd_p); else - return txq->rd_p - txq->wr_p - 8; + free_desc = txq->rd_p - txq->wr_p; + + return (free_desc > 8) ? (free_desc - 8) : 0; } /* -- 2.39.1