Commit graph

607 commits

Author SHA1 Message Date
Doug Moore dc048255b3 mlx5: use roundup_pow_of_two
Use roundup_pow_of_two in place of an expression.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:22:52 -05:00
Kristof Provost 7deadea2eb mlx5: handle vlan PF restrictions
Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D45427
2024-06-17 10:50:16 +02:00
Doug Moore f0a0420dfd powerof2: replace loops with fls or ilog2
In several places, a loop tests for powers of two, or iterates through
powers of two.  In those places, replace the loop with an invocation
of fls or ilog2 without changing the meaning of the code.

Reviewed by:	alc, markj, kib, np, erj, avg (previous version)
Differential Revision:	https://reviews.freebsd.org/D45494
2024-06-12 05:00:48 -05:00
Zhenlei Huang 2439ae9483 mlx4, mlx5: Eliminate redundent NULL check for packet filter
mlx4 and mlx5 are Ethernet devices and ether_ifattach() does an
unconditional bpfattach(). From commit 16d878cc99 [1] and on, we
should not check ifp->if_bpf to tell us whether or not we have any bpf
peers that might be interested in receiving packets. And since commit
2b9600b449 [2], ifp->if_bpf can not be NULL even after the network
interface has been detached.

No functional change intended.

1. 16d878cc99 Fix the following bpf(4) race condition which can result in a panic
2. 2b9600b449 Add dead_bpf_if structure, that should be used as fake bpf_if during ifnet detach

Reviewed by:	kp, kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45196
2024-05-28 12:46:04 +08:00
Konstantin Belousov c097967b9a mlx5en: add diagnostic in one more case of failed eeprom read preparation
Sponsored by:	Nvidia Networking
MFC after:	1 week
2024-05-06 06:15:35 +03:00
Mark Johnston 47a6fb9d5a mlx5: Zero DMA memory mlx5_alloc_cmd_msg() and alloc_cmd_page()
These functions may map more memory for DMA than is actually used, since
the allocator operates on multiples of a 4KB page size.  Thus,
bus_dmamap_sync() can trigger KMSAN reports when the unused portion of
a page is not zero-ed.

Reported by:	KMSAN
Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D43133
2024-01-18 16:52:17 -05:00
Konstantin Belousov 987446fa39 mlx5(4): only detach IOV children if iov was successfully initialized
Reported by:	jwd
Sponsored by:	NVidia networking
MFC after:	1 week
2024-01-05 06:52:39 +02:00
Patrisious Haddad 0cd90ee598 mlx5: Fix HCA cap 2 query
Previously we were trying to set hca_cap_2 without checking if
sw_vhca_id_valid max value, which is the only settable value inside
hca_cap_2, and seeing that we dont have driver support for sw_vhca_id
yet there is no need to set hca_cap_2 at all, it is enough to query it.

Fixes: 7b959396ca ("mlx5: Introduce new destination type TABLE_TYPE")
MFC after:	3 days
2023-12-03 10:21:44 +02:00
Warner Losh fdafd315ad sys: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:00 -07:00
Martin Matuska a592812327 mlx5_core: fix deadlock when using RXTLS
If removing a node of type FS_TYPE_FLOW_DEST we lock the flow group too
late. This can lead to a deadlock with fs_add_dst_fg().

PR:		274715
MFC after:	1 week
Reviewed by:	kib
Tested by:	mm
Differential Revision: https://reviews.freebsd.org/D42368
2023-11-16 12:17:41 +01:00
Konstantin Belousov 97beac79ed mlx5core: add linux/bitops.h include for mlx5_ifc.h use of BIT()
Sponsored by:	NVidia networking
MFC after:	1 week
2023-11-16 01:08:17 +02:00
Patrisious Haddad 7b959396ca mlx5: Introduce new destination type TABLE_TYPE
This new destination type supports flow transition between different
table types, e.g. from NIC_RX to RDMA_RX or from RDMA_TX to NIC_TX.

In addition add driver support to be able to query the capability for
this new destination type.

Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
Sponsored by:	NVidia networking
MFC after:	1 week
2023-11-16 01:08:17 +02:00
Konstantin Belousov b94ef2a3bc mlx5ib: adjust for the mlx5_create_auto_grouped_flow_table() interface change
Sponsored by:	NVidia networking
MFC after:	1 week
2023-11-16 01:08:17 +02:00
Mark Bloch ad74454131 mlx5: add ability to attach flow counter to steering rule
Expose a way to attach a counter to a flow rule.

Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Sponsored by:	NVidia networking
MFC after:	1 week
2023-11-16 01:08:17 +02:00
Raed Salem 35bbcf0916 mlx5: add fs_counters
Signed-off-by: Raed Salem <raeds@nvidia.com>
Sponsored by:	NVidia networking
MFC after:	1 week
2023-11-16 01:08:17 +02:00
Mark Bloch 6a6af22b6e mlx5: Add a no-append flow insertion mode
This allows to insert a rule and make sure it doesn't get
combined by the steering layer with any other rule.

Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Sponsored by:	NVidia networking
MFC after:	1 week
2023-11-16 01:08:16 +02:00
Mark Bloch 0a5db6bb3a net/mlx5: Allow creating autogroups with reserved entries
Exclude the last n entries for an autogrouped flow table.

Reserving entries at the end of the FT will ensure that this FG will be
the last to be evaluated. This will be used in the next patch to create

Linux upstream commit: 79cdb0aaea8b5478db34afa1d4d5ecc808689a67
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Sponsored by:	NVidia networking
MFC after:	1 week
2023-11-16 01:08:16 +02:00
Mark Bloch 04db54fe43 net/mlx5: Fix auto group size calculation
Once all the large flow groups (defined by the user when the flow table
is created - max_num_groups) were created, then all the following new
flow groups will have only one flow table entry, even though the flow table
has place to larger groups.
Fix the condition to prefer large flow group.

Upstream Linux commit: 97fd8da281f80e7e69e0114bc906575734d4dfaf
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Sponsored by:	NVidia networking
MFC after:	1 week
2023-11-16 01:08:16 +02:00
Mark Bloch 76ed99ed8a mlx5: Use software enum in APIs instead of PRM
Users of the steering APIs shouldn't use the PRM directly.
Create an software enum to be used instead.

Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Sponsored by:	NVidia networking
MFC after:	1 week
2023-11-16 01:08:16 +02:00
Mark Bloch 45e2e55df6 mlx5: Add packet reformat support to flow rules
Allow attaching a packet reformat action to a flow rule.

Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Sponsored by:	NVidia networking
MFC after:	1 week
2023-11-16 01:08:16 +02:00
Mark Bloch 847542c60c mlx5: Add modify header support to flow rules
Allow attaching a modify header to a flow rule.

Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Sponsored by:	NVidia networking
MFC after:	1 week
2023-11-16 01:08:16 +02:00
Mark Bloch cb054a493a mlx5: Refactor flow actions into a struct
Create a struct to hold flow actions to be used when creating
a flow rule.

Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Sponsored by:	NVidia networking
MFC after:	1 week
2023-11-16 01:08:16 +02:00
Mark Bloch bb4645b95b mlx5: Add packet reformat allocation support
Add support to allocating a packet reformat context.

Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Sponsored by:	NVidia networking
MFC after:	1 week
2023-11-16 01:08:16 +02:00
Mark Bloch e4f84168b3 mlx5: Add modify header support
Add support to allocating a modify header context.

Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Sponsored by:	NVidia networking
MFC after:	1 week
2023-11-16 01:08:15 +02:00
Yishai Hadas 813d981e1e mlx5ib: Fix RSS Toeplitz setup to be aligned with the HW specification
The specification for the Toeplitz function doesn't require to set the key
explicitly to be symmetric. In case a symmetric functionality is required
a symmetric key can be simply used.

Wrongly forcing the algorithm to symmetric causes the wrong packet
distribution and a performance degradation.

Link: https://lore.kernel.org/r/20190723065733.4899-7-leon@kernel.org
Fixes: 28d6137008b2 ("IB/mlx5: Add RSS QP support")
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Reviewed-by: Alex Vainman <alexv@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

[khng: cherry-picked from Linux
b7165bd0d6cbb93732559be6ea8774653b204480]

Sponsored by:	Juniper Networks, Inc.
MFC after:      7 days
Reviewed by:	kib, zlei
Differential Revision:	https://reviews.freebsd.org/D42178
2023-10-28 16:59:09 -04:00
Ka Ho Ng 3b17328176 mlx5ib: Fix ethertype to be ETH_P_IPV6
Sponsored by:	Juniper Networks, Inc.
MFC after:	7 days
Reviewed by:	ae, kib, zlei
Differential Revision:	https://reviews.freebsd.org/D42184
2023-10-28 16:59:05 -04:00
Warner Losh 685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh 95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Hans Petter Selasky 1943c40cd6 mlx5en(4): Don't wait for receive queue to fill up with mbufs during open channels.
Failure to get mbufs may be transient.
Don't permanently fail to open the channels due to lack of mbufs.
This also makes modifying channel parameters faster.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2023-04-18 15:01:07 +02:00
Hans Petter Selasky 6bd4bb9bdb mlx5en(4): Explain why CQE zipping is off.
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2023-04-18 15:01:07 +02:00
Hans Petter Selasky 80b4ef6d10 mlx5: Remove unused debugfs node pointers.
No functional change intended.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2023-04-18 15:01:07 +02:00
Hans Petter Selasky aa7bbdabde mlx5: Implement diagostic counters as sysctl(8) nodes.
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2023-04-18 15:01:07 +02:00
Hans Petter Selasky 95bf70a4bf mlx5: Don't give zero number of pages to the firmware.
Can happen when using virtual mlx5_core<N> functions, VFs.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2023-04-18 15:01:06 +02:00
Hans Petter Selasky 273bfac08f mlx5: Implement mlx5_core_modify_cq_by_mask().
Implement one CQ modify function supporting all firmware versions,
instead of having more variants of CQ modify.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2023-04-18 15:01:06 +02:00
Hans Petter Selasky 2f7e9a8a21 mlx5: Fix duplicate free of default flow rule in error case.
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2023-04-18 15:01:06 +02:00
Hans Petter Selasky b0b87d9151 mlx5: Make mlx5_del_flow_rule() NULL safe.
This change factors out repeated NULL checks.

No functional change intended.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2023-04-18 15:01:06 +02:00
Hans Petter Selasky 3bb3e4768f mlx5: Make MLX5_COMP_EQ_SIZE tunable.
When using hardware pacing, this value can be increased, because more SQ's
means more EQ events aswell. Make it tunable, hw.mlx5.comp_eq_size .

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2023-04-18 15:01:06 +02:00
Gleb Smirnoff a6b55ee6be net: replace IFF_KNOWSEPOCH with IFF_NEEDSEPOCH
Expect that drivers call into the network stack with the net epoch
entered. This has already been the fact since early 2020. The net
interrupts, that are marked with INTR_TYPE_NET, were entering epoch
since 511d1afb6b. For the taskqueues there is NET_TASK_INIT() and
all drivers that were known back in 2020 we marked with it in
6c3e93cb5a. However in e87c494015 we took conservative approach
and preferred to opt-in rather than opt-out for the epoch.

This change not only reverts e87c494015 but adds a safety belt to
avoid panicing with INVARIANTS if there is a missed driver. With
INVARIANTS we will run in_epoch() check, print a warning and enter
the net epoch.  A driver that prints can be quickly fixed with the
IFF_NEEDSEPOCH flag, but better be augmented to properly enter the
epoch itself.

Note on TCP LRO: it is a backdoor to enter the TCP stack bypassing
some layers of net stack, ignoring either old IFF_KNOWSEPOCH or the
new IFF_NEEDSEPOCH.  But the tcp_lro_flush_all() asserts the presence
of network epoch.  Indeed, all NIC drivers that support LRO already
provide the epoch, either with help of INTR_TYPE_NET or just running
NET_EPOCH_ENTER() in their code.

Reviewed by:		zlei, gallatin, erj
Differential Revision:	https://reviews.freebsd.org/D39510
2023-04-17 09:08:35 -07:00
Zhenlei Huang da4068c4e1 mlx5ib(4): Mark driver knows net epoch
This driver has already been EPOCH(9) aware since e48813009c.

Reviewed by:	hselasky
Tested by:	hselasky
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D39406
2023-04-06 00:08:23 +08:00
Justin Hibbits 70510800d1 mlx5: Enter network epoch when using if_foreach()
Summary: IFNET_RLOCK() is not sufficient, the epoch needs entered.

Reviewed by:	hselasky
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D38711
2023-03-06 11:04:15 -05:00
Justin Hibbits 5dc00f00b7 Mechanically convert mlx5en(4) to IfAPI
Reviewed by:	zlei
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D38595
2023-02-15 09:32:41 -05:00
Gleb Smirnoff caf32b260a pfil: add pfil_mem_{in,out}() and retire pfil_run_hooks()
The 0b70e3e78b changed the original design of a single entry point
into pfil(9) chains providing separate functions for the filtering
points that always provide mbufs and know the direction of a flow.
The motivation was to reduce branching.  The logical continuation
would be to do the same for the filtering points that always provide
a memory pointer and retire the single entry point.

o Hooks now provide two functions: one for mbufs and optional for
  memory pointers.
o pfil_hook_args() has a new member and pfil_add_hook() has a
  requirement to zero out uninitialized data. Bump PFIL_VERSION.
o As it was before, a hook function for a memory pointer may realloc
  into an mbuf.  Such mbuf would be returned via a pointer that must
  be provided in argument.
o The only hook that supports memory pointers is ipfw:default-link.
  It is rewritten to provide two functions.
o All remaining uses of pfil_run_hooks() are converted to
  pfil_mem_in().
o Transparent union of pfil_packet_t and tricks to fix pointer
  alignment are retired. Internal pfil_realloc() reduces down to
  m_devget() and thus is retired, too.

Reviewed by:		mjg, ocochard
Differential revision:	https://reviews.freebsd.org/D37977
2023-02-14 10:02:49 -08:00
Elliott Mitchell 1c5e687117 mlx5: purge EOL release compatibility
Remove FreeBSD 10 support code

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/603
Differential Revision: https://reviews.freebsd.org/D35560
2023-02-04 09:13:09 -07:00
Konstantin Belousov 01143ba118 ifcapnv: fix IFCAP2 usage
IFCAP2_XXX constants are integers, they do not need shift for the
definition.  But their usage as bitmask for if_capenable2 does require
shift.  Add convenience macro IFCAP2_BIT() for consumers.

Fix the only existing consumer, mlx5(4) RXTLS enable bits.

Reported by:	jhb
Reviewed by:	jhb, jhibbits, hselasky
Coverity CID:	1501659
Sponsored by:	NVIDIA networking
Differential revision:	https://reviews.freebsd.org/D37862
2023-01-03 11:48:16 +02:00
John Baldwin 47cc457bd6 mlx5: Fix mismatch in array bounds.
Reported by:	GCC -Warray-parameter
Reviewed by:	hselasky, imp, emaste (earlier version)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D37549
2022-12-07 12:32:54 -08:00
John Baldwin f49fd63a6a kmem_malloc/free: Use void * instead of vm_offset_t for kernel pointers.
Reviewed by:	kib, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D36549
2022-09-22 15:09:19 -07:00
Randall Stewart 7cc3ea9c6f mlx5 M_TSTMP accuracy looses quite a bit of precision so lets fix it.
The way that the clock is synchronized between the system and the current mlx5 for the purposes of the M_TSTMP
being carried we loose a lot of precision. Instead lets change the math that calculates this to separate out
the seconds/nanoseconds and operate on the two values so we don't get overflow instead of just
shifting the value down and loosing precision.

Reviewed by: kib, hselasky
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D36327
2022-09-20 13:12:16 -04:00
Gordon Bergling e1a40dd294 mlx5en(4): Correct a typo in a kernel error message
- s/ouput/output

MFC after:	5 days
2022-09-03 19:29:33 +02:00
Gordon Bergling a4181a3ec3 mlx5en(4): Fix a typo in a source code comment
- s/functino/function/

MFC after:	3 days
2022-07-31 10:28:20 +02:00
Dimitry Andric 3a0b243282 Fix unused variable warning in mlx5_ib_devx.c
With clang 15, the following -Werror warning is produced:

    sys/dev/mlx5/mlx5_ib/mlx5_ib_devx.c:1926:6: error: variable 'num_alloc_xa_entries' set but not used [-Werror,-Wunused-but-set-variable]
            int num_alloc_xa_entries = 0;
                ^

The 'num_alloc_xa_entries' variable appears to have been a debugging aid
that has never been used for anything, so remove it.

MFC after:	3 days
2022-07-25 00:40:13 +02:00