1. 12 Feb, 2021 7 commits
    • Cong Wang's avatar
      net: fix dev_ifsioc_locked() race condition · 3b23a32a
      Cong Wang authored
      dev_ifsioc_locked() is called with only RCU read lock, so when
      there is a parallel writer changing the mac address, it could
      get a partially updated mac address, as shown below:
      
      Thread 1			Thread 2
      // eth_commit_mac_addr_change()
      memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
      				// dev_ifsioc_locked()
      				memcpy(ifr->ifr_hwaddr.sa_data,
      					dev->dev_addr,...);
      
      Close this race condition by guarding them with a RW semaphore,
      like netdev_get_name(). We can not use seqlock here as it does not
      allow blocking. The writers already take RTNL anyway, so this does
      not affect the slow path. To avoid bothering existing
      dev_set_mac_address() callers in drivers, introduce a new wrapper
      just for user-facing callers on ioctl and rtnetlink paths.
      
      Note, bonding also changes slave mac addresses but that requires
      a separate patch due to the complexity of bonding code.
      
      Fixes: 3710becf ("net: RCU locking for simple ioctl()")
      Reported-by: default avatar"Gong, Sishuai" <sishuai@purdue.edu>
      Cc: Eric Dumazet <eric.dumazet@gmail.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarCong Wang <cong.wang@bytedance.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3b23a32a
    • Stefan Chulski's avatar
      net: mvpp2: fix interrupt mask/unmask skip condition · 7867299c
      Stefan Chulski authored
      The condition should be skipped if CPU ID equal to nthreads.
      The patch doesn't fix any actual issue since
      nthreads = min_t(unsigned int, num_present_cpus(), MVPP2_MAX_THREADS).
      On all current Armada platforms, the number of CPU's is
      less than MVPP2_MAX_THREADS.
      
      Fixes: e531f767 ("net: mvpp2: handle cases where more CPUs are available than s/w threads")
      Reported-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarStefan Chulski <stefanc@marvell.com>
      Reviewed-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7867299c
    • David S. Miller's avatar
      Merge branch 'am65-cpsw-nuss-switchdev-driver' · f79bebad
      David S. Miller authored
      Vignesh Raghavendra says:
      
      ====================
      net: ti: am65-cpsw-nuss: Add switchdev driver
      
      This series adds switchdev support for AM65 CPSW NUSS driver to support
      multi port CPSW present on J721e and AM64 SoCs.
      It adds devlink hook to switch b/w switch mode and multi mac mode.
      
      v2:
      Rebased on latest net-next
      Update patch 1/4 with rationale for using devlink
      ====================
      f79bebad
    • Vignesh Raghavendra's avatar
      docs: networking: ti: Add driver doc for AM65 NUSS switch driver · e276cfb9
      Vignesh Raghavendra authored
      J721e, J7200 and AM64 have multi port switches which can work in multi
      mac mode and in switch mode. Add documentation explaining how to use
      different modes.
      
      Borrowed from:
      Documentation/networking/device_drivers/ethernet/ti/cpsw_switchdev.rst
      Signed-off-by: default avatarVignesh Raghavendra <vigneshr@ti.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e276cfb9
    • Vignesh Raghavendra's avatar
      net: ti: am65-cpsw-nuss: Add switchdev support · 86e8b070
      Vignesh Raghavendra authored
      J721e, J7200 and AM64 have multi port switches which can work in multi
      mac mode and in switch mode. Add support for configuring this HW in
      switch mode using devlink and switchdev notifiers.
      
      Support is similar to existing CPSW switchdev implementation of TI's 32 bit
      platform like AM33/AM43/AM57.
      
      To enable switch mode:
      devlink dev param set platform/8000000.ethernet name switch_mode value true cmode runtime
      
      All configuration is implemented via switchdev API and notifiers.
      Supported:
            - SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS
            - SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS
            - SWITCHDEV_ATTR_ID_PORT_STP_STATE
            - SWITCHDEV_OBJ_ID_PORT_VLAN
            - SWITCHDEV_OBJ_ID_PORT_MDB
            - SWITCHDEV_OBJ_ID_HOST_MDB
      
      Hence AM65 CPSW switchdev driver supports:
           - FDB offloading
           - MDB offloading
           - VLAN filtering and offloading
           - STP
      Signed-off-by: default avatarVignesh Raghavendra <vigneshr@ti.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      86e8b070
    • Vignesh Raghavendra's avatar
      net: ti: am65-cpsw-nuss: Add netdevice notifiers · 2934db9b
      Vignesh Raghavendra authored
      Register netdevice notifiers in order to receive notification when
      individual MAC ports are added to the HW bridge.
      Signed-off-by: default avatarVignesh Raghavendra <vigneshr@ti.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2934db9b
    • Vignesh Raghavendra's avatar
      net: ti: am65-cpsw-nuss: Add devlink support · 58356eb3
      Vignesh Raghavendra authored
      AM65 NUSS ethernet switch on K3 devices can be configured to work either
      in independent mac mode where each port acts as independent network
      interface (multi mac) or switch mode.
      
      Add devlink hooks to provide a way to switch b/w these modes.
      
      Rationale to use devlink instead of defaulting to bridge mode is that
      SoC use cases require to support multiple independent MAC ports with no
      switching so that users can use software bridges with multi-mac
      configuration (e.g: to support LAG, HSR/PRP, etc). Also, switching
      between multi mac and switch mode requires significant Port and ALE
      reconfiguration, therefore is easier to be made as part of mode change
      devlink hooks. It also allows to keep user interface similar to what
      was implemented for the previous generation of TI CPSW IP
      (on AM33/AM43/AM57 SoCs).
      Signed-off-by: default avatarVignesh Raghavendra <vigneshr@ti.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      58356eb3
  2. 11 Feb, 2021 33 commits