I've done no hard testing but have experimented with the USB gadgets.
The short answer is "it depends".
Now for the long answer:
The maximum theoretical bandwdith for data transfer using a Pi (whether in gadget mode or host mode on that port) is 480Mbps i.e. USB 2. Pi with USB 3 cannot use gadget mode on their USB 3 ports.
To get that, the Pi has to be the only device on that root port and the USB host has to be giving it enough CPU time to handle its end of things.
This is no different than any other USB device.
The Pi also has to be giving enough of its CPU time to handling its end of things.
Then it gets complicated...
The low level protocol is packet based. Packets should travel at the full speed negotiated by host and device but not necessarily often enough to hit the maximum speed - this is why the 3B+ can report it's connected to your ethernet switch/router at 1Gbps (it is, that's the link speed it negotiated) but you'll never actually see that level of through put as USB 2 can't keep up.
The ethernet gadget, for example, just sends packeets each way as and when permitted. It doesn't really simulate ethernet, just the API to the OS at each end and encapsulates ethernet frames into USB packets.
Same goes for the serial and other gadgets. And while I've never tried it, things like serial port baud rate shouldn't matter data to/from the host arrives when it arrives and gets shoved into a quere/buffer for the OS to handle at its leisure.
Total bandwidth on a root port cannot exceed the maximum the USB standard it supports and may be less depending on how the USB controller is connected to the CPU and RAM. For maximum bandwidth one active device per root port is the way to go and that assume that whatever you're doing to process the data isn't CPU bound.
And as with most data transfer things, speed/bandwidth is limited by the slowest link in the chain. It doesn't matter if you have the latest PCIe x4 NVMe drive if the only link between that computer and the other one is a 115K200 serial port.
One major caveat to the above: I am not an expert in the ins and outs of USB. The above is based on my limited understanding and experience of using it in prqactise.
One other factor, the dwc2 driver needed for gadget mode used to be a bit of a CPU hog due to how it handled interrups. That could hit overl performace on single core Pi models. I've no idea if that ever got fixed or not.
The short answer is "it depends".
Now for the long answer:
The maximum theoretical bandwdith for data transfer using a Pi (whether in gadget mode or host mode on that port) is 480Mbps i.e. USB 2. Pi with USB 3 cannot use gadget mode on their USB 3 ports.
To get that, the Pi has to be the only device on that root port and the USB host has to be giving it enough CPU time to handle its end of things.
This is no different than any other USB device.
The Pi also has to be giving enough of its CPU time to handling its end of things.
Then it gets complicated...
The low level protocol is packet based. Packets should travel at the full speed negotiated by host and device but not necessarily often enough to hit the maximum speed - this is why the 3B+ can report it's connected to your ethernet switch/router at 1Gbps (it is, that's the link speed it negotiated) but you'll never actually see that level of through put as USB 2 can't keep up.
The ethernet gadget, for example, just sends packeets each way as and when permitted. It doesn't really simulate ethernet, just the API to the OS at each end and encapsulates ethernet frames into USB packets.
Same goes for the serial and other gadgets. And while I've never tried it, things like serial port baud rate shouldn't matter data to/from the host arrives when it arrives and gets shoved into a quere/buffer for the OS to handle at its leisure.
Total bandwidth on a root port cannot exceed the maximum the USB standard it supports and may be less depending on how the USB controller is connected to the CPU and RAM. For maximum bandwidth one active device per root port is the way to go and that assume that whatever you're doing to process the data isn't CPU bound.
And as with most data transfer things, speed/bandwidth is limited by the slowest link in the chain. It doesn't matter if you have the latest PCIe x4 NVMe drive if the only link between that computer and the other one is a 115K200 serial port.
One major caveat to the above: I am not an expert in the ins and outs of USB. The above is based on my limited understanding and experience of using it in prqactise.
One other factor, the dwc2 driver needed for gadget mode used to be a bit of a CPU hog due to how it handled interrups. That could hit overl performace on single core Pi models. I've no idea if that ever got fixed or not.
Statistics: Posted by thagrol — Mon Apr 15, 2024 12:09 am