From nobody Wed Nov 27 12:58:28 2024 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2054.outbound.protection.outlook.com [40.107.22.54]) (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 5B16B1BCA07; Thu, 10 Oct 2024 09:35:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552946; cv=fail; b=aNDNwKDKS1o2uGH6UOylxQEPVa+0oCZo8hmD1zs+OLITOg4Gizym1lfdswW/Ce9ceTOf5mKNPE3xKVz2d/Qhw3tTl6FY6+LWMl54Kp9bS9nHP23cxm1p1hQjIdSaEq8YUXJllhqSCXl97GklAYYoWJPDZQBw1LaZOhhc8h7Cbso= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552946; c=relaxed/simple; bh=BNp1PPLf7Itya7K86iPb9MexCuPDtFACR9SLTG5S7Nc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=JzoRL9rKASDGcD6xvAdbMDrVJZHc5nD9IaLFp9Gv6dRpQBCdXQ7MntVQQIgP/t/YaIXPfv98wo7BgVWOSLySGahopni+i/rS7U50+ukrDJn2urS7o54SrgyAvJXCFmqzPKBBfG/TB+ol1g5jUGl+RSrsxQI87pc8gnHppcq2Je8= 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=YB6Z8Wpz; arc=fail smtp.client-ip=40.107.22.54 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="YB6Z8Wpz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zSAjQSKb2LCd7YGCjxKNA1eE81LCbk645o3uxF0PmwV3JlADUTU/B5uKV5c/vNm/os0QC3ESmR4mr1Lla8NAb85YdjUq3oblb5hDRco6joiYXlALHkhgK/vLOoKq7GZ9i4qK29eftE6Vj6V2dto6mP5oYyAS5n6mHKVL+q8+tJg4ZU/IDJb1mZQHLRspsrVgsQc2+k6TzkCkVFCAS9TKl5TmOlJ1+ZGJdI1sLkUrP0v2FQa8ZB+emDThxiXR3tgFOhIGgywMyI0dDbDJeqv6P2r+e1JEVEPUFqXwuZumxH1CL17BJvZn1+JcPvxRy4hQtoBzbuGNO2uWY+Ms40m4Bw== 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=KbgL4c98ZuZs8xDtLLH0rxBccZgVRUIlsAB8EEj4Ibg=; b=Guc091hOgUJVbmvFhIIVwLTWWMCtIu5VcXo4o7N43YtV23V7Wvhh6/oicn22HQMi9W0qCkyrktYkpVA1Ey0C5zUAuwFuEgWvDUkuyBAbZDXUG6SDTyR+CoqykDbMJgJGJoKOVA4jo2kbYgUEvWOVlisjU8mnDY/P2FhA64vH4WMefzOCjYuv/vqwx7Jv2ovpZt+FWlGAIzM5fK9i/cx9tgbn1W4NkX1GZKbpIMuu+ymc4YK0e5TigPZagm6qfjmsR/J5Qp3j3H6BtzfkWHEHxiw1aNhyGZ4fgYlmOPlyFdcLHTuRwNWFAXxXreTwF437Sa5V3cqxvO9bxiKzI4SYig== 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=KbgL4c98ZuZs8xDtLLH0rxBccZgVRUIlsAB8EEj4Ibg=; b=YB6Z8WpzjR9qDMMhyVGZU5KBH6vUR9frIrWyZ6Lzfw/15WsNmegkWEHwJZHl67cFreY3FzBRJT0xJzKKN2iH0YX8vfg+/G/FaB5TDfkBgy7/6AcTfPczyRzbzfEySyfRlnovirQ8lV7UxWKNiB9s+jTGSe+zjQW7skITsdfOIHW/CjgP19Sodr3sck2FHEYsZMJW/spOXooUxDuE5GcdQ8Tn0MYlr+npNL0KeIlzrc1R6esI4ke9RchizvzF6Dqlkb201yTnnRNZQ7W6NVzfAOKXsJhf4zZ1bQO8deLYn2yJjSzaLuChqBA3qj74IbvdNHlNyHuxrZym45WPF5s0eA== 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 VI1PR04MB6847.eurprd04.prod.outlook.com (2603:10a6:803:134::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Thu, 10 Oct 2024 09:35:37 +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; Thu, 10 Oct 2024 09:35:37 +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 v4 net 1/4] net: enetc: remove xdp_drops statistic from enetc_xdp_drop() Date: Thu, 10 Oct 2024 17:20:53 +0800 Message-Id: <20241010092056.298128-2-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010092056.298128-1-wei.fang@nxp.com> References: <20241010092056.298128-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0002.apcprd01.prod.exchangelabs.com (2603:1096:4:191::21) 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_|VI1PR04MB6847:EE_ X-MS-Office365-Filtering-Correlation-Id: e0eac67c-5eee-4530-1efb-08dce90ee4df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|366016|7416014|376014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?+XZdq71yckMDv6ymBXth1L3eMBqjY+lyvoQTuidjWBhzUSUSb1t6tWvxljxl?= =?us-ascii?Q?G2B3nrO+bSmJy3Fsq3AmkpXRc7NnHOKpKQdIY85ND1H2rkEEAXKi9kvDPAZQ?= =?us-ascii?Q?mhz7NeDK4Z8mehJ3mOAXxfaZQl1uf2x8IIqvSJaix1ia0w9YGdv3xqWfwoEx?= =?us-ascii?Q?d4tt8wAbt0CXfCxiRoGHPeaiZxWD3YxDkC8KW+hvAjfTfSIEmQHNFlb/gjIx?= =?us-ascii?Q?7b/3ZOIzibLd+zrstWw7Ht/6cA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?Q?oXteDcqd3nn5HsSL/RyDoEPdb7IAaLDh8v0+0jW+HGU1D1WTwVqwtCAqDt44?= =?us-ascii?Q?CoRGqxS+G0G4Od4d+2UPQU56RBb3M780nLIrp/agJkriIMl2n440nuJak7gv?= =?us-ascii?Q?73FJ+Ul/AzdUhIf7boE4vsAMwck2kzgNj+l/GJ3mJQ2Ey3tasK1ktqp2pCQs?= =?us-ascii?Q?m7cwrSOonJlHQ84ymFjK6+15RCrhJCtLd6SOKcR0NyqpXg=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)(1800799024)(52116014)(366016)(7416014)(376014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?wxXQo3kBsx2+d87WxDs8JUUyl5tkxLZXrYsTqZ7VM2JqxLgaQOFan7FPTAXD?= =?us-ascii?Q?vFTnjzbkgqgpRzDXORtkf9MLaAd7aTPnMby1viQ+IxBUyJI8leQBIn0jQTP9?= =?us-ascii?Q?OE5QX2Yp7LQ1Kk2PihZelAhUJ11hgICeaV2afkkpxW+W9CXH/NYb2C3H0YS5?= =?us-ascii?Q?cxlW6zN05zXUhuaoIj6LO6+zcO2uYhdttnYHMHaHNFhCtZn37lYTzePKaRph?= =?us-ascii?Q?6M/6D7yaMWo1nKn4Z96VC7O7y4nNHkzT3AnWkTKRq+JgGCgzFDE5SAKh22tr?= =?us-ascii?Q?auhzj3/VzZ9IbiK34kQGVm36VVlW6b/MVLGnLLtJnbuVW5vctVfrf9x0cBpd?= =?us-ascii?Q?kAO0cSUyqyeHLfScKMnU2RwWytS9xnMLeXDW6GIbNYsiHFWZcQciXYMH49CO?= =?us-ascii?Q?JqsaEONSza8AwndhRllgbhsFdLa4/RiI+5pG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q?xVDlMX10URvU2JnMZveC06UIVmg2sKsuPI6R26q5Kcioypdoa6g/JFov6uts?= =?us-ascii?Q?VRrQ9lw+tZ2R2yeV5p/wN3QOOLAMpV4o+FVDFe7MW9lkSW2AXcs04cKEZSri?= =?us-ascii?Q?Hmmt17r4VIrJ1dGzOalzuxmOaK3SDRhSj/zP1beszH8xQueXM4j/0qFU+7ko?= =?us-ascii?Q?+KkH/6vs3DqB93wZG3l5qDzllQ052r0PwrfrH9aoK8bjSxBoerwvRiSXxRR4?= =?us-ascii?Q?ToH2+qYwLwFQ/f7urceDJNv4ab5kkGcBaDw5B4fS?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0eac67c-5eee-4530-1efb-08dce90ee4df X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 09:35:36.0940 (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: SrVtQwpwgdYoMdzBcKQ6RXTFCGpiKjP9NiUZFtHGMVs8KvwO6MvVYShjZM26Hpw+XiMW8iNMt86qMwmqa+j8XQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6847 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 v4: 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 12:58:28 2024 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2054.outbound.protection.outlook.com [40.107.22.54]) (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 91F731BD516; Thu, 10 Oct 2024 09:35:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552948; cv=fail; b=GGmQTu7stOtETtDyDeP0Kn1KvC1xWtJ74sNfuQKVZSWvmF7mmaxIhQX9ZFU2bqJ74tPiMyxQRB72fPPpeVbSwsFt+rj15Q5d1sdGM9uduMGnoUtNBEerhwqlJmdtnKPVUTuGKa8a9vxJy0ZEnd6Ok+VyF5+i292M8D6KWv3Dwic= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552948; c=relaxed/simple; bh=94lZlI+yAUW8VqjbiR3ZlZhdLmdrLfQON7QWRZP+lQ0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=hMqKxPwRnMDZVqH3r1GQUxzXoy26r1dn5gTETyX4fQ+LH+0B+CMNULXSngprKYdoeQTq7cxTgL8PAZx0k9DCWxD5foLe9C4WdD+KqOEnlxemhbL0HSreHUeZqhY1apGhbN8Y6Id38SvxxxPx3FD4I1LXCg8bFbYBIy9vFR7++h8= 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=h2G0MLFp; arc=fail smtp.client-ip=40.107.22.54 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="h2G0MLFp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LtvWNa3XRYqRxBSl9cZsvpbeyPXwVuk/hsnCrN4q5jJkWJXRYtTktuUchorq+VqFfHhap5tobPjGkTjXSDNgyXtailX5BVf61q4dxCE0migHMkz0HH4gt5i7HVUMdeCjY05VHSPA7wGiYR7b+aM5gRo15CJVOxp+iB0hlb1S/1GDDpKCKWU02RzOV8dWX3qTD45XUopWJlv3c+4ghj7qvWi9ScV6QlkJY2cNGLv05dzqgwJ6WVPzoKliRG1RWSWmQWEfFGnvukGhIMwFOoC/sttnRwh1fBYPFH9EzIOvaW3DUfgRkpWpiJ8eTG58jNDvSlRuJdqbYUvx/fLtyjir2Q== 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=iEqTK5LVLzSagk7VtJOHN1FFsPC8NVFjO9XD78ydW/o=; b=x5ZafsTNniN8eQisLB7Ug/uH5LSJm+7tKvRQcgHftFuryoUeNlRYR7L9fliXaQtamCPKqp/i/U2N2Kr9aHPioiFI1loJGEz/fmp2euF+j/tCFeVkW1LeZSCsfvIoKZdsYe8R6InYUvLbMTtXDhGZS1MFXmC4Sm1WMswzpwq8knwcHHgsNWpNnUMOPNSNILwuzSsvaCH+jAd6LhZWqMyO74iXG36PFYL/ESdYt3nBMnd8zUCOWYfCepyRcByczhkDhoKGRCY9ZHJNYOGYJb09dyUe1lyWEYWz1rIn6oJnEOn61gwuFzEt2lylD/loBnEvmMEWx5oK98+artgVVhjwsQ== 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=iEqTK5LVLzSagk7VtJOHN1FFsPC8NVFjO9XD78ydW/o=; b=h2G0MLFps3l/GpXBXG8OksAUuTeKwdLcxM9tcp82BRL/VGsj/Jjm6s+GvaUesiyikjDUNAz5VGD0wuq42C3bgyqtAtbb1FaBkr9ew38IdGtB4MjfJXDFQqB3jAyF3MAoceLXGEf2uMMiNXZa+G8pcmAwW4w6y/ghaDUTuhAi0w04SOO9+aZAjwMN0dQO2y6nb8zRtTOzEW2TAt6RwZAtS9lZ2TaCH5iX0m3RXQV1MRpGFNZOJQ5MudyZXMNlcSA8UFmASjwUdulom5GUrguZK5V9SXbLvii+ZnnaHpBjTzfK7IN16ujpB1E2KUqsM6NJQAY9ydL4ykpvANb6nuywPg== 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 VI1PR04MB6847.eurprd04.prod.outlook.com (2603:10a6:803:134::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Thu, 10 Oct 2024 09:35:44 +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; Thu, 10 Oct 2024 09:35:42 +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 v4 net 2/4] net: enetc: block concurrent XDP transmissions during ring reconfiguration Date: Thu, 10 Oct 2024 17:20:54 +0800 Message-Id: <20241010092056.298128-3-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010092056.298128-1-wei.fang@nxp.com> References: <20241010092056.298128-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0002.apcprd01.prod.exchangelabs.com (2603:1096:4:191::21) 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_|VI1PR04MB6847:EE_ X-MS-Office365-Filtering-Correlation-Id: 78ad2d32-6bca-49e0-9118-08dce90ee85e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|366016|7416014|376014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?QoSr4o+bxY4l9afy8UanIBQphXuzwnKwxeZRQYp3th3jEGbSBvH+cQlp4+Zl?= =?us-ascii?Q?ecP2u/r14netWJbdELDsg/gZCQs03NzPXi5MsdR4V+d1oSrFfHZ6hrIjQ81+?= =?us-ascii?Q?gEHr4uHV1z1oWFD4w/VtTrnanwIXsmwMC/3XElvb76xRcI4veAoCVrPK4zUG?= =?us-ascii?Q?hZwB25puvDwunuyhlTvQ21hrYmtgugZhBgxZa3mjW+uUV4fcondAZ8L6UvBz?= =?us-ascii?Q?eb4GU/gHZR8eoWtxRSBqpErfpEq6p844ln19q8FV1G623fgDySWX/AwEf6Sd?= =?us-ascii?Q?gKTz/Jyc07h4lTHGn/UA4Pxhu0y4GTbibrMjDY9jzXCpap6w1egsJLbbNm5W?= =?us-ascii?Q?1xc9Xp8FL3B1s+KQVpzzlLlqjS9UWx4T32pDjSs48uRs7cuvcKYQxqDbgHQp?= =?us-ascii?Q?snprOibMKEa3LlEuubpUWbmJXpKEbaTbNrsjhLN5f4WmHuyEKkV2MS+IM1wa?= =?us-ascii?Q?u1fyalmWnOk1EVLZ2AHYjhuHt4bcGJOiSVkia0urjuY7rlwqXr5GzOes5ceO?= =?us-ascii?Q?PqmJ8IaOp3hTBfKuMuViCd63lxwbvzSLBv3KPAYVf/nMFWYww8DaScYSEO1r?= =?us-ascii?Q?Wvd2fJRe1ydaETIsKQ5aOFV9A3GbA4BHkraQZZmmp9cgGy8dcVR8wcRz1MsW?= =?us-ascii?Q?1YHs/2wGhKM8MZJ6mS6TQv+vnSz91cVOaX8SVZv+iTnjTmkf9WlZ0nqE+wjH?= =?us-ascii?Q?Yr4zCmhANCSPQy5Z9JuwFGlVmHlHDyUvBPxnxDkZysEWbv186Mr1MXJu7lAA?= =?us-ascii?Q?DSpCED6ysOwL8dnEBLjzLIxEk+IDrkdWZi2nBfLvqTB69nkB3ygEKy8tSYkQ?= =?us-ascii?Q?QLFwh1LBNUvpNstZL3pvryOm2C30G1dROKkKxL+7Q705H8q9u8ftW7mrZWRB?= =?us-ascii?Q?u/+fHy8fDYB582xGL1F/Ff/3PtySwilqBZL5UVpldXzMGvcz0yXgqLtAiXvq?= =?us-ascii?Q?qG6yaPB7c1ayM9fUsIyzyBeYkOuRcIOg85kQ7sbXF16etns91r8jPx4I/5ck?= =?us-ascii?Q?1H2QyWEoaPDdhp4KNZFFY7ZlCq/lYYRy4uPxUBKrQIf6d1SvbQyHf9IvTf0z?= =?us-ascii?Q?Sc7UBpq9w6AS9TiiCD5Yc0SJ8xLPZ8Jsqy5bGCd5lynDAq3DkZ3U7jOheYo0?= =?us-ascii?Q?+TvzAJYKUWsHVjgrQm0GxfnhiQcbpZTl+2lDIN1Eu8dcr5+zh2rEKEAJGAJ4?= =?us-ascii?Q?lDXBrvVJ2lyqHOo+2eDebckYXog+3dqzAjqSIuZ/U28O9AsuJiksuQHNbIfD?= =?us-ascii?Q?XgBpW/khmZFom0N0d35+gL+UqjEM99pMJ1vyhS9i/8U40LKecYVOUYZZADIW?= =?us-ascii?Q?p1OsdhLOeA4qrogPRBynb7U4MddZcWI6j/PuEzMK1mGEKg=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)(1800799024)(52116014)(366016)(7416014)(376014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkC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=?us-ascii?Q?poJdXazWbz/5lAZezQjlZA9F6i8dnKTbnGIwaUkpAqVKle48/GPBO2J3G7H1?= =?us-ascii?Q?owgrf6CKlwokNOOiAI92Gr2F2fJfPQHwhn3rO+FTxdMQFd7gPHQ6J05B1VUk?= =?us-ascii?Q?YKIeS4JXsyOX8wwtCF4B/utO4u069U4FqO/h7ePaNrOY3juwaWoFLhHdk5/A?= =?us-ascii?Q?TnGpTVxCpHlB+ui3J2+81KQdbDBT51Ot7dqe7/htGcn1Ywst+IfwIoBurVY1?= =?us-ascii?Q?ldp8/4/WMaJ/kkUUo6cv6sFNWLJPvsJAcNHhwggHac6TjwU/A9BHHNSHtUDo?= =?us-ascii?Q?e9shBTsL+Vpvss5h89wyFlCDGJLe8SnnVlCh7auywNjzA99Zo584eNnv10gu?= =?us-ascii?Q?7/harDeN7juIvB2u6FMWzGyeAhNSjTH0+s2WwdWeI0iw84nC37cRC+/GSdeG?= =?us-ascii?Q?ppb0xDOsvYpBDI1ptzfatx5O/ncAkjKE6Qs9bg6owhJFHZt1RgBJhrlBBMBQ?= =?us-ascii?Q?4coQMoNenrxlZ5TFqSVtoG4hhPSjmbOI5NWOY4jh4Jl1hUwNUe9IgBO6POq1?= =?us-ascii?Q?nQdVXmRRnVkGfDBMBP04Pm32AxJ5syw2eS5pX1WJFnzt4mu5bkx0rwTRoJPn?= =?us-ascii?Q?prbHnFxckE0CA8fIHGX/BjR9emtZTLI4o4mEocVPuX+LKgV6Q/AaUDeRB6P6?= =?us-ascii?Q?7KyXDqilY9p7aiU0IrCQx8KSchnZW8ag+bnGtIPXKoTz1D9TZWyCRu2TefU5?= =?us-ascii?Q?odNLRrTmi8+7RlSNMiOlQyAEQokkxWfKIP+8L+ko?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78ad2d32-6bca-49e0-9118-08dce90ee85e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 09:35:41.9756 (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: S2GCL8FGF6vVIwr1V2LsIaMaKussCZBdrYlqJL+drMkfdJOChg0do3WEEpdzhYITcMQemyFu/CDYAYq9l2IPmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6847 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 detailed 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, the 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 rings. Similarly, XDP_TX verdicts on received frames can also lead to frames being enqueued in the Tx rings. Because XDP ignores the state set by the netif_tx_wake_queue() API, so introduce the ENETC_TX_DOWN flag to suppress transmission of XDP frames. Fixes: c33bfaf91c4c ("net: enetc: set up XDP program under enetc_reconfigur= e()") Cc: stable@vger.kernel.org Signed-off-by: Wei Fang Reviewed-by: Vladimir Oltean --- 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. v4 changes: 1. Modify the title and rephrase the commit message. 2. Move the changes of operation order in enect_stop() and enetc_stop() to a separated patch (patch 3). --- drivers/net/ethernet/freescale/enetc/enetc.c | 14 ++++++++++++++ drivers/net/ethernet/freescale/enetc/enetc.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/eth= ernet/freescale/enetc/enetc.c index 56e59721ec7d..482c44ed9d46 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); @@ -2463,6 +2473,8 @@ void enetc_start(struct net_device *ndev) enetc_enable_bdrs(priv); =20 netif_tx_start_all_queues(ndev); + + clear_bit(ENETC_TX_DOWN, &priv->flags); } EXPORT_SYMBOL_GPL(enetc_start); =20 @@ -2520,6 +2532,8 @@ 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); 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 12:58:28 2024 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011014.outbound.protection.outlook.com [52.101.70.14]) (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 4D3A11BC074; Thu, 10 Oct 2024 09:35:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.14 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552960; cv=fail; b=b3hG/9RpauTPyP66GY7CB8TipkHmT+vGQEK6J4a5hMS8JxbY1jnx997BRk9+nhQfUz4aqBnPNkFhBQ/JLK2+8hCBaQkauZxrdcCKOBhrKcXbdVaNjOkvNxn8IVCgt05ZswmPn9/u8xj22tCdPqJHO/KqsoX13+eX22OGo7x1x5Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552960; c=relaxed/simple; bh=PG5tTHcfBglgmg9je1jOI9O7TLIUnVlIuoVxAEH6Jm8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Ew81s8MOPjlBLh6Yodqnj5QjrxOxHUh/CkKgrXTh+ZToYwLEsBvt6LAymEZnIoni78aDVKPNsUDnyRcSiYbViOQfpbjBezkG0L5Wa/0ga5OEodYJdHSg3vmv9MiF7yzyujAHFj5VbiC8Q38Zn07ajjwBIilctkBf5mtZghF7sCM= 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=SCsr2laJ; arc=fail smtp.client-ip=52.101.70.14 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="SCsr2laJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DA9yXx3Mn627LNIehy0iBZK8NjyfbgWTcNV0hLxocSq1ssdgjc69G0/MH1p4QWBXTMcjWR5J0Hh17EFbxA38ipcIY1wDFJKPiIDWilhK6ez5sKbeZiQDfC6LCv3MwkCcTcF89hxif6qN9ZwiRSZOujGYewDrmn8KNmDP+7Wv6mc53Vfiyw3ZAReSE/6d9dY8i/WZvjZ8ia9jh/Qwi6UnIVG3BYVJDSQxucg3bXh9kf1JUJiUAXKFxMG4cHWpewmPqucTX0hvZdgxSKpSF4ya/ElSU6V2j3WP0bj+FlnPcl2fviYQ/ZjVGB2cV0Liu5NPIj4KLjt4qakjo+/sL6rKGA== 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=1yl0RmtvtTuLVkZJv2oC6KenI+lgS4OMopBKhZ+sQYw=; b=tLTHd5/ehezSMnUyHx9g00O4sNBkFrNZp5tU+afeJLUK00umyr6A72qpZpBkogTV6sRAxuGTW32AqBKGmOEwnzgET6IGRvinkj8kVNTSFU9X2bf9AUcEnlVjOkB6hj8vvQq43AE6UexpwY7F9RXV1yNjpiZZB3GKmxGbAZBbZvn3XwxVRklYhhPe/jADE0jHS9LG3uTjlrfPq11dDQ1frmENdTYI5zA6AWBaDX3f1TZyZ1tM7An48IMvyCUZUFaAatSA7lAUaEi+3nIh4DLQlkffH6BZXWeCNuOEwvp30OqlFk6VoM0Ib/yi2GqGrAp6OphbARUlHzIGh9rzN8sJFQ== 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=1yl0RmtvtTuLVkZJv2oC6KenI+lgS4OMopBKhZ+sQYw=; b=SCsr2laJVdr8+iAzjmMgZ/Y9RAUYeeM+e4V+kyvjAuEtuEeKiyNm8oVr2b/adLy0JEnSayMSLAvByRfFDAtNrKdebrXOf4UFQyTbUfOa7A+nYuXRA9QkWSWrby17ZxrIdQ4C3GT6FpWKr9ru1dtlMAmgQ6GI7pyjkUHHKVfXDE1nqM7pVQdIKsbFgULCO0dvsUBFJfB/3OdmMNx2HuULpO588R4u+7MU4Rowc1fdwb81OugNkSAGfOjCn95r66yVDgw9ESCRcHDgwloghQl/6iCu07HEVC4+3AuH4CmrJ5yvLFR/BihSTSJIVmXzexy+TyDYiW7gRI51XxrZFrumzw== 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 VI0PR04MB10856.eurprd04.prod.outlook.com (2603:10a6:800:267::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Thu, 10 Oct 2024 09:35:48 +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; Thu, 10 Oct 2024 09:35:48 +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 v4 net 3/4] net: enetc: disable Tx BD rings after they are empty Date: Thu, 10 Oct 2024 17:20:55 +0800 Message-Id: <20241010092056.298128-4-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010092056.298128-1-wei.fang@nxp.com> References: <20241010092056.298128-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0002.apcprd01.prod.exchangelabs.com (2603:1096:4:191::21) 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_|VI0PR04MB10856:EE_ X-MS-Office365-Filtering-Correlation-Id: b17420ad-cab9-4c02-9d0c-08dce90eec11 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|7416014|52116014|376014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?onSs8YqWf5QpQxGoa8MDYjQ33bjn1RzBxGxQ3usxwuc9IyV7Z9d+g9h0TtX5?= =?us-ascii?Q?VQLMJ4EGKINiFSeNtfz3opyURGkFPrZQoRf3JRKyat4NA9BxJ05hBnsLqudG?= =?us-ascii?Q?pr9Gjm28P/Htdu5Awm5BIRy8asB0S+cVhUJObUzxkhrVVzeg1ndSvZuYxlf2?= =?us-ascii?Q?Xtf9e0MNY5evke1YyeMdWitiPtz7uTDRXERd7jCuPw2YbTF2xosyXc9G/LT2?= =?us-ascii?Q?e1NSWU4MYrp7YroBIdJrEM4+t038aTc8u+xiP2puHfPs/iK/KygGfevQEW86?= =?us-ascii?Q?luh98mK/5SkAut4Lv8nMouPnPE8jKVwG64o5z47j64KnHxWptw3eJG7M2qGl?= =?us-ascii?Q?h2V8nK7IVgdJUlJdxtUW1f/ln63tQe7Ws1V5lOytJ7gHNq+Ezs7NYQSWY89u?= =?us-ascii?Q?XmYu7paOA42UVfk2bq4AuSe8Ybo9F0CS/GnRmJ9NU2uOOToqgj0z94aumyTd?= =?us-ascii?Q?CIggb2bRNYFbSJtTQ4C9iO5Wfui2C5XymU4uxKyct8rFPcsOPwypQdOE8pdC?= =?us-ascii?Q?uDc5WMMIb7B6oi2YwBzk1b4mVBCUQ2oUPMx+lYd6Qm7sTqheW+eJjY2Kc+pS?= =?us-ascii?Q?Lj4OMtXWZswQ1zO4vVRFL9d8Wv7FpEBGoqg0xeyDMSaxPHxR0Lxwk126dZQO?= =?us-ascii?Q?+BnrVunt6yz0c92vpn+q1vv21zBQKLP1/my+YV5thOjMn9fyvaeE09zm2MWg?= =?us-ascii?Q?nT+y1PWm2P+0hbhRxyBORd/hw9r0UZ09O5gpZMQmURs3naypFKgQErMyJeJH?= =?us-ascii?Q?Xd0nM93Oafjyk6WX2CQjFGsSCSlOC1OXeKL7JIcZQk/Ebd18A3ObkChmrrjN?= =?us-ascii?Q?gG22dPIJGIdJOKfq1cDTKnZYgr/vzlNt/OvAdhWigG9iIasQvjcHg9aHoqmG?= =?us-ascii?Q?X3uU4nKchqg6T+Z0vy/jluXcDydjjLWQfW7iqQ2HgQpgr/qrbLqjTksnMWIn?= =?us-ascii?Q?t6FPjdoXoW51/8dYzhmZuzhOyW4pkDnDazqHqXKzlTbfQ0LoMi1zEy5oPSjp?= =?us-ascii?Q?j6bsORuI12RlNb+zbsmG33lpvP4kHf5dNx9zG5p0Mz6+OWi6AOhHfXAfnGW8?= =?us-ascii?Q?2AjsVja5Y9P/sUvU1paEEXvP77PxgLwWaLhEldLAB+dQZuSIdsoAt8/XFc5R?= =?us-ascii?Q?tw8r4Tl5+WksDi9sqp0RiF1uo2Fi3hn3Qc4WPXWN/168Y1eEhwnQLO6pR7lz?= =?us-ascii?Q?a6AC0dolCJnK0RM7xwDD9oN2gVQ6Iqn/dxVFy88wJy/UUfw5j93PEfu7CQkr?= =?us-ascii?Q?aDZLKsPfS4ro2DJTiExGyQyonVgHOxc+xqpQ0MkNwlZZAnMG7VAJOc1BnZyS?= =?us-ascii?Q?t+tNqGMUNiSTQ4ciyQTSghAO3ihkAdoMs1hgPxcyoezP6bS2i5hf4vm8W44I?= =?us-ascii?Q?nfEPdHg=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)(366016)(7416014)(52116014)(376014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?v1lO0y0x1BDkMZH9uAEgpY5lyO1NYBqYG3Yh7R1qEpfs+i+3duO+zff5jKw9?= =?us-ascii?Q?iC3Jwds6GzTqzldANk6rcOWht3zkNmGKXqq8kaX9R66ZY/rjKMT5L5F7rJJH?= =?us-ascii?Q?vh7zE0o+wBB2n7XxcK9Sv8Xn76l0OKXK0vlbXuAHAu/I08XPIOcKBMGOckL2?= =?us-ascii?Q?Hiz1tgfIwS1lWCh1uuOVUwKF2oO4R1Srsm+nmW32VpbxBWMain52sHpw6NhA?= =?us-ascii?Q?Vyn941SNjKx7aJxgLRbcyj1sI3ne+WSW1bshNI0O9v6P0Cgdeaf0FAQPr4Ww?= =?us-ascii?Q?UDLjPH+wxS49PauELOTlPhQF/5bQTJvjTj6bW6c0aiK/nIOP5x0dcTBA3hyt?= =?us-ascii?Q?76PvU3J04HJ8d9LUWxWrlMLxvq/Rlycq9uK+8+IXIxq2IuRiNQyTdc1Qe1ub?= =?us-ascii?Q?GYTRYCor+OCKCxH+qT3y1Cshyz5FWiHheatDwd5EMq9B9XP1oqgJHehuoja3?= =?us-ascii?Q?ZDICoxFhHn451sjcpB2swxoy4+KJH+5u3AtRSyWfY0xmelqYZYKTSyucloRV?= =?us-ascii?Q?7jxvSXDnIQbIRTU3UL8HI3vQ7It5Wf7NvrrPIfv24Qp64rGgHAr7J7SrHcdT?= =?us-ascii?Q?4lZxTzdSExeXKyB2cpkoB/rdbEONEXeqjVEq1pejJYs2RLVg4iCgK4zMnTBq?= =?us-ascii?Q?5dnoQ12YYLQICATk782r95VAehJ93hmqxCTOyRL6vC01/s/BAFdXt9weO7FD?= =?us-ascii?Q?0v/3ieUkn9CDTeATFvJHsziYiXsC/XEJ7wIsEOhVw4u3y/Vr0oI0Y4rqzh9/?= =?us-ascii?Q?8oAcxh9/A9QFxcQ35pdxysgzLwFV11YQcE1yUIVfFoOtWFFwLZCDBK155ACK?= =?us-ascii?Q?YLTtYhkszOZkgAd9IoOhMIJUnO1ryiuQRhnUxIjMnxC3TVodc1N0c3opZFCb?= =?us-ascii?Q?7A44Fu+mu3Ct1GtDZ2z/fdlq/GxqgK3rD9uBL1SotB+Rp1emDSBvWOEGM4yp?= =?us-ascii?Q?V6FlvOU9CsZQ/sFUhxq5o1jzZpQ6WhQnoNbJ0S16TPspyg7XhkCtjs8gxrYY?= =?us-ascii?Q?KEMesHiY5tuucA+LiRB8ekuC00wssNpUVlrhp2mO6DFNGblC1cS8+QgWGLtn?= =?us-ascii?Q?9z8S7rVk7nvYiMxgQsyQ/9BIeFu8SmgpfIlfSbBcugOgGx62Sn7zt8soKNKC?= =?us-ascii?Q?WNUrpzsRvqj7L/BndQEoS57FpwVRbN+fipsW2+43jHoKtctFLO30wkssfDQq?= =?us-ascii?Q?P9b2gM1FyYQPkPQQlsvv37hSpb9n0bPx3kENg29gAvxvpRhS15QVvLkCGP1E?= =?us-ascii?Q?pBqmmSwAHyBKqRZ5plUuFftS1WTuUB4Wy71PuYYTI9yNxQSFlZbpo/FI/U87?= =?us-ascii?Q?ZuIh42sOiy+UWJ9ysjhQv2xmeILKjsKGB+PvTlrmN5VHjvCU8HBxkm72blKM?= =?us-ascii?Q?p6iP8RwizOB35vcCWiJQFZ6Xr8xgwX9RhYoZPR7IDMaW6zaGA7k0XPicHjoT?= =?us-ascii?Q?N8MT/zPDdc7I543WkYKxfjVT5a5UPZgByihZezyDZtQNY9YWIWl/zJP5YhGX?= =?us-ascii?Q?z9bYEZQvPM692isqvN9BqdEtNnivyKRn6FXhT+i5VBg9DxVsmnQGWjGKBwPc?= =?us-ascii?Q?zv8sJNVuYMgaNPtfX4TMTsVzaOLWI2sf65RI8kZ8?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b17420ad-cab9-4c02-9d0c-08dce90eec11 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 09:35:48.1094 (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: kWgD7vAQd7jU6aWHiMuir3suSaPzP24olaNI0aAZLYkOLyIoZOd1J6nM/fdTvgBLrgvLrjvBYEvO8AQxThRGMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10856 Content-Type: text/plain; charset="utf-8" The Tx BD rings are disabled first in enetc_stop() and the driver waits for them to become empty. This operation is not safe while the ring is actively transmitting frames, and will cause the ring to not be empty and hardware exception. As described in the NETC block guide, software should only disable an active Tx 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. When testing XDP_REDIRECT feautre, although all frames were blocked from being put into Tx rings during ring reconfiguration, the similar warning log was still encountered: fsl_enetc 0000:00:00.2 eno2: timeout for tx ring #6 clear fsl_enetc 0000:00:00.2 eno2: timeout for tx ring #7 clear The reason is that when there are still unsent frames in the Tx ring, disabling the Tx ring causes the remaining frames to be unable to be sent out. And the Tx ring cannot be restored, which means that even if the xdp program is uninstalled, the Tx frames cannot be sent out anymore. Therefore, correct the operation order in enect_start() and enect_stop(). Fixes: ff58fda09096 ("net: enetc: prioritize ability to go down over packet= processing") Cc: stable@vger.kernel.org Signed-off-by: Wei Fang Reviewed-by: Vladimir Oltean --- v4 changes: new patch --- drivers/net/ethernet/freescale/enetc/enetc.c | 36 ++++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/eth= ernet/freescale/enetc/enetc.c index 482c44ed9d46..52da10f62430 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -2233,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; @@ -2261,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; @@ -2462,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); @@ -2470,7 +2484,7 @@ 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); =20 @@ -2536,7 +2550,7 @@ void enetc_stop(struct net_device *ndev) =20 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, @@ -2549,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); --=20 2.34.1 From nobody Wed Nov 27 12:58:28 2024 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011014.outbound.protection.outlook.com [52.101.70.14]) (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 8B1271BC9ED; Thu, 10 Oct 2024 09:36:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.14 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552962; cv=fail; b=tdz5xWlW6o39UvJh9GSrwjQDohvtR2qBxuzWQL2bF+dRd7L04NhXtiRQgjSi99djGjpn0PN4ps1QX1F4xylB4amT4fmnuiUr8zCgNWDwRhwtOcqc4SkuavdP18Og/AAcyo5XnXB2TpDw/MEO2coRFEIZjM3URTD5yky/YbGKVMM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552962; c=relaxed/simple; bh=W7yEJpYb3Pu9CzMvGRlij/dsgM37cXfZu5kHjh1UUZU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=QQ8d/+6Oyg9E+lkjMjxgidXGZTkC5zFpZn2HzNne2OUSIcjhs+w1xFj9xlHnOt+fjEfPOfTyqGV414xkgtsuc5LIJdhgbclSJ5CkH+TV8T/gztzSP47oPlMCZWZsCa/ycDM369Nbdct9EXLB0HK53cryK1dMHtDJlf0mUkBDC9s= 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=nlPyGZRf; arc=fail smtp.client-ip=52.101.70.14 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="nlPyGZRf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=E4/Gm/DHIwq4blZakzLofMsD5PG3mCNoRsZql/50b3AOmEjyvzyMZpAEew41M8yySFUnLWxB3exuQuzeSs53eCINnM9JRSf3Kj6h1qNT6lCSAfiZYQVufZqlea+LKeJmY5Jtfhyc6VIH4txSZYlR2JpbHBIReT3uMec1+I3B/kPIJ912DiHPQVd/q+uZLA2QEfmCDMHd14+XRk4jkPN1INn7TFgFc//DF6lwBiJP294O48nqm78+ePM6k0K6J5O+TOzHwPtS/cL3MhFXpbbyx08MrM5y60iKXu8YKM00xuAAmoIhrFEP64ZnPSFBuL04GCNgDWFD70JYvh+MHQecrg== 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=5a0+mRL4Rvw6pF64IM1ITWNwXZ3Cwy27hVi6eNOR7j4=; b=Ph6NxvjB5b9AwfeIaDxe9fCsrfWWrlhRhhDy3sBfyLrfH9sYQMu31jNI0fBOszV6pF9zgJltxns+/tZqcEqi6rHhotTtYyzc02KVErs7JWPIMdMS7sst9NGiWQyqkB8t7MUmsQbyh2gJtcfO33zSxqxHdy+o2Qiw6QvXdYRMGbfOkFG/K/IWpaJYVcHzV8k82a82A9vrtN7RxImuaSP7QjIErUzMcpcf4/nXkwHxiCtVoauaHfURqplJSGwtBcOGGViXjy4sT5sZTfsAR2KZMmfiDMDIzeIYdAMSivGyTd2TivhRkndDH5zXydZa1n3HbGByQz5rGNysgOIuypvz8Q== 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=5a0+mRL4Rvw6pF64IM1ITWNwXZ3Cwy27hVi6eNOR7j4=; b=nlPyGZRfwZD1A/HSGongaBiF4CB/ZwQWpLNwAmKDOcixAoJYkzJALLGpsI3sGmO2RX8LEtYbZ9p+LYnVu7ZRMYIoBk+6TV2WUBGreLZ+oi6X0GNOE1+QEcjXhBLLBaPWF4wFG6xyMkguPnZECFAPOveHbCO5loV+EjcdMBCilG88gpjj7RepY5bBPZQJh2TulZjHWc0xoVqjzy8lnwYFwWK7sHjlLe+OAmv843ghUk6Pna5LL1tyE3cM4r7E/gxDPDrjZarK85bklF6tq/8sjc/O6G5udllRdk49r16zofuGuSJ2gtTl5I4tW7bWxFUDZpJpPVnIas7JT38BCDW0/g== 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 VI0PR04MB10856.eurprd04.prod.outlook.com (2603:10a6:800:267::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Thu, 10 Oct 2024 09:35:53 +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; Thu, 10 Oct 2024 09:35:53 +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 v4 net 4/4] net: enetc: disable NAPI after all rings are disabled Date: Thu, 10 Oct 2024 17:20:56 +0800 Message-Id: <20241010092056.298128-5-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010092056.298128-1-wei.fang@nxp.com> References: <20241010092056.298128-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0002.apcprd01.prod.exchangelabs.com (2603:1096:4:191::21) 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_|VI0PR04MB10856:EE_ X-MS-Office365-Filtering-Correlation-Id: 9818f9c4-8b3c-45ad-5d41-08dce90eef81 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|7416014|52116014|376014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wpZFHm31TXjiVFkT2VZayFKNKTW1QK0djibfcOwq/0XXkDwbKMFH0pSNF9qQ?= =?us-ascii?Q?yWqyWrjYkOrG4wum8QhMd6irMZnz/iQw80oMgT4uiIldVjzglEv7P2piAfG5?= =?us-ascii?Q?Bu57qxCpWcDGmMWOuCOhuxqxs3x8UyLlbt+zeqeoDpK3QZmpAlyhnjkZugNx?= =?us-ascii?Q?VDHdnii3W4TUFY1/8jVOOT5XoSdoKhctGrEjAgJs9FZvrDyLBcX5BwzE9zXi?= =?us-ascii?Q?OLYprfs7P4ZdgU+Gezu1mk7Ilnz7EJl5WCR90YkSyO/LjXppte14nqD5AC9l?= =?us-ascii?Q?icK2dZ+OpcpuO2p/jRe3hFHS16ngVTZxtmxLQthJZhbmiogjgofqmDl1iw4e?= =?us-ascii?Q?pevDlp2YTQqiCPakAeizO1UV+yodYUCOyvHUV8VcFuMhVXbReT0oYUVq5Q2q?= =?us-ascii?Q?18DUhA4vBq96bJLGpdHwwhS6TN6RqbJuzSJV6+ynxYnxbmX/ozi7uNv/Z4s5?= =?us-ascii?Q?x4x0cYRRhoO5SA02aCS3wH4SXQ/+ztTYLuZCJJv4fJoYk5ddX6uQDRSNReMQ?= =?us-ascii?Q?XwizbdYP1VGnf+1s2Basl+HsS5IGS/1exkkjQDLRYwt7xcVzoqZVWBNXyqWh?= =?us-ascii?Q?gyj444fQxDDVqkeW1gJVbPH9QqZSpgN20megkqOh/PayQFBsCWzc8R/dvH6o?= =?us-ascii?Q?WhhArF06A6dQ6M+BvFdcexqeg25McbfVWssDSnj+7nHaKzKZp+jdFCHT7DW5?= =?us-ascii?Q?C/t6o1I26QJj9PJWASM09gkeEeJ7Cibozr2ZcnGFlKQr17uPJGRKN2FLkBEd?= =?us-ascii?Q?3n5KpSjRI/2lgtwsYOEOj43xXHGTVCePnuSClrknGrL+sSY7WsoeLD+/uFGO?= =?us-ascii?Q?cS4TsFgqqHjrK8Pas7oi0AKX2uvWOWS4sqYrPSGJPkcQZKMxVzcYY7yVgpH1?= =?us-ascii?Q?YnRPfRFQYi9T9jizfFKSeNYHvX4DYFmU2/qRhHQTtwoRBXCcIAL7ja+oIC5f?= =?us-ascii?Q?IAwBprVKN7htgytAl04LyUzMSLWyKhVBtmaz1jE5N6NfXy9YhPIUbS6EUpZh?= =?us-ascii?Q?cwHuN0l66WaX9iUmu+/Ge4aBAEOX2gUQ5HCjMzVI4vuzdWu4oZYFYOyqAvAT?= =?us-ascii?Q?M76Ys3gAVXfQNPcKqSzNHKXuaRVgihxKrf6YYCfw1Hlxvz61pb9ROtj+6OTN?= =?us-ascii?Q?/TSv8jNn06jbXnayCQFpmEVLvwwb+YzWPArRGiyWXKi2BWxioz1du4TAC9xt?= =?us-ascii?Q?ATU4wWxenXWTRmpCDxlKCKFVqtBW7kSqufFtQaxduJ/kvcdKNKGQfQJt8gHc?= =?us-ascii?Q?diRklU44ds5e8SyShf5i5gawnHn7qeQ4nhBr6sfmDd/Yzqg3vy7ka4tTVsR4?= =?us-ascii?Q?n4SOBPXsyK5dkRzhq8PDqZI6L9NDlUhd9gMLtSeQoAtD0g=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)(366016)(7416014)(52116014)(376014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-A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s4D4A/QUw1Vxn7F7/BSQOlHIX5K1N/bVhsiwnyVd7VODlYU/qxHH5u+?= =?us-ascii?Q?/G4Wh/NDPBnd62Raz4xK+xBKEiIdWbMhnInrxu07RxtAPeFirmp3kdA/NQE7?= =?us-ascii?Q?Sc9mK+QIabSltzYwPn6WnU+RH0931TvCgJGSIhp60xfZppx5mRD+WM6Zf9PT?= =?us-ascii?Q?bIu2HCNYNQ/8jF27DaxW94wLvi+URZuPvbj/570/3C4mWm3WPXOuHCN6XWQD?= =?us-ascii?Q?Ofa/TLK3w3BZKIf9jP6MtLregaWniZgdXVoVkJJ7yEnah3Da7dc2q5J7RMug?= =?us-ascii?Q?GNP7i/D8sHoKLv2QYajfYGPUX51NYlDvoKKhN/oimEKGmvAsA+EMs3AZ1xiH?= =?us-ascii?Q?VtrygeZSWzNd80SmhkjjKg3Q9nt4OXzPJgr7Tgchl4TiTk53PcDtWbdJLnYq?= =?us-ascii?Q?Y68KrkmRpDkDvfL4GP48CDgl4EPP6g8ZzXgaNyXGwaoqN1HgZHLdkjWOipgh?= =?us-ascii?Q?1V8znsEkuOc+DTKXq9X+qEqzG0W3rVW5NBO/MnfPhnl7VBfpmakuUo99mIpK?= =?us-ascii?Q?maKqoU/4MQZmwCzf+TFgJyyTJ6H7UGX3f/puOasBqyNea+MswlOw2g4avsuN?= =?us-ascii?Q?G4Czk/+0mm9Ki0ua0la5FP7t2Jsf8FR42vsHZv17jYpMRE3W+AmpIQ5J1FDF?= =?us-ascii?Q?Nu4nIx/ZRCoS8iRsxMMzh/Hk4fM9ecB+H1pfH3jB/F1nGUEh9x1cZZJgbPwr?= =?us-ascii?Q?6KFFnYYFY1GeZRYITuT8b5GtJOb6nAaTVAHQvzoM?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9818f9c4-8b3c-45ad-5d41-08dce90eef81 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 09:35:53.9062 (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: 5Y8BrQL1m3jsuCTyKcLY7fl+EfEb2v0TpsbzTXVKToJiVDE11CSHI5ECsPW3vNxJaXlEdYMltFS28sRJVgSK8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10856 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 xdp-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, CIR is always 0x7FF and PIR is always 0x7FE, which means that the Rx ring is full and can no longer accommodate other Rx frames. Therefore, 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, the max value of xdp_tx_in_flight has reached 2140. However, the size of the Rx BD ring is only 2048. So xdp_tx_in_flight did not drop to 0 after enetc_stop() is called and the driver does not clear it. The root cause is that NAPI is disabled too aggressively, without having waited for the pending XDP_TX frames to be transmitted, and their buffers recycled, so that xdp_tx_in_flight cannot naturally drop to 0. Later, enetc_free_tx_ring() does free those stale, unsent XDP_TX packets, but it is not coded up to also reset xdp_tx_in_flight, hence the manifestation of the bug. One option would be to cover this extra condition in enetc_free_tx_ring(), but now that the ENETC_TX_DOWN exists, we have created a window at the beginning of enetc_stop() where NAPI can still be scheduled, but any concurrent enqueue will be blocked. Therefore, enetc_wait_bdrs() and enetc_disable_tx_bdrs() can be called with NAPI still scheduled, and it is guaranteed that this will not wait indefinitely, but instead give us an indication that the pending TX frames have orderly dropped to zero. Only then should we call napi_disable(). This way, enetc_free_tx_ring() becomes entirely redundant and can be dropped as part of subsequent cleanup. The change also refactors enetc_start() so that it looks like the mirror opposite procedure of enetc_stop(). Fixes: ff58fda09096 ("net: enetc: prioritize ability to go down over packet= processing") Cc: stable@vger.kernel.org Signed-off-by: Wei Fang Reviewed-by: Vladimir Oltean Tested-by: Vladimir Oltean --- v2 changes: 1. Modify the titile and rephrase the commit meesage. 2. Use the new solution as described in the title v3: no changes. v4 changes: 1. Modify the title and rephrase the commit message. --- 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