From patchwork Mon Nov 11 01:52:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13870178 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2085.outbound.protection.outlook.com [40.107.21.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 8D9F680034 for ; Mon, 11 Nov 2024 02:08:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731290887; cv=fail; b=hQ0SAxB+Z5Cr44mk6FDiDKR7QjHMW46vlcI4nxPsEO7IOJMHnWAIUGgSqf3tAxb2eVxS2TfOnG1sezxC1Sq1mKXum5MzRoreL7CEdkWSDVHIoCuRBx+b6+0c6PFj2UBxNyxEx8mZddHVA0ft3VT+9/WdvB7zfAZNOe2wU5hK0Jw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731290887; c=relaxed/simple; bh=2qqGIs3/VSIePvGmEDPHHzT/nB3Dw4/8aF41T4RvTmM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=TgM/LEFRUFI+CiyqiG1rPQTAi5GEZ8AOFCCPIa90fecW0yInI6NogvHNGUm4YzR0HbcKi3ANI7FTDneYU6Lz6d3Tw1ndfzdZEbnMRt8s+aFQWz6zRD5NTS0OcRa7M7cb64iyBoCbJnW3+9eDhXhCwd8vEMa7PEtIztHb+D3IcEU= 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=cRjE0iZH; arc=fail smtp.client-ip=40.107.21.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="cRjE0iZH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ml+vbUBWl8QGPLzF8ol4ae7eWr4+z3xMZC43zyy2k8Mo/H/69MGYoL1vAFlEsD+U+3IyzyoPpjCRVBbcJTH+BauqAxBwpM6Ev1j+iB1FhH3qVw5gBcZZRNVSsUlvV+vhmx0h0hBxfyjifeF3/pJQ96BVi3i3us2Jej97qy/JeRRrA8NWqGkgRUPRX1ZwC7OvP0FTpGue/DMTgfEOurd5ApSPJt1OQi0iz8Ttd3pHJajCdeOCytNM5Qz/lMB5eab6XAnxZBjL7VhleSJZ1I6H/rKMgKtj1MltIZ4RO8sivQzpKG3zkyHwtTb8zV+JzSWXn5Np239r+8zwDS9VsOWFwQ== 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=jDcmo91d7aSf9dKaxzuY5sw/lnFyQr2oFgJgtqCk6r0=; b=Nl4itr9YTt5Ig+A5/z2x5XPXbWx8Ie6iVswIjouqN3aR2R+EG7pt7dpkjhUt1r30vsNXnhfX/Q+ZvTEc3QA4jgzBDs/PBTlfaKlLb3EHmsP1heRhFvKGhJ434TJEGrC8xA/e8hVROAiO1BTC0/eAoGJgnyy1gwH63X9ZaMI4Edb/WSkMH8/JRHcHjvzs/9su5EnJFEIjazMh0UN+ZNDgMBtDesS+DLw6jmhh4tZ/yMprrBCEC3tHPttcHyWt2hcDpP/EAc48b0ZJtwGKHHra9xtfah0US1fMrX7eu95+sgsrk6pf9D1nSua88pYBWLTHoS0AkgQm3SPmd4n4Z4f47g== 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=jDcmo91d7aSf9dKaxzuY5sw/lnFyQr2oFgJgtqCk6r0=; b=cRjE0iZHuCS7G0PxnbLuYDXtONu99/J8gUGLTrNuo186GUJG4X0gOPvFfMw6Cl6IxSn/6PR6KErlX1EHQdM3lR3/oXZyOsyvlMFK0JHYMpjnmQxJAq3W2fWZAGj8gYIcaz0oBH9wWSfndsLhWclq00ywP+sdaHORdohK01d3TpGAObZ4NctTQNvZuHgfcez8FF95uRNyxMZgtXrN2phHpRhe/f0i6QyurlPv6RfgCs/Ryw7uW81FkfT47iWvVZ+v32cnHcY+4diQYVLLPh8ylbQJSDHiYoOC8ytJbrJuohRZip40lyusiDuRvmqJZ9ZAEMYt84wjLlgbUGODJOLRJw== 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 AM8PR04MB7745.eurprd04.prod.outlook.com (2603:10a6:20b:234::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Mon, 11 Nov 2024 02:08:02 +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; Mon, 11 Nov 2024 02:08:02 +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 v2 net-next 1/5] net: enetc: add Rx checksum offload for i.MX95 ENETC Date: Mon, 11 Nov 2024 09:52:12 +0800 Message-Id: <20241111015216.1804534-2-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241111015216.1804534-1-wei.fang@nxp.com> References: <20241111015216.1804534-1-wei.fang@nxp.com> X-ClientProxiedBy: SI2P153CA0023.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::6) 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_|AM8PR04MB7745:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f643d2b-8b81-499f-91c3-08dd01f5ac0d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: wepjC4ldWQbrkxiqI3IfUugEpuANbHt12AR5X4rFAk5VUFoXrJZ/FUAD/i9gVY/qZxwRSPjFjQHmkfx7fVgf7sYtLfBcBmk7v2kLu82j53nv21bWfaoJt3GXpagiTbbkSWSq3/FFsjL1gs9RXuwRPpZIqS8Up+soLWn8JeM9XlYX6egOA7Aaxg2XituL16TPRtB/BeZrTh9m19XP1DVaTqdxzuexbYwtF2jM1P8jcSipFydAzttt6h43tUNaRWTrxadPvYXvxNk/sTm0RGFVzkYvz5Ced1j7vcmuNqrZyXb9oQAdXy4hOkJ/cRzWNc3pa/WNdu2KrvvLNx0quZ/Ie4fyn9n+MEdjT3Ggob7YCIH0WgPiloL4ozfciLiLWfrMzYX5WohsxXS5IenCt2idRyXGT/sem77QEgvx+Xq2J+J0/q42SI1BeCnTTbZhisASTP7U4SsSv6SS9Hd/pRH+bdwA/nNPYYTqakbXWTtdZhsGgopVSr3UTBdTXpnISGjNNTGuXR++escH7QBLIHCQsoqdK9F+tSOeBjZwETmYiVHI1i9UwjdkLqQdC0U2lvTJ71u987tQW2uyb8KuI/zgxYntlj+/DfvrtLqh0QvCuC2mj/dTauoW+ewnujmDfsRWHhFhExYfINlJOWh/bzn1T4JQXT7vLMIQloMmQKi1UEcOmDFp+p+Q4+q0N/m+4EFTOtxDp8pxGqOtCoUHR7VpLsRSDp9jwSSVH8zXeQEo3R/OFooFBTwoJF4rDXUka9rUaLo5TJhAaG9oarJURmCyErdKwchAKF+L+oJMHntoojd2A+/s6C9og5h1lxBOqFjp1v0NSXwXryiRfP9RhOuRaSQHCRZxTziMFs5bl9Dc4PAKFf4oOj9uGoD1kOYuJ2OI4kDLQba8i9Si6vrYPalj8b0Pe6KWgkbOSPvoTKORqZEeTimyEaBANTmLO3QGyGE8tAk6H0xmVb80ZfyStJSs0K4+O6P1tcOmSSb3CvaX2iPKNbC/2iRYM0PjYtt9FoiEjMnrKA51zScCWbx9qoR2mN0r9DvBT+Qx+rrADheZ2tV+Ifp6+RpMJvq77+UQHIV8PuXn4KG2c66LrpMzhCf9ik6ETbluTApBMYLjjjlhfBQCjRoRAi7V13d1j9FfoYiK1EovN3MaGg+xc15KFeBvHjUdR1it8i2HFDLA8WYpbl53dTsfJQxqQYfUUax4u9X3dSnkvy5Be9Nlr1/PlrWQL1qYZwfdsrJ68AEQXWuqslzv67sTy70F+LsSBI+wajEjOFM0VfqxCQLlNKBgAF50sVqMMq5nyfc57ew3kp4PZgQsqRl918N8dzGBWLFDkdyyPw/lx0IxIGuBf+8/2hRSNW+AFqEte402hSrx4ctdv2E= 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)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3qt+2ODbKLL4d3EpMRhzAgmmcpRtEIR83Wg+a8yze4HF9u/5KM1C4YXjmVjNJIgd9+dOOCcyOxVjHpbwiixg1Bm2Qc/ftHPmsishILRqEKkbw01ktSpaIkDstdPrS6dLEtZTv30vhfVMdyz73sHp0434aeLPrftDfJwGf0jYA0xsoTiJdakIqOZ6DN2jqSPTWshcmqtDGgGzHdViI3t2fdlxsUPO5Sx9x7JjG59flrtnhm/zu9SCJ0hB6B+Ou+FIy/5pqwMrjcIbLiVLFKzKDfFuOODG86G91cV/twNdleXp21HOXtm2NKqajxloYxTTgqzT7duj67W59m481PBulqfDkSpw0FcCa/wlcdjMrijv/oZEQImumQDKOBiMCn9lISkFNAsdy9kOrLjq026w1Ji5YtgHCK5varZNVNy5hFb0/gzzP4IbuNBe2Cfx6D/a79jEhLHAXch6zBbW8rBxIMWO40Y4Z1oOlO/+Z1XEVK/9gyhakoOndZt5WNUcTnDQqL68I/kzdK8BiPYF+cC15XVizqGHH51OkqZOokFBJ7ArYX8sQMPvtw+Eac05gQMGetAlgBfd0tD4cacOrSLVP+M5Udnn7n/f3/I3gabi+1OwAfES3qRqfHEcr+ffEtuTaUQK6FB/Q77Lbl62o6oduWS1L3wPv2hbi0JFNGyHk/c2xJFzZ68VuzE8dOgA62rl3FQvp1jdusW4bLqc2t4v93Q0zFuQQ9h4Ud8peTx39nLfFfMhVj5XGOOzbGfkDyuigWUjfbhnr00Noa6XuqnBxbUVXk9BQid8b0x0K+0tyk0Ee2dr97XJFdRl0FbORh9ViUTXPVNvinA9chZy8kWF2UMqkYkFCa+7jf7B1NfCVUW69kM8bjBt4XLSQKSbUSjlcsgXgOCNq/Ey9OWH4uNLwz67z8W1baGICj0kCu9ZM96MIMItvaYwNAiioc+8j6D7o8EWlaF1Sic9D+cSPa/A0bzDtNKVhZ/COU0e7tjEnIZ75U9H2a5K4ks0JYF44nQDqgNwl4bsN4Zr4h2TZ1w9I5bEjHihtnoE67qLzIcuwPs84N8X4pxZJa4wT3OaZ7KJX+GNVfkCv+cxtiAS4UHb49QoVpgCQ4FaR0DyqY+FRf7j4JNtMJ06XHFDtPZsvfp+zYmX2p3p3/hWcPbUliWLayzwfFguRGXfnOqvRKU178bNfgYQazxDbXFF/IBXIdbd2cz00HzhNQEQIBwa/N1R6zd1NncKcV6+ONjrdP9TOfsfW817RQGGoVTL0C5z0SYhFe2PwBoqlAnuXK4CEIkLIrRRN5EopKe9D1GJgx3h1IWi1lgpYdLnwYyPaVvxQ5cu9gwRgj9P8FY/MiW+qJqcAhmrh1lkoDCLPq+kI2d+FnEsyuRXfc+Bd/VeJqbcqQJUujdvzev305x6kOXBOqWeWnbgPK0gECO+0MhKKFpw/0aRZ9RjigmNkvpkyz2lYdQkaxiuUEfAYVNu5QqDfcKyYkLnH/fEmh0E0WWJFaA3NYCBoNyS165lvpinPkb9KGvXxa/LILKU8fNfX0vuYPGp4+B93QZnlirzPWc7twlmqHPmH3mDmyAXiPxYcQeiinrC X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2f643d2b-8b81-499f-91c3-08dd01f5ac0d X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2024 02:08:02.4784 (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: aXqSmSBP7bCQHuFjiD/seh0e4JdiKQ0AvVrSefmaXdEmT6H/9QcJnruxXD+yWZ5xpX6ybofysECeM2rKp9Chyw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7745 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 --- 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 Mon Nov 11 01:52:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13870179 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2084.outbound.protection.outlook.com [40.107.20.84]) (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 9ADA613B592 for ; Mon, 11 Nov 2024 02:08:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731290891; cv=fail; b=dn0feLmq2utrWTnsQinqDnAkEZRaT3RoWgODu/plWTrwTkcevsc86ezGaFYv8GDvPqdgP3fLgmRPuYwPtrVUsATe3uWSONHTPj3UL0uZXM0A/GwtOHz0J8Bv+MbdXFNEZYaqKLMltcJP/AkMrdPb1RQ3NguM6QK+6xtSSjG3EU0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731290891; c=relaxed/simple; bh=UYQs2SH7ZE4tYfAgwzU674wtDS+pwu5c4cUfYUeQBwE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=QkEXIS7F1lh7+eUTIC8R+NTqF6PtexwiHVngLcNh7rSZxRy6Le5jwqxqe8rcvqo4iI/2Z7sDao+LshjH0dpgQA3h8X3rxDByYraLSYQqYlW7WrCZC8TEJ7Hi5JNrNgw2ajtxAVsDhDcHx4bLNEk6fYv5gpBxr2FPeJOlInfqGfY= 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=Nx36gzf4; arc=fail smtp.client-ip=40.107.20.84 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="Nx36gzf4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qOPs6/G85ZTBIB/jG1XDSjmxuYoBoP7uuoNtqS+ZQ03QFqzdzzZYc5i5NL3jHjfYbaUNQhPyLTFY7ChtdjvhvFqUwgPw98rU+OvfUtdy0V+hlabBi03+2tm9IarcdPaYCIbs2cPx+yFc1mgCLODlINbcCpVzhhDldCVOj1aI6pbTCP0PcJtrBBmnHvmMDCcBfwE6K1SKmu053A7Yp/JKeYE49xpxPpubfVPtIdfhlo/gE084TRC4RN9n0LzBfrzAE4bc3VeTu3FXo6xCt8XxC4He8FscR5VXKkPLgk1IGpVD+WyXILeeoctjp0FkfgbYlrg7ef2SWKTXnVDEe/9qWQ== 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=daspW7rj84aaocJqIZn+sdRfxymek3Lxlhpezo5wj10=; b=A22NiMNc4SCXa/K0Cn38LKyDHco/ivOR4bGAUK+YYoCAnFtwfKQZnmNyZfFLKNVFZkcw2/ot9PB/wFsv7htTe1MUzQDLKdi+7AEGExYfPiOnVZY4z6VMJDX4EKdvQ6qdfow5oympgQSvZkXPVPaaAe97cVu3Hu4AHwIvRosx0iuNCztb32NXR0nJ1dfa4BGG77wegmJJ7lUOVs3stenHCXqd5VLrjRmxgrsAutBthIJ225qJmLvqJYg/adAcGkso19P0BDrUJvibi2Z0Tj+hhexxn8hOhUdyl7aETXbvji8Nhu9Pi9J+whuZ+fFYwqKa1AuMhO+ug2OB2e1xBNmR7w== 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=daspW7rj84aaocJqIZn+sdRfxymek3Lxlhpezo5wj10=; b=Nx36gzf4guwj83Bbc6g+P08Ly6nF/ln+p/zzgGAXUJ6zEnqasEGiyMr8A63g5031gOVXe2ohVIBFHoEgp2jIFOvc9jPVn3Bw92gsJP/EM557ZODiO7w0Sn27i9V7HjzzqkEQkeUywW4bl9f+6/ftdWI5NYgDA4PrJWrrEypM4O2FniVoZY63BKRdpvcvCbq17Ku3foVcjuhH5SUiiXwKxhShe5OuMdAeVaWK48gyM0a0LEYyOQO3yesyq2CVTDgAzHWZ32QaDPN8Gwyyy7jlk3T02eAMioUboMHnGkA0Y/HdIfI6vZHACxQBkCB8Ne+XU59q0IyL2QfHPwKIJCQfmg== 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 AM8PR04MB7745.eurprd04.prod.outlook.com (2603:10a6:20b:234::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Mon, 11 Nov 2024 02:08:07 +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; Mon, 11 Nov 2024 02:08:07 +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 v2 net-next 2/5] net: enetc: add Tx checksum offload for i.MX95 ENETC Date: Mon, 11 Nov 2024 09:52:13 +0800 Message-Id: <20241111015216.1804534-3-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241111015216.1804534-1-wei.fang@nxp.com> References: <20241111015216.1804534-1-wei.fang@nxp.com> X-ClientProxiedBy: SI2P153CA0023.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::6) 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_|AM8PR04MB7745:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f85bf19-f7f5-41ac-1cff-08dd01f5aec4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: KjwqpEVqHIdTU4sAMhRFA7yPd+OOEi1FROepHIpM0nk/4CSiPCaA3NymmjuJ9+EDvR6IjmugvbJ2FB6NzTewuKue1QFUJx+W5/bXVj8QtjPN/zcXJ/moIni1k4wC1WEOLMX/B3+/r/JHYC1hYF4OkTchAPz/tIDhzXXSfgPl4WnNZxZq0N0e5xso73Mlu6JgLQ6iu/CBsB3DP9TLfWEu/p9lbzuDG+n0FJS5LC+/aWW7TV+gB5dmYpH56ubwigKe0ubdFyMslyHJKrWlsh5vvgrSRg6bsA40b19Yrzmk+vB9Xa9avVab65oJipQBo34JgVysa0zZUvhVKydiYzGZt4d7jb7MnECU25Hmuhd9FtP7NlTXnuUIxiK75PRDA3hkvebpqG9MhGEm0S8kYgwkUa6ye2u7BtADWCVwdpfX6EF3FP/mv4Nd6zp6GcLkNb+k3A5NB8H7eXYkpVsGCEiOsRbEF8t72cTelTbq+VvvYBCiN6lwYuLHTI00b940ouidn8Romub+CfFTVfP38H9ug8y9qBPena8zo1o3qIDZ9cr18SoiJipGY3uxtZxteUqrkA2vXmoRcXFh8EmBfJB+5zfd2JwtrFmsqHuIsk5Z60byxMdPv+OYWFw54c9YHlP9bQWstE8F7bfrLfAbXqiTb07iMywu3xJEJTRqW82hk+l/L1YmPS0dL5Kikfva4wEJN20rj6Sa2lAYoc8S2olL5f7TNSXgqMwQ8O/Vx9PmYw7cle3NLe59T/aE2yvajmvK3pmjqdOmnNM30j7vgYiIFRrIbOZr+MngJum9hfKxpWwHNUs0VIjk7WUt3k6snK6PxI77n2AUrBW5sXBzVDebK7Bcl4KkRnC0tIE2XOlHEAk7Ie/q+c0sDUdDW+YLPaVBzJ6ZykttybaIKplHfq/zH0YuHKintX1dNr86NHK2oHzu3hMExaQtlzB4ErvbiCrfQizEob7i8yklgXFZvoMByvAZTCTnSFJ6yJ0TrvJpKvUXaqPTF/xUZvRYx6rghI52D3/Lfe/nZekDRSw8/gsLx05HDr6jRoJgaulm3oBck8vozw732dmDkzgmjtLuH8l8QEdLM7iCtrLf5ns6YGvA8BxltqUgHNqp51n9YKwDUzM013KC/MXjhLt4cTmxTWIbUQ/hdx7AAtlmknBVt2/bi/qedM44G9Fu04PQ/O/Swpr57GuRK5pdbM727emVpLrEoslNLhk4f0xH/akBtjgZ2+OAXjmzLSj31VnehG778deEwRbnS4wmmTyN3csJQ1UyNQjUDkSqG9zur76lUFHiSt45qXNo80VF05HmTv2pv6t9m9K7s32hBkJaQ/EyGquVrKuZDFVJplUuFIWNVApg1epDPzdayxOnQZQPRnFLDwU= 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)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eDbVL66UHfzyWmQeki/nfe/rwWhUahcd8X+i3eZ+7NYvFp2J+/4VFm35rSgAMEJLY2peYGaGC82EpZ9iWsVmfAFbh7rwrTNoTeTqBu7icqH2ZZyI3KER6llaZYCyDGQiTKtwmL54fg+znVhfWQ3DvE991p6cVt1Q75ajk9vkH98l0NSCZ/6uLaPeKcwVTe8K1m1O5aLrwHr893LxZqWDC+pmRrV6xNhM+r9wggn0eIv1Tbk3eMT75Mt7TQJvNpsqhRIN2goIA1Nrqsv7CZbAWE/tkoCPg9Nl2JLXyVgno557Wo7Xw/Y+JrLDcmAS94403xq31S17kR3xvjQ6zY5L4Ee15KfuhinyJiTqMgHAzjA265WoXVYR2fwTW0uuxKovPwMNdnnXbLkdWWGG2wXm+xcAomg8FZ1NMR8f2kPR2zHUB6i1aEibQnyeq3LfntI09ZQeZ/+NbQhP7fk+nwMwcY7EglV7G+N9C2h33yUhAKvECbV3qywJwdvEER/jO30qvDybTxfcd8ZTpW9n4SY2D6S9EorX4Idc0EeRqbSazs7/lxRRqEtS/ReakSmnEUOc+Vzd2Tie70Y4XKKsvzaRRKyb/c/EXbIX71Et4qsoRA+ez+0arY0JsOheR4lJlLVbyRWHL2gJZbdWfPjNoMRoDmOGNhk6yaizP7w+Po0Kvx8lHofL34ik8TBkzvIDHWAdVxbnLa+rKpviwBxPwKwqfsP36iANxOjxCU3soB4HHKkOlRMnPGnbOp4EkHYSDFPvLxQFsx0QKGrwjL9h5vdzhzlU9ibka6kaMHUzYpnyZE6MIGj1Y1gphJ39s+E90abiGVQ8kqZqznFA7yqMt7Mdy9BMsAWUg1SoQ5RjEQXjaK+7/fndNG8ABNLGEzob3Y23KTKA4ps6qu7w6Jh4LoepobskF1TlbqguhjY/7ydrSHkayHhFhG+xmqHP1wim8MCGGZHok+nsoU+UzGv0pfVWgr0nlyigdvD9R83k4JMU1t4YKdWOdjPbeHGoZd0nimx4ttWcOs5GN6AMI9drkDR8LZIeQyoCjVH2EgbiGoOwQKqjicBtM2tbYd+sjGa4PaQMV/WC98D9ZnKYj+r1baZihAn6eNL2h7ZE1VIWHbuJFn+29MHId2HL3xvH8iSwPSvkXVX1Kd5jUTfm6IQ0jwAReflqCisqSoth3IxVeIIjr4qKpirGI5/prNlbsCZHtFWhKnFNnCRuNHeXbRwAZDGXy4gZUSbuUbjUvrg8MrdHHauZZ4flqNjC8ketPqsVityl5PKSab6HfXbvwL1agJx4yVad4npUFTp8PcBZss/sMTqqCX/LfN3r71LHNDK9yslfnS6iGN6Q/WzoBXU4aKTltqzRDOVens4A5EldJ6VwnNHtJV0nhXZ1SvQiOaz4lrZzcb3l5kVL4T0Ey3+xCVHUt2oWHJiZ3X37WWguClTt4jde94rcjYt1iKfJpgAqDD6LTcXQ/dfgeEka8OUuO0xP7oOo2qIQH5KBsKRLf7zF2cYaXFGW72kx5aTx2a5PEHbAHgICc597jOPAfALXIFNsCHMNwpvTMgMoGpOanQmM2FECXuDE0YjMTXVSdgQ/sRak X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f85bf19-f7f5-41ac-1cff-08dd01f5aec4 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2024 02:08:06.9944 (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: qta3PH1N/QdPshZ3PojX/KBhcyCZbKIfYTmxSVB4lMNxMULK0d6tpbgRbV3xeXDpPA0haPxJc8o3q5q3P/TDWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7745 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 --- v2: refine enetc_tx_csum_offload_check(). --- drivers/net/ethernet/freescale/enetc/enetc.c | 53 ++++++++++++++++--- 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, 62 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 3137b6ee62d3..502194317a96 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) +{ + if (ip_hdr(skb)->version == 4) + return ip_hdr(skb)->protocol == IPPROTO_TCP || + ip_hdr(skb)->protocol == IPPROTO_UDP; + + if (ip_hdr(skb)->version == 6) + return ipv6_hdr(skb)->nexthdr == NEXTHDR_TCP || + ipv6_hdr(skb)->nexthdr == NEXTHDR_UDP; + + return false; +} + +static bool enetc_skb_is_tcp(struct sk_buff *skb) +{ + if (ip_hdr(skb)->version == 4) + return ip_hdr(skb)->protocol == IPPROTO_TCP; + else + return ipv6_hdr(skb)->nexthdr == NEXTHDR_TCP; +} + 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,29 @@ 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) { + bool is_ipv6 = ip_hdr(skb)->version == 6; + bool is_tcp = enetc_skb_is_tcp(skb); + + temp_bd.l3_start = skb_network_offset(skb); + temp_bd.ipcs = is_ipv6 ? 0 : 1; + temp_bd.l3_hdr_size = skb_network_header_len(skb) / 4; + temp_bd.l3t = is_ipv6 ? 1 : 0; + temp_bd.l4t = is_tcp ? 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 +214,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 +634,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 +667,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 +3325,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 Mon Nov 11 01:52:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13870180 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2077.outbound.protection.outlook.com [40.107.20.77]) (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 2FC5113E022 for ; Mon, 11 Nov 2024 02:08:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731290896; cv=fail; b=nhqhJsQDuc0FVtRfhmHnzDcxWBoxlnBMQWQNRUeMsCTPUScfNPsFW+DuhZtyW8Ck5bO7/ewPRiiiNj7QEOIKd7y0+Zdqd8ccnjEt9LtRonvVm2PKWAO3OB2+6/T08McIF7h1FcqHk9eqVsudQ9WnerwyFGTFNCvlyxyVFb7z0Gg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731290896; c=relaxed/simple; bh=g2eZt/EC4Fg1/2SUc8BWMFVMXACkSePdODMY0mq7Ggc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=om/aRs2tNUgxV5JpYj6D2vqqoRQTJhAGvkNH3+wj9CZPjGMGFBqGjJXbPzFF0i3wU5CIbZ9vxkAu6odpMo2G8O5CPJXkEGw1NpmqkYLCodtzwMFgANp1hlBu2wKFonZ5sQoD6qrKc2Cwh051yMdENEcPmjfKBCFwxZLwZI3d34c= 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=HF0eazUm; arc=fail smtp.client-ip=40.107.20.77 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="HF0eazUm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gjDl45ISJkVLwMWLDWMg7ocbTv5tWoFsQnfjJcA8fERT0U1uIBBBmAeSazUyymvMiNGWpEa96VYvJKCiPYqCri9bTxdsDyRD/p5k05QDkR/FcL19ZUHATINySnMM4r5IqJv53MO57HYVCn91IE/Jhk4L9TEY4mCOqB0U6p3QTdQTrjFs8zFkF5PAnbNRR1euhwm7MT2+u9QMpg3iD7OLtJzWt2RNEo8qfqnrYESk7k4u+z8igTPJNzZb9a7AoDlt0Fc+KAHIC203c6mqHcW5oqgXkBJI0uWLM/GgrlTaWSfwBV2pG1kQWuwLMSFI2/5fLMWUqedG7mujX5L8x+NiwA== 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=bcbyJnO9HUt/TykEJFC8ZTYzskhcRG6yutS7gX/5ReQ=; b=C6SDv1/M/rg1gsL+VooxOPawaSZd3IOtn/5NmXLkQBXDg565ntq68CKD5VcmccGamZKbhSikYyitVUYy8gdAMLEPVx7RvU3h+Prs7GEVL5Uvg8cJv2uaaKIyNcyRFSK3Xbq4ZQufAuEopswY71CqB1np8OE0J9rtg9uAdhEiKh94pF74fuT9jXSPprYRmCYom5sWX4nLTNe6nnK77fryKyB6I7oHIwccwDW4yK3gw5frmKbozMh2kXTf9CLHumYbCLG8qqzC5B+1C5C3EAUTPl5b/2hn4MUUcDOWmp6WoE3dyO74eqdKhFGAaIJzpv3U1P5IOIDYbnhUoejaXwswLg== 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=bcbyJnO9HUt/TykEJFC8ZTYzskhcRG6yutS7gX/5ReQ=; b=HF0eazUmJHkybFW3PXWmFHlJsXFZHm/bKiUHt9TcNKyVfycGA9ulYdmtVZko+IsNLPbBvIX65Nw+9qftcyT/7OpNfTLypsyQDfT2zSaM7PRzFGTLoi1eeVwnKokRelc8MJEFph00PqU1Elwcd3bGIwI/lRJ7FIefincCdsw+Hld5izRNGz+CtJf8f3dzFGZHCbVomdOO5LlV4Qo5GqfBFzjZj8CT9vZT+zqZKmlfFN+iEPkELWWwHWomiS/zlZFkbODnnPnvpBWaGRNjWfDIZyaSHSTuaK7k2XaETREycC5ea3VVIAtcNkGq8xodwh06yssgKm19P+kcTy3XDVwSbg== 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 AM8PR04MB7745.eurprd04.prod.outlook.com (2603:10a6:20b:234::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Mon, 11 Nov 2024 02:08:11 +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; Mon, 11 Nov 2024 02:08:11 +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 v2 net-next 3/5] net: enetc: update max chained Tx BD number for i.MX95 ENETC Date: Mon, 11 Nov 2024 09:52:14 +0800 Message-Id: <20241111015216.1804534-4-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241111015216.1804534-1-wei.fang@nxp.com> References: <20241111015216.1804534-1-wei.fang@nxp.com> X-ClientProxiedBy: SI2P153CA0023.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::6) 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_|AM8PR04MB7745:EE_ X-MS-Office365-Filtering-Correlation-Id: 1062b1e7-b48c-4602-28d2-08dd01f5b174 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: 09Miffm+AB87twI9hqi4Xmfg0foxjHKYc3LmVvKMPLqbS6BQx6t3I5Ut27XoZWuaXcK3aneIdtZNoKuZ/PGRIvASXYMfqUuYDRQ2muHc53jfMv1SVFkXZl73ILIyLj0Ja4LRBPxGk/764UQyeaIZZasL1aJmH9n3hA0UVg5P7/EGP4JulgvNJq3gnWEt6IkKw1/kuUtgYJBOtsoWDrBPZ9gK1+CetjbVrhflpeCzC63/sk/y/qHc2JIjm94eWwE49Q5HhLGT5eqH3RE3seAKzwq+vcyGCL5DTd0AMyOC1OoJrKqSEJl9tTwej9qva8AxVm+PakiaaFsWY2JdUvuMp9MkzSGqrehSAjyA0tSrSkw8Vd/0O5SV8dH3GhxpRM5v5uClNZCZEPNk8ASqxbCgd/myJSfy7xPOeD3x6hmUDAdOEN0We2HdF4UKCPwHMNJEGQPhwDA/k5wecZwgdgS0+zmndzXq+0IbcMFZHHbeG07R2NQKPWuAYWyPZ92qGUzvzs/+zWYJ9i8d0f4L4R6+BRgHyZiCAK61I0DANgfXOt76oA+PUhIOg5i0DlxRIPtxUnwD5FtZK/jyQUT0N2maJiGXXw4S2O3E1lIOyMs/8DiCKR9ZylCZBl006xWEvvCYX2SZLAJWwPOv7jwxPsXJgil/e3piYY2qSVnUMprUwIVdOoqQABJA7h77Hz6o97KvMx4lAkkgNa6rt6izB6G7547betv2mAEc5KHfkM74AkcdjajZCaClKFj5PjXicVw7wIerEhlvExiYpr+aw3s8Cr34jM5I6XRXaRqhtL07uJH/hLSu0Zvaac2Ofcx/wAJjzKf4u6f+dcT2FHG5HMWuVN6qfwP5XvMV0sUN+VSB5Cf09Zd9UVILFnrLgU5auH0k9PzUAqPerPjwSLYEi/31AvP7sZCaOC8BsettsGQlQuywPKwB/rSG+8jE82h7C3KobfLnMtzSnruCutxB51ZJIAL6FwJ+Ip2RHwox3jzyDYALYKmlci1tw3Z/G38oRFZDfD0x4jJAlLfEGtnXSc5lP1u+bHql6xSTiwG5dxxffbYF+ZIIaVw2YvQdeI3J0uB0F0PezLWSeJYHzWh8rHbwrdP9s9I+YdE0itefPdZdjDG1V1xUXJuzGyVIUsS8icToS6Pu8aVjopijBOFt/F1nHJ8XKrZJbIF+quPsWrzNFvYfmDMLzezyDQf579O0CTLZJdivN0zWmcVn0pF4RG8GxdjDNUU+5HiSmPH8Q0nKcZzFdhPoz0rYgeZS28Eey15sP9VaiumhHGK1YL4rXXJjBfl9NlAXlxYgPlegPhKeLeJGGWq9g4NMJNHRjqOh74lhh4HPfPhm/SZDgh+xZOxTnFJsY8wTGrDEc2QY+VGYyhk= 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)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 05tX11hy7o0mDrzKW1pkREUqTShMBjA+ZOLzCYz4OvdyRbvCEXeB+OCXFzVEF/siP6MpO1wVkQeF99xQPgAYKQHxGzhmjHJbsSBuG+AeMu/8V9h/s/FcoT/flA1m4keZ26iN+RLGk8s98KZer/4iCh5bMkDqf4qclQgqINxFLl3vlFblVCCb5kaaLV7I2bSJCVRK9qRPfkfbEffhqENgeMmsX0NihUuBtgjcx4eJIdwXu1c0TkltyzZRwEJ0QRhIUN8W3I8TlHb7tpdXj/XZ/Crk1/qpSWjpbkO/rjP8pk7IYisPNEz8VvN71e4cg/YwteFOnMF1o3cYbeRKHkkymi2kMaN8eZJnuqtt/jHQ3UIgw4WiFG3dgyCABICL8X3Yg6pO+WyrkYV8pKrLy3g3N5exxEsKtFEkaGSFvvhzqTW/7ODhfKDkpWgLGtI02WKHn2T+h4fkG5f21FZRhdY6BVI2GwVUk/tcc1/fLVb2lpe0QQZrtoYa3b5eB13MQo6t4/t6WRdlqxrXPJz+5lduK+r+ectDZbk3MAei39tYiRPntMmdSrXBHD+Go13ja+jWYHGS+2gZL452n4fbcZmjhN1Yy29Lo7UNKF8Mq4pizkst8DVH5hZEMzGJEXpCfFBINz3LiBq3sDpexCIjRTXpHBas1VNn74le1iXBooqQ2MtDnbv/+Dq0cbobtgq24oyrjctOLBmoy2U+yI4OurRBPKFCTti05UCl3PqbKcRl5sK4l7V6EBusXunCKDYCLA2Pok1HZOGv7vwW/BFubo7o8/zTLnzqB+rMYb7eDaqoQRxLOpyg7O/Uas2pPweYpQACKn5Xve220q+otdr7YRFbCHhqEA70Ro6TTrM8r0fRErioum1CtHKn64Fvf4fvFnFl9i2UpHraTDiviJf/4FnzIY9YObbFNloFjKp0o5htD+znRe3ErSIXIw6iGHXXE6yenQszeUV3bfDe61zrsNia3WkYXFDUVElNcYMmNdPt2f7dxQxz3BvOuyoGdqCdEnG5WhNcNXY5T/F61hKAQxMCihdsyGjHxd8RYx4VukycxTw4qAvrr9hALFta38eNhbieicDpGDjq8mdZx5ZVST7PY5582LcljgBC4QCazAxGL2NBF4l+6n04zsooHT/6PBFpS465fLpCelpQxv5Nn++BRnDtSK4RpgbFXCQ96CWl6ZJUQ6dFDNFDCwusKD0amcYJmVT2UPmhrulSkGSYZIp5VIzz5cf4LSVbfkfLm8PXSno5MyeoouXWswiBjw3xx/pSXetorIoW/ITY9kbsWepx5u8wj5xrk7mfJAYzfVfmM7wPlEREWWc8HnYA/szd0Q0Ees79C7Txz4+N+Uz4bFfLnuekDGrl0azdL8hTC+LJwWpvT3hrdngaV1v1kTZhHPupa4G1w3O32HrEwDT7W5/KYTZJh7vZcIDMZbNxVn1l1SQhsTg/MoofQD8zu4WI3cn+/909xKA5Alvh6I2T0tDDlJvQH3m1RyBor4ec9zzQOLUYcbR/SdYdghtOQDEMqKYOnE/zSYukycrEC5Fk8lgm4yM0hepupXBK5thm9qGGCTsg2LKIugU4yS4lVQUjLuMp X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1062b1e7-b48c-4602-28d2-08dd01f5b174 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2024 02:08:11.4943 (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: i6C7TRfgEbDmZLrFbeNZSOckuf/Du0HwLWf8eNcUhmaVJTEuFrrKx7bFqKYft+DX4fNaL32Q+rnZZvNbP9DDEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7745 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 --- v2: 1. Refine the commit message 2. Add Reviewed-by tag --- 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 502194317a96..87033317ca56 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -531,6 +531,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; @@ -596,7 +597,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; } @@ -657,7 +658,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; @@ -675,7 +676,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; @@ -943,7 +944,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); } @@ -3318,6 +3320,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, }; @@ -3326,11 +3329,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 Mon Nov 11 01:52:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13870181 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2055.outbound.protection.outlook.com [40.107.20.55]) (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 885FB14831C for ; Mon, 11 Nov 2024 02:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731290901; cv=fail; b=NIR5eQfjNEKmmwIxflE1coyBaHkA+PB1MwrziTdQWzeLxiQwE9OTun/dqnyDGXhTdqCoxHGj/iqQrwMx4xnuKBBrnhCX8qDfhexF9Z8aPf03SInre2pLA6GThPo7v/nnAMlUgpGNA7oqpcve0f2J4KIY/zMLXuDYrJT7MSJCLJo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731290901; c=relaxed/simple; bh=90OAde0W6CwTPU9ou4o6fXBFZZXHzoDnwTF4TE8wJq8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=PnE+Qr5cyInGFPLFRBRrpyRGjQLSMw79UjGGIAdah+OHtrG4DENd/vhjvivaLtnmLzUyatqSfcfWxXtDU30OUiBQS1DkvL1HINvmZ5mWByAmXTzLFK8p6IPEpLkfAaeLrWepQyEK8mUiwzDHdLR7Ob4zkmeihGcyR6W2C39Q0SA= 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=ZbCZu55X; arc=fail smtp.client-ip=40.107.20.55 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="ZbCZu55X" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BiTgUaCLxS/+PrICMfiKDBROZCZkhb95U5C4MXGcqcYunvOLq8fSKEhRu3of3RhXMLoKbmCpe3NJfun9cU7nkkT18UjmlLHG0ER3v9m/1yVfFhSh6nU4JI2D8qEochMAG4LD5Azu/xP6R9kHMc+wEMNT2xe60mjeMyDug3Bq4Hne77br8nCQzsLDgv1agoG67lUr3Y1nRyy8srfrmjxwv1O5QrFQZcJVoTuIaKO0rMOjKdLdUYpvTQrzP1AyyQn3u+e0KjA5v1qtzon/Ak79G2gNV8sdFm4lytvZvp2iQiJkYye9Uyvr18jPvNdS43wN94o6Dc/dZYIc6hbiHov3eg== 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=10DpXboWPMq5+j42RzAkvpoLEvqfUWZfWof2RGfeLkQ=; b=R7fCA2rsC0UxI/vCRMmOzoeoJSwu8SU1+ze4z9eX2iVrANL7iJ/VIOhN/yx9dXOyoHs6LNYYIAMZPp0rvEJEWToaJVWS7IM19kSq7+j08CrVa470mDO6PLopkoF40GAfbITn+eCTq0IJyTEAce5hCW6mcNYZlMYKcZlZ8hAOxDjsZosQ6+ALHE3srayWwPxrY6jt/mWmwvH430PVCBYhjgr1mglN5TKhOZHEKWzsx1arjqLRZjyIDcgGU5C1hlrE/37pAQWe3QhsNxJV81Od09kQyjS1T1rZTTPd+M05uHwL3vzKzzwimavYGCSC6bxwO+uu0lzq02BpVI+Ec8oKIw== 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=10DpXboWPMq5+j42RzAkvpoLEvqfUWZfWof2RGfeLkQ=; b=ZbCZu55XyTMYHsm4UfX/WR+W1j4OQ3b4LKSRMb4BTbcEcYoHl/6g/FYJ+DMgyXIShYKds5mSNEdNbFNT1mlK/G5jzYeoWAvC0v2j5v5gdUErCic7ileVzzp/virrdS5UsaNX79vD6SfZtti+AD+iG7bPSt2xSLCeEeMH0lYT0Tkz+VgzqUMhWCkH7vePSZAcHFx4NMarbyGRvzRPt13198b6hIrSeq7DlsixvoH4fDqmAXZBPRT06S1txLWP+0rxBWYvZyL0eG+MGEQubXb+RLsVUM2LZlDK5ChqNyKSWqWPS2UlOYjCS2O0VDjfAFjMbzN094ObvWr6OddUXo16CQ== 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 AM8PR04MB7745.eurprd04.prod.outlook.com (2603:10a6:20b:234::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Mon, 11 Nov 2024 02:08:16 +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; Mon, 11 Nov 2024 02:08:16 +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 v2 net-next 4/5] net: enetc: add LSO support for i.MX95 ENETC PF Date: Mon, 11 Nov 2024 09:52:15 +0800 Message-Id: <20241111015216.1804534-5-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241111015216.1804534-1-wei.fang@nxp.com> References: <20241111015216.1804534-1-wei.fang@nxp.com> X-ClientProxiedBy: SI2P153CA0023.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::6) 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_|AM8PR04MB7745:EE_ X-MS-Office365-Filtering-Correlation-Id: cac1f740-f449-4e19-ea99-08dd01f5b45a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: bxcB9X4VOnR2LYUjYNVv9CMdjakR9UAbe5mmyNX0IwX5NAqR2UUrAfxy2xsJgzhTzX0Yj9kq5UoAezZ5v0ul3WZrlKuLLzIZcumtuNdmLjOKTbV3Jin8Cj46yBjXIrZYxlu+GuW2QqSqE/4q5RMWPK/EU1aAEny2mRi+M5Cy5v8lorFyiOMdEHPBK2AZYVLx53faz52NCIVlA7oIG+NpFlNN3VwxrzhEca2F8izDyAPLtAXj3nBmVqDcQ/NytBe3bwr1oBTbsPiGVKi68WEon2aM4GGAsHEajqzM8ZYUkpXLXB8u7wLobOr7BXIOfoNGZpXbHGA56nz1vNPtBUI6SUr1iewLz0nnh0CMTYtZeufIMi2VLaTfwG/AeUrSjvfYIvUpAfINA9GD/VojP11qyF4fhBcewxRtbgGkWFT2eM8egzF/r9hZSJt1XgB7p6IKDgdS9Qx8MC+U3/w43Qe4wrM02fwkOS7ghhaHFoPzuZQ5nNgTZg+8sqry+bt/gJdAWg9XiqgEFba+/rllj+0Xjrqjc8hUgJlBp8em77el8qo5DVgzrNrwYoIMDbCrvFjPWMRqNtHqF78oomc6xxHcRxtb561nH3LwOAEhCvvlHePrqJ9SBeRF3KJw1+oyYbT779DwxG2M53fyD2x/63pkbYFPHvIx8qH10DR5FWLv3b8iluRraqovmIrI1Y+RTmH/L8L/O09fKKiEl35B7ay2XyMxCFRje1j1SMjA4943B9PlAKukNmelBWj1/3gO3FmPa7k+yuO06K5LsCeEPy2Y9M6wG6SBMHYzZRAHDTCjU0DPy1Sovsgk4yPnlWdgBVODkrS52WoIKtSfBVv9ap5iSV2OOexu8ryisyumtfEqlw/FsH97cb29G0HQsJ+OsSfW0+Zx63cNIUEOopA6Vij0C/oAyQKdOFH1i0w7rVgqgMk0+De9fa93rvW7aQe6DGCo0eUgrUaewcVLnLb49xg0CNVUi0TThXR92khAbLvFCicekKskRkObOsmCMDmco2ULQokFAnuUeo3/qRUNXsTzdCdZM7XcWQnKCaT98l5mt8zkvaxW0pgwLEGtgoyjSOlYUPc/o/m1FORo4CH1ejHlEjMEoJSAR3QA3tPGObqVan6AAdfp33Y4Rbi6pvNlPDcGzgjqPRmH5masFY0A6ojnlVB/IrCnRB0SI5cBjGLJKHeIgZKtvblASwbnTNTBS+vUtQkrJGQfwBgYeH7CppalqUZkEphF0vgKyF8oZDriO13DVghIuOsazRyyTI2WrFqVfNA68D7rq52xt1GLPOFl+0JFtaCVbAV6QceHX/4hIN3a1tTGYvzAC82k0HEnwlkxJPC4au7Q9d7hbXaVA/Ik3KCQwtit9gM39wqHfusqkOk= 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)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JKcC8bVFZg/G92BCIyAVQirqxAxUwRKixGgQV+0Q3iTKKrc8F68KARnFAy3ZtPd7QqOhZ1dHax9giE3XUPfHByk8W/wYsvBJhI9wbesfkI3UMyG7qoaAhDNDj1Qpp6AhkUaf4UU4GxFk1hzo0yMUBJUEYMOiirSMGYlKhSCl8GD0l9E5jy5rgCED3K9kSRTzHnfs4z2KwPLQF9rKA2t9blD2e3FLZmpqLxCQwskYhG0dcVaoVrCt/uNO0tNW5QE+fCCPMxxdIAbkqihmPLVGT1qIpvx6bOUyoOLwsFL+MsoRK86NhigJkom7KWM2GbpfjbukeTeBbE7sYiYPfZ93868ual7irI6fkh3s58Eri8hZUUceum/Og5p66sYyaQCOHc5h7FHf2WKjbq8S28Xz+UyipJMdQmH5UyzHee9uwxeHhCWLsJcqJnheoRUSuk/KYY7Y2RS6KFHJ6NYrxXVg7Zv/V/24TlXyffOu3B9PaGq7l9O//kh0EVmDo8TluW3J+2CdVV3n8V2dbOt504rH4W6khNk3WRqFQfTObUTb6PrRz7qE8TPegXDdkO1ylqoyF0+Vd5oPWn6/ilRskM9T9qEzshQ6xtcVSIO2M0uzaVEyJJHddQwnIRlEt5kkcgSd8qzzvrd17C+l/aGgPs/JUDppyLUHHFkKUAZMW+2DSBMPu/HhFR0UiW63PGV5+m1jBIbUE8+7P7R7Xvf8du+neEXy77V+LszThvzEHChAtJKfE66A5d7dgPaF/7cHDM2QpBUJyvfdsPYodtp+DDPZnQpaxK7Fb6PERsbPKkkacCsmnBAM9tLsIOSKPbDauHvSOXs11ALIR7sM/Wee2Ev1Xp07fXnxAy5efQrJj9yLBIzMLkAoQmpJgP/C+f2E+o9J0SZhz2cunXRCPL49dfGQFN4e+Js40ySwbfrjEgFAfd9xOjeZHRaZqYhDajKFPyDOeic63l79EXpXpXbmbIV5yqHVii4G62n4Tn4PkErbuQ4o/fRIQOxvO7DNF2NSK0tozW4d1kbCHe5yRJPMxh72Ngvq2c0LRkAz9Wt6E+Nq2RY2gY5Ikmy250Yse54PpaZtlRxQkwoduu7eV3e+ZX7jrdGpNiKlHB3MePDzYTCj2LGRsgX1vyBxZCh3NqF9WMEuY1lsSU4YjaG9cfF1R4A9RVya4qj5Rf8j6Ys8hZTF/ZrL97Rh/chPm7FMtiLzPYfX1+HG/4yjjpiuibYMypjLJji3hjDHAL+Z96sjaOEKfD43HLr7+EWUqndht6alyCmkmcrhAmAOSMMtQDPTYF7n8mTgB/9R24/MT2LFpGGz8ftvcfv/ow9M5KiVYPpa053nopifdUFqs4lPEjXjoZ8P7DaQgeSMF3tGJYK9+Bsb9fvSS5XdGxs88OdvVhgVyAYmq6I2F4ancUMRamcAyYz65SmC0FiMOq1XrzjefdN2p+8m9lVr2XijqxsSyY3Mm7NED+kOI2W6bYjHHBbzDLp/yALWHsAvMYQZV1pCgfAMj0lyuh6Fg9zcG9fX+nYBNlT7Em/m2YtNReU3EDfrovIDFA5+vSWuYS90WuYkq5rUW1t+zi+bhdRtq377fTDRVqOU X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cac1f740-f449-4e19-ea99-08dd01f5b45a X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2024 02:08:16.4901 (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: 4RgG2w8xPKhdsy7O1mET3ME0ZqropKYYe10/Z0aG+AzY5NUzX8e1Ho9Flm7LCp6T/9+GWWTdO5l6yayImHnQJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7745 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 --- v2: no changes --- 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 87033317ca56..45878b8f9362 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -529,6 +529,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 = vlan_get_protocol(skb) == htons(ETH_P_IPV6); + 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); @@ -649,14 +876,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))) @@ -1802,6 +2041,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; @@ -2106,6 +2348,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; @@ -2119,6 +2368,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 Mon Nov 11 01:52:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13870182 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2055.outbound.protection.outlook.com [40.107.20.55]) (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 2F0D414831C for ; Mon, 11 Nov 2024 02:08:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731290903; cv=fail; b=P+qfb1YpL7HkmwWQhAwZuYtXB5AZgonb0VL++3zYifGX+HAQBY8CFyho1QuJcq76QQ7x+/qJpqHqIFlO1CnDSy926c958oGWPTTbGUI8vB77E0jvMwwOSAR0MBIrMvkx4Sz2YJkJx/rlXDU01rZwpyZXW3l2UHwQ7zYHcxQDBHY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731290903; c=relaxed/simple; bh=LjqgiehF70pOTaA+fYQ8Epbe+yz1HTdq2u7K9bM73dg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=UwcMlDY+OaiREo1aHvLiAskNRAq/tsMh0W187OIy9qsgubRYG5tmv3i9bOYqQ3k62SRzK5Z4nyfphZ4LoqxrEYVI4DBYIKuDbbF/12JVyCHTdtQduVACSdHBuJgA0S9bboZJft0TImpSWsOFz6dEVTkn67qdrh8pw2nJJzHf+nE= 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=goi/eXtv; arc=fail smtp.client-ip=40.107.20.55 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="goi/eXtv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=P59I26Q/4TXGcaUEqcBP34eHqFkvhrabLDQUr5beMNLEKbUbu46G3eDMBEZqcyA+2X7Z898zcW3A9TpcTXq/wFzdH8YdW2/2TnGLMMICrpaKFVxrQ5CJItOQxCoT8JJ7PzrSeG2V949o0WOhDeQTu7A7BGxt7lvbIYriVGladtrYFKofDBSZoIO3vEiBGPRQRF/ay2OxkLHLNJVcV0QNnCpHs7zviIs9SM6G3GdjOYN8Ai+QSt7T/+u7UgGrVgm++Gps1NLwhpgSaV/UPS0cbFQYjElZrIr3ClzHoeKRxf2vZwDY29peseMnYOCe0IOBXATYeASnm529aLyj6Io6Iw== 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=scK0KinTJsqbTwKoDMiw4G+RveaMiwTj5YF/ayAhaO4=; b=Kv5YdqI3s5/CvbOJWd1mXNyxYoDx9nIfH/YxE66+ECxcoO/JUD7GTlBTapinA2N9z2ZfzBwTxtr88eamHUtTUJySAvJ3rzA9ufvvKjlzbvGiZ+mJ1q6M49wRPfr0BOmr7Byt5To1d6qbWoUgod8A/gpRpseTD/w6sKY5BpLaHh4hDpy3pEqN1xQYeM1vSCyWKzum/BkFbkT0b/ucWKe2ALikeGGFtcQ1FKjXPM4GFYd5YuzvVUlFKNly7vCO8fKe535Ra+PJsKbmMfKYFQCX5+rx8o3/L4aPqCk/nc2BVRwz3Bws+znprtqoC3tieEeYXCllatPkiKlXLf07x/RtnQ== 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=scK0KinTJsqbTwKoDMiw4G+RveaMiwTj5YF/ayAhaO4=; b=goi/eXtv6PATtzmrG/sq4smgiX8PKNwYKDuEptg8cZyU11mrXibcWVRTf6hV7d6RbBDhtI1R1yH2SPybXTDkC4Q7veDX4ZfGwfXwUZ8eTrBlCw5utbe3hyZJ2uFevZcjwJJa4WZxqxBpGnSYK54mtiJCJrLjN3QJoUziLdXp9hWtnLvK5vXqHIMV92J9doouBUyesNHsgI08mvDw2KghWxT0Yfetwk3CAfO9ntbhNQlcxvfPr6l1lak++Ca7Bfd+xx5Hio7PKXjX6khvwQY3CNdVAM8DV6xwNCyXeapIalUNwY5AaAdXi0Id3vuUxhyxjVONKem1R7PfG74azwtPkQ== 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 AM8PR04MB7745.eurprd04.prod.outlook.com (2603:10a6:20b:234::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Mon, 11 Nov 2024 02:08:20 +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; Mon, 11 Nov 2024 02:08:20 +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 v2 net-next 5/5] net: enetc: add UDP segmentation offload support Date: Mon, 11 Nov 2024 09:52:16 +0800 Message-Id: <20241111015216.1804534-6-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241111015216.1804534-1-wei.fang@nxp.com> References: <20241111015216.1804534-1-wei.fang@nxp.com> X-ClientProxiedBy: SI2P153CA0023.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::6) 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_|AM8PR04MB7745:EE_ X-MS-Office365-Filtering-Correlation-Id: ef6b4985-c662-436d-f72a-08dd01f5b710 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: KrXjtfc7gVozWT8NwHvGd5MNH8mEIRFqOcdLQHWi5yo5CootAwkdzcYx4OjT9X5KXpUU6O7JIG3Yu1z68B99OD33hd/lONNg2Jtod5tseoeeUStmHbfkiMMO6lx3YX1cN0btGrWvwQMQ4QNhRtrDBl07lbgiONSeax36w8fHupdd6szqwhE35lUIsin8tV+loEOI/iOUea5P87OrEAJtbr2h1ChbG3u+5KG0VNGB2IvZEnepIiaW9XdlhCUTKSCs+edVdQ2QenksG7sOpj1fqRzOoPqDx1uReJCpz46zxGI9QSzRk8WQY0893eYQgOYR9eokSts0ECuvsucZLq6DZQ5H/fEWE8CcE2LB9baugGwAr6Ids2gZj/yypxvXQgk0dSWAlpcW+E7ydQeguLfVIhARWlqvUy3VMj9qvZSbkkpccdnlWiiM7IJqg7ALufrOcnQbMWKmWUiIAxa9yFI6t1ZdV9oHov88P1btQvQ/me1OPkOERxQcckEBvIhQZFvujTYgSPmfAE2sNh8WBIjnJ0dl7Vg2gdZRCcvHk2eFForsbseeHGvfEZ/ckxTJ5iLNH9gZPx/GtDd7ukfx/4KROFoPReB1vjrcpV80xhCbAZ7ebBF+vgDVoUDwx+9Mcys6ZBMbkW580Gwdgx/HxC87T6Dt27/8P1QnHAn+jw5gURnHtHlTNpMFKaoWscdDmXvGXMJj/oUCvrRZN7DD9c7Cmv122zECNf1/wUmbWpLy2TyOCw9bMpdgEfgO4HjBkebkGsSvRB/vG5rd/ZeR23w8X7/BcoVxaAVcW+ulu5uU6EkngpXLoPMurtjUlrL6JBDebIlF983437aRI9Vfong1sBLOGTFAONwK3BIg+qDtgXL1NDK2uVX16gqbb4xp5kY/ZBgBTLs1g2iTS871K1/T4ryFmC9YhUolzT5M9tCTeWth0+MM0V9t6rREhkM6Ipl0vFq2QrFGYzPz35mYM9lmiDKbl7Nydm07xruLKMoJWigDmDg+w7VYJ5IWju5ysx87oIJ5MHosfCiaXtq6EmRSX3XUbfqzmnFianys5j59U/xR8DBVpfPqakYC63O7JET93mMrtnFQf4Et1xzbsMu9nqdojVqSE9OiQi/9hux5fTXW3z127vNM6zU9H36b0iWBstuCQgICM/EJAhYDwcSKRM9dtbDzn3plfe7lgeCsoi4Y87VudBu9C4FGw8v1Mf3htA0tmmOyKP0j9/f0pUHdlm+dlNaXZH6L1KlCbsFGT6ym+V+TPE3GWtr3ygHRJug4tbhczAve7JwlMNMsu8HhAnjqMk6xkh3j4zf+IiaKvbpK/wOVlqPz0A/fiVdcbOHe6oE3RpR7pWbMS+P+Bwt6orbB1xnj+RaQ9ZIMPOYEQqk= 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)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CSa5YGxrbp3ni9nDNzQoeEoCrpiinGqIqWFFpqXox3kNSG/yV9XECElxjfJHudMAtVdp11uqqZJC7FDMPAQtbISqpv8P2YQ90kH1nLhiBgahEOsPqHY+0cEu9CtTIqnrDfxvo1fzlc1gDoM+5PT+x05LghxGPGCqgK1uoAND310f3yWfz7x0tgSGkQltK3Mj6Vve92HaQ6HvrpwQzpVwdlAUp4d3WZuA9WQmwlwU8SYoMdwzLrASLzCEZtkbLklk80gup9jx60Ry/cSwskKXMsZAof5nQX+S7MfCvMkPif9j2tNCRp6zd0/Ckyy7ralxN0Buby189UZM/zLRdmWuaOG+LnkLQImF+bov2IYonVOlPfJ932DupB1NaL8dXWRk44zqHe0iVZ2MaG9nnBmxnAXw0sgeEI76AORymNL1uWVNv+OVKZ+Q64WZA+ndmaC8bvAdGJYVarVWytcXAsFwHR4PVNPb8iRvH1pJgC0S7/UYJ8vb0VUbXCiW9Z+jphck/WbzjHIjSSalLzO5EYHuSfatoxbYA84oyTpVg2UmggCSB+/raj9vMcfGWXg6zpx7sVxPa9Ht6BagMvEiQblCntykdh5h/bZhC9soFduGacu3hcvJvZ69VVEik2cCryGwUQ/CERklcy2z95HUNf9jCRMPsDQjembzIMDFaS9eSn3cukzJL4JNUpqegr1j4+0kwXJOwnCpz/aqTFokA/Sc1h6ezX6iNBc4DXcDRbYvSyVt8KUib01j9v0ATZHh2D5EqA/fbHfURFnB3ZSbTaQsCxIC3WcjDmfXEYiZyDBy+KArJ91Q746JRQLAaRtIPmtrqY1EVyooUuvnZellsN7u1qP30bPP3jaNVyW+4KF8LI1ZrCRv6uMn+Ezo+7Zv5OJc5bVoOaEVnQX3HTLUl8DJts76IPdKsjvE+g25DzXwWuay5I61VSnBeIdNDaUlrzZFdYyDsGpuw8GnjF8RCon7LMMA9til0FjkffrL5SaYlW8xiKBQ993Qn+cU20XMYsH3odErUboBqM3y+SVeDyZPvxR2IRMq/UxxKvW+z8xOiqjgWpXWmu3MzS1eO72ryMrSEmetSR8Rfr9iiDmuAk6GAulGLwQnSEM5S4ibX6GYP3Q3cXPhg4YpZVLS/uYRJB8UpfCkDHYL4seyNdKfz01SdfXLdGcU6GLl1M9jXxQgTXNxbrHgTovHHs/uQ2nfLf3/I0stMJ+K+SdgFHvP2EMkGNSztRg6IgzbrU2Q+uZwY/Md1+fDJraJLRX59Rp/MZqNA1LICYk3CDRiKHcYL7GQtbwoVG+eZ0wk9Ok5RkwS7ijyD38SqBVlxNWSMB00el7CWRYkueKUi8dCzQ19sFAKLTWHNLAEzBreosT55Etvgoo+VnTqjON7YUMqbYa67Dmm4TCVZA/G0FvMbx2d2aP6v1IzkEr1sPCZs2aQ87UKmt5fcMFzf0eympkDgXPm5ZEI2mRtCBW4p/wURdl3lBuUxbjvpPDsM8RqBEL2kHUkWpdwTz2cRNa0JwmOxVn/RDt5V1suDC6SddQbOfXSyoYDNDHdv/b/gR6AoxVkB9bM656ma8pm3IhyQNBrb7ToNB7D X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef6b4985-c662-436d-f72a-08dd01f5b710 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2024 02:08:20.8295 (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: qTstDHTR+uWJ3ifB8rIPF4+6HVLd/H849BwgGTbWz2fBPrALIPiVBeZHevkIeXrlEcS8BkHoe8FfGrJCZGEPrg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7745 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 --- v2: rephrase the commit message --- 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;