]> git.kernelconcepts.de Git - karo-tx-linux.git/log
karo-tx-linux.git
7 years agoBluetooth: Avoid bt_accept_unlink() double unlinking
Dean Jenkins [Fri, 10 Mar 2017 11:34:46 +0000 (11:34 +0000)]
Bluetooth: Avoid bt_accept_unlink() double unlinking

There is a race condition between a thread calling bt_accept_dequeue()
and a different thread calling bt_accept_unlink(). Protection against
concurrency is implemented using sk locking. However, sk locking causes
serialisation of the bt_accept_dequeue() and bt_accept_unlink() threads.
This serialisation can cause bt_accept_dequeue() to obtain the sk from the
parent list but becomes blocked waiting for the sk lock held by the
bt_accept_unlink() thread. bt_accept_unlink() unlinks sk and this thread
releases the sk lock unblocking bt_accept_dequeue() which potentially runs
bt_accept_unlink() again on the same sk causing a crash. The attempt to
double unlink the same sk from the parent list can cause a NULL pointer
dereference crash due to bt_sk(sk)->parent becoming NULL on the first
unlink, followed by the second unlink trying to execute
bt_sk(sk)->parent->sk_ack_backlog-- in bt_accept_unlink() which crashes.

When sk is in the parent list, bt_sk(sk)->parent will be not be NULL.
When sk is removed from the parent list, bt_sk(sk)->parent is set to
NULL. Therefore, add a defensive check for bt_sk(sk)->parent not being
NULL to ensure that sk is still in the parent list after the sk lock has
been taken in bt_accept_dequeue(). If bt_sk(sk)->parent is detected as
being NULL then restart the loop so that the loop variables are refreshed
to use the latest values. This is necessary as list_for_each_entry_safe()
is not thread safe so causing a risk of an infinite loop occurring as sk
could point to itself.

In addition, in bt_accept_dequeue() increase the sk reference count to
protect against early freeing of sk. Early freeing can be possible if the
bt_accept_unlink() thread calls l2cap_sock_kill() or rfcomm_sock_kill()
functions before bt_accept_dequeue() gets the sk lock.

For test purposes, the probability of failure can be increased by putting
a msleep of 1 second in bt_accept_dequeue() between getting the sk and
waiting for the sk lock. This exposes the fact that the loop
list_for_each_entry_safe(p, n, &bt_sk(parent)->accept_q) is not safe from
threads that unlink sk from the list in parallel with the loop which can
cause sk to become stale within the loop.

Signed-off-by: Dean Jenkins <Dean_Jenkins@mentor.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
7 years agoBluetooth: Handle bt_accept_enqueue() socket atomically
Dean Jenkins [Fri, 10 Mar 2017 11:34:45 +0000 (11:34 +0000)]
Bluetooth: Handle bt_accept_enqueue() socket atomically

There is a small risk that bt_accept_unlink() runs concurrently with
bt_accept_enqueue() on the same socket. This scenario could potentially
lead to a NULL pointer dereference of the socket's parent member because
the socket can be on the list but the socket's parent member is not yet
updated by bt_accept_enqueue().

Therefore, add socket locking inside bt_accept_enqueue() so that the
socket is added to the list AND the parent's socket address is set in the
socket's parent member. The socket locking ensures that the socket is on
the list with a valid non-NULL parent member.

Signed-off-by: Dean Jenkins <Dean_Jenkins@mentor.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
7 years agoBluetooth: bluecard: use setup_timer
Geliang Tang [Sat, 11 Mar 2017 00:46:58 +0000 (08:46 +0800)]
Bluetooth: bluecard: use setup_timer

Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
7 years ago6lowpan: Fix IID format for Bluetooth
Luiz Augusto von Dentz [Sun, 12 Mar 2017 08:19:38 +0000 (10:19 +0200)]
6lowpan: Fix IID format for Bluetooth

According to RFC 7668 U/L bit shall not be used:

https://wiki.tools.ietf.org/html/rfc7668#section-3.2.2 [Page 10]:

   In the figure, letter 'b' represents a bit from the
   Bluetooth device address, copied as is without any changes on any
   bit.  This means that no bit in the IID indicates whether the
   underlying Bluetooth device address is public or random.

   |0              1|1              3|3              4|4              6|
   |0              5|6              1|2              7|8              3|
   +----------------+----------------+----------------+----------------+
   |bbbbbbbbbbbbbbbb|bbbbbbbb11111111|11111110bbbbbbbb|bbbbbbbbbbbbbbbb|
   +----------------+----------------+----------------+----------------+

Because of this the code cannot figure out the address type from the IP
address anymore thus it makes no sense to use peer_lookup_ba as it needs
the peer address type.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
Acked-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
7 years ago6lowpan: Use netdev addr_len to determine lladdr len
Luiz Augusto von Dentz [Sun, 12 Mar 2017 08:19:37 +0000 (10:19 +0200)]
6lowpan: Use netdev addr_len to determine lladdr len

This allow technologies such as Bluetooth to use its native lladdr which
is eui48 instead of eui64 which was expected by functions like
lowpan_header_decompress and lowpan_header_compress.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
7 years agoipv6: addrconf: fix 48 bit 6lowpan autoconfiguration
Alexander Aring [Sun, 12 Mar 2017 08:19:36 +0000 (10:19 +0200)]
ipv6: addrconf: fix 48 bit 6lowpan autoconfiguration

This patch adds support for 48 bit 6LoWPAN address length
autoconfiguration which is the case for BTLE 6LoWPAN.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
7 years ago6lowpan: iphc: override l2 packet information
Alexander Aring [Sun, 12 Mar 2017 08:19:35 +0000 (10:19 +0200)]
6lowpan: iphc: override l2 packet information

The skb->pkt_type need to be set by L2, but on 6LoWPAN there exists L2
e.g. BTLE which doesn't has multicast addressing. If it's a multicast or
not is detected by IPHC headers multicast bit. The IPv6 layer will
evaluate this pkt_type, so we force set this type while uncompressing.
Should be okay for 802.15.4 as well.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
7 years ago6lowpan: Set MAC address length according to LOWPAN_LLTYPE
Patrik Flykt [Sun, 12 Mar 2017 08:19:34 +0000 (10:19 +0200)]
6lowpan: Set MAC address length according to LOWPAN_LLTYPE

Set MAC address length according to the 6LoWPAN link layer in use.
Bluetooth Low Energy uses 48 bit addressing while IEEE802.15.4 uses
64 bits.

Signed-off-by: Patrik Flykt <patrik.flykt@linux.intel.com>
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
7 years agobluetooth: Set 6 byte device addresses
Patrik Flykt [Sun, 12 Mar 2017 08:19:33 +0000 (10:19 +0200)]
bluetooth: Set 6 byte device addresses

Set BTLE MAC addresses that are 6 bytes long and not 8 bytes
that are used in other places with 6lowpan.

Signed-off-by: Patrik Flykt <patrik.flykt@linux.intel.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
7 years agoBluetooth: hci_bcm: Fix clock (un)prepare
John Keeping [Wed, 15 Mar 2017 12:20:05 +0000 (12:20 +0000)]
Bluetooth: hci_bcm: Fix clock (un)prepare

The hci_bcm driver currently does not prepare/unprepare the clock and
goes directly to enable, but as the documentation for clk_enable says,
clk_prepare must be called before clk_enable.

Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
7 years agoBluetooth: convert rfcomm_dlc.refcnt from atomic_t to refcount_t
Elena Reshetova [Fri, 17 Mar 2017 11:12:46 +0000 (13:12 +0200)]
Bluetooth: convert rfcomm_dlc.refcnt from atomic_t to refcount_t

refcount_t type and corresponding API should be
used instead of atomic_t when the variable is used as
a reference counter. This allows to avoid accidental
refcounter overflows that might lead to use-after-free
situations.

Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
Signed-off-by: Hans Liljestrand <ishkamiel@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David Windsor <dwindsor@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
7 years agoBluetooth: btmrvl: fix spelling mistake: "unregester" -> "unregister"
Colin Ian King [Tue, 21 Mar 2017 12:20:28 +0000 (12:20 +0000)]
Bluetooth: btmrvl: fix spelling mistake: "unregester" -> "unregister"

trivial fix to spelling mistake in debug message

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
7 years agonet: make struct net_device::min_header_len 8-bit
Alexey Dobriyan [Mon, 10 Apr 2017 08:25:26 +0000 (11:25 +0300)]
net: make struct net_device::min_header_len 8-bit

This field is never big enough to warrant 16-bitness.

8-bit accesses enjoy shorted encoding on i386/x86_64 than 16-bit
accesses:

add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-10 (-10)
function                                     old     new   delta
loopback_setup                               169     164      -5
ether_setup                                  148     143      -5

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet: neigh: make ->hh_len 32-bit
Alexey Dobriyan [Mon, 10 Apr 2017 08:11:17 +0000 (11:11 +0300)]
net: neigh: make ->hh_len 32-bit

Using 16-bit ->hh_len doesn't save any memory, save some .text instead:

add/remove: 0/0 grow/shrink: 1/6 up/down: 2/-19 (-17)
function                                     old     new   delta
neigh_update                                2312    2314      +2
fwnet_header_cache                           199     197      -2
eth_header_cache                             101      99      -2
ip6_finish_output2                          2371    2368      -3
vrf_finish_output6                          1522    1518      -4
vrf_finish_output                           1413    1409      -4
ip_finish_output2                           1627    1623      -4

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agogso: Support frag_list splitting with head_frag
Ilan Tayari [Fri, 7 Apr 2017 23:07:08 +0000 (02:07 +0300)]
gso: Support frag_list splitting with head_frag

A driver may use build_skb() for received packets.
These SKBs then have a head_frag.

Since commit d7e8883cfcf4 ("net: make GRO aware of
skb->head_frag"), GRO may build frag_list SKBs out of
head_frag received SKBs.
In such a case, the chained SKBs end up with a head_frag.

Commit 07b26c9454a2 ("gso: Support partial splitting at
the frag_list pointer") adds partial segmentation of frag_list
SKB chains into individual SKBs.
However, this is not done if the chained SKBs have any
linear part, because the device may not be able to DMA
the private linear buffer.

A chained frag_list SKB with head_frag is wrongfully
detected in this case as having a private linear part
and thus falls back to software GSO, while in fact the
linear part is backed by a DMA page just like any other frag.

This causes low performance when forwarding those packets
that were built with build_skb()

Allow partial segmentation at the frag_list pointer for
chained SKBs with head_frag.

Note that such SKBs can only be created by GRO, when applied
to received packets with head_frag.
Also note that this change only affects the data path that
performs the partial segmentation at frag_list pointer, and
not any of the other more common data paths.

Signed-off-by: Ilan Tayari <ilant@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoMerge branch 'l2tp-const'
David S. Miller [Wed, 12 Apr 2017 14:44:03 +0000 (10:44 -0400)]
Merge branch 'l2tp-const'

Guillaume Nault says:

====================
l2tp: constify l2tp_session_get*() and l2tp_tunnel_find*()

Declare parameters of these functions as "const" where possible.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agol2tp: define parameters of l2tp_tunnel_find*() as "const"
Guillaume Nault [Wed, 12 Apr 2017 08:05:30 +0000 (10:05 +0200)]
l2tp: define parameters of l2tp_tunnel_find*() as "const"

l2tp_tunnel_find() and l2tp_tunnel_find_nth() don't modify "net".

Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agol2tp: define parameters of l2tp_session_get*() as "const"
Guillaume Nault [Wed, 12 Apr 2017 08:05:29 +0000 (10:05 +0200)]
l2tp: define parameters of l2tp_session_get*() as "const"

Make l2tp_pernet()'s parameter constant, so that l2tp_session_get*() can
declare their "net" variable as "const".
Also constify "ifname" in l2tp_session_get_by_ifname().

Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoMerge branch 'ftgmac100-rework-batch4-misc'
David S. Miller [Wed, 12 Apr 2017 14:17:03 +0000 (10:17 -0400)]
Merge branch 'ftgmac100-rework-batch4-misc'

Benjamin Herrenschmidt says:

====================
ftgmac100: Rework batch 4 - Misc

This is v2 of the fourth batch of updates to the ftgmac100 driver.

This is a bunch of misc cleanups and fixes, such as properly
disabling HW checksum generation on AST2400 where it's known
to be broken and some chip init updates.

This also adds the ability to turn HW checksum on/off and
configure the ring sizes via ethtool.

v2 Fixes patch 1/10 (NETIF_F_HW_CSUM conversion)

The next (and last) batch will add a few more "features" such
as netpoll, multicast/promist, vlan offload...
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Set default ring sizes to 128 entries
Benjamin Herrenschmidt [Wed, 12 Apr 2017 03:27:10 +0000 (13:27 +1000)]
ftgmac100: Set default ring sizes to 128 entries

I haven't seen any improvement above that size on the machines
I've tested with.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Make ring sizes configurable via ethtool
Benjamin Herrenschmidt [Wed, 12 Apr 2017 03:27:09 +0000 (13:27 +1000)]
ftgmac100: Make ring sizes configurable via ethtool

We set an arbitrary max at 1024 since we pre-allocate the actual
descriptor arrays and skb arrays to the full size to keep the
code a bit simpler and avoid allocation failures in the reset
task.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Add more register inits in ftgmac100_init_hw()
Benjamin Herrenschmidt [Wed, 12 Apr 2017 03:27:08 +0000 (13:27 +1000)]
ftgmac100: Add more register inits in ftgmac100_init_hw()

Clear stale interrupts on entry, configure FIFO sizes, set FIFO
thresholds, configure interrupt mitigation.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Open code remaining register writes
Benjamin Herrenschmidt [Wed, 12 Apr 2017 03:27:07 +0000 (13:27 +1000)]
ftgmac100: Open code remaining register writes

The helpers just take space but don't provide much value. Simple
one line comments are more explanatory.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Rename ftgmac100_setup_mac to ftgmac100_initial_mac
Benjamin Herrenschmidt [Wed, 12 Apr 2017 03:27:06 +0000 (13:27 +1000)]
ftgmac100: Rename ftgmac100_setup_mac to ftgmac100_initial_mac

To remove more confusion. This function is about obtaining the
initial MAC address at driver probe time.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Rename ftgmac100_set_mac to ftgmac100_write_mac_addr
Benjamin Herrenschmidt [Wed, 12 Apr 2017 03:27:05 +0000 (13:27 +1000)]
ftgmac100: Rename ftgmac100_set_mac to ftgmac100_write_mac_addr

To avoid confusion with the ndo callback and generally be
clearer about the purpose of that function

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Set netdev->hw_features
Benjamin Herrenschmidt [Wed, 12 Apr 2017 03:27:04 +0000 (13:27 +1000)]
ftgmac100: Set netdev->hw_features

So features can be turned on/off via ethtool

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Disable HW checksum generation on AST2400, enable on others
Benjamin Herrenschmidt [Wed, 12 Apr 2017 03:27:03 +0000 (13:27 +1000)]
ftgmac100: Disable HW checksum generation on AST2400, enable on others

We found out that HW checksum generation only works from AST2500
onward. This disables it on AST2400 and removes the "no-hw-checksum"
properties in the device-trees. The problem we had wasn't related
to NC-SI.

Also rework the logic testing for that property so it can be used
to disable HW checksum generation and checking regardless of whether
NC-SI is used or not in case other variants out there need this.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Use device "compatible" property, not machine.
Benjamin Herrenschmidt [Wed, 12 Apr 2017 03:27:02 +0000 (13:27 +1000)]
ftgmac100: Use device "compatible" property, not machine.

We test for aspeed chips to handle a couple of special cases,
but we do that by checking the machine type which isn't right.

Instead check the actual device compatible property. This also
updates the dtsi files for the aspeed SoC to match.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Upgrade to NETIF_F_HW_CSUM
Benjamin Herrenschmidt [Wed, 12 Apr 2017 03:27:01 +0000 (13:27 +1000)]
ftgmac100: Upgrade to NETIF_F_HW_CSUM

The documentation describes NETIF_F_IP_CSUM as deprecated
so let's switch to NETIF_F_HW_CSUM and use the helper to
handle unhandled protocols.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoMerge branch 'net-smc-next'
David S. Miller [Wed, 12 Apr 2017 03:01:15 +0000 (23:01 -0400)]
Merge branch 'net-smc-next'

Ursula Braun says:

====================
net/smc: patches for net-next

here are some patches for net/smc. Most important are
improvements for socket closing.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet/smc: do not use IB_SEND_INLINE together with mapped data
Ursula Braun [Mon, 10 Apr 2017 12:58:05 +0000 (14:58 +0200)]
net/smc: do not use IB_SEND_INLINE together with mapped data

smc specifies IB_SEND_INLINE for IB_WR_SEND ib_post_send calls, but
provides a mapped buffer to be sent. This is inconsistent, since
IB_SEND_INLINE works without mapped buffer. Problem has not been
detected in the past, because tests had been limited to Connect X3 cards
from Mellanox, whose mlx4 driver just ignored the IB_SEND_INLINE flag.
For now, the IB_SEND_INLINE flag is removed.

Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet/smc: destruct non-accepted sockets
Ursula Braun [Mon, 10 Apr 2017 12:58:04 +0000 (14:58 +0200)]
net/smc: destruct non-accepted sockets

Make sure sockets never accepted are removed cleanly.

Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet/smc: remove duplicate unhash
Ursula Braun [Mon, 10 Apr 2017 12:58:03 +0000 (14:58 +0200)]
net/smc: remove duplicate unhash

unhash is already called in sock_put_work. Remove the second call.

Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet/smc: guarantee ConnClosed send after shutdown SHUT_WR
Ursula Braun [Mon, 10 Apr 2017 12:58:02 +0000 (14:58 +0200)]
net/smc: guarantee ConnClosed send after shutdown SHUT_WR

State SMC_CLOSED should be reached only, if ConnClosed has been sent to
the peer. If ConnClosed is received from the peer, a socket with
shutdown SHUT_WR done, switches errorneously to state SMC_CLOSED, which
means the peer socket is dangling. The local SMC socket is supposed to
switch to state APPFINCLOSEWAIT to make sure smc_close_final() is called
during socket close.

Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet/smc: no socket state changes in tasklet context
Ursula Braun [Mon, 10 Apr 2017 12:58:01 +0000 (14:58 +0200)]
net/smc: no socket state changes in tasklet context

Several state changes occur during SMC socket closing. Currently
state changes triggered locally occur in process context with
lock_sock() taken while state changes triggered by peer occur in
tasklet context with bh_lock_sock() taken. bh_lock_sock() does not
wait till a lock_sock(() task in process context is finished. This
may lead to races in socket state transitions resulting in dangling
SMC-sockets, or it may lead to duplicate SMC socket freeing.
This patch introduces a closing worker to run all state changes under
lock_sock().

Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reported-by: Dave Jones <davej@codemonkey.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet/smc: always call the POLL_IN part of sk_wake_async
Ursula Braun [Mon, 10 Apr 2017 12:58:00 +0000 (14:58 +0200)]
net/smc: always call the POLL_IN part of sk_wake_async

Wake up reading file descriptors for a closing socket as well, otherwise
some socket applications may stall.

Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet/smc: guarantee reset of write_blocked for heavy workload
Ursula Braun [Mon, 10 Apr 2017 12:57:59 +0000 (14:57 +0200)]
net/smc: guarantee reset of write_blocked for heavy workload

If peer indicates write_blocked, the cursor state of the received data
should be send to the peer immediately (in smc_tx_consumer_update()).
Afterwards the write_blocked indicator is cleared.

If there is no free slot for another write request, sending is postponed
to worker smc_tx_work, and the write_blocked indicator is not cleared.
Therefore another clearing check is needed in smc_tx_work().

Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet/smc: return active RoCE port only
Ursula Braun [Mon, 10 Apr 2017 12:57:58 +0000 (14:57 +0200)]
net/smc: return active RoCE port only

SMC requires an active ib port on the RoCE device.
smc_pnet_find_roce_resource() determines the matching RoCE device port
according to the configured PNET table. Do not return the found
RoCE device port, if it is not flagged active.

Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet/smc: remove useless smc_ib_devices_list check
Ursula Braun [Mon, 10 Apr 2017 12:57:57 +0000 (14:57 +0200)]
net/smc: remove useless smc_ib_devices_list check

The global event handler is created only, if the ib_device has already
been used by at least one link group. It is guaranteed that there exists
the corresponding entry in the smc_ib_devices list. Get rid of this
superfluous check.

Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet/smc: get rid of old comment
Ursula Braun [Mon, 10 Apr 2017 12:57:56 +0000 (14:57 +0200)]
net/smc: get rid of old comment

This patch removes an outdated comment.

Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet: stmmac: use netif_set_real_num_{rx,tx}_queues
Joao Pinto [Mon, 10 Apr 2017 10:32:14 +0000 (11:32 +0100)]
net: stmmac: use netif_set_real_num_{rx,tx}_queues

In the submission of the lastest multiple buffer patch set, this fix was lost.
I am sending this patch to put it right again. The fix was originally proposed
by Arnd Bergmann.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Joao Pinto <jpinto@synopsys.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agobpf: pass sk to helper functions
Willem de Bruijn [Tue, 11 Apr 2017 18:08:08 +0000 (14:08 -0400)]
bpf: pass sk to helper functions

BPF helper functions access socket fields through skb->sk. This is not
set in ingress cgroup and socket filters. The association is only made
in skb_set_owner_r once the filter has accepted the packet. Sk is
available as socket lookup has taken place.

Temporarily set skb->sk to sk in these cases.

Signed-off-by: Willem de Bruijn <willemb@google.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agodevlink: fix return value check in devlink_dpipe_header_put()
Wei Yongjun [Tue, 11 Apr 2017 16:02:02 +0000 (16:02 +0000)]
devlink: fix return value check in devlink_dpipe_header_put()

Fix the return value check which testing the wrong variable
in devlink_dpipe_header_put().

Fixes: 1555d204e743 ("devlink: Support for pipeline debug (dpipe)")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoMerge branch 's390-qeth-updates'
David S. Miller [Tue, 11 Apr 2017 18:51:36 +0000 (14:51 -0400)]
Merge branch 's390-qeth-updates'

Julian Wiedmann says:

====================
more s390/net updates

here's a second batch of s390/net patches for net-next.
A mixed bunch of qeth cleanups, and a few patches to add support for
ETHTOOL_GLINKSETTINGS.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agos390/qeth: remove unimplemented gdev routines
Julian Wiedmann [Tue, 11 Apr 2017 14:11:19 +0000 (16:11 +0200)]
s390/qeth: remove unimplemented gdev routines

prepare() and complete() are not implemented by any discipline, so just
drop all the indirection.

Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Reviewed-by: Hans Wippel <hwippel@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agos390/qeth: use LINK_MODE_* to report the link characteristics
Julian Wiedmann [Tue, 11 Apr 2017 14:11:18 +0000 (16:11 +0200)]
s390/qeth: use LINK_MODE_* to report the link characteristics

LINK_MODE_* replaces the u32-limited SUPPORTED_* / ENABLED_*
definitions.

Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agos390/qeth: convert to ETHTOOL_GLINKSETTINGS API
Julian Wiedmann [Tue, 11 Apr 2017 14:11:17 +0000 (16:11 +0200)]
s390/qeth: convert to ETHTOOL_GLINKSETTINGS API

get_settings() is deprecated and lacks support for higher link
speeds, so implement get_link_ksettings() instead.

Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agos390/qeth: clean up qeth_set_ecmd_adv_sup()
Julian Wiedmann [Tue, 11 Apr 2017 14:11:16 +0000 (16:11 +0200)]
s390/qeth: clean up qeth_set_ecmd_adv_sup()

In preparation for moving to get_link_ksettings(), clean up how
we build the supported and advertised port/speed masks.

Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Reviewed-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agos390/qeth: use and remove some defines
Julian Wiedmann [Tue, 11 Apr 2017 14:11:15 +0000 (16:11 +0200)]
s390/qeth: use and remove some defines

1. a buffer has 16 is_header flags, because that's its # of elements
2. replace the last occurrence of QETH_HEADER_SIZE, and remove it

Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Acked-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agos390/qeth: use correct return type for hard_start_xmit()
Julian Wiedmann [Tue, 11 Apr 2017 14:11:14 +0000 (16:11 +0200)]
s390/qeth: use correct return type for hard_start_xmit()

ndo_start_xmit() expects us to return netdev_tx_t here...

Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Acked-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agos390/qeth: remove unused parameter
Julian Wiedmann [Tue, 11 Apr 2017 14:11:13 +0000 (16:11 +0200)]
s390/qeth: remove unused parameter

'elements_needed' is not used in qeth_do_send_packet_fast(),
so consequently remove it.

Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Acked-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agos390/qeth: move gdev shutdown handler to core
Julian Wiedmann [Tue, 11 Apr 2017 14:11:12 +0000 (16:11 +0200)]
s390/qeth: move gdev shutdown handler to core

Duplicated code.

Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Acked-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agos390/qeth: move NAPI poll routine to core
Julian Wiedmann [Tue, 11 Apr 2017 14:11:11 +0000 (16:11 +0200)]
s390/qeth: move NAPI poll routine to core

Identical code, we just need to call a layer-specific hook
to process any received buffer.

qeth_buffer_reclaim_work() is shuffled around to avoid a
forward declaration for qeth_queue_input_buffer().

Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Acked-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agos390/qeth: move common ioctl handling to core
Julian Wiedmann [Tue, 11 Apr 2017 14:11:10 +0000 (16:11 +0200)]
s390/qeth: move common ioctl handling to core

There's a number of layer-independent ioctls that we can handle
in core, and reduce code duplication. For layer-specific ioctls,
add a do_ioctl() discipline hook.

Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Acked-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agobpf: remove struct bpf_map_type_list
Johannes Berg [Tue, 11 Apr 2017 13:34:58 +0000 (15:34 +0200)]
bpf: remove struct bpf_map_type_list

There's no need to have struct bpf_map_type_list since
it just contains a list_head, the type, and the ops
pointer. Since the types are densely packed and not
actually dynamically registered, it's much easier and
smaller to have an array of type->ops pointer. Also
initialize this array statically to remove code needed
to initialize it.

In order to save duplicating the list, move it to the
types header file added by the previous patch and
include it in the same fashion.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agobpf: remove struct bpf_prog_type_list
Johannes Berg [Tue, 11 Apr 2017 13:34:57 +0000 (15:34 +0200)]
bpf: remove struct bpf_prog_type_list

There's no need to have struct bpf_prog_type_list since
it just contains a list_head, the type, and the ops
pointer. Since the types are densely packed and not
actually dynamically registered, it's much easier and
smaller to have an array of type->ops pointer. Also
initialize this array statically to remove code needed
to initialize it.

In order to save duplicating the list, move it to a new
header file and include it in the places needing it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoMerge branch 'fec-driver-code-clean'
David S. Miller [Tue, 11 Apr 2017 18:36:28 +0000 (14:36 -0400)]
Merge branch 'fec-driver-code-clean'

Fugang Duan says:

====================
net: fec: driver code clean

The patch series are for fec ethernet driver code clean up, each patch is
independent.
Patch #1,#4,#5 are code clean up.
Patch #2,#3 are for aarch64 platform.
Patch #6 is for i.MX6UL to add lost errata workaround.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet: fec: add ERR007885 for i.MX6ul enet IP
Fugang Duan [Tue, 11 Apr 2017 11:13:08 +0000 (19:13 +0800)]
net: fec: add ERR007885 for i.MX6ul enet IP

The errata ERR007885 HW fix don't add to i.MX6ul ENET IP version,
so add sw workaroud for the chip.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet: fec: correct the errata number comment typo
Fugang Duan [Tue, 11 Apr 2017 11:13:07 +0000 (19:13 +0800)]
net: fec: correct the errata number comment typo

Correct the errata number ERR006358 comment typo.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet: fec: add phy-reset-gpios PROBE_DEFER check
Fugang Duan [Tue, 11 Apr 2017 11:13:06 +0000 (19:13 +0800)]
net: fec: add phy-reset-gpios PROBE_DEFER check

Many boards use i2c/spi expander gpio as phy-reset-gpios and these
gpios maybe registered after fec port, driver should check the return
value of .of_get_named_gpio().

Signed-off-by: Fugang Duan <B38611@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet: fec: pass ->dev to dma_alloc__coherent() API
Fugang Duan [Tue, 11 Apr 2017 11:13:05 +0000 (19:13 +0800)]
net: fec: pass ->dev to dma_alloc__coherent() API

In aarch64 system, it requires to trasfer ->dev to dma_alloc_coherent()
API, otherwise allocate failed and print kernel warning.

Signed-off-by: Fugang Duan <B38611@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet: fec: avoid BD pointer type cast to 32bit
Fugang Duan [Tue, 11 Apr 2017 11:13:04 +0000 (19:13 +0800)]
net: fec: avoid BD pointer type cast to 32bit

In aarch64 system, the BD pointer is 64bit, and the high-order 32-bits
of the address is effective, so replace usigned with (void *) type to
aovid 64bit address is casted to 32bit in .fec_enet_get_nextdesc() and
.fec_enet_get_prevdesc() functions.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet: fec: add return value check after calling .of_property_read_u32()
Fugang Duan [Tue, 11 Apr 2017 11:13:03 +0000 (19:13 +0800)]
net: fec: add return value check after calling .of_property_read_u32()

Add return value check after calling .of_property_read_u32() to avoid
the warning reported by coverity.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoMerge branch 'l2tp-drop-l2tp_session_find'
David S. Miller [Tue, 11 Apr 2017 17:48:10 +0000 (13:48 -0400)]
Merge branch 'l2tp-drop-l2tp_session_find'

Guillaume Nault says:

====================
l2tp: drop l2tp_session_find()

l2tp_netlink is the last user of l2tp_session_find(), but that call is
useless. Let's remove it and drop l2tp_session_find() definitely.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agol2tp: remove l2tp_session_find()
Guillaume Nault [Tue, 11 Apr 2017 11:12:21 +0000 (13:12 +0200)]
l2tp: remove l2tp_session_find()

This function isn't used anymore.

Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agol2tp: remove useless duplicate session detection in l2tp_netlink
Guillaume Nault [Tue, 11 Apr 2017 11:12:13 +0000 (13:12 +0200)]
l2tp: remove useless duplicate session detection in l2tp_netlink

There's no point in checking for duplicate sessions at the beginning of
l2tp_nl_cmd_session_create(); the ->session_create() callbacks already
return -EEXIST when the session already exists.

Furthermore, even if l2tp_session_find() returns NULL, a new session
might be created right after the test. So relying on ->session_create()
to avoid duplicate session is the only sane behaviour.

Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoMerge branch 'net-remove-pci_enable_msix'
David S. Miller [Tue, 11 Apr 2017 15:16:04 +0000 (11:16 -0400)]
Merge branch 'net-remove-pci_enable_msix'

Christoph Hellwig says:

====================
remove pci_enable_msix() V3

this series removes the remaining callers of the pci_enable_msix()
function and then the function itself.  The final removal has been
Acked by Bjorn.

Changes since V2:
 - add another patch on Dave's request
 - add various acks
 - spelling fixes in the commit logs

Changes since V1:
 - replace the two previous thunderx patches with a new one from Thanneeru
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agomlxsw: convert to pci_alloc_irq_vectors
Christoph Hellwig [Tue, 11 Apr 2017 11:01:25 +0000 (13:01 +0200)]
mlxsw: convert to pci_alloc_irq_vectors

Trivial conversion as only one vector is supported, but at least we
lose the useless msix_entry member in the per-device structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Tested-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoPCI: remove pci_enable_msix
Christoph Hellwig [Tue, 11 Apr 2017 11:01:24 +0000 (13:01 +0200)]
PCI: remove pci_enable_msix

Unused now that all callers switched to pci_alloc_irq_vectors.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet: thunderx: Switch to pci_alloc_irq_vectors
Thanneeru Srinivasulu [Tue, 11 Apr 2017 11:01:23 +0000 (13:01 +0200)]
net: thunderx: Switch to pci_alloc_irq_vectors

Remove deprecated pci_enable_msix API in favour of its
successor pci_alloc_irq_vectors.

Signed-off-by: Thanneeru Srinivasulu <tsrinivasulu@cavium.com>
Signed-off-by: Sunil Goutham <sgoutham@cavium.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet/ena: switch to pci_alloc_irq_vectors
Christoph Hellwig [Tue, 11 Apr 2017 11:01:22 +0000 (13:01 +0200)]
net/ena: switch to pci_alloc_irq_vectors

Remove the deprecated pci_enable_msix API in favour of its successor.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet: alx: switch to pci_alloc_irq_vectors
Christoph Hellwig [Tue, 11 Apr 2017 11:01:21 +0000 (13:01 +0200)]
net: alx: switch to pci_alloc_irq_vectors

Remove the deprecated pci_enable_msix API in favour of its successor,
and make sure to handle errors during IRQ setup properly.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoMerge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec...
David S. Miller [Tue, 11 Apr 2017 14:10:30 +0000 (10:10 -0400)]
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next

Steffen Klassert says:

====================
pull request (net-next): ipsec-next 2017-04-11

1) Remove unused field from struct xfrm_mgr.

2) Code size optimizations for the xfrm prefix hash and
   address match.

3) Branch optimization for addr4_match.

All patches from Alexey Dobriyan.

Please pull or let me know if there are problems.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoMerge branch 'ftgmac100-rework-batch3-tx-path'
David S. Miller [Mon, 10 Apr 2017 20:03:59 +0000 (16:03 -0400)]
Merge branch 'ftgmac100-rework-batch3-tx-path'

Benjamin Herrenschmidt says:

====================
ftgmac100: Rework batch 3 - TX path

This is version 2 of the third batch of updates to
the ftgmac100 driver.

This one tackles the TX path of the driver. This provides the
bulk of the performance improvements by adding support for
fragmented sends along with a bunch of cleanups.

Version 2 fixes a patch splitting mistake and uses
eth_skb_pad() (which uses skb_put_padto) to pad ethernet
frames rather than skb_padto(), thus removing the need to
also pad the packet headlen in a couple of places.

Subsequent batches will add various features (ethtool functions,
vlan offlan, ...) and cleanups.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Remove tx descriptor accessors
Benjamin Herrenschmidt [Mon, 10 Apr 2017 01:15:26 +0000 (11:15 +1000)]
ftgmac100: Remove tx descriptor accessors

Directly access the fields when needed. The accessors add clutter
not clarity and in some cases cause unnecessary read-modify-write
type access on the slow (uncached) descriptor memory.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Add support for fragmented tx
Benjamin Herrenschmidt [Mon, 10 Apr 2017 01:15:25 +0000 (11:15 +1000)]
ftgmac100: Add support for fragmented tx

Add NETIF_F_SG and create multiple TX ring entries for skb fragments.

On reclaim, the skb is only freed on the segment marked as "last".

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Don't clear tx desc fields unnecessarily
Benjamin Herrenschmidt [Mon, 10 Apr 2017 01:15:24 +0000 (11:15 +1000)]
ftgmac100: Don't clear tx desc fields unnecessarily

Those are non-cachable stores, let's avoid those we don't need. Remove
the helper, it's not particularly helpful and since it uses "priv"
I can't move it to the header file.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Split tx packet freeing from ftgmac100_tx_complete_packet()
Benjamin Herrenschmidt [Mon, 10 Apr 2017 01:15:23 +0000 (11:15 +1000)]
ftgmac100: Split tx packet freeing from ftgmac100_tx_complete_packet()

This moves the packet freeing to a separate function
which is also used by ftgmac100_free_buffers() and will
be used more in the error path of fragmented sends.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Move the barrier out of ftgmac100_txdes_set_dma_own()
Benjamin Herrenschmidt [Mon, 10 Apr 2017 01:15:22 +0000 (11:15 +1000)]
ftgmac100: Move the barrier out of ftgmac100_txdes_set_dma_own()

We'll use variants of this accessor without barriers when
building series of descriptors for fragmented sends

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Cleanup tx queue handling
Benjamin Herrenschmidt [Mon, 10 Apr 2017 01:15:21 +0000 (11:15 +1000)]
ftgmac100: Cleanup tx queue handling

We have a private lock which isn't terribly useful, and we maintain
a "tx_pending" counter for information that's already available
via a trivial arithmetic operation. Then we unconditionaly wake
the queue even when not stopped. Finally our code in tx isn't
really safe vs. a concurrent reclaim. The aspeed chips aren't SMP
today but I prefer the code being right and future proof.

So rip that out and replace it with more "standard" queue handling,
currently with a threshold of 1 queue element, which will be
increased when we implement fragmented sends.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Store tx skbs in a separate array
Benjamin Herrenschmidt [Mon, 10 Apr 2017 01:15:20 +0000 (11:15 +1000)]
ftgmac100: Store tx skbs in a separate array

Rather than in the descriptor. The descriptor is mapped non-cachable
and rather slow to access.

Since to do that we need to keep track of the tx "pointer" we also
have no use of all the accesors to manipulate it, just open code
it, it's as clear and will help when adding fragmented sends.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Pad small frames properly
Benjamin Herrenschmidt [Mon, 10 Apr 2017 01:15:19 +0000 (11:15 +1000)]
ftgmac100: Pad small frames properly

Rather than just transmitting garbage past the end of the small
packet.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Factor tx packet dropping path
Benjamin Herrenschmidt [Mon, 10 Apr 2017 01:15:18 +0000 (11:15 +1000)]
ftgmac100: Factor tx packet dropping path

Use a simple goto to a drop path at the tail of the function,
it will be used in a few more cases soon

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Merge ftgmac100_xmit() into ftgmac100_hard_start_xmit()
Benjamin Herrenschmidt [Mon, 10 Apr 2017 01:15:17 +0000 (11:15 +1000)]
ftgmac100: Merge ftgmac100_xmit() into ftgmac100_hard_start_xmit()

This will make subsequent rework of the tx path simpler

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Move ftgmac100_hard_start_xmit() around
Benjamin Herrenschmidt [Mon, 10 Apr 2017 01:15:16 +0000 (11:15 +1000)]
ftgmac100: Move ftgmac100_hard_start_xmit() around

Move it below ftgmac100_xmit() and the rest of the tx path

No code change.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoftgmac100: Add a tx timeout handler
Benjamin Herrenschmidt [Mon, 10 Apr 2017 01:15:15 +0000 (11:15 +1000)]
ftgmac100: Add a tx timeout handler

We have a reset task to reset our chip, use it.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet: dsa: mt7530: Include gpio/consumer.h for GPIO functions
Florian Fainelli [Sat, 8 Apr 2017 15:52:02 +0000 (08:52 -0700)]
net: dsa: mt7530: Include gpio/consumer.h for GPIO functions

Fixes build errors seen with CONFIG_GPIOLIB disabled and warnings enabled:

drivers/net/dsa/mt7530.c: In function 'mt7530_setup':
drivers/net/dsa/mt7530.c:948:3: error: implicit declaration of function 'gpiod_set_value_cansleep' [-Werror=implicit-function-declaration]
   gpiod_set_value_cansleep(priv->reset, 0);
   ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/dsa/mt7530.c: In function 'mt7530_probe':
drivers/net/dsa/mt7530.c:1068:17: error: implicit declaration of function 'devm_gpiod_get_optional' [-Werror=implicit-function-declaration]
   priv->reset = devm_gpiod_get_optional(&mdiodev->dev, "reset",
                 ^~~~~~~~~~~~~~~~~~~~~~~
drivers/net/dsa/mt7530.c:1069:13: error: 'GPIOD_OUT_LOW' undeclared (first use in this function)
             GPIOD_OUT_LOW);
             ^~~~~~~~~~~~~
drivers/net/dsa/mt7530.c:1069:13:

Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agobpf: fix comment typo
Alexander Alemayhu [Sat, 8 Apr 2017 20:08:10 +0000 (22:08 +0200)]
bpf: fix comment typo

o s/bpf_bpf_get_socket_cookie/bpf_get_socket_cookie

Signed-off-by: Alexander Alemayhu <alexander@alemayhu.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonetvsc: use napi_consume_skb
stephen hemminger [Fri, 7 Apr 2017 18:41:19 +0000 (14:41 -0400)]
netvsc: use napi_consume_skb

This allows using deferred skb freeing and with NAPI. And get buffer
recycling.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoMerge tag 'wireless-drivers-next-for-davem-2017-04-07' of git://git.kernel.org/pub...
David S. Miller [Mon, 10 Apr 2017 01:13:12 +0000 (18:13 -0700)]
Merge tag 'wireless-drivers-next-for-davem-2017-04-07' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next

Kalle Valo says:

====================
wireless-drivers-next patches for 4.12

Lots of bugfixes as usual but also some new features.

Major changes:

ath10k

* improve firmware download time for QCA6174 and QCA9377, especially
  helps resume time

ath9k_htc

* add support AirTies 1eda:2315 AR9271 device

rt2x00

* add support MT7620

mwifiex

* enable auto deep sleep mode for USB chipsets

brcmfmac

* add support for network namespaces (WIPHY_FLAG_NETNS_OK)
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoRevert "rtnl: Add support for netdev event to link messages"
David S. Miller [Sun, 9 Apr 2017 21:45:21 +0000 (14:45 -0700)]
Revert "rtnl: Add support for netdev event to link messages"

This reverts commit def12888c161e6fec0702e5ec9c3962846e3a21d.

As per discussion between Roopa Prabhu and David Ahern, it is
advisable that we instead have the code collect the setlink triggered
events into a bitmask emitted in the IFLA_EVENT netlink attribute.

Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoMerge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next...
David S. Miller [Sun, 9 Apr 2017 20:41:06 +0000 (13:41 -0700)]
Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue

Jeff Kirsher says:

====================
40GbE Intel Wired LAN Driver Updates 2017-04-08

This series contains updates to i40e and i40evf only.

Mitch fixes an issue where the client driver (i40iw) was attempting to
load on x710 devices (which do not support iWARP), so only register with
the client if iWARP is supported.

Jake fixes up error messages to better clarify to the user when adding a
invalid flow type.  Updates the driver to look up the MAC address from
eth_get_platform_mac_address() first before checking what the firmware
provides.  Cleans up code so we are not repeating a duplicate loop, by
checking both transmit and receive queues in a single loop.  Also cleans
up flags never used, so remove the definitions.

Alex does cleanup so that we are always updating pf->flags when a change
is made to the private flags.  Adds support for 3K buffers to the receive
path so that we can provide the additional padding needed in the event
of NET_IP_ALIGN being non-zero or a cache line being greater than 64.
Adds support for build_skb() to i40e/i40evf.

Maciej adjusts the scope of the rtnl lock held during reset because it
was stopping other PFs from running their reset procedures.

Alan reduces code complexity in i40e_detect_recover_hung_queue().
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoMerge branch 'dsa-receive-path-simplifications'
David S. Miller [Sat, 8 Apr 2017 20:49:36 +0000 (13:49 -0700)]
Merge branch 'dsa-receive-path-simplifications'

Florian Fainelli says:

====================
net: dsa: Receive path simplifications

This patch series does factor the common code found in all tag implementations
into dsa_switch_rcv(). The original motivation was to add GRO support, but this
may be a lot of work with unclear benefits at this point.

Changes in v2:
- take care of tag_mtk.c in the process
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet: dsa: Factor bottom tag receive functions
Florian Fainelli [Sat, 8 Apr 2017 15:55:23 +0000 (08:55 -0700)]
net: dsa: Factor bottom tag receive functions

All DSA tag receive functions do strictly the same thing after they have located
the originating source port from their tag specific protocol:

- push ETH_HLEN bytes
- set pkt_type to PACKET_HOST
- call eth_type_trans()
- bump up counters
- call netif_receive_skb()

Factor all of that into dsa_switch_rcv(). This also makes us return a pointer to
a sk_buff, which makes us symetric with the xmit function.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet: dsa: Move skb_unshare() to dsa_switch_rcv()
Florian Fainelli [Sat, 8 Apr 2017 15:55:22 +0000 (08:55 -0700)]
net: dsa: Move skb_unshare() to dsa_switch_rcv()

All DSA tag receive functions need to unshare the skb before mangling it, move
this to the generic dsa_switch_rcv() function which will allow us to make the
tag receive function return their mangled skb without caring about freeing a
NULL skb.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet: dsa: Do not check for NULL dst in tag parsers
Florian Fainelli [Sat, 8 Apr 2017 15:55:21 +0000 (08:55 -0700)]
net: dsa: Do not check for NULL dst in tag parsers

dsa_switch_rcv() already tests for dst == NULL, so there is no need to duplicate
the same check within the tag receive functions.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoskbuff: Extend gso_type to unsigned int.
Steffen Klassert [Sat, 8 Apr 2017 18:36:24 +0000 (20:36 +0200)]
skbuff: Extend gso_type to unsigned int.

All available gso_type flags are currently in use, so
extend gso_type from 'unsigned short' to 'unsigned int'
to be able to add further flags.

We reorder the struct skb_shared_info to use
two bytes of the four byte hole before dataref.
All fields before dataref are cleared, i.e.
four bytes more than before the change.

The remaining two byte hole is moved to the
beginning of the structure, this protects us
from immediate overwites on out of bound writes
to the sk_buff head.

Structure layout on x86-64 before the change:

struct skb_shared_info {
unsigned char              nr_frags;             /*     0     1 */
__u8                       tx_flags;             /*     1     1 */
short unsigned int         gso_size;             /*     2     2 */
short unsigned int         gso_segs;             /*     4     2 */
short unsigned int         gso_type;             /*     6     2 */
struct sk_buff *           frag_list;            /*     8     8 */
struct skb_shared_hwtstamps hwtstamps;           /*    16     8 */
u32                        tskey;                /*    24     4 */
__be32                     ip6_frag_id;          /*    28     4 */
atomic_t                   dataref;              /*    32     4 */

/* XXX 4 bytes hole, try to pack */

void *                     destructor_arg;       /*    40     8 */
skb_frag_t                 frags[17];            /*    48   272 */
/* --- cacheline 5 boundary (320 bytes) --- */

/* size: 320, cachelines: 5, members: 12 */
/* sum members: 316, holes: 1, sum holes: 4 */
};

Structure layout on x86-64 after the change:

struct skb_shared_info {
short unsigned int         _unused;              /*     0     2 */
unsigned char              nr_frags;             /*     2     1 */
__u8                       tx_flags;             /*     3     1 */
short unsigned int         gso_size;             /*     4     2 */
short unsigned int         gso_segs;             /*     6     2 */
struct sk_buff *           frag_list;            /*     8     8 */
struct skb_shared_hwtstamps hwtstamps;           /*    16     8 */
unsigned int               gso_type;             /*    24     4 */
u32                        tskey;                /*    28     4 */
__be32                     ip6_frag_id;          /*    32     4 */
atomic_t                   dataref;              /*    36     4 */
void *                     destructor_arg;       /*    40     8 */
skb_frag_t                 frags[17];            /*    48   272 */
/* --- cacheline 5 boundary (320 bytes) --- */

/* size: 320, cachelines: 5, members: 13 */
};

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agoliquidio: fix VF incorrectly indicating that it successfully set its VLAN
Felix Manlunas [Fri, 7 Apr 2017 02:22:22 +0000 (19:22 -0700)]
liquidio: fix VF incorrectly indicating that it successfully set its VLAN

For security reasons, NIC firmware does not allow VF to set its VLAN if PF
set it already.  Firmware allows VF to set its VLAN if PF did not set it.
After the VF instructs the firmware to set the VLAN, VF always indicates
(via return 0) that the operation is successful--even for the times when it
isn't.

Put in a mechanism for the VF's set VLAN function to receive the firmware
response code, then make that function return -EPERM if the firmware
forbids the operation.

Make that mechanism available for other functions that may, in the future,
be interested in receiving the response code from the firmware.  That
mechanism involves adding new fields to struct octnic_ctrl_pkt, so make all
users of struct octnic_ctrl_pkt initialize the struct to zero before using
it; otherwise, the mechanism might act on uninitialized garbage.

Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com>
Signed-off-by: Derek Chickles <derek.chickles@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonetvsc: Initialize all channel related state prior to opening the channel
K. Y. Srinivasan [Thu, 6 Apr 2017 21:59:21 +0000 (14:59 -0700)]
netvsc: Initialize all channel related state prior to opening the channel

Prior to opening the channel we should have all the state setup to handle
interrupts. The current code does not do that; fix the bug. This bug
can result in faults in the interrupt path.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7 years agonet: dsa: mv88e6xxx: Make SMI c22/c45 read/write functions static
Florian Fainelli [Thu, 6 Apr 2017 19:42:16 +0000 (12:42 -0700)]
net: dsa: mv88e6xxx: Make SMI c22/c45 read/write functions static

The SMI clause 22 & 45 read/write operations are local to the global2.c file,
so make them static. This eliminates the following warning:

drivers/net/dsa/mv88e6xxx/global2.c:571:5: warning: no previous prototype for 'mv88e6xxx_g2_smi_phy_read_c45' [-Wmissing-prototypes]
 int mv88e6xxx_g2_smi_phy_read_c45(struct mv88e6xxx_chip *chip, int addr,
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/dsa/mv88e6xxx/global2.c:602:5: warning: no previous prototype for 'mv88e6xxx_g2_smi_phy_read_c22' [-Wmissing-prototypes]
 int mv88e6xxx_g2_smi_phy_read_c22(struct mv88e6xxx_chip *chip, int addr,
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/dsa/mv88e6xxx/global2.c:635:5: warning: no previous prototype for 'mv88e6xxx_g2_smi_phy_write_c45' [-Wmissing-prototypes]
 int mv88e6xxx_g2_smi_phy_write_c45(struct mv88e6xxx_chip *chip, int addr,
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/dsa/mv88e6xxx/global2.c:664:5: warning: no previous prototype for 'mv88e6xxx_g2_smi_phy_write_c22' [-Wmissing-prototypes]
 int mv88e6xxx_g2_smi_phy_write_c22(struct mv88e6xxx_chip *chip, int addr,
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>