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 invocations 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>
121 #include <linux/io.h>
122 #include <linux/delay.h>
123 #include <asm/byteorder.h>
124 #include <linux/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"
148 #define THROTTLE_JIFFIES (HZ/8)
149 #define URB_ASYNC_UNLINK 0
150 #define USB_QUEUE_BULK 0
152 #define ROUNDUP64(a) (((a)+63)&~63)
155 static void dbprint_urb(struct urb
*urb
);
159 hfa384x_int_rxmonitor(wlandevice_t
*wlandev
, hfa384x_usb_rxfrm_t
*rxfrm
);
161 static void hfa384x_usb_defer(struct work_struct
*data
);
163 static int submit_rx_urb(hfa384x_t
*hw
, gfp_t flags
);
165 static int submit_tx_urb(hfa384x_t
*hw
, struct urb
*tx_urb
, gfp_t flags
);
167 /*---------------------------------------------------*/
169 static void hfa384x_usbout_callback(struct urb
*urb
);
170 static void hfa384x_ctlxout_callback(struct urb
*urb
);
171 static void hfa384x_usbin_callback(struct urb
*urb
);
174 hfa384x_usbin_txcompl(wlandevice_t
*wlandev
, hfa384x_usbin_t
* usbin
);
176 static void hfa384x_usbin_rx(wlandevice_t
*wlandev
, struct sk_buff
*skb
);
178 static void hfa384x_usbin_info(wlandevice_t
*wlandev
, hfa384x_usbin_t
* usbin
);
181 hfa384x_usbout_tx(wlandevice_t
*wlandev
, hfa384x_usbout_t
*usbout
);
183 static void hfa384x_usbin_ctlx(hfa384x_t
*hw
, hfa384x_usbin_t
*usbin
,
186 /*---------------------------------------------------*/
187 /* Functions to support the prism2 usb command queue */
189 static void hfa384x_usbctlxq_run(hfa384x_t
*hw
);
191 static void hfa384x_usbctlx_reqtimerfn(unsigned long data
);
193 static void hfa384x_usbctlx_resptimerfn(unsigned long data
);
195 static void hfa384x_usb_throttlefn(unsigned long data
);
197 static void hfa384x_usbctlx_completion_task(unsigned long data
);
199 static void hfa384x_usbctlx_reaper_task(unsigned long data
);
201 static int hfa384x_usbctlx_submit(hfa384x_t
*hw
, hfa384x_usbctlx_t
*ctlx
);
203 static void unlocked_usbctlx_complete(hfa384x_t
*hw
, hfa384x_usbctlx_t
*ctlx
);
205 struct usbctlx_completor
{
206 int (*complete
) (struct usbctlx_completor
*);
210 hfa384x_usbctlx_complete_sync(hfa384x_t
*hw
,
211 hfa384x_usbctlx_t
*ctlx
,
212 struct usbctlx_completor
*completor
);
215 unlocked_usbctlx_cancel_async(hfa384x_t
*hw
, hfa384x_usbctlx_t
*ctlx
);
217 static void hfa384x_cb_status(hfa384x_t
*hw
, const hfa384x_usbctlx_t
*ctlx
);
219 static void hfa384x_cb_rrid(hfa384x_t
*hw
, const hfa384x_usbctlx_t
*ctlx
);
222 usbctlx_get_status(const hfa384x_usb_cmdresp_t
*cmdresp
,
223 hfa384x_cmdresult_t
*result
);
226 usbctlx_get_rridresult(const hfa384x_usb_rridresp_t
*rridresp
,
227 hfa384x_rridresult_t
*result
);
229 /*---------------------------------------------------*/
230 /* Low level req/resp CTLX formatters and submitters */
232 hfa384x_docmd(hfa384x_t
*hw
,
234 hfa384x_metacmd_t
*cmd
,
235 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
238 hfa384x_dorrid(hfa384x_t
*hw
,
242 unsigned int riddatalen
,
243 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
246 hfa384x_dowrid(hfa384x_t
*hw
,
250 unsigned int riddatalen
,
251 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
254 hfa384x_dormem(hfa384x_t
*hw
,
260 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
263 hfa384x_dowmem(hfa384x_t
*hw
,
269 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
271 static int hfa384x_isgood_pdrcode(u16 pdrcode
);
273 static inline const char *ctlxstr(CTLX_STATE s
)
275 static const char *ctlx_str
[] = {
280 "Request packet submitted",
281 "Request packet completed",
282 "Response packet completed"
288 static inline hfa384x_usbctlx_t
*get_active_ctlx(hfa384x_t
* hw
)
290 return list_entry(hw
->ctlxq
.active
.next
, hfa384x_usbctlx_t
, list
);
294 void dbprint_urb(struct urb
*urb
)
296 pr_debug("urb->pipe=0x%08x\n", urb
->pipe
);
297 pr_debug("urb->status=0x%08x\n", urb
->status
);
298 pr_debug("urb->transfer_flags=0x%08x\n", urb
->transfer_flags
);
299 pr_debug("urb->transfer_buffer=0x%08x\n",
300 (unsigned int)urb
->transfer_buffer
);
301 pr_debug("urb->transfer_buffer_length=0x%08x\n",
302 urb
->transfer_buffer_length
);
303 pr_debug("urb->actual_length=0x%08x\n", urb
->actual_length
);
304 pr_debug("urb->bandwidth=0x%08x\n", urb
->bandwidth
);
305 pr_debug("urb->setup_packet(ctl)=0x%08x\n",
306 (unsigned int)urb
->setup_packet
);
307 pr_debug("urb->start_frame(iso/irq)=0x%08x\n", urb
->start_frame
);
308 pr_debug("urb->interval(irq)=0x%08x\n", urb
->interval
);
309 pr_debug("urb->error_count(iso)=0x%08x\n", urb
->error_count
);
310 pr_debug("urb->timeout=0x%08x\n", urb
->timeout
);
311 pr_debug("urb->context=0x%08x\n", (unsigned int)urb
->context
);
312 pr_debug("urb->complete=0x%08x\n", (unsigned int)urb
->complete
);
316 /*----------------------------------------------------------------
319 * Listen for input data on the BULK-IN pipe. If the pipe has
320 * stalled then schedule it to be reset.
324 * memflags memory allocation flags
327 * error code from submission
331 ----------------------------------------------------------------*/
332 static int submit_rx_urb(hfa384x_t
*hw
, gfp_t memflags
)
337 skb
= dev_alloc_skb(sizeof(hfa384x_usbin_t
));
343 /* Post the IN urb */
344 usb_fill_bulk_urb(&hw
->rx_urb
, hw
->usb
,
346 skb
->data
, sizeof(hfa384x_usbin_t
),
347 hfa384x_usbin_callback
, hw
->wlandev
);
349 hw
->rx_urb_skb
= skb
;
352 if (!hw
->wlandev
->hwremoved
&&
353 !test_bit(WORK_RX_HALT
, &hw
->usb_flags
)) {
354 result
= SUBMIT_URB(&hw
->rx_urb
, memflags
);
356 /* Check whether we need to reset the RX pipe */
357 if (result
== -EPIPE
) {
359 "%s rx pipe stalled: requesting reset\n",
360 hw
->wlandev
->netdev
->name
);
361 if (!test_and_set_bit(WORK_RX_HALT
, &hw
->usb_flags
))
362 schedule_work(&hw
->usb_work
);
366 /* Don't leak memory if anything should go wrong */
369 hw
->rx_urb_skb
= NULL
;
376 /*----------------------------------------------------------------
379 * Prepares and submits the URB of transmitted data. If the
380 * submission fails then it will schedule the output pipe to
385 * tx_urb URB of data for tranmission
386 * memflags memory allocation flags
389 * error code from submission
393 ----------------------------------------------------------------*/
394 static int submit_tx_urb(hfa384x_t
*hw
, struct urb
*tx_urb
, gfp_t memflags
)
396 struct net_device
*netdev
= hw
->wlandev
->netdev
;
400 if (netif_running(netdev
)) {
402 if (!hw
->wlandev
->hwremoved
403 && !test_bit(WORK_TX_HALT
, &hw
->usb_flags
)) {
404 result
= SUBMIT_URB(tx_urb
, memflags
);
406 /* Test whether we need to reset the TX pipe */
407 if (result
== -EPIPE
) {
409 "%s tx pipe stalled: requesting reset\n",
411 set_bit(WORK_TX_HALT
, &hw
->usb_flags
);
412 schedule_work(&hw
->usb_work
);
413 } else if (result
== 0) {
414 netif_stop_queue(netdev
);
422 /*----------------------------------------------------------------
425 * There are some things that the USB stack cannot do while
426 * in interrupt context, so we arrange this function to run
427 * in process context.
430 * hw device structure
436 * process (by design)
437 ----------------------------------------------------------------*/
438 static void hfa384x_usb_defer(struct work_struct
*data
)
440 hfa384x_t
*hw
= container_of(data
, struct hfa384x
, usb_work
);
441 struct net_device
*netdev
= hw
->wlandev
->netdev
;
443 /* Don't bother trying to reset anything if the plug
444 * has been pulled ...
446 if (hw
->wlandev
->hwremoved
)
449 /* Reception has stopped: try to reset the input pipe */
450 if (test_bit(WORK_RX_HALT
, &hw
->usb_flags
)) {
453 usb_kill_urb(&hw
->rx_urb
); /* Cannot be holding spinlock! */
455 ret
= usb_clear_halt(hw
->usb
, hw
->endp_in
);
458 "Failed to clear rx pipe for %s: err=%d\n",
461 printk(KERN_INFO
"%s rx pipe reset complete.\n",
463 clear_bit(WORK_RX_HALT
, &hw
->usb_flags
);
464 set_bit(WORK_RX_RESUME
, &hw
->usb_flags
);
468 /* Resume receiving data back from the device. */
469 if (test_bit(WORK_RX_RESUME
, &hw
->usb_flags
)) {
472 ret
= submit_rx_urb(hw
, GFP_KERNEL
);
475 "Failed to resume %s rx pipe.\n", netdev
->name
);
477 clear_bit(WORK_RX_RESUME
, &hw
->usb_flags
);
481 /* Transmission has stopped: try to reset the output pipe */
482 if (test_bit(WORK_TX_HALT
, &hw
->usb_flags
)) {
485 usb_kill_urb(&hw
->tx_urb
);
486 ret
= usb_clear_halt(hw
->usb
, hw
->endp_out
);
489 "Failed to clear tx pipe for %s: err=%d\n",
492 printk(KERN_INFO
"%s tx pipe reset complete.\n",
494 clear_bit(WORK_TX_HALT
, &hw
->usb_flags
);
495 set_bit(WORK_TX_RESUME
, &hw
->usb_flags
);
497 /* Stopping the BULK-OUT pipe also blocked
498 * us from sending any more CTLX URBs, so
499 * we need to re-run our queue ...
501 hfa384x_usbctlxq_run(hw
);
505 /* Resume transmitting. */
506 if (test_and_clear_bit(WORK_TX_RESUME
, &hw
->usb_flags
))
507 netif_wake_queue(hw
->wlandev
->netdev
);
510 /*----------------------------------------------------------------
513 * Sets up the hfa384x_t data structure for use. Note this
514 * does _not_ intialize the actual hardware, just the data structures
515 * we use to keep track of its state.
518 * hw device structure
519 * irq device irq number
520 * iobase i/o base address for register access
521 * membase memory base address for register access
530 ----------------------------------------------------------------*/
531 void hfa384x_create(hfa384x_t
*hw
, struct usb_device
*usb
)
533 memset(hw
, 0, sizeof(hfa384x_t
));
536 /* set up the endpoints */
537 hw
->endp_in
= usb_rcvbulkpipe(usb
, 1);
538 hw
->endp_out
= usb_sndbulkpipe(usb
, 2);
540 /* Set up the waitq */
541 init_waitqueue_head(&hw
->cmdq
);
543 /* Initialize the command queue */
544 spin_lock_init(&hw
->ctlxq
.lock
);
545 INIT_LIST_HEAD(&hw
->ctlxq
.pending
);
546 INIT_LIST_HEAD(&hw
->ctlxq
.active
);
547 INIT_LIST_HEAD(&hw
->ctlxq
.completing
);
548 INIT_LIST_HEAD(&hw
->ctlxq
.reapable
);
550 /* Initialize the authentication queue */
551 skb_queue_head_init(&hw
->authq
);
553 tasklet_init(&hw
->reaper_bh
,
554 hfa384x_usbctlx_reaper_task
, (unsigned long)hw
);
555 tasklet_init(&hw
->completion_bh
,
556 hfa384x_usbctlx_completion_task
, (unsigned long)hw
);
557 INIT_WORK(&hw
->link_bh
, prism2sta_processing_defer
);
558 INIT_WORK(&hw
->usb_work
, hfa384x_usb_defer
);
560 init_timer(&hw
->throttle
);
561 hw
->throttle
.function
= hfa384x_usb_throttlefn
;
562 hw
->throttle
.data
= (unsigned long)hw
;
564 init_timer(&hw
->resptimer
);
565 hw
->resptimer
.function
= hfa384x_usbctlx_resptimerfn
;
566 hw
->resptimer
.data
= (unsigned long)hw
;
568 init_timer(&hw
->reqtimer
);
569 hw
->reqtimer
.function
= hfa384x_usbctlx_reqtimerfn
;
570 hw
->reqtimer
.data
= (unsigned long)hw
;
572 usb_init_urb(&hw
->rx_urb
);
573 usb_init_urb(&hw
->tx_urb
);
574 usb_init_urb(&hw
->ctlx_urb
);
576 hw
->link_status
= HFA384x_LINK_NOTCONNECTED
;
577 hw
->state
= HFA384x_STATE_INIT
;
579 INIT_WORK(&hw
->commsqual_bh
, prism2sta_commsqual_defer
);
580 init_timer(&hw
->commsqual_timer
);
581 hw
->commsqual_timer
.data
= (unsigned long)hw
;
582 hw
->commsqual_timer
.function
= prism2sta_commsqual_timer
;
585 /*----------------------------------------------------------------
588 * Partner to hfa384x_create(). This function cleans up the hw
589 * structure so that it can be freed by the caller using a simple
590 * kfree. Currently, this function is just a placeholder. If, at some
591 * point in the future, an hw in the 'shutdown' state requires a 'deep'
592 * kfree, this is where it should be done. Note that if this function
593 * is called on a _running_ hw structure, the drvr_stop() function is
597 * hw device structure
600 * nothing, this function is not allowed to fail.
606 ----------------------------------------------------------------*/
607 void hfa384x_destroy(hfa384x_t
*hw
)
611 if (hw
->state
== HFA384x_STATE_RUNNING
)
612 hfa384x_drvr_stop(hw
);
613 hw
->state
= HFA384x_STATE_PREINIT
;
615 if (hw
->scanresults
) {
616 kfree(hw
->scanresults
);
617 hw
->scanresults
= NULL
;
620 /* Now to clean out the auth queue */
621 while ((skb
= skb_dequeue(&hw
->authq
)))
625 static hfa384x_usbctlx_t
*usbctlx_alloc(void)
627 hfa384x_usbctlx_t
*ctlx
;
629 ctlx
= kmalloc(sizeof(*ctlx
), in_interrupt() ? GFP_ATOMIC
: GFP_KERNEL
);
631 memset(ctlx
, 0, sizeof(*ctlx
));
632 init_completion(&ctlx
->done
);
639 usbctlx_get_status(const hfa384x_usb_cmdresp_t
*cmdresp
,
640 hfa384x_cmdresult_t
*result
)
642 result
->status
= le16_to_cpu(cmdresp
->status
);
643 result
->resp0
= le16_to_cpu(cmdresp
->resp0
);
644 result
->resp1
= le16_to_cpu(cmdresp
->resp1
);
645 result
->resp2
= le16_to_cpu(cmdresp
->resp2
);
647 pr_debug("cmdresult:status=0x%04x "
648 "resp0=0x%04x resp1=0x%04x resp2=0x%04x\n",
649 result
->status
, result
->resp0
, result
->resp1
, result
->resp2
);
651 return result
->status
& HFA384x_STATUS_RESULT
;
655 usbctlx_get_rridresult(const hfa384x_usb_rridresp_t
*rridresp
,
656 hfa384x_rridresult_t
*result
)
658 result
->rid
= le16_to_cpu(rridresp
->rid
);
659 result
->riddata
= rridresp
->data
;
660 result
->riddata_len
= ((le16_to_cpu(rridresp
->frmlen
) - 1) * 2);
664 /*----------------------------------------------------------------
666 * This completor must be passed to hfa384x_usbctlx_complete_sync()
667 * when processing a CTLX that returns a hfa384x_cmdresult_t structure.
668 ----------------------------------------------------------------*/
669 struct usbctlx_cmd_completor
{
670 struct usbctlx_completor head
;
672 const hfa384x_usb_cmdresp_t
*cmdresp
;
673 hfa384x_cmdresult_t
*result
;
676 static inline int usbctlx_cmd_completor_fn(struct usbctlx_completor
*head
)
678 struct usbctlx_cmd_completor
*complete
;
680 complete
= (struct usbctlx_cmd_completor
*) head
;
681 return usbctlx_get_status(complete
->cmdresp
, complete
->result
);
684 static inline struct usbctlx_completor
*init_cmd_completor(
685 struct usbctlx_cmd_completor
687 const hfa384x_usb_cmdresp_t
689 hfa384x_cmdresult_t
*result
)
691 completor
->head
.complete
= usbctlx_cmd_completor_fn
;
692 completor
->cmdresp
= cmdresp
;
693 completor
->result
= result
;
694 return &(completor
->head
);
697 /*----------------------------------------------------------------
699 * This completor must be passed to hfa384x_usbctlx_complete_sync()
700 * when processing a CTLX that reads a RID.
701 ----------------------------------------------------------------*/
702 struct usbctlx_rrid_completor
{
703 struct usbctlx_completor head
;
705 const hfa384x_usb_rridresp_t
*rridresp
;
707 unsigned int riddatalen
;
710 static int usbctlx_rrid_completor_fn(struct usbctlx_completor
*head
)
712 struct usbctlx_rrid_completor
*complete
;
713 hfa384x_rridresult_t rridresult
;
715 complete
= (struct usbctlx_rrid_completor
*) head
;
716 usbctlx_get_rridresult(complete
->rridresp
, &rridresult
);
718 /* Validate the length, note body len calculation in bytes */
719 if (rridresult
.riddata_len
!= complete
->riddatalen
) {
721 "RID len mismatch, rid=0x%04x hlen=%d fwlen=%d\n",
723 complete
->riddatalen
, rridresult
.riddata_len
);
727 memcpy(complete
->riddata
, rridresult
.riddata
, complete
->riddatalen
);
731 static inline struct usbctlx_completor
*init_rrid_completor(
732 struct usbctlx_rrid_completor
734 const hfa384x_usb_rridresp_t
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 struct usbctlx_cmd_completor 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 struct usbctlx_cmd_completor 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 struct usbctlx_completor 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(struct usbctlx_completor
*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 struct usbctlx_completor
*init_rmem_completor(
783 usbctlx_rmem_completor_t
785 hfa384x_usb_rmemresp_t
790 completor
->head
.complete
= usbctlx_rmem_completor_fn
;
791 completor
->rmemresp
= rmemresp
;
792 completor
->data
= data
;
793 completor
->len
= len
;
794 return &(completor
->head
);
797 /*----------------------------------------------------------------
800 * Ctlx_complete handler for async CMD type control exchanges.
801 * mark the hw struct as such.
803 * Note: If the handling is changed here, it should probably be
804 * changed in docmd as well.
808 * ctlx completed CTLX
817 ----------------------------------------------------------------*/
818 static void hfa384x_cb_status(hfa384x_t
*hw
, const hfa384x_usbctlx_t
*ctlx
)
820 if (ctlx
->usercb
!= NULL
) {
821 hfa384x_cmdresult_t cmdresult
;
823 if (ctlx
->state
!= CTLX_COMPLETE
) {
824 memset(&cmdresult
, 0, sizeof(cmdresult
));
826 HFA384x_STATUS_RESULT_SET(HFA384x_CMD_ERR
);
828 usbctlx_get_status(&ctlx
->inbuf
.cmdresp
, &cmdresult
);
831 ctlx
->usercb(hw
, &cmdresult
, ctlx
->usercb_data
);
835 /*----------------------------------------------------------------
838 * CTLX completion handler for async RRID type control exchanges.
840 * Note: If the handling is changed here, it should probably be
841 * changed in dorrid as well.
845 * ctlx completed CTLX
854 ----------------------------------------------------------------*/
855 static void hfa384x_cb_rrid(hfa384x_t
*hw
, const hfa384x_usbctlx_t
*ctlx
)
857 if (ctlx
->usercb
!= NULL
) {
858 hfa384x_rridresult_t rridresult
;
860 if (ctlx
->state
!= CTLX_COMPLETE
) {
861 memset(&rridresult
, 0, sizeof(rridresult
));
862 rridresult
.rid
= le16_to_cpu(ctlx
->outbuf
.rridreq
.rid
);
864 usbctlx_get_rridresult(&ctlx
->inbuf
.rridresp
,
868 ctlx
->usercb(hw
, &rridresult
, ctlx
->usercb_data
);
872 static inline int hfa384x_docmd_wait(hfa384x_t
*hw
, hfa384x_metacmd_t
*cmd
)
874 return hfa384x_docmd(hw
, DOWAIT
, cmd
, NULL
, NULL
, NULL
);
878 hfa384x_docmd_async(hfa384x_t
*hw
,
879 hfa384x_metacmd_t
*cmd
,
880 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
882 return hfa384x_docmd(hw
, DOASYNC
, cmd
, cmdcb
, usercb
, usercb_data
);
886 hfa384x_dorrid_wait(hfa384x_t
*hw
, u16 rid
, void *riddata
,
887 unsigned int riddatalen
)
889 return hfa384x_dorrid(hw
, DOWAIT
,
890 rid
, riddata
, riddatalen
, NULL
, NULL
, NULL
);
894 hfa384x_dorrid_async(hfa384x_t
*hw
,
895 u16 rid
, void *riddata
, unsigned int riddatalen
,
897 ctlx_usercb_t usercb
, void *usercb_data
)
899 return hfa384x_dorrid(hw
, DOASYNC
,
900 rid
, riddata
, riddatalen
,
901 cmdcb
, usercb
, usercb_data
);
905 hfa384x_dowrid_wait(hfa384x_t
*hw
, u16 rid
, void *riddata
,
906 unsigned int riddatalen
)
908 return hfa384x_dowrid(hw
, DOWAIT
,
909 rid
, riddata
, riddatalen
, NULL
, NULL
, NULL
);
913 hfa384x_dowrid_async(hfa384x_t
*hw
,
914 u16 rid
, void *riddata
, unsigned int riddatalen
,
916 ctlx_usercb_t usercb
, void *usercb_data
)
918 return hfa384x_dowrid(hw
, DOASYNC
,
919 rid
, riddata
, riddatalen
,
920 cmdcb
, usercb
, usercb_data
);
924 hfa384x_dormem_wait(hfa384x_t
*hw
,
925 u16 page
, u16 offset
, void *data
, unsigned int len
)
927 return hfa384x_dormem(hw
, DOWAIT
,
928 page
, offset
, data
, len
, NULL
, NULL
, NULL
);
932 hfa384x_dormem_async(hfa384x_t
*hw
,
933 u16 page
, u16 offset
, void *data
, unsigned int len
,
935 ctlx_usercb_t usercb
, void *usercb_data
)
937 return hfa384x_dormem(hw
, DOASYNC
,
938 page
, offset
, data
, len
,
939 cmdcb
, usercb
, usercb_data
);
943 hfa384x_dowmem_wait(hfa384x_t
*hw
,
944 u16 page
, u16 offset
, void *data
, unsigned int len
)
946 return hfa384x_dowmem(hw
, DOWAIT
,
947 page
, offset
, data
, len
, NULL
, NULL
, NULL
);
951 hfa384x_dowmem_async(hfa384x_t
*hw
,
957 ctlx_usercb_t usercb
, void *usercb_data
)
959 return hfa384x_dowmem(hw
, DOASYNC
,
960 page
, offset
, data
, len
,
961 cmdcb
, usercb
, usercb_data
);
964 /*----------------------------------------------------------------
965 * hfa384x_cmd_initialize
967 * Issues the initialize command and sets the hw->state based
971 * hw device structure
975 * >0 f/w reported error - f/w status code
976 * <0 driver reported error
982 ----------------------------------------------------------------*/
983 int hfa384x_cmd_initialize(hfa384x_t
*hw
)
987 hfa384x_metacmd_t cmd
;
989 cmd
.cmd
= HFA384x_CMDCODE_INIT
;
994 result
= hfa384x_docmd_wait(hw
, &cmd
);
996 pr_debug("cmdresp.init: "
997 "status=0x%04x, resp0=0x%04x, "
998 "resp1=0x%04x, resp2=0x%04x\n",
1000 cmd
.result
.resp0
, cmd
.result
.resp1
, cmd
.result
.resp2
);
1002 for (i
= 0; i
< HFA384x_NUMPORTS_MAX
; i
++)
1003 hw
->port_enabled
[i
] = 0;
1006 hw
->link_status
= HFA384x_LINK_NOTCONNECTED
;
1011 /*----------------------------------------------------------------
1012 * hfa384x_cmd_disable
1014 * Issues the disable command to stop communications on one of
1018 * hw device structure
1019 * macport MAC port number (host order)
1023 * >0 f/w reported failure - f/w status code
1024 * <0 driver reported error (timeout|bad arg)
1030 ----------------------------------------------------------------*/
1031 int hfa384x_cmd_disable(hfa384x_t
*hw
, u16 macport
)
1034 hfa384x_metacmd_t cmd
;
1036 cmd
.cmd
= HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DISABLE
) |
1037 HFA384x_CMD_MACPORT_SET(macport
);
1042 result
= hfa384x_docmd_wait(hw
, &cmd
);
1047 /*----------------------------------------------------------------
1048 * hfa384x_cmd_enable
1050 * Issues the enable command to enable communications on one of
1054 * hw device structure
1055 * macport MAC port number
1059 * >0 f/w reported failure - f/w status code
1060 * <0 driver reported error (timeout|bad arg)
1066 ----------------------------------------------------------------*/
1067 int hfa384x_cmd_enable(hfa384x_t
*hw
, u16 macport
)
1070 hfa384x_metacmd_t cmd
;
1072 cmd
.cmd
= HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ENABLE
) |
1073 HFA384x_CMD_MACPORT_SET(macport
);
1078 result
= hfa384x_docmd_wait(hw
, &cmd
);
1083 /*----------------------------------------------------------------
1084 * hfa384x_cmd_monitor
1086 * Enables the 'monitor mode' of the MAC. Here's the description of
1087 * monitor mode that I've received thus far:
1089 * "The "monitor mode" of operation is that the MAC passes all
1090 * frames for which the PLCP checks are correct. All received
1091 * MPDUs are passed to the host with MAC Port = 7, with a
1092 * receive status of good, FCS error, or undecryptable. Passing
1093 * certain MPDUs is a violation of the 802.11 standard, but useful
1094 * for a debugging tool." Normal communication is not possible
1095 * while monitor mode is enabled.
1098 * hw device structure
1099 * enable a code (0x0b|0x0f) that enables/disables
1100 * monitor mode. (host order)
1104 * >0 f/w reported failure - f/w status code
1105 * <0 driver reported error (timeout|bad arg)
1111 ----------------------------------------------------------------*/
1112 int hfa384x_cmd_monitor(hfa384x_t
*hw
, u16 enable
)
1115 hfa384x_metacmd_t cmd
;
1117 cmd
.cmd
= HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR
) |
1118 HFA384x_CMD_AINFO_SET(enable
);
1123 result
= hfa384x_docmd_wait(hw
, &cmd
);
1128 /*----------------------------------------------------------------
1129 * hfa384x_cmd_download
1131 * Sets the controls for the MAC controller code/data download
1132 * process. The arguments set the mode and address associated
1133 * with a download. Note that the aux registers should be enabled
1134 * prior to setting one of the download enable modes.
1137 * hw device structure
1138 * mode 0 - Disable programming and begin code exec
1139 * 1 - Enable volatile mem programming
1140 * 2 - Enable non-volatile mem programming
1141 * 3 - Program non-volatile section from NV download
1145 * highaddr For mode 1, sets the high & low order bits of
1146 * the "destination address". This address will be
1147 * the execution start address when download is
1148 * subsequently disabled.
1149 * For mode 2, sets the high & low order bits of
1150 * the destination in NV ram.
1151 * For modes 0 & 3, should be zero. (host order)
1152 * NOTE: these are CMD format.
1153 * codelen Length of the data to write in mode 2,
1154 * zero otherwise. (host order)
1158 * >0 f/w reported failure - f/w status code
1159 * <0 driver reported error (timeout|bad arg)
1165 ----------------------------------------------------------------*/
1166 int hfa384x_cmd_download(hfa384x_t
*hw
, u16 mode
, u16 lowaddr
,
1167 u16 highaddr
, u16 codelen
)
1170 hfa384x_metacmd_t cmd
;
1172 pr_debug("mode=%d, lowaddr=0x%04x, highaddr=0x%04x, codelen=%d\n",
1173 mode
, lowaddr
, highaddr
, codelen
);
1175 cmd
.cmd
= (HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DOWNLD
) |
1176 HFA384x_CMD_PROGMODE_SET(mode
));
1178 cmd
.parm0
= lowaddr
;
1179 cmd
.parm1
= highaddr
;
1180 cmd
.parm2
= codelen
;
1182 result
= hfa384x_docmd_wait(hw
, &cmd
);
1187 /*----------------------------------------------------------------
1190 * Perform a reset of the hfa38xx MAC core. We assume that the hw
1191 * structure is in its "created" state. That is, it is initialized
1192 * with proper values. Note that if a reset is done after the
1193 * device has been active for awhile, the caller might have to clean
1194 * up some leftover cruft in the hw structure.
1197 * hw device structure
1198 * holdtime how long (in ms) to hold the reset
1199 * settletime how long (in ms) to wait after releasing
1209 ----------------------------------------------------------------*/
1210 int hfa384x_corereset(hfa384x_t
*hw
, int holdtime
, int settletime
, int genesis
)
1214 result
= usb_reset_device(hw
->usb
);
1216 printk(KERN_ERR
"usb_reset_device() failed, result=%d.\n",
1223 /*----------------------------------------------------------------
1224 * hfa384x_usbctlx_complete_sync
1226 * Waits for a synchronous CTLX object to complete,
1227 * and then handles the response.
1230 * hw device structure
1232 * completor functor object to decide what to
1233 * do with the CTLX's result.
1237 * -ERESTARTSYS Interrupted by a signal
1239 * -ENODEV Adapter was unplugged
1240 * ??? Result from completor
1246 ----------------------------------------------------------------*/
1247 static int hfa384x_usbctlx_complete_sync(hfa384x_t
*hw
,
1248 hfa384x_usbctlx_t
*ctlx
,
1249 struct usbctlx_completor
*completor
)
1251 unsigned long flags
;
1254 result
= wait_for_completion_interruptible(&ctlx
->done
);
1256 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
1259 * We can only handle the CTLX if the USB disconnect
1260 * function has not run yet ...
1263 if (hw
->wlandev
->hwremoved
) {
1264 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1266 } else if (result
!= 0) {
1270 * We were probably interrupted, so delete
1271 * this CTLX asynchronously, kill the timers
1272 * and the URB, and then start the next
1275 * NOTE: We can only delete the timers and
1276 * the URB if this CTLX is active.
1278 if (ctlx
== get_active_ctlx(hw
)) {
1279 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1281 del_singleshot_timer_sync(&hw
->reqtimer
);
1282 del_singleshot_timer_sync(&hw
->resptimer
);
1283 hw
->req_timer_done
= 1;
1284 hw
->resp_timer_done
= 1;
1285 usb_kill_urb(&hw
->ctlx_urb
);
1287 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
1292 * This scenario is so unlikely that I'm
1293 * happy with a grubby "goto" solution ...
1295 if (hw
->wlandev
->hwremoved
)
1300 * The completion task will send this CTLX
1301 * to the reaper the next time it runs. We
1302 * are no longer in a hurry.
1305 ctlx
->state
= CTLX_REQ_FAILED
;
1306 list_move_tail(&ctlx
->list
, &hw
->ctlxq
.completing
);
1308 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1311 hfa384x_usbctlxq_run(hw
);
1313 if (ctlx
->state
== CTLX_COMPLETE
) {
1314 result
= completor
->complete(completor
);
1316 printk(KERN_WARNING
"CTLX[%d] error: state(%s)\n",
1317 le16_to_cpu(ctlx
->outbuf
.type
),
1318 ctlxstr(ctlx
->state
));
1322 list_del(&ctlx
->list
);
1323 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1330 /*----------------------------------------------------------------
1333 * Constructs a command CTLX and submits it.
1335 * NOTE: Any changes to the 'post-submit' code in this function
1336 * need to be carried over to hfa384x_cbcmd() since the handling
1337 * is virtually identical.
1340 * hw device structure
1341 * mode DOWAIT or DOASYNC
1342 * cmd cmd structure. Includes all arguments and result
1343 * data points. All in host order. in host order
1344 * cmdcb command-specific callback
1345 * usercb user callback for async calls, NULL for DOWAIT calls
1346 * usercb_data user supplied data pointer for async calls, NULL
1352 * -ERESTARTSYS Awakened on signal
1353 * >0 command indicated error, Status and Resp0-2 are
1361 ----------------------------------------------------------------*/
1363 hfa384x_docmd(hfa384x_t
*hw
,
1365 hfa384x_metacmd_t
*cmd
,
1366 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1369 hfa384x_usbctlx_t
*ctlx
;
1371 ctlx
= usbctlx_alloc();
1377 /* Initialize the command */
1378 ctlx
->outbuf
.cmdreq
.type
= cpu_to_le16(HFA384x_USB_CMDREQ
);
1379 ctlx
->outbuf
.cmdreq
.cmd
= cpu_to_le16(cmd
->cmd
);
1380 ctlx
->outbuf
.cmdreq
.parm0
= cpu_to_le16(cmd
->parm0
);
1381 ctlx
->outbuf
.cmdreq
.parm1
= cpu_to_le16(cmd
->parm1
);
1382 ctlx
->outbuf
.cmdreq
.parm2
= cpu_to_le16(cmd
->parm2
);
1384 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.cmdreq
);
1386 pr_debug("cmdreq: cmd=0x%04x "
1387 "parm0=0x%04x parm1=0x%04x parm2=0x%04x\n",
1388 cmd
->cmd
, cmd
->parm0
, cmd
->parm1
, cmd
->parm2
);
1390 ctlx
->reapable
= mode
;
1391 ctlx
->cmdcb
= cmdcb
;
1392 ctlx
->usercb
= usercb
;
1393 ctlx
->usercb_data
= usercb_data
;
1395 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1398 } else if (mode
== DOWAIT
) {
1399 struct usbctlx_cmd_completor completor
;
1402 hfa384x_usbctlx_complete_sync(hw
, ctlx
,
1403 init_cmd_completor(&completor
,
1415 /*----------------------------------------------------------------
1418 * Constructs a read rid CTLX and issues it.
1420 * NOTE: Any changes to the 'post-submit' code in this function
1421 * need to be carried over to hfa384x_cbrrid() since the handling
1422 * is virtually identical.
1425 * hw device structure
1426 * mode DOWAIT or DOASYNC
1427 * rid Read RID number (host order)
1428 * riddata Caller supplied buffer that MAC formatted RID.data
1429 * record will be written to for DOWAIT calls. Should
1430 * be NULL for DOASYNC calls.
1431 * riddatalen Buffer length for DOWAIT calls. Zero for DOASYNC calls.
1432 * cmdcb command callback for async calls, NULL for DOWAIT calls
1433 * usercb user callback for async calls, NULL for DOWAIT calls
1434 * usercb_data user supplied data pointer for async calls, NULL
1440 * -ERESTARTSYS Awakened on signal
1441 * -ENODATA riddatalen != macdatalen
1442 * >0 command indicated error, Status and Resp0-2 are
1448 * interrupt (DOASYNC)
1449 * process (DOWAIT or DOASYNC)
1450 ----------------------------------------------------------------*/
1452 hfa384x_dorrid(hfa384x_t
*hw
,
1456 unsigned int riddatalen
,
1457 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1460 hfa384x_usbctlx_t
*ctlx
;
1462 ctlx
= usbctlx_alloc();
1468 /* Initialize the command */
1469 ctlx
->outbuf
.rridreq
.type
= cpu_to_le16(HFA384x_USB_RRIDREQ
);
1470 ctlx
->outbuf
.rridreq
.frmlen
=
1471 cpu_to_le16(sizeof(ctlx
->outbuf
.rridreq
.rid
));
1472 ctlx
->outbuf
.rridreq
.rid
= cpu_to_le16(rid
);
1474 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.rridreq
);
1476 ctlx
->reapable
= mode
;
1477 ctlx
->cmdcb
= cmdcb
;
1478 ctlx
->usercb
= usercb
;
1479 ctlx
->usercb_data
= usercb_data
;
1481 /* Submit the CTLX */
1482 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1485 } else if (mode
== DOWAIT
) {
1486 struct usbctlx_rrid_completor completor
;
1489 hfa384x_usbctlx_complete_sync(hw
, ctlx
,
1492 &ctlx
->inbuf
.rridresp
,
1493 riddata
, riddatalen
));
1500 /*----------------------------------------------------------------
1503 * Constructs a write rid CTLX and issues it.
1505 * NOTE: Any changes to the 'post-submit' code in this function
1506 * need to be carried over to hfa384x_cbwrid() since the handling
1507 * is virtually identical.
1510 * hw device structure
1511 * enum cmd_mode DOWAIT or DOASYNC
1513 * riddata Data portion of RID formatted for MAC
1514 * riddatalen Length of the data portion in bytes
1515 * cmdcb command callback for async calls, NULL for DOWAIT calls
1516 * usercb user callback for async calls, NULL for DOWAIT calls
1517 * usercb_data user supplied data pointer for async calls
1521 * -ETIMEDOUT timed out waiting for register ready or
1522 * command completion
1523 * >0 command indicated error, Status and Resp0-2 are
1529 * interrupt (DOASYNC)
1530 * process (DOWAIT or DOASYNC)
1531 ----------------------------------------------------------------*/
1533 hfa384x_dowrid(hfa384x_t
*hw
,
1537 unsigned int riddatalen
,
1538 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1541 hfa384x_usbctlx_t
*ctlx
;
1543 ctlx
= usbctlx_alloc();
1549 /* Initialize the command */
1550 ctlx
->outbuf
.wridreq
.type
= cpu_to_le16(HFA384x_USB_WRIDREQ
);
1551 ctlx
->outbuf
.wridreq
.frmlen
= cpu_to_le16((sizeof
1552 (ctlx
->outbuf
.wridreq
.rid
) +
1553 riddatalen
+ 1) / 2);
1554 ctlx
->outbuf
.wridreq
.rid
= cpu_to_le16(rid
);
1555 memcpy(ctlx
->outbuf
.wridreq
.data
, riddata
, riddatalen
);
1557 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.wridreq
.type
) +
1558 sizeof(ctlx
->outbuf
.wridreq
.frmlen
) +
1559 sizeof(ctlx
->outbuf
.wridreq
.rid
) + riddatalen
;
1561 ctlx
->reapable
= mode
;
1562 ctlx
->cmdcb
= cmdcb
;
1563 ctlx
->usercb
= usercb
;
1564 ctlx
->usercb_data
= usercb_data
;
1566 /* Submit the CTLX */
1567 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1570 } else if (mode
== DOWAIT
) {
1571 usbctlx_wrid_completor_t completor
;
1572 hfa384x_cmdresult_t wridresult
;
1574 result
= hfa384x_usbctlx_complete_sync(hw
,
1578 &ctlx
->inbuf
.wridresp
,
1586 /*----------------------------------------------------------------
1589 * Constructs a readmem CTLX and issues it.
1591 * NOTE: Any changes to the 'post-submit' code in this function
1592 * need to be carried over to hfa384x_cbrmem() since the handling
1593 * is virtually identical.
1596 * hw device structure
1597 * mode DOWAIT or DOASYNC
1598 * page MAC address space page (CMD format)
1599 * offset MAC address space offset
1600 * data Ptr to data buffer to receive read
1601 * len Length of the data to read (max == 2048)
1602 * cmdcb command callback for async calls, NULL for DOWAIT calls
1603 * usercb user callback for async calls, NULL for DOWAIT calls
1604 * usercb_data user supplied data pointer for async calls
1608 * -ETIMEDOUT timed out waiting for register ready or
1609 * command completion
1610 * >0 command indicated error, Status and Resp0-2 are
1616 * interrupt (DOASYNC)
1617 * process (DOWAIT or DOASYNC)
1618 ----------------------------------------------------------------*/
1620 hfa384x_dormem(hfa384x_t
*hw
,
1626 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1629 hfa384x_usbctlx_t
*ctlx
;
1631 ctlx
= usbctlx_alloc();
1637 /* Initialize the command */
1638 ctlx
->outbuf
.rmemreq
.type
= cpu_to_le16(HFA384x_USB_RMEMREQ
);
1639 ctlx
->outbuf
.rmemreq
.frmlen
=
1640 cpu_to_le16(sizeof(ctlx
->outbuf
.rmemreq
.offset
) +
1641 sizeof(ctlx
->outbuf
.rmemreq
.page
) + len
);
1642 ctlx
->outbuf
.rmemreq
.offset
= cpu_to_le16(offset
);
1643 ctlx
->outbuf
.rmemreq
.page
= cpu_to_le16(page
);
1645 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.rmemreq
);
1647 pr_debug("type=0x%04x frmlen=%d offset=0x%04x page=0x%04x\n",
1648 ctlx
->outbuf
.rmemreq
.type
,
1649 ctlx
->outbuf
.rmemreq
.frmlen
,
1650 ctlx
->outbuf
.rmemreq
.offset
, ctlx
->outbuf
.rmemreq
.page
);
1652 pr_debug("pktsize=%zd\n", ROUNDUP64(sizeof(ctlx
->outbuf
.rmemreq
)));
1654 ctlx
->reapable
= mode
;
1655 ctlx
->cmdcb
= cmdcb
;
1656 ctlx
->usercb
= usercb
;
1657 ctlx
->usercb_data
= usercb_data
;
1659 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1662 } else if (mode
== DOWAIT
) {
1663 usbctlx_rmem_completor_t completor
;
1666 hfa384x_usbctlx_complete_sync(hw
, ctlx
,
1669 &ctlx
->inbuf
.rmemresp
, data
,
1677 /*----------------------------------------------------------------
1680 * Constructs a writemem CTLX and issues it.
1682 * NOTE: Any changes to the 'post-submit' code in this function
1683 * need to be carried over to hfa384x_cbwmem() since the handling
1684 * is virtually identical.
1687 * hw device structure
1688 * mode DOWAIT or DOASYNC
1689 * page MAC address space page (CMD format)
1690 * offset MAC address space offset
1691 * data Ptr to data buffer containing write data
1692 * len Length of the data to read (max == 2048)
1693 * cmdcb command callback for async calls, NULL for DOWAIT calls
1694 * usercb user callback for async calls, NULL for DOWAIT calls
1695 * usercb_data user supplied data pointer for async calls.
1699 * -ETIMEDOUT timed out waiting for register ready or
1700 * command completion
1701 * >0 command indicated error, Status and Resp0-2 are
1707 * interrupt (DOWAIT)
1708 * process (DOWAIT or DOASYNC)
1709 ----------------------------------------------------------------*/
1711 hfa384x_dowmem(hfa384x_t
*hw
,
1717 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1720 hfa384x_usbctlx_t
*ctlx
;
1722 pr_debug("page=0x%04x offset=0x%04x len=%d\n", page
, offset
, len
);
1724 ctlx
= usbctlx_alloc();
1730 /* Initialize the command */
1731 ctlx
->outbuf
.wmemreq
.type
= cpu_to_le16(HFA384x_USB_WMEMREQ
);
1732 ctlx
->outbuf
.wmemreq
.frmlen
=
1733 cpu_to_le16(sizeof(ctlx
->outbuf
.wmemreq
.offset
) +
1734 sizeof(ctlx
->outbuf
.wmemreq
.page
) + len
);
1735 ctlx
->outbuf
.wmemreq
.offset
= cpu_to_le16(offset
);
1736 ctlx
->outbuf
.wmemreq
.page
= cpu_to_le16(page
);
1737 memcpy(ctlx
->outbuf
.wmemreq
.data
, data
, len
);
1739 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.wmemreq
.type
) +
1740 sizeof(ctlx
->outbuf
.wmemreq
.frmlen
) +
1741 sizeof(ctlx
->outbuf
.wmemreq
.offset
) +
1742 sizeof(ctlx
->outbuf
.wmemreq
.page
) + len
;
1744 ctlx
->reapable
= mode
;
1745 ctlx
->cmdcb
= cmdcb
;
1746 ctlx
->usercb
= usercb
;
1747 ctlx
->usercb_data
= usercb_data
;
1749 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1752 } else if (mode
== DOWAIT
) {
1753 usbctlx_wmem_completor_t completor
;
1754 hfa384x_cmdresult_t wmemresult
;
1756 result
= hfa384x_usbctlx_complete_sync(hw
,
1760 &ctlx
->inbuf
.wmemresp
,
1768 /*----------------------------------------------------------------
1769 * hfa384x_drvr_commtallies
1771 * Send a commtallies inquiry to the MAC. Note that this is an async
1772 * call that will result in an info frame arriving sometime later.
1775 * hw device structure
1784 ----------------------------------------------------------------*/
1785 int hfa384x_drvr_commtallies(hfa384x_t
*hw
)
1787 hfa384x_metacmd_t cmd
;
1789 cmd
.cmd
= HFA384x_CMDCODE_INQ
;
1790 cmd
.parm0
= HFA384x_IT_COMMTALLIES
;
1794 hfa384x_docmd_async(hw
, &cmd
, NULL
, NULL
, NULL
);
1799 /*----------------------------------------------------------------
1800 * hfa384x_drvr_disable
1802 * Issues the disable command to stop communications on one of
1803 * the MACs 'ports'. Only macport 0 is valid for stations.
1804 * APs may also disable macports 1-6. Only ports that have been
1805 * previously enabled may be disabled.
1808 * hw device structure
1809 * macport MAC port number (host order)
1813 * >0 f/w reported failure - f/w status code
1814 * <0 driver reported error (timeout|bad arg)
1820 ----------------------------------------------------------------*/
1821 int hfa384x_drvr_disable(hfa384x_t
*hw
, u16 macport
)
1825 if ((!hw
->isap
&& macport
!= 0) ||
1826 (hw
->isap
&& !(macport
<= HFA384x_PORTID_MAX
)) ||
1827 !(hw
->port_enabled
[macport
])) {
1830 result
= hfa384x_cmd_disable(hw
, macport
);
1832 hw
->port_enabled
[macport
] = 0;
1837 /*----------------------------------------------------------------
1838 * hfa384x_drvr_enable
1840 * Issues the enable command to enable communications on one of
1841 * the MACs 'ports'. Only macport 0 is valid for stations.
1842 * APs may also enable macports 1-6. Only ports that are currently
1843 * disabled may be enabled.
1846 * hw device structure
1847 * macport MAC port number
1851 * >0 f/w reported failure - f/w status code
1852 * <0 driver reported error (timeout|bad arg)
1858 ----------------------------------------------------------------*/
1859 int hfa384x_drvr_enable(hfa384x_t
*hw
, u16 macport
)
1863 if ((!hw
->isap
&& macport
!= 0) ||
1864 (hw
->isap
&& !(macport
<= HFA384x_PORTID_MAX
)) ||
1865 (hw
->port_enabled
[macport
])) {
1868 result
= hfa384x_cmd_enable(hw
, macport
);
1870 hw
->port_enabled
[macport
] = 1;
1875 /*----------------------------------------------------------------
1876 * hfa384x_drvr_flashdl_enable
1878 * Begins the flash download state. Checks to see that we're not
1879 * already in a download state and that a port isn't enabled.
1880 * Sets the download state and retrieves the flash download
1881 * buffer location, buffer size, and timeout length.
1884 * hw device structure
1888 * >0 f/w reported error - f/w status code
1889 * <0 driver reported error
1895 ----------------------------------------------------------------*/
1896 int hfa384x_drvr_flashdl_enable(hfa384x_t
*hw
)
1901 /* Check that a port isn't active */
1902 for (i
= 0; i
< HFA384x_PORTID_MAX
; i
++) {
1903 if (hw
->port_enabled
[i
]) {
1904 pr_debug("called when port enabled.\n");
1909 /* Check that we're not already in a download state */
1910 if (hw
->dlstate
!= HFA384x_DLSTATE_DISABLED
)
1913 /* Retrieve the buffer loc&size and timeout */
1914 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_DOWNLOADBUFFER
,
1915 &(hw
->bufinfo
), sizeof(hw
->bufinfo
));
1919 hw
->bufinfo
.page
= le16_to_cpu(hw
->bufinfo
.page
);
1920 hw
->bufinfo
.offset
= le16_to_cpu(hw
->bufinfo
.offset
);
1921 hw
->bufinfo
.len
= le16_to_cpu(hw
->bufinfo
.len
);
1922 result
= hfa384x_drvr_getconfig16(hw
, HFA384x_RID_MAXLOADTIME
,
1927 hw
->dltimeout
= le16_to_cpu(hw
->dltimeout
);
1929 pr_debug("flashdl_enable\n");
1931 hw
->dlstate
= HFA384x_DLSTATE_FLASHENABLED
;
1936 /*----------------------------------------------------------------
1937 * hfa384x_drvr_flashdl_disable
1939 * Ends the flash download state. Note that this will cause the MAC
1940 * firmware to restart.
1943 * hw device structure
1947 * >0 f/w reported error - f/w status code
1948 * <0 driver reported error
1954 ----------------------------------------------------------------*/
1955 int hfa384x_drvr_flashdl_disable(hfa384x_t
*hw
)
1957 /* Check that we're already in the download state */
1958 if (hw
->dlstate
!= HFA384x_DLSTATE_FLASHENABLED
)
1961 pr_debug("flashdl_enable\n");
1963 /* There isn't much we can do at this point, so I don't */
1964 /* bother w/ the return value */
1965 hfa384x_cmd_download(hw
, HFA384x_PROGMODE_DISABLE
, 0, 0, 0);
1966 hw
->dlstate
= HFA384x_DLSTATE_DISABLED
;
1971 /*----------------------------------------------------------------
1972 * hfa384x_drvr_flashdl_write
1974 * Performs a FLASH download of a chunk of data. First checks to see
1975 * that we're in the FLASH download state, then sets the download
1976 * mode, uses the aux functions to 1) copy the data to the flash
1977 * buffer, 2) sets the download 'write flash' mode, 3) readback and
1978 * compare. Lather rinse, repeat as many times an necessary to get
1979 * all the given data into flash.
1980 * When all data has been written using this function (possibly
1981 * repeatedly), call drvr_flashdl_disable() to end the download state
1982 * and restart the MAC.
1985 * hw device structure
1986 * daddr Card address to write to. (host order)
1987 * buf Ptr to data to write.
1988 * len Length of data (host order).
1992 * >0 f/w reported error - f/w status code
1993 * <0 driver reported error
1999 ----------------------------------------------------------------*/
2000 int hfa384x_drvr_flashdl_write(hfa384x_t
*hw
, u32 daddr
, void *buf
, u32 len
)
2017 pr_debug("daddr=0x%08x len=%d\n", daddr
, len
);
2019 /* Check that we're in the flash download state */
2020 if (hw
->dlstate
!= HFA384x_DLSTATE_FLASHENABLED
)
2023 printk(KERN_INFO
"Download %d bytes to flash @0x%06x\n", len
, daddr
);
2025 /* Convert to flat address for arithmetic */
2026 /* NOTE: dlbuffer RID stores the address in AUX format */
2028 HFA384x_ADDR_AUX_MKFLAT(hw
->bufinfo
.page
, hw
->bufinfo
.offset
);
2029 pr_debug("dlbuf.page=0x%04x dlbuf.offset=0x%04x dlbufaddr=0x%08x\n",
2030 hw
->bufinfo
.page
, hw
->bufinfo
.offset
, dlbufaddr
);
2032 /* Calculations to determine how many fills of the dlbuffer to do
2033 * and how many USB wmemreq's to do for each fill. At this point
2034 * in time, the dlbuffer size and the wmemreq size are the same.
2035 * Therefore, nwrites should always be 1. The extra complexity
2036 * here is a hedge against future changes.
2039 /* Figure out how many times to do the flash programming */
2040 nburns
= len
/ hw
->bufinfo
.len
;
2041 nburns
+= (len
% hw
->bufinfo
.len
) ? 1 : 0;
2043 /* For each flash program cycle, how many USB wmemreq's are needed? */
2044 nwrites
= hw
->bufinfo
.len
/ HFA384x_USB_RWMEM_MAXLEN
;
2045 nwrites
+= (hw
->bufinfo
.len
% HFA384x_USB_RWMEM_MAXLEN
) ? 1 : 0;
2048 for (i
= 0; i
< nburns
; i
++) {
2049 /* Get the dest address and len */
2050 burnlen
= (len
- (hw
->bufinfo
.len
* i
)) > hw
->bufinfo
.len
?
2051 hw
->bufinfo
.len
: (len
- (hw
->bufinfo
.len
* i
));
2052 burndaddr
= daddr
+ (hw
->bufinfo
.len
* i
);
2053 burnlo
= HFA384x_ADDR_CMD_MKOFF(burndaddr
);
2054 burnhi
= HFA384x_ADDR_CMD_MKPAGE(burndaddr
);
2056 printk(KERN_INFO
"Writing %d bytes to flash @0x%06x\n",
2057 burnlen
, burndaddr
);
2059 /* Set the download mode */
2060 result
= hfa384x_cmd_download(hw
, HFA384x_PROGMODE_NV
,
2061 burnlo
, burnhi
, burnlen
);
2063 printk(KERN_ERR
"download(NV,lo=%x,hi=%x,len=%x) "
2064 "cmd failed, result=%d. Aborting d/l\n",
2065 burnlo
, burnhi
, burnlen
, result
);
2069 /* copy the data to the flash download buffer */
2070 for (j
= 0; j
< nwrites
; j
++) {
2072 (i
* hw
->bufinfo
.len
) +
2073 (j
* HFA384x_USB_RWMEM_MAXLEN
);
2075 writepage
= HFA384x_ADDR_CMD_MKPAGE(dlbufaddr
+
2076 (j
* HFA384x_USB_RWMEM_MAXLEN
));
2077 writeoffset
= HFA384x_ADDR_CMD_MKOFF(dlbufaddr
+
2078 (j
* HFA384x_USB_RWMEM_MAXLEN
));
2080 writelen
= burnlen
- (j
* HFA384x_USB_RWMEM_MAXLEN
);
2081 writelen
= writelen
> HFA384x_USB_RWMEM_MAXLEN
?
2082 HFA384x_USB_RWMEM_MAXLEN
: writelen
;
2084 result
= hfa384x_dowmem_wait(hw
,
2087 writebuf
, writelen
);
2090 /* set the download 'write flash' mode */
2091 result
= hfa384x_cmd_download(hw
,
2092 HFA384x_PROGMODE_NVWRITE
,
2096 "download(NVWRITE,lo=%x,hi=%x,len=%x) "
2097 "cmd failed, result=%d. Aborting d/l\n",
2098 burnlo
, burnhi
, burnlen
, result
);
2102 /* TODO: We really should do a readback and compare. */
2107 /* Leave the firmware in the 'post-prog' mode. flashdl_disable will */
2108 /* actually disable programming mode. Remember, that will cause the */
2109 /* the firmware to effectively reset itself. */
2114 /*----------------------------------------------------------------
2115 * hfa384x_drvr_getconfig
2117 * Performs the sequence necessary to read a config/info item.
2120 * hw device structure
2121 * rid config/info record id (host order)
2122 * buf host side record buffer. Upon return it will
2123 * contain the body portion of the record (minus the
2125 * len buffer length (in bytes, should match record length)
2129 * >0 f/w reported error - f/w status code
2130 * <0 driver reported error
2131 * -ENODATA length mismatch between argument and retrieved
2138 ----------------------------------------------------------------*/
2139 int hfa384x_drvr_getconfig(hfa384x_t
*hw
, u16 rid
, void *buf
, u16 len
)
2143 result
= hfa384x_dorrid_wait(hw
, rid
, buf
, len
);
2148 /*----------------------------------------------------------------
2149 * hfa384x_drvr_getconfig_async
2151 * Performs the sequence necessary to perform an async read of
2152 * of a config/info item.
2155 * hw device structure
2156 * rid config/info record id (host order)
2157 * buf host side record buffer. Upon return it will
2158 * contain the body portion of the record (minus the
2160 * len buffer length (in bytes, should match record length)
2161 * cbfn caller supplied callback, called when the command
2162 * is done (successful or not).
2163 * cbfndata pointer to some caller supplied data that will be
2164 * passed in as an argument to the cbfn.
2167 * nothing the cbfn gets a status argument identifying if
2170 * Queues an hfa384x_usbcmd_t for subsequent execution.
2174 ----------------------------------------------------------------*/
2176 hfa384x_drvr_getconfig_async(hfa384x_t
*hw
,
2177 u16 rid
, ctlx_usercb_t usercb
, void *usercb_data
)
2179 return hfa384x_dorrid_async(hw
, rid
, NULL
, 0,
2180 hfa384x_cb_rrid
, usercb
, usercb_data
);
2183 /*----------------------------------------------------------------
2184 * hfa384x_drvr_setconfig_async
2186 * Performs the sequence necessary to write a config/info item.
2189 * hw device structure
2190 * rid config/info record id (in host order)
2191 * buf host side record buffer
2192 * len buffer length (in bytes)
2193 * usercb completion callback
2194 * usercb_data completion callback argument
2198 * >0 f/w reported error - f/w status code
2199 * <0 driver reported error
2205 ----------------------------------------------------------------*/
2207 hfa384x_drvr_setconfig_async(hfa384x_t
*hw
,
2210 u16 len
, ctlx_usercb_t usercb
, void *usercb_data
)
2212 return hfa384x_dowrid_async(hw
, rid
, buf
, len
,
2213 hfa384x_cb_status
, usercb
, usercb_data
);
2216 /*----------------------------------------------------------------
2217 * hfa384x_drvr_ramdl_disable
2219 * Ends the ram download state.
2222 * hw device structure
2226 * >0 f/w reported error - f/w status code
2227 * <0 driver reported error
2233 ----------------------------------------------------------------*/
2234 int hfa384x_drvr_ramdl_disable(hfa384x_t
*hw
)
2236 /* Check that we're already in the download state */
2237 if (hw
->dlstate
!= HFA384x_DLSTATE_RAMENABLED
)
2240 pr_debug("ramdl_disable()\n");
2242 /* There isn't much we can do at this point, so I don't */
2243 /* bother w/ the return value */
2244 hfa384x_cmd_download(hw
, HFA384x_PROGMODE_DISABLE
, 0, 0, 0);
2245 hw
->dlstate
= HFA384x_DLSTATE_DISABLED
;
2250 /*----------------------------------------------------------------
2251 * hfa384x_drvr_ramdl_enable
2253 * Begins the ram download state. Checks to see that we're not
2254 * already in a download state and that a port isn't enabled.
2255 * Sets the download state and calls cmd_download with the
2256 * ENABLE_VOLATILE subcommand and the exeaddr argument.
2259 * hw device structure
2260 * exeaddr the card execution address that will be
2261 * jumped to when ramdl_disable() is called
2266 * >0 f/w reported error - f/w status code
2267 * <0 driver reported error
2273 ----------------------------------------------------------------*/
2274 int hfa384x_drvr_ramdl_enable(hfa384x_t
*hw
, u32 exeaddr
)
2281 /* Check that a port isn't active */
2282 for (i
= 0; i
< HFA384x_PORTID_MAX
; i
++) {
2283 if (hw
->port_enabled
[i
]) {
2285 "Can't download with a macport enabled.\n");
2290 /* Check that we're not already in a download state */
2291 if (hw
->dlstate
!= HFA384x_DLSTATE_DISABLED
) {
2292 printk(KERN_ERR
"Download state not disabled.\n");
2296 pr_debug("ramdl_enable, exeaddr=0x%08x\n", exeaddr
);
2298 /* Call the download(1,addr) function */
2299 lowaddr
= HFA384x_ADDR_CMD_MKOFF(exeaddr
);
2300 hiaddr
= HFA384x_ADDR_CMD_MKPAGE(exeaddr
);
2302 result
= hfa384x_cmd_download(hw
, HFA384x_PROGMODE_RAM
,
2303 lowaddr
, hiaddr
, 0);
2306 /* Set the download state */
2307 hw
->dlstate
= HFA384x_DLSTATE_RAMENABLED
;
2309 pr_debug("cmd_download(0x%04x, 0x%04x) failed, result=%d.\n",
2310 lowaddr
, hiaddr
, result
);
2316 /*----------------------------------------------------------------
2317 * hfa384x_drvr_ramdl_write
2319 * Performs a RAM download of a chunk of data. First checks to see
2320 * that we're in the RAM download state, then uses the [read|write]mem USB
2321 * commands to 1) copy the data, 2) readback and compare. The download
2322 * state is unaffected. When all data has been written using
2323 * this function, call drvr_ramdl_disable() to end the download state
2324 * and restart the MAC.
2327 * hw device structure
2328 * daddr Card address to write to. (host order)
2329 * buf Ptr to data to write.
2330 * len Length of data (host order).
2334 * >0 f/w reported error - f/w status code
2335 * <0 driver reported error
2341 ----------------------------------------------------------------*/
2342 int hfa384x_drvr_ramdl_write(hfa384x_t
*hw
, u32 daddr
, void *buf
, u32 len
)
2353 /* Check that we're in the ram download state */
2354 if (hw
->dlstate
!= HFA384x_DLSTATE_RAMENABLED
)
2357 printk(KERN_INFO
"Writing %d bytes to ram @0x%06x\n", len
, daddr
);
2359 /* How many dowmem calls? */
2360 nwrites
= len
/ HFA384x_USB_RWMEM_MAXLEN
;
2361 nwrites
+= len
% HFA384x_USB_RWMEM_MAXLEN
? 1 : 0;
2363 /* Do blocking wmem's */
2364 for (i
= 0; i
< nwrites
; i
++) {
2365 /* make address args */
2366 curraddr
= daddr
+ (i
* HFA384x_USB_RWMEM_MAXLEN
);
2367 currpage
= HFA384x_ADDR_CMD_MKPAGE(curraddr
);
2368 curroffset
= HFA384x_ADDR_CMD_MKOFF(curraddr
);
2369 currlen
= len
- (i
* HFA384x_USB_RWMEM_MAXLEN
);
2370 if (currlen
> HFA384x_USB_RWMEM_MAXLEN
)
2371 currlen
= HFA384x_USB_RWMEM_MAXLEN
;
2373 /* Do blocking ctlx */
2374 result
= hfa384x_dowmem_wait(hw
,
2378 (i
* HFA384x_USB_RWMEM_MAXLEN
),
2384 /* TODO: We really should have a readback. */
2390 /*----------------------------------------------------------------
2391 * hfa384x_drvr_readpda
2393 * Performs the sequence to read the PDA space. Note there is no
2394 * drvr_writepda() function. Writing a PDA is
2395 * generally implemented by a calling component via calls to
2396 * cmd_download and writing to the flash download buffer via the
2400 * hw device structure
2401 * buf buffer to store PDA in
2406 * >0 f/w reported error - f/w status code
2407 * <0 driver reported error
2408 * -ETIMEDOUT timout waiting for the cmd regs to become
2409 * available, or waiting for the control reg
2410 * to indicate the Aux port is enabled.
2411 * -ENODATA the buffer does NOT contain a valid PDA.
2412 * Either the card PDA is bad, or the auxdata
2413 * reads are giving us garbage.
2419 * process or non-card interrupt.
2420 ----------------------------------------------------------------*/
2421 int hfa384x_drvr_readpda(hfa384x_t
*hw
, void *buf
, unsigned int len
)
2427 int currpdr
= 0; /* word offset of the current pdr */
2429 u16 pdrlen
; /* pdr length in bytes, host order */
2430 u16 pdrcode
; /* pdr code, host order */
2438 HFA3842_PDA_BASE
, 0}, {
2439 HFA3841_PDA_BASE
, 0}, {
2440 HFA3841_PDA_BOGUS_BASE
, 0}
2443 /* Read the pda from each known address. */
2444 for (i
= 0; i
< ARRAY_SIZE(pdaloc
); i
++) {
2446 currpage
= HFA384x_ADDR_CMD_MKPAGE(pdaloc
[i
].cardaddr
);
2447 curroffset
= HFA384x_ADDR_CMD_MKOFF(pdaloc
[i
].cardaddr
);
2449 /* units of bytes */
2450 result
= hfa384x_dormem_wait(hw
, currpage
, curroffset
, buf
,
2455 "Read from index %zd failed, continuing\n", i
);
2459 /* Test for garbage */
2460 pdaok
= 1; /* initially assume good */
2462 while (pdaok
&& morepdrs
) {
2463 pdrlen
= le16_to_cpu(pda
[currpdr
]) * 2;
2464 pdrcode
= le16_to_cpu(pda
[currpdr
+ 1]);
2465 /* Test the record length */
2466 if (pdrlen
> HFA384x_PDR_LEN_MAX
|| pdrlen
== 0) {
2467 printk(KERN_ERR
"pdrlen invalid=%d\n", pdrlen
);
2472 if (!hfa384x_isgood_pdrcode(pdrcode
)) {
2473 printk(KERN_ERR
"pdrcode invalid=%d\n",
2478 /* Test for completion */
2479 if (pdrcode
== HFA384x_PDR_END_OF_PDA
)
2482 /* Move to the next pdr (if necessary) */
2484 /* note the access to pda[], need words here */
2485 currpdr
+= le16_to_cpu(pda
[currpdr
]) + 1;
2490 "PDA Read from 0x%08x in %s space.\n",
2492 pdaloc
[i
].auxctl
== 0 ? "EXTDS" :
2493 pdaloc
[i
].auxctl
== 1 ? "NV" :
2494 pdaloc
[i
].auxctl
== 2 ? "PHY" :
2495 pdaloc
[i
].auxctl
== 3 ? "ICSRAM" :
2500 result
= pdaok
? 0 : -ENODATA
;
2503 pr_debug("Failure: pda is not okay\n");
2508 /*----------------------------------------------------------------
2509 * hfa384x_drvr_setconfig
2511 * Performs the sequence necessary to write a config/info item.
2514 * hw device structure
2515 * rid config/info record id (in host order)
2516 * buf host side record buffer
2517 * len buffer length (in bytes)
2521 * >0 f/w reported error - f/w status code
2522 * <0 driver reported error
2528 ----------------------------------------------------------------*/
2529 int hfa384x_drvr_setconfig(hfa384x_t
*hw
, u16 rid
, void *buf
, u16 len
)
2531 return hfa384x_dowrid_wait(hw
, rid
, buf
, len
);
2534 /*----------------------------------------------------------------
2535 * hfa384x_drvr_start
2537 * Issues the MAC initialize command, sets up some data structures,
2538 * and enables the interrupts. After this function completes, the
2539 * low-level stuff should be ready for any/all commands.
2542 * hw device structure
2545 * >0 f/w reported error - f/w status code
2546 * <0 driver reported error
2552 ----------------------------------------------------------------*/
2554 int hfa384x_drvr_start(hfa384x_t
*hw
)
2556 int result
, result1
, result2
;
2561 /* Clear endpoint stalls - but only do this if the endpoint
2562 * is showing a stall status. Some prism2 cards seem to behave
2563 * badly if a clear_halt is called when the endpoint is already
2567 usb_get_status(hw
->usb
, USB_RECIP_ENDPOINT
, hw
->endp_in
, &status
);
2569 printk(KERN_ERR
"Cannot get bulk in endpoint status.\n");
2572 if ((status
== 1) && usb_clear_halt(hw
->usb
, hw
->endp_in
))
2573 printk(KERN_ERR
"Failed to reset bulk in endpoint.\n");
2576 usb_get_status(hw
->usb
, USB_RECIP_ENDPOINT
, hw
->endp_out
, &status
);
2578 printk(KERN_ERR
"Cannot get bulk out endpoint status.\n");
2581 if ((status
== 1) && usb_clear_halt(hw
->usb
, hw
->endp_out
))
2582 printk(KERN_ERR
"Failed to reset bulk out endpoint.\n");
2584 /* Synchronous unlink, in case we're trying to restart the driver */
2585 usb_kill_urb(&hw
->rx_urb
);
2587 /* Post the IN urb */
2588 result
= submit_rx_urb(hw
, GFP_KERNEL
);
2591 "Fatal, failed to submit RX URB, result=%d\n", result
);
2595 result1
= hfa384x_cmd_initialize(hw
);
2597 result
= result2
= hfa384x_cmd_initialize(hw
);
2601 "cmd_initialize() failed on two attempts, results %d and %d\n",
2603 usb_kill_urb(&hw
->rx_urb
);
2606 pr_debug("First cmd_initialize() failed (result %d),\n",
2608 pr_debug("but second attempt succeeded. All should be ok\n");
2610 } else if (result2
!= 0) {
2611 printk(KERN_WARNING
"First cmd_initialize() succeeded, but second attempt failed (result=%d)\n",
2614 "Most likely the card will be functional\n");
2618 hw
->state
= HFA384x_STATE_RUNNING
;
2624 /*----------------------------------------------------------------
2627 * Shuts down the MAC to the point where it is safe to unload the
2628 * driver. Any subsystem that may be holding a data or function
2629 * ptr into the driver must be cleared/deinitialized.
2632 * hw device structure
2635 * >0 f/w reported error - f/w status code
2636 * <0 driver reported error
2642 ----------------------------------------------------------------*/
2643 int hfa384x_drvr_stop(hfa384x_t
*hw
)
2650 /* There's no need for spinlocks here. The USB "disconnect"
2651 * function sets this "removed" flag and then calls us.
2653 if (!hw
->wlandev
->hwremoved
) {
2654 /* Call initialize to leave the MAC in its 'reset' state */
2655 hfa384x_cmd_initialize(hw
);
2657 /* Cancel the rxurb */
2658 usb_kill_urb(&hw
->rx_urb
);
2661 hw
->link_status
= HFA384x_LINK_NOTCONNECTED
;
2662 hw
->state
= HFA384x_STATE_INIT
;
2664 del_timer_sync(&hw
->commsqual_timer
);
2666 /* Clear all the port status */
2667 for (i
= 0; i
< HFA384x_NUMPORTS_MAX
; i
++)
2668 hw
->port_enabled
[i
] = 0;
2673 /*----------------------------------------------------------------
2674 * hfa384x_drvr_txframe
2676 * Takes a frame from prism2sta and queues it for transmission.
2679 * hw device structure
2680 * skb packet buffer struct. Contains an 802.11
2682 * p80211_hdr points to the 802.11 header for the packet.
2684 * 0 Success and more buffs available
2685 * 1 Success but no more buffs
2686 * 2 Allocation failure
2687 * 4 Buffer full or queue busy
2693 ----------------------------------------------------------------*/
2694 int hfa384x_drvr_txframe(hfa384x_t
*hw
, struct sk_buff
*skb
,
2695 union p80211_hdr
*p80211_hdr
,
2696 struct p80211_metawep
*p80211_wep
)
2698 int usbpktlen
= sizeof(hfa384x_tx_frame_t
);
2703 if (hw
->tx_urb
.status
== -EINPROGRESS
) {
2704 printk(KERN_WARNING
"TX URB already in use\n");
2709 /* Build Tx frame structure */
2710 /* Set up the control field */
2711 memset(&hw
->txbuff
.txfrm
.desc
, 0, sizeof(hw
->txbuff
.txfrm
.desc
));
2713 /* Setup the usb type field */
2714 hw
->txbuff
.type
= cpu_to_le16(HFA384x_USB_TXFRM
);
2716 /* Set up the sw_support field to identify this frame */
2717 hw
->txbuff
.txfrm
.desc
.sw_support
= 0x0123;
2719 /* Tx complete and Tx exception disable per dleach. Might be causing
2722 /* #define DOEXC SLP -- doboth breaks horribly under load, doexc less so. */
2724 hw
->txbuff
.txfrm
.desc
.tx_control
=
2725 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2726 HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(1);
2727 #elif defined(DOEXC)
2728 hw
->txbuff
.txfrm
.desc
.tx_control
=
2729 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2730 HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(0);
2732 hw
->txbuff
.txfrm
.desc
.tx_control
=
2733 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2734 HFA384x_TX_TXEX_SET(0) | HFA384x_TX_TXOK_SET(0);
2736 hw
->txbuff
.txfrm
.desc
.tx_control
=
2737 cpu_to_le16(hw
->txbuff
.txfrm
.desc
.tx_control
);
2739 /* copy the header over to the txdesc */
2740 memcpy(&(hw
->txbuff
.txfrm
.desc
.frame_control
), p80211_hdr
,
2741 sizeof(union p80211_hdr
));
2743 /* if we're using host WEP, increase size by IV+ICV */
2744 if (p80211_wep
->data
) {
2745 hw
->txbuff
.txfrm
.desc
.data_len
= cpu_to_le16(skb
->len
+ 8);
2748 hw
->txbuff
.txfrm
.desc
.data_len
= cpu_to_le16(skb
->len
);
2751 usbpktlen
+= skb
->len
;
2753 /* copy over the WEP IV if we are using host WEP */
2754 ptr
= hw
->txbuff
.txfrm
.data
;
2755 if (p80211_wep
->data
) {
2756 memcpy(ptr
, p80211_wep
->iv
, sizeof(p80211_wep
->iv
));
2757 ptr
+= sizeof(p80211_wep
->iv
);
2758 memcpy(ptr
, p80211_wep
->data
, skb
->len
);
2760 memcpy(ptr
, skb
->data
, skb
->len
);
2762 /* copy over the packet data */
2765 /* copy over the WEP ICV if we are using host WEP */
2766 if (p80211_wep
->data
)
2767 memcpy(ptr
, p80211_wep
->icv
, sizeof(p80211_wep
->icv
));
2769 /* Send the USB packet */
2770 usb_fill_bulk_urb(&(hw
->tx_urb
), hw
->usb
,
2772 &(hw
->txbuff
), ROUNDUP64(usbpktlen
),
2773 hfa384x_usbout_callback
, hw
->wlandev
);
2774 hw
->tx_urb
.transfer_flags
|= USB_QUEUE_BULK
;
2777 ret
= submit_tx_urb(hw
, &hw
->tx_urb
, GFP_ATOMIC
);
2779 printk(KERN_ERR
"submit_tx_urb() failed, error=%d\n", ret
);
2787 void hfa384x_tx_timeout(wlandevice_t
*wlandev
)
2789 hfa384x_t
*hw
= wlandev
->priv
;
2790 unsigned long flags
;
2792 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2794 if (!hw
->wlandev
->hwremoved
) {
2797 sched
= !test_and_set_bit(WORK_TX_HALT
, &hw
->usb_flags
);
2798 sched
|= !test_and_set_bit(WORK_RX_HALT
, &hw
->usb_flags
);
2800 schedule_work(&hw
->usb_work
);
2803 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2806 /*----------------------------------------------------------------
2807 * hfa384x_usbctlx_reaper_task
2809 * Tasklet to delete dead CTLX objects
2812 * data ptr to a hfa384x_t
2818 ----------------------------------------------------------------*/
2819 static void hfa384x_usbctlx_reaper_task(unsigned long data
)
2821 hfa384x_t
*hw
= (hfa384x_t
*) data
;
2822 struct list_head
*entry
;
2823 struct list_head
*temp
;
2824 unsigned long flags
;
2826 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2828 /* This list is guaranteed to be empty if someone
2829 * has unplugged the adapter.
2831 list_for_each_safe(entry
, temp
, &hw
->ctlxq
.reapable
) {
2832 hfa384x_usbctlx_t
*ctlx
;
2834 ctlx
= list_entry(entry
, hfa384x_usbctlx_t
, list
);
2835 list_del(&ctlx
->list
);
2839 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2843 /*----------------------------------------------------------------
2844 * hfa384x_usbctlx_completion_task
2846 * Tasklet to call completion handlers for returned CTLXs
2849 * data ptr to hfa384x_t
2856 ----------------------------------------------------------------*/
2857 static void hfa384x_usbctlx_completion_task(unsigned long data
)
2859 hfa384x_t
*hw
= (hfa384x_t
*) data
;
2860 struct list_head
*entry
;
2861 struct list_head
*temp
;
2862 unsigned long flags
;
2866 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2868 /* This list is guaranteed to be empty if someone
2869 * has unplugged the adapter ...
2871 list_for_each_safe(entry
, temp
, &hw
->ctlxq
.completing
) {
2872 hfa384x_usbctlx_t
*ctlx
;
2874 ctlx
= list_entry(entry
, hfa384x_usbctlx_t
, list
);
2876 /* Call the completion function that this
2877 * command was assigned, assuming it has one.
2879 if (ctlx
->cmdcb
!= NULL
) {
2880 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2881 ctlx
->cmdcb(hw
, ctlx
);
2882 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2884 /* Make sure we don't try and complete
2885 * this CTLX more than once!
2889 /* Did someone yank the adapter out
2890 * while our list was (briefly) unlocked?
2892 if (hw
->wlandev
->hwremoved
) {
2899 * "Reapable" CTLXs are ones which don't have any
2900 * threads waiting for them to die. Hence they must
2901 * be delivered to The Reaper!
2903 if (ctlx
->reapable
) {
2904 /* Move the CTLX off the "completing" list (hopefully)
2905 * on to the "reapable" list where the reaper task
2906 * can find it. And "reapable" means that this CTLX
2907 * isn't sitting on a wait-queue somewhere.
2909 list_move_tail(&ctlx
->list
, &hw
->ctlxq
.reapable
);
2913 complete(&ctlx
->done
);
2915 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2918 tasklet_schedule(&hw
->reaper_bh
);
2921 /*----------------------------------------------------------------
2922 * unlocked_usbctlx_cancel_async
2924 * Mark the CTLX dead asynchronously, and ensure that the
2925 * next command on the queue is run afterwards.
2928 * hw ptr to the hfa384x_t structure
2929 * ctlx ptr to a CTLX structure
2932 * 0 the CTLX's URB is inactive
2933 * -EINPROGRESS the URB is currently being unlinked
2936 * Either process or interrupt, but presumably interrupt
2937 ----------------------------------------------------------------*/
2938 static int unlocked_usbctlx_cancel_async(hfa384x_t
*hw
,
2939 hfa384x_usbctlx_t
*ctlx
)
2944 * Try to delete the URB containing our request packet.
2945 * If we succeed, then its completion handler will be
2946 * called with a status of -ECONNRESET.
2948 hw
->ctlx_urb
.transfer_flags
|= URB_ASYNC_UNLINK
;
2949 ret
= usb_unlink_urb(&hw
->ctlx_urb
);
2951 if (ret
!= -EINPROGRESS
) {
2953 * The OUT URB had either already completed
2954 * or was still in the pending queue, so the
2955 * URB's completion function will not be called.
2956 * We will have to complete the CTLX ourselves.
2958 ctlx
->state
= CTLX_REQ_FAILED
;
2959 unlocked_usbctlx_complete(hw
, ctlx
);
2966 /*----------------------------------------------------------------
2967 * unlocked_usbctlx_complete
2969 * A CTLX has completed. It may have been successful, it may not
2970 * have been. At this point, the CTLX should be quiescent. The URBs
2971 * aren't active and the timers should have been stopped.
2973 * The CTLX is migrated to the "completing" queue, and the completing
2974 * tasklet is scheduled.
2977 * hw ptr to a hfa384x_t structure
2978 * ctlx ptr to a ctlx structure
2986 * Either, assume interrupt
2987 ----------------------------------------------------------------*/
2988 static void unlocked_usbctlx_complete(hfa384x_t
*hw
, hfa384x_usbctlx_t
*ctlx
)
2990 /* Timers have been stopped, and ctlx should be in
2991 * a terminal state. Retire it from the "active"
2994 list_move_tail(&ctlx
->list
, &hw
->ctlxq
.completing
);
2995 tasklet_schedule(&hw
->completion_bh
);
2997 switch (ctlx
->state
) {
2999 case CTLX_REQ_FAILED
:
3000 /* This are the correct terminating states. */
3004 printk(KERN_ERR
"CTLX[%d] not in a terminating state(%s)\n",
3005 le16_to_cpu(ctlx
->outbuf
.type
), ctlxstr(ctlx
->state
));
3010 /*----------------------------------------------------------------
3011 * hfa384x_usbctlxq_run
3013 * Checks to see if the head item is running. If not, starts it.
3016 * hw ptr to hfa384x_t
3025 ----------------------------------------------------------------*/
3026 static void hfa384x_usbctlxq_run(hfa384x_t
*hw
)
3028 unsigned long flags
;
3031 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3033 /* Only one active CTLX at any one time, because there's no
3034 * other (reliable) way to match the response URB to the
3037 * Don't touch any of these CTLXs if the hardware
3038 * has been removed or the USB subsystem is stalled.
3040 if (!list_empty(&hw
->ctlxq
.active
) ||
3041 test_bit(WORK_TX_HALT
, &hw
->usb_flags
) || hw
->wlandev
->hwremoved
)
3044 while (!list_empty(&hw
->ctlxq
.pending
)) {
3045 hfa384x_usbctlx_t
*head
;
3048 /* This is the first pending command */
3049 head
= list_entry(hw
->ctlxq
.pending
.next
,
3050 hfa384x_usbctlx_t
, list
);
3052 /* We need to split this off to avoid a race condition */
3053 list_move_tail(&head
->list
, &hw
->ctlxq
.active
);
3055 /* Fill the out packet */
3056 usb_fill_bulk_urb(&(hw
->ctlx_urb
), hw
->usb
,
3058 &(head
->outbuf
), ROUNDUP64(head
->outbufsize
),
3059 hfa384x_ctlxout_callback
, hw
);
3060 hw
->ctlx_urb
.transfer_flags
|= USB_QUEUE_BULK
;
3062 /* Now submit the URB and update the CTLX's state */
3063 result
= SUBMIT_URB(&hw
->ctlx_urb
, GFP_ATOMIC
);
3065 /* This CTLX is now running on the active queue */
3066 head
->state
= CTLX_REQ_SUBMITTED
;
3068 /* Start the OUT wait timer */
3069 hw
->req_timer_done
= 0;
3070 hw
->reqtimer
.expires
= jiffies
+ HZ
;
3071 add_timer(&hw
->reqtimer
);
3073 /* Start the IN wait timer */
3074 hw
->resp_timer_done
= 0;
3075 hw
->resptimer
.expires
= jiffies
+ 2 * HZ
;
3076 add_timer(&hw
->resptimer
);
3081 if (result
== -EPIPE
) {
3082 /* The OUT pipe needs resetting, so put
3083 * this CTLX back in the "pending" queue
3084 * and schedule a reset ...
3087 "%s tx pipe stalled: requesting reset\n",
3088 hw
->wlandev
->netdev
->name
);
3089 list_move(&head
->list
, &hw
->ctlxq
.pending
);
3090 set_bit(WORK_TX_HALT
, &hw
->usb_flags
);
3091 schedule_work(&hw
->usb_work
);
3095 if (result
== -ESHUTDOWN
) {
3096 printk(KERN_WARNING
"%s urb shutdown!\n",
3097 hw
->wlandev
->netdev
->name
);
3101 printk(KERN_ERR
"Failed to submit CTLX[%d]: error=%d\n",
3102 le16_to_cpu(head
->outbuf
.type
), result
);
3103 unlocked_usbctlx_complete(hw
, head
);
3107 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3110 /*----------------------------------------------------------------
3111 * hfa384x_usbin_callback
3113 * Callback for URBs on the BULKIN endpoint.
3116 * urb ptr to the completed urb
3125 ----------------------------------------------------------------*/
3126 static void hfa384x_usbin_callback(struct urb
*urb
)
3128 wlandevice_t
*wlandev
= urb
->context
;
3130 hfa384x_usbin_t
*usbin
= (hfa384x_usbin_t
*) urb
->transfer_buffer
;
3131 struct sk_buff
*skb
= NULL
;
3142 if (!wlandev
|| !wlandev
->netdev
|| wlandev
->hwremoved
)
3149 skb
= hw
->rx_urb_skb
;
3150 BUG_ON(!skb
|| (skb
->data
!= urb
->transfer_buffer
));
3152 hw
->rx_urb_skb
= NULL
;
3154 /* Check for error conditions within the URB */
3155 switch (urb
->status
) {
3159 /* Check for short packet */
3160 if (urb
->actual_length
== 0) {
3161 ++(wlandev
->linux_stats
.rx_errors
);
3162 ++(wlandev
->linux_stats
.rx_length_errors
);
3168 printk(KERN_WARNING
"%s rx pipe stalled: requesting reset\n",
3169 wlandev
->netdev
->name
);
3170 if (!test_and_set_bit(WORK_RX_HALT
, &hw
->usb_flags
))
3171 schedule_work(&hw
->usb_work
);
3172 ++(wlandev
->linux_stats
.rx_errors
);
3179 if (!test_and_set_bit(THROTTLE_RX
, &hw
->usb_flags
) &&
3180 !timer_pending(&hw
->throttle
)) {
3181 mod_timer(&hw
->throttle
, jiffies
+ THROTTLE_JIFFIES
);
3183 ++(wlandev
->linux_stats
.rx_errors
);
3188 ++(wlandev
->linux_stats
.rx_over_errors
);
3194 pr_debug("status=%d, device removed.\n", urb
->status
);
3200 pr_debug("status=%d, urb explicitly unlinked.\n", urb
->status
);
3205 pr_debug("urb status=%d, transfer flags=0x%x\n",
3206 urb
->status
, urb
->transfer_flags
);
3207 ++(wlandev
->linux_stats
.rx_errors
);
3212 urb_status
= urb
->status
;
3214 if (action
!= ABORT
) {
3215 /* Repost the RX URB */
3216 result
= submit_rx_urb(hw
, GFP_ATOMIC
);
3220 "Fatal, failed to resubmit rx_urb. error=%d\n",
3225 /* Handle any USB-IN packet */
3226 /* Note: the check of the sw_support field, the type field doesn't
3227 * have bit 12 set like the docs suggest.
3229 type
= le16_to_cpu(usbin
->type
);
3230 if (HFA384x_USB_ISRXFRM(type
)) {
3231 if (action
== HANDLE
) {
3232 if (usbin
->txfrm
.desc
.sw_support
== 0x0123) {
3233 hfa384x_usbin_txcompl(wlandev
, usbin
);
3235 skb_put(skb
, sizeof(*usbin
));
3236 hfa384x_usbin_rx(wlandev
, skb
);
3242 if (HFA384x_USB_ISTXFRM(type
)) {
3243 if (action
== HANDLE
)
3244 hfa384x_usbin_txcompl(wlandev
, usbin
);
3248 case HFA384x_USB_INFOFRM
:
3249 if (action
== ABORT
)
3251 if (action
== HANDLE
)
3252 hfa384x_usbin_info(wlandev
, usbin
);
3255 case HFA384x_USB_CMDRESP
:
3256 case HFA384x_USB_WRIDRESP
:
3257 case HFA384x_USB_RRIDRESP
:
3258 case HFA384x_USB_WMEMRESP
:
3259 case HFA384x_USB_RMEMRESP
:
3260 /* ALWAYS, ALWAYS, ALWAYS handle this CTLX!!!! */
3261 hfa384x_usbin_ctlx(hw
, usbin
, urb_status
);
3264 case HFA384x_USB_BUFAVAIL
:
3265 pr_debug("Received BUFAVAIL packet, frmlen=%d\n",
3266 usbin
->bufavail
.frmlen
);
3269 case HFA384x_USB_ERROR
:
3270 pr_debug("Received USB_ERROR packet, errortype=%d\n",
3271 usbin
->usberror
.errortype
);
3275 pr_debug("Unrecognized USBIN packet, type=%x, status=%d\n",
3276 usbin
->type
, urb_status
);
3286 /*----------------------------------------------------------------
3287 * hfa384x_usbin_ctlx
3289 * We've received a URB containing a Prism2 "response" message.
3290 * This message needs to be matched up with a CTLX on the active
3291 * queue and our state updated accordingly.
3294 * hw ptr to hfa384x_t
3295 * usbin ptr to USB IN packet
3296 * urb_status status of this Bulk-In URB
3305 ----------------------------------------------------------------*/
3306 static void hfa384x_usbin_ctlx(hfa384x_t
*hw
, hfa384x_usbin_t
*usbin
,
3309 hfa384x_usbctlx_t
*ctlx
;
3311 unsigned long flags
;
3314 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3316 /* There can be only one CTLX on the active queue
3317 * at any one time, and this is the CTLX that the
3318 * timers are waiting for.
3320 if (list_empty(&hw
->ctlxq
.active
))
3323 /* Remove the "response timeout". It's possible that
3324 * we are already too late, and that the timeout is
3325 * already running. And that's just too bad for us,
3326 * because we could lose our CTLX from the active
3329 if (del_timer(&hw
->resptimer
) == 0) {
3330 if (hw
->resp_timer_done
== 0) {
3331 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3335 hw
->resp_timer_done
= 1;
3338 ctlx
= get_active_ctlx(hw
);
3340 if (urb_status
!= 0) {
3342 * Bad CTLX, so get rid of it. But we only
3343 * remove it from the active queue if we're no
3344 * longer expecting the OUT URB to complete.
3346 if (unlocked_usbctlx_cancel_async(hw
, ctlx
) == 0)
3349 const u16 intype
= (usbin
->type
& ~cpu_to_le16(0x8000));
3352 * Check that our message is what we're expecting ...
3354 if (ctlx
->outbuf
.type
!= intype
) {
3356 "Expected IN[%d], received IN[%d] - ignored.\n",
3357 le16_to_cpu(ctlx
->outbuf
.type
),
3358 le16_to_cpu(intype
));
3362 /* This URB has succeeded, so grab the data ... */
3363 memcpy(&ctlx
->inbuf
, usbin
, sizeof(ctlx
->inbuf
));
3365 switch (ctlx
->state
) {
3366 case CTLX_REQ_SUBMITTED
:
3368 * We have received our response URB before
3369 * our request has been acknowledged. Odd,
3370 * but our OUT URB is still alive...
3372 pr_debug("Causality violation: please reboot Universe\n");
3373 ctlx
->state
= CTLX_RESP_COMPLETE
;
3376 case CTLX_REQ_COMPLETE
:
3378 * This is the usual path: our request
3379 * has already been acknowledged, and
3380 * now we have received the reply too.
3382 ctlx
->state
= CTLX_COMPLETE
;
3383 unlocked_usbctlx_complete(hw
, ctlx
);
3389 * Throw this CTLX away ...
3392 "Matched IN URB, CTLX[%d] in invalid state(%s)."
3394 le16_to_cpu(ctlx
->outbuf
.type
),
3395 ctlxstr(ctlx
->state
));
3396 if (unlocked_usbctlx_cancel_async(hw
, ctlx
) == 0)
3403 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3406 hfa384x_usbctlxq_run(hw
);
3409 /*----------------------------------------------------------------
3410 * hfa384x_usbin_txcompl
3412 * At this point we have the results of a previous transmit.
3415 * wlandev wlan device
3416 * usbin ptr to the usb transfer buffer
3425 ----------------------------------------------------------------*/
3426 static void hfa384x_usbin_txcompl(wlandevice_t
*wlandev
,
3427 hfa384x_usbin_t
*usbin
)
3431 status
= le16_to_cpu(usbin
->type
); /* yeah I know it says type... */
3433 /* Was there an error? */
3434 if (HFA384x_TXSTATUS_ISERROR(status
))
3435 prism2sta_ev_txexc(wlandev
, status
);
3437 prism2sta_ev_tx(wlandev
, status
);
3440 /*----------------------------------------------------------------
3443 * At this point we have a successful received a rx frame packet.
3446 * wlandev wlan device
3447 * usbin ptr to the usb transfer buffer
3456 ----------------------------------------------------------------*/
3457 static void hfa384x_usbin_rx(wlandevice_t
*wlandev
, struct sk_buff
*skb
)
3459 hfa384x_usbin_t
*usbin
= (hfa384x_usbin_t
*) skb
->data
;
3460 hfa384x_t
*hw
= wlandev
->priv
;
3462 struct p80211_rxmeta
*rxmeta
;
3466 /* Byte order convert once up front. */
3467 usbin
->rxfrm
.desc
.status
= le16_to_cpu(usbin
->rxfrm
.desc
.status
);
3468 usbin
->rxfrm
.desc
.time
= le32_to_cpu(usbin
->rxfrm
.desc
.time
);
3470 /* Now handle frame based on port# */
3471 switch (HFA384x_RXSTATUS_MACPORT_GET(usbin
->rxfrm
.desc
.status
)) {
3473 fc
= le16_to_cpu(usbin
->rxfrm
.desc
.frame_control
);
3475 /* If exclude and we receive an unencrypted, drop it */
3476 if ((wlandev
->hostwep
& HOSTWEP_EXCLUDEUNENCRYPTED
) &&
3477 !WLAN_GET_FC_ISWEP(fc
)) {
3481 data_len
= le16_to_cpu(usbin
->rxfrm
.desc
.data_len
);
3483 /* How much header data do we have? */
3484 hdrlen
= p80211_headerlen(fc
);
3486 /* Pull off the descriptor */
3487 skb_pull(skb
, sizeof(hfa384x_rx_frame_t
));
3489 /* Now shunt the header block up against the data block
3490 * with an "overlapping" copy
3492 memmove(skb_push(skb
, hdrlen
),
3493 &usbin
->rxfrm
.desc
.frame_control
, hdrlen
);
3495 skb
->dev
= wlandev
->netdev
;
3496 skb
->dev
->last_rx
= jiffies
;
3498 /* And set the frame length properly */
3499 skb_trim(skb
, data_len
+ hdrlen
);
3501 /* The prism2 series does not return the CRC */
3502 memset(skb_put(skb
, WLAN_CRC_LEN
), 0xff, WLAN_CRC_LEN
);
3504 skb_reset_mac_header(skb
);
3506 /* Attach the rxmeta, set some stuff */
3507 p80211skb_rxmeta_attach(wlandev
, skb
);
3508 rxmeta
= P80211SKB_RXMETA(skb
);
3509 rxmeta
->mactime
= usbin
->rxfrm
.desc
.time
;
3510 rxmeta
->rxrate
= usbin
->rxfrm
.desc
.rate
;
3511 rxmeta
->signal
= usbin
->rxfrm
.desc
.signal
- hw
->dbmadjust
;
3512 rxmeta
->noise
= usbin
->rxfrm
.desc
.silence
- hw
->dbmadjust
;
3514 prism2sta_ev_rx(wlandev
, skb
);
3519 if (!HFA384x_RXSTATUS_ISFCSERR(usbin
->rxfrm
.desc
.status
)) {
3520 /* Copy to wlansnif skb */
3521 hfa384x_int_rxmonitor(wlandev
, &usbin
->rxfrm
);
3524 pr_debug("Received monitor frame: FCSerr set\n");
3529 printk(KERN_WARNING
"Received frame on unsupported port=%d\n",
3530 HFA384x_RXSTATUS_MACPORT_GET(usbin
->rxfrm
.desc
.status
));
3539 /*----------------------------------------------------------------
3540 * hfa384x_int_rxmonitor
3542 * Helper function for int_rx. Handles monitor frames.
3543 * Note that this function allocates space for the FCS and sets it
3544 * to 0xffffffff. The hfa384x doesn't give us the FCS value but the
3545 * higher layers expect it. 0xffffffff is used as a flag to indicate
3549 * wlandev wlan device structure
3550 * rxfrm rx descriptor read from card in int_rx
3556 * Allocates an skb and passes it up via the PF_PACKET interface.
3559 ----------------------------------------------------------------*/
3560 static void hfa384x_int_rxmonitor(wlandevice_t
*wlandev
,
3561 hfa384x_usb_rxfrm_t
*rxfrm
)
3563 hfa384x_rx_frame_t
*rxdesc
= &(rxfrm
->desc
);
3564 unsigned int hdrlen
= 0;
3565 unsigned int datalen
= 0;
3566 unsigned int skblen
= 0;
3569 struct sk_buff
*skb
;
3570 hfa384x_t
*hw
= wlandev
->priv
;
3572 /* Remember the status, time, and data_len fields are in host order */
3573 /* Figure out how big the frame is */
3574 fc
= le16_to_cpu(rxdesc
->frame_control
);
3575 hdrlen
= p80211_headerlen(fc
);
3576 datalen
= le16_to_cpu(rxdesc
->data_len
);
3578 /* Allocate an ind message+framesize skb */
3579 skblen
= sizeof(struct p80211_caphdr
) + hdrlen
+ datalen
+ WLAN_CRC_LEN
;
3581 /* sanity check the length */
3583 (sizeof(struct p80211_caphdr
) +
3584 WLAN_HDR_A4_LEN
+ WLAN_DATA_MAXLEN
+ WLAN_CRC_LEN
)) {
3585 pr_debug("overlen frm: len=%zd\n",
3586 skblen
- sizeof(struct p80211_caphdr
));
3589 skb
= dev_alloc_skb(skblen
);
3592 "alloc_skb failed trying to allocate %d bytes\n",
3597 /* only prepend the prism header if in the right mode */
3598 if ((wlandev
->netdev
->type
== ARPHRD_IEEE80211_PRISM
) &&
3599 (hw
->sniffhdr
!= 0)) {
3600 struct p80211_caphdr
*caphdr
;
3601 /* The NEW header format! */
3602 datap
= skb_put(skb
, sizeof(struct p80211_caphdr
));
3603 caphdr
= (struct p80211_caphdr
*) datap
;
3605 caphdr
->version
= htonl(P80211CAPTURE_VERSION
);
3606 caphdr
->length
= htonl(sizeof(struct p80211_caphdr
));
3607 caphdr
->mactime
= __cpu_to_be64(rxdesc
->time
) * 1000;
3608 caphdr
->hosttime
= __cpu_to_be64(jiffies
);
3609 caphdr
->phytype
= htonl(4); /* dss_dot11_b */
3610 caphdr
->channel
= htonl(hw
->sniff_channel
);
3611 caphdr
->datarate
= htonl(rxdesc
->rate
);
3612 caphdr
->antenna
= htonl(0); /* unknown */
3613 caphdr
->priority
= htonl(0); /* unknown */
3614 caphdr
->ssi_type
= htonl(3); /* rssi_raw */
3615 caphdr
->ssi_signal
= htonl(rxdesc
->signal
);
3616 caphdr
->ssi_noise
= htonl(rxdesc
->silence
);
3617 caphdr
->preamble
= htonl(0); /* unknown */
3618 caphdr
->encoding
= htonl(1); /* cck */
3621 /* Copy the 802.11 header to the skb
3622 (ctl frames may be less than a full header) */
3623 datap
= skb_put(skb
, hdrlen
);
3624 memcpy(datap
, &(rxdesc
->frame_control
), hdrlen
);
3626 /* If any, copy the data from the card to the skb */
3628 datap
= skb_put(skb
, datalen
);
3629 memcpy(datap
, rxfrm
->data
, datalen
);
3631 /* check for unencrypted stuff if WEP bit set. */
3632 if (*(datap
- hdrlen
+ 1) & 0x40) /* wep set */
3633 if ((*(datap
) == 0xaa) && (*(datap
+ 1) == 0xaa))
3634 /* clear wep; it's the 802.2 header! */
3635 *(datap
- hdrlen
+ 1) &= 0xbf;
3638 if (hw
->sniff_fcs
) {
3640 datap
= skb_put(skb
, WLAN_CRC_LEN
);
3641 memset(datap
, 0xff, WLAN_CRC_LEN
);
3644 /* pass it back up */
3645 prism2sta_ev_rx(wlandev
, skb
);
3650 /*----------------------------------------------------------------
3651 * hfa384x_usbin_info
3653 * At this point we have a successful received a Prism2 info frame.
3656 * wlandev wlan device
3657 * usbin ptr to the usb transfer buffer
3666 ----------------------------------------------------------------*/
3667 static void hfa384x_usbin_info(wlandevice_t
*wlandev
, hfa384x_usbin_t
*usbin
)
3669 usbin
->infofrm
.info
.framelen
=
3670 le16_to_cpu(usbin
->infofrm
.info
.framelen
);
3671 prism2sta_ev_info(wlandev
, &usbin
->infofrm
.info
);
3674 /*----------------------------------------------------------------
3675 * hfa384x_usbout_callback
3677 * Callback for URBs on the BULKOUT endpoint.
3680 * urb ptr to the completed urb
3689 ----------------------------------------------------------------*/
3690 static void hfa384x_usbout_callback(struct urb
*urb
)
3692 wlandevice_t
*wlandev
= urb
->context
;
3693 hfa384x_usbout_t
*usbout
= urb
->transfer_buffer
;
3699 if (wlandev
&& wlandev
->netdev
) {
3701 switch (urb
->status
) {
3703 hfa384x_usbout_tx(wlandev
, usbout
);
3708 hfa384x_t
*hw
= wlandev
->priv
;
3710 "%s tx pipe stalled: requesting reset\n",
3711 wlandev
->netdev
->name
);
3712 if (!test_and_set_bit
3713 (WORK_TX_HALT
, &hw
->usb_flags
))
3714 schedule_work(&hw
->usb_work
);
3715 ++(wlandev
->linux_stats
.tx_errors
);
3723 hfa384x_t
*hw
= wlandev
->priv
;
3725 if (!test_and_set_bit
3726 (THROTTLE_TX
, &hw
->usb_flags
)
3727 && !timer_pending(&hw
->throttle
)) {
3728 mod_timer(&hw
->throttle
,
3729 jiffies
+ THROTTLE_JIFFIES
);
3731 ++(wlandev
->linux_stats
.tx_errors
);
3732 netif_stop_queue(wlandev
->netdev
);
3738 /* Ignorable errors */
3742 printk(KERN_INFO
"unknown urb->status=%d\n",
3744 ++(wlandev
->linux_stats
.tx_errors
);
3750 /*----------------------------------------------------------------
3751 * hfa384x_ctlxout_callback
3753 * Callback for control data on the BULKOUT endpoint.
3756 * urb ptr to the completed urb
3765 ----------------------------------------------------------------*/
3766 static void hfa384x_ctlxout_callback(struct urb
*urb
)
3768 hfa384x_t
*hw
= urb
->context
;
3769 int delete_resptimer
= 0;
3772 hfa384x_usbctlx_t
*ctlx
;
3773 unsigned long flags
;
3775 pr_debug("urb->status=%d\n", urb
->status
);
3779 if ((urb
->status
== -ESHUTDOWN
) ||
3780 (urb
->status
== -ENODEV
) || (hw
== NULL
))
3784 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3787 * Only one CTLX at a time on the "active" list, and
3788 * none at all if we are unplugged. However, we can
3789 * rely on the disconnect function to clean everything
3790 * up if someone unplugged the adapter.
3792 if (list_empty(&hw
->ctlxq
.active
)) {
3793 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3798 * Having something on the "active" queue means
3799 * that we have timers to worry about ...
3801 if (del_timer(&hw
->reqtimer
) == 0) {
3802 if (hw
->req_timer_done
== 0) {
3804 * This timer was actually running while we
3805 * were trying to delete it. Let it terminate
3806 * gracefully instead.
3808 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3812 hw
->req_timer_done
= 1;
3815 ctlx
= get_active_ctlx(hw
);
3817 if (urb
->status
== 0) {
3818 /* Request portion of a CTLX is successful */
3819 switch (ctlx
->state
) {
3820 case CTLX_REQ_SUBMITTED
:
3821 /* This OUT-ACK received before IN */
3822 ctlx
->state
= CTLX_REQ_COMPLETE
;
3825 case CTLX_RESP_COMPLETE
:
3826 /* IN already received before this OUT-ACK,
3827 * so this command must now be complete.
3829 ctlx
->state
= CTLX_COMPLETE
;
3830 unlocked_usbctlx_complete(hw
, ctlx
);
3835 /* This is NOT a valid CTLX "success" state! */
3837 "Illegal CTLX[%d] success state(%s, %d) in OUT URB\n",
3838 le16_to_cpu(ctlx
->outbuf
.type
),
3839 ctlxstr(ctlx
->state
), urb
->status
);
3843 /* If the pipe has stalled then we need to reset it */
3844 if ((urb
->status
== -EPIPE
) &&
3845 !test_and_set_bit(WORK_TX_HALT
, &hw
->usb_flags
)) {
3847 "%s tx pipe stalled: requesting reset\n",
3848 hw
->wlandev
->netdev
->name
);
3849 schedule_work(&hw
->usb_work
);
3852 /* If someone cancels the OUT URB then its status
3853 * should be either -ECONNRESET or -ENOENT.
3855 ctlx
->state
= CTLX_REQ_FAILED
;
3856 unlocked_usbctlx_complete(hw
, ctlx
);
3857 delete_resptimer
= 1;
3862 if (delete_resptimer
) {
3863 timer_ok
= del_timer(&hw
->resptimer
);
3865 hw
->resp_timer_done
= 1;
3868 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3870 if (!timer_ok
&& (hw
->resp_timer_done
== 0)) {
3871 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3876 hfa384x_usbctlxq_run(hw
);
3882 /*----------------------------------------------------------------
3883 * hfa384x_usbctlx_reqtimerfn
3885 * Timer response function for CTLX request timeouts. If this
3886 * function is called, it means that the callback for the OUT
3887 * URB containing a Prism2.x XXX_Request was never called.
3890 * data a ptr to the hfa384x_t
3899 ----------------------------------------------------------------*/
3900 static void hfa384x_usbctlx_reqtimerfn(unsigned long data
)
3902 hfa384x_t
*hw
= (hfa384x_t
*) data
;
3903 unsigned long flags
;
3905 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3907 hw
->req_timer_done
= 1;
3909 /* Removing the hardware automatically empties
3910 * the active list ...
3912 if (!list_empty(&hw
->ctlxq
.active
)) {
3914 * We must ensure that our URB is removed from
3915 * the system, if it hasn't already expired.
3917 hw
->ctlx_urb
.transfer_flags
|= URB_ASYNC_UNLINK
;
3918 if (usb_unlink_urb(&hw
->ctlx_urb
) == -EINPROGRESS
) {
3919 hfa384x_usbctlx_t
*ctlx
= get_active_ctlx(hw
);
3921 ctlx
->state
= CTLX_REQ_FAILED
;
3923 /* This URB was active, but has now been
3924 * cancelled. It will now have a status of
3925 * -ECONNRESET in the callback function.
3927 * We are cancelling this CTLX, so we're
3928 * not going to need to wait for a response.
3929 * The URB's callback function will check
3930 * that this timer is truly dead.
3932 if (del_timer(&hw
->resptimer
) != 0)
3933 hw
->resp_timer_done
= 1;
3937 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3940 /*----------------------------------------------------------------
3941 * hfa384x_usbctlx_resptimerfn
3943 * Timer response function for CTLX response timeouts. If this
3944 * function is called, it means that the callback for the IN
3945 * URB containing a Prism2.x XXX_Response was never called.
3948 * data a ptr to the hfa384x_t
3957 ----------------------------------------------------------------*/
3958 static void hfa384x_usbctlx_resptimerfn(unsigned long data
)
3960 hfa384x_t
*hw
= (hfa384x_t
*) data
;
3961 unsigned long flags
;
3963 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3965 hw
->resp_timer_done
= 1;
3967 /* The active list will be empty if the
3968 * adapter has been unplugged ...
3970 if (!list_empty(&hw
->ctlxq
.active
)) {
3971 hfa384x_usbctlx_t
*ctlx
= get_active_ctlx(hw
);
3973 if (unlocked_usbctlx_cancel_async(hw
, ctlx
) == 0) {
3974 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3975 hfa384x_usbctlxq_run(hw
);
3980 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3987 /*----------------------------------------------------------------
3988 * hfa384x_usb_throttlefn
4001 ----------------------------------------------------------------*/
4002 static void hfa384x_usb_throttlefn(unsigned long data
)
4004 hfa384x_t
*hw
= (hfa384x_t
*) data
;
4005 unsigned long flags
;
4007 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
4010 * We need to check BOTH the RX and the TX throttle controls,
4011 * so we use the bitwise OR instead of the logical OR.
4013 pr_debug("flags=0x%lx\n", hw
->usb_flags
);
4014 if (!hw
->wlandev
->hwremoved
&&
4015 ((test_and_clear_bit(THROTTLE_RX
, &hw
->usb_flags
) &&
4016 !test_and_set_bit(WORK_RX_RESUME
, &hw
->usb_flags
))
4018 (test_and_clear_bit(THROTTLE_TX
, &hw
->usb_flags
) &&
4019 !test_and_set_bit(WORK_TX_RESUME
, &hw
->usb_flags
))
4021 schedule_work(&hw
->usb_work
);
4024 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
4027 /*----------------------------------------------------------------
4028 * hfa384x_usbctlx_submit
4030 * Called from the doxxx functions to submit a CTLX to the queue
4033 * hw ptr to the hw struct
4034 * ctlx ctlx structure to enqueue
4037 * -ENODEV if the adapter is unplugged
4043 * process or interrupt
4044 ----------------------------------------------------------------*/
4045 static int hfa384x_usbctlx_submit(hfa384x_t
*hw
, hfa384x_usbctlx_t
*ctlx
)
4047 unsigned long flags
;
4050 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
4052 if (hw
->wlandev
->hwremoved
) {
4053 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
4056 ctlx
->state
= CTLX_PENDING
;
4057 list_add_tail(&ctlx
->list
, &hw
->ctlxq
.pending
);
4059 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
4060 hfa384x_usbctlxq_run(hw
);
4067 /*----------------------------------------------------------------
4070 * At this point we have finished a send of a frame. Mark the URB
4071 * as available and call ev_alloc to notify higher layers we're
4075 * wlandev wlan device
4076 * usbout ptr to the usb transfer buffer
4085 ----------------------------------------------------------------*/
4086 static void hfa384x_usbout_tx(wlandevice_t
*wlandev
, hfa384x_usbout_t
*usbout
)
4088 prism2sta_ev_alloc(wlandev
);
4091 /*----------------------------------------------------------------
4092 * hfa384x_isgood_pdrcore
4094 * Quick check of PDR codes.
4097 * pdrcode PDR code number (host order)
4106 ----------------------------------------------------------------*/
4107 static int hfa384x_isgood_pdrcode(u16 pdrcode
)
4110 case HFA384x_PDR_END_OF_PDA
:
4111 case HFA384x_PDR_PCB_PARTNUM
:
4112 case HFA384x_PDR_PDAVER
:
4113 case HFA384x_PDR_NIC_SERIAL
:
4114 case HFA384x_PDR_MKK_MEASUREMENTS
:
4115 case HFA384x_PDR_NIC_RAMSIZE
:
4116 case HFA384x_PDR_MFISUPRANGE
:
4117 case HFA384x_PDR_CFISUPRANGE
:
4118 case HFA384x_PDR_NICID
:
4119 case HFA384x_PDR_MAC_ADDRESS
:
4120 case HFA384x_PDR_REGDOMAIN
:
4121 case HFA384x_PDR_ALLOWED_CHANNEL
:
4122 case HFA384x_PDR_DEFAULT_CHANNEL
:
4123 case HFA384x_PDR_TEMPTYPE
:
4124 case HFA384x_PDR_IFR_SETTING
:
4125 case HFA384x_PDR_RFR_SETTING
:
4126 case HFA384x_PDR_HFA3861_BASELINE
:
4127 case HFA384x_PDR_HFA3861_SHADOW
:
4128 case HFA384x_PDR_HFA3861_IFRF
:
4129 case HFA384x_PDR_HFA3861_CHCALSP
:
4130 case HFA384x_PDR_HFA3861_CHCALI
:
4131 case HFA384x_PDR_3842_NIC_CONFIG
:
4132 case HFA384x_PDR_USB_ID
:
4133 case HFA384x_PDR_PCI_ID
:
4134 case HFA384x_PDR_PCI_IFCONF
:
4135 case HFA384x_PDR_PCI_PMCONF
:
4136 case HFA384x_PDR_RFENRGY
:
4137 case HFA384x_PDR_HFA3861_MANF_TESTSP
:
4138 case HFA384x_PDR_HFA3861_MANF_TESTI
:
4143 if (pdrcode
< 0x1000) {
4144 /* code is OK, but we don't know exactly what it is */
4145 pr_debug("Encountered unknown PDR#=0x%04x, "
4146 "assuming it's ok.\n", pdrcode
);
4150 pr_debug("Encountered unknown PDR#=0x%04x, "
4151 "(>=0x1000), assuming it's bad.\n", pdrcode
);
4156 return 0; /* avoid compiler warnings */