From: MD Danish Anwar <danishanwar@ti.com>
Add driver support for viewing / changing the MAC Merge sublayer
parameters and dump the Mac Merge stats via ethtool ops: .set_mm(),
.get_mm() and .get_mm_stats().
The minimum size of non-final mPacket fragments supported by the firmware
without leading errors is 64 Bytes (in octets). Add a check to ensure
user passed tx_min_frag_size argument via ethtool, honors this .
Add pa stats registers to check statistics for preemption, which can be
dumped using ethtool ops.
Signed-off-by: MD Danish Anwar <danishanwar@ti.com>
Signed-off-by: Meghana Malladi <m-malladi@ti.com>
---
v2-v1:
- Following changes have been done as suggested by Vladimir Oltean <vladimir.oltean@nxp.com>
* Add sanity check to ensure valid min_frag_size is requested by the user.
* Add comments wherever applicable w.r.t min_frag_size.
* Make it uniform to return all valures from the driver for .get_mm()
* Use ETHTOOL_MM_MAX_VERIFY_TIME_MS macro for 128
* Use NL_SET_ERR_MSG_MOD() wherever applicable
* Re-schedule the iet work thread whenever there .set_mm() get called
based on fpe_enabled flag.
drivers/net/ethernet/ti/icssg/icssg_ethtool.c | 86 ++++++++++++++++++-
drivers/net/ethernet/ti/icssg/icssg_prueth.h | 3 +-
drivers/net/ethernet/ti/icssg/icssg_qos.h | 20 +++++
drivers/net/ethernet/ti/icssg/icssg_stats.c | 1 -
drivers/net/ethernet/ti/icssg/icssg_stats.h | 5 ++
.../net/ethernet/ti/icssg/icssg_switch_map.h | 5 ++
6 files changed, 117 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c b/drivers/net/ethernet/ti/icssg/icssg_ethtool.c
index b715af21d23a..3c4ff154f6d1 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_ethtool.c
@@ -6,7 +6,6 @@
*/
#include "icssg_prueth.h"
-#include "icssg_stats.h"
static void emac_get_drvinfo(struct net_device *ndev,
struct ethtool_drvinfo *info)
@@ -294,6 +293,88 @@ static int emac_set_per_queue_coalesce(struct net_device *ndev, u32 queue,
return 0;
}
+static int emac_get_mm(struct net_device *ndev, struct ethtool_mm_state *state)
+{
+ struct prueth_emac *emac = netdev_priv(ndev);
+ struct prueth_qos_iet *iet = &emac->qos.iet;
+
+ state->tx_enabled = iet->fpe_enabled;
+ state->pmac_enabled = true;
+ state->tx_min_frag_size = iet->tx_min_frag_size;
+ /* 64Bytes is the minimum fragment size supported
+ * by the firmware. <64B leads to min frame errors
+ */
+ state->rx_min_frag_size = 64;
+ state->tx_active = iet->fpe_active;
+ state->verify_enabled = iet->mac_verify_configure;
+ state->verify_time = iet->verify_time_ms;
+
+ switch (iet->verify_status) {
+ case ICSSG_IETFPE_STATE_DISABLED:
+ state->verify_status = ETHTOOL_MM_VERIFY_STATUS_DISABLED;
+ break;
+ case ICSSG_IETFPE_STATE_SUCCEEDED:
+ state->verify_status = ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED;
+ break;
+ case ICSSG_IETFPE_STATE_FAILED:
+ state->verify_status = ETHTOOL_MM_VERIFY_STATUS_FAILED;
+ break;
+ default:
+ state->verify_status = ETHTOOL_MM_VERIFY_STATUS_UNKNOWN;
+ break;
+ }
+
+ /* 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 = ETHTOOL_MM_MAX_VERIFY_TIME_MS;
+
+ 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 = netdev_priv(ndev);
+ struct prueth_qos_iet *iet = &emac->qos.iet;
+ int err;
+
+ if (!cfg->pmac_enabled)
+ NL_SET_ERR_MSG_MOD(extack, "preemptible MAC is always enabled");
+
+ err = icssg_qos_frag_size_min_to_add(cfg->tx_min_frag_size, extack);
+ if (err)
+ return err;
+
+ iet->verify_time_ms = cfg->verify_time;
+ iet->tx_min_frag_size = cfg->tx_min_frag_size;
+
+ iet->fpe_enabled = cfg->tx_enabled;
+ iet->mac_verify_configure = cfg->verify_enabled;
+
+ /* Re-trigger the state machine to incorporate the updated configuration */
+ if (iet->fpe_enabled)
+ atomic_set(&iet->enable_fpe_config, 1);
+ else
+ atomic_set(&iet->enable_fpe_config, 0);
+
+ schedule_work(&iet->fpe_config_task);
+
+ return 0;
+}
+
+static void emac_get_mm_stats(struct net_device *ndev,
+ struct ethtool_mm_stats *s)
+{
+ struct prueth_emac *emac = netdev_priv(ndev);
+
+ s->MACMergeFrameAssOkCount = emac_get_stat_by_name(emac, "FW_PREEMPT_ASSEMBLY_OK");
+ s->MACMergeFrameAssErrorCount = emac_get_stat_by_name(emac, "FW_PREEMPT_ASSEMBLY_ERR");
+ s->MACMergeFragCountRx = emac_get_stat_by_name(emac, "FW_PREEMPT_FRAG_CNT_RX");
+ s->MACMergeFragCountTx = emac_get_stat_by_name(emac, "FW_PREEMPT_FRAG_CNT_TX");
+ s->MACMergeFrameSmdErrorCount = emac_get_stat_by_name(emac, "FW_PREEMPT_BAD_FRAG");
+}
+
const struct ethtool_ops icssg_ethtool_ops = {
.get_drvinfo = emac_get_drvinfo,
.get_msglevel = emac_get_msglevel,
@@ -317,5 +398,8 @@ const struct ethtool_ops icssg_ethtool_ops = {
.set_eee = emac_set_eee,
.nway_reset = emac_nway_reset,
.get_rmon_stats = emac_get_rmon_stats,
+ .get_mm = emac_get_mm,
+ .set_mm = emac_set_mm,
+ .get_mm_stats = emac_get_mm_stats,
};
EXPORT_SYMBOL_GPL(icssg_ethtool_ops);
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.h b/drivers/net/ethernet/ti/icssg/icssg_prueth.h
index 7a586038adf8..1309af6aab78 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.h
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.h
@@ -45,6 +45,7 @@
#include "icss_iep.h"
#include "icssg_switch_map.h"
#include "icssg_qos.h"
+#include "icssg_stats.h"
#define PRUETH_MAX_MTU (2000 - ETH_HLEN - ETH_FCS_LEN)
#define PRUETH_MIN_PKT_SIZE (VLAN_ETH_ZLEN)
@@ -58,7 +59,7 @@
#define ICSSG_MAX_RFLOWS 8 /* per slice */
-#define ICSSG_NUM_PA_STATS 32
+#define ICSSG_NUM_PA_STATS ARRAY_SIZE(icssg_all_pa_stats)
#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_qos.h b/drivers/net/ethernet/ti/icssg/icssg_qos.h
index 8aa79b68ad54..b18a93f9181a 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_qos.h
+++ b/drivers/net/ethernet/ti/icssg/icssg_qos.h
@@ -55,4 +55,24 @@ 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 type,
void *type_data);
+static inline int icssg_qos_frag_size_min_to_add(u32 min_frag_size,
+ struct netlink_ext_ack *extack)
+{
+ /* The minimum size of the non-final mPacket supported
+ * by the firmware is 64B and multiples of 64B.
+ */
+ if (min_frag_size < 64) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "tx_min_frag_size must be at least 64 bytes");
+ return -EINVAL;
+ }
+
+ if (min_frag_size % (ETH_ZLEN + ETH_FCS_LEN)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "tx_min_frag_size must be a multiple of 64 bytes");
+ return -EINVAL;
+ }
+
+ return 0;
+}
#endif /* __NET_TI_ICSSG_QOS_H */
diff --git a/drivers/net/ethernet/ti/icssg/icssg_stats.c b/drivers/net/ethernet/ti/icssg/icssg_stats.c
index 7159baa0155c..d27e1c48976f 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_stats.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_stats.c
@@ -6,7 +6,6 @@
*/
#include "icssg_prueth.h"
-#include "icssg_stats.h"
#include <linux/regmap.h>
#define ICSSG_TX_PACKET_OFFSET 0xA0
diff --git a/drivers/net/ethernet/ti/icssg/icssg_stats.h b/drivers/net/ethernet/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[] = {
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
--
2.43.0
Hi Meghana,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 9a9424c756feee9ee6e717405a9d6fa7bacdef08]
url: https://github.com/intel-lab-lkp/linux/commits/Meghana-Malladi/net-ti-icssg-prueth-Add-Frame-Preemption-MAC-Merge-support/20260204-220543
base: 9a9424c756feee9ee6e717405a9d6fa7bacdef08
patch link: https://lore.kernel.org/r/20260204140044.4086725-3-m-malladi%40ti.com
patch subject: [PATCH net-next v2 2/2] net: ti: icssg-prueth: Add ethtool ops for Frame Preemption MAC Merge
config: arm64-defconfig (https://download.01.org/0day-ci/archive/20260205/202602050744.pYAnjG71-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260205/202602050744.pYAnjG71-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202602050744.pYAnjG71-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from drivers/net/ethernet/ti/icssg/icssg_prueth.h:48,
from drivers/net/ethernet/ti/icssg/icssg_prueth.c:34:
>> drivers/net/ethernet/ti/icssg/icssg_stats.h:93:38: warning: 'icssg_all_miig_stats' defined but not used [-Wunused-const-variable=]
93 | static const struct icssg_miig_stats icssg_all_miig_stats[] = {
| ^~~~~~~~~~~~~~~~~~~~
vim +/icssg_all_miig_stats +93 drivers/net/ethernet/ti/icssg/icssg_stats.h
c1e10d5dc7a1be MD Danish Anwar 2023-08-01 92
550ee90ac61c1f MD Danish Anwar 2024-08-22 @93 static const struct icssg_miig_stats icssg_all_miig_stats[] = {
c1e10d5dc7a1be MD Danish Anwar 2023-08-01 94 /* Rx */
550ee90ac61c1f MD Danish Anwar 2024-08-22 95 ICSSG_MIIG_STATS(rx_packets, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 96 ICSSG_MIIG_STATS(rx_broadcast_frames, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 97 ICSSG_MIIG_STATS(rx_multicast_frames, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 98 ICSSG_MIIG_STATS(rx_crc_errors, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 99 ICSSG_MIIG_STATS(rx_mii_error_frames, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 100 ICSSG_MIIG_STATS(rx_odd_nibble_frames, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 101 ICSSG_MIIG_STATS(rx_frame_max_size, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 102 ICSSG_MIIG_STATS(rx_max_size_error_frames, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 103 ICSSG_MIIG_STATS(rx_frame_min_size, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 104 ICSSG_MIIG_STATS(rx_min_size_error_frames, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 105 ICSSG_MIIG_STATS(rx_over_errors, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 106 ICSSG_MIIG_STATS(rx_class0_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 107 ICSSG_MIIG_STATS(rx_class1_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 108 ICSSG_MIIG_STATS(rx_class2_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 109 ICSSG_MIIG_STATS(rx_class3_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 110 ICSSG_MIIG_STATS(rx_class4_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 111 ICSSG_MIIG_STATS(rx_class5_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 112 ICSSG_MIIG_STATS(rx_class6_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 113 ICSSG_MIIG_STATS(rx_class7_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 114 ICSSG_MIIG_STATS(rx_class8_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 115 ICSSG_MIIG_STATS(rx_class9_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 116 ICSSG_MIIG_STATS(rx_class10_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 117 ICSSG_MIIG_STATS(rx_class11_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 118 ICSSG_MIIG_STATS(rx_class12_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 119 ICSSG_MIIG_STATS(rx_class13_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 120 ICSSG_MIIG_STATS(rx_class14_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 121 ICSSG_MIIG_STATS(rx_class15_hits, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 122 ICSSG_MIIG_STATS(rx_smd_frags, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 123 ICSSG_MIIG_STATS(rx_bucket1_size, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 124 ICSSG_MIIG_STATS(rx_bucket2_size, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 125 ICSSG_MIIG_STATS(rx_bucket3_size, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 126 ICSSG_MIIG_STATS(rx_bucket4_size, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 127 ICSSG_MIIG_STATS(rx_64B_frames, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 128 ICSSG_MIIG_STATS(rx_bucket1_frames, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 129 ICSSG_MIIG_STATS(rx_bucket2_frames, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 130 ICSSG_MIIG_STATS(rx_bucket3_frames, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 131 ICSSG_MIIG_STATS(rx_bucket4_frames, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 132 ICSSG_MIIG_STATS(rx_bucket5_frames, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 133 ICSSG_MIIG_STATS(rx_bytes, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 134 ICSSG_MIIG_STATS(rx_tx_total_bytes, false),
c1e10d5dc7a1be MD Danish Anwar 2023-08-01 135 /* Tx */
550ee90ac61c1f MD Danish Anwar 2024-08-22 136 ICSSG_MIIG_STATS(tx_packets, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 137 ICSSG_MIIG_STATS(tx_broadcast_frames, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 138 ICSSG_MIIG_STATS(tx_multicast_frames, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 139 ICSSG_MIIG_STATS(tx_odd_nibble_frames, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 140 ICSSG_MIIG_STATS(tx_underflow_errors, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 141 ICSSG_MIIG_STATS(tx_frame_max_size, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 142 ICSSG_MIIG_STATS(tx_max_size_error_frames, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 143 ICSSG_MIIG_STATS(tx_frame_min_size, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 144 ICSSG_MIIG_STATS(tx_min_size_error_frames, false),
550ee90ac61c1f MD Danish Anwar 2024-08-22 145 ICSSG_MIIG_STATS(tx_bucket1_size, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 146 ICSSG_MIIG_STATS(tx_bucket2_size, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 147 ICSSG_MIIG_STATS(tx_bucket3_size, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 148 ICSSG_MIIG_STATS(tx_bucket4_size, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 149 ICSSG_MIIG_STATS(tx_64B_frames, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 150 ICSSG_MIIG_STATS(tx_bucket1_frames, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 151 ICSSG_MIIG_STATS(tx_bucket2_frames, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 152 ICSSG_MIIG_STATS(tx_bucket3_frames, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 153 ICSSG_MIIG_STATS(tx_bucket4_frames, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 154 ICSSG_MIIG_STATS(tx_bucket5_frames, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 155 ICSSG_MIIG_STATS(tx_bytes, true),
550ee90ac61c1f MD Danish Anwar 2024-08-22 156 };
550ee90ac61c1f MD Danish Anwar 2024-08-22 157
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
© 2016 - 2026 Red Hat, Inc.