From patchwork Sun Sep 29 02:45: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: 13814799 X-Patchwork-Delegate: kuba@kernel.org Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011067.outbound.protection.outlook.com [52.101.65.67]) (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 1449F1E493; Sun, 29 Sep 2024 03:00:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727578846; cv=fail; b=LsNS99bJAlOWuH7rGuwN3rDGhQH/WIoJMVwvXICTYUvfFGFpTBVPGGQ1SOdmq894iP3e3A4BTIdtwbtS7lPhZB5wPS+8t9TB4sGlJHECGB6sLggRIq3gFT+PpSzsi/8d1C35CqeWiHBcU0NQkiicd3Hfj/XTPuib0AulxmY/bi8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727578846; c=relaxed/simple; bh=jo0zcjTxPmpgKrrLRu7oOnhbPSzk4/IH5Sk+uHDJFo0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=QcfFcPnfyWqXBx4TN9sBv79jdc8aCSSul3Et3yoUOitSBtqAofvqtcRRd1jHZLxkT1zz0NXiAUyGIK8UKP/GIHBrIjwZP1t2C9a0AR6qOxaEOdPBiBxRSr/XB8WpsWjQc/hR/3xiTebL7jtNwT9qlfWrS8C+UH8b2ky7wurIzwo= 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=BofRoxdc; arc=fail smtp.client-ip=52.101.65.67 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="BofRoxdc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rswECR6QI9am6u3A03rf6cSvu6JR3VoRq8SJwcZxBhbxLD8PAnDJGOkeyMy78++PVMdt5kM0C4JlI2PRPAxLnahYlDCoOALYE/3GNadJSCkXWIzPic/IccysCYwpMMpL+eSSLwrol2noMG1N0d5I6dzVUMR0zdGnjt+11CUShBljFAJba9WrkkN3HHr3QEFmj9Y5Ylplysb7PVHg9IXibk2UWULNLv1+fuhL+YnYnSpwrSjrkaA2RoGcNCxcFqbtB33+Dz5Y5RHfYWc5R4evF87BAkSZK1tAZWaZiNaX6QSOdxvJMX9vbP6X3TOOY2KVTt3SSQndWY7TQ+vnDEFmhw== 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=r3emIS0MbRnOt4rKCznCGzkjomRJ9jMyr6aiq5rceM0=; b=cqp7hRBmQhzLtSXWllnJKGOL3LaaNDD9AjTlH3J1aXE9v6Uh4ifKSzqmIGekALDMImYypxSt/f57BAWe93/cwlfNOpuLOBHCOcxL41JBLAtvtVmWhlKdCwNrIO144XxcB/m6RKIgAQTtnAyPynfGH8EBFXahxLg8DRp7xOx4Qwkl51uOY6Nib6GV7gF8jRdBuAKHmkNz9f4DuM94gWo2eSL6H4mMR2N4/SqVJY3c7oANbgrdTKGx/32DF1HNS5Gyu+6V5oEDvWc3Q0DbFurINnUrObUvjG6jpatlCK5G7TQOIEbLnxE1+1R5XS1cTewahy0+Xu2aXikjlOxkUwL63Q== 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=r3emIS0MbRnOt4rKCznCGzkjomRJ9jMyr6aiq5rceM0=; b=BofRoxdcZgq2ikEcjJuw99n0Mi2oeNdHev1AWW5NqTBI7JMjGOQDSm09PGUtnEqkHIqnvCKlNOpc89nRsNB+tD2DlTHkqcYGeCWL6eFrdypGq2OeKltRredRiD+4qbIu4FkYuQFoIKJBwzNo3bkFmxUyUaI1rao5VHLgHphb44dmL67yrLtlQstHr3YKR00xfPt7MU/7BMO9Gls8RBlfN21oGc+eQDzKBrluq1m/S9RyJyU5KvepXLcnYQDaWT/WBRPOVGLCOPRLgHh4rt3fr6ymJb+Tz8kpQeDQ3y7oc6CD1JLMmWq0YEeVj8t6gxGkfNQEO+hKbR219qAMj6v8ig== 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 VI2PR04MB10690.eurprd04.prod.outlook.com (2603:10a6:800:279::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.25; Sun, 29 Sep 2024 03:00:39 +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; Sun, 29 Sep 2024 03:00:39 +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 v2 net 1/3] net: enetc: remove xdp_drops statistic from enetc_xdp_drop() Date: Sun, 29 Sep 2024 10:45:04 +0800 Message-Id: <20240929024506.1527828-2-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240929024506.1527828-1-wei.fang@nxp.com> References: <20240929024506.1527828-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2P153CA0025.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::12) 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_|VI2PR04MB10690:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f019287-2f13-4fee-17a1-08dce032e5a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|52116014|1800799024|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: woxNXBCV9kfIqmY/fUzMc9ySQ+8Xky/dWlcxrQmBmFPjTK7jDsY3ImAD1bnd/oFppIlXVYdox86o7QqmYY6f0IfGoyD1sl46xW6swu28MxfQd7otN3Vt8w2l54yUIGrnYjtQIN0aIUo74ka//7DnovM/BXAAmNvr3JyRsx74KVoUsxerjJOT9WDQv6bJvQDXuPTPIlum7zMU8bKLVvlUgAnnFthyFAy8vH8dD7kGS8H2VxMW+dSNRIeDm/4Sm215etkSNGSqquZn66tmSjQeN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IYttd9t4SR3d5Lst8lU1nLOssAgZkVvRNLFn6fTL0Tx/e5NeDTSrKLVSPBUfPHdAVqJFsw6DKFeN9BvVDSfyoGHolXmojQMfN/SzCnvIBdmKcldJy7O+1kG4aajE= 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)(7416014)(52116014)(1800799024)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ppi+iUQmNy5C70NVAQAfjHtb3PzczReNhecSNCz9PuvyAdLjobVHuYKnRKYtbkEYbFVcu7G9z9ckT0Ie9YVdRUL2tOze1xPlKYRjfgSwKSoDFZGyjKAdfVmdwf1vhwBiWOUudfupHzdLrTYoCydx7EbAC8q6GdJ7y53o0SA1IbbOAPs2+iwZ4/s6mtt8tA8hMjqIYfUPrktFHHA2ofwkBT5nDeUuaU/Kk8swiE6a7saxLVoUjSLe5+AxdPxr7U0pvk9nYi5+qZfFstSXvCB1jrPp27WXb8hrbfz36PolwXoPZTakeB/J+CZBH6TBJCpHSLJM8It4huOnmIotlWqELZ1EyEVRI7DccnltTZBdU5iLZ2YqGrC6BMxn3z2N0atnwLT5uPPbE6DXBoNaUzAX9ScdJBZaeeX4ytyIHSC93Rm2IZNwzAqk/hWh4bNEl7Z6ryWpgiExtUmS6GFiHZVLj4JkVLwFLIMGdqsBz3cP3Kz8SZxfMS1zW9/HRXQtxRwcoWeByjbIBX4vWbPOYUr2663nW2F5VOe2YgBDtJImEE6t3wHETCAEPUq4QMwQSTbDfRnQtsVsJ2A8x2w8bi7Bc9w1ppXD8ii/PRVXFOOysLzsVcpoWsU7tp+74UBuUCjIN0sLBZy1Ln4MbdWe58ZFusK7zhrYL1FtKBg9dhC/jPUkV1RKDL6H+l7P+u/CYttTJG1BVN2IMhrJShha04BH83ljmjAlrujcxLm1VruxEO+WonG9gF3SyvSu97ezCCWVfRGRGPnlzEgPXF9U5/KM5mnoLujISBHHMhpGbhc56LKwAFZPFaPiMFElWIJRQ8J5LHhc6sIFKet9eNa+T84zoS2hpfGCX+kaY6Js9QY173bXqd3EF+2h9CsMj0a9WXazZMjt6/SYYP1JqsekpNMLGtd58akvLouiFm98Z1DLXnPgzhrupzdchcL3GQla2TAdMuGWntQHQL/MpCoVLAD1qDDYG/TW3a4794jkvkINfQ/uj1dXwt9zGd2llFxxc16tebYF3HzCXo8M26A/us6Uy244A4/YFUV/26bHoWK517BV2XVEPQfJVsSrl6DnnzUxXfe69+X6AleuMYf3noUNFt21qFheO9qWSlSuZhdRaWIc9ZAg7o6Kg2vV6q1TilCnlQEMmlAELQnqillvZCTymVLjELUc2jDUwMzg/t8vt2/E824JbTfA+/Vb6JqYl0Ggg39qEmkqTQERp3rEq5UNYtDt/NjfGtzne7NJVBKIFKG1ReN2+kEzViguZQbDVuVHYN6xgJJM5X331mjTlzsYoVQJ3cApOZq+XjXcTB7YsTqq1qXqbr/TFKYv7GTmewt9Fpd8kZnQx3HGmrhVkiIv7TDAuJ2PrjIrM2QwGDmsb/x4tgP3VZP/KijBLFiRuSFwslMjIbAjOUaOQeiNC4ZnEjjCz6laDr2JS8HGqSAqxv70llB0YhUMRB2H2Yr/VIK2aX8wtEIpxCnXwnwjP0j+fyKpr+ZEJZErFH8Cr1Ng5tMqXmFeLIpMTt1Lq3a2R5+3I0RB2I9I+B985eN/Fyd6NYPrLrKyCtIxXLtpAiE0OZLmEU0XLqmv6pddOcg7Cfus X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f019287-2f13-4fee-17a1-08dce032e5a0 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2024 03:00:38.9119 (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: Ys/LEiJCL4fw2+Ie9rxY+nC9lljQoYm68hjSziaBAKSp6I9WXqrWRapKK4KqV22wfMwZ3Ak2H8pxxeA1yDK+RQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10690 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") Cc: stable@vger.kernel.org Signed-off-by: Wei Fang Reviewed-by: Maciej Fijalkowski --- v2: 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/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 Sun Sep 29 02:45:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13814800 X-Patchwork-Delegate: kuba@kernel.org Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011067.outbound.protection.outlook.com [52.101.65.67]) (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 28C0729CFB; Sun, 29 Sep 2024 03:00:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727578849; cv=fail; b=C13uGNcbTWsL1i4dwHAqikSvpeLv31v1cbYYluGschSxrokykFiLgI+OpyGcYGYWANvNSsdbjnipNuX+NaBCtGodA0yNbxTe2tKjGMGQKW8q6HZsDhsC0+hkVlZef8+qdY8/ZeHioRY9zNSXRI82t952Q7t0IOrUtWc780Kjkn0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727578849; c=relaxed/simple; bh=Dt0DsktHw3T9HCoveP76x7M4ForUVbak9L9RgESctOE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=hsPJKWSYpheZ5uh0/jI8dRijA7Tc1jG+ixGLCHL8Z2pHMRTjCtNq5Ik9JgX9LADSHv+1LRiE7FYZ5S+A15fkSCS8ZLlfaR87zVNoQ4v6LOBbHJNxWUylKioV09TohkmWw7V68M3MgRW3Ve868NdVlPfriXagdT6yU6Q/ymh0vu8= 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=TUTIHQ61; arc=fail smtp.client-ip=52.101.65.67 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="TUTIHQ61" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xkHKM2jNxBWZfeA5cNtx5/NlKyqBKZMzFuWt7b0gbreRMnYgyzWH/Xu1libpPaE8zlIHG9c92K2Zd8eKOjpbYaS1auVszfYZcq10UG/lLALqM926krHl4XfK41mw5Z6JdF8glwmBVMdwgz9y0XnuHM4fhgkCcEnJD7XtncIrUnRgFDk2QFiah3wT1rqoe/WLEuk848jmS3+whX+kN7N/xlb0VN15+fO1r+PbH+V/1c1ZA6yGym7kbGqFgW6b23tfNSROEyXbZ2Q0m1LGO5tvO87MzVFj94UgFwhFXSTU3LXnUGmIMeMhBT8adq8wOiV25nTN5qmU14DiAM09nMAHwQ== 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=y41x+Ww1ZCQDuSCxCKrcVKJipkciLJZIOVGdc5fTRIU=; b=jkSpRYlzMlDTChW9bBR1wkBptNUeMcPFIrnSnMR0pSufBC/DCEAMFJ/ez5Vs9LlCeQlNGzddCbLDJEpQ/LaTslzFz/3HEhwXNb7WVfZ4hz3gqOWnmJFu/ny016l0z6mS/PUW2Znm/4M4BCJtWKcIldwT8MEjZGbQ6SZAfhLQjVqT80hR5BZoH+pEF8JmBZSB1mApQR+t9nwyPyepqXUR1cA06PRLKDBkfZzwG9nTwh+rhrSUp9Xp0GgbhG6anEsBJ5RoBQvMVDQJdLF0Hh7mgdtM5ZnJ0tE0Jld3oqsl8REBtfVKnLjOP5zR/z3k5Y3bCrqe6KzhYXI4yA6pzGAIzg== 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=y41x+Ww1ZCQDuSCxCKrcVKJipkciLJZIOVGdc5fTRIU=; b=TUTIHQ61QXgZbvP4MkjOPvk3sQ3p2wweNCYXcNYRGkXkTun+xWP2lnHjrD5CRLMJz/Qxmi3P/AcDbNYwOvmAlxFwx/sa9V6ZnK0NmQpm3IKEkPi9ZzbXyJhn8DNS9p564QXWHUdjZ8qtN4Hc/sCa4WzOQeJBo7uYu+hYyTSSagzNMlEVK4itQWp1QE1yhgON94tR63RMjiOc2DpuohJ144ULUhfWRzhul18yiPD9EL2CGiZj6emLjRhMkdk6tLR3viKB8MO/ZjWX7yJ3KEQkpni0UmHFr4zOcm2HMwpa6glbIFSj8seG1GQl6PtPuxZfoyk3PZdcKZpTQCft5DcyIw== 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 VI2PR04MB10690.eurprd04.prod.outlook.com (2603:10a6:800:279::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.25; Sun, 29 Sep 2024 03:00: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%6]) with mapi id 15.20.7918.024; Sun, 29 Sep 2024 03:00:44 +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 v2 net 2/3] net: enetc: fix the issues of XDP_REDIRECT feature Date: Sun, 29 Sep 2024 10:45:05 +0800 Message-Id: <20240929024506.1527828-3-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240929024506.1527828-1-wei.fang@nxp.com> References: <20240929024506.1527828-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2P153CA0025.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::12) 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_|VI2PR04MB10690:EE_ X-MS-Office365-Filtering-Correlation-Id: ed4a3041-8af1-4479-3e1d-08dce032e91d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|52116014|1800799024|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: Y77iRpOWN0jffu5zLese1YOF0Lnerl+/PJe3w9wdcUlAaYYcd7ZV4hTdnEV7L/lTVpaZnUWP7A71xFpQY6tfEhtAaD7E9j8wkttiF2hBc3tOABvJ8lmOW18oKspZEguNbaMR52aqnu5KgzXmat/jKr8OVnkrg9YMHMnPPPtuBn/3hKFsf058OX0nXRyeofnPpCwITOc0r+rLARpKNoBlAAPL7T2kJazJD3tLl8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iUfW0Ybmam/SqSATge0+euWsDCYTVvS9HhvyN8PRRpPu0rspHkRKynHYKeGOxNPmbz5gws35x5CZLAZTATQg50eEFL4+a9pjdwzSJEIt0EhYe7/laJAeh1h+PEIL2LKpswTRerYBsc= 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)(7416014)(52116014)(1800799024)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: R2hBmbntK4XoZcYPmctfGfp7vfEEPBt5CET36TieJyFD4oOUENWTR+Q/8LBFCtlS9D8VoTMHfCin48hXEjsEpjquAjHk8KigIeQJHRlk4YADOMJ60NwH3fgLAhHAufD3NH9tLT1bgXDzntNPQOoP8s/e1hmKeyIqRWEDjmp8tHiLFA+2bDqv/XPWRCrV3VJuMoR/eoAqvf2cJEVpXf3dhjk+Cw4m97g20Tqom5S69fEPX2lW+RCcFLU6OjbaGKJH8/yfvGPejbMDqlhLPJEXvL1aiFhNyBlb2GO5hx5QJXsrtD0WX3IZnzmZOINfBzIyLZGgvMcYl2v7gLCNHn4BTAZblifeiH4klffsSMr34xK+AyNazS3yAp3CpUsm428e2I+L2hlU2K/6+nZwVKjYDlP4luMtJ3HtWBt/8DDb5ItEPPmoUgS6IyenmtlvbAM/B8ZqaSGInNFpJVL3gRAPrI6ASNf3yYdN9ucwJk4dlx211Nx2PxvCGj+BCq9Kw6wiGAV7j2KV3L35Dmwa6o+QRAwxNhlppCt0kG48NDMWdZmkzNqmrMjHgmTjjKNG0yO2iy/ysTfl4T2FX6VNM5utjO3RCryueZTI/HE3tMlW6Ik4c1l8NGAjYDqWXikLJlYCCXoIhWW7BAhxPuRJRFF3PZsHtzsZHBzRbYG45IrhF/b7P8BbAPAJjbTXxTv21P9ulpDsVoVnY7QG60z+S3YnRDQQXRCe6KHOsOcAhQvQ4t2yIQpAJDf9iGGLTPH4fjvCGbFwTA6+yF/RSYu4kVAgkUpixzq0Re/pcG3sSqOdhi3jtv0wSNGghKb+v43KSk/ySHP1WKhPcHSrIdt/xeffSWTBoyfbKwLfMq/wiFYMk2SryZtRGQvWTA9He1SLfbxJR4IHAjpUtKprDbb091q1U05z994A5UuhbPfvSTP8oIF00EP/3WOgA4jdUjfjNczKNKoQp4DeocdqikbFbKEuxT6Ib1CVNjnetxpnJAY0zG4FfDn+ftsLZYln/vAQWKXaExb+5FYZnnRzGZfUdMuzT6O+xlvuSnsQqfJPA02R1+eX8ufoUX+uav51lo1GSVPeixCOEluFmgHgmYgvjiMZaXt6K4T2VPU69kJaAWe8AoQjPE7ZqOK+UIzRtPuqb++HvD+juq6ckqV7L06njsfV7nRKN+VCu9WmGkrcmazKEyLhc2QeUS6oL6EVcjnF0NGcHtfnljqOMjPJd8CZXTVWLLNIPv30QYdvDWmcDhikuu1zuNQWZ4OQAYSjb4WuK8nvxs8UJkNKlfFAXGnlgYmzYoUsKgqZEFL5si4VjGR37mL5LiLuzN2MRAAKzI61bhZ+eb5yrWqjsvoOTPxtmgQrsPESx14pWLnRkBQnblSNHTb8+P9SSLHfAhpbx29nwpNcfI+DJtnmcHSeQbvBmiY809wa4TV5UGNsgE/80nY45KIOXPkHemOMgb77SJlJ6grg0lIgaAG5yLebw1P8xvuZ1bSqAxxmWVHur9cJM8xceRKKB9w4QvBV9noVKgJUs8i+pYlz2WUtBqr80ioRVR8mm0wykJZPtYV6dAdvGxUVsO2NRQ9PfdwZmHTCa1udtu5h X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed4a3041-8af1-4479-3e1d-08dce032e91d X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2024 03:00:44.6299 (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: 0tJEz85tUSuB8JejL9mYnU1IdOcEks6KI888iS3tVxRYr+Lz9SYNCKYVTKudwtw+aqVipK8lf0iE/uVmifW73A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10690 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 --- v2 changes: Remove a blank line from the end of enetc_disable_tx_bdrs(). --- drivers/net/ethernet/freescale/enetc/enetc.c | 44 +++++++++++++++----- drivers/net/ethernet/freescale/enetc/enetc.h | 1 + 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 56e59721ec7d..138c0a36f033 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,18 +2261,24 @@ 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_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_disable_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_disable_txbdr(hw, priv->tx_ring[i]); +} + static void enetc_wait_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring) { int delay = 8, timeout = 100; @@ -2452,6 +2468,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 +2478,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 +2540,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 +2557,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 Sun Sep 29 02:45:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13814801 X-Patchwork-Delegate: kuba@kernel.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011008.outbound.protection.outlook.com [52.101.70.8]) (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 7C58B41C92; Sun, 29 Sep 2024 03:00:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.8 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727578855; cv=fail; b=CgJko7iv5zUmBmIwvg++vttA+AS2RnbsydXj0onvBOZ0SKPphiHhbKZRKY7CtMK8H/PhS+raoHZfNHGd1o3N0PrRiqfxEz+HJDyueeXi4qp0Z7ew5r1ADsLs26cgb62qfMU8hfhs2VvXU13zmWBDd7EcOrYcnjesmPvM75jWuQo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727578855; c=relaxed/simple; bh=kzbfzXOJDy0ko4JCER1OHISsxcKN9pL3ycNimm1oQCQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Vqp8bsIGXph7Im0aJfD+T2Sr+WRjRRaELJBro7d417VkSgBYuMxSFt9mvd4pxeoQSRi2xX14GYR7LuL/PY8YtnDcoXB7SMEHNIlaY1P7SDbFZZwyfkIXQFp2UiyAZ03smtenBhDfOxPb9FMNAI2zzXvWWAUOChXZZrmOTNIUFwk= 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=Dd+wTiYr; arc=fail smtp.client-ip=52.101.70.8 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="Dd+wTiYr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LvW/Rtp4feft2aWyErFb1140yHoMwzGAlZZ3PqpCiy6vIzQNZyekwEFt/zO7JgfVCMDORro2H04uT8fUju3WuNMVaa77Lfg18hpB3ybmmxdm+J0HkVcCJXH6kQn9gEKMXobQeGel+tFb19XdB/OsJaV/tZozWTbiKuMs/TbY4aMwaMXotLVVT7ktovc17RtfLk0+7KBDJDeuzt9TOBn7vdtwLJnlOXgPb95aeZ7xiaTTlgSXLoevHvdpS9MzcjLLbaMLaVtyRR4pdPuf2v4/QNbX3MH0hNIfWVu779ufsOj949fQV01OGTzdLWDIprauZ9PE9yN6VIUIACKT11xUMg== 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=nPt+0ixg7wZ4qD0BhhCyiY0zH5Ea5CUHExmy6K11pFg=; b=CNulxPpWn+c5AMtR0sNDw2A5YXss3kwoReY/Czu7IdXPMAHBaA/WddHjOdfeDxhSmLMBIBMeissP3M30IM7J1IqWTobR/acf5CZjteDoT2vnJ051Ypq+ywSq29l99LdHr0XIy1+FapTeoMsilCBi4ZSY/20+JI1jN7kXaDggqiQBqjBUD5/jL8db4ph9MYtxMXuZLiuN4Q6W8WfZ1tsaCb/wMq0+cYDxbq1Q4dlQpCh+Q1tEIEMZuyNXQUfFutrImOzlHoBitwpHmLEquWTs/sHWYNzqG+B3yCJC/2NoDXqgo49NACjXyE80U0Yam9uMGN3NrbAPpu190VjcDb3PsQ== 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=nPt+0ixg7wZ4qD0BhhCyiY0zH5Ea5CUHExmy6K11pFg=; b=Dd+wTiYrEVm68nm/0I9wLcI0TqGSR+4emk839XpBMCVcm9wK2dB1tqGRMty0TrBCnYeKIyBMtV5LYoBI4RKpUN9m+fTDQ1JYlBw5xKz5FwVEZioQj45TOGysRBh/Oa7uy4ufF0wmfJe+p92NDphPbBnjYLkXQskHPpk0Q12qWSBS4hBNI35DbTSbLkUsCz8RxZ4pcMBrsXkaQXSLfRY7g+RLOiDIo1LBSMnue1QWBf1rpJpb9Zu2VuGuXddlKCEypzTVgoStye895RzVLtbnl12LSzmAGKd0Ur1DEaYDFTzfcq61q6U0OKgYzqkGUTx0HcCFR3/1VQgyE9IHYh8fMw== 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 VI2PR04MB10690.eurprd04.prod.outlook.com (2603:10a6:800:279::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.25; Sun, 29 Sep 2024 03:00:50 +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; Sun, 29 Sep 2024 03:00:50 +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 v2 net 3/3] net: enetc: disable IRQ after Rx and Tx BD rings are disabled Date: Sun, 29 Sep 2024 10:45:06 +0800 Message-Id: <20240929024506.1527828-4-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240929024506.1527828-1-wei.fang@nxp.com> References: <20240929024506.1527828-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2P153CA0025.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::12) 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_|VI2PR04MB10690:EE_ X-MS-Office365-Filtering-Correlation-Id: 113459c6-fdcc-4e23-0104-08dce032ec9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|52116014|1800799024|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: osfpJ/J0kb3A8OkwhqaLS0r3OxwEEL8NwTolPSWG95daR8a5tOHfIYTQOB+ukCJAYNSk0Lj8OubWHEAV/MZwh3kjLR9C0Ciqt11ok3c8XtQj3LpcO3PTqMIxUqAImQTDyivWO4NgUzkHanFrEgxhdVrAL+4S17MZ54cai9ujLV/vGptj+eieRu18PsC6xVngqzkkmQlHj8f6/byfWPAR/++1bo54WZz0FoAy7pahcifB8VGRU+htXKr0z6Yd/+RNxdcQyFMQqA3NvAvSmJ8SRVnC3OskBOOWr3y1WajrB5EobZjMUalMjvqG/V9ijIU93/b9Lg/7VHHpEQw2EZVJ9kryp+cs4GNmCaOJzYcnMhqsxrcRNc1Z38hRTL+4MGz8ASnkN5OGmfqWQvFJQxgY2peP+kxnRMqZUy0e8pUEQtW1OS/U9PzoOlB2SehmwuKfp8fA7FdSO9EVhyhmWFtDYrnGQS6JGULupXdHhWWDzk2H7mfVmkdiBsGdgIy3QepwZH1J0Fn7LKJC/IXwKstlLaLRIwyGBjYT3YXGq7F7J3e0Xma6gK4bcVVIwd/UqChJ5LaJAmzZ216uTNg16vwA5SKXnYjInJej9DgjKrRxpqIynH7lWdq/tb9Yf7bbitYwCzu1eN09Scsrl+/Ods0FcdWqHbilIfUPe7oSvuhZAwA4HdmLtQM6GW/3OgD5/+IERFg2RbGEBiIKyPxkH83OcA7dgFutpzYf+etoBSWPTZO4Xi3lmdXGYeRsZvHP3K6+GQi/zr25WoCHew1lvFhE9WMmYxg24qKvWLKZig48M0PvaDtmN/icrnO2mwBMgqJRqSeM79d2GJn1R7/+4BBpMp/JV49vCB88jwOVogvpcOzchvj0zN62fRJEIJDn+hMuBvOqKpcy5UST+xzJXo7IYWFK18xLXGD2xNMeS9B73X6w17xkAFTOiWj8HhZCEnvpIwlRoDymoz9MtDeEmV2ZIEJYp7nNn84OHmFBTlzucWDywd+kXcxkAWzUCJ25NV0/rIqqbZHjQsdZ6vWuJYTEBCs5fBg3KAMwL86onmYxOULHOGdtz22eE1iz6aAccfR2YD7pxJZFJIzqu7A2eeT0VRULaDSNIWtMg66inkamY3yV33el6DBjYK0tj0PhhHjihV9KhW8O/CmjkTabNIzpPE1/uovilwau6Zcj77oQt6l84gQuN8yg+UMRhidUsTCqTvX12y+fpJfNrv1GBXtR17JKIbyMkOGegP0jUgm24D5/gXu3Dv/dwuAToIdcVMix4onrIgIkRAH9utc9LFvW8/nqKS/j/6nI+9YjjA3I7NrLXwx1UEFNPqTktGnn2jvPTzwUJWH4+kvhU0g6/SHlgf+i2aEWEOyd/xNlcEnD0k+vvPGy9GF9AeSrR0TexxPBTKvcWwsqazQohVnG7y/6H2uC6cmgf+aqVz4+hEAYcJc= 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)(7416014)(52116014)(1800799024)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sDP3mdde6C6dASWNUo0sIVUZvQxuUhjfyW7WWLrSpqzuHA3wVxDR4osMwlNeW7ZQ5+re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AwtnL7PbnFxo+quGWt/xd3w95uxBtNYE6k+vbPczqszzxtsqAbC9g/D0hvNtC09nI5dGhe9nfs4F8vwu1U66W/87y/Z7TtgzFtrDwzHgU6Sr1AJSwM7e3hDrpEJ7UrEvp50ZtUg6bBuCBpdr0zQ890m1qtm+vwHhvctj7TxbKxOkVFO/QBSRlNhxK8jbZnbeVfnGl1fo8QBwSsxNP26ZflmtGpimE7DfDWFmQORlQ7kX/LPg8C72JuAnqyujiIihA4/DxyqbHKXE/3bXI7qh6hdjmXc8dx4CZQ3TOKJ47CBNjI0CKZVno+fJ/a1ggzANhiyrOCkomZmP2YjS9bi56Hu9D4/KlGcpLHTsMfjfTLYyBnR6AUfZe3ezu3vFDu+ckFU2WT4CgN35y6Dll5CO9tUGBJ0BrCeAi6Vjsvdg3CF42gcJOB/vdb X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 113459c6-fdcc-4e23-0104-08dce032ec9d X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2024 03:00:50.5051 (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: ZRVIIsRLMOxZCiZeDeCGlPs3Gjq0uXJqm127Bg6dsoWs19RjZFg4TOAYNuUahBDl3c8qSOf2cd38102z+5lT8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10690 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, 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 --- 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/ethernet/freescale/enetc/enetc.c index 138c0a36f033..906f0edbfef8 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -2468,8 +2468,6 @@ 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); @@ -2478,6 +2476,8 @@ void enetc_start(struct net_device *ndev) enable_irq(irq); } + enetc_enable_tx_bdrs(priv); + enetc_enable_rx_bdrs(priv); netif_tx_start_all_queues(ndev); @@ -2546,6 +2546,10 @@ void enetc_stop(struct net_device *ndev) enetc_disable_rx_bdrs(priv); + enetc_wait_bdrs(priv); + + enetc_disable_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); @@ -2555,10 +2559,6 @@ void enetc_stop(struct net_device *ndev) napi_disable(&priv->int_vector[i]->napi); } - enetc_wait_bdrs(priv); - - enetc_disable_tx_bdrs(priv); - enetc_clear_interrupts(priv); } EXPORT_SYMBOL_GPL(enetc_stop);