1. 02 Jan, 2024 35 commits
  2. 01 Jan, 2024 5 commits
    • David S. Miller's avatar
      Merge branch 'phy-listing-link_topology-tracking' · 9fb3dc1e
      David S. Miller authored
      Maxime Chevallier says:
      
      ====================
      Introduce PHY listing and link_topology tracking
      
      Here's a V5 of the multi-PHY support series.
      
      At a glance, besides some minor fixes and R'd-by from Andrew, one of the
      thing this series does is remove the ASSERT_RTNL() from the
      topo_add_phy/del_phy operations.
      
      These operations will take a PHY device and put it into the list of
      devices associated to a netdevice. The main thing to protect here is the
      list itself, but since we use xarrays, my naive understanding of it is
      that it contains its own protection scheme. There shouldn't be a need
      for more locking, as the insertion/deletion paths are already hooked
      into the PHY connection to a netdev, or disconnection from it.
      
      Now for the rest of the cover :
      
      As a remainder, this ongoing work aims ultimately at supporting complex
      link topologies that involve multiplexing multiple PHYs/SFPs on a single
      netdevice. As a first step, it's required that we are able to enumerate the
      PHYs on a given ethernet interface.
      
      By just doing so, we also improve already-existing use-cases, namely the
      copper SFP modules support when a media-converter is used (as we have 2
      PHYs on the link, but only one is referenced by net_device.phydev, which
      is used on a variety of netlink commands).
      
      The series is architectured as follows :
      
      - The first patch adds the notion of phy_link_topology, which tracks
      all PHYs attached to a netdevice.
      
      - Patches 2, 3 and 4 adds some plumbing into SFP and phylib to be able
        to connect the dots when building the topology tree, to know which PHY
        is connected to which SFP bus, trying not to be too invasive on phylib.
      
      - Patch 5 allows passing a PHY_INDEX to ethnl commands. I'm uncertain about
        this, as there are at least 4 netlink commands ( 5 with the one introduced
        in patch 7 ) that targets PHYs directly or indirectly, which to me makes
        it worth-it to have a generic way to pass a PHY index to commands, however
        the approach taken may be too generic.
      
      - Patch 6 is the netlink spec update + ethtool-user.c|h autogenerated code
      update (the autogenerated code triggers checkpatch warning though)
      
      - Patch 7 introduces a new netlink command set to list PHYs on a netdevice.
      It implements a custom DUMP and GET operation to allow filtered dumps,
      that lists all PHYs on a given netdevice. I couldn't use most of ethnl's
      plumbing though.
      
      - Patch 8 is the netlink spec update + ethtool-user.c|h update for that
      new command
      
      - Patch 8,9,10 and 11 updates the PLCA, strset, cable-test and pse netlink
      commands to use the user-provided PHY instead of net_device.phydev.
      
      - Finally patch 12 adds some documentation for this whole work.
      
      Examples
      ========
      
      Here's a short overview of the kind of operations you can have regarding
      the PHY topology. These tests were performed on a MacchiatoBin, which
      has 3 interfaces :
      
      eth0 and eth1 have the following layout:
      
      MAC - PHY - SFP
      
      eth2 has this more classic topology :
      
      MAC - PHY - RJ45
      
      finally eth3 has the following topology :
      
      MAC - SFP
      
      When performing a dump with all interfaces down, we don't get any
      result, as no PHY has been attached to their respective net_device :
      
      None
      
      The following output is with eth0, eth2 and eth3 up, but no SFP module
      inserted in none of the interfaces :
      
      [{'downstream-sfp-name': 'sfp-eth0',
        'drvname': 'mv88x3310',
        'header': {'dev-index': 2, 'dev-name': 'eth0'},
        'id': 0,
        'index': 1,
        'name': 'f212a600.mdio-mii:00',
        'upstream-type': 'mac'},
       {'drvname': 'Marvell 88E1510',
        'header': {'dev-index': 4, 'dev-name': 'eth2'},
        'id': 21040593,
        'index': 1,
        'name': 'f212a200.mdio-mii:00',
        'upstream-type': 'mac'}]
      
      And now is a dump operation with a copper SFP in the eth0 port :
      
      [{'downstream-sfp-name': 'sfp-eth0',
        'drvname': 'mv88x3310',
        'header': {'dev-index': 2, 'dev-name': 'eth0'},
        'id': 0,
        'index': 1,
        'name': 'f212a600.mdio-mii:00',
        'upstream-type': 'mac'},
       {'drvname': 'Marvell 88E1111',
        'header': {'dev-index': 2, 'dev-name': 'eth0'},
        'id': 21040322,
        'index': 2,
        'name': 'i2c:sfp-eth0:16',
        'upstream': {'index': 1, 'sfp-name': 'sfp-eth0'},
        'upstream-type': 'phy'},
       {'drvname': 'Marvell 88E1510',
        'header': {'dev-index': 4, 'dev-name': 'eth2'},
        'id': 21040593,
        'index': 1,
        'name': 'f212a200.mdio-mii:00',
        'upstream-type': 'mac'}]
      
       -- Note that this shouldn't actually work as the 88x3310 PHY doesn't allow
      a 1G SFP to be connected to its SFP interface, and I don't have a 10G copper SFP,
      so for the sake of the demo I applied the following modification, which
      of courses gives a non-functionnal link, but the PHY attach still works,
      which is what I want to demonstrate :
      
      @@ -488,7 +488,7 @@ static int mv3310_sfp_insert(void *upstream, const struct sfp_eeprom_id *id)
      
              if (iface != PHY_INTERFACE_MODE_10GBASER) {
                      dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n");
      -               return -EINVAL;
      +               //return -EINVAL;
              }
              return 0;
       }
      
      Finally an example of the filtered DUMP operation that Jakub suggested
      in V1 :
      
      [{'downstream-sfp-name': 'sfp-eth0',
        'drvname': 'mv88x3310',
        'header': {'dev-index': 2, 'dev-name': 'eth0'},
        'id': 0,
        'index': 1,
        'name': 'f212a600.mdio-mii:00',
        'upstream-type': 'mac'},
       {'drvname': 'Marvell 88E1111',
        'header': {'dev-index': 2, 'dev-name': 'eth0'},
        'id': 21040322,
        'index': 2,
        'name': 'i2c:sfp-eth0:16',
        'upstream': {'index': 1, 'sfp-name': 'sfp-eth0'},
        'upstream-type': 'phy'}]
      
      And a classic GET operation allows querying a single PHY's info :
      
      {'drvname': 'Marvell 88E1111',
       'header': {'dev-index': 2, 'dev-name': 'eth0'},
       'id': 21040322,
       'index': 2,
       'name': 'i2c:sfp-eth0:16',
       'upstream': {'index': 1, 'sfp-name': 'sfp-eth0'},
       'upstream-type': 'phy'}
      
      Changed in V5:
      - Removed the RTNL assertion in the topology ops
      - Made the phy_topo_get_phy inline
      - Fixed the PSE-PD multi-PHY support by re-adding a wrongly dropped
        check
      - Fixed some typos in the documentation
      - Fixed reverse xmas trees
      
      Changes in V4:
      - Dropped the RFC flag
      - Made the net_device integration independent to having phylib enabled
      - Removed the autogenerated ethtool-user code for the YNL specs
      
      Changes in V3:
      - Added RTNL assertions where needed
      - Fixed issues in the DUMP code for PHY_GET, which crashed when running it
        twice in a row
      - Added the documentation, and moved in-source docs around
      - renamed link_topology to phy_link_topology
      
      Changes in V2:
      - Added the DUMP operation
      - Added much more information in the reported data, to be able to reconstruct
        precisely the topology tree
      - renamed phy_list to link_topology
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9fb3dc1e
    • Maxime Chevallier's avatar
      Documentation: networking: document phy_link_topology · 32bb4515
      Maxime Chevallier authored
      The newly introduced phy_link_topology tracks all ethernet PHYs that are
      attached to a netdevice. Document the base principle, internal and
      external APIs. As the phy_link_topology is expected to be extended, this
      documentation will hold any further improvements and additions made
      relative to topology handling.
      Signed-off-by: default avatarMaxime Chevallier <maxime.chevallier@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      32bb4515
    • Maxime Chevallier's avatar
      net: ethtool: strset: Allow querying phy stats by index · d078d480
      Maxime Chevallier authored
      The ETH_SS_PHY_STATS command gets PHY statistics. Use the phydev pointer
      from the ethnl request to allow query phy stats from each PHY on the
      link.
      Signed-off-by: default avatarMaxime Chevallier <maxime.chevallier@bootlin.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d078d480
    • Maxime Chevallier's avatar
      net: ethtool: cable-test: Target the command to the requested PHY · fcc4b105
      Maxime Chevallier authored
      Cable testing is a PHY-specific command. Instead of targeting the command
      towards dev->phydev, use the request to pick the targeted PHY.
      Signed-off-by: default avatarMaxime Chevallier <maxime.chevallier@bootlin.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fcc4b105
    • Maxime Chevallier's avatar
      net: ethtool: pse-pd: Target the command to the requested PHY · 345237db
      Maxime Chevallier authored
      PSE and PD configuration is a PHY-specific command. Instead of targeting
      the command towards dev->phydev, use the request to pick the targeted
      PHY device.
      Signed-off-by: default avatarMaxime Chevallier <maxime.chevallier@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      345237db