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