From patchwork Thu Nov 7 03:38:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13865780 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012009.outbound.protection.outlook.com [52.101.66.9]) (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 102EB80603 for ; Thu, 7 Nov 2024 03:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.9 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951639; cv=fail; b=BDKOYy7iDZqucUMl5G+ONe4iIl5OsiMjhm+KQMGzSSgsnFQ8jRGiYoxzY5ez3FEfv5VaAuWiqzVPdph8GDCzH2NpW+iW7aPx3Utyg3VmTGG5HY7x18MjZynn5Ahq0d5PEmidUqttuzk44OtcY6yyWH+9VUrCrP4lENhEtm+kFN4= 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.66.9 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> 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: imx@lists.linux.dev 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: RwTWv4D5LUYLh1VOCaYqDsNes8bIinYrOJfnOh2n/T6DA4GszLEvaWw9vdumol5VqLm7hksxUSM7fgiV+6Ey0SaL9OA6QpV1oiG7bTUXR6Db9yQ5Tgc+FHC8IOKUsuCZU4HMbnXoCXrJczj9pqiN1X+SpnrpaLaIca0X3j68+nt6RS4+OB8xcHjuMcFs5bLeVcOflXXzDyh6zfUst6V2o1cQglXVudO8MPHn3F6zvZ25XZ6fCcYzVsgB7zp2AnzoUuNiX2cGMGhSaQ6R0AnYwW8h4sxUumSXX9ioFGRGwoze+NzSdT9XVRWz8DmpFVHZZhaQS13UXizbPY7HTolQcfDSuqR+M8qbe2RVvgN6nvtL9zyivHQaBQnvf4aQNOHz3vSfdK3kFc96mAu+Gv01RnYK8HIq9y5hRPEhQ0PgJ84iR+DUBrP3eJ6+GFFfnlkVYxzYYsSI9Bwwz9xJC3tCjeEpqXdKRYnwh0eLYvv8bT8CglAdmc79phjfbuNGM1Km6VLLxc+FJLcF1uldthYtdSBDmsnNXeZ3WPb4RheIaS8kAh2APmy+Dc/oTjjtTG6NUX6eHcbaEYtw473KVZ++htBBpT594ot3HKluH/yEWb5pPNNAKMtmpn9mEmEUEEsnSJ3uc4HjooZek+HvkG/2XxZHtjPl4kkeqxBnrEj07zs8XJI15JB/DSOYCHjoIOp4NPZP42LfWIzjC0pb6BIomX/n6j6WE9cHKudR2kEyj/1I/L3iChKM2kVrm+jL1uOp5PS2QaZaxmsVDJzmSusClO5CIWEwun/uE0OiiQQyhOQmXYHAsqWkpYuq4vZ6jbHpwsoKsXhLn1OmdhbPAndGofU5s16xkrA8UWhnJtwKL4920w0ckTx6xO/G8upi1v+SBRHgBfK1ItKjfY9mSPf7Q4XESUR8e2/rcOw65HYiv5QpdmOsCG4gea43mOurcadv1oSPEQOp7xvMJZU2LfqPb70xtbOrzihf+AAg0wYkdwrsy/vSTj+BZ7F39GA5Ymjq037mrBXRL0ZjQrAlal6GfnG8oH0DRHJ76c1L9udr3FtcDVCm4DpiZanXahsDj7Cav7ZVBzhxPaq1aO2p7QBnuVEMdn3X/moJuZf/XfuPFfiy63Ud1ivyEsuZiDQDoFdeV7O15/shVym9UJriJcaZTVZ5M4ZC1950ybbZkETm8sZzmCDk6lGYRNRqNcr70Ot5rGUQaV0weZ7/aD27P4JDZcigK+6ly3U54IJDM/gwxst5HLUlwtNxBBK1OQamxSFGZJuzsZCfMbwWSI1MES8Kw8XcjlJrQlbAQvkKQeIDacJ0ouXA4PMU+9ZhXGXHhM3omsUy8IDhlmDKzTjvIv0iwhGiArWUN+dPqOUqTNcsm9g= 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: pbJp69iQsO6+Hpb9r88q+uJQaWZM/zC53TCxG4ADWO+ttyhElYUPeP18KSqNBeUUB6wt7L0a37iHRVPm1glakW7PymbJdXWrGJVIUzKoKMViKohwGsK6CdhYmWLScEmcroHPgEg2LNfuzKcTfXXQTy/z3oA/lHiXviUp1M7XXXnXY3Tr2jT4nt562fJ4c56p1bzi6Xa8+5rjXish7aWRCEZtcMlCzNXP09zoDr9e2QlWY7ErJzQnjNnG91MJ9CEjEIG3q6dTAjzOg2yshP1x560OQ0EhqF7+WMZ+IOOCbT9+c92A4zqsybujy2X2pTA5Ru49WltT3AyJlw30PiQhelRBBUF3edS3hDRjo1ZC28HwuCmpN33C3Zjvp9cB93/tDr64Bd6+ea59GMjmkkBO2Pi2jcWrI17iDzV1E7VsPEdaRMOvrL3CbyXKx0Dw20i4sysTnxUptTX4n5u0V5Le9H0ogf3CqKbkM19P1b4wnCBPZCInStlw8McF8DvT4u1JveuYOZi/5SZmfkimbnD9geeMJQ5frVcWIFEcpRx6meQUFOE0Xt6hnydRD4WJJJmVw/ZMKAV7h4HkC04PZvYEVYoPFWzQnBeaa8nH088Q+X2jike33/C3PXnrYV/3Q5Nu7TuqQD7Gn0+g297F59cjmuVHjBLSGhuBdvkuZCGCCk0evarIQ+TS0UPoaFHCDKopVUEsBTADshaItmtfLu8wyGMzC4ktt572lPVYE+/m3WJlpOQQNVZJdfA2U+Mwn0XWifhIutAKrPyYGHlBKpPar76vmbZjfeDEIKK3SjYkOrx0ASRmbKEcVrfUH1jERe/CeR6oMd+YyoRSAXKY/wrbHGt4S3BBe8mDj6BmISvwA3PQzHIrfdZzM4/mtc/1BHA/UpICqeZLmY+VGBV2KVpWnqQXHBVy/mzNyjsK0f24bbhHpZJ1td15Yg6P4t4LIHmKFqw8Q2k1r45wNSgpzXapnAVYGTJzEOHuRX2S/0ipNeKv6uI5XsUbv218MmLoJ+UaYX2PqPCitCayi7hqOx46cgvKhEnM0c+9TTLHyu+o9L7GAEfqw2kVNKmrWr1E+CCBsg0NwYO3s1EBxhY0+8RVfRBtzmnST1RREtqwW9sfubKoz0zb71P4wdR3XdN5LViNRy2TGiQWPJaBvyC29IIrf4QvsGqHJpRtHhi1KUfR8IZdlxS+zju0eyPyKLmPLJWg8rhwGyN1oJo/kjvZVmo/QGteXitHbtQbLmFwWymcCv1meQfGZxD/ULBh6c4CEggzzrbq01GzQucpuwVSleEEhXWKME9QQNLt2K7FQeeeG6mEGaWI77hqJaad7LAaUZVggar5DMSnnb2w67nFWZkGkoboqjsgLrE+zjKbcXQ2SSVY5ERBbHDAKnwBz51FFrdMOK6knIPxrqOiXQK/gDPU5Id8MndFGbh1thYGKIwUeZnYyIWewaPlCTgx++LVEevlm6UQhIbF+RSH+OkBDSgTQfCMlva+Bjv40RezCE6NJo3Wo+6uhC5H7QrfaA0mbEAJMI1gcobVAYu4Sc8eT4h/damBy3OCyp+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 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/ethernet/freescale/enetc/enetc.c index 35634c516e26..3137b6ee62d3 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1011,10 +1011,15 @@ static void enetc_get_offloads(struct enetc_bdr *rx_ring, /* TODO: hashing */ if (rx_ring->ndev->features & NETIF_F_RXCSUM) { - u16 inet_csum = le16_to_cpu(rxbd->r.inet_csum); - - skb->csum = csum_unfold((__force __sum16)~htons(inet_csum)); - skb->ip_summed = CHECKSUM_COMPLETE; + if (priv->active_offloads & ENETC_F_RXCSUM && + le16_to_cpu(rxbd->r.flags) & ENETC_RXBD_FLAG_L4_CSUM_OK) { + skb->ip_summed = CHECKSUM_UNNECESSARY; + } else { + u16 inet_csum = le16_to_cpu(rxbd->r.inet_csum); + + skb->csum = csum_unfold((__force __sum16)~htons(inet_csum)); + skb->ip_summed = CHECKSUM_COMPLETE; + } } if (le16_to_cpu(rxbd->r.flags) & ENETC_RXBD_FLAG_VLAN) { @@ -3281,6 +3286,7 @@ static const struct enetc_drvdata enetc_pf_data = { static const struct enetc_drvdata enetc4_pf_data = { .sysclk_freq = ENETC_CLK_333M, .pmac_offset = ENETC4_PMAC_OFFSET, + .rx_csum = 1, .eth_ops = &enetc4_pf_ethtool_ops, }; diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 72fa03dbc2dd..5b65f79e05be 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -234,6 +234,7 @@ enum enetc_errata { struct enetc_drvdata { u32 pmac_offset; /* Only valid for PSI which supports 802.1Qbu */ + u8 rx_csum:1; u64 sysclk_freq; const struct ethtool_ops *eth_ops; }; @@ -341,6 +342,7 @@ enum enetc_active_offloads { ENETC_F_QBV = BIT(9), ENETC_F_QCI = BIT(10), ENETC_F_QBU = BIT(11), + ENETC_F_RXCSUM = BIT(12), }; enum enetc_flags_bit { diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 7c3285584f8a..4b8fd1879005 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -645,6 +645,8 @@ union enetc_rx_bd { #define ENETC_RXBD_LSTATUS(flags) ((flags) << 16) #define ENETC_RXBD_FLAG_VLAN BIT(9) #define ENETC_RXBD_FLAG_TSTMP BIT(10) +/* UDP and TCP checksum offload, for ENETC 4.1 and later */ +#define ENETC_RXBD_FLAG_L4_CSUM_OK BIT(12) #define ENETC_RXBD_FLAG_TPID GENMASK(1, 0) #define ENETC_MAC_ADDR_FILT_CNT 8 /* # of supported entries per port */ diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 0eecfc833164..91e79582a541 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -119,6 +119,9 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, ndev->priv_flags |= IFF_UNICAST_FLT; + if (si->drvdata->rx_csum) + priv->active_offloads |= ENETC_F_RXCSUM; + /* TODO: currently, i.MX95 ENETC driver does not support advanced features */ if (!is_enetc_rev1(si)) { ndev->hw_features &= ~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK); From patchwork Thu Nov 7 03:38:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13865781 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011019.outbound.protection.outlook.com [52.101.65.19]) (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 0C3F71917FE for ; Thu, 7 Nov 2024 03:54:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.19 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951644; cv=fail; b=RZNAczVQkZqPdxOtvLE3p5Fqzffw/cYCHYfltHt8ORujbfqjlcD5hbFMUWCoJAyx24CSR6QNlgLn4qm2es/uuZIx7T1qEvzCCbSWKafZZR0hAMG42FamnUxq4Xl+ihx1dDf6G3di1YYUJkPCs6AfTFNYuBRpRDfbGvrqfrfchnM= 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.19 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> 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: imx@lists.linux.dev 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: EMg5W4n17W3MYHqkcyYb8ZreyEHJCGdGS2IZKTk2V+1jgRxWZYr9QJ5c46NEeELzDoufcdSa5+Ixow5lKiCJPEmalazOl3dQ15wqliNlmxQ1d3qi9fw1jI2gHnrMz2s6usNPMpDxue+qThWjvs6i0jzuhQx0IxjTRlkgWhlu9Y8UG5Rv1gYlD7Sy9cbIB7EVOH4iyYWygHE6CLvxCKr92g5hM3V56xWJ3q3lF+k3mhf/s4XyGZ1W8erADorcAuNhY8YdjpKRRnJ7U2uHTzFe/YOFxqYZodSSPrVtVT+o7xpm6UfuPkFTOOPecInGq/4pFiS/FrtVE5Mp0oGpJe/qv+Dp5jcc9LIHoSNrnMp40nbAzdWXEJ6w/fcbR7HLKZTfK7EPedQIxhO5PjnTR3Aj9jK12GqBZDZjCfK96f04aitU/jQg76VTrIkmLypYiU2dbuPSiUDMRuPN4mN6f9L/rRt5ABuJHItJFJ4WCzNINDNKepU7udHpyyJvfE541EgCnvXgFA2qJUkjXBTob4XecbDd1ycoPGR+QhkU0J+iLmvrWXV4gFOJevKu8Fb+G4ZoXvXiTwTF4heu9tHWLVKbxRJGsytjXHORfyQmdkNzDJm5rbRmpvsNcGSIGb6WnXyvNRRcUpsDhELSvlcoc5y17abgqLLaJK7zDRYuynVDvMIJWkpRlkMVp2ehp0MR2xYZqADr2I9Chh52dhy7IoCS1btQVSrnCWmLrR5ZBGVuHqm0FVDxQuRc4JxMJL2O50y1Km2wVDJkdun+WOe9aA2HCrNeO5y6ntY/e/SeV5MUVMFE4Gsv+e7qZL83gdXon2z2QUCGyauqe92VkFIfGmF/th0EELwZwQVX9vP5AbxuQrCSLvgJhif6j8pK3iMKCXWz+7CPGnX5j7TA27tSj50ikbE7aTnxBEn15z9vFxK+l9fbqc2mgYmspynwoi+AGNzuiVGeaFX1KZPYZzIyvsuzqFI9gXqFvcA6cGEc5xsXirCOMaWvbXu1amYEIlS4C5aM3PVw0QWjaUu/r+OyoYsTr5VBNOjLySDp5VBNosYKn/T5TmdY3KLNpNz8wDZjA5u7XTuoxxJQbMh1z5wrKyMt85OnsGTl+1iD46yvwTqBMKAh1A/IBy6/UaDhfO8HoOPqDtUUAlNexHNe4YbvfK2C7lKRUWCoPlLURx0D+3kKRmgcHzG7MoWBhzHmqNwCr4+0TN8X33gNquAWwl4Ap0oKt3EQdlWYx7ru3YvBb6ZmoXaTF5EDdZYNbQOOa3JcdFzfRBFWtouIXbqfP7nMhFa8UFFbIYbH6HW9dOvoFbRa/MGceGPwPOZDHf5LT8JmTYh1talmt6EeHdc9KO9518dqAjjwwQIdJzx9NT+JFczpcUs= 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: sPDi/3elVKBMM4xIh80E/4d8RkEnjsOwHlaHj9DMT1+7FBwB4GEgcaJkHoCio5+EBPf0b9RrAqfjhe8gsuQIDDeOEYLOs5LUriKNfVR3pOOb96YWSsftdIrpDb+BjaD/zXTMBFjDJwdAt3uN2/+fhlJFLyD54urF8rJDUI6obBJ2pGdeDtUVAJHYKVsK6JtaYxmeynStP1I1ZvFkzzehuMlyaD5GoxJpiB9PG6bVH1UNIAr9GQVhQSxZ6mAE5ePuMJpx0EguFalDsY/hIn+XkrcK20AvZWJn3MyGp4utPalbvT5e1ckxXALZ5PjPbP0bSyJzs5YGMH0bwZWpCaa5dxlOOV8Bc19HluTA6cEWHH9vDces5T7QA39o8d6+yP1Tqt2F9fNv+hjhm9AmjIDfTwNnmmYysW8INtkVQXdJ/pYNy/c2ykQJ4BCmxQBdHD4a4tUenEJ3NGHbpzrXSEge++ubNPWmMGJXmkyTiMQ7n1itATbWS/olBxw+6Gm0q9ZEvU0oT1n0Qq/vngMHiZwwh6cHsx+447cndcf5WMd6JFwzzhIYOir2/9dYl1ActdS/1fvPRMUmIcFRnFFwygu2E6vHSDJ25Jlh0z5WGpBJR4oJn7T10p7/rvhDNsLxpQADXcywy05n0KdFj0qwHHWcXadOfR/87eQzhemAGhdGkzQzoR55V7rOvLUXfsZZe/bIRolCjiG907HIrOazwTOtjezGg+Owo90YreVxy6eK4CvT5eh/394EsVUWRFUbs3mUBBJRorsuMPKA0t2vYyHy4+/1amrGPBtou9JM58b4OevCcNoKo+MMYpapYgfgc69336285CO+1BlUKLrff1hui9t0GmqpGuWzQ4TEm7wNfvIvwJ0uceNAI+jOyjHMIpCalYwFcgMOnetfNkqFL0eUV+SyCSvPThwm7q1Cdqp3MJ80uz5KRLWPDqnJYI9WZ1CBc8bvVHIsfhwo2LKYLRY7su+ro26d5x0xHMMsbIvHTywz+9dB7mRr1sR123Mjovdcf7yaK2ppjLWBmSoIbcsU5sL2hZux++6paRF2v3rBKsp8OAd06W1H1wO4kguLCGqwPe92OoIs5p7AjZ4k1abqQI6+a/1wqrwK3Gmwswjx/jp70XlpeT5kR5QaoZKDnDjfcwCpKy6ZxXaQJNESTj0KFnfun8VjZbighKLLMKS6xe1Gos1rrYY40WkbHt0uybB4yJ6BwAABHwGbBdz+6o4a2UpIXuSuwqxJpXj0tM87K+pivsrA8Id9CkqfUGZgBkD6wtJy/SfKd4yCbHoWW2iwG2JEc5M/kdBVUYQ3f92eps4KAc9evLgbwNSHTJbGpUb3jAxdKE1mdf4TdE11y+JRCvBBrLpCfYpRT4vGIABrnVMiJvQSP8yieHNYUJL+FNPdfwLR6MsCRHdev5lXP8X6JRU90EaNKoFdCCZSIrjgAzj5RatTEVyIBblqGp0PTJ/uGIo2eDLJ0n6NrguHyBgTfUThlqmU8h0pB5yT+Tfa2OW05Rbbhz+sTywI8lXqJpijECytVC1cOnMMZqXt6MK2vxOGfjjltBGAasei/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 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/ethernet/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 *udp, return 0; } +static bool enetc_tx_csum_offload_check(struct sk_buff *skb) +{ + if (ip_hdr(skb)->version == 4) + return ip_hdr(skb)->protocol == IPPROTO_TCP || + ip_hdr(skb)->protocol == IPPROTO_UDP; + else if (ip_hdr(skb)->version == 6) + return ipv6_hdr(skb)->nexthdr == NEXTHDR_TCP || + ipv6_hdr(skb)->nexthdr == NEXTHDR_UDP; + else + return false; +} + +static bool enetc_skb_is_tcp(struct sk_buff *skb) +{ + if (ip_hdr(skb)->version == 4) + return ip_hdr(skb)->protocol == IPPROTO_TCP; + else + return ipv6_hdr(skb)->nexthdr == NEXTHDR_TCP; +} + static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) { bool do_vlan, do_onestep_tstamp = false, do_twostep_tstamp = false; @@ -160,6 +180,29 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) dma_addr_t dma; u8 flags = 0; + enetc_clear_tx_bd(&temp_bd); + if (skb->ip_summed == CHECKSUM_PARTIAL) { + /* Can not support TSD and checksum offload at the same time */ + if (priv->active_offloads & ENETC_F_TXCSUM && + enetc_tx_csum_offload_check(skb) && !tx_ring->tsd_enable) { + bool is_ipv6 = ip_hdr(skb)->version == 6; + bool is_tcp = enetc_skb_is_tcp(skb); + + temp_bd.l3_start = skb_network_offset(skb); + temp_bd.ipcs = is_ipv6 ? 0 : 1; + temp_bd.l3_hdr_size = skb_network_header_len(skb) / 4; + temp_bd.l3t = is_ipv6 ? 1 : 0; + temp_bd.l4t = is_tcp ? ENETC_TXBD_L4T_TCP : ENETC_TXBD_L4T_UDP; + flags |= ENETC_TXBD_FLAGS_CSUM_LSO | ENETC_TXBD_FLAGS_L4CS; + } else { + if (skb_checksum_help(skb)) { + dev_err(tx_ring->dev, "skb_checksum_help() error\n"); + + return 0; + } + } + } + i = tx_ring->next_to_use; txbd = ENETC_TXBD(*tx_ring, i); prefetchw(txbd); @@ -170,7 +213,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 +633,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 +666,6 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb, return NETDEV_TX_BUSY; } - if (skb->ip_summed == CHECKSUM_PARTIAL) { - err = skb_checksum_help(skb); - if (err) - goto drop_packet_err; - } enetc_lock_mdio(); count = enetc_map_tx_buffs(tx_ring, skb); enetc_unlock_mdio(); @@ -3287,6 +3324,7 @@ static const struct enetc_drvdata enetc4_pf_data = { .sysclk_freq = ENETC_CLK_333M, .pmac_offset = ENETC4_PMAC_OFFSET, .rx_csum = 1, + .tx_csum = 1, .eth_ops = &enetc4_pf_ethtool_ops, }; diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 5b65f79e05be..ee11ff97e9ed 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -235,6 +235,7 @@ enum enetc_errata { struct enetc_drvdata { u32 pmac_offset; /* Only valid for PSI which supports 802.1Qbu */ u8 rx_csum:1; + u8 tx_csum:1; u64 sysclk_freq; const struct ethtool_ops *eth_ops; }; @@ -343,6 +344,7 @@ enum enetc_active_offloads { ENETC_F_QCI = BIT(10), ENETC_F_QBU = BIT(11), ENETC_F_RXCSUM = BIT(12), + ENETC_F_TXCSUM = BIT(13), }; enum enetc_flags_bit { diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 4b8fd1879005..590b1412fadf 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -558,7 +558,12 @@ union enetc_tx_bd { __le16 frm_len; union { struct { - u8 reserved[3]; + u8 l3_start:7; + u8 ipcs:1; + u8 l3_hdr_size:7; + u8 l3t:1; + u8 resv:5; + u8 l4t:3; u8 flags; }; /* default layout */ __le32 txstart; @@ -582,10 +587,10 @@ union enetc_tx_bd { }; enum enetc_txbd_flags { - ENETC_TXBD_FLAGS_RES0 = BIT(0), /* reserved */ + ENETC_TXBD_FLAGS_L4CS = BIT(0), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TSE = BIT(1), ENETC_TXBD_FLAGS_W = BIT(2), - ENETC_TXBD_FLAGS_RES3 = BIT(3), /* reserved */ + ENETC_TXBD_FLAGS_CSUM_LSO = BIT(3), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TXSTART = BIT(4), ENETC_TXBD_FLAGS_EX = BIT(6), ENETC_TXBD_FLAGS_F = BIT(7) @@ -594,6 +599,9 @@ enum enetc_txbd_flags { #define ENETC_TXBD_TXSTART_MASK GENMASK(24, 0) #define ENETC_TXBD_FLAGS_OFFSET 24 +#define ENETC_TXBD_L4T_UDP BIT(0) +#define ENETC_TXBD_L4T_TCP BIT(1) + static inline __le32 enetc_txbd_set_tx_start(u64 tx_start, u8 flags) { u32 temp; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 91e79582a541..3a8a5b6d8c26 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -122,6 +122,9 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, if (si->drvdata->rx_csum) priv->active_offloads |= ENETC_F_RXCSUM; + if (si->drvdata->tx_csum) + priv->active_offloads |= ENETC_F_TXCSUM; + /* TODO: currently, i.MX95 ENETC driver does not support advanced features */ if (!is_enetc_rev1(si)) { ndev->hw_features &= ~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK); From patchwork Thu Nov 7 03:38:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13865782 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011011.outbound.protection.outlook.com [52.101.65.11]) (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 6756518A943 for ; Thu, 7 Nov 2024 03:54:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951648; cv=fail; b=fOKpm+qKQ4Ufb8IVUWYlyhp4SSeH34t0EzWPPiCPZceoEkFpfShYaOxo+zyg/IUHl3O7S3Wsh69rd2n43A0eHLgOGPqTScBlDCCZrsMSs8aGAH5wyt46FtlEVudx0WgJwTddlFKBj1iGhjuvOK3ck7kxTTWN0qG07+wrjUEigFQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951648; c=relaxed/simple; bh=kWdRpoAXi4NBpxy49iB4UBzELwcCJ584DBJ2JoSTvow=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=dozV4WkOkp9ffYwIve9UmACiE1N6D1VYsTlQGiQLtOSS8jAu+uZs2tPNwiHdv6ysgYEB1C6ib1y68M/zSX04xiTdw8vQIYOboHECs6BOodlMbIrB6kexfSoOrhDAU3qTp98yagWA2BJGZ4r3sTBcRnpnTNhBEJLUr2/uBsbVm6Q= 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.65.11 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> 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: imx@lists.linux.dev 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: id7Aj7gDknZNh3+soSevB6gJgvAIBpHcKXf8Um7120mK17b3X4ylNo/dYC3zx3/mwKZq0+tnisLT+YdhgMqu7JCy4yyViPQRK0czuJg7x4fkAY5eKBQ8SVoF+SKYGFfW44lipBRUw2Dv63+YhBQC+ShdK9+30yvDK0tP9nC3X4NaVxPAv9vCk9ncRVKhxBH/vnmbNBSptJCqivb/7KSgHASjOaschlnuETFBm766VqAzAgXkiqVrMpTNbzjD/FiO0azdUGaBfMwpOjXHDIB9vrtOPVNOpxqaJfoPpDni9SB7g4ANYKIVTfJNy9ZAiBVxxeQpKbGYMvsZfi7usRtGcN7I3qrqmpm4Mm+pzod2/nj0U44x2ExcdWzGTCJ5JDUHSRYX4Y6EguMXsrpXEXv664nsC4lGpQu2YnvQ4Ax0ins0DKmi2Bobq1GFCfbPOsM4A214k3kZ+X+R9Silaohtc2uEUvqimgawtqSKeVR1zq/R7DxURgVG6cYDd2gN4NdoCfZwuTczO/SzBfp0qRIW5xeBUZnKaHVeQcsZpyRUG48+Sg9DHlBaj+AduANT02G5vzGjtLt+CDXHf+3tFNF+FgbOvQ+/GaH4cnrpxplpDFueb/Uj0MP9afLAf73Mp+QdrOQpXULuy3Xm6A98v1TGF017XBrfR7gjA1UL1G6i5g4ioQTeoplbvzm5vi+HQU13IfBkzEechs41Z9XyWvHBCXbpPGyUHQKIl+oRut5MXNlfQ/2Y9YGX3hwH/RZGLeWbM4Rnt/jIKuEph81fUeZj29y5Qo5FdVp/zwn+RYBv8CFwBvVxGSIWdjcbvxdNjlZHto9TryDbgORkz3bO5Z6fJvkfn4Rk0FEC4RmnXMsFX4kEldUcO+EAnw1PrvVGcp3pW8XI/IFImqQ4n0zoyI7z9+0j6FyMI01ZX3oVrmA5UFu61w8JEnWxgGisgyZo0fBCVZzoa6+ckXnRDiYo9jO4upvdsC7DqiE8HJ1oWjmGFMColTLRYnSXyeZHCrH1e33kxIHuUQdRp4vGPbqQtWgnUaKK/qKme+JtGjqKAA4H9w6snyzde4JztV5jan1JJ50eR39bPt1yU4WMkXKNGTPjgGcy0i/HATa47Mv4K1zFXOiGMEsjLeXfRgYXdOBa4lt3TtHkROBliPyYST5DR/dcmHBqyVcMM9MGPI2VL1+LnwP+rRLZtglMHswWXr3+k+ZDqPu+Ddx44KK3tM1x5X0gKTDhWrBHxvMl753QyP+sABE4CRp0OB2HbXp+8fdanMdjztsCdQ9nlFdQ3BzFZMMukPWwYqFhsL3ZLM0T5M3s0v8B4gzqewYXwzM/R0Q9cYkZRJnyKSTQIi6XbTNDec0qYD5AYE+F4MXIcSP9dwaE9Tc= 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: Y37c/yJyjWD3t+yzaS+gTfreYIRqAAJWGYaWgraP1d1rRPA+LyrFm20k9SRxgCY+yAz4eQgPHwWuscQl36x7U3fVg2falgCSRy0flgdPJ8iHcG+gr6nV+Kb05OST31zHU64Hy8pzPJFmdMdYysA5WSjDUJh1Nrq2vV+C1p0AxwE//4DApI5fpCXqVAzQ6F3qG7rxl74jVwjNbNJo/v5qrdR90aFvQMT4YbVixNdPMZ0FT7T6e0eFVdWvuZWrh4codU28P22JPY2IykUnktEnthioF8shWi5qAY8pVIKs3i86wyQ93jrTsNONF+GrIQwem9wocAepiRSO3RGro3KvgrT8O1bvlBXrFzFHMSS71PiFmLkHtdY9LoFa09+RXS/JIii0Zsxx+CODwYzLAQ+G/1zUxu3MJUOqgBjGLf7XJBpVjciUhoOgXgWxCpHFnuj3WJJ5dw92P+aRYnh/bTz3vdYya1FYzFCt93tNGqGzL0jNs2xdHvRxxxNsj03wVAd20hJWEgWJpQxLg0Gvf8NFhLqyvpMCMz9J92SIlbVrWYbPlLirrHW4+7/4C8VJmazalJAoZnKWERxuJvYPhEAv+sPVeg7jU/B6SQRS1bHhOq5kYoUgKi/vgiYUplMrnEt0iCE3Ddj890+oRO5LxfZFDwLDrlIpYKOYlka7r4x3ce255TNXq7l2toqmtHo4eF/14UGH82QmLPSGXOd3SRTyPgWBFdlUi3obpHWhUDpxWTdwmtCw4bPXrn2FO1BPCQH3QFf2jC7baw/9d9WGE73VB/nzvpIyagHfH9AC20pTU6xR9RiQU8oPlEtFKlFTXu6nF9BsvsoereJQZ4rDlHavgeAg/kGhye+Bf5Ha/29g0ibjXKWqyouXUE4Po8vTR3cK+Y7dtcbySZDg1QiL8IH7xG42Rrm0AX60ERXUzGeScj0DOQFNudE5OEWAiXS9TJEEAhysB1mhQeKBMgBPjywLa+P49YIPBHOw7skMoI1llXUq9KE9m83mOY35rq7+Alhwitgn3m8iPS5U4OeIqrTukzyEQ7PFgtmoVhWDFNFwrFlHHgL6EFzR2WGDL3x31Wn+Kh29DqOpJBwjZihG4T9Mgyht2kEHV6wedx+5S5s2VSQ4EVBfR6jAWNAT2PBXR9fs+hmSmj0EzhvDTl8rm8z8RRl2AVQhFeyIfdbIM15xbE4DWuXux++PB2wNBBx3LOLZ2ZCQ30TYMcqXkZJydRJkzelNQbeQKii0Wez+c+RDCdgrFaeuqVqBsSEbBFPktJDodTd0gegqcsIEwMVAjnpeCpII8Obhc7Ok70JJH6626c59kyX+AOhWUPr5dngHwKEqMfZObPeYkckJ3GxteM9KIRFfY8a3CNjiLvwGcz6TiKsIkTJSSuDq6Yx9Z4J0rkgOEdCP9WkuxWmMaXBX5J9t/GtQM3YjjubH8H7dNzqw22FY9u1fo+M8v1qO8ds+eA17TadM9tLpWQ0+HsVH/5I+wvN8SbBTocjinSSd64Xmj18kss1fOeHe3EG8JrPoMeo99mdC66Y75XFFl7gES9mu4Fp9V7EvSMX3EpU/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 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/ethernet/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 *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; @@ -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); - 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; } @@ -656,7 +657,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; @@ -674,7 +675,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; @@ -942,7 +943,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); } @@ -3317,6 +3319,7 @@ EXPORT_SYMBOL_GPL(enetc_pci_remove); static const struct enetc_drvdata enetc_pf_data = { .sysclk_freq = ENETC_CLK_400M, .pmac_offset = ENETC_PMAC_OFFSET, + .max_frags = ENETC_MAX_SKB_FRAGS, .eth_ops = &enetc_pf_ethtool_ops, }; @@ -3325,11 +3328,13 @@ static const struct enetc_drvdata enetc4_pf_data = { .pmac_offset = ENETC4_PMAC_OFFSET, .rx_csum = 1, .tx_csum = 1, + .max_frags = ENETC4_MAX_SKB_FRAGS, .eth_ops = &enetc4_pf_ethtool_ops, }; static const struct enetc_drvdata enetc_vf_data = { .sysclk_freq = ENETC_CLK_400M, + .max_frags = ENETC_MAX_SKB_FRAGS, .eth_ops = &enetc_vf_ethtool_ops, }; diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index ee11ff97e9ed..a78af4f624e0 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -59,9 +59,16 @@ struct enetc_rx_swbd { /* ENETC overhead: optional extension BD + 1 BD gap */ #define ENETC_TXBDS_NEEDED(val) ((val) + 2) -/* max # of chained Tx BDs is 15, including head and extension BD */ +/* For LS1028A, max # of chained Tx BDs is 15, including head and + * extension BD. + */ #define ENETC_MAX_SKB_FRAGS 13 -#define ENETC_TXBDS_MAX_NEEDED ENETC_TXBDS_NEEDED(ENETC_MAX_SKB_FRAGS + 1) +/* For ENETC v4 and later versions, max # of chained Tx BDs is 63, + * including head and extension BD, but the range of MAX_SKB_FRAGS + * is 17 ~ 45, so set ENETC4_MAX_SKB_FRAGS to MAX_SKB_FRAGS. + */ +#define ENETC4_MAX_SKB_FRAGS MAX_SKB_FRAGS +#define ENETC_TXBDS_MAX_NEEDED(x) ENETC_TXBDS_NEEDED((x) + 1) struct enetc_ring_stats { unsigned int packets; @@ -236,6 +243,7 @@ struct enetc_drvdata { u32 pmac_offset; /* Only valid for PSI which supports 802.1Qbu */ u8 rx_csum:1; u8 tx_csum:1; + u8 max_frags; u64 sysclk_freq; const struct ethtool_ops *eth_ops; }; @@ -379,6 +387,7 @@ struct enetc_ndev_priv { u16 msg_enable; u8 preemptible_tcs; + u8 max_frags; /* The maximum number of BDs for fragments */ enum enetc_active_offloads active_offloads; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 3a8a5b6d8c26..2c4c6af672e7 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -101,6 +101,7 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, priv->msg_enable = (NETIF_MSG_WOL << 1) - 1; priv->sysclk_freq = si->drvdata->sysclk_freq; + priv->max_frags = si->drvdata->max_frags; ndev->netdev_ops = ndev_ops; enetc_set_ethtool_ops(ndev); ndev->watchdog_timeo = 5 * HZ; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c index 31e630638090..052833acd220 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c @@ -129,6 +129,7 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev, priv->msg_enable = (NETIF_MSG_IFUP << 1) - 1; priv->sysclk_freq = si->drvdata->sysclk_freq; + priv->max_frags = si->drvdata->max_frags; ndev->netdev_ops = ndev_ops; enetc_set_ethtool_ops(ndev); ndev->watchdog_timeo = 5 * HZ; From patchwork Thu Nov 7 03:38:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13865783 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011021.outbound.protection.outlook.com [52.101.65.21]) (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 8A2F9192D86 for ; Thu, 7 Nov 2024 03:54:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.21 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951655; cv=fail; b=ZbsX9/9NDsqMC17oYuyo1PntMrkj6bSVA3h2oatJCRifvYx+CgAIt7lMAZqNsU1nrEOwpwbIfVkSqIXOmmWFePXviWY6vAmHuN5XeSJ1MFxfmQuM1/5Es7EMVpfqFtMgVsyJcoND4/g7Oq9TLla4oF8pIk2LlXHmk/9zOI6YNMg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951655; c=relaxed/simple; bh=y+BEGu2YGicLDAipuoNxOj0MWZqljmS4svUgFCbPOMo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=mLAZXFoW8H+ELLFjjGKrr70QrMwJBptnTmHsPFdm5txIS0o6hBUn+XbzfhbqEL3VhC0PcZcoVoTuspggTmORxUMymkSU45U72YnSY/YuRWwE2pE/ijEKnJIYVOCSLpaSR9Pti0CnyysxYS9tnok5q7hxecuyqbTnrfBfBCMJh7g= 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.21 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> 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: imx@lists.linux.dev 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: NEKQmtIDFXIFDOtjpu/NTzQ3gWv4JuDbxI52HCbBv2nVNUBcDad0z/onXmVF+8P6wqftP0YZ97xDzyEgTN0Cdpg/QuZh7lGTfRC59zhx1S5HFyBpx6+zWS/S7gHC/XyfHPrY3L9gGQ4it5HwKHEzFulsQ0g1kw9ot+PMhDqbq+2Yh74wml+dQv6D5heN1RcMErJ2iWPgQLv5nvpFV04qjSN7fsUo4eilEQFyQ0MV8NUmSzsG/qsSBBXmgODmbXrDnp7cqpx+cRVdIntx4WhldosrQOuPG7xV0A9FfZf6sSsZXyY2fHqNR9HtK0NPTrgf7NxydFmUkV2QPISwhbLNNVFKNspOAr/2tC3C0oe4s7ufZ2+G7uC2PmP1x3J8CtJ1J2+5kC8njTCKxXOH9rieMHRzDdBI5yLa6Wg9KzTx9RPXEnb9i3PGewckZJXbQy7CMv7c7jlht40WDZ8sspnuij5Ms7Um4WezA9Y5PVAEpobmfZ0AZKaG678wB77otxU/TwQ23xi4OgJWqETtlYuG6XTiirSJNyCCxf/DOGwgNcOfnlVvAOSMbY5wKn7d6DE8xsrT2gZd/jwrC+h+NscrJ78uoa92pwKQoYsn7T/8MO3hzDOMhCWAxoD86jox9ea5hPpk37slLTEORpFduv8EwNy99SzJzhJhkI6IaBSeQePd1pIp9c5OJxORw8xlJ6V2oY/j1qHXl6eWsLaslsXFN7n7yuQzWy6EbvOjqN0PnLKmgyBjIfy+9DsNaPouL1ucRhiLAElZH+J5uv2+3ts+yosL2M3jecEQ7wKOxRAR0V7edfxxrrMCs+UIPTWVzBHQWR91uZFs/KQjGYHLEmIW3AJTILaHI41E1gM/NjW+yQfGah3gKvUGboCUy9Zn97OouF5NxHGwcn3qpr9ZJZkUodMr9wTvd1dHnPcQzEnon/IHQ82pHQeUnpUU7ykjBlVHmRyH/eqOe6/1ZeFOqmo/f6q/Mrsm8J0rYGAwCliBBJwKkXPd6+hoSraOQCSUt+OYGW7puNEOByWInkC1xluWAn86FZ1+t3F/zHNgJ1jbu+sVJVfMDdafe4VzmQ7H7Yvv4D3xDbQXlHb97IAJl3DJ6RIItjT7EGADO19Xx6yzwZL02U+nPmiCnIaQjwWkDgJp7UqTwSg/Zy1C4e6H3Jb8aSNymhb5LtReMJB3WEtN5bp+/VqeXP6Zud6w/teJY6tmlQB1OkWriVAeeFSD3jbYz493pdyC76k4PgCzUBJa3wn1hnh5bJwQFt5nE4O+mEudmebBG4u+yEANRZTeJRdi8fkfpFBiiuMzShio0olMNe8f5AGBOQM65Ia/K8oDjau5A1b/sMkZUy5l207fgEDba7tivUa0glf5JNrQegvsCZE= 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: 9AnlEUaO9gH+Qd40pPVuKQDNRNzmJTs6GFyrMPJUfxp/zF9x0zfJjhFsn9IrH91mG391E6MHgjNjvZNPcN/CHT+FvsTXkCsoEfp/eIst5hiZDSG36ME4Chf0Bnga42dsfIheu3ngwmvj4XBn8DDhNEjUAx6LuU5dHDh1YbGV9/XbJ3ykUa+TJ8xGApchz436pJIjEsDp+WsGhl2lBDeA8WbkR/wOKEJajKSdphXeAG0GgCfLm3tVJejtXw3InocWlHMjrqYf4vjyTrxpvp8LLZBcuAqmIzgEjpvYEhbcBoQllcllbbq2MOrjluBH4tUkU5E9pEB8Nd2VJ7T+Tf4vUOWsisWsRZB8c+370RE5BVtrjFMGqLelptWRkFsoP4IxWk+VD37irfRPXLZhvb0T0EJH5AL9y4eLWjG+gN2N/+z2F+tPD5h2T38zvovY8S5rc8PCM4Vug3n271crtwosaqnripHqYaCF4cS51a7/aEvRvN+xYSeZ9VAwhBFwOVSGeSLgyJM60HXzfc5j68EV9sE6Vj73FnN0RYQq7VLSt/NiZCGTdVkjuCDFhvwFi99V553m/dWQQl1zRPL2faGVHEMKuxUDrk/JTE0vG1vyg/E5lMja5Zy5SJfsXqW/cF2PVIL9B/GEmpjUZCZoAszmY6/KHBOIDvO4zdkywitXXBBa7NQgDgMrAfE6fIXZEZk/xiwtChVTVEVhAvHgni4MZRPqYUb3t0Hg2rXn03j9Ct8tLVnOiJ0M6RGiQsY7j9tzwcVmdYInjG4ApQpPSb8rLVBbCY3gzDCCEeKk+y/9s7runoMPH8aHKIV8DVA+2D2eo/55dk7F3LZAOhGuI3rr/DMD0LwVt/5RTTmNplwYalY2EnFFeX5lbbampzwICprIJWVF/VYPcVFTt3fZ4/apkoN/zS6bZdU3FEdPqZ4pQF8K8OTnwvLmsKyH1UbCDyBlgg59QvlN6iBKuO6XojXAfGLhwjHVH6KNkdF/kT0AAclmoSGa3KLt0EtKvWa053ybb5hWVoyQrt7MuotvNoDZFPCHwYQNwixpuYmHCgrVo/9MV/9qCKUKrrDKM6fxKroOvQRE1RXwb8eci04VOZdEt7+SDWuu186u/atOkUL73HzUVTp54+ELCWCqnqkoblh5kR3IjsiZVyl9vLRuV9UDe5Ckqq1+aAxariRtEvKIaWIQMJ0fLX30ImRTmzPhE812gyX4pe8W5CA379379Ydha0adskpLAKJhUQPTlvUD7BCaqsGZf6aMlNC6/UzMWFVbAtGsQQyryRIxI/Kp3Aa5yLT0XfRWKbYAaC8iLzO8QqOSv245R3SfUrOv0gOGOuQmAFPiUSRCaN+k1RismuTZezIy7wP2jnf+4FDjLb75K4vubuVjZRaSpnYWhHv8lJwchUcql2AVr/TRbAYMTdpvzlGevVFDf5DZ74oofETqakV1J3jLMFBWNF74jMf14nE7bX5FagmB981VQDt0yAqfksa6dj1WRwImOZhWEoicJHOUzebSOP2T/eHkTmp5zKVvuEGnFQXmWv5Uujz47n0+++LYLkBI8GSwiBdz8YLiKyVDGnDnE24x4NwKgFNr6wa4 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 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/ethernet/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 } } +static inline int enetc_lso_count_descs(const struct sk_buff *skb) +{ + /* 4 BDs: 1 BD for LSO header + 1 BD for extended BD + 1 BD + * for linear area data but not include LSO header, namely + * skb_headlen(skb) - lso_hdr_len. And 1 BD for gap. + */ + return skb_shinfo(skb)->nr_frags + 4; +} + +static int enetc_lso_get_hdr_len(const struct sk_buff *skb) +{ + int hdr_len, tlen; + + tlen = skb_is_gso_tcp(skb) ? tcp_hdrlen(skb) : sizeof(struct udphdr); + hdr_len = skb_transport_offset(skb) + tlen; + + return hdr_len; +} + +static void enetc_lso_start(struct sk_buff *skb, struct enetc_lso_t *lso) +{ + lso->lso_seg_size = skb_shinfo(skb)->gso_size; + lso->ipv6 = vlan_get_protocol(skb) == htons(ETH_P_IPV6); + lso->tcp = skb_is_gso_tcp(skb); + lso->l3_hdr_len = skb_network_header_len(skb); + lso->l3_start = skb_network_offset(skb); + lso->hdr_len = enetc_lso_get_hdr_len(skb); + lso->total_len = skb->len - lso->hdr_len; +} + +static void enetc_lso_map_hdr(struct enetc_bdr *tx_ring, struct sk_buff *skb, + int *i, struct enetc_lso_t *lso) +{ + union enetc_tx_bd txbd_tmp, *txbd; + struct enetc_tx_swbd *tx_swbd; + u16 frm_len, frm_len_ext; + u8 flags, e_flags = 0; + dma_addr_t addr; + char *hdr; + + /* Get the fisrt BD of the LSO BDs chain */ + txbd = ENETC_TXBD(*tx_ring, *i); + tx_swbd = &tx_ring->tx_swbd[*i]; + prefetchw(txbd); + + /* Prepare LSO header: MAC + IP + TCP/UDP */ + hdr = tx_ring->tso_headers + *i * TSO_HEADER_SIZE; + memcpy(hdr, skb->data, lso->hdr_len); + addr = tx_ring->tso_headers_dma + *i * TSO_HEADER_SIZE; + + frm_len = lso->total_len & 0xffff; + frm_len_ext = (lso->total_len >> 16) & 0xf; + + /* Set the flags of the first BD */ + flags = ENETC_TXBD_FLAGS_EX | ENETC_TXBD_FLAGS_CSUM_LSO | + ENETC_TXBD_FLAGS_LSO | ENETC_TXBD_FLAGS_L4CS; + + enetc_clear_tx_bd(&txbd_tmp); + txbd_tmp.addr = cpu_to_le64(addr); + txbd_tmp.hdr_len = cpu_to_le16(lso->hdr_len); + + /* first BD needs frm_len and offload flags set */ + txbd_tmp.frm_len = cpu_to_le16(frm_len); + txbd_tmp.flags = flags; + + if (lso->tcp) + txbd_tmp.l4t = ENETC_TXBD_L4T_TCP; + else + txbd_tmp.l4t = ENETC_TXBD_L4T_UDP; + + if (lso->ipv6) + txbd_tmp.l3t = 1; + else + txbd_tmp.ipcs = 1; + + /* l3_hdr_size in 32-bits (4 bytes) */ + txbd_tmp.l3_hdr_size = lso->l3_hdr_len / 4; + txbd_tmp.l3_start = lso->l3_start; + + /* For the LSO header we do not set the dma address since + * we do not want it unmapped when we do cleanup. We still + * set len so that we count the bytes sent. + */ + tx_swbd->len = lso->hdr_len; + tx_swbd->do_twostep_tstamp = false; + tx_swbd->check_wb = false; + + /* Actually write the header in the BD */ + *txbd = txbd_tmp; + + /* Get the next BD, and the next BD is extended BD */ + enetc_bdr_idx_inc(tx_ring, i); + txbd = ENETC_TXBD(*tx_ring, *i); + tx_swbd = &tx_ring->tx_swbd[*i]; + prefetchw(txbd); + + enetc_clear_tx_bd(&txbd_tmp); + if (skb_vlan_tag_present(skb)) { + /* Setup the VLAN fields */ + txbd_tmp.ext.vid = cpu_to_le16(skb_vlan_tag_get(skb)); + txbd_tmp.ext.tpid = 0; /* < C-TAG */ + e_flags = ENETC_TXBD_E_FLAGS_VLAN_INS; + } + + /* Write the BD */ + txbd_tmp.ext.e_flags = e_flags; + txbd_tmp.ext.lso_sg_size = cpu_to_le16(lso->lso_seg_size); + txbd_tmp.ext.frm_len_ext = cpu_to_le16(frm_len_ext); + *txbd = txbd_tmp; +} + +static int enetc_lso_map_data(struct enetc_bdr *tx_ring, struct sk_buff *skb, + int *i, struct enetc_lso_t *lso, int *count) +{ + union enetc_tx_bd txbd_tmp, *txbd = NULL; + struct enetc_tx_swbd *tx_swbd; + skb_frag_t *frag; + dma_addr_t dma; + u8 flags = 0; + int len, f; + + len = skb_headlen(skb) - lso->hdr_len; + if (len > 0) { + dma = dma_map_single(tx_ring->dev, skb->data + lso->hdr_len, + len, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(tx_ring->dev, dma))) { + netdev_err(tx_ring->ndev, "DMA map error\n"); + goto dma_err; + } + + enetc_bdr_idx_inc(tx_ring, i); + txbd = ENETC_TXBD(*tx_ring, *i); + tx_swbd = &tx_ring->tx_swbd[*i]; + prefetchw(txbd); + *count += 1; + + enetc_clear_tx_bd(&txbd_tmp); + txbd_tmp.addr = cpu_to_le64(dma); + txbd_tmp.buf_len = cpu_to_le16(len); + + tx_swbd->dma = dma; + tx_swbd->len = len; + tx_swbd->is_dma_page = 0; + tx_swbd->dir = DMA_TO_DEVICE; + } + + frag = &skb_shinfo(skb)->frags[0]; + for (f = 0; f < skb_shinfo(skb)->nr_frags; f++, frag++) { + if (txbd) + *txbd = txbd_tmp; + + len = skb_frag_size(frag); + dma = skb_frag_dma_map(tx_ring->dev, frag, 0, len, + DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(tx_ring->dev, dma))) { + netdev_err(tx_ring->ndev, "DMA map error\n"); + goto dma_err; + } + + /* Get the next BD */ + enetc_bdr_idx_inc(tx_ring, i); + txbd = ENETC_TXBD(*tx_ring, *i); + tx_swbd = &tx_ring->tx_swbd[*i]; + prefetchw(txbd); + *count += 1; + + enetc_clear_tx_bd(&txbd_tmp); + txbd_tmp.addr = cpu_to_le64(dma); + txbd_tmp.buf_len = cpu_to_le16(len); + + tx_swbd->dma = dma; + tx_swbd->len = len; + tx_swbd->is_dma_page = 1; + tx_swbd->dir = DMA_TO_DEVICE; + } + + /* Last BD needs 'F' bit set */ + flags |= ENETC_TXBD_FLAGS_F; + txbd_tmp.flags = flags; + *txbd = txbd_tmp; + + tx_swbd->is_eof = 1; + tx_swbd->skb = skb; + + return 0; + +dma_err: + return -ENOMEM; +} + +static int enetc_lso_hw_offload(struct enetc_bdr *tx_ring, struct sk_buff *skb) +{ + struct enetc_tx_swbd *tx_swbd; + struct enetc_lso_t lso = {0}; + int err, i, count = 0; + + /* Initialize the LSO handler */ + enetc_lso_start(skb, &lso); + i = tx_ring->next_to_use; + + enetc_lso_map_hdr(tx_ring, skb, &i, &lso); + /* First BD and an extend BD */ + count += 2; + + err = enetc_lso_map_data(tx_ring, skb, &i, &lso, &count); + if (err) + goto dma_err; + + /* Go to the next BD */ + enetc_bdr_idx_inc(tx_ring, &i); + tx_ring->next_to_use = i; + enetc_update_tx_ring_tail(tx_ring); + + return count; + +dma_err: + do { + tx_swbd = &tx_ring->tx_swbd[i]; + enetc_free_tx_frame(tx_ring, tx_swbd); + if (i == 0) + i = tx_ring->bd_count; + i--; + } while (count--); + + return 0; +} + static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) { struct enetc_ndev_priv *priv = netdev_priv(tx_ring->ndev); @@ -648,14 +875,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))) @@ -1801,6 +2040,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; @@ -2105,6 +2347,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; @@ -2118,6 +2367,9 @@ int enetc_configure_si(struct enetc_ndev_priv *priv) /* enable SI */ enetc_wr(hw, ENETC_SIMR, ENETC_SIMR_EN); + if (si->hw_features & ENETC_SI_F_LSO) + enetc_set_lso_flags_mask(hw); + /* TODO: RSS support for i.MX95 will be supported later, and the * is_enetc_rev1() condition will be removed */ diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index a78af4f624e0..0a69f72fe8ec 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -41,6 +41,19 @@ struct enetc_tx_swbd { u8 qbv_en:1; }; +struct enetc_lso_t { + bool ipv6; + bool tcp; + u8 l3_hdr_len; + u8 hdr_len; /* LSO header length */ + u8 l3_start; + u16 lso_seg_size; + int total_len; /* total data length, not include LSO header */ +}; + +#define ENETC_1KB_SIZE 1024 +#define ENETC_LSO_MAX_DATA_LEN (256 * ENETC_1KB_SIZE) + #define ENETC_RX_MAXFRM_SIZE ENETC_MAC_MAXFRM_SIZE #define ENETC_RXB_TRUESIZE 2048 /* PAGE_SIZE >> 1 */ #define ENETC_RXB_PAD NET_SKB_PAD /* add extra space if needed */ @@ -238,6 +251,7 @@ enum enetc_errata { #define ENETC_SI_F_PSFP BIT(0) #define ENETC_SI_F_QBV BIT(1) #define ENETC_SI_F_QBU BIT(2) +#define ENETC_SI_F_LSO BIT(3) struct enetc_drvdata { u32 pmac_offset; /* Only valid for PSI which supports 802.1Qbu */ @@ -353,6 +367,7 @@ enum enetc_active_offloads { ENETC_F_QBU = BIT(11), ENETC_F_RXCSUM = BIT(12), ENETC_F_TXCSUM = BIT(13), + ENETC_F_LSO = BIT(14), }; enum enetc_flags_bit { diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_hw.h b/drivers/net/ethernet/freescale/enetc/enetc4_hw.h index 26b220677448..cdde8e93a73c 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc4_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc4_hw.h @@ -12,6 +12,28 @@ #define NXP_ENETC_VENDOR_ID 0x1131 #define NXP_ENETC_PF_DEV_ID 0xe101 +/**********************Station interface registers************************/ +/* Station interface LSO segmentation flag mask register 0/1 */ +#define ENETC4_SILSOSFMR0 0x1300 +#define SILSOSFMR0_TCP_MID_SEG GENMASK(27, 16) +#define SILSOSFMR0_TCP_1ST_SEG GENMASK(11, 0) +#define SILSOSFMR0_VAL_SET(first, mid) ((((mid) << 16) & SILSOSFMR0_TCP_MID_SEG) | \ + ((first) & SILSOSFMR0_TCP_1ST_SEG)) + +#define ENETC4_SILSOSFMR1 0x1304 +#define SILSOSFMR1_TCP_LAST_SEG GENMASK(11, 0) +#define TCP_FLAGS_FIN BIT(0) +#define TCP_FLAGS_SYN BIT(1) +#define TCP_FLAGS_RST BIT(2) +#define TCP_FLAGS_PSH BIT(3) +#define TCP_FLAGS_ACK BIT(4) +#define TCP_FLAGS_URG BIT(5) +#define TCP_FLAGS_ECE BIT(6) +#define TCP_FLAGS_CWR BIT(7) +#define TCP_FLAGS_NS BIT(8) +/* According to tso_build_hdr(), clear all special flags for not last packet. */ +#define TCP_NL_SEG_FLAGS_DMASK (TCP_FLAGS_FIN | TCP_FLAGS_RST | TCP_FLAGS_PSH) + /***************************ENETC port registers**************************/ #define ENETC4_ECAPR0 0x0 #define ECAPR0_RFS BIT(2) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 590b1412fadf..34a3e8f1496e 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -28,6 +28,8 @@ #define ENETC_SIPCAPR0_QBV BIT(4) #define ENETC_SIPCAPR0_QBU BIT(3) #define ENETC_SIPCAPR0_RFS BIT(2) +#define ENETC_SIPCAPR0_LSO BIT(1) +#define ENETC_SIPCAPR0_RSC BIT(0) #define ENETC_SIPCAPR1 0x24 #define ENETC_SITGTGR 0x30 #define ENETC_SIRBGCR 0x38 @@ -554,7 +556,10 @@ static inline u64 _enetc_rd_reg64_wa(void __iomem *reg) union enetc_tx_bd { struct { __le64 addr; - __le16 buf_len; + union { + __le16 buf_len; + __le16 hdr_len; /* For LSO, ENETC 4.1 and later */ + }; __le16 frm_len; union { struct { @@ -574,13 +579,16 @@ union enetc_tx_bd { __le32 tstamp; __le16 tpid; __le16 vid; - u8 reserved[6]; + __le16 lso_sg_size; /* For ENETC 4.1 and later */ + __le16 frm_len_ext; /* For ENETC 4.1 and later */ + u8 reserved[2]; u8 e_flags; u8 flags; } ext; /* Tx BD extension */ struct { __le32 tstamp; - u8 reserved[10]; + u8 reserved[8]; + __le16 lso_err_count; /* For ENETC 4.1 and later */ u8 status; u8 flags; } wb; /* writeback descriptor */ @@ -589,6 +597,7 @@ union enetc_tx_bd { enum enetc_txbd_flags { ENETC_TXBD_FLAGS_L4CS = BIT(0), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TSE = BIT(1), + ENETC_TXBD_FLAGS_LSO = BIT(1), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_W = BIT(2), ENETC_TXBD_FLAGS_CSUM_LSO = BIT(3), /* For ENETC 4.1 and later */ ENETC_TXBD_FLAGS_TXSTART = BIT(4), diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 2c4c6af672e7..82a67356abe4 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -126,6 +126,9 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, if (si->drvdata->tx_csum) priv->active_offloads |= ENETC_F_TXCSUM; + if (si->hw_features & ENETC_SI_F_LSO) + priv->active_offloads |= ENETC_F_LSO; + /* TODO: currently, i.MX95 ENETC driver does not support advanced features */ if (!is_enetc_rev1(si)) { ndev->hw_features &= ~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK); From patchwork Thu Nov 7 03:38:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13865784 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011021.outbound.protection.outlook.com [52.101.65.21]) (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 50860192D86 for ; Thu, 7 Nov 2024 03:54:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.21 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951657; cv=fail; b=SbpzshgAhQz8c14Tpt/il3YKguC27Hw7q7zDlZbyl87zKrH3ojmIAFla7jGkE9j8XqivtA8lUgaR7JnzYcbjnJ2ureyffJnzCIdvfDohm7KqOTLpZ1KmH7A60q5cPCkJrf+b7OoznYRCs/b0tlMflgmvwn1W8xB7AcXaK7l0Kj0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730951657; c=relaxed/simple; bh=bVNl9Tu8GcV5eA+hKTHko9gF8fXk8PAfj64OyT3Z6Is=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=mTu6m+cCsK4hs8JdTBOGldZ25P1Q/hJQnc/J1bTl2bg32sZRMY+O7Rkn7Kk8y/6PV5PYwFs8SqRIwdDsv/M5DO4XBzfLSrKv8qpyYKpZHEDZUJkIVg4W+7wbJWCVoRKcsTg/h/30ZG2U0Ly3/rkJnISZiyufm1nVNlU/m5RLoEc= 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.65.21 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> 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: imx@lists.linux.dev 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: MvQsVzcU6mOcXhe1iLVyEtn4eAUo0GV2AOhaeFDpuiM2wDYtq1ZAxPZ3tFFDMThf5yV27vJ7pPxnNsn2IXYL/gqAfFQsCRTN9eHiRlbgDyzbEtX7MOpKW06HY2ZF1RDoWEv7BIihqyMDTMttcU9CvS+Th4Zd3DYvPrtNxtdy2OWZjboVC0bJPnVgdFXqgqWC/QwseZe2jNVu+9ifrAGLPOXyxEh9ZL6/O7zHQR9ch3fbYEx5GFmBFPw1sI/5sytRBdTO3BOR8ZlQG+G9EG38oWILIvGaGhrzWMqQ/r9/jexluwH/S57FV2LDQa8fMmPIhY3U+/1BcHpL5Uy3tOr30ovhX0gqy4Oj8uTMb2cRvNB/tH4Ss3G5BPaYW4y1+ttbnCkkkafJUtTii8e6fqj73/kIgJudUD3M+ghYPrAmD33XrrJPZORQTXNiHW33SCNfWLQMx1Nk2HvYN4KvSqq3mEbofmuPfo2Lw+hRQAr2ZxCawWfDprrWwLVV+J4l2PjgCTrcRtEspBqTDJx+PT7VaKhHDGwSMvnnGPpKbyysFc5h7m4sLVFNzEaLgQDyap9cBtBH8zl9sqGvXvxsOqCmb/qWu15eHhoJXFbg5T5oOogywL/lwlSJ+5JWUMXAZ8qpQJ1pf/GfFUk57AeFY90cYTbwzLFhh3Ndw1y8bUirq5nh21DxhoEYgetLVng+RjfTQ0ooTie0kJzFw6AtEbtReZGgZoxQAQlptQq6r9s5ja3xqbJlU/ZP1zbMTag+DxEMCTsWHYeb4XBCggyUOryshifEVHwRTsfxg4VAnW+XTHXfVlssrbJ290dkvqUPHK7wpPFLvYE10VP2HsVtpZ+Z13oZR/AyA/6+pBCiFWXpS7Y5JNjl1ytXoec+p3uqF4NCSCaMoAWCH1TPgQE64/Oe92Cwr0vR5NuLP6BiaVNfG1X1hi3fwULIL4nMSDu3nBSPckd3ztSfyfWpEtZXFyxJZVUbRB9SC2FHDEe19sj3+eE22UzuG6YW1dGAuYXpZ67Wk7C9sVW3Av3baLgEsTviilxwbS+LLIS2DbffLBkzdlQXWW2bCKW1IqIODkqlrtQmV3n55ttwVXyAhXqK6h9ITj15QzGvuZtml5vz1Uudt4mKG5dkRc11J2XTZHvG47WCE8I4/iuXAqi7BIgGtStLqTY1ImVrBEE3bzVbh2fz3Pk9leaaLUnvMfSi+jClI4J1MRLIfivQO0qFTc6dv3E2bIbWU1uJO3/e9xf9H5V/AHx+cQjV9NAyui2mpcVNFbDwych8iSfDOjyVA3hMfhbf9Mllo41at+GdGr3cWStoCOs7O9GzihWGAUPuQt6+giqhS6S/YZWc6KzUCXb0D/z7HhbkCBh8S1LY0Z+ZyvnhGQo= 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: IafvZyElUl6+RYNkSyQtwsiQNeMK27L3cMsM6c1hJM/1/XSEHNA0D3FoADjD1NgaVsroQ+ydjHNYkDuNGBF5E1mLCh21FJDR8syhvRg37bFT9DEVUkRow43PqNaU6YpWdZSQcyE1/QHhjQe+Z9NhtfRzjX6MfweHrw8LHdecmCeOxvs2PYv//8NvFR98JolvufziwZt9pZmcHgie7gQ5Lwvkso9oCVsx/4OZOHt7/1beBrxjuC6vT6mbqtE0w98k3ji6ShX74RKz9SFliPRG3OPJCdS9rNe4EiL5pqH10W0uRK5bFg4lvC+rvc8H7MoXjhLF0t/DvQasgzlueah35+J6Cq7nMD6gucmK1jI6JNd/qQGN2yM5RCTyrr3PN3jHIONi1lXTMMf80aCHRiBvf7LJAH0glJFN26N0nAHsuTcyvtyNlBQB1wNKVH1iHJYGTty4vpQDtgTrlVQgV2p7CWm5/VhGRdPGdIxtx95oCfPdDsZQbcAkJjbxJyK5byyH5LDsMxDRvGcZTNJ2FJzzpCK+ESMw5Pe6b38Xp8BZZaF02TDWdAariyY3XsKEvi1U1WmQldW3nfwlsVBHQ1ujHHLc/yesV1KZBSaxpGtRTdPwCfaLGuMTIp7sVOIwSvD1xcysMVTMR7C3B1nc953Nh/ZgguDHy3Bz9w1vTui0jMzOnRxhQgPBIiHU/rv4xILffjizznjptM3aXLE8L2V3QVoavtkw08yv1yGutLEApncxzPlZECRsz+/1j3Hn+dpOZT3k6TyV3J/TknuLVE6dopjboPCLddglVEIeT2Bpa8VA8BsT9F/eTG1JSs3lP1SfFtzuHFH3ckKwcHhzqIxLrAJMW4NEy3lqFYzb/95SJB5vDMZq9XFYYe4Vd7FDaRBCPSzuxuEmypKslRcbKX60nubxksX9z0qasPCrQejt/PUwzMl1tqgusUt+Ou2oN7OgvMOIzlEpBP9BhIL6avdoESpdDH2nDywiR7QyPWvRD0KaHbaV1wJzrYukqSwFUL5OXwXMoTxSEQkUnHeLICL5lKAlxbeQBq6rQYmgdY3tWC4royP5KWZbotof2ttUE8Db4DsAh6Lym+AdEgHGU7pb08/H+S8g/ivzryG3wIro+jy9ELVTK3O056EDKcjpOzqu/gmUOSNajquTEgreuk9hJWZ2v26HotnfVUql3fQH0rv+B3NSvQlKhXHlCCIJZPcnNwufwfAMGy2NJWOT3Y/J9TpVC6nzdNWlidyDkmCVsW6oqjPgkCyMTeko+F5aXOdUrXfg1hYsbL4VZTaM3r1j3tOM1N53qNeEJx3ez1oWzkfg5eArmbBryu1unaRFiuBqQNfgwqy1zmn/zO2YcwSvzgWOHe04SPlU6r3pGfuPLW/6SyPor6z4/Z419RAr298xsPcLo3pZVpn3SQldxdD6oxPcw8a/yFTNn2auSXjuVgCRulClX7KqTFaIxHxW9w+4emtfDlY5jOyRKa79ktbzCfdtQ20/3vgeQKJ405oh8rL1jSqif8VjTXA/Arak4I5m/jP6ODDhb6b9kcGBLmV69we3RLx435596CyTlAFU6Jb67x/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 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/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c index 82a67356abe4..76fc3c6fdec1 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c @@ -110,11 +110,13 @@ void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK | - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | + NETIF_F_GSO_UDP_L4; ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | + NETIF_F_GSO_UDP_L4; ndev->vlan_features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c index 052833acd220..ba71c04994c4 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c @@ -138,11 +138,13 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev, ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | + NETIF_F_GSO_UDP_L4; ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | + NETIF_F_GSO_UDP_L4; ndev->vlan_features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6;