linux/drivers/usb/atm/usbatm.c

// SPDX-License-Identifier: GPL-2.0+
/******************************************************************************
 *  usbatm.c - Generic USB xDSL driver core
 *
 *  Copyright (C) 2001, Alcatel
 *  Copyright (C) 2003, Duncan Sands, SolNegro, Josep Comas
 *  Copyright (C) 2004, David Woodhouse, Roman Kagan
 ******************************************************************************/

/*
 *  Written by Johan Verrept, Duncan Sands ([email protected]) and David Woodhouse
 *
 *  1.7+:	- See the check-in logs
 *
 *  1.6:	- No longer opens a connection if the firmware is not loaded
 *  		- Added support for the speedtouch 330
 *  		- Removed the limit on the number of devices
 *  		- Module now autoloads on device plugin
 *  		- Merged relevant parts of sarlib
 *  		- Replaced the kernel thread with a tasklet
 *  		- New packet transmission code
 *  		- Changed proc file contents
 *  		- Fixed all known SMP races
 *  		- Many fixes and cleanups
 *  		- Various fixes by Oliver Neukum ([email protected])
 *
 *  1.5A:	- Version for inclusion in 2.5 series kernel
 *		- Modifications by Richard Purdie ([email protected])
 *		- made compatible with kernel 2.5.6 onwards by changing
 *		usbatm_usb_send_data_context->urb to a pointer and adding code
 *		to alloc and free it
 *		- remove_wait_queue() added to usbatm_atm_processqueue_thread()
 *
 *  1.5:	- fixed memory leak when atmsar_decode_aal5 returned NULL.
 *		(reported by [email protected])
 *
 *  1.4:	- changed the spin_lock() under interrupt to spin_lock_irqsave()
 *		- unlink all active send urbs of a vcc that is being closed.
 *
 *  1.3.1:	- added the version number
 *
 *  1.3:	- Added multiple send urb support
 *		- fixed memory leak and vcc->tx_inuse starvation bug
 *		  when not enough memory left in vcc.
 *
 *  1.2:	- Fixed race condition in usbatm_usb_send_data()
 *  1.1:	- Turned off packet debugging
 *
 */

#include "usbatm.h"

#include <linux/uaccess.h>
#include <linux/crc32.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/netdevice.h>
#include <linux/proc_fs.h>
#include <linux/sched/signal.h>
#include <linux/signal.h>
#include <linux/slab.h>
#include <linux/stat.h>
#include <linux/timer.h>
#include <linux/wait.h>
#include <linux/kthread.h>
#include <linux/ratelimit.h>

#ifdef VERBOSE_DEBUG
static int usbatm_print_packet(struct usbatm_data *instance, const unsigned char *data, int len);
#define PACKETDEBUG
#define vdbg
#else
#define PACKETDEBUG(arg...)
#define vdbg(arg...)
#endif

#define DRIVER_AUTHOR
#define DRIVER_DESC

static const char usbatm_driver_name[] =;

#define UDSL_MAX_RCV_URBS
#define UDSL_MAX_SND_URBS
#define UDSL_MAX_BUF_SIZE
#define UDSL_DEFAULT_RCV_URBS
#define UDSL_DEFAULT_SND_URBS
#define UDSL_DEFAULT_RCV_BUF_SIZE
#define UDSL_DEFAULT_SND_BUF_SIZE

#define ATM_CELL_HEADER

#define THROTTLE_MSECS

static unsigned int num_rcv_urbs =;
static unsigned int num_snd_urbs =;
static unsigned int rcv_buf_bytes =;
static unsigned int snd_buf_bytes =;

module_param(num_rcv_urbs, uint, S_IRUGO);
MODULE_PARM_DESC();

module_param(num_snd_urbs, uint, S_IRUGO);
MODULE_PARM_DESC();

module_param(rcv_buf_bytes, uint, S_IRUGO);
MODULE_PARM_DESC();

module_param(snd_buf_bytes, uint, S_IRUGO);
MODULE_PARM_DESC();


/* receive */

struct usbatm_vcc_data {};


/* send */

struct usbatm_control {};

#define UDSL_SKB(x)


/* ATM */

static void usbatm_atm_dev_close(struct atm_dev *atm_dev);
static int usbatm_atm_open(struct atm_vcc *vcc);
static void usbatm_atm_close(struct atm_vcc *vcc);
static int usbatm_atm_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void __user *arg);
static int usbatm_atm_send(struct atm_vcc *vcc, struct sk_buff *skb);
static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t *pos, char *page);

static const struct atmdev_ops usbatm_atm_devops =;


/***********
**  misc  **
***********/

static inline unsigned int usbatm_pdu_length(unsigned int length)
{}

static inline void usbatm_pop(struct atm_vcc *vcc, struct sk_buff *skb)
{}


/***********
**  urbs  **
************/

static struct urb *usbatm_pop_urb(struct usbatm_channel *channel)
{}

static int usbatm_submit_urb(struct urb *urb)
{}

static void usbatm_complete(struct urb *urb)
{}


/*************
**  decode  **
*************/

static inline struct usbatm_vcc_data *usbatm_find_vcc(struct usbatm_data *instance,
						  short vpi, int vci)
{}

static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char *source)
{}

static void usbatm_extract_cells(struct usbatm_data *instance,
		unsigned char *source, unsigned int avail_data)
{}


/*************
**  encode  **
*************/

static unsigned int usbatm_write_cells(struct usbatm_data *instance,
				       struct sk_buff *skb,
				       u8 *target, unsigned int avail_space)
{}


/**************
**  receive  **
**************/

static void usbatm_rx_process(struct tasklet_struct *t)
{}


/***********
**  send  **
***********/

static void usbatm_tx_process(struct tasklet_struct *t)
{}

static void usbatm_cancel_send(struct usbatm_data *instance,
			       struct atm_vcc *vcc)
{}

static int usbatm_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
{}


/********************
**  bean counting  **
********************/

static void usbatm_destroy_instance(struct kref *kref)
{}

static void usbatm_get_instance(struct usbatm_data *instance)
{}

static void usbatm_put_instance(struct usbatm_data *instance)
{}


/**********
**  ATM  **
**********/

static void usbatm_atm_dev_close(struct atm_dev *atm_dev)
{}

static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t *pos, char *page)
{}

static int usbatm_atm_open(struct atm_vcc *vcc)
{}

static void usbatm_atm_close(struct atm_vcc *vcc)
{}

static int usbatm_atm_ioctl(struct atm_dev *atm_dev, unsigned int cmd,
			  void __user *arg)
{}

static int usbatm_atm_init(struct usbatm_data *instance)
{}


/**********
**  USB  **
**********/

static int usbatm_do_heavy_init(void *arg)
{}

static int usbatm_heavy_init(struct usbatm_data *instance)
{}

static void usbatm_tasklet_schedule(struct timer_list *t)
{}

static void usbatm_init_channel(struct usbatm_channel *channel)
{}

int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
		     struct usbatm_driver *driver)
{}
EXPORT_SYMBOL_GPL();

void usbatm_usb_disconnect(struct usb_interface *intf)
{}
EXPORT_SYMBOL_GPL();


/***********
**  init  **
***********/

static int __init usbatm_usb_init(void)
{}
module_init();

static void __exit usbatm_usb_exit(void)
{}
module_exit(usbatm_usb_exit);

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

/************
**  debug  **
************/

#ifdef VERBOSE_DEBUG
static int usbatm_print_packet(struct usbatm_data *instance,
			       const unsigned char *data, int len)
{
	unsigned char buffer[256];
	int i = 0, j = 0;

	for (i = 0; i < len;) {
		buffer[0] = '\0';
		sprintf(buffer, "%.3d :", i);
		for (j = 0; (j < 16) && (i < len); j++, i++)
			sprintf(buffer, "%s %2.2x", buffer, data[i]);
		dev_dbg(&instance->usb_intf->dev, "%s", buffer);
	}
	return i;
}
#endif