1 /* src/prism2/driver/hfa384x_usb.c
3 * Functions that talk to the USB variantof the Intersil hfa384x MAC
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
6 * --------------------------------------------------------------------
10 * The contents of this file are subject to the Mozilla Public
11 * License Version 1.1 (the "License"); you may not use this file
12 * except in compliance with the License. You may obtain a copy of
13 * the License at http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS
16 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 * implied. See the License for the specific language governing
18 * rights and limitations under the License.
20 * Alternatively, the contents of this file may be used under the
21 * terms of the GNU Public License version 2 (the "GPL"), in which
22 * case the provisions of the GPL are applicable instead of the
23 * above. If you wish to allow the use of your version of this file
24 * only under the terms of the GPL and not to allow others to use
25 * your version of this file under the MPL, indicate your decision
26 * by deleting the provisions above and replace them with the notice
27 * and other provisions required by the GPL. If you do not delete
28 * the provisions above, a recipient may use your version of this
29 * file under either the MPL or the GPL.
31 * --------------------------------------------------------------------
33 * Inquiries regarding the linux-wlan Open Source project can be
36 * AbsoluteValue Systems Inc.
38 * http://www.linux-wlan.com
40 * --------------------------------------------------------------------
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
45 * --------------------------------------------------------------------
47 * This file implements functions that correspond to the prism2/hfa384x
48 * 802.11 MAC hardware and firmware host interface.
50 * The functions can be considered to represent several levels of
51 * abstraction. The lowest level functions are simply C-callable wrappers
52 * around the register accesses. The next higher level represents C-callable
53 * prism2 API functions that match the Intersil documentation as closely
54 * as is reasonable. The next higher layer implements common sequences
55 * of invokations of the API layer (e.g. write to bap, followed by cmd).
58 * hfa384x_drvr_xxx Highest level abstractions provided by the
59 * hfa384x code. They are driver defined wrappers
60 * for common sequences. These functions generally
61 * use the services of the lower levels.
63 * hfa384x_drvr_xxxconfig An example of the drvr level abstraction. These
64 * functions are wrappers for the RID get/set
65 * sequence. They call copy_[to|from]_bap() and
66 * cmd_access(). These functions operate on the
67 * RIDs and buffers without validation. The caller
68 * is responsible for that.
70 * API wrapper functions:
71 * hfa384x_cmd_xxx functions that provide access to the f/w commands.
72 * The function arguments correspond to each command
73 * argument, even command arguments that get packed
74 * into single registers. These functions _just_
75 * issue the command by setting the cmd/parm regs
76 * & reading the status/resp regs. Additional
77 * activities required to fully use a command
78 * (read/write from/to bap, get/set int status etc.)
79 * are implemented separately. Think of these as
80 * C-callable prism2 commands.
82 * Lowest Layer Functions:
83 * hfa384x_docmd_xxx These functions implement the sequence required
84 * to issue any prism2 command. Primarily used by the
85 * hfa384x_cmd_xxx functions.
87 * hfa384x_bap_xxx BAP read/write access functions.
88 * Note: we usually use BAP0 for non-interrupt context
89 * and BAP1 for interrupt context.
91 * hfa384x_dl_xxx download related functions.
93 * Driver State Issues:
94 * Note that there are two pairs of functions that manage the
95 * 'initialized' and 'running' states of the hw/MAC combo. The four
96 * functions are create(), destroy(), start(), and stop(). create()
97 * sets up the data structures required to support the hfa384x_*
98 * functions and destroy() cleans them up. The start() function gets
99 * the actual hardware running and enables the interrupts. The stop()
100 * function shuts the hardware down. The sequence should be:
104 * . Do interesting things w/ the hardware
109 * Note that destroy() can be called without calling stop() first.
110 * --------------------------------------------------------------------
113 #include <linux/module.h>
114 #include <linux/kernel.h>
115 #include <linux/sched.h>
116 #include <linux/types.h>
117 #include <linux/slab.h>
118 #include <linux/wireless.h>
119 #include <linux/netdevice.h>
120 #include <linux/timer.h>
122 #include <linux/delay.h>
123 #include <asm/byteorder.h>
124 #include <asm/bitops.h>
125 #include <linux/list.h>
126 #include <linux/usb.h>
127 #include <linux/byteorder/generic.h>
129 #define SUBMIT_URB(u,f) usb_submit_urb(u,f)
131 #include "p80211types.h"
132 #include "p80211hdr.h"
133 #include "p80211mgmt.h"
134 #include "p80211conv.h"
135 #include "p80211msg.h"
136 #include "p80211netdev.h"
137 #include "p80211req.h"
138 #include "p80211metadef.h"
139 #include "p80211metastruct.h"
141 #include "prism2mgmt.h"
147 typedef enum cmd_mode CMD_MODE
;
149 #define THROTTLE_JIFFIES (HZ/8)
150 #define URB_ASYNC_UNLINK 0
151 #define USB_QUEUE_BULK 0
153 #define ROUNDUP64(a) (((a)+63)&~63)
156 static void dbprint_urb(struct urb
*urb
);
160 hfa384x_int_rxmonitor(wlandevice_t
*wlandev
, hfa384x_usb_rxfrm_t
*rxfrm
);
162 static void hfa384x_usb_defer(struct work_struct
*data
);
164 static int submit_rx_urb(hfa384x_t
*hw
, gfp_t flags
);
166 static int submit_tx_urb(hfa384x_t
*hw
, struct urb
*tx_urb
, gfp_t flags
);
168 /*---------------------------------------------------*/
170 static void hfa384x_usbout_callback(struct urb
*urb
);
171 static void hfa384x_ctlxout_callback(struct urb
*urb
);
172 static void hfa384x_usbin_callback(struct urb
*urb
);
175 hfa384x_usbin_txcompl(wlandevice_t
*wlandev
, hfa384x_usbin_t
* usbin
);
177 static void hfa384x_usbin_rx(wlandevice_t
*wlandev
, struct sk_buff
*skb
);
179 static void hfa384x_usbin_info(wlandevice_t
*wlandev
, hfa384x_usbin_t
* usbin
);
182 hfa384x_usbout_tx(wlandevice_t
*wlandev
, hfa384x_usbout_t
*usbout
);
184 static void hfa384x_usbin_ctlx(hfa384x_t
*hw
, hfa384x_usbin_t
*usbin
,
187 /*---------------------------------------------------*/
188 /* Functions to support the prism2 usb command queue */
190 static void hfa384x_usbctlxq_run(hfa384x_t
*hw
);
192 static void hfa384x_usbctlx_reqtimerfn(unsigned long data
);
194 static void hfa384x_usbctlx_resptimerfn(unsigned long data
);
196 static void hfa384x_usb_throttlefn(unsigned long data
);
198 static void hfa384x_usbctlx_completion_task(unsigned long data
);
200 static void hfa384x_usbctlx_reaper_task(unsigned long data
);
202 static int hfa384x_usbctlx_submit(hfa384x_t
*hw
, hfa384x_usbctlx_t
*ctlx
);
204 static void unlocked_usbctlx_complete(hfa384x_t
*hw
, hfa384x_usbctlx_t
*ctlx
);
206 struct usbctlx_completor
{
207 int (*complete
) (struct usbctlx_completor
*);
209 typedef struct usbctlx_completor usbctlx_completor_t
;
212 hfa384x_usbctlx_complete_sync(hfa384x_t
*hw
,
213 hfa384x_usbctlx_t
*ctlx
,
214 usbctlx_completor_t
*completor
);
217 unlocked_usbctlx_cancel_async(hfa384x_t
*hw
, hfa384x_usbctlx_t
*ctlx
);
219 static void hfa384x_cb_status(hfa384x_t
*hw
, const hfa384x_usbctlx_t
*ctlx
);
221 static void hfa384x_cb_rrid(hfa384x_t
*hw
, const hfa384x_usbctlx_t
*ctlx
);
224 usbctlx_get_status(const hfa384x_usb_cmdresp_t
*cmdresp
,
225 hfa384x_cmdresult_t
*result
);
228 usbctlx_get_rridresult(const hfa384x_usb_rridresp_t
*rridresp
,
229 hfa384x_rridresult_t
*result
);
231 /*---------------------------------------------------*/
232 /* Low level req/resp CTLX formatters and submitters */
234 hfa384x_docmd(hfa384x_t
*hw
,
236 hfa384x_metacmd_t
*cmd
,
237 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
240 hfa384x_dorrid(hfa384x_t
*hw
,
244 unsigned int riddatalen
,
245 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
248 hfa384x_dowrid(hfa384x_t
*hw
,
252 unsigned int riddatalen
,
253 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
256 hfa384x_dormem(hfa384x_t
*hw
,
262 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
265 hfa384x_dowmem(hfa384x_t
*hw
,
271 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
273 static int hfa384x_isgood_pdrcode(u16 pdrcode
);
275 static inline const char *ctlxstr(CTLX_STATE s
)
277 static const char *ctlx_str
[] = {
282 "Request packet submitted",
283 "Request packet completed",
284 "Response packet completed"
290 static inline hfa384x_usbctlx_t
*get_active_ctlx(hfa384x_t
* hw
)
292 return list_entry(hw
->ctlxq
.active
.next
, hfa384x_usbctlx_t
, list
);
296 void dbprint_urb(struct urb
*urb
)
298 pr_debug("urb->pipe=0x%08x\n", urb
->pipe
);
299 pr_debug("urb->status=0x%08x\n", urb
->status
);
300 pr_debug("urb->transfer_flags=0x%08x\n", urb
->transfer_flags
);
301 pr_debug("urb->transfer_buffer=0x%08x\n",
302 (unsigned int)urb
->transfer_buffer
);
303 pr_debug("urb->transfer_buffer_length=0x%08x\n",
304 urb
->transfer_buffer_length
);
305 pr_debug("urb->actual_length=0x%08x\n", urb
->actual_length
);
306 pr_debug("urb->bandwidth=0x%08x\n", urb
->bandwidth
);
307 pr_debug("urb->setup_packet(ctl)=0x%08x\n",
308 (unsigned int)urb
->setup_packet
);
309 pr_debug("urb->start_frame(iso/irq)=0x%08x\n", urb
->start_frame
);
310 pr_debug("urb->interval(irq)=0x%08x\n", urb
->interval
);
311 pr_debug("urb->error_count(iso)=0x%08x\n", urb
->error_count
);
312 pr_debug("urb->timeout=0x%08x\n", urb
->timeout
);
313 pr_debug("urb->context=0x%08x\n", (unsigned int)urb
->context
);
314 pr_debug("urb->complete=0x%08x\n", (unsigned int)urb
->complete
);
318 /*----------------------------------------------------------------
321 * Listen for input data on the BULK-IN pipe. If the pipe has
322 * stalled then schedule it to be reset.
326 * memflags memory allocation flags
329 * error code from submission
333 ----------------------------------------------------------------*/
334 static int submit_rx_urb(hfa384x_t
*hw
, gfp_t memflags
)
339 skb
= dev_alloc_skb(sizeof(hfa384x_usbin_t
));
345 /* Post the IN urb */
346 usb_fill_bulk_urb(&hw
->rx_urb
, hw
->usb
,
348 skb
->data
, sizeof(hfa384x_usbin_t
),
349 hfa384x_usbin_callback
, hw
->wlandev
);
351 hw
->rx_urb_skb
= skb
;
354 if (!hw
->wlandev
->hwremoved
&& !test_bit(WORK_RX_HALT
, &hw
->usb_flags
)) {
355 result
= SUBMIT_URB(&hw
->rx_urb
, memflags
);
357 /* Check whether we need to reset the RX pipe */
358 if (result
== -EPIPE
) {
360 "%s rx pipe stalled: requesting reset\n",
361 hw
->wlandev
->netdev
->name
);
362 if (!test_and_set_bit(WORK_RX_HALT
, &hw
->usb_flags
))
363 schedule_work(&hw
->usb_work
);
367 /* Don't leak memory if anything should go wrong */
370 hw
->rx_urb_skb
= NULL
;
377 /*----------------------------------------------------------------
380 * Prepares and submits the URB of transmitted data. If the
381 * submission fails then it will schedule the output pipe to
386 * tx_urb URB of data for tranmission
387 * memflags memory allocation flags
390 * error code from submission
394 ----------------------------------------------------------------*/
395 static int submit_tx_urb(hfa384x_t
*hw
, struct urb
*tx_urb
, gfp_t memflags
)
397 struct net_device
*netdev
= hw
->wlandev
->netdev
;
401 if (netif_running(netdev
)) {
403 if (!hw
->wlandev
->hwremoved
404 && !test_bit(WORK_TX_HALT
, &hw
->usb_flags
)) {
405 result
= SUBMIT_URB(tx_urb
, memflags
);
407 /* Test whether we need to reset the TX pipe */
408 if (result
== -EPIPE
) {
410 "%s tx pipe stalled: requesting reset\n",
412 set_bit(WORK_TX_HALT
, &hw
->usb_flags
);
413 schedule_work(&hw
->usb_work
);
414 } else if (result
== 0) {
415 netif_stop_queue(netdev
);
423 /*----------------------------------------------------------------
426 * There are some things that the USB stack cannot do while
427 * in interrupt context, so we arrange this function to run
428 * in process context.
431 * hw device structure
437 * process (by design)
438 ----------------------------------------------------------------*/
439 static void hfa384x_usb_defer(struct work_struct
*data
)
441 hfa384x_t
*hw
= container_of(data
, struct hfa384x
, usb_work
);
442 struct net_device
*netdev
= hw
->wlandev
->netdev
;
444 /* Don't bother trying to reset anything if the plug
445 * has been pulled ...
447 if (hw
->wlandev
->hwremoved
)
450 /* Reception has stopped: try to reset the input pipe */
451 if (test_bit(WORK_RX_HALT
, &hw
->usb_flags
)) {
454 usb_kill_urb(&hw
->rx_urb
); /* Cannot be holding spinlock! */
456 ret
= usb_clear_halt(hw
->usb
, hw
->endp_in
);
459 "Failed to clear rx pipe for %s: err=%d\n",
462 printk(KERN_INFO
"%s rx pipe reset complete.\n",
464 clear_bit(WORK_RX_HALT
, &hw
->usb_flags
);
465 set_bit(WORK_RX_RESUME
, &hw
->usb_flags
);
469 /* Resume receiving data back from the device. */
470 if (test_bit(WORK_RX_RESUME
, &hw
->usb_flags
)) {
473 ret
= submit_rx_urb(hw
, GFP_KERNEL
);
476 "Failed to resume %s rx pipe.\n", netdev
->name
);
478 clear_bit(WORK_RX_RESUME
, &hw
->usb_flags
);
482 /* Transmission has stopped: try to reset the output pipe */
483 if (test_bit(WORK_TX_HALT
, &hw
->usb_flags
)) {
486 usb_kill_urb(&hw
->tx_urb
);
487 ret
= usb_clear_halt(hw
->usb
, hw
->endp_out
);
490 "Failed to clear tx pipe for %s: err=%d\n",
493 printk(KERN_INFO
"%s tx pipe reset complete.\n",
495 clear_bit(WORK_TX_HALT
, &hw
->usb_flags
);
496 set_bit(WORK_TX_RESUME
, &hw
->usb_flags
);
498 /* Stopping the BULK-OUT pipe also blocked
499 * us from sending any more CTLX URBs, so
500 * we need to re-run our queue ...
502 hfa384x_usbctlxq_run(hw
);
506 /* Resume transmitting. */
507 if (test_and_clear_bit(WORK_TX_RESUME
, &hw
->usb_flags
))
508 netif_wake_queue(hw
->wlandev
->netdev
);
511 /*----------------------------------------------------------------
514 * Sets up the hfa384x_t data structure for use. Note this
515 * does _not_ intialize the actual hardware, just the data structures
516 * we use to keep track of its state.
519 * hw device structure
520 * irq device irq number
521 * iobase i/o base address for register access
522 * membase memory base address for register access
531 ----------------------------------------------------------------*/
532 void hfa384x_create(hfa384x_t
*hw
, struct usb_device
*usb
)
534 memset(hw
, 0, sizeof(hfa384x_t
));
537 /* set up the endpoints */
538 hw
->endp_in
= usb_rcvbulkpipe(usb
, 1);
539 hw
->endp_out
= usb_sndbulkpipe(usb
, 2);
541 /* Set up the waitq */
542 init_waitqueue_head(&hw
->cmdq
);
544 /* Initialize the command queue */
545 spin_lock_init(&hw
->ctlxq
.lock
);
546 INIT_LIST_HEAD(&hw
->ctlxq
.pending
);
547 INIT_LIST_HEAD(&hw
->ctlxq
.active
);
548 INIT_LIST_HEAD(&hw
->ctlxq
.completing
);
549 INIT_LIST_HEAD(&hw
->ctlxq
.reapable
);
551 /* Initialize the authentication queue */
552 skb_queue_head_init(&hw
->authq
);
554 tasklet_init(&hw
->reaper_bh
,
555 hfa384x_usbctlx_reaper_task
, (unsigned long)hw
);
556 tasklet_init(&hw
->completion_bh
,
557 hfa384x_usbctlx_completion_task
, (unsigned long)hw
);
558 INIT_WORK(&hw
->link_bh
, prism2sta_processing_defer
);
559 INIT_WORK(&hw
->usb_work
, hfa384x_usb_defer
);
561 init_timer(&hw
->throttle
);
562 hw
->throttle
.function
= hfa384x_usb_throttlefn
;
563 hw
->throttle
.data
= (unsigned long)hw
;
565 init_timer(&hw
->resptimer
);
566 hw
->resptimer
.function
= hfa384x_usbctlx_resptimerfn
;
567 hw
->resptimer
.data
= (unsigned long)hw
;
569 init_timer(&hw
->reqtimer
);
570 hw
->reqtimer
.function
= hfa384x_usbctlx_reqtimerfn
;
571 hw
->reqtimer
.data
= (unsigned long)hw
;
573 usb_init_urb(&hw
->rx_urb
);
574 usb_init_urb(&hw
->tx_urb
);
575 usb_init_urb(&hw
->ctlx_urb
);
577 hw
->link_status
= HFA384x_LINK_NOTCONNECTED
;
578 hw
->state
= HFA384x_STATE_INIT
;
580 INIT_WORK(&hw
->commsqual_bh
, prism2sta_commsqual_defer
);
581 init_timer(&hw
->commsqual_timer
);
582 hw
->commsqual_timer
.data
= (unsigned long)hw
;
583 hw
->commsqual_timer
.function
= prism2sta_commsqual_timer
;
586 /*----------------------------------------------------------------
589 * Partner to hfa384x_create(). This function cleans up the hw
590 * structure so that it can be freed by the caller using a simple
591 * kfree. Currently, this function is just a placeholder. If, at some
592 * point in the future, an hw in the 'shutdown' state requires a 'deep'
593 * kfree, this is where it should be done. Note that if this function
594 * is called on a _running_ hw structure, the drvr_stop() function is
598 * hw device structure
601 * nothing, this function is not allowed to fail.
607 ----------------------------------------------------------------*/
608 void hfa384x_destroy(hfa384x_t
*hw
)
612 if (hw
->state
== HFA384x_STATE_RUNNING
)
613 hfa384x_drvr_stop(hw
);
614 hw
->state
= HFA384x_STATE_PREINIT
;
616 if (hw
->scanresults
) {
617 kfree(hw
->scanresults
);
618 hw
->scanresults
= NULL
;
621 /* Now to clean out the auth queue */
622 while ((skb
= skb_dequeue(&hw
->authq
)))
626 static hfa384x_usbctlx_t
*usbctlx_alloc(void)
628 hfa384x_usbctlx_t
*ctlx
;
630 ctlx
= kmalloc(sizeof(*ctlx
), in_interrupt()? GFP_ATOMIC
: GFP_KERNEL
);
632 memset(ctlx
, 0, sizeof(*ctlx
));
633 init_completion(&ctlx
->done
);
640 usbctlx_get_status(const hfa384x_usb_cmdresp_t
*cmdresp
,
641 hfa384x_cmdresult_t
*result
)
643 result
->status
= le16_to_cpu(cmdresp
->status
);
644 result
->resp0
= le16_to_cpu(cmdresp
->resp0
);
645 result
->resp1
= le16_to_cpu(cmdresp
->resp1
);
646 result
->resp2
= le16_to_cpu(cmdresp
->resp2
);
648 pr_debug("cmdresult:status=0x%04x "
649 "resp0=0x%04x resp1=0x%04x resp2=0x%04x\n",
650 result
->status
, result
->resp0
, result
->resp1
, result
->resp2
);
652 return result
->status
& HFA384x_STATUS_RESULT
;
656 usbctlx_get_rridresult(const hfa384x_usb_rridresp_t
*rridresp
,
657 hfa384x_rridresult_t
*result
)
659 result
->rid
= le16_to_cpu(rridresp
->rid
);
660 result
->riddata
= rridresp
->data
;
661 result
->riddata_len
= ((le16_to_cpu(rridresp
->frmlen
) - 1) * 2);
665 /*----------------------------------------------------------------
667 * This completor must be passed to hfa384x_usbctlx_complete_sync()
668 * when processing a CTLX that returns a hfa384x_cmdresult_t structure.
669 ----------------------------------------------------------------*/
670 struct usbctlx_cmd_completor
{
671 usbctlx_completor_t head
;
673 const hfa384x_usb_cmdresp_t
*cmdresp
;
674 hfa384x_cmdresult_t
*result
;
676 typedef struct usbctlx_cmd_completor usbctlx_cmd_completor_t
;
678 static int usbctlx_cmd_completor_fn(usbctlx_completor_t
* head
)
680 usbctlx_cmd_completor_t
*complete
= (usbctlx_cmd_completor_t
*) head
;
681 return usbctlx_get_status(complete
->cmdresp
, complete
->result
);
684 static inline usbctlx_completor_t
*init_cmd_completor(usbctlx_cmd_completor_t
*
687 hfa384x_usb_cmdresp_t
*
689 hfa384x_cmdresult_t
*
692 completor
->head
.complete
= usbctlx_cmd_completor_fn
;
693 completor
->cmdresp
= cmdresp
;
694 completor
->result
= result
;
695 return &(completor
->head
);
698 /*----------------------------------------------------------------
700 * This completor must be passed to hfa384x_usbctlx_complete_sync()
701 * when processing a CTLX that reads a RID.
702 ----------------------------------------------------------------*/
703 struct usbctlx_rrid_completor
{
704 usbctlx_completor_t head
;
706 const hfa384x_usb_rridresp_t
*rridresp
;
708 unsigned int riddatalen
;
710 typedef struct usbctlx_rrid_completor usbctlx_rrid_completor_t
;
712 static int usbctlx_rrid_completor_fn(usbctlx_completor_t
*head
)
714 usbctlx_rrid_completor_t
*complete
= (usbctlx_rrid_completor_t
*) head
;
715 hfa384x_rridresult_t rridresult
;
717 usbctlx_get_rridresult(complete
->rridresp
, &rridresult
);
719 /* Validate the length, note body len calculation in bytes */
720 if (rridresult
.riddata_len
!= complete
->riddatalen
) {
722 "RID len mismatch, rid=0x%04x hlen=%d fwlen=%d\n",
724 complete
->riddatalen
, rridresult
.riddata_len
);
728 memcpy(complete
->riddata
, rridresult
.riddata
, complete
->riddatalen
);
732 static inline usbctlx_completor_t
*init_rrid_completor(usbctlx_rrid_completor_t
735 hfa384x_usb_rridresp_t
*
736 rridresp
, void *riddata
,
737 unsigned int riddatalen
)
739 completor
->head
.complete
= usbctlx_rrid_completor_fn
;
740 completor
->rridresp
= rridresp
;
741 completor
->riddata
= riddata
;
742 completor
->riddatalen
= riddatalen
;
743 return &(completor
->head
);
746 /*----------------------------------------------------------------
748 * Interprets the results of a synchronous RID-write
749 ----------------------------------------------------------------*/
750 typedef usbctlx_cmd_completor_t usbctlx_wrid_completor_t
;
751 #define init_wrid_completor init_cmd_completor
753 /*----------------------------------------------------------------
755 * Interprets the results of a synchronous memory-write
756 ----------------------------------------------------------------*/
757 typedef usbctlx_cmd_completor_t usbctlx_wmem_completor_t
;
758 #define init_wmem_completor init_cmd_completor
760 /*----------------------------------------------------------------
762 * Interprets the results of a synchronous memory-read
763 ----------------------------------------------------------------*/
764 struct usbctlx_rmem_completor
{
765 usbctlx_completor_t head
;
767 const hfa384x_usb_rmemresp_t
*rmemresp
;
771 typedef struct usbctlx_rmem_completor usbctlx_rmem_completor_t
;
773 static int usbctlx_rmem_completor_fn(usbctlx_completor_t
*head
)
775 usbctlx_rmem_completor_t
*complete
= (usbctlx_rmem_completor_t
*) head
;
777 pr_debug("rmemresp:len=%d\n", complete
->rmemresp
->frmlen
);
778 memcpy(complete
->data
, complete
->rmemresp
->data
, complete
->len
);
782 static inline usbctlx_completor_t
*init_rmem_completor(usbctlx_rmem_completor_t
784 hfa384x_usb_rmemresp_t
785 *rmemresp
, void *data
,
788 completor
->head
.complete
= usbctlx_rmem_completor_fn
;
789 completor
->rmemresp
= rmemresp
;
790 completor
->data
= data
;
791 completor
->len
= len
;
792 return &(completor
->head
);
795 /*----------------------------------------------------------------
798 * Ctlx_complete handler for async CMD type control exchanges.
799 * mark the hw struct as such.
801 * Note: If the handling is changed here, it should probably be
802 * changed in docmd as well.
806 * ctlx completed CTLX
815 ----------------------------------------------------------------*/
816 static void hfa384x_cb_status(hfa384x_t
*hw
, const hfa384x_usbctlx_t
*ctlx
)
818 if (ctlx
->usercb
!= NULL
) {
819 hfa384x_cmdresult_t cmdresult
;
821 if (ctlx
->state
!= CTLX_COMPLETE
) {
822 memset(&cmdresult
, 0, sizeof(cmdresult
));
824 HFA384x_STATUS_RESULT_SET(HFA384x_CMD_ERR
);
826 usbctlx_get_status(&ctlx
->inbuf
.cmdresp
, &cmdresult
);
829 ctlx
->usercb(hw
, &cmdresult
, ctlx
->usercb_data
);
833 /*----------------------------------------------------------------
836 * CTLX completion handler for async RRID type control exchanges.
838 * Note: If the handling is changed here, it should probably be
839 * changed in dorrid as well.
843 * ctlx completed CTLX
852 ----------------------------------------------------------------*/
853 static void hfa384x_cb_rrid(hfa384x_t
*hw
, const hfa384x_usbctlx_t
*ctlx
)
855 if (ctlx
->usercb
!= NULL
) {
856 hfa384x_rridresult_t rridresult
;
858 if (ctlx
->state
!= CTLX_COMPLETE
) {
859 memset(&rridresult
, 0, sizeof(rridresult
));
860 rridresult
.rid
= le16_to_cpu(ctlx
->outbuf
.rridreq
.rid
);
862 usbctlx_get_rridresult(&ctlx
->inbuf
.rridresp
,
866 ctlx
->usercb(hw
, &rridresult
, ctlx
->usercb_data
);
870 static inline int hfa384x_docmd_wait(hfa384x_t
*hw
, hfa384x_metacmd_t
*cmd
)
872 return hfa384x_docmd(hw
, DOWAIT
, cmd
, NULL
, NULL
, NULL
);
876 hfa384x_docmd_async(hfa384x_t
*hw
,
877 hfa384x_metacmd_t
*cmd
,
878 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
880 return hfa384x_docmd(hw
, DOASYNC
, cmd
, cmdcb
, usercb
, usercb_data
);
884 hfa384x_dorrid_wait(hfa384x_t
*hw
, u16 rid
, void *riddata
,
885 unsigned int riddatalen
)
887 return hfa384x_dorrid(hw
, DOWAIT
,
888 rid
, riddata
, riddatalen
, NULL
, NULL
, NULL
);
892 hfa384x_dorrid_async(hfa384x_t
*hw
,
893 u16 rid
, void *riddata
, unsigned int riddatalen
,
895 ctlx_usercb_t usercb
, void *usercb_data
)
897 return hfa384x_dorrid(hw
, DOASYNC
,
898 rid
, riddata
, riddatalen
,
899 cmdcb
, usercb
, usercb_data
);
903 hfa384x_dowrid_wait(hfa384x_t
*hw
, u16 rid
, void *riddata
,
904 unsigned int riddatalen
)
906 return hfa384x_dowrid(hw
, DOWAIT
,
907 rid
, riddata
, riddatalen
, NULL
, NULL
, NULL
);
911 hfa384x_dowrid_async(hfa384x_t
*hw
,
912 u16 rid
, void *riddata
, unsigned int riddatalen
,
914 ctlx_usercb_t usercb
, void *usercb_data
)
916 return hfa384x_dowrid(hw
, DOASYNC
,
917 rid
, riddata
, riddatalen
,
918 cmdcb
, usercb
, usercb_data
);
922 hfa384x_dormem_wait(hfa384x_t
*hw
,
923 u16 page
, u16 offset
, void *data
, unsigned int len
)
925 return hfa384x_dormem(hw
, DOWAIT
,
926 page
, offset
, data
, len
, NULL
, NULL
, NULL
);
930 hfa384x_dormem_async(hfa384x_t
*hw
,
931 u16 page
, u16 offset
, void *data
, unsigned int len
,
933 ctlx_usercb_t usercb
, void *usercb_data
)
935 return hfa384x_dormem(hw
, DOASYNC
,
936 page
, offset
, data
, len
,
937 cmdcb
, usercb
, usercb_data
);
941 hfa384x_dowmem_wait(hfa384x_t
*hw
,
942 u16 page
, u16 offset
, void *data
, unsigned int len
)
944 return hfa384x_dowmem(hw
, DOWAIT
,
945 page
, offset
, data
, len
, NULL
, NULL
, NULL
);
949 hfa384x_dowmem_async(hfa384x_t
*hw
,
955 ctlx_usercb_t usercb
, void *usercb_data
)
957 return hfa384x_dowmem(hw
, DOASYNC
,
958 page
, offset
, data
, len
,
959 cmdcb
, usercb
, usercb_data
);
962 /*----------------------------------------------------------------
963 * hfa384x_cmd_initialize
965 * Issues the initialize command and sets the hw->state based
969 * hw device structure
973 * >0 f/w reported error - f/w status code
974 * <0 driver reported error
980 ----------------------------------------------------------------*/
981 int hfa384x_cmd_initialize(hfa384x_t
*hw
)
985 hfa384x_metacmd_t cmd
;
987 cmd
.cmd
= HFA384x_CMDCODE_INIT
;
992 result
= hfa384x_docmd_wait(hw
, &cmd
);
994 pr_debug("cmdresp.init: "
995 "status=0x%04x, resp0=0x%04x, "
996 "resp1=0x%04x, resp2=0x%04x\n",
998 cmd
.result
.resp0
, cmd
.result
.resp1
, cmd
.result
.resp2
);
1000 for (i
= 0; i
< HFA384x_NUMPORTS_MAX
; i
++)
1001 hw
->port_enabled
[i
] = 0;
1004 hw
->link_status
= HFA384x_LINK_NOTCONNECTED
;
1009 /*----------------------------------------------------------------
1010 * hfa384x_cmd_disable
1012 * Issues the disable command to stop communications on one of
1016 * hw device structure
1017 * macport MAC port number (host order)
1021 * >0 f/w reported failure - f/w status code
1022 * <0 driver reported error (timeout|bad arg)
1028 ----------------------------------------------------------------*/
1029 int hfa384x_cmd_disable(hfa384x_t
*hw
, u16 macport
)
1032 hfa384x_metacmd_t cmd
;
1034 cmd
.cmd
= HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DISABLE
) |
1035 HFA384x_CMD_MACPORT_SET(macport
);
1040 result
= hfa384x_docmd_wait(hw
, &cmd
);
1045 /*----------------------------------------------------------------
1046 * hfa384x_cmd_enable
1048 * Issues the enable command to enable communications on one of
1052 * hw device structure
1053 * macport MAC port number
1057 * >0 f/w reported failure - f/w status code
1058 * <0 driver reported error (timeout|bad arg)
1064 ----------------------------------------------------------------*/
1065 int hfa384x_cmd_enable(hfa384x_t
*hw
, u16 macport
)
1068 hfa384x_metacmd_t cmd
;
1070 cmd
.cmd
= HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ENABLE
) |
1071 HFA384x_CMD_MACPORT_SET(macport
);
1076 result
= hfa384x_docmd_wait(hw
, &cmd
);
1081 /*----------------------------------------------------------------
1082 * hfa384x_cmd_monitor
1084 * Enables the 'monitor mode' of the MAC. Here's the description of
1085 * monitor mode that I've received thus far:
1087 * "The "monitor mode" of operation is that the MAC passes all
1088 * frames for which the PLCP checks are correct. All received
1089 * MPDUs are passed to the host with MAC Port = 7, with a
1090 * receive status of good, FCS error, or undecryptable. Passing
1091 * certain MPDUs is a violation of the 802.11 standard, but useful
1092 * for a debugging tool." Normal communication is not possible
1093 * while monitor mode is enabled.
1096 * hw device structure
1097 * enable a code (0x0b|0x0f) that enables/disables
1098 * monitor mode. (host order)
1102 * >0 f/w reported failure - f/w status code
1103 * <0 driver reported error (timeout|bad arg)
1109 ----------------------------------------------------------------*/
1110 int hfa384x_cmd_monitor(hfa384x_t
*hw
, u16 enable
)
1113 hfa384x_metacmd_t cmd
;
1115 cmd
.cmd
= HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR
) |
1116 HFA384x_CMD_AINFO_SET(enable
);
1121 result
= hfa384x_docmd_wait(hw
, &cmd
);
1126 /*----------------------------------------------------------------
1127 * hfa384x_cmd_download
1129 * Sets the controls for the MAC controller code/data download
1130 * process. The arguments set the mode and address associated
1131 * with a download. Note that the aux registers should be enabled
1132 * prior to setting one of the download enable modes.
1135 * hw device structure
1136 * mode 0 - Disable programming and begin code exec
1137 * 1 - Enable volatile mem programming
1138 * 2 - Enable non-volatile mem programming
1139 * 3 - Program non-volatile section from NV download
1143 * highaddr For mode 1, sets the high & low order bits of
1144 * the "destination address". This address will be
1145 * the execution start address when download is
1146 * subsequently disabled.
1147 * For mode 2, sets the high & low order bits of
1148 * the destination in NV ram.
1149 * For modes 0 & 3, should be zero. (host order)
1150 * NOTE: these are CMD format.
1151 * codelen Length of the data to write in mode 2,
1152 * zero otherwise. (host order)
1156 * >0 f/w reported failure - f/w status code
1157 * <0 driver reported error (timeout|bad arg)
1163 ----------------------------------------------------------------*/
1164 int hfa384x_cmd_download(hfa384x_t
*hw
, u16 mode
, u16 lowaddr
,
1165 u16 highaddr
, u16 codelen
)
1168 hfa384x_metacmd_t cmd
;
1170 pr_debug("mode=%d, lowaddr=0x%04x, highaddr=0x%04x, codelen=%d\n",
1171 mode
, lowaddr
, highaddr
, codelen
);
1173 cmd
.cmd
= (HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DOWNLD
) |
1174 HFA384x_CMD_PROGMODE_SET(mode
));
1176 cmd
.parm0
= lowaddr
;
1177 cmd
.parm1
= highaddr
;
1178 cmd
.parm2
= codelen
;
1180 result
= hfa384x_docmd_wait(hw
, &cmd
);
1185 /*----------------------------------------------------------------
1188 * Perform a reset of the hfa38xx MAC core. We assume that the hw
1189 * structure is in its "created" state. That is, it is initialized
1190 * with proper values. Note that if a reset is done after the
1191 * device has been active for awhile, the caller might have to clean
1192 * up some leftover cruft in the hw structure.
1195 * hw device structure
1196 * holdtime how long (in ms) to hold the reset
1197 * settletime how long (in ms) to wait after releasing
1207 ----------------------------------------------------------------*/
1208 int hfa384x_corereset(hfa384x_t
*hw
, int holdtime
, int settletime
, int genesis
)
1212 result
= usb_reset_device(hw
->usb
);
1214 printk(KERN_ERR
"usb_reset_device() failed, result=%d.\n",
1221 /*----------------------------------------------------------------
1222 * hfa384x_usbctlx_complete_sync
1224 * Waits for a synchronous CTLX object to complete,
1225 * and then handles the response.
1228 * hw device structure
1230 * completor functor object to decide what to
1231 * do with the CTLX's result.
1235 * -ERESTARTSYS Interrupted by a signal
1237 * -ENODEV Adapter was unplugged
1238 * ??? Result from completor
1244 ----------------------------------------------------------------*/
1245 static int hfa384x_usbctlx_complete_sync(hfa384x_t
*hw
,
1246 hfa384x_usbctlx_t
*ctlx
,
1247 usbctlx_completor_t
*completor
)
1249 unsigned long flags
;
1252 result
= wait_for_completion_interruptible(&ctlx
->done
);
1254 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
1257 * We can only handle the CTLX if the USB disconnect
1258 * function has not run yet ...
1261 if (hw
->wlandev
->hwremoved
) {
1262 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1264 } else if (result
!= 0) {
1268 * We were probably interrupted, so delete
1269 * this CTLX asynchronously, kill the timers
1270 * and the URB, and then start the next
1273 * NOTE: We can only delete the timers and
1274 * the URB if this CTLX is active.
1276 if (ctlx
== get_active_ctlx(hw
)) {
1277 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1279 del_singleshot_timer_sync(&hw
->reqtimer
);
1280 del_singleshot_timer_sync(&hw
->resptimer
);
1281 hw
->req_timer_done
= 1;
1282 hw
->resp_timer_done
= 1;
1283 usb_kill_urb(&hw
->ctlx_urb
);
1285 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
1290 * This scenario is so unlikely that I'm
1291 * happy with a grubby "goto" solution ...
1293 if (hw
->wlandev
->hwremoved
)
1298 * The completion task will send this CTLX
1299 * to the reaper the next time it runs. We
1300 * are no longer in a hurry.
1303 ctlx
->state
= CTLX_REQ_FAILED
;
1304 list_move_tail(&ctlx
->list
, &hw
->ctlxq
.completing
);
1306 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1309 hfa384x_usbctlxq_run(hw
);
1311 if (ctlx
->state
== CTLX_COMPLETE
) {
1312 result
= completor
->complete(completor
);
1314 printk(KERN_WARNING
"CTLX[%d] error: state(%s)\n",
1315 le16_to_cpu(ctlx
->outbuf
.type
),
1316 ctlxstr(ctlx
->state
));
1320 list_del(&ctlx
->list
);
1321 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1328 /*----------------------------------------------------------------
1331 * Constructs a command CTLX and submits it.
1333 * NOTE: Any changes to the 'post-submit' code in this function
1334 * need to be carried over to hfa384x_cbcmd() since the handling
1335 * is virtually identical.
1338 * hw device structure
1339 * mode DOWAIT or DOASYNC
1340 * cmd cmd structure. Includes all arguments and result
1341 * data points. All in host order. in host order
1342 * cmdcb command-specific callback
1343 * usercb user callback for async calls, NULL for DOWAIT calls
1344 * usercb_data user supplied data pointer for async calls, NULL
1350 * -ERESTARTSYS Awakened on signal
1351 * >0 command indicated error, Status and Resp0-2 are
1359 ----------------------------------------------------------------*/
1361 hfa384x_docmd(hfa384x_t
*hw
,
1363 hfa384x_metacmd_t
*cmd
,
1364 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1367 hfa384x_usbctlx_t
*ctlx
;
1369 ctlx
= usbctlx_alloc();
1375 /* Initialize the command */
1376 ctlx
->outbuf
.cmdreq
.type
= cpu_to_le16(HFA384x_USB_CMDREQ
);
1377 ctlx
->outbuf
.cmdreq
.cmd
= cpu_to_le16(cmd
->cmd
);
1378 ctlx
->outbuf
.cmdreq
.parm0
= cpu_to_le16(cmd
->parm0
);
1379 ctlx
->outbuf
.cmdreq
.parm1
= cpu_to_le16(cmd
->parm1
);
1380 ctlx
->outbuf
.cmdreq
.parm2
= cpu_to_le16(cmd
->parm2
);
1382 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.cmdreq
);
1384 pr_debug("cmdreq: cmd=0x%04x "
1385 "parm0=0x%04x parm1=0x%04x parm2=0x%04x\n",
1386 cmd
->cmd
, cmd
->parm0
, cmd
->parm1
, cmd
->parm2
);
1388 ctlx
->reapable
= mode
;
1389 ctlx
->cmdcb
= cmdcb
;
1390 ctlx
->usercb
= usercb
;
1391 ctlx
->usercb_data
= usercb_data
;
1393 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1396 } else if (mode
== DOWAIT
) {
1397 usbctlx_cmd_completor_t completor
;
1400 hfa384x_usbctlx_complete_sync(hw
, ctlx
,
1401 init_cmd_completor(&completor
,
1413 /*----------------------------------------------------------------
1416 * Constructs a read rid CTLX and issues it.
1418 * NOTE: Any changes to the 'post-submit' code in this function
1419 * need to be carried over to hfa384x_cbrrid() since the handling
1420 * is virtually identical.
1423 * hw device structure
1424 * mode DOWAIT or DOASYNC
1425 * rid Read RID number (host order)
1426 * riddata Caller supplied buffer that MAC formatted RID.data
1427 * record will be written to for DOWAIT calls. Should
1428 * be NULL for DOASYNC calls.
1429 * riddatalen Buffer length for DOWAIT calls. Zero for DOASYNC calls.
1430 * cmdcb command callback for async calls, NULL for DOWAIT calls
1431 * usercb user callback for async calls, NULL for DOWAIT calls
1432 * usercb_data user supplied data pointer for async calls, NULL
1438 * -ERESTARTSYS Awakened on signal
1439 * -ENODATA riddatalen != macdatalen
1440 * >0 command indicated error, Status and Resp0-2 are
1446 * interrupt (DOASYNC)
1447 * process (DOWAIT or DOASYNC)
1448 ----------------------------------------------------------------*/
1450 hfa384x_dorrid(hfa384x_t
*hw
,
1454 unsigned int riddatalen
,
1455 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1458 hfa384x_usbctlx_t
*ctlx
;
1460 ctlx
= usbctlx_alloc();
1466 /* Initialize the command */
1467 ctlx
->outbuf
.rridreq
.type
= cpu_to_le16(HFA384x_USB_RRIDREQ
);
1468 ctlx
->outbuf
.rridreq
.frmlen
=
1469 cpu_to_le16(sizeof(ctlx
->outbuf
.rridreq
.rid
));
1470 ctlx
->outbuf
.rridreq
.rid
= cpu_to_le16(rid
);
1472 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.rridreq
);
1474 ctlx
->reapable
= mode
;
1475 ctlx
->cmdcb
= cmdcb
;
1476 ctlx
->usercb
= usercb
;
1477 ctlx
->usercb_data
= usercb_data
;
1479 /* Submit the CTLX */
1480 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1483 } else if (mode
== DOWAIT
) {
1484 usbctlx_rrid_completor_t completor
;
1487 hfa384x_usbctlx_complete_sync(hw
, ctlx
,
1490 &ctlx
->inbuf
.rridresp
,
1491 riddata
, riddatalen
));
1498 /*----------------------------------------------------------------
1501 * Constructs a write rid CTLX and issues it.
1503 * NOTE: Any changes to the 'post-submit' code in this function
1504 * need to be carried over to hfa384x_cbwrid() since the handling
1505 * is virtually identical.
1508 * hw device structure
1509 * CMD_MODE DOWAIT or DOASYNC
1511 * riddata Data portion of RID formatted for MAC
1512 * riddatalen Length of the data portion in bytes
1513 * cmdcb command callback for async calls, NULL for DOWAIT calls
1514 * usercb user callback for async calls, NULL for DOWAIT calls
1515 * usercb_data user supplied data pointer for async calls
1519 * -ETIMEDOUT timed out waiting for register ready or
1520 * command completion
1521 * >0 command indicated error, Status and Resp0-2 are
1527 * interrupt (DOASYNC)
1528 * process (DOWAIT or DOASYNC)
1529 ----------------------------------------------------------------*/
1531 hfa384x_dowrid(hfa384x_t
*hw
,
1535 unsigned int riddatalen
,
1536 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1539 hfa384x_usbctlx_t
*ctlx
;
1541 ctlx
= usbctlx_alloc();
1547 /* Initialize the command */
1548 ctlx
->outbuf
.wridreq
.type
= cpu_to_le16(HFA384x_USB_WRIDREQ
);
1549 ctlx
->outbuf
.wridreq
.frmlen
= cpu_to_le16((sizeof
1550 (ctlx
->outbuf
.wridreq
.rid
) +
1551 riddatalen
+ 1) / 2);
1552 ctlx
->outbuf
.wridreq
.rid
= cpu_to_le16(rid
);
1553 memcpy(ctlx
->outbuf
.wridreq
.data
, riddata
, riddatalen
);
1555 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.wridreq
.type
) +
1556 sizeof(ctlx
->outbuf
.wridreq
.frmlen
) +
1557 sizeof(ctlx
->outbuf
.wridreq
.rid
) + riddatalen
;
1559 ctlx
->reapable
= mode
;
1560 ctlx
->cmdcb
= cmdcb
;
1561 ctlx
->usercb
= usercb
;
1562 ctlx
->usercb_data
= usercb_data
;
1564 /* Submit the CTLX */
1565 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1568 } else if (mode
== DOWAIT
) {
1569 usbctlx_wrid_completor_t completor
;
1570 hfa384x_cmdresult_t wridresult
;
1572 result
= hfa384x_usbctlx_complete_sync(hw
,
1576 &ctlx
->inbuf
.wridresp
,
1584 /*----------------------------------------------------------------
1587 * Constructs a readmem CTLX and issues it.
1589 * NOTE: Any changes to the 'post-submit' code in this function
1590 * need to be carried over to hfa384x_cbrmem() since the handling
1591 * is virtually identical.
1594 * hw device structure
1595 * mode DOWAIT or DOASYNC
1596 * page MAC address space page (CMD format)
1597 * offset MAC address space offset
1598 * data Ptr to data buffer to receive read
1599 * len Length of the data to read (max == 2048)
1600 * cmdcb command callback for async calls, NULL for DOWAIT calls
1601 * usercb user callback for async calls, NULL for DOWAIT calls
1602 * usercb_data user supplied data pointer for async calls
1606 * -ETIMEDOUT timed out waiting for register ready or
1607 * command completion
1608 * >0 command indicated error, Status and Resp0-2 are
1614 * interrupt (DOASYNC)
1615 * process (DOWAIT or DOASYNC)
1616 ----------------------------------------------------------------*/
1618 hfa384x_dormem(hfa384x_t
*hw
,
1624 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1627 hfa384x_usbctlx_t
*ctlx
;
1629 ctlx
= usbctlx_alloc();
1635 /* Initialize the command */
1636 ctlx
->outbuf
.rmemreq
.type
= cpu_to_le16(HFA384x_USB_RMEMREQ
);
1637 ctlx
->outbuf
.rmemreq
.frmlen
=
1638 cpu_to_le16(sizeof(ctlx
->outbuf
.rmemreq
.offset
) +
1639 sizeof(ctlx
->outbuf
.rmemreq
.page
) + len
);
1640 ctlx
->outbuf
.rmemreq
.offset
= cpu_to_le16(offset
);
1641 ctlx
->outbuf
.rmemreq
.page
= cpu_to_le16(page
);
1643 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.rmemreq
);
1645 pr_debug("type=0x%04x frmlen=%d offset=0x%04x page=0x%04x\n",
1646 ctlx
->outbuf
.rmemreq
.type
,
1647 ctlx
->outbuf
.rmemreq
.frmlen
,
1648 ctlx
->outbuf
.rmemreq
.offset
, ctlx
->outbuf
.rmemreq
.page
);
1650 pr_debug("pktsize=%zd\n", ROUNDUP64(sizeof(ctlx
->outbuf
.rmemreq
)));
1652 ctlx
->reapable
= mode
;
1653 ctlx
->cmdcb
= cmdcb
;
1654 ctlx
->usercb
= usercb
;
1655 ctlx
->usercb_data
= usercb_data
;
1657 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1660 } else if (mode
== DOWAIT
) {
1661 usbctlx_rmem_completor_t completor
;
1664 hfa384x_usbctlx_complete_sync(hw
, ctlx
,
1667 &ctlx
->inbuf
.rmemresp
, data
,
1675 /*----------------------------------------------------------------
1678 * Constructs a writemem CTLX and issues it.
1680 * NOTE: Any changes to the 'post-submit' code in this function
1681 * need to be carried over to hfa384x_cbwmem() since the handling
1682 * is virtually identical.
1685 * hw device structure
1686 * mode DOWAIT or DOASYNC
1687 * page MAC address space page (CMD format)
1688 * offset MAC address space offset
1689 * data Ptr to data buffer containing write data
1690 * len Length of the data to read (max == 2048)
1691 * cmdcb command callback for async calls, NULL for DOWAIT calls
1692 * usercb user callback for async calls, NULL for DOWAIT calls
1693 * usercb_data user supplied data pointer for async calls.
1697 * -ETIMEDOUT timed out waiting for register ready or
1698 * command completion
1699 * >0 command indicated error, Status and Resp0-2 are
1705 * interrupt (DOWAIT)
1706 * process (DOWAIT or DOASYNC)
1707 ----------------------------------------------------------------*/
1709 hfa384x_dowmem(hfa384x_t
*hw
,
1715 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1718 hfa384x_usbctlx_t
*ctlx
;
1720 pr_debug("page=0x%04x offset=0x%04x len=%d\n", page
, offset
, len
);
1722 ctlx
= usbctlx_alloc();
1728 /* Initialize the command */
1729 ctlx
->outbuf
.wmemreq
.type
= cpu_to_le16(HFA384x_USB_WMEMREQ
);
1730 ctlx
->outbuf
.wmemreq
.frmlen
=
1731 cpu_to_le16(sizeof(ctlx
->outbuf
.wmemreq
.offset
) +
1732 sizeof(ctlx
->outbuf
.wmemreq
.page
) + len
);
1733 ctlx
->outbuf
.wmemreq
.offset
= cpu_to_le16(offset
);
1734 ctlx
->outbuf
.wmemreq
.page
= cpu_to_le16(page
);
1735 memcpy(ctlx
->outbuf
.wmemreq
.data
, data
, len
);
1737 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.wmemreq
.type
) +
1738 sizeof(ctlx
->outbuf
.wmemreq
.frmlen
) +
1739 sizeof(ctlx
->outbuf
.wmemreq
.offset
) +
1740 sizeof(ctlx
->outbuf
.wmemreq
.page
) + len
;
1742 ctlx
->reapable
= mode
;
1743 ctlx
->cmdcb
= cmdcb
;
1744 ctlx
->usercb
= usercb
;
1745 ctlx
->usercb_data
= usercb_data
;
1747 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1750 } else if (mode
== DOWAIT
) {
1751 usbctlx_wmem_completor_t completor
;
1752 hfa384x_cmdresult_t wmemresult
;
1754 result
= hfa384x_usbctlx_complete_sync(hw
,
1758 &ctlx
->inbuf
.wmemresp
,
1766 /*----------------------------------------------------------------
1767 * hfa384x_drvr_commtallies
1769 * Send a commtallies inquiry to the MAC. Note that this is an async
1770 * call that will result in an info frame arriving sometime later.
1773 * hw device structure
1782 ----------------------------------------------------------------*/
1783 int hfa384x_drvr_commtallies(hfa384x_t
*hw
)
1785 hfa384x_metacmd_t cmd
;
1787 cmd
.cmd
= HFA384x_CMDCODE_INQ
;
1788 cmd
.parm0
= HFA384x_IT_COMMTALLIES
;
1792 hfa384x_docmd_async(hw
, &cmd
, NULL
, NULL
, NULL
);
1797 /*----------------------------------------------------------------
1798 * hfa384x_drvr_disable
1800 * Issues the disable command to stop communications on one of
1801 * the MACs 'ports'. Only macport 0 is valid for stations.
1802 * APs may also disable macports 1-6. Only ports that have been
1803 * previously enabled may be disabled.
1806 * hw device structure
1807 * macport MAC port number (host order)
1811 * >0 f/w reported failure - f/w status code
1812 * <0 driver reported error (timeout|bad arg)
1818 ----------------------------------------------------------------*/
1819 int hfa384x_drvr_disable(hfa384x_t
*hw
, u16 macport
)
1823 if ((!hw
->isap
&& macport
!= 0) ||
1824 (hw
->isap
&& !(macport
<= HFA384x_PORTID_MAX
)) ||
1825 !(hw
->port_enabled
[macport
])) {
1828 result
= hfa384x_cmd_disable(hw
, macport
);
1830 hw
->port_enabled
[macport
] = 0;
1835 /*----------------------------------------------------------------
1836 * hfa384x_drvr_enable
1838 * Issues the enable command to enable communications on one of
1839 * the MACs 'ports'. Only macport 0 is valid for stations.
1840 * APs may also enable macports 1-6. Only ports that are currently
1841 * disabled may be enabled.
1844 * hw device structure
1845 * macport MAC port number
1849 * >0 f/w reported failure - f/w status code
1850 * <0 driver reported error (timeout|bad arg)
1856 ----------------------------------------------------------------*/
1857 int hfa384x_drvr_enable(hfa384x_t
*hw
, u16 macport
)
1861 if ((!hw
->isap
&& macport
!= 0) ||
1862 (hw
->isap
&& !(macport
<= HFA384x_PORTID_MAX
)) ||
1863 (hw
->port_enabled
[macport
])) {
1866 result
= hfa384x_cmd_enable(hw
, macport
);
1868 hw
->port_enabled
[macport
] = 1;
1873 /*----------------------------------------------------------------
1874 * hfa384x_drvr_flashdl_enable
1876 * Begins the flash download state. Checks to see that we're not
1877 * already in a download state and that a port isn't enabled.
1878 * Sets the download state and retrieves the flash download
1879 * buffer location, buffer size, and timeout length.
1882 * hw device structure
1886 * >0 f/w reported error - f/w status code
1887 * <0 driver reported error
1893 ----------------------------------------------------------------*/
1894 int hfa384x_drvr_flashdl_enable(hfa384x_t
*hw
)
1899 /* Check that a port isn't active */
1900 for (i
= 0; i
< HFA384x_PORTID_MAX
; i
++) {
1901 if (hw
->port_enabled
[i
]) {
1902 pr_debug("called when port enabled.\n");
1907 /* Check that we're not already in a download state */
1908 if (hw
->dlstate
!= HFA384x_DLSTATE_DISABLED
)
1911 /* Retrieve the buffer loc&size and timeout */
1912 if ((result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_DOWNLOADBUFFER
,
1914 sizeof(hw
->bufinfo
)))) {
1917 hw
->bufinfo
.page
= le16_to_cpu(hw
->bufinfo
.page
);
1918 hw
->bufinfo
.offset
= le16_to_cpu(hw
->bufinfo
.offset
);
1919 hw
->bufinfo
.len
= le16_to_cpu(hw
->bufinfo
.len
);
1920 if ((result
= hfa384x_drvr_getconfig16(hw
, HFA384x_RID_MAXLOADTIME
,
1921 &(hw
->dltimeout
)))) {
1924 hw
->dltimeout
= le16_to_cpu(hw
->dltimeout
);
1926 pr_debug("flashdl_enable\n");
1928 hw
->dlstate
= HFA384x_DLSTATE_FLASHENABLED
;
1933 /*----------------------------------------------------------------
1934 * hfa384x_drvr_flashdl_disable
1936 * Ends the flash download state. Note that this will cause the MAC
1937 * firmware to restart.
1940 * hw device structure
1944 * >0 f/w reported error - f/w status code
1945 * <0 driver reported error
1951 ----------------------------------------------------------------*/
1952 int hfa384x_drvr_flashdl_disable(hfa384x_t
*hw
)
1954 /* Check that we're already in the download state */
1955 if (hw
->dlstate
!= HFA384x_DLSTATE_FLASHENABLED
)
1958 pr_debug("flashdl_enable\n");
1960 /* There isn't much we can do at this point, so I don't */
1961 /* bother w/ the return value */
1962 hfa384x_cmd_download(hw
, HFA384x_PROGMODE_DISABLE
, 0, 0, 0);
1963 hw
->dlstate
= HFA384x_DLSTATE_DISABLED
;
1968 /*----------------------------------------------------------------
1969 * hfa384x_drvr_flashdl_write
1971 * Performs a FLASH download of a chunk of data. First checks to see
1972 * that we're in the FLASH download state, then sets the download
1973 * mode, uses the aux functions to 1) copy the data to the flash
1974 * buffer, 2) sets the download 'write flash' mode, 3) readback and
1975 * compare. Lather rinse, repeat as many times an necessary to get
1976 * all the given data into flash.
1977 * When all data has been written using this function (possibly
1978 * repeatedly), call drvr_flashdl_disable() to end the download state
1979 * and restart the MAC.
1982 * hw device structure
1983 * daddr Card address to write to. (host order)
1984 * buf Ptr to data to write.
1985 * len Length of data (host order).
1989 * >0 f/w reported error - f/w status code
1990 * <0 driver reported error
1996 ----------------------------------------------------------------*/
1997 int hfa384x_drvr_flashdl_write(hfa384x_t
*hw
, u32 daddr
, void *buf
, u32 len
)
2014 pr_debug("daddr=0x%08x len=%d\n", daddr
, len
);
2016 /* Check that we're in the flash download state */
2017 if (hw
->dlstate
!= HFA384x_DLSTATE_FLASHENABLED
)
2020 printk(KERN_INFO
"Download %d bytes to flash @0x%06x\n", len
, daddr
);
2022 /* Convert to flat address for arithmetic */
2023 /* NOTE: dlbuffer RID stores the address in AUX format */
2025 HFA384x_ADDR_AUX_MKFLAT(hw
->bufinfo
.page
, hw
->bufinfo
.offset
);
2026 pr_debug("dlbuf.page=0x%04x dlbuf.offset=0x%04x dlbufaddr=0x%08x\n",
2027 hw
->bufinfo
.page
, hw
->bufinfo
.offset
, dlbufaddr
);
2030 printk(KERN_WARNING
"dlbuf@0x%06lx len=%d to=%d\n", dlbufaddr
,
2031 hw
->bufinfo
.len
, hw
->dltimeout
);
2033 /* Calculations to determine how many fills of the dlbuffer to do
2034 * and how many USB wmemreq's to do for each fill. At this point
2035 * in time, the dlbuffer size and the wmemreq size are the same.
2036 * Therefore, nwrites should always be 1. The extra complexity
2037 * here is a hedge against future changes.
2040 /* Figure out how many times to do the flash programming */
2041 nburns
= len
/ hw
->bufinfo
.len
;
2042 nburns
+= (len
% hw
->bufinfo
.len
) ? 1 : 0;
2044 /* For each flash program cycle, how many USB wmemreq's are needed? */
2045 nwrites
= hw
->bufinfo
.len
/ HFA384x_USB_RWMEM_MAXLEN
;
2046 nwrites
+= (hw
->bufinfo
.len
% HFA384x_USB_RWMEM_MAXLEN
) ? 1 : 0;
2049 for (i
= 0; i
< nburns
; i
++) {
2050 /* Get the dest address and len */
2051 burnlen
= (len
- (hw
->bufinfo
.len
* i
)) > hw
->bufinfo
.len
?
2052 hw
->bufinfo
.len
: (len
- (hw
->bufinfo
.len
* i
));
2053 burndaddr
= daddr
+ (hw
->bufinfo
.len
* i
);
2054 burnlo
= HFA384x_ADDR_CMD_MKOFF(burndaddr
);
2055 burnhi
= HFA384x_ADDR_CMD_MKPAGE(burndaddr
);
2057 printk(KERN_INFO
"Writing %d bytes to flash @0x%06x\n",
2058 burnlen
, burndaddr
);
2060 /* Set the download mode */
2061 result
= hfa384x_cmd_download(hw
, HFA384x_PROGMODE_NV
,
2062 burnlo
, burnhi
, burnlen
);
2064 printk(KERN_ERR
"download(NV,lo=%x,hi=%x,len=%x) "
2065 "cmd failed, result=%d. Aborting d/l\n",
2066 burnlo
, burnhi
, burnlen
, result
);
2070 /* copy the data to the flash download buffer */
2071 for (j
= 0; j
< nwrites
; j
++) {
2073 (i
* hw
->bufinfo
.len
) +
2074 (j
* HFA384x_USB_RWMEM_MAXLEN
);
2076 writepage
= HFA384x_ADDR_CMD_MKPAGE(dlbufaddr
+
2078 HFA384x_USB_RWMEM_MAXLEN
));
2080 HFA384x_ADDR_CMD_MKOFF(dlbufaddr
+
2082 HFA384x_USB_RWMEM_MAXLEN
));
2084 writelen
= burnlen
- (j
* HFA384x_USB_RWMEM_MAXLEN
);
2085 writelen
= writelen
> HFA384x_USB_RWMEM_MAXLEN
?
2086 HFA384x_USB_RWMEM_MAXLEN
: writelen
;
2088 result
= hfa384x_dowmem_wait(hw
,
2091 writebuf
, writelen
);
2094 /* set the download 'write flash' mode */
2095 result
= hfa384x_cmd_download(hw
,
2096 HFA384x_PROGMODE_NVWRITE
,
2100 "download(NVWRITE,lo=%x,hi=%x,len=%x) "
2101 "cmd failed, result=%d. Aborting d/l\n",
2102 burnlo
, burnhi
, burnlen
, result
);
2106 /* TODO: We really should do a readback and compare. */
2111 /* Leave the firmware in the 'post-prog' mode. flashdl_disable will */
2112 /* actually disable programming mode. Remember, that will cause the */
2113 /* the firmware to effectively reset itself. */
2118 /*----------------------------------------------------------------
2119 * hfa384x_drvr_getconfig
2121 * Performs the sequence necessary to read a config/info item.
2124 * hw device structure
2125 * rid config/info record id (host order)
2126 * buf host side record buffer. Upon return it will
2127 * contain the body portion of the record (minus the
2129 * len buffer length (in bytes, should match record length)
2133 * >0 f/w reported error - f/w status code
2134 * <0 driver reported error
2135 * -ENODATA length mismatch between argument and retrieved
2142 ----------------------------------------------------------------*/
2143 int hfa384x_drvr_getconfig(hfa384x_t
*hw
, u16 rid
, void *buf
, u16 len
)
2147 result
= hfa384x_dorrid_wait(hw
, rid
, buf
, len
);
2152 /*----------------------------------------------------------------
2153 * hfa384x_drvr_getconfig_async
2155 * Performs the sequence necessary to perform an async read of
2156 * of a config/info item.
2159 * hw device structure
2160 * rid config/info record id (host order)
2161 * buf host side record buffer. Upon return it will
2162 * contain the body portion of the record (minus the
2164 * len buffer length (in bytes, should match record length)
2165 * cbfn caller supplied callback, called when the command
2166 * is done (successful or not).
2167 * cbfndata pointer to some caller supplied data that will be
2168 * passed in as an argument to the cbfn.
2171 * nothing the cbfn gets a status argument identifying if
2174 * Queues an hfa384x_usbcmd_t for subsequent execution.
2178 ----------------------------------------------------------------*/
2180 hfa384x_drvr_getconfig_async(hfa384x_t
*hw
,
2181 u16 rid
, ctlx_usercb_t usercb
, void *usercb_data
)
2183 return hfa384x_dorrid_async(hw
, rid
, NULL
, 0,
2184 hfa384x_cb_rrid
, usercb
, usercb_data
);
2187 /*----------------------------------------------------------------
2188 * hfa384x_drvr_setconfig_async
2190 * Performs the sequence necessary to write a config/info item.
2193 * hw device structure
2194 * rid config/info record id (in host order)
2195 * buf host side record buffer
2196 * len buffer length (in bytes)
2197 * usercb completion callback
2198 * usercb_data completion callback argument
2202 * >0 f/w reported error - f/w status code
2203 * <0 driver reported error
2209 ----------------------------------------------------------------*/
2211 hfa384x_drvr_setconfig_async(hfa384x_t
*hw
,
2214 u16 len
, ctlx_usercb_t usercb
, void *usercb_data
)
2216 return hfa384x_dowrid_async(hw
, rid
, buf
, len
,
2217 hfa384x_cb_status
, usercb
, usercb_data
);
2220 /*----------------------------------------------------------------
2221 * hfa384x_drvr_ramdl_disable
2223 * Ends the ram download state.
2226 * hw device structure
2230 * >0 f/w reported error - f/w status code
2231 * <0 driver reported error
2237 ----------------------------------------------------------------*/
2238 int hfa384x_drvr_ramdl_disable(hfa384x_t
*hw
)
2240 /* Check that we're already in the download state */
2241 if (hw
->dlstate
!= HFA384x_DLSTATE_RAMENABLED
)
2244 pr_debug("ramdl_disable()\n");
2246 /* There isn't much we can do at this point, so I don't */
2247 /* bother w/ the return value */
2248 hfa384x_cmd_download(hw
, HFA384x_PROGMODE_DISABLE
, 0, 0, 0);
2249 hw
->dlstate
= HFA384x_DLSTATE_DISABLED
;
2254 /*----------------------------------------------------------------
2255 * hfa384x_drvr_ramdl_enable
2257 * Begins the ram download state. Checks to see that we're not
2258 * already in a download state and that a port isn't enabled.
2259 * Sets the download state and calls cmd_download with the
2260 * ENABLE_VOLATILE subcommand and the exeaddr argument.
2263 * hw device structure
2264 * exeaddr the card execution address that will be
2265 * jumped to when ramdl_disable() is called
2270 * >0 f/w reported error - f/w status code
2271 * <0 driver reported error
2277 ----------------------------------------------------------------*/
2278 int hfa384x_drvr_ramdl_enable(hfa384x_t
*hw
, u32 exeaddr
)
2285 /* Check that a port isn't active */
2286 for (i
= 0; i
< HFA384x_PORTID_MAX
; i
++) {
2287 if (hw
->port_enabled
[i
]) {
2289 "Can't download with a macport enabled.\n");
2294 /* Check that we're not already in a download state */
2295 if (hw
->dlstate
!= HFA384x_DLSTATE_DISABLED
) {
2296 printk(KERN_ERR
"Download state not disabled.\n");
2300 pr_debug("ramdl_enable, exeaddr=0x%08x\n", exeaddr
);
2302 /* Call the download(1,addr) function */
2303 lowaddr
= HFA384x_ADDR_CMD_MKOFF(exeaddr
);
2304 hiaddr
= HFA384x_ADDR_CMD_MKPAGE(exeaddr
);
2306 result
= hfa384x_cmd_download(hw
, HFA384x_PROGMODE_RAM
,
2307 lowaddr
, hiaddr
, 0);
2310 /* Set the download state */
2311 hw
->dlstate
= HFA384x_DLSTATE_RAMENABLED
;
2313 pr_debug("cmd_download(0x%04x, 0x%04x) failed, result=%d.\n",
2314 lowaddr
, hiaddr
, result
);
2320 /*----------------------------------------------------------------
2321 * hfa384x_drvr_ramdl_write
2323 * Performs a RAM download of a chunk of data. First checks to see
2324 * that we're in the RAM download state, then uses the [read|write]mem USB
2325 * commands to 1) copy the data, 2) readback and compare. The download
2326 * state is unaffected. When all data has been written using
2327 * this function, call drvr_ramdl_disable() to end the download state
2328 * and restart the MAC.
2331 * hw device structure
2332 * daddr Card address to write to. (host order)
2333 * buf Ptr to data to write.
2334 * len Length of data (host order).
2338 * >0 f/w reported error - f/w status code
2339 * <0 driver reported error
2345 ----------------------------------------------------------------*/
2346 int hfa384x_drvr_ramdl_write(hfa384x_t
*hw
, u32 daddr
, void *buf
, u32 len
)
2357 /* Check that we're in the ram download state */
2358 if (hw
->dlstate
!= HFA384x_DLSTATE_RAMENABLED
)
2361 printk(KERN_INFO
"Writing %d bytes to ram @0x%06x\n", len
, daddr
);
2363 /* How many dowmem calls? */
2364 nwrites
= len
/ HFA384x_USB_RWMEM_MAXLEN
;
2365 nwrites
+= len
% HFA384x_USB_RWMEM_MAXLEN
? 1 : 0;
2367 /* Do blocking wmem's */
2368 for (i
= 0; i
< nwrites
; i
++) {
2369 /* make address args */
2370 curraddr
= daddr
+ (i
* HFA384x_USB_RWMEM_MAXLEN
);
2371 currpage
= HFA384x_ADDR_CMD_MKPAGE(curraddr
);
2372 curroffset
= HFA384x_ADDR_CMD_MKOFF(curraddr
);
2373 currlen
= len
- (i
* HFA384x_USB_RWMEM_MAXLEN
);
2374 if (currlen
> HFA384x_USB_RWMEM_MAXLEN
)
2375 currlen
= HFA384x_USB_RWMEM_MAXLEN
;
2377 /* Do blocking ctlx */
2378 result
= hfa384x_dowmem_wait(hw
,
2382 (i
* HFA384x_USB_RWMEM_MAXLEN
),
2388 /* TODO: We really should have a readback. */
2394 /*----------------------------------------------------------------
2395 * hfa384x_drvr_readpda
2397 * Performs the sequence to read the PDA space. Note there is no
2398 * drvr_writepda() function. Writing a PDA is
2399 * generally implemented by a calling component via calls to
2400 * cmd_download and writing to the flash download buffer via the
2404 * hw device structure
2405 * buf buffer to store PDA in
2410 * >0 f/w reported error - f/w status code
2411 * <0 driver reported error
2412 * -ETIMEDOUT timout waiting for the cmd regs to become
2413 * available, or waiting for the control reg
2414 * to indicate the Aux port is enabled.
2415 * -ENODATA the buffer does NOT contain a valid PDA.
2416 * Either the card PDA is bad, or the auxdata
2417 * reads are giving us garbage.
2423 * process or non-card interrupt.
2424 ----------------------------------------------------------------*/
2425 int hfa384x_drvr_readpda(hfa384x_t
*hw
, void *buf
, unsigned int len
)
2431 int currpdr
= 0; /* word offset of the current pdr */
2433 u16 pdrlen
; /* pdr length in bytes, host order */
2434 u16 pdrcode
; /* pdr code, host order */
2442 HFA3842_PDA_BASE
, 0}, {
2443 HFA3841_PDA_BASE
, 0}, {
2444 HFA3841_PDA_BOGUS_BASE
, 0}
2447 /* Read the pda from each known address. */
2448 for (i
= 0; i
< ARRAY_SIZE(pdaloc
); i
++) {
2450 currpage
= HFA384x_ADDR_CMD_MKPAGE(pdaloc
[i
].cardaddr
);
2451 curroffset
= HFA384x_ADDR_CMD_MKOFF(pdaloc
[i
].cardaddr
);
2453 result
= hfa384x_dormem_wait(hw
, currpage
, curroffset
, buf
, len
); /* units of bytes */
2457 "Read from index %zd failed, continuing\n", i
);
2461 /* Test for garbage */
2462 pdaok
= 1; /* initially assume good */
2464 while (pdaok
&& morepdrs
) {
2465 pdrlen
= le16_to_cpu(pda
[currpdr
]) * 2;
2466 pdrcode
= le16_to_cpu(pda
[currpdr
+ 1]);
2467 /* Test the record length */
2468 if (pdrlen
> HFA384x_PDR_LEN_MAX
|| pdrlen
== 0) {
2469 printk(KERN_ERR
"pdrlen invalid=%d\n", pdrlen
);
2474 if (!hfa384x_isgood_pdrcode(pdrcode
)) {
2475 printk(KERN_ERR
"pdrcode invalid=%d\n",
2480 /* Test for completion */
2481 if (pdrcode
== HFA384x_PDR_END_OF_PDA
)
2484 /* Move to the next pdr (if necessary) */
2486 /* note the access to pda[], need words here */
2487 currpdr
+= le16_to_cpu(pda
[currpdr
]) + 1;
2492 "PDA Read from 0x%08x in %s space.\n",
2494 pdaloc
[i
].auxctl
== 0 ? "EXTDS" :
2495 pdaloc
[i
].auxctl
== 1 ? "NV" :
2496 pdaloc
[i
].auxctl
== 2 ? "PHY" :
2497 pdaloc
[i
].auxctl
== 3 ? "ICSRAM" :
2502 result
= pdaok
? 0 : -ENODATA
;
2505 pr_debug("Failure: pda is not okay\n");
2510 /*----------------------------------------------------------------
2511 * hfa384x_drvr_setconfig
2513 * Performs the sequence necessary to write a config/info item.
2516 * hw device structure
2517 * rid config/info record id (in host order)
2518 * buf host side record buffer
2519 * len buffer length (in bytes)
2523 * >0 f/w reported error - f/w status code
2524 * <0 driver reported error
2530 ----------------------------------------------------------------*/
2531 int hfa384x_drvr_setconfig(hfa384x_t
*hw
, u16 rid
, void *buf
, u16 len
)
2533 return hfa384x_dowrid_wait(hw
, rid
, buf
, len
);
2536 /*----------------------------------------------------------------
2537 * hfa384x_drvr_start
2539 * Issues the MAC initialize command, sets up some data structures,
2540 * and enables the interrupts. After this function completes, the
2541 * low-level stuff should be ready for any/all commands.
2544 * hw device structure
2547 * >0 f/w reported error - f/w status code
2548 * <0 driver reported error
2554 ----------------------------------------------------------------*/
2556 int hfa384x_drvr_start(hfa384x_t
*hw
)
2558 int result
, result1
, result2
;
2563 /* Clear endpoint stalls - but only do this if the endpoint
2564 * is showing a stall status. Some prism2 cards seem to behave
2565 * badly if a clear_halt is called when the endpoint is already
2569 usb_get_status(hw
->usb
, USB_RECIP_ENDPOINT
, hw
->endp_in
, &status
);
2571 printk(KERN_ERR
"Cannot get bulk in endpoint status.\n");
2574 if ((status
== 1) && usb_clear_halt(hw
->usb
, hw
->endp_in
))
2575 printk(KERN_ERR
"Failed to reset bulk in endpoint.\n");
2578 usb_get_status(hw
->usb
, USB_RECIP_ENDPOINT
, hw
->endp_out
, &status
);
2580 printk(KERN_ERR
"Cannot get bulk out endpoint status.\n");
2583 if ((status
== 1) && usb_clear_halt(hw
->usb
, hw
->endp_out
))
2584 printk(KERN_ERR
"Failed to reset bulk out endpoint.\n");
2586 /* Synchronous unlink, in case we're trying to restart the driver */
2587 usb_kill_urb(&hw
->rx_urb
);
2589 /* Post the IN urb */
2590 result
= submit_rx_urb(hw
, GFP_KERNEL
);
2593 "Fatal, failed to submit RX URB, result=%d\n", result
);
2597 /* Call initialize twice, with a 1 second sleep in between.
2598 * This is a nasty work-around since many prism2 cards seem to
2599 * need time to settle after an init from cold. The second
2600 * call to initialize in theory is not necessary - but we call
2601 * it anyway as a double insurance policy:
2602 * 1) If the first init should fail, the second may well succeed
2603 * and the card can still be used
2604 * 2) It helps ensures all is well with the card after the first
2605 * init and settle time.
2607 result1
= hfa384x_cmd_initialize(hw
);
2609 result
= result2
= hfa384x_cmd_initialize(hw
);
2613 "cmd_initialize() failed on two attempts, results %d and %d\n",
2615 usb_kill_urb(&hw
->rx_urb
);
2618 pr_debug("First cmd_initialize() failed (result %d),\n",
2621 ("but second attempt succeeded. All should be ok\n");
2623 } else if (result2
!= 0) {
2625 "First cmd_initialize() succeeded, but second attempt failed (result=%d)\n",
2628 "Most likely the card will be functional\n");
2632 hw
->state
= HFA384x_STATE_RUNNING
;
2638 /*----------------------------------------------------------------
2641 * Shuts down the MAC to the point where it is safe to unload the
2642 * driver. Any subsystem that may be holding a data or function
2643 * ptr into the driver must be cleared/deinitialized.
2646 * hw device structure
2649 * >0 f/w reported error - f/w status code
2650 * <0 driver reported error
2656 ----------------------------------------------------------------*/
2657 int hfa384x_drvr_stop(hfa384x_t
*hw
)
2664 /* There's no need for spinlocks here. The USB "disconnect"
2665 * function sets this "removed" flag and then calls us.
2667 if (!hw
->wlandev
->hwremoved
) {
2668 /* Call initialize to leave the MAC in its 'reset' state */
2669 hfa384x_cmd_initialize(hw
);
2671 /* Cancel the rxurb */
2672 usb_kill_urb(&hw
->rx_urb
);
2675 hw
->link_status
= HFA384x_LINK_NOTCONNECTED
;
2676 hw
->state
= HFA384x_STATE_INIT
;
2678 del_timer_sync(&hw
->commsqual_timer
);
2680 /* Clear all the port status */
2681 for (i
= 0; i
< HFA384x_NUMPORTS_MAX
; i
++)
2682 hw
->port_enabled
[i
] = 0;
2687 /*----------------------------------------------------------------
2688 * hfa384x_drvr_txframe
2690 * Takes a frame from prism2sta and queues it for transmission.
2693 * hw device structure
2694 * skb packet buffer struct. Contains an 802.11
2696 * p80211_hdr points to the 802.11 header for the packet.
2698 * 0 Success and more buffs available
2699 * 1 Success but no more buffs
2700 * 2 Allocation failure
2701 * 4 Buffer full or queue busy
2707 ----------------------------------------------------------------*/
2708 int hfa384x_drvr_txframe(hfa384x_t
*hw
, struct sk_buff
*skb
,
2709 p80211_hdr_t
*p80211_hdr
,
2710 p80211_metawep_t
*p80211_wep
)
2712 int usbpktlen
= sizeof(hfa384x_tx_frame_t
);
2717 if (hw
->tx_urb
.status
== -EINPROGRESS
) {
2718 printk(KERN_WARNING
"TX URB already in use\n");
2723 /* Build Tx frame structure */
2724 /* Set up the control field */
2725 memset(&hw
->txbuff
.txfrm
.desc
, 0, sizeof(hw
->txbuff
.txfrm
.desc
));
2727 /* Setup the usb type field */
2728 hw
->txbuff
.type
= cpu_to_le16(HFA384x_USB_TXFRM
);
2730 /* Set up the sw_support field to identify this frame */
2731 hw
->txbuff
.txfrm
.desc
.sw_support
= 0x0123;
2733 /* Tx complete and Tx exception disable per dleach. Might be causing
2736 /* #define DOEXC SLP -- doboth breaks horribly under load, doexc less so. */
2738 hw
->txbuff
.txfrm
.desc
.tx_control
=
2739 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2740 HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(1);
2741 #elif defined(DOEXC)
2742 hw
->txbuff
.txfrm
.desc
.tx_control
=
2743 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2744 HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(0);
2746 hw
->txbuff
.txfrm
.desc
.tx_control
=
2747 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2748 HFA384x_TX_TXEX_SET(0) | HFA384x_TX_TXOK_SET(0);
2750 hw
->txbuff
.txfrm
.desc
.tx_control
=
2751 cpu_to_le16(hw
->txbuff
.txfrm
.desc
.tx_control
);
2753 /* copy the header over to the txdesc */
2754 memcpy(&(hw
->txbuff
.txfrm
.desc
.frame_control
), p80211_hdr
,
2755 sizeof(p80211_hdr_t
));
2757 /* if we're using host WEP, increase size by IV+ICV */
2758 if (p80211_wep
->data
) {
2759 hw
->txbuff
.txfrm
.desc
.data_len
= cpu_to_le16(skb
->len
+ 8);
2762 hw
->txbuff
.txfrm
.desc
.data_len
= cpu_to_le16(skb
->len
);
2765 usbpktlen
+= skb
->len
;
2767 /* copy over the WEP IV if we are using host WEP */
2768 ptr
= hw
->txbuff
.txfrm
.data
;
2769 if (p80211_wep
->data
) {
2770 memcpy(ptr
, p80211_wep
->iv
, sizeof(p80211_wep
->iv
));
2771 ptr
+= sizeof(p80211_wep
->iv
);
2772 memcpy(ptr
, p80211_wep
->data
, skb
->len
);
2774 memcpy(ptr
, skb
->data
, skb
->len
);
2776 /* copy over the packet data */
2779 /* copy over the WEP ICV if we are using host WEP */
2780 if (p80211_wep
->data
)
2781 memcpy(ptr
, p80211_wep
->icv
, sizeof(p80211_wep
->icv
));
2783 /* Send the USB packet */
2784 usb_fill_bulk_urb(&(hw
->tx_urb
), hw
->usb
,
2786 &(hw
->txbuff
), ROUNDUP64(usbpktlen
),
2787 hfa384x_usbout_callback
, hw
->wlandev
);
2788 hw
->tx_urb
.transfer_flags
|= USB_QUEUE_BULK
;
2791 ret
= submit_tx_urb(hw
, &hw
->tx_urb
, GFP_ATOMIC
);
2793 printk(KERN_ERR
"submit_tx_urb() failed, error=%d\n", ret
);
2801 void hfa384x_tx_timeout(wlandevice_t
*wlandev
)
2803 hfa384x_t
*hw
= wlandev
->priv
;
2804 unsigned long flags
;
2806 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2808 if (!hw
->wlandev
->hwremoved
&&
2809 /* Note the bitwise OR, not the logical OR. */
2810 (!test_and_set_bit(WORK_TX_HALT
, &hw
->usb_flags
) |
2811 !test_and_set_bit(WORK_RX_HALT
, &hw
->usb_flags
))) {
2812 schedule_work(&hw
->usb_work
);
2815 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2818 /*----------------------------------------------------------------
2819 * hfa384x_usbctlx_reaper_task
2821 * Tasklet to delete dead CTLX objects
2824 * data ptr to a hfa384x_t
2830 ----------------------------------------------------------------*/
2831 static void hfa384x_usbctlx_reaper_task(unsigned long data
)
2833 hfa384x_t
*hw
= (hfa384x_t
*) data
;
2834 struct list_head
*entry
;
2835 struct list_head
*temp
;
2836 unsigned long flags
;
2838 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2840 /* This list is guaranteed to be empty if someone
2841 * has unplugged the adapter.
2843 list_for_each_safe(entry
, temp
, &hw
->ctlxq
.reapable
) {
2844 hfa384x_usbctlx_t
*ctlx
;
2846 ctlx
= list_entry(entry
, hfa384x_usbctlx_t
, list
);
2847 list_del(&ctlx
->list
);
2851 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2855 /*----------------------------------------------------------------
2856 * hfa384x_usbctlx_completion_task
2858 * Tasklet to call completion handlers for returned CTLXs
2861 * data ptr to hfa384x_t
2868 ----------------------------------------------------------------*/
2869 static void hfa384x_usbctlx_completion_task(unsigned long data
)
2871 hfa384x_t
*hw
= (hfa384x_t
*) data
;
2872 struct list_head
*entry
;
2873 struct list_head
*temp
;
2874 unsigned long flags
;
2878 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2880 /* This list is guaranteed to be empty if someone
2881 * has unplugged the adapter ...
2883 list_for_each_safe(entry
, temp
, &hw
->ctlxq
.completing
) {
2884 hfa384x_usbctlx_t
*ctlx
;
2886 ctlx
= list_entry(entry
, hfa384x_usbctlx_t
, list
);
2888 /* Call the completion function that this
2889 * command was assigned, assuming it has one.
2891 if (ctlx
->cmdcb
!= NULL
) {
2892 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2893 ctlx
->cmdcb(hw
, ctlx
);
2894 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2896 /* Make sure we don't try and complete
2897 * this CTLX more than once!
2901 /* Did someone yank the adapter out
2902 * while our list was (briefly) unlocked?
2904 if (hw
->wlandev
->hwremoved
) {
2911 * "Reapable" CTLXs are ones which don't have any
2912 * threads waiting for them to die. Hence they must
2913 * be delivered to The Reaper!
2915 if (ctlx
->reapable
) {
2916 /* Move the CTLX off the "completing" list (hopefully)
2917 * on to the "reapable" list where the reaper task
2918 * can find it. And "reapable" means that this CTLX
2919 * isn't sitting on a wait-queue somewhere.
2921 list_move_tail(&ctlx
->list
, &hw
->ctlxq
.reapable
);
2925 complete(&ctlx
->done
);
2927 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2930 tasklet_schedule(&hw
->reaper_bh
);
2933 /*----------------------------------------------------------------
2934 * unlocked_usbctlx_cancel_async
2936 * Mark the CTLX dead asynchronously, and ensure that the
2937 * next command on the queue is run afterwards.
2940 * hw ptr to the hfa384x_t structure
2941 * ctlx ptr to a CTLX structure
2944 * 0 the CTLX's URB is inactive
2945 * -EINPROGRESS the URB is currently being unlinked
2948 * Either process or interrupt, but presumably interrupt
2949 ----------------------------------------------------------------*/
2950 static int unlocked_usbctlx_cancel_async(hfa384x_t
*hw
,
2951 hfa384x_usbctlx_t
*ctlx
)
2956 * Try to delete the URB containing our request packet.
2957 * If we succeed, then its completion handler will be
2958 * called with a status of -ECONNRESET.
2960 hw
->ctlx_urb
.transfer_flags
|= URB_ASYNC_UNLINK
;
2961 ret
= usb_unlink_urb(&hw
->ctlx_urb
);
2963 if (ret
!= -EINPROGRESS
) {
2965 * The OUT URB had either already completed
2966 * or was still in the pending queue, so the
2967 * URB's completion function will not be called.
2968 * We will have to complete the CTLX ourselves.
2970 ctlx
->state
= CTLX_REQ_FAILED
;
2971 unlocked_usbctlx_complete(hw
, ctlx
);
2978 /*----------------------------------------------------------------
2979 * unlocked_usbctlx_complete
2981 * A CTLX has completed. It may have been successful, it may not
2982 * have been. At this point, the CTLX should be quiescent. The URBs
2983 * aren't active and the timers should have been stopped.
2985 * The CTLX is migrated to the "completing" queue, and the completing
2986 * tasklet is scheduled.
2989 * hw ptr to a hfa384x_t structure
2990 * ctlx ptr to a ctlx structure
2998 * Either, assume interrupt
2999 ----------------------------------------------------------------*/
3000 static void unlocked_usbctlx_complete(hfa384x_t
*hw
, hfa384x_usbctlx_t
*ctlx
)
3002 /* Timers have been stopped, and ctlx should be in
3003 * a terminal state. Retire it from the "active"
3006 list_move_tail(&ctlx
->list
, &hw
->ctlxq
.completing
);
3007 tasklet_schedule(&hw
->completion_bh
);
3009 switch (ctlx
->state
) {
3011 case CTLX_REQ_FAILED
:
3012 /* This are the correct terminating states. */
3016 printk(KERN_ERR
"CTLX[%d] not in a terminating state(%s)\n",
3017 le16_to_cpu(ctlx
->outbuf
.type
), ctlxstr(ctlx
->state
));
3022 /*----------------------------------------------------------------
3023 * hfa384x_usbctlxq_run
3025 * Checks to see if the head item is running. If not, starts it.
3028 * hw ptr to hfa384x_t
3037 ----------------------------------------------------------------*/
3038 static void hfa384x_usbctlxq_run(hfa384x_t
*hw
)
3040 unsigned long flags
;
3043 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3045 /* Only one active CTLX at any one time, because there's no
3046 * other (reliable) way to match the response URB to the
3049 * Don't touch any of these CTLXs if the hardware
3050 * has been removed or the USB subsystem is stalled.
3052 if (!list_empty(&hw
->ctlxq
.active
) ||
3053 test_bit(WORK_TX_HALT
, &hw
->usb_flags
) || hw
->wlandev
->hwremoved
)
3056 while (!list_empty(&hw
->ctlxq
.pending
)) {
3057 hfa384x_usbctlx_t
*head
;
3060 /* This is the first pending command */
3061 head
= list_entry(hw
->ctlxq
.pending
.next
,
3062 hfa384x_usbctlx_t
, list
);
3064 /* We need to split this off to avoid a race condition */
3065 list_move_tail(&head
->list
, &hw
->ctlxq
.active
);
3067 /* Fill the out packet */
3068 usb_fill_bulk_urb(&(hw
->ctlx_urb
), hw
->usb
,
3070 &(head
->outbuf
), ROUNDUP64(head
->outbufsize
),
3071 hfa384x_ctlxout_callback
, hw
);
3072 hw
->ctlx_urb
.transfer_flags
|= USB_QUEUE_BULK
;
3074 /* Now submit the URB and update the CTLX's state
3076 if ((result
= SUBMIT_URB(&hw
->ctlx_urb
, GFP_ATOMIC
)) == 0) {
3077 /* This CTLX is now running on the active queue */
3078 head
->state
= CTLX_REQ_SUBMITTED
;
3080 /* Start the OUT wait timer */
3081 hw
->req_timer_done
= 0;
3082 hw
->reqtimer
.expires
= jiffies
+ HZ
;
3083 add_timer(&hw
->reqtimer
);
3085 /* Start the IN wait timer */
3086 hw
->resp_timer_done
= 0;
3087 hw
->resptimer
.expires
= jiffies
+ 2 * HZ
;
3088 add_timer(&hw
->resptimer
);
3093 if (result
== -EPIPE
) {
3094 /* The OUT pipe needs resetting, so put
3095 * this CTLX back in the "pending" queue
3096 * and schedule a reset ...
3099 "%s tx pipe stalled: requesting reset\n",
3100 hw
->wlandev
->netdev
->name
);
3101 list_move(&head
->list
, &hw
->ctlxq
.pending
);
3102 set_bit(WORK_TX_HALT
, &hw
->usb_flags
);
3103 schedule_work(&hw
->usb_work
);
3107 if (result
== -ESHUTDOWN
) {
3108 printk(KERN_WARNING
"%s urb shutdown!\n",
3109 hw
->wlandev
->netdev
->name
);
3113 printk(KERN_ERR
"Failed to submit CTLX[%d]: error=%d\n",
3114 le16_to_cpu(head
->outbuf
.type
), result
);
3115 unlocked_usbctlx_complete(hw
, head
);
3119 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3122 /*----------------------------------------------------------------
3123 * hfa384x_usbin_callback
3125 * Callback for URBs on the BULKIN endpoint.
3128 * urb ptr to the completed urb
3137 ----------------------------------------------------------------*/
3138 static void hfa384x_usbin_callback(struct urb
*urb
)
3140 wlandevice_t
*wlandev
= urb
->context
;
3142 hfa384x_usbin_t
*usbin
= (hfa384x_usbin_t
*) urb
->transfer_buffer
;
3143 struct sk_buff
*skb
= NULL
;
3154 if (!wlandev
|| !wlandev
->netdev
|| wlandev
->hwremoved
)
3161 skb
= hw
->rx_urb_skb
;
3162 BUG_ON(!skb
|| (skb
->data
!= urb
->transfer_buffer
));
3164 hw
->rx_urb_skb
= NULL
;
3166 /* Check for error conditions within the URB */
3167 switch (urb
->status
) {
3171 /* Check for short packet */
3172 if (urb
->actual_length
== 0) {
3173 ++(wlandev
->linux_stats
.rx_errors
);
3174 ++(wlandev
->linux_stats
.rx_length_errors
);
3180 printk(KERN_WARNING
"%s rx pipe stalled: requesting reset\n",
3181 wlandev
->netdev
->name
);
3182 if (!test_and_set_bit(WORK_RX_HALT
, &hw
->usb_flags
))
3183 schedule_work(&hw
->usb_work
);
3184 ++(wlandev
->linux_stats
.rx_errors
);
3191 if (!test_and_set_bit(THROTTLE_RX
, &hw
->usb_flags
) &&
3192 !timer_pending(&hw
->throttle
)) {
3193 mod_timer(&hw
->throttle
, jiffies
+ THROTTLE_JIFFIES
);
3195 ++(wlandev
->linux_stats
.rx_errors
);
3200 ++(wlandev
->linux_stats
.rx_over_errors
);
3206 pr_debug("status=%d, device removed.\n", urb
->status
);
3212 pr_debug("status=%d, urb explicitly unlinked.\n", urb
->status
);
3217 pr_debug("urb status=%d, transfer flags=0x%x\n",
3218 urb
->status
, urb
->transfer_flags
);
3219 ++(wlandev
->linux_stats
.rx_errors
);
3224 urb_status
= urb
->status
;
3226 if (action
!= ABORT
) {
3227 /* Repost the RX URB */
3228 result
= submit_rx_urb(hw
, GFP_ATOMIC
);
3232 "Fatal, failed to resubmit rx_urb. error=%d\n",
3237 /* Handle any USB-IN packet */
3238 /* Note: the check of the sw_support field, the type field doesn't
3239 * have bit 12 set like the docs suggest.
3241 type
= le16_to_cpu(usbin
->type
);
3242 if (HFA384x_USB_ISRXFRM(type
)) {
3243 if (action
== HANDLE
) {
3244 if (usbin
->txfrm
.desc
.sw_support
== 0x0123) {
3245 hfa384x_usbin_txcompl(wlandev
, usbin
);
3247 skb_put(skb
, sizeof(*usbin
));
3248 hfa384x_usbin_rx(wlandev
, skb
);
3254 if (HFA384x_USB_ISTXFRM(type
)) {
3255 if (action
== HANDLE
)
3256 hfa384x_usbin_txcompl(wlandev
, usbin
);
3260 case HFA384x_USB_INFOFRM
:
3261 if (action
== ABORT
)
3263 if (action
== HANDLE
)
3264 hfa384x_usbin_info(wlandev
, usbin
);
3267 case HFA384x_USB_CMDRESP
:
3268 case HFA384x_USB_WRIDRESP
:
3269 case HFA384x_USB_RRIDRESP
:
3270 case HFA384x_USB_WMEMRESP
:
3271 case HFA384x_USB_RMEMRESP
:
3272 /* ALWAYS, ALWAYS, ALWAYS handle this CTLX!!!! */
3273 hfa384x_usbin_ctlx(hw
, usbin
, urb_status
);
3276 case HFA384x_USB_BUFAVAIL
:
3277 pr_debug("Received BUFAVAIL packet, frmlen=%d\n",
3278 usbin
->bufavail
.frmlen
);
3281 case HFA384x_USB_ERROR
:
3282 pr_debug("Received USB_ERROR packet, errortype=%d\n",
3283 usbin
->usberror
.errortype
);
3287 pr_debug("Unrecognized USBIN packet, type=%x, status=%d\n",
3288 usbin
->type
, urb_status
);
3298 /*----------------------------------------------------------------
3299 * hfa384x_usbin_ctlx
3301 * We've received a URB containing a Prism2 "response" message.
3302 * This message needs to be matched up with a CTLX on the active
3303 * queue and our state updated accordingly.
3306 * hw ptr to hfa384x_t
3307 * usbin ptr to USB IN packet
3308 * urb_status status of this Bulk-In URB
3317 ----------------------------------------------------------------*/
3318 static void hfa384x_usbin_ctlx(hfa384x_t
*hw
, hfa384x_usbin_t
*usbin
,
3321 hfa384x_usbctlx_t
*ctlx
;
3323 unsigned long flags
;
3326 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3328 /* There can be only one CTLX on the active queue
3329 * at any one time, and this is the CTLX that the
3330 * timers are waiting for.
3332 if (list_empty(&hw
->ctlxq
.active
))
3335 /* Remove the "response timeout". It's possible that
3336 * we are already too late, and that the timeout is
3337 * already running. And that's just too bad for us,
3338 * because we could lose our CTLX from the active
3341 if (del_timer(&hw
->resptimer
) == 0) {
3342 if (hw
->resp_timer_done
== 0) {
3343 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3347 hw
->resp_timer_done
= 1;
3350 ctlx
= get_active_ctlx(hw
);
3352 if (urb_status
!= 0) {
3354 * Bad CTLX, so get rid of it. But we only
3355 * remove it from the active queue if we're no
3356 * longer expecting the OUT URB to complete.
3358 if (unlocked_usbctlx_cancel_async(hw
, ctlx
) == 0)
3361 const u16 intype
= (usbin
->type
& ~cpu_to_le16(0x8000));
3364 * Check that our message is what we're expecting ...
3366 if (ctlx
->outbuf
.type
!= intype
) {
3368 "Expected IN[%d], received IN[%d] - ignored.\n",
3369 le16_to_cpu(ctlx
->outbuf
.type
),
3370 le16_to_cpu(intype
));
3374 /* This URB has succeeded, so grab the data ... */
3375 memcpy(&ctlx
->inbuf
, usbin
, sizeof(ctlx
->inbuf
));
3377 switch (ctlx
->state
) {
3378 case CTLX_REQ_SUBMITTED
:
3380 * We have received our response URB before
3381 * our request has been acknowledged. Odd,
3382 * but our OUT URB is still alive...
3385 ("Causality violation: please reboot Universe, or email linux-wlan-devel@lists.linux-wlan.com\n");
3386 ctlx
->state
= CTLX_RESP_COMPLETE
;
3389 case CTLX_REQ_COMPLETE
:
3391 * This is the usual path: our request
3392 * has already been acknowledged, and
3393 * now we have received the reply too.
3395 ctlx
->state
= CTLX_COMPLETE
;
3396 unlocked_usbctlx_complete(hw
, ctlx
);
3402 * Throw this CTLX away ...
3405 "Matched IN URB, CTLX[%d] in invalid state(%s)."
3407 le16_to_cpu(ctlx
->outbuf
.type
),
3408 ctlxstr(ctlx
->state
));
3409 if (unlocked_usbctlx_cancel_async(hw
, ctlx
) == 0)
3416 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3419 hfa384x_usbctlxq_run(hw
);
3422 /*----------------------------------------------------------------
3423 * hfa384x_usbin_txcompl
3425 * At this point we have the results of a previous transmit.
3428 * wlandev wlan device
3429 * usbin ptr to the usb transfer buffer
3438 ----------------------------------------------------------------*/
3439 static void hfa384x_usbin_txcompl(wlandevice_t
*wlandev
,
3440 hfa384x_usbin_t
*usbin
)
3444 status
= le16_to_cpu(usbin
->type
); /* yeah I know it says type... */
3446 /* Was there an error? */
3447 if (HFA384x_TXSTATUS_ISERROR(status
))
3448 prism2sta_ev_txexc(wlandev
, status
);
3450 prism2sta_ev_tx(wlandev
, status
);
3453 /*----------------------------------------------------------------
3456 * At this point we have a successful received a rx frame packet.
3459 * wlandev wlan device
3460 * usbin ptr to the usb transfer buffer
3469 ----------------------------------------------------------------*/
3470 static void hfa384x_usbin_rx(wlandevice_t
*wlandev
, struct sk_buff
*skb
)
3472 hfa384x_usbin_t
*usbin
= (hfa384x_usbin_t
*) skb
->data
;
3473 hfa384x_t
*hw
= wlandev
->priv
;
3475 p80211_rxmeta_t
*rxmeta
;
3479 /* Byte order convert once up front. */
3480 usbin
->rxfrm
.desc
.status
= le16_to_cpu(usbin
->rxfrm
.desc
.status
);
3481 usbin
->rxfrm
.desc
.time
= le32_to_cpu(usbin
->rxfrm
.desc
.time
);
3483 /* Now handle frame based on port# */
3484 switch (HFA384x_RXSTATUS_MACPORT_GET(usbin
->rxfrm
.desc
.status
)) {
3486 fc
= le16_to_cpu(usbin
->rxfrm
.desc
.frame_control
);
3488 /* If exclude and we receive an unencrypted, drop it */
3489 if ((wlandev
->hostwep
& HOSTWEP_EXCLUDEUNENCRYPTED
) &&
3490 !WLAN_GET_FC_ISWEP(fc
)) {
3494 data_len
= le16_to_cpu(usbin
->rxfrm
.desc
.data_len
);
3496 /* How much header data do we have? */
3497 hdrlen
= p80211_headerlen(fc
);
3499 /* Pull off the descriptor */
3500 skb_pull(skb
, sizeof(hfa384x_rx_frame_t
));
3502 /* Now shunt the header block up against the data block
3503 * with an "overlapping" copy
3505 memmove(skb_push(skb
, hdrlen
),
3506 &usbin
->rxfrm
.desc
.frame_control
, hdrlen
);
3508 skb
->dev
= wlandev
->netdev
;
3509 skb
->dev
->last_rx
= jiffies
;
3511 /* And set the frame length properly */
3512 skb_trim(skb
, data_len
+ hdrlen
);
3514 /* The prism2 series does not return the CRC */
3515 memset(skb_put(skb
, WLAN_CRC_LEN
), 0xff, WLAN_CRC_LEN
);
3517 skb_reset_mac_header(skb
);
3519 /* Attach the rxmeta, set some stuff */
3520 p80211skb_rxmeta_attach(wlandev
, skb
);
3521 rxmeta
= P80211SKB_RXMETA(skb
);
3522 rxmeta
->mactime
= usbin
->rxfrm
.desc
.time
;
3523 rxmeta
->rxrate
= usbin
->rxfrm
.desc
.rate
;
3524 rxmeta
->signal
= usbin
->rxfrm
.desc
.signal
- hw
->dbmadjust
;
3525 rxmeta
->noise
= usbin
->rxfrm
.desc
.silence
- hw
->dbmadjust
;
3527 prism2sta_ev_rx(wlandev
, skb
);
3532 if (!HFA384x_RXSTATUS_ISFCSERR(usbin
->rxfrm
.desc
.status
)) {
3533 /* Copy to wlansnif skb */
3534 hfa384x_int_rxmonitor(wlandev
, &usbin
->rxfrm
);
3537 pr_debug("Received monitor frame: FCSerr set\n");
3542 printk(KERN_WARNING
"Received frame on unsupported port=%d\n",
3543 HFA384x_RXSTATUS_MACPORT_GET(usbin
->rxfrm
.desc
.status
));
3552 /*----------------------------------------------------------------
3553 * hfa384x_int_rxmonitor
3555 * Helper function for int_rx. Handles monitor frames.
3556 * Note that this function allocates space for the FCS and sets it
3557 * to 0xffffffff. The hfa384x doesn't give us the FCS value but the
3558 * higher layers expect it. 0xffffffff is used as a flag to indicate
3562 * wlandev wlan device structure
3563 * rxfrm rx descriptor read from card in int_rx
3569 * Allocates an skb and passes it up via the PF_PACKET interface.
3572 ----------------------------------------------------------------*/
3573 static void hfa384x_int_rxmonitor(wlandevice_t
*wlandev
,
3574 hfa384x_usb_rxfrm_t
*rxfrm
)
3576 hfa384x_rx_frame_t
*rxdesc
= &(rxfrm
->desc
);
3577 unsigned int hdrlen
= 0;
3578 unsigned int datalen
= 0;
3579 unsigned int skblen
= 0;
3582 struct sk_buff
*skb
;
3583 hfa384x_t
*hw
= wlandev
->priv
;
3585 /* Don't forget the status, time, and data_len fields are in host order */
3586 /* Figure out how big the frame is */
3587 fc
= le16_to_cpu(rxdesc
->frame_control
);
3588 hdrlen
= p80211_headerlen(fc
);
3589 datalen
= le16_to_cpu(rxdesc
->data_len
);
3591 /* Allocate an ind message+framesize skb */
3592 skblen
= sizeof(p80211_caphdr_t
) + hdrlen
+ datalen
+ WLAN_CRC_LEN
;
3594 /* sanity check the length */
3596 (sizeof(p80211_caphdr_t
) +
3597 WLAN_HDR_A4_LEN
+ WLAN_DATA_MAXLEN
+ WLAN_CRC_LEN
)) {
3598 pr_debug("overlen frm: len=%zd\n",
3599 skblen
- sizeof(p80211_caphdr_t
));
3602 if ((skb
= dev_alloc_skb(skblen
)) == NULL
) {
3604 "alloc_skb failed trying to allocate %d bytes\n",
3609 /* only prepend the prism header if in the right mode */
3610 if ((wlandev
->netdev
->type
== ARPHRD_IEEE80211_PRISM
) &&
3611 (hw
->sniffhdr
!= 0)) {
3612 p80211_caphdr_t
*caphdr
;
3613 /* The NEW header format! */
3614 datap
= skb_put(skb
, sizeof(p80211_caphdr_t
));
3615 caphdr
= (p80211_caphdr_t
*) datap
;
3617 caphdr
->version
= htonl(P80211CAPTURE_VERSION
);
3618 caphdr
->length
= htonl(sizeof(p80211_caphdr_t
));
3619 caphdr
->mactime
= __cpu_to_be64(rxdesc
->time
) * 1000;
3620 caphdr
->hosttime
= __cpu_to_be64(jiffies
);
3621 caphdr
->phytype
= htonl(4); /* dss_dot11_b */
3622 caphdr
->channel
= htonl(hw
->sniff_channel
);
3623 caphdr
->datarate
= htonl(rxdesc
->rate
);
3624 caphdr
->antenna
= htonl(0); /* unknown */
3625 caphdr
->priority
= htonl(0); /* unknown */
3626 caphdr
->ssi_type
= htonl(3); /* rssi_raw */
3627 caphdr
->ssi_signal
= htonl(rxdesc
->signal
);
3628 caphdr
->ssi_noise
= htonl(rxdesc
->silence
);
3629 caphdr
->preamble
= htonl(0); /* unknown */
3630 caphdr
->encoding
= htonl(1); /* cck */
3633 /* Copy the 802.11 header to the skb (ctl frames may be less than a full header) */
3634 datap
= skb_put(skb
, hdrlen
);
3635 memcpy(datap
, &(rxdesc
->frame_control
), hdrlen
);
3637 /* If any, copy the data from the card to the skb */
3639 datap
= skb_put(skb
, datalen
);
3640 memcpy(datap
, rxfrm
->data
, datalen
);
3642 /* check for unencrypted stuff if WEP bit set. */
3643 if (*(datap
- hdrlen
+ 1) & 0x40) /* wep set */
3644 if ((*(datap
) == 0xaa) && (*(datap
+ 1) == 0xaa))
3645 *(datap
- hdrlen
+ 1) &= 0xbf; // clear wep; it's the 802.2 header!
3648 if (hw
->sniff_fcs
) {
3650 datap
= skb_put(skb
, WLAN_CRC_LEN
);
3651 memset(datap
, 0xff, WLAN_CRC_LEN
);
3654 /* pass it back up */
3655 prism2sta_ev_rx(wlandev
, skb
);
3660 /*----------------------------------------------------------------
3661 * hfa384x_usbin_info
3663 * At this point we have a successful received a Prism2 info frame.
3666 * wlandev wlan device
3667 * usbin ptr to the usb transfer buffer
3676 ----------------------------------------------------------------*/
3677 static void hfa384x_usbin_info(wlandevice_t
*wlandev
, hfa384x_usbin_t
*usbin
)
3679 usbin
->infofrm
.info
.framelen
=
3680 le16_to_cpu(usbin
->infofrm
.info
.framelen
);
3681 prism2sta_ev_info(wlandev
, &usbin
->infofrm
.info
);
3684 /*----------------------------------------------------------------
3685 * hfa384x_usbout_callback
3687 * Callback for URBs on the BULKOUT endpoint.
3690 * urb ptr to the completed urb
3699 ----------------------------------------------------------------*/
3700 static void hfa384x_usbout_callback(struct urb
*urb
)
3702 wlandevice_t
*wlandev
= urb
->context
;
3703 hfa384x_usbout_t
*usbout
= urb
->transfer_buffer
;
3709 if (wlandev
&& wlandev
->netdev
) {
3711 switch (urb
->status
) {
3713 hfa384x_usbout_tx(wlandev
, usbout
);
3718 hfa384x_t
*hw
= wlandev
->priv
;
3720 "%s tx pipe stalled: requesting reset\n",
3721 wlandev
->netdev
->name
);
3722 if (!test_and_set_bit
3723 (WORK_TX_HALT
, &hw
->usb_flags
))
3724 schedule_work(&hw
->usb_work
);
3725 ++(wlandev
->linux_stats
.tx_errors
);
3733 hfa384x_t
*hw
= wlandev
->priv
;
3735 if (!test_and_set_bit
3736 (THROTTLE_TX
, &hw
->usb_flags
)
3737 && !timer_pending(&hw
->throttle
)) {
3738 mod_timer(&hw
->throttle
,
3739 jiffies
+ THROTTLE_JIFFIES
);
3741 ++(wlandev
->linux_stats
.tx_errors
);
3742 netif_stop_queue(wlandev
->netdev
);
3748 /* Ignorable errors */
3752 printk(KERN_INFO
"unknown urb->status=%d\n",
3754 ++(wlandev
->linux_stats
.tx_errors
);
3760 /*----------------------------------------------------------------
3761 * hfa384x_ctlxout_callback
3763 * Callback for control data on the BULKOUT endpoint.
3766 * urb ptr to the completed urb
3775 ----------------------------------------------------------------*/
3776 static void hfa384x_ctlxout_callback(struct urb
*urb
)
3778 hfa384x_t
*hw
= urb
->context
;
3779 int delete_resptimer
= 0;
3782 hfa384x_usbctlx_t
*ctlx
;
3783 unsigned long flags
;
3785 pr_debug("urb->status=%d\n", urb
->status
);
3789 if ((urb
->status
== -ESHUTDOWN
) ||
3790 (urb
->status
== -ENODEV
) || (hw
== NULL
))
3794 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3797 * Only one CTLX at a time on the "active" list, and
3798 * none at all if we are unplugged. However, we can
3799 * rely on the disconnect function to clean everything
3800 * up if someone unplugged the adapter.
3802 if (list_empty(&hw
->ctlxq
.active
)) {
3803 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3808 * Having something on the "active" queue means
3809 * that we have timers to worry about ...
3811 if (del_timer(&hw
->reqtimer
) == 0) {
3812 if (hw
->req_timer_done
== 0) {
3814 * This timer was actually running while we
3815 * were trying to delete it. Let it terminate
3816 * gracefully instead.
3818 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3822 hw
->req_timer_done
= 1;
3825 ctlx
= get_active_ctlx(hw
);
3827 if (urb
->status
== 0) {
3828 /* Request portion of a CTLX is successful */
3829 switch (ctlx
->state
) {
3830 case CTLX_REQ_SUBMITTED
:
3831 /* This OUT-ACK received before IN */
3832 ctlx
->state
= CTLX_REQ_COMPLETE
;
3835 case CTLX_RESP_COMPLETE
:
3836 /* IN already received before this OUT-ACK,
3837 * so this command must now be complete.
3839 ctlx
->state
= CTLX_COMPLETE
;
3840 unlocked_usbctlx_complete(hw
, ctlx
);
3845 /* This is NOT a valid CTLX "success" state! */
3847 "Illegal CTLX[%d] success state(%s, %d) in OUT URB\n",
3848 le16_to_cpu(ctlx
->outbuf
.type
),
3849 ctlxstr(ctlx
->state
), urb
->status
);
3853 /* If the pipe has stalled then we need to reset it */
3854 if ((urb
->status
== -EPIPE
) &&
3855 !test_and_set_bit(WORK_TX_HALT
, &hw
->usb_flags
)) {
3857 "%s tx pipe stalled: requesting reset\n",
3858 hw
->wlandev
->netdev
->name
);
3859 schedule_work(&hw
->usb_work
);
3862 /* If someone cancels the OUT URB then its status
3863 * should be either -ECONNRESET or -ENOENT.
3865 ctlx
->state
= CTLX_REQ_FAILED
;
3866 unlocked_usbctlx_complete(hw
, ctlx
);
3867 delete_resptimer
= 1;
3872 if (delete_resptimer
) {
3873 if ((timer_ok
= del_timer(&hw
->resptimer
)) != 0) {
3874 hw
->resp_timer_done
= 1;
3878 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3880 if (!timer_ok
&& (hw
->resp_timer_done
== 0)) {
3881 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3886 hfa384x_usbctlxq_run(hw
);
3892 /*----------------------------------------------------------------
3893 * hfa384x_usbctlx_reqtimerfn
3895 * Timer response function for CTLX request timeouts. If this
3896 * function is called, it means that the callback for the OUT
3897 * URB containing a Prism2.x XXX_Request was never called.
3900 * data a ptr to the hfa384x_t
3909 ----------------------------------------------------------------*/
3910 static void hfa384x_usbctlx_reqtimerfn(unsigned long data
)
3912 hfa384x_t
*hw
= (hfa384x_t
*) data
;
3913 unsigned long flags
;
3915 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3917 hw
->req_timer_done
= 1;
3919 /* Removing the hardware automatically empties
3920 * the active list ...
3922 if (!list_empty(&hw
->ctlxq
.active
)) {
3924 * We must ensure that our URB is removed from
3925 * the system, if it hasn't already expired.
3927 hw
->ctlx_urb
.transfer_flags
|= URB_ASYNC_UNLINK
;
3928 if (usb_unlink_urb(&hw
->ctlx_urb
) == -EINPROGRESS
) {
3929 hfa384x_usbctlx_t
*ctlx
= get_active_ctlx(hw
);
3931 ctlx
->state
= CTLX_REQ_FAILED
;
3933 /* This URB was active, but has now been
3934 * cancelled. It will now have a status of
3935 * -ECONNRESET in the callback function.
3937 * We are cancelling this CTLX, so we're
3938 * not going to need to wait for a response.
3939 * The URB's callback function will check
3940 * that this timer is truly dead.
3942 if (del_timer(&hw
->resptimer
) != 0)
3943 hw
->resp_timer_done
= 1;
3947 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3950 /*----------------------------------------------------------------
3951 * hfa384x_usbctlx_resptimerfn
3953 * Timer response function for CTLX response timeouts. If this
3954 * function is called, it means that the callback for the IN
3955 * URB containing a Prism2.x XXX_Response was never called.
3958 * data a ptr to the hfa384x_t
3967 ----------------------------------------------------------------*/
3968 static void hfa384x_usbctlx_resptimerfn(unsigned long data
)
3970 hfa384x_t
*hw
= (hfa384x_t
*) data
;
3971 unsigned long flags
;
3973 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3975 hw
->resp_timer_done
= 1;
3977 /* The active list will be empty if the
3978 * adapter has been unplugged ...
3980 if (!list_empty(&hw
->ctlxq
.active
)) {
3981 hfa384x_usbctlx_t
*ctlx
= get_active_ctlx(hw
);
3983 if (unlocked_usbctlx_cancel_async(hw
, ctlx
) == 0) {
3984 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3985 hfa384x_usbctlxq_run(hw
);
3990 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3997 /*----------------------------------------------------------------
3998 * hfa384x_usb_throttlefn
4011 ----------------------------------------------------------------*/
4012 static void hfa384x_usb_throttlefn(unsigned long data
)
4014 hfa384x_t
*hw
= (hfa384x_t
*) data
;
4015 unsigned long flags
;
4017 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
4020 * We need to check BOTH the RX and the TX throttle controls,
4021 * so we use the bitwise OR instead of the logical OR.
4023 pr_debug("flags=0x%lx\n", hw
->usb_flags
);
4024 if (!hw
->wlandev
->hwremoved
&&
4025 ((test_and_clear_bit(THROTTLE_RX
, &hw
->usb_flags
) &&
4026 !test_and_set_bit(WORK_RX_RESUME
, &hw
->usb_flags
))
4028 (test_and_clear_bit(THROTTLE_TX
, &hw
->usb_flags
) &&
4029 !test_and_set_bit(WORK_TX_RESUME
, &hw
->usb_flags
))
4031 schedule_work(&hw
->usb_work
);
4034 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
4037 /*----------------------------------------------------------------
4038 * hfa384x_usbctlx_submit
4040 * Called from the doxxx functions to submit a CTLX to the queue
4043 * hw ptr to the hw struct
4044 * ctlx ctlx structure to enqueue
4047 * -ENODEV if the adapter is unplugged
4053 * process or interrupt
4054 ----------------------------------------------------------------*/
4055 static int hfa384x_usbctlx_submit(hfa384x_t
*hw
, hfa384x_usbctlx_t
*ctlx
)
4057 unsigned long flags
;
4060 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
4062 if (hw
->wlandev
->hwremoved
) {
4063 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
4066 ctlx
->state
= CTLX_PENDING
;
4067 list_add_tail(&ctlx
->list
, &hw
->ctlxq
.pending
);
4069 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
4070 hfa384x_usbctlxq_run(hw
);
4077 /*----------------------------------------------------------------
4080 * At this point we have finished a send of a frame. Mark the URB
4081 * as available and call ev_alloc to notify higher layers we're
4085 * wlandev wlan device
4086 * usbout ptr to the usb transfer buffer
4095 ----------------------------------------------------------------*/
4096 static void hfa384x_usbout_tx(wlandevice_t
*wlandev
, hfa384x_usbout_t
*usbout
)
4098 prism2sta_ev_alloc(wlandev
);
4101 /*----------------------------------------------------------------
4102 * hfa384x_isgood_pdrcore
4104 * Quick check of PDR codes.
4107 * pdrcode PDR code number (host order)
4116 ----------------------------------------------------------------*/
4117 static int hfa384x_isgood_pdrcode(u16 pdrcode
)
4120 case HFA384x_PDR_END_OF_PDA
:
4121 case HFA384x_PDR_PCB_PARTNUM
:
4122 case HFA384x_PDR_PDAVER
:
4123 case HFA384x_PDR_NIC_SERIAL
:
4124 case HFA384x_PDR_MKK_MEASUREMENTS
:
4125 case HFA384x_PDR_NIC_RAMSIZE
:
4126 case HFA384x_PDR_MFISUPRANGE
:
4127 case HFA384x_PDR_CFISUPRANGE
:
4128 case HFA384x_PDR_NICID
:
4129 case HFA384x_PDR_MAC_ADDRESS
:
4130 case HFA384x_PDR_REGDOMAIN
:
4131 case HFA384x_PDR_ALLOWED_CHANNEL
:
4132 case HFA384x_PDR_DEFAULT_CHANNEL
:
4133 case HFA384x_PDR_TEMPTYPE
:
4134 case HFA384x_PDR_IFR_SETTING
:
4135 case HFA384x_PDR_RFR_SETTING
:
4136 case HFA384x_PDR_HFA3861_BASELINE
:
4137 case HFA384x_PDR_HFA3861_SHADOW
:
4138 case HFA384x_PDR_HFA3861_IFRF
:
4139 case HFA384x_PDR_HFA3861_CHCALSP
:
4140 case HFA384x_PDR_HFA3861_CHCALI
:
4141 case HFA384x_PDR_3842_NIC_CONFIG
:
4142 case HFA384x_PDR_USB_ID
:
4143 case HFA384x_PDR_PCI_ID
:
4144 case HFA384x_PDR_PCI_IFCONF
:
4145 case HFA384x_PDR_PCI_PMCONF
:
4146 case HFA384x_PDR_RFENRGY
:
4147 case HFA384x_PDR_HFA3861_MANF_TESTSP
:
4148 case HFA384x_PDR_HFA3861_MANF_TESTI
:
4153 if (pdrcode
< 0x1000) {
4154 /* code is OK, but we don't know exactly what it is */
4155 pr_debug("Encountered unknown PDR#=0x%04x, "
4156 "assuming it's ok.\n", pdrcode
);
4160 pr_debug("Encountered unknown PDR#=0x%04x, "
4161 "(>=0x1000), assuming it's bad.\n", pdrcode
);
4166 return 0; /* avoid compiler warnings */