Commit graph

42796 commits

Author SHA1 Message Date
Shailend Chand
3afdae4885 gve: Fix TX livelock
Before this change the transmit taskqueue would enqueue itself when it
cannot find space on the NIC ring with the hope that eventually space
would be made. This results in the following livelock that only occurs
after passing ~200Gbps of TCP traffic for many hours:

                        100% CPU
┌───────────┐wait on  ┌──────────┐         ┌───────────┐
│user thread│  cpu    │gve xmit  │wait on  │gve cleanup│
│with mbuf  ├────────►│taskqueue ├────────►│taskqueue  │
│uma lock   │         │          │ NIC ring│           │
└───────────┘         └──────────┘  space  └─────┬─────┘
     ▲                                           │
     │      wait on mbuf uma lock                │
     └───────────────────────────────────────────┘

Further details about the livelock are available on
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=281560.

After this change, the transmit taskqueue no longer spins till there is
room on the NIC ring. It instead stops itself and lets the
completion-processing taskqueue wake it up.

Since I'm touching the trasnmit taskqueue I've also corrected the name
of a counter and also fixed a bug where EINVAL mbufs were not being
freed and were instead living forever on the bufring.

Signed-off-by: Shailend Chand <shailend@google.com>
Reviewed-by: markj
MFC-after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D47138

(cherry picked from commit 40097cd67c0d52e2b288e8555b12faf02768d89c)
2024-11-20 21:41:08 +00:00
Shailend Chand
1bda36a393 gve: Add DQO QPL support
DQO is the descriptor format for our next generation virtual NIC.
It is necessary to make full use of the hardware bandwidth on many
newer GCP VM shapes.

This patch extends the previously introduced DQO descriptor format
with a "QPL" mode. QPL stands for Queue Page List and refers to
the fact that the hardware cannot access arbitrary regions of the
host memory and instead expects a fixed bounce buffer comprising
of a list of pages.

The QPL aspects are similar to the already existing GQI queue
queue format: in that the mbufs being input in the Rx path have
external storage in the form of vm pages attached to them; and
in the Tx path we always copy the mbuf payload into QPL pages.

Signed-off-by: Shailend Chand <shailend@google.com>
Reviewed-by: markj
MFC-after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D46691

(cherry picked from commit 2348ac893d10f06d2d84e1e4bd5ca9f1c5da92d8)
2024-11-20 21:41:08 +00:00
Shailend Chand
c7aea09126 gve: Add DQO RDA support
DQO is the descriptor format for our next generation virtual NIC.
It is necessary to make full use of the hardware bandwidth on many
newer GCP VM shapes.

One major change with DQO from its predecessor GQI is that it uses
dual descriptor rings for both TX and RX queues.

The TX path uses a descriptor ring to send descriptors to HW, and
receives packet completion events on a TX completion ring.

The RX path posts buffers to HW using an RX descriptor ring and
receives incoming packets on an RX completion ring.

In GQI-QPL, the hardware could not access arbitrary regions of
guest memory, which is why there was a pre-negotitated bounce buffer
(QPL: Queue Page List). DQO-RDA has no such limitation.

"RDA" is in contrast to QPL and stands for "Raw DMA Addressing" which
just means that HW does not need a fixed bounce buffer and can DMA
arbitrary regions of guest memory.

A subsequent patch will introduce the DQO-QPL datapath that uses the
same descriptor format as in this patch, but will have a fixed
bounce buffer.

Signed-off-by: Shailend Chand <shailend@google.com>
Reviewed-by: markj
MFC-after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D46690

(cherry picked from commit d438b4ef0cfc6986b93d0754f49ebf3ead50f269)
2024-11-20 21:41:08 +00:00
Dag-Erling Smørgrav
3bcbd391dd gpiospi: Fix module dependencies.
MFC after:	3 days
Reviewed by:	ray
Differential Revision:	https://reviews.freebsd.org/D47570

(cherry picked from commit 79af8f72b3aff993703778423e83320df0953a37)
2024-11-19 12:40:29 +01:00
Konstantin Belousov
8925ea58c2 mlx5en: improve reporting of kernel TLS, IPSEC offload, and ratelimit caps
Sponsored by:	NVidia networking

(cherry picked from commit de7a92756f0ab50e5e243ce9ac680e27f5c41370)
2024-11-19 07:20:09 +02:00
Jose Luis Duran
2fb5f13766
sound: Include ai2s and davbus for PowerPC
Include PowerPC ai2s and davbus sound modules in the metadriver.

Reviewed by:	christos, emaste
Approved by:	emaste (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47467

(cherry picked from commit cdd3234186b19e1b9d7cfc985ef8d247552b0f11)
2024-11-19 01:19:20 +00:00
Hajimu UMEMOTO
47db906375 usb: Add support for Brainboxes USB-to-Serial adapters
PR:		277482
Reported by:	Cameron Williams

(cherry picked from commit 8eaeaf5c467866cf72701cdc34f7ab2ee3c2f123)
2024-11-17 14:17:55 +09:00
Christos Margiolis
b64867e332 Revert "sound: Make device registration more intuitive"
These KPI changes will break out-of-tree drivers. Keep the commit only
in -CURRENT.

This reverts commit 5aece3be1c.
2024-11-14 17:25:41 +01:00
Jose Luis Duran
200a3cb706
sound: Include snd_cmi only for i386 and amd64
When running FreeBSD on an arm64/aarch64 QEMU virtual machine, using the
Intel HD Audio Controller (ich6) (intel-hda), for example, and by
following the procedure in the handbook ("Setting Up the Sound Card"):

    kldload snd_driver

The following error is shown:

    KLD snd_driver.ko: depends on snd_cmi - not available or version mismatch

This is because the CMedia sound driver (snd_cmi) is only built for i386
and amd64.

Add the same guards to the snd_driver metadriver.

Reviewed by:	christos, emaste
Approved by:	emaste (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47399

(cherry picked from commit 0187bc8a472ef21ddb901f797d46075fc0d5eb14)
2024-11-14 03:19:19 +00:00
Brian Poole
23173329b0 ice(4): properly use kernel option RSS
Header ice_rss.h uses the kernel RSS interface if option RSS is defined.
However when ice_rss.h is included by ice_lib.h there is no prior
inclusion of ice_opts.h to set RSS causing ifdef RSS to always fail. Add
ice_opts.h to the top of ice_lib.h (like ice_iflib.h) so RSS can be
defined when ice_rss.h is parsed.

With that in place, compilation fails due to a missing defintion of
ICE_DEFAULT_RSS_HASH_CONFIG. It is defined in ice_rss.h only when RSS is
not defined. Since this define is not part of the kernel RSS interface
but ice-specific, it should always be defined. Move its definition
outside of ifdef RSS.

PR:		255309
Reviewed by:	mhorne, erj (earlier version)
MFC after:	3 days
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1460

(cherry picked from commit 6e5650896fe47398e49e3d81af60cc60dbb09e6e)
2024-11-13 11:47:28 -04:00
Ed Maste
ddc9bb7068 usb: fix loop in usb_config_parse
By inspection, index increment was missing.

PR:		281843
Reported by:	Matt Jacobson
Reviewed by:	bz, markj
Fixes: e4611d2626 ("usb(4): Call optional endpoint_uninit() when changing configuration or alternate setting.")
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 114080d19973331426cd826f3a961c6ea9216a53)
2024-11-13 09:26:44 -05:00
Austin Shafer
5cc7196a81 ig4(4): Add Meteor Lake PCI IDs
PR:		282389
MFC after:	3 days

(cherry picked from commit bab5e3d468305928e9e5cf1ca9efcee4c89f6a76)
2024-11-12 07:08:43 +03:00
Vladimir Kondratyev
c53ec86f0e iichid(4): Do not power down opened device in attach handler
Some iichid(4) child devices, currently hkbd(4) only, opens parent
device in their attach handlers. That breaks internal iichid(4) state
leading to rejecting any incoming data on software and hardware levels.

Fix it with adding of extra state check in iichid(4) attach handler.

Reported by:	many
Submitted by:	trasz (initial version)
PR:		280290
MFC after:	3 days

(cherry picked from commit 018cb11cb7d412b031e1be681a6a19e734473f99)
2024-11-12 07:08:33 +03:00
Konstantin Belousov
ae81fb2db3 iommu: eliminate iommu_free_ctx()
iommu_free_ctx_locked() alone is enough

Sponsored by:	Advanced Micro Devices (AMD)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week

(cherry picked from commit d97838b7c2a605932b6edf36f87abe7ccce74314)
2024-11-09 21:31:28 +02:00
Christos Margiolis
136c2b5a8e sound: Remove unused pcm_channel->data fields
No functional change intended.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D47360

(cherry picked from commit 829951f857b73faaf28cbfcf09e861668692d8a1)
2024-11-05 22:45:07 +01:00
Christos Margiolis
5aece3be1c sound: Make device registration more intuitive
The way a sound driver currently registers to sound(4) is using the
following sequence of function calls:

1. pcm_register() to initialize snddev_info.
2. pcm_addchan() calls to create the device's primary channels.
3. pcm_setstatus() to do the final setup.

While using 3 different functions in a specific order might not be very
elegant, this pattern cannot be easily avoided. However, pcm_register()
and pcm_setstatus() are especially confusing, since one would
intuitively expect:

1. pcm_register() to actually do the registration, as opposed to a basic
   initialization.
2. pcm_setstatus() to, as the name suggests, set some kind of status, as
   opposed to finalizing the registration.

This patch renames pcm_register() to pcm_init(), and pcm_setstatus() to
pcm_register(). Drivers are modified accordingly.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D47325

(cherry picked from commit 516a9c0212b003e1da0c6f4476dbe4f3f431606c)
2024-11-05 22:45:01 +01:00
Christos Margiolis
c874fcc4ca sound: Remove early SD_F_SIMPLEX and SD_F_AUTOVCHAN assignments
These flags are properly set in pcm_setstatus(), once the primary
channels have been created. The existing comment already states that
this is wrong.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D47324

(cherry picked from commit 3a7d40c692622cc614a3839491c345d945f474fe)
2024-11-05 22:44:41 +01:00
Christos Margiolis
9e36026dc3 sound: Move sndstat_register() call to pcm_setstatus()
The d->status string is populated in pcm_setstatus() anyway, so call
sndstat_register() after we populate it, and are closer to finalizing
the device creation.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D47323

(cherry picked from commit 181a31d8349088cbcead8dcbff8d62ee8af6c913)
2024-11-05 22:44:41 +01:00
Christos Margiolis
00c066cd57 sound: Move sysctl and /dev/dspX creation to pcm_setstatus()
Create the sysctl and /dev/dsp* nodes in pcm_setstatus(), which is
responsible for finalizing the device initialization, instead of doing
this in the middle of the initialization.

For the sysctl creation specifically, move them into pcm_sysinit(),
since this is where we create the rest of the sysctl nodes anyway.

A side effect of this change is, that we avoid the possibility of racing
in between pcm_register() and pcm_setstatus() by accessing /dev/dspX or
the sysctls within that window.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D47322

(cherry picked from commit 66f3eb14e955d3917f817ff346d33d839679c2cf)
2024-11-05 22:44:41 +01:00
Christos Margiolis
3dace161c2 sound: Retire pcm_veto_load
pcm_veto_load is used to prevent pcm_register() from running if the root
feeder has not been registered yet. However, feeder_register_root() is a
SYSINIT.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch, markj, emaste
Differential Revision:	https://reviews.freebsd.org/D47280

(cherry picked from commit 98cd27c8e13418fa517a02844641f390f9389987)
2024-11-05 22:44:41 +01:00
Mark Johnston
26d85a5aba geom_flashmap: Rename the kernel module
Absent a linker.hints, if a module dependency exists on disk, the loader
will automatically load it.  That is, if something depends on module
foo, and foo.ko exists, we'll load foo.ko even though the linker hints
file is missing.  It's a bit of a hack but it's handy.

This breaks with geom_flashmap though, since it's geom_flashmap.ko on
disk but the module is called g_flashmap.  However, pretty much every
other GEOM module is given a "geom_" prefix, so for consistency's sake
alone, it seems nice to rename the module.

PR:		274388
Reviewed by:	jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47311

(cherry picked from commit 2352336ad9b26fd21d9b0013e195e41d6d02b914)
2024-11-05 00:55:43 +00:00
Ed Maste
752c25c01c vt: add comments for KDMKTONE ioctl implementation
The KDMKTONE ioctl, introduced in commit 916347f77e, is used to beep
the PC speaker.  For historical reasons the frequency is specified as an
8254 PIT divisor for a 1.19MHz clock.  Linux provides this same ioctl.
Add a comment to vtterm_beep to avoid someone wanting to "fix" this in
the future.

Also add an XXX comment that the period unit is supposed to be "timer
ticks."  Note that nothing in the base system uses this ioctl.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47395

(cherry picked from commit adba3c74209eb5d2197b9092002cc9d7505fd3c6)
2024-11-04 08:54:10 -05:00
Warner Losh
1c9f1cb4f0 vt: Fix frequency calcuation for bell
386BSD provided a MD function sysbeep. This took two arguments (pitch
and period). Pitch was jammed into the PIT's divisor directly (which
means the argument was expected to sound a tone at '1193182 / pitch'
Hz). FreeBSD inherited this interface.

In commit e465985885 (svn 177642, Mar 26 2008), phk changed this
function to take a tone to sound in hz. He converted all in-tree
instances of 1193182 / hz to just hz (and kept the few misguided folks
that passed hz directly unchanged -- this was part of what motivated the
change). He converted the places where we pre-computed the 8254 divisor
from being pitch to 1193182 / pitch (since that converts the divisor to
the frequency and the interfaces that were exposed to userland exposed
it in these units in places, continuing the tradition inherited from SCO
System V/386 Unix in spots).

In 2009, Ed Shouten was contracted by the FreeBSD Foundation to write /
finish newcons. This work was done in perforce and was imported into
subversion in user/ed/newcons in revision 199072
(https://svnweb.freebsd.org/base?view=revision&revision=199072) which
was later imported into FreeBSD by ray@ (Aleksandr Rybalko).

From that earliest import into svn import to this date, we ring the bell
with:
      sysbeep(1193182 / VT_BELLPITCH, VT_BELLDURATION);
where VT_BELLPITCH was defined to be 800. This results in a bell
frequency of 1491Hz, more or less today. This is similar to the
frequency that syscons and pcvt used (1493Hz and 1500Hz respectively).
This in turn was inherited from 386BSD, it seems, which used the hard
coded value 0x31b which is 795 -> 1500Hz.

This '800' was intended to be the bell tone (eg 800Hz) and this
interface was one that wasn't converted. The most common terminal prior
to the rise of PCs was the VT100, which had an approximately 800Hz
bell. Ed Shouten has confirmed that the original intent was 800Hz and
changing this was overlooked after the change to -current was made.
This restors that original intent and makes the bell less obnoxious in
the process.

Reviewed by:		des, adrian
Differential Revision:	https://reviews.freebsd.org/D32594
Sponsored by:		Netflix

(cherry picked from commit ba48d52ca6)

This change was accidentally reverted in 80f21bb039.

(cherry picked from commit 2416be588ea113cc06b924ed85861ed3bc391fe0)
2024-11-03 11:57:19 -05:00
Colin Percival
c2cd78d944 GPIO: Add ACPI _AEI support
Changes to acpi_gpiobus.c handle discovering and parsing the _AEI
objects and storing necessary data in device ivars.  A new gpioaei.c
file implements the device, which simply requests an interrupt when
the pin is triggered and invokes the appropriate _Exx or _Lxx ACPI
method.

This makes the GPIO "power button" work on arm64 Graviton systems,
allowing EC2 "Stop"/"Reboot" instance calls to be handled cleanly.
(Prior to this change, those requests would time out after 4 minutes
and the instance would be forcibly killed.)

Reviwed by:	imp, andrew, Ahmad Khalifa
MFC after:	3 days
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D47253
Co-authored-by:	Andrew Turner <andrew@FreeBSD.org>

(cherry picked from commit 9709bda03cd0f20eba0ba4276fc3c2e06354a54f)
2024-11-03 08:01:28 -08:00
Colin Percival
1f69417607 acpi_gpiobus: Narrow scope of NOT_YET
GPIO interrupts work just fine and will be used shortly.  We still
do not support GPIO_INTR_SHAREABLE however, so leave that within
the NOT_YET scope.

Reviwed by:	andrew
MFC after:	1 week
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D47251

(cherry picked from commit 2d4219919a48aa6d67ae62e2b8859ffe3b035bd2)
2024-11-03 08:01:27 -08:00
Colin Percival
fffdfe2f67 gpiobus: Make gpiobus_read_ivar extern
This allows acpi_gpiobus to override the method and fall back to the
generic gpiobus_read_ivar function if needed.

Reviewed by:	andrew
MFC after:	1 week
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D47250

(cherry picked from commit bc0d10d01c3c69004d600e14d53cd0dceffe4b09)
2024-11-03 08:01:27 -08:00
Colin Percival
5fa51c3653 ACPI: Add ACPI_Q_AEI_NOPULL quirk and use in EC2
AWS Graviton [1234] systems have a bug in their ACPI where they mark
the PL061's GPIO pins as needing to be configured in PullUp mode (in
fact the PL061 has no pullup/pulldown resistors); this flag needs to
be removed in order for _AEI objects to be handled on these systems.

Reviewed by:	Ali Saidi
MFC after:	1 week
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D47239

(cherry picked from commit 2f3f867ac6dd7ff3769366b828b79c44b38828e1)
2024-11-03 08:01:27 -08:00
Colin Percival
e177e64294 ACPI: Implement power button on !x86
ACPI sleep states are only implemented on x86 systems, so having the
ACPI power button attempt to enter "S5" (or other state as configured
via the hw.acpi.power_button_state sysctl) is not useful.

On non-x86 systems, implement the power button with a call to
    shutdown_nice(RB_POWEROFF)
to shut down the system.

Reviewed by:	Andrew
Tested on:	Graviton 2
MFC after:	2 weeks
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D47094

(cherry picked from commit f41ef9d80b3d272e08dd9e2ea3c1d8d3f2818066)
2024-11-03 08:01:27 -08:00
Colin Percival
7c8f273bfb acpi_gpiobus: OR GPIO_PIN_(IN|OUT)PUT into flags
Right now flags is set to 0 before this "=" -> "|=" change, but it will
matter when the NOT_YET section above becomes effective.

MFC after:	2 weeks
Sponsored by:	Amazon

(cherry picked from commit c808132731aa999947f4f7810157d7d8d9aaf61e)
2024-11-03 08:01:27 -08:00
Ahmad Khalifa
14887d2c86 gpiobus(4): Add an acpi variant of gpiobus
This currently only implements the address space handler and attempts to
configure pins with flags obtained from ACPI.

Reviewed by:	wulf
MFC after:	1 month
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1359

(cherry picked from commit 92adaa5862d5ea94318a011e0618622d0fb72521)
2024-11-03 08:01:27 -08:00
Mark Johnston
16b24ba872 igc: Remove a bogus register write in igc_if_queues_free()
As explained in PR 277038, iflib calls IFDI_DETACH() and then
IFDI_QUEUES_FREE().  With igc, the latter writes to a register after it
has been unmapped.

igc_if_detach() already calls igc_release_hw_control(), and looking at
callers of igc_if_queues_free(), that appears to be sufficient.  So,
just remove the igc_release_hw_control() call.

PR:		277038
Reported by:	Mike Belanger <mibelanger@qnx.com>
Reviewed by:	kbowling
Tested by:	kbowling
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47293

(cherry picked from commit 35d05a14ed7e9935be1ed0fe965b91aaaa4c92ef)
2024-11-02 14:29:26 +00:00
Eric Joyner
b8ab635de4
iavf(4): Get MSI-X BAR index at runtime instead of hardcoding it
This allows iavf to load on E830 devices since those devices place their MSI-X
BAR at a different location than in previous 800 series products.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>

Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D46952

(cherry picked from commit e53a21abdf2953714e44e3c54b4bb78557cb096c)
2024-10-31 09:54:24 -07:00
osamaabb
6bf02434bd ena: Update driver version to v2.8.0
Features:
* Add support for device request reset message over AENQ
* Support LLQ entry size recommendation from device
* Support max large LLQ depth from the device
* Expand PHC infrastructures
* Configuration notification support

Bug Fixes:
* Fix leaking ifmedia resources on detach
* Fix netmap socket chain unmapping issue
* Properly reinit netmap structs upon sysctl changes
* Correctly count missing TX completions

Minor Changes:
* Add reset reason for corrupted TX/RX completion descriptors
* Add reset reason for missing admin interrupts
* Improve reset reason statistics
* Update licenses

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit ce4cc746bb4171a131ab9099947a500c0de18ff4)
2024-10-31 14:54:12 +00:00
Osama Abboud
7a39823d8e ena: Fix leaking ifmedia resources on detach
ifmedia_add() allocates an ifmedia_entry during ena_attach.
Current code doesn't release this memory during ena_detach()

This commit calls ifmedia_removeall() to properly free the
allocated memory during ena_detach().

Also, in case ena_attach fails, we need to detach ifmedia
which was allocated within ena_setup_ifnet().

This bug was first described in:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278100

Reviewed by: zlei
Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit 449496eb28daec8d5b852fa4be1e337c2957345c)
2024-10-31 14:54:12 +00:00
Osama Abboud
86ec26e7a9 ena: Support max large LLQ depth from the device
Large LLQ depth size is currently calculated by dividing the maximum
possible size of LLQ by 2.
In newer paltforms, starting from r8g the size of BAR2,
which contains LLQ, will be increased, and the maximum depth of
wide LLQ will be set according to a value set by the device, instead of
hardcoded division by 2.

The new value will be stored by the device in max_wide_llq_depth field
for drivers that expose ENA_ADMIN_LLQ_FEATURE_VERSION_1 or higher to
the device.

There is an assumption that max_llq_depth >= max_wide_llq_depth, since
they both use the same bar, and if it is possible to have a wide LLQ
of size max_wide_llq_depth, it is possible to have a normal LLQ of the
same size, since it will occupy half of the space.

Also moved the large LLQ case calculation of max_tx_queue_size
before its rounddown.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit d0419551d96c8f995bdf6388a8e69684be33f9b5)
2024-10-31 14:54:11 +00:00
Osama Abboud
4d18878ada ena: Support LLQ entry size recommendation from device
This commit adds support for receiving LLQ entry size recommendation
from the device. The driver will use the recommended entry size, unless
the user specifically chooses to use regular or large LLQ entry.

Also added enum ena_llq_header_size_policy_t and llq_plociy field in
order to support the new feature.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit b1c38df05d79c81ee1e9fd0942774820a4ffcb63)
2024-10-31 14:54:11 +00:00
Osama Abboud
ebb857f4ce ena: Add support for device request reset message over AENQ
This commit adds a handler for the new aenq message
ENA_ADMIN_DEVICE_REQUEST_RESET,
which in turn causes the driver to trigger reset of a new type:
ENA_REGS_RESET_DEVICE_REQUEST. Also adds counting of such occurrences in
a new statistic for it.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit 705879424bc76fcc925e78eb7643dbf4bd9a11eb)
2024-10-31 14:54:11 +00:00
Osama Abboud
9aa14351c1 ena: Reinit netmap adapter struct upon sysctl changes
When attaching ENA driver, ena_netmap_attach() is invoked which, in turn
calls netmap_attach which, initializes a struct netmap_adapter,
allocating the struct's netmap_ring and the struct selinfo.

When we change the interface number of queues we need to reinit the
netmap adapter struct as well, so we need to detach it in order to free
the memory allocated by netmap_attach and allocate new memory based on
the new parameters like number of rings, ring size etc...

Without detaching and attaching the netmap interface, if we're to change
the number of queues from 8 to 2 for example and try to enable netmap,
the kernel will panic since the original netmap struct within the
kernel's possession still thinks that the driver has 8 queues which will
eventually cause a non-allocated virtual address access fault.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit f9c9c01de87e0440380b939c684d9939d48ce175)
2024-10-31 14:54:11 +00:00
Osama Abboud
8b43095ad8 ena: Clear NS_MOREFRAG flag for last netmap slot
When processing packets within the rx-flow
ena_netmap_rx_load_desc doesn't know the number of descriptors, so it
sets NS_MOREFRAG to all the slots to indicate that there are more
fragments for this packet.
The code calls ena_netmap_rx_load_desc() for every descriptor in
this packet to map the relevant buffer into the netmap shared memory.
After ena_netmap_rx_load_desc() calls, we need to unset the NS_MOREFRAG
for the last fragment to indicate that this is the last fragment,
so we explicitly turn off NS_MOREFRAG flag.
Current code overrides all other flags and sets NS_BUF_CHANGED.
This patch unsets the relevant flag only.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit 2f17afd19a3534dc1755c52edb0c2f70ea0eb1e4)
2024-10-31 14:54:11 +00:00
Osama Abboud
b0830d2b6b ena: Handle wrap around for prefetch in netmap
Netmap index wraps around based on the number of netmap kernel ring
slots.
Currently the driver prefetches the next slot using nm_i + 1 which may
be wrong since it does not handle wrap around.
This patch fixes that by using the kernel API for fetching the next
netmap index.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit ce20b51cb71bfb548fcaafc4bacb8290460f03d5)
2024-10-31 14:54:11 +00:00
Osama Abboud
b47eb2848a ena: Properly unmap last socket chain in netmap
In case ena_com_prepare_tx() fails within the netmap tx flow,
the driver will unmap the last socket chain.
Currently, the driver unmaps the wrong socket within
ena_netmap_unmap_last_socket_chain().

Illustration of the flow:

1- ena_netmap_tx_frames()
2- ena_netmap_tx_frame()
3- ena_netmap_tx_map_slots()
3.1- Map slot
3.2- Advance to the next socket
4- ena_com_prepare_tx()
4.1- ena_com_prepare_tx() fails
5- ena_netmap_unmap_last_socket_chain()

In step 5, where the driver unmaps the socket, the netmap
index already points at the next entry, meaning we're unmapping the
wrong socket in case ena_com_prepare_tx() fails.
In order to fix that, the driver should first update the netmap index to
point at the previous entry and only then update the socket parameters.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit f236e544a2ff685ae151f3232e3785a6a9aab035)
2024-10-31 14:54:11 +00:00
Osama Abboud
d38362c0ee ena: Make global counters style unified
This commit changes the code so all global counters will have the
same line break.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit 90953d2f829a45669b0c88a6a03da481f2d54e46)
2024-10-31 14:54:11 +00:00
Osama Abboud
cc489c17d2 ena: Trigger reset when mbuf is NULL error happens
The mbuf is NULL issue happens when the device sends the driver
a completion with a wrong request id.
Trigger a reset whenever this happens.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit da73e3a7d08c215a5d8530fea9a9730f8ac3709f)
2024-10-31 14:54:11 +00:00
Osama Abboud
db0c751ed7 ena: Add differentiation for missing TX completions reset
This commit adds differentiation for a reset caused by missing tx
completions, by verifying if the driver didn't receive tx
completions caused by missing interrupts.
The cleanup_running field was added to ena_ring because
cleanup_task.ta_pending is zeroed before ena_cleanup() runs.

Also ena_increment_reset_counter() API was added in order to support
only incrementing the reset counter.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit a33ec635d1f6d574d54e6f6d74766d070183be4c)
2024-10-31 14:54:11 +00:00
osamaabb
a20c06c6f1 ena: Set ena_min_poll_delay_us default value
This commit sets the default value for ena_min_poll_delay_us to 100.

This commit does not change the behavior of the driver, the delay is
calculated as MAX(ENA_MIN_ADMIN_POLL_US, delay_us), where the first
field is already defined as 100.
The second parameter, delay_us is taken from ena_min_poll_delay_us
which is currently unset - 0.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit 637ff00f2f9bd6c8509d0e2ac8959c7a23f09650)
2024-10-31 14:54:11 +00:00
Osama Abboud
a0594d1f65 ena: Add reset reason for missing admin interrupt
There can be cases when we trigger reset if an admin interrupt
is missing.
In order to identify this use-case specifically,
this commit adds a new reset reason.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit 274319acb48424958242d55e1b0c7d4528da7f70)
2024-10-31 14:54:10 +00:00
Osama Abboud
e445e3afde ena: Add reset reason for corrupted RX cdescs
RX completion descriptors may sometimes contain errors due
to corruption. Upon identifying such a case, the driver will
trigger a reset with an explicit reset reason
ENA_REGS_RESET_RX_DESCRIPTOR_MALFORMED.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit 4af71159db3cd4a37055b2b3d982ec53703c5c3d)
2024-10-31 14:54:10 +00:00
Osama Abboud
189bc23fd0 ena: Add reset reason for corrupted TX cdescs
TX completion descriptors may sometimes contain errors due
to corruption. Upon identifying such a case, the driver will
trigger a reset with an explicit reset reason
ENA_REGS_RESET_TX_DESCRIPTOR_MALFORMED.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit 38727218460008a500fbc18f08c90082ed678895)
2024-10-31 14:54:10 +00:00
Osama Abboud
89940eed91 ena: Improve reset reason statistics
The driver uses different reset reasons.
Some of them are counted and presented in the driver statistics.
There are cases where statistics are counted on a ring level,
but these are zeroed after a reset procedure takes place.

This commit makes the following changes:
1. Add statistics for the unrepresented reset reasons.
2. Add reset reasons which are counted on a ring level,
to be also global for better tracking.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit 89ce3f6314f6feba0e6626be51832d44df611218)
2024-10-31 14:54:10 +00:00
Osama Abboud
b1718de62f ena: Update license signatures to 2024
This commit updates all the license signatures to 2024.

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.

(cherry picked from commit 8d6806cd08c093fc001db1f94cf122368b8d1549)
2024-10-31 14:54:10 +00:00