From patchwork Wed Dec 11 06:37:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13903009 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2046.outbound.protection.outlook.com [40.107.22.46]) (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 56CEE1C5CC1; Wed, 11 Dec 2024 06:54:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733900044; cv=fail; b=jkhmBCQN5HVvg52zn8KdA38PnGP8SbfRUZaP5TSUrmPaQz9Y/KG3H9+mTDMR+E6Z3Kiu8m8uei2HZnNpvf0zLfmQxHUTFDNKAPqbRdV/P31FcR+x0qL5+SARnyuQ+gVMsFgz87s2KB7I9GnWB0jowc26XWloHhYyqmwCYgq3jRc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733900044; c=relaxed/simple; bh=dkhfDE5iSSkIV0IA4c4iGuEcaNDr4BCT2piR3DTkCjQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=R6/mQdf91J8Rmu8IdFzx+FcSiCu0t8DMzW03mKhBux2TRox/2TJ3nNNPaRDpXmIPT42iVNrbyD6DImOZHHX2BaPmvSFuU7cJ2PNowG3hrqDjW55+A5z0d50vsY2mZberXMjtANMdBkqqwHHnwnt92ctd1CvM6mDQ9i6yf6vSjOI= 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=IAr+pAL4; arc=fail smtp.client-ip=40.107.22.46 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="IAr+pAL4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tJVUMlrFk86KXruTjHiofaH8aFe1jXLIxrIX7BqTfLd5RuwjdzrqEfZpHYTBeSIbKlMEyDjiclEly7xz5NPAzmTNBJ1PMcJwXOCQsYOrD4ltGCd2TmhJstWZ/pg5XOtsgH+1gKQdpaD/SyMkKNeNrnQP+u6FOKQEh17wbPW2Kd1HM/XcKrwSKm1B5cAinH0sNX/IQqsFq3pFD/BiyzS6541lFmKp0d5B0KvJcnwu0b7Pr+Mn2IxQcD5X2RP91BH88TwjrifQuqyQ4P2hx+0QM07LxBYGvPuaqnImmeAaPZKz0o7bK83z6b5T86rw6oeaqlnrZrK+07VIPYu0hoQoVw== 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=+xCmXcKUQnvouBgl1ejloT8UEhsXfQCXxk3HZJP/LKc=; b=MOyMDEeMzXT4GyihMmG6MVJ7ZVn10/bFP/SP8/5qEq9nV93mJGzDbuMs9z0t3UBHNb6+EGCiaTUqa0HPEmZ25cyz+zWScEveG7/xIu8tVpedzitS1pqSX7gwWQ2aW2l9SbAWeZ2A++SuNJzZcbNmn4KT/jcNCBiRDBJSBr99RYpHdfKPRR+ZgRgRgrw8zjXn1JkCIzOYk8doluI+Q2X95RP7LXhrTYcQVUBHx6qEzACtWsTr2yJydXitPJ1uzLUAN6TiWGi8Gvbu2bRLqVt2S75RrxNyiJWVgcFZ9n0lTrBVVj1dlbH0OfSCpOHJw3okIWe2Gde3iQBVWdj1LTaWQQ== 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=+xCmXcKUQnvouBgl1ejloT8UEhsXfQCXxk3HZJP/LKc=; b=IAr+pAL4U063mIKwvzhBnwaG1nTGcB/SkZHWlmzsBSIQiThaAykkFvCfGq3DlQ0JDhdtlo8YzhneeTIL2KuUcSdpES3jZ0+icH25qN6WCbzRyvnS/7TETP8nF0piDtYv8Oo06fsQvnsf6ibhaHKegxdEqtG2bF+xqHynY1YNQBmUOJScW0hyC/OJ1oPnNJxvA6QQH20j2JR5tfZQoEoSeMvnenduIALu6BGT1r+6agwLyAshC3i4/v2AcT7OqquleX87SICwh2Eq3Uln5HPWmr28LGPEpjYk5n/yZgM4XQVfchDBE1YTzrgM8WWhpw0qZCsgnIid63UMEAGHoT3BSw== 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 GVXPR04MB11042.eurprd04.prod.outlook.com (2603:10a6:150:21f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Wed, 11 Dec 2024 06: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%6]) with mapi id 15.20.8251.008; Wed, 11 Dec 2024 06: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, frank.li@nxp.com, horms@kernel.org, idosch@idosch.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v7 net-next 1/4] net: enetc: add Tx checksum offload for i.MX95 ENETC Date: Wed, 11 Dec 2024 14:37:49 +0800 Message-Id: <20241211063752.744975-2-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241211063752.744975-1-wei.fang@nxp.com> References: <20241211063752.744975-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR06CA0237.apcprd06.prod.outlook.com (2603:1096:4:ac::21) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|GVXPR04MB11042:EE_ X-MS-Office365-Filtering-Correlation-Id: 896eebdf-94ff-47bc-a7bb-08dd19b096bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: nT/29cJLRdvXfBeSo9oyS41998Xo34yCtpfsAA+tBTKrYEd2Lp+EJ5Vl8222KLb19hRfPoSRsINLUTSpNjv2teMGIahWXjaT8HVq9kgBjrqqtetCvG9iDBVjjuHru5Gf8EFKSqbEYJShWzgEDUWg4YWptsIUz4ZoMFolsxFh6SIHG3dqRTJ5f+GVfm6ZSiEP7Gc0Wir1WHjIpwHPtCXSH53cH/00nGDC9t52U/t2lrn6rXbQZsutcFoJEanfYKXJLuvOZwYKuqS99XN4RQRn5PqaHQaylt48rDfHjldZhSakzhCP/9nMTDa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iNn3kxPbydSaxL9O9xBgvvd9eApaJWkb2abvju9a79IxbEXuyabSP6GtlQxOa8bGY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zWdBdUNXvAaP0uY18EpNPjw7D96+YYKQ8mexypPVqOhByjGta/0yb1fvN5uDK5WVV+0JgZs+0ThmcSGFcQWLeYJDrmBSXJtQtt3IU3aEAA6ZvFdWGveVnhYoTAt783S1TYzMDVPlsPqh5A1TxbAprgsh9B2gDew5FSwzYepie0OhPxYT6AgGP1RKVwKa/r2Eoc9BZ1GKdHemG9JXzlUllBvg4ZOHqGDDCQFkNZryItJQFvPy/Qoiz2WfUSk7FMzmXgv2cedHZ/tlyCe0Vor7a2sm4J7ZbQe/aJsN7dtOOeafGrekq2JpW+hnqUxAWkbk1XEntPmxkZzO08Qt+0mXGCVdyY4S84ZUG3HU4Oi9HZ7gb4YX+CQGi/5F9vbwHJwp2o/iUJAdS4NdH4T7HPhNJ2V7EMom8Vy4VOJMO6ob/1jO0wWx0PnwCxLQy8l+vqhfv7qklIW39uQXzyz79Oyb1mffcAqgUjX7QX6Hz4raPNze018FUpRdNr5T/ZBWCyyAfE3QdgI5pIih7v8GktAGw6uPfURaCpwnO3SZWIYLrcbg4iCnHRan2U4OMK+jpYQCQvrn6801zrAPlo5JS3H8+zg2s3EkxXZC2oDIvayYkkeDq0Ul9Pi0mIWcT9KTpOrWjVbhFjFAbN48Jej8pKL/nwgTvsdD8MpqPqR8fUIUJaTFtxoPQtlPlq23UQdGdCxgmkHFJxerCgPSu0PoQL+W0DPUlG2zDC0mcchCRQNJ7cppy+AFzAPY/IGmcJAjQzk1T+HNDOLpYoHczsLMPxnJXLByedUWncwiNIg/RQfUdxeMSMa/D4QrIUa962/TyaYb1D8qwDhOvBEuNkINx6yqyDb75FjgkQY0teDd7va00na7TFcvrTUhNlaA34LLMT734Ywl3JupbzH1TjtYeSbFJYiePW9S2BDwJPFkPcZMo0rR1zLNCJdyeMT2OuI0ey9BmM3kjzKTc0AksAVwWS5zt+NqOIarebIVJGmJBjheclHWacyWo7Ae3WP3xLg8M6iWe92LQCIAir3rr4OFhZyhODhcXWo0KnIYK8Li3Tnmw6TOWvhkBOspHjumaYtXCIqn62nzAd6/aEhE8zfH/AXZG3meMF7KDEntqCimRLhxl1GUFrPRt0MUI93kigyUKDyNiiO3WH4CUJRZst3+RveCNCQLN2m+XH511dUmnFYbbBKfKY7sd92u5jsaU1ZU7yGgGSnVO2V39z+CHayKoGaWp/17KsyYkGjfZSKxBxV+YIj2VVWa50HbRS3VAd49n7Aqj2wrOzaxstzjRheVbUrRcl5/VLD80Vzx7hqTSlAPauEnmD/ZSwPxhB1G6OI4WSOdw7f5MfvvqzW81H0N4EGeFiIL0d/aOnAHix8kJ3tt69oBmgbScgfEgdNUjZWeeMxTp4/gVgI/NRftiH1PQNwGr/klRtV6h1imuj1An0fcLPgewXSnxHVJInL4H1Db4su4BEeGLsXah7pwp61fwQi8xobJBP7QgDaw7Qykso17SP389kTxC0ICUMPCTowig+ixJfKnpC1x6g5IIdsACAmOCkOV9FIWsrNLg7Ui1D6D6btXN3vtrrTLjOI5TYSfM30P X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 896eebdf-94ff-47bc-a7bb-08dd19b096bf X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 06:53:59.3042 (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: J/cNtOvKk72Cf0dYGkPrDH+F2i95ojn8WbsRWIG2X/i8kqZOJIeoyA29PN8HvETozUOplkmZhpURPDmjFGLIWQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB11042 X-Patchwork-Delegate: kuba@kernel.org In addition to supporting Rx checksum offload, i.MX95 ENETC also supports Tx checksum offload. The transmit checksum offload is implemented through the Tx BD. To support Tx checksum offload, software needs to fill some auxiliary information in Tx BD, such as IP version, IP header offset and size, whether L4 is UDP or TCP, etc. Same as Rx checksum offload, Tx checksum offload capability isn't defined in register, so tx_csum bit is added to struct enetc_drvdata to indicate whether the device supports Tx checksum offload. Signed-off-by: Wei Fang Reviewed-by: Frank Li Reviewed-by: Claudiu Manoil --- v2: refine enetc_tx_csum_offload_check(). v3: 1. refine enetc_tx_csum_offload_check() and enetc_skb_is_tcp() through skb->csum_offset instead of touching skb->data. 2. add enetc_skb_is_ipv6() helper function v4: no changes v5: 1. remove 'inline' from enetc_skb_is_ipv6() and enetc_skb_is_tcp(). 2. temp_bd.ipcs is no need to be set due to Linux always aclculates the IPv4 checksum, so remove it. 3. simplify the setting of temp_bd.l3t. 4. remove the error log from the datapath v6: no changes v7: 1. Change the layout of enetc_tx_bd to fix the issue on big-endian hosts. 2. Rebase the patch due to remove the Rx checksum offload patch from v6. --- drivers/net/ethernet/freescale/enetc/enetc.c | 54 ++++++++++++++++--- drivers/net/ethernet/freescale/enetc/enetc.h | 2 + .../net/ethernet/freescale/enetc/enetc_hw.h | 15 ++++-- .../freescale/enetc/enetc_pf_common.c | 3 ++ 4 files changed, 64 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 35634c516e26..c278915cd021 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -143,6 +143,27 @@ static int enetc_ptp_parse(struct sk_buff *skb, u8 *udp, return 0; } +static bool enetc_tx_csum_offload_check(struct sk_buff *skb) +{ + switch (skb->csum_offset) { + case offsetof(struct tcphdr, check): + case offsetof(struct udphdr, check): + return true; + default: + return false; + } +} + +static bool enetc_skb_is_ipv6(struct sk_buff *skb) +{ + return vlan_get_protocol(skb) == htons(ETH_P_IPV6); +} + +static bool enetc_skb_is_tcp(struct sk_buff *skb) +{ + return skb->csum_offset == offsetof(struct tcphdr, check); +} + static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) { bool do_vlan, do_onestep_tstamp = false, do_twostep_tstamp = false; @@ -160,6 +181,30 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) dma_addr_t dma; u8 flags = 0; + enetc_clear_tx_bd(&temp_bd); + if (skb->ip_summed == CHECKSUM_PARTIAL) { + /* Can not support TSD and checksum offload at the same time */ + if (priv->active_offloads & ENETC_F_TXCSUM && + enetc_tx_csum_offload_check(skb) && !tx_ring->tsd_enable) { + temp_bd.l3_aux0 = FIELD_PREP(ENETC_TX_BD_L3_START, + skb_network_offset(skb)); + temp_bd.l3_aux1 = FIELD_PREP(ENETC_TX_BD_L3_HDR_LEN, + skb_network_header_len(skb) / 4); + temp_bd.l3_aux1 |= FIELD_PREP(ENETC_TX_BD_L3T, + enetc_skb_is_ipv6(skb)); + if (enetc_skb_is_tcp(skb)) + temp_bd.l4_aux = FIELD_PREP(ENETC_TX_BD_L4T, + ENETC_TXBD_L4T_TCP); + else + temp_bd.l4_aux = FIELD_PREP(ENETC_TX_BD_L4T, + ENETC_TXBD_L4T_UDP); + flags |= ENETC_TXBD_FLAGS_CSUM_LSO | ENETC_TXBD_FLAGS_L4CS; + } else { + if (skb_checksum_help(skb)) + return 0; + } + } + i = tx_ring->next_to_use; txbd = ENETC_TXBD(*tx_ring, i); prefetchw(txbd); @@ -170,7 +215,6 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) temp_bd.addr = cpu_to_le64(dma); temp_bd.buf_len = cpu_to_le16(len); - temp_bd.lstatus = 0; tx_swbd = &tx_ring->tx_swbd[i]; tx_swbd->dma = dma; @@ -591,7 +635,7 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb, { struct enetc_ndev_priv *priv = netdev_priv(ndev); struct enetc_bdr *tx_ring; - int count, err; + int count; /* Queue one-step Sync packet if already locked */ if (skb->cb[0] & ENETC_F_TX_ONESTEP_SYNC_TSTAMP) { @@ -624,11 +668,6 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb, return NETDEV_TX_BUSY; } - if (skb->ip_summed == CHECKSUM_PARTIAL) { - err = skb_checksum_help(skb); - if (err) - goto drop_packet_err; - } enetc_lock_mdio(); count = enetc_map_tx_buffs(tx_ring, skb); enetc_unlock_mdio(); @@ -3280,6 +3319,7 @@ static const struct enetc_drvdata enetc_pf_data = { static const struct enetc_drvdata enetc4_pf_data = { .sysclk_freq = ENETC_CLK_333M, + .tx_csum = 1, .pmac_offset = ENETC4_PMAC_OFFSET, .eth_ops = &enetc4_pf_ethtool_ops, }; diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 72fa03dbc2dd..e82eb9a9137c 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -234,6 +234,7 @@ enum enetc_errata { struct enetc_drvdata { u32 pmac_offset; /* Only valid for PSI which supports 802.1Qbu */ + u8 tx_csum:1; u64 sysclk_freq; const struct ethtool_ops *eth_ops; }; @@ -341,6 +342,7 @@ enum enetc_active_offloads { ENETC_F_QBV = BIT(9), ENETC_F_QCI = BIT(10), ENETC_F_QBU = BIT(11), + ENETC_F_TXCSUM = BIT(12), }; enum enetc_flags_bit { diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 7c3285584f8a..09ee86d09170 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -558,7 +558,16 @@ union enetc_tx_bd { __le16 frm_len; union { struct { - u8 reserved[3]; + u8 l3_aux0; +#define ENETC_TX_BD_L3_START GENMASK(6, 0) +#define ENETC_TX_BD_IPCS BIT(7) + u8 l3_aux1; +#define ENETC_TX_BD_L3_HDR_LEN GENMASK(6, 0) +#define ENETC_TX_BD_L3T BIT(7) + u8 l4_aux; +#define ENETC_TX_BD_L4T GENMASK(7, 5) +#define ENETC_TXBD_L4T_UDP 1 +#define ENETC_TXBD_L4T_TCP 2 u8 flags; }; /* default layout */ __le32 txstart; @@ -582,10 +591,10 @@ union enetc_tx_bd { }; enum enetc_txbd_flags { - ENETC_TXBD_FLAGS_RES0 = BIT(0), /* reserved */ + ENETC_TXBD_FLAGS_L4CS = BIT(0), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TSE = BIT(1), ENETC_TXBD_FLAGS_W = BIT(2), - ENETC_TXBD_FLAGS_RES3 = BIT(3), /* reserved */ + ENETC_TXBD_FLAGS_CSUM_LSO = BIT(3), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TXSTART = BIT(4), ENETC_TXBD_FLAGS_EX = BIT(6), ENETC_TXBD_FLAGS_F = BIT(7) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 0eecfc833164..09f2d7ec44eb 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -119,6 +119,9 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, ndev->priv_flags |= IFF_UNICAST_FLT; + if (si->drvdata->tx_csum) + priv->active_offloads |= ENETC_F_TXCSUM; + /* TODO: currently, i.MX95 ENETC driver does not support advanced features */ if (!is_enetc_rev1(si)) { ndev->hw_features &= ~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK); From patchwork Wed Dec 11 06:37:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13903010 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2056.outbound.protection.outlook.com [40.107.20.56]) (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 2CC731C54AE; Wed, 11 Dec 2024 06:54:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733900051; cv=fail; b=urQ0oEEU3l2Rp5bt+eNQyaZAs95063IPTYkM0D4MNo30vrugadGi9pbksBG+xlhcJKrnfM29FC/6VzFpNRUoeWYVJoHZ1DfVxW0cS8fi6wSNP+ffPcg0auKKNHMCMPG740TTjcXCmD8ypElf5U2XFl1Ujb5Mm9K2WtNS6D7ilpk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733900051; c=relaxed/simple; bh=0RzK3vPXsSDop+1uHZxrKUHoJVm70qGUneKQ7Mkz9cE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=L0P1VLgN/Ksgr8iHaOQ2rjkQZL/3nFOZlhy4Xk/emEl5HcYwCbTrh7vJrekiM50jCsdnWBd3wAt8ANQdua1Jx0xPJ4UvRr7xHALwLMrjTkbYI8vnmfb93gwhl+MQ6YZ6wZDqSWYtlZtLCqVOchtsvkedddn1Huw926OOIPQHz6I= 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=hKtzPPwy; arc=fail smtp.client-ip=40.107.20.56 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="hKtzPPwy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BIJL4qUmk7OAQpq/SIUCcOQzVpykHN4VgHmBeseZsvdyN4DGJPz3SweQhWPXPuzGYZOlP890BrCXh3Pge3oXu/UM2IICMRjsnFICNkv/Sw0ZXDrsIIVj2AchMOHSE74Qcxumyca1vlPxGCO2KZQYtpS5m+6Y19CsUQI/ZnJRmCGr6aQgVg7oWPAe338C7mgZn9G1lfn4xgkHhlZ3WrQvYTiBKmxMhCeG6BGlhgGQHsXmlZhX2eSfL/aOP6ft7EnCTMwN6ukYvxN6Xu2zuU8AG5OykRibXuhSkdUl4/MkPUpxBdPcFIFOKD1aDfqYsgfIXpWNbd+u+usUTtlaT5z5Aw== 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=1MNH0GTv3dqSITDJ1d/46crgUBeR+xkN9Td26hYfk5c=; b=ZCKCmAcatFdyDujHBwAYkCocL3zFTCw5qm1AZD/X3tI1QupW3xaFzuGKJeS6V3DhfzvXB8L0lP4N8RNRqnN7ECQuYGUld4aEW3zMCaEFBHgevryXNsktvosD3Ah9k+3DZaF3bQuLxJxM4uvbGzXt0et8xhX8hV7e2U8bq8LulqJ4vMfUF1oe/qptVRcb+jET3LwepXcw6+FDLdSmeiDorQcIj+XnPvGlelo/pelY5zb2CeM88QD6ji3WzwWaRoSFoJ86VSxkTOaSCru1OJ5EkeKHxt+t6KB5qwTt0n1ZT0k0cj65wotQDBLOojWgXINgyQ8QzquCiMnNkUZ1hLy4hw== 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=1MNH0GTv3dqSITDJ1d/46crgUBeR+xkN9Td26hYfk5c=; b=hKtzPPwydeZBSxMt7aM25jGq7Df2670HIt/61eoLrc3c8dTAS3fFSRhYfa6WTJxehLPlovs5imLxTsUyYXcR+rJ8DxdjGqUxpfE/X7u9u+l46e0YaygGxqgnTDEKHxbS4LMsvxwW5IUQWF/Dv0vfDleWKw6w3D1GL0GCx784WDirH5zYVGskFs892WnKJDzwEnoxnpUSHs0TOqExAGDsIz5ZFQrTl7c3PgZQ7TTybINGUkHg0ASQf0P0pRy73kvsgmUEBk0DkBQmmBLRGDujmwzaeWXr838xefRUr2hmZbZ3sTVWbvuxA/al3tKA0z25Gb92iwtQ2ZjbpwB3JKuWHQ== 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 GVXPR04MB11042.eurprd04.prod.outlook.com (2603:10a6:150:21f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Wed, 11 Dec 2024 06:54:06 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8251.008; Wed, 11 Dec 2024 06:54:06 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, frank.li@nxp.com, horms@kernel.org, idosch@idosch.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v7 net-next 2/4] net: enetc: update max chained Tx BD number for i.MX95 ENETC Date: Wed, 11 Dec 2024 14:37:50 +0800 Message-Id: <20241211063752.744975-3-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241211063752.744975-1-wei.fang@nxp.com> References: <20241211063752.744975-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR06CA0237.apcprd06.prod.outlook.com (2603:1096:4:ac::21) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|GVXPR04MB11042:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b2b28f0-237e-44c1-ccea-08dd19b09af3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: HwGGlxdzC04H7IJLAUMiDw6m4mlAJSX817DPjF3vXdT5t3RgrXUHL3cXJoBRCy1TcYKVccvV0zyqRvkqQgL/6JTO9e05PlNs1kEDzTyfL9Kb7XI1mPzplVkidRwnGr0RaGY0+l1ThwWTZ90FjUuOW724Fol1osU/I4XD9nmLsoxEwlJr4uvBKMKza9pObClUb0XvM60TS+T6iRau34ZAdJqy6xeP+ydXPuSUvu6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FI+qeHbK1IztjkvVDgqW/fhfw6SnKfv32tbc1lC0An7L3iCdrCSh80JmsxwcBeV7W0skT2pa+EKDxBAmF++DUoJkUAIWX72ApCgPdZm8gwCae9WOazGZJT9Dflyck2J8UotHFrAyinhGcbTSzdC79pw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OLnTc4iUhBgssGbJogFgIkFj9o8bacrppo5Fka0nuyNHhLfW9bGtIuU+mlA0S1SZQufhjSegrr+VzXl6bDLXQcs0k6T/zq+2aELozuhkugoK7ntGzyDdWGwEn8Y/+jLQNdNEdXAreurIXWSKAmzM1rmJOiA9fDi4TNpjHesvbApPiQm/Kg2B/JU4pgUWV5LcQqcXKMsmGMT3m3Y19tE2E5N41WcO4ucBP66FkInPToBk7hUJo2VRJ4Wu5eIdnJklSEM1ZmUt0s8suQiQbMREw7QQyIF3Y+ao0iOvfVlOOYtanVjPohMU6mf3F97I0t8zi8/dO3fn9oAgi8AdlrHEU1ZpgKUlhoWbEi41BW/uOnvZ1gCbH0jM6o9Cx+ILzcdhHLBt6fCqHZ3Ms5ZSIINv/fOdz92r7hXNDEiqyH71ZUZo5T5kOfoQjVj382pXQSHaBH+8yHVwRHHr8s0euEeOcq4TLJetlh6i8y9UF7IRElpWvg4IWiP03+XFwirfTrOQPP2bi3jLTrNH74VUyDu/5LCPc9zvaAtLuWDe4axMtDVHZpXnds+IF436jjZwLaKrXkKh+ZvTKIGPaLa/bUj+Kj42WmCtNbqYCGU5DRKl4LtPngjlIfocU74NvHwOQFAQILJ7lzw5UelFCXGWFUubKnWyu6z3fkBcrxX5pTQKDB+8VI9uE0lSnaY+NPx5Dfbg0nCKEH/g+bIG828fsSVTbU+tNfvpaVVA6Cg2kfeCNcC4MNXH6t3C8vkZzuEw0GNnJMuoCGOB6ERtxwNbtGBYiI739Csdwrmsmg193mIyjJnEgLF8ITVI4whL4Ad/xDtzC5JyEC/U3u+GYHPq3YxWZuAETE/3oWjjCt0yI1pUfYdhlCUYR4PjokNrvXvof872TzKeUCuEmuoAui1M2ElPlDWoAMpOzLpFFb2KwWlZgsmVqfpV2WN3C6FkxsnxOvLhMHUEJqDQUFLfiDMGLS/ePvK1EfNqySyB2TPF6SRk49nST+mxUbGJOcDmP0FDFuNXIed/Gtpib4OlVgz9d/AiNgmCJCp/SjCUA3T1+sU5UTBblutE8AadGKL7nMXNIQzrVm8BuyZnccX5z0u/CMmk6XodaZZ6z2xITcCrU4ZtDMIMf8wgHV2qdAINurgE6XTu1p8XOpxT2b5YBTGRmFHeMAGdhMds9K+nj9EB/NFEH6Z3TnHaknvyB1PqIbsq+RO2EnBGa3/7H4walU6724TM6X9X/SaoogS85/knga0/dyLXDjLXGXwF68AXkPrPFcIs2jLBvagVjd2LamvRgz976j5Vd50nsKj062/qhyS/BRnYuAmniaVRIFTlWXytTuIcmOEvptV5pD38jDpBdUAxhVnn98Z1ScWHHzdDrKruiRmuEcw2nps833DOyA/sfp2XfyZzD+UH3pTQ2qaUsWkQ1u2lJkZkhMzxuNxuDAxglwna0JmmlWYowGPqyBZZbiLCcgfxQ/Qn3yGE8945cEq0ufg9fIbOVgHnjfZYvhrSL6PhZNqNAsDE3UrEZEZrdYc8F7Pvrb0PrElWm1zwqiNPCBxeRsbmApKQlNqWJfASoZ09GHgegFMd5cgYK1sa5Vcx X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1b2b28f0-237e-44c1-ccea-08dd19b09af3 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 06:54:06.3790 (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: ugxvmvdKTiEWaGDCFxMvi8iSd0aYf/0RKQzJfIdoT9S1/3MoCfEzF+xvuYNBYKoaSsNm+laXOUZHxFjbwq/YvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB11042 X-Patchwork-Delegate: kuba@kernel.org The max chained Tx BDs of latest ENETC (i.MX95 ENETC, rev 4.1) has been increased to 63, but since the range of MAX_SKB_FRAGS is 17~45, so for i.MX95 ENETC and later revision, it is better to set ENETC4_MAX_SKB_FRAGS to MAX_SKB_FRAGS. In addition, add max_frags in struct enetc_drvdata to indicate the max chained BDs supported by device. Because the max number of chained BDs supported by LS1028A and i.MX95 ENETC is different. Signed-off-by: Wei Fang Reviewed-by: Frank Li Reviewed-by: Claudiu Manoil Reviewed-by: Simon Horman --- v2: 1. Refine the commit message 2. Add Reviewed-by tag v3 ~ v7: no changes --- drivers/net/ethernet/freescale/enetc/enetc.c | 13 +++++++++---- drivers/net/ethernet/freescale/enetc/enetc.h | 13 +++++++++++-- .../net/ethernet/freescale/enetc/enetc_pf_common.c | 1 + drivers/net/ethernet/freescale/enetc/enetc_vf.c | 1 + 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index c278915cd021..f31b7e71ef97 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -532,6 +532,7 @@ static void enetc_tso_complete_csum(struct enetc_bdr *tx_ring, struct tso_t *tso static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) { + struct enetc_ndev_priv *priv = netdev_priv(tx_ring->ndev); int hdr_len, total_len, data_len; struct enetc_tx_swbd *tx_swbd; union enetc_tx_bd *txbd; @@ -597,7 +598,7 @@ static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb bd_data_num++; tso_build_data(skb, &tso, size); - if (unlikely(bd_data_num >= ENETC_MAX_SKB_FRAGS && data_len)) + if (unlikely(bd_data_num >= priv->max_frags && data_len)) goto err_chained_bd; } @@ -658,7 +659,7 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb, count = enetc_map_tx_tso_buffs(tx_ring, skb); enetc_unlock_mdio(); } else { - if (unlikely(skb_shinfo(skb)->nr_frags > ENETC_MAX_SKB_FRAGS)) + if (unlikely(skb_shinfo(skb)->nr_frags > priv->max_frags)) if (unlikely(skb_linearize(skb))) goto drop_packet_err; @@ -676,7 +677,7 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb, if (unlikely(!count)) goto drop_packet_err; - if (enetc_bd_unused(tx_ring) < ENETC_TXBDS_MAX_NEEDED) + if (enetc_bd_unused(tx_ring) < ENETC_TXBDS_MAX_NEEDED(priv->max_frags)) netif_stop_subqueue(ndev, tx_ring->index); return NETDEV_TX_OK; @@ -944,7 +945,8 @@ static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget) if (unlikely(tx_frm_cnt && netif_carrier_ok(ndev) && __netif_subqueue_stopped(ndev, tx_ring->index) && !test_bit(ENETC_TX_DOWN, &priv->flags) && - (enetc_bd_unused(tx_ring) >= ENETC_TXBDS_MAX_NEEDED))) { + (enetc_bd_unused(tx_ring) >= + ENETC_TXBDS_MAX_NEEDED(priv->max_frags)))) { netif_wake_subqueue(ndev, tx_ring->index); } @@ -3314,18 +3316,21 @@ EXPORT_SYMBOL_GPL(enetc_pci_remove); static const struct enetc_drvdata enetc_pf_data = { .sysclk_freq = ENETC_CLK_400M, .pmac_offset = ENETC_PMAC_OFFSET, + .max_frags = ENETC_MAX_SKB_FRAGS, .eth_ops = &enetc_pf_ethtool_ops, }; static const struct enetc_drvdata enetc4_pf_data = { .sysclk_freq = ENETC_CLK_333M, .tx_csum = 1, + .max_frags = ENETC4_MAX_SKB_FRAGS, .pmac_offset = ENETC4_PMAC_OFFSET, .eth_ops = &enetc4_pf_ethtool_ops, }; static const struct enetc_drvdata enetc_vf_data = { .sysclk_freq = ENETC_CLK_400M, + .max_frags = ENETC_MAX_SKB_FRAGS, .eth_ops = &enetc_vf_ethtool_ops, }; diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index e82eb9a9137c..1e680f0f5123 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -59,9 +59,16 @@ struct enetc_rx_swbd { /* ENETC overhead: optional extension BD + 1 BD gap */ #define ENETC_TXBDS_NEEDED(val) ((val) + 2) -/* max # of chained Tx BDs is 15, including head and extension BD */ +/* For LS1028A, max # of chained Tx BDs is 15, including head and + * extension BD. + */ #define ENETC_MAX_SKB_FRAGS 13 -#define ENETC_TXBDS_MAX_NEEDED ENETC_TXBDS_NEEDED(ENETC_MAX_SKB_FRAGS + 1) +/* For ENETC v4 and later versions, max # of chained Tx BDs is 63, + * including head and extension BD, but the range of MAX_SKB_FRAGS + * is 17 ~ 45, so set ENETC4_MAX_SKB_FRAGS to MAX_SKB_FRAGS. + */ +#define ENETC4_MAX_SKB_FRAGS MAX_SKB_FRAGS +#define ENETC_TXBDS_MAX_NEEDED(x) ENETC_TXBDS_NEEDED((x) + 1) struct enetc_ring_stats { unsigned int packets; @@ -235,6 +242,7 @@ enum enetc_errata { struct enetc_drvdata { u32 pmac_offset; /* Only valid for PSI which supports 802.1Qbu */ u8 tx_csum:1; + u8 max_frags; u64 sysclk_freq; const struct ethtool_ops *eth_ops; }; @@ -377,6 +385,7 @@ struct enetc_ndev_priv { u16 msg_enable; u8 preemptible_tcs; + u8 max_frags; /* The maximum number of BDs for fragments */ enum enetc_active_offloads active_offloads; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 09f2d7ec44eb..00b73a948746 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -101,6 +101,7 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, priv->msg_enable = (NETIF_MSG_WOL << 1) - 1; priv->sysclk_freq = si->drvdata->sysclk_freq; + priv->max_frags = si->drvdata->max_frags; ndev->netdev_ops = ndev_ops; enetc_set_ethtool_ops(ndev); ndev->watchdog_timeo = 5 * HZ; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c index a5f8ce576b6e..63d78b2b8670 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c @@ -136,6 +136,7 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev, priv->msg_enable = (NETIF_MSG_IFUP << 1) - 1; priv->sysclk_freq = si->drvdata->sysclk_freq; + priv->max_frags = si->drvdata->max_frags; ndev->netdev_ops = ndev_ops; enetc_set_ethtool_ops(ndev); ndev->watchdog_timeo = 5 * HZ; From patchwork Wed Dec 11 06:37:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13903011 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2055.outbound.protection.outlook.com [40.107.20.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E71FA1C5F35; Wed, 11 Dec 2024 06:54:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733900057; cv=fail; b=rx0NIP27OwWgWFw3ciGzaede9rtY76LXcvubDpVXMAPk7b5U5U+KuTFRYfk0VaVn7SDcXheHJ2tsnkReCb+eaopQ24raU4C18EHCFGHj85T3NnrYZEgEHH35ZxCW9qbo/GwXVin/XqjP+GJd38jopbhHlq+j2ZxsEZapiP1UFTQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733900057; c=relaxed/simple; bh=E0b5d1t7ifrKI9eRpb1qN33rREfD3EXegMJd4Tjah6A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pH4HPJV7VkGRoJJelmzk0qwSwPj9W73I8rfUw6id73rKPT/pz7tbsep6fhDYvx8IY2L1Nwxve+6lSps31N7+H6rkg6463j+WEz8v5rNdiwywS2Hjbbu+HY8wonAtEKOQb5GFqPZDDkIPAQeqWgUg/Xw4gHf3cRCT4qike4ySpiA= 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=g3ZO+Twc; arc=fail smtp.client-ip=40.107.20.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="g3ZO+Twc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F0nZLB2LzCS7eOFbIeFOKLaM19LGZ2IX2C+5oGjKKfgPm2Ylfd+hNEAnWI/SaBvnugCk1/4M7JzL4nwnzw2NglviffG3xT9ZrvZpJ7aFXGbJcX5WmNAXDCo4IJ10l3x7pa3rfGJ5fRp6ZuFNad2aE7wXzLEETQPLvDv/PXdzzB7ulcA9HSqBB2zxy+aEHAOByIz/nW+4v3QLJFzMAe51eNtK0XeE8K168G41/E7NX+SQ8969L+pMvsiNIJ9IJnBkun78FWC+22INcrEreNIEh1AHfwcsEMu7reQYt5S+iu1x6apJsggkdzKQt/NO/4wh+WStHpwc2M+Bt0IabF58HQ== 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=DXIuHrrJmtxWfBvspEgItbS+WW9KnTzgyG/V51XnT50=; b=P9FyYCaJmAPyyDlll6NI0Lo5M9OMrl5biwgU2TLmjeh2n/v1n5f5CwcC0Brqn3FbpYzm9cF+tLLdDqBJPZ4kMPmpHRpVxFxbz9WeY7jfaIjDKVFuqCkmtQL5wPVJnU/TKevdZSaKoonSZ5DkcgF5+a0c20AhqvzBhZdhN4qewznVizYowqvJZF8ct5ynRKd81io/a9rRBIyWXdD4JpHdlFW6Rw1OjZzexXTWOshF4wMNs/xv/X1Ei64ZWOTwvCI5Kno3HXSjas9Y6YzraZx2EQMM+tBf9duBvoVksWdgrIveiVmmT2A4OImxwkNhm9TFdkMmKvzfzcYEdKThHFAWxA== 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=DXIuHrrJmtxWfBvspEgItbS+WW9KnTzgyG/V51XnT50=; b=g3ZO+Twc8lBK93PuMg7EsFdsEBPBgPz7mKNbbYVo8SmONALC5kpvgeniRf7bOV7TRWc1ZWqVc3oAPy4i3v7NCVkd4T0LwVIunTPmPO4Fdb0zXhlMHZ+dNEyFMN9IPX2w+DQYdyJSX07DSt09HhwND/NQCYzOqBjFc5aYQyRpGDmSyXpN3ZR3UIOpuhjBizxAWH0qwrxnJwCM56HDaYMb1yiqBpuXrutIISlAIZ4Qu1czeK7BfrnwPjGX8hZnRFkN0mBjYkcbriu2FovSyQl5nD9KTvdltMi0MSBb5B0eFIZK1c0IHA+IWnm63KWIPiMxH5SkHU4Ln+e4iTjxhKQKAA== 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 GVXPR04MB11042.eurprd04.prod.outlook.com (2603:10a6:150:21f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Wed, 11 Dec 2024 06:54:12 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8251.008; Wed, 11 Dec 2024 06:54:11 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, frank.li@nxp.com, horms@kernel.org, idosch@idosch.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v7 net-next 3/4] net: enetc: add LSO support for i.MX95 ENETC PF Date: Wed, 11 Dec 2024 14:37:51 +0800 Message-Id: <20241211063752.744975-4-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241211063752.744975-1-wei.fang@nxp.com> References: <20241211063752.744975-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR06CA0237.apcprd06.prod.outlook.com (2603:1096:4:ac::21) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|GVXPR04MB11042:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f2cb3b7-84f1-4fde-bd64-08dd19b09dfe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: pk/1bLveIffikwaTYp2GF1DaduVwAg6XwLg87VWB+8C75jjnYAtQ4ColNRdqHypqvJ/RqHQ9vS+wLdDqs2gs+ZtVwWoF6Prl45giXGtEnR38P8kAeKWKSLQNvuy/tTmoH4GwhBsCizcJ9Ij3iJ6vDSMMLRcybLIi5PMHQONIYPW7wQdO6ZhIztCvoE6e2VzV4veiLU5Hk9GT3Cu4Wkuoj4pRFEPN6IF8KMCoRaWxjcY8Eajd+yGM+jIALrPHOzYHUofykePJ7a4JvZ7UaXDz2+oF5sb8mSmWVr+7c83w+guJJ5eFQAqvViW6wm/0TyenY+yhYTYt3HSRsDF0bJSc07RmXl19udN8mbX6fSYXIKl6X6bjAMz1267wtOsvLlueE0f461WYUDL4RXXhTP8gm2+PgyQ9lE01q6cH68C5HOw226ZoduIEVbjQrRlTt0LprElwqpkwhMldo723sWODevvzxiWWOk9P301UwJqYugxV72avNKws7f6mn2DYFp9gcwLvGSegYmOlKB0eU/Uah4YKqtYAtLxQJaVkEdSlOsh2jnrni92YqRGvMtay+GKLLASHsjymkb6Om8tfBzvvJCViRHt7S8T+vjZlRYSvSNGZi4jAE93WsO0nrnMiXx1T1Kq+i19ERSr0AGOshmHuZfj5nTISTtkse8C5b8k3GQesElqweUW6c7OP5wO1rZ8qL6LcsiCgbqvzxEosC3Uqz4IMVT+SptHSgk4jkQdfakoUvnVJ/Pid+hZWtCc+THBTcV8xqrgjbRu9/2PHKR3qseIn6Q+jsRxGPoZQpc/B6ZQ6BEHz57HSvh2K/QHRBwWgvUMV+fhfag7uKoNY1Lf6Ts2c175oSxfBqSn0HH2ge0iRtSO2Mooqax0cdm6aKzAb1rhAOQrAmBwB33Y6xa4SBpnqKskEGR6N7uBx9qE8mQkoB5UGbnhbyZoVGWrV1m5OIj6EYLYLICqlHRWtQRjzxfbwL6qeJT1uDNCqTlzyixkiasdSG9C5HRSkp5yPEeo8oN5L8SegYEh9ymgTjXzXLkDs/cuTPEY0rSWUtOQ9bq+UgmyTDfi13euvSd6pAh17Oo4zVY102BZC/TZ/wElpMRfzM+UFwsLPjcAIOLLZS/0UTMs9P2sRiDps3YdGLvwUxWs7S/5/5Vv/8zmduocvcBmjI95NguvtDhybyCIQrENEtpMXxmVhxoxozmsnypNPzp6UWcTJvxUInS7DgDpxVd5CqmyxyBqmsxDDBj/tdZzKMe1F9Zzc1WzOrh2SUPaODMsDP5MYVJvU316faFZpxawAshy3wPyLSvP4QTClbfUK3761KQvMX1c/qQqheL5Pge3KUcTvE/TIXwKJZMM6tXZ/bM371lg+uy2ertwP6jtjOnfQGWqInLRJxkLqdAlaYth0fYPLYtuFipUcXN5YEBvZlDRFetMW9bQOphzCsqY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4udc03qVORKpr1+KJr+lItU8l6Cy8YKP2tUXkKiMaYkkDRvD8xufkNqWPCwA38gonUI2dNWDlz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4gj3+LiemicANH/OI3qtI5gKGgYeHgG3e+1ajQ12mcyAvao8CSGiPay/Fqwv/qPaLpJYKRIKI4G4cFsSxTB/GP21CBcX1x71ZnW5VcKnyZ0LWbdBfLh9d1/jwNSr3KHM+twdmichy30E+U7IZ6RKL5kt6GcjW8cWzkSwv/BDBDz+u7qEEtWXDOTZJ/Spx4fm27YAxsm1W0jBG5vNFUTOKaEUETWzOqrrHXzmUrmt1bwqMLqZUAOEImWvgNITYUeYEwf+S0eR3+RH9fpGxHb9p4klcS1rnblZOWMQsPidADA+ydzyPMYLe5kM2rIcx9nkCmJ971YgeyT4tArBashtPhCuoJz/ClsymWBl6wdclaeepUMmETrObmBtg/DSi135uqds8vczCnN/qsmefa9O7NuMfl+CQfeX7uLRaHJZmWb4bRLAj X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f2cb3b7-84f1-4fde-bd64-08dd19b09dfe X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 06:54:11.7992 (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: VXWR/zEuSI+DCakWOz1I154mZ+7LfGq+F6jXHXvUdDMpVgdvu54TRY2M6iOz8J+FQsAWV6Q4pAeEqtczIX+Aow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB11042 X-Patchwork-Delegate: kuba@kernel.org ENETC rev 4.1 supports large send offload (LSO), segmenting large TCP and UDP transmit units into multiple Ethernet frames. To support LSO, software needs to fill some auxiliary information in Tx BD, such as LSO header length, frame length, LSO maximum segment size, etc. At 1Gbps link rate, TCP segmentation was tested using iperf3, and the CPU performance before and after applying the patch was compared through the top command. It can be seen that LSO saves a significant amount of CPU cycles compared to software TSO. Before applying the patch: %Cpu(s): 0.1 us, 4.1 sy, 0.0 ni, 85.7 id, 0.0 wa, 0.5 hi, 9.7 si After applying the patch: %Cpu(s): 0.1 us, 2.3 sy, 0.0 ni, 94.5 id, 0.0 wa, 0.4 hi, 2.6 si Signed-off-by: Wei Fang Reviewed-by: Frank Li Reviewed-by: Claudiu Manoil --- v2: no changes v3: use enetc_skb_is_ipv6() helper fucntion which is added in patch 2 v4: fix a typo v5: no changes v6: remove error logs from the datapath v7: rebase the patch duo to the layout change of enetc_tx_bd --- drivers/net/ethernet/freescale/enetc/enetc.c | 257 +++++++++++++++++- drivers/net/ethernet/freescale/enetc/enetc.h | 15 + .../net/ethernet/freescale/enetc/enetc4_hw.h | 22 ++ .../net/ethernet/freescale/enetc/enetc_hw.h | 15 +- .../freescale/enetc/enetc_pf_common.c | 3 + 5 files changed, 302 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index f31b7e71ef97..aca679509d83 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -530,6 +530,224 @@ static void enetc_tso_complete_csum(struct enetc_bdr *tx_ring, struct tso_t *tso } } +static inline int enetc_lso_count_descs(const struct sk_buff *skb) +{ + /* 4 BDs: 1 BD for LSO header + 1 BD for extended BD + 1 BD + * for linear area data but not include LSO header, namely + * skb_headlen(skb) - lso_hdr_len. And 1 BD for gap. + */ + return skb_shinfo(skb)->nr_frags + 4; +} + +static int enetc_lso_get_hdr_len(const struct sk_buff *skb) +{ + int hdr_len, tlen; + + tlen = skb_is_gso_tcp(skb) ? tcp_hdrlen(skb) : sizeof(struct udphdr); + hdr_len = skb_transport_offset(skb) + tlen; + + return hdr_len; +} + +static void enetc_lso_start(struct sk_buff *skb, struct enetc_lso_t *lso) +{ + lso->lso_seg_size = skb_shinfo(skb)->gso_size; + lso->ipv6 = enetc_skb_is_ipv6(skb); + lso->tcp = skb_is_gso_tcp(skb); + lso->l3_hdr_len = skb_network_header_len(skb); + lso->l3_start = skb_network_offset(skb); + lso->hdr_len = enetc_lso_get_hdr_len(skb); + lso->total_len = skb->len - lso->hdr_len; +} + +static void enetc_lso_map_hdr(struct enetc_bdr *tx_ring, struct sk_buff *skb, + int *i, struct enetc_lso_t *lso) +{ + union enetc_tx_bd txbd_tmp, *txbd; + struct enetc_tx_swbd *tx_swbd; + u16 frm_len, frm_len_ext; + u8 flags, e_flags = 0; + dma_addr_t addr; + char *hdr; + + /* Get the first BD of the LSO BDs chain */ + txbd = ENETC_TXBD(*tx_ring, *i); + tx_swbd = &tx_ring->tx_swbd[*i]; + prefetchw(txbd); + + /* Prepare LSO header: MAC + IP + TCP/UDP */ + hdr = tx_ring->tso_headers + *i * TSO_HEADER_SIZE; + memcpy(hdr, skb->data, lso->hdr_len); + addr = tx_ring->tso_headers_dma + *i * TSO_HEADER_SIZE; + + frm_len = lso->total_len & 0xffff; + frm_len_ext = (lso->total_len >> 16) & 0xf; + + /* Set the flags of the first BD */ + flags = ENETC_TXBD_FLAGS_EX | ENETC_TXBD_FLAGS_CSUM_LSO | + ENETC_TXBD_FLAGS_LSO | ENETC_TXBD_FLAGS_L4CS; + + enetc_clear_tx_bd(&txbd_tmp); + txbd_tmp.addr = cpu_to_le64(addr); + txbd_tmp.hdr_len = cpu_to_le16(lso->hdr_len); + + /* first BD needs frm_len and offload flags set */ + txbd_tmp.frm_len = cpu_to_le16(frm_len); + txbd_tmp.flags = flags; + + txbd_tmp.l3_aux0 = FIELD_PREP(ENETC_TX_BD_L3_START, lso->l3_start); + /* l3_hdr_size in 32-bits (4 bytes) */ + txbd_tmp.l3_aux1 = FIELD_PREP(ENETC_TX_BD_L3_HDR_LEN, + lso->l3_hdr_len / 4); + if (lso->ipv6) + txbd_tmp.l3_aux1 |= FIELD_PREP(ENETC_TX_BD_L3T, 1); + else + txbd_tmp.l3_aux0 |= FIELD_PREP(ENETC_TX_BD_IPCS, 1); + + txbd_tmp.l4_aux = FIELD_PREP(ENETC_TX_BD_L4T, lso->tcp ? + ENETC_TXBD_L4T_TCP : ENETC_TXBD_L4T_UDP); + + /* For the LSO header we do not set the dma address since + * we do not want it unmapped when we do cleanup. We still + * set len so that we count the bytes sent. + */ + tx_swbd->len = lso->hdr_len; + tx_swbd->do_twostep_tstamp = false; + tx_swbd->check_wb = false; + + /* Actually write the header in the BD */ + *txbd = txbd_tmp; + + /* Get the next BD, and the next BD is extended BD */ + enetc_bdr_idx_inc(tx_ring, i); + txbd = ENETC_TXBD(*tx_ring, *i); + tx_swbd = &tx_ring->tx_swbd[*i]; + prefetchw(txbd); + + enetc_clear_tx_bd(&txbd_tmp); + if (skb_vlan_tag_present(skb)) { + /* Setup the VLAN fields */ + txbd_tmp.ext.vid = cpu_to_le16(skb_vlan_tag_get(skb)); + txbd_tmp.ext.tpid = 0; /* < C-TAG */ + e_flags = ENETC_TXBD_E_FLAGS_VLAN_INS; + } + + /* Write the BD */ + txbd_tmp.ext.e_flags = e_flags; + txbd_tmp.ext.lso_sg_size = cpu_to_le16(lso->lso_seg_size); + txbd_tmp.ext.frm_len_ext = cpu_to_le16(frm_len_ext); + *txbd = txbd_tmp; +} + +static int enetc_lso_map_data(struct enetc_bdr *tx_ring, struct sk_buff *skb, + int *i, struct enetc_lso_t *lso, int *count) +{ + union enetc_tx_bd txbd_tmp, *txbd = NULL; + struct enetc_tx_swbd *tx_swbd; + skb_frag_t *frag; + dma_addr_t dma; + u8 flags = 0; + int len, f; + + len = skb_headlen(skb) - lso->hdr_len; + if (len > 0) { + dma = dma_map_single(tx_ring->dev, skb->data + lso->hdr_len, + len, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(tx_ring->dev, dma))) + return -ENOMEM; + + enetc_bdr_idx_inc(tx_ring, i); + txbd = ENETC_TXBD(*tx_ring, *i); + tx_swbd = &tx_ring->tx_swbd[*i]; + prefetchw(txbd); + *count += 1; + + enetc_clear_tx_bd(&txbd_tmp); + txbd_tmp.addr = cpu_to_le64(dma); + txbd_tmp.buf_len = cpu_to_le16(len); + + tx_swbd->dma = dma; + tx_swbd->len = len; + tx_swbd->is_dma_page = 0; + tx_swbd->dir = DMA_TO_DEVICE; + } + + frag = &skb_shinfo(skb)->frags[0]; + for (f = 0; f < skb_shinfo(skb)->nr_frags; f++, frag++) { + if (txbd) + *txbd = txbd_tmp; + + len = skb_frag_size(frag); + dma = skb_frag_dma_map(tx_ring->dev, frag, 0, len, + DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(tx_ring->dev, dma))) + return -ENOMEM; + + /* Get the next BD */ + enetc_bdr_idx_inc(tx_ring, i); + txbd = ENETC_TXBD(*tx_ring, *i); + tx_swbd = &tx_ring->tx_swbd[*i]; + prefetchw(txbd); + *count += 1; + + enetc_clear_tx_bd(&txbd_tmp); + txbd_tmp.addr = cpu_to_le64(dma); + txbd_tmp.buf_len = cpu_to_le16(len); + + tx_swbd->dma = dma; + tx_swbd->len = len; + tx_swbd->is_dma_page = 1; + tx_swbd->dir = DMA_TO_DEVICE; + } + + /* Last BD needs 'F' bit set */ + flags |= ENETC_TXBD_FLAGS_F; + txbd_tmp.flags = flags; + *txbd = txbd_tmp; + + tx_swbd->is_eof = 1; + tx_swbd->skb = skb; + + return 0; +} + +static int enetc_lso_hw_offload(struct enetc_bdr *tx_ring, struct sk_buff *skb) +{ + struct enetc_tx_swbd *tx_swbd; + struct enetc_lso_t lso = {0}; + int err, i, count = 0; + + /* Initialize the LSO handler */ + enetc_lso_start(skb, &lso); + i = tx_ring->next_to_use; + + enetc_lso_map_hdr(tx_ring, skb, &i, &lso); + /* First BD and an extend BD */ + count += 2; + + err = enetc_lso_map_data(tx_ring, skb, &i, &lso, &count); + if (err) + goto dma_err; + + /* Go to the next BD */ + enetc_bdr_idx_inc(tx_ring, &i); + tx_ring->next_to_use = i; + enetc_update_tx_ring_tail(tx_ring); + + return count; + +dma_err: + do { + tx_swbd = &tx_ring->tx_swbd[i]; + enetc_free_tx_frame(tx_ring, tx_swbd); + if (i == 0) + i = tx_ring->bd_count; + i--; + } while (count--); + + return 0; +} + static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) { struct enetc_ndev_priv *priv = netdev_priv(tx_ring->ndev); @@ -650,14 +868,26 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb, tx_ring = priv->tx_ring[skb->queue_mapping]; if (skb_is_gso(skb)) { - if (enetc_bd_unused(tx_ring) < tso_count_descs(skb)) { - netif_stop_subqueue(ndev, tx_ring->index); - return NETDEV_TX_BUSY; - } + /* LSO data unit lengths of up to 256KB are supported */ + if (priv->active_offloads & ENETC_F_LSO && + (skb->len - enetc_lso_get_hdr_len(skb)) <= + ENETC_LSO_MAX_DATA_LEN) { + if (enetc_bd_unused(tx_ring) < enetc_lso_count_descs(skb)) { + netif_stop_subqueue(ndev, tx_ring->index); + return NETDEV_TX_BUSY; + } - enetc_lock_mdio(); - count = enetc_map_tx_tso_buffs(tx_ring, skb); - enetc_unlock_mdio(); + count = enetc_lso_hw_offload(tx_ring, skb); + } else { + if (enetc_bd_unused(tx_ring) < tso_count_descs(skb)) { + netif_stop_subqueue(ndev, tx_ring->index); + return NETDEV_TX_BUSY; + } + + enetc_lock_mdio(); + count = enetc_map_tx_tso_buffs(tx_ring, skb); + enetc_unlock_mdio(); + } } else { if (unlikely(skb_shinfo(skb)->nr_frags > priv->max_frags)) if (unlikely(skb_linearize(skb))) @@ -1798,6 +2028,9 @@ void enetc_get_si_caps(struct enetc_si *si) si->num_rss = ENETC_SIRSSCAPR_GET_NUM_RSS(rss); } + if (val & ENETC_SIPCAPR0_LSO) + si->hw_features |= ENETC_SI_F_LSO; + if (val & ENETC_SIPCAPR0_QBV) si->hw_features |= ENETC_SI_F_QBV; @@ -2102,6 +2335,13 @@ static int enetc_setup_default_rss_table(struct enetc_si *si, int num_groups) return 0; } +static void enetc_set_lso_flags_mask(struct enetc_hw *hw) +{ + enetc_wr(hw, ENETC4_SILSOSFMR0, + SILSOSFMR0_VAL_SET(TCP_NL_SEG_FLAGS_DMASK, TCP_NL_SEG_FLAGS_DMASK)); + enetc_wr(hw, ENETC4_SILSOSFMR1, 0); +} + int enetc_configure_si(struct enetc_ndev_priv *priv) { struct enetc_si *si = priv->si; @@ -2115,6 +2355,9 @@ int enetc_configure_si(struct enetc_ndev_priv *priv) /* enable SI */ enetc_wr(hw, ENETC_SIMR, ENETC_SIMR_EN); + if (si->hw_features & ENETC_SI_F_LSO) + enetc_set_lso_flags_mask(hw); + /* TODO: RSS support for i.MX95 will be supported later, and the * is_enetc_rev1() condition will be removed */ diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 1e680f0f5123..6db6b3eee45c 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -41,6 +41,19 @@ struct enetc_tx_swbd { u8 qbv_en:1; }; +struct enetc_lso_t { + bool ipv6; + bool tcp; + u8 l3_hdr_len; + u8 hdr_len; /* LSO header length */ + u8 l3_start; + u16 lso_seg_size; + int total_len; /* total data length, not include LSO header */ +}; + +#define ENETC_1KB_SIZE 1024 +#define ENETC_LSO_MAX_DATA_LEN (256 * ENETC_1KB_SIZE) + #define ENETC_RX_MAXFRM_SIZE ENETC_MAC_MAXFRM_SIZE #define ENETC_RXB_TRUESIZE 2048 /* PAGE_SIZE >> 1 */ #define ENETC_RXB_PAD NET_SKB_PAD /* add extra space if needed */ @@ -238,6 +251,7 @@ enum enetc_errata { #define ENETC_SI_F_PSFP BIT(0) #define ENETC_SI_F_QBV BIT(1) #define ENETC_SI_F_QBU BIT(2) +#define ENETC_SI_F_LSO BIT(3) struct enetc_drvdata { u32 pmac_offset; /* Only valid for PSI which supports 802.1Qbu */ @@ -351,6 +365,7 @@ enum enetc_active_offloads { ENETC_F_QCI = BIT(10), ENETC_F_QBU = BIT(11), ENETC_F_TXCSUM = BIT(12), + ENETC_F_LSO = BIT(13), }; enum enetc_flags_bit { diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_hw.h b/drivers/net/ethernet/freescale/enetc/enetc4_hw.h index 26b220677448..cdde8e93a73c 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc4_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc4_hw.h @@ -12,6 +12,28 @@ #define NXP_ENETC_VENDOR_ID 0x1131 #define NXP_ENETC_PF_DEV_ID 0xe101 +/**********************Station interface registers************************/ +/* Station interface LSO segmentation flag mask register 0/1 */ +#define ENETC4_SILSOSFMR0 0x1300 +#define SILSOSFMR0_TCP_MID_SEG GENMASK(27, 16) +#define SILSOSFMR0_TCP_1ST_SEG GENMASK(11, 0) +#define SILSOSFMR0_VAL_SET(first, mid) ((((mid) << 16) & SILSOSFMR0_TCP_MID_SEG) | \ + ((first) & SILSOSFMR0_TCP_1ST_SEG)) + +#define ENETC4_SILSOSFMR1 0x1304 +#define SILSOSFMR1_TCP_LAST_SEG GENMASK(11, 0) +#define TCP_FLAGS_FIN BIT(0) +#define TCP_FLAGS_SYN BIT(1) +#define TCP_FLAGS_RST BIT(2) +#define TCP_FLAGS_PSH BIT(3) +#define TCP_FLAGS_ACK BIT(4) +#define TCP_FLAGS_URG BIT(5) +#define TCP_FLAGS_ECE BIT(6) +#define TCP_FLAGS_CWR BIT(7) +#define TCP_FLAGS_NS BIT(8) +/* According to tso_build_hdr(), clear all special flags for not last packet. */ +#define TCP_NL_SEG_FLAGS_DMASK (TCP_FLAGS_FIN | TCP_FLAGS_RST | TCP_FLAGS_PSH) + /***************************ENETC port registers**************************/ #define ENETC4_ECAPR0 0x0 #define ECAPR0_RFS BIT(2) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 09ee86d09170..5518c0dba1f1 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 { @@ -578,13 +583,16 @@ union enetc_tx_bd { __le32 tstamp; __le16 tpid; __le16 vid; - u8 reserved[6]; + __le16 lso_sg_size; /* For ENETC 4.1 and later */ + __le16 frm_len_ext; /* For ENETC 4.1 and later */ + u8 reserved[2]; u8 e_flags; u8 flags; } ext; /* Tx BD extension */ struct { __le32 tstamp; - u8 reserved[10]; + u8 reserved[8]; + __le16 lso_err_count; /* For ENETC 4.1 and later */ u8 status; u8 flags; } wb; /* writeback descriptor */ @@ -593,6 +601,7 @@ union enetc_tx_bd { enum enetc_txbd_flags { ENETC_TXBD_FLAGS_L4CS = BIT(0), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TSE = BIT(1), + ENETC_TXBD_FLAGS_LSO = BIT(1), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_W = BIT(2), ENETC_TXBD_FLAGS_CSUM_LSO = BIT(3), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TXSTART = BIT(4), diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 00b73a948746..31dedc665a16 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -123,6 +123,9 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, if (si->drvdata->tx_csum) priv->active_offloads |= ENETC_F_TXCSUM; + if (si->hw_features & ENETC_SI_F_LSO) + priv->active_offloads |= ENETC_F_LSO; + /* TODO: currently, i.MX95 ENETC driver does not support advanced features */ if (!is_enetc_rev1(si)) { ndev->hw_features &= ~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK); From patchwork Wed Dec 11 06:37:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13903012 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2073.outbound.protection.outlook.com [40.107.21.73]) (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 7D6E71C5CCD; Wed, 11 Dec 2024 06:54:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733900062; cv=fail; b=ao1pi7tqoUU75D9IyUbKZy6mhB4B16ovi0PvybWTyE48XKn1dCGPj9ty/6vxuyUxJZZP8G9kTj1JJJAiMozDvjIaKrgQbSP011NlTNCZe+mVKI5i/QRdQ0w6fqIpkFbD2yNrzGY6cwLrqkkqCJfL5pwwPw2LOBOUIqtHM7QOxEU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733900062; c=relaxed/simple; bh=eZ+f86BtXZnFrFVtUTGtIbNQ7TesIQCEFQMtsIZMEsU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=h7PUcsypeZeJbfB3xd/Miw9rsLkaHim0888WIqcECefSjuhWkt7t9YXppL6R5CJHWriR+WVRz6M3xqs6j+76zKwvy8FznGrFsQh7xRsaJy46CiEil9NkwXKWHCJMgTd+PYl06QYu2M8zucXrdcKVUWMxgqx6J+hl2j1duygV9FQ= 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=DTnUxha8; arc=fail smtp.client-ip=40.107.21.73 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="DTnUxha8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j+fJcb6oQqDDebWdwR2d9mte5uorsb9ONQebv57b4kmX/oQ+LvyUkIByzUxutUtsz9TIHGZMTIszJL8iFBGVQAZiR0m53pSOJGmcbSZG8lb+6DzqxzxNrjhlylO6tkCvUq4439vJXoLwUNFjujIHDNEO7t8P2o+M7K0OsrTA3jJ2q4i7N5wcfDjbxNSaOanuR8V6AXqr9SpmkgTV0Y1GGluQKVCUAyNcsXpb3yP5M8FU2p1KlMMq/FjTjEZuI53Ew916IXwuswXoQXBzOyzUx1a+Jx6137qDuz7w5KB2VAl7JXR3ToCp7WseQE5Q+gZGon6A5jbx+/ZbFHl9b8bojQ== 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=9Yyqj/0ldTtYZEIVR+oRp/9wA2PcIxoJtU+g0QhTT84=; b=zD3HUdJewZO2bVT7bu9lwxFxDTzQJWm9GHTAldOsAEu4yyFOW4m4Mulc4oIJ7VHrY6i9gehkIDVTmNRmkVWJV8GAfn+eL82kkekUTquCVSLVFO8WzVbeOBzQ0+aepXmwyQNmcVD2cRSkt5oriVemvqxdIWKHr5vLXMq1tepnXVW2GRLnpM92V6h/aGlRBoZxJRrVA6jmpesTHzHT1SOBbgAv0Q8X2kw35t6o94CXzVMqnq14jlqpMeSC2Qs4Ab/6FYF+6e1F46rtd626X/wMdEeZt8E+3qij5Ncx8cb832E5wRrWv4bGOVT5DMZUfrS7aLrHS0ZWIJBjSaJfwUMe6A== 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=9Yyqj/0ldTtYZEIVR+oRp/9wA2PcIxoJtU+g0QhTT84=; b=DTnUxha8amYH4Dcr1DUqL9fJovLnrL9Tb89Wn0AMC8JusoZh3C9OkHweBWnLvjJhrb4O4ker1kzAEsVFgBIK8I7FY/9XCfY1hF5b+bgV4saJtGewLkxC3M1GHbYRIi83SBjWt1cb8lIdJUZEEotADDMu2R0MQUqsjwhX2AVStF3ftQrwFPUXHgyvH8tlIj1UGQ0wSugYZXe7WBBM/4iKxyuvwytYMx/bZTOH/lghQ4AXxA3PFu0cs1EnX9kx2Zxay2HvHMFq4Wh/YgcrDHg+czHMDp5YMiOtPADWXh6XRAMQcaFcA6+Vsupyl9v6s+ONJvP5gMAluDAh6NZZbph8+w== 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 GVXPR04MB11042.eurprd04.prod.outlook.com (2603:10a6:150:21f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Wed, 11 Dec 2024 06:54:17 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.8251.008; Wed, 11 Dec 2024 06:54:17 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, frank.li@nxp.com, horms@kernel.org, idosch@idosch.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v7 net-next 4/4] net: enetc: add UDP segmentation offload support Date: Wed, 11 Dec 2024 14:37:52 +0800 Message-Id: <20241211063752.744975-5-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241211063752.744975-1-wei.fang@nxp.com> References: <20241211063752.744975-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR06CA0237.apcprd06.prod.outlook.com (2603:1096:4:ac::21) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|GVXPR04MB11042:EE_ X-MS-Office365-Filtering-Correlation-Id: 58837c78-a6c5-45d8-e59d-08dd19b0a19c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: Q6NP47CgnT+eBZMZeJfpOMJX7qJgXgb3iKb6jESr/SCRyjRiy01fK6XGNBWLvQZUe/QULAvXW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1riJMLAEQqYZ4N0Afoa5xEH34MpP1di6MRgOXhcjbxu3Hh5/7ccZMn3NCz0C/hPfST4vpwW1f4jwMyznx8+TCJlTv5OWDR7Q5dC2kiZTQVn8fdlxRUFLbucAKo0LQoOcIwv9w/VZ50gXe1x/3b0zwOA1JLOkr5+vx78SaExLgygwo41z7fBAmWpIwxxKy7cdCn2l7/AQdoKbuMF3XB4YSjhpoHb5mxkqkbFpB/Txkp5vaS+UPJhXzlKXFUT4Ag6WaJQRDpK1djgO9C6ttBIho= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1FxThlx1OvBrmlINU2o8whtvTWeM2y9GJ6bVnhqvx1dy85jZKREUQgptP/5gxxnD4GZkorFFKixo0MipbS12X+DacqBqzxEdZmCcZ14C6P4hlOVqyymVju3IhPX75Kz8rfBaBqrtUv9jDC3eTCLgPx2psmp6Wy9uEPRgIdIqfD8AoNAA/edxTO9Pg/4v9gJwN59IcB00qPcMS5XlZRIeLBUbMuYaAAWBh0P/nm1LAcWMIuVcdpVK1tgmWUpNQGVDJQLPdzj7lKEiJAwKQMwJLXIAaPWqHA/5rj2h9NLLbsyvbqXyyHtgOQJW/XQYJdeN+0i2ys5sHibQQc5+PqOoQD+EuHsUMcci+5ufhkAbxDQTuwnL51wMTkL7ffHiXV05wQYDppxKQVahmnJGLElyl3jv83yxkTbsTFIPSPBiVsZS2IhYTW4hlV0lq831q0qKmcATjP7whtKlKx4Fx0J5W5Jg2AixrCwoxIIeqd/mmFfb5tmVuJaxYzW1gtPo7HXhE+4RvfrpNcQsMB2yanxehucCXRfcd/BaIOxI1MuMXfP1zTy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Message-Id: 58837c78-a6c5-45d8-e59d-08dd19b0a19c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 06:54:17.5190 (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: a/fsPjHw4l26kgCSD5quXERmmKvmyNzjyZng+f9qHzW5Swipa63rSnxGPdZ11wm8EYqGcwdvH5lPFeNqxux7mA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB11042 X-Patchwork-Delegate: kuba@kernel.org Set NETIF_F_GSO_UDP_L4 bit of hw_features and features because i.MX95 enetc and LS1028A driver implements UDP segmentation. - i.MX95 ENETC supports UDP segmentation via LSO. - LS1028A ENETC supports UDP segmentation since the commit 3d5b459ba0e3 ("net: tso: add UDP segmentation support"). Signed-off-by: Wei Fang Reviewed-by: Frank Li --- v2: rephrase the commit message v3: no changes v4: fix typo in commit message v5 ~ v7: no changes --- drivers/net/ethernet/freescale/enetc/enetc_pf_common.c | 6 ++++-- drivers/net/ethernet/freescale/enetc/enetc_vf.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 31dedc665a16..3fd9b0727875 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -110,11 +110,13 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK | - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | + NETIF_F_GSO_UDP_L4; ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | + NETIF_F_GSO_UDP_L4; ndev->vlan_features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c index 63d78b2b8670..3768752b6008 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c @@ -145,11 +145,13 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev, ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | + NETIF_F_GSO_UDP_L4; ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | + NETIF_F_GSO_UDP_L4; ndev->vlan_features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6;