Commit graph

42368 commits

Author SHA1 Message Date
Chandrakanth Patil
baa7cf2524 if_bnxt: Update Maximum Configurable MTU from 9000 to 9600
Increasing the maximum configurable MTU from 9000 to 9600 to
align with the firmware's capability of handling an MTU up to 9600.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D42954

(cherry picked from commit 8a3aab53e335dadb3c95c0eb0664143a955f1ab7)
2024-06-03 13:23:13 -06:00
Chandrakanth Patil
c75f0a568e if_bnxt: Enabled support for 1G SX, CX, and LX forced speed settings
Enabled User Configuration of 1G Speed on Wh+ SFP28 Port with AOC
cable.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D42953

(cherry picked from commit 0f8d1a9e0cd26bf4dd0b2fe2d28c1ab15d03cce4)
2024-06-03 13:23:13 -06:00
Chandrakanth Patil
30ae347bc1 if_bnxt: Incorrect Labeling of Supported Medium in ifconfig -m <inf> Command
The 1G speed on DAC medium is incorrectly labeled as 1000baseT, it
should be 1000baseCX. Updated the label accordingly.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D42952

(cherry picked from commit c5108e37fbf93a538c76325766b8a3d76a72f119)
2024-06-03 13:23:12 -06:00
Chandrakanth Patil
6288beb31e if_bnxt: Fix media speed update issue in "ifconfig -m" during PHY hot plug
Currently, if a media type (e.g., DAC) is hot-plugged out and another type
(e.g., optical cable) is hot-plugged in, the new speed is not reflected in
ifconfig. This occurs when the driver fails to update speeds with unchanged
tx and rx flow control.

To fix, a phy_type check ensures update of phy speeds upon detecting the new
phy.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D42951

(cherry picked from commit 7cbffbfcd9a5185be61bec65790674159bb7c0a8)
2024-06-03 13:23:12 -06:00
Sumit Saxena
4083c62d69 if_bnxt: Correcting the firmware package version parsing logic
The firmware package version currently appears as "Unknown" through
the sysctl interface. The parsing logic for extracting the firmware
package version from the package log has been modified to ensure
compatibility with all controllers.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D42950

(cherry picked from commit e436cb79666db3c8bb167d47ca9803c36013e32c)
2024-06-03 13:23:12 -06:00
Brooks Davis
38286d9f68 pcm: centralize 32-bit ioctl compat
Move all handlng of struct sndstioc_nv_arg(32) to sndstat_ioctl() and
make the functions that actually do the work take a buffer and size or
size pointer.  The 32-bit compat work is minimal so just inline it.

Remove checks that we've got a 32-bit process for 32-bit ioctls.  We
don't check that default ioctls are from 64-bit processes on 64-bit
systems.

Reviewed by:	christos
Differential Revision:	https://reviews.freebsd.org/D45307

(cherry picked from commit fb9013f215211f013eccc54786f299e39a1f8773)
2024-05-26 15:51:33 +02:00
Christos Margiolis
0aa767021c sound: Fix minchn, maxchn and fmts in sndstat_get_caps()
The current implementation (incorrectly) passes the channel encoding
value to AFMT_CHANNEL(), which will always return 0, since the channel
number bits are masked out by AFMT_ENCODING().

Also add missing fmts initialization and aggregate encoding formats into
it directly.

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

(cherry picked from commit 425a7bc465d4a6393c88c2e79c5ad77befda2a97)
2024-05-25 21:31:26 +02:00
Christos Margiolis
ab7c894154 sound: Handle unavailable devices in various OSS IOCTLs
mixer(8)'s -a option is used to print information about all mixer
devices in the system. To do this, it loops from 0 to
mixer_get_nmixers(), and tries to open "/dev/mixer%d". However, this
approach doesn't work when there are disabled/unregistered mixers in the
system, or when an audio device simply doesn't have a mixer.

mixer_get_nmixers() calls SNDCTL_SYSINFO and returns
oss_sysinfo->nummixers, whose value is the number of currently _enabled_
mixers only. Taking the bug report mentioned below (277615) as an
example, suppose a system with 8 mixer devices total, but 3 of them are
either disabled or non-existent, which means they will not show up under
/dev, meaning we have 5 enabled mixer devices, which is also what the
value of oss_sysinfo->nummixers will be. What mixer(8) will do is loop
from 0 to 5 (instead of 8), and start calling mixer_open() on
/dev/mixer0, up to /dev/mixer4, and as is expected, the first call will
fail right away, hence the error shown in the bug report.

To fix this, modify oss_sysinfo->nummixers to hold the value of the
maximum unit in the system, which, although not necessarily "correct",
is more intuitive for applications that will want to use this value to
loop through all mixer devices.

Additionally, notify applications that a device is
unavailable/unregistered instead of skipping it. The current
implementations of SNDCTL_AUDIOINFO, SNDCTL_MIXERINFO and
SNDCTL_CARDINFO break applications that expect to get information about
a device that is skipped. Related discussion can be found here:
https://reviews.freebsd.org/D45135#1029526

It has to be noted, that other applications, apart from mixer(8), suffer
from this.

PR:		277615
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45256

(cherry picked from commit 5d980fadf73df64a1e0eda40a93170ed76ce6f14)
2024-05-25 21:30:40 +02:00
Christos Margiolis
e8a80b4e50 sound: Separate implementations for SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO
FreeBSD's implementation of SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO
does not exactly work as intended. The problem is essentially that both
IOCTLs return the same information, while in fact the information
returned currently by dsp_oss_audioinfo() is what _only_
SNDCTL_ENGINEINFO is meant to return.

This behavior is also noted in the OSS manual [1] (see bold paragraph in
"Audio engines and device files" section), but since e8c0d15a64fa
("sound: Get rid of snd_clone and use DEVFS_CDEVPRIV(9)") we can
actually fix this, because we now expose only a single device for each
soundcard, and create the engines (channels) internally.
SNDCTL_ENGINEINFO will now report info about all channels in a given
device, and SNDCTL_AUDIOINFO[_EX] will only report information about
/dev/dspX.

To make this work, we also have to modify the SNDCTL_SYSINFO IOCTL to
report the number of audio devices and audio engines correctly.

While here, modernize the minimum and maximum channel counting in both
SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO. Currently these IOCTLs will
report only up to 2 channels, which is no longer the case.

[1] http://manuals.opensound.com/developer/SNDCTL_AUDIOINFO.html

PR:		246231, 252761
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45164

(cherry picked from commit e07f9178502b7cbc0769fc10e99ad0d013f437fd)
2024-05-25 21:30:26 +02:00
Lutz Bichler
1fb0a65ab2 snd_hda: Add patch for Asus UX331UAL
PR:		242802
MFC after:	1 day
Differential Revision:	https://reviews.freebsd.org/D45238

(cherry picked from commit 93ad59a251897431627345c287390ae134925a95)
2024-05-23 02:24:15 +02:00
Lexi Winter
07f3a9eb1c alc(4): disable MSI-X by default on Killer cards
Several users with alc(4)-based "Killer" Ethernet cards have reported
issues with this driver not passing traffic, which are solved by
disabling MSI-X using the provided tunable.

To work around this issue, disable MSI-X by default on this card.

This is done by having msix_disable default to 2, which means
"auto-detect".  The user can still override this to either 0 or 1 as
desired.

Since these are slow (1Gbps) Ethernet ICs used in low-end systems, it's
unlikely this will cause any practical performance issues; on the other
hand, the card not working by default likely causes issues for many new
FreeBSD users who find their network port doesn't work and have no idea
why.

PR:		230807
MFC after:	1 week

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1185

(cherry picked from commit 05a95d19cb248203acdd4e069d3eedfe597c3b49)
2024-05-21 13:43:34 -06:00
Christos Margiolis
45feaa73c6 sound: Correctly check nvlist_unpack() error
The current check is never false and if nvlist_unpack() fails, we might
panic later down the road.

PR:		266144
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch, emaste
Differential Revision:	https://reviews.freebsd.org/D45237

(cherry picked from commit 64f4e2db6d19d8ab520903a197fcaa8cc7ab9f9a)
2024-05-21 19:45:55 +02:00
Christos Margiolis
5830a00c2c sound: Check user-supplied size passed to SNDSTIOC_ADD_USER_DEVS*
SNDSTIOC_ADD_USER_DEVS* expects a user-supplied sndstioc_nv_arg->nbytes,
however we currently do not check whether this size is actually valid,
which results in a panic when SNDSTIOC_ADD_USER_DEVS* is called with an
invalid size. sndstat_add_user_devs() calls
sndstat_unpack_user_nvlbuf(), which then calls malloc() with that size.

PR:		266142
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D45236

(cherry picked from commit 074d337ad618f9cc2a1d5ab18b484928e57bd72b)
2024-05-21 19:45:49 +02:00
Christos Margiolis
bca6f391ae sound: Prevent uninitialized variable destruction in chn_init()
If dsp_unit2name() fails, we'll get to out2 with b, bs and devinfo
uninitialized, which will result in a panic.

Reported by:	Pierre Pronchery <pierre@freebsdfoundation.org>
Reported by:	Coverity Scan
CID:		1545029, 1545025
Pull-request:	https://github.com/freebsd/freebsd-src/pull/1240
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45272

(cherry picked from commit 5d1a5d6f1f599a4fbea9634cbe5c77f7370e1a5d)
2024-05-21 19:45:41 +02:00
Christos Margiolis
8a15d5e722 sound: Get rid of redundant assignments in chn_init()
c is allocated with M_ZERO.

Reported by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45273

(cherry picked from commit 2db2292dac7331be5414f86c3ef7863c7b6a4ac6)
2024-05-21 19:45:30 +02:00
Lexi Winter
7aba922879 sys/dev/irdma/irdma_cm: fix compile without INET
irdma_get_vlan_ipv4() calls ip_ifp_find() even if INET isn't defined, in
which case this function isn't available.

Stub this out for the non-INET case to return an error (0xffff) instead.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1156

(cherry picked from commit 0478a0356272ab3907af9d97711f0bb8b14bf38b)
2024-05-20 21:10:46 -06:00
Mark Johnston
160e7a4c16 wg: Add netmap support
When in netmap (emulated) mode, wireguard interfaces prepend or strip a
dummy ethernet header when interfacing with netmap.  The netmap
application thus sees unencrypted, de-encapsulated frames with a fixed
header.

In this mode, netmap hooks the if_input and if_transmit routines of the
ifnet.  Packets from the host TX ring are handled by wg_if_input(),
which simply hands them to the netisr layer; packets which would
otherwise be tunneled are intercepted in wg_output() and placed in the
host RX ring.

The "physical" TX ring is processed by wg_transmit(), which behaves
identically to wg_output() when netmap is not enabled, and packets
appear in the "physical" RX ring by hooking wg_deliver_in().

Reviewed by:	vmaffione
MFC after:	1 month
Sponsored by:	Klara, Inc.
Sponsored by:	Zenarmor
Differential Revision:	https://reviews.freebsd.org/D43460

(cherry picked from commit bf454ca88bdf4acfa873386e876ff5e772e6a830)
2024-05-20 09:42:35 -04:00
Christos Margiolis
a19d42b08a sound: Remove ncards variable from sound_oss_card_info()
The loop counter is also the card's index, so ncards is redundant.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45144

(cherry picked from commit 305db91d4b92a5d53826dcb6df39fc8a1f3b427e)
2024-05-17 21:30:36 +02:00
Christos Margiolis
7814ed2bd3 snd_hda: Rename LENOVO_I* to LENOVO_IDEAPAD*
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D45105

(cherry picked from commit 278953360e0e6187c3f7c688cb49254df1567f0b)
2024-05-17 21:30:36 +02:00
Christos Margiolis
9a620018af snd_hda: Add patch for Lenovo Ideapad 3
Reported by:	bsd-lists@bsdforge.com
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D45100

(cherry picked from commit 54cc353f505dbc5f19168b6b1417b6736433d9ae)
2024-05-17 21:30:36 +02:00
Christos Margiolis
15aa8688d0 sound: Rename oss_audioinfo->real_device to oss_audioinfo->legacy_device
The OSS manual now documents this field as "legacy_device".

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45138

(cherry picked from commit 24d5cc14dd60b49553ff3ee7830305621f782ff1)
2024-05-17 21:30:36 +02:00
Christos Margiolis
8bd14f511e sound: Add missing oss_mixerinfo devnode and legacy_device fields
They are missing from soundcard.h and are in fact used by some
applications, such as OSS' ossinfo(1):
http://manuals.opensound.com/developer/ossinfo.c.html

The new size for filler is chosen according to the most recent official
version of soundcard.h, which includes those 2 fields.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45137

(cherry picked from commit e6df8c379b0cf2f6d715d4903fcb1f279e38173e)
2024-05-17 21:30:36 +02:00
Christos Margiolis
2b36982887 sound: Fix oss_sysinfo->numcards
According to the OSS manual, oss_sysinfo->numcards holds the number of
detected audio devices in the system, while the current ncards variable,
whose value is assigned to oss_sysinfo->numcards, holds the number of
currently registered devices only.

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

(cherry picked from commit 59d98edae3e1a6fffd292e4393c49862d624f25f)
2024-05-17 21:30:36 +02:00
Christos Margiolis
8b4e2ba31d sound: Remove nmix variable from mixer_oss_mixerinfo()
nmix is used to compare against oss_mixerinfo->dev, which is a
user-supplied value to select the mixer device (if not -1, in which case
we'll select the default one) we want to fetch the information of. It is
also used to set oss_mixerinfo->dev in case it is -1.

However, nmix is at best redundant, since we have the loop counter
already (i), and confusing at worst.

For example, suppose a system with 3 mixer devices. We call
SNDCTL_MIXERINFO with oss_mixerinfo->dev=1, meaning we want to get
information for /dev/mixer1. Suppose /dev/mixer0 detaches while inside
the loop, so we'll hit the loop's "continue" case, and nmix won't get
incremented (i.e will stay 0 for now). At this point nmix counts 1
device less, so when it reaches 1, we'll be fetching /dev/mixer2's
information instead of /dev/mixer1's.

This is also true in case the mixer device disappears prior to the call
to mixer_oss_mixerinfo().

Simply remove nmix and use the loop counter to both set
oss_mixerinfo->dev and check against it in case a non -1 value is
supplied.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45135

(cherry picked from commit 2f31a5eb75f1e47b5c49f574e8ce48d2c863e9d3)
2024-05-17 21:30:36 +02:00
Christos Margiolis
00f9d84ee2 sound: Update pcm/vchan.c LICENSE header
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week

(cherry picked from commit 2b14465faa8dd9d228b764359672b38b4c8ca8c1)
2024-05-17 21:30:35 +02:00
Christos Margiolis
17a50abe0e sound: Remove unused "num" argument from chn_init() and related callers
It is always -1 (i.e unused).

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

(cherry picked from commit 3af2beb8b24ba21fb7e7fbd165a79b8eeff37712)
2024-05-17 21:30:35 +02:00
Christos Margiolis
99e372420d sound: Rename pcm_getparentchannel() to vchan_getparentchannel()
Follow the rest of the vchan.c naming convention.

No functional change intended.

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

(cherry picked from commit 77ab4263bc42a5dcc102bbea39ce4f7f46b8d4f8)
2024-05-17 21:30:35 +02:00
Christos Margiolis
ab7c01f9e8 sound: Move vchan-related code to pcm/vchan.*
pcm/sound.* contains code that should be part of pcm/vchan.*.

Changes:
- pcm_setvchans() -> vchan_setnew()
- pcm_setmaxautovchans() -> vchan_setmaxauto()
- hw.snd.maxautovchans moved to pcm/vchan.c
- snd_maxautovchans declaration moved to pcm/vchan.h and definition to
  pcm/vchan.c

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

(cherry picked from commit 7ad5f383fcb507482d5606c8eb7a324b3621a9db)
2024-05-17 21:30:35 +02:00
Christos Margiolis
00b0cbf98b sound: Use nitems() where possible
No functional change intended.

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

(cherry picked from commit c597c557923288eff527594619a692a44ade909a)
2024-05-17 21:30:35 +02:00
Christos Margiolis
6f6cc93241 sound: Remove unused dsp_cdevs[] fields and devices
These fields and devices are unused as of e8c0d15a64fa ("sound: Get rid
of snd_clone and use DEVFS_CDEVPRIV(9)").

While here, remove unused SND_DEV_* defines from pcm/sound.h and convert
the list to an enum.

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

(cherry picked from commit 72cbd381075a2eb22a070505334d1ce92ec2d7ad)
2024-05-17 21:30:35 +02:00
Christos Margiolis
e14f7d11cb sound: Move chip.h contents to pcm/sound.h
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44997

(cherry picked from commit 923e0040a59af8ac2271d3e673fef1c641d0cce7)
2024-05-17 21:30:35 +02:00
Christos Margiolis
d1eaefde3b sound: Remove hw.snd.version and SND_DRV_VERSION
hw.snd.version and SND_DRV_VERSION define the sound driver version and
are meant to be used in bug reports, but because these values are
constant, there is not much useful information we can extract from them.

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

(cherry picked from commit 7398d1ece5cfa2e6ce4997234a95115b49c9e818)
2024-05-17 21:30:35 +02:00
Christos Margiolis
2c53a4bbcb sound: Convert pcm_chn_add() to void
It always returns 0.

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

(cherry picked from commit 139bcec852cf2786ca839ca0bddbb2b78a23d6fa)
2024-05-17 21:30:34 +02:00
Christos Margiolis
e6e7bf7087 sound: Add __assert_unreachable() to default cases in pcm_chn_add() and pcm_chn_remove()
We should normally never enter these cases.

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

(cherry picked from commit 76f95bae092b7353ff82b7a0056ca5801bb98f76)
2024-05-17 21:30:34 +02:00
Christos Margiolis
13ee4d7f33 sound: Merge pcm_chn_create() and chn_init()
Follow-up of b3ea087c05d8c75978a302cbb3fa92ce1afa3e49 ("sound: Merge
pcm_chn_destroy() and chn_kill()")

While here, add device_printf()'s to all failure points. Also fix an
existing bug where we'd unlock an already unlocked channel, in case we
went to "out" (now "out2") before locking the channel.

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

(cherry picked from commit 2e9962ef57044b191431fe9228841e1415574d82)
2024-05-17 21:30:34 +02:00
Christos Margiolis
0baaaf8543 sound: Remove chn_timeout check from chn_init()
This check is not related to channel initializion, but is also
unnecessary, since sysctl_hw_snd_timeout() takes care of checking if
chn_timeout is within bounds.

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

(cherry picked from commit 7cc1afc5589000ac6ad7a908b07fad3401367bd1)
2024-05-17 21:30:34 +02:00
Christos Margiolis
930b5a3c07 sound: Move pcm_chnref() and pcm_chnrelease() to pcm/channel.c
Improve code layering. These are channel functions, and so they do not
belong in pcm/sound.c.

While here, assert in chn_ref() that new refcount won't be negative.

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

(cherry picked from commit a24050e2b784e13561da3ab731a1db92f2e3366c)
2024-05-17 21:30:34 +02:00
Christos Margiolis
532b1efd2d sound: Merge pcm_chn_destroy() and chn_kill()
pcm_chn_destroy() acts like a wrapper around chn_kill(), and
additionally calls a few more functions that should in fact be part of
chn_kill()'s logic. Merge pcm_chn_destroy()'s functionality in
chn_kill() to improve readability, as well as code layering.

While here, convert chn_kill() to void as it currently always returns 0.

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

(cherry picked from commit b3ea087c05d8c75978a302cbb3fa92ce1afa3e49)
2024-05-17 21:30:34 +02:00
Christos Margiolis
ad677fb457 sound: Retire unit.*
The unit.* code is largely obsolete and imposes limits that are no
longer needed nowadays.

- Capping the maximum allowed soundcards in a given machine. By default,
  the limit is 512 (snd_max_u() in unit.c), and the maximum possible is
  2048 (SND_UNIT_UMAX in unit.h). It can also be tuned through the
  hw.snd.maxunit loader(8) tunable. Even though these limits are large
  enough that they should never cause problems, there is no need for
  this limit to exist in the first place.
- Capping the available device/channel types. By default, this is 32
  (snd_max_d() in unit.c). However, these types are pre-defined in
  pcm/sound.h (see SND_DEV_*), so the cap is unnecessary when we know
  that their number is constant.
- Capping the number of channels per-device. By default, the limit 1024
  (snd_max_c() in unit.c). This is probably the most problematic of the
  limits mentioned, because this limit can never be reached, as the
  maximum is hard-capped at either hw.snd.maxautovchans (16 by default),
  or SND_MAXHWCHAN and SND_MAXVCHANS.

These limtits are encoded in masks (see SND_U_MASK, SND_D_MASK,
SND_C_MASK in unit.h) and are used to construct a bitfield of the form
[dsp_unit, type, channel_unit] in snd_mkunit() which is assigned to
pcm_channel->unit.

This patch gets rid of everything unit.*-related and makes a slightly
different use of the "unit" field to only contain the channel unit
number. The channel type is stored in a new pcm_channel->type field, and
the DSP unit number need not be stored at all, since we can fetch it
from device_get_unit(pcm_channel->dev). This change has the effect that
we no longer need to impose caps on the number of soundcards,
device/channel types and per-device channels. As a result the code is
noticeably simplified and more readable.

Apart from the fact that the hw.snd.maxunit loader(8) tunable is also
retired as a side-effect of this patch, sound(4)'s behavior remains the
same.

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

(cherry picked from commit 25723d66369fe6786e9e4f5f77381b944755f267)
2024-05-17 21:30:25 +02:00
Christos Margiolis
41dee63555 sound: Remove obsolete DV_F_* flags
The ISA sound drivers that used them are retired.

Last reference of DV_F_DRQ_MASK and DV_F_DUAL_DMA:
716924cb48 ("Retire snd_sbc ISA sound card
driver")

Last reference of DV_F_DEV_MASK and DV_F_DEV_SHIFT:
5126e5eeeb ("Retire snd_mss ISA sound card
driver")

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

(cherry picked from commit 1b82d425ec0ac155765bcdf706040534309e9c94)
2024-05-17 21:30:01 +02:00
Christos Margiolis
9815728172 sound: Simplify unit fetching in dsp_oss_audioinfo()
"i" keeps the value of the current unit, so we do not have to call
PCMUNIT() and device_get_unit() to fetch it.

In the mixer case, I think it is more correct to do it like this, since
mixer and DSP device units have a 1-1 relationship (i.e the mixer unit
is always the same as the corresponding DSP device one) and that way we
can make it more clear.

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

(cherry picked from commit a44c45c7f597d67d37e09396b0778a2847a30981)
2024-05-17 21:30:01 +02:00
Christos Margiolis
decc224ab8 sound: Remove PCMMINOR()
It's a NO-OP.

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

(cherry picked from commit 8b97dce6973ca1b6c3407c34c76d459f43ca1061)
2024-05-17 21:30:01 +02:00
Christos Margiolis
d27972ec91 sound: Get rid of snddev_info->devcount
snddev_info->devcount keeps track of the total number of channels for a
given device. However, it is redundant to have it, since it is only used
in sound_oss_sysinfo() to populate the "numaudios" field, and we also
keep track of the channel counts in the playcount, pvchancount, reccount
and rvchancount fields anyway. We can simply sum those fields together
instead of updating a separate variable upon every channel
addition/deletion.

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

(cherry picked from commit 4d2be7be3837d66ba242a0a7fd51632c3f89285d)
2024-05-17 21:30:01 +02:00
Christos Margiolis
69707d9f50 sound: Call device_get_name() and device_get_unit() only once in mixer_init()
No functional change intended.

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

(cherry picked from commit 41ab202ff74ea6af7e9125c9dfb430c729380f41)
2024-05-17 21:30:01 +02:00
Christos Margiolis
8771127d75 sound: Be more verbose with virtual channel descriptions
Non-virtual channel description denote "play" or "record", so do the
same for virtual ones as well.

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

(cherry picked from commit d0032e6a9e6596302bf129d7f68a627a02c6cd0a)
2024-05-17 21:30:01 +02:00
Ed Maste
7309d72e14 ukswitch: fix non-debug build
PR:		278847
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2e0c027e69de66afc1157c76bd42ecd3737d54e1)
2024-05-14 10:47:00 -04:00
Ed Maste
e9a7be7def ip17x: fix non-debug build
PR:		278847
Reviewed by:	jhibbits
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45133

(cherry picked from commit 82f43db382cc4aea2a3f34f08da9a97ab023d5fb)
2024-05-14 10:47:00 -04:00
Konstantin Belousov
ddabe1d3c5 mlx5en: add diagnostic in one more case of failed eeprom read preparation
(cherry picked from commit c097967b9af946cf46246cce5adde53f7e955ecc)
2024-05-13 12:51:29 +03:00
Ed Maste
5e7de5daa9 smsc(4): update to mention Microchip
Microchip Technology acquired SMSC in 2012, and all current products
and datasheets refer to the devices supported by this driver as
Microchip parts.  Mention SMSC in a parenthetical comment to explain
the driver's name.

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

(cherry picked from commit 7ef6ce51742d44a7375ccbaeda4cc64e034c4816)
2024-05-10 09:01:52 -04:00
Seth Hoffert
3f6515c20f bpf: Make BPF interop consistent with if_loop
The pseudo_AF_HDRCMPLT check is already being done in if_loop and
just needed to be ported over to if_ic, if_wg, if_disc, if_gif,
if_gre, if_me, if_tuntap and ng_iface.  This is needed in order to
allow these interfaces to work properly with e.g., tcpreplay.

PR:		256587
Reviewed by:	markj
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/876

(cherry picked from commit 2cb0fce24d64039090dc9243cdf0715ee80c91b1)
2024-05-08 09:06:15 -04:00