Commit Graph

4312 Commits

Author SHA1 Message Date
Elyes HAOUAS
9097ac9af4 Fix typo on "Celsius"
"Celcius" --> "Celsius"

Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Pull Request: https://github.com/freebsd/freebsd-src/pull/551/files
2021-11-18 23:05:32 -07:00
Bjoern A. Zeeb
3987e50611 USB dwc3 controller: add quirk snps,dis_rxdet_inp3_quirk
Add support for the "snps,dis_rxdet_inp3_quirk" quirk needed
at least on SolidRun's HoneyComb.

Reviewed by:	manu, mw
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D32921
2021-11-10 09:44:44 +00:00
Alexander Motin
dc238358f9 Add some of Intel Alder Lake device IDs.
MFC after:	1 week
2021-11-05 23:06:59 -04:00
Jessica Clarke
29863d1eff xhci: Rework 64-byte context support to avoid pointer abuse
Currently, to support 64-byte contexts, xhci_ctx_[gs]et_le(32|64) take a
pointer to the field within a 32-byte context and, if 64-byte contexts
are in use, compute where the 64-byte context field is and use that
instead by deriving a pointer from the 32-byte field pointer. This is
done by exploiting a combination of 64-byte contexts being the same
layout as their 32-byte counterparts, just with 32 bytes of padding at
the end, and that all individual contexts are either in a device
context or an input context which itself is page-aligned. By masking out
the low 4 bits (which is the offset of the field within the 32-byte
contxt) of the offset within the page, the offset of the invididual
context within the containing device/input context can be determined,
which is itself 32 times the number of preceding contexts. Thus, adding
this value to the pointer again gets 64 times the number of preceding
contexts plus the field offset, which gives the offset of the 64-byte
context plus the field offset, which is the address of the field in the
64-byte context.

However, this involves a fair amount of lying to the compiler when
constructing these intermediate pointers, and is rather difficult to
reason about. In particular, this is problematic for CHERI, where we
compile the kernel with subobject bounds enabled; that is, unless
annotated to opt out (e.g. for C struct inheritance reasons where you
need to be able to downcast, or containerof idioms), a pointer to a
member of a struct is a capability whose bounds only cover that field,
and any attempt to dereference outside those bounds will fault,
protecting against intra-object buffer overflows. Thus the pointer given
to xhci_ctx_[gs]et_le(32|64) is a capability whose bounds only cover the
field in the 32-byte context, and computing the pointer to the 64-byte
context field takes the address out of bounds, resulting in a fault when
later dereferenced.

This can be cleaned up by using a different abstraction. Instead of
doing the 32-byte to 64-byte conversion on access to the field, we can
do the conversion when getting a pointer to the context itself, and
define proper 64-byte versions of contexts in order to let the compiler
do all the necessary arithmetic rather than do it manually ourselves.
This provides a cleaner implementation, works for CHERI and may even be
slightly more performant as it avoids the need to mess with masking
pointers (which cannot in the general case be optimised by compilers to
be reused across accesses to different fields within the same context,
since it does not know that the contexts are over-aligned compared with
the C ABI requirements).

Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D32554
2021-10-27 18:38:37 +01:00
Hans Petter Selasky
aad0c65d6b usb(4): Fix for use after free in combination with EVDEV_SUPPORT.
When EVDEV_SUPPORT was introduced, the USB transfers may be running
after the main FIFO is closed. In connection to this a race may appear
which can lead to use-after-free scenarios. Fix this for all FIFO
consumers by initializing and resetting the FIFO queues under the
lock used by the client. Then the client driver will see an empty
queue in all cases a race may appear.

Found by:	pho@
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-10-24 19:37:17 +02:00
Bjoern A. Zeeb
9a6695532b net80211/drivers: improve ieee80211_rx_stats for band
While IEEE80211_R_BAND was defined, there was no place to store the
band.  Add a field for that, adjust ieee80211_lookup_channel_rxstatus()
to require it, and update drivers passing "R_{FREQ|IEEE}" in already to
provide the band as well.  For the moment keep the fall-back code
requiring all three fields.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D30662
2021-10-22 09:55:54 +00:00
Bjoern A. Zeeb
76f3b8cb64 USB: adjust the Generic XHCI ACPI probe return value
Change the probe return value from BUS_PROBE_DEFAULT to BUS_PROBE_GENERIC
given this is the "generic" attach method.  This allows individual
drivers using XHCI generic but needing their own intialisation to
gain priority for attaching over the generic implementation.

Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D32257
2021-10-08 10:28:44 +00:00
Gordon Bergling
9599d8141f smsc(4): Fix a typo in a comment
- s/setings/settings/

MFC after:	3 days
2021-10-02 10:45:58 +02:00
Ian Lepore
dc91a9715f Fix busdma resource leak on usb device detach.
When a usb device is detached, usb_pc_dmamap_destroy() called
bus_dmamap_destroy() while the map was still loaded. That's harmless on x86
architectures, but on all other platforms it causes bus_dmamap_destroy() to
return EBUSY and leak away any memory resources (including bounce buffers)
associated with the mapping, as well as any allocated map structure itself.

This change introduces a new is_loaded flag to the usb_page_cache struct to
track whether a map is loaded or not. If the map is loaded,
bus_dmamap_unload() is called before bus_dmamap_destroy() to avoid leaking
away resources.

MFC after:	7 days
Differential Revision:	https://reviews.freebsd.org/D32208
2021-09-28 13:29:10 -06:00
Vladimir Kondratyev
527b6d60f8 wmt(4): Adapt to recent KPI changes
MFC after:	2 weeks
2021-09-02 22:35:26 +03:00
Kornel Duleba
f0c393f781 if_cdce: Add support for setting RX filtering
We can now set promisc and allmulti modes.
Filtering of given multicast addresses is not supported.
Changing the mode is done by sending a command described in:
"USB CDC Subclass Specification for Ethernet Devices v1.2, section 6.2.4".
This means that at least in theory this feature should work with all
modems that are using this driver.

This fixes Huawei E3372h-320 running new firmware in "HiLink" mode.
Previously it would reset a few seconds after its mode was changed
with "usb_modeswitch".
Setting RX filter to default value at the end of attach function
fixed that.

Sponsored by:		Stormshield
Obtained from:		Semihalf
Differential revision:	https://reviews.freebsd.org/D31766
MFC after:		2 weeks
Reviewed by:		hps
2021-09-01 12:27:14 +02:00
Kornel Duleba
28d5498268 umodem: Add Huawei E3372h-320 device id
After switching the dongle to the Huawei alternate mode(modem mode)
with usb_modeswitch the serial interfaces had all of their ids set to
0xFF.
After modifying umodem to work with that it attached successfully and
I've managed to configure device with standard AT commands to get
internet connection.
2021-08-31 08:44:36 +02:00
Gordon Bergling
b1603638e3 Fix a common typo in man pages and src comments
- s/desciptor/descriptor/

MFC after:	5 days
2021-08-28 19:24:27 +02:00
Vladimir Kondratyev
8d73071c47 wsp(4): Add evdev support.
Reviewed by:	hselasky
Tested by:	Greg V, Constantin Furst<constantin_AT_fuersten_DOT_info>
MFC after:	2 weeks
PR:		252236
Differential revision:	https://reviews.freebsd.org/D31653
2021-08-25 02:01:42 +03:00
Vladimir Kondratyev
250ab00407 wsp(4): Compact parameter structure.
MFC after:	2 weeks
2021-08-25 01:59:48 +03:00
Vladimir Kondratyev
9fa1201d60 atp(4), wsp(4): Return correct priority from probe() method;
MFC after:	2 weeks
2021-08-25 01:59:17 +03:00
Hans Petter Selasky
ec97e9ca1f Fully revert f83f5d5839 for the sys/dev/usb/serial
folder, only keeping the zero length packet API introduced in sys/dev/usb
after more reports of USB serial devices not supporting ZLPs.

Reported by:	mav@
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-08-20 18:00:42 +02:00
Hans Petter Selasky
bcb195d917 Partial revert of f83f5d5839 for uftdi(4).
Apparently devices with bcdDevice less than 0x0600, have problems receiving ZLPs.

Reported by:	kevlo@
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-08-20 09:54:34 +02:00
Hans Petter Selasky
8a46f021c2 Make sure the uftdi(4) driver doesn't start a USB transfer when being cancelled.
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-08-18 11:42:37 +02:00
Gordon Bergling
a1581cd735 Fix a common typo in source code comments
- s/aligment/alignment/

MFC after:	5 days
2021-08-14 14:17:48 +02:00
Hans Petter Selasky
65788dae31 Cleanup unused USB enums.
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-07-15 12:38:42 +02:00
Hans Petter Selasky
f83f5d5839 Send a zero-length-packet first when opening a BULK endpoint for USB serial
port devices. If it gets eaten it is fine. Many USB device side implementations
don't properly support the clear endpoint halt command and if they do, data is lost
because the transmit FIFO is typically reset when this command is received.

Tested by:	jmg
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-07-15 12:11:53 +02:00
Hans Petter Selasky
cf48d1f771 Clamp the XHCI minimum isochronous scheduling delay to the maximum value that
will work under FreeBSD, if the value is too big.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-07-11 13:57:15 +02:00
Hans Petter Selasky
f52783fcf5 Fix USB debug print after 8fc2a3c417 .
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-07-10 21:31:28 +02:00
Hans Petter Selasky
8fc2a3c417 Factor out repeated code in the USB controller drivers to avoid bugs
computing the same isochronous start frame number over and over again.

PR:		257082
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-07-10 20:59:00 +02:00
Hans Petter Selasky
3f5054862a Make sure the avr32dci_odevd structure is used.
This fixes a compilation error.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-07-10 19:57:52 +02:00
Hans Petter Selasky
d038463bd2 Make sure the XHCI driver obeys the isochronous scheduling threshold value
as given by the XHCI hardware parameters to avoid scheduling isochronous
transfers too early.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-07-10 19:57:52 +02:00
Hans Petter Selasky
e036ee6ce2 Let the xhci_hw_root structure span exactly XHCI_PAGE_SIZE bytes by increasing
the number of completion event TRBs. This avoids wasting memory.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-07-10 19:57:52 +02:00
John-Mark Gurney
3d5104182c ued may be NULL here which will cause a panic... reproducable by
simply doing a usbconfig reset on a device which doesn't reset itself
properly...
2021-06-28 18:09:14 -07:00
Warner Losh
30f8afd027 cam: fix xpt_bus_register and xpt_bus_deregister return errno
xpt_bus_register and xpt_bus_deregister returns a hybrid error that's
neither a cam_status, nor an errno, but a mix of both.  Update
xpt_bus_register and xpt_bus_deregister to return an errno. The vast
majority of current users compare against zero, which can also be
spelled CAM_SUCCESS. Nobody uses CAM_FAILURE, so remove that symbol
to prevent comfusion (nothing returns it either).

Where the return value is saved, ensure that the variable 'error' is
used to store an errno and 'status' is used to store a cam_status where
it makes the code clearer (usually just in functions that already mix
and match). Where the return value isn't used at all, avoid storing it
at all.

Reviewed by:		scottl@, mav@ (earlier version)
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D30860
2021-06-28 16:13:03 -06:00
John-Mark Gurney
b43d600c83 Add support for link status, media and VLAN MTU (if supported) to if_cdce...
This makes it more usable in that dhclient will autolaunch from devd
now when cdce devices are plugged in..  It also sets the baudrate, but
this isn't exported via tools, and CDCE doesn't have a good way to
specify the media type, so there isn't a good way to tell userland
what the speed is currently...

Reviewed by:		hps
Relnotes:		yes
Differential Revision:	https://reviews.freebsd.org/D30625
2021-06-25 17:57:04 -07:00
Warner Losh
ddfc9c4c59 newbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location} with sbuf
Now that the upper layers all go through a layer to tie into these
information functions that translates an sbuf into char * and len. The
current interface suffers issues of what to do in cases of truncation,
etc. Instead, migrate all these functions to using struct sbuf and these
issues go away. The caller is also in charge of any memory allocation
and/or expansion that's needed during this process.

Create a bus_generic_child_{pnpinfo,location} and make it default. It
just returns success. This is for those busses that have no information
for these items. Migrate the now-empty routines to using this as
appropriate.

Document these new interfaces with man pages, and oversight from before.

Reviewed by:		jhb, bcr
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D29937
2021-06-22 20:52:06 -06:00
CeDeROM Tomasz CEDRO
d21c884e52 USB/U3G: Added Panasonic CF-F9 GOBI 3G modem to U3G module.
Add kernel support for the Panasonic GOBI 3g modem.

Note: GOBI modems require QDL firmware to be uploaded with gobi_loader:
https://github.com/cederom/gobi_loader.

Signed-off-by:	CeDeROM Tomasz CEDRO <tomek@cedro.info>
Pull Request:	https://github.com/freebsd/freebsd-src/pull/115
Reviewed by:	imp (split off kernel bits from original)
2021-06-13 10:23:01 -06:00
Hans Petter Selasky
a7cf31da5a Add new USB ID to u3g(4).
Submitted by:	pierre-jean.gineste@nuabee.fr
PR:		231909
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-06-11 13:05:58 +02:00
Hans Petter Selasky
dab84426a6 Narrow down the probe range for if_ure(4) compatible devices
to only match the first vendor specific interface, if any.

PR:		253374
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-06-04 15:51:01 +02:00
Hans Petter Selasky
d4cf41a99b Add support for RTL8153B, RTL8156 and RTL8156B to if_ure(4).
Submitted by:	fbbz@synack.eu
PR:		253374
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-06-04 10:29:55 +02:00
Warner Losh
cc384c67ce cam: prefer cam_sim_softc() over accessing cam_sim structure directly.
Use the accessor function to get the softc for this sim. This also drops
an unneeded cast.

Sponsored by:		Netflix
Reviewed by:		mav@, hselasky@
Differential Revision:	https://reviews.freebsd.org/D30360
2021-06-03 13:08:29 -06:00
Maksym Stetsyuk
5c447fe677 usb: reduce verbosity of logging about unsuccessful port reset
Reviewed by:		imp@,hselasny@
Pull Request:		https://github.com/freebsd/freebsd-src/pull/385
Differential Revision:	https://reviews.freebsd.org/D30621
2021-06-03 09:52:52 -06:00
Vladimir Kondratyev
9aa0e5af75 usbhid(4): Add second set of USB transfers to work in polled mode.
The second set of USB transfer is requested by hkbd(4) and
should improve HID keyboard handling in kdb and panic contexts.

MFC after:	1 week
Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D30486
2021-05-28 23:29:42 +03:00
Vladimir Kondratyev
e889a462d8 usbhid(4): Fix NULL pointer dereference in usbd_xfer_max_len()
Which happens when USB transfer setup is failed.

MFC after:	1 week
PR:		254974
Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D30485
2021-05-28 23:29:42 +03:00
Dmitry Chagin
434c46c006 rtwn_usb(4): Add a USB ID for the TP-Link Archer T2U v3.
PR:		256203
Submitted by:	Steve Kargl sgk at troutmask.apl.washington.edu
MFC after:	2 weeks
2021-05-27 21:52:10 +03:00
Vladimir Kondratyev
47791339f0 ums(4): Start USB xfers on opening of evdev node unconditionally.
This fixes inability to start USB xfers in a case when FIFO has been
already open()-ed but no read() or poll() calls has been issued yet.

MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D30343
2021-05-24 01:41:17 +03:00
Vladimir Kondratyev
05ab03a317 ums(4): Do not stop USB xfers on FIFO close when evdev is still active
This fixes lose of evdev events after moused has been killed.

While here use bitwise operations for UMS_EVDEV_OPENED flag.

Reviewed by:	hselasky
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D30342
2021-05-24 01:38:53 +03:00
Dmitry Chagin
8746bc9187 run(4): add support for DLINK DWA-130 rev F1 wireless adaptor.
PR:		256092
Submitted by:	Francois Briere <purplefiasco at gmail.com>
MFC After:	2 weeks
2021-05-23 21:31:51 +03:00
Dmitry Chagin
d6fd321ef6 run(4): add support for ASUS USB-N14 wireless adaptor.
PR:		255759
Submitted by:	john.lmurdoch at gmail.com
MFC After:	1 week
2021-05-22 13:52:12 +03:00
Hans Petter Selasky
4eac63af23 Fix for use-after-free by if_ioctl() calls from user-space in USB drivers by
detaching the ifnet before the miibus.

PR:		252608
Suggested by:	jhb@
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-05-21 14:59:19 +02:00
Hans Petter Selasky
e5ff940a81 Propagate down USB explore error codes, so that failures to enumerate USB HUBs
behind USB HUBs are detected and the USB reset counter logic will kick in
preventing enumeration of continuously failing ports.

Submitted by:	phk@
Tested by:	bz@
PR:		237666
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-05-18 16:11:35 +02:00
Hans Petter Selasky
70ffaaa69c Update USB_PORT_RESET_RECOVERY to comply with the USB 2.0 specification which
says it should be max 10 milliseconds.

This may fix some USB enumeration issues:
> usbd_req_re_enumerate: addr=3, set address failed! (USB_ERR_IOERROR, ignored)
> usbd_setup_device_desc: getting device descriptor at addr 3 failed,

Found by:	Zhichao1.Li@dell.com
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-05-18 15:52:41 +02:00
Hans Petter Selasky
00e501d720 Update usb_timings_sysctl_handler() to accept any value for timings between
0 milliseconds and 2 seconds inclusivly. Some style fixes while at it.

The USB specification has minimum values and maximum values,
and not only minimum values.

MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-05-18 15:52:41 +02:00
Hans Petter Selasky
47bc8fc9ae Add more USB quirks for Kingston devices.
PR:		253855
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-04-22 12:40:29 +02:00