1. 09 7月, 2019 11 次提交
    • D
      Merge branch 'cpsw-Add-XDP-support' · aa6be2b9
      David S. Miller 提交于
      Ivan Khoronzhuk says:
      
      ====================
      net: ethernet: ti: cpsw: Add XDP support
      
      This patchset adds XDP support for TI cpsw driver and base it on
      page_pool allocator. It was verified on af_xdp socket drop,
      af_xdp l2f, ebpf XDP_DROP, XDP_REDIRECT, XDP_PASS, XDP_TX.
      
      It was verified with following configs enabled:
      CONFIG_JIT=y
      CONFIG_BPFILTER=y
      CONFIG_BPF_SYSCALL=y
      CONFIG_XDP_SOCKETS=y
      CONFIG_BPF_EVENTS=y
      CONFIG_HAVE_EBPF_JIT=y
      CONFIG_BPF_JIT=y
      CONFIG_CGROUP_BPF=y
      
      Link on previous v7:
      https://lkml.org/lkml/2019/7/4/715
      
      Also regular tests with iperf2 were done in order to verify impact on
      regular netstack performance, compared with base commit:
      https://pastebin.com/JSMT0iZ4
      
      v8..v9:
      - fix warnings on arm64 caused by typos in type casting
      
      v7..v8:
      - corrected dma calculation based on headroom instead of hard start
      - minor comment changes
      
      v6..v7:
      - rolled back to v4 solution but with small modification
      - picked up patch:
        https://www.spinics.net/lists/netdev/msg583145.html
      - added changes related to netsec fix and cpsw
      
      v5..v6:
      - do changes that is rx_dev while redirect/flush cycle is kept the same
      - dropped net: ethernet: ti: davinci_cpdma: return handler status
      - other changes desc in patches
      
      v4..v5:
      - added two plreliminary patches:
        net: ethernet: ti: davinci_cpdma: allow desc split while down
        net: ethernet: ti: cpsw_ethtool: allow res split while down
      - added xdp alocator refcnt on xdp level, avoiding page pool refcnt
      - moved flush status as separate argument for cpdma_chan_process
      - reworked cpsw code according to last changes to allocator
      - added missed statistic counter
      
      v3..v4:
      - added page pool user counter
      - use same pool for ndevs in dual mac
      - restructured page pool create/destroy according to the last changes in API
      
      v2..v3:
      - each rxq and ndev has its own page pool
      
      v1..v2:
      - combined xdp_xmit functions
      - used page allocation w/o refcnt juggle
      - unmapped page for skb netstack
      - moved rxq/page pool allocation to open/close pair
      - added several preliminary patches:
        net: page_pool: add helper function to retrieve dma addresses
        net: page_pool: add helper function to unmap dma addresses
        net: ethernet: ti: cpsw: use cpsw as drv data
        net: ethernet: ti: cpsw_ethtool: simplify slave loops
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      aa6be2b9
    • I
      net: ethernet: ti: cpsw: add XDP support · 9ed4050c
      Ivan Khoronzhuk 提交于
      Add XDP support based on rx page_pool allocator, one frame per page.
      Page pool allocator is used with assumption that only one rx_handler
      is running simultaneously. DMA map/unmap is reused from page pool
      despite there is no need to map whole page.
      
      Due to specific of cpsw, the same TX/RX handler can be used by 2
      network devices, so special fields in buffer are added to identify
      an interface the frame is destined to. Thus XDP works for both
      interfaces, that allows to test xdp redirect between two interfaces
      easily. Also, each rx queue have own page pools, but common for both
      netdevs.
      
      XDP prog is common for all channels till appropriate changes are added
      in XDP infrastructure. Also, once page_pool recycling becomes part of
      skb netstack some simplifications can be added, like removing
      page_pool_release_page() before skb receive.
      
      In order to keep rx_dev while redirect, that can be somehow used in
      future, do flush in rx_handler, that allows to keep rx dev the same
      while redirect. It allows to conform with tracing rx_dev pointed
      by Jesper.
      
      Also, there is probability, that XDP generic code can be extended to
      support multi ndev drivers like this one, using same rx queue for
      several ndevs, based on switchdev for instance or else. In this case,
      driver can be modified like exposed here:
      https://lkml.org/lkml/2019/7/3/243Acked-by: NJesper Dangaard Brouer <brouer@redhat.com>
      Signed-off-by: NIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9ed4050c
    • I
      net: ethernet: ti: cpsw_ethtool: allow res split while down · 608ef620
      Ivan Khoronzhuk 提交于
      That's possible to set channel num while interfaces are down. When
      interface gets up it should resplit budget. This resplit can happen
      after phy is up but only if speed is changed, so should be set before
      this, for this allow it to happen while changing number of channels,
      when interfaces are down.
      Signed-off-by: NIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      608ef620
    • I
      net: ethernet: ti: davinci_cpdma: allow desc split while down · 962fb618
      Ivan Khoronzhuk 提交于
      That's possible to set ring params while interfaces are down. When
      interface gets up it uses number of descs to fill rx queue and on
      later on changes to create rx pools. Usually, this resplit can happen
      after phy is up, but it can be needed before this, so allow it to
      happen while setting number of rx descs, when interfaces are down.
      Also, if no dependency on intf state, move it to cpdma layer, where
      it should be.
      Signed-off-by: NIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      962fb618
    • I
      net: ethernet: ti: davinci_cpdma: add dma mapped submit · 6670acac
      Ivan Khoronzhuk 提交于
      In case if dma mapped packet needs to be sent, like with XDP
      page pool, the "mapped" submit can be used. This patch adds dma
      mapped submit based on regular one.
      Signed-off-by: NIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6670acac
    • I
      net: core: page_pool: add user refcnt and reintroduce page_pool_destroy · 1da4bbef
      Ivan Khoronzhuk 提交于
      Jesper recently removed page_pool_destroy() (from driver invocation)
      and moved shutdown and free of page_pool into xdp_rxq_info_unreg(),
      in-order to handle in-flight packets/pages. This created an asymmetry
      in drivers create/destroy pairs.
      
      This patch reintroduce page_pool_destroy and add page_pool user
      refcnt. This serves the purpose to simplify drivers error handling as
      driver now drivers always calls page_pool_destroy() and don't need to
      track if xdp_rxq_info_reg_mem_model() was unsuccessful.
      
      This could be used for a special cases where a single RX-queue (with a
      single page_pool) provides packets for two net_device'es, and thus
      needs to register the same page_pool twice with two xdp_rxq_info
      structures.
      
      This patch is primarily to ease API usage for drivers. The recently
      merged netsec driver, actually have a bug in this area, which is
      solved by this API change.
      
      This patch is a modified version of Ivan Khoronzhuk's original patch.
      
      Link: https://lore.kernel.org/netdev/20190625175948.24771-2-ivan.khoronzhuk@linaro.org/
      Fixes: 5c67bf0e ("net: netsec: Use page_pool API")
      Signed-off-by: NJesper Dangaard Brouer <brouer@redhat.com>
      Reviewed-by: NIlias Apalodimas <ilias.apalodimas@linaro.org>
      Acked-by: NJesper Dangaard Brouer <brouer@redhat.com>
      Reviewed-by: NSaeed Mahameed <saeedm@mellanox.com>
      Signed-off-by: NIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1da4bbef
    • A
      macb: fix build warning for !CONFIG_OF · 49db9228
      Arnd Bergmann 提交于
      When CONFIG_OF is disabled, we get a harmless warning about the
      newly added variable:
      
      drivers/net/ethernet/cadence/macb_main.c:48:39: error: 'mgmt' defined but not used [-Werror=unused-variable]
       static struct sifive_fu540_macb_mgmt *mgmt;
      
      Move the variable closer to its use inside of the #ifdef.
      
      Fixes: c218ad55 ("macb: Add support for SiFive FU540-C000")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      49db9228
    • A
      gve: fix unused variable/label warnings · 0287f9ed
      Arnd Bergmann 提交于
      On unusual page sizes, we get harmless warnings:
      
      drivers/net/ethernet/google/gve/gve_rx.c:283:6: error: unused variable 'pagecount' [-Werror,-Wunused-variable]
      drivers/net/ethernet/google/gve/gve_rx.c:336:1: error: unused label 'have_skb' [-Werror,-Wunused-label]
      
      Change the preprocessor #if to regular if() to avoid this.
      
      Fixes: f5cedc84 ("gve: Add transmit and receive support")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0287f9ed
    • M
      sfc: Remove 'PCIE error reporting unavailable' · 05cfee98
      Martin Habets 提交于
      This is only at notice level but it was pointed out that no other driver
      does this.
      Also there is no action the user can take as it is really a property of
      the server.
      Signed-off-by: NMartin Habets <mhabets@solarflare.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      05cfee98
    • D
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next · 47cfb904
      David S. Miller 提交于
      Pablo Neira Ayuso says:
      
      ====================
      Netfilter/IPVS updates for net-next
      
      The following patchset contains Netfilter/IPVS updates for net-next:
      
      1) Move bridge keys in nft_meta to nft_meta_bridge, from wenxu.
      
      2) Support for bridge pvid matching, from wenxu.
      
      3) Support for bridge vlan protocol matching, also from wenxu.
      
      4) Add br_vlan_get_pvid_rcu(), to fetch the bridge port pvid
         from packet path.
      
      5) Prefer specific family extension in nf_tables.
      
      6) Autoload specific family extension in case it is missing.
      
      7) Add synproxy support to nf_tables, from Fernando Fernandez Mancera.
      
      8) Support for GRE encapsulation in IPVS, from Vadim Fedorenko.
      
      9) ICMP handling for GRE encapsulation, from Julian Anastasov.
      
      10) Remove unused parameter in nf_queue, from Florian Westphal.
      
      11) Replace seq_printf() by seq_puts() in nf_log, from Markus Elfring.
      
      12) Rename nf_SYNPROXY.h => nf_synproxy.h before this header becomes
          public.
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      47cfb904
    • I
      net: netsec: Sync dma for device on buffer allocation · bfb20412
      Ilias Apalodimas 提交于
      cd1973a9 ("net: netsec: Sync dma for device on buffer allocation")
      was merged on it's v1 instead of the v3.
      Merge the proper patch version
      Signed-off-by: NIlias Apalodimas <ilias.apalodimas@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      bfb20412
  2. 08 7月, 2019 10 次提交
  3. 07 7月, 2019 6 次提交
    • D
      Merge tag 'wireless-drivers-next-for-davem-2019-07-06' of... · 437fde6c
      David S. Miller 提交于
      Merge tag 'wireless-drivers-next-for-davem-2019-07-06' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next
      
      Kalle Valo says:
      
      ====================
      wireless-drivers-next patches for 5.3
      
      Second, and last, set of patches for 5.3.
      
      Major changes:
      
      mt76
      
      * use NAPI polling for tx cleanup on mt7603/mt7615
      
      * add support for toggling edcca on mt7603
      
      * fix rate control / tx status reporting issues on mt76x02/mt7603
      
      * add support for eeprom calibration data from mtd on mt7615
      
      * support configuring tx power on mt7615
      
      * per-chain signal reporting on mt7615
      
      iwlwifi
      
      * Update the FW API for Channel State Information (CSI)
      
      * Special Specific Absorption Rate (SAR) implementation for South Korea
      
      ath10k
      
      * fixes for SDIO support
      
      * add support for firmware logging via WMI
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      437fde6c
    • S
      Bluetooth: btusb: Add protocol support for MediaTek MT7663U USB devices · 9ce67c32
      Sean Wang 提交于
      This adds the support of enabling MT7663U Bluetooth function running
      on the top of btusb driver.
      
      The information in /sys/kernel/debug/usb/devices about the Bluetooth
      device is listed as the below.
      
      T:  Bus=04 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  5 Spd=5000 MxCh= 0
      D:  Ver= 3.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS= 9 #Cfgs=  1
      P:  Vendor=0e8d ProdID=7663 Rev= 1.00
      S:  Manufacturer=MediaTek Inc.
      S:  Product=Wireless_Device
      S:  SerialNumber=000000000
      C:* #Ifs= 3 Cfg#= 1 Atr=a0 MxPwr=160mA
      A:  FirstIf#= 0 IfCount= 2 Cls=e0(wlcon) Sub=01 Prot=01
      I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=125us
      E:  Ad=82(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      E:  Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      I:  If#= 1 Alt= 6 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  63 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  63 Ivl=1ms
      Signed-off-by: NSean Wang <sean.wang@mediatek.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      9ce67c32
    • S
      Bluetooth: btusb: Add protocol support for MediaTek MT7668U USB devices · a1c49c43
      Sean Wang 提交于
      This adds the support of enabling MT7668U Bluetooth function running
      on the top of btusb driver.
      
      The information in /sys/kernel/debug/usb/devices about the Bluetooth
      device is listed as the below.
      
      T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=5000 MxCh= 0
      D:  Ver= 3.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS= 9 #Cfgs=  1
      P:  Vendor=0e8d ProdID=7668 Rev= 1.00
      S:  Manufacturer=MediaTek Inc.
      S:  Product=Wireless_Device
      S:  SerialNumber=000000000
      C:* #Ifs= 3 Cfg#= 1 Atr=a0 MxPwr=160mA
      A:  FirstIf#= 0 IfCount= 2 Cls=e0(wlcon) Sub=01 Prot=01
      I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=125us
      E:  Ad=82(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      E:  Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      I:  If#= 1 Alt= 6 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  63 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  63 Ivl=1ms
      Signed-off-by: NSean Wang <sean.wang@mediatek.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      a1c49c43
    • J
      Bluetooth: 6lowpan: always check destination address · 688d94fd
      Josua Mayer 提交于
      BLE based 6LoWPAN networks are highly constrained in bandwidth.
      Do not take a short-cut, always check if the destination address is
      known to belong to a peer.
      
      As a side-effect this also removes any behavioral differences between
      one, and two or more connected peers.
      Acked-by: NJukka Rissanen <jukka.rissanen@linux.intel.com>
      Tested-by: NMichael Scott <mike@foundries.io>
      Signed-off-by: NJosua Mayer <josua.mayer@jm0.eu>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      688d94fd
    • J
      Bluetooth: 6lowpan: check neighbour table for SLAAC · 5636376c
      Josua Mayer 提交于
      Like any IPv6 capable device, 6LNs can have multiple addresses assigned
      using SLAAC and made known through neighbour advertisements.
      After checking the destination address against all peers link-local
      addresses, consult the neighbour cache for additional known addresses.
      
      RFC7668 defines the scope of Neighbor Advertisements in Section 3.2.3:
      1. "A Bluetooth LE 6LN MUST NOT register its link-local address"
      2. "A Bluetooth LE 6LN MUST register its non-link-local addresses with
      the 6LBR by sending Neighbor Solicitation (NS) messages ..."
      
      Due to these constranits both the link-local addresses tracked in the
      list of 6lowpan peers, and the neighbour cache have to be used when
      identifying the 6lowpan peer for a destination address.
      Acked-by: NJukka Rissanen <jukka.rissanen@linux.intel.com>
      Tested-by: NMichael Scott <mike@foundries.io>
      Signed-off-by: NJosua Mayer <josua.mayer@jm0.eu>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      5636376c
    • J
      Bluetooth: 6lowpan: search for destination address in all peers · b188b032
      Josua Mayer 提交于
      Handle overlooked case where the target address is assigned to a peer
      and neither route nor gateway exist.
      
      For one peer, no checks are performed to see if it is meant to receive
      packets for a given address.
      
      As soon as there is a second peer however, checks are performed
      to deal with routes and gateways for handling complex setups with
      multiple hops to a target address.
      This logic assumed that no route and no gateway imply that the
      destination address can not be reached, which is false in case of a
      direct peer.
      Acked-by: NJukka Rissanen <jukka.rissanen@linux.intel.com>
      Tested-by: NMichael Scott <mike@foundries.io>
      Signed-off-by: NJosua Mayer <josua.mayer@jm0.eu>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      b188b032
  4. 06 7月, 2019 13 次提交
    • S
      Bluetooth: Add SMP workaround Microsoft Surface Precision Mouse bug · 1d87b88b
      Szymon Janc 提交于
      Microsoft Surface Precision Mouse provides bogus identity address when
      pairing. It connects with Static Random address but provides Public
      Address in SMP Identity Address Information PDU. Address has same
      value but type is different. Workaround this by dropping IRK if ID
      address discrepancy is detected.
      
      > HCI Event: LE Meta Event (0x3e) plen 19
            LE Connection Complete (0x01)
              Status: Success (0x00)
              Handle: 75
              Role: Master (0x00)
              Peer address type: Random (0x01)
              Peer address: E0:52:33:93:3B:21 (Static)
              Connection interval: 50.00 msec (0x0028)
              Connection latency: 0 (0x0000)
              Supervision timeout: 420 msec (0x002a)
              Master clock accuracy: 0x00
      
      ....
      
      > ACL Data RX: Handle 75 flags 0x02 dlen 12
            SMP: Identity Address Information (0x09) len 7
              Address type: Public (0x00)
              Address: E0:52:33:93:3B:21
      Signed-off-by: NSzymon Janc <szymon.janc@codecoup.pl>
      Tested-by: NMaarten Fonville <maarten.fonville@gmail.com>
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199461
      Cc: stable@vger.kernel.org
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      1d87b88b
    • L
      Bluetooth: L2CAP: Check bearer type on __l2cap_global_chan_by_addr · 00f62726
      Luiz Augusto von Dentz 提交于
      The spec defines PSM and LE_PSM as different domains so a listen on the
      same PSM is valid if the address type points to a different bearer.
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      00f62726
    • L
      Bluetooth: Use controller sets when available · 1d0fac2c
      Luiz Augusto von Dentz 提交于
      This makes use of controller sets when using Extended Advertising
      feature thus offloading the scheduling to the controller.
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      1d0fac2c
    • C
      Bluetooth: validate BLE connection interval updates · c49a8682
      csonsino 提交于
      Problem: The Linux Bluetooth stack yields complete control over the BLE
      connection interval to the remote device.
      
      The Linux Bluetooth stack provides access to the BLE connection interval
      min and max values through /sys/kernel/debug/bluetooth/hci0/
      conn_min_interval and /sys/kernel/debug/bluetooth/hci0/conn_max_interval.
      These values are used for initial BLE connections, but the remote device
      has the ability to request a connection parameter update. In the event
      that the remote side requests to change the connection interval, the Linux
      kernel currently only validates that the desired value is within the
      acceptable range in the Bluetooth specification (6 - 3200, corresponding to
      7.5ms - 4000ms). There is currently no validation that the desired value
      requested by the remote device is within the min/max limits specified in
      the conn_min_interval/conn_max_interval configurations. This essentially
      leads to Linux yielding complete control over the connection interval to
      the remote device.
      
      The proposed patch adds a verification step to the connection parameter
      update mechanism, ensuring that the desired value is within the min/max
      bounds of the current connection. If the desired value is outside of the
      current connection min/max values, then the connection parameter update
      request is rejected and the negative response is returned to the remote
      device. Recall that the initial connection is established using the local
      conn_min_interval/conn_max_interval values, so this allows the Linux
      administrator to retain control over the BLE connection interval.
      
      The one downside that I see is that the current default Linux values for
      conn_min_interval and conn_max_interval typically correspond to 30ms and
      50ms respectively. If this change were accepted, then it is feasible that
      some devices would no longer be able to negotiate to their desired
      connection interval values. This might be remedied by setting the default
      Linux conn_min_interval and conn_max_interval values to the widest
      supported range (6 - 3200 / 7.5ms - 4000ms). This could lead to the same
      behavior as the current implementation, where the remote device could
      request to change the connection interval value to any value that is
      permitted by the Bluetooth specification, and Linux would accept the
      desired value.
      Signed-off-by: NCarey Sonsino <csonsino@gmail.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      c49a8682
    • S
      Bluetooth: Add support for LE ping feature · 302975cb
      Spoorthi Ravishankar Koppad 提交于
      Changes made to add HCI Write Authenticated Payload timeout
      command for LE Ping feature.
      
      As per the Core Specification 5.0 Volume 2 Part E Section 7.3.94,
      the following code changes implements
      HCI Write Authenticated Payload timeout command for LE Ping feature.
      Signed-off-by: NSpoorthi Ravishankar Koppad <spoorthix.k@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      302975cb
    • M
      Bluetooth: Check state in l2cap_disconnect_rsp · 28261da8
      Matias Karhumaa 提交于
      Because of both sides doing L2CAP disconnection at the same time, it
      was possible to receive L2CAP Disconnection Response with CID that was
      already freed. That caused problems if CID was already reused and L2CAP
      Connection Request with same CID was sent out. Before this patch kernel
      deleted channel context regardless of the state of the channel.
      
      Example where leftover Disconnection Response (frame #402) causes local
      device to delete L2CAP channel which was not yet connected. This in
      turn confuses remote device's stack because same CID is re-used without
      properly disconnecting.
      
      Btmon capture before patch:
      ** snip **
      > ACL Data RX: Handle 43 flags 0x02 dlen 8                #394 [hci1] 10.748949
            Channel: 65 len 4 [PSM 3 mode 0] {chan 2}
            RFCOMM: Disconnect (DISC) (0x43)
               Address: 0x03 cr 1 dlci 0x00
               Control: 0x53 poll/final 1
               Length: 0
               FCS: 0xfd
      < ACL Data TX: Handle 43 flags 0x00 dlen 8                #395 [hci1] 10.749062
            Channel: 65 len 4 [PSM 3 mode 0] {chan 2}
            RFCOMM: Unnumbered Ack (UA) (0x63)
               Address: 0x03 cr 1 dlci 0x00
               Control: 0x73 poll/final 1
               Length: 0
               FCS: 0xd7
      < ACL Data TX: Handle 43 flags 0x00 dlen 12               #396 [hci1] 10.749073
            L2CAP: Disconnection Request (0x06) ident 17 len 4
              Destination CID: 65
              Source CID: 65
      > HCI Event: Number of Completed Packets (0x13) plen 5    #397 [hci1] 10.752391
              Num handles: 1
              Handle: 43
              Count: 1
      > HCI Event: Number of Completed Packets (0x13) plen 5    #398 [hci1] 10.753394
              Num handles: 1
              Handle: 43
              Count: 1
      > ACL Data RX: Handle 43 flags 0x02 dlen 12               #399 [hci1] 10.756499
            L2CAP: Disconnection Request (0x06) ident 26 len 4
              Destination CID: 65
              Source CID: 65
      < ACL Data TX: Handle 43 flags 0x00 dlen 12               #400 [hci1] 10.756548
            L2CAP: Disconnection Response (0x07) ident 26 len 4
              Destination CID: 65
              Source CID: 65
      < ACL Data TX: Handle 43 flags 0x00 dlen 12               #401 [hci1] 10.757459
            L2CAP: Connection Request (0x02) ident 18 len 4
              PSM: 1 (0x0001)
              Source CID: 65
      > ACL Data RX: Handle 43 flags 0x02 dlen 12               #402 [hci1] 10.759148
            L2CAP: Disconnection Response (0x07) ident 17 len 4
              Destination CID: 65
              Source CID: 65
      = bluetoothd: 00:1E:AB:4C:56:54: error updating services: Input/o..   10.759447
      > HCI Event: Number of Completed Packets (0x13) plen 5    #403 [hci1] 10.759386
              Num handles: 1
              Handle: 43
              Count: 1
      > ACL Data RX: Handle 43 flags 0x02 dlen 12               #404 [hci1] 10.760397
            L2CAP: Connection Request (0x02) ident 27 len 4
              PSM: 3 (0x0003)
              Source CID: 65
      < ACL Data TX: Handle 43 flags 0x00 dlen 16               #405 [hci1] 10.760441
            L2CAP: Connection Response (0x03) ident 27 len 8
              Destination CID: 65
              Source CID: 65
              Result: Connection successful (0x0000)
              Status: No further information available (0x0000)
      < ACL Data TX: Handle 43 flags 0x00 dlen 27               #406 [hci1] 10.760449
            L2CAP: Configure Request (0x04) ident 19 len 19
              Destination CID: 65
              Flags: 0x0000
              Option: Maximum Transmission Unit (0x01) [mandatory]
                MTU: 1013
              Option: Retransmission and Flow Control (0x04) [mandatory]
                Mode: Basic (0x00)
                TX window size: 0
                Max transmit: 0
                Retransmission timeout: 0
                Monitor timeout: 0
                Maximum PDU size: 0
      > HCI Event: Number of Completed Packets (0x13) plen 5    #407 [hci1] 10.761399
              Num handles: 1
              Handle: 43
              Count: 1
      > ACL Data RX: Handle 43 flags 0x02 dlen 16               #408 [hci1] 10.762942
            L2CAP: Connection Response (0x03) ident 18 len 8
              Destination CID: 66
              Source CID: 65
              Result: Connection successful (0x0000)
              Status: No further information available (0x0000)
      *snip*
      
      Similar case after the patch:
      *snip*
      > ACL Data RX: Handle 43 flags 0x02 dlen 8            #22702 [hci0] 1664.411056
            Channel: 65 len 4 [PSM 3 mode 0] {chan 3}
            RFCOMM: Disconnect (DISC) (0x43)
               Address: 0x03 cr 1 dlci 0x00
               Control: 0x53 poll/final 1
               Length: 0
               FCS: 0xfd
      < ACL Data TX: Handle 43 flags 0x00 dlen 8            #22703 [hci0] 1664.411136
            Channel: 65 len 4 [PSM 3 mode 0] {chan 3}
            RFCOMM: Unnumbered Ack (UA) (0x63)
               Address: 0x03 cr 1 dlci 0x00
               Control: 0x73 poll/final 1
               Length: 0
               FCS: 0xd7
      < ACL Data TX: Handle 43 flags 0x00 dlen 12           #22704 [hci0] 1664.411143
            L2CAP: Disconnection Request (0x06) ident 11 len 4
              Destination CID: 65
              Source CID: 65
      > HCI Event: Number of Completed Pac.. (0x13) plen 5  #22705 [hci0] 1664.414009
              Num handles: 1
              Handle: 43
              Count: 1
      > HCI Event: Number of Completed Pac.. (0x13) plen 5  #22706 [hci0] 1664.415007
              Num handles: 1
              Handle: 43
              Count: 1
      > ACL Data RX: Handle 43 flags 0x02 dlen 12           #22707 [hci0] 1664.418674
            L2CAP: Disconnection Request (0x06) ident 17 len 4
              Destination CID: 65
              Source CID: 65
      < ACL Data TX: Handle 43 flags 0x00 dlen 12           #22708 [hci0] 1664.418762
            L2CAP: Disconnection Response (0x07) ident 17 len 4
              Destination CID: 65
              Source CID: 65
      < ACL Data TX: Handle 43 flags 0x00 dlen 12           #22709 [hci0] 1664.421073
            L2CAP: Connection Request (0x02) ident 12 len 4
              PSM: 1 (0x0001)
              Source CID: 65
      > ACL Data RX: Handle 43 flags 0x02 dlen 12           #22710 [hci0] 1664.421371
            L2CAP: Disconnection Response (0x07) ident 11 len 4
              Destination CID: 65
              Source CID: 65
      > HCI Event: Number of Completed Pac.. (0x13) plen 5  #22711 [hci0] 1664.424082
              Num handles: 1
              Handle: 43
              Count: 1
      > HCI Event: Number of Completed Pac.. (0x13) plen 5  #22712 [hci0] 1664.425040
              Num handles: 1
              Handle: 43
              Count: 1
      > ACL Data RX: Handle 43 flags 0x02 dlen 12           #22713 [hci0] 1664.426103
            L2CAP: Connection Request (0x02) ident 18 len 4
              PSM: 3 (0x0003)
              Source CID: 65
      < ACL Data TX: Handle 43 flags 0x00 dlen 16           #22714 [hci0] 1664.426186
            L2CAP: Connection Response (0x03) ident 18 len 8
              Destination CID: 66
              Source CID: 65
              Result: Connection successful (0x0000)
              Status: No further information available (0x0000)
      < ACL Data TX: Handle 43 flags 0x00 dlen 27           #22715 [hci0] 1664.426196
            L2CAP: Configure Request (0x04) ident 13 len 19
              Destination CID: 65
              Flags: 0x0000
              Option: Maximum Transmission Unit (0x01) [mandatory]
                MTU: 1013
              Option: Retransmission and Flow Control (0x04) [mandatory]
                Mode: Basic (0x00)
                TX window size: 0
                Max transmit: 0
                Retransmission timeout: 0
                Monitor timeout: 0
                Maximum PDU size: 0
      > ACL Data RX: Handle 43 flags 0x02 dlen 16           #22716 [hci0] 1664.428804
            L2CAP: Connection Response (0x03) ident 12 len 8
              Destination CID: 66
              Source CID: 65
              Result: Connection successful (0x0000)
              Status: No further information available (0x0000)
      *snip*
      
      Fix is to check that channel is in state BT_DISCONN before deleting the
      channel.
      
      This bug was found while fuzzing Bluez's OBEX implementation using
      Synopsys Defensics.
      Reported-by: NMatti Kamunen <matti.kamunen@synopsys.com>
      Reported-by: NAri Timonen <ari.timonen@synopsys.com>
      Signed-off-by: NMatias Karhumaa <matias.karhumaa@gmail.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      28261da8
    • D
      Bluetooth: hidp: NUL terminate a string in the compat ioctl · dcae9052
      Dan Carpenter 提交于
      This change is similar to commit a1616a5a ("Bluetooth: hidp: fix
      buffer overflow") but for the compat ioctl.  We take a string from the
      user and forgot to ensure that it's NUL terminated.
      
      I have also changed the strncpy() in to strscpy() in hidp_setup_hid().
      The difference is the strncpy() doesn't necessarily NUL terminate the
      destination string.  Either change would fix the problem but it's nice
      to take a belt and suspenders approach and do both.
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      dcae9052
    • J
      Bluetooth: Add new 13d3:3491 QCA_ROME device · 44d34af2
      João Paulo Rechi Vita 提交于
      Without the QCA ROME setup routine this adapter fails to establish a SCO
      connection.
      
      T:  Bus=01 Lev=01 Prnt=01 Port=08 Cnt=01 Dev#=  2 Spd=12  MxCh= 0
      D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
      P:  Vendor=13d3 ProdID=3491 Rev=00.01
      C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
      I:  If#=0x0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      I:  If#=0x1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      Signed-off-by: NJoão Paulo Rechi Vita <jprvita@endlessm.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      44d34af2
    • J
      Bluetooth: Add new 13d3:3501 QCA_ROME device · 881cec4f
      João Paulo Rechi Vita 提交于
      Without the QCA ROME setup routine this adapter fails to establish a SCO
      connection.
      
      T:  Bus=01 Lev=01 Prnt=01 Port=04 Cnt=01 Dev#=  2 Spd=12  MxCh= 0
      D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
      P:  Vendor=13d3 ProdID=3501 Rev=00.01
      C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
      I:  If#=0x0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      I:  If#=0x1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      Signed-off-by: NJoão Paulo Rechi Vita <jprvita@endlessm.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      881cec4f
    • T
      Bluetooth: hci_bcsp: Fix memory leak in rx_skb · 4ce9146e
      Tomas Bortoli 提交于
      Syzkaller found that it is possible to provoke a memory leak by
      never freeing rx_skb in struct bcsp_struct.
      
      Fix by freeing in bcsp_close()
      Signed-off-by: NTomas Bortoli <tomasbortoli@gmail.com>
      Reported-by: syzbot+98162c885993b72f19c4@syzkaller.appspotmail.com
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      4ce9146e
    • L
      Bluetooth:: btrtl: Add support for RTL8723DU · 6c595ea8
      Larry Finger 提交于
      This device is functionally equivalent to the BT part of the RTL8723DE,
      uses the same firmware, but the LMP subversion and HCI revision are unique.
      Signed-off-by: NLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      6c595ea8
    • S
      Bluetooth: btmtkuart: add an implementation for clock osc property · 05582561
      Sean Wang 提交于
      Some board requires explicitily control external osscilator via GPIO.
      So, add an implementation of a clock property for an external oscillator
      to the device.
      Signed-off-by: NSean Wang <sean.wang@mediatek.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      05582561
    • S
      Bluetooth: btmtkuart: add an implementation for boot-gpios property · a3cb6d60
      Sean Wang 提交于
      Not every platform has the pinctrl device integrates the GPIO the function
      such as MT7621 whose pinctrl and GPIO are separate hardware so the driver
      adds additional boot-gpios to let the MT766[3,8]U can enter the proper boot
      mode by gpiod for such platform.
      Signed-off-by: NSean Wang <sean.wang@mediatek.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      a3cb6d60