Commit graph

4581 commits

Author SHA1 Message Date
Adrian Chadd
7067450010 sys: convert ni->ni_txrate references use to the new net80211 API
This just mechanically converts things.

* For linuxkpi, it was just used for display.
* For uath, it was just used for display, as firmware
  doesn't report it up.

Differential Revision:	https://reviews.freebsd.org/D48602
Reviewed by:	bz, thj
2025-02-26 11:29:18 -08:00
Jesper Schmitz Mouridsen
b968644127 mtw: Use correct cmd for radio
Approved by:	adrian, wireless
Differential Revision:	https://reviews.freebsd.org/D49003
2025-02-14 16:20:40 +01:00
John Baldwin
d6cce475cb mtw: Pass the right pointer to the constructed command in mtw_mcu_radio
This was just using random stack garbage before.

Reported by:	GCC -Wunused-but-set-variable
2025-02-12 17:17:00 -05:00
Jose Luis Duran
4b77a9a80c
uath: Avoid a NULL dereference
PR:		284643
Reviewed by:	adrian
Approved by:	emaste (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48948
2025-02-12 15:33:26 +00:00
Jesper Schmitz Mouridsen
c14b016242 mt7601U: Importing if_mtw from OpenBSD
Added ht20 mode, based on if_run from FreeBSD, and if_mtw.c
from OpenBSD.

PR: 247545
Approved by:	adrian, wireless
Differential Revision: https://reviews.freebsd.org/D45179
2025-02-03 20:20:52 +01:00
Warner Losh
fdaf7d0fe1 umass: Print quirks with %b
Print the quirks in a more human-readable form. When testing a dozen
different removeable devices, the hex numbers quickly blur...

Sponsored by:		Netflix
2025-02-03 10:25:27 -07:00
Warner Losh
c64b3f32a5 umass: Add comment for ASC/ASCQ 24h/00h INVALID FIELD IN CDB
Add a comment for what this asc/ascq combo means. Very few people have
this memorized.

Sponsored by:		Netflix
2025-01-28 13:08:51 -07:00
FUKAUMI Naoki
dc273058cb ure(4): Add support for ELECOM EDC-QUA3C
ELECOM EDC-QUA3C is a USB3.1 Gen1 Type-A/C 2.5GBASE-T network adapter.
This also works as a cdce(4) device by:

usbconfig -d X.Y set_config 1
  or
usbconfig -d X.Y set_config 2

Signed-off-by: FUKAUMI Naoki <naoki@radxa.com>

MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1578
2025-01-24 19:25:11 +00:00
Adrian Chadd
0f1bf1c22a umb: Introduce the USB umb(4) network driver
This includes the port of a driver originally from OpenBSD, later
ported to NetBSD by the author:

* The umb(4) kernel driver
* The umbctl(8) companion tool

This driver supports USB network devices implementing the
Mobile Broadband Interface Model (MBIM), often found in modern
(internal) USB models for 4G/LTE mobile broadband access.

It is currently limited to IPv4.

umbctl has to be used to display or set MBIM cellular modem
interface parameters (4G/LTE).

Differential Revision:  https://reviews.freebsd.org/D48167
Approved by:    adrian, zlei
Sponsored by:   FreeBSD Foundation
PR:             kern/263783
Submitted by:   Pierre Pronchery <khorben@defora.org>
2025-01-20 23:46:15 +00:00
Mitchell Horne
9eb30ef4b7 riscv: enable Allwinner D1 USB drivers
Add the generic USB drivers and FDT glue to the build.

Make small tweaks to the aw_usbphy and aw_musb drivers for the Allwinner
D1.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D48126
2025-01-10 13:57:36 -04:00
John Baldwin
11a9117871 Use bus_generic_detach to detach and delete child devices during detach
This is simpler and more robust than individual calls to
device_delete_child.

Differential Revision:	https://reviews.freebsd.org/D47972
2025-01-02 13:25:12 -05:00
John Baldwin
3ddaf8200b Use bus_generic_detach instead of device_delete_children in detach
While here, check for errors from bus_generic_detach and move it to
the start of detach if necessary.

Differential Revision:	https://reviews.freebsd.org/D47969
2025-01-02 13:24:28 -05:00
John Baldwin
160179ea3e Remove now-redundant calls to device_delete_children
Earlier calls to bus_generic_detach now take care of deleting
children.

Differential Revision:	https://reviews.freebsd.org/D47962
2025-01-02 13:22:50 -05:00
John Baldwin
cf416f56eb Use the new bus_generic_detach directly in place of home-grown versions
Differential Revision:	https://reviews.freebsd.org/D47960
2025-01-02 13:22:20 -05:00
Kyle Evans
36a80f4264 usb: serial: make more commands execute synchronously
The termios layer wants some level of guarantee that we've actually
submitted param changes to the hardware when our functions return, so we
need to do a little more waiting to avoid violating those guarantees.

This is especially important as some hardware has some minimum timing
specifications around this stuff, and without being less asynchronous
the software dealing with these devices can't reasonably operate the
hardware without more excessive delays than they should need.

More specifically, we make sure that:
 - The command to start transfers is finished before we toggle DTR/RTS
 - The status_change command finishes before we return, which may change
    some fields in the softc that we need for a subsequent call into
    usb_serial
 - cfg_param finishes before we re-enable transfers, and we ensure that
    RTS is appropriately toggled before we return to userland

This has been observed to fix some flakiness in connecting to some
ESP32 devices.

Tested by:	kenrap from Libera
Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D47952
2024-12-10 19:23:41 -06:00
Kyle Evans
729eb176a4 usb: serial: allow the open/close sleep to be interruptible
ucom_queue_command will issue commands for open/close, then wait on them
to be finished.  In the spirit of playing it safe, allow
ucom_queue_command's wait to be interrupted in case the usb process gets
jammed up waiting on the hardware -- we can at least recover the user
thread that initiated it, even if we can't recover the usb process.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D47951
2024-12-10 19:23:10 -06:00
Kyle Evans
51f3d0874f usb: serial: propagate errors from ucom_queue_command()
There's only one error that we can get back right now, but future
changes will add some more cases that we need to watch out for.  Start
by returning errors and propagating them back.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D47950
2024-12-10 19:23:10 -06:00
John Baldwin
18250ec6c0 Replace calls to bus_generic_attach with bus_attach_children
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D47675
2024-12-06 17:26:16 -05:00
Mark Johnston
ef9ffb8594 kern: Make fileops and filterops tables const where possible
No functional change intended.

MFC after:	1 week
2024-11-26 21:04:21 +00:00
Augustin Cavalier
7dfaf23856 rtwn: Add device ID for TPLink RTL8192CU 2024-11-21 10:40:11 -05:00
Adrian Chadd
842a2c1ad3 uath: flush data/commands to the firmware before changing channel / state
The driver wasn't stable - it would start fine, but during scan
it would eventually hang and no further command endpoint transfers
would complete.

After adding some debugging and looking at the logs I noticed that
things went sideways once a /data/ frame was sent.  The channel
change config happened between the data frame being sent and
being completed.

My guess is that the firmware doesn't like a channel change
and reset whilst there's pending data frames.  Checking the Linux
driver I found that it was doing a flush before a channel change,
and we're doing it afterwards.  This acts like a fence around
ensuring scheduled TX work has completed.  In net80211 the
transmit path and the control path aren't serialised, so it's
very often the case that ioctls, state changes, etc occur
whilst in parallel there are frame transmits being scheduled.

This seems to happen more frequently on a more recent, high core
(8) machine with XHCI.  I remember testing this driver years ago
on single and dual core CPU laptops with no problems.

So, add some flushes - before a channel change, and during
a transition to AUTH when the BSS config is being programmed into
the firmware.  These two fences seem enough to reliably
associate as a 2GHz and 5GHz STA.

Note that this isn't entirely blocking all newly queued
transmit work from occuring until after the NIC has finished
configuration.  That will need some further investigation.

Locally tested:

  * Wistron NuWeb AR5523 dual-band NIC, STA mode, 2/5GHz

Differential Revision:	https://reviews.freebsd.org/D47655
2024-11-18 20:50:41 -08:00
Adrian Chadd
7098b90152 usb: fix the ID for the dual-band Wistron AR5523 USB NIC
Use the correct ID, as I have one of these NICs.
Add the previous one back in case it's out there in the wild.

@emaste did a bit of a dig into the product numbers.
@sam did change the ID from 0x0828 -> 082a in a commit
a long while back. It's worth reading the code review for
further details.

However, I do have one of these NICs and I verified that
it indeed has the given ID, and with some follow-up work
to fix some race conditions, it works fine in 2GHz 11bg
and 5GHz 11a operation.

Differential Revision:	https://reviews.freebsd.org/D47654

Obtained from:	Linux, drivers/net/wireless/ath/ar5523/ar5523.c
2024-11-18 20:50:24 -08:00
Matthew Nygard Dodd
0b5d86b38a uhid(4): update ugd_actlen in USB_GET_REPORT ioctl
USB_GET_REPORT ioctl is documented to update ugd_actlen on return with
the number of bytes copied.  It does not do this.

Reviewed by:	wulf
PR:		282790
MFC after:	1 week
2024-11-18 07:31:24 +03:00
Adrian Chadd
c249cc3822 net80211: migrate FC0_TYPE_MASK / FC0_SUBTYPE_MASK frame type checks to macros
* Add macros for the management and control frame type checks that
  I've come across in the drivers.
* Delete some now old code (eg ath's ieee80211_is_action()) as there's now
  a macro for it.

Local testing:

* not yet, I have a lot of wifi devices to find and test against

Differential Revision: https://reviews.freebsd.org/D47500
2024-11-17 09:53:04 -08:00
Hajimu UMEMOTO
8eaeaf5c46 usb: Add support for Brainboxes USB-to-Serial adapters
PR:		277482
Reported by:	Cameron Williams
2024-11-11 21:14:05 +09:00
Ed Maste
114080d199 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
2024-11-10 21:53:18 -05:00
Frank Hilgendorf
541e7a98b7 ukbd: Enable ukbd_apple_swap for all Apple ISO keyboards
Key code swapping between [<>] and [^°] key is enabled for all Apple ISO
type keyboards.  Before, swapping was enabled when the Eject key was
detected in HID usage.  This did not correlate well with the swapped
keys presence.

usbdevs file is extended by several Apple keyboard models to support ISO
model identification.

Reviewed by:	markj
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1506
2024-11-07 20:38:38 +00:00
Bjoern A. Zeeb
5b8f97d8db usb: change LIST to SLIST to avoid LinuxKPI conflicts
In order to better integrate modern LinuxKPI USB this tries to reduce
a contention point of "LIST".  Given there is no need to use a LIST here
change it to SLIST to avoid conflicts.
It is a workaround which does not solve the actual problem (overlapping
namespaces) but it helps us a lot for now.

Sponsored by:	The FreeBSD Foundation
X-MFC?		unclear
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D46534
2024-09-24 22:53:28 +00:00
Kristof Provost
f8d14a44de if_usie: fix typo
Fix a 'case AF_INET;' typo, and ensure we include 'opt_inet6.h' so #ifdef INET6
actually works.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-09-22 00:56:37 +02:00
Franco Fichtner
1693e3be3b u3g: reorder Quectel devices by product ID
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1410
2024-09-21 05:25:15 -06:00
Alexander Motin
a1bb5bdb0a ure(4): Add ID for LAN port in Thinkpad OneLink+ dock
That's a pretty old dock for Thinkpad X1 Carbon Gen4 and few others.

MFC after:	1 week
2024-09-18 21:55:24 -04:00
Joshua Rogers
8aef1cd698 wsp: Use already-calculated distance of fingers for comparison.
Also correctly use tun.max_double_tap_distance for maximum distance
of fingers for vertical scrolling.

Signed-off-by: Joshua Rogers <Joshua@Joshua.Hu>
Reviewed by: imp, wulf
Pull Request: https://github.com/freebsd/freebsd-src/pull/1365
2024-09-06 12:34:31 -06:00
Joshua Rogers
62cf43dda8 wsp: Improve multi-finger touchpad usage and allow more configurations
This patch allows scrolling with multiple fingers simultaneously, in
line with how wsp trackpads function on MacOS.

Two new tunables are added: hw.usb.wsp.max_finger_area and
hw.usb.wsp.max_double_tap_distance.

max_finger_area defines the maximum size which the driver registered an
object on trackpad as a finger.
Previously, this value was hardcoded as 1200, which was too low to
register thumb-clicks.

max_double_tap_distance defines the maximum distance between two
fingers which will register as a double-click.

Signed-off-by: Joshua Rogers <Joshua@Joshua.Hu>
Reviewed by: imp, wulf
Pull Request: https://github.com/freebsd/freebsd-src/pull/1365
2024-09-06 12:34:31 -06:00
Joshua Rogers
7b984d5043 wsp: Allow the trackpad to be used after a partially unreleased click.
This provides functionality for a click which is partially unreleased
and then allows the user to continue moving the mousepad as if were not
invoked as a full click

Signed-off-by: Joshua Rogers <Joshua@Joshua.Hu>
Reviewed by: imp, wulf
Pull Request: https://github.com/freebsd/freebsd-src/pull/1365
2024-09-06 12:34:31 -06:00
Ahmad Khalifa
e152944f1a usb: increase USB_PORT_RESET_RECOVERY
10ms seems to be too strict for some configurations, so increase to
20ms.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1327
2024-09-06 12:34:30 -06:00
Franco Fichtner
4b6e76eff8 u3g: add SIERRA AC340U
Pull request:	https://github.com/freebsd/freebsd-src/pull/1397
MFC after:	3 days
2024-08-30 00:05:30 -07:00
Bjoern A. Zeeb
9c0cce3283 usb: correct the rtw8821cu quirk and add another wireless rtw88 device
The RTW8821CU_CD entry in quirks has an invalid lo_rev/hi_rev match
entry.  Use the different USB_QUIRK macro to match on all of these;
the value we currently see is 0x0200 on two different wifi sticks. [1]

Also add an entry for the DLINK DWA-181 rev A1, rtw88 USB.

Submitted by:	phk
Tested by:	phk
Fixes:		b3b6a959c8 [1]
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D46189
2024-08-27 17:48:43 +00:00
Li-Wen Hsu
6ea4d95f6c
Move support of Realtek 8156/8156B from cdce(4) to ure(4)
Reviewed by:	kevlo, imp, hrs
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D45088
2024-08-12 14:56:28 +08:00
Warner Losh
5b56413d04 newbus: globally replace device_add_child(..., -1) with DEVICE_UNIT_ANY
Sponsored by:		Netflix
2024-07-24 22:22:58 -06:00
Adrian Chadd
2589197adb net80211: migrate the group/unicast key check into inline functions
The way that net80211 and drivers are checking for the /type/ of key
is to check if it's in the vap WEP key array and if so, it's a group
key.  If not, it's a unicast key.

That's not only kind of terrible, but it's also going to be
problematic with future 802.11 support (for multiple unicast keys
and IGTK keys for management frame protection.)

So as part of this, remove the places where this is done and
instead use a pair inline functions - ieee80211_is_key_global() and
ieee80211_is_key_unicast().  They currenly still use the same logic
but the drivers and net80211 stack isn't doing it itself.

There are still open questions about why keys are not being
correctly tagged as GROUP, GTK, PTK, etc.  That will be investigated
and addressed in follow-up work as a pre-cursor to MFP, IGTK, etc.
as mentioned above.

Testing:

* iwn, rtwn - STA mode

Differential Revision:	 https://reviews.freebsd.org/D45516
2024-07-15 11:45:30 -07:00
Mark Johnston
5dc4682c32 if_urndis: Organize buffer layouts more naturally
- Group the request header and I/O buffer in one structure, rather than
  assuming that both request structures have the same size.
- Pass a pointer to the whole structure to urndis_ctrl_query() and
  urndis_ctrl_set() rather than just the header.  Otherwise, on CHERI
  platforms, these functions violate subobject bounds since they modify
  the buffer following the header.

While here, there is no apparent reason for the request structure used
in urndis_attach() to be allocated statically.  Change it so that it's
allocated on the stack.

No functional change intended.

Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D45866
2024-07-09 10:26:16 -04:00
Niko Sonack
d6888e211b ums(4): fix incorrect mouse button reporting via evdev
when ums driver receives non-mouse HID report. This results in
unexpected button release event. Reuse existing sysmouse logic to
keep button pressed.

Reviewed by:	imp, wulf
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D45838
2024-07-03 02:15:50 +03:00
Zhenlei Huang
aa3860851b net: Remove unneeded NULL check for the allocated ifnet
Change 4787572d05 made if_alloc_domain() never fail, then also do the
wrappers if_alloc(), if_alloc_dev(), and if_gethandle().

No functional change intended.

Reviewed by:	kp, imp, glebius, stevek
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D45740
2024-06-28 18:16:29 +08:00
Dmitry Luhtionov
4cc4b5e2b5 Add some AMD device IDs. 2024-06-07 13:02:03 -04:00
Maxime Thiebaut
b5b90ff984 u3g: Add support for SIM7600G
Signed-off-by:	Maxime Thiebaut <maxime+freebsd@thiebaut.dev>
Reviewed by:	kp
2024-06-06 17:02:15 +02:00
Joshua Kinard
80828c6fab kern: Remove leftover saf1761otg bits
Almost all code related to the saf1761 driver was removed in commit
44796b7e82, except for two small bits related to saf1761otg support.
This patch completes the removal.

PR:		279302
Signed-off-by:	Joshua Kinard <freebsd@kumba.dev>
Reviewed by:	mhorne
MFC after:	3 days
Fixes:		44796b7e82 ("mips: remove saf1761")
2024-06-03 12:52:58 -03:00
Kevin Lo
345fd21a6a Add a new USB ID for Xiaomi mini USB WiFi 2024-05-31 09:40:03 +08:00
Ahmad Khalifa
881ae768f2 usb: Remove uneeded revision verbosity from quirks list
Seperate usb quirks that target specific revisions from those that
dont. Alot of the quirks dont use lo_rev and hi_rev, so we can abstract
the 0x0000, 0xffff into a macro.

[[ This commit is a bit more churn than we like. I carefully reviewed
   each one and they are all good. The end product is better -- imp ]]

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1153
2024-05-11 13:32:57 -06:00
Ahmad Khalifa
64e05e9065 usb: Fix quirks list
In some cases, the USB_QUIRK_VP macro was being misused. Instead of
setting quirks to the intended value, the first two supplied quirks
would go into lo_rev and hi_rev. Replace it with USB_QUIRK_VO which only
takes the needed args. This also makes the Dummy products, which where
being used to correctly set vendor only quirks, not necessary.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1153
2024-05-11 13:32:37 -06:00
Ed Maste
7ef6ce5174 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
2024-05-08 14:18:46 -04:00