From nobody Sun Nov 24 06:08:36 2024 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011006.outbound.protection.outlook.com [52.101.65.6]) (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 7D37318FDA5; Thu, 7 Nov 2024 03:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.6 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951639; cv=fail; b=icNIWUPqm6iza0iPEpacAdgUaWozMRwSx+bfzRqL2xVS7q/kM1CAD+sKreZDOhieu/9qlGtqZfhDo88ACAqSsJ8GfePp58qWEuSrkK+5smjVDItYRRNzdbAc+lUo1Q61W9iCUWCS2KFJOkD+/3ZRh5eQ7mD9Xzrey7vglohufis= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951639; c=relaxed/simple; bh=+LGRTaFdfhXebYqRbOeag0l9EBSOweGSeu9YfpQsGTo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=oGdxh7QryPjRJWzZBIA5eRRa+6YA75pgebpbDRqPhSh8uXcSECfcCPLsqV8trnDEMTd47wxDEhMNvF1O9yQLW8ZZTfOR5PtXPWRbNp424nIG3b/ORg+gAyqL5SYczURHnLCbAVYacLaESJ/iJ3ZV85zXw+u9c3Gkk77JXy/JnHE= 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=oJAEQmyY; arc=fail smtp.client-ip=52.101.65.6 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="oJAEQmyY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XaQOgT/EjNLMYVLNRQb4EWunJrZEL0+lrxHcMfMIqiPmtke5Un4elFD5dNQQFU+XgoPMK6KzlpezJuxNsRErD7cRgjxsP2mDg5MipjCwKaKhZ8nBomlrhxSe2q4EsGhxTDO5RRvN8a77yMjk7t7MNleWDeqNiuFt1h7Y4vQo8bEKsLK2ymz51GphqmUsJewlp0VOhStN8kiDDxDIcvZptANH3NSqV1DqWJi9fhibOSPOVo+f8OgdO5NT68U8RDDcyYkBie4Xo/BagiBqbJ18nXB1yuYlCKB8zgGNYvRq0lPhpvYahHphb82mBDqX+/GTNcHBFDxp7lLp+EOlKNiyDg== 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=x3PRZvZZGzrSO74VuNIuOP4pK9eNhX1g7rP3zvoMVYk=; b=P9NgYMEOYKC3s5cTQ4bLjQCtY94xOXi46rI7RAsXV8iQAuKrRZv5AEzLKnP+x8bCojt1cVioRjI2Zegkz2JY+fX+l9mQT0g7VRJbIpxCQlgQAyD9T1PJ6CHvNNuwM+MM0+n7xC1l2NZkGmYwxf8lpHBRBJaZzKJfIXXdFjJ0SO6UwhDHdKSFy/kmqIxnnvdhw/St9hgmvDGDwA1ffSRhEbza80bJb2GwY4wn8945pHT0GRG+Uxl5GY99QHy6YyfKgLFCKhaMRnSuKTWR90S6hh7PAtqS12k0P6nDH1e4n2JLiNSPtb5/aLlBIEJtj+02RQ8sRAHzrl/mp3SuAaEOXw== 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=x3PRZvZZGzrSO74VuNIuOP4pK9eNhX1g7rP3zvoMVYk=; b=oJAEQmyYc66CUyI74oRsJHzmE8sBHvL1lrNNPO3a+J9cz2NzanKAFRr1PInjpEwiz0BUaHz2B5TlGHbBVvC82XlBUuPz6jmFSXficmtSOXJDKmgP6n/fgQhOvSkVE1DfnfEMcsYghTLeBzaDbVs5VTTvpEL2GjpJmHHUagURBlpJEmcfsYJeVHihZ2NSv3RgIoR0ey5o3jhIhkCkE4i1KGbR6STDKiNjtSzqv8C0ZURaPg1ixtOY24jQh9oNjytmYXLvCm6Bju9a25f9/WrK4BzaAHsCy1oQ3LkB+gFip4NKa3PNnFh4ciCtcmaqA5RJYXC2IVSb6eGZ9XScVorwTg== 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 DBBPR04MB7898.eurprd04.prod.outlook.com (2603:10a6:10:1ed::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21; Thu, 7 Nov 2024 03:53:54 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%7]) with mapi id 15.20.8137.018; Thu, 7 Nov 2024 03:53:54 +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 Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH net-next 1/5] net: enetc: add Rx checksum offload for i.MX95 ENETC Date: Thu, 7 Nov 2024 11:38:13 +0800 Message-Id: <20241107033817.1654163-2-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107033817.1654163-1-wei.fang@nxp.com> References: <20241107033817.1654163-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SG2PR01CA0154.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::34) 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_|DBBPR04MB7898:EE_ X-MS-Office365-Filtering-Correlation-Id: e8673ad5-633b-482d-c19f-08dcfedfcca9 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?RwTWv4D5LUYLh1VOCaYqDsNes8bIinYrOJfnOh2n/T6DA4GszLEvaWw9vdum?= =?us-ascii?Q?ol5VqLm7hksxUSM7fgiV+6Ey0SaL9OA6QpV1oiG7bTUXR6Db9yQ5Tgc+FHC8?= =?us-ascii?Q?IOKUsuCZU4HMbnXoCXrJczj9pqiN1X+SpnrpaLaIca0X3j68+nt6RS4+OB8x?= =?us-ascii?Q?cHjuMcFs5bLeVcOflXXzDyh6zfUst6V2o1cQglXVudO8MPHn3F6zvZ25XZ6f?= =?us-ascii?Q?CcYzVsgB7zp2AnzoUuNiX2cGMGhSaQ6R0AnYwW8h4sxUumSXX9ioFGRGwoze?= =?us-ascii?Q?+NzSdT9XVRWz8DmpFVHZZhaQS13UXizbPY7HTolQcfDSuqR+M8qbe2RVv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7/aD27P4JDZcigK+6ly3U54IJDM/gwxst5?= =?us-ascii?Q?HLUlwtNxBBK1OQamxSFGZJuzsZCfMbwWSI1MES8Kw8XcjlJrQlbAQvkKQeID?= =?us-ascii?Q?acJ0ouXA4PMU+9ZhXGXHhM3omsUy8IDhlmDKzTjvIv0iwhGiArWUN+dPqOUq?= =?us-ascii?Q?TNcsm9g=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?pbJp69iQsO6+Hpb9r88q+uJQaWZM/zC53TCxG4ADWO+ttyhElYUPeP18KSqN?= =?us-ascii?Q?BeUUB6wt7L0a37iHRVPm1glakW7PymbJdXWrGJVIUzKoKMViKohwGsK6CdhY?= =?us-ascii?Q?mWLScEmcroHPgEg2LNfuzKcTfXXQTy/z3oA/lHiXviUp1M7XXXnXY3Tr2jT4?= =?us-ascii?Q?nt562fJ4c56p1bzi6Xa8+5rjXish7aWRCEZtcMlCzNXP09zoDr9e2QlWY7Er?= =?us-ascii?Q?JzQnjNnG91MJ9CEjEIG3q6dTAjzOg2yshP1x560OQ0EhqF7+WMZ+IOOCbT9+?= =?us-ascii?Q?c92A4zqsybujy2X2pTA5Ru49WltT3AyJlw30PiQhelRBBUF3edS3hDRjo1ZC?= =?us-ascii?Q?28HwuCmpN33C3Zjvp9cB93/tDr64Bd6+ea59GMjmkkBO2Pi2jcWrI17iDzV1?= =?us-ascii?Q?E7VsPEdaRMOvrL3CbyXKx0Dw20i4sysTnxUptTX4n5u0V5Le9H0ogf3CqKbk?= =?us-ascii?Q?M19P1b4wnCBPZCInStlw8McF8DvT4u1JveuYOZi/5SZmfkimbnD9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FrdMOK6knIPxrqOiXQK/gDPU5Id8MndFGbh1?= =?us-ascii?Q?thYGKIwUeZnYyIWewaPlCTgx++LVEevlm6UQhIbF+RSH+OkBDSgTQfCMlva+?= =?us-ascii?Q?Bjv40RezCE6NJo3Wo+6uhC5H7QrfaA0mbEAJMI1gcobVAYu4Sc8eT4h/damB?= =?us-ascii?Q?y3OCyp+cNLmq9S5ZjC09sAivDnbDT1UcjS2BTb1k?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8673ad5-633b-482d-c19f-08dcfedfcca9 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 03:53:54.7569 (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: W+PqWauE6M4Dol90bNyaUOJiO+l63Loay6ameQQrxYUUKk7LNZ7vdM/UZikntyny6UpdeEJa3MNC4IxoZViwuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7898 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 --- 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 Sun Nov 24 06:08:36 2024 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011050.outbound.protection.outlook.com [52.101.65.50]) (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 1F787191F66; Thu, 7 Nov 2024 03:54:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951644; cv=fail; b=T399nXebwK/bNUQr7PU1yH23eRPYFIDSPAWTVUejRhKeIkKovNafVPhswoyUpLhcJSiPwai12U9xVgESx3yek0zVLJBchomSVbC8JSvi00vbu+0QZCJ9xoPkqEBjjKRfqPOnS545Xd5RChSJjiYsxStgPr8jD8QJov8KVD3CJWE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951644; c=relaxed/simple; bh=a2ebia7bMF/ffErsfUldYhdBb68rsVdl4VQOpOkaaNc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=RmSJZqX0GTIdw4/bqQOQ22L4wo2OMaUZpLpJxTdcqpUVzYRSfYzsd19H5HXkNtAOS+tRRRXr/BudGmMufGE4+PtjtcZAtZ1GADCdBXUoo3Z/r5Layv7HX6E/ZdnqOqVZ8IFdEEhIi3+J8gCTNgnw1NZLlPELAEyd2P4MA3Kq2jE= 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=ESOJtROv; arc=fail smtp.client-ip=52.101.65.50 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="ESOJtROv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JGPoEr0+yM8kV5bAGfJA+KBti2wZfVLmqrbsjyqz0Vr2f4LAa+kpQhG84ht+rnWHRZLLnN7VZa2wai6r1No2aRWgSkNFTKqs/3YC88u+qIf7zsNciPUpLuK+436HlTbHCmHual3pd03mJdtBGaHiEVjOXZ8Aym4B0WSQT5gwzhLNKrJCiIX7mocVkpScBfAR6GPNNcLBoBVYa98wwCtbC3T2ziDQdJk2z+U5FO6n95q1r5MCfLcejDqubyPhANhX1If7wMh34x7nk4OP40R8EyLdqPiM8Od/87USPo9/ZN4HUZ3P0coMcVRpVXxuppSsnNCpiXpRjThbW/sBkwjq9g== 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=01PeWZU+Qr9nq6iyKy15tvfe4bx9kpMWjHlnP3/HQ0o=; b=Iq5lJrbamaEfm4XRG3FHaZfCbYVCUW1jjGG8sGnhX7otDoOgFUPt97AKbuZ03YUbp+eMi6f2f11t1GSxGpbh6lvh+0cIm2r/wpabPVkFCJH05k43l/mVF/AuHrWQ6xD20BE7c6DSThrjNvCo7wUI5B3OLY3o/+Tk+hMoqvrf8mXJucaXrZK9gHUOt0C4LYiE4otKAhNj1ZTBGhkMkqjA0Sj2WC9tjfQ8uEj8Jw06HUY/uU54YYQ/Vm+UfUaSt0XGgenomk+916xVuH4x6RhmCS0ViSRrhzNOYemusZgUGdada3AIgGVbEgG969oaJyUdxYylCOdiopmvrIWiqR6TGw== 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=01PeWZU+Qr9nq6iyKy15tvfe4bx9kpMWjHlnP3/HQ0o=; b=ESOJtROvsZVqh2Wx2pqBiQ8RW+k/Ex/9xKKrU/ChsjefKd6H/eZg7zi77s04u41E/LaubLzOLxiqm4kCFY0vM9Gqeb0AmLqMhNJ21EqariigkzjrLXJywdtbVg+6n70c1iiRJwp5vR93hN7Tx/IvvzBYLnOkQsg6M4JUeGGVDinxqlLDA+cCbt4QW/n1q1ghQ8bRV+u5GRjLGCoYCNMd+ZFZsxEy+PPaeDnu2/uGjc/djk2G4/qE7/OEIFXr1OgUiYz76Jhnw7Njq/0iah2qMnieMdcRcwbYLlsZSAf4CQ/M9EIRrSDKusOO/kWqr60h9koQsqFsYl7zN0UhC3CFhQ== 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 DBBPR04MB7898.eurprd04.prod.outlook.com (2603:10a6:10:1ed::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21; Thu, 7 Nov 2024 03:53:59 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%7]) with mapi id 15.20.8137.018; Thu, 7 Nov 2024 03:53:59 +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 Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH net-next 2/5] net: enetc: add Tx checksum offload for i.MX95 ENETC Date: Thu, 7 Nov 2024 11:38:14 +0800 Message-Id: <20241107033817.1654163-3-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107033817.1654163-1-wei.fang@nxp.com> References: <20241107033817.1654163-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SG2PR01CA0154.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::34) 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_|DBBPR04MB7898:EE_ X-MS-Office365-Filtering-Correlation-Id: e2fc2303-6919-45fe-ed4a-08dcfedfcf68 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?EMg5W4n17W3MYHqkcyYb8ZreyEHJCGdGS2IZKTk2V+1jgRxWZYr9QJ5c46NE?= =?us-ascii?Q?eELzDoufcdSa5+Ixow5lKiCJPEmalazOl3dQ15wqliNlmxQ1d3qi9fw1jI2g?= =?us-ascii?Q?HnrMz2s6usNPMpDxue+qThWjvs6i0jzuhQx0IxjTRlkgWhlu9Y8UG5Rv1gYl?= =?us-ascii?Q?D7Sy9cbIB7EVOH4iyYWygHE6CLvxCKr92g5hM3V56xWJ3q3lF+k3mhf/s4Xy?= =?us-ascii?Q?GZ1W8erADorcAuNhY8YdjpKRRnJ7U2uHTzFe/YOFxqYZodSSPrVtVT+o7xpm?= =?us-ascii?Q?6UfuPkFTOOPecInGq/4pFiS/FrtVE5Mp0oGpJe/qv+Dp5jcc9LIHoSNrnMp4?= =?us-ascii?Q?0nbAzdWXEJ6w/fcbR7HLKZTfK7EPedQIxhO5PjnTR3Aj9jK12GqBZDZjCfK9?= =?us-ascii?Q?6f04aitU/jQg76VTrIkmLypYiU2dbuPSiUDMRuPN4mN6f9L/rRt5ABuJHItJ?= =?us-ascii?Q?FJ4WCz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IdJzx9NT+J?= =?us-ascii?Q?FczpcUs=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?sPDi/3elVKBMM4xIh80E/4d8RkEnjsOwHlaHj9DMT1+7FBwB4GEgcaJkHoCi?= =?us-ascii?Q?o5+EBPf0b9RrAqfjhe8gsuQIDDeOEYLOs5LUriKNfVR3pOOb96YWSsftdIrp?= =?us-ascii?Q?Db+BjaD/zXTMBFjDJwdAt3uN2/+fhlJFLyD54urF8rJDUI6obBJ2pGdeDtUV?= =?us-ascii?Q?AJHYKVsK6JtaYxmeynStP1I1ZvFkzzehuMlyaD5GoxJpiB9PG6bVH1UNIAr9?= =?us-ascii?Q?GQVhQSxZ6mAE5ePuMJpx0EguFalDsY/hIn+XkrcK20AvZWJn3MyGp4utPalb?= =?us-ascii?Q?vT5e1ckxXALZ5PjPbP0bSyJzs5YGMH0bwZWpCaa5dxlOOV8Bc19HluTA6cEW?= =?us-ascii?Q?HH9vDces5T7QA39o8d6+yP1Tqt2F9fNv+hjhm9AmjIDfTwNnmmYysW8INtkV?= =?us-ascii?Q?QXdJ/pYNy/c2ykQJ4BCmxQBdHD4a4tUenEJ3NGHbpzrXSEge++ubNPWmMGJX?= =?us-ascii?Q?mkyTiMQ7n1itATbWS/olBxw+6Gm0q9ZEvU0oT1n0Qq/vngMHiZwwh6cHsx+4?= =?us-ascii?Q?47cndcf5WMd6JFwzzhIYOir2/9dYl1ActdS/1fvPRMUmIcFRnFFwygu2E6vH?= =?us-ascii?Q?SDJ25Jlh0z5WGpBJR4oJn7T10p7/rvhDNsLxpQADXcywy05n0KdFj0qwHHWc?=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OnMMZqXt6MK2vxOG?= =?us-ascii?Q?fjjltBGAasei/48pqjwkpr89YQKK+6/VRTpO+Zv7?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e2fc2303-6919-45fe-ed4a-08dcfedfcf68 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 03:53:59.3801 (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: 3ppwWKiQRFWXSjAoyJHIBQGSaOYB/E8gI12dD7RKTFT4Af2k9gOaQrMvMmRTSEcJ4Q4+xgxdsZsdz+PrnVCKfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7898 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 --- drivers/net/ethernet/freescale/enetc/enetc.c | 52 ++++++++++++++++--- 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, 61 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/eth= ernet/freescale/enetc/enetc.c index 3137b6ee62d3..f98d14841838 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -143,6 +143,26 @@ 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) +{ + if (ip_hdr(skb)->version =3D=3D 4) + return ip_hdr(skb)->protocol =3D=3D IPPROTO_TCP || + ip_hdr(skb)->protocol =3D=3D IPPROTO_UDP; + else if (ip_hdr(skb)->version =3D=3D 6) + return ipv6_hdr(skb)->nexthdr =3D=3D NEXTHDR_TCP || + ipv6_hdr(skb)->nexthdr =3D=3D NEXTHDR_UDP; + else + return false; +} + +static bool enetc_skb_is_tcp(struct sk_buff *skb) +{ + if (ip_hdr(skb)->version =3D=3D 4) + return ip_hdr(skb)->protocol =3D=3D IPPROTO_TCP; + else + return ipv6_hdr(skb)->nexthdr =3D=3D NEXTHDR_TCP; +} + 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 +180,29 @@ 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) { + bool is_ipv6 =3D ip_hdr(skb)->version =3D=3D 6; + bool is_tcp =3D enetc_skb_is_tcp(skb); + + temp_bd.l3_start =3D skb_network_offset(skb); + temp_bd.ipcs =3D is_ipv6 ? 0 : 1; + temp_bd.l3_hdr_size =3D skb_network_header_len(skb) / 4; + temp_bd.l3t =3D is_ipv6 ? 1 : 0; + temp_bd.l4t =3D is_tcp ? 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 +213,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 +633,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 +666,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 +3324,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 Sun Nov 24 06:08:36 2024 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012068.outbound.protection.outlook.com [52.101.66.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 E43631922CC; Thu, 7 Nov 2024 03:54:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951649; cv=fail; b=RwTiUqy7+pOTDV1jZBLmu7IvXfyi1+7Om1E1cmVbPPD6/Tf34yMsu+fBD8nZlgD2EA9L3WX1xNfDdGhsvbEDE8rt7Y0sXaVMuWZaO537L5OSlxbNa4MTVVZL1qrtntO1pyOPHsOLPPPpsBBYSZR96AuYScdhHBU8Mxr5t9oRE0c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951649; c=relaxed/simple; bh=kWdRpoAXi4NBpxy49iB4UBzELwcCJ584DBJ2JoSTvow=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=BKaIX7SSgtYPoFNOVvSd//T6wNjMZf1WRaVg9tCYMV0DtERj3MFL1zZBjk7ZN7OkUhfdznqEZx6YocbdrGqo3F8tdwrgxymNWyZmXtRgIalPxEqQioKZzmiYWgtPQ6+j9YKb+pK0GfsAzQz30fK1RD4Kyyr0Ov9DXsH2iNyizKc= 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=YQ4UzU4N; arc=fail smtp.client-ip=52.101.66.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="YQ4UzU4N" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BwLkmYzS8WDUdEHai+hWPtrzpoNbdK4xTMBpLJzZ+gYYEsgtKZ5cjzL5gIdmrgzPHMaQVrXBEFNnAkS/1DABfoRzi5rGelSc90+QKZwSX+NLXKsw92Q38CCREbtXUMqi/wQAaVQjpjIB/4B8iCDCUWMxSpmSE7jA1qTtZ78B6QkNrGADTWN5HMAOEzmyuePjWa2J8JAvZ2CHO1wznfObFysco7VidnTxrc+wQ7JFY4jCG8d6Cojnp+aWCQViiXLz/CMZ++iqtPRdGGtUBaKOIM09liM5AmA8LtLBP5qqMyA/zpXCi5ySo4puC9mavawS28p0hrZEB78o74QZnffYvw== 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=XgnxCjX7eNR9ErGwGn971WROAL1GVJX1D+8L1Pxb5vw=; b=w+Ei/jMDeaFqrvBb5Cw0lmfPW4QNHeAl8nl7v4UA8yBnB7NJdPtrJlzihdRBbw191WOzwfEF0Jnq/AlOm9M6kO2lpXRjcdZNHxkrtz7YGGNVe/OFJqoyFK5kwuunFj6nHMbWdem0H9nArfHekTuLzvkg3XfVNozCIQeUDi65hGQ39nfX25A0ldpjmK7aD3rJOpYso4bl/KydhNekabj1wHLokEQjN46ARNUeZcGiewDsUb1n4Rhmcbn3I581pLgubZKqdxy0vZBbz55TFevyn9IRZTHRxbt9wuZKZL3FU/TMLJK/yme8qTXqMv6u3+OFFDe08ImebDu8EPvFrLZ5AA== 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=XgnxCjX7eNR9ErGwGn971WROAL1GVJX1D+8L1Pxb5vw=; b=YQ4UzU4NfdxpDI1qxeIbeQv0l38RdXngqbMN52bbNbcOsD2Gf74EOC1wNGyF7OLPde5WSuYnP82Ra8rGLc4plmAYa6PquPeToyVqr1QYerUmRVykvw+ba42Fw48REkg4Hcl+uqW9oz9KgcQ8iqFcWbMCRvz+X/GYcAjGupqCAor0YERL8YYI93QTwcF3bVRHdDW3D2xxlm2IFThKZHcMFfTf5IdsRPDXuG50hemfGAGzAET1oTJ71sEbsOu5v5TRL36nCmtCuQBvqEpE6R1zIfVfvU0ZCQyHzwNUgdA3C4/qvpB6lCBvo0SMffYdO/BzmTI46WsVYf5d1NrxxYxvcw== 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 DBBPR04MB7898.eurprd04.prod.outlook.com (2603:10a6:10:1ed::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21; Thu, 7 Nov 2024 03:54:04 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%7]) with mapi id 15.20.8137.018; Thu, 7 Nov 2024 03:54:04 +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 Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH net-next 3/5] net: enetc: update max chained Tx BD number for i.MX95 ENETC Date: Thu, 7 Nov 2024 11:38:15 +0800 Message-Id: <20241107033817.1654163-4-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107033817.1654163-1-wei.fang@nxp.com> References: <20241107033817.1654163-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SG2PR01CA0154.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::34) 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_|DBBPR04MB7898:EE_ X-MS-Office365-Filtering-Correlation-Id: a10f55fe-bd6f-4508-4d8c-08dcfedfd1c6 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?id7Aj7gDknZNh3+soSevB6gJgvAIBpHcKXf8Um7120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Q4n0zoyI7z9+0j6FyMI01ZX3oVrmA5UFu61w8JEnWxgGisgyZo0fBC?= =?us-ascii?Q?VZzoa6+ckXnRDiYo9jO4upvdsC7DqiE8HJ1oWjmGFMColTLRYnSXyeZHCrH1?= =?us-ascii?Q?e33kxIHuUQdRp4vGPbqQtWgnUaKK/qKme+JtGjqKAA4H9w6snyzde4JztV5j?= =?us-ascii?Q?an1JJ50eR39bPt1yU4WMkXKNGTPjgGcy0i/HATa47Mv4K1zFXOiGMEsjLeXf?= =?us-ascii?Q?RgYXdOBa4lt3TtHkROBliPyYST5DR/dcmHBqyVcMM9MGPI2VL1+LnwP+rRLZ?= =?us-ascii?Q?tglMHswWXr3+k+ZDqPu+Ddx44KK3tM1x5X0gKTDhWrBHxvMl753QyP+sABE4?= =?us-ascii?Q?CRp0OB2HbXp+8fdanMdjztsCdQ9nlFdQ3BzFZMMukPWwYqFhsL3ZLM0T5M3s?= =?us-ascii?Q?0v8B4gzqewYXwzM/R0Q9cYkZRJnyKSTQIi6XbTNDec0qYD5AYE+F4MXIcSP9?= =?us-ascii?Q?dwaE9Tc=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?Y37c/yJyjWD3t+yzaS+gTfreYIRqAAJWGYaWgraP1d1rRPA+LyrFm20k9SRx?= =?us-ascii?Q?gCY+yAz4eQgPHwWuscQl36x7U3fVg2falgCSRy0flgdPJ8iHcG+gr6nV+Kb0?= =?us-ascii?Q?5OST31zHU64Hy8pzPJFmdMdYysA5WSjDUJh1Nrq2vV+C1p0AxwE//4DApI5f?= =?us-ascii?Q?pCXqVAzQ6F3qG7rxl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?Q?L3x31Wn+Kh29DqOpJBwjZihG4T9Mgyht2kEHV6wedx+5S5s2VSQ4EVBfR6jA?= =?us-ascii?Q?WNAT2PBXR9fs+hmSmj0EzhvDTl8rm8z8RRl2AVQhFeyIfdbIM15xbE4DWuXu?= =?us-ascii?Q?x++PB2wNBBx3LOLZ2ZCQ30TYMcqXkZJydRJkzelNQbeQKii0Wez+c+RDCdgr?= =?us-ascii?Q?FaeuqVqBsSEbBFPktJDodTd0gegqcsIEwMVAjnpeCpII8Obhc7Ok70JJH662?= =?us-ascii?Q?6c59kyX+AOhWUPr5dngHwKEqMfZObPeYkckJ3GxteM9KIRFfY8a3CNjiLvwG?= =?us-ascii?Q?cz6TiKsIkTJSSuDq6Yx9Z4J0rkgOEdCP9WkuxWmMaXBX5J9t/GtQM3YjjubH?= =?us-ascii?Q?8H7dNzqw22FY9u1fo+M8v1qO8ds+eA17TadM9tLpWQ0+HsVH/5I+wvN8SbBT?= =?us-ascii?Q?ocjinSSd64Xmj18kss1fOeHe3EG8JrPoMeo99mdC66Y75XFFl7gES9mu4Fp9?= =?us-ascii?Q?V7EvSMX3EpU/M4UmiyH53nEZ3I/BBuKKjRaLbnqX?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a10f55fe-bd6f-4508-4d8c-08dcfedfd1c6 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 03:54:03.9660 (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: 20iKrzL5VaJlSnaDjpAcXXuWQPRB7muyKA2CfE65FEq/Ibvh+1KnABoJUsN4IJCosT6gqsxL2Wg50Ep2Ucc/Vg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7898 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. Because the maximum number of chained BDs supported by LS1028A and i.MX95 ENETC is different, so add max_frags to struct enetc_drvdata to indicate the maximum chained BDs supported by device. Signed-off-by: Wei Fang Reviewed-by: Frank Li --- 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 f98d14841838..b294ca4c2885 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -530,6 +530,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; @@ -595,7 +596,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 @@ -656,7 +657,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 @@ -674,7 +675,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; @@ -942,7 +943,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 @@ -3317,6 +3319,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 @@ -3325,11 +3328,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 Sun Nov 24 06:08:36 2024 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011047.outbound.protection.outlook.com [52.101.65.47]) (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 1AE92192D93; Thu, 7 Nov 2024 03:54:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951654; cv=fail; b=q1tabihmBmxPHKuqh9KHm69l4FDC5z8GZIqyqGNUwg4lPU13UtP4GlhbKVU9PmjHTUgsOYw5GN2V4pamcNSOQS2bIwmV1p9WZpnwK+nUF8syi5W+yhaBahgvapw4NxDG3gT1GH4PpwO3GLrcAVmHwIyqXDSV9v8Bb3uSsjWMvk4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951654; c=relaxed/simple; bh=y+BEGu2YGicLDAipuoNxOj0MWZqljmS4svUgFCbPOMo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=p1ZbWn1dqaZ1ycXBBFJz38FsiUXA4RLNTyS+1tFXcDp89d+f/U8bJMSFmM53mHx8a81uwPz+BChDnCAxUXnXo/TcArDIkeDkBiqBSf7l7WyJqWHsl0h4peVynjKDB2/TrlD5RAzF/c24ro9NZlgjRTt9OqIhGFhkI2WlBrLhogc= 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=jwyV5jZp; arc=fail smtp.client-ip=52.101.65.47 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="jwyV5jZp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KEm+7wGCUTNJBEPAz8SvltULxDoASnJTDz3hu5zQ7TVOgOZ2VgEWvSDWs+zvgQLLho0A24pRq0xRxXY4LSXEXtZilnLkRZ9qX9aMPopqpXHYZaIhnic5NQjqqhWcWNrKcpk/QEra0xHofKBVvtyeyCaDg7c93VTjZ4nKiOx4JAaW/P+kZEKoQ5rZX/0kgPrvG4QmhEqI0iaCrL3qxo6FMRC72IRO/s9guQHMg2oW9qoR4kPMXsBEgHhroxQpf/u6TAR1st+QaZiHgQ3Q8XL0taezuCgdcK8ZqvNxCMt07gbCpy+44cPNjswhW24ZTlI0DKDDlBOUvbsW6fFF3brAlA== 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=X9wkibA94qlyjb70/0GxT55+XxHs7Yr6k7u8oxocfwo=; b=eSkwvGm5l5GQm0X4j42Ssa5fBZTeyF2DvAKBOE6XnduCgt+Ex0aHoLgv5XY9hEF18o78ObkM7zdxiqOrY11HmmOFbTtAsCWk5Z0yyELLSxOnJvjpdgjsAKzSoIgkit86c3muUvofrfCsneDwAoqfScD9imqh0xmK96Co9FlkZwr4ZY9IyPzMFkEFCZIhxhlnknihOQY6/ZdK9Ni2n8ffwp6ceVLfXI9E8F+S8GpvtIbZAoGGGzGjiwrNBTryaxjTxL6LcTpRm8tnI4eOGRTv05BwmozaId/25toIm8oX20WBoVaQkV90PvXw34KQT0LCHvRyjb7mz0QRn27Xs9/Upg== 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=X9wkibA94qlyjb70/0GxT55+XxHs7Yr6k7u8oxocfwo=; b=jwyV5jZp4UQXbW05+74LJ9B6Xa0grDCBAs0m4/imuX1dCWqc992f5y4SdShK09Z1YGteweFi8Pt9LlTDcQp/Cqi68DCS6VXrQ7RuXBtp9oP74P78O0W2OtvktAcIE9YEXT/afsLXCD7pA/rwMp+QIg5h70FNGYWrbTeR5uAGSLLH5gR9BDNKoV40Y3lqrbdjYMUYRE1xEkVsnBF0bX5H7DU9AENsRseRC1GwQ4MMJdb9STQu22kBm7gW154GtHty0WjWR4nY1hFc2zQf1kvqtootv7KL1twkuhxXva8swJyzk0AYC/M3KSGl+OxLFN2WkQ+EuISKxaWdl9ero//q4w== 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 DBBPR04MB7898.eurprd04.prod.outlook.com (2603:10a6:10:1ed::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21; Thu, 7 Nov 2024 03:54:09 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%7]) with mapi id 15.20.8137.018; Thu, 7 Nov 2024 03:54:09 +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 Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH net-next 4/5] net: enetc: add LSO support for i.MX95 ENETC PF Date: Thu, 7 Nov 2024 11:38:16 +0800 Message-Id: <20241107033817.1654163-5-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107033817.1654163-1-wei.fang@nxp.com> References: <20241107033817.1654163-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SG2PR01CA0154.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::34) 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_|DBBPR04MB7898:EE_ X-MS-Office365-Filtering-Correlation-Id: 26b075a0-e5d1-4d3e-530a-08dcfedfd51b 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?NEKQmtIDFXIFDOtjpu/NTzQ3gWv4JuDbxI52HCbBv2nVNUBcDad0z/onXmVF?= =?us-ascii?Q?+8P6wqftP0YZ97xDzyEgTN0Cdpg/QuZh7lGTfRC59zhx1S5HFyBpx6+zWS/S?= =?us-ascii?Q?7gHC/XyfHPrY3L9gGQ4it5HwKHEzFulsQ0g1kw9ot+PMhDqbq+2Yh74wml+d?= =?us-ascii?Q?Qv6D5heN1RcMErJ2iWPgQLv5nvpFV04qjSN7fsUo4eilEQFyQ0MV8NUmSzsG?= =?us-ascii?Q?/qsSBBXmgODmbXrDnp7cqpx+cRVdIntx4WhldosrQOuPG7xV0A9FfZf6sSsZ?= =?us-ascii?Q?XyY2fHqNR9HtK0NPTrgf7NxydFmUkV2QPISwhbLNNVFKNspOAr/2tC3C0oe4?= =?us-ascii?Q?s7ufZ2+G7uC2PmP1x3J8CtJ1J2+5kC8njTCKxXOH9rieMHRzDdBI5yLa6Wg9?= =?us-ascii?Q?KzTx9RPXEnb9i3PGewckZJXbQy7CMv7c7jlht40WDZ8sspnuij5Ms7Um4Wez?= =?us-ascii?Q?A9Y5PVAEpobmfZ0AZKaG678wB77otxU/TwQ23xi4OgJWqETtlYuG6XTiirSJ?= =?us-ascii?Q?NyCCxf/DOGwgNcOfnlVvAOSMbY5wKn7d6DE8xsrT2gZd/jwrC+h+NscrJ78u?= =?us-ascii?Q?oa92pwKQoYsn7T/8MO3hzDOMhCWAxoD86jox9ea5hPpk37slLTEORpFduv8E?= =?us-ascii?Q?wNy99SzJzhJhkI6IaBSeQePd1pIp9c5OJxORw8xlJ6V2oY/j1qHXl6eWsLas?= =?us-ascii?Q?lsXFN7n7yuQzWy6EbvOjqN0PnLKmgyBjIfy+9DsNaPouL1ucRhiLAElZH+J5?= =?us-ascii?Q?uv2+3ts+yosL2M3jecEQ7wKOxRAR0V7edfxxrrMCs+UIPTWVzBHQWR91uZFs?= =?us-ascii?Q?/KQjGYHLEmIW3AJTILaHI41E1gM/NjW+yQfGah3gKvUGboCUy9Zn97OouF5N?= =?us-ascii?Q?xHGwcn3qpr9ZJZkUodMr9wTvd1dHnPcQzEnon/IHQ82pHQeUnpUU7ykjBlVH?= =?us-ascii?Q?mRyH/eqOe6/1ZeFOqmo/f6q/Mrsm8J0rYGAwCliBBJwKkXPd6+hoSraOQCSU?= =?us-ascii?Q?t+OYGW7puNEOByWInkC1xluWAn86FZ1+t3F/zHNgJ1jbu+sVJVfMDdafe4Vz?= =?us-ascii?Q?mQ7H7Yvv4D3xDbQXlHb97IAJl3DJ6RIItjT7EGADO19Xx6yzwZL02U+nPmiC?= =?us-ascii?Q?nIaQjwWkDgJp7UqTwSg/Zy1C4e6H3Jb8aSNymhb5LtReMJB3WEtN5bp+/Vqe?= =?us-ascii?Q?XP6Zud6w/teJY6tmlQB1OkWriVAeeFSD3jbYz493pdyC76k4PgCzUBJa3wn1?= =?us-ascii?Q?hnh5bJwQFt5nE4O+mEudmebBG4u+yEANRZTeJRdi8fkfpFBiiuMzShio0olM?= =?us-ascii?Q?Ne8f5AGBOQM65Ia/K8oDjau5A1b/sMkZUy5l207fgEDba7tivUa0glf5JNrQ?= =?us-ascii?Q?egvsCZE=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?9AnlEUaO9gH+Qd40pPVuKQDNRNzmJTs6GFyrMPJUfxp/zF9x0zfJjhFsn9Ir?= =?us-ascii?Q?H91mG391E6MHgjNjvZNPcN/CHT+F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?gg59QvlN6iBKuO6XojXAfGLhwjHVH6KNkdF/kT0AAclmoSGa3KLt0EtKvWa0?= =?us-ascii?Q?53ybb5hWVoyQrt7MuotvNoDZFPCHwYQNwixpuYmHCgrVo/9MV/9qCKUKrrDK?= =?us-ascii?Q?M6fxKroOvQRE1RXwb8eci04VOZdEt7+SDWuu186u/atOkUL73HzUVTp54+EL?= =?us-ascii?Q?CWCqnqkoblh5kR3IjsiZVyl9vLRuV9UDe5Ckqq1+aAxariRtEvKIaWIQMJ0f?= =?us-ascii?Q?LX30ImRTmzPhE812gyX4pe8W5CA379379Ydha0adskpLAKJhUQPTlvUD7BCa?= =?us-ascii?Q?qsGZf6aMlNC6/UzMWFVbAtGsQQyryRIxI/Kp3Aa5yLT0XfRWKbYAaC8iLzO8?= =?us-ascii?Q?QqOSv245R3SfUrOv0gOGOuQmAFPiUSRCaN+k1RismuTZezIy7wP2jnf+4FDj?= =?us-ascii?Q?Lb75K4vubuVjZRaSpnYWhHv8lJwchUcql2AVr/TRbAYMTdpvzlGevVFDf5DZ?= =?us-ascii?Q?74oofETqakV1J3jLMFBWNF74jMf14nE7bX5FagmB981VQDt0yAqfksa6dj1W?= =?us-ascii?Q?RwImOZhWEoicJHOUzebSOP2T/eHkTmp5zKVvuEGnFQXmWv5Uujz47n0+++LY?= =?us-ascii?Q?LkBI8GSwiBdz8YLiKyVDGnDnE24x4NwKgFNr6wa4?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26b075a0-e5d1-4d3e-530a-08dcfedfd51b X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 03:54:08.9329 (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: LhC1L7LfOE0guf0kVe9PaKjXJw1TNOsTb8hS10gfRCn8EOaLI2WqqEPlnvyROlKmtGI7eRbrpHD/YKO2fPy8uA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7898 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 --- 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 b294ca4c2885..5586bdc7ab59 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -528,6 +528,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 vlan_get_protocol(skb) =3D=3D htons(ETH_P_IPV6); + 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 fisrt 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); @@ -648,14 +875,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))) @@ -1801,6 +2040,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 @@ -2105,6 +2347,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; @@ -2118,6 +2367,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 Sun Nov 24 06:08:36 2024 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012039.outbound.protection.outlook.com [52.101.66.39]) (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 86B90194089; Thu, 7 Nov 2024 03:54:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.39 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951658; cv=fail; b=qLxcASKNxUDz22yFejuJJudHQ2sIqKII3XxCkytxu8ERaE6tkRPdNj1Jdz5TLfDKdMme6AgpnpSO8QJugwk366paYqTVp02QKh6EEjeBu0MKloK+BKJHTrmoR/M3OC2BRcnEsp8F5e11w/VVmpfJ5gi4st+9ZoolZ7OhXaPK7YQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951658; c=relaxed/simple; bh=bVNl9Tu8GcV5eA+hKTHko9gF8fXk8PAfj64OyT3Z6Is=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=IZ5LUC/y9wAFfTii75MRYtx4xCAvL35NQmtSAyyB4kwx5QtxQWN5l0yhsZIPTU8HNvaP4HZl49vjva0BIFj5DKe6e/8zsc61U7eqgmSXiRcnwxtSvBGkPQfVmiHy4HslFrYZWowPPLyXAz4jWn5WKfeEKf7rLCh1GWWEeygzm8s= 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=OvweDaDV; arc=fail smtp.client-ip=52.101.66.39 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="OvweDaDV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=a1+BQJRveaFHIzTq1c6ZxM6xOCHpgBssI91TqF0MiHqTXSVT2OSOyN7R8uopuduoy4cQrT/H/usEUCTYG6nfiC0ZlogKcAKnBoF6iTHMdiy6SYGM74o8mUtA5FILErs+28UJcTiRUvpZnZlfNnW6NzZc4KuocyRc1gfDX4f9p8AZRSH0gfsysEeRS5NUYwUCIp5aojYU9zOR+p4IW+d4K7mG4HpmgkDVmilLhzpT47IqXykB/zVVdV6RjoCmSuW5IcZulFhG0ecBa6yKeL1WBZT5F1H+RififgVrqs6rJy55vRP5lNCzNIichAtX2pEXl+vQ9vpoIBjTh4uEpa/O8g== 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=ibq35Pj/Qc1wDe8VyilUjUiIgk+sfg/vLq0rYyrpySw=; b=O3MBiOtUOUfpFRjeXgdQm+U2F7NQZcnDqkSSFfC3sAcVhuwX4vmFzhvsQEI4R40I44/GPXuoQzrqVbb9eCYng4ue7Ev2UiVExSTOkepFXCWNY4if8kg0o8FKDMR5dXGXg5PDI6DlTQGj0aj6r4zygy9JjV5dx6o0oZq4W38OWalmgFDAT+TohmqegHk6f/zuehUqrXpcqaHEQTqxG5T4gCe73s2jT5xUYLme/AWNvoBfBharULzRAvUWfQ7Vs/kCpAltu3pJKEox2SmTJRO6Y68NYS0QhnZXltGlhZRVmERGtqoqxWia5O0SLWh8AHU9rqrrRFc6YJoX5HHgTlKrZg== 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=ibq35Pj/Qc1wDe8VyilUjUiIgk+sfg/vLq0rYyrpySw=; b=OvweDaDVc5a1tQMggUwQ4spH7exfxZE2sXfAmaU5Ag48o8N7EJpydw5XpsLHJw+MDxfH+plEI3VB4jSfjaogorOPbvwP7gotzI85GRI5yjx1zo5Gy7AhAko5bfAziwI4p4VZ9TCahggWzV07VmE7zGUsZo6Vurs3IhatE1r9ZQxcUsQRWjewtQDXBHpfJQR+citKd1vFuZuzlxAk9/cL+uni2REV/LMGGsxG1Z26aKk2SWax+uPYhaZLa6k9yV9ICb800mAHvef82PuC3H+yAgmHs7VjOSgF4n8PzkuUGVKjCnyhulSrRwwcrABidxmh8uSHAsu/bJH7Ah/rwst2Ig== 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 DBBPR04MB7898.eurprd04.prod.outlook.com (2603:10a6:10:1ed::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21; Thu, 7 Nov 2024 03:54:13 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%7]) with mapi id 15.20.8137.018; Thu, 7 Nov 2024 03:54:13 +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 Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH net-next 5/5] net: enetc: add UDP segmentation offload support Date: Thu, 7 Nov 2024 11:38:17 +0800 Message-Id: <20241107033817.1654163-6-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107033817.1654163-1-wei.fang@nxp.com> References: <20241107033817.1654163-1-wei.fang@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SG2PR01CA0154.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::34) 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_|DBBPR04MB7898:EE_ X-MS-Office365-Filtering-Correlation-Id: 54940245-4629-4052-8878-08dcfedfd7c1 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?MvQsVzcU6mOcXhe1iLVyEtn4eAUo0GV2AOhaeFDpuiM2wDYtq1ZAxPZ3tFFD?= =?us-ascii?Q?MThf5yV27vJ7pPxnNsn2IXYL/gqAfFQsCRTN9eHiRlbgDyzbEtX7MOpKW06H?= =?us-ascii?Q?Y2ZF1RDoWEv7BIihqyMDTMttcU9CvS+Th4Zd3DYvPrtNxtdy2OWZjboVC0bJ?= =?us-ascii?Q?PnVgdFXqgqWC/QwseZe2jNVu+9ifrAGLPOXyxEh9ZL6/O7zHQR9ch3fbYEx5?= =?us-ascii?Q?GFmBFPw1sI/5sytRBdTO3BOR8ZlQG+G9EG38oWILIvGaGhrzWMqQ/r9/jexl?= =?us-ascii?Q?uwH/S57FV2LDQa8fMmPIhY3U+/1BcHpL5Uy3tOr30ovhX0gqy4Oj8uTMb2cR?= =?us-ascii?Q?vNB/tH4Ss3G5BPaYW4y1+ttbnCkkkafJUtTii8e6fqj73/kIgJudUD3M+ghY?= =?us-ascii?Q?PrAmD33XrrJPZORQTXNiHW33SCNfWLQMx1Nk2HvYN4KvSqq3mEbofmuPfo2L?= =?us-ascii?Q?w+hRQAr2ZxCawWfDprrWwLVV+J4l2PjgCTrcRtEspBqTDJx+PT7VaKhHDGwS?= =?us-ascii?Q?MvnnGPpKbyysFc5h7m4sLVFNzEaLgQDyap9cBtBH8zl9sqGvXvxsOqCmb/qW?= =?us-ascii?Q?u15eHhoJXFbg5T5oOogywL/lwlSJ+5JWUMXAZ8qpQJ1pf/GfFUk57AeFY90c?= =?us-ascii?Q?YTbwzLFhh3Ndw1y8bUirq5nh21DxhoEYgetLVng+RjfTQ0ooTie0kJzFw6At?= =?us-ascii?Q?EbtReZGgZoxQAQlptQq6r9s5ja3xqbJlU/ZP1zbMTag+DxEMCTsWHYeb4XBC?= =?us-ascii?Q?ggyUOryshifEVHwRTsfxg4VAnW+XTHXfVlssrbJ290dkvqUPHK7wpPFLvYE1?= =?us-ascii?Q?0VP2HsVtpZ+Z13oZR/AyA/6+pBCiFWXpS7Y5JNjl1ytXoec+p3uqF4NCSCaM?= =?us-ascii?Q?oAWCH1TPgQE64/Oe92Cwr0vR5NuLP6BiaVNfG1X1hi3fwULIL4nMSDu3nBSP?= =?us-ascii?Q?ckd3ztSfyfWpEtZXFyxJZVUbRB9SC2FHDEe19sj3+eE22UzuG6YW1dGAuYXp?= =?us-ascii?Q?Z67Wk7C9sVW3Av3baLgEsTviilxwbS+LLIS2DbffLBkzdlQXWW2bCKW1IqIO?= =?us-ascii?Q?DkqlrtQmV3n55ttwVXyAhXqK6h9ITj15QzGvuZtml5vz1Uudt4mKG5dkRc11?= =?us-ascii?Q?J2XTZHvG47WCE8I4/iuXAqi7BIgGtStLqTY1ImVrBEE3bzVbh2fz3Pk9leaa?= =?us-ascii?Q?LUnvMfSi+jClI4J1MRLIfivQO0qFTc6dv3E2bIbWU1uJO3/e9xf9H5V/AHx+?= =?us-ascii?Q?cQjV9NAyui2mpcVNFbDwych8iSfDOjyVA3hMfhbf9Mllo41at+GdGr3cWSto?= =?us-ascii?Q?COs7O9GzihWGAUPuQt6+giqhS6S/YZWc6KzUCXb0D/z7HhbkCBh8S1LY0Z+Z?= =?us-ascii?Q?yvnhGQo=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?IafvZyElUl6+RYNkSyQtwsiQNeMK27L3cMsM6c1hJM/1/XSEHNA0D3FoADjD?= =?us-ascii?Q?1NgaVsroQ+ydjHNYkDuNGBF5E1mLCh21FJDR8syhvRg37bFT9DEVUkRow43P?= =?us-ascii?Q?qNaU6YpWdZSQcyE1/QHhjQe+Z9NhtfRzjX6MfweHrw8LHdecmCeOxvs2PYv/?= =?us-ascii?Q?/8NvFR98JolvufziwZt9pZmcHgie7gQ5Lwvkso9oCVsx/4OZOHt7/1beBrxj?= =?us-ascii?Q?uC6vT6mbqtE0w98k3ji6ShX74RKz9SFliPRG3OPJCdS9rNe4EiL5pqH10W0u?= =?us-ascii?Q?RK5bFg4lvC+rvc8H7MoXjhLF0t/DvQasgzlueah35+J6Cq7nMD6gucmK1jI6?= =?us-ascii?Q?JNd/qQGN2yM5RCTyrr3PN3jHIONi1lXTMMf80aCHRiBvf7LJAH0glJFN26N0?= =?us-ascii?Q?nAHsuTcyvtyNlBQB1wNKVH1iHJYGTty4vpQDtgTrlVQgV2p7CWm5/VhGRdPG?= =?us-ascii?Q?dIxtx95oCfPdDsZQbcAkJjbxJyK5byyH5LDsMxDRvGcZTNJ2FJzzpCK+ESMw?= =?us-ascii?Q?5Pe6b38Xp8BZZaF02TDWdAariyY3XsKEvi1U1WmQldW3nfwlsVBHQ1ujHHLc?= =?us-ascii?Q?/yesV1KZBSaxpGtRTdPwCfaLGuMTIp7sVOIwSvD1xcysMVTMR7C3B1nc953N?= =?us-ascii?Q?h/ZgguDHy3Bz9w1vTui0jMzOnRxhQgPBIiHU/rv4xILffjizznjptM3aXLE8?= =?us-ascii?Q?L2V3QVoavtkw08yv1yGutLEApncxzPlZECRsz+/1j3Hn+dpOZT3k6TyV3J/T?= =?us-ascii?Q?knuLVE6dopjboPCLddglVEIeT2Bpa8VA8BsT9F/eTG1JSs3lP1SfFtzuHFH3?= =?us-ascii?Q?ckKwcHhzqIxLrAJMW4NEy3lqFYzb/95SJB5vDMZq9XFYYe4Vd7FDaRBCPSzu?= =?us-ascii?Q?xuEmypKslRcbKX60nubxksX9z0qasPCrQejt/PUwzMl1tqgusUt+Ou2oN7Og?= =?us-ascii?Q?vMOIzlEpBP9BhIL6avdoESpdDH2nDywiR7QyPWvRD0KaHbaV1wJzrYukqSwF?= =?us-ascii?Q?UL5OXwXMoTxSEQkUnHeLICL5lKAlxbeQBq6rQYmgdY3tWC4royP5KWZbotof?= =?us-ascii?Q?2ttUE8Db4DsAh6Lym+AdEgHGU7pb08/H+S8g/ivzryG3wIro+jy9ELVTK3O0?= =?us-ascii?Q?56EDKcjpOzqu/gmUOSNajquTEgreuk9hJWZ2v26HotnfVUql3fQH0rv+B3NS?= =?us-ascii?Q?vQlKhXHlCCIJZPcnNwufwfAMGy2NJWOT3Y/J9TpVC6nzdNWlidyDkmCVsW6o?= =?us-ascii?Q?qjPgkCyMTeko+F5aXOdUrXfg1hYsbL4VZTaM3r1j3tOM1N53qNeEJx3ez1oW?= =?us-ascii?Q?zkfg5eArmbBryu1unaRFiuBqQNfgwqy1zmn/zO2YcwSvzgWOHe04SPlU6r3p?= =?us-ascii?Q?GfuPLW/6SyPor6z4/Z419RAr298xsPcLo3pZVpn3SQldxdD6oxPcw8a/yFTN?= =?us-ascii?Q?n2auSXjuVgCRulClX7KqTFaIxHxW9w+4emtfDlY5jOyRKa79ktbzCfdtQ20/?= =?us-ascii?Q?3vgeQKJ405oh8rL1jSqif8VjTXA/Arak4I5m/jP6ODDhb6b9kcGBLmV69we3?= =?us-ascii?Q?RLx435596CyTlAFU6Jb67x/PF6fvvZex2QR6cGtE?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54940245-4629-4052-8878-08dcfedfd7c1 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 03:54:13.7719 (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: j24cdYvInef9WPs0jpJ8BLEIRSVnMQdvSyPvyf+PARrO9mUhMZzbQ3AecGHrVZlUfHAGbZVCxXRBGJfWkonv8A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7898 Content-Type: text/plain; charset="utf-8" For LS1028A, the enetc driver implements TCP segmentation via the tso interfaces provided by the kernel, but since the commit 3d5b459ba0e3 ("net: tso: add UDP segmentation support"), the LS1028A enetc driver also supports UDP segmentation. For i.MX95, the enetc driver implements TCP segmentation via the LSO feature, and LSO also supports UDP segmentation. Therefore, setting the NETIF_F_GSO_UDP_L4 bit in the enetc net_device indicates that enetc supports UDP segmentation offload. Signed-off-by: Wei Fang --- 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