Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set maximum captured packet size to 1027 #56

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

desowin
Copy link
Contributor

@desowin desowin commented Jan 9, 2023

Report untruncated packet size to host

Do not immediately proceed to writing header when packet larger than MAX_PACKET_SIZE is captured on the bus. Keep counting packet length so the value can be reported to the host.

When Truncated flag is set the size reported in header is untruncated packet size and only MAX_PACKET_SIZE bytes are included. In order to not increase header size, and thus limit the maximum capture throughput, the MAX_PACKET_SIZE value must match between gateware and host.

Because change modifies gateware to host software protocol and hence is backwards incompatible. I believe the gateware should be considered integral part of software package and therefore I do not consider this protocol incompatibility to be a problem, especially that the gateware is only loaded to volatile memory.

Reporting actual length as seen on the bus allows USBInterpreter to display for example "Truncated 2 bytes" instead of "Unexpected ERR CRC". Similarly, when exporting to pcap format, Wireshark can display "[Packet size limited during capture]" instead of reporting CRC errors.

USB 2.0 maximum possible packet size is 1027. The packet is 1027 bytes when wMaxPacketSize is 1024 (interrupt or isochronous high-speed) and 1024 bytes are transferred in single transaction (1 byte PID + 1024 bytes data + 2 bytes CRC).

Fixes: #29

GitHub switched off git protocol on March 15, 2022.
Add new prebuilt ov3.fwpkg generated with Xilinx ISE 14.7.

Gateware make test target is no longer working at least since commit
e6f25c4 ("Initial update to current migen") where Migen was updated
to version no longer containing old simulator. Icarus, needed by ov3
gateware tests was removed in Migen commit f1dc008d324d ("Simulator will
be rewritten"). Unfortunately, my very limited FHDL knowledge is not
enough to fix the tests.
Do not immediately proceed to writing header when packet larger than
MAX_PACKET_SIZE is captured on the bus. Keep counting packet length so
the value can be reported to the host.

When Truncated flag is set the size reported in header is untruncated
packet size and only MAX_PACKET_SIZE bytes are included. In order to not
increase header size, and thus limit the maximum capture throughput, the
MAX_PACKET_SIZE value must match between gateware and host.

Because change modifies gateware to host software protocol and hence is
backwards incompatible. I believe the gateware should be considered
integral part of software package and therefore I do not consider this
protocol incompatibility to be a problem, especially that the gateware
is only loaded to volatile memory.

Reporting actual length as seen on the bus allows USBInterpreter to
display for example "Truncated 2 bytes" instead of "Unexpected ERR CRC".
Similarly, when exporting to pcap format, Wireshark can display "[Packet
size limited during capture]" instead of reporting CRC errors.
USB 2.0 maximum possible packet size is 1027. The packet is 1027 bytes
when wMaxPacketSize is 1024 (interrupt or isochronous high-speed) and
1024 bytes are transferred in single transaction (1 byte PID + 1024
bytes data + 2 bytes CRC).
@tmbinc
Copy link
Collaborator

tmbinc commented Jan 9, 2023

This looks good to me, thank you!

Loss of the ability to test is unfortunate but I realize it would take significant effort to bring it back.

FYI - https://github.com/OpenVizslaTNG/ov_ftdi is now used for development. The same change should apply there.

@desowin
Copy link
Contributor Author

desowin commented Jan 10, 2023

Opened OpenVizslaTNG#14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Why MAX_PACKET_SIZE is set to 800?
2 participants