Skip to contentSkip to conversation

On macro usage for ethtool stats across netdev drivers

RFC Yeounsu Moon 1 participant 1 message Jul 9, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

While working on "[PATCH net-next v2] net: dlink: add support for reporting stats via 'ethtool -S'", I received the following feedback from Jakub:

Quoted 9 lines

Review

Quoted 8 lines
(quoted diff) +7 -0
+	DEFINE_RMON_STATS(rmon_rx_byte_512to1203,
+			  EtherStatsPkts512to1023Octets, hist[4]),
+	DEFINE_RMON_STATS(rmon_tx_byte_1204to1518,
+			  EtherStatsPkts1024to1518OctetsTransmit, hist_tx[5]),
+	DEFINE_RMON_STATS(rmon_rx_byte_1204to1518,
+			  EtherStatsPkts1024to1518Octets, hist[5])
+};

Do these macro wrappers really buy you anything? They make the code a lot harder to follow :(

I understand that such macro usage can reduce readability, as Jakub pointed out. That said, this style is also seen in several other network drivers (e.g. intel/e1000e/ethtool.c, broadcom/bnxt/bnxt_ethtool.c), and I initially followed this approach to keep things consistent and reduce boilerplate.

Given these differing perspectives, I'd like to raise the following
question: Is there a general consensus on the use of macro wrappers in netdev drivers, particularly for ethtool stats? Is it encouraged, discouraged, or left to the discretion of each driver maintainer?

I've seen this pattern in several existing drivers, so I'm wondering if it was considered acceptable in the past, but has since fallen out of favor in current developement practices.