linux-2.6-microblaze.git
3 years agomlxsw: reg: Allow to pass NULL pointer to mlxsw_reg_ralue_pack4/6()
Jiri Pirko [Tue, 10 Nov 2020 09:48:53 +0000 (11:48 +0200)]
mlxsw: reg: Allow to pass NULL pointer to mlxsw_reg_ralue_pack4/6()

In preparation for the change that is going to be done in the next
patch, allow to pass NULL pointer to mlxsw_reg_ralue_pack4() and
mlxsw_reg_ralue_pack6() helpers.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agomlxsw: spectrum_router: Pass destination IP as a pointer to mlxsw_reg_ralue_pack4()
Jiri Pirko [Tue, 10 Nov 2020 09:48:52 +0000 (11:48 +0200)]
mlxsw: spectrum_router: Pass destination IP as a pointer to mlxsw_reg_ralue_pack4()

Instead of passing destination IP as a u32 value, pass it as pointer to
u32. Avoid using local variable for the pointer store.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agomlxsw: spectrum: Export RALUE pack helper and use it from IPIP
Jiri Pirko [Tue, 10 Nov 2020 09:48:51 +0000 (11:48 +0200)]
mlxsw: spectrum: Export RALUE pack helper and use it from IPIP

As the RALUE packing is going to be put into op, make the user from
IPIP code use the same helper as the router code does.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agomlxsw: spectrum_router: Push out RALUE pack into separate helper
Jiri Pirko [Tue, 10 Nov 2020 09:48:50 +0000 (11:48 +0200)]
mlxsw: spectrum_router: Push out RALUE pack into separate helper

As the RALUE packing is going to be pushed into an op, in preparation
for that push the code into a separate function in the meantime.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agomlxsw: spectrum: Propagate context from work handler containing RALUE payload
Jiri Pirko [Tue, 10 Nov 2020 09:48:49 +0000 (11:48 +0200)]
mlxsw: spectrum: Propagate context from work handler containing RALUE payload

Currently, RALUE payload is defined locally in the function that is
calling the register write. With introduction of alternative register to
RALUE, XMDR, it has to be possible to put multiple FIB entry
operations into single register write.

So in order to prepare for that, have per-work entry operation context
and propagate it all the way down to the functions writing RALUE.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agomlxsw: spectrum_router: Introduce FIB event queue instead of separate works
Jiri Pirko [Tue, 10 Nov 2020 09:48:48 +0000 (11:48 +0200)]
mlxsw: spectrum_router: Introduce FIB event queue instead of separate works

Currently, every FIB event is queued-up as a separate work to be
processed. However, that allows to process only one FIB entry per work
callback.

In preparation of future XMDR register bulking of multiple FIB entries,
convert to FIB event queue. Implement this by a list_head, adding new
events to the end of the list in the FIB notify callback. That allows to
process multiple events from the list inside the work callback.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agomlxsw: spectrum_router: Use RALUE-independent op arg
Jiri Pirko [Tue, 10 Nov 2020 09:48:47 +0000 (11:48 +0200)]
mlxsw: spectrum_router: Use RALUE-independent op arg

Since the write/delete of FIB entry is going to be implemented by XMDR
register for XM implementation, introduce RALUE-independent enum for op
so the enum could be used in both RALUE and XMDR.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agomlxsw: spectrum_router: Pass non-register proto enum to __mlxsw_sp_router_set_abort_t...
Jiri Pirko [Tue, 10 Nov 2020 09:48:46 +0000 (11:48 +0200)]
mlxsw: spectrum_router: Pass non-register proto enum to __mlxsw_sp_router_set_abort_trap()

Don't pass RALXX register enum and rather pass enum mlxsw_sp_l3proto
to __mlxsw_sp_router_set_abort_trap(). This is in preparation to fib
entry pack implementation by XMDR register.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: kcov: don't select SKB_EXTENSIONS when there is no NET
Randy Dunlap [Tue, 10 Nov 2020 17:57:46 +0000 (09:57 -0800)]
net: kcov: don't select SKB_EXTENSIONS when there is no NET

Fix kconfig warning when CONFIG_NET is not set/enabled:

WARNING: unmet direct dependencies detected for SKB_EXTENSIONS
  Depends on [n]: NET [=n]
  Selected by [y]:
  - KCOV [=y] && ARCH_HAS_KCOV [=y] && (CC_HAS_SANCOV_TRACE_PC [=y] || GCC_PLUGINS [=n])

Fixes: 6370cc3bbd8a ("net: add kcov handle to skb extensions")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Aleksandr Nogikh <nogikh@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/20201110175746.11437-1-rdunlap@infradead.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoMerge branch 'net-switch-further-drivers-to-core-functionality-for-handling-per-cpu...
Jakub Kicinski [Thu, 12 Nov 2020 22:58:27 +0000 (14:58 -0800)]
Merge branch 'net-switch-further-drivers-to-core-functionality-for-handling-per-cpu-byte-packet-counters'

Heiner Kallweit says:

====================
net: switch further drivers to core functionality for handling per-cpu byte/packet counters

Switch further drivers to core functionality for handling per-cpu
byte/packet counters. All changes are compile-tested only.
====================

Link: https://lore.kernel.org/r/5fbe3a1f-6625-eadc-b1c9-f76f78debb94@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: usb: switch to dev_get_tstats64 and remove usbnet_get_stats64 alias
Heiner Kallweit [Tue, 10 Nov 2020 19:51:03 +0000 (20:51 +0100)]
net: usb: switch to dev_get_tstats64 and remove usbnet_get_stats64 alias

Replace usbnet_get_stats64() with new identical core function
dev_get_tstats64() in all users and remove usbnet_get_stats64().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agousbnet: switch to core handling of rx/tx byte/packet counters
Heiner Kallweit [Tue, 10 Nov 2020 19:50:02 +0000 (20:50 +0100)]
usbnet: switch to core handling of rx/tx byte/packet counters

Use netdev->tstats instead of a member of usbnet for storing a pointer
to the per-cpu counters. This allows us to use core functionality for
statistics handling.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoqtnfmac: switch to core handling of rx/tx byte/packet counters
Heiner Kallweit [Tue, 10 Nov 2020 19:48:54 +0000 (20:48 +0100)]
qtnfmac: switch to core handling of rx/tx byte/packet counters

Use netdev->tstats instead of a member of qtnf_vif for storing a pointer
to the per-cpu counters. This allows us to use core functionality for
statistics handling.
The driver sets netdev->needs_free_netdev, therefore freeing the per-cpu
counters at the right point in time is a little bit tricky. Best option
seems to be to use the ndo_init/ndo_uninit callbacks.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoqmi_wwan: switch to core handling of rx/tx byte/packet counters
Heiner Kallweit [Tue, 10 Nov 2020 19:48:14 +0000 (20:48 +0100)]
qmi_wwan: switch to core handling of rx/tx byte/packet counters

Use netdev->tstats instead of a member of qmimux_priv for storing
a pointer to the per-cpu counters. This allows us to use core
functionality for statistics handling.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoIB/hfi1: switch to core handling of rx/tx byte/packet counters
Heiner Kallweit [Tue, 10 Nov 2020 19:47:34 +0000 (20:47 +0100)]
IB/hfi1: switch to core handling of rx/tx byte/packet counters

Use netdev->tstats instead of a member of hfi1_ipoib_dev_priv for storing
a pointer to the per-cpu counters. This allows us to use core
functionality for statistics handling.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipconfig: Avoid spurious blank lines in boot log
Thierry Reding [Tue, 10 Nov 2020 07:37:57 +0000 (08:37 +0100)]
net: ipconfig: Avoid spurious blank lines in boot log

When dumping the name and NTP servers advertised by DHCP, a blank line
is emitted if either of the lists is empty. This can lead to confusing
issues such as the blank line getting flagged as warning. This happens
because the blank line is the result of pr_cont("\n") and that may see
its level corrupted by some other driver concurrently writing to the
console.

Fix this by making sure that the terminating newline is only emitted
if at least one entry in the lists was printed before.

Reported-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20201110073757.1284594-1-thierry.reding@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoMerge branch 'smsc-w-1-warning-fixes'
Jakub Kicinski [Thu, 12 Nov 2020 22:49:42 +0000 (14:49 -0800)]
Merge branch 'smsc-w-1-warning-fixes'

Andrew Lunn says:

====================
smsc W=1 warning fixes

Fixup various W=1 warnings, and then add COMPILE_TEST support, which
explains why these where missed on the previous pass.

v2:
Use while (0)
Rework buffer alignment to make it clearer

v3:
Access the length from the hardware and Use __always_unused to tell the
compiler we want to discard the value.
====================

Link: https://lore.kernel.org/r/20201110030248.1480413-1-andrew@lunn.ch
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agodrivers: net: smsc: Add COMPILE_TEST support
Andrew Lunn [Tue, 10 Nov 2020 03:02:48 +0000 (04:02 +0100)]
drivers: net: smsc: Add COMPILE_TEST support

Improve the build testing of these SMSC drivers by enabling them when
COMPILE_TEST is selected.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agodrivers: net: smc911x: Fix cast from pointer to integer of different size
Andrew Lunn [Tue, 10 Nov 2020 03:02:47 +0000 (04:02 +0100)]
drivers: net: smc911x: Fix cast from pointer to integer of different size

drivers/net/ethernet/smsc/smc911x.c: In function ‘smc911x_hardware_send_pkt’:
drivers/net/ethernet/smsc/smc911x.c:471:11: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  471 |  cmdA = (((u32)skb->data & 0x3) << 16) |

When built on 64bit targets, the skb->data pointer cannot be cast to a
u32 in a meaningful way. Use uintptr_t instead.

Suggested-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agodrivers: net: smc911x: Fix passing wrong number of parameters to DBG() macro
Andrew Lunn [Tue, 10 Nov 2020 03:02:46 +0000 (04:02 +0100)]
drivers: net: smc911x: Fix passing wrong number of parameters to DBG() macro

Now that the compiler always sees the parameters passed to the DBG()
macro, it gives an error message about wrong parameters. The comment
says it all:

/* ndev is not valid yet, so avoid passing it in. */
DBG(SMC_DEBUG_FUNC, "--> %s\n",  __func__);

You cannot not just pass a parameter!

The DBG does not seem to have any real value, to just remove it.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agodrivers: net: smc911x: Fix set but unused status because of DBG macro
Andrew Lunn [Tue, 10 Nov 2020 03:02:45 +0000 (04:02 +0100)]
drivers: net: smc911x: Fix set but unused status because of DBG macro

drivers/net/ethernet/smsc/smc911x.c: In function ‘smc911x_timeout’:
drivers/net/ethernet/smsc/smc911x.c:1251:6: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
 1251 |  int status, mask;

The status is read in order to print it via the DBG macro. However,
due to the way DBG is disabled, the compiler never sees it being used.

Change the DBG macro to actually make use of the passed parameters,
and the leave the optimiser to remove the unwanted code inside the
while (0).

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agodrivers: net: smc911x: Work around set but unused status
Andrew Lunn [Tue, 10 Nov 2020 03:02:44 +0000 (04:02 +0100)]
drivers: net: smc911x: Work around set but unused status

drivers/net/ethernet/smsc/smc911x.c: In function ‘smc911x_phy_interrupt’:
drivers/net/ethernet/smsc/smc911x.c:976:6: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
  976 |  int status;

A comment indicates the status needs to be read from the PHY,
otherwise bad things happen. But due to the macro magic, it is hard to
perform the read without assigning it to a variable. So add
_always_unused attribute to status to tell the compiler we don't
expect to use the value.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agodrivers: net: smc91x: Fix missing kerneldoc reported by W=1
Andrew Lunn [Tue, 10 Nov 2020 03:02:43 +0000 (04:02 +0100)]
drivers: net: smc91x: Fix missing kerneldoc reported by W=1

drivers/net/ethernet/smsc/smc91x.c:2199: warning: Function parameter or member 'dev' not described in 'try_toggle_control_gpio'
drivers/net/ethernet/smsc/smc91x.c:2199: warning: Function parameter or member 'desc' not described in 'try_toggle_control_gpio'
drivers/net/ethernet/smsc/smc91x.c:2199: warning: Function parameter or member 'name' not described in 'try_toggle_control_gpio'
drivers/net/ethernet/smsc/smc91x.c:2199: warning: Function parameter or member 'index' not described in 'try_toggle_control_gpio'
drivers/net/ethernet/smsc/smc91x.c:2199: warning: Function parameter or member 'value' not described in 'try_toggle_control_gpio'
drivers/net/ethernet/smsc/smc91x.c:2199: warning: Function parameter or member 'nsdelay' not described in 'try_toggle_control_gpio'

Document these parameters.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agodrivers: net: smc91x: Fix set but unused W=1 warning
Andrew Lunn [Tue, 10 Nov 2020 03:02:42 +0000 (04:02 +0100)]
drivers: net: smc91x: Fix set but unused W=1 warning

drivers/net/ethernet/smsc/smc91x.c:706:51: warning: variable ‘pkt_len’ set but not used [-Wunused-but-set-variable]
  706 |  unsigned int saved_packet, packet_no, tx_status, pkt_len;

The read of the packet length in the descriptor probably needs to be
kept in order to keep the hardware happy. So tell the compiler we
don't expect to use the value by using the __always_unused attribute.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: udp: remove redundant initialization in udp_gro_complete
Menglong Dong [Tue, 10 Nov 2020 02:57:58 +0000 (21:57 -0500)]
net: udp: remove redundant initialization in udp_gro_complete

The initialization for 'err' with '-ENOSYS' is redundant and
can be removed, as it is updated soon and not used.

Changes since v1:
- Move the err declaration below struct sock *sk

Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
Link: https://lore.kernel.org/r/5faa01d5.1c69fb81.8451c.cb5b@mx.google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoMerge branch 'xilinx_emaclite-w-1-fixes'
Jakub Kicinski [Thu, 12 Nov 2020 22:33:13 +0000 (14:33 -0800)]
Merge branch 'xilinx_emaclite-w-1-fixes'

Andrew Lunn says:

====================
xilinx_emaclite W=1 fixes

kerneldoc, pointer issues, and add COMPILE_TEST support to easy
finding future issues via build testing.

v2:
 - Use uintptr_t instead of long
 - Added Acked-by's.
====================

Link: https://lore.kernel.org/r/20201110024024.1479741-1-andrew@lunn.ch
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agodrivers: net: xilinx_emaclite: Add COMPILE_TEST support
Andrew Lunn [Tue, 10 Nov 2020 02:40:24 +0000 (03:40 +0100)]
drivers: net: xilinx_emaclite: Add COMPILE_TEST support

To improve build testing of this driver, add COMPILE_TEST support.

Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agodrivers: net: xilinx_emaclite: Fix -Wpointer-to-int-cast warnings with W=1
Andrew Lunn [Tue, 10 Nov 2020 02:40:23 +0000 (03:40 +0100)]
drivers: net: xilinx_emaclite: Fix -Wpointer-to-int-cast warnings with W=1

drivers/net/ethernet//xilinx/xilinx_emaclite.c:341:35: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  341 |   addr = (void __iomem __force *)((u32 __force)addr ^

Use uintptr_t instead of u32 to avoid problems on 64 bit systems.

Also, cast the address to an unsigned long for printing.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agodrivers: net: xilinx_emaclite: Add missing parameter kerneldoc
Andrew Lunn [Tue, 10 Nov 2020 02:40:22 +0000 (03:40 +0100)]
drivers: net: xilinx_emaclite: Add missing parameter kerneldoc

The txqueue parameter to the watchdog callback is unused in this
driver. But it still needs to be documented.

Reviewed-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonfp: Fix passing zero to 'PTR_ERR'
YueHaibing [Thu, 12 Nov 2020 14:58:52 +0000 (22:58 +0800)]
nfp: Fix passing zero to 'PTR_ERR'

nfp_cpp_from_nfp6000_pcie() returns ERR_PTR() and never returns
NULL. The NULL test should be removed, also return correct err.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Link: https://lore.kernel.org/r/20201112145852.6580-1-yuehaibing@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoMerge branch 'selftests-pmtu-sh-improve-the-test-result-processing'
Jakub Kicinski [Thu, 12 Nov 2020 15:56:32 +0000 (07:56 -0800)]
Merge branch 'selftests-pmtu-sh-improve-the-test-result-processing'

Po-Hsu Lin says:

====================
selftests: pmtu.sh: improve the test result processing

The pmtu.sh test script treats all non-zero return code as a failure,
thus it will be marked as FAILED when some sub-test got skipped.

This patchset will:
  1. Use the kselftest framework skip code $ksft_skip to replace the
     hardcoded SKIP return code.
  2. Improve the result processing, the test will be marked as PASSED
     if nothing goes wrong and not all the tests were skipped.
====================

Link: https://lore.kernel.org/r/20201110020049.6705-1-po-hsu.lin@canonical.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoselftests: pmtu.sh: improve the test result processing
Po-Hsu Lin [Tue, 10 Nov 2020 02:00:49 +0000 (10:00 +0800)]
selftests: pmtu.sh: improve the test result processing

This test will treat all non-zero return codes as failures, it will
make the pmtu.sh test script being marked as FAILED when some
sub-test got skipped.

Improve the result processing by
  * Only mark the whole test script as SKIP when all of the
    sub-tests were skipped
  * If the sub-tests were either passed or skipped, the overall
    result will be PASS
  * If any of them has failed with return code 1 or anything bad
    happened (e.g. return code 127 for command not found), the
    overall result will be FAIL

Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoselftests: pmtu.sh: use $ksft_skip for skipped return code
Po-Hsu Lin [Tue, 10 Nov 2020 02:00:48 +0000 (10:00 +0800)]
selftests: pmtu.sh: use $ksft_skip for skipped return code

This test uses return code 2 as a hard-coded skipped state, let's use
the kselftest framework skip code variable $ksft_skip instead to make
it more readable and easier to maintain.

Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agomptcp: fix static checker warnings in mptcp_pm_add_timer
Geliang Tang [Tue, 10 Nov 2020 03:01:43 +0000 (11:01 +0800)]
mptcp: fix static checker warnings in mptcp_pm_add_timer

Fix the following Smatch complaint:

     net/mptcp/pm_netlink.c:213 mptcp_pm_add_timer()
     warn: variable dereferenced before check 'msk' (see line 208)

 net/mptcp/pm_netlink.c
    207          struct mptcp_sock *msk = entry->sock;
    208          struct sock *sk = (struct sock *)msk;
    209          struct net *net = sock_net(sk);
                                           ^^
 "msk" dereferenced here.

    210
    211          pr_debug("msk=%p", msk);
    212
    213          if (!msk)
                    ^^^^
 Too late.

    214                  return;
    215

Fixes: 93f323b9cccc ("mptcp: add a new sysctl add_addr_timeout")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Link: https://lore.kernel.org/r/078a2ef5bdc4e3b2c25ef852461692001f426495.1604976945.git.geliangtang@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: dsa: mv88e6xxx: Add helper to get a chip's max_vid
Tobias Waldekranz [Tue, 10 Nov 2020 18:57:20 +0000 (19:57 +0100)]
net: dsa: mv88e6xxx: Add helper to get a chip's max_vid

Most of the other chip info constants have helpers to get at them; add
one for max_vid to keep things consistent.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20201110185720.18228-1-tobias@waldekranz.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoipv4: Set nexthop flags in a more consistent way
Ido Schimmel [Tue, 10 Nov 2020 10:25:53 +0000 (12:25 +0200)]
ipv4: Set nexthop flags in a more consistent way

Be more consistent about the way in which the nexthop flags are set and
set them in one go.

Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20201110102553.1924232-1-idosch@idosch.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agodrivers: net: sky2: Fix -Wstringop-truncation with W=1
Andrew Lunn [Tue, 10 Nov 2020 02:32:22 +0000 (03:32 +0100)]
drivers: net: sky2: Fix -Wstringop-truncation with W=1

In function ‘strncpy’,
    inlined from ‘sky2_name’ at drivers/net/ethernet/marvell/sky2.c:4903:3,
    inlined from ‘sky2_probe’ at drivers/net/ethernet/marvell/sky2.c:5049:2:
./include/linux/string.h:297:30: warning: ‘__builtin_strncpy’ specified bound 16 equals destination size [-Wstringop-truncation]

None of the device names are 16 characters long, so it was never an
issue. But replace the strncpy with an snprintf() to prevent the
theoretical overflow.

Suggested-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Link: https://lore.kernel.org/r/20201110023222.1479398-1-andrew@lunn.ch
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoMAINTAINERS: Add entry for Hirschmann Hellcreek Switch Driver
Kurt Kanzenbach [Tue, 10 Nov 2020 07:18:29 +0000 (08:18 +0100)]
MAINTAINERS: Add entry for Hirschmann Hellcreek Switch Driver

Add myself to cover the Hirschmann Hellcreek TSN Ethernet Switch Driver.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Link: https://lore.kernel.org/r/20201110071829.7467-1-kurt@linutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoMerge branch 'net-evaluate-net-ipvX-conf-all-sysctls'
Jakub Kicinski [Thu, 12 Nov 2020 00:41:34 +0000 (16:41 -0800)]
Merge branch 'net-evaluate-net-ipvX-conf-all-sysctls'

Vincent Bernat says:

====================
net: evaluate net.ipvX.conf.all.* sysctls

Some per-interface sysctls are ignoring the "all" variant. This
patchset fixes some of them when such a sysctl is handled as a
boolean. This includes:

 - net.ipvX.conf.all.disable_policy
 - net.ipvX.conf.all.disable_policy.disable_xfrm
 - net.ipv4.conf.all.proxy_arp_pvlan
 - net.ipvX.conf.all.ignore_routes_with_linkdown

Two sysctls are still ignoring the "all" variant as it wouldn't make
much sense for them:

 - net.ipv4.conf.all.tag
 - net.ipv4.conf.all.medium_id

Ideally, the "all" variant should be removed, but there is no simple
alternative to DEVINET_SYSCTL_* macros that would allow one to not
expose and "all" entry.
====================

Link: https://lore.kernel.org/r/20201107193515.1469030-1-vincent@bernat.ch
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: evaluate net.ipvX.conf.all.disable_policy and disable_xfrm
Vincent Bernat [Sat, 7 Nov 2020 19:35:15 +0000 (20:35 +0100)]
net: evaluate net.ipvX.conf.all.disable_policy and disable_xfrm

The disable_policy and disable_xfrm are a per-interface sysctl to
disable IPsec policy or encryption on an interface. However, while a
"all" variant is exposed, it was a noop since it was never evaluated.
We use the usual "or" logic for this kind of sysctls.

Signed-off-by: Vincent Bernat <vincent@bernat.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: evaluate net.ipv4.conf.all.proxy_arp_pvlan
Vincent Bernat [Sat, 7 Nov 2020 19:35:14 +0000 (20:35 +0100)]
net: evaluate net.ipv4.conf.all.proxy_arp_pvlan

Introduced in 65324144b50b, the "proxy_arp_vlan" sysctl is a
per-interface sysctl to tune proxy ARP support for private VLANs.
While the "all" variant is exposed, it was a noop and never evaluated.
We use the usual "or" logic for this kind of sysctls.

Fixes: 65324144b50b ("net: RFC3069, private VLAN proxy arp support")
Signed-off-by: Vincent Bernat <vincent@bernat.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: evaluate net.ipvX.conf.all.ignore_routes_with_linkdown
Vincent Bernat [Sat, 7 Nov 2020 19:35:13 +0000 (20:35 +0100)]
net: evaluate net.ipvX.conf.all.ignore_routes_with_linkdown

Introduced in 0eeb075fad73, the "ignore_routes_with_linkdown" sysctl
ignores a route whose interface is down. It is provided as a
per-interface sysctl. However, while a "all" variant is exposed, it
was a noop since it was never evaluated. We use the usual "or" logic
for this kind of sysctls.

Tested with:

    ip link add type veth # veth0 + veth1
    ip link add type veth # veth1 + veth2
    ip link set up dev veth0
    ip link set up dev veth1 # link-status paired with veth0
    ip link set up dev veth2
    ip link set up dev veth3 # link-status paired with veth2

    # First available path
    ip -4 addr add 203.0.113.${uts#H}/24 dev veth0
    ip -6 addr add 2001:db8:1::${uts#H}/64 dev veth0

    # Second available path
    ip -4 addr add 192.0.2.${uts#H}/24 dev veth2
    ip -6 addr add 2001:db8:2::${uts#H}/64 dev veth2

    # More specific route through first path
    ip -4 route add 198.51.100.0/25 via 203.0.113.254 # via veth0
    ip -6 route add 2001:db8:3::/56 via 2001:db8:1::ff # via veth0

    # Less specific route through second path
    ip -4 route add 198.51.100.0/24 via 192.0.2.254 # via veth2
    ip -6 route add 2001:db8:3::/48 via 2001:db8:2::ff # via veth2

    # H1: enable on "all"
    # H2: enable on "veth0"
    for v in ipv4 ipv6; do
      case $uts in
        H1)
          sysctl -qw net.${v}.conf.all.ignore_routes_with_linkdown=1
          ;;
        H2)
          sysctl -qw net.${v}.conf.veth0.ignore_routes_with_linkdown=1
          ;;
      esac
    done

    set -xe
    # When veth0 is up, best route is through veth0
    ip -o route get 198.51.100.1 | grep -Fw veth0
    ip -o route get 2001:db8:3::1 | grep -Fw veth0

    # When veth0 is down, best route should be through veth2 on H1/H2,
    # but on veth0 on H2
    ip link set down dev veth1 # down veth0
    ip route show
    [ $uts != H3 ] || ip -o route get 198.51.100.1 | grep -Fw veth0
    [ $uts != H3 ] || ip -o route get 2001:db8:3::1 | grep -Fw veth0
    [ $uts = H3 ] || ip -o route get 198.51.100.1 | grep -Fw veth2
    [ $uts = H3 ] || ip -o route get 2001:db8:3::1 | grep -Fw veth2

Without this patch, the two last lines would fail on H1 (the one using
the "all" sysctl). With the patch, everything succeeds as expected.

Also document the sysctl in `ip-sysctl.rst`.

Fixes: 0eeb075fad73 ("net: ipv4 sysctl option to ignore routes when nexthop link is down")
Signed-off-by: Vincent Bernat <vincent@bernat.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoMerge branch 'net-qrtr-add-distant-node-support'
Jakub Kicinski [Wed, 11 Nov 2020 23:29:37 +0000 (15:29 -0800)]
Merge branch 'net-qrtr-add-distant-node-support'

Loic Poulain says:

====================
net: qrtr: Add distant node support

QRTR protocol allows a node to communicate with an other non-immediate
node via an intermdediate immediate node acting as a 'bridge':

node-0 <=> node-1 <=> node-2

This is currently not supported in this upstream version and this
series aim to fix that.

This series is V2 because changes 1, 2 and 3 have already been submitted
separately on LKML.

Changes in v2:
- Add reviewed-by tags from Bjorn and Mani
- Fixing checkpatch issue reported by Jakub
====================

Link: https://lore.kernel.org/r/1604684010-24090-1-git-send-email-loic.poulain@linaro.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: qrtr: Release distant nodes along the bridge node
Loic Poulain [Fri, 6 Nov 2020 17:33:30 +0000 (18:33 +0100)]
net: qrtr: Release distant nodes along the bridge node

Distant QRTR nodes can be accessed via an other node that acts as
a bridge. When the a QRTR endpoint associated to a bridge node is
released, all the linked distant nodes should also be released.

This patch fixes endpoint release by:
- Submitting QRTR BYE message locally on behalf of all the nodes
accessible through the endpoint.
- Removing all the routable node IDs from radix tree pointing to
the released node endpoint.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: qrtr: Add GFP flags parameter to qrtr_alloc_ctrl_packet
Loic Poulain [Fri, 6 Nov 2020 17:33:29 +0000 (18:33 +0100)]
net: qrtr: Add GFP flags parameter to qrtr_alloc_ctrl_packet

This will be requested for allocating control packet in atomic context.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: qrtr: Allow non-immediate node routing
Loic Poulain [Fri, 6 Nov 2020 17:33:28 +0000 (18:33 +0100)]
net: qrtr: Allow non-immediate node routing

In order to reach non-immediate remote node services that are
accessed through an intermediate node, the route to the remote
node needs to be saved.

E.g for a [node1 <=> node2 <=> node3] network
- node2 forwards node3 service to node1
- node1 must save node2 as route for reaching node3

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: qrtr: Allow forwarded services
Loic Poulain [Fri, 6 Nov 2020 17:33:27 +0000 (18:33 +0100)]
net: qrtr: Allow forwarded services

A remote endpoint (immediate neighbors node) can forward services
from other nodes (non-immadiate), in that case ctrl packet node ID
(offering distant service) can differ from the qrtr source node
(forwarding the packet).

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: qrtr: Fix port ID for control messages
Loic Poulain [Fri, 6 Nov 2020 17:33:26 +0000 (18:33 +0100)]
net: qrtr: Fix port ID for control messages

The port ID for control messages was uncorrectly set with broadcast
node ID value, causing message to be dropped on remote side since
not passing packet filtering (cb->dst_port != QRTR_PORT_CTRL).

Fixes: d27e77a3de28 ("net: qrtr: Reset the node and port ID of broadcast messages")
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: stmmac: dwc-qos: Change the dwc_eth_dwmac_data's .probe prototype
Jisheng Zhang [Mon, 9 Nov 2020 08:05:14 +0000 (16:05 +0800)]
net: stmmac: dwc-qos: Change the dwc_eth_dwmac_data's .probe prototype

The return pointer of dwc_eth_dwmac_data's .probe isn't used, and
"probe" usually return int, so change the prototype to follow standard
way. Secondly, it can simplify the tegra_eqos_probe() code.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Link: https://lore.kernel.org/r/20201109160440.3a736ee3@xhacker.debian
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: phy: aquantia: do not return an error on clearing pending IRQs
Ioana Ciornei [Mon, 9 Nov 2020 15:46:01 +0000 (17:46 +0200)]
net: phy: aquantia: do not return an error on clearing pending IRQs

The referenced commit added in .config_intr() the part of code which upon
configuration of the IRQ state it also clears up any pending IRQ. If
there were actually pending IRQs, a read on the IRQ status register will
return something non zero. This should not result in the callback
returning an error.

Fix this by returning an error only when the result of the
phy_read_mmd() is negative.

Fixes: e11ef96d44f1 ("net: phy: aquantia: remove the use of .ack_interrupt()")
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Tested-by: Camelia Groza <camelia.groza@nxp.com>
Link: https://lore.kernel.org/r/20201109154601.3812574-1-ciorneiioana@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoMerge branch 'net-ipa-little-fixes'
Jakub Kicinski [Wed, 11 Nov 2020 22:07:02 +0000 (14:07 -0800)]
Merge branch 'net-ipa-little-fixes'

Alex Elder says:

====================
net: ipa: little fixes

This series adds a few small fixes to the IPA code.

The first patch appeared in a different form in June, and got some
pushback from David because he felt a problem that can be caught at
build time *should* be caught at build time.
  https://lore.kernel.org/netdev/20200610195332.2612233-1-elder@linaro.org/
I agree with that, but in this case the "problem" was never actually
a problem.  There's a little more explanation on the patch, but
basically now we remove the BUILD_BUG_ON() call entirely.

The second deletes a line of code that isn't needed.

The third converts a warning message to be a debug, as requested by
Stephen Boyd.

And the last one just gets rid of an error message that would be
output after a different message had already reported a problem.
====================

Link: https://lore.kernel.org/r/20201109165635.5449-1-elder@linaro.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipa: drop an error message
Alex Elder [Mon, 9 Nov 2020 16:56:35 +0000 (10:56 -0600)]
net: ipa: drop an error message

There is no need for gsi_modem_channel_halt() to report an error,
because gsi_generic_command() will already have done that if the
command times out.  So get rid of the extra message.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipa: change a warning to debug
Alex Elder [Mon, 9 Nov 2020 16:56:34 +0000 (10:56 -0600)]
net: ipa: change a warning to debug

When we determine from hardware what the size of IPA memory is
we compare it against what we learned about it from DT.

If DT defines a region that's larger than actual memory, we use the
smaller actual size and issue a warning.

If DT defines a smaller region than actual memory we issue a warning
too.  But in this case the difference is harmless; so rather than
issuing a warning, just provide a debug message instead.

Reorder these checks so the one that matters more is done first.

Reported-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipa: get rid of a useless line of code
Alex Elder [Mon, 9 Nov 2020 16:56:33 +0000 (10:56 -0600)]
net: ipa: get rid of a useless line of code

Delete a spurious line of code in ipa_hardware_config().  It reads a
register value then ignores the value, so is completely unnecessary.

Add a missing word in a comment.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipa: don't break build on large transaction size
Alex Elder [Mon, 9 Nov 2020 16:56:32 +0000 (10:56 -0600)]
net: ipa: don't break build on large transaction size

The following call in ipa_validate_build() is erroneous:

    BUILD_BUG_ON(sizeof(struct gsi_trans) > 128);

The fact is, it is not a bug for the size of a GSI transaction to be
bigger than 128 bytes.  The correct operation of the driver is not
dependent on the size of this structure.  The only consequence of
the transaction being large is that the amount of memory required
is larger.

The problem this was trying to flag is that a *slight* increase in
the size of this structure will have a disproportionate effect on
the amount of memory used.  E.g. if the structure grew to 132 bytes
the memory requirement for the transaction arrays would be about
double.

With various debugging build flags enabled, the size grows to 160
bytes.  But there's no reason to treat that as a build-time bug.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoMerge branch 'inet-prevent-skb-changes-in-udp-4-6-_lib_lookup_skb'
Jakub Kicinski [Wed, 11 Nov 2020 01:57:20 +0000 (17:57 -0800)]
Merge branch 'inet-prevent-skb-changes-in-udp-4-6-_lib_lookup_skb'

Eric Dumazet says:

====================
inet: prevent skb changes in udp{4|6}_lib_lookup_skb()

This came while reviewing Alexander Lobakin patch against UDP GRO:

We want to make sure skb wont be changed by these helpers
while it is owned by GRO stack.
====================

Link: https://lore.kernel.org/r/20201109231349.20946-1-eric.dumazet@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoinet: udp{4|6}_lib_lookup_skb() skb argument is const
Eric Dumazet [Mon, 9 Nov 2020 23:13:49 +0000 (15:13 -0800)]
inet: udp{4|6}_lib_lookup_skb() skb argument is const

The skb is needed only to fetch the keys for the lookup.

Both functions are used from GRO stack, we do not want
accidental modification of the skb.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Alexander Lobakin <alobakin@pm.me>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoinet: constify inet_sdif() argument
Eric Dumazet [Mon, 9 Nov 2020 23:13:48 +0000 (15:13 -0800)]
inet: constify inet_sdif() argument

inet_sdif() does not modify the skb.

This will permit propagating the const qualifier in
udp{4|6}_lib_lookup_skb() functions.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Alexander Lobakin <alobakin@pm.me>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: dsa: fix unintended sign extension on a u16 left shift
Colin Ian King [Mon, 9 Nov 2020 12:40:08 +0000 (12:40 +0000)]
net: dsa: fix unintended sign extension on a u16 left shift

The left shift of u16 variable high is promoted to the type int and
then sign extended to a 64 bit u64 value.  If the top bit of high is
set then the upper 32 bits of the result end up being set by the
sign extension. Fix this by explicitly casting the value in high to
a u64 before left shifting by 16 places.

Also, remove the initialisation of variable value to 0 at the start
of each loop iteration as the value is never read and hence the
assignment it is redundant.

Addresses-Coverity: ("Unintended sign extension")
Fixes: e4b27ebc780f ("net: dsa: Add DSA driver for Hirschmann Hellcreek switches")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>
Link: https://lore.kernel.org/r/20201109124008.2079873-1-colin.king@canonical.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: sched: fix misspellings using misspell-fixer tool
Menglong Dong [Mon, 9 Nov 2020 07:02:17 +0000 (02:02 -0500)]
net: sched: fix misspellings using misspell-fixer tool

Some typos are found out by misspell-fixer tool:

$ misspell-fixer -rnv ./net/sched/
./net/sched/act_api.c:686
./net/sched/act_bpf.c:68
./net/sched/cls_rsvp.h:241
./net/sched/em_cmp.c:44
./net/sched/sch_pie.c:408

Fix typos found by misspell-fixer.

Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/r/5fa8e9d4.1c69fb81.5d889.5c64@mx.google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: pch_gbe: remove unneeded variable retval in __pch_gbe_suspend
Kaixu Xia [Sun, 8 Nov 2020 12:13:00 +0000 (20:13 +0800)]
net: pch_gbe: remove unneeded variable retval in __pch_gbe_suspend

Fix the following coccicheck warning:

./drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c:2415:5-11: Unneeded variable: "retval". Return "0" on line 2435

Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
Link: https://lore.kernel.org/r/1604837580-12419-1-git-send-email-kaixuxia@tencent.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: atlantic: Remove unnecessary conversion to bool
Kaixu Xia [Sun, 8 Nov 2020 01:11:59 +0000 (09:11 +0800)]
net: atlantic: Remove unnecessary conversion to bool

The '!=' expression itself is bool, no need to convert it to bool.
Fix the following coccicheck warning:

./drivers/net/ethernet/aquantia/atlantic/aq_nic.c:1477:34-39: WARNING: conversion to bool not needed here

Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
Link: https://lore.kernel.org/r/1604797919-10157-1-git-send-email-kaixuxia@tencent.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipv4: remove redundant initialization in inet_rtm_deladdr
Menglong Dong [Sun, 8 Nov 2020 01:05:41 +0000 (09:05 +0800)]
net: ipv4: remove redundant initialization in inet_rtm_deladdr

The initialization for 'err' with '-EINVAL' is redundant and
can be removed, as it is updated soon.

Changes since v1:
- Remove redundant empty line

Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
Link: https://lore.kernel.org/r/20201108010541.12432-1-dong.menglong@zte.com.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoselftests: disable rp_filter when testing bareudp
Guillaume Nault [Sat, 7 Nov 2020 16:47:17 +0000 (17:47 +0100)]
selftests: disable rp_filter when testing bareudp

Some systems have rp_filter=1 as default configuration. This breaks
bareudp.sh as the intermediate namespaces handle part of the routing
with regular IPv4 routes but the reverse path is done with tc
(flower/tunnel_key/mirred).

Signed-off-by: Guillaume Nault <gnault@redhat.com>
Link: https://lore.kernel.org/r/28140b7d20161e4f766b558018fe2718f9bc1117.1604767577.git.gnault@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: skb_vlan_untag(): don't reset transport offset if set by GRO layer
Alexander Lobakin [Mon, 9 Nov 2020 23:47:23 +0000 (23:47 +0000)]
net: skb_vlan_untag(): don't reset transport offset if set by GRO layer

Similar to commit fda55eca5a33f
("net: introduce skb_transport_header_was_set()"), avoid resetting
transport offsets that were already set by GRO layer. This not only
mirrors the behavior of __netif_receive_skb_core(), but also makes
sense when it comes to UDP GSO fraglists forwarding: transport offset
of such skbs is set only once by GRO receive callback and remains
untouched and correct up to the xmitting driver in 1:1 case, but
becomes junk after untagging in ingress VLAN case and breaks UDP
GSO offload. This does not happen after this change, and all types
of forwarding of UDP GSO fraglists work as expected.

Since v1 [1]:
 - keep the code 1:1 with __netif_receive_skb_core() (Jakub).

[1] https://lore.kernel.org/netdev/zYurwsZRN7BkqSoikWQLVqHyxz18h4LhHU4NFa2Vw@cp4-web-038.plabs.ch

Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Link: https://lore.kernel.org/r/7JgIkgEztzt0W6ZtC9V9Cnk5qfkrUFYcpN871syCi8@cp4-web-040.plabs.ch
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoMerge branch 'net-add-and-use-dev_get_tstats64'
Jakub Kicinski [Tue, 10 Nov 2020 01:50:32 +0000 (17:50 -0800)]
Merge branch 'net-add-and-use-dev_get_tstats64'

Heiner Kallweit says:

====================
net: add and use dev_get_tstats64

It's a frequent pattern to use netdev->stats for the less frequently
accessed counters and per-cpu counters for the frequently accessed
counters (rx/tx bytes/packets). Add a default ndo_get_stats64()
implementation for this use case. Subsequently switch more drivers
to use this pattern.

v2:
- add patches for replacing ip_tunnel_get_stats64
  Requested additional migrations will come in a separate series.

v3:
- add atomic_long_t member rx_frame_errors in patch 3 for making
  counter updates atomic
====================

Link: https://lore.kernel.org/r/99273e2f-c218-cd19-916e-9161d8ad8c56@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: remove ip_tunnel_get_stats64
Heiner Kallweit [Sat, 7 Nov 2020 20:55:11 +0000 (21:55 +0100)]
net: remove ip_tunnel_get_stats64

After having migrated all users remove ip_tunnel_get_stats64().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoipv4/ipv6: switch to dev_get_tstats64
Heiner Kallweit [Sat, 7 Nov 2020 20:54:33 +0000 (21:54 +0100)]
ipv4/ipv6: switch to dev_get_tstats64

Replace ip_tunnel_get_stats64() with the new identical core function
dev_get_tstats64().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agovti: switch to dev_get_tstats64
Heiner Kallweit [Sat, 7 Nov 2020 20:53:53 +0000 (21:53 +0100)]
vti: switch to dev_get_tstats64

Replace ip_tunnel_get_stats64() with the new identical core function
dev_get_tstats64().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agowireguard: switch to dev_get_tstats64
Heiner Kallweit [Sat, 7 Nov 2020 20:53:19 +0000 (21:53 +0100)]
wireguard: switch to dev_get_tstats64

Replace ip_tunnel_get_stats64() with the new identical core function
dev_get_tstats64().

Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agogtp: switch to dev_get_tstats64
Heiner Kallweit [Sat, 7 Nov 2020 20:52:42 +0000 (21:52 +0100)]
gtp: switch to dev_get_tstats64

Replace ip_tunnel_get_stats64() with the new identical core function
dev_get_tstats64().

Acked-by: Harald Welte <laforge@gnumonks.org>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: switch to dev_get_tstats64
Heiner Kallweit [Sat, 7 Nov 2020 20:52:06 +0000 (21:52 +0100)]
net: switch to dev_get_tstats64

Replace ip_tunnel_get_stats64() with the new identical core function
dev_get_tstats64().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoip6_tunnel: use ip_tunnel_get_stats64 as ndo_get_stats64 callback
Heiner Kallweit [Sat, 7 Nov 2020 20:51:32 +0000 (21:51 +0100)]
ip6_tunnel: use ip_tunnel_get_stats64 as ndo_get_stats64 callback

Switch ip6_tunnel to the standard statistics pattern:
- use dev->stats for the less frequently accessed counters
- use dev->tstats for the frequently accessed counters

An additional benefit is that we now have 64bit statistics also on
32bit systems.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agotun: switch to net core provided statistics counters
Heiner Kallweit [Sat, 7 Nov 2020 20:50:56 +0000 (21:50 +0100)]
tun: switch to net core provided statistics counters

Switch tun to the standard statistics pattern:
- use netdev->stats for the less frequently accessed counters
- use netdev->tstats for the frequently accessed per-cpu counters

v3:
- add atomic_long_t member rx_frame_errors for making counter updates
  atomic

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: dsa: use net core stats64 handling
Heiner Kallweit [Sat, 7 Nov 2020 20:49:46 +0000 (21:49 +0100)]
net: dsa: use net core stats64 handling

Use netdev->tstats instead of a member of dsa_slave_priv for storing
a pointer to the per-cpu counters. This allows us to use core
functionality for statistics handling.

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: core: add dev_get_tstats64 as a ndo_get_stats64 implementation
Heiner Kallweit [Sat, 7 Nov 2020 20:49:07 +0000 (21:49 +0100)]
net: core: add dev_get_tstats64 as a ndo_get_stats64 implementation

It's a frequent pattern to use netdev->stats for the less frequently
accessed counters and per-cpu counters for the frequently accessed
counters (rx/tx bytes/packets). Add a default ndo_get_stats64()
implementation for this use case.

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: dsa: mv88e6xxx: Export VTU as devlink region
Tobias Waldekranz [Mon, 9 Nov 2020 08:29:27 +0000 (09:29 +0100)]
net: dsa: mv88e6xxx: Export VTU as devlink region

Export the raw VTU data and related registers in a devlink region so
that it can be inspected from userspace and compared to the current
bridge configuration.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20201109082927.8684-1-tobias@waldekranz.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: phy: microchip_t1: Don't set .config_aneg
Jisheng Zhang [Mon, 9 Nov 2020 01:16:05 +0000 (09:16 +0800)]
net: phy: microchip_t1: Don't set .config_aneg

The .config_aneg in microchip_t1 is genphy_config_aneg, so it's not
needed, because the phy core will call genphy_config_aneg() if the
.config_aneg is NULL.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20201109091605.3951c969@xhacker.debian
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet/mlx4: Assign boolean values to a bool variable
Kaixu Xia [Sat, 7 Nov 2020 06:53:58 +0000 (14:53 +0800)]
net/mlx4: Assign boolean values to a bool variable

Fix the following coccinelle warnings:

./drivers/net/ethernet/mellanox/mlx4/en_rx.c:687:1-17: WARNING: Assignment of 0/1 to bool variable

Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://lore.kernel.org/r/1604732038-6057-1-git-send-email-kaixuxia@tencent.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: udp: remove redundant initialization in udp_dump_one
Menglong Dong [Fri, 6 Nov 2020 06:42:38 +0000 (01:42 -0500)]
net: udp: remove redundant initialization in udp_dump_one

The initialization for 'err' with '-EINVAL' is redundant and
can be removed, as it is updated soon and not used.

Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
Link: https://lore.kernel.org/r/1604644960-48378-2-git-send-email-dong.menglong@zte.com.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: udp: remove redundant initialization in udp_send_skb
Menglong Dong [Fri, 6 Nov 2020 06:42:40 +0000 (01:42 -0500)]
net: udp: remove redundant initialization in udp_send_skb

The initialization for 'err' with 0 is redundant and can be removed,
as it is updated by ip_send_skb and not used before that.

Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
Link: https://lore.kernel.org/r/1604644960-48378-4-git-send-email-dong.menglong@zte.com.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agobridge: mrp: Use hlist_head instead of list_head for mrp
Horatiu Vultur [Fri, 6 Nov 2020 21:50:49 +0000 (22:50 +0100)]
bridge: mrp: Use hlist_head instead of list_head for mrp

Replace list_head with hlist_head for MRP list under the bridge.
There is no need for a circular list when a linear list will work.
This will also decrease the size of 'struct net_bridge'.

Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Link: https://lore.kernel.org/r/20201106215049.1448185-1-horatiu.vultur@microchip.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoMerge branch 'net-packet-make-packet_fanout-arr-size-configurable-up-to-64k'
Jakub Kicinski [Tue, 10 Nov 2020 00:41:45 +0000 (16:41 -0800)]
Merge branch 'net-packet-make-packet_fanout-arr-size-configurable-up-to-64k'

Tanner Love says:

====================
net/packet: make packet_fanout.arr size configurable up to 64K

First patch makes the change; second patch adds unit tests.
====================

Link: https://lore.kernel.org/r/20201106180741.2839668-1-tannerlove.kernel@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoselftests/net: test max_num_members, fanout_args in psock_fanout
Tanner Love [Fri, 6 Nov 2020 18:07:41 +0000 (13:07 -0500)]
selftests/net: test max_num_members, fanout_args in psock_fanout

Add an additional control test that verifies:
-specifying two different max_num_members values fails
-specifying max_num_members > PACKET_FANOUT_MAX fails

In datapath tests, set max_num_members to PACKET_FANOUT_MAX.

Signed-off-by: Tanner Love <tannerlove@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet/packet: make packet_fanout.arr size configurable up to 64K
Tanner Love [Fri, 6 Nov 2020 18:07:40 +0000 (13:07 -0500)]
net/packet: make packet_fanout.arr size configurable up to 64K

One use case of PACKET_FANOUT is lockless reception with one socket
per CPU. 256 is a practical limit on increasingly many machines.

Increase PACKET_FANOUT_MAX to 64K. Expand setsockopt PACKET_FANOUT to
take an extra argument max_num_members. Also explicitly define a
fanout_args struct, instead of implicitly casting to an integer. This
documents the API and simplifies the control flow.

If max_num_members is not specified or is set to 0, then 256 is used,
same as before.

Signed-off-by: Tanner Love <tannerlove@google.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: udp: introduce UDP_MIB_MEMERRORS for udp_mem
Menglong Dong [Fri, 6 Nov 2020 01:49:14 +0000 (20:49 -0500)]
net: udp: introduce UDP_MIB_MEMERRORS for udp_mem

When udp_memory_allocated is at the limit, __udp_enqueue_schedule_skb
will return a -ENOBUFS, and skb will be dropped in __udp_queue_rcv_skb
without any counters being done. It's hard to find out what happened
once this happen.

So we introduce a UDP_MIB_MEMERRORS to do this job. Well, this change
looks friendly to the existing users, such as netstat:

$ netstat -u -s
Udp:
    0 packets received
    639 packets to unknown port received.
    158689 packet receive errors
    180022 packets sent
    RcvbufErrors: 20930
    MemErrors: 137759
UdpLite:
IpExt:
    InOctets: 257426235
    OutOctets: 257460598
    InNoECTPkts: 181177

v2:
- Fix some alignment problems

Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
Link: https://lore.kernel.org/r/1604627354-43207-1-git-send-email-dong.menglong@zte.com.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agostmmac: intel: change all EHL/TGL to auto detect phy addr
Voon Weifeng [Fri, 6 Nov 2020 09:43:41 +0000 (17:43 +0800)]
stmmac: intel: change all EHL/TGL to auto detect phy addr

Set all EHL/TGL phy_addr to -1 so that the driver will automatically
detect it at run-time by probing all the possible 32 addresses.

Signed-off-by: Voon Weifeng <weifeng.voon@intel.com>
Signed-off-by: Wong Vee Khee <vee.khee.wong@intel.com>
Link: https://lore.kernel.org/r/20201106094341.4241-1-vee.khee.wong@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: usb: fix spelling typo in cdc_ncm.c
Wang Qing [Fri, 6 Nov 2020 07:50:25 +0000 (15:50 +0800)]
net: usb: fix spelling typo in cdc_ncm.c

Actually, withing should be within.

Signed-off-by: Wang Qing <wangqing@vivo.com>
Link: https://lore.kernel.org/r/1604649025-22559-1-git-send-email-wangqing@vivo.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: core: fix spelling typo in flow_dissector.c
Wang Qing [Fri, 6 Nov 2020 08:11:49 +0000 (16:11 +0800)]
net: core: fix spelling typo in flow_dissector.c

withing should be within.

Signed-off-by: Wang Qing <wangqing@vivo.com>
Link: https://lore.kernel.org/r/1604650310-30432-1-git-send-email-wangqing@vivo.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agoMerge branch 'net-ipa-constrain-gsi-interrupts'
Jakub Kicinski [Sat, 7 Nov 2020 23:39:20 +0000 (15:39 -0800)]
Merge branch 'net-ipa-constrain-gsi-interrupts'

Alex Elder says:

====================
net: ipa: constrain GSI interrupts

The goal of this series is to more tightly control when GSI
interrupts are enabled.  This is a long-ish series, so I'll
describe it in parts.

The first patch is actually unrelated...  I forgot to include
it in my previous series (which exposed the GSI layer to the
IPA version).  It is a trivial comments-only update patch.

The second patch defers registering the GSI interrupt handler
until *after* all of the resources that handler touches have
been initialized.  In practice, we don't see this interrupt
that early, but this precludes an obvious problem.

The next two patches are simple changes.  The first just
trivially renames a field.  The second switches from using
constant mask values to using an enumerated type of bit
positions to represent each GSI interrupt type.

The rest implement the "real work."  First, all interrupts
are disabled at initialization time.  Next, we keep track of
a bitmask of enabled GSI interrupt types, updating it each
time we enable or disable one of them.  From there we have
a set of patches that one-by-one enable each interrupt type
only during the period it is required.  This includes allowing
a channel to generate IEOB interrupts only when it has been
enabled.  And finally, the last patch simplifies some code
now that all GSI interrupt types are handled uniformly.
====================

Link: https://lore.kernel.org/r/20201105181407.8006-1-elder@linaro.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipa: pass a value to gsi_irq_type_update()
Alex Elder [Thu, 5 Nov 2020 18:14:07 +0000 (12:14 -0600)]
net: ipa: pass a value to gsi_irq_type_update()

Now that all of the GSI interrupts are handled uniformly,
change gsi_irq_type_update() so it takes a value.  Have the
function assign that value to the cached mask of enabled GSI
IRQ types before writing it to hardware.

Note that gsi_irq_teardown() will only be called after
gsi_irq_disable(), so it's not necessary for the former
to disable all IRQ types.  Get rid of that.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipa: only enable GSI general IRQs when needed
Alex Elder [Thu, 5 Nov 2020 18:14:06 +0000 (12:14 -0600)]
net: ipa: only enable GSI general IRQs when needed

Most GSI general errors are unrecoverable without a full reset.
Despite that, we want to receive these errors so we can at least
report what happened before whatever undefined behavior ensues.

Explicitly disable all such interrupts in gsi_irq_setup(), then
enable those we want in gsi_irq_enable().  List the interrupt types
we are interested in (everything but breakpoint) explicitly rather
than using GSI_CNTXT_GSI_IRQ_ALL, and remove that symbol's
definition.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipa: explicitly disallow inter-EE interrupts
Alex Elder [Thu, 5 Nov 2020 18:14:05 +0000 (12:14 -0600)]
net: ipa: explicitly disallow inter-EE interrupts

It is possible for other execution environments (EEs, like the modem)
to request changes to local (AP) channel or event ring state.  We do
not support this feature.

In gsi_irq_setup(), explicitly zero the mask that defines which
channels are permitted to generate inter-EE channel state change
interrupts.  Do the same for the event ring mask.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipa: only enable GSI IEOB IRQs when needed
Alex Elder [Thu, 5 Nov 2020 18:14:04 +0000 (12:14 -0600)]
net: ipa: only enable GSI IEOB IRQs when needed

A GSI channel must be started in order to use it to perform a
transfer data (or command) transaction.  And the only time we'll see
an IEOB interrupt is if we send a transaction to a started channel.
Therefore we do not need to have the IEOB interrupt type enabled
until at least one channel has been started.  And once the last
started channel has been stopped, we can disable the IEOB interrupt
type again.

We already enable the IEOB interrupt for a particular channel only
when it is started.  Extend that by having the IEOB interrupt *type*
be enabled only when at least one channel is in STARTED state.

Disallow all channels from triggering the IEOB interrupt in
gsi_irq_setup().  We only enable an channel's interrupt when
needed, so there is no longer any need to zero the channel mask
in gsi_irq_disable().

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipa: only enable generic command completion IRQ when needed
Alex Elder [Thu, 5 Nov 2020 18:14:03 +0000 (12:14 -0600)]
net: ipa: only enable generic command completion IRQ when needed

The completion of a generic EE GSI command is signaled by a global
interrupt of type GP_INT1.  The only other used type for a global
interrupt is a hardware error report.

First, disallow all global interrupt types in gsi_irq_setup().  We
want to know about hardware errors, so re-enable the interrupt type
in gsi_irq_enable(), to allow hardware errors to be reported.
Disable that interrupt type again in gsi_irq_disable().

We only issue generic EE commands one at a time, and there's no
reason to keep the completion interrupt enabled when no generic
EE command is pending.  We furthermore have no need to enable the
GP_INT2 or GP_INT3 interrupt types (which aren't used).

The change in gsi_irq_enable() makes GSI_CNTXT_GLOB_IRQ_ALL unused,
so get rid of it.  Have gsi_generic_command() enable the GP_INT1
interrupt type (in addition to the ERROR_INT type) only while a
generic command is pending.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipa: only enable GSI event control IRQs when needed
Alex Elder [Thu, 5 Nov 2020 18:14:02 +0000 (12:14 -0600)]
net: ipa: only enable GSI event control IRQs when needed

A GSI event ring causes an event control interrupt to fire whenever
its state changes (between NOT_ALLOCATED and ALLOCATED).  No event
ring should ever change state except when we request it to.

Currently, we permit *all* events rings to generate event control
interrupts--even those that are never used.  And we enable event
control interrupts essentially at all times, from setup to teardown.

Instead, only enable the event control interrupt type for the
duration of an event ring command, and when doing so, only allow
the event ring being operated upon to cause the interrupt to fire.
Disallow all event rings from issuing the event control interrupt
in gsi_irq_setup().

Because an event ring's interrupt is only enabled when needed,
there is no longer any need to zero the event channel mask in
gsi_irq_disable().

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipa: only enable GSI channel control IRQs when needed
Alex Elder [Thu, 5 Nov 2020 18:14:01 +0000 (12:14 -0600)]
net: ipa: only enable GSI channel control IRQs when needed

A GSI channel causes a channel control interrupt to fire whenever
its state changes (between NOT_ALLOCATED, ALLOCATED, STARTED, etc.).
We do not support inter-EE channel commands (initiated by other EEs),
so no channel should ever change state except when we request it to.

Currently, we permit *all* channels to generate channel control
interrupts--even those that are never used.  And we enable channel
control interrupts essentially at all times, from setup to teardown.

Instead, disable all channel control interrupts initially in
gsi_irq_setup(), and only enable the channel control interrupt
type for the duration of a channel command.  When doing so, only
allow the channel being operated upon to cause the interrupt to
fire.

Because a channel's interrupt is now enabled only when needed (one
channel at a time), there is no longer any need to zero the channel
mask in gsi_irq_disable().

Add new gsi_irq_type_enable() and gsi_irq_type_disable() as helper
functions to control whether a given GSI interrupt type is enabled.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipa: cache last-saved GSI IRQ enabled type
Alex Elder [Thu, 5 Nov 2020 18:14:00 +0000 (12:14 -0600)]
net: ipa: cache last-saved GSI IRQ enabled type

Keep track of the set of GSI interrupt types that are currently
enabled by recording the mask value to write (or last written) to
the TYPE_IRQ_MSK register.

Create a new helper function gsi_irq_type_update() to handle
actually writing the register.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipa: disable all GSI interrupt types initially
Alex Elder [Thu, 5 Nov 2020 18:13:59 +0000 (12:13 -0600)]
net: ipa: disable all GSI interrupt types initially

Introduce gsi_irq_setup() and gsi_irq_teardown() to disable all
GSI interrupts when first setting up GSI hardware, and to clean
things up when we're done.

Re-enable all GSI interrupt types in gsi_irq_enable(), but do
so only after each of the type-specific interrupt masks has
been configured.  Similarly, disable all interrupt types in
gsi_irq_disable()--first--before zeroing out the type-specific
masks.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
3 years agonet: ipa: define GSI interrupt types with an enum
Alex Elder [Thu, 5 Nov 2020 18:13:58 +0000 (12:13 -0600)]
net: ipa: define GSI interrupt types with an enum

Define the GSI interrupt types with an enumerated type whose values
are the bit positions representing each interrupt type.  Include a
short comment describing how each interrupt type is used.

Build up the enabled interrupt mask explicitly in gsi_irq_enable(),
and get rid of the definition of GSI_CNTXT_TYPE_IRQ_MSK_ALL.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>