1. 04 Feb, 2021 19 commits
    • Danielle Ratson's avatar
      net: selftests: Add lanes setting test · f72e2f48
      Danielle Ratson authored
      Test that setting lanes parameter is working.
      
      Set max speed and max lanes in the list of advertised link modes,
      and then try to set max speed with the lanes below max lanes if exists
      in the list.
      
      And then, test that setting number of lanes larger than max lanes fails.
      
      Do the above for both autoneg on and off.
      
      $ ./ethtool_lanes.sh
      
      TEST: 4 lanes is autonegotiated                                     [ OK ]
      TEST: Lanes number larger than max width is not set                 [ OK ]
      TEST: Autoneg off, 4 lanes detected during force mode               [ OK ]
      TEST: Lanes number larger than max width is not set                 [ OK ]
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      f72e2f48
    • Danielle Ratson's avatar
      mlxsw: ethtool: Pass link mode in use to ethtool · 25a96f05
      Danielle Ratson authored
      Currently, when user space queries the link's parameters, as speed and
      duplex, each parameter is passed from the driver to ethtool.
      
      Instead, pass the link mode bit in use.
      In Spectrum-1, simply pass the bit that is set to '1' from PTYS register.
      In Spectrum-2, pass the first link mode bit in the mask of the used
      link mode.
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      25a96f05
    • Danielle Ratson's avatar
      mlxsw: ethtool: Add support for setting lanes when autoneg is off · 763ece86
      Danielle Ratson authored
      Currently, when auto negotiation is set to off, the user can force a
      specific speed or both speed and duplex. The user cannot influence the
      number of lanes that will be forced.
      
      Add support for setting speed along with lanes so one would be able
      to choose how many lanes will be forced.
      
      When lanes parameter is passed from user space, choose the link mode
      that its actual width equals to it.
      Otherwise, the default link mode will be the one that supports the width
      of the port.
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      763ece86
    • Danielle Ratson's avatar
      mlxsw: ethtool: Remove max lanes filtering · 5fc4053d
      Danielle Ratson authored
      Currently, when a speed can be supported by different number of lanes,
      the supported link modes bitmask contains only link modes with a single
      number of lanes.
      
      This was done in order to prevent auto negotiation on number of
      lanes after 50G-1-lane and 100G-2-lanes link modes were introduced.
      
      For example, if a port's max width is 4, only link modes with 4 lanes
      will be presented as supported by that port, so 100G is always achieved by
      4 lanes of 25G.
      
      After the previous patches that allow selection of the number of lanes,
      auto negotiation on number of lanes becomes practical.
      
      Remove that filtering of the maximum number of lanes supported link modes,
      so indeed all the supported and advertised link modes will be shown.
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      5fc4053d
    • Danielle Ratson's avatar
      ethtool: Expose the number of lanes in use · 7dc33f09
      Danielle Ratson authored
      Currently, ethtool does not expose how many lanes are used when the
      link is up.
      
      After adding a possibility to advertise or force a specific number of
      lanes, the lanes in use value can be either the maximum width of the port
      or below.
      
      Extend ethtool to expose the number of lanes currently in use for
      drivers that support it.
      
      For example:
      
      $ ethtool -s swp1 speed 100000 lanes 4
      $ ethtool -s swp2 speed 100000 lanes 4
      $ ip link set swp1 up
      $ ip link set swp2 up
      $ ethtool swp1
      Settings for swp1:
              Supported ports: [ FIBRE         Backplane ]
              Supported link modes:   1000baseT/Full
                                      10000baseT/Full
                                      1000baseKX/Full
                                      10000baseKR/Full
                                      10000baseR_FEC
                                      40000baseKR4/Full
                                      40000baseCR4/Full
                                      40000baseSR4/Full
                                      40000baseLR4/Full
                                      25000baseCR/Full
                                      25000baseKR/Full
                                      25000baseSR/Full
                                      50000baseCR2/Full
                                      50000baseKR2/Full
                                      100000baseKR4/Full
                                      100000baseSR4/Full
                                      100000baseCR4/Full
                                      100000baseLR4_ER4/Full
                                      50000baseSR2/Full
                                      10000baseCR/Full
                                      10000baseSR/Full
                                      10000baseLR/Full
                                      10000baseER/Full
                                      50000baseKR/Full
                                      50000baseSR/Full
                                      50000baseCR/Full
                                      50000baseLR_ER_FR/Full
                                      50000baseDR/Full
                                      100000baseKR2/Full
                                      100000baseSR2/Full
                                      100000baseCR2/Full
                                      100000baseLR2_ER2_FR2/Full
                                      100000baseDR2/Full
                                      200000baseKR4/Full
                                      200000baseSR4/Full
                                      200000baseLR4_ER4_FR4/Full
                                      200000baseDR4/Full
                                      200000baseCR4/Full
              Supported pause frame use: Symmetric Receive-only
              Supports auto-negotiation: Yes
              Supported FEC modes: Not reported
              Advertised link modes:  1000baseT/Full
                                      10000baseT/Full
                                      1000baseKX/Full
                                      1000baseKX/Full
                                      10000baseKR/Full
                                      10000baseR_FEC
                                      40000baseKR4/Full
                                      40000baseCR4/Full
                                      40000baseSR4/Full
                                      40000baseLR4/Full
                                      25000baseCR/Full
                                      25000baseKR/Full
                                      25000baseSR/Full
                                      50000baseCR2/Full
                                      50000baseKR2/Full
                                      100000baseKR4/Full
                                      100000baseSR4/Full
                                      100000baseCR4/Full
                                      100000baseLR4_ER4/Full
                                      50000baseSR2/Full
                                      10000baseCR/Full
                                      10000baseSR/Full
                                      10000baseLR/Full
                                      10000baseER/Full
                                      200000baseKR4/Full
                                      200000baseSR4/Full
                                      200000baseLR4_ER4_FR4/Full
                                      200000baseDR4/Full
                                      200000baseCR4/Full
              Advertised pause frame use: No
              Advertised auto-negotiation: Yes
              Advertised FEC modes: Not reported
              Advertised link modes:  100000baseKR4/Full
                                      100000baseSR4/Full
                                      100000baseCR4/Full
                                      100000baseLR4_ER4/Full
      	Advertised pause frame use: No
      	Advertised auto-negotiation: Yes
      	Advertised FEC modes: Not reported
      	Speed: 100000Mb/s
      	Lanes: 4
      	Duplex: Full
      	Auto-negotiation: on
      	Port: Direct Attach Copper
      	PHYAD: 0
      	Transceiver: internal
      	Link detected: yes
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      7dc33f09
    • Danielle Ratson's avatar
      ethtool: Get link mode in use instead of speed and duplex parameters · c8907043
      Danielle Ratson authored
      Currently, when user space queries the link's parameters, as speed and
      duplex, each parameter is passed from the driver to ethtool.
      
      Instead, get the link mode bit in use, and derive each of the parameters
      from it in ethtool.
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      c8907043
    • Danielle Ratson's avatar
      ethtool: Extend link modes settings uAPI with lanes · 012ce4dd
      Danielle Ratson authored
      Currently, when auto negotiation is on, the user can advertise all the
      linkmodes which correspond to a specific speed, but does not have a
      similar selector for the number of lanes. This is significant when a
      specific speed can be achieved using different number of lanes.  For
      example, 2x50 or 4x25.
      
      Add 'ETHTOOL_A_LINKMODES_LANES' attribute and expand 'struct
      ethtool_link_settings' with lanes field in order to implement a new
      lanes-selector that will enable the user to advertise a specific number
      of lanes as well.
      
      When auto negotiation is off, lanes parameter can be forced only if the
      driver supports it. Add a capability bit in 'struct ethtool_ops' that
      allows ethtool know if the driver can handle the lanes parameter when
      auto negotiation is off, so if it does not, an error message will be
      returned when trying to set lanes.
      
      Example:
      
      $ ethtool -s swp1 lanes 4
      $ ethtool swp1
        Settings for swp1:
      	Supported ports: [ FIBRE ]
              Supported link modes:   1000baseKX/Full
                                      10000baseKR/Full
                                      40000baseCR4/Full
      				40000baseSR4/Full
      				40000baseLR4/Full
                                      25000baseCR/Full
                                      25000baseSR/Full
      				50000baseCR2/Full
                                      100000baseSR4/Full
      				100000baseCR4/Full
              Supported pause frame use: Symmetric Receive-only
              Supports auto-negotiation: Yes
              Supported FEC modes: Not reported
              Advertised link modes:  40000baseCR4/Full
      				40000baseSR4/Full
      				40000baseLR4/Full
                                      100000baseSR4/Full
      				100000baseCR4/Full
              Advertised pause frame use: No
              Advertised auto-negotiation: Yes
              Advertised FEC modes: Not reported
              Speed: Unknown!
              Duplex: Unknown! (255)
              Auto-negotiation: on
              Port: Direct Attach Copper
              PHYAD: 0
              Transceiver: internal
              Link detected: no
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      012ce4dd
    • Danielle Ratson's avatar
      ethtool: Validate master slave configuration before rtnl_lock() · 189e7a8d
      Danielle Ratson authored
      Create a new function for input validations to be called before
      rtnl_lock() and move the master slave validation to that function.
      
      This would be a cleanup for next patch that would add another validation
      to the new function.
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      189e7a8d
    • Vladimir Oltean's avatar
      net: dsa: fix SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING getting ignored · 99b8202b
      Vladimir Oltean authored
      The bridge emits VLAN filtering events and quite a few others via
      switchdev with orig_dev = br->dev. After the blamed commit, these events
      started getting ignored.
      
      The point of the patch was to not offload switchdev objects for ports
      that didn't go through dsa_port_bridge_join, because the configuration
      is unsupported:
      - ports that offload a bonding/team interface go through
        dsa_port_bridge_join when that bonding/team interface is later bridged
        with another switch port or LAG
      - ports that don't offload LAG don't get notified of the bridge that is
        on top of that LAG.
      
      Sadly, a check is missing, which is that the orig_dev is equal to the
      bridge device. This check is compatible with the original intention,
      because ports that don't offload bridging because they use a software
      LAG don't have dp->bridge_dev set.
      
      On a semi-related note, we should not offload switchdev objects or
      populate dp->bridge_dev if the driver doesn't implement .port_bridge_join
      either. However there is no regression associated with that, so it can
      be done separately.
      
      Fixes: 5696c8ae ("net: dsa: Don't offload port attributes on standalone ports")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarTobias Waldekranz <tobias@waldekranz.com>
      Tested-by: default avatarTobias Waldekranz <tobias@waldekranz.com>
      Link: https://lore.kernel.org/r/20210202233109.1591466-1-olteanv@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      99b8202b
    • Jakub Kicinski's avatar
      Merge branch 'chelsio-cxgb-use-threaded-interrupts-for-deferred-work' · 75b8f78f
      Jakub Kicinski authored
      Sebastian Andrzej Siewior says:
      
      ====================
      chelsio: cxgb: Use threaded interrupts for deferred work
      
      Patch #2 fixes an issue in which del_timer_sync() and tasklet_kill() is
      invoked from the interrupt handler. This is probably a rare error case
      since it disables interrupts / the card in that case.
      Patch #1 converts a worker to use a threaded interrupt which is then
      also used in patch #2 instead adding another worker for this task (and
      flush_work() to synchronise vs rmmod).
      ====================
      
      Link: https://lore.kernel.org/r/20210202170104.1909200-1-bigeasy@linutronix.deSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      75b8f78f
    • Sebastian Andrzej Siewior's avatar
      chelsio: cxgb: Disable the card on error in threaded interrupt · 82154580
      Sebastian Andrzej Siewior authored
      t1_fatal_err() is invoked from the interrupt handler. The bad part is
      that it invokes (via t1_sge_stop()) del_timer_sync() and tasklet_kill().
      Both functions must not be called from an interrupt because it is
      possible that it will wait for the completion of the timer/tasklet it
      just interrupted.
      
      In case of a fatal error, use t1_interrupts_disable() to disable all
      interrupt sources and then wake the interrupt thread with
      F_PL_INTR_SGE_ERR as pending flag. The threaded-interrupt will stop the
      card via t1_sge_stop() and not re-enable the interrupts again.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      82154580
    • Sebastian Andrzej Siewior's avatar
      chelsio: cxgb: Replace the workqueue with threaded interrupt · fec7fa0a
      Sebastian Andrzej Siewior authored
      The external interrupt (F_PL_INTR_EXT) needs to be handled in a process
      context and this is accomplished by utilizing a workqueue.
      
      The process context can also be provided by a threaded interrupt instead
      of a workqueue. The threaded interrupt can be used later for other
      interrupt related processing which require non-atomic context without
      using yet another workqueue. free_irq() also ensures that the thread is
      done which is currently missing (the worker could continue after the
      module has been removed).
      
      Save pending flags in pending_thread_intr. Use the same mechanism
      to disable F_PL_INTR_EXT as interrupt source like it is used before the
      worker is scheduled. Enable the interrupt again once
      t1_elmer0_ext_intr_handler() is done.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      fec7fa0a
    • Jakub Kicinski's avatar
      Merge branch 'support-for-octeontx2-98xx-cpt-block' · 462e99a1
      Jakub Kicinski authored
      Srujana Challa says:
      
      ====================
      Support for OcteonTX2 98xx CPT block.
      
      OcteonTX2 series of silicons have multiple variants, the
      98xx variant has two crypto (CPT) blocks to double the crypto
      performance. This patchset adds support for new CPT block(CPT1).
      ====================
      
      Link: https://lore.kernel.org/r/20210202152709.20450-1-schalla@marvell.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      462e99a1
    • Srujana Challa's avatar
      octeontx2-af: Handle CPT function level reset · c57c58fd
      Srujana Challa authored
      When FLR is initiated for a VF (PCI function level reset),
      the parent PF gets a interrupt. PF then sends a message to
      admin function (AF), which then cleans up all resources
      attached to that VF. This patch adds support to handle
      CPT FLR.
      Signed-off-by: default avatarNarayana Prasad Raju Atherya <pathreya@marvell.com>
      Signed-off-by: default avatarSuheil Chandran <schandran@marvell.com>
      Signed-off-by: default avatarSunil Kovvuri Goutham <sgoutham@marvell.com>
      Signed-off-by: default avatarSrujana Challa <schalla@marvell.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      c57c58fd
    • Srujana Challa's avatar
      octeontx2-af: Add support for CPT1 in debugfs · b0f60fab
      Srujana Challa authored
      Adds support to display block CPT1 stats at
      "/sys/kernel/debug/octeontx2/cpt1".
      Signed-off-by: default avatarMahipal Challa <mchalla@marvell.com>
      Signed-off-by: default avatarSrujana Challa <schalla@marvell.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      b0f60fab
    • Srujana Challa's avatar
      octeontx2-af: Mailbox changes for 98xx CPT block · de2854c8
      Srujana Challa authored
      This patch changes CPT mailbox message format to
      support new block CPT1 in 98xx silicon.
      
      cpt_rd_wr_reg ->
          Modify cpt_rd_wr_reg mailbox and its handler to
          accommodate new block CPT1.
      cpt_lf_alloc ->
          Modify cpt_lf_alloc mailbox and its handler to
          configure LFs from a block address out of multiple
          blocks of same type. If a PF/VF needs to configure
          LFs from both the blocks then this mbox should be
          called twice.
      Signed-off-by: default avatarMahipal Challa <mchalla@marvell.com>
      Signed-off-by: default avatarSrujana Challa <schalla@marvell.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      de2854c8
    • Mike Looijmans's avatar
      net: mdiobus: Prevent spike on MDIO bus reset signal · e0183b97
      Mike Looijmans authored
      The mdio_bus reset code first de-asserted the reset by allocating with
      GPIOD_OUT_LOW, then asserted and de-asserted again. In other words, if
      the reset signal defaulted to asserted, there'd be a short "spike"
      before the reset.
      
      Here is what happens depending on the pre-existing state of the reset
      signal:
      Reset (previously asserted):   ~~~|_|~~~~|_______
      Reset (previously deasserted): _____|~~~~|_______
                                        ^ ^    ^
                                        A B    C
      
      At point A, the low going transition is because the reset line is
      requested using GPIOD_OUT_LOW. If the line is successfully requested,
      the first thing we do is set it high _without_ any delay. This is
      point B. So, a glitch occurs between A and B.
      
      We then fsleep() and finally set the GPIO low at point C.
      
      Requesting the line using GPIOD_OUT_HIGH eliminates the A and B
      transitions. Instead we get:
      
      Reset (previously asserted)  : ~~~~~~~~~~|______
      Reset (previously deasserted): ____|~~~~~|______
                                         ^     ^
                                         A     C
      
      Where A and C are the points described above in the code. Point B
      has been eliminated.
      
      The issue was found when we pulled down the reset signal for the
      Marvell 88E1512P PHY (because it requires at least 50ms after POR with
      an active clock). Looking at the reset signal with a scope revealed a
      short spike, point B in the artwork above.
      Signed-off-by: default avatarMike Looijmans <mike.looijmans@topic.nl>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Link: https://lore.kernel.org/r/20210202143239.10714-1-mike.looijmans@topic.nlSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      e0183b97
    • Dan Carpenter's avatar
      net: mscc: ocelot: fix error code in mscc_ocelot_probe() · 4160d9ec
      Dan Carpenter authored
      Probe should return an error code if platform_get_irq_byname() fails
      but it returns success instead.
      
      Fixes: 6c30384e ("net: mscc: ocelot: register devlink ports")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Link: https://lore.kernel.org/r/YBkXyFIl4V9hgxYM@mwandaSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      4160d9ec
    • Dan Carpenter's avatar
      net: mscc: ocelot: fix error handling bugs in mscc_ocelot_init_ports() · e0c16233
      Dan Carpenter authored
      There are several error handling bugs in mscc_ocelot_init_ports().  I
      went through the code, and carefully audited it and made fixes and
      cleanups.
      
      1) The ocelot_probe_port() function didn't have a mirror release function
         so it was hard to follow.  I created the ocelot_release_port()
         function.
      2) In the ocelot_probe_port() function, if the register_netdev() call
         failed, then it lead to a double free_netdev(dev) bug.  Fix this by
         setting "ocelot->ports[port] = NULL" on the error path.
      3) I was concerned that the "port" which comes from of_property_read_u32()
         might be out of bounds so I added a check for that.
      4) In the original code if ocelot_regmap_init() failed then the driver
         tried to continue but I think that should be a fatal error.
      5) If ocelot_probe_port() failed then the most recent devlink was leaked.
         The fix for mostly came Vladimir Oltean.  Get rid of "registered_ports"
         and just set a bit in "devlink_ports_registered" to say when the
         devlink port has been registered (and needs to be unregistered on
         error).  There are fewer than 32 ports so a u32 is large enough for
         this purpose.
      6) The error handling if the final ocelot_port_devlink_init() failed had
         two problems.  The "while (port-- >= 0)" loop should have been
         "--port" pre-op instead of a post-op to avoid a buffer underflow.
         The "if (!registered_ports[port])" condition was reversed leading to
         resource leaks and double frees.
      
      Fixes: 6c30384e ("net: mscc: ocelot: register devlink ports")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Tested-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Link: https://lore.kernel.org/r/YBkXhqRxHtRGzSnJ@mwandaSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      e0c16233
  2. 03 Feb, 2021 21 commits