linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v3 00/17] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API
@ 2015-11-30 22:05 David Decotigny
  2015-11-30 22:05 ` [PATCH net-next v3 01/17] net: usnic: remove unused call to ethtool_ops::get_settings David Decotigny
                   ` (16 more replies)
  0 siblings, 17 replies; 25+ messages in thread
From: David Decotigny @ 2015-11-30 22:05 UTC (permalink / raw)
  To: David S. Miller, Ben Hutchings, Amir Vadai,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA, linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-mips-6z/3iImG2C8G8FEW9MqTrA,
	fcoe-devel-s9riP+hp16TNLxjTenLetw
  Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
	Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
	Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
	Ed Swierk, Robert Love, James E.J. Bottomley, Yuval Mintz,
	David Decotigny

From: David Decotigny <decot-Ypc/8FJVVoBWk0Htik3J/w@public.gmane.org>


History:
 v3
 - rebased v2 on top of latest net-next, minor checkpatch/printf %*pb
   updates
 v2
 - keep return 0 in get_settings when successful, instead of
   propagating positive result from driver's get_settings callback.
 v1
 - original submission


The main goal of this series is to support ethtool link mode masks
larger than 32 bits. It implements a new ioctl pair
(ETHTOOL_GSETTINGS/SSETTINGS), its associated callbacks
(get/set_settings) and a new struct ethtool_settings, which should
eventually replace legacy ethtool_cmd. Internally, the kernel uses
fixed length link mode masks defined at compilation time in ethtool.h
(for now: 31 bits), that can be increased by changing
__ETHTOOL_LINK_MODE_LAST in ethtool.h (absolute max is 4064 bits,
checked at compile time), and the user/kernel interface allows this
length to be arbitrary within 1..4064. This should allow some
flexibility without using too much malloc/stack space, at the cost of
a small kernel/user handshake for the user to determine the sizes of
those bitmaps.

Along the way, I chose to drop in the new structure the 3 ethtool_cmd
fields marked "deprecated" (transceiver/maxrxpkt/maxtxpkt). They are
still available for old drivers via the old ETHTOOL_GSET/SSET API, but
are not available to drivers that switch to new API. Of those 3
fields, ethtool_cmd::transceiver seems to be still actively used by
several drivers, maybe we should not consider this field deprecated?
The 2 other fields are basically not used. This transition requires
some care in the way old and new ethtool talk to the kernel.

More technical details provided in the description for main patch. In
particular details about backward compatibility properties.

Some questions to more experts than me:
 - the kernel/interface multiplexes the "tell me the bitmap length"
   handshake and the "give me the settings" inside the new
   ETHTOOL_GSETTINGS cmd. I was thinking of making this into 2
   separate cmds: 1 cmd ETHTOOL_GKERNELPROPERTIES which would be
   kernel-wide rather than device-specific, would return properties
   like "length of the link mode bitmaps", and possibly others. And
   ETHTOOL_GSETTINGS would expect the proper bitmaps
 - the link mode bitmaps are piggybacked at tail of the new struct
   ethtool_settings. Since its user-visible definition does not assume
   specific bitmap width, I am using a 0-length array as the publicly
   visible placeholder. But then, the kernel needs to specialize it
   (struct ethtool_ksettings) to specify its current link mode
   masks. This means that kernel code is "littered" with
   "ksettings->parent.field" to access "field" inside
   ethtool_settings:
   + I don't like the field name "parent", any suggestion welcome
   + and/or: I could use ethtool_settings everywhere (instead of a new
     ethtool_ksettings) and an accessor to retrieve the link mode
     masks?
   + or: we could decide to make the link mode masks statically
     bounded again, ie. make their width public, but larger than
     current 32, and unchangeable forever. This would make everything
     straightforward, but we might hit limits later, or have an
     unneeded memory/stack usage for unused bits.
   any preference?
 - crossing user/kernel boundary requires conversion of the kernel
   bitmaps (unsigned long[]) to something more strict (in my case:
   u32) to accomodate for 32/64 compat. Maybe I should add a
   copy_bitmap_from_user/copy_bitmap_to_user API inside bitmap.h
   instead of defining my own in ethtool.c?
 - I am using a typedef struct (ethtool_link_mode_mask_t) to build and
   hold the new masks. Makes it handy to use in the drivers (see mlx4
   for an example). Not very nice.
 - I foresee bugs where people use the legacy/deprecated SUPPORTED_x
   macros instead of the new ETHTOOL_LINK_MODE_x_BIT enums in the new
   get/set__ksettings callbacks. Not sure how to prevent problems with
   this.

The only driver which was converted for now is mlx4. I am not
considering fcoe as fully converted, but I updated it a minima to be
able to remove __ethtool_get_settings, now known as
__ethtool_get_ksettings.

Tested with legacy and "future" ethtool on 64b x86 kernel and 32+64b
ethtool, and on a 32b x86 kernel + 32b ethtool.

############################################
# Patch Set Summary:

David Decotigny (17):
  net: usnic: remove unused call to ethtool_ops::get_settings
  net: usnic: use __ethtool_get_settings
  net: ethtool: add new ETHTOOL_GSETTINGS/SSETTINGS API
  tx4939: use __ethtool_get_ksettings
  net: usnic: use __ethtool_get_ksettings
  net: bonding: use __ethtool_get_ksettings
  net: ipvlan: use __ethtool_get_ksettings
  net: macvlan: use __ethtool_get_ksettings
  net: team: use __ethtool_get_ksettings
  net: fcoe: use __ethtool_get_ksettings
  net: rdma: use __ethtool_get_ksettings
  net: 8021q: use __ethtool_get_ksettings
  net: bridge: use __ethtool_get_ksettings
  net: core: use __ethtool_get_ksettings
  net: ethtool: remove unused __ethtool_get_settings
  net: mlx4: convenience predicate for debug messages
  net: mlx4: use new ETHTOOL_G/SSETTINGS API

 arch/mips/txx9/generic/setup_tx4939.c           |   7 +-
 drivers/infiniband/hw/usnic/usnic_ib_verbs.c    |  10 +-
 drivers/net/bonding/bond_main.c                 |  14 +-
 drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 323 ++++++++--------
 drivers/net/ethernet/mellanox/mlx4/en_main.c    |   1 +
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h    |   5 +-
 drivers/net/ipvlan/ipvlan_main.c                |   8 +-
 drivers/net/macvlan.c                           |   8 +-
 drivers/net/team/team.c                         |   8 +-
 drivers/scsi/fcoe/fcoe_transport.c              |  36 +-
 include/linux/ethtool.h                         |  97 ++++-
 include/rdma/ib_addr.h                          |  14 +-
 include/uapi/linux/ethtool.h                    | 323 ++++++++++++----
 net/8021q/vlan_dev.c                            |   8 +-
 net/bridge/br_if.c                              |   6 +-
 net/core/ethtool.c                              | 478 +++++++++++++++++++++++-
 net/core/net-sysfs.c                            |  15 +-
 net/packet/af_packet.c                          |  11 +-
 18 files changed, 1046 insertions(+), 326 deletions(-)

-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2015-12-02 17:31 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-30 22:05 [PATCH net-next v3 00/17] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
2015-11-30 22:05 ` [PATCH net-next v3 01/17] net: usnic: remove unused call to ethtool_ops::get_settings David Decotigny
2015-11-30 22:05 ` [PATCH net-next v3 02/17] net: usnic: use __ethtool_get_settings David Decotigny
2015-11-30 22:05 ` [PATCH net-next v3 03/17] net: ethtool: add new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
     [not found]   ` <1448921155-24764-4-git-send-email-ddecotig-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-01  0:04     ` kbuild test robot
2015-12-01  0:47       ` David Decotigny
2015-12-01  1:52   ` Ben Hutchings
2015-12-02  3:13   ` David Miller
     [not found]     ` <20151201.221356.2176806670215219133.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2015-12-02  6:00       ` David Decotigny
2015-12-02 17:31         ` David Miller
2015-11-30 22:05 ` [PATCH net-next v3 04/17] tx4939: use __ethtool_get_ksettings David Decotigny
2015-11-30 23:51   ` Ralf Baechle
2015-11-30 22:05 ` [PATCH net-next v3 05/17] net: usnic: " David Decotigny
2015-11-30 22:05 ` [PATCH net-next v3 06/17] net: bonding: " David Decotigny
2015-11-30 22:05 ` [PATCH net-next v3 07/17] net: ipvlan: " David Decotigny
2015-11-30 22:05 ` [PATCH net-next v3 08/17] net: macvlan: " David Decotigny
2015-11-30 22:05 ` [PATCH net-next v3 09/17] net: team: " David Decotigny
2015-11-30 22:05 ` [PATCH net-next v3 10/17] net: fcoe: " David Decotigny
2015-11-30 22:05 ` [PATCH net-next v3 11/17] net: rdma: " David Decotigny
2015-11-30 22:05 ` [PATCH net-next v3 12/17] net: 8021q: " David Decotigny
2015-11-30 22:05 ` [PATCH net-next v3 13/17] net: bridge: " David Decotigny
2015-11-30 22:05 ` [PATCH net-next v3 14/17] net: core: " David Decotigny
2015-11-30 22:05 ` [PATCH net-next v3 15/17] net: ethtool: remove unused __ethtool_get_settings David Decotigny
2015-11-30 22:05 ` [PATCH net-next v3 16/17] net: mlx4: convenience predicate for debug messages David Decotigny
2015-11-30 22:05 ` [PATCH net-next v3 17/17] net: mlx4: use new ETHTOOL_G/SSETTINGS API David Decotigny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).