<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>struct usb_request</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="USB Gadget API for Linux" /><link rel="up" href="ch03s03.html" title="Core Objects and Methods" /><link rel="prev" href="ch03s03.html" title="Core Objects and Methods" /><link rel="next" href="re17.html" title="struct usb_ep" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span>struct usb_request</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03s03.html">Prev</a> </td><th width="60%" align="center">Core Objects and Methods</th><td width="20%" align="right"> <a accesskey="n" href="re17.html">Next</a></td></tr></table><hr /></div><div class="refentry" title="struct usb_request"><a id="API-struct-usb-request"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct usb_request — describes one i/o request </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><pre class="programlisting"> struct usb_request { void * buf; unsigned length; dma_addr_t dma; unsigned no_interrupt:1; unsigned zero:1; unsigned short_not_ok:1; void (* complete) (struct usb_ep *ep,struct usb_request *req); void * context; struct list_head list; int status; unsigned actual; }; </pre></div><div class="refsect1" title="Members"><a id="id2992184"></a><h2>Members</h2><div class="variablelist"><dl><dt><span class="term">buf</span></dt><dd><p> Buffer used for data. Always provide this; some controllers only use PIO, or don't use DMA for some endpoints. </p></dd><dt><span class="term">length</span></dt><dd><p> Length of that data </p></dd><dt><span class="term">dma</span></dt><dd><p> DMA address corresponding to 'buf'. If you don't set this field, and the usb controller needs one, it is responsible for mapping and unmapping the buffer. </p></dd><dt><span class="term">no_interrupt</span></dt><dd><p> If true, hints that no completion irq is needed. Helpful sometimes with deep request queues that are handled directly by DMA controllers. </p></dd><dt><span class="term">zero</span></dt><dd><p> If true, when writing data, makes the last packet be <span class="quote">“<span class="quote">short</span>”</span> by adding a zero length packet as needed; </p></dd><dt><span class="term">short_not_ok</span></dt><dd><p> When reading data, makes short packets be treated as errors (queue stops advancing till cleanup). </p></dd><dt><span class="term">complete</span></dt><dd><p> Function called when request completes, so this request and its buffer may be re-used. The function will always be called with interrupts disabled, and it must not sleep. Reads terminate with a short packet, or when the buffer fills, whichever comes first. When writes terminate, some data bytes will usually still be in flight (often in a hardware fifo). Errors (for reads or writes) stop the queue from advancing until the completion function returns, so that any transfers invalidated by the error may first be dequeued. </p></dd><dt><span class="term">context</span></dt><dd><p> For use by the completion callback </p></dd><dt><span class="term">list</span></dt><dd><p> For use by the gadget driver. </p></dd><dt><span class="term">status</span></dt><dd><p> Reports completion code, zero or a negative errno. Normally, faults block the transfer queue from advancing until the completion callback returns. Code <span class="quote">“<span class="quote">-ESHUTDOWN</span>”</span> indicates completion caused by device disconnect, or when the driver disabled the endpoint. </p></dd><dt><span class="term">actual</span></dt><dd><p> Reports bytes transferred to/from the buffer. For reads (OUT transfers) this may be less than the requested length. If the short_not_ok flag is set, short reads are treated as errors even when status otherwise indicates successful completion. Note that for writes (IN transfers) some data bytes may still reside in a device-side FIFO when the request is reported as complete. </p></dd></dl></div></div><div class="refsect1" title="Description"><a id="id2992351"></a><h2>Description</h2><p> These are allocated/freed through the endpoint they're used with. The hardware's driver can add extra per-request data to the memory it returns, which often avoids separate memory allocations (potential failures), later when the request is queued. </p><p> Request flags affect request handling, such as whether a zero length packet is written (the <span class="quote">“<span class="quote">zero</span>”</span> flag), whether a short read should be treated as an error (blocking request queue advance, the <span class="quote">“<span class="quote">short_not_ok</span>”</span> flag), or hinting that an interrupt is not required (the <span class="quote">“<span class="quote">no_interrupt</span>”</span> flag, for use with deep request queues). </p><p> Bulk endpoints can use any size buffers, and can also be used for interrupt transfers. interrupt-only endpoints can be much less functional. </p></div><div class="refsect1" title="NOTE"><a id="id2992388"></a><h2>NOTE</h2><p> this is analagous to 'struct urb' on the host side, except that it's thinner and promotes more pre-allocation. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03s03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch03s03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="re17.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Core Objects and Methods </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span>struct usb_ep</span></td></tr></table></div></body></html>