GitHub/moto-9609/android_kernel_motorola_exynos9610.git
8 years agobpf, verifier: enforce larger zero range for pkt on overloading stack buffs
Daniel Borkmann [Mon, 19 Sep 2016 22:26:12 +0000 (00:26 +0200)]
bpf, verifier: enforce larger zero range for pkt on overloading stack buffs

Current contract for the following two helper argument types is:

  * ARG_CONST_STACK_SIZE: passed argument pair must be (ptr, >0).
  * ARG_CONST_STACK_SIZE_OR_ZERO: passed argument pair can be either
    (NULL, 0) or (ptr, >0).

With 6841de8b0d03 ("bpf: allow helpers access the packet directly"), we can
pass also raw packet data to helpers, so depending on the argument type
being PTR_TO_PACKET, we now either assert memory via check_packet_access()
or check_stack_boundary(). As a result, the tests in check_packet_access()
currently allow more than intended with regards to reg->imm.

Back in 969bf05eb3ce ("bpf: direct packet access"), check_packet_access()
was fine to ignore size argument since in check_mem_access() size was
bpf_size_to_bytes() derived and prior to the call to check_packet_access()
guaranteed to be larger than zero.

However, for the above two argument types, it currently means, we can have
a <= 0 size and thus breaking current guarantees for helpers. Enforce a
check for size <= 0 and bail out if so.

check_stack_boundary() doesn't have such an issue since it already tests
for access_size <= 0 and bails out, resp. access_size == 0 in case of NULL
pointer passed when allowed.

Fixes: 6841de8b0d03 ("bpf: allow helpers access the packet directly")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agoipvlan: Fix dependency issue
Mahesh Bandewar [Mon, 19 Sep 2016 20:56:29 +0000 (13:56 -0700)]
ipvlan: Fix dependency issue

kbuild-build-bot reported that if NETFILTER is not selected, the
build fails pointing to netfilter symbols.

Fixes: 4fbae7d83c98 ("ipvlan: Introduce l3s mode")

Signed-off-by: Mahesh Bandewar <maheshb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agoopenvswitch: avoid resetting flow key while installing new flow.
pravin shelar [Mon, 19 Sep 2016 20:51:00 +0000 (13:51 -0700)]
openvswitch: avoid resetting flow key while installing new flow.

since commit commit db74a3335e0f6 ("openvswitch: use percpu
flow stats") flow alloc resets flow-key. So there is no need
to reset the flow-key again if OVS is using newly allocated
flow-key.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agoopenvswitch: Fix Frame-size larger than 1024 bytes warning.
pravin shelar [Mon, 19 Sep 2016 20:50:59 +0000 (13:50 -0700)]
openvswitch: Fix Frame-size larger than 1024 bytes warning.

There is no need to declare separate key on stack,
we can just use sw_flow->key to store the key directly.

This commit fixes following warning:

net/openvswitch/datapath.c: In function ‘ovs_flow_cmd_new’:
net/openvswitch/datapath.c:1080:1: warning: the frame size of 1040 bytes
is larger than 1024 bytes [-Wframe-larger-than=]

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agoMerge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetoot...
David S. Miller [Wed, 21 Sep 2016 02:52:50 +0000 (22:52 -0400)]
Merge branch 'for-upstream' of git://git./linux/kernel/git/bluetooth/bluetooth-next

Johan Hedberg says:

====================
pull request: bluetooth-next 2016-09-19

Here's the main bluetooth-next pull request for the 4.9 kernel.

 - Added new messages for monitor sockets for better mgmt tracing
 - Added local name and appearance support in scan response
 - Added new Qualcomm WCNSS SMD based HCI driver
 - Minor fixes & cleanup to 802.15.4 code
 - New USB ID to btusb driver
 - Added Marvell support to HCI UART driver
 - Add combined LED trigger for controller power
 - Other minor fixes here and there

Please let me know if there are any issues pulling. Thanks.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
8 years ago6pack: fix buffer length mishandling
Alan Cox [Mon, 19 Sep 2016 19:15:24 +0000 (20:15 +0100)]
6pack: fix buffer length mishandling

Dmitry Vyukov wrote:
> different runs). Looking at code, the following looks suspicious -- we
> limit copy by 512 bytes, but use the original count which can be
> larger than 512:
>
> static void sixpack_receive_buf(struct tty_struct *tty,
>     const unsigned char *cp, char *fp, int count)
> {
>     unsigned char buf[512];
>     ....
>     memcpy(buf, cp, count < sizeof(buf) ? count : sizeof(buf));
>     ....
>     sixpack_decode(sp, buf, count1);

With the sane tty locking we now have I believe the following is safe as
we consume the bytes and move them into the decoded buffer before
returning.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agomlx4: add missed recycle opportunity for XDP_TX on TX failure
Jesper Dangaard Brouer [Mon, 19 Sep 2016 15:46:38 +0000 (17:46 +0200)]
mlx4: add missed recycle opportunity for XDP_TX on TX failure

Correct drop handling for XDP_TX on TX failure, were recently added in
commit 95357907ae73 ("mlx4: fix XDP_TX is acting like XDP_PASS on TX
ring full").

The change missed an opportunity for recycling the RX page, instead of
going through the page allocator, like the regular XDP_DROP action does.
This patch cease the opportunity, by going through the XDP_DROP case.

Fixes: 95357907ae73 ("mlx4: fix XDP_TX is acting like XDP_PASS on TX ring full")
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agoMerge branch 'dsa-set_addr-optional'
David S. Miller [Tue, 20 Sep 2016 08:47:50 +0000 (04:47 -0400)]
Merge branch 'dsa-set_addr-optional'

John Crispin says:

====================
net-next: dsa: set_addr should be optional

The Marvell driver is the only one that actually sets the switches HW
address. All other drivers have an empty stub. fix this by making the
callback optional.
====================

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agonet-next: dsa: qca8k: remove empty set_addr() stub
John Crispin [Mon, 19 Sep 2016 13:28:03 +0000 (15:28 +0200)]
net-next: dsa: qca8k: remove empty set_addr() stub

The set_addr() callback is now optional. Remove the empty stub that qca8k
has.

Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agonet-next: dsa: b53: remove empty set_addr() stub
John Crispin [Mon, 19 Sep 2016 13:28:02 +0000 (15:28 +0200)]
net-next: dsa: b53: remove empty set_addr() stub

The set_addr() callback is now optional. Remove the empty stub that b53
has.

Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agonet-next: dsa: make the set_addr() operation optional
John Crispin [Mon, 19 Sep 2016 13:28:01 +0000 (15:28 +0200)]
net-next: dsa: make the set_addr() operation optional

Only 1 of the 3 drivers currently has a set_addr() operation. Make the
set_addr() callback optional to reduce the amount of empty stubs inside
the drivers.

Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agonet-next: dsa: fix duplicate invocation of set_addr()
John Crispin [Mon, 19 Sep 2016 13:28:00 +0000 (15:28 +0200)]
net-next: dsa: fix duplicate invocation of set_addr()

commit 83c0afaec7b730b ("net: dsa: Add new binding implementation")
has a duplicate invocation of the set_addr() operation callback. Remove one
of them.

Signed-off-by: John Crispin <john@phrozen.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agoMerge branch 'rhashtable-dups'
David S. Miller [Tue, 20 Sep 2016 08:43:43 +0000 (04:43 -0400)]
Merge branch 'rhashtable-dups'

Herbert Xu says:

====================
rhashtable: rhashtable with duplicate objects

v3 fixes a bug in the remove path that causes the element count
to decrease when it shouldn't, leading to a gigantic hash table
when it underflows.

v2 contains a reworked insertion slowpath to ensure that the
spinlock for the table we're inserting into is taken.

This series contains two patches.  The first adds the rhlist
interface and the second converts mac80211 to use it.  If this
works out I'll then proceed to convert the other insecure_elasticity
users over to this.

I've tested the rhlist code with test_rhashtable but I haven't
tested the mac80211 conversion.  So please give it a go and see
if it still works.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agomac80211: Use rhltable instead of rhashtable
Herbert Xu [Mon, 19 Sep 2016 11:00:10 +0000 (19:00 +0800)]
mac80211: Use rhltable instead of rhashtable

mac80211 currently uses rhashtable with insecure_elasticity set
to true.  The latter is because of duplicate objects.  What's
more, mac80211 walks the rhashtable chains by hand which is broken
as rhashtable may contain multiple tables due to resizing or
rehashing.

This patch fixes it by converting it to the newly added rhltable
interface which is designed for use with duplicate objects.

With rhltable a lookup returns a list of objects instead of a
single one.  This is then fed into the existing for_each_sta_info
macro.

This patch also deletes the sta_addr_hash function since rhashtable
defaults to jhash.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agorhashtable: Add rhlist interface
Herbert Xu [Mon, 19 Sep 2016 11:00:09 +0000 (19:00 +0800)]
rhashtable: Add rhlist interface

The insecure_elasticity setting is an ugly wart brought out by
users who need to insert duplicate objects (that is, distinct
objects with identical keys) into the same table.

In fact, those users have a much bigger problem.  Once those
duplicate objects are inserted, they don't have an interface to
find them (unless you count the walker interface which walks
over the entire table).

Some users have resorted to doing a manual walk over the hash
table which is of course broken because they don't handle the
potential existence of multiple hash tables.  The result is that
they will break sporadically when they encounter a hash table
resize/rehash.

This patch provides a way out for those users, at the expense
of an extra pointer per object.  Essentially each object is now
a list of objects carrying the same key.  The hash table will
only see the lists so nothing changes as far as rhashtable is
concerned.

To use this new interface, you need to insert a struct rhlist_head
into your objects instead of struct rhash_head.  While the hash
table is unchanged, for type-safety you'll need to use struct
rhltable instead of struct rhashtable.  All the existing interfaces
have been duplicated for rhlist, including the hash table walker.

One missing feature is nulls marking because AFAIK the only potential
user of it does not need duplicate objects.  Should anyone need
this it shouldn't be too hard to add.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agoxen-netfront: avoid packet loss when ethernet header crosses page boundary
Vitaly Kuznetsov [Mon, 19 Sep 2016 10:53:40 +0000 (12:53 +0200)]
xen-netfront: avoid packet loss when ethernet header crosses page boundary

Small packet loss is reported on complex multi host network configurations
including tunnels, NAT, ... My investigation led me to the following check
in netback which drops packets:

        if (unlikely(txreq.size < ETH_HLEN)) {
                netdev_err(queue->vif->dev,
                           "Bad packet size: %d\n", txreq.size);
                xenvif_tx_err(queue, &txreq, extra_count, idx);
                break;
        }

But this check itself is legitimate. SKBs consist of a linear part (which
has to have the ethernet header) and (optionally) a number of frags.
Netfront transmits the head of the linear part up to the page boundary
as the first request and all the rest becomes frags so when we're
reconstructing the SKB in netback we can't distinguish between original
frags and the 'tail' of the linear part. The first SKB needs to be at
least ETH_HLEN size. So in case we have an SKB with its linear part
starting too close to the page boundary the packet is lost.

I see two ways to fix the issue:
- Change the 'wire' protocol between netfront and netback to start keeping
  the original SKB structure. We'll have to add a flag indicating the fact
  that the particular request is a part of the original linear part and not
  a frag. We'll need to know the length of the linear part to pre-allocate
  memory.
- Avoid transmitting SKBs with linear parts starting too close to the page
  boundary. That seems preferable short-term and shouldn't bring
  significant performance degradation as such packets are rare. That's what
  this patch is trying to achieve with skb_copy().

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Acked-by: David Vrabel <david.vrabel@citrix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agonet: phy: Add MAC-IF driver for Microsemi PHYs.
Raju Lakkaraju [Mon, 19 Sep 2016 10:03:54 +0000 (15:33 +0530)]
net: phy: Add MAC-IF driver for Microsemi PHYs.

All the review comments updated and resending for review.

This is MAC interface feature.
Microsemi PHY can support RGMII, RMII or GMII/MII interface between MAC and PHY.
MAC-IF function program the right value based on Device tree configuration.

Tested on Beaglebone Black with VSC 8531 PHY.

Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agomlxsw: spectrum: Fix sparse warnings
Ido Schimmel [Mon, 19 Sep 2016 06:29:26 +0000 (08:29 +0200)]
mlxsw: spectrum: Fix sparse warnings

drivers/net/ethernet/mellanox/mlxsw//spectrum.c:251:28: warning: symbol
'mlxsw_sp_span_entry_find' was not declared. Should it be static?
drivers/net/ethernet/mellanox/mlxsw//spectrum.c:265:28: warning: symbol
'mlxsw_sp_span_entry_get' was not declared. Should it be static?
drivers/net/ethernet/mellanox/mlxsw//spectrum.c:367:56: warning: mixing
different enum types
drivers/net/ethernet/mellanox/mlxsw//spectrum.c:367:56:     int enum
mlxsw_sp_span_type  versus
drivers/net/ethernet/mellanox/mlxsw//spectrum.c:367:56:     int enum
mlxsw_reg_mpar_i_e
...
drivers/net/ethernet/mellanox/mlxsw//spectrum_buffers.c:598:32: warning:
mixing different enum types
drivers/net/ethernet/mellanox/mlxsw//spectrum_buffers.c:598:32:     int
enum mlxsw_reg_sbxx_dir  versus
drivers/net/ethernet/mellanox/mlxsw//spectrum_buffers.c:598:32:     int
enum devlink_sb_pool_type
drivers/net/ethernet/mellanox/mlxsw//spectrum_buffers.c:600:39: warning:
mixing different enum types
drivers/net/ethernet/mellanox/mlxsw//spectrum_buffers.c:600:39:     int
enum mlxsw_reg_sbpr_mode  versus
drivers/net/ethernet/mellanox/mlxsw//spectrum_buffers.c:600:39:     int
enum devlink_sb_threshold_type
...
drivers/net/ethernet/mellanox/mlxsw//spectrum_router.c:255:54: warning:
mixing different enum types
drivers/net/ethernet/mellanox/mlxsw//spectrum_router.c:255:54:     int
enum mlxsw_sp_l3proto  versus
drivers/net/ethernet/mellanox/mlxsw//spectrum_router.c:255:54:     int
enum mlxsw_reg_ralxx_protocol
...
drivers/net/ethernet/mellanox/mlxsw//spectrum_router.c:1749:6: warning:
symbol 'mlxsw_sp_fib_entry_put' was not declared. Should it be static?

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agomlxsw: Change the RX LAG hash function from XOR to CRC
Elad Raz [Mon, 19 Sep 2016 06:28:24 +0000 (08:28 +0200)]
mlxsw: Change the RX LAG hash function from XOR to CRC

Change the RX hash function from XOR to CRC in order to have better
distribution of the traffic.

Signed-off-by: Elad Raz <eladr@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agobnxt_en: Fix build error for kernesl without RTC-LIB
Rob Swindell [Tue, 20 Sep 2016 07:36:33 +0000 (03:36 -0400)]
bnxt_en: Fix build error for kernesl without RTC-LIB

bnxt_hwrm_fw_set_time() now returns -EOPNOTSUPP when built for kernel
without RTC_LIB.  Setting the firmware time is not critical to the
successful completion of the firmware update process.

Signed-off-by: Rob Swindell <Rob.Swindell@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agonet sched: stylistic cleanups
Jamal Hadi Salim [Sun, 18 Sep 2016 12:45:33 +0000 (08:45 -0400)]
net sched: stylistic cleanups

Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agonet sched actions police: peg drop stats for conforming traffic
Roman Mashak [Sun, 18 Sep 2016 11:53:08 +0000 (07:53 -0400)]
net sched actions police: peg drop stats for conforming traffic

setting conforming action to drop is a valid policy.
When it is set we need to at least see the stats indicating it
for debugging.

Signed-off-by: Roman Mashak <mrv@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agonet sched ife action: Introduce skb tcindex metadata encap decap
Jamal Hadi Salim [Sun, 18 Sep 2016 11:31:43 +0000 (07:31 -0400)]
net sched ife action: Introduce skb tcindex metadata encap decap

Sample use case of how this is encoded:
user space via tuntap (or a connected VM/Machine/container)
encodes the tcindex TLV.

Sample use case of decoding:
IFE action decodes it and the skb->tc_index is then used to classify.
So something like this for encoded ICMP packets:

.. first decode then reclassify... skb->tcindex will be set
sudo $TC filter add dev $ETH parent ffff: prio 2 protocol 0xbeef \
u32 match u32 0 0 flowid 1:1 \
action ife decode reclassify

...next match the decode icmp packet...
sudo $TC filter add dev $ETH parent ffff: prio 4 protocol ip \
u32 match ip protocol 1 0xff flowid 1:1 \
action continue

... last classify it using the tcindex classifier and do someaction..
sudo $TC filter add dev $ETH parent ffff: prio 5 protocol ip \
handle 0x11 tcindex classid 1:1 \
action blah..

Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agonet sched ife action: add 16 bit helpers
Jamal Hadi Salim [Sun, 18 Sep 2016 11:31:42 +0000 (07:31 -0400)]
net sched ife action: add 16 bit helpers

encoder and checker for 16 bits metadata

Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agonet/mlx5: clean function declarations in eswitch.c up
Baoyou Xie [Sun, 18 Sep 2016 08:44:22 +0000 (16:44 +0800)]
net/mlx5: clean function declarations in eswitch.c up

We get 2 warnings when building kernel with W=1:
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c:463:5: warning: no previous prototype for 'esw_offloads_init' [-Wmissing-prototypes]
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c:521:6: warning: no previous prototype for 'esw_offloads_cleanup' [-Wmissing-prototypes]

In fact, both functions are declared in
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c,but should be
declared in a header file, thus can be recognized in other file.

So this patch moves the declarations into
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org>
Acked-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agobe2net: mark symbols static where possible
Baoyou Xie [Sun, 18 Sep 2016 08:35:29 +0000 (16:35 +0800)]
be2net: mark symbols static where possible

We get 4 warnings when building kernel with W=1:
drivers/net/ethernet/emulex/benet/be_main.c:4368:6: warning: no previous prototype for 'be_calculate_pf_pool_rss_tables' [-Wmissing-prototypes]
drivers/net/ethernet/emulex/benet/be_cmds.c:4385:5: warning: no previous prototype for 'be_get_nic_pf_num_list' [-Wmissing-prototypes]
drivers/net/ethernet/emulex/benet/be_cmds.c:4537:6: warning: no previous prototype for 'be_reset_nic_desc' [-Wmissing-prototypes]
drivers/net/ethernet/emulex/benet/be_cmds.c:4910:5: warning: no previous prototype for '__be_cmd_set_logical_link_config' [-Wmissing-prototypes]

In fact, these functions are only used in the file in which they are
declared and don't need a declaration, but can be made static.
so this patch marks these functions with 'static'.

Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agophy: mark lan88xx_suspend() static
Baoyou Xie [Sun, 18 Sep 2016 08:26:34 +0000 (16:26 +0800)]
phy: mark lan88xx_suspend() static

We get 1 warning when building kernel with W=1:
drivers/net/phy/microchip.c:58:5: warning: no previous prototype for 'lan88xx_suspend' [-Wmissing-prototypes]

In fact, this function is only used in the file in which it is
declared and don't need a declaration, but can be made static.
so this patch marks this function with 'static'.

Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agonet: ethernet: broadcom: bcmgenet: use new api ethtool_{get|set}_link_ksettings
Philippe Reynes [Sun, 18 Sep 2016 15:16:45 +0000 (17:16 +0200)]
net: ethernet: broadcom: bcmgenet: use new api ethtool_{get|set}_link_ksettings

The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agonet: ethernet: broadcom: bcm63xx: use new api ethtool_{get|set}_link_ksettings
Philippe Reynes [Sun, 18 Sep 2016 14:59:07 +0000 (16:59 +0200)]
net: ethernet: broadcom: bcm63xx: use new api ethtool_{get|set}_link_ksettings

The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agonet: ethernet: broadcom: bcm63xx: use phydev from struct net_device
Philippe Reynes [Sun, 18 Sep 2016 14:59:06 +0000 (16:59 +0200)]
net: ethernet: broadcom: bcm63xx: use phydev from struct net_device

The private structure contain a pointer to phydev, but the structure
net_device already contain such pointer. So we can remove the pointer
phydev in the private structure, and update the driver to use the
one contained in struct net_device.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agonet: ethernet: broadcom: b44: use new api ethtool_{get|set}_link_ksettings
Philippe Reynes [Sat, 17 Sep 2016 22:11:35 +0000 (00:11 +0200)]
net: ethernet: broadcom: b44: use new api ethtool_{get|set}_link_ksettings

The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agonet: ethernet: broadcom: b44: use phydev from struct net_device
Philippe Reynes [Sat, 17 Sep 2016 22:11:34 +0000 (00:11 +0200)]
net: ethernet: broadcom: b44: use phydev from struct net_device

The private structure contain a pointer to phydev, but the structure
net_device already contain such pointer. So we can remove the pointer
phydev in the private structure, and update the driver to use the
one contained in struct net_device.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agoMerge branch 'bnxt_en-next'
David S. Miller [Tue, 20 Sep 2016 01:32:31 +0000 (21:32 -0400)]
Merge branch 'bnxt_en-next'

Michael Chan says:

====================
bnxt: update for net-next.

Misc. changes and minor bug fixes for net-next.  Please review.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agobnxt_en: Fixed the VF link status after a link state change
Eddie Wai [Mon, 19 Sep 2016 07:58:09 +0000 (03:58 -0400)]
bnxt_en: Fixed the VF link status after a link state change

The VF link state can be changed via the 'ip link set' cmd.
Currently, the new link state does not take effect immediately.

The fix is for the PF to send a link change async event to the
designated VF after a VF link state change.  This async event will
trigger the VF to update the link status.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agobnxt_en: Support for "ethtool -r" command
Deepak Khungar [Mon, 19 Sep 2016 07:58:08 +0000 (03:58 -0400)]
bnxt_en: Support for "ethtool -r" command

Restart autoneg if autoneg is enabled.

Signed-off-by: Deepak Khungar <deepak.khungar@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agobnxt_en: Pad TX packets below 52 bytes.
Michael Chan [Mon, 19 Sep 2016 07:58:07 +0000 (03:58 -0400)]
bnxt_en: Pad TX packets below 52 bytes.

The hardware has a limitation that it won't pass host to BMC loopback
packets below 52-bytes.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agobnxt_en: Call firmware to approve the random VF MAC address.
Michael Chan [Mon, 19 Sep 2016 07:58:06 +0000 (03:58 -0400)]
bnxt_en: Call firmware to approve the random VF MAC address.

After generating the random MAC address for VF, call the firmware to
approve it.  This step serves 2 purposes.  Some hypervisor (e.g. ESX)
wants to approve the MAC address.  2nd, the call will setup the
proper forwarding database in the internal switch.

We need to unlock the hwrm_cmd_lock mutex before calling bnxt_approve_mac().
We can do that because we are at the end of the function and all the
previous firmware response data has been copied.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agobnxt_en: Re-arrange bnxt_hwrm_func_qcaps().
Michael Chan [Mon, 19 Sep 2016 07:58:05 +0000 (03:58 -0400)]
bnxt_en: Re-arrange bnxt_hwrm_func_qcaps().

Re-arrange the code so that the generation of the random MAC address for
the VF is at the end of the function.  The next patch will add one more step
to call bnxt_approve_mac() to get the firmware to approve the random MAC
address.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agobnxt_en: Fix ethtool -l|-L inconsistent channel counts.
Michael Chan [Mon, 19 Sep 2016 07:58:04 +0000 (03:58 -0400)]
bnxt_en: Fix ethtool -l|-L inconsistent channel counts.

The existing code is inconsistent in reporting and accepting the combined
channel count.  bnxt_get_channels() reports maximum combined as the
maximum rx count.  bnxt_set_channels() accepts combined count that
cannot be bigger than max rx or max tx.

For example, if max rx = 2 and max tx = 1, we report max supported
combined to be 2.  But if the user tries to set combined to 2, it will
fail because 2 is bigger than max tx which is 1.

Fix the code to be consistent.  Max allowed combined = max(max_rx, max_tx).
We will accept a combined channel count <= max(max_rx, max_tx).

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agobnxt_en: Added support for Secure Firmware Update
Rob Swindell [Mon, 19 Sep 2016 07:58:03 +0000 (03:58 -0400)]
bnxt_en: Added support for Secure Firmware Update

Using Ethtool flashdev command, entire NVM package (*.pkg) files
may now be staged into the "update" area of the NVM and subsequently
verified and installed by the firmware using the newly introduced
command: NVM_INSTALL_UPDATE.

We also introduce use of the new firmware command FW_SET_TIME so that the
NVM-resident package installation log contains valid time-stamps.

Signed-off-by: Rob Swindell <Rob.Swindell@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agobnxt_en: Update to firmware interface spec 1.5.1.
Michael Chan [Mon, 19 Sep 2016 07:58:02 +0000 (03:58 -0400)]
bnxt_en: Update to firmware interface spec 1.5.1.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agobnxt_en: Simplify PCI device names and add additinal PCI IDs.
Michael Chan [Mon, 19 Sep 2016 07:58:01 +0000 (03:58 -0400)]
bnxt_en: Simplify PCI device names and add additinal PCI IDs.

Remove "Single-port/Dual-port" from the device names.  Dual-port devices
will appear as 2 separate devices, so no need to call each a dual-port
device.  Use a more generic name for VF devices belonging to the same
chip fanmily.  Add some remaining NPAR device IDs.

Signed-off-by: David Christensen <david.christensen@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agobnxt_en: Use RSS flags defined in the bnxt_hsi.h file.
Michael Chan [Mon, 19 Sep 2016 07:58:00 +0000 (03:58 -0400)]
bnxt_en: Use RSS flags defined in the bnxt_hsi.h file.

And remove redundant definitions of the same flags.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agogso: Support partial splitting at the frag_list pointer
Steffen Klassert [Mon, 19 Sep 2016 10:58:47 +0000 (12:58 +0200)]
gso: Support partial splitting at the frag_list pointer

Since commit 8a29111c7 ("net: gro: allow to build full sized skb")
gro may build buffers with a frag_list. This can hurt forwarding
because most NICs can't offload such packets, they need to be
segmented in software. This patch splits buffers with a frag_list
at the frag_list pointer into buffers that can be TSO offloaded.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Acked-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8 years agoBluetooth: Set appearance only for LE capable controllers
Michał Narajowski [Mon, 19 Sep 2016 12:33:33 +0000 (14:33 +0200)]
Bluetooth: Set appearance only for LE capable controllers

Setting appearance on controllers without LE support will result
in No Supported error.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: Fix missing ext info event when setting appearance
Michał Narajowski [Mon, 19 Sep 2016 18:25:56 +0000 (20:25 +0200)]
Bluetooth: Fix missing ext info event when setting appearance

This patch adds missing event when setting appearance, just like
in the set local name command.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Add supported data types to ext info changed event
Michał Narajowski [Mon, 19 Sep 2016 18:25:55 +0000 (20:25 +0200)]
Bluetooth: Add supported data types to ext info changed event

This patch adds EIR data to extended info changed event.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Add appearance to Read Ext Controller Info command
Szymon Janc [Mon, 19 Sep 2016 18:25:54 +0000 (20:25 +0200)]
Bluetooth: Add appearance to Read Ext Controller Info command

If LE is enabled appearance is added to EIR data.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Factor appending EIR to separate helper
Michał Narajowski [Mon, 19 Sep 2016 18:25:53 +0000 (20:25 +0200)]
Bluetooth: Factor appending EIR to separate helper

This will also be used for Extended Information Event handling.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Refactor read_ext_controller_info handler
Szymon Janc [Mon, 19 Sep 2016 18:25:52 +0000 (20:25 +0200)]
Bluetooth: Refactor read_ext_controller_info handler

There is no need to allocate heap for reply only to copy stack data to
it. This also fix rp memory leak and missing hdev unlock if kmalloc
failed.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: hci_uart: Add Marvell support
Loic Poulain [Mon, 19 Sep 2016 14:29:27 +0000 (16:29 +0200)]
Bluetooth: hci_uart: Add Marvell support

This patch introduces support for Marvell Bluetooth controller over
UART (8897 for now). In order to send the final firmware at full speed,
a helper firmware is firstly sent. Firmware download is driven by the
controller which sends request firmware packets (including expected
size).

This driver is a global rework of the one proposed by
Amitkumar Karwar <akarwar@marvell.com>.

Signed-off-by: Loic Poulain <loic.poulain@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: hci_uart: Add Nokia Protocol identifier
Loic Poulain [Mon, 19 Sep 2016 09:32:35 +0000 (11:32 +0200)]
Bluetooth: hci_uart: Add Nokia Protocol identifier

Will be used by hci_nokia extra protocol.

Signed-off-by: Loic Poulain <loic.poulain@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: hci_bcm: Change protocol name
Loic Poulain [Mon, 19 Sep 2016 10:05:12 +0000 (12:05 +0200)]
Bluetooth: hci_bcm: Change protocol name

Use full name instead of abbreviation.

Signed-off-by: Loic Poulain <loic.poulain@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Increment management interface revision
Szymon Janc [Sun, 18 Sep 2016 10:50:07 +0000 (12:50 +0200)]
Bluetooth: Increment management interface revision

Increment the mgmt revision due to the recently added
Read Extended Controller Information and Set Appearance commands.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Fix advertising instance validity check for flags
Szymon Janc [Sun, 18 Sep 2016 10:50:06 +0000 (12:50 +0200)]
Bluetooth: Fix advertising instance validity check for flags

Flags are not allowed in Scan Response.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Unify advertising instance flags check
Szymon Janc [Sun, 18 Sep 2016 10:50:05 +0000 (12:50 +0200)]
Bluetooth: Unify advertising instance flags check

This unifies max length and TLV validity checks.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Remove unused parameter from tlv_data_is_valid function
Szymon Janc [Sun, 18 Sep 2016 10:50:04 +0000 (12:50 +0200)]
Bluetooth: Remove unused parameter from tlv_data_is_valid function

hdev parameter is not used in function.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Add support for appearance in scan rsp
Michał Narajowski [Sun, 18 Sep 2016 10:50:03 +0000 (12:50 +0200)]
Bluetooth: Add support for appearance in scan rsp

This patch enables prepending appearance value to scan response data.
It also adds support for setting appearance value through mgmt command.
If currently advertised instance has apperance flag set it is expired
immediately.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Add support for local name in scan rsp
Michał Narajowski [Sun, 18 Sep 2016 10:50:02 +0000 (12:50 +0200)]
Bluetooth: Add support for local name in scan rsp

This patch enables appending local name to scan response data. If
currently advertised instance has name flag set it is expired
immediately.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: btrtl: Add RTL8822BE Bluetooth device
Larry Finger [Fri, 9 Sep 2016 15:02:05 +0000 (10:02 -0500)]
Bluetooth: btrtl: Add RTL8822BE Bluetooth device

The RTL8822BE is a new Realtek wifi and BT device. Support for the BT
part is hereby added.

As this device is similar to most of the other Realtek BT devices, the
changes are minimal. The main difference is that the 8822BE needs a
configuration file for enabling and disabling features. Thus code is
added to select and load this configuration file. Although not needed
at the moment, hooks are added for the other devices that might need
such configuration files.

One additional change is to the routine that tests that the project
ID contained in the firmware matches the hardware. As the project IDs
are not sequential, continuing to use the position in the array as the
expected value of the ID would require adding extra unused entries in
the table, and any subsequant rearrangment of the array would break the
code. To fix these problems, the array elements now contain both the
hardware ID and the expected value for the project ID.

Signed-off-by: 陆朱伟 <alex_lu@realsil.com.cn>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Fix not registering BR/EDR SMP channel with force_bredr flag
Szymon Janc [Fri, 9 Sep 2016 18:24:40 +0000 (20:24 +0200)]
Bluetooth: Fix not registering BR/EDR SMP channel with force_bredr flag

If force_bredr is set SMP BR/EDR channel should also be for non-SC
capable controllers. Since hcidev flag is persistent wrt power toggle
it can be already set when calling smp_register(). This resulted in
SMP BR/EDR channel not being registered even if HCI_FORCE_BREDR_SMP
flag was set.

This also fix NULL pointer dereference when trying to disable
force_bredr after power cycle.

BUG: unable to handle kernel NULL pointer dereference at 0000000000000388
IP: [<ffffffffc0493ad8>] smp_del_chan+0x18/0x80 [bluetooth]

Call Trace:
[<ffffffffc04950ca>] force_bredr_smp_write+0xba/0x100 [bluetooth]
[<ffffffff8133be14>] full_proxy_write+0x54/0x90
[<ffffffff81245967>] __vfs_write+0x37/0x160
[<ffffffff813617f7>] ? selinux_file_permission+0xd7/0x110
[<ffffffff81356fbd>] ? security_file_permission+0x3d/0xc0
[<ffffffff810eb5b2>] ? percpu_down_read+0x12/0x50
[<ffffffff812462a5>] vfs_write+0xb5/0x1a0
[<ffffffff812476f5>] SyS_write+0x55/0xc0
[<ffffffff817eb872>] entry_SYSCALL_64_fastpath+0x1a/0xa4
Code: 48 8b 45 f0 eb c1 0f 1f 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f
      44 00 00 f6 05 c6 3b 02 00 04 55 48 89 e5 41 54 53 49 89 fc 75
      4b
      <49> 8b 9c 24 88 03 00 00 48 85 db 74 31 49 c7 84 24 88 03 00 00
RIP  [<ffffffffc0493ad8>] smp_del_chan+0x18/0x80 [bluetooth]
RSP <ffff8802aee3bd90>
CR2: 0000000000000388

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Use kzalloc instead of kmalloc/memset
Wei Yongjun [Sat, 10 Sep 2016 12:21:22 +0000 (12:21 +0000)]
Bluetooth: Use kzalloc instead of kmalloc/memset

Use kzalloc rather than kmalloc followed by memset with 0.

Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Increase the subsystem minor version number
Marcel Holtmann [Thu, 8 Sep 2016 16:07:07 +0000 (18:07 +0200)]
Bluetooth: Increase the subsystem minor version number

While the subsystem version information are purely informational,
increase the minor number due to the addition of user channel and
management control monitoring suppport. It is helpful for debugging
purposes to see the version numbers change.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: Fix reason code used for rejecting SCO connections
Frédéric Dalleau [Thu, 8 Sep 2016 10:00:11 +0000 (12:00 +0200)]
Bluetooth: Fix reason code used for rejecting SCO connections

A comment in the code states that SCO connection should be rejected
with the proper error value between 0xd-0xf. The code uses
HCI_ERROR_REMOTE_LOW_RESOURCES which is 0x14.

This led to following error:
< HCI Command: Reject Synchronous Co.. (0x01|0x002a) plen 7
        Address: 34:51:C9:EF:02:CA (Apple, Inc.)
        Reason: Remote Device Terminated due to Low Resources (0x14)
> HCI Event: Command Status (0x0f) plen 4
      Reject Synchronous Connection Request (0x01|0x002a) ncmd 1
        Status: Invalid HCI Command Parameters (0x12)

Instead make use of HCI_ERROR_REJ_LIMITED_RESOURCES which is 0xd.

Signed-off-by: Frédéric Dalleau <frederic.dalleau@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: btqca: remove null checks on edl->data as it is an array
Colin Ian King [Tue, 6 Sep 2016 12:15:49 +0000 (13:15 +0100)]
Bluetooth: btqca: remove null checks on edl->data as it is an array

edl->data is an array of __u8 so the null check is unneccessary,
so remove it.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Fix wrong New Settings event when closing HCI User Channel
Marcel Holtmann [Sun, 4 Sep 2016 03:13:46 +0000 (05:13 +0200)]
Bluetooth: Fix wrong New Settings event when closing HCI User Channel

When closing HCI User Channel, the New Settings event was send out to
inform about changed settings. However such event is wrong since the
exclusive HCI User Channel access is active until the Index Added event
has been sent.

@ USER Close: test
@ MGMT Event: New Settings (0x0006) plen 4
        Current settings: 0x00000ad0
          Bondable
          Secure Simple Pairing
          BR/EDR
          Low Energy
          Secure Connections
= Close Index: 00:14:EF:22:04:12
@ MGMT Event: Index Added (0x0004) plen 0

Calling __mgmt_power_off from hci_dev_do_close requires an extra check
for an active HCI User Channel.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: Send control open and close messages for HCI user channels
Marcel Holtmann [Thu, 1 Sep 2016 17:48:28 +0000 (19:48 +0200)]
Bluetooth: Send control open and close messages for HCI user channels

When opening and closing HCI user channel, send monitoring messages to
be able to trace its behavior.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agofakelb: fix schedule while atomic
Alexander Aring [Thu, 1 Sep 2016 09:24:57 +0000 (11:24 +0200)]
fakelb: fix schedule while atomic

This patch changes the spinlock to mutex for the available fakelb phy
list. When holding the spinlock the ieee802154_unregister_hw is called
which holding the rtnl_mutex, in that case we get a "BUG: sleeping function
called from invalid context" error. We simple change the spinlock to
mutex which allows to hold the rtnl lock there.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Append local name and CoD to Extended Controller Info
Michał Narajowski [Thu, 1 Sep 2016 14:46:24 +0000 (16:46 +0200)]
Bluetooth: Append local name and CoD to Extended Controller Info

This adds device class, complete local name and short local name
to EIR data in Extended Controller Info as specified in docs.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Add framework for Extended Controller Information
Marcel Holtmann [Thu, 1 Sep 2016 14:46:23 +0000 (16:46 +0200)]
Bluetooth: Add framework for Extended Controller Information

This command is used to retrieve the current state and basic
information of a controller. It is typically used right after
getting the response to the Read Controller Index List command
or an Index Added event (or its extended counterparts).

When any of the values in the EIR_Data field changes, the event
Extended Controller Information Changed will be used to inform
clients about the updated information.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
8 years agoBluetooth: btusb: Mark CW6622 devices to have broken link key commands
Szymon Janc [Thu, 1 Sep 2016 15:22:37 +0000 (17:22 +0200)]
Bluetooth: btusb: Mark CW6622 devices to have broken link key commands

Conwise CW6622 seems to have a problem with the stored link key
commands so just mark it as broken.

< HCI Command: Read Local Supported Features (0x04|0x0003) plen 0
> HCI Event: Command Complete (0x0e) plen 12
    Read Local Supported Features (0x04|0x0003) ncmd 1
    status 0x00
    Features: 0xff 0x3e 0x85 0x38 0x18 0x18 0x00 0x00
< HCI Command: Read Local Version Information (0x04|0x0001) plen 0
> HCI Event: Command Complete (0x0e) plen 12
    Read Local Version Information (0x04|0x0001) ncmd 1
    status 0x00
    HCI Version: 2.0 (0x3) HCI Revision: 0x1f4
    LMP Version: 2.0 (0x3) LMP Subversion: 0x1f4
    Manufacturer: CONWISE Technology Corporation Ltd (66)
...
< HCI Command: Read Local Supported Commands (0x04|0x0002) plen 0
> HCI Event: Command Complete (0x0e) plen 68
    Read Local Supported Commands (0x04|0x0002) ncmd 1
    status 0x00
    Commands: 7fffef03cedfffffffffff1ff20ff8ff3f
...
< HCI Command: Read Stored Link Key (0x03|0x000d) plen 7
    bdaddr 00:00:00:00:00:00 all 1
> HCI Event: Command Complete (0x0e) plen 8
    Read Stored Link Key (0x03|0x000d) ncmd 1
    status 0x11 max 0 num 0
    Error: Unsupported Feature or Parameter Value

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Remove deprecated create_singlethread_workqueue
Bhaktipriya Shridhar [Tue, 30 Aug 2016 17:12:53 +0000 (22:42 +0530)]
Bluetooth: Remove deprecated create_singlethread_workqueue

The workqueue "workqueue" queues multiple work items viz &qca->ws_awake_rx
&qca->ws_rx_vote_off, &qca->ws_awake_device, &qca->ws_tx_vote_off which
require strict execution ordering. Hence, an ordered dedicated workqueue
has been used to replace the deprecated create_singlethread_workqueue
instance.

WQ_MEM_RECLAIM has not been set since the driver is not being used on a
memory reclaim path.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Handle HCI raw socket transition from unbound to bound
Marcel Holtmann [Tue, 30 Aug 2016 03:00:40 +0000 (05:00 +0200)]
Bluetooth: Handle HCI raw socket transition from unbound to bound

In case an unbound HCI raw socket is later on bound, ensure that the
monitor notification messages indicate a close and re-open. None of
the userspace tools use the socket this, but it is actually possible
to use an ioctl on an unbound socket and then later bind it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: Send control open and close messages for HCI raw sockets
Marcel Holtmann [Tue, 30 Aug 2016 03:00:39 +0000 (05:00 +0200)]
Bluetooth: Send control open and close messages for HCI raw sockets

When opening and closing HCI raw sockets their main usage is for legacy
userspace. To track interaction with the modern mgmt interface, send
open and close monitoring messages for these action.

The HCI raw sockets is special since it supports unbound ioctl operation
and for that special case delay the notification message until at least
one ioctl has been executed. The difference between a bound and unbound
socket will be detailed by the fact the HCI index is present or not.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: Add extra channel checks for control open/close messages
Marcel Holtmann [Tue, 30 Aug 2016 03:00:38 +0000 (05:00 +0200)]
Bluetooth: Add extra channel checks for control open/close messages

The control open and close monitoring events require special channel
checks to ensure messages are only send when the right events happen.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: Assign the channel early when binding HCI sockets
Marcel Holtmann [Tue, 30 Aug 2016 03:00:37 +0000 (05:00 +0200)]
Bluetooth: Assign the channel early when binding HCI sockets

Assignment of the hci_pi(sk)->channel should be done early when binding
the HCI socket. This avoids confusion with the RAW channel that is used
for legacy access.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: Send control open and close only when cookie is present
Marcel Holtmann [Tue, 30 Aug 2016 03:00:36 +0000 (05:00 +0200)]
Bluetooth: Send control open and close only when cookie is present

Only when the cookie has been assigned, then send the open and close
monitor messages. Also if the socket is bound to a device, then include
the index into the message.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: Use numbers for subsystem version string
Marcel Holtmann [Tue, 30 Aug 2016 03:00:35 +0000 (05:00 +0200)]
Bluetooth: Use numbers for subsystem version string

Instead of keeping a version string around, use version and revision
numbers and then stringify them for use as module parameter.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: Introduce helper functions for socket cookie handling
Marcel Holtmann [Tue, 30 Aug 2016 03:00:34 +0000 (05:00 +0200)]
Bluetooth: Introduce helper functions for socket cookie handling

Instead of manually allocating cookie information each time, use helper
functions for generating and releasing cookies.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: add WCNSS dependency for HCI driver
Arnd Bergmann [Mon, 29 Aug 2016 12:36:18 +0000 (14:36 +0200)]
Bluetooth: add WCNSS dependency for HCI driver

The newly added bluetooth driver is based on the soc-specific support,
but lacks the obvious compile-time dependency on that:

drivers/bluetooth/btqcomsmd.o: In function `btqcomsmd_probe':
btqcomsmd.c:(.text.btqcomsmd_probe+0x40): undefined reference to `qcom_wcnss_open_channel'
btqcomsmd.c:(.text.btqcomsmd_probe+0x5c): undefined reference to `qcom_wcnss_open_channel'
Makefile:969: recipe for target 'vmlinux' failed

Fixes: 90c107dc8b2c ("Bluetooth: Introduce Qualcomm WCNSS SMD based HCI driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Use command status event for Set IO Capability errors
Marcel Holtmann [Mon, 29 Aug 2016 04:31:57 +0000 (06:31 +0200)]
Bluetooth: Use command status event for Set IO Capability errors

In case of failure, the Set IO Capability command is suppose to return
command status and not command complete.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: Fix wrong Get Clock Information return parameters
Marcel Holtmann [Mon, 29 Aug 2016 04:19:47 +0000 (06:19 +0200)]
Bluetooth: Fix wrong Get Clock Information return parameters

The address information of the Get Clock Information return parameters
is copying from a different memory location. It uses &cmd->param while
it actually needs to be cmd->param.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: Use individual flags for certain management events
Marcel Holtmann [Mon, 29 Aug 2016 04:19:46 +0000 (06:19 +0200)]
Bluetooth: Use individual flags for certain management events

Instead of hiding everything behind a general managment events flag,
introduce indivdual flags that allow fine control over which events are
send to a given management channel.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: mgmt: Fix sending redundant event for Advertising Instance
Johan Hedberg [Sun, 28 Aug 2016 17:53:34 +0000 (20:53 +0300)]
Bluetooth: mgmt: Fix sending redundant event for Advertising Instance

When an Advertising Instance is removed, the Advertising Removed event
shouldn't be sent to the same socket that issued the Remove
Advertising command (it gets a command complete event instead). The
mgmt_advertising_removed() function already has a parameter for
skipping a specific socket, but there was no code to propagate the
right value to this parameter. This patch fixes the issue by making
sure the intermediate hci_req_clear_adv_instance() function gets the
socket pointer.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Add support for sending MGMT commands and events to monitor
Marcel Holtmann [Sat, 27 Aug 2016 18:23:41 +0000 (20:23 +0200)]
Bluetooth: Add support for sending MGMT commands and events to monitor

This adds support for tracing all management commands and events via the
monitor interface.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: Add support for sending MGMT open and close to monitor
Marcel Holtmann [Sat, 27 Aug 2016 18:23:40 +0000 (20:23 +0200)]
Bluetooth: Add support for sending MGMT open and close to monitor

This sends new notifications to the monitor support whenever a
management channel has been opened or closed. This allows tracing of
control channels really easily.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: Introduce helper to pack mgmt version information
Marcel Holtmann [Sat, 27 Aug 2016 18:23:39 +0000 (20:23 +0200)]
Bluetooth: Introduce helper to pack mgmt version information

The mgmt version information will be also needed for the control
changell tracing feature. This provides a helper to pack them.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: Store control socket cookie and comm information
Marcel Holtmann [Sat, 27 Aug 2016 18:23:38 +0000 (20:23 +0200)]
Bluetooth: Store control socket cookie and comm information

To further allow unique identification and tracking of control socket,
store cookie and comm information when binding the socket.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: Check SOL_HCI for raw socket options
Marcel Holtmann [Sat, 27 Aug 2016 18:23:37 +0000 (20:23 +0200)]
Bluetooth: Check SOL_HCI for raw socket options

The SOL_HCI level should be enforced when using socket options on the
HCI raw socket interface.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
8 years agoBluetooth: bcm203x: don't print error when allocating urb fails
Wolfram Sang [Thu, 11 Aug 2016 21:00:31 +0000 (23:00 +0200)]
Bluetooth: bcm203x: don't print error when allocating urb fails

kmalloc will print enough information in case of failure.

Signed-off-by: Wolfram Sang <wsa-dev@sang-engineering.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: btusb: Add support for 0cf3:e009
Kai-Heng Feng [Tue, 16 Aug 2016 04:50:06 +0000 (12:50 +0800)]
Bluetooth: btusb: Add support for 0cf3:e009

Device 0cf3:e009 is one of the QCA ROME family.

T:  Bus=01 Lev=01 Prnt=01 Port=07 Cnt=04 Dev#=  4 Spd=12  MxCh= 0
D:  Ver= 2.01 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0cf3 ProdID=e009 Rev=00.01
C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
I:  If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: add printf format attribute to hci_set_[fh]w_info()
Nicolas Iooss [Fri, 29 Jul 2016 11:28:25 +0000 (13:28 +0200)]
Bluetooth: add printf format attribute to hci_set_[fh]w_info()

Commit 5177a83827cd ("Bluetooth: Add debugfs fields for hardware and
firmware info") introduced hci_set_hw_info() and hci_set_fw_info().
These functions use kvasprintf_const() but are not marked with a
__printf attribute.  Adding such an attribute helps detecting issues
related to printf-formatting at build time.

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: btusb, hci_intel: Fix wait_on_bit_timeout() return value checks
Bart Van Assche [Thu, 11 Aug 2016 23:02:44 +0000 (16:02 -0700)]
Bluetooth: btusb, hci_intel: Fix wait_on_bit_timeout() return value checks

wait_on_bit_timeout() returns one of the following three values:
* 0 to indicate success.
* -EINTR to indicate that a signal has been received;
* -EAGAIN to indicate timeout;
Make the wait_on_bit_timeout() callers check for these values.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Introduce Qualcomm WCNSS SMD based HCI driver
Bjorn Andersson [Sat, 13 Aug 2016 00:01:28 +0000 (17:01 -0700)]
Bluetooth: Introduce Qualcomm WCNSS SMD based HCI driver

The Qualcomm WCNSS chip provides two SMD channels to the BT core; one
for command and one for event packets. This driver exposes the two
channels as a hci device.

Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Add HCI device identifier for Qualcomm SMD
Bjorn Andersson [Sat, 13 Aug 2016 00:01:27 +0000 (17:01 -0700)]
Bluetooth: Add HCI device identifier for Qualcomm SMD

This patch assigns the next free HCI device identifier to Bluetooth
devices based on the Qualcomm Shared Memory channels.

Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agomac802154: use rate limited warnings for malformed frames
Aristeu Rozanski [Mon, 25 Jul 2016 15:46:41 +0000 (11:46 -0400)]
mac802154: use rate limited warnings for malformed frames

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
Acked-by: Alexander Aring <aar@pengutronix.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agomac802154: don't warn on unsupported frames
Aristeu Rozanski [Mon, 25 Jul 2016 15:46:40 +0000 (11:46 -0400)]
mac802154: don't warn on unsupported frames

Just because we don't support certain types of frames yet doesn't mean
we have to flood the message log with warnings about "invalid" frames.

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
Acked-by: Alexander Aring <aar@pengutronix.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years ago6lowpan: ndisc: no overreact if no short address is available
Alexander Aring [Sun, 24 Jul 2016 14:12:25 +0000 (16:12 +0200)]
6lowpan: ndisc: no overreact if no short address is available

This patch removes handling to remove short address for a neigbour entry
if RS/RA/NS/NA doesn't contain a short address. If these messages
doesn't has any short address option, the existing short address from
ndisc cache will be used. The current behaviour will set that the
neigbour doesn't has a short address anymore.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agomac802154: set phy net namespace for new ifaces
Alexander Aring [Sun, 24 Jul 2016 14:12:24 +0000 (16:12 +0200)]
mac802154: set phy net namespace for new ifaces

This patch sets the net namespace when creating SoftMAC interfaces. This
is important if the namespace at phy layer was switched before.
Currently we losing interfaces in some namespace and it's not possible
to recover that.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
8 years agoBluetooth: Add combined LED trigger for controller power
Marcel Holtmann [Thu, 21 Jul 2016 12:12:41 +0000 (14:12 +0200)]
Bluetooth: Add combined LED trigger for controller power

Instead of just having a LED trigger for power on a specific controller,
this adds the LED trigger "bluetooth-power" that combines the power
states of all controllers into a single trigger. This simplifies the
trigger selection and also supports multiple controllers per host
system via a single LED.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>