1 /***********************************************************************
2 ** Copyright (C) 2003 ACX100 Open Source Project
4 ** The contents of this file are subject to the Mozilla Public
5 ** License Version 1.1 (the "License"); you may not use this file
6 ** except in compliance with the License. You may obtain a copy of
7 ** the License at http://www.mozilla.org/MPL/
9 ** Software distributed under the License is distributed on an "AS
10 ** IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11 ** implied. See the License for the specific language governing
12 ** rights and limitations under the License.
14 ** Alternatively, the contents of this file may be used under the
15 ** terms of the GNU Public License version 2 (the "GPL"), in which
16 ** case the provisions of the GPL are applicable instead of the
17 ** above. If you wish to allow the use of your version of this file
18 ** only under the terms of the GPL and not to allow others to use
19 ** your version of this file under the MPL, indicate your decision
20 ** by deleting the provisions above and replace them with the notice
21 ** and other provisions required by the GPL. If you do not delete
22 ** the provisions above, a recipient may use your version of this
23 ** file under either the MPL or the GPL.
24 ** ---------------------------------------------------------------------
25 ** Inquiries regarding the ACX100 Open Source Project can be
28 ** acx100-users@lists.sf.net
29 ** http://acx100.sf.net
30 ** ---------------------------------------------------------------------
33 /***********************************************************************
34 ** USB support for TI ACX100 based devices. Many parts are taken from
38 ** Martin Wawro <martin.wawro AT uni-dortmund.de>
39 ** Andreas Mohr <andi AT lisas.de>
42 ** - Note that this driver relies on a native little-endian byteformat
46 ** callback functions called by USB core are running in interrupt context
47 ** and thus have names with _i_.
51 #include <linux/version.h>
52 #include <linux/config.h>
53 #include <linux/types.h>
54 #include <linux/module.h>
55 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
56 #include <linux/moduleparam.h>
58 #include <linux/kernel.h>
59 #include <linux/usb.h>
60 #include <linux/netdevice.h>
61 #include <linux/rtnetlink.h>
62 #include <linux/etherdevice.h>
63 #include <linux/wireless.h>
64 #if WIRELESS_EXT >= 13
65 #include <net/iw_handler.h>
71 /***********************************************************************
73 /* number of endpoints of an interface */
74 #define NUM_EP(intf) (intf)->altsetting[0].desc.bNumEndpoints
75 #define EP(intf, nr) (intf)->altsetting[0].endpoint[(nr)].desc
76 #define GET_DEV(udev) usb_get_dev((udev))
77 #define PUT_DEV(udev) usb_put_dev((udev))
78 #define SET_NETDEV_OWNER(ndev, owner) /* not needed anymore ??? */
80 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
81 /* removed in 2.6.14. We will use fake value for now */
82 #define URB_ASYNC_UNLINK 0
86 /***********************************************************************
88 #define ACX100_VENDOR_ID 0x2001
89 #define ACX100_PRODUCT_ID_UNBOOTED 0x3B01
90 #define ACX100_PRODUCT_ID_BOOTED 0x3B00
92 /* RX-Timeout: NONE (request waits forever) */
93 #define ACX100_USB_RX_TIMEOUT (0)
95 #define ACX100_USB_TX_TIMEOUT (4*HZ)
97 #define USB_CTRL_HARD_TIMEOUT 5500 /* steps in ms */
100 /***********************************************************************
103 static int acx100usb_e_probe(struct usb_interface
*, const struct usb_device_id
*);
104 static void acx100usb_e_disconnect(struct usb_interface
*);
105 static void acx100usb_i_complete_tx(struct urb
*, struct pt_regs
*);
106 static void acx100usb_i_complete_rx(struct urb
*, struct pt_regs
*);
107 static int acx100usb_e_open(struct net_device
*);
108 static int acx100usb_e_close(struct net_device
*);
109 static void acx100usb_i_set_rx_mode(struct net_device
*);
110 static int acx100usb_e_init_network_device(struct net_device
*);
111 static int acx100usb_boot(struct usb_device
*);
113 static void acx100usb_l_poll_rx(wlandevice_t
*, usb_rx_t
* rx
);
115 static void acx100usb_i_tx_timeout(struct net_device
*);
117 /* static void dump_device(struct usb_device *); */
118 /* static void dump_device_descriptor(struct usb_device_descriptor *); */
119 /* static void dump_config_descriptor(struct usb_config_descriptor *); */
121 /***********************************************************************
124 #define TXBUFSIZE sizeof(usb_txbuffer_t)
125 //// Bogus! We CANNOT pretend that rxbuffer_t is larger than it is.
126 /* make it a multiply of 64 */
127 /* #define RXBUFSIZE ((sizeof(rxbuffer_t)+63) & ~63) */
128 #define RXBUFSIZE sizeof(rxbuffer_t)
130 static const struct usb_device_id
132 { USB_DEVICE(ACX100_VENDOR_ID
, ACX100_PRODUCT_ID_BOOTED
) },
133 { USB_DEVICE(ACX100_VENDOR_ID
, ACX100_PRODUCT_ID_UNBOOTED
) },
138 /* USB driver data structure as required by the kernel's USB core */
139 static struct usb_driver
142 .owner
= THIS_MODULE
,
143 .probe
= acx100usb_e_probe
,
144 .disconnect
= acx100usb_e_disconnect
,
145 .id_table
= acx100usb_ids
149 /***********************************************************************
153 ** When the function is usb_kill_urb, the urb lifecycle is stopped. This
154 ** function is usually used when the device is disconnected from the system,
155 ** in the disconnect callback. For some drivers, the usb_unlink_urb function
156 ** should be used to tell the USB core to stop an urb. This function does not
157 ** wait for the urb to be fully stopped before returning to the caller.
158 ** This is useful for stoppingthe urb while in an interrupt handler or when
159 ** a spinlock is held, as waiting for a urb to fully stop requires the ability
160 ** for the USB core to put the calling process to sleep. This function requires
161 ** that the URB_ASYNC_UNLINK flag value be set in the urb that is being asked
162 ** to be stopped in order to work properly.
164 ** (URB_ASYNC_UNLINK is obsolete, usb_unlink_urb will always be
165 ** asynchronous while usb_kill_urb is synchronous and should be called
166 ** directly (drivers/usb/core/urb.c))
168 ** In light of this, timeout is just for paranoid reasons...
170 * Actually, it's useful for debugging. If we reach timeout, we're doing
171 * something wrong with the urbs.
174 acxusb_unlink_urb(struct urb
* urb
)
179 if (urb
->status
== -EINPROGRESS
) {
183 while (--timeout
&& urb
->status
== -EINPROGRESS
) {
187 printk("acx_usb: urb unlink timeout!\n");
193 /***********************************************************************
194 ** EEPROM and PHY read/write helpers
196 /***********************************************************************
197 ** acxusb_s_read_phy_reg
200 acxusb_s_read_phy_reg(wlandevice_t
*priv
, u32 reg
, u8
*charbuf
)
202 mem_read_write_t mem
;
206 mem
.addr
= cpu_to_le16(reg
);
207 mem
.type
= cpu_to_le16(0x82);
208 mem
.len
= cpu_to_le32(4);
209 acx_s_issue_cmd(priv
, ACX1xx_CMD_MEM_READ
, &mem
, sizeof(mem
));
211 acxlog(L_DEBUG
, "read radio PHY[0x%04X]=0x%02X\n", reg
, *charbuf
);
218 /***********************************************************************
221 acxusb_s_write_phy_reg(wlandevice_t
*priv
, u32 reg
, u8 value
)
223 mem_read_write_t mem
;
227 mem
.addr
= cpu_to_le16(reg
);
228 mem
.type
= cpu_to_le16(0x82);
229 mem
.len
= cpu_to_le32(4);
231 acx_s_issue_cmd(priv
, ACX1xx_CMD_MEM_WRITE
, &mem
, sizeof(mem
));
232 acxlog(L_DEBUG
, "write radio PHY[0x%04X]=0x%02X\n", reg
, value
);
239 /***********************************************************************
240 ** acx_s_issue_cmd_timeo
241 ** Excecutes a command in the command mailbox
243 ** buffer = a pointer to the data.
244 ** The data must not include 4 byte command header
247 /* TODO: ideally we shall always know how much we need
248 ** and this shall be 0 */
249 #define BOGUS_SAFETY_PADDING 0x40
252 #define FUNC "issue_cmd"
256 acxusb_s_issue_cmd_timeo(
265 acxusb_s_issue_cmd_timeo_debug(
274 /* USB ignores timeout param */
276 struct usb_device
*usbdev
;
279 u16 status ACX_PACKED
;
280 u8 data
[1] ACX_PACKED
;
283 int acklen
, blocklen
, inpipe
, outpipe
;
289 devname
= priv
->netdev
->name
;
290 if (!devname
|| !devname
[0])
293 acxlog(L_CTL
, FUNC
"(cmd:%s,buflen:%u,type:0x%04X)\n",
295 buffer
? le16_to_cpu(((acx_ie_generic_t
*)buffer
)->type
) : -1);
297 loc
= kmalloc(buflen
+ 4 + BOGUS_SAFETY_PADDING
, GFP_KERNEL
);
299 printk("%s: "FUNC
"(): no memory for data buffer\n", devname
);
303 /* get context from wlandevice */
304 usbdev
= priv
->usbdev
;
306 /* check which kind of command was issued */
307 loc
->cmd
= cpu_to_le16(cmd
);
310 /* NB: buflen == frmlen + 4
312 ** Interrogate: write 8 bytes: (cmd,status,rid,frmlen), then
313 ** read (cmd,status,rid,frmlen,data[frmlen]) back
315 ** Configure: write (cmd,status,rid,frmlen,data[frmlen])
317 ** Possibly bogus special handling of ACX1xx_IE_SCAN_STATUS removed
320 /* now write the parameters of the command if needed */
321 acklen
= buflen
+ 4 + BOGUS_SAFETY_PADDING
;
323 if (buffer
&& buflen
) {
324 /* if it's an INTERROGATE command, just pass the length
325 * of parameters to read, as data */
326 if (cmd
== ACX1xx_CMD_INTERROGATE
) {
330 memcpy(loc
->data
, buffer
, blocklen
);
332 blocklen
+= 4; /* account for cmd,status */
334 /* obtain the I/O pipes */
335 outpipe
= usb_sndctrlpipe(usbdev
, 0);
336 inpipe
= usb_rcvctrlpipe(usbdev
, 0);
337 acxlog(L_CTL
, "ctrl inpipe=0x%X outpipe=0x%X\n", inpipe
, outpipe
);
338 acxlog(L_CTL
, "sending USB control msg (out) (blocklen=%d)\n", blocklen
);
339 if (acx_debug
& L_DATA
)
340 acx_dump_bytes(loc
, blocklen
);
342 result
= usb_control_msg(usbdev
, outpipe
,
343 ACX_USB_REQ_CMD
, /* request */
344 USB_TYPE_VENDOR
|USB_DIR_OUT
, /* requesttype */
349 USB_CTRL_HARD_TIMEOUT
/* timeout in ms */
352 if (result
== -ENODEV
) {
353 acxlog(L_CTL
, "no device present (unplug?)\n");
357 acxlog(L_CTL
, "wrote %d bytes\n", result
);
362 /* check for device acknowledge */
363 acxlog(L_CTL
, "sending USB control msg (in) (acklen=%d)\n", acklen
);
364 loc
->status
= 0; /* delete old status flag -> set to IDLE */
365 //shall we zero out the rest?
366 result
= usb_control_msg(usbdev
, inpipe
,
367 ACX_USB_REQ_CMD
, /* request */
368 USB_TYPE_VENDOR
|USB_DIR_IN
, /* requesttype */
373 USB_CTRL_HARD_TIMEOUT
/* timeout in ms */
376 printk("%s: "FUNC
"(): USB read error %d\n", devname
, result
);
379 if (acx_debug
& L_CTL
) {
380 printk("read %d bytes: ", result
);
381 acx_dump_bytes(loc
, result
);
384 //check for result==buflen+4? Was seen:
386 interrogate(type:ACX100_IE_DOT11_ED_THRESHOLD,len:4)
387 issue_cmd(cmd:ACX1xx_CMD_INTERROGATE,buflen:8,type:4111)
388 ctrl inpipe=0x80000280 outpipe=0x80000200
389 sending USB control msg (out) (blocklen=8)
390 01 00 00 00 0F 10 04 00
392 sending USB control msg (in) (acklen=12) sizeof(loc->data
393 read 4 bytes <==== MUST BE 12!!
396 cmd_status
= le16_to_cpu(loc
->status
);
397 if (cmd_status
!= 1) {
398 printk("%s: "FUNC
"(): cmd_status is not SUCCESS: %d (%s)\n",
399 devname
, cmd_status
, acx_cmd_status_str(cmd_status
));
400 /* TODO: goto bad; ? */
402 if ((cmd
== ACX1xx_CMD_INTERROGATE
) && buffer
&& buflen
) {
403 memcpy(buffer
, loc
->data
, buflen
);
404 acxlog(L_CTL
, "response frame: cmd=0x%04X status=%d\n",
405 le16_to_cpu(loc
->cmd
),
413 /* Give enough info so that callers can avoid
414 ** printing their own diagnostic messages */
416 printk("%s: "FUNC
"(cmd:%s) FAILED\n", devname
, cmdstr
);
418 printk("%s: "FUNC
"(cmd:0x%04X) FAILED\n", devname
, cmd
);
427 /***********************************************************************
428 ** acx100usb_e_probe()
431 ** dev -> Pointer to usb_device structure that may or may not be claimed
432 ** ifNum -> Interface number
433 ** devID -> Device ID (vendor and product specific stuff)
434 ************************************************************************
436 ** (void *) Pointer to (custom) driver context or NULL if we are not interested
437 ** or unable to handle the offered device.
440 ** This function is invoked by the kernel's USB core whenever a new device is
441 ** attached to the system or the module is loaded. It is presented a usb_device
442 ** structure from which information regarding the device is obtained and evaluated.
443 ** In case this driver is able to handle one of the offered devices, it returns
444 ** a non-null pointer to a driver context and thereby claims the device.
447 dummy_netdev_init(struct net_device
*dev
) {}
450 acx100usb_e_probe(struct usb_interface
*intf
, const struct usb_device_id
*devID
)
452 struct usb_device
*usbdev
= interface_to_usbdev(intf
);
453 wlandevice_t
*priv
= NULL
;
454 struct net_device
*dev
= NULL
;
455 struct usb_config_descriptor
*config
;
456 struct usb_endpoint_descriptor
*epdesc
;
457 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
458 struct usb_host_endpoint
*ep
;
460 struct usb_interface_descriptor
*ifdesc
;
462 int numconfigs
, numfaces
, numep
;
468 /* First check if this is the "unbooted" hardware */
469 if ((usbdev
->descriptor
.idVendor
== ACX100_VENDOR_ID
)
470 && (usbdev
->descriptor
.idProduct
== ACX100_PRODUCT_ID_UNBOOTED
)) {
471 /* Boot the device (i.e. upload the firmware) */
472 acx100usb_boot(usbdev
);
474 /* OK, we are done with booting. Normally, the
475 ** ID for the unbooted device should disappear
476 ** and it will not need a driver anyway...so
479 acxlog(L_INIT
, "finished booting, returning from probe()\n");
480 result
= OK
; /* success */
484 if ((usbdev
->descriptor
.idVendor
!= ACX100_VENDOR_ID
)
485 || (usbdev
->descriptor
.idProduct
!= ACX100_PRODUCT_ID_BOOTED
)) {
489 /* Ok, so it's our device and it is already booted */
491 /* Allocate memory for a network device */
492 dev
= alloc_netdev(sizeof(wlandevice_t
), "wlan%d", dummy_netdev_init
);
493 /* (NB: memsets to 0 entire area) */
495 msg
= "acx: no memory for netdev\n";
498 dev
->init
= (void *)&acx100usb_e_init_network_device
;
500 /* Setup private driver context */
501 priv
= netdev_priv(dev
);
503 priv
->dev_type
= DEVTYPE_USB
;
504 priv
->chip_type
= CHIPTYPE_ACX100
;
505 /* FIXME: should be read from register (via firmware) using standard ACX code */
506 priv
->radio_type
= RADIO_MAXIM_0D
;
507 priv
->usbdev
= usbdev
;
509 spin_lock_init(&priv
->lock
); /* initial state: unlocked */
510 sema_init(&priv
->sem
, 1); /* initial state: 1 (upped) */
512 /* Initialize the device context and also check
513 ** if this is really the hardware we know about.
514 ** If not sure, at least notify the user that he
515 ** may be in trouble...
517 numconfigs
= (int)usbdev
->descriptor
.bNumConfigurations
;
519 printk("acx: number of configurations is %d, "
520 "this driver only knows how to handle 1, "
521 "be prepared for surprises\n", numconfigs
);
523 config
= &usbdev
->config
->desc
;
524 numfaces
= config
->bNumInterfaces
;
526 printk("acx: number of interfaces is %d, "
527 "this driver only knows how to handle 1, "
528 "be prepared for surprises\n", numfaces
);
530 ifdesc
= &intf
->altsetting
->desc
;
531 numep
= ifdesc
->bNumEndpoints
;
532 acxlog(L_DEBUG
, "# of endpoints: %d\n", numep
);
534 /* obtain information about the endpoint
535 ** addresses, begin with some default values
539 for (i
= 0; i
< numep
; i
++) {
540 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
541 ep
= usbdev
->ep_in
[i
];
546 epdesc
= usb_epnum_to_ep_desc(usbdev
, i
);
550 if (epdesc
->bmAttributes
& USB_ENDPOINT_XFER_BULK
) {
551 if (epdesc
->bEndpointAddress
& 0x80)
552 priv
->bulkinep
= epdesc
->bEndpointAddress
& 0xF;
554 priv
->bulkoutep
= epdesc
->bEndpointAddress
& 0xF;
557 acxlog(L_DEBUG
, "bulkout ep: 0x%X\n", priv
->bulkoutep
);
558 acxlog(L_DEBUG
, "bulkin ep: 0x%X\n", priv
->bulkinep
);
560 /* Set the packet-size equivalent to the buffer size */
561 /* already done by memset: priv->rxtruncsize = 0; */
562 acxlog(L_DEBUG
, "TXBUFSIZE=%d RXBUFSIZE=%d\n",
563 (int) TXBUFSIZE
, (int) RXBUFSIZE
);
565 priv
->tx_free
= ACX100_USB_NUM_BULK_URBS
;
567 /* Allocate the RX/TX containers. */
568 priv
->usb_tx
= kmalloc(sizeof(usb_tx_t
) * ACX100_USB_NUM_BULK_URBS
,
571 msg
= "acx: no memory for tx container";
574 priv
->usb_rx
= kmalloc(sizeof(usb_rx_t
) * ACX100_USB_NUM_BULK_URBS
,
577 msg
= "acx: no memory for rx container";
581 /* Setup URBs for bulk-in/out messages */
582 for (i
= 0; i
< ACX100_USB_NUM_BULK_URBS
; i
++) {
583 priv
->usb_rx
[i
].urb
= usb_alloc_urb(0, GFP_KERNEL
);
584 if (!priv
->usb_rx
[i
].urb
) {
585 msg
= "acx: no memory for input URB\n";
588 priv
->usb_rx
[i
].urb
->status
= 0;
589 priv
->usb_rx
[i
].priv
= priv
;
591 priv
->usb_tx
[i
].urb
= usb_alloc_urb(0, GFP_KERNEL
);
592 if (!priv
->usb_tx
[i
].urb
) {
593 msg
= "acx: no memory for output URB\n";
596 priv
->usb_tx
[i
].urb
->status
= 0;
597 priv
->usb_tx
[i
].priv
= priv
;
600 usb_set_intfdata(intf
, priv
);
601 SET_NETDEV_DEV(dev
, &intf
->dev
);
603 /* Register the network device */
604 acxlog(L_INIT
, "registering network device\n");
605 result
= register_netdev(dev
);
607 msg
= "acx: failed to register network device "
608 "for USB WLAN (errcode=%d)\n";
612 if (OK
!= acx_proc_register_entries(dev
)) {
613 printk("acx: /proc registration failed\n");
616 printk("acx: USB module " WLAN_RELEASE
" loaded successfully\n");
619 great_inquisitor(priv
);
622 /* Everything went OK, we are happy now */
631 for (i
= 0; i
< ACX100_USB_NUM_BULK_URBS
; i
++)
632 usb_free_urb(priv
->usb_rx
[i
].urb
);
636 for (i
= 0; i
< ACX100_USB_NUM_BULK_URBS
; i
++)
637 usb_free_urb(priv
->usb_tx
[i
].urb
);
648 /* no device we could handle, return error. */
657 /***********************************************************************
658 ** acx100usb_e_disconnect()
660 ** This function is invoked whenever the user pulls the plug from the USB
661 ** device or the module is removed from the kernel. In these cases, the
662 ** network devices have to be taken down and all allocated memory has
666 acx100usb_e_disconnect(struct usb_interface
*intf
)
668 wlandevice_t
*priv
= usb_get_intfdata(intf
);
674 /* No WLAN device... no sense */
678 /* Unregister network device
680 * If the interface is up, unregister_netdev() will take
681 * care of calling our close() function, which takes
682 * care of unlinking the urbs, sending the device to
684 * This can't be called with sem or lock held because
685 * _close() will try to grab it as well if it's called,
686 * deadlocking the machine.
688 unregister_netdev(priv
->netdev
);
691 acx_lock(priv
, flags
);
692 /* This device exists no more */
693 usb_set_intfdata(intf
, NULL
);
694 acx_proc_unregister_entries(priv
->netdev
);
697 * Here we only free them. _close() takes care of
700 for (i
= 0; i
< ACX100_USB_NUM_BULK_URBS
; ++i
) {
701 usb_free_urb(priv
->usb_rx
[i
].urb
);
702 usb_free_urb(priv
->usb_tx
[i
].urb
);
705 /* The the containers. */
709 acx_unlock(priv
, flags
);
710 acx_sem_unlock(priv
);
712 free_netdev(priv
->netdev
);
718 /***********************************************************************
721 ** usbdev -> Pointer to kernel's usb_device structure
722 ** endpoint -> Address of the endpoint for control transfers
723 ************************************************************************
725 ** (int) Errorcode or 0 on success
728 ** This function triggers the loading of the firmware image from harddisk
729 ** and then uploads the firmware to the USB device. After uploading the
730 ** firmware and transmitting the checksum, the device resets and appears
731 ** as a new device on the USB bus (the device we can finally deal with)
734 acx100usb_boot(struct usb_device
*usbdev
)
736 static const char filename
[] = "tiacx100usb";
738 char *firmware
= NULL
;
741 unsigned int len
, inpipe
, outpipe
;
748 usbbuf
= kmalloc(ACX100_USB_RWMEM_MAXLEN
, GFP_KERNEL
);
750 printk(KERN_ERR
"acx: no memory for USB transfer buffer ("
751 STRING(ACX100_USB_RWMEM_MAXLEN
)" bytes)\n");
755 firmware
= (char *)acx_s_read_fw(&usbdev
->dev
, filename
, &size
);
760 acxlog(L_INIT
, "firmware size: %d bytes\n", size
);
762 /* Obtain the I/O pipes */
763 outpipe
= usb_sndctrlpipe(usbdev
, 0);
764 inpipe
= usb_rcvctrlpipe(usbdev
, 0);
766 /* now upload the firmware, slice the data into blocks */
768 while (offset
< size
) {
770 if (len
>= ACX100_USB_RWMEM_MAXLEN
) {
771 len
= ACX100_USB_RWMEM_MAXLEN
;
773 acxlog(L_INIT
, "uploading firmware (%d bytes, offset=%d)\n",
776 memcpy(usbbuf
, firmware
+ offset
, len
);
777 result
= usb_control_msg(usbdev
, outpipe
,
778 ACX_USB_REQ_UPLOAD_FW
,
779 USB_TYPE_VENDOR
|USB_DIR_OUT
,
780 size
- 8, /* value */
782 usbbuf
, /* dataptr */
784 3000 /* timeout in ms */
788 printk(KERN_ERR
"acx: error %d during upload "
789 "of firmware, aborting\n", result
);
794 /* finally, send the checksum and reboot the device */
795 checksum
= le32_to_cpu(*(u32
*)firmware
);
796 /* is this triggers the reboot? */
797 result
= usb_control_msg(usbdev
, outpipe
,
798 ACX_USB_REQ_UPLOAD_FW
,
799 USB_TYPE_VENDOR
|USB_DIR_OUT
,
800 checksum
& 0xffff, /* value */
801 checksum
>> 16, /* index */
804 3000 /* timeout in ms */
807 printk(KERN_ERR
"acx: error %d during tx of checksum, "
808 "aborting\n", result
);
811 result
= usb_control_msg(usbdev
, inpipe
,
813 USB_TYPE_VENDOR
|USB_DIR_IN
,
814 checksum
& 0xffff, /* value */
815 checksum
>> 16, /* index */
816 usbbuf
, /* dataptr */
818 3000 /* timeout in ms */
821 printk(KERN_ERR
"acx: error %d during ACK of checksum, "
822 "aborting\n", result
);
825 if (*usbbuf
!= 0x10) {
827 printk(KERN_ERR
"acx: invalid checksum?\n");
841 /***********************************************************************
842 ** acx100usb_e_init_network_device():
844 ** dev -> Pointer to network device
845 ************************************************************************
847 ** Basic setup of a network device for use with the WLAN device.
850 acx100usb_e_init_network_device(struct net_device
*dev
)
857 /* Setup the device and stop the queue */
859 acx_stop_queue(dev
, "on init");
861 priv
= netdev_priv(dev
);
865 /* put the ACX100 out of sleep mode */
866 acx_s_issue_cmd(priv
, ACX1xx_CMD_WAKE
, NULL
, 0);
868 /* Register the callbacks for the network device functions */
869 dev
->open
= &acx100usb_e_open
;
870 dev
->stop
= &acx100usb_e_close
;
871 dev
->hard_start_xmit
= (void *)&acx_i_start_xmit
;
872 dev
->get_stats
= (void *)&acx_e_get_stats
;
873 dev
->get_wireless_stats
= (void *)&acx_e_get_wireless_stats
;
874 #if WIRELESS_EXT >= 13
875 dev
->wireless_handlers
= (struct iw_handler_def
*)&acx_ioctl_handler_def
;
877 dev
->do_ioctl
= (void *)&acx_e_ioctl_old
;
879 dev
->set_multicast_list
= (void *)&acx100usb_i_set_rx_mode
;
880 #ifdef HAVE_TX_TIMEOUT
881 dev
->tx_timeout
= &acx100usb_i_tx_timeout
;
882 dev
->watchdog_timeo
= 4 * HZ
;
884 dev
->change_mtu
= &acx_e_change_mtu
;
885 result
= acx_s_init_mac(dev
);
888 result
= acx_s_set_defaults(priv
);
890 printk("%s: acx_set_defaults FAILED\n", dev
->name
);
894 SET_MODULE_OWNER(dev
);
896 acx_sem_unlock(priv
);
903 /***********************************************************************
905 ** This function is called when the user sets up the network interface.
906 ** It initializes a management timer, sets up the USB card and starts
907 ** the network tx queue and USB receive.
910 acx100usb_e_open(struct net_device
*dev
)
912 wlandevice_t
*priv
= netdev_priv(dev
);
920 /* put the ACX100 out of sleep mode */
921 acx_s_issue_cmd(priv
, ACX1xx_CMD_WAKE
, NULL
, 0);
923 acx_init_task_scheduler(priv
);
925 init_timer(&priv
->mgmt_timer
);
926 priv
->mgmt_timer
.function
= acx_i_timer
;
927 priv
->mgmt_timer
.data
= (unsigned long)priv
;
929 /* acx_s_start needs it */
930 SET_BIT(priv
->dev_state_mask
, ACX_STATE_IFACE_UP
);
933 acx_start_queue(dev
, "on open");
935 acx_lock(priv
, flags
);
936 for (i
= 0; i
< ACX100_USB_NUM_BULK_URBS
; i
++) {
937 acx100usb_l_poll_rx(priv
, &priv
->usb_rx
[i
]);
939 acx_unlock(priv
, flags
);
941 WLAN_MOD_INC_USE_COUNT
;
943 acx_sem_unlock(priv
);
950 /***********************************************************************
951 ** acx100usb_l_poll_rx
952 ** This function (re)initiates a bulk-in USB transfer on given urb
955 acx100usb_l_poll_rx(wlandevice_t
*priv
, usb_rx_t
* rx
)
957 struct usb_device
*usbdev
;
965 usbdev
= priv
->usbdev
;
967 rxnum
= rx
- priv
->usb_rx
;
969 inpipe
= usb_rcvbulkpipe(usbdev
, priv
->bulkinep
);
970 if (rxurb
->status
== -EINPROGRESS
) {
971 printk(KERN_ERR
"acx: error, rx triggered while rx urb in progress\n");
972 /* FIXME: this is nasty, receive is being cancelled by this code
973 * on the other hand, this should not happen anyway...
975 usb_unlink_urb(rxurb
);
976 } else if (rxurb
->status
== -ECONNRESET
) {
977 acxlog(L_USBRXTX
, "acx_usb: _poll_rx: connection reset\n");
980 rxurb
->actual_length
= 0;
981 usb_fill_bulk_urb(rxurb
, usbdev
, inpipe
,
982 &rx
->bulkin
, /* dataptr */
983 RXBUFSIZE
, /* size */
984 acx100usb_i_complete_rx
, /* handler */
985 rx
/* handler param */
987 rxurb
->transfer_flags
= URB_ASYNC_UNLINK
;
989 /* ATOMIC: we may be called from complete_rx() usb callback */
990 errcode
= usb_submit_urb(rxurb
, GFP_ATOMIC
);
991 /* FIXME: evaluate the error code! */
992 acxlog(L_USBRXTX
, "SUBMIT RX (%d) inpipe=0x%X size=%d errcode=%d\n",
993 rxnum
, inpipe
, (int) RXBUFSIZE
, errcode
);
999 /***********************************************************************
1000 ** acx100usb_i_complete_rx():
1002 ** urb -> Pointer to USB request block
1003 ** regs -> Pointer to register-buffer for syscalls (see asm/ptrace.h)
1004 ************************************************************************
1006 ** This function is invoked by USB subsystem whenever a bulk receive
1008 ** The received data is then committed to the network stack and the next
1009 ** USB receive is triggered.
1012 acx100usb_i_complete_rx(struct urb
*urb
, struct pt_regs
*regs
)
1018 unsigned long flags
;
1019 int size
, remsize
, packetsize
, rxnum
;
1023 BUG_ON(!urb
->context
);
1025 rx
= (usb_rx_t
*)urb
->context
;
1028 acx_lock(priv
, flags
);
1031 * Happens on disconnect or close. Don't play with the urb.
1032 * Don't resubmit it. It will get unlinked by close()
1034 if (!(priv
->dev_state_mask
& ACX_STATE_IFACE_UP
)) {
1035 acxlog(L_USBRXTX
, "not doing anything.\n");
1039 inbuf
= &rx
->bulkin
;
1040 size
= urb
->actual_length
;
1042 rxnum
= rx
- priv
->usb_rx
;
1044 acxlog(L_USBRXTX
, "RETURN RX (%d) status=%d size=%d\n",
1045 rxnum
, urb
->status
, size
);
1047 if(size
> sizeof(rxbuffer_t
))
1048 printk("acx_usb: rx too large: %d bytes, lease report\n", size
);
1050 /* check if the transfer was aborted */
1051 switch (urb
->status
) {
1052 case 0: /* No error */
1055 printk(KERN_ERR
"acx: error in rx, data overrun -> emergency stop\n");
1056 /* LOCKING BUG! acx100usb_e_close(priv->netdev); */
1060 case -ESHUTDOWN
: /* rmmod */
1063 priv
->stats
.rx_errors
++;
1064 printk("acx: rx error (urb status=%d)\n", urb
->status
);
1069 printk("acx: warning, encountered zerolength rx packet\n");
1071 if (urb
->transfer_buffer
!= inbuf
)
1074 /* check if previous frame was truncated
1075 ** FIXME: this code can only handle truncation
1076 ** of consecutive packets!
1079 if (priv
->rxtruncsize
) {
1082 ptr
= &priv
->rxtruncbuf
;
1083 packetsize
= RXBUF_BYTES_USED(ptr
);
1084 if (acx_debug
& L_USBRXTX
) {
1085 printk("handling truncated frame (truncsize=%d size=%d "
1086 "packetsize(from trunc)=%d)\n",
1087 priv
->rxtruncsize
, size
, packetsize
);
1088 acx_dump_bytes(ptr
, RXBUF_HDRSIZE
);
1089 acx_dump_bytes(inbuf
, RXBUF_HDRSIZE
);
1092 /* bytes needed for rxtruncbuf completion: */
1093 tail_size
= packetsize
- priv
->rxtruncsize
;
1095 if (size
< tail_size
) {
1096 /* there is not enough data to complete this packet,
1097 ** simply append the stuff to the truncation buffer
1099 memcpy(((char *)ptr
) + priv
->rxtruncsize
, inbuf
, size
);
1100 priv
->rxtruncsize
+= size
;
1103 /* ok, this data completes the previously
1104 ** truncated packet. copy it into a descriptor
1105 ** and give it to the rest of the stack */
1107 /* append tail to previously truncated part
1108 ** NB: priv->rxtruncbuf (pointed to by ptr) can't
1109 ** overflow because this is already checked before
1110 ** truncation buffer was filled. See below,
1111 ** "if (packetsize > sizeof(rxbuffer_t))..." code */
1112 memcpy(((char *)ptr
) + priv
->rxtruncsize
, inbuf
, tail_size
);
1114 if (acx_debug
& L_USBRXTX
) {
1115 printk("full trailing packet + 12 bytes:\n");
1116 acx_dump_bytes(inbuf
, tail_size
+ RXBUF_HDRSIZE
);
1118 acx_l_process_rxbuf(priv
, ptr
);
1119 priv
->rxtruncsize
= 0;
1120 ptr
= (rxbuffer_t
*) (((char *)inbuf
) + tail_size
);
1121 remsize
-= tail_size
;
1123 acxlog(L_USBRXTX
, "post-merge size=%d remsize=%d\n",
1127 /* size = USB data block size
1128 ** remsize = unprocessed USB bytes left
1129 ** ptr = current pos in USB data block
1132 if (remsize
< RXBUF_HDRSIZE
) {
1133 printk("acx: truncated rx header (%d bytes)!\n",
1137 packetsize
= RXBUF_BYTES_USED(ptr
);
1138 acxlog(L_USBRXTX
, "packet with packetsize=%d\n", packetsize
);
1139 if (packetsize
> sizeof(rxbuffer_t
)) {
1140 printk("acx: packet exceeds max wlan "
1141 "frame size (%d > %d). size=%d\n",
1142 packetsize
, (int) sizeof(rxbuffer_t
), size
);
1143 /* FIXME: put some real error-handling in here! */
1147 /* skip null packets (does this really happen?!) */
1148 if (packetsize
== RXBUF_HDRSIZE
) {
1149 remsize
-= RXBUF_HDRSIZE
;
1150 if (acx_debug
& L_USBRXTX
) {
1151 printk("acx: null packet, new remsize=%d. "
1152 "header follows:\n", remsize
);
1153 acx_dump_bytes(ptr
, RXBUF_HDRSIZE
);
1155 ptr
= (rxbuffer_t
*)(((char *)ptr
) + RXBUF_HDRSIZE
);
1159 if (packetsize
> remsize
) {
1160 /* frame truncation handling */
1161 if (acx_debug
& L_USBRXTX
) {
1162 printk("need to truncate packet, "
1163 "packetsize=%d remsize=%d "
1165 packetsize
, remsize
, size
);
1166 acx_dump_bytes(ptr
, RXBUF_HDRSIZE
);
1168 memcpy(&priv
->rxtruncbuf
, ptr
, remsize
);
1169 priv
->rxtruncsize
= remsize
;
1171 } else { /* packetsize <= remsize */
1172 /* now handle the received data */
1173 acx_l_process_rxbuf(priv
, ptr
);
1175 ptr
= (rxbuffer_t
*)(((char *)ptr
) + packetsize
);
1176 remsize
-= packetsize
;
1177 if ((acx_debug
& L_USBRXTX
) && remsize
) {
1178 printk("more than one packet in buffer, "
1179 "second packet hdr follows\n");
1180 acx_dump_bytes(ptr
, RXBUF_HDRSIZE
);
1186 /* receive of frame completed, now look for the next one */
1187 acx100usb_l_poll_rx(priv
, rx
);
1189 acx_unlock(priv
, flags
);
1195 /***********************************************************************
1196 ** acx100usb_i_complete_tx():
1198 ** urb -> Pointer to USB request block
1199 ** regs -> Pointer to register-buffer for syscalls (see asm/ptrace.h)
1200 ************************************************************************
1202 ** This function is invoked upon termination of a USB transfer. As the
1203 ** USB device is only capable of sending a limited amount of bytes per
1204 ** transfer to the bulk-out endpoint, this routine checks if there are
1205 ** more bytes to send and triggers subsequent transfers. In case the
1206 ** transfer size exactly matches the maximum bulk-out size, it triggers
1207 ** a transfer of a null-frame, telling the card that this is it. Upon
1208 ** completion of a frame, it checks whether the Tx ringbuffer contains
1209 ** more data to send and invokes the Tx routines if this is the case.
1210 ** If there are no more occupied Tx descriptors, the Tx Mutex is unlocked
1211 ** and the network queue is switched back to life again.
1213 ** FIXME: unlike PCI code, we do not analyze tx rate used, retries, etc...
1214 ** Thus we have no automatic rate control in USB!
1217 acx100usb_i_complete_tx(struct urb
*urb
, struct pt_regs
*regs
)
1221 unsigned long flags
;
1226 BUG_ON(!urb
->context
);
1228 tx
= (usb_tx_t
*)urb
->context
;
1231 txnum
= tx
- priv
->usb_tx
;
1233 acx_lock(priv
, flags
);
1236 * If the iface isn't up, we don't have any right
1237 * to play with them. The urb may get unlinked.
1239 if (!(priv
->dev_state_mask
& ACX_STATE_IFACE_UP
)) {
1240 acxlog(L_USBRXTX
, "not doing anything\n");
1242 /*FIXME: Do the priv->tx_free++? */
1245 acxlog(L_USBRXTX
, "RETURN TX (%d): status=%d size=%d\n",
1246 txnum
, urb
->status
, urb
->actual_length
);
1248 /* handle USB transfer errors */
1249 switch (urb
->status
) {
1250 case 0: /* No error */
1258 /* FIXME: real error-handling code here please */
1260 printk(KERN_ERR
"acx: tx error, urb status=%d\n", urb
->status
);
1261 /* FIXME: real error-handling code here please */
1264 /* free the URB and check for more data */
1269 acx_unlock(priv
, flags
);
1275 /***********************************************************************
1276 ** acx100usb_e_close()
1278 ** This function stops the network functionality of the interface (invoked
1279 ** when the user calls ifconfig <wlan> down). The tx queue is halted and
1280 ** the device is marked as down. In case there were any pending USB bulk
1281 ** transfers, these are unlinked (asynchronously). The module in-use count
1282 ** is also decreased in this function.
1285 acx100usb_e_close(struct net_device
*dev
)
1287 wlandevice_t
*priv
= netdev_priv(dev
);
1288 unsigned long flags
;
1293 #ifdef WE_STILL_DONT_CARE_ABOUT_IT
1294 /* Transmit a disassociate frame */
1296 acx_l_transmit_disassoc(priv
, &client
);
1302 /* Make sure we don't get any more rx requests */
1303 acx_s_issue_cmd(priv
, ACX1xx_CMD_DISABLE_RX
, NULL
, 0);
1304 acx_s_issue_cmd(priv
, ACX1xx_CMD_DISABLE_TX
, NULL
, 0);
1307 * We must do FLUSH *without* holding sem to avoid a deadlock.
1308 * See pci.c:acxpci_s_down() for deails.
1310 acx_sem_unlock(priv
);
1311 FLUSH_SCHEDULED_WORK();
1314 /* Power down the device */
1315 acx_s_issue_cmd(priv
, ACX1xx_CMD_SLEEP
, NULL
, 0);
1317 /* Stop the transmit queue, mark the device as DOWN */
1318 acx_lock(priv
, flags
);
1319 acx_stop_queue(dev
, "on iface stop");
1320 CLEAR_BIT(priv
->dev_state_mask
, ACX_STATE_IFACE_UP
);
1321 /* stop pending rx/tx urb transfers */
1322 /* Make sure you don't free them! */
1323 for (i
= 0; i
< ACX100_USB_NUM_BULK_URBS
; i
++) {
1324 acxusb_unlink_urb(priv
->usb_rx
[i
].urb
);
1325 acxusb_unlink_urb(priv
->usb_tx
[i
].urb
);
1328 del_timer_sync(&priv
->mgmt_timer
);
1330 priv
->tx_free
= ACX100_USB_NUM_BULK_URBS
;
1332 for (i
= 0; i
< ACX100_USB_NUM_BULK_URBS
; ++i
) {
1333 priv
->usb_tx
[i
].busy
= 0;
1334 priv
->usb_rx
[i
].busy
= 0;
1337 acx_unlock(priv
, flags
);
1339 acx_sem_unlock(priv
);
1341 /* Decrease module-in-use count (if necessary) */
1343 WLAN_MOD_DEC_USE_COUNT
;
1350 /***************************************************************
1351 ** acxusb_l_alloc_tx
1352 ** Actually returns a usb_tx_t* ptr
1355 acxusb_l_alloc_tx(wlandevice_t
* priv
)
1358 usb_tx_t
*tx
= NULL
;
1362 for (i
= 0; i
< ACX100_USB_NUM_BULK_URBS
; i
++) {
1363 if (!priv
->usb_tx
[i
].busy
) {
1364 acxlog(L_USBRXTX
, "allocated tx %d\n", i
);
1365 tx
= &priv
->usb_tx
[i
];
1370 if (i
>= ACX100_USB_NUM_BULK_URBS
) {
1371 printk_ratelimited("acx: tx buffers full\n");
1380 /***************************************************************
1383 acxusb_l_get_txbuf(wlandevice_t
*priv
, tx_t
* tx_opaque
)
1385 usb_tx_t
* tx
= (usb_tx_t
*)tx_opaque
;
1386 return &tx
->bulkout
.data
;
1390 /***************************************************************
1393 ** Can be called from IRQ (rx -> (AP bridging or mgmt response) -> tx).
1394 ** Can be called from acx_i_start_xmit (data frames from net core).
1397 acxusb_l_tx_data(wlandevice_t
*priv
, tx_t
* tx_opaque
, int wlanpkt_len
)
1399 struct usb_device
*usbdev
;
1402 usb_txbuffer_t
* txbuf
;
1405 unsigned int outpipe
;
1411 tx
= ((usb_tx_t
*)tx_opaque
);
1413 txbuf
= &tx
->bulkout
;
1414 whdr
= (wlan_hdr_t
*)txbuf
->data
;
1417 acxlog(L_DEBUG
, "using buf#%d free=%d len=%d\n",
1418 (int)(tx
- priv
->usb_tx
),
1419 priv
->tx_free
, wlanpkt_len
);
1421 switch (priv
->mode
) {
1422 case ACX_MODE_0_ADHOC
:
1424 clt
= acx_l_sta_list_get(priv
, whdr
->a1
);
1426 case ACX_MODE_2_STA
:
1427 clt
= priv
->ap_client
;
1429 default: /* ACX_MODE_OFF, ACX_MODE_MONITOR */
1434 if (unlikely(clt
&& !clt
->rate_cur
)) {
1435 printk("acx: driver bug! bad ratemask\n");
1439 /* used in tx cleanup routine for auto rate and accounting: */
1440 //TODO: currently unused - fix that
1443 rate100
= clt
? clt
->rate_100
: priv
->rate_bcast100
;
1445 /* fill the USB transfer header */
1446 txbuf
->desc
= cpu_to_le16(USB_TXBUF_TXDESC
);
1447 txbuf
->MPDUlen
= cpu_to_le16(wlanpkt_len
);
1450 txbuf
->hostData
= cpu_to_le32(wlanpkt_len
| (rate100
<< 24));
1451 if (1 == priv
->preamble_cur
)
1452 SET_BIT(txbuf
->ctrl1
, DESC_CTL_SHORT_PREAMBLE
);
1453 SET_BIT(txbuf
->ctrl1
, DESC_CTL_FIRSTFRAG
);
1454 txbuf
->txRate
= rate100
;
1456 txbuf
->dataLength
= cpu_to_le16(wlanpkt_len
);
1458 if ( (WF_FC_FTYPEi
& whdr
->fc
) == WF_FTYPE_DATAi
)
1459 SET_BIT(txbuf
->hostData
, cpu_to_le32(USB_TXBUF_HD_ISDATA
));
1460 if (mac_is_directed(whdr
->a1
))
1461 SET_BIT(txbuf
->hostData
, cpu_to_le32(USB_TXBUF_HD_DIRECTED
));
1462 else if (mac_is_bcast(whdr
->a1
))
1463 SET_BIT(txbuf
->hostData
, cpu_to_le32(USB_TXBUF_HD_BROADCAST
));
1465 if (acx_debug
& L_DATA
) {
1466 printk("dump of bulk out urb:\n");
1467 acx_dump_bytes(txbuf
, wlanpkt_len
+ USB_TXBUF_HDRSIZE
);
1470 if (txurb
->status
== -EINPROGRESS
) {
1471 printk("acx: trying to submit tx urb while already in progress\n");
1474 /* now schedule the USB transfer */
1475 usbdev
= priv
->usbdev
;
1476 outpipe
= usb_sndbulkpipe(usbdev
, priv
->bulkoutep
);
1478 usb_fill_bulk_urb(txurb
, usbdev
, outpipe
,
1479 txbuf
, /* dataptr */
1480 wlanpkt_len
+ USB_TXBUF_HDRSIZE
, /* size */
1481 acx100usb_i_complete_tx
, /* handler */
1482 tx
/* handler param */
1485 txurb
->transfer_flags
= URB_ASYNC_UNLINK
|URB_ZERO_PACKET
;
1486 ucode
= usb_submit_urb(txurb
, GFP_ATOMIC
);
1487 acxlog(L_USBRXTX
, "SUBMIT TX (%p): outpipe=0x%X buf=%p txsize=%d "
1488 "errcode=%d\n", tx
, outpipe
, txbuf
,
1489 wlanpkt_len
+ USB_TXBUF_HDRSIZE
, ucode
);
1492 printk(KERN_ERR
"acx: submit_urb() error=%d txsize=%d\n",
1493 ucode
, wlanpkt_len
+ USB_TXBUF_HDRSIZE
);
1495 /* on error, just mark the frame as done and update
1498 priv
->stats
.tx_errors
++;
1507 /***********************************************************************
1510 acx100usb_i_set_rx_mode(struct net_device
*dev
)
1515 /***********************************************************************
1517 #ifdef HAVE_TX_TIMEOUT
1519 acx100usb_i_tx_timeout(struct net_device
*dev
)
1521 wlandevice_t
*priv
= netdev_priv(dev
);
1522 unsigned long flags
;
1527 acx_lock(priv
, flags
);
1528 /* unlink the URBs */
1529 for (i
= 0; i
< ACX100_USB_NUM_BULK_URBS
; i
++) {
1530 acxusb_unlink_urb(priv
->usb_tx
[i
].urb
);
1532 /* TODO: stats update */
1533 acx_unlock(priv
, flags
);
1540 /***********************************************************************
1543 ** This function is invoked upon loading of the kernel module.
1544 ** It registers itself at the kernel's USB subsystem.
1546 ** Returns: Errorcode on failure, 0 on success
1549 acxusb_e_init_module(void)
1551 acxlog(L_INIT
, "USB module " WLAN_RELEASE
" initialized, "
1552 "probing for devices...\n");
1553 return usb_register(&acx100usb_driver
);
1558 /***********************************************************************
1559 ** cleanup_module():
1561 ** This function is invoked as last step of the module unloading. It simply
1562 ** deregisters this module at the kernel's USB subsystem.
1565 acxusb_e_cleanup_module()
1567 usb_deregister(&acx100usb_driver
);
1571 /***********************************************************************
1578 dump_device(struct usb_device
*usbdev
)
1581 struct usb_config_descriptor
*cd
;
1583 printk("acx device dump:\n");
1584 printk(" devnum: %d\n", usbdev
->devnum
);
1585 printk(" speed: %d\n", usbdev
->speed
);
1586 printk(" tt: 0x%X\n", (unsigned int)(usbdev
->tt
));
1587 printk(" ttport: %d\n", (unsigned int)(usbdev
->ttport
));
1588 printk(" toggle[0]: 0x%X toggle[1]: 0x%X\n", (unsigned int)(usbdev
->toggle
[0]), (unsigned int)(usbdev
->toggle
[1]));
1589 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8)
1590 /* halted removed in 2.6.9-rc1 */
1591 /* DOH, Canbreak... err... Mandrake decided to do their very own very
1592 * special version "2.6.8.1" which already includes this change, so we
1593 * need to blacklist that version already (i.e. 2.6.8) */
1594 printk(" halted[0]: 0x%X halted[1]: 0x%X\n", usbdev
->halted
[0], usbdev
->halted
[1]);
1596 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
1597 /* This saw a change after 2.6.10 */
1598 printk(" ep_in wMaxPacketSize: ");
1599 for (i
= 0; i
< 16; ++i
)
1600 printk("%d ", usbdev
->ep_in
[i
]->desc
.wMaxPacketSize
);
1602 printk(" ep_out wMaxPacketSize: ");
1603 for (i
= 0; i
< 15; ++i
)
1604 printk("%d ", usbdev
->ep_out
[i
]->desc
.wMaxPacketSize
);
1607 printk(" epmaxpacketin: ");
1608 for (i
= 0; i
< 16; i
++)
1609 printk("%d ", usbdev
->epmaxpacketin
[i
]);
1611 printk(" epmaxpacketout: ");
1612 for (i
= 0; i
< 16; i
++)
1613 printk("%d ", usbdev
->epmaxpacketout
[i
]);
1616 printk(" parent: 0x%X\n", (unsigned int)usbdev
->parent
);
1617 printk(" bus: 0x%X\n", (unsigned int)usbdev
->bus
);
1619 printk(" configs: ");
1620 for (i
= 0; i
< usbdev
->descriptor
.bNumConfigurations
; i
++)
1621 printk("0x%X ", usbdev
->config
[i
]);
1624 printk(" actconfig: %p\n", usbdev
->actconfig
);
1625 dump_device_descriptor(&usbdev
->descriptor
);
1627 cd
= &usbdev
->config
->desc
;
1628 dump_config_descriptor(cd
);
1632 /***********************************************************************
1635 dump_config_descriptor(struct usb_config_descriptor
*cd
)
1637 printk("Configuration Descriptor:\n");
1642 printk(" bLength: %d (0x%X)\n", cd
->bLength
, cd
->bLength
);
1643 printk(" bDescriptorType: %d (0x%X)\n", cd
->bDescriptorType
, cd
->bDescriptorType
);
1644 printk(" bNumInterfaces: %d (0x%X)\n", cd
->bNumInterfaces
, cd
->bNumInterfaces
);
1645 printk(" bConfigurationValue: %d (0x%X)\n", cd
->bConfigurationValue
, cd
->bConfigurationValue
);
1646 printk(" iConfiguration: %d (0x%X)\n", cd
->iConfiguration
, cd
->iConfiguration
);
1647 printk(" bmAttributes: %d (0x%X)\n", cd
->bmAttributes
, cd
->bmAttributes
);
1648 /* printk(" MaxPower: %d (0x%X)\n", cd->bMaxPower, cd->bMaxPower); */
1653 dump_device_descriptor(struct usb_device_descriptor
*dd
)
1655 printk("Device Descriptor:\n");
1660 printk(" bLength: %d (0x%X)\n", dd
->bLength
, dd
->bLength
);
1661 printk(" bDescriptortype: %d (0x%X)\n", dd
->bDescriptorType
, dd
->bDescriptorType
);
1662 printk(" bcdUSB: %d (0x%X)\n", dd
->bcdUSB
, dd
->bcdUSB
);
1663 printk(" bDeviceClass: %d (0x%X)\n", dd
->bDeviceClass
, dd
->bDeviceClass
);
1664 printk(" bDeviceSubClass: %d (0x%X)\n", dd
->bDeviceSubClass
, dd
->bDeviceSubClass
);
1665 printk(" bDeviceProtocol: %d (0x%X)\n", dd
->bDeviceProtocol
, dd
->bDeviceProtocol
);
1666 printk(" bMaxPacketSize0: %d (0x%X)\n", dd
->bMaxPacketSize0
, dd
->bMaxPacketSize0
);
1667 printk(" idVendor: %d (0x%X)\n", dd
->idVendor
, dd
->idVendor
);
1668 printk(" idProduct: %d (0x%X)\n", dd
->idProduct
, dd
->idProduct
);
1669 printk(" bcdDevice: %d (0x%X)\n", dd
->bcdDevice
, dd
->bcdDevice
);
1670 printk(" iManufacturer: %d (0x%X)\n", dd
->iManufacturer
, dd
->iManufacturer
);
1671 printk(" iProduct: %d (0x%X)\n", dd
->iProduct
, dd
->iProduct
);
1672 printk(" iSerialNumber: %d (0x%X)\n", dd
->iSerialNumber
, dd
->iSerialNumber
);
1673 printk(" bNumConfigurations: %d (0x%X)\n", dd
->bNumConfigurations
, dd
->bNumConfigurations
);
1677 #endif /* ACX_DEBUG */