platform/kernel/linux-rpi.git
4 years agoBluetooth: serdev: Constify serdev_device_ops
Rikard Falkeborn [Sat, 9 May 2020 13:17:19 +0000 (15:17 +0200)]
Bluetooth: serdev: Constify serdev_device_ops

serdev_device_ops is not modified and can be const. Also, remove the
unneeded declaration of it.

Output from the file command before and after:

Before:
   text    data     bss     dec     hex filename
   7192    2408     192    9792    2640 drivers/bluetooth/hci_serdev.o

After:
   text    data     bss     dec     hex filename
   7256    2344     192    9792    2640 drivers/bluetooth/hci_serdev.o

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: btusb: Add support for Intel Bluetooth Device Typhoon Peak (8087:0032)
Raghuram Hegde [Mon, 11 May 2020 11:10:40 +0000 (16:40 +0530)]
Bluetooth: btusb: Add support for Intel Bluetooth Device Typhoon Peak (8087:0032)

Device from /sys/kernel/debug/usb/devices:

T:  Bus=01 Lev=01 Prnt=01 Port=13 Cnt=02 Dev#=  3 Spd=12   MxCh= 0
D:  Ver= 2.01 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=8087 ProdID=0032 Rev= 0.00
C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=81(I) Atr=03(Int.) MxPS=  64 Ivl=1ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
I:  If#= 1 Alt= 6 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=03(O) Atr=01(Isoc) MxPS=  63 Ivl=1ms
E:  Ad=83(I) Atr=01(Isoc) MxPS=  63 Ivl=1ms

Signed-off-by: Raghuram Hegde <raghuram.hegde@intel.com>
Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
Signed-off-by: Amit K Bag <amit.k.bag@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: btusb: Implement hdev->prevent_wake
Abhishek Pandit-Subedi [Wed, 13 May 2020 02:19:27 +0000 (19:19 -0700)]
Bluetooth: btusb: Implement hdev->prevent_wake

Implement the prevent_wake hook by checking device_may_wakeup on the usb
interface. This prevents the Bluetooth core from enabling scanning when
the device isn't expected to wake from suspend.

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Alain Michaud <alainm@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: Add hook for driver to prevent wake from suspend
Abhishek Pandit-Subedi [Wed, 13 May 2020 02:19:26 +0000 (19:19 -0700)]
Bluetooth: Add hook for driver to prevent wake from suspend

Let drivers have a hook to disable configuring scanning during suspend.
Drivers should use the device_may_wakeup function call to determine
whether hci should be configured for wakeup.

For example, an implementation for btusb may look like the following:

  bool btusb_prevent_wake(struct hci_dev *hdev)
  {
        struct btusb_data *data = hci_get_drvdata(hdev);
        return !device_may_wakeup(&data->udev->dev);
  }

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Alain Michaud <alainm@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: Rename BT_SUSPEND_COMPLETE
Abhishek Pandit-Subedi [Wed, 13 May 2020 02:19:25 +0000 (19:19 -0700)]
Bluetooth: Rename BT_SUSPEND_COMPLETE

Renamed BT_SUSPEND_COMPLETE to BT_SUSPEND_CONFIGURE_WAKE since it sets
up the event filter and whitelist for wake-up.

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Alain Michaud <alainm@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: Modify LE window and interval for suspend
Abhishek Pandit-Subedi [Wed, 13 May 2020 02:09:33 +0000 (19:09 -0700)]
Bluetooth: Modify LE window and interval for suspend

When a device is suspended, it doesn't need to be as responsive to
connection events. Increase the interval to 640ms (creating a duty cycle
of roughly 1.75%) so that passive scanning uses much less power (vs
previous duty cycle of 18.75%). The new window + interval combination
has been tested to work with HID devices (which are currently the only
devices capable of wake up).

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: Fix incorrect type for window and interval
Abhishek Pandit-Subedi [Wed, 13 May 2020 02:09:32 +0000 (19:09 -0700)]
Bluetooth: Fix incorrect type for window and interval

The types for window and interval should be uint16, not uint8.

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: Introduce debug feature when dynamic debug is disabled
Marcel Holtmann [Wed, 6 May 2020 07:57:52 +0000 (09:57 +0200)]
Bluetooth: Introduce debug feature when dynamic debug is disabled

In case dynamic debug is disabled, this feature allows a vendor platform
to provide debug statement printing.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
4 years agoBluetooth: Add support for experimental features configuration
Marcel Holtmann [Wed, 6 May 2020 07:57:51 +0000 (09:57 +0200)]
Bluetooth: Add support for experimental features configuration

To enable platform specific experimental features, introduce this new set of
management commands and events.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
4 years agoBluetooth: Replace BT_DBG with bt_dev_dbg for security manager support
Marcel Holtmann [Wed, 6 May 2020 07:57:50 +0000 (09:57 +0200)]
Bluetooth: Replace BT_DBG with bt_dev_dbg for security manager support

The security manager operates on a specific controller and thus use
bt_dev_dbg to indetify the controller for each debug message.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
4 years agoBluetooth: Introduce HCI_MGMT_HDEV_OPTIONAL option
Marcel Holtmann [Wed, 6 May 2020 07:57:49 +0000 (09:57 +0200)]
Bluetooth: Introduce HCI_MGMT_HDEV_OPTIONAL option

When setting HCI_MGMT_HDEV_OPTIONAL it is possible to target a specific
conntroller or a global interface.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
4 years agoBluetooth: replace zero-length array with flexible-array member
Marcel Holtmann [Wed, 6 May 2020 07:57:48 +0000 (09:57 +0200)]
Bluetooth: replace zero-length array with flexible-array member

The current codebase makes use of the zero-length array language extension
to the C90 standard, but the preferred mechanism to declare variable-length
types such as these ones is a flexible array member.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
4 years agoBluetooth: Replace BT_DBG with bt_dev_dbg for management support
Marcel Holtmann [Wed, 6 May 2020 07:57:47 +0000 (09:57 +0200)]
Bluetooth: Replace BT_DBG with bt_dev_dbg for management support

The majority of management interaction are based on a controller index
and have a hci_dev associated with it. So use bt_dev_dbg to have a clean
way of indentifying the controller the debug message belongs to.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
4 years agoBluetooth: Add MGMT_EV_PHY_CONFIGURATION_CHANGED to supported list
Marcel Holtmann [Wed, 6 May 2020 07:57:46 +0000 (09:57 +0200)]
Bluetooth: Add MGMT_EV_PHY_CONFIGURATION_CHANGED to supported list

The event MGMT_EV_PHY_CONFIGURATION_CHANGED wasn't listed in the list of
supported events. So add it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
4 years agoBluetooth: L2CAP: Fix errors during L2CAP_CREDIT_BASED_CONNECTION_REQ (0x17)
Konstantin Forostyan [Mon, 4 May 2020 16:01:49 +0000 (16:01 +0000)]
Bluetooth: L2CAP: Fix errors during L2CAP_CREDIT_BASED_CONNECTION_REQ (0x17)

Fix 2 typos in L2CAP_CREDIT_BASED_CONNECTION_REQ (0x17) handling function, that
cause BlueZ answer with L2CAP_CR_LE_INVALID_PARAMS or L2CAP_CR_LE_INVALID_SCID
error on a correct ECRED connection request.

Enchanced Credit Based Mode support was recently introduced with the commit
15f02b91056253e8cdc592888f431da0731337b8 ("Bluetooth: L2CAP: Add initial code
for Enhanced Credit Based Mode").

Signed-off-by: Konstantin Forostyan <konstantin.forostyan@peiker-cee.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: Fix advertising handle is set to 0
Tedd Ho-Jeong An [Fri, 1 May 2020 17:00:50 +0000 (10:00 -0700)]
Bluetooth: Fix advertising handle is set to 0

This patch fix the advertising handle is set to 0 regardless of actual
instance value. The affected commands are LE Set Advertising Set Random
Address, LE Set Extended Advertising Data, and LE Set Extended Scan
Response Data commands.

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: hci_h5: Add support for binding RTL8723BS with device tree
Vasily Khoruzhick [Sat, 25 Apr 2020 15:55:30 +0000 (08:55 -0700)]
Bluetooth: hci_h5: Add support for binding RTL8723BS with device tree

RTL8723BS is often used in ARM boards, so add ability to bind it
using device tree.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Alistair Francis <alistair@alistair23.me>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agodt-bindings: net: bluetooth: Add rtl8723bs-bluetooth
Vasily Khoruzhick [Sat, 25 Apr 2020 15:55:29 +0000 (08:55 -0700)]
dt-bindings: net: bluetooth: Add rtl8723bs-bluetooth

Add binding document for bluetooth part of RTL8723BS/RTL8723CS

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Alistair Francis <alistair@alistair23.me>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: hci_qca: allow max-speed to be set for QCA9377 devices
Christian Hewitt [Thu, 23 Apr 2020 01:34:30 +0000 (01:34 +0000)]
Bluetooth: hci_qca: allow max-speed to be set for QCA9377 devices

Move the read of max-speed from device-tree out of the qca_is_wcn399x
if block so oper_speed can be set for QCA9377 devices as well.

Suggested-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: hci_qca: add compatible for QCA9377
Christian Hewitt [Thu, 23 Apr 2020 01:34:29 +0000 (01:34 +0000)]
Bluetooth: hci_qca: add compatible for QCA9377

Add a compatible so QCA9377 devices can be defined in device-tree.

Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agodt-bindings: net: bluetooth: Add device tree bindings for QCA9377
Christian Hewitt [Thu, 23 Apr 2020 01:34:28 +0000 (01:34 +0000)]
dt-bindings: net: bluetooth: Add device tree bindings for QCA9377

QCA9377 is a QCA ROME device frequently found in Android TV boxes.

Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: btusb: Adding support for LE scatternet to Jfp and ThP
Alain Michaud [Thu, 23 Apr 2020 14:43:31 +0000 (14:43 +0000)]
Bluetooth: btusb: Adding support for LE scatternet to Jfp and ThP

This change adds support for LE scatternet connections to Intel's JfP
and ThP controllers.

Signed-off-by: Alain Michaud <alainm@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: allow scatternet connections if supported.
Alain Michaud [Thu, 23 Apr 2020 14:43:29 +0000 (14:43 +0000)]
Bluetooth: allow scatternet connections if supported.

This change allows scatternet connections to be created if the
controller reports support and the HCI_QUIRK_VALID_LE_STATES indicates
that the reported LE states can be trusted.

Signed-off-by: Alain Michaud <alainm@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: Adding driver and quirk defs for multi-role LE
Alain Michaud [Thu, 23 Apr 2020 14:43:27 +0000 (14:43 +0000)]
Bluetooth: Adding driver and quirk defs for multi-role LE

This change adds the relevant driver and quirk to allow drivers to
report the le_states as being trustworthy.

This has historically been disabled as controllers did not reliably
support this. In particular, this will be used to relax this condition
for controllers that have been well tested and reliable.

/* Most controller will fail if we try to create new connections
 * while we have an existing one in slave role.
 */
if (hdev->conn_hash.le_num_slave > 0)
return NULL;

Signed-off-by: Alain Michaud <alainm@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: btbcm: Add 2 missing models to subver tables
Hans de Goede [Fri, 17 Apr 2020 17:15:32 +0000 (19:15 +0200)]
Bluetooth: btbcm: Add 2 missing models to subver tables

Currently the bcm_uart_subver_ and bcm_usb_subver_table-s lack entries
for the BCM4324B5 and BCM20703A1 chipsets. This makes the code use just
"BCM" as prefix for the filename to pass to request-firmware, making it
harder for users to figure out which firmware they need. This especially
is problematic with the UART attached BCM4324B5 where this leads to the
filename being just "BCM.hcd".

Add the 2 missing devices to subver tables. This has been tested on:

1. A Dell XPS15 9550 where this makes btbcm.c try to load
"BCM20703A1-0a5c-6410.hcd" before it tries to load "BCM-0a5c-6410.hcd".

2. A Thinkpad 8 where this makes btbcm.c try to load
"BCM4324B5.hcd" before it tries to load "BCM.hcd"

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: btbcm: Try multiple Patch filenames when loading the Patch firmware
Hans de Goede [Fri, 17 Apr 2020 17:15:31 +0000 (19:15 +0200)]
Bluetooth: btbcm: Try multiple Patch filenames when loading the Patch firmware

Currently the bcm_uart_subver_ and bcm_usb_subver_table-s lack entries
for various newer chipsets. This makes the code use just "BCM" as prefix
for the filename to pass to request-firmware, making it harder for users
to figure out which firmware they need. This especially a problem with
UART attached devices where this leads to the filename being "BCM.hcd".

If we add new entries to the subver-tables now, then this will change
what firmware file the kernel looks for, e.g. currently linux-firmware
contains a brcm/BCM-0bb4-0306.hcd file. If we add the info for the
BCM20703A1 to the subver table, then this will change to
brcm/BCM20703A1-0bb4-0306.hcd. This will cause the file to no longer
get loaded breaking Bluetooth for existing users, going against the
no regressions policy.

To avoid this regression make the btbcm code try multiple filenames,
first try the fullname, e.g. BCM20703A1-0bb4-0306.hcd and if that is
not found, then fallback to the name with just BCM as prefix.

This commit also adds an info message which filename was used,
this makes the output look like this for example:

[   57.387867] Bluetooth: hci0: BCM20703A1
[   57.387870] Bluetooth: hci0: BCM20703A1 (001.001.005) build 0000
[   57.389438] Bluetooth: hci0: BCM20703A1 'brcm/BCM20703A1-0a5c-6410.hcd' Patch
[   58.681769] Bluetooth: hci0: BCM20703A1 Generic USB 20Mhz fcbga_BU
[   58.681772] Bluetooth: hci0: BCM20703A1 (001.001.005) build 0481

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: btbcm: Bail sooner from btbcm_initialize() when not loading fw
Hans de Goede [Fri, 17 Apr 2020 17:15:30 +0000 (19:15 +0200)]
Bluetooth: btbcm: Bail sooner from btbcm_initialize() when not loading fw

If we have already loaded the firmware/patchram and btbcm_initialize()
is called to re-init the HCI after this then there is no need to get
the USB device-ids and build a firmware-filename out of these.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: btbcm: Make btbcm_setup_patchram use btbcm_finalize
Hans de Goede [Fri, 17 Apr 2020 17:15:29 +0000 (19:15 +0200)]
Bluetooth: btbcm: Make btbcm_setup_patchram use btbcm_finalize

On UART attached devices we do:

1. btbcm_initialize()
2. Setup UART baudrate, etc.
3. btbcm_finalize()

After our previous changes we can now also use btbcm_finalize() from
the btbcm_setup_patchram() function used on USB devices without any
functional changes. This completes unifying the USB and UART paths
as much as possible.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: btbcm: Make btbcm_initialize() print local-name on re-init too
Hans de Goede [Fri, 17 Apr 2020 17:15:28 +0000 (19:15 +0200)]
Bluetooth: btbcm: Make btbcm_initialize() print local-name on re-init too

Make btbcm_initialize() get and print the device's local-name on re-init
too, this will make us also print the local-name after loading the
Patch on UART attached devices making things more consistent.

This also removes some code duplication from btbcm_setup_patchram()
and allows more code duplication removal there in a follow-up patch.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: btbcm: Fold Patch loading + applying into btbcm_initialize()
Hans de Goede [Fri, 17 Apr 2020 17:15:27 +0000 (19:15 +0200)]
Bluetooth: btbcm: Fold Patch loading + applying into btbcm_initialize()

Instead of having btbcm_initialize() fill a passed in fw_name buffer
and then have its callers use that to request the firmware + load
it into the HCI, make btbcm_initialize() do this itself the first
time it is called (its get called a second time to reset the HCI
after the firmware has been loaded).

This removes some code duplication and makes it easier for further
patches in this series to try more then 1 firmware filename.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: btbcm: Move setting of USE_BDADDR_PROPERTY quirk to hci_bcm.c
Hans de Goede [Fri, 17 Apr 2020 17:15:26 +0000 (19:15 +0200)]
Bluetooth: btbcm: Move setting of USE_BDADDR_PROPERTY quirk to hci_bcm.c

btbcm_finalize() is currently only used by UART attached BCM devices.

Move the setting of the USE_BDADDR_PROPERTY quirk, which we only want
for UART attached devices to hci_bcm in preparation for using
btbcm_finalize() for USB attached devices too.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoBluetooth: btbcm: Drop upper nibble version check from btbcm_initialize()
Hans de Goede [Fri, 17 Apr 2020 17:15:25 +0000 (19:15 +0200)]
Bluetooth: btbcm: Drop upper nibble version check from btbcm_initialize()

btbcm_initialize() must either return an error; or fill the passed in
fw_name, otherwise we end up passing uninitialized stack memory to
request_firmware().

Since we have a fallback hw_name of "BCM" not having a known version
in the subver field does not matter, drop the check so that we always
fill the passed in fw_name.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
4 years agoMerge branch 'Support-programmable-pins-for-Ocelot-PTP-driver'
David S. Miller [Tue, 21 Apr 2020 22:38:34 +0000 (15:38 -0700)]
Merge branch 'Support-programmable-pins-for-Ocelot-PTP-driver'

Yangbo Lu says:

====================
Support programmable pins for Ocelot PTP driver

The Ocelot PTP clock driver had been embedded into ocelot.c driver.
It had supported basic gettime64/settime64/adjtime/adjfine functions
by now which were used by both Ocelot switch and Felix switch.

This patch-set is to move current ptp clock code out of ocelot.c driver
maintaining as a single ocelot_ptp.c driver, and to implement 4
programmable pins with only PTP_PF_PEROUT function for now.
The PTP_PF_EXTTS function will be supported in the future, and it should
be implemented separately for Felix and Ocelot, because of different
hardware interrupt implementation in them.

Changes for v2:
- Put PTP driver under drivers/net/ethernet/mscc/.
- Dropped MAINTAINERS patch. Kept original maintaining.
- Initialized PTP separately in ocelot/felix platforms.
- Supported PPS case in programmable pin.
- Supported disabling pin function since deadlock is fixed by Richard.
- Returned -EBUSY if not finding pin available.
Changes for v3:
- Re-sent.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: dsa: felix: enable PTP programmable pin
Yangbo Lu [Mon, 20 Apr 2020 02:46:51 +0000 (10:46 +0800)]
net: dsa: felix: enable PTP programmable pin

Enable PTP programmable pin.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: mscc: ocelot: enable PTP programmable pin
Yangbo Lu [Mon, 20 Apr 2020 02:46:50 +0000 (10:46 +0800)]
net: mscc: ocelot: enable PTP programmable pin

Enable PTP programmable pin.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: mscc: ocelot: support 4 PTP programmable pins
Yangbo Lu [Mon, 20 Apr 2020 02:46:49 +0000 (10:46 +0800)]
net: mscc: ocelot: support 4 PTP programmable pins

Support 4 PTP programmable pins with only PTP_PF_PEROUT function
for now. The PTP_PF_EXTTS function will be supported in the
future, and it should be implemented separately for Felix and
Ocelot, because of different hardware interrupt implementation
in them.

Since the hardware is not able to support absolute start time,
the periodic clock request only allows start time 0 0. But nsec
could be accepted for PPS case for phase adjustment.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: mscc: ocelot: add wave programming registers definitions
Yangbo Lu [Mon, 20 Apr 2020 02:46:48 +0000 (10:46 +0800)]
net: mscc: ocelot: add wave programming registers definitions

Add wave programming registers definitions for Ocelot platforms.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: mscc: ocelot: redefine PTP pins
Yangbo Lu [Mon, 20 Apr 2020 02:46:47 +0000 (10:46 +0800)]
net: mscc: ocelot: redefine PTP pins

There are 5 PTP_PINS register groups on Ocelot switch.
Except the one used for TOD operations, there are still
4 register groups for programmable pins. So redefine the
4 programmable pins.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: mscc: ocelot: fix timestamp info if ptp clock does not work
Yangbo Lu [Mon, 20 Apr 2020 02:46:46 +0000 (10:46 +0800)]
net: mscc: ocelot: fix timestamp info if ptp clock does not work

The timestamp info should be only software timestamp capabilities
if ptp clock does not work.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: mscc: ocelot: move ocelot ptp clock code out of ocelot.c
Yangbo Lu [Mon, 20 Apr 2020 02:46:45 +0000 (10:46 +0800)]
net: mscc: ocelot: move ocelot ptp clock code out of ocelot.c

The Ocelot PTP clock driver had been embedded into ocelot.c driver.
It had supported basic gettime64/settime64/adjtime/adjfine functions
by now which were used by both Ocelot switch and Felix switch.

This patch is to move current ptp clock code out of ocelot.c driver
maintaining as a single ocelot_ptp.c.
For futher new features implementation, the common code could be put
in ocelot_ptp.c and the switch specific code should be in specific
switch driver. The interrupt implementation in SoC is different
between Ocelot and Felix.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'vermagic-non-global'
David S. Miller [Tue, 21 Apr 2020 20:27:38 +0000 (13:27 -0700)]
Merge branch 'vermagic-non-global'

Leon Romanovsky says:

====================
Remove vermagic header from global include folder

Changelog:
v2:
 * Changed the implementation of patch #4 to be like Masahiro wants.
I personally don't like this implementation and changing it just to move forward
this this patchset.
v1:
https://lore.kernel.org/lkml/20200415133648.1306956-1-leon@kernel.org
 * Added tags
 * Updated patch #4 with test results
 * Changed scripts/mod/modpost.c to create inclusion of vermagic.h
   from kernel folder and not from general include/linux. This is
   needed to generate *.mod.c files, while building modules.
v0:
https://lore.kernel.org/lkml/20200414155732.1236944-1-leon@kernel.org

This is followup to the failure reported by Borislav [1] and suggested
fix later on [2].

The series removes all includes of linux/vermagic.h, updates hns and
nfp to use same kernel versioning scheme (exactly like we did for
other drivers in previous cycle) and removes vermagic.h from global
include folder.

[1] https://lore.kernel.org/lkml/20200411155623.GA22175@zn.tnic
[2] https://lore.kernel.org/lkml/20200413080452.GA3772@zn.tnic
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agokernel/module: Hide vermagic header file from general use
Leon Romanovsky [Sun, 19 Apr 2020 15:55:06 +0000 (18:55 +0300)]
kernel/module: Hide vermagic header file from general use

VERMAGIC* definitions are not supposed to be used by the drivers,
see this [1] bug report, so introduce special define to guard inclusion
of this header file and define it in kernel/modules.h and in internal
script that generates *.mod.c files.

In-tree module build:
āžœ  kernel git:(vermagic) āœ— make clean
āžœ  kernel git:(vermagic) āœ— make M=drivers/infiniband/hw/mlx5
āžœ  kernel git:(vermagic) āœ— modinfo drivers/infiniband/hw/mlx5/mlx5_ib.ko
filename: /images/leonro/src/kernel/drivers/infiniband/hw/mlx5/mlx5_ib.ko
<...>
vermagic:       5.6.0+ SMP mod_unload modversions

Out-of-tree module build:
āžœ  mlx5 make -C /images/leonro/src/kernel clean M=/tmp/mlx5
āžœ  mlx5 make -C /images/leonro/src/kernel M=/tmp/mlx5
āžœ  mlx5 modinfo /tmp/mlx5/mlx5_ib.ko
filename:       /tmp/mlx5/mlx5_ib.ko
<...>
vermagic:       5.6.0+ SMP mod_unload modversions

[1] https://lore.kernel.org/lkml/20200411155623.GA22175@zn.tnic
Reported-by: Borislav Petkov <bp@suse.de>
Acked-by: Borislav Petkov <bp@suse.de>
Acked-by: Jessica Yu <jeyu@kernel.org>
Co-developed-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/nfp: Update driver to use global kernel version
Leon Romanovsky [Sun, 19 Apr 2020 14:18:49 +0000 (17:18 +0300)]
net/nfp: Update driver to use global kernel version

Change nfp driver to use globally defined kernel version.

Reported-by: Borislav Petkov <bp@suse.de>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/hns: Remove custom driver version in favour of global one
Leon Romanovsky [Sun, 19 Apr 2020 14:18:48 +0000 (17:18 +0300)]
net/hns: Remove custom driver version in favour of global one

Use globally defined kernel version instead of custom driver variant.

Reported-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agodrivers: Remove inclusion of vermagic header
Leon Romanovsky [Sun, 19 Apr 2020 14:18:47 +0000 (17:18 +0300)]
drivers: Remove inclusion of vermagic header

Get rid of linux/vermagic.h includes, so that MODULE_ARCH_VERMAGIC from
the arch header arch/x86/include/asm/module.h won't be redefined.

  In file included from ./include/linux/module.h:30,
                   from drivers/net/ethernet/3com/3c515.c:56:
  ./arch/x86/include/asm/module.h:73: warning: "MODULE_ARCH_VERMAGIC"
redefined
     73 | # define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
        |
  In file included from drivers/net/ethernet/3com/3c515.c:25:
  ./include/linux/vermagic.h:28: note: this is the location of the
previous definition
     28 | #define MODULE_ARCH_VERMAGIC ""
        |

Fixes: 6bba2e89a88c ("net/3com: Delete driver and module versions from 3com drivers")
Co-developed-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Shannon Nelson <snelson@pensando.io> # ionic
Acked-by: Sebastian Reichel <sre@kernel.org> # power
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: ipv4: remove redundant assignment to variable rc
Colin Ian King [Mon, 20 Apr 2020 21:51:49 +0000 (22:51 +0100)]
net: ipv4: remove redundant assignment to variable rc

The variable rc is being assigned with a value that is never read
and it is being updated later with a new value. The initialization is
redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'net-bcmgenet-Clean-up-after-ACPI-enablement'
David S. Miller [Mon, 20 Apr 2020 23:24:53 +0000 (16:24 -0700)]
Merge branch 'net-bcmgenet-Clean-up-after-ACPI-enablement'

Andy Shevchenko says:

====================
net: bcmgenet: Clean up after ACPI enablement

ACPI enablement series had missed some clean ups that would have been done
at the same time. Here are these bits.

In v2:
- return dev_dbg() calls to avoid spamming logs when probe is deferred (Florian)
- added Ack (Florian)
- combined two, earlier sent, series together
- added couple more patches
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: bcmgenet: Drop too many parentheses in bcmgenet_probe()
Andy Shevchenko [Mon, 20 Apr 2020 21:51:21 +0000 (00:51 +0300)]
net: bcmgenet: Drop too many parentheses in bcmgenet_probe()

No need to have parentheses around plain pointer variable or
negation operator. Drop them for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: bcmgenet: Use get_unligned_beXX() and put_unaligned_beXX()
Andy Shevchenko [Mon, 20 Apr 2020 21:51:20 +0000 (00:51 +0300)]
net: bcmgenet: Use get_unligned_beXX() and put_unaligned_beXX()

It's convenient to use get_unligned_beXX() and put_unaligned_beXX() helpers
to get or set MAC instead of open-coded variants.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: bcmgenet: Use devm_clk_get_optional() to get the clocks
Andy Shevchenko [Mon, 20 Apr 2020 21:51:19 +0000 (00:51 +0300)]
net: bcmgenet: Use devm_clk_get_optional() to get the clocks

Conversion to devm_clk_get_optional() makes it explicit that clocks are
optional. This change allows to handle deferred probe in case clocks are
defined, but not yet probed. Due to above changes bail out in error case.

While here, check potential error when enable main clock.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: bcmgenet: Drop useless OF code
Andy Shevchenko [Mon, 20 Apr 2020 21:51:18 +0000 (00:51 +0300)]
net: bcmgenet: Drop useless OF code

There is nothing which needs a set of OF headers, followed by redundant
OF node ID check. Drop them for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: bcmgenet: Drop ACPI_PTR() to avoid compiler warning
Andy Shevchenko [Mon, 20 Apr 2020 21:51:17 +0000 (00:51 +0300)]
net: bcmgenet: Drop ACPI_PTR() to avoid compiler warning

When compiled with CONFIG_ACPI=n, ACPI_PTR() will be no-op, and thus
genet_acpi_match table defined, but not used. Compiler is not happy about
such data. Drop ACPI_PTR() for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge tag 'mlx5-updates-2020-04-20' of git://git.kernel.org/pub/scm/linux/kernel...
David S. Miller [Mon, 20 Apr 2020 23:11:31 +0000 (16:11 -0700)]
Merge tag 'mlx5-updates-2020-04-20' of git://git./linux/kernel/git/saeed/linux

Saeed Mahameed says:

====================
mlx5-updates-2020-04-20

This series includes misc updates and clean ups to mlx5 driver:

1) improve some comments from Hu Haowen.
2) Handles errors of netif_set_real_num_{tx,rx}_queues, from Maxim
3) IPsec and FPGA related code cleanup to prepare for ASIC devices
   IPsec offloads, from Raed
4) Allow partial mask for tunnel options, from Roi.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agor8169: change wmb to smb_wmb in rtl8169_start_xmit
Heiner Kallweit [Mon, 20 Apr 2020 20:52:59 +0000 (22:52 +0200)]
r8169: change wmb to smb_wmb in rtl8169_start_xmit

A barrier is needed here to ensure that rtl_tx sees the descriptor
changes (DescOwn set) before the updated tp->cur_tx value. Else it may
wrongly assume that the transfer has been finished already. For this
purpose smp_wmb() is sufficient.

No separate barrier is needed for ordering the descriptor changes
with the MMIO doorbell write. The needed barrier is included in
the non-relaxed writel() used by rtl8169_doorbell().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/mlx5: improve some comments
Hu Haowen [Wed, 1 Apr 2020 12:57:20 +0000 (20:57 +0800)]
net/mlx5: improve some comments

Replaced "its" with "it's".

Signed-off-by: Hu Haowen <xianfengting221@163.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
4 years agonet/mlx5: Read embedded cpu bit only once
Parav Pandit [Mon, 9 Mar 2020 02:41:22 +0000 (21:41 -0500)]
net/mlx5: Read embedded cpu bit only once

Embedded CPU bit doesn't change with PCI resume/suspend.
Hence read it only once while probing the PCI device.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Bodong Wang <bodong@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
4 years agonet/mlx5e: Handle errors from netif_set_real_num_{tx,rx}_queues
Maxim Mikityanskiy [Thu, 19 Mar 2020 15:32:27 +0000 (17:32 +0200)]
net/mlx5e: Handle errors from netif_set_real_num_{tx,rx}_queues

netif_set_real_num_tx_queues and netif_set_real_num_rx_queues may fail.
Now that mlx5e supports handling errors in the preactivate hook, this
commit leverages that functionality to handle errors from those
functions and roll back all changes on failure.

Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
4 years agonet/mlx5e: Allow partial data mask for tunnel options
Roi Dayan [Wed, 25 Mar 2020 09:32:56 +0000 (11:32 +0200)]
net/mlx5e: Allow partial data mask for tunnel options

We use mapping to save and restore the tunnel options.
Save also the tunnel options mask.

Signed-off-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Paul Blakey <paulb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
4 years agonet/mlx5e: Set of completion request bit should not clear other adjacent bits
Tariq Toukan [Tue, 18 Feb 2020 10:27:25 +0000 (12:27 +0200)]
net/mlx5e: Set of completion request bit should not clear other adjacent bits

In notify HW (ring doorbell) flow, we set the bit to request a completion
on the TX descriptor.
When doing so, we should not unset other bits in the same byte.
Currently, this does not fix a real issue, as we still don't have a flow
where both MLX5_WQE_CTRL_CQ_UPDATE and any adjacent bit are set together.

Fixes: 542578c67936 ("net/mlx5e: Move helper functions to a new txrx datapath header")
Fixes: 864b2d715300 ("net/mlx5e: Generalize tx helper functions for different SQ types")
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Reviewed-by: Aya Levin <ayal@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
4 years agonet/mlx5: IPsec, Refactor SA handle creation and destruction
Raed Salem [Wed, 23 Oct 2019 14:04:13 +0000 (17:04 +0300)]
net/mlx5: IPsec, Refactor SA handle creation and destruction

Currently the SA handle is created and managed as part of the common
code for different IPsec supporting HW, this handle is passed to HW
to be used on Rx to identify the SA handle that was used to
return the xfrm state to stack.

The above implementation pose a limitation on managing this handle.

Refactor by moving management of this field to the specific HW code.

Downstream patches will introduce the Connect-X support for IPsec that
will use this handle differently than current implementation.

Signed-off-by: Raed Salem <raeds@mellanox.com>
Reviewed-by: Boris Pismenny <borisp@mellanox.com>
Reviewed-by: Huy Nguyen <huyn@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
4 years agonet/mlx5e: IPSec, Expose IPsec HW stat only for supporting HW
Raed Salem [Wed, 8 Jan 2020 09:48:37 +0000 (11:48 +0200)]
net/mlx5e: IPSec, Expose IPsec HW stat only for supporting HW

The current HW counters are supported only by Innova, split the ipsec
stats group into two groups, one for HW and one for SW. And expose
the HW counters to ethtool only if Innova HW is used for IPsec offload.

Signed-off-by: Raed Salem <raeds@mellanox.com>
Reviewed-by: Huy Nguyen <huyn@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
4 years agonet/mlx5: Refactor mlx5_accel_esp_create_hw_context parameter list
Raed Salem [Tue, 10 Dec 2019 11:20:55 +0000 (13:20 +0200)]
net/mlx5: Refactor mlx5_accel_esp_create_hw_context parameter list

Currently the FPGA IPsec is the only hw implementation of the IPsec
acceleration api, and so the mlx5_accel_esp_create_hw_context was
wrongly made to suit this HW api, among other in its parameter list
and some of its parameter endianness.

This implementation might not be suitable for different HW.

Refactor by group and pass all function arguments of
mlx5_accel_esp_create_hw_context in common mlx5_accel_esp_xfrm_attrs
struct field of mlx5_accel_esp_xfrm struct and correct the endianness
according to the HW being called.

Signed-off-by: Raed Salem <raeds@mellanox.com>
Reviewed-by: Boris Pismenny <borisp@mellanox.com>
Reviewed-by: Huy Nguyen <huyn@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
4 years agonet/mlx5e: en_accel, Add missing net/geneve.h include
Raed Salem [Mon, 20 Jan 2020 13:03:00 +0000 (15:03 +0200)]
net/mlx5e: en_accel, Add missing net/geneve.h include

The cited commit relies on include <net/geneve.h> being included
implicitly prior to include "en_accel/en_accel.h".
This mandates that all files that needs to include en_accel.h
to redantantly include net/geneve.h.

Include net/geneve.h explicitly at "en_accel/en_accel.h" to avoid
undesired constrain as above.

Fixes: e3cfc7e6b7bd ("net/mlx5e: TX, Add geneve tunnel stateless offload support")
Signed-off-by: Raed Salem <raeds@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
4 years agonet/mlx5: Use the correct IPsec capability function for FPGA ops
Raed Salem [Wed, 23 Oct 2019 13:03:12 +0000 (16:03 +0300)]
net/mlx5: Use the correct IPsec capability function for FPGA ops

Currently the IPsec acceleration capability function is also used
at IPsec fpga capable device code.

This could cause a future bug as the acceleration layer is agnostic
to the device implementing its API.

Fix by using the IPsec FPGA capability function instead of acceleration
layer capability function in case of FPGA IPsec only related operations.

Downstream patches will add support for Connect-X IPsec, this can avoid
a future bug.

Signed-off-by: Raed Salem <raeds@mellanox.com>
Reviewed-by: Boris Pismenny <borisp@mellanox.com>
Reviewed-by: Huy Nguyen <huyn@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
4 years agoqed: use true,false for bool variables
Jason Yan [Mon, 20 Apr 2020 04:27:20 +0000 (12:27 +0800)]
qed: use true,false for bool variables

Fix the following coccicheck warning:

drivers/net/ethernet/qlogic/qed/qed_dev.c:4395:2-34: WARNING:
Assignment of 0/1 to bool variable
drivers/net/ethernet/qlogic/qed/qed_dev.c:1975:2-34: WARNING:
Assignment of 0/1 to bool variable

Signed-off-by: Jason Yan <yanaijie@huawei.com>
Acked-by: Michal KalderonĀ <michal.kalderon@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'hns3-next'
David S. Miller [Mon, 20 Apr 2020 19:49:18 +0000 (12:49 -0700)]
Merge branch 'hns3-next'

Huazhong Tan says:

====================
net: hns3: misc updates for -next

This patchset includes some misc updates for the HNS3 ethernet driver.

[patch 1&2] separates two bloated function.
[patch 3-5] removes some redundant code.
[patch 6-7] cleans up some coding style issues.
[patch 8-10] adds some debugging information.

Change log:
V1->V2: removes an unnecessary initialization in [patch 1] which
suggested by David Miller.
modified some print format issue and commit log in [patch 8].
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: hns3: add trace event support for PF/VF mailbox
Yufeng Mo [Mon, 20 Apr 2020 02:17:35 +0000 (10:17 +0800)]
net: hns3: add trace event support for PF/VF mailbox

This patch adds trace event support for PF/VF mailbox.

Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: hns3: add support for dumping MAC reg in debugfs
Yufeng Mo [Mon, 20 Apr 2020 02:17:34 +0000 (10:17 +0800)]
net: hns3: add support for dumping MAC reg in debugfs

This patch adds support for dumping MAC reg in debugfs,
which will be helpful for debugging.

Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: hns3: add debug information for flow table when failed
Guojia Liao [Mon, 20 Apr 2020 02:17:33 +0000 (10:17 +0800)]
net: hns3: add debug information for flow table when failed

Adds some debug information for failures of processing flow table,
removes the redundant printing when hclge_fd_check_spec() returns
error, and modifies the printing level for FD not enable error.

Signed-off-by: Guojia Liao <liaoguojia@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: hns3: clean up some coding style issue
Huazhong Tan [Mon, 20 Apr 2020 02:17:32 +0000 (10:17 +0800)]
net: hns3: clean up some coding style issue

This patch removes some unnecessary blank lines, redundant
parentheses, and changes one tab to blank in
hclge_dbg_dump_reg_common().

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: hns3: modify some unsuitable type declaration
Guojia Liao [Mon, 20 Apr 2020 02:17:31 +0000 (10:17 +0800)]
net: hns3: modify some unsuitable type declaration

In hclge_set_fd_key_config(), parameter 'stage' should be
as enum HCLGE_FD_STAGE, and in hclge_config_key(), 'tuple_size'
should be type u8, also simplify unsigned int with u32 for 'i'.

Signed-off-by: Guojia Liao <liaoguojia@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: hns3: remove two unused structures in hclge_cmd.h
Guojia Liao [Mon, 20 Apr 2020 02:17:30 +0000 (10:17 +0800)]
net: hns3: remove two unused structures in hclge_cmd.h

struct hclge_mac_vlan_remove_cmd and hclge_mac_vlan_add_cmd are unused.
So removes them from hclge_cmd.h.

Signed-off-by: Guojia Liao <liaoguojia@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: hns3: remove useless proto_support field in struct hclge_fd_cfg
Guojia Liao [Mon, 20 Apr 2020 02:17:29 +0000 (10:17 +0800)]
net: hns3: remove useless proto_support field in struct hclge_fd_cfg

proto_support field in struct hclge_fd_cfg shows what protocols
in flow direct table are supported now. It is unnecessary since
checking which one is unsupported will be more efficient,
so this patch removes it.

Signed-off-by: Guojia Liao <liaoguojia@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: hns3: remove an unnecessary case 0 in hclge_fd_convert_tuple()
Huazhong Tan [Mon, 20 Apr 2020 02:17:28 +0000 (10:17 +0800)]
net: hns3: remove an unnecessary case 0 in hclge_fd_convert_tuple()

Since case default has included case 0, so removes this
redundant case 0.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: hns3: split out hclge_get_fd_rule_info()
Jian Shen [Mon, 20 Apr 2020 02:17:27 +0000 (10:17 +0800)]
net: hns3: split out hclge_get_fd_rule_info()

hclge_get_fd_rule_info() is bloated, this patch separates
it into several standalone functions for readability and
maintainability.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: hns3: split out hclge_fd_check_ether_tuple()
Jian Shen [Mon, 20 Apr 2020 02:17:26 +0000 (10:17 +0800)]
net: hns3: split out hclge_fd_check_ether_tuple()

For readability and maintainability, this patch separates the
handling part of each flow type in hclge_fd_check_ether_tuple()
into standalone functions.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'RFC-2863-Testing-Oper-status'
David S. Miller [Mon, 20 Apr 2020 19:43:24 +0000 (12:43 -0700)]
Merge branch 'RFC-2863-Testing-Oper-status'

Andrew Lunn says:

====================
RFC 2863 Testing Oper status

This patchset add support for RFC 2863 Oper status testing.  An
interface is placed into this state when a self test is performed
using ethtool.

v2:
Fix date/kernel version in Documentation
Add reviewed-by tags
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: ethtool: self_test: Mark interface in testing operative status
Andrew Lunn [Sun, 19 Apr 2020 22:11:52 +0000 (00:11 +0200)]
net: ethtool: self_test: Mark interface in testing operative status

When an interface is executing a self test, put the interface into
operative status testing.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: Add testing sysfs attribute
Andrew Lunn [Sun, 19 Apr 2020 22:11:51 +0000 (00:11 +0200)]
net: Add testing sysfs attribute

Similar to speed, duplex and dorment, report the testing status
in sysfs.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: Add IF_OPER_TESTING
Andrew Lunn [Sun, 19 Apr 2020 22:11:50 +0000 (00:11 +0200)]
net: Add IF_OPER_TESTING

RFC 2863 defines the operational state testing. Add support for this
state, both as a IF_LINK_MODE_ and __LINK_STATE_.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'FEC-MDIO-speedups'
David S. Miller [Mon, 20 Apr 2020 19:37:08 +0000 (12:37 -0700)]
Merge branch 'FEC-MDIO-speedups'

Andrew Lunn says:

====================
FEC MDIO speedups

This patchset gives a number of speedups for MDIO with the FEC.
Replacing interrupt driven with polled IO brings a big speedup due to
the overheads of interrupts compared to the short time interval.
Clocking the bus faster, when the MDIO targets supports it, can double
the transfer rate. And suppressing the preamble, if devices support
it, makes each transaction faster.

By default the MDIO clock remains 2.5MHz and preables are used. But
these can now be controlled from the device tree. Since these are
generic properties applicable to more than just FEC, these have been
added to the generic MDIO binding documentation.

v2:
readl_poll_timeout()
Add patches to set bus frequency and preamble disable

v3:
Add Reviewed tags
uS->us
readl_poll_timeout_atomic()
Extend DT binding documentation
====================

Acked-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: ethernet: fec: Allow the MDIO preamble to be disabled
Andrew Lunn [Sun, 19 Apr 2020 22:04:02 +0000 (00:04 +0200)]
net: ethernet: fec: Allow the MDIO preamble to be disabled

An MDIO transaction normally starts with 32 1s as a preamble. However
not all devices requires such a preamble. Add a device tree property
which allows the preamble to be suppressed. This will half the size of
the MDIO transaction, allowing faster transactions. But it should only
be used when all devices on the bus support suppressed preamble.

Suggested-by: Chris Healy <Chris.Healy@zii.aero>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: ethernet: fec: Allow configuration of MDIO bus speed
Andrew Lunn [Sun, 19 Apr 2020 22:04:01 +0000 (00:04 +0200)]
net: ethernet: fec: Allow configuration of MDIO bus speed

MDIO busses typically operate at 2.5MHz. However many devices can
operate at faster speeds. This then allows more MDIO transactions per
second, useful for Ethernet switch statistics, or Ethernet PHY TDR
data. Allow the bus speed to be configured, using the standard
"clock-frequency" property, which i2c busses use to indicate the bus
speed. Before using this property, ensure all devices on the bus do
actually support the requested clock speed.

Suggested-by: Chris Healy <Chris.Healy@zii.aero>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: ethernet: fec: Replace interrupt driven MDIO with polled IO
Andrew Lunn [Sun, 19 Apr 2020 22:04:00 +0000 (00:04 +0200)]
net: ethernet: fec: Replace interrupt driven MDIO with polled IO

Measurements of the MDIO bus have shown that driving the MDIO bus
using interrupts is slow. Back to back MDIO transactions take about
90us, with 25us spent performing the transaction, and the remainder of
the time the bus is idle.

Replacing the completion interrupt with polled IO results in back to
back transactions of 40us. The polling loop waiting for the hardware
to complete the transaction takes around 28us. Which suggests
interrupt handling has an overhead of 50us, and polled IO nearly
halves this overhead, and doubles the MDIO performance.

Suggested-by: Chris Heally <cphealy@gmail.com>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agor8169: inline rtl8169_make_unusable_by_asic
Heiner Kallweit [Sun, 19 Apr 2020 21:16:55 +0000 (23:16 +0200)]
r8169: inline rtl8169_make_unusable_by_asic

Inline rtl8169_make_unusable_by_asic() and simplify it:
- Address field doesn't need to be poisoned because descriptor is
  owned by CPU now
- desc->opts1 is set by rtl8169_mark_to_asic() and rtl8169_rx_fill(),
  therefore we don't have to preserve any field parts.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agor8169: inline rtl8169_mark_as_last_descriptor
Heiner Kallweit [Sun, 19 Apr 2020 21:07:39 +0000 (23:07 +0200)]
r8169: inline rtl8169_mark_as_last_descriptor

rtl8169_mark_as_last_descriptor() has just one user, so inline it.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next...
David S. Miller [Mon, 20 Apr 2020 19:25:31 +0000 (12:25 -0700)]
Merge branch '1GbE' of git://git./linux/kernel/git/jkirsher/next-queue

Jeff Kirsher says:

====================
1GbE Intel Wired LAN Driver Updates 2020-04-19

This series contains updates to e1000e and igc only.

Sasha adds new device IDs supported by the igc driver.

Vitaly fixes the S0ix entry and exit flows in e1000e for TGP and newer
MAC types when a cable is connected.

Andre has the remaining changes in the series, starting with cleanup of
the igc driver of duplicate code.  Added a check for
IGC_MAC_STATE_SRC_ADDR flag which is unsupported for MAC filters in igc.
Cleaned up the return values for igc_add_mac_filter(), where the return
value was not being used, so update the function to only return success
or failure.  Fix the return value of igc_uc_unsync() as well.  Refactor
the igc driver in several functions to help reduce the convoluted logic
and simplify the driver filtering mechanisms.  Improve the MAC address
checks when adding a MAC filter.  Lastly, improve the log messages
related to MAC address filtering to ease debugging.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: qed: Remove unneeded cast from memory allocation
Aishwarya Ramakrishnan [Sun, 19 Apr 2020 16:29:17 +0000 (21:59 +0530)]
net: qed: Remove unneeded cast from memory allocation

Remove casting the values returned by memory allocation function.

Coccinelle emits WARNING: casting value returned by memory allocation
function to struct pointer is useless.

This issue was detected by using the Coccinelle.

Signed-off-by: Aishwarya Ramakrishnan <aishwaryarj100@gmail.com>
Acked-by: Michal KalderonĀ <michal.kalderon@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: sun: Remove unneeded cast from memory allocation
Aishwarya Ramakrishnan [Sun, 19 Apr 2020 15:44:43 +0000 (21:14 +0530)]
net: sun: Remove unneeded cast from memory allocation

Remove casting the values returned by memory allocation function.

Coccinelle emits WARNING: casting value returned by memory allocation
function to (struct cas_init_block *) is useless.

This issue was detected by using the Coccinelle software.

Signed-off-by: Aishwarya Ramakrishnan <aishwaryarj100@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: ethernet: dnet: convert to devm_platform_get_and_ioremap_resource
Dejin Zheng [Sun, 19 Apr 2020 12:02:53 +0000 (20:02 +0800)]
net: ethernet: dnet: convert to devm_platform_get_and_ioremap_resource

use devm_platform_get_and_ioremap_resource() to simplify code, which
contains platform_get_resource() and devm_ioremap_resource(), it also
get the resource for use by the following code.

Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoselftests: pmtu: implement IPIP, SIT and ip6tnl PMTU discovery tests
Lourdes Pedrajas [Sun, 19 Apr 2020 09:16:51 +0000 (11:16 +0200)]
selftests: pmtu: implement IPIP, SIT and ip6tnl PMTU discovery tests

Add PMTU discovery tests for these encapsulations:

- IPIP
- SIT, mode ip6ip
- ip6tnl, modes ip6ip6 and ipip6

Signed-off-by: Lourdes Pedrajas <lu@pplo.net>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: phy: mscc: use mdiobus_get_phy()
Michael Walle [Sun, 19 Apr 2020 08:27:57 +0000 (10:27 +0200)]
net: phy: mscc: use mdiobus_get_phy()

Don't use internal knowledge of the mdio bus core, instead use
mdiobus_get_phy() which does the same thing.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'mlxsw-Two-small-changes'
David S. Miller [Mon, 20 Apr 2020 18:57:33 +0000 (11:57 -0700)]
Merge branch 'mlxsw-Two-small-changes'

Ido Schimmel says:

====================
mlxsw: Two small changes

Patch #1 increases the scale of supported IPv6 nexthops groups when each
group has one nexthop and all are using the same nexthop device, but
with a different gateway IP.

Patch #2 adjusts a register definition in accordance with recent
firmware changes.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: reg: Increase register field length to 13 bits
Ido Schimmel [Sun, 19 Apr 2020 07:01:06 +0000 (10:01 +0300)]
mlxsw: reg: Increase register field length to 13 bits

The Infrastructure Entry Delete Register (IEDR) is used to delete
entries stored in the KVD linear database. Currently, it is only
possible to delete entries of size up to 2048. Future firmware versions
will support deletion of entries of size up to 4096.

Increase the size of the field so that the driver will be able to
perform such deletions in the future, when required.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_router: Re-increase scale of IPv6 nexthop groups
Ido Schimmel [Sun, 19 Apr 2020 07:01:05 +0000 (10:01 +0300)]
mlxsw: spectrum_router: Re-increase scale of IPv6 nexthop groups

As explained in commit fc25996e6f46 ("mlxsw: spectrum_router: Increase
scale of IPv6 nexthop groups"), each nexthop group is hashed by XOR-ing
the interface indexes of all the member nexthop devices.

To avoid many different nexthop groups ending up using the same key, the
above commit started hashing the interface indexes themselves before
they are XOR-ed.

However, in cases in which there are many nexthop groups that all use
the same nexthop device and only differ in the gateway IP, we can still
end up in a situation in which all the groups are using the same key.
This eventually leads to -EBUSY error from rhashtable during insertion.

Improve the situation by also making the gateway IP part of the key.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reported-by: Alex Veber <alexve@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Tested-by: Alex Veber <alexve@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: phy: Propagate error from bus->reset
Florian Fainelli [Sun, 19 Apr 2020 03:17:13 +0000 (20:17 -0700)]
net: phy: Propagate error from bus->reset

If a bus->reset() call for the mii_bus structure returns an error (e.g.:
-EPROE_DEFER) we should propagate it accordingly.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'net-phy-realtek-move-PHY-resume-delay-from-MAC-to-PHY-driver'
David S. Miller [Mon, 20 Apr 2020 18:12:29 +0000 (11:12 -0700)]
Merge branch 'net-phy-realtek-move-PHY-resume-delay-from-MAC-to-PHY-driver'

Heiner Kallweit says:

====================
net: phy: realtek: move PHY resume delay from MAC to PHY driver

Internal PHY's from RTL8168h up may not be instantly ready after calling
genphy_resume(). So far r8169 network driver adds the needed delay, but
better handle this in the PHY driver. The network driver may miss other
places where the PHY is resumed.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agor8169: remove PHY resume delay that is handled in the PHY driver now
Heiner Kallweit [Sat, 18 Apr 2020 20:09:42 +0000 (22:09 +0200)]
r8169: remove PHY resume delay that is handled in the PHY driver now

The Realtek PHY driver takes care of adding the needed delay now,
therefore we can remove the delay here.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: phy: realtek: add delay to resume path of certain internal PHY's
Heiner Kallweit [Sat, 18 Apr 2020 20:08:51 +0000 (22:08 +0200)]
net: phy: realtek: add delay to resume path of certain internal PHY's

Internal PHY's from RTL8168h up may not be instantly ready after calling
genphy_resume(). So far r8169 network driver adds the needed delay, but
better handle this in the PHY driver. The network driver may miss other
places where the PHY is resumed.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: hns: use true,false for bool variables
Jason Yan [Sat, 18 Apr 2020 08:42:12 +0000 (16:42 +0800)]
net: hns: use true,false for bool variables

Fix the following coccicheck warning:

drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c:700:2-8: WARNING:
Assignment of 0/1 to bool variable
drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c:702:2-8: WARNING:
Assignment of 0/1 to bool variable

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>