GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / usb / atm / usbatm.h
blob047cf00f4ae9c790a7bad3e665a6144f754073c4
1 /******************************************************************************
2 * usbatm.h - Generic USB xDSL driver core
4 * Copyright (C) 2001, Alcatel
5 * Copyright (C) 2003, Duncan Sands, SolNegro, Josep Comas
6 * Copyright (C) 2004, David Woodhouse
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
18 * You should have received a copy of the GNU General Public License along with
19 * this program; if not, write to the Free Software Foundation, Inc., 59
20 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 ******************************************************************************/
24 #ifndef _USBATM_H_
25 #define _USBATM_H_
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>
39 #define VERBOSE_DEBUG
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
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
68 #define atm_printk(level, instance, format, arg...) \
69 printk(level "ATM dev %d: " format , \
70 (instance)->atm_dev->number , ## arg)
72 #define atm_err(instance, format, arg...) \
73 atm_printk(KERN_ERR, instance , format , ## arg)
74 #define atm_info(instance, format, arg...) \
75 atm_printk(KERN_INFO, instance , format , ## arg)
76 #define atm_warn(instance, format, arg...) \
77 atm_printk(KERN_WARNING, instance , format , ## arg)
78 #ifdef DEBUG
79 #define atm_dbg(instance, format, arg...) \
80 atm_printk(KERN_DEBUG, instance , format , ## arg)
81 #define atm_rldbg(instance, format, arg...) \
82 if (printk_ratelimit()) \
83 atm_printk(KERN_DEBUG, instance , format , ## arg)
84 #else
85 #define atm_dbg(instance, format, arg...) \
86 do {} while (0)
87 #define atm_rldbg(instance, format, arg...) \
88 do {} while (0)
89 #endif
92 /* flags, set by mini-driver in bind() */
94 #define UDSL_SKIP_HEAVY_INIT (1<<0)
95 #define UDSL_USE_ISOC (1<<1)
96 #define UDSL_IGNORE_EILSEQ (1<<2)
99 /* mini driver */
101 struct usbatm_data;
104 * Assuming all methods exist and succeed, they are called in this order:
106 * bind, heavy_init, atm_start, ..., atm_stop, unbind
109 struct usbatm_driver {
110 const char *driver_name;
112 /* init device ... can sleep, or cause probe() failure */
113 int (*bind) (struct usbatm_data *, struct usb_interface *,
114 const struct usb_device_id *id);
116 /* additional device initialization that is too slow to be done in probe() */
117 int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
119 /* cleanup device ... can sleep, but can't fail */
120 void (*unbind) (struct usbatm_data *, struct usb_interface *);
122 /* init ATM device ... can sleep, or cause ATM initialization failure */
123 int (*atm_start) (struct usbatm_data *, struct atm_dev *);
125 /* cleanup ATM device ... can sleep, but can't fail */
126 void (*atm_stop) (struct usbatm_data *, struct atm_dev *);
128 int bulk_in; /* bulk rx endpoint */
129 int isoc_in; /* isochronous rx endpoint */
130 int bulk_out; /* bulk tx endpoint */
132 unsigned rx_padding;
133 unsigned tx_padding;
136 extern int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
137 struct usbatm_driver *driver);
138 extern void usbatm_usb_disconnect(struct usb_interface *intf);
141 struct usbatm_channel {
142 int endpoint; /* usb pipe */
143 unsigned int stride; /* ATM cell size + padding */
144 unsigned int buf_size; /* urb buffer size */
145 unsigned int packet_size; /* endpoint maxpacket */
146 spinlock_t lock;
147 struct list_head list;
148 struct tasklet_struct tasklet;
149 struct timer_list delay;
150 struct usbatm_data *usbatm;
153 /* main driver data */
155 struct usbatm_data {
156 /******************
157 * public fields *
158 ******************/
160 /* mini driver */
161 struct usbatm_driver *driver;
162 void *driver_data;
163 char driver_name[16];
164 unsigned int flags; /* set by mini-driver in bind() */
166 /* USB device */
167 struct usb_device *usb_dev;
168 struct usb_interface *usb_intf;
169 char description[64];
171 /* ATM device */
172 struct atm_dev *atm_dev;
174 /********************************
175 * private fields - do not use *
176 ********************************/
178 struct kref refcount;
179 struct mutex serialize;
180 int disconnected;
182 /* heavy init */
183 struct task_struct *thread;
184 struct completion thread_started;
185 struct completion thread_exited;
187 /* ATM device */
188 struct list_head vcc_list;
190 struct usbatm_channel rx_channel;
191 struct usbatm_channel tx_channel;
193 struct sk_buff_head sndqueue;
194 struct sk_buff *current_skb; /* being emptied */
196 struct usbatm_vcc_data *cached_vcc;
197 int cached_vci;
198 short cached_vpi;
200 unsigned char *cell_buf; /* holds partial rx cell */
201 unsigned int buf_usage;
203 struct urb *urbs[0];
206 static inline void *to_usbatm_driver_data(struct usb_interface *intf)
208 struct usbatm_data *usbatm_instance;
210 if (intf == NULL)
211 return NULL;
213 usbatm_instance = usb_get_intfdata(intf);
215 if (usbatm_instance == NULL) /* set NULL before unbind() */
216 return NULL;
218 return usbatm_instance->driver_data; /* set NULL after unbind() */
221 #endif /* _USBATM_H_ */