Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4551115ybl; Mon, 9 Dec 2019 12:46:57 -0800 (PST) X-Google-Smtp-Source: APXvYqzQCerXZUGWXK91WcTPf4xSztzHfykvr/Wz2hapu5BbSkUjhweci3PEZ3B5fawy65co8pzt X-Received: by 2002:a05:6830:1309:: with SMTP id p9mr23570577otq.328.1575924416889; Mon, 09 Dec 2019 12:46:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575924416; cv=none; d=google.com; s=arc-20160816; b=Xh736fw0b1KccrzTgqVCSsaypNzyDe0Bt98zW1zlSrKQYYTl99z9xZr3ClC9Ix26er iFbztPLMUpgsFzOv7cDnuQ08mfg5TojBU6DjL4agaI8oOijr5sMuvHGZPYSqGpfEAdQj xFumFOt9LAwL8hs+xh+kNuk7uEoygPUEUHv/y4YgjAB14eg25GqUIeo5hVTaYru2QJmz h58/3vryUI9QBTcZYyL9TEe6AJgHX7GEO0ZyEcbwZsYhaSw3HzO9G1/H6jAhOSg368VT r1SWpXb2i/FAg9V/st6V/r8aVVAwB5n2eAZSKLTwOegCh3WLdBeEglQOL3CSMwLT7rDl 1Ixg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=MRLflikENKOeNMVIwciXVDK5Cxvjt/euLSTKfuvPx9w=; b=qTwzLZhOritw8ubqPmAT0bQBzjJLuf4/V6JggkBuxQEk9hj3IZ3TgJrJQ5cXgJxpJ7 wH9or+1KaQzQsR8H4/lavFjzNYslIikrLGGblokJwKFLKEjtBp4+dZr8q5Tzu7ERTe6T WTXKMO5LK+k0+4WTNje+cf49XctzNnymcBeqcZZ8dricR32zFaLnaA77cIWYKOHPEPD+ 7xDNzAzLi8o44W6X+xINYZOFkS8Wc4alrJX065gJR7IVF45SK7+fZx902YE99vUhbEo8 V3bymNdmn5e7NAvDXhlhOG3gKDkAaBJLlpGJvUQxTQ0JXFm98FrIZuwa6PklyH/dQUtQ cBBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r8si574232otp.194.2019.12.09.12.46.44; Mon, 09 Dec 2019 12:46:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726683AbfLIUpu (ORCPT + 99 others); Mon, 9 Dec 2019 15:45:50 -0500 Received: from mx2.suse.de ([195.135.220.15]:35098 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726509AbfLIUpt (ORCPT ); Mon, 9 Dec 2019 15:45:49 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 118DCAC45; Mon, 9 Dec 2019 20:45:47 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 449CEE0321; Mon, 9 Dec 2019 21:45:46 +0100 (CET) Date: Mon, 9 Dec 2019 21:45:46 +0100 From: Michal Kubecek To: netdev@vger.kernel.org Cc: Andrew Lunn , David Miller , Jakub Kicinski , Jiri Pirko , Florian Fainelli , John Linville , Stephen Hemminger , Johannes Berg , linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next 5/5] ethtool: provide link mode names as a string set Message-ID: <20191209204546.GB31047@unicorn.suse.cz> References: <0c239334df943c3f5f4ca74a2509754e08eda9e3.1575920565.git.mkubecek@suse.cz> <20191209201511.GL9099@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191209201511.GL9099@lunn.ch> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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