Linux 2.6.26-rc5
[linux-2.6/openmoko-kernel/knife-kernel.git] / drivers / usb / atm / usbatm.h
blobe6887c6cf3cf5a26b7401ca4b7477b001df18b01
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(x) BUG_ON(!(x))
44 #else
45 #define UDSL_ASSERT(x) do { if (!(x)) warn("failed assertion '%s' at line %d", __stringify(x), __LINE__); } while(0)
46 #endif
48 #define usb_err(instance, format, arg...) \
49 dev_err(&(instance)->usb_intf->dev , format , ## arg)
50 #define usb_info(instance, format, arg...) \
51 dev_info(&(instance)->usb_intf->dev , format , ## arg)
52 #define usb_warn(instance, format, arg...) \
53 dev_warn(&(instance)->usb_intf->dev , format , ## arg)
54 #ifdef DEBUG
55 #define usb_dbg(instance, format, arg...) \
56 dev_printk(KERN_DEBUG , &(instance)->usb_intf->dev , format , ## arg)
57 #else
58 #define usb_dbg(instance, format, arg...) \
59 do {} while (0)
60 #endif
62 /* FIXME: move to dev_* once ATM is driver model aware */
63 #define atm_printk(level, instance, format, arg...) \
64 printk(level "ATM dev %d: " format , \
65 (instance)->atm_dev->number , ## arg)
67 #define atm_err(instance, format, arg...) \
68 atm_printk(KERN_ERR, instance , format , ## arg)
69 #define atm_info(instance, format, arg...) \
70 atm_printk(KERN_INFO, instance , format , ## arg)
71 #define atm_warn(instance, format, arg...) \
72 atm_printk(KERN_WARNING, instance , format , ## arg)
73 #ifdef DEBUG
74 #define atm_dbg(instance, format, arg...) \
75 atm_printk(KERN_DEBUG, instance , format , ## arg)
76 #define atm_rldbg(instance, format, arg...) \
77 if (printk_ratelimit()) \
78 atm_printk(KERN_DEBUG, instance , format , ## arg)
79 #else
80 #define atm_dbg(instance, format, arg...) \
81 do {} while (0)
82 #define atm_rldbg(instance, format, arg...) \
83 do {} while (0)
84 #endif
87 /* flags, set by mini-driver in bind() */
89 #define UDSL_SKIP_HEAVY_INIT (1<<0)
90 #define UDSL_USE_ISOC (1<<1)
91 #define UDSL_IGNORE_EILSEQ (1<<2)
94 /* mini driver */
96 struct usbatm_data;
99 * Assuming all methods exist and succeed, they are called in this order:
101 * bind, heavy_init, atm_start, ..., atm_stop, unbind
104 struct usbatm_driver {
105 const char *driver_name;
107 /* init device ... can sleep, or cause probe() failure */
108 int (*bind) (struct usbatm_data *, struct usb_interface *,
109 const struct usb_device_id *id);
111 /* additional device initialization that is too slow to be done in probe() */
112 int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
114 /* cleanup device ... can sleep, but can't fail */
115 void (*unbind) (struct usbatm_data *, struct usb_interface *);
117 /* init ATM device ... can sleep, or cause ATM initialization failure */
118 int (*atm_start) (struct usbatm_data *, struct atm_dev *);
120 /* cleanup ATM device ... can sleep, but can't fail */
121 void (*atm_stop) (struct usbatm_data *, struct atm_dev *);
123 int bulk_in; /* bulk rx endpoint */
124 int isoc_in; /* isochronous rx endpoint */
125 int bulk_out; /* bulk tx endpoint */
127 unsigned rx_padding;
128 unsigned tx_padding;
131 extern int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
132 struct usbatm_driver *driver);
133 extern void usbatm_usb_disconnect(struct usb_interface *intf);
136 struct usbatm_channel {
137 int endpoint; /* usb pipe */
138 unsigned int stride; /* ATM cell size + padding */
139 unsigned int buf_size; /* urb buffer size */
140 unsigned int packet_size; /* endpoint maxpacket */
141 spinlock_t lock;
142 struct list_head list;
143 struct tasklet_struct tasklet;
144 struct timer_list delay;
145 struct usbatm_data *usbatm;
148 /* main driver data */
150 struct usbatm_data {
151 /******************
152 * public fields *
153 ******************/
155 /* mini driver */
156 struct usbatm_driver *driver;
157 void *driver_data;
158 char driver_name[16];
159 unsigned int flags; /* set by mini-driver in bind() */
161 /* USB device */
162 struct usb_device *usb_dev;
163 struct usb_interface *usb_intf;
164 char description[64];
166 /* ATM device */
167 struct atm_dev *atm_dev;
169 /********************************
170 * private fields - do not use *
171 ********************************/
173 struct kref refcount;
174 struct mutex serialize;
175 int disconnected;
177 /* heavy init */
178 struct task_struct *thread;
179 struct completion thread_started;
180 struct completion thread_exited;
182 /* ATM device */
183 struct list_head vcc_list;
185 struct usbatm_channel rx_channel;
186 struct usbatm_channel tx_channel;
188 struct sk_buff_head sndqueue;
189 struct sk_buff *current_skb; /* being emptied */
191 struct usbatm_vcc_data *cached_vcc;
192 int cached_vci;
193 short cached_vpi;
195 unsigned char *cell_buf; /* holds partial rx cell */
196 unsigned int buf_usage;
198 struct urb *urbs[0];
201 #endif /* _USBATM_H_ */