f541a3a83bd3165c1311af759a14e05ac6294d6a
[pandora-kernel.git] / drivers / staging / usbip / stub.h
1 /*
2  * Copyright (C) 2003-2008 Takahiro Hirofuchi
3  *
4  * This is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17  * USA.
18  */
19
20 #include <linux/kernel.h>
21 #include <linux/list.h>
22 #include <linux/spinlock.h>
23 #include <linux/slab.h>
24 #include <linux/string.h>
25 #include <linux/module.h>
26 #include <linux/net.h>
27
28 struct stub_device {
29         struct usb_interface *interface;
30         struct list_head list;
31
32         struct usbip_device ud;
33         __u32 devid;
34
35         /*
36          * stub_priv preserves private data of each urb.
37          * It is allocated as stub_priv_cache and assigned to urb->context.
38          *
39          * stub_priv is always linked to any one of 3 lists;
40          *      priv_init: linked to this until the comletion of a urb.
41          *      priv_tx  : linked to this after the completion of a urb.
42          *      priv_free: linked to this after the sending of the result.
43          *
44          * Any of these list operations should be locked by priv_lock.
45          */
46         spinlock_t priv_lock;
47         struct list_head priv_init;
48         struct list_head priv_tx;
49         struct list_head priv_free;
50
51         /* see comments for unlinking in stub_rx.c */
52         struct list_head unlink_tx;
53         struct list_head unlink_free;
54
55
56         wait_queue_head_t tx_waitq;
57 };
58
59 /* private data into urb->priv */
60 struct stub_priv {
61         unsigned long seqnum;
62         struct list_head list;
63         struct stub_device *sdev;
64         struct urb *urb;
65
66         int unlinking;
67 };
68
69 struct stub_unlink {
70         unsigned long seqnum;
71         struct list_head list;
72         __u32 status;
73 };
74
75
76 extern struct kmem_cache *stub_priv_cache;
77
78
79 /*-------------------------------------------------------------------------*/
80 /* prototype declarations */
81
82 /* stub_tx.c */
83 void stub_complete(struct urb *);
84 void stub_tx_loop(struct usbip_task *);
85
86 /* stub_dev.c */
87 extern struct usb_driver stub_driver;
88
89 /* stub_rx.c */
90 void stub_rx_loop(struct usbip_task *);
91 void stub_enqueue_ret_unlink(struct stub_device *, __u32, __u32);
92
93 /* stub_main.c */
94 int match_busid(char *busid);
95 void stub_device_cleanup_urbs(struct stub_device *sdev);