mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: netdev@vger.kernel.org
Cc: Andrew Lunn <andrew@lunn.ch>, David Miller <davem@davemloft.net>,
	Jakub Kicinski <jakub.kicinski@netronome.com>,
	Jiri Pirko <jiri@resnulli.us>,
	Florian Fainelli <f.fainelli@gmail.com>,
	John Linville <linville@tuxdriver.com>,
	Stephen Hemminger <stephen@networkplumber.org>,
	Johannes Berg <johannes@sipsolutions.net>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 5/5] ethtool: provide link mode names as a string set
Date: Mon, 9 Dec 2019 21:45:46 +0100	[thread overview]
Message-ID: <20191209204546.GB31047@unicorn.suse.cz> (raw)
In-Reply-To: <20191209201511.GL9099@lunn.ch>

On Mon, Dec 09, 2019 at 09:15:11PM +0100, Andrew Lunn wrote:
> On Mon, Dec 09, 2019 at 08:55:45PM +0100, Michal Kubecek wrote:
> > Unlike e.g. netdev features, the ethtool ioctl interface requires link mode
> > table to be in sync between kernel and userspace for userspace to be able
> > to display and set all link modes supported by kernel. The way arbitrary
> > length bitsets are implemented in netlink interface, this will be no longer
> > needed.
> > 
> > To allow userspace to access all link modes running kernel supports, add
> > table of ethernet link mode names and make it available as a string set to
> > userspace GET_STRSET requests. Add build time check to make sure names
> > are defined for all modes declared in enum ethtool_link_mode_bit_indices.
> 
> Hi Michal
> 
> Having a build time check is a good idea. However, i don't see it in
> the code. Please could you point it out.

Thanks for noticing. The BUILD_BUG_ON() check got lost when I moved the
patch to an earlier place and changed the declaration to fixed size
array like other name tables have. But you are right, losing the check
would be too high price for the uniformity.

> > +#define __LINK_MODE_NAME(speed, type, duplex) \
> > +	#speed "base" #type "/" #duplex
> > +#define __DEFINE_LINK_MODE_NAME(speed, type, duplex) \
> > +	[ETHTOOL_LINK_MODE(speed, type, duplex)] = \
> > +	__LINK_MODE_NAME(speed, type, duplex)
> > +#define __DEFINE_SPECIAL_MODE_NAME(_mode, _name) \
> > +	[ETHTOOL_LINK_MODE_ ## _mode ## _BIT] = _name
> > +
> > +const char
> > +link_mode_names[__ETHTOOL_LINK_MODE_MASK_NBITS][ETH_GSTRING_LEN] = {
> > +	__DEFINE_LINK_MODE_NAME(10, T, Half),
> > +	__DEFINE_LINK_MODE_NAME(10, T, Full),
> > +	__DEFINE_LINK_MODE_NAME(100, T, Half),
> > +	__DEFINE_LINK_MODE_NAME(100, T, Full),
> > +	__DEFINE_LINK_MODE_NAME(1000, T, Half),
> > +	__DEFINE_LINK_MODE_NAME(1000, T, Full),
> > +	__DEFINE_SPECIAL_MODE_NAME(Autoneg, "Autoneg"),
> > +	__DEFINE_SPECIAL_MODE_NAME(TP, "TP"),
> > +	__DEFINE_SPECIAL_MODE_NAME(AUI, "AUI"),
> > +	__DEFINE_SPECIAL_MODE_NAME(MII, "MII"),
> > +	__DEFINE_SPECIAL_MODE_NAME(FIBRE, "FIBRE"),
> > +	__DEFINE_SPECIAL_MODE_NAME(BNC, "BNC"),
> > +	__DEFINE_LINK_MODE_NAME(10000, T, Full),
> > +	__DEFINE_SPECIAL_MODE_NAME(Pause, "Pause"),
> > +	__DEFINE_SPECIAL_MODE_NAME(Asym_Pause, "Asym_Pause"),
> > +	__DEFINE_LINK_MODE_NAME(2500, X, Full),
> > +	__DEFINE_SPECIAL_MODE_NAME(Backplane, "Backplane"),
> > +	__DEFINE_LINK_MODE_NAME(1000, KX, Full),
> > +	__DEFINE_LINK_MODE_NAME(10000, KX4, Full),
> > +	__DEFINE_LINK_MODE_NAME(10000, KR, Full),
> > +	[ETHTOOL_LINK_MODE_10000baseR_FEC_BIT] = "10000baseR_FEC",
> 
> Would
> 
> __DEFINE_SPECIAL_MODE_NAME(10000baseR_FEC, 10000baseR_FEC),
> 
> work here?

Right, it would (with double quotes for second argument). As I wrote the
macro for bits which don't represent actual link modes, it never occured
to me that it can be also used for this special case.

I'll wait until tomorrow to see if there are more comments and send v2.

Michal

      reply	other threads:[~2019-12-09 20:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09 19:55 [PATCH net-next 0/5] ethtool netlink interface, preliminary patches Michal Kubecek
2019-12-09 19:55 ` [PATCH net-next 1/5] rtnetlink: provide permanent hardware address in RTM_NEWLINK Michal Kubecek
2019-12-09 23:20   ` Johannes Berg
2019-12-09 23:21     ` Johannes Berg
2019-12-09 19:55 ` [PATCH net-next 2/5] netlink: rename nl80211_validate_nested() to nla_validate_nested() Michal Kubecek
2019-12-09 19:55 ` [PATCH net-next 3/5] ethtool: move to its own directory Michal Kubecek
2019-12-09 19:55 ` [PATCH net-next 4/5] ethtool: move string arrays into common file Michal Kubecek
2019-12-09 19:55 ` [PATCH net-next 5/5] ethtool: provide link mode names as a string set Michal Kubecek
2019-12-09 20:15   ` Andrew Lunn
2019-12-09 20:45     ` Michal Kubecek [this message]

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=20191209204546.GB31047@unicorn.suse.cz \
    --to=mkubecek@suse.cz \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=jiri@resnulli.us \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®