Commit Graph

4263 Commits

Author SHA1 Message Date
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
John Baldwin
282381aa53 rsu: Don't modify read-only firmware block.
The firmware header loaded into an rsu(4) device has to be customized
to reflect device settings.  The driver was overwriting the header
from the shared firmware image before sending it to the device.  If
two devices attached at the same time with different settings, one
device could potentially get a corrupted header.  The recent changes
in a095390344 exposed this bug in the
form of a panic as the firmware blobs are now marked read-only in
object files and mapped read-only by the kernel.

To avoid the bug, change the driver to allocate a copy of the firmware
header on the stack that is initialized before writing it to the
device.

PR:		252163
Reported by:	vidwer+fbsdbugs@gmail.com
Tested by:	vidwer+fbsdbugs@gmail.com
Reviewed by:	hselasky, bz, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27850
2020-12-30 15:21:35 -08:00
Marius Strobl
5db1ed2f33 ohci(4): remove support for Sun PCIO-2 USB controllers
It's no longer used since 58aa35d429
and r357455 respectively.
2020-12-25 19:47:46 +01:00
Ryan Libby
322a188d45 wmt: quiet gcc -Wparentheses
Reviewed by:	wulf
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D27767
2020-12-24 12:49:27 -08:00
Vladimir Kondratyev
30f34a5193 ukbd(4): Push LED events in ioctl handler rather than in xfer callback
If LED state is set through evdev interface, than asynchronous nature
of USB transfer callback can lead to change of order of events echoed
back to userland as it causes LED events to be echoed with some lag.

Fix that with echoing of LED events synchronously in ioctl handler.

Reviewed by:	hselasky
Obtained from:	sysutils/iichid
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D27750
2020-12-24 22:08:04 +03:00
Vladimir Kondratyev
769935a4ed ukbd(4): Do not serialize evdev key events
Unlike AT keyboards, HID devices are able to send all pc105 key
states within a single report. Let evdev to transmit all key state
changes within a single report too.

Reviewed by:	hselasky
Obtained from:	sysutils/iichid
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D27749
2020-12-24 21:56:33 +03:00
Hans Petter Selasky
a8261b70e6 Add support for USB-C and TB3 Gen2 to if_ure(4).
Add support for LAN found on Thinkpad USB-C and Thunderbolt Gen 2
docking stations.

Submitted by:	ali.abdallah@suse.com
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-12-24 12:59:19 +01:00
Vladimir Kondratyev
c26a348427 wmt(4): Use sys/param.h macroses to work with bit fields
Obtained from:	sysutils/iichid
2020-12-24 01:27:17 +03:00
Vladimir Kondratyev
18a3b77e22 wmt(4): Refactor 'Contact Count Maximum' parsing
That is done mainly to reduce diff with upstream.

Obtained from:	sysutils/iichid
2020-12-24 01:26:06 +03:00
Vladimir Kondratyev
501022d3a0 wmt(4): Add support for hardware timestamp reporting
Hardware timestamp reporting is disabled by default as it produces many
extra events which are not handled by consumers like libinput.
Add hw.usb.wmt.timestamps=1 tunable to loader.conf to enable it.

Obtained from:	sysutils/iichid
2020-12-24 01:24:53 +03:00
Vladimir Kondratyev
8de78df54d wmt(4): Add support for touchpads
Obtained from:	sysutils/iichid
2020-12-24 01:22:56 +03:00
Vladimir Kondratyev
7eae6aab7d wmt(4): Fetch and parse HID report descriptor only one time
Do it at probe stage and reuse results during attach.

Obtained from:	sysutils/iichid
2020-12-24 01:21:53 +03:00
Vladimir Kondratyev
0ba4b5ff4c wmt(4): Add support for hybrid mode
In Hybrid mode, the number of contacts that can be reported in one
report is less than the maximum number of contacts that the device
supports.  For example, a device that supports a maximum of 4
concurrent physical contacts, can set up its top-level collection to
deliver a maximum of two contacts in one report.  If four contact
points are present, the device can break these up into two serial
reports that deliver two contacts each.

Obtained from:	sysutils/iichid
2020-12-24 01:19:41 +03:00
Hans Petter Selasky
1622a49852 No need to stop XHCI endpoints in disabled state.
Some AMD XHCI implementations apparently assert a permanent
internal failure if this happens.

Submitted by:	ali.abdallah@suse.com
PR:		251503
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-12-23 12:04:51 +01:00
Hans Petter Selasky
7d0368ee34 Ensure a minimum packet length before creating a mbuf in if_ure.
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-12-19 11:03:54 +00:00
Hans Petter Selasky
412bbd0811 Move SYSCTL_ADD_PROC() to unlocked context in if_ure to avoid lock order reversal.
MFC after:	1 week
Reported by:	Mark Millard <marklmi@yahoo.com>
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-12-19 11:00:11 +00:00
Jessica Clarke
ddf42202c9 usb: Replace ITUNERNET vendor with MICROCHIP and improve product names
These Mini-Box LCDs are using Microchip components and sub-licensed product
IDs. Whilst here, update the constant names and descriptions for the products
to use the names listed on the manufacturer's website rather than vague ones.
The picoLCD 4x20 is named that on the manufacturer's website so prefer that
name, even though linux-usb.org lists it with the numbers reversed as one might
expect.

Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D27670
2020-12-18 23:31:36 +00:00
John Baldwin
52ab576d74 Use __containerof() instead of home-rolled versions.
Reviewed by:	imp, hselasky
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27582
2020-12-17 20:45:10 +00:00
John Baldwin
3ab53b27e3 Use more standard types for manipulating pointers.
- Use a uintptr_t cast to get the virtual address of a pointer in
  USB_P2U() instead of a ptrdiff_t.

- Add offsets to a char * pointer directly without roundtripping the
  pointer through a ptrdiff_t in USB_ADD_BYTES().

Reviewed by:	imp, hselasky
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27581
2020-12-16 00:27:28 +00:00
Hans Petter Selasky
b1f99f9cc9 Improve handling of alternate settings in the USB stack.
Move initialization of num_altsetting under USB_CFG_INIT, else
there will be a page fault when enumerating USB devices.

PR:		251856
MFC after:	1 week
Submitted by:	Ma, Horse <Shichun.Ma@dell.com>
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-12-15 15:36:41 +00:00
Hans Petter Selasky
b8b3f4fdc3 Improve handling of alternate settings in the USB stack.
Allow setting the alternate interface number to fail when there is only
one alternate setting present, to comply with the USB specification.

Refactor how iface->num_altsetting is computed.

Bump the __FreeBSD_version due to change of core USB structure.

PR:		251856
MFC after:	1 week
Submitted by:	Ma, Horse <Shichun.Ma@dell.com>
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-12-15 12:05:07 +00:00
Hans Petter Selasky
6da5df4700 Improve handling of alternate settings in the USB stack.
Limit the number of alternate settings to 256.
Else the alternate index variable may wrap around.

PR:		251856
MFC after:	1 week
Submitted by:	Ma, Horse <Shichun.Ma@dell.com>
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-12-15 11:51:17 +00:00
Bjoern A. Zeeb
9d2d04462d USB umass: add quirk to not probe
Some USB WLAN devices have "on-board" storage showing up as umass
and making the root mount wait for a very long time.
The WLAN drivers know how to deal with that an issue an eject
command later when attaching themselves.
Introduce a quirk to not probe these devices as umass and avoid
hangs and confusion altogether.

Reviewed by:	hselasky, imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D27434
2020-12-01 18:24:06 +00:00
Konstantin Belousov
cd85379104 Make MAXPHYS tunable. Bump MAXPHYS to 1M.
Replace MAXPHYS by runtime variable maxphys. It is initialized from
MAXPHYS by default, but can be also adjusted with the tunable kern.maxphys.

Make b_pages[] array in struct buf flexible.  Size b_pages[] for buffer
cache buffers exactly to atop(maxbcachebuf) (currently it is sized to
atop(MAXPHYS)), and b_pages[] for pbufs is sized to atop(maxphys) + 1.
The +1 for pbufs allow several pbuf consumers, among them vmapbuf(),
to use unaligned buffers still sized to maxphys, esp. when such
buffers come from userspace (*).  Overall, we save significant amount
of otherwise wasted memory in b_pages[] for buffer cache buffers,
while bumping MAXPHYS to desired high value.

Eliminate all direct uses of the MAXPHYS constant in kernel and driver
sources, except a place which initialize maxphys.  Some random (and
arguably weird) uses of MAXPHYS, e.g. in linuxolator, are converted
straight.  Some drivers, which use MAXPHYS to size embeded structures,
get private MAXPHYS-like constant; their convertion is out of scope
for this work.

Changes to cam/, dev/ahci, dev/ata, dev/mpr, dev/mpt, dev/mvs,
dev/siis, where either submitted by, or based on changes by mav.

Suggested by: mav (*)
Reviewed by:	imp, mav, imp, mckusick, scottl (intermediate versions)
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D27225
2020-11-28 12:12:51 +00:00
Li-Wen Hsu
ed0d16b017 ipheth(4): Fix for iOS 14
Fix USB tethering for iOS 14.

Inspired by:	https://github.com/libimobiledevice/libimobiledevice/issues/1038

PR:		249979
Reviewed by:	hselasky
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D27250
2020-11-18 19:35:30 +00:00
Hans Petter Selasky
a2dd1caade Fix build of USB bootloader code by adding checks for _STANDALONE being defined.
Currently the USB bootloader code is not part of buildworld.

MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-11-18 13:22:22 +00:00
Ed Maste
46a5f8837d uplcom: add ATen/Prolific USB-232 Controller D USB ID
PR:		251166
Submitted by:	marcus
MFC after:	2 weeks
2020-11-17 18:28:20 +00:00
Hans Petter Selasky
6abe97c014 Add more USB quirks.
PR:		230038
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-11-12 18:24:37 +00:00