Commit | Line | Data |
---|---|---|
4d7b5c7f TH |
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 | ||
4d7b5c7f | 20 | #include <linux/list.h> |
4d7b5c7f | 21 | #include <linux/slab.h> |
7aaacb43 | 22 | #include <linux/spinlock.h> |
23 | #include <linux/types.h> | |
24 | #include <linux/usb.h> | |
25 | #include <linux/wait.h> | |
4d7b5c7f | 26 | |
aa5873e9 EK |
27 | #define STUB_BUSID_OTHER 0 |
28 | #define STUB_BUSID_REMOV 1 | |
29 | #define STUB_BUSID_ADDED 2 | |
30 | #define STUB_BUSID_ALLOC 3 | |
31 | ||
4d7b5c7f TH |
32 | struct stub_device { |
33 | struct usb_interface *interface; | |
2d8f4595 | 34 | struct usb_device *udev; |
4d7b5c7f TH |
35 | struct list_head list; |
36 | ||
37 | struct usbip_device ud; | |
38 | __u32 devid; | |
39 | ||
40 | /* | |
41 | * stub_priv preserves private data of each urb. | |
42 | * It is allocated as stub_priv_cache and assigned to urb->context. | |
43 | * | |
44 | * stub_priv is always linked to any one of 3 lists; | |
45 | * priv_init: linked to this until the comletion of a urb. | |
46 | * priv_tx : linked to this after the completion of a urb. | |
47 | * priv_free: linked to this after the sending of the result. | |
48 | * | |
49 | * Any of these list operations should be locked by priv_lock. | |
50 | */ | |
51 | spinlock_t priv_lock; | |
52 | struct list_head priv_init; | |
53 | struct list_head priv_tx; | |
54 | struct list_head priv_free; | |
55 | ||
56 | /* see comments for unlinking in stub_rx.c */ | |
57 | struct list_head unlink_tx; | |
58 | struct list_head unlink_free; | |
59 | ||
4d7b5c7f TH |
60 | wait_queue_head_t tx_waitq; |
61 | }; | |
62 | ||
63 | /* private data into urb->priv */ | |
64 | struct stub_priv { | |
65 | unsigned long seqnum; | |
66 | struct list_head list; | |
67 | struct stub_device *sdev; | |
68 | struct urb *urb; | |
69 | ||
70 | int unlinking; | |
71 | }; | |
72 | ||
73 | struct stub_unlink { | |
74 | unsigned long seqnum; | |
75 | struct list_head list; | |
76 | __u32 status; | |
77 | }; | |
78 | ||
aa5873e9 | 79 | #define BUSID_SIZE 20 |
87352760 | 80 | |
aa5873e9 EK |
81 | struct bus_id_priv { |
82 | char name[BUSID_SIZE]; | |
83 | char status; | |
84 | int interf_count; | |
85 | struct stub_device *sdev; | |
86 | char shutdown_busid; | |
87 | }; | |
4d7b5c7f | 88 | |
499aaae0 | 89 | /* stub_priv is allocated from stub_priv_cache */ |
4d7b5c7f TH |
90 | extern struct kmem_cache *stub_priv_cache; |
91 | ||
4d7b5c7f TH |
92 | /* stub_dev.c */ |
93 | extern struct usb_driver stub_driver; | |
94 | ||
4d7b5c7f | 95 | /* stub_main.c */ |
aa5873e9 EK |
96 | struct bus_id_priv *get_busid_priv(const char *busid); |
97 | int del_match_busid(char *busid); | |
4d7b5c7f | 98 | void stub_device_cleanup_urbs(struct stub_device *sdev); |
499aaae0 | 99 | |
100 | /* stub_rx.c */ | |
101 | int stub_rx_loop(void *data); | |
102 | ||
103 | /* stub_tx.c */ | |
104 | void stub_enqueue_ret_unlink(struct stub_device *sdev, __u32 seqnum, | |
105 | __u32 status); | |
106 | void stub_complete(struct urb *urb); | |
107 | int stub_tx_loop(void *data); |