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 , \
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)
75 #define atm_dbg(instance, format, arg...) \
76 atm_printk(KERN_DEBUG, instance , format , ## arg)
78 #define atm_dbg(instance, format, arg...) \
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
{
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 */
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 */
134 struct list_head list
;
135 struct tasklet_struct tasklet
;
136 struct timer_list delay
;
137 struct usbatm_data
*usbatm
;
140 /* main driver data */
148 struct usbatm_driver
*driver
;
150 char driver_name
[16];
153 struct usb_device
*usb_dev
;
154 struct usb_interface
*usb_intf
;
155 char description
[64];
158 struct atm_dev
*atm_dev
;
160 /********************************
161 * private fields - do not use *
162 ********************************/
164 struct kref refcount
;
165 struct semaphore serialize
;
169 struct completion thread_started
;
170 struct completion thread_exited
;
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 */
184 #endif /* _USBATM_H_ */