aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/atm/usbatm.h
diff options
context:
space:
mode:
authorDuncan Sands <duncan.sands@math.u-psud.fr>2005-05-11 14:24:03 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-06-27 17:43:55 -0400
commitc59bba75fa500f13ef14215d599ee0d7faa1b954 (patch)
treeb37daba6cdb31635173e781a2c742f4190ff08e3 /drivers/usb/atm/usbatm.h
parentd49d431744007cec0ee1a3ade96f9e0f100c7907 (diff)
[PATCH] USB ATM: new usbatm core
Rework the core usbatm code: minidrivers (i.e. drivers for particular modems) now register themselves with the usbatm core, supplying methods for binding/unbinding etc. The design was inspired by usb-serial and usbnet. At the same time, more common code from the speedtch and cxacru (patch 3/5) drivers was generalized and moved into the core. The transmission and reception parts have been unified and simplified. Since this is a major change and I don't like underscores in file names, usb_atm.[ch] has been renamed usbatm.[ch]. Many thanks to Roman Kagan, who did a lot of the coding. Signed-off-by: Duncan Sands <baldrick@free.fr> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/atm/usbatm.h')
-rw-r--r--drivers/usb/atm/usbatm.h183
1 files changed, 183 insertions, 0 deletions
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h
new file mode 100644
index 000000000000..2239804453cf
--- /dev/null
+++ b/drivers/usb/atm/usbatm.h
@@ -0,0 +1,183 @@
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 , (instance)->atm_dev->number, ## arg)
66
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)
73#ifdef DEBUG
74#define atm_dbg(instance, format, arg...) \
75 atm_printk(KERN_DEBUG, instance , format , ## arg)
76#else
77#define atm_dbg(instance, format, arg...) \
78 do {} while (0)
79#endif
80
81
82/* mini driver */
83
84struct usbatm_data;
85
86/*
87* Assuming all methods exist and succeed, they are called in this order:
88*
89* bind, heavy_init, atm_start, ..., atm_stop, unbind
90*/
91
92struct usbatm_driver {
93 struct module *owner;
94
95 const char *driver_name;
96
97 /*
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.
100 */
101 int (*bind) (struct usbatm_data *, struct usb_interface *,
102 const struct usb_device_id *id, int *need_heavy_init);
103
104 /* additional device initialization that is too slow to be done in probe() */
105 int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
106
107 /* cleanup device ... can sleep, but can't fail */
108 void (*unbind) (struct usbatm_data *, struct usb_interface *);
109
110 /* init ATM device ... can sleep, or cause ATM initialization failure */
111 int (*atm_start) (struct usbatm_data *, struct atm_dev *);
112
113 /* cleanup ATM device ... can sleep, but can't fail */
114 void (*atm_stop) (struct usbatm_data *, struct atm_dev *);
115
116 int in; /* rx endpoint */
117 int out; /* tx endpoint */
118
119 unsigned rx_padding;
120 unsigned tx_padding;
121};
122
123extern int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
124 struct usbatm_driver *driver);
125extern void usbatm_usb_disconnect(struct usb_interface *intf);
126
127
128struct usbatm_channel {
129 int endpoint; /* usb pipe */
130 unsigned int stride; /* ATM cell size + padding */
131 unsigned int buf_size; /* urb buffer size */
132 spinlock_t lock;
133 struct list_head list;
134 struct tasklet_struct tasklet;
135 struct timer_list delay;
136 struct usbatm_data *usbatm;
137};
138
139/* main driver data */
140
141struct usbatm_data {
142 /******************
143 * public fields *
144 ******************/
145
146 /* mini driver */
147 struct usbatm_driver *driver;
148 void *driver_data;
149 char driver_name[16];
150
151 /* USB device */
152 struct usb_device *usb_dev;
153 struct usb_interface *usb_intf;
154 char description[64];
155
156 /* ATM device */
157 struct atm_dev *atm_dev;
158
159 /********************************
160 * private fields - do not use *
161 ********************************/
162
163 struct kref refcount;
164 struct semaphore serialize;
165
166 /* heavy init */
167 int thread_pid;
168 struct completion thread_started;
169 struct completion thread_exited;
170
171 /* ATM device */
172 struct list_head vcc_list;
173
174 struct usbatm_channel rx_channel;
175 struct usbatm_channel tx_channel;
176
177 struct sk_buff_head sndqueue;
178 struct sk_buff *current_skb; /* being emptied */
179
180 struct urb *urbs[0];
181};
182
183#endif /* _USBATM_H_ */