1<html><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.78.1"><link rel="home" href="index.html" title="USB Gadget API for Linux"><link rel="up" href="core.html" title="Core Objects and Methods"><link rel="prev" href="core.html" title="Core Objects and Methods"><link rel="next" href="API-struct-usb-ep.html" title="struct usb_ep"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">struct usb_request</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="core.html">Prev</a>&#160;</td><th width="60%" align="center">Core Objects and Methods</th><td width="20%" align="right">&#160;<a accesskey="n" href="API-struct-usb-ep.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-struct-usb-request"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct usb_request &#8212; 
2  describes one i/o request
3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="programlisting">
4struct usb_request {
5  void * buf;
6  unsigned length;
7  dma_addr_t dma;
8  struct scatterlist * sg;
9  unsigned num_sgs;
10  unsigned num_mapped_sgs;
11  unsigned stream_id:16;
12  unsigned no_interrupt:1;
13  unsigned zero:1;
14  unsigned short_not_ok:1;
15  void (* complete) (struct usb_ep *ep,struct usb_request *req);
16  void * context;
17  struct list_head list;
18  int status;
19  unsigned actual;
20};  </pre></div><div class="refsect1"><a name="idp1121049580"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">buf</span></dt><dd><p>
21Buffer used for data.  Always provide this; some controllers
22only use PIO, or don't use DMA for some endpoints.
23      </p></dd><dt><span class="term">length</span></dt><dd><p>
24Length of that data
25      </p></dd><dt><span class="term">dma</span></dt><dd><p>
26DMA address corresponding to 'buf'.  If you don't set this
27field, and the usb controller needs one, it is responsible
28for mapping and unmapping the buffer.
29      </p></dd><dt><span class="term">sg</span></dt><dd><p>
30a scatterlist for SG-capable controllers.
31      </p></dd><dt><span class="term">num_sgs</span></dt><dd><p>
32number of SG entries
33      </p></dd><dt><span class="term">num_mapped_sgs</span></dt><dd><p>
34number of SG entries mapped to DMA (internal)
35      </p></dd><dt><span class="term">stream_id</span></dt><dd><p>
36The stream id, when USB3.0 bulk streams are being used
37      </p></dd><dt><span class="term">no_interrupt</span></dt><dd><p>
38If true, hints that no completion irq is needed.
39Helpful sometimes with deep request queues that are handled
40directly by DMA controllers.
41      </p></dd><dt><span class="term">zero</span></dt><dd><p>
42If true, when writing data, makes the last packet be <span class="quote">&#8220;<span class="quote">short</span>&#8221;</span>
43by adding a zero length packet as needed;
44      </p></dd><dt><span class="term">short_not_ok</span></dt><dd><p>
45When reading data, makes short packets be
46treated as errors (queue stops advancing till cleanup).
47      </p></dd><dt><span class="term">complete</span></dt><dd><p>
48Function called when request completes, so this request and
49its buffer may be re-used.  The function will always be called with
50interrupts disabled, and it must not sleep.
51Reads terminate with a short packet, or when the buffer fills,
52whichever comes first.  When writes terminate, some data bytes
53will usually still be in flight (often in a hardware fifo).
54Errors (for reads or writes) stop the queue from advancing
55until the completion function returns, so that any transfers
56invalidated by the error may first be dequeued.
57      </p></dd><dt><span class="term">context</span></dt><dd><p>
58For use by the completion callback
59      </p></dd><dt><span class="term">list</span></dt><dd><p>
60For use by the gadget driver.
61      </p></dd><dt><span class="term">status</span></dt><dd><p>
62Reports completion code, zero or a negative errno.
63Normally, faults block the transfer queue from advancing until
64the completion callback returns.
65Code <span class="quote">&#8220;<span class="quote">-ESHUTDOWN</span>&#8221;</span> indicates completion caused by device disconnect,
66or when the driver disabled the endpoint.
67      </p></dd><dt><span class="term">actual</span></dt><dd><p>
68Reports bytes transferred to/from the buffer.  For reads (OUT
69transfers) this may be less than the requested length.  If the
70short_not_ok flag is set, short reads are treated as errors
71even when status otherwise indicates successful completion.
72Note that for writes (IN transfers) some data bytes may still
73reside in a device-side FIFO when the request is reported as
74complete.
75      </p></dd></dl></div></div><div class="refsect1"><a name="idp1123935988"></a><h2>Description</h2><p>
76   These are allocated/freed through the endpoint they're used with.  The
77   hardware's driver can add extra per-request data to the memory it returns,
78   which often avoids separate memory allocations (potential failures),
79   later when the request is queued.
80   </p><p>
81
82   Request flags affect request handling, such as whether a zero length
83   packet is written (the <span class="quote">&#8220;<span class="quote">zero</span>&#8221;</span> flag), whether a short read should be
84   treated as an error (blocking request queue advance, the <span class="quote">&#8220;<span class="quote">short_not_ok</span>&#8221;</span>
85   flag), or hinting that an interrupt is not required (the <span class="quote">&#8220;<span class="quote">no_interrupt</span>&#8221;</span>
86   flag, for use with deep request queues).
87   </p><p>
88
89   Bulk endpoints can use any size buffers, and can also be used for interrupt
90   transfers. interrupt-only endpoints can be much less functional.
91</p></div><div class="refsect1"><a name="idp1123938172"></a><h2>NOTE</h2><p>
92   this is analogous to 'struct urb' on the host side, except that
93   it's thinner and promotes more pre-allocation.
94</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="core.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="core.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="API-struct-usb-ep.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Core Objects and Methods&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span class="phrase">struct usb_ep</span></td></tr></table></div></body></html>
95