summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorMichael Brown2015-02-12 16:14:04 +0100
committerMichael Brown2015-02-13 02:10:51 +0100
commit17fc79425ef27f508cf8527c2adf160cef1888c8 (patch)
treeaa05c85ced9448237b52c3c5c44cb0ffbbc83199 /src/include
parent[build] Apply the "-fno-PIE -nopie" workaround only to i386 builds (diff)
downloadipxe-17fc79425ef27f508cf8527c2adf160cef1888c8.tar.gz
ipxe-17fc79425ef27f508cf8527c2adf160cef1888c8.tar.xz
ipxe-17fc79425ef27f508cf8527c2adf160cef1888c8.zip
[usb] Provide generic framework for refilling receive endpoints
Provide a generic framework for allocating, refilling, and optionally recycling I/O buffers used by bulk IN and interrupt endpoints. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/ipxe/usb.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/include/ipxe/usb.h b/src/include/ipxe/usb.h
index 8e182416..63358024 100644
--- a/src/include/ipxe/usb.h
+++ b/src/include/ipxe/usb.h
@@ -379,6 +379,8 @@ struct usb_endpoint {
int open;
/** Current failure state (if any) */
int rc;
+ /** Buffer fill level */
+ unsigned int fill;
/** Host controller operations */
struct usb_endpoint_host_operations *host;
@@ -386,6 +388,13 @@ struct usb_endpoint {
void *priv;
/** Driver operations */
struct usb_endpoint_driver_operations *driver;
+
+ /** Recycled I/O buffer list */
+ struct list_head recycled;
+ /** Refill buffer length */
+ size_t len;
+ /** Maximum fill level */
+ unsigned int max;
};
/** USB endpoint host controller operations */
@@ -554,6 +563,37 @@ extern void usb_complete_err ( struct usb_endpoint *ep,
struct io_buffer *iobuf, int rc );
/**
+ * Initialise USB endpoint refill
+ *
+ * @v ep USB endpoint
+ * @v len Refill buffer length (or zero to use endpoint's MTU)
+ * @v max Maximum fill level
+ */
+static inline __attribute__ (( always_inline )) void
+usb_refill_init ( struct usb_endpoint *ep, size_t len, unsigned int max ) {
+
+ INIT_LIST_HEAD ( &ep->recycled );
+ ep->len = len;
+ ep->max = max;
+}
+
+/**
+ * Recycle I/O buffer
+ *
+ * @v ep USB endpoint
+ * @v iobuf I/O buffer
+ */
+static inline __attribute__ (( always_inline )) void
+usb_recycle ( struct usb_endpoint *ep, struct io_buffer *iobuf ) {
+
+ list_add_tail ( &iobuf->list, &ep->recycled );
+}
+
+extern int usb_prefill ( struct usb_endpoint *ep );
+extern int usb_refill ( struct usb_endpoint *ep );
+extern void usb_flush ( struct usb_endpoint *ep );
+
+/**
* A USB function
*
* A USB function represents an association of interfaces within a USB