From patchwork Thu Sep 19 08:41:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13807525 X-Patchwork-Delegate: kuba@kernel.org Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010071.outbound.protection.outlook.com [52.101.69.71]) (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 C1890199240; Thu, 19 Sep 2024 08:56:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726736189; cv=fail; b=FJKac9XqR0p79FhCGEHPF9UGbzBSEcU8Jq6XYA9eiDYY3FDMh0LaPQubWDqmflVAlKhi1uDVq1guvkjIyiv4NG0fLpNiGYhGGQEmNIpAruAOZQwrcPbEpTlJSj6jDIfZX7oMknQedBUwP8ys6kXGo6Oy9RDSVTRC7R9SlWAWY9Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726736189; c=relaxed/simple; bh=HhZiYKornp5ytnDoCd2esR31fqRIVo04QywrdpKwsYU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=YsPBB97n/lem0siCN7wyT3JrO1caigg8SrOL6R2mfeTq650CpFwXtarDzTlZk148RMV0bJhxgjCh8BbP1hJqNpFXUI6OV4kY+Y5gCL2I6YZWQWpnIwksukFjijx2x9JTqO7oxIbGejreSpyH84BUrxXgqE4AscKWwlqtqIGsBp4= 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=kxE15vaw; arc=fail smtp.client-ip=52.101.69.71 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="kxE15vaw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L8mX6uraMy/5wI5aRxAz0+g5k8CdjNvkBkB5y/jiEbzChwFkMIFQph018MrToUmU5t2NtMkVjMWBXWJWL64SfdCBC1+s8NmqjBa7FRKGP9dnRZ2Fo5n5o5aC6sJ9g0HTQcMauSp1MH4yTWUcAiZsd1PHgnQa18QrF7PWZCgbgr+S/rzU/4esXMUwJ/6KCS6a9Eu4qe7UYqaNY2Gi0HIJJz9rGiOV70huVBBirwZlIWg8rBAA+qGsmsQ2j/LuR/mUePYrv/T2pyL18uUHcpOxoFJ19lD4/dZtajT4/4pJLOw85sd6QadWfo5WCm406GCl0Ct8h+H+nGjd8/cm4+Cr6g== 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=RA9MIuYWcWZejfrz9HxIEAn8oS+/fbp15DCAFJw4vMM=; b=bbgBCVaKZ1YZqA/TgMBF5p8SmLC7vwv7v4zqRIUcbU+3UN6o1ETSnRVC02DJrKlhln8jcrs2sLB0RNUcYqo9H7uVYzrQwRdRO3vju4LNi4AdcYw9GyngCnx7R53RthOOH8GSkG6u+P/EcGWtI1L49hngIR0XlqfL1b3aouVFPI9R5q/kZQqOEMGRSLJs+X7rTKhdw+Vs01FjYswUEAClV1bm65zC500WK143hi3KJxJ5tmyNFGhZTFUY9CfoMGF6USqOe/VZXpeFXr4Sz9B30Hts/H+vpad8d74ilmYLT7URKuEFR32+JHmrPzXB6dtIMNVeN7z4A2ny8kPK9zwQXA== 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=RA9MIuYWcWZejfrz9HxIEAn8oS+/fbp15DCAFJw4vMM=; b=kxE15vawP21eIesh+/kd7kJTBZ70UCXIppWuBBV0T6cTfOq65uCIGlZrpdY8Y4otJijL+EGJ+65+3z0eOoAPE2xot0F6ykxwln4HtgLuIX/cbNMLxHLZTPfkIuGGJiQVUIL/8UYSkqkJLBV7dbdaJT5T55iqV3nFsiSjUm7kvQWrGpViMEfD4u/JhFXoVjOoim3htSGD9r9RXPy9qr4aXSadfXgG70/kgFUnG61m6OTeiTzNoauTGumXCKiv0X6x+IvPjAmFfLINhxtYN/XabavG/HXJK6lFit3oXWWaDDThK4131GhAjoqsOipEPrSUiSCa1oOVpBHARGeQ6DQqHw== 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 GV1PR04MB10242.eurprd04.prod.outlook.com (2603:10a6:150:1a8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.16; Thu, 19 Sep 2024 08:56:21 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.7918.024; Thu, 19 Sep 2024 08:56:21 +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 Subject: [PATCH net 1/3] net: enetc: remove xdp_drops statistic from enetc_xdp_drop() Date: Thu, 19 Sep 2024 16:41:02 +0800 Message-Id: <20240919084104.661180-2-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240919084104.661180-1-wei.fang@nxp.com> References: <20240919084104.661180-1-wei.fang@nxp.com> X-ClientProxiedBy: SI1PR02CA0005.apcprd02.prod.outlook.com (2603:1096:4:1f7::13) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|GV1PR04MB10242:EE_ X-MS-Office365-Filtering-Correlation-Id: 031a7fc0-2afb-4da6-a75f-08dcd888eea6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|366016|1800799024|7416014|38350700014|921020; X-Microsoft-Antispam-Message-Info: cobNhYE3+D3p9ZQBfiRk6esjMrbf7SOhbghYDAAsiv9x7nvGAoo+fpfeAe1e6A4AycrEDb8lZIKFKfoqtxfJHDrCxLr1b03d9lQIjwKr4xjQqMpOeW6mh2mIKdVpBavfd7IYiIVpjAoZ2TJMzhcIw2CXCkvwKGbrZTdyGDmWHpv30I7jNIvAmNcVEsrNWfilOmvUuCrrh9wvB5Dgq2hLFMH1MMDFDMpSRWb9dosSlM/YP9ZJfsBi5ZZfpbmH7C2w0YPJ9fh8L74zzp2g3Uxeoosn29/Iw+SBonpZKwk1Rhh7KtB8TlyCzC1hxK7DvQuFTJW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ERa7eR16hi7u+T/Ua5m3aD8n2HgKo9To= 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)(376014)(52116014)(366016)(1800799024)(7416014)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 83SoA4rCdJFUp/9DuLuFgTqn+CB6hJI1EBU7bYSY5fL/RVRbFSzdwuJELDIDqJnLhorEukI6Ti2T1bECsRO0UuKigHB6K3iy4RlrXZpWBsQxDAU/Qz2D4RPoa/lipF1YFVCIBbKwWA/YEk33sLcReTZ9XnQ+RXE+4bfUG2GctuYEQpKBxeVK3QUxKogRUHpO7Ebe3uKLWl5CAXEAwidhphMoSZ9Dd3k8ygzrHq0sWwq/8ddDnCMMigJBC0NvaZzfgPqOkKm+dnGpuOPqhToe/ANTTaJ0Op1pOTIU23qJL3ok99mrUMU3VlDCB01VOFAa7wLIMVNH3dgnaAM7lGtG4yc2Gboi27p8hCTV3wsA6gDZN9S3bEzK438sk04XFj4DwdHWxKeGJO7JmSuSnygrSLuU9Gip9ovOQNmquNTnf6A2jPgSCrZ/5Z8Z7hblb9LWWDHRDSxRZW5KY5Dhc7Kt0VR0QTtXwTNPMPWmWRCkjI5RMwHN6b+PvyKgartdwCS40yWb3vQSVskr0pZpIA2bdQ619aoGxVZ2Cg7YnPKHuyxkgGLPHNvT2mY3QQhhDVtjRgKdHLZcyg9El9lYpQTPFCvU5y29VYXdpeWl3yq8Qwy5/VNswMMnLhwd7ILAWy+4iSz7GxpHBh3aqZmE/awBrBWyWPyMne9vJvdtiqSggJBbbdOQzKBjN4EOIa0yHrji3e0bscGJ+D/jmcmn17Qyd/2+fi02IdQbpCuf+R+oYB8Pe1L4xGQm5RiyoNgsw9tBdo+9Z3Ac1c4RILJZte9CBy4vzjSuN5RVieiLEV2p88Jg0qHjX+zpOoIhXFIt4KTJYgbmrFq+jnipjfc3O0UANlpUxRW82OYBMky4AejfREy4chbqGEK2Q1ow7pcA0nu4igjYT/4ODlbN20PHE42sZ/IcK36h0iZ1a2Y7PU3kRo9dT9w8r3aMSkSZVz7qZsocpKbCTTIoYc7cC5LHO1kEoYIzcKRlCO4xIy3XQcO0ThUvR+NstjBqNK+Ek49rUGJn33CcfzgiIy2U2mEVZET1p3dZsOSUEAUdAZYGjcQMwWGygt+6TCSfsIevyeQTFzFnFKtw8+vOkJrKnnB4OZo0R8+p5G38n2GN8szZJCmHOLI7oSoQpCkSXui/qubdXZjAfZF0v9ItHqvsvUPvAXigOf95U18vF6IRjNe8Dcxz8UiFlT1gqgHG1vnG/eiausoP7AT1S3l3dBriJPgRLT9jDzV7j5AV8p3Hf8K1do5Hor4Qy00a8mzuACanH6WDUVbbAJS9p88QWHSf9umvtRMcg3gXSsMi5OfQOOQ4UKF5/Of69ERNuIh0nCD+RXOZMEdYzDvALrCyB26JcyzT5FihPQoa7vDSk7SkxaDzF+6bxdM6fNff5+B5ISnCMhHDqxV4qBnfwX7FMMNgeKjyb4PVyWMUyIUT35PznLMxCEu2PJy+sZuqvkFAQGaWls1/FD1BoY4igVTEsoaUpGefieIGLrqIHrA1iHiHaUGeWIAImeWpvxJwg5hc6vgTGUpdbavh5mYO92V0JSIdS1J1rPdAR486ryWg/njuQQ1TGG6a6AFblyFWEekIRh4rTB/2aX1y X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 031a7fc0-2afb-4da6-a75f-08dcd888eea6 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2024 08:56:21.3294 (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: ZCFzl9DSgrRmRpk25xm2pq4N9EFur0O95C3rPt0Ad2c7yjD3SVx4Jzyj7YbjjyJAUP1Re3JPvTylOt2LsPgwYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10242 X-Patchwork-Delegate: kuba@kernel.org 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") Signed-off-by: Wei Fang Reviewed-by: Maciej Fijalkowski --- 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/ethernet/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++; } 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 = orig_rxbd; From patchwork Thu Sep 19 08:41:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13807526 X-Patchwork-Delegate: kuba@kernel.org Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010071.outbound.protection.outlook.com [52.101.69.71]) (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 08077199E8D; Thu, 19 Sep 2024 08:56:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726736194; cv=fail; b=o7yRuvkNS3yFGucdqOW2x35fTAhNEnK06aAb+zwtqXT8OkG1O+SkiVc1RkTEfL4DL4d3imJzYWWAe0u5IGywYgYFDUaGR6jZVXxLny0udoM9ehepi3k3hpmkZWm9GU7r0e61y54BYn6Y+WIx8ugi8axjYRvZTlKRqQ4Q351YSLw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726736194; c=relaxed/simple; bh=C+eiBjDargBJ4OM1LG70wElM0b1QVFYWDeO4r5FGLNs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=PjYVrQ/tqYvNoP/OUFujggd9zi4daYkHZBgrm6oglROBlTATQkWqTFxMa/eYgSLa1WqcdqexO72LR9DoclzKquR2EQsvlhrrMQZQ8me8xnNBKvbLlBAjslxJJ3EPtzILIF09Kmi8S9p/WxgXMFdvmpz4i4PoyWL3nZEhmFW7TzQ= 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=nBcRyRHt; arc=fail smtp.client-ip=52.101.69.71 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="nBcRyRHt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LoJZzkCerC2tzd25m2fczTfaF39eNNeYZUk9TTuaW/HyAr0+vPQZYdzWlbmR4BJvHyFixVaNSA+/0ZO/2TvWV3+6kjaEuY1aUVoIol87A5ha2dWpYQJvE3IrYEHv+UeQP5SANtiP9oY9pIM8VVBr0zZViFCxjJHvb8lEIuV96MGS33XiHsZFpc3IDWyvPF79eQ/AT+DEO5uv6vUcGTsWoLPbxWD12m5dYsf6l2btkG0dV1jCdunVZAGN/fA0Ab/t0qIY5+spukwSy0RVHdF+wR9yiALIr8amlEI4To+BXofLTu6unbe1u9aQuyCWrrEcgbn8W4DVBf+Wy24LRKdI/A== 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=ZWfIGcFKLgid4Cx4toHmnsPKQkybDSu/i3y6tw5J+U8=; b=N5qsXnt/CGR531ESnb64IC1mEvegXxopPJyRnEctPDjo5tWddSvoy6HWT8KeL7AlM87mwVU0Xzk2iAvwWy3WHidH40yL9pqKcwAAgJuO9kQ6ikOxZSlYwFuKyyNcRIQR7IKg3nwbANiLVr49qZ9qMcn8FxgsaUeelldUxHDdeZ63hsg7d4jyl9ktOV3eY/gcjeadQDe85M5rAMFDwVylc7EWKr1a7smaiT6wkVWLovvS0lf8nJJEtOr7ke5yPKTuSQxaCTOVFRysAEj28ze/PtpYUM10X7RkwwUP1G6OfGQKbrbEuvHwmuAB+4X+TiYnLltLSbreX42v4Tv65bM9IQ== 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=ZWfIGcFKLgid4Cx4toHmnsPKQkybDSu/i3y6tw5J+U8=; b=nBcRyRHtrlFETWUm1itAqjwS0ed3x7qqjavls+xB4NPNtQggYADBw+9ca7z2nmGi6D3wteTJK2gRbAEU1cKI/vO3tr6+nbtYGLZvCOsQl3O0Kw9X3swVozJj7AZnpLuiBesiJezFeD7ErVqZ1KYQovPrnSLyStU6ES1qzx/ntyRGeM/PbT6+gNTq4Q83xJUdrVP/Mt+NjJR/8qpPZw+oPWsG/JECqN7pZYWpA30CypwjPejUHb9ktAbQN4Pmvn+4Y7yz/ElCEoK55XCuJ/YBF5qX8uCfKUz8SgnYaUxAM6p0FFG6+5lZZbe6R2wa61fUiwoBAXgJM5/uo/iEH3hkWg== 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 GV1PR04MB10242.eurprd04.prod.outlook.com (2603:10a6:150:1a8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.16; Thu, 19 Sep 2024 08:56:26 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.7918.024; Thu, 19 Sep 2024 08:56:26 +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 Subject: [PATCH net 2/3] net: enetc: fix the issues of XDP_REDIRECT feature Date: Thu, 19 Sep 2024 16:41:03 +0800 Message-Id: <20240919084104.661180-3-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240919084104.661180-1-wei.fang@nxp.com> References: <20240919084104.661180-1-wei.fang@nxp.com> X-ClientProxiedBy: SI1PR02CA0005.apcprd02.prod.outlook.com (2603:1096:4:1f7::13) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|GV1PR04MB10242:EE_ X-MS-Office365-Filtering-Correlation-Id: 403dff20-28fb-4cd3-127a-08dcd888f1dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|366016|1800799024|7416014|38350700014|921020; X-Microsoft-Antispam-Message-Info: xQgYx2BKTjBmJhib92+rg7Z6ZCSkBIlIyY3TbpAj0tax9OPrMtoLkIrZapk7zZvucwHFx+vztwgd+Pnyu6NOeQ71eHYaRuLrEnfB6vj90y8aKOJ3QC0KceLJQuHG4DtaG1FmxZ9dqbjbtsrdYN0c6Wb85NGJE4/TZMOKYHmyJmLNyGlnhb/tqaksf79DlMLuZlSDaO0VOVemTgXCvqIv/SDh36AVRiNWMXSbzb7jquJ8ZuLosNH3rLVYJxI0uj5ZzjElRt+1D0ckGA1QtDptIPvFTcX6+5lRAjniK3IzPWYDcGHNkXTkXbEH70qsPdiS2uypSUGTU0Z4MoqwrJ8rvyiC7lZVMzw/4nQS0dHRrgfqZnqQA5r3Hc3gkGGdEgsV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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)(376014)(52116014)(366016)(1800799024)(7416014)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vFCWc/rMzFN4JjlIWOaEe/P1oZkGlyPtWoMgQos9Fm4PcIh5AMLK0BdZqUpKtMr9TcOdHj9pXhtCQSLX58QE7NoM5Gh79OMapFiSyGsIlIm7ISZefTfmBykW/HrwRp9LPnOotciLoxKVtzAAJUtJFoNLx1e+73dGsipFj4CLHQRz4rsYX0x5A2xZtMKm7FOOjrSpsWuqZXtUP5+7k/yXjD3U5j4SDOmlyMw1gb35fQedE0x5KsTaA97+/S5XkVHkCwVGl33r5xVnLQDlSim74tuzcl3WJTh/nqarcGt0V/ldtnmQKEjqwNFdabcMbkDLUPpe1h8tgljBtMsuBJicJnyN0UefFlQpw+8NQYxqBokb+IC1hTO0mDB8VwCQOvrk9i1A6uVQmPIbyiwzLFN0GOATWvLu5vxbfYLcYnpqgJuKRfA0wYdoVNkApYrSIkTzFzRX5PEJldsjUruyQwTqqzPC64y5FqxwYYShRPyNbIB3cJeQFeDpBYTJ8VXpOGL+ELVvN2+WwI4PUwIRo5NkTc1K40VhSvdCrRE5YHBzCII+C7jqibF7a69cggqjl7nfVcq8YRdGoeSY34eg8+tiWvrxrkDbE8m0EecYB/7S0q4MsIk5SUg+gLrLVIBkmGC7mT8gkTg+ALrhjGhfHiw9e9mhYJXw6BAE00zE/r//IjdplrIzuozX26xeAxwhzHV//cjt6xEwn6iAX0ap3lEE1g4Lo9U8eeK70c5+anIp78YTEluTwiMPrARcDVCUxUIswWUap8DcBuOE6SnXk1EuY4CGM5FAk14RbxR6zYLCrblfDk5sqE0vr547y31TvPrFgaFpeIuAOfnUxDnv+A5vTkLMRmcs3XZdwjMmHR5P3kGFoyP99YBScxlFLXt3qgWbUNk+mpE1wqseYfH56b6cDbedPBLlFjdfXX7qZiDCZOgQf9kdxtDUADX9LWO95Vvj59TZiGT+z1WchB7g01QeboTCi/UIa2T1utK/NWtFbkTJC/SDjg6htHxYpZvjg4tnMJROYQF3kmvDp6gNmUndx4hO5WWkW3ABC8sFONBfhQEAtgvzPvxI1PeOYMrs8kwBbpvDjOTCnXqHNhIc1X9tRBKRJobpIwsQ5Scl2Cuu9rAiYRsvp9Pke8477Poyr6EahpRz5owM8YaeWU4kfXWEJPN8zjfzonTcKFCdcnD2vRWT1UnDWeQj+FAt0Cncg0urwt8LPpTrVRQP2jk7EUIxsEqpW1s/Q95JiF7T/1UjQc9FT356y0mPepOu/y1z3y0+3TzGpScYKOLPTn3t713Is6J3iVb2F2KTzcqOjxG6bBYLi4QFtcKpWhe/3lTMKMPP1Gu+3qDSKpe6q50AMAEpt9iUtghlZ2GKwO+j7kOqE/SppbWqBqw02SS+Elyzjsg9r3Z40NhivXmL4ZuiQNM7Uoz6rbXaUjlU5oL2KvfOcuRBIByvpfApfeWs8j/lHEM8CDIeeLBcl52Iewb77ROAnHSFWEQ4anFe+DB6Jzn3XzccZckTGubU4SbSSfi/iC+SyqwNhVKc+69X3Rr9KOtfJcJCPZf8kax4/E192az8ZN08L/uNrPtC1rvPwhj0km+9 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 403dff20-28fb-4cd3-127a-08dcd888f1dd X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2024 08:56:26.8444 (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: sp5XeBLpcWd5s8+l1DrKbp524CSA6/aKDOmIEjICBK5VbcOCL2dUgq/QyGx2j05NDQt4WCefCg317cZKR0vQVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10242 X-Patchwork-Delegate: kuba@kernel.org 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; driver 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. 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 = 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_reconfigure()") Cc: stable@vger.kernel.org Signed-off-by: Wei Fang Reviewed-by: Maciej Fijalkowski --- drivers/net/ethernet/freescale/enetc/enetc.c | 43 ++++++++++++++++---- drivers/net/ethernet/freescale/enetc/enetc.h | 1 + 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 56e59721ec7d..5830c046cb7d 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_ring, int napi_budget) 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) >= 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_frames, int xdp_tx_bd_cnt, i, k; int xdp_tx_frm_cnt = 0; + if (unlikely(test_bit(ENETC_TX_DOWN, &priv->flags))) + return -ENETDOWN; + enetc_lock_mdio(); tx_ring = priv->xdp_tx_ring[smp_processor_id()]; @@ -2223,18 +2227,24 @@ static void enetc_enable_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring) enetc_rxbdr_wr(hw, idx, ENETC_RBMR, rbmr); } -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 = &priv->si->hw; int i; - for (i = 0; i < priv->num_tx_rings; i++) - enetc_enable_txbdr(hw, priv->tx_ring[i]); - for (i = 0; i < priv->num_rx_rings; i++) enetc_enable_rxbdr(hw, priv->rx_ring[i]); } +static void enetc_enable_tx_bdrs(struct enetc_ndev_priv *priv) +{ + struct enetc_hw *hw = &priv->si->hw; + int i; + + for (i = 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 = rx_ring->index; @@ -2251,7 +2261,16 @@ static void enetc_disable_txbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring) enetc_txbdr_wr(hw, idx, ENETC_TBMR, 0); } -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 = &priv->si->hw; + int i; + + for (i = 0; i < priv->num_rx_rings; i++) + enetc_disable_rxbdr(hw, priv->rx_ring[i]); +} + +static void enetc_disable_tx_bdrs(struct enetc_ndev_priv *priv) { struct enetc_hw *hw = &priv->si->hw; int i; @@ -2259,8 +2278,6 @@ static void enetc_disable_bdrs(struct enetc_ndev_priv *priv) for (i = 0; i < priv->num_tx_rings; i++) enetc_disable_txbdr(hw, priv->tx_ring[i]); - for (i = 0; i < priv->num_rx_rings; i++) - enetc_disable_rxbdr(hw, priv->rx_ring[i]); } static void enetc_wait_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring) @@ -2452,6 +2469,8 @@ void enetc_start(struct net_device *ndev) enetc_setup_interrupts(priv); + enetc_enable_tx_bdrs(priv); + for (i = 0; i < priv->bdr_int_num; i++) { int irq = pci_irq_vector(priv->si->pdev, ENETC_BDR_INT_BASE_IDX + i); @@ -2460,9 +2479,11 @@ void enetc_start(struct net_device *ndev) enable_irq(irq); } - enetc_enable_bdrs(priv); + enetc_enable_rx_bdrs(priv); netif_tx_start_all_queues(ndev); + + clear_bit(ENETC_TX_DOWN, &priv->flags); } EXPORT_SYMBOL_GPL(enetc_start); @@ -2520,9 +2541,11 @@ void enetc_stop(struct net_device *ndev) struct enetc_ndev_priv *priv = netdev_priv(ndev); int i; + set_bit(ENETC_TX_DOWN, &priv->flags); + netif_tx_stop_all_queues(ndev); - enetc_disable_bdrs(priv); + enetc_disable_rx_bdrs(priv); for (i = 0; i < priv->bdr_int_num; i++) { int irq = pci_irq_vector(priv->si->pdev, @@ -2535,6 +2558,8 @@ void enetc_stop(struct net_device *ndev) enetc_wait_bdrs(priv); + 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/ethernet/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 { enum enetc_flags_bit { ENETC_TX_ONESTEP_TSTAMP_IN_PROGRESS = 0, + ENETC_TX_DOWN, }; /* interrupt coalescing modes */ From patchwork Thu Sep 19 08:41:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13807527 X-Patchwork-Delegate: kuba@kernel.org Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012050.outbound.protection.outlook.com [52.101.66.50]) (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 BDB6F199FCC; Thu, 19 Sep 2024 08:56:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726736198; cv=fail; b=O3KgG3zhnqvF/Q4eO5/2FPE+0vcFTLU+rQpmLV9yb4b5UmE9AADej7T9X3EF9ey/CLrM2ANy5G0xVks/XhCveuNq9uuEFQ2l2Sjd5O4AA7xA9FPcinvmiJHbhgAedSHipuysWE62jzwQIIBC4/l+aEGM6SHcJeVV1WTncDjs0cE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726736198; c=relaxed/simple; bh=9Rh+rUmzy0C7oq95npDG1YWIvHqAMKFRjI3hPK8DO1M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=sXd7wIu2mlZvZeoGWoU+Yy1rzwqdVdTbInu3RIQ2Ya2M3b+sgP1AmJnZYtUNAEcZJCmP2jjcXkGtx8lpvY2dnp7tenmpjSlDh/nIMWaKrRrc39nrfFqJZgT1LPqVX4Uog+FUZOhx/UFLZQGGOF0CmvClAQ2z1HWKfk3qm2BMS1s= 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=hhPVwu03; arc=fail smtp.client-ip=52.101.66.50 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="hhPVwu03" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FtQXnUoRIi6BkmlNPEUHEYPrLpk1ijLa+v8ZlH4yy1bkesM5CTLwQiQeaWJjmvpBGDGltRPKQ2/BEFnrvz3nIrgTtnELlGc6iZhQ25GKWgURVqi7tf7AI/wSGVgFiD9oYMRlh0n+zLYoP/OzYYlKt+IH9S4YINnXeIj+gva7JWmGOfDNugbY/c3i2frelQQj3+4k9neGlljxvFB4ss2PeaD3W82/nWNyL6p2in+rtnR7D8JPU501CDGby7DrTlOeHdUemG8gr1be6fGUTB9YmwpV4dr318tHPDPtMrM9/GK5o1uclrztW4iczoZHo0BNKQIefoylJdsBwLRBnfgH/w== 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=rXqv+sdVIr3z3O07cuBTJ+KGD392tNhRET2iee9VYFk=; b=lrQW+g9qvpgCeWsEt4wtwl6hfcaFmU127fbIgm9ypjoPv1uF2wjUfniJB0RvwSgI8bSfCutgw06vYm0mR5BqGKqB4x+D5ZxtaOpwwqxAZ9SDF57+StRTztOPZmEJ8T2sicOhg9KM8XwM4bgatVw9Fails3+u5lvwfODX8OJdaPeSeatg21oF5jdvcx9SMGbH4k3H1LNPlPKVsagYJRe2DXcxB6mCMBYtMxyW18qE7FmpSopNkGybsuOE0hNju/qV2ityB5YPO88bk5PZ7ai97HN5cwZKgvwXHTghYpSR5LnIs2JUVzFFwG615f6FF8nLylzXmz+APGGYO8Tb/g8OJg== 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=rXqv+sdVIr3z3O07cuBTJ+KGD392tNhRET2iee9VYFk=; b=hhPVwu03wSfc07YE8VXN9xrAc/igmqEcsDI2VhSJpWmFuKHTlaSzhnHtg97DaYA/T2/31kDz7n1y+EP+GUHSSm7PQd+RSh0UBVpm8rNkTqktWD7iQho26ioMgZF0yC/RsoO4mYb11i9ml8fwjTINDUfhXk3g1MwpfqjMBxzfc1EslRnw4+gLreIVHeP0z+tQUcGkQoxcUTVuOb9vRcg6ShQZzpO7cB6adWU1kXmei6QYPIphDzkLN6rvNAv+aun9aBd/vMocDo67NqCJ2YAtzXrsng/l9ENP6GXWl6gxbyCwf6X2tRmyZBrMgbZPer14LFXhVx8JMJ48C34uSquFsg== 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 GV1PR04MB10242.eurprd04.prod.outlook.com (2603:10a6:150:1a8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.16; Thu, 19 Sep 2024 08:56:32 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.7918.024; Thu, 19 Sep 2024 08:56:32 +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 Subject: [PATCH net 3/3] net: enetc: reset xdp_tx_in_flight when updating bpf program Date: Thu, 19 Sep 2024 16:41:04 +0800 Message-Id: <20240919084104.661180-4-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240919084104.661180-1-wei.fang@nxp.com> References: <20240919084104.661180-1-wei.fang@nxp.com> X-ClientProxiedBy: SI1PR02CA0005.apcprd02.prod.outlook.com (2603:1096:4:1f7::13) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|GV1PR04MB10242:EE_ X-MS-Office365-Filtering-Correlation-Id: 12ce09aa-ae1b-4ecc-6591-08dcd888f565 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|366016|1800799024|7416014|38350700014|921020; X-Microsoft-Antispam-Message-Info: jAq+TMt2opBkoJEEw8D7ZT0w7NyQKRrsm82BuyhnnVbFv6g50Igub58OgOMxZenOD4xA8EoabV1foqACGzHicsx+iv6cji7LQNCF7J/eNpnpAYsmV5N5u6iw1XXwYyHj4sd9dw+DPNsAfym1p0ioQw7yypL5QXIOjZW1MxkZ1ZNBcuq1iPJQ6MXX/eAzvoPGv9QYgbQzn6Fjgm8xE4JTXjY+j9ybKGmT5bwl13IKRi5usw68Y3oVRCywRAHcvnlnrxtGgRbaObfSHad+C3Fwx4Ow/CVGebd3bqPalwZFyGyt+L/vfuLg0lzI87bOMkqHqkfPieaXZ02cwQuSvsAg8iSUFywKWiY21r0YULBVYdla8tqjeSYgvSwUn55twOqPkbnPkHU+eRIA4KRt1wX64LNHJpBnM4CKlNNqxA2SwgMS4haeGj3Bip0KdzBlVdrc8rbHwouuRPfCaYMrRtDVc40ggeyLlLkZDi1dS9/mlQg7E/zMlgBFUyJEVGDecg+sbF0Vk7i0iibRRGZO2VS1wBNgvxaX6elNs2N0OK4B5NFlf78HiWtJGGxQoe0c9evCpVdPpzIwpuIkLWvN82g1KLbrS3DzcaSZL50D6UIC/iO0Z4TWtdtmJz/FsgK5MZswbsKqBrf9a1gdxqmtOZb9dq/crRTcLSTwa+zFewshCxwu8mpYwUaJM/0EQ3O+K1nqYG8xL9Du9lpJETyyN/LQNyaaiaQYtDgw22q9kBXrsrdGYw745bL2af9U/rigYIpSKmGscBSUFHsdqxW77yX329ulqGCrkZdo2j9lhWdxn53wsChjEsCtO1WrzoBo6J0ntSbDyc6nTQWZeO/KGUO8G2V7/arEo0u87vUjAJpUU4qqrtczQQzFo8yEmAvOsqOH+iHUsvgi9Rs6zf2MBqa08XSXwkVi/gCyxGzwm00yodGrcJue9cizPhr8KaiBbKL6zHyA6uMx5SBJBdUusHzfhn8f8WRx7Yc1HMz/ruhUMFfVeU3MRQyHEZqP8BNSAT479JrJrIG2lFxZG8xEqLoiG2qfgkmW+llD9CBNE4+wUi/oygzeijRm1Tmk8V9pE59FN44w+I1JJmhJi2H5y0gH934SnjPLLBQ3h6dex9A7xwGXu/Jr5lvr9WCujlGIk41rTzD6FEUYuIF6O5i52DwJOB9R169eXqjcn1RfGGJySU9c+86fSeMh5/BrkUKw85biZQTsr0N6X+shKEjEcDJRUl0jbOC2IF4VPbgjRrVsq/Br0Ps8z8Uiykmqz6yf9xw9iIamkNSnL0wc+2F4/rsfjt4wVlCEdrBuRs8EYoBEZi74yHZX5J3sVg7Pt4Cgfx4Jg6dQH/mhaez1eVVODQFGQHVfCZB5tVTxbLJc/tcFgFA21h+1TAJgUTlvx00xvqiZ/UQgZiOWUes4coYWEIHASC5owhCSyt/siARl3+W8mlU= 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)(376014)(52116014)(366016)(1800799024)(7416014)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MKfb1jD0GxF76HMZ3pUh+8360jO6Y5Cs0sjPwHoG505lY0dLQhPbWCyvfakZHUN9nVqSYlL7Px2pS7Cw/OTPPlbVkg6A5Fkk0+rURsdmj9W3oyipTxSdU+yotSxaH2Ywb6JZ3A3VPE08pV0f7aOmYHNBvEF58FpZv/DuoNrgIPuCFfaksZd93rlRYzeUnhxUonpOXMeokE4eOF4N9enrM0boxUQE9hG8Mm3RfDTksooG2jEiFuAtikfNxnrhhx/WDm62j/kRckwRchVZIf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sMgakVvlP6reICGf+IKqw/fQ076t2jnrUYp/LPNkjFl3YJW/Fz9+Q6r9dyxurAy4NSaFvWbmQD2TvIFPeUu5eKy9QVVdy5SOnDnNdvtcF1U6B2rgsiQeB1E9vRZwEVdn0HNbTlmc6aaa+//7Z3/90Ff1hQ5Ti/mMQcHFmXN+4z1Xi7fx/OvHhqUojhRrSv85qtYqNkQ2XiZvQrqCEhWTw7oIHArh+im3ei3DSnIhk9pbFTgWPKo/20y13jjMkQOaaVJ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12ce09aa-ae1b-4ecc-6591-08dcd888f565 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2024 08:56:32.6610 (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: ECr/6kdHmRrmkfPiY+raD1YKCoiHHteyr8VZ7gYNIINFvYEQSbnlhKhebdm4gyIT1/tCiQ6R/sNITtHIWAiZyg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10242 X-Patchwork-Delegate: kuba@kernel.org 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, it is obvious that the RX BD ring has not been 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 maximum value of xdp_tx_in_flight has reached 2140. However, the size of the Rx BD ring is only 2048. This is incredible, so checked the code again and found that the driver did not reset xdp_tx_in_flight when installing or uninstalling bpf program, resulting in xdp_tx_in_flight still retaining the value after the last command was run. Fixes: c33bfaf91c4c ("net: enetc: set up XDP program under enetc_reconfigure()") Cc: stable@vger.kernel.org Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/enetc/enetc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 5830c046cb7d..3cff76923ab9 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -2769,6 +2769,7 @@ static int enetc_reconfigure_xdp_cb(struct enetc_ndev_priv *priv, void *ctx) for (i = 0; i < priv->num_rx_rings; i++) { struct enetc_bdr *rx_ring = priv->rx_ring[i]; + rx_ring->xdp.xdp_tx_in_flight = 0; rx_ring->xdp.prog = prog; if (prog)