From nobody Wed Nov 27 14:22:38 2024 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2077.outbound.protection.outlook.com [40.107.104.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E240CF9C0; Wed, 9 Oct 2024 09:18:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728465503; cv=fail; b=uGufEJe3LY4/U8dug3EsSuqSTAc74svkHOBIWH9MuEnXFPz/OwuZc6brZ14/+HlC1gKKDYK444wTil9mvHDIFtHtx6382KGd825/mAoHyF6t5Q9hHwA2EsOiTBr3YkCR9gwcgwQr20b23Vy0yKbhHBE4lrb25Y+bJ6qcuriBSyQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728465503; c=relaxed/simple; bh=yG6zMOIrUy1VozJLeovt3JsnwrjkIXFUHGzqiCfjNjk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=HUx+FnNdkV/hlcD3X+q7bKrcC1KlxjaJMGe7VlRGtIuvy/tt+0ksK3eVXXQ/ZdQ4NjP9r231BHUUM5XyCoYn/WSrZvbqZtNUACZ81iJqL/dajCHOohwkBClKtQ/yEF6bo26GUB0ZLGx5dSmGZAe3ls4rzEHNT5QTs+RkBlGJzM0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=GLOKp76s; arc=fail smtp.client-ip=40.107.104.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="GLOKp76s" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WR2L4dbtalr7QjazYMEEEcrFIGQx7GhOTeGanyNrR4YXmpxLU4T1Gvw95w0c/gj9PN1quuqvLPLKGbXhYeOPPfbUFx0Z5Zwrq3pR8/nzvjdy3GoQOrG5lVvFxPpuS8YF7Ks/sJ5I4f02BgAJE/BMkPs6VcBHqBMtANBmBNNFTYUqwbQdtI9CjfYcro3ZyItUi0hw4gr/DSlG7YSwH3KvS/T4ch+8G+jh6ItkkgLe2W+W7kP62Ig6FVEp5ZoKgORLFf7fc7Hwm8ZvH2Q/xjOBj6m7/OS4/1TsyhwTWeH8VHRlH+m/YKWBp6NfSe+nj8XIM3EtzApUayNU01opSHHxtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=J+UT3Aj9pXKHz1zIEj/01SoRaXU6yDqUrDa5Plb0JcE=; b=lYU9LlsMjpKfaHsE0X4jPUh9jVx82bvjmAa4BaTqcg4SpvJql8SZ8dtyZXuRK7Xav/f2EwUWL7u4UwUN0Iy4Pj4kme9HuH53FuT3xM7NCHREaYSPoOhLy0s05cT0eFdyxwBXiQoRnzMagcMiCkzgwLbSR1RtFT3fA5nuDUpjGF60Cd8qcO9nSeFtn6usNBEhSUg+dLetaLDTQ24xlsQs85j1lZpOfadu3IP3I8QhAll+X0OVNuBuBTloF9CTMF46m598w0iBAMfJLAJWYC4w61Dv8gyIiJKrR9ZVeHGLnd7yG6CmRnIKSebhCVrPr5UMqRxyWLy9OB2mv9jqtzA3aA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J+UT3Aj9pXKHz1zIEj/01SoRaXU6yDqUrDa5Plb0JcE=; b=GLOKp76sxnIWjxF2fkiEpJG+8BBlAtjQZMsZWk5WN2M5IzbtjYOBSL1lqjR7mB3qIGFoV+7hdnSDCJ78h0Nh3AXZLfeq35oM/Bor26ITULEbW4KJklTJ4VAnfKwmlwxDWp+ViL7VqeZ00SitrpBA4nOkr6Xd2O1/0rGD25FN5RifbWoCL7f3efCysFZC+HaJ897dvvwhpk11yAMp0kRfGuhCBQRsVH7TYQsn79h79ck2jrgmTtnIYBOojGS5mNIDCPs+OjzEgi4FAWv1WB/ulKGEtCBpv/gB58wdLt/TdrZl+og22DJKzvCznFuJK48jBGgrSK74yq36Q9ED4GrKhA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by PA4PR04MB9318.eurprd04.prod.outlook.com (2603:10a6:102:2a5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.22; Wed, 9 Oct 2024 09:18:20 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%7]) with mapi id 15.20.8026.019; Wed, 9 Oct 2024 09:18:20 +0000 From: Wei Fang To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, stable@vger.kernel.org, imx@lists.linux.dev, rkannoth@marvell.com, maciej.fijalkowski@intel.com, sbhatta@marvell.com Subject: [PATCH v3 net 1/3] net: enetc: remove xdp_drops statistic from enetc_xdp_drop() Date: Wed, 9 Oct 2024 17:03:25 +0800 Message-Id: <20241009090327.146461-2-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241009090327.146461-1-wei.fang@nxp.com> References: <20241009090327.146461-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SG2PR03CA0102.apcprd03.prod.outlook.com (2603:1096:4:7c::30) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|PA4PR04MB9318:EE_ X-MS-Office365-Filtering-Correlation-Id: f886636d-260a-4271-2fa3-08dce8435111 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|376014|366016|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?2e3c0uH8LfXBj9qZwFS6h4VOWIupoeIwqmPJ8QkJI1M3kyx1hdsW5hZzmT4x?= =?us-ascii?Q?V0+dE8fwAli+6XQJrqG0YPVjIFhS8shdxOHlS6F2bs6dQY/GoqQGeKIpdlK/?= =?us-ascii?Q?TFRLWJUer81sg9HGLc6pczpQB1/gQPna7YiqZ/j1CqAkm2DTIo3D5P69OrtA?= =?us-ascii?Q?rw/vqO9tHKk++3nVIVPT7lCCuRAeJtqIIZDvKwv4ZBGoYYTHmo7sqNa3pJb3?= =?us-ascii?Q?Ebrg9ITeFbRYn5i9R5gFgzaetDZgFf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ascii?Q?RuNFBEEg+aDCMm6kQGVhlR+dLzs/SW63t6wAD9L+e0CiQ/F1xYJeHemsDEcJ?= =?us-ascii?Q?D4HOhk/y1gujk/JvZ7m0KIJRpAnaoyBfb3yaerPHc9C83yVOXdK6a/lGx5Kn?= =?us-ascii?Q?VHmBuI2UF393BqGtFR5V1Xjfv/GiSlCjmFZOFOUtU+//XqpiU9YmKbYdvs5K?= =?us-ascii?Q?eHQynowyaOWRzCktUXCkSS0zyisKu81Cwjdn76sp+pWc6g=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(7416014)(376014)(366016)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?92SmKzujttIfEJlINMclSc3voUZZNJsRxEBx8vY47Qu5YXCtKYrFGC1Ul2Mt?= =?us-ascii?Q?xrTSkI8JbY86H9IQSirNcIhaWFFb9WIUorz+/Yu22udCJRrM1SooIsYHWSMV?= =?us-ascii?Q?eiNKQKNZMGtX2WBUE2KXBxpTtjTVR4rhkxT5y67HCZNR132nmsxZfs8HjpJ3?= =?us-ascii?Q?fmUCEEqEBNSt2BGuQS1lACnPxcKmphRGjQPmjeW2nIZaCtPp2xUeQM85X65e?= =?us-ascii?Q?gagBLecS/2FdAP9e4JW9cyxN79fqHUxEkiReSkyMhkIbdcX7a9qZh/bw1453?= =?us-ascii?Q?ooqxcgUd0DriP6PaSCUli6o+fBgiwSWp3ofAty/egIFrkq78mbUiXo3nKWL+?= =?us-ascii?Q?7I8PQv/zSyw2x/qQUVL/1jVreoiUqJLSkiQBNSwuBUch1N+Wh704WsTxm0mz?= =?us-ascii?Q?TgFPiEtUZ0q4oryutWMTGo226qTFzJx+PboXoEJEPo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0iohyGl0itchTnryjqjH8k/ufgNpMuL3/r4YRtllN5qy7giz8g?= =?us-ascii?Q?390YUlmjJi8b53Jy+ERnMKZNKAEHXFHV4PHtV9o7i5U6AFXaAjZID3ZWg1mM?= =?us-ascii?Q?aYmOLIDS2sJBOzIqxA5ReYRdMqc79kVctcPMFgz9Ue255ovDWjE08P4rJFTb?= =?us-ascii?Q?ndJo2n8vsWQyrf26a+8v4KLrnqv8XF0n6o1Y93kyQkgRCGcCX1B2OuM0CYZc?= =?us-ascii?Q?oFCUYr+AqZopJHXES+4sbTGBYvyAPJn7K2VOATUe?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f886636d-260a-4271-2fa3-08dce8435111 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 09:18:20.2093 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0doioPXCuSTgiKwACvYwuV62tPEboi53B2wWcwqgW20FNb/LvRH08yYuUPAXULkpF4cuviGWexJTzIHSRlGI6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9318 Content-Type: text/plain; charset="utf-8" The xdp_drops statistic indicates the number of XDP frames dropped in the Rx direction. However, enetc_xdp_drop() is also used in XDP_TX and XDP_REDIRECT actions. If frame loss occurs in these two actions, the frames loss count should not be included in xdp_drops, because there are already xdp_tx_drops and xdp_redirect_failures to count the frame loss of these two actions, so it's better to remove xdp_drops statistic from enetc_xdp_drop() and increase xdp_drops in XDP_DROP action. Fixes: 7ed2bc80074e ("net: enetc: add support for XDP_TX") Cc: stable@vger.kernel.org Signed-off-by: Wei Fang Reviewed-by: Maciej Fijalkowski Reviewed-by: Vladimir Oltean --- v2: no changes v3: no changes --- drivers/net/ethernet/freescale/enetc/enetc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/eth= ernet/freescale/enetc/enetc.c index 032d8eadd003..56e59721ec7d 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1521,7 +1521,6 @@ static void enetc_xdp_drop(struct enetc_bdr *rx_ring,= int rx_ring_first, &rx_ring->rx_swbd[rx_ring_first]); enetc_bdr_idx_inc(rx_ring, &rx_ring_first); } - rx_ring->stats.xdp_drops++; } =20 static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring, @@ -1586,6 +1585,7 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *= rx_ring, fallthrough; case XDP_DROP: enetc_xdp_drop(rx_ring, orig_i, i); + rx_ring->stats.xdp_drops++; break; case XDP_PASS: rxbd =3D orig_rxbd; --=20 2.34.1 From nobody Wed Nov 27 14:22:38 2024 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2053.outbound.protection.outlook.com [40.107.104.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A4E5F9C0; Wed, 9 Oct 2024 09:18:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728465511; cv=fail; b=CuWScyjOpm/fURNRNv0lQ9Jb8X4y+TlyfTLNvEWedney5NtkBz2Vat3ML2Tzbx85Isb2iRc8V04O3KDqN0c7JsA4YbmUgLu6Z6OYgIA4KOIiZVFci/QVRJyW0odguCnsyV/M2QX18Ap785cCT92Jqej8olMnu1h50ho1mBWr9Pk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728465511; c=relaxed/simple; bh=f3KMfoSLaFhD4UyCQcKwW1J49zjJkyBjI8Ut7puYXN4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=PJDBVlp/I73ESHEn+zS1kMGD1bwiMUtlGvuxkce1sXTO1A1W8JPt5Rgh6Zloo1lbaJ8FgjSCnu1EPg5kewGVNIQVNSbA7dUUgnCX9617lnvgs5UDWG3qnFx8fWRfVkr0st9eZW/lUcfzuiB3VrwaaD2a5nJeWV5yhN7IwEgZPWQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=M4bDe+vO; arc=fail smtp.client-ip=40.107.104.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="M4bDe+vO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w7OL0YrxX6YKBSzNZwUZhO7moFJBCXnuOrnw2sLQMZlTjb6vcGcaVfZfj95Tb5PtwTzYlmEyiXO4i83tr8fIXWe5hudBHb63K47jI8UsumsIyH0jlb6945LnzekJctOfKyHWjP/Pj0QaIOQ0n7YHSg9cah2B5GWZAlgriWU0GerGdkJUSAq8JshsaqA3tncsR3cv9hZmpWJUX1vb7IiAcC73uepbvJdnSzdk8243mhffnLjyfHfS9xxS+W8OQiBaZsKW0IAcmJ3QiK7KtV40qhfxtAKp9LszJcxeP9PFfAEutlHuTXuAT+2JLnmdyXk7prvahyK/wiUeVdG1PCu1cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=BX3E5Q42efCWu3VFFPuVSQQalVFHiWE5+TajCjjRfIY=; b=lIdNZvWDyXYhDsUaxIj8KyNjvDUqLZ+6uHUoVWuFqgHXjH0sW77p35re7oOAPUZoY4J2Vbqg7hpGj9khiSsdfW+q8pmCI0cJzMowulY5XisNu4VlLelsKyrhFW6/2y+csJ+SSGpdQ4Gzlf0kBMxN7+RSEjJ50Ftrs7ro0Gn2GUE1ezPU04r7f9BMv2+dpdQm1CThO8BpNfvLNYjbfc538w9H/1ZmZV2absUzyZpmMTwL0+FDtzTUDnLkIsvVCaseiB28CO/rj4lYN8fwYIYsmkwN4++PSK6hvhlEDyfH98NHZNIyrtq4a5BfhmgCDJi7nFfzoguUSjp9kf8zlVTnbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BX3E5Q42efCWu3VFFPuVSQQalVFHiWE5+TajCjjRfIY=; b=M4bDe+vOn2woGMyid6iRo02OZ4e4iP1n5FNYQzRGi++L9kIubiEPpbJSpCOGBcRVJOJA+lOuM4v3pluH58h//o4L0556Sb7EY+jhy1oUjrzZkUn3h7UsP0K139+toseuFJk3k8ZCBPW7mAM5tifMz26ksBVvGQe3rJUwR2+nfNingxPNpJXcLGQapdstTuMhLASS+xnxXl3dJeJu8ZomYOhONsbMczvHHHARqdvB1Siq5seYB2lpli+qacM2c/evU54oISpqdKLOoefc1Jo472rzhJn6DqB/VWZ35zWqVjXiTdoZRHIH/SUOEjxHSSumeZWxh7RXbwxeuVUAulUkrg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by PA4PR04MB9318.eurprd04.prod.outlook.com (2603:10a6:102:2a5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.22; Wed, 9 Oct 2024 09:18:25 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%7]) with mapi id 15.20.8026.019; Wed, 9 Oct 2024 09:18:25 +0000 From: Wei Fang To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, stable@vger.kernel.org, imx@lists.linux.dev, rkannoth@marvell.com, maciej.fijalkowski@intel.com, sbhatta@marvell.com Subject: [PATCH v3 net 2/3] net: enetc: fix the issues of XDP_REDIRECT feature Date: Wed, 9 Oct 2024 17:03:26 +0800 Message-Id: <20241009090327.146461-3-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241009090327.146461-1-wei.fang@nxp.com> References: <20241009090327.146461-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SG2PR03CA0102.apcprd03.prod.outlook.com (2603:1096:4:7c::30) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|PA4PR04MB9318:EE_ X-MS-Office365-Filtering-Correlation-Id: 11c8b8bb-47eb-4973-c211-08dce843543e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|376014|366016|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?fRiiZGx71IWJfEiIUrKt7bQIliJt6A62CJRGjyri2WRHzgUGdD4XkrgMmcEn?= =?us-ascii?Q?C6KiM2HA4+SSdosC9xtSpmtClAuUw0Nz41bouDEQzTxa1wxcLK5af9pRk7rD?= =?us-ascii?Q?gZiPEOnYxKRSmMp5CwHhEonaicffiWfh6FedyywTCzFO5fE+0xolqCfpQ1md?= =?us-ascii?Q?hXFGWiNpvUtmTOoBP6cpN+MXoOadBn2ZoCzarERMf5PCeHJka+5b2LmapD4w?= =?us-ascii?Q?uEuMOqK4MOFin2rwx13ReThg6D0+8FzfmMPtN73sLATqzo95Wwh9NAx18CSQ?= =?us-ascii?Q?5DcS/egPUZrJLlSFydhLLJeCtDkNMKXoAUCFgUqWAwbPmaSRze66FretmaUB?= =?us-ascii?Q?PC3PDoQk1+JgN6Cp3cVpiVv8cy0FUuYLCTIdrKILUy/lI+1tS7JgtA9Go2ax?= =?us-ascii?Q?j604EItMeEWvoJD1SGmiDKuYvK0NUjuKv5N/g6pTyCi++/cnhR/GlMriMqUT?= =?us-ascii?Q?Zq/5IdYi8ZM52Sp5BvxtTLoU7h3pR9i3RxwZu30LTPSMDojqpUGmsJjCZZOo?= =?us-ascii?Q?VYeZLBh9gjmKr0VBSlhNgI9vd56Wnwc92G6qW+MqDf+vfG2BqkhpfyrY+ndp?= =?us-ascii?Q?Bc2xs3WI4g6uDUCJ+t8us4MWtLAGzj60PvoGioxRSEJpoHFaDS4rRu5r5miQ?= =?us-ascii?Q?dF85SLBWXOh+dSsy7S5iBJftqh9Nc0rNTZZG45ib+4FLHtRiJSOiqLAEKZmr?= =?us-ascii?Q?hAL1tu2Q3f6rY0I4LTks9gF6zYdfrqVcUIlsZ0QBLFF9H4EzJSxbap6R6Wfi?= =?us-ascii?Q?fHnmb8mBXtN1K4XIadJxeIsIZRgaAy2kX4IVxJTh9Dxqr1pjUjtDLS93Oryj?= =?us-ascii?Q?3YX6CCq2yfy7F5g+BS0mfaL/OlMxAbzT8jPpgiD/F+MI72s7Qb4TOAqZPJA1?= =?us-ascii?Q?/4G9LW782yis3VJiAVb9xNsNumWaSeyr2uGneCSfxGYjGW+tm1lhfwQZukkY?= =?us-ascii?Q?hNBFKqh7zF9tim8VFh14psV+At/4iW2h1KQxMWyQwCfkEKPI4PSN4hZZqZNZ?= =?us-ascii?Q?xnvExYBUjVIh1zzCgu5DjIyJJoMOrJmbMm1LvAWaIBMaa/zO3eCmHbQab7aE?= =?us-ascii?Q?YkaLI+55KfgEHo+sRFa9NXjExx3fnKh5xwlr2WmnFWIakRBRwcPIZVXac5nS?= =?us-ascii?Q?yxjXiShLSbPggwbJZuSKkHOHZ/K3aK4HGX8AqBmDHRkv70XCIK1vR4CbUqsK?= =?us-ascii?Q?BR4ZQWXA8SR7rFPEUVf3s77TBB9vPlaUX1NJF2gG2roBSehEKRJciQv4LXy9?= =?us-ascii?Q?OKsg8/TXcAB8OSS6ukq16At423o41iyfaPM/Mjef039rZZ6mToWPL0eI+zT4?= =?us-ascii?Q?ThiphC/+QShoL9VsXZDoCa2vGLDvCf+O/5TsVvo1pF9fjg=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(7416014)(376014)(366016)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?jmKqxIOakAN1XiQOaLw6ye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?Q?9k1+YIiupJ3ZqRSUyjA0s+V5mDaZz+T2ZX8FbIzucVJP0XUXLMu89PBF72xr?= =?us-ascii?Q?KQ0yj8MplKTtjvjyn1SsGw2yDHP4bp5v4fxNTHzDI95wzYYOTLg9Aqvy+sTJ?= =?us-ascii?Q?vBHZIoIXWa6yZRCWn+jf9KI4fKPpYgTxRENCSLJV5XxsJyqZo30HGdzncIUa?= =?us-ascii?Q?Vxt2HpQKeGJwTtpR5Vm5QMSE/DN7pe5FC02J2hyY+E5qlVj6M3ti/QkXm1cT?= =?us-ascii?Q?Ff8QJI9YHRBD0K+lwUZG3U1vmcRTUcJrT4AHBkD/96uEHhAddNGEwbVQvzd5?= =?us-ascii?Q?S8Zo60ZANWrQTiWcNlfTt4ZnxoiRwqaWGfvF8K2whEolZUaXV6JE2hSsIIwi?= =?us-ascii?Q?nWl/MU8P+W0asU95hzUcJtq6lOI3n5MeYFy0nbrmO7J3ue0QzuiWgSxMIwGa?= =?us-ascii?Q?UXpp2yf/CKDQIq/8Z1datVgqT7Tmy4m1mal9r5+7UUxAwsOP+71sFqLWDR7C?= =?us-ascii?Q?uug9Zv12l6PfwVMMQ0Xx1OdWayMHd0X/AmE37S4NCLWBhuzPZLJM2h6rim/L?= =?us-ascii?Q?7b59vkcjvpNf1HifyodXmaNMfmOK4laQ4HEkB6EpMruPMycUJoYo+BuWqZ2f?= =?us-ascii?Q?9EDtdAg9fezOaJOCvmmMXHiTZH8ASblRcENBd9Y0PUBURK0ODJ9suRvSmzhy?= =?us-ascii?Q?7hHugabjKOPQAaTstsXx1pgzCTlTKi8O5orF+Je8?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11c8b8bb-47eb-4973-c211-08dce843543e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 09:18:25.6186 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SA1RDrEk3tcFFnI9r1usGFJffXqZ6MyczCZzMJwX8Sv4DxNVguJ8wwWPF1Jcn5fqIzP3OkU0BD/22aPcgXqkTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9318 Content-Type: text/plain; charset="utf-8" When testing the XDP_REDIRECT function on the LS1028A platform, we found a very reproducible issue that the Tx frames can no longer be sent out even if XDP_REDIRECT is turned off. Specifically, if there is a lot of traffic on Rx direction, when XDP_REDIRECT is turned on, the console may display some warnings like "timeout for tx ring #6 clear", and all redirected frames will be dropped, the detaild log is as follows. root@ls1028ardb:~# ./xdp-bench redirect eno0 eno2 Redirecting from eno0 (ifindex 3; driver fsl_enetc) to eno2 (ifindex 4; dri= ver fsl_enetc) [203.849809] fsl_enetc 0000:00:00.2 eno2: timeout for tx ring #5 clear [204.006051] fsl_enetc 0000:00:00.2 eno2: timeout for tx ring #6 clear [204.161944] fsl_enetc 0000:00:00.2 eno2: timeout for tx ring #7 clear eno0->eno2 1420505 rx/s 1420590 err,drop/s 0 xmit/s xmit eno0->eno2 0 xmit/s 1420590 drop/s 0 drv_err/s 15.71 = bulk-avg eno0->eno2 1420484 rx/s 1420485 err,drop/s 0 xmit/s xmit eno0->eno2 0 xmit/s 1420485 drop/s 0 drv_err/s 15.71 = bulk-avg By analyzing the XDP_REDIRECT implementation of enetc driver, we found two problems. First, enetc driver will reconfigure Tx and Rx BD rings when a bpf program is installed or uninstalled, but there is no mechanisms to block the redirected frames when enetc driver reconfigures BD rings. So introduce ENETC_TX_DOWN flag to prevent the redirected frames to be attached to Tx BD rings. This is not only used to block XDP_REDIRECT frames, but also to block XDP_TX frames. Second, Tx BD rings are disabled first in enetc_stop() and then wait for empty. This operation is not safe while the Tx BD ring is actively transmitting frames, and will cause the ring to not be empty and hardware exception. As described in the block guide of LS1028A NETC, software should only disable an active ring after all pending ring entries have been consumed (i.e. when PI =3D CI). Disabling a transmit ring that is actively processing BDs risks a HW-SW race hazard whereby a hardware resource becomes assigned to work on one or more ring entries only to have those entries be removed due to the ring becoming disabled. So the correct behavior is that the software stops putting frames on the Tx BD rings (this is what ENETC_TX_DOWN does), then waits for the Tx BD rings to be empty, and finally disables the Tx BD rings. Fixes: c33bfaf91c4c ("net: enetc: set up XDP program under enetc_reconfigur= e()") Cc: stable@vger.kernel.org Signed-off-by: Wei Fang --- v2 changes: Remove a blank line from the end of enetc_disable_tx_bdrs(). v3 changes: Block the XDP_TX frames when ENETC_TX_DOWN flag is set. --- drivers/net/ethernet/freescale/enetc/enetc.c | 50 ++++++++++++++++---- drivers/net/ethernet/freescale/enetc/enetc.h | 1 + 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/eth= ernet/freescale/enetc/enetc.c index 56e59721ec7d..52da10f62430 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -902,6 +902,7 @@ static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ri= ng, int napi_budget) =20 if (unlikely(tx_frm_cnt && netif_carrier_ok(ndev) && __netif_subqueue_stopped(ndev, tx_ring->index) && + !test_bit(ENETC_TX_DOWN, &priv->flags) && (enetc_bd_unused(tx_ring) >=3D ENETC_TXBDS_MAX_NEEDED))) { netif_wake_subqueue(ndev, tx_ring->index); } @@ -1377,6 +1378,9 @@ int enetc_xdp_xmit(struct net_device *ndev, int num_f= rames, int xdp_tx_bd_cnt, i, k; int xdp_tx_frm_cnt =3D 0; =20 + if (unlikely(test_bit(ENETC_TX_DOWN, &priv->flags))) + return -ENETDOWN; + enetc_lock_mdio(); =20 tx_ring =3D priv->xdp_tx_ring[smp_processor_id()]; @@ -1602,6 +1606,12 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr = *rx_ring, break; case XDP_TX: tx_ring =3D priv->xdp_tx_ring[rx_ring->index]; + if (unlikely(test_bit(ENETC_TX_DOWN, &priv->flags))) { + enetc_xdp_drop(rx_ring, orig_i, i); + tx_ring->stats.xdp_tx_drops++; + break; + } + xdp_tx_bd_cnt =3D enetc_rx_swbd_to_xdp_tx_swbd(xdp_tx_arr, rx_ring, orig_i, i); @@ -2223,18 +2233,24 @@ static void enetc_enable_rxbdr(struct enetc_hw *hw,= struct enetc_bdr *rx_ring) enetc_rxbdr_wr(hw, idx, ENETC_RBMR, rbmr); } =20 -static void enetc_enable_bdrs(struct enetc_ndev_priv *priv) +static void enetc_enable_rx_bdrs(struct enetc_ndev_priv *priv) { struct enetc_hw *hw =3D &priv->si->hw; int i; =20 - for (i =3D 0; i < priv->num_tx_rings; i++) - enetc_enable_txbdr(hw, priv->tx_ring[i]); - for (i =3D 0; i < priv->num_rx_rings; i++) enetc_enable_rxbdr(hw, priv->rx_ring[i]); } =20 +static void enetc_enable_tx_bdrs(struct enetc_ndev_priv *priv) +{ + struct enetc_hw *hw =3D &priv->si->hw; + int i; + + for (i =3D 0; i < priv->num_tx_rings; i++) + enetc_enable_txbdr(hw, priv->tx_ring[i]); +} + static void enetc_disable_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_= ring) { int idx =3D rx_ring->index; @@ -2251,18 +2267,24 @@ static void enetc_disable_txbdr(struct enetc_hw *hw= , struct enetc_bdr *rx_ring) enetc_txbdr_wr(hw, idx, ENETC_TBMR, 0); } =20 -static void enetc_disable_bdrs(struct enetc_ndev_priv *priv) +static void enetc_disable_rx_bdrs(struct enetc_ndev_priv *priv) { struct enetc_hw *hw =3D &priv->si->hw; int i; =20 - for (i =3D 0; i < priv->num_tx_rings; i++) - enetc_disable_txbdr(hw, priv->tx_ring[i]); - for (i =3D 0; i < priv->num_rx_rings; i++) enetc_disable_rxbdr(hw, priv->rx_ring[i]); } =20 +static void enetc_disable_tx_bdrs(struct enetc_ndev_priv *priv) +{ + struct enetc_hw *hw =3D &priv->si->hw; + int i; + + for (i =3D 0; i < priv->num_tx_rings; i++) + enetc_disable_txbdr(hw, priv->tx_ring[i]); +} + static void enetc_wait_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_rin= g) { int delay =3D 8, timeout =3D 100; @@ -2452,6 +2474,8 @@ void enetc_start(struct net_device *ndev) =20 enetc_setup_interrupts(priv); =20 + enetc_enable_tx_bdrs(priv); + for (i =3D 0; i < priv->bdr_int_num; i++) { int irq =3D pci_irq_vector(priv->si->pdev, ENETC_BDR_INT_BASE_IDX + i); @@ -2460,9 +2484,11 @@ void enetc_start(struct net_device *ndev) enable_irq(irq); } =20 - enetc_enable_bdrs(priv); + enetc_enable_rx_bdrs(priv); =20 netif_tx_start_all_queues(ndev); + + clear_bit(ENETC_TX_DOWN, &priv->flags); } EXPORT_SYMBOL_GPL(enetc_start); =20 @@ -2520,9 +2546,11 @@ void enetc_stop(struct net_device *ndev) struct enetc_ndev_priv *priv =3D netdev_priv(ndev); int i; =20 + set_bit(ENETC_TX_DOWN, &priv->flags); + netif_tx_stop_all_queues(ndev); =20 - enetc_disable_bdrs(priv); + enetc_disable_rx_bdrs(priv); =20 for (i =3D 0; i < priv->bdr_int_num; i++) { int irq =3D pci_irq_vector(priv->si->pdev, @@ -2535,6 +2563,8 @@ void enetc_stop(struct net_device *ndev) =20 enetc_wait_bdrs(priv); =20 + enetc_disable_tx_bdrs(priv); + enetc_clear_interrupts(priv); } EXPORT_SYMBOL_GPL(enetc_stop); diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/eth= ernet/freescale/enetc/enetc.h index 97524dfa234c..fb7d98d57783 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -325,6 +325,7 @@ enum enetc_active_offloads { =20 enum enetc_flags_bit { ENETC_TX_ONESTEP_TSTAMP_IN_PROGRESS =3D 0, + ENETC_TX_DOWN, }; =20 /* interrupt coalescing modes */ --=20 2.34.1 From nobody Wed Nov 27 14:22:38 2024 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2063.outbound.protection.outlook.com [40.107.104.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5777E18FC91; Wed, 9 Oct 2024 09:18:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728465516; cv=fail; b=QkzdDsS2V+sGhH3653h/L5rx4dVU+5l82ReVIyNU81OxQOKgcDy3C4hEX/cAC5EIJzTnZtM614lF44KOjrB17/dFhiA278v1hxZljVR9cnp4hzXw5olrN8ID01zDqX3CEch0BigkFKNcgWi5XPBZdUXcpTQln+pXLHaAMi61sds= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728465516; c=relaxed/simple; bh=yBeuD0Iqg/ituMtcfzKkx7tyWqjGcMvm58NKUCp8v1M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=koUcJBTJ9dtuHE2tU7o0cwAPVvkxvRKr6yA25p+R7XmJTi2M5ifwqOQAAjK9/AiAWqgUTwxt6HBOooGp5mXRRRbXohhOTy6Z1MhOpPx9cfq6r941zZ8leitePzYJo9r8dVIj6xbKqKa35uGGY7nszfNO0su76oqJa/cqqHJOR3Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=dklhFZ90; arc=fail smtp.client-ip=40.107.104.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="dklhFZ90" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x9RSVpJfc69u16ceGOi0+H/Rs+gDyPHlBpTCqp37WZa6NXxp4k9R1eFWPrnpfV9rYT9ALXq8LoDm1U7CCnplR2Ay72U4ChChnAKu9U3ei8o7BmYh02NVxmPVfIhMgkIa/hFh/gWKog80mZCLQSf2NnwKB8vtQFRzo4p1yv4q/kgNR2mXO5nZXeHoetUYvb3TBwjxgbk07hejhniYcJkiSOq0x8Cs1DowZE1S2g+e9dHHJmXeklbFY7nluQ3WKiN8iO8m7bvesQYMQWJpYWHadJTlbRHcSUJaHF1T1UD3jig0vKVjgkqvo6vbSprynyeKre3c7uVmefIVxXXjKYO8Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=93Q6bC+rUmekL98GbSB+NnAyTzySjcS7PYhJolkQX8Q=; b=ucIpN4j/xY94g9e3CkCamfKHGJS21ZPOkTnv6sJyjDzpB+nNC1GCuEVcV73j8VRH/uNTNK1STWvG3TOeqYaJHotWvLp2wrGP5tTbuoEcmj4GQjlKvfFr08Q0jKhylDCMh5Mw5yTA0MPEjup6op4ztdX9o2R7Mw6Ry8zAzKK990uNk7Yw6AMdiVUYNgHdNY6zZH3QL9JbkR1nubrSLwucFCbQ99Z8tXqPiVdheab7W7lY/W2V/kIUa4BwB57BQWVPPC71AH6ylWiuNZ8q4Jjg4Y9mQHV5ESkofxQvKSDzDzweUlquE869ArRJgtZ/vh32aE9niESyjIK9sr+yxhS9JA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=93Q6bC+rUmekL98GbSB+NnAyTzySjcS7PYhJolkQX8Q=; b=dklhFZ902HMWbqYNO8TkNW6+2A/pVg3IynXBPcCYoFYYC4671x3e69JpbSWXtrlReuMkcHJ4UApGLST3+Ov2XqVKQhk7S47LstwlXHc82tKF6LYb2aubFcGPG9u7FSDe/CQwivqRGDnNPARhcI6Zci8UR1TpckEXPRXOocnvxoDZ6P4n4OYW8Lk574GU0LqrtmRpCXiqlGByRjR7PDZQColClGlJ9YNfQUg+fZIVsI8oBqQOe1H/g5Ga19eZcp54lWPxzJGOPThEA3sfq+yz1vTvQaBDP8B9bcrNL3TW2l6RUhApE+X/2a/TYiuHR07LSwHfnczpIzXRBMDL56DYhg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by PA4PR04MB9318.eurprd04.prod.outlook.com (2603:10a6:102:2a5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.22; Wed, 9 Oct 2024 09:18:31 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%7]) with mapi id 15.20.8026.019; Wed, 9 Oct 2024 09:18:30 +0000 From: Wei Fang To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, stable@vger.kernel.org, imx@lists.linux.dev, rkannoth@marvell.com, maciej.fijalkowski@intel.com, sbhatta@marvell.com Subject: [PATCH v3 net 3/3] net: enetc: disable IRQ after Rx and Tx BD rings are disabled Date: Wed, 9 Oct 2024 17:03:27 +0800 Message-Id: <20241009090327.146461-4-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241009090327.146461-1-wei.fang@nxp.com> References: <20241009090327.146461-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SG2PR03CA0102.apcprd03.prod.outlook.com (2603:1096:4:7c::30) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|PA4PR04MB9318:EE_ X-MS-Office365-Filtering-Correlation-Id: fea24d23-c278-47af-1d52-08dce843576d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|376014|366016|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?d0v4nv8lblXXGpul9clLYdvZpX84FmuwLFGyAkhl/vw9m7arSznJLLJO7KeR?= =?us-ascii?Q?lVae7v3HcKK2zXhsaSWaRoIGZWwyep76nTkruxqbKG3bW5XNOSXoxt9ZuJ9S?= =?us-ascii?Q?cpxNLBE5ddJbEMo4cli0quHQmn39xxsUwGJlJ1DpFzPPZ+LKYnrJyq5dRKWR?= =?us-ascii?Q?3t1e4nPlRxzJY2SPr1rHe8byEbsfUBn1qY5hTLutbVLTFmmJQsqASTUoin+l?= =?us-ascii?Q?MVzCYEkmEDUSozEe1DxxS4KN/DtTAEXXzHE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E6xX9SWwvEAranVBUjsAvpM+plmjB4kxwnc1SNmKOG?= =?us-ascii?Q?wYwulyF5n3qkF/DiAJbBNUMjPolzUSG0EV5H1ILobcj2oKTNXHWDVT7WS5TG?= =?us-ascii?Q?wD+y52mrE2qbNWY0EoFB3zddiHPPZmb7aZZ7DeHnX1iUMWwXiKh8We6u81Fk?= =?us-ascii?Q?cxn8nbYJUP2ttkOAHXobS4X7svNhc359wZ/CYNCRqyDhXA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(7416014)(376014)(366016)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?VBXhDp1f6ifk6WcyiqiAYsvARP/g+P8yLklBXiwSEKAuqkkA0LUkxrWKHwBy?= =?us-ascii?Q?HQBR33h/4O/5NAhxrJ3mlMVv5SMrGBkLgCFSXoFuJmU/8kfsubhh9ocKAg58?= =?us-ascii?Q?rzmH2yRVtcVbZ9Auo9/m1wfn8M+Db8vGKCgOGUw0AA4Qm0zBrksGzIugexe9?= =?us-ascii?Q?SS/rrPHv8gvzXp3pkW0aA0AZLtKJ2hlAUKSmi2lcPG2czLhMsxJkiBF4Akhl?= =?us-ascii?Q?kdyYjsUJDAKuZteuZhuHAI37MpfRzmLmwKdCfD5QNZnZfsLyrint/iR9cV7H?= =?us-ascii?Q?2hyHpb8zye7j0GZcPN5JstWlMguPnuKKOQMuevOXjnwVmdGMnWOHBq0jRLlj?= =?us-ascii?Q?vtxvHeohY50jsM/kfvyUV0CtbbyD/UYrDLptzJUOdp0FFE5datrglpSAQzfW?= =?us-ascii?Q?9nTlOnslsspj20h6xIeoKQe3RBY+MvUQ9r8duIzBvaX9CowWsuvm7k/26ySz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W8K6kz5X4t7b7JlrATjF9H?= =?us-ascii?Q?tUKVbOMfe3RbH69SKfuMdtV/MMQjdffhyoBQLwIKOFZZ34CCvoz7EAKCVWi/?= =?us-ascii?Q?2VmKVis97it+GKciM2YVYdPfjgNuGsdiytOxSwl9v++BCq4cQHYZX9JvmbV7?= =?us-ascii?Q?eclZ0QzzLIg6tRFOWbx15GF7SGDEOxu4wilDkNyP4pciTMwRjpDsF9qziu4n?= =?us-ascii?Q?dp0j41N95yVS2Ied0Ssf2Xgk5C32GTTdwnq6mAN7?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fea24d23-c278-47af-1d52-08dce843576d X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 09:18:30.9016 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZqBjDihGJ9VDb1ecQR89KBwQ+xEXUIADS3le0w3reSfWhw8VqAqrjmjlOb4894oAO/wK0e9Z2SKXhi+2chAKwA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9318 Content-Type: text/plain; charset="utf-8" When running "xdp-bench tx eno0" to test the XDP_TX feature of ENETC on LS1028A, it was found that if the command was re-run multiple times, Rx could not receive the frames, and the result of xdo-bench showed that the rx rate was 0. root@ls1028ardb:~# ./xdp-bench tx eno0 Hairpinning (XDP_TX) packets on eno0 (ifindex 3; driver fsl_enetc) Summary 2046 rx/s 0 err,drop/s Summary 0 rx/s 0 err,drop/s Summary 0 rx/s 0 err,drop/s Summary 0 rx/s 0 err,drop/s By observing the Rx PIR and CIR registers, we found that CIR is always equal to 0x7FF and PIR is always 0x7FE, which means that the Rx ring is full and can no longer accommodate other Rx frames. Therefore, we can conclude that the problem is caused by the Rx BD ring not being cleaned up. Further analysis of the code revealed that the Rx BD ring will only be cleaned if the "cleaned_cnt > xdp_tx_in_flight" condition is met. Therefore, some debug logs were added to the driver and the current values of cleaned_cnt and xdp_tx_in_flight were printed when the Rx BD ring was full. The logs are as follows. [ 178.762419] [XDP TX] >> cleaned_cnt:1728, xdp_tx_in_flight:2140 [ 178.771387] [XDP TX] >> cleaned_cnt:1941, xdp_tx_in_flight:2110 [ 178.776058] [XDP TX] >> cleaned_cnt:1792, xdp_tx_in_flight:2110 From the results, we can see that the max value of xdp_tx_in_flight has reached 2140. However, the size of the Rx BD ring is only 2048. This is incredible, so we checked the code again and found that xdp_tx_in_flight did not drop to 0 when the bpf program was uninstalled and it was not reset when the bfp program was installed again. The root cause is that the IRQ is disabled too early in enetc_stop(), resulting in enetc_recycle_xdp_tx_buff() not being called, therefore, xdp_tx_in_flight is not cleared. Fixes: ff58fda09096 ("net: enetc: prioritize ability to go down over packet= processing") Cc: stable@vger.kernel.org Signed-off-by: Wei Fang --- v2 changes: 1. Modify the titile and rephrase the commit meesage. 2. Use the new solution as described in the title v3 changes: no changes. --- drivers/net/ethernet/freescale/enetc/enetc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/eth= ernet/freescale/enetc/enetc.c index 52da10f62430..c09370eab319 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -2474,8 +2474,6 @@ void enetc_start(struct net_device *ndev) =20 enetc_setup_interrupts(priv); =20 - enetc_enable_tx_bdrs(priv); - for (i =3D 0; i < priv->bdr_int_num; i++) { int irq =3D pci_irq_vector(priv->si->pdev, ENETC_BDR_INT_BASE_IDX + i); @@ -2484,6 +2482,8 @@ void enetc_start(struct net_device *ndev) enable_irq(irq); } =20 + enetc_enable_tx_bdrs(priv); + enetc_enable_rx_bdrs(priv); =20 netif_tx_start_all_queues(ndev); @@ -2552,6 +2552,10 @@ void enetc_stop(struct net_device *ndev) =20 enetc_disable_rx_bdrs(priv); =20 + enetc_wait_bdrs(priv); + + enetc_disable_tx_bdrs(priv); + for (i =3D 0; i < priv->bdr_int_num; i++) { int irq =3D pci_irq_vector(priv->si->pdev, ENETC_BDR_INT_BASE_IDX + i); @@ -2561,10 +2565,6 @@ void enetc_stop(struct net_device *ndev) napi_disable(&priv->int_vector[i]->napi); } =20 - enetc_wait_bdrs(priv); - - enetc_disable_tx_bdrs(priv); - enetc_clear_interrupts(priv); } EXPORT_SYMBOL_GPL(enetc_stop); --=20 2.34.1