Date: Tue, 22 Mar 2022 14:05:19 -0400 From: "Farhan Khan" <farhan@farhan.codes> To: freebsd-usb@freebsd.org Subject: Understanding USB callback events and sequence Message-ID: <57ff6d47-79b3-4409-b804-108fe7d62e9d@www.fastmail.com>
next in thread | raw e-mail | index | archive | help
--5950a9e3350143c090d056536e154453 Content-Type: text/plain Hi all, I am trying to understand how the structure of the USB callback and have a few questions. The relevant manual page is usbdi(9). The manual talks about the 3 states of the callback: USB_ST_SETUP, USB_ST_TRANSFERRED, and default (error). I am not clear on the difference between USB_ST_SETUP and USB_ST_TRANSFERRED. The manual seems to suggest that USB_ST_SETUP is where the USB packet is sent, which leads me to think USB_ST_TRANSFERRED is cleanup? From looking at examples, this appears to be how thinks are done. What triggers the event? From testing, it seems that usbd_transfer_start(9) triggers the callback with USB_ST_SETUP. If so, what triggers USB_ST_TRANSFERRED. Why is it necessary? Also, when I read examples I see that in some places the expected `break` in the `select` is removed with a note saying "fall through". Wouldn't this double-send the USB packet, or at least sent another packet during the USB_ST_TRANSFERRED stage? For example here: https://github.com/freebsd/freebsd-src/blob/9a6695532b3997e4e2bc3fe57481cc49be5e9e93/sys/dev/usb/wlan/if_rsu.c#L2671 Finally, I have been looking at USB traffic under wireshark (interpreted from usbdump -w file.pcap) and I see that every USB packet has a response from the device. Is this response packet handled by one of the RX callbacks? Or is this the same as TX's USB_ST_TRANSFERRED? Thank you and pardon the multiple questions! -- Farhan Khan PGP Fingerprint: 1312 89CE 663E 1EB2 179C 1C83 C41D 2281 F8DA C0DE --5950a9e3350143c090d056536e154453 Content-Type: text/html Content-Transfer-Encoding: quoted-printable <!DOCTYPE html><html><head><title></title><style type=3D"text/css">p.MsoNor= mal,p.MsoNoSpacing{margin:0}</style></head><body><div>Hi all,<br></div><div= ><br></div><div>I am trying to understand how the structure of the USB call= back and have a few questions. The relevant manual page is usbdi(9).<br></d= iv><div><br></div><div>The manual talks about the 3 states of the callback:= USB_ST_SETUP, USB_ST_TRANSFERRED, and default (error). I am= not clear on the difference between USB_ST_SETUP and USB_ST_TRAN= SFERRED. The manual seems to suggest that USB_ST_SETUP is where the USB pac= ket is sent, which leads me to think USB_ST_TRANSFERRED is cleanup? From lo= oking at examples, this appears to be how thinks are done.<br></div><div><b= r></div><div>What triggers the event? From testing, it seems that usbd_tran= sfer_start(9) triggers the callback with USB_ST_SETUP. If so, what triggers= USB_ST_TRANSFERRED. Why is it necessary?</div><div><br></div><div>Als= o, when I read examples I see that in some places the expected `break` in t= he `select` is removed with a note saying "fall through". Wouldn't this dou= ble-send the USB packet, or at least sent another packet during the US= B_ST_TRANSFERRED stage? For example here:<br></div><div><a href=3D"https://= github.com/freebsd/freebsd-src/blob/9a6695532b3997e4e2bc3fe57481cc49be5e9e9= 3/sys/dev/usb/wlan/if_rsu.c#L2671">https://github.com/freebsd/freebsd-src/b= lob/9a6695532b3997e4e2bc3fe57481cc49be5e9e93/sys/dev/usb/wlan/if_rsu.c#L267= 1</a></div><div><br></div><div>Finally, I have been looking at USB traffic = under wireshark (interpreted from usbdump -w file.pcap) and I see that ever= y USB packet has a response from the device. Is this response packet h= andled by one of the RX callbacks? Or is this the same as TX's USB_ST_= TRANSFERRED?</div><div><br></div><div>Thank you and pardon the multiple que= stions!</div><div><br></div><div id=3D"sig100029512"><div class=3D"signatur= e">--<br></div><div class=3D"signature">Farhan Khan<br></div><div class=3D"= signature">PGP Fingerprint: 1312 89CE 663E 1EB2 179C 1C83 C41D 2281 F8DA C0= DE<br></div></div><div><br></div><pre style=3D"white-space: pre-wrap"></pre= ></body></html> --5950a9e3350143c090d056536e154453--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?57ff6d47-79b3-4409-b804-108fe7d62e9d>