USB笔记 超高速设备功能描述符(SuperSpeed Device Capability Descriptor)
超高速设备功能描述符(SuperSpeed Device Capability Descriptor)是设备功能类型码(Device Capability Type Codes)为SUPERSPEED_USB的一个设备功能描述符(Device Capability Descriptor)。超高速设备功能描述符(SuperSpeed Device Capability Descriptor)定义了增强型超高速设备(Enhanced SuperSpeed devices)所需的设备级功能描述符,所有的增强型超高速设备(Enhanced SuperSpeed devices)都需要有该描述符。
超高速设备功能描述符(SuperSpeed Device Capability Descriptor)作为一种设备功能描述符(Device Capability Descriptor),总是作为GetDescriptor(BOS)请求所返回的BOS信息的一部分。主机端不能单独读取单个的超高速设备功能描述符(SuperSpeed Device Capability Descriptor),无法使用GetDescriptor()或SetDescriptor()请求直接读取或设置单独的设备功能,只能通过GetDescriptor()请求获取BOS描述符(BOS Descriptor)并通过wTotalLength字段得到长度来读取整个描述符集。
SuperSpeed Device Capability Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | Number | 以字节为单位的描述符大小 |
1 | bDescriptorType | 1 | Constant | 设备功能描述符类型DEVICE CAPABILITY |
2 | bDevCapabilityType | 1 | Constant | 设备功能类型为SUPERSPEED_USB (03H) |
3 | bmAttributes | 1 | Bitmap | 设备功能的属性 |
4 | wSpeedsSupported | 2 | Bitmap | 设备支持的速度 |
6 | bFunctionalitySupport | 1 | Number | 设备支持的所有功能对用户可用的最低速度 |
7 | bU1DevExitLat | 1 | Number | U1设备退出延迟 |
8 | wU2DevExitLat | 2 | Number | U2设备退出延迟 |
bLength以字节为单位的描述符大小 (0x0A)。
bDescriptorType设备功能描述符类型,为DEVICE CAPABILITY (0x10)。
bDevCapabilityType 设备功能类型,为SUPERSPEED_USB (0x03)。
bmAttributes 支持的设备级别功能。位(bit)置1表示支持该功能,置0表示不支持该功能。
Bits 0 保留,应该设置为0。
Bits 1 具有LTM功能。该位(bit)置1表示这个设备能够生成延迟容忍消息(Latency Tolerance Messages)。
Bits 7:2 保留,应该设置为0。
wSpeedsSupported 这个设备支持的速度。
Bits 0 如果这个位(bit)置1,那么这个设备支持低速USB(low-Speed USB)操作。
Bits 1 如果这个位(bit)置1,那么这个设备支持全速USB(full-Speed USB)操作。
Bits 2 如果这个位(bit)置1,那么这个设备支持高速USB(high-Speed USB)操作。
Bits 3 如果这个位(bit)置1,那么这个设备支持Gen 1 speed操作。
Bits 15:4 保留,应该设置为0。
bFunctionalitySupport 设备支持的所有功能对用户可用的最低速度。
例如,如果设备以全速及以上速度连接时支持所有功能,则将这个值设置为1。请参考wSpeedsSupported字段,了解可以放在该字段中的有效值。
bU1DevExitLat U1设备退出延迟(U1 Device Exit Latency)。
从 U1 到 U0 在最坏情况下的延迟,假设该延迟仅受设备而非设备的链路伙伴限制。
这个字段仅适用于与单个端口相关联的退出延迟,不适用于通过集线器(hub)的总延迟(例如,从下游端口到上游端口)。
有效值如下:
00H 0
01H 小于1 µs
02H 小于 2 µs
03H 小于 3 µs
04H 小于 4 µs
… …
0AH 小于 10 µs
0BH – FFH 保留
对于集线器(hub),这是其上游端口和下游端口的值。
wU2DevExitLat U2设备退出延迟(U2 Device Exit Latency)。
从 U2 到 U0 在最坏情况下的延迟,假设该延迟仅受设备而非设备的链路伙伴限制。适用于设备上的所有端口。
有效值如下:
0000H 0
0001H 小于1 µs
0002H 小于 2 µs
0003H 小于 3 µs
0004H 小于 4 µs
… …
07FFH 小于 2047 µs
0800H – FFFFH 保留
对于集线器(hub),这是其上游端口和下游端口的值。
获取设备功能描述符(Device Capability Descriptor) : 超高速设备功能描述符(SuperSpeed Device Capability Descriptor)
主机通过发送Get Descriptor
请求,取得BOS描述符及其子描述符。超高速设备功能描述符(SuperSpeed Device Capability Descriptor)作为一种设备功能描述符(Device Capability Descriptor),总是作为BOS描述符的一部分返回。
Get Descriptor | Value |
---|---|
bmRequestType | 0x80 |
bmRequestType.Recipient | 0b00000(Device) |
bmRequestType.Type | 0b00(Standard) |
bmRequestType.Direction | 0b1(Device-to-Host) |
bRequest | 0x06(Get Descriptor) |
wValue | 0x0f00(BOS#0) |
wIndex | 0x0000 |
wLength | 0x??? |
下面举例说明一个获取设备功能描述符(Device Capability Descriptor)的过程。使用USB分析仪抓包,软件Total Phase Data Center。这是一个增强型高速设备运行在高速模式下的抓包。
获取一个设备的设备功能描述符(Device Capability Descriptor),该设备的设备功能描述符(Device Capability Descriptor)如下所示,这是一个SuperSpeed Device Capability Descriptor:
使用USB分析仪抓包可以看到,获取BOS描述符(BOS Descriptor),而设备功能描述符(Device Capability Descriptor)就包含在其中:
设备功能描述符(Device Capability Descriptor)的获取过程如下:
再展开看到详细的过程:
接下来详细看整个获取过程的各个字段含义:
一开始的setup包过程:
setup data:
IN包过程
OUT包过程:
完成整个设备功能描述符(Device Capability Descriptor)的获取。
描述符示例
这里举例一个带有超高速设备功能描述符(SuperSpeed Device Capability Descriptor)的完整BOS描述符(BOS Descriptor)。
USB 3.x BOS Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | 0x05 | |
1 | bDescriptorType | 1 | 0x0f | BOS |
2 | wTotalLength | 2 | 0x0016 | |
4 | bNumDeviceCaps | 1 | 0x02 |
Device Capability Descriptor : USB 2.0 Extension Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | 0x07 | |
1 | bDescriptorType | 1 | 0x10 | DEVICE_CAPABILITY |
2 | bDevCapabilityType | 1 | 0x02 | USB 2.0 EXTENSION |
3 | bmAttributes | 4 | 0x00000002 | LPM Supported |
Device Capability Descriptor : SuperSpeed Device Capability Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | 0x0a | |
1 | bDescriptorType | 1 | 0x10 | DEVICE_CAPABILITY |
2 | bDevCapabilityType | 1 | 0x03 | SUPERSPEED_USB |
3 | bmAttributes | 1 | 0x00 | LTM Not Supported |
4 | wSpeedsSupported | 2 | 0x000e | |
6 | bFunctionalitySupport | 1 | 0x02 | High Speed |
7 | bU1DevExitLat | 1 | 0x0a | Less than 10 us |
8 | wU2DevExitLat | 2 | 0x0100 | Less than 256 us |
附录
USB 3.0 Device Capability Descriptor : SuperSpeed Device Capability Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | Number | Size of descriptor |
1 | bDescriptorType | 1 | Constant | DEVICE CAPABILITY Descriptor type |
2 | bDevCapabilityType | 1 | Constant | Capability type: SUPERSPEED_USB |
3 | bmAttributes | 1 | Bitmap | Bitmap encoding of supported device level features. A value of one in a bit location indicates a feature is supported; a value of zero indicates it is not supported. Encodings are: Bit Encoding 0 Reserved. Shall be set to zero. 1 LTM Capable. A value of one in this bit location indicates that this device has is capable of generating Latency Tolerance Messages. 7:2 Reserved. Shall be set to zero. |
4 | wSpeedsSupported | 2 | Bitmap | Bitmap encoding of the speed supported by this device when operating in SuperSpeed mode. Bit Encoding 0 If this bit is set, then the device supports operation at low-Speed USB. 1 If this bit is set, then the device supports operation at full-Speed USB. 2 If this bit is set, then the device supports operation at high-Speed USB. 3 If this bit is set, then the device supports operation at 5 Gbps. 15:4 Reserved. Shall be set to zero. |
6 | bFunctionalitySupport | 1 | Number | The lowest speed at which all the functionality supported by the device is available to the user. For example if the device supports all its functionality when connected at full speed and above then it sets this value to 1. Refer to the wSpeedsSupported field for valid values that can be placed in this field. |
7 | bU1DevExitLat | 1 | Number | U1 Device Exit Latency. Worst case latency to transition from U1 to U0, assuming the latency is limited only by the device and not the device’s link partner. This field applies only to the exit latency associated with an individual port, and does not apply to the total latency through a hub (e.g., from downstream port to upstream port). The following are permissible values: Value Meaning 00H Zero. 01H Less than 1 µs 02H Less than 2 µs 03H Less than 3 µs 04H Less than 4 µs … … 0AH Less than 10 µs 0BH – Reserved FFH For a hub, this is the value for both its upstream and downstream ports. |
8 | wU2DevExitLat | 2 | Number | U2 Device Exit Latency. Worst case latency to transition from U2 to U0, assuming the latency is limited only by the device and not the device’s link partner. Applies to all ports on a device. The following are permissible values: Value Meaning 0000H Zero 0001H Less than 1 µs 0002H Less than 2 µs 0003H Less than 3 µs 0004H Less than 4 µs … … 07FFH Less than 2047 µs 0800H – Reserved FFFFH For a hub, this is the value for both its upstream and downstream ports. |
USB 3.1/USB 3.2 Device Capability Descriptor : SuperSpeed Device Capability Descriptor
Offset | Field | Size | Value | Description |
---|---|---|---|---|
0 | bLength | 1 | Number | Size of descriptor |
1 | bDescriptorType | 1 | Constant | DEVICE CAPABILITY Descriptor type |
2 | bDevCapabilityType | 1 | Constant | Capability type: SUPERSPEED_USB |
3 | bmAttributes | 1 | Bitmap | Bitmap encoding of supported device level features. A value of one in a bit location indicates a feature is supported; a value of zero indicates it is not supported. Encodings are: Bit Encoding 0 Reserved. Shall be set to zero. 1 LTM Capable. A value of one in this bit location indicates that this device has is capable of generating Latency Tolerance Messages. 7:2 Reserved. Shall be set to zero. |
4 | wSpeedsSupported | 2 | Bitmap | Bitmap encoding of the speed supported by this device. Bit Encoding 0 If this bit is set, then the device supports operation at low-Speed USB. 1 If this bit is set, then the device supports operation at full-Speed USB. 2 If this bit is set, then the device supports operation at high-Speed USB. 3 If this bit is set, then the device supports operation at Gen 1 speed. 15:4 Reserved. Shall be set to zero. |
6 | bFunctionalitySupport | 1 | Number | The lowest speed at which all the functionality supported by the device is available to the user. For example if the device supports all its functionality when connected at full speed and above then it sets this value to 1. Refer to the wSpeedsSupported field for valid values that can be placed in this field. |
7 | bU1DevExitLat | 1 | Number | U1 Device Exit Latency. Worst case latency to transition from U1 to U0, assuming the latency is limited only by the device and not the device’s link partner. This field applies only to the exit latency associated with an individual port, and does not apply to the total latency through a hub (e.g., from downstream port to upstream port). The following are permissible values: Value Meaning 00H Zero. 01H Less than 1 µs 02H Less than 2 µs 03H Less than 3 µs 04H Less than 4 µs … … 0AH Less than 10 µs 0BH – Reserved FFH For a hub, this is the value for both its upstream and downstream ports. |
8 | wU2DevExitLat | 2 | Number | U2 Device Exit Latency. Worst case latency to transition from U2 to U0, assuming the latency is limited only by the device and not the device’s link partner. Applies to all ports on a device. The following are permissible values: Value Meaning 0000H Zero 0001H Less than 1 µs 0002H Less than 2 µs 0003H Less than 3 µs 0004H Less than 4 µs … … 07FFH Less than 2047 µs 0800H – Reserved FFFFH For a hub, this is the value for both its upstream and downstream ports. |
[参考资料]
Universal Serial Bus 3.0 Specification
Universal Serial Bus 3.1 Specification
Universal Serial Bus 3.2 Specification
USB Complete, 5th Edition
USB开发大全
本文链接:https://blog.csdn.net/u012028275/article/details/110307047