From nobody Sat Nov 23 11:31:47 2024 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2040.outbound.protection.outlook.com [40.107.105.40]) (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 2ADCD14830C; Mon, 18 Nov 2024 06:22:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731910943; cv=fail; b=BVOayY2OknA+I1YgxZmGEh0Hrv+/e4HFYv/Drurqsz7YqwBKvon8g2RxaP1l5sxWrpUy/4CDEEvsSaRdGnx3mkMICCJk29rwdBIbDi0oxTnSyDiwt890lhYbRV9aA0+fr3cdrOiBN8UJ0qGbtYT8W1RmnukemykRv3NIyHq9PM8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731910943; c=relaxed/simple; bh=aqhWNWDIxxhXGramADdKy+U88193GWHDHuY/Dhqm4tM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ts+Cn2+O/UdZq8yTMsujlYztMAGjxBAqUyZJ83QO7MHi420dPIZ18bc/TRNeq8lTCiLz3G+kTvQqlHwaPc04133SkfWmkg6TT5V4NJ6A+eHh94GIuGsxs5P0VotjRFhGX16aO2iZvHcn52XorJNvRegdSR3avoshsHdBLrEFP/k= 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=Q9mH5bBi; arc=fail smtp.client-ip=40.107.105.40 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="Q9mH5bBi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KorvlBMy7YcbkxzpGmf5BFUiDaM38vzfeHGqyPY69DYjDi2ytfPv/E4ELwaYewhYNcv6vUaosQPQFxyr1AmlM5RNupyJrMExC5uwoNWK7xT3cI+ojboib3Nl9hSYrBpPLbs5W3Pcd5G7LFc7bhRINELzKSDyYvcNsDetZPJCCUfHB1ifosAeC4FUF43ogc2xciZBtKvZixWsBkzfoY6vW25yJ1KxzBSrwLO1TPoaTsUH2uXw/UbDnfx2po/NodiHoxvxA436Ed/OhYrILba4wm538+RrWU42hir/6wOuWC3aDOlvWEO1fI9kFBE5rIVbMgvsTCuHu5Di+lPrHzEWow== 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=WFRKqyrcnNeg/ky4xnpikrrjOl8BV/aWrWZ3k4bHFp0=; b=y0bzKeT3NW/CjQpV4t3hn65wvfEzwfjyb2fYcynGBKd0IX5m3r4MrA5hWZW4uaRCa8nfYSOYD/Df2FGNWD1ipkS8SBuG0DpSb8l4gibtTGLXF5tVTq3hDu2jLDQn3tCLhOuokvtxlFzKZskIDLmWXZPWIQr7SOrhaXoczkd/W8lzSbRid80mRBtiYAVOMsrQM4JgBKhhe/djO5kUenKWOLkWmJk4+O+BTxWA09MBJkAQtphdGsNRjZv3127C4SF5HtDnjpIIJuua3wKNlr+z1DwnqBaCeIwljgp6v5WYRwdjy6FZyQpmKNBiJTmCxC+vuhIsqR5rgGnckbXDRNrJxQ== 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=WFRKqyrcnNeg/ky4xnpikrrjOl8BV/aWrWZ3k4bHFp0=; b=Q9mH5bBiUGsz29D1rAGlYHr6MoxkdPR6fOG6XpCtWm0F0EAkWOBMtN4xO6cFn3VpCq72nJkRaW1hWChMfRQ0hShwS0+b2y0QPVO//wg4KQbQuPJD9Lxkl1m4j26qb2jrbxkWtmSNny7rd4OhH9Q/2UvSDVB3U75Nu6z2bxNdLpsu5ug1rwX5xwCr6GvnN+LZPUPeJY/RVFaFqcBpX75insL7SB33Wxp1augq65A3sTdddLNnPpDhwuNkeojM39LJfRvOrpfgvKD6QcdizoLlWT/nW/Fe9rKBwPfDM0UdheOnr+vFVBQfH4M8dynwnqbYVt3dqdFyBF0C2RzQA0x3xw== 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 VI1PR04MB9739.eurprd04.prod.outlook.com (2603:10a6:800:1df::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 06:22:18 +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.8158.023; Mon, 18 Nov 2024 06:22:18 +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 v5 net-next 1/5] net: enetc: add Rx checksum offload for i.MX95 ENETC Date: Mon, 18 Nov 2024 14:06:26 +0800 Message-Id: <20241118060630.1956134-2-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118060630.1956134-1-wei.fang@nxp.com> References: <20241118060630.1956134-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2P153CA0007.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::8) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|VI1PR04MB9739:EE_ X-MS-Office365-Filtering-Correlation-Id: 692365a2-fa28-4e63-5bea-08dd07995a1c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wDNpCRTcA1OwS9jDDcdxdDtGbOQ8aN64fZcl4Jubn7GiaM7EjJoKuMQRyQVQ?= =?us-ascii?Q?+W2N42NdTSe1S34wWyfe4JEpYTCRzpkjk+NIbrMb+CURFFIPf04H9eyVoNEK?= =?us-ascii?Q?ZAhQsrwMV4IuedyYFJrwWSmi3Kc7JhfvcvQiOYe1J/LkXNtAwz7G5CyPua71?= =?us-ascii?Q?0NoZoVovAxc1ux4fkp2YVjekAqjU+H8xTLxQyahpOuZ7eOImbAQ/LTnzcbEX?= =?us-ascii?Q?pMZlmMJYQU3ljTa5KCPuuGpBDrzPwayIgjHNZ4Jai4zGIKvbItePqdAAKHTA?= =?us-ascii?Q?NRloW9VxXQRAXaU/lLzBdaE9JyvReZc7srLh6rcknc+J7+9yN1dGYqGYB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5EbXhY9SisPddz1OFeen+alNApTSoJ5?= =?us-ascii?Q?Bw3CoBM/fva9F2BOLAxy1c6TH9/rEkLP1oA2MRu98qEFMS29KEXUaXdYPB/y?= =?us-ascii?Q?G0FwtRecL0GxYDMo1+uHanyKEemy4cIgK1XN3508gJUmo9ooqtaymxsacokK?= =?us-ascii?Q?XeNmAPw=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?GjB0ESlT+6HxjSYZVOZ4q0MbPtjuSG3MTjtmSZplTj77CN19WUyV919y13qA?= =?us-ascii?Q?IBHA+1CxxW9vvTbpGceBOGfc5WSTUE+UoBEXwJV9+f/qVg82xQex0UxufdA9?= =?us-ascii?Q?1nwWTSj9WdZPJe0Zy6/7K0rIw/rE8Zi3j4tuq/+JeMzHfDPt2jI48j+yCzBv?= =?us-ascii?Q?XAX/GHo2ViFrWks80PXzQ6EWakv28z35xMAnLIIDPuoI1sIBx0CHsbcbpMlO?= =?us-ascii?Q?32Vk/W1GCpnmx1DvEcADx0m4DjLQ4W7exuUtbq54w9M8+MB1I4ByGmQe7p/T?= =?us-ascii?Q?x+HLKxc9tNfuiNSYvceMgSyIQePYXEW6QBZdM/6lExTMOgthqe2Cdb/fDVK7?= =?us-ascii?Q?/AVJhS0gzY6ffv1w/LV0VHw0RmpiPrVzlvEPlL9PRwi6e+HoeUCErs2/vFHn?= =?us-ascii?Q?lp4UkK6yERCY+ZkVsLwieW1W9+G58nqJ4q7eXE7FYerSQXBqH1FBIROdagAJ?= =?us-ascii?Q?xSo5xQsYOKiH7X/yy1iTOOAZiEy8F7whgOUg5Qu5CoZh+CQSn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+2hiasICPg+iBee86N7SIxtYi4pk?= =?us-ascii?Q?x0VK4l7AhimlorlE0NlAOCDg96QsMYAJmaoP2SXwWkud38Jt9ajMDQKbV70U?= =?us-ascii?Q?AKl7uQrK5yPQI2Z0I7m3Co1CdRTDROcfjuzRbCgvR4LdtSCaoEL6ZIfIVhkK?= =?us-ascii?Q?Nbd4TOc9OLG27mN6jLX1BXfnktur3iQ62eVvtY0x?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 692365a2-fa28-4e63-5bea-08dd07995a1c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 06:22:18.2038 (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: tAptnOMA4hJ9eIlAS0SGUFG8H5VP1uUFguluD2Fh+UCW8mtdy4mHpi2lU/VOpM7ah8yRTFnGajEazJNDQJduNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9739 Content-Type: text/plain; charset="utf-8" ENETC rev 4.1 supports TCP and UDP checksum offload for receive, the bit 108 of the Rx BD will be set if the TCP/UDP checksum is correct. Since this capability is not defined in register, the rx_csum bit is added to struct enetc_drvdata to indicate whether the device supports Rx checksum offload. Signed-off-by: Wei Fang Reviewed-by: Frank Li Reviewed-by: Claudiu Manoil --- v2: no changes v3: no changes v4: no changes v5: 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/eth= ernet/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, =20 /* TODO: hashing */ if (rx_ring->ndev->features & NETIF_F_RXCSUM) { - u16 inet_csum =3D le16_to_cpu(rxbd->r.inet_csum); - - skb->csum =3D csum_unfold((__force __sum16)~htons(inet_csum)); - skb->ip_summed =3D CHECKSUM_COMPLETE; + if (priv->active_offloads & ENETC_F_RXCSUM && + le16_to_cpu(rxbd->r.flags) & ENETC_RXBD_FLAG_L4_CSUM_OK) { + skb->ip_summed =3D CHECKSUM_UNNECESSARY; + } else { + u16 inet_csum =3D le16_to_cpu(rxbd->r.inet_csum); + + skb->csum =3D csum_unfold((__force __sum16)~htons(inet_csum)); + skb->ip_summed =3D CHECKSUM_COMPLETE; + } } =20 if (le16_to_cpu(rxbd->r.flags) & ENETC_RXBD_FLAG_VLAN) { @@ -3281,6 +3286,7 @@ static const struct enetc_drvdata enetc_pf_data =3D { static const struct enetc_drvdata enetc4_pf_data =3D { .sysclk_freq =3D ENETC_CLK_333M, .pmac_offset =3D ENETC4_PMAC_OFFSET, + .rx_csum =3D 1, .eth_ops =3D &enetc4_pf_ethtool_ops, }; =20 diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/eth= ernet/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 { =20 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 =3D BIT(9), ENETC_F_QCI =3D BIT(10), ENETC_F_QBU =3D BIT(11), + ENETC_F_RXCSUM =3D BIT(12), }; =20 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) =20 #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/drive= rs/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, =20 ndev->priv_flags |=3D IFF_UNICAST_FLT; =20 + if (si->drvdata->rx_csum) + priv->active_offloads |=3D ENETC_F_RXCSUM; + /* TODO: currently, i.MX95 ENETC driver does not support advanced feature= s */ if (!is_enetc_rev1(si)) { ndev->hw_features &=3D ~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK); --=20 2.34.1 From nobody Sat Nov 23 11:31:47 2024 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2057.outbound.protection.outlook.com [40.107.241.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 6C09B14B976; Mon, 18 Nov 2024 06:22:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731910947; cv=fail; b=YUSsuIWDGZF16gFD3DfueuGO20d0acQ0CKYg89voQ6XajXoTiuz3sZe/Szk0j5tq8QJvXVHBeIRoeQGQGP4dEjFiDgdfuHXKNjDSZa1vroh7pL97sfghlA3MwskhN6rb46r1QIIRYsl7WX4JSGG3+pl/zH3aSyT0kZEoIlDNRHg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731910947; c=relaxed/simple; bh=jiMHE4X8F+B2nXCbXCSq+wHndX/xHZEc297e8Qm+2WI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=iiViRE/wxqnOQ1TtqHQyvMYE43p8YdrhO2UaneCkg2dQMdQ4h3MClkn1Bg6E8DzA0Wl2NQ6VcQknWYwHbK+VfMasmNPXepL8ZCjNVxQMZnM8VUP5xk8FvnCeD/fUlffcDYshDK6u5K+/hwhFSbNQ3M6V+K2WGl35FHFDA20JcCg= 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=FM82sYh0; arc=fail smtp.client-ip=40.107.241.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="FM82sYh0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FWuNRVDTZw8BcseYbv0gsukN8GdfG5kC5eZPK8BGA7TfSeLAWmRhe5hElF5k51Vuzd0q91w11H8e7ghUujTBSVdcIPfE1DzRWacyDvV3pKMwlHOH1a9m/8hOlhXCnXNIEGHC/s6i68AB6eBekQ84XSgY/01RgL77IZXNfx+ficF80anj9xPDnY1cpp1woslmM6qzFZ2l9TuyO1pnC/4deYLm1nZBCjSp7G1lnNH3hzQuXM8Y+ymYp3ykkyY4amh00T/GbpZ+kc6x8CtbQ//AHxfrpB7MdC0wE/bLhVdX373K8xaXViAPGDWE0GRO6fQOnY5GFCJsc7PhHfg0lnNNow== 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=9mlCNhC4y7y5LLKnK+1q4fmiM5iXD+n49KHonHzpNnw=; b=sJPq7CC08VRWWU4A0PsERpNbh0/6DJJ/2+U14G5m2s2qF7zvVntaXGZkc7BvdqFxfAJ6Lr4ljXLGtNK7Tv1cd1VHxpYx6yvVar1gR5pmEncs/p2EIsf9l6CaYix6hf/0O0ULtvRATtibNmJqhuIwd1p+PKf/wofZlXi8YfWsJLVY8lebsyOnJiDsdZMs+Evy3+ytm85YvrLI+LQq+at7/t+qJTXAO7Gt2Mo4Pwr8ZFM40dWyvvc/swceU/WKDnELkEthY2yRYlWCmnM8sSL4WzOt1Q/eEekXdzGDDuDOcs5XajIdLiw1OmzcVA80mJ6WDzbPo7DWFYToPcpK5/zOaw== 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=9mlCNhC4y7y5LLKnK+1q4fmiM5iXD+n49KHonHzpNnw=; b=FM82sYh0a111zWB6AyT3euAOEhde6pdIQ26GlHBVqqDtH4FDHcOZCGrcni4UhPa2WLq5Wr66xrbJO6SFVXvLvVj23NsIe8K2kRY0KP5fGdRsPgMtoQrRC5KhwCtcHpGqJgPJ5RQbqhHM0flBpsQTZkCqFLsxuPQ3Zjy+mFxiPDYVdKjrAzbP60z/TmiLyjF3Z0Q/DJvgJwjMkDIrAM2TXYKvZHEIdBcpP8xhMX/t2CP7Xx4eYo6qESinewws8yG7VLBG+kk84G4bFrSIBA1Usjm+uPY0mxNzXiyPgpI2fkCfLhqeovX9stk76b0b950YZdMxLOD7xGng5LhevpXS2Q== 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 VI1PR04MB9739.eurprd04.prod.outlook.com (2603:10a6:800:1df::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 06:22:22 +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.8158.023; Mon, 18 Nov 2024 06:22:22 +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 v5 net-next 2/5] net: enetc: add Tx checksum offload for i.MX95 ENETC Date: Mon, 18 Nov 2024 14:06:27 +0800 Message-Id: <20241118060630.1956134-3-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118060630.1956134-1-wei.fang@nxp.com> References: <20241118060630.1956134-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2P153CA0007.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::8) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|VI1PR04MB9739:EE_ X-MS-Office365-Filtering-Correlation-Id: 385aecfd-2b4f-4d33-bb87-08dd07995ca6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?fnbWsTdn0XY+BO7jOJuu5/9TVY5bVb6URj7Z1UzpN47TgKAUP1psHn/NHIWr?= =?us-ascii?Q?KeMcZDJIW9CG/SbIyYDJlWk3LBFAyOiq+VbuEg4WiAtbt0iTAtsayXlLlJUb?= =?us-ascii?Q?F29sZ4ONUrN3f3rnORuM1xDR9L2u7qgflWyfH72JXfjzoaSeNVevL6Ztgf6s?= =?us-ascii?Q?upIo0JSey/GtfbU1V8gHMdsRPbzysfpyl2/Wd7IkDfkDZGmIfmNHJ8EzEAts?= =?us-ascii?Q?RmkDl3YJQGJdvo5Rm3dc4MKIVjtny7WWxaDEc5zGJ3+ot2bcV2PCRqWZ41ay?= =?us-ascii?Q?ldUssB8sP4un5Y1ADfhc+pPu8YD/1zlp7SZUngKUP5giYju16tV3BkgbzjcJ?= =?us-ascii?Q?JhsBuGh3v3JXRUpZrzZk5J8lXb75iJWKQQYEQQ3vOQwWNJGDA4HeB0EORpeK?= =?us-ascii?Q?NycgjwfFI14qn5LLyTMeJZs+pl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k?= =?us-ascii?Q?P3ZuKD+43JKyvltzsuj2AEPX9cL0DoGHG3xndjtI+7otNWkolGpy7ONVD+h8?= =?us-ascii?Q?C3hCwgA=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?6NibOdPDgTKPOaKgcSUgtnq+WBLqHJCg8LfjFgkmh1Q0ZJlDLuHe34EDsFrv?= =?us-ascii?Q?sA2qryS9xPnBFJT3w8HC+LK0oMgoelGp3QL584m9z3UP6ESivA1yF2tAKZI8?= =?us-ascii?Q?hdxG6if3Il12YOb2fQ9mBWvJv5lis+yRBUQQUBaHO1mZOe2yHXf5oAVfexuo?= =?us-ascii?Q?pgiwBfpuJLrfJDRva1yA2YXiGifdCOpd6gk7TZ9xFfPyd2SD43vPUYVRCY/m?= =?us-ascii?Q?2AbsawZmjiZg/bDcjN+ENuqxUO0XthsSLpoIi604Cjnd9FUO3vWobgiDyL2w?= =?us-ascii?Q?tMh+/zwvIjGfALD7XSV+bcs9/MgahS9HdtVAfcUet6bTLLKG/9WvrlY6m/5R?= =?us-ascii?Q?OqbjQ87FxaNN3RcrKC1657dxISpR4xTTYsLWzGF7HUHX3oajyADa0EMER/zM?= =?us-ascii?Q?H42pweNgsm9yua0srueK70w5CedtyP/QVHxOZ8Qak1wMDt/cOuS2hWo/QCuG?= =?us-ascii?Q?cMjqZrUYKKXhUwD1fBZZp/xYvviizMkCyvtJC7tn+MDMIjPdPl+JewrJ5X9W?= =?us-ascii?Q?HY/4GQ/Bh19Tef0vQqzz6P9La25ebrw4OnxJU2pkp5SyQryePWghDjhn3P5o?= =?us-ascii?Q?1VvwQOzuXE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us-ascii?Q?Fc1q6hoNVgJnMSLUErk2JSKpUSJnDmAqflJRsxnkE7KPoDwJactaHLeQWo/Y?= =?us-ascii?Q?9cnA+J9TbzWwDFZEqm/aAfgPqNx0ZsJtvMKlZbod?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 385aecfd-2b4f-4d33-bb87-08dd07995ca6 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 06:22:22.4125 (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: s0yhuLq6zXBD+C+MbQ3Q7UlxMuUJJqQTIrEAdMfh4tbQFWmOT/q92+c3luPL9F8vBgqcG+/W8Jp4hgfcO3WmrA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9739 Content-Type: text/plain; charset="utf-8" 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 --- drivers/net/ethernet/freescale/enetc/enetc.c | 47 ++++++++++++++++--- 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, 56 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/eth= ernet/freescale/enetc/enetc.c index 3137b6ee62d3..94a78dca86e1 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 *ud= p, return 0; } =20 +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) =3D=3D htons(ETH_P_IPV6); +} + +static bool enetc_skb_is_tcp(struct sk_buff *skb) +{ + return skb->csum_offset =3D=3D offsetof(struct tcphdr, check); +} + static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *s= kb) { bool do_vlan, do_onestep_tstamp =3D false, do_twostep_tstamp =3D false; @@ -160,6 +181,23 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_rin= g, struct sk_buff *skb) dma_addr_t dma; u8 flags =3D 0; =20 + enetc_clear_tx_bd(&temp_bd); + if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL) { + /* Can not support TSD and checksum offload at the same time */ + if (priv->active_offloads & ENETC_F_TXCSUM && + enetc_tx_csum_offload_check(skb) && !tx_ring->tsd_enable) { + temp_bd.l3_start =3D skb_network_offset(skb); + temp_bd.l3_hdr_size =3D skb_network_header_len(skb) / 4; + temp_bd.l3t =3D enetc_skb_is_ipv6(skb); + temp_bd.l4t =3D enetc_skb_is_tcp(skb) ? ENETC_TXBD_L4T_TCP : + ENETC_TXBD_L4T_UDP; + flags |=3D ENETC_TXBD_FLAGS_CSUM_LSO | ENETC_TXBD_FLAGS_L4CS; + } else { + if (skb_checksum_help(skb)) + return 0; + } + } + i =3D tx_ring->next_to_use; txbd =3D ENETC_TXBD(*tx_ring, i); prefetchw(txbd); @@ -170,7 +208,6 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring= , struct sk_buff *skb) =20 temp_bd.addr =3D cpu_to_le64(dma); temp_bd.buf_len =3D cpu_to_le16(len); - temp_bd.lstatus =3D 0; =20 tx_swbd =3D &tx_ring->tx_swbd[i]; tx_swbd->dma =3D dma; @@ -591,7 +628,7 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb, { struct enetc_ndev_priv *priv =3D netdev_priv(ndev); struct enetc_bdr *tx_ring; - int count, err; + int count; =20 /* Queue one-step Sync packet if already locked */ if (skb->cb[0] & ENETC_F_TX_ONESTEP_SYNC_TSTAMP) { @@ -624,11 +661,6 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *sk= b, return NETDEV_TX_BUSY; } =20 - if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL) { - err =3D skb_checksum_help(skb); - if (err) - goto drop_packet_err; - } enetc_lock_mdio(); count =3D enetc_map_tx_buffs(tx_ring, skb); enetc_unlock_mdio(); @@ -3287,6 +3319,7 @@ static const struct enetc_drvdata enetc4_pf_data =3D { .sysclk_freq =3D ENETC_CLK_333M, .pmac_offset =3D ENETC4_PMAC_OFFSET, .rx_csum =3D 1, + .tx_csum =3D 1, .eth_ops =3D &enetc4_pf_ethtool_ops, }; =20 diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/eth= ernet/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 =3D BIT(10), ENETC_F_QBU =3D BIT(11), ENETC_F_RXCSUM =3D BIT(12), + ENETC_F_TXCSUM =3D BIT(13), }; =20 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 { }; =20 enum enetc_txbd_flags { - ENETC_TXBD_FLAGS_RES0 =3D BIT(0), /* reserved */ + ENETC_TXBD_FLAGS_L4CS =3D BIT(0), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TSE =3D BIT(1), ENETC_TXBD_FLAGS_W =3D BIT(2), - ENETC_TXBD_FLAGS_RES3 =3D BIT(3), /* reserved */ + ENETC_TXBD_FLAGS_CSUM_LSO =3D BIT(3), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TXSTART =3D BIT(4), ENETC_TXBD_FLAGS_EX =3D BIT(6), ENETC_TXBD_FLAGS_F =3D BIT(7) @@ -594,6 +599,9 @@ enum enetc_txbd_flags { #define ENETC_TXBD_TXSTART_MASK GENMASK(24, 0) #define ENETC_TXBD_FLAGS_OFFSET 24 =20 +#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/drive= rs/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 |=3D ENETC_F_RXCSUM; =20 + if (si->drvdata->tx_csum) + priv->active_offloads |=3D ENETC_F_TXCSUM; + /* TODO: currently, i.MX95 ENETC driver does not support advanced feature= s */ if (!is_enetc_rev1(si)) { ndev->hw_features &=3D ~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK); --=20 2.34.1 From nobody Sat Nov 23 11:31:47 2024 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2057.outbound.protection.outlook.com [40.107.241.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 062F31474BC; Mon, 18 Nov 2024 06:22:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731910950; cv=fail; b=Wg4DtLmuOdBvxkSSH3k5zJGalmRZpK1LJ2Gr0OPUMT1xXGt2yHNgA5O9bz1740pzvR56yNxHmCH4pcUOAW6wZxJC2woT/ccHpD61oK4RjF60+cfc2tPpGLrSDYss2XgR/IOCgTVa/PDen7m4a4X9XYKG6WIGNfHdoRK4Fcinkp8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731910950; c=relaxed/simple; bh=0qS9EczlzVw7aBsCTfr4v8RQU5H8KeNqOfnwAsp/AGU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=YCcdCYfGUDlgxaJ+AFAUX6VgcjzJEVLn3+kuCCfQqTH9oIAyUgsBbOYXANLNCyMuEu2TvxeLSzuP1iq7S0xTyGlVMKs6J1vNfuhyWHkB75S7D+7Z+GQVMBwlg2O1m7c4kPYz05pBB2KQ3NNk9A5V6zyzI4Knh3Z+IEGvV5wuQ04= 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=ffpP+lHb; arc=fail smtp.client-ip=40.107.241.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="ffpP+lHb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uU69RyP+ahbFbOmQwKw78svH296tzhn3MP9RpqDxv8972mgj2zAtLzV74oqeopVQgVFMe8YxJbcrfB4awUkIlWsdrapE1QVS+zrxHTqabUhj3pksnQqITgQCyKMfRlpYK+PxWbCYvQRlozF5pBpTtjn4L3ZamIUKl8EMHT6u3JO3Kn2JegEaUzbLfMI+RqGK9ROkDA6IQna5gRaC8QJfJUjY5yX8dBVQBaPZUfrYXtfqSHNk25WWaSNozDhuqF0wcxG6FYK2cYe+tsEX/7rSG7X2962bX8vdmo6eeM8jd3CmSVhWNwpVzI8tUfmkhR0Nln2FDzMSDQXZ3JDJTlm3sg== 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=yiSuT2x1UtfiB+PF5lpiCO+cKmu3quHcLIqYoTVIYAQ=; b=S8b9Hc6KXotOHz1YH/SEln/M7miNKKDiL7CgWGN5tR50QgLDIRqoqQS0uvopWv1bIYfZPvffENyE9O3bQEcQUir1TCpYj8mMc2Jw8UzgE3C2Zklpe2U6xXTooKKz0EZqvtWKwPcwOlFp6+i1aH77FJzy3smkgS+At9NwcePqP3Ax0HnzLKqy1twlr0aMY5+rDEkK+0hnnwAFE9nC8HhJXEXfnG+///TfB3ZjGjYZcvPCDBroMh735yKrM67N9tS1cEy1z5zra+a+cyXRMEH7Pv4/rXJYAZ5DKfZml06eWwIYUpsZKY+jpj32l69g6XrwDGUV0NblfOzj2pHFmYdl5A== 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=yiSuT2x1UtfiB+PF5lpiCO+cKmu3quHcLIqYoTVIYAQ=; b=ffpP+lHbs/4S92pbGUVgbLS5Km5xFQs5/yYl4KajV92empCY8+Y7Y1swY5sMmNKJyi3yu67rx0ElVFUkRU4uf+VBRkRrYwLhzxmCskMtJqxS5PX+88osvm7fRSatpHg0z7kbNg8lSXhiwUmWvUZbGFw9EY4AEMQ4sPzDrFjUIi6CYRFsBJpntega+4PazkHSMHIWpe3mANSsR0AinO55P0JrK61UnccbsNLgmP8piizU7E+Ziqxlk2P5WSmcekOFvKU23EZuoR4omRjGQOKpu6iNx2PSVwtN06bv7XJb4iAWKxLKYm7GZySqU9Dt3z6DlSXi+S1BL3zwBqWSw+HH/A== 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 VI1PR04MB9739.eurprd04.prod.outlook.com (2603:10a6:800:1df::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 06:22:26 +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.8158.023; Mon, 18 Nov 2024 06:22:26 +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 v5 net-next 3/5] net: enetc: update max chained Tx BD number for i.MX95 ENETC Date: Mon, 18 Nov 2024 14:06:28 +0800 Message-Id: <20241118060630.1956134-4-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118060630.1956134-1-wei.fang@nxp.com> References: <20241118060630.1956134-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2P153CA0007.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::8) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|VI1PR04MB9739:EE_ X-MS-Office365-Filtering-Correlation-Id: a092da5f-2d05-4b4b-9b8e-08dd07995f03 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?XzlIyLTjLAzKRFELvZHX1udp7ovNM3e6959ZkHrRAdk25kt416pEe5guCNth?= =?us-ascii?Q?VIMBxHJ30lU9mdETsx5HPLu9oq2OjNYjriE+1dp3p81PltL4YQhBUXbU9VcR?= =?us-ascii?Q?Nhq6Hx0MZaJ7e6jdSZn/TEmeTBJf3pAFICBre4yeG90FwN2lIKB9Jex2AUk7?= =?us-ascii?Q?ExUwcqrMCJ6AOij5NhVZ1Gl+/dEw+zz1q6ZmHDCpWOJRKUktRODh23QQyDSO?= =?us-ascii?Q?UhcWp+fPxR3JJdwborljd7qKNXkm2FI+Ur7bPY023tj/iw7wNgbkx1riifc0?= =?us-ascii?Q?JVZW7FJ2RYnrHML6rNkSR6/WenudQBK9xlrfsiI2LajejQ3qk/mskItTL0IT?= =?us-ascii?Q?snWD1aII9yVHDHu8kmM0gUihHMZ+Y62kcQdzlAHFKyOvMCIY9IJuvcpE3ugJ?= =?us-ascii?Q?SnczrzwoVsuI4vejXbEPm/YdEmwBmdK6Ac+Rb3z32X4KkoujYMz11wAlYdOU?= =?us-ascii?Q?hT+piLxTnzZs2gjt2P45QEQ9JvytsHORi3B9qNg3gN60ChAEGU8qE8BceDza?= =?us-ascii?Q?byqGb3YK4d+e7bOE43MClgU5d/FIr/llXhJkAZoON2c1FkWKAMEDlwX/ldaE?= =?us-ascii?Q?lECLGFD9r77HhTWVjFJi05QCHLeQkPRZbFceHmZYZpXsrJTTVWSL2hCxtAGf?= =?us-ascii?Q?bM/aSGtdNDn0tKtu5hVTdBQj63U4Lw2WgdrvXvV1jd6Z+aSeh0mMNO8cKmMG?= =?us-ascii?Q?FelrWE0NSPKssX7fXDZNj2O1yoyfXpzHGtiwssozSxQb3fJvkt3cNNNdIh+J?= =?us-ascii?Q?5OOfO8VPMhcW0U8K1EKP742F/hgz/r4bmVjwkHTbtiLSWLtQJUKBtEgM7tfd?= =?us-ascii?Q?6uY+0RiaXbaMCEXQoIkdtwlbnhzOVNb7s2UjwSZEBV085Jo/GAkXitmpBQFR?= =?us-ascii?Q?KqaHzRAFKOSbmvnQcCM2hA7d9h3QjY4AWpxyeC3mV9lokmR7+oBNBIdXW2XC?= =?us-ascii?Q?NlOueMGDz8iRXEyUTPkZq5hWvYPq8E1knroFSK1Pi2qPEQx9GR07lT0gy2oZ?= =?us-ascii?Q?gB+NrFmuqKEj3pNUFVzHt1tRRks1kFy7qmpjKr5wWwORFoPhAgBGEOFSHtsZ?= =?us-ascii?Q?0aJj2yUKY/4nBSD6IXzj62WVWeD+APi1bAyzILpSU9OLoTty2tbv9tyqXqSA?= =?us-ascii?Q?YSfgxogz/VZVyRmOFj9pdtqipCSwCEC9H+3ILGciaZ3PPIjkOy5ambUzdQ3j?= =?us-ascii?Q?jT7Uc4su9tj8UeSC76yXPag+9PUMFIpskzkS+9OutJggVWziOAHmBOhUQmIS?= =?us-ascii?Q?N2exIvi5UTQZ865LWPBcHMrqe+fSsvNM8S9fd7Kiz4kD5h062I5EP00a3Q/H?= =?us-ascii?Q?Sr9vrxseaSN1AWGWCrONTOQ+AqAfuG8apR6KjZyTAJ9EEL6Z/gi6S3Az6JKK?= =?us-ascii?Q?e6MJo30=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?pb68698r3Z9p5WBhyRZidk7l9oM5RdP0y+qW+rcaQhPv3VqhbItet1KDZEFk?= =?us-ascii?Q?8fK4Xn61AQntCXqyhrnCtuKRi+H6h4o5wQzxMdy2ebyp9oyod8cDXdPwSRe+?= =?us-ascii?Q?vENXSurPxbpf8dHQf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ascii?Q?EFyiy96lU4tZ4HiSsJzQYXZk18zy7YXe72yJAK9He19B/+anawSuq4SA6U7Q?= =?us-ascii?Q?x2/f0fPPaqaRdEZbxsktHcVFoUjavZ/On8Y5aJwMd/llKCXPAr9Op3laSZaU?= =?us-ascii?Q?B+Yl+2PqvBcgOxEH+BpUeZrye7wpnmxR2WPj2zqAItaeWsX8Ap3FXoFFIfsW?= =?us-ascii?Q?J1w8X+d38CrAK292kpSdqWAP3zpNVubGXRvq8DHJ1+sNeA040cQHA9HmX9H/?= =?us-ascii?Q?cURYnZUGqKNp8fe7cKbTlx23ckmoOnu+9MI50TaxZumjhJ0mGjD5nHwUxjBR?= =?us-ascii?Q?bqDPCvTFQ6QNOA1Exd1kJD1mTvwZLQK+7Xu2oViHlaNI00RmzN/hNNKtHADs?= =?us-ascii?Q?VQXKn/ZAvZPpq3WnOqrQQZkwqMawWkYs7WLyXg+HxPGm8ulp5bGKL0Jy0ri0?= =?us-ascii?Q?jZgjzo56ZalzZVE6XLCQx3bwBtB+GQQhzTAoGKpx0Uhx1AiR6pBGAu/GN5Rh?= =?us-ascii?Q?Flh59p2ZnSM1D6pjQ9qqczUMsOWtzFQd48rIwv6oU/TPAYEdqGtCAr+Gjv8R?= =?us-ascii?Q?j54nFqr1L4GYCqzdkLjhyTwFO/WY9NgqinU7369w?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a092da5f-2d05-4b4b-9b8e-08dd07995f03 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 06:22:26.4256 (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: Qc05B3VSszCv0Ubxr0+KiWQjlc6O6RIU/Gyr9ObnZwxyVNSVKSuRb12mrUEiJljR/jGBZCwCah7rLR+mbY4xDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9739 Content-Type: text/plain; charset="utf-8" The max chained Tx BDs of latest ENETC (i.MX95 ENETC, rev 4.1) has been increased to 63, but since the range of MAX_SKB_FRAGS is 17~45, so for i.MX95 ENETC and later revision, it is better to set ENETC4_MAX_SKB_FRAGS to MAX_SKB_FRAGS. In addition, add max_frags in struct enetc_drvdata to indicate the max chained BDs supported by device. Because the max number of chained BDs supported by LS1028A and i.MX95 ENETC is different. Signed-off-by: Wei Fang Reviewed-by: Frank Li Reviewed-by: Claudiu Manoil --- v2: 1. Refine the commit message 2. Add Reviewed-by tag v3: no changes v4: no changes v5: 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/eth= ernet/freescale/enetc/enetc.c index 94a78dca86e1..dafe7aeac26b 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -525,6 +525,7 @@ static void enetc_tso_complete_csum(struct enetc_bdr *t= x_ring, struct tso_t *tso =20 static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buf= f *skb) { + struct enetc_ndev_priv *priv =3D netdev_priv(tx_ring->ndev); int hdr_len, total_len, data_len; struct enetc_tx_swbd *tx_swbd; union enetc_tx_bd *txbd; @@ -590,7 +591,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); =20 - if (unlikely(bd_data_num >=3D ENETC_MAX_SKB_FRAGS && data_len)) + if (unlikely(bd_data_num >=3D priv->max_frags && data_len)) goto err_chained_bd; } =20 @@ -651,7 +652,7 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb, count =3D 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; =20 @@ -669,7 +670,7 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb, if (unlikely(!count)) goto drop_packet_err; =20 - 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); =20 return NETDEV_TX_OK; @@ -937,7 +938,8 @@ static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ri= ng, 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) >=3D ENETC_TXBDS_MAX_NEEDED))) { + (enetc_bd_unused(tx_ring) >=3D + ENETC_TXBDS_MAX_NEEDED(priv->max_frags)))) { netif_wake_subqueue(ndev, tx_ring->index); } =20 @@ -3312,6 +3314,7 @@ EXPORT_SYMBOL_GPL(enetc_pci_remove); static const struct enetc_drvdata enetc_pf_data =3D { .sysclk_freq =3D ENETC_CLK_400M, .pmac_offset =3D ENETC_PMAC_OFFSET, + .max_frags =3D ENETC_MAX_SKB_FRAGS, .eth_ops =3D &enetc_pf_ethtool_ops, }; =20 @@ -3320,11 +3323,13 @@ static const struct enetc_drvdata enetc4_pf_data = =3D { .pmac_offset =3D ENETC4_PMAC_OFFSET, .rx_csum =3D 1, .tx_csum =3D 1, + .max_frags =3D ENETC4_MAX_SKB_FRAGS, .eth_ops =3D &enetc4_pf_ethtool_ops, }; =20 static const struct enetc_drvdata enetc_vf_data =3D { .sysclk_freq =3D ENETC_CLK_400M, + .max_frags =3D ENETC_MAX_SKB_FRAGS, .eth_ops =3D &enetc_vf_ethtool_ops, }; =20 diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/eth= ernet/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 { =20 /* 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) =20 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; =20 u8 preemptible_tcs; + u8 max_frags; /* The maximum number of BDs for fragments */ =20 enum enetc_active_offloads active_offloads; =20 diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drive= rs/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, =20 priv->msg_enable =3D (NETIF_MSG_WOL << 1) - 1; priv->sysclk_freq =3D si->drvdata->sysclk_freq; + priv->max_frags =3D si->drvdata->max_frags; ndev->netdev_ops =3D ndev_ops; enetc_set_ethtool_ops(ndev); ndev->watchdog_timeo =3D 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, =20 priv->msg_enable =3D (NETIF_MSG_IFUP << 1) - 1; priv->sysclk_freq =3D si->drvdata->sysclk_freq; + priv->max_frags =3D si->drvdata->max_frags; ndev->netdev_ops =3D ndev_ops; enetc_set_ethtool_ops(ndev); ndev->watchdog_timeo =3D 5 * HZ; --=20 2.34.1 From nobody Sat Nov 23 11:31:47 2024 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2075.outbound.protection.outlook.com [40.107.105.75]) (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 8ACF11494A6; Mon, 18 Nov 2024 06:22:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731910957; cv=fail; b=JwKWO8+k0mpe+F/qyHd/iYNIL9B+41GzCyQEzuul4v2G8dY04hHLf5i5dxN/LoSpPEvhV/wl4REkZCWgljuLVEiRMP30XTUUgQu4oR6fASdEznvcgmecSvk4so45v/OFg+jwIpLUGteqsGQRw1YXMxPu5a6I+XBOFN/SUbhVNYQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731910957; c=relaxed/simple; bh=Tnw+WjFVrI7oPyhkXEkN5viwsOowDzZhEX5d0qGpMsM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=oJpDFYtHclmI6QAazPqdzLZCBByYbq0j2iI9/I/Xr0U+pwWCikRjFfDGUWsOowqfXGj6zs2Q4AgkEh/iOwuVbBpt7PeuX/WZfJv/ww2MMjvHQmEmvmBNECeferd5nMyFQhSaS/Yk+hHFX/zJS6ht0/zk2Nu8wNHlZ+ZaWZCocuQ= 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=KG4apcNS; arc=fail smtp.client-ip=40.107.105.75 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="KG4apcNS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YSiV7IqcIiqOQysAAsUhywILDK6h5NungLFAaNhWm5tWplgDA46K0g7EChlnppImJegigNwWkwrF6+3miuo9eEQbJT8bZRRAalAGIeY/OtXf6zWK9D6f7Kn42felJR6HVJdEZgflyGZmMEPsxcdEwrxB8xvFVk9bKF/UySPu5FIcqBggqvGmsB7KDVO1CTru8arj3mDVzu+/IyUBhW6x58UKsmeobh3wSDzPv4Cegwt+1lTmaPNPNJ9MIMWR5ruqIBzs5yW7upAhnB2T6EYfyyL4XGFunz377SWX9doqEu7eimb98aWAAsqd/TIEhsTz5I5akB2iIUIImK32g6ia4w== 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=k0upDHC3PtDWwb5PDww/DP3Oerjbden0UIXoPjrYBdY=; b=a09YHjy+qQzSMEjmcVjG6aqfnmziH7BcoFizLHvY2DbhfbDElkG2FGLpfIWSCH2mTZiLVv3O/YSQnQnUhP/7UePwv6vb7YhrZwA3Oz6Joe3TR8mFT1fVM29LxI0reWlES2zq2uSDHLAV2KmwMxunU3Vskn1ODeKPfY0uiyLnXCvLs7kH49+WznUxkY8M8K0KdoztHM9OB6yihyR7q21kC4K/dEGNf6mBhED6vVVPl1QnB7x4JZUx55L+lGJ5aUwIqHMhBVnc8M7Ur/yUDx3u8+eGvFjkPkq38M0XhrFVeujm3LlmnGBDoq8WXX4G10UZW1plxXH1xyCcXyyiU4eDvg== 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=k0upDHC3PtDWwb5PDww/DP3Oerjbden0UIXoPjrYBdY=; b=KG4apcNSm03rFF1C2WL1utQe+op/LF3olzZQBQZCFRKtUkdsnrrHn3Bhc9yvJnUxD/G4Mvof/2HEDsBdz1HxGCW+PqfuoUC85ASrkcIBaggUvZjpeQNuLumI3hl0Em8UPVFXS0qcvGV9y/cwLUFwsrcxes5S4dXcaZfXSd7N9lnHa6Oh2o1epO4TzeY5aBKlRxF56B1qxcdOunEZ7lRjDgpoIZ9RIUlWq9exs8MJYMwdI2g3OjMKSpvgaLXfs7Bt39w7zGsxlUhhaB9z/5zf6aCdY2a0Lgld4skCnWQtQRrnAclaXmeRlJTsZVGlcXGLSRtJ6itl0v+yadJRgweXsQ== 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 VI1PR04MB9739.eurprd04.prod.outlook.com (2603:10a6:800:1df::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 06:22:30 +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.8158.023; Mon, 18 Nov 2024 06:22:30 +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 v5 net-next 4/5] net: enetc: add LSO support for i.MX95 ENETC PF Date: Mon, 18 Nov 2024 14:06:29 +0800 Message-Id: <20241118060630.1956134-5-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118060630.1956134-1-wei.fang@nxp.com> References: <20241118060630.1956134-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2P153CA0007.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::8) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|VI1PR04MB9739:EE_ X-MS-Office365-Filtering-Correlation-Id: 50cdd731-7c6a-416b-7e45-08dd0799615f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Nj5yQKFsVc1FM85rzc1IXrLI/DYbcHM8Cvzq5gU10xSpUToDx0kMx5ORcSxk?= =?us-ascii?Q?9m9KAYK6+KpGkjxcKPvq6UzNqfVAxzTicwvG6YQ4pGOwX4yGg6bisKWgt/S5?= =?us-ascii?Q?1Y3oYL1sLIOiTq9B/uGkXW3JI1StVHpKRcgGQO/G7WDNxZLOpVvdZR/tCWhf?= =?us-ascii?Q?wP7sTxXOCOcpaRZQl2x1coIqKJ3+XLwJZe5T9WGmaFKjSVKTU1ltJL5r4uVh?= =?us-ascii?Q?WhZHc8I6Nd+uY/O/EbJiii9fkUcte/EuprtrZY85bYs2HYStRlSewVz68r/k?= =?us-ascii?Q?ByoYv0iyJKZq2B1QPPvW2Yka1iH5RII/wNyA744MPShLCS52ZfbPUleNrKIH?= =?us-ascii?Q?OA8lxQVFEMLXKaaEbh8IMVWeMvAcULZLJPYaQuyeas8iU2k8sUcyto8paQpe?= =?us-ascii?Q?q7cwM2mJuckpuqC5Knr48Fq2m+Fdp/n4Pd8imOJHk0S/HWnSzTYCPcX8b6e9?= =?us-ascii?Q?eQeLRRR/5SOnPvJdkRRDXmldEzWedZA6gVof9adx6K2OGQBc4wzaVkFcfOJx?= =?us-ascii?Q?9GuFSWGqPeudarKwmOr1p4d7rlh22Lsv5IQEny3yP5AyOl0bIxzIg5CXWCwS?= =?us-ascii?Q?sThdel+SqibyLGUkpkqh3h23lBhmgIxLBAMwUvlGs5cNIKTrLKP8mkTS/8L8?= =?us-ascii?Q?7aacMQNB0T8/KA0kjjXYuAd0MC6UdWLnwH36cYFIxqFr/gO+YxrJqzfDetPy?= =?us-ascii?Q?TBsl/46ZXEIg4xViJkD56MfoSi3fXptNhxsca+JuY3lhY9MRobBZbaLoJ5PM?= =?us-ascii?Q?0KBxXLGwAF3/izN8e6bvIo81eCM4ue6pJ3RZcfpOOBEfywMIz52w+2PHXEtN?= =?us-ascii?Q?LAi454EXG1O+PML8PrmjgBr1KNfkCCbjZR0SU84sZvQVPmEnda+Fz/jV1qFX?= =?us-ascii?Q?yD0zp3uzi5L4gqu2WMGkW4dhzKl1y9kSYoFh9Nn6+TjZL3VpbMf9dUgtdXNR?= =?us-ascii?Q?jKrnRlVaDKX64s/XHhfm2gJ4mrCJgaQdBznQ9fNSG3fZ9bvmUNkyPUuHxkwL?= =?us-ascii?Q?m0mV4yQ2u1CDAR7+RnTcFAYY/782v7AAXA37ewoOnVG+Wm9dVBlwiDnQp5Pp?= =?us-ascii?Q?ydkAjpF9FQ7kQ6ERAquhPbl8NQ/GOQOBTEskmYSiS9xBFxixTfIdZp2oddRv?= =?us-ascii?Q?VfPwfTtdrYrMah1QnxC/fKxkLGmrXEJW3i2OMQI0qxNYvc8sRhJspzyH4jaG?= =?us-ascii?Q?VgznJjrI1Ef+1V9DPVwWCUIQbdWxWWP1jwZ6TBmOdm6CpcwMOKm9RCCG0LQB?= =?us-ascii?Q?ULOF0qwvnmgwOILdZ/FV0YI8Mi4Am917iH7IszsWFxus+4bu4gjp03qzUUfs?= =?us-ascii?Q?c8EpAp/KqZGn9DE4C2F9VJg/GMqYMnayjnjOeUAFuFZ5IQAosTN8dGBy307h?= =?us-ascii?Q?x3l5hVQ=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange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lw/2vswiLeqwi?= =?us-ascii?Q?V/GmZCVT5UbmGWyvUE57+xIwC2vw/zu1TWJ9nrmWRZdqV+HGtCjuVT7forVy?= =?us-ascii?Q?ADztH6lqydTNHUyvF51Oq9t9iaW16DejE8OTC4XzIimodLpFBZXDraOtfc7Z?= =?us-ascii?Q?JqtAAihF0mz3vb5YzgoUquVhH2J2Wc0hQu3E5coD+YLvnU5R9NZ3maE9GOIH?= =?us-ascii?Q?kjMwOxBH3V85OoPoEKss37n9zjEgM2J0rs9TuW6SOK3BpROVrexA8662YmPf?= =?us-ascii?Q?VY+Wv6QzYbmD5E6BaGJhxhsRJVE51WpzerTW74DRBtnwKFJ8ZU7sLgvpmlY5?= =?us-ascii?Q?rRvYvDUf8s7MWpu8KfAIVzRpy3BQqJ76ZVFR/UZQ3ZkPVyWpF8zV+HjNymqp?= =?us-ascii?Q?4QtebVpgx2qHGFuT2+IvTjZOQenbnj5FqXFGF8O4NbAHRfRgAmJ5aQq3mE7j?= =?us-ascii?Q?f2b/nMHDU8hbxKfsQ8cCyHrTvyOYdT4qMp6XboQC3np2CtheCfv+FAuL/nSU?= =?us-ascii?Q?XV59kOreEaTyymbEaTY5lFzabJFdsTnHWiRVoaVProGpYctHTQpC//eBOGvv?= =?us-ascii?Q?le1mLBPprMMUVT16lskrfItzaRCpjvTnyiIrb8isT+TS4JWEEdGvFG+wQZBs?= =?us-ascii?Q?pg1X8UxGAu2hj8OEtYJxlDAtodt+pD5NHlnUJMTHY4RmfboIS76anqUGrhiQ?= =?us-ascii?Q?sgAC0tSqjEYnmSJ8OPcTU6hsufKRf3KlHZLEdvNvfPvdbTCpNCBu9uicz7MH?= =?us-ascii?Q?0y2wzSeiwOc+TWmLWhWQNwc8URVjny6F/8uTdA4N?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50cdd731-7c6a-416b-7e45-08dd0799615f X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 06:22:30.4468 (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: MFzkHkbOnM+uXKzeAPt8mb7GOslPiYoqGc0qUZUyDv4j17ktM9q4t9oDWNwPnPsHaSjLkW9eT72p5Paj/PmYLA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9739 Content-Type: text/plain; charset="utf-8" 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 --- 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/eth= ernet/freescale/enetc/enetc.c index dafe7aeac26b..1d5c63ceaad8 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -523,6 +523,233 @@ static void enetc_tso_complete_csum(struct enetc_bdr = *tx_ring, struct tso_t *tso } } =20 +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 =3D skb_is_gso_tcp(skb) ? tcp_hdrlen(skb) : sizeof(struct udphdr); + hdr_len =3D 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 =3D skb_shinfo(skb)->gso_size; + lso->ipv6 =3D enetc_skb_is_ipv6(skb); + lso->tcp =3D skb_is_gso_tcp(skb); + lso->l3_hdr_len =3D skb_network_header_len(skb); + lso->l3_start =3D skb_network_offset(skb); + lso->hdr_len =3D enetc_lso_get_hdr_len(skb); + lso->total_len =3D skb->len - lso->hdr_len; +} + +static void enetc_lso_map_hdr(struct enetc_bdr *tx_ring, struct sk_buff *s= kb, + 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 =3D 0; + dma_addr_t addr; + char *hdr; + + /* Get the first BD of the LSO BDs chain */ + txbd =3D ENETC_TXBD(*tx_ring, *i); + tx_swbd =3D &tx_ring->tx_swbd[*i]; + prefetchw(txbd); + + /* Prepare LSO header: MAC + IP + TCP/UDP */ + hdr =3D tx_ring->tso_headers + *i * TSO_HEADER_SIZE; + memcpy(hdr, skb->data, lso->hdr_len); + addr =3D tx_ring->tso_headers_dma + *i * TSO_HEADER_SIZE; + + frm_len =3D lso->total_len & 0xffff; + frm_len_ext =3D (lso->total_len >> 16) & 0xf; + + /* Set the flags of the first BD */ + flags =3D 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 =3D cpu_to_le64(addr); + txbd_tmp.hdr_len =3D cpu_to_le16(lso->hdr_len); + + /* first BD needs frm_len and offload flags set */ + txbd_tmp.frm_len =3D cpu_to_le16(frm_len); + txbd_tmp.flags =3D flags; + + if (lso->tcp) + txbd_tmp.l4t =3D ENETC_TXBD_L4T_TCP; + else + txbd_tmp.l4t =3D ENETC_TXBD_L4T_UDP; + + if (lso->ipv6) + txbd_tmp.l3t =3D 1; + else + txbd_tmp.ipcs =3D 1; + + /* l3_hdr_size in 32-bits (4 bytes) */ + txbd_tmp.l3_hdr_size =3D lso->l3_hdr_len / 4; + txbd_tmp.l3_start =3D 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 =3D lso->hdr_len; + tx_swbd->do_twostep_tstamp =3D false; + tx_swbd->check_wb =3D false; + + /* Actually write the header in the BD */ + *txbd =3D txbd_tmp; + + /* Get the next BD, and the next BD is extended BD */ + enetc_bdr_idx_inc(tx_ring, i); + txbd =3D ENETC_TXBD(*tx_ring, *i); + tx_swbd =3D &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 =3D cpu_to_le16(skb_vlan_tag_get(skb)); + txbd_tmp.ext.tpid =3D 0; /* < C-TAG */ + e_flags =3D ENETC_TXBD_E_FLAGS_VLAN_INS; + } + + /* Write the BD */ + txbd_tmp.ext.e_flags =3D e_flags; + txbd_tmp.ext.lso_sg_size =3D cpu_to_le16(lso->lso_seg_size); + txbd_tmp.ext.frm_len_ext =3D cpu_to_le16(frm_len_ext); + *txbd =3D txbd_tmp; +} + +static int enetc_lso_map_data(struct enetc_bdr *tx_ring, struct sk_buff *s= kb, + int *i, struct enetc_lso_t *lso, int *count) +{ + union enetc_tx_bd txbd_tmp, *txbd =3D NULL; + struct enetc_tx_swbd *tx_swbd; + skb_frag_t *frag; + dma_addr_t dma; + u8 flags =3D 0; + int len, f; + + len =3D skb_headlen(skb) - lso->hdr_len; + if (len > 0) { + dma =3D 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 =3D ENETC_TXBD(*tx_ring, *i); + tx_swbd =3D &tx_ring->tx_swbd[*i]; + prefetchw(txbd); + *count +=3D 1; + + enetc_clear_tx_bd(&txbd_tmp); + txbd_tmp.addr =3D cpu_to_le64(dma); + txbd_tmp.buf_len =3D cpu_to_le16(len); + + tx_swbd->dma =3D dma; + tx_swbd->len =3D len; + tx_swbd->is_dma_page =3D 0; + tx_swbd->dir =3D DMA_TO_DEVICE; + } + + frag =3D &skb_shinfo(skb)->frags[0]; + for (f =3D 0; f < skb_shinfo(skb)->nr_frags; f++, frag++) { + if (txbd) + *txbd =3D txbd_tmp; + + len =3D skb_frag_size(frag); + dma =3D 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 =3D ENETC_TXBD(*tx_ring, *i); + tx_swbd =3D &tx_ring->tx_swbd[*i]; + prefetchw(txbd); + *count +=3D 1; + + enetc_clear_tx_bd(&txbd_tmp); + txbd_tmp.addr =3D cpu_to_le64(dma); + txbd_tmp.buf_len =3D cpu_to_le16(len); + + tx_swbd->dma =3D dma; + tx_swbd->len =3D len; + tx_swbd->is_dma_page =3D 1; + tx_swbd->dir =3D DMA_TO_DEVICE; + } + + /* Last BD needs 'F' bit set */ + flags |=3D ENETC_TXBD_FLAGS_F; + txbd_tmp.flags =3D flags; + *txbd =3D txbd_tmp; + + tx_swbd->is_eof =3D 1; + tx_swbd->skb =3D 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 =3D {0}; + int err, i, count =3D 0; + + /* Initialize the LSO handler */ + enetc_lso_start(skb, &lso); + i =3D tx_ring->next_to_use; + + enetc_lso_map_hdr(tx_ring, skb, &i, &lso); + /* First BD and an extend BD */ + count +=3D 2; + + err =3D 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 =3D i; + enetc_update_tx_ring_tail(tx_ring); + + return count; + +dma_err: + do { + tx_swbd =3D &tx_ring->tx_swbd[i]; + enetc_free_tx_frame(tx_ring, tx_swbd); + if (i =3D=3D 0) + i =3D tx_ring->bd_count; + i--; + } while (count--); + + return 0; +} + static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buf= f *skb) { struct enetc_ndev_priv *priv =3D netdev_priv(tx_ring->ndev); @@ -643,14 +870,26 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *s= kb, tx_ring =3D priv->tx_ring[skb->queue_mapping]; =20 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)) <=3D + 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; + } =20 - enetc_lock_mdio(); - count =3D enetc_map_tx_tso_buffs(tx_ring, skb); - enetc_unlock_mdio(); + count =3D 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 =3D 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))) @@ -1796,6 +2035,9 @@ void enetc_get_si_caps(struct enetc_si *si) si->num_rss =3D ENETC_SIRSSCAPR_GET_NUM_RSS(rss); } =20 + if (val & ENETC_SIPCAPR0_LSO) + si->hw_features |=3D ENETC_SI_F_LSO; + if (val & ENETC_SIPCAPR0_QBV) si->hw_features |=3D ENETC_SI_F_QBV; =20 @@ -2100,6 +2342,13 @@ static int enetc_setup_default_rss_table(struct enet= c_si *si, int num_groups) return 0; } =20 +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 =3D priv->si; @@ -2113,6 +2362,9 @@ int enetc_configure_si(struct enetc_ndev_priv *priv) /* enable SI */ enetc_wr(hw, ENETC_SIMR, ENETC_SIMR_EN); =20 + 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/eth= ernet/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; }; =20 +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) =20 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 =3D BIT(11), ENETC_F_RXCSUM =3D BIT(12), ENETC_F_TXCSUM =3D BIT(13), + ENETC_F_LSO =3D BIT(14), }; =20 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 =20 +/**********************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_M= ID_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 pack= et. */ +#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 =3D BIT(0), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TSE =3D BIT(1), + ENETC_TXBD_FLAGS_LSO =3D BIT(1), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_W =3D BIT(2), ENETC_TXBD_FLAGS_CSUM_LSO =3D BIT(3), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TXSTART =3D BIT(4), diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drive= rs/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 |=3D ENETC_F_TXCSUM; =20 + if (si->hw_features & ENETC_SI_F_LSO) + priv->active_offloads |=3D ENETC_F_LSO; + /* TODO: currently, i.MX95 ENETC driver does not support advanced feature= s */ if (!is_enetc_rev1(si)) { ndev->hw_features &=3D ~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK); --=20 2.34.1 From nobody Sat Nov 23 11:31:47 2024 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2075.outbound.protection.outlook.com [40.107.105.75]) (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 42A69165EF8; Mon, 18 Nov 2024 06:22:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731910959; cv=fail; b=pUTGIoEKLEDalRLAJ7fZh63JIZljXKLQE+tYc7/KdyENDyAEqE7atxv6oF+51cDqkZt+B2+kCHVKn+LfW8MHfiitUmrcaJHhJi0l2PCJbShqNmEUJ+ElbyGLOM898/iUBaHVmUfLa4he7BOYBdXIILjxy0ZDGlZDZL6m+83tPJ0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731910959; c=relaxed/simple; bh=GcBRI3fRmqtHBLmmq84nuZuseIMLeVz9qNc80/VAe50=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=NF9O27cRqLTAqm6nIlskfKDTaqHyU+9Pa45Sf6E0/nhIp0DAG11Wj4RIzLnF3yPUDP7879AIV5M9RVSOw+kyiAyWlGSqHHLuYGeUNA3OM9aHz2HM8vYwWQVgBgZAvPpqRkvmkuqIDPwS2J1U7iBSA0JfyXA9adHNmSY45k1PEpA= 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=APHsICiy; arc=fail smtp.client-ip=40.107.105.75 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="APHsICiy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i7ecXkbBchN3JuGnfQ2+UExwhzgHcaVqPHQMoAFokatgXH8E/r0NkJs9uKbEg1ZgL6+v34fyJJ7DKmRHWPISC974XwmbybRjqsyUeZVe2urXbdlzJ3qycSlDOXR8Y89tIUUU5JbQzDCNMXkfLXb14jfEUNuaFUWuydgeTiX+4KawRAIoAFEyrx2AWyAPDJZk3AjlACj1o2C88ej68iiNx2VIprF6rprsi2FVilT0OO6gQZmBCYTKpT2luRsYfpfIyvNnaMS6PcghC42uzPEejoDpE+sy/KypP9IyXocxZFcQJ5T0xAbxBzGPtVoYBkFSliEwqElhVWHUrUhufvPDEg== 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=eIAAiB+DeVGJXe8iPw1R2VFttXf8547vGuC6PrmznoQ=; b=XBc7T1VdZCsUI/S2DN/51FXoqA+hfcyb2r2hvz0XhR0Vic0P1gDE13vP7CDgt2UQcm5pn7lFu7Ci9JVQQQqn97ZXIrxJF4shu2vZYuPMCcR2azD7bmYgBLrwixJ2DLYdn9yRoiAYKdzJT7y215UHroHIOBmbAabxs6ZjV2XwgDyV9rBewd+/qaNJEVidQgFmxINhDLt1rZfwoV52lU4W7VzfK/1BMb+noltkAmRoDrBoCz1Hghha5E81wCgOMTEe3rz/lcQStKpaKK9ZyltSRfbJLn9c9r6VPkTVMWj5f0n93ItcgR+/q9JBQ0h8FuuiqJxx7HC7t5hmDqBVqecDZw== 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=eIAAiB+DeVGJXe8iPw1R2VFttXf8547vGuC6PrmznoQ=; b=APHsICiyxiqt7ADwbOl7ZBCGBl9WOoKKMQIACArAuyPXp20d7zHN1AYuIWa44axksPrEWLIzIzmHHEVFgihfI0vBVG4KWZET1El/bwFCXlA/GzhtAdJBNc7aCrXGvII8LIHuj7EI9UBy0AFhy0fJu+f6gbwwjfP/CwmkZXfwf1QxJ9d/rz47eO4Wg2Gfw5s0kHmj4YxNdzWzhJwtwgLeaEUtF9cK4jjPKmrxtmfKtFzA9MqK9ITCMytczfsbr3thUyyxWe+GQSGt3EDPSIv7eEdtDwFYfUKV87RKCcYGYn6Opw31KQYX4jirqcOYqQXg+yLRn5F0QwkJUCrIXxZl8A== 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 VI1PR04MB9739.eurprd04.prod.outlook.com (2603:10a6:800:1df::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 06:22:34 +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.8158.023; Mon, 18 Nov 2024 06:22:34 +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 v5 net-next 5/5] net: enetc: add UDP segmentation offload support Date: Mon, 18 Nov 2024 14:06:30 +0800 Message-Id: <20241118060630.1956134-6-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118060630.1956134-1-wei.fang@nxp.com> References: <20241118060630.1956134-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2P153CA0007.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::8) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|VI1PR04MB9739:EE_ X-MS-Office365-Filtering-Correlation-Id: 81d822ed-793f-4315-51e4-08dd079963d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?h3zTkNNADBUbBe0TewV3xQTkrJEBlQp5jGbkrPX+ENteKbAkl5vGB7lKtj/j?= =?us-ascii?Q?cCG80Ij8lRULGF5zCBR4EUUyFnOnOfphimM3IKWpU1vXSQSurt/T/qKqwVyu?= =?us-ascii?Q?0K4n4iXz9NDDdEuMq3zPNY85kFjfstcW5zJDYK/XxxYbQ/qKQ/WdiudOEzJZ?= =?us-ascii?Q?FBQoRcO9Op31GFGIjZkoZt4++NROzCBUNoNW6CI4mTrlD2lveXOeTG7YT29W?= =?us-ascii?Q?55pGMqCHTlpFIZDmdD02AdNyHs0pYRGOGgb8d7tEMfohUALszsraUVRUdEOV?= =?us-ascii?Q?FkgfyKweIBPBbkM2zXXnpNRwz+pVdYi60Yj5icB06zQDxr36/Hga0wG0X+aT?= =?us-ascii?Q?tpOWIiKugUWskvs5QzAnd4cyZzfWojV8SCpsX2f1VmEo9LzZsc0JHGVGwKsw?= =?us-ascii?Q?2bv3rWTh1IOeM4H3mv4HxY7/SL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m3dlCuYhfqrhcnS4fQwId0a0FKx63CWJ5dw1O/aIHwTR1C6lrmcfz8DE?= =?us-ascii?Q?aUtK9NU=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?bIBJs9xWl8aKr/V/2tq3iCN5Gn4FyDKkb0W90NCqJewxW0dn7Vu8LQXYtn3P?= =?us-ascii?Q?G/eLSWOyh1S0EMFsno193sEl/3QVausd1zGcOGYU8+bVYe+7EEXhrBrMOuP4?= =?us-ascii?Q?/Chue54kvtqBn5ITM7Yq9LF1ywsfhMhgad3qQRZpDyC9XQ1wJka3BbI4FwY+?= =?us-ascii?Q?JQVqS1XUnDf7mjE35TKjG/yh1VGWVSHDM0fykN5bq6De4ZbXhSKcQp7vYyHi?= =?us-ascii?Q?m0HbU2gw6MJk1RuPVpOX3HsqlO8fzacoFUQMXDuM7BEFKrL/JH1ZsL2+mzXq?= =?us-ascii?Q?2Xjt6HrzMHjE0nkuc/PhUzC15LPFvQFC6x1kaCy+mVzjsVJRhuntv3DYnlgS?= =?us-ascii?Q?9e0hG8odhrVFelRfPGmIdg14FvHYGNKywgIOA2usvZLdvN3vBlM5Z7Tp8e32?= =?us-ascii?Q?k2ESkE8iCU9TrBxqGeTyYzi4BtKKkeGi0nwL9ToQD5bEON/dLlenfyXM/7md?= =?us-ascii?Q?jpUTXukKf8p6iQ/XSI1ZJYc1sy19A8XonijhlsX8Ox724+iRte9KWBRRpwGT?= =?us-ascii?Q?YHpMieD8UYRJg+tuvZLnxwUU2GQmizTgSlfIkIX0NRjky+9vryd5t5fbZ2YV?= =?us-ascii?Q?Lzop4kRIxoo6Ob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us-ascii?Q?G5VkUCdUNa9t/3KMVMd+nL7Af5zufWB3VN/6Cdxzrqjvym+EcZ6M7OZEhc2K?= =?us-ascii?Q?dFMZyDOJWaVaoqM6cUkyaMSK1IElm8RJMKWpH30C?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81d822ed-793f-4315-51e4-08dd079963d6 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 06:22:34.5050 (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: sXHFWiT8vhjhUsb5WjXm+eITAtTT8+N/L13HCjncvwUZQG5K/hvTGHEnokyXPCAgcV12v55bjkaQZHqoh5uNLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9739 Content-Type: text/plain; charset="utf-8" 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: 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/drive= rs/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, struc= t net_device *ndev, ndev->hw_features =3D 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 =3D 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 =3D NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; =20 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 =3D 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 =3D 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 =3D NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; =20 --=20 2.34.1