Linux v2.6.13
[linux-2.6/next.git] / drivers / usb / atm / usbatm.h
blob936646457935a3af6aba0750ef27a00e08a2208d
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/config.h>
30 #define DEBUG
31 #define VERBOSE_DEBUG
34 #if !defined (DEBUG) && defined (CONFIG_USB_DEBUG)
35 # define DEBUG
36 #endif
38 #include <asm/semaphore.h>
39 #include <linux/atm.h>
40 #include <linux/atmdev.h>
41 #include <linux/completion.h>
42 #include <linux/device.h>
43 #include <linux/kref.h>
44 #include <linux/list.h>
45 #include <linux/stringify.h>
46 #include <linux/usb.h>
48 #ifdef DEBUG
49 #define UDSL_ASSERT(x) BUG_ON(!(x))
50 #else
51 #define UDSL_ASSERT(x) do { if (!(x)) warn("failed assertion '%s' at line %d", __stringify(x), __LINE__); } 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 #define usb_dbg(instance, format, arg...) \
61 dev_dbg(&(instance)->usb_intf->dev , format , ## arg)
63 /* FIXME: move to dev_* once ATM is driver model aware */
64 #define atm_printk(level, instance, format, arg...) \
65 printk(level "ATM dev %d: " format , \
66 (instance)->atm_dev->number , ## arg)
68 #define atm_err(instance, format, arg...) \
69 atm_printk(KERN_ERR, instance , format , ## arg)
70 #define atm_info(instance, format, arg...) \
71 atm_printk(KERN_INFO, instance , format , ## arg)
72 #define atm_warn(instance, format, arg...) \
73 atm_printk(KERN_WARNING, instance , format , ## arg)
74 #ifdef DEBUG
75 #define atm_dbg(instance, format, arg...) \
76 atm_printk(KERN_DEBUG, instance , format , ## arg)
77 #else
78 #define atm_dbg(instance, format, arg...) \
79 do {} while (0)
80 #endif
83 /* mini driver */
85 struct usbatm_data;
88 * Assuming all methods exist and succeed, they are called in this order:
90 * bind, heavy_init, atm_start, ..., atm_stop, unbind
93 struct usbatm_driver {
94 struct module *owner;
96 const char *driver_name;
99 * init device ... can sleep, or cause probe() failure. Drivers with a heavy_init
100 * method can avoid having it called by setting need_heavy_init to zero.
102 int (*bind) (struct usbatm_data *, struct usb_interface *,
103 const struct usb_device_id *id, int *need_heavy_init);
105 /* additional device initialization that is too slow to be done in probe() */
106 int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
108 /* cleanup device ... can sleep, but can't fail */
109 void (*unbind) (struct usbatm_data *, struct usb_interface *);
111 /* init ATM device ... can sleep, or cause ATM initialization failure */
112 int (*atm_start) (struct usbatm_data *, struct atm_dev *);
114 /* cleanup ATM device ... can sleep, but can't fail */
115 void (*atm_stop) (struct usbatm_data *, struct atm_dev *);
117 int in; /* rx endpoint */
118 int out; /* tx endpoint */
120 unsigned rx_padding;
121 unsigned tx_padding;
124 extern int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
125 struct usbatm_driver *driver);
126 extern void usbatm_usb_disconnect(struct usb_interface *intf);
129 struct usbatm_channel {
130 int endpoint; /* usb pipe */
131 unsigned int stride; /* ATM cell size + padding */
132 unsigned int buf_size; /* urb buffer size */
133 spinlock_t lock;
134 struct list_head list;
135 struct tasklet_struct tasklet;
136 struct timer_list delay;
137 struct usbatm_data *usbatm;
140 /* main driver data */
142 struct usbatm_data {
143 /******************
144 * public fields *
145 ******************/
147 /* mini driver */
148 struct usbatm_driver *driver;
149 void *driver_data;
150 char driver_name[16];
152 /* USB device */
153 struct usb_device *usb_dev;
154 struct usb_interface *usb_intf;
155 char description[64];
157 /* ATM device */
158 struct atm_dev *atm_dev;
160 /********************************
161 * private fields - do not use *
162 ********************************/
164 struct kref refcount;
165 struct semaphore serialize;
167 /* heavy init */
168 int thread_pid;
169 struct completion thread_started;
170 struct completion thread_exited;
172 /* ATM device */
173 struct list_head vcc_list;
175 struct usbatm_channel rx_channel;
176 struct usbatm_channel tx_channel;
178 struct sk_buff_head sndqueue;
179 struct sk_buff *current_skb; /* being emptied */
181 struct urb *urbs[0];
184 #endif /* _USBATM_H_ */