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)
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
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 ******************************************************************************/
27 #include <linux/config.h>
34 #if !defined (DEBUG) && defined (CONFIG_USB_DEBUG)
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>
49 #define UDSL_ASSERT(x) BUG_ON(!(x))
51 #define UDSL_ASSERT(x) do { if (!(x)) warn("failed assertion '%s' at line %d", __stringify(x), __LINE__); } while(0)
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 , (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)
74 #define atm_dbg(instance, format, arg...) \
75 atm_printk(KERN_DEBUG, instance , format , ## arg)
77 #define atm_dbg(instance, format, arg...) \
87 * Assuming all methods exist and succeed, they are called in this order:
89 * bind, heavy_init, atm_start, ..., atm_stop, unbind
92 struct usbatm_driver {
95 const char *driver_name;
98 * init device ... can sleep, or cause probe() failure. Drivers with a heavy_init
99 * method can avoid having it called by setting need_heavy_init to zero.
101 int (*bind) (struct usbatm_data *, struct usb_interface *,
102 const struct usb_device_id *id, int *need_heavy_init);
104 /* additional device initialization that is too slow to be done in probe() */
105 int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
107 /* cleanup device ... can sleep, but can't fail */
108 void (*unbind) (struct usbatm_data *, struct usb_interface *);
110 /* init ATM device ... can sleep, or cause ATM initialization failure */
111 int (*atm_start) (struct usbatm_data *, struct atm_dev *);
113 /* cleanup ATM device ... can sleep, but can't fail */
114 void (*atm_stop) (struct usbatm_data *, struct atm_dev *);
116 int in; /* rx endpoint */
117 int out; /* tx endpoint */
123 extern int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
124 struct usbatm_driver *driver);
125 extern void usbatm_usb_disconnect(struct usb_interface *intf);
128 struct usbatm_channel {
129 int endpoint; /* usb pipe */
130 unsigned int stride; /* ATM cell size + padding */
131 unsigned int buf_size; /* urb buffer size */
133 struct list_head list;
134 struct tasklet_struct tasklet;
135 struct timer_list delay;
136 struct usbatm_data *usbatm;
139 /* main driver data */
147 struct usbatm_driver *driver;
149 char driver_name[16];
152 struct usb_device *usb_dev;
153 struct usb_interface *usb_intf;
154 char description[64];
157 struct atm_dev *atm_dev;
159 /********************************
160 * private fields - do not use *
161 ********************************/
163 struct kref refcount;
164 struct semaphore serialize;
168 struct completion thread_started;
169 struct completion thread_exited;
172 struct list_head vcc_list;
174 struct usbatm_channel rx_channel;
175 struct usbatm_channel tx_channel;
177 struct sk_buff_head sndqueue;
178 struct sk_buff *current_skb; /* being emptied */
183 #endif /* _USBATM_H_ */