All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Ido Schimmel <idosch@idosch.org>
Cc: netdev@vger.kernel.org, davem@davemloft.net, andrew@lunn.ch,
	mkubecek@suse.cz, idosch@nvidia.com, saeedm@nvidia.com,
	michael.chan@broadcom.com
Subject: Re: [PATCH net-next v2 3/9] ethtool: add a new command for reading standard stats
Date: Sat, 17 Apr 2021 12:15:20 -0700	[thread overview]
Message-ID: <20210417121520.242b0c14@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <YHsutM6vesbQq+Ju@shredder.lan>

On Sat, 17 Apr 2021 21:53:40 +0300 Ido Schimmel wrote:
> On Sat, Apr 17, 2021 at 11:13:51AM -0700, Jakub Kicinski wrote:
> > On Sat, 17 Apr 2021 10:57:42 -0700 Jakub Kicinski wrote:  
> > > Um, yes and now. The only places the user space puts those names 
> > > is the help message and man page.
> > > 
> > > Thru the magic of bitsets it doesn't actually interpret them, so
> > > with old user space you can still query a new group, it will just 
> > > not show up in "ethtool -h".
> > > 
> > > Is that what you're saying?  
> > 
> > FWIW ethnl_parse_bit() -> ETHTOOL_A_BITSET_BIT_NAME
> > User space can also use raw flags like --groups 0xf but that's perhaps
> > too spartan for serious use.  
> 
> So the kernel can work with ETHTOOL_A_BITSET_BIT_INDEX /
> ETHTOOL_A_BITSET_BIT_NAME, but I was wondering if using ethtool binary
> we can query the strings that the kernel will accept. I think not?

For request user space sends the strings inside the netlink message:

ethtool --debug 0xff -S eth0 --groups eth-phy eth-mac

sending genetlink packet (80 bytes):
    msg length 80 ethool ETHTOOL_MSG_STATS_GET
    ETHTOOL_MSG_STATS_GET
        ETHTOOL_A_STATS_HEADER
            ETHTOOL_A_HEADER_DEV_NAME = "eth0"
        ETHTOOL_A_STATS_GROUPS
            ETHTOOL_A_BITSET_NOMASK = true
            ETHTOOL_A_BITSET_BITS
                ETHTOOL_A_BITSET_BITS_BIT
                    ETHTOOL_A_BITSET_BIT_NAME = "eth-phy"
                ETHTOOL_A_BITSET_BITS_BIT
                    ETHTOOL_A_BITSET_BIT_NAME = "eth-mac"

Kernel will then search the bitset and respond with:

netlink error: bit name not found

if string is not found. So upfront enumeration is not strictly
necessary.

The only way to query what will be accepted AFAIU is to query 
the string set via ETHTOOL_MSG_STRSET_GET. The string set is part 
of the uAPI:

const char stats_std_names[__ETHTOOL_STATS_CNT][ETH_GSTRING_LEN] = {
	[ETHTOOL_STATS_ETH_PHY]			= "eth-phy",
	[ETHTOOL_STATS_ETH_MAC]			= "eth-mac",
	[ETHTOOL_STATS_ETH_CTRL]		= "eth-ctrl",
	[ETHTOOL_STATS_RMON]			= "rmon",
};

	[ETH_SS_STATS_STD] = {
		.per_dev	= false,
		.count		= __ETHTOOL_STATS_CNT,
		.strings	= stats_std_names,
	},

I believe string set must have the same number of bits as the bitset,
so there's full equivalency. We could try to express the limits in a
static netlink policy one day but today parameters of the bitset are
passed in the code.

> Anyway, I'm fine with implementing '--all-groups' via
> ETHTOOL_MSG_STRSET_GET.

Cool, will do!

> We can always add a new attribute later, but I
> don't see a reason to do so.

  reply	other threads:[~2021-04-17 19:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16 19:27 [PATCH net-next v2 0/9] ethtool: add uAPI for reading standard stats Jakub Kicinski
2021-04-16 19:27 ` [PATCH net-next v2 1/9] docs: networking: extend the statistics documentation Jakub Kicinski
2021-04-16 19:27 ` [PATCH net-next v2 2/9] docs: ethtool: document standard statistics Jakub Kicinski
2021-04-16 19:27 ` [PATCH net-next v2 3/9] ethtool: add a new command for reading standard stats Jakub Kicinski
2021-04-17 17:15   ` Ido Schimmel
2021-04-17 17:57     ` Jakub Kicinski
2021-04-17 18:13       ` Jakub Kicinski
2021-04-17 18:53         ` Ido Schimmel
2021-04-17 19:15           ` Jakub Kicinski [this message]
2021-04-17 19:18             ` Jakub Kicinski
2021-04-17 19:27               ` Ido Schimmel
2021-04-17 20:10               ` Michal Kubecek
2021-04-19 19:20                 ` Jakub Kicinski
2021-04-18  8:20   ` Ido Schimmel
2021-04-16 19:27 ` [PATCH net-next v2 4/9] ethtool: add interface to read standard MAC stats Jakub Kicinski
2021-04-16 19:27 ` [PATCH net-next v2 5/9] ethtool: add interface to read standard MAC Ctrl stats Jakub Kicinski
2021-04-16 19:27 ` [PATCH net-next v2 6/9] ethtool: add interface to read RMON stats Jakub Kicinski
2021-04-18  8:04   ` Ido Schimmel
2021-04-19 18:55     ` Jakub Kicinski
2021-04-16 19:27 ` [PATCH net-next v2 7/9] mlxsw: implement ethtool standard stats Jakub Kicinski
2021-04-16 19:27 ` [PATCH net-next v2 8/9] bnxt: " Jakub Kicinski
2021-04-19  0:27   ` Michael Chan
2021-04-16 19:27 ` [PATCH net-next v2 9/9] mlx5: " Jakub Kicinski

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=20210417121520.242b0c14@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
    --to=kuba@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=idosch@idosch.org \
    --cc=idosch@nvidia.com \
    --cc=michael.chan@broadcom.com \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.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.