1 /* src/prism2/driver/hfa384x_usb.c
3 * Functions that talk to the USB variantof the Intersil hfa384x MAC
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
6 * --------------------------------------------------------------------
10 * The contents of this file are subject to the Mozilla Public
11 * License Version 1.1 (the "License"); you may not use this file
12 * except in compliance with the License. You may obtain a copy of
13 * the License at http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS
16 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 * implied. See the License for the specific language governing
18 * rights and limitations under the License.
20 * Alternatively, the contents of this file may be used under the
21 * terms of the GNU Public License version 2 (the "GPL"), in which
22 * case the provisions of the GPL are applicable instead of the
23 * above. If you wish to allow the use of your version of this file
24 * only under the terms of the GPL and not to allow others to use
25 * your version of this file under the MPL, indicate your decision
26 * by deleting the provisions above and replace them with the notice
27 * and other provisions required by the GPL. If you do not delete
28 * the provisions above, a recipient may use your version of this
29 * file under either the MPL or the GPL.
31 * --------------------------------------------------------------------
33 * Inquiries regarding the linux-wlan Open Source project can be
36 * AbsoluteValue Systems Inc.
38 * http://www.linux-wlan.com
40 * --------------------------------------------------------------------
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
45 * --------------------------------------------------------------------
47 * This file implements functions that correspond to the prism2/hfa384x
48 * 802.11 MAC hardware and firmware host interface.
50 * The functions can be considered to represent several levels of
51 * abstraction. The lowest level functions are simply C-callable wrappers
52 * around the register accesses. The next higher level represents C-callable
53 * prism2 API functions that match the Intersil documentation as closely
54 * as is reasonable. The next higher layer implements common sequences
55 * of invocations of the API layer (e.g. write to bap, followed by cmd).
58 * hfa384x_drvr_xxx Highest level abstractions provided by the
59 * hfa384x code. They are driver defined wrappers
60 * for common sequences. These functions generally
61 * use the services of the lower levels.
63 * hfa384x_drvr_xxxconfig An example of the drvr level abstraction. These
64 * functions are wrappers for the RID get/set
65 * sequence. They call copy_[to|from]_bap() and
66 * cmd_access(). These functions operate on the
67 * RIDs and buffers without validation. The caller
68 * is responsible for that.
70 * API wrapper functions:
71 * hfa384x_cmd_xxx functions that provide access to the f/w commands.
72 * The function arguments correspond to each command
73 * argument, even command arguments that get packed
74 * into single registers. These functions _just_
75 * issue the command by setting the cmd/parm regs
76 * & reading the status/resp regs. Additional
77 * activities required to fully use a command
78 * (read/write from/to bap, get/set int status etc.)
79 * are implemented separately. Think of these as
80 * C-callable prism2 commands.
82 * Lowest Layer Functions:
83 * hfa384x_docmd_xxx These functions implement the sequence required
84 * to issue any prism2 command. Primarily used by the
85 * hfa384x_cmd_xxx functions.
87 * hfa384x_bap_xxx BAP read/write access functions.
88 * Note: we usually use BAP0 for non-interrupt context
89 * and BAP1 for interrupt context.
91 * hfa384x_dl_xxx download related functions.
93 * Driver State Issues:
94 * Note that there are two pairs of functions that manage the
95 * 'initialized' and 'running' states of the hw/MAC combo. The four
96 * functions are create(), destroy(), start(), and stop(). create()
97 * sets up the data structures required to support the hfa384x_*
98 * functions and destroy() cleans them up. The start() function gets
99 * the actual hardware running and enables the interrupts. The stop()
100 * function shuts the hardware down. The sequence should be:
104 * . Do interesting things w/ the hardware
109 * Note that destroy() can be called without calling stop() first.
110 * --------------------------------------------------------------------
113 #include <linux/module.h>
114 #include <linux/kernel.h>
115 #include <linux/sched.h>
116 #include <linux/types.h>
117 #include <linux/slab.h>
118 #include <linux/wireless.h>
119 #include <linux/netdevice.h>
120 #include <linux/timer.h>
121 #include <linux/io.h>
122 #include <linux/delay.h>
123 #include <asm/byteorder.h>
124 #include <linux/bitops.h>
125 #include <linux/list.h>
126 #include <linux/usb.h>
127 #include <linux/byteorder/generic.h>
129 #define SUBMIT_URB(u, f) usb_submit_urb(u, f)
131 #include "p80211types.h"
132 #include "p80211hdr.h"
133 #include "p80211mgmt.h"
134 #include "p80211conv.h"
135 #include "p80211msg.h"
136 #include "p80211netdev.h"
137 #include "p80211req.h"
138 #include "p80211metadef.h"
139 #include "p80211metastruct.h"
141 #include "prism2mgmt.h"
148 #define THROTTLE_JIFFIES (HZ/8)
149 #define URB_ASYNC_UNLINK 0
150 #define USB_QUEUE_BULK 0
152 #define ROUNDUP64(a) (((a)+63)&~63)
155 static void dbprint_urb(struct urb
*urb
);
159 hfa384x_int_rxmonitor(wlandevice_t
*wlandev
, hfa384x_usb_rxfrm_t
*rxfrm
);
161 static void hfa384x_usb_defer(struct work_struct
*data
);
163 static int submit_rx_urb(hfa384x_t
*hw
, gfp_t flags
);
165 static int submit_tx_urb(hfa384x_t
*hw
, struct urb
*tx_urb
, gfp_t flags
);
167 /*---------------------------------------------------*/
169 static void hfa384x_usbout_callback(struct urb
*urb
);
170 static void hfa384x_ctlxout_callback(struct urb
*urb
);
171 static void hfa384x_usbin_callback(struct urb
*urb
);
174 hfa384x_usbin_txcompl(wlandevice_t
*wlandev
, hfa384x_usbin_t
*usbin
);
176 static void hfa384x_usbin_rx(wlandevice_t
*wlandev
, struct sk_buff
*skb
);
178 static void hfa384x_usbin_info(wlandevice_t
*wlandev
, hfa384x_usbin_t
*usbin
);
181 hfa384x_usbout_tx(wlandevice_t
*wlandev
, hfa384x_usbout_t
*usbout
);
183 static void hfa384x_usbin_ctlx(hfa384x_t
*hw
, hfa384x_usbin_t
*usbin
,
186 /*---------------------------------------------------*/
187 /* Functions to support the prism2 usb command queue */
189 static void hfa384x_usbctlxq_run(hfa384x_t
*hw
);
191 static void hfa384x_usbctlx_reqtimerfn(unsigned long data
);
193 static void hfa384x_usbctlx_resptimerfn(unsigned long data
);
195 static void hfa384x_usb_throttlefn(unsigned long data
);
197 static void hfa384x_usbctlx_completion_task(unsigned long data
);
199 static void hfa384x_usbctlx_reaper_task(unsigned long data
);
201 static int hfa384x_usbctlx_submit(hfa384x_t
*hw
, hfa384x_usbctlx_t
*ctlx
);
203 static void unlocked_usbctlx_complete(hfa384x_t
*hw
, hfa384x_usbctlx_t
*ctlx
);
205 struct usbctlx_completor
{
206 int (*complete
)(struct usbctlx_completor
*);
210 hfa384x_usbctlx_complete_sync(hfa384x_t
*hw
,
211 hfa384x_usbctlx_t
*ctlx
,
212 struct usbctlx_completor
*completor
);
215 unlocked_usbctlx_cancel_async(hfa384x_t
*hw
, hfa384x_usbctlx_t
*ctlx
);
217 static void hfa384x_cb_status(hfa384x_t
*hw
, const hfa384x_usbctlx_t
*ctlx
);
219 static void hfa384x_cb_rrid(hfa384x_t
*hw
, const hfa384x_usbctlx_t
*ctlx
);
222 usbctlx_get_status(const hfa384x_usb_cmdresp_t
*cmdresp
,
223 hfa384x_cmdresult_t
*result
);
226 usbctlx_get_rridresult(const hfa384x_usb_rridresp_t
*rridresp
,
227 hfa384x_rridresult_t
*result
);
229 /*---------------------------------------------------*/
230 /* Low level req/resp CTLX formatters and submitters */
232 hfa384x_docmd(hfa384x_t
*hw
,
234 hfa384x_metacmd_t
*cmd
,
235 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
238 hfa384x_dorrid(hfa384x_t
*hw
,
242 unsigned int riddatalen
,
243 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
246 hfa384x_dowrid(hfa384x_t
*hw
,
250 unsigned int riddatalen
,
251 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
254 hfa384x_dormem(hfa384x_t
*hw
,
260 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
263 hfa384x_dowmem(hfa384x_t
*hw
,
269 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
);
271 static int hfa384x_isgood_pdrcode(u16 pdrcode
);
273 static inline const char *ctlxstr(CTLX_STATE s
)
275 static const char * const ctlx_str
[] = {
280 "Request packet submitted",
281 "Request packet completed",
282 "Response packet completed"
288 static inline hfa384x_usbctlx_t
*get_active_ctlx(hfa384x_t
*hw
)
290 return list_entry(hw
->ctlxq
.active
.next
, hfa384x_usbctlx_t
, list
);
294 void dbprint_urb(struct urb
*urb
)
296 pr_debug("urb->pipe=0x%08x\n", urb
->pipe
);
297 pr_debug("urb->status=0x%08x\n", urb
->status
);
298 pr_debug("urb->transfer_flags=0x%08x\n", urb
->transfer_flags
);
299 pr_debug("urb->transfer_buffer=0x%08x\n",
300 (unsigned int)urb
->transfer_buffer
);
301 pr_debug("urb->transfer_buffer_length=0x%08x\n",
302 urb
->transfer_buffer_length
);
303 pr_debug("urb->actual_length=0x%08x\n", urb
->actual_length
);
304 pr_debug("urb->bandwidth=0x%08x\n", urb
->bandwidth
);
305 pr_debug("urb->setup_packet(ctl)=0x%08x\n",
306 (unsigned int)urb
->setup_packet
);
307 pr_debug("urb->start_frame(iso/irq)=0x%08x\n", urb
->start_frame
);
308 pr_debug("urb->interval(irq)=0x%08x\n", urb
->interval
);
309 pr_debug("urb->error_count(iso)=0x%08x\n", urb
->error_count
);
310 pr_debug("urb->timeout=0x%08x\n", urb
->timeout
);
311 pr_debug("urb->context=0x%08x\n", (unsigned int)urb
->context
);
312 pr_debug("urb->complete=0x%08x\n", (unsigned int)urb
->complete
);
316 /*----------------------------------------------------------------
319 * Listen for input data on the BULK-IN pipe. If the pipe has
320 * stalled then schedule it to be reset.
324 * memflags memory allocation flags
327 * error code from submission
331 ----------------------------------------------------------------*/
332 static int submit_rx_urb(hfa384x_t
*hw
, gfp_t memflags
)
337 skb
= dev_alloc_skb(sizeof(hfa384x_usbin_t
));
343 /* Post the IN urb */
344 usb_fill_bulk_urb(&hw
->rx_urb
, hw
->usb
,
346 skb
->data
, sizeof(hfa384x_usbin_t
),
347 hfa384x_usbin_callback
, hw
->wlandev
);
349 hw
->rx_urb_skb
= skb
;
352 if (!hw
->wlandev
->hwremoved
&&
353 !test_bit(WORK_RX_HALT
, &hw
->usb_flags
)) {
354 result
= SUBMIT_URB(&hw
->rx_urb
, memflags
);
356 /* Check whether we need to reset the RX pipe */
357 if (result
== -EPIPE
) {
358 netdev_warn(hw
->wlandev
->netdev
,
359 "%s rx pipe stalled: requesting reset\n",
360 hw
->wlandev
->netdev
->name
);
361 if (!test_and_set_bit(WORK_RX_HALT
, &hw
->usb_flags
))
362 schedule_work(&hw
->usb_work
);
366 /* Don't leak memory if anything should go wrong */
369 hw
->rx_urb_skb
= NULL
;
376 /*----------------------------------------------------------------
379 * Prepares and submits the URB of transmitted data. If the
380 * submission fails then it will schedule the output pipe to
385 * tx_urb URB of data for transmission
386 * memflags memory allocation flags
389 * error code from submission
393 ----------------------------------------------------------------*/
394 static int submit_tx_urb(hfa384x_t
*hw
, struct urb
*tx_urb
, gfp_t memflags
)
396 struct net_device
*netdev
= hw
->wlandev
->netdev
;
400 if (netif_running(netdev
)) {
401 if (!hw
->wlandev
->hwremoved
&&
402 !test_bit(WORK_TX_HALT
, &hw
->usb_flags
)) {
403 result
= SUBMIT_URB(tx_urb
, memflags
);
405 /* Test whether we need to reset the TX pipe */
406 if (result
== -EPIPE
) {
407 netdev_warn(hw
->wlandev
->netdev
,
408 "%s tx pipe stalled: requesting reset\n",
410 set_bit(WORK_TX_HALT
, &hw
->usb_flags
);
411 schedule_work(&hw
->usb_work
);
412 } else if (result
== 0) {
413 netif_stop_queue(netdev
);
421 /*----------------------------------------------------------------
424 * There are some things that the USB stack cannot do while
425 * in interrupt context, so we arrange this function to run
426 * in process context.
429 * hw device structure
435 * process (by design)
436 ----------------------------------------------------------------*/
437 static void hfa384x_usb_defer(struct work_struct
*data
)
439 hfa384x_t
*hw
= container_of(data
, struct hfa384x
, usb_work
);
440 struct net_device
*netdev
= hw
->wlandev
->netdev
;
442 /* Don't bother trying to reset anything if the plug
443 * has been pulled ...
445 if (hw
->wlandev
->hwremoved
)
448 /* Reception has stopped: try to reset the input pipe */
449 if (test_bit(WORK_RX_HALT
, &hw
->usb_flags
)) {
452 usb_kill_urb(&hw
->rx_urb
); /* Cannot be holding spinlock! */
454 ret
= usb_clear_halt(hw
->usb
, hw
->endp_in
);
456 netdev_err(hw
->wlandev
->netdev
,
457 "Failed to clear rx pipe for %s: err=%d\n",
460 netdev_info(hw
->wlandev
->netdev
, "%s rx pipe reset complete.\n",
462 clear_bit(WORK_RX_HALT
, &hw
->usb_flags
);
463 set_bit(WORK_RX_RESUME
, &hw
->usb_flags
);
467 /* Resume receiving data back from the device. */
468 if (test_bit(WORK_RX_RESUME
, &hw
->usb_flags
)) {
471 ret
= submit_rx_urb(hw
, GFP_KERNEL
);
473 netdev_err(hw
->wlandev
->netdev
,
474 "Failed to resume %s rx pipe.\n",
477 clear_bit(WORK_RX_RESUME
, &hw
->usb_flags
);
481 /* Transmission has stopped: try to reset the output pipe */
482 if (test_bit(WORK_TX_HALT
, &hw
->usb_flags
)) {
485 usb_kill_urb(&hw
->tx_urb
);
486 ret
= usb_clear_halt(hw
->usb
, hw
->endp_out
);
488 netdev_err(hw
->wlandev
->netdev
,
489 "Failed to clear tx pipe for %s: err=%d\n",
492 netdev_info(hw
->wlandev
->netdev
, "%s tx pipe reset complete.\n",
494 clear_bit(WORK_TX_HALT
, &hw
->usb_flags
);
495 set_bit(WORK_TX_RESUME
, &hw
->usb_flags
);
497 /* Stopping the BULK-OUT pipe also blocked
498 * us from sending any more CTLX URBs, so
499 * we need to re-run our queue ...
501 hfa384x_usbctlxq_run(hw
);
505 /* Resume transmitting. */
506 if (test_and_clear_bit(WORK_TX_RESUME
, &hw
->usb_flags
))
507 netif_wake_queue(hw
->wlandev
->netdev
);
510 /*----------------------------------------------------------------
513 * Sets up the hfa384x_t data structure for use. Note this
514 * does _not_ initialize the actual hardware, just the data structures
515 * we use to keep track of its state.
518 * hw device structure
519 * irq device irq number
520 * iobase i/o base address for register access
521 * membase memory base address for register access
530 ----------------------------------------------------------------*/
531 void hfa384x_create(hfa384x_t
*hw
, struct usb_device
*usb
)
533 memset(hw
, 0, sizeof(hfa384x_t
));
536 /* set up the endpoints */
537 hw
->endp_in
= usb_rcvbulkpipe(usb
, 1);
538 hw
->endp_out
= usb_sndbulkpipe(usb
, 2);
540 /* Set up the waitq */
541 init_waitqueue_head(&hw
->cmdq
);
543 /* Initialize the command queue */
544 spin_lock_init(&hw
->ctlxq
.lock
);
545 INIT_LIST_HEAD(&hw
->ctlxq
.pending
);
546 INIT_LIST_HEAD(&hw
->ctlxq
.active
);
547 INIT_LIST_HEAD(&hw
->ctlxq
.completing
);
548 INIT_LIST_HEAD(&hw
->ctlxq
.reapable
);
550 /* Initialize the authentication queue */
551 skb_queue_head_init(&hw
->authq
);
553 tasklet_init(&hw
->reaper_bh
,
554 hfa384x_usbctlx_reaper_task
, (unsigned long)hw
);
555 tasklet_init(&hw
->completion_bh
,
556 hfa384x_usbctlx_completion_task
, (unsigned long)hw
);
557 INIT_WORK(&hw
->link_bh
, prism2sta_processing_defer
);
558 INIT_WORK(&hw
->usb_work
, hfa384x_usb_defer
);
560 setup_timer(&hw
->throttle
, hfa384x_usb_throttlefn
, (unsigned long)hw
);
562 setup_timer(&hw
->resptimer
, hfa384x_usbctlx_resptimerfn
,
565 setup_timer(&hw
->reqtimer
, hfa384x_usbctlx_reqtimerfn
,
568 usb_init_urb(&hw
->rx_urb
);
569 usb_init_urb(&hw
->tx_urb
);
570 usb_init_urb(&hw
->ctlx_urb
);
572 hw
->link_status
= HFA384x_LINK_NOTCONNECTED
;
573 hw
->state
= HFA384x_STATE_INIT
;
575 INIT_WORK(&hw
->commsqual_bh
, prism2sta_commsqual_defer
);
576 setup_timer(&hw
->commsqual_timer
, prism2sta_commsqual_timer
,
580 /*----------------------------------------------------------------
583 * Partner to hfa384x_create(). This function cleans up the hw
584 * structure so that it can be freed by the caller using a simple
585 * kfree. Currently, this function is just a placeholder. If, at some
586 * point in the future, an hw in the 'shutdown' state requires a 'deep'
587 * kfree, this is where it should be done. Note that if this function
588 * is called on a _running_ hw structure, the drvr_stop() function is
592 * hw device structure
595 * nothing, this function is not allowed to fail.
601 ----------------------------------------------------------------*/
602 void hfa384x_destroy(hfa384x_t
*hw
)
606 if (hw
->state
== HFA384x_STATE_RUNNING
)
607 hfa384x_drvr_stop(hw
);
608 hw
->state
= HFA384x_STATE_PREINIT
;
610 kfree(hw
->scanresults
);
611 hw
->scanresults
= NULL
;
613 /* Now to clean out the auth queue */
614 while ((skb
= skb_dequeue(&hw
->authq
)))
618 static hfa384x_usbctlx_t
*usbctlx_alloc(void)
620 hfa384x_usbctlx_t
*ctlx
;
622 ctlx
= kmalloc(sizeof(*ctlx
), in_interrupt() ? GFP_ATOMIC
: GFP_KERNEL
);
624 memset(ctlx
, 0, sizeof(*ctlx
));
625 init_completion(&ctlx
->done
);
632 usbctlx_get_status(const hfa384x_usb_cmdresp_t
*cmdresp
,
633 hfa384x_cmdresult_t
*result
)
635 result
->status
= le16_to_cpu(cmdresp
->status
);
636 result
->resp0
= le16_to_cpu(cmdresp
->resp0
);
637 result
->resp1
= le16_to_cpu(cmdresp
->resp1
);
638 result
->resp2
= le16_to_cpu(cmdresp
->resp2
);
640 pr_debug("cmdresult:status=0x%04x resp0=0x%04x resp1=0x%04x resp2=0x%04x\n",
641 result
->status
, result
->resp0
, result
->resp1
, result
->resp2
);
643 return result
->status
& HFA384x_STATUS_RESULT
;
647 usbctlx_get_rridresult(const hfa384x_usb_rridresp_t
*rridresp
,
648 hfa384x_rridresult_t
*result
)
650 result
->rid
= le16_to_cpu(rridresp
->rid
);
651 result
->riddata
= rridresp
->data
;
652 result
->riddata_len
= ((le16_to_cpu(rridresp
->frmlen
) - 1) * 2);
655 /*----------------------------------------------------------------
657 * This completor must be passed to hfa384x_usbctlx_complete_sync()
658 * when processing a CTLX that returns a hfa384x_cmdresult_t structure.
659 ----------------------------------------------------------------*/
660 struct usbctlx_cmd_completor
{
661 struct usbctlx_completor head
;
663 const hfa384x_usb_cmdresp_t
*cmdresp
;
664 hfa384x_cmdresult_t
*result
;
667 static inline int usbctlx_cmd_completor_fn(struct usbctlx_completor
*head
)
669 struct usbctlx_cmd_completor
*complete
;
671 complete
= (struct usbctlx_cmd_completor
*)head
;
672 return usbctlx_get_status(complete
->cmdresp
, complete
->result
);
675 static inline struct usbctlx_completor
*init_cmd_completor(
676 struct usbctlx_cmd_completor
678 const hfa384x_usb_cmdresp_t
680 hfa384x_cmdresult_t
*result
)
682 completor
->head
.complete
= usbctlx_cmd_completor_fn
;
683 completor
->cmdresp
= cmdresp
;
684 completor
->result
= result
;
685 return &(completor
->head
);
688 /*----------------------------------------------------------------
690 * This completor must be passed to hfa384x_usbctlx_complete_sync()
691 * when processing a CTLX that reads a RID.
692 ----------------------------------------------------------------*/
693 struct usbctlx_rrid_completor
{
694 struct usbctlx_completor head
;
696 const hfa384x_usb_rridresp_t
*rridresp
;
698 unsigned int riddatalen
;
701 static int usbctlx_rrid_completor_fn(struct usbctlx_completor
*head
)
703 struct usbctlx_rrid_completor
*complete
;
704 hfa384x_rridresult_t rridresult
;
706 complete
= (struct usbctlx_rrid_completor
*)head
;
707 usbctlx_get_rridresult(complete
->rridresp
, &rridresult
);
709 /* Validate the length, note body len calculation in bytes */
710 if (rridresult
.riddata_len
!= complete
->riddatalen
) {
711 pr_warn("RID len mismatch, rid=0x%04x hlen=%d fwlen=%d\n",
713 complete
->riddatalen
, rridresult
.riddata_len
);
717 memcpy(complete
->riddata
, rridresult
.riddata
, complete
->riddatalen
);
721 static inline struct usbctlx_completor
*init_rrid_completor(
722 struct usbctlx_rrid_completor
724 const hfa384x_usb_rridresp_t
727 unsigned int riddatalen
)
729 completor
->head
.complete
= usbctlx_rrid_completor_fn
;
730 completor
->rridresp
= rridresp
;
731 completor
->riddata
= riddata
;
732 completor
->riddatalen
= riddatalen
;
733 return &(completor
->head
);
736 /*----------------------------------------------------------------
738 * Interprets the results of a synchronous RID-write
739 ----------------------------------------------------------------*/
740 #define init_wrid_completor init_cmd_completor
742 /*----------------------------------------------------------------
744 * Interprets the results of a synchronous memory-write
745 ----------------------------------------------------------------*/
746 #define init_wmem_completor init_cmd_completor
748 /*----------------------------------------------------------------
750 * Interprets the results of a synchronous memory-read
751 ----------------------------------------------------------------*/
752 struct usbctlx_rmem_completor
{
753 struct usbctlx_completor head
;
755 const hfa384x_usb_rmemresp_t
*rmemresp
;
760 static int usbctlx_rmem_completor_fn(struct usbctlx_completor
*head
)
762 struct usbctlx_rmem_completor
*complete
=
763 (struct usbctlx_rmem_completor
*)head
;
765 pr_debug("rmemresp:len=%d\n", complete
->rmemresp
->frmlen
);
766 memcpy(complete
->data
, complete
->rmemresp
->data
, complete
->len
);
770 static inline struct usbctlx_completor
*init_rmem_completor(
771 struct usbctlx_rmem_completor
773 hfa384x_usb_rmemresp_t
778 completor
->head
.complete
= usbctlx_rmem_completor_fn
;
779 completor
->rmemresp
= rmemresp
;
780 completor
->data
= data
;
781 completor
->len
= len
;
782 return &(completor
->head
);
785 /*----------------------------------------------------------------
788 * Ctlx_complete handler for async CMD type control exchanges.
789 * mark the hw struct as such.
791 * Note: If the handling is changed here, it should probably be
792 * changed in docmd as well.
796 * ctlx completed CTLX
805 ----------------------------------------------------------------*/
806 static void hfa384x_cb_status(hfa384x_t
*hw
, const hfa384x_usbctlx_t
*ctlx
)
808 if (ctlx
->usercb
!= NULL
) {
809 hfa384x_cmdresult_t cmdresult
;
811 if (ctlx
->state
!= CTLX_COMPLETE
) {
812 memset(&cmdresult
, 0, sizeof(cmdresult
));
814 HFA384x_STATUS_RESULT_SET(HFA384x_CMD_ERR
);
816 usbctlx_get_status(&ctlx
->inbuf
.cmdresp
, &cmdresult
);
819 ctlx
->usercb(hw
, &cmdresult
, ctlx
->usercb_data
);
823 /*----------------------------------------------------------------
826 * CTLX completion handler for async RRID type control exchanges.
828 * Note: If the handling is changed here, it should probably be
829 * changed in dorrid as well.
833 * ctlx completed CTLX
842 ----------------------------------------------------------------*/
843 static void hfa384x_cb_rrid(hfa384x_t
*hw
, const hfa384x_usbctlx_t
*ctlx
)
845 if (ctlx
->usercb
!= NULL
) {
846 hfa384x_rridresult_t rridresult
;
848 if (ctlx
->state
!= CTLX_COMPLETE
) {
849 memset(&rridresult
, 0, sizeof(rridresult
));
850 rridresult
.rid
= le16_to_cpu(ctlx
->outbuf
.rridreq
.rid
);
852 usbctlx_get_rridresult(&ctlx
->inbuf
.rridresp
,
856 ctlx
->usercb(hw
, &rridresult
, ctlx
->usercb_data
);
860 static inline int hfa384x_docmd_wait(hfa384x_t
*hw
, hfa384x_metacmd_t
*cmd
)
862 return hfa384x_docmd(hw
, DOWAIT
, cmd
, NULL
, NULL
, NULL
);
866 hfa384x_docmd_async(hfa384x_t
*hw
,
867 hfa384x_metacmd_t
*cmd
,
868 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
870 return hfa384x_docmd(hw
, DOASYNC
, cmd
, cmdcb
, usercb
, usercb_data
);
874 hfa384x_dorrid_wait(hfa384x_t
*hw
, u16 rid
, void *riddata
,
875 unsigned int riddatalen
)
877 return hfa384x_dorrid(hw
, DOWAIT
,
878 rid
, riddata
, riddatalen
, NULL
, NULL
, NULL
);
882 hfa384x_dorrid_async(hfa384x_t
*hw
,
883 u16 rid
, void *riddata
, unsigned int riddatalen
,
885 ctlx_usercb_t usercb
, void *usercb_data
)
887 return hfa384x_dorrid(hw
, DOASYNC
,
888 rid
, riddata
, riddatalen
,
889 cmdcb
, usercb
, usercb_data
);
893 hfa384x_dowrid_wait(hfa384x_t
*hw
, u16 rid
, void *riddata
,
894 unsigned int riddatalen
)
896 return hfa384x_dowrid(hw
, DOWAIT
,
897 rid
, riddata
, riddatalen
, NULL
, NULL
, NULL
);
901 hfa384x_dowrid_async(hfa384x_t
*hw
,
902 u16 rid
, void *riddata
, unsigned int riddatalen
,
904 ctlx_usercb_t usercb
, void *usercb_data
)
906 return hfa384x_dowrid(hw
, DOASYNC
,
907 rid
, riddata
, riddatalen
,
908 cmdcb
, usercb
, usercb_data
);
912 hfa384x_dormem_wait(hfa384x_t
*hw
,
913 u16 page
, u16 offset
, void *data
, unsigned int len
)
915 return hfa384x_dormem(hw
, DOWAIT
,
916 page
, offset
, data
, len
, NULL
, NULL
, NULL
);
920 hfa384x_dormem_async(hfa384x_t
*hw
,
921 u16 page
, u16 offset
, void *data
, unsigned int len
,
923 ctlx_usercb_t usercb
, void *usercb_data
)
925 return hfa384x_dormem(hw
, DOASYNC
,
926 page
, offset
, data
, len
,
927 cmdcb
, usercb
, usercb_data
);
931 hfa384x_dowmem_wait(hfa384x_t
*hw
,
932 u16 page
, u16 offset
, void *data
, unsigned int len
)
934 return hfa384x_dowmem(hw
, DOWAIT
,
935 page
, offset
, data
, len
, NULL
, NULL
, NULL
);
939 hfa384x_dowmem_async(hfa384x_t
*hw
,
945 ctlx_usercb_t usercb
, void *usercb_data
)
947 return hfa384x_dowmem(hw
, DOASYNC
,
948 page
, offset
, data
, len
,
949 cmdcb
, usercb
, usercb_data
);
952 /*----------------------------------------------------------------
953 * hfa384x_cmd_initialize
955 * Issues the initialize command and sets the hw->state based
959 * hw device structure
963 * >0 f/w reported error - f/w status code
964 * <0 driver reported error
970 ----------------------------------------------------------------*/
971 int hfa384x_cmd_initialize(hfa384x_t
*hw
)
975 hfa384x_metacmd_t cmd
;
977 cmd
.cmd
= HFA384x_CMDCODE_INIT
;
982 result
= hfa384x_docmd_wait(hw
, &cmd
);
984 pr_debug("cmdresp.init: status=0x%04x, resp0=0x%04x, resp1=0x%04x, resp2=0x%04x\n",
986 cmd
.result
.resp0
, cmd
.result
.resp1
, cmd
.result
.resp2
);
988 for (i
= 0; i
< HFA384x_NUMPORTS_MAX
; i
++)
989 hw
->port_enabled
[i
] = 0;
992 hw
->link_status
= HFA384x_LINK_NOTCONNECTED
;
997 /*----------------------------------------------------------------
998 * hfa384x_cmd_disable
1000 * Issues the disable command to stop communications on one of
1004 * hw device structure
1005 * macport MAC port number (host order)
1009 * >0 f/w reported failure - f/w status code
1010 * <0 driver reported error (timeout|bad arg)
1016 ----------------------------------------------------------------*/
1017 int hfa384x_cmd_disable(hfa384x_t
*hw
, u16 macport
)
1020 hfa384x_metacmd_t cmd
;
1022 cmd
.cmd
= HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DISABLE
) |
1023 HFA384x_CMD_MACPORT_SET(macport
);
1028 result
= hfa384x_docmd_wait(hw
, &cmd
);
1033 /*----------------------------------------------------------------
1034 * hfa384x_cmd_enable
1036 * Issues the enable command to enable communications on one of
1040 * hw device structure
1041 * macport MAC port number
1045 * >0 f/w reported failure - f/w status code
1046 * <0 driver reported error (timeout|bad arg)
1052 ----------------------------------------------------------------*/
1053 int hfa384x_cmd_enable(hfa384x_t
*hw
, u16 macport
)
1056 hfa384x_metacmd_t cmd
;
1058 cmd
.cmd
= HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ENABLE
) |
1059 HFA384x_CMD_MACPORT_SET(macport
);
1064 result
= hfa384x_docmd_wait(hw
, &cmd
);
1069 /*----------------------------------------------------------------
1070 * hfa384x_cmd_monitor
1072 * Enables the 'monitor mode' of the MAC. Here's the description of
1073 * monitor mode that I've received thus far:
1075 * "The "monitor mode" of operation is that the MAC passes all
1076 * frames for which the PLCP checks are correct. All received
1077 * MPDUs are passed to the host with MAC Port = 7, with a
1078 * receive status of good, FCS error, or undecryptable. Passing
1079 * certain MPDUs is a violation of the 802.11 standard, but useful
1080 * for a debugging tool." Normal communication is not possible
1081 * while monitor mode is enabled.
1084 * hw device structure
1085 * enable a code (0x0b|0x0f) that enables/disables
1086 * monitor mode. (host order)
1090 * >0 f/w reported failure - f/w status code
1091 * <0 driver reported error (timeout|bad arg)
1097 ----------------------------------------------------------------*/
1098 int hfa384x_cmd_monitor(hfa384x_t
*hw
, u16 enable
)
1101 hfa384x_metacmd_t cmd
;
1103 cmd
.cmd
= HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR
) |
1104 HFA384x_CMD_AINFO_SET(enable
);
1109 result
= hfa384x_docmd_wait(hw
, &cmd
);
1114 /*----------------------------------------------------------------
1115 * hfa384x_cmd_download
1117 * Sets the controls for the MAC controller code/data download
1118 * process. The arguments set the mode and address associated
1119 * with a download. Note that the aux registers should be enabled
1120 * prior to setting one of the download enable modes.
1123 * hw device structure
1124 * mode 0 - Disable programming and begin code exec
1125 * 1 - Enable volatile mem programming
1126 * 2 - Enable non-volatile mem programming
1127 * 3 - Program non-volatile section from NV download
1131 * highaddr For mode 1, sets the high & low order bits of
1132 * the "destination address". This address will be
1133 * the execution start address when download is
1134 * subsequently disabled.
1135 * For mode 2, sets the high & low order bits of
1136 * the destination in NV ram.
1137 * For modes 0 & 3, should be zero. (host order)
1138 * NOTE: these are CMD format.
1139 * codelen Length of the data to write in mode 2,
1140 * zero otherwise. (host order)
1144 * >0 f/w reported failure - f/w status code
1145 * <0 driver reported error (timeout|bad arg)
1151 ----------------------------------------------------------------*/
1152 int hfa384x_cmd_download(hfa384x_t
*hw
, u16 mode
, u16 lowaddr
,
1153 u16 highaddr
, u16 codelen
)
1156 hfa384x_metacmd_t cmd
;
1158 pr_debug("mode=%d, lowaddr=0x%04x, highaddr=0x%04x, codelen=%d\n",
1159 mode
, lowaddr
, highaddr
, codelen
);
1161 cmd
.cmd
= (HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DOWNLD
) |
1162 HFA384x_CMD_PROGMODE_SET(mode
));
1164 cmd
.parm0
= lowaddr
;
1165 cmd
.parm1
= highaddr
;
1166 cmd
.parm2
= codelen
;
1168 result
= hfa384x_docmd_wait(hw
, &cmd
);
1173 /*----------------------------------------------------------------
1176 * Perform a reset of the hfa38xx MAC core. We assume that the hw
1177 * structure is in its "created" state. That is, it is initialized
1178 * with proper values. Note that if a reset is done after the
1179 * device has been active for awhile, the caller might have to clean
1180 * up some leftover cruft in the hw structure.
1183 * hw device structure
1184 * holdtime how long (in ms) to hold the reset
1185 * settletime how long (in ms) to wait after releasing
1195 ----------------------------------------------------------------*/
1196 int hfa384x_corereset(hfa384x_t
*hw
, int holdtime
, int settletime
, int genesis
)
1200 result
= usb_reset_device(hw
->usb
);
1202 netdev_err(hw
->wlandev
->netdev
, "usb_reset_device() failed, result=%d.\n",
1209 /*----------------------------------------------------------------
1210 * hfa384x_usbctlx_complete_sync
1212 * Waits for a synchronous CTLX object to complete,
1213 * and then handles the response.
1216 * hw device structure
1218 * completor functor object to decide what to
1219 * do with the CTLX's result.
1223 * -ERESTARTSYS Interrupted by a signal
1225 * -ENODEV Adapter was unplugged
1226 * ??? Result from completor
1232 ----------------------------------------------------------------*/
1233 static int hfa384x_usbctlx_complete_sync(hfa384x_t
*hw
,
1234 hfa384x_usbctlx_t
*ctlx
,
1235 struct usbctlx_completor
*completor
)
1237 unsigned long flags
;
1240 result
= wait_for_completion_interruptible(&ctlx
->done
);
1242 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
1245 * We can only handle the CTLX if the USB disconnect
1246 * function has not run yet ...
1249 if (hw
->wlandev
->hwremoved
) {
1250 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1252 } else if (result
!= 0) {
1256 * We were probably interrupted, so delete
1257 * this CTLX asynchronously, kill the timers
1258 * and the URB, and then start the next
1261 * NOTE: We can only delete the timers and
1262 * the URB if this CTLX is active.
1264 if (ctlx
== get_active_ctlx(hw
)) {
1265 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1267 del_singleshot_timer_sync(&hw
->reqtimer
);
1268 del_singleshot_timer_sync(&hw
->resptimer
);
1269 hw
->req_timer_done
= 1;
1270 hw
->resp_timer_done
= 1;
1271 usb_kill_urb(&hw
->ctlx_urb
);
1273 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
1278 * This scenario is so unlikely that I'm
1279 * happy with a grubby "goto" solution ...
1281 if (hw
->wlandev
->hwremoved
)
1286 * The completion task will send this CTLX
1287 * to the reaper the next time it runs. We
1288 * are no longer in a hurry.
1291 ctlx
->state
= CTLX_REQ_FAILED
;
1292 list_move_tail(&ctlx
->list
, &hw
->ctlxq
.completing
);
1294 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1297 hfa384x_usbctlxq_run(hw
);
1299 if (ctlx
->state
== CTLX_COMPLETE
) {
1300 result
= completor
->complete(completor
);
1302 netdev_warn(hw
->wlandev
->netdev
, "CTLX[%d] error: state(%s)\n",
1303 le16_to_cpu(ctlx
->outbuf
.type
),
1304 ctlxstr(ctlx
->state
));
1308 list_del(&ctlx
->list
);
1309 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
1316 /*----------------------------------------------------------------
1319 * Constructs a command CTLX and submits it.
1321 * NOTE: Any changes to the 'post-submit' code in this function
1322 * need to be carried over to hfa384x_cbcmd() since the handling
1323 * is virtually identical.
1326 * hw device structure
1327 * mode DOWAIT or DOASYNC
1328 * cmd cmd structure. Includes all arguments and result
1329 * data points. All in host order. in host order
1330 * cmdcb command-specific callback
1331 * usercb user callback for async calls, NULL for DOWAIT calls
1332 * usercb_data user supplied data pointer for async calls, NULL
1338 * -ERESTARTSYS Awakened on signal
1339 * >0 command indicated error, Status and Resp0-2 are
1347 ----------------------------------------------------------------*/
1349 hfa384x_docmd(hfa384x_t
*hw
,
1351 hfa384x_metacmd_t
*cmd
,
1352 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1355 hfa384x_usbctlx_t
*ctlx
;
1357 ctlx
= usbctlx_alloc();
1363 /* Initialize the command */
1364 ctlx
->outbuf
.cmdreq
.type
= cpu_to_le16(HFA384x_USB_CMDREQ
);
1365 ctlx
->outbuf
.cmdreq
.cmd
= cpu_to_le16(cmd
->cmd
);
1366 ctlx
->outbuf
.cmdreq
.parm0
= cpu_to_le16(cmd
->parm0
);
1367 ctlx
->outbuf
.cmdreq
.parm1
= cpu_to_le16(cmd
->parm1
);
1368 ctlx
->outbuf
.cmdreq
.parm2
= cpu_to_le16(cmd
->parm2
);
1370 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.cmdreq
);
1372 pr_debug("cmdreq: cmd=0x%04x parm0=0x%04x parm1=0x%04x parm2=0x%04x\n",
1373 cmd
->cmd
, cmd
->parm0
, cmd
->parm1
, cmd
->parm2
);
1375 ctlx
->reapable
= mode
;
1376 ctlx
->cmdcb
= cmdcb
;
1377 ctlx
->usercb
= usercb
;
1378 ctlx
->usercb_data
= usercb_data
;
1380 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1383 } else if (mode
== DOWAIT
) {
1384 struct usbctlx_cmd_completor completor
;
1387 hfa384x_usbctlx_complete_sync(hw
, ctlx
,
1388 init_cmd_completor(&completor
,
1400 /*----------------------------------------------------------------
1403 * Constructs a read rid CTLX and issues it.
1405 * NOTE: Any changes to the 'post-submit' code in this function
1406 * need to be carried over to hfa384x_cbrrid() since the handling
1407 * is virtually identical.
1410 * hw device structure
1411 * mode DOWAIT or DOASYNC
1412 * rid Read RID number (host order)
1413 * riddata Caller supplied buffer that MAC formatted RID.data
1414 * record will be written to for DOWAIT calls. Should
1415 * be NULL for DOASYNC calls.
1416 * riddatalen Buffer length for DOWAIT calls. Zero for DOASYNC calls.
1417 * cmdcb command callback for async calls, NULL for DOWAIT calls
1418 * usercb user callback for async calls, NULL for DOWAIT calls
1419 * usercb_data user supplied data pointer for async calls, NULL
1425 * -ERESTARTSYS Awakened on signal
1426 * -ENODATA riddatalen != macdatalen
1427 * >0 command indicated error, Status and Resp0-2 are
1433 * interrupt (DOASYNC)
1434 * process (DOWAIT or DOASYNC)
1435 ----------------------------------------------------------------*/
1437 hfa384x_dorrid(hfa384x_t
*hw
,
1441 unsigned int riddatalen
,
1442 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1445 hfa384x_usbctlx_t
*ctlx
;
1447 ctlx
= usbctlx_alloc();
1453 /* Initialize the command */
1454 ctlx
->outbuf
.rridreq
.type
= cpu_to_le16(HFA384x_USB_RRIDREQ
);
1455 ctlx
->outbuf
.rridreq
.frmlen
=
1456 cpu_to_le16(sizeof(ctlx
->outbuf
.rridreq
.rid
));
1457 ctlx
->outbuf
.rridreq
.rid
= cpu_to_le16(rid
);
1459 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.rridreq
);
1461 ctlx
->reapable
= mode
;
1462 ctlx
->cmdcb
= cmdcb
;
1463 ctlx
->usercb
= usercb
;
1464 ctlx
->usercb_data
= usercb_data
;
1466 /* Submit the CTLX */
1467 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1470 } else if (mode
== DOWAIT
) {
1471 struct usbctlx_rrid_completor completor
;
1474 hfa384x_usbctlx_complete_sync(hw
, ctlx
,
1477 &ctlx
->inbuf
.rridresp
,
1478 riddata
, riddatalen
));
1485 /*----------------------------------------------------------------
1488 * Constructs a write rid CTLX and issues it.
1490 * NOTE: Any changes to the 'post-submit' code in this function
1491 * need to be carried over to hfa384x_cbwrid() since the handling
1492 * is virtually identical.
1495 * hw device structure
1496 * enum cmd_mode DOWAIT or DOASYNC
1498 * riddata Data portion of RID formatted for MAC
1499 * riddatalen Length of the data portion in bytes
1500 * cmdcb command callback for async calls, NULL for DOWAIT calls
1501 * usercb user callback for async calls, NULL for DOWAIT calls
1502 * usercb_data user supplied data pointer for async calls
1506 * -ETIMEDOUT timed out waiting for register ready or
1507 * command completion
1508 * >0 command indicated error, Status and Resp0-2 are
1514 * interrupt (DOASYNC)
1515 * process (DOWAIT or DOASYNC)
1516 ----------------------------------------------------------------*/
1518 hfa384x_dowrid(hfa384x_t
*hw
,
1522 unsigned int riddatalen
,
1523 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1526 hfa384x_usbctlx_t
*ctlx
;
1528 ctlx
= usbctlx_alloc();
1534 /* Initialize the command */
1535 ctlx
->outbuf
.wridreq
.type
= cpu_to_le16(HFA384x_USB_WRIDREQ
);
1536 ctlx
->outbuf
.wridreq
.frmlen
= cpu_to_le16((sizeof
1537 (ctlx
->outbuf
.wridreq
.rid
) +
1538 riddatalen
+ 1) / 2);
1539 ctlx
->outbuf
.wridreq
.rid
= cpu_to_le16(rid
);
1540 memcpy(ctlx
->outbuf
.wridreq
.data
, riddata
, riddatalen
);
1542 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.wridreq
.type
) +
1543 sizeof(ctlx
->outbuf
.wridreq
.frmlen
) +
1544 sizeof(ctlx
->outbuf
.wridreq
.rid
) + riddatalen
;
1546 ctlx
->reapable
= mode
;
1547 ctlx
->cmdcb
= cmdcb
;
1548 ctlx
->usercb
= usercb
;
1549 ctlx
->usercb_data
= usercb_data
;
1551 /* Submit the CTLX */
1552 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1555 } else if (mode
== DOWAIT
) {
1556 struct usbctlx_cmd_completor completor
;
1557 hfa384x_cmdresult_t wridresult
;
1559 result
= hfa384x_usbctlx_complete_sync(hw
,
1563 &ctlx
->inbuf
.wridresp
,
1571 /*----------------------------------------------------------------
1574 * Constructs a readmem CTLX and issues it.
1576 * NOTE: Any changes to the 'post-submit' code in this function
1577 * need to be carried over to hfa384x_cbrmem() since the handling
1578 * is virtually identical.
1581 * hw device structure
1582 * mode DOWAIT or DOASYNC
1583 * page MAC address space page (CMD format)
1584 * offset MAC address space offset
1585 * data Ptr to data buffer to receive read
1586 * len Length of the data to read (max == 2048)
1587 * cmdcb command callback for async calls, NULL for DOWAIT calls
1588 * usercb user callback for async calls, NULL for DOWAIT calls
1589 * usercb_data user supplied data pointer for async calls
1593 * -ETIMEDOUT timed out waiting for register ready or
1594 * command completion
1595 * >0 command indicated error, Status and Resp0-2 are
1601 * interrupt (DOASYNC)
1602 * process (DOWAIT or DOASYNC)
1603 ----------------------------------------------------------------*/
1605 hfa384x_dormem(hfa384x_t
*hw
,
1611 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1614 hfa384x_usbctlx_t
*ctlx
;
1616 ctlx
= usbctlx_alloc();
1622 /* Initialize the command */
1623 ctlx
->outbuf
.rmemreq
.type
= cpu_to_le16(HFA384x_USB_RMEMREQ
);
1624 ctlx
->outbuf
.rmemreq
.frmlen
=
1625 cpu_to_le16(sizeof(ctlx
->outbuf
.rmemreq
.offset
) +
1626 sizeof(ctlx
->outbuf
.rmemreq
.page
) + len
);
1627 ctlx
->outbuf
.rmemreq
.offset
= cpu_to_le16(offset
);
1628 ctlx
->outbuf
.rmemreq
.page
= cpu_to_le16(page
);
1630 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.rmemreq
);
1632 pr_debug("type=0x%04x frmlen=%d offset=0x%04x page=0x%04x\n",
1633 ctlx
->outbuf
.rmemreq
.type
,
1634 ctlx
->outbuf
.rmemreq
.frmlen
,
1635 ctlx
->outbuf
.rmemreq
.offset
, ctlx
->outbuf
.rmemreq
.page
);
1637 pr_debug("pktsize=%zd\n", ROUNDUP64(sizeof(ctlx
->outbuf
.rmemreq
)));
1639 ctlx
->reapable
= mode
;
1640 ctlx
->cmdcb
= cmdcb
;
1641 ctlx
->usercb
= usercb
;
1642 ctlx
->usercb_data
= usercb_data
;
1644 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1647 } else if (mode
== DOWAIT
) {
1648 struct usbctlx_rmem_completor completor
;
1651 hfa384x_usbctlx_complete_sync(hw
, ctlx
,
1654 &ctlx
->inbuf
.rmemresp
, data
,
1662 /*----------------------------------------------------------------
1665 * Constructs a writemem CTLX and issues it.
1667 * NOTE: Any changes to the 'post-submit' code in this function
1668 * need to be carried over to hfa384x_cbwmem() since the handling
1669 * is virtually identical.
1672 * hw device structure
1673 * mode DOWAIT or DOASYNC
1674 * page MAC address space page (CMD format)
1675 * offset MAC address space offset
1676 * data Ptr to data buffer containing write data
1677 * len Length of the data to read (max == 2048)
1678 * cmdcb command callback for async calls, NULL for DOWAIT calls
1679 * usercb user callback for async calls, NULL for DOWAIT calls
1680 * usercb_data user supplied data pointer for async calls.
1684 * -ETIMEDOUT timed out waiting for register ready or
1685 * command completion
1686 * >0 command indicated error, Status and Resp0-2 are
1692 * interrupt (DOWAIT)
1693 * process (DOWAIT or DOASYNC)
1694 ----------------------------------------------------------------*/
1696 hfa384x_dowmem(hfa384x_t
*hw
,
1702 ctlx_cmdcb_t cmdcb
, ctlx_usercb_t usercb
, void *usercb_data
)
1705 hfa384x_usbctlx_t
*ctlx
;
1707 pr_debug("page=0x%04x offset=0x%04x len=%d\n", page
, offset
, len
);
1709 ctlx
= usbctlx_alloc();
1715 /* Initialize the command */
1716 ctlx
->outbuf
.wmemreq
.type
= cpu_to_le16(HFA384x_USB_WMEMREQ
);
1717 ctlx
->outbuf
.wmemreq
.frmlen
=
1718 cpu_to_le16(sizeof(ctlx
->outbuf
.wmemreq
.offset
) +
1719 sizeof(ctlx
->outbuf
.wmemreq
.page
) + len
);
1720 ctlx
->outbuf
.wmemreq
.offset
= cpu_to_le16(offset
);
1721 ctlx
->outbuf
.wmemreq
.page
= cpu_to_le16(page
);
1722 memcpy(ctlx
->outbuf
.wmemreq
.data
, data
, len
);
1724 ctlx
->outbufsize
= sizeof(ctlx
->outbuf
.wmemreq
.type
) +
1725 sizeof(ctlx
->outbuf
.wmemreq
.frmlen
) +
1726 sizeof(ctlx
->outbuf
.wmemreq
.offset
) +
1727 sizeof(ctlx
->outbuf
.wmemreq
.page
) + len
;
1729 ctlx
->reapable
= mode
;
1730 ctlx
->cmdcb
= cmdcb
;
1731 ctlx
->usercb
= usercb
;
1732 ctlx
->usercb_data
= usercb_data
;
1734 result
= hfa384x_usbctlx_submit(hw
, ctlx
);
1737 } else if (mode
== DOWAIT
) {
1738 struct usbctlx_cmd_completor completor
;
1739 hfa384x_cmdresult_t wmemresult
;
1741 result
= hfa384x_usbctlx_complete_sync(hw
,
1745 &ctlx
->inbuf
.wmemresp
,
1753 /*----------------------------------------------------------------
1754 * hfa384x_drvr_commtallies
1756 * Send a commtallies inquiry to the MAC. Note that this is an async
1757 * call that will result in an info frame arriving sometime later.
1760 * hw device structure
1769 ----------------------------------------------------------------*/
1770 int hfa384x_drvr_commtallies(hfa384x_t
*hw
)
1772 hfa384x_metacmd_t cmd
;
1774 cmd
.cmd
= HFA384x_CMDCODE_INQ
;
1775 cmd
.parm0
= HFA384x_IT_COMMTALLIES
;
1779 hfa384x_docmd_async(hw
, &cmd
, NULL
, NULL
, NULL
);
1784 /*----------------------------------------------------------------
1785 * hfa384x_drvr_disable
1787 * Issues the disable command to stop communications on one of
1788 * the MACs 'ports'. Only macport 0 is valid for stations.
1789 * APs may also disable macports 1-6. Only ports that have been
1790 * previously enabled may be disabled.
1793 * hw device structure
1794 * macport MAC port number (host order)
1798 * >0 f/w reported failure - f/w status code
1799 * <0 driver reported error (timeout|bad arg)
1805 ----------------------------------------------------------------*/
1806 int hfa384x_drvr_disable(hfa384x_t
*hw
, u16 macport
)
1810 if ((!hw
->isap
&& macport
!= 0) ||
1811 (hw
->isap
&& !(macport
<= HFA384x_PORTID_MAX
)) ||
1812 !(hw
->port_enabled
[macport
])) {
1815 result
= hfa384x_cmd_disable(hw
, macport
);
1817 hw
->port_enabled
[macport
] = 0;
1822 /*----------------------------------------------------------------
1823 * hfa384x_drvr_enable
1825 * Issues the enable command to enable communications on one of
1826 * the MACs 'ports'. Only macport 0 is valid for stations.
1827 * APs may also enable macports 1-6. Only ports that are currently
1828 * disabled may be enabled.
1831 * hw device structure
1832 * macport MAC port number
1836 * >0 f/w reported failure - f/w status code
1837 * <0 driver reported error (timeout|bad arg)
1843 ----------------------------------------------------------------*/
1844 int hfa384x_drvr_enable(hfa384x_t
*hw
, u16 macport
)
1848 if ((!hw
->isap
&& macport
!= 0) ||
1849 (hw
->isap
&& !(macport
<= HFA384x_PORTID_MAX
)) ||
1850 (hw
->port_enabled
[macport
])) {
1853 result
= hfa384x_cmd_enable(hw
, macport
);
1855 hw
->port_enabled
[macport
] = 1;
1860 /*----------------------------------------------------------------
1861 * hfa384x_drvr_flashdl_enable
1863 * Begins the flash download state. Checks to see that we're not
1864 * already in a download state and that a port isn't enabled.
1865 * Sets the download state and retrieves the flash download
1866 * buffer location, buffer size, and timeout length.
1869 * hw device structure
1873 * >0 f/w reported error - f/w status code
1874 * <0 driver reported error
1880 ----------------------------------------------------------------*/
1881 int hfa384x_drvr_flashdl_enable(hfa384x_t
*hw
)
1886 /* Check that a port isn't active */
1887 for (i
= 0; i
< HFA384x_PORTID_MAX
; i
++) {
1888 if (hw
->port_enabled
[i
]) {
1889 pr_debug("called when port enabled.\n");
1894 /* Check that we're not already in a download state */
1895 if (hw
->dlstate
!= HFA384x_DLSTATE_DISABLED
)
1898 /* Retrieve the buffer loc&size and timeout */
1899 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_DOWNLOADBUFFER
,
1900 &(hw
->bufinfo
), sizeof(hw
->bufinfo
));
1904 hw
->bufinfo
.page
= le16_to_cpu(hw
->bufinfo
.page
);
1905 hw
->bufinfo
.offset
= le16_to_cpu(hw
->bufinfo
.offset
);
1906 hw
->bufinfo
.len
= le16_to_cpu(hw
->bufinfo
.len
);
1907 result
= hfa384x_drvr_getconfig16(hw
, HFA384x_RID_MAXLOADTIME
,
1912 hw
->dltimeout
= le16_to_cpu(hw
->dltimeout
);
1914 pr_debug("flashdl_enable\n");
1916 hw
->dlstate
= HFA384x_DLSTATE_FLASHENABLED
;
1921 /*----------------------------------------------------------------
1922 * hfa384x_drvr_flashdl_disable
1924 * Ends the flash download state. Note that this will cause the MAC
1925 * firmware to restart.
1928 * hw device structure
1932 * >0 f/w reported error - f/w status code
1933 * <0 driver reported error
1939 ----------------------------------------------------------------*/
1940 int hfa384x_drvr_flashdl_disable(hfa384x_t
*hw
)
1942 /* Check that we're already in the download state */
1943 if (hw
->dlstate
!= HFA384x_DLSTATE_FLASHENABLED
)
1946 pr_debug("flashdl_enable\n");
1948 /* There isn't much we can do at this point, so I don't */
1949 /* bother w/ the return value */
1950 hfa384x_cmd_download(hw
, HFA384x_PROGMODE_DISABLE
, 0, 0, 0);
1951 hw
->dlstate
= HFA384x_DLSTATE_DISABLED
;
1956 /*----------------------------------------------------------------
1957 * hfa384x_drvr_flashdl_write
1959 * Performs a FLASH download of a chunk of data. First checks to see
1960 * that we're in the FLASH download state, then sets the download
1961 * mode, uses the aux functions to 1) copy the data to the flash
1962 * buffer, 2) sets the download 'write flash' mode, 3) readback and
1963 * compare. Lather rinse, repeat as many times an necessary to get
1964 * all the given data into flash.
1965 * When all data has been written using this function (possibly
1966 * repeatedly), call drvr_flashdl_disable() to end the download state
1967 * and restart the MAC.
1970 * hw device structure
1971 * daddr Card address to write to. (host order)
1972 * buf Ptr to data to write.
1973 * len Length of data (host order).
1977 * >0 f/w reported error - f/w status code
1978 * <0 driver reported error
1984 ----------------------------------------------------------------*/
1985 int hfa384x_drvr_flashdl_write(hfa384x_t
*hw
, u32 daddr
, void *buf
, u32 len
)
2002 pr_debug("daddr=0x%08x len=%d\n", daddr
, len
);
2004 /* Check that we're in the flash download state */
2005 if (hw
->dlstate
!= HFA384x_DLSTATE_FLASHENABLED
)
2008 netdev_info(hw
->wlandev
->netdev
,
2009 "Download %d bytes to flash @0x%06x\n", len
, daddr
);
2011 /* Convert to flat address for arithmetic */
2012 /* NOTE: dlbuffer RID stores the address in AUX format */
2014 HFA384x_ADDR_AUX_MKFLAT(hw
->bufinfo
.page
, hw
->bufinfo
.offset
);
2015 pr_debug("dlbuf.page=0x%04x dlbuf.offset=0x%04x dlbufaddr=0x%08x\n",
2016 hw
->bufinfo
.page
, hw
->bufinfo
.offset
, dlbufaddr
);
2017 /* Calculations to determine how many fills of the dlbuffer to do
2018 * and how many USB wmemreq's to do for each fill. At this point
2019 * in time, the dlbuffer size and the wmemreq size are the same.
2020 * Therefore, nwrites should always be 1. The extra complexity
2021 * here is a hedge against future changes.
2024 /* Figure out how many times to do the flash programming */
2025 nburns
= len
/ hw
->bufinfo
.len
;
2026 nburns
+= (len
% hw
->bufinfo
.len
) ? 1 : 0;
2028 /* For each flash program cycle, how many USB wmemreq's are needed? */
2029 nwrites
= hw
->bufinfo
.len
/ HFA384x_USB_RWMEM_MAXLEN
;
2030 nwrites
+= (hw
->bufinfo
.len
% HFA384x_USB_RWMEM_MAXLEN
) ? 1 : 0;
2033 for (i
= 0; i
< nburns
; i
++) {
2034 /* Get the dest address and len */
2035 burnlen
= (len
- (hw
->bufinfo
.len
* i
)) > hw
->bufinfo
.len
?
2036 hw
->bufinfo
.len
: (len
- (hw
->bufinfo
.len
* i
));
2037 burndaddr
= daddr
+ (hw
->bufinfo
.len
* i
);
2038 burnlo
= HFA384x_ADDR_CMD_MKOFF(burndaddr
);
2039 burnhi
= HFA384x_ADDR_CMD_MKPAGE(burndaddr
);
2041 netdev_info(hw
->wlandev
->netdev
, "Writing %d bytes to flash @0x%06x\n",
2042 burnlen
, burndaddr
);
2044 /* Set the download mode */
2045 result
= hfa384x_cmd_download(hw
, HFA384x_PROGMODE_NV
,
2046 burnlo
, burnhi
, burnlen
);
2048 netdev_err(hw
->wlandev
->netdev
,
2049 "download(NV,lo=%x,hi=%x,len=%x) cmd failed, result=%d. Aborting d/l\n",
2050 burnlo
, burnhi
, burnlen
, result
);
2054 /* copy the data to the flash download buffer */
2055 for (j
= 0; j
< nwrites
; j
++) {
2057 (i
* hw
->bufinfo
.len
) +
2058 (j
* HFA384x_USB_RWMEM_MAXLEN
);
2060 writepage
= HFA384x_ADDR_CMD_MKPAGE(dlbufaddr
+
2061 (j
* HFA384x_USB_RWMEM_MAXLEN
));
2062 writeoffset
= HFA384x_ADDR_CMD_MKOFF(dlbufaddr
+
2063 (j
* HFA384x_USB_RWMEM_MAXLEN
));
2065 writelen
= burnlen
- (j
* HFA384x_USB_RWMEM_MAXLEN
);
2066 writelen
= writelen
> HFA384x_USB_RWMEM_MAXLEN
?
2067 HFA384x_USB_RWMEM_MAXLEN
: writelen
;
2069 result
= hfa384x_dowmem_wait(hw
,
2072 writebuf
, writelen
);
2075 /* set the download 'write flash' mode */
2076 result
= hfa384x_cmd_download(hw
,
2077 HFA384x_PROGMODE_NVWRITE
,
2080 netdev_err(hw
->wlandev
->netdev
,
2081 "download(NVWRITE,lo=%x,hi=%x,len=%x) cmd failed, result=%d. Aborting d/l\n",
2082 burnlo
, burnhi
, burnlen
, result
);
2086 /* TODO: We really should do a readback and compare. */
2091 /* Leave the firmware in the 'post-prog' mode. flashdl_disable will */
2092 /* actually disable programming mode. Remember, that will cause the */
2093 /* the firmware to effectively reset itself. */
2098 /*----------------------------------------------------------------
2099 * hfa384x_drvr_getconfig
2101 * Performs the sequence necessary to read a config/info item.
2104 * hw device structure
2105 * rid config/info record id (host order)
2106 * buf host side record buffer. Upon return it will
2107 * contain the body portion of the record (minus the
2109 * len buffer length (in bytes, should match record length)
2113 * >0 f/w reported error - f/w status code
2114 * <0 driver reported error
2115 * -ENODATA length mismatch between argument and retrieved
2122 ----------------------------------------------------------------*/
2123 int hfa384x_drvr_getconfig(hfa384x_t
*hw
, u16 rid
, void *buf
, u16 len
)
2125 return hfa384x_dorrid_wait(hw
, rid
, buf
, len
);
2128 /*----------------------------------------------------------------
2129 * hfa384x_drvr_getconfig_async
2131 * Performs the sequence necessary to perform an async read of
2132 * of a config/info item.
2135 * hw device structure
2136 * rid config/info record id (host order)
2137 * buf host side record buffer. Upon return it will
2138 * contain the body portion of the record (minus the
2140 * len buffer length (in bytes, should match record length)
2141 * cbfn caller supplied callback, called when the command
2142 * is done (successful or not).
2143 * cbfndata pointer to some caller supplied data that will be
2144 * passed in as an argument to the cbfn.
2147 * nothing the cbfn gets a status argument identifying if
2150 * Queues an hfa384x_usbcmd_t for subsequent execution.
2154 ----------------------------------------------------------------*/
2156 hfa384x_drvr_getconfig_async(hfa384x_t
*hw
,
2157 u16 rid
, ctlx_usercb_t usercb
, void *usercb_data
)
2159 return hfa384x_dorrid_async(hw
, rid
, NULL
, 0,
2160 hfa384x_cb_rrid
, usercb
, usercb_data
);
2163 /*----------------------------------------------------------------
2164 * hfa384x_drvr_setconfig_async
2166 * Performs the sequence necessary to write a config/info item.
2169 * hw device structure
2170 * rid config/info record id (in host order)
2171 * buf host side record buffer
2172 * len buffer length (in bytes)
2173 * usercb completion callback
2174 * usercb_data completion callback argument
2178 * >0 f/w reported error - f/w status code
2179 * <0 driver reported error
2185 ----------------------------------------------------------------*/
2187 hfa384x_drvr_setconfig_async(hfa384x_t
*hw
,
2190 u16 len
, ctlx_usercb_t usercb
, void *usercb_data
)
2192 return hfa384x_dowrid_async(hw
, rid
, buf
, len
,
2193 hfa384x_cb_status
, usercb
, usercb_data
);
2196 /*----------------------------------------------------------------
2197 * hfa384x_drvr_ramdl_disable
2199 * Ends the ram download state.
2202 * hw device structure
2206 * >0 f/w reported error - f/w status code
2207 * <0 driver reported error
2213 ----------------------------------------------------------------*/
2214 int hfa384x_drvr_ramdl_disable(hfa384x_t
*hw
)
2216 /* Check that we're already in the download state */
2217 if (hw
->dlstate
!= HFA384x_DLSTATE_RAMENABLED
)
2220 pr_debug("ramdl_disable()\n");
2222 /* There isn't much we can do at this point, so I don't */
2223 /* bother w/ the return value */
2224 hfa384x_cmd_download(hw
, HFA384x_PROGMODE_DISABLE
, 0, 0, 0);
2225 hw
->dlstate
= HFA384x_DLSTATE_DISABLED
;
2230 /*----------------------------------------------------------------
2231 * hfa384x_drvr_ramdl_enable
2233 * Begins the ram download state. Checks to see that we're not
2234 * already in a download state and that a port isn't enabled.
2235 * Sets the download state and calls cmd_download with the
2236 * ENABLE_VOLATILE subcommand and the exeaddr argument.
2239 * hw device structure
2240 * exeaddr the card execution address that will be
2241 * jumped to when ramdl_disable() is called
2246 * >0 f/w reported error - f/w status code
2247 * <0 driver reported error
2253 ----------------------------------------------------------------*/
2254 int hfa384x_drvr_ramdl_enable(hfa384x_t
*hw
, u32 exeaddr
)
2261 /* Check that a port isn't active */
2262 for (i
= 0; i
< HFA384x_PORTID_MAX
; i
++) {
2263 if (hw
->port_enabled
[i
]) {
2264 netdev_err(hw
->wlandev
->netdev
,
2265 "Can't download with a macport enabled.\n");
2270 /* Check that we're not already in a download state */
2271 if (hw
->dlstate
!= HFA384x_DLSTATE_DISABLED
) {
2272 netdev_err(hw
->wlandev
->netdev
, "Download state not disabled.\n");
2276 pr_debug("ramdl_enable, exeaddr=0x%08x\n", exeaddr
);
2278 /* Call the download(1,addr) function */
2279 lowaddr
= HFA384x_ADDR_CMD_MKOFF(exeaddr
);
2280 hiaddr
= HFA384x_ADDR_CMD_MKPAGE(exeaddr
);
2282 result
= hfa384x_cmd_download(hw
, HFA384x_PROGMODE_RAM
,
2283 lowaddr
, hiaddr
, 0);
2286 /* Set the download state */
2287 hw
->dlstate
= HFA384x_DLSTATE_RAMENABLED
;
2289 pr_debug("cmd_download(0x%04x, 0x%04x) failed, result=%d.\n",
2290 lowaddr
, hiaddr
, result
);
2296 /*----------------------------------------------------------------
2297 * hfa384x_drvr_ramdl_write
2299 * Performs a RAM download of a chunk of data. First checks to see
2300 * that we're in the RAM download state, then uses the [read|write]mem USB
2301 * commands to 1) copy the data, 2) readback and compare. The download
2302 * state is unaffected. When all data has been written using
2303 * this function, call drvr_ramdl_disable() to end the download state
2304 * and restart the MAC.
2307 * hw device structure
2308 * daddr Card address to write to. (host order)
2309 * buf Ptr to data to write.
2310 * len Length of data (host order).
2314 * >0 f/w reported error - f/w status code
2315 * <0 driver reported error
2321 ----------------------------------------------------------------*/
2322 int hfa384x_drvr_ramdl_write(hfa384x_t
*hw
, u32 daddr
, void *buf
, u32 len
)
2333 /* Check that we're in the ram download state */
2334 if (hw
->dlstate
!= HFA384x_DLSTATE_RAMENABLED
)
2337 netdev_info(hw
->wlandev
->netdev
, "Writing %d bytes to ram @0x%06x\n",
2340 /* How many dowmem calls? */
2341 nwrites
= len
/ HFA384x_USB_RWMEM_MAXLEN
;
2342 nwrites
+= len
% HFA384x_USB_RWMEM_MAXLEN
? 1 : 0;
2344 /* Do blocking wmem's */
2345 for (i
= 0; i
< nwrites
; i
++) {
2346 /* make address args */
2347 curraddr
= daddr
+ (i
* HFA384x_USB_RWMEM_MAXLEN
);
2348 currpage
= HFA384x_ADDR_CMD_MKPAGE(curraddr
);
2349 curroffset
= HFA384x_ADDR_CMD_MKOFF(curraddr
);
2350 currlen
= len
- (i
* HFA384x_USB_RWMEM_MAXLEN
);
2351 if (currlen
> HFA384x_USB_RWMEM_MAXLEN
)
2352 currlen
= HFA384x_USB_RWMEM_MAXLEN
;
2354 /* Do blocking ctlx */
2355 result
= hfa384x_dowmem_wait(hw
,
2359 (i
* HFA384x_USB_RWMEM_MAXLEN
),
2365 /* TODO: We really should have a readback. */
2371 /*----------------------------------------------------------------
2372 * hfa384x_drvr_readpda
2374 * Performs the sequence to read the PDA space. Note there is no
2375 * drvr_writepda() function. Writing a PDA is
2376 * generally implemented by a calling component via calls to
2377 * cmd_download and writing to the flash download buffer via the
2381 * hw device structure
2382 * buf buffer to store PDA in
2387 * >0 f/w reported error - f/w status code
2388 * <0 driver reported error
2389 * -ETIMEDOUT timeout waiting for the cmd regs to become
2390 * available, or waiting for the control reg
2391 * to indicate the Aux port is enabled.
2392 * -ENODATA the buffer does NOT contain a valid PDA.
2393 * Either the card PDA is bad, or the auxdata
2394 * reads are giving us garbage.
2400 * process or non-card interrupt.
2401 ----------------------------------------------------------------*/
2402 int hfa384x_drvr_readpda(hfa384x_t
*hw
, void *buf
, unsigned int len
)
2408 int currpdr
= 0; /* word offset of the current pdr */
2410 u16 pdrlen
; /* pdr length in bytes, host order */
2411 u16 pdrcode
; /* pdr code, host order */
2419 HFA3842_PDA_BASE
, 0}, {
2420 HFA3841_PDA_BASE
, 0}, {
2421 HFA3841_PDA_BOGUS_BASE
, 0}
2424 /* Read the pda from each known address. */
2425 for (i
= 0; i
< ARRAY_SIZE(pdaloc
); i
++) {
2427 currpage
= HFA384x_ADDR_CMD_MKPAGE(pdaloc
[i
].cardaddr
);
2428 curroffset
= HFA384x_ADDR_CMD_MKOFF(pdaloc
[i
].cardaddr
);
2430 /* units of bytes */
2431 result
= hfa384x_dormem_wait(hw
, currpage
, curroffset
, buf
,
2435 netdev_warn(hw
->wlandev
->netdev
,
2436 "Read from index %zd failed, continuing\n",
2441 /* Test for garbage */
2442 pdaok
= 1; /* initially assume good */
2444 while (pdaok
&& morepdrs
) {
2445 pdrlen
= le16_to_cpu(pda
[currpdr
]) * 2;
2446 pdrcode
= le16_to_cpu(pda
[currpdr
+ 1]);
2447 /* Test the record length */
2448 if (pdrlen
> HFA384x_PDR_LEN_MAX
|| pdrlen
== 0) {
2449 netdev_err(hw
->wlandev
->netdev
,
2450 "pdrlen invalid=%d\n", pdrlen
);
2455 if (!hfa384x_isgood_pdrcode(pdrcode
)) {
2456 netdev_err(hw
->wlandev
->netdev
, "pdrcode invalid=%d\n",
2461 /* Test for completion */
2462 if (pdrcode
== HFA384x_PDR_END_OF_PDA
)
2465 /* Move to the next pdr (if necessary) */
2467 /* note the access to pda[], need words here */
2468 currpdr
+= le16_to_cpu(pda
[currpdr
]) + 1;
2472 netdev_info(hw
->wlandev
->netdev
,
2473 "PDA Read from 0x%08x in %s space.\n",
2475 pdaloc
[i
].auxctl
== 0 ? "EXTDS" :
2476 pdaloc
[i
].auxctl
== 1 ? "NV" :
2477 pdaloc
[i
].auxctl
== 2 ? "PHY" :
2478 pdaloc
[i
].auxctl
== 3 ? "ICSRAM" :
2483 result
= pdaok
? 0 : -ENODATA
;
2486 pr_debug("Failure: pda is not okay\n");
2491 /*----------------------------------------------------------------
2492 * hfa384x_drvr_setconfig
2494 * Performs the sequence necessary to write a config/info item.
2497 * hw device structure
2498 * rid config/info record id (in host order)
2499 * buf host side record buffer
2500 * len buffer length (in bytes)
2504 * >0 f/w reported error - f/w status code
2505 * <0 driver reported error
2511 ----------------------------------------------------------------*/
2512 int hfa384x_drvr_setconfig(hfa384x_t
*hw
, u16 rid
, void *buf
, u16 len
)
2514 return hfa384x_dowrid_wait(hw
, rid
, buf
, len
);
2517 /*----------------------------------------------------------------
2518 * hfa384x_drvr_start
2520 * Issues the MAC initialize command, sets up some data structures,
2521 * and enables the interrupts. After this function completes, the
2522 * low-level stuff should be ready for any/all commands.
2525 * hw device structure
2528 * >0 f/w reported error - f/w status code
2529 * <0 driver reported error
2535 ----------------------------------------------------------------*/
2537 int hfa384x_drvr_start(hfa384x_t
*hw
)
2539 int result
, result1
, result2
;
2544 /* Clear endpoint stalls - but only do this if the endpoint
2545 * is showing a stall status. Some prism2 cards seem to behave
2546 * badly if a clear_halt is called when the endpoint is already
2550 usb_get_status(hw
->usb
, USB_RECIP_ENDPOINT
, hw
->endp_in
, &status
);
2552 netdev_err(hw
->wlandev
->netdev
, "Cannot get bulk in endpoint status.\n");
2555 if ((status
== 1) && usb_clear_halt(hw
->usb
, hw
->endp_in
))
2556 netdev_err(hw
->wlandev
->netdev
, "Failed to reset bulk in endpoint.\n");
2559 usb_get_status(hw
->usb
, USB_RECIP_ENDPOINT
, hw
->endp_out
, &status
);
2561 netdev_err(hw
->wlandev
->netdev
, "Cannot get bulk out endpoint status.\n");
2564 if ((status
== 1) && usb_clear_halt(hw
->usb
, hw
->endp_out
))
2565 netdev_err(hw
->wlandev
->netdev
, "Failed to reset bulk out endpoint.\n");
2567 /* Synchronous unlink, in case we're trying to restart the driver */
2568 usb_kill_urb(&hw
->rx_urb
);
2570 /* Post the IN urb */
2571 result
= submit_rx_urb(hw
, GFP_KERNEL
);
2573 netdev_err(hw
->wlandev
->netdev
,
2574 "Fatal, failed to submit RX URB, result=%d\n",
2579 /* Call initialize twice, with a 1 second sleep in between.
2580 * This is a nasty work-around since many prism2 cards seem to
2581 * need time to settle after an init from cold. The second
2582 * call to initialize in theory is not necessary - but we call
2583 * it anyway as a double insurance policy:
2584 * 1) If the first init should fail, the second may well succeed
2585 * and the card can still be used
2586 * 2) It helps ensures all is well with the card after the first
2587 * init and settle time.
2589 result1
= hfa384x_cmd_initialize(hw
);
2591 result
= hfa384x_cmd_initialize(hw
);
2595 netdev_err(hw
->wlandev
->netdev
,
2596 "cmd_initialize() failed on two attempts, results %d and %d\n",
2598 usb_kill_urb(&hw
->rx_urb
);
2601 pr_debug("First cmd_initialize() failed (result %d),\n",
2603 pr_debug("but second attempt succeeded. All should be ok\n");
2605 } else if (result2
!= 0) {
2606 netdev_warn(hw
->wlandev
->netdev
, "First cmd_initialize() succeeded, but second attempt failed (result=%d)\n",
2608 netdev_warn(hw
->wlandev
->netdev
,
2609 "Most likely the card will be functional\n");
2613 hw
->state
= HFA384x_STATE_RUNNING
;
2619 /*----------------------------------------------------------------
2622 * Shuts down the MAC to the point where it is safe to unload the
2623 * driver. Any subsystem that may be holding a data or function
2624 * ptr into the driver must be cleared/deinitialized.
2627 * hw device structure
2630 * >0 f/w reported error - f/w status code
2631 * <0 driver reported error
2637 ----------------------------------------------------------------*/
2638 int hfa384x_drvr_stop(hfa384x_t
*hw
)
2644 /* There's no need for spinlocks here. The USB "disconnect"
2645 * function sets this "removed" flag and then calls us.
2647 if (!hw
->wlandev
->hwremoved
) {
2648 /* Call initialize to leave the MAC in its 'reset' state */
2649 hfa384x_cmd_initialize(hw
);
2651 /* Cancel the rxurb */
2652 usb_kill_urb(&hw
->rx_urb
);
2655 hw
->link_status
= HFA384x_LINK_NOTCONNECTED
;
2656 hw
->state
= HFA384x_STATE_INIT
;
2658 del_timer_sync(&hw
->commsqual_timer
);
2660 /* Clear all the port status */
2661 for (i
= 0; i
< HFA384x_NUMPORTS_MAX
; i
++)
2662 hw
->port_enabled
[i
] = 0;
2667 /*----------------------------------------------------------------
2668 * hfa384x_drvr_txframe
2670 * Takes a frame from prism2sta and queues it for transmission.
2673 * hw device structure
2674 * skb packet buffer struct. Contains an 802.11
2676 * p80211_hdr points to the 802.11 header for the packet.
2678 * 0 Success and more buffs available
2679 * 1 Success but no more buffs
2680 * 2 Allocation failure
2681 * 4 Buffer full or queue busy
2687 ----------------------------------------------------------------*/
2688 int hfa384x_drvr_txframe(hfa384x_t
*hw
, struct sk_buff
*skb
,
2689 union p80211_hdr
*p80211_hdr
,
2690 struct p80211_metawep
*p80211_wep
)
2692 int usbpktlen
= sizeof(hfa384x_tx_frame_t
);
2697 if (hw
->tx_urb
.status
== -EINPROGRESS
) {
2698 netdev_warn(hw
->wlandev
->netdev
, "TX URB already in use\n");
2703 /* Build Tx frame structure */
2704 /* Set up the control field */
2705 memset(&hw
->txbuff
.txfrm
.desc
, 0, sizeof(hw
->txbuff
.txfrm
.desc
));
2707 /* Setup the usb type field */
2708 hw
->txbuff
.type
= cpu_to_le16(HFA384x_USB_TXFRM
);
2710 /* Set up the sw_support field to identify this frame */
2711 hw
->txbuff
.txfrm
.desc
.sw_support
= 0x0123;
2713 /* Tx complete and Tx exception disable per dleach. Might be causing
2716 /* #define DOEXC SLP -- doboth breaks horribly under load, doexc less so. */
2718 hw
->txbuff
.txfrm
.desc
.tx_control
=
2719 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2720 HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(1);
2721 #elif defined(DOEXC)
2722 hw
->txbuff
.txfrm
.desc
.tx_control
=
2723 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2724 HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(0);
2726 hw
->txbuff
.txfrm
.desc
.tx_control
=
2727 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2728 HFA384x_TX_TXEX_SET(0) | HFA384x_TX_TXOK_SET(0);
2730 hw
->txbuff
.txfrm
.desc
.tx_control
=
2731 cpu_to_le16(hw
->txbuff
.txfrm
.desc
.tx_control
);
2733 /* copy the header over to the txdesc */
2734 memcpy(&(hw
->txbuff
.txfrm
.desc
.frame_control
), p80211_hdr
,
2735 sizeof(union p80211_hdr
));
2737 /* if we're using host WEP, increase size by IV+ICV */
2738 if (p80211_wep
->data
) {
2739 hw
->txbuff
.txfrm
.desc
.data_len
= cpu_to_le16(skb
->len
+ 8);
2742 hw
->txbuff
.txfrm
.desc
.data_len
= cpu_to_le16(skb
->len
);
2745 usbpktlen
+= skb
->len
;
2747 /* copy over the WEP IV if we are using host WEP */
2748 ptr
= hw
->txbuff
.txfrm
.data
;
2749 if (p80211_wep
->data
) {
2750 memcpy(ptr
, p80211_wep
->iv
, sizeof(p80211_wep
->iv
));
2751 ptr
+= sizeof(p80211_wep
->iv
);
2752 memcpy(ptr
, p80211_wep
->data
, skb
->len
);
2754 memcpy(ptr
, skb
->data
, skb
->len
);
2756 /* copy over the packet data */
2759 /* copy over the WEP ICV if we are using host WEP */
2760 if (p80211_wep
->data
)
2761 memcpy(ptr
, p80211_wep
->icv
, sizeof(p80211_wep
->icv
));
2763 /* Send the USB packet */
2764 usb_fill_bulk_urb(&(hw
->tx_urb
), hw
->usb
,
2766 &(hw
->txbuff
), ROUNDUP64(usbpktlen
),
2767 hfa384x_usbout_callback
, hw
->wlandev
);
2768 hw
->tx_urb
.transfer_flags
|= USB_QUEUE_BULK
;
2771 ret
= submit_tx_urb(hw
, &hw
->tx_urb
, GFP_ATOMIC
);
2773 netdev_err(hw
->wlandev
->netdev
,
2774 "submit_tx_urb() failed, error=%d\n", ret
);
2782 void hfa384x_tx_timeout(wlandevice_t
*wlandev
)
2784 hfa384x_t
*hw
= wlandev
->priv
;
2785 unsigned long flags
;
2787 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2789 if (!hw
->wlandev
->hwremoved
) {
2792 sched
= !test_and_set_bit(WORK_TX_HALT
, &hw
->usb_flags
);
2793 sched
|= !test_and_set_bit(WORK_RX_HALT
, &hw
->usb_flags
);
2795 schedule_work(&hw
->usb_work
);
2798 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2801 /*----------------------------------------------------------------
2802 * hfa384x_usbctlx_reaper_task
2804 * Tasklet to delete dead CTLX objects
2807 * data ptr to a hfa384x_t
2813 ----------------------------------------------------------------*/
2814 static void hfa384x_usbctlx_reaper_task(unsigned long data
)
2816 hfa384x_t
*hw
= (hfa384x_t
*)data
;
2817 struct list_head
*entry
;
2818 struct list_head
*temp
;
2819 unsigned long flags
;
2821 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2823 /* This list is guaranteed to be empty if someone
2824 * has unplugged the adapter.
2826 list_for_each_safe(entry
, temp
, &hw
->ctlxq
.reapable
) {
2827 hfa384x_usbctlx_t
*ctlx
;
2829 ctlx
= list_entry(entry
, hfa384x_usbctlx_t
, list
);
2830 list_del(&ctlx
->list
);
2834 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2837 /*----------------------------------------------------------------
2838 * hfa384x_usbctlx_completion_task
2840 * Tasklet to call completion handlers for returned CTLXs
2843 * data ptr to hfa384x_t
2850 ----------------------------------------------------------------*/
2851 static void hfa384x_usbctlx_completion_task(unsigned long data
)
2853 hfa384x_t
*hw
= (hfa384x_t
*)data
;
2854 struct list_head
*entry
;
2855 struct list_head
*temp
;
2856 unsigned long flags
;
2860 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2862 /* This list is guaranteed to be empty if someone
2863 * has unplugged the adapter ...
2865 list_for_each_safe(entry
, temp
, &hw
->ctlxq
.completing
) {
2866 hfa384x_usbctlx_t
*ctlx
;
2868 ctlx
= list_entry(entry
, hfa384x_usbctlx_t
, list
);
2870 /* Call the completion function that this
2871 * command was assigned, assuming it has one.
2873 if (ctlx
->cmdcb
!= NULL
) {
2874 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2875 ctlx
->cmdcb(hw
, ctlx
);
2876 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
2878 /* Make sure we don't try and complete
2879 * this CTLX more than once!
2883 /* Did someone yank the adapter out
2884 * while our list was (briefly) unlocked?
2886 if (hw
->wlandev
->hwremoved
) {
2893 * "Reapable" CTLXs are ones which don't have any
2894 * threads waiting for them to die. Hence they must
2895 * be delivered to The Reaper!
2897 if (ctlx
->reapable
) {
2898 /* Move the CTLX off the "completing" list (hopefully)
2899 * on to the "reapable" list where the reaper task
2900 * can find it. And "reapable" means that this CTLX
2901 * isn't sitting on a wait-queue somewhere.
2903 list_move_tail(&ctlx
->list
, &hw
->ctlxq
.reapable
);
2907 complete(&ctlx
->done
);
2909 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
2912 tasklet_schedule(&hw
->reaper_bh
);
2915 /*----------------------------------------------------------------
2916 * unlocked_usbctlx_cancel_async
2918 * Mark the CTLX dead asynchronously, and ensure that the
2919 * next command on the queue is run afterwards.
2922 * hw ptr to the hfa384x_t structure
2923 * ctlx ptr to a CTLX structure
2926 * 0 the CTLX's URB is inactive
2927 * -EINPROGRESS the URB is currently being unlinked
2930 * Either process or interrupt, but presumably interrupt
2931 ----------------------------------------------------------------*/
2932 static int unlocked_usbctlx_cancel_async(hfa384x_t
*hw
,
2933 hfa384x_usbctlx_t
*ctlx
)
2938 * Try to delete the URB containing our request packet.
2939 * If we succeed, then its completion handler will be
2940 * called with a status of -ECONNRESET.
2942 hw
->ctlx_urb
.transfer_flags
|= URB_ASYNC_UNLINK
;
2943 ret
= usb_unlink_urb(&hw
->ctlx_urb
);
2945 if (ret
!= -EINPROGRESS
) {
2947 * The OUT URB had either already completed
2948 * or was still in the pending queue, so the
2949 * URB's completion function will not be called.
2950 * We will have to complete the CTLX ourselves.
2952 ctlx
->state
= CTLX_REQ_FAILED
;
2953 unlocked_usbctlx_complete(hw
, ctlx
);
2960 /*----------------------------------------------------------------
2961 * unlocked_usbctlx_complete
2963 * A CTLX has completed. It may have been successful, it may not
2964 * have been. At this point, the CTLX should be quiescent. The URBs
2965 * aren't active and the timers should have been stopped.
2967 * The CTLX is migrated to the "completing" queue, and the completing
2968 * tasklet is scheduled.
2971 * hw ptr to a hfa384x_t structure
2972 * ctlx ptr to a ctlx structure
2980 * Either, assume interrupt
2981 ----------------------------------------------------------------*/
2982 static void unlocked_usbctlx_complete(hfa384x_t
*hw
, hfa384x_usbctlx_t
*ctlx
)
2984 /* Timers have been stopped, and ctlx should be in
2985 * a terminal state. Retire it from the "active"
2988 list_move_tail(&ctlx
->list
, &hw
->ctlxq
.completing
);
2989 tasklet_schedule(&hw
->completion_bh
);
2991 switch (ctlx
->state
) {
2993 case CTLX_REQ_FAILED
:
2994 /* This are the correct terminating states. */
2998 netdev_err(hw
->wlandev
->netdev
, "CTLX[%d] not in a terminating state(%s)\n",
2999 le16_to_cpu(ctlx
->outbuf
.type
),
3000 ctlxstr(ctlx
->state
));
3005 /*----------------------------------------------------------------
3006 * hfa384x_usbctlxq_run
3008 * Checks to see if the head item is running. If not, starts it.
3011 * hw ptr to hfa384x_t
3020 ----------------------------------------------------------------*/
3021 static void hfa384x_usbctlxq_run(hfa384x_t
*hw
)
3023 unsigned long flags
;
3026 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3028 /* Only one active CTLX at any one time, because there's no
3029 * other (reliable) way to match the response URB to the
3032 * Don't touch any of these CTLXs if the hardware
3033 * has been removed or the USB subsystem is stalled.
3035 if (!list_empty(&hw
->ctlxq
.active
) ||
3036 test_bit(WORK_TX_HALT
, &hw
->usb_flags
) || hw
->wlandev
->hwremoved
)
3039 while (!list_empty(&hw
->ctlxq
.pending
)) {
3040 hfa384x_usbctlx_t
*head
;
3043 /* This is the first pending command */
3044 head
= list_entry(hw
->ctlxq
.pending
.next
,
3045 hfa384x_usbctlx_t
, list
);
3047 /* We need to split this off to avoid a race condition */
3048 list_move_tail(&head
->list
, &hw
->ctlxq
.active
);
3050 /* Fill the out packet */
3051 usb_fill_bulk_urb(&(hw
->ctlx_urb
), hw
->usb
,
3053 &(head
->outbuf
), ROUNDUP64(head
->outbufsize
),
3054 hfa384x_ctlxout_callback
, hw
);
3055 hw
->ctlx_urb
.transfer_flags
|= USB_QUEUE_BULK
;
3057 /* Now submit the URB and update the CTLX's state */
3058 result
= SUBMIT_URB(&hw
->ctlx_urb
, GFP_ATOMIC
);
3060 /* This CTLX is now running on the active queue */
3061 head
->state
= CTLX_REQ_SUBMITTED
;
3063 /* Start the OUT wait timer */
3064 hw
->req_timer_done
= 0;
3065 hw
->reqtimer
.expires
= jiffies
+ HZ
;
3066 add_timer(&hw
->reqtimer
);
3068 /* Start the IN wait timer */
3069 hw
->resp_timer_done
= 0;
3070 hw
->resptimer
.expires
= jiffies
+ 2 * HZ
;
3071 add_timer(&hw
->resptimer
);
3076 if (result
== -EPIPE
) {
3077 /* The OUT pipe needs resetting, so put
3078 * this CTLX back in the "pending" queue
3079 * and schedule a reset ...
3081 netdev_warn(hw
->wlandev
->netdev
,
3082 "%s tx pipe stalled: requesting reset\n",
3083 hw
->wlandev
->netdev
->name
);
3084 list_move(&head
->list
, &hw
->ctlxq
.pending
);
3085 set_bit(WORK_TX_HALT
, &hw
->usb_flags
);
3086 schedule_work(&hw
->usb_work
);
3090 if (result
== -ESHUTDOWN
) {
3091 netdev_warn(hw
->wlandev
->netdev
, "%s urb shutdown!\n",
3092 hw
->wlandev
->netdev
->name
);
3096 netdev_err(hw
->wlandev
->netdev
, "Failed to submit CTLX[%d]: error=%d\n",
3097 le16_to_cpu(head
->outbuf
.type
), result
);
3098 unlocked_usbctlx_complete(hw
, head
);
3102 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3105 /*----------------------------------------------------------------
3106 * hfa384x_usbin_callback
3108 * Callback for URBs on the BULKIN endpoint.
3111 * urb ptr to the completed urb
3120 ----------------------------------------------------------------*/
3121 static void hfa384x_usbin_callback(struct urb
*urb
)
3123 wlandevice_t
*wlandev
= urb
->context
;
3125 hfa384x_usbin_t
*usbin
= (hfa384x_usbin_t
*)urb
->transfer_buffer
;
3126 struct sk_buff
*skb
= NULL
;
3137 if (!wlandev
|| !wlandev
->netdev
|| wlandev
->hwremoved
)
3144 skb
= hw
->rx_urb_skb
;
3145 BUG_ON(!skb
|| (skb
->data
!= urb
->transfer_buffer
));
3147 hw
->rx_urb_skb
= NULL
;
3149 /* Check for error conditions within the URB */
3150 switch (urb
->status
) {
3154 /* Check for short packet */
3155 if (urb
->actual_length
== 0) {
3156 wlandev
->netdev
->stats
.rx_errors
++;
3157 wlandev
->netdev
->stats
.rx_length_errors
++;
3163 netdev_warn(hw
->wlandev
->netdev
, "%s rx pipe stalled: requesting reset\n",
3164 wlandev
->netdev
->name
);
3165 if (!test_and_set_bit(WORK_RX_HALT
, &hw
->usb_flags
))
3166 schedule_work(&hw
->usb_work
);
3167 wlandev
->netdev
->stats
.rx_errors
++;
3174 if (!test_and_set_bit(THROTTLE_RX
, &hw
->usb_flags
) &&
3175 !timer_pending(&hw
->throttle
)) {
3176 mod_timer(&hw
->throttle
, jiffies
+ THROTTLE_JIFFIES
);
3178 wlandev
->netdev
->stats
.rx_errors
++;
3183 wlandev
->netdev
->stats
.rx_over_errors
++;
3189 pr_debug("status=%d, device removed.\n", urb
->status
);
3195 pr_debug("status=%d, urb explicitly unlinked.\n", urb
->status
);
3200 pr_debug("urb status=%d, transfer flags=0x%x\n",
3201 urb
->status
, urb
->transfer_flags
);
3202 wlandev
->netdev
->stats
.rx_errors
++;
3207 urb_status
= urb
->status
;
3209 if (action
!= ABORT
) {
3210 /* Repost the RX URB */
3211 result
= submit_rx_urb(hw
, GFP_ATOMIC
);
3214 netdev_err(hw
->wlandev
->netdev
,
3215 "Fatal, failed to resubmit rx_urb. error=%d\n",
3220 /* Handle any USB-IN packet */
3221 /* Note: the check of the sw_support field, the type field doesn't
3222 * have bit 12 set like the docs suggest.
3224 type
= le16_to_cpu(usbin
->type
);
3225 if (HFA384x_USB_ISRXFRM(type
)) {
3226 if (action
== HANDLE
) {
3227 if (usbin
->txfrm
.desc
.sw_support
== 0x0123) {
3228 hfa384x_usbin_txcompl(wlandev
, usbin
);
3230 skb_put(skb
, sizeof(*usbin
));
3231 hfa384x_usbin_rx(wlandev
, skb
);
3237 if (HFA384x_USB_ISTXFRM(type
)) {
3238 if (action
== HANDLE
)
3239 hfa384x_usbin_txcompl(wlandev
, usbin
);
3243 case HFA384x_USB_INFOFRM
:
3244 if (action
== ABORT
)
3246 if (action
== HANDLE
)
3247 hfa384x_usbin_info(wlandev
, usbin
);
3250 case HFA384x_USB_CMDRESP
:
3251 case HFA384x_USB_WRIDRESP
:
3252 case HFA384x_USB_RRIDRESP
:
3253 case HFA384x_USB_WMEMRESP
:
3254 case HFA384x_USB_RMEMRESP
:
3255 /* ALWAYS, ALWAYS, ALWAYS handle this CTLX!!!! */
3256 hfa384x_usbin_ctlx(hw
, usbin
, urb_status
);
3259 case HFA384x_USB_BUFAVAIL
:
3260 pr_debug("Received BUFAVAIL packet, frmlen=%d\n",
3261 usbin
->bufavail
.frmlen
);
3264 case HFA384x_USB_ERROR
:
3265 pr_debug("Received USB_ERROR packet, errortype=%d\n",
3266 usbin
->usberror
.errortype
);
3270 pr_debug("Unrecognized USBIN packet, type=%x, status=%d\n",
3271 usbin
->type
, urb_status
);
3281 /*----------------------------------------------------------------
3282 * hfa384x_usbin_ctlx
3284 * We've received a URB containing a Prism2 "response" message.
3285 * This message needs to be matched up with a CTLX on the active
3286 * queue and our state updated accordingly.
3289 * hw ptr to hfa384x_t
3290 * usbin ptr to USB IN packet
3291 * urb_status status of this Bulk-In URB
3300 ----------------------------------------------------------------*/
3301 static void hfa384x_usbin_ctlx(hfa384x_t
*hw
, hfa384x_usbin_t
*usbin
,
3304 hfa384x_usbctlx_t
*ctlx
;
3306 unsigned long flags
;
3309 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3311 /* There can be only one CTLX on the active queue
3312 * at any one time, and this is the CTLX that the
3313 * timers are waiting for.
3315 if (list_empty(&hw
->ctlxq
.active
))
3318 /* Remove the "response timeout". It's possible that
3319 * we are already too late, and that the timeout is
3320 * already running. And that's just too bad for us,
3321 * because we could lose our CTLX from the active
3324 if (del_timer(&hw
->resptimer
) == 0) {
3325 if (hw
->resp_timer_done
== 0) {
3326 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3330 hw
->resp_timer_done
= 1;
3333 ctlx
= get_active_ctlx(hw
);
3335 if (urb_status
!= 0) {
3337 * Bad CTLX, so get rid of it. But we only
3338 * remove it from the active queue if we're no
3339 * longer expecting the OUT URB to complete.
3341 if (unlocked_usbctlx_cancel_async(hw
, ctlx
) == 0)
3344 const __le16 intype
= (usbin
->type
& ~cpu_to_le16(0x8000));
3347 * Check that our message is what we're expecting ...
3349 if (ctlx
->outbuf
.type
!= intype
) {
3350 netdev_warn(hw
->wlandev
->netdev
,
3351 "Expected IN[%d], received IN[%d] - ignored.\n",
3352 le16_to_cpu(ctlx
->outbuf
.type
),
3353 le16_to_cpu(intype
));
3357 /* This URB has succeeded, so grab the data ... */
3358 memcpy(&ctlx
->inbuf
, usbin
, sizeof(ctlx
->inbuf
));
3360 switch (ctlx
->state
) {
3361 case CTLX_REQ_SUBMITTED
:
3363 * We have received our response URB before
3364 * our request has been acknowledged. Odd,
3365 * but our OUT URB is still alive...
3367 pr_debug("Causality violation: please reboot Universe\n");
3368 ctlx
->state
= CTLX_RESP_COMPLETE
;
3371 case CTLX_REQ_COMPLETE
:
3373 * This is the usual path: our request
3374 * has already been acknowledged, and
3375 * now we have received the reply too.
3377 ctlx
->state
= CTLX_COMPLETE
;
3378 unlocked_usbctlx_complete(hw
, ctlx
);
3384 * Throw this CTLX away ...
3386 netdev_err(hw
->wlandev
->netdev
,
3387 "Matched IN URB, CTLX[%d] in invalid state(%s). Discarded.\n",
3388 le16_to_cpu(ctlx
->outbuf
.type
),
3389 ctlxstr(ctlx
->state
));
3390 if (unlocked_usbctlx_cancel_async(hw
, ctlx
) == 0)
3397 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3400 hfa384x_usbctlxq_run(hw
);
3403 /*----------------------------------------------------------------
3404 * hfa384x_usbin_txcompl
3406 * At this point we have the results of a previous transmit.
3409 * wlandev wlan device
3410 * usbin ptr to the usb transfer buffer
3419 ----------------------------------------------------------------*/
3420 static void hfa384x_usbin_txcompl(wlandevice_t
*wlandev
,
3421 hfa384x_usbin_t
*usbin
)
3425 status
= le16_to_cpu(usbin
->type
); /* yeah I know it says type... */
3427 /* Was there an error? */
3428 if (HFA384x_TXSTATUS_ISERROR(status
))
3429 prism2sta_ev_txexc(wlandev
, status
);
3431 prism2sta_ev_tx(wlandev
, status
);
3434 /*----------------------------------------------------------------
3437 * At this point we have a successful received a rx frame packet.
3440 * wlandev wlan device
3441 * usbin ptr to the usb transfer buffer
3450 ----------------------------------------------------------------*/
3451 static void hfa384x_usbin_rx(wlandevice_t
*wlandev
, struct sk_buff
*skb
)
3453 hfa384x_usbin_t
*usbin
= (hfa384x_usbin_t
*)skb
->data
;
3454 hfa384x_t
*hw
= wlandev
->priv
;
3456 struct p80211_rxmeta
*rxmeta
;
3460 /* Byte order convert once up front. */
3461 usbin
->rxfrm
.desc
.status
= le16_to_cpu(usbin
->rxfrm
.desc
.status
);
3462 usbin
->rxfrm
.desc
.time
= le32_to_cpu(usbin
->rxfrm
.desc
.time
);
3464 /* Now handle frame based on port# */
3465 switch (HFA384x_RXSTATUS_MACPORT_GET(usbin
->rxfrm
.desc
.status
)) {
3467 fc
= le16_to_cpu(usbin
->rxfrm
.desc
.frame_control
);
3469 /* If exclude and we receive an unencrypted, drop it */
3470 if ((wlandev
->hostwep
& HOSTWEP_EXCLUDEUNENCRYPTED
) &&
3471 !WLAN_GET_FC_ISWEP(fc
)) {
3475 data_len
= le16_to_cpu(usbin
->rxfrm
.desc
.data_len
);
3477 /* How much header data do we have? */
3478 hdrlen
= p80211_headerlen(fc
);
3480 /* Pull off the descriptor */
3481 skb_pull(skb
, sizeof(hfa384x_rx_frame_t
));
3483 /* Now shunt the header block up against the data block
3484 * with an "overlapping" copy
3486 memmove(skb_push(skb
, hdrlen
),
3487 &usbin
->rxfrm
.desc
.frame_control
, hdrlen
);
3489 skb
->dev
= wlandev
->netdev
;
3490 skb
->dev
->last_rx
= jiffies
;
3492 /* And set the frame length properly */
3493 skb_trim(skb
, data_len
+ hdrlen
);
3495 /* The prism2 series does not return the CRC */
3496 memset(skb_put(skb
, WLAN_CRC_LEN
), 0xff, WLAN_CRC_LEN
);
3498 skb_reset_mac_header(skb
);
3500 /* Attach the rxmeta, set some stuff */
3501 p80211skb_rxmeta_attach(wlandev
, skb
);
3502 rxmeta
= P80211SKB_RXMETA(skb
);
3503 rxmeta
->mactime
= usbin
->rxfrm
.desc
.time
;
3504 rxmeta
->rxrate
= usbin
->rxfrm
.desc
.rate
;
3505 rxmeta
->signal
= usbin
->rxfrm
.desc
.signal
- hw
->dbmadjust
;
3506 rxmeta
->noise
= usbin
->rxfrm
.desc
.silence
- hw
->dbmadjust
;
3508 prism2sta_ev_rx(wlandev
, skb
);
3513 if (!HFA384x_RXSTATUS_ISFCSERR(usbin
->rxfrm
.desc
.status
)) {
3514 /* Copy to wlansnif skb */
3515 hfa384x_int_rxmonitor(wlandev
, &usbin
->rxfrm
);
3518 pr_debug("Received monitor frame: FCSerr set\n");
3523 netdev_warn(hw
->wlandev
->netdev
, "Received frame on unsupported port=%d\n",
3524 HFA384x_RXSTATUS_MACPORT_GET(
3525 usbin
->rxfrm
.desc
.status
));
3530 /*----------------------------------------------------------------
3531 * hfa384x_int_rxmonitor
3533 * Helper function for int_rx. Handles monitor frames.
3534 * Note that this function allocates space for the FCS and sets it
3535 * to 0xffffffff. The hfa384x doesn't give us the FCS value but the
3536 * higher layers expect it. 0xffffffff is used as a flag to indicate
3540 * wlandev wlan device structure
3541 * rxfrm rx descriptor read from card in int_rx
3547 * Allocates an skb and passes it up via the PF_PACKET interface.
3550 ----------------------------------------------------------------*/
3551 static void hfa384x_int_rxmonitor(wlandevice_t
*wlandev
,
3552 hfa384x_usb_rxfrm_t
*rxfrm
)
3554 hfa384x_rx_frame_t
*rxdesc
= &(rxfrm
->desc
);
3555 unsigned int hdrlen
= 0;
3556 unsigned int datalen
= 0;
3557 unsigned int skblen
= 0;
3560 struct sk_buff
*skb
;
3561 hfa384x_t
*hw
= wlandev
->priv
;
3563 /* Remember the status, time, and data_len fields are in host order */
3564 /* Figure out how big the frame is */
3565 fc
= le16_to_cpu(rxdesc
->frame_control
);
3566 hdrlen
= p80211_headerlen(fc
);
3567 datalen
= le16_to_cpu(rxdesc
->data_len
);
3569 /* Allocate an ind message+framesize skb */
3570 skblen
= sizeof(struct p80211_caphdr
) + hdrlen
+ datalen
+ WLAN_CRC_LEN
;
3572 /* sanity check the length */
3574 (sizeof(struct p80211_caphdr
) +
3575 WLAN_HDR_A4_LEN
+ WLAN_DATA_MAXLEN
+ WLAN_CRC_LEN
)) {
3576 pr_debug("overlen frm: len=%zd\n",
3577 skblen
- sizeof(struct p80211_caphdr
));
3580 skb
= dev_alloc_skb(skblen
);
3584 /* only prepend the prism header if in the right mode */
3585 if ((wlandev
->netdev
->type
== ARPHRD_IEEE80211_PRISM
) &&
3586 (hw
->sniffhdr
!= 0)) {
3587 struct p80211_caphdr
*caphdr
;
3588 /* The NEW header format! */
3589 datap
= skb_put(skb
, sizeof(struct p80211_caphdr
));
3590 caphdr
= (struct p80211_caphdr
*)datap
;
3592 caphdr
->version
= htonl(P80211CAPTURE_VERSION
);
3593 caphdr
->length
= htonl(sizeof(struct p80211_caphdr
));
3594 caphdr
->mactime
= __cpu_to_be64(rxdesc
->time
) * 1000;
3595 caphdr
->hosttime
= __cpu_to_be64(jiffies
);
3596 caphdr
->phytype
= htonl(4); /* dss_dot11_b */
3597 caphdr
->channel
= htonl(hw
->sniff_channel
);
3598 caphdr
->datarate
= htonl(rxdesc
->rate
);
3599 caphdr
->antenna
= htonl(0); /* unknown */
3600 caphdr
->priority
= htonl(0); /* unknown */
3601 caphdr
->ssi_type
= htonl(3); /* rssi_raw */
3602 caphdr
->ssi_signal
= htonl(rxdesc
->signal
);
3603 caphdr
->ssi_noise
= htonl(rxdesc
->silence
);
3604 caphdr
->preamble
= htonl(0); /* unknown */
3605 caphdr
->encoding
= htonl(1); /* cck */
3608 /* Copy the 802.11 header to the skb
3609 (ctl frames may be less than a full header) */
3610 datap
= skb_put(skb
, hdrlen
);
3611 memcpy(datap
, &(rxdesc
->frame_control
), hdrlen
);
3613 /* If any, copy the data from the card to the skb */
3615 datap
= skb_put(skb
, datalen
);
3616 memcpy(datap
, rxfrm
->data
, datalen
);
3618 /* check for unencrypted stuff if WEP bit set. */
3619 if (*(datap
- hdrlen
+ 1) & 0x40) /* wep set */
3620 if ((*(datap
) == 0xaa) && (*(datap
+ 1) == 0xaa))
3621 /* clear wep; it's the 802.2 header! */
3622 *(datap
- hdrlen
+ 1) &= 0xbf;
3625 if (hw
->sniff_fcs
) {
3627 datap
= skb_put(skb
, WLAN_CRC_LEN
);
3628 memset(datap
, 0xff, WLAN_CRC_LEN
);
3631 /* pass it back up */
3632 prism2sta_ev_rx(wlandev
, skb
);
3635 /*----------------------------------------------------------------
3636 * hfa384x_usbin_info
3638 * At this point we have a successful received a Prism2 info frame.
3641 * wlandev wlan device
3642 * usbin ptr to the usb transfer buffer
3651 ----------------------------------------------------------------*/
3652 static void hfa384x_usbin_info(wlandevice_t
*wlandev
, hfa384x_usbin_t
*usbin
)
3654 usbin
->infofrm
.info
.framelen
=
3655 le16_to_cpu(usbin
->infofrm
.info
.framelen
);
3656 prism2sta_ev_info(wlandev
, &usbin
->infofrm
.info
);
3659 /*----------------------------------------------------------------
3660 * hfa384x_usbout_callback
3662 * Callback for URBs on the BULKOUT endpoint.
3665 * urb ptr to the completed urb
3674 ----------------------------------------------------------------*/
3675 static void hfa384x_usbout_callback(struct urb
*urb
)
3677 wlandevice_t
*wlandev
= urb
->context
;
3678 hfa384x_usbout_t
*usbout
= urb
->transfer_buffer
;
3684 if (wlandev
&& wlandev
->netdev
) {
3685 switch (urb
->status
) {
3687 hfa384x_usbout_tx(wlandev
, usbout
);
3692 hfa384x_t
*hw
= wlandev
->priv
;
3694 netdev_warn(hw
->wlandev
->netdev
,
3695 "%s tx pipe stalled: requesting reset\n",
3696 wlandev
->netdev
->name
);
3697 if (!test_and_set_bit
3698 (WORK_TX_HALT
, &hw
->usb_flags
))
3699 schedule_work(&hw
->usb_work
);
3700 wlandev
->netdev
->stats
.tx_errors
++;
3708 hfa384x_t
*hw
= wlandev
->priv
;
3710 if (!test_and_set_bit
3711 (THROTTLE_TX
, &hw
->usb_flags
) &&
3712 !timer_pending(&hw
->throttle
)) {
3713 mod_timer(&hw
->throttle
,
3714 jiffies
+ THROTTLE_JIFFIES
);
3716 wlandev
->netdev
->stats
.tx_errors
++;
3717 netif_stop_queue(wlandev
->netdev
);
3723 /* Ignorable errors */
3727 netdev_info(wlandev
->netdev
, "unknown urb->status=%d\n",
3729 wlandev
->netdev
->stats
.tx_errors
++;
3735 /*----------------------------------------------------------------
3736 * hfa384x_ctlxout_callback
3738 * Callback for control data on the BULKOUT endpoint.
3741 * urb ptr to the completed urb
3750 ----------------------------------------------------------------*/
3751 static void hfa384x_ctlxout_callback(struct urb
*urb
)
3753 hfa384x_t
*hw
= urb
->context
;
3754 int delete_resptimer
= 0;
3757 hfa384x_usbctlx_t
*ctlx
;
3758 unsigned long flags
;
3760 pr_debug("urb->status=%d\n", urb
->status
);
3764 if ((urb
->status
== -ESHUTDOWN
) ||
3765 (urb
->status
== -ENODEV
) || (hw
== NULL
))
3769 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3772 * Only one CTLX at a time on the "active" list, and
3773 * none at all if we are unplugged. However, we can
3774 * rely on the disconnect function to clean everything
3775 * up if someone unplugged the adapter.
3777 if (list_empty(&hw
->ctlxq
.active
)) {
3778 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3783 * Having something on the "active" queue means
3784 * that we have timers to worry about ...
3786 if (del_timer(&hw
->reqtimer
) == 0) {
3787 if (hw
->req_timer_done
== 0) {
3789 * This timer was actually running while we
3790 * were trying to delete it. Let it terminate
3791 * gracefully instead.
3793 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3797 hw
->req_timer_done
= 1;
3800 ctlx
= get_active_ctlx(hw
);
3802 if (urb
->status
== 0) {
3803 /* Request portion of a CTLX is successful */
3804 switch (ctlx
->state
) {
3805 case CTLX_REQ_SUBMITTED
:
3806 /* This OUT-ACK received before IN */
3807 ctlx
->state
= CTLX_REQ_COMPLETE
;
3810 case CTLX_RESP_COMPLETE
:
3811 /* IN already received before this OUT-ACK,
3812 * so this command must now be complete.
3814 ctlx
->state
= CTLX_COMPLETE
;
3815 unlocked_usbctlx_complete(hw
, ctlx
);
3820 /* This is NOT a valid CTLX "success" state! */
3821 netdev_err(hw
->wlandev
->netdev
,
3822 "Illegal CTLX[%d] success state(%s, %d) in OUT URB\n",
3823 le16_to_cpu(ctlx
->outbuf
.type
),
3824 ctlxstr(ctlx
->state
), urb
->status
);
3828 /* If the pipe has stalled then we need to reset it */
3829 if ((urb
->status
== -EPIPE
) &&
3830 !test_and_set_bit(WORK_TX_HALT
, &hw
->usb_flags
)) {
3831 netdev_warn(hw
->wlandev
->netdev
,
3832 "%s tx pipe stalled: requesting reset\n",
3833 hw
->wlandev
->netdev
->name
);
3834 schedule_work(&hw
->usb_work
);
3837 /* If someone cancels the OUT URB then its status
3838 * should be either -ECONNRESET or -ENOENT.
3840 ctlx
->state
= CTLX_REQ_FAILED
;
3841 unlocked_usbctlx_complete(hw
, ctlx
);
3842 delete_resptimer
= 1;
3847 if (delete_resptimer
) {
3848 timer_ok
= del_timer(&hw
->resptimer
);
3850 hw
->resp_timer_done
= 1;
3853 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3855 if (!timer_ok
&& (hw
->resp_timer_done
== 0)) {
3856 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3861 hfa384x_usbctlxq_run(hw
);
3864 /*----------------------------------------------------------------
3865 * hfa384x_usbctlx_reqtimerfn
3867 * Timer response function for CTLX request timeouts. If this
3868 * function is called, it means that the callback for the OUT
3869 * URB containing a Prism2.x XXX_Request was never called.
3872 * data a ptr to the hfa384x_t
3881 ----------------------------------------------------------------*/
3882 static void hfa384x_usbctlx_reqtimerfn(unsigned long data
)
3884 hfa384x_t
*hw
= (hfa384x_t
*)data
;
3885 unsigned long flags
;
3887 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3889 hw
->req_timer_done
= 1;
3891 /* Removing the hardware automatically empties
3892 * the active list ...
3894 if (!list_empty(&hw
->ctlxq
.active
)) {
3896 * We must ensure that our URB is removed from
3897 * the system, if it hasn't already expired.
3899 hw
->ctlx_urb
.transfer_flags
|= URB_ASYNC_UNLINK
;
3900 if (usb_unlink_urb(&hw
->ctlx_urb
) == -EINPROGRESS
) {
3901 hfa384x_usbctlx_t
*ctlx
= get_active_ctlx(hw
);
3903 ctlx
->state
= CTLX_REQ_FAILED
;
3905 /* This URB was active, but has now been
3906 * cancelled. It will now have a status of
3907 * -ECONNRESET in the callback function.
3909 * We are cancelling this CTLX, so we're
3910 * not going to need to wait for a response.
3911 * The URB's callback function will check
3912 * that this timer is truly dead.
3914 if (del_timer(&hw
->resptimer
) != 0)
3915 hw
->resp_timer_done
= 1;
3919 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3922 /*----------------------------------------------------------------
3923 * hfa384x_usbctlx_resptimerfn
3925 * Timer response function for CTLX response timeouts. If this
3926 * function is called, it means that the callback for the IN
3927 * URB containing a Prism2.x XXX_Response was never called.
3930 * data a ptr to the hfa384x_t
3939 ----------------------------------------------------------------*/
3940 static void hfa384x_usbctlx_resptimerfn(unsigned long data
)
3942 hfa384x_t
*hw
= (hfa384x_t
*)data
;
3943 unsigned long flags
;
3945 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3947 hw
->resp_timer_done
= 1;
3949 /* The active list will be empty if the
3950 * adapter has been unplugged ...
3952 if (!list_empty(&hw
->ctlxq
.active
)) {
3953 hfa384x_usbctlx_t
*ctlx
= get_active_ctlx(hw
);
3955 if (unlocked_usbctlx_cancel_async(hw
, ctlx
) == 0) {
3956 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3957 hfa384x_usbctlxq_run(hw
);
3961 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
3964 /*----------------------------------------------------------------
3965 * hfa384x_usb_throttlefn
3978 ----------------------------------------------------------------*/
3979 static void hfa384x_usb_throttlefn(unsigned long data
)
3981 hfa384x_t
*hw
= (hfa384x_t
*)data
;
3982 unsigned long flags
;
3984 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
3987 * We need to check BOTH the RX and the TX throttle controls,
3988 * so we use the bitwise OR instead of the logical OR.
3990 pr_debug("flags=0x%lx\n", hw
->usb_flags
);
3991 if (!hw
->wlandev
->hwremoved
&&
3992 ((test_and_clear_bit(THROTTLE_RX
, &hw
->usb_flags
) &&
3993 !test_and_set_bit(WORK_RX_RESUME
, &hw
->usb_flags
))
3995 (test_and_clear_bit(THROTTLE_TX
, &hw
->usb_flags
) &&
3996 !test_and_set_bit(WORK_TX_RESUME
, &hw
->usb_flags
))
3998 schedule_work(&hw
->usb_work
);
4001 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
4004 /*----------------------------------------------------------------
4005 * hfa384x_usbctlx_submit
4007 * Called from the doxxx functions to submit a CTLX to the queue
4010 * hw ptr to the hw struct
4011 * ctlx ctlx structure to enqueue
4014 * -ENODEV if the adapter is unplugged
4020 * process or interrupt
4021 ----------------------------------------------------------------*/
4022 static int hfa384x_usbctlx_submit(hfa384x_t
*hw
, hfa384x_usbctlx_t
*ctlx
)
4024 unsigned long flags
;
4026 spin_lock_irqsave(&hw
->ctlxq
.lock
, flags
);
4028 if (hw
->wlandev
->hwremoved
) {
4029 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
4033 ctlx
->state
= CTLX_PENDING
;
4034 list_add_tail(&ctlx
->list
, &hw
->ctlxq
.pending
);
4035 spin_unlock_irqrestore(&hw
->ctlxq
.lock
, flags
);
4036 hfa384x_usbctlxq_run(hw
);
4041 /*----------------------------------------------------------------
4044 * At this point we have finished a send of a frame. Mark the URB
4045 * as available and call ev_alloc to notify higher layers we're
4049 * wlandev wlan device
4050 * usbout ptr to the usb transfer buffer
4059 ----------------------------------------------------------------*/
4060 static void hfa384x_usbout_tx(wlandevice_t
*wlandev
, hfa384x_usbout_t
*usbout
)
4062 prism2sta_ev_alloc(wlandev
);
4065 /*----------------------------------------------------------------
4066 * hfa384x_isgood_pdrcore
4068 * Quick check of PDR codes.
4071 * pdrcode PDR code number (host order)
4080 ----------------------------------------------------------------*/
4081 static int hfa384x_isgood_pdrcode(u16 pdrcode
)
4084 case HFA384x_PDR_END_OF_PDA
:
4085 case HFA384x_PDR_PCB_PARTNUM
:
4086 case HFA384x_PDR_PDAVER
:
4087 case HFA384x_PDR_NIC_SERIAL
:
4088 case HFA384x_PDR_MKK_MEASUREMENTS
:
4089 case HFA384x_PDR_NIC_RAMSIZE
:
4090 case HFA384x_PDR_MFISUPRANGE
:
4091 case HFA384x_PDR_CFISUPRANGE
:
4092 case HFA384x_PDR_NICID
:
4093 case HFA384x_PDR_MAC_ADDRESS
:
4094 case HFA384x_PDR_REGDOMAIN
:
4095 case HFA384x_PDR_ALLOWED_CHANNEL
:
4096 case HFA384x_PDR_DEFAULT_CHANNEL
:
4097 case HFA384x_PDR_TEMPTYPE
:
4098 case HFA384x_PDR_IFR_SETTING
:
4099 case HFA384x_PDR_RFR_SETTING
:
4100 case HFA384x_PDR_HFA3861_BASELINE
:
4101 case HFA384x_PDR_HFA3861_SHADOW
:
4102 case HFA384x_PDR_HFA3861_IFRF
:
4103 case HFA384x_PDR_HFA3861_CHCALSP
:
4104 case HFA384x_PDR_HFA3861_CHCALI
:
4105 case HFA384x_PDR_3842_NIC_CONFIG
:
4106 case HFA384x_PDR_USB_ID
:
4107 case HFA384x_PDR_PCI_ID
:
4108 case HFA384x_PDR_PCI_IFCONF
:
4109 case HFA384x_PDR_PCI_PMCONF
:
4110 case HFA384x_PDR_RFENRGY
:
4111 case HFA384x_PDR_HFA3861_MANF_TESTSP
:
4112 case HFA384x_PDR_HFA3861_MANF_TESTI
:
4116 if (pdrcode
< 0x1000) {
4117 /* code is OK, but we don't know exactly what it is */
4118 pr_debug("Encountered unknown PDR#=0x%04x, assuming it's ok.\n",
4125 pr_debug("Encountered unknown PDR#=0x%04x, (>=0x1000), assuming it's bad.\n",