From patchwork Wed Feb 9 09:23:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12739904 X-Patchwork-Delegate: kuba@kernel.org 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 639B9C433F5 for ; Wed, 9 Feb 2022 09:25:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231690AbiBIJZD (ORCPT ); Wed, 9 Feb 2022 04:25:03 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:43980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229616AbiBIJY7 (ORCPT ); Wed, 9 Feb 2022 04:24:59 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0600.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::600]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5606AE056C2B for ; Wed, 9 Feb 2022 01:24:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XRTduzcZWRlbei+45w757DPqDa7g+VwVwgcWV6htecRfp6hTq2NiiAqNdvvoa+kjzCsYSPzkTVcfaUNNTvju1P7bYA7VA+Jcs/V7RQpDvKkh6SLqpfNFk5DlkJZgZA+gV+QEXQrxTuIkHIQN8kkqDFziZjBsdNMoUiaTI/pTGQXS/4SxXs74pGAIOlHcxDbTzR8XyfwqhsS/8Jz6LUDHnYNJD3hn+irkkj/dBEhnetkHcq6sZPF/xGAuG/Vbfu64NZkxaKzUw/xSLyzjXgZv1qMtcsZt8yZInRz16Ak9V9nL7jN1E+W/UYSY6rjh9S5AR+tfJKygGsrWvjIbExxJGA== 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=v5SrKGU8FD/c8zDy2feLrobaOzgObo/7cgs6hUnPEXw=; b=ExEQU5hzynV7ptUocNGUoUnfFshOgFY7u8a51kQmDQQkHTyFAH+5a2nrulEyy4IfqSGVfErjIeYaNZ/c+hvysZMTo04zIpW8ZQPhLWAChOTPkktBZYsRC3JOjSeSopYFrrGJV1mF4Aqntyv2lfGoq6TK9EA5QT3lpHdQcd4/wSxNJk9pL6m6R5A5bReq0xkgKXtQ9+OVFnHu5Pk/ye9Q44mCv+xz+HFFBQOZXlxQyRnBtQR3oOYbFOCAfW2e+qh5a/NNnJQlyxl/QkSRnu+g6npezK46bZMpVnOZ+5h53W+uKEYkavsAgFVIdDXTkhy+qEwm2zIVX7wjq0Kb1VkuhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=v5SrKGU8FD/c8zDy2feLrobaOzgObo/7cgs6hUnPEXw=; b=dIWEFlXl3WEriVX9hTowiSQxrIl7Ki2GBuooBAVQP1U/7/I1941maxuJJnB6ohAMaqwgsJtoyt3jMq+7TJ5sl2qxEzdJTZ74BopCO+E2JIgBg8Eoq0DVQSYjI1FgLyBH/uSzy4ckLVtt3QB7ObPKZx48WC4oLZQGR7h5xXMtWSA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) by VI1PR04MB5423.eurprd04.prod.outlook.com (2603:10a6:803:da::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 09:24:00 +0000 Received: from AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::5df9:5bf0:7ac1:a793]) by AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::5df9:5bf0:7ac1:a793%9]) with mapi id 15.20.4975.011; Wed, 9 Feb 2022 09:24:00 +0000 From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: youri.querry_1@nxp.com, leoyang.li@nxp.com, Ioana Ciornei Subject: [PATCH net-next 1/7] dpaa2-eth: rearrange variable declaration in __dpaa2_eth_tx Date: Wed, 9 Feb 2022 11:23:29 +0200 Message-Id: <20220209092335.3064731-2-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220209092335.3064731-1-ioana.ciornei@nxp.com> References: <20220209092335.3064731-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: AM0PR03CA0037.eurprd03.prod.outlook.com (2603:10a6:208::14) To AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae3f8a96-b795-44a1-8b62-08d9ebade7df X-MS-TrafficTypeDiagnostic: VI1PR04MB5423:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MlvmuOXSTGCLAJdIZczemU6X8VtyJnvVjijcTImc/VJrfhgrnImus9EumjVbhO1HZqyaTKuQnfB4MHyOE4uRKrzvEIFZglAnq0RUfoSueUHioEYmsoWi1MZ5LNAqYbDGH1Ff/EZmNfDhY8lp88S+D+uNDHVqmjLzIVxQ8RiBemMPPhP21APuLyygSilL8qrZEjdMBg315F82P9ClsoZjU8PXAqmC16mr1vmklV16VO8owxrIYxEnSoXOnTf4y6X/9/FIaCAF+parhawd6G2xP9JZ+56WErRqXHc2HgUsQwyLxWyLUUBqyT7HPdOfxK4dpL2GJ6RdyjII9ixi7jGwo57RIuJqOpgYTVEUUpI1dXoqQ7M5woslmMnJEpM4P0yqRZBauDasyAKSNEs8fcJUB8+4IpPNMhR3OV7CgSrGeKGsM/5YGMO/O75qD5LAo709aJxLUpCnFbwn2WLT2t214tF+lMzAHYSY9lnm+Q04rqZmbMayMwjQOjuyrohSkQkSPiDEc3Qix2GH88VcjeRGD1HTw4FSCfr8GEw5pg98CkbcVynIj+mt/bnRZdP98B4o1nrTjJ2w1y2kV9ST6kYD9foomRm/cCrOgZJBnpPzV07WiAhdQM7N33BvwR6qWxE7R/zI8A09DnDzTpNy5dx91JI541RoPQSEhGHS8g2quHxVXoU7UmWlxYLVEiTrnbyFB/I0+NiKiN1fVFKJGQhtPg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(2616005)(83380400001)(66556008)(66476007)(8936002)(4326008)(8676002)(2906002)(1076003)(26005)(36756003)(6486002)(5660300002)(44832011)(52116002)(66946007)(86362001)(38350700002)(508600001)(38100700002)(186003)(316002)(6506007)(6666004)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jpN7fZSssi0xomPR8uDheZhXOCkKftG8xCodFGb7fqcVFM1ekSi7J/ZmbmhKLNQcstlT1dTP083XtAnax0RWsJvRMQnp0RRgMtctwT+E46AXpXkKWaWQLFcQGt3zN/EKpbyqisaQFJteQN5El6Z3yeglPVjnTv6u+X23XOgHOmW9Qjbj8birzU0Lb+MQt/XNoSIBbI6r54y2JdqfdYQS4lTBEGy2py6sVnE2CncQhFbgcB9L3MzwkKxu01WLc2rKE0JEfJm4cLcI+qACZJUAvzaVCWENqQNvTvpqCrabLA9koWFPGbcQ8AdqosVpk6PZqut+n2tp7HxeCU/OxUB+DRfj35/Ygv9RZKX+uhRijoIhxn9A8g0GygL2lPE1+E3NUtMwFlwI9VWG6DsNgA/E7Dwu4bYyO5FSQ5jbx63sOEqanPRD5RUXRp80uC5Jn3p71n9TNxY40E4uTgmNKjdxw3V8tZgBi5kCf/hpzZYstF9YYQG38ba2FviVZVy8rRVab5WEC+zrgpIp/RuS5UEJAra+JJUcp6ukmUj8NF8Tmf/FWqpnYER9lCQ9r693fVjHEahjO36U+MxXh6lUX0WdR9miJFGwTgD5eVuR/8DZc1CsWXyH50XZB1tpLJMf2Sh4JFzNaxdCNuyKqChgfErvajGrmSu0jWMybV0M59sCS+vHRmGH/G4r/4TON5w0Bxz2ivev0AOse3AHZUa8K3R1omyPjnD5c46QhXIRHfcXO2/5njYC4s7tbnx0T1nx7zjhzb/FcqIO7fotbWp8ECjmEMPhs3btbRayaaNIPacxdKCEmp1ckbRG6kNfuRp8XMHmePaIHAsBgH+D7Rtg5z1okn3PC0b3MhEyTAP3PvpB87WDfKi/K2OO48tDheCMko4zykejXWyF7PFYX8qlZIMXiOHhwrK5t32Pg1Ta2BRzhkYYEsn2vpNOl6EBOo34+5Ly3OATXwY5cMoM+9+ef5U0O3yj3/2CMShkvOHhliywSrmaG1CScjTDTDfPnK6jBppGizy+VFHB1QjIEivfaxJhY7KPQEpUebq6bWinNEzPH8PmfYEVK5eCbM7Aa5riP2MUyIVfvcDWkPNR3Y4P0dQpNZ1YbvlYmGYENTJXl0Ws9vMQrEo+ai58vm/vAQPY7VUMurFO1A+PYdaTestvDZm5Qc2+RxeymfX4vr9qyOp1p8eCuTYWXntsNx8lipVA0rtWK0TkuyzIfqH6ZYORumUgToWoYMnRwngN3y8vXtLc8Zf+4tt0cG/36Wp67VwBjNJ3RJXdGiV83Kf1W2PYG50IHETB32qEH9XuZhm93lFKO3vWu3kRT2j45cGbqFM7RHlHJiveXTv0CYHfoEtYjCbC/BoRYbsUAZ2RhmaFG3B0B9qEk7+XRhw6PkwzXbsVNuXulShJfLpxVFiNJcuYabjBY7raUm03WMSM2FxYv7EKuorrawu995bsxDPrqUHB1uWFC6OMGxtWvOOZUhR9tIYC0DShPFT/yjZvQWhXspX4m+tDdC7PVYe/nkuEVPY8ynT08ONLU/fLWwNRz7Ju4vZHZRsd0ejBnT8woTS6wV5oXdD7gSPk0v2vpb2vYCS4QO6cZ9FNxAC1HKVTSw2n8GMiM4c7cVd2u+Ac0DY9FaJSqqA= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae3f8a96-b795-44a1-8b62-08d9ebade7df X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 09:24:00.4660 (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: rUOKn08VsGlIxjA17P3HJ+aZsmvaGVF9IAI0rl28TV2WN1wNZbk+/Droy6+w0f5WI3scH7fznvR5tQd85Bwx3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5423 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In the next patches we'll be moving things arroung in the mentioned function and also add some new variable declarations. Before all this, cleanup the variable declaration order. Signed-off-by: Ioana Ciornei --- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index e985ae008a97..218b1516b86b 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -1102,16 +1102,16 @@ static netdev_tx_t __dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) { struct dpaa2_eth_priv *priv = netdev_priv(net_dev); - struct dpaa2_fd fd; - struct rtnl_link_stats64 *percpu_stats; struct dpaa2_eth_drv_stats *percpu_extras; + struct rtnl_link_stats64 *percpu_stats; + unsigned int needed_headroom; struct dpaa2_eth_fq *fq; struct netdev_queue *nq; + struct dpaa2_fd fd; u16 queue_mapping; - unsigned int needed_headroom; - u32 fd_len; u8 prio = 0; int err, i; + u32 fd_len; void *swa; percpu_stats = this_cpu_ptr(priv->percpu_stats); From patchwork Wed Feb 9 09:23:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12739906 X-Patchwork-Delegate: kuba@kernel.org 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 EC89AC433EF for ; Wed, 9 Feb 2022 09:25:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232055AbiBIJZL (ORCPT ); Wed, 9 Feb 2022 04:25:11 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:44596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbiBIJZK (ORCPT ); Wed, 9 Feb 2022 04:25:10 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0600.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::600]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3169FE03D712 for ; Wed, 9 Feb 2022 01:25:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LSQtgA6i0BH5hWlEhv+vvB7gVt5uYBCo7nH8qddnVfqHZls6n49E7kdGN8PCYE1C374iX3HcAWGWka72Aaz8eXRYhnkKHKkW7JcD/1EmTA0R9yHzxAx0LSC7pBN5epZ5RaaHh8ZL855jWQc1wCzXCdHvIl9EywiPXv8GevE7SG3BW301lOCqkt3Yt45wM/V1+Jzjld5kZT63RxhdTPAqY9rTI/G6cmOHmiBYnIVgxAJ7BLPXuCoA/IhWmX08cotXwzAF/Pz7dJ47XZBFPs8ZVMTC+amBegN0bHYEA8pKxRDIwbnpYlfuT7OGWO8FRWKs6CTn9S27unSh499a2d52bA== 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=0CVfbngSFZA8obmdC6h6TN3I0nd4NCGn+Z98J28qkXg=; b=HXxEHQ2aX63kotoEeFsVjgk6iBUkJsv9C3k2DkhBWXnc4MGF4Ovj7NlCLwGMzK2k81AybEKCrDXoBCC6L72RlUPgD5tf60yoi5qV7sXIKhb6AHynxEOsFi/cDK4CxOtwajuDg8X9x/8dT9jJCPHdZRc5QIPUndfoIQG2E+KRnHIqZA/iaO+28sciPwSnhs/CNRQazTnc99u8LN2DAwYTplkqEIDia9VRX5JyB/8qgqMTFjOP1bNxA6VoYzp4aN+TvEerru8Ca+6DcA40fJGhuBifdBmt5+xfwUjqJu6X2fQt7T40I/0TuNHvhvPsajvmX5UC1ibGFNz3OjKXYeYNHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=0CVfbngSFZA8obmdC6h6TN3I0nd4NCGn+Z98J28qkXg=; b=NGuITutAlUnz2EEKKWvPkpgylbs6VZYugLV+BibFzyQNwCcEys6FrpmhhdP2LMsdo0rfllmyxnyDKD4Wm9GNVq85HMaqeWErqvcQPxoHNYo5+Ola1rfR4Ej4gH1+rr4kEYVYWRC1T0Yy8JEm6o7JSfjH9h1EyONt6NBwjn0y7GA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) by VI1PR04MB5423.eurprd04.prod.outlook.com (2603:10a6:803:da::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 09:24:01 +0000 Received: from AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::5df9:5bf0:7ac1:a793]) by AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::5df9:5bf0:7ac1:a793%9]) with mapi id 15.20.4975.011; Wed, 9 Feb 2022 09:24:01 +0000 From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: youri.querry_1@nxp.com, leoyang.li@nxp.com, Ioana Ciornei Subject: [PATCH net-next 2/7] dpaa2-eth: allocate a fragment already aligned Date: Wed, 9 Feb 2022 11:23:30 +0200 Message-Id: <20220209092335.3064731-3-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220209092335.3064731-1-ioana.ciornei@nxp.com> References: <20220209092335.3064731-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: AM0PR03CA0037.eurprd03.prod.outlook.com (2603:10a6:208::14) To AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e635a2b3-7dbf-4d68-e85f-08d9ebade87a X-MS-TrafficTypeDiagnostic: VI1PR04MB5423:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CgCYsl7y3qenHcwcOMZQ0nkPEIYyQ+5sULNYtnz+sdPJubF6brR+8HsB6eSmyQOmKRfKi6Ke02STc9LioEjrCRvh528fkfoSGK0tMztRVIomok+aKKRl005bjYUk6E91Poqtoi4X8WLM6DXMpcc9xmAd/+SGkKAriuVeEivm57jC9IvYWVsXYbKnoMLWKD/RCnqLVD4qT12CCJ9tb3bmrJJma9RS7ZpZQnkLOyoRbocXWSXHaaoVY9+fcOREUrXZG65zzIDZBNrBpUU99S38VeJNkD9CMXZR/8Dg9FN/iud37UxAgbW/M+fqHL5o5E8Y+4Eb8xHtJwwceuv2AQ/fQN68Ev2QbhxK3EsR2JYcvXYvbzpEWwhIG+m5fPckh4AR8sE9g4c4K0sq7d1hi2MoY+8nZLwIbRafm3AJaKvlX5YhAn65jVL2aWnfUWaEZ3luUfTCcPnjMJOLnEMgL8PJpQs80+1ltva1PyTT2Pr9sdHGVlqeNq7WTVeuyL+eX8Set1Cexz75QLTG6rn0113Bu3/ddMw9sTWsL9rUolxqeH1j88PzVQTUxq8LP2cMUXjRqr41AbOCX863Pab7ZbQpX6v/vuBbJp5MxJx/EnUuGQBFs1/kfVCrgtzKyvInkF41ZEyW+7EmPHHpGHh/Ld7uxl7LT7eFx4XUUj1DtsS1W9FNxbVb81WbosLMVo5Pfld5HrzhwUWYRWr/LrzvJOTzoQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(2616005)(83380400001)(66556008)(66476007)(8936002)(4326008)(8676002)(2906002)(1076003)(26005)(36756003)(6486002)(5660300002)(44832011)(52116002)(66946007)(86362001)(38350700002)(508600001)(38100700002)(186003)(316002)(6506007)(6666004)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DM7p0Evd/9tliQJcHAo0mksKP+LtNpQkbxlHmHJKdbtMKREpZqdVkWLiFzpvI/z33PGmAFiyM9KwStkosCb5vYfXOUt0nUz1e+ZSF2ka02HXqv8kXcX0lI1M0DPL/zv5uJsjFw5Zd2Li0N5XqM/VFPi7iEQo7NpNUc/H6Lyg9RlnnCBaECm4DJOHH1DId/B9SB8KD3dkGtJhgdk2O1uzqaxQoHU26OkIBbGT+TfknHfDCyrpQ/KJBazQIspRwv4eRiCLUqo8mMm3YgqLHqq6gB+EiViCLr8Salr8u9y491+lsogln3xxQnkkVD94DcYU4ZrcDmF9zQ6FbG/zReESj65rV8iWs3qAexHIdDBXqX/Whj253bAIdhoGTR3FmqpwP9doZLhliizsCCHB1kHSRnlfuhwVMeAN8x9aFXWco7sm1l4+PaFSp4tFr2nZT8nIgdtQSGwKDd5yB4QCA+6+Y/izAlZohga3DBpJa3BO/EBsAYeqpZ+R/813JiZSTNYuQe0z1ailgT5Bw0N39ep/3gn+cUL8sKakzCU/Q5lw0JWiBqDfIz/DGqleJHYDhioEGKpshx9nknRAlFYoZubeiTH/MdVujbRD+Its7klbJjAqDfrsGDQaZUMgGZnsD3MJAxudqqkAHXIf34s67fkLfvZW93oGxDtReO3yoCl4Mlw0Z2JvH2tIG5L/h+VXdFAoR9nMoCbY7isuuw71BL89dw3AlPb//h+0efY5Rcjfq0BYYxmePJQB4GAgJZw3msSVqzM2ACL8KSLKBIwWOfC1DPoEjy5N8bSYWdRQFxIeLPTLvXGpi1mef107fBdj80fPmVznMExmHVhgrPXvJh6Ersju7oKIxnDo5DqmRNqJ9uxNpSTUln5n3pnX9F/hvHjCbeUcX7aO/2gp2iIBFsbNH6sY06nook5pz2HBqiXY8niY3dKuFA6UyhswbDunWyaTwTrVppyjBacifTrM+Odu+rozcv4hr6BlPKB1Jxvn2RfyAj/V5Y+rmUSpb4LL52Ecz5O5YezDlMYImiBxcMNAcYj65g7v7OaNFIYpbr8v0XW9xMP0R1iSb/Y/s4kwhSA8L3tWa1E9nU242tm6DtF8NFRGhG/EXbPsW6LHtLwbxTroJ5NFY154v+/bGGLFTv5AeGtrqd3hOTZbD5DM0XV9x3wcUPPERfvjCNtVgpcwpqYrwQSTmoImTN0F7PVntop1DzRskhFIvV/Bb/KHPLiKgG5ipqOOAP/YxOLKFbfv63/ow1rlpm3TpFiTDg8G+dJ48igca0RuRRX7OFfvLMI7aHUrGc5+aNJ8pQBdo6Hv8fY5JRJtn3+NM7VsVsfuWnoS0CSouZlDDmHVldsO4aUtFRIwlFS+isoz1koyd0TurzTUnHlU+C4XKd6vl1/9J96F4S+DtdGts6rXw8b2KcZ1zuS33/ajKvZzfwkVjwGfVBQhQW2MGdgKP30gxS6nZ850DLS0FBCf1qBJQbLeoL2oGtamQ4pjFzHN3/5rKrbNLeL8Q5fAIOq5AVsqJVlV/ZLq1tHxTwegbtIicybE5lg/iQ76poeCcuX5ZYxmjAEYaop5UAsMgO1hwVSj7JhRFFKWpSV8h4E4wgn5oCuxqmc4h4T0HnmwkUKAhQa1ydyyUxk= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e635a2b3-7dbf-4d68-e85f-08d9ebade87a X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 09:24:01.4998 (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: qjFfF/DnV3dOnudwvXvKZ0j/IdJImqZ/Hqpy8LcIe5qDE4Bjl1K0eYMnD0uK9DaP9wYVvcMaiJC1uVIuLqIUsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5423 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Instead of allocating memory and then manually aligning it to the desired value use napi_alloc_frag_align() directly to streamline the process. Signed-off-by: Ioana Ciornei --- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 218b1516b86b..6ccbec21300f 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -888,14 +888,13 @@ static int dpaa2_eth_build_sg_fd_single_buf(struct dpaa2_eth_priv *priv, sgt_buf_size = priv->tx_data_offset + sizeof(struct dpaa2_sg_entry); if (sgt_cache->count == 0) - sgt_buf = kzalloc(sgt_buf_size + DPAA2_ETH_TX_BUF_ALIGN, - GFP_ATOMIC); + sgt_buf = napi_alloc_frag_align(sgt_buf_size, DPAA2_ETH_TX_BUF_ALIGN); else sgt_buf = sgt_cache->buf[--sgt_cache->count]; if (unlikely(!sgt_buf)) return -ENOMEM; + memset(sgt_buf, 0, sgt_buf_size); - sgt_buf = PTR_ALIGN(sgt_buf, DPAA2_ETH_TX_BUF_ALIGN); sgt = (struct dpaa2_sg_entry *)(sgt_buf + priv->tx_data_offset); addr = dma_map_single(dev, skb->data, skb->len, DMA_BIDIRECTIONAL); @@ -935,7 +934,7 @@ static int dpaa2_eth_build_sg_fd_single_buf(struct dpaa2_eth_priv *priv, dma_unmap_single(dev, addr, skb->len, DMA_BIDIRECTIONAL); data_map_failed: if (sgt_cache->count >= DPAA2_ETH_SGT_CACHE_SIZE) - kfree(sgt_buf); + skb_free_frag(sgt_buf); else sgt_cache->buf[sgt_cache->count++] = sgt_buf; @@ -1088,7 +1087,7 @@ static void dpaa2_eth_free_tx_fd(struct dpaa2_eth_priv *priv, skb_free_frag(buffer_start); } else { if (sgt_cache->count >= DPAA2_ETH_SGT_CACHE_SIZE) - kfree(buffer_start); + skb_free_frag(buffer_start); else sgt_cache->buf[sgt_cache->count++] = buffer_start; } @@ -1523,7 +1522,7 @@ static void dpaa2_eth_sgt_cache_drain(struct dpaa2_eth_priv *priv) count = sgt_cache->count; for (i = 0; i < count; i++) - kfree(sgt_cache->buf[i]); + skb_free_frag(sgt_cache->buf[i]); sgt_cache->count = 0; } } From patchwork Wed Feb 9 09:23:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12739908 X-Patchwork-Delegate: kuba@kernel.org 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 514F3C433F5 for ; Wed, 9 Feb 2022 09:25:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232374AbiBIJZW (ORCPT ); Wed, 9 Feb 2022 04:25:22 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:45136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbiBIJZT (ORCPT ); Wed, 9 Feb 2022 04:25:19 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0600.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::600]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17B83E03D72C for ; Wed, 9 Feb 2022 01:25:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=adPldMEH80bjAxPGvntsV0Ey4+heygsJiR1dQAI3MZfpia/MAAjm8VRCA+Wlv66y2CrhQKPfGWA12x1AcfbAoWfHqYJ84XT6Q5ZrCcwQESPX4Ra/YJvHJVHkL6Ab6QwtlPbYrYj4OM61W0909KGXaEb2FmFZk/RsORFKR1PqNnCoWKJW4a7+bxfXbmyrSlenc9eBwM8XwIF16XUTGrA22l45O0JbrTI1mv0oOdfOJ+CfKptj9pcWaf4Yyu5247C8vx50V6qRW9+JMhGw2936sNThtHyN4lBqCp7kaQAmwguDIRMw+KaS242sFJkz3N42BoLLJ0MMG265tybc8qx/pg== 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=RaWyxIpeNOfGLlIWGlvMkZ0N1zcYFmdXBN5cS4LSbBU=; b=GhS0v2fbf6rDvyLm0HdGQ38c+Xyr/qqzuBdfRRH/dAJUUNO3BaEND97uhOyC7PxgS+Z4YqrflzOIwcJOz4DDpi1+zfjldnmp3fRtV8ac1lZVi5aCM5/tjOpyoqtkW3Ychck4txXZ/MqhfIyOMFZ6Qgb4yyoI2bWoURfS+ndIZ+BAvYwspdXKP65hjJHCdNwI+D7NFNer4w5ydivBZKNi4+iSyN77rfILycEY2AvVr4q32b7eXpeJQ/KF9apH4Y4UPT8s4KCINHlsue1OgHK5GcVPZ/igIy+IOtybJW+XH9Rn7jfkrOuZ4n5tVEtY9d9cKpwjo5AwtaxW+tewgk6pBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=RaWyxIpeNOfGLlIWGlvMkZ0N1zcYFmdXBN5cS4LSbBU=; b=Twnq2GRmWOYxe5yoAe51hEicYZX4QlNPZKVd16ykneLW/81nu4ubGcsSC1nxxtMOw/vgziBbIV8sgrvAFqyZ6q9TrxB5XccZIkb1fBDAlLuYtBEH21jjTQ9EL5IQM6PpXzRHCdD4PBceHD9nyVIY9owGmQJHuU7iqnNzrb77wRk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) by VI1PR04MB5423.eurprd04.prod.outlook.com (2603:10a6:803:da::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 09:24:02 +0000 Received: from AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::5df9:5bf0:7ac1:a793]) by AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::5df9:5bf0:7ac1:a793%9]) with mapi id 15.20.4975.011; Wed, 9 Feb 2022 09:24:02 +0000 From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: youri.querry_1@nxp.com, leoyang.li@nxp.com, Ioana Ciornei Subject: [PATCH net-next 3/7] dpaa2-eth: extract the S/G table buffer cache interaction into functions Date: Wed, 9 Feb 2022 11:23:31 +0200 Message-Id: <20220209092335.3064731-4-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220209092335.3064731-1-ioana.ciornei@nxp.com> References: <20220209092335.3064731-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: AM0PR03CA0037.eurprd03.prod.outlook.com (2603:10a6:208::14) To AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3df7aac8-0736-42f3-65a7-08d9ebade900 X-MS-TrafficTypeDiagnostic: VI1PR04MB5423:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +G5xeI8fW5+e2vDzA0vVfNXKzOKes4NjEb6D3kGxwfIa8RpPMio6xTmQaAZ0pS/jViuffm65qcnRSKxduI4JsddjNhlrUp4HhasUJ4fsMckWMRoK4ry39yEFuAOu+Ng/yAoq73umxTJ+laGsY37OB1jSTFcnfI+zJ6RAbibiUzHgs4j5bP+nvzRbbea0jYY7YOXPUPkSTe73axoY4lloSIO5JmZwqpl3f68t9uP6x9qWXoScKHI4p3uxu+WLdePRFtcnHCHottWZljw9CLJOAPQ9z8pMz84L/c81oetMFyTdS13hQEznhI3AKr+9FFBWR8f2Undo3JP+IHLcBpX2P00Z/ItC13VbixuPojCe0smtS3VbK4WVWzTGnJZDsGegbA653igzBoRYzPJbtdpSKK+O5EXsoecfGUp6RNcqQkfsn9BuhJTKh7YovyKBPuZimwLHge5/eEVlm8S/sWjiiRDZAwQp2a2GKcTKKIaLkPOTHUmQk8O7eikSFMytmn54VSQv83qdN2oOrqi5J+VOG3bj9TT/wuklKrCeaMp0uL7PtL8L3sLLAB3m7/sB6iX0S+EEMxFAKPuhSGMnCyJWo61pza2vBl8VzU4c5+kWZztRakqEMGegJch6Dw3WfkhezU2sI4he5A98ptWqEse3wJu0eJ8ODmWBhx4r94tjs6dJcYa23+eMOatWJx2r0B1S6RKxA4fZHJIrNn7BKpOKSg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(2616005)(83380400001)(66556008)(66476007)(8936002)(4326008)(8676002)(2906002)(1076003)(26005)(36756003)(6486002)(5660300002)(44832011)(52116002)(66946007)(86362001)(38350700002)(508600001)(38100700002)(186003)(316002)(6506007)(6666004)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wiYUF3edSUK8ajIXtzV24CM0NSoG6MRkcJATAybae8Q3ROVAnB/S5WOcUjRa3cMuBNIs7oJJJo+VnkOpqVqngZ5OCZWNBBD99Xm1alH3SDRIapgYAch1P0fW6aUylaXCYghUzAJDI1IjjO7zBH6ESVcok4B4brwZPSDc9mRhrEW0Upqkj0hm5e/5sPIOfWfCUH/ky9UNtFjTnoEEBm0JgSIV9mCMpjygae7zTKrbC8n8RpuQtboEdVNeW4cvysqpNwgKl3d2+hycMfDJYaVwuzN4iKglozBXUJui/EyjfpM/hPTvRMskR6wRMoKHhZ5kbvfPvCt+MItBEG091LY69kHnuXvdKwRn4P6g1ZXX/sMqC3AhKAV7WzdKCEVgHXFAz7Dg19J2wyzvSNXRiqnJx5FZCkbCR5gBC2DUFQJoUpRxGu+vCmzlzCuHqElgP1sZAXvcvYt0fuyqM1ga5/hDzrPbMYnPkIYZd8DIbPxXt1ic7XK1mN5WyrfLyRDwZB8Tq594C8aHqf1VGz8rf5Jy31YI5uQ0yQIeooH762+2sRiCrz3aYBJSIe3DzTMnzxG0YIwoCHdlMjXSF0mwT/CKXTnION4Jla7SvFsr6TFLFX9xBU1lmYZHfaf82rlLtt7ffZNf1S6gUn+VIn2xGpp+iEHHqZ/gvvhyH5X3ZZ8t790PVk0Ofp+TzjjinloK6PBOwcfIlLb9G1z0pkaT6Z3oAnr82te5TxLq9DnW+ePi0mrmdLik5IfegZwi/sxc+xGcFUbdnsZzwoXwDMu1Qq3gVpQn5JKAv6Eoh6o8t50z6e1Wn5owz+pYGu+fYMNC9zjnGP4bxm3Ti8hwd3zDPBDcYm9yhzl1FYjeZ67NH1w55bd5yswKbazPOP7MmphqgcD38eA2NCy8VKt6UuyVwGyIrDFWYhodgcyy9dilD5epb/Ui/aKBvA1xAfprIl83tBkQ/EevnqJ2bsHtqzE6pgqaf8axlK+Omb+Fs/7RCXtrWOq8D5gobTVKQLhC4DU+YZnFypyzdaIFqDn0VfH6NlqULP2C8EzrRiMtrvGWZGkq5g9y0rcQSJghj2N8vBBiuin27JYvatE1UNsWu3ZsU4k7r21+bDuU2hhOPMSZodV4BsTzANXjGkXMcSgPqGeE3qxWRfQqLG1NtrG1A4lWeyfWeFfvV6ecuy7mhjmDTz6D2P3bEKND0QG4WtPiiKpdSu0epYMOIp99RPWwcdr2ib4zX7yXJsAMwKgpgrzM5gTT/OU/esYmUr/IqH3To7GIfNJxiCYbMbuw0FyGb+6ZFsOJ1m5ghC/2RQw+gx3FB5VzHtO12kWvniz98Q5CL2UF2GPYoJc4k+dQPD6+loByuO7vRcAzDLdkbw5XNptfgl0fcIrzmjBtiSrmQTDxAU3p7c+fO1B4gM/snYj4wmpeODRG0PXkLftgWwdPeLWqAwqSFqnZ28EfMz0JwLEuCnaRYb8QxQYpGjZF/uuaNRbUtk+GEVPDvnc8VIoM/FiZd7CLhGWIrvOnQQ79WMK98GDXRO+/F1LHzCv3nIb/T+Cr+FKnpw9N721kOP5EDb9J1cgI5b0pQOPn61qEZd9wAjJFM1T781GG+K6J73JBjwUe51YeRvif5J3h8tvBbgLNKyjKvWw= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3df7aac8-0736-42f3-65a7-08d9ebade900 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 09:24:02.2826 (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: MRj/YMwcTur9W0ukNK5Rt+yywqxqoX27ExUg5foIJOc6yDwoHfG6lLzp/5cqvRyge+Wp0QSWUjt5aLhzPVRISw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5423 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The dpaa2-eth driver uses in certain circumstances a buffer cache for the S/G tables needed in case of a S/G FD. At the moment, the interraction with the cache is open-coded and couldn't be reused easily. Add two new functions - dpaa2_eth_sgt_get and dpaa2_eth_sgt_recycle - which help with code reusability. Signed-off-by: Ioana Ciornei --- .../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 61 +++++++++++-------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 6ccbec21300f..006ab355a21d 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -760,6 +760,38 @@ static void dpaa2_eth_enable_tx_tstamp(struct dpaa2_eth_priv *priv, } } +static void *dpaa2_eth_sgt_get(struct dpaa2_eth_priv *priv) +{ + struct dpaa2_eth_sgt_cache *sgt_cache; + void *sgt_buf = NULL; + int sgt_buf_size; + + sgt_cache = this_cpu_ptr(priv->sgt_cache); + sgt_buf_size = priv->tx_data_offset + sizeof(struct dpaa2_sg_entry); + + if (sgt_cache->count == 0) + sgt_buf = napi_alloc_frag_align(sgt_buf_size, DPAA2_ETH_TX_BUF_ALIGN); + else + sgt_buf = sgt_cache->buf[--sgt_cache->count]; + if (!sgt_buf) + return NULL; + + memset(sgt_buf, 0, sgt_buf_size); + + return sgt_buf; +} + +static void dpaa2_eth_sgt_recycle(struct dpaa2_eth_priv *priv, void *sgt_buf) +{ + struct dpaa2_eth_sgt_cache *sgt_cache; + + sgt_cache = this_cpu_ptr(priv->sgt_cache); + if (sgt_cache->count >= DPAA2_ETH_SGT_CACHE_SIZE) + skb_free_frag(sgt_buf); + else + sgt_cache->buf[sgt_cache->count++] = sgt_buf; +} + /* Create a frame descriptor based on a fragmented skb */ static int dpaa2_eth_build_sg_fd(struct dpaa2_eth_priv *priv, struct sk_buff *skb, @@ -810,7 +842,6 @@ static int dpaa2_eth_build_sg_fd(struct dpaa2_eth_priv *priv, err = -ENOMEM; goto sgt_buf_alloc_failed; } - memset(sgt_buf, 0, sgt_buf_size); sgt = (struct dpaa2_sg_entry *)(sgt_buf + priv->tx_data_offset); @@ -875,7 +906,6 @@ static int dpaa2_eth_build_sg_fd_single_buf(struct dpaa2_eth_priv *priv, void **swa_addr) { struct device *dev = priv->net_dev->dev.parent; - struct dpaa2_eth_sgt_cache *sgt_cache; struct dpaa2_sg_entry *sgt; struct dpaa2_eth_swa *swa; dma_addr_t addr, sgt_addr; @@ -884,17 +914,10 @@ static int dpaa2_eth_build_sg_fd_single_buf(struct dpaa2_eth_priv *priv, int err; /* Prepare the HW SGT structure */ - sgt_cache = this_cpu_ptr(priv->sgt_cache); sgt_buf_size = priv->tx_data_offset + sizeof(struct dpaa2_sg_entry); - - if (sgt_cache->count == 0) - sgt_buf = napi_alloc_frag_align(sgt_buf_size, DPAA2_ETH_TX_BUF_ALIGN); - else - sgt_buf = sgt_cache->buf[--sgt_cache->count]; + sgt_buf = dpaa2_eth_sgt_get(priv); if (unlikely(!sgt_buf)) return -ENOMEM; - memset(sgt_buf, 0, sgt_buf_size); - sgt = (struct dpaa2_sg_entry *)(sgt_buf + priv->tx_data_offset); addr = dma_map_single(dev, skb->data, skb->len, DMA_BIDIRECTIONAL); @@ -933,10 +956,7 @@ static int dpaa2_eth_build_sg_fd_single_buf(struct dpaa2_eth_priv *priv, sgt_map_failed: dma_unmap_single(dev, addr, skb->len, DMA_BIDIRECTIONAL); data_map_failed: - if (sgt_cache->count >= DPAA2_ETH_SGT_CACHE_SIZE) - skb_free_frag(sgt_buf); - else - sgt_cache->buf[sgt_cache->count++] = sgt_buf; + dpaa2_eth_sgt_recycle(priv, sgt_buf); return err; } @@ -1004,8 +1024,6 @@ static void dpaa2_eth_free_tx_fd(struct dpaa2_eth_priv *priv, struct dpaa2_eth_swa *swa; u8 fd_format = dpaa2_fd_get_format(fd); u32 fd_len = dpaa2_fd_get_len(fd); - - struct dpaa2_eth_sgt_cache *sgt_cache; struct dpaa2_sg_entry *sgt; fd_addr = dpaa2_fd_get_addr(fd); @@ -1082,15 +1100,10 @@ static void dpaa2_eth_free_tx_fd(struct dpaa2_eth_priv *priv, /* Free SGT buffer allocated on tx */ if (fd_format != dpaa2_fd_single) { - sgt_cache = this_cpu_ptr(priv->sgt_cache); - if (swa->type == DPAA2_ETH_SWA_SG) { + if (swa->type == DPAA2_ETH_SWA_SG) skb_free_frag(buffer_start); - } else { - if (sgt_cache->count >= DPAA2_ETH_SGT_CACHE_SIZE) - skb_free_frag(buffer_start); - else - sgt_cache->buf[sgt_cache->count++] = buffer_start; - } + else + dpaa2_eth_sgt_recycle(priv, buffer_start); } /* Move on with skb release */ From patchwork Wed Feb 9 09:23:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12739905 X-Patchwork-Delegate: kuba@kernel.org 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 D3637C433FE for ; Wed, 9 Feb 2022 09:25:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232011AbiBIJZE (ORCPT ); Wed, 9 Feb 2022 04:25:04 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:44142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbiBIJZC (ORCPT ); Wed, 9 Feb 2022 04:25:02 -0500 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03on062d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0a::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CE0CE0AE452 for ; Wed, 9 Feb 2022 01:24:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ELBeKhGirdbX2wiWQ9YPLoTx0kitJPYARR0+avTYpx293OyDpNTJ2gUeMCgo712UE/bBcNPkU5tntMP+ltZmPht1aSQL7n4l5bnn4jqyA4jleZ54WZV5JFhsY9EcRYWdD+C3PxR+r4tSwDgolAfjzYN3Li53veQqP9CFcqdHa1b/1BWxRoYi09jKa565h+SgunrZjkqxQ9KhqmNSf2iygl+UHVae+YWz5K490VO66FdAGlbfMSxAlYXet9IPyA+Z7tpN2DQ4Xt/TjnGHdWsiCDzOIZmN8J4/hV2RkMY5L60RLzO06/4MVanY9n1VWEQ30Ha14wp7H7xxvyxpqo3dRw== 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=r8tw2PfGESWAy7OiggmN6W1fdruCW0dTTFhKxxgjdXs=; b=bhID3mB1DZXLKlEoF73uq1EJn17jOWX3mlik2wdobMuhF3p4PZm0HyRuZUIr+nvBy4xcWX59WOnAlaSvQY1mz/docpCT+KVjX1NERJMyO5BYrprbBI/db+SAWMhlVafkdvAGkpof6f8cnYLcDGRZvy+MMF+fzXn2U9Wd2bGjgP78iQEXXZzj+bACn3SHBrp/UNQLxTWy8F7Q4Q1YDw49SfzGR6RSTyCkmYf5qhaOmGvlpfxBLPe0rwI3RurBOS4I9ScBLV2MaOHTknnlyVeOG+ubVnwB+Yb5GR2Z1dN3VvmRGlSv1HlH3WM3GZty5QYss7YiwKWS22Hb6X3PkEY5ow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=r8tw2PfGESWAy7OiggmN6W1fdruCW0dTTFhKxxgjdXs=; b=e8v5ay0VSQrCU9bKAtHpbSbaZsztIKTCvJRl2nmINY9wi/DjTpkgnDp9CP2Tefd/b0bC9QtkDkpMElazAdLSy7ERFk5uokE31+hsf34Aonm9WfFFN9hMEQKadjBZJHBVlQKuZxPpnBWd2tNS+GQ9RkhWQpuzOinUIDHPszrL9pk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) by DB6PR0401MB2485.eurprd04.prod.outlook.com (2603:10a6:4:33::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 09:24:03 +0000 Received: from AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::5df9:5bf0:7ac1:a793]) by AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::5df9:5bf0:7ac1:a793%9]) with mapi id 15.20.4975.011; Wed, 9 Feb 2022 09:24:03 +0000 From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: youri.querry_1@nxp.com, leoyang.li@nxp.com, Ioana Ciornei Subject: [PATCH net-next 4/7] dpaa2-eth: use the S/G table cache also for the normal S/G path Date: Wed, 9 Feb 2022 11:23:32 +0200 Message-Id: <20220209092335.3064731-5-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220209092335.3064731-1-ioana.ciornei@nxp.com> References: <20220209092335.3064731-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: AM0PR03CA0037.eurprd03.prod.outlook.com (2603:10a6:208::14) To AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: df4ca472-7c63-48d0-b56e-08d9ebade9a7 X-MS-TrafficTypeDiagnostic: DB6PR0401MB2485:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GTYGraxb2ZlBCLe5ynSRoldsgKEe+YM1Jc+538yAuhJL+BDKkB5H1ivy7UvwdjyiE566HAiO5YLfb20mo/Ic3FwihUo8xEHGPmSdLWNCJrQfSEr6AaQcRoU60Re4BBlCIHmZZAEY6kknhCEXY5FtR0SwEEOrvPFKL31Wo/yatgZsnXhxnEsvvQyYwWvoJSGK0/WUqZRnIJ0ukaoBl5uLKBoWrSxzQf7izqNxu7eWKfyZCml9+WGaGUZvNNp3yRyGS/7wgHs9NzP1iWNTKCgsHWHahi3YRFjJ8dhkA4q4evQDagb+z1aJTFwDx4CoLUkH8l5op0h2j8M8gXXGBiy6eeoeshMVIunsydeZ1wGnoa8y5K0qflHN57GTf+fg+EvaTUBmh3pusRABH4l7rFs3zptYXfjSoAhxMFPiWIruD6XbAi1Uy+OYSLNx4cP3X6gvg+h/Xhx2oQ0HCDley9BZrYB5snuNhMe9wOQmUP9uaQbflPTofVTvvNLA4dfpLEZM0g8JppraHy9WdDR6HD5GQTRghyUiyvOxEU+a+pbwYHw3FcoHkaBF7C2hinTAXs9a5qQRHFEugKPJD4OZyTMtpeJno9MJ6euyS5e7QbT6+NW2riZngUqQ3fhKvcWbW/hVhatpcUnpkoRtpHBfCTzxSlbBVrZjOP+GjJeuLKpGnIX7jZnEekconUO9mttJZgEY2dwimsYchE4kEFhgMbofmFn6KRqLGOzzTYThDGeh7Ogv9X5fb3Q2M7Zbnd7EcVxo X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(186003)(508600001)(26005)(2616005)(1076003)(6486002)(52116002)(6506007)(6512007)(86362001)(6666004)(83380400001)(38100700002)(38350700002)(4326008)(8676002)(66476007)(66556008)(66946007)(316002)(44832011)(36756003)(2906002)(8936002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: djdVRiAY0qNWPahl2LeLjbPTnfur1zUBcxSjqw/zzAlALq1sRRpzEkn6rtw7ac9gWSTAsWtiJhXmZDN30yCqAA4eb1s/iNkQEaX6HJE4+Hz4jwRS4DODV7AgzYpmNNpGPXirvFYfrN3t7rH/dcsBZCyQ+k0AztWaseb9/PCtay0UX3a0lXOPj92roWK+tpgAg1TvQGnZrB8Ik+IvozvXk+w4sSgGap+MboOz7iaJXSkyAS0vC2wNxJzrL67z60Ux/FjphHU3FxNvfCh/6ZO19ywkOwViRcVasNZ4pcrm/xW8HO6Dn6Jm96yJkwcF3AzCVCPAhoDw2iYO49K7FVLmd8JEuFl36/6SnYRok4e0nHwHV49g4tyqzcEF8f7czOKqmQQ0DuNuHxgo2ahXb2b6yf+1669xGF575enzuJNtnjKDTItEp1SICv4AipPElyB5Qv+3SJOLhPCZhyJ+4WFIx2EtgdpiBusG2n7vIkUyXjfmUIZykkxwMKbHfWbuvm4q1tnzH0yA6ZLGraVzieTJ5MuAiu4R9BnhAhOK9qRjjvAxJ9v9Rt/b6tSXLMkCK29z0MTJ7KHDQhovMlRM/eR9Pd1ccXfjzl/sMYM0nmqtR9ioZMa6x9Z0dLOphwzUIjhI9jcDA2ENG+j2dIIO2S9u6dDRDlYCmke/+Qxn2z5z1VVbyk8xEw/I32kifR5ef3anUj4ePbw7AqdvbMaXnN+/YfH5oZ6dc3TzlQNGwGYVNxPxxQ8/8lQpNIxeSrgImqcnyBVedAZFYUO/JDZZQM9d9hw48ojitvP6Lddd1nJDl9L4YCA/YJphVs8MH9DpVg25NOIGPINKvnbBNsgiHiL6vIoEvgYgan7gRs4ASD8xJQYsYZqWOXz2LxQ03IgXLA0co2b0JPz+EoRriQLbTujofMAqPUK3piZF9tedNAubygTgK5XFTQeYUvYzkXCoocuI7Kof1DeW+6dimz9sxZAmp0QFTPvXbIel9o/tTk5INW9T/aEyBmQskIE1j1FpZkJ1C/jx+61DW8Z9hLX5F7QdSdGvLJmUoLqn6hgYyIjt8VBHzKv8GKoYfF5cQ0ViB3KBPv9SRWcl7YPL9XCJKJYCOFAHsTRSTVyYFzxQF6Sxl2kN5AooPWevW8Vu5kyPgEtxn26enUYbaw9BJ9L0zgOEUBIp7eDtqw3KOfiHQWCPi69OH0B6yGWmp/tF0zE6YJR5fdcmmskSAYxg851ld6yEcxRse7Mxr7sD4GJNAtI01g9S/IsnSbG7rJeEHCximzFnoxL7y0wWoqd+DIAEQUzE0zPR+0HyI0kuE1usIDXAD63YSfX7Ptvt/vhcPms/LGbSefSgeAKyoGJCNJ8EsQHlhJU9OoaCmVvQHqhH+RXmc7YnT2VIS/bCsCPYRabJopYFrFxQlWJw131lxTO0li2HeAVVADgOdkGU1Wyre9GPBwU8R0QcAtMLQ4SvDhj0lljL2fVmgFOfYwdPtmVZi9Qqk7kfSW19VlMtCCpqq7PF5NsOcAH+ZhecEd5w0L/wnwS+8sC8/rjduxEvdo9crwIK0/IED43aFH2JiV1nQSCrro7Rwg7yn5nnadYF+CAgzp+6zQAn2MU+fOQ96oESK6AqBYu2YFABbrAwIu20z2anae4= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: df4ca472-7c63-48d0-b56e-08d9ebade9a7 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 09:24:03.2837 (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: TjJHmWF1M/mVS9tnJnlyp7kgA9GEwqp1CvtSpVKIVdmphCtW1PZ7P6VlbZ8oWg9C31PYhbkrPskoTinkNjhzgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0401MB2485 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Instead of allocating memory for an S/G table each time a nonlinear skb is processed, and then freeing it on the Tx confirmation path, use the S/G table cache in order to reuse the memory. For this to work we have to change the size of the cached buffers so that it can hold the maximum number of scatterlist entries. Other than that, each allocate/free call is replaced by a call to the dpaa2_eth_sgt_get/dpaa2_eth_sgt_recycle functions, introduced in the previous patch. Signed-off-by: Ioana Ciornei --- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 15 ++++++--------- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h | 2 ++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 006ab355a21d..73e242fad000 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -767,7 +767,8 @@ static void *dpaa2_eth_sgt_get(struct dpaa2_eth_priv *priv) int sgt_buf_size; sgt_cache = this_cpu_ptr(priv->sgt_cache); - sgt_buf_size = priv->tx_data_offset + sizeof(struct dpaa2_sg_entry); + sgt_buf_size = priv->tx_data_offset + + DPAA2_ETH_SG_ENTRIES_MAX * sizeof(struct dpaa2_sg_entry); if (sgt_cache->count == 0) sgt_buf = napi_alloc_frag_align(sgt_buf_size, DPAA2_ETH_TX_BUF_ALIGN); @@ -837,7 +838,7 @@ static int dpaa2_eth_build_sg_fd(struct dpaa2_eth_priv *priv, /* Prepare the HW SGT structure */ sgt_buf_size = priv->tx_data_offset + sizeof(struct dpaa2_sg_entry) * num_dma_bufs; - sgt_buf = napi_alloc_frag_align(sgt_buf_size, DPAA2_ETH_TX_BUF_ALIGN); + sgt_buf = dpaa2_eth_sgt_get(priv); if (unlikely(!sgt_buf)) { err = -ENOMEM; goto sgt_buf_alloc_failed; @@ -886,7 +887,7 @@ static int dpaa2_eth_build_sg_fd(struct dpaa2_eth_priv *priv, return 0; dma_map_single_failed: - skb_free_frag(sgt_buf); + dpaa2_eth_sgt_recycle(priv, sgt_buf); sgt_buf_alloc_failed: dma_unmap_sg(dev, scl, num_sg, DMA_BIDIRECTIONAL); dma_map_sg_failed: @@ -1099,12 +1100,8 @@ static void dpaa2_eth_free_tx_fd(struct dpaa2_eth_priv *priv, } /* Free SGT buffer allocated on tx */ - if (fd_format != dpaa2_fd_single) { - if (swa->type == DPAA2_ETH_SWA_SG) - skb_free_frag(buffer_start); - else - dpaa2_eth_sgt_recycle(priv, buffer_start); - } + if (fd_format != dpaa2_fd_single) + dpaa2_eth_sgt_recycle(priv, buffer_start); /* Move on with skb release */ napi_consume_skb(skb, in_napi); diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h index e54e70ebdd05..7f9c6f4dea53 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h @@ -493,6 +493,8 @@ struct dpaa2_eth_trap_data { struct dpaa2_eth_priv *priv; }; +#define DPAA2_ETH_SG_ENTRIES_MAX (PAGE_SIZE / sizeof(struct scatterlist)) + #define DPAA2_ETH_DEFAULT_COPYBREAK 512 /* Driver private data */ From patchwork Wed Feb 9 09:23:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12739909 X-Patchwork-Delegate: kuba@kernel.org 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 334C1C433EF for ; Wed, 9 Feb 2022 09:25:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229753AbiBIJZa (ORCPT ); Wed, 9 Feb 2022 04:25:30 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:45706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbiBIJZ3 (ORCPT ); Wed, 9 Feb 2022 04:25:29 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0600.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::600]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 636B4E0AFABD for ; Wed, 9 Feb 2022 01:25:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SwHllJi8HdwDZ9hbu5s/ne3NjE0rVVaxd2b+Ei8dI7xlt21o79xQH1xrU+jKtcE3/7GMGoVDUdynOO5P7QJdZ/JP0XTQSG6lJE4YUGpvIl4DBsKOd5uPOMU+4lZUxRLbTGtne5K14RCgo6zo1TObzxhMVBBdlCMJ09UQVeGifVVYwqi4lNMce3csR9Pp16tcVZewAQt8ELlU8ace+I6Jv/pJZ9aae2/9mKI9hp9Czxsy77O4hUJ+UUa9hMMtaJAxM6CkInJ9IsQuWMGwIDlDWuqCPnpgv2imcPVmr73p+FE+TGuXR76i8qn9S19AYYKKDpm8agybnjiuJ6aJETvu3Q== 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=0rleTzK79zSdJeNqyEEI49q+ziPUwcTWDGz6+83FDSs=; b=XYhXMUk0LOuYlzaoLH7GFujT/r25jg/RYVs+PHZAKAbc+mD1G8HVxdSjHN70DGKdjBheWRVKF4IymYBQstPvApBhgqpnDUc8y+2mZJj0Qweswg2ltTtNaAlLbyHD8zs63yRQEP2xf22sM1oeepmdgrRR60cX/wE8vUJeabGNTiJQESmXsyE8zH06NKGcjxO4l9ANYNFLYBtKGNiIe6orlatfH9vyzpqWf4gRZb3JsD6T+Rcd8hflpyHjzDPX3z/BPnIWHIjrVsnmHLSV89yIx3t5JihSTy81F3TMb2q3bBG9JgmSlo/KT6f/InJ4yqjA31EyErnaN+Kgu6HoMjxYGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=0rleTzK79zSdJeNqyEEI49q+ziPUwcTWDGz6+83FDSs=; b=EWL/9/yShn/gE7dpfBbnXP0ccTG/2AI2nVbWtns1DpICK/VPerX4de3CGJ+UNm76C7AzX7J57X9bmsH5ZSji0hYZPvDU6BixtV5fUksfRA74up5mq4lnCl0xjmqfhpbrK25zoGfZjmHx2+o1kBJBJAFLCPT20Tx3UnMps9WvyJU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) by VI1PR04MB5423.eurprd04.prod.outlook.com (2603:10a6:803:da::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 09:24:04 +0000 Received: from AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::5df9:5bf0:7ac1:a793]) by AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::5df9:5bf0:7ac1:a793%9]) with mapi id 15.20.4975.011; Wed, 9 Feb 2022 09:24:04 +0000 From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: youri.querry_1@nxp.com, leoyang.li@nxp.com, Ioana Ciornei Subject: [PATCH net-next 5/7] dpaa2-eth: work with an array of FDs Date: Wed, 9 Feb 2022 11:23:33 +0200 Message-Id: <20220209092335.3064731-6-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220209092335.3064731-1-ioana.ciornei@nxp.com> References: <20220209092335.3064731-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: AM0PR03CA0037.eurprd03.prod.outlook.com (2603:10a6:208::14) To AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 740172a9-91c2-4ef3-fa12-08d9ebadea12 X-MS-TrafficTypeDiagnostic: VI1PR04MB5423:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R3D0fEbeo8aBrtqzTxmctw4GIjDogQ1m3bRlWXSJTFHAXQOk54Z6KPF7uVpY1s9WDXJDa0KK/AES39Q/kiIexvXcRFxr04kxDKQcmNYZ6FbVDEgvMnW9sxUKiHfjeXAeDJEfxexPl53eZys4U5nxhfFx8+/fkOPc1CJB7Nv8DyoRP/GYbVdqBeP06Nb0Xzj6pUutVvqx4MnH4HMKQ/VPW6OTL4+EG91t62aBaDfZJzUVpN6sOP/LtythjL93ioTwhGZ8XEczbt81CPLjQips9g5uYa30ASgNGKe5P0YwMopBCWECxOkcSACkGgTk74VE/XJ756l9gtmHXJOsdcAf1eR7C4whRHnvOwhbmDOf4VWFSGxVDAOIiV6TeYyQd2LReP7+W/7bngrXmNwYTir410c9AU8j+GG8eYvuFvMo0cTXSMJhWGrAeX5ipdYv+NMyjQw+5LWuOtZv2lfddbVUKQx0VAC96RqT8BTxWZnxXdX10+RobPrpcM81Df6pLBznOWx5Z3w1wbIhxZv/0R4TsntAtIb5FJ5ZclmfUJwAYhVgNuJk2v6LrvLojUsA6XUAVkyyxUCoGjMLydh/a2cDB6Yov5lIcUyO4PKIXYlQALgch4AcMFLGO4cSmlcBgmo56kzo9VAny7aBRL6Dmn4w/5P/dI0Dlp4oRjS/U9pXWnER8iZSo8zgan1dSF5gGC6coL0ALCgiA7mGzirpKkJe5w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(2616005)(83380400001)(66556008)(66476007)(8936002)(4326008)(8676002)(2906002)(1076003)(26005)(36756003)(6486002)(5660300002)(44832011)(52116002)(66946007)(86362001)(38350700002)(508600001)(38100700002)(186003)(316002)(6506007)(6666004)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hticUJiWm2Cpaj6gWYOPX87ZPkGgHW1BaNHL/3qGMl1Mwouqu350BuDAPVAtyQX76XxBeFC4sTxkh+wV31TXKCAxip5zY+MMk/lmbaj+3s4Y7atnvcW4Pub/rqMQD/S/egBrhcYTQS0CmBpaH1+3TJpKccOCvjYG2aKBwZBzqb8KRQzlMxU7p1rWn3q1sq/TOoYyBkqUL4ij0ckl9XQXLdfdTwAFaleqsxon6khHnN2mSwxfZnT77IFBnbU4CKwouQTgNVuQlN0eXP/yif7qhNhyDilIhIGFau1uA5i00ce8PPlU3gCfK00LfiVOe2e1vwm5qMAulBad62T15zOgZFGx/Cnc1hnvfS5fONvM7J5hZw+PXNzvYUR9tP8Z78a46BabBFo/u0Z0WKEN5noQ+JTHAgqd+vaW4MB3ukhil7JfoVJ3neTDIiB7mXx6EFIXztSzienI79msCOG7xVd9dl5sq5zd3b2Uulk7Os1oJgFz0wNODCwBLscms08zJgWhpxmR0bgI4SMhIRdPwgffob7rXsSHiYtBHem5KVqCFP9BSA9kI7bY2u1nOncoBPgonr04oTUOujThxZloooVMzc0LUHUGtRoIUs/RVcg6pT0Agir+KnTPJ5Zyqz4vEN/a58fN4HA5FtvB4RrAG7o0G5jlK1cunn+Ja/NcCyL0FZSQHBCYvqz3cy63k8BWjTZL3HDZA5QHsOMv8Qx2LLthBmJWwU4Gc6QX43r2No9i4u0EIB4JiCc3J6OzKwyhpHzz1SndnX1RhqqEOipamkTAuaF0FMBeMqnRpeqg2AFttAfjPl3WtoHvnBXuPXIQOImDw3f1St/vS8WBM1YNhAFdKpbfKOR950dTBTNFu+kwr+A7S+UDvHB5//5b5B2on87cnZP/FbHUaQlP5x6vH53TOg81H099f8UbpFC8ZuJkpT8kOLES3MJdCmGfRza2vTkJW6NAptiLSXO407qJp264Qd1F2JtlEmuEZmluFOQQvAbH0GJqWd89SSfIrhgR/C4lQ4BMOws1TDelbCH4CTqBm+7urrHdtqBUtz1bIX6ttsxXHpVMnz9jWDE2JzFwV4TI7eO1GuN4AlKEaZpZC3uCVK8BukQwZdOiaE22o51BYhTTEW4zDqoJb3uduEj8wqAuJ5wjfbfkOxvn+0TmbIsqypYZWuhaCKC3zVBVX7cnRYyH7M0cOnRI/t9d1FGQcOdY+u1VzK4bCDk+FfabeBmJxrrHFMTbSfT9hYtUOJkpyeevAnOz1S5QpkvqD5EORg3zaU866PZTG4z2Su2HzkF0J/Ay/TOcNf21oYEae2WxtkiU+a03SbGdAVxfs5vRg+iCIUqSAyXj5xgokFCcXdhxdwLZwzwUQEK8vTUcZYRYpDXUg2aGFSP/OGBVQEE+mNsjy3FrOeE6GJXVO3G0I5vEZOipsm30JZnY1FfG5Qpz3Ecbc7m1bYr9xZBDFghG9Vp/uA3iE+yzz86YS+0TZsbuCB+uBnFQ4F8vhpZ7YqeR9Am3zkKDUNdFuL8ZrYbvh7MrGBfUD2DzYCY2SQWkJy3v5xk7fTPrbnJO4eFDcXTzWVDdagXG+aK4d5VSoV/6UxLABCfAJdl6/uiJly12hKUNarUSvyvdWuyc2CktxTWto9U= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 740172a9-91c2-4ef3-fa12-08d9ebadea12 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 09:24:04.0179 (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: noqKporooznJhF9oKLQ/CvPf5f4GqsyhvPVDpQnODM4b+sHQLVETM8pdV5vfZ9UIJu7CqvSp8K/BIyjZ2FmpTw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5423 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Up until now, the __dpaa2_eth_tx function used a single FD on the stack to construct the structure to be enqueued. Since we are now preparing the ground work to add support for TSO done in software at the driver level, the same function needs to work with an array of FDs and enqueue as many as the build_*_fd functions create. Make the necessary adjustments in order to do this. These include: keeping an array of FDs in a percpu structure, cleaning up the necessary FDs before populating it and then, retrying the enqueue process up till all the generated FDs were enqueued or until we reach the maximum number retries. This patch does not change the fact that only a single FD will result from a __dpaa2_eth_tx call but rather just creates the necessary changes for the next patch. Signed-off-by: Ioana Ciornei --- .../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 56 +++++++++++++------ .../net/ethernet/freescale/dpaa2/dpaa2-eth.h | 7 +++ 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 73e242fad000..d9871b9c1aad 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -878,6 +878,7 @@ static int dpaa2_eth_build_sg_fd(struct dpaa2_eth_priv *priv, err = -ENOMEM; goto dma_map_single_failed; } + memset(fd, 0, sizeof(struct dpaa2_fd)); dpaa2_fd_set_offset(fd, priv->tx_data_offset); dpaa2_fd_set_format(fd, dpaa2_fd_sg); dpaa2_fd_set_addr(fd, addr); @@ -946,6 +947,7 @@ static int dpaa2_eth_build_sg_fd_single_buf(struct dpaa2_eth_priv *priv, goto sgt_map_failed; } + memset(fd, 0, sizeof(struct dpaa2_fd)); dpaa2_fd_set_offset(fd, priv->tx_data_offset); dpaa2_fd_set_format(fd, dpaa2_fd_sg); dpaa2_fd_set_addr(fd, sgt_addr); @@ -998,6 +1000,7 @@ static int dpaa2_eth_build_single_fd(struct dpaa2_eth_priv *priv, if (unlikely(dma_mapping_error(dev, addr))) return -ENOMEM; + memset(fd, 0, sizeof(struct dpaa2_fd)); dpaa2_fd_set_addr(fd, addr); dpaa2_fd_set_offset(fd, (u16)(skb->data - buffer_start)); dpaa2_fd_set_len(fd, skb->len); @@ -1111,12 +1114,14 @@ static netdev_tx_t __dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) { struct dpaa2_eth_priv *priv = netdev_priv(net_dev); + int total_enqueued = 0, retries = 0, enqueued; struct dpaa2_eth_drv_stats *percpu_extras; struct rtnl_link_stats64 *percpu_stats; unsigned int needed_headroom; + int num_fds = 1, max_retries; struct dpaa2_eth_fq *fq; struct netdev_queue *nq; - struct dpaa2_fd fd; + struct dpaa2_fd *fd; u16 queue_mapping; u8 prio = 0; int err, i; @@ -1125,6 +1130,7 @@ static netdev_tx_t __dpaa2_eth_tx(struct sk_buff *skb, percpu_stats = this_cpu_ptr(priv->percpu_stats); percpu_extras = this_cpu_ptr(priv->percpu_extras); + fd = (this_cpu_ptr(priv->fd))->array; needed_headroom = dpaa2_eth_needed_headroom(skb); @@ -1139,20 +1145,22 @@ static netdev_tx_t __dpaa2_eth_tx(struct sk_buff *skb, } /* Setup the FD fields */ - memset(&fd, 0, sizeof(fd)); if (skb_is_nonlinear(skb)) { - err = dpaa2_eth_build_sg_fd(priv, skb, &fd, &swa); + err = dpaa2_eth_build_sg_fd(priv, skb, fd, &swa); percpu_extras->tx_sg_frames++; percpu_extras->tx_sg_bytes += skb->len; + fd_len = dpaa2_fd_get_len(fd); } else if (skb_headroom(skb) < needed_headroom) { - err = dpaa2_eth_build_sg_fd_single_buf(priv, skb, &fd, &swa); + err = dpaa2_eth_build_sg_fd_single_buf(priv, skb, fd, &swa); percpu_extras->tx_sg_frames++; percpu_extras->tx_sg_bytes += skb->len; percpu_extras->tx_converted_sg_frames++; percpu_extras->tx_converted_sg_bytes += skb->len; + fd_len = dpaa2_fd_get_len(fd); } else { - err = dpaa2_eth_build_single_fd(priv, skb, &fd, &swa); + err = dpaa2_eth_build_single_fd(priv, skb, fd, &swa); + fd_len = dpaa2_fd_get_len(fd); } if (unlikely(err)) { @@ -1161,10 +1169,11 @@ static netdev_tx_t __dpaa2_eth_tx(struct sk_buff *skb, } if (skb->cb[0]) - dpaa2_eth_enable_tx_tstamp(priv, &fd, swa, skb); + dpaa2_eth_enable_tx_tstamp(priv, fd, swa, skb); /* Tracing point */ - trace_dpaa2_tx_fd(net_dev, &fd); + for (i = 0; i < num_fds; i++) + trace_dpaa2_tx_fd(net_dev, &fd[i]); /* TxConf FQ selection relies on queue id from the stack. * In case of a forwarded frame from another DPNI interface, we choose @@ -1184,27 +1193,32 @@ static netdev_tx_t __dpaa2_eth_tx(struct sk_buff *skb, queue_mapping %= dpaa2_eth_queue_count(priv); } fq = &priv->fq[queue_mapping]; - - fd_len = dpaa2_fd_get_len(&fd); nq = netdev_get_tx_queue(net_dev, queue_mapping); netdev_tx_sent_queue(nq, fd_len); /* Everything that happens after this enqueues might race with * the Tx confirmation callback for this frame */ - for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) { - err = priv->enqueue(priv, fq, &fd, prio, 1, NULL); - if (err != -EBUSY) - break; + max_retries = num_fds * DPAA2_ETH_ENQUEUE_RETRIES; + while (total_enqueued < num_fds && retries < max_retries) { + err = priv->enqueue(priv, fq, &fd[total_enqueued], + prio, num_fds - total_enqueued, &enqueued); + if (err == -EBUSY) { + retries++; + continue; + } + + total_enqueued += enqueued; } - percpu_extras->tx_portal_busy += i; + percpu_extras->tx_portal_busy += retries; + if (unlikely(err < 0)) { percpu_stats->tx_errors++; /* Clean up everything, including freeing the skb */ - dpaa2_eth_free_tx_fd(priv, fq, &fd, false); + dpaa2_eth_free_tx_fd(priv, fq, fd, false); netdev_tx_completed_queue(nq, 1, fd_len); } else { - percpu_stats->tx_packets++; + percpu_stats->tx_packets += total_enqueued; percpu_stats->tx_bytes += fd_len; } @@ -4406,6 +4420,13 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev) goto err_alloc_sgt_cache; } + priv->fd = alloc_percpu(*priv->fd); + if (!priv->fd) { + dev_err(dev, "alloc_percpu(fds) failed\n"); + err = -ENOMEM; + goto err_alloc_fds; + } + err = dpaa2_eth_netdev_init(net_dev); if (err) goto err_netdev_init; @@ -4493,6 +4514,8 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev) err_alloc_rings: err_csum: err_netdev_init: + free_percpu(priv->fd); +err_alloc_fds: free_percpu(priv->sgt_cache); err_alloc_sgt_cache: free_percpu(priv->percpu_extras); @@ -4548,6 +4571,7 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev) fsl_mc_free_irqs(ls_dev); dpaa2_eth_free_rings(priv); + free_percpu(priv->fd); free_percpu(priv->sgt_cache); free_percpu(priv->percpu_stats); free_percpu(priv->percpu_extras); diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h index 7f9c6f4dea53..64e4aaebdcb2 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h @@ -497,6 +497,11 @@ struct dpaa2_eth_trap_data { #define DPAA2_ETH_DEFAULT_COPYBREAK 512 +#define DPAA2_ETH_ENQUEUE_MAX_FDS 200 +struct dpaa2_eth_fds { + struct dpaa2_fd array[DPAA2_ETH_ENQUEUE_MAX_FDS]; +}; + /* Driver private data */ struct dpaa2_eth_priv { struct net_device *net_dev; @@ -579,6 +584,8 @@ struct dpaa2_eth_priv { struct devlink_port devlink_port; u32 rx_copybreak; + + struct dpaa2_eth_fds __percpu *fd; }; struct dpaa2_eth_devlink_priv { From patchwork Wed Feb 9 09:23:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12739907 X-Patchwork-Delegate: kuba@kernel.org 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 4F236C433EF for ; Wed, 9 Feb 2022 09:25:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232231AbiBIJZR (ORCPT ); Wed, 9 Feb 2022 04:25:17 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:44732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbiBIJZM (ORCPT ); Wed, 9 Feb 2022 04:25:12 -0500 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0618.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::618]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44EC2E0AFABD for ; Wed, 9 Feb 2022 01:25:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MkHKD3qG7CUmYqwndU5PIx0clvbp0HnKK18Q+reM1we8zr4VVDgrvQ3Qr0tlqHecx9PJlRdaUEyB6O8qZV8/IFl4RdiRpCJq1OFPxdzUBXNwYyEOsWu9DPDbjsHG9IDTrKfeQy7ETUq6UTft3iLJ/UH8JQQqeXcO2ESa7jJxJ80f2oca85EoyXqRIdoWyXUTWlNO0gi5nssNhVEPKmwt0ssxBNQn+zHYs56LqiLCXj9zVZftrb03z7Hz091tkAcrt4pqMInMtV2fEEDTOXBupfqwAA8LwCj5dICmzO9FzsbfimAIt1MO4iAbjmUf/8ev67HWffQ7Pa7yUydO4xLvrg== 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=/0aFghDfIYwFaUYpFKoORvxIYff2JFHE3Z80R9Pz3pw=; b=EVq3/ig218hpV/NNNEASnUxgpmXASGhrHQDTvNsm3XfF/mwPzjwCbucxiYHsuxAwtMbb2bQIr/kuKQPbXe6ccJ0awl4qWDdfk4Wk71+PlXVudMuOVJHfBJ0FkFrYcgeNiaIH1Ou2IXPcugn2PCCJohbkIK88JVylNfwoIa1ihmWzaA/E+s4smcKMtef7JscDXJL1A2EkJ8/bv6RyhfhC8X4WSfgIv40x+A94dqpEN3BJxGsrwnqGMAzHZEWYqDjL/AEBunpv3FY+ye93o3aHLGnQ0NBxPC3w+Mp5Bbs5UobBKmZzI+E47eKlTxTYK85k5fhUm6Ktof06JcIPuEueQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=/0aFghDfIYwFaUYpFKoORvxIYff2JFHE3Z80R9Pz3pw=; b=kEXTmH4RpSu6N8atTrlZuZPKUbGuqIPRAC5qdFGDGsOq5y7tNIU/Q10TUFXAVisCIAkWXETRrRoPAJh+V6+MVIeORMUXexllfZkl8p2n/tukFtgtgHvJRU6z0wGHHoa+RsrB9fNhhgpPjv5A+4MJUN44fBRWDCQa3plWEmqsAlY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) by AM0PR04MB5972.eurprd04.prod.outlook.com (2603:10a6:208:120::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 09:24:05 +0000 Received: from AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::5df9:5bf0:7ac1:a793]) by AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::5df9:5bf0:7ac1:a793%9]) with mapi id 15.20.4975.011; Wed, 9 Feb 2022 09:24:04 +0000 From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: youri.querry_1@nxp.com, leoyang.li@nxp.com, Ioana Ciornei Subject: [PATCH net-next 6/7] dpaa2-eth: add support for software TSO Date: Wed, 9 Feb 2022 11:23:34 +0200 Message-Id: <20220209092335.3064731-7-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220209092335.3064731-1-ioana.ciornei@nxp.com> References: <20220209092335.3064731-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: AM0PR03CA0037.eurprd03.prod.outlook.com (2603:10a6:208::14) To AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fced7a4f-db6e-4a02-fec6-08d9ebadeaa1 X-MS-TrafficTypeDiagnostic: AM0PR04MB5972:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:983; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bq/NhxZ6QsPdnSbSU+g2mZRzGhuddNC0qd/YERXImWfm3zJ3Y1eB/4rH5srvmCg6AfK2E+/JkPPgrBaJwu1eFOj7bGZi8WlgZ2iTrkhxEBI8hluiRPOLLMSibyVG/o5UEmpLy8f0wEoGNAZY6Y3ot6/3A8ZS2J651ZOlNPxFmoJp9stYOp0ZGaYT1tuO6A4CpzjXzzL+VJmu5XM3F8BSirRWF4NR9/eK3QyOKvsZ2QoKp9gb+M8UUwLuLtDRn1RWfQsQ6P854uE8GsMM6CvlJOGTFyl11R9neWx5Eej0ToRWsIEHM+xoIy+S0bNeOKaT7ON4RfNq52t1vzOfCkkypbQbYRtec/u93loHgGTRi6p2uKCQjxMbcywmOHOdn5FxwMremHOCBx9I1+HqvsasvyXyaU/VSKhZVT/90jHH8aqTa31KQfBqDP/215FbmpXZ1+NJdfv94kPUYmkGJ+VD9b86JSN/EzG6ckhYqJrPlqRnC3a41iX1+PcB42psC9FsyDBgCyp1psV2qtHciDW/Y2TafuWdOWap3lOAhn5Za44M3FnOIfM6CHmm/nBZ6ChX4k5t2/HFLF93aflYPAVokOdMpN87IjY+imkQ8QOX2kTpPHyRUNnGCkXBOhJbFkTihmU72A9h2DUW/KNZcgntGVlvYLMuZIM0Bo7obwNoAMcDuJkGd2LX/WS6twNixhJwP99GYPXk/ZiG96XZ0CHywA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(8936002)(38100700002)(2906002)(2616005)(5660300002)(38350700002)(44832011)(83380400001)(52116002)(6506007)(6512007)(36756003)(30864003)(186003)(6666004)(1076003)(316002)(86362001)(66946007)(66556008)(508600001)(4326008)(66476007)(8676002)(26005)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Y19Mt7LNRTA/P68ovVI7eVgdPYe/hEkA7SQwzbstJkOytdLkJXqIQylwwx9QRhKY/p0lBZDrA8oHJC6/KTpjgMmXPWbZ3sEVGxZlJUkqXZVdDGgRJUSxRM+USk/eRusrtYvo18QGp4uFDwr6iBxh3bSyl8uZZuz/aBw9CF5m3Xveqf2OiUTuWk616ii+Jl093Wo1IjvmHWlofSvNwlgxqxHb7shM5ojVsY0pLE09JK9q+uv0nNTIP0Wrfec6Q6L0i3nbR0b9B+7ZxpsH9bXDfo6rd/la2pRreOqFTWUrjvMoJBQyM6rcgfXduHlcmtUjjj0Lxqnohyyvoyfe1wy2PwAD2EdKwg/1i2pQMSx2eNBzAoHTtL2AQOfo0hxiZOrXB7/1WA7wDGx3+1stfuWCLBGkD3a0puUYUm4G129oVu1XDrcf9JG9aCkH/cwURRUIQ8Zr0mSFWjCIB/dUhIbkesgUN+1xyrl5oh97dwNQHiWiL9Ti/wk8yX3ute3RiOGFPOdhKCdqg2ULwe0xbK/EXGwguMYtFOesI3iS7ps2Gz5Nb/E9so82YnxuzGw8PCVzYsHIvcKoL4U6mMLHv7GNsgCj2AAfNvvuU22zRM2Q5/1/INSnTDPJ5fFeWK/aNJSnfVW4IFvd8x245C/FhyiQ1NBH9VBkykZhFALyxh5E4I8Z8bLtqyDxC1hcRfz7LQQewhYu6Sv7y3x0Ns+fr68xyr72JqpOCUDXH5/womiZfw8XjFbi8iRkkvxUcdElrkCcFA3u9b4M08YbWyohxV7p0JiXgojH7wtE9/b6RGHUykB3wnDMC8PWUfBpDKSbDjcOixD2899OtxbtqVnvm2wz3Q7eeJLQordk+NnTZMz+Kcfgp0WLah235fJpVdlWdK97bZiHyN0CjwPG/Ycg+XiVoIa1A41EgQ5Nr52580lWPzfiaUULV8oyW4nvKn1AqazBBXqkhkDxqTlKz5izJabozxCD4I2XUYF9k4fHrm5gsL5mFo/ITaWMgByyicgRcVKHQk5GOuVz7y85bTtlVks/Fqq1b7mbqJRf9QHZqo+vAXo4yKxEjytrvc/A1h//Fh6FopxAuDt/cuU5MdNSa/9mzVYlxdWGDh1t1Pn8cfFLxjanMyOGvUISBxdNqmx9vBzUQs3nx9yZBd/esSLUNise4Qss6jDJy+IteYyrWlv0lPk4raav4AuKP4mEWV+lvV41THhpLD36L2yIxBiZZUzpHHvfnaRZ6nik4LXeIpuNUUEBG6GM47EnucQbcGOgd8MqArhxpoD2lMxEPmys6bXxflkE2LQcuCGNMnTQzLVHXC2eiRjxWXJqiq8ny8Sudh9NNaLwaSqkNVrzQNdNPeGj7PE/rsMk6QgQvsU2j5X4vGPYdN2iWQU/bPiIMdy/JO6UwoolgTHjgiOYv7e8NpEvWDI8geOsxs++Ec/fx8qTmlQ2f4QeOhRJEyseNoKVZAGa1+NNoae1zyBHnJeDFipYf9bfi5wKskGryRb95ig7YeliWQ0UbGajgxTp+pKiUKP76KRMG75BWT6XaxKPwJubPR4h3yMgMuqJSmlJlzdg0VJbwjGWVlVWps2FQ1QoPW5Eqh22nMTI1bNm73aLqJzIaRWoTP0DvDXpNssOslfYeJs= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fced7a4f-db6e-4a02-fec6-08d9ebadeaa1 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 09:24:04.9084 (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: +kDOAPg9fbhSGMHScntcyhTvmlnL9dDWpnwTWMmAtwvEFH0Gym7NQHQFYilpXjkRuD5vgYNPBcJQmcxrD1zyIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5972 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch adds support for driver level TSO in the enetc driver using the TSO API. There is not much to say about this specific implementation. We are using the usual tso_build_hdr(), tso_build_data() to create each data segment, we create an array of S/G FDs where the first S/G entry is referencing the header data and the remaining ones the data portion. For the S/G Table buffer we use the same cache of buffers used on the other non-GSO cases - dpaa2_eth_sgt_get() and dpaa2_eth_sgt_recycle(). We cannot keep a DMA coherent buffer for all the TSO headers because the DPAA2 architecture does not work in a ring based fashion so we just allocate a buffer each time. Even with these limitations we get the following improvement in TCP termination on the LX2160A SoC, on a single A72 core running at 2.2GHz. before: 6.38Gbit/s after: 8.48Gbit/s Signed-off-by: Ioana Ciornei --- .../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 214 ++++++++++++++++-- .../net/ethernet/freescale/dpaa2/dpaa2-eth.h | 9 + .../ethernet/freescale/dpaa2/dpaa2-ethtool.c | 2 + 3 files changed, 207 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index d9871b9c1aad..88534aa29af2 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "dpaa2-eth.h" @@ -1029,6 +1030,8 @@ static void dpaa2_eth_free_tx_fd(struct dpaa2_eth_priv *priv, u8 fd_format = dpaa2_fd_get_format(fd); u32 fd_len = dpaa2_fd_get_len(fd); struct dpaa2_sg_entry *sgt; + int should_free_skb = 1; + int i; fd_addr = dpaa2_fd_get_addr(fd); buffer_start = dpaa2_iova_to_virt(priv->iommu_domain, fd_addr); @@ -1060,6 +1063,28 @@ static void dpaa2_eth_free_tx_fd(struct dpaa2_eth_priv *priv, /* Unmap the SGT buffer */ dma_unmap_single(dev, fd_addr, swa->sg.sgt_size, DMA_BIDIRECTIONAL); + } else if (swa->type == DPAA2_ETH_SWA_SW_TSO) { + skb = swa->tso.skb; + + sgt = (struct dpaa2_sg_entry *)(buffer_start + + priv->tx_data_offset); + + /* Unmap and free the header */ + dma_unmap_single(dev, dpaa2_sg_get_addr(sgt), TSO_HEADER_SIZE, + DMA_TO_DEVICE); + kfree(dpaa2_iova_to_virt(priv->iommu_domain, dpaa2_sg_get_addr(sgt))); + + /* Unmap the other SG entries for the data */ + for (i = 1; i < swa->tso.num_sg; i++) + dma_unmap_single(dev, dpaa2_sg_get_addr(&sgt[i]), + dpaa2_sg_get_len(&sgt[i]), DMA_TO_DEVICE); + + /* Unmap the SGT buffer */ + dma_unmap_single(dev, fd_addr, swa->sg.sgt_size, + DMA_BIDIRECTIONAL); + + if (!swa->tso.is_last_fd) + should_free_skb = 0; } else { skb = swa->single.skb; @@ -1088,26 +1113,172 @@ static void dpaa2_eth_free_tx_fd(struct dpaa2_eth_priv *priv, } /* Get the timestamp value */ - if (skb->cb[0] == TX_TSTAMP) { - struct skb_shared_hwtstamps shhwtstamps; - __le64 *ts = dpaa2_get_ts(buffer_start, true); - u64 ns; - - memset(&shhwtstamps, 0, sizeof(shhwtstamps)); - - ns = DPAA2_PTP_CLK_PERIOD_NS * le64_to_cpup(ts); - shhwtstamps.hwtstamp = ns_to_ktime(ns); - skb_tstamp_tx(skb, &shhwtstamps); - } else if (skb->cb[0] == TX_TSTAMP_ONESTEP_SYNC) { - mutex_unlock(&priv->onestep_tstamp_lock); + if (swa->type != DPAA2_ETH_SWA_SW_TSO) { + if (skb->cb[0] == TX_TSTAMP) { + struct skb_shared_hwtstamps shhwtstamps; + __le64 *ts = dpaa2_get_ts(buffer_start, true); + u64 ns; + + memset(&shhwtstamps, 0, sizeof(shhwtstamps)); + + ns = DPAA2_PTP_CLK_PERIOD_NS * le64_to_cpup(ts); + shhwtstamps.hwtstamp = ns_to_ktime(ns); + skb_tstamp_tx(skb, &shhwtstamps); + } else if (skb->cb[0] == TX_TSTAMP_ONESTEP_SYNC) { + mutex_unlock(&priv->onestep_tstamp_lock); + } } /* Free SGT buffer allocated on tx */ if (fd_format != dpaa2_fd_single) dpaa2_eth_sgt_recycle(priv, buffer_start); - /* Move on with skb release */ - napi_consume_skb(skb, in_napi); + /* Move on with skb release. If we are just confirming multiple FDs + * from the same TSO skb then only the last one will need to free the + * skb. + */ + if (should_free_skb) + napi_consume_skb(skb, in_napi); +} + +static int dpaa2_eth_build_gso_fd(struct dpaa2_eth_priv *priv, + struct sk_buff *skb, struct dpaa2_fd *fd, + int *num_fds, u32 *total_fds_len) +{ + struct device *dev = priv->net_dev->dev.parent; + int hdr_len, total_len, data_left, fd_len; + int num_sge, err, i, sgt_buf_size; + struct dpaa2_fd *fd_start = fd; + struct dpaa2_sg_entry *sgt; + struct dpaa2_eth_swa *swa; + dma_addr_t sgt_addr, addr; + dma_addr_t tso_hdr_dma; + unsigned int index = 0; + struct tso_t tso; + char *tso_hdr; + void *sgt_buf; + + /* Initialize the TSO handler, and prepare the first payload */ + hdr_len = tso_start(skb, &tso); + *total_fds_len = 0; + + total_len = skb->len - hdr_len; + while (total_len > 0) { + /* Prepare the HW SGT structure for this frame */ + sgt_buf = dpaa2_eth_sgt_get(priv); + if (unlikely(!sgt_buf)) { + netdev_err(priv->net_dev, "dpaa2_eth_sgt_get() failed\n"); + err = -ENOMEM; + goto err_sgt_get; + } + sgt = (struct dpaa2_sg_entry *)(sgt_buf + priv->tx_data_offset); + + /* Determine the data length of this frame */ + data_left = min_t(int, skb_shinfo(skb)->gso_size, total_len); + total_len -= data_left; + fd_len = data_left + hdr_len; + + /* Prepare packet headers: MAC + IP + TCP */ + tso_hdr = kmalloc(TSO_HEADER_SIZE, GFP_ATOMIC); + if (!tso_hdr) { + err = -ENOMEM; + goto err_alloc_tso_hdr; + } + + tso_build_hdr(skb, tso_hdr, &tso, data_left, total_len == 0); + tso_hdr_dma = dma_map_single(dev, tso_hdr, TSO_HEADER_SIZE, DMA_TO_DEVICE); + if (dma_mapping_error(dev, tso_hdr_dma)) { + netdev_err(priv->net_dev, "dma_map_single(tso_hdr) failed\n"); + err = -ENOMEM; + goto err_map_tso_hdr; + } + + /* Setup the SG entry for the header */ + dpaa2_sg_set_addr(sgt, tso_hdr_dma); + dpaa2_sg_set_len(sgt, hdr_len); + dpaa2_sg_set_final(sgt, data_left > 0 ? false : true); + + /* Compose the SG entries for each fragment of data */ + num_sge = 1; + while (data_left > 0) { + int size; + + /* Move to the next SG entry */ + sgt++; + size = min_t(int, tso.size, data_left); + + addr = dma_map_single(dev, tso.data, size, DMA_TO_DEVICE); + if (dma_mapping_error(dev, addr)) { + netdev_err(priv->net_dev, "dma_map_single(tso.data) failed\n"); + err = -ENOMEM; + goto err_map_data; + } + dpaa2_sg_set_addr(sgt, addr); + dpaa2_sg_set_len(sgt, size); + dpaa2_sg_set_final(sgt, size == data_left ? true : false); + + num_sge++; + + /* Build the data for the __next__ fragment */ + data_left -= size; + tso_build_data(skb, &tso, size); + } + + /* Store the skb backpointer in the SGT buffer */ + sgt_buf_size = priv->tx_data_offset + num_sge * sizeof(struct dpaa2_sg_entry); + swa = (struct dpaa2_eth_swa *)sgt_buf; + swa->type = DPAA2_ETH_SWA_SW_TSO; + swa->tso.skb = skb; + swa->tso.num_sg = num_sge; + swa->tso.sgt_size = sgt_buf_size; + swa->tso.is_last_fd = total_len == 0 ? 1 : 0; + + /* Separately map the SGT buffer */ + sgt_addr = dma_map_single(dev, sgt_buf, sgt_buf_size, DMA_BIDIRECTIONAL); + if (unlikely(dma_mapping_error(dev, sgt_addr))) { + netdev_err(priv->net_dev, "dma_map_single(sgt_buf) failed\n"); + err = -ENOMEM; + goto err_map_sgt; + } + + /* Setup the frame descriptor */ + memset(fd, 0, sizeof(struct dpaa2_fd)); + dpaa2_fd_set_offset(fd, priv->tx_data_offset); + dpaa2_fd_set_format(fd, dpaa2_fd_sg); + dpaa2_fd_set_addr(fd, sgt_addr); + dpaa2_fd_set_len(fd, fd_len); + dpaa2_fd_set_ctrl(fd, FD_CTRL_PTA); + + *total_fds_len += fd_len; + /* Advance to the next frame descriptor */ + fd++; + index++; + } + + *num_fds = index; + + return 0; + +err_map_sgt: +err_map_data: + /* Unmap all the data S/G entries for the current FD */ + sgt = (struct dpaa2_sg_entry *)(sgt_buf + priv->tx_data_offset); + for (i = 1; i < num_sge; i++) + dma_unmap_single(dev, dpaa2_sg_get_addr(&sgt[i]), + dpaa2_sg_get_len(&sgt[i]), DMA_TO_DEVICE); + + /* Unmap the header entry */ + dma_unmap_single(dev, tso_hdr_dma, TSO_HEADER_SIZE, DMA_TO_DEVICE); +err_map_tso_hdr: + kfree(tso_hdr); +err_alloc_tso_hdr: + dpaa2_eth_sgt_recycle(priv, sgt_buf); +err_sgt_get: + /* Free all the other FDs that were already fully created */ + for (i = 0; i < index; i++) + dpaa2_eth_free_tx_fd(priv, NULL, &fd_start[i], false); + + return err; } static netdev_tx_t __dpaa2_eth_tx(struct sk_buff *skb, @@ -1123,10 +1294,10 @@ static netdev_tx_t __dpaa2_eth_tx(struct sk_buff *skb, struct netdev_queue *nq; struct dpaa2_fd *fd; u16 queue_mapping; + void *swa = NULL; u8 prio = 0; int err, i; u32 fd_len; - void *swa; percpu_stats = this_cpu_ptr(priv->percpu_stats); percpu_extras = this_cpu_ptr(priv->percpu_extras); @@ -1146,7 +1317,13 @@ static netdev_tx_t __dpaa2_eth_tx(struct sk_buff *skb, /* Setup the FD fields */ - if (skb_is_nonlinear(skb)) { + if (skb_is_gso(skb)) { + err = dpaa2_eth_build_gso_fd(priv, skb, fd, &num_fds, &fd_len); + percpu_extras->tx_sg_frames += num_fds; + percpu_extras->tx_sg_bytes += fd_len; + percpu_extras->tx_tso_frames += num_fds; + percpu_extras->tx_tso_bytes += fd_len; + } else if (skb_is_nonlinear(skb)) { err = dpaa2_eth_build_sg_fd(priv, skb, fd, &swa); percpu_extras->tx_sg_frames++; percpu_extras->tx_sg_bytes += skb->len; @@ -1168,7 +1345,7 @@ static netdev_tx_t __dpaa2_eth_tx(struct sk_buff *skb, goto err_build_fd; } - if (skb->cb[0]) + if (swa && skb->cb[0]) dpaa2_eth_enable_tx_tstamp(priv, fd, swa, skb); /* Tracing point */ @@ -4138,7 +4315,8 @@ static int dpaa2_eth_netdev_init(struct net_device *net_dev) net_dev->features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG | NETIF_F_HIGHDMA | - NETIF_F_LLTX | NETIF_F_HW_TC; + NETIF_F_LLTX | NETIF_F_HW_TC | NETIF_F_TSO; + net_dev->gso_max_segs = DPAA2_ETH_ENQUEUE_MAX_FDS; net_dev->hw_features = net_dev->features; if (priv->dpni_attrs.vlan_filter_entries) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h index 64e4aaebdcb2..b79831cd1a94 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h @@ -122,6 +122,7 @@ enum dpaa2_eth_swa_type { DPAA2_ETH_SWA_SINGLE, DPAA2_ETH_SWA_SG, DPAA2_ETH_SWA_XDP, + DPAA2_ETH_SWA_SW_TSO, }; /* Must keep this struct smaller than DPAA2_ETH_SWA_SIZE */ @@ -142,6 +143,12 @@ struct dpaa2_eth_swa { int dma_size; struct xdp_frame *xdpf; } xdp; + struct { + struct sk_buff *skb; + int num_sg; + int sgt_size; + int is_last_fd; + } tso; }; }; @@ -354,6 +361,8 @@ struct dpaa2_eth_drv_stats { __u64 tx_conf_bytes; __u64 tx_sg_frames; __u64 tx_sg_bytes; + __u64 tx_tso_frames; + __u64 tx_tso_bytes; __u64 rx_sg_frames; __u64 rx_sg_bytes; /* Linear skbs sent as a S/G FD due to insufficient headroom */ diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c index 3fdbf87dccb1..eea7d7a07c00 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c @@ -44,6 +44,8 @@ static char dpaa2_ethtool_extras[][ETH_GSTRING_LEN] = { "[drv] tx conf bytes", "[drv] tx sg frames", "[drv] tx sg bytes", + "[drv] tx tso frames", + "[drv] tx tso bytes", "[drv] rx sg frames", "[drv] rx sg bytes", "[drv] tx converted sg frames", From patchwork Wed Feb 9 09:23:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12739911 X-Patchwork-Delegate: kuba@kernel.org 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 AEB2BC433EF for ; Wed, 9 Feb 2022 09:26:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234661AbiBIJ0V (ORCPT ); Wed, 9 Feb 2022 04:26:21 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:48672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbiBIJ0T (ORCPT ); Wed, 9 Feb 2022 04:26:19 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on061c.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::61c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5E47E01D5E1 for ; Wed, 9 Feb 2022 01:26:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R8rBmSoauhr/PasxH15iGOHtl4p5TrTjQlvxODgVz4ppr1C465srhvQoUpxip/o8gpg2kMYs3o+2sZhgnKyb6j1NeSwaA8P7eHMGiWsDJbuYcZPj9SjxsLyQvp93ZEkoML3pBWTwgHZuzLhSGZoj9SsYFb9n9yXtAnXnar33hHZZJpe+VUNHhPw+ZCgfmnku3cXrboG/n0qp3AbGFft9alHvZU6QJtKgOiRJmvyerHJKvP1UvJao2WzeNJl9snNxmafnxGdPvH1PmV4PNYhP8vM0j7kO5eohm8LOWLA/DOxVF2nwGYjiARZifNL6kufSTL9Q74gfssLh0TDjXLmRmw== 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=HBRvrC5HV19StHSkA7eYj1O1NylUgmjqtq3L9xgUOfo=; b=egyTcxKSF424qOuBaxxEzLx0G9049OoM65BkEwl+2mt0vdFBLvw2SLnk8PSm+gEiFTsbk57jpJ1ePQAyH2PUVljb6pMMDKpDnqPSha0q7CP3q/kadW782wkVaV+Faivs8Y8tI5/yLZRtGTmeKGV9rsPl2fQIDq3/S28PSFikDf9YBtIVesvS5VEPaIf7BdJ6Ej0rOFkbCEHOKFhVdkvTSqRT+WoCa59YrswhDDKPaMP7zab6I+xQfc/1gSzcUFKECaHoq/RMVRoXJCPPHN+cRwibseyzxBJecvUJDSSl8D1cYtPpmvI+mRRv7f6XtL1XIG/TH6xZfXrcnwsAG2+7Eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=HBRvrC5HV19StHSkA7eYj1O1NylUgmjqtq3L9xgUOfo=; b=OvTpG4+kYdaa4BvekXVShpyOmq8QseMfWWipXN+uoLimfEM9bU/633ss1wm+Rw6t8Gg5Cmu/MGKJcryM1eNhd/Xmqvdzu+p0Bw/1ijQ4cqM/FBO2gjDb/oaVT+GZBI8l8wvYLAMKGxegCjmjucypKXnwIqdMdbAYp1LemlbfgV8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) by AM0PR04MB5972.eurprd04.prod.outlook.com (2603:10a6:208:120::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 09:24:05 +0000 Received: from AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::5df9:5bf0:7ac1:a793]) by AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::5df9:5bf0:7ac1:a793%9]) with mapi id 15.20.4975.011; Wed, 9 Feb 2022 09:24:05 +0000 From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: youri.querry_1@nxp.com, leoyang.li@nxp.com, Ioana Ciornei Subject: [PATCH net-next 7/7] soc: fsl: dpio: read the consumer index from the cache inhibited area Date: Wed, 9 Feb 2022 11:23:35 +0200 Message-Id: <20220209092335.3064731-8-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220209092335.3064731-1-ioana.ciornei@nxp.com> References: <20220209092335.3064731-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: AM0PR03CA0037.eurprd03.prod.outlook.com (2603:10a6:208::14) To AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 567d8c67-8642-4611-6742-08d9ebadeb33 X-MS-TrafficTypeDiagnostic: AM0PR04MB5972:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tJf/uioi/kcYMDUwslTJEotxDoIBeaq1tqjmWY2/mt5eQeaJDNKwDuJhCwfxN/vGNhE7uiGSCfuK8LC5OOlQdnoIR2t1bx/uQwYbbkx0DfY8pJOegSjUY4gVegfP7J+kLU1+GRDNpuZGSlLmF4YAKUwfBU6ej1zBZGbcb38YnVotMIXSEL5ZDZJqIUT/FDgNR+OFaR5sGziFW/JQInrp5oGvVbfmD7PycEXzcyYplJKCgznusuxSP0XwWIxVa3zQdgKlqGlrovekNyRNkz8xhkp/3Zp+zqAIjZn90FDK3FbupQUmldkKt7546rw+qTzfhXmNJ+knaPn26e9LIa0OouQfZBBvXjkLoGwxCfnMqEVgXLFrf/7xRYgZVBnQM+zXKT9Xpk+oUSwKl1wCH+eUYkT9gnDxgVTh1kAGow+wYs2t59poA+zJ2KswnPvqrf4QDNSW3l9ZfUomalaaGRZCINLJGDSxX5LRVfN7vTX80k1tOlpOuxFDcgSypy8wmOcrCg81fcvGs2Ei8rhExhuc2KgOCw14UMuc2WXcL5/HAhmNpTTmWgGDnL6uCX50FaqPb6ac4OdobYBm5Anl6L8ODjkwtqx8b5hMC7B0AFRqvbL9qs98t5WlKpRQJvPvnVY+ES1jRjJx4yO7S19PDndSwzErXMyPwTtiZRN1DrsYvqvkK1WDawQNgIusHh+ZcWZRC+xKbQCFVjnybyu4q4y2Xw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(8936002)(38100700002)(2906002)(2616005)(5660300002)(38350700002)(44832011)(83380400001)(52116002)(6506007)(6512007)(36756003)(186003)(6666004)(1076003)(316002)(86362001)(66946007)(66556008)(508600001)(4326008)(66476007)(8676002)(26005)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HBMaCA4cDWvc1PIx76sukwVieoQpIZc24V13NKnQ48ECr3u6xAChKmJKtfjbNSqBNaAYnNjX1NXxvDkJIMBEVOpq67X3NHU5DHJ8/Cr5Zi2KzRKzLm4au2pt5hNMoyo8rxhi2DvXqYB8WQcXtbrJrr1dJsGdI6NeLzwVtgmtp60uoVcgHlYt/My7AW2tt+vk2FjclAnCBUM+Le37E4jJLN6ZjbVGpcqVrkgQxNHa/ifVmQ3L5uCTkgvXTHymCBEPwYePebLtCqMUvaNse0NUH+rmsVIdAWMn8/OYnLMMsTKb9T7T+ipbkoe9dzSAPmVqIPSyqqNRvSLI3eX3F+gfVs8x0VvWsigS5VaJBLE/gt57CVqPEmb1FgPMZ0LC7+e/4nH75GeompROO8C9WaIn1p0+QgiDA7XwTRzGe7oD1r6/B0E6if9cJD1niHuLRjukkTAet1/KgStoftsCELodOIeBC0iSyQxtZ2q+W8lnry8ecz9an2iTnie2O6klmPF04VVofZwIofZw5xyRpLiVZEGdmgL47n3LYDhnYBEv0b2ptSMDHQdz8xL66YdDQj3NbRAQRkUmnYVc9NNXD8RxINtLJmRNxLw9LzyTsUQxuXJjpHFicXGAbM1W66tPjoystaUwrXLM5ESfMQ5TBxAWJp3OlCiSiNBGapQYHcvbTV2InF7PtwIIrNXCBFPTPgbMx7nzYW6dE76+qhFd3Z2BnnhTmXUPKinr/RPKT4dSyjwWXgMLAVxW0lI+fds2fmvm1aLuwit0sIrKm0l1cJTSGsbvAz/Sepzq5HL1xEIjgj/shT4iVEcPuvA7VmuKfH3MqK6qxJUhNcYMCSDzMRRCbh0ll+BNWNGN7x+rOEz1f6vCL4EoKaKK7P3NZqp7VkyzMyxURgDv8UKtg0gBMXaV9fq9TBdtzbPR4X7Y9Dw8Z4QXlcF7Fue9w6UvY842VEXdt4PX1t0WS7ANMRcVeWnVL51I3SDC6mzcWkoyMIEk1nvMkHvjdn94NMC+ERhG+rphNiSr9JJH9wpM9prB2H0tWf2Py0Qf17hezt81sxcdOj5nHyJLIzOBey3Vrc3vWR2SrWrB2G2yQI+K8dgSqPr0vk+jvmJ0504WKOPoHBAw4WzxWdbJEXdjRxtKPXc26r7/XcArp+nCAS2ZiYr5izmVespqn5fQrYEwS1aHpcVFC86tFlLdEbA69zLfOTY+6L1EyGUx4NBpLEBtzPGdN3DNnVl1k0QOZRLmmlhHrLfU5xex2f/ACDuRC6TPFXemGJdZlAarBaS/AB/x+OwLBmYJrJFK/F2q2sThwDRNbS4FhxnlOQH1GIM27X16HTVzuF5xQYiYEX8FlU3nL+RK7qA30Epg0OsG+iIbT6jH0t+w1ej0pokqbU1Y4Tiv2fofWVFEmEAjWMMdbtQdxtLpEqqP8n3ONjoV0wfgzcdkaAz+UQOIXurzjoAk50AE0jV2lt5iyQHp4zpRAZvRFI/I3TxSq+Q/koX4z76QPCw2uwY7sUXMXHkD9v7wuxVnQ5sQ9yoaUtH6gHkfnvOrVoqymQtvQ+aOHj98gEKkAhiPXNxyVrl8UC1U5D02WG73vLDIbgjktsmmCnu/wwp8iebs6OMx+eCkGIkuq3/eClRzr+otwZY= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 567d8c67-8642-4611-6742-08d9ebadeb33 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 09:24:05.8769 (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: 8qDj0YtTo+92/q5G3/0Cx1rmSOm60ElJl7hyYIxfH0sWEWYQYJWiPDeqmFRovIuXAEw+4DunP5M0EPs9FMcZWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5972 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Once we added support in the dpaa2-eth for driver level software TSO we observed the following situation: if the EQCR CI (consumer index) is read from the cache-enabled area we sometimes end up with a computed value of available enqueue entries bigger than the size of the ring. This eventually will lead to the multiple enqueue of the same FD which will determine the same FD to end up on the Tx confirmation path and the same skb being freed twice. Just read the consumer index from the cache inhibited area so that we avoid this situation. Signed-off-by: Ioana Ciornei --- drivers/soc/fsl/dpio/qbman-portal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/soc/fsl/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c index 058b78fac5e3..0a3fb6c115f4 100644 --- a/drivers/soc/fsl/dpio/qbman-portal.c +++ b/drivers/soc/fsl/dpio/qbman-portal.c @@ -743,8 +743,8 @@ int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s, full_mask = s->eqcr.pi_ci_mask; if (!s->eqcr.available) { eqcr_ci = s->eqcr.ci; - p = s->addr_cena + QBMAN_CENA_SWP_EQCR_CI_MEMBACK; - s->eqcr.ci = *p & full_mask; + s->eqcr.ci = qbman_read_register(s, QBMAN_CINH_SWP_EQCR_CI); + s->eqcr.ci &= full_mask; s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size, eqcr_ci, s->eqcr.ci); if (!s->eqcr.available) { @@ -887,8 +887,8 @@ int qbman_swp_enqueue_multiple_desc_mem_back(struct qbman_swp *s, full_mask = s->eqcr.pi_ci_mask; if (!s->eqcr.available) { eqcr_ci = s->eqcr.ci; - p = s->addr_cena + QBMAN_CENA_SWP_EQCR_CI_MEMBACK; - s->eqcr.ci = *p & full_mask; + s->eqcr.ci = qbman_read_register(s, QBMAN_CINH_SWP_EQCR_CI); + s->eqcr.ci &= full_mask; s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size, eqcr_ci, s->eqcr.ci); if (!s->eqcr.available)