~ubuntu-branches/debian/sid/acx100/sid

« back to all changes in this revision

Viewing changes to src/acx100_usb.c

  • Committer: Bazaar Package Importer
  • Author(s): Miguel Gea Milvaques
  • Date: 2005-04-13 23:36:11 UTC
  • Revision ID: james.westby@ubuntu.com-20050413233611-5ec8mnua3b9k3t4u
Tags: upstream-0.2.0pre8+52
ImportĀ upstreamĀ versionĀ 0.2.0pre8+52

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  - USB main module functions
 
2
 *
 
3
 * --------------------------------------------------------------------
 
4
 *
 
5
 * Copyright (C) 2003  ACX100 Open Source Project
 
6
 *
 
7
 *   The contents of this file are subject to the Mozilla Public
 
8
 *   License Version 1.1 (the "License"); you may not use this file
 
9
 *   except in compliance with the License. You may obtain a copy of
 
10
 *   the License at http://www.mozilla.org/MPL/
 
11
 *
 
12
 *   Software distributed under the License is distributed on an "AS
 
13
 *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
14
 *   implied. See the License for the specific language governing
 
15
 *   rights and limitations under the License.
 
16
 *
 
17
 *   Alternatively, the contents of this file may be used under the
 
18
 *   terms of the GNU Public License version 2 (the "GPL"), in which
 
19
 *   case the provisions of the GPL are applicable instead of the
 
20
 *   above.  If you wish to allow the use of your version of this file
 
21
 *   only under the terms of the GPL and not to allow others to use
 
22
 *   your version of this file under the MPL, indicate your decision
 
23
 *   by deleting the provisions above and replace them with the notice
 
24
 *   and other provisions required by the GPL.  If you do not delete
 
25
 *   the provisions above, a recipient may use your version of this
 
26
 *   file under either the MPL or the GPL.
 
27
 *
 
28
 * --------------------------------------------------------------------
 
29
 *
 
30
 * Inquiries regarding the ACX100 Open Source Project can be
 
31
 * made directly to:
 
32
 *
 
33
 * acx100-users@lists.sf.net
 
34
 * http://acx100.sf.net
 
35
 *
 
36
 * --------------------------------------------------------------------
 
37
 * USB support for TI ACX100 based devices. Many parts are taken from
 
38
 * the PCI driver.
 
39
 *
 
40
 * Authors:
 
41
 *  Martin Wawro <martin.wawro AT uni-dortmund.de>
 
42
 *  Andreas Mohr <andi AT lisas.de>
 
43
 *
 
44
 * Issues:
 
45
 *  - Note that this driver relies on a native little-endian byteformat
 
46
 *    at some points
 
47
 *
 
48
 *
 
49
*/
 
50
 
 
51
/* -------------------------------------------------------------------------
 
52
**                      Linux Kernel Header Files
 
53
** ---------------------------------------------------------------------- */
 
54
 
 
55
#include <version.h>
 
56
#include <linux/version.h>
 
57
#include <linux/config.h>
 
58
#include <linux/types.h>
 
59
#include <linux/module.h>
 
60
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
 
61
#include <linux/moduleparam.h>
 
62
#endif
 
63
#include <linux/kernel.h>
 
64
#include <linux/usb.h>
 
65
#include <linux/netdevice.h>
 
66
#include <linux/rtnetlink.h>
 
67
#include <linux/etherdevice.h>
 
68
#include <linux/wireless.h>
 
69
#if WIRELESS_EXT >= 13
 
70
#include <net/iw_handler.h>
 
71
#endif
 
72
#include <linux/vmalloc.h>
 
73
#include <linux/interrupt.h>
 
74
#include <asm/uaccess.h>
 
75
#include <asm/byteorder.h>
 
76
 
 
77
/* -------------------------------------------------------------------------
 
78
**                         Project Header Files
 
79
** ---------------------------------------------------------------------- */
 
80
 
 
81
/* FIXME: integrate nicely into src/Makefile at the time it is clear which
 
82
 * other source files from the PCI / CardBus driver have to be linked with this
 
83
 * one and therefore _also_ need this define - until then this hack is ok */
 
84
#undef WLAN_HOSTIF
 
85
#define WLAN_HOSTIF WLAN_USB
 
86
 
 
87
#include <acx.h>
 
88
 
 
89
/* try to make it compile for both 2.4.x and 2.6.x kernels */
 
90
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0)
 
91
 
 
92
/* number of endpoints of an interface */
 
93
#define NUM_EP(intf) (intf)->altsetting[0].desc.bNumEndpoints
 
94
#define EP(intf,nr) (intf)->altsetting[0].endpoint[(nr)].desc
 
95
#define GET_DEV(udev) usb_get_dev((udev))
 
96
#define PUT_DEV(udev) usb_put_dev((udev))
 
97
#define SET_NETDEV_OWNER(ndev,owner) /* not needed anymore ??? */
 
98
 
 
99
#define ASYNC_UNLINK    URB_ASYNC_UNLINK
 
100
#define QUEUE_BULK      0
 
101
#define ZERO_PACKET     URB_ZERO_PACKET
 
102
 
 
103
/* For GFP_KERNEL vs. GFP_ATOMIC, see
 
104
 * http://groups.google.de/groups?th=6cd2e5f77e799a23&seekm=linux.scsi.OF9C38FD78.07E54601-ON87256C24.0056B509%40boulder.ibm.com
 
105
 * Basically GFP_KERNEL waits until an alloc succeeds, while
 
106
 * GFP_ATOMIC should be used in situations where we need to know
 
107
 * the result immediately, since we cannot wait (in case we're within lock
 
108
 * or so) */
 
109
static inline int submit_urb(struct urb *urb, int mem_flags) {
 
110
        return usb_submit_urb(urb, mem_flags);
 
111
}
 
112
static inline struct urb *alloc_urb(int iso_pk, int mem_flags) {
 
113
        return usb_alloc_urb(iso_pk, mem_flags);
 
114
}
 
115
 
 
116
#else
 
117
 
 
118
/* 2.4.x kernels */
 
119
#define USB_24  1
 
120
 
 
121
#define NUM_EP(intf) (intf)->altsetting[0].bNumEndpoints
 
122
#define EP(intf,nr) (intf)->altsetting[0].endpoint[(nr)]
 
123
 
 
124
#define GET_DEV(udev) usb_inc_dev_use((udev))
 
125
#define PUT_DEV(udev) usb_dec_dev_use((udev))
 
126
 
 
127
#ifndef SET_NETDEV_DEV
 
128
#define SET_NETDEV_DEV(x,y)
 
129
#endif
 
130
#define SET_NETDEV_OWNER(ndev,owner) ndev->owner = owner
 
131
 
 
132
#define ASYNC_UNLINK    USB_ASYNC_UNLINK
 
133
#define QUEUE_BULK      USB_QUEUE_BULK
 
134
#define ZERO_PACKET     USB_ZERO_PACKET
 
135
 
 
136
static inline int submit_urb(struct urb *urb, int mem_flags) {
 
137
        return usb_submit_urb(urb);
 
138
}
 
139
static inline struct urb *alloc_urb(int iso_pk, int mem_flags) {
 
140
        return usb_alloc_urb(iso_pk);
 
141
}
 
142
 
 
143
static inline void usb_set_intfdata(struct usb_interface *intf, void *data) {}
 
144
 
 
145
#endif /* #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) */
 
146
 
 
147
/* -------------------------------------------------------------------------
 
148
**                             Module Stuff
 
149
** ---------------------------------------------------------------------- */
 
150
 
 
151
char *firmware_dir;
 
152
 
 
153
#if ACX_DEBUG
 
154
/* unsigned int debug = L_DEBUG|L_ASSOC|L_INIT|L_STD; */
 
155
unsigned int debug = L_STD; 
 
156
#endif
 
157
 
 
158
#ifdef MODULE_LICENSE
 
159
MODULE_LICENSE("Dual MPL/GPL");
 
160
#endif
 
161
MODULE_AUTHOR("Martin Wawro <martin.wawro AT uni-dortmund.de>");
 
162
MODULE_DESCRIPTION("TI ACX100 WLAN USB Driver");
 
163
 
 
164
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
 
165
#if ACX_DEBUG
 
166
module_param(debug, uint, 0);
 
167
#endif
 
168
module_param(firmware_dir, charp, 0);
 
169
#else
 
170
#if ACX_DEBUG
 
171
MODULE_PARM(debug, "i");
 
172
#endif
 
173
MODULE_PARM(firmware_dir, "s");
 
174
#endif
 
175
 
 
176
MODULE_PARM_DESC(debug, "Debug level mask: 0x0000 - 0x3fff");
 
177
MODULE_PARM_DESC(firmware_dir, "Directory to load acx100 firmware files from");
 
178
 
 
179
/* -------------------------------------------------------------------------
 
180
**                Module Definitions (preprocessor based)
 
181
** ---------------------------------------------------------------------- */
 
182
 
 
183
 
 
184
#define SHORTNAME "acx_usb: "
 
185
 
 
186
#define ACX100_VENDOR_ID 0x2001
 
187
#define ACX100_PRODUCT_ID_UNBOOTED 0x3B01
 
188
#define ACX100_PRODUCT_ID_BOOTED 0x3B00
 
189
 
 
190
/* RX-Timeout: NONE (request waits forever) */
 
191
#define ACX100_USB_RX_TIMEOUT (0)    
 
192
 
 
193
#define ACX100_USB_TX_TIMEOUT (4*HZ)
 
194
 
 
195
 
 
196
/* -------------------------------------------------------------------------
 
197
**                        Module Data Structures
 
198
** ---------------------------------------------------------------------- */
 
199
 
 
200
typedef struct {
 
201
        void *device;
 
202
        int number;
 
203
} acx_usb_bulk_context_t;
 
204
 
 
205
 
 
206
/* -------------------------------------------------------------------------
 
207
**                          Module Prototypes
 
208
** ---------------------------------------------------------------------- */
 
209
 
 
210
#if USB_24
 
211
static void * acx100usb_probe(struct usb_device *, unsigned int, const struct usb_device_id *);
 
212
static void acx100usb_disconnect(struct usb_device *,void *);
 
213
static void acx100usb_complete_tx(struct urb *);
 
214
static void acx100usb_complete_rx(struct urb *);
 
215
#else
 
216
static int acx100usb_probe(struct usb_interface *, const struct usb_device_id *);
 
217
static void acx100usb_disconnect(struct usb_interface *);
 
218
static void acx100usb_complete_tx(struct urb *, struct pt_regs *);
 
219
static void acx100usb_complete_rx(struct urb *, struct pt_regs *);
 
220
#endif
 
221
static int acx100usb_open(struct net_device *);
 
222
static int acx100usb_close(struct net_device *);
 
223
static int acx100usb_start_xmit(struct sk_buff *,struct net_device *);
 
224
static void acx100usb_set_rx_mode(struct net_device *);
 
225
static int init_network_device(struct net_device *);
 
226
static int acx100usb_boot(struct usb_device *);
 
227
void acx100usb_tx_data(wlandevice_t *,struct txdescriptor *);
 
228
static void acx100usb_prepare_tx(wlandevice_t *,struct txdescriptor *);
 
229
static void acx100usb_trigger_next_tx(wlandevice_t *);
 
230
 
 
231
static struct net_device_stats * acx_get_stats(struct net_device *);
 
232
static struct iw_statistics *acx_get_wireless_stats(struct net_device *);
 
233
 
 
234
 
 
235
static void acx100usb_poll_rx(wlandevice_t *,int number);
 
236
void acx_rx(struct rxhostdescriptor *,wlandevice_t *);
 
237
 
 
238
int init_module(void);
 
239
void cleanup_module(void);
 
240
 
 
241
#ifdef HAVE_TX_TIMEOUT
 
242
static void acx100usb_tx_timeout(struct net_device *);
 
243
#endif
 
244
 
 
245
int txbufsize;
 
246
int rxbufsize;
 
247
#if ACX_DEBUG
 
248
static char * acx100usb_pstatus(int);
 
249
extern void acx_dump_bytes(void *,int);
 
250
static void dump_device(struct usb_device *);
 
251
static void dump_device_descriptor(struct usb_device_descriptor *);
 
252
#if USB_24
 
253
static void dump_endpoint_descriptor(struct usb_endpoint_descriptor *);
 
254
static void dump_interface_descriptor(struct usb_interface_descriptor *);
 
255
#endif
 
256
static void dump_config_descriptor(struct usb_config_descriptor *);
 
257
/* static void acx100usb_printsetup(devrequest *); */
 
258
/* static void acx100usb_printcmdreq(struct acx100_usb_cmdreq *) __attribute__((__unused__)); */
 
259
#endif
 
260
 
 
261
/* -------------------------------------------------------------------------
 
262
**                             Module Data
 
263
** ---------------------------------------------------------------------- */
 
264
 
 
265
/* FIXME: static variable, big no-no!! might disrupt operation of two USB
 
266
 * adapters at the same time! */
 
267
static int disconnected=0;
 
268
 
 
269
extern const struct iw_handler_def acx_ioctl_handler_def;
 
270
 
 
271
static const struct usb_device_id acx100usb_ids[] = {
 
272
   { USB_DEVICE(ACX100_VENDOR_ID, ACX100_PRODUCT_ID_BOOTED) },
 
273
   { USB_DEVICE(ACX100_VENDOR_ID, ACX100_PRODUCT_ID_UNBOOTED) },
 
274
   { }
 
275
};
 
276
 
 
277
 
 
278
/* USB driver data structure as required by the kernel's USB core */
 
279
 
 
280
static struct usb_driver acx100usb_driver = {
 
281
  .name = "acx_usb",                       /* name of the driver */
 
282
  .probe = acx100usb_probe,                /* pointer to probe() procedure */
 
283
  .disconnect = acx100usb_disconnect,      /* pointer to disconnect() procedure */
 
284
  .id_table = acx100usb_ids
 
285
};
 
286
 
 
287
 
 
288
acx_usb_bulk_context_t rxcons[ACX100_USB_NUM_BULK_URBS];
 
289
acx_usb_bulk_context_t txcons[ACX100_USB_NUM_BULK_URBS];
 
290
 
 
291
 
 
292
/* ---------------------------------------------------------------------------
 
293
** acx100usb_probe():
 
294
** Inputs:
 
295
**    dev -> Pointer to usb_device structure that may or may not be claimed
 
296
**  ifNum -> Interface number
 
297
**  devID -> Device ID (vendor and product specific stuff)
 
298
** ---------------------------------------------------------------------------
 
299
** Returns:
 
300
**  (void *) Pointer to (custom) driver context or NULL if we are not interested
 
301
**           or unable to handle the offered device.
 
302
**
 
303
** Description:
 
304
**  This function is invoked by the kernel's USB core whenever a new device is
 
305
**  attached to the system or the module is loaded. It is presented a usb_device
 
306
**  structure from which information regarding the device is obtained and evaluated.
 
307
**  In case this driver is able to handle one of the offered devices, it returns
 
308
**  a non-null pointer to a driver context and thereby claims the device.
 
309
** ------------------------------------------------------------------------ */
 
310
 
 
311
#if USB_24
 
312
#define OUTOFMEM        NULL
 
313
static void * acx100usb_probe(struct usb_device *usbdev,unsigned int ifNum,const struct usb_device_id *devID)
 
314
{
 
315
#else
 
316
#define OUTOFMEM        -ENOMEM
 
317
static int acx100usb_probe(struct usb_interface *intf, const struct usb_device_id *devID)
 
318
{
 
319
        struct usb_device *usbdev = interface_to_usbdev(intf);
 
320
#endif
 
321
        wlandevice_t *priv;
 
322
        struct net_device *dev=NULL;
 
323
        int numconfigs,numfaces,result;
 
324
        struct usb_config_descriptor *config;
 
325
        struct usb_endpoint_descriptor *epdesc;
 
326
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
 
327
        struct usb_host_endpoint *ep;
 
328
#endif
 
329
        struct usb_interface_descriptor *ifdesc;
 
330
        int i,j,numep;
 
331
#if USB_24
 
332
        void *res = NULL;
 
333
#else
 
334
        int res = 0;
 
335
#endif
 
336
 
 
337
        FN_ENTER;
 
338
        /* ---------------------------------------------
 
339
        ** First check if this is the "unbooted" hardware
 
340
        ** --------------------------------------------- */
 
341
        if ((usbdev->descriptor.idVendor==ACX100_VENDOR_ID)&&(usbdev->descriptor.idProduct==ACX100_PRODUCT_ID_UNBOOTED)) {
 
342
                /* ---------------------------------------------
 
343
                ** Boot the device (i.e. upload the firmware)
 
344
                ** --------------------------------------------- */
 
345
                acx100usb_boot(usbdev);
 
346
                /* ---------------------------------------------
 
347
                ** OK, we are done with booting. Normally, the
 
348
                ** ID for the unbooted device should disappear
 
349
                ** and it will not need a driver anyway...so
 
350
                ** return a NULL
 
351
                ** --------------------------------------------- */
 
352
                acxlog(L_INIT, "Finished booting, returning from probe().\n");
 
353
#if USB_24
 
354
                res = NULL;
 
355
#else
 
356
                res = 0; /* is that ok?? */
 
357
#endif
 
358
                goto end;
 
359
        }
 
360
        if ((usbdev->descriptor.idVendor==ACX100_VENDOR_ID)&&(usbdev->descriptor.idProduct==ACX100_PRODUCT_ID_BOOTED)) {
 
361
                /* ---------------------------------------------
 
362
                ** allocate memory for the device driver context
 
363
                ** --------------------------------------------- */
 
364
                priv = kmalloc(sizeof(struct wlandevice),GFP_KERNEL);
 
365
                if (!priv) {
 
366
                        printk(KERN_WARNING SHORTNAME ": could not allocate %d bytes memory for device driver context, giving up.\n",sizeof(struct wlandevice));
 
367
                        res = OUTOFMEM;
 
368
                        goto end;
 
369
                }
 
370
                memset(priv,0,sizeof(wlandevice_t));
 
371
                priv->chip_type = CHIPTYPE_ACX100;
 
372
                priv->radio_type = RADIO_MAXIM_0D; /* FIXME: should be read from register (via firmware) using standard ACX code */
 
373
                priv->usbdev=usbdev;
 
374
                /* ---------------------------------------------
 
375
                ** Initialize the device context and also check
 
376
                ** if this is really the hardware we know about.
 
377
                ** If not sure, at least notify the user that he
 
378
                ** may be in trouble...
 
379
                ** --------------------------------------------- */
 
380
                numconfigs=(int)(usbdev->descriptor.bNumConfigurations);
 
381
                if (numconfigs!=1) printk(KERN_WARNING SHORTNAME ": number of configurations is %d, this version of the driver only knows how to handle 1, be prepared for surprises\n",numconfigs);
 
382
#if USB_24
 
383
                config = usbdev->actconfig;
 
384
#else
 
385
                config = &usbdev->config->desc;
 
386
#endif
 
387
                numfaces=config->bNumInterfaces;
 
388
                if (numfaces!=1) printk(KERN_WARNING SHORTNAME "number of interfaces is %d, this version of the driver only knows how to handle 1, be prepared for surprises\n",numfaces);
 
389
                /* --------------------------------------------
 
390
                 * ----------------------------------------- */
 
391
#ifdef USB_24
 
392
                ifdesc = config->interface->altsetting;
 
393
#else           
 
394
                ifdesc = &(intf->altsetting->desc);
 
395
#endif
 
396
                numep = ifdesc->bNumEndpoints;
 
397
                acxlog(L_STD,"# of endpoints: %d\n",numep);
 
398
                /* ------------------------------------------
 
399
                 * obtain information about the endpoint
 
400
                 * addresses, begin with some default values
 
401
                 * --------------------------------------- */
 
402
                priv->bulkoutep=1;
 
403
                priv->bulkinep=1;
 
404
                for (i=0;i<numep;i++) {
 
405
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
 
406
                        ep = usbdev->ep_in[i];
 
407
                        if(!ep) continue;
 
408
                        epdesc = &ep->desc;
 
409
#else
 
410
                        epdesc=usb_epnum_to_ep_desc(usbdev,i);
 
411
                        if (!epdesc) continue;
 
412
#endif
 
413
                        if ((epdesc->bmAttributes)&USB_ENDPOINT_XFER_BULK) {
 
414
                                if ((epdesc->bEndpointAddress)&0x80) priv->bulkinep=(epdesc->bEndpointAddress)&0xF;
 
415
                                else priv->bulkoutep=(epdesc->bEndpointAddress)&0xF;
 
416
                        }
 
417
                }
 
418
                acxlog(L_STD,"bulkout ep: 0x%X\n",priv->bulkoutep);
 
419
                acxlog(L_STD,"bulkin ep: 0x%X\n",priv->bulkinep);
 
420
                /* --------------------------------------------
 
421
                ** Set the packet-size equivalent to the
 
422
                ** buffer size...
 
423
                ** ------------------------------------------ */
 
424
                txbufsize=sizeof(acx100_usb_txfrm_t);
 
425
                rxbufsize=sizeof(acx100_usbin_t);
 
426
                rxbufsize&=~0x3f; /* make it a multiply of 6ty fucking 4 ! */
 
427
                priv->rxtruncsize=0;
 
428
                priv->rxtruncation=0;
 
429
                printk(KERN_INFO SHORTNAME "txbufsize=%d rxbufsize=%d\n",txbufsize,rxbufsize);
 
430
                /* ---------------------------------------------
 
431
                ** initialize custom spinlocks...
 
432
                ** --------------------------------------------- */
 
433
                spin_lock_init(&(priv->usb_ctrl_lock));
 
434
                spin_lock_init(&(priv->usb_tx_lock));
 
435
                priv->currentdesc=0;
 
436
                priv->usb_free_tx=ACX100_USB_NUM_BULK_URBS;
 
437
                for (i=0;i<ACX100_USB_NUM_BULK_URBS;i++) {
 
438
                        priv->bulktx_states[i]=0;
 
439
                }
 
440
                /* ---------------------------------------------
 
441
                ** Allocate memory for a network device
 
442
                ** --------------------------------------------- */
 
443
                dev = kmalloc(sizeof(struct net_device),GFP_ATOMIC);
 
444
                if (!dev) {
 
445
                        printk(KERN_WARNING SHORTNAME ": failed to alloc netdev\n");
 
446
                        kfree(priv);
 
447
                        res = OUTOFMEM;
 
448
                        goto end;
 
449
                }
 
450
                /* ---------------------------------------------
 
451
                ** Setup network device
 
452
                ** --------------------------------------------- */
 
453
                memset(dev, 0, sizeof(struct net_device));
 
454
                dev->init=(void *)&init_network_device;
 
455
                dev->priv=priv;
 
456
                priv->netdev=dev;
 
457
                /* ---------------------------------------------
 
458
                ** Setup URB for control messages
 
459
                ** --------------------------------------------- */
 
460
                priv->ctrl_urb=alloc_urb(0, GFP_KERNEL);
 
461
                if (!priv->ctrl_urb) {
 
462
                        printk(KERN_WARNING SHORTNAME ": failed to allocate URB\n");
 
463
                        kfree(dev);
 
464
                        kfree(priv);
 
465
                        res = OUTOFMEM;
 
466
                        goto end;
 
467
                }
 
468
                /* ---------------------------------------------
 
469
                ** Setup URBs for bulk-in messages
 
470
                ** --------------------------------------------- */
 
471
                for (i=0;i<ACX100_USB_NUM_BULK_URBS;i++) {
 
472
                        priv->bulkrx_urbs[i]=alloc_urb(0, GFP_KERNEL);
 
473
                        if (!priv->bulkrx_urbs[i]) {
 
474
                                printk(KERN_WARNING SHORTNAME ": failed to allocate input URB\n");
 
475
                                for (j=0;j<i;j++) usb_free_urb(priv->bulkrx_urbs[j]);
 
476
                                usb_free_urb(priv->ctrl_urb);
 
477
                                kfree(dev);
 
478
                                kfree(priv);
 
479
                                res = OUTOFMEM;
 
480
                                goto end;
 
481
                        }
 
482
                        priv->bulkrx_urbs[i]->status=0;
 
483
                }
 
484
                /* ---------------------------------------------
 
485
                ** Setup URBs for bulk-out messages
 
486
                ** --------------------------------------------- */
 
487
                for(i=0;i<ACX100_USB_NUM_BULK_URBS;i++) {
 
488
                        priv->bulktx_urbs[i]=alloc_urb(0, GFP_KERNEL);
 
489
                        if (!priv->bulktx_urbs[i]) {
 
490
                                printk(KERN_WARNING SHORTNAME ": failed to allocate output URB\n");
 
491
                                usb_free_urb(priv->ctrl_urb);
 
492
                                for (j=0;j<i;j++) usb_free_urb(priv->bulktx_urbs[j]);
 
493
                                for (i=0;i<ACX100_USB_NUM_BULK_URBS;i++) usb_free_urb(priv->bulkrx_urbs[i]);
 
494
                                kfree(dev);
 
495
                                kfree(priv);
 
496
                                res = OUTOFMEM;
 
497
                                goto end;
 
498
                        }
 
499
                        priv->bulktx_urbs[i]->status=0;
 
500
                }
 
501
                /* --------------------------------------
 
502
                ** Allocate a network device name
 
503
                ** -------------------------------------- */
 
504
                acxlog(L_INIT,"allocating device name\n");
 
505
                result=dev_alloc_name(dev,"wlan%d");
 
506
                if (result<0) {
 
507
                        printk(KERN_ERR SHORTNAME ": failed to allocate wlan device name (errcode=%d), giving up.\n",result);
 
508
                        kfree(dev);
 
509
                        usb_free_urb(priv->ctrl_urb);
 
510
                        for (i=0;i<ACX100_USB_NUM_BULK_URBS;i++) {
 
511
                                usb_free_urb(priv->bulkrx_urbs[i]);
 
512
                                usb_free_urb(priv->bulktx_urbs[i]);
 
513
                        }
 
514
                        kfree(priv);
 
515
                        res = OUTOFMEM;
 
516
                        goto end;
 
517
                }
 
518
#if USB_24 == 0
 
519
                usb_set_intfdata(intf, priv);
 
520
                SET_NETDEV_DEV(dev, &intf->dev);
 
521
#endif
 
522
                /* --------------------------------------
 
523
                ** Register the network device
 
524
                ** -------------------------------------- */
 
525
                acxlog(L_INIT,"registering network device\n");
 
526
                result=register_netdev(dev);
 
527
                if (result!=0) {
 
528
                        printk(KERN_ERR SHORTNAME "failed to register network device for USB WLAN (errcode=%d), giving up.\n",result);
 
529
                        kfree(dev);
 
530
                        usb_free_urb(priv->ctrl_urb);
 
531
                        for (i=0;i<ACX100_USB_NUM_BULK_URBS;i++) {
 
532
                                usb_free_urb(priv->bulkrx_urbs[i]);
 
533
                                usb_free_urb(priv->bulktx_urbs[i]);
 
534
                        }       
 
535
                        kfree(priv);
 
536
                        res = OUTOFMEM;
 
537
                        goto end;
 
538
                }
 
539
#ifdef CONFIG_PROC_FS
 
540
                if (OK != acx_proc_register_entries(dev)) {
 
541
                        acxlog(L_INIT, "/proc registration failed\n");
 
542
                }
 
543
#endif
 
544
 
 
545
                /* --------------------------------------
 
546
                ** Everything went OK, we are happy now
 
547
                ** ----------------------------------- */
 
548
#if USB_24
 
549
                res = priv;
 
550
#else
 
551
                res = 0;
 
552
#endif
 
553
                goto end;
 
554
        }
 
555
        /* --------------------------------------
 
556
        ** no device we could handle, return NULL
 
557
        ** -------------------------------------- */
 
558
#if USB_24
 
559
        res = NULL;
 
560
#else
 
561
        res = -EIO;
 
562
#endif
 
563
end:
 
564
        FN_EXIT1((int)res);
 
565
        return res;
 
566
}
 
567
 
 
568
 
 
569
 
 
570
 
 
571
/* ---------------------------------------------------------------------------
 
572
** acx100usb_disconnect():
 
573
** Inputs:
 
574
**         dev -> Pointer to usb_device structure handled by this module
 
575
**  devContext -> Pointer to own device context (acx100usb_context)
 
576
** ---------------------------------------------------------------------------
 
577
** Returns:
 
578
**  <NOTHING>
 
579
**
 
580
** Description:
 
581
**  This function is invoked whenever the user pulls the plug from the USB
 
582
**  device or the module is removed from the kernel. In these cases, the
 
583
**  network devices have to be taken down and all allocated memory has
 
584
**  to be freed.
 
585
** ------------------------------------------------------------------------ */
 
586
 
 
587
#if USB_24
 
588
static void acx100usb_disconnect(struct usb_device *usbdev, void *devContext)
 
589
{
 
590
        wlandevice_t *priv = (wlandevice_t *)devContext;
 
591
#else
 
592
static void acx100usb_disconnect(struct usb_interface *intf)
 
593
{
 
594
        wlandevice_t *priv = usb_get_intfdata(intf);
 
595
#endif
 
596
        int i,result;
 
597
 
 
598
        if (disconnected) return;
 
599
        /* --------------------------------------
 
600
        ** No WLAN device...no sense
 
601
        ** ----------------------------------- */
 
602
        if (NULL == priv) 
 
603
                return;
 
604
        /* -------------------------------------
 
605
        ** stop the transmit queue...
 
606
        ** ---------------------------------- */
 
607
        if (priv->netdev) {
 
608
                rtnl_lock();
 
609
                if (!acx_queue_stopped(priv->netdev)) {
 
610
                        acx_stop_queue(priv->netdev,"on USB disconnect");
 
611
                }
 
612
                rtnl_unlock();
 
613
#ifdef CONFIG_PROC_FS
 
614
                acx_proc_unregister_entries(priv->netdev);
 
615
#endif
 
616
 
 
617
        }       
 
618
        /* ---------------------------------------
 
619
        ** now abort pending URBs and free them...
 
620
        ** ------------------------------------ */
 
621
        if (priv->ctrl_urb) {
 
622
                if (priv->ctrl_urb->status==-EINPROGRESS) usb_unlink_urb(priv->ctrl_urb);
 
623
                while (priv->ctrl_urb->status==-EINPROGRESS) {
 
624
                        mdelay(2);
 
625
                }
 
626
                usb_free_urb(priv->ctrl_urb);
 
627
        }
 
628
        for (i=0;i<ACX100_USB_NUM_BULK_URBS;i++) {
 
629
                if (priv->bulkrx_urbs[i]) {
 
630
                        if (priv->bulkrx_urbs[i]->status==-EINPROGRESS) usb_unlink_urb(priv->bulkrx_urbs[i]);
 
631
                        while (priv->bulkrx_urbs[i]->status==-EINPROGRESS) {
 
632
                                mdelay(2);
 
633
                        }
 
634
                        usb_free_urb(priv->bulkrx_urbs[i]);
 
635
                }
 
636
        }
 
637
        for (i=0;i<ACX100_USB_NUM_BULK_URBS;i++) {
 
638
                if (priv->bulktx_urbs[i]) {
 
639
                        if (priv->bulktx_urbs[i]->status==-EINPROGRESS) usb_unlink_urb(priv->bulktx_urbs[i]);
 
640
                        while (priv->bulktx_urbs[i]->status==-EINPROGRESS) {
 
641
                                mdelay(2);
 
642
                        }
 
643
                        usb_free_urb(priv->bulktx_urbs[i]);
 
644
                }
 
645
        }
 
646
        /* --------------------------------------
 
647
        ** Unregister the network devices
 
648
        ** -------------------------------------- */
 
649
        if (priv->netdev) {
 
650
                rtnl_lock();
 
651
                result=unregister_netdevice(priv->netdev);
 
652
                rtnl_unlock();
 
653
                kfree(priv->netdev);
 
654
        }
 
655
        /* --------------------------------------
 
656
        ** finally free the WLAN device...
 
657
        ** -------------------------------------- */
 
658
        if (priv) kfree(priv);
 
659
        disconnected=1;
 
660
}
 
661
 
 
662
 
 
663
 
 
664
 
 
665
/* ---------------------------------------------------------------------------
 
666
** acx100usb_boot():
 
667
** Inputs:
 
668
**    usbdev -> Pointer to kernel's usb_device structure
 
669
**  endpoint -> Address of the endpoint for control transfers
 
670
** ---------------------------------------------------------------------------
 
671
** Returns:
 
672
**  (int) Errorcode or 0 on success
 
673
**
 
674
** Description:
 
675
**  This function triggers the loading of the firmware image from harddisk
 
676
**  and then uploads the firmware to the USB device. After uploading the
 
677
**  firmware and transmitting the checksum, the device resets and appears
 
678
**  as a new device on the USB bus (the device we can finally deal with)
 
679
** ----------------------------------------------------------------------- */
 
680
 
 
681
static int acx100usb_boot(struct usb_device *usbdev)
 
682
{
 
683
        unsigned int offset=8,len,inpipe,outpipe;
 
684
        u32 size;
 
685
        int result;
 
686
        u16 *csptr;
 
687
        char filename[128],*firmware,*usbbuf;
 
688
        FN_ENTER;
 
689
        usbbuf = kmalloc(ACX100_USB_RWMEM_MAXLEN,GFP_KERNEL);
 
690
        if (!usbbuf) {
 
691
                printk(KERN_ERR SHORTNAME "not enough memory for allocating USB transfer buffer (req=%d bytes)\n",ACX100_USB_RWMEM_MAXLEN);
 
692
                return(-ENOMEM);
 
693
        }
 
694
        if ((firmware_dir)&&(strlen(firmware_dir)>114)) {
 
695
                printk(KERN_ERR "path in firmware_dir is too long (max. 114 chars)\n");
 
696
                kfree(usbbuf);
 
697
                return(-EINVAL);
 
698
        }
 
699
        if (firmware_dir) sprintf(filename,"%s/ACX100_USB.bin",firmware_dir);
 
700
        else sprintf(filename,"/usr/share/acx/ACX100_USB.bin");
 
701
        acxlog(L_INIT,"loading firmware %s\n",filename);
 
702
        firmware=(char *)acx_read_fw(&usbdev->dev, filename, &size);
 
703
        if (!firmware) {
 
704
                kfree(usbbuf);
 
705
                return(-EIO);
 
706
        }
 
707
        acxlog(L_INIT,"firmware size: %d bytes\n",size);
 
708
        /* --------------------------------------
 
709
        ** Obtain the I/O pipes
 
710
        ** -------------------------------------- */
 
711
        outpipe=usb_sndctrlpipe(usbdev,0);
 
712
        inpipe =usb_rcvctrlpipe(usbdev,0);
 
713
        /* --------------------------------------
 
714
        ** now upload the firmware, slice the data
 
715
        ** into blocks
 
716
        ** -------------------------------------- */
 
717
        while (offset<size) {
 
718
                if ((size-offset)>=(ACX100_USB_RWMEM_MAXLEN)) len=ACX100_USB_RWMEM_MAXLEN;
 
719
                else len=size-offset;
 
720
                acxlog(L_INIT,"uploading firmware (%d bytes, offset=%d)\n",len,offset);
 
721
                result=0;
 
722
                memcpy(usbbuf,firmware+offset,len);
 
723
                result=usb_control_msg(usbdev,outpipe,ACX100_USB_UPLOAD_FW,USB_TYPE_VENDOR|USB_DIR_OUT,(u16)(size-8),0,usbbuf,len,3000);
 
724
                offset+=len;
 
725
                if (result<0) {
 
726
#if ACX_DEBUG
 
727
                        printk(KERN_ERR SHORTNAME "error %d (%s) during upload of firmware, aborting\n",result,acx100usb_pstatus(result));
 
728
#else
 
729
                        printk(KERN_ERR SHORTNAME "error %d during upload of firmware, aborting\n", result);
 
730
#endif
 
731
                        kfree(usbbuf);
 
732
                        vfree(firmware);
 
733
                        return(result);
 
734
                }
 
735
        }
 
736
        /* --------------------------------------
 
737
        ** finally, send the checksum and reboot
 
738
        ** the device...
 
739
        ** -------------------------------------- */
 
740
        csptr=(u16 *)firmware;
 
741
        result=usb_control_msg(usbdev,outpipe,ACX100_USB_UPLOAD_FW,USB_TYPE_VENDOR|USB_DIR_OUT,csptr[0],csptr[1],NULL,0,3000); /* this triggers the reboot ? */
 
742
        if (result<0) {
 
743
                printk(KERN_ERR SHORTNAME "error %d during tx of checksum, aborting\n",result);
 
744
                kfree(usbbuf);
 
745
                vfree(firmware);
 
746
                return(result);
 
747
        }
 
748
        result=usb_control_msg(usbdev,inpipe,ACX100_USB_ACK_CS,USB_TYPE_VENDOR|USB_DIR_IN,csptr[0],csptr[1],usbbuf,8,3000);
 
749
        if (result<0) {
 
750
                printk(KERN_ERR SHORTNAME "error %d during ACK of checksum, aborting\n",result);
 
751
                kfree(usbbuf);
 
752
                vfree(firmware);
 
753
                return(result);
 
754
        }
 
755
        vfree(firmware);
 
756
        if (((u16 *)usbbuf)[0]!=0x10) {
 
757
                kfree(usbbuf);
 
758
                printk(KERN_ERR SHORTNAME "invalid checksum?\n");
 
759
                return(-EINVAL);
 
760
        }
 
761
        kfree(usbbuf);
 
762
        return(0);
 
763
}
 
764
 
 
765
 
 
766
 
 
767
 
 
768
/* ---------------------------------------------------------------------------
 
769
** init_network_device():
 
770
** Inputs:
 
771
**    dev -> Pointer to network device
 
772
** ---------------------------------------------------------------------------
 
773
** Returns:
 
774
**  <NOTHING>
 
775
**
 
776
** Description:
 
777
**  Basic setup of a network device for use with the WLAN device.
 
778
** ------------------------------------------------------------------------- */
 
779
 
 
780
static int init_network_device(struct net_device *dev) {
 
781
        int result=0;
 
782
        wlandevice_t *priv;
 
783
        /* --------------------------------------
 
784
        ** Setup the device and stop the queue
 
785
        ** -------------------------------------- */
 
786
        ether_setup(dev);
 
787
        acx_stop_queue(dev, "on init");
 
788
        /* --------------------------------------
 
789
        ** put the ACX100 out of sleep mode
 
790
        ** ----------------------------------- */
 
791
        priv=dev->priv;
 
792
        acx_issue_cmd(priv,ACX1xx_CMD_WAKE,NULL,0,ACX_CMD_TIMEOUT_DEFAULT);
 
793
        /* --------------------------------------
 
794
        ** Register the callbacks for the network
 
795
        ** device functions.
 
796
        ** -------------------------------------- */
 
797
        dev->open = &acx100usb_open;
 
798
        dev->stop = &acx100usb_close;
 
799
        dev->hard_start_xmit = (void *)&acx100usb_start_xmit;
 
800
        dev->get_stats = (void *)&acx_get_stats;
 
801
        dev->get_wireless_stats = (void *)&acx_get_wireless_stats;
 
802
#if WIRELESS_EXT >= 13
 
803
        dev->wireless_handlers = (struct iw_handler_def *)&acx_ioctl_handler_def;
 
804
#else
 
805
        dev->do_ioctl = (void *)&acx_ioctl_old;
 
806
#endif
 
807
        dev->set_multicast_list = (void *)&acx100usb_set_rx_mode;
 
808
#ifdef HAVE_TX_TIMEOUT
 
809
        dev->tx_timeout = &acx100usb_tx_timeout;
 
810
        dev->watchdog_timeo = 4 * HZ;        /* 400 */
 
811
#endif
 
812
        result=acx_init_mac(dev, 1);
 
813
        if (OK == result) {
 
814
          SET_MODULE_OWNER(dev);
 
815
        }
 
816
        return result;
 
817
}
 
818
 
 
819
 
 
820
 
 
821
 
 
822
 
 
823
/* --------------------------------------------------------------------------
 
824
** acx100usb_open():
 
825
** Inputs:
 
826
**    dev -> Pointer to network device
 
827
** --------------------------------------------------------------------------
 
828
** Returns:
 
829
**  <NOTHING>
 
830
**
 
831
** Description:
 
832
**  This function is called when the user sets up the network interface.
 
833
**  It initializes a management timer, sets up the USB card and starts
 
834
**  the network tx queue and USB receive.
 
835
** ---------------------------------------------------------------------- */
 
836
 
 
837
static int acx100usb_open(struct net_device *dev)
 
838
{
 
839
        wlandevice_t *priv = (wlandevice_t *)dev->priv;
 
840
        int i;
 
841
 
 
842
        FN_ENTER;
 
843
 
 
844
        /* ---------------------------------
 
845
        ** put the ACX100 out of sleep mode
 
846
        ** ------------------------------ */
 
847
        acx_issue_cmd(priv,ACX1xx_CMD_WAKE,NULL,0,ACX_CMD_TIMEOUT_DEFAULT);
 
848
 
 
849
        acx_init_task_scheduler(priv);
 
850
 
 
851
        init_timer(&(priv->mgmt_timer));
 
852
        priv->mgmt_timer.function=acx_timer;
 
853
        priv->mgmt_timer.data=(unsigned long)priv;
 
854
 
 
855
        /* set ifup to 1, since acx_start needs it (FIXME: ugly) */
 
856
 
 
857
        SET_BIT(priv->dev_state_mask, ACX_STATE_IFACE_UP);
 
858
        acx_start(priv);
 
859
 
 
860
 
 
861
        acx_start_queue(dev, "on open");
 
862
        for (i=0;i<ACX100_USB_NUM_BULK_URBS;i++) {
 
863
                acx100usb_poll_rx(priv,i);
 
864
        }
 
865
        /* --- */
 
866
        WLAN_MOD_INC_USE_COUNT;
 
867
        return 0;
 
868
}
 
869
 
 
870
 
 
871
 
 
872
 
 
873
/* ---------------------------------------------------------------------------
 
874
** acx_rx():
 
875
** Inputs:
 
876
**    dev -> Pointer to network device
 
877
** ---------------------------------------------------------------------------
 
878
** Returns:
 
879
**  <NOTHING>
 
880
**
 
881
** Description:
 
882
**  This function is invoked when a packet has been received by the USB
 
883
**  part of the code. It converts the rxdescriptor to an ethernet frame and
 
884
**  then commits the data to the network stack.
 
885
** ------------------------------------------------------------------------ */
 
886
 
 
887
void acx_rx(struct rxhostdescriptor *rxdesc, wlandevice_t *priv)
 
888
{
 
889
        netdevice_t *dev = priv->netdev;
 
890
        struct sk_buff *skb;
 
891
 
 
892
        FN_ENTER;
 
893
        if (priv->dev_state_mask & ACX_STATE_IFACE_UP) {
 
894
                skb = acx_rxdesc_to_ether(priv, rxdesc);
 
895
                if (skb) {
 
896
                        netif_rx(skb);
 
897
                        dev->last_rx = jiffies;
 
898
                        priv->stats.rx_packets++;
 
899
                        priv->stats.rx_bytes += skb->len;
 
900
                }
 
901
        }
 
902
        FN_EXIT0();
 
903
}
 
904
 
 
905
 
 
906
 
 
907
/* ---------------------------------------------------------------------------
 
908
** acx100usb_poll_rx():
 
909
** Inputs:
 
910
**    priv -> Pointer to wlandevice structure
 
911
** ---------------------------------------------------------------------------
 
912
** Returns:
 
913
**  <NOTHING>
 
914
**
 
915
** Description:
 
916
**  This function initiates a bulk-in USB transfer (in case the interface
 
917
**  is up).
 
918
** ------------------------------------------------------------------------- */
 
919
 
 
920
static void acx100usb_poll_rx(wlandevice_t *priv,int number) {
 
921
        acx100_usbin_t *inbuf;
 
922
        struct usb_device *usbdev;
 
923
        int errcode;
 
924
        unsigned int inpipe;
 
925
 
 
926
        FN_ENTER;
 
927
        if (priv->dev_state_mask & ACX_STATE_IFACE_UP) {
 
928
                inbuf=&(priv->bulkins[number]);
 
929
                usbdev=priv->usbdev;
 
930
                rxcons[number].device=priv;
 
931
                rxcons[number].number=number;
 
932
                inpipe=usb_rcvbulkpipe(usbdev,priv->bulkinep);
 
933
                if (priv->bulkrx_urbs[number]->status==-EINPROGRESS) {
 
934
                        printk(KERN_ERR SHORTNAME "error, rx triggered while rx urb in progress\n");
 
935
                        /* FIXME: this is nasty, receive is being cancelled by this code
 
936
                         * on the other hand, this should not happen anyway...
 
937
                         */
 
938
                        usb_unlink_urb(priv->bulkrx_urbs[number]);
 
939
                }
 
940
                priv->bulkrx_urbs[number]->actual_length=0;
 
941
                usb_fill_bulk_urb(priv->bulkrx_urbs[number], usbdev, inpipe, inbuf, rxbufsize, acx100usb_complete_rx, &(rxcons[number]));
 
942
                priv->bulkrx_urbs[number]->transfer_flags=ASYNC_UNLINK|QUEUE_BULK;
 
943
#ifdef USB_24
 
944
                priv->bulkrx_urbs[number]->timeout=0;
 
945
                priv->bulkrx_urbs[number]->status=0;
 
946
#endif
 
947
                errcode=submit_urb(priv->bulkrx_urbs[number], GFP_KERNEL);
 
948
                /* FIXME: evaluate the error code ! */
 
949
                acxlog(L_USBRXTX,"SUBMIT RX (%d) inpipe=0x%X size=%d errcode=%d\n",number,inpipe,rxbufsize,errcode);
 
950
        }
 
951
        FN_EXIT0();
 
952
}
 
953
 
 
954
 
 
955
 
 
956
 
 
957
/* ---------------------------------------------------------------------------
 
958
** acx100usb_complete_rx():
 
959
** Inputs:
 
960
**     urb -> Pointer to USB request block
 
961
**    regs -> Pointer to register-buffer for syscalls (see asm/ptrace.h)
 
962
** ---------------------------------------------------------------------------
 
963
** Returns:
 
964
**  <NOTHING>
 
965
**
 
966
** Description:
 
967
**  This function is invoked whenever a bulk receive request returns. The
 
968
**  received data is then committed to the network stack and the next
 
969
**  USB receive is triggered.
 
970
** ------------------------------------------------------------------------- */
 
971
 
 
972
#if USB_24
 
973
static void acx100usb_complete_rx(struct urb *urb)
 
974
#else
 
975
static void acx100usb_complete_rx(struct urb *urb, struct pt_regs *regs)
 
976
#endif
 
977
{
 
978
        wlandevice_t *priv;
 
979
        int offset,size,number,remsize,packetsize;
 
980
        rxbuffer_t *ptr;
 
981
        struct rxhostdescriptor *rxdesc;
 
982
        TIWLAN_DC *ticontext;
 
983
        acx_usb_bulk_context_t *context;
 
984
 
 
985
        FN_ENTER;
 
986
        if (!urb->context) {
 
987
                printk(KERN_ERR SHORTNAME "error, urb context was NULL\n");
 
988
                return; /* at least try to prevent the worst */
 
989
        }
 
990
        context=(acx_usb_bulk_context_t *)(urb->context);
 
991
        priv=context->device;
 
992
        number=context->number;
 
993
        /* ----------------------------
 
994
        ** grab the TI device context
 
995
        ** -------------------------- */
 
996
        ticontext=&(priv->dc);
 
997
        size=urb->actual_length;
 
998
        /* ---------------------------------------------
 
999
        ** check if the transfer was aborted...
 
1000
        ** ------------------------------------------ */
 
1001
        acxlog(L_USBRXTX,"RETURN RX (%d) status=%d size=%d\n",number,urb->status,size);
 
1002
        if (urb->status!=0) {
 
1003
                switch (urb->status) {
 
1004
                        case -ECONNRESET:
 
1005
                                break;
 
1006
                        case -EOVERFLOW:
 
1007
                                printk(KERN_ERR SHORTNAME "error in rx, data overrun -> emergency stop\n");
 
1008
                                acx100usb_close(priv->netdev);
 
1009
                                return;
 
1010
                        default:
 
1011
                                priv->stats.rx_errors++;
 
1012
                                printk(KERN_WARNING SHORTNAME "rx error (urb status=%d)\n",urb->status);
 
1013
                }
 
1014
                if (priv->dev_state_mask & ACX_STATE_IFACE_UP) acx100usb_poll_rx(priv,number);
 
1015
                return;
 
1016
        }
 
1017
        /* ---------------------------------------------
 
1018
        ** work the receive buffer...
 
1019
        ** --------------------------------------------- */
 
1020
        if (size==0) acxlog(L_STD,"warning, encountered zerolength rx packet\n");
 
1021
        if ((size>0)&&(urb->transfer_buffer==&(priv->bulkins[number]))) {
 
1022
                /* ------------------------------------------------------------------
 
1023
                ** now fill the data into the rxhostdescriptor for further processing
 
1024
                ** ---------------------------------------------------------------- */
 
1025
                if (!(ticontext->pRxHostDescQPool)) {
 
1026
                        printk(KERN_ERR SHORTNAME "error, rxhostdescriptor pool is NULL\n");
 
1027
                        return; /* bail out before something bad happens */
 
1028
                }
 
1029
                ptr=(rxbuffer_t *)&(priv->bulkins[number]);
 
1030
                offset=0;
 
1031
                remsize=size;
 
1032
                /* -------------------------------------------
 
1033
                 * check if previous frame was truncated...
 
1034
                 * FIXME: this code can only handle truncation
 
1035
                 * into TWO parts, NOT MORE !
 
1036
                 * ---------------------------------------- */
 
1037
                if (priv->rxtruncation) {
 
1038
                        ptr=(rxbuffer_t *)&(priv->rxtruncbuf);
 
1039
                        packetsize=MAC_CNT_RCVD(ptr)+ACX100_RXBUF_HDRSIZE;
 
1040
                        rxdesc=&(ticontext->pRxHostDescQPool[ticontext->rx_tail]);
 
1041
                        SET_BIT(rxdesc->Ctl_16, cpu_to_le16(DESC_CTL_HOSTOWN));
 
1042
                        rxdesc->Status=cpu_to_le32(0xF0000000); /* set the MSB, FIXME: shouldn't that be MSBit instead??? (BIT31) */
 
1043
                        acxlog(L_USBRXTX,"handling truncated frame (truncsize=%d usbsize=%d packetsize(from trunc)=%d)\n",priv->rxtruncsize,size,packetsize);
 
1044
#if ACX_DEBUG
 
1045
                        if (debug&L_USBRXTX) acx_dump_bytes(ptr,12);
 
1046
                        if (debug&L_USBRXTX) acx_dump_bytes(&(priv->bulkins[number]),12);
 
1047
#endif
 
1048
                        if (size<(packetsize-priv->rxtruncsize)) {
 
1049
                                /* -------------------------------------------------
 
1050
                                 * there is not enough data to complete this packet
 
1051
                                 * simply append the stuff to the truncation buffer
 
1052
                                 * ----------------------------------------------- */
 
1053
                                memcpy(((char *)ptr)+priv->rxtruncsize,&(priv->bulkins[number]),size);
 
1054
                                priv->rxtruncsize+=size;
 
1055
                                offset=size;
 
1056
                                remsize=0;
 
1057
                        } else {
 
1058
                                /* ------------------------------------------
 
1059
                                 * ok, this data completes the previously
 
1060
                                 * truncated packet. copy it into a descriptor
 
1061
                                 * and give it to the rest of the stack...
 
1062
                                 * ----------------------------------------- */
 
1063
                                memcpy(rxdesc->data,ptr,priv->rxtruncsize);     /* first copy the previously truncated part */
 
1064
                                ptr=(rxbuffer_t *)&(priv->bulkins[number]);
 
1065
                                memcpy(((char *)(rxdesc->data))+priv->rxtruncsize,(char *)ptr,packetsize-priv->rxtruncsize);
 
1066
#if ACX_DEBUG                   
 
1067
                                acxlog(L_USBRXTX,"full trailing packet + 12 bytes:\n");
 
1068
                                if (debug&L_USBRXTX) acx_dump_bytes(ptr,(packetsize-priv->rxtruncsize)+ACX100_RXBUF_HDRSIZE);
 
1069
#endif
 
1070
                                priv->rxtruncation=0;
 
1071
                                offset=(packetsize-priv->rxtruncsize);
 
1072
                                ptr=(rxbuffer_t *)(((char *)ptr)+offset);
 
1073
                                remsize-=offset;
 
1074
                                acx_process_rx_desc(priv);
 
1075
                        }
 
1076
                        acxlog(L_USBRXTX,"post-merge offset: %d usbsize: %d remsize=%d\n",offset,size,remsize);
 
1077
                }
 
1078
                while (offset<size) {
 
1079
                        packetsize=MAC_CNT_RCVD(ptr)+ACX100_RXBUF_HDRSIZE;
 
1080
                        acxlog(L_USBRXTX,"packet with packetsize=%d\n",packetsize);
 
1081
                        if (packetsize>sizeof(rxbuffer_t)) {
 
1082
                                printk(KERN_ERR "packetsize exceeded (got %d , max %d, usbsize=%d)\n",packetsize,sizeof(rxbuffer_t),size);
 
1083
                                /* FIXME: put some real error-handling in here ! */
 
1084
                        }
 
1085
                        /* --------------------------------
 
1086
                         * skip zero-length packets...
 
1087
                         * ----------------------------- */
 
1088
                        if (packetsize==0) {
 
1089
                                offset+=ACX100_RXBUF_HDRSIZE;
 
1090
                                remsize-=ACX100_RXBUF_HDRSIZE;
 
1091
                                acxlog(L_USBRXTX,"packetsize=0, new offs=%d new rem=%d header follows:\n",offset,remsize);
 
1092
#if ACX_DEBUG
 
1093
                                if (debug&L_USBRXTX) acx_dump_bytes(ptr,12);
 
1094
#endif
 
1095
                                ptr=(rxbuffer_t *)(((char *)ptr)+ACX100_RXBUF_HDRSIZE);
 
1096
                                continue;
 
1097
                        }
 
1098
                        /* -------------------------------
 
1099
                         * if packet has no information,
 
1100
                         * skip it..
 
1101
                         * ---------------------------- */
 
1102
                        if (remsize<=ACX100_RXBUF_HDRSIZE) {
 
1103
                        }
 
1104
                        if (packetsize>remsize) {
 
1105
                                /* -----------------------------------
 
1106
                                 * frame truncation handling...
 
1107
                                 * --------------------------------- */
 
1108
                                acxlog(L_USBRXTX,"need to truncate this packet , packetsize=%d remain=%d offset=%d usbsize=%d\n",packetsize,remsize,offset,size);
 
1109
#if ACX_DEBUG                           
 
1110
                                if (debug&L_USBRXTX) acx_dump_bytes(ptr,12);
 
1111
#endif                          
 
1112
                                priv->rxtruncation=1;
 
1113
                                memcpy(&(priv->rxtruncbuf),ptr,remsize);
 
1114
                                priv->rxtruncsize=remsize;
 
1115
                                offset=size;
 
1116
                        } else {
 
1117
                                rxdesc=&(ticontext->pRxHostDescQPool[ticontext->rx_tail]);
 
1118
                                SET_BIT(rxdesc->Ctl_16, cpu_to_le16(DESC_CTL_HOSTOWN));
 
1119
                                rxdesc->Status=cpu_to_le32(0xF0000000); /* set the MSB, FIXME: shouldn't that be MSBit instead??? (BIT31) */
 
1120
                                memcpy(rxdesc->data,ptr,packetsize);
 
1121
                                /* ---------------------------------------------
 
1122
                                ** now handle the received data....
 
1123
                                ** ------------------------------------------ */
 
1124
                                acx_process_rx_desc(priv);
 
1125
                                ptr=(rxbuffer_t *)(((char *)ptr)+packetsize);
 
1126
                                offset+=packetsize;
 
1127
                                remsize-=packetsize;
 
1128
#if ACX_DEBUG
 
1129
                                if ((remsize)&&(debug&L_USBRXTX)) {
 
1130
                                        acxlog(L_USBRXTX,"more than one packet in buffer, second packet hdr follows\n");
 
1131
                                        if (debug&L_USBRXTX) acx_dump_bytes(ptr,12);
 
1132
                                }
 
1133
#endif                          
 
1134
                        }
 
1135
                }
 
1136
        }
 
1137
        /* -------------------------------
 
1138
        ** look for the next rx ...
 
1139
        ** ---------------------------- */
 
1140
        if (priv->dev_state_mask & ACX_STATE_IFACE_UP) acx100usb_poll_rx(priv,number); /* receive of frame completed, now look for the next one */
 
1141
        FN_EXIT0();
 
1142
}
 
1143
 
 
1144
 
 
1145
 
 
1146
 
 
1147
/* ---------------------------------------------------------------------------
 
1148
** acx100usb_tx_data():
 
1149
** Inputs:
 
1150
**    priv -> Pointer to wlandevice structure
 
1151
**    desc -> Pointer to TX descriptor
 
1152
** ---------------------------------------------------------------------------
 
1153
** Returns:
 
1154
**  <NOTHING>
 
1155
**
 
1156
** Description:
 
1157
**  This function is called by acx_dma_tx_data() and is responsible for
 
1158
**  sending out the data within the given txdescriptor to the USB device.
 
1159
**  In order to avoid inconsistency on SMP systems, a Mutex is checked
 
1160
**  that forbids other packets to disturb the USB queue when there is
 
1161
**  more than 1 packet within the Tx queue at a time. In case there is
 
1162
**  a transfer in progress, this function immediately returns. It is
 
1163
**  within the responsibility of the acx100usb_complete_tx() function to
 
1164
**  ensure that these transfers are completed after the current transfer
 
1165
**  was finished. In case there are no transfers in progress, the Mutex
 
1166
**  is set and the transfer is triggered.
 
1167
** ------------------------------------------------------------------------- */
 
1168
 
 
1169
void acx100usb_tx_data(wlandevice_t *priv,struct txdescriptor *desc)
 
1170
{
 
1171
        FN_ENTER;
 
1172
        /* ------------------------------------
 
1173
        ** some sanity checks...
 
1174
        ** --------------------------------- */
 
1175
        if ((!priv)||(!desc)) return;
 
1176
        /*-----------------------------------------------
 
1177
        ** check if there are free buffers to use...
 
1178
        ** ------------------------------------------- */
 
1179
        if (!(priv->usb_free_tx)) return;
 
1180
        /*-----------------------------------------------
 
1181
        ** transmit the frame...
 
1182
        ** ------------------------------------------- */
 
1183
        acx100usb_prepare_tx(priv,desc);
 
1184
        FN_EXIT0();
 
1185
}
 
1186
 
 
1187
 
 
1188
 
 
1189
/* ---------------------------------------------------------------------------
 
1190
** acx100usb_prepare_tx():
 
1191
** Inputs:
 
1192
**    priv -> Pointer to wlandevice structure
 
1193
**    desc -> Pointer to TX descriptor
 
1194
** ---------------------------------------------------------------------------
 
1195
** Returns:
 
1196
**  <NOTHING>
 
1197
**
 
1198
** Description:
 
1199
**  This function inserts the given txdescriptor into the USB output buffer
 
1200
**  and initiates the USB data transfer of the packet.
 
1201
** ------------------------------------------------------------------------- */
 
1202
 
 
1203
static void acx100usb_prepare_tx(wlandevice_t *priv,struct txdescriptor *desc) {
 
1204
        int bufindex,txsize,ucode,size;
 
1205
        unsigned long flags;
 
1206
        acx100_usb_txfrm_t *buf;
 
1207
        const u8 *addr;
 
1208
        struct usb_device *usbdev;
 
1209
        unsigned int outpipe;
 
1210
        struct txhostdescriptor *header,*payload;
 
1211
        TIWLAN_DC *ticontext;
 
1212
 
 
1213
        FN_ENTER;
 
1214
        priv->currentdesc = desc;
 
1215
        ticontext=&(priv->dc);
 
1216
        /* ------------------------------------------
 
1217
        ** extract header and payload from descriptor
 
1218
        ** --------------------------------------- */
 
1219
        header = desc->fixed_size.s.host_desc;
 
1220
        payload = desc->fixed_size.s.host_desc+1;
 
1221
        /* ---------------------------------------------
 
1222
        ** look for a free tx buffer.....
 
1223
        ** ------------------------------------------ */
 
1224
        spin_lock_irqsave(&(priv->usb_tx_lock),flags);
 
1225
        for (bufindex=0;bufindex<ACX100_USB_NUM_BULK_URBS;bufindex++) {
 
1226
                if (priv->bulktx_states[bufindex]==0) break;
 
1227
        }
 
1228
        if (bufindex>=ACX100_USB_NUM_BULK_URBS) {
 
1229
                printk(KERN_WARNING SHORTNAME "tx buffers full\n");
 
1230
                spin_unlock_irqrestore(&(priv->usb_tx_lock),flags);
 
1231
                return;
 
1232
        }
 
1233
        priv->bulktx_states[bufindex]=1;
 
1234
        priv->usb_free_tx--;
 
1235
        acxlog(L_DEBUG,"using buf #%d (free=%d) len=%d\n",bufindex,priv->usb_free_tx,le16_to_cpu(header->length)+le16_to_cpu(payload->length));
 
1236
        /* ----------------------------------------------
 
1237
        ** concatenate header and payload into USB buffer
 
1238
        ** ------------------------------------------- */
 
1239
        acxlog(L_XFER,"tx_data: headerlen=%d  payloadlen=%d\n",le16_to_cpu(header->length),le16_to_cpu(payload->length));
 
1240
        buf=&(priv->bulkouts[bufindex].txfrm);
 
1241
        size=le16_to_cpu(header->length) + le16_to_cpu(payload->length);
 
1242
        if (size>txbufsize) {
 
1243
                printk(KERN_WARNING SHORTNAME "error, USB buffer smaller than total data to send (%d vs. %d) -> frame dropped\n",size,txbufsize);
 
1244
                priv->bulktx_states[bufindex]=0;
 
1245
                priv->usb_free_tx++;
 
1246
                spin_unlock_irqrestore(&(priv->usb_tx_lock),flags);
 
1247
                return;
 
1248
        }
 
1249
        memcpy(&(buf->data),header->data,le16_to_cpu(header->length));
 
1250
        memcpy(((char *)&(buf->data))+le16_to_cpu(header->length),payload->data,le16_to_cpu(payload->length));
 
1251
        /* ----------------------------------------------
 
1252
        ** fill the USB transfer header
 
1253
        ** ------------------------------------------- */
 
1254
        buf->hdr.desc=cpu_to_le16(ACX100_USB_TX_DESC);
 
1255
        buf->hdr.MPDUlen=cpu_to_le16(size);
 
1256
        buf->hdr.ctrl1=0;
 
1257
        buf->hdr.ctrl2=0;
 
1258
        buf->hdr.hostData=cpu_to_le32(size|(desc->u.r1.rate)<<24);
 
1259
        if (1 == priv->defpeer.shortpre) /* vda: TODO: when to use ap_peer? */
 
1260
                SET_BIT(buf->hdr.ctrl1, DESC_CTL_SHORT_PREAMBLE);
 
1261
        SET_BIT(buf->hdr.ctrl1, DESC_CTL_FIRSTFRAG);
 
1262
        buf->hdr.txRate=desc->u.r1.rate;
 
1263
        buf->hdr.index=1;
 
1264
        buf->hdr.dataLength=cpu_to_le16(size|((buf->hdr.txRate)<<24));
 
1265
        if (WLAN_GET_FC_FTYPE(ieee2host16(((p80211_hdr_t *)header->data)->a3.fc))==WLAN_FTYPE_DATA) {
 
1266
                SET_BIT(buf->hdr.hostData, (ACX100_USB_TXHI_ISDATA<<16));
 
1267
        }
 
1268
        addr=(((p80211_hdr_t *)(header->data))->a3.a3);
 
1269
        if (mac_is_directed(addr))
 
1270
            SET_BIT(buf->hdr.hostData, cpu_to_le32((ACX100_USB_TXHI_DIRECTED<<16)));
 
1271
        if (mac_is_bcast(addr))
 
1272
            SET_BIT(buf->hdr.hostData, cpu_to_le32((ACX100_USB_TXHI_BROADCAST<<16)));
 
1273
        acxlog(L_DATA,"Dump of bulk out urb:\n");
 
1274
        if (debug&L_DATA) acx_dump_bytes(buf,size+sizeof(acx100_usb_txhdr_t));
 
1275
 
 
1276
 
 
1277
        if (priv->bulktx_urbs[bufindex]->status==-EINPROGRESS) {
 
1278
                printk(KERN_WARNING SHORTNAME "trying to subma a tx urb while already in progress\n");
 
1279
        }
 
1280
        
 
1281
        priv->usb_txsize=size+sizeof(acx100_usb_txhdr_t);
 
1282
        priv->usb_txoffset=priv->usb_txsize;
 
1283
        txsize=priv->usb_txsize;
 
1284
        /* ---------------------------------------------
 
1285
        ** now schedule the USB transfer...
 
1286
        ** ------------------------------------------ */
 
1287
        usbdev=priv->usbdev;
 
1288
        outpipe=usb_sndbulkpipe(usbdev,priv->bulkoutep); 
 
1289
        txcons[bufindex].device=priv;
 
1290
        txcons[bufindex].number=bufindex;
 
1291
        usb_fill_bulk_urb(priv->bulktx_urbs[bufindex],usbdev,outpipe,buf,txsize,(usb_complete_t)acx100usb_complete_tx,&(txcons[bufindex]));
 
1292
        priv->bulktx_urbs[bufindex]->transfer_flags=ASYNC_UNLINK|QUEUE_BULK|ZERO_PACKET;
 
1293
#ifdef USB_24   
 
1294
        priv->bulktx_urbs[bufindex]->status=0;
 
1295
        priv->bulktx_urbs[bufindex]->timeout=ACX100_USB_TX_TIMEOUT;
 
1296
#endif  
 
1297
        ucode=submit_urb(priv->bulktx_urbs[bufindex], GFP_KERNEL);
 
1298
        acxlog(L_USBRXTX,"SUBMIT TX (%d): outpipe=0x%X buf=%p txsize=%d errcode=%d\n",bufindex,outpipe,buf,txsize,ucode);
 
1299
        if (ucode!=0) {
 
1300
                printk(KERN_ERR SHORTNAME "submit_urb() return code: %d (%s:%d) txsize=%d\n",ucode,__FILE__,__LINE__,txsize);
 
1301
                /* -------------------------------------------------
 
1302
                ** on error, just mark the frame as done and update
 
1303
                ** the statistics...
 
1304
                ** ---------------------------------------------- */
 
1305
                priv->stats.tx_errors++;
 
1306
                priv->bulktx_states[bufindex]=0;
 
1307
                priv->usb_free_tx++;
 
1308
                spin_unlock_irqrestore(&(priv->usb_tx_lock),flags);
 
1309
                acx100usb_trigger_next_tx(priv);
 
1310
                return;
 
1311
        }
 
1312
        spin_unlock_irqrestore(&(priv->usb_tx_lock),flags);
 
1313
        FN_EXIT0();
 
1314
}
 
1315
 
 
1316
 
 
1317
 
 
1318
 
 
1319
 
 
1320
 
 
1321
/* ---------------------------------------------------------------------------
 
1322
** acx100usb_complete_tx():
 
1323
** Inputs:
 
1324
**     urb -> Pointer to USB request block
 
1325
**    regs -> Pointer to register-buffer for syscalls (see asm/ptrace.h)
 
1326
** ---------------------------------------------------------------------------
 
1327
** Returns:
 
1328
**  <NOTHING>
 
1329
**
 
1330
** Description:
 
1331
**   This function is invoked upon termination of a USB transfer. As the
 
1332
**   USB device is only capable of sending a limited amount of bytes per
 
1333
**   transfer to the bulk-out endpoint, this routine checks if there are
 
1334
**   more bytes to send and triggers subsequent transfers. In case the
 
1335
**   transfer size exactly matches the maximum bulk-out size, it triggers
 
1336
**   a transfer of a null-frame, telling the card that this is it. Upon
 
1337
**   completion of a frame, it checks whether the Tx ringbuffer contains
 
1338
**   more data to send and invokes the Tx routines if this is the case.
 
1339
**   If there are no more occupied Tx descriptors, the Tx Mutex is unlocked
 
1340
**   and the network queue is switched back to life again.
 
1341
** ------------------------------------------------------------------------- */
 
1342
 
 
1343
#if USB_24
 
1344
static void acx100usb_complete_tx(struct urb *urb)
 
1345
#else
 
1346
static void acx100usb_complete_tx(struct urb *urb, struct pt_regs *regs)
 
1347
#endif
 
1348
{
 
1349
        wlandevice_t *priv;
 
1350
        acx_usb_bulk_context_t *context;
 
1351
        int index;
 
1352
        unsigned long flags;
 
1353
 
 
1354
        FN_ENTER;
 
1355
        
 
1356
        context=(acx_usb_bulk_context_t *)(urb->context);
 
1357
        if (!context) {
 
1358
                printk(KERN_ERR SHORTNAME "error, enountered NULL context in tx completion callback\n");
 
1359
                /* FIXME: real error-handling code must go here ! */
 
1360
                return;
 
1361
        }
 
1362
        priv=context->device;
 
1363
        index=context->number;
 
1364
        acxlog(L_USBRXTX,"RETURN TX (%d): status=%d size=%d\n",index,urb->status,urb->actual_length);
 
1365
        /* ------------------------------
 
1366
        ** handle USB transfer errors...
 
1367
        ** --------------------------- */
 
1368
        if (urb->status!=0) {
 
1369
                switch (urb->status) {
 
1370
                        case -ECONNRESET:
 
1371
                                break;
 
1372
                        default:
 
1373
                                printk(KERN_ERR SHORTNAME "tx error, urb status=%d\n",urb->status);
 
1374
                }
 
1375
                /* FIXME: real error-handling code here please */
 
1376
        }
 
1377
        /* ---------------------------------------------
 
1378
        ** free the URB and check for more data...
 
1379
        ** --------------------------------------------- */
 
1380
        spin_lock_irqsave(&(priv->usb_tx_lock),flags);
 
1381
        priv->usb_free_tx++;
 
1382
        priv->bulktx_states[index]=0;
 
1383
        spin_unlock_irqrestore(&(priv->usb_tx_lock),flags);
 
1384
        if (priv->dev_state_mask&ACX_STATE_IFACE_UP) acx100usb_trigger_next_tx(priv);
 
1385
        FN_EXIT0();
 
1386
}
 
1387
 
 
1388
 
 
1389
/* ---------------------------------------------------------------------------
 
1390
** acx100usb_trigger_next_tx():
 
1391
** Inputs:
 
1392
**     priv -> Pointer to WLAN device structure
 
1393
** ---------------------------------------------------------------------------
 
1394
** Returns:
 
1395
**  <NOTHING>
 
1396
**
 
1397
** Description:
 
1398
**  This function is invoked when the transfer of the current txdescriptor
 
1399
**  to send is completed OR if there went something wrong during the transfer
 
1400
**  of the descriptor. In either case, this function checks if there are more
 
1401
**  descriptors to send and handles the descriptors over to the 
 
1402
**  acx100usb_prepare_tx() function. If there are no more descriptors to send,
 
1403
**  the transfer-in-progress Mutex is released and the network tx queue is
 
1404
**  kicked back to life.
 
1405
** ------------------------------------------------------------------------ */
 
1406
 
 
1407
static void acx100usb_trigger_next_tx(wlandevice_t *priv) {
 
1408
        struct txdescriptor *txdesc;
 
1409
        struct txhostdescriptor *header,*payload;
 
1410
        int descnum;
 
1411
        struct TIWLAN_DC *ticontext;
 
1412
        /* ----------------------------
 
1413
        ** grab the TI device context
 
1414
        ** -------------------------- */
 
1415
        ticontext=&(priv->dc);
 
1416
        /* ----------------------------------------------
 
1417
        ** free the txdescriptor...
 
1418
        ** ------------------------------------------- */
 
1419
        txdesc=priv->currentdesc;
 
1420
        header = txdesc->fixed_size.s.host_desc;
 
1421
        payload = txdesc->fixed_size.s.host_desc+1;
 
1422
        SET_BIT(header->Ctl_16, cpu_to_le16(DESC_CTL_DONE));
 
1423
        SET_BIT(payload->Ctl_16, cpu_to_le16(DESC_CTL_DONE));
 
1424
        SET_BIT(txdesc->Ctl_8, DESC_CTL_DONE);
 
1425
        acx_clean_tx_desc(priv);
 
1426
        /* ----------------------------------------------
 
1427
        ** check if there are still descriptors that have
 
1428
        ** to be sent. acx_clean_tx_desc() should
 
1429
        ** have set the next non-free descriptor position
 
1430
        ** in tx_tail...
 
1431
        ** ------------------------------------------- */
 
1432
        descnum=ticontext->tx_tail;
 
1433
        txdesc=&(ticontext->pTxDescQPool[descnum]);
 
1434
        if (!(txdesc->Ctl_8 & DESC_CTL_HOSTOWN)) {
 
1435
                acx100usb_prepare_tx(priv,txdesc);
 
1436
        } else {
 
1437
                /* ----------------------------------------------
 
1438
                ** now wake the output queue...
 
1439
                ** ------------------------------------------- */
 
1440
                if (priv->dev_state_mask&ACX_STATE_IFACE_UP) acx_wake_queue(priv->netdev, "for next Tx");
 
1441
        }
 
1442
}
 
1443
 
 
1444
 
 
1445
/* ---------------------------------------------------------------------------
 
1446
** acx100usb_close():
 
1447
** Inputs:
 
1448
**    dev -> Pointer to network device structure
 
1449
** ---------------------------------------------------------------------------
 
1450
** Returns:
 
1451
**  (int) 0 on success, or error-code 
 
1452
**
 
1453
** Description:
 
1454
**  This function stops the network functionality of the interface (invoked
 
1455
**  when the user calls ifconfig <wlan> down). The tx queue is halted and
 
1456
**  the device is marked as down. In case there were any pending USB bulk
 
1457
**  transfers, these are unlinked (asynchronously). The module in-use count
 
1458
**  is also decreased in this function.
 
1459
** ------------------------------------------------------------------------- */
 
1460
 
 
1461
static int acx100usb_close(struct net_device *dev)
 
1462
{
 
1463
        wlandevice_t *priv;
 
1464
        client_t client;
 
1465
        int i,already_down;
 
1466
        if (!(dev->priv)) {
 
1467
                printk(KERN_ERR SHORTNAME "dev->priv empty, FAILED.\n");
 
1468
                return -ENODEV;
 
1469
        }
 
1470
        priv=dev->priv;
 
1471
        FN_ENTER;
 
1472
        /* ------------------------------
 
1473
        ** Transmit a disassociate frame
 
1474
        ** --------------------------- */
 
1475
        acx_transmit_disassoc(&client,priv);
 
1476
        /* --------------------------------
 
1477
        * stop the transmit queue...
 
1478
        * ------------------------------ */
 
1479
        if (!acx_queue_stopped(dev)) {
 
1480
                acx_stop_queue(dev, "on iface stop");
 
1481
        }
 
1482
        acx_flush_task_scheduler();
 
1483
        /* --------------------------------
 
1484
        ** mark the device as DOWN
 
1485
        ** ----------------------------- */
 
1486
        if (priv->dev_state_mask&ACX_STATE_IFACE_UP) {
 
1487
                already_down=0;
 
1488
                CLEAR_BIT(priv->dev_state_mask, ACX_STATE_IFACE_UP);
 
1489
        } else
 
1490
                already_down=1;
 
1491
        /* --------------------------------------
 
1492
         * wait until all tx are out...
 
1493
         * ----------------------------------- */
 
1494
        for (i=0;i<ACX100_USB_NUM_BULK_URBS;i++) {
 
1495
                while (priv->bulktx_urbs[i]->status==-EINPROGRESS) {
 
1496
                        mdelay(5);
 
1497
                }
 
1498
        }
 
1499
        /* ----------------------------------------
 
1500
        * interrupt pending bulk rx transfers ....
 
1501
        * ------------------------------------- */
 
1502
        for (i=0;i<ACX100_USB_NUM_BULK_URBS;i++) {
 
1503
                if (priv->bulkrx_urbs[i]->status==-EINPROGRESS) usb_unlink_urb(priv->bulkrx_urbs[i]);
 
1504
                while (priv->bulkrx_urbs[i]->status==-EINPROGRESS) { 
 
1505
                        mdelay(5);
 
1506
                }
 
1507
        }
 
1508
        /* ----------------------------------------------------
 
1509
         * stop any pending tx URBs...
 
1510
         * ------------------------------------------------- */
 
1511
        for (i=0;i<ACX100_USB_NUM_BULK_URBS;i++) {
 
1512
                if (priv->bulktx_urbs[i]->status==-EINPROGRESS) usb_unlink_urb(priv->bulktx_urbs[i]);
 
1513
                while (priv->bulktx_urbs[i]->status==-EINPROGRESS) { 
 
1514
                        mdelay(20);
 
1515
                }
 
1516
        }
 
1517
        /* ------------------------
 
1518
        ** disable rx and tx ...
 
1519
        ** --------------------- */
 
1520
        acx_issue_cmd(priv,ACX1xx_CMD_DISABLE_TX,NULL,0,ACX_CMD_TIMEOUT_DEFAULT);
 
1521
        acx_issue_cmd(priv,ACX1xx_CMD_DISABLE_RX,NULL,0,ACX_CMD_TIMEOUT_DEFAULT);
 
1522
        /* -------------------------
 
1523
        ** power down the device...
 
1524
        ** ---------------------- */
 
1525
        acx_issue_cmd(priv,ACX1xx_CMD_SLEEP,NULL,0,ACX_CMD_TIMEOUT_DEFAULT);
 
1526
        /* --------------------------------------------
 
1527
        ** decrease module-in-use count (if necessary)
 
1528
        ** ----------------------------------------- */
 
1529
        if (!already_down) WLAN_MOD_DEC_USE_COUNT;
 
1530
        FN_EXIT1(0);
 
1531
        return 0;
 
1532
}
 
1533
 
 
1534
 
 
1535
 
 
1536
/* ---------------------------------------------------------------------------
 
1537
** acx100usb_start_xmit():
 
1538
** Inputs:
 
1539
**    skb -> Pointer to sk_buffer that contains the data to send 
 
1540
**    dev -> Pointer to the network device this transfer is directed to
 
1541
** ---------------------------------------------------------------------------
 
1542
** Returns:
 
1543
**  (int) 0 on success, or error-code
 
1544
**
 
1545
** Description:
 
1546
** ------------------------------------------------------------------------- */
 
1547
 
 
1548
static int acx100usb_start_xmit(struct sk_buff *skb, netdevice_t * dev) {
 
1549
        int txresult = 0;
 
1550
        unsigned long flags;
 
1551
        wlandevice_t *priv = (wlandevice_t *) dev->priv;
 
1552
        struct txdescriptor *tx_desc;
 
1553
        int templen;
 
1554
 
 
1555
        FN_ENTER;
 
1556
 
 
1557
        if (!skb) {
 
1558
                return 0;
 
1559
        }
 
1560
        if (!priv) {
 
1561
                return 1;
 
1562
        }
 
1563
  /*
 
1564
  if (!(priv->open)) {
 
1565
                return 1;
 
1566
        }
 
1567
  */
 
1568
        /* --------------------------------------
 
1569
        ** if the device is otherwise locked,
 
1570
        ** bail-out...
 
1571
        ** ----------------------------------- */
 
1572
        if (acx_lock(priv, &flags))
 
1573
                return 1;
 
1574
        /* --------------------------------------
 
1575
        ** if the queue is halted, there is no point
 
1576
        ** in sending out data...
 
1577
        ** ----------------------------------- */
 
1578
        if (acx_queue_stopped(dev)) {
 
1579
                acxlog(L_STD, "%s: called when queue stopped\n", __func__);
 
1580
                txresult = 1;
 
1581
                goto end;
 
1582
        }
 
1583
        /* --------------------------------------
 
1584
        ** there is no one to talk to...
 
1585
        ** ----------------------------------- */
 
1586
        if (priv->status != ACX_STATUS_4_ASSOCIATED) {
 
1587
                printk(KERN_INFO SHORTNAME "trying to xmit, but not associated yet: aborting.\n");
 
1588
                /* silently drop the packet, since we're not connected yet */
 
1589
                dev_kfree_skb(skb);
 
1590
                priv->stats.tx_errors++;
 
1591
                txresult = 0;
 
1592
                goto end;
 
1593
        }
 
1594
#if 0
 
1595
        /* we're going to transmit now, so stop another packet from entering.
 
1596
         * FIXME: most likely we shouldn't do it like that, but instead:
 
1597
         * stop the queue during card init, then wake the queue once
 
1598
         * we're associated to the network, then stop the queue whenever
 
1599
         * we don't have any free Tx buffers left, and wake it again once a
 
1600
         * Tx buffer becomes free again. And of course also stop the
 
1601
         * queue once we lose association to the network (since it
 
1602
         * doesn't make sense to allow more user packets if we can't
 
1603
         * forward them to a network).
 
1604
         * FIXME: Hmm, seems this is all wrong. We SHOULD leave the
 
1605
         * queue open from the beginning (as long as we're not full,
 
1606
         * and also even before we're even associated),
 
1607
         * otherwise we'll get NETDEV WATCHDOG transmit timeouts... */
 
1608
        acx_stop_queue(dev, "during Tx");
 
1609
#endif
 
1610
#if UNUSED
 
1611
        if (acx_lock(priv,&flags)) ...
 
1612
 
 
1613
        memset(pb, 0, sizeof(wlan_pb_t) /*0x14*4 */ );
 
1614
 
 
1615
        pb->ethhostbuf = skb;
 
1616
        pb->ethbuf = skb->data;
 
1617
#endif
 
1618
        templen = skb->len;
 
1619
        /* ------------------------------------
 
1620
        ** get the next free tx descriptor...
 
1621
        ** -------------------------------- */
 
1622
        tx_desc = acx_get_tx_desc(priv);
 
1623
        if (!tx_desc) {
 
1624
                acxlog(L_BINSTD,"BUG: txdesc ring full\n");
 
1625
                txresult = 1;
 
1626
                goto end;
 
1627
        }
 
1628
        /* ------------------------------------
 
1629
        ** convert the ethernet frame into our
 
1630
        ** own tx descriptor type...
 
1631
        ** -------------------------------- */
 
1632
        acx_ether_to_txdesc(priv,tx_desc,skb);
 
1633
        /* -------------------------
 
1634
        ** free the skb
 
1635
        ** ---------------------- */
 
1636
        dev_kfree_skb(skb);
 
1637
        dev->trans_start = jiffies;
 
1638
        /* -----------------------------------
 
1639
        ** until the packages are flushed out,
 
1640
        ** stop the queue...
 
1641
        ** -------------------------------- */
 
1642
        acx_stop_queue(dev, "after Tx");
 
1643
        /* -----------------------------------
 
1644
        ** transmit the data...
 
1645
        ** -------------------------------- */
 
1646
        acx_dma_tx_data(priv, tx_desc);  /* this function finally calls acx100usb_tx_data() */
 
1647
        txresult=0;
 
1648
        /* -----------------------------------
 
1649
        ** statistical bookkeeping...
 
1650
        ** -------------------------------- */
 
1651
        priv->stats.tx_packets++;
 
1652
        priv->stats.tx_bytes += templen;
 
1653
end:
 
1654
        acx_unlock(priv, &flags);
 
1655
        FN_EXIT1(txresult);
 
1656
        return txresult;
 
1657
}
 
1658
 
 
1659
 
 
1660
 
 
1661
static struct net_device_stats *acx_get_stats(netdevice_t *dev) {
 
1662
        wlandevice_t *priv = (wlandevice_t *)dev->priv;
 
1663
        FN_ENTER;
 
1664
        FN_EXIT1((int)&priv->stats);
 
1665
        return &priv->stats;
 
1666
}
 
1667
 
 
1668
 
 
1669
 
 
1670
static struct iw_statistics *acx_get_wireless_stats(netdevice_t *dev) {
 
1671
        wlandevice_t *priv = (wlandevice_t *)dev->priv;
 
1672
        FN_ENTER;
 
1673
        FN_EXIT1((int)&priv->stats);
 
1674
        return &priv->wstats;
 
1675
}
 
1676
 
 
1677
 
 
1678
 
 
1679
static void acx100usb_set_rx_mode(struct net_device *dev)
 
1680
{
 
1681
}
 
1682
 
 
1683
 
 
1684
 
 
1685
#ifdef HAVE_TX_TIMEOUT
 
1686
static void acx100usb_tx_timeout(struct net_device *dev) {
 
1687
        wlandevice_t *priv;
 
1688
        int i;
 
1689
        FN_ENTER;
 
1690
        priv=dev->priv;
 
1691
        /* ------------------------------------
 
1692
        ** unlink the URBs....
 
1693
        ** --------------------------------- */
 
1694
        for (i=0;i<ACX100_USB_NUM_BULK_URBS;i++) {      
 
1695
                if (priv->bulktx_urbs[i]->status==-EINPROGRESS) usb_unlink_urb(priv->bulktx_urbs[i]);
 
1696
        }
 
1697
        /* ------------------------------------
 
1698
        ** TODO: stats update
 
1699
        ** --------------------------------- */
 
1700
        FN_EXIT0();
 
1701
}
 
1702
#endif
 
1703
 
 
1704
 
 
1705
 
 
1706
 
 
1707
 
 
1708
/* ---------------------------------------------------------------------------
 
1709
** init_module():
 
1710
** Inputs:
 
1711
**  <NONE>
 
1712
** ---------------------------------------------------------------------------
 
1713
** Returns:
 
1714
**  (int) Errorcode on failure, 0 on success
 
1715
**
 
1716
** Description:
 
1717
**  This function is invoked upon loading of the kernel module. It registers
 
1718
**  itself at the Kernel's USB subsystem.
 
1719
** ------------------------------------------------------------------------ */
 
1720
 
 
1721
int init_module() {
 
1722
        int err;
 
1723
        printk(KERN_INFO "Initializing acx100 WLAN USB kernel module\n");
 
1724
        /* ------------------------------------------------------
 
1725
        ** Register this driver to the USB subsystem
 
1726
        ** --------------------------------------------------- */
 
1727
        err=usb_register(&acx100usb_driver);
 
1728
        if (!err) {
 
1729
                return(err);
 
1730
        }
 
1731
        return(0);
 
1732
}
 
1733
 
 
1734
 
 
1735
 
 
1736
/* ---------------------------------------------------------------------------
 
1737
** cleanup_module():
 
1738
** Inputs:
 
1739
**  <NONE>
 
1740
** ---------------------------------------------------------------------------
 
1741
** Returns:
 
1742
**  <NOTHING>
 
1743
**
 
1744
** Description:
 
1745
**  This function is invoked as last step of the module unloading. It simply
 
1746
**  deregisters this module at the Kernel's USB subsystem.
 
1747
** ------------------------------------------------------------------------- */
 
1748
 
 
1749
void cleanup_module() {
 
1750
        usb_deregister(&acx100usb_driver);
 
1751
        printk(KERN_INFO "Cleaning up acx100 WLAN USB kernel module\n");
 
1752
}
 
1753
 
 
1754
 
 
1755
/* ---------------------------------------------------------------------------
 
1756
**                                   DEBUG STUFF
 
1757
** --------------------------------------------------------------------------- */
 
1758
 
 
1759
#if ACX_DEBUG
 
1760
#if USB_24
 
1761
static char *acx100usb_pstatus(int val)
 
1762
{
 
1763
#define CASE(status)    case status: return ""#status""
 
1764
        switch (val) {
 
1765
                CASE(USB_ST_NOERROR);
 
1766
                CASE(USB_ST_CRC);
 
1767
                CASE(USB_ST_BITSTUFF);
 
1768
                CASE(USB_ST_DATAOVERRUN);
 
1769
                CASE(USB_ST_BUFFEROVERRUN);
 
1770
                CASE(USB_ST_BUFFERUNDERRUN);
 
1771
                CASE(USB_ST_SHORT_PACKET);
 
1772
                CASE(USB_ST_URB_KILLED);
 
1773
                CASE(USB_ST_URB_PENDING);
 
1774
                CASE(USB_ST_REMOVED);
 
1775
                CASE(USB_ST_TIMEOUT);
 
1776
                CASE(USB_ST_NOTSUPPORTED);
 
1777
                CASE(USB_ST_BANDWIDTH_ERROR);
 
1778
                CASE(USB_ST_URB_INVALID_ERROR);
 
1779
                CASE(USB_ST_URB_REQUEST_ERROR);
 
1780
                CASE(USB_ST_STALL);
 
1781
        default:
 
1782
                return "UNKNOWN";
 
1783
        }
 
1784
}
 
1785
#else
 
1786
static char *acx100usb_pstatus(int val)
 
1787
{
 
1788
        static char status[80];
 
1789
 
 
1790
        if (val < 0)
 
1791
                sprintf(status, "errno %d\n", -val);
 
1792
        else
 
1793
                sprintf(status, "length %d\n", val);
 
1794
 
 
1795
        return status;
 
1796
}
 
1797
#endif
 
1798
 
 
1799
static void dump_device(struct usb_device *usbdev)
 
1800
{
 
1801
  int i;
 
1802
  struct usb_config_descriptor *cd;
 
1803
 
 
1804
  printk(KERN_INFO "acx100 device dump:\n");
 
1805
  printk(KERN_INFO "  devnum: %d\n",usbdev->devnum);
 
1806
  printk(KERN_INFO "  speed: %d\n",usbdev->speed);
 
1807
  printk(KERN_INFO "  tt: 0x%X\n",(unsigned int)(usbdev->tt));
 
1808
  printk(KERN_INFO "  ttport: %d\n",(unsigned int)(usbdev->ttport));
 
1809
  printk(KERN_INFO "  toggle[0]: 0x%X  toggle[1]: 0x%X\n",(unsigned int)(usbdev->toggle[0]),(unsigned int)(usbdev->toggle[1]));
 
1810
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8)
 
1811
  /* halted removed in 2.6.9-rc1 */
 
1812
  /* DOH, Canbreak... err... Mandrake decided to do their very own very
 
1813
   * special version "2.6.8.1" which already includes this change, so we
 
1814
   * need to blacklist that version already (i.e. 2.6.8) */
 
1815
  printk(KERN_INFO "  halted[0]: 0x%X  halted[1]: 0x%X\n",usbdev->halted[0],usbdev->halted[1]);
 
1816
#endif
 
1817
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
 
1818
  /* This saw a change after 2.6.10 */
 
1819
  printk(KERN_INFO "  ep_in wMaxPacketSize: ");
 
1820
  for(i = 0; i < 16; ++i) printk("%d ", usbdev->ep_in[i]->desc.wMaxPacketSize);
 
1821
  printk("\n");
 
1822
  printk(KERN_INFO "  ep_out wMaxPacketSize: ");
 
1823
  for(i = 0; i < 15; ++i) printk("%d ", usbdev->ep_out[i]->desc.wMaxPacketSize);
 
1824
  printk("\n");
 
1825
#else
 
1826
  printk(KERN_INFO "  epmaxpacketin: ");
 
1827
  for (i=0;i<16;i++) printk("%d ",usbdev->epmaxpacketin[i]);
 
1828
  printk("\n");
 
1829
  printk(KERN_INFO "  epmaxpacketout: ");
 
1830
  for (i=0;i<16;i++) printk("%d ",usbdev->epmaxpacketout[i]);
 
1831
  printk("\n");
 
1832
#endif
 
1833
  printk(KERN_INFO "  parent: 0x%X\n",(unsigned int)(usbdev->parent));
 
1834
  printk(KERN_INFO "  bus: 0x%X\n",(unsigned int)(usbdev->bus));
 
1835
#if NO_DATATYPE
 
1836
  printk(KERN_INFO "  configs: ");
 
1837
  for (i=0;i<usbdev->descriptor.bNumConfigurations;i++) printk("0x%X ",usbdev->config[i]);
 
1838
  printk("\n");
 
1839
#endif
 
1840
  printk(KERN_INFO "  actconfig: %p\n",usbdev->actconfig);
 
1841
  dump_device_descriptor(&(usbdev->descriptor));
 
1842
#if USB_24
 
1843
  cd = usbdev->actconfig;
 
1844
#else
 
1845
  cd = &usbdev->config->desc;
 
1846
#endif
 
1847
  dump_config_descriptor(cd);
 
1848
#if USB_24
 
1849
  {
 
1850
    struct usb_interface *ifc;
 
1851
    ifc=cd->interface;
 
1852
    if (ifc) {
 
1853
      printk(KERN_INFO "iface: altsetting=%p act_altsetting=%d  num_altsetting=%d  max_altsetting=%d\n",ifc->altsetting,ifc->act_altsetting,ifc->num_altsetting,ifc->max_altsetting);
 
1854
      dump_interface_descriptor(ifc->altsetting);
 
1855
      dump_endpoint_descriptor(ifc->altsetting->endpoint);
 
1856
    }
 
1857
  }
 
1858
#endif
 
1859
}
 
1860
 
 
1861
 
 
1862
static void dump_config_descriptor(struct usb_config_descriptor *cd)
 
1863
{
 
1864
  printk(KERN_INFO "Configuration Descriptor:\n");
 
1865
  if (!cd) {
 
1866
    printk(KERN_INFO "NULL\n");
 
1867
    return;
 
1868
  }
 
1869
  printk(KERN_INFO "  bLength: %d (0x%X)\n",cd->bLength,cd->bLength);
 
1870
  printk(KERN_INFO "  bDescriptorType: %d (0x%X)\n",cd->bDescriptorType,cd->bDescriptorType);
 
1871
  printk(KERN_INFO "  bNumInterfaces: %d (0x%X)\n",cd->bNumInterfaces,cd->bNumInterfaces);
 
1872
  printk(KERN_INFO "  bConfigurationValue: %d (0x%X)\n",cd->bConfigurationValue,cd->bConfigurationValue);
 
1873
  printk(KERN_INFO "  iConfiguration: %d (0x%X)\n",cd->iConfiguration,cd->iConfiguration);
 
1874
  printk(KERN_INFO "  bmAttributes: %d (0x%X)\n",cd->bmAttributes,cd->bmAttributes);
 
1875
  /* printk(KERN_INFO "  MaxPower: %d (0x%X)\n",cd->bMaxPower,cd->bMaxPower); */
 
1876
}
 
1877
 
 
1878
static void dump_device_descriptor(struct usb_device_descriptor *dd)
 
1879
{
 
1880
  printk(KERN_INFO "Device Descriptor:\n");
 
1881
  if (!dd) {
 
1882
    printk(KERN_INFO "NULL\n");
 
1883
    return;
 
1884
  }
 
1885
  printk(KERN_INFO "  bLength: %d (0x%X)\n",dd->bLength,dd->bLength);
 
1886
  printk(KERN_INFO "  bDescriptortype: %d (0x%X)\n",dd->bDescriptorType,dd->bDescriptorType);
 
1887
  printk(KERN_INFO "  bcdUSB: %d (0x%X)\n",dd->bcdUSB,dd->bcdUSB);
 
1888
  printk(KERN_INFO "  bDeviceClass: %d (0x%X)\n",dd->bDeviceClass,dd->bDeviceClass);
 
1889
  printk(KERN_INFO "  bDeviceSubClass: %d (0x%X)\n",dd->bDeviceSubClass,dd->bDeviceSubClass);
 
1890
  printk(KERN_INFO "  bDeviceProtocol: %d (0x%X)\n",dd->bDeviceProtocol,dd->bDeviceProtocol);
 
1891
  printk(KERN_INFO "  bMaxPacketSize0: %d (0x%X)\n",dd->bMaxPacketSize0,dd->bMaxPacketSize0);
 
1892
  printk(KERN_INFO "  idVendor: %d (0x%X)\n",dd->idVendor,dd->idVendor);
 
1893
  printk(KERN_INFO "  idProduct: %d (0x%X)\n",dd->idProduct,dd->idProduct);
 
1894
  printk(KERN_INFO "  bcdDevice: %d (0x%X)\n",dd->bcdDevice,dd->bcdDevice);
 
1895
  printk(KERN_INFO "  iManufacturer: %d (0x%X)\n",dd->iManufacturer,dd->iManufacturer);
 
1896
  printk(KERN_INFO "  iProduct: %d (0x%X)\n",dd->iProduct,dd->iProduct);
 
1897
  printk(KERN_INFO "  iSerialNumber: %d (0x%X)\n",dd->iSerialNumber,dd->iSerialNumber);
 
1898
  printk(KERN_INFO "  bNumConfigurations: %d (0x%X)\n",dd->bNumConfigurations,dd->bNumConfigurations);
 
1899
}
 
1900
 
 
1901
#if USB_24
 
1902
static void dump_usbblock(char *block,int bytes)
 
1903
{
 
1904
  int i;
 
1905
  for (i=0;i<bytes;i++) {
 
1906
    if ((i&0xF)==0) {
 
1907
      if (i!=0) printk("\n");
 
1908
      printk(KERN_INFO);
 
1909
    }
 
1910
    printk("%02X ",(unsigned char)(block[i]));
 
1911
  }
 
1912
}
 
1913
 
 
1914
static void dump_endpoint_descriptor(struct usb_endpoint_descriptor *ep)
 
1915
{
 
1916
  printk(KERN_INFO "Endpoint Descriptor:\n");
 
1917
  if (!ep) {
 
1918
    printk(KERN_INFO "NULL\n");
 
1919
    return;
 
1920
  }
 
1921
  printk(KERN_INFO "  bLength: %d (0x%X)\n",ep->bLength,ep->bLength);
 
1922
  printk(KERN_INFO "  bDescriptorType: %d (0x%X)\n",ep->bDescriptorType,ep->bDescriptorType);
 
1923
  printk(KERN_INFO "  bEndpointAddress: %d (0x%X)\n",ep->bEndpointAddress,ep->bEndpointAddress);
 
1924
  printk(KERN_INFO "  bmAttributes: 0x%X\n",ep->bmAttributes);
 
1925
  printk(KERN_INFO "  wMaxPacketSize: %d (0x%X)\n",ep->wMaxPacketSize,ep->wMaxPacketSize);
 
1926
  printk(KERN_INFO "  bInterval: %d (0x%X)\n",ep->bInterval,ep->bInterval);
 
1927
  printk(KERN_INFO "  bRefresh: %d (0x%X)\n",ep->bRefresh,ep->bRefresh);
 
1928
  printk(KERN_INFO "  bSyncAdrress: %d (0x%X)\n",ep->bSynchAddress,ep->bSynchAddress);
 
1929
}
 
1930
 
 
1931
static void dump_interface_descriptor(struct usb_interface_descriptor *id)
 
1932
{
 
1933
  printk(KERN_INFO "Interface Descriptor:\n");
 
1934
  if (!id) {
 
1935
    printk(KERN_INFO "NULL\n");
 
1936
    return;
 
1937
  }
 
1938
  printk(KERN_INFO "  bLength: %d (0x%X)\n",id->bLength,id->bLength);
 
1939
  printk(KERN_INFO "  bDescriptorType: %d (0x%X)\n",id->bDescriptorType,id->bDescriptorType);
 
1940
  printk(KERN_INFO "  bInterfaceNumber: %d (0x%X)\n",id->bInterfaceNumber,id->bInterfaceNumber);
 
1941
  printk(KERN_INFO "  bAlternateSetting: %d (0x%X)\n",id->bAlternateSetting,id->bAlternateSetting);
 
1942
  printk(KERN_INFO "  bNumEndpoints: %d (0x%X)\n",id->bNumEndpoints,id->bNumEndpoints);
 
1943
  printk(KERN_INFO "  bInterfaceClass: %d (0x%X)\n",id->bInterfaceClass,id->bInterfaceClass);
 
1944
  printk(KERN_INFO "  bInterfaceSubClass: %d (0x%X)\n",id->bInterfaceSubClass,id->bInterfaceSubClass);
 
1945
  printk(KERN_INFO "  bInterfaceProtocol: %d (0x%X)\n",id->bInterfaceProtocol,id->bInterfaceProtocol);
 
1946
  printk(KERN_INFO "  iInterface: %d (0x%X)\n",id->iInterface,id->iInterface);
 
1947
#if USB_24
 
1948
  printk(KERN_INFO "  endpoint: 0x%X\n",(unsigned int)(id->endpoint));
 
1949
#endif
 
1950
}
 
1951
#endif
 
1952
 
 
1953
#endif