openwrt/staging/blogic.git
6 years agomt76: add an intermediate struct for rx status information
Felix Fietkau [Wed, 24 Jan 2018 15:19:12 +0000 (16:19 +0100)]
mt76: add an intermediate struct for rx status information

Preparation for passing in more internal rx data via skb->cb

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agomt76: fix TSF value in probe responses
Felix Fietkau [Wed, 24 Jan 2018 15:19:11 +0000 (16:19 +0100)]
mt76: fix TSF value in probe responses

Like beacons, probe responses need a hardware-generated TSF value. Set
the flag that causes the hw to generate it

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agomt76: retry rx polling as long as there is budget left
Felix Fietkau [Wed, 24 Jan 2018 15:19:10 +0000 (16:19 +0100)]
mt76: retry rx polling as long as there is budget left

Sending frames to mac80211 needs time, which could allow for more rx
packets to end up in the DMA ring. Retry polling until there are no more
frames left. Improves rx latency under load.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoMerge ath-next from git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
Kalle Valo [Thu, 25 Jan 2018 17:39:07 +0000 (19:39 +0200)]
Merge ath-next from git://git./linux/kernel/git/kvalo/ath.git

ath.git patches for 4.16. Major changes:

wil6210

* add PCI device id for Talyn

* support flashless device

ath9k

* improve RSSI/signal accuracy on AR9003 series

6 years agortlwifi: btcoex: Fix some static warnings from Sparse
Ping-Ke Shih [Thu, 25 Jan 2018 02:49:54 +0000 (10:49 +0800)]
rtlwifi: btcoex: Fix some static warnings from Sparse

Add 'static' or declaration to resolve the warnings, and remove two unused
functions halbtc_set_macreg() and halbtc_get_macreg() exposed when they
were made static.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agowcn36xx: release DMA memory in case of error
Ramon Fried [Tue, 23 Jan 2018 15:20:13 +0000 (17:20 +0200)]
wcn36xx: release DMA memory in case of error

wcn36xx_dxe_init() doesn't check for the return value of
wcn36xx_dxe_init_descs(), release the resources in case an error ocurred.

Signed-off-by: Ramon Fried <rfried@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoath9k: Display calibration data piers in debugfs
Wojciech Dubowik [Wed, 24 Jan 2018 08:02:19 +0000 (09:02 +0100)]
ath9k: Display calibration data piers in debugfs

Display per frequency calibration data in dump_modal
debugfs entry including reference power, voltage,
tx temperature and noise floor.

Example of chain 0 of OEM card (dump from modal_eeprom):
Chain 0
Freq  ref volt temp nf_Cal nf_Pow rx_temp
5180 -30 0 137 0 0 0
5320 -24 0 137 0 0 0
5500 -15 0 137 0 0 0
5620 -10 0 137 0 0 0
5700 -15 0 137 0 0 0
5745 -16 0 135 0 0 0
5785 -19 0 136 0 0 0
5825 -22 0 136 0 0 0

Example of a card with calibrated noise floor.
Chain 0
Freq  ref volt temp nf_Cal nf_Pow rx_temp
4890 -49 0 128 -107 -97 124
5100 -23 0 128 -101 -96 124
5180 -18 0 128 -101 -96 124
5300 -12 0 128 -102 -97 124
5500 -9 0 128 -101 -97 125
5640 -17 0 128 -101 -98 124
5785 -25 0 128 -101 -98 124
5940 -33 0 128 -106 -99 124

Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoath9k: Use calibrated noise floor value when available
Wojciech Dubowik [Wed, 24 Jan 2018 08:02:18 +0000 (09:02 +0100)]
ath9k: Use calibrated noise floor value when available

AR9003 series allows to calibrate noise floor for different frequency
bins. Once it's done it's possible to get more accurate rssi/signal
values over whole frequency band at a given temperature.
The RSSI/signal accuracy reported by calibrated RF cards improves
from 6 to up to 2dB.

This could be interesting for application which require good signal
accuracy like roaming or mesh protocols.

Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoath9k: Read noise floor calibration data from eeprom
Wojciech Dubowik [Wed, 24 Jan 2018 08:02:17 +0000 (09:02 +0100)]
ath9k: Read noise floor calibration data from eeprom

AR9003 devices can have calibrated noise floor values
which can be used instead of hard coded one. Read them
from eeprom and save interpolated value in nf limits for
the current channel.

Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoath9k: Alternative EEPROM size for AR9003
Wojciech Dubowik [Wed, 24 Jan 2018 08:02:16 +0000 (09:02 +0100)]
ath9k: Alternative EEPROM size for AR9003

AR9003 factory calibration allows to use bigger EEPROM than
standard 1k without changing the default layout. Allow
probing of EEPROM at alternative address if initial check
for default fails.
The original ar9003 eeprom ops are still be used.

Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agowil6210: support parsing brd file address from fw file
Maya Erez [Sun, 21 Jan 2018 09:14:43 +0000 (11:14 +0200)]
wil6210: support parsing brd file address from fw file

In order to allow using the same brd file across different
11ad chips, the address for loading the brd file should be
part of the FW file, instead of the brd file. The brd file is
expected to include only one section.
To allow backward compatibility the driver reads the
address from the brd file in case it is not included in the
FW file.

Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agowil6210: enlarge FW mac_rgf_ext section for Sparrow D0
Lior David [Sun, 21 Jan 2018 09:14:42 +0000 (11:14 +0200)]
wil6210: enlarge FW mac_rgf_ext section for Sparrow D0

Sparrow D0 chips have slightly larger mac_rgf_ext section
in order to support extra features such as multiple virtual
interfaces.

Signed-off-by: Lior David <liord@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agowil6210: fix random failure to bring network interface up
Lior David [Sun, 21 Jan 2018 09:14:41 +0000 (11:14 +0200)]
wil6210: fix random failure to bring network interface up

Currently when we want to bring the interface up, we first
reset the device which causes the boot loader to run. Then
we halt the device CPU, load FW image and resume the device
CPU.
There are some boot loader versions which perform redundant
memory accesses even when idle. Halting the device CPU
while boot loader access memory can cause the device memory
controller to get stuck, the FW will fail to load and the
network interface will not come up.
For such boot loaders implement a workaround where we freeze
the boot loader before halting the device CPU, so it will not
perform any memory accesses.

Signed-off-by: Lior David <liord@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agowil6210: configure OTP HW vectors in SW reset flow
Maya Erez [Sun, 21 Jan 2018 09:14:40 +0000 (11:14 +0200)]
wil6210: configure OTP HW vectors in SW reset flow

OTP HW vectors values are different for 40MHz and 330MHz AHB
clocks.
In SW reset flow, the host driver sets the clock frequency
to 40MHz. In order to allow reading from the OTP, the host
driver should configure the OTP HW vectors with the values
that fits this clock frequency.

Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agowil6210: support flashless device
Dedy Lansky [Sun, 21 Jan 2018 09:14:39 +0000 (11:14 +0200)]
wil6210: support flashless device

Talyn device supports boot without flash.
Driver detects flashless device and in this case waits for ready indication
from HW machine (instead of bootloader ready indication). Also in this
case, MAC address is retrieved from OTP.

Signed-off-by: Dedy Lansky <dlansky@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agowil6210: add support for Talyn AHB address map
Maya Erez [Sun, 21 Jan 2018 09:14:38 +0000 (11:14 +0200)]
wil6210: add support for Talyn AHB address map

Talyn memory has changed, areas were increased and shifted
to new locations.
Use the appropriate address map according to the device JTAG ID.

Signed-off-by: Dedy Lansky <dlansky@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agowil6210: recognize Talyn JTAG ID
Maya Erez [Sun, 21 Jan 2018 09:14:37 +0000 (11:14 +0200)]
wil6210: recognize Talyn JTAG ID

Add Talyn JTAG ID to the list of valid IDs
and identify this device as Talyn.

Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agowil6210: add Talyn PCIe device ID
Maya Erez [Sun, 21 Jan 2018 09:14:36 +0000 (11:14 +0200)]
wil6210: add Talyn PCIe device ID

PCIe device ID has changed in Talyn.
Add this ID to wil6210_pcie_ids list to allow
recognition of Talyn device.

Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoath9k: discard undersized packets
Felix Fietkau [Mon, 22 Jan 2018 06:00:16 +0000 (08:00 +0200)]
ath9k: discard undersized packets

Sometimes the hardware will push small packets that trigger a WARN_ON
in mac80211. Discard them early to avoid this issue.

Reported-by: Stijn Tintel <stijn@linux-ipv6.be>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agobrcmfmac: separate firmware errors from i/o errors
Arend Van Spriel [Mon, 22 Jan 2018 20:46:40 +0000 (21:46 +0100)]
brcmfmac: separate firmware errors from i/o errors

When using the firmware api it can fail simply because firmware does
not like the request or it fails due to issues in the host interface.
Currently, there is only a single error code which is confusing. So
adding a parameter to pass the firmware error separately and in case
of a firmware error always return -EBADE to user-space.

Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
Reviewed-by: Franky Lin <franky.lin@broadcom.com>
Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agobrcmfmac: assure bcdc dcmd api does not return value > 0
Arend Van Spriel [Mon, 22 Jan 2018 20:46:39 +0000 (21:46 +0100)]
brcmfmac: assure bcdc dcmd api does not return value > 0

The protocol layer api defines callbacks for dongle commands.
Although not really well documented these should only return an
error code in case of an error, or 0 upon success. In the bcdc
protocol it can return value above 0 and we carry a fix in the
caller of the protocol layer api. This patch makes it adhere to
the intent of the api as described above.

Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
Reviewed-by: Franky Lin <franky.lin@broadcom.com>
Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoqtnfmac: remove redundant 'unlikely' checks
Sergey Matyukevich [Mon, 22 Jan 2018 12:46:34 +0000 (15:46 +0300)]
qtnfmac: remove redundant 'unlikely' checks

Signed-off-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoqtnfmac: do not use bus mutex for events processing
Igor Mitsyanko [Mon, 22 Jan 2018 12:46:33 +0000 (15:46 +0300)]
qtnfmac: do not use bus mutex for events processing

Events processing requires locking of bus mutex, which is also used by
cfg80211 layer before calling several of cfg80211 callbacks. Since all
cfg80211 callbacks in qtnfmac driver also lock bus mutex, this
potentially may lead to a deadlock.

Do not use bus lock for event processing. Use RTNL lock instead to
serialize events and commands processing threads.

Signed-off-by: Igor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoqtnfmac: do not use mutexes in timer context
Igor Mitsyanko [Mon, 22 Jan 2018 12:46:32 +0000 (15:46 +0300)]
qtnfmac: do not use mutexes in timer context

The function qtnf_scan_done makes use of mutexes which is wrong
since it may be called from timer context. Move scan timeout
handler from timer to deferred work.

Signed-off-by: Igor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoqtnfmac: fix STA disconnect procedure
Sergey Matyukevich [Mon, 22 Jan 2018 12:46:31 +0000 (15:46 +0300)]
qtnfmac: fix STA disconnect procedure

STA does not reconnect to the same AP after disconnect. The reason is
that STA is marked as disconnected in cfg80211 disconnect callback.
This is too early since in this case qtnfmac event handler skips
cfg80211_disconnected call when processing disconnect event from
the card. As a result, wdev is left in an inconsistent state.

Signed-off-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoqtnfmac: validate interface combinations on changes
Sergey Matyukevich [Mon, 22 Jan 2018 12:46:30 +0000 (15:46 +0300)]
qtnfmac: validate interface combinations on changes

Validate new interface combinations using wireless core checks when new
interface is added or when the type of existing interface is modified.
This is performed to make sure that new interface combination is supported
by hardware. As a result, invalid interface combinations are rejected early,
rather than passed to hardware with sometimes unpredictable results.

Signed-off-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoqtnfmac: modify supported interface combinations
Sergey Matyukevich [Mon, 22 Jan 2018 12:46:29 +0000 (15:46 +0300)]
qtnfmac: modify supported interface combinations

Update existing code handling configuration of supported interface
combinations. Current implementation is not complete since it does
not report multiple interface combinations which are incompatible
with each other. Instead current implementation packs all the
supported combinations into single entry.

In fact currently qsr10g wireless card supports the following
two distinct interface combinations:

1. STA/repeater: 1 STA and/or 1 AP
   {
     { .max = 1, .types = NL80211_IFTYPE_AP},
     { .max = 1, .types = NL80211_IFTYPE_STA},
   }

2. AP/mBSS
   {
     { .max = 8, .types = NL80211_IFTYPE_AP},
   }

The list of supported configuration is reported by firmware during
wireless card bring-up. Communication protocol between firmware
and host has been updated accordingly in order to accommodate passing
multiple interface combination entries.

Signed-off-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoqtnfmac: report hardware/firmware information via ethtool
Vasily Ulyanov [Mon, 22 Jan 2018 12:46:28 +0000 (15:46 +0300)]
qtnfmac: report hardware/firmware information via ethtool

Enable reporting of qtnfmac hardware and firmware details
using ethtool command.

Signed-off-by: Vasily Ulyanov <vulyanov@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoqtnfmac: get more hardware info from card
Vasily Ulyanov [Mon, 22 Jan 2018 12:46:27 +0000 (15:46 +0300)]
qtnfmac: get more hardware info from card

Various bits of hardware and firmware versions are useful for debug
and troubleshooting. Get more information from the wireless card.

Signed-off-by: Vasily Ulyanov <vulyanov@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoqtnfmac: support 64-bit network interface stats
Vasily Ulyanov [Mon, 22 Jan 2018 12:46:26 +0000 (15:46 +0300)]
qtnfmac: support 64-bit network interface stats

On 32-bit platforms packet counters are stored in a net_device_stats struct
as unsigned long integers. As a result, after some time of network activity
an overflow takes place in network packet counters. This patch makes use of
new structs for holding interface statistics.

Signed-off-by: Vasily Ulyanov <vulyanov@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoqtnfmac: fix warnings when mBSS setup is stopped
Vasily Ulyanov [Mon, 22 Jan 2018 12:46:25 +0000 (15:46 +0300)]
qtnfmac: fix warnings when mBSS setup is stopped

Virtual interface should be deleted after calling unregister_netdevice
since this function ends up with sending updown_intf command to card.

Signed-off-by: Vasily Ulyanov <vulyanov@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoqtnfmac: remove struct qlink_cmd_set_mac_acl
Vasily Ulyanov [Mon, 22 Jan 2018 12:46:24 +0000 (15:46 +0300)]
qtnfmac: remove struct qlink_cmd_set_mac_acl

TLV is used to pass ACL data to firmware in start_ap cfg80211 callback.
Use the same approach in set_mac_acl cfg80211 callback.

Signed-off-by: Vasily Ulyanov <vulyanov@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agortl8xxxu: Fix trailing semicolon
Luis de Bethencourt [Wed, 17 Jan 2018 10:56:22 +0000 (10:56 +0000)]
rtl8xxxu: Fix trailing semicolon

The trailing semicolon is an empty statement that does no operation.
Removing it since it doesn't do anything.

Signed-off-by: Luis de Bethencourt <luisbg@kernel.org>
Acked-by: Jes Sorensen <Jes.Sorensen@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agortlwifi: Add spec_ver to check whether use new rate-id or not
Ping-Ke Shih [Fri, 19 Jan 2018 06:45:51 +0000 (14:45 +0800)]
rtlwifi: Add spec_ver to check whether use new rate-id or not

The field spec_ver is IC's specification mask for common code to do proper
process to specified IC. This commit add a field new rate ID for new
generation IC.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agortlwifi: Add ratr_table for newer IC
Ping-Ke Shih [Fri, 19 Jan 2018 06:45:50 +0000 (14:45 +0800)]
rtlwifi: Add ratr_table for newer IC

New generation ICs will support 11ac, 5G, n-NSS, etc, so we define a set of
rate ID.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agortlwifi: 8822be has to report vht capability to mac80211
Ping-Ke Shih [Fri, 19 Jan 2018 06:45:49 +0000 (14:45 +0800)]
rtlwifi: 8822be has to report vht capability to mac80211

8822be is 2x2 11ac wifi chip, so report VHT capability to mac80211.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agortlwifi: btcoex: add boolean variables dbg_mode
Ping-Ke Shih [Fri, 19 Jan 2018 06:45:47 +0000 (14:45 +0800)]
rtlwifi: btcoex: add boolean variables dbg_mode

In files halbtc8822b1ant.c and halbtc8822b2ant.c that I will submit later,
two undesired directives named BT_8822B_1ANT_COEX_DBG and
BT_8822B_2ANT_COEX_DBG will be replaced by boolean variables.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agortlwifi: btcoex: Add wifi_only series ops to control solo card
Ping-Ke Shih [Fri, 19 Jan 2018 06:45:46 +0000 (14:45 +0800)]
rtlwifi: btcoex: Add wifi_only series ops to control solo card

Originally, btcoex controls the antenna of combo card, but solo card
is also needed to setup properly. The new ops are named with suffix
'_wifi_only' opposited to original btc_ops, and new structures and
definitions are also introduced. The wifi_only oly contains four ops that
are initial variable, hw config, scan notify, and switch band notify.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agortlwifi: btcoex: add scan_notify within ips_notify if RFON
Ping-Ke Shih [Fri, 19 Jan 2018 06:45:45 +0000 (14:45 +0800)]
rtlwifi: btcoex: add scan_notify within ips_notify if RFON

Three steps of connection procedure are scan, enter/leave IPS, auth.
There is no scan between leaving IPS and sending auth, but btcoex use scan
as an important clue that indicates user is going to connect. So add scan
notifications in ips_notify to correct btcoex's state.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agortlwifi: btcoex: Add variable ant_div_cfg to support antenna diversity
Ping-Ke Shih [Fri, 19 Jan 2018 06:45:44 +0000 (14:45 +0800)]
rtlwifi: btcoex: Add variable ant_div_cfg to support antenna diversity

The variable will be used by btcoex of 8822be, so we prepare this variable
in advance.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agortlwifi: btcoex: Add switch band notify for btc
Ping-Ke Shih [Fri, 19 Jan 2018 06:45:43 +0000 (14:45 +0800)]
rtlwifi: btcoex: Add switch band notify for btc

BT shares 2.4G band but not 5G band, so inform current band to btcoex to
setup antenna properly.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agortlwifi: btcoex: extend get_wifi_bw to support bandwidth 80M
Ping-Ke Shih [Fri, 19 Jan 2018 06:45:42 +0000 (14:45 +0800)]
rtlwifi: btcoex: extend get_wifi_bw to support bandwidth 80M

The rtlwifi newer ICs support 80M bandwidth in 5G band, so extend
get_wifi_bw() to know bandwidth 80M that helps btcoex to make correct
decisions.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agomt76x2: init: disable all pending tasklets during device removal
Lorenzo Bianconi [Tue, 23 Jan 2018 09:03:24 +0000 (10:03 +0100)]
mt76x2: init: disable all pending tasklets during device removal

There is a possible race in mt76x2_stop_hardware() since pre_tbtt and
dfs tasklets could run during driver cleanup. Fix it disabling all
pending tasklets during device removal

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Acked-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agomt76x2: dfs: take into account dfs region in mt76x2_dfs_init_params()
Lorenzo Bianconi [Tue, 9 Jan 2018 13:13:12 +0000 (14:13 +0100)]
mt76x2: dfs: take into account dfs region in mt76x2_dfs_init_params()

Do not enable DFS state machine if dfs region is set to NL80211_DFS_UNSET

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agomt76x2: dfs: add set_domain handler
Lorenzo Bianconi [Tue, 9 Jan 2018 13:13:11 +0000 (14:13 +0100)]
mt76x2: dfs: add set_domain handler

Add mt76x2_dfs_set_domain routine in order to properly reconfigure
pattern detector when DFS domain has been changed

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agomt76x2: dfs: avoid tasklet scheduling during mt76x2_dfs_init_params()
Lorenzo Bianconi [Tue, 9 Jan 2018 13:13:10 +0000 (14:13 +0100)]
mt76x2: dfs: avoid tasklet scheduling during mt76x2_dfs_init_params()

Substitute tasklet_kill with tasklet_disable/tasklet_enable in order to
guarantee dfs tasklet can not be executed during dfs parameter
initialization

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agomt76: fix transmission of encrypted management frames
Felix Fietkau [Thu, 18 Jan 2018 18:01:43 +0000 (19:01 +0100)]
mt76: fix transmission of encrypted management frames

Hardware encryption seems to break encrypted unicast mgmt tx.
Unfortunately the hardware TXWI header does not have a bit to indicate
that a frame is software encrypted, so sw-encrypted frames need to use a
different WCID. For that to work, the CCMP PN needs to be generated in
software, which makes things a bit slower, so only do it for keys that
also need to tx management frames.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agomt76x2: fix WMM parameter configuration
Lorenzo Bianconi [Wed, 17 Jan 2018 11:01:27 +0000 (12:01 +0100)]
mt76x2: fix WMM parameter configuration

Fix hw queue configuration since mt76x2 devices use a reverse queue
enumeration respect to mac80211 one:
 - 0: AC_BE
 - 1: AC_BK
 - 2: AC_VI
 - 3: AC_VO

The issue can be reproduced sending two concurrent flow using
two separate queues:
 - VO: 20Mbps UDP traffic
 - BE: TCP traffic

In this scenario the UDP traffic will be blocked by the TCP one.
Fix it configuring properly WMM hw queue parameters

Fixes: 7bc04215a66b ("mt76: add driver code for MT76x2e")
Tested-by: Gaetano Catalli <gaetano.catalli@gmail.com>
Signed-off-by: Gaetano Catalli <gaetano.catalli@gmail.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Acked-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoMerge branch 'mlxsw-Add-support-for-mirror-action-with-flower'
David S. Miller [Sun, 21 Jan 2018 23:21:31 +0000 (18:21 -0500)]
Merge branch 'mlxsw-Add-support-for-mirror-action-with-flower'

Jiri Pirko says:

====================
mlxsw: Add support for mirror action with flower

Arkadi says:

Add support for mirror action with flower classifier. The first 3 patches
introduce a generic per-block resource infra. The last 4 patches add
support for flow based span.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agomlxsw: spectrum_acl: Add support for mirror action
Arkadi Sharshevsky [Fri, 19 Jan 2018 08:24:52 +0000 (09:24 +0100)]
mlxsw: spectrum_acl: Add support for mirror action

Add support for mirror action. Only one mirror action can be set per rule.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agomlxsw: spectrum: Extend mlxsw_afa_ops for counter index and implement for Spectrum
Arkadi Sharshevsky [Fri, 19 Jan 2018 08:24:51 +0000 (09:24 +0100)]
mlxsw: spectrum: Extend mlxsw_afa_ops for counter index and implement for Spectrum

Introduce extension of mlxsw_afa_ops in order to add/del mirroring and
implement the ops for Spectrum.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agomlxsw: spectrum: Extend and export SPAN API
Arkadi Sharshevsky [Fri, 19 Jan 2018 08:24:50 +0000 (09:24 +0100)]
mlxsw: spectrum: Extend and export SPAN API

Extend SPAN API for ACL case. In case of ACL triggering the MPAR register
shouldn't be configured. This patch also export those helpers for
ACL usage.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agomlxsw: spectrum_acl: Add support for mirroring action
Arkadi Sharshevsky [Fri, 19 Jan 2018 08:24:49 +0000 (09:24 +0100)]
mlxsw: spectrum_acl: Add support for mirroring action

The patch extends the trap action for mirroring.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agomlxsw: core: Make counter index allocated inside the action append
Jiri Pirko [Fri, 19 Jan 2018 08:24:48 +0000 (09:24 +0100)]
mlxsw: core: Make counter index allocated inside the action append

So far, the caller of mlxsw_afa_block_append_counter needed to allocate
counter index by hand. Benefit from the previously introduced resource
infra and counter_index_get/put callbacks, and allocate the counter
index in place where it is needed, inside the action append function.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agomlxsw: core: Convert fwd_entry_ref list to be generic per-block resource list
Jiri Pirko [Fri, 19 Jan 2018 08:24:47 +0000 (09:24 +0100)]
mlxsw: core: Convert fwd_entry_ref list to be generic per-block resource list

Since the resource list needs to be used also for other entries different
to fwd_entry_ref, make the list generic. For that purpose, introduce a
resource structure with couple of helpers that the code which need to
store a per-block resource should use.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agomlxsw: spectrum: Extend mlxsw_afa_ops for counter index and implement for Spectrum
Jiri Pirko [Fri, 19 Jan 2018 08:24:46 +0000 (09:24 +0100)]
mlxsw: spectrum: Extend mlxsw_afa_ops for counter index and implement for Spectrum

Introduce extension of mlxsw_afa_ops in order to get/put counter indexes
and implement the ops for Spectrum.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agoMerge branch 'Aquantia-atlantic-driver-new-devices-support'
David S. Miller [Sun, 21 Jan 2018 23:19:04 +0000 (18:19 -0500)]
Merge branch 'Aquantia-atlantic-driver-new-devices-support'

Igor Russkikh says:

====================
Aquantia atlantic driver new devices support

This patchset introduces a support for new Aquantia hardware:
AQC11x family with updated hardware (B1) and firmware (2.x and 3.x branches).

For that, a number of improvements in overall driver model were done:
 - Firmware specific ops tables. Firmware 2.x and 3.x series support
   functions are now in separate fw2x module.
 - PCI module cleanup and simplification done.
 - Verified and tested hardware reset process.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: aquantia: bump driver version to match aquantia internal numbering
Igor Russkikh [Fri, 19 Jan 2018 14:03:28 +0000 (17:03 +0300)]
net: aquantia: bump driver version to match aquantia internal numbering

Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: aquantia: Report correct mediatype via ethtool
Igor Russkikh [Fri, 19 Jan 2018 14:03:27 +0000 (17:03 +0300)]
net: aquantia: Report correct mediatype via ethtool

For devices with known capabilities of Fibre media type we now report that
to ethtool.

Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: aquantia: Introduce global AQC hardware reset sequence
Igor Russkikh [Fri, 19 Jan 2018 14:03:26 +0000 (17:03 +0300)]
net: aquantia: Introduce global AQC hardware reset sequence

The detailed reset sequence ensures all HW components are in aligned
state before NIC startup. It also supports cards with signed firmware (RBL)
and checks if their FW is valid.

Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: aquantia: Introduce support for new firmware on AQC cards
Igor Russkikh [Fri, 19 Jan 2018 14:03:25 +0000 (17:03 +0300)]
net: aquantia: Introduce support for new firmware on AQC cards

This defines fw2x operations table and corresponding methods.
Some of the functions are being shared with 1.x firmware

Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: aquantia: Introduce firmware ops callbacks
Igor Russkikh [Fri, 19 Jan 2018 14:03:24 +0000 (17:03 +0300)]
net: aquantia: Introduce firmware ops callbacks

New AQC cards will have an updated firmware with new binary interface.
This patch extracts firmware specific operations into a separate table
and prepares for the introduction of new fw 2.x and 3.x

Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: aquantia: Change confusing no_ff_addr to more meaningful name
Igor Russkikh [Fri, 19 Jan 2018 14:03:23 +0000 (17:03 +0300)]
net: aquantia: Change confusing no_ff_addr to more meaningful name

The address to check if HW is not dead/hang could be stored in
capabilities, since it is a constant. Change its name to better reflect
the idea.

Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: aquantia: Remove create/destroy from hw ops
Igor Russkikh [Fri, 19 Jan 2018 14:03:22 +0000 (17:03 +0300)]
net: aquantia: Remove create/destroy from hw ops

These ops are not related to HW and are now implemented in pci module.
Thus, remove these ops pointers and implementation.

Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: aquantia: Cleanup pci functions module
Igor Russkikh [Fri, 19 Jan 2018 14:03:21 +0000 (17:03 +0300)]
net: aquantia: Cleanup pci functions module

Driver contained a dead code of maintaining multiple pci port instances.
That will never be used since for each pci function a separate NIC
instance is created.
Simplify this, making pci module only responsible for pci resource
management.
NIC initialization is also simplified accordingly.

Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: aquantia: Convert hw and caps structures to const static pointers
Igor Russkikh [Fri, 19 Jan 2018 14:03:20 +0000 (17:03 +0300)]
net: aquantia: Convert hw and caps structures to const static pointers

This removes unnecessary structure copying, and prepares the driver for
separate firmware ops table introduction.

We also remove extra copy of capabilities structure (which is const actually)
and also replace it with a const pointer in aq_nic_cfg.

Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: aquantia: Introduce new AQC devices and capabilities
Igor Russkikh [Fri, 19 Jan 2018 14:03:19 +0000 (17:03 +0300)]
net: aquantia: Introduce new AQC devices and capabilities

A number of new AQC devices is going to be released. To support more
flexible capabilities management a number of static caps instances is now
declared. Devices now are mainly differs by supported speeds, but in future
more parameters will be customized. A set of AQC100 devices have
fibre media, not twisted pair - this is also reflected in
new capabilities definitions.

HW level also now directly exports hw_ops for each of A0/B0 hardware.

PCI configuration now uses a device configuration table where each
device ID is explicitly mapped with hardware OPs and capabilities
structures.

Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: aquantia: Introduce new device ids and constants
Igor Russkikh [Fri, 19 Jan 2018 14:03:18 +0000 (17:03 +0300)]
net: aquantia: Introduce new device ids and constants

New set of aquantia devices has an upgraded hardware (B1).
The hardware interface is identical to B0. The difference will
be in firmware which is incompatible with old one.

Reorganized and removed duplicate speed and devid definitions
Introduced explicit flow control configuration defines

Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agoMerge tag 'mlx5-updates-2018-01-19' of git://git.kernel.org/pub/scm/linux/kernel...
David S. Miller [Sun, 21 Jan 2018 23:13:23 +0000 (18:13 -0500)]
Merge tag 'mlx5-updates-2018-01-19' of git://git./linux/kernel/git/saeed/linux

Saeed Mahameed says:

====================
mlx5-updates-2018-01-19

From: Or Gerlitz <ogerlitz@mellanox.com>
=======
First six patches of this series further enhances the mlx5 hairpin support.
The first two patches deal with using different hairpin instances
for flows whose packets have different priorities to align with the port
TX QoS model. The next four patches allow us to do HW spreading
of flows over a set of hairpin pairs using RSS. The last two patches
change the driver to also set the size of the HW hairpin queues.
========

Next four patches from Eran Ben Elisha <eranbe@mellanox.com>:
Add more debug data for TX timeout handling, and further enhance and optimize
TX timeout handling upon lost interrupts, which adds a mechanism for explicitly
polling EQ in case of a TX timeout in order to recover from a lost interrupt.
If this is not the case (no pending EQEs), perform a channels full recovery as
usual.

From Kamal Heib <kamalh@mellanox.com>, Two patches to extend the stats group API
to have an update_stats() callback which will be used to fetch the hardware or
software counters data, this will improve the current API and reduce code
duplication.

From Gal Pressman <galp@mellanox.com>, Last patch, Add likely to the common RX checksum
flow.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonfp: flower: prioritize stats updates
Pieter Jansen van Vuuren [Sat, 20 Jan 2018 01:54:08 +0000 (17:54 -0800)]
nfp: flower: prioritize stats updates

Previously it was possible to interrupt processing stats updates because
they were handled in a work queue. Interrupting the stats updates could
lead to a situation where we backup the control message queue. This patch
moves the stats update processing out of the work queue to be processed as
soon as hardware sends a request.

Reported-by: Louis Peens <louis.peens@netronome.com>
Signed-off-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: gemini: Depend on HAS_IOMEM
Linus Walleij [Sun, 21 Jan 2018 13:15:41 +0000 (14:15 +0100)]
net: gemini: Depend on HAS_IOMEM

The zeroday builder notices that since Usermode Linux does not
have IO memory, the build fails for them when selecting everything
it can enable.

As the driver is clearly using memory-mapped registers to access
the network adapter, we add depends on HAS_IOMEM to solve this
problem.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agoMerge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
David S. Miller [Sun, 21 Jan 2018 16:35:34 +0000 (11:35 -0500)]
Merge git://git./linux/kernel/git/pablo/nf-next

Pablo Neira Ayuso says:

====================
Netfilter/IPVS updates for net-next

The following patchset contains Netfilter/IPVS updates for your net-next
tree. Basically, a new extension for ip6tables, simplification work of
nf_tables that saves us 500 LoC, allow raw table registration before
defragmentation, conversion of the SNMP helper to use the ASN.1 code
generator, unique 64-bit handle for all nf_tables objects and fixes to
address fallout from previous nf-next batch.  More specifically, they
are:

1) Seven patches to remove family abstraction layer (struct nft_af_info)
   in nf_tables, this simplifies our codebase and it saves us 64 bytes per
   net namespace.

2) Add IPv6 segment routing header matching for ip6tables, from Ahmed
   Abdelsalam.

3) Allow to register iptable_raw table before defragmentation, some
   people do not want to waste cycles on defragmenting traffic that is
   going to be dropped, hence add a new module parameter to enable this
   behaviour in iptables and ip6tables. From Subash Abhinov
   Kasiviswanathan. This patch needed a couple of follow up patches to
   get things tidy from Arnd Bergmann.

4) SNMP helper uses the ASN.1 code generator, from Taehee Yoo. Several
   patches for this helper to prepare this change are also part of this
   patch series.

5) Add 64-bit handles to uniquely objects in nf_tables, from Harsha
   Sharma.

6) Remove log message that several netfilter subsystems print at
   boot/load time.

7) Restore x_tables module autoloading, that got broken in a previous
   patch to allow singleton NAT hook callback registration per hook
   spot, from Florian Westphal. Moreover, return EBUSY to report that
   the singleton NAT hook slot is already in instead.

8) Several fixes for the new nf_tables flowtable representation,
   including incorrect error check after nf_tables_flowtable_lookup(),
   missing Kconfig dependencies that lead to build breakage and missing
   initialization of priority and hooknum in flowtable object.

9) Missing NETFILTER_FAMILY_ARP dependency in Kconfig for the clusterip
   target. This is due to recent updates in the core to shrink the hook
   array size and compile it out if no specific family is enabled via
   .config file. Patch from Florian Westphal.

10) Remove duplicated include header files, from Wei Yongjun.

11) Sparse warning fix for the NFPROTO_INET handling from the core
    due to missing static function definition, also from Wei Yongjun.

12) Restore ICMPv6 Parameter Problem error reporting when
    defragmentation fails, from Subash Abhinov Kasiviswanathan.

13) Remove obsolete owner field initialization from struct
    file_operations, patch from Alexey Dobriyan.

14) Use boolean datatype where needed in the Netfilter codebase, from
    Gustavo A. R. Silva.

15) Remove double semicolon in dynset nf_tables expression, from
    Luis de Bethencourt.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agoMerge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
David S. Miller [Sun, 21 Jan 2018 03:03:46 +0000 (22:03 -0500)]
Merge git://git./linux/kernel/git/bpf/bpf-next

Alexei Starovoitov says:

====================
pull-request: bpf-next 2018-01-19

The following pull-request contains BPF updates for your *net-next* tree.

The main changes are:

1) bpf array map HW offload, from Jakub.

2) support for bpf_get_next_key() for LPM map, from Yonghong.

3) test_verifier now runs loaded programs, from Alexei.

4) xdp cpumap monitoring, from Jesper.

5) variety of tests, cleanups and small x64 JIT optimization, from Daniel.

6) user space can now retrieve HW JITed program, from Jiong.

Note there is a minor conflict between Russell's arm32 JIT fixes
and removal of bpf_jit_enable variable by Daniel which should
be resolved by keeping Russell's comment and removing that variable.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agoMerge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
David S. Miller [Sat, 20 Jan 2018 03:59:33 +0000 (22:59 -0500)]
Merge git://git./linux/kernel/git/davem/net

The BPF verifier conflict was some minor contextual issue.

The TUN conflict was less trivial.  Cong Wang fixed a memory leak of
tfile->tx_array in 'net'.  This is an skb_array.  But meanwhile in
net-next tun changed tfile->tx_arry into tfile->tx_ring which is a
ptr_ring.

Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agoMerge branch 'bpf-misc-improvements'
Alexei Starovoitov [Sat, 20 Jan 2018 02:37:01 +0000 (18:37 -0800)]
Merge branch 'bpf-misc-improvements'

Daniel Borkmann says:

====================
This series adds various misc improvements to BPF: detection
of BPF helper definition misconfiguration for mem/size argument
pairs, csum_diff helper also for XDP, various test cases,
removal of the recently added pure_initcall(), restriction
of the jit sysctls to cap_sys_admin for initns, a minor size
improvement for x86 jit in alu ops, output of complexity limit
to verifier log and last but not least having the event output
more flexible with moving to const_size_or_zero type.

Thanks!
====================

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
6 years agobpf: move event_output to const_size_or_zero for xdp/skb as well
Daniel Borkmann [Sat, 20 Jan 2018 00:24:37 +0000 (01:24 +0100)]
bpf: move event_output to const_size_or_zero for xdp/skb as well

Similar rationale as in a60dd35d2e39 ("bpf: change bpf_perf_event_output
arg5 type to ARG_CONST_SIZE_OR_ZERO"), change the type to CONST_SIZE_OR_ZERO
such that we can better deal with optimized code. No changes needed in
bpf_event_output() as it can also deal with 0 size entirely (e.g. as only
wake-up signal with empty frame in perf RB, or packet dumps w/o meta data
as another such possibility).

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
6 years agobpf: add upper complexity limit to verifier log
Daniel Borkmann [Sat, 20 Jan 2018 00:24:36 +0000 (01:24 +0100)]
bpf: add upper complexity limit to verifier log

Given the limit could potentially get further adjustments in the
future, add it to the log so it becomes obvious what the current
limit is w/o having to check the source first. This may also be
helpful for debugging complexity related issues on kernels that
backport from upstream.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
6 years agobpf, x86: small optimization in alu ops with imm
Daniel Borkmann [Sat, 20 Jan 2018 00:24:35 +0000 (01:24 +0100)]
bpf, x86: small optimization in alu ops with imm

For the BPF_REG_0 (BPF_REG_A in cBPF, respectively), we can use
the short form of the opcode as dst mapping is on eax/rax and
thus save a byte per such operation. Added to add/sub/and/or/xor
for 32/64 bit when K immediate is used. There may be more such
low-hanging fruit to add in future as well.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
6 years agobpf: restrict access to core bpf sysctls
Daniel Borkmann [Sat, 20 Jan 2018 00:24:34 +0000 (01:24 +0100)]
bpf: restrict access to core bpf sysctls

Given BPF reaches far beyond just networking these days, it was
never intended to allow setting and in some cases reading those
knobs out of a user namespace root running without CAP_SYS_ADMIN,
thus tighten such access.

Also the bpf_jit_enable = 2 debugging mode should only be allowed
if kptr_restrict is not set since it otherwise can leak addresses
to the kernel log. Dump a note to the kernel log that this is for
debugging JITs only when enabled.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
6 years agobpf: get rid of pure_initcall dependency to enable jits
Daniel Borkmann [Sat, 20 Jan 2018 00:24:33 +0000 (01:24 +0100)]
bpf: get rid of pure_initcall dependency to enable jits

Having a pure_initcall() callback just to permanently enable BPF
JITs under CONFIG_BPF_JIT_ALWAYS_ON is unnecessary and could leave
a small race window in future where JIT is still disabled on boot.
Since we know about the setting at compilation time anyway, just
initialize it properly there. Also consolidate all the individual
bpf_jit_enable variables into a single one and move them under one
location. Moreover, don't allow for setting unspecified garbage
values on them.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
6 years agobpf: add couple of test cases for div/mod by zero
Daniel Borkmann [Sat, 20 Jan 2018 00:24:32 +0000 (01:24 +0100)]
bpf: add couple of test cases for div/mod by zero

Add couple of missing test cases for eBPF div/mod by zero to the
new test_verifier prog runtime feature. Also one for an empty prog
and only exit.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
6 years agobpf: add couple of test cases for signed extended imms
Daniel Borkmann [Sat, 20 Jan 2018 00:24:31 +0000 (01:24 +0100)]
bpf: add couple of test cases for signed extended imms

Add a couple of test cases for interpreter and JIT that are
related to an issue we faced some time ago in Cilium [1],
which is fixed in LLVM with commit e53750e1e086 ("bpf: fix
bug on silently truncating 64-bit immediate").

Test cases were run-time checking kernel to behave as intended
which should also provide some guidance for current or new
JITs in case they should trip over this. Added for cBPF and
eBPF.

  [1] https://github.com/cilium/cilium/pull/2162

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
6 years agobpf: add csum_diff helper to xdp as well
Daniel Borkmann [Sat, 20 Jan 2018 00:24:30 +0000 (01:24 +0100)]
bpf: add csum_diff helper to xdp as well

Useful for porting cls_bpf programs w/o increasing program
complexity limits much at the same time, so add the helper
to XDP as well.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
6 years agobpf, verifier: detect misconfigured mem, size argument pair
Daniel Borkmann [Sat, 20 Jan 2018 00:24:29 +0000 (01:24 +0100)]
bpf, verifier: detect misconfigured mem, size argument pair

I've seen two patch proposals now for helper additions that used
ARG_PTR_TO_MEM or similar in reg_X but no corresponding ARG_CONST_SIZE
in reg_X+1. Verifier won't complain in such case, but it will omit
verifying the memory passed to the helper thus ending up badly.
Detect such buggy helper function signature and bail out during
verification rather than finding them through review.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
6 years agosamples/bpf: xdp_monitor include cpumap tracepoints in monitoring
Jesper Dangaard Brouer [Fri, 19 Jan 2018 16:15:50 +0000 (17:15 +0100)]
samples/bpf: xdp_monitor include cpumap tracepoints in monitoring

The xdp_redirect_cpu sample have some "builtin" monitoring of the
tracepoints for xdp_cpumap_*, but it is practical to have an external
tool that can monitor these transpoint as an easy way to troubleshoot
an application using XDP + cpumap.

Specifically I need such external tool when working on Suricata and
XDP cpumap redirect. Extend the xdp_monitor tool sample with
monitoring of these xdp_cpumap_* tracepoints.  Model the output format
like xdp_redirect_cpu.

Given I needed to handle per CPU decoding for cpumap, this patch also
add per CPU info on the existing monitor events.  This resembles part
of the builtin monitoring output from sample xdp_rxq_info.  Thus, also
covering part of that sample in an external monitoring tool.

Performance wise, the cpumap tracepoints uses bulking, which cause
them to have very little overhead.  Thus, they are enabled by default.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
6 years agoMerge branch 'bpf-lpm-get-next-key'
Daniel Borkmann [Fri, 19 Jan 2018 22:26:41 +0000 (23:26 +0100)]
Merge branch 'bpf-lpm-get-next-key'

Yonghong Song says:

====================
This patch set implements MAP_GET_NEXT_KEY command for LPM_TRIE map.
This command is really useful for key enumeration, and for key deletion
if what keys in the trie are unknown.

Patch #1 implements the functionality in the kernel and patch #2
adds a test case in tools/testing/selftests/bpf.
====================

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
6 years agotools/bpf: add a testcase for MAP_GET_NEXT_KEY command of LPM_TRIE map
Yonghong Song [Thu, 18 Jan 2018 23:08:51 +0000 (15:08 -0800)]
tools/bpf: add a testcase for MAP_GET_NEXT_KEY command of LPM_TRIE map

A test case is added in tools/testing/selftests/bpf/test_lpm_map.c
for MAP_GET_NEXT_KEY command. A four node trie, which
is described in kernel/bpf/lpm_trie.c, is built and the
MAP_GET_NEXT_KEY results are checked.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
6 years agobpf: implement MAP_GET_NEXT_KEY command for LPM_TRIE map
Yonghong Song [Thu, 18 Jan 2018 23:08:50 +0000 (15:08 -0800)]
bpf: implement MAP_GET_NEXT_KEY command for LPM_TRIE map

Current LPM_TRIE map type does not implement MAP_GET_NEXT_KEY
command. This command is handy when users want to enumerate
keys. Otherwise, a different map which supports key
enumeration may be required to store the keys. If the
map data is sparse and all map data are to be deleted without
closing file descriptor, using MAP_GET_NEXT_KEY to find
all keys is much faster than enumerating all key space.

This patch implements MAP_GET_NEXT_KEY command for LPM_TRIE map.
If user provided key pointer is NULL or the key does not have
an exact match in the trie, the first key will be returned.
Otherwise, the next key will be returned.

In this implemenation, key enumeration follows a postorder
traversal of internal trie. More specific keys
will be returned first than less specific ones, given
a sequence of MAP_GET_NEXT_KEY syscalls.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
6 years agoselftests: bpf: update .gitignore with missing generated files
Shuah Khan [Fri, 19 Jan 2018 00:36:24 +0000 (17:36 -0700)]
selftests: bpf: update .gitignore with missing generated files

Update .gitignore with missing generated files.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
6 years agobpftool: recognize BPF_MAP_TYPE_CPUMAP maps
Roman Gushchin [Fri, 19 Jan 2018 14:17:45 +0000 (14:17 +0000)]
bpftool: recognize BPF_MAP_TYPE_CPUMAP maps

Add BPF_MAP_TYPE_CPUMAP map type to the list
of map type recognized by bpftool and define
corresponding text representation.

Signed-off-by: Roman Gushchin <guro@fb.com>
Cc: Quentin Monnet <quentin.monnet@netronome.com>
Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Alexei Starovoitov <ast@kernel.org>
Acked-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
6 years agoMerge branch 'dsa-mv88e6xxx-ATU-VTU-irq-fixes'
David S. Miller [Fri, 19 Jan 2018 20:57:03 +0000 (15:57 -0500)]
Merge branch 'dsa-mv88e6xxx-ATU-VTU-irq-fixes'

Andrew Lunn says:

====================
ATU and VTU irq fixes

Further testing and code review found two sets of bugs.

Core review found a cut/paste error in the irq setup code.

A board which does not have an interrupt line from the switch to the
SoC, and experiancing an EPROBE_DEFER throw a splat when the ATU irq
was freed but never registered.

v2: Fix typ0 chip->chip->vtu_prob_irq to chip->vtu_prob_irq
    0-day compile testing.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: dsa: mv88e6xxx: Free ATU/VTU irq only when there is chip irq
Andrew Lunn [Thu, 18 Jan 2018 16:42:50 +0000 (17:42 +0100)]
net: dsa: mv88e6xxx: Free ATU/VTU irq only when there is chip irq

We only register the ATU and VTU irq when we have a chip level IRQ.
In the error path, we should only attempt to remove the ATU and VTU
irq if we also have a chip level IRQ.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: dsa: mv88e6xxx: Return error from irq_find_mapping()
Andrew Lunn [Thu, 18 Jan 2018 16:42:49 +0000 (17:42 +0100)]
net: dsa: mv88e6xxx: Return error from irq_find_mapping()

Fix a cut/paste error. When irq_find_mapping() returns an error for
the ATU or VTU interrupt, return that error, not the value of
chip->device_irq.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agoMerge branch 'net-sched-cls-add-extack-support'
David S. Miller [Fri, 19 Jan 2018 20:52:52 +0000 (15:52 -0500)]
Merge branch 'net-sched-cls-add-extack-support'

Alexander Aring says:

====================
net: sched: cls: add extack support

this patch adds extack support for TC classifier subsystem. The first
patch fixes some code style issues for this patch series pointed out
by checkpatch. The other patches until the last one prepares extack
handling for the TC classifier subsystem and handle generic extack
errors.

The last patch is an example for u32 classifier to add extack support
inside the callbacks delete and change. There exists a init callback as
well, but most classifier implementation run a kalloc() once to allocate
something. Not necessary _yet_ to add extack support now.

- Alex

Cc: David Ahern <dsahern@gmail.com>
changes since v3:
 - fix accidentally move of config option mismatch message in PATCH 2/8
   correct one is 4/8, detected by kbuildbot (Thank you)
 - Removed patch "net: sched: cls: add extack support for tc_setup_cb_call"
   PATCH 7/8 in version v2 as suggested by Jakub Kicinski (Thank you)
 - changed NL_SET_ERR_MSG to NL_SET_ERR_MSG_MOD as suggested by Jakub Kicinski
   in u32 cls (Thank You)
 - Removed text from cover letter that I was waiting for Jiri's Patches as
   detected by Jamal Hadi Salim (Thank you).

changes since v2:
 - rebased on Jiri's patches (Thank you)
 - several spelling fixes pointed out by Cong Wang (Thank you)
 - several spelling fixes pointed out by David Ahern (Thank you)
 - use David Ahern recommendation if config option is mismatch, but
   combine it with Cong Wang recommendation to put config name into it
   (Thank you)
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: sched: cls_u32: add extack support
Alexander Aring [Thu, 18 Jan 2018 16:20:55 +0000 (11:20 -0500)]
net: sched: cls_u32: add extack support

This patch adds extack support for the u32 classifier as example for
delete and init callback.

Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: Alexander Aring <aring@mojatatu.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: sched: cls: add extack support for tcf_change_indev
Alexander Aring [Thu, 18 Jan 2018 16:20:54 +0000 (11:20 -0500)]
net: sched: cls: add extack support for tcf_change_indev

This patch adds extack handling for the tcf_change_indev function which
is common used by TC classifier implementations.

Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: Alexander Aring <aring@mojatatu.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: sched: cls: add extack support for delete callback
Alexander Aring [Thu, 18 Jan 2018 16:20:53 +0000 (11:20 -0500)]
net: sched: cls: add extack support for delete callback

This patch adds extack support for classifier delete callback api. This
prepares to handle extack support inside each specific classifier
implementation.

Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: Alexander Aring <aring@mojatatu.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: sched: cls: add extack support for tcf_exts_validate
Alexander Aring [Thu, 18 Jan 2018 16:20:52 +0000 (11:20 -0500)]
net: sched: cls: add extack support for tcf_exts_validate

The tcf_exts_validate function calls the act api change callback. For
preparing extack support for act api, this patch adds the extack as
parameter for this function which is common used in cls implementations.

Furthermore the tcf_exts_validate will call action init callback which
prepares the TC action subsystem for extack support.

Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: Alexander Aring <aring@mojatatu.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: sched: cls: add extack support for change callback
Alexander Aring [Thu, 18 Jan 2018 16:20:51 +0000 (11:20 -0500)]
net: sched: cls: add extack support for change callback

This patch adds extack support for classifier change callback api. This
prepares to handle extack support inside each specific classifier
implementation.

Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: Alexander Aring <aring@mojatatu.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 years agonet: sched: cls_api: handle generic cls errors
Alexander Aring [Thu, 18 Jan 2018 16:20:50 +0000 (11:20 -0500)]
net: sched: cls_api: handle generic cls errors

This patch adds extack support for generic cls handling. The extack
will be set deeper to each called function which is not part of netdev
core api.

Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: Alexander Aring <aring@mojatatu.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>