FROMLIST: usb: gadget: f_ncm: fix ncm_bitrate for SuperSpeed and above.
Currently, SuperSpeed NCM gadgets report a speed of 851 Mbps in USB_CDC_NOTIFY_SPEED_CHANGE. But the calculation appears to assume 16 packets per microframe, and USB 3 and above no longer use microframes. Maximum speed is actually much higher. On a direct connection, theoretical throughput is at most 3.86 Gbps for gen1x1 and 9.36 Gbps for gen2x1, and I have seen gadget->host iperf throughput of >2 Gbps for gen1x1 and >4 Gbps for gen2x1. Unfortunately the ConnectionSpeedChange defined in the CDC spec only uses 32-bit values, so we can't report accurate numbers for 10Gbps and above. So, report 3.75Gbps for SuperSpeed (which is roughly maximum theoretical performance) and 4.25Gbps for SuperSpeed Plus (which is close to the maximum that we can report in a 32-bit unsigned integer). This results in: [50879.191272] cdc_ncm 2-2:1.0 enx228b127e050c: renamed from usb0 [50879.234778] cdc_ncm 2-2:1.0 enx228b127e050c: 3750 mbit/s downlink 3750 mbit/s uplink on SuperSpeed and: [50798.434527] cdc_ncm 8-2:1.0 enx228b127e050c: renamed from usb0 [50798.524278] cdc_ncm 8-2:1.0 enx228b127e050c: 4250 mbit/s downlink 4250 mbit/s uplink on SuperSpeed Plus. Fixes: 16501138 ("usb: gadget: f_ncm: add SuperSpeed descriptors for CDC NCM") Signed-off-by:Lorenzo Colitti <lorenzo@google.com> Reviewed-by:
Maciej Żenczykowski <maze@google.com> Bug: 162298600 Link: https://lore.kernel.org/linux-usb/20200825055505.765782-2-lorenzo@google.com/ Signed-off-by:
Maciej Żenczykowski <maze@google.com> Change-Id: I87a44ff8d16569e97fc2ef2766f74704c5e19644 (cherry picked from commit d45abdced72953890cac29fcef0c1f233a221e3a) Signed-off-by:
Will McVicker <willmcvicker@google.com>
Loading
Please sign in to comment