Skip to contentSkip to conversation

USB: Add support to store lane count used by USB 3.2

PATCH New Mathias Nyman 1 participant 1 message Mar 13, 2018 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 USB: Add support to store lane count used by USB 3.2

USB 3.2 specification adds Dual-lane support, doubling the maximum SuperSpeedPlus data rate from 10Gbps to 20Gbps.

Dual-lane takes into use a second set of rx and tx wires/pins in the Type-C cable and connector.

Add a "lanes" variable to struct usb_device to store the numer of lanes in use. Number of lanes can be read using the extended port status hub request that was introduced in USB 3.1.

Extended port status rx and tx lane count are zero based, maximum lanes supported by usb 3.2 is 2 (dual lane).
If extended port status is not available then default to one lane.

---
 drivers/usb/core/hub.c | 6 ++++++
 include/linux/usb.h    | 2 ++
 2 files changed, 8 insertions(+)
drivers/usb/core/hub.c +6 -0
index c5c1f6c..853516d 100644
@@ -2742,6 +2742,12 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1,
 	if (!udev)
 		return 0;
 
+	if (hub_is_superspeedplus(hub->hdev))
+		udev->lanes = ((ext_portstatus &
+				USB_EXT_PORT_STAT_RX_LANES) >> 8) + 1;
+	else
+		udev->lanes = 1;
+
 	if (hub_is_wusb(hub))
 		udev->speed = USB_SPEED_WIRELESS;
 	else if (hub_is_superspeedplus(hub->hdev) &&
include/linux/usb.h +2 -0
index 0173597..0df5acc 100644
@@ -551,6 +551,7 @@ struct usb3_lpm_parameters {
  * @route: tree topology hex string for use with xHCI
  * @state: device state: configured, not attached, etc.
  * @speed: device speed: high/full/low (or error)
+ * @lanes: number of lanes in use, USB 3.2 adds dual-lane support
  * @tt: Transaction Translator info; used with low/full speed dev, highspeed hub
  * @ttport: device port on that tt hub
  * @toggle: one bit for each endpoint, with ([0] = IN, [1] = OUT) endpoints
@@ -624,6 +625,7 @@ struct usb_device {
 	u32		route;
 	enum usb_device_state	state;
 	enum usb_device_speed	speed;
+	unsigned int		lanes;
 
 	struct usb_tt	*tt;
 	int		ttport;