platform/kernel/linux-starfive.git
4 years agoqlogic: Replace zero-length array with flexible-array member
Gustavo A. R. Silva [Tue, 25 Feb 2020 00:03:55 +0000 (18:03 -0600)]
qlogic: 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[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was detected with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoRevert "net: dsa: bcm_sf2: Also configure Port 5 for 2Gb/sec on 7278"
Florian Fainelli [Mon, 24 Feb 2020 23:44:26 +0000 (15:44 -0800)]
Revert "net: dsa: bcm_sf2: Also configure Port 5 for 2Gb/sec on 7278"

This reverts commit 7458bd540fa0a90220b9e8c349d910d9dde9caf8 ("net: dsa:
bcm_sf2: Also configure Port 5 for 2Gb/sec on 7278") as it causes
advanced congestion buffering issues with 7278 switch devices when using
their internal Giabit PHY. While this is being debugged, continue with
conservative defaults that work and do not cause packet loss.

Fixes: 7458bd540fa0 ("net: dsa: bcm_sf2: Also configure Port 5 for 2Gb/sec on 7278")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Vivien Didelot <vivien.didelot@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoiavf: use tc_cls_can_offload_and_chain0() instead of chain check
Jiri Pirko [Wed, 26 Feb 2020 08:21:57 +0000 (09:21 +0100)]
iavf: use tc_cls_can_offload_and_chain0() instead of chain check

Looks like the iavf code actually experienced a race condition, when a
developer took code before the check for chain 0 was put to helper.
So use tc_cls_can_offload_and_chain0() helper instead of direct check and
move the check to _cb() so this is similar to i40e code.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'mlxsw-Implement-ACL-dropped-packets-identification'
David S. Miller [Tue, 25 Feb 2020 19:05:55 +0000 (11:05 -0800)]
Merge branch 'mlxsw-Implement-ACL-dropped-packets-identification'

Jiri Pirko says:

====================
mlxsw: Implement ACL-dropped packets identification

mlxsw hardware allows to insert a ACL-drop action with a value defined
by user that would be later on passed with a dropped packet.

To implement this, use the existing TC action cookie and pass it to the
driver. As the cookie format coming down from TC and the mlxsw HW cookie
format is different, do the mapping of these two using idr and rhashtable.

The cookie is passed up from the HW through devlink_trap_report() to
drop_monitor code. A new metadata type is used for that.

Example:
$ tc qdisc add dev enp0s16np1 clsact
$ tc filter add dev enp0s16np1 ingress protocol ip pref 10 flower skip_sw dst_ip 192.168.1.2 action drop cookie 3b45fa38c8
                                                                                                                ^^^^^^^^^^
$ devlink trap set pci/0000:00:10.0 trap acl action trap
$ dropwatch
Initializing null lookup method
dropwatch> set hw true
setting hardware drops monitoring to 1
dropwatch> set alertmode packet
Setting alert mode
Alert mode successfully set
dropwatch> start
Enabling monitoring...
Kernel monitoring activated.
Issue Ctrl-C to stop monitoring
drop at: ingress_flow_action_drop (acl_drops)
origin: hardware
input port ifindex: 30
input port name: enp0s16np1
cookie: 3b45fa38c8    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
timestamp: Fri Jan 24 17:10:53 2020 715387671 nsec
protocol: 0x800
length: 98
original length: 98

This way the user may insert multiple drop rules and monitor the dropped
packets with the information of which action caused the drop.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoselftests: netdevsim: Extend devlink trap test to include flow action cookie
Jiri Pirko [Tue, 25 Feb 2020 10:45:27 +0000 (11:45 +0100)]
selftests: netdevsim: Extend devlink trap test to include flow action cookie

Extend existing devlink trap test to include metadata type for flow
action cookie.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonetdevsim: add ACL trap reporting cookie as a metadata
Jiri Pirko [Tue, 25 Feb 2020 10:45:26 +0000 (11:45 +0100)]
netdevsim: add ACL trap reporting cookie as a metadata

Add new trap ACL which reports flow action cookie in a metadata. Allow
used to setup the cookie using debugfs file.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_trap: Lookup and pass cookie down to devlink_trap_report()
Jiri Pirko [Tue, 25 Feb 2020 10:45:25 +0000 (11:45 +0100)]
mlxsw: spectrum_trap: Lookup and pass cookie down to devlink_trap_report()

Use the cookie index received along with the packet to lookup original
flow_offload cookie binary and pass it down to devlink_trap_report().
Add "fa_cookie" metadata to the ACL trap.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: pci: Extract cookie index for ACL discard trap packets
Jiri Pirko [Tue, 25 Feb 2020 10:45:24 +0000 (11:45 +0100)]
mlxsw: pci: Extract cookie index for ACL discard trap packets

In case the received packet comes in due to one of ACL discard traps,
take the user_def_val_orig_pkt_len field from CQE and store it
in skb->cb as ACL cookie index.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: core_acl_flex_actions: Implement flow_offload action cookie offload
Jiri Pirko [Tue, 25 Feb 2020 10:45:23 +0000 (11:45 +0100)]
mlxsw: core_acl_flex_actions: Implement flow_offload action cookie offload

Track cookies coming down to driver by flow_offload.
Assign a cookie_index to each unique cookie binary. Use previously
defined "Trap with userdef" flex action to ask HW to pass cookie_index
alongside with the dropped packets.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: core_acl_flex_actions: Add trap with userdef action
Jiri Pirko [Tue, 25 Feb 2020 10:45:22 +0000 (11:45 +0100)]
mlxsw: core_acl_flex_actions: Add trap with userdef action

Expose "Trap action with userdef". It is the same as already
defined "Trap action" with a difference that it would ask the policy
engine to pass arbitrary value (userdef) alongside with received packets.
This would be later on used to carry cookie index.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agodevlink: extend devlink_trap_report() to accept cookie and pass
Jiri Pirko [Tue, 25 Feb 2020 10:45:21 +0000 (11:45 +0100)]
devlink: extend devlink_trap_report() to accept cookie and pass

Add cookie argument to devlink_trap_report() allowing driver to pass in
the user cookie. Pass on the cookie down to drop monitor code.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agodrop_monitor: extend by passing cookie from driver
Jiri Pirko [Tue, 25 Feb 2020 10:45:20 +0000 (11:45 +0100)]
drop_monitor: extend by passing cookie from driver

If driver passed along the cookie, push it through Netlink.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agodevlink: add trap metadata type for cookie
Jiri Pirko [Tue, 25 Feb 2020 10:45:19 +0000 (11:45 +0100)]
devlink: add trap metadata type for cookie

Allow driver to indicate cookie metadata for registered traps.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoflow_offload: pass action cookie through offload structures
Jiri Pirko [Tue, 25 Feb 2020 10:45:18 +0000 (11:45 +0100)]
flow_offload: pass action cookie through offload structures

Extend struct flow_action_entry in order to hold TC action cookie
specified by user inserting the action.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge tag 'mac80211-next-for-net-next-2020-02-24' of git://git.kernel.org/pub/scm...
David S. Miller [Mon, 24 Feb 2020 23:41:54 +0000 (15:41 -0800)]
Merge tag 'mac80211-next-for-net-next-2020-02-24' of git://git./linux/kernel/git/jberg/mac80211-next

Johannes Berg says:

====================
A new set of changes:
 * lots of small documentation fixes, from Jérôme Pouiller
 * beacon protection (BIGTK) support from Jouni Malinen
 * some initial code for TID configuration, from Tamizh chelvam
 * I reverted some new API before it's actually used, because
   it's wrong to mix controlled port and preauth
 * a few other cleanups/fixes
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: qrtr: fix spelling mistake "serivce" -> "service"
Colin Ian King [Mon, 24 Feb 2020 17:35:53 +0000 (17:35 +0000)]
net: qrtr: fix spelling mistake "serivce" -> "service"

There is a spelling mistake in a pr_err message. Fix it.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: ethernet: stmmac: don't warn about missing optional wakeup IRQ
Ahmad Fatoum [Mon, 24 Feb 2020 17:29:55 +0000 (18:29 +0100)]
net: ethernet: stmmac: don't warn about missing optional wakeup IRQ

The "stm32_pwr_wakeup" is optional per the binding and the driver
handles its absence gracefully. Request it with
platform_get_irq_byname_optional, so its absence doesn't needlessly
clutter the log.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: ethernet: stmmac: demote warnings about missing optional clocks
Ahmad Fatoum [Mon, 24 Feb 2020 17:29:54 +0000 (18:29 +0100)]
net: ethernet: stmmac: demote warnings about missing optional clocks

The specification of a "eth-ck" and a "ptp_ref" clock is optional per
the binding and the driver handles them gracefully.
Demote the output to an info message accordingly.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'Add-ACPI-bindings-to-the-genet'
David S. Miller [Mon, 24 Feb 2020 23:31:23 +0000 (15:31 -0800)]
Merge branch 'Add-ACPI-bindings-to-the-genet'

Jeremy Linton says:

====================
Add ACPI bindings to the genet

This patch series allows the BCM GENET, as used on the RPi4,
to attach when booted in an ACPI environment. The DSDT entry to
trigger this is seen below. Of note, the first patch adds a
small extension to the mdio layer which allows drivers to find
the mii_bus without firmware assistance. The fifth patch in
the set retrieves the MAC address from the umac registers
rather than carrying it directly in the DSDT. This of course
requires the firmware to pre-program it, so we continue to fall
back on a random one if it appears to be garbage.

v1 -> v2:
     fail on missing phy-mode property
     replace phy-mode internal property read string with
           device_get_phy_mode() equivalent
     rework mac address detection logic so that it merges
          the acpi/DT case into device_get_mac_address()
    allowing _DSD mac address properties.
     some commit messages justifying why phy_find_first()
          isn't the worst choice for this driver.

+    Device (ETH0)
+    {
+      Name (_HID, "BCM6E4E")
+      Name (_UID, 0)
+      Name (_CCA, 0x0)
+      Method (_STA)
+      {
+        Return (0xf)
+      }
+      Method (_CRS, 0x0, Serialized)
+      {
+        Name (RBUF, ResourceTemplate ()
+        {
+          Memory32Fixed (ReadWrite, 0xFd580000, 0x10000, )
+          Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0xBD }
+          Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0xBE }
+        })
+        Return (RBUF)
+      }
+      Name (_DSD, Package () {
+        ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+          Package () {
+          Package () { "phy-mode", "rgmii-rxid" },
+        }
+      })
+    }
====================

Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: bcmgenet: reduce severity of missing clock warnings
Jeremy Linton [Mon, 24 Feb 2020 22:54:03 +0000 (16:54 -0600)]
net: bcmgenet: reduce severity of missing clock warnings

If one types "failed to get enet clock" or similar into google
there are ~370k hits. The vast majority are people debugging
problems unrelated to this adapter, or bragging about their
rpi's. Further, the DT clock bindings here are optional.

Given that its not a fatal situation with common DT based
systems, lets reduce the severity so people aren't seeing failure
messages in everyday operation.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: bcmgenet: Fetch MAC address from the adapter
Jeremy Linton [Mon, 24 Feb 2020 22:54:02 +0000 (16:54 -0600)]
net: bcmgenet: Fetch MAC address from the adapter

ARM/ACPI machines should utilize self describing hardware
when possible. The MAC address on the BCMGENET can be
read from the adapter if a full featured firmware has already
programmed it. Lets try using the address already programmed,
if it appears to be valid.

It should be noted that while we move the macaddr logic below
the clock and power logic in the driver, none of that code will
ever be active in an ACPI environment as the device will be
attached to the acpi power domain, and brought to full power
with all clocks enabled immediately before the device probe
routine is called.

One side effect of the above tweak is that while its now
possible to read the MAC address via _DSD properties, it should
be avoided.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: bcmgenet: Initial bcmgenet ACPI support
Jeremy Linton [Mon, 24 Feb 2020 22:54:01 +0000 (16:54 -0600)]
net: bcmgenet: Initial bcmgenet ACPI support

The rpi4 is capable of booting in ACPI mode with the latest
edk2-platform commits. As such it would be helpful if the genet
platform device were usable.

To achieve this we add a new MODULE_DEVICE_TABLE, and convert
a few dt specific methods to their generic device_ calls. Until
the next patch, ACPI based machines will fallback on random
mac addresses.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: bcmgenet: enable automatic phy discovery
Jeremy Linton [Mon, 24 Feb 2020 22:54:00 +0000 (16:54 -0600)]
net: bcmgenet: enable automatic phy discovery

The unimac mdio driver falls back to scanning the
entire bus if its given an appropriate mask. In ACPI
mode we expect that the system is well behaved and
conforms to recent versions of the specification.

We then utilize phy_find_first(), and
phy_connect_direct() to find and attach to the
discovered phy during net_device open. While its
apparently possible to build a genet based device
with multiple phys on a single mdio bus, this works
for current machines. Further, this driver makes
a number of assumptions about the platform device,
mac, mdio and phy all being 1:1. Lastly, It also
avoids having to create references across the ACPI
namespace hierarchy.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: bcmgenet: refactor phy mode configuration
Jeremy Linton [Mon, 24 Feb 2020 22:53:59 +0000 (16:53 -0600)]
net: bcmgenet: refactor phy mode configuration

The DT phy mode is similar to what we want for ACPI
lets factor it out of the of path, and change the
of_ call to device_.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomdio_bus: Add generic mdio_find_bus()
Jeremy Linton [Mon, 24 Feb 2020 22:53:58 +0000 (16:53 -0600)]
mdio_bus: Add generic mdio_find_bus()

It appears most ethernet drivers follow one of two main strategies
for mdio bus/phy management. A monolithic model where the net driver
itself creates, probes and uses the phy, and one where an external
mdio/phy driver instantiates the mdio bus/phy and the net driver
only attaches to a known phy. Usually in this latter model the phys
are discovered via DT relationships or simply phy name/address
hardcoding.

This is a shame because modern well behaved mdio buses are self
describing and can be probed. The mdio layer itself is fully capable
of this, yet there isn't a clean way for a standalone net driver
to attach and enumerate the discovered devices. This is because
outside of of_mdio_find_bus() there isn't a straightforward way
to acquire the mii_bus pointer.

So, lets add a mdio_find_bus which can return the mii_bus based
only on its name.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agofreescale: Replace zero-length array with flexible-array member
Gustavo A. R. Silva [Mon, 24 Feb 2020 16:43:46 +0000 (10:43 -0600)]
freescale: 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[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agointel: Replace zero-length array with flexible-array member
Gustavo A. R. Silva [Mon, 24 Feb 2020 16:41:06 +0000 (10:41 -0600)]
intel: 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[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonetronome: Replace zero-length array with flexible-array member
Gustavo A. R. Silva [Mon, 24 Feb 2020 16:36:52 +0000 (10:36 -0600)]
netronome: 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[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agotoshiba: Replace zero-length array with flexible-array member
Gustavo A. R. Silva [Mon, 24 Feb 2020 16:32:52 +0000 (10:32 -0600)]
toshiba: 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[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agochelsio: Replace zero-length array with flexible-array member
Gustavo A. R. Silva [Mon, 24 Feb 2020 16:30:24 +0000 (10:30 -0600)]
chelsio: 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[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'Remainder-for-DT-bindings-for-Felix-DSA-switch-on-LS1028A'
David S. Miller [Mon, 24 Feb 2020 23:12:11 +0000 (15:12 -0800)]
Merge branch 'Remainder-for-DT-bindings-for-Felix-DSA-switch-on-LS1028A'

Vladimir Oltean says:

====================
Remainder for "DT bindings for Felix DSA switch on LS1028A"

This series is the remainder of patchset [0] which has been merged
through Shawn Guo's devicetree tree.

It contains changes to the PHY mode validation in the Felix driver
("gmii" to "internal") and the documentation for the DT bindings.

[0]: https://patchwork.ozlabs.org/cover/1242716/
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agodt-bindings: net: dsa: ocelot: document the vsc9959 core
Vladimir Oltean [Mon, 24 Feb 2020 12:15:34 +0000 (14:15 +0200)]
dt-bindings: net: dsa: ocelot: document the vsc9959 core

This patch adds the required documentation for the embedded L2 switch
inside the NXP LS1028A chip.

I've submitted it in the legacy format instead of yaml schema, because
DSA itself has not yet been converted to yaml, and this driver defines
no custom bindings.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: dsa: felix: Use PHY_INTERFACE_MODE_INTERNAL instead of GMII
Vladimir Oltean [Mon, 24 Feb 2020 12:15:33 +0000 (14:15 +0200)]
net: dsa: felix: Use PHY_INTERFACE_MODE_INTERNAL instead of GMII

phy-mode = "gmii" is confusing because it may mean that the port
supports the 8-bit-wide parallel data interface pinout, which it
doesn't.

It may also be confusing because one of the "gmii" internal ports is
actually overclocked to run at 2.5Gbps (even though, yes, as far as the
switch MAC is concerned, it still thinks it's gigabit).

So use the phy-mode = "internal" property to describe the internal ports
inside the NXP LS1028A chip (the ones facing the ENETC). The change
should be fine, because the device tree bindings document is yet to be
introduced, and there are no stable DT blobs in use.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Michael Walle <michael@walle.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agobareudp: Fix uninitialized variable warnings.
David S. Miller [Mon, 24 Feb 2020 22:40:54 +0000 (14:40 -0800)]
bareudp: Fix uninitialized variable warnings.

drivers/net/bareudp.c: In function 'bareudp_xmit_skb':
drivers/net/bareudp.c:346:9: warning: 'err' may be used uninitialized in this function [-Wmaybe-uninitialized]
  346 |  return err;
      |         ^~~
drivers/net/bareudp.c: In function 'bareudp6_xmit_skb':
drivers/net/bareudp.c:407:9: warning: 'err' may be used uninitialized in this function [-Wmaybe-uninitialized]
  407 |  return err;

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'Bare-UDP-L3-Encapsulation-Module'
David S. Miller [Mon, 24 Feb 2020 21:31:42 +0000 (13:31 -0800)]
Merge branch 'Bare-UDP-L3-Encapsulation-Module'

Martin Varghese says:

====================
Bare UDP L3 Encapsulation Module

There are various L3 encapsulation standards using UDP being discussed to
leverage the UDP based load balancing capability of different networks.
MPLSoUDP (__ https://tools.ietf.org/html/rfc7510) is one among them.

The Bareudp tunnel module provides a generic L3 encapsulation tunnelling
support for tunnelling different L3 protocols like MPLS, IP, NSH etc. inside
a UDP tunnel.

Special Handling
----------------
The bareudp device supports special handling for MPLS & IP as they can have
multiple ethertypes.
MPLS procotcol can have ethertypes ETH_P_MPLS_UC  (unicast) & ETH_P_MPLS_MC (multicast).
IP protocol can have ethertypes ETH_P_IP (v4) & ETH_P_IPV6 (v6).
This special handling can be enabled only for ethertypes ETH_P_IP & ETH_P_MPLS_UC
with a flag called multiproto mode.

Usage
------

1) Device creation & deletion

    a) ip link add dev bareudp0 type bareudp dstport 6635 ethertype 0x8847.

       This creates a bareudp tunnel device which tunnels L3 traffic with ethertype
       0x8847 (MPLS traffic). The destination port of the UDP header will be set to
       6635.The device will listen on UDP port 6635 to receive traffic.

    b) ip link delete bareudp0

2) Device creation with multiple proto mode enabled

There are two ways to create a bareudp device for MPLS & IP with multiproto mode
enabled.

    a) ip link add dev  bareudp0 type bareudp dstport 6635 ethertype 0x8847 multiproto

    b) ip link add dev  bareudp0 type bareudp dstport 6635 ethertype mpls

3) Device Usage

The bareudp device could be used along with OVS or flower filter in TC.
The OVS or TC flower layer must set the tunnel information in SKB dst field before
sending packet buffer to the bareudp device for transmission. On reception the
bareudp device extracts and stores the tunnel information in SKB dst field before
passing the packet buffer to the network stack.

Why not FOU ?
------------
FOU by design does l4 encapsulation.It maps udp port to ipproto (IP protocol number for l4 protocol).
Bareudp acheives a generic l3 encapsulation.It maps udp port to l3 ethertype.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: Special handling for IP & MPLS.
Martin Varghese [Mon, 24 Feb 2020 05:28:35 +0000 (10:58 +0530)]
net: Special handling for IP & MPLS.

Special handling is needed in bareudp module for IP & MPLS as they
support more than one ethertypes.

MPLS has 2 ethertypes. 0x8847 for MPLS unicast and 0x8848 for MPLS multicast.
While decapsulating MPLS packet from UDP packet the tunnel destination IP
address is checked to determine the ethertype. The ethertype of the packet
will be set to 0x8848 if the  tunnel destination IP address is a multicast
IP address. The ethertype of the packet will be set to 0x8847 if the
tunnel destination IP address is a unicast IP address.

IP has 2 ethertypes.0x0800 for IPV4 and 0x86dd for IPv6. The version
field of the IP header tunnelled will be checked to determine the ethertype.

This special handling to tunnel additional ethertypes will be disabled
by default and can be enabled using a flag called multiproto. This flag can
be used only with ethertypes 0x8847 and 0x0800.

Signed-off-by: Martin Varghese <martin.varghese@nokia.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: UDP tunnel encapsulation module for tunnelling different protocols like MPLS...
Martin Varghese [Mon, 24 Feb 2020 05:27:50 +0000 (10:57 +0530)]
net: UDP tunnel encapsulation module for tunnelling different protocols like MPLS, IP, NSH etc.

The Bareudp tunnel module provides a generic L3 encapsulation
tunnelling module for tunnelling different protocols like MPLS,
IP,NSH etc inside a UDP tunnel.

Signed-off-by: Martin Varghese <martin.varghese@nokia.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoaf_unix: Add missing annotation for unix_wait_for_peer()
Jules Irenge [Sun, 23 Feb 2020 23:16:56 +0000 (23:16 +0000)]
af_unix: Add missing annotation for unix_wait_for_peer()

Sparse reports a warning unix_wait_for_peer()

warning: context imbalance in unix_wait_for_peer() - unexpected unlock

The root cause is the missing annotation at unix_wait_for_peer()
Add the missing annotation __releases(&unix_sk(other)->lock)

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agodccp: Add missing annotation for dccp_child_process()
Jules Irenge [Sun, 23 Feb 2020 23:16:55 +0000 (23:16 +0000)]
dccp: Add missing annotation for dccp_child_process()

Sparse reports a warning at dccp_child_process()
warning: context imbalance in dccp_child_process() - unexpected unlock
The root cause is the missing annotation at dccp_child_process()
Add the missing __releases(child) annotation

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: netrom: Add missing annotation for nr_neigh_stop()
Jules Irenge [Sun, 23 Feb 2020 23:16:54 +0000 (23:16 +0000)]
net: netrom: Add missing annotation for nr_neigh_stop()

Sparse reports a warning at nr_neigh_stop()
warning: context imbalance in nr_neigh_stop() - unexpected unlock
The root cause is the missing annotation at nr_neigh_stop()
Add the missing __releases(&nr_neigh_list_lock) annotation

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: netrom: Add missing annotation for nr_neigh_start()
Jules Irenge [Sun, 23 Feb 2020 23:16:53 +0000 (23:16 +0000)]
net: netrom: Add missing annotation for nr_neigh_start()

Sparse reports a warning at nr_neigh_start()
warning: context imbalance in nr_neigh_start() - wrong count at exit
The root cause is the missing annotation at nr_neigh_start()
Add the missing __acquires(&nr_neigh_list_lock) annotation

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: netrom: Add missing annotation for nr_node_stop()
Jules Irenge [Sun, 23 Feb 2020 23:16:52 +0000 (23:16 +0000)]
net: netrom: Add missing annotation for nr_node_stop()

Sparse reports a warning at nr_node_stop()
warning: context imbalance in nr_node_stop() - wrong count at exit
The root cause is the missing annotation at nr_node_stop()
Add the missing __releases(&nr_node_list_lock) annotation

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: netrom: Add missing annotation for nr_node_start()
Jules Irenge [Sun, 23 Feb 2020 23:16:51 +0000 (23:16 +0000)]
net: netrom: Add missing annotation for nr_node_start()

Sparse reports a warning at nr_node_start()
warning: context imbalance in nr_node_start() - wrong count at exit
The root cause is the missing annotation at nr_node_start()
Add the missing __acquires(&nr_node_list_lock) annotation

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonetrom: Add missing annotation for nr_info_stop()
Jules Irenge [Sun, 23 Feb 2020 23:16:50 +0000 (23:16 +0000)]
netrom: Add missing annotation for nr_info_stop()

Sparse reports a warning at nr_info_stop()
warning: context imbalance in nr_info_stop() - unexpected unlock
The root cause is the missing annotation at nr_info_stop()
Add the missing __releases(&nr_list_lock)

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonetrom: Add missing annotation for nr_info_start()
Jules Irenge [Sun, 23 Feb 2020 23:16:49 +0000 (23:16 +0000)]
netrom: Add missing annotation for nr_info_start()

Sparse reports a warning at nr_info_start()
warning: context imbalance in nr_info_start() - wrong count at exit
The root cause is the missing annotation at nr_info_start()
Add the missing __acquires(&nr_list_lock)

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: Add missing annotation for llc_seq_start()
Jules Irenge [Sun, 23 Feb 2020 23:16:48 +0000 (23:16 +0000)]
net: Add missing annotation for llc_seq_start()

Sparse reports a warning at llc_seq_start()

warning: context imbalance in llc_seq_start() - wrong count at exit
The root cause is the msiing annotation at llc_seq_start()

Add the missing __acquires(RCU) annotation

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agosctp: Add missing annotation for sctp_transport_walk_stop()
Jules Irenge [Sun, 23 Feb 2020 23:16:47 +0000 (23:16 +0000)]
sctp: Add missing annotation for sctp_transport_walk_stop()

Sparse reports a warning at sctp_transport_walk_stop()

warning: context imbalance in sctp_transport_walk_stop
- wrong count at exit

The root cause is the missing annotation at sctp_transport_walk_stop()
Add the missing __releases(RCU) annotation

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agosctp: Add missing annotation for sctp_transport_walk_start()
Jules Irenge [Sun, 23 Feb 2020 23:16:46 +0000 (23:16 +0000)]
sctp: Add missing annotation for sctp_transport_walk_start()

Sparse reports a warning at sctp_transport_walk_start()

warning: context imbalance in sctp_transport_walk_start
- wrong count at exit

The root cause is the missing annotation at sctp_transport_walk_start()
Add the missing __acquires(RCU) annotation

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agosctp: Add missing annotation for sctp_err_finish()
Jules Irenge [Sun, 23 Feb 2020 23:16:45 +0000 (23:16 +0000)]
sctp: Add missing annotation for sctp_err_finish()

Sparse reports a warning at sctp_err_finish()
warning: context imbalance in sctp_err_finish() - unexpected unlock

The root cause is a missing annotation at sctp_err_finish()
Add the missing  __releases(&((__sk)->sk_lock.slock)) annotation

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoip6mr: Fix RCU list debugging warning
Amol Grover [Sat, 22 Feb 2020 16:57:27 +0000 (22:27 +0530)]
ip6mr: Fix RCU list debugging warning

ip6mr_for_each_table() macro uses list_for_each_entry_rcu()
for traversing outside an RCU read side critical section
but under the protection of rtnl_mutex. Hence add the
corresponding lockdep expression to silence the following
false-positive warnings:

[    4.319479] =============================
[    4.319480] WARNING: suspicious RCU usage
[    4.319482] 5.5.4-stable #17 Tainted: G            E
[    4.319483] -----------------------------
[    4.319485] net/ipv6/ip6mr.c:1243 RCU-list traversed in non-reader section!!

[    4.456831] =============================
[    4.456832] WARNING: suspicious RCU usage
[    4.456834] 5.5.4-stable #17 Tainted: G            E
[    4.456835] -----------------------------
[    4.456837] net/ipv6/ip6mr.c:1582 RCU-list traversed in non-reader section!!

Signed-off-by: Amol Grover <frextrite@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoptp: Add a ptp clock driver for IDT 82P33 SMU.
Min Li [Fri, 21 Feb 2020 20:03:51 +0000 (15:03 -0500)]
ptp: Add a ptp clock driver for IDT 82P33 SMU.

The IDT 82P33 Synchronization Management Unit (SMU) family provides
tools to manage timing references, clock sources and
timing paths for IEEE 1588 / Precision Time Protocol (PTP) and
Synchronous Ethernet (SyncE) based clocks. The device supports up
to three independent timing paths that control: PTP clock synthesis;
SyncE clock generation; and general purpose frequency translation.
The device supports physical layer timing with Digital PLLs (DPLLs)
and it supports packet based timing with Digitally Controlled
Oscillators (DCOs). This patch adds support for ptp clock based on
the device.

Changes since v1:
 - As suggested by Richard Cochran:
   1. Replace _mask_bit_count with the existing hweight8
   2. Prefix all functions with idt82p33
   3. Fix white space issues in Kconfig and Makefile
   4. Remove forward declaration
   5. Use adjfine instead of adjfreq for better resolution

 - As suggested by David Miller:
   1. Replace CHAN_INIT macro with a static function
      idt82p33_channel_init
   2. Employ reverse christmas tree ordering for local
      variables
   3. Fix indentation problem by appropriate number of
      TAB then SPACE character

Signed-off-by: Min Li <min.li.xe@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agodt-bindings: ptp: Add device tree binding for IDT 82P33 based PTP clock
Min Li [Fri, 21 Feb 2020 21:48:38 +0000 (16:48 -0500)]
dt-bindings: ptp: Add device tree binding for IDT 82P33 based PTP clock

Add device tree binding doc for the PTP clock based on IDT 82P33
Synchronization Management Unit (SMU).

Changes since v1:
 - As suggested by Rob Herring:
   1. Drop reg description for i2c
   2. Replace i2c@1 with i2c
   3. Add addtionalProperties: false

Signed-off-by: Min Li <min.li.xe@renesas.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agotcp: ipv4: Pass lockdep expression to RCU lists
Amol Grover [Fri, 21 Feb 2020 17:57:14 +0000 (23:27 +0530)]
tcp: ipv4: Pass lockdep expression to RCU lists

md5sig->head maybe traversed using hlist_for_each_entry_rcu
outside an RCU read-side critical section but under the protection
of socket lock.

Hence, add corresponding lockdep expression to silence false-positive
warnings, and harden RCU lists.

Signed-off-by: Amol Grover <frextrite@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: 802: psnap.c: Use built-in RCU list checking
Madhuparna Bhowmik [Fri, 21 Feb 2020 16:19:47 +0000 (21:49 +0530)]
net: 802: psnap.c: Use built-in RCU list checking

list_for_each_entry_rcu() has built-in RCU and lock checking.

Pass cond argument to list_for_each_entry_rcu() to silence
false lockdep warning when CONFIG_PROVE_RCU_LIST is enabled
by default.

Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agotcp, ulp: Pass lockdep expression to RCU lists
Amol Grover [Fri, 21 Feb 2020 15:15:38 +0000 (20:45 +0530)]
tcp, ulp: Pass lockdep expression to RCU lists

tcp_ulp_list is traversed using list_for_each_entry_rcu
outside an RCU read-side critical section but under the protection
of tcp_ulp_list_lock.

Hence, add corresponding lockdep expression to silence false-positive
warnings, and harden RCU lists.t

Signed-off-by: Amol Grover <frextrite@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'mlxsw-Introduce-ACL-traps'
David S. Miller [Mon, 24 Feb 2020 19:55:07 +0000 (11:55 -0800)]
Merge branch 'mlxsw-Introduce-ACL-traps'

Jiri Pirko says:

====================
mlxsw: Introduce ACL traps

This patchset allows to track packets that are dropped in HW by ACL.

Unlike the existing mlxsw traps, ACL traps are "source traps".
That means the action is not controlled by HPKT register but directly
in ACL TRAP action. When devlink user changes action from drop to trap
and vice versa, it would be needed to go over all instances of ACL TRAP
action and do change. That does not scale. Instead, resolve this
by introducing "dummy" group with "thin" policer. The purpose of
this policer is to drop as many packets as possible. The ones
that pass through are going to be dropped in devlink code - patch #6
takes care of that.

First four patches are preparation for introduction of ACL traps in mlxsw
so it possible to easily change from drop to trap for source traps
as well - by changing group to "dummy" and back.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoselftests: devlink_trap_acl_drops: Add ACL traps test
Jiri Pirko [Mon, 24 Feb 2020 07:35:58 +0000 (08:35 +0100)]
selftests: devlink_trap_acl_drops: Add ACL traps test

Add a test to check functionality of ACL traps.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoselftests: pass pref and handle to devlink_trap_drop_* helpers
Jiri Pirko [Mon, 24 Feb 2020 07:35:57 +0000 (08:35 +0100)]
selftests: pass pref and handle to devlink_trap_drop_* helpers

Currently the helpers assume pref 1 and handle 101. Make that explicit
and pass the values from callers.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoselftests: introduce test for mlxsw tc flower restrictions
Jiri Pirko [Mon, 24 Feb 2020 07:35:56 +0000 (08:35 +0100)]
selftests: introduce test for mlxsw tc flower restrictions

Include test of forbidding to have drop rule on mixed-bound
shared block.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_trap: Add ACL devlink-trap support
Jiri Pirko [Mon, 24 Feb 2020 07:35:55 +0000 (08:35 +0100)]
mlxsw: spectrum_trap: Add ACL devlink-trap support

Add the trap group used to report ACL drops. Setup the trap IDs for
ingress/egress flow action drop. Register the two packet traps
associated with ACL trap group with devlink during driver
initialization. As these are "source traps", set the disabled
trap group to be the dummy, discarding as many packets in HW
as possible.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_trap: Introduce dummy group with thin policer
Jiri Pirko [Mon, 24 Feb 2020 07:35:54 +0000 (08:35 +0100)]
mlxsw: spectrum_trap: Introduce dummy group with thin policer

For "source traps" it is not possible to change HPKT action to discard.
But there is still need to disallow packets arriving to CPU as much as
possible. Handle this by introduction of a "dummy group". It has a
"thin" policer, which passes as less packets to CPU as possible. The
rest is going to be discarded there. The "dummy group" is to be used
later on by ACL trap (which is a "source trap").

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: core: Extend MLXSW_RXL_DIS to register disabled trap group
Jiri Pirko [Mon, 24 Feb 2020 07:35:53 +0000 (08:35 +0100)]
mlxsw: core: Extend MLXSW_RXL_DIS to register disabled trap group

Extend the mlxsw_listener struct to contain trap group for disabled
traps too. Rename the original "trap_group" item to "en_trap_group" as
it represents enabled state. Let both groups be the same for MLXSW_RXL
however extend MLXSW_RXL_DIS to register separate groups for enable and
disable.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: core: Allow to enable/disable rx_listener for trap
Jiri Pirko [Mon, 24 Feb 2020 07:35:52 +0000 (08:35 +0100)]
mlxsw: core: Allow to enable/disable rx_listener for trap

For source traps, the "thin policer" is going to be used in order
to reduce the amount of trapped packets to minimum. However, there
will be still small number of packets coming in that need to be dropped
in the driver. Allow to enable/disable rx_listener related to specific
trap in order to prevent unwanted packets to go up the stack.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: acl_flex_actions: Trap all ACL dropped packets to DISCARD_*_ACL traps
Jiri Pirko [Mon, 24 Feb 2020 07:35:51 +0000 (08:35 +0100)]
mlxsw: acl_flex_actions: Trap all ACL dropped packets to DISCARD_*_ACL traps

Introduce a new set of traps:
DISCARD_INGRESS_ACL and DISCARD_EGRESS_ACL
Set the trap_action from NOP to TRAP which causes the packets dropped
by the TRAP action to be trapped under new trap IDs, depending on the
ingress/egress binding point.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_acl: Pass the ingress indication down to flex action
Jiri Pirko [Mon, 24 Feb 2020 07:35:50 +0000 (08:35 +0100)]
mlxsw: spectrum_acl: Pass the ingress indication down to flex action

The ACL flex action will have to know if it is in ingress or egress,
so it can use correct trap ID. Pass the ingress indication down to it.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_flower: Disable mixed bound blocks to contain action drop
Jiri Pirko [Mon, 24 Feb 2020 07:35:49 +0000 (08:35 +0100)]
mlxsw: spectrum_flower: Disable mixed bound blocks to contain action drop

Action drop is going to be tracked by two separate traps, one for
ingress and one for egress. Prepare for it and disallow the possibility
to have drop action in blocks which are bound to both ingress and
egress.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_acl: Track ingress and egress block bindings
Jiri Pirko [Mon, 24 Feb 2020 07:35:48 +0000 (08:35 +0100)]
mlxsw: spectrum_acl: Track ingress and egress block bindings

Count the number of ingress and egress block bindings. Use the egress
counter in "is_egress_bound" helper. Add couple of helpers to check
ingress and mixed bound.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agodevlink: add ACL generic packet traps
Jiri Pirko [Mon, 24 Feb 2020 07:35:47 +0000 (08:35 +0100)]
devlink: add ACL generic packet traps

Add packet traps that can report packets that were dropped during ACL
processing.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_trap: Prepare mlxsw_core_trap_action_set() to handle not only action
Jiri Pirko [Mon, 24 Feb 2020 07:35:46 +0000 (08:35 +0100)]
mlxsw: spectrum_trap: Prepare mlxsw_core_trap_action_set() to handle not only action

Rename function mlxsw_core_trap_action_set() to
mlxsw_core_trap_state_set() and pass bool enabled instead of action.
Figure out the action according to the enabled state there.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_trap: Use listener->en/dis_action instead of hard-coded values
Jiri Pirko [Mon, 24 Feb 2020 07:35:45 +0000 (08:35 +0100)]
mlxsw: spectrum_trap: Use listener->en/dis_action instead of hard-coded values

The listener fields en_action and dis_action now contain the actions to
be used for TRAP and DROP devlink trap actions. Use them directly
instead of the hard-coded values.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: core: Allow to register disabled traps using MLXSW_RXL_DIS
Jiri Pirko [Mon, 24 Feb 2020 07:35:44 +0000 (08:35 +0100)]
mlxsw: core: Allow to register disabled traps using MLXSW_RXL_DIS

Introduce a new macro MLXSW_RXL_DIS that allows to register listeners
as disabled. That allows that from now on, the "action" can be
understood always as "enabled action" and "unreg_action" as "disabled
action". Rename them and treat them accordingly.

Use the new macro for defining drops in spectrum_trap.c.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_trap: Set unreg_action to be SET_FW_DEFAULT
Jiri Pirko [Mon, 24 Feb 2020 07:35:43 +0000 (08:35 +0100)]
mlxsw: spectrum_trap: Set unreg_action to be SET_FW_DEFAULT

Currently it does not really matter if it is set to DISCARD or
SET_FW_DEFAULT because it is set only during unregister of the listener.
The unreg_action is going to be used for disabling the listener too, so
change to SET_FW_DEFAULT and ensure the HW is going to behave correctly.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'net-Clean-driver-module-and-FW-versions'
David S. Miller [Mon, 24 Feb 2020 19:24:57 +0000 (11:24 -0800)]
Merge branch 'net-Clean-driver-module-and-FW-versions'

Leon Romanovsky says:

====================
Clean driver, module and FW versions

Change log:
 v1:
  * Split all FW cleanups patches to separate patches
  * Fixed commit message
  * Deleted odd DRV_RELDATE
  * Added everyone from MAINTAINERS file
 v0: https://lore.kernel.org/netdev/20200220145855.255704-1-leon@kernel.org

This is first patchset to netdev (already sent RDMA [1] and arch/um [2])
in attempt to unify the version management for in-tree kernel code.
The patches follow already accepted ethtool change [3] to set as
a default linux kernel version.

It allows us to remove driver version and present to the users unified
picture of driver version, which is similar to default MODULE_VERSION().

As part of this series, I deleted various creative attempts to mark
absence of FW. There is no need to set "N/A" in ethtool ->fw_version
field and it is enough to do not set it.

1.
The code is compile tested and passes 0-day kbuild.
2.
The proposed changes are based on commit:
  2bb07f4e1d86 ("tc-testing: updated tdc tests for basic filter")
3.
WIP branch is [4].

[1] https://lore.kernel.org/linux-rdma/20200220071239.231800-1-leon@kernel.org/
[2] http://lists.infradead.org/pipermail/linux-um/2020-February/002913.html
[3] https://lore.kernel.org/linux-rdma/20200127072028.19123-1-leon@kernel.org/
[4] https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git/log/?h=ethtool
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/atheros: Clean atheros code from driver version
Leon Romanovsky [Mon, 24 Feb 2020 08:53:11 +0000 (10:53 +0200)]
net/atheros: Clean atheros code from driver version

Use linux kernel version for ethtool and module versions.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Acked-by: Chris Snook <chris.snook@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/arc: Delete driver version
Leon Romanovsky [Mon, 24 Feb 2020 08:53:10 +0000 (10:53 +0200)]
net/arc: Delete driver version

Drop constant driver version in favour of global linux kernel.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/aquantia: Delete module version
Leon Romanovsky [Mon, 24 Feb 2020 08:53:09 +0000 (10:53 +0200)]
net/aquantia: Delete module version

There is no need to keep module and driver versions in in-tree
kernel code.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/apm: Properly mark absence of FW
Leon Romanovsky [Mon, 24 Feb 2020 08:53:08 +0000 (10:53 +0200)]
net/apm: Properly mark absence of FW

There is no need to set "N/A" if FW is not available.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/apm: Remove useless driver version
Leon Romanovsky [Mon, 24 Feb 2020 08:53:07 +0000 (10:53 +0200)]
net/apm: Remove useless driver version

Delete module version in favor of global and unique linux kernel.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/amd: Remove useless driver version
Leon Romanovsky [Mon, 24 Feb 2020 08:53:06 +0000 (10:53 +0200)]
net/amd: Remove useless driver version

Convert AMD drivers to respect universal linux kernel version.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/amazon: Ensure that driver version is aligned to the linux kernel
Leon Romanovsky [Mon, 24 Feb 2020 08:53:05 +0000 (10:53 +0200)]
net/amazon: Ensure that driver version is aligned to the linux kernel

Upstream drivers are managed inside global repository and released all
together, this ensure that driver version is the same as linux kernel,
so update amazon drivers to properly reflect it.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/althera: Delete hardcoded driver version
Leon Romanovsky [Mon, 24 Feb 2020 08:53:04 +0000 (10:53 +0200)]
net/althera: Delete hardcoded driver version

Convert to use default version provided by ethtool.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/alteon: Properly report FW version
Leon Romanovsky [Mon, 24 Feb 2020 08:53:03 +0000 (10:53 +0200)]
net/alteon: Properly report FW version

The acenic driver assigns FW version in driver version field,
as part of cleanup driver version, set FW version properly.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/allwinner: Remove driver version
Leon Romanovsky [Mon, 24 Feb 2020 08:53:02 +0000 (10:53 +0200)]
net/allwinner: Remove driver version

There is no need in custom driver version for in-tree code.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/alacritech: Delete driver version
Leon Romanovsky [Mon, 24 Feb 2020 08:53:01 +0000 (10:53 +0200)]
net/alacritech: Delete driver version

Use standard variant of the driver version.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/agere: Delete unneeded driver version
Leon Romanovsky [Mon, 24 Feb 2020 08:53:00 +0000 (10:53 +0200)]
net/agere: Delete unneeded driver version

There is no need in driver version for in-tree kernel code.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/aeroflex: Don't assign FW if it is not available
Leon Romanovsky [Mon, 24 Feb 2020 08:52:59 +0000 (10:52 +0200)]
net/aeroflex: Don't assign FW if it is not available

If FW version is not available, it is enough to leave that field as
empty, there is no need to write N/A.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/aeroflex: Clean ethtool_info struct assignments
Leon Romanovsky [Mon, 24 Feb 2020 08:52:58 +0000 (10:52 +0200)]
net/aeroflex: Clean ethtool_info struct assignments

If FW version is not available, it is enough to leave that field as
empty, there is no need to write N/A.

The driver version is replaced in favor of generally available
in-tree variant.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/adaptec: Clean driver versions
Leon Romanovsky [Mon, 24 Feb 2020 08:52:57 +0000 (10:52 +0200)]
net/adaptec: Clean driver versions

Delete useless driver version in favor of default ones.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/3com: Delete driver and module versions from 3com drivers
Leon Romanovsky [Mon, 24 Feb 2020 08:52:56 +0000 (10:52 +0200)]
net/3com: Delete driver and module versions from 3com drivers

There is no need to mislead users by providing different versions for
driver, ethtool and modules. Delete driver assignments and let use
the default one.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/dummy: Ditch driver and module versions
Leon Romanovsky [Mon, 24 Feb 2020 08:52:55 +0000 (10:52 +0200)]
net/dummy: Ditch driver and module versions

Delete constant driver and module versions in favor of
standard global version which is unique to whole kernel.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/bond: Delete driver and module versions
Leon Romanovsky [Mon, 24 Feb 2020 08:52:54 +0000 (10:52 +0200)]
net/bond: Delete driver and module versions

The in-kernel code has already unique version, which is based
on Linus's tag, update the bond driver to be consistent with that
version.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: hns3: remove redundant initialization of pointer 'client'
Colin Ian King [Mon, 24 Feb 2020 19:20:22 +0000 (19:20 +0000)]
net: hns3: remove redundant initialization of pointer 'client'

The pointer 'client' is being initialized with a value that is never
read, it is being updated later on. 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 agonet/mlxfw: fix spelling mistake: "progamming" -> "programming"
Colin Ian King [Mon, 24 Feb 2020 15:21:01 +0000 (15:21 +0000)]
net/mlxfw: fix spelling mistake: "progamming" -> "programming"

There is a spelling mistake in a literal string. Fix it.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: Remove unneeded export of a couple of xdp generic functions
David Ahern [Fri, 21 Feb 2020 05:03:13 +0000 (22:03 -0700)]
net: Remove unneeded export of a couple of xdp generic functions

generic_xdp_tx and xdp_do_generic_redirect are only used by builtin
code, so remove the EXPORT_SYMBOL_GPL for them.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomac80211: Add api to support configuring TID specific configuration
Tamizh chelvam [Mon, 20 Jan 2020 07:51:27 +0000 (13:21 +0530)]
mac80211: Add api to support configuring TID specific configuration

Implement drv_set_tid_config api to allow TID specific
configuration and drv_reset_tid_config api to reset peer
specific TID configuration. This per-TID onfiguration
will be applied for all the connected stations when MAC is NULL.

Signed-off-by: Tamizh chelvam <tamizhr@codeaurora.org>
Link: https://lore.kernel.org/r/1579506687-18296-7-git-send-email-tamizhr@codeaurora.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
4 years agonl80211: Add support to configure TID specific RTSCTS configuration
Tamizh chelvam [Mon, 20 Jan 2020 07:51:25 +0000 (13:21 +0530)]
nl80211: Add support to configure TID specific RTSCTS configuration

This patch adds support to configure per TID RTSCTS control
configuration to enable/disable through the
NL80211_TID_CONFIG_ATTR_RTSCTS_CTRL attribute.

Signed-off-by: Tamizh chelvam <tamizhr@codeaurora.org>
Link: https://lore.kernel.org/r/1579506687-18296-5-git-send-email-tamizhr@codeaurora.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
4 years agonl80211: Add support to configure TID specific AMPDU configuration
Tamizh chelvam [Mon, 20 Jan 2020 07:51:24 +0000 (13:21 +0530)]
nl80211: Add support to configure TID specific AMPDU configuration

This patch adds support to configure per TID AMPDU control
configuration to enable/disable aggregation through the
NL80211_TID_CONFIG_ATTR_AMPDU_CTRL attribute.

Signed-off-by: Tamizh chelvam <tamizhr@codeaurora.org>
Link: https://lore.kernel.org/r/1579506687-18296-4-git-send-email-tamizhr@codeaurora.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
4 years agonl80211: Add support to configure TID specific retry configuration
Tamizh chelvam [Mon, 20 Jan 2020 07:51:23 +0000 (13:21 +0530)]
nl80211: Add support to configure TID specific retry configuration

This patch adds support to configure per TID retry configuration
through the NL80211_TID_CONFIG_ATTR_RETRY_SHORT and
NL80211_TID_CONFIG_ATTR_RETRY_LONG attributes. This TID specific
retry configuration will have more precedence than phy level
configuration.

Signed-off-by: Tamizh chelvam <tamizhr@codeaurora.org>
Link: https://lore.kernel.org/r/1579506687-18296-3-git-send-email-tamizhr@codeaurora.org
[rebase completely on top of my previous API changes]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
4 years agonl80211: modify TID-config API
Johannes Berg [Mon, 24 Feb 2020 10:34:25 +0000 (11:34 +0100)]
nl80211: modify TID-config API

Make some changes to the TID-config API:
 * use u16 in nl80211 (only, and restrict to using 8 bits for now),
   to avoid issues in the future if we ever want to use higher TIDs.
 * reject empty TIDs mask (via netlink policy)
 * change feature advertising to not use extended feature flags but
   have own mechanism for this, which simplifies the code
 * fix all variable names from 'tid' to 'tids' since it's a mask
 * change to cfg80211_ name prefixes, not ieee80211_
 * fix some minor docs/spelling things.

Change-Id: Ia234d464b3f914cdeab82f540e018855be580dce
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
4 years agonl80211: Add NL command to support TID speicific configurations
Tamizh chelvam [Mon, 20 Jan 2020 07:51:22 +0000 (13:21 +0530)]
nl80211: Add NL command to support TID speicific configurations

Add the new NL80211_CMD_SET_TID_CONFIG command to support
data TID specific configuration. Per TID configuration is
passed in the nested NL80211_ATTR_TID_CONFIG attribute.

This patch adds support to configure per TID noack policy
through the NL80211_TID_CONFIG_ATTR_NOACK attribute.

Signed-off-by: Tamizh chelvam <tamizhr@codeaurora.org>
Link: https://lore.kernel.org/r/1579506687-18296-2-git-send-email-tamizhr@codeaurora.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>