From patchwork Mon Feb 6 10:08:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53129 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2151387wrn; Mon, 6 Feb 2023 02:12:07 -0800 (PST) X-Google-Smtp-Source: AK7set9vBmyOoZ661Ig22T9Q8s2H5f9uzHs4ddCyt9YdiclQ4ElrTmyrdp+r0bqV9hjvsxziy1H3 X-Received: by 2002:a17:907:724b:b0:888:9bd6:34d2 with SMTP id ds11-20020a170907724b00b008889bd634d2mr25929978ejc.63.1675678327137; Mon, 06 Feb 2023 02:12:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675678327; cv=pass; d=google.com; s=arc-20160816; b=MHR0nLmovMYJLmeqn2UWuWT/2xlwoHKrKlOEyzMEL5N03dWFRxxpa+V7dVS/TaQZpZ 1y9hIMX4GXkLeOuQAPr+aPPGAJDYX6iUSx0+E/AiZTOr2YFEX22wj00te+7hKItKk793 9W3Y2VCMiO9GxQ7XSJcb77A1feFwZpSqXfaNDPb+C4Xs9Foq+klQoPtrFYOia5LPBq8M R7nr+2hvNuTxXIT/Uwo98MmIjADO85ojfxEyMEBSiHtio8cJ5LO+gOZJf51VTGkOpZtG 6g48PvxOuzcjObHChz484AcG+csXv7sYn3tz01Eyjpg/Q8Fp/Ae/5cqvY4/67QK+dwhF Tqxw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E/v6lLmpQeYFlEtgAIe5Sc1tmdXZPd9iPKdGEgDMruc=; b=lIs24e32gT03TMfaKDFktoGONNr9OWl2lXcmhoLP+y6u+3rO1MdSKHge2upNNCf1nl gUkOumnmYuUI1FS/DEL1b4/uzHZ++JdySIDbyohcF1DaVF2qPQ6K5/K9gnh7jnI31CKE /LJxO+XbksuIB9OMwinTIITrYWzbwP6QeOpYu7MY5ko/Ifxf6Q98S1ZxkLDvdNm0V+uh YMJNFIy/sOA1sqh6mtl2Tuhb/Om9xGG03IYhHOoqwsP6hSP8KZeYOdsxyBV9cJdC/spD dgviixp+19dUtn2IXb9tIlEJpNF8274zlnpv6YVq9J2Pc7ow2KsxWspSPYNNmQ51YwEn pbiA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=DSdTuh6a; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c22-20020a17090620d600b0087784d21e5asi14205803ejc.721.2023.02.06.02.11.44; Mon, 06 Feb 2023 02:12:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=DSdTuh6a; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbjBFKJk (ORCPT + 99 others); Mon, 6 Feb 2023 05:09:40 -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?b?QmrDtnJuIFTDtnBlbA==?= , 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> 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: 0WtJX6tgoavvK4pO2jkDINkepJ98VhBXTcjYzA/QvNyMpKT/2Kb9aO7bl7jdDilSddDc9HDDUUgoQrj+gnxN4KXgbLRhO3HROATTUsvTtprbOkB0Zolqs+zjCbb+l7P6Zut8A2JT9c0GnfYtSmV3rE2ZKQJ9lVIPvY7EGqSoJBnjYJqdx9e6WCwOPrOR6eRdmR+YcT18coIrNuA5JrmnhLYKLgo+WQPy+2J0B4Vkq573ofd+UKIX0IcCrz13Kyx+dsEKGy/NbR/joZYUDbnH8rk+YuE8623i5f428DSBeNsa/RZUhd1ltduvQ1Cp4tDRmOAfIs0JqYDpdukDVt6rwch66LBp16B0sA8UjVXUIgBaq6fbC5X6iKaTNOc1unCQQ1RLMSj8CFkcXuQRPOUPXT6YUzP16bz5ywxZAI9hsQHwM3hJGxiVZ8oJLHYRvZXmCWSqw+OjIcek7R3uxAW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vRVxz0G4QopJYrxnK0JTT9heNRQmp/1yLxLRM7zMAhAqNnZ17tTeGRlKgXjfnQ== 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757076077672147492?= X-GMAIL-MSGID: =?utf-8?q?1757076077672147492?= 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)