From patchwork Thu Oct 10 09:20:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13829859 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2083.outbound.protection.outlook.com [40.107.22.83]) (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 23AED33CE8 for ; Thu, 10 Oct 2024 09:35:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552947; cv=fail; b=k4juMEvSqLf9igPwhmQKLgqK5Dvxa72ltMTtPkVKsOkt+wzOKb2dz8/c2SPpwsf57t9ma6sLh2nCjf0I2gptEorv5YD2Que00StUcR+XyTeJSr52waYz4fwr7y9LKjpv+3+OOeLiRwTg4QSGUTNIvKkTYqq7SqQMEDhrBIXf9rM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552947; c=relaxed/simple; bh=BNp1PPLf7Itya7K86iPb9MexCuPDtFACR9SLTG5S7Nc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=EfYQVdoKP+92GizUbzE6AMmGM0j1k9aM29emP9f5kfhOrq07erIvhKC1dwbFeVt6q5TZQf5T32v9+SYb0iQo2t2j212GOH/zABPCxvjhwYE0bxup0sjY4wkykIhfiS0GCWzEBeVJinIwG8BlxCzWBezPPkNwFU7vOlcw3C531nM= 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.83 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> 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: imx@lists.linux.dev 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: +XZdq71yckMDv6ymBXth1L3eMBqjY+lyvoQTuidjWBhzUSUSb1t6tWvxljxlG2B3nrO+bSmJy3Fsq3AmkpXRc7NnHOKpKQdIY85ND1H2rkEEAXKi9kvDPAZQmhz7NeDK4Z8mehJ3mOAXxfaZQl1uf2x8IIqvSJaix1ia0w9YGdv3xqWfwoExd4tt8wAbt0CXfCxiRoGHPeaiZxWD3YxDkC8KW+hvAjfTfSIEmQHNFlb/gjIx7b/3ZOIzibLd+zrstWw7Ht/6cAMNOuzc+0Dftva0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KcR0NyqpXg== 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: wxXQo3kBsx2+d87WxDs8JUUyl5tkxLZXrYsTqZ7VM2JqxLgaQOFan7FPTAXDvFTnjzbkgqgpRzDXORtkf9MLaAd7aTPnMby1viQ+IxBUyJI8leQBIn0jQTP9OE5QX2Yp7LQ1Kk2PihZelAhUJ11hgICeaV2afkkpxW+W9CXH/NYb2C3H0YS5cxlW6zN05zXUhuaoIj6LO6+zcO2uYhdttnYHMHaHNFhCtZn37lYTzePKaRph6M/6D7yaMWo1nKn4Z96VC7O7y4nNHkzT3AnWkTKRq+JgGCgzFDE5SAKh22trauhzj3/VzZ9IbiK34kQGVm36VVlW6b/MVLGnLLtJnbuVW5vctVfrf9x0cBpdkAO0cSUyqyeHLfScKMnU2RwWytS9xnMLeXDW6GIbNYsiHFWZcQciXYMH49COJqsaEONSza8AwndhRllgbhsFdLa4/RiI+5pGS3c/GvLu5JEBRlonni1z4X+jBWBd9nMYn1Ex7oVeMhKml288iOnW+HRtsKZX6PrQe8k/HbSAY89/ElsJQZ53bB4yB2Aea2oJo1CSCIVrJycRF3J5kQor3QtYQvivTiKLsXQi0/6f8wsg3s1opckL/95c/Lb/189wcXYHhdm+8yxSRVKdUOTGt/Tztl0TeXBWlqcxHJwCtzL98Ex944E4hKKk9h8nRHphjhbg8bPl4wUQB/GVF8ERjY6fbuwhBWhBog+6tqy9XikN/t1S77PTC0FEoCWOcWx+3qcjPlu953fX+ec3eptWhAAF+y2R+IZRHvPGSMfu8vskjmI+kXagM3I+fPt6DJ8Juf2Xya5xfLq8ugI00eP3o+r7qppj2WtuZTDiZkyZqfIb+d6Yv3sW8TkoUnI9iZZ4/6wROXTbOyiVuKI8FGz7tNH5waoNcso1MUacaJKF+FDZ9qGqfBJwcI7fjCY/bDqVL0oxw4r4peo5ZyQjYZ7uISEiiNDdPgXDyuxMYY3E+L0KcH4+F+oKWEIgMNz/hrLvhpVAxMLCSDt6baAUnsclZvMWziDYDwzcgf9WmOLpAi9abvezhqCUBGT216a6N3YXLUpBL2d8Cs7yolt68H1F6dBHzoqQTLWbIld2E6qMT0DZ4HMYSDZ2YCPPXtys9V34dTygjCpuKMLDat9/hcj75Dzxs78r5UgDzeBDEf2KIPr3LVsazJYRSOKZzwKrF3YgqewstkwhihbmNUgW20Vq1EC+N5tIi7r4UcBrA1Ji5uoXx2cS7SDA8cv0EhPcka4sCBz8xG6s2yboKUPbnXfhe/xDcAdAXHd5QKwnpNbcfAS0N2eNZIDkh3u/v/6g9Jw1xVDlMX10URvU2JnMZveC06UIVmg2sKsuPI6R26q5Kcioypdoa6g/JFov6utsVRrQ9lw+tZ2R2yeV5p/wN3QOOLAMpV4o+FVDFe7MW9lkSW2AXcs04cKEZSriHmmt17r4VIrJ1dGzOalzuxmOaK3SDRhSj/zP1beszH8xQueXM4j/0qFU+7ko+KkH/6vs3DqB93wZG3l5qDzllQ052r0PwrfrH9aoK8bjSxBoerwvRiSXxRR4ToH2+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 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/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 Oct 10 09:20:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13829860 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2083.outbound.protection.outlook.com [40.107.22.83]) (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 2EE461BDAA8 for ; Thu, 10 Oct 2024 09:35:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552950; cv=fail; b=MUyi6SqTxnGpBUN4Ve65mn0KrfWWDXzpHvpK/ukwIKVkjfme5KC12Xaz+wjHLrsi4VRCONfH34FGFejeuhYPrBcfu1Gt3u21qTflW+y8158/ZcHFONcxUZywvGZiddQ8fhYN9ummD5zXADWLLfuffU1/g48k8oQFdn/1W4mMEWY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552950; c=relaxed/simple; bh=94lZlI+yAUW8VqjbiR3ZlZhdLmdrLfQON7QWRZP+lQ0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=fH1WwkY0DpRy7dB75HkCkN+DlqtEx8iybhEizKJ3UZxt2JVbW1825khBjGfkE2IdcCiSXhqD0Q8kBNAQNTVv7MY4CrOZRlSUp87UETDikNXuVkqw2sxDGLiPK9p5jHnD16kIE+K/HE456ogFoSIIxQC49VVP3R7h+wGRjG1m4yU= 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.83 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> 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: imx@lists.linux.dev 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: QoSr4o+bxY4l9afy8UanIBQphXuzwnKwxeZRQYp3th3jEGbSBvH+cQlp4+ZlecP2u/r14netWJbdELDsg/gZCQs03NzPXi5MsdR4V+d1oSrFfHZ6hrIjQ81+gEHr4uHV1z1oWFD4w/VtTrnanwIXsmwMC/3XElvb76xRcI4veAoCVrPK4zUGhZwB25puvDwunuyhlTvQ21hrYmtgugZhBgxZa3mjW+uUV4fcondAZ8L6UvBzeb4GU/gHZR8eoWtxRSBqpErfpEq6p844ln19q8FV1G623fgDySWX/AwEf6SdgKTz/Jyc07h4lTHGn/UA4Pxhu0y4GTbibrMjDY9jzXCpap6w1egsJLbbNm5W1xc9Xp8FL3B1s+KQVpzzlLlqjS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.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: 7DBqAHjteWfRL6Ks0D+HDq10o3VQ2mALdAHXLUUrtXOpWm9vnbGFcf5y8yc1vQtTqToAX2iic6sFhcFrBvfapdzHthXOXMBrkvFsXzZEDj8BoM1HBmzfHd9u9A9McvMsb7AZaYXI6vi+sYFD9iMKvdAbBuR/Ff/+ZQ4OjUCnnce/PvQ7ojkXygwTsmb3+hXZE0/v9rVZ0I9s27I+fkxWYA9PMmVGHh/P3S46eUHqRscXaFfy9t7auZ1DpSKhXHUYuO5db1W6OQ0gk0+wTSKCtI0dOpLgthTiING26BDO4jBW8ZvMPtu3wrblvR98koXdX3ZINZ4s7I1lxc8+f5U2OXYQxcx+Sq9kzIOY+tiU3EzpAd79W7zJ2HLSSZnqheDiIbUBPUZCfJY3qW6J/QJ+kWio2anduiKhSI0y6XzM9cTOqimazrgFzuGyvFMpAqoTa9fEwSgqPTkixtxeH8AqbvanMi2R/jFXDZjRSWO+IZiws1KERvGPzZ+T4+OrxJCF62FjwUjQpT0T4PPU+UzXuM5i0IX/mw0HCUxN1DLvHgkT8QXKxzBDcy+U8hWbqVZ9W22xF/a5bgLX0ltEAnAHdWsXIDp8h8Q+kPT3AspzJxV0PnZQM9LHsKX8fX8kmpAXlC/Btr/tIhcm9nYVimBTGLdpsu/QAjNoN2QqbQSGw9a0bbeZ6cgU+xxTef16MEXJQIOY9k87+zD+howQEavKjk4CqzwObBiMw4ttwmru+qAHob7VPa4Tk01iqGhQsY/TtZQr0LUV13iok15Crt6A3ClheJFVEbvpexnxWbqXN1CN0ue3+Fa5Dy1WK7Wgtb5/8NJaQ4bYpoJdXazWbz/5lAZezQjlZA9F6i8dnKTbnGIwaUkpAqVKle48/GPBO2J3G7H1owgrf6CKlwokNOOiAI92Gr2F2fJfPQHwhn3rO+FTxdMQFd7gPHQ6J05B1VUkYKIeS4JXsyOX8wwtCF4B/utO4u069U4FqO/h7ePaNrOY3juwaWoFLhHdk5/ATnGpTVxCpHlB+ui3J2+81KQdbDBT51Ot7dqe7/htGcn1Ywst+IfwIoBurVY1ldp8/4/WMaJ/kkUUo6cv6sFNWLJPvsJAcNHhwggHac6TjwU/A9BHHNSHtUDoe9shBTsL+Vpvss5h89wyFlCDGJLe8SnnVlCh7auywNjzA99Zo584eNnv10gu7/harDeN7juIvB2u6FMWzGyeAhNSjTH0+s2WwdWeI0iw84nC37cRC+/GSdeGppb0xDOsvYpBDI1ptzfatx5O/ncAkjKE6Qs9bg6owhJFHZt1RgBJhrlBBMBQ4coQMoNenrxlZ5TFqSVtoG4hhPSjmbOI5NWOY4jh4Jl1hUwNUe9IgBO6POq1nQdVXmRRnVkGfDBMBP04Pm32AxJ5syw2eS5pX1WJFnzt4mu5bkx0rwTRoJPnprbHnFxckE0CA8fIHGX/BjR9emtZTLI4o4mEocVPuX+LKgV6Q/AaUDeRB6P67KyXDqilY9p7aiU0IrCQx8KSchnZW8ag+bnGtIPXKoTz1D9TZWyCRu2TefU5odNLRrTmi8+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 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; 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, 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_reconfigure()") 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/ethernet/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_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()]; @@ -1602,6 +1606,12 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring, break; case XDP_TX: tx_ring = 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 = 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); netif_tx_start_all_queues(ndev); + + clear_bit(ENETC_TX_DOWN, &priv->flags); } EXPORT_SYMBOL_GPL(enetc_start); @@ -2520,6 +2532,8 @@ 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); 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 Oct 10 09:20:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13829861 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012069.outbound.protection.outlook.com [52.101.66.69]) (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 ACDED1BBBFE for ; Thu, 10 Oct 2024 09:35:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552953; cv=fail; b=blzaqsMwFGvXI9o+BV14bi5ph5rv8WuNjK+EuhDIpk/pV9lOvDg+kKYDblteiQxbzE2WgvBd2YQzDlFpOvriro5Mhz+rAbV6EhLDzv5wOYF5HWIQh3pkGpGDqjDq5DtQuDYcMtheGP40njVzjzi/NrXQ3fnfH53XbGQ7YJv1gN0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552953; c=relaxed/simple; bh=PG5tTHcfBglgmg9je1jOI9O7TLIUnVlIuoVxAEH6Jm8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=V8Y8yQB14NOkGsVoJI7e1RkBp8+KfVJEXYG3d+iThEgN0aZlN692Z1XebcQukmFxKIMiLrY/qMhEA+2Kb7gsfhX4aH9DEj6WYTpknX0wI+Fw86+4Xw/A+vFzO74Mbly+d/gL9zxQy6iQFKdiyINUKH05m+hjw3evzgAfQtaZPPo= 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.66.69 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> 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: imx@lists.linux.dev 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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hHfXAfnGW82AjsVja5Y9P/sUvU1paEEXvP77PxgLwWaLhEldLAB+dQZuSIdsoAt8/XFc5Rtw8r4Tl5+WksDi9sqp0RiF1uo2Fi3hn3Qc4WPXWN/168Y1eEhwnQLO6pR7lza6AC0dolCJnK0RM7xwDD9oN2gVQ6Iqn/dxVFy88wJy/UUfw5j93PEfu7CQkraDZLKsPfS4ro2DJTiExGyQyonVgHOxc+xqpQ0MkNwlZZAnMG7VAJOc1BnZySt+tNqGMUNiSTQ4ciyQTSghAO3ihkAdoMs1hgPxcyoezP6bS2i5hf4vm8W44InfEPdHg= 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: v1lO0y0x1BDkMZH9uAEgpY5lyO1NYBqYG3Yh7R1qEpfs+i+3duO+zff5jKw9iC3Jwds6GzTqzldANk6rcOWht3zkNmGKXqq8kaX9R66ZY/rjKMT5L5F7rJJHvh7zE0o+wBB2n7XxcK9Sv8Xn76l0OKXK0vlbXuAHAu/I08XPIOcKBMGOckL2Hiz1tgfIwS1lWCh1uuOVUwKF2oO4R1Srsm+nmW32VpbxBWMain52sHpw6NhAVyn941SNjKx7aJxgLRbcyj1sI3ne+WSW1bshNI0O9v6P0Cgdeaf0FAQPr4WwUDLjPH+wxS49PauELOTlPhQF/5bQTJvjTj6bW6c0aiK/nIOP5x0dcTBA3hyt76PvU3J04HJ8d9LUWxWrlMLxvq/Rlycq9uK+8+IXIxq2IuRiNQyTdc1Qe1ubGYTRYCor+OCKCxH+qT3y1Cshyz5FWiHheatDwd5EMq9B9XP1oqgJHehuoja3ZDICoxFhHn451sjcpB2swxoy4+KJH+5u3At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2sf65RI8kZ8 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 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 = 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/ethernet/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); } -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; @@ -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); } -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; @@ -2462,6 +2474,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); @@ -2470,7 +2484,7 @@ 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); @@ -2536,7 +2550,7 @@ void enetc_stop(struct net_device *ndev) 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, @@ -2549,6 +2563,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); From patchwork Thu Oct 10 09:20:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13829862 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013059.outbound.protection.outlook.com [52.101.67.59]) (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 1381D1BBBFE for ; Thu, 10 Oct 2024 09:35:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552959; cv=fail; b=DwCfU6i7wna+LGJ72kXgwPglQIXRnQjQyVjG7c6oLnb6ZIThRXhJLW0PD4yuI3DSaFdl1mUGKSLn7JvAaLShBRobE41A5YnwEEFFeKGvq4L+yaKmb6PwindTyPdolK/KQTCjrHScF95HTuG+UgppS01JJRSKKMVG7VX3gXhS7YI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728552959; c=relaxed/simple; bh=W7yEJpYb3Pu9CzMvGRlij/dsgM37cXfZu5kHjh1UUZU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Lu/6ShuVdk4M21U2CJdGSXxqw8w+z//9OAW4u3sy8xCJok/JusXqBMgMhHhnZH6hasZkgzO7+q5GtiOmbAIUpuu0jgZeeU7iu5g8jGErHYXNoiMQgWr84raoNf8napjEFhMYEHdlrRV1RZv36aCUEAVBvkzr/Z+nAuGvb+2SGFI= 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.67.59 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> 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: imx@lists.linux.dev 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: wpZFHm31TXjiVFkT2VZayFKNKTW1QK0djibfcOwq/0XXkDwbKMFH0pSNF9qQyWqyWrjYkOrG4wum8QhMd6irMZnz/iQw80oMgT4uiIldVjzglEv7P2piAfG5Bu57qxCpWcDGmMWOuCOhuxqxs3x8UyLlbt+zeqeoDpK3QZmpAlyhnjkZugNxVDHdnii3W4TUFY1/8jVOOT5XoSdoKhctGrEjAgJs9FZvrDyLBcX5BwzE9zXiOLYprfs7P4ZdgU+Gezu1mk7Ilnz7EJl5WCR90YkSyO/LjXppte14nqD5AC9licK2dZ+OpcpuO2p/jRe3hFHS16ngVTZxtmxLQthJZhbmiogjgofqmDl1iw4epevDlp2YTQqiCPakAeizO1UV+yodYUCOyvHUV8VcFuMhVXbReT0oYUVq5Q2q18DUhA4vBq96bJLGpdHwwhS6TN6RqbJuzSJV6+ynxYnxbmX/ozi7uNv/Z4s5x4x0cYRRhoO5SA02aCS3wH4SXQ/+ztTYLuZCJJv4fJoYk5ddX6uQDRSNReMQXwizbdYP1VGnf+1s2Basl+HsS5IGS/1exkkjQDLRYwt7xcVzoqZVWBNXyqWhgyj444fQxDDVqkeW1gJVbPH9QqZSpgN20megkqOh/PayQFBsCWzc8R/dvH6oWhhArF06A6dQ6M+BvFdcexqeg25McbfVWssDSnj+7nHaKzKZp+jdFCHT7DW5C/t6o1I26QJj9PJWASM09gkeEeJ7Cibozr2ZcnGFlKQr17uPJGRKN2FLkBEd3n5KpSjRI/2lgtwsYOEOj43xXHGTVCePnuSClrknGrL+sSY7WsoeLD+/uFGOcS4TsFgqqHjrK8Pas7oi0AKX2uvWOWS4sqYrPSGJPkcQZKMxVzcYY7yVgpH1YnRPfRFQYi9T9jizfFKSeNYHvX4DYFmU2/qRhHQTtwoRBXCcIAL7ja+oIC5fIAwBprVKN7htgytAl04LyUzMSLWyKhVBtmaz1jE5N6NfXy9YhPIUbS6EUpZhcwHuN0l66WaX9iUmu+/Ge4aBAEOX2gUQ5HCjMzVI4vuzdWu4oZYFYOyqAvATM76Ys3gAVXfQNPcKqSzNHKXuaRVgihxKrf6YYCfw1Hlxvz61pb9ROtj+6OTN/TSv8jNn06jbXnayCQFpmEVLvwwb+YzWPArRGiyWXKi2BWxioz1du4TAC9xtATU4wWxenXWTRmpCDxlKCKFVqtBW7kSqufFtQaxduJ/kvcdKNKGQfQJt8gHcdiRklU44ds5e8SyShf5i5gawnHn7qeQ4nhBr6sfmDd/Yzqg3vy7ka4tTVsR4n4SOBPXsyK5dkRzhq8PDqZI6L9NDlUhd9gMLtSeQoAtD0g== 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: B48Af+RGk5ALOTsJfkxHyNG1hYpftN/ds7h+xJrvPWBO329+zQ5zD2PlTvbVO3O/kbpRAvSzCovQGwK8T8WMrvy53V3DSIGppzigPdeXpstxgJ7YIQMDqVzVVtohEnQG8gaGEQ6jiGAo97QVBo59ZhTW7yfJvuIPhv3pVE+U0UTZ3fhjcEBnyH3YWtBSQZvBOa8wIOSd6tjMCK5f/Y0d40v6/IXdB9lEnk3U9XJ970CkKWCAzIurv0pPa3p9/TRVyH6b1EY7GM0Vty4D2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+qEqzG0W3rVW5NBO/MnfPhnl7VBfpmakuUo99mIpKmaKqoU/4MQZmwCzf+TFgJyyTJ6H7UGX3f/puOasBqyNea+MswlOw2g4avsuNG4Czk/+0mm9Ki0ua0la5FP7t2Jsf8FR42vsHZv17jYpMRE3W+AmpIQ5J1FDFNu4nIx/ZRCoS8iRsxMMzh/Hk4fM9ecB+H1pfH3jB/F1nGUEh9x1cZZJgbPwr6KFFnYYFY1GeZRYITuT8b5GtJOb6nAaTVAHQvzoM 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 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/ethernet/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) 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); @@ -2484,6 +2482,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); @@ -2552,6 +2552,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); @@ -2561,10 +2565,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);