1 /* src/prism2/driver/hfa384x_usb.c
3 * Functions that talk to the USB variantof the Intersil hfa384x MAC
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
6 * --------------------------------------------------------------------
10 * The contents of this file are subject to the Mozilla Public
11 * License Version 1.1 (the "License"); you may not use this file
12 * except in compliance with the License. You may obtain a copy of
13 * the License at http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS
16 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 * implied. See the License for the specific language governing
18 * rights and limitations under the License.
20 * Alternatively, the contents of this file may be used under the
21 * terms of the GNU Public License version 2 (the "GPL"), in which
22 * case the provisions of the GPL are applicable instead of the
23 * above. If you wish to allow the use of your version of this file
24 * only under the terms of the GPL and not to allow others to use
25 * your version of this file under the MPL, indicate your decision
26 * by deleting the provisions above and replace them with the notice
27 * and other provisions required by the GPL. If you do not delete
28 * the provisions above, a recipient may use your version of this
29 * file under either the MPL or the GPL.
31 * --------------------------------------------------------------------
33 * Inquiries regarding the linux-wlan Open Source project can be
36 * AbsoluteValue Systems Inc.
38 * http://www.linux-wlan.com
40 * --------------------------------------------------------------------
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
45 * --------------------------------------------------------------------
47 * This file implements functions that correspond to the prism2/hfa384x
48 * 802.11 MAC hardware and firmware host interface.
50 * The functions can be considered to represent several levels of
51 * abstraction. The lowest level functions are simply C-callable wrappers
52 * around the register accesses. The next higher level represents C-callable
53 * prism2 API functions that match the Intersil documentation as closely
54 * as is reasonable. The next higher layer implements common sequences
55 * of invokations of the API layer (e.g. write to bap, followed by cmd).
58 * hfa384x_drvr_xxx Highest level abstractions provided by the
59 * hfa384x code. They are driver defined wrappers
60 * for common sequences. These functions generally
61 * use the services of the lower levels.
63 * hfa384x_drvr_xxxconfig An example of the drvr level abstraction. These
64 * functions are wrappers for the RID get/set
65 * sequence. They call copy_[to|from]_bap() and
66 * cmd_access(). These functions operate on the
67 * RIDs and buffers without validation. The caller
68 * is responsible for that.
70 * API wrapper functions:
71 * hfa384x_cmd_xxx functions that provide access to the f/w commands.
72 * The function arguments correspond to each command
73 * argument, even command arguments that get packed
74 * into single registers. These functions _just_
75 * issue the command by setting the cmd/parm regs
76 * & reading the status/resp regs. Additional
77 * activities required to fully use a command
78 * (read/write from/to bap, get/set int status etc.)
79 * are implemented separately. Think of these as
80 * C-callable prism2 commands.
82 * Lowest Layer Functions:
83 * hfa384x_docmd_xxx These functions implement the sequence required
84 * to issue any prism2 command. Primarily used by the
85 * hfa384x_cmd_xxx functions.
87 * hfa384x_bap_xxx BAP read/write access functions.
88 * Note: we usually use BAP0 for non-interrupt context
89 * and BAP1 for interrupt context.
91 * hfa384x_dl_xxx download related functions.
93 * Driver State Issues:
94 * Note that there are two pairs of functions that manage the
95 * 'initialized' and 'running' states of the hw/MAC combo. The four
96 * functions are create(), destroy(), start(), and stop(). create()
97 * sets up the data structures required to support the hfa384x_*
98 * functions and destroy() cleans them up. The start() function gets
99 * the actual hardware running and enables the interrupts. The stop()
100 * function shuts the hardware down. The sequence should be:
104 * . Do interesting things w/ the hardware
109 * Note that destroy() can be called without calling stop() first.
110 * --------------------------------------------------------------------
113 #include <linux/module.h>
114 #include <linux/kernel.h>
115 #include <linux/sched.h>
116 #include <linux/types.h>
117 #include <linux/slab.h>
118 #include <linux/wireless.h>
119 #include <linux/netdevice.h>
120 #include <linux/timer.h>
122 #include <linux/delay.h>
123 #include <asm/byteorder.h>
124 #include <asm/bitops.h>
125 #include <linux/list.h>
126 #include <linux/usb.h>
127 #include <linux/byteorder/generic.h>
129 #define SUBMIT_URB(u,f) usb_submit_urb(u,f)
131 /*================================================================*/
132 /* Project Includes */
134 #include "p80211types.h"
135 #include "p80211hdr.h"
136 #include "p80211mgmt.h"
137 #include "p80211conv.h"
138 #include "p80211msg.h"
139 #include "p80211netdev.h"
140 #include "p80211req.h"
141 #include "p80211metadef.h"
142 #include "p80211metastruct.h"
144 #include "prism2mgmt.h"
150 typedef enum cmd_mode CMD_MODE
;
152 #define THROTTLE_JIFFIES (HZ/8)
153 #define URB_ASYNC_UNLINK 0
154 #define USB_QUEUE_BULK 0
156 #define ROUNDUP64(a) (((a)+63)&~63)
159 static void dbprint_urb(struct urb
*urb
);
163 hfa384x_int_rxmonitor(wlandevice_t
* wlandev
, hfa384x_usb_rxfrm_t
* rxfrm
);
165 static void hfa384x_usb_defer(struct work_struct
*data
);
167 static int submit_rx_urb(hfa384x_t
* hw
, gfp_t flags
);
169 static int submit_tx_urb(hfa384x_t
* hw
, struct urb
*tx_urb
, gfp_t flags
);
171 /*---------------------------------------------------*/
173 static void hfa384x_usbout_callback(struct urb
*urb
);
174 static void hfa384x_ctlxout_callback(struct urb
*urb
);
175 static void hfa384x_usbin_callback(struct urb
*urb
);
178 hfa384x_usbin_txcompl(wlandevice_t
* wlandev
, hfa384x_usbin_t
* usbin
);
180 static void hfa384x_usbin_rx(wlandevice_t
* wlandev
, struct sk_buff
*skb
);
182 static void hfa384x_usbin_info(wlandevice_t
* wlandev
, hfa384x_usbin_t
* usbin
);
185 hfa384x_usbout_tx(wlandevice_t
* wlandev
, hfa384x_usbout_t
* usbout
);
187 static void hfa384x_usbin_ctlx(hfa384x_t
* hw
, hfa384x_usbin_t
* usbin
,
190 /*---------------------------------------------------*/
191 /* Functions to support the prism2 usb command queue */
193 static void hfa384x_usbctlxq_run(hfa384x_t
* hw
);
195 static void hfa384x_usbctlx_reqtimerfn(unsigned long data
);
197 static void hfa384x_usbctlx_resptimerfn(unsigned long data
);
199 static void hfa384x_usb_throttlefn(unsigned long data
);
201 static void hfa384x_usbctlx_completion_task(unsigned long data
);
203 static void hfa384x_usbctlx_reaper_task(unsigned long data
);
205 static int hfa384x_usbctlx_submit(hfa384x_t
* hw
, hfa384x_usbctlx_t
* ctlx
);
207 static void unlocked_usbctlx_complete(hfa384x_t
* hw
, hfa384x_usbctlx_t
* ctlx
);
209 struct usbctlx_completor
{
210 int (*complete
) (struct usbctlx_completor
*);
212 typedef struct usbctlx_completor usbctlx_completor_t
;
215 hfa384x_usbctlx_complete_sync(hfa384x_t
* hw
,
216 hfa384x_usbctlx_t
* ctlx
,
217 usbctlx_completor_t
* completor
);
220 unlocked_usbctlx_cancel_async(hfa384x_t
* hw
, hfa384x_usbctlx_t
* ctlx
);
222 static void hfa384x_cb_status(hfa384x_t
* hw
, const hfa384x_usbctlx_t
* ctlx
);
224 static void hfa384x_cb_rrid(hfa384x_t
* hw
, const hfa384x_usbctlx_t
* ctlx
);
227 usbctlx_get_status(const hfa384x_usb_cmdresp_t
* cmdresp
,
228 hfa384x_cmdresult_t
* result
);
231 usbctlx_get_rridresult(const hfa384x_usb_rridresp_t
* rridresp
,
232 hfa384x_rridresult_t
* result
);
234 /*---------------------------------------------------*/
235 /* Low level req/resp CTLX formatters and submitters */
237 hfa384x_docmd(hfa384x_t
* hw
,
239 hfa384x_metacmd_t
* cmd
,
240 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
243 hfa384x_dorrid(hfa384x_t
* hw
,
247 unsigned int riddatalen
,
248 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
251 hfa384x_dowrid(hfa384x_t
* hw
,
255 unsigned int riddatalen
,
256 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
259 hfa384x_dormem(hfa384x_t
* hw
,
265 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
268 hfa384x_dowmem(hfa384x_t
* hw
,
274 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
276 static int hfa384x_isgood_pdrcode(u16 pdrcode
);
278 static inline const char *ctlxstr(CTLX_STATE s
)
280 static const char *ctlx_str
[] = {
285 "Request packet submitted",
286 "Request packet completed",
287 "Response packet completed"
293 static inline hfa384x_usbctlx_t
*get_active_ctlx(hfa384x_t
* hw
)
295 return list_entry(hw
->ctlxq
.active
.next
, hfa384x_usbctlx_t
, list
);
299 void dbprint_urb(struct urb
*urb
)
301 pr_debug("urb->pipe=0x%08x\n", urb
->pipe
);
302 pr_debug("urb->status=0x%08x\n", urb
->status
);
303 pr_debug("urb->transfer_flags=0x%08x\n", urb
->transfer_flags
);
304 pr_debug("urb->transfer_buffer=0x%08x\n",
305 (unsigned int)urb
->transfer_buffer
);
306 pr_debug("urb->transfer_buffer_length=0x%08x\n",
307 urb
->transfer_buffer_length
);
308 pr_debug("urb->actual_length=0x%08x\n", urb
->actual_length
);
309 pr_debug("urb->bandwidth=0x%08x\n", urb
->bandwidth
);
310 pr_debug("urb->setup_packet(ctl)=0x%08x\n",
311 (unsigned int)urb
->setup_packet
);
312 pr_debug("urb->start_frame(iso/irq)=0x%08x\n", urb
->start_frame
);
313 pr_debug("urb->interval(irq)=0x%08x\n", urb
->interval
);
314 pr_debug("urb->error_count(iso)=0x%08x\n", urb
->error_count
);
315 pr_debug("urb->timeout=0x%08x\n", urb
->timeout
);
316 pr_debug("urb->context=0x%08x\n", (unsigned int)urb
->context
);
317 pr_debug("urb->complete=0x%08x\n", (unsigned int)urb
->complete
);
321 /*----------------------------------------------------------------
324 * Listen for input data on the BULK-IN pipe. If the pipe has
325 * stalled then schedule it to be reset.
329 * memflags memory allocation flags
332 * error code from submission
336 ----------------------------------------------------------------*/
337 static int submit_rx_urb(hfa384x_t
* hw
, gfp_t memflags
)
342 skb
= dev_alloc_skb(sizeof(hfa384x_usbin_t
));
348 /* Post the IN urb */
349 usb_fill_bulk_urb(&hw
->rx_urb
, hw
->usb
,
351 skb
->data
, sizeof(hfa384x_usbin_t
),
352 hfa384x_usbin_callback
, hw
->wlandev
);
354 hw
->rx_urb_skb
= skb
;
357 if (!hw
->wlandev
->hwremoved
&& !test_bit(WORK_RX_HALT
, &hw
->usb_flags
)) {
358 result
= SUBMIT_URB(&hw
->rx_urb
, memflags
);
360 /* Check whether we need to reset the RX pipe */
361 if (result
== -EPIPE
) {
363 "%s rx pipe stalled: requesting reset\n",
364 hw
->wlandev
->netdev
->name
);
365 if (!test_and_set_bit(WORK_RX_HALT
, &hw
->usb_flags
))
366 schedule_work(&hw
->usb_work
);
370 /* Don't leak memory if anything should go wrong */
373 hw
->rx_urb_skb
= NULL
;
380 /*----------------------------------------------------------------
383 * Prepares and submits the URB of transmitted data. If the
384 * submission fails then it will schedule the output pipe to
389 * tx_urb URB of data for tranmission
390 * memflags memory allocation flags
393 * error code from submission
397 ----------------------------------------------------------------*/
398 static int submit_tx_urb(hfa384x_t
* hw
, struct urb
*tx_urb
, gfp_t memflags
)
400 struct net_device
*netdev
= hw
->wlandev
->netdev
;
404 if (netif_running(netdev
)) {
406 if (!hw
->wlandev
->hwremoved
407 && !test_bit(WORK_TX_HALT
, &hw
->usb_flags
)) {
408 result
= SUBMIT_URB(tx_urb
, memflags
);
410 /* Test whether we need to reset the TX pipe */
411 if (result
== -EPIPE
) {
413 "%s tx pipe stalled: requesting reset\n",
415 set_bit(WORK_TX_HALT
, &hw
->usb_flags
);
416 schedule_work(&hw
->usb_work
);
417 } else if (result
== 0) {
418 netif_stop_queue(netdev
);
426 /*----------------------------------------------------------------
429 * There are some things that the USB stack cannot do while
430 * in interrupt context, so we arrange this function to run
431 * in process context.
434 * hw device structure
440 * process (by design)
441 ----------------------------------------------------------------*/
442 static void hfa384x_usb_defer(struct work_struct
*data
)
444 hfa384x_t
*hw
= container_of(data
, struct hfa384x
, usb_work
);
445 struct net_device
*netdev
= hw
->wlandev
->netdev
;
447 /* Don't bother trying to reset anything if the plug
448 * has been pulled ...
450 if (hw
->wlandev
->hwremoved
)
453 /* Reception has stopped: try to reset the input pipe */
454 if (test_bit(WORK_RX_HALT
, &hw
->usb_flags
)) {
457 usb_kill_urb(&hw
->rx_urb
); /* Cannot be holding spinlock! */
459 ret
= usb_clear_halt(hw
->usb
, hw
->endp_in
);
462 "Failed to clear rx pipe for %s: err=%d\n",
465 printk(KERN_INFO
"%s rx pipe reset complete.\n",
467 clear_bit(WORK_RX_HALT
, &hw
->usb_flags
);
468 set_bit(WORK_RX_RESUME
, &hw
->usb_flags
);
472 /* Resume receiving data back from the device. */
473 if (test_bit(WORK_RX_RESUME
, &hw
->usb_flags
)) {
476 ret
= submit_rx_urb(hw
, GFP_KERNEL
);
479 "Failed to resume %s rx pipe.\n", netdev
->name
);
481 clear_bit(WORK_RX_RESUME
, &hw
->usb_flags
);
485 /* Transmission has stopped: try to reset the output pipe */
486 if (test_bit(WORK_TX_HALT
, &hw
->usb_flags
)) {
489 usb_kill_urb(&hw
->tx_urb
);
490 ret
= usb_clear_halt(hw
->usb
, hw
->endp_out
);
493 "Failed to clear tx pipe for %s: err=%d\n",
496 printk(KERN_INFO
"%s tx pipe reset complete.\n",
498 clear_bit(WORK_TX_HALT
, &hw
->usb_flags
);
499 set_bit(WORK_TX_RESUME
, &hw
->usb_flags
);
501 /* Stopping the BULK-OUT pipe also blocked
502 * us from sending any more CTLX URBs, so
503 * we need to re-run our queue ...
505 hfa384x_usbctlxq_run(hw
);
509 /* Resume transmitting. */
510 if (test_and_clear_bit(WORK_TX_RESUME
, &hw
->usb_flags
))
511 netif_wake_queue(hw
->wlandev
->netdev
);
514 /*----------------------------------------------------------------
517 * Sets up the hfa384x_t data structure for use. Note this
518 * does _not_ intialize the actual hardware, just the data structures
519 * we use to keep track of its state.
522 * hw device structure
523 * irq device irq number
524 * iobase i/o base address for register access
525 * membase memory base address for register access
534 ----------------------------------------------------------------*/
535 void hfa384x_create(hfa384x_t
* hw
, struct usb_device
*usb
)
537 memset(hw
, 0, sizeof(hfa384x_t
));
540 /* set up the endpoints */
541 hw
->endp_in
= usb_rcvbulkpipe(usb
, 1);
542 hw
->endp_out
= usb_sndbulkpipe(usb
, 2);
544 /* Set up the waitq */
545 init_waitqueue_head(&hw
->cmdq
);
547 /* Initialize the command queue */
548 spin_lock_init(&hw
->ctlxq
.lock
);
549 INIT_LIST_HEAD(&hw
->ctlxq
.pending
);
550 INIT_LIST_HEAD(&hw
->ctlxq
.active
);
551 INIT_LIST_HEAD(&hw
->ctlxq
.completing
);
552 INIT_LIST_HEAD(&hw
->ctlxq
.reapable
);
554 /* Initialize the authentication queue */
555 skb_queue_head_init(&hw
->authq
);
557 tasklet_init(&hw
->reaper_bh
,
558 hfa384x_usbctlx_reaper_task
, (unsigned long)hw
);
559 tasklet_init(&hw
->completion_bh
,
560 hfa384x_usbctlx_completion_task
, (unsigned long)hw
);
561 INIT_WORK(&hw
->link_bh
, prism2sta_processing_defer
);
562 INIT_WORK(&hw
->usb_work
, hfa384x_usb_defer
);
564 init_timer(&hw
->throttle
);
565 hw
->throttle
.function
= hfa384x_usb_throttlefn
;
566 hw
->throttle
.data
= (unsigned long)hw
;
568 init_timer(&hw
->resptimer
);
569 hw
->resptimer
.function
= hfa384x_usbctlx_resptimerfn
;
570 hw
->resptimer
.data
= (unsigned long)hw
;
572 init_timer(&hw
->reqtimer
);
573 hw
->reqtimer
.function
= hfa384x_usbctlx_reqtimerfn
;
574 hw
->reqtimer
.data
= (unsigned long)hw
;
576 usb_init_urb(&hw
->rx_urb
);
577 usb_init_urb(&hw
->tx_urb
);
578 usb_init_urb(&hw
->ctlx_urb
);
580 hw
->link_status
= HFA384x_LINK_NOTCONNECTED
;
581 hw
->state
= HFA384x_STATE_INIT
;
583 INIT_WORK(&hw
->commsqual_bh
, prism2sta_commsqual_defer
);
584 init_timer(&hw
->commsqual_timer
);
585 hw
->commsqual_timer
.data
= (unsigned long)hw
;
586 hw
->commsqual_timer
.function
= prism2sta_commsqual_timer
;
589 /*----------------------------------------------------------------
592 * Partner to hfa384x_create(). This function cleans up the hw
593 * structure so that it can be freed by the caller using a simple
594 * kfree. Currently, this function is just a placeholder. If, at some
595 * point in the future, an hw in the 'shutdown' state requires a 'deep'
596 * kfree, this is where it should be done. Note that if this function
597 * is called on a _running_ hw structure, the drvr_stop() function is
601 * hw device structure
604 * nothing, this function is not allowed to fail.
610 ----------------------------------------------------------------*/
611 void hfa384x_destroy(hfa384x_t
* hw
)
615 if (hw
->state
== HFA384x_STATE_RUNNING
)
616 hfa384x_drvr_stop(hw
);
617 hw
->state
= HFA384x_STATE_PREINIT
;
619 if (hw
->scanresults
) {
620 kfree(hw
->scanresults
);
621 hw
->scanresults
= NULL
;
624 /* Now to clean out the auth queue */
625 while ((skb
= skb_dequeue(&hw
->authq
)))
629 static hfa384x_usbctlx_t
*usbctlx_alloc(void)
631 hfa384x_usbctlx_t
*ctlx
;
633 ctlx
= kmalloc(sizeof(*ctlx
), in_interrupt()? GFP_ATOMIC
: GFP_KERNEL
);
635 memset(ctlx
, 0, sizeof(*ctlx
));
636 init_completion(&ctlx
->done
);
643 usbctlx_get_status(const hfa384x_usb_cmdresp_t
* cmdresp
,
644 hfa384x_cmdresult_t
* result
)
646 result
->status
= le16_to_cpu(cmdresp
->status
);
647 result
->resp0
= le16_to_cpu(cmdresp
->resp0
);
648 result
->resp1
= le16_to_cpu(cmdresp
->resp1
);
649 result
->resp2
= le16_to_cpu(cmdresp
->resp2
);
651 pr_debug("cmdresult:status=0x%04x "
652 "resp0=0x%04x resp1=0x%04x resp2=0x%04x\n",
653 result
->status
, result
->resp0
, result
->resp1
, result
->resp2
);
655 return result
->status
& HFA384x_STATUS_RESULT
;
659 usbctlx_get_rridresult(const hfa384x_usb_rridresp_t
* rridresp
,
660 hfa384x_rridresult_t
* result
)
662 result
->rid
= le16_to_cpu(rridresp
->rid
);
663 result
->riddata
= rridresp
->data
;
664 result
->riddata_len
= ((le16_to_cpu(rridresp
->frmlen
) - 1) * 2);
668 /*----------------------------------------------------------------
670 * This completor must be passed to hfa384x_usbctlx_complete_sync()
671 * when processing a CTLX that returns a hfa384x_cmdresult_t structure.
672 ----------------------------------------------------------------*/
673 struct usbctlx_cmd_completor
{
674 usbctlx_completor_t head
;
676 const hfa384x_usb_cmdresp_t
*cmdresp
;
677 hfa384x_cmdresult_t
*result
;
679 typedef struct usbctlx_cmd_completor usbctlx_cmd_completor_t
;
681 static int usbctlx_cmd_completor_fn(usbctlx_completor_t
* head
)
683 usbctlx_cmd_completor_t
*complete
= (usbctlx_cmd_completor_t
*) head
;
684 return usbctlx_get_status(complete
->cmdresp
, complete
->result
);
687 static inline usbctlx_completor_t
*init_cmd_completor(usbctlx_cmd_completor_t
*
690 hfa384x_usb_cmdresp_t
*
692 hfa384x_cmdresult_t
*
695 completor
->head
.complete
= usbctlx_cmd_completor_fn
;
696 completor
->cmdresp
= cmdresp
;
697 completor
->result
= result
;
698 return &(completor
->head
);
701 /*----------------------------------------------------------------
703 * This completor must be passed to hfa384x_usbctlx_complete_sync()
704 * when processing a CTLX that reads a RID.
705 ----------------------------------------------------------------*/
706 struct usbctlx_rrid_completor
{
707 usbctlx_completor_t head
;
709 const hfa384x_usb_rridresp_t
*rridresp
;
711 unsigned int riddatalen
;
713 typedef struct usbctlx_rrid_completor usbctlx_rrid_completor_t
;
715 static int usbctlx_rrid_completor_fn(usbctlx_completor_t
* head
)
717 usbctlx_rrid_completor_t
*complete
= (usbctlx_rrid_completor_t
*) head
;
718 hfa384x_rridresult_t rridresult
;
720 usbctlx_get_rridresult(complete
->rridresp
, &rridresult
);
722 /* Validate the length, note body len calculation in bytes */
723 if (rridresult
.riddata_len
!= complete
->riddatalen
) {
725 "RID len mismatch, rid=0x%04x hlen=%d fwlen=%d\n",
727 complete
->riddatalen
, rridresult
.riddata_len
);
731 memcpy(complete
->riddata
, rridresult
.riddata
, complete
->riddatalen
);
735 static inline usbctlx_completor_t
*init_rrid_completor(usbctlx_rrid_completor_t
738 hfa384x_usb_rridresp_t
*
739 rridresp
, void *riddata
,
740 unsigned int riddatalen
)
742 completor
->head
.complete
= usbctlx_rrid_completor_fn
;
743 completor
->rridresp
= rridresp
;
744 completor
->riddata
= riddata
;
745 completor
->riddatalen
= riddatalen
;
746 return &(completor
->head
);
749 /*----------------------------------------------------------------
751 * Interprets the results of a synchronous RID-write
752 ----------------------------------------------------------------*/
753 typedef usbctlx_cmd_completor_t usbctlx_wrid_completor_t
;
754 #define init_wrid_completor init_cmd_completor
756 /*----------------------------------------------------------------
758 * Interprets the results of a synchronous memory-write
759 ----------------------------------------------------------------*/
760 typedef usbctlx_cmd_completor_t usbctlx_wmem_completor_t
;
761 #define init_wmem_completor init_cmd_completor
763 /*----------------------------------------------------------------
765 * Interprets the results of a synchronous memory-read
766 ----------------------------------------------------------------*/
767 struct usbctlx_rmem_completor
{
768 usbctlx_completor_t head
;
770 const hfa384x_usb_rmemresp_t
*rmemresp
;
774 typedef struct usbctlx_rmem_completor usbctlx_rmem_completor_t
;
776 static int usbctlx_rmem_completor_fn(usbctlx_completor_t
* head
)
778 usbctlx_rmem_completor_t
*complete
= (usbctlx_rmem_completor_t
*) head
;
780 pr_debug("rmemresp:len=%d\n", complete
->rmemresp
->frmlen
);
781 memcpy(complete
->data
, complete
->rmemresp
->data
, complete
->len
);
785 static inline usbctlx_completor_t
*init_rmem_completor(usbctlx_rmem_completor_t
787 hfa384x_usb_rmemresp_t
788 * rmemresp
, void *data
,
791 completor
->head
.complete
= usbctlx_rmem_completor_fn
;
792 completor
->rmemresp
= rmemresp
;
793 completor
->data
= data
;
794 completor
->len
= len
;
795 return &(completor
->head
);
798 /*----------------------------------------------------------------
801 * Ctlx_complete handler for async CMD type control exchanges.
802 * mark the hw struct as such.
804 * Note: If the handling is changed here, it should probably be
805 * changed in docmd as well.
809 * ctlx completed CTLX
818 ----------------------------------------------------------------*/
819 static void hfa384x_cb_status(hfa384x_t
* hw
, const hfa384x_usbctlx_t
* ctlx
)
821 if (ctlx
->usercb
!= NULL
) {
822 hfa384x_cmdresult_t cmdresult
;
824 if (ctlx
->state
!= CTLX_COMPLETE
) {
825 memset(&cmdresult
, 0, sizeof(cmdresult
));
827 HFA384x_STATUS_RESULT_SET(HFA384x_CMD_ERR
);
829 usbctlx_get_status(&ctlx
->inbuf
.cmdresp
, &cmdresult
);
832 ctlx
->usercb(hw
, &cmdresult
, ctlx
->usercb_data
);
836 /*----------------------------------------------------------------
839 * CTLX completion handler for async RRID type control exchanges.
841 * Note: If the handling is changed here, it should probably be
842 * changed in dorrid as well.
846 * ctlx completed CTLX
855 ----------------------------------------------------------------*/
856 static void hfa384x_cb_rrid(hfa384x_t
* hw
, const hfa384x_usbctlx_t
* ctlx
)
858 if (ctlx
->usercb
!= NULL
) {
859 hfa384x_rridresult_t rridresult
;
861 if (ctlx
->state
!= CTLX_COMPLETE
) {
862 memset(&rridresult
, 0, sizeof(rridresult
));
863 rridresult
.rid
= le16_to_cpu(ctlx
->outbuf
.rridreq
.rid
);
865 usbctlx_get_rridresult(&ctlx
->inbuf
.rridresp
,
869 ctlx
->usercb(hw
, &rridresult
, ctlx
->usercb_data
);
873 static inline int hfa384x_docmd_wait(hfa384x_t
* hw
, hfa384x_metacmd_t
* cmd
)
875 return hfa384x_docmd(hw
, DOWAIT
, cmd
, NULL
, NULL
, NULL
);
879 hfa384x_docmd_async(hfa384x_t
* hw
,
880 hfa384x_metacmd_t
* cmd
,
881 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
883 return hfa384x_docmd(hw
, DOASYNC
, cmd
, cmdcb
, usercb
, usercb_data
);
887 hfa384x_dorrid_wait(hfa384x_t
* hw
, u16 rid
, void *riddata
,
888 unsigned int riddatalen
)
890 return hfa384x_dorrid(hw
, DOWAIT
,
891 rid
, riddata
, riddatalen
, NULL
, NULL
, NULL
);
895 hfa384x_dorrid_async(hfa384x_t
* hw
,
896 u16 rid
, void *riddata
, unsigned int riddatalen
,
898 ctlx_usercb_t usercb
, void *usercb_data
)
900 return hfa384x_dorrid(hw
, DOASYNC
,
901 rid
, riddata
, riddatalen
,
902 cmdcb
, usercb
, usercb_data
);
906 hfa384x_dowrid_wait(hfa384x_t
* hw
, u16 rid
, void *riddata
,
907 unsigned int riddatalen
)
909 return hfa384x_dowrid(hw
, DOWAIT
,
910 rid
, riddata
, riddatalen
, NULL
, NULL
, NULL
);
914 hfa384x_dowrid_async(hfa384x_t
* hw
,
915 u16 rid
, void *riddata
, unsigned int riddatalen
,
917 ctlx_usercb_t usercb
, void *usercb_data
)
919 return hfa384x_dowrid(hw
, DOASYNC
,
920 rid
, riddata
, riddatalen
,
921 cmdcb
, usercb
, usercb_data
);
925 hfa384x_dormem_wait(hfa384x_t
* hw
,
926 u16 page
, u16 offset
, void *data
, unsigned int len
)
928 return hfa384x_dormem(hw
, DOWAIT
,
929 page
, offset
, data
, len
, NULL
, NULL
, NULL
);
933 hfa384x_dormem_async(hfa384x_t
* hw
,
934 u16 page
, u16 offset
, void *data
, unsigned int len
,
936 ctlx_usercb_t usercb
, void *usercb_data
)
938 return hfa384x_dormem(hw
, DOASYNC
,
939 page
, offset
, data
, len
,
940 cmdcb
, usercb
, usercb_data
);
944 hfa384x_dowmem_wait(hfa384x_t
* hw
,
945 u16 page
, u16 offset
, void *data
, unsigned int len
)
947 return hfa384x_dowmem(hw
, DOWAIT
,
948 page
, offset
, data
, len
, NULL
, NULL
, NULL
);
952 hfa384x_dowmem_async(hfa384x_t
* hw
,
958 ctlx_usercb_t usercb
, void *usercb_data
)
960 return hfa384x_dowmem(hw
, DOASYNC
,
961 page
, offset
, data
, len
,
962 cmdcb
, usercb
, usercb_data
);
965 /*----------------------------------------------------------------
966 * hfa384x_cmd_initialize
968 * Issues the initialize command and sets the hw->state based
972 * hw device structure
976 * >0 f/w reported error - f/w status code
977 * <0 driver reported error
983 ----------------------------------------------------------------*/
984 int hfa384x_cmd_initialize(hfa384x_t
* hw
)
988 hfa384x_metacmd_t cmd
;
990 cmd
.cmd
= HFA384x_CMDCODE_INIT
;
995 result
= hfa384x_docmd_wait(hw
, &cmd
);
997 pr_debug("cmdresp.init: "
998 "status=0x%04x, resp0=0x%04x, "
999 "resp1=0x%04x, resp2=0x%04x\n",
1001 cmd
.result
.resp0
, cmd
.result
.resp1
, cmd
.result
.resp2
);
1003 for (i
= 0; i
< HFA384x_NUMPORTS_MAX
; i
++)
1004 hw
->port_enabled
[i
] = 0;
1007 hw
->link_status
= HFA384x_LINK_NOTCONNECTED
;
1012 /*----------------------------------------------------------------
1013 * hfa384x_cmd_disable
1015 * Issues the disable command to stop communications on one of
1019 * hw device structure
1020 * macport MAC port number (host order)
1024 * >0 f/w reported failure - f/w status code
1025 * <0 driver reported error (timeout|bad arg)
1031 ----------------------------------------------------------------*/
1032 int hfa384x_cmd_disable(hfa384x_t
* hw
, u16 macport
)
1035 hfa384x_metacmd_t cmd
;
1037 cmd
.cmd
= HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DISABLE
) |
1038 HFA384x_CMD_MACPORT_SET(macport
);
1043 result
= hfa384x_docmd_wait(hw
, &cmd
);
1048 /*----------------------------------------------------------------
1049 * hfa384x_cmd_enable
1051 * Issues the enable command to enable communications on one of
1055 * hw device structure
1056 * macport MAC port number
1060 * >0 f/w reported failure - f/w status code
1061 * <0 driver reported error (timeout|bad arg)
1067 ----------------------------------------------------------------*/
1068 int hfa384x_cmd_enable(hfa384x_t
* hw
, u16 macport
)
1071 hfa384x_metacmd_t cmd
;
1073 cmd
.cmd
= HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ENABLE
) |
1074 HFA384x_CMD_MACPORT_SET(macport
);
1079 result
= hfa384x_docmd_wait(hw
, &cmd
);
1084 /*----------------------------------------------------------------
1085 * hfa384x_cmd_monitor
1087 * Enables the 'monitor mode' of the MAC. Here's the description of
1088 * monitor mode that I've received thus far:
1090 * "The "monitor mode" of operation is that the MAC passes all
1091 * frames for which the PLCP checks are correct. All received
1092 * MPDUs are passed to the host with MAC Port = 7, with a
1093 * receive status of good, FCS error, or undecryptable. Passing
1094 * certain MPDUs is a violation of the 802.11 standard, but useful
1095 * for a debugging tool." Normal communication is not possible
1096 * while monitor mode is enabled.
1099 * hw device structure
1100 * enable a code (0x0b|0x0f) that enables/disables
1101 * monitor mode. (host order)
1105 * >0 f/w reported failure - f/w status code
1106 * <0 driver reported error (timeout|bad arg)
1112 ----------------------------------------------------------------*/
1113 int hfa384x_cmd_monitor(hfa384x_t
* hw
, u16 enable
)
1116 hfa384x_metacmd_t cmd
;
1118 cmd
.cmd
= HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR
) |
1119 HFA384x_CMD_AINFO_SET(enable
);
1124 result
= hfa384x_docmd_wait(hw
, &cmd
);
1129 /*----------------------------------------------------------------
1130 * hfa384x_cmd_download
1132 * Sets the controls for the MAC controller code/data download
1133 * process. The arguments set the mode and address associated
1134 * with a download. Note that the aux registers should be enabled
1135 * prior to setting one of the download enable modes.
1138 * hw device structure
1139 * mode 0 - Disable programming and begin code exec
1140 * 1 - Enable volatile mem programming
1141 * 2 - Enable non-volatile mem programming
1142 * 3 - Program non-volatile section from NV download
1146 * highaddr For mode 1, sets the high & low order bits of
1147 * the "destination address". This address will be
1148 * the execution start address when download is
1149 * subsequently disabled.
1150 * For mode 2, sets the high & low order bits of
1151 * the destination in NV ram.
1152 * For modes 0 & 3, should be zero. (host order)
1153 * NOTE: these are CMD format.
1154 * codelen Length of the data to write in mode 2,
1155 * zero otherwise. (host order)
1159 * >0 f/w reported failure - f/w status code
1160 * <0 driver reported error (timeout|bad arg)
1166 ----------------------------------------------------------------*/
1167 int hfa384x_cmd_download(hfa384x_t
* hw
, u16 mode
, u16 lowaddr
,
1168 u16 highaddr
, u16 codelen
)
1171 hfa384x_metacmd_t cmd
;
1173 pr_debug("mode=%d, lowaddr=0x%04x, highaddr=0x%04x, codelen=%d\n",
1174 mode
, lowaddr
, highaddr
, codelen
);
1176 cmd
.cmd
= (HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DOWNLD
) |
1177 HFA384x_CMD_PROGMODE_SET(mode
));
1179 cmd
.parm0
= lowaddr
;
1180 cmd
.parm1
= highaddr
;
1181 cmd
.parm2
= codelen
;
1183 result
= hfa384x_docmd_wait(hw
, &cmd
);
1188 /*----------------------------------------------------------------
1191 * Perform a reset of the hfa38xx MAC core. We assume that the hw
1192 * structure is in its "created" state. That is, it is initialized
1193 * with proper values. Note that if a reset is done after the
1194 * device has been active for awhile, the caller might have to clean
1195 * up some leftover cruft in the hw structure.
1198 * hw device structure
1199 * holdtime how long (in ms) to hold the reset
1200 * settletime how long (in ms) to wait after releasing
1210 ----------------------------------------------------------------*/
1211 int hfa384x_corereset(hfa384x_t
* hw
, int holdtime
, int settletime
, int genesis
)
1215 result
= usb_reset_device(hw
->usb
);
1217 printk(KERN_ERR
"usb_reset_device() failed, result=%d.\n",
1224 /*----------------------------------------------------------------
1225 * hfa384x_usbctlx_complete_sync
1227 * Waits for a synchronous CTLX object to complete,
1228 * and then handles the response.
1231 * hw device structure
1233 * completor functor object to decide what to
1234 * do with the CTLX's result.
1238 * -ERESTARTSYS Interrupted by a signal
1240 * -ENODEV Adapter was unplugged
1241 * ??? Result from completor
1247 ----------------------------------------------------------------*/
1248 static int hfa384x_usbctlx_complete_sync(hfa384x_t
* hw
,
1249 hfa384x_usbctlx_t
* ctlx
,
1250 usbctlx_completor_t
* completor
)
1252 unsigned long flags
;
1255 result
= wait_for_completion_interruptible(&ctlx
->done
);
1257 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
1260 * We can only handle the CTLX if the USB disconnect
1261 * function has not run yet ...
1264 if (hw
->wlandev
->hwremoved
) {
1265 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1267 } else if (result
!= 0) {
1271 * We were probably interrupted, so delete
1272 * this CTLX asynchronously, kill the timers
1273 * and the URB, and then start the next
1276 * NOTE: We can only delete the timers and
1277 * the URB if this CTLX is active.
1279 if (ctlx
== get_active_ctlx(hw
)) {
1280 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1282 del_singleshot_timer_sync(&hw
->reqtimer
);
1283 del_singleshot_timer_sync(&hw
->resptimer
);
1284 hw
->req_timer_done
= 1;
1285 hw
->resp_timer_done
= 1;
1286 usb_kill_urb(&hw
->ctlx_urb
);
1288 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
1293 * This scenario is so unlikely that I'm
1294 * happy with a grubby "goto" solution ...
1296 if (hw
->wlandev
->hwremoved
)
1301 * The completion task will send this CTLX
1302 * to the reaper the next time it runs. We
1303 * are no longer in a hurry.
1306 ctlx
->state
= CTLX_REQ_FAILED
;
1307 list_move_tail(&ctlx
->list
, &hw
->ctlxq
.completing
);
1309 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1312 hfa384x_usbctlxq_run(hw
);
1314 if (ctlx
->state
== CTLX_COMPLETE
) {
1315 result
= completor
->complete(completor
);
1317 printk(KERN_WARNING
"CTLX[%d] error: state(%s)\n",
1318 le16_to_cpu(ctlx
->outbuf
.type
),
1319 ctlxstr(ctlx
->state
));
1323 list_del(&ctlx
->list
);
1324 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1331 /*----------------------------------------------------------------
1334 * Constructs a command CTLX and submits it.
1336 * NOTE: Any changes to the 'post-submit' code in this function
1337 * need to be carried over to hfa384x_cbcmd() since the handling
1338 * is virtually identical.
1341 * hw device structure
1342 * mode DOWAIT or DOASYNC
1343 * cmd cmd structure. Includes all arguments and result
1344 * data points. All in host order. in host order
1345 * cmdcb command-specific callback
1346 * usercb user callback for async calls, NULL for DOWAIT calls
1347 * usercb_data user supplied data pointer for async calls, NULL
1353 * -ERESTARTSYS Awakened on signal
1354 * >0 command indicated error, Status and Resp0-2 are
1362 ----------------------------------------------------------------*/
1364 hfa384x_docmd(hfa384x_t
* hw
,
1366 hfa384x_metacmd_t
* cmd
,
1367 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1370 hfa384x_usbctlx_t
*ctlx
;
1372 ctlx
= usbctlx_alloc();
1378 /* Initialize the command */
1379 ctlx
->outbuf
.cmdreq
.type
= cpu_to_le16(HFA384x_USB_CMDREQ
);
1380 ctlx
->outbuf
.cmdreq
.cmd
= cpu_to_le16(cmd
->cmd
);
1381 ctlx
->outbuf
.cmdreq
.parm0
= cpu_to_le16(cmd
->parm0
);
1382 ctlx
->outbuf
.cmdreq
.parm1
= cpu_to_le16(cmd
->parm1
);
1383 ctlx
->outbuf
.cmdreq
.parm2
= cpu_to_le16(cmd
->parm2
);
1385 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.cmdreq
);
1387 pr_debug("cmdreq: cmd=0x%04x "
1388 "parm0=0x%04x parm1=0x%04x parm2=0x%04x\n",
1389 cmd
->cmd
, cmd
->parm0
, cmd
->parm1
, cmd
->parm2
);
1391 ctlx
->reapable
= mode
;
1392 ctlx
->cmdcb
= cmdcb
;
1393 ctlx
->usercb
= usercb
;
1394 ctlx
->usercb_data
= usercb_data
;
1396 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1399 } else if (mode
== DOWAIT
) {
1400 usbctlx_cmd_completor_t completor
;
1403 hfa384x_usbctlx_complete_sync(hw
, ctlx
,
1404 init_cmd_completor(&completor
,
1416 /*----------------------------------------------------------------
1419 * Constructs a read rid CTLX and issues it.
1421 * NOTE: Any changes to the 'post-submit' code in this function
1422 * need to be carried over to hfa384x_cbrrid() since the handling
1423 * is virtually identical.
1426 * hw device structure
1427 * mode DOWAIT or DOASYNC
1428 * rid Read RID number (host order)
1429 * riddata Caller supplied buffer that MAC formatted RID.data
1430 * record will be written to for DOWAIT calls. Should
1431 * be NULL for DOASYNC calls.
1432 * riddatalen Buffer length for DOWAIT calls. Zero for DOASYNC calls.
1433 * cmdcb command callback for async calls, NULL for DOWAIT calls
1434 * usercb user callback for async calls, NULL for DOWAIT calls
1435 * usercb_data user supplied data pointer for async calls, NULL
1441 * -ERESTARTSYS Awakened on signal
1442 * -ENODATA riddatalen != macdatalen
1443 * >0 command indicated error, Status and Resp0-2 are
1449 * interrupt (DOASYNC)
1450 * process (DOWAIT or DOASYNC)
1451 ----------------------------------------------------------------*/
1453 hfa384x_dorrid(hfa384x_t
* hw
,
1457 unsigned int riddatalen
,
1458 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1461 hfa384x_usbctlx_t
*ctlx
;
1463 ctlx
= usbctlx_alloc();
1469 /* Initialize the command */
1470 ctlx
->outbuf
.rridreq
.type
= cpu_to_le16(HFA384x_USB_RRIDREQ
);
1471 ctlx
->outbuf
.rridreq
.frmlen
=
1472 cpu_to_le16(sizeof(ctlx
->outbuf
.rridreq
.rid
));
1473 ctlx
->outbuf
.rridreq
.rid
= cpu_to_le16(rid
);
1475 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.rridreq
);
1477 ctlx
->reapable
= mode
;
1478 ctlx
->cmdcb
= cmdcb
;
1479 ctlx
->usercb
= usercb
;
1480 ctlx
->usercb_data
= usercb_data
;
1482 /* Submit the CTLX */
1483 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1486 } else if (mode
== DOWAIT
) {
1487 usbctlx_rrid_completor_t completor
;
1490 hfa384x_usbctlx_complete_sync(hw
, ctlx
,
1493 &ctlx
->inbuf
.rridresp
,
1494 riddata
, riddatalen
));
1501 /*----------------------------------------------------------------
1504 * Constructs a write rid CTLX and issues it.
1506 * NOTE: Any changes to the 'post-submit' code in this function
1507 * need to be carried over to hfa384x_cbwrid() since the handling
1508 * is virtually identical.
1511 * hw device structure
1512 * CMD_MODE DOWAIT or DOASYNC
1514 * riddata Data portion of RID formatted for MAC
1515 * riddatalen Length of the data portion in bytes
1516 * cmdcb command callback for async calls, NULL for DOWAIT calls
1517 * usercb user callback for async calls, NULL for DOWAIT calls
1518 * usercb_data user supplied data pointer for async calls
1522 * -ETIMEDOUT timed out waiting for register ready or
1523 * command completion
1524 * >0 command indicated error, Status and Resp0-2 are
1530 * interrupt (DOASYNC)
1531 * process (DOWAIT or DOASYNC)
1532 ----------------------------------------------------------------*/
1534 hfa384x_dowrid(hfa384x_t
* hw
,
1538 unsigned int riddatalen
,
1539 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1542 hfa384x_usbctlx_t
*ctlx
;
1544 ctlx
= usbctlx_alloc();
1550 /* Initialize the command */
1551 ctlx
->outbuf
.wridreq
.type
= cpu_to_le16(HFA384x_USB_WRIDREQ
);
1552 ctlx
->outbuf
.wridreq
.frmlen
= cpu_to_le16((sizeof
1553 (ctlx
->outbuf
.wridreq
.rid
) +
1554 riddatalen
+ 1) / 2);
1555 ctlx
->outbuf
.wridreq
.rid
= cpu_to_le16(rid
);
1556 memcpy(ctlx
->outbuf
.wridreq
.data
, riddata
, riddatalen
);
1558 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.wridreq
.type
) +
1559 sizeof(ctlx
->outbuf
.wridreq
.frmlen
) +
1560 sizeof(ctlx
->outbuf
.wridreq
.rid
) + riddatalen
;
1562 ctlx
->reapable
= mode
;
1563 ctlx
->cmdcb
= cmdcb
;
1564 ctlx
->usercb
= usercb
;
1565 ctlx
->usercb_data
= usercb_data
;
1567 /* Submit the CTLX */
1568 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1571 } else if (mode
== DOWAIT
) {
1572 usbctlx_wrid_completor_t completor
;
1573 hfa384x_cmdresult_t wridresult
;
1575 result
= hfa384x_usbctlx_complete_sync(hw
,
1579 &ctlx
->inbuf
.wridresp
,
1587 /*----------------------------------------------------------------
1590 * Constructs a readmem CTLX and issues it.
1592 * NOTE: Any changes to the 'post-submit' code in this function
1593 * need to be carried over to hfa384x_cbrmem() since the handling
1594 * is virtually identical.
1597 * hw device structure
1598 * mode DOWAIT or DOASYNC
1599 * page MAC address space page (CMD format)
1600 * offset MAC address space offset
1601 * data Ptr to data buffer to receive read
1602 * len Length of the data to read (max == 2048)
1603 * cmdcb command callback for async calls, NULL for DOWAIT calls
1604 * usercb user callback for async calls, NULL for DOWAIT calls
1605 * usercb_data user supplied data pointer for async calls
1609 * -ETIMEDOUT timed out waiting for register ready or
1610 * command completion
1611 * >0 command indicated error, Status and Resp0-2 are
1617 * interrupt (DOASYNC)
1618 * process (DOWAIT or DOASYNC)
1619 ----------------------------------------------------------------*/
1621 hfa384x_dormem(hfa384x_t
* hw
,
1627 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1630 hfa384x_usbctlx_t
*ctlx
;
1632 ctlx
= usbctlx_alloc();
1638 /* Initialize the command */
1639 ctlx
->outbuf
.rmemreq
.type
= cpu_to_le16(HFA384x_USB_RMEMREQ
);
1640 ctlx
->outbuf
.rmemreq
.frmlen
=
1641 cpu_to_le16(sizeof(ctlx
->outbuf
.rmemreq
.offset
) +
1642 sizeof(ctlx
->outbuf
.rmemreq
.page
) + len
);
1643 ctlx
->outbuf
.rmemreq
.offset
= cpu_to_le16(offset
);
1644 ctlx
->outbuf
.rmemreq
.page
= cpu_to_le16(page
);
1646 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.rmemreq
);
1648 pr_debug("type=0x%04x frmlen=%d offset=0x%04x page=0x%04x\n",
1649 ctlx
->outbuf
.rmemreq
.type
,
1650 ctlx
->outbuf
.rmemreq
.frmlen
,
1651 ctlx
->outbuf
.rmemreq
.offset
, ctlx
->outbuf
.rmemreq
.page
);
1653 pr_debug("pktsize=%zd\n", ROUNDUP64(sizeof(ctlx
->outbuf
.rmemreq
)));
1655 ctlx
->reapable
= mode
;
1656 ctlx
->cmdcb
= cmdcb
;
1657 ctlx
->usercb
= usercb
;
1658 ctlx
->usercb_data
= usercb_data
;
1660 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1663 } else if (mode
== DOWAIT
) {
1664 usbctlx_rmem_completor_t completor
;
1667 hfa384x_usbctlx_complete_sync(hw
, ctlx
,
1670 &ctlx
->inbuf
.rmemresp
, data
,
1678 /*----------------------------------------------------------------
1681 * Constructs a writemem CTLX and issues it.
1683 * NOTE: Any changes to the 'post-submit' code in this function
1684 * need to be carried over to hfa384x_cbwmem() since the handling
1685 * is virtually identical.
1688 * hw device structure
1689 * mode DOWAIT or DOASYNC
1690 * page MAC address space page (CMD format)
1691 * offset MAC address space offset
1692 * data Ptr to data buffer containing write data
1693 * len Length of the data to read (max == 2048)
1694 * cmdcb command callback for async calls, NULL for DOWAIT calls
1695 * usercb user callback for async calls, NULL for DOWAIT calls
1696 * usercb_data user supplied data pointer for async calls.
1700 * -ETIMEDOUT timed out waiting for register ready or
1701 * command completion
1702 * >0 command indicated error, Status and Resp0-2 are
1708 * interrupt (DOWAIT)
1709 * process (DOWAIT or DOASYNC)
1710 ----------------------------------------------------------------*/
1712 hfa384x_dowmem(hfa384x_t
* hw
,
1718 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1721 hfa384x_usbctlx_t
*ctlx
;
1723 pr_debug("page=0x%04x offset=0x%04x len=%d\n", page
, offset
, len
);
1725 ctlx
= usbctlx_alloc();
1731 /* Initialize the command */
1732 ctlx
->outbuf
.wmemreq
.type
= cpu_to_le16(HFA384x_USB_WMEMREQ
);
1733 ctlx
->outbuf
.wmemreq
.frmlen
=
1734 cpu_to_le16(sizeof(ctlx
->outbuf
.wmemreq
.offset
) +
1735 sizeof(ctlx
->outbuf
.wmemreq
.page
) + len
);
1736 ctlx
->outbuf
.wmemreq
.offset
= cpu_to_le16(offset
);
1737 ctlx
->outbuf
.wmemreq
.page
= cpu_to_le16(page
);
1738 memcpy(ctlx
->outbuf
.wmemreq
.data
, data
, len
);
1740 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.wmemreq
.type
) +
1741 sizeof(ctlx
->outbuf
.wmemreq
.frmlen
) +
1742 sizeof(ctlx
->outbuf
.wmemreq
.offset
) +
1743 sizeof(ctlx
->outbuf
.wmemreq
.page
) + len
;
1745 ctlx
->reapable
= mode
;
1746 ctlx
->cmdcb
= cmdcb
;
1747 ctlx
->usercb
= usercb
;
1748 ctlx
->usercb_data
= usercb_data
;
1750 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1753 } else if (mode
== DOWAIT
) {
1754 usbctlx_wmem_completor_t completor
;
1755 hfa384x_cmdresult_t wmemresult
;
1757 result
= hfa384x_usbctlx_complete_sync(hw
,
1761 &ctlx
->inbuf
.wmemresp
,
1769 /*----------------------------------------------------------------
1770 * hfa384x_drvr_commtallies
1772 * Send a commtallies inquiry to the MAC. Note that this is an async
1773 * call that will result in an info frame arriving sometime later.
1776 * hw device structure
1785 ----------------------------------------------------------------*/
1786 int hfa384x_drvr_commtallies(hfa384x_t
* hw
)
1788 hfa384x_metacmd_t cmd
;
1790 cmd
.cmd
= HFA384x_CMDCODE_INQ
;
1791 cmd
.parm0
= HFA384x_IT_COMMTALLIES
;
1795 hfa384x_docmd_async(hw
, &cmd
, NULL
, NULL
, NULL
);
1800 /*----------------------------------------------------------------
1801 * hfa384x_drvr_disable
1803 * Issues the disable command to stop communications on one of
1804 * the MACs 'ports'. Only macport 0 is valid for stations.
1805 * APs may also disable macports 1-6. Only ports that have been
1806 * previously enabled may be disabled.
1809 * hw device structure
1810 * macport MAC port number (host order)
1814 * >0 f/w reported failure - f/w status code
1815 * <0 driver reported error (timeout|bad arg)
1821 ----------------------------------------------------------------*/
1822 int hfa384x_drvr_disable(hfa384x_t
* hw
, u16 macport
)
1826 if ((!hw
->isap
&& macport
!= 0) ||
1827 (hw
->isap
&& !(macport
<= HFA384x_PORTID_MAX
)) ||
1828 !(hw
->port_enabled
[macport
])) {
1831 result
= hfa384x_cmd_disable(hw
, macport
);
1833 hw
->port_enabled
[macport
] = 0;
1838 /*----------------------------------------------------------------
1839 * hfa384x_drvr_enable
1841 * Issues the enable command to enable communications on one of
1842 * the MACs 'ports'. Only macport 0 is valid for stations.
1843 * APs may also enable macports 1-6. Only ports that are currently
1844 * disabled may be enabled.
1847 * hw device structure
1848 * macport MAC port number
1852 * >0 f/w reported failure - f/w status code
1853 * <0 driver reported error (timeout|bad arg)
1859 ----------------------------------------------------------------*/
1860 int hfa384x_drvr_enable(hfa384x_t
* hw
, u16 macport
)
1864 if ((!hw
->isap
&& macport
!= 0) ||
1865 (hw
->isap
&& !(macport
<= HFA384x_PORTID_MAX
)) ||
1866 (hw
->port_enabled
[macport
])) {
1869 result
= hfa384x_cmd_enable(hw
, macport
);
1871 hw
->port_enabled
[macport
] = 1;
1876 /*----------------------------------------------------------------
1877 * hfa384x_drvr_flashdl_enable
1879 * Begins the flash download state. Checks to see that we're not
1880 * already in a download state and that a port isn't enabled.
1881 * Sets the download state and retrieves the flash download
1882 * buffer location, buffer size, and timeout length.
1885 * hw device structure
1889 * >0 f/w reported error - f/w status code
1890 * <0 driver reported error
1896 ----------------------------------------------------------------*/
1897 int hfa384x_drvr_flashdl_enable(hfa384x_t
* hw
)
1902 /* Check that a port isn't active */
1903 for (i
= 0; i
< HFA384x_PORTID_MAX
; i
++) {
1904 if (hw
->port_enabled
[i
]) {
1905 pr_debug("called when port enabled.\n");
1910 /* Check that we're not already in a download state */
1911 if (hw
->dlstate
!= HFA384x_DLSTATE_DISABLED
)
1914 /* Retrieve the buffer loc&size and timeout */
1915 if ((result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_DOWNLOADBUFFER
,
1917 sizeof(hw
->bufinfo
)))) {
1920 hw
->bufinfo
.page
= le16_to_cpu(hw
->bufinfo
.page
);
1921 hw
->bufinfo
.offset
= le16_to_cpu(hw
->bufinfo
.offset
);
1922 hw
->bufinfo
.len
= le16_to_cpu(hw
->bufinfo
.len
);
1923 if ((result
= hfa384x_drvr_getconfig16(hw
, HFA384x_RID_MAXLOADTIME
,
1924 &(hw
->dltimeout
)))) {
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
);
2033 printk(KERN_WARNING
"dlbuf@0x%06lx len=%d to=%d\n", dlbufaddr
,
2034 hw
->bufinfo
.len
, hw
->dltimeout
);
2036 /* Calculations to determine how many fills of the dlbuffer to do
2037 * and how many USB wmemreq's to do for each fill. At this point
2038 * in time, the dlbuffer size and the wmemreq size are the same.
2039 * Therefore, nwrites should always be 1. The extra complexity
2040 * here is a hedge against future changes.
2043 /* Figure out how many times to do the flash programming */
2044 nburns
= len
/ hw
->bufinfo
.len
;
2045 nburns
+= (len
% hw
->bufinfo
.len
) ? 1 : 0;
2047 /* For each flash program cycle, how many USB wmemreq's are needed? */
2048 nwrites
= hw
->bufinfo
.len
/ HFA384x_USB_RWMEM_MAXLEN
;
2049 nwrites
+= (hw
->bufinfo
.len
% HFA384x_USB_RWMEM_MAXLEN
) ? 1 : 0;
2052 for (i
= 0; i
< nburns
; i
++) {
2053 /* Get the dest address and len */
2054 burnlen
= (len
- (hw
->bufinfo
.len
* i
)) > hw
->bufinfo
.len
?
2055 hw
->bufinfo
.len
: (len
- (hw
->bufinfo
.len
* i
));
2056 burndaddr
= daddr
+ (hw
->bufinfo
.len
* i
);
2057 burnlo
= HFA384x_ADDR_CMD_MKOFF(burndaddr
);
2058 burnhi
= HFA384x_ADDR_CMD_MKPAGE(burndaddr
);
2060 printk(KERN_INFO
"Writing %d bytes to flash @0x%06x\n",
2061 burnlen
, burndaddr
);
2063 /* Set the download mode */
2064 result
= hfa384x_cmd_download(hw
, HFA384x_PROGMODE_NV
,
2065 burnlo
, burnhi
, burnlen
);
2067 printk(KERN_ERR
"download(NV,lo=%x,hi=%x,len=%x) "
2068 "cmd failed, result=%d. Aborting d/l\n",
2069 burnlo
, burnhi
, burnlen
, result
);
2073 /* copy the data to the flash download buffer */
2074 for (j
= 0; j
< nwrites
; j
++) {
2076 (i
* hw
->bufinfo
.len
) +
2077 (j
* HFA384x_USB_RWMEM_MAXLEN
);
2079 writepage
= HFA384x_ADDR_CMD_MKPAGE(dlbufaddr
+
2081 HFA384x_USB_RWMEM_MAXLEN
));
2083 HFA384x_ADDR_CMD_MKOFF(dlbufaddr
+
2085 HFA384x_USB_RWMEM_MAXLEN
));
2087 writelen
= burnlen
- (j
* HFA384x_USB_RWMEM_MAXLEN
);
2088 writelen
= writelen
> HFA384x_USB_RWMEM_MAXLEN
?
2089 HFA384x_USB_RWMEM_MAXLEN
: writelen
;
2091 result
= hfa384x_dowmem_wait(hw
,
2094 writebuf
, writelen
);
2097 /* set the download 'write flash' mode */
2098 result
= hfa384x_cmd_download(hw
,
2099 HFA384x_PROGMODE_NVWRITE
,
2103 "download(NVWRITE,lo=%x,hi=%x,len=%x) "
2104 "cmd failed, result=%d. Aborting d/l\n",
2105 burnlo
, burnhi
, burnlen
, result
);
2109 /* TODO: We really should do a readback and compare. */
2114 /* Leave the firmware in the 'post-prog' mode. flashdl_disable will */
2115 /* actually disable programming mode. Remember, that will cause the */
2116 /* the firmware to effectively reset itself. */
2121 /*----------------------------------------------------------------
2122 * hfa384x_drvr_getconfig
2124 * Performs the sequence necessary to read a config/info item.
2127 * hw device structure
2128 * rid config/info record id (host order)
2129 * buf host side record buffer. Upon return it will
2130 * contain the body portion of the record (minus the
2132 * len buffer length (in bytes, should match record length)
2136 * >0 f/w reported error - f/w status code
2137 * <0 driver reported error
2138 * -ENODATA length mismatch between argument and retrieved
2145 ----------------------------------------------------------------*/
2146 int hfa384x_drvr_getconfig(hfa384x_t
* hw
, u16 rid
, void *buf
, u16 len
)
2150 result
= hfa384x_dorrid_wait(hw
, rid
, buf
, len
);
2155 /*----------------------------------------------------------------
2156 * hfa384x_drvr_getconfig_async
2158 * Performs the sequence necessary to perform an async read of
2159 * of a config/info item.
2162 * hw device structure
2163 * rid config/info record id (host order)
2164 * buf host side record buffer. Upon return it will
2165 * contain the body portion of the record (minus the
2167 * len buffer length (in bytes, should match record length)
2168 * cbfn caller supplied callback, called when the command
2169 * is done (successful or not).
2170 * cbfndata pointer to some caller supplied data that will be
2171 * passed in as an argument to the cbfn.
2174 * nothing the cbfn gets a status argument identifying if
2177 * Queues an hfa384x_usbcmd_t for subsequent execution.
2181 ----------------------------------------------------------------*/
2183 hfa384x_drvr_getconfig_async(hfa384x_t
* hw
,
2184 u16 rid
, ctlx_usercb_t usercb
, void *usercb_data
)
2186 return hfa384x_dorrid_async(hw
, rid
, NULL
, 0,
2187 hfa384x_cb_rrid
, usercb
, usercb_data
);
2190 /*----------------------------------------------------------------
2191 * hfa384x_drvr_setconfig_async
2193 * Performs the sequence necessary to write a config/info item.
2196 * hw device structure
2197 * rid config/info record id (in host order)
2198 * buf host side record buffer
2199 * len buffer length (in bytes)
2200 * usercb completion callback
2201 * usercb_data completion callback argument
2205 * >0 f/w reported error - f/w status code
2206 * <0 driver reported error
2212 ----------------------------------------------------------------*/
2214 hfa384x_drvr_setconfig_async(hfa384x_t
* hw
,
2217 u16 len
, ctlx_usercb_t usercb
, void *usercb_data
)
2219 return hfa384x_dowrid_async(hw
, rid
, buf
, len
,
2220 hfa384x_cb_status
, usercb
, usercb_data
);
2223 /*----------------------------------------------------------------
2224 * hfa384x_drvr_ramdl_disable
2226 * Ends the ram download state.
2229 * hw device structure
2233 * >0 f/w reported error - f/w status code
2234 * <0 driver reported error
2240 ----------------------------------------------------------------*/
2241 int hfa384x_drvr_ramdl_disable(hfa384x_t
* hw
)
2243 /* Check that we're already in the download state */
2244 if (hw
->dlstate
!= HFA384x_DLSTATE_RAMENABLED
)
2247 pr_debug("ramdl_disable()\n");
2249 /* There isn't much we can do at this point, so I don't */
2250 /* bother w/ the return value */
2251 hfa384x_cmd_download(hw
, HFA384x_PROGMODE_DISABLE
, 0, 0, 0);
2252 hw
->dlstate
= HFA384x_DLSTATE_DISABLED
;
2257 /*----------------------------------------------------------------
2258 * hfa384x_drvr_ramdl_enable
2260 * Begins the ram download state. Checks to see that we're not
2261 * already in a download state and that a port isn't enabled.
2262 * Sets the download state and calls cmd_download with the
2263 * ENABLE_VOLATILE subcommand and the exeaddr argument.
2266 * hw device structure
2267 * exeaddr the card execution address that will be
2268 * jumped to when ramdl_disable() is called
2273 * >0 f/w reported error - f/w status code
2274 * <0 driver reported error
2280 ----------------------------------------------------------------*/
2281 int hfa384x_drvr_ramdl_enable(hfa384x_t
* hw
, u32 exeaddr
)
2288 /* Check that a port isn't active */
2289 for (i
= 0; i
< HFA384x_PORTID_MAX
; i
++) {
2290 if (hw
->port_enabled
[i
]) {
2292 "Can't download with a macport enabled.\n");
2297 /* Check that we're not already in a download state */
2298 if (hw
->dlstate
!= HFA384x_DLSTATE_DISABLED
) {
2299 printk(KERN_ERR
"Download state not disabled.\n");
2303 pr_debug("ramdl_enable, exeaddr=0x%08x\n", exeaddr
);
2305 /* Call the download(1,addr) function */
2306 lowaddr
= HFA384x_ADDR_CMD_MKOFF(exeaddr
);
2307 hiaddr
= HFA384x_ADDR_CMD_MKPAGE(exeaddr
);
2309 result
= hfa384x_cmd_download(hw
, HFA384x_PROGMODE_RAM
,
2310 lowaddr
, hiaddr
, 0);
2313 /* Set the download state */
2314 hw
->dlstate
= HFA384x_DLSTATE_RAMENABLED
;
2316 pr_debug("cmd_download(0x%04x, 0x%04x) failed, result=%d.\n",
2317 lowaddr
, hiaddr
, result
);
2323 /*----------------------------------------------------------------
2324 * hfa384x_drvr_ramdl_write
2326 * Performs a RAM download of a chunk of data. First checks to see
2327 * that we're in the RAM download state, then uses the [read|write]mem USB
2328 * commands to 1) copy the data, 2) readback and compare. The download
2329 * state is unaffected. When all data has been written using
2330 * this function, call drvr_ramdl_disable() to end the download state
2331 * and restart the MAC.
2334 * hw device structure
2335 * daddr Card address to write to. (host order)
2336 * buf Ptr to data to write.
2337 * len Length of data (host order).
2341 * >0 f/w reported error - f/w status code
2342 * <0 driver reported error
2348 ----------------------------------------------------------------*/
2349 int hfa384x_drvr_ramdl_write(hfa384x_t
* hw
, u32 daddr
, void *buf
, u32 len
)
2360 /* Check that we're in the ram download state */
2361 if (hw
->dlstate
!= HFA384x_DLSTATE_RAMENABLED
)
2364 printk(KERN_INFO
"Writing %d bytes to ram @0x%06x\n", len
, daddr
);
2366 /* How many dowmem calls? */
2367 nwrites
= len
/ HFA384x_USB_RWMEM_MAXLEN
;
2368 nwrites
+= len
% HFA384x_USB_RWMEM_MAXLEN
? 1 : 0;
2370 /* Do blocking wmem's */
2371 for (i
= 0; i
< nwrites
; i
++) {
2372 /* make address args */
2373 curraddr
= daddr
+ (i
* HFA384x_USB_RWMEM_MAXLEN
);
2374 currpage
= HFA384x_ADDR_CMD_MKPAGE(curraddr
);
2375 curroffset
= HFA384x_ADDR_CMD_MKOFF(curraddr
);
2376 currlen
= len
- (i
* HFA384x_USB_RWMEM_MAXLEN
);
2377 if (currlen
> HFA384x_USB_RWMEM_MAXLEN
)
2378 currlen
= HFA384x_USB_RWMEM_MAXLEN
;
2380 /* Do blocking ctlx */
2381 result
= hfa384x_dowmem_wait(hw
,
2385 (i
* HFA384x_USB_RWMEM_MAXLEN
),
2391 /* TODO: We really should have a readback. */
2397 /*----------------------------------------------------------------
2398 * hfa384x_drvr_readpda
2400 * Performs the sequence to read the PDA space. Note there is no
2401 * drvr_writepda() function. Writing a PDA is
2402 * generally implemented by a calling component via calls to
2403 * cmd_download and writing to the flash download buffer via the
2407 * hw device structure
2408 * buf buffer to store PDA in
2413 * >0 f/w reported error - f/w status code
2414 * <0 driver reported error
2415 * -ETIMEDOUT timout waiting for the cmd regs to become
2416 * available, or waiting for the control reg
2417 * to indicate the Aux port is enabled.
2418 * -ENODATA the buffer does NOT contain a valid PDA.
2419 * Either the card PDA is bad, or the auxdata
2420 * reads are giving us garbage.
2426 * process or non-card interrupt.
2427 ----------------------------------------------------------------*/
2428 int hfa384x_drvr_readpda(hfa384x_t
* hw
, void *buf
, unsigned int len
)
2434 int currpdr
= 0; /* word offset of the current pdr */
2436 u16 pdrlen
; /* pdr length in bytes, host order */
2437 u16 pdrcode
; /* pdr code, host order */
2445 HFA3842_PDA_BASE
, 0}, {
2446 HFA3841_PDA_BASE
, 0}, {
2447 HFA3841_PDA_BOGUS_BASE
, 0}
2450 /* Read the pda from each known address. */
2451 for (i
= 0; i
< ARRAY_SIZE(pdaloc
); i
++) {
2453 currpage
= HFA384x_ADDR_CMD_MKPAGE(pdaloc
[i
].cardaddr
);
2454 curroffset
= HFA384x_ADDR_CMD_MKOFF(pdaloc
[i
].cardaddr
);
2456 result
= hfa384x_dormem_wait(hw
, currpage
, curroffset
, buf
, len
); /* units of bytes */
2460 "Read from index %zd failed, continuing\n", i
);
2464 /* Test for garbage */
2465 pdaok
= 1; /* initially assume good */
2467 while (pdaok
&& morepdrs
) {
2468 pdrlen
= le16_to_cpu(pda
[currpdr
]) * 2;
2469 pdrcode
= le16_to_cpu(pda
[currpdr
+ 1]);
2470 /* Test the record length */
2471 if (pdrlen
> HFA384x_PDR_LEN_MAX
|| pdrlen
== 0) {
2472 printk(KERN_ERR
"pdrlen invalid=%d\n", pdrlen
);
2477 if (!hfa384x_isgood_pdrcode(pdrcode
)) {
2478 printk(KERN_ERR
"pdrcode invalid=%d\n",
2483 /* Test for completion */
2484 if (pdrcode
== HFA384x_PDR_END_OF_PDA
)
2487 /* Move to the next pdr (if necessary) */
2489 /* note the access to pda[], need words here */
2490 currpdr
+= le16_to_cpu(pda
[currpdr
]) + 1;
2495 "PDA Read from 0x%08x in %s space.\n",
2497 pdaloc
[i
].auxctl
== 0 ? "EXTDS" :
2498 pdaloc
[i
].auxctl
== 1 ? "NV" :
2499 pdaloc
[i
].auxctl
== 2 ? "PHY" :
2500 pdaloc
[i
].auxctl
== 3 ? "ICSRAM" :
2505 result
= pdaok
? 0 : -ENODATA
;
2508 pr_debug("Failure: pda is not okay\n");
2513 /*----------------------------------------------------------------
2514 * hfa384x_drvr_setconfig
2516 * Performs the sequence necessary to write a config/info item.
2519 * hw device structure
2520 * rid config/info record id (in host order)
2521 * buf host side record buffer
2522 * len buffer length (in bytes)
2526 * >0 f/w reported error - f/w status code
2527 * <0 driver reported error
2533 ----------------------------------------------------------------*/
2534 int hfa384x_drvr_setconfig(hfa384x_t
* hw
, u16 rid
, void *buf
, u16 len
)
2536 return hfa384x_dowrid_wait(hw
, rid
, buf
, len
);
2539 /*----------------------------------------------------------------
2540 * hfa384x_drvr_start
2542 * Issues the MAC initialize command, sets up some data structures,
2543 * and enables the interrupts. After this function completes, the
2544 * low-level stuff should be ready for any/all commands.
2547 * hw device structure
2550 * >0 f/w reported error - f/w status code
2551 * <0 driver reported error
2557 ----------------------------------------------------------------*/
2559 int hfa384x_drvr_start(hfa384x_t
* hw
)
2561 int result
, result1
, result2
;
2566 /* Clear endpoint stalls - but only do this if the endpoint
2567 * is showing a stall status. Some prism2 cards seem to behave
2568 * badly if a clear_halt is called when the endpoint is already
2572 usb_get_status(hw
->usb
, USB_RECIP_ENDPOINT
, hw
->endp_in
, &status
);
2574 printk(KERN_ERR
"Cannot get bulk in endpoint status.\n");
2577 if ((status
== 1) && usb_clear_halt(hw
->usb
, hw
->endp_in
))
2578 printk(KERN_ERR
"Failed to reset bulk in endpoint.\n");
2581 usb_get_status(hw
->usb
, USB_RECIP_ENDPOINT
, hw
->endp_out
, &status
);
2583 printk(KERN_ERR
"Cannot get bulk out endpoint status.\n");
2586 if ((status
== 1) && usb_clear_halt(hw
->usb
, hw
->endp_out
))
2587 printk(KERN_ERR
"Failed to reset bulk out endpoint.\n");
2589 /* Synchronous unlink, in case we're trying to restart the driver */
2590 usb_kill_urb(&hw
->rx_urb
);
2592 /* Post the IN urb */
2593 result
= submit_rx_urb(hw
, GFP_KERNEL
);
2596 "Fatal, failed to submit RX URB, result=%d\n", result
);
2600 /* Call initialize twice, with a 1 second sleep in between.
2601 * This is a nasty work-around since many prism2 cards seem to
2602 * need time to settle after an init from cold. The second
2603 * call to initialize in theory is not necessary - but we call
2604 * it anyway as a double insurance policy:
2605 * 1) If the first init should fail, the second may well succeed
2606 * and the card can still be used
2607 * 2) It helps ensures all is well with the card after the first
2608 * init and settle time.
2610 result1
= hfa384x_cmd_initialize(hw
);
2612 result
= result2
= hfa384x_cmd_initialize(hw
);
2616 "cmd_initialize() failed on two attempts, results %d and %d\n",
2618 usb_kill_urb(&hw
->rx_urb
);
2621 pr_debug("First cmd_initialize() failed (result %d),\n",
2624 ("but second attempt succeeded. All should be ok\n");
2626 } else if (result2
!= 0) {
2628 "First cmd_initialize() succeeded, but second attempt failed (result=%d)\n",
2631 "Most likely the card will be functional\n");
2635 hw
->state
= HFA384x_STATE_RUNNING
;
2641 /*----------------------------------------------------------------
2644 * Shuts down the MAC to the point where it is safe to unload the
2645 * driver. Any subsystem that may be holding a data or function
2646 * ptr into the driver must be cleared/deinitialized.
2649 * hw device structure
2652 * >0 f/w reported error - f/w status code
2653 * <0 driver reported error
2659 ----------------------------------------------------------------*/
2660 int hfa384x_drvr_stop(hfa384x_t
* hw
)
2667 /* There's no need for spinlocks here. The USB "disconnect"
2668 * function sets this "removed" flag and then calls us.
2670 if (!hw
->wlandev
->hwremoved
) {
2671 /* Call initialize to leave the MAC in its 'reset' state */
2672 hfa384x_cmd_initialize(hw
);
2674 /* Cancel the rxurb */
2675 usb_kill_urb(&hw
->rx_urb
);
2678 hw
->link_status
= HFA384x_LINK_NOTCONNECTED
;
2679 hw
->state
= HFA384x_STATE_INIT
;
2681 del_timer_sync(&hw
->commsqual_timer
);
2683 /* Clear all the port status */
2684 for (i
= 0; i
< HFA384x_NUMPORTS_MAX
; i
++)
2685 hw
->port_enabled
[i
] = 0;
2690 /*----------------------------------------------------------------
2691 * hfa384x_drvr_txframe
2693 * Takes a frame from prism2sta and queues it for transmission.
2696 * hw device structure
2697 * skb packet buffer struct. Contains an 802.11
2699 * p80211_hdr points to the 802.11 header for the packet.
2701 * 0 Success and more buffs available
2702 * 1 Success but no more buffs
2703 * 2 Allocation failure
2704 * 4 Buffer full or queue busy
2710 ----------------------------------------------------------------*/
2711 int hfa384x_drvr_txframe(hfa384x_t
* hw
, struct sk_buff
*skb
,
2712 p80211_hdr_t
* p80211_hdr
,
2713 p80211_metawep_t
* p80211_wep
)
2715 int usbpktlen
= sizeof(hfa384x_tx_frame_t
);
2720 if (hw
->tx_urb
.status
== -EINPROGRESS
) {
2721 printk(KERN_WARNING
"TX URB already in use\n");
2726 /* Build Tx frame structure */
2727 /* Set up the control field */
2728 memset(&hw
->txbuff
.txfrm
.desc
, 0, sizeof(hw
->txbuff
.txfrm
.desc
));
2730 /* Setup the usb type field */
2731 hw
->txbuff
.type
= cpu_to_le16(HFA384x_USB_TXFRM
);
2733 /* Set up the sw_support field to identify this frame */
2734 hw
->txbuff
.txfrm
.desc
.sw_support
= 0x0123;
2736 /* Tx complete and Tx exception disable per dleach. Might be causing
2739 /* #define DOEXC SLP -- doboth breaks horribly under load, doexc less so. */
2741 hw
->txbuff
.txfrm
.desc
.tx_control
=
2742 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2743 HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(1);
2744 #elif defined(DOEXC)
2745 hw
->txbuff
.txfrm
.desc
.tx_control
=
2746 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2747 HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(0);
2749 hw
->txbuff
.txfrm
.desc
.tx_control
=
2750 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2751 HFA384x_TX_TXEX_SET(0) | HFA384x_TX_TXOK_SET(0);
2753 hw
->txbuff
.txfrm
.desc
.tx_control
=
2754 cpu_to_le16(hw
->txbuff
.txfrm
.desc
.tx_control
);
2756 /* copy the header over to the txdesc */
2757 memcpy(&(hw
->txbuff
.txfrm
.desc
.frame_control
), p80211_hdr
,
2758 sizeof(p80211_hdr_t
));
2760 /* if we're using host WEP, increase size by IV+ICV */
2761 if (p80211_wep
->data
) {
2762 hw
->txbuff
.txfrm
.desc
.data_len
= cpu_to_le16(skb
->len
+ 8);
2765 hw
->txbuff
.txfrm
.desc
.data_len
= cpu_to_le16(skb
->len
);
2768 usbpktlen
+= skb
->len
;
2770 /* copy over the WEP IV if we are using host WEP */
2771 ptr
= hw
->txbuff
.txfrm
.data
;
2772 if (p80211_wep
->data
) {
2773 memcpy(ptr
, p80211_wep
->iv
, sizeof(p80211_wep
->iv
));
2774 ptr
+= sizeof(p80211_wep
->iv
);
2775 memcpy(ptr
, p80211_wep
->data
, skb
->len
);
2777 memcpy(ptr
, skb
->data
, skb
->len
);
2779 /* copy over the packet data */
2782 /* copy over the WEP ICV if we are using host WEP */
2783 if (p80211_wep
->data
)
2784 memcpy(ptr
, p80211_wep
->icv
, sizeof(p80211_wep
->icv
));
2786 /* Send the USB packet */
2787 usb_fill_bulk_urb(&(hw
->tx_urb
), hw
->usb
,
2789 &(hw
->txbuff
), ROUNDUP64(usbpktlen
),
2790 hfa384x_usbout_callback
, hw
->wlandev
);
2791 hw
->tx_urb
.transfer_flags
|= USB_QUEUE_BULK
;
2794 ret
= submit_tx_urb(hw
, &hw
->tx_urb
, GFP_ATOMIC
);
2796 printk(KERN_ERR
"submit_tx_urb() failed, error=%d\n", ret
);
2804 void hfa384x_tx_timeout(wlandevice_t
* wlandev
)
2806 hfa384x_t
*hw
= wlandev
->priv
;
2807 unsigned long flags
;
2809 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2811 if (!hw
->wlandev
->hwremoved
&&
2812 /* Note the bitwise OR, not the logical OR. */
2813 (!test_and_set_bit(WORK_TX_HALT
, &hw
->usb_flags
) |
2814 !test_and_set_bit(WORK_RX_HALT
, &hw
->usb_flags
))) {
2815 schedule_work(&hw
->usb_work
);
2818 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2821 /*----------------------------------------------------------------
2822 * hfa384x_usbctlx_reaper_task
2824 * Tasklet to delete dead CTLX objects
2827 * data ptr to a hfa384x_t
2833 ----------------------------------------------------------------*/
2834 static void hfa384x_usbctlx_reaper_task(unsigned long data
)
2836 hfa384x_t
*hw
= (hfa384x_t
*) data
;
2837 struct list_head
*entry
;
2838 struct list_head
*temp
;
2839 unsigned long flags
;
2841 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2843 /* This list is guaranteed to be empty if someone
2844 * has unplugged the adapter.
2846 list_for_each_safe(entry
, temp
, &hw
->ctlxq
.reapable
) {
2847 hfa384x_usbctlx_t
*ctlx
;
2849 ctlx
= list_entry(entry
, hfa384x_usbctlx_t
, list
);
2850 list_del(&ctlx
->list
);
2854 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2858 /*----------------------------------------------------------------
2859 * hfa384x_usbctlx_completion_task
2861 * Tasklet to call completion handlers for returned CTLXs
2864 * data ptr to hfa384x_t
2871 ----------------------------------------------------------------*/
2872 static void hfa384x_usbctlx_completion_task(unsigned long data
)
2874 hfa384x_t
*hw
= (hfa384x_t
*) data
;
2875 struct list_head
*entry
;
2876 struct list_head
*temp
;
2877 unsigned long flags
;
2881 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2883 /* This list is guaranteed to be empty if someone
2884 * has unplugged the adapter ...
2886 list_for_each_safe(entry
, temp
, &hw
->ctlxq
.completing
) {
2887 hfa384x_usbctlx_t
*ctlx
;
2889 ctlx
= list_entry(entry
, hfa384x_usbctlx_t
, list
);
2891 /* Call the completion function that this
2892 * command was assigned, assuming it has one.
2894 if (ctlx
->cmdcb
!= NULL
) {
2895 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2896 ctlx
->cmdcb(hw
, ctlx
);
2897 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2899 /* Make sure we don't try and complete
2900 * this CTLX more than once!
2904 /* Did someone yank the adapter out
2905 * while our list was (briefly) unlocked?
2907 if (hw
->wlandev
->hwremoved
) {
2914 * "Reapable" CTLXs are ones which don't have any
2915 * threads waiting for them to die. Hence they must
2916 * be delivered to The Reaper!
2918 if (ctlx
->reapable
) {
2919 /* Move the CTLX off the "completing" list (hopefully)
2920 * on to the "reapable" list where the reaper task
2921 * can find it. And "reapable" means that this CTLX
2922 * isn't sitting on a wait-queue somewhere.
2924 list_move_tail(&ctlx
->list
, &hw
->ctlxq
.reapable
);
2928 complete(&ctlx
->done
);
2930 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2933 tasklet_schedule(&hw
->reaper_bh
);
2936 /*----------------------------------------------------------------
2937 * unlocked_usbctlx_cancel_async
2939 * Mark the CTLX dead asynchronously, and ensure that the
2940 * next command on the queue is run afterwards.
2943 * hw ptr to the hfa384x_t structure
2944 * ctlx ptr to a CTLX structure
2947 * 0 the CTLX's URB is inactive
2948 * -EINPROGRESS the URB is currently being unlinked
2951 * Either process or interrupt, but presumably interrupt
2952 ----------------------------------------------------------------*/
2953 static int unlocked_usbctlx_cancel_async(hfa384x_t
* hw
,
2954 hfa384x_usbctlx_t
* ctlx
)
2959 * Try to delete the URB containing our request packet.
2960 * If we succeed, then its completion handler will be
2961 * called with a status of -ECONNRESET.
2963 hw
->ctlx_urb
.transfer_flags
|= URB_ASYNC_UNLINK
;
2964 ret
= usb_unlink_urb(&hw
->ctlx_urb
);
2966 if (ret
!= -EINPROGRESS
) {
2968 * The OUT URB had either already completed
2969 * or was still in the pending queue, so the
2970 * URB's completion function will not be called.
2971 * We will have to complete the CTLX ourselves.
2973 ctlx
->state
= CTLX_REQ_FAILED
;
2974 unlocked_usbctlx_complete(hw
, ctlx
);
2981 /*----------------------------------------------------------------
2982 * unlocked_usbctlx_complete
2984 * A CTLX has completed. It may have been successful, it may not
2985 * have been. At this point, the CTLX should be quiescent. The URBs
2986 * aren't active and the timers should have been stopped.
2988 * The CTLX is migrated to the "completing" queue, and the completing
2989 * tasklet is scheduled.
2992 * hw ptr to a hfa384x_t structure
2993 * ctlx ptr to a ctlx structure
3001 * Either, assume interrupt
3002 ----------------------------------------------------------------*/
3003 static void unlocked_usbctlx_complete(hfa384x_t
* hw
, hfa384x_usbctlx_t
* ctlx
)
3005 /* Timers have been stopped, and ctlx should be in
3006 * a terminal state. Retire it from the "active"
3009 list_move_tail(&ctlx
->list
, &hw
->ctlxq
.completing
);
3010 tasklet_schedule(&hw
->completion_bh
);
3012 switch (ctlx
->state
) {
3014 case CTLX_REQ_FAILED
:
3015 /* This are the correct terminating states. */
3019 printk(KERN_ERR
"CTLX[%d] not in a terminating state(%s)\n",
3020 le16_to_cpu(ctlx
->outbuf
.type
), ctlxstr(ctlx
->state
));
3025 /*----------------------------------------------------------------
3026 * hfa384x_usbctlxq_run
3028 * Checks to see if the head item is running. If not, starts it.
3031 * hw ptr to hfa384x_t
3040 ----------------------------------------------------------------*/
3041 static void hfa384x_usbctlxq_run(hfa384x_t
* hw
)
3043 unsigned long flags
;
3046 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3048 /* Only one active CTLX at any one time, because there's no
3049 * other (reliable) way to match the response URB to the
3052 * Don't touch any of these CTLXs if the hardware
3053 * has been removed or the USB subsystem is stalled.
3055 if (!list_empty(&hw
->ctlxq
.active
) ||
3056 test_bit(WORK_TX_HALT
, &hw
->usb_flags
) || hw
->wlandev
->hwremoved
)
3059 while (!list_empty(&hw
->ctlxq
.pending
)) {
3060 hfa384x_usbctlx_t
*head
;
3063 /* This is the first pending command */
3064 head
= list_entry(hw
->ctlxq
.pending
.next
,
3065 hfa384x_usbctlx_t
, list
);
3067 /* We need to split this off to avoid a race condition */
3068 list_move_tail(&head
->list
, &hw
->ctlxq
.active
);
3070 /* Fill the out packet */
3071 usb_fill_bulk_urb(&(hw
->ctlx_urb
), hw
->usb
,
3073 &(head
->outbuf
), ROUNDUP64(head
->outbufsize
),
3074 hfa384x_ctlxout_callback
, hw
);
3075 hw
->ctlx_urb
.transfer_flags
|= USB_QUEUE_BULK
;
3077 /* Now submit the URB and update the CTLX's state
3079 if ((result
= SUBMIT_URB(&hw
->ctlx_urb
, GFP_ATOMIC
)) == 0) {
3080 /* This CTLX is now running on the active queue */
3081 head
->state
= CTLX_REQ_SUBMITTED
;
3083 /* Start the OUT wait timer */
3084 hw
->req_timer_done
= 0;
3085 hw
->reqtimer
.expires
= jiffies
+ HZ
;
3086 add_timer(&hw
->reqtimer
);
3088 /* Start the IN wait timer */
3089 hw
->resp_timer_done
= 0;
3090 hw
->resptimer
.expires
= jiffies
+ 2 * HZ
;
3091 add_timer(&hw
->resptimer
);
3096 if (result
== -EPIPE
) {
3097 /* The OUT pipe needs resetting, so put
3098 * this CTLX back in the "pending" queue
3099 * and schedule a reset ...
3102 "%s tx pipe stalled: requesting reset\n",
3103 hw
->wlandev
->netdev
->name
);
3104 list_move(&head
->list
, &hw
->ctlxq
.pending
);
3105 set_bit(WORK_TX_HALT
, &hw
->usb_flags
);
3106 schedule_work(&hw
->usb_work
);
3110 if (result
== -ESHUTDOWN
) {
3111 printk(KERN_WARNING
"%s urb shutdown!\n",
3112 hw
->wlandev
->netdev
->name
);
3116 printk(KERN_ERR
"Failed to submit CTLX[%d]: error=%d\n",
3117 le16_to_cpu(head
->outbuf
.type
), result
);
3118 unlocked_usbctlx_complete(hw
, head
);
3122 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3125 /*----------------------------------------------------------------
3126 * hfa384x_usbin_callback
3128 * Callback for URBs on the BULKIN endpoint.
3131 * urb ptr to the completed urb
3140 ----------------------------------------------------------------*/
3141 static void hfa384x_usbin_callback(struct urb
*urb
)
3143 wlandevice_t
*wlandev
= urb
->context
;
3145 hfa384x_usbin_t
*usbin
= (hfa384x_usbin_t
*) urb
->transfer_buffer
;
3146 struct sk_buff
*skb
= NULL
;
3157 if (!wlandev
|| !wlandev
->netdev
|| wlandev
->hwremoved
)
3164 skb
= hw
->rx_urb_skb
;
3165 BUG_ON(!skb
|| (skb
->data
!= urb
->transfer_buffer
));
3167 hw
->rx_urb_skb
= NULL
;
3169 /* Check for error conditions within the URB */
3170 switch (urb
->status
) {
3174 /* Check for short packet */
3175 if (urb
->actual_length
== 0) {
3176 ++(wlandev
->linux_stats
.rx_errors
);
3177 ++(wlandev
->linux_stats
.rx_length_errors
);
3183 printk(KERN_WARNING
"%s rx pipe stalled: requesting reset\n",
3184 wlandev
->netdev
->name
);
3185 if (!test_and_set_bit(WORK_RX_HALT
, &hw
->usb_flags
))
3186 schedule_work(&hw
->usb_work
);
3187 ++(wlandev
->linux_stats
.rx_errors
);
3194 if (!test_and_set_bit(THROTTLE_RX
, &hw
->usb_flags
) &&
3195 !timer_pending(&hw
->throttle
)) {
3196 mod_timer(&hw
->throttle
, jiffies
+ THROTTLE_JIFFIES
);
3198 ++(wlandev
->linux_stats
.rx_errors
);
3203 ++(wlandev
->linux_stats
.rx_over_errors
);
3209 pr_debug("status=%d, device removed.\n", urb
->status
);
3215 pr_debug("status=%d, urb explicitly unlinked.\n", urb
->status
);
3220 pr_debug("urb status=%d, transfer flags=0x%x\n",
3221 urb
->status
, urb
->transfer_flags
);
3222 ++(wlandev
->linux_stats
.rx_errors
);
3227 urb_status
= urb
->status
;
3229 if (action
!= ABORT
) {
3230 /* Repost the RX URB */
3231 result
= submit_rx_urb(hw
, GFP_ATOMIC
);
3235 "Fatal, failed to resubmit rx_urb. error=%d\n",
3240 /* Handle any USB-IN packet */
3241 /* Note: the check of the sw_support field, the type field doesn't
3242 * have bit 12 set like the docs suggest.
3244 type
= le16_to_cpu(usbin
->type
);
3245 if (HFA384x_USB_ISRXFRM(type
)) {
3246 if (action
== HANDLE
) {
3247 if (usbin
->txfrm
.desc
.sw_support
== 0x0123) {
3248 hfa384x_usbin_txcompl(wlandev
, usbin
);
3250 skb_put(skb
, sizeof(*usbin
));
3251 hfa384x_usbin_rx(wlandev
, skb
);
3257 if (HFA384x_USB_ISTXFRM(type
)) {
3258 if (action
== HANDLE
)
3259 hfa384x_usbin_txcompl(wlandev
, usbin
);
3263 case HFA384x_USB_INFOFRM
:
3264 if (action
== ABORT
)
3266 if (action
== HANDLE
)
3267 hfa384x_usbin_info(wlandev
, usbin
);
3270 case HFA384x_USB_CMDRESP
:
3271 case HFA384x_USB_WRIDRESP
:
3272 case HFA384x_USB_RRIDRESP
:
3273 case HFA384x_USB_WMEMRESP
:
3274 case HFA384x_USB_RMEMRESP
:
3275 /* ALWAYS, ALWAYS, ALWAYS handle this CTLX!!!! */
3276 hfa384x_usbin_ctlx(hw
, usbin
, urb_status
);
3279 case HFA384x_USB_BUFAVAIL
:
3280 pr_debug("Received BUFAVAIL packet, frmlen=%d\n",
3281 usbin
->bufavail
.frmlen
);
3284 case HFA384x_USB_ERROR
:
3285 pr_debug("Received USB_ERROR packet, errortype=%d\n",
3286 usbin
->usberror
.errortype
);
3290 pr_debug("Unrecognized USBIN packet, type=%x, status=%d\n",
3291 usbin
->type
, urb_status
);
3301 /*----------------------------------------------------------------
3302 * hfa384x_usbin_ctlx
3304 * We've received a URB containing a Prism2 "response" message.
3305 * This message needs to be matched up with a CTLX on the active
3306 * queue and our state updated accordingly.
3309 * hw ptr to hfa384x_t
3310 * usbin ptr to USB IN packet
3311 * urb_status status of this Bulk-In URB
3320 ----------------------------------------------------------------*/
3321 static void hfa384x_usbin_ctlx(hfa384x_t
* hw
, hfa384x_usbin_t
* usbin
,
3324 hfa384x_usbctlx_t
*ctlx
;
3326 unsigned long flags
;
3329 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3331 /* There can be only one CTLX on the active queue
3332 * at any one time, and this is the CTLX that the
3333 * timers are waiting for.
3335 if (list_empty(&hw
->ctlxq
.active
))
3338 /* Remove the "response timeout". It's possible that
3339 * we are already too late, and that the timeout is
3340 * already running. And that's just too bad for us,
3341 * because we could lose our CTLX from the active
3344 if (del_timer(&hw
->resptimer
) == 0) {
3345 if (hw
->resp_timer_done
== 0) {
3346 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3350 hw
->resp_timer_done
= 1;
3353 ctlx
= get_active_ctlx(hw
);
3355 if (urb_status
!= 0) {
3357 * Bad CTLX, so get rid of it. But we only
3358 * remove it from the active queue if we're no
3359 * longer expecting the OUT URB to complete.
3361 if (unlocked_usbctlx_cancel_async(hw
, ctlx
) == 0)
3364 const u16 intype
= (usbin
->type
& ~cpu_to_le16(0x8000));
3367 * Check that our message is what we're expecting ...
3369 if (ctlx
->outbuf
.type
!= intype
) {
3371 "Expected IN[%d], received IN[%d] - ignored.\n",
3372 le16_to_cpu(ctlx
->outbuf
.type
),
3373 le16_to_cpu(intype
));
3377 /* This URB has succeeded, so grab the data ... */
3378 memcpy(&ctlx
->inbuf
, usbin
, sizeof(ctlx
->inbuf
));
3380 switch (ctlx
->state
) {
3381 case CTLX_REQ_SUBMITTED
:
3383 * We have received our response URB before
3384 * our request has been acknowledged. Odd,
3385 * but our OUT URB is still alive...
3388 ("Causality violation: please reboot Universe, or email linux-wlan-devel@lists.linux-wlan.com\n");
3389 ctlx
->state
= CTLX_RESP_COMPLETE
;
3392 case CTLX_REQ_COMPLETE
:
3394 * This is the usual path: our request
3395 * has already been acknowledged, and
3396 * now we have received the reply too.
3398 ctlx
->state
= CTLX_COMPLETE
;
3399 unlocked_usbctlx_complete(hw
, ctlx
);
3405 * Throw this CTLX away ...
3408 "Matched IN URB, CTLX[%d] in invalid state(%s)."
3410 le16_to_cpu(ctlx
->outbuf
.type
),
3411 ctlxstr(ctlx
->state
));
3412 if (unlocked_usbctlx_cancel_async(hw
, ctlx
) == 0)
3419 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3422 hfa384x_usbctlxq_run(hw
);
3425 /*----------------------------------------------------------------
3426 * hfa384x_usbin_txcompl
3428 * At this point we have the results of a previous transmit.
3431 * wlandev wlan device
3432 * usbin ptr to the usb transfer buffer
3441 ----------------------------------------------------------------*/
3442 static void hfa384x_usbin_txcompl(wlandevice_t
* wlandev
,
3443 hfa384x_usbin_t
* usbin
)
3447 status
= le16_to_cpu(usbin
->type
); /* yeah I know it says type... */
3449 /* Was there an error? */
3450 if (HFA384x_TXSTATUS_ISERROR(status
))
3451 prism2sta_ev_txexc(wlandev
, status
);
3453 prism2sta_ev_tx(wlandev
, status
);
3456 /*----------------------------------------------------------------
3459 * At this point we have a successful received a rx frame packet.
3462 * wlandev wlan device
3463 * usbin ptr to the usb transfer buffer
3472 ----------------------------------------------------------------*/
3473 static void hfa384x_usbin_rx(wlandevice_t
* wlandev
, struct sk_buff
*skb
)
3475 hfa384x_usbin_t
*usbin
= (hfa384x_usbin_t
*) skb
->data
;
3476 hfa384x_t
*hw
= wlandev
->priv
;
3478 p80211_rxmeta_t
*rxmeta
;
3482 /* Byte order convert once up front. */
3483 usbin
->rxfrm
.desc
.status
= le16_to_cpu(usbin
->rxfrm
.desc
.status
);
3484 usbin
->rxfrm
.desc
.time
= le32_to_cpu(usbin
->rxfrm
.desc
.time
);
3486 /* Now handle frame based on port# */
3487 switch (HFA384x_RXSTATUS_MACPORT_GET(usbin
->rxfrm
.desc
.status
)) {
3489 fc
= le16_to_cpu(usbin
->rxfrm
.desc
.frame_control
);
3491 /* If exclude and we receive an unencrypted, drop it */
3492 if ((wlandev
->hostwep
& HOSTWEP_EXCLUDEUNENCRYPTED
) &&
3493 !WLAN_GET_FC_ISWEP(fc
)) {
3497 data_len
= le16_to_cpu(usbin
->rxfrm
.desc
.data_len
);
3499 /* How much header data do we have? */
3500 hdrlen
= p80211_headerlen(fc
);
3502 /* Pull off the descriptor */
3503 skb_pull(skb
, sizeof(hfa384x_rx_frame_t
));
3505 /* Now shunt the header block up against the data block
3506 * with an "overlapping" copy
3508 memmove(skb_push(skb
, hdrlen
),
3509 &usbin
->rxfrm
.desc
.frame_control
, hdrlen
);
3511 skb
->dev
= wlandev
->netdev
;
3512 skb
->dev
->last_rx
= jiffies
;
3514 /* And set the frame length properly */
3515 skb_trim(skb
, data_len
+ hdrlen
);
3517 /* The prism2 series does not return the CRC */
3518 memset(skb_put(skb
, WLAN_CRC_LEN
), 0xff, WLAN_CRC_LEN
);
3520 skb_reset_mac_header(skb
);
3522 /* Attach the rxmeta, set some stuff */
3523 p80211skb_rxmeta_attach(wlandev
, skb
);
3524 rxmeta
= P80211SKB_RXMETA(skb
);
3525 rxmeta
->mactime
= usbin
->rxfrm
.desc
.time
;
3526 rxmeta
->rxrate
= usbin
->rxfrm
.desc
.rate
;
3527 rxmeta
->signal
= usbin
->rxfrm
.desc
.signal
- hw
->dbmadjust
;
3528 rxmeta
->noise
= usbin
->rxfrm
.desc
.silence
- hw
->dbmadjust
;
3530 prism2sta_ev_rx(wlandev
, skb
);
3535 if (!HFA384x_RXSTATUS_ISFCSERR(usbin
->rxfrm
.desc
.status
)) {
3536 /* Copy to wlansnif skb */
3537 hfa384x_int_rxmonitor(wlandev
, &usbin
->rxfrm
);
3540 pr_debug("Received monitor frame: FCSerr set\n");
3545 printk(KERN_WARNING
"Received frame on unsupported port=%d\n",
3546 HFA384x_RXSTATUS_MACPORT_GET(usbin
->rxfrm
.desc
.status
));
3555 /*----------------------------------------------------------------
3556 * hfa384x_int_rxmonitor
3558 * Helper function for int_rx. Handles monitor frames.
3559 * Note that this function allocates space for the FCS and sets it
3560 * to 0xffffffff. The hfa384x doesn't give us the FCS value but the
3561 * higher layers expect it. 0xffffffff is used as a flag to indicate
3565 * wlandev wlan device structure
3566 * rxfrm rx descriptor read from card in int_rx
3572 * Allocates an skb and passes it up via the PF_PACKET interface.
3575 ----------------------------------------------------------------*/
3576 static void hfa384x_int_rxmonitor(wlandevice_t
* wlandev
,
3577 hfa384x_usb_rxfrm_t
* rxfrm
)
3579 hfa384x_rx_frame_t
*rxdesc
= &(rxfrm
->desc
);
3580 unsigned int hdrlen
= 0;
3581 unsigned int datalen
= 0;
3582 unsigned int skblen
= 0;
3585 struct sk_buff
*skb
;
3586 hfa384x_t
*hw
= wlandev
->priv
;
3588 /* Don't forget the status, time, and data_len fields are in host order */
3589 /* Figure out how big the frame is */
3590 fc
= le16_to_cpu(rxdesc
->frame_control
);
3591 hdrlen
= p80211_headerlen(fc
);
3592 datalen
= le16_to_cpu(rxdesc
->data_len
);
3594 /* Allocate an ind message+framesize skb */
3595 skblen
= sizeof(p80211_caphdr_t
) + hdrlen
+ datalen
+ WLAN_CRC_LEN
;
3597 /* sanity check the length */
3599 (sizeof(p80211_caphdr_t
) +
3600 WLAN_HDR_A4_LEN
+ WLAN_DATA_MAXLEN
+ WLAN_CRC_LEN
)) {
3601 pr_debug("overlen frm: len=%zd\n",
3602 skblen
- sizeof(p80211_caphdr_t
));
3605 if ((skb
= dev_alloc_skb(skblen
)) == NULL
) {
3607 "alloc_skb failed trying to allocate %d bytes\n",
3612 /* only prepend the prism header if in the right mode */
3613 if ((wlandev
->netdev
->type
== ARPHRD_IEEE80211_PRISM
) &&
3614 (hw
->sniffhdr
!= 0)) {
3615 p80211_caphdr_t
*caphdr
;
3616 /* The NEW header format! */
3617 datap
= skb_put(skb
, sizeof(p80211_caphdr_t
));
3618 caphdr
= (p80211_caphdr_t
*) datap
;
3620 caphdr
->version
= htonl(P80211CAPTURE_VERSION
);
3621 caphdr
->length
= htonl(sizeof(p80211_caphdr_t
));
3622 caphdr
->mactime
= __cpu_to_be64(rxdesc
->time
) * 1000;
3623 caphdr
->hosttime
= __cpu_to_be64(jiffies
);
3624 caphdr
->phytype
= htonl(4); /* dss_dot11_b */
3625 caphdr
->channel
= htonl(hw
->sniff_channel
);
3626 caphdr
->datarate
= htonl(rxdesc
->rate
);
3627 caphdr
->antenna
= htonl(0); /* unknown */
3628 caphdr
->priority
= htonl(0); /* unknown */
3629 caphdr
->ssi_type
= htonl(3); /* rssi_raw */
3630 caphdr
->ssi_signal
= htonl(rxdesc
->signal
);
3631 caphdr
->ssi_noise
= htonl(rxdesc
->silence
);
3632 caphdr
->preamble
= htonl(0); /* unknown */
3633 caphdr
->encoding
= htonl(1); /* cck */
3636 /* Copy the 802.11 header to the skb (ctl frames may be less than a full header) */
3637 datap
= skb_put(skb
, hdrlen
);
3638 memcpy(datap
, &(rxdesc
->frame_control
), hdrlen
);
3640 /* If any, copy the data from the card to the skb */
3642 datap
= skb_put(skb
, datalen
);
3643 memcpy(datap
, rxfrm
->data
, datalen
);
3645 /* check for unencrypted stuff if WEP bit set. */
3646 if (*(datap
- hdrlen
+ 1) & 0x40) /* wep set */
3647 if ((*(datap
) == 0xaa) && (*(datap
+ 1) == 0xaa))
3648 *(datap
- hdrlen
+ 1) &= 0xbf; // clear wep; it's the 802.2 header!
3651 if (hw
->sniff_fcs
) {
3653 datap
= skb_put(skb
, WLAN_CRC_LEN
);
3654 memset(datap
, 0xff, WLAN_CRC_LEN
);
3657 /* pass it back up */
3658 prism2sta_ev_rx(wlandev
, skb
);
3663 /*----------------------------------------------------------------
3664 * hfa384x_usbin_info
3666 * At this point we have a successful received a Prism2 info frame.
3669 * wlandev wlan device
3670 * usbin ptr to the usb transfer buffer
3679 ----------------------------------------------------------------*/
3680 static void hfa384x_usbin_info(wlandevice_t
* wlandev
, hfa384x_usbin_t
* usbin
)
3682 usbin
->infofrm
.info
.framelen
=
3683 le16_to_cpu(usbin
->infofrm
.info
.framelen
);
3684 prism2sta_ev_info(wlandev
, &usbin
->infofrm
.info
);
3687 /*----------------------------------------------------------------
3688 * hfa384x_usbout_callback
3690 * Callback for URBs on the BULKOUT endpoint.
3693 * urb ptr to the completed urb
3702 ----------------------------------------------------------------*/
3703 static void hfa384x_usbout_callback(struct urb
*urb
)
3705 wlandevice_t
*wlandev
= urb
->context
;
3706 hfa384x_usbout_t
*usbout
= urb
->transfer_buffer
;
3712 if (wlandev
&& wlandev
->netdev
) {
3714 switch (urb
->status
) {
3716 hfa384x_usbout_tx(wlandev
, usbout
);
3721 hfa384x_t
*hw
= wlandev
->priv
;
3723 "%s tx pipe stalled: requesting reset\n",
3724 wlandev
->netdev
->name
);
3725 if (!test_and_set_bit
3726 (WORK_TX_HALT
, &hw
->usb_flags
))
3727 schedule_work(&hw
->usb_work
);
3728 ++(wlandev
->linux_stats
.tx_errors
);
3736 hfa384x_t
*hw
= wlandev
->priv
;
3738 if (!test_and_set_bit
3739 (THROTTLE_TX
, &hw
->usb_flags
)
3740 && !timer_pending(&hw
->throttle
)) {
3741 mod_timer(&hw
->throttle
,
3742 jiffies
+ THROTTLE_JIFFIES
);
3744 ++(wlandev
->linux_stats
.tx_errors
);
3745 netif_stop_queue(wlandev
->netdev
);
3751 /* Ignorable errors */
3755 printk(KERN_INFO
"unknown urb->status=%d\n",
3757 ++(wlandev
->linux_stats
.tx_errors
);
3763 /*----------------------------------------------------------------
3764 * hfa384x_ctlxout_callback
3766 * Callback for control data on the BULKOUT endpoint.
3769 * urb ptr to the completed urb
3778 ----------------------------------------------------------------*/
3779 static void hfa384x_ctlxout_callback(struct urb
*urb
)
3781 hfa384x_t
*hw
= urb
->context
;
3782 int delete_resptimer
= 0;
3785 hfa384x_usbctlx_t
*ctlx
;
3786 unsigned long flags
;
3788 pr_debug("urb->status=%d\n", urb
->status
);
3792 if ((urb
->status
== -ESHUTDOWN
) ||
3793 (urb
->status
== -ENODEV
) || (hw
== NULL
))
3797 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3800 * Only one CTLX at a time on the "active" list, and
3801 * none at all if we are unplugged. However, we can
3802 * rely on the disconnect function to clean everything
3803 * up if someone unplugged the adapter.
3805 if (list_empty(&hw
->ctlxq
.active
)) {
3806 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3811 * Having something on the "active" queue means
3812 * that we have timers to worry about ...
3814 if (del_timer(&hw
->reqtimer
) == 0) {
3815 if (hw
->req_timer_done
== 0) {
3817 * This timer was actually running while we
3818 * were trying to delete it. Let it terminate
3819 * gracefully instead.
3821 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3825 hw
->req_timer_done
= 1;
3828 ctlx
= get_active_ctlx(hw
);
3830 if (urb
->status
== 0) {
3831 /* Request portion of a CTLX is successful */
3832 switch (ctlx
->state
) {
3833 case CTLX_REQ_SUBMITTED
:
3834 /* This OUT-ACK received before IN */
3835 ctlx
->state
= CTLX_REQ_COMPLETE
;
3838 case CTLX_RESP_COMPLETE
:
3839 /* IN already received before this OUT-ACK,
3840 * so this command must now be complete.
3842 ctlx
->state
= CTLX_COMPLETE
;
3843 unlocked_usbctlx_complete(hw
, ctlx
);
3848 /* This is NOT a valid CTLX "success" state! */
3850 "Illegal CTLX[%d] success state(%s, %d) in OUT URB\n",
3851 le16_to_cpu(ctlx
->outbuf
.type
),
3852 ctlxstr(ctlx
->state
), urb
->status
);
3856 /* If the pipe has stalled then we need to reset it */
3857 if ((urb
->status
== -EPIPE
) &&
3858 !test_and_set_bit(WORK_TX_HALT
, &hw
->usb_flags
)) {
3860 "%s tx pipe stalled: requesting reset\n",
3861 hw
->wlandev
->netdev
->name
);
3862 schedule_work(&hw
->usb_work
);
3865 /* If someone cancels the OUT URB then its status
3866 * should be either -ECONNRESET or -ENOENT.
3868 ctlx
->state
= CTLX_REQ_FAILED
;
3869 unlocked_usbctlx_complete(hw
, ctlx
);
3870 delete_resptimer
= 1;
3875 if (delete_resptimer
) {
3876 if ((timer_ok
= del_timer(&hw
->resptimer
)) != 0) {
3877 hw
->resp_timer_done
= 1;
3881 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3883 if (!timer_ok
&& (hw
->resp_timer_done
== 0)) {
3884 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3889 hfa384x_usbctlxq_run(hw
);
3895 /*----------------------------------------------------------------
3896 * hfa384x_usbctlx_reqtimerfn
3898 * Timer response function for CTLX request timeouts. If this
3899 * function is called, it means that the callback for the OUT
3900 * URB containing a Prism2.x XXX_Request was never called.
3903 * data a ptr to the hfa384x_t
3912 ----------------------------------------------------------------*/
3913 static void hfa384x_usbctlx_reqtimerfn(unsigned long data
)
3915 hfa384x_t
*hw
= (hfa384x_t
*) data
;
3916 unsigned long flags
;
3918 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3920 hw
->req_timer_done
= 1;
3922 /* Removing the hardware automatically empties
3923 * the active list ...
3925 if (!list_empty(&hw
->ctlxq
.active
)) {
3927 * We must ensure that our URB is removed from
3928 * the system, if it hasn't already expired.
3930 hw
->ctlx_urb
.transfer_flags
|= URB_ASYNC_UNLINK
;
3931 if (usb_unlink_urb(&hw
->ctlx_urb
) == -EINPROGRESS
) {
3932 hfa384x_usbctlx_t
*ctlx
= get_active_ctlx(hw
);
3934 ctlx
->state
= CTLX_REQ_FAILED
;
3936 /* This URB was active, but has now been
3937 * cancelled. It will now have a status of
3938 * -ECONNRESET in the callback function.
3940 * We are cancelling this CTLX, so we're
3941 * not going to need to wait for a response.
3942 * The URB's callback function will check
3943 * that this timer is truly dead.
3945 if (del_timer(&hw
->resptimer
) != 0)
3946 hw
->resp_timer_done
= 1;
3950 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3953 /*----------------------------------------------------------------
3954 * hfa384x_usbctlx_resptimerfn
3956 * Timer response function for CTLX response timeouts. If this
3957 * function is called, it means that the callback for the IN
3958 * URB containing a Prism2.x XXX_Response was never called.
3961 * data a ptr to the hfa384x_t
3970 ----------------------------------------------------------------*/
3971 static void hfa384x_usbctlx_resptimerfn(unsigned long data
)
3973 hfa384x_t
*hw
= (hfa384x_t
*) data
;
3974 unsigned long flags
;
3976 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3978 hw
->resp_timer_done
= 1;
3980 /* The active list will be empty if the
3981 * adapter has been unplugged ...
3983 if (!list_empty(&hw
->ctlxq
.active
)) {
3984 hfa384x_usbctlx_t
*ctlx
= get_active_ctlx(hw
);
3986 if (unlocked_usbctlx_cancel_async(hw
, ctlx
) == 0) {
3987 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3988 hfa384x_usbctlxq_run(hw
);
3993 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
4000 /*----------------------------------------------------------------
4001 * hfa384x_usb_throttlefn
4014 ----------------------------------------------------------------*/
4015 static void hfa384x_usb_throttlefn(unsigned long data
)
4017 hfa384x_t
*hw
= (hfa384x_t
*) data
;
4018 unsigned long flags
;
4020 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
4023 * We need to check BOTH the RX and the TX throttle controls,
4024 * so we use the bitwise OR instead of the logical OR.
4026 pr_debug("flags=0x%lx\n", hw
->usb_flags
);
4027 if (!hw
->wlandev
->hwremoved
&&
4028 ((test_and_clear_bit(THROTTLE_RX
, &hw
->usb_flags
) &&
4029 !test_and_set_bit(WORK_RX_RESUME
, &hw
->usb_flags
))
4031 (test_and_clear_bit(THROTTLE_TX
, &hw
->usb_flags
) &&
4032 !test_and_set_bit(WORK_TX_RESUME
, &hw
->usb_flags
))
4034 schedule_work(&hw
->usb_work
);
4037 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
4040 /*----------------------------------------------------------------
4041 * hfa384x_usbctlx_submit
4043 * Called from the doxxx functions to submit a CTLX to the queue
4046 * hw ptr to the hw struct
4047 * ctlx ctlx structure to enqueue
4050 * -ENODEV if the adapter is unplugged
4056 * process or interrupt
4057 ----------------------------------------------------------------*/
4058 static int hfa384x_usbctlx_submit(hfa384x_t
* hw
, hfa384x_usbctlx_t
* ctlx
)
4060 unsigned long flags
;
4063 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
4065 if (hw
->wlandev
->hwremoved
) {
4066 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
4069 ctlx
->state
= CTLX_PENDING
;
4070 list_add_tail(&ctlx
->list
, &hw
->ctlxq
.pending
);
4072 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
4073 hfa384x_usbctlxq_run(hw
);
4080 /*----------------------------------------------------------------
4083 * At this point we have finished a send of a frame. Mark the URB
4084 * as available and call ev_alloc to notify higher layers we're
4088 * wlandev wlan device
4089 * usbout ptr to the usb transfer buffer
4098 ----------------------------------------------------------------*/
4099 static void hfa384x_usbout_tx(wlandevice_t
* wlandev
, hfa384x_usbout_t
* usbout
)
4101 prism2sta_ev_alloc(wlandev
);
4104 /*----------------------------------------------------------------
4105 * hfa384x_isgood_pdrcore
4107 * Quick check of PDR codes.
4110 * pdrcode PDR code number (host order)
4119 ----------------------------------------------------------------*/
4120 static int hfa384x_isgood_pdrcode(u16 pdrcode
)
4123 case HFA384x_PDR_END_OF_PDA
:
4124 case HFA384x_PDR_PCB_PARTNUM
:
4125 case HFA384x_PDR_PDAVER
:
4126 case HFA384x_PDR_NIC_SERIAL
:
4127 case HFA384x_PDR_MKK_MEASUREMENTS
:
4128 case HFA384x_PDR_NIC_RAMSIZE
:
4129 case HFA384x_PDR_MFISUPRANGE
:
4130 case HFA384x_PDR_CFISUPRANGE
:
4131 case HFA384x_PDR_NICID
:
4132 case HFA384x_PDR_MAC_ADDRESS
:
4133 case HFA384x_PDR_REGDOMAIN
:
4134 case HFA384x_PDR_ALLOWED_CHANNEL
:
4135 case HFA384x_PDR_DEFAULT_CHANNEL
:
4136 case HFA384x_PDR_TEMPTYPE
:
4137 case HFA384x_PDR_IFR_SETTING
:
4138 case HFA384x_PDR_RFR_SETTING
:
4139 case HFA384x_PDR_HFA3861_BASELINE
:
4140 case HFA384x_PDR_HFA3861_SHADOW
:
4141 case HFA384x_PDR_HFA3861_IFRF
:
4142 case HFA384x_PDR_HFA3861_CHCALSP
:
4143 case HFA384x_PDR_HFA3861_CHCALI
:
4144 case HFA384x_PDR_3842_NIC_CONFIG
:
4145 case HFA384x_PDR_USB_ID
:
4146 case HFA384x_PDR_PCI_ID
:
4147 case HFA384x_PDR_PCI_IFCONF
:
4148 case HFA384x_PDR_PCI_PMCONF
:
4149 case HFA384x_PDR_RFENRGY
:
4150 case HFA384x_PDR_HFA3861_MANF_TESTSP
:
4151 case HFA384x_PDR_HFA3861_MANF_TESTI
:
4156 if (pdrcode
< 0x1000) {
4157 /* code is OK, but we don't know exactly what it is */
4158 pr_debug("Encountered unknown PDR#=0x%04x, "
4159 "assuming it's ok.\n", pdrcode
);
4163 pr_debug("Encountered unknown PDR#=0x%04x, "
4164 "(>=0x1000), assuming it's bad.\n", pdrcode
);
4169 return 0; /* avoid compiler warnings */