1. 11 Apr, 2021 9 commits
    • David S. Miller's avatar
      Merge branch 'ethtool-eeprom' · 7dc85b59
      David S. Miller authored
      Moshe Shemesh says:
      
      ====================
      ethtool: Extend module EEPROM dump API
      
      Ethtool supports module EEPROM dumps via the `ethtool -m <dev>` command.
      But in current state its functionality is limited - offset and length
      parameters, which are used to specify a linear desired region of EEPROM
      data to dump, is not enough, considering emergence of complex module
      EEPROM layouts such as CMIS 4.0.
      Moreover, CMIS 4.0 extends the amount of pages that may be accessible by
      introducing another parameter for page addressing - banks.
      
      Besides, currently module EEPROM is represented as a chunk of
      concatenated pages, where lower 128 bytes of all pages, except page 00h,
      are omitted. Offset and length are used to address parts of this fake
      linear memory. But in practice drivers, which implement
      get_module_info() and get_module_eeprom() ethtool ops still calculate
      page number and set I2C address on their own.
      
      This series tackles these issues by adding ethtool op, which allows to
      pass page number, bank number and I2C address in addition to offset and
      length parameters to the driver, adds corresponding netlink
      infrastructure and implements the new interface in mlx5 driver.
      
      This allows to extend userspace 'ethtool -m' CLI by adding new
      parameters - page, bank and i2c. New command line format:
       ethtool -m <dev> [hex on|off] [raw on|off] [offset N] [length N] [page N] [bank N] [i2c N]
      
      The consequence of this series is a possibility to dump arbitrary EEPROM
      page at a time, in contrast to dumps of concatenated pages. Therefore,
      offset and length change their semantics and may be used only to specify
      a part of data within half page boundary, which size is currently limited
      to 128 bytes.
      
      As for drivers that support legacy get_module_info() and
      get_module_eeprom() pair, the series addresses it by implementing a
      fallback mechanism. As mentioned earlier, such drivers derive a page
      number from 'global' offset, so this can be done vice versa without
      their involvement thanks to standardization. If kernel netlink handler
      of 'ethtool -m' command detects that new ethtool op is not supported by
      the driver, it calculates offset from given page number and page offset
      and calls old ndos, if they are available.
      ====================
      
      \Signed-off-by: David S. Miller <davem@davemloft.net>
      7dc85b59
    • Andrew Lunn's avatar
      ethtool: wire in generic SFP module access · c97a31f6
      Andrew Lunn authored
      If the device has a sfp bus attached, call its
      sfp_get_module_eeprom_by_page() function, otherwise use the ethtool op
      for the device. This follows how the IOCTL works.
      Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c97a31f6
    • Andrew Lunn's avatar
      phy: sfp: add netlink SFP support to generic SFP code · d740513f
      Andrew Lunn authored
      The new netlink API for reading SFP data requires a new op to be
      implemented. The idea of the new netlink SFP code is that userspace is
      responsible to parsing the EEPROM data and requesting pages, rather
      than have the kernel decide what pages are interesting and returning
      them. This allows greater flexibility for newer formats.
      
      Currently the generic SFP code only supports simple SFPs. Allow i2c
      address 0x50 and 0x51 to be accessed with page and bank must always be
      0. This interface will later be extended when for example QSFP support
      is added.
      Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarVladyslav Tarasiuk <vladyslavt@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d740513f
    • Vladyslav Tarasiuk's avatar
      ethtool: Add fallback to get_module_eeprom from netlink command · 96d971e3
      Vladyslav Tarasiuk authored
      In case netlink get_module_eeprom_by_page() callback is not implemented
      by the driver, try to call old get_module_info() and get_module_eeprom()
      pair. Recalculate parameters to get_module_eeprom() offset and len using
      page number and their sizes. Return error if this can't be done.
      Signed-off-by: default avatarVladyslav Tarasiuk <vladyslavt@nvidia.com>
      Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      96d971e3
    • Andrew Lunn's avatar
      net: ethtool: Export helpers for getting EEPROM info · 95dfc7ef
      Andrew Lunn authored
      There are two ways to retrieve information from SFP EEPROMs.  Many
      devices make use of the common code, and assign the sfp_bus pointer in
      the netdev to point to the bus holding the SFP device. Some MAC
      drivers directly implement ops in there ethool structure.
      
      Export within net/ethtool the two helpers used to call these methods,
      so that they can also be used in the new netlink code.
      Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      95dfc7ef
    • Vladyslav Tarasiuk's avatar
      net/mlx5: Add support for DSFP module EEPROM dumps · 4c88fa41
      Vladyslav Tarasiuk authored
      Allow the driver to recognise DSFP transceiver module ID and therefore
      allow its EEPROM dumps using ethtool.
      Signed-off-by: default avatarVladyslav Tarasiuk <vladyslavt@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4c88fa41
    • Vladyslav Tarasiuk's avatar
      net/mlx5: Implement get_module_eeprom_by_page() · e109d2b2
      Vladyslav Tarasiuk authored
      Implement ethtool_ops::get_module_eeprom_by_page() to enable
      support of new SFP standards.
      Signed-off-by: default avatarVladyslav Tarasiuk <vladyslavt@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e109d2b2
    • Vladyslav Tarasiuk's avatar
      net/mlx5: Refactor module EEPROM query · e19b0a34
      Vladyslav Tarasiuk authored
      Prepare for ethtool_ops::get_module_eeprom_data() implementation by
      extracting common part of mlx5_query_module_eeprom() into a separate
      function.
      Signed-off-by: default avatarVladyslav Tarasiuk <vladyslavt@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e19b0a34
    • Vladyslav Tarasiuk's avatar
      ethtool: Allow network drivers to dump arbitrary EEPROM data · c781ff12
      Vladyslav Tarasiuk authored
      Define get_module_eeprom_by_page() ethtool callback and implement
      netlink infrastructure.
      
      get_module_eeprom_by_page() allows network drivers to dump a part of
      module's EEPROM specified by page and bank numbers along with offset and
      length. It is effectively a netlink replacement for get_module_info()
      and get_module_eeprom() pair, which is needed due to emergence of
      complex non-linear EEPROM layouts.
      Signed-off-by: default avatarVladyslav Tarasiuk <vladyslavt@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c781ff12
  2. 10 Apr, 2021 12 commits
  3. 09 Apr, 2021 19 commits