From: "Yeounsu Moon" <yyyynoom@gmail.com>
To: "Andrew Lunn" <andrew@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [RFC] On macro usage for ethtool stats across netdev drivers
Date: Thu, 10 Jul 2025 05:25:07 +0900 [thread overview]
Message-ID: <DB7T1297UN2E.20SHSTO9HWDMU@gmail.com> (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:
>> + 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/
reply other threads:[~2025-07-09 20:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DB7T1297UN2E.20SHSTO9HWDMU@gmail.com \
--to=yyyynoom@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.