* [PATCH net-next v3] ethtool: Clarify len/n_stats fields in/out semantics
@ 2026-01-15 6:05 Gal Pressman
2026-01-16 3:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Gal Pressman @ 2026-01-15 6:05 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andrew Lunn, netdev
Cc: Andrew Lunn, Simon Horman, Gal Pressman, Dragos Tatulea
Document that the 'len' field in ethtool_gstrings and 'n_stats' field in
ethtool_stats optionally serve dual purposes: on entry they specify the
number of items requested, and on return they indicate the number
actually returned (which is not necessarily the same).
Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
---
v2->v3: https://lore.kernel.org/all/20260112115708.244752-1-gal@nvidia.com/
* Remove the 'on return' description (Jakub).
v1->v2: https://lore.kernel.org/all/20260105163923.49104-1-gal@nvidia.com/
* Reword comments (Jakub).
---
include/uapi/linux/ethtool.h | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index eb7ff2602fbb..7887697e6886 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -1094,13 +1094,20 @@ enum ethtool_module_fw_flash_status {
* struct ethtool_gstrings - string set for data tagging
* @cmd: Command number = %ETHTOOL_GSTRINGS
* @string_set: String set ID; one of &enum ethtool_stringset
- * @len: On return, the number of strings in the string set
+ * @len: Number of strings in the string set
* @data: Buffer for strings. Each string is null-padded to a size of
* %ETH_GSTRING_LEN.
*
* Users must use %ETHTOOL_GSSET_INFO to find the number of strings in
* the string set. They must allocate a buffer of the appropriate
* size immediately following this structure.
+ *
+ * Setting @len on input is optional (though preferred), but must be zeroed
+ * otherwise.
+ * When set, @len will return the requested count if it matches the actual
+ * count; otherwise, it will be zero.
+ * This prevents issues when the number of strings is different than the
+ * userspace allocation.
*/
struct ethtool_gstrings {
__u32 cmd;
@@ -1177,13 +1184,20 @@ struct ethtool_test {
/**
* struct ethtool_stats - device-specific statistics
* @cmd: Command number = %ETHTOOL_GSTATS
- * @n_stats: On return, the number of statistics
+ * @n_stats: Number of statistics
* @data: Array of statistics
*
* Users must use %ETHTOOL_GSSET_INFO or %ETHTOOL_GDRVINFO to find the
* number of statistics that will be returned. They must allocate a
* buffer of the appropriate size (8 * number of statistics)
* immediately following this structure.
+ *
+ * Setting @n_stats on input is optional (though preferred), but must be zeroed
+ * otherwise.
+ * When set, @n_stats will return the requested count if it matches the actual
+ * count; otherwise, it will be zero.
+ * This prevents issues when the number of stats is different than the
+ * userspace allocation.
*/
struct ethtool_stats {
__u32 cmd;
--
2.40.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next v3] ethtool: Clarify len/n_stats fields in/out semantics
2026-01-15 6:05 [PATCH net-next v3] ethtool: Clarify len/n_stats fields in/out semantics Gal Pressman
@ 2026-01-16 3:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-16 3:20 UTC (permalink / raw)
To: Gal Pressman
Cc: davem, edumazet, kuba, pabeni, andrew+netdev, netdev, andrew,
horms, dtatulea
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 15 Jan 2026 08:05:44 +0200 you wrote:
> Document that the 'len' field in ethtool_gstrings and 'n_stats' field in
> ethtool_stats optionally serve dual purposes: on entry they specify the
> number of items requested, and on return they indicate the number
> actually returned (which is not necessarily the same).
>
> Signed-off-by: Gal Pressman <gal@nvidia.com>
> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
>
> [...]
Here is the summary with links:
- [net-next,v3] ethtool: Clarify len/n_stats fields in/out semantics
https://git.kernel.org/netdev/net-next/c/567873005dca
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-16 3:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-15 6:05 [PATCH net-next v3] ethtool: Clarify len/n_stats fields in/out semantics Gal Pressman
2026-01-16 3:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox