[RFC] On macro usage for ethtool stats across netdev drivers

From: Yeounsu Moon <hidden>
Date: 2025-07-09 20:25:12
Also in: lkml

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
+	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.

Link: https://lore.kernel.org/netdev/20241107200940.4dff026d@kernel.org/ (local)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help