netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] On macro usage for ethtool stats across netdev drivers
@ 2025-07-09 20:25 Yeounsu Moon
  0 siblings, 0 replies; only message in thread
From: Yeounsu Moon @ 2025-07-09 20:25 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: netdev, linux-kernel

While working on "[PATCH net-next v2] net: dlink: add support for
reporting stats via 'ethtool -S'", I received the following feedback from
Jakub:
>> +	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/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-07-09 20:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-09 20:25 [RFC] On macro usage for ethtool stats across netdev drivers Yeounsu Moon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).