1. 07 Aug, 2017 19 commits
    • David S. Miller's avatar
      Merge branch 'phylink-and-sfp-support' · 23470933
      David S. Miller authored
      Russell King says:
      
      ====================
      phylink and sfp support
      
      This patch series introduces generic support for SFP sockets found on
      various Marvell based platforms.  The idea here is to provide common
      SFP socket support which can be re-used by network drivers as
      appropriate, rather than each network driver having to re-implement
      SFP socket support.
      
      SFP sockets typically use other system resources, eg, I2C buses to read
      identifying information, and GPIOs to monitor socket state and control
      the socket.  Meanwhile, some network drivers drive multiple ethernet
      ports from one instantiation of the driver.
      
      It is not desirable to block the initialisation of a network driver
      (thus denying other ports from being operational) if the resources
      for the SFP socket are not yet available.  This means that an element
      of independence between the SFP support code and the driver is
      required.
      
      More than that, SFP modules effectively bring hotplug PHYs to
      networking - SFP copper modules normally contain a standard PHY
      accessed over the I2C bus, and it is desirable to read their state
      so network drivers can be appropriately configured.
      
      To add to the complexity, SFP modules can be connected in at least
      two places:
      
      1. Directly to the serdes output of a MAC with no intervening PHY.
         For example:
      
           mvneta ----> SFP socket
      
      2. To a PHY, for example:
      
           mvpp2 ---> PHY ---> copper
                       |
                       `-----> SFP socket
      
      This code supports both setups, although it's not fully implemented
      with scenario (2).
      
      Moreover, the link presented by the SFP module can be one of the
      10Gbase-R family (for SFP+ sockets), SGMII or 1000base-X (for SFP
      sockets) depending on the module, and network drivers need to
      reconfigure themselves accordingly for the link to come up.
      
      For example, if the MAC is configured for SGMII and a fibre module
      is plugged in, the link won't come up until the MAC is reconfigured
      for 1000base-X mode.
      
      The SFP code manages the SFP socket - detecting the module, reading
      the identifying information, and managing the control and status
      signals.  Importantly, it disables the SFP module transmitter when
      the MAC is down, so that the laser is turned off (but that is not
      a guarantee.)
      
      phylink provides the mechanisms necessary to manage the link modes,
      based on the SFP module type, and supports hot-plugging of the PHY
      without needing the MAC driver to be brought up and down on
      transitions.  phylink also supports the classical static PHY and
      fixed-link modes.
      
      I currently (but not included in this series) have code to convert
      mvneta to use phylink, and the out of tree mvpp2x driver.  I have
      nothing for the mvpp2 driver at present as that driver is only
      recently becoming functional on 10G hardware, and is missing a lot
      of features that are necessary to make things work correctly.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      23470933
    • Russell King's avatar
      sfp: add SFP module support · 73970055
      Russell King authored
      Add support for SFP hotpluggable modules via sfp-bus and phylink.
      This supports both copper and optical SFP modules, which require
      different Serdes modes in order to properly negotiate the link.
      
      Optical SFP modules typically require the Serdes link to be talking
      1000BaseX mode - this is the gigabit ethernet mode defined by the
      802.3 standard.
      
      Copper SFP modules typically integrate a PHY in the module to convert
      from Serdes to copper, and the PHY will be configured by the vendor
      to either present a 1000BaseX Serdes link (for fixed 1000BaseT) or a
      SGMII Serdes link.  However, this is vendor defined, so we instead
      detect the PHY, switch the link to SGMII mode, and use traditional
      PHY based negotiation.
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      73970055
    • Russell King's avatar
      phylink: add in-band autonegotiation support for 10GBase-KR mode. · da7c1862
      Russell King authored
      Add in-band autonegotation support for 10GBase-KR mode.
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      da7c1862
    • Russell King's avatar
      phylink: add support for MII ioctl access to Clause 45 PHYs · ecbd87b8
      Russell King authored
      Add support for reading and writing the clause 45 MII registers.
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ecbd87b8
    • Russell King's avatar
      phylink: add module EEPROM support · 770a1ad5
      Russell King authored
      Add support for reading module EEPROMs through phylink.
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      770a1ad5
    • Russell King's avatar
    • Russell King's avatar
      phylink: add phylink infrastructure · 9525ae83
      Russell King authored
      The link between the ethernet MAC and its PHY has become more complex
      as the interface evolves.  This is especially true with serdes links,
      where the part of the PHY is effectively integrated into the MAC.
      
      Serdes links can be connected to a variety of devices, including SFF
      modules soldered down onto the board with the MAC, a SFP cage with
      a hotpluggable SFP module which may contain a PHY or directly modulate
      the serdes signals onto optical media with or without a PHY, or even
      a classical PHY connection.
      
      Moreover, the negotiation information on serdes links comes in two
      varieties - SGMII mode, where the PHY provides its speed/duplex/flow
      control information to the MAC, and 1000base-X mode where both ends
      exchange their abilities and each resolve the link capabilities.
      
      This means we need a more flexible means to support these arrangements,
      particularly with the hotpluggable nature of SFP, where the PHY can
      be attached or detached after the network device has been brought up.
      
      Ethtool information can come from multiple sources:
      - we may have a PHY operating in either SGMII or 1000base-X mode, in
        which case we take ethtool/mii data directly from the PHY.
      - we may have a optical SFP module without a PHY, with the MAC
        operating in 1000base-X mode - the ethtool/mii data needs to come
        from the MAC.
      - we may have a copper SFP module with a PHY whic can't be accessed,
        which means we need to take ethtool/mii data from the MAC.
      
      Phylink aims to solve this by providing an intermediary between the
      MAC and PHY, providing a safe way for PHYs to be hotplugged, and
      allowing a SFP driver to reconfigure the serdes connection.
      
      Phylink also takes over support of fixed link connections, where the
      speed/duplex/flow control are fixed, but link status may be controlled
      by a GPIO signal.  By avoiding the fixed-phy implementation, phylink
      can provide a faster response to link events: fixed-phy has to wait for
      phylib to operate its state machine, which can take several seconds.
      In comparison, phylink takes milliseconds.
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      
      - remove sync status
      - rework supported and advertisment handling
      - add 1000base-x speed for fixed links
      - use functionality exported from phy-core, reworking
        __phylink_ethtool_ksettings_set for it
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9525ae83
    • Russell King's avatar
      net: phy: add I2C mdio bus · 453d00de
      Russell King authored
      Add an I2C MDIO bus bridge library, to allow phylib to access PHYs which
      are connected to an I2C bus instead of the more conventional MDIO bus.
      Such PHYs can be found in SFP adapters and SFF modules.
      
      Since PHYs appear at I2C bus address 0x40..0x5f, and 0x50/0x51 are
      reserved for SFP EEPROMs/diagnostics, we must not allow the MDIO bus
      to access these I2C addresses.
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      453d00de
    • Russell King's avatar
      net: phy: export phy_start_machine() for phylink · 5e5758d9
      Russell King authored
      phylink will need phy_start_machine exported, so lets export it as a
      GPL symbol.  Documentation/networking/phy.txt indicates that this
      should be a PHY API function.
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5e5758d9
    • Russell King's avatar
      net: phy: provide a hook for link up/link down events · a81497be
      Russell King authored
      Sometimes, we need to do additional work between the PHY coming up and
      marking the carrier present - for example, we may need to wait for the
      PHY to MAC link to finish negotiation.  This changes phylib to provide
      a notification function pointer which avoids the built-in
      netif_carrier_on() and netif_carrier_off() functions.
      
      Standard ->adjust_link functionality is provided by hooking a helper
      into the new ->phy_link_change method.
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a81497be
    • Russell King's avatar
      net: phy: add 1000Base-X to phy settings table · 1f3645bb
      Russell King authored
      Add the missing 1000Base-X entry to the phy settings table.  This was
      not included because the original code could not cope with more than
      32 bits of link mode mask.
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1f3645bb
    • Russell King's avatar
      net: phy: move phy_lookup_setting() and guts of phy_supported_speeds() to phy-core · 0ccb4fc6
      Russell King authored
      phy_lookup_setting() provides useful functionality in ethtool code
      outside phylib.  Move it to phy-core and allow it to be re-used (eg,
      in phylink) rather than duplicated elsewhere.  Note that this supports
      the larger linkmode space.
      
      As we move the phy settings table, we also need to move the guts of
      phy_supported_speeds() as well.
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0ccb4fc6
    • Russell King's avatar
      net: phy: split out PHY speed and duplex string generation · da4625ac
      Russell King authored
      Other code would like to make use of this, so make the speed and duplex
      string generation visible, and place it in a separate file.
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      da4625ac
    • Russell King's avatar
      net: phy: allow settings table to support more than 32 link modes · c3ecbe75
      Russell King authored
      Allow the phy settings table to support more than 32 link modes by
      switching to the ethtool link mode bit number representation, rather
      than storing the mask.  This will allow phylink and other ethtool
      code to share the settings table to look up settings.
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c3ecbe75
    • David S. Miller's avatar
      Merge branch 'IP-cleanup-LSRR-option-processing' · 21e27f2d
      David S. Miller authored
      Paolo Abeni says:
      
      ====================
      IP: cleanup LSRR option processing
      
      The __ip_options_echo() function expect a valid dst entry in skb->dst;
      as result we sometimes need to preserve the dst entry for the whole IP
      RX path.
      
      The current usage of skb->dst looks more a relic from ancient past that
      a real functional constraint. This patchset tries to remove such usage,
      and than drops some hacks currently in place in the IP code to keep
      skb->dst around.
      
      __ip_options_echo() uses of skb->dst for two different purposes: retrieving
      the netns assicated with the skb, and modify the ingress packet LSRR address
      list.
      
      The first patch removes the code modifying the ingress packet, and the second
      one provides an explicit netns argument to __ip_options_echo(). The following
      patches cleanup the current code keeping arund skb->dst for __ip_options_echo's
      sake.
      
      Updating the __ip_options_echo() function has been previously discussed here:
      
      http://marc.info/?l=linux-netdev&m=150064533516348&w=2
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      21e27f2d
    • Paolo Abeni's avatar
      udp: no need to preserve skb->dst · 3bdefdf9
      Paolo Abeni authored
      __ip_options_echo() does not need anymore skb->dst, so we can
      avoid explicitly preserving it for its own sake.
      
      This is almost a revert of commit 0ddf3fb2 ("udp: preserve
      skb->dst if required for IP options processing") plus some
      lifting to fit later changes.
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3bdefdf9
    • Paolo Abeni's avatar
      Revert "ipv4: keep skb->dst around in presence of IP options" · 61a1030b
      Paolo Abeni authored
      ip_options_echo() does not use anymore the skb->dst and don't
      need to keep the dst around for options's sake only.
      This reverts commit 34b2cef2.
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      61a1030b
    • Paolo Abeni's avatar
      ip/options: explicitly provide net ns to __ip_options_echo() · 91ed1e66
      Paolo Abeni authored
      __ip_options_echo() uses the current network namespace, and
      currently retrives it via skb->dst->dev.
      
      This commit adds an explicit 'net' argument to __ip_options_echo()
      and update all the call sites to provide it, usually via a simpler
      sock_net().
      
      After this change, __ip_options_echo() no more needs to access
      skb->dst and we can drop a couple of hack to preserve such
      info in the rx path.
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      91ed1e66
    • Paolo Abeni's avatar
      IP: do not modify ingress packet IP option in ip_options_echo() · a1e155ec
      Paolo Abeni authored
      While computing the response option set for LSRR, ip_options_echo()
      also changes the ingress packet LSRR addresses list, setting
      the last one to the dst specific address for the ingress packet
      - via memset(start[ ...
      The only visible effect of such change - beyond possibly damaging
      shared/cloned skbs - is modifying the data carried by ICMP replies
      changing the header information for reported the ingress packet,
      which violates RFC1122 3.2.2.6.
      All the others call sites just ignore the ingress packet IP options
      after calling ip_options_echo()
      Note that the last element in the LSRR option address list for the
      reply packet will be properly set later in the ip output path
      via ip_options_build().
      This buggy memset() predates git history and apparently was present
      into the initial ip_options_echo() implementation in linux 1.3.30 but
      still looks wrong.
      
      The removal of the fib_compute_spec_dst() call will help
      completely dropping the skb->dst usage by __ip_options_echo() with a
      later patch.
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a1e155ec
  2. 05 Aug, 2017 1 commit
  3. 04 Aug, 2017 20 commits