Linux Audio

Check our new training course

Linux debugging, profiling, tracing and performance analysis training

Mar 24-27, 2025, special US time zones
Register
Loading...
v6.8
  1/* SPDX-License-Identifier: GPL-2.0+ */
  2/******************************************************************************
  3 *  usbatm.h - Generic USB xDSL driver core
  4 *
  5 *  Copyright (C) 2001, Alcatel
  6 *  Copyright (C) 2003, Duncan Sands, SolNegro, Josep Comas
  7 *  Copyright (C) 2004, David Woodhouse
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  8 ******************************************************************************/
  9
 10#ifndef	_USBATM_H_
 11#define	_USBATM_H_
 12
 13#include <linux/atm.h>
 14#include <linux/atmdev.h>
 15#include <linux/completion.h>
 16#include <linux/device.h>
 17#include <linux/kernel.h>
 18#include <linux/kref.h>
 19#include <linux/list.h>
 20#include <linux/stringify.h>
 21#include <linux/usb.h>
 22#include <linux/mutex.h>
 23#include <linux/ratelimit.h>
 24
 25/*
 26#define VERBOSE_DEBUG
 27*/
 28
 
 
 
 
 
 
 
 
 
 
 
 
 29#define usb_err(instance, format, arg...)	\
 30	dev_err(&(instance)->usb_intf->dev , format , ## arg)
 31#define usb_info(instance, format, arg...)	\
 32	dev_info(&(instance)->usb_intf->dev , format , ## arg)
 33#define usb_warn(instance, format, arg...)	\
 34	dev_warn(&(instance)->usb_intf->dev , format , ## arg)
 
 
 
 
 35#define usb_dbg(instance, format, arg...)	\
 36	dev_dbg(&(instance)->usb_intf->dev , format , ## arg)
 
 37
 38/* FIXME: move to dev_* once ATM is driver model aware */
 39#define atm_printk(level, instance, format, arg...)	\
 40	printk(level "ATM dev %d: " format ,		\
 41	(instance)->atm_dev->number , ## arg)
 42
 43#define atm_err(instance, format, arg...)	\
 44	atm_printk(KERN_ERR, instance , format , ## arg)
 45#define atm_info(instance, format, arg...)	\
 46	atm_printk(KERN_INFO, instance , format , ## arg)
 47#define atm_warn(instance, format, arg...)	\
 48	atm_printk(KERN_WARNING, instance , format , ## arg)
 49#define atm_dbg(instance, format, ...)					\
 50	pr_debug("ATM dev %d: " format,					\
 51		 (instance)->atm_dev->number, ##__VA_ARGS__)
 52#define atm_rldbg(instance, format, ...)				\
 53	pr_debug_ratelimited("ATM dev %d: " format,			\
 54			     (instance)->atm_dev->number, ##__VA_ARGS__)
 
 
 
 
 
 
 
 55
 56/* flags, set by mini-driver in bind() */
 57
 58#define UDSL_SKIP_HEAVY_INIT	(1<<0)
 59#define UDSL_USE_ISOC		(1<<1)
 60#define UDSL_IGNORE_EILSEQ	(1<<2)
 61
 62
 63/* mini driver */
 64
 65struct usbatm_data;
 66
 67/*
 68*  Assuming all methods exist and succeed, they are called in this order:
 69*
 70*	bind, heavy_init, atm_start, ..., atm_stop, unbind
 71*/
 72
 73struct usbatm_driver {
 74	const char *driver_name;
 75
 76	/* init device ... can sleep, or cause probe() failure */
 77	int (*bind) (struct usbatm_data *, struct usb_interface *,
 78		     const struct usb_device_id *id);
 79
 80	/* additional device initialization that is too slow to be done in probe() */
 81	int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
 82
 83	/* cleanup device ... can sleep, but can't fail */
 84	void (*unbind) (struct usbatm_data *, struct usb_interface *);
 85
 86	/* init ATM device ... can sleep, or cause ATM initialization failure */
 87	int (*atm_start) (struct usbatm_data *, struct atm_dev *);
 88
 89	/* cleanup ATM device ... can sleep, but can't fail */
 90	void (*atm_stop) (struct usbatm_data *, struct atm_dev *);
 91
 92	int bulk_in;	/* bulk rx endpoint */
 93	int isoc_in;	/* isochronous rx endpoint */
 94	int bulk_out;	/* bulk tx endpoint */
 95
 96	unsigned rx_padding;
 97	unsigned tx_padding;
 98};
 99
100extern int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
101		struct usbatm_driver *driver);
102extern void usbatm_usb_disconnect(struct usb_interface *intf);
103
104
105struct usbatm_channel {
106	int endpoint;			/* usb pipe */
107	unsigned int stride;		/* ATM cell size + padding */
108	unsigned int buf_size;		/* urb buffer size */
109	unsigned int packet_size;	/* endpoint maxpacket */
110	spinlock_t lock;
111	struct list_head list;
112	struct tasklet_struct tasklet;
113	struct timer_list delay;
114	struct usbatm_data *usbatm;
115};
116
117/* main driver data */
118
119struct usbatm_data {
120	/******************
121	*  public fields  *
122	******************/
123
124	/* mini driver */
125	struct usbatm_driver *driver;
126	void *driver_data;
127	char driver_name[16];
128	unsigned int flags; /* set by mini-driver in bind() */
129
130	/* USB device */
131	struct usb_device *usb_dev;
132	struct usb_interface *usb_intf;
133	char description[64];
134
135	/* ATM device */
136	struct atm_dev *atm_dev;
137
138	/********************************
139	*  private fields - do not use  *
140	********************************/
141
142	struct kref refcount;
143	struct mutex serialize;
144	int disconnected;
145
146	/* heavy init */
147	struct task_struct *thread;
148	struct completion thread_started;
149	struct completion thread_exited;
150
151	/* ATM device */
152	struct list_head vcc_list;
153
154	struct usbatm_channel rx_channel;
155	struct usbatm_channel tx_channel;
156
157	struct sk_buff_head sndqueue;
158	struct sk_buff *current_skb;	/* being emptied */
159
160	struct usbatm_vcc_data *cached_vcc;
161	int cached_vci;
162	short cached_vpi;
163
164	unsigned char *cell_buf;	/* holds partial rx cell */
165	unsigned int buf_usage;
166
167	struct urb *urbs[];
168};
169
170static inline void *to_usbatm_driver_data(struct usb_interface *intf)
171{
172	struct usbatm_data *usbatm_instance;
173
174	if (intf == NULL)
175		return NULL;
176
177	usbatm_instance = usb_get_intfdata(intf);
178
179	if (usbatm_instance == NULL) /* set NULL before unbind() */
180		return NULL;
181
182	return usbatm_instance->driver_data; /* set NULL after unbind() */
183}
184
185#endif	/* _USBATM_H_ */
v3.1
 
  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/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>
 
 37
 38/*
 39#define VERBOSE_DEBUG
 40*/
 41
 42#ifdef DEBUG
 43#define UDSL_ASSERT(instance, x)	BUG_ON(!(x))
 44#else
 45#define UDSL_ASSERT(instance, x)					\
 46	do {	\
 47		if (!(x))						\
 48			dev_warn(&(instance)->usb_intf->dev,		\
 49				 "failed assertion '%s' at line %d",	\
 50				 __stringify(x), __LINE__);		\
 51	} 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#ifdef DEBUG
 61#define usb_dbg(instance, format, arg...)	\
 62	dev_printk(KERN_DEBUG , &(instance)->usb_intf->dev , format , ## arg)
 63#else
 64#define usb_dbg(instance, format, arg...)	\
 65	do {} while (0)
 66#endif
 67
 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)
 72
 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)
 79#ifdef DEBUG
 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)
 85#else
 86#define atm_dbg(instance, format, arg...)	\
 87	do {} while (0)
 88#define atm_rldbg(instance, format, arg...)	\
 89	do {} while (0)
 90#endif
 91
 92
 93/* flags, set by mini-driver in bind() */
 94
 95#define UDSL_SKIP_HEAVY_INIT	(1<<0)
 96#define UDSL_USE_ISOC		(1<<1)
 97#define UDSL_IGNORE_EILSEQ	(1<<2)
 98
 99
100/* mini driver */
101
102struct usbatm_data;
103
104/*
105*  Assuming all methods exist and succeed, they are called in this order:
106*
107*	bind, heavy_init, atm_start, ..., atm_stop, unbind
108*/
109
110struct usbatm_driver {
111	const char *driver_name;
112
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);
116
117	/* additional device initialization that is too slow to be done in probe() */
118	int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
119
120	/* cleanup device ... can sleep, but can't fail */
121	void (*unbind) (struct usbatm_data *, struct usb_interface *);
122
123	/* init ATM device ... can sleep, or cause ATM initialization failure */
124	int (*atm_start) (struct usbatm_data *, struct atm_dev *);
125
126	/* cleanup ATM device ... can sleep, but can't fail */
127	void (*atm_stop) (struct usbatm_data *, struct atm_dev *);
128
129	int bulk_in;	/* bulk rx endpoint */
130	int isoc_in;	/* isochronous rx endpoint */
131	int bulk_out;	/* bulk tx endpoint */
132
133	unsigned rx_padding;
134	unsigned tx_padding;
135};
136
137extern int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
138		struct usbatm_driver *driver);
139extern void usbatm_usb_disconnect(struct usb_interface *intf);
140
141
142struct 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 */
147	spinlock_t lock;
148	struct list_head list;
149	struct tasklet_struct tasklet;
150	struct timer_list delay;
151	struct usbatm_data *usbatm;
152};
153
154/* main driver data */
155
156struct usbatm_data {
157	/******************
158	*  public fields  *
159	******************/
160
161	/* mini driver */
162	struct usbatm_driver *driver;
163	void *driver_data;
164	char driver_name[16];
165	unsigned int flags; /* set by mini-driver in bind() */
166
167	/* USB device */
168	struct usb_device *usb_dev;
169	struct usb_interface *usb_intf;
170	char description[64];
171
172	/* ATM device */
173	struct atm_dev *atm_dev;
174
175	/********************************
176	*  private fields - do not use  *
177	********************************/
178
179	struct kref refcount;
180	struct mutex serialize;
181	int disconnected;
182
183	/* heavy init */
184	struct task_struct *thread;
185	struct completion thread_started;
186	struct completion thread_exited;
187
188	/* ATM device */
189	struct list_head vcc_list;
190
191	struct usbatm_channel rx_channel;
192	struct usbatm_channel tx_channel;
193
194	struct sk_buff_head sndqueue;
195	struct sk_buff *current_skb;	/* being emptied */
196
197	struct usbatm_vcc_data *cached_vcc;
198	int cached_vci;
199	short cached_vpi;
200
201	unsigned char *cell_buf;	/* holds partial rx cell */
202	unsigned int buf_usage;
203
204	struct urb *urbs[0];
205};
206
207static inline void *to_usbatm_driver_data(struct usb_interface *intf)
208{
209	struct usbatm_data *usbatm_instance;
210
211	if (intf == NULL)
212		return NULL;
213
214	usbatm_instance = usb_get_intfdata(intf);
215
216	if (usbatm_instance == NULL) /* set NULL before unbind() */
217		return NULL;
218
219	return usbatm_instance->driver_data; /* set NULL after unbind() */
220}
221
222#endif	/* _USBATM_H_ */