From patchwork Fri Dec 13 02:17:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13906383 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2083.outbound.protection.outlook.com [40.107.21.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B33C8768FD for ; Fri, 13 Dec 2024 02:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734057218; cv=fail; b=tCdN+ZWB393WVx4do89w/1g7NE6ySm6hOVGvWi5vb1pRO2XSSEIOc0zk/6fdK43cmAREticUOmHZl4to5ROvpxqcltC1cFneTaIhLth9K5BOFYozp7Udgur5gKGuX04ph7vXMmX1hYnRZuX3AqOQRrQOZbUWl/TZZXLdnd6DSp0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734057218; c=relaxed/simple; bh=FRq6qJfnftitbD4zveSJsSl374wdcbmj71lcXik427E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=uxJjlW8XDwAYNK9EE4trs3x5DJNj0l5dd3lJxLJVlbSD/WZg+aRwZRfKiPPwrRL0ra5vwBkyEyiv5Fu0Elj8i8KSyBb8Nsd9X6DYulouDhjhmkpeMtGbsAQo6A8aZtjBQoNg36V9sBxhSkyjMi46eXE813c5Vys27lT0Dq8OYiE= 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=GAtegVUs; arc=fail smtp.client-ip=40.107.21.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="GAtegVUs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PTpRZS4ExmrLltBBPmFJARXB584f5PdMwVCWtFZt44TwTOKxWF1LaWVJ+fmXj9VnaYBlpIfQ4gSVHh0qmP5wc+sFTDqIxCVqZYRqnaEt5C+W5KYLpaVWNFjO45Cv3j3JmGawwQdYX4kHaRXE2QBKP/caJ/w8RYxzgywuqIAqWDVmFpPv7MGjLYej7jdEF44Iw3Tz+R1dS+AWM/hpguFqxyRRP7nse/rE0nxVea+Vy7jNKS1cgjJ6e+iz78otqsuGXXiSvpIi5bmfmiqFAU2HQavtqVJOrq9rD1PybhU2lW1Xr6hoPuF1nEKl2Umhz68/HqOlZxhWgfaUjG/QgHAUBQ== 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=kcTP2IfOb4WxJx/2wEYbAgYHhqYPZF4IQVcnYZwx/F4=; b=onXOjKJeaX8k8GmZPPtVjwt3xJMfvEA6+gVpRCYfaKfXT5wtaZUIjlF7tvFG3BU7UrTnE6jU74jJ8JbJuuoy2wXe4eQ/WG1/gonZdelUvKQ2CHz5Ih37aYJGmcVOCsvSy9bm9Wcl4Ekul+T3DLqDVlW/klHZXpy98fQ+G5OlPx9pe2DQQ/LCO+o2Lqs8AI0wgsz66iRuTAtXfJMMDROAeevP3eDpIVKMnQe8B329HYsbKyE6amkjxB/JxYwFFuA1R6l+dzvuQQOPZTSq+8ObcwNl+YmvVbsWiC2hQXqC6MTTjaCeNWOtN8JLeT1c0WHiWTSFI/Q3/k+5AWbT6znYvw== 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=kcTP2IfOb4WxJx/2wEYbAgYHhqYPZF4IQVcnYZwx/F4=; b=GAtegVUs6OUXh9HnrDlJRTzQkQalxxIJNEMnUcpOVENC3VxXv58HdOGy7Z+ZmvFaTriU16GQum53IyK7PSr6o9uj84XNbm46u1Tvtbu0Oe/F8OQSJUviEwI6b/Y9vD+8X09rxy+AHunjZUpz6A5THLRzcLF5Xu7PWWLg4runKeWWKZke+9y5gjoc+H2uAEXJS3atfKoP/pXdSQ5OzLpXVrws73+p8B3sGFu60NenLyLSvAS21s2jOsCprnfGwD0RcN7nbiJLfVaVsvG7AAt6Ffh/GgqqJztU5SoK3eXaJPwWXZY+jpKRsO0Grxpooc4DBcxvWeDvMN+2CRDUpWLbjQ== 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 DB8PR04MB7114.eurprd04.prod.outlook.com (2603:10a6:10:fe::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Fri, 13 Dec 2024 02:33: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%6]) with mapi id 15.20.8251.015; Fri, 13 Dec 2024 02:33:32 +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, horms@kernel.org, idosch@idosch.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v8 net-next 1/4] net: enetc: add Tx checksum offload for i.MX95 ENETC Date: Fri, 13 Dec 2024 10:17:28 +0800 Message-Id: <20241213021731.1157535-2-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241213021731.1157535-1-wei.fang@nxp.com> References: <20241213021731.1157535-1-wei.fang@nxp.com> X-ClientProxiedBy: SI2PR01CA0014.apcprd01.prod.exchangelabs.com (2603:1096:4:191::17) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB8PR04MB7114:EE_ X-MS-Office365-Filtering-Correlation-Id: 7953b6e4-4478-4985-3ccc-08dd1b1e8987 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|52116014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: DbsC/SMMy0eWhDYY9Y2xzxR+/h3pYmkuNXnkidqbWcr7feuRCMp3q71bGv2QhI0KJR+WYKV5/I7Eio8uh3vAbAt5viSlMBZGsHwAJdEQ+v4+RGVmv9UBAaaEdxssxdcReBzYltl6drAKpbsBUUTUNgiZXdR1NdO15L8IupT2+CIXySWLw8CPULhQzGGWqdLMkBuniFwHA6tpUMmAqDFfS/Psw0U0p7C+8DyBGvCqja2VaW5yRrOHRmY1OZBKTbnnvfgbrEgzsPeLvOdNgrQJTz40MwOPPrYeg7oy4G+A46ICTkzASytakUohInzJUk8FLm72vDd+3p+1Zw0HI+GnZCpADcO8U/Rp6++dd900RK5ss8VydYdzgxCGoD+tMRVKr76gnxG7QHAeTD+/bu4HZd1HEx5xP99Gkupl0qe1UhbrTPl2KBZ1X/sYgbgnckLlJbnB/X0qlA3itHpTJ5oD+VENP/uWRwsAozPsD43gaIMP3PHg1nKslgBwueO4SG0UQCDvvXRYlL+om0zRKKREPfryDvAPV6ZujrelzsNMZ24aX7WqBVGtjZBIOGi0PFVoKTYCZhXxx0NSYlVoJ0reZOIwG9c9vqFfmDWuyTBqHOoRedVbLNd1V7iwUVzFsDrsvmvudSZDctEA01+sn0ZFn6UMgRBh6YZgZpTpFR/mxH+7LawMe/DYEoyZZ6vs6hBHT0ZtgaYdED7SAW4EnMRUz4HvXk0IC+WtKsYm3G+J8pbM+p/tzsAXZRdrYhdf8cjLxbxqxlATZNtr1GaJnEr0wv/0wbHaexosFQ2T1xY+cXQBvbtyqsNYfLgrBz9f5nKW8fbNM4VDX0BGYU8NW+vN68M6i8AvaHkmRyvGqEmGXvOD3zKAsJQnGg8eNOXGNNnrF7Fcb1TXSOL+iMQwnFm9hpSCSWnR2btifUGshhj1jawouLxg41PytmYbC8SGN5b+7g3GoEZ2crPOFtUIUCWStBB5RU17H9bLtI6yO3H+r/L2ZtCGc6j9utQTXVjrTN15VgdCyFwQJpXR1bSlEolQemWHjccGJHTTZfb+AXaPSg1MDm7V5yA/qEwZ32eiTM4EHF8ezuqBIehT5Mo84VcTrb4rckYXHuMpGHzwe5jXv+uR/kwEUr2IQacrwRVP00AxCXcVDkaM4s0WqGNdvYCQsogCZ5HQqmf0uNvSHS0Oyi1qXM7h5bX514b2vwzHXJKT+9nZP4WSSqNCe+lkzElF9naFthqzrV16u6XXAJUYOHGFCTVMo9I91/iChc8xGbqcIrq/8Q6+ldYuDpdWhhci0pw87avPhmRyCRisHgFNWC3w/875M1as93ZyavUwgMwR7CBV6z/M78+D9IKezMLRmR7NLSvQEEq7S8BgG7kJLFkoUG2MYB54pHvWYBNMu73lN5AShVCb/7xEPoBiCSaY5uE7hmeLHYu9f/GSzI5iPmw= 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)(376014)(7416014)(52116014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: W1hb0YukuDGD0bvqsCmsk7pFn4hiKbXj2AAmJS/uJCSTeUkRryvTtLorBTP22YGwUpx9qunJf9jzN0Oa6qWJTyXnBrjVAd0Ai6DU2sY5x7caIpKTxis11VjygAzLNXBP/cs7EVm5v68eZTLa3/cRWJDtfV+rxYRSm74fM26S00dDPKBzd5Dv2xSOd1dVXBxwlcDzIHUqnviziW7TE/k+ZQ3Z4vZpTpAFBJpb5p7ZObRHg7ajHfGHCHmo1ritlrhv3rHm1sNW3bzmOJKQgnCdpO6MsyaOn2Z+gJTxKpXN+ZpA02HE4RtdAC7ZkN1T5WgeCGsPsDsNJHRIN6jOwMYwfELLSTT2DE1BV0opjnSF3Q0f01ijvjqw7TXABsehwRwBVzWu3gVensE/XVa7l58X2/LRd5WyxgSqt31KlwcYIwDCrZIbM2NTZJCZjCNiyScg9fEIE2P/5UHh6lx98Macvt3VzdHi3G5JcrHyWIyJ02Wqho2jphO0UrVyrMe57fVUfghNZRg5DUrusiBuagCrXcmHqyaObUr/X3J2khArQ9zpTqt2Of4/IOBWyFmR7BUtykcGvLLLXDfLoW4dCRysqB6fH7c9tT8SMDvJ8mLa05hCNY/FrZrSXaQ+w/Dojy4grbHLsUjH88bsAEMI23jmRz5AvNbAlyvmx63a7GYYb85QEH+SE+4qLeAtutmuXpp3ivKcLcBt+yFj/C6AELPSSgn854WPmd7AgRm7NHJUkOj4o8XUcLcbg7e0UewaB7j7e1Xz7924VAp9kMig3kGCQ/xjwGGEUhkXGLBfKYFh2eV5Z2XcyJTTUxt958RmJcWgB6Q7P8mJ1ScRauGsolXWRK1k78gC3CeC3HfvOVGDbxAWXTALwBqKqgT3xSU3Kp1euyamwFjtJex7U9Z51tQojC/d597LdYaTwZwtanuYvedaItWlD8TycTv9OohTW6CgEdd0aVCJBBChAmBaer2UMPbRZEG9GULgzYpp4SBJIvTZWrw2ysXQjVl526rxmJndPEyUB7FdjuEkeRlFEqgNe4rgIcdLQdbdkXLi1wdpL2dspIwawdTyviMCCoRs6sis53so3OWRH9vLJXhcgLoleVtj2BioXcvjx3J22L7hOYRprK0zx6uGNxcscQVLqyL95cCc34H44JxqzuuqwJ+NzqSIAMVNLaagi2YX3hg9SOq6aho+jDl8YGUAQZbHXI2b8CbWjG/vYPjDJs6DxG/GgH0C5oz422vFSqOK8e6eDLAKe6xSMEBs0o9zOxtE/B2jw3FniTNL6XR+TxmYpGYKkXiTB0+iIhT1sCNtL0ILaeT/92Yv+wnqfNW0o7aONEl97+Op7GmVpg2HJLEkOnBhTn+UIAEDZ1w32OVH+h2EzvNXI3YpFt1YE9Hb1ZFMTML3NqpKt7xFDUh0Y6etO7dVdwlikCkvbiExpY689At5bLEKsR+fuKXV/54flUqcto81FVmKDVabVnaB7T9/Fl7oeY/dSHJCVUuAGGhyjKYz3w9K1KdQFoo7YU94sTFNeVmpulipaz8S1ZaxDSjDFjERf+dQ5sBXWo1S1XYsXgxMwPM3duwggDKQnPcpIWJtlQ6b X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7953b6e4-4478-4985-3ccc-08dd1b1e8987 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2024 02:33:32.8996 (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: 1gGIz+MmVHGUI7LSRmnhXmGpNVeKHwysx9aBF6cO/EJuyxPTJf3m4rfkhwMUBT0/E9mEDHF+ii1WL+aw4WayXw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7114 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 v4: no changes v5: 1. remove 'inline' from enetc_skb_is_ipv6() and enetc_skb_is_tcp(). 2. temp_bd.ipcs is no need to be set due to Linux always aclculates the IPv4 checksum, so remove it. 3. simplify the setting of temp_bd.l3t. 4. remove the error log from the datapath v6: no changes v7: 1. Change the layout of enetc_tx_bd to fix the issue on big-endian hosts. 2. Rebase the patch due to remove the Rx checksum offload patch from v6. v8: no changes --- drivers/net/ethernet/freescale/enetc/enetc.c | 54 ++++++++++++++++--- drivers/net/ethernet/freescale/enetc/enetc.h | 2 + .../net/ethernet/freescale/enetc/enetc_hw.h | 15 ++++-- .../freescale/enetc/enetc_pf_common.c | 3 ++ 4 files changed, 64 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 535969fa0fdb..b8ac680e46bd 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -146,6 +146,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 bool enetc_skb_is_ipv6(struct sk_buff *skb) +{ + return vlan_get_protocol(skb) == htons(ETH_P_IPV6); +} + +static 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; @@ -163,6 +184,30 @@ 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_aux0 = FIELD_PREP(ENETC_TX_BD_L3_START, + skb_network_offset(skb)); + temp_bd.l3_aux1 = FIELD_PREP(ENETC_TX_BD_L3_HDR_LEN, + skb_network_header_len(skb) / 4); + temp_bd.l3_aux1 |= FIELD_PREP(ENETC_TX_BD_L3T, + enetc_skb_is_ipv6(skb)); + if (enetc_skb_is_tcp(skb)) + temp_bd.l4_aux = FIELD_PREP(ENETC_TX_BD_L4T, + ENETC_TXBD_L4T_TCP); + else + temp_bd.l4_aux = FIELD_PREP(ENETC_TX_BD_L4T, + ENETC_TXBD_L4T_UDP); + flags |= ENETC_TXBD_FLAGS_CSUM_LSO | ENETC_TXBD_FLAGS_L4CS; + } else { + if (skb_checksum_help(skb)) + return 0; + } + } + i = tx_ring->next_to_use; txbd = ENETC_TXBD(*tx_ring, i); prefetchw(txbd); @@ -173,7 +218,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; @@ -594,7 +638,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) { @@ -627,11 +671,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(); @@ -3274,6 +3313,7 @@ static const struct enetc_drvdata enetc_pf_data = { static const struct enetc_drvdata enetc4_pf_data = { .sysclk_freq = ENETC_CLK_333M, + .tx_csum = 1, .pmac_offset = ENETC4_PMAC_OFFSET, .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..e82eb9a9137c 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 tx_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_TXCSUM = 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 55ba949230ff..0e259baf36ee 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -558,7 +558,16 @@ union enetc_tx_bd { __le16 frm_len; union { struct { - u8 reserved[3]; + u8 l3_aux0; +#define ENETC_TX_BD_L3_START GENMASK(6, 0) +#define ENETC_TX_BD_IPCS BIT(7) + u8 l3_aux1; +#define ENETC_TX_BD_L3_HDR_LEN GENMASK(6, 0) +#define ENETC_TX_BD_L3T BIT(7) + u8 l4_aux; +#define ENETC_TX_BD_L4T GENMASK(7, 5) +#define ENETC_TXBD_L4T_UDP 1 +#define ENETC_TXBD_L4T_TCP 2 u8 flags; }; /* default layout */ __le32 txstart; @@ -582,10 +591,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) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 0eecfc833164..09f2d7ec44eb 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->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 Fri Dec 13 02:17:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13906384 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2065.outbound.protection.outlook.com [40.107.22.65]) (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 4C09054769 for ; Fri, 13 Dec 2024 02:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734057222; cv=fail; b=Co+CqFcgTRp2TXKxxWWMMfACRIQUc18GkoBak1SQTmfvohG0q8OlJwbGqcb4GkDIK/2GWzidw3hrRV8aRLnm+oH4LwjBVP1LIZ67UClCFEaWqWYGthQT4cUz3bAfMx+ofWz3tW4Rzxszz+b15QoVUyyFu3Z3hKNnqdK1WtvRmbk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734057222; c=relaxed/simple; bh=JcmjQmXYClNk+/LZkkQoOlCYvSTkEKkBFqR9yBlihg4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pqmXemPYJaaqcuEir9c3zmjQ1mi6os24Rq0ZaaWnCavl1wsf3wFFJSANJGw88bfx3emsa9W9BPudxeUH0VSOH6RRosbzqSmqG5vHA1lrS/zN1gVbKt+snGs/gFI6tbnyzIWLsSCJ3QsYZXalQQgiJXI7dkdfJHtF/EAoiET20OI= 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=YcQNEZk/; arc=fail smtp.client-ip=40.107.22.65 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="YcQNEZk/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Xrsiw3Si7pyX6NWJfBuyq/Z7DRt5i5LUJnLAw8KNcxAz0jmqqQToURMmu88fx2sO0v5gwbzbieh8Zy6ddgWyn63AOe/plX7cVKhW4BDScSbBSGo7S2WsvPChW+Tc7ckUX/myvvKB/JN1gpbJ/es5qZk2zy/yd9b26PYwNJ5iaj22jwTwGpNdCQw/FRjyQ43Iq4U8uhUSaWHWxV98iVw/kPiurWStpp7HG1wz4BCTKgIdEKaIaKBtCqaJWXbNZev6tMA3P6a14QKgOUhsH6T67oDtMyz7OD9wxalpZsyrGIJl7x5XuhR24r/h405MTyhwiyCTEPHe57Jwtvphkttl5g== 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=PQwdi+hBf8UlmY5O1W3DFR1o2r1aUrjTHTjBIo2nY7s=; b=xII5HBiHctPmbiRHy4rjF0IsEPiwqaVgz+obObUxwRjL3tDXmTE4Ma0PXw3oAGE5TrxspYB4mWc1a5EiFmsiuxQGLKTXwPKWQHGBYuWHPCs5EDuW0iZ6Od9xXTLXa6ErZlcFwf5/+SoJRnvDeCOhHNNpgkdzE3JCLCldRrznh6MgkK1JlBhpwrUq8xKCk4Gt3exUZVl+zKzcsDLGtWoIwn0hntt2nhZ9ijmwzZnOK+ChEUEG1QPCBONNNQjNLSCQLrt4LICd4ENtGrgzY4OXbX47jViHF6NpnGHStZISYpqU08a+bVMISv5KVFgyR9Anv9EZh7SaJmvIdP8peJa2LA== 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=PQwdi+hBf8UlmY5O1W3DFR1o2r1aUrjTHTjBIo2nY7s=; b=YcQNEZk/4B52TsI8eVrZcgAh9tI1EiVE/fa/MwmEM0HtdJepSc6oP6y7VMRoDTcZ+yCPCZfaBwDZcdLslXkigvyabLA0qhT+Nye/VS+WeoGCVbCRlJCVa950g7GFwofKrkI+x/fBJ6Uw8sQbSoRPxNDWx2j7bqvmnuW3Jh4vLw7/UE95wuhwb5xfQS13AlrvpSkBhdNBNZnyoag9hakyiIU6csWRpERS/fsfvtH5I8MTRaMcz+lOfdApxOcb560lOEXfq2C4RoYzX12TYsMrRAaqHWnsK2lc6Am+lcaTyenNxjo8lTlsPT0slLhBL0f1w5+kQXsWgbIibyBaIQuZBA== 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 DB8PR04MB7114.eurprd04.prod.outlook.com (2603:10a6:10:fe::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Fri, 13 Dec 2024 02:33: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%6]) with mapi id 15.20.8251.015; Fri, 13 Dec 2024 02:33: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, horms@kernel.org, idosch@idosch.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v8 net-next 2/4] net: enetc: update max chained Tx BD number for i.MX95 ENETC Date: Fri, 13 Dec 2024 10:17:29 +0800 Message-Id: <20241213021731.1157535-3-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241213021731.1157535-1-wei.fang@nxp.com> References: <20241213021731.1157535-1-wei.fang@nxp.com> X-ClientProxiedBy: SI2PR01CA0014.apcprd01.prod.exchangelabs.com (2603:1096:4:191::17) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB8PR04MB7114:EE_ X-MS-Office365-Filtering-Correlation-Id: 182bf4f9-276f-4fde-325b-08dd1b1e8c17 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|52116014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: k5ncF1VwbYf1PDG6atQmVC0pefhZuXlaQshVICXIOYiGXzebHWO60Yv6WR8PQAP2BP07mOrRFJwqod+Essyv1Rd2wL+jQuwP9Y4JXKzXBYqo+yiRL62EWlWZgpDB/Azo2wjtAOpWHbmakfnvFsi1mVIatoWklLVy3uRz/sJMtlyeoh4wwASdmbdj54aP6R9f9l6R1iw1mtpDRgTTJy+z7ul4A6FaV6uhk89saxhIUyWvGIjT20MMuy92FFkLv6pJOJZY7nvFvezuBgioEXXvZ2QeFY4bo0BiQ07yFbwsm9dBcoWZi3453u5acTViNiepKw4dwCxfpA6rCsMOrPSFPOYdkxAQ9YVyxHlpI0g1A3BERcp7iBceumrcu0FlwDfNsPlrQvDFIK5XLAT2HQoFcrChEdNimn+Ery7brE+uvTO442NSptJTEL5nRTkxRCBRySkX2zEA0XRfJij63XlGVXCa31z2PZNeJa6679L9EUG9BMKGfO79oK8vpLjalFTNL8MMMWrUpsQm9yv4n7J1+ljWrb31E3H4+bnuUuFlxsUbkQ51EC7JrX59qDRAkxjzxL3UKsj+sYPKD9zvtVvxekSOYyt6Gjp0ruCybf/ySkNFz9uuFesB7pB/PBdJBqbc8v5fERr43UnE+GwHzlbMdp8zJZHneoGhzQAnVdFcAzozSUZWYmVhzpAQ5YahYaoMG6WU+n8hgkZpE3QUM2iZmUuev7Fs9TnQoavSEVNqFMVytwi4jxMhq4bP7iNXhcFFHjssonN+3G9w0Az7GaWeJRj12uGcg6yrzNbaC+ZNIgcQqi5LhgCUH1CeIW2tUvOYzGgJZ8Xrit6yhjvkAceUMnpnqh4k0RT0svmTz0xCNc1qqJbQchCvMYyoCdV+kmIt07FHLyso3iQLnEVM+5pC1+FRYTw2BsaDZWn+lSFIqYEedySnAht+OHlEym3BiP+p74xgE8Wgizkw1ax6gL2WNhKxPnlFiuYHIMHLU86Eht0cshyrgguX9bGDK10Ag/vXZT0s+LDRVyKiaSHS9uW9BaUd1KQb3yzX+FI6FOZs4RPNmEy8kfuWMaI/rXgBa7oUOR2Y6Q1SbzDfr80O3mnilaSBbTAW+SioxHKE8TBi5natCo4/UKoQNJxWrTnl64frzqGcnXhe69JhyNpgp+ozVjIaYwxGcD4WHbQgyqPnvOi58kxhXVOvV9EBDkiX0zPymXyIjf406S5jwnKWSrMNHl0IazYntZ6FOfIpNCvrb3cHU6V1e4uJD4qEELNOqONpH3wgKh6Vg89zMf3dwOcBVf84BBI+eMKnXxDTu7sfAIX8a2jhRmyjuj9uYcGMOvv4A4ZrvMG7pD9ehh1CmYK/Rw4C/s9CCbLzr7KRcIUZ8RwbRkNfKsR1eFMKE8mWquXJcZQv1B/y6NJqSCIusq656TNk+KzrUk+CjcPZ59Ab2NI= 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)(376014)(7416014)(52116014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hYxmIAHiZeKgEcq9fBtRjXzRKMRXdb/vE/mUm+btq50CgkNAUYx3uZCabtf5hexwIuRK65/et/W39enj87oYPxTuuiV2RECYXvzF2ruoPXu3X4spyEIHqaaXHNdy9/i/QVK9iq7ZzdGB7v0MZkT1VyoM9y5CM2XtsJz2s2yAR57yVAChQALbxHb7EsGWNdSsz974tqw7zwUU2J3hO3iVwhr5fmJjTAhNMkRj5rp+gG8FARSrmsItCKADzC5R/b0jhcIj9v+4znZ3g+at8tydw9TLCZ2TsKup5CnofsveF2SE/H7DP8r0XiMDYOIMCGp/T0yyyz1BQZtP33iij6xwDeusoDfDsgjE4PsHrrWon/0sDsDqeUFejCF65Tn+GnGKn/Jh6gjc0gWogvc9vtji9Q0ISszQ4cS2sxHxE0vIz+RHQXhHKAtNAXhYLLAKEZTL2xXYP+YjgGFkmvN4yIcoc7m5pn7Qu7dmV2Si3le12vERzizjwTFNxDlh2Y6tVkkVwmABNo8BVpxwiB5KblSgacqmAwvAqZJwIB8QKHGSUAChhPDvPdk6vUaT6VM4bgmnPKUIMkgmBl809D0aF1L71Uw9OWgTz460fFMwzSkmtgrTcEhYBVzFa2ytRwt49rP+EK2mfZwPu5U4Qibj1xKMbO4oPW4E7lEfju2DjKoB1a6qrZEBALEjX+4de5JYktskJvT9OOFgyu/LZ4UQQN1U+JBjGC7x5ocS01Iuewx6JDrzvpgsUmN8SA2qjZCwn45PAhCx1KmQ4BehLhEi1zU3jnpx9Aa7sk7yGrklY26wrBXNlS5pbBn7Yf5RD55FHdYW21Bod5Xj9E4wACGNpCQZ6OcXlsDD4EsoK3h77DJjLZYwqhWOihWElWFsS1mk0/4btJSkk+iWvrdOy+4b+T+lDITotN2KqPiuwgl+2/P3pLoGYKbyqRkJwR7R5Fu0rWHbqJXCw8Ov6bc93OgI/msBC5VEZa2S7H9XQ1xDPEr4xL4aTuEyJGFxiu2419+IzfDVhS/WOniszJgHyRIXXCAHZRf5rOTdFcKJEmYiAa/LiZ7FRLv/mQYFG6gfKLa7c+Z84586Avy7rK5pQhOesC8/FvyBvbgoFpTWkBaX6/mbycRVtv/A++VORXsBtrBmqgOv+Q3x/dcs32V9kCA4bQxB+4D27FibTS7QltssQwbEixDHZnHaxCbWlMhsVn0mdZmyHjxJDEmOjS74xw6frPOb827zWBrF5dkR9/HtFEbyDyiB2yb/euDg/UlpUJr/HlFcAu6wLXqaLk2p7Kotcz5v/9qMSenHodsbqssinjgvi62IcD4AM3SjHzX4johj0DsoOqxy2wQBbdz+Nl81NlNjjVkkfHMXcNY3xmR7AHLr8gLWsnnHkKrVkIo5gBSHyhNHMXRJk13XKn34H8W7r+Rwi4+7ioG1oMMCh83hFZxNqHCGF0KKgInEVuBrv37pbL5umAoNt6+NZe/y5HUDINRAiVCvFYtzSHzT9IYXds6qyexJ7r7SMSPfKwXmxmYGeO1M6VI2Un16vITLjCdaBoA7Un6QBqsPmHlPPDrsPMlF3qPcTgedFSlC8ivNtb7KhfI6 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 182bf4f9-276f-4fde-325b-08dd1b1e8c17 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2024 02:33:37.2338 (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: Ctx97qrBTNa9bfcad3+4xMHvHmgdWYSq2SXPqjJbfftsTCicAVqOvhbRmPTV3kEeH9mzj2VDHzTzNX/PyZBiPQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7114 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 Reviewed-by: Simon Horman --- v2: 1. Refine the commit message 2. Add Reviewed-by tag v3 ~ v8: 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 b8ac680e46bd..09ca4223ff9d 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -535,6 +535,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; @@ -600,7 +601,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; } @@ -661,7 +662,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; @@ -679,7 +680,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; @@ -947,7 +948,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); } @@ -3308,18 +3310,21 @@ 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, }; static const struct enetc_drvdata enetc4_pf_data = { .sysclk_freq = ENETC_CLK_333M, .tx_csum = 1, + .max_frags = ENETC4_MAX_SKB_FRAGS, .pmac_offset = ENETC4_PMAC_OFFSET, .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 e82eb9a9137c..1e680f0f5123 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; @@ -235,6 +242,7 @@ enum enetc_errata { struct enetc_drvdata { u32 pmac_offset; /* Only valid for PSI which supports 802.1Qbu */ u8 tx_csum:1; + u8 max_frags; u64 sysclk_freq; const struct ethtool_ops *eth_ops; }; @@ -377,6 +385,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 09f2d7ec44eb..00b73a948746 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 a5f8ce576b6e..63d78b2b8670 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c @@ -136,6 +136,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 Fri Dec 13 02:17:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13906385 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2057.outbound.protection.outlook.com [40.107.20.57]) (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 C3212286A1 for ; Fri, 13 Dec 2024 02:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734057227; cv=fail; b=gUr/eS+NbYn8KRcCFWG/35BUJPJGM2l/komxiP8sRfb8ih3fXpduDyQPhKUD4ZNcu+h9aip5yBbASn8BjXFX0/+rAgchlR1HEMePI2BqixN+rpq/8t8gVqlCr79uwqjpNfna83iOz7Dc3ckRqacP0uJM9OSY0c2Gaz/yNPEFHFM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734057227; c=relaxed/simple; bh=txTfwK5asE5FysU+fSoi8matOakIXwMT0hwIZ7uO/kI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Uaok/xxXWRZFOqwCvpdR0SsoL7q+i7Fmgpp0lgEsymB+Gt5xu94RalBPjXtfX3XVKxx3B1g16fhiJrG0mycH8i641ebIbZOcngNFMNxo5w/uQCfEIL0BsQGNU1tplaShEL3Y7SIS33pamR27nmoY/GyvqnF5cYQK05X718Cctjw= 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=n0TdS2KH; arc=fail smtp.client-ip=40.107.20.57 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="n0TdS2KH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jEj4iwln5xo4RmpJAqPd4K6XdO2n2tdoauzccy3fuYdYrGBVap5PBLG/W3bCKiDLVkG3AKwywOVTcXbkaYuIYZtiBcqhHWy7pCdzEM6b5aEXvDQcQnShNwJmK09mL4Qdm87mVdnfAmkD4gj/7wrhtmi7OvsUc5WM32sHYYxt5NFfuhqy5YgutiHn9f5ysU+dTBufq098xORY/WeqI8K8nB2u98LGoiUpBRE26b1g216q0Y55+Uewi96WXrwmmhoo9FfD7WW/SgYJoxMH0N+yaHNXrF1Bw7OJQIQ36oP0NJT+6JeRlkMoBW14IDUGdHVFr5gq5k/FgxsvQdsugg7CVw== 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=7GA2PmR+U84cNn+YeuVg4t8q8e4u2fD9q8H6KRESw70=; b=oyQFrj96U2WtRFpwIM4GwbJuutLR1QYj/OAqv+ROGziPg+3Sxbgy+FtnRV18E5y/pMJnzCUQF3N9egvU2fcgUPBJOIy6HktIeBfrO8Zcff+0C2DGr8Ls9VI+4zRAoCdOwHNIX/+FnWQRKTvNb7WUjCpV7rbFNYq38Ad2BhVUvbfMSgugshNlRFN60OcB1OL9C4eg7iw04GqA1uWGrFzICxe2m0kg4rfZ6pkm5zkAcLZEbIHcpq89tTBLLeJKqQqSCjgNCZiLTfkGhbPXHrFmVIcAU01yDPx76aPQGQB/QTxHOTNqEztBSybVG/COwTml0BG/DQKtwlcj59WLuUSt1g== 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=7GA2PmR+U84cNn+YeuVg4t8q8e4u2fD9q8H6KRESw70=; b=n0TdS2KHE5TJ9aL9mev+QZRsiEHJtRD8C3pj/b0ou3e839lLAqdTCxUik4eIs/2T/XNv7EzC3vLa2vgbD7vtpIpWOJelIzK5q9l+Bwkg7no9owH0HbTWoPfoGN8LMC/qv4HixpQweUb+FmB56Cn9uTtzwYG2hVgHlka9D4d9vISQ0zAJJlSVQJn6sNJ7GYGOZwDNt3FlOVXBKE9mcvCVFSzPEPT8DUzOs3rZEQg/nZNnBjtoQ85jiWs/0OQwZHb0NWfjabc8tExZ32RG9TU00Q0b4wsRuUewR+DK32igeOrRNvXdJ4dL5DQOiTgDSTybqtO7Lg2X2gpPseKVrJmbNA== 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 DB8PR04MB7114.eurprd04.prod.outlook.com (2603:10a6:10:fe::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Fri, 13 Dec 2024 02:33:41 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8251.015; Fri, 13 Dec 2024 02:33:41 +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, horms@kernel.org, idosch@idosch.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v8 net-next 3/4] net: enetc: add LSO support for i.MX95 ENETC PF Date: Fri, 13 Dec 2024 10:17:30 +0800 Message-Id: <20241213021731.1157535-4-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241213021731.1157535-1-wei.fang@nxp.com> References: <20241213021731.1157535-1-wei.fang@nxp.com> X-ClientProxiedBy: SI2PR01CA0014.apcprd01.prod.exchangelabs.com (2603:1096:4:191::17) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB8PR04MB7114:EE_ X-MS-Office365-Filtering-Correlation-Id: ef3d8fab-1fc8-4c07-76e2-08dd1b1e8eb5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|52116014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: 5g5vbecJUx9H64C1eNO2IzvQshnYq2X//pkco1PtuFiWchDyMOcmhzc07lvWEikbCYMrQj3q/tijYpeo9SfzT6JSZknTwe84G7VrP3bRZeTv9vDHvNKRp0rmpbb39zxveGeWK1p8Xb9/gC8rpUHuHxP1YnkKH5CyGspGZOIFBfp1SpsC7NK5zwlE4YfIBg/YAauAB+rkDJnTA9Sxq83oFCw7bu+p8lxEInvyaLRP8+grtcEiHnvP42DZ/KKvGYwajcv6c0OEZoM/2xbuyQpnpwBn/R8JIExL5zIHgatbS77cmHMMILeNQp9fPyNTs9HdKrM1A/rSAsr7g/+W+12Ztw4ukvhO/VH4ZI6GJgYBN0o//AiaaulksvWjGmA0icCGWiQngI4O5zTXg27OA9SMxVS6Bz+/Itx5Zx9DibKp6k7p7KQd5cm8QmjTsOdvYAc0s2B753IOA8Dsa6qA1UWH4FHdUPV21EMfoirjEZ381i6cTSO7ZIHzb6OPr6YArv57Ro0Ae/bu304uMc0MeSxyuf14n4bwOwMXpM9rfQse3dVUN/PcsoxISy1MXvpOn2OAvYfsqv0QK7N4kYKeLW3h4HL0i81IQmxC7WANXcV77oUno8BcnQT6ZA0dTFeRV6FkIuSHByJJ2xAL9i9zY1kGwKcOqvLMblZpxXkqrAoJu3V0H4oZVfS8AwVT+E+EuoQ5nP6BgT3U4VIbfnjk1L3fyE17UDO5BjncpL94Y2V3NZRPUZeC2nvpiiq6xE4mBBAYlOIxUBPSAQCi+UTQ+xmOyBhEHYDG3Z1mV18OLwUuCAwQQaICjXePKIFxeO3SH2Ef/UZqVRhTips9Bz76Z/64DY/Q2K8p76kQeL+aJsDJK30kZs/xw3qQ7flcx6NYhuLcdPVPDHP2kFTdnAktXoHBxryYGweHzq+QCyRsB+M4SKS5tq4V7jLhD6D5Mz00ymYnWjMHrgUA0DebZP/kwJ8X46HSEMgswPP3xCBYpdi/NCgkOtEQm2piyms22+etpKZtUIU1MYAvYmQjNtstWw31HTfpocDvYgNlpvPsj4AOak7Q5i3FTCMHznELu030huiqvFNoFQrSjlok7Tp5Sl7PRcx1CRO+02DcRNKhAKuR1OWU526YRpnVpDqehRs/b9kGYASWd1Mh8v24uLft4aFbyTHWV+MEUdBXW3SCAYdR0/Nlh3FiZ6dijeaRCZktVFaiP16DaksGQ3GRIl9QhhO6FPjgH66zNzEwotW74AC+gl73R+IVh4KdYXJCXrgc8QzvOZBPoV/Yq29n7hLlJbUVp3b6YqpiTZx7FRr6Lru6IoYB1UYGZDAmhI4HK7gRFdy8+qFZDu1fk1Wil+d8HldQkvyQ3OybL0RgSrAsnE2a90l/r+OG4aYsHWb+TTk7G4IhsRRe71OQ60Nyki4WDYJ6D092iaUgEG1Z1noBcJuNodw= 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)(376014)(7416014)(52116014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 54bqwLWC9nPEMa4Vy0WNiboUMsVk5A66e0sQuNzK9p4zMKop6QWw33QzTuqkQsMi6bO0Ml+EZPAOrlJ6hjFYoGD2JojUJHCLnZLyvg47wStH/L4m64TkJNpkk9bTfFWpJeMfV2t1g/nM1B/xssBLNW4IFDg3aJdZcV0doyZQzPYcM3LsZZ4/D/ZmOKsHsupP2TRrgh6CFmnMTuT28AQMhYFsgpjPc/FdYgx01eDYsmM76oK7ABM5SMnVTBlv5518qTi6XBWI2ww71Yy3qqnNWHZ9laBdfPMqH5udyoqSeaV3XIZiYXCx3YQSZLEybEecT12WIuQWUoQex0icTXj9kuiBUIDwNqaqJ/f+SQ/TW4ynLppjNBq04JYU0McSS0PqITnd28XQBasHhZxnFHnKv0kWYmDClNuFHNSTAoS7HQYeGrKsYIYgI54d/iTSBMQGqiUzk3qIOiTBy9OSOpCNhYPecybhV1fjTbPd3UgMHKukOFX+gLmL06oqHuLiKMwbqQ+iTNrFPYtClrDPYAicGx0MlRxiuL/5Gc3gRw2jjDoTCU/uqEcTm/QbAtRftcQEeZ73DzDVnRblw9EMfHUd+eqkZIHB0S6kVvJTIo1zASPgWSrOCZKMyt4wHF0T13rmsn5lOX/Rg8jF3lO8F8bfpssIeKsHrM8SEx1ZFY1D40RVlz+enex6sHN/hO0odR0FAHz+HuxGV+s+ftBnVQLotRtfxen4YWAb9YdI3iyVA/URG1+niQENCuZ9v6LacWB90d+rWMPdC0Q+3D8qomNvinZg4tNWN4u37fzWfCTunAllesRpBgMVxMAcuYDtXLEBHVDiiIY5oea6sI2Qm3RBrKZHKvL5IR6h398tR1tPWVJqZoMXeYpjxwBw8Ax2NZCc7LGZ0F4y6Kcu318nGWkSki1DvFKr7nhNOivql/9MFTtjUZnpR4it2EWK8mk818LTrb3R1JJhkWu0d84x8gOGqN/NyoC9SIuLa86NlQfFY3xX5Kzt8xMV+VhOk+Fi0fFvB+m1f8eAXgxOHM1zqfEKK0YdZTvveQkBRec7EG0fVmnrxqLHiCFl7W1+gyy9L2tIhHkjqFWN9GYAmyvhcBYquPBRwVg7NI/BUTP44DRu5Cmq5VQb3bsYTz3UGsKAtbT5SJCuMkCWOt1w9Hn0nsAmUAhekERFhQpYK07FxShRtsgcVXQ+JldCNZTWNmGlVZzlY6+STwOArRfeR/GGqF8gwvNHOkWyP5YCVVPCyBZRfzxQL3NXKg1QFIBYE2QxIdMdqK92aq0JnneupMRPpsYfbl6Dfrz2hBaCAF63QMVosm3SnHQQItxH4uljTMBBnYC+cRI+64HP1ZiJT6CfWQXp9k9n6WDvKJyWB95iSZM2JMce4dKowYl9BELpxtOMfktaaJ9DA5tM86R4F7lkpJ4uCOULDbByY6df6jtF51Hf8qXu3m0jTwyx3nSPWMT6kgQqSjsDyfx2+568k0YCYhJHerGRbpCen+WBKgIp9YFBfdMj1avoyZ4xKJIWOTuqGc3V3Q6qpk5OiNUFnkfwmKnDtsrDLQrcno+hpTWrLHZmZyEIbg0DbzE3/J5Gz05pjniG X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef3d8fab-1fc8-4c07-76e2-08dd1b1e8eb5 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2024 02:33:41.7221 (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: Iso6nJc7Hg3zBCuCQy8keYq/TKF48VK8G9K0kMZG611b5WH0GgCAlmMcaxT9AYSmJ94fTH02lJ0gblvUSpZw/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7114 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 v4: fix a typo v5: no changes v6: remove error logs from the datapath v7: rebase the patch due to the layout change of enetc_tx_bd v8: rebase the patch due to merge conflicts --- drivers/net/ethernet/freescale/enetc/enetc.c | 257 +++++++++++++++++- drivers/net/ethernet/freescale/enetc/enetc.h | 15 + .../net/ethernet/freescale/enetc/enetc4_hw.h | 22 ++ .../net/ethernet/freescale/enetc/enetc_hw.h | 14 +- .../freescale/enetc/enetc_pf_common.c | 3 + 5 files changed, 301 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 09ca4223ff9d..41a3798c7564 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -533,6 +533,224 @@ 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 first 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; + + txbd_tmp.l3_aux0 = FIELD_PREP(ENETC_TX_BD_L3_START, lso->l3_start); + /* l3_hdr_size in 32-bits (4 bytes) */ + txbd_tmp.l3_aux1 = FIELD_PREP(ENETC_TX_BD_L3_HDR_LEN, + lso->l3_hdr_len / 4); + if (lso->ipv6) + txbd_tmp.l3_aux1 |= FIELD_PREP(ENETC_TX_BD_L3T, 1); + else + txbd_tmp.l3_aux0 |= FIELD_PREP(ENETC_TX_BD_IPCS, 1); + + txbd_tmp.l4_aux = FIELD_PREP(ENETC_TX_BD_L4T, lso->tcp ? + ENETC_TXBD_L4T_TCP : ENETC_TXBD_L4T_UDP); + + /* 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))) + return -ENOMEM; + + 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))) + return -ENOMEM; + + /* 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; +} + +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); @@ -653,14 +871,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 +2030,9 @@ void enetc_get_si_caps(struct enetc_si *si) rss = enetc_rd(hw, ENETC_SIRSSCAPR); si->num_rss = ENETC_SIRSSCAPR_GET_NUM_RSS(rss); } + + if (val & ENETC_SIPCAPR0_LSO) + si->hw_features |= ENETC_SI_F_LSO; } EXPORT_SYMBOL_GPL(enetc_get_si_caps); @@ -2096,6 +2329,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; @@ -2109,6 +2349,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 1e680f0f5123..6db6b3eee45c 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 */ @@ -351,6 +365,7 @@ enum enetc_active_offloads { ENETC_F_QCI = BIT(10), ENETC_F_QBU = BIT(11), ENETC_F_TXCSUM = BIT(12), + ENETC_F_LSO = BIT(13), }; 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 0e259baf36ee..c3789868e9eb 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -25,6 +25,7 @@ #define ENETC_SIPCAPR0 0x20 #define ENETC_SIPCAPR0_RSS BIT(8) #define ENETC_SIPCAPR0_RFS BIT(2) +#define ENETC_SIPCAPR0_LSO BIT(1) #define ENETC_SIPCAPR1 0x24 #define ENETC_SITGTGR 0x30 #define ENETC_SIRBGCR 0x38 @@ -554,7 +555,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 { @@ -578,13 +582,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 */ @@ -593,6 +600,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 00b73a948746..31dedc665a16 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -123,6 +123,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 Fri Dec 13 02:17:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13906388 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2043.outbound.protection.outlook.com [40.107.21.43]) (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 5FDED1607A4 for ; Fri, 13 Dec 2024 02:33:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734057231; cv=fail; b=R1lGEUFM0hMr3l3uGiuvPaks5vdwhravek/+zHgnZ94t8SXmEFgbqQQquBEzvZZk+iYDpj5qk8hYWr3oJ8SfsLbNm6sdDfL+DSfmdnavmJgolPtFusTzc0Iq48NEy/fbeMCMYLfmNzuN/a+HzhilsXWkcSgYLa60QVQxAsenxZ0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734057231; c=relaxed/simple; bh=CkodByBBagRtPFc+k2XsQBF8vpyHcxbbT8/Ga7p+yYE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=HHfE2TmkhNo+Ct4B8Xf2ZMb0QSxRZmQjj8Y1U6YnlWxHxbfjMDZLYsppY8v++d2eSXWc/U9bBK7rBEizLv8kb7ylvsows+aUX6X3kG1djMVHmOLuXD9+wOThtL8rPn5pEBkDqJaLGBVF+1DoKbHw/f5lbJn7XQcZRevxT6mCaz0= 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=kxib8WH4; arc=fail smtp.client-ip=40.107.21.43 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="kxib8WH4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YqywBd96wgW37iPkW18FmFaakQ/B5UJRLr50uL/rimzKgWv3dMpkaZjPTWIDI5K5KlEb79f2+f+LRZxrEuG9Jfp79KTmK6Xc+qbcZP9iL7tzI59NIrW3ge7wWyHGGaNWjg+ZtxWqH6PIIDhvDAVNNmERSVQnDfY5vpUf0xrRXsZhs9r00rOn15juvZgJpd6ttlzRHSRtAWwt2ZlfBPHxit47bn6Hl+ISvg3IyRGb01MTmwAIujtv/g2KHn/Gn8R7XkGuNo+zDFvobfO5VrOy4vITk7waUVvjox5P/T+9TbDmICX4Ki0Njukpjn9+Hqq9XEraZs06zI6woxgPxJ2owA== 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=8xkesW27yDubqW92IGckwU+80vzPqe2oD2O0gVTDejE=; b=X+rntA5KVc7iG61CzCViYz1UyO7EO8LB2kQqCofc5uR8CHDOEKyrgaxqA8qXz9Qy3OeLuV1a58b1OVAbWDdBT3sFCWZQt5wgvJ4hCy4mCaZLIZynvynP6jINpaipLEQMYStghf+cJsNM7fSRgZqev4ztgfXuP46fh5ltzJ1rjASZAUjW5f6S6k+JZkIgCftFKmbNdf/YjMMSksRXY3Z1ZMy+W+yDTJCLW9yxtQmkabTg23iIMMB1MY3H8QVFMNMNXeJQjiAazg0kHhkVfEn666HbcnzZgjugnbaWK6jyqhPWhgjahvH7RQ6iXibOU7eBCvsUYnG+ht2+Xdh6YwIdzA== 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=8xkesW27yDubqW92IGckwU+80vzPqe2oD2O0gVTDejE=; b=kxib8WH4q38PXLgiuvsGb3U0FhszJVbZIdTo/EXtoB7/+EMTwo4f9rUElU/rZHhbM4ZWsuzKDVP+CGF79nOweKeWAeXI8smWA9OfgMjeFFqGyJZJfdKqSnFpQoFLfgjiqNKU02IK4jnnfi/y0+naGi+k2/jMD6XJAljQYTJ9ZgbuEmmp/S9iKzI+AwI3j3w2gVi+JyrFQUl5wg7WgW0K2O6/VYGZS3U6BnahepchtNPRTsFXLlrfn12mMydgqy7XHXjvLIy7jReehI87ShpcBn5zDPQEVTDE4bF5bkuBatKOebmL+fLfSMGg7RGpjP+5htQ+SSqfTqzX/w40uJ5s9Q== 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 DB8PR04MB7114.eurprd04.prod.outlook.com (2603:10a6:10:fe::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Fri, 13 Dec 2024 02:33:46 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8251.015; Fri, 13 Dec 2024 02:33:46 +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, horms@kernel.org, idosch@idosch.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v8 net-next 4/4] net: enetc: add UDP segmentation offload support Date: Fri, 13 Dec 2024 10:17:31 +0800 Message-Id: <20241213021731.1157535-5-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241213021731.1157535-1-wei.fang@nxp.com> References: <20241213021731.1157535-1-wei.fang@nxp.com> X-ClientProxiedBy: SI2PR01CA0014.apcprd01.prod.exchangelabs.com (2603:1096:4:191::17) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|DB8PR04MB7114:EE_ X-MS-Office365-Filtering-Correlation-Id: ab17f139-1752-43ef-eac5-08dd1b1e918f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|52116014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: NqqRSyL2ff7mhjLxueyGOoERiBkaxaKMbrwv6kt8B2cj6KeWkxMh6/FuuKkrVkDDKgQzhDCqg26m9Mz7M6pH5dwjfuogrfXSF31b1LNzJvyxFTOzzoPuu4zSI2rSo53bjlPjLp+5C8Ufn2PkV4BGpe1t0sg5IbvmkjKAQt8mJZN7Jr9yqEmBTPySTEbpI6ZmAP2VtEgW+cDYXFrAllQTvdL4UYJss9pD4eU+nXD8D/DMaVuNlfla28rW7e3xqMzAHYglHtKftdWfzBsAcqwTOo/LFEJPR9cjh9sxwdGXy83viw5JllKsvgVEwjCqP7Z2jcKw1fquAKPCAd96Bp5HaraKNGOM4p7wEj7uvxEuUw2/ojoYfn4sundphP7ohooBonVuxqktMpK7PpzIjaGbTpjpTEgIPZ6/BS1IzJvDRgLMnC4P2DjulOE4/tgDtAOU9pRQanSt8MHtKVBDdEZgO4pPtIudXhBg3tyRjEvKozOxC648Ab62QTuAIOD+25T3Su+66VXeSCDoIKaxgBiLEUW291i1sPP8xYClmP+miOYFvKO7GF3pbU9yoOLX/UQnLZoS8tQDzEH5R4Zyo8uLxunJmqpf3iodDqW4LnoxdhVHJ5LJtH837SnxRsq4ud3KnEhRwtSuqC05SH0e9bwyYzxhUgmucQg2BBerV6hYFDJ5vhd8MbFpRKfJ6B/CL150jLHDF+zOab8xUcZmPOYvTR2QAVfm7fXlTBaX6AEf/EKpMoqtCXoD9i/kHWQEqN/QdQxfCJD3Vkg/nndAEMT6SMsSMhz0WbMrhtLMo0+EfDQ4g0ewQuTfBtxRDAIwG/dZtRap5sVGzV8gAATsWiHnfwpfDwB9RnUZOAPBYiDOtXOfg/bWvLPqRSxjUcfQQGOAF3AY9qCC7zFbq7fYyvUvwOK/orJdm8JcYplYDDP4C5EXfmjMB4jbNvkJB7h/Yq7F80lum18UJfO2WnbOlYfQQkHDjh34ci6j8622KVbaIyp+3w38CBYfafedOnNywWLTPj26X0tprSFkmtoU8vT5qgQ6cVfFYwTJuHgCDsPuQh3yL/of2RvGMl76GYH4w+INtOtb0AYVGvK3BJZSwxLhI131KMcF6+U/2UdPhDTBprmL9wRV0xJZVMx/hmO//iEdaSQA3SS6aseapui5W/SR+Y6TnP5q0NMbHFSx+NagG1pjaPmk4CgBWcVcthq/FY6KaQvKivCcUKzCOUM5G8k7SBZ1JYuuBKjb0sW0nLSBuFadO58591xbigbHBCcjVvifEtOYm0mAIWDeARm0PIR8MFwgbNhTNmuA7nA4GWsaBfnLU3/9k6yiMoU7kbEytUTagdih6qPxCI2hkXEQdYSsy1sZ+oxsVhJdApaf9GwDZVTsiXutiBDsubGqNStifR5dlETOcZ5T7TlJ6AupltMfJqMfO/7HgfI1ncO6QnPSOkY= 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)(376014)(7416014)(52116014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4JA5YkOfyHO2z+LTGL54oXzcMjB1F+BNcrdMQbi8sWkjRZvQE7r4XoaM0T3gWYDA08KS0Rfdk2IgcKzFcE3eE6Fsqv0NSbVhMCmBjPxRbE7i226f3ZC4YebPZ2pCYt66hPWd4pS3yWmN+hoxzRDmpblIaR5dKZvtXyhgAhMzYizUFXEJMVFU+ZdZglIsgtoqYy9LDlMhs/tMCF1Yby7H3x8wekj9pGeYST+SbnVNiO230p9hx9V4oXT1cVq2bL+6R3zEBwYr9PPIlg2pPEGs4hEOv/0xpMxGRXwte0VcMFSz1FXPhOfoLmfWdWIiwq2iYrZyVeRnFHu086jqVvXz/+0XZn51IquGgGH4b5nbnTZzIpd5mVGBNzYteO7w7MEGbOTTC6EOI8jmc8Qw8e+VGbVWdmSYi5FBVZ26LjWJhxlk6VFxNXeZB97l/aqAzb3EOIPzKo7+6vi7Ptl5+HC/TEMssVzYNWcIfiluYmRGDdE5BMDjI8a3dj0z7oOPfU6oiz8ujSr8zDUXhp6hck4Wjl1fQBLSrFQx4mHRZaRUAuZoCIgZ7WR0Nxm/DjR4VjpVpLwIrcNi6E9J3qK022KNLInWgwi67xb/p/2j7aaxuhH8N7BjoSw+7RBvyXKsg1YNsJj7fuffAUpLnEmfE3hBDp+zJwnbPUw+bHZyCZZ6YR5HwwP5Xyja0dGkrrfxtpQGRR9KnCWP/+htKH42/APyKCY853gYVRrkjjfiLusjylAPZhn7fKWywl4QZcpvNIct3o4eP+KxTb6DWpFFgGfnRS2CGF6oKsqhs0ZCuF4xXfcKTCrCy8E/AOad1eR2X7+uzmpSMG6Al6QS8BNF243ldBCEibywn/ZDmKyocHECb6hO7mQ+42fGTOhplRM16ytWmHNHvv1hEWUQZjpS3Nb8W7sLAp0TXz1vIBsElEixxdx91gvJwai0m0BQy2XB5RYvRF8jg35/gdWrT+3S0Y3aQ1cAehAOy4xIJwQbKjOEszVE/1+t6xKjJpIUr7BQi/rXM6dBLykTLS3uESAFvDus9kljI1VvXF0LAGpjjIZB7+yJvtHr0Ofjud9L8EIwXAJ8qVnVnxlcV6aPqS/mj5m2nxX5YJQ/Gs97mD/8IlwcQ9+InbuO+Wf4O6ggq+ZdWYfPIhcUnxEkSktyNUf+urRq/2vuhwomxE1D5jj1Ag+LTNG27W9RUFlNf5DOt7rN8EjfyKJAKijkgoMRCQrJECEQPqu9v6m70E99zLkQHPaWFYZuq5dZ/VxyLYAPP69NmSH9rNVPAKHcK1cEcaw8M8YZ1HHiQGQnUNAt4iujdDgpDekqkGzJovbSXuVjWah2Ah1iIFRdSNxaPYyQrdSOsO8wc+bq0VGGFSv0q2wfvAtY4/ME7OJtaMhl/SJ1mg8LmKG94ULu6sLeBoVGABTkKpzpgrhrxB5KfSfIowwEHCDkLO8RX2pt941wRhWRM1TezNXcqN4OPxrWFg4yf2AW4ZXMR2vCMnRGeMd10CKcd6//zoz43K63maAJtfBvomIer9vY1c9apAYCXMQPOMP8V5hRTysLACWN7MYkED1LeIJcY0oJN9QTMrJNkrFxzuLxnhr4 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab17f139-1752-43ef-eac5-08dd1b1e918f X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2024 02:33:46.4042 (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: XrUmcEpVEwYKp8h+ILO/FeZmVpGabSbvtYkZq08OyixNgGBmXI2szzcJRGBQEymM7bVcTjpoX6JkTPQPnhzyyg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7114 Set NETIF_F_GSO_UDP_L4 bit of hw_features and features because i.MX95 enetc and LS1028A driver implements UDP segmentation. - i.MX95 ENETC supports UDP segmentation via LSO. - LS1028A ENETC supports UDP segmentation 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 v4: fix typo in commit message v5 ~ v8: 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 31dedc665a16..3fd9b0727875 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 63d78b2b8670..3768752b6008 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c @@ -145,11 +145,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;