2005-05-12 02:24:03 +08:00
|
|
|
/******************************************************************************
|
|
|
|
* usbatm.h - Generic USB xDSL driver core
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001, Alcatel
|
|
|
|
* Copyright (C) 2003, Duncan Sands, SolNegro, Josep Comas
|
|
|
|
* Copyright (C) 2004, David Woodhouse
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc., 59
|
|
|
|
* Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _USBATM_H_
|
|
|
|
#define _USBATM_H_
|
|
|
|
|
|
|
|
#include <linux/atm.h>
|
|
|
|
#include <linux/atmdev.h>
|
|
|
|
#include <linux/completion.h>
|
|
|
|
#include <linux/device.h>
|
2006-01-17 18:15:13 +08:00
|
|
|
#include <linux/kernel.h>
|
2005-05-12 02:24:03 +08:00
|
|
|
#include <linux/kref.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/stringify.h>
|
|
|
|
#include <linux/usb.h>
|
2006-01-13 22:52:55 +08:00
|
|
|
#include <linux/mutex.h>
|
2005-05-12 02:24:03 +08:00
|
|
|
|
2006-01-17 18:15:13 +08:00
|
|
|
/*
|
|
|
|
#define VERBOSE_DEBUG
|
|
|
|
*/
|
|
|
|
|
2005-05-12 02:24:03 +08:00
|
|
|
#ifdef DEBUG
|
2008-08-15 00:37:34 +08:00
|
|
|
#define UDSL_ASSERT(instance, x) BUG_ON(!(x))
|
2005-05-12 02:24:03 +08:00
|
|
|
#else
|
2008-08-15 00:37:34 +08:00
|
|
|
#define UDSL_ASSERT(instance, x) \
|
|
|
|
do { \
|
|
|
|
if (!(x)) \
|
|
|
|
dev_warn(&(instance)->usb_intf->dev, \
|
|
|
|
"failed assertion '%s' at line %d", \
|
|
|
|
__stringify(x), __LINE__); \
|
2010-06-17 17:55:49 +08:00
|
|
|
} while (0)
|
2005-05-12 02:24:03 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define usb_err(instance, format, arg...) \
|
|
|
|
dev_err(&(instance)->usb_intf->dev , format , ## arg)
|
|
|
|
#define usb_info(instance, format, arg...) \
|
|
|
|
dev_info(&(instance)->usb_intf->dev , format , ## arg)
|
|
|
|
#define usb_warn(instance, format, arg...) \
|
|
|
|
dev_warn(&(instance)->usb_intf->dev , format , ## arg)
|
2006-01-17 18:15:13 +08:00
|
|
|
#ifdef DEBUG
|
|
|
|
#define usb_dbg(instance, format, arg...) \
|
2010-06-17 17:55:49 +08:00
|
|
|
dev_printk(KERN_DEBUG , &(instance)->usb_intf->dev , format , ## arg)
|
2006-01-17 18:15:13 +08:00
|
|
|
#else
|
2005-05-12 02:24:03 +08:00
|
|
|
#define usb_dbg(instance, format, arg...) \
|
2006-01-17 18:15:13 +08:00
|
|
|
do {} while (0)
|
|
|
|
#endif
|
2005-05-12 02:24:03 +08:00
|
|
|
|
|
|
|
/* FIXME: move to dev_* once ATM is driver model aware */
|
|
|
|
#define atm_printk(level, instance, format, arg...) \
|
2005-05-30 16:09:06 +08:00
|
|
|
printk(level "ATM dev %d: " format , \
|
|
|
|
(instance)->atm_dev->number , ## arg)
|
2005-05-12 02:24:03 +08:00
|
|
|
|
|
|
|
#define atm_err(instance, format, arg...) \
|
|
|
|
atm_printk(KERN_ERR, instance , format , ## arg)
|
|
|
|
#define atm_info(instance, format, arg...) \
|
|
|
|
atm_printk(KERN_INFO, instance , format , ## arg)
|
|
|
|
#define atm_warn(instance, format, arg...) \
|
|
|
|
atm_printk(KERN_WARNING, instance , format , ## arg)
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define atm_dbg(instance, format, arg...) \
|
|
|
|
atm_printk(KERN_DEBUG, instance , format , ## arg)
|
2006-01-17 18:15:13 +08:00
|
|
|
#define atm_rldbg(instance, format, arg...) \
|
|
|
|
if (printk_ratelimit()) \
|
|
|
|
atm_printk(KERN_DEBUG, instance , format , ## arg)
|
2005-05-12 02:24:03 +08:00
|
|
|
#else
|
|
|
|
#define atm_dbg(instance, format, arg...) \
|
|
|
|
do {} while (0)
|
2006-01-17 18:15:13 +08:00
|
|
|
#define atm_rldbg(instance, format, arg...) \
|
|
|
|
do {} while (0)
|
2005-05-12 02:24:03 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-01-17 18:16:13 +08:00
|
|
|
/* flags, set by mini-driver in bind() */
|
|
|
|
|
|
|
|
#define UDSL_SKIP_HEAVY_INIT (1<<0)
|
2006-01-13 17:59:23 +08:00
|
|
|
#define UDSL_USE_ISOC (1<<1)
|
2006-01-13 18:12:58 +08:00
|
|
|
#define UDSL_IGNORE_EILSEQ (1<<2)
|
2006-01-17 18:16:13 +08:00
|
|
|
|
|
|
|
|
2005-05-12 02:24:03 +08:00
|
|
|
/* mini driver */
|
|
|
|
|
|
|
|
struct usbatm_data;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assuming all methods exist and succeed, they are called in this order:
|
|
|
|
*
|
2010-06-17 17:55:49 +08:00
|
|
|
* bind, heavy_init, atm_start, ..., atm_stop, unbind
|
2005-05-12 02:24:03 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct usbatm_driver {
|
|
|
|
const char *driver_name;
|
|
|
|
|
2006-01-17 18:16:13 +08:00
|
|
|
/* init device ... can sleep, or cause probe() failure */
|
2010-06-17 17:55:49 +08:00
|
|
|
int (*bind) (struct usbatm_data *, struct usb_interface *,
|
2006-01-17 18:16:13 +08:00
|
|
|
const struct usb_device_id *id);
|
2005-05-12 02:24:03 +08:00
|
|
|
|
|
|
|
/* additional device initialization that is too slow to be done in probe() */
|
2010-06-17 17:55:49 +08:00
|
|
|
int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
|
2005-05-12 02:24:03 +08:00
|
|
|
|
|
|
|
/* cleanup device ... can sleep, but can't fail */
|
2010-06-17 17:55:49 +08:00
|
|
|
void (*unbind) (struct usbatm_data *, struct usb_interface *);
|
2005-05-12 02:24:03 +08:00
|
|
|
|
|
|
|
/* init ATM device ... can sleep, or cause ATM initialization failure */
|
|
|
|
int (*atm_start) (struct usbatm_data *, struct atm_dev *);
|
|
|
|
|
|
|
|
/* cleanup ATM device ... can sleep, but can't fail */
|
|
|
|
void (*atm_stop) (struct usbatm_data *, struct atm_dev *);
|
|
|
|
|
2010-06-17 17:55:49 +08:00
|
|
|
int bulk_in; /* bulk rx endpoint */
|
|
|
|
int isoc_in; /* isochronous rx endpoint */
|
|
|
|
int bulk_out; /* bulk tx endpoint */
|
2005-05-12 02:24:03 +08:00
|
|
|
|
|
|
|
unsigned rx_padding;
|
|
|
|
unsigned tx_padding;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
|
|
|
|
struct usbatm_driver *driver);
|
|
|
|
extern void usbatm_usb_disconnect(struct usb_interface *intf);
|
|
|
|
|
|
|
|
|
|
|
|
struct usbatm_channel {
|
|
|
|
int endpoint; /* usb pipe */
|
|
|
|
unsigned int stride; /* ATM cell size + padding */
|
|
|
|
unsigned int buf_size; /* urb buffer size */
|
2006-01-13 17:59:23 +08:00
|
|
|
unsigned int packet_size; /* endpoint maxpacket */
|
2005-05-12 02:24:03 +08:00
|
|
|
spinlock_t lock;
|
|
|
|
struct list_head list;
|
|
|
|
struct tasklet_struct tasklet;
|
|
|
|
struct timer_list delay;
|
|
|
|
struct usbatm_data *usbatm;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* main driver data */
|
|
|
|
|
|
|
|
struct usbatm_data {
|
|
|
|
/******************
|
|
|
|
* public fields *
|
2010-06-17 17:55:49 +08:00
|
|
|
******************/
|
2005-05-12 02:24:03 +08:00
|
|
|
|
|
|
|
/* mini driver */
|
|
|
|
struct usbatm_driver *driver;
|
|
|
|
void *driver_data;
|
|
|
|
char driver_name[16];
|
2006-01-17 18:16:13 +08:00
|
|
|
unsigned int flags; /* set by mini-driver in bind() */
|
2005-05-12 02:24:03 +08:00
|
|
|
|
|
|
|
/* USB device */
|
|
|
|
struct usb_device *usb_dev;
|
|
|
|
struct usb_interface *usb_intf;
|
|
|
|
char description[64];
|
|
|
|
|
|
|
|
/* ATM device */
|
|
|
|
struct atm_dev *atm_dev;
|
|
|
|
|
|
|
|
/********************************
|
|
|
|
* private fields - do not use *
|
2010-06-17 17:55:49 +08:00
|
|
|
********************************/
|
2005-05-12 02:24:03 +08:00
|
|
|
|
|
|
|
struct kref refcount;
|
2006-01-13 22:52:55 +08:00
|
|
|
struct mutex serialize;
|
2006-01-13 17:05:15 +08:00
|
|
|
int disconnected;
|
2005-05-12 02:24:03 +08:00
|
|
|
|
|
|
|
/* heavy init */
|
2008-02-11 20:26:09 +08:00
|
|
|
struct task_struct *thread;
|
2005-05-12 02:24:03 +08:00
|
|
|
struct completion thread_started;
|
|
|
|
struct completion thread_exited;
|
|
|
|
|
|
|
|
/* ATM device */
|
|
|
|
struct list_head vcc_list;
|
|
|
|
|
|
|
|
struct usbatm_channel rx_channel;
|
|
|
|
struct usbatm_channel tx_channel;
|
|
|
|
|
|
|
|
struct sk_buff_head sndqueue;
|
2006-01-17 18:15:13 +08:00
|
|
|
struct sk_buff *current_skb; /* being emptied */
|
2005-05-12 02:24:03 +08:00
|
|
|
|
2006-01-13 18:06:46 +08:00
|
|
|
struct usbatm_vcc_data *cached_vcc;
|
|
|
|
int cached_vci;
|
|
|
|
short cached_vpi;
|
|
|
|
|
|
|
|
unsigned char *cell_buf; /* holds partial rx cell */
|
|
|
|
unsigned int buf_usage;
|
|
|
|
|
2005-05-12 02:24:03 +08:00
|
|
|
struct urb *urbs[0];
|
|
|
|
};
|
|
|
|
|
2009-11-21 23:33:51 +08:00
|
|
|
static inline void *to_usbatm_driver_data(struct usb_interface *intf)
|
|
|
|
{
|
|
|
|
struct usbatm_data *usbatm_instance;
|
|
|
|
|
|
|
|
if (intf == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
usbatm_instance = usb_get_intfdata(intf);
|
|
|
|
|
|
|
|
if (usbatm_instance == NULL) /* set NULL before unbind() */
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return usbatm_instance->driver_data; /* set NULL after unbind() */
|
|
|
|
}
|
|
|
|
|
2005-05-12 02:24:03 +08:00
|
|
|
#endif /* _USBATM_H_ */
|