1. 21 10月, 2016 1 次提交
    • J
      net: use core MTU range checking in USB NIC drivers · f77f0aee
      Jarod Wilson 提交于
      usbnet:
      - Remove stale new_mtu <= 0 check in usbnet.c
      - Set min_mtu = 0, max_mtu = 65535 (sub-drivers must set their own
        max_mtu and/or min_mtu as needed)
      
      r8152:
      - Set appropriate max_mtu for different variants (1500 or 9194)
      
      lan78xx:
      - Set max_mtu = 9000
      
      asix_driver:
      - max_mtu = 16384 for ax88178 variant
      
      ax88179:
      - max_mtu = 4088
      
      cdc_ncm:
      - max_mtu from hardware
      
      cdc-phonet:
      - min_mtu = 6, max_mtu = 65541
      
      sierra_net:
      - max_mtu = 1500, call usbnet_change_mtu directly
      - sierra_net_change_mtu checked for MTU > 1500, then called
        usbnet_change_mtu, but if we set max_mtu to let the network core handle
        the range check, then we can simply call usbnet_change_mtu directly
      
      smsc75xx:
      - max_mtu = 9000
      
      CC: netdev@vger.kernel.org
      CC: Woojung Huh <woojung.huh@microchip.com>
      CC: Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>
      CC: Hayes Wang <hayeswang@realtek.com>
      CC: Oliver Neukum <oneukum@suse.com>
      CC: Steve Glendinning <steve.glendinning@shawell.net>
      Signed-off-by: NJarod Wilson <jarod@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f77f0aee
  2. 14 8月, 2016 1 次提交
  3. 18 7月, 2016 1 次提交
  4. 30 6月, 2016 1 次提交
  5. 05 5月, 2016 1 次提交
  6. 04 5月, 2016 1 次提交
  7. 08 3月, 2016 1 次提交
  8. 05 12月, 2015 1 次提交
  9. 11 11月, 2015 1 次提交
  10. 16 9月, 2015 1 次提交
  11. 09 9月, 2015 1 次提交
    • E
      usbnet: Fix a race between usbnet_stop() and the BH · fcb0bb6a
      Eugene Shatokhin 提交于
      The race may happen when a device (e.g. YOTA 4G LTE Modem) is
      unplugged while the system is downloading a large file from the Net.
      
      Hardware breakpoints and Kprobes with delays were used to confirm that
      the race does actually happen.
      
      The race is on skb_queue ('next' pointer) between usbnet_stop()
      and rx_complete(), which, in turn, calls usbnet_bh().
      
      Here is a part of the call stack with the code where the changes to the
      queue happen. The line numbers are for the kernel 4.1.0:
      
      *0 __skb_unlink (skbuff.h:1517)
          prev->next = next;
      *1 defer_bh (usbnet.c:430)
          spin_lock_irqsave(&list->lock, flags);
          old_state = entry->state;
          entry->state = state;
          __skb_unlink(skb, list);
          spin_unlock(&list->lock);
          spin_lock(&dev->done.lock);
          __skb_queue_tail(&dev->done, skb);
          if (dev->done.qlen == 1)
              tasklet_schedule(&dev->bh);
          spin_unlock_irqrestore(&dev->done.lock, flags);
      *2 rx_complete (usbnet.c:640)
          state = defer_bh(dev, skb, &dev->rxq, state);
      
      At the same time, the following code repeatedly checks if the queue is
      empty and reads these values concurrently with the above changes:
      
      *0  usbnet_terminate_urbs (usbnet.c:765)
          /* maybe wait for deletions to finish. */
          while (!skb_queue_empty(&dev->rxq)
              && !skb_queue_empty(&dev->txq)
              && !skb_queue_empty(&dev->done)) {
                  schedule_timeout(msecs_to_jiffies(UNLINK_TIMEOUT_MS));
                  set_current_state(TASK_UNINTERRUPTIBLE);
                  netif_dbg(dev, ifdown, dev->net,
                        "waited for %d urb completions\n", temp);
          }
      *1  usbnet_stop (usbnet.c:806)
          if (!(info->flags & FLAG_AVOID_UNLINK_URBS))
              usbnet_terminate_urbs(dev);
      
      As a result, it is possible, for example, that the skb is removed from
      dev->rxq by __skb_unlink() before the check
      "!skb_queue_empty(&dev->rxq)" in usbnet_terminate_urbs() is made. It is
      also possible in this case that the skb is added to dev->done queue
      after "!skb_queue_empty(&dev->done)" is checked. So
      usbnet_terminate_urbs() may stop waiting and return while dev->done
      queue still has an item.
      
      Locking in defer_bh() and usbnet_terminate_urbs() was revisited to avoid
      this race.
      Signed-off-by: NEugene Shatokhin <eugene.shatokhin@rosalab.ru>
      Reviewed-by: NBjørn Mork <bjorn@mork.no>
      Acked-by: NOliver Neukum <oneukum@suse.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      fcb0bb6a
  12. 26 8月, 2015 1 次提交
  13. 10 5月, 2015 1 次提交
  14. 10 4月, 2015 1 次提交
  15. 30 3月, 2015 2 次提交
  16. 01 3月, 2015 1 次提交
  17. 25 1月, 2015 1 次提交
  18. 29 10月, 2014 1 次提交
  19. 24 9月, 2014 1 次提交
  20. 03 8月, 2014 1 次提交
  21. 30 7月, 2014 2 次提交
  22. 28 3月, 2014 1 次提交
    • O
      usbnet: include wait queue head in device structure · 14a0d635
      Oliver Neukum 提交于
      This fixes a race which happens by freeing an object on the stack.
      Quoting Julius:
      > The issue is
      > that it calls usbnet_terminate_urbs() before that, which temporarily
      > installs a waitqueue in dev->wait in order to be able to wait on the
      > tasklet to run and finish up some queues. The waiting itself looks
      > okay, but the access to 'dev->wait' is totally unprotected and can
      > race arbitrarily. I think in this case usbnet_bh() managed to succeed
      > it's dev->wait check just before usbnet_terminate_urbs() sets it back
      > to NULL. The latter then finishes and the waitqueue_t structure on its
      > stack gets overwritten by other functions halfway through the
      > wake_up() call in usbnet_bh().
      
      The fix is to just not allocate the data structure on the stack.
      As dev->wait is abused as a flag it also takes a runtime PM change
      to fix this bug.
      Signed-off-by: NOliver Neukum <oneukum@suse.de>
      Reported-by: NGrant Grundler <grundler@google.com>
      Tested-by: NGrant Grundler <grundler@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      14a0d635
  23. 18 2月, 2014 1 次提交
    • E
      usbnet: remove generic hard_header_len check · eb85569f
      Emil Goode 提交于
      This patch removes a generic hard_header_len check from the usbnet
      module that is causing dropped packages under certain circumstances
      for devices that send rx packets that cross urb boundaries.
      
      One example is the AX88772B which occasionally send rx packets that
      cross urb boundaries where the remaining partial packet is sent with
      no hardware header. When the buffer with a partial packet is of less
      number of octets than the value of hard_header_len the buffer is
      discarded by the usbnet module.
      
      With AX88772B this can be reproduced by using ping with a packet
      size between 1965-1976.
      
      The bug has been reported here:
      
      https://bugzilla.kernel.org/show_bug.cgi?id=29082
      
      This patch introduces the following changes:
      - Removes the generic hard_header_len check in the rx_complete
        function in the usbnet module.
      - Introduces a ETH_HLEN check for skbs that are not cloned from
        within a rx_fixup callback.
      - For safety a hard_header_len check is added to each rx_fixup
        callback function that could be affected by this change.
        These extra checks could possibly be removed by someone
        who has the hardware to test.
      - Removes a call to dev_kfree_skb_any() and instead utilizes the
        dev->done list to queue skbs for cleanup.
      
      The changes place full responsibility on the rx_fixup callback
      functions that clone skbs to only pass valid skbs to the
      usbnet_skb_return function.
      Signed-off-by: NEmil Goode <emilgoode@gmail.com>
      Reported-by: NIgor Gnatenko <i.gnatenko.brain@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      eb85569f
  24. 14 1月, 2014 1 次提交
  25. 07 12月, 2013 1 次提交
  26. 14 11月, 2013 1 次提交
  27. 18 10月, 2013 1 次提交
  28. 29 9月, 2013 1 次提交
  29. 06 9月, 2013 1 次提交
  30. 13 8月, 2013 1 次提交
  31. 28 7月, 2013 2 次提交
    • M
      USBNET: increase max rx/tx qlen for improving USB3 thoughtput · 452c447a
      Ming Lei 提交于
      The default RX_QLEN()/TX_QLEN() didn't consider super speed
      USB device, so only max 4 URBs are scheduled at the same time
      for tx/rx, then USB3 NIC can't perform very well.
      
      With this patch, both rx and tx thoughput are increased more than
      100Mbps when doing iperf test on ax88179_178a USB 3.0 NIC.
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      452c447a
    • M
      USBNET: centralize computing of max rx/tx qlen · a88c32ae
      Ming Lei 提交于
      This patch centralizes computing of max rx/tx qlen, because:
      
      - RX_QLEN()/TX_QLEN() is called in hot path
      - computing depends on device's usb speed, now we have ls/fs, hs, ss,
      so more checks need to be involved
      - in fact, max rx/tx qlen should not only depend on device USB
      speed, but also depend on ethernet link speed, so we need to
      consider that in future.
      - if SG support is done, max tx qlen may need change too
      
      Generally, hard_mtu and rx_urb_size are changed in bind(), reset()
      and link_reset() callback, and change mtu network operation, this
      patches introduces the API of usbnet_update_max_qlen(), and calls
      it in above path.
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a88c32ae
  32. 16 5月, 2013 1 次提交
  33. 09 5月, 2013 1 次提交
    • D
      usbnet: allow status interrupt URB to always be active · 6eecdc5f
      Dan Williams 提交于
      Some drivers (sierra_net) need the status interrupt URB
      active even when the device is closed, because they receive
      custom indications from firmware.  Add functions to refcount
      the status interrupt URB submit/kill operation so that
      sub-drivers and the generic driver don't fight over whether
      the status interrupt URB is active or not.
      
      A sub-driver can call usbnet_status_start() at any time, but
      the URB is only submitted the first time the function is
      called.  Likewise, when the sub-driver is done with the URB,
      it calls usbnet_status_stop() but the URB is only killed when
      all users have stopped it.  The URB is still killed and
      re-submitted for suspend/resume, as before, with the same
      refcount it had at suspend.
      Signed-off-by: NDan Williams <dcbw@redhat.com>
      Acked-by: NOliver Neukum <oliver@neukum.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6eecdc5f
  34. 12 4月, 2013 3 次提交
    • M
      usbnet: handle link change · 4b49f58f
      Ming Lei 提交于
      The link change is detected via the interrupt pipe, and bulk
      pipes are responsible for transfering packets, so it is reasonable
      to stop bulk transfer after link is reported as off.
      
      Two adavantages may be obtained with stopping bulk transfer
      after link becomes off:
      
      - USB bus bandwidth is saved(USB bus is shared bus except for
      USB3.0), for example, lots of 'IN' token packets and 'NYET'
      handshake packets is transfered on 2.0 bus.
      
      - probabaly power might be saved for usb host controller since
      cancelling bulk transfer may disable the asynchronous schedule of
      host controller.
      
      With this patch, when link becomes off, about ~10% performance
      boost can be found on bulk transfer of anther usb device which
      is attached to same bus with the usbnet device, see below
      test on next-20130410:
      
      - read from usb mass storage(Sandisk Extreme USB 3.0) on pandaboard
      with below command after unplugging ethernet cable:
      
      	dd if=/dev/sda iflag=direct of=/dev/null bs=1M count=800
      
      - without the patch
      1, 838860800 bytes (839 MB) copied, 36.2216 s, 23.2 MB/s
      2, 838860800 bytes (839 MB) copied, 35.8368 s, 23.4 MB/s
      3, 838860800 bytes (839 MB) copied, 35.823 s, 23.4 MB/s
      4, 838860800 bytes (839 MB) copied, 35.937 s, 23.3 MB/s
      5, 838860800 bytes (839 MB) copied, 35.7365 s, 23.5 MB/s
      average: 23.6MB/s
      
      - with the patch
      1, 838860800 bytes (839 MB) copied, 32.3817 s, 25.9 MB/s
      2, 838860800 bytes (839 MB) copied, 31.7389 s, 26.4 MB/s
      3, 838860800 bytes (839 MB) copied, 32.438 s, 25.9 MB/s
      4, 838860800 bytes (839 MB) copied, 32.5492 s, 25.8 MB/s
      5, 838860800 bytes (839 MB) copied, 31.6178 s, 26.5 MB/s
      average: 26.1MB/s
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4b49f58f
    • M
      usbnet: apply usbnet_link_change · 0162c554
      Ming Lei 提交于
      Use usbnet_link_change to handle link change centrally.
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0162c554
    • M
      usbnet: introduce usbnet_link_change API · ac64995d
      Ming Lei 提交于
      This patch introduces the API of usbnet_link_change, so that
      usbnet can handle link change centrally, which may help to
      implement killing traffic URBs for saving USB bus bandwidth
      and host controller power.
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ac64995d
  35. 05 2月, 2013 1 次提交