linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [1/2] USB: Add support to store lane count used by USB 3.2
@ 2018-03-13 15:27 Mathias Nyman
  0 siblings, 0 replies; 3+ messages in thread
From: Mathias Nyman @ 2018-03-13 15:27 UTC (permalink / raw)
  To: gregkh; +Cc: stern, linux-usb, Mathias Nyman

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.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
 drivers/usb/core/hub.c | 6 ++++++
 include/linux/usb.h    | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index c5c1f6c..853516d 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -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) &&
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 0173597..0df5acc 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -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;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [1/2] USB: Add support to store lane count used by USB 3.2
@ 2018-03-13 15:29 Felipe Balbi
  0 siblings, 0 replies; 3+ messages in thread
From: Felipe Balbi @ 2018-03-13 15:29 UTC (permalink / raw)
  To: Mathias Nyman, gregkh; +Cc: stern, linux-usb

Hi,

Mathias Nyman <mathias.nyman@linux.intel.com> writes:

> 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.
>
> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
> ---
>  drivers/usb/core/hub.c | 6 ++++++
>  include/linux/usb.h    | 2 ++
>  2 files changed, 8 insertions(+)
>
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index c5c1f6c..853516d 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -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;

should this be udev->rx_lanes instead? We have macros for both TX and RX
lanes:

#define USB_EXT_PORT_STAT_RX_SPEED_ID	0x0000000f
#define USB_EXT_PORT_STAT_TX_SPEED_ID	0x000000f0
#define USB_EXT_PORT_STAT_RX_LANES	0x00000f00
#define USB_EXT_PORT_STAT_TX_LANES	0x0000f000

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [1/2] USB: Add support to store lane count used by USB 3.2
@ 2018-03-13 15:53 Mathias Nyman
  0 siblings, 0 replies; 3+ messages in thread
From: Mathias Nyman @ 2018-03-13 15:53 UTC (permalink / raw)
  To: Felipe Balbi, gregkh; +Cc: stern, linux-usb

On 13.03.2018 17:29, Felipe Balbi wrote:
> 
> Hi,
> 
> Mathias Nyman <mathias.nyman@linux.intel.com> writes:
> 
>> 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.
>>
>> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
>> ---
>>   drivers/usb/core/hub.c | 6 ++++++
>>   include/linux/usb.h    | 2 ++
>>   2 files changed, 8 insertions(+)
>>
>> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
>> index c5c1f6c..853516d 100644
>> --- a/drivers/usb/core/hub.c
>> +++ b/drivers/usb/core/hub.c
>> @@ -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;
> 
> should this be udev->rx_lanes instead? We have macros for both TX and RX
> lanes:
> 
> #define USB_EXT_PORT_STAT_RX_SPEED_ID	0x0000000f
> #define USB_EXT_PORT_STAT_TX_SPEED_ID	0x000000f0
> #define USB_EXT_PORT_STAT_RX_LANES	0x00000f00
> #define USB_EXT_PORT_STAT_TX_LANES	0x0000f000
> 

This is one part of the discussion, For non-SSIC devices, the lane count is
symmetric so rx_lanes = tx_lanes.
The USB 3.2 Gen XxY notion seems to only cover symmetric lane counts as
the "Y" part describes one generic "lane count".

See USB 3.2 section 8.5.6.7:
"Asymmetric Lane Types may only be reported by SuperSpeed Interchip (SSIC) devices. A
Symmetric link is one that has the same Lane Speed and number of lanes for both the Rx and
Tx Sublinks. Enhanced SuperSpeed devices shall only support Symmetric links."

and definition on Gen XxY in section 2. Terms and abbreviations

"X refers to the rate of signaling on the wire (Gen 1, Gen 2, etc.) and Y refers to
the number of lanes."

-Mathias
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-03-13 15:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-13 15:53 [1/2] USB: Add support to store lane count used by USB 3.2 Mathias Nyman
  -- strict thread matches above, loose matches on Subject: below --
2018-03-13 15:29 Felipe Balbi
2018-03-13 15:27 Mathias Nyman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).