Commit Graph

55 Commits

Author SHA1 Message Date
Pawel Biernacki
f8d2b1f3f7 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (2 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked). Use it in
preparation for a general review of all nodes.
This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Reviewed by:	hselasky, kib
Approved by:	kib (mentor)
Differential Revision:	https://reviews.freebsd.org/D23632
2020-02-15 18:52:12 +00:00
Edward Tomasz Napierala
63722e5212 Add cdceem(4) driver, for virtual ethernet devices compliant
with Communication Device Class Ethernet Emulation Model (CDC EEM).
The driver supports both the device, and host side operation; there
is a new USB template (#11) for the former.

This enables communication with virtual USB NIC provided by iLO 5,
as found in new HPE Proliant servers.

Reviewed by:	hselasky
MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	Hewlett Packard Enterprise
2019-08-07 18:14:45 +00:00
Edward Tomasz Napierala
e8a5d07df5 Set bDeviceClass properly for composite device (template 8). There should
be no functional change.

PR:		203289
Reviewed by:	hselasky@
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-06-01 09:17:20 +00:00
Edward Tomasz Napierala
6ad033c2f1 Clarify that USB bus power consumption is measured in mA at 5V.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-05-24 18:02:02 +00:00
Edward Tomasz Napierala
d008c0d75f Centralize USB device mode bus power reporting, and add
hw.usb.template_power sysctl to control it.

Reviewed by:	hselasky@ (earlier version)
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-05-23 20:06:04 +00:00
Edward Tomasz Napierala
defd918d79 Add new PIDs for Audio, CDCE, MTP, and Mass Storage, from
https://github.com/obdev/v-usb/blob/master/usbdrv/USB-IDs-for-free.txt.

Big thanks to Christian Starkjohann for allocating those.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-05-22 19:11:06 +00:00
Edward Tomasz Napierala
733efc21c4 Add a somewhat ugly hack that makes OSX serial device node names
human-readable.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-05-21 17:33:52 +00:00
Edward Tomasz Napierala
ac4a7f30d2 Improve description strings for USB device-mode serial ports.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-05-21 16:33:13 +00:00
Edward Tomasz Napierala
d01c1c8bfe Use USB Vendor Identifiers and Product Identifiers provided by V-USB
(https://github.com/obdev/v-usb/blob/master/usbdrv/USB-IDs-for-free.txt).
Previously we were using an invalid (not assigned to us) VID.

Reviewed by:	hselasky@
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-05-21 15:06:19 +00:00
Edward Tomasz Napierala
86c61317fd Fix whitespace; no functional changes.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-05-19 15:18:15 +00:00
Edward Tomasz Napierala
1558eec6db Add #defines for vendor/product USB IDs. No functional changes.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-05-19 15:11:24 +00:00
Edward Tomasz Napierala
6b7e508c4a Stop claiming the device-side USB serial interfaces talk Hayes AT.
There should be no functional difference.

Reviewed by:	hselasky@
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-05-18 20:24:19 +00:00
Edward Tomasz Napierala
3dc87e52a9 Add a "multifunction" device side USB template, which provides mass
storage, CDC ACM (serial), and CDC ECM (ethernet) at the same time.
It's quite similar in function to Linux' "g_multi" gadget.

Reviewed by:	hselasky@
MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	The FreeBSD Foundation
2018-05-17 19:54:11 +00:00
Edward Tomasz Napierala
2d1a76975e Fix off-by-one in usb_decode_str_desc(). Previously it would decode
one character too many.  Note that this function is only used to decode
string descriptors generated by the kernel itself.

Reviewed by:	hselasky@
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-05-17 15:19:29 +00:00
Edward Tomasz Napierala
4e6e77b74f Fix sysctl description.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-05-15 15:11:52 +00:00
Hans Petter Selasky
c70e38e40c Give USB template SYSUNINIT()'s a uniq name to avoid symbol name collision
when building stand/usb. Regression after r328194.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2018-02-07 18:46:08 +00:00
Edward Tomasz Napierala
1ee5bed72a Add missing manufacturer/serial number string descriptors.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-01-21 17:31:31 +00:00
Edward Tomasz Napierala
ad2c142415 Remove unused index.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-01-20 14:05:55 +00:00
Edward Tomasz Napierala
42e42a9aa4 Add missing SPDX tags; the rest of the license text is the same as in other
USB templates.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-01-20 14:03:55 +00:00
Edward Tomasz Napierala
8e06491a4e Add sysctls to control device side USB identifiers. This makes it
possible to change string and numeric vendor and product identifiers,
as well as anything else there might be to change for a particular
device side template, eg the MAC address.

Reviewed by:	hselasky@
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D13920
2018-01-20 13:58:34 +00:00
Pedro F. Giffuni
718cf2ccb9 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 14:52:40 +00:00
Edward Tomasz Napierala
4ffeccf1e8 Replace some magic numbers in usb_template(4) code with #defines.
There should be no functional changes.

Reviewed by:	hselasky
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D12670
2017-10-15 11:46:11 +00:00
Hans Petter Selasky
64cb5e2a26 Resolve deadlock between device_detach() and usbd_do_request_flags()
by reviving the SX control request lock and refining which lock
protects the common scratch area in "struct usb_device".

The SX control request lock was removed by r246759 because it caused a
lock order reversal with the USB enumeration lock inside
usbd_transfer_setup() as a function of r246616. It was thought that
reducing the number of locks would resolve the LOR, but because some
USB device drivers use usbd_do_request_flags() inside callback
functions, like in taskqueues, a deadlock may occur when these are
drained from device_detach(). By restoring the SX control request
lock usbd_do_request_flags() is allowed to complete its execution
when a USB device driver is detaching. By using the SX control request
lock to protect the scratch area, the LOR introduced by r246616 is
also resolved.

Bump the FreeBSD version while at it to force recompilation of all USB
kernel modules.

Found by:	avos@
MFC after:	1 week
2016-09-05 15:35:58 +00:00
Edward Tomasz Napierala
5a92ac1d68 Fix MTP description in the comment.
MFC after:	1 month
2016-07-29 11:33:01 +00:00
Pedro F. Giffuni
207332450e dev/usb: minor spelling fixes in comments.
No functional change.

Reviewed by:	hselasky
2016-05-02 17:44:03 +00:00
Hans Petter Selasky
be14cd6be7 Fix spelling. 2015-06-03 15:43:55 +00:00
Hans Petter Selasky
0a76fe7c24 Add USB MIDI template for USB device side mode. 2015-06-01 11:24:34 +00:00
Ruslan Bukin
3e420a3e12 Add usb template SERIALNET allowing us to have both USB CDC Ethernet
and USB CDC Modem same time by single cable.

Reviewed by:	hselasky@
2015-01-13 14:03:56 +00:00
Hans Petter Selasky
f9478f91fb Add new USB phone descriptor template for USB device side mode.
MFC after:	3 days
2014-08-05 07:03:16 +00:00
Hans Petter Selasky
e892b3fe36 USB method structures for USB controllers and USB pipes should be
constant and does not need to be modified. This also saves a small
amount of RAM.
2013-12-11 13:20:32 +00:00
Hans Petter Selasky
2c79a775ed - Add more defines to limit USB memory usage and number of allocations
in reduced memory systems.

- Split allocation and freeing of the configuration descriptor into a separate
function, so that the configuration descriptor can be made fixed size
to save memory allocations. This applies for both device and host mode.
2013-05-03 11:10:04 +00:00
Hans Petter Selasky
6950c75f40 - Move scratch data from the USB bus structure to the USB device structure
so that simultaneous access cannot happen. Protect scratch area using
the enumeration lock. Also reduce stack usage in usbd_transfer_setup()
by moving some big stack members to the scratch area. This saves around
200 bytes of stack.
- Fix a whitespace.

MFC after:	1 week
2013-02-10 10:56:13 +00:00
Hans Petter Selasky
b51875c9f6 Use string literals in string descriptors for marginally
better readability.

Submitted by:	Christoph Mallon
2013-01-30 16:05:54 +00:00
Hans Petter Selasky
23ab08715c Provide one global language string descriptor for
american english instead of giving each module its
own.

Submitted by:	Christoph Mallon
2013-01-30 15:46:26 +00:00
Hans Petter Selasky
d2b99310b1 Modify the FreeBSD USB kernel code so that it can be compiled directly
into the FreeBSD boot loader, typically for non-USB aware BIOSes, EFI systems
or embedded platforms. This is also useful for out of the system compilation
of the FreeBSD USB stack for various purposes. The USB kernel files can
now optionally include a global header file which should include all needed
definitions required to compile the FreeBSD USB stack. When the global USB
header file is included, no other USB header files will be included by
default.

Add new file containing the USB stack configuration for the
FreeBSD loader build.

Replace some __FBSDID()'s by /* $FreeBSD$ */ comments. Now all
USB files follow the same style.

Use cases:
 - console in loader via USB
 - loading kernel via USB

Discussed with:		Hiroki Sato, hrs @ EuroBSDCon
2013-01-30 15:26:04 +00:00
Hans Petter Selasky
3758c66a4f Remove some extra and not needed space characters.
MFC after:	1 week
2013-01-28 10:52:24 +00:00
Hans Petter Selasky
6d917491f5 Fix compiler warnings, mostly signed issues,
when USB modules are compiled with WARNS=9.

MFC after:	1 weeks
2012-04-02 10:50:42 +00:00
Hans Petter Selasky
e6ee4f7d33 Correct some bInterval USB template descriptor values.
MFC after:	3 days
2011-12-06 08:08:52 +00:00
Hans Petter Selasky
271ae033e9 Style change.
- Make it easier to port the USB code to other platforms by only using
one set of memory functions for clearing and copying memory. None of
the memory copies are overlapping. This means using bcopy() is not
required.
- Fix a compile warning when USB_HAVE_BUSDMA=0
- Add missing semicolon in avr32dci.
- Update some comments.

MFC after:	1 week
2011-11-12 08:16:45 +00:00
Hans Petter Selasky
df142785d5 - Add some comments about the origin of some USB descriptors.
MFC after:	7 days
2011-06-23 10:35:45 +00:00
Hans Petter Selasky
399e6543b2 - Add more USB templates for various USB device classes
- Add basic template support for USB 3.0
- Export definition of template sysctl numbers through usb_ioctl.h

MFC after:	7 days
2011-06-23 07:54:03 +00:00
Hans Petter Selasky
8833442863 Minor cleanup:
- use device_printf() instead of printf() to give more accurate warnings.
 - use memcpy() instead of bcopy().
 - add missing #if's for non-FreeBSD compilation.

Approved by:	thompsa (mentor)
2011-02-09 08:01:45 +00:00
John Baldwin
58ccf5b41c Remove unneeded includes of <sys/linker_set.h>. Other headers that use
it internally contain nested includes.

Reviewed by:	bde
2011-01-11 13:59:06 +00:00
Andrew Thompson
6a268418dc isochronous endpoint descriptors should have two more bytes which are zero by
default.

Submitted by:	Hans Petter Selasky
2010-03-11 21:48:10 +00:00
Andrew Thompson
9a8e0122d2 - make the usb_temp_setup() and usb_temp_unsetup() functions public so that
other modules can generate USB descriptors.
- extend the vendor specific request function by one length pointer argument,
  because not all descriptors store the length in the first byte. For example
  HID descriptors.

Submitted by:	Hans Petter Selasky
2010-03-11 21:45:31 +00:00
Andrew Thompson
767cb2e29d Remove overuse of exclamation marks in kernel printfs, there mere fact a
message has been printed is enough to get someones attention. Also remove the
line number for DPRINTF/DPRINTFN, it already prints the funtion name and a
unique message.
2009-11-26 00:43:17 +00:00
Andrew Thompson
ed6d949afd - Make struct usb_xfer opaque so that drivers can not access the internals
- Reduce the number of headers needed for a usb driver, the common case is just   usb.h and usbdi.h
2009-06-23 02:19:59 +00:00
Andrew Thompson
a593f6b8de s/usb2_/usb_|usbd_/ on all function names for the USB stack. 2009-06-15 01:02:43 +00:00
Andrew Thompson
e0a69b51ac s/usb2_/usb_/ on all typedefs for the USB stack. 2009-05-29 18:46:57 +00:00
Andrew Thompson
760bc48e7e s/usb2_/usb_/ on all C structs for the USB stack. 2009-05-28 17:36:36 +00:00