1 /* src/prism2/driver/hfa384x_usb.c
3 * Functions that talk to the USB variantof the Intersil hfa384x MAC
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
6 * --------------------------------------------------------------------
10 * The contents of this file are subject to the Mozilla Public
11 * License Version 1.1 (the "License"); you may not use this file
12 * except in compliance with the License. You may obtain a copy of
13 * the License at http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS
16 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 * implied. See the License for the specific language governing
18 * rights and limitations under the License.
20 * Alternatively, the contents of this file may be used under the
21 * terms of the GNU Public License version 2 (the "GPL"), in which
22 * case the provisions of the GPL are applicable instead of the
23 * above. If you wish to allow the use of your version of this file
24 * only under the terms of the GPL and not to allow others to use
25 * your version of this file under the MPL, indicate your decision
26 * by deleting the provisions above and replace them with the notice
27 * and other provisions required by the GPL. If you do not delete
28 * the provisions above, a recipient may use your version of this
29 * file under either the MPL or the GPL.
31 * --------------------------------------------------------------------
33 * Inquiries regarding the linux-wlan Open Source project can be
36 * AbsoluteValue Systems Inc.
38 * http://www.linux-wlan.com
40 * --------------------------------------------------------------------
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
45 * --------------------------------------------------------------------
47 * This file implements functions that correspond to the prism2/hfa384x
48 * 802.11 MAC hardware and firmware host interface.
50 * The functions can be considered to represent several levels of
51 * abstraction. The lowest level functions are simply C-callable wrappers
52 * around the register accesses. The next higher level represents C-callable
53 * prism2 API functions that match the Intersil documentation as closely
54 * as is reasonable. The next higher layer implements common sequences
55 * of invokations of the API layer (e.g. write to bap, followed by cmd).
58 * hfa384x_drvr_xxx Highest level abstractions provided by the
59 * hfa384x code. They are driver defined wrappers
60 * for common sequences. These functions generally
61 * use the services of the lower levels.
63 * hfa384x_drvr_xxxconfig An example of the drvr level abstraction. These
64 * functions are wrappers for the RID get/set
65 * sequence. They call copy_[to|from]_bap() and
66 * cmd_access(). These functions operate on the
67 * RIDs and buffers without validation. The caller
68 * is responsible for that.
70 * API wrapper functions:
71 * hfa384x_cmd_xxx functions that provide access to the f/w commands.
72 * The function arguments correspond to each command
73 * argument, even command arguments that get packed
74 * into single registers. These functions _just_
75 * issue the command by setting the cmd/parm regs
76 * & reading the status/resp regs. Additional
77 * activities required to fully use a command
78 * (read/write from/to bap, get/set int status etc.)
79 * are implemented separately. Think of these as
80 * C-callable prism2 commands.
82 * Lowest Layer Functions:
83 * hfa384x_docmd_xxx These functions implement the sequence required
84 * to issue any prism2 command. Primarily used by the
85 * hfa384x_cmd_xxx functions.
87 * hfa384x_bap_xxx BAP read/write access functions.
88 * Note: we usually use BAP0 for non-interrupt context
89 * and BAP1 for interrupt context.
91 * hfa384x_dl_xxx download related functions.
93 * Driver State Issues:
94 * Note that there are two pairs of functions that manage the
95 * 'initialized' and 'running' states of the hw/MAC combo. The four
96 * functions are create(), destroy(), start(), and stop(). create()
97 * sets up the data structures required to support the hfa384x_*
98 * functions and destroy() cleans them up. The start() function gets
99 * the actual hardware running and enables the interrupts. The stop()
100 * function shuts the hardware down. The sequence should be:
104 * . Do interesting things w/ the hardware
109 * Note that destroy() can be called without calling stop() first.
110 * --------------------------------------------------------------------
113 /*================================================================*/
114 /* System Includes */
115 #define WLAN_DBVAR prism2_debug
117 #include <linux/version.h>
119 #include <linux/module.h>
120 #include <linux/kernel.h>
121 #include <linux/sched.h>
122 #include <linux/types.h>
123 #include <linux/slab.h>
124 #include <linux/wireless.h>
125 #include <linux/netdevice.h>
126 #include <linux/timer.h>
128 #include <linux/delay.h>
129 #include <asm/byteorder.h>
130 #include <asm/bitops.h>
131 #include <linux/list.h>
132 #include <linux/usb.h>
134 #include "wlan_compat.h"
136 #define SUBMIT_URB(u,f) usb_submit_urb(u,f)
138 /*================================================================*/
139 /* Project Includes */
141 #include "p80211types.h"
142 #include "p80211hdr.h"
143 #include "p80211mgmt.h"
144 #include "p80211conv.h"
145 #include "p80211msg.h"
146 #include "p80211netdev.h"
147 #include "p80211req.h"
148 #include "p80211metadef.h"
149 #include "p80211metastruct.h"
151 #include "prism2mgmt.h"
153 /*================================================================*/
154 /* Local Constants */
161 typedef enum cmd_mode CMD_MODE;
163 #define THROTTLE_JIFFIES (HZ/8)
165 /*================================================================*/
168 #define ROUNDUP64(a) (((a)+63)&~63)
170 /*================================================================*/
173 /*================================================================*/
174 /* Local Static Definitions */
175 extern int prism2_debug;
177 /*================================================================*/
178 /* Local Function Declarations */
182 dbprint_urb(struct urb* urb);
186 hfa384x_int_rxmonitor(
187 wlandevice_t *wlandev,
188 hfa384x_usb_rxfrm_t *rxfrm);
191 hfa384x_usb_defer(struct work_struct *data);
194 submit_rx_urb(hfa384x_t *hw, gfp_t flags);
197 submit_tx_urb(hfa384x_t *hw, struct urb *tx_urb, gfp_t flags);
199 /*---------------------------------------------------*/
202 hfa384x_usbout_callback(struct urb *urb);
204 hfa384x_ctlxout_callback(struct urb *urb);
206 hfa384x_usbin_callback(struct urb *urb);
209 hfa384x_usbin_txcompl(wlandevice_t *wlandev, hfa384x_usbin_t *usbin);
212 hfa384x_usbin_rx(wlandevice_t *wlandev, struct sk_buff *skb);
215 hfa384x_usbin_info(wlandevice_t *wlandev, hfa384x_usbin_t *usbin);
218 hfa384x_usbout_tx(wlandevice_t *wlandev, hfa384x_usbout_t *usbout);
220 static void hfa384x_usbin_ctlx(hfa384x_t *hw, hfa384x_usbin_t *usbin,
223 /*---------------------------------------------------*/
224 /* Functions to support the prism2 usb command queue */
227 hfa384x_usbctlxq_run(hfa384x_t *hw);
230 hfa384x_usbctlx_reqtimerfn(unsigned long data);
233 hfa384x_usbctlx_resptimerfn(unsigned long data);
236 hfa384x_usb_throttlefn(unsigned long data);
239 hfa384x_usbctlx_completion_task(unsigned long data);
242 hfa384x_usbctlx_reaper_task(unsigned long data);
245 hfa384x_usbctlx_submit(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx);
248 unlocked_usbctlx_complete(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx);
250 struct usbctlx_completor
252 int (*complete)(struct usbctlx_completor*);
254 typedef struct usbctlx_completor usbctlx_completor_t;
257 hfa384x_usbctlx_complete_sync(hfa384x_t *hw,
258 hfa384x_usbctlx_t *ctlx,
259 usbctlx_completor_t *completor);
262 unlocked_usbctlx_cancel_async(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx);
265 hfa384x_cb_status(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx);
268 hfa384x_cb_rrid(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx);
271 usbctlx_get_status(const hfa384x_usb_cmdresp_t *cmdresp,
272 hfa384x_cmdresult_t *result);
275 usbctlx_get_rridresult(const hfa384x_usb_rridresp_t *rridresp,
276 hfa384x_rridresult_t *result);
278 /*---------------------------------------------------*/
279 /* Low level req/resp CTLX formatters and submitters */
284 hfa384x_metacmd_t *cmd,
286 ctlx_usercb_t usercb,
295 unsigned int riddatalen,
297 ctlx_usercb_t usercb,
306 unsigned int riddatalen,
308 ctlx_usercb_t usercb,
320 ctlx_usercb_t usercb,
332 ctlx_usercb_t usercb,
336 hfa384x_isgood_pdrcode(u16 pdrcode);
338 /*================================================================*/
339 /* Function Definitions */
340 static inline const char* ctlxstr(CTLX_STATE s)
342 static const char* ctlx_str[] = {
347 "Request packet submitted",
348 "Request packet completed",
349 "Response packet completed"
356 static inline hfa384x_usbctlx_t*
357 get_active_ctlx(hfa384x_t *hw)
359 return list_entry(hw->ctlxq.active.next, hfa384x_usbctlx_t, list);
365 dbprint_urb(struct urb* urb)
367 WLAN_LOG_DEBUG(3,"urb->pipe=0x%08x\n", urb->pipe);
368 WLAN_LOG_DEBUG(3,"urb->status=0x%08x\n", urb->status);
369 WLAN_LOG_DEBUG(3,"urb->transfer_flags=0x%08x\n", urb->transfer_flags);
370 WLAN_LOG_DEBUG(3,"urb->transfer_buffer=0x%08x\n", (unsigned int)urb->transfer_buffer);
371 WLAN_LOG_DEBUG(3,"urb->transfer_buffer_length=0x%08x\n", urb->transfer_buffer_length);
372 WLAN_LOG_DEBUG(3,"urb->actual_length=0x%08x\n", urb->actual_length);
373 WLAN_LOG_DEBUG(3,"urb->bandwidth=0x%08x\n", urb->bandwidth);
374 WLAN_LOG_DEBUG(3,"urb->setup_packet(ctl)=0x%08x\n", (unsigned int)urb->setup_packet);
375 WLAN_LOG_DEBUG(3,"urb->start_frame(iso/irq)=0x%08x\n", urb->start_frame);
376 WLAN_LOG_DEBUG(3,"urb->interval(irq)=0x%08x\n", urb->interval);
377 WLAN_LOG_DEBUG(3,"urb->error_count(iso)=0x%08x\n", urb->error_count);
378 WLAN_LOG_DEBUG(3,"urb->timeout=0x%08x\n", urb->timeout);
379 WLAN_LOG_DEBUG(3,"urb->context=0x%08x\n", (unsigned int)urb->context);
380 WLAN_LOG_DEBUG(3,"urb->complete=0x%08x\n", (unsigned int)urb->complete);
385 /*----------------------------------------------------------------
388 * Listen for input data on the BULK-IN pipe. If the pipe has
389 * stalled then schedule it to be reset.
393 * memflags memory allocation flags
396 * error code from submission
400 ----------------------------------------------------------------*/
402 submit_rx_urb(hfa384x_t *hw, gfp_t memflags)
409 skb = dev_alloc_skb(sizeof(hfa384x_usbin_t));
415 /* Post the IN urb */
416 usb_fill_bulk_urb(&hw->rx_urb, hw->usb,
418 skb->data, sizeof(hfa384x_usbin_t),
419 hfa384x_usbin_callback, hw->wlandev);
421 hw->rx_urb_skb = skb;
424 if ( !hw->wlandev->hwremoved && !test_bit(WORK_RX_HALT, &hw->usb_flags)) {
425 result = SUBMIT_URB(&hw->rx_urb, memflags);
427 /* Check whether we need to reset the RX pipe */
428 if (result == -EPIPE) {
429 WLAN_LOG_WARNING("%s rx pipe stalled: requesting reset\n",
430 hw->wlandev->netdev->name);
431 if ( !test_and_set_bit(WORK_RX_HALT, &hw->usb_flags) )
432 schedule_work(&hw->usb_work);
436 /* Don't leak memory if anything should go wrong */
439 hw->rx_urb_skb = NULL;
448 /*----------------------------------------------------------------
451 * Prepares and submits the URB of transmitted data. If the
452 * submission fails then it will schedule the output pipe to
457 * tx_urb URB of data for tranmission
458 * memflags memory allocation flags
461 * error code from submission
465 ----------------------------------------------------------------*/
467 submit_tx_urb(hfa384x_t *hw, struct urb *tx_urb, gfp_t memflags)
469 struct net_device *netdev = hw->wlandev->netdev;
475 if ( netif_running(netdev) ) {
477 if ( !hw->wlandev->hwremoved && !test_bit(WORK_TX_HALT, &hw->usb_flags) ) {
478 result = SUBMIT_URB(tx_urb, memflags);
480 /* Test whether we need to reset the TX pipe */
481 if (result == -EPIPE) {
482 WLAN_LOG_WARNING("%s tx pipe stalled: requesting reset\n",
484 set_bit(WORK_TX_HALT, &hw->usb_flags);
485 schedule_work(&hw->usb_work);
486 } else if (result == 0) {
487 netif_stop_queue(netdev);
497 /*----------------------------------------------------------------
500 * There are some things that the USB stack cannot do while
501 * in interrupt context, so we arrange this function to run
502 * in process context.
505 * hw device structure
511 * process (by design)
512 ----------------------------------------------------------------*/
514 hfa384x_usb_defer(struct work_struct *data)
516 hfa384x_t *hw = container_of(data, struct hfa384x, usb_work);
517 struct net_device *netdev = hw->wlandev->netdev;
521 /* Don't bother trying to reset anything if the plug
522 * has been pulled ...
524 if ( hw->wlandev->hwremoved ) {
529 /* Reception has stopped: try to reset the input pipe */
530 if (test_bit(WORK_RX_HALT, &hw->usb_flags)) {
533 usb_kill_urb(&hw->rx_urb); /* Cannot be holding spinlock! */
535 ret = usb_clear_halt(hw->usb, hw->endp_in);
538 "Failed to clear rx pipe for %s: err=%d\n",
541 printk(KERN_INFO "%s rx pipe reset complete.\n",
543 clear_bit(WORK_RX_HALT, &hw->usb_flags);
544 set_bit(WORK_RX_RESUME, &hw->usb_flags);
548 /* Resume receiving data back from the device. */
549 if ( test_bit(WORK_RX_RESUME, &hw->usb_flags) ) {
552 ret = submit_rx_urb(hw, GFP_KERNEL);
555 "Failed to resume %s rx pipe.\n", netdev->name);
557 clear_bit(WORK_RX_RESUME, &hw->usb_flags);
561 /* Transmission has stopped: try to reset the output pipe */
562 if (test_bit(WORK_TX_HALT, &hw->usb_flags)) {
565 usb_kill_urb(&hw->tx_urb);
566 ret = usb_clear_halt(hw->usb, hw->endp_out);
569 "Failed to clear tx pipe for %s: err=%d\n",
572 printk(KERN_INFO "%s tx pipe reset complete.\n",
574 clear_bit(WORK_TX_HALT, &hw->usb_flags);
575 set_bit(WORK_TX_RESUME, &hw->usb_flags);
577 /* Stopping the BULK-OUT pipe also blocked
578 * us from sending any more CTLX URBs, so
579 * we need to re-run our queue ...
581 hfa384x_usbctlxq_run(hw);
585 /* Resume transmitting. */
586 if ( test_and_clear_bit(WORK_TX_RESUME, &hw->usb_flags) ) {
587 p80211netdev_wake_queue(hw->wlandev);
594 /*----------------------------------------------------------------
597 * Sets up the hfa384x_t data structure for use. Note this
598 * does _not_ intialize the actual hardware, just the data structures
599 * we use to keep track of its state.
602 * hw device structure
603 * irq device irq number
604 * iobase i/o base address for register access
605 * membase memory base address for register access
614 ----------------------------------------------------------------*/
616 hfa384x_create( hfa384x_t *hw, struct usb_device *usb)
620 memset(hw, 0, sizeof(hfa384x_t));
623 /* set up the endpoints */
624 hw->endp_in = usb_rcvbulkpipe(usb, 1);
625 hw->endp_out = usb_sndbulkpipe(usb, 2);
627 /* Set up the waitq */
628 init_waitqueue_head(&hw->cmdq);
630 /* Initialize the command queue */
631 spin_lock_init(&hw->ctlxq.lock);
632 INIT_LIST_HEAD(&hw->ctlxq.pending);
633 INIT_LIST_HEAD(&hw->ctlxq.active);
634 INIT_LIST_HEAD(&hw->ctlxq.completing);
635 INIT_LIST_HEAD(&hw->ctlxq.reapable);
637 /* Initialize the authentication queue */
638 skb_queue_head_init(&hw->authq);
640 tasklet_init(&hw->reaper_bh,
641 hfa384x_usbctlx_reaper_task,
643 tasklet_init(&hw->completion_bh,
644 hfa384x_usbctlx_completion_task,
646 INIT_WORK(&hw->link_bh, prism2sta_processing_defer);
647 INIT_WORK(&hw->usb_work, hfa384x_usb_defer);
649 init_timer(&hw->throttle);
650 hw->throttle.function = hfa384x_usb_throttlefn;
651 hw->throttle.data = (unsigned long)hw;
653 init_timer(&hw->resptimer);
654 hw->resptimer.function = hfa384x_usbctlx_resptimerfn;
655 hw->resptimer.data = (unsigned long)hw;
657 init_timer(&hw->reqtimer);
658 hw->reqtimer.function = hfa384x_usbctlx_reqtimerfn;
659 hw->reqtimer.data = (unsigned long)hw;
661 usb_init_urb(&hw->rx_urb);
662 usb_init_urb(&hw->tx_urb);
663 usb_init_urb(&hw->ctlx_urb);
665 hw->link_status = HFA384x_LINK_NOTCONNECTED;
666 hw->state = HFA384x_STATE_INIT;
668 INIT_WORK(&hw->commsqual_bh, prism2sta_commsqual_defer);
669 init_timer(&hw->commsqual_timer);
670 hw->commsqual_timer.data = (unsigned long) hw;
671 hw->commsqual_timer.function = prism2sta_commsqual_timer;
677 /*----------------------------------------------------------------
680 * Partner to hfa384x_create(). This function cleans up the hw
681 * structure so that it can be freed by the caller using a simple
682 * kfree. Currently, this function is just a placeholder. If, at some
683 * point in the future, an hw in the 'shutdown' state requires a 'deep'
684 * kfree, this is where it should be done. Note that if this function
685 * is called on a _running_ hw structure, the drvr_stop() function is
689 * hw device structure
692 * nothing, this function is not allowed to fail.
698 ----------------------------------------------------------------*/
700 hfa384x_destroy( hfa384x_t *hw)
706 if ( hw->state == HFA384x_STATE_RUNNING ) {
707 hfa384x_drvr_stop(hw);
709 hw->state = HFA384x_STATE_PREINIT;
711 if (hw->scanresults) {
712 kfree(hw->scanresults);
713 hw->scanresults = NULL;
716 /* Now to clean out the auth queue */
717 while ( (skb = skb_dequeue(&hw->authq)) ) {
725 /*----------------------------------------------------------------
727 static hfa384x_usbctlx_t* usbctlx_alloc(void)
729 hfa384x_usbctlx_t *ctlx;
731 ctlx = kmalloc(sizeof(*ctlx), in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
734 memset(ctlx, 0, sizeof(*ctlx));
735 init_completion(&ctlx->done);
742 /*----------------------------------------------------------------
744 ----------------------------------------------------------------*/
746 usbctlx_get_status(const hfa384x_usb_cmdresp_t *cmdresp,
747 hfa384x_cmdresult_t *result)
751 result->status = hfa384x2host_16(cmdresp->status);
752 result->resp0 = hfa384x2host_16(cmdresp->resp0);
753 result->resp1 = hfa384x2host_16(cmdresp->resp1);
754 result->resp2 = hfa384x2host_16(cmdresp->resp2);
756 WLAN_LOG_DEBUG(4, "cmdresult:status=0x%04x "
757 "resp0=0x%04x resp1=0x%04x resp2=0x%04x\n",
764 return (result->status & HFA384x_STATUS_RESULT);
768 usbctlx_get_rridresult(const hfa384x_usb_rridresp_t *rridresp,
769 hfa384x_rridresult_t *result)
773 result->rid = hfa384x2host_16(rridresp->rid);
774 result->riddata = rridresp->data;
775 result->riddata_len = ((hfa384x2host_16(rridresp->frmlen) - 1) * 2);
781 /*----------------------------------------------------------------
783 * This completor must be passed to hfa384x_usbctlx_complete_sync()
784 * when processing a CTLX that returns a hfa384x_cmdresult_t structure.
785 ----------------------------------------------------------------*/
786 struct usbctlx_cmd_completor
788 usbctlx_completor_t head;
790 const hfa384x_usb_cmdresp_t *cmdresp;
791 hfa384x_cmdresult_t *result;
793 typedef struct usbctlx_cmd_completor usbctlx_cmd_completor_t;
795 static int usbctlx_cmd_completor_fn(usbctlx_completor_t *head)
797 usbctlx_cmd_completor_t *complete = (usbctlx_cmd_completor_t*)head;
798 return usbctlx_get_status(complete->cmdresp, complete->result);
801 static inline usbctlx_completor_t*
802 init_cmd_completor(usbctlx_cmd_completor_t *completor,
803 const hfa384x_usb_cmdresp_t *cmdresp,
804 hfa384x_cmdresult_t *result)
806 completor->head.complete = usbctlx_cmd_completor_fn;
807 completor->cmdresp = cmdresp;
808 completor->result = result;
809 return &(completor->head);
812 /*----------------------------------------------------------------
814 * This completor must be passed to hfa384x_usbctlx_complete_sync()
815 * when processing a CTLX that reads a RID.
816 ----------------------------------------------------------------*/
817 struct usbctlx_rrid_completor
819 usbctlx_completor_t head;
821 const hfa384x_usb_rridresp_t *rridresp;
823 unsigned int riddatalen;
825 typedef struct usbctlx_rrid_completor usbctlx_rrid_completor_t;
827 static int usbctlx_rrid_completor_fn(usbctlx_completor_t *head)
829 usbctlx_rrid_completor_t *complete = (usbctlx_rrid_completor_t*)head;
830 hfa384x_rridresult_t rridresult;
832 usbctlx_get_rridresult(complete->rridresp, &rridresult);
834 /* Validate the length, note body len calculation in bytes */
835 if ( rridresult.riddata_len != complete->riddatalen ) {
837 "RID len mismatch, rid=0x%04x hlen=%d fwlen=%d\n",
839 complete->riddatalen,
840 rridresult.riddata_len);
844 memcpy(complete->riddata,
846 complete->riddatalen);
850 static inline usbctlx_completor_t*
851 init_rrid_completor(usbctlx_rrid_completor_t *completor,
852 const hfa384x_usb_rridresp_t *rridresp,
854 unsigned int riddatalen)
856 completor->head.complete = usbctlx_rrid_completor_fn;
857 completor->rridresp = rridresp;
858 completor->riddata = riddata;
859 completor->riddatalen = riddatalen;
860 return &(completor->head);
863 /*----------------------------------------------------------------
865 * Interprets the results of a synchronous RID-write
866 ----------------------------------------------------------------*/
867 typedef usbctlx_cmd_completor_t usbctlx_wrid_completor_t;
868 #define init_wrid_completor init_cmd_completor
870 /*----------------------------------------------------------------
872 * Interprets the results of a synchronous memory-write
873 ----------------------------------------------------------------*/
874 typedef usbctlx_cmd_completor_t usbctlx_wmem_completor_t;
875 #define init_wmem_completor init_cmd_completor
877 /*----------------------------------------------------------------
879 * Interprets the results of a synchronous memory-read
880 ----------------------------------------------------------------*/
881 struct usbctlx_rmem_completor
883 usbctlx_completor_t head;
885 const hfa384x_usb_rmemresp_t *rmemresp;
889 typedef struct usbctlx_rmem_completor usbctlx_rmem_completor_t;
891 static int usbctlx_rmem_completor_fn(usbctlx_completor_t *head)
893 usbctlx_rmem_completor_t *complete = (usbctlx_rmem_completor_t*)head;
895 WLAN_LOG_DEBUG(4,"rmemresp:len=%d\n", complete->rmemresp->frmlen);
896 memcpy(complete->data, complete->rmemresp->data, complete->len);
900 static inline usbctlx_completor_t*
901 init_rmem_completor(usbctlx_rmem_completor_t *completor,
902 hfa384x_usb_rmemresp_t *rmemresp,
906 completor->head.complete = usbctlx_rmem_completor_fn;
907 completor->rmemresp = rmemresp;
908 completor->data = data;
909 completor->len = len;
910 return &(completor->head);
913 /*----------------------------------------------------------------
916 * Ctlx_complete handler for async CMD type control exchanges.
917 * mark the hw struct as such.
919 * Note: If the handling is changed here, it should probably be
920 * changed in docmd as well.
924 * ctlx completed CTLX
933 ----------------------------------------------------------------*/
935 hfa384x_cb_status(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx)
939 if ( ctlx->usercb != NULL ) {
940 hfa384x_cmdresult_t cmdresult;
942 if (ctlx->state != CTLX_COMPLETE) {
943 memset(&cmdresult, 0, sizeof(cmdresult));
944 cmdresult.status = HFA384x_STATUS_RESULT_SET(HFA384x_CMD_ERR);
946 usbctlx_get_status(&ctlx->inbuf.cmdresp, &cmdresult);
949 ctlx->usercb(hw, &cmdresult, ctlx->usercb_data);
956 /*----------------------------------------------------------------
959 * CTLX completion handler for async RRID type control exchanges.
961 * Note: If the handling is changed here, it should probably be
962 * changed in dorrid as well.
966 * ctlx completed CTLX
975 ----------------------------------------------------------------*/
977 hfa384x_cb_rrid(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx)
981 if ( ctlx->usercb != NULL ) {
982 hfa384x_rridresult_t rridresult;
984 if (ctlx->state != CTLX_COMPLETE) {
985 memset(&rridresult, 0, sizeof(rridresult));
986 rridresult.rid = hfa384x2host_16(ctlx->outbuf.rridreq.rid);
988 usbctlx_get_rridresult(&ctlx->inbuf.rridresp, &rridresult);
991 ctlx->usercb(hw, &rridresult, ctlx->usercb_data);
998 hfa384x_docmd_wait(hfa384x_t *hw, hfa384x_metacmd_t *cmd)
1000 return hfa384x_docmd(hw, DOWAIT, cmd, NULL, NULL, NULL);
1004 hfa384x_docmd_async(hfa384x_t *hw,
1005 hfa384x_metacmd_t *cmd,
1007 ctlx_usercb_t usercb,
1010 return hfa384x_docmd(hw, DOASYNC, cmd,
1011 cmdcb, usercb, usercb_data);
1015 hfa384x_dorrid_wait(hfa384x_t *hw, u16 rid, void *riddata, unsigned int riddatalen)
1017 return hfa384x_dorrid(hw, DOWAIT,
1018 rid, riddata, riddatalen,
1023 hfa384x_dorrid_async(hfa384x_t *hw,
1024 u16 rid, void *riddata, unsigned int riddatalen,
1026 ctlx_usercb_t usercb,
1029 return hfa384x_dorrid(hw, DOASYNC,
1030 rid, riddata, riddatalen,
1031 cmdcb, usercb, usercb_data);
1035 hfa384x_dowrid_wait(hfa384x_t *hw, u16 rid, void *riddata, unsigned int riddatalen)
1037 return hfa384x_dowrid(hw, DOWAIT,
1038 rid, riddata, riddatalen,
1043 hfa384x_dowrid_async(hfa384x_t *hw,
1044 u16 rid, void *riddata, unsigned int riddatalen,
1046 ctlx_usercb_t usercb,
1049 return hfa384x_dowrid(hw, DOASYNC,
1050 rid, riddata, riddatalen,
1051 cmdcb, usercb, usercb_data);
1055 hfa384x_dormem_wait(hfa384x_t *hw,
1056 u16 page, u16 offset, void *data, unsigned int len)
1058 return hfa384x_dormem(hw, DOWAIT,
1059 page, offset, data, len,
1064 hfa384x_dormem_async(hfa384x_t *hw,
1065 u16 page, u16 offset, void *data, unsigned int len,
1067 ctlx_usercb_t usercb,
1070 return hfa384x_dormem(hw, DOASYNC,
1071 page, offset, data, len,
1072 cmdcb, usercb, usercb_data);
1076 hfa384x_dowmem_wait(
1083 return hfa384x_dowmem(hw, DOWAIT,
1084 page, offset, data, len,
1089 hfa384x_dowmem_async(
1096 ctlx_usercb_t usercb,
1099 return hfa384x_dowmem(hw, DOASYNC,
1100 page, offset, data, len,
1101 cmdcb, usercb, usercb_data);
1104 /*----------------------------------------------------------------
1105 * hfa384x_cmd_initialize
1107 * Issues the initialize command and sets the hw->state based
1111 * hw device structure
1115 * >0 f/w reported error - f/w status code
1116 * <0 driver reported error
1122 ----------------------------------------------------------------*/
1124 hfa384x_cmd_initialize(hfa384x_t *hw)
1128 hfa384x_metacmd_t cmd;
1133 cmd.cmd = HFA384x_CMDCODE_INIT;
1138 result = hfa384x_docmd_wait(hw, &cmd);
1141 WLAN_LOG_DEBUG(3,"cmdresp.init: "
1142 "status=0x%04x, resp0=0x%04x, "
1143 "resp1=0x%04x, resp2=0x%04x\n",
1148 if ( result == 0 ) {
1149 for ( i = 0; i < HFA384x_NUMPORTS_MAX; i++) {
1150 hw->port_enabled[i] = 0;
1154 hw->link_status = HFA384x_LINK_NOTCONNECTED;
1161 /*----------------------------------------------------------------
1162 * hfa384x_cmd_disable
1164 * Issues the disable command to stop communications on one of
1168 * hw device structure
1169 * macport MAC port number (host order)
1173 * >0 f/w reported failure - f/w status code
1174 * <0 driver reported error (timeout|bad arg)
1180 ----------------------------------------------------------------*/
1181 int hfa384x_cmd_disable(hfa384x_t *hw, u16 macport)
1184 hfa384x_metacmd_t cmd;
1188 cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DISABLE) |
1189 HFA384x_CMD_MACPORT_SET(macport);
1194 result = hfa384x_docmd_wait(hw, &cmd);
1201 /*----------------------------------------------------------------
1202 * hfa384x_cmd_enable
1204 * Issues the enable command to enable communications on one of
1208 * hw device structure
1209 * macport MAC port number
1213 * >0 f/w reported failure - f/w status code
1214 * <0 driver reported error (timeout|bad arg)
1220 ----------------------------------------------------------------*/
1221 int hfa384x_cmd_enable(hfa384x_t *hw, u16 macport)
1224 hfa384x_metacmd_t cmd;
1228 cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ENABLE) |
1229 HFA384x_CMD_MACPORT_SET(macport);
1234 result = hfa384x_docmd_wait(hw, &cmd);
1241 /*----------------------------------------------------------------
1242 * hfa384x_cmd_notify
1244 * Sends an info frame to the firmware to alter the behavior
1245 * of the f/w asynch processes. Can only be called when the MAC
1246 * is in the enabled state.
1249 * hw device structure
1250 * reclaim [0|1] indicates whether the given FID will
1251 * be handed back (via Alloc event) for reuse.
1253 * fid FID of buffer containing the frame that was
1254 * previously copied to MAC memory via the bap.
1259 * >0 f/w reported failure - f/w status code
1260 * <0 driver reported error (timeout|bad arg)
1263 * hw->resp0 will contain the FID being used by async notify
1264 * process. If reclaim==0, resp0 will be the same as the fid
1265 * argument. If reclaim==1, resp0 will be the different.
1269 ----------------------------------------------------------------*/
1270 int hfa384x_cmd_notify(hfa384x_t *hw, u16 reclaim, u16 fid,
1277 cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_NOTIFY) |
1278 HFA384x_CMD_RECL_SET(reclaim);
1279 result = hfa384x_docmd_wait(hw, cmd);
1289 /*----------------------------------------------------------------
1290 * hfa384x_cmd_inquiry
1292 * Requests an info frame from the firmware. The info frame will
1293 * be delivered asynchronously via the Info event.
1296 * hw device structure
1297 * fid FID of the info frame requested. (host order)
1301 * >0 f/w reported failure - f/w status code
1302 * <0 driver reported error (timeout|bad arg)
1308 ----------------------------------------------------------------*/
1309 int hfa384x_cmd_inquiry(hfa384x_t *hw, u16 fid)
1312 hfa384x_metacmd_t cmd;
1316 cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_INQ);
1321 result = hfa384x_docmd_wait(hw, &cmd);
1329 /*----------------------------------------------------------------
1330 * hfa384x_cmd_monitor
1332 * Enables the 'monitor mode' of the MAC. Here's the description of
1333 * monitor mode that I've received thus far:
1335 * "The "monitor mode" of operation is that the MAC passes all
1336 * frames for which the PLCP checks are correct. All received
1337 * MPDUs are passed to the host with MAC Port = 7, with a
1338 * receive status of good, FCS error, or undecryptable. Passing
1339 * certain MPDUs is a violation of the 802.11 standard, but useful
1340 * for a debugging tool." Normal communication is not possible
1341 * while monitor mode is enabled.
1344 * hw device structure
1345 * enable a code (0x0b|0x0f) that enables/disables
1346 * monitor mode. (host order)
1350 * >0 f/w reported failure - f/w status code
1351 * <0 driver reported error (timeout|bad arg)
1357 ----------------------------------------------------------------*/
1358 int hfa384x_cmd_monitor(hfa384x_t *hw, u16 enable)
1361 hfa384x_metacmd_t cmd;
1365 cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) |
1366 HFA384x_CMD_AINFO_SET(enable);
1371 result = hfa384x_docmd_wait(hw, &cmd);
1378 /*----------------------------------------------------------------
1379 * hfa384x_cmd_download
1381 * Sets the controls for the MAC controller code/data download
1382 * process. The arguments set the mode and address associated
1383 * with a download. Note that the aux registers should be enabled
1384 * prior to setting one of the download enable modes.
1387 * hw device structure
1388 * mode 0 - Disable programming and begin code exec
1389 * 1 - Enable volatile mem programming
1390 * 2 - Enable non-volatile mem programming
1391 * 3 - Program non-volatile section from NV download
1395 * highaddr For mode 1, sets the high & low order bits of
1396 * the "destination address". This address will be
1397 * the execution start address when download is
1398 * subsequently disabled.
1399 * For mode 2, sets the high & low order bits of
1400 * the destination in NV ram.
1401 * For modes 0 & 3, should be zero. (host order)
1402 * NOTE: these are CMD format.
1403 * codelen Length of the data to write in mode 2,
1404 * zero otherwise. (host order)
1408 * >0 f/w reported failure - f/w status code
1409 * <0 driver reported error (timeout|bad arg)
1415 ----------------------------------------------------------------*/
1416 int hfa384x_cmd_download(hfa384x_t *hw, u16 mode, u16 lowaddr,
1417 u16 highaddr, u16 codelen)
1420 hfa384x_metacmd_t cmd;
1424 "mode=%d, lowaddr=0x%04x, highaddr=0x%04x, codelen=%d\n",
1425 mode, lowaddr, highaddr, codelen);
1427 cmd.cmd = (HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DOWNLD) |
1428 HFA384x_CMD_PROGMODE_SET(mode));
1430 cmd.parm0 = lowaddr;
1431 cmd.parm1 = highaddr;
1432 cmd.parm2 = codelen;
1434 result = hfa384x_docmd_wait(hw, &cmd);
1441 /*----------------------------------------------------------------
1442 * hfa384x_copy_from_aux
1444 * Copies a collection of bytes from the controller memory. The
1445 * Auxiliary port MUST be enabled prior to calling this function.
1446 * We _might_ be in a download state.
1449 * hw device structure
1450 * cardaddr address in hfa384x data space to read
1451 * auxctl address space select
1452 * buf ptr to destination host buffer
1453 * len length of data to transfer (in bytes)
1459 * buf contains the data copied
1464 ----------------------------------------------------------------*/
1466 hfa384x_copy_from_aux(
1467 hfa384x_t *hw, u32 cardaddr, u32 auxctl, void *buf, unsigned int len)
1470 WLAN_LOG_ERROR("not used in USB.\n");
1475 /*----------------------------------------------------------------
1476 * hfa384x_copy_to_aux
1478 * Copies a collection of bytes to the controller memory. The
1479 * Auxiliary port MUST be enabled prior to calling this function.
1480 * We _might_ be in a download state.
1483 * hw device structure
1484 * cardaddr address in hfa384x data space to read
1485 * auxctl address space select
1486 * buf ptr to destination host buffer
1487 * len length of data to transfer (in bytes)
1493 * Controller memory now contains a copy of buf
1498 ----------------------------------------------------------------*/
1500 hfa384x_copy_to_aux(
1501 hfa384x_t *hw, u32 cardaddr, u32 auxctl, void *buf, unsigned int len)
1504 WLAN_LOG_ERROR("not used in USB.\n");
1509 /*----------------------------------------------------------------
1512 * Perform a reset of the hfa38xx MAC core. We assume that the hw
1513 * structure is in its "created" state. That is, it is initialized
1514 * with proper values. Note that if a reset is done after the
1515 * device has been active for awhile, the caller might have to clean
1516 * up some leftover cruft in the hw structure.
1519 * hw device structure
1520 * holdtime how long (in ms) to hold the reset
1521 * settletime how long (in ms) to wait after releasing
1531 ----------------------------------------------------------------*/
1532 int hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis)
1538 result=usb_reset_device(hw->usb);
1540 WLAN_LOG_ERROR("usb_reset_device() failed, result=%d.\n",result);
1548 /*----------------------------------------------------------------
1549 * hfa384x_usbctlx_complete_sync
1551 * Waits for a synchronous CTLX object to complete,
1552 * and then handles the response.
1555 * hw device structure
1557 * completor functor object to decide what to
1558 * do with the CTLX's result.
1562 * -ERESTARTSYS Interrupted by a signal
1564 * -ENODEV Adapter was unplugged
1565 * ??? Result from completor
1571 ----------------------------------------------------------------*/
1572 static int hfa384x_usbctlx_complete_sync(hfa384x_t *hw,
1573 hfa384x_usbctlx_t *ctlx,
1574 usbctlx_completor_t *completor)
1576 unsigned long flags;
1581 result = wait_for_completion_interruptible(&ctlx->done);
1583 spin_lock_irqsave(&hw->ctlxq.lock, flags);
1586 * We can only handle the CTLX if the USB disconnect
1587 * function has not run yet ...
1590 if ( hw->wlandev->hwremoved )
1592 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
1595 else if ( result != 0 )
1600 * We were probably interrupted, so delete
1601 * this CTLX asynchronously, kill the timers
1602 * and the URB, and then start the next
1605 * NOTE: We can only delete the timers and
1606 * the URB if this CTLX is active.
1608 if (ctlx == get_active_ctlx(hw))
1610 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
1612 del_singleshot_timer_sync(&hw->reqtimer);
1613 del_singleshot_timer_sync(&hw->resptimer);
1614 hw->req_timer_done = 1;
1615 hw->resp_timer_done = 1;
1616 usb_kill_urb(&hw->ctlx_urb);
1618 spin_lock_irqsave(&hw->ctlxq.lock, flags);
1623 * This scenario is so unlikely that I'm
1624 * happy with a grubby "goto" solution ...
1626 if ( hw->wlandev->hwremoved )
1631 * The completion task will send this CTLX
1632 * to the reaper the next time it runs. We
1633 * are no longer in a hurry.
1636 ctlx->state = CTLX_REQ_FAILED;
1637 list_move_tail(&ctlx->list, &hw->ctlxq.completing);
1639 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
1642 hfa384x_usbctlxq_run(hw);
1644 if (ctlx->state == CTLX_COMPLETE) {
1645 result = completor->complete(completor);
1647 WLAN_LOG_WARNING("CTLX[%d] error: state(%s)\n",
1648 hfa384x2host_16(ctlx->outbuf.type),
1649 ctlxstr(ctlx->state));
1653 list_del(&ctlx->list);
1654 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
1662 /*----------------------------------------------------------------
1665 * Constructs a command CTLX and submits it.
1667 * NOTE: Any changes to the 'post-submit' code in this function
1668 * need to be carried over to hfa384x_cbcmd() since the handling
1669 * is virtually identical.
1672 * hw device structure
1673 * mode DOWAIT or DOASYNC
1674 * cmd cmd structure. Includes all arguments and result
1675 * data points. All in host order. in host order
1676 * cmdcb command-specific callback
1677 * usercb user callback for async calls, NULL for DOWAIT calls
1678 * usercb_data user supplied data pointer for async calls, NULL
1684 * -ERESTARTSYS Awakened on signal
1685 * >0 command indicated error, Status and Resp0-2 are
1693 ----------------------------------------------------------------*/
1698 hfa384x_metacmd_t *cmd,
1700 ctlx_usercb_t usercb,
1704 hfa384x_usbctlx_t *ctlx;
1707 ctlx = usbctlx_alloc();
1708 if ( ctlx == NULL ) {
1713 /* Initialize the command */
1714 ctlx->outbuf.cmdreq.type = host2hfa384x_16(HFA384x_USB_CMDREQ);
1715 ctlx->outbuf.cmdreq.cmd = host2hfa384x_16(cmd->cmd);
1716 ctlx->outbuf.cmdreq.parm0 = host2hfa384x_16(cmd->parm0);
1717 ctlx->outbuf.cmdreq.parm1 = host2hfa384x_16(cmd->parm1);
1718 ctlx->outbuf.cmdreq.parm2 = host2hfa384x_16(cmd->parm2);
1720 ctlx->outbufsize = sizeof(ctlx->outbuf.cmdreq);
1722 WLAN_LOG_DEBUG(4, "cmdreq: cmd=0x%04x "
1723 "parm0=0x%04x parm1=0x%04x parm2=0x%04x\n",
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 usbctlx_cmd_completor_t completor;
1740 result = hfa384x_usbctlx_complete_sync(
1741 hw, ctlx, init_cmd_completor(&completor,
1742 &ctlx->inbuf.cmdresp,
1752 /*----------------------------------------------------------------
1755 * Constructs a read rid CTLX and issues it.
1757 * NOTE: Any changes to the 'post-submit' code in this function
1758 * need to be carried over to hfa384x_cbrrid() since the handling
1759 * is virtually identical.
1762 * hw device structure
1763 * mode DOWAIT or DOASYNC
1764 * rid Read RID number (host order)
1765 * riddata Caller supplied buffer that MAC formatted RID.data
1766 * record will be written to for DOWAIT calls. Should
1767 * be NULL for DOASYNC calls.
1768 * riddatalen Buffer length for DOWAIT calls. Zero for DOASYNC calls.
1769 * cmdcb command callback for async calls, NULL for DOWAIT calls
1770 * usercb user callback for async calls, NULL for DOWAIT calls
1771 * usercb_data user supplied data pointer for async calls, NULL
1777 * -ERESTARTSYS Awakened on signal
1778 * -ENODATA riddatalen != macdatalen
1779 * >0 command indicated error, Status and Resp0-2 are
1785 * interrupt (DOASYNC)
1786 * process (DOWAIT or DOASYNC)
1787 ----------------------------------------------------------------*/
1794 unsigned int riddatalen,
1796 ctlx_usercb_t usercb,
1800 hfa384x_usbctlx_t *ctlx;
1803 ctlx = usbctlx_alloc();
1804 if ( ctlx == NULL ) {
1809 /* Initialize the command */
1810 ctlx->outbuf.rridreq.type = host2hfa384x_16(HFA384x_USB_RRIDREQ);
1811 ctlx->outbuf.rridreq.frmlen =
1812 host2hfa384x_16(sizeof(ctlx->outbuf.rridreq.rid));
1813 ctlx->outbuf.rridreq.rid = host2hfa384x_16(rid);
1815 ctlx->outbufsize = sizeof(ctlx->outbuf.rridreq);
1817 ctlx->reapable = mode;
1818 ctlx->cmdcb = cmdcb;
1819 ctlx->usercb = usercb;
1820 ctlx->usercb_data = usercb_data;
1822 /* Submit the CTLX */
1823 result = hfa384x_usbctlx_submit(hw, ctlx);
1826 } else if (mode == DOWAIT) {
1827 usbctlx_rrid_completor_t completor;
1829 result = hfa384x_usbctlx_complete_sync(
1830 hw, ctlx, init_rrid_completor(&completor,
1831 &ctlx->inbuf.rridresp,
1842 /*----------------------------------------------------------------
1845 * Constructs a write rid CTLX and issues it.
1847 * NOTE: Any changes to the 'post-submit' code in this function
1848 * need to be carried over to hfa384x_cbwrid() since the handling
1849 * is virtually identical.
1852 * hw device structure
1853 * CMD_MODE DOWAIT or DOASYNC
1855 * riddata Data portion of RID formatted for MAC
1856 * riddatalen Length of the data portion in bytes
1857 * cmdcb command callback for async calls, NULL for DOWAIT calls
1858 * usercb user callback for async calls, NULL for DOWAIT calls
1859 * usercb_data user supplied data pointer for async calls
1863 * -ETIMEDOUT timed out waiting for register ready or
1864 * command completion
1865 * >0 command indicated error, Status and Resp0-2 are
1871 * interrupt (DOASYNC)
1872 * process (DOWAIT or DOASYNC)
1873 ----------------------------------------------------------------*/
1880 unsigned int riddatalen,
1882 ctlx_usercb_t usercb,
1886 hfa384x_usbctlx_t *ctlx;
1889 ctlx = usbctlx_alloc();
1890 if ( ctlx == NULL ) {
1895 /* Initialize the command */
1896 ctlx->outbuf.wridreq.type = host2hfa384x_16(HFA384x_USB_WRIDREQ);
1897 ctlx->outbuf.wridreq.frmlen = host2hfa384x_16(
1898 (sizeof(ctlx->outbuf.wridreq.rid) +
1899 riddatalen + 1) / 2);
1900 ctlx->outbuf.wridreq.rid = host2hfa384x_16(rid);
1901 memcpy(ctlx->outbuf.wridreq.data, riddata, riddatalen);
1903 ctlx->outbufsize = sizeof(ctlx->outbuf.wridreq.type) +
1904 sizeof(ctlx->outbuf.wridreq.frmlen) +
1905 sizeof(ctlx->outbuf.wridreq.rid) +
1908 ctlx->reapable = mode;
1909 ctlx->cmdcb = cmdcb;
1910 ctlx->usercb = usercb;
1911 ctlx->usercb_data = usercb_data;
1913 /* Submit the CTLX */
1914 result = hfa384x_usbctlx_submit(hw, ctlx);
1917 } else if (mode == DOWAIT) {
1918 usbctlx_wrid_completor_t completor;
1919 hfa384x_cmdresult_t wridresult;
1921 result = hfa384x_usbctlx_complete_sync(
1924 init_wrid_completor(&completor,
1925 &ctlx->inbuf.wridresp,
1934 /*----------------------------------------------------------------
1937 * Constructs a readmem CTLX and issues it.
1939 * NOTE: Any changes to the 'post-submit' code in this function
1940 * need to be carried over to hfa384x_cbrmem() since the handling
1941 * is virtually identical.
1944 * hw device structure
1945 * mode DOWAIT or DOASYNC
1946 * page MAC address space page (CMD format)
1947 * offset MAC address space offset
1948 * data Ptr to data buffer to receive read
1949 * len Length of the data to read (max == 2048)
1950 * cmdcb command callback for async calls, NULL for DOWAIT calls
1951 * usercb user callback for async calls, NULL for DOWAIT calls
1952 * usercb_data user supplied data pointer for async calls
1956 * -ETIMEDOUT timed out waiting for register ready or
1957 * command completion
1958 * >0 command indicated error, Status and Resp0-2 are
1964 * interrupt (DOASYNC)
1965 * process (DOWAIT or DOASYNC)
1966 ----------------------------------------------------------------*/
1976 ctlx_usercb_t usercb,
1980 hfa384x_usbctlx_t *ctlx;
1983 ctlx = usbctlx_alloc();
1984 if ( ctlx == NULL ) {
1989 /* Initialize the command */
1990 ctlx->outbuf.rmemreq.type = host2hfa384x_16(HFA384x_USB_RMEMREQ);
1991 ctlx->outbuf.rmemreq.frmlen = host2hfa384x_16(
1992 sizeof(ctlx->outbuf.rmemreq.offset) +
1993 sizeof(ctlx->outbuf.rmemreq.page) +
1995 ctlx->outbuf.rmemreq.offset = host2hfa384x_16(offset);
1996 ctlx->outbuf.rmemreq.page = host2hfa384x_16(page);
1998 ctlx->outbufsize = sizeof(ctlx->outbuf.rmemreq);
2001 "type=0x%04x frmlen=%d offset=0x%04x page=0x%04x\n",
2002 ctlx->outbuf.rmemreq.type,
2003 ctlx->outbuf.rmemreq.frmlen,
2004 ctlx->outbuf.rmemreq.offset,
2005 ctlx->outbuf.rmemreq.page);
2007 WLAN_LOG_DEBUG(4,"pktsize=%zd\n",
2008 ROUNDUP64(sizeof(ctlx->outbuf.rmemreq)));
2010 ctlx->reapable = mode;
2011 ctlx->cmdcb = cmdcb;
2012 ctlx->usercb = usercb;
2013 ctlx->usercb_data = usercb_data;
2015 result = hfa384x_usbctlx_submit(hw, ctlx);
2018 } else if ( mode == DOWAIT ) {
2019 usbctlx_rmem_completor_t completor;
2021 result = hfa384x_usbctlx_complete_sync(
2022 hw, ctlx, init_rmem_completor(&completor,
2023 &ctlx->inbuf.rmemresp,
2035 /*----------------------------------------------------------------
2038 * Constructs a writemem CTLX and issues it.
2040 * NOTE: Any changes to the 'post-submit' code in this function
2041 * need to be carried over to hfa384x_cbwmem() since the handling
2042 * is virtually identical.
2045 * hw device structure
2046 * mode DOWAIT or DOASYNC
2047 * page MAC address space page (CMD format)
2048 * offset MAC address space offset
2049 * data Ptr to data buffer containing write data
2050 * len Length of the data to read (max == 2048)
2051 * cmdcb command callback for async calls, NULL for DOWAIT calls
2052 * usercb user callback for async calls, NULL for DOWAIT calls
2053 * usercb_data user supplied data pointer for async calls.
2057 * -ETIMEDOUT timed out waiting for register ready or
2058 * command completion
2059 * >0 command indicated error, Status and Resp0-2 are
2065 * interrupt (DOWAIT)
2066 * process (DOWAIT or DOASYNC)
2067 ----------------------------------------------------------------*/
2077 ctlx_usercb_t usercb,
2081 hfa384x_usbctlx_t *ctlx;
2084 WLAN_LOG_DEBUG(5, "page=0x%04x offset=0x%04x len=%d\n",
2087 ctlx = usbctlx_alloc();
2088 if ( ctlx == NULL ) {
2093 /* Initialize the command */
2094 ctlx->outbuf.wmemreq.type = host2hfa384x_16(HFA384x_USB_WMEMREQ);
2095 ctlx->outbuf.wmemreq.frmlen = host2hfa384x_16(
2096 sizeof(ctlx->outbuf.wmemreq.offset) +
2097 sizeof(ctlx->outbuf.wmemreq.page) +
2099 ctlx->outbuf.wmemreq.offset = host2hfa384x_16(offset);
2100 ctlx->outbuf.wmemreq.page = host2hfa384x_16(page);
2101 memcpy(ctlx->outbuf.wmemreq.data, data, len);
2103 ctlx->outbufsize = sizeof(ctlx->outbuf.wmemreq.type) +
2104 sizeof(ctlx->outbuf.wmemreq.frmlen) +
2105 sizeof(ctlx->outbuf.wmemreq.offset) +
2106 sizeof(ctlx->outbuf.wmemreq.page) +
2109 ctlx->reapable = mode;
2110 ctlx->cmdcb = cmdcb;
2111 ctlx->usercb = usercb;
2112 ctlx->usercb_data = usercb_data;
2114 result = hfa384x_usbctlx_submit(hw, ctlx);
2117 } else if ( mode == DOWAIT ) {
2118 usbctlx_wmem_completor_t completor;
2119 hfa384x_cmdresult_t wmemresult;
2121 result = hfa384x_usbctlx_complete_sync(
2124 init_wmem_completor(&completor,
2125 &ctlx->inbuf.wmemresp,
2135 /*----------------------------------------------------------------
2136 * hfa384x_drvr_commtallies
2138 * Send a commtallies inquiry to the MAC. Note that this is an async
2139 * call that will result in an info frame arriving sometime later.
2142 * hw device structure
2151 ----------------------------------------------------------------*/
2152 int hfa384x_drvr_commtallies( hfa384x_t *hw )
2154 hfa384x_metacmd_t cmd;
2158 cmd.cmd = HFA384x_CMDCODE_INQ;
2159 cmd.parm0 = HFA384x_IT_COMMTALLIES;
2163 hfa384x_docmd_async(hw, &cmd, NULL, NULL, NULL);
2170 /*----------------------------------------------------------------
2171 * hfa384x_drvr_disable
2173 * Issues the disable command to stop communications on one of
2174 * the MACs 'ports'. Only macport 0 is valid for stations.
2175 * APs may also disable macports 1-6. Only ports that have been
2176 * previously enabled may be disabled.
2179 * hw device structure
2180 * macport MAC port number (host order)
2184 * >0 f/w reported failure - f/w status code
2185 * <0 driver reported error (timeout|bad arg)
2191 ----------------------------------------------------------------*/
2192 int hfa384x_drvr_disable(hfa384x_t *hw, u16 macport)
2197 if ((!hw->isap && macport != 0) ||
2198 (hw->isap && !(macport <= HFA384x_PORTID_MAX)) ||
2199 !(hw->port_enabled[macport]) ){
2202 result = hfa384x_cmd_disable(hw, macport);
2203 if ( result == 0 ) {
2204 hw->port_enabled[macport] = 0;
2212 /*----------------------------------------------------------------
2213 * hfa384x_drvr_enable
2215 * Issues the enable command to enable communications on one of
2216 * the MACs 'ports'. Only macport 0 is valid for stations.
2217 * APs may also enable macports 1-6. Only ports that are currently
2218 * disabled may be enabled.
2221 * hw device structure
2222 * macport MAC port number
2226 * >0 f/w reported failure - f/w status code
2227 * <0 driver reported error (timeout|bad arg)
2233 ----------------------------------------------------------------*/
2234 int hfa384x_drvr_enable(hfa384x_t *hw, u16 macport)
2239 if ((!hw->isap && macport != 0) ||
2240 (hw->isap && !(macport <= HFA384x_PORTID_MAX)) ||
2241 (hw->port_enabled[macport]) ){
2244 result = hfa384x_cmd_enable(hw, macport);
2245 if ( result == 0 ) {
2246 hw->port_enabled[macport] = 1;
2254 /*----------------------------------------------------------------
2255 * hfa384x_drvr_flashdl_enable
2257 * Begins the flash download state. Checks to see that we're not
2258 * already in a download state and that a port isn't enabled.
2259 * Sets the download state and retrieves the flash download
2260 * buffer location, buffer size, and timeout length.
2263 * hw device structure
2267 * >0 f/w reported error - f/w status code
2268 * <0 driver reported error
2274 ----------------------------------------------------------------*/
2275 int hfa384x_drvr_flashdl_enable(hfa384x_t *hw)
2281 /* Check that a port isn't active */
2282 for ( i = 0; i < HFA384x_PORTID_MAX; i++) {
2283 if ( hw->port_enabled[i] ) {
2284 WLAN_LOG_DEBUG(1,"called when port enabled.\n");
2289 /* Check that we're not already in a download state */
2290 if ( hw->dlstate != HFA384x_DLSTATE_DISABLED ) {
2294 /* Retrieve the buffer loc&size and timeout */
2295 if ( (result = hfa384x_drvr_getconfig(hw, HFA384x_RID_DOWNLOADBUFFER,
2296 &(hw->bufinfo), sizeof(hw->bufinfo))) ) {
2299 hw->bufinfo.page = hfa384x2host_16(hw->bufinfo.page);
2300 hw->bufinfo.offset = hfa384x2host_16(hw->bufinfo.offset);
2301 hw->bufinfo.len = hfa384x2host_16(hw->bufinfo.len);
2302 if ( (result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_MAXLOADTIME,
2303 &(hw->dltimeout))) ) {
2306 hw->dltimeout = hfa384x2host_16(hw->dltimeout);
2308 WLAN_LOG_DEBUG(1,"flashdl_enable\n");
2310 hw->dlstate = HFA384x_DLSTATE_FLASHENABLED;
2316 /*----------------------------------------------------------------
2317 * hfa384x_drvr_flashdl_disable
2319 * Ends the flash download state. Note that this will cause the MAC
2320 * firmware to restart.
2323 * hw device structure
2327 * >0 f/w reported error - f/w status code
2328 * <0 driver reported error
2334 ----------------------------------------------------------------*/
2335 int hfa384x_drvr_flashdl_disable(hfa384x_t *hw)
2338 /* Check that we're already in the download state */
2339 if ( hw->dlstate != HFA384x_DLSTATE_FLASHENABLED ) {
2343 WLAN_LOG_DEBUG(1,"flashdl_enable\n");
2345 /* There isn't much we can do at this point, so I don't */
2346 /* bother w/ the return value */
2347 hfa384x_cmd_download(hw, HFA384x_PROGMODE_DISABLE, 0, 0 , 0);
2348 hw->dlstate = HFA384x_DLSTATE_DISABLED;
2355 /*----------------------------------------------------------------
2356 * hfa384x_drvr_flashdl_write
2358 * Performs a FLASH download of a chunk of data. First checks to see
2359 * that we're in the FLASH download state, then sets the download
2360 * mode, uses the aux functions to 1) copy the data to the flash
2361 * buffer, 2) sets the download 'write flash' mode, 3) readback and
2362 * compare. Lather rinse, repeat as many times an necessary to get
2363 * all the given data into flash.
2364 * When all data has been written using this function (possibly
2365 * repeatedly), call drvr_flashdl_disable() to end the download state
2366 * and restart the MAC.
2369 * hw device structure
2370 * daddr Card address to write to. (host order)
2371 * buf Ptr to data to write.
2372 * len Length of data (host order).
2376 * >0 f/w reported error - f/w status code
2377 * <0 driver reported error
2383 ----------------------------------------------------------------*/
2385 hfa384x_drvr_flashdl_write(
2407 WLAN_LOG_DEBUG(5,"daddr=0x%08x len=%d\n", daddr, len);
2409 /* Check that we're in the flash download state */
2410 if ( hw->dlstate != HFA384x_DLSTATE_FLASHENABLED ) {
2414 WLAN_LOG_INFO("Download %d bytes to flash @0x%06x\n", len, daddr);
2416 /* Convert to flat address for arithmetic */
2417 /* NOTE: dlbuffer RID stores the address in AUX format */
2418 dlbufaddr = HFA384x_ADDR_AUX_MKFLAT(
2419 hw->bufinfo.page, hw->bufinfo.offset);
2421 "dlbuf.page=0x%04x dlbuf.offset=0x%04x dlbufaddr=0x%08x\n",
2422 hw->bufinfo.page, hw->bufinfo.offset, dlbufaddr);
2425 WLAN_LOG_WARNING("dlbuf@0x%06lx len=%d to=%d\n", dlbufaddr, hw->bufinfo.len, hw->dltimeout);
2427 /* Calculations to determine how many fills of the dlbuffer to do
2428 * and how many USB wmemreq's to do for each fill. At this point
2429 * in time, the dlbuffer size and the wmemreq size are the same.
2430 * Therefore, nwrites should always be 1. The extra complexity
2431 * here is a hedge against future changes.
2434 /* Figure out how many times to do the flash programming */
2435 nburns = len / hw->bufinfo.len;
2436 nburns += (len % hw->bufinfo.len) ? 1 : 0;
2438 /* For each flash program cycle, how many USB wmemreq's are needed? */
2439 nwrites = hw->bufinfo.len / HFA384x_USB_RWMEM_MAXLEN;
2440 nwrites += (hw->bufinfo.len % HFA384x_USB_RWMEM_MAXLEN) ? 1 : 0;
2443 for ( i = 0; i < nburns; i++) {
2444 /* Get the dest address and len */
2445 burnlen = (len - (hw->bufinfo.len * i)) > hw->bufinfo.len ?
2447 (len - (hw->bufinfo.len * i));
2448 burndaddr = daddr + (hw->bufinfo.len * i);
2449 burnlo = HFA384x_ADDR_CMD_MKOFF(burndaddr);
2450 burnhi = HFA384x_ADDR_CMD_MKPAGE(burndaddr);
2452 WLAN_LOG_INFO("Writing %d bytes to flash @0x%06x\n",
2453 burnlen, burndaddr);
2455 /* Set the download mode */
2456 result = hfa384x_cmd_download(hw, HFA384x_PROGMODE_NV,
2457 burnlo, burnhi, burnlen);
2459 WLAN_LOG_ERROR("download(NV,lo=%x,hi=%x,len=%x) "
2460 "cmd failed, result=%d. Aborting d/l\n",
2461 burnlo, burnhi, burnlen, result);
2465 /* copy the data to the flash download buffer */
2466 for ( j=0; j < nwrites; j++) {
2468 (i*hw->bufinfo.len) +
2469 (j*HFA384x_USB_RWMEM_MAXLEN);
2471 writepage = HFA384x_ADDR_CMD_MKPAGE(
2473 (j*HFA384x_USB_RWMEM_MAXLEN));
2474 writeoffset = HFA384x_ADDR_CMD_MKOFF(
2476 (j*HFA384x_USB_RWMEM_MAXLEN));
2478 writelen = burnlen-(j*HFA384x_USB_RWMEM_MAXLEN);
2479 writelen = writelen > HFA384x_USB_RWMEM_MAXLEN ?
2480 HFA384x_USB_RWMEM_MAXLEN :
2483 result = hfa384x_dowmem_wait( hw,
2490 Comment out for debugging, assume the write was successful.
2493 "Write to dl buffer failed, "
2494 "result=0x%04x. Aborting.\n",
2502 /* set the download 'write flash' mode */
2503 result = hfa384x_cmd_download(hw,
2504 HFA384x_PROGMODE_NVWRITE,
2508 "download(NVWRITE,lo=%x,hi=%x,len=%x) "
2509 "cmd failed, result=%d. Aborting d/l\n",
2510 burnlo, burnhi, burnlen, result);
2514 /* TODO: We really should do a readback and compare. */
2519 /* Leave the firmware in the 'post-prog' mode. flashdl_disable will */
2520 /* actually disable programming mode. Remember, that will cause the */
2521 /* the firmware to effectively reset itself. */
2528 /*----------------------------------------------------------------
2529 * hfa384x_drvr_getconfig
2531 * Performs the sequence necessary to read a config/info item.
2534 * hw device structure
2535 * rid config/info record id (host order)
2536 * buf host side record buffer. Upon return it will
2537 * contain the body portion of the record (minus the
2539 * len buffer length (in bytes, should match record length)
2543 * >0 f/w reported error - f/w status code
2544 * <0 driver reported error
2545 * -ENODATA length mismatch between argument and retrieved
2552 ----------------------------------------------------------------*/
2553 int hfa384x_drvr_getconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len)
2558 result = hfa384x_dorrid_wait(hw, rid, buf, len);
2564 /*----------------------------------------------------------------
2565 * hfa384x_drvr_getconfig_async
2567 * Performs the sequence necessary to perform an async read of
2568 * of a config/info item.
2571 * hw device structure
2572 * rid config/info record id (host order)
2573 * buf host side record buffer. Upon return it will
2574 * contain the body portion of the record (minus the
2576 * len buffer length (in bytes, should match record length)
2577 * cbfn caller supplied callback, called when the command
2578 * is done (successful or not).
2579 * cbfndata pointer to some caller supplied data that will be
2580 * passed in as an argument to the cbfn.
2583 * nothing the cbfn gets a status argument identifying if
2586 * Queues an hfa384x_usbcmd_t for subsequent execution.
2590 ----------------------------------------------------------------*/
2592 hfa384x_drvr_getconfig_async(
2595 ctlx_usercb_t usercb,
2598 return hfa384x_dorrid_async(hw, rid, NULL, 0,
2599 hfa384x_cb_rrid, usercb, usercb_data);
2602 /*----------------------------------------------------------------
2603 * hfa384x_drvr_setconfig_async
2605 * Performs the sequence necessary to write a config/info item.
2608 * hw device structure
2609 * rid config/info record id (in host order)
2610 * buf host side record buffer
2611 * len buffer length (in bytes)
2612 * usercb completion callback
2613 * usercb_data completion callback argument
2617 * >0 f/w reported error - f/w status code
2618 * <0 driver reported error
2624 ----------------------------------------------------------------*/
2626 hfa384x_drvr_setconfig_async(
2631 ctlx_usercb_t usercb,
2634 return hfa384x_dowrid_async(hw, rid, buf, len,
2635 hfa384x_cb_status, usercb, usercb_data);
2638 /*----------------------------------------------------------------
2639 * hfa384x_drvr_handover
2641 * Sends a handover notification to the MAC.
2644 * hw device structure
2645 * addr address of station that's left
2649 * -ERESTARTSYS received signal while waiting for semaphore.
2650 * -EIO failed to write to bap, or failed in cmd.
2656 ----------------------------------------------------------------*/
2657 int hfa384x_drvr_handover( hfa384x_t *hw, u8 *addr)
2660 WLAN_LOG_ERROR("Not currently supported in USB!\n");
2665 /*----------------------------------------------------------------
2666 * hfa384x_drvr_low_level
2668 * Write test commands to the card. Some test commands don't make
2669 * sense without prior set-up. For example, continous TX isn't very
2670 * useful until you set the channel. That functionality should be
2676 * -----------------------------------------------------------------*/
2677 int hfa384x_drvr_low_level(hfa384x_t *hw, hfa384x_metacmd_t *cmd)
2682 /* Do i need a host2hfa... conversion ? */
2684 result = hfa384x_docmd_wait(hw, cmd);
2690 /*----------------------------------------------------------------
2691 * hfa384x_drvr_mmi_read
2693 * Read mmi registers. mmi is intersil-speak for the baseband
2694 * processor registers.
2697 * hw device structure
2698 * register The test register to be accessed (must be even #).
2702 * >0 f/w reported error - f/w status code
2703 * <0 driver reported error
2709 ----------------------------------------------------------------*/
2710 int hfa384x_drvr_mmi_read(hfa384x_t *hw, u32 addr, u32 *resp)
2714 u16 cmd_code = (u16) 0x30;
2715 u16 param = (u16) addr;
2718 /* Do i need a host2hfa... conversion ? */
2719 result = hfa384x_docmd_wait(hw, cmd_code);
2727 /*----------------------------------------------------------------
2728 * hfa384x_drvr_mmi_write
2730 * Read mmi registers. mmi is intersil-speak for the baseband
2731 * processor registers.
2734 * hw device structure
2735 * addr The test register to be accessed (must be even #).
2736 * data The data value to write to the register.
2740 * >0 f/w reported error - f/w status code
2741 * <0 driver reported error
2747 ----------------------------------------------------------------*/
2750 hfa384x_drvr_mmi_write(hfa384x_t *hw, u32 addr, u32 data)
2754 u16 cmd_code = (u16) 0x31;
2755 u16 param0 = (u16) addr;
2756 u16 param1 = (u16) data;
2759 WLAN_LOG_DEBUG(1,"mmi write : addr = 0x%08lx\n", addr);
2760 WLAN_LOG_DEBUG(1,"mmi write : data = 0x%08lx\n", data);
2762 /* Do i need a host2hfa... conversion ? */
2763 result = hfa384x_docmd_wait(hw, cmd_code);
2772 /*----------------------------------------------------------------
2773 * hfa384x_drvr_ramdl_disable
2775 * Ends the ram download state.
2778 * hw device structure
2782 * >0 f/w reported error - f/w status code
2783 * <0 driver reported error
2789 ----------------------------------------------------------------*/
2791 hfa384x_drvr_ramdl_disable(hfa384x_t *hw)
2794 /* Check that we're already in the download state */
2795 if ( hw->dlstate != HFA384x_DLSTATE_RAMENABLED ) {
2799 WLAN_LOG_DEBUG(3,"ramdl_disable()\n");
2801 /* There isn't much we can do at this point, so I don't */
2802 /* bother w/ the return value */
2803 hfa384x_cmd_download(hw, HFA384x_PROGMODE_DISABLE, 0, 0 , 0);
2804 hw->dlstate = HFA384x_DLSTATE_DISABLED;
2811 /*----------------------------------------------------------------
2812 * hfa384x_drvr_ramdl_enable
2814 * Begins the ram download state. Checks to see that we're not
2815 * already in a download state and that a port isn't enabled.
2816 * Sets the download state and calls cmd_download with the
2817 * ENABLE_VOLATILE subcommand and the exeaddr argument.
2820 * hw device structure
2821 * exeaddr the card execution address that will be
2822 * jumped to when ramdl_disable() is called
2827 * >0 f/w reported error - f/w status code
2828 * <0 driver reported error
2834 ----------------------------------------------------------------*/
2836 hfa384x_drvr_ramdl_enable(hfa384x_t *hw, u32 exeaddr)
2843 /* Check that a port isn't active */
2844 for ( i = 0; i < HFA384x_PORTID_MAX; i++) {
2845 if ( hw->port_enabled[i] ) {
2847 "Can't download with a macport enabled.\n");
2852 /* Check that we're not already in a download state */
2853 if ( hw->dlstate != HFA384x_DLSTATE_DISABLED ) {
2855 "Download state not disabled.\n");
2859 WLAN_LOG_DEBUG(3,"ramdl_enable, exeaddr=0x%08x\n", exeaddr);
2861 /* Call the download(1,addr) function */
2862 lowaddr = HFA384x_ADDR_CMD_MKOFF(exeaddr);
2863 hiaddr = HFA384x_ADDR_CMD_MKPAGE(exeaddr);
2865 result = hfa384x_cmd_download(hw, HFA384x_PROGMODE_RAM,
2866 lowaddr, hiaddr, 0);
2869 /* Set the download state */
2870 hw->dlstate = HFA384x_DLSTATE_RAMENABLED;
2873 "cmd_download(0x%04x, 0x%04x) failed, result=%d.\n",
2884 /*----------------------------------------------------------------
2885 * hfa384x_drvr_ramdl_write
2887 * Performs a RAM download of a chunk of data. First checks to see
2888 * that we're in the RAM download state, then uses the [read|write]mem USB
2889 * commands to 1) copy the data, 2) readback and compare. The download
2890 * state is unaffected. When all data has been written using
2891 * this function, call drvr_ramdl_disable() to end the download state
2892 * and restart the MAC.
2895 * hw device structure
2896 * daddr Card address to write to. (host order)
2897 * buf Ptr to data to write.
2898 * len Length of data (host order).
2902 * >0 f/w reported error - f/w status code
2903 * <0 driver reported error
2909 ----------------------------------------------------------------*/
2911 hfa384x_drvr_ramdl_write(hfa384x_t *hw, u32 daddr, void* buf, u32 len)
2922 /* Check that we're in the ram download state */
2923 if ( hw->dlstate != HFA384x_DLSTATE_RAMENABLED ) {
2927 WLAN_LOG_INFO("Writing %d bytes to ram @0x%06x\n", len, daddr);
2929 /* How many dowmem calls? */
2930 nwrites = len / HFA384x_USB_RWMEM_MAXLEN;
2931 nwrites += len % HFA384x_USB_RWMEM_MAXLEN ? 1 : 0;
2933 /* Do blocking wmem's */
2934 for(i=0; i < nwrites; i++) {
2935 /* make address args */
2936 curraddr = daddr + (i * HFA384x_USB_RWMEM_MAXLEN);
2937 currpage = HFA384x_ADDR_CMD_MKPAGE(curraddr);
2938 curroffset = HFA384x_ADDR_CMD_MKOFF(curraddr);
2939 currlen = len - (i * HFA384x_USB_RWMEM_MAXLEN);
2940 if ( currlen > HFA384x_USB_RWMEM_MAXLEN) {
2941 currlen = HFA384x_USB_RWMEM_MAXLEN;
2944 /* Do blocking ctlx */
2945 result = hfa384x_dowmem_wait( hw,
2948 data + (i*HFA384x_USB_RWMEM_MAXLEN),
2953 /* TODO: We really should have a readback. */
2961 /*----------------------------------------------------------------
2962 * hfa384x_drvr_readpda
2964 * Performs the sequence to read the PDA space. Note there is no
2965 * drvr_writepda() function. Writing a PDA is
2966 * generally implemented by a calling component via calls to
2967 * cmd_download and writing to the flash download buffer via the
2971 * hw device structure
2972 * buf buffer to store PDA in
2977 * >0 f/w reported error - f/w status code
2978 * <0 driver reported error
2979 * -ETIMEOUT timout waiting for the cmd regs to become
2980 * available, or waiting for the control reg
2981 * to indicate the Aux port is enabled.
2982 * -ENODATA the buffer does NOT contain a valid PDA.
2983 * Either the card PDA is bad, or the auxdata
2984 * reads are giving us garbage.
2990 * process or non-card interrupt.
2991 ----------------------------------------------------------------*/
2992 int hfa384x_drvr_readpda(hfa384x_t *hw, void *buf, unsigned int len)
2998 int currpdr = 0; /* word offset of the current pdr */
3000 u16 pdrlen; /* pdr length in bytes, host order */
3001 u16 pdrcode; /* pdr code, host order */
3009 { HFA3842_PDA_BASE, 0},
3010 { HFA3841_PDA_BASE, 0},
3011 { HFA3841_PDA_BOGUS_BASE, 0}
3016 /* Read the pda from each known address. */
3017 for ( i = 0; i < ARRAY_SIZE(pdaloc); i++) {
3019 currpage = HFA384x_ADDR_CMD_MKPAGE(pdaloc[i].cardaddr);
3020 curroffset = HFA384x_ADDR_CMD_MKOFF(pdaloc[i].cardaddr);
3022 result = hfa384x_dormem_wait(hw,
3026 len); /* units of bytes */
3030 "Read from index %zd failed, continuing\n",
3035 /* Test for garbage */
3036 pdaok = 1; /* initially assume good */
3038 while ( pdaok && morepdrs ) {
3039 pdrlen = hfa384x2host_16(pda[currpdr]) * 2;
3040 pdrcode = hfa384x2host_16(pda[currpdr+1]);
3041 /* Test the record length */
3042 if ( pdrlen > HFA384x_PDR_LEN_MAX || pdrlen == 0) {
3043 WLAN_LOG_ERROR("pdrlen invalid=%d\n",
3049 if ( !hfa384x_isgood_pdrcode(pdrcode) ) {
3050 WLAN_LOG_ERROR("pdrcode invalid=%d\n",
3055 /* Test for completion */
3056 if ( pdrcode == HFA384x_PDR_END_OF_PDA) {
3060 /* Move to the next pdr (if necessary) */
3062 /* note the access to pda[], need words here */
3063 currpdr += hfa384x2host_16(pda[currpdr]) + 1;
3068 "PDA Read from 0x%08x in %s space.\n",
3070 pdaloc[i].auxctl == 0 ? "EXTDS" :
3071 pdaloc[i].auxctl == 1 ? "NV" :
3072 pdaloc[i].auxctl == 2 ? "PHY" :
3073 pdaloc[i].auxctl == 3 ? "ICSRAM" :
3078 result = pdaok ? 0 : -ENODATA;
3081 WLAN_LOG_DEBUG(3,"Failure: pda is not okay\n");
3089 /*----------------------------------------------------------------
3090 * hfa384x_drvr_setconfig
3092 * Performs the sequence necessary to write a config/info item.
3095 * hw device structure
3096 * rid config/info record id (in host order)
3097 * buf host side record buffer
3098 * len buffer length (in bytes)
3102 * >0 f/w reported error - f/w status code
3103 * <0 driver reported error
3109 ----------------------------------------------------------------*/
3110 int hfa384x_drvr_setconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len)
3112 return hfa384x_dowrid_wait(hw, rid, buf, len);
3115 /*----------------------------------------------------------------
3116 * hfa384x_drvr_start
3118 * Issues the MAC initialize command, sets up some data structures,
3119 * and enables the interrupts. After this function completes, the
3120 * low-level stuff should be ready for any/all commands.
3123 * hw device structure
3126 * >0 f/w reported error - f/w status code
3127 * <0 driver reported error
3133 ----------------------------------------------------------------*/
3134 int hfa384x_drvr_start(hfa384x_t *hw)
3141 if (usb_clear_halt(hw->usb, hw->endp_in)) {
3143 "Failed to reset bulk in endpoint.\n");
3146 if (usb_clear_halt(hw->usb, hw->endp_out)) {
3148 "Failed to reset bulk out endpoint.\n");
3151 /* Synchronous unlink, in case we're trying to restart the driver */
3152 usb_kill_urb(&hw->rx_urb);
3154 /* Post the IN urb */
3155 result = submit_rx_urb(hw, GFP_KERNEL);
3158 "Fatal, failed to submit RX URB, result=%d\n",
3163 /* call initialize */
3164 result = hfa384x_cmd_initialize(hw);
3166 usb_kill_urb(&hw->rx_urb);
3168 "cmd_initialize() failed, result=%d\n",
3173 hw->state = HFA384x_STATE_RUNNING;
3181 /*----------------------------------------------------------------
3184 * Shuts down the MAC to the point where it is safe to unload the
3185 * driver. Any subsystem that may be holding a data or function
3186 * ptr into the driver must be cleared/deinitialized.
3189 * hw device structure
3192 * >0 f/w reported error - f/w status code
3193 * <0 driver reported error
3199 ----------------------------------------------------------------*/
3201 hfa384x_drvr_stop(hfa384x_t *hw)
3209 /* There's no need for spinlocks here. The USB "disconnect"
3210 * function sets this "removed" flag and then calls us.
3212 if ( !hw->wlandev->hwremoved ) {
3213 /* Call initialize to leave the MAC in its 'reset' state */
3214 hfa384x_cmd_initialize(hw);
3216 /* Cancel the rxurb */
3217 usb_kill_urb(&hw->rx_urb);
3220 hw->link_status = HFA384x_LINK_NOTCONNECTED;
3221 hw->state = HFA384x_STATE_INIT;
3223 del_timer_sync(&hw->commsqual_timer);
3225 /* Clear all the port status */
3226 for ( i = 0; i < HFA384x_NUMPORTS_MAX; i++) {
3227 hw->port_enabled[i] = 0;
3234 /*----------------------------------------------------------------
3235 * hfa384x_drvr_txframe
3237 * Takes a frame from prism2sta and queues it for transmission.
3240 * hw device structure
3241 * skb packet buffer struct. Contains an 802.11
3243 * p80211_hdr points to the 802.11 header for the packet.
3245 * 0 Success and more buffs available
3246 * 1 Success but no more buffs
3247 * 2 Allocation failure
3248 * 4 Buffer full or queue busy
3254 ----------------------------------------------------------------*/
3255 int hfa384x_drvr_txframe(hfa384x_t *hw, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep)
3258 int usbpktlen = sizeof(hfa384x_tx_frame_t);
3265 if (hw->tx_urb.status == -EINPROGRESS) {
3266 WLAN_LOG_WARNING("TX URB already in use\n");
3271 /* Build Tx frame structure */
3272 /* Set up the control field */
3273 memset(&hw->txbuff.txfrm.desc, 0, sizeof(hw->txbuff.txfrm.desc));
3275 /* Setup the usb type field */
3276 hw->txbuff.type = host2hfa384x_16(HFA384x_USB_TXFRM);
3278 /* Set up the sw_support field to identify this frame */
3279 hw->txbuff.txfrm.desc.sw_support = 0x0123;
3281 /* Tx complete and Tx exception disable per dleach. Might be causing
3284 //#define DOEXC SLP -- doboth breaks horribly under load, doexc less so.
3286 hw->txbuff.txfrm.desc.tx_control =
3287 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
3288 HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(1);
3289 #elif defined(DOEXC)
3290 hw->txbuff.txfrm.desc.tx_control =
3291 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
3292 HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(0);
3294 hw->txbuff.txfrm.desc.tx_control =
3295 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
3296 HFA384x_TX_TXEX_SET(0) | HFA384x_TX_TXOK_SET(0);
3298 hw->txbuff.txfrm.desc.tx_control =
3299 host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control);
3301 /* copy the header over to the txdesc */
3302 memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, sizeof(p80211_hdr_t));
3304 /* if we're using host WEP, increase size by IV+ICV */
3305 if (p80211_wep->data) {
3306 hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8);
3307 // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1);
3310 hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len);
3313 usbpktlen += skb->len;
3315 /* copy over the WEP IV if we are using host WEP */
3316 ptr = hw->txbuff.txfrm.data;
3317 if (p80211_wep->data) {
3318 memcpy(ptr, p80211_wep->iv, sizeof(p80211_wep->iv));
3319 ptr+= sizeof(p80211_wep->iv);
3320 memcpy(ptr, p80211_wep->data, skb->len);
3322 memcpy(ptr, skb->data, skb->len);
3324 /* copy over the packet data */
3327 /* copy over the WEP ICV if we are using host WEP */
3328 if (p80211_wep->data) {
3329 memcpy(ptr, p80211_wep->icv, sizeof(p80211_wep->icv));
3332 /* Send the USB packet */
3333 usb_fill_bulk_urb( &(hw->tx_urb), hw->usb,
3335 &(hw->txbuff), ROUNDUP64(usbpktlen),
3336 hfa384x_usbout_callback, hw->wlandev );
3337 hw->tx_urb.transfer_flags |= USB_QUEUE_BULK;
3340 ret = submit_tx_urb(hw, &hw->tx_urb, GFP_ATOMIC);
3343 "submit_tx_urb() failed, error=%d\n", ret);
3352 void hfa384x_tx_timeout(wlandevice_t *wlandev)
3354 hfa384x_t *hw = wlandev->priv;
3355 unsigned long flags;
3359 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3361 if ( !hw->wlandev->hwremoved &&
3362 /* Note the bitwise OR, not the logical OR. */
3363 ( !test_and_set_bit(WORK_TX_HALT, &hw->usb_flags) |
3364 !test_and_set_bit(WORK_RX_HALT, &hw->usb_flags) ) )
3366 schedule_work(&hw->usb_work);
3369 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3374 /*----------------------------------------------------------------
3375 * hfa384x_usbctlx_reaper_task
3377 * Tasklet to delete dead CTLX objects
3380 * data ptr to a hfa384x_t
3386 ----------------------------------------------------------------*/
3387 static void hfa384x_usbctlx_reaper_task(unsigned long data)
3389 hfa384x_t *hw = (hfa384x_t*)data;
3390 struct list_head *entry;
3391 struct list_head *temp;
3392 unsigned long flags;
3396 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3398 /* This list is guaranteed to be empty if someone
3399 * has unplugged the adapter.
3401 list_for_each_safe(entry, temp, &hw->ctlxq.reapable) {
3402 hfa384x_usbctlx_t *ctlx;
3404 ctlx = list_entry(entry, hfa384x_usbctlx_t, list);
3405 list_del(&ctlx->list);
3409 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3414 /*----------------------------------------------------------------
3415 * hfa384x_usbctlx_completion_task
3417 * Tasklet to call completion handlers for returned CTLXs
3420 * data ptr to hfa384x_t
3427 ----------------------------------------------------------------*/
3428 static void hfa384x_usbctlx_completion_task(unsigned long data)
3430 hfa384x_t *hw = (hfa384x_t*)data;
3431 struct list_head *entry;
3432 struct list_head *temp;
3433 unsigned long flags;
3439 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3441 /* This list is guaranteed to be empty if someone
3442 * has unplugged the adapter ...
3444 list_for_each_safe(entry, temp, &hw->ctlxq.completing) {
3445 hfa384x_usbctlx_t *ctlx;
3447 ctlx = list_entry(entry, hfa384x_usbctlx_t, list);
3449 /* Call the completion function that this
3450 * command was assigned, assuming it has one.
3452 if ( ctlx->cmdcb != NULL ) {
3453 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3454 ctlx->cmdcb(hw, ctlx);
3455 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3457 /* Make sure we don't try and complete
3458 * this CTLX more than once!
3462 /* Did someone yank the adapter out
3463 * while our list was (briefly) unlocked?
3465 if ( hw->wlandev->hwremoved )
3473 * "Reapable" CTLXs are ones which don't have any
3474 * threads waiting for them to die. Hence they must
3475 * be delivered to The Reaper!
3477 if ( ctlx->reapable ) {
3478 /* Move the CTLX off the "completing" list (hopefully)
3479 * on to the "reapable" list where the reaper task
3480 * can find it. And "reapable" means that this CTLX
3481 * isn't sitting on a wait-queue somewhere.
3483 list_move_tail(&ctlx->list, &hw->ctlxq.reapable);
3487 complete(&ctlx->done);
3489 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3492 tasklet_schedule(&hw->reaper_bh);
3497 /*----------------------------------------------------------------
3498 * unlocked_usbctlx_cancel_async
3500 * Mark the CTLX dead asynchronously, and ensure that the
3501 * next command on the queue is run afterwards.
3504 * hw ptr to the hfa384x_t structure
3505 * ctlx ptr to a CTLX structure
3508 * 0 the CTLX's URB is inactive
3509 * -EINPROGRESS the URB is currently being unlinked
3512 * Either process or interrupt, but presumably interrupt
3513 ----------------------------------------------------------------*/
3514 static int unlocked_usbctlx_cancel_async(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx)
3521 * Try to delete the URB containing our request packet.
3522 * If we succeed, then its completion handler will be
3523 * called with a status of -ECONNRESET.
3525 hw->ctlx_urb.transfer_flags |= URB_ASYNC_UNLINK;
3526 ret = usb_unlink_urb(&hw->ctlx_urb);
3528 if (ret != -EINPROGRESS) {
3530 * The OUT URB had either already completed
3531 * or was still in the pending queue, so the
3532 * URB's completion function will not be called.
3533 * We will have to complete the CTLX ourselves.
3535 ctlx->state = CTLX_REQ_FAILED;
3536 unlocked_usbctlx_complete(hw, ctlx);
3545 /*----------------------------------------------------------------
3546 * unlocked_usbctlx_complete
3548 * A CTLX has completed. It may have been successful, it may not
3549 * have been. At this point, the CTLX should be quiescent. The URBs
3550 * aren't active and the timers should have been stopped.
3552 * The CTLX is migrated to the "completing" queue, and the completing
3553 * tasklet is scheduled.
3556 * hw ptr to a hfa384x_t structure
3557 * ctlx ptr to a ctlx structure
3565 * Either, assume interrupt
3566 ----------------------------------------------------------------*/
3567 static void unlocked_usbctlx_complete(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx)
3571 /* Timers have been stopped, and ctlx should be in
3572 * a terminal state. Retire it from the "active"
3575 list_move_tail(&ctlx->list, &hw->ctlxq.completing);
3576 tasklet_schedule(&hw->completion_bh);
3578 switch (ctlx->state) {
3580 case CTLX_REQ_FAILED:
3581 /* This are the correct terminating states. */
3585 WLAN_LOG_ERROR("CTLX[%d] not in a terminating state(%s)\n",
3586 hfa384x2host_16(ctlx->outbuf.type),
3587 ctlxstr(ctlx->state));
3594 /*----------------------------------------------------------------
3595 * hfa384x_usbctlxq_run
3597 * Checks to see if the head item is running. If not, starts it.
3600 * hw ptr to hfa384x_t
3609 ----------------------------------------------------------------*/
3611 hfa384x_usbctlxq_run(hfa384x_t *hw)
3613 unsigned long flags;
3617 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3619 /* Only one active CTLX at any one time, because there's no
3620 * other (reliable) way to match the response URB to the
3623 * Don't touch any of these CTLXs if the hardware
3624 * has been removed or the USB subsystem is stalled.
3626 if ( !list_empty(&hw->ctlxq.active) ||
3627 test_bit(WORK_TX_HALT, &hw->usb_flags) ||
3628 hw->wlandev->hwremoved )
3631 while ( !list_empty(&hw->ctlxq.pending) ) {
3632 hfa384x_usbctlx_t *head;
3635 /* This is the first pending command */
3636 head = list_entry(hw->ctlxq.pending.next,
3640 /* We need to split this off to avoid a race condition */
3641 list_move_tail(&head->list, &hw->ctlxq.active);
3643 /* Fill the out packet */
3644 usb_fill_bulk_urb( &(hw->ctlx_urb), hw->usb,
3646 &(head->outbuf), ROUNDUP64(head->outbufsize),
3647 hfa384x_ctlxout_callback, hw);
3648 hw->ctlx_urb.transfer_flags |= USB_QUEUE_BULK;
3650 /* Now submit the URB and update the CTLX's state
3652 if ((result = SUBMIT_URB(&hw->ctlx_urb, GFP_ATOMIC)) == 0) {
3653 /* This CTLX is now running on the active queue */
3654 head->state = CTLX_REQ_SUBMITTED;
3656 /* Start the OUT wait timer */
3657 hw->req_timer_done = 0;
3658 hw->reqtimer.expires = jiffies + HZ;
3659 add_timer(&hw->reqtimer);
3661 /* Start the IN wait timer */
3662 hw->resp_timer_done = 0;
3663 hw->resptimer.expires = jiffies + 2*HZ;
3664 add_timer(&hw->resptimer);
3669 if (result == -EPIPE) {
3670 /* The OUT pipe needs resetting, so put
3671 * this CTLX back in the "pending" queue
3672 * and schedule a reset ...
3674 WLAN_LOG_WARNING("%s tx pipe stalled: requesting reset\n",
3675 hw->wlandev->netdev->name);
3676 list_move(&head->list, &hw->ctlxq.pending);
3677 set_bit(WORK_TX_HALT, &hw->usb_flags);
3678 schedule_work(&hw->usb_work);
3682 if (result == -ESHUTDOWN) {
3683 WLAN_LOG_WARNING("%s urb shutdown!\n",
3684 hw->wlandev->netdev->name);
3688 WLAN_LOG_ERROR("Failed to submit CTLX[%d]: error=%d\n",
3689 hfa384x2host_16(head->outbuf.type), result);
3690 unlocked_usbctlx_complete(hw, head);
3694 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3700 /*----------------------------------------------------------------
3701 * hfa384x_usbin_callback
3703 * Callback for URBs on the BULKIN endpoint.
3706 * urb ptr to the completed urb
3715 ----------------------------------------------------------------*/
3716 static void hfa384x_usbin_callback(struct urb *urb)
3718 wlandevice_t *wlandev = urb->context;
3720 hfa384x_usbin_t *usbin = (hfa384x_usbin_t *) urb->transfer_buffer;
3721 struct sk_buff *skb = NULL;
3736 !netif_device_present(wlandev->netdev) )
3743 skb = hw->rx_urb_skb;
3744 if (!skb || (skb->data != urb->transfer_buffer)) {
3747 hw->rx_urb_skb = NULL;
3749 /* Check for error conditions within the URB */
3750 switch (urb->status) {
3754 /* Check for short packet */
3755 if ( urb->actual_length == 0 ) {
3756 ++(wlandev->linux_stats.rx_errors);
3757 ++(wlandev->linux_stats.rx_length_errors);
3763 WLAN_LOG_WARNING("%s rx pipe stalled: requesting reset\n",
3764 wlandev->netdev->name);
3765 if ( !test_and_set_bit(WORK_RX_HALT, &hw->usb_flags) )
3766 schedule_work(&hw->usb_work);
3767 ++(wlandev->linux_stats.rx_errors);
3774 if ( !test_and_set_bit(THROTTLE_RX, &hw->usb_flags) &&
3775 !timer_pending(&hw->throttle) ) {
3776 mod_timer(&hw->throttle, jiffies + THROTTLE_JIFFIES);
3778 ++(wlandev->linux_stats.rx_errors);
3783 ++(wlandev->linux_stats.rx_over_errors);
3789 WLAN_LOG_DEBUG(3,"status=%d, device removed.\n", urb->status);
3795 WLAN_LOG_DEBUG(3,"status=%d, urb explicitly unlinked.\n", urb->status);
3800 WLAN_LOG_DEBUG(3,"urb status=%d, transfer flags=0x%x\n",
3801 urb->status, urb->transfer_flags);
3802 ++(wlandev->linux_stats.rx_errors);
3807 urb_status = urb->status;
3809 if (action != ABORT) {
3810 /* Repost the RX URB */
3811 result = submit_rx_urb(hw, GFP_ATOMIC);
3815 "Fatal, failed to resubmit rx_urb. error=%d\n",
3820 /* Handle any USB-IN packet */
3821 /* Note: the check of the sw_support field, the type field doesn't
3822 * have bit 12 set like the docs suggest.
3824 type = hfa384x2host_16(usbin->type);
3825 if (HFA384x_USB_ISRXFRM(type)) {
3826 if (action == HANDLE) {
3827 if (usbin->txfrm.desc.sw_support == 0x0123) {
3828 hfa384x_usbin_txcompl(wlandev, usbin);
3830 skb_put(skb, sizeof(*usbin));
3831 hfa384x_usbin_rx(wlandev, skb);
3837 if (HFA384x_USB_ISTXFRM(type)) {
3838 if (action == HANDLE)
3839 hfa384x_usbin_txcompl(wlandev, usbin);
3843 case HFA384x_USB_INFOFRM:
3844 if (action == ABORT)
3846 if (action == HANDLE)
3847 hfa384x_usbin_info(wlandev, usbin);
3850 case HFA384x_USB_CMDRESP:
3851 case HFA384x_USB_WRIDRESP:
3852 case HFA384x_USB_RRIDRESP:
3853 case HFA384x_USB_WMEMRESP:
3854 case HFA384x_USB_RMEMRESP:
3855 /* ALWAYS, ALWAYS, ALWAYS handle this CTLX!!!! */
3856 hfa384x_usbin_ctlx(hw, usbin, urb_status);
3859 case HFA384x_USB_BUFAVAIL:
3860 WLAN_LOG_DEBUG(3,"Received BUFAVAIL packet, frmlen=%d\n",
3861 usbin->bufavail.frmlen);
3864 case HFA384x_USB_ERROR:
3865 WLAN_LOG_DEBUG(3,"Received USB_ERROR packet, errortype=%d\n",
3866 usbin->usberror.errortype);
3870 WLAN_LOG_DEBUG(3,"Unrecognized USBIN packet, type=%x, status=%d\n",
3871 usbin->type, urb_status);
3884 /*----------------------------------------------------------------
3885 * hfa384x_usbin_ctlx
3887 * We've received a URB containing a Prism2 "response" message.
3888 * This message needs to be matched up with a CTLX on the active
3889 * queue and our state updated accordingly.
3892 * hw ptr to hfa384x_t
3893 * usbin ptr to USB IN packet
3894 * urb_status status of this Bulk-In URB
3903 ----------------------------------------------------------------*/
3904 static void hfa384x_usbin_ctlx(hfa384x_t *hw, hfa384x_usbin_t *usbin,
3907 hfa384x_usbctlx_t *ctlx;
3909 unsigned long flags;
3914 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3916 /* There can be only one CTLX on the active queue
3917 * at any one time, and this is the CTLX that the
3918 * timers are waiting for.
3920 if ( list_empty(&hw->ctlxq.active) ) {
3924 /* Remove the "response timeout". It's possible that
3925 * we are already too late, and that the timeout is
3926 * already running. And that's just too bad for us,
3927 * because we could lose our CTLX from the active
3930 if (del_timer(&hw->resptimer) == 0) {
3931 if (hw->resp_timer_done == 0) {
3932 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3937 hw->resp_timer_done = 1;
3940 ctlx = get_active_ctlx(hw);
3942 if (urb_status != 0) {
3944 * Bad CTLX, so get rid of it. But we only
3945 * remove it from the active queue if we're no
3946 * longer expecting the OUT URB to complete.
3948 if (unlocked_usbctlx_cancel_async(hw, ctlx) == 0)
3951 const u16 intype = (usbin->type&~host2hfa384x_16(0x8000));
3954 * Check that our message is what we're expecting ...
3956 if (ctlx->outbuf.type != intype) {
3957 WLAN_LOG_WARNING("Expected IN[%d], received IN[%d] - ignored.\n",
3958 hfa384x2host_16(ctlx->outbuf.type),
3959 hfa384x2host_16(intype));
3963 /* This URB has succeeded, so grab the data ... */
3964 memcpy(&ctlx->inbuf, usbin, sizeof(ctlx->inbuf));
3966 switch (ctlx->state) {
3967 case CTLX_REQ_SUBMITTED:
3969 * We have received our response URB before
3970 * our request has been acknowledged. Odd,
3971 * but our OUT URB is still alive...
3973 WLAN_LOG_DEBUG(0, "Causality violation: please reboot Universe, or email linux-wlan-devel@lists.linux-wlan.com\n");
3974 ctlx->state = CTLX_RESP_COMPLETE;
3977 case CTLX_REQ_COMPLETE:
3979 * This is the usual path: our request
3980 * has already been acknowledged, and
3981 * now we have received the reply too.
3983 ctlx->state = CTLX_COMPLETE;
3984 unlocked_usbctlx_complete(hw, ctlx);
3990 * Throw this CTLX away ...
3992 WLAN_LOG_ERROR("Matched IN URB, CTLX[%d] in invalid state(%s)."
3994 hfa384x2host_16(ctlx->outbuf.type),
3995 ctlxstr(ctlx->state));
3996 if (unlocked_usbctlx_cancel_async(hw, ctlx) == 0)
4003 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
4006 hfa384x_usbctlxq_run(hw);
4012 /*----------------------------------------------------------------
4013 * hfa384x_usbin_txcompl
4015 * At this point we have the results of a previous transmit.
4018 * wlandev wlan device
4019 * usbin ptr to the usb transfer buffer
4028 ----------------------------------------------------------------*/
4029 static void hfa384x_usbin_txcompl(wlandevice_t *wlandev, hfa384x_usbin_t *usbin)
4034 status = hfa384x2host_16(usbin->type); /* yeah I know it says type...*/
4036 /* Was there an error? */
4037 if (HFA384x_TXSTATUS_ISERROR(status)) {
4038 prism2sta_ev_txexc(wlandev, status);
4040 prism2sta_ev_tx(wlandev, status);
4042 // prism2sta_ev_alloc(wlandev);
4048 /*----------------------------------------------------------------
4051 * At this point we have a successful received a rx frame packet.
4054 * wlandev wlan device
4055 * usbin ptr to the usb transfer buffer
4064 ----------------------------------------------------------------*/
4065 static void hfa384x_usbin_rx(wlandevice_t *wlandev, struct sk_buff *skb)
4067 hfa384x_usbin_t *usbin = (hfa384x_usbin_t *) skb->data;
4068 hfa384x_t *hw = wlandev->priv;
4070 p80211_rxmeta_t *rxmeta;
4076 /* Byte order convert once up front. */
4077 usbin->rxfrm.desc.status =
4078 hfa384x2host_16(usbin->rxfrm.desc.status);
4079 usbin->rxfrm.desc.time =
4080 hfa384x2host_32(usbin->rxfrm.desc.time);
4082 /* Now handle frame based on port# */
4083 switch( HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status) )
4086 fc = ieee2host16(usbin->rxfrm.desc.frame_control);
4088 /* If exclude and we receive an unencrypted, drop it */
4089 if ( (wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED) &&
4090 !WLAN_GET_FC_ISWEP(fc)){
4094 data_len = hfa384x2host_16(usbin->rxfrm.desc.data_len);
4096 /* How much header data do we have? */
4097 hdrlen = p80211_headerlen(fc);
4099 /* Pull off the descriptor */
4100 skb_pull(skb, sizeof(hfa384x_rx_frame_t));
4102 /* Now shunt the header block up against the data block
4103 * with an "overlapping" copy
4105 memmove(skb_push(skb, hdrlen),
4106 &usbin->rxfrm.desc.frame_control,
4109 skb->dev = wlandev->netdev;
4110 skb->dev->last_rx = jiffies;
4112 /* And set the frame length properly */
4113 skb_trim(skb, data_len + hdrlen);
4115 /* The prism2 series does not return the CRC */
4116 memset(skb_put(skb, WLAN_CRC_LEN), 0xff, WLAN_CRC_LEN);
4118 skb_reset_mac_header(skb);
4120 /* Attach the rxmeta, set some stuff */
4121 p80211skb_rxmeta_attach(wlandev, skb);
4122 rxmeta = P80211SKB_RXMETA(skb);
4123 rxmeta->mactime = usbin->rxfrm.desc.time;
4124 rxmeta->rxrate = usbin->rxfrm.desc.rate;
4125 rxmeta->signal = usbin->rxfrm.desc.signal - hw->dbmadjust;
4126 rxmeta->noise = usbin->rxfrm.desc.silence - hw->dbmadjust;
4128 prism2sta_ev_rx(wlandev, skb);
4133 if ( ! HFA384x_RXSTATUS_ISFCSERR(usbin->rxfrm.desc.status) ) {
4134 /* Copy to wlansnif skb */
4135 hfa384x_int_rxmonitor( wlandev, &usbin->rxfrm);
4138 WLAN_LOG_DEBUG(3,"Received monitor frame: FCSerr set\n");
4143 WLAN_LOG_WARNING("Received frame on unsupported port=%d\n",
4144 HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status) );
4154 /*----------------------------------------------------------------
4155 * hfa384x_int_rxmonitor
4157 * Helper function for int_rx. Handles monitor frames.
4158 * Note that this function allocates space for the FCS and sets it
4159 * to 0xffffffff. The hfa384x doesn't give us the FCS value but the
4160 * higher layers expect it. 0xffffffff is used as a flag to indicate
4164 * wlandev wlan device structure
4165 * rxfrm rx descriptor read from card in int_rx
4171 * Allocates an skb and passes it up via the PF_PACKET interface.
4174 ----------------------------------------------------------------*/
4175 static void hfa384x_int_rxmonitor( wlandevice_t *wlandev, hfa384x_usb_rxfrm_t *rxfrm)
4177 hfa384x_rx_frame_t *rxdesc = &(rxfrm->desc);
4178 unsigned int hdrlen = 0;
4179 unsigned int datalen = 0;
4180 unsigned int skblen = 0;
4181 p80211msg_lnxind_wlansniffrm_t *msg;
4184 struct sk_buff *skb;
4185 hfa384x_t *hw = wlandev->priv;
4189 /* Don't forget the status, time, and data_len fields are in host order */
4190 /* Figure out how big the frame is */
4191 fc = ieee2host16(rxdesc->frame_control);
4192 hdrlen = p80211_headerlen(fc);
4193 datalen = hfa384x2host_16(rxdesc->data_len);
4195 /* Allocate an ind message+framesize skb */
4196 skblen = sizeof(p80211msg_lnxind_wlansniffrm_t) +
4197 hdrlen + datalen + WLAN_CRC_LEN;
4199 /* sanity check the length */
4201 (sizeof(p80211msg_lnxind_wlansniffrm_t) +
4202 WLAN_HDR_A4_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN) ) {
4203 WLAN_LOG_DEBUG(1, "overlen frm: len=%zd\n",
4204 skblen - sizeof(p80211msg_lnxind_wlansniffrm_t));
4207 if ( (skb = dev_alloc_skb(skblen)) == NULL ) {
4208 WLAN_LOG_ERROR("alloc_skb failed trying to allocate %d bytes\n", skblen);
4212 /* only prepend the prism header if in the right mode */
4213 if ((wlandev->netdev->type == ARPHRD_IEEE80211_PRISM) &&
4214 (hw->sniffhdr == 0)) {
4215 datap = skb_put(skb, sizeof(p80211msg_lnxind_wlansniffrm_t));
4216 msg = (p80211msg_lnxind_wlansniffrm_t*) datap;
4218 /* Initialize the message members */
4219 msg->msgcode = DIDmsg_lnxind_wlansniffrm;
4220 msg->msglen = sizeof(p80211msg_lnxind_wlansniffrm_t);
4221 strcpy(msg->devname, wlandev->name);
4223 msg->hosttime.did = DIDmsg_lnxind_wlansniffrm_hosttime;
4224 msg->hosttime.status = 0;
4225 msg->hosttime.len = 4;
4226 msg->hosttime.data = jiffies;
4228 msg->mactime.did = DIDmsg_lnxind_wlansniffrm_mactime;
4229 msg->mactime.status = 0;
4230 msg->mactime.len = 4;
4231 msg->mactime.data = rxdesc->time;
4233 msg->channel.did = DIDmsg_lnxind_wlansniffrm_channel;
4234 msg->channel.status = 0;
4235 msg->channel.len = 4;
4236 msg->channel.data = hw->sniff_channel;
4238 msg->rssi.did = DIDmsg_lnxind_wlansniffrm_rssi;
4239 msg->rssi.status = P80211ENUM_msgitem_status_no_value;
4243 msg->sq.did = DIDmsg_lnxind_wlansniffrm_sq;
4244 msg->sq.status = P80211ENUM_msgitem_status_no_value;
4248 msg->signal.did = DIDmsg_lnxind_wlansniffrm_signal;
4249 msg->signal.status = 0;
4250 msg->signal.len = 4;
4251 msg->signal.data = rxdesc->signal;
4253 msg->noise.did = DIDmsg_lnxind_wlansniffrm_noise;
4254 msg->noise.status = 0;
4256 msg->noise.data = rxdesc->silence;
4258 msg->rate.did = DIDmsg_lnxind_wlansniffrm_rate;
4259 msg->rate.status = 0;
4261 msg->rate.data = rxdesc->rate / 5; /* set to 802.11 units */
4263 msg->istx.did = DIDmsg_lnxind_wlansniffrm_istx;
4264 msg->istx.status = 0;
4266 msg->istx.data = P80211ENUM_truth_false;
4268 msg->frmlen.did = DIDmsg_lnxind_wlansniffrm_frmlen;
4269 msg->frmlen.status = 0;
4270 msg->frmlen.len = 4;
4271 msg->frmlen.data = hdrlen + datalen + WLAN_CRC_LEN;
4272 } else if ((wlandev->netdev->type == ARPHRD_IEEE80211_PRISM) &&
4273 (hw->sniffhdr != 0)) {
4274 p80211_caphdr_t *caphdr;
4275 /* The NEW header format! */
4276 datap = skb_put(skb, sizeof(p80211_caphdr_t));
4277 caphdr = (p80211_caphdr_t*) datap;
4279 caphdr->version = htonl(P80211CAPTURE_VERSION);
4280 caphdr->length = htonl(sizeof(p80211_caphdr_t));
4281 caphdr->mactime = __cpu_to_be64(rxdesc->time) * 1000;
4282 caphdr->hosttime = __cpu_to_be64(jiffies);
4283 caphdr->phytype = htonl(4); /* dss_dot11_b */
4284 caphdr->channel = htonl(hw->sniff_channel);
4285 caphdr->datarate = htonl(rxdesc->rate);
4286 caphdr->antenna = htonl(0); /* unknown */
4287 caphdr->priority = htonl(0); /* unknown */
4288 caphdr->ssi_type = htonl(3); /* rssi_raw */
4289 caphdr->ssi_signal = htonl(rxdesc->signal);
4290 caphdr->ssi_noise = htonl(rxdesc->silence);
4291 caphdr->preamble = htonl(0); /* unknown */
4292 caphdr->encoding = htonl(1); /* cck */
4295 /* Copy the 802.11 header to the skb (ctl frames may be less than a full header) */
4296 datap = skb_put(skb, hdrlen);
4297 memcpy( datap, &(rxdesc->frame_control), hdrlen);
4299 /* If any, copy the data from the card to the skb */
4302 datap = skb_put(skb, datalen);
4303 memcpy(datap, rxfrm->data, datalen);
4305 /* check for unencrypted stuff if WEP bit set. */
4306 if (*(datap - hdrlen + 1) & 0x40) // wep set
4307 if ((*(datap) == 0xaa) && (*(datap+1) == 0xaa))
4308 *(datap - hdrlen + 1) &= 0xbf; // clear wep; it's the 802.2 header!
4311 if (hw->sniff_fcs) {
4313 datap = skb_put(skb, WLAN_CRC_LEN);
4314 memset( datap, 0xff, WLAN_CRC_LEN);
4317 /* pass it back up */
4318 prism2sta_ev_rx(wlandev, skb);
4326 /*----------------------------------------------------------------
4327 * hfa384x_usbin_info
4329 * At this point we have a successful received a Prism2 info frame.
4332 * wlandev wlan device
4333 * usbin ptr to the usb transfer buffer
4342 ----------------------------------------------------------------*/
4343 static void hfa384x_usbin_info(wlandevice_t *wlandev, hfa384x_usbin_t *usbin)
4347 usbin->infofrm.info.framelen = hfa384x2host_16(usbin->infofrm.info.framelen);
4348 prism2sta_ev_info(wlandev, &usbin->infofrm.info);
4355 /*----------------------------------------------------------------
4356 * hfa384x_usbout_callback
4358 * Callback for URBs on the BULKOUT endpoint.
4361 * urb ptr to the completed urb
4370 ----------------------------------------------------------------*/
4371 static void hfa384x_usbout_callback(struct urb *urb)
4373 wlandevice_t *wlandev = urb->context;
4374 hfa384x_usbout_t *usbout = urb->transfer_buffer;
4384 switch(urb->status) {
4386 hfa384x_usbout_tx(wlandev, usbout);
4391 hfa384x_t *hw = wlandev->priv;
4392 WLAN_LOG_WARNING("%s tx pipe stalled: requesting reset\n",
4393 wlandev->netdev->name);
4394 if ( !test_and_set_bit(WORK_TX_HALT, &hw->usb_flags) )
4395 schedule_work(&hw->usb_work);
4396 ++(wlandev->linux_stats.tx_errors);
4404 hfa384x_t *hw = wlandev->priv;
4406 if ( !test_and_set_bit(THROTTLE_TX, &hw->usb_flags)
4407 && !timer_pending(&hw->throttle) ) {
4408 mod_timer(&hw->throttle,
4409 jiffies + THROTTLE_JIFFIES);
4411 ++(wlandev->linux_stats.tx_errors);
4412 netif_stop_queue(wlandev->netdev);
4418 /* Ignorable errors */
4422 WLAN_LOG_INFO("unknown urb->status=%d\n", urb->status);
4423 ++(wlandev->linux_stats.tx_errors);
4432 /*----------------------------------------------------------------
4433 * hfa384x_ctlxout_callback
4435 * Callback for control data on the BULKOUT endpoint.
4438 * urb ptr to the completed urb
4447 ----------------------------------------------------------------*/
4448 static void hfa384x_ctlxout_callback(struct urb *urb)
4450 hfa384x_t *hw = urb->context;
4451 int delete_resptimer = 0;
4454 hfa384x_usbctlx_t *ctlx;
4455 unsigned long flags;
4459 WLAN_LOG_DEBUG(3,"urb->status=%d\n", urb->status);
4463 if ( (urb->status == -ESHUTDOWN) ||
4464 (urb->status == -ENODEV) ||
4469 spin_lock_irqsave(&hw->ctlxq.lock, flags);
4472 * Only one CTLX at a time on the "active" list, and
4473 * none at all if we are unplugged. However, we can
4474 * rely on the disconnect function to clean everything
4475 * up if someone unplugged the adapter.
4477 if ( list_empty(&hw->ctlxq.active) ) {
4478 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
4483 * Having something on the "active" queue means
4484 * that we have timers to worry about ...
4486 if (del_timer(&hw->reqtimer) == 0) {
4487 if (hw->req_timer_done == 0) {
4489 * This timer was actually running while we
4490 * were trying to delete it. Let it terminate
4491 * gracefully instead.
4493 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
4498 hw->req_timer_done = 1;
4501 ctlx = get_active_ctlx(hw);
4503 if ( urb->status == 0 ) {
4504 /* Request portion of a CTLX is successful */
4505 switch ( ctlx->state ) {
4506 case CTLX_REQ_SUBMITTED:
4507 /* This OUT-ACK received before IN */
4508 ctlx->state = CTLX_REQ_COMPLETE;
4511 case CTLX_RESP_COMPLETE:
4512 /* IN already received before this OUT-ACK,
4513 * so this command must now be complete.
4515 ctlx->state = CTLX_COMPLETE;
4516 unlocked_usbctlx_complete(hw, ctlx);
4521 /* This is NOT a valid CTLX "success" state! */
4523 "Illegal CTLX[%d] success state(%s, %d) in OUT URB\n",
4524 hfa384x2host_16(ctlx->outbuf.type),
4525 ctlxstr(ctlx->state), urb->status);
4529 /* If the pipe has stalled then we need to reset it */
4530 if ( (urb->status == -EPIPE) &&
4531 !test_and_set_bit(WORK_TX_HALT, &hw->usb_flags) ) {
4532 WLAN_LOG_WARNING("%s tx pipe stalled: requesting reset\n",
4533 hw->wlandev->netdev->name);
4534 schedule_work(&hw->usb_work);
4537 /* If someone cancels the OUT URB then its status
4538 * should be either -ECONNRESET or -ENOENT.
4540 ctlx->state = CTLX_REQ_FAILED;
4541 unlocked_usbctlx_complete(hw, ctlx);
4542 delete_resptimer = 1;
4547 if (delete_resptimer) {
4548 if ((timer_ok = del_timer(&hw->resptimer)) != 0) {
4549 hw->resp_timer_done = 1;
4553 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
4555 if ( !timer_ok && (hw->resp_timer_done == 0) ) {
4556 spin_lock_irqsave(&hw->ctlxq.lock, flags);
4561 hfa384x_usbctlxq_run(hw);
4568 /*----------------------------------------------------------------
4569 * hfa384x_usbctlx_reqtimerfn
4571 * Timer response function for CTLX request timeouts. If this
4572 * function is called, it means that the callback for the OUT
4573 * URB containing a Prism2.x XXX_Request was never called.
4576 * data a ptr to the hfa384x_t
4585 ----------------------------------------------------------------*/
4587 hfa384x_usbctlx_reqtimerfn(unsigned long data)
4589 hfa384x_t *hw = (hfa384x_t*)data;
4590 unsigned long flags;
4593 spin_lock_irqsave(&hw->ctlxq.lock, flags);
4595 hw->req_timer_done = 1;
4597 /* Removing the hardware automatically empties
4598 * the active list ...
4600 if ( !list_empty(&hw->ctlxq.active) )
4603 * We must ensure that our URB is removed from
4604 * the system, if it hasn't already expired.
4606 hw->ctlx_urb.transfer_flags |= URB_ASYNC_UNLINK;
4607 if (usb_unlink_urb(&hw->ctlx_urb) == -EINPROGRESS)
4609 hfa384x_usbctlx_t *ctlx = get_active_ctlx(hw);
4611 ctlx->state = CTLX_REQ_FAILED;
4613 /* This URB was active, but has now been
4614 * cancelled. It will now have a status of
4615 * -ECONNRESET in the callback function.
4617 * We are cancelling this CTLX, so we're
4618 * not going to need to wait for a response.
4619 * The URB's callback function will check
4620 * that this timer is truly dead.
4622 if (del_timer(&hw->resptimer) != 0)
4623 hw->resp_timer_done = 1;
4627 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
4633 /*----------------------------------------------------------------
4634 * hfa384x_usbctlx_resptimerfn
4636 * Timer response function for CTLX response timeouts. If this
4637 * function is called, it means that the callback for the IN
4638 * URB containing a Prism2.x XXX_Response was never called.
4641 * data a ptr to the hfa384x_t
4650 ----------------------------------------------------------------*/
4652 hfa384x_usbctlx_resptimerfn(unsigned long data)
4654 hfa384x_t *hw = (hfa384x_t*)data;
4655 unsigned long flags;
4659 spin_lock_irqsave(&hw->ctlxq.lock, flags);
4661 hw->resp_timer_done = 1;
4663 /* The active list will be empty if the
4664 * adapter has been unplugged ...
4666 if ( !list_empty(&hw->ctlxq.active) )
4668 hfa384x_usbctlx_t *ctlx = get_active_ctlx(hw);
4670 if ( unlocked_usbctlx_cancel_async(hw, ctlx) == 0 )
4672 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
4673 hfa384x_usbctlxq_run(hw);
4678 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
4684 /*----------------------------------------------------------------
4685 * hfa384x_usb_throttlefn
4698 ----------------------------------------------------------------*/
4700 hfa384x_usb_throttlefn(unsigned long data)
4702 hfa384x_t *hw = (hfa384x_t*)data;
4703 unsigned long flags;
4707 spin_lock_irqsave(&hw->ctlxq.lock, flags);
4710 * We need to check BOTH the RX and the TX throttle controls,
4711 * so we use the bitwise OR instead of the logical OR.
4713 WLAN_LOG_DEBUG(3, "flags=0x%lx\n", hw->usb_flags);
4714 if ( !hw->wlandev->hwremoved &&
4716 (test_and_clear_bit(THROTTLE_RX, &hw->usb_flags) &&
4717 !test_and_set_bit(WORK_RX_RESUME, &hw->usb_flags))
4719 (test_and_clear_bit(THROTTLE_TX, &hw->usb_flags) &&
4720 !test_and_set_bit(WORK_TX_RESUME, &hw->usb_flags))
4723 schedule_work(&hw->usb_work);
4726 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
4732 /*----------------------------------------------------------------
4733 * hfa384x_usbctlx_submit
4735 * Called from the doxxx functions to submit a CTLX to the queue
4738 * hw ptr to the hw struct
4739 * ctlx ctlx structure to enqueue
4742 * -ENODEV if the adapter is unplugged
4748 * process or interrupt
4749 ----------------------------------------------------------------*/
4751 hfa384x_usbctlx_submit(
4753 hfa384x_usbctlx_t *ctlx)
4755 unsigned long flags;
4760 spin_lock_irqsave(&hw->ctlxq.lock, flags);
4762 if (hw->wlandev->hwremoved) {
4763 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
4766 ctlx->state = CTLX_PENDING;
4767 list_add_tail(&ctlx->list, &hw->ctlxq.pending);
4769 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
4770 hfa384x_usbctlxq_run(hw);
4779 /*----------------------------------------------------------------
4782 * At this point we have finished a send of a frame. Mark the URB
4783 * as available and call ev_alloc to notify higher layers we're
4787 * wlandev wlan device
4788 * usbout ptr to the usb transfer buffer
4797 ----------------------------------------------------------------*/
4798 static void hfa384x_usbout_tx(wlandevice_t *wlandev, hfa384x_usbout_t *usbout)
4802 prism2sta_ev_alloc(wlandev);
4807 /*----------------------------------------------------------------
4808 * hfa384x_isgood_pdrcore
4810 * Quick check of PDR codes.
4813 * pdrcode PDR code number (host order)
4822 ----------------------------------------------------------------*/
4824 hfa384x_isgood_pdrcode(u16 pdrcode)
4827 case HFA384x_PDR_END_OF_PDA:
4828 case HFA384x_PDR_PCB_PARTNUM:
4829 case HFA384x_PDR_PDAVER:
4830 case HFA384x_PDR_NIC_SERIAL:
4831 case HFA384x_PDR_MKK_MEASUREMENTS:
4832 case HFA384x_PDR_NIC_RAMSIZE:
4833 case HFA384x_PDR_MFISUPRANGE:
4834 case HFA384x_PDR_CFISUPRANGE:
4835 case HFA384x_PDR_NICID:
4836 case HFA384x_PDR_MAC_ADDRESS:
4837 case HFA384x_PDR_REGDOMAIN:
4838 case HFA384x_PDR_ALLOWED_CHANNEL:
4839 case HFA384x_PDR_DEFAULT_CHANNEL:
4840 case HFA384x_PDR_TEMPTYPE:
4841 case HFA384x_PDR_IFR_SETTING:
4842 case HFA384x_PDR_RFR_SETTING:
4843 case HFA384x_PDR_HFA3861_BASELINE:
4844 case HFA384x_PDR_HFA3861_SHADOW:
4845 case HFA384x_PDR_HFA3861_IFRF:
4846 case HFA384x_PDR_HFA3861_CHCALSP:
4847 case HFA384x_PDR_HFA3861_CHCALI:
4848 case HFA384x_PDR_3842_NIC_CONFIG:
4849 case HFA384x_PDR_USB_ID:
4850 case HFA384x_PDR_PCI_ID:
4851 case HFA384x_PDR_PCI_IFCONF:
4852 case HFA384x_PDR_PCI_PMCONF:
4853 case HFA384x_PDR_RFENRGY:
4854 case HFA384x_PDR_HFA3861_MANF_TESTSP:
4855 case HFA384x_PDR_HFA3861_MANF_TESTI:
4860 if ( pdrcode < 0x1000 ) {
4861 /* code is OK, but we don't know exactly what it is */
4863 "Encountered unknown PDR#=0x%04x, "
4864 "assuming it's ok.\n",
4870 "Encountered unknown PDR#=0x%04x, "
4871 "(>=0x1000), assuming it's bad.\n",
4877 return 0; /* avoid compiler warnings */