1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef _USBATM_H_
25#define _USBATM_H_
26
27#include <linux/atm.h>
28#include <linux/atmdev.h>
29#include <linux/completion.h>
30#include <linux/device.h>
31#include <linux/kernel.h>
32#include <linux/kref.h>
33#include <linux/list.h>
34#include <linux/stringify.h>
35#include <linux/usb.h>
36#include <linux/mutex.h>
37
38
39
40
41
42#ifdef DEBUG
43#define UDSL_ASSERT(instance, x) BUG_ON(!(x))
44#else
45#define UDSL_ASSERT(instance, x) \
46 do { \
47 if (!(x)) \
48 dev_warn(&(instance)->usb_intf->dev, \
49 "failed assertion '%s' at line %d", \
50 __stringify(x), __LINE__); \
51 } while (0)
52#endif
53
54#define usb_err(instance, format, arg...) \
55 dev_err(&(instance)->usb_intf->dev , format , ## arg)
56#define usb_info(instance, format, arg...) \
57 dev_info(&(instance)->usb_intf->dev , format , ## arg)
58#define usb_warn(instance, format, arg...) \
59 dev_warn(&(instance)->usb_intf->dev , format , ## arg)
60#ifdef DEBUG
61#define usb_dbg(instance, format, arg...) \
62 dev_printk(KERN_DEBUG , &(instance)->usb_intf->dev , format , ## arg)
63#else
64#define usb_dbg(instance, format, arg...) \
65 do {} while (0)
66#endif
67
68
69#define atm_printk(level, instance, format, arg...) \
70 printk(level "ATM dev %d: " format , \
71 (instance)->atm_dev->number , ## arg)
72
73#define atm_err(instance, format, arg...) \
74 atm_printk(KERN_ERR, instance , format , ## arg)
75#define atm_info(instance, format, arg...) \
76 atm_printk(KERN_INFO, instance , format , ## arg)
77#define atm_warn(instance, format, arg...) \
78 atm_printk(KERN_WARNING, instance , format , ## arg)
79#ifdef DEBUG
80#define atm_dbg(instance, format, arg...) \
81 atm_printk(KERN_DEBUG, instance , format , ## arg)
82#define atm_rldbg(instance, format, arg...) \
83 if (printk_ratelimit()) \
84 atm_printk(KERN_DEBUG, instance , format , ## arg)
85#else
86#define atm_dbg(instance, format, arg...) \
87 do {} while (0)
88#define atm_rldbg(instance, format, arg...) \
89 do {} while (0)
90#endif
91
92
93
94
95#define UDSL_SKIP_HEAVY_INIT (1<<0)
96#define UDSL_USE_ISOC (1<<1)
97#define UDSL_IGNORE_EILSEQ (1<<2)
98
99
100
101
102struct usbatm_data;
103
104
105
106
107
108
109
110struct usbatm_driver {
111 const char *driver_name;
112
113
114 int (*bind) (struct usbatm_data *, struct usb_interface *,
115 const struct usb_device_id *id);
116
117
118 int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
119
120
121 void (*unbind) (struct usbatm_data *, struct usb_interface *);
122
123
124 int (*atm_start) (struct usbatm_data *, struct atm_dev *);
125
126
127 void (*atm_stop) (struct usbatm_data *, struct atm_dev *);
128
129 int bulk_in;
130 int isoc_in;
131 int bulk_out;
132
133 unsigned rx_padding;
134 unsigned tx_padding;
135};
136
137extern int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
138 struct usbatm_driver *driver);
139extern void usbatm_usb_disconnect(struct usb_interface *intf);
140
141
142struct usbatm_channel {
143 int endpoint;
144 unsigned int stride;
145 unsigned int buf_size;
146 unsigned int packet_size;
147 spinlock_t lock;
148 struct list_head list;
149 struct tasklet_struct tasklet;
150 struct timer_list delay;
151 struct usbatm_data *usbatm;
152};
153
154
155
156struct usbatm_data {
157
158
159
160
161
162 struct usbatm_driver *driver;
163 void *driver_data;
164 char driver_name[16];
165 unsigned int flags;
166
167
168 struct usb_device *usb_dev;
169 struct usb_interface *usb_intf;
170 char description[64];
171
172
173 struct atm_dev *atm_dev;
174
175
176
177
178
179 struct kref refcount;
180 struct mutex serialize;
181 int disconnected;
182
183
184 struct task_struct *thread;
185 struct completion thread_started;
186 struct completion thread_exited;
187
188
189 struct list_head vcc_list;
190
191 struct usbatm_channel rx_channel;
192 struct usbatm_channel tx_channel;
193
194 struct sk_buff_head sndqueue;
195 struct sk_buff *current_skb;
196
197 struct usbatm_vcc_data *cached_vcc;
198 int cached_vci;
199 short cached_vpi;
200
201 unsigned char *cell_buf;
202 unsigned int buf_usage;
203
204 struct urb *urbs[0];
205};
206
207static inline void *to_usbatm_driver_data(struct usb_interface *intf)
208{
209 struct usbatm_data *usbatm_instance;
210
211 if (intf == NULL)
212 return NULL;
213
214 usbatm_instance = usb_get_intfdata(intf);
215
216 if (usbatm_instance == NULL)
217 return NULL;
218
219 return usbatm_instance->driver_data;
220}
221
222#endif
223