From patchwork Tue Nov 12 09:14:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13871971 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2049.outbound.protection.outlook.com [40.107.20.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9A9420E31F; Tue, 12 Nov 2024 09:30:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731403826; cv=fail; b=pJfjycEWGnLGQfSwJajwku9UjLXpo9LSXk1+pnBW8VjdNkdVLeSjO8QsRhQudKMgVZCGB1oO6YPnN/FgCJz2TADPSlVHxRfeVJq3sF8gWiJFZram5Jq6VUrhdR5TksFM1pJN6jNlhAAWbQeZeZ3ad6H3vzhUZNpzT88JckUGvj8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731403826; c=relaxed/simple; bh=XyucMni2+AgKc6fANwmKum4vQ9QsOp5KBJGK+wF+NQ4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ABXgLrXdITSNZ4S0SGas2tTzsuNyHS7mZmQyHKWkhSE1OB1er7xL3Xp+F0BwaqZ+2WN0BIiHYxL3r7R4yNvJIQBPyNb9fF8AfC4+1AYghVLcxZrt4ZucQczVgysKjMiRh8UUIRFE9arQdA2svmgzYlyw2yVK2i4lOFwLCOEl5tk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=WG5EW1Jf; arc=fail smtp.client-ip=40.107.20.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="WG5EW1Jf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wvE+Bioyy6RA6a5otcJG8pqALGHzqFqYDiYRnyP5+xP6/MjC8Hz5m0o2wwvoPC7WdI+4+AFtLpvZSzdNXv78KcVwKROv5z3pkSfU2hrTyRrQA9/TmthvI79CQzQF3PzQnQDYOqAWsagu0ZRhvC+g2hH5BYW/5gaXF5+qG4cqfYscLOvA4IVXor/X5mB/ZWkBnY+Kht/lF3OI02yOOnjREQ27byimJ/b1o7IxicmQ2XWc0WSUvmpvHekUjcFXqibWT+cjcYnW9Gwuc0tVm4km8zHm4XbRl/M2ryu0suPrh5MfJmECiBf4gbFcc3UXkGYa361kDM0k1kBTJdC5PL1mfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fy6EgeEjot1tcShDqpHwFSDynpXVxx3eJaHQo9TSYCU=; b=yatkihnRx6u3D17KHZiR/JNo2iyJIcaZqK8V05UKKGcK8QQ5UMy/9eJrk+Zi3pOgqdmKAGvKVmvqSywUhYdjWVF+Jal8uiDA0iMXcQT5prpnD03VCU1ELdAb3QzrMdSLVtXHfNzSJ2Rmm1NfnlTYCVHl24gEQblvv+SVVhzYAEOYQ7lABdkBoy1SjhON3OliV1JoqhBurdH6S8/RwEfu9Q7w0tELDXF4p9zLl+MftJvgAcCcsuefI/trUdsGc7RWN34+EgHi//pb699KUW9M8XjPBXgFm6qFDgY3VmB4cB3pbyybhPb4f0oJ5VPb+tlFAx/0HzYvVe7pxggeuLgSCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fy6EgeEjot1tcShDqpHwFSDynpXVxx3eJaHQo9TSYCU=; b=WG5EW1JfWRO2cr4mq8TI/hwvuHd8Bmx0ZZJsGxjmRlvY8bxaVp6Gp6i5MdOJD1oJ6hQ4yQfnlMlVpSVtf0h2pgmS8T/oON59VyP/hMjHeVVF5TWbGi6FqWfwq8wPM40FV/zXbOXXETylmPxgKOQ57dpJRjKiP6KwpSVhUbu+dhgWBg/tKKbco8V3ZXztq6ShJGAA7dm/40lH4OybGkow7nIx/10KKiSxNj4R1qwUXvNr335wprasHTAgVFZ2np2Wob9hdDLpjdh2XaHyC/1bUB9h9jDGZFogEbA7ggNex4+uY1m9KBKLlbUD+7LYaLiakJr09IQqnhYUdx5XvLV3Ww== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by AM8PR04MB7892.eurprd04.prod.outlook.com (2603:10a6:20b:235::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.29; Tue, 12 Nov 2024 09:30:21 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%7]) with mapi id 15.20.8137.027; Tue, 12 Nov 2024 09:30:21 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, frank.li@nxp.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v3 net-next 1/5] net: enetc: add Rx checksum offload for i.MX95 ENETC Date: Tue, 12 Nov 2024 17:14:43 +0800 Message-Id: <20241112091447.1850899-2-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112091447.1850899-1-wei.fang@nxp.com> References: <20241112091447.1850899-1-wei.fang@nxp.com> X-ClientProxiedBy: SI2PR01CA0041.apcprd01.prod.exchangelabs.com (2603:1096:4:193::15) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|AM8PR04MB7892:EE_ X-MS-Office365-Filtering-Correlation-Id: de5255a4-7b6f-40a1-f2dd-08dd02fca0a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|1800799024|366016|376014|38350700014; X-Microsoft-Antispam-Message-Info: IQKLNQD7AClN8OtuQuwOqiwibAw+juPjxU77a/1Io7ud2tMXktS0dQHzNQ1XslxtWfWk+msbnAJOA7KGWNs4LDzlFJqKbRzEY04i4ItigYNuRY0xqnjidD7PG+XixzIV5lUaxNieXZPcQj6rGbzyLK0XwyNio26K9TiA/x0l1f1kLJPmd7Ml9TgReN+JjHb5OaCcINhmYpQgdZCbsHEcB0zZdhWiycalXAyeooDMjMOPA1IqhlVF0UCSoyged8nJ8ddLvK9/4A8CZLhA8PU6LTaChUJByzKjjeb5qgnHxvolDrc3QFgSLct66SPdJIYqnrdqyTfEaxo5Xnha7MP49b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;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(1800799024)(366016)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Q3Wv44H3LYc/9TbwVirZw2siG1z1kqEuxELYAWnf3SIdnF+c60Iji5gxl71oKbfKrGxAvEKl5iDXV+3NqLARPrUy/AUdoDu9/Rt0D59sI/56Ydvd5Yz4v88Gn2scE/SvP40AFZv/n+gJ2Vyy7e74QBe+2+hRT60XDN0mFVEnmxPorf36k1HuZPQjsjTyL0KuEa3XCvAhNxhgJEfapWEupkpkYwaBFnJRA9lZoEQ0QuD8aGUBjuByFWxrN9gQevlKN2WvIjSzLPhmkAwtkUK559iNNE1g2Pkw2hiYVNjbY7Ade38qvS/oQ4FgXhny9m5rHIu8Dp2w4JA0o/ei2jkket5tWQ+EfuT2MBP9PRaSHX909+x1C0lQ4U+WP6KfkPqkW1a0QSdL/AZA2p/AtfyjK84/9KJOxX1CBRIjUuyn5YaOEJRkmKueCQWyQzbxmvNdKiEYheNXFU/6WIL9F09HvR4vu1r48SLiofSzE8Tl6BTkJ0ppQ01AdR3sd2RrSNRsWm2pBGxCgBVuUheeIwALoI2XJ0MxlyBZaeFlZGvnMWOc7TdFjquyWmMXPtxH5kty/DtY5gj/5o5q/u/4xpm/QpJAHc1uDEhD5xoPXJjUYi0xuNfh3hMfSaVlbVdSmL3Xe8hoJS8qAYog46i15z2w9xFF6DI2X43JlRD7QlUgHePBFGu5tNvOOPNbOqOxTTpQehJraseAcJiuc5kNxwxnmHI28LC4HwBifv4N7Whr4RC4HObklLy6euDIW1Kj+AyZE8uBPdMnNHNlbAFCnKuWAIG9OtTuT8As9byGsFL1z0pgoCiYYcUbl0rd534uOfQ761GeQkjYF4ru/wie0JlKQZOhXYXOTzhmYA8rRwGmVgXuA5SXjwwfQFWYUCEc2RYwf6pc0DX7Ob5Jae7BXZsyU87uPEsu1Rforn7eh9Zsfu63+qCAU+E2iyp9+DMBpEGeVs4GnoBXSCObm1ZfIp487E3HtXLc58qK1RHACUeEf7H3Jc9GXWaOlBl8BJuc5pjI1DUpxb5xuoBvBon4g6YjJ2O+a1Vseo1NndgqbAZ7jLGXs5vVXtLhZ95JG3TvHM6b61Xk0r10ISRHl9lbot2CQtMFBtj/CpSOCWmpo8oWqgLGLc2Vvoa/oMLbzkHIOf+Iv+tGilIjSTfPSRTAhZdAbZy3w0a0JCgE9SOoxlpbAGaYapGZfZbfolxC456jnUbYG7orPHRLWxyPLGcyw3CyOGj/REZns5GTpbZ62QqAPzYiRAWF+9g48V5evahML9YSdfFwQmdgXonxEJCfZuazNqbvEhGGrm0ziUF6hNdqejjALOthZLIG5bVv+8CWnH9Gqtc/QMhZo7aOK+6E5QEaMo0zccTerD7Tq15BbKb2fDWfEV+0rYK9cca+5prRIz1vYREkEYmh7BziYeU3sx/tectlKKMKQpayjR1Mi20m+N7QfTKWjK4OsV4/OofR6UVoc1HBipHbLW+Ofzx2th2mlRb+gQHve2uekv6FOg6JgibfUXvhlQYDiH/sdVnoPdp3eXc97jpfj8MKPMGg1XIVYehv4plDg1nuAMKo7fiedIwvVu4Xkbwf7T2FHdmRKNPS X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: de5255a4-7b6f-40a1-f2dd-08dd02fca0a6 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2024 09:30:20.9762 (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: 3+bs40YMVYjdUhrtbi2XtkmmXZ+mTNRGKzlYVP7FujL9ITxKPsFvpnCZdK6YSI/bkB6xKRSpxaz+z8uEd+iuKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7892 X-Patchwork-Delegate: kuba@kernel.org ENETC rev 4.1 supports TCP and UDP checksum offload for receive, the bit 108 of the Rx BD will be set if the TCP/UDP checksum is correct. Since this capability is not defined in register, the rx_csum bit is added to struct enetc_drvdata to indicate whether the device supports Rx checksum offload. Signed-off-by: Wei Fang Reviewed-by: Frank Li Reviewed-by: Claudiu Manoil --- v2: no changes v3: no changes --- drivers/net/ethernet/freescale/enetc/enetc.c | 14 ++++++++++---- drivers/net/ethernet/freescale/enetc/enetc.h | 2 ++ drivers/net/ethernet/freescale/enetc/enetc_hw.h | 2 ++ .../net/ethernet/freescale/enetc/enetc_pf_common.c | 3 +++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 35634c516e26..3137b6ee62d3 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1011,10 +1011,15 @@ static void enetc_get_offloads(struct enetc_bdr *rx_ring, /* TODO: hashing */ if (rx_ring->ndev->features & NETIF_F_RXCSUM) { - u16 inet_csum = le16_to_cpu(rxbd->r.inet_csum); - - skb->csum = csum_unfold((__force __sum16)~htons(inet_csum)); - skb->ip_summed = CHECKSUM_COMPLETE; + if (priv->active_offloads & ENETC_F_RXCSUM && + le16_to_cpu(rxbd->r.flags) & ENETC_RXBD_FLAG_L4_CSUM_OK) { + skb->ip_summed = CHECKSUM_UNNECESSARY; + } else { + u16 inet_csum = le16_to_cpu(rxbd->r.inet_csum); + + skb->csum = csum_unfold((__force __sum16)~htons(inet_csum)); + skb->ip_summed = CHECKSUM_COMPLETE; + } } if (le16_to_cpu(rxbd->r.flags) & ENETC_RXBD_FLAG_VLAN) { @@ -3281,6 +3286,7 @@ static const struct enetc_drvdata enetc_pf_data = { static const struct enetc_drvdata enetc4_pf_data = { .sysclk_freq = ENETC_CLK_333M, .pmac_offset = ENETC4_PMAC_OFFSET, + .rx_csum = 1, .eth_ops = &enetc4_pf_ethtool_ops, }; diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 72fa03dbc2dd..5b65f79e05be 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -234,6 +234,7 @@ enum enetc_errata { struct enetc_drvdata { u32 pmac_offset; /* Only valid for PSI which supports 802.1Qbu */ + u8 rx_csum:1; u64 sysclk_freq; const struct ethtool_ops *eth_ops; }; @@ -341,6 +342,7 @@ enum enetc_active_offloads { ENETC_F_QBV = BIT(9), ENETC_F_QCI = BIT(10), ENETC_F_QBU = BIT(11), + ENETC_F_RXCSUM = BIT(12), }; enum enetc_flags_bit { diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 7c3285584f8a..4b8fd1879005 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -645,6 +645,8 @@ union enetc_rx_bd { #define ENETC_RXBD_LSTATUS(flags) ((flags) << 16) #define ENETC_RXBD_FLAG_VLAN BIT(9) #define ENETC_RXBD_FLAG_TSTMP BIT(10) +/* UDP and TCP checksum offload, for ENETC 4.1 and later */ +#define ENETC_RXBD_FLAG_L4_CSUM_OK BIT(12) #define ENETC_RXBD_FLAG_TPID GENMASK(1, 0) #define ENETC_MAC_ADDR_FILT_CNT 8 /* # of supported entries per port */ diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 0eecfc833164..91e79582a541 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -119,6 +119,9 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, ndev->priv_flags |= IFF_UNICAST_FLT; + if (si->drvdata->rx_csum) + priv->active_offloads |= ENETC_F_RXCSUM; + /* TODO: currently, i.MX95 ENETC driver does not support advanced features */ if (!is_enetc_rev1(si)) { ndev->hw_features &= ~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK); From patchwork Tue Nov 12 09:14:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13871972 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2080.outbound.protection.outlook.com [40.107.21.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9267420F5B6; Tue, 12 Nov 2024 09:30:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731403830; cv=fail; b=QfPayyH8NfqFueSQvQ0gAiEzqKjU5Pp9utE65/uVYV7TKOyz4Zi2PJIHXmMmlT6EW3KA1zWkbgw31fqMccmMox8PisWY4x4eh2Gg6CMND1sg23nIQiUzcVkZCma/rpPFmxqcFpi4Axl27UJ7sqbtK5UNVsKtbjYMdv9/BeBSARA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731403830; c=relaxed/simple; bh=NPCv6d60efLKVg7OgJQVm3h2/Jj3sv5Swm2WhxKGvEE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pqukR+79bo8ZDY7q4GJq9G+IBSryIndKgnVap00q48Wgnq22OV8pyqYNlApiM6wtf8LkCTYicU7uWda/m3RUUF6I5C6nB5NWIs7TTzdvpWViD0nfT7z+4uqLUEFLzzX/ytAQX1hUYrZVciAwXhsndYhNo2a4gjRVO39DifR6+90= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=bQxC3FUg; arc=fail smtp.client-ip=40.107.21.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="bQxC3FUg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cIPe+AdYKoT75luaaanEll2ou/jdxgon4RApvipnkUlp+3E9O2K13t8dzA9Bb5PscjWCvzNFmqoAxYhWN4JGA5pC45rwXO1rzklFObuj3bBno3imH5UVpXaK2NnVVjOzDlChhWFS/nI435BdActD/8K/GZ6yrZm23tvQ/sJLfWs0yJBYVALZRw7bdjJjWw/K6cCsB5813yyqYQmU945RJZawcoq7Dd6XjZq0+1YKzGECYZ6+rseKyU5kCCdoD5k2Sa/mAEZjmXdIFyIwY5cuJHXbtrNEbo8kWE3RbLIcuk3lGFR5S9aumBIfm7oo8veKIwT9A5fHdDAlHTFhBf5y8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=x0xLRCqDknP/fkYZGGNbE9VAzIWrI/Fok2BQI5/EVFQ=; b=UsdRdyhtSmlxCvs/AU8E5qDnmyO/iSxhzunFy75WetAAkhxwGWZpSJarHrJK0YUYWWb29eYHBKBSZJFuvxyalO3vwDy7pw9YK08eTc5VyEr3MRWnKkHWbn9NA+y5SYAMrDKsiscap2QyaD3nD7nQSoAi1INZ53wFajLRG3ae8kgzYiRPfiRiBG3L/HYzdHfy9auThd09LIDXSP6UDnUttAKWxm2+wsiTX/zkXXUKqD2c8s5rvFERdlXuyhy0tj/fsxofPWXQMzjRmK4hf+wGd0BPNg5I+vUgMyfjNxlWK/mF2DVicI9Qmcqow4XhC6F5ih+TmTi/IQuUJZvUsrxtxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x0xLRCqDknP/fkYZGGNbE9VAzIWrI/Fok2BQI5/EVFQ=; b=bQxC3FUgxLYG6CMgFV4bOQDDDG3IcVMB0CHpHa/Es5C3wishBlXAqILYG/3ImJCrgCHD0XGi5TBdILkZQnJEbR6EpRyxcCsh4JgarZMpky4wKBFOMP6fFMPY06tWg6yPizJAvZTn44Sn5BKmYHuAL32NIC0jjPsd0dvCTBJXlMxIpYQi9PjwM1/JqXXc45JwsvhGe34uAIokwokT8emD+xwluOu4yoo/usGj8vmtMajiDjkhdYJ8htmt3NqnxM69KVTAX5q1Ce3TnI0Dz7tqC5OWtOcdf6drgrjl63ffew7VwuE/5erW3Hu9CURI7rtiiAnSl/1+jzoCQyvbUut2aA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by AM8PR04MB7892.eurprd04.prod.outlook.com (2603:10a6:20b:235::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.29; Tue, 12 Nov 2024 09:30:25 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%7]) with mapi id 15.20.8137.027; Tue, 12 Nov 2024 09:30:25 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, frank.li@nxp.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v3 net-next 2/5] net: enetc: add Tx checksum offload for i.MX95 ENETC Date: Tue, 12 Nov 2024 17:14:44 +0800 Message-Id: <20241112091447.1850899-3-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112091447.1850899-1-wei.fang@nxp.com> References: <20241112091447.1850899-1-wei.fang@nxp.com> X-ClientProxiedBy: SI2PR01CA0041.apcprd01.prod.exchangelabs.com (2603:1096:4:193::15) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|AM8PR04MB7892:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f0795b0-d578-4d8d-b8e1-08dd02fca334 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|1800799024|366016|376014|38350700014; X-Microsoft-Antispam-Message-Info: P931na60nPk2OW+UwgrdtdYcbvruVujRw4YdjHVhx7Iw1EO4qePolM8KGnTEF0dUvsl5YH5dcDNjUsF+RK7sQIX07bAkPhi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V5zJ/CpbSTaA6x2OTsmQjZPuUmXmteQEPkwh9sxcM64DC4XnvZgCZUTBzIr3df+CI96/f9jEwwChuxbdHDDcRGcl9ZaSfSJWlCOPyU7GdC8LV72YFHlyfAsOIlmsN36BMkesPD7ES+UVvLnLvJ0lumjlmLmBuXtgCnM0ypotghzd/NWv3ey4Xp7hQde7Y0IM0fyk0oSnXhdruByo+MfMw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(1800799024)(366016)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eqB76Kjgl3eHwmA0OhTKUPSz1XgRp0pZzQZ9hcYmyDMQW8FZSb+E7iuzbAPa5bMJMSgEkkSs/N7Y/ZgaNlu9hn1XHrRB8F2SGgxGWdZYfK7Y/GVnBLKeV4OcVSv0XtO1W6BmUa+ReEsos1EmmOrDE/aB69vr3tmnKTw5eBxqI36x/62Z1CJ/ClyDriwY+j4HIsDSaO0daW2Bcr8JxCiWZ3DBPIL1TVN+3grRoC2y8FKIjL5J5xOvweTY00cPim1N3Lg3VhrzonoleaP18iu1T9s3XVXUZYAs9pfGAnG2RAJUeWsyjBIbHMRy3ayAJTSVxIXfKGREUSe4+4AouOtXdBJzKvwFC5pyku0AhkE7w9zDtbT0RcIPwccnrWx1PSck+PzHx5eO6+j7zrW6S1PDeMIsPHP0m05kBtJHamp/iWQHkXrBcCrAxoUiVssrppceJNivqHKbtZVdco4eipW/zWC6z0QDyKm6zF5EPX/0m2YQT8HRqc6X1HIs5OMtLWzCcyM7zWGYauSBQa1aQoon9AexYL4M/UicQxm5yDBaf8UlU7d0M73NiMCE5uO/zUteAI9SCanYSUJDRdotVJ0mNCFyL+OYw1wLaiaoErVn9uL8f5Sx/GGUO6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8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2024 09:30:25.1523 (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: 6HpAzPa3aQBo6PC4bkfSF/cefTJy0nya+HZUQgYNLYJGMjBpiV1GLXjsM/Vu0sThvig64k55g3Qta1qKItwF5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7892 X-Patchwork-Delegate: kuba@kernel.org In addition to supporting Rx checksum offload, i.MX95 ENETC also supports Tx checksum offload. The transmit checksum offload is implemented through the Tx BD. To support Tx checksum offload, software needs to fill some auxiliary information in Tx BD, such as IP version, IP header offset and size, whether L4 is UDP or TCP, etc. Same as Rx checksum offload, Tx checksum offload capability isn't defined in register, so tx_csum bit is added to struct enetc_drvdata to indicate whether the device supports Tx checksum offload. Signed-off-by: Wei Fang Reviewed-by: Frank Li Reviewed-by: Claudiu Manoil --- v2: refine enetc_tx_csum_offload_check(). v3: 1. refine enetc_tx_csum_offload_check() and enetc_skb_is_tcp() through skb->csum_offset instead of touching skb->data. 2. add enetc_skb_is_ipv6() helper function --- drivers/net/ethernet/freescale/enetc/enetc.c | 51 ++++++++++++++++--- drivers/net/ethernet/freescale/enetc/enetc.h | 2 + .../net/ethernet/freescale/enetc/enetc_hw.h | 14 +++-- .../freescale/enetc/enetc_pf_common.c | 3 ++ 4 files changed, 60 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 3137b6ee62d3..eeefd536d051 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -143,6 +143,27 @@ static int enetc_ptp_parse(struct sk_buff *skb, u8 *udp, return 0; } +static bool enetc_tx_csum_offload_check(struct sk_buff *skb) +{ + switch (skb->csum_offset) { + case offsetof(struct tcphdr, check): + case offsetof(struct udphdr, check): + return true; + default: + return false; + } +} + +static inline bool enetc_skb_is_ipv6(struct sk_buff *skb) +{ + return vlan_get_protocol(skb) == htons(ETH_P_IPV6); +} + +static inline bool enetc_skb_is_tcp(struct sk_buff *skb) +{ + return skb->csum_offset == offsetof(struct tcphdr, check); +} + static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) { bool do_vlan, do_onestep_tstamp = false, do_twostep_tstamp = false; @@ -160,6 +181,27 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) dma_addr_t dma; u8 flags = 0; + enetc_clear_tx_bd(&temp_bd); + if (skb->ip_summed == CHECKSUM_PARTIAL) { + /* Can not support TSD and checksum offload at the same time */ + if (priv->active_offloads & ENETC_F_TXCSUM && + enetc_tx_csum_offload_check(skb) && !tx_ring->tsd_enable) { + temp_bd.l3_start = skb_network_offset(skb); + temp_bd.ipcs = enetc_skb_is_ipv6(skb) ? 0 : 1; + temp_bd.l3_hdr_size = skb_network_header_len(skb) / 4; + temp_bd.l3t = enetc_skb_is_ipv6(skb) ? 1 : 0; + temp_bd.l4t = enetc_skb_is_tcp(skb) ? ENETC_TXBD_L4T_TCP : + ENETC_TXBD_L4T_UDP; + flags |= ENETC_TXBD_FLAGS_CSUM_LSO | ENETC_TXBD_FLAGS_L4CS; + } else { + if (skb_checksum_help(skb)) { + dev_err(tx_ring->dev, "skb_checksum_help() error\n"); + + return 0; + } + } + } + i = tx_ring->next_to_use; txbd = ENETC_TXBD(*tx_ring, i); prefetchw(txbd); @@ -170,7 +212,6 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) temp_bd.addr = cpu_to_le64(dma); temp_bd.buf_len = cpu_to_le16(len); - temp_bd.lstatus = 0; tx_swbd = &tx_ring->tx_swbd[i]; tx_swbd->dma = dma; @@ -591,7 +632,7 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb, { struct enetc_ndev_priv *priv = netdev_priv(ndev); struct enetc_bdr *tx_ring; - int count, err; + int count; /* Queue one-step Sync packet if already locked */ if (skb->cb[0] & ENETC_F_TX_ONESTEP_SYNC_TSTAMP) { @@ -624,11 +665,6 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb, return NETDEV_TX_BUSY; } - if (skb->ip_summed == CHECKSUM_PARTIAL) { - err = skb_checksum_help(skb); - if (err) - goto drop_packet_err; - } enetc_lock_mdio(); count = enetc_map_tx_buffs(tx_ring, skb); enetc_unlock_mdio(); @@ -3287,6 +3323,7 @@ static const struct enetc_drvdata enetc4_pf_data = { .sysclk_freq = ENETC_CLK_333M, .pmac_offset = ENETC4_PMAC_OFFSET, .rx_csum = 1, + .tx_csum = 1, .eth_ops = &enetc4_pf_ethtool_ops, }; diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 5b65f79e05be..ee11ff97e9ed 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -235,6 +235,7 @@ enum enetc_errata { struct enetc_drvdata { u32 pmac_offset; /* Only valid for PSI which supports 802.1Qbu */ u8 rx_csum:1; + u8 tx_csum:1; u64 sysclk_freq; const struct ethtool_ops *eth_ops; }; @@ -343,6 +344,7 @@ enum enetc_active_offloads { ENETC_F_QCI = BIT(10), ENETC_F_QBU = BIT(11), ENETC_F_RXCSUM = BIT(12), + ENETC_F_TXCSUM = BIT(13), }; enum enetc_flags_bit { diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 4b8fd1879005..590b1412fadf 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -558,7 +558,12 @@ union enetc_tx_bd { __le16 frm_len; union { struct { - u8 reserved[3]; + u8 l3_start:7; + u8 ipcs:1; + u8 l3_hdr_size:7; + u8 l3t:1; + u8 resv:5; + u8 l4t:3; u8 flags; }; /* default layout */ __le32 txstart; @@ -582,10 +587,10 @@ union enetc_tx_bd { }; enum enetc_txbd_flags { - ENETC_TXBD_FLAGS_RES0 = BIT(0), /* reserved */ + ENETC_TXBD_FLAGS_L4CS = BIT(0), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TSE = BIT(1), ENETC_TXBD_FLAGS_W = BIT(2), - ENETC_TXBD_FLAGS_RES3 = BIT(3), /* reserved */ + ENETC_TXBD_FLAGS_CSUM_LSO = BIT(3), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TXSTART = BIT(4), ENETC_TXBD_FLAGS_EX = BIT(6), ENETC_TXBD_FLAGS_F = BIT(7) @@ -594,6 +599,9 @@ enum enetc_txbd_flags { #define ENETC_TXBD_TXSTART_MASK GENMASK(24, 0) #define ENETC_TXBD_FLAGS_OFFSET 24 +#define ENETC_TXBD_L4T_UDP BIT(0) +#define ENETC_TXBD_L4T_TCP BIT(1) + static inline __le32 enetc_txbd_set_tx_start(u64 tx_start, u8 flags) { u32 temp; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 91e79582a541..3a8a5b6d8c26 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -122,6 +122,9 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, if (si->drvdata->rx_csum) priv->active_offloads |= ENETC_F_RXCSUM; + if (si->drvdata->tx_csum) + priv->active_offloads |= ENETC_F_TXCSUM; + /* TODO: currently, i.MX95 ENETC driver does not support advanced features */ if (!is_enetc_rev1(si)) { ndev->hw_features &= ~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK); From patchwork Tue Nov 12 09:14:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13871973 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2080.outbound.protection.outlook.com [40.107.21.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12A982101A4; Tue, 12 Nov 2024 09:30:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731403833; cv=fail; b=UyM6FqrIrxwmMv5XjfxNNYf2AkXKqA7Ju5COkIitRDFnxOj4PFXiD1CZpkbAlGFFTje1CpAIyW2qYXVzbDvPFYr9P1WE+UOuT+JogDUibKc3GxLIAVHKpNfSI+7RCcdFB/xJ2Q0UxGuloBeeW+hyPTy5905EZh0Tugb1lJL5Jfw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731403833; c=relaxed/simple; bh=UiBA0kHLm6NlsJwRa64NkkxUP19MJ7g8Uxh5nc1+OUA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=IQyDNmM+CBzQewsluOJwL+SB7BTW6OOhxeuRMDeTOrBi2DNfik/zwuDA/uN73B0KOXu4csUQRCCidijb+VMZ3GEZ++ZIf1BUHUueCNLl055NLryNANTpgI1pcbD7sd7CpHFRKaYbIrhzEhDWYmxgFux2cIPNEXDRSO7z9qmv5tw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=E+UnMJBd; arc=fail smtp.client-ip=40.107.21.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="E+UnMJBd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xZzSXA+doK+0dCXeLW0J0TNjAxHAxbDDDUlOXYa+NuJbH5f4x++cJuv8qlD26TkZAXtE2j+k6xWePTb8bJcfQj7QqFf/4xQNZPX5G5KqRx3upqh7Yz6ZLqlikJDcO7lkaIEHVNgUNrWQ+sZSNmQe9hvJrWCKbPtUo5l2SUH8We+ubtuqLZNdgl6cqZdGAssQELclpqyj+aXVBSg95b47jEt7lAvZ6QxHJZtOgJ1jGcwYs7NAa3LVfntnFdOMBk+ab3KGlGc+L5myjkBW8PRw692gey1wUDiCIOZ95O8m7pdBDCGHMJxVW6P4tq/aZfasWrqrwW4WhhDs0HTm2NL7/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yNRIVuA5oKrIVX7jFT0M7Sbbqulv1P+PUqog7zFTdMc=; b=jd4QLlOjWtogaiSnLLF3JItClA1EJjMqUjtTIa43pzJTAfetUnDV+WHa3VWNVEoUCks+eUu9mLakMWrTVzGI/H2I47ohR9oyoLtKFuhl3CYMUIBCRJmmDBhortBC0BPuekA4nywAVVrGDMDfrq/A8yuQ+AsTkTBZuKSi+7JOPpee6hFHWOJYhuwm+8Coxoq51QB0w2dGnfXzH3BJoqweMjQQd0qW97Il+XtVx2iI65ahRYbZimiOD480OmwoMK/udwrqIQXD10n2AdyrcRDLs5vFOPbMWa/1X7INIm/4I5VIE6JK/3IEpWqZRHpJyX3vuRcKWOzYqQstV+gV956pdw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yNRIVuA5oKrIVX7jFT0M7Sbbqulv1P+PUqog7zFTdMc=; b=E+UnMJBdWJsAd+LxNtbONJtCL076r6WELgMCj+LS9lw66maY+xYPh6S2vbjtuoXj6QH4pc027wA8l8fBuRT9EKoWSGudwpnep3Kz7yNpw6VpBDeTBZBV+plxhoLj3Rg5NN7zYkBBakiB7O89LMdCotj55+4urGC+JvqsX9uftQs2O4rnVY6Fss8ZeH3e74/XcyDxtyqPk9p+cduBDm4dY9Xyi/2+wDB9BNvq5ka3MsxkIYwZDpwfBLx+5oN1YKvIGRAQ4TjtEPaEPvgZRLODumvWobxhvNDE+d4KGxTx1TH1bndld1LLv1nnRRnsiUT3KuMb7rTHGcoESSSwZNroTg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by AM8PR04MB7892.eurprd04.prod.outlook.com (2603:10a6:20b:235::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.29; Tue, 12 Nov 2024 09:30:29 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%7]) with mapi id 15.20.8137.027; Tue, 12 Nov 2024 09:30:29 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, frank.li@nxp.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v3 net-next 3/5] net: enetc: update max chained Tx BD number for i.MX95 ENETC Date: Tue, 12 Nov 2024 17:14:45 +0800 Message-Id: <20241112091447.1850899-4-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112091447.1850899-1-wei.fang@nxp.com> References: <20241112091447.1850899-1-wei.fang@nxp.com> X-ClientProxiedBy: SI2PR01CA0041.apcprd01.prod.exchangelabs.com (2603:1096:4:193::15) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|AM8PR04MB7892:EE_ X-MS-Office365-Filtering-Correlation-Id: 91bc4d4d-e9fe-47ee-55d1-08dd02fca589 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|1800799024|366016|376014|38350700014; X-Microsoft-Antispam-Message-Info: 1ctll0faqhqoqwpUS5zSU7a2c0fabqSPAId9rz++ypq9i7wgSBPKqhyIXLSH06IT+xw7/pif+Mt56CyO25e03ZfgWhR5B4LmRpmeghOCJXhbfCsTa8Lb7+B0HWOIGslEtdHqXvqREjC/sBH4OphRlCGfCz9iQgp3qO8jCWvJ2Oyolc4vjPrwJo+C3Qu+yABo0zMlhMUjcPNIOVA631T8Awqm6n5Uo6G3AjjEELlYbum1xpOeOeI6oc0j9X4HINSjzuDtwtFdiaTCdCEvSkWlNggsOPlx28jPr0qW0JhYEA5z2XFs/0P3PVUQTX1OezIrtwVN5AAQphmyTwVouva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en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(1800799024)(366016)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0XMScVvzRXQGyZ76Id/YeApZRDsvI8tD9Tr+CkbyUW2XfYLI8jvnh7h8RqbBuPiIahipPXLlbvuElJvb2rXf7mwWja36sVgdP0ZWmnfixsgLPDno3Ddbl8gFGm7Oz+TP/KcQ9NjmzcOiD7/nffrRN1Q2KIczo+3CZ4xvIRAnDsrp9NbZq8j8TcnR6Ddx9yQp8lyz95m7+JZqUvw+zNpkMCyqy4LI7dfwWul1cHZVoAOMFkce+sbYYxFIh8h0iZhd3+rfsMWJO2aX8ISedwiHDXgQdwUftAq5km3tz2ad1w289MyUnW8XWy2Mc8A8XkF1iT8feL8k69KxtDQESjPO2NdWwkWSKIHNDKvF5id9tUVEQr6zHSCeO7PRehVnxqhWB8jhql3WqsOcDbXCVt1+cVzywhABVpuOhw0wANCHDHlczet0+dePO3gHonwRsVuQVm08dUgLOtgaYp0zR/cPr/k92L5ZDyvaKF3XLOn5/pzY/oXSfUPL24vfMzuq0SnFQd6FIvLqu97XMtjftcCva2gs1FYpozHNNTRm4HnkYUCg33o2fXZu0Yb+mFr653WXBsaODt0C/u5qX9teTxEhpv7u0b00TDX3eUwDMxScoadvoWsOttTpr4EViu+rvv44cIU7BWjd+Jbenz1OH9W1G9knne7Ju+Z3O4ABfzrACvaxFN86a+mritE/OjBzfxsz3k4KN7pM7YdIZY8fTfg00CTd+jW1dYsHSn19Uwd1n33Z7VcA3JDSsIqNVnyJOpymFp1keG0PPKlZX7QodSu+8JA9QjnUE5vO1OAv4k+kAYEjuX9ojZODUbRACH6O4K/GaRcAGEnokalSOjv20yIqE3ejkl7seDtmBhMNaG5i6jKOCxRfOu4mcki+Tvxm8W509XcCdzZnvzIf+mAjBLb4n/FQboD3EQse3Tmzs7nocS0Y2RBHyfxsgrrPz6zCvuADXCqI0Ik2NyAeJzuPCex0wXsZi+Hp7CpJ4PjvvyaFBR+Vnjy2nQIbdDfdYXulwtVOoEiW3hnQN1HfWa+Zjse1rbCq5r24P9UkW1saz68KwFNJv1cgxch6f8YcYP8KTDHjB0lUC99w74PamChXBjnsEXhlPoFHiyvlZ77uaJHtbO/axH0bkJpq2AS6OzcQlRFpOVTUBpCZglJYuzcTmsMjfYgh4KLH1FTDEy8Cs6cpGN+sF3rOXBlAPSj0hlPIbYUfCfm0jc8Slu2znFe+TsK+jgM7g5bllGjF9QrA5XJyr4/50FuqAU6SaQdNXsbWpgAkyd/AiTuLLJ3WBcNJGq/FeGjNm6XWcJ54WIwLbhjwsY8sF461cuzxmDZd70GZI/k3YrX95B6Xvt6N3Lg0npntL9+HlEPvbfPd5LO4Q88mucneX4KTlT+zf7dyiWzK06Uuf5cCxy9QvCuLUIdlwu7UY+Y8pkL+ii4k//4PhDenBJsamFQAdPZVx9psC0K1EsBHvAMYfPEw5mwQHyW+EDKSxCT1LoYPlJ8NJJyFlLt4btupnVAj+E6b6Fi7JcyqdJFoWnwqu2q4VzyGMg7bp5deO3bc+gQvZh3OnK6WHtmC8Wi0+FJacW2OmKJSkl3hsP7q X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91bc4d4d-e9fe-47ee-55d1-08dd02fca589 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2024 09:30:29.1953 (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: krDQ2btQbr9dOCUdK7zwdPsXuamjxQkr+arCPbVjW20pfscMnUXSrKu8h6Smc31oP76wddgSJKbwVPfN05vnQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7892 X-Patchwork-Delegate: kuba@kernel.org The max chained Tx BDs of latest ENETC (i.MX95 ENETC, rev 4.1) has been increased to 63, but since the range of MAX_SKB_FRAGS is 17~45, so for i.MX95 ENETC and later revision, it is better to set ENETC4_MAX_SKB_FRAGS to MAX_SKB_FRAGS. In addition, add max_frags in struct enetc_drvdata to indicate the max chained BDs supported by device. Because the max number of chained BDs supported by LS1028A and i.MX95 ENETC is different. Signed-off-by: Wei Fang Reviewed-by: Frank Li Reviewed-by: Claudiu Manoil --- v2: 1. Refine the commit message 2. Add Reviewed-by tag v3: no changes --- drivers/net/ethernet/freescale/enetc/enetc.c | 13 +++++++++---- drivers/net/ethernet/freescale/enetc/enetc.h | 13 +++++++++++-- .../net/ethernet/freescale/enetc/enetc_pf_common.c | 1 + drivers/net/ethernet/freescale/enetc/enetc_vf.c | 1 + 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index eeefd536d051..7c6b844c2e96 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -529,6 +529,7 @@ static void enetc_tso_complete_csum(struct enetc_bdr *tx_ring, struct tso_t *tso static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) { + struct enetc_ndev_priv *priv = netdev_priv(tx_ring->ndev); int hdr_len, total_len, data_len; struct enetc_tx_swbd *tx_swbd; union enetc_tx_bd *txbd; @@ -594,7 +595,7 @@ static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb bd_data_num++; tso_build_data(skb, &tso, size); - if (unlikely(bd_data_num >= ENETC_MAX_SKB_FRAGS && data_len)) + if (unlikely(bd_data_num >= priv->max_frags && data_len)) goto err_chained_bd; } @@ -655,7 +656,7 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb, count = enetc_map_tx_tso_buffs(tx_ring, skb); enetc_unlock_mdio(); } else { - if (unlikely(skb_shinfo(skb)->nr_frags > ENETC_MAX_SKB_FRAGS)) + if (unlikely(skb_shinfo(skb)->nr_frags > priv->max_frags)) if (unlikely(skb_linearize(skb))) goto drop_packet_err; @@ -673,7 +674,7 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb, if (unlikely(!count)) goto drop_packet_err; - if (enetc_bd_unused(tx_ring) < ENETC_TXBDS_MAX_NEEDED) + if (enetc_bd_unused(tx_ring) < ENETC_TXBDS_MAX_NEEDED(priv->max_frags)) netif_stop_subqueue(ndev, tx_ring->index); return NETDEV_TX_OK; @@ -941,7 +942,8 @@ static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget) if (unlikely(tx_frm_cnt && netif_carrier_ok(ndev) && __netif_subqueue_stopped(ndev, tx_ring->index) && !test_bit(ENETC_TX_DOWN, &priv->flags) && - (enetc_bd_unused(tx_ring) >= ENETC_TXBDS_MAX_NEEDED))) { + (enetc_bd_unused(tx_ring) >= + ENETC_TXBDS_MAX_NEEDED(priv->max_frags)))) { netif_wake_subqueue(ndev, tx_ring->index); } @@ -3316,6 +3318,7 @@ EXPORT_SYMBOL_GPL(enetc_pci_remove); static const struct enetc_drvdata enetc_pf_data = { .sysclk_freq = ENETC_CLK_400M, .pmac_offset = ENETC_PMAC_OFFSET, + .max_frags = ENETC_MAX_SKB_FRAGS, .eth_ops = &enetc_pf_ethtool_ops, }; @@ -3324,11 +3327,13 @@ static const struct enetc_drvdata enetc4_pf_data = { .pmac_offset = ENETC4_PMAC_OFFSET, .rx_csum = 1, .tx_csum = 1, + .max_frags = ENETC4_MAX_SKB_FRAGS, .eth_ops = &enetc4_pf_ethtool_ops, }; static const struct enetc_drvdata enetc_vf_data = { .sysclk_freq = ENETC_CLK_400M, + .max_frags = ENETC_MAX_SKB_FRAGS, .eth_ops = &enetc_vf_ethtool_ops, }; diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index ee11ff97e9ed..a78af4f624e0 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -59,9 +59,16 @@ struct enetc_rx_swbd { /* ENETC overhead: optional extension BD + 1 BD gap */ #define ENETC_TXBDS_NEEDED(val) ((val) + 2) -/* max # of chained Tx BDs is 15, including head and extension BD */ +/* For LS1028A, max # of chained Tx BDs is 15, including head and + * extension BD. + */ #define ENETC_MAX_SKB_FRAGS 13 -#define ENETC_TXBDS_MAX_NEEDED ENETC_TXBDS_NEEDED(ENETC_MAX_SKB_FRAGS + 1) +/* For ENETC v4 and later versions, max # of chained Tx BDs is 63, + * including head and extension BD, but the range of MAX_SKB_FRAGS + * is 17 ~ 45, so set ENETC4_MAX_SKB_FRAGS to MAX_SKB_FRAGS. + */ +#define ENETC4_MAX_SKB_FRAGS MAX_SKB_FRAGS +#define ENETC_TXBDS_MAX_NEEDED(x) ENETC_TXBDS_NEEDED((x) + 1) struct enetc_ring_stats { unsigned int packets; @@ -236,6 +243,7 @@ struct enetc_drvdata { u32 pmac_offset; /* Only valid for PSI which supports 802.1Qbu */ u8 rx_csum:1; u8 tx_csum:1; + u8 max_frags; u64 sysclk_freq; const struct ethtool_ops *eth_ops; }; @@ -379,6 +387,7 @@ struct enetc_ndev_priv { u16 msg_enable; u8 preemptible_tcs; + u8 max_frags; /* The maximum number of BDs for fragments */ enum enetc_active_offloads active_offloads; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 3a8a5b6d8c26..2c4c6af672e7 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -101,6 +101,7 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, priv->msg_enable = (NETIF_MSG_WOL << 1) - 1; priv->sysclk_freq = si->drvdata->sysclk_freq; + priv->max_frags = si->drvdata->max_frags; ndev->netdev_ops = ndev_ops; enetc_set_ethtool_ops(ndev); ndev->watchdog_timeo = 5 * HZ; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c index 31e630638090..052833acd220 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c @@ -129,6 +129,7 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev, priv->msg_enable = (NETIF_MSG_IFUP << 1) - 1; priv->sysclk_freq = si->drvdata->sysclk_freq; + priv->max_frags = si->drvdata->max_frags; ndev->netdev_ops = ndev_ops; enetc_set_ethtool_ops(ndev); ndev->watchdog_timeo = 5 * HZ; From patchwork Tue Nov 12 09:14:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13871974 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2085.outbound.protection.outlook.com [40.107.249.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9240F2123F0; Tue, 12 Nov 2024 09:30:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731403840; cv=fail; b=aisQdvf/8mHUa533jdrBjigOvBB5BM6fKNwbkhNy8GEQlCyjhjaRJ1Q8Vz3gsLxaql0vM+p6EmrvCKYHhT1t0ST3Aeo27HrIK9wTnDJB2UWQp3N7nEmgUeqHOe4JtfFbebDmAAsWmWqkFAJ0vBxkSi1Omm9+TiFONKgGe7wJUwE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731403840; c=relaxed/simple; bh=rnuz9WSThS7kQ/rtN+cQ1pMVPFVVMcvOrGTl22N5Vb4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=uTm6X12xmaLmP6Dn/CqoR/ReGjwKRL1IL3li2b+2ksb737e6shr/UEE3nTR9APEs50Nb6Q7QwIR/JjQ1uNdIBVoW2iyFPKZ7/8j/wia0hEnI+ghdLIT5SK2wZGLg28hdhK8SeNno1KiBX9fead/WDb9ARtLL7zhl02fPGC/nXT4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=kCR3TGsY; arc=fail smtp.client-ip=40.107.249.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="kCR3TGsY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VSU6mZqFCC6N78A4VihEd4o+UGFTlgOkIZlsWVL0e8IBgBt1xZ7nVNTTMaOOZBsg2Ss0yJs+X7MB5mgD975o7oIzusKli99TrSxico9Rk1QDpDYAzct04OrqKfx6j6LYdo3ZQ4z/a/90lyDL6O/dcjya9dUsSTe9iqkanAxm1iSQA7k1cFAtc13/kojms/QOpT5ll2SooVuiZoI5UDpTjMUJNY3g+bJNWtwYU2nM/C1OgWW72aucd1meV5VU6LT8IA5bRnbsAkClX7Wen5e4FxZWqWMzeZWaYv8j3jZVsdTRFujeFA/m0EV7wMIkRickzNfdDPfqfjGs/qf11Q8pCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oDEkoZQMNj6A7ah59aru6sKVGKBHceP9SBhJZluznTM=; b=MWHpzInN/92/1QOxRAlpZrci1gQLLkfuD4ckXcaGYKRsmhO+gidRnk+QJNTC3LPAVM0A7YiLmxkk+8H0FVTqkoTbwwBOUMGF7CNaMDhe2OEWBISSwm5rodUKfrLwTE5HtPSugVTumcw32MgRdaXXafz7B50DPaN/JO5WbOE+1CjGp6NytQFUZJi6Lb0cwdx9zjt+ANW77ozOdBDvnzhjN34t/liquBtIIUA6mvsyXDeRWWvaZRHaoDBFof6sk7avKh7c7riUzhgw/JdFwbMxvOyVUQ22nN3X9SrnS0CFl7ouWc47weQ6sHD820epjv+iHqcmmWYb4PBw0VY7OIDD/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oDEkoZQMNj6A7ah59aru6sKVGKBHceP9SBhJZluznTM=; b=kCR3TGsYA+GNeRdEpuvF6WWdU0VqTZW0HNsRVAJhh5PFEvxnV20aSQ/DEaJWX1O/kE1MM8J9VBh09z7C4qKWnCKnq2Tg3tt6t9eVol/uhbVLZsKMVT6aRMZrXQuUHqpUA4ooI8l8HTK4T2EqwmPv5k/HzmPdVat9i08QObHB1t6medAAA2FPTh977LkN5IL9xjSdckL4yINUeR/B2cKgiG4EknaLppj1l4IIzGwZurHTfeYJgyJc3JlPkN+uCeQetDh8M6dZ2q2jzc7+mVtGIivH49UIN33ZC3LG67mch64qex0xODq0IlcPGZqsqm/T+d2m5YvmbF4jN6Zo1tN7GA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by PR3PR04MB7339.eurprd04.prod.outlook.com (2603:10a6:102:8b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Tue, 12 Nov 2024 09:30:33 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%7]) with mapi id 15.20.8137.027; Tue, 12 Nov 2024 09:30:33 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, frank.li@nxp.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v3 net-next 4/5] net: enetc: add LSO support for i.MX95 ENETC PF Date: Tue, 12 Nov 2024 17:14:46 +0800 Message-Id: <20241112091447.1850899-5-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112091447.1850899-1-wei.fang@nxp.com> References: <20241112091447.1850899-1-wei.fang@nxp.com> X-ClientProxiedBy: SI2PR01CA0041.apcprd01.prod.exchangelabs.com (2603:1096:4:193::15) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|PR3PR04MB7339:EE_ X-MS-Office365-Filtering-Correlation-Id: d2421ffe-ae30-4e5e-1fb8-08dd02fca802 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|366016|376014|38350700014; X-Microsoft-Antispam-Message-Info: SKvNJecDiDUErSm7Datpa2G9b0nJ36H4ujSlgjipfELNIspQgNeTwv+We5VCP7TIC4budbbPJIuY7HFZpSB6dhVlMOOGOfoeKErIXb7+KzqNcic/sBLwGQ7toEpEdT/SJzhiTbi5eLkbf9H0aOXxkc/txTE0eQbgs9gCsmrYqLbtcJAQNAtSNVA9md1jYU5eiRygMPa/YbPpvsznHqN/4nqxJi/JeUfteUQJRwQ7yxDwoYmBKT4kXcoiAhA21evEJiR7k9Erup2xKQCkIoYLK0TJsP6qGRfnLBnkTpf3mZpL9Aw+pY6GDdUqfWkbxKUjZ0EQ15S4QFe8JHRGW3e0vBXxfADN30Dg9EpNrKbp/AP3j3aQN2GAWxrQ/3lMDZ0+HOPupOB5kvfYCwu6vlIEfnxYHZ0TUNepmBc7ztMVjB+UZ6roVFTe0BzYVFp3xW7T0tEocNkVR3PzYROq7MD7ltfxHiGA3Us4bCNV0Ro8kr2dkBGPnb9T7EIf81y4szKkOQ9Nm6tnw53K4pG2XlR0sz+l07km9ojOsIeGxH7fcYEkaeSm55cJuFbAORRfDZRJjWJpUfa1JubW3A+GMgcE863ktOp8ZdZDz+fbfp1yDwszB5pov/v2b9EMLngy9kADVTGT/4VxwlJ4a/x8BvI+CYNr7kTXKC61OVCGRjAp64u9wDpxRvrzS2SCLv7IBUbNGcHWqwnhao5pQdCyolYFEDanvwHc4OUTSUKINFe4X0YSNL1rQafEREVd1SHnl18ZDayptrEk8CAaGr85VfWEWH0jsRR1zeHrKjLIUZxlX/aWLGxCam0ULhgYfNw8prNQBsAhmo6Rr5vz/Uu7n69vKMTU00QLDzVfo5cSZ2sGGShNWAQzxDNjHUex4BbwdoIGz86tNoZ+e9XZPMYLHiV6bMSK10W6SqztRK9JkXdfBO7odh5dawmVUQVaBqGdjufNlUIZy9+8RzxCg7Pj514dCePyISuowz9OGeZ8X4XYRTPEJB6r/fp7VhAftKqBJFkDuHuG8fmpG6q6YRvRj0/fOp/JJ2cmjjOpq3MRO5SPUEC1KU02pReyiq545C+Qgl9czhoBJc3PSn9u94B3986DqOE6cZD3S+MUSzLij40D+/2NxLaz0no/G1EIuX0wbntq6FBNVK6GMVOJcqnuc11R9Erc3pkAksWbjG3aeX20msvuFz8AneU25xtaRYWQqYwwQMuwe+uTCfdlJEjkOYoqEBKrFK2iqiytmHp5UJKMKFcPnHqEXpCAue6QUexlV8DlzI9pEBk11hpEr6pj5Yn6yonDWCGJXzRaQgbWAVIVs7M13TyRvuWmPpLv/ocwW2QXXdcik1ZbfaHSKZn2CNEW6y4EXCn6LcR/XVeMEw2eMNY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(366016)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: H8DfxZTJYS3GpHVu03ZThBw43oQo4Di+hr6+XZYS/ZrFHxfT59lpHx8qUeLnvbW6crQ7Io0zEmxeoUSjqMty8i71z/qNcLmQAykPVn7WA4rqy1UWKOg7I+Xak5S3OE/y4+0Ytd/r6ELtVFg47Kiv0QhZFR0OOksHsCnEjHeVGPbgxwL2mRJHdpY6ULfN1F5JNi/V2s+cle9kNjd4VBe2Ohg4MOiDCp3Rb6hfsQrR8CxUo6I25NY/pPKBJSuGJGjhtdcnVrlXy+5LBx/77pqOHDiVPcnKJa14fTWzbDKm3xkYLAihV0sczAs8AbHLLKMv4SZP3Iq20LnjhqVhhyYVh1MIZxVda+rY2vKBnh8UJ8e76xeGLrDPa1/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GyqlOnyA2avnMr9GrOEIvthyylM/gBVWO4SKQvgym4l8xz2Sr0VSDK3nQqo6dPdW+9nStDPpJhtaqQ0izyoTIPpjvl3S8bTsu2un9AAYo6beltpcChHcK1V X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2421ffe-ae30-4e5e-1fb8-08dd02fca802 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2024 09:30:33.4006 (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: P5bYI6XpPYm6MWiQvkUNiAF5/ShrFwJ09UCeCg1WXVbWo9m0KL1c/QvKk4dtp9Vg7Sb+yY0fzDEz76DD1g163A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR04MB7339 X-Patchwork-Delegate: kuba@kernel.org ENETC rev 4.1 supports large send offload (LSO), segmenting large TCP and UDP transmit units into multiple Ethernet frames. To support LSO, software needs to fill some auxiliary information in Tx BD, such as LSO header length, frame length, LSO maximum segment size, etc. At 1Gbps link rate, TCP segmentation was tested using iperf3, and the CPU performance before and after applying the patch was compared through the top command. It can be seen that LSO saves a significant amount of CPU cycles compared to software TSO. Before applying the patch: %Cpu(s): 0.1 us, 4.1 sy, 0.0 ni, 85.7 id, 0.0 wa, 0.5 hi, 9.7 si After applying the patch: %Cpu(s): 0.1 us, 2.3 sy, 0.0 ni, 94.5 id, 0.0 wa, 0.4 hi, 2.6 si Signed-off-by: Wei Fang Reviewed-by: Frank Li Reviewed-by: Claudiu Manoil --- v2: no changes v3: use enetc_skb_is_ipv6() helper fucntion which is added in patch 2 --- drivers/net/ethernet/freescale/enetc/enetc.c | 266 +++++++++++++++++- drivers/net/ethernet/freescale/enetc/enetc.h | 15 + .../net/ethernet/freescale/enetc/enetc4_hw.h | 22 ++ .../net/ethernet/freescale/enetc/enetc_hw.h | 15 +- .../freescale/enetc/enetc_pf_common.c | 3 + 5 files changed, 311 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 7c6b844c2e96..91428bb99f6d 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -527,6 +527,233 @@ static void enetc_tso_complete_csum(struct enetc_bdr *tx_ring, struct tso_t *tso } } +static inline int enetc_lso_count_descs(const struct sk_buff *skb) +{ + /* 4 BDs: 1 BD for LSO header + 1 BD for extended BD + 1 BD + * for linear area data but not include LSO header, namely + * skb_headlen(skb) - lso_hdr_len. And 1 BD for gap. + */ + return skb_shinfo(skb)->nr_frags + 4; +} + +static int enetc_lso_get_hdr_len(const struct sk_buff *skb) +{ + int hdr_len, tlen; + + tlen = skb_is_gso_tcp(skb) ? tcp_hdrlen(skb) : sizeof(struct udphdr); + hdr_len = skb_transport_offset(skb) + tlen; + + return hdr_len; +} + +static void enetc_lso_start(struct sk_buff *skb, struct enetc_lso_t *lso) +{ + lso->lso_seg_size = skb_shinfo(skb)->gso_size; + lso->ipv6 = enetc_skb_is_ipv6(skb); + lso->tcp = skb_is_gso_tcp(skb); + lso->l3_hdr_len = skb_network_header_len(skb); + lso->l3_start = skb_network_offset(skb); + lso->hdr_len = enetc_lso_get_hdr_len(skb); + lso->total_len = skb->len - lso->hdr_len; +} + +static void enetc_lso_map_hdr(struct enetc_bdr *tx_ring, struct sk_buff *skb, + int *i, struct enetc_lso_t *lso) +{ + union enetc_tx_bd txbd_tmp, *txbd; + struct enetc_tx_swbd *tx_swbd; + u16 frm_len, frm_len_ext; + u8 flags, e_flags = 0; + dma_addr_t addr; + char *hdr; + + /* Get the fisrt BD of the LSO BDs chain */ + txbd = ENETC_TXBD(*tx_ring, *i); + tx_swbd = &tx_ring->tx_swbd[*i]; + prefetchw(txbd); + + /* Prepare LSO header: MAC + IP + TCP/UDP */ + hdr = tx_ring->tso_headers + *i * TSO_HEADER_SIZE; + memcpy(hdr, skb->data, lso->hdr_len); + addr = tx_ring->tso_headers_dma + *i * TSO_HEADER_SIZE; + + frm_len = lso->total_len & 0xffff; + frm_len_ext = (lso->total_len >> 16) & 0xf; + + /* Set the flags of the first BD */ + flags = ENETC_TXBD_FLAGS_EX | ENETC_TXBD_FLAGS_CSUM_LSO | + ENETC_TXBD_FLAGS_LSO | ENETC_TXBD_FLAGS_L4CS; + + enetc_clear_tx_bd(&txbd_tmp); + txbd_tmp.addr = cpu_to_le64(addr); + txbd_tmp.hdr_len = cpu_to_le16(lso->hdr_len); + + /* first BD needs frm_len and offload flags set */ + txbd_tmp.frm_len = cpu_to_le16(frm_len); + txbd_tmp.flags = flags; + + if (lso->tcp) + txbd_tmp.l4t = ENETC_TXBD_L4T_TCP; + else + txbd_tmp.l4t = ENETC_TXBD_L4T_UDP; + + if (lso->ipv6) + txbd_tmp.l3t = 1; + else + txbd_tmp.ipcs = 1; + + /* l3_hdr_size in 32-bits (4 bytes) */ + txbd_tmp.l3_hdr_size = lso->l3_hdr_len / 4; + txbd_tmp.l3_start = lso->l3_start; + + /* For the LSO header we do not set the dma address since + * we do not want it unmapped when we do cleanup. We still + * set len so that we count the bytes sent. + */ + tx_swbd->len = lso->hdr_len; + tx_swbd->do_twostep_tstamp = false; + tx_swbd->check_wb = false; + + /* Actually write the header in the BD */ + *txbd = txbd_tmp; + + /* Get the next BD, and the next BD is extended BD */ + enetc_bdr_idx_inc(tx_ring, i); + txbd = ENETC_TXBD(*tx_ring, *i); + tx_swbd = &tx_ring->tx_swbd[*i]; + prefetchw(txbd); + + enetc_clear_tx_bd(&txbd_tmp); + if (skb_vlan_tag_present(skb)) { + /* Setup the VLAN fields */ + txbd_tmp.ext.vid = cpu_to_le16(skb_vlan_tag_get(skb)); + txbd_tmp.ext.tpid = 0; /* < C-TAG */ + e_flags = ENETC_TXBD_E_FLAGS_VLAN_INS; + } + + /* Write the BD */ + txbd_tmp.ext.e_flags = e_flags; + txbd_tmp.ext.lso_sg_size = cpu_to_le16(lso->lso_seg_size); + txbd_tmp.ext.frm_len_ext = cpu_to_le16(frm_len_ext); + *txbd = txbd_tmp; +} + +static int enetc_lso_map_data(struct enetc_bdr *tx_ring, struct sk_buff *skb, + int *i, struct enetc_lso_t *lso, int *count) +{ + union enetc_tx_bd txbd_tmp, *txbd = NULL; + struct enetc_tx_swbd *tx_swbd; + skb_frag_t *frag; + dma_addr_t dma; + u8 flags = 0; + int len, f; + + len = skb_headlen(skb) - lso->hdr_len; + if (len > 0) { + dma = dma_map_single(tx_ring->dev, skb->data + lso->hdr_len, + len, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(tx_ring->dev, dma))) { + netdev_err(tx_ring->ndev, "DMA map error\n"); + goto dma_err; + } + + enetc_bdr_idx_inc(tx_ring, i); + txbd = ENETC_TXBD(*tx_ring, *i); + tx_swbd = &tx_ring->tx_swbd[*i]; + prefetchw(txbd); + *count += 1; + + enetc_clear_tx_bd(&txbd_tmp); + txbd_tmp.addr = cpu_to_le64(dma); + txbd_tmp.buf_len = cpu_to_le16(len); + + tx_swbd->dma = dma; + tx_swbd->len = len; + tx_swbd->is_dma_page = 0; + tx_swbd->dir = DMA_TO_DEVICE; + } + + frag = &skb_shinfo(skb)->frags[0]; + for (f = 0; f < skb_shinfo(skb)->nr_frags; f++, frag++) { + if (txbd) + *txbd = txbd_tmp; + + len = skb_frag_size(frag); + dma = skb_frag_dma_map(tx_ring->dev, frag, 0, len, + DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(tx_ring->dev, dma))) { + netdev_err(tx_ring->ndev, "DMA map error\n"); + goto dma_err; + } + + /* Get the next BD */ + enetc_bdr_idx_inc(tx_ring, i); + txbd = ENETC_TXBD(*tx_ring, *i); + tx_swbd = &tx_ring->tx_swbd[*i]; + prefetchw(txbd); + *count += 1; + + enetc_clear_tx_bd(&txbd_tmp); + txbd_tmp.addr = cpu_to_le64(dma); + txbd_tmp.buf_len = cpu_to_le16(len); + + tx_swbd->dma = dma; + tx_swbd->len = len; + tx_swbd->is_dma_page = 1; + tx_swbd->dir = DMA_TO_DEVICE; + } + + /* Last BD needs 'F' bit set */ + flags |= ENETC_TXBD_FLAGS_F; + txbd_tmp.flags = flags; + *txbd = txbd_tmp; + + tx_swbd->is_eof = 1; + tx_swbd->skb = skb; + + return 0; + +dma_err: + return -ENOMEM; +} + +static int enetc_lso_hw_offload(struct enetc_bdr *tx_ring, struct sk_buff *skb) +{ + struct enetc_tx_swbd *tx_swbd; + struct enetc_lso_t lso = {0}; + int err, i, count = 0; + + /* Initialize the LSO handler */ + enetc_lso_start(skb, &lso); + i = tx_ring->next_to_use; + + enetc_lso_map_hdr(tx_ring, skb, &i, &lso); + /* First BD and an extend BD */ + count += 2; + + err = enetc_lso_map_data(tx_ring, skb, &i, &lso, &count); + if (err) + goto dma_err; + + /* Go to the next BD */ + enetc_bdr_idx_inc(tx_ring, &i); + tx_ring->next_to_use = i; + enetc_update_tx_ring_tail(tx_ring); + + return count; + +dma_err: + do { + tx_swbd = &tx_ring->tx_swbd[i]; + enetc_free_tx_frame(tx_ring, tx_swbd); + if (i == 0) + i = tx_ring->bd_count; + i--; + } while (count--); + + return 0; +} + static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) { struct enetc_ndev_priv *priv = netdev_priv(tx_ring->ndev); @@ -647,14 +874,26 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb, tx_ring = priv->tx_ring[skb->queue_mapping]; if (skb_is_gso(skb)) { - if (enetc_bd_unused(tx_ring) < tso_count_descs(skb)) { - netif_stop_subqueue(ndev, tx_ring->index); - return NETDEV_TX_BUSY; - } + /* LSO data unit lengths of up to 256KB are supported */ + if (priv->active_offloads & ENETC_F_LSO && + (skb->len - enetc_lso_get_hdr_len(skb)) <= + ENETC_LSO_MAX_DATA_LEN) { + if (enetc_bd_unused(tx_ring) < enetc_lso_count_descs(skb)) { + netif_stop_subqueue(ndev, tx_ring->index); + return NETDEV_TX_BUSY; + } - enetc_lock_mdio(); - count = enetc_map_tx_tso_buffs(tx_ring, skb); - enetc_unlock_mdio(); + count = enetc_lso_hw_offload(tx_ring, skb); + } else { + if (enetc_bd_unused(tx_ring) < tso_count_descs(skb)) { + netif_stop_subqueue(ndev, tx_ring->index); + return NETDEV_TX_BUSY; + } + + enetc_lock_mdio(); + count = enetc_map_tx_tso_buffs(tx_ring, skb); + enetc_unlock_mdio(); + } } else { if (unlikely(skb_shinfo(skb)->nr_frags > priv->max_frags)) if (unlikely(skb_linearize(skb))) @@ -1800,6 +2039,9 @@ void enetc_get_si_caps(struct enetc_si *si) si->num_rss = ENETC_SIRSSCAPR_GET_NUM_RSS(rss); } + if (val & ENETC_SIPCAPR0_LSO) + si->hw_features |= ENETC_SI_F_LSO; + if (val & ENETC_SIPCAPR0_QBV) si->hw_features |= ENETC_SI_F_QBV; @@ -2104,6 +2346,13 @@ static int enetc_setup_default_rss_table(struct enetc_si *si, int num_groups) return 0; } +static void enetc_set_lso_flags_mask(struct enetc_hw *hw) +{ + enetc_wr(hw, ENETC4_SILSOSFMR0, + SILSOSFMR0_VAL_SET(TCP_NL_SEG_FLAGS_DMASK, TCP_NL_SEG_FLAGS_DMASK)); + enetc_wr(hw, ENETC4_SILSOSFMR1, 0); +} + int enetc_configure_si(struct enetc_ndev_priv *priv) { struct enetc_si *si = priv->si; @@ -2117,6 +2366,9 @@ int enetc_configure_si(struct enetc_ndev_priv *priv) /* enable SI */ enetc_wr(hw, ENETC_SIMR, ENETC_SIMR_EN); + if (si->hw_features & ENETC_SI_F_LSO) + enetc_set_lso_flags_mask(hw); + /* TODO: RSS support for i.MX95 will be supported later, and the * is_enetc_rev1() condition will be removed */ diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index a78af4f624e0..0a69f72fe8ec 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -41,6 +41,19 @@ struct enetc_tx_swbd { u8 qbv_en:1; }; +struct enetc_lso_t { + bool ipv6; + bool tcp; + u8 l3_hdr_len; + u8 hdr_len; /* LSO header length */ + u8 l3_start; + u16 lso_seg_size; + int total_len; /* total data length, not include LSO header */ +}; + +#define ENETC_1KB_SIZE 1024 +#define ENETC_LSO_MAX_DATA_LEN (256 * ENETC_1KB_SIZE) + #define ENETC_RX_MAXFRM_SIZE ENETC_MAC_MAXFRM_SIZE #define ENETC_RXB_TRUESIZE 2048 /* PAGE_SIZE >> 1 */ #define ENETC_RXB_PAD NET_SKB_PAD /* add extra space if needed */ @@ -238,6 +251,7 @@ enum enetc_errata { #define ENETC_SI_F_PSFP BIT(0) #define ENETC_SI_F_QBV BIT(1) #define ENETC_SI_F_QBU BIT(2) +#define ENETC_SI_F_LSO BIT(3) struct enetc_drvdata { u32 pmac_offset; /* Only valid for PSI which supports 802.1Qbu */ @@ -353,6 +367,7 @@ enum enetc_active_offloads { ENETC_F_QBU = BIT(11), ENETC_F_RXCSUM = BIT(12), ENETC_F_TXCSUM = BIT(13), + ENETC_F_LSO = BIT(14), }; enum enetc_flags_bit { diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_hw.h b/drivers/net/ethernet/freescale/enetc/enetc4_hw.h index 26b220677448..cdde8e93a73c 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc4_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc4_hw.h @@ -12,6 +12,28 @@ #define NXP_ENETC_VENDOR_ID 0x1131 #define NXP_ENETC_PF_DEV_ID 0xe101 +/**********************Station interface registers************************/ +/* Station interface LSO segmentation flag mask register 0/1 */ +#define ENETC4_SILSOSFMR0 0x1300 +#define SILSOSFMR0_TCP_MID_SEG GENMASK(27, 16) +#define SILSOSFMR0_TCP_1ST_SEG GENMASK(11, 0) +#define SILSOSFMR0_VAL_SET(first, mid) ((((mid) << 16) & SILSOSFMR0_TCP_MID_SEG) | \ + ((first) & SILSOSFMR0_TCP_1ST_SEG)) + +#define ENETC4_SILSOSFMR1 0x1304 +#define SILSOSFMR1_TCP_LAST_SEG GENMASK(11, 0) +#define TCP_FLAGS_FIN BIT(0) +#define TCP_FLAGS_SYN BIT(1) +#define TCP_FLAGS_RST BIT(2) +#define TCP_FLAGS_PSH BIT(3) +#define TCP_FLAGS_ACK BIT(4) +#define TCP_FLAGS_URG BIT(5) +#define TCP_FLAGS_ECE BIT(6) +#define TCP_FLAGS_CWR BIT(7) +#define TCP_FLAGS_NS BIT(8) +/* According to tso_build_hdr(), clear all special flags for not last packet. */ +#define TCP_NL_SEG_FLAGS_DMASK (TCP_FLAGS_FIN | TCP_FLAGS_RST | TCP_FLAGS_PSH) + /***************************ENETC port registers**************************/ #define ENETC4_ECAPR0 0x0 #define ECAPR0_RFS BIT(2) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 590b1412fadf..34a3e8f1496e 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -28,6 +28,8 @@ #define ENETC_SIPCAPR0_QBV BIT(4) #define ENETC_SIPCAPR0_QBU BIT(3) #define ENETC_SIPCAPR0_RFS BIT(2) +#define ENETC_SIPCAPR0_LSO BIT(1) +#define ENETC_SIPCAPR0_RSC BIT(0) #define ENETC_SIPCAPR1 0x24 #define ENETC_SITGTGR 0x30 #define ENETC_SIRBGCR 0x38 @@ -554,7 +556,10 @@ static inline u64 _enetc_rd_reg64_wa(void __iomem *reg) union enetc_tx_bd { struct { __le64 addr; - __le16 buf_len; + union { + __le16 buf_len; + __le16 hdr_len; /* For LSO, ENETC 4.1 and later */ + }; __le16 frm_len; union { struct { @@ -574,13 +579,16 @@ union enetc_tx_bd { __le32 tstamp; __le16 tpid; __le16 vid; - u8 reserved[6]; + __le16 lso_sg_size; /* For ENETC 4.1 and later */ + __le16 frm_len_ext; /* For ENETC 4.1 and later */ + u8 reserved[2]; u8 e_flags; u8 flags; } ext; /* Tx BD extension */ struct { __le32 tstamp; - u8 reserved[10]; + u8 reserved[8]; + __le16 lso_err_count; /* For ENETC 4.1 and later */ u8 status; u8 flags; } wb; /* writeback descriptor */ @@ -589,6 +597,7 @@ union enetc_tx_bd { enum enetc_txbd_flags { ENETC_TXBD_FLAGS_L4CS = BIT(0), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TSE = BIT(1), + ENETC_TXBD_FLAGS_LSO = BIT(1), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_W = BIT(2), ENETC_TXBD_FLAGS_CSUM_LSO = BIT(3), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TXSTART = BIT(4), diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 2c4c6af672e7..82a67356abe4 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -126,6 +126,9 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, if (si->drvdata->tx_csum) priv->active_offloads |= ENETC_F_TXCSUM; + if (si->hw_features & ENETC_SI_F_LSO) + priv->active_offloads |= ENETC_F_LSO; + /* TODO: currently, i.MX95 ENETC driver does not support advanced features */ if (!is_enetc_rev1(si)) { ndev->hw_features &= ~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK); From patchwork Tue Nov 12 09:14:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13871975 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2085.outbound.protection.outlook.com [40.107.249.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45E8C2123F7; Tue, 12 Nov 2024 09:30:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731403842; cv=fail; b=i6/E7LEp3HHfsg+tE0Bc+lF1sT1rAHl9cJgkpZN5bsR/kFV5XJ+nP8aWtSJxB7EjDzFrNB8w6+0Wseua7Gd9wiJFzdbsVfNmhz3BoTpjwb9F/tH+QYHK5aHuP29a6yL9RXBGjcZx/+K7qDbw1tPHWP7a7Tkzp7hKca70bRcdqKA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731403842; c=relaxed/simple; bh=X4d44crqkMfxyx6J/7WtVEOEq5iFvpaqo8i0V2Yzkko=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=USzzD73ehlrK5/sdNwRneqrHAEBc2RLeZikrRtWw0F3aaLP1BVrJwdgD1K8C2aFa0zT2BWXWj44sTS0AopZl7kxYc0kJ2klYGkQKB6fMi74BqsLfb7JBARN8JCm4oYFmxLBCNo37zfhV22NC38Jwm3xcdPbWDXayEeUVmd6IWec= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=gCI8hVAq; arc=fail smtp.client-ip=40.107.249.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="gCI8hVAq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EQQ/D9mSLLdsF2cKHa7hjopADXk3nUY5l6pokggLH2nlPMrCNeZFpLzS8tuwmf9mXwz0akiBy2Ns/C9qm7Lsn5m/Mt4Fivx0snIfjIm7+4u7XdqSnrPmKZZ4dXPSFtsDekv1lhMA3/fDK/cv9ZJgutoDxExLzYL2ZJEaQMoik/CKf4a8Sx51Es4t3PiGbuabALb7mIu7tkIOM9tW7oIV+zMhCj3ovhSpIvSqbmI/DGPq83jeS+3hY60p8p1xCioR0+HEGIIU1pDq6wAJwSrMTjF5Yba4mKz/iXuj4Av6H9q2h89XWf8qQ8/igy7mMJOIe9jHvPpFxMmRcNxzN8mSFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/ssm4zWHRK1/jOivf8RW//M1jW4WvovXFyRb6moy2Wg=; b=PUNGMvEBqNPuCxMMErUPbTMLsXLZcAO5WkxB1iSjfXrn2+4Tgery0ddJUZYDcTBO03axkUZFA5nBGSiPXTiscPFRzOvI2AEBsJPe7u3r4EpZOLaYOy++DFwbTEIdqcNEVuKEeqjeJa4V8nDTWwZxxoIUVNdBGvERvYf3bL+OiJNNQ2LMrXXKPkDwM+ItqI8imS9stdV40onVVbve7Iqy3X3+1PDhlxtP/2PouBGUQC3u2ZXRyyGE7MF0Y8d9995is9SXvGohmQFiiddBjMfdHo+VenwOj/Mb9BdbVJkZ4RCEc+XgYu03IzMt74QaU3d5zemPj9XYq/R9aIeGhxgBTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/ssm4zWHRK1/jOivf8RW//M1jW4WvovXFyRb6moy2Wg=; b=gCI8hVAqUnpLeMXGHBQmtp87St8y4LWafAp3oWL/irguOPzm7k5xltEiQgrfm+MHm/M35zvq0oOl0o237tLiX6pHJaMdiSgYTnV7UVqVYnM6tHpAE2NzdlN3fXAYaPu9iisDOMJTlfF/ka4YVobhoGck28OT3mpLsJ23vrxopOVlJlh8NqNw4Ic74rAJRDTJ6C8/OxocKf/F5mrC8lzuHCyLWrW/x7KCnORVCUxIV3AnDqbQoJuswvGVmXWBDm1uhoElePvVqNUfHRUIwVeGjwOPn8XssxhZecYPMzzXrokJySpOeYGQzTWkKtd4Xi80y4t3B8H08dddXYq1Uqt4uw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by PR3PR04MB7339.eurprd04.prod.outlook.com (2603:10a6:102:8b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Tue, 12 Nov 2024 09:30:37 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%7]) with mapi id 15.20.8137.027; Tue, 12 Nov 2024 09:30:37 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, frank.li@nxp.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v3 net-next 5/5] net: enetc: add UDP segmentation offload support Date: Tue, 12 Nov 2024 17:14:47 +0800 Message-Id: <20241112091447.1850899-6-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112091447.1850899-1-wei.fang@nxp.com> References: <20241112091447.1850899-1-wei.fang@nxp.com> X-ClientProxiedBy: SI2PR01CA0041.apcprd01.prod.exchangelabs.com (2603:1096:4:193::15) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|PR3PR04MB7339:EE_ X-MS-Office365-Filtering-Correlation-Id: b783455f-ded6-4e71-7e56-08dd02fcaa6c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|366016|376014|38350700014; X-Microsoft-Antispam-Message-Info: pn3p11h2rmTG6p1emVmA3xNKJfBKBvpLXsy9oXpq8iwZcEKDITxpYg7bT478fL7FKiO3d1FRP7jMAf4+N2yaqkiGu3b/0debhHITuX/BqI1AIhn5uWhGpaIosfKhCTyHh8Mzp5IUrVEMv2mit+QBHHPg4tytCIRwSaMMG0vumimrwJZuUtcEiULAA5y04VEELvwi/qSRWk1zRpIbfsLzJGu3DKzxWz9AFNKwxGs+qYHjbUDnkOeLwCNh800ouQSh+DJxKW0D6G9lr1g5saZQ9UVMviOCTj010JaWEhBH4ZseD9FAem3B7MylptHrf4eNoFWK5GvBD+1mbQeGs2VYb19L0v+e+BYN9YQJ45rzPDDgQBLj5+QI2S1dTKKVLbqzIxFw0NezeQZAioTC6DQrraQappjAMOW58+NI0gSkqB7sNTk6JyWuoz+G6NF0ngUEzivL/ObwGjPevu27BM5s7PfGDEtkwT1e4STjeggX449+fuhxZMgmf8uRtDkXUCLGq/dTb5rLbka3+vjxDIVeElbGjze1NLDR2pLaYbE38Soci/T9rn7w/PaHctwEb3WnP3ouP0p99fO4j4ngbGngJ2ZWM1pAqf5I6g7Z/INsprCPTozUr0gWof88IFFKQPo5hcilfwgPz3EX2IgO+7Jxt/cNs5acOiOHYxeuIxJd3NWJKnKODhVsPSoofZqmHJzVRGq9Z0coLX8OH8btYnn0JpKiutjTZbaVrCjphED+Z16NSTM5BR3LnvPk4OzXq9Uqd7PRK+MP2k8cZKKmpRLzASI3KMeiG08hZgwpkgVDUXEOXbcfHuyUUKSXDW2PgGSvYkM21jpiO1a2+yDBoTjrharM77bSqhSchraRP4BNxDAldKCSopTJ6dSxAXLNSCcBcwDHjdX7N6H31edYwiKzvL4rnki6xhCgrhjH8llEuWWbl+wC3V6mWssfK0ZAktG9Jnw78PNjIvmrqtEMP+Q6goCgTY4o2GLQsga6ohgzyUO7L4o07LnwPXX/30GAV8iS8BKxGdgVLt+Y2WYGGB03zfyg4ymPdmmZ8GwD//54U84NIAURdVMHZG/YiE3nKfQytBrvNo58ctc2ldbbWN7t53r0VYa3pPWP8sgkfcNfLI3DYSUQGXDPMFy6JHa+CzeSWTfxNaYe94MhNAqrL1CXVH1QBPjONn10jV+d/2RqyLWfyBuTWRKE3smglLbFpNpBLT14piESFm2qPeSZ8JI6+mNSJHyYfoDxRpiok2dATRHpSmzXOvUeJVi0+JIOb0XcQoAerveY5XEXd6uUFUtNOke87JvOZR4bdL/YRR6JfP04OX3iylTFWCZ9FFshUkizr1VjjfU0NwJYhv1C0FDe2ANh9yvuU8+4E4Obpnz5yHI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(366016)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0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1a4o5tDCcbzOBgWCSs6NPG2qpneEfzEkD2eQ5mB8t2AXt7CgVo9/n6YOpWcBz/cLjdqC9b90HDZHesP3Gfg5+MRyIPDYJBkdQKuc3+wkQaj7vLGK4SlEUm8TpXvDmlqJxKX+bnvnyhPkLaJc6ZN+QFJWR+s6W2N9P/X+TlqDtLBO+z9whjAwcculw7eMl1ITl8mqBCH76mS30GrfWgPjmw7oIdzJ+i80/ueBb6xaImYt9DCZ398P4h6Otpvu8RNEEvlUee8Cew6hOPg/bqi3NqMhJCB+JHGkNqiqeo28B7OVDf6q8cbQgQc3vyZoP1SNisiV8gipt/An0vU8kHLDdHSiuyORryJVRVRjO7pwXW0l6uNRB+eHmZYyF2FEh1i4GTd8bH0j1tfg/EKH9SgNiGrPlyeLS9iPPOtegjR5xVkklM9jODhYIyIW0bf/ujaYpXWTyCPnpezld+vUrErtCPAJJjXySnIZuM9Uq9A5uBvl7ER0Uo0lxLL9aXmwuo/BUWGc/0UpNsGK8n0bU86j/G2 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b783455f-ded6-4e71-7e56-08dd02fcaa6c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2024 09:30:37.2783 (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: iZpQV9A/f0ieHFfhGB+wXYKQvaf62pkPF/CuRgVYZvuzxJVnCgD3jvjrteXzwxmDvdNVOOLJcCa3+GThVtpt+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR04MB7339 X-Patchwork-Delegate: kuba@kernel.org Set NETIF_F_GSO_UDP_L4 bit of hw_features and features because i.MX95 enetc and LS1028A driver implements UDP segmenation. - i.MX95 ENETC supports UDP segmentation via LSO. - LS1028A ENETC supports UDP segmenation since the commit 3d5b459ba0e3 ("net: tso: add UDP segmentation support"). Signed-off-by: Wei Fang Reviewed-by: Frank Li --- v2: rephrase the commit message v3: no changes --- drivers/net/ethernet/freescale/enetc/enetc_pf_common.c | 6 ++++-- drivers/net/ethernet/freescale/enetc/enetc_vf.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 82a67356abe4..76fc3c6fdec1 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -110,11 +110,13 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK | - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | + NETIF_F_GSO_UDP_L4; ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | + NETIF_F_GSO_UDP_L4; ndev->vlan_features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c index 052833acd220..ba71c04994c4 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c @@ -138,11 +138,13 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev, ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | + NETIF_F_GSO_UDP_L4; ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | + NETIF_F_GSO_UDP_L4; ndev->vlan_features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6;