From nobody Fri Nov 22 22:51:47 2024 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2082.outbound.protection.outlook.com [40.107.22.82]) (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 9C68B15B153; Fri, 15 Nov 2024 03:03:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731639815; cv=fail; b=OCCFtkfGJpLAHExwVaw78j220BEU9r6Vb0zfELJxrQeU8BQw8uGQ03tn8xbNxVPJ4D3reOG2OC7V70fCFtKh7ySq/gR5HW+W49HL6pH3ulqP1jxBSGIrC2hmMjQmYJA2Uc9B+GuLa3IcCuWgvMNoyPlaSefC2U/ikbnF2muE1Ns= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731639815; c=relaxed/simple; bh=6OBjYIif+Wi3qP//igl4AcNvIbBLWrayd06KnOnt48s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=hODAOSaK5vP/3/kU3pfF+0Xqn7XIDDShpD2SCmoa4Zih197DF8INRMLnZOPXOPknV8Ad7f47DNQ71sKZ9mbZUkv2WVPFFqQHfr2G8vqKEcUxuHlqrgpYEh7uao2uedhAFXAKLHBTkW5hLdzAjtS7uaTJkYyVDgfeMlFuEnRM2Uw= 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=VE6IWhsJ; arc=fail smtp.client-ip=40.107.22.82 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="VE6IWhsJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kLlMunpKcyNFNtZ19TZRiXcfVX/Rs0GhZHxNmipMbASQP0WqGvMeSsDbju561xtW16HNg63a0vRS98gLjV3lHWa0Tng2wgPGVdwqBJF1c6ymBclxt0nb6IRUnB9IanPMTIGDNTfuIu6DtKvIbsnEKbyPFUOhCL3nTEy9Jcsl66HHwFxe/W6NHLJg2KYw7JLoiEGuUxWTzKauNcNWIeKcbT7MIACkeJETh5RHPxa47VuC+sVSjP1FvWKmKBY0QA2jRKmxgL8lkcik58bFNhZ5ixRfcFaMJ/rrUqvk6GIccA2UGjhqsu+SYqneyPuaFTr2hzIwGvBhkV9dbOcd8KRBfA== 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=92o1UFRlB9G+7GfxDvmYRBzcLKkiB1JOI3RTc87wH0Y=; b=i5q/ql89gYeh+N6eF6HqbstVAHZkKKgYniNwQKySMKemPuvGhpIp+DqxEnfyf1KnU4JKD5EEf+AqTDiZlATxqAl0JlOAWeDwQqeVFsuiuLbgQ1FLp7If/bC248qTk3Q0HFovbVcKsu9iUoNH3+TxY6UMehRTNFfmTPjn7S++z/oI/nPD49KCw5qI5gbz1mmmZQ+md+dzddN9PtDBFFzoDIQ5sCJFGq1O/NM9eJI54846sajE2yIAZHoHgUt6tHj31sQHwVffZbW8ntkhgGWrLMX1gOw4cqHu8kr4OJRcVKehbWlIJx4UJEVOwQWLM7/tNoUHArtZTRpGa1ZvUJHX8A== 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=92o1UFRlB9G+7GfxDvmYRBzcLKkiB1JOI3RTc87wH0Y=; b=VE6IWhsJ/2TLJyfo6IQioq0k3xtF5yT5KoOiJg4fVIWHWeD25QpHRX3rk1Iy/j0sQ/aUBxvhJSaX1tSRvo7zyRLY2areUNjOld8nbE9Nz2ijXJLS0F24xPBfnUO7vZiid2RmoElyYTQDLhgz3vXW7PdhucU7mUQzGfjR3ara2YYobRfubfQlfhpowjsSuE4IJ6xLnXcqxRz2o+qV3ycg1dq39VjpJUtKFf4qYOVAklz+he8p3GKT+It9kNvyoWcmWTRMq9MbRs6MqydkEJgL/lHzoF6AcAEbekunROrvgMxf8Zsxjf9jDq3VS/t2KWDT6UkDQVeOG5VNVZxipNwJaw== 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 VI1PR04MB10028.eurprd04.prod.outlook.com (2603:10a6:800:1db::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.18; Fri, 15 Nov 2024 03:03: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.017; Fri, 15 Nov 2024 03:03: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 v4 net-next 1/5] net: enetc: add Rx checksum offload for i.MX95 ENETC Date: Fri, 15 Nov 2024 10:47:40 +0800 Message-Id: <20241115024744.1903377-2-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115024744.1903377-1-wei.fang@nxp.com> References: <20241115024744.1903377-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI1PR02CA0047.apcprd02.prod.outlook.com (2603:1096:4:1f5::15) 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_|VI1PR04MB10028:EE_ X-MS-Office365-Filtering-Correlation-Id: f4222e3c-fa21-4392-6798-08dd0522156f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lMntpY3gQ8mQ0jB/Fdcj4frCN5/NyoFud+LsMKneD8aMcnLS69BKFtJYecWl?= =?us-ascii?Q?wUgyHqWii9jiyHT8Y5iB8bdNgWYjUrMKCozlj8bMMslCbDKy7qDiEeDjN/20?= =?us-ascii?Q?SwqaZL3SESe8TX6MO02U43cPTTpXaZiYg8GGNqvGwetTSGRGT0EDtom4AfI0?= =?us-ascii?Q?sRTHu1iGFQ/b89u5ASubryKSNoCJndAEKYhW0Kk6rh/G1wFPH5oewKJ/nNQA?= =?us-ascii?Q?F56L1VdBvRiclzE+bzRj5YnXT78FHvl2yeMFUr7qNcib187+W2rSift5siLs?= =?us-ascii?Q?b2kaKT8cQFFFk4RAbcpqCzxA2jKoY+tvYP30Ib/7vpm0WjdWoZkfoQvGDaN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F9mO6tVX1+5D3idRxJ9QVfHgKpneE7mm/v+aI9cmdO?= =?us-ascii?Q?hFJWTb9XhdXZTJcx5nEaY1yRO2mJBtspI6Eubph7GEsGBKXU1DK7uXa8CH5K?= =?us-ascii?Q?iA8rcmxfgcFv9znAYxkkRxJIV0VQvOuLNVaL4Qknnqno/+j6mNpo5L/WNm2Q?= =?us-ascii?Q?TD7k53k=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)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?E8encL5DnBwqsru32Kg/EgdSnX0Zjd3bI0z5lmJQQNrfJGYmFI2ht27C0A7c?= =?us-ascii?Q?5m5FupmIMKewrYPVcKKoQjStmoz88TRAHU28xrQRzE46Rl3HmeCBykbiePwO?= =?us-ascii?Q?Flkl3sWX0c/Ft+uWq88kmyrSr+3NQRYBfHIPmuT1Jnu9Y3R2YBD1Nv5coA2C?= =?us-ascii?Q?Y5YMFh3nSzQMAbBGtGZYZJ99yb+6GmkaE6V/OicnWFiAAnmRTVjKVD+pS2e4?= =?us-ascii?Q?MXAvdyzHVpW5aZPhxm/ZKI8d4nEdDlLTCCadDVZnMkchfhnjUC/JV8gqwuCU?= =?us-ascii?Q?75Q5rv0NEFaYUBxCGXemfY0rksqjSfnLpgGwuY8PUtoOHEtJpYCT9BNgYx/W?= =?us-ascii?Q?wVLzlnFfrB8BsnZe9BkC5la6mgEByIT1yy0C/2dyBaOH66tra3MzQiLMnWXJ?= =?us-ascii?Q?hz08/0CdBhn5kav33RIHvIg1i6PC8i62m9hF89Ul+A5OGr6lJcLArMQZwD2o?= =?us-ascii?Q?/1mh0SxSZ9PHpJea7kcgV3hLGAVfTSEfR1jQx286KbVBCaZwhVPysu2KkZrB?= =?us-ascii?Q?YGLHeiuiooB/zBK48TBxhIjv+IUPO8+qx5czNgmM6UCt3Adw5gDLMhVdE9/J?= =?us-ascii?Q?bcK+/6TJVfzs8Jyy9yJxAjki2wPi1lX94ID6EuRIvJdg3XFJ3Cii1scQOcTZ?= =?us-ascii?Q?L8rp2tsnV3yUrisekKSjFA8w57ZridCmvSFE/YbyXv7PdFxPr2LA0YVTUVpX?= =?us-ascii?Q?eU4P9sBsyYDct/wvF6Gn5NQJv73FTCMDnN7D0bckBcmmmSk49Crv3qkOHCRu?= =?us-ascii?Q?evreP1NoFc3ZB+VNMI29xbU3vjcMHuDBM1vLSb6Sa+2HX2YLeYdRUQ+nZpVD?= =?us-ascii?Q?foe0sWdaD/8efB499jWS39cBuVFF9Qt5odmeL/WS73bAVhHb1W6FpgGq5iy8?= =?us-ascii?Q?RdsyWyr00yHlYlhV5MU759i9K23LFL68AO42SpHFQXi266BhIIu7yR9hr3d+?= =?us-ascii?Q?c4SxOxGyeGalRwtPZ5+e+NQL2UHD2tyk06RWYqsX7bpBDnKUklvmHawv7i/W?= =?us-ascii?Q?aBi+pmewwRXx/lOJSgoP/LXDvlF6JcK5EI1iMZOmYoz1LRjCAMjHvP4ipPe7?= =?us-ascii?Q?czB19PcHDKNHEQ++zp4tVUocrMTRJqUIy6G3lY6SU0Le+4au3yu45NObAZQ1?= =?us-ascii?Q?qafDXd7M+940lpadZKSFRSYFROByss/m8cAmmJd12msrY/roLxRKMEVxD98I?= =?us-ascii?Q?UPetBT6pQtnZJn+cV5pyPw0EsRTvUqeIRVryuc/6WLQcDknOI8JXnH+VEquF?= =?us-ascii?Q?Y4isnBRLRNGqsftX7TMusBJySIh/G1u3ObmVYzBXh+UPWk6uY0L+qEQZg7p8?= =?us-ascii?Q?8ZcrWeRZt+5rr0+ubLsJ9t0QcPbItjj34Attz6H94O0CDosXfkU7gcXBHvoe?= =?us-ascii?Q?3ol8qRd76YGns8cYj21Gn1hDcjTGhHQCAAuJrACF3bfLBMwQT0hWTvqMmWiM?= =?us-ascii?Q?gF+ai/fDspyXzsApST7S+l+ZR/Wia4KYPTil5E4zOoqEqZ/t6euF8JWIqMtF?= =?us-ascii?Q?BFfpMAIh+PWRXX2CHUpZEqSIJmtbLxWltQ2533bbEAYRNjp7javq6l2RqPtI?= =?us-ascii?Q?o2dtAi/BYKUGXfVst7JdGURW1XTARkJIUEg0cX3s?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4222e3c-fa21-4392-6798-08dd0522156f X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2024 03:03:30.5723 (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: 7WsgkZ/vZr8670Gdnom3Gya+834LzMyXUPb5UFfXA0vpI5tULo+Rh1gpGeROihMzqoeUrjikwM+nqmGnL2TyJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 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 --- 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 Fri Nov 22 22:51:47 2024 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2068.outbound.protection.outlook.com [40.107.21.68]) (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 34E8515EFA1; Fri, 15 Nov 2024 03:03:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731639820; cv=fail; b=qn4+9+xnMwVwLXF+lcuMxa/1QKzzv9zt71ozKgKw/IatGz7yD7D2MwW5KEO18/+fb9Ubw6eNxmoth2ApVhkRtpiPuXEtR46tToUbTWMsuIuDsP6m/Lj0pz9DNSGeRtGN0lUnDYU6TG3COCdAjUV9u0XsYBsJgktz16fqEFcwUhI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731639820; c=relaxed/simple; bh=wvcwA0TcQ2lY7UCi56C7BFzkvVyhvP1G7nl+byj0pCk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=EwnvskvvnZF2zptgFfMVawnsI+i0QRj9lHUGg5WNo3jvbv6HlVeASJkJoz2RjP4H68w99h9HYezrvrAhgCvIknvpaMdt3+Kr7o5ZmDl5sn+PMLfFNMz9qkpt+qUxly4qETXUdXkMrA+fr1n7V7gREvBekaaqo9lf40rEIc0gJ3o= 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=nnBJpq2k; arc=fail smtp.client-ip=40.107.21.68 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="nnBJpq2k" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V6/yjI3ctHocQi2G//sj42heLJ56P8CvBrPEER9AkdGtWbiUtW7bajtyYY2HA/3B8aRR8uPoFC/+WN34omCT4nSltqI8n2GvhSNoWKRi12HzSglgi4iBT/B65DDoMKQNbbvCK+cmBUUQF8jGbmNFe7yJASruKkPCuoxtlPDisjJsVKwt/7szZjMlkVW0E5L1JiUgB85gAedR16iUuk6HMjaEZ2Yb1vCRQ+kEeDWUyO6PWu8urfZMFaAtK/h4un50h0t0LXDQC6dN+Ve+Ul6WImk6u3ygb4+B2WtbvZj5iu4se+FsJi7Y9x9k6HQUSfX+iudKbb9LXxiTIpIbmdOJTw== 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=RI7n+9YpO7BspDRS6jV2qe1q7HOQ29KetcpUYE3oZA0=; b=DzOeREDQ9YoZj/N042UIlziVBEaZ/hP2lMydEb+nrkuvWdD8XylVX9Pf0QD3HxaU7kpEUBMC7cG9NmTxcG0O5BHuMHZZ8QE4R7FnupMjjf8zrxUWIEtzyd2oSmgBJuEg4qU5cv/wUvoaMjBR1FBK3EFdZ0TGN5lkMzfqkVwmKIq3iMHpOq2YAcWDCYh1pLFrQwxV5tGxqARvWNDqpUZ6HUnbHMpuVRfFO06L8WFmtZo0GrkDmYfUpgY7SpIvQAjjqRjnoCA4oT6C8MeonQ9ZNA+gklcIQcXoVdH+yFNuzik3X+1eOPSsd2aG+FAZlPo5b+aOx71DXOG1c2jZ1OcRPw== 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=RI7n+9YpO7BspDRS6jV2qe1q7HOQ29KetcpUYE3oZA0=; b=nnBJpq2kZsl8i8hOdRqq1kXmQKnOOsEBhoRQjqlFv0c9HY/FwJEVg/hkiEgOk7cuI2uhEYQ90uK9CsVZdyhvIipngYN0jY/Pr8D58170UueWIQA4KnX03HoJyqgUlCIFgbISNw/BNk95sV5ZUnHlNdmrL6aFzOA6hQzb/TDB4eViCfcJUydsQK1wlsEso79gKHQijR/Yzo99ZtBHz+Ue4w48jzAOacrNQV1dANFxcerVXYv4fFEsNUvy2qGxvLHvhLUh5cWRmz18nBOhQf6C1YkABbaXf9VnpTWuG1YYT6nIrjHm31vK8ePaWH/+wHaXTFkAKR9bJBl/sw9wiF1j/g== 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 VI1PR04MB10028.eurprd04.prod.outlook.com (2603:10a6:800:1db::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.18; Fri, 15 Nov 2024 03:03:35 +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.017; Fri, 15 Nov 2024 03:03:35 +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 v4 net-next 2/5] net: enetc: add Tx checksum offload for i.MX95 ENETC Date: Fri, 15 Nov 2024 10:47:41 +0800 Message-Id: <20241115024744.1903377-3-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115024744.1903377-1-wei.fang@nxp.com> References: <20241115024744.1903377-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI1PR02CA0047.apcprd02.prod.outlook.com (2603:1096:4:1f5::15) 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_|VI1PR04MB10028:EE_ X-MS-Office365-Filtering-Correlation-Id: 438dd3ee-ab96-4913-30bc-08dd0522182c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zvvDfoDSgc0WWbeDYVGIJAkuiWUV1JTjCLnjqPjjSjKxw83FXRw5UlHDspgl?= =?us-ascii?Q?a8MBLiyCb6QLBqJ+jEmCL9RxUOiHCCUGibRg2fGEEu1IS7SZ3FufVmy2Y7lB?= =?us-ascii?Q?t0EW4L/TOOpQOhAf6b+/JNHKqnaJzFAf2X/BPjOtdFT0yBwYjcw3E7tLcEPj?= =?us-ascii?Q?7SQngqj7x7z5YoFG93F34/FEQzHPJiFDolDephkZIwO9Or4MobWYpi2U471K?= =?us-ascii?Q?GDY4WlF7wp1Xbeajwx7h8ZJh2HUwtC1qU6oNhSTCLmfHLyjfggVaS5cr8dSE?= =?us-ascii?Q?JnzMNxbNGEBU9R63Klz5ra7qrF/Y3t871wyllZrrJMbEFZOk2gCeHddBbKs9?= =?us-ascii?Q?w++G8iEtoVAS6LlXRTr5XA0rjH9JhVbWoQ2iJE3u4gxWu3Oc57bZ3duedIKY?= =?us-ascii?Q?juuSp6W5abmdJOj70fk02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= =?us-ascii?Q?+MgIC3LMHpxKdUslKTObKgqrATdNVcrKTUhA8ftqPIA9LNMnU7IRrlxCMlkv?= =?us-ascii?Q?Aw202wk=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)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?BxCsuRbHK+1UeXP19tMq59B5IvOjySjgayhgnYFB3FQVDa0CZKNf8vHTu3Ka?= =?us-ascii?Q?v+pVFiuIDbUf71rSUARb48kSiydUZVjYMotMTQDaWef+haV3ZgwefSoB5by6?= =?us-ascii?Q?cAeh/TsjB8RIqAWrx7Qg+sfUDZ9MXYs4ZeLQg6CCW/e6lynFa3feygRK4kfP?= =?us-ascii?Q?u/+fFPOzjK1PuAd4jCzUOYkHWOwDOWtKpkUQYmUmx/fUC+pPJ/qjyhAwBTED?= =?us-ascii?Q?mfi94n2HsR8rYbr4LgkxsrPjb7NucTyf4eulGjtW/JICGlHVhEjQD7pNci9f?= =?us-ascii?Q?nfs8/Yu7F6QDJA57aNiIveoroESAvvpotJDPO6FnNcWhdrSMLMY4kFPrFSCz?= =?us-ascii?Q?fAFd2BRTAqmwNvG6d5k9WYr+vu9XJe55RWjnJFuo66b+tAQxC3kTLADkFLV2?= =?us-ascii?Q?UZLbIUCTZpR+8r+Z5/prwFQsLa2qGtUlSSV9NofHLMobiuyAAlHDYDS/K34R?= =?us-ascii?Q?CrEbrbXUxFVUUnuEFjZCo2SGDGdk2/WNbCeZPUCMsicFWgAmuxJ4xgwdX1jh?= =?us-ascii?Q?8+LYnxBfFOmm2uuMmq+Y4rfG7hNC4bWJqIwC9HcmVCo7IQkV1fDOZ21PKikG?= =?us-ascii?Q?Ds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ySkBJwX?= =?us-ascii?Q?KikgZsI9v0ScmF25DFkSN0GRampm9wPcco7SrICfoCfHY4O72sKz9pPDT+fe?= =?us-ascii?Q?7kZF5tr+MEq2noMVHZxLFMssBDeXphSk0zkURhSI?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 438dd3ee-ab96-4913-30bc-08dd0522182c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2024 03:03:35.1921 (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: 3OBpKfiQtfSVlMZqlJc6dgLe/q889FQiLT4bCBDMEXd/stnMQ8PJERJKiO43YKlOINSVNXhYcZjG4EV/h48R5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 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 --- drivers/net/ethernet/freescale/enetc/enetc.c | 51 ++++++++++++++++--- drivers/net/ethernet/freescale/enetc/enetc.h | 2 + .../net/ethernet/freescale/enetc/enetc_hw.h | 14 +++-- .../freescale/enetc/enetc_pf_common.c | 3 ++ 4 files changed, 60 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/eth= ernet/freescale/enetc/enetc.c index 3137b6ee62d3..eeefd536d051 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -143,6 +143,27 @@ static int enetc_ptp_parse(struct sk_buff *skb, u8 *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 inline bool enetc_skb_is_ipv6(struct sk_buff *skb) +{ + return vlan_get_protocol(skb) =3D=3D htons(ETH_P_IPV6); +} + +static inline 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,27 @@ 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.ipcs =3D enetc_skb_is_ipv6(skb) ? 0 : 1; + temp_bd.l3_hdr_size =3D skb_network_header_len(skb) / 4; + temp_bd.l3t =3D enetc_skb_is_ipv6(skb) ? 1 : 0; + 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)) { + dev_err(tx_ring->dev, "skb_checksum_help() error\n"); + + return 0; + } + } + } + i =3D tx_ring->next_to_use; txbd =3D ENETC_TXBD(*tx_ring, i); prefetchw(txbd); @@ -170,7 +212,6 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring= , struct sk_buff *skb) =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 +632,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 +665,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 +3323,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 Fri Nov 22 22:51: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 683B1176AB7; Fri, 15 Nov 2024 03:03:42 +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=1731639825; cv=fail; b=ZIZbYMb8na/NAmzOqO/r0Uf5VT/+ueTet9rqiKMvvrWVs9btdVUAntoVq9/V9a2T6DOZ2pRw7wtsGJF9aT9CLuQc14DhHiiihmrRDh/Tbj04hnncB+Lkdh3V6TZDoiGuqkUqaMS10mijw4e1pJVptaKpjkcrkCu8BVYtdR0N/fg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731639825; c=relaxed/simple; bh=SWBuTvYmdj+l000rued5AkC6nvwZZo8BOPcQf13pMv0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=uG0+Oc1gNWNk2gQbtKrE0sXeLAsegBLG6WqKciMtzXU5eiSJUKccF+8bUsisY5Zkti/OSUIvywFbYsGbvci+H4TAEb8vsRp/0tbwoHChVESMFDpOQl4I1VrkCuRZesEz3kulhNptsGd2tYKogwvFJxVC+p8l3N+j+zwy6e9Hds4= 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=QT1NpE39; 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="QT1NpE39" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dC2IhX8bY0muekWqTm8kWxs/Aly4c4FW6SMCxAakpqCSmVfQNtXVDRJrVtNZkJ2ubPWVhZyJJjnvHtHiIzIlETiggEYTIcf84rXgnDED3LUjJ1bU1phsUkthnxCU1sR1Yi0xqoPn9vStTee5wmy04wrRcxdWEENBigJFC2bYp+0Vucswf/CqH28/FwmiBwVCyqI2CRxT6z2ZoWjEgLe1qNrodmI57Hi6c02YfqOqOwaeQbD7UDZJNky1Yy0II2kTsKj7BWEpo9rGG7o1Cup2000PQqClfnEalvqZGkzzgXMc6sxHF8uKZ0KEdJsyyLKuYjbSSgxmw4HOEG+9haGJQw== 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=iGCDOkk2izEzTdvJ19yTFpJKyHMLmjxkpBFDGypQHCg=; b=SoR/PUwY+CiuO1pBOTQg5xAp3RZm4pcS2Xo0Jbg7RzWBoiwPP6ndwP5/P36YR4dyPhpQINgKqaJyHn/EA86GPDm01kL/IrEZLcqlhiwaJJSqYzTX8SduhVliD7kBjFLjL0fc6zNmc3IxGk6n/B3MtJCK7c8fmD+pHXP1q+HDSMqTdOVQ3zyrF3zlQRblnij+smSHdMZsEwE0aQ53FEPWpGmaJqiozg/POEjPLdD4pYTz1zwHpARJJCcxmmsivpD3NGX41ijMrbHgk+301nXMBCHz5idxbv6S47bNNjX8S30MxBZOLLvt6nv73nMHvIAmYHfyWSto3hhVSV+14LrtYg== 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=iGCDOkk2izEzTdvJ19yTFpJKyHMLmjxkpBFDGypQHCg=; b=QT1NpE39cfWvFSmWZNxVZ+Fu/trXZtsk6Lb/fbQVsEuMZvSUYJiQXpZcEbthqsILHhn+6HThrvjWVbqslo1u6JdlFRq29358kaF+NFurcdUBL3YosOo0C30hcnY6f+YJnfKWdzsbhrIKAhlyWjxx2Vhiz0+XdpVxlRMQB79mAXVA2HFO4lInACmVLXbMUkREOg6ytMByazOFO11iyCFvDlgQQVJJCGe8VJopQjJ/HHKcAla58KloQmxYwt2erdvCas6WT3F6XzhGl3Z0+pBuGVylACOts2Ip1sEChqgNV882VuKEwUc/LziUZ4BuVd1nLthJOkzcpft9XnzhCqO4zg== 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 VI1PR04MB10028.eurprd04.prod.outlook.com (2603:10a6:800:1db::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.18; Fri, 15 Nov 2024 03:03:40 +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.017; Fri, 15 Nov 2024 03:03:40 +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 v4 net-next 3/5] net: enetc: update max chained Tx BD number for i.MX95 ENETC Date: Fri, 15 Nov 2024 10:47:42 +0800 Message-Id: <20241115024744.1903377-4-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115024744.1903377-1-wei.fang@nxp.com> References: <20241115024744.1903377-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI1PR02CA0047.apcprd02.prod.outlook.com (2603:1096:4:1f5::15) 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_|VI1PR04MB10028:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b0e1b9e-b86d-4614-167a-08dd05221b51 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?iiYN7OWe1mvRdvXk1oq5MIp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YkbiZNZxQWWyRcJs+6J5Hb2lzWN71Aq6iq7Vkf2eH06B/CR67/Go?= =?us-ascii?Q?lHdzA4q8XaApZKj9WJiX8ENCtFovzwz/G6u8k1huj1+4hy9UcnG1eaGqLkWV?= =?us-ascii?Q?w/LtqA94vcguIXmp9mX46GcvzYepwo9lzg5nNXZkjqVIqJZnRkHfMLh1XZLe?= =?us-ascii?Q?+45fjbfoLyR+rSZ9OSmLRTxTmC3kE9DTX0gIY2DxhBtI7f/mxvZgpDvO9LZ2?= =?us-ascii?Q?xw+BemNcEAVaOSilvJpiQLBJNEWE2ei6XPKkRqbdv8i8rRnGtia7qz6rccpg?= =?us-ascii?Q?j7Mg2NFgQa5eULtTNRRvO+tNylaTYzq0IU/Lf/iAKqrXZ+/RLZQqusdxn19e?= =?us-ascii?Q?pQXKW42OFLeXFJiUvroTURSC6bzP682FqITqauBDQHKJlfg6eDvylYdQ/60+?= =?us-ascii?Q?OP+I6svyE6FT52+9pg005Xen/8Rk+TSZrTNO8ySct+kX2LTOCgnlbL+NGK9w?= =?us-ascii?Q?pUBqupo=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)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?YNOoov39xrybEUiEf9GWVBn55cMBzlTTyXsS7qkH3bXVX/xBPorXckEXlH3u?= =?us-ascii?Q?HD53zNRdGasNLh9t/js8tdrGmFKa+g09NGl6gNEflMegNsJ2psBFHJ0SkWhx?= =?us-ascii?Q?fDGVt0O5OItQkQc6kYBVxgt9tT4zIA9w+3FRrlkGUrAOd7rr+4uHsot9Ezhe?= =?us-ascii?Q?DsDl7c/JwZGGC4SjN0pf0klbgPUcyypuhdfL8paUAsNe2qe6eDPB1I3k8+10?= =?us-ascii?Q?WOPA+EB6jLq6xHC4BWmIaPlYzt9Pl4SQONJ5GzhHPmKmkHAaCA1GdbmhywTC?= =?us-ascii?Q?fUhR+plU6eS0DGQWxWSiUIXahqphMf40Zw6jK77uMgsYt0RVlzK9b602FMZ7?= =?us-ascii?Q?eZfwPlcz4H9iwTOusnvZSGitFOuDgStnFNSQhICB5rKRrGSQ/YVpTr73Wmny?= =?us-ascii?Q?8IBezIs8t4wc2znrR55F7OJ2s9nR6fobJZ/gPZL/H6jxbOE0EkyMQYjHJQl1?= =?us-ascii?Q?N3MC5DLiCKhKTDjbkF9SOsXnt2+Z0UGEBYlVXmDjKYgbE5vYuABND7vvN0dT?= =?us-ascii?Q?Kba9Z0n6IBr59pOHK4SFhiITTileOjotbSO9FYyFI76Ry26UnvOkxTUSlD+v?= =?us-ascii?Q?F5bHU32ivgbqhiNgd5QaioT5VVW2z32NjnY1hjl6clhfn68BkeL7VrkgrYZL?= =?us-ascii?Q?lU2SFJLEfvqOrCwzwft6DlvaF9/My3Z1YIlvYufdkEr9RAVuLw2oO+clnQeb?= =?us-ascii?Q?16HFr27vRUU8cmRoKxp7FDciCquzFHmwPJq/myPy4duM1XXK4fvt6g1MgMdq?= =?us-ascii?Q?qSGRiP8gSFA5FhC5FhjbCRGUdx/AMhz4kyX7QLld+s/DhVmGMEkONhCBAuhQ?= =?us-ascii?Q?zhAmVVEORG7FsVYT1083+CUISJ8SycrdgrXs2NbybieJ/Dj3p8CDNXT8clZ4?= =?us-ascii?Q?anspMATY7OyZ6LGvdKPDe709BbE92Z22NAp8YAszERgpM3KuziWvQr3Xrzee?= =?us-ascii?Q?6tguVX1FyiaVkaHul473tLIax30pclH0KMbxPZ5VXe5HefP1K2zk62MYhS9R?= =?us-ascii?Q?beurGRrLRFtXP+krkeTbhPnToypR50UuSvQHm2OQZjLBgbM7d0KvB0HoQ/HO?= =?us-ascii?Q?wXfPF2Nr6zdFiKGMlyu3Ji9l+O4otWrwxIdc3mm6TCVdJqqMlezC/l5nBr+u?= =?us-ascii?Q?mT0oBgNeGJC2Bj1NsI5kahBlJ1MmA89d2KzKuoqKRB8Q6BkzXnv8HMM13Y6W?= =?us-ascii?Q?TizDBg6NzdZ/6EKV5v0gif0wk6v5aJLW+VaPgFiELFKd/f47Eo74Obc1sPn+?= =?us-ascii?Q?FwTcxkX+orJwkks8gL0ZTcR8X6SQebLplYIzXPYiQNunTxMiWUTV7TAjlqD8?= =?us-ascii?Q?HS7zYCQM4vEWTG9RidXVaJe/AWvDa4Uomjo3Gb682DbxaAnRPJzoBflH7mP4?= =?us-ascii?Q?CbIXGC/01pgFNJmgO1hxiVUO+W5Oq0laP0+Wkls0u8h426dk2h0awyyMovKv?= =?us-ascii?Q?2L5yRbg2BUZeqoMiiXs4exudTGkFJgtRb0cdZXCbc/zuXB4Wdt0GYp56m3zx?= =?us-ascii?Q?xipgZv527e7sMkC27SWjzWLohZihKJ4V5P8Xt26QtMduv0PrXs2WSbF6TqrN?= =?us-ascii?Q?e6P7yBTWhj9X5+f9D/i/NY57eYYr31r+Q6CHD4AI?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b0e1b9e-b86d-4614-167a-08dd05221b51 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2024 03:03:40.4893 (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: PQI0dn23NEBSIYf7m0yZhSt6yC0lb7y3Z/XlVjTuQcw3tbViwVZaPNgNEzqs85+iL3T5V1j+mdanuQdYVRlssQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 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 --- 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 eeefd536d051..7c6b844c2e96 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -529,6 +529,7 @@ static void enetc_tso_complete_csum(struct enetc_bdr *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; @@ -594,7 +595,7 @@ static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_= ring, struct sk_buff *skb bd_data_num++; tso_build_data(skb, &tso, size); =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 @@ -655,7 +656,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 @@ -673,7 +674,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; @@ -941,7 +942,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 @@ -3316,6 +3318,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 @@ -3324,11 +3327,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 Fri Nov 22 22:51:47 2024 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2085.outbound.protection.outlook.com [40.107.105.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 82A6114F9D9; Fri, 15 Nov 2024 03:03:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731639831; cv=fail; b=j+lxo0RL7sHGzn3ve0UsANd2T4/sZHKtwwaOaesSJBA8UpjtoCykaW24Cwi7oV5+nqymk3mJirHHS+YOfN+2MOLCBMvPj81UtIQ3xpuUBLIKGnV0gGXZBvzHSIAaHu20tuNQcybaPWKQgipAY/fgMIGCAyxdY+FYTPgsgXqPUxw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731639831; c=relaxed/simple; bh=jDzdflMFBGLq7JisXPAx45zswPL1Xdmze9bB6OwstL4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=rP+EcZ8pyPksyhmXlGnNhktT075ahxGCwPKGNgieiuEWtBJj/GpQXC3E60W7XqYndileP0ZgqBTfg3ayP5QBQPtUOxgPMHjMFTvRR/PeskMPZJyAHv6E8VWQIIqfof6cazpCpUpaUJelZ5t/yFd9QzZhfCyqYeBigUgbH/XmpbY= 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=i5ok+M9B; arc=fail smtp.client-ip=40.107.105.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="i5ok+M9B" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=q9QkM/ek08CSyHpFyQZRXxdFvrf4bA78rMAPWNMT7F8FLcZo7I5tPUWfPUO4hbeuyU/Yp7uOIv3EWJaX9u8eFmD4jqYjESQRt7yjPWfV7RJA8IgW/gAjl4hNKRkm7BUtwKxuhPj1wjkoMZeCFNWk/1gutwCCal4dAt3nBFzwSW8aOGpolDyou1L0Qx5VJ5AAD347i5H/kV9mSDxcMrT58orRQCbyxBHBZqL2Ab7lMoys2CuuL4X03N1C73cIO1q2XkIDfm9ynzHL4iRIn44fuI9FPCJDblXVTB2owQLrEtdZrn/TITkrgmCDt2erqAloWOOTki3BNDHqktaiMHlIuA== 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=BVIfY2blyRDn27O2nVcGRh/gl54CkwsBRLjQmOShMIs=; b=HGtsL6YGz+bgQ3JHGQLzsMHLvUn0G1wIakD0AaIzmTV8/z9tW0WcAbD8f8UBRnYEZoYy72fof83pj7XIVscFG8ShAmyERBvb+t+0d65tn7MRFPe6UR8q2gqWESB448vEdAxjEFv7ytLsKQZ4eM50G6qrs2cYz+mU0ewYXWGPmBFF/el+qcyoO0qj0bn54t2Eg7I2rOCsc+4JOjbs9Dj9q62VXsFv8tm1OwK7XpdjafvIpjXORP99OnfePzw/f8z+O0hbdH2hlzcHHLKI6/M4lqrl1tBMIUZIoVwJmY4CN8AX44U1MZO9rKHkSLeCaK148+qgB7hWleQw+TJvrPCWWQ== 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=BVIfY2blyRDn27O2nVcGRh/gl54CkwsBRLjQmOShMIs=; b=i5ok+M9Ba1HKdmjD/bKXn/yxkooVp35Nx6KAfllZkc42aBgyBOm3iwv57vIyOdXTksJfrsTEJfMpIuzp/hpsAPT7KAdTYZYD/zuA9SbmN6aC2k8007peJjq4BCLgKtPlNEFYMIZ1KqsMbb3f4Ll5t+g6rtBRTlPSs/kneMBT3i7teqBV/7zhNGRnjFdT6A+TxynE5UJ9UrrgskHYOcVGxQ7yFYt7yaAX/wk3dv80e7Fy+yoXY68vuyKp9wtsQGZ7JP1pxwAMKNAK6cVg/RRaoVlmZzZUsqmHZ8zpD7UkuM2nASCMBngkGSM3qgRre1t+Djr3gDh+tEJpHreCLSjDEQ== 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 VI1PR04MB10028.eurprd04.prod.outlook.com (2603:10a6:800:1db::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.18; Fri, 15 Nov 2024 03:03:45 +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.017; Fri, 15 Nov 2024 03:03:45 +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 v4 net-next 4/5] net: enetc: add LSO support for i.MX95 ENETC PF Date: Fri, 15 Nov 2024 10:47:43 +0800 Message-Id: <20241115024744.1903377-5-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115024744.1903377-1-wei.fang@nxp.com> References: <20241115024744.1903377-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI1PR02CA0047.apcprd02.prod.outlook.com (2603:1096:4:1f5::15) 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_|VI1PR04MB10028:EE_ X-MS-Office365-Filtering-Correlation-Id: 64069a76-83b1-4241-b178-08dd05221e69 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?LkzXnqPJ3A3vnLKh2q74ZHIP2BXxSvtapyiHG8T5hWFwa9u8WiBIF9uxRMbO?= =?us-ascii?Q?tEVsrp3l74nmMOfMN2mDjThftQBQSwl1yioNcbgA0AohYjU/r33/M3SnqdDE?= =?us-ascii?Q?AbH0NFo64aGcYCrxCUeKilSijDYOeEnwEQqdLr0HziEcUW7AGJV5EuEZ6+mx?= =?us-ascii?Q?NUeocJaKSToUc0cZtcOhfz1oks/OR/zVAzBMuK2kwKFpFJI9OX9/lR9nsxwQ?= =?us-ascii?Q?OJ1yWe5DbmJDe9yOS6GkZJW/38Al1bce9/727Z/aMIeu22lV3eHKX0JpgEWp?= =?us-ascii?Q?NBv7OF3NFIhtiDwpOE/4ajHCifrsExVwxoNeXMsF6U/b7Cf7OR/EZgCfawZm?= =?us-ascii?Q?s7ACpxc3WGshjakilJgkDB2+eSf3cA83aleHoZ0GDSuVQjjzGnIAkifnouAr?= =?us-ascii?Q?dV4onH3m14VeyliRQhl4OcpKooBeY5LK09Ls2R/e8bo3NOt0E3fdQTt6RCB1?= =?us-ascii?Q?ZUcVxJ0wRO3GZUV08X8K6a4NbzYGZR0ucGBbIXPxK4Z9eZaSmhaAJqD/+NsZ?= =?us-ascii?Q?+2Iv8v4k3b/oQOjc8WvEy27hzrR1+RHQGfPTtQBVY66cMpKdtIxCyD2spSMz?= =?us-ascii?Q?DzOsCqwsgTTl2pEZ6i+mcINIJKikoC8ozvSazAIUIjRpE6M6y5JhT0uxhgYX?= =?us-ascii?Q?NIqGRoJSHKkZ3/Iw6gSuPLtb0PzIceuqfb8zdc6XQ5U+oP/+OcsiZrCPQbgb?= =?us-ascii?Q?7jXQ7ZkLcXZpvObpV1CMxSuHVeYxJ3CCZM9XhS2P1JkwTyEHh5ArDjLSdiKI?= =?us-ascii?Q?s3BND5axt/XRs9yN5v3X5hAYY3JTZdVKNibxGnbl01r8c/1WJPb8ArTnMzM+?= =?us-ascii?Q?6lZAQTLPH3bnV7rEPF7vaFlzCg99pFxOTJaCFPJdk7uzB4ru0ti9sbgmnBGn?= =?us-ascii?Q?ItAAKahPfoCczQWMqnDv8w/z3YkdmjtpvNpPD9Z4FZ+/nNl7PZZd/UupkCv2?= =?us-ascii?Q?nRyc6Aj2uih5jnxwzSFn5Ev/uNoszVJ7ByTxEmeWMlRBynERVo4EvC2jutE6?= =?us-ascii?Q?nDW1LF7N8G5LA218Blf4ulnPYORvqk1NtODh1KP5qEtZx0SORZybOb7r6UWb?= =?us-ascii?Q?YlTqZneBAiFqJWR/+AaC7nfC+FisgkaqjfJCkPEQI368MrHK09Q6kd2vNtcc?= =?us-ascii?Q?aBSnuZbkrHjmfS0D0qhLpjcDvqmaIHW7UqeufvyjADv6IUtkN1YcjOOh/ojt?= =?us-ascii?Q?IGjT82DWllRi5xOOGd8kfx4q3WyXnXu/PH5hJmEz5zyqcq3CZ2F9l8ue6YQG?= =?us-ascii?Q?tN2G9+Tusx9JTbxfkBJEDN8juXrZsHSdbfo9e+Zg6oF78Xye54tMGWR4WIWN?= =?us-ascii?Q?1ILN05A7L7ugG0t00/zPxOlxPu8Fej03NTNhAwX0/W1zKLt4WO0/w4mmP6tq?= =?us-ascii?Q?6GtCQy0=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)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?vx5bRDgcoFlART4O7sPX0VXUhkjhPkIsLRqmv8gKBQg9lJEi0SuY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E6+FPo0iUy8yfq3HAt4UE86xjDixJMmlfM2Ei?= =?us-ascii?Q?1Hc1Y6ecPnTYVyGlTrUjppqIEmgjCAv9bPNcOpE/T1RCecFR8k+dOryiIkUv?= =?us-ascii?Q?k1LmQq5pfc3uUeV4ZV8I7P2pMmbvtbbaPTDy7sRvXe2rCHOgaCiSL11yIFDS?= =?us-ascii?Q?9ToDz5DbQpASQO8p19cjm4+h3NCChtPzbiTABkcLgf4sACK5HopzoiLjM8sH?= =?us-ascii?Q?NUMshSP29TukwopoUUOdVYM3CNmSCWw1cQpJipMetRpnQmY+ZZafGcatAyNm?= =?us-ascii?Q?Wn3bw4YVHi4W0VfsvAyj6bCCtJBn/gUMbKIHwyskT5eBW5cr+x6zLGHC/JZV?= =?us-ascii?Q?b0Tgc4KpIoZKdu4t1vDjvYuXfcOCtD2zLdDxdDcAyCLW1JevGd5L/DQDcJVF?= =?us-ascii?Q?O9pJEauRE1m79/kw9h1aMirLpVcglmTrRc1ulPEFwgVWNFj9sNzaY6ipqbGb?= =?us-ascii?Q?y4GMcXwRtH5Q6vwD7okpGH0TGI+EoEGIScil9s/DE+3fdYTJ+KV8fZ4P4oF0?= =?us-ascii?Q?lqYS6i8qAWd/5Zhiq9WVXLGrxpwuLxHWETn7oPAeRab9VFHKxjJBv4v5THhB?= =?us-ascii?Q?oVc9jCaaFmFuhmbwQt2TzI1y7VVJH+wtFEd3v84EXJZ1mma0gH55WJq39BVM?= =?us-ascii?Q?t7Qxea4C21UMk6z6cpdlSmhWNJk+Z8ZJM6WorJE1?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 64069a76-83b1-4241-b178-08dd05221e69 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2024 03:03:45.7634 (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: BraBmCBOXLj4R/RXAku5836VPIvo7zcjvJa0yYrUgRhpoSw6oe4ZDO91CJf74wesNTQz/4skKMKaW0IDC3n87A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 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 --- 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 7c6b844c2e96..d05eaaf8a812 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -527,6 +527,233 @@ static void enetc_tso_complete_csum(struct enetc_bdr = *tx_ring, struct tso_t *tso } } =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); @@ -647,14 +874,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))) @@ -1800,6 +2039,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 @@ -2104,6 +2346,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; @@ -2117,6 +2366,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 Fri Nov 22 22:51:47 2024 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2041.outbound.protection.outlook.com [40.107.20.41]) (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 5694317E017; Fri, 15 Nov 2024 03:03:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731639835; cv=fail; b=kixjAxVRQqH9VS4gZCRYbjK6P+m3D2sqrPLQvdwlrt43Jc/eFZiUUsHHXUAI1O1FF7LbJS0Im4uXPJusl8A3IHUREq72p9XqqrF+teS0f7WhfBBHNAv2eIGW+UAnwL4Ot4ejmFfhn/GkAdW4LNmzXBwDdjSGC8Ou5yHOpTNfDbM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731639835; c=relaxed/simple; bh=Nkk4AxYQjfxXdQi3GPscmfEoEXJ5yNP8kfWbHa31cok=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=EbUZ4XZE+otLQP7gIADu5pSmm+/MSqv39tnLcp453D+HkMcLKNH8SSsDKdiMmlrQ9nWojgrRL6c8GoWS03sPvSyBrEZoCeN4w+uCAvdcdLp38Fw6jYTaFx0eVoB2ZX221aRBWeh4KHCSfhboZU4kMAuIg08qHlYQ9p31nB0Xa+U= 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=RQiNBmMl; arc=fail smtp.client-ip=40.107.20.41 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="RQiNBmMl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ccRkElgwHP7ctIz2BAUeNvXbj30mCHyuXDjnwhD6P/u1C+57LREAtAJ0qLO3S9NShJCJeolXLTdWoIU84Ps2dGQgeXm0ksbzBBEx1M26WWKlThfca/E7W+f3NNnfl13gHH0n+tRvSDxwSKPVKTb+HCiQ7HWTl3ogp0QEj0GH/EaGNVHp42nHQRQCjizCSEM4U0iEwz/FljydX4nZ4OfiSBF5zSmK5+8nsvYpoHfqHQMNwgeg5ZhugfuP7FWZTwBRrU/snBGzYwuxtNTuaBY47buQLbsSIFmKSgPBOBC8knwXkjzT2giY2Bw2khObEgsaX+IQ/oTI0XiIAS/JO85Jlw== 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=eSRSkCcH5OvfN4cZ4Cjkba+bZxVcDFUWG7inqlrM8mw=; b=YHAm/RQIvJ1/dcJqnNquiYfyvtyf4RZIhwZuQkDz08Mbp/QmYXntspFhERhHC5jNTIRwshIVSnJBVgy0Z57or+3lXJcKHSorbqHFdcuywiwT2BemfOOp2+LR3502mUbE3M3OfZwRNiV8xAIfEYIajdaZfLORiOOPBEHLrfdBVZANA9kikwnQRYhlmMwuaspg+b96ERUNfhvL3zh7bnymfCPJsqZ4NX6iyELQzNEKwAYLhOoW3g/+EiNr/4ESamDtC58aks5rKuPTDt6wBkHseuhlo3S3XYt+8vi/72RMD7pgp+CgD0nYZOc1+ISDKbrm+Ker99FW/0tONamzPD17PA== 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=eSRSkCcH5OvfN4cZ4Cjkba+bZxVcDFUWG7inqlrM8mw=; b=RQiNBmMlhQ8Bey+Xu+HlDEO5aLSSgVZTY7tYGgGxhiFVdS3MTzy6I6xCNA6T0tHfbriJiGf5YbF7zH6ANKuG/+TvbuOQJ/frynNqiJf5y+Xd4WSBRO3vWUsFVIx2+/iNACCUkbFcSImdCIXKrVd4vElYZzoJ+AOMu/yam93p5tVV98oQa+0KwpczruDIse5+iwdH4ZgnR6aBsp/CdFxXagp38V3XpG6lMyAlPKYs29f7kHs57yDfTA3KrxNparCGs8wYWj0yc70dD4gBkpw9+BmOba3GY2uKRvGjaYO1nRrxvXIpnFTi7Z5cl2lQR2OiWsINrrHv568CjZFR2aD90g== 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 VI1PR04MB10028.eurprd04.prod.outlook.com (2603:10a6:800:1db::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.18; Fri, 15 Nov 2024 03:03:50 +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.017; Fri, 15 Nov 2024 03:03:50 +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 v4 net-next 5/5] net: enetc: add UDP segmentation offload support Date: Fri, 15 Nov 2024 10:47:44 +0800 Message-Id: <20241115024744.1903377-6-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115024744.1903377-1-wei.fang@nxp.com> References: <20241115024744.1903377-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI1PR02CA0047.apcprd02.prod.outlook.com (2603:1096:4:1f5::15) 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_|VI1PR04MB10028:EE_ X-MS-Office365-Filtering-Correlation-Id: a7d0fafb-cbeb-4140-e9b7-08dd05222170 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lrjqvaX/+CnrIOm2vHoWMwAJZiRYJ9jvrNXLFQPEhqhYyxQofLnJw837ynAg?= =?us-ascii?Q?N8NOPvc6BHJvKU0xBZO2W68nJBIJMAVMcu31HLDN7jFdtHBunBr4c2LkKGjn?= =?us-ascii?Q?DwUudxYIqp/DyIjIC1P5ypxXYtJFHVXE4YCYoBF6C+KToigth+tOMAf1GIQX?= =?us-ascii?Q?pOaTnsGr2hGIrqXGQZ3wcAeEZow5Rs2zcfIWzlZaRnkBdQys43b33jkyMxZE?= =?us-ascii?Q?lcFPkOQKslpqdSkXT5uuVeWMui/8TtpoKomF3RPxFkQ5OIBCscZ+NHGhRItN?= =?us-ascii?Q?efU5QpaABCcZZ7lKbgjixwdrwf2dm17q041YgQQJx13yL2bVgJxoBYq/69mO?= =?us-ascii?Q?fG5HHFge+4sZ/WcLzqk4/1C0DfVVMwcwiOQ/4/iRtj3Enh3mf2lR1DaxdKkd?= =?us-ascii?Q?pN0oJpiZCiT5XFAdww4PKk1cHO9VmNaLdHcV5btOi3kiD2/Fuv5Z79MI+RV+?= =?us-ascii?Q?ewNRfZCqvF91aA5jZDhiHhZwdgGw2nmGZNvUxQntYp2uqwl9II2WXaQyIKuB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-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)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?mdzw2PxkViL7fmxGSkqB2sYdq5Ewj8jGI3Q28LY0kUbPao6zxkw8Bmtd+EDP?= =?us-ascii?Q?+uW+P36JS7yaAR07eNpQd1tdLHN7a3voDRvLIGV07b3+9OoFxnhVZeoPg2cn?= =?us-ascii?Q?gF+n9byrqcmxmE0Ul4vb7u/zqqr315npkc+WgnN6qvfO2MGRHof5YA2es7/q?= =?us-ascii?Q?loLjLaX0qrvPqCxyRdhn7YaZsIHcFrJJR4zz0OLxtoNxuFQ/9uzr0ZaJ2D+a?= =?us-ascii?Q?ikUaiLdzWL5vZS/F/e3V30WhFhqQl9BowJjxS6ToMasJ8PwzpG7XpXA8AQt6?= =?us-ascii?Q?ihawBb2jSJnJc4V6Q+GDyM/7B8EWEUIlYH3dr581fahfytNRamtTti4gBgOt?= =?us-ascii?Q?9vEaI6VhXTAXCI5Fpv+uqZfTfPKNZhgJsBr/QUGyVKAfuVdQbBBBOZtb5dyi?= =?us-ascii?Q?DTyxbunwSA7KC73vBmqBrzqgJFtISuAtH/6kMd/nbPUUQn/d8EN6KbO4rgvR?= =?us-ascii?Q?DmR3IxWqPd+9chfePF/Kz2GPqgmAmdeWrVSQoutg84V8Vc0y5ZOUvsf3ywuO?= =?us-ascii?Q?l4jsifQPi2ylf5LkxxP25mvmIKjqt6h/dNn5v+Th6TxfOXCtb1R+t5III50g?= =?us-ascii?Q?iRyLFcyJVxWbAMzy0Jxi3KyEmyUDCeLwsrPdBNMaiS/QBgjqBrRMtwHq2K5K?= =?us-ascii?Q?Mqdn3O5upYDIBB/WdibSrYISz08wRuiZu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l58ZFfPc+18O3HqPANgMXweItEPVq1SrKgcP?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a7d0fafb-cbeb-4140-e9b7-08dd05222170 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2024 03:03:50.6938 (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: 3rPHZ1+L+rHSFP1rvm9lGQi2XQkmnhH+YARIg/Qt6x0aGVMrWZoafhXfenPve18U6EkcvYQ9ecHJwLdmcwtMnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10028 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 --- 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