Skip to content
  1. Jan 08, 2020
  2. Jan 07, 2020
  3. Jan 06, 2020
    • David S. Miller's avatar
      Merge branch 'Convert-Felix-DSA-switch-to-PHYLINK' · df2c2ba8
      David S. Miller authored
      Vladimir Oltean says:
      
      ====================
      Convert Felix DSA switch to PHYLINK
      
      Unlike most other conversions, this one is not by far a trivial one, and should
      be seen as "Layerscape PCS meets PHYLINK". Actually, the PCS doesn't
      need a lot of hand-holding and most of our other devices 'just work'
      (this one included) without any sort of operating system awareness, just
      an initialization procedure done typically in the bootloader.
      Our issues start when the PCS stops from "just working", and that is
      where PHYLINK comes in handy.
      
      The PCS is not specific to the Vitesse / Microsemi / Microchip switching core
      at all. Variations of this SerDes/PCS design can also be found on DPAA1 and
      DPAA2 hardware.
      
      The main idea of the abstraction provided is that the PCS looks so much like a
      PHY device, that we model it as an actual PHY device and run the generic PHY
      functions on it, where appropriate.
      
      The 4xSGMII, QSGMII and QSXGMII modes are fairly straightforward.
      
      The SerDes protocol which the driver calls 2500Base-X mode (a misnomer) is more
      interesting. There is a description of how it works and what can be done with
      it in patch 9/9 (in a comment above vsc9959_pcs_init_2500basex).
      In short, it is a fixed speed protocol with no auto-negotiation whatsoever.
      From my research of the SGMII-2500 patent [1], it has nothing to do with
      SGMII-2500. That one:
      * does not define any change to the AN base page compared to plain 10/100/1000
        SGMII. This implies that the 2500 speed is not negotiable, but the other
        speeds are. In our case, when the SerDes is configured for this protocol it's
        configured for good, there's no going back to SGMII.
      * runs at a higher base frequency than regular SGMII. So SGMII-2500 operating
        at 1000 Mbps wouldn't interoperate with plain SGMII at 1000 Mbps. Strange,
        but ok..
      * Emulates lower link speeds than 2500 by duplicating the codewords twice, then
        thrice, then twice again etc (2.5/25/250 times on average). The Layerscape
        PCS doesn't do that (it is fixed at 2500 Mbaud).
      
      But on the other hand it isn't completely compatible with Base-X either,
      since it doesn't do 802.3z / clause 37 auto negotiation (flow control,
      local/remote fault etc). It is compatible with 2500Base-X without
      in-band AN, and that is exactly how we decided to expose it (this is
      actually similar to what others do).
      
      For SGMII and USXGMII, the driver is using the PHYLINK 'managed =
      "in-band-status"' DTS binding to figure out whether in-band AN is
      expected to be enabled in the PCS or not. It is expected that the
      attached PHY follows suite, but there is a gap here: the PHY driver does
      not react to this setting, so only one of "AN on" and "AN off" works on
      any particular PHY, even though that PHY might support bypassing the
      SGMII AN process, as is the case on the VSC8514 PHY present on the
      LS1028A-RDB board. A separate series will be sent to propose a way to
      deal with that.
      
      I dropped the Ocelot PHYLINK conversion because:
      * I don't have VSC7514 hardware anyway
      * The hardware is so different in this regard that there's almost nothing to
        share anyway.
      
      Changes in v5:
      
      - Added the register write to DEV_CLOCK_CFG back in
        felix_phylink_mac_config in patch 9/9.
      
      Changes in v4:
      
      - This is mostly a resend of v3, with the only notable change that I've
        dropped the PHY core patches for in_band_autoneg and I'll propose them
        independently.
      
      v1 series:
      https://www.spinics.net/lists/netdev/msg613869.html
      
      RFC v2 series:
      https://www.spinics.net/lists/netdev/msg620128.html
      
      v3 series:
      https://www.spinics.net/lists/netdev/msg622060.html
      
      v4 series:
      https://www.spinics.net/lists/netdev/msg622606.html
      
      [0]: https://www.spinics.net/lists/netdev/msg613869.html
      [1]: https://patents.google.com/patent/US7356047B1/en
      
      
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      df2c2ba8
    • Vladimir Oltean's avatar
      net: dsa: felix: Add PCS operations for PHYLINK · bdeced75
      Vladimir Oltean authored
      
      
      Layerscape SoCs traditionally expose the SerDes configuration/status for
      Ethernet protocols (PCS for SGMII/USXGMII/10GBase-R etc etc) in a register
      format that is compatible with clause 22 or clause 45 (depending on
      SerDes protocol). Each MAC has its own internal MDIO bus on which there
      is one or more of these PCS's, responding to commands at a configurable
      PHY address. The per-port internal MDIO bus (which is just for PCSs) is
      totally separate and has nothing to do with the dedicated external MDIO
      controller (which is just for PHYs), but the register map for the MDIO
      controller is the same.
      
      The VSC9959 (Felix) switch instantiated in the LS1028A is integrated
      in hardware with the ENETC PCS of its DSA master, and reuses its MDIO
      controller driver, so Felix has been made to depend on it in Kconfig.
      
       +------------------------------------------------------------------------+
       |                   +--------+ GMII (typically disabled via RCW)         |
       | ENETC PCI         |  ENETC |--------------------------+                |
       | Root Complex      | port 3 |-----------------------+  |                |
       | Integrated        +--------+                       |  |                |
       | Endpoint                                           |  |                |
       |                   +--------+ 2.5G GMII             |  |                |
       |                   |  ENETC |--------------+        |  |                |
       |                   | port 2 |-----------+  |        |  |                |
       |                   +--------+           |  |        |  |                |
       |                                     +--------+  +--------+             |
       |                                     |  Felix |  |  Felix |             |
       |                                     | port 4 |  | port 5 |             |
       |                                     +--------+  +--------+             |
       |                                                                        |
       | +--------+  +--------+  +--------+  +--------+  +--------+  +--------+ |
       | |  ENETC |  |  ENETC |  |  Felix |  |  Felix |  |  Felix |  |  Felix | |
       | | port 0 |  | port 1 |  | port 0 |  | port 1 |  | port 2 |  | port 3 | |
       +------------------------------------------------------------------------+
       |    ||||  SerDes |          ||||        ||||        ||||        ||||    |
       | +--------+block |       +--------------------------------------------+ |
       | |  ENETC |      |       |       ENETC port 2 internal MDIO bus       | |
       | | port 0 |      |       |  PCS         PCS          PCS        PCS   | |
       | |   PCS  |      |       |   0           1            2          3    | |
       +-----------------|------------------------------------------------------+
              v          v           v           v            v          v
           SGMII/      RGMII    QSGMII/QSXGMII/4xSGMII/4x1000Base-X/4x2500Base-X
          USXGMII/   (bypasses
        1000Base-X/   SerDes)
        2500Base-X
      
      In the LS1028A SoC described above, the VSC9959 Felix switch is PF5 of
      the ENETC root complex, and has 2 BARs:
      - BAR 4: the switch's effective registers
      - BAR 0: the MDIO controller register map lended from ENETC port 2
               (PF2), for accessing its associated PCS's.
      
      This explanation is necessary because the patch does some renaming
      "pci_bar" -> "switch_pci_bar" for clarity, which would otherwise appear
      a bit obtuse.
      
      The fact that the internal MDIO bus is "borrowed" is relevant because
      the register map is found in PF5 (the switch) but it triggers an access
      fault if PF2 (the ENETC DSA master) is not enabled. This is not treated
      in any way (and I don't think it can be treated).
      
      All of this is so SoC-specific, that it was contained as much as
      possible in the platform-integration file felix_vsc9959.c.
      
      We need to parse and pre-validate the device tree because of 2 reasons:
      - The PHY mode (SerDes protocol) cannot change at runtime due to SoC
        design.
      - There is a circular dependency in that we need to know what clause the
        PCS speaks in order to find it on the internal MDIO bus. But the
        clause of the PCS depends on what phy-mode it is configured for.
      
      The goal of this patch is to make steps towards removing the bootloader
      dependency for SGMII PCS pre-configuration, as well as to add support
      for monitoring the in-band SGMII AN between the PCS and the system-side
      link partner (PHY or other MAC).
      
      In practice the bootloader dependency is not completely removed. U-Boot
      pre-programs the PHY address at which each PCS can be found on the
      internal MDIO bus (MDEV_PORT). This is needed because the PCS of each
      port has the same out-of-reset PHY address of zero. The SerDes register
      for changing MDEV_PORT is pretty deep in the SoC (outside the addresses
      of the ENETC PCI BARs) and therefore inaccessible to us from here.
      
      Felix VSC9959 and Ocelot VSC7514 are integrated very differently in
      their respective SoCs, and for that reason Felix does not use the Ocelot
      core library for PHYLINK. On one hand we don't want to impose the
      fixed phy-mode limitation to Ocelot, and on the other hand Felix doesn't
      need to force the MAC link speed the way Ocelot does, since the MAC is
      connected to the PCS through a fixed GMII, and the PCS is the one who
      does the rate adaptation at lower link speeds, which the MAC does not
      even need to know about. In fact changing the GMII speed for Felix
      irrecoverably breaks transmission through that port until a reset.
      
      The pair with ENETC port 3 and Felix port 5 is optional and doesn't
      support tagging. When we enable it, swp5 is a regular slave port, albeit
      an internal one. The trouble is that it doesn't work, and that is
      because the DSA PHYLIB adaptation layer doesn't treat fixed-link slave
      ports. So that is yet another reason for wanting to convert Felix to the
      native PHYLINK API.
      
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bdeced75