]> git.ipfire.org Git - thirdparty/linux.git/log
thirdparty/linux.git
10 months agoMerge branch 'selftests/bpf: Various sockmap-related fixes'
Martin KaFai Lau [Mon, 19 Aug 2024 23:40:11 +0000 (16:40 -0700)] 
Merge branch 'selftests/bpf: Various sockmap-related fixes'

Michal Luczaj says:

====================
Series takes care of few bugs and missing features with the aim to improve
the test coverage of sockmap/sockhash.

Last patch is a create_pair() rewrite making use of
__attribute__((cleanup)) to handle socket fd lifetime.

---
Changes in v2:
- Rebase on bpf-next (Jakub)
- Use cleanup helpers from kernel's cleanup.h (Jakub)
- Fix subject of patch 3, rephrase patch 4, use correct prefix
- Link to v1: https://lore.kernel.org/r/20240724-sockmap-selftest-fixes-v1-0-46165d224712@rbox.co

Changes in v1:
- No declarations in function body (Jakub)
- Don't touch output arguments until function succeeds (Jakub)
- Link to v0: https://lore.kernel.org/netdev/027fdb41-ee11-4be0-a493-22f28a1abd7c@rbox.co/
====================

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
10 months agoselftests/bpf: Introduce __attribute__((cleanup)) in create_pair()
Michal Luczaj [Wed, 31 Jul 2024 10:01:31 +0000 (12:01 +0200)] 
selftests/bpf: Introduce __attribute__((cleanup)) in create_pair()

Rewrite function to have (unneeded) socket descriptors automatically
close()d when leaving the scope. Make sure the "ownership" of fds is
correctly passed via take_fd(); i.e. descriptor returned to caller will
remain valid.

Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
Tested-by: Jakub Sitnicki <jakub@cloudflare.com>
Suggested-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Link: https://lore.kernel.org/r/20240731-selftest-sockmap-fixes-v2-6-08a0c73abed2@rbox.co
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
10 months agoselftests/bpf: Exercise SOCK_STREAM unix_inet_redir_to_connected()
Michal Luczaj [Wed, 31 Jul 2024 10:01:30 +0000 (12:01 +0200)] 
selftests/bpf: Exercise SOCK_STREAM unix_inet_redir_to_connected()

Constants got switched reducing the test's coverage. Replace SOCK_DGRAM
with SOCK_STREAM in one of unix_inet_skb_redir_to_connected() tests.

Fixes: 51354f700d40 ("bpf, sockmap: Add af_unix test with both sockets in map")
Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
Tested-by: Jakub Sitnicki <jakub@cloudflare.com>
Suggested-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Link: https://lore.kernel.org/r/20240731-selftest-sockmap-fixes-v2-5-08a0c73abed2@rbox.co
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
10 months agoselftests/bpf: Honour the sotype of af_unix redir tests
Michal Luczaj [Wed, 31 Jul 2024 10:01:29 +0000 (12:01 +0200)] 
selftests/bpf: Honour the sotype of af_unix redir tests

Do actually test the sotype as specified by the caller.

This picks up after commit 75e0e27db6cf ("selftest/bpf: Change udp to inet
in some function names").

Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
Tested-by: Jakub Sitnicki <jakub@cloudflare.com>
Suggested-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Link: https://lore.kernel.org/r/20240731-selftest-sockmap-fixes-v2-4-08a0c73abed2@rbox.co
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
10 months agoselftests/bpf: Simplify inet_socketpair() and vsock_socketpair_connectible()
Michal Luczaj [Wed, 31 Jul 2024 10:01:28 +0000 (12:01 +0200)] 
selftests/bpf: Simplify inet_socketpair() and vsock_socketpair_connectible()

Replace implementation with a call to a generic function.

Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
Tested-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Link: https://lore.kernel.org/r/20240731-selftest-sockmap-fixes-v2-3-08a0c73abed2@rbox.co
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
10 months agoselftests/bpf: Socket pair creation, cleanups
Michal Luczaj [Wed, 31 Jul 2024 10:01:27 +0000 (12:01 +0200)] 
selftests/bpf: Socket pair creation, cleanups

Following create_pair() changes, remove unused function argument in
create_socket_pairs() and adapt its callers, i.e. drop the open-coded
loopback socket creation.

Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
Tested-by: Jakub Sitnicki <jakub@cloudflare.com>
Suggested-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Link: https://lore.kernel.org/r/20240731-selftest-sockmap-fixes-v2-2-08a0c73abed2@rbox.co
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
10 months agoselftests/bpf: Support more socket types in create_pair()
Michal Luczaj [Wed, 31 Jul 2024 10:01:26 +0000 (12:01 +0200)] 
selftests/bpf: Support more socket types in create_pair()

Extend the function to allow creating socket pairs of SOCK_STREAM,
SOCK_DGRAM and SOCK_SEQPACKET.

Adapt direct callers and leave further cleanups for the following patch.

Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
Tested-by: Jakub Sitnicki <jakub@cloudflare.com>
Suggested-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Link: https://lore.kernel.org/r/20240731-selftest-sockmap-fixes-v2-1-08a0c73abed2@rbox.co
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
10 months agoselftests/bpf: Avoid subtraction after htons() in ipip tests
Asbjørn Sloth Tønnesen [Thu, 8 Aug 2024 07:59:02 +0000 (07:59 +0000)] 
selftests/bpf: Avoid subtraction after htons() in ipip tests

On little-endian systems, doing subtraction after htons()
leads to interesting results:

Given:
  MAGIC_BYTES = 123 = 0x007B aka. in big endian: 0x7B00 = 31488
  sizeof(struct iphdr) = 20

Before this patch:
__bpf_constant_htons(MAGIC_BYTES) - sizeof(struct iphdr) = 0x7AEC
0x7AEC = htons(0xEC7A) = htons(60538)

So these were outer IP packets with a total length of 123 bytes,
containing an inner IP packet with a total length of 60538 bytes.

After this patch:
__bpf_constant_htons(MAGIC_BYTES - sizeof(struct iphdr)) = htons(103)

Now these packets are outer IP packets with a total length of 123 bytes,
containing an inner IP packet with a total length of 103 bytes.

Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: Toke Høiland-Jørgensen <toke@kernel.org>
Link: https://lore.kernel.org/r/20240808075906.1849564-1-ast@fiberby.net
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
10 months agoMerge branch 'add TCP_BPF_SOCK_OPS_CB_FLAGS to bpf_*sockopt()'
Martin KaFai Lau [Thu, 8 Aug 2024 22:31:26 +0000 (15:31 -0700)] 
Merge branch 'add TCP_BPF_SOCK_OPS_CB_FLAGS to bpf_*sockopt()'

Alan Maguire says:

====================
As previously discussed here [1], long-lived sockets can miss
a chance to set additional callbacks if a sock ops program
was not attached early in their lifetime.  Adding support
to bpf_setsockopt() to set callback flags (and bpf_getsockopt()
to retrieve them) provides other opportunities to enable callbacks,
either directly via a cgroup/setsockopt intercepted setsockopt()
or via a socket iterator.

Patch 1 adds bpf_[get|set]sockopt() support; patch 2 adds testing
for it via a sockops programs, along with verification via a
cgroup/getsockopt program.

Changes since v1 [2]:

- Removed unneeded READ_ONCE() (Martin, patch 1)
- Reworked sockopt test to leave existing tests undisturbed while adding
  test_nonstandard_opt() test to cover the TCP_BPF_SOCK_OPS_CB_FLAGS
  case; test verifies that value set via bpf_setsockopt() is what we
  expect via a call to getsockopt() which is caught by a
  cgroup/getsockopt program to provide the flags value (Martin, patch 2)
- Removed unneeded iterator test (Martin)

[1] https://lore.kernel.org/bpf/f42f157b-6e52-dd4d-3d97-9b86c84c0b00@oracle.com/
[2] https://lore.kernel.org/bpf/20240802152929.2695863-1-alan.maguire@oracle.com/
====================

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
10 months agoselftests/bpf: add sockopt tests for TCP_BPF_SOCK_OPS_CB_FLAGS
Alan Maguire [Thu, 8 Aug 2024 15:05:58 +0000 (16:05 +0100)] 
selftests/bpf: add sockopt tests for TCP_BPF_SOCK_OPS_CB_FLAGS

Add tests to set TCP sockopt TCP_BPF_SOCK_OPS_CB_FLAGS via
bpf_setsockopt() and use a cgroup/getsockopt program to retrieve
the value to verify it was set.

Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Link: https://lore.kernel.org/r/20240808150558.1035626-3-alan.maguire@oracle.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
10 months agobpf/bpf_get,set_sockopt: add option to set TCP-BPF sock ops flags
Alan Maguire [Thu, 8 Aug 2024 15:05:57 +0000 (16:05 +0100)] 
bpf/bpf_get,set_sockopt: add option to set TCP-BPF sock ops flags

Currently the only opportunity to set sock ops flags dictating
which callbacks fire for a socket is from within a TCP-BPF sockops
program.  This is problematic if the connection is already set up
as there is no further chance to specify callbacks for that socket.
Add TCP_BPF_SOCK_OPS_CB_FLAGS to bpf_setsockopt() and bpf_getsockopt()
to allow users to specify callbacks later, either via an iterator
over sockets or via a socket-specific program triggered by a
setsockopt() on the socket.

Previous discussion on this here [1].

[1] https://lore.kernel.org/bpf/f42f157b-6e52-dd4d-3d97-9b86c84c0b00@oracle.com/

Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Link: https://lore.kernel.org/r/20240808150558.1035626-2-alan.maguire@oracle.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
10 months agonet: mvpp2: Increase size of queue_name buffer
Simon Horman [Tue, 6 Aug 2024 11:28:24 +0000 (12:28 +0100)] 
net: mvpp2: Increase size of queue_name buffer

Increase size of queue_name buffer from 30 to 31 to accommodate
the largest string written to it. This avoids truncation in
the possibly unlikely case where the string is name is the
maximum size.

Flagged by gcc-14:

  .../mvpp2_main.c: In function 'mvpp2_probe':
  .../mvpp2_main.c:7636:32: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
   7636 |                  "stats-wq-%s%s", netdev_name(priv->port_list[0]->dev),
        |                                ^
  .../mvpp2_main.c:7635:9: note: 'snprintf' output between 10 and 31 bytes into a destination of size 30
   7635 |         snprintf(priv->queue_name, sizeof(priv->queue_name),
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   7636 |                  "stats-wq-%s%s", netdev_name(priv->port_list[0]->dev),
        |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   7637 |                  priv->port_count > 1 ? "+" : "");
        |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Introduced by commit 118d6298f6f0 ("net: mvpp2: add ethtool GOP statistics").
I am not flagging this as a bug as I am not aware that it is one.

Compile tested only.

Signed-off-by: Simon Horman <horms@kernel.org>
Reviewed-by: Marcin Wojtas <marcin.s.wojtas@gmail.com>
Link: https://patch.msgid.link/20240806-mvpp2-namelen-v1-1-6dc773653f2f@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agodoc/netlink/specs: add netkit support to rt_link.yaml
Nikolay Aleksandrov [Tue, 6 Aug 2024 10:45:31 +0000 (13:45 +0300)] 
doc/netlink/specs: add netkit support to rt_link.yaml

Add netkit support to rt_link.yaml. Only forward(PASS) and
blackhole(DROP) policies are allowed to be set by user-space so I've
added only them to the yaml to avoid confusion.

Example:
  $ ./tools/net/ynl/cli.py \
     --spec Documentation/netlink/specs/rt_link.yaml \
     --do getlink --json '{"ifname": "netkit0"}' --output-json | jq
  ...
  "linkinfo": {
    "kind": "netkit",
    "data": {
      "primary": 1,
      "policy": "blackhole",
      "mode": "l2",
      "peer-policy": "forward"
    }
  },
  ...

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://patch.msgid.link/20240806104531.3296718-1-razor@blackwall.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agobonding: Pass string literal as format argument of alloc_ordered_workqueue()
Simon Horman [Tue, 6 Aug 2024 09:56:52 +0000 (10:56 +0100)] 
bonding: Pass string literal as format argument of alloc_ordered_workqueue()

Recently I noticed that both gcc-14 and clang-18 report that passing
a non-string literal as the format argument of alloc_ordered_workqueue
is potentially insecure.

F.e. clang-18 says:

.../bond_main.c:6384:37: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
 6384 |         bond->wq = alloc_ordered_workqueue(bond_dev->name, WQ_MEM_RECLAIM);
      |                                            ^~~~~~~~~~~~~~
.../workqueue.h:524:18: note: expanded from macro 'alloc_ordered_workqueue'
  524 |         alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, ##args)
      |                         ^~~
.../bond_main.c:6384:37: note: treat the string as an argument to avoid this
 6384 |         bond->wq = alloc_ordered_workqueue(bond_dev->name, WQ_MEM_RECLAIM);
      |                                            ^
      |                                            "%s",
..../workqueue.h:524:18: note: expanded from macro 'alloc_ordered_workqueue'
  524 |         alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, ##args)
      |                         ^

Perhaps it is always the case where the contents of bond_dev->name is
safe to pass as the format argument. That is, in my understanding, it
never contains any format escape sequences.

But, it seems better to be safe than sorry. And, as a bonus, compiler
output becomes less verbose by addressing this issue as suggested by
clang-18.

Signed-off-by: Simon Horman <horms@kernel.org>
Acked-by: Jay Vosburgh <jv@jvosburgh.net>
Link: https://patch.msgid.link/20240806-bonding-fmt-v1-1-e75027e45775@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet: fec: Switch to RUNTIME/SYSTEM_SLEEP_PM_OPS()
Fabio Estevam [Tue, 6 Aug 2024 02:16:28 +0000 (23:16 -0300)] 
net: fec: Switch to RUNTIME/SYSTEM_SLEEP_PM_OPS()

Replace SET_RUNTIME_PM_OPS()/SET SYSTEM_SLEEP_PM_OPS() with their modern
RUNTIME_PM_OPS() and SYSTEM_SLEEP_PM_OPS() alternatives.

The combined usage of pm_ptr() and RUNTIME_PM_OPS/SYSTEM_SLEEP_PM_OPS()
allows the compiler to evaluate if the runtime suspend/resume() functions
are used at build time or are simply dead code.

This allows removing the __maybe_unused notation from the runtime
suspend/resume() functions.

Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Link: https://patch.msgid.link/20240806021628.2524089-1-festevam@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet/fungible: Avoid -Wflex-array-member-not-at-end warning
Gustavo A. R. Silva [Mon, 5 Aug 2024 15:30:26 +0000 (09:30 -0600)] 
net/fungible: Avoid -Wflex-array-member-not-at-end warning

Use the `DEFINE_RAW_FLEX()` helper for an on-stack definition of
a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

So, with these changes, fix the following warning:
drivers/net/ethernet/fungible/funcore/fun_dev.c:550:43: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://patch.msgid.link/ZrDwEugW7DR/FlP5@cute
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoMerge branch 'tcp-active-reset'
David S. Miller [Wed, 7 Aug 2024 09:24:46 +0000 (10:24 +0100)] 
Merge branch 'tcp-active-reset'

Jason Xing says:

===================
tcp: completely support active reset

This time the patch series finally covers all the cases in the active
reset logic. After this, we can know the related exact reason(s).

v4
Link:
1. revise the changelog to avoid future confusion in patch [5/7] (Eric)
2. revise the changelog of patch [6/7] like above.
3. add reviewed-by tags (Eric)

v3
Link: https://lore.kernel.org/all/20240731120955.23542-1-kerneljasonxing@gmail.com/
1. introduce TCP_DISCONNECT_WITH_DATA reason (Eric)
2. use a better name 'TCP_KEEPALIVE_TIMEOUT' (Eric)
3. add three reviewed-by tags (Eric)

v2
Link: https://lore.kernel.org/all/20240730133513.99986-1-kerneljasonxing@gmail.com/
1. use RFC 9293 in the comment and changelog instead of old RFC 793
2. correct the comment and changelog in patch 5
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agotcp: rstreason: let it work finally in tcp_send_active_reset()
Jason Xing [Fri, 2 Aug 2024 10:21:12 +0000 (18:21 +0800)] 
tcp: rstreason: let it work finally in tcp_send_active_reset()

Now it's time to let it work by using the 'reason' parameter in
the trace world :)

Signed-off-by: Jason Xing <kernelxing@tencent.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agotcp: rstreason: introduce SK_RST_REASON_TCP_DISCONNECT_WITH_DATA for active reset
Jason Xing [Fri, 2 Aug 2024 10:21:11 +0000 (18:21 +0800)] 
tcp: rstreason: introduce SK_RST_REASON_TCP_DISCONNECT_WITH_DATA for active reset

When user tries to disconnect a socket and there are more data written
into tcp write queue, we should tell users about this reset reason.

Signed-off-by: Jason Xing <kernelxing@tencent.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agotcp: rstreason: introduce SK_RST_REASON_TCP_KEEPALIVE_TIMEOUT for active reset
Jason Xing [Fri, 2 Aug 2024 10:21:10 +0000 (18:21 +0800)] 
tcp: rstreason: introduce SK_RST_REASON_TCP_KEEPALIVE_TIMEOUT for active reset

Introducing this to show the users the reason of keepalive timeout.

Signed-off-by: Jason Xing <kernelxing@tencent.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agotcp: rstreason: introduce SK_RST_REASON_TCP_STATE for active reset
Jason Xing [Fri, 2 Aug 2024 10:21:09 +0000 (18:21 +0800)] 
tcp: rstreason: introduce SK_RST_REASON_TCP_STATE for active reset

Introducing a new type TCP_STATE to handle some reset conditions
appearing in RFC 793 due to its socket state. Actually, we can look
into RFC 9293 which has no discrepancy about this part.

Signed-off-by: Jason Xing <kernelxing@tencent.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agotcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_MEMORY for active reset
Jason Xing [Fri, 2 Aug 2024 10:21:08 +0000 (18:21 +0800)] 
tcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_MEMORY for active reset

Introducing a new type TCP_ABORT_ON_MEMORY for tcp reset reason to handle
out of memory case.

Signed-off-by: Jason Xing <kernelxing@tencent.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agotcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_LINGER for active reset
Jason Xing [Fri, 2 Aug 2024 10:21:07 +0000 (18:21 +0800)] 
tcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_LINGER for active reset

Introducing a new type TCP_ABORT_ON_LINGER for tcp reset reason to handle
negative linger value case.

Signed-off-by: Jason Xing <kernelxing@tencent.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agotcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_CLOSE for active reset
Jason Xing [Fri, 2 Aug 2024 10:21:06 +0000 (18:21 +0800)] 
tcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_CLOSE for active reset

Introducing a new type TCP_ABORT_ON_CLOSE for tcp reset reason to handle
the case where more data is unread in closing phase.

Signed-off-by: Jason Xing <kernelxing@tencent.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agoMerge tag 'linux-can-next-for-6.12-20240806' of git://git.kernel.org/pub/scm/linux...
Jakub Kicinski [Wed, 7 Aug 2024 02:44:21 +0000 (19:44 -0700)] 
Merge tag 'linux-can-next-for-6.12-20240806' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next

Marc Kleine-Budde says:

====================
pull-request: can-next 2024-08-06

The first patch is by Frank Li and adds the can-transceiver property
to the flexcan device-tree bindings.

Haibo Chen contributes 2 patches for the flexcan driver to add wakeup
support for the imx95.

The 2 patches by Stefan Mätje for the esd_402_pci driver clean up the
driver and add support for the one-shot mode.

The last 15 patches are by Jimmy Assarsson and add hardware timestamp
support for all devices covered by the kvaser_usb driver.

* tag 'linux-can-next-for-6.12-20240806' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next:
  can: kvaser_usb: Rename kvaser_usb_{ethtool,netdev}_ops_hwts to kvaser_usb_{ethtool,netdev}_ops
  can: kvaser_usb: Remove struct variables kvaser_usb_{ethtool,netdev}_ops
  can: kvaser_usb: Remove KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP
  can: kvaser_usb: leaf: Add hardware timestamp support to usbcan devices
  can: kvaser_usb: leaf: Store MSB of timestamp
  can: kvaser_usb: leaf: Add structs for Tx ACK and clock overflow commands
  can: kvaser_usb: leaf: Add hardware timestamp support to leaf based devices
  can: kvaser_usb: leaf: kvaser_usb_leaf_tx_acknowledge: Rename local variable
  can: kvaser_usb: leaf: Replace kvaser_usb_leaf_m32c_dev_cfg with kvaser_usb_leaf_m32c_dev_cfg_{16,24,32}mhz
  can: kvaser_usb: leaf: Assign correct timestamp_freq for kvaser_usb_leaf_imx_dev_cfg_{16,24,32}mhz
  can: kvaser_usb: leaf: Add struct for Tx ACK commands
  can: kvaser_usb: hydra: Set hardware timestamp on transmitted packets
  can: kvaser_usb: hydra: Add struct for Tx ACK commands
  can: kvaser_usb: hydra: kvaser_usb_hydra_ktime_from_rx_cmd: Drop {rx_} in function name
  can: kvaser_usb: Add helper functions to convert device timestamp into ktime
  can: esd_402_pci: Add support for one-shot mode
  can: esd_402_pci: Rename esdACC CTRL register macros
  can: flexcan: add wakeup support for imx95
  dt-bindings: can: fsl,flexcan: move fsl,imx95-flexcan standalone
  dt-bindings: can: fsl,flexcan: add common 'can-transceiver' for fsl,flexcan
====================

Link: https://patch.msgid.link/20240806074731.1905378-1-mkl@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet/chelsio/libcxgb: Add __percpu annotations to libcxgb_ppm.c
Uros Bizjak [Sun, 4 Aug 2024 15:46:09 +0000 (17:46 +0200)] 
net/chelsio/libcxgb: Add __percpu annotations to libcxgb_ppm.c

Compiling libcxgb_ppm.c results in several sparse warnings:

libcxgb_ppm.c:368:15: warning: incorrect type in assignment (different address spaces)
libcxgb_ppm.c:368:15:    expected struct cxgbi_ppm_pool *pools
libcxgb_ppm.c:368:15:    got void [noderef] __percpu *_res
libcxgb_ppm.c:374:48: warning: incorrect type in initializer (different address spaces)
libcxgb_ppm.c:374:48:    expected void const [noderef] __percpu *__vpp_verify
libcxgb_ppm.c:374:48:    got struct cxgbi_ppm_pool *
libcxgb_ppm.c:484:19: warning: incorrect type in assignment (different address spaces)
libcxgb_ppm.c:484:19:    expected struct cxgbi_ppm_pool [noderef] __percpu *pool
libcxgb_ppm.c:484:19:    got struct cxgbi_ppm_pool *[assigned] pool
libcxgb_ppm.c:511:21: warning: incorrect type in argument 1 (different address spaces)
libcxgb_ppm.c:511:21:    expected void [noderef] __percpu *__pdata
libcxgb_ppm.c:511:21:    got struct cxgbi_ppm_pool *[assigned] pool

Add __percpu annotation to *pools and *pool percpu pointers and to
ppm_alloc_cpu_pool() function that returns percpu pointer to fix
these warnings.

Compile tested only, but there is no difference in the resulting object file.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240804154635.4249-1-ubizjak@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet: phy: phy_device: fix PHY WOL enabled, PM failed to suspend
Youwan Wang [Wed, 31 Jul 2024 09:15:37 +0000 (17:15 +0800)] 
net: phy: phy_device: fix PHY WOL enabled, PM failed to suspend

If the PHY of the mido bus is enabled with Wake-on-LAN (WOL),
we cannot suspend the PHY. Although the WOL status has been
checked in phy_suspend(), returning -EBUSY(-16) would cause
the Power Management (PM) to fail to suspend. Since
phy_suspend() is an exported symbol (EXPORT_SYMBOL),
timely error reporting is needed. Therefore, an additional
check is performed here. If the PHY of the mido bus is enabled
with WOL, we skip calling phy_suspend() to avoid PM failure.

From the following logs, it has been observed that the phydev->attached_dev
is NULL, phydev is "stmmac-0:01", it not attached, but it will affect suspend
and resume.The actually attached "stmmac-0:00" will not dpm_run_callback():
mdio_bus_phy_suspend().

init log:
[    5.932502] YT8521 Gigabit Ethernet stmmac-0:00: attached PHY driver
(mii_bus:phy_addr=stmmac-0:00, irq=POLL)
[    5.932512] YT8521 Gigabit Ethernet stmmac-0:01: attached PHY driver
(mii_bus:phy_addr=stmmac-0:01, irq=POLL)
[   24.566289] YT8521 Gigabit Ethernet stmmac-0:00: yt8521_read_status,
link down, media: UTP

suspend log:
[  322.631362] OOM killer disabled.
[  322.631364] Freezing remaining freezable tasks
[  322.632536] Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
[  322.632540] printk: Suspending console(s) (use no_console_suspend to debug)
[  322.633052] YT8521 Gigabit Ethernet stmmac-0:01:
PM: dpm_run_callback(): mdio_bus_phy_suspend+0x0/0x110 [libphy] returns -16
[  322.633071] YT8521 Gigabit Ethernet stmmac-0:01:
PM: failed to suspend: error -16
[  322.669699] PM: Some devices failed to suspend, or early wake event detected
[  322.669949] OOM killer enabled.
[  322.669951] Restarting tasks ... done.
[  322.671008] random: crng reseeded on system resumption
[  322.671014] PM: suspend exit

Add a function that phylib can inquire of the driver whether WoL
has been enabled at the PHY.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Youwan Wang <youwan@nfschina.com>
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
Link: https://patch.msgid.link/20240731091537.771391-1-youwan@nfschina.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet: veth: Disable netpoll support
Breno Leitao [Mon, 5 Aug 2024 09:40:11 +0000 (02:40 -0700)] 
net: veth: Disable netpoll support

The current implementation of netpoll in veth devices leads to
suboptimal behavior, as it triggers warnings due to the invocation of
__netif_rx() within a softirq context. This is not compliant with
expected practices, as __netif_rx() has the following statement:

lockdep_assert_once(hardirq_count() | softirq_count());

Given that veth devices typically do not benefit from the
functionalities provided by netpoll, Disable netpoll for veth
interfaces.

Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20240805094012.1843247-1-leitao@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoethtool: cmis_cdb: Remove unused declaration ethtool_cmis_page_fini()
Yue Haibing [Sat, 3 Aug 2024 11:22:13 +0000 (19:22 +0800)] 
ethtool: cmis_cdb: Remove unused declaration ethtool_cmis_page_fini()

ethtool_cmis_page_fini() is declared but never implemented.

Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
Reviewed-by: Danielle Ratson <danieller@nvidia.com>
Link: https://patch.msgid.link/20240803112213.4044015-1-yuehaibing@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agotcp: Use clamp() in htcp_alpha_update()
Christophe JAILLET [Sun, 4 Aug 2024 06:20:17 +0000 (08:20 +0200)] 
tcp: Use clamp() in htcp_alpha_update()

Using clamp instead of min(max()) is easier to read and it matches even
better the comment just above it.

It also reduces the size of the preprocessed files by ~ 2.5 ko.
(see [1] for a discussion about it)

$ ls -l net/ipv4/tcp_htcp*.i
 5576024 27 juil. 10:19 net/ipv4/tcp_htcp.old.i
 5573550 27 juil. 10:21 net/ipv4/tcp_htcp.new.i

[1]: https://lore.kernel.org/all/23bdb6fc8d884ceebeb6e8b8653b8cfe@AcuMS.aculab.com/

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/561bb4974499a328ac39aff31858465d9bd12b1c.1722752370.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet: airoha: honor reset return value in airoha_hw_init()
Lorenzo Bianconi [Sat, 3 Aug 2024 15:50:50 +0000 (17:50 +0200)] 
net: airoha: honor reset return value in airoha_hw_init()

Take into account return value from reset_control_bulk_assert and
reset_control_bulk_deassert routines in airoha_hw_init().

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/f49dc04a87653e0155f4fab3e3eb584785c8ad6a.1722699555.git.lorenzo@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoMAINTAINERS: Update Mellanox website links
Rahul Rameshbabu [Mon, 5 Aug 2024 05:22:02 +0000 (08:22 +0300)] 
MAINTAINERS: Update Mellanox website links

Point to the nvidia.com domain.

Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20240805052202.2005316-1-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoMerge branch 'mlx5-ptm-cross-timestamping-support'
Jakub Kicinski [Mon, 5 Aug 2024 23:44:46 +0000 (16:44 -0700)] 
Merge branch 'mlx5-ptm-cross-timestamping-support'

Tariq Toukan says:

====================
mlx5 PTM cross timestamping support

This patchset by Rahul and Carolina adds PTM (Precision Time Measurement)
support to the mlx5 driver.

PTM is a PCI extended capability introduced by PCI-SIG for providing an
accurate read of the device clock offset without being impacted by
asymmetric bus transfer rates.

The performance of PTM on ConnectX-7 was evaluated using both real-time
(RTC) and free-running (FRC) clocks under traffic and no traffic
conditions. Tests with phc2sys measured the maximum offset values at a 50Hz
rate, with and without PTM.

Results:

1. No traffic
+-----+--------+--------+
|     | No-PTM | PTM    |
+-----+--------+--------+
| FRC | 125 ns | <29 ns |
+-----+--------+--------+
| RTC | 248 ns | <34 ns |
+-----+--------+--------+

2. With traffic
+-----+--------+--------+
|     | No-PTM | PTM    |
+-----+--------+--------+
| FRC | 254 ns | <40 ns |
+-----+--------+--------+
| RTC | 255 ns | <45 ns |
+-----+--------+--------+

v2: https://lore.kernel.org/d1dba3e1-2ecc-4fdf-a23b-7696c4bccf45@gmail.com
====================

Link: https://patch.msgid.link/20240730134055.1835261-1-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet/mlx5: Implement PTM cross timestamping support
Rahul Rameshbabu [Tue, 30 Jul 2024 13:40:54 +0000 (16:40 +0300)] 
net/mlx5: Implement PTM cross timestamping support

Expose Precision Time Measurement support through related PTP ioctl.

The performance of PTM on ConnectX-7 was evaluated using both real-time
(RTC) and free-running (FRC) clocks under traffic and no traffic
conditions. Tests with phc2sys measured the maximum offset values at a 50Hz
rate, with and without PTM.

Results:

1. No traffic
+-----+--------+--------+
|     | No-PTM | PTM    |
+-----+--------+--------+
| FRC | 125 ns | <29 ns |
+-----+--------+--------+
| RTC | 248 ns | <34 ns |
+-----+--------+--------+

2. With traffic
+-----+--------+--------+
|     | No-PTM | PTM    |
+-----+--------+--------+
| FRC | 254 ns | <40 ns |
+-----+--------+--------+
| RTC | 255 ns | <45 ns |
+-----+--------+--------+

Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Co-developed-by: Carolina Jubran <cjubran@nvidia.com>
Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
Tested-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20240730134055.1835261-4-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet/mlx5: Add support for enabling PTM PCI capability
Carolina Jubran [Tue, 30 Jul 2024 13:40:53 +0000 (16:40 +0300)] 
net/mlx5: Add support for enabling PTM PCI capability

Since the kernel doesn't support enabling Precision Time Measurement
for an endpoint device, enable the PTM PCI capability in the driver.

Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
Tested-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20240730134055.1835261-3-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet/mlx5: Add support for MTPTM and MTCTR registers
Rahul Rameshbabu [Tue, 30 Jul 2024 13:40:52 +0000 (16:40 +0300)] 
net/mlx5: Add support for MTPTM and MTCTR registers

Make Management Precision Time Measurement (MTPTM) register and Management
Cross Timestamp (MTCTR) register usable in mlx5 driver.

Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
Tested-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20240730134055.1835261-2-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agotools: ynl: remove extraneous ; after statements
Colin Ian King [Fri, 2 Aug 2024 11:34:36 +0000 (12:34 +0100)] 
tools: ynl: remove extraneous ; after statements

There are a couple of statements with two following semicolons,
replace these with just one semicolon.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://patch.msgid.link/20240802113436.448939-1-colin.i.king@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoMerge branch 'net-constify-struct-net-parameter-of-socket-lookups'
Jakub Kicinski [Mon, 5 Aug 2024 23:22:51 +0000 (16:22 -0700)] 
Merge branch 'net-constify-struct-net-parameter-of-socket-lookups'

Eric Dumazet says:

====================
net: constify 'struct net' parameter of socket lookups

We should keep const qualifiers whenever possible.

This series should remove the need for Tom patch in :

Link: https://lore.kernel.org/netdev/20240731172332.683815-2-tom@herbertland.com/
====================

Link: https://patch.msgid.link/20240802134029.3748005-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoipv6: udp: constify 'struct net' parameter of socket lookups
Eric Dumazet [Fri, 2 Aug 2024 13:40:29 +0000 (13:40 +0000)] 
ipv6: udp: constify 'struct net' parameter of socket lookups

Following helpers do not touch their 'struct net' argument.

- udp6_lib_lookup()
- __udp6_lib_lookup()

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240802134029.3748005-6-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoinet6: constify 'struct net' parameter of various lookup helpers
Eric Dumazet [Fri, 2 Aug 2024 13:40:28 +0000 (13:40 +0000)] 
inet6: constify 'struct net' parameter of various lookup helpers

Following helpers do not touch their struct net argument:

- bpf_sk_lookup_run_v6()
- __inet6_lookup_established()
- inet6_lookup_reuseport()
- inet6_lookup_listener()
- inet6_lookup_run_sk_lookup()
- __inet6_lookup()
- inet6_lookup()

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240802134029.3748005-5-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoudp: constify 'struct net' parameter of socket lookups
Eric Dumazet [Fri, 2 Aug 2024 13:40:27 +0000 (13:40 +0000)] 
udp: constify 'struct net' parameter of socket lookups

Following helpers do not touch their 'struct net' argument.

- udp_sk_bound_dev_eq()
- udp4_lib_lookup()
- __udp4_lib_lookup()

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240802134029.3748005-4-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoinet: constify 'struct net' parameter of various lookup helpers
Eric Dumazet [Fri, 2 Aug 2024 13:40:26 +0000 (13:40 +0000)] 
inet: constify 'struct net' parameter of various lookup helpers

Following helpers do not touch their struct net argument:

- bpf_sk_lookup_run_v4()
- inet_lookup_reuseport()
- inet_lhash2_lookup()
- inet_lookup_run_sk_lookup()
- __inet_lookup_listener()
- __inet_lookup_established()

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240802134029.3748005-3-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoinet: constify inet_sk_bound_dev_eq() net parameter
Eric Dumazet [Fri, 2 Aug 2024 13:40:25 +0000 (13:40 +0000)] 
inet: constify inet_sk_bound_dev_eq() net parameter

inet_sk_bound_dev_eq() and its callers do not modify the net structure.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240802134029.3748005-2-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoMerge patch series "can: kvaser_usb: Add hardware timestamp support to all devices"
Marc Kleine-Budde [Mon, 5 Aug 2024 15:39:05 +0000 (17:39 +0200)] 
Merge patch series "can: kvaser_usb: Add hardware timestamp support to all devices"

Jimmy Assarsson <extja@kvaser.com> says:

This patch series add hardware timestamp support to all devices supported
by the kvaser_usb driver.

The first patches resolves a known issue; "Hardware timestamps are not set
for CAN Tx frames". I can't remember why this wasn't implemented in the
first version of the hydra driver.

Followed by, hardware timestamp support for leaf and usbcan based devices.

The final patches are removing code used for selecting the correct ethtool
and netdev ops.

Note: This patch series depends on patch
"can: kvaser_usb: Explicitly initialize family in leafimx..." [1].

[1] https://lore.kernel.org/linux-can/20240628194529.312968-1-extja@kvaser.com

Changes in v2:
- Replaced patch 3/15
  can: kvaser_usb: Add function kvaser_usb_ticks_to_ktime()
  with a new patch
  can: kvaser_usb: Add helper functions to convert device timestamp into ktime
  and put it first in this series
- Resolved Vincent MAILHOL's review comments regarding duplicated code when converting timestamps [2] [3]
- As pointed out by Vincent MAILHOL [4], the clock overflow commands is not
  dispatched in this patch
  moved code from 10/15
  can: kvaser_usb: leaf: Add structs for Tx ACK and clock overflow commands
  to 11/15
  can: kvaser_usb: leaf: Store MSB of timestamp
  where it's actually used

[2] https://lore.kernel.org/linux-can/CAMZ6RqKSa-6KjvgfmN9eL7A=A65gMkYsRrnaF41Azhsc45FA2Q@mail.gmail.com/
[3] https://lore.kernel.org/linux-can/CAMZ6Rq+Xd7+th=dKV+vrqzRtS+GY-xq2UziH1CURcQ3HxEXMqQ@mail.gmail.com/
[4] https://lore.kernel.org/linux-can/CAMZ6RqKqJX6eqogS2598BFm-AN1uOBbBGL+MkoJtR=-z379Q=w@mail.gmail.com/

Link: https://lore.kernel.org/all/20240701154936.92633-1-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: kvaser_usb: Rename kvaser_usb_{ethtool,netdev}_ops_hwts to kvaser_usb_{ethtool...
Jimmy Assarsson [Mon, 1 Jul 2024 15:49:36 +0000 (17:49 +0200)] 
can: kvaser_usb: Rename kvaser_usb_{ethtool,netdev}_ops_hwts to kvaser_usb_{ethtool,netdev}_ops

Now when we only got one set of ethtool_ops and netdev_ops, remove the
"hwts" suffix from the struct variables
kvaser_usb_{ethtool,netdev}_ops_hwts.

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20240701154936.92633-16-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: kvaser_usb: Remove struct variables kvaser_usb_{ethtool,netdev}_ops
Jimmy Assarsson [Mon, 1 Jul 2024 15:49:35 +0000 (17:49 +0200)] 
can: kvaser_usb: Remove struct variables kvaser_usb_{ethtool,netdev}_ops

Remove no longer used struct variables, kvaser_usb_ethtool_ops and
kvaser_usb_netdev_ops.

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20240701154936.92633-15-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: kvaser_usb: Remove KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP
Jimmy Assarsson [Mon, 1 Jul 2024 15:49:34 +0000 (17:49 +0200)] 
can: kvaser_usb: Remove KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP

Remove KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP, since all devices got
hardware timestamp support.

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20240701154936.92633-14-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: kvaser_usb: leaf: Add hardware timestamp support to usbcan devices
Jimmy Assarsson [Mon, 1 Jul 2024 15:49:33 +0000 (17:49 +0200)] 
can: kvaser_usb: leaf: Add hardware timestamp support to usbcan devices

Add hardware timestamp support for all usbcan based devices (M16C).
The usbcan firmware is slightly different compared to the other Kvaser USB
interfaces:
  - The timestamp is provided by a 32-bit counter, with 10us resolution.
    Hence, the hardware timestamp will wrap after less than 12 hours.
  - Each Rx CAN or Tx ACK command only contains the 16-bits LSB of the
    timestamp counter.
  - The 16-bits MSB are sent in an asynchronous event (command), if any
    change occurred in the MSB since the last event.

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20240701154936.92633-13-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: kvaser_usb: leaf: Store MSB of timestamp
Jimmy Assarsson [Mon, 1 Jul 2024 15:49:32 +0000 (17:49 +0200)] 
can: kvaser_usb: leaf: Store MSB of timestamp

Store MSB of timestamp, provided from the device via the clock overflow
event, for usbcan devices (M16C).

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20240701154936.92633-12-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: kvaser_usb: leaf: Add structs for Tx ACK and clock overflow commands
Jimmy Assarsson [Mon, 1 Jul 2024 15:49:31 +0000 (17:49 +0200)] 
can: kvaser_usb: leaf: Add structs for Tx ACK and clock overflow commands

For usbcan devices (M16C), add struct usbcan_cmd_tx_acknowledge for Tx ACK
commands and struct usbcan_cmd_clk_overflow_event for clock overflow event
commands.

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20240701154936.92633-11-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: kvaser_usb: leaf: Add hardware timestamp support to leaf based devices
Jimmy Assarsson [Mon, 1 Jul 2024 15:49:30 +0000 (17:49 +0200)] 
can: kvaser_usb: leaf: Add hardware timestamp support to leaf based devices

Add hardware timestamp support to leaf based devices (M32C and leafimx).

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20240701154936.92633-10-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: kvaser_usb: leaf: kvaser_usb_leaf_tx_acknowledge: Rename local variable
Jimmy Assarsson [Mon, 1 Jul 2024 15:49:29 +0000 (17:49 +0200)] 
can: kvaser_usb: leaf: kvaser_usb_leaf_tx_acknowledge: Rename local variable

Rename local variable skb to err_skb.

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20240701154936.92633-9-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: kvaser_usb: leaf: Replace kvaser_usb_leaf_m32c_dev_cfg with kvaser_usb_leaf_m32c...
Jimmy Assarsson [Mon, 1 Jul 2024 15:49:28 +0000 (17:49 +0200)] 
can: kvaser_usb: leaf: Replace kvaser_usb_leaf_m32c_dev_cfg with kvaser_usb_leaf_m32c_dev_cfg_{16,24,32}mhz

Add new struct kvaser_usb_dev_cfg constants,
kvaser_usb_leaf_m32c_dev_cfg_{16,24,32}mhz,
for M32C based leaf devices.

Note that the bittiming parameters are always calculated for 16MHz clock,
while the timestamps are in the actual clock frequency of the device.

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20240701154936.92633-8-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: kvaser_usb: leaf: Assign correct timestamp_freq for kvaser_usb_leaf_imx_dev_cfg_...
Jimmy Assarsson [Mon, 1 Jul 2024 15:49:27 +0000 (17:49 +0200)] 
can: kvaser_usb: leaf: Assign correct timestamp_freq for kvaser_usb_leaf_imx_dev_cfg_{16,24,32}mhz

Assign correct timestamp_freq to kvaser_usb_leaf_imx_dev_cfg_{16,24,32}mhz.
Since the driver didn't utilize the value, this didn't cause any problems.

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20240701154936.92633-7-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: kvaser_usb: leaf: Add struct for Tx ACK commands
Jimmy Assarsson [Mon, 1 Jul 2024 15:49:26 +0000 (17:49 +0200)] 
can: kvaser_usb: leaf: Add struct for Tx ACK commands

Add, struct leaf_cmd_tx_acknowledge, for Tx ACK commands received from leaf
devices (M32C and leafimx28).

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20240701154936.92633-6-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: kvaser_usb: hydra: Set hardware timestamp on transmitted packets
Jimmy Assarsson [Mon, 1 Jul 2024 15:49:25 +0000 (17:49 +0200)] 
can: kvaser_usb: hydra: Set hardware timestamp on transmitted packets

Set hardware timestamp on transmitted packets.

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20240701154936.92633-5-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: kvaser_usb: hydra: Add struct for Tx ACK commands
Jimmy Assarsson [Mon, 1 Jul 2024 15:49:24 +0000 (17:49 +0200)] 
can: kvaser_usb: hydra: Add struct for Tx ACK commands

Add, struct kvaser_cmd_tx_ack, for standard Tx ACK commands.

Expand kvaser_usb_hydra_ktime_from_cmd() to extract timestamps from both
standard and extended Tx ACK commands. Unsupported commands are silently
ignored, and 0 is returned.

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20240701154936.92633-4-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: kvaser_usb: hydra: kvaser_usb_hydra_ktime_from_rx_cmd: Drop {rx_} in function...
Jimmy Assarsson [Mon, 1 Jul 2024 15:49:23 +0000 (17:49 +0200)] 
can: kvaser_usb: hydra: kvaser_usb_hydra_ktime_from_rx_cmd: Drop {rx_} in function name

Rename function, since this function will be used for more than just the
rx commands.

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20240701154936.92633-3-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: kvaser_usb: Add helper functions to convert device timestamp into ktime
Jimmy Assarsson [Mon, 1 Jul 2024 15:49:22 +0000 (17:49 +0200)] 
can: kvaser_usb: Add helper functions to convert device timestamp into ktime

Add helper function kvaser_usb_ticks_to_ktime() that converts from
device ticks to ktime.
And kvaser_usb_timestamp{48,64}_to_ktime() that converts from device
48-bit or 64-bit timestamp, to ktime.

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20240701154936.92633-2-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agoMerge patch series "can: esd_402_pci: Do cleanup; Add one-shot mode"
Marc Kleine-Budde [Mon, 5 Aug 2024 15:32:02 +0000 (17:32 +0200)] 
Merge patch series "can: esd_402_pci: Do cleanup; Add one-shot mode"

Stefan Mätje <stefan.maetje@esd.eu> says:

The goal of this patch series is to do some cleanup
and also add the support for the one-shot mode before
the next patch introduces CAN-FD support for this
driver.

Link: https://lore.kernel.org/all/20240717214409.3934333-1-stefan.maetje@esd.eu
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: esd_402_pci: Add support for one-shot mode
Stefan Mätje [Wed, 17 Jul 2024 21:44:09 +0000 (23:44 +0200)] 
can: esd_402_pci: Add support for one-shot mode

This patch adds support for one-shot mode. In this mode there happens no
automatic retransmission in the case of an arbitration lost error or on
any bus error.

Signed-off-by: Stefan Mätje <stefan.maetje@esd.eu>
Link: https://lore.kernel.org/all/20240717214409.3934333-3-stefan.maetje@esd.eu
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: esd_402_pci: Rename esdACC CTRL register macros
Stefan Mätje [Wed, 17 Jul 2024 21:44:08 +0000 (23:44 +0200)] 
can: esd_402_pci: Rename esdACC CTRL register macros

Rename macros to use for esdACC CTRL register access to match the
internal documentation and to make the macro prefix consistent.

- ACC_CORE_OF_CTRL_MODE -> ACC_CORE_OF_CTRL
  Makes the name match the documentation.
- ACC_REG_CONTROL_MASK_MODE_ -> ACC_REG_CTRL_MASK_
  ACC_REG_CONTROL_MASK_ -> ACC_REG_CTRL_MASK_
  Makes the prefix consistent for macros describing masks in the same
  register (CTRL).

Signed-off-by: Stefan Mätje <stefan.maetje@esd.eu>
Link: https://lore.kernel.org/all/20240717214409.3934333-2-stefan.maetje@esd.eu
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agoMerge patch series "can: fsl,flexcan: add imx95 wakeup"
Marc Kleine-Budde [Mon, 5 Aug 2024 14:45:57 +0000 (16:45 +0200)] 
Merge patch series "can: fsl,flexcan: add imx95 wakeup"

The flexcan in iMX95 is not compatible with imx93 because wakeup
method is difference.

Link: https://lore.kernel.org/all/20240731-flexcan-v4-0-82ece66e5a76@nxp.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agocan: flexcan: add wakeup support for imx95
Haibo Chen [Thu, 1 Aug 2024 00:00:26 +0000 (20:00 -0400)] 
can: flexcan: add wakeup support for imx95

iMX95 defines a bit in GPR that sets/unsets the IPG_STOP signal to the
FlexCAN module, controlling its entry into STOP mode. Wakeup should work
even if FlexCAN is in STOP mode.

Due to iMX95 architecture design, the A-Core cannot access GPR; only the
system manager (SM) can configure GPR. To support the wakeup feature,
follow these steps:

- For suspend:
  1) During Linux suspend, when CAN suspends, do nothing for GPR and keep
     CAN-related clocks on.
  2) In ATF, check whether CAN needs to support wakeup; if yes, send a
     request to SM through the SCMI protocol.
  3) In SM, configure the GPR and unset IPG_STOP.
  4) A-Core suspends.

- For wakeup and resume:
  1) A-Core wakeup event arrives.
  2) In SM, deassert IPG_STOP.
  3) Linux resumes.

Add a new fsl_imx95_devtype_data and FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI to
reflect this.

Reviewed-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/all/20240731-flexcan-v4-2-82ece66e5a76@nxp.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agodt-bindings: can: fsl,flexcan: move fsl,imx95-flexcan standalone
Haibo Chen [Thu, 1 Aug 2024 00:00:25 +0000 (20:00 -0400)] 
dt-bindings: can: fsl,flexcan: move fsl,imx95-flexcan standalone

The flexcan in iMX95 is not compatible with imx93 because wakeup method is
difference. Make fsl,imx95-flexcan not fallback to fsl,imx93-flexcan.

Reviewed-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://lore.kernel.org/all/20240731-flexcan-v4-1-82ece66e5a76@nxp.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agonet: netconsole: Fix MODULE_AUTHOR format
Breno Leitao [Fri, 2 Aug 2024 08:07:23 +0000 (01:07 -0700)] 
net: netconsole: Fix MODULE_AUTHOR format

Update the MODULE_AUTHOR for netconsole, according to the format, as
stated in module.h:

use "Name <email>" or just "Name"

Suggested-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agonet: phy: vitesse: implement downshift in vsc73xx phys
Pawel Dembicki [Fri, 2 Aug 2024 05:16:09 +0000 (07:16 +0200)] 
net: phy: vitesse: implement downshift in vsc73xx phys

This commit implements downshift feature in vsc73xx family phys.

By default downshift was enabled with maximum tries.

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agonet: skbuff: sprinkle more __GFP_NOWARN on ingress allocs
Jakub Kicinski [Fri, 2 Aug 2024 00:19:56 +0000 (17:19 -0700)] 
net: skbuff: sprinkle more __GFP_NOWARN on ingress allocs

build_skb() and frag allocations done with GFP_ATOMIC will
fail in real life, when system is under memory pressure,
and there's nothing we can do about that. So no point
printing warnings.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agodt-bindings: can: fsl,flexcan: add common 'can-transceiver' for fsl,flexcan
Frank Li [Sat, 29 Jun 2024 02:17:54 +0000 (22:17 -0400)] 
dt-bindings: can: fsl,flexcan: add common 'can-transceiver' for fsl,flexcan

Add common 'can-transceiver' children node for fsl,flexcan.

Fix below warning:
arch/arm64/boot/dts/freescale/fsl-ls1028a-rdb.dtb: can@2180000: 'can-transceiver' does not match any of the regexes: 'pinctrl-[0-9]+'
        from schema $id: http://devicetree.org/schemas/net/can/fsl,flexcan.yaml#

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://lore.kernel.org/all/20240629021754.3583641-1-Frank.Li@nxp.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
10 months agoMerge branch 'dsa-en7581' into main
David S. Miller [Sun, 4 Aug 2024 14:22:31 +0000 (15:22 +0100)] 
Merge branch 'dsa-en7581' into main

Lorenzo Bianconi says:

====================
Add second QDMA support for EN7581 eth controller

EN7581 SoC supports two independent QDMA controllers to connect the
Ethernet Frame Engine (FE) to the CPU. Introduce support for the second
QDMA controller. This is a preliminary series to support multiple FE ports
(e.g. connected to a second PHY controller).

Changes since v1:
- squash patch 6/9 and 7/9
- move some duplicated code from patch 2/9 in 1/9
- cosmetics
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agonet: dsa: mt7530: Add EN7581 support
Lorenzo Bianconi [Thu, 1 Aug 2024 07:35:12 +0000 (09:35 +0200)] 
net: dsa: mt7530: Add EN7581 support

Introduce support for the DSA built-in switch available on the EN7581
development board. EN7581 support is similar to MT7988 one except
it requires to set MT7530_FORCE_MODE bit in MT753X_PMCR_P register
for on cpu port.

Tested-by: Benjamin Larsson <benjamin.larsson@genexis.eu>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Arınç ÜNAL <arinc.unal@arinc9.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agodt-bindings: net: dsa: mediatek,mt7530: Add airoha,en7581-switch
Lorenzo Bianconi [Thu, 1 Aug 2024 07:35:11 +0000 (09:35 +0200)] 
dt-bindings: net: dsa: mediatek,mt7530: Add airoha,en7581-switch

Add documentation for the built-in switch which can be found in the
Airoha EN7581 SoC.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Arınç ÜNAL <arinc.unal@arinc9.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agoMerge branch 'netns-init-cleanups' into main
David S. Miller [Sat, 3 Aug 2024 21:38:45 +0000 (22:38 +0100)] 
Merge branch 'netns-init-cleanups' into main

Kuniyuki Iwashima says:

====================
net: Random cleanup for netns initialisation.

patch 1 & 2 suppress unwanted memory allocation for net->gen->ptr[].

patch 3 ~ 6 move part of netns initialisation to prenet_init() that
do not require pernet_ops_rwsem.

v2:
  patch 1 : Removed Fixes: tag
  patch 2 : Use XOR for WARN_ON()

v1: https://lore.kernel.org/netdev/20240729210801.16196-1-kuniyu@amazon.com/
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agonet: Initialise net.core sysctl defaults in preinit_net().
Kuniyuki Iwashima [Wed, 31 Jul 2024 20:07:21 +0000 (13:07 -0700)] 
net: Initialise net.core sysctl defaults in preinit_net().

Commit 7c3f1875c66f ("net: move somaxconn init from sysctl code")
introduced net_defaults_ops to make sure that net.core sysctl knobs
are always initialised even if CONFIG_SYSCTL is disabled.

Such operations better fit preinit_net() added for a similar purpose
by commit 6e77a5a4af05 ("net: initialize net->notrefcnt_tracker earlier").

Let's initialise the sysctl defaults in preinit_net().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agonet: Slim down setup_net().
Kuniyuki Iwashima [Wed, 31 Jul 2024 20:07:20 +0000 (13:07 -0700)] 
net: Slim down setup_net().

Most initialisations in setup_net() do not require pernet_ops_rwsem
and can be moved to preinit_net().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agonet: Call preinit_net() without pernet_ops_rwsem.
Kuniyuki Iwashima [Wed, 31 Jul 2024 20:07:19 +0000 (13:07 -0700)] 
net: Call preinit_net() without pernet_ops_rwsem.

When initialising the root netns, we call preinit_net() under
pernet_ops_rwsem.

However, the operations in preinit_net() do not require pernet_ops_rwsem.

Also, we don't hold it for preinit_net() when initialising non-root netns.

To be consistent, let's call preinit_net() without pernet_ops_rwsem in
net_ns_init().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agonet: Initialise net->passive once in preinit_net().
Kuniyuki Iwashima [Wed, 31 Jul 2024 20:07:18 +0000 (13:07 -0700)] 
net: Initialise net->passive once in preinit_net().

When initialising the root netns, we set net->passive in setup_net().

However, we do it twice for non-root netns in copy_net_ns() and
setup_net().

This is because we could bypass setup_net() in copy_net_ns() if
down_read_killable() fails.

preinit_net() is a better place to put such an operation.

Let's initialise net->passive in preinit_net().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agonet: Don't register pernet_operations if only one of id or size is specified.
Kuniyuki Iwashima [Wed, 31 Jul 2024 20:07:17 +0000 (13:07 -0700)] 
net: Don't register pernet_operations if only one of id or size is specified.

We can allocate per-netns memory for struct pernet_operations by specifying
id and size.

register_pernet_operations() assigns an id to pernet_operations and later
ops_init() allocates the specified size of memory as net->gen->ptr[id].

If id is missing, no memory is allocated.  If size is not specified,
pernet_operations just wastes an entry of net->gen->ptr[] for every netns.

net_generic is available only when both id and size are specified, so let's
ensure that.

While we are at it, we add const to both fields.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agol2tp: Don't assign net->gen->ptr[] for pppol2tp_net_ops.
Kuniyuki Iwashima [Wed, 31 Jul 2024 20:07:16 +0000 (13:07 -0700)] 
l2tp: Don't assign net->gen->ptr[] for pppol2tp_net_ops.

Commit fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and
ppp parts") converted net->gen->ptr[pppol2tp_net_id] in l2tp_ppp.c to
net->gen->ptr[l2tp_net_id] in l2tp_core.c.

Now the leftover wastes one entry of net->gen->ptr[] in each netns.

Let's avoid the unwanted allocation.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: James Chapman <jchapman@katalix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agonet: pse-pd: tps23881: Fix the device ID check
Kyle Swenson [Wed, 31 Jul 2024 15:42:14 +0000 (15:42 +0000)] 
net: pse-pd: tps23881: Fix the device ID check

The DEVID register contains two pieces of information: the device ID in
the upper nibble, and the silicon revision number in the lower nibble.
The driver should work fine with any silicon revision, so let's mask
that out in the device ID check.

Fixes: 20e6d190ffe1 ("net: pse-pd: Add TI TPS23881 PSE controller driver")
Signed-off-by: Kyle Swenson <kyle.swenson@est.tech>
Reviewed-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
10 months agonet: dsa: vsc73xx: speed up MDIO bus to max allowed value
Pawel Dembicki [Wed, 31 Jul 2024 20:34:55 +0000 (22:34 +0200)] 
net: dsa: vsc73xx: speed up MDIO bus to max allowed value

According to the datasheet, the VSC73xx family's maximum internal MDIO bus
speed is 20 MHz. It also allows disabling the preamble.

This commit sets the MDIO clock prescaler to the minimum value and
disables the preamble to speed up MDIO operations.

It doesn't affect the external bus because it's configured in a different
subblock.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20240731203455.580262-1-paweldembicki@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agorxrpc: Remove unused function declarations
Yue Haibing [Wed, 31 Jul 2024 10:08:15 +0000 (18:08 +0800)] 
rxrpc: Remove unused function declarations

commit 3cec055c5695 ("rxrpc: Don't hold a ref for connection workqueue")
left behind rxrpc_put_client_conn().
And commit 248f219cb8bc ("rxrpc: Rewrite the data and ack handling code")
removed rxrpc_accept_incoming_calls() but left declaration.

Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240731100815.1277894-1-yuehaibing@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet: core: annotate socks of struct sock_reuseport with __counted_by
Dmitry Antipov [Thu, 1 Aug 2024 14:23:11 +0000 (17:23 +0300)] 
net: core: annotate socks of struct sock_reuseport with __counted_by

According to '__reuseport_alloc()', annotate flexible array member
'sock' of 'struct sock_reuseport' with '__counted_by()' and use
convenient 'struct_size()' to simplify the math used in 'kzalloc()'.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20240801142311.42837-1-dmantipov@yandex.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agotipc: guard against string buffer overrun
Simon Horman [Thu, 1 Aug 2024 18:35:37 +0000 (19:35 +0100)] 
tipc: guard against string buffer overrun

Smatch reports that copying media_name and if_name to name_parts may
overwrite the destination.

 .../bearer.c:166 bearer_name_validate() error: strcpy() 'media_name' too large for 'name_parts->media_name' (32 vs 16)
 .../bearer.c:167 bearer_name_validate() error: strcpy() 'if_name' too large for 'name_parts->if_name' (1010102 vs 16)

This does seem to be the case so guard against this possibility by using
strscpy() and failing if truncation occurs.

Introduced by commit b97bf3fd8f6a ("[TIPC] Initial merge")

Compile tested only.

Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240801-tipic-overrun-v2-1-c5b869d1f074@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoMerge branch 'ibmveth-rr-performance'
Jakub Kicinski [Fri, 2 Aug 2024 23:39:45 +0000 (16:39 -0700)] 
Merge branch 'ibmveth-rr-performance'

Nick Child says:

====================
ibmveth RR performance

This patchset aims to increase the ibmveth drivers small packet
request response rate.

These 2 patches address:
1. NAPI rescheduling technique
2. Driver-side processing of small packets

Testing over several netperf tcp_rr connections, we saw a
30% increase in transactions per second. No regressions
were observed in other workloads.
====================

Link: https://patch.msgid.link/20240801211215.128101-1-nnac123@linux.ibm.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoibmveth: Recycle buffers during replenish phase
Nick Child [Thu, 1 Aug 2024 21:12:15 +0000 (16:12 -0500)] 
ibmveth: Recycle buffers during replenish phase

When the length of a packet is under the rx_copybreak threshold, the
buffer is copied into a new skb and sent up the stack. This allows the
dma mapped memory to be recycled back to FW.

Previously, the reuse of the DMA space was handled immediately.
This means that further packet processing has to wait until
h_add_logical_lan finishes for this packet.

Therefore, when reusing a packet, offload the hcall to the replenish
function. As a result, much of the shared logic between the recycle and
replenish functions can be removed.

This change increases TCP_RR packet rate by another 15% (370k to 430k
txns). We can see the ftrace data supports this:
PREV: ibmveth_poll = 8078553.0 us / 190999.0 hits = AVG 42.3 us
NEW:  ibmveth_poll = 7632787.0 us / 224060.0 hits = AVG 34.07 us

Signed-off-by: Nick Child <nnac123@linux.ibm.com>
Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>
Link: https://patch.msgid.link/20240801211215.128101-3-nnac123@linux.ibm.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoibmveth: Optimize poll rescheduling process
Nick Child [Thu, 1 Aug 2024 21:12:14 +0000 (16:12 -0500)] 
ibmveth: Optimize poll rescheduling process

When the ibmveth driver processes less than the budget, it must call
napi_complete_done() to release the instance. This function will
return false if the driver should avoid rearming interrupts.
Previously, the driver was ignoring the return code of
napi_complete_done(). As a result, there were unnecessary calls to
enable the veth irq.
Therefore, use the return code napi_complete_done() to determine if
irq rearm is necessary.

Additionally, in the event that new data is received immediately after
rearming interrupts, rather than just rescheduling napi, also jump
back to the poll processing loop since we are already in the poll
function (and know that we did not expense all of budget).

This slight tweak results in a 15% increase in TCP_RR transaction rate
(320k to 370k txns). We can see the ftrace data supports this:
PREV: ibmveth_poll = 8818014.0 us / 182802.0 hits = AVG 48.24
NEW:  ibmveth_poll = 8082398.0 us / 191413.0 hits = AVG 42.22

Signed-off-by: Nick Child <nnac123@linux.ibm.com>
Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>
Link: https://patch.msgid.link/20240801211215.128101-2-nnac123@linux.ibm.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agolinkmode: Change return type of linkmode_andnot to bool
Simon Horman [Thu, 1 Aug 2024 20:00:03 +0000 (21:00 +0100)] 
linkmode: Change return type of linkmode_andnot to bool

linkmode_andnot() simply returns the result of bitmap_andnot().
And the return type of bitmap_andnot() is bool.
So it makes sense for the return type of linkmode_andnot()
to also be bool.

I checked all call-sites and they either ignore the return
value or treat it as a bool.

Compile tested only.

Link: https://lore.kernel.org/netdev/68088998-4486-4930-90a4-96a32f08c490@lunn.ch/
Signed-off-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240801-linkfield-bowl-v1-1-d58f68967802@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoMerge branch 'add-second-qdma-support-for-en7581-eth-controller'
Jakub Kicinski [Fri, 2 Aug 2024 23:31:13 +0000 (16:31 -0700)] 
Merge branch 'add-second-qdma-support-for-en7581-eth-controller'

Lorenzo Bianconi says:

====================
Add second QDMA support for EN7581 eth controller

EN7581 SoC supports two independent QDMA controllers to connect the
Ethernet Frame Engine (FE) to the CPU. Introduce support for the second
QDMA controller. This is a preliminary series to support multiple FE ports
(e.g. connected to a second PHY controller).
====================

Link: https://patch.msgid.link/cover.1722522582.git.lorenzo@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet: airoha: Link the gdm port to the selected qdma controller
Lorenzo Bianconi [Thu, 1 Aug 2024 14:35:10 +0000 (16:35 +0200)] 
net: airoha: Link the gdm port to the selected qdma controller

Link the running gdm port to the qdma controller used to connect with
the CPU. Moreover, load all QDMA controllers available on EN7581 SoC.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/95b515df34ba4727f7ae5b14a1d0462cceec84ff.1722522582.git.lorenzo@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet: airoha: Start all qdma NAPIs in airoha_probe()
Lorenzo Bianconi [Thu, 1 Aug 2024 14:35:09 +0000 (16:35 +0200)] 
net: airoha: Start all qdma NAPIs in airoha_probe()

This is a preliminary patch to support multi-QDMA controllers.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/b51cf69c94d8cbc81e0a0b35587f024d01e6d9c0.1722522582.git.lorenzo@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet: airoha: Allow mapping IO region for multiple qdma controllers
Lorenzo Bianconi [Thu, 1 Aug 2024 14:35:08 +0000 (16:35 +0200)] 
net: airoha: Allow mapping IO region for multiple qdma controllers

Map MMIO regions of both qdma controllers available on EN7581 SoC.
Run airoha_hw_cleanup routine for both QDMA controllers available on
EN7581 SoC removing airoha_eth module or in airoha_probe error path.
This is a preliminary patch to support multi-QDMA controllers.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/a734ae608da14b67ae749b375d880dbbc70868ea.1722522582.git.lorenzo@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet: airoha: Use qdma pointer as private structure in airoha_irq_handler routine
Lorenzo Bianconi [Thu, 1 Aug 2024 14:35:07 +0000 (16:35 +0200)] 
net: airoha: Use qdma pointer as private structure in airoha_irq_handler routine

This is a preliminary patch to support multi-QDMA controllers.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/1e40c3cb973881c0eb3c3c247c78550da62054ab.1722522582.git.lorenzo@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet: airoha: Add airoha_qdma pointer in airoha_tx_irq_queue/airoha_queue structures
Lorenzo Bianconi [Thu, 1 Aug 2024 14:35:06 +0000 (16:35 +0200)] 
net: airoha: Add airoha_qdma pointer in airoha_tx_irq_queue/airoha_queue structures

Move airoha_eth pointer in airoha_qdma structure from
airoha_tx_irq_queue/airoha_queue ones. This is a preliminary patch to
introduce support for multi-QDMA controllers available on EN7581.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/074565b82fd0ceefe66e186f21133d825dbd48eb.1722522582.git.lorenzo@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet: airoha: Move irq_mask in airoha_qdma structure
Lorenzo Bianconi [Thu, 1 Aug 2024 14:35:05 +0000 (16:35 +0200)] 
net: airoha: Move irq_mask in airoha_qdma structure

QDMA controllers have independent irq lines, so move irqmask in
airoha_qdma structure. This is a preliminary patch to support multiple
QDMA controllers.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/1c8a06e8be605278a7b2f3cd8ac06e74bf5ebf2b.1722522582.git.lorenzo@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet: airoha: Move airoha_queues in airoha_qdma
Lorenzo Bianconi [Thu, 1 Aug 2024 14:35:04 +0000 (16:35 +0200)] 
net: airoha: Move airoha_queues in airoha_qdma

QDMA controllers available in EN7581 SoC have independent tx/rx hw queues
so move them in airoha_queues structure.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/795fc4797bffbf7f0a1351308aa9bf0e65b5126e.1722522582.git.lorenzo@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agonet: airoha: Introduce airoha_qdma struct
Lorenzo Bianconi [Thu, 1 Aug 2024 14:35:03 +0000 (16:35 +0200)] 
net: airoha: Introduce airoha_qdma struct

Introduce airoha_qdma struct and move qdma IO register mapping in
airoha_qdma. This is a preliminary patch to enable both QDMA controllers
available on EN7581 SoC.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/7df163bdc72ee29c3d27a0cbf54522ffeeafe53c.1722522582.git.lorenzo@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoeth: fbnic: select DEVLINK and PAGE_POOL
Simon Horman [Fri, 2 Aug 2024 15:43:17 +0000 (16:43 +0100)] 
eth: fbnic: select DEVLINK and PAGE_POOL

Build bot reports undefined references to devlink functions.
And local testing revealed undefined references to page_pool functions.

Based on a patch by Jakub Kicinski <kuba@kernel.org>

Fixes: 1a9d48892ea5 ("eth: fbnic: Allocate core device specific structures and devlink interface")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202408011219.hiPmwwAs-lkp@intel.com/
Signed-off-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240802-fbnic-select-v2-1-41f82a3e0178@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoselftests: net: ksft: print more of the stack for checks
Jakub Kicinski [Thu, 1 Aug 2024 23:23:17 +0000 (16:23 -0700)] 
selftests: net: ksft: print more of the stack for checks

Print more stack frames and the failing line when check fails.
This helps when tests use helpers to do the checks.

Before:

  # At ./ksft/drivers/net/hw/rss_ctx.py line 92:
  # Check failed 1037698 >= 396893.0 traffic on other queues:[344612, 462380, 233020, 449174, 342298]
  not ok 8 rss_ctx.test_rss_context_queue_reconfigure

After:

  # Check| At ./ksft/drivers/net/hw/rss_ctx.py, line 387, in test_rss_context_queue_reconfigure:
  # Check|     test_rss_queue_reconfigure(cfg, main_ctx=False)
  # Check| At ./ksft/drivers/net/hw/rss_ctx.py, line 230, in test_rss_queue_reconfigure:
  # Check|     _send_traffic_check(cfg, port, ctx_ref, { 'target': (0, 3),
  # Check| At ./ksft/drivers/net/hw/rss_ctx.py, line 92, in _send_traffic_check:
  # Check|     ksft_lt(sum(cnts[i] for i in params['noise']), directed / 2,
  # Check failed 1045235 >= 405823.5 traffic on other queues (context 1)':[460068, 351995, 565970, 351579, 127270]
  not ok 8 rss_ctx.test_rss_context_queue_reconfigure

Link: https://patch.msgid.link/20240801232317.545577-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
10 months agoselftests: net: ksft: replace 95 with errno.EOPNOTSUPP
Stanislav Fomichev [Fri, 2 Aug 2024 00:03:09 +0000 (17:03 -0700)] 
selftests: net: ksft: replace 95 with errno.EOPNOTSUPP

Petr suggested to use errno.EOPNOTSUPP instead of hard-coded 95
in the new test case. Adjust existing ones to match this style.

Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20240802000309.2368-3-sdf@fomichev.me
Signed-off-by: Jakub Kicinski <kuba@kernel.org>