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/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>
43 #define UDSL_ASSERT(instance, x) BUG_ON(!(x))
45 #define UDSL_ASSERT(instance, x) \
48 dev_warn(&(instance)->usb_intf->dev, \
49 "failed assertion '%s' at line %d", \
50 __stringify(x), __LINE__); \
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)
61 #define usb_dbg(instance, format, arg...) \
62 dev_printk(KERN_DEBUG , &(instance)->usb_intf->dev , format , ## arg)
64 #define usb_dbg(instance, format, arg...) \
68 /* FIXME: move to dev_* once ATM is driver model aware */
69 #define atm_printk(level, instance, format, arg...) \
70 printk(level "ATM dev %d: " format , \
71 (instance)->atm_dev->number , ## arg)
73 #define atm_err(instance, format, arg...) \
74 atm_printk(KERN_ERR, instance , format , ## arg)
75 #define atm_info(instance, format, arg...) \
76 atm_printk(KERN_INFO, instance , format , ## arg)
77 #define atm_warn(instance, format, arg...) \
78 atm_printk(KERN_WARNING, instance , format , ## arg)
80 #define atm_dbg(instance, format, arg...) \
81 atm_printk(KERN_DEBUG, instance , format , ## arg)
82 #define atm_rldbg(instance, format, arg...) \
83 if (printk_ratelimit()) \
84 atm_printk(KERN_DEBUG, instance , format , ## arg)
86 #define atm_dbg(instance, format, arg...) \
88 #define atm_rldbg(instance, format, arg...) \
93 /* flags, set by mini-driver in bind() */
95 #define UDSL_SKIP_HEAVY_INIT (1<<0)
96 #define UDSL_USE_ISOC (1<<1)
97 #define UDSL_IGNORE_EILSEQ (1<<2)
105 * Assuming all methods exist and succeed, they are called in this order:
107 * bind, heavy_init, atm_start, ..., atm_stop, unbind
110 struct usbatm_driver {
111 const char *driver_name;
113 /* init device ... can sleep, or cause probe() failure */
114 int (*bind) (struct usbatm_data *, struct usb_interface *,
115 const struct usb_device_id *id);
117 /* additional device initialization that is too slow to be done in probe() */
118 int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
120 /* cleanup device ... can sleep, but can't fail */
121 void (*unbind) (struct usbatm_data *, struct usb_interface *);
123 /* init ATM device ... can sleep, or cause ATM initialization failure */
124 int (*atm_start) (struct usbatm_data *, struct atm_dev *);
126 /* cleanup ATM device ... can sleep, but can't fail */
127 void (*atm_stop) (struct usbatm_data *, struct atm_dev *);
129 int bulk_in; /* bulk rx endpoint */
130 int isoc_in; /* isochronous rx endpoint */
131 int bulk_out; /* bulk tx endpoint */
137 extern int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
138 struct usbatm_driver *driver);
139 extern void usbatm_usb_disconnect(struct usb_interface *intf);
142 struct usbatm_channel {
143 int endpoint; /* usb pipe */
144 unsigned int stride; /* ATM cell size + padding */
145 unsigned int buf_size; /* urb buffer size */
146 unsigned int packet_size; /* endpoint maxpacket */
148 struct list_head list;
149 struct tasklet_struct tasklet;
150 struct timer_list delay;
151 struct usbatm_data *usbatm;
154 /* main driver data */
162 struct usbatm_driver *driver;
164 char driver_name[16];
165 unsigned int flags; /* set by mini-driver in bind() */
168 struct usb_device *usb_dev;
169 struct usb_interface *usb_intf;
170 char description[64];
173 struct atm_dev *atm_dev;
175 /********************************
176 * private fields - do not use *
177 ********************************/
179 struct kref refcount;
180 struct mutex serialize;
184 struct task_struct *thread;
185 struct completion thread_started;
186 struct completion thread_exited;
189 struct list_head vcc_list;
191 struct usbatm_channel rx_channel;
192 struct usbatm_channel tx_channel;
194 struct sk_buff_head sndqueue;
195 struct sk_buff *current_skb; /* being emptied */
197 struct usbatm_vcc_data *cached_vcc;
201 unsigned char *cell_buf; /* holds partial rx cell */
202 unsigned int buf_usage;
207 #endif /* _USBATM_H_ */