History

usb: usbtest: Add TEST 29, toggle sync, Clear toggle between bulk writes

Clear Feature Endpoint Halt should reset the data toggle even if the endpoint isn't halted. Host should manage to clear the host side data toggle to keep in sync with the device. Test by sending a "3 data packet URB" before and after clearing the halt. this should create a toggle sequence with two consecutive DATA0 packets. A successful test sequence looks like this ClearFeature(ENDPOINT_HALT) - initial toggle clear DATA0 (max packet sized) DATA1 (max packet sized) DATA0 (zero length packet) ClearFeature(ENDPOINT_HALT) - resets toggle DATA0 (max packet sized), if clear halt fails then toggle is DATA1 DATA1 (max packet sized) DATA0 (zero length packet)

Mathias Nyman committed 8 years ago

Commit cc2e60d1 parent 886ee361 file · +70 −0Browse files

Unified · Split

drivers/usb/misc/usbtest.c+70−0
@@ -1710,6 +1710,35 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb) · 1709 unmodified lines
17101710 return 0;
17111711 }
17121712
1713+static int test_toggle_sync(struct usbtest_dev *tdev, int ep, struct urb *urb)
1714+{
1715+ int retval;
1716+
1717+ /* clear initial data toggle to DATA0 */
1718+ retval = usb_clear_halt(urb->dev, urb->pipe);
1719+ if (retval < 0) {
1720+ ERROR(tdev, "ep %02x couldn't clear halt, %d\n", ep, retval);
1721+ return retval;
1722+ }
1723+
1724+ /* transfer 3 data packets, should be DATA0, DATA1, DATA0 */
1725+ retval = simple_io(tdev, urb, 1, 0, 0, __func__);
1726+ if (retval != 0)
1727+ return -EINVAL;
1728+
1729+ /* clear halt resets device side data toggle, host should react to it */
1730+ retval = usb_clear_halt(urb->dev, urb->pipe);
1731+ if (retval < 0) {
1732+ ERROR(tdev, "ep %02x couldn't clear halt, %d\n", ep, retval);
1733+ return retval;
1734+ }
1735+
1736+ /* host should use DATA0 again after clear halt */
1737+ retval = simple_io(tdev, urb, 1, 0, 0, __func__);
1738+
1739+ return retval;
1740+}
1741+
17131742 static int halt_simple(struct usbtest_dev *dev)
17141743 {
17151744 int ep;
@@ -1742,6 +1771,33 @@ done: · 26 unmodified lines
17421771 return retval;
17431772 }
17441773
1774+static int toggle_sync_simple(struct usbtest_dev *dev)
1775+{
1776+ int ep;
1777+ int retval = 0;
1778+ struct urb *urb;
1779+ struct usb_device *udev = testdev_to_usbdev(dev);
1780+ unsigned maxp = get_maxpacket(udev, dev->out_pipe);
1781+
1782+ /*
1783+ * Create a URB that causes a transfer of uneven amount of data packets
1784+ * This way the clear toggle has an impact on the data toggle sequence.
1785+ * Use 2 maxpacket length packets and one zero packet.
1786+ */
1787+ urb = simple_alloc_urb(udev, 0, 2 * maxp, 0);
1788+ if (urb == NULL)
1789+ return -ENOMEM;
1790+
1791+ urb->transfer_flags |= URB_ZERO_PACKET;
1792+
1793+ ep = usb_pipeendpoint(dev->out_pipe);
1794+ urb->pipe = dev->out_pipe;
1795+ retval = test_toggle_sync(dev, ep, urb);
1796+
1797+ simple_free_urb(urb);
1798+ return retval;
1799+}
1800+
17451801 /*-------------------------------------------------------------------------*/
17461802
17471803 /* Control OUT tests use the vendor control requests from Intel's
@@ -2524,6 +2580,20 @@ usbtest_do_ioctl(struct usb_interface *intf, struct usbtest_param_32 *param) · 776 unmodified lines
25242580 retval = test_queue(dev, param,
25252581 dev->in_pipe, NULL, 0);
25262582 break;
2583+ /* Test data Toggle/seq_nr clear between bulk out transfers */
2584+ case 29:
2585+ if (dev->out_pipe == 0)
2586+ break;
2587+ retval = 0;
2588+ dev_info(&intf->dev, "TEST 29: Clear toggle between bulk writes %d times\n",
2589+ param->iterations);
2590+ for (i = param->iterations; retval == 0 && i > 0; --i)
2591+ retval = toggle_sync_simple(dev);
2592+
2593+ if (retval)
2594+ ERROR(dev, "toggle sync failed, iterations left %d\n",
2595+ i);
2596+ break;
25272597 }
25282598 return retval;
25292599 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t