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#include <linux/ratelimit.h>
38
39
40
41
42
43#define usb_err(instance, format, arg...) \
44 dev_err(&(instance)->usb_intf->dev , format , ## arg)
45#define usb_info(instance, format, arg...) \
46 dev_info(&(instance)->usb_intf->dev , format , ## arg)
47#define usb_warn(instance, format, arg...) \
48 dev_warn(&(instance)->usb_intf->dev , format , ## arg)
49#define usb_dbg(instance, format, arg...) \
50 dev_dbg(&(instance)->usb_intf->dev , format , ## arg)
51
52
53#define atm_printk(level, instance, format, arg...) \
54 printk(level "ATM dev %d: " format , \
55 (instance)->atm_dev->number , ## arg)
56
57#define atm_err(instance, format, arg...) \
58 atm_printk(KERN_ERR, instance , format , ## arg)
59#define atm_info(instance, format, arg...) \
60 atm_printk(KERN_INFO, instance , format , ## arg)
61#define atm_warn(instance, format, arg...) \
62 atm_printk(KERN_WARNING, instance , format , ## arg)
63#define atm_dbg(instance, format, ...) \
64 pr_debug("ATM dev %d: " format, \
65 (instance)->atm_dev->number, ##__VA_ARGS__)
66#define atm_rldbg(instance, format, ...) \
67 pr_debug_ratelimited("ATM dev %d: " format, \
68 (instance)->atm_dev->number, ##__VA_ARGS__)
69
70
71
72#define UDSL_SKIP_HEAVY_INIT (1<<0)
73#define UDSL_USE_ISOC (1<<1)
74#define UDSL_IGNORE_EILSEQ (1<<2)
75
76
77
78
79struct usbatm_data;
80
81
82
83
84
85
86
87struct usbatm_driver {
88 const char *driver_name;
89
90
91 int (*bind) (struct usbatm_data *, struct usb_interface *,
92 const struct usb_device_id *id);
93
94
95 int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
96
97
98 void (*unbind) (struct usbatm_data *, struct usb_interface *);
99
100
101 int (*atm_start) (struct usbatm_data *, struct atm_dev *);
102
103
104 void (*atm_stop) (struct usbatm_data *, struct atm_dev *);
105
106 int bulk_in;
107 int isoc_in;
108 int bulk_out;
109
110 unsigned rx_padding;
111 unsigned tx_padding;
112};
113
114extern int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
115 struct usbatm_driver *driver);
116extern void usbatm_usb_disconnect(struct usb_interface *intf);
117
118
119struct usbatm_channel {
120 int endpoint;
121 unsigned int stride;
122 unsigned int buf_size;
123 unsigned int packet_size;
124 spinlock_t lock;
125 struct list_head list;
126 struct tasklet_struct tasklet;
127 struct timer_list delay;
128 struct usbatm_data *usbatm;
129};
130
131
132
133struct usbatm_data {
134
135
136
137
138
139 struct usbatm_driver *driver;
140 void *driver_data;
141 char driver_name[16];
142 unsigned int flags;
143
144
145 struct usb_device *usb_dev;
146 struct usb_interface *usb_intf;
147 char description[64];
148
149
150 struct atm_dev *atm_dev;
151
152
153
154
155
156 struct kref refcount;
157 struct mutex serialize;
158 int disconnected;
159
160
161 struct task_struct *thread;
162 struct completion thread_started;
163 struct completion thread_exited;
164
165
166 struct list_head vcc_list;
167
168 struct usbatm_channel rx_channel;
169 struct usbatm_channel tx_channel;
170
171 struct sk_buff_head sndqueue;
172 struct sk_buff *current_skb;
173
174 struct usbatm_vcc_data *cached_vcc;
175 int cached_vci;
176 short cached_vpi;
177
178 unsigned char *cell_buf;
179 unsigned int buf_usage;
180
181 struct urb *urbs[0];
182};
183
184static inline void *to_usbatm_driver_data(struct usb_interface *intf)
185{
186 struct usbatm_data *usbatm_instance;
187
188 if (intf == NULL)
189 return NULL;
190
191 usbatm_instance = usb_get_intfdata(intf);
192
193 if (usbatm_instance == NULL)
194 return NULL;
195
196 return usbatm_instance->driver_data;
197}
198
199#endif
200