platform/kernel/linux-starfive.git
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 agoigmp: remove unused macro IGMP_Vx_UNSOLICITED_REPORT_INTERVAL
Li RongQing [Sun, 23 Feb 2020 08:05:43 +0000 (16:05 +0800)]
igmp: remove unused macro IGMP_Vx_UNSOLICITED_REPORT_INTERVAL

After commit 2690048c01f3 ("net: igmp: Allow user-space
configuration of igmp unsolicited report interval"), they
are not used now

Signed-off-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agotc-testing: updated tdc tests for basic filter with u32 extended match rules
Roman Mashak [Sun, 23 Feb 2020 19:12:36 +0000 (14:12 -0500)]
tc-testing: updated tdc tests for basic filter with u32 extended match rules

Signed-off-by: Roman Mashak <mrv@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agor8169: improve rtl8169_start_xmit
Heiner Kallweit [Sat, 22 Feb 2020 16:02:51 +0000 (17:02 +0100)]
r8169: improve rtl8169_start_xmit

Only call rtl8169_xmit_frags() if the skb is actually fragmented.
This avoid a small overhead for non-fragmented skb's, and it allows
to simplify rtl8169_xmit_frags() a little.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: ena: ethtool: remove redundant non-zero check on rc
Colin Ian King [Fri, 21 Feb 2020 23:26:53 +0000 (23:26 +0000)]
net: ena: ethtool: remove redundant non-zero check on rc

The non-zero check on rc is redundant as a previous non-zero
check on rc will always return and the second check is never
reached, hence it is redundant and can be removed.  Also
remove a blank line.

Addresses-Coverity: ("Logically dead code")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agotun: Remove unnecessary BUG_ON check in tun_net_xmit
David Ahern [Fri, 21 Feb 2020 19:53:09 +0000 (12:53 -0700)]
tun: Remove unnecessary BUG_ON check in tun_net_xmit

The BUG_ON for NULL tfile is now redundant due to a recently
added null check after the rcu_dereference. Remove the BUG_ON.

Cc: Jason Wang <jasowang@redhat.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'mlxsw-Cosmetic-fixes'
David S. Miller [Mon, 24 Feb 2020 00:07:31 +0000 (16:07 -0800)]
Merge branch 'mlxsw-Cosmetic-fixes'

Jiri Pirko says:

====================
mlxsw: Cosmetic fixes

This is a set of mainly action/trap related cosmetic fixes.
No functional changes.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: pci: Remove unused values
Ido Schimmel [Sun, 23 Feb 2020 07:31:44 +0000 (08:31 +0100)]
mlxsw: pci: Remove unused values

Since commit f3a52c6162f8 ("mlxsw: pci: Utilize MRSR register to perform
FW reset") the driver no longer issues a reset via the PCI BAR, so the
offset of the reset bit is unused. Remove it.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: core: Remove priv from listener equality comparison
Jiri Pirko [Sun, 23 Feb 2020 07:31:43 +0000 (08:31 +0100)]
mlxsw: core: Remove priv from listener equality comparison

During packet receive, only the first matching RX listener
in rx_listener_list is going to get the packet. So there is no
meaning in registering two equal listeners with different privs.
Remove priv from equality comparison and disable possibility
of doing 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_acl: Make block arg const where appropriate
Jiri Pirko [Sun, 23 Feb 2020 07:31:42 +0000 (08:31 +0100)]
mlxsw: spectrum_acl: Make block arg const where appropriate

There are couple of places where block pointer as a function argument
can be const. So make those const.

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: Make global arrays const as they should be
Jiri Pirko [Sun, 23 Feb 2020 07:31:41 +0000 (08:31 +0100)]
mlxsw: spectrum_trap: Make global arrays const as they should be

The global arrays are treated as const, they should be const, so make
them const.

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: Remove initialization to false of mlxsw_listener struct
Jiri Pirko [Sun, 23 Feb 2020 07:31:40 +0000 (08:31 +0100)]
mlxsw: core: Remove initialization to false of mlxsw_listener struct

No need to initialize to false, so remove 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: core: Convert is_event and is_ctrl bools to be single bits
Jiri Pirko [Sun, 23 Feb 2020 07:31:39 +0000 (08:31 +0100)]
mlxsw: core: Convert is_event and is_ctrl bools to be single bits

No need for these two flags to be bool. Covert them to bits of u8.

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: Remove dummy union name from struct mlxsw_listener
Jiri Pirko [Sun, 23 Feb 2020 07:31:38 +0000 (08:31 +0100)]
mlxsw: core: Remove dummy union name from struct mlxsw_listener

The dummy name for union is no longer needed, remove 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: core: Remove unused action field from mlxsw_rx_listener struct
Jiri Pirko [Sun, 23 Feb 2020 07:31:37 +0000 (08:31 +0100)]
mlxsw: core: Remove unused action field from mlxsw_rx_listener struct

Commit 0791051c43ef ("mlxsw: core: Create a generic function to
register / unregister traps") moved this field to struct mlxsw_listener,
but forgot to remove it from struct mlxsw_rx_listener.
Remove the unused field.

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: Move policer initialization to mlxsw_sp_trap_init()
Jiri Pirko [Sun, 23 Feb 2020 07:31:36 +0000 (08:31 +0100)]
mlxsw: spectrum_trap: Move policer initialization to mlxsw_sp_trap_init()

No need to initialize a single policer multiple times for each group.
So move the initialization to be done from mlxsw_sp_trap_init(), making
the function much simpler. Also, rename it so it is with sync with
spectrum.c policers initialization.

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: Rename Trap / Discard Action to Trap Action
Jiri Pirko [Sun, 23 Feb 2020 07:31:35 +0000 (08:31 +0100)]
mlxsw: core_acl_flex_actions: Rename Trap / Discard Action to Trap Action

The Trap / Discard Action action got renamed in PRM, so rename it in the
code as well.

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: Move functions to avoid their forward declarations
Jiri Pirko [Sun, 23 Feb 2020 07:31:34 +0000 (08:31 +0100)]
mlxsw: spectrum_trap: Move functions to avoid their forward declarations

No need to have forward declarations for mlxsw_sp_rx_drop_listener()
and mlxsw_sp_rx_exception_listener(). Just move them up and avoid 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_trap: Use err variable instead of directly checking func return value
Jiri Pirko [Sun, 23 Feb 2020 07:31:33 +0000 (08:31 +0100)]
mlxsw: spectrum_trap: Use err variable instead of directly checking func return value

When calling mlxsw_sp_rx_listener(), use err variable instead of directly
checking func return value.

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 agor8169: remove RTL_EVENT_NAPI constants
Heiner Kallweit [Fri, 21 Feb 2020 18:27:00 +0000 (19:27 +0100)]
r8169: remove RTL_EVENT_NAPI constants

These constants are used in one place only, so we can remove them and
use the values directly.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'mlxsw-Remove-RTNL-from-route-insertion-path'
David S. Miller [Sun, 23 Feb 2020 05:24:51 +0000 (21:24 -0800)]
Merge branch 'mlxsw-Remove-RTNL-from-route-insertion-path'

Ido Schimmel says:

====================
mlxsw: Remove RTNL from route insertion path

This patch set removes RTNL from the route insertion path in mlxsw in
order to reduce the control plane latency: the time it takes to push
routes from user space to the kernel and mlxsw.

Up until now mlxsw did not have a lock to protect its shared router data
structures and instead relied on RTNL. While this was simple and worked,
it resulted in large control plane latencies as RTNL was heavily
contended - by both the task receiving the netlink messages from user
space and the mlxsw workqueue that programs the routes to the device.

By removing RTNL and introducing a new router mutex, this patch set
reduces the control plane latency by ~80%. A single mutex is added as
inside mlxsw there is not a lot of concurrency. In addition, a more
fine-grained locking scheme is much more error-prone.

Patches #1-#6 are preparations. They add needed locking in NVE and
multicast routing code instead of relying on RTNL
Patch #7 introduces the new mutex
Patches #8-#12 gradually take the lock in various entry points into the
routing code
Patch #13 removes RTNL in places where it is no longer required
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum: Remove RTNL where possible
Ido Schimmel [Fri, 21 Feb 2020 17:54:15 +0000 (19:54 +0200)]
mlxsw: spectrum: Remove RTNL where possible

After introducing the router lock in previous patches and making sure it
protects internal router structures, we no longer need to rely on RTNL
to serialize access to these structures.

Remove RTNL from call sites that no longer require it.

Two calls sites that keep taking the lock are
mlxsw_sp_router_fibmr_event_work() and mlxsw_sp_inet6addr_event_work().
The first calls into ACL code that still assumes RTNL is taken. The
second potentially calls into the FID code that also relies on RTNL.
Removing RTNL from these two call sites is the subject of future work.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_router: Take router lock from exported helpers
Ido Schimmel [Fri, 21 Feb 2020 17:54:14 +0000 (19:54 +0200)]
mlxsw: spectrum_router: Take router lock from exported helpers

The routing code exports some helper functions that can be called from
other driver modules such as the bridge. These helpers are never called
with the router lock already held and therefore need to take it in order
to serialize access to shared router structures.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_router: Take router lock from inetaddr listeners
Ido Schimmel [Fri, 21 Feb 2020 17:54:13 +0000 (19:54 +0200)]
mlxsw: spectrum_router: Take router lock from inetaddr listeners

Another entry point into the routing code is from inetaddr listeners.
The driver registers listeners to IPv4 and IPv6 inetaddr notification
chains in order to understand when a RIF needs to be created or
destroyed.

Serialize access to shared router structures from these listeners by
taking the router lock when processing inetaddr events.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_router: Take router lock from netdev listener
Ido Schimmel [Fri, 21 Feb 2020 17:54:12 +0000 (19:54 +0200)]
mlxsw: spectrum_router: Take router lock from netdev listener

One entry point into the routing code is from the netdev listener block.
Some netdev events require access to internal router structures. For
example, changing the MTU of a netdev requires looking-up the backing
RIF and adjusting its MTU.

In order to serialize access to shared router structures, take the
router lock when processing netdev events that require access to it.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_dpipe: Take router lock from dpipe code
Ido Schimmel [Fri, 21 Feb 2020 17:54:11 +0000 (19:54 +0200)]
mlxsw: spectrum_dpipe: Take router lock from dpipe code

The dpipe code traverses internal router structures such as neighbours
and adjacency entries and dumps them to user space via netlink. Up until
now the routing code did not have its own locks and relied on RTNL lock
to serialize access. This is going to change with the introduction of
the router lock.

Take the router lock in the code paths where RTNL lock is currently
taken so that the latter could be removed by subsequent patches.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_router: Take router lock from inside routing code
Ido Schimmel [Fri, 21 Feb 2020 17:54:10 +0000 (19:54 +0200)]
mlxsw: spectrum_router: Take router lock from inside routing code

There are several work items in the routing code that currently rely on
RTNL lock to guard against concurrent changes. Have these work items
acquire the router lock in preparation for the removal for RTNL lock
from the routing code.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_router: Introduce router lock
Ido Schimmel [Fri, 21 Feb 2020 17:54:09 +0000 (19:54 +0200)]
mlxsw: spectrum_router: Introduce router lock

Introduce a mutex to protect the internal structure of the routing code.
A single lock is added instead of a more fine-grained and complicated
locking scheme because there is not a lot of concurrency in the routing
code.

The main motivation is remove the dependence on RTNL lock, which is
currently used by both the process pushing routes to the kernel and the
workqueue pushing the routes to the underlying device.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_router: Store NVE decapsulation configuration in router
Ido Schimmel [Fri, 21 Feb 2020 17:54:08 +0000 (19:54 +0200)]
mlxsw: spectrum_router: Store NVE decapsulation configuration in router

When a host route is added, the driver checks if the route needs to be
promoted to perform NVE decapsulation based on the current NVE
configuration. If so, the index of the decapsulation entry is retrieved
and associated with the route.

Currently, this information is stored in the NVE module which the router
module consults. Since the information is protected under RTNL and since
route insertion happens with RTNL held, there is no problem to retrieve
the information from the NVE module.

However, this is going to change and route insertion will no longer
happen under RTNL. Instead, a dedicated lock will be introduced for the
router module.

Therefore, store this information in the router module and change the
router module to consult this copy.

The validity of the information is set / cleared whenever an NVE tunnel
is initialized / de-initialized. When this happens the NVE module calls
into the router module to promote / demote the relevant host route.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_router: Expose router struct to internal users
Ido Schimmel [Fri, 21 Feb 2020 17:54:07 +0000 (19:54 +0200)]
mlxsw: spectrum_router: Expose router struct to internal users

The dpipe code accesses internal router data structures and acquires
RTNL to protect against their changes. Subsequent patches will remove
reliance on RTNL and introduce a dedicated lock to protect router data
structures.

Publish the router struct to internal users such as the dpipe, so that
they could acquire it instead of RTNL.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_mr: Protect multicast route list with a lock
Ido Schimmel [Fri, 21 Feb 2020 17:54:06 +0000 (19:54 +0200)]
mlxsw: spectrum_mr: Protect multicast route list with a lock

Protect the per-table multicast route list with a lock and remove RTNL
from the delayed work that periodically updates the kernel about packets
and bytes statistics from each multicast route.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_mr: Protect multicast table list with a lock
Ido Schimmel [Fri, 21 Feb 2020 17:54:05 +0000 (19:54 +0200)]
mlxsw: spectrum_mr: Protect multicast table list with a lock

The multicast table list is traversed from a delayed work that
periodically updates the kernel about packets and bytes statistics from
each multicast route.

The list is currently protected by RTNL, but subsequent patches will
remove the driver's dependence on this contended lock.

In order to be able to remove dependence on RTNL in the next patch,
guard this list with a dedicated mutex.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agomlxsw: spectrum_mr: Publish multicast route after writing it to the device
Ido Schimmel [Fri, 21 Feb 2020 17:54:04 +0000 (19:54 +0200)]
mlxsw: spectrum_mr: Publish multicast route after writing it to the device

The driver periodically traverses the linked list of multicast routes
and updates the kernel about packets and bytes statistics from each
multicast route. These statistics are read from a counter associated
with the route when it is written to the device.

Currently, multicast routes are published via this linked list before
they are associated with a counter. Despite that, it is not possible for
the driver to access an invalid counter because the delayed work that
reads the statistics and multicast route addition / deletion are
mutually exclusive using RTNL.

In order to be able to remove RTNL, the list needs to be protected by a
dedicated lock, but any route published via the list must have an
associated counter, otherwise the driver will access an invalid counter.

Solve this by re-ordering the operations during multicast route addition
so that the route is only added to the linked list after it was written
to the device. Similarly, during deletion the route is first removed
from the linked list before its deletion from the device.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'mlxfw-Improve-error-reporting-and-FW-reactivate-support'
David S. Miller [Fri, 21 Feb 2020 23:41:10 +0000 (15:41 -0800)]
Merge branch 'mlxfw-Improve-error-reporting-and-FW-reactivate-support'

Saeed Mahameed says:

====================
mlxfw: Improve error reporting and FW reactivate support

This patchset improves mlxfw error reporting to netlink and to
kernel log.

V2:
 - Use proper err codes, EBUSY/EIO instead of EALREADY/EREMOTEIO
 - Fix typo.

From Eran and me.

1) patch #1, Make mlxfw/mlxsw fw flash devlink status notify generic,
   and enable it for mlx5.

2) patches #2..#5 are improving mlxfw flash error messages by
reporting detailed mlxfw FSM error messages to netlink and kernel log.

3) patches #6,7 From Eran: Add FW reactivate flow to  mlxfw and mlx5
====================

Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/mlx5: Add fsm_reactivate callback support
Eran Ben Elisha [Fri, 21 Feb 2020 21:46:12 +0000 (21:46 +0000)]
net/mlx5: Add fsm_reactivate callback support

Add support for fsm reactivate via MIRC (Management Image Re-activation
Control) set and query commands.
For re-activation flow, driver shall first run MIRC set, and then wait
until FW is done (via querying MIRC status).

Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/mlxfw: Add reactivate flow support to FSM burn flow
Eran Ben Elisha [Fri, 21 Feb 2020 21:46:09 +0000 (21:46 +0000)]
net/mlxfw: Add reactivate flow support to FSM burn flow

Expose fsm_reactivate callback to the mlxfw_dev_ops struct. FSM reactivate
is needed before flashing the new image in order to flush the old flashed
but not running firmware image.

In case mlxfw_dev do not support the reactivation, this step will be
skipped. But if later image flash will fail, a hint will be provided by
the extack to advise the user that the failure might be related to it.

Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/mlxfw: Use MLXFW_ERR_MSG macro for error reporting
Saeed Mahameed [Fri, 21 Feb 2020 21:46:07 +0000 (21:46 +0000)]
net/mlxfw: Use MLXFW_ERR_MSG macro for error reporting

Instead of always calling both mlxfw_err and NL_SET_ERR_MSG_MOD with the
same message, use the dedicated macro instead.

Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>