summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/usb
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/common/sys/usb')
-rw-r--r--usr/src/uts/common/sys/usb/usba/bos.h242
-rw-r--r--usr/src/uts/common/sys/usb/usba/usba10.h3
-rw-r--r--usr/src/uts/common/sys/usb/usba/usba_impl.h9
-rw-r--r--usr/src/uts/common/sys/usb/usba/usba_private.h32
-rw-r--r--usr/src/uts/common/sys/usb/usba/usba_types.h12
-rw-r--r--usr/src/uts/common/sys/usb/usbai.h4
6 files changed, 282 insertions, 20 deletions
diff --git a/usr/src/uts/common/sys/usb/usba/bos.h b/usr/src/uts/common/sys/usb/usba/bos.h
new file mode 100644
index 0000000000..417dd1e60c
--- /dev/null
+++ b/usr/src/uts/common/sys/usb/usba/bos.h
@@ -0,0 +1,242 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
+
+#ifndef _SYS_USB_BOS_H
+#define _SYS_USB_BOS_H
+
+/*
+ * This header contains definitions that relate to the USB Binary Object Store.
+ * While this functionality was originally introduced with WUSB, it was used in
+ * USB 3.x as a way to provide additional device related information. This is
+ * currently separate from the primary usbai headers as this functionality is
+ * not currently used by client device drivers themselves, but only by the hub
+ * driver for private functionality.
+ *
+ * This data is all derived from the USB 3.1 specification, Chapter 9.6.2 Binary
+ * Device Object Store (BOS).
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Capability list, see USB 3.1 r1.0, Table 9-14.
+ */
+#define USB_BOS_TYPE_INVALID 0x00 /* Internal, synthetic value */
+#define USB_BOS_TYPE_WUSB 0x01
+#define USB_BOS_TYPE_USB2_EXT 0x02
+#define USB_BOS_TYPE_SUPERSPEED 0x03
+#define USB_BOS_TYPE_CONTAINER 0x04
+#define USB_BOS_TYPE_PLATFORM 0x05
+#define USB_BOS_TYPE_PD_CAP 0x06
+#define USB_BOS_TYPE_BATTERY_INFO 0x07
+#define USB_BOS_TYPE_PD_CONSUMER_CAP 0x08
+#define USB_BOS_TYPE_PD_PRODUCER_CAP 0x09
+#define USB_BOS_TYPE_SUPERSPEED_PLUS 0x0a
+#define USB_BOS_TYPE_PRECISION_TIME 0x0b
+#define USB_BOS_TYPE_WUSB_EXT 0x0c
+
+/*
+ * General Binary Object Store (BOS) descriptor. This is returned at the start
+ * of the BOS tree. See USB 3.1/Table 9-12.
+ */
+typedef struct usb_bos_descr {
+ uint8_t bLength; /* Descriptor size */
+ uint8_t bDescriptorType; /* Set to USB_DESCR_TYPE_BOS */
+ uint16_t wTotalLength; /* Total length */
+ uint8_t bNumDeviceCaps; /* Number of caps that follow */
+} usb_bos_descr_t;
+
+/*
+ * This is the size of the usb_bos_descr_t in terms of packed bytes.
+ */
+#define USB_BOS_PACKED_SIZE 5
+
+/*
+ * This represents a Device Capability Descriptor. bNumDeviceCaps of these
+ * follow the usb_bos_descr_t. This structure is the generic header of each
+ * device capability. Capability specific ones follow this. See USB 3.1/Table
+ * 9-14.
+ */
+typedef struct usb_dev_cap_descr {
+ uint8_t bLength; /* Descriptor size */
+ uint8_t bDescriptorType; /* USB_TYPE_DEV_CAPABILITY */
+ uint8_t bDevCapabilityType; /* USB_BOS_TYPE_* value */
+} usb_dev_cap_descr_t;
+
+#define USB_DEV_CAP_PACKED_SIZE 3
+
+/*
+ * SuperSpeed devices include this descriptor to describe additional
+ * capabilities that they have when operating in USB 2.0 High-Speed mode. See
+ * USB 3.1/9.6.2.1 USB 2.0 Extension.
+ */
+typedef struct usb_bos_usb2ext {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint8_t bDevCapabilityType;
+ uint32_t bmAttributes; /* Bitfield defined below */
+} usb_bos_usb2ext_t;
+
+#define USB_BOS_USB2EXT_PACKED_SIZE 7
+
+#define USB_BOS_USB2EXT_LPM 0x02
+
+/*
+ * SuperSpeed devices include this descriptor to describe various hardware
+ * attributes related to basic USB 3.0 SuperSpeed functionality. See USB
+ * 3.1/9.6.2.2 SuperSpeed USB Device Capability.
+ */
+typedef struct usb_bos_ssusb {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint8_t bDevCapabilityType;
+ uint8_t bmAttributes; /* Capability bitfield */
+ uint16_t wSpeedsSupported; /* speed bitmap defined below */
+ uint8_t bFunctionalitySupport; /* Minimum supported speed */
+ uint8_t bU1DevExitLat; /* Exit latency in us */
+ uint16_t bU2DevExitLat; /* Exit latency in us */
+} usb_bos_ssusb_t;
+
+#define USB_BOS_SSUSB_PACKED_SIZE 10
+
+#define USB_BOS_SSUB_CAP_LTM 0x02
+
+#define USB_BOS_SSUSB_SPEED_LOW (1 << 0)
+#define USB_BOS_SSUSB_SPEED_FULL (1 << 1)
+#define USB_BOS_SSUSB_SPEED_HIGH (1 << 2)
+#define USB_BOS_SSUSB_SPEED_SUPER (1 << 3)
+
+/*
+ * This structure is used to indicate a UUID for a given device that could
+ * register on multiple ports. For example, a hub that appears on both a USB 2.x
+ * and USB 3.x port like a hub. This UUID allows one to know that the device is
+ * the same. See USB 3.1/9.6.2.3 Container ID.
+ */
+typedef struct usb_bos_container {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint8_t bDevCapabilityType;
+ uint8_t bReserved;
+ uint8_t ContainerId[16];
+} usb_bos_container_t;
+
+#define USB_BOS_CONTAINER_PACKED_SIZE 20
+
+/*
+ * This structure is used to indicate a platform-specific capability. For more
+ * information, see USB 3.1/9.6.2.4 Platform Descriptor.
+ */
+typedef struct usb_bos_platform {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint8_t bDevCapabilityType;
+ uint8_t bReserved;
+ uint8_t PlatformCapabilityUUID[16];
+ uint8_t CapabilityData[];
+} usb_bos_platform_t;
+
+#define USB_BOS_PLATFORM_MIN_PACKED_SIZE 20
+
+/*
+ * This structure is used to indicate capabilities and attributes of a
+ * SuperSpeedPlus link. This describes the USB 3.1+ speed needs and minimum
+ * attributes of the device. See USB 3.1/9.6.2.5 SuperSpeedPlus USB Device
+ * Capability.
+ */
+typedef struct usb_bos_ssplus {
+ uint8_t bLength;
+ uint8_t bDescriptortype;
+ uint8_t bDevCapabilityType;
+ uint8_t bReserved;
+ uint32_t bmAttributes;
+ uint16_t wFunctionalitySupport;
+ uint16_t wReserved;
+ uint32_t bmSublinkSpeedAttr[];
+} usb_bos_ssplus_t;
+
+#define USB_BOS_SSPLUS_MIN_PACKED_SIZE 16
+
+/*
+ * These macros take apart the bmAttributes fields.
+ */
+#define USB_BOS_SSPLUS_NSSAC(x) (((x) & 0xf) + 1)
+#define USB_BOS_SSPLUS_NSSIC(x) ((((x) & 0xf0) >> 4) + 1)
+
+/*
+ * These macros take apart the wFunctionalitySupport member.
+ */
+#define USB_BOS_SSPLUS_MIN_SSAI(x) ((x) & 0x0f)
+#define USB_BOS_SSPLUS_MIN_RX_LANE(x) (((x) >> 8) & 0xf)
+#define USB_BOS_SSPLUS_MIN_TX_LANE(x) (((x) >> 12) & 0xf)
+
+/*
+ * These macros are used to take apart the bmSublinkSpeedAttr members. There is
+ * always at least one of them that exist in each attribute; however, there
+ * could be more based on the value in NSSAC.
+ */
+#define USB_BOS_SSPLUS_ATTR_SSID(x) ((x) & 0xf)
+#define USB_BOS_SSPLUS_ATTR_LSE(x) (((x) >> 4) & 0x3)
+#define USB_BOS_SSPLUS_ATTR_LSE_BITPS 0
+#define USB_BOS_SSPLUS_ATTR_LSE_KBITPS 1
+#define USB_BOS_SSPLUS_ATTR_LSE_GBITPS 2
+
+/*
+ * These two macros take apart the sublink type. bit 6 indicates whether or not
+ * the links are symmetric or asymmetric. It is asymmetric if the value is set
+ * to one (USB_BOS_SSPLUS_ATTR_ST_ASYM), symmetric otherwise. If it is
+ * asymmetric, then bit 7 indicates whether or not it's a tx or rx link.
+ */
+#define USB_BOS_SSPLUS_ATTR_ST_ASYM (1 << 6)
+#define USB_BOS_SSPLUS_ATTR_ST_TX (1 << 7)
+
+#define USB_BOS_SSPLUS_ATTR_LP(x) (((x) >> 14) & 0x3)
+#define USB_BOS_SSPLUS_ATTR_LP_SS 0x0
+#define USB_BOS_SSPLUS_ATTR_LP_SSPLUS 0x1
+
+#define USB_BOS_SSPLUS_ATTR_LSM(x) ((x) >> 16)
+
+typedef struct usb_bos_precision_time {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint8_t bDevCapabilityType;
+} usb_bos_precision_time_t;
+
+#define USB_BOS_PRECISION_TIME_PACKED_SIZE 3
+
+/*
+ * This structure serves as an internal, parsed representation of a USB bos
+ * descriptor.
+ */
+typedef struct usb_bos {
+ uint8_t ubos_length;
+ uint8_t ubos_type;
+ union {
+ usb_bos_usb2ext_t ubos_usb2;
+ usb_bos_ssusb_t ubos_ssusb;
+ usb_bos_container_t ubos_container;
+ usb_bos_platform_t ubos_platform;
+ usb_bos_ssplus_t ubos_ssplus;
+ usb_bos_precision_time_t ubos_time;
+ uint8_t ubos_raw[256];
+ } ubos_caps;
+} usb_bos_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_USB_BOS_H */
diff --git a/usr/src/uts/common/sys/usb/usba/usba10.h b/usr/src/uts/common/sys/usb/usba/usba10.h
index 947dd65379..42e78cd35e 100644
--- a/usr/src/uts/common/sys/usb/usba/usba10.h
+++ b/usr/src/uts/common/sys/usb/usba/usba10.h
@@ -21,6 +21,7 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2019, Joyent, Inc.
*/
#ifndef _SYS_USB_USBA10_H
@@ -139,7 +140,7 @@ usba10_usb_free_descr_tree(
size_t
usba10_usb_parse_data(
char *format,
- uchar_t *data,
+ const uchar_t *data,
size_t datalen,
void *structure,
size_t structlen);
diff --git a/usr/src/uts/common/sys/usb/usba/usba_impl.h b/usr/src/uts/common/sys/usb/usba/usba_impl.h
index 784bb32d44..ddb6f7346d 100644
--- a/usr/src/uts/common/sys/usb/usba/usba_impl.h
+++ b/usr/src/uts/common/sys/usb/usba/usba_impl.h
@@ -23,6 +23,7 @@
* Use is subject to license terms.
*
* Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ * Copyright 2019, Joyent, Inc.
*/
#ifndef _SYS_USB_USBA_USBA_IMPL_H
@@ -34,6 +35,7 @@
#include <sys/usb/usba/hubdi.h>
#include <sys/usb/usba/usba_private.h>
#include <sys/usb/usba/usba_types.h>
+#include <sys/usb/usba/bos.h>
#include <sys/taskq.h>
#include <sys/disp.h>
@@ -301,6 +303,13 @@ void usba_rem_root_hub(dev_info_t *dip);
void usba_get_dev_string_descrs(dev_info_t *, usba_device_t *);
/*
+ * Retrieve the binary object store for the device.
+ */
+void usba_get_binary_object_store(dev_info_t *, usba_device_t *);
+void usba_add_binary_object_store_props(dev_info_t *, usba_device_t *);
+void usba_free_binary_object_store(usba_device_t *);
+
+/*
* Check if we are not in interrupt context and have
* USB_FLAGS_SLEEP flags set.
*/
diff --git a/usr/src/uts/common/sys/usb/usba/usba_private.h b/usr/src/uts/common/sys/usb/usba/usba_private.h
index 4e56e4aa47..406ee3824c 100644
--- a/usr/src/uts/common/sys/usb/usba/usba_private.h
+++ b/usr/src/uts/common/sys/usb/usba/usba_private.h
@@ -23,6 +23,7 @@
* Use is subject to license terms.
*
* Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ * Copyright 2019, Joyent, Inc.
*/
#ifndef _SYS_USB_USBA_USBA_PRIVATE_H
@@ -88,21 +89,21 @@ extern "C" {
* extended in a later rev of the spec.
*/
size_t usb_parse_dev_descr(
- uchar_t *buf, /* from GET_DESCRIPTOR(DEVICE) */
+ const uchar_t *buf, /* from GET_DESCRIPTOR(DEVICE) */
size_t buflen,
usb_dev_descr_t *ret_descr,
size_t ret_buf_len);
size_t usb_parse_cfg_descr(
- uchar_t *buf, /* from GET_DESCRIPTOR(CONFIGURATION) */
+ const uchar_t *buf, /* from GET_DESCRIPTOR(CONFIGURATION) */
size_t buflen,
usb_cfg_descr_t *ret_descr,
size_t ret_buf_len);
size_t usb_parse_ia_descr(
- uchar_t *buf, /* from GET_DESCRIPTOR(CONFIGURATION) */
+ const uchar_t *buf, /* from GET_DESCRIPTOR(CONFIGURATION) */
size_t buflen,
size_t first_if,
usb_ia_descr_t *ret_descr,
@@ -110,7 +111,7 @@ size_t usb_parse_ia_descr(
size_t usb_parse_if_descr(
- uchar_t *buf, /* from GET_DESCRIPTOR(CONFIGURATION) */
+ const uchar_t *buf, /* from GET_DESCRIPTOR(CONFIGURATION) */
size_t buflen,
uint_t if_index,
uint_t alt_if_setting,
@@ -123,7 +124,7 @@ size_t usb_parse_if_descr(
* the first endpoint
*/
size_t usb_parse_ep_descr(
- uchar_t *buf, /* from GET_DESCRIPTOR(CONFIGURATION) */
+ const uchar_t *buf, /* from GET_DESCRIPTOR(CONFIGURATION) */
size_t buflen,
uint_t if_index,
uint_t alt_if_setting,
@@ -160,7 +161,7 @@ size_t usb_parse_ep_descr(
#define USB_DESCR_TYPE_ANY -1 /* Wild card */
size_t usb_parse_CV_cfg_descr(
- uchar_t *buf, /* from GET_DESCRIPTOR(CONFIGURATION) */
+ const uchar_t *buf, /* from GET_DESCRIPTOR(CONFIGURATION) */
size_t buflen,
char *fmt,
uint_t descr_type,
@@ -170,7 +171,7 @@ size_t usb_parse_CV_cfg_descr(
size_t usb_parse_CV_if_descr(
- uchar_t *buf, /* from GET_DESCRIPTOR(CONFIGURATION) */
+ const uchar_t *buf, /* from GET_DESCRIPTOR(CONFIGURATION) */
size_t buflen,
char *fmt,
uint_t if_index,
@@ -182,7 +183,7 @@ size_t usb_parse_CV_if_descr(
size_t usb_parse_CV_ep_descr(
- uchar_t *buf, /* from GET_DESCRIPTOR(CONFIGURATION) */
+ const uchar_t *buf, /* from GET_DESCRIPTOR(CONFIGURATION) */
size_t buflen,
char *fmt,
uint_t if_index,
@@ -199,7 +200,7 @@ size_t usb_parse_CV_ep_descr(
*/
size_t usb_parse_CV_descr(
char *format,
- uchar_t *data,
+ const uchar_t *data,
size_t datalen,
void *structure,
size_t structlen);
@@ -270,8 +271,7 @@ typedef enum usba_event {
USBA_EVENT_TAG_HOT_REMOVAL = 0,
USBA_EVENT_TAG_HOT_INSERTION = 1,
USBA_EVENT_TAG_PRE_SUSPEND = 2,
- USBA_EVENT_TAG_POST_RESUME = 3,
- USBA_EVENT_TAG_CPR = -1
+ USBA_EVENT_TAG_POST_RESUME = 3
} usba_event_t;
#define USBA_PRE_SUSPEND_EVENT "SUNW,USBA:USBA_PRE_SUSPEND"
@@ -409,11 +409,11 @@ typedef struct usba_if_pwr_descr {
uint16_t TransitionTimeFromD3; /* D3 -> D0 transition time */
} usba_if_pwr_descr_t;
-size_t usba_parse_cfg_pwr_descr(uchar_t *, size_t, usba_cfg_pwr_descr_t *,
- size_t);
+size_t usba_parse_cfg_pwr_descr(const uchar_t *, size_t, usba_cfg_pwr_descr_t *,
+ size_t);
-size_t usba_parse_if_pwr_descr(uchar_t *, size_t buflen, uint_t,
- uint_t, usba_if_pwr_descr_t *, size_t);
+size_t usba_parse_if_pwr_descr(const uchar_t *, size_t buflen, uint_t,
+ uint_t, usba_if_pwr_descr_t *, size_t);
/*
* Returns (at ret_descr) a null-terminated string. Null termination is
@@ -423,7 +423,7 @@ size_t usba_parse_if_pwr_descr(uchar_t *, size_t buflen, uint_t,
* XXX is this needed when there is usb_get_string_descriptor
* If so, then more comments about how it differs?
*/
-size_t usba_ascii_string_descr(uchar_t *, size_t, char *, size_t);
+size_t usba_ascii_string_descr(const uchar_t *, size_t, char *, size_t);
/*
diff --git a/usr/src/uts/common/sys/usb/usba/usba_types.h b/usr/src/uts/common/sys/usb/usba/usba_types.h
index c99a958c1a..e09bacb860 100644
--- a/usr/src/uts/common/sys/usb/usba/usba_types.h
+++ b/usr/src/uts/common/sys/usb/usba/usba_types.h
@@ -22,6 +22,7 @@
* Use is subject to license terms.
*
* Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ * Copyright 2019, Joyent, Inc.
*/
#ifndef _SYS_USB_USBA_USBA_TYPES_H
@@ -31,6 +32,7 @@
#include <sys/taskq.h>
#include <sys/usb/usba/usba_private.h>
#include <sys/usb/usba/usbai_private.h>
+#include <sys/usb/usba/bos.h>
#ifdef __cplusplus
extern "C" {
@@ -241,7 +243,7 @@ typedef struct usb_client_dev_data_list {
} usb_client_dev_data_list_t;
/*
- * This structure uniquely identifies a USB device
+ * This structure uniquely identifies a USB device
* with all interfaces, or just one interface of a USB device.
* usba_device is associated with a devinfo node
*
@@ -363,6 +365,14 @@ typedef struct usba_device {
* Private data for HCD drivers
*/
void *usb_hcd_private;
+
+ /*
+ * Binary Object Store data
+ */
+ mblk_t *usb_bos_mp;
+ uint_t usb_bos_nalloc;
+ uint_t usb_bos_nents;
+ usb_bos_t *usb_bos;
} usba_device_t;
#define USBA_CLIENT_FLAG_SIZE 1
diff --git a/usr/src/uts/common/sys/usb/usbai.h b/usr/src/uts/common/sys/usb/usbai.h
index b37d8f230f..6c90a50b81 100644
--- a/usr/src/uts/common/sys/usb/usbai.h
+++ b/usr/src/uts/common/sys/usb/usbai.h
@@ -23,7 +23,7 @@
* Use is subject to license terms.
*
* Copyright 2014 Garrett D'Amore <garrett@damore.org>
- * Copyright 2016 Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
*/
#ifndef _SYS_USB_USBAI_H
@@ -789,7 +789,7 @@ void usb_client_detach(
size_t usb_parse_data(
char *format,
- uchar_t *data,
+ const uchar_t *data,
size_t datalen,
void *structure,
size_t structlen);