From: Lorenzo Colitti <lorenzo@google.com>
To: linux-usb@vger.kernel.org
Cc: balbi@kernel.org, gregkh@linuxfoundation.org,
zenczykowski@gmail.com, Lorenzo Colitti <lorenzo@google.com>
Subject: [PATCH v3 1/3] usb: gadget: f_ncm: fix ncm_bitrate for SuperSpeed and above.
Date: Tue, 25 Aug 2020 14:55:03 +0900 [thread overview]
Message-ID: <20200825055505.765782-2-lorenzo@google.com> (raw)
In-Reply-To: <20200825055505.765782-1-lorenzo@google.com>
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: 1650113888fe ("usb: gadget: f_ncm: add SuperSpeed descriptors for CDC NCM")
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
---
drivers/usb/gadget/function/f_ncm.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
index 1d900081b1..5b9266a87f 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -85,8 +85,10 @@ static inline struct f_ncm *func_to_ncm(struct usb_function *f)
/* peak (theoretical) bulk transfer rate in bits-per-second */
static inline unsigned ncm_bitrate(struct usb_gadget *g)
{
- if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER)
- return 13 * 1024 * 8 * 1000 * 8;
+ if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER_PLUS)
+ return 4250000000U;
+ else if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER)
+ return 3750000000U;
else if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
return 13 * 512 * 8 * 1000 * 8;
else
--
2.28.0.297.g1956fa8f8d-goog
next prev parent reply other threads:[~2020-08-25 5:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-25 5:55 [PATCH v3 0/3] usb: gadget: f_ncm: support SuperSpeed Plus, improve on SuperSpeed Lorenzo Colitti
2020-08-25 5:55 ` Lorenzo Colitti [this message]
2020-08-25 21:16 ` [PATCH v3 1/3] usb: gadget: f_ncm: fix ncm_bitrate for SuperSpeed and above Maciej Żenczykowski
2020-09-29 2:52 ` Sid Spry
2020-09-29 4:29 ` Lorenzo Colitti
2020-09-29 5:53 ` Maciej Żenczykowski
2020-08-25 5:55 ` [PATCH v3 2/3] usb: gadget: f_ncm: set SuperSpeed bulk descriptor bMaxBurst to 15 Lorenzo Colitti
2020-08-25 5:55 ` [PATCH v3 3/3] usb: gadget: f_ncm: allow using NCM in SuperSpeed Plus gadgets Lorenzo Colitti
2020-08-25 21:17 ` Maciej Żenczykowski
2020-09-09 10:40 ` [PATCH v3 0/3] usb: gadget: f_ncm: support SuperSpeed Plus, improve on SuperSpeed Greg KH
2020-09-24 7:28 ` Felipe Balbi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200825055505.765782-2-lorenzo@google.com \
--to=lorenzo@google.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=zenczykowski@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).