Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 390E5C636D6 for ; Mon, 6 Feb 2023 10:09:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229763AbjBFKJl (ORCPT ); Mon, 6 Feb 2023 05:09:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbjBFKJ0 (ORCPT ); Mon, 6 Feb 2023 05:09:26 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2076.outbound.protection.outlook.com [40.107.20.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37F1F13D45; Mon, 6 Feb 2023 02:09:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jfUC3k8oQxDSxkdGvFUFIgAH4WrcaAH6Cp7Tvv8XlgR6JiHeRc8qHZClh1GDRY1lOqXVYDKPE3QSVC8mLGx/1gGQtXd2DsVpNIo/bfzMBAwvdlEwu6m8xJZ77tZ5w6nGYc2le7yRDoAI8k3I9Ub3wAGAUDAt7HnVbv2JnunGCiQQxeKdqNx+1OErnWaVQ5YqOmvoEYDpIRzvmBPGr6qdF38UmAbRN1A5go4skGdIS7g7if3fm2qVl8wo32cbcMAxTBSluVZrDurb3731M2oVR/gbi0N7TXQt3dSDmazB/BT+8WAAu58kG77dXYMVgdMKZH35D+z+eHQs7A/WD8VSGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=E/v6lLmpQeYFlEtgAIe5Sc1tmdXZPd9iPKdGEgDMruc=; b=CO/Kc30DH3wOMmt3SnILZI7ehfVApLNVo5NmpbkJvVbPlS6cVAydkLanxsRR9Z1WVBrTC3PSkKmLsocZVdrCxMz+qgs0KxV3uARPLc2kIsyAInWpvdW3pKGJzEwCaP6idCh0sBCzt6kFozpnqa1eEvd8jr7+EGEEjdLCLMQJog0uNIVLCG5lJpwSU/6rCu+a1U5pIi5bB4E2Kr6QLRyxqAjfDPsflLIheChMLqxyEY/x1apjlzrvUKG5SdProVXvx0qno47X12/5GEPE+jkPEXZp5Xsh14Q0CpxcIbBT8K5KJOKgERp25ta8AMtzYq9hvisnjAcSgxzj0fVPipp0uA== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E/v6lLmpQeYFlEtgAIe5Sc1tmdXZPd9iPKdGEgDMruc=; b=DSdTuh6a2gfP1hKTY2ASCBKqM9OT+ybXcHcGXuVi+tsbD9lHu1zEXzvxfFSc85lFtFXmOdjAyRYpGDfMsvC1aUTkYFWQdaXdRI4nmfd6hGjyUxapm+JcKFo6NN75u+6hULAhFtzsIbIKU6frA4DOsYn8m4nb+G7dv/S3R4s3F5Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AS8PR04MB7735.eurprd04.prod.outlook.com (2603:10a6:20b:2a5::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 10:09:07 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Mon, 6 Feb 2023 10:09:07 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Magnus Karlsson , Maciej Fijalkowski , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next 06/11] net: enetc: consolidate rx_swbd freeing Date: Mon, 6 Feb 2023 12:08:32 +0200 Message-Id: <20230206100837.451300-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230206100837.451300-1-vladimir.oltean@nxp.com> References: <20230206100837.451300-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: AS4PR10CA0019.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::19) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AS8PR04MB7735:EE_ X-MS-Office365-Filtering-Correlation-Id: deea83af-e018-4c9f-f7da-08db082a2ed8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gw08D3GLmD8iGnfOsd6tzX0DQaJyNBlS3tmXRhzJhREKHIQm02vEyDLN/cMD3/SppckRJEiiP60/p+/1mcNhmBERv0PLrygr49UiUqJPHLgsoFZ4V7+8YxdwClNpcRUWgYUPeslPsnx9Lk7RczbuAAkPSparub7EU5QlJvQ07j5aear840Yzhi0D1W0zN6UiLrDb2Pov0QyYsMDn1NQI30/p+suFu0zHIWMcUmzwkO14o9z52blptTo48MIsYZM6KUfQMdj8kVmXYxZTvfZVpPIVh+S6+Gcsj/Z+JB4Y+cb4u/vfhTSviFF2S5ySH9+wTlzYEWZFB0vgYTrG6c7k7pvWIabiV78fOp5C4UOo6mmcowBT6D7js8u2sX4KscCOUwXWuAPSVcZrnt6htnaWbe4ezO03vSrPH9COANDhjo9PJZMNJEFHUN3NFAoix6lEiqD3S1luGacq6U2g+XBjH0sHpv7/VmlCq5jo6W4HHaVf/J7YqzSWt+f+yohqP4dhJjGwB+2NCVwR3SCDIQPaETPZCw+r4WV3F5kudg8oNr+4mH+cfd4CR+oednWJzd4nJWPe4EVLXoCpTUP/WHWkLMtyiceUrGvGt/gET/+RMYWPrUx3GBEaDKICxWppXct9OQ2ZzfbA5uGvtelq62EQ/F0w8rIw1MkrYdcUmFwiPjFkGXUIllp4ZUFUtgEfHbx680vTSYl5C3shvezLx0W+CA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(136003)(366004)(376002)(346002)(396003)(39860400002)(451199018)(86362001)(36756003)(38100700002)(38350700002)(66946007)(66556008)(4326008)(6916009)(41300700001)(8936002)(8676002)(7416002)(5660300002)(54906003)(66476007)(2906002)(44832011)(2616005)(83380400001)(478600001)(6486002)(186003)(52116002)(6512007)(26005)(316002)(6506007)(6666004)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?0WtJX6tgoavvK4pO2jkDINkepJ98VhBXTcjYzA/QvNyMpKT/2Kb9aO7bl7jd?= =?us-ascii?Q?DilSddDc9HDDUUgoQrj+gnxN4KXgbLRhO3HROATTUsvTtprbOkB0Zolqs+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WozN/IkwbvUgGDFbpS1DTJCLFZGKTSozLUJzSShJ?= =?us-ascii?Q?paGMf1MShQk8N3aPs5joM8E+2CLuzF1PeoUfOlKR2r3iRzGdLNZwucjvuqFc?= =?us-ascii?Q?HTTR6z8Jc0zazv/cU69eR8HFVa8C5lU7kLngBAeT86t9AGOwvE5BxAtXii56?= =?us-ascii?Q?YOv7PtyfxrhVzMjyvnwwDs+luR8oTGLy1TGgRX3ONM6kazxGEdAUGuCNkmzV?= =?us-ascii?Q?UnDtSmRhwH4zkfRut9TZtIrE3FCLvnrxbYUiRsG7bSKqaNFewWofU3ExKSP8?= =?us-ascii?Q?R2OPY+JL+9q0WJdmPExar1lXsugXac0xg6GWCbF2RbnDAehdXucxyus2GMJZ?= =?us-ascii?Q?YNydIKZTfxETFRQqGLbM1GmmFdt9ODhzoFh7j6f5a4f1Sn8qHq1PwcxlKNxJ?= =?us-ascii?Q?HIphX57qrSc1W4vSg7fLhSwE7AgRAXpF/wSte73inR1ThGYQuq+ik2f/VlEK?= =?us-ascii?Q?xotESlogWAnQgTjkVMzHXqhNW8pXynNbR4KzFDaliYFE4YNnklYjQCmqO+fR?= =?us-ascii?Q?p8Dha8J+CmusQfUEYpHFmDt08ODya0aHIqhw039E0eN3AQLcSkstImYSeysY?= =?us-ascii?Q?vRVxz0G4QopJYrxnK0JTT9heNRQmp/1yLxLRM7zMAhAqNnZ17tTeGRlKgXjf?= =?us-ascii?Q?nQ=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: deea83af-e018-4c9f-f7da-08db082a2ed8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 10:09:07.2864 (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: Uili954G+ueKBVREPEZHOOwh/WsPpopmjEVxJYXdkP5URBPBKQdg1iJ7YDnNvuNWQm4r1KKwCKhNP3mAMTCdMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7735 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are 2 code paths in the driver which DMA unmap and give back to the allocator the page held by the shadow copy of an RX buffer descriptor. One is on RX ring teardown, and the other on XDP_TX recycling failure. Refactor them to call the same helper function, which will make it easier to add support for one more RX software BD type in the future (XSK buffer). Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/enetc/enetc.c | 28 ++++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 37d6ad0576e5..33950c81e53c 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -95,6 +95,17 @@ static void enetc_free_tx_frame(struct enetc_bdr *tx_ring, } } +static void enetc_free_rx_swbd(struct enetc_bdr *rx_ring, + struct enetc_rx_swbd *rx_swbd) +{ + if (rx_swbd->page) { + dma_unmap_page(rx_ring->dev, rx_swbd->dma, PAGE_SIZE, + rx_swbd->dir); + __free_page(rx_swbd->page); + rx_swbd->page = NULL; + } +} + /* Let H/W know BD ring has been updated */ static void enetc_update_tx_ring_tail(struct enetc_bdr *tx_ring) { @@ -796,9 +807,7 @@ static void enetc_recycle_xdp_tx_buff(struct enetc_bdr *tx_ring, */ rx_ring->stats.recycle_failures++; - dma_unmap_page(rx_ring->dev, rx_swbd.dma, PAGE_SIZE, - rx_swbd.dir); - __free_page(rx_swbd.page); + enetc_free_rx_swbd(rx_ring, &rx_swbd); } rx_ring->xdp.xdp_tx_in_flight--; @@ -1988,17 +1997,8 @@ static void enetc_free_rx_ring(struct enetc_bdr *rx_ring) { int i; - for (i = 0; i < rx_ring->bd_count; i++) { - struct enetc_rx_swbd *rx_swbd = &rx_ring->rx_swbd[i]; - - if (!rx_swbd->page) - continue; - - dma_unmap_page(rx_ring->dev, rx_swbd->dma, PAGE_SIZE, - rx_swbd->dir); - __free_page(rx_swbd->page); - rx_swbd->page = NULL; - } + for (i = 0; i < rx_ring->bd_count; i++) + enetc_free_rx_swbd(rx_ring, &rx_ring->rx_swbd[i]); } static void enetc_free_rxtx_rings(struct enetc_ndev_priv *priv) -- 2.34.1