1. 23 11月, 2018 1 次提交
    • F
      net: systemport: Protect stop from timeout · 3d6679c8
      Florian Fainelli 提交于
      [ Upstream commit 7cb6a2a2c72c1ed8f42fb01f1a661281b568dead ]
      
      A timing hazard exists when the network interface is stopped that
      allows a watchdog timeout to be processed by a separate core in
      parallel. This creates the potential for the timeout handler to
      wake the queues while the driver is shutting down, or access
      registers after their clocks have been removed.
      
      The more common case is that the watchdog timeout will produce a
      warning message which doesn't lead to a crash. The chances of this
      are greatly increased by the fact that bcm_sysport_netif_stop stops
      the transmit queues which can easily precipitate a watchdog time-
      out because of stale trans_start data in the queues.
      
      This commit corrects the behavior by ensuring that the watchdog
      timeout is disabled before enterring bcm_sysport_netif_stop. There
      are currently only two users of the bcm_sysport_netif_stop function:
      close and suspend.
      
      The close case already handles the issue by exiting the RUNNING
      state before invoking the driver close service.
      
      The suspend case now performs the netif_device_detach to exit the
      PRESENT state before the call to bcm_sysport_netif_stop rather than
      after it.
      
      These behaviors prevent any future scheduling of the driver timeout
      service during the window. The netif_tx_stop_all_queues function
      in bcm_sysport_netif_stop is replaced with netif_tx_disable to ensure
      synchronization with any transmit or timeout threads that may
      already be executing on other cores.
      
      For symmetry, the netif_device_attach call upon resume is moved to
      after the call to bcm_sysport_netif_start. Since it wakes the transmit
      queues it is not necessary to invoke netif_tx_start_all_queues from
      bcm_sysport_netif_start so it is moved into the driver open service.
      
      Fixes: 40755a0f ("net: systemport: add suspend and resume support")
      Fixes: 80105bef ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3d6679c8
  2. 03 10月, 2018 1 次提交
    • F
      net: systemport: Fix wake-up interrupt race during resume · 45ec3185
      Florian Fainelli 提交于
      The AON_PM_L2 is normally used to trigger and identify the source of a
      wake-up event. Since the RX_SYS clock is no longer turned off, we also
      have an interrupt being sent to the SYSTEMPORT INTRL_2_0 controller, and
      that interrupt remains active up until the magic packet detector is
      disabled which happens much later during the driver resumption.
      
      The race happens if we have a CPU that is entering the SYSTEMPORT
      INTRL2_0 handler during resume, and another CPU has managed to clear the
      wake-up interrupt during bcm_sysport_resume_from_wol(). In that case, we
      have the first CPU stuck in the interrupt handler with an interrupt
      cause that has been cleared under its feet, and so we keep returning
      IRQ_NONE and we never make any progress.
      
      This was not a problem before because we would always turn off the
      RX_SYS clock during WoL, so the SYSTEMPORT INTRL2_0 would also be turned
      off as well, thus not latching the interrupt.
      
      The fix is to make sure we do not enable either the MPD or
      BRCM_TAG_MATCH interrupts since those are redundant with what the
      AON_PM_L2 interrupt controller already processes and they would cause
      such a race to occur.
      
      Fixes: bb9051a2 ("net: systemport: Add support for WAKE_FILTER")
      Fixes: 83e82f4c ("net: systemport: add Wake-on-LAN support")
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      45ec3185
  3. 14 8月, 2018 1 次提交
  4. 08 8月, 2018 1 次提交
  5. 04 8月, 2018 2 次提交
  6. 13 7月, 2018 1 次提交
  7. 10 7月, 2018 2 次提交
  8. 30 4月, 2018 1 次提交
  9. 28 4月, 2018 1 次提交
    • F
      net: systemport: Correclty disambiguate driver instances · 1f3ccc3c
      Florian Fainelli 提交于
      While adding the DSA notifier, we will be sending DSA notifications with
      info->master that is going to point to a particular net_device instance.
      
      Our logic in bcm_sysport_map_queues() correctly disambiguates net_device
      instances that are not covered by our own driver, but it will not make
      sure that info->master points to a particular driver instance that we
      are interested in. In a system where e.g: two or more SYSTEMPORT
      instances are registered, this would lead in programming two or more
      times the queue mapping, completely messing with the logic which does
      the queue/port allocation and tracking.
      
      Fix this by looking at the notifier_block pointer which is unique per
      instance and allows us to go back to our driver private structure, and
      in turn to the backing net_device instance.
      
      Fixes: d1565763 ("net: systemport: Establish lower/upper queue mapping")
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: NVivien Didelot <vivien.didelot@savoirfairelinux.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1f3ccc3c
  10. 24 4月, 2018 1 次提交
  11. 04 4月, 2018 1 次提交
  12. 30 3月, 2018 2 次提交
  13. 26 3月, 2018 1 次提交
  14. 16 3月, 2018 1 次提交
    • F
      net: systemport: Rewrite __bcm_sysport_tx_reclaim() · 484d802d
      Florian Fainelli 提交于
      There is no need for complex checking between the last consumed index
      and current consumed index, a simple subtraction will do.
      
      This also eliminates the possibility of a permanent transmit queue stall
      under the following conditions:
      
      - one CPU bursts ring->size worth of traffic (up to 256 buffers), to the
        point where we run out of free descriptors, so we stop the transmit
        queue at the end of bcm_sysport_xmit()
      
      - because of our locking, we have the transmit process disable
        interrupts which means we can be blocking the TX reclamation process
      
      - when TX reclamation finally runs, we will be computing the difference
        between ring->c_index (last consumed index by SW) and what the HW
        reports through its register
      
      - this register is masked with (ring->size - 1) = 0xff, which will lead
        to stripping the upper bits of the index (register is 16-bits wide)
      
      - we will be computing last_tx_cn as 0, which means there is no work to
        be done, and we never wake-up the transmit queue, leaving it
        permanently disabled
      
      A practical example is e.g: ring->c_index aka last_c_index = 12, we
      pushed 256 entries, HW consumer index = 268, we mask it with 0xff = 12,
      so last_tx_cn == 0, nothing happens.
      
      Fixes: 80105bef ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      484d802d
  15. 06 1月, 2018 1 次提交
  16. 03 11月, 2017 1 次提交
  17. 02 11月, 2017 1 次提交
  18. 27 10月, 2017 1 次提交
  19. 23 10月, 2017 1 次提交
    • F
      net: systemport: Guard against unmapped TX ring · e83b1715
      Florian Fainelli 提交于
      Because SYSTEMPORT is a (semi) normal network device, the stack may attempt to
      queue packets on it oustide of the DSA slave transmit path.  When that happens,
      the DSA layer has not had a chance to tag packets with the appropriate per-port
      and per-queue information, and if that happens and we don't have a port 0 queue
      0 available (e.g: on boards where this does not exist), we will hit a NULL
      pointer de-reference in bcm_sysport_select_queue().
      
      Guard against such cases by testing for the TX ring validity.
      
      Fixes: 84ff33eeb23d ("net: systemport: Establish DSA network device queue mapping")
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e83b1715
  20. 13 10月, 2017 2 次提交
    • F
      net: systemport: Turn on ACB at the SYSTEMPORT level · 723934fb
      Florian Fainelli 提交于
      Now that we have established the queue mapping between the switch port
      egress queues and the SYSTEMPORT egress queues, we can turn on Advanced
      Congestion Buffering (ACB) at the SYSTEMPORT level. This enables the
      Ethernet MAC controller to get out of band flow control information
      directly from the switch port and queue that it monitors such that its
      internal TDMA can be appropriately backpressured.
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      723934fb
    • F
      net: systemport: Establish lower/upper queue mapping · d1565763
      Florian Fainelli 提交于
      Establish a queue mapping between the DSA slave network device queues
      created that correspond to switch port queues, and the transmit queue
      that SYSTEMPORT manages.
      
      We need to configure the SYSTEMPORT transmit queue with the switch port number
      and switch port queue number in order for the switch and SYSTEMPORT hardware to
      utilize the out of band congestion notification. This hardware mechanism works
      by looking at the switch port egress queue and determines whether there is
      enough buffers for this queue, with that class of service for a successful
      transmission and if not, backpressures the SYSTEMPORT queue that is being used.
      
      For this to work, we implement a notifier which looks at the
      DSA_PORT_REGISTER event.  When DSA network devices are registered, the
      framework calls the DSA notifiers when that happens, extracts the number
      of queues for these devices and their associated port number, remembers
      that in the driver private structure and linearly maps those queues to
      TX rings/queues that we manage.
      
      This scheme works because DSA slave network deviecs always transmit
      through SYSTEMPORT so when DSA slave network devices are
      destroyed/brought down, the corresponding SYSTEMPORT queues are no
      longer used. Also, by design of the DSA framework, the master network
      device (SYSTEMPORT) is registered first.
      
      For faster lookups we use an array of up to DSA_MAX_PORTS * number of
      queues per port, and then map pointers to bcm_sysport_tx_ring such that
      our ndo_select_queue() implementation can just index into that array to
      locate the corresponding ring index.
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d1565763
  21. 19 9月, 2017 1 次提交
    • F
      net: systemport: Fix 64-bit statistics dependency · 8ecb1a29
      Florian Fainelli 提交于
      There are several problems with commit 10377ba7 ("net: systemport:
      Support 64bit statistics", first one got fixed in 7095c973 ("net:
      systemport: Fix 64-bit stats deadlock").
      
      The second problem is that this specific code updates the
      stats64.tx_{packets,bytes} from ndo_get_stats64() and that is what we
      are returning to ethtool -S. If we are not running a tool that involves
      calling ndo_get_stats64(), then we won't get updated ethtool stats.
      
      The solution to this is to update the stats from both call sites,
      factoring that into a specific function, While at it, don't just check
      the sizeof() but also the type of the statistics in order to use the
      64-bit stats seqlock.
      
      Fixes: 10377ba7 ("net: systemport: Support 64bit statistics")
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8ecb1a29
  22. 16 9月, 2017 1 次提交
    • F
      net: systemport: Fix 64-bit stats deadlock · 7095c973
      Florian Fainelli 提交于
      We can enter a deadlock situation because there is no sufficient protection
      when ndo_get_stats64() runs in process context to guard against RX or TX NAPI
      contexts running in softirq, this can lead to the following lockdep splat and
      actual deadlock was experienced as well with an iperf session in the background
      and a while loop doing ifconfig + ethtool.
      
      [    5.780350] ================================
      [    5.784679] WARNING: inconsistent lock state
      [    5.789011] 4.13.0-rc7-02179-g32fae27c725d #70 Not tainted
      [    5.794561] --------------------------------
      [    5.798890] inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.
      [    5.804971] swapper/0/0 [HC0[0]:SC1[1]:HE0:SE0] takes:
      [    5.810175]  (&syncp->seq#2){+.?...}, at: [<c0768a28>] bcm_sysport_tx_reclaim+0x30/0x54
      [    5.818327] {SOFTIRQ-ON-W} state was registered at:
      [    5.823278]   bcm_sysport_get_stats64+0x17c/0x258
      [    5.828053]   dev_get_stats+0x38/0xac
      [    5.831776]   rtnl_fill_stats+0x30/0x118
      [    5.835761]   rtnl_fill_ifinfo+0x538/0xe24
      [    5.839921]   rtmsg_ifinfo_build_skb+0x6c/0xd8
      [    5.844430]   rtmsg_ifinfo_event.part.5+0x14/0x44
      [    5.849201]   rtmsg_ifinfo+0x20/0x28
      [    5.852837]   register_netdevice+0x628/0x6b8
      [    5.857171]   register_netdev+0x14/0x24
      [    5.861051]   bcm_sysport_probe+0x30c/0x438
      [    5.865280]   platform_drv_probe+0x50/0xb0
      [    5.869418]   driver_probe_device+0x2e8/0x450
      [    5.873817]   __driver_attach+0x104/0x120
      [    5.877871]   bus_for_each_dev+0x7c/0xc0
      [    5.881834]   bus_add_driver+0x1b0/0x270
      [    5.885797]   driver_register+0x78/0xf4
      [    5.889675]   do_one_initcall+0x54/0x190
      [    5.893646]   kernel_init_freeable+0x144/0x1d0
      [    5.898135]   kernel_init+0x8/0x110
      [    5.901665]   ret_from_fork+0x14/0x2c
      [    5.905363] irq event stamp: 24263
      [    5.908804] hardirqs last  enabled at (24262): [<c08eecf0>] net_rx_action+0xc4/0x4e4
      [    5.916624] hardirqs last disabled at (24263): [<c0a7da00>] _raw_spin_lock_irqsave+0x1c/0x98
      [    5.925143] softirqs last  enabled at (24258): [<c022a7fc>] irq_enter+0x84/0x98
      [    5.932524] softirqs last disabled at (24259): [<c022a918>] irq_exit+0x108/0x16c
      [    5.939985]
      [    5.939985] other info that might help us debug this:
      [    5.946576]  Possible unsafe locking scenario:
      [    5.946576]
      [    5.952556]        CPU0
      [    5.955031]        ----
      [    5.957506]   lock(&syncp->seq#2);
      [    5.960955]   <Interrupt>
      [    5.963604]     lock(&syncp->seq#2);
      [    5.967227]
      [    5.967227]  *** DEADLOCK ***
      [    5.967227]
      [    5.973222] 1 lock held by swapper/0/0:
      [    5.977092]  #0:  (&(&ring->lock)->rlock){..-...}, at: [<c0768a18>] bcm_sysport_tx_reclaim+0x20/0x54
      
      So just remove the u64_stats_update_begin()/end() pair in ndo_get_stats64()
      since it does not appear to be useful for anything. No inconsistency was
      observed with either ifconfig or ethtool, global TX counts equal the sum of
      per-queue TX counts on a 32-bit architecture.
      
      Fixes: 10377ba7 ("net: systemport: Support 64bit statistics")
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7095c973
  23. 02 9月, 2017 1 次提交
  24. 30 8月, 2017 2 次提交
  25. 25 8月, 2017 2 次提交
  26. 10 8月, 2017 1 次提交
  27. 07 8月, 2017 1 次提交
    • K
      net: systemport: Support 64bit statistics · 10377ba7
      kiki good 提交于
      When using Broadcom Systemport device in 32bit Platform, ifconfig can
      only report up to 4G tx,rx status, which will be wrapped to 0 when the
      number of incoming or outgoing packets exceeds 4G, only taking
      around 2 hours in busy network environment (such as streaming).
      Therefore, it makes hard for network diagnostic tool to get reliable
      statistical result, so the patch is used to add 64bit support for
      Broadcom Systemport device in 32bit Platform.
      
      This patch provides 64bit statistics capability on both ethtool and ifconfig.
      Signed-off-by: NJianming.qiao <kiki-good@hotmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      10377ba7
  28. 16 6月, 2017 1 次提交
    • J
      networking: make skb_push & __skb_push return void pointers · d58ff351
      Johannes Berg 提交于
      It seems like a historic accident that these return unsigned char *,
      and in many places that means casts are required, more often than not.
      
      Make these functions return void * and remove all the casts across
      the tree, adding a (u8 *) cast only where the unsigned char pointer
      was used directly, all done with the following spatch:
      
          @@
          expression SKB, LEN;
          typedef u8;
          identifier fn = { skb_push, __skb_push, skb_push_rcsum };
          @@
          - *(fn(SKB, LEN))
          + *(u8 *)fn(SKB, LEN)
      
          @@
          expression E, SKB, LEN;
          identifier fn = { skb_push, __skb_push, skb_push_rcsum };
          type T;
          @@
          - E = ((T *)(fn(SKB, LEN)))
          + E = fn(SKB, LEN)
      
          @@
          expression SKB, LEN;
          identifier fn = { skb_push, __skb_push, skb_push_rcsum };
          @@
          - fn(SKB, LEN)[0]
          + *(u8 *)fn(SKB, LEN)
      
      Note that the last part there converts from push(...)[0] to the
      more idiomatic *(u8 *)push(...).
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d58ff351
  29. 02 6月, 2017 1 次提交
  30. 29 3月, 2017 1 次提交
  31. 25 3月, 2017 3 次提交
  32. 23 1月, 2017 1 次提交
    • F
      net: systemport: Add support for SYSTEMPORT Lite · 44a4524c
      Florian Fainelli 提交于
      Add supporf for the SYSTEMPORT Lite Ethernet controller, this piece of hardware
      is largely based on the full-blown SYSTEMPORT and differs in the following:
      
      - no full-blown UniMAC, instead we have the MagicPacket matching from UniMAC at
        same offset, and a GMII Interface Block (GIB) for the MAC-level stuff, since
        we are always interfaced to an Ethernet switch which is fully Ethernet compliant
        shortcuts could be made
      
      - 16 transmit queues, whose interrupts are moved into the first Level-2 interrupt
        controller bank
      
      - slight TDMA offset change (a register was inserted after TDMA_STATUS, *sigh*)
      
      - 256 RX descriptors (512 words) and 256 TX descriptors (not visible)
      
      As a consequence of these two things, update the code paths accordingly to
      differentiate the full-blown from the light version.
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      44a4524c