1. 10 11月, 2021 5 次提交
  2. 09 11月, 2021 5 次提交
  3. 08 11月, 2021 5 次提交
  4. 07 11月, 2021 5 次提交
  5. 05 11月, 2021 13 次提交
    • V
      net: marvell: prestera: fix patchwork build problems · a46a5036
      Volodymyr Mytnyk 提交于
      fix the remaining build issues reported by patchwork
      in firmware v4.0 support commit which has been already
      merged.
      
      Fix patchwork issues:
       - source inline
       - checkpatch
      
      Fixes: bb5dbf2c ("net: marvell: prestera: add firmware v4.0 support")
      Signed-off-by: NVolodymyr Mytnyk <vmytnyk@marvell.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a46a5036
    • Z
      amt: remove duplicate include in amt.c · dce981c4
      Zhang Mingyu 提交于
      'net/protocol.h' included in 'drivers/net/amt.c' is duplicated.
      Reported-by: NZeal Robot <zealci@zte.com.cn>
      Signed-off-by: NZhang Mingyu <zhang.mingyu@zte.com.cn>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      dce981c4
    • A
      octeontx2-nicvf: fix ioctl callback · a6785bd7
      Arnd Bergmann 提交于
      The mii ioctls are now handled by the ndo_eth_ioctl() callback,
      not the old ndo_do_ioctl(), but octeontx2-nicvf introduced the
      function for the old way.
      
      Move it over to ndo_eth_ioctl() to actually allow calling it from
      user space.
      
      Fixes: 43510ef4 ("octeontx2-nicvf: Add PTP hardware clock support to NIX VF")
      Fixes: a7605370 ("dev_ioctl: split out ndo_eth_ioctl")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a6785bd7
    • A
      ax88796c: fix ioctl callback · 9dcc0071
      Arnd Bergmann 提交于
      The timestamp ioctls are now handled by the ndo_eth_ioctl() callback,
      not the old ndo_do_ioctl(), but oax88796 introduced the
      function for the old way.
      
      Move it over to ndo_eth_ioctl() to actually allow calling it from
      user space.
      
      Fixes: a97c69ba ("net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver")
      Fixes: a7605370 ("dev_ioctl: split out ndo_eth_ioctl")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NLukasz Stelmach <l.stelmach@samsung.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9dcc0071
    • Y
      amt: Fix NULL but dereferenced coccicheck error · 3f81c579
      Yang Li 提交于
      Eliminate the following coccicheck warning:
      ./drivers/net/amt.c:2795:6-9: ERROR: amt is NULL but dereferenced.
      Reported-by: NAbaci Robot <abaci@linux.alibaba.com>
      Signed-off-by: NYang Li <yang.lee@linux.alibaba.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3f81c579
    • J
      net: ax88796c: hide ax88796c_dt_ids if !CONFIG_OF · 6789a4c0
      Jakub Kicinski 提交于
      Build bot says:
      
      >> drivers/net/ethernet/asix/ax88796c_main.c:1116:34: warning: unused variable 'ax88796c_dt_ids' [-Wunused-const-variable]
         static const struct of_device_id ax88796c_dt_ids[] = {
                                          ^
      
      The only reference to this array is wrapped in of_match_ptr().
      Reported-by: Nkernel test robot <lkp@intel.com>
      Fixes: a97c69ba ("net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver")
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6789a4c0
    • X
      net: ethernet: litex: Remove unnecessary print function dev_err() · 827beb77
      Xu Wang 提交于
      The print function dev_err() is redundant because
      platform_get_irq() already prints an error.
      Signed-off-by: NXu Wang <vulab@iscas.ac.cn>
      Reviewed-by: NCai Huoqing <caihuoqing@baidu.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      827beb77
    • A
      octeontx2-pf: select CONFIG_NET_DEVLINK · 9cbc3367
      Arnd Bergmann 提交于
      The octeontx2 pf nic driver failsz to link when the devlink support
      is not reachable:
      
      aarch64-linux-ld: drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.o: in function `otx2_dl_mcam_count_get':
      otx2_devlink.c:(.text+0x10): undefined reference to `devlink_priv'
      aarch64-linux-ld: drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.o: in function `otx2_dl_mcam_count_validate':
      otx2_devlink.c:(.text+0x50): undefined reference to `devlink_priv'
      aarch64-linux-ld: drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.o: in function `otx2_dl_mcam_count_set':
      otx2_devlink.c:(.text+0xd0): undefined reference to `devlink_priv'
      aarch64-linux-ld: drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.o: in function `otx2_devlink_info_get':
      otx2_devlink.c:(.text+0x150): undefined reference to `devlink_priv'
      
      This is already selected by the admin function driver, but not the
      actual nic, which might be built-in when the af driver is not.
      
      Fixes: 2da48943 ("octeontx2-pf: devlink params support to set mcam entry count")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9cbc3367
    • Y
      sfc: use swap() to make code cleaner · f6a51010
      Yang Guang 提交于
      Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
      opencoding it.
      Reported-by: NZeal Robot <zealci@zte.com.cn>
      Signed-off-by: NYang Guang <yang.guang5@zte.com.cn>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f6a51010
    • Y
      octeontx2-af: use swap() to make code cleaner · d7be1d1c
      Yang Guang 提交于
      Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
      opencoding it.
      Reported-by: NZeal Robot <zealci@zte.com.cn>
      Signed-off-by: NYang Guang <yang.guang5@zte.com.cn>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d7be1d1c
    • L
      tg3: Remove redundant assignments · 0c500ef5
      luo penghao 提交于
      The assignment of err will be overwritten next, so this statement
      should be deleted.
      
      The clang_analyzer complains as follows:
      
      drivers/net/ethernet/broadcom/tg3.c:5506:2: warning:
      
      Value stored to 'expected_sg_dig_ctrl' is never read
      Reported-by: NZeal Robot <zealci@zte.com.cn>
      Signed-off-by: Nluo penghao <luo.penghao@zte.com.cn>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0c500ef5
    • H
      bonding: Fix a use-after-free problem when bond_sysfs_slave_add() failed · b93c6a91
      Huang Guobin 提交于
      When I do fuzz test for bonding device interface, I got the following
      use-after-free Calltrace:
      
      ==================================================================
      BUG: KASAN: use-after-free in bond_enslave+0x1521/0x24f0
      Read of size 8 at addr ffff88825bc11c00 by task ifenslave/7365
      
      CPU: 5 PID: 7365 Comm: ifenslave Tainted: G            E     5.15.0-rc1+ #13
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1 04/01/2014
      Call Trace:
       dump_stack_lvl+0x6c/0x8b
       print_address_description.constprop.0+0x48/0x70
       kasan_report.cold+0x82/0xdb
       __asan_load8+0x69/0x90
       bond_enslave+0x1521/0x24f0
       bond_do_ioctl+0x3e0/0x450
       dev_ifsioc+0x2ba/0x970
       dev_ioctl+0x112/0x710
       sock_do_ioctl+0x118/0x1b0
       sock_ioctl+0x2e0/0x490
       __x64_sys_ioctl+0x118/0x150
       do_syscall_64+0x35/0xb0
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      RIP: 0033:0x7f19159cf577
      Code: b3 66 90 48 8b 05 11 89 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 78
      RSP: 002b:00007ffeb3083c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
      RAX: ffffffffffffffda RBX: 00007ffeb3084bca RCX: 00007f19159cf577
      RDX: 00007ffeb3083ce0 RSI: 0000000000008990 RDI: 0000000000000003
      RBP: 00007ffeb3084bc4 R08: 0000000000000040 R09: 0000000000000000
      R10: 00007ffeb3084bc0 R11: 0000000000000246 R12: 00007ffeb3083ce0
      R13: 0000000000000000 R14: 0000000000000000 R15: 00007ffeb3083cb0
      
      Allocated by task 7365:
       kasan_save_stack+0x23/0x50
       __kasan_kmalloc+0x83/0xa0
       kmem_cache_alloc_trace+0x22e/0x470
       bond_enslave+0x2e1/0x24f0
       bond_do_ioctl+0x3e0/0x450
       dev_ifsioc+0x2ba/0x970
       dev_ioctl+0x112/0x710
       sock_do_ioctl+0x118/0x1b0
       sock_ioctl+0x2e0/0x490
       __x64_sys_ioctl+0x118/0x150
       do_syscall_64+0x35/0xb0
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Freed by task 7365:
       kasan_save_stack+0x23/0x50
       kasan_set_track+0x20/0x30
       kasan_set_free_info+0x24/0x40
       __kasan_slab_free+0xf2/0x130
       kfree+0xd1/0x5c0
       slave_kobj_release+0x61/0x90
       kobject_put+0x102/0x180
       bond_sysfs_slave_add+0x7a/0xa0
       bond_enslave+0x11b6/0x24f0
       bond_do_ioctl+0x3e0/0x450
       dev_ifsioc+0x2ba/0x970
       dev_ioctl+0x112/0x710
       sock_do_ioctl+0x118/0x1b0
       sock_ioctl+0x2e0/0x490
       __x64_sys_ioctl+0x118/0x150
       do_syscall_64+0x35/0xb0
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Last potentially related work creation:
       kasan_save_stack+0x23/0x50
       kasan_record_aux_stack+0xb7/0xd0
       insert_work+0x43/0x190
       __queue_work+0x2e3/0x970
       delayed_work_timer_fn+0x3e/0x50
       call_timer_fn+0x148/0x470
       run_timer_softirq+0x8a8/0xc50
       __do_softirq+0x107/0x55f
      
      Second to last potentially related work creation:
       kasan_save_stack+0x23/0x50
       kasan_record_aux_stack+0xb7/0xd0
       insert_work+0x43/0x190
       __queue_work+0x2e3/0x970
       __queue_delayed_work+0x130/0x180
       queue_delayed_work_on+0xa7/0xb0
       bond_enslave+0xe25/0x24f0
       bond_do_ioctl+0x3e0/0x450
       dev_ifsioc+0x2ba/0x970
       dev_ioctl+0x112/0x710
       sock_do_ioctl+0x118/0x1b0
       sock_ioctl+0x2e0/0x490
       __x64_sys_ioctl+0x118/0x150
       do_syscall_64+0x35/0xb0
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      The buggy address belongs to the object at ffff88825bc11c00
       which belongs to the cache kmalloc-1k of size 1024
      The buggy address is located 0 bytes inside of
       1024-byte region [ffff88825bc11c00, ffff88825bc12000)
      The buggy address belongs to the page:
      page:ffffea00096f0400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x25bc10
      head:ffffea00096f0400 order:3 compound_mapcount:0 compound_pincount:0
      flags: 0x57ff00000010200(slab|head|node=1|zone=2|lastcpupid=0x7ff)
      raw: 057ff00000010200 ffffea0009a71c08 ffff888240001968 ffff88810004dbc0
      raw: 0000000000000000 00000000000a000a 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
       ffff88825bc11b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
       ffff88825bc11b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      >ffff88825bc11c00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
       ffff88825bc11c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       ffff88825bc11d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      ==================================================================
      
      Put new_slave in bond_sysfs_slave_add() will cause use-after-free problems
      when new_slave is accessed in the subsequent error handling process. Since
      new_slave will be put in the subsequent error handling process, remove the
      unnecessary put to fix it.
      In addition, when sysfs_create_file() fails, if some files have been crea-
      ted successfully, we need to call sysfs_remove_file() to remove them.
      Since there are sysfs_create_files() & sysfs_remove_files() can be used,
      use these two functions instead.
      
      Fixes: 7afcaec4 (bonding: use kobject_put instead of _del after kobject_add)
      Signed-off-by: NHuang Guobin <huangguobin4@huawei.com>
      Reviewed-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b93c6a91
    • H
      net: phy: fix duplex out of sync problem while changing settings · a4db9055
      Heiner Kallweit 提交于
      As reported by Zhang there's a small issue if in forced mode the duplex
      mode changes with the link staying up [0]. In this case the MAC isn't
      notified about the change.
      
      The proposed patch relies on the phylib state machine and ignores the
      fact that there are drivers that uses phylib but not the phylib state
      machine. So let's don't change the behavior for such drivers and fix
      it w/o re-adding state PHY_FORCING for the case that phylib state
      machine is used.
      
      [0] https://lore.kernel.org/netdev/a5c26ffd-4ee4-a5e6-4103-873208ce0dc5@huawei.com/T/
      
      Fixes: 2bd229df ("net: phy: remove state PHY_FORCING")
      Reported-by: NZhang Changzhong <zhangchangzhong@huawei.com>
      Tested-by: NZhang Changzhong <zhangchangzhong@huawei.com>
      Signed-off-by: NHeiner Kallweit <hkallweit1@gmail.com>
      Link: https://lore.kernel.org/r/7b8b9456-a93f-abbc-1dc5-a2c2542f932c@gmail.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      a4db9055
  6. 03 11月, 2021 7 次提交
    • B
      ice: Fix race conditions between virtchnl handling and VF ndo ops · e6ba5273
      Brett Creeley 提交于
      The VF can be configured via the PF's ndo ops at the same time the PF is
      receiving/handling virtchnl messages. This has many issues, with
      one of them being the ndo op could be actively resetting a VF (i.e.
      resetting it to the default state and deleting/re-adding the VF's VSI)
      while a virtchnl message is being handled. The following error was seen
      because a VF ndo op was used to change a VF's trust setting while the
      VIRTCHNL_OP_CONFIG_VSI_QUEUES was ongoing:
      
      [35274.192484] ice 0000:88:00.0: Failed to set LAN Tx queue context, error: ICE_ERR_PARAM
      [35274.193074] ice 0000:88:00.0: VF 0 failed opcode 6, retval: -5
      [35274.193640] iavf 0000:88:01.0: PF returned error -5 (IAVF_ERR_PARAM) to our request 6
      
      Fix this by making sure the virtchnl handling and VF ndo ops that
      trigger VF resets cannot run concurrently. This is done by adding a
      struct mutex cfg_lock to each VF structure. For VF ndo ops, the mutex
      will be locked around the critical operations and VFR. Since the ndo ops
      will trigger a VFR, the virtchnl thread will use mutex_trylock(). This
      is done because if any other thread (i.e. VF ndo op) has the mutex, then
      that means the current VF message being handled is no longer valid, so
      just ignore it.
      
      This issue can be seen using the following commands:
      
      for i in {0..50}; do
              rmmod ice
              modprobe ice
      
              sleep 1
      
              echo 1 > /sys/class/net/ens785f0/device/sriov_numvfs
              echo 1 > /sys/class/net/ens785f1/device/sriov_numvfs
      
              ip link set ens785f1 vf 0 trust on
              ip link set ens785f0 vf 0 trust on
      
              sleep 2
      
              echo 0 > /sys/class/net/ens785f0/device/sriov_numvfs
              echo 0 > /sys/class/net/ens785f1/device/sriov_numvfs
              sleep 1
              echo 1 > /sys/class/net/ens785f0/device/sriov_numvfs
              echo 1 > /sys/class/net/ens785f1/device/sriov_numvfs
      
              ip link set ens785f1 vf 0 trust on
              ip link set ens785f0 vf 0 trust on
      done
      
      Fixes: 7c710869 ("ice: Add handlers for VF netdevice operations")
      Signed-off-by: NBrett Creeley <brett.creeley@intel.com>
      Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      e6ba5273
    • B
      ice: Fix not stopping Tx queues for VFs · b385cca4
      Brett Creeley 提交于
      When a VF is removed and/or reset its Tx queues need to be
      stopped from the PF. This is done by calling the ice_dis_vf_qs()
      function, which calls ice_vsi_stop_lan_tx_rings(). Currently
      ice_dis_vf_qs() is protected by the VF state bit ICE_VF_STATE_QS_ENA.
      Unfortunately, this is causing the Tx queues to not be disabled in some
      cases and when the VF tries to re-enable/reconfigure its Tx queues over
      virtchnl the op is failing. This is because a VF can be reset and/or
      removed before the ICE_VF_STATE_QS_ENA bit is set, but the Tx queues
      were already configured via ice_vsi_cfg_single_txq() in the
      VIRTCHNL_OP_CONFIG_VSI_QUEUES op. However, the ICE_VF_STATE_QS_ENA bit
      is set on a successful VIRTCHNL_OP_ENABLE_QUEUES, which will always
      happen after the VIRTCHNL_OP_CONFIG_VSI_QUEUES op.
      
      This was causing the following error message when loading the ice
      driver, creating VFs, and modifying VF trust in an endless loop:
      
      [35274.192484] ice 0000:88:00.0: Failed to set LAN Tx queue context, error: ICE_ERR_PARAM
      [35274.193074] ice 0000:88:00.0: VF 0 failed opcode 6, retval: -5
      [35274.193640] iavf 0000:88:01.0: PF returned error -5 (IAVF_ERR_PARAM) to our request 6
      
      Fix this by always calling ice_dis_vf_qs() and silencing the error
      message in ice_vsi_stop_tx_ring() since the calling code ignores the
      return anyway. Also, all other places that call ice_vsi_stop_tx_ring()
      catch the error, so this doesn't affect those flows since there was no
      change to the values the function returns.
      
      Other solutions were considered (i.e. tracking which VF queues had been
      "started/configured" in VIRTCHNL_OP_CONFIG_VSI_QUEUES, but it seemed
      more complicated than it was worth. This solution also brings in the
      chance for other unexpected conditions due to invalid state bit checks.
      So, the proposed solution seemed like the best option since there is no
      harm in failing to stop Tx queues that were never started.
      
      This issue can be seen using the following commands:
      
      for i in {0..50}; do
              rmmod ice
              modprobe ice
      
              sleep 1
      
              echo 1 > /sys/class/net/ens785f0/device/sriov_numvfs
              echo 1 > /sys/class/net/ens785f1/device/sriov_numvfs
      
              ip link set ens785f1 vf 0 trust on
              ip link set ens785f0 vf 0 trust on
      
              sleep 2
      
              echo 0 > /sys/class/net/ens785f0/device/sriov_numvfs
              echo 0 > /sys/class/net/ens785f1/device/sriov_numvfs
              sleep 1
              echo 1 > /sys/class/net/ens785f0/device/sriov_numvfs
              echo 1 > /sys/class/net/ens785f1/device/sriov_numvfs
      
              ip link set ens785f1 vf 0 trust on
              ip link set ens785f0 vf 0 trust on
      done
      
      Fixes: 77ca27c4 ("ice: add support for virtchnl_queue_select.[tx|rx]_queues bitmap")
      Signed-off-by: NBrett Creeley <brett.creeley@intel.com>
      Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      b385cca4
    • S
      ice: Fix replacing VF hardware MAC to existing MAC filter · ce572a5b
      Sylwester Dziedziuch 提交于
      VF was not able to change its hardware MAC address in case
      the new address was already present in the MAC filter list.
      Change the handling of VF add mac request to not return
      if requested MAC address is already present on the list
      and check if its hardware MAC needs to be updated in this case.
      
      Fixes: ed4c068d ("ice: Enable ip link show on the PF to display VF unicast MAC(s)")
      Signed-off-by: NSylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
      Tested-by: NTony Brelinski <tony.brelinski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      ce572a5b
    • B
      ice: Remove toggling of antispoof for VF trusted promiscuous mode · 0299faea
      Brett Creeley 提交于
      Currently when a trusted VF enables promiscuous mode spoofchk will be
      disabled. This is wrong and should only be modified from the
      ndo_set_vf_spoofchk callback. Fix this by removing the call to toggle
      spoofchk for trusted VFs.
      
      Fixes: 01b5e89a ("ice: Add VF promiscuous support")
      Signed-off-by: NBrett Creeley <brett.creeley@intel.com>
      Tested-by: NTony Brelinski <tony.brelinski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      0299faea
    • B
      ice: Fix VF true promiscuous mode · 1a8c7778
      Brett Creeley 提交于
      When a VF requests promiscuous mode and it's trusted and true promiscuous
      mode is enabled the PF driver attempts to enable unicast and/or
      multicast promiscuous mode filters based on the request. This is fine,
      but there are a couple issues with the current code.
      
      [1] The define to configure the unicast promiscuous mode mask also
          includes bits to configure the multicast promiscuous mode mask, which
          causes multicast to be set/cleared unintentionally.
      [2] All 4 cases for enable/disable unicast/multicast mode are not
          handled in the promiscuous mode message handler, which causes
          unexpected results regarding the current promiscuous mode settings.
      
      To fix [1] make sure any promiscuous mask defines include the correct
      bits for each of the promiscuous modes.
      
      To fix [2] make sure that all 4 cases are handled since there are 2 bits
      (FLAG_VF_UNICAST_PROMISC and FLAG_VF_MULTICAST_PROMISC) that can be
      either set or cleared. Also, since either unicast and/or multicast
      promiscuous configuration can fail, introduce two separate error values
      to handle each of these cases.
      
      Fixes: 01b5e89a ("ice: Add VF promiscuous support")
      Signed-off-by: NBrett Creeley <brett.creeley@intel.com>
      Tested-by: NTony Brelinski <tony.brelinski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      1a8c7778
    • V
      net: dsa: felix: fix broken VLAN-tagged PTP under VLAN-aware bridge · 92f62485
      Vladimir Oltean 提交于
      Normally it is expected that the dsa_device_ops :: rcv() method finishes
      parsing the DSA tag and consumes it, then never looks at it again.
      
      But commit c0bcf537 ("net: dsa: ocelot: add hardware timestamping
      support for Felix") added support for RX timestamping in a very
      unconventional way. On this switch, a partial timestamp is available in
      the DSA header, but the driver got away with not parsing that timestamp
      right away, but instead delayed that parsing for a little longer:
      
      dsa_switch_rcv():
      	nskb = cpu_dp->rcv(skb, dev); <------------- not here
      	-> ocelot_rcv()
      	...
      
      	skb = nskb;
      	skb_push(skb, ETH_HLEN);
      	skb->pkt_type = PACKET_HOST;
      	skb->protocol = eth_type_trans(skb, skb->dev);
      
      	...
      
      	if (dsa_skb_defer_rx_timestamp(p, skb)) <--- but here
      	-> felix_rxtstamp()
      		return 0;
      
      When in felix_rxtstamp(), this driver accounted for the fact that
      eth_type_trans() happened in the meanwhile, so it got a hold of the
      extraction header again by subtracting (ETH_HLEN + OCELOT_TAG_LEN) bytes
      from the current skb->data.
      
      This worked for quite some time but was quite fragile from the very
      beginning. Not to mention that having DSA tag parsing split in two
      different files, under different folders (net/dsa/tag_ocelot.c vs
      drivers/net/dsa/ocelot/felix.c) made it quite non-obvious for patches to
      come that they might break this.
      
      Finally, the blamed commit does the following: at the end of
      ocelot_rcv(), it checks whether the skb payload contains a VLAN header.
      If it does, and this port is under a VLAN-aware bridge, that VLAN ID
      might not be correct in the sense that the packet might have suffered
      VLAN rewriting due to TCAM rules (VCAP IS1). So we consume the VLAN ID
      from the skb payload using __skb_vlan_pop(), and take the classified
      VLAN ID from the DSA tag, and construct a hwaccel VLAN tag with the
      classified VLAN, and the skb payload is VLAN-untagged.
      
      The big problem is that __skb_vlan_pop() does:
      
      	memmove(skb->data + VLAN_HLEN, skb->data, 2 * ETH_ALEN);
      	__skb_pull(skb, VLAN_HLEN);
      
      aka it moves the Ethernet header 4 bytes to the right, and pulls 4 bytes
      from the skb headroom (effectively also moving skb->data, by definition).
      So for felix_rxtstamp()'s fragile logic, all bets are off now.
      Instead of having the "extraction" pointer point to the DSA header,
      it actually points to 4 bytes _inside_ the extraction header.
      Corollary, the last 4 bytes of the "extraction" header are in fact 4
      stale bytes of the destination MAC address from the Ethernet header,
      from prior to the __skb_vlan_pop() movement.
      
      So of course, RX timestamps are completely bogus when the system is
      configured in this way.
      
      The fix is actually very simple: just don't structure the code like that.
      For better or worse, the DSA PTP timestamping API does not offer a
      straightforward way for drivers to present their RX timestamps, but
      other drivers (sja1105) have established a simple mechanism to carry
      their RX timestamp from dsa_device_ops :: rcv() all the way to
      dsa_switch_ops :: port_rxtstamp() and even later. That mechanism is to
      simply save the partial timestamp to the skb->cb, and complete it later.
      
      Question: why don't we simply populate the skb's struct
      skb_shared_hwtstamps from ocelot_rcv(), and bother with this
      complication of propagating the timestamp to felix_rxtstamp()?
      
      Answer: dsa_switch_ops :: port_rxtstamp() answers the question whether
      PTP packets need sleepable context to retrieve the full RX timestamp.
      Currently felix_rxtstamp() answers "no, thanks" to that question, and
      calls ocelot_ptp_gettime64() from softirq atomic context. This is
      understandable, since Felix VSC9959 is a PCIe memory-mapped switch, so
      hardware access does not require sleeping. But the felix driver is
      preparing for the introduction of other switches where hardware access
      is over a slow bus like SPI or MDIO:
      https://lore.kernel.org/lkml/20210814025003.2449143-1-colin.foster@in-advantage.com/
      
      So I would like to keep this code structure, so the rework needed when
      that driver will need PTP support will be minimal (answer "yes, I need
      deferred context for this skb's RX timestamp", then the partial
      timestamp will still be found in the skb->cb.
      
      Fixes: ea440cd2 ("net: dsa: tag_ocelot: use VLAN information from tagging header when available")
      Reported-by: NPo Liu <po.liu@nxp.com>
      Cc: Yangbo Lu <yangbo.lu@nxp.com>
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      92f62485
    • A
      net: dsa: qca8k: make sure PAD0 MAC06 exchange is disabled · 5f15d392
      Ansuel Smith 提交于
      Some device set MAC06 exchange in the bootloader. This cause some
      problem as we don't support this strange mode and we just set the port6
      as the primary CPU port. With MAC06 exchange, PAD0 reg configure port6
      instead of port0. Add an extra check and explicitly disable MAC06 exchange
      to correctly configure the port PAD config.
      Signed-off-by: NAnsuel Smith <ansuelsmth@gmail.com>
      Fixes: 3fcf734a ("net: dsa: qca8k: add support for cpu port 6")
      Reviewed-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5f15d392