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. 05 7月, 2016 1 次提交
  3. 21 5月, 2016 1 次提交
  4. 01 4月, 2016 1 次提交
  5. 08 3月, 2016 2 次提交
  6. 24 12月, 2015 1 次提交
    • B
      net: cdc_ncm: avoid changing RX/TX buffers on MTU changes · 1dfddff5
      Bjørn Mork 提交于
      NCM buffer sizes are negotiated with the device independently of
      the network device MTU.  The RX buffers are allocated by the
      usbnet framework based on the rx_urb_size value set by cdc_ncm. A
      single RX buffer can hold a number of MTU sized packets.
      
      The default usbnet change_mtu ndo only modifies rx_urb_size if it
      is equal to hard_mtu.  And the cdc_ncm driver will set rx_urb_size
      and hard_mtu independently of each other, based on dwNtbInMaxSize
      and dwNtbOutMaxSize respectively. It was therefore assumed that
      usbnet_change_mtu() would never touch rx_urb_size.  This failed to
      consider the case where dwNtbInMaxSize and dwNtbOutMaxSize happens
      to be equal.
      
      Fix by implementing an NCM specific change_mtu ndo, modifying the
      netdev MTU without touching the buffer size settings.
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1dfddff5
  7. 22 12月, 2015 2 次提交
  8. 07 12月, 2015 1 次提交
  9. 06 12月, 2015 1 次提交
  10. 25 11月, 2015 1 次提交
    • B
      net: cdc_ncm: fix NULL pointer deref in cdc_ncm_bind_common · 6527f833
      Bjørn Mork 提交于
      Commit 77b0a099 ("cdc-ncm: use common parser") added a dangerous
      new trust in the CDC functional descriptors presented by the device,
      unconditionally assuming that any device handled by the driver has
      a CDC Union descriptor.
      
      This descriptor is required by the NCM and MBIM specs, but crashing
      on non-compliant devices is still unacceptable. Not only will that
      allow malicious devices to crash the kernel, but in this case it is
      also well known that there are non-compliant real devices on the
      market - as shown by the comment accompanying the IAD workaround
      in the same function.
      
      The Sierra Wireless EM7305 is an example of such device, having
      a CDC header and a CDC MBIM descriptor but no CDC Union:
      
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber       12
            bAlternateSetting       0
            bNumEndpoints           1
            bInterfaceClass         2 Communications
            bInterfaceSubClass     14
            bInterfaceProtocol      0
            iInterface              0
            CDC Header:
              bcdCDC               1.10
            CDC MBIM:
              bcdMBIMVersion       1.00
              wMaxControlMessage   4096
              bNumberFilters       16
              bMaxFilterSize       128
              wMaxSegmentSize      4064
              bmNetworkCapabilities 0x20
                8-byte ntb input size
            Endpoint Descriptor:
      	..
      
      The conversion to a common parser also left the local cdc_union
      variable untouched.  This caused the IAD workaround code to be applied
      to all devices with an IAD descriptor, which was never intended.  Finish
      the conversion by testing for hdr.usb_cdc_union_desc instead.
      
      Cc: Oliver Neukum <oneukum@suse.com>
      Fixes: 77b0a099 ("cdc-ncm: use common parser")
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6527f833
  11. 16 9月, 2015 1 次提交
  12. 12 7月, 2015 1 次提交
  13. 10 7月, 2015 1 次提交
    • E
      cdc_ncm: Add support for moving NDP to end of NCM frame · 4a0e3e98
      Enrico Mioso 提交于
      NCM specs are not actually mandating a specific position in the frame for
      the NDP (Network Datagram Pointer). However, some Huawei devices will
      ignore our aggregates if it is not placed after the datagrams it points
      to. Add support for doing just this, in a per-device configurable way.
      While at it, update NCM subdrivers, disabling this functionality in all of
      them, except in huawei_cdc_ncm where it is enabled instead.
      We aren't making any distinction between different Huawei NCM devices,
      based on what the vendor driver does. Standard NCM devices are left
      unaffected: if they are compliant, they should be always usable, still
      stay on the safe side.
      
      This change has been tested and working with a Huawei E3131 device (which
      works regardless of NDP position), a Huawei E3531 (also working both
      ways) and an E3372 (which mandates NDP to be after indexed datagrams).
      
      V1->V2:
      - corrected wrong NDP acronym definition
      - fixed possible NULL pointer dereference
      - patch cleanup
      V2->V3:
      - Properly account for the NDP size when writing new packets to SKB
      Signed-off-by: NEnrico Mioso <mrkiko.rs@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4a0e3e98
  14. 23 5月, 2015 1 次提交
  15. 30 3月, 2015 2 次提交
  16. 01 3月, 2015 1 次提交
  17. 03 6月, 2014 7 次提交
    • B
      net: cdc_ncm: allow tuning min_tx_pkt · 39eb7e0e
      Bjørn Mork 提交于
      The min_tx_pkt variable decides the cutoff point where the driver
      will stop padding out NTBs to maximum size. The padding is a tradeoff
      where we use some USB bus bandwidth to allow the device to receive
      fixed size buffers. Different devices will have different optimal
      settings, spanning from no padding at all to padding every NTB.
      There is no way to automatically figure out which setting is best
      for a specific device.
      
      The default value is a reasonable tradeoff, calculated based on the
      USB packet size and out NTB max size. This may have to be changed
      along with any tx_max changes.
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      39eb7e0e
    • B
      net: cdc_ncm: export NCM Transfer Block (NTB) parameters · 871578c9
      Bjørn Mork 提交于
      The mandatory GetNtbParameters control request is an important part of
      the host <-> device protocol negotiation in CDC NCM (and CDC MBIM). It
      gives device limits which the host must obey when configuring the
      protocol aggregation variables. The driver will enforce this by
      rejecting attempts to set any of the tunable variables to a value
      which is not supported by the device.  Exporting the parameter block
      helps userspace decide which values are allowed without resorting
      to trial and error.
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      871578c9
    • B
      net: cdc_ncm: drop ethtool coalesce support · e368d27f
      Bjørn Mork 提交于
      The ethtool coalesce API is not applicable for this driver. Forcing
      it to fit the NCM aggregation redefined the API in a driver specific
      way, which is much worse than defining a clean new API. These ethtool
      coalesce functions have therefore been replaced by a new sysfs API.
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e368d27f
    • B
      net: cdc_ncm: use sysfs for rx/tx aggregation tuning · 289507d3
      Bjørn Mork 提交于
      Attach a driver specific sysfs group to the netdev, and use it
      for the rx/tx aggregation variables.
      
      The datagram aggregation defined by the CDC NCM specification is
      specific to this device class (including CDC MBIM). Using the
      ethtool interrupt coalesce API as an interface to the aggregation
      parameters redefined that API in a driver specific and confusing
      way.  A sysfs group
       - makes it clear that this is a driver specific userspace API, and
       - allows us to export the real values instead of some translated
         version, and
       - lets us include more aggregation variables which were impossible
         to force into the ethtool API.
      
      Additionally, using sysfs allows tuning the driver on space
      constrained hosts where userspace tools like ethtool are undesired.
      Suggested-by: NPeter Stuge <peter@stuge.se>
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      289507d3
    • B
      net: cdc_ncm: inform usbnet when rx buffers are reduced · f42763db
      Bjørn Mork 提交于
      It doesn't matter whether the buffer size goes up or down.  We have to
      keep usbnet and device syncronized to be able to split transfers at the
      correct boundaries. The spec allow skipping short packets when using
      max sized transfers.  If we don't tell usbnet about our new expected rx
      buffer size, then it will merge and/or split NTBs.  The driver does not
      support this, and the result will be lots of framing errors.
      
      Fix by always reallocating usbnet rx buffers when the rx_max value
      changes.
      
      Fixes: 68864abf ("net: cdc_ncm: support rx_max/tx_max updates when running")
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f42763db
    • B
      net: cdc_ncm: always reallocate tx_curr_skb when tx_max increases · 1ba5d0ff
      Bjørn Mork 提交于
      We are calling usbnet_start_xmit() to flush any remaining data,
      depending on the side effect that tx_curr_skb is set to NULL,
      ensuring a new allocation using the updated tx_max.  But this
      side effect will only happen if there were any cached data ready
      to transmit. If not, then an empty tx_curr_skb is still allocated
      using the old tx_max size. Free it to avoid a buffer overrun.
      
      Fixes: 68864abf ("net: cdc_ncm: support rx_max/tx_max updates when running")
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1ba5d0ff
    • B
      net: cdc_ncm: reduce skb truesize in rx path · 1e2c6117
      Bjørn Mork 提交于
      Cloning the big skbs we use for USB buffering chokes up TCP and
      SCTP because the socket memory limits are hitting earlier than
      they should. It is better to unconditionally copy the unwrapped
      packets to freshly allocated skbs.
      Reported-by: NJim Baxter <jim_baxter@mentor.com>
      Acked-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1e2c6117
  18. 23 5月, 2014 1 次提交
  19. 21 5月, 2014 1 次提交
  20. 17 5月, 2014 12 次提交