1. 03 10月, 2022 1 次提交
    • M
      net: phylink: pass supported host PHY interface modes to phylib for SFP's PHYs · eca68a3c
      Marek Behún 提交于
      Pass the supported PHY interface types to phylib if the PHY we are
      connecting is inside a SFP, so that the PHY driver can select an
      appropriate host configuration mode for their interface according to
      the host capabilities.
      
      For example the Marvell 88X3310 PHY inside RollBall SFP modules
      defaults to 10gbase-r mode on host's side, and the marvell10g
      driver currently does not change this setting. But a host may not
      support 10gbase-r. For example Turris Omnia only supports sgmii,
      1000base-x and 2500base-x modes. The PHY can be configured to use
      those modes, but in order for the PHY driver to do that, it needs
      to know which modes are supported.
      Signed-off-by: NMarek Behún <kabel@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      eca68a3c
  2. 23 9月, 2022 1 次提交
    • S
      net: phy: Add support for rate matching · 0c3e10cb
      Sean Anderson 提交于
      This adds support for rate matching (also known as rate adaptation) to
      the phy subsystem. The general idea is that the phy interface runs at
      one speed, and the MAC throttles the rate at which it sends packets to
      the link speed. There's a good overview of several techniques for
      achieving this at [1]. This patch adds support for three: pause-frame
      based (such as in Aquantia phys), CRS-based (such as in 10PASS-TS and
      2BASE-TL), and open-loop-based (such as in 10GBASE-W).
      
      This patch makes a few assumptions and a few non assumptions about the
      types of rate matching available. First, it assumes that different phys
      may use different forms of rate matching. Second, it assumes that phys
      can use rate matching for any of their supported link speeds (e.g. if a
      phy supports 10BASE-T and XGMII, then it can adapt XGMII to 10BASE-T).
      Third, it does not assume that all interface modes will use the same
      form of rate matching. Fourth, it does not assume that all phy devices
      will support rate matching (even if some do). Relaxing or strengthening
      these (non-)assumptions could result in a different API. For example, if
      all interface modes were assumed to use the same form of rate matching,
      then a bitmask of interface modes supportting rate matching would
      suffice.
      
      For some better visibility into the process, the current rate matching
      mode is exposed as part of the ethtool ksettings. For the moment, only
      read access is supported. I'm not sure what userspace might want to
      configure yet (disable it altogether, disable just one mode, specify the
      mode to use, etc.). For the moment, since only pause-based rate
      adaptation support is added in the next few commits, rate matching can
      be disabled altogether by adjusting the advertisement.
      
      802.3 calls this feature "rate adaptation" in clause 49 (10GBASE-R) and
      "rate matching" in clause 61 (10PASS-TL and 2BASE-TS). Aquantia also calls
      this feature "rate adaptation". I chose "rate matching" because it is
      shorter, and because Russell doesn't think "adaptation" is correct in this
      context.
      Signed-off-by: NSean Anderson <sean.anderson@seco.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0c3e10cb
  3. 05 9月, 2022 1 次提交
    • S
      net: phy: Add 1000BASE-KX interface mode · 05ad5d45
      Sean Anderson 提交于
      Add 1000BASE-KX interface mode. This 1G backplane ethernet as described in
      clause 70. Clause 73 autonegotiation is mandatory, and only full duplex
      operation is supported.
      
      Although at the PMA level this interface mode is identical to
      1000BASE-X, it uses a different form of in-band autonegation. This
      justifies a separate interface mode, since the interface mode (along
      with the MLO_AN_* autonegotiation mode) sets the type of autonegotiation
      which will be used on a link. This results in more than just electrical
      differences between the link modes.
      
      With regard to 1000BASE-X, 1000BASE-KX holds a similar position to
      SGMII: same signaling, but different autonegotiation. PCS drivers
      (which typically handle in-band autonegotiation) may only support
      1000BASE-X, and not 1000BASE-KX. Similarly, the phy mode is used to
      configure serdes phys with phy_set_mode_ext. Due to the different
      electrical standards (SFI or XFI vs Clause 70), they will likely want to
      use different configuration. Adding a phy interface mode for
      1000BASE-KX helps simplify configuration in these areas.
      Signed-off-by: NSean Anderson <sean.anderson@seco.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      05ad5d45
  4. 22 8月, 2022 2 次提交
  5. 30 6月, 2022 1 次提交
    • L
      net: phy: Don't trigger state machine while in suspend · 1758bde2
      Lukas Wunner 提交于
      Upon system sleep, mdio_bus_phy_suspend() stops the phy_state_machine(),
      but subsequent interrupts may retrigger it:
      
      They may have been left enabled to facilitate wakeup and are not
      quiesced until the ->suspend_noirq() phase.  Unwanted interrupts may
      hence occur between mdio_bus_phy_suspend() and dpm_suspend_noirq(),
      as well as between dpm_resume_noirq() and mdio_bus_phy_resume().
      
      Retriggering the phy_state_machine() through an interrupt is not only
      undesirable for the reason given in mdio_bus_phy_suspend() (freezing it
      midway with phydev->lock held), but also because the PHY may be
      inaccessible after it's suspended:  Accesses to USB-attached PHYs are
      blocked once usb_suspend_both() clears the can_submit flag and PHYs on
      PCI network cards may become inaccessible upon suspend as well.
      
      Amend phy_interrupt() to avoid triggering the state machine if the PHY
      is suspended.  Signal wakeup instead if the attached net_device or its
      parent has been configured as a wakeup source.  (Those conditions are
      identical to mdio_bus_phy_may_suspend().)  Postpone handling of the
      interrupt until the PHY has resumed.
      
      Before stopping the phy_state_machine() in mdio_bus_phy_suspend(),
      wait for a concurrent phy_interrupt() to run to completion.  That is
      necessary because phy_interrupt() may have checked the PHY's suspend
      status before the system sleep transition commenced and it may thus
      retrigger the state machine after it was stopped.
      
      Likewise, after re-enabling interrupt handling in mdio_bus_phy_resume(),
      wait for a concurrent phy_interrupt() to complete to ensure that
      interrupts which it postponed are properly rerun.
      
      The issue was exposed by commit 1ce8b372 ("usbnet: smsc95xx: Forward
      PHY interrupts to PHY driver to avoid polling"), but has existed since
      forever.
      
      Fixes: 541cd3ee ("phylib: Fix deadlock on resume")
      Link: https://lore.kernel.org/netdev/a5315a8a-32c2-962f-f696-de9a26d30091@samsung.com/Reported-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Tested-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Acked-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: stable@vger.kernel.org # v2.6.33+
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Link: https://lore.kernel.org/r/b7f386d04e9b5b0e2738f0125743e30676f309ef.1656410895.git.lukas@wunner.deSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      1758bde2
  6. 17 6月, 2022 1 次提交
  7. 09 5月, 2022 3 次提交
  8. 02 5月, 2022 2 次提交
  9. 11 3月, 2022 1 次提交
  10. 08 3月, 2022 1 次提交
  11. 31 1月, 2022 1 次提交
  12. 08 12月, 2021 1 次提交
  13. 17 11月, 2021 1 次提交
  14. 26 10月, 2021 1 次提交
  15. 25 10月, 2021 1 次提交
  16. 20 7月, 2021 1 次提交
  17. 13 6月, 2021 1 次提交
  18. 12 6月, 2021 3 次提交
  19. 08 6月, 2021 1 次提交
  20. 27 5月, 2021 1 次提交
  21. 21 4月, 2021 1 次提交
  22. 20 4月, 2021 1 次提交
  23. 10 4月, 2021 1 次提交
    • H
      net: phy: make PHY PM ops a no-op if MAC driver manages PHY PM · fba863b8
      Heiner Kallweit 提交于
      Resume callback of the PHY driver is called after the one for the MAC
      driver. The PHY driver resume callback calls phy_init_hw(), and this is
      potentially problematic if the MAC driver calls phy_start() in its resume
      callback. One issue was reported with the fec driver and a KSZ8081 PHY
      which seems to become unstable if a soft reset is triggered during aneg.
      
      The new flag allows MAC drivers to indicate that they take care of
      suspending/resuming the PHY. Then the MAC PM callbacks can handle
      any dependency between MAC and PHY PM.
      Signed-off-by: NHeiner Kallweit <hkallweit1@gmail.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      fba863b8
  24. 25 3月, 2021 1 次提交
  25. 17 2月, 2021 2 次提交
  26. 16 2月, 2021 1 次提交
  27. 12 2月, 2021 1 次提交
  28. 20 1月, 2021 1 次提交
    • A
      mdio, phy: fix -Wshadow warnings triggered by nested container_of() · 7eab14de
      Alexander Lobakin 提交于
      container_of() macro hides a local variable '__mptr' inside. This
      becomes a problem when several container_of() are nested in each
      other within single line or plain macros.
      As C preprocessor doesn't support generating random variable names,
      the sole solution is to avoid defining macros that consist only of
      container_of() calls, or they will self-shadow '__mptr' each time:
      
      In file included from ./include/linux/bitmap.h:10,
                       from drivers/net/phy/phy_device.c:12:
      drivers/net/phy/phy_device.c: In function ‘phy_device_release’:
      ./include/linux/kernel.h:693:8: warning: declaration of ‘__mptr’ shadows a previous local [-Wshadow]
        693 |  void *__mptr = (void *)(ptr);     \
            |        ^~~~~~
      ./include/linux/phy.h:647:26: note: in expansion of macro ‘container_of’
        647 | #define to_phy_device(d) container_of(to_mdio_device(d), \
            |                          ^~~~~~~~~~~~
      ./include/linux/mdio.h:52:27: note: in expansion of macro ‘container_of’
         52 | #define to_mdio_device(d) container_of(d, struct mdio_device, dev)
            |                           ^~~~~~~~~~~~
      ./include/linux/phy.h:647:39: note: in expansion of macro ‘to_mdio_device’
        647 | #define to_phy_device(d) container_of(to_mdio_device(d), \
            |                                       ^~~~~~~~~~~~~~
      drivers/net/phy/phy_device.c:217:8: note: in expansion of macro ‘to_phy_device’
        217 |  kfree(to_phy_device(dev));
            |        ^~~~~~~~~~~~~
      ./include/linux/kernel.h:693:8: note: shadowed declaration is here
        693 |  void *__mptr = (void *)(ptr);     \
            |        ^~~~~~
      ./include/linux/phy.h:647:26: note: in expansion of macro ‘container_of’
        647 | #define to_phy_device(d) container_of(to_mdio_device(d), \
            |                          ^~~~~~~~~~~~
      drivers/net/phy/phy_device.c:217:8: note: in expansion of macro ‘to_phy_device’
        217 |  kfree(to_phy_device(dev));
            |        ^~~~~~~~~~~~~
      
      As they are declared in header files, these warnings are highly
      repetitive and very annoying (along with the one from linux/pci.h).
      
      Convert the related macros from linux/{mdio,phy}.h to static inlines
      to avoid self-shadowing and potentially improve bug-catching.
      No functional changes implied.
      Signed-off-by: NAlexander Lobakin <alobakin@pm.me>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Link: https://lore.kernel.org/r/20210116161246.67075-1-alobakin@pm.meSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      7eab14de
  29. 15 1月, 2021 1 次提交
  30. 17 12月, 2020 1 次提交
  31. 26 11月, 2020 1 次提交
  32. 06 11月, 2020 2 次提交
    • I
      net: phy: add genphy_handle_interrupt_no_ack() · 87de1f05
      Ioana Ciornei 提交于
      It seems there are cases where the interrupts are handled by another
      entity (ie an IRQ controller embedded inside the PHY) and do not need
      any other interraction from phylib. For this kind of PHYs, like the
      RTL8366RB, add the genphy_handle_interrupt_no_ack() function which just
      triggers the link state machine.
      Signed-off-by: NIoana Ciornei <ioana.ciornei@nxp.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      87de1f05
    • I
      net: phy: export phy_error and phy_trigger_machine · 293e9a3d
      Ioana Ciornei 提交于
      These functions are currently used by phy_interrupt() to either signal
      an error condition or to trigger the link state machine. In an attempt
      to actually support shared PHY IRQs, export these two functions so that
      the actual PHY drivers can use them.
      
      Cc: Alexandru Ardelean <alexandru.ardelean@analog.com>
      Cc: Andre Edich <andre.edich@microchip.com>
      Cc: Antoine Tenart <atenart@kernel.org>
      Cc: Baruch Siach <baruch@tkos.co.il>
      Cc: Christophe Leroy <christophe.leroy@c-s.fr>
      Cc: Dan Murphy <dmurphy@ti.com>
      Cc: Divya Koppera <Divya.Koppera@microchip.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Hauke Mehrtens <hauke@hauke-m.de>
      Cc: Heiner Kallweit <hkallweit1@gmail.com>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Kavya Sree Kotagiri <kavyasree.kotagiri@microchip.com>
      Cc: Linus Walleij <linus.walleij@linaro.org>
      Cc: Marco Felsch <m.felsch@pengutronix.de>
      Cc: Marek Vasut <marex@denx.de>
      Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
      Cc: Mathias Kresin <dev@kresin.me>
      Cc: Maxim Kochetkov <fido_max@inbox.ru>
      Cc: Michael Walle <michael@walle.cc>
      Cc: Neil Armstrong <narmstrong@baylibre.com>
      Cc: Nisar Sayed <Nisar.Sayed@microchip.com>
      Cc: Oleksij Rempel <o.rempel@pengutronix.de>
      Cc: Philippe Schenker <philippe.schenker@toradex.com>
      Cc: Willy Liu <willy.liu@realtek.com>
      Cc: Yuiko Oshino <yuiko.oshino@microchip.com>
      Signed-off-by: NIoana Ciornei <ioana.ciornei@nxp.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      293e9a3d