speedtch cxacru2.c,1.1,1.2 speedtch2.c,1.1,1.2 usbatm2.c,1.1,1.2
Duncan Sands
duncan at infradead.org
Thu Jan 20 16:58:10 EST 2005
- Previous message: usbatm cxacru.c,1.4,1.5
- Next message: speedtch cxacru2.h, 1.1, 1.2 speedtch2.c, 1.2, 1.3 speedtch2.h, 1.1,
1.2 usbatm2.c, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/speedtch
In directory phoenix.infradead.org:/tmp/cvs-serv17281
Modified Files:
cxacru2.c speedtch2.c usbatm2.c
Log Message:
Further progess in my attempt to annoy Roman :)
Index: cxacru2.c
===================================================================
RCS file: /home/cvs/speedtch/cxacru2.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cxacru2.c 20 Jan 2005 16:04:20 -0000 1.1
+++ cxacru2.c 20 Jan 2005 21:58:06 -0000 1.2
@@ -39,7 +39,7 @@
#include <linux/init.h>
#include <linux/firmware.h>
-#include "usb_atm.h"
+#include "cxacru2.h"
#if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
# define USE_FW_LOADER
@@ -160,7 +160,7 @@
};
struct cxacru_instance_data {
- struct udsl_instance_data u;
+ struct usbatm_data u;
struct semaphore start_serialize;
#ifdef USE_FW_LOADER
Index: speedtch2.c
===================================================================
RCS file: /home/cvs/speedtch/speedtch2.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- speedtch2.c 20 Jan 2005 16:04:20 -0000 1.1
+++ speedtch2.c 20 Jan 2005 21:58:06 -0000 1.2
@@ -42,7 +42,6 @@
#include <linux/init.h>
#include <linux/firmware.h>
-#include "usb_atm.h"
#include "speedtch2.h"
#if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
@@ -94,7 +93,7 @@
#define hex2int(c) ( (c >= '0') && (c <= '9') ? (c - '0') : ((c & 0xf) + 9) )
struct speedtch_instance_data {
- struct udsl_instance_data u;
+ struct usbatm_data u;
/* Status */
struct urb *int_urb;
@@ -662,7 +661,7 @@
speedtch_got_firmware(instance, 0);
}
-static int speedtch_firmware_wait(struct udsl_instance_data *instance)
+static int speedtch_firmware_wait(struct usbatm_data *instance)
{
speedtch_firmware_start((void *)instance);
Index: usbatm2.c
===================================================================
RCS file: /home/cvs/speedtch/usbatm2.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- usbatm2.c 20 Jan 2005 16:04:20 -0000 1.1
+++ usbatm2.c 20 Jan 2005 21:58:06 -0000 1.2
@@ -85,7 +85,7 @@
#include <linux/firmware.h>
#include <linux/config.h>
-#include "usb_atm.h"
+#include "usbatm.h"
#ifdef CONFIG_USB_SPEEDTOUCH
#include "speedtch2.h"
@@ -112,6 +112,50 @@
static const char driver_name[] = "usbatm";
+#define UDSL_MAX_RCV_URBS 4
+#define UDSL_MAX_SND_URBS 4
+#define UDSL_MAX_RCV_BUFS 8
+#define UDSL_MAX_SND_BUFS 8
+#define UDSL_MAX_RCV_BUF_SIZE 1024 /* ATM cells */
+#define UDSL_MAX_SND_BUF_SIZE 1024 /* ATM cells */
+#define UDSL_DEFAULT_RCV_URBS 2
+#define UDSL_DEFAULT_SND_URBS 2
+#define UDSL_DEFAULT_RCV_BUFS 4
+#define UDSL_DEFAULT_SND_BUFS 4
+#define UDSL_DEFAULT_RCV_BUF_SIZE 64 /* ATM cells */
+#define UDSL_DEFAULT_SND_BUF_SIZE 64 /* ATM cells */
+
+#define ATM_CELL_HEADER (ATM_CELL_SIZE - ATM_CELL_PAYLOAD)
+#define UDSL_NUM_CELLS(x) (((x) + ATM_AAL5_TRAILER + ATM_CELL_PAYLOAD - 1) / ATM_CELL_PAYLOAD)
+
+
+/* receive */
+
+struct udsl_vcc_data {
+ /* vpi/vci lookup */
+ struct list_head list;
+ short vpi;
+ int vci;
+ struct atm_vcc *vcc;
+
+ /* raw cell reassembly */
+ struct sk_buff *sarb;
+};
+
+
+/* send */
+
+struct udsl_control {
+ struct atm_skb_data atm_data;
+ unsigned int num_cells;
+ unsigned int num_entire;
+ unsigned int pdu_padding;
+ unsigned char aal5_trailer[ATM_AAL5_TRAILER];
+};
+
+#define UDSL_SKB(x) ((struct udsl_control *)(x)->cb)
+
+
static unsigned int num_rcv_urbs = UDSL_DEFAULT_RCV_URBS;
static unsigned int num_snd_urbs = UDSL_DEFAULT_SND_URBS;
static unsigned int num_rcv_bufs = UDSL_DEFAULT_RCV_BUFS;
@@ -190,7 +234,7 @@
** decode **
*************/
-static inline struct udsl_vcc_data *udsl_find_vcc(struct udsl_instance_data *instance,
+static inline struct udsl_vcc_data *udsl_find_vcc(struct usbatm_data *instance,
short vpi, int vci)
{
struct udsl_vcc_data *vcc;
@@ -201,7 +245,7 @@
return NULL;
}
-static void udsl_extract_cells(struct udsl_instance_data *instance,
+static void udsl_extract_cells(struct usbatm_data *instance,
unsigned char *source, unsigned int howmany)
{
struct udsl_vcc_data *cached_vcc = NULL;
@@ -216,7 +260,7 @@
short vpi;
for (i = 0; i < howmany;
- i++, source += ATM_CELL_SIZE + instance->rcv_padding) {
+ i++, source += ATM_CELL_SIZE + instance->rx_padding) {
vpi = ((source[0] & 0x0f) << 4) | (source[1] >> 4);
vci = ((source[1] & 0x0f) << 12) | (source[2] << 4) | (source[3] >> 4);
pti = (source[3] & 0x2) != 0;
@@ -355,7 +399,7 @@
ctrl->aal5_trailer[7] = crc;
}
-static unsigned int udsl_write_cells(struct udsl_instance_data *instance,
+static unsigned int udsl_write_cells(struct usbatm_data *instance,
unsigned int howmany, struct sk_buff *skb,
unsigned char **target_p)
{
@@ -373,9 +417,9 @@
target += ATM_CELL_HEADER;
memcpy(target, skb->data, ATM_CELL_PAYLOAD);
target += ATM_CELL_PAYLOAD;
- if (instance->snd_padding) {
- memset(target, 0, instance->snd_padding);
- target += instance->snd_padding;
+ if (instance->tx_padding) {
+ memset(target, 0, instance->tx_padding);
+ target += instance->tx_padding;
}
__skb_pull(skb, ATM_CELL_PAYLOAD);
}
@@ -399,9 +443,9 @@
goto out;
}
- if (instance->snd_padding) {
- memset(target, 0, instance->snd_padding);
- target += instance->snd_padding;
+ if (instance->tx_padding) {
+ memset(target, 0, instance->tx_padding);
+ target += instance->tx_padding;
}
udsl_fill_cell_header(target, ctrl->atm_data.vcc);
target += ATM_CELL_HEADER;
@@ -416,9 +460,9 @@
target += ATM_AAL5_TRAILER;
/* set pti bit in last cell */
*(target + 3 - ATM_CELL_SIZE) |= 0x2;
- if (instance->snd_padding) {
- memset(target, 0, instance->snd_padding);
- target += instance->snd_padding;
+ if (instance->tx_padding) {
+ memset(target, 0, instance->tx_padding);
+ target += instance->tx_padding;
}
out:
*target_p = target;
@@ -432,7 +476,7 @@
static void udsl_complete_receive(struct urb *urb, struct pt_regs *regs)
{
struct udsl_receive_buffer *buf;
- struct udsl_instance_data *instance;
+ struct usbatm_data *instance;
struct udsl_receiver *rcv;
unsigned long flags;
@@ -444,7 +488,7 @@
instance = rcv->instance;
buf = rcv->buffer;
- buf->filled_cells = urb->actual_length / (ATM_CELL_SIZE + instance->rcv_padding);
+ buf->filled_cells = urb->actual_length / (ATM_CELL_SIZE + instance->rx_padding);
vdbg("udsl_complete_receive: urb 0x%p, status %d, actual_length %d, filled_cells %u, rcv 0x%p, buf 0x%p", urb, urb->status, urb->actual_length, buf->filled_cells, rcv, buf);
@@ -462,7 +506,7 @@
static void udsl_process_receive(unsigned long data)
{
struct udsl_receive_buffer *buf;
- struct udsl_instance_data *instance = (struct udsl_instance_data *)data;
+ struct usbatm_data *instance = (struct usbatm_data *)data;
struct udsl_receiver *rcv;
int err;
@@ -485,9 +529,9 @@
rcv->buffer = buf;
usb_fill_bulk_urb(rcv->urb, instance->usb_dev,
- usb_rcvbulkpipe(instance->usb_dev, instance->data_endpoint),
+ instance->rx_endpoint,
buf->base,
- rcv_buf_size * (ATM_CELL_SIZE + instance->rcv_padding),
+ rcv_buf_size * (ATM_CELL_SIZE + instance->rx_padding),
udsl_complete_receive, rcv);
vdbg("udsl_process_receive: sending urb 0x%p, rcv 0x%p, buf 0x%p",
@@ -525,7 +569,7 @@
static void udsl_complete_send(struct urb *urb, struct pt_regs *regs)
{
- struct udsl_instance_data *instance;
+ struct usbatm_data *instance;
struct udsl_sender *snd;
unsigned long flags;
@@ -548,7 +592,7 @@
static void udsl_process_send(unsigned long data)
{
struct udsl_send_buffer *buf;
- struct udsl_instance_data *instance = (struct udsl_instance_data *)data;
+ struct usbatm_data *instance = (struct usbatm_data *)data;
struct sk_buff *skb;
struct udsl_sender *snd;
int err;
@@ -573,9 +617,9 @@
snd->buffer = buf;
usb_fill_bulk_urb(snd->urb, instance->usb_dev,
- usb_sndbulkpipe(instance->usb_dev, instance->data_endpoint),
+ instance->tx_endpoint,
buf->base,
- (snd_buf_size - buf->free_cells) * (ATM_CELL_SIZE + instance->snd_padding),
+ (snd_buf_size - buf->free_cells) * (ATM_CELL_SIZE + instance->tx_padding),
udsl_complete_send, snd);
vdbg("udsl_process_send: submitting urb 0x%p (%d cells), snd 0x%p, buf 0x%p",
@@ -644,7 +688,7 @@
goto made_progress;
}
-static void udsl_cancel_send(struct udsl_instance_data *instance,
+static void udsl_cancel_send(struct usbatm_data *instance,
struct atm_vcc *vcc)
{
struct sk_buff *skb, *n;
@@ -673,7 +717,7 @@
static int udsl_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
{
- struct udsl_instance_data *instance = vcc->dev->dev_data;
+ struct usbatm_data *instance = vcc->dev->dev_data;
int err;
vdbg("udsl_atm_send called (skb 0x%p, len %u)", skb, skb->len);
@@ -716,8 +760,8 @@
static void udsl_destroy_instance(struct kref *kref)
{
- struct udsl_instance_data *instance =
- container_of(kref, struct udsl_instance_data, refcount);
+ struct usbatm_data *instance =
+ container_of(kref, struct usbatm_data, refcount);
tasklet_kill(&instance->receive_tasklet);
tasklet_kill(&instance->send_tasklet);
@@ -725,12 +769,12 @@
kfree(instance);
}
-void udsl_get_instance(struct udsl_instance_data *instance)
+void udsl_get_instance(struct usbatm_data *instance)
{
kref_get(&instance->refcount);
}
-void udsl_put_instance(struct udsl_instance_data *instance)
+void udsl_put_instance(struct usbatm_data *instance)
{
kref_put(&instance->refcount, udsl_destroy_instance);
}
@@ -741,7 +785,7 @@
static void udsl_atm_dev_close(struct atm_dev *dev)
{
- struct udsl_instance_data *instance = dev->dev_data;
+ struct usbatm_data *instance = dev->dev_data;
dev->dev_data = NULL;
udsl_put_instance(instance);
@@ -749,7 +793,7 @@
static int udsl_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *page)
{
- struct udsl_instance_data *instance = atm_dev->dev_data;
+ struct usbatm_data *instance = atm_dev->dev_data;
int left = *pos;
if (!instance) {
@@ -807,7 +851,7 @@
static int udsl_atm_open(struct atm_vcc *vcc)
{
- struct udsl_instance_data *instance = vcc->dev->dev_data;
+ struct usbatm_data *instance = vcc->dev->dev_data;
struct udsl_vcc_data *new;
unsigned int max_pdu;
int vci = vcc->vci;
@@ -883,7 +927,7 @@
static void udsl_atm_close(struct atm_vcc *vcc)
{
- struct udsl_instance_data *instance = vcc->dev->dev_data;
+ struct usbatm_data *instance = vcc->dev->dev_data;
struct udsl_vcc_data *vcc_data = vcc->dev_data;
dbg("udsl_atm_close called");
@@ -932,22 +976,77 @@
}
}
+static int usbatm_atm_init(struct usbatm_data *instance)
+{
+ /* ATM init */
+ instance->atm_dev = atm_dev_register(instance->driver_name,
+ &udsl_atm_devops, -1, NULL);
+ if (!instance->atm_dev) {
+ dbg("usbatm_atm_init: failed to register ATM device!");
+ return -1;
+ }
+
+ instance->atm_dev->ci_range.vpi_bits = ATM_CI_MAX;
+ instance->atm_dev->ci_range.vci_bits = ATM_CI_MAX;
+ instance->atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
+
+ /* temp init ATM device, set to 128kbit */
+ instance->atm_dev->link_rate = 128 * 1000 / 424;
+
+ /* ready for ATM callbacks */
+ wmb();
+ instance->atm_dev->dev_data = instance;
+
+ return 0;
+}
+
+
/**********
** USB **
**********/
-int udsl_instance_setup(struct usb_device *dev,
- struct udsl_instance_data *instance)
+static void usbatm_heavy_init(struct usbatm_data *instance)
{
+/* to be done later QQ */
+}
+
+static int usbatm_usb_probe (struct usb_interface *intf, const struct usb_device_id *id)
+{
+ struct usb_device *dev = interface_to_usbdev(intf);
+ struct usbatm_driver *driver = (struct usbatm_driver *) id->driver_info;
+ struct usbatm_data *instance;
char *buf;
+ int error = -ENOMEM;
+ int ifnum = intf->altsetting->desc.bInterfaceNumber;
int i, length;
+ dev_dbg(&intf->dev, "trying device with vendor=0x%x, product=0x%x, ifnum %d\n", dev->descriptor.idVendor, dev->descriptor.idProduct, ifnum);
+
+ if (!driver) {
+ dev_dbg(&intf->dev, "blacklisted by %s\n", driver_name);
+ return -ENODEV;
+ }
+
+ /* instance init */
+ if (!(instance = kmalloc(sizeof(*instance), GFP_KERNEL))) {
+ dev_dbg(&intf->dev, "no memory for instance data!\n");
+ return -ENOMEM;
+ }
+
+ memset(instance, 0, sizeof(*instance));
+
kref_init(&instance->refcount); /* one for USB */
udsl_get_instance(instance); /* one for ATM */
init_MUTEX(&instance->serialize);
+ instance->driver = driver;
+
instance->usb_dev = dev;
+ instance->tx_endpoint = usb_sndbulkpipe(dev, driver->out);
+ instance->rx_endpoint = usb_rcvbulkpipe(dev, driver->in);
+ instance->tx_padding = driver->tx_padding;
+ instance->rx_padding = driver->rx_padding;
INIT_LIST_HEAD(&instance->vcc_list);
@@ -989,7 +1088,7 @@
struct udsl_receive_buffer *buf =
&(instance->receive_buffers[i]);
- buf->base = kmalloc(rcv_buf_size * (ATM_CELL_SIZE + instance->rcv_padding),
+ buf->base = kmalloc(rcv_buf_size * (ATM_CELL_SIZE + instance->rx_padding),
GFP_KERNEL);
if (!buf->base) {
dbg("udsl_usb_probe: no memory for receive buffer %d!", i);
@@ -1016,7 +1115,7 @@
for (i = 0; i < num_snd_bufs; i++) {
struct udsl_send_buffer *buf = &(instance->send_buffers[i]);
- buf->base = kmalloc(snd_buf_size * (ATM_CELL_SIZE + instance->snd_padding),
+ buf->base = kmalloc(snd_buf_size * (ATM_CELL_SIZE + instance->tx_padding),
GFP_KERNEL);
if (!buf->base) {
dbg("udsl_usb_probe: no memory for send buffer %d!", i);
@@ -1026,21 +1125,6 @@
list_add(&buf->list, &instance->spare_send_buffers);
}
- /* ATM init */
- instance->atm_dev = atm_dev_register(instance->driver_name,
- &udsl_atm_devops, -1, NULL);
- if (!instance->atm_dev) {
- dbg("udsl_usb_probe: failed to register ATM device!");
- goto fail;
- }
-
- instance->atm_dev->ci_range.vpi_bits = ATM_CI_MAX;
- instance->atm_dev->ci_range.vci_bits = ATM_CI_MAX;
- instance->atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
-
- /* temp init ATM device, set to 128kbit */
- instance->atm_dev->link_rate = 128 * 1000 / 424;
-
/* device description */
buf = instance->description;
length = sizeof(instance->description);
@@ -1064,12 +1148,18 @@
snprintf(buf, length, ")");
finish:
- /* ready for ATM callbacks */
- wmb();
- instance->atm_dev->dev_data = instance;
+ if (driver->bind && (error = driver->bind(instance, intf)) < 0)
+ goto fail;
usb_get_dev(dev);
+ if (driver->heavy_init)
+ usbatm_heavy_init(instance);
+ else if ((error = usbatm_atm_init(instance)) < 0) {
+ usb_put_dev(dev);
+ goto fail;
+ }
+
return 0;
fail:
@@ -1085,10 +1175,12 @@
for (i = 0; i < num_rcv_urbs; i++)
usb_free_urb(instance->receivers[i].urb);
- return -ENOMEM;
+ kfree (instance);
+
+ return error;
}
-void udsl_instance_disconnect(struct udsl_instance_data *instance)
+static void udsl_instance_disconnect(struct usbatm_data *instance)
{
int i;
@@ -1140,10 +1232,6 @@
shutdown_atm_dev(instance->atm_dev);
}
-EXPORT_SYMBOL_GPL(udsl_get_instance);
-EXPORT_SYMBOL_GPL(udsl_put_instance);
-EXPORT_SYMBOL_GPL(udsl_instance_setup);
-EXPORT_SYMBOL_GPL(udsl_instance_disconnect);
/***********
** init **
@@ -1211,8 +1299,8 @@
static struct usb_driver usbatm_driver = {
.owner = THIS_MODULE,
.name = driver_name,
-//QQ .probe = usbatm_probe,
-//QQ .disconnect = usbatm_disconnect,
+ .probe = usbatm_usb_probe,
+ .disconnect = usbatm_disconnect,
.id_table = products,
};
- Previous message: usbatm cxacru.c,1.4,1.5
- Next message: speedtch cxacru2.h, 1.1, 1.2 speedtch2.c, 1.2, 1.3 speedtch2.h, 1.1,
1.2 usbatm2.c, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Usbatm-commits
mailing list