aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/atm/usbatm.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/atm/usbatm.h')
-rw-r--r--drivers/usb/atm/usbatm.h184
1 files changed, 184 insertions, 0 deletions
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h
new file mode 100644
index 000000000000..936646457935
--- /dev/null
+++ b/drivers/usb/atm/usbatm.h
@@ -0,0 +1,184 @@
1/******************************************************************************
2 * usbatm.h - Generic USB xDSL driver core
3 *
4 * Copyright (C) 2001, Alcatel
5 * Copyright (C) 2003, Duncan Sands, SolNegro, Josep Comas
6 * Copyright (C) 2004, David Woodhouse
7 *
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.
12 *
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.
17 *
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.
21 *
22 ******************************************************************************/
23
24#ifndef _USBATM_H_
25#define _USBATM_H_
26
27#include <linux/config.h>
28
29/*
30#define DEBUG
31#define VERBOSE_DEBUG
32*/
33
34#if !defined (DEBUG) && defined (CONFIG_USB_DEBUG)
35# define DEBUG
36#endif
37
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>
47
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
53
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)
62
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)
67
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
81
82
83/* mini driver */
84
85struct usbatm_data;
86
87/*
88* Assuming all methods exist and succeed, they are called in this order:
89*
90* bind, heavy_init, atm_start, ..., atm_stop, unbind
91*/
92
93struct usbatm_driver {
94 struct module *owner;
95
96 const char *driver_name;
97
98 /*
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.
101 */
102 int (*bind) (struct usbatm_data *, struct usb_interface *,
103 const struct usb_device_id *id, int *need_heavy_init);
104
105 /* additional device initialization that is too slow to be done in probe() */
106 int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
107
108 /* cleanup device ... can sleep, but can't fail */
109 void (*unbind) (struct usbatm_data *, struct usb_interface *);
110
111 /* init ATM device ... can sleep, or cause ATM initialization failure */
112 int (*atm_start) (struct usbatm_data *, struct atm_dev *);
113
114 /* cleanup ATM device ... can sleep, but can't fail */
115 void (*atm_stop) (struct usbatm_data *, struct atm_dev *);
116
117 int in; /* rx endpoint */
118 int out; /* tx endpoint */
119
120 unsigned rx_padding;
121 unsigned tx_padding;
122};
123
124extern int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
125 struct usbatm_driver *driver);
126extern void usbatm_usb_disconnect(struct usb_interface *intf);
127
128
129struct 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;
138};
139
140/* main driver data */
141
142struct usbatm_data {
143 /******************
144 * public fields *
145 ******************/
146
147 /* mini driver */
148 struct usbatm_driver *driver;
149 void *driver_data;
150 char driver_name[16];
151
152 /* USB device */
153 struct usb_device *usb_dev;
154 struct usb_interface *usb_intf;
155 char description[64];
156
157 /* ATM device */
158 struct atm_dev *atm_dev;
159
160 /********************************
161 * private fields - do not use *
162 ********************************/
163
164 struct kref refcount;
165 struct semaphore serialize;
166
167 /* heavy init */
168 int thread_pid;
169 struct completion thread_started;
170 struct completion thread_exited;
171
172 /* ATM device */
173 struct list_head vcc_list;
174
175 struct usbatm_channel rx_channel;
176 struct usbatm_channel tx_channel;
177
178 struct sk_buff_head sndqueue;
179 struct sk_buff *current_skb; /* being emptied */
180
181 struct urb *urbs[0];
182};
183
184#endif /* _USBATM_H_ */