# @name USB I/O Controller throughput performance test
# @desc Perform Bulk OUT and IN throughput tests
# @requires usb/host

# Needs a specific test USB gadget connected to the host controller (e.g. Gadget zero)
# For a complete list of compatible devices, see
# http://lxr.free-electrons.com/source/drivers/usb/misc/usbtest.c#L2440

# Hint: Unload host and gadget drivers, load them with appropriate parameters, wait for 2 seconds for enumeration and then run test.
# NOTE: The USB Host and device port must be connected to each other before running these tests

USB_L_PERF_BULK_OUT source 'common.sh' ; do_cmd install_modules.sh 'usb'; check_config_options "m" CONFIG_USB_TEST; check_config_options "m" CONFIG_USB_ZERO; do_cmd modprobe -r g_zero; do_cmd modprobe -r usbtest; do_cmd modprobe usbtest pattern=2; do_cmd modprobe g_zero pattern=2 buflen=16384; do_cmd sleep 2;  do_cmd usb_test.sh -t out-perf

USB_L_PERF_BULK_IN source 'common.sh' ; do_cmd install_modules.sh 'usb'; check_config_options "m" CONFIG_USB_TEST; check_config_options "m" CONFIG_USB_ZERO; do_cmd modprobe -r g_zero; do_cmd modprobe -r usbtest; do_cmd modprobe usbtest pattern=2; do_cmd modprobe g_zero pattern=2 buflen=16384; do_cmd sleep 2;  do_cmd usb_test.sh -t in-perf

USB_L_PERF_ISO_OUT source 'common.sh' ; do_cmd install_modules.sh 'usb'; check_config_options "m" CONFIG_USB_TEST; check_config_options "m" CONFIG_USB_ZERO; do_cmd modprobe -r g_zero; do_cmd modprobe -r usbtest; do_cmd modprobe usbtest pattern=2 alt=1; do_cmd modprobe g_zero pattern=2 buflen=16384 isoc_interval=1 isoc_maxpacket=960 isoc_mult=2 isoc_maxburst=15; do_cmd sleep 2;  do_cmd usb_test.sh -t iso-out-perf

USB_L_PERF_ISO_IN source 'common.sh' ; do_cmd install_modules.sh 'usb'; check_config_options "m" CONFIG_USB_TEST; check_config_options "m" CONFIG_USB_ZERO; do_cmd modprobe -r g_zero; do_cmd modprobe -r usbtest; do_cmd modprobe usbtest pattern=2 alt=1; do_cmd modprobe g_zero pattern=2 buflen=16384 isoc_interval=1 isoc_maxpacket=960 isoc_mult=2 isoc_maxburst=15; do_cmd sleep 2;  do_cmd usb_test.sh -t iso-in-perf

