Commit Graph

4290 Commits

Author SHA1 Message Date
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
Hans Petter Selasky
28af0c4814 Add more USB quirks for Garmin devices.
Sort the Garmin products while at it.

PR:		254664
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-04-22 12:35:07 +02:00
Hans Petter Selasky
d2c8714064 Remove USB device ID added by SVN r150701 in the CDC USB ethernet driver.
Since then, the FreeBSD USB stack has got proper USB RNDIS support.

PR:		254345
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-04-22 12:23:36 +02:00
Hans Petter Selasky
5a3426f453 if_smsc: Add the ability to disable "turbo_mode", also called RX frame batching,
similarly to the Linux driver, by a tunable read only sysctl.

Submitted by:	Oleg Sidorkin <osidorkin@gmail.com>
PR:		254884
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-04-11 20:25:58 +02:00
Poul-Henning Kamp
6c709cbf03 Add Siemens SITOP UPS500S usb device 2021-04-06 10:56:27 +00:00
Ed Maste
453d8a7ee2 rsu: add KASSERT to document maximum mbuf size in rsu_tx_start
PR:		254479
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
2021-03-22 14:34:44 -04:00
Warner Losh
1645a4ae64 usb: tiny formatting nit
Format 300 baud like all the others here. No functional change.
2021-03-11 08:24:13 -07:00
Alexander Motin
2c7dc6bae9 Refactor CTL datamove KPI.
- Make frontends call unified CTL core method ctl_datamove_done()
to report move completion.  It allows to reduce code duplication
in differerent backends by accounting DMA time in common code.
 - Add to ctl_datamove_done() and be_move_done() callback samethr
argument, reporting whether the callback is called in the same
context as ctl_datamove().  It allows for some cases like iSCSI
write with immediate data or camsim frontend write save one context
switch, since we know that the context is sleepable.
 - Remove data_move_done() methods from struct ctl_backend_driver,
unused since forever.

MFC after:	 1 month
2021-02-21 16:52:33 -05:00
Vladimir Kondratyev
032d315387 ukbd: Fix handling of keyboard ErrorRollOver reports
Ignore fantom keyboard state reports entirelly rather than ignore
RollOver states for each key separatelly.  Latter results in spurious
release/push pairs of events on each fantom keyboard state report.

Reported by:	Jan Martin Mikkelsen <janm_AT_transactionware_DOT_com>
Submitted by:	Jan Martin Mikkelsen (initial version)
PR:		253249
MFC after:	1 week
2021-02-13 21:12:56 +03:00
Vladimir Kondratyev
d8c6d4c732 wsp: Add sysctl tunable for Z-Axis inversion
This adds a new sysctl to Wellspring Touchpad driver for controlling
Z-Axis (2-finger vertical scroll) direction "hw.usb.wsp.z_invert".

Submitted by:	James Wright <james.wright_AT_digital-chaos_DOT_com>
Reviewed by:	wulf
PR:		253321
Differential revision:	https://reviews.freebsd.org/D28521
2021-02-09 00:35:39 +03:00
Vladimir Kondratyev
b62f6dfaed hid: Replace USBHID_ENABLED kernel config option with loader tunable
usbhid(4) is disabled by default to avoid conflicts with existing USB HID
drivers. To enable it place following lines to /boot/loader.conf:

hw.usb.usbhid.enable=1
usbhid_load="YES"

Suggested by:	jhb
Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D28124
2021-01-14 23:04:47 +03:00
Hans Petter Selasky
6e5baec33c Fix for use-after-free in if_ure(4) driver.
When detaching the if_ure(4) driver, the TX active USB transfer array may
point to freed USB transfers. Given that the number of USB transfers is
very low, simply start all transfers every time there is a packet to
keep safe from use-after-free.

PR: 252608
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking
2021-01-12 17:57:58 +01:00
Vladimir Kondratyev
9be6b22da9 hidraw(4): Add HIDRAW_MAKE_UHID_ALIAS kernel option
which installs /dev/uhid# alias to hidraw character device for
compatibility with some existing uhid(4) users like Firefox.
As side effect it renames traditional uhid(4) driver to hidraw
to make possible using of common unit number allocator.

Requested by:	Greg V <greg_unrelenting.technology>
Reviewed by:	hselasky (as part of D27992)
2021-01-08 02:18:44 +03:00
Vladimir Kondratyev
9477390796 hid: Import hidraw(4) - driver for access to raw HID device data
This driver provides raw access to HID devices through uhid(4)-compatible
interface and is based on pre-8.x uhid(4) code. Unlike uhid(4) it does
not take devices in to monopoly ownership and allows parallel access
from other drivers.

hidraw supports Linux's hidraw-compatible interface as well.

Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D27992
2021-01-08 02:18:43 +03:00
Vladimir Kondratyev
01f2e864f7 hid: Import usbhid - USB transport backend for HID subsystem.
This change implements hid_if.m methods for HID-over-USB protocol [1].

Also, this change adds USBHID_ENABLED kernel option which changes
device_probe() priority and adds/removes PnP records to prefer usbhid
over ums, ukbd, wmt and other USB HID device drivers and vice-versa.

The module is based on uhid(4) driver.  It is disabled by default for
now due to conflicts with existing USB HID drivers.

[1] https://www.usb.org/sites/default/files/hid1_11.pdf

Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D27893
2021-01-08 02:18:43 +03:00
Vladimir Kondratyev
eead9017d2 hid: Chase for HID function name changes in existing USB HID drivers
Also hide shim code added in a previous commit under COMPAT_USBHID12.

Note: it is enough to add -DCOMPAT_USBHID12 to CFLAGS to compile old
code with new HID subsystem, but it is not enough to link it at runtime.
HID dependency has to be added explicitly with MODULE_DEPEND macro.

Reviewed by:	manu, hselasky (as part of D27887)
2021-01-08 02:18:42 +03:00
Vladimir Kondratyev
1975878673 hid: Import functions and constants required by new subsystem
This does an import of quirk stubs, debugging macros from USB code and
numerous usage constants used by dependent drivers.

Besides, this change renames some functions to get a better matching
with userland library and NetBSD/OpenBSD HID code. Namely:

- Old hid_report_size() renamed to hid_report_size_max()
- New hid_report_size() calculates size of given report rather than
  maximum size of all reports.
- hid_get_data_unsigned() renamed to hid_get_udata()
- hid_put_data_unsigned() renamed to hid_put_udata()

Compat shim functions are provided in usbhid.h to make possible compile
of legacy code unmodified after this change.

Reviewed by:	manu, hselasky
Differential revision:	https://reviews.freebsd.org/D27887
2021-01-08 02:18:42 +03:00
Vladimir Kondratyev
67de2db262 Factor-out hardware-independent part of USB HID support to new module
It will be used by the upcoming HID-over-i2C implementation.  Should be
no-op, except hid.ko module dependency is to be added to affected drivers.

Reviewed by:	hselasky, manu
Differential revision:	https://reviews.freebsd.org/D27867
2021-01-08 02:18:42 +03:00
Vladimir Kondratyev
5af73ad51b evdev: Remove useless "initial value" parameter from evdev_support_abs()
It can not be used for setting of state of multitouch events.
If necessary, use evdev_push_event() instead of it.
2021-01-08 02:18:41 +03:00
Vladimir Kondratyev
95e1f0d684 Allow HID report descriptor parser to return more then 1 usage per item
This handles parsing of following descriptor, containing array of
usages:

0x05, 0x01,        // Usage Page (Generic Desktop Ctrls)
0x09, 0x80,        // Usage (Sys Control)
0xA1, 0x01,        // Collection (Application)
0x75, 0x02,        //   Report Size (2)
0x95, 0x01,        //   Report Count (1)
0x15, 0x01,        //   Logical Minimum (1)
0x25, 0x03,        //   Logical Maximum (3)
0x09, 0x82,        //   Usage (Sys Sleep)
0x09, 0x81,        //   Usage (Sys Power Down)
0x09, 0x83,        //   Usage (Sys Wake Up)
0x81, 0x60,        //   Input (Data,Array,Abs)
0x75, 0x06,        //   Report Size (6)
0x81, 0x03,        //   Input (Const,Var,Abs)
0xC0,              // End Collection

Our current parser returns only first usage (Sys Sleep) and loses next
two. Set HID_ITEM_MAXUSAGE limit relatively low as existing code
usually allocates hid_item on stack.

Also tweak hid_locate() to support hid items with multiple usages.

Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D27748
2021-01-08 02:18:41 +03:00
Vladimir Kondratyev
3f27092854 hid_locate: do not ignore constant items.
hid_locate() currently ignores all HID items which tagged as constant,
i.e. bit 0 of main item data is set to 1. See p.6.2.2.4 of
hid1_11.pdf [1]. Such an items are unconditionally treated as
byte-alignment padding. While that may be right decision for input and
output reports that is wrong for features reports. Feature reports can
contain constant capabilities e.g. 'Contact Count Maximum'.
See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=232040

Remove check for constant from hid_locate() to make possible parsing of
such a reports.

[1] https://www.usb.org/sites/default/files/documents/hid1_11.pdf

Reviewed by:	hselasky
Obtained from:	sysutils/iichid
Differential Revision:	https://reviews.freebsd.org/D27747
2021-01-08 02:18:41 +03:00
Hans Petter Selasky
ea0efc3704 Add support for PL2303HXN to uplcom(4).
Code changes in this commit were obtained from straight from OpenBSD's
uplcom.c with almost no modification, the list of chip names and USB
IDs was obtained from Linux.

Differential Revision: https://reviews.freebsd.org/D27952
Submitted by: tomli_tomli.me (Yifeng Li)
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking
2021-01-07 15:35:35 +01:00
Hans Petter Selasky
c834f30a0c Add new PCI ID for XHCI(4).
Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking
2021-01-07 15:35:35 +01:00