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 CFA9042ADA; Fri, 12 May 2023 04:07:37 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9E661406B7; Fri, 12 May 2023 04:07:37 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2132.outbound.protection.outlook.com [40.107.223.132]) by mails.dpdk.org (Postfix) with ESMTP id 4CCAF40223; Fri, 12 May 2023 04:07:36 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OkUPzz0U8EUx6Jb9bil6s7RS+AeD454727F++bFDk21Iaju4ZBUZ1n/MNj/fzFkqtl/y/hphVEAVH/bdKi5B7m6ZQeUwbr2MrZutpUjazrZTv5/4GWoOTvM3RBP2Gai1jMeZhXZWjK9QxOIs+5JKTPAUmdvQshGW9LxR7lloPNWx4o8f/Lkc0zKv98mYfubEe8ncoUnQao27rNYdC1CCE8UYhK5NN6nlCF/sN4tnNrrU8LYiWQoOcezmRoZqKBM1qDJn3skHBn/M9ELhjk/UdMdqQbT0PYdRD/In8OgufG+TXts6egHj2Rz13I1NmYSRuzHyNJPny7bcUIMDfpEEoQ== 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=FuqHdqb/VbqyKv//0lZ0qqsE9NPLg8iBlSrx5ROrTgY=; b=Zvd655bTNQ0Do2I5ndwzKwkEfkSm1GKJpWtXui53Lrw6WV/iDLIos0SP/a2rSE5pN3Nsi2sdrk7PcBPf/K6aLYLVqLjmTkfrdloB5v9i02Aq8P+IdpemuwFqFwvWSpuUG0QdPrAyJTc8Jz21o7FqQPlWVyPn90bDAsIhmjxub+7wG1zPU7KkarqDpCJrsoICRnyH7RWFU/fE3qCaaip8Oj5IJOP/+KsJk5AD5bdeIWR0cQNcbblciRHy5lz+XjNGhKF1QsgpxTTWI0R7mxhxd/oZMFacFJXfZekoyamYupAj5nn5a8j3YtTp8/cWgMDT8q6PGUHkFxiv4jTVWcWtEQ== 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=FuqHdqb/VbqyKv//0lZ0qqsE9NPLg8iBlSrx5ROrTgY=; b=hrkwEd/b1lahyCFZGxXL6w2Ogv1S7GHjdlwCoDg1xie5VgPLBM22GU2q4UarnaloH+kQrbXpfWIPKu9YGhBs3mARk03DCkkzlQDEUTcWdl3d9WNo+eZizzyeAbcaVg4UdyOuLqqrVabKvjKQ1FvrVRgLTiyUi20MOFMhCX800+U= 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 MW3PR13MB3980.namprd13.prod.outlook.com (2603:10b6:303:5c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.23; Fri, 12 May 2023 02:07:33 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ac2e:52b6:82ec:4994]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ac2e:52b6:82ec:4994%6]) with mapi id 15.20.6363.032; Fri, 12 May 2023 02:07:33 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He , stable@dpdk.org Subject: [PATCH] net/nfp: fix the Tx descriptor free logic of nfd3 Date: Fri, 12 May 2023 10:07:12 +0800 Message-Id: <20230512020712.616206-1-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR01CA0036.apcprd01.prod.exchangelabs.com (2603:1096:4:192::22) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW3PR13MB3980:EE_ X-MS-Office365-Filtering-Correlation-Id: 7165b50e-fdd0-421b-27e6-08db528da5af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IgnIKUJxktmj2JUx7DvVXpErbg40VnRRbY4VMZSgpbzMrcIYXAP7dfnI8LIXYHJNf/Eh1rIy7VXmxRILhwOxykgTTsY4YFAv7eZuCT4j1nFEnMF3JMDbNR4yj1CHpd4YC5GizQFZH2EhR1OYmWJWmDAbKttlKm7j4uzbJRFa+YKMzwItPO2ISs7nLdNdE2sPiay1q62moAP1kG2koBr8xtvhjRzWyrtEwGtOiQq9rih4jQVKDzGFMLV+GI6jt1yDrTruqMGwPfuZGq0Vna17kSNL3y+1gw/0m2TE6oxTy0mprGeLAtgW2BB42M4ZFeoORVQqwnPa+eCet6UsQj2Qsc17g8ktU7jkyl8gbDoPS98/CG9WoYLFL4C1t5DfuoZUwIRaWDCQXCWdu8G7zuiDKx6vAzj18Az1cGW1UmT4j+ewfybhmPAuZ3xn8/Nldb+UuZPDIergqRjyT7ghlOb5bZHqdOu44GGopb4CqF5y6soOE2iPh4yVO/1UhJIVyHEYCPMzCeQ42FrKYDPtXisGa77jZUDKF1i0GWNf941tProJvWfhXHpQVPyB8mcVqBco/gafoAhYEiliyI/qHGxt0U0wR7jBvNiGjFaPCcNCSaGs32QxoqWEJtIEtjYOXks8 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)(346002)(39850400004)(366004)(136003)(376002)(451199021)(478600001)(2906002)(66556008)(66476007)(66946007)(316002)(6666004)(41300700001)(4326008)(6916009)(52116002)(450100002)(8936002)(8676002)(5660300002)(44832011)(6506007)(26005)(186003)(6512007)(1076003)(2616005)(83380400001)(6486002)(38350700002)(38100700002)(86362001)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Ym0va1hReGhTdENLTHpuQkQzc2thZnJTdFdRa3lHVE1RUFZTWkJjSzJNbDdI?= =?utf-8?B?NERxN0FNRTNDUSt2NCs2UjJmQWZpQ3QrNFRJNmdDb3NNcTVVSnIwRy81Y29J?= =?utf-8?B?NDdLbHVDQjFxNjVJY1RIdHdHd29ZZ3h6SEVSalFVNTlBWlhGcnFBZW1wbXo2?= =?utf-8?B?bVZaNmQzMjZOYmM0OFVEbGlmTmZKc2E2NXd4d3BIeGF3WGtrcHZsRU9PZ0ZH?= =?utf-8?B?SEZPM20vSndJODVWbkc1T2N6ajhDZnF1ZEZzdGZ2T3VXaUhIa29ZNC9hdHRo?= =?utf-8?B?eG1UYnRoNUNHQUUvWDhPUHJaSzdGS3hsTW5EV2R5cUNKR2h6WVlZRjhXVHJu?= =?utf-8?B?YndWVTRtN2hsUEFlTWhnQVRLck05NSsyemJOS3FKTWlBS3lOM2JHa3E5cHNL?= =?utf-8?B?eGtML2xJSTZIRXhTZ3EwV3RONXBnRENod1JuY0NYTEtHUXNIRUp2SmN3dW1h?= =?utf-8?B?WWFNNVRXSU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0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 02:07:33.0512 (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: Zg13FnZ9VvkPS420BCwGSQyHoa7QXHdYzv07NmKib3dEUv44Ezy0YFU7D9kD2Jas0Dgjq2pNKRV+sxfANpXKvmc/d94wCaeT/4GAzVym61k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR13MB3980 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 --- drivers/net/nfp/nfp_rxtx.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h index 5e651518ed..e642bc970a 100644 --- a/drivers/net/nfp/nfp_rxtx.h +++ b/drivers/net/nfp/nfp_rxtx.h @@ -401,10 +401,14 @@ nfp_net_mbuf_alloc_failed(struct nfp_net_rxq *rxq) 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