This source file includes following definitions.
- port_to_rhport
- port_to_pdev_nr
- hcd_to_vhci_hcd
- hcd_dev
- hcd_name
- vhci_hcd_to_hcd
- vdev_to_vhci_hcd
1
2
3
4
5
6
7 #ifndef __USBIP_VHCI_H
8 #define __USBIP_VHCI_H
9
10 #include <linux/device.h>
11 #include <linux/list.h>
12 #include <linux/spinlock.h>
13 #include <linux/sysfs.h>
14 #include <linux/types.h>
15 #include <linux/usb.h>
16 #include <linux/usb/hcd.h>
17 #include <linux/wait.h>
18
19 struct vhci_device {
20 struct usb_device *udev;
21
22
23
24
25
26 __u32 devid;
27
28
29 enum usb_device_speed speed;
30
31
32 __u32 rhport;
33
34 struct usbip_device ud;
35
36
37 spinlock_t priv_lock;
38
39
40 struct list_head priv_tx;
41 struct list_head priv_rx;
42
43
44 struct list_head unlink_tx;
45 struct list_head unlink_rx;
46
47
48 wait_queue_head_t waitq_tx;
49 };
50
51
52 struct vhci_priv {
53 unsigned long seqnum;
54 struct list_head list;
55
56 struct vhci_device *vdev;
57 struct urb *urb;
58 };
59
60 struct vhci_unlink {
61
62 unsigned long seqnum;
63
64 struct list_head list;
65
66
67 unsigned long unlink_seqnum;
68 };
69
70 enum hub_speed {
71 HUB_SPEED_HIGH = 0,
72 HUB_SPEED_SUPER,
73 };
74
75
76 #ifdef CONFIG_USBIP_VHCI_HC_PORTS
77 #define VHCI_HC_PORTS CONFIG_USBIP_VHCI_HC_PORTS
78 #else
79 #define VHCI_HC_PORTS 8
80 #endif
81
82
83 #define VHCI_PORTS (VHCI_HC_PORTS*2)
84
85 #ifdef CONFIG_USBIP_VHCI_NR_HCS
86 #define VHCI_NR_HCS CONFIG_USBIP_VHCI_NR_HCS
87 #else
88 #define VHCI_NR_HCS 1
89 #endif
90
91 #define MAX_STATUS_NAME 16
92
93 struct vhci {
94 spinlock_t lock;
95
96 struct platform_device *pdev;
97
98 struct vhci_hcd *vhci_hcd_hs;
99 struct vhci_hcd *vhci_hcd_ss;
100 };
101
102
103 struct vhci_hcd {
104 struct vhci *vhci;
105
106 u32 port_status[VHCI_HC_PORTS];
107
108 unsigned resuming:1;
109 unsigned long re_timeout;
110
111 atomic_t seqnum;
112
113
114
115
116
117
118 struct vhci_device vdev[VHCI_HC_PORTS];
119 };
120
121 extern int vhci_num_controllers;
122 extern struct vhci *vhcis;
123 extern struct attribute_group vhci_attr_group;
124
125
126 void rh_port_connect(struct vhci_device *vdev, enum usb_device_speed speed);
127
128
129 int vhci_init_attr_group(void);
130 void vhci_finish_attr_group(void);
131
132
133 struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, __u32 seqnum);
134 int vhci_rx_loop(void *data);
135
136
137 int vhci_tx_loop(void *data);
138
139 static inline __u32 port_to_rhport(__u32 port)
140 {
141 return port % VHCI_HC_PORTS;
142 }
143
144 static inline int port_to_pdev_nr(__u32 port)
145 {
146 return port / VHCI_PORTS;
147 }
148
149 static inline struct vhci_hcd *hcd_to_vhci_hcd(struct usb_hcd *hcd)
150 {
151 return (struct vhci_hcd *) (hcd->hcd_priv);
152 }
153
154 static inline struct device *hcd_dev(struct usb_hcd *hcd)
155 {
156 return (hcd)->self.controller;
157 }
158
159 static inline const char *hcd_name(struct usb_hcd *hcd)
160 {
161 return (hcd)->self.bus_name;
162 }
163
164 static inline struct usb_hcd *vhci_hcd_to_hcd(struct vhci_hcd *vhci_hcd)
165 {
166 return container_of((void *) vhci_hcd, struct usb_hcd, hcd_priv);
167 }
168
169 static inline struct vhci_hcd *vdev_to_vhci_hcd(struct vhci_device *vdev)
170 {
171 return container_of((void *)(vdev - vdev->rhport), struct vhci_hcd, vdev);
172 }
173
174 #endif