From nobody Sun Feb 8 14:42:00 2026 Received: from DM5PR21CU001.outbound.protection.outlook.com (mail-centralusazon11011029.outbound.protection.outlook.com [52.101.62.29]) (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 AAC832DA776; Wed, 7 Jan 2026 12:51:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.62.29 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767790293; cv=fail; b=dwNmuPWu5n9FdXbZf8LRvPFR2Pe/sAj8/7ODBlvHvGSPSe3+oNK4mjIfhlaEoCLs8IhGVr+7x5dOoUIj7zS5MPBW3fwiaUsYcTEv++DP9encvF3Iwdh/ioVkXSz/JEX4xvppG+PglGvRgbk8DmxPbnSzoohifMddnmufnhIM/8k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767790293; c=relaxed/simple; bh=I97r0CvXth5zc1joUpVn2/GP2ftcKhnYzjFCv7yIsMA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LunwxTnezSUHPgZ/O0iRRtE3/ZQI4uWqV+zvNfYoCZXDvK+XQ1xaNQCtO8ANbVCJ2cYlnTpy1rQrNMDx0qpSCLEf3p1XIAdrU8PzfKE7FbHimnd+Gs/DKM2Tglji2C1+/ejsQtfVjuNgBT9iWlJN1Oegllia81wX3HEnCJCHgQo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=J3XIo9iZ; arc=fail smtp.client-ip=52.101.62.29 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="J3XIo9iZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CRmefxvmBaWDroXyEWsomzRbeZ+f1s9ED3nPrhzve2C3EKSWfv/bpUot+dPwQkC44lrUkwX28ee+GlNYbhRZTHDY1E0aI2/EMido1VX9PV5nnHbuUDGMH8xv0gpqvJgFTmX7uGNdiz3G+g8d6ehrpCOZTKA+U321b1WzaC9oA5DSa66N7l5t2PfMDerKUJ2iB/E4p7NHN3UnLInTWN5UUa7mRUvbjO143oy5vROKWwo3g4dXqvHBtshaRcGmlFpEnnTsg55DriEf1stHVLvqYWF/7t9FFq3potgvaiDdOB7mVQfhnesgzfFfyELVWQqdSEAPHNSHqfcUD+ex8UOpVw== 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=Evdp2FF+SlUKdpNZhMqGqiZyrHunsCvKOl4bE9QUom0=; b=Dpu4GaoWDKbj+Ln8uPftBkM6RJA84StKFurH3zlA3ZdiGRXP0upE0H0minrK/h8RvAD2riRi36saCsCcWa37Zj3aXPEqpXZvzzfTowswuQrleUJlkxxz/CksJYZnunVFoa7V2yGKwJs/fUVHUnxbqiOLZpIJjvCsro6NyvebC+n8ADBWEchCrw0D3VKp3HXJ06v7n+LXuG93xRh1ytbCWmE5dOUOWJba2a6qBrAvyDhl4+uaNXdhYR58roNDDgzJdNKE4eMjiB89uSj4KtsRHoAGzC2mwLnwAjxcWK6VZ1OLl4SuirY/UZBiu5KvRQL8dwTV0nFapmEuHqj2UmmHxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=linux.dev smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Evdp2FF+SlUKdpNZhMqGqiZyrHunsCvKOl4bE9QUom0=; b=J3XIo9iZY9GfVxLP2jFGzvYiD2Vwo34e9DBZkxdbNpC24AgkxAPZ8NFXNcvaxFpnQsByh++4xthU0rXjkCC+tjx4/KS2/1WYwT9E3Gqd5sulOIpgYSGJFOMn/jDJKvTuKekWAADCZpsIWdojvKTu8GFBD7+WYCjQfxIcPvvDhh8= Received: from BN9PR03CA0372.namprd03.prod.outlook.com (2603:10b6:408:f7::17) by SN4PR10MB5605.namprd10.prod.outlook.com (2603:10b6:806:208::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9499.2; Wed, 7 Jan 2026 12:51:28 +0000 Received: from BN3PEPF0000B370.namprd21.prod.outlook.com (2603:10b6:408:f7:cafe::f2) by BN9PR03CA0372.outlook.office365.com (2603:10b6:408:f7::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9499.2 via Frontend Transport; Wed, 7 Jan 2026 12:51:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by BN3PEPF0000B370.mail.protection.outlook.com (10.167.243.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.0 via Frontend Transport; Wed, 7 Jan 2026 12:51:27 +0000 Received: from DLEE210.ent.ti.com (157.170.170.112) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 7 Jan 2026 06:51:20 -0600 Received: from DLEE214.ent.ti.com (157.170.170.117) by DLEE210.ent.ti.com (157.170.170.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 7 Jan 2026 06:51:19 -0600 Received: from fllvem-mr07.itg.ti.com (10.64.41.89) by DLEE214.ent.ti.com (157.170.170.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 7 Jan 2026 06:51:19 -0600 Received: from lelv0854.itg.ti.com (lelv0854.itg.ti.com [10.181.64.140]) by fllvem-mr07.itg.ti.com (8.18.1/8.18.1) with ESMTP id 607CpJ0I4135493; Wed, 7 Jan 2026 06:51:19 -0600 Received: from localhost (meghana-pc.dhcp.ti.com [10.24.69.13] (may be forged)) by lelv0854.itg.ti.com (8.14.7/8.14.7) with ESMTP id 607CpIp6027899; Wed, 7 Jan 2026 06:51:19 -0600 From: Meghana Malladi To: , , , , , , , , , , , , , , CC: , , , , Vignesh Raghavendra Subject: [PATCH net-next 1/2] net: ti: icssg-prueth: Add Frame Preemption MAC Merge support Date: Wed, 7 Jan 2026 18:21:10 +0530 Message-ID: <20260107125111.2372254-2-m-malladi@ti.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260107125111.2372254-1-m-malladi@ti.com> References: <20260107125111.2372254-1-m-malladi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B370:EE_|SN4PR10MB5605:EE_ X-MS-Office365-Filtering-Correlation-Id: 1dbc8513-f874-4c4b-5b0e-08de4deb794d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|82310400026|36860700013|376014|1800799024|13003099007|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?XXM6D1ssBboARky5miJD8JBDbmY3ZSw1ZxOVEV2wr4CnA2lQ+fVsVqjvnHes?= =?us-ascii?Q?r9lVQ+9HQLZPGbmphyrpV6t0fFT1jhmfUrCQCi/O7JK/t/KxyQ3T7n/zgJ8n?= =?us-ascii?Q?H5v4lw/p6ZE+W88mtBgdNwd1OObQo98EbYeb88FPsYOD9vwMDCz3jFMSS1mn?= =?us-ascii?Q?pVdEh3cxyFz60v6SNtRuXyhxVkl11imN3xEeHQAo6mn10Cmm9RAiaV/jgGUZ?= =?us-ascii?Q?Y+DZV+vW9ZzFOuIkGzl8O8ElC5NT1RKxR5xXPwhX/yOKPoczcgqW/yggPcSm?= =?us-ascii?Q?eLQjIi2+YSVQ5iw0hIXIJYGOYRCGpSrNfXR+qYwfSW7GxU1dSA9Mew6WL1Gf?= =?us-ascii?Q?ddH/qf3qFojK5Eab9l5RQoZOuAbGHw1lp5JtzacQcq5dpOoLRHz4joHsAUVN?= =?us-ascii?Q?uE8yvenaVSzsQdBffxVeUiGAQKgcVSr2NjOJHl31IZJMRK05zOfVpC6luJCM?= =?us-ascii?Q?ff5vjogPFtd32pC49U/RU7sXTtzHSSoxp+Sxz4lUq4Mx8V1TWlenz5U9/Gn9?= =?us-ascii?Q?A4rRm6So5mfS3yI4j7VW/0p10S7a11YOPesuKMkoxImmfkOE2SctdQ98RgIW?= =?us-ascii?Q?2sWFF5aP7Dax9JZvs9NAdpVHXjFksOx/2eD3Xql5PIHG2StnOIND8XNe+YYp?= =?us-ascii?Q?oFx4C8W3GHb1yUU/P/jttrR+IC0OKqHzRXs33Yh7WNvH6UQsAfh9skaVcfjH?= =?us-ascii?Q?tci+SPSgnKXeR9/DIsYKULZ3mVggJcLLA0ac5AG0RRCWc4lP2slmMkmeAyR7?= =?us-ascii?Q?EBPsdpPsWyiimbATHiKi371kDgurjnVQMiPdpjqi7cjdj5Z55S65kB6fAScN?= =?us-ascii?Q?syWcZDHhwelWPkNz7CHKEY42nmFL5VSuBVpSauzrft7OOLYUAchiz8qdrhN3?= =?us-ascii?Q?C7vdIPciRNWkvPERddnJmClLa0YAQHNyapDRrJfj8o13VEVzK98ZS1MdkHJA?= =?us-ascii?Q?HBAlF8DCcXLkCSBXWirTMMzs2ncWa0ljs+sBHNGkM/khstyHPW79PsBBl5J/?= =?us-ascii?Q?ypSwXxPdfkBq5u4aryrjtm9Ib7Nr06Bo4Fg2QUcc1smc5RQRjO/7JB/BAK6S?= =?us-ascii?Q?93FCr/jgrmAJyGbH1DzfSriVHQLkf9Yuu+KxeSi4I7QtKkGfCRh46NAIJXi8?= =?us-ascii?Q?A/VSAa7mUu85PX7LM0caRRlvZtUZLqmEGolulhNFxqPa9RUuvlB7AY8UemXL?= =?us-ascii?Q?vN6c88zabtzYjRHxZ+5YZEj1ScKnaMQYbxFPapLumJXMfwqZi/2GJrUXcC8X?= =?us-ascii?Q?E0ixGSgaHD0xj2S5b3cdJiykEsdTEKuv6T7lQoHBB/z4KGL/O4X6nzSoRs5x?= =?us-ascii?Q?4GMOj4FRTcryk1YtSqAk59WULlqNY6qrWY0SsabfccjJQTWXncdtAQ+Ni9rt?= =?us-ascii?Q?rFO3qmyPVASrV9njUbQmw6yBggGCEwvpJeXoM9TJfjw3R8U7oAGhtRG0KPmW?= =?us-ascii?Q?zqg1UzaFWnVB+Bl+8HXj6kgvRF1ClIl+QK1Rs0XcyWl41loGa+ygKJRmgfkD?= =?us-ascii?Q?RcTCwvNgylyFtQ+PyNDBdK6UHRr4YlYNhO6u?= X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(82310400026)(36860700013)(376014)(1800799024)(13003099007)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2026 12:51:27.9764 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1dbc8513-f874-4c4b-5b0e-08de4deb794d X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.195];Helo=[lewvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B370.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5605 Content-Type: text/plain; charset="utf-8" This patch adds utility functions to configure firmware to enable IET FPE. The highest priority queue is marked as Express queue and lower priority queues as pre-emptable, as the default configuration which will be overwritten by the mqprio tc mask passed by tc qdisc. Driver optionally allow configure the Verify state machine in the firmware to check remote peer capability. If remote fails to respond to Verify command, then FPE is disabled by firmware and TX FPE active status is disabled. This also adds the necessary hooks to enable IET/FPE feature in ICSSG driver. IET/FPE gets configured when Link is up and gets disabled when link goes down or device is stopped. Signed-off-by: MD Danish Anwar Signed-off-by: Meghana Malladi --- drivers/net/ethernet/ti/Makefile | 2 +- drivers/net/ethernet/ti/icssg/icssg_prueth.c | 9 + drivers/net/ethernet/ti/icssg/icssg_prueth.h | 2 + drivers/net/ethernet/ti/icssg/icssg_qos.c | 319 +++++++++++++++++++ drivers/net/ethernet/ti/icssg/icssg_qos.h | 48 +++ 5 files changed, 379 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/ti/icssg/icssg_qos.c create mode 100644 drivers/net/ethernet/ti/icssg/icssg_qos.h diff --git a/drivers/net/ethernet/ti/Makefile b/drivers/net/ethernet/ti/Mak= efile index 93c0a4d0e33a..2f588663fdf0 100644 --- a/drivers/net/ethernet/ti/Makefile +++ b/drivers/net/ethernet/ti/Makefile @@ -35,7 +35,7 @@ ti-am65-cpsw-nuss-$(CONFIG_TI_K3_AM65_CPSW_SWITCHDEV) += =3D am65-cpsw-switchdev.o obj-$(CONFIG_TI_K3_AM65_CPTS) +=3D am65-cpts.o =20 obj-$(CONFIG_TI_ICSSG_PRUETH) +=3D icssg-prueth.o icssg.o -icssg-prueth-y :=3D icssg/icssg_prueth.o icssg/icssg_switchdev.o +icssg-prueth-y :=3D icssg/icssg_prueth.o icssg/icssg_switchdev.o icssg/ics= sg_qos.o =20 obj-$(CONFIG_TI_ICSSG_PRUETH_SR1) +=3D icssg-prueth-sr1.o icssg.o icssg-prueth-sr1-y :=3D icssg/icssg_prueth_sr1.o diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/eth= ernet/ti/icssg/icssg_prueth.c index f65041662173..668177eba3f8 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c @@ -378,6 +378,12 @@ static void emac_adjust_link(struct net_device *ndev) } else { icssg_set_port_state(emac, ICSSG_EMAC_PORT_DISABLE); } + + if (emac->link) { + icssg_qos_link_up(ndev); + } else { + icssg_qos_link_down(ndev); + } } =20 if (emac->link) { @@ -967,6 +973,8 @@ static int emac_ndo_open(struct net_device *ndev) if (ret) goto destroy_rxq; =20 + icssg_qos_init(ndev); + /* start PHY */ phy_start(ndev->phydev); =20 @@ -1421,6 +1429,7 @@ static const struct net_device_ops emac_netdev_ops = =3D { .ndo_hwtstamp_get =3D icssg_ndo_get_ts_config, .ndo_hwtstamp_set =3D icssg_ndo_set_ts_config, .ndo_xsk_wakeup =3D prueth_xsk_wakeup, + .ndo_setup_tc =3D icssg_qos_ndo_setup_tc, }; =20 static int prueth_netdev_init(struct prueth *prueth, diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.h b/drivers/net/eth= ernet/ti/icssg/icssg_prueth.h index 10eadd356650..7a586038adf8 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.h +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.h @@ -44,6 +44,7 @@ #include "icssg_config.h" #include "icss_iep.h" #include "icssg_switch_map.h" +#include "icssg_qos.h" =20 #define PRUETH_MAX_MTU (2000 - ETH_HLEN - ETH_FCS_LEN) #define PRUETH_MIN_PKT_SIZE (VLAN_ETH_ZLEN) @@ -255,6 +256,7 @@ struct prueth_emac { struct bpf_prog *xdp_prog; struct xdp_attachment_info xdpi; int xsk_qid; + struct prueth_qos qos; }; =20 /* The buf includes headroom compatible with both skb and xdpf */ diff --git a/drivers/net/ethernet/ti/icssg/icssg_qos.c b/drivers/net/ethern= et/ti/icssg/icssg_qos.c new file mode 100644 index 000000000000..858268740dae --- /dev/null +++ b/drivers/net/ethernet/ti/icssg/icssg_qos.c @@ -0,0 +1,319 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Texas Instruments ICSSG PRUETH QoS submodule + * Copyright (C) 2023 Texas Instruments Incorporated - http://www.ti.com/ + */ + +#include "icssg_prueth.h" +#include "icssg_switch_map.h" + +static int icssg_prueth_iet_fpe_enable(struct prueth_emac *emac); +static void icssg_prueth_iet_fpe_disable(struct prueth_qos_iet *iet); +static void icssg_qos_enable_ietfpe(struct work_struct *work); + +void icssg_qos_init(struct net_device *ndev) +{ + struct prueth_emac *emac =3D netdev_priv(ndev); + struct prueth_qos_iet *iet =3D &emac->qos.iet; + + if (!iet->fpe_configured) + return; + + /* Init work queue for IET MAC verify process */ + iet->emac =3D emac; + INIT_WORK(&iet->fpe_config_task, icssg_qos_enable_ietfpe); + init_completion(&iet->fpe_config_compl); + + /* As worker may be sleeping, check this flag to abort + * as soon as it comes of out of sleep and cancel the + * fpe config task. + */ + atomic_set(&iet->cancel_fpe_config, 0); +} + +static void icssg_iet_set_preempt_mask(struct prueth_emac *emac, u8 preemp= tible_tcs) +{ + void __iomem *config =3D emac->dram.va + ICSSG_CONFIG_OFFSET; + struct prueth_qos_mqprio *p_mqprio =3D &emac->qos.mqprio; + struct tc_mqprio_qopt *qopt =3D &p_mqprio->mqprio.qopt; + u8 tc; + int i; + + /* Configure highest queue as express. Set Bit 4 for FPE, + * Reset for express + */ + + /* first set all 8 queues as Preemptive */ + for (i =3D 0; i < PRUETH_MAX_TX_QUEUES * PRUETH_NUM_MACS; i++) + writeb(BIT(4), config + EXPRESS_PRE_EMPTIVE_Q_MAP + i); + + /* set highest priority channel queue as express as default configuration= */ + writeb(0, config + EXPRESS_PRE_EMPTIVE_Q_MAP + emac->tx_ch_num - 1); + + /* set up queue mask for FPE. 1 means express */ + writeb(BIT(emac->tx_ch_num - 1), config + EXPRESS_PRE_EMPTIVE_Q_MASK); + + /* Overwrite the express queue mapping based on the tc map set by the use= r */ + for (tc =3D 0; tc < p_mqprio->mqprio.qopt.num_tc; tc++) { + /* check if the tc is express or not */ + if (!(p_mqprio->preemptible_tcs & BIT(tc))) { + for (i =3D qopt->offset[tc]; i < qopt->offset[tc] + qopt->count[tc]; i+= +) { + /* Set all the queues in this tc as express queues */ + writeb(0, config + EXPRESS_PRE_EMPTIVE_Q_MAP + i); + writeb(BIT(i), config + EXPRESS_PRE_EMPTIVE_Q_MASK); + } + } + netdev_set_tc_queue(emac->ndev, tc, qopt->count[tc], qopt->offset[tc]); + } +} + +static int prueth_mqprio_validate(struct net_device *ndev, + struct tc_mqprio_qopt_offload *mqprio) +{ + int num_tc =3D mqprio->qopt.num_tc; + int queue_count =3D 0; + int i; + + /* Always start tc-queue mapping from queue 0 */ + if (mqprio->qopt.offset[0] !=3D 0) + return -EINVAL; + + /* Check for valid number of traffic classes */ + if (num_tc < 1 || num_tc > PRUETH_MAX_TX_QUEUES) + return -EINVAL; + + /* Only channel mode is supported */ + if (mqprio->mode !=3D TC_MQPRIO_MODE_CHANNEL) { + netdev_err(ndev, "Unsupported mode: %d\n", mqprio->mode); + return -EINVAL; + } + + for (i =3D 0; i < num_tc; i++) { + if (!mqprio->qopt.count[i]) { + netdev_err(ndev, "TC %d has zero size queue count: %d\n", + i, mqprio->qopt.count[i]); + return -EINVAL; + } + if (mqprio->min_rate[i] || mqprio->max_rate[i]) { + netdev_err(ndev, "Min/Max tx rate is not supported\n"); + return -EINVAL; + } + if (mqprio->qopt.offset[i] !=3D queue_count) { + netdev_err(ndev, "Discontinuous queues config is not supported\n"); + return -EINVAL; + } + queue_count +=3D mqprio->qopt.count[i]; + } + + if (queue_count > PRUETH_MAX_TX_QUEUES) { + netdev_err(ndev, "Total queues %d exceed max %d\n", + queue_count, PRUETH_MAX_TX_QUEUES); + return -EINVAL; + } + + return 0; +} + +static int emac_tc_query_caps(struct net_device *ndev, void *type_data) +{ + struct tc_query_caps_base *base =3D type_data; + + switch (base->type) { + case TC_SETUP_QDISC_MQPRIO: { + struct tc_mqprio_caps *caps =3D base->caps; + + caps->validate_queue_counts =3D true; + return 0; + } + default: + return -EOPNOTSUPP; + } +} + +static int emac_tc_setup_mqprio(struct net_device *ndev, void *type_data) +{ + struct tc_mqprio_qopt_offload *mqprio =3D type_data; + struct prueth_emac *emac =3D netdev_priv(ndev); + struct prueth_qos_mqprio *p_mqprio; + int ret; + + if (mqprio->qopt.hw =3D=3D TC_MQPRIO_HW_OFFLOAD_TCS) + return -EOPNOTSUPP; + + if (!mqprio->qopt.num_tc) { + netdev_reset_tc(ndev); + p_mqprio->preemptible_tcs =3D 0; + return 0; + } + + ret =3D prueth_mqprio_validate(ndev, mqprio); + if (ret) + return ret; + + p_mqprio =3D &emac->qos.mqprio; + memcpy(&p_mqprio->mqprio, mqprio, sizeof(*mqprio)); + netdev_set_num_tc(ndev, mqprio->qopt.num_tc); + + return 0; +} + +int icssg_qos_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type typ= e, + void *type_data) +{ + switch (type) { + case TC_QUERY_CAPS: + return emac_tc_query_caps(ndev, type_data); + case TC_SETUP_QDISC_MQPRIO: + return emac_tc_setup_mqprio(ndev, type_data); + default: + return -EOPNOTSUPP; + } +} +EXPORT_SYMBOL_GPL(icssg_qos_ndo_setup_tc); + +void icssg_qos_link_up(struct net_device *ndev) +{ + struct prueth_emac *emac =3D netdev_priv(ndev); + struct prueth_qos_iet *iet =3D &emac->qos.iet; + + if (!iet->fpe_configured) + return; + + icssg_prueth_iet_fpe_enable(emac); +} + +void icssg_qos_link_down(struct net_device *ndev) +{ + struct prueth_emac *emac =3D netdev_priv(ndev); + struct prueth_qos_iet *iet =3D &emac->qos.iet; + + if (iet->fpe_configured) + icssg_prueth_iet_fpe_disable(iet); +} + +static int icssg_config_ietfpe(struct prueth_qos_iet *iet, bool enable) +{ + void __iomem *config =3D iet->emac->dram.va + ICSSG_CONFIG_OFFSET; + struct prueth_qos_mqprio *p_mqprio =3D &iet->emac->qos.mqprio; + int ret; + u8 val; + + /* If FPE is to be enabled, first configure MAC Verify state + * machine in firmware as firmware kicks the Verify process + * as soon as ICSSG_EMAC_PORT_PREMPT_TX_ENABLE command is + * received. + */ + if (enable && iet->mac_verify_configured) { + writeb(1, config + PRE_EMPTION_ENABLE_VERIFY); + writew(iet->tx_min_frag_size, config + PRE_EMPTION_ADD_FRAG_SIZE_LOCAL); + writel(iet->verify_time_ms, config + PRE_EMPTION_VERIFY_TIME); + } + + /* Send command to enable FPE Tx side. Rx is always enabled */ + ret =3D icssg_set_port_state(iet->emac, + enable ? ICSSG_EMAC_PORT_PREMPT_TX_ENABLE : + ICSSG_EMAC_PORT_PREMPT_TX_DISABLE); + if (ret) { + netdev_err(iet->emac->ndev, "TX preempt %s command failed\n", + str_enable_disable(enable)); + writeb(0, config + PRE_EMPTION_ENABLE_VERIFY); + return ret; + } + + /* Update FPE Tx enable bit. Assume firmware use this bit + * and enable PRE_EMPTION_ACTIVE_TX if everything looks + * good at firmware + */ + writeb(enable ? 1 : 0, config + PRE_EMPTION_ENABLE_TX); + + if (enable && iet->mac_verify_configured) { + ret =3D readb_poll_timeout(config + PRE_EMPTION_VERIFY_STATUS, val, + (val =3D=3D ICSSG_IETFPE_STATE_SUCCEEDED), + USEC_PER_MSEC, 5 * USEC_PER_SEC); + if (ret) { + netdev_err(iet->emac->ndev, + "timeout for MAC Verify: status %x\n", + val); + return ret; + } + } else { + /* Give f/w some time to update PRE_EMPTION_ACTIVE_TX state */ + usleep_range(100, 200); + } + + if (enable) { + val =3D readb(config + PRE_EMPTION_ACTIVE_TX); + if (val !=3D 1) { + netdev_err(iet->emac->ndev, + "F/w fails to activate IET/FPE\n"); + writeb(0, config + PRE_EMPTION_ENABLE_TX); + return -ENODEV; + } + } else { + return 0; + } + + icssg_iet_set_preempt_mask(iet->emac, p_mqprio->preemptible_tcs); + + iet->fpe_enabled =3D true; + + return ret; +} + +static void icssg_qos_enable_ietfpe(struct work_struct *work) +{ + struct prueth_qos_iet *iet =3D + container_of(work, struct prueth_qos_iet, fpe_config_task); + int ret; + + /* Set the required flag and send a command to ICSSG firmware to + * enable FPE and start MAC verify + */ + ret =3D icssg_config_ietfpe(iet, true); + + /* if verify configured, poll for the status and complete. + * Or just do completion + */ + if (!ret) + netdev_err(iet->emac->ndev, "IET FPE configured successfully\n"); + else + netdev_err(iet->emac->ndev, "IET FPE config error\n"); + complete(&iet->fpe_config_compl); +} + +static void icssg_prueth_iet_fpe_disable(struct prueth_qos_iet *iet) +{ + int ret; + + atomic_set(&iet->cancel_fpe_config, 1); + cancel_work_sync(&iet->fpe_config_task); + ret =3D icssg_config_ietfpe(iet, false); + if (!ret) + netdev_err(iet->emac->ndev, "IET FPE disabled successfully\n"); + else + netdev_err(iet->emac->ndev, "IET FPE disable failed\n"); +} + +static int icssg_prueth_iet_fpe_enable(struct prueth_emac *emac) +{ + struct prueth_qos_iet *iet =3D &emac->qos.iet; + int ret; + + /* Schedule MAC Verify and enable IET FPE if configured */ + atomic_set(&iet->cancel_fpe_config, 0); + reinit_completion(&iet->fpe_config_compl); + schedule_work(&iet->fpe_config_task); + /* By trial, found it takes about 1.5s. So + * wait for 10s + */ + ret =3D wait_for_completion_timeout(&iet->fpe_config_compl, + msecs_to_jiffies(10000)); + if (!ret) { + netdev_err(emac->ndev, + "IET verify completion timeout\n"); + /* cancel verify in progress */ + atomic_set(&iet->cancel_fpe_config, 1); + cancel_work_sync(&iet->fpe_config_task); + } + + return ret; +} diff --git a/drivers/net/ethernet/ti/icssg/icssg_qos.h b/drivers/net/ethern= et/ti/icssg/icssg_qos.h new file mode 100644 index 000000000000..3d3f42107dd7 --- /dev/null +++ b/drivers/net/ethernet/ti/icssg/icssg_qos.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2023 Texas Instruments Incorporated - http://www.ti.com/ + */ + +#ifndef __NET_TI_ICSSG_QOS_H +#define __NET_TI_ICSSG_QOS_H + +#include +#include +#include + +struct prueth_qos_mqprio { + struct tc_mqprio_qopt_offload mqprio; + u8 preemptible_tcs; +}; + +struct prueth_qos_iet { + struct work_struct fpe_config_task; + struct completion fpe_config_compl; + struct prueth_emac *emac; + atomic_t cancel_fpe_config; + /* Set through priv flags to enable IET frame preemption */ + bool fpe_configured; + /* Set through priv flags to enable IET MAC Verify state machine + * in firmware + */ + bool mac_verify_configured; + /* Min TX fragment size, set via ethtool */ + u32 tx_min_frag_size; + /* wait time between verification attempts in ms (according to clause + * 30.14.1.6 aMACMergeVerifyTime), set via ethtool + */ + u32 verify_time_ms; + /* Set if IET FPE is active */ + bool fpe_enabled; +}; + +struct prueth_qos { + struct prueth_qos_iet iet; + struct prueth_qos_mqprio mqprio; +}; + +void icssg_qos_init(struct net_device *ndev); +void icssg_qos_link_up(struct net_device *ndev); +void icssg_qos_link_down(struct net_device *ndev); +int icssg_qos_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type typ= e, + void *type_data); +#endif /* __NET_TI_ICSSG_QOS_H */ --=20 2.43.0 From nobody Sun Feb 8 14:42:00 2026 Received: from PH7PR06CU001.outbound.protection.outlook.com (mail-westus3azon11010021.outbound.protection.outlook.com [52.101.201.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 340C131AA9E; Wed, 7 Jan 2026 12:51:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.201.21 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767790294; cv=fail; b=bpV/j23uU6PqRhDsFt6La8vltNCihY3g0NZfOX2iZHyGCCCQY7GYt0m7glAMLs+tvG1QI4isGVGGPtn8B9bXMsFlD9u1d/fLBXFAAaijuemMBKQYXNX05nGXIhY078dg0Q8TtRFb1PKIISVDfgjdr8hVe7J2M907ChRg/AVKV7Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767790294; c=relaxed/simple; bh=UtkmKRLRzKEMeTQVzuAZBMVRA6Jg51qU/n4gvPyDY6Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=knB3imTfNhhU+vwVCvlbgnwOt5UcTx5EYcRYRHFXLHE4c3T8MEFIupeHsGvjB+zpAnmy/+jD8gn1ItGL1ALDYR1rjjIlwEiBWMS4JpEHmibYJaaQVgYlvSFus+q8l375hFhZ7BBB1rLf3Vhp7CTjL+L1yTfdAyxliUpRVAnLkic= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=PuhZAyIl; arc=fail smtp.client-ip=52.101.201.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="PuhZAyIl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jvWt2Yvc2xhUtoMDh6l3J6zGiXon+waBYdtmu11shza6IK9pnTdx2WqmwGCR84x185Ne3meag9qP1NTWOA484xRTQHHPCN/eFtpI6r1g2h4R/rSg6l5zU+8KakVBXcJCTD+yDOQjnUVwSvb+FDGtMTNw+VrjPf1lcdiNlkXousr5GDwjvNHgsbYcgW0pb7X0WWtmqe1561y0uXiM7TEjzGGhDzt9w3U77ABFSN8EYNT5PdfbyZzNAthqWJYXvr9XIttuY4yr1T23yCzI6YTbS/XfWuClcoxHVOrtkOrAgGVI/cb44EISYKP7K8KDVMhulLLz0fuAb8CbJ5pKvCH9WA== 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=KgIS2UwftiuzGQp1xzrNfEG0YlLSUQxPunOl8AkoEfA=; b=ZE7haB3d8q09B9Geb5agjbTQabzXl2S+s77GK9GEoPebWACvAh9LJAsb5hEuJ2OWgCeYfNertEOSedoqwlCHTy3TLSHqSWPNGDJMWnH11SA2GdCodPW+7iDjlo/uAiE3lDxFxapjxb8uFRbeebpjPLjohw6clTCR4cxXbdZg/+YOxXtdPO2r566nhfFSr7JpbhBpdjyj+9lYMSJCvDb8+QiqxiweWoLR4MmOd1EpzPDFioB3FWYSDrCjgnRqyPveFZxMmWYIBiKwzyAuB/Looru+ZsHjJW54gSHncvHi86WG65mFQaT3cKCnpVKJmQMRwVko01MT8z1VxM2q1OxPcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.195) smtp.rcpttodomain=linux.dev smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KgIS2UwftiuzGQp1xzrNfEG0YlLSUQxPunOl8AkoEfA=; b=PuhZAyIlNmrKuE3Q/Rd7DP2JkF6cAZelmve4vqPCCCNTP8QH0yLXuI27GcRvaMjQJ+cwuNK+oTE7843oXVbfPMq1MrJAzPI4xJLKg5Dz7SS9zUPpOQ3bUcH0aVkq7DQuxWf2+VE5UDW42syA+wWdD8/jceLikrMzImm+LQES9Ow= Received: from BY5PR16CA0026.namprd16.prod.outlook.com (2603:10b6:a03:1a0::39) by SN7PR10MB6617.namprd10.prod.outlook.com (2603:10b6:806:2ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9478.4; Wed, 7 Jan 2026 12:51:28 +0000 Received: from SJ1PEPF000023CD.namprd02.prod.outlook.com (2603:10b6:a03:1a0:cafe::45) by BY5PR16CA0026.outlook.office365.com (2603:10b6:a03:1a0::39) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9499.2 via Frontend Transport; Wed, 7 Jan 2026 12:51:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.195; helo=flwvzet201.ext.ti.com; pr=C Received: from flwvzet201.ext.ti.com (198.47.21.195) by SJ1PEPF000023CD.mail.protection.outlook.com (10.167.244.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9499.1 via Frontend Transport; Wed, 7 Jan 2026 12:51:26 +0000 Received: from DFLE211.ent.ti.com (10.64.6.69) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 7 Jan 2026 06:51:22 -0600 Received: from DFLE210.ent.ti.com (10.64.6.68) by DFLE211.ent.ti.com (10.64.6.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 7 Jan 2026 06:51:22 -0600 Received: from fllvem-mr08.itg.ti.com (10.64.41.88) by DFLE210.ent.ti.com (10.64.6.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 7 Jan 2026 06:51:22 -0600 Received: from lelv0854.itg.ti.com (lelv0854.itg.ti.com [10.181.64.140]) by fllvem-mr08.itg.ti.com (8.18.1/8.18.1) with ESMTP id 607CpM66035713; Wed, 7 Jan 2026 06:51:22 -0600 Received: from localhost (meghana-pc.dhcp.ti.com [10.24.69.13] (may be forged)) by lelv0854.itg.ti.com (8.14.7/8.14.7) with ESMTP id 607CpKrN027905; Wed, 7 Jan 2026 06:51:21 -0600 From: Meghana Malladi To: , , , , , , , , , , , , , , CC: , , , , Vignesh Raghavendra Subject: [PATCH net-next 2/2] net: ti: icssg-prueth: Add ethtool ops for Frame Preemption MAC Merge Date: Wed, 7 Jan 2026 18:21:11 +0530 Message-ID: <20260107125111.2372254-3-m-malladi@ti.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260107125111.2372254-1-m-malladi@ti.com> References: <20260107125111.2372254-1-m-malladi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023CD:EE_|SN7PR10MB6617:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f8a5c89-f397-44a1-d1ff-08de4deb78ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|82310400026|7416014|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?LkZRmVP+7cUcP9CWo59uiAiK60l7Fgdabt1JXpJw851RZT1Dm6hVxRn9Ioni?= =?us-ascii?Q?UdHRc2nhYCh97uCjZfdgFGOSjcoYGl+SnNfWjBQyCZttK2Nr4biqD9R/dCtK?= =?us-ascii?Q?XxziJzDj/EshgoY9/pwIc7YEMf5qn3c2dx6lZK98STreYjpdEXLJ97QJRK09?= =?us-ascii?Q?2mYTxhVuzxh+p0AD4D1qTh1gtTJH0CciblsJrL2JvOwpU1Wfz9S37q0UrL6r?= =?us-ascii?Q?dTIQijbcFazxEix0Ckno03agDVWxcE6XRvjdrzK9Jh1UtBUnpW5VJeDEwoj/?= =?us-ascii?Q?bP4RRh/xhPi+xQSH5Hk70wmLBUvDcqSui6/b1GPzCnklOqX6qhUHM05Is4qe?= =?us-ascii?Q?HAvlEnEc9DEs1y6YEcagjnRF8crI4VNTYxDhyMp9QhI/kqdiCZupQ0ALZPrW?= =?us-ascii?Q?33xCMWRWdCyfnYA7ZVQAOu6gp0vitY3t3bzXQqHLWHaCIrYLKqMBh5m/VL7l?= =?us-ascii?Q?AewHqUVU93quazTtchWgO06EmoXlYImLOi5lVeyJJWpc/FkHpqrMxJEhC69K?= =?us-ascii?Q?rsDRQihIBeNtdekKuWbVniEbVPReBebCA81YbpLLQ1Iafyi+t5PK7anazAug?= =?us-ascii?Q?DMUkR4kerbggOTED59a9EM3z16SW+DZKIbLFiGD51ONeq/9JiZRCihRG9edf?= =?us-ascii?Q?tG4ref1DVaLZua52M1xF+e5ypYKcej499viZfTwuTrRQYRA9rMYpvDuBzzH6?= =?us-ascii?Q?yO5bgFr74VvBugvuKcaYQsBCAQMK4AOHhdDp/elcskMReVnxlq7eauKO4TgB?= =?us-ascii?Q?SUc8K90TutpHFKQ0bRZDnXG2k+rbSi4KfOpOpu/C3af7mJJs3BO3BKSRIQUw?= =?us-ascii?Q?hviGEQ46X0Qc90PXYgX6KOL8cQvcfylKEjm1WDNaFAbirFnedkQeesKMbosH?= =?us-ascii?Q?93uD2NatGqaEDcMKnSsoGbWGEWSmRd8h/pMT1hoT0d9s1SSNvx4DxqeMP9RX?= =?us-ascii?Q?JnqGcMrtn9w4lcLO5AvDfTwoICz4yAuuIHVFFiROuaESCxKd/HJs7LbuPtP1?= =?us-ascii?Q?MGq9JtiETjvOWuBDrkSHAlUZYBNDVjhQagkuGUjp7vTYmjz3jiyLlZE1LGOk?= =?us-ascii?Q?2A/wvCax5EcBdqo6M3DQY3z+5fJvKVn7R+M/Ep/l16Bry7hZ/mPZvWxafolo?= =?us-ascii?Q?Ixzuk0N6m8nTKguaUP7InlTnbtDImh7CAwFKjWS+UGP+mPOYKJw9F4I33y10?= =?us-ascii?Q?ufjBf+SzyCK1sjdzxn/avbg0+9hyyFOpgNuVn71uxVODHkPXJ/XsrXQa81k9?= =?us-ascii?Q?ntZRBxeqks8CtuxmHCpz3v8YkkaMot94JX7bJPhYAmgPqCF8+edDEuM9a2Hc?= =?us-ascii?Q?XX8m3VKlGer7iI4HlnpJhOnG3kJVZTqGDvBXYcP+UqOJY4yrbWSNB9MkWh3j?= =?us-ascii?Q?LFHoe50CcyUJkjaujTPabfp0utJZDPhwfp5HDMZcp3moIp6L2MLed7yW1jrR?= =?us-ascii?Q?6uCwio/wzHeG0TDTvUx9hfP0qGAJFfNHlGP3vDfGZm1tTMQhiM8m3FJbSxru?= =?us-ascii?Q?5avzq+dk1kXISxNQKCOi0TNQysvdUPOWMqOO450yxTPDWu86WAiHQ9E6SC2G?= =?us-ascii?Q?LR4k3eXhhX5PkG4LdfHyuEXZxxOX54KIjQKakGZK?= X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(376014)(36860700013)(82310400026)(7416014)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2026 12:51:26.9088 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f8a5c89-f397-44a1-d1ff-08de4deb78ab X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.195];Helo=[flwvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023CD.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6617 Content-Type: text/plain; charset="utf-8" Add ethtool ops .get_mm, .set_mm and .get_mm_stats to enable / disable Mac merge frame preemption and dump Preemption related statistics for ICSSG driver. Add pa stats registers for mac merge related statistics, which can be dumped using the ethtool ops. Signed-off-by: MD Danish Anwar Signed-off-by: Meghana Malladi --- drivers/net/ethernet/ti/icssg/icssg_ethtool.c | 58 +++++++++++++++++++ drivers/net/ethernet/ti/icssg/icssg_prueth.h | 2 +- drivers/net/ethernet/ti/icssg/icssg_stats.h | 5 ++ .../net/ethernet/ti/icssg/icssg_switch_map.h | 5 ++ 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c b/drivers/net/et= hernet/ti/icssg/icssg_ethtool.c index b715af21d23a..ceca6d6ec0f4 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c +++ b/drivers/net/ethernet/ti/icssg/icssg_ethtool.c @@ -294,6 +294,61 @@ static int emac_set_per_queue_coalesce(struct net_devi= ce *ndev, u32 queue, return 0; } =20 +static int emac_get_mm(struct net_device *ndev, struct ethtool_mm_state *s= tate) +{ + struct prueth_emac *emac =3D netdev_priv(ndev); + struct prueth_qos_iet *iet =3D &emac->qos.iet; + void __iomem *config; + + config =3D emac->dram.va + ICSSG_CONFIG_OFFSET; + + state->tx_enabled =3D iet->fpe_enabled; + state->pmac_enabled =3D true; + state->verify_status =3D readb(config + PRE_EMPTION_VERIFY_STATUS); + state->tx_min_frag_size =3D iet->tx_min_frag_size; + state->rx_min_frag_size =3D 124; + state->tx_active =3D readb(config + PRE_EMPTION_ACTIVE_TX) ? true : false; + state->verify_enabled =3D readb(config + PRE_EMPTION_ENABLE_VERIFY) ? tru= e : false; + state->verify_time =3D iet->verify_time_ms; + + /* 802.3-2018 clause 30.14.1.6, says that the aMACMergeVerifyTime + * variable has a range between 1 and 128 ms inclusive. Limit to that. + */ + state->max_verify_time =3D 128; + + return 0; +} + +static int emac_set_mm(struct net_device *ndev, struct ethtool_mm_cfg *cfg, + struct netlink_ext_ack *extack) +{ + struct prueth_emac *emac =3D netdev_priv(ndev); + struct prueth_qos_iet *iet =3D &emac->qos.iet; + + if (!cfg->pmac_enabled) + netdev_err(ndev, "preemptible MAC is always enabled"); + + iet->verify_time_ms =3D cfg->verify_time; + iet->tx_min_frag_size =3D cfg->tx_min_frag_size; + + iet->fpe_configured =3D cfg->tx_enabled; + iet->mac_verify_configured =3D cfg->verify_enabled; + + return 0; +} + +static void emac_get_mm_stats(struct net_device *ndev, + struct ethtool_mm_stats *s) +{ + struct prueth_emac *emac =3D netdev_priv(ndev); + + s->MACMergeFrameAssOkCount =3D emac_get_stat_by_name(emac, "FW_PREEMPT_AS= SEMBLY_OK"); + s->MACMergeFrameAssErrorCount =3D emac_get_stat_by_name(emac, "FW_PREEMPT= _ASSEMBLY_ERR"); + s->MACMergeFragCountRx =3D emac_get_stat_by_name(emac, "FW_PREEMPT_FRAG_C= NT_RX"); + s->MACMergeFragCountTx =3D emac_get_stat_by_name(emac, "FW_PREEMPT_FRAG_C= NT_TX"); + s->MACMergeFrameSmdErrorCount =3D emac_get_stat_by_name(emac, "FW_PREEMPT= _BAD_FRAG"); +} + const struct ethtool_ops icssg_ethtool_ops =3D { .get_drvinfo =3D emac_get_drvinfo, .get_msglevel =3D emac_get_msglevel, @@ -317,5 +372,8 @@ const struct ethtool_ops icssg_ethtool_ops =3D { .set_eee =3D emac_set_eee, .nway_reset =3D emac_nway_reset, .get_rmon_stats =3D emac_get_rmon_stats, + .get_mm =3D emac_get_mm, + .set_mm =3D emac_set_mm, + .get_mm_stats =3D emac_get_mm_stats, }; EXPORT_SYMBOL_GPL(icssg_ethtool_ops); diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.h b/drivers/net/eth= ernet/ti/icssg/icssg_prueth.h index 7a586038adf8..9c31574cc7f6 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.h +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.h @@ -58,7 +58,7 @@ =20 #define ICSSG_MAX_RFLOWS 8 /* per slice */ =20 -#define ICSSG_NUM_PA_STATS 32 +#define ICSSG_NUM_PA_STATS 37 #define ICSSG_NUM_MIIG_STATS 60 /* Number of ICSSG related stats */ #define ICSSG_NUM_STATS (ICSSG_NUM_MIIG_STATS + ICSSG_NUM_PA_STATS) diff --git a/drivers/net/ethernet/ti/icssg/icssg_stats.h b/drivers/net/ethe= rnet/ti/icssg/icssg_stats.h index 5ec0b38e0c67..f35ae1b4f846 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_stats.h +++ b/drivers/net/ethernet/ti/icssg/icssg_stats.h @@ -189,6 +189,11 @@ static const struct icssg_pa_stats icssg_all_pa_stats[= ] =3D { ICSSG_PA_STATS(FW_INF_DROP_PRIOTAGGED), ICSSG_PA_STATS(FW_INF_DROP_NOTAG), ICSSG_PA_STATS(FW_INF_DROP_NOTMEMBER), + ICSSG_PA_STATS(FW_PREEMPT_BAD_FRAG), + ICSSG_PA_STATS(FW_PREEMPT_ASSEMBLY_ERR), + ICSSG_PA_STATS(FW_PREEMPT_FRAG_CNT_TX), + ICSSG_PA_STATS(FW_PREEMPT_ASSEMBLY_OK), + ICSSG_PA_STATS(FW_PREEMPT_FRAG_CNT_RX), ICSSG_PA_STATS(FW_RX_EOF_SHORT_FRMERR), ICSSG_PA_STATS(FW_RX_B0_DROP_EARLY_EOF), ICSSG_PA_STATS(FW_TX_JUMBO_FRM_CUTOFF), diff --git a/drivers/net/ethernet/ti/icssg/icssg_switch_map.h b/drivers/net= /ethernet/ti/icssg/icssg_switch_map.h index 7e053b8af3ec..855fd4ed0b3f 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_switch_map.h +++ b/drivers/net/ethernet/ti/icssg/icssg_switch_map.h @@ -256,6 +256,11 @@ #define FW_INF_DROP_PRIOTAGGED 0x0148 #define FW_INF_DROP_NOTAG 0x0150 #define FW_INF_DROP_NOTMEMBER 0x0158 +#define FW_PREEMPT_BAD_FRAG 0x0160 +#define FW_PREEMPT_ASSEMBLY_ERR 0x0168 +#define FW_PREEMPT_FRAG_CNT_TX 0x0170 +#define FW_PREEMPT_ASSEMBLY_OK 0x0178 +#define FW_PREEMPT_FRAG_CNT_RX 0x0180 #define FW_RX_EOF_SHORT_FRMERR 0x0188 #define FW_RX_B0_DROP_EARLY_EOF 0x0190 #define FW_TX_JUMBO_FRM_CUTOFF 0x0198 --=20 2.43.0