1 /* src/prism2/driver/prism2sta.c
3 * Implements the station functionality for prism2
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 the module and linux pcmcia routines for the
50 * --------------------------------------------------------------------
53 /*================================================================*/
55 #define WLAN_DBVAR prism2_debug
60 #include <linux/version.h>
62 #include <linux/module.h>
63 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,25))
64 #include <linux/moduleparam.h>
67 #include <linux/kernel.h>
68 #include <linux/sched.h>
69 #include <linux/types.h>
70 #include <linux/init.h>
71 #include <linux/slab.h>
72 #include <linux/wireless.h>
73 #include <linux/netdevice.h>
75 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
76 #include <linux/tqueue.h>
78 #include <linux/workqueue.h>
82 #include <linux/delay.h>
83 #include <asm/byteorder.h>
84 #include <linux/if_arp.h>
86 #if (WLAN_HOSTIF == WLAN_PCMCIA)
87 #include <pcmcia/version.h>
88 #include <pcmcia/cs_types.h>
89 #include <pcmcia/cs.h>
90 #include <pcmcia/cistpl.h>
91 #include <pcmcia/ds.h>
92 #include <pcmcia/cisreg.h>
95 #include "wlan_compat.h"
97 #if ((WLAN_HOSTIF == WLAN_PLX) || (WLAN_HOSTIF == WLAN_PCI))
98 #include <linux/ioport.h>
99 #include <linux/pci.h>
102 /*================================================================*/
103 /* Project Includes */
105 #include "p80211types.h"
106 #include "p80211hdr.h"
107 #include "p80211mgmt.h"
108 #include "p80211conv.h"
109 #include "p80211msg.h"
110 #include "p80211netdev.h"
111 #include "p80211req.h"
112 #include "p80211metadef.h"
113 #include "p80211metastruct.h"
115 #include "prism2mgmt.h"
117 /*================================================================*/
118 /* Local Constants */
120 /*================================================================*/
123 /*================================================================*/
126 /*================================================================*/
127 /* Local Static Definitions */
129 #if (WLAN_HOSTIF == WLAN_PCMCIA)
130 #define DRIVER_SUFFIX "_cs"
131 #elif (WLAN_HOSTIF == WLAN_PLX)
132 #define DRIVER_SUFFIX "_plx"
133 typedef char* dev_info_t;
134 #elif (WLAN_HOSTIF == WLAN_PCI)
135 #define DRIVER_SUFFIX "_pci"
136 typedef char* dev_info_t;
137 #elif (WLAN_HOSTIF == WLAN_USB)
138 #define DRIVER_SUFFIX "_usb"
139 typedef char* dev_info_t;
141 #error "HOSTIF unsupported or undefined!"
144 static char *version = "prism2" DRIVER_SUFFIX ".o: " WLAN_RELEASE;
145 static dev_info_t dev_info = "prism2" DRIVER_SUFFIX;
147 #if (WLAN_HOSTIF == WLAN_PLX || WLAN_HOSTIF == WLAN_PCI)
149 static int prism2sta_suspend_pci(struct pci_dev *pdev, pm_message_t state);
150 static int prism2sta_resume_pci(struct pci_dev *pdev);
154 #if (WLAN_HOSTIF == WLAN_PCI)
156 #endif /* WLAN_PCI */
158 static wlandevice_t *create_wlan(void);
160 /*----------------------------------------------------------------*/
161 /* --Module Parameters */
163 int prism2_reset_holdtime=30; /* Reset hold time in ms */
164 int prism2_reset_settletime=100; /* Reset settle time in ms */
166 #if (WLAN_HOSTIF == WLAN_USB)
167 static int prism2_doreset=0; /* Do a reset at init? */
169 static int prism2_doreset=1; /* Do a reset at init? */
170 int prism2_bap_timeout=1000; /* BAP timeout */
171 int prism2_irq_evread_max=20; /* Maximum number of
177 #ifdef WLAN_INCLUDE_DEBUG
179 module_param( prism2_debug, int, 0644);
180 MODULE_PARM_DESC(prism2_debug, "prism2 debugging");
183 module_param( prism2_doreset, int, 0644);
184 MODULE_PARM_DESC(prism2_doreset, "Issue a reset on initialization");
186 module_param( prism2_reset_holdtime, int, 0644);
187 MODULE_PARM_DESC( prism2_reset_holdtime, "reset hold time in ms");
188 module_param( prism2_reset_settletime, int, 0644);
189 MODULE_PARM_DESC( prism2_reset_settletime, "reset settle time in ms");
191 #if (WLAN_HOSTIF != WLAN_USB)
192 module_param( prism2_bap_timeout, int, 0644);
193 MODULE_PARM_DESC(prism2_bap_timeout, "BufferAccessPath Timeout in 10*n us");
194 module_param( prism2_irq_evread_max, int, 0644);
195 MODULE_PARM_DESC( prism2_irq_evread_max, "Maximim number of event reads in interrupt handler");
198 MODULE_LICENSE("Dual MPL/GPL");
200 /*================================================================*/
201 /* Local Function Declarations */
203 static int prism2sta_open(wlandevice_t *wlandev);
204 static int prism2sta_close(wlandevice_t *wlandev);
205 static void prism2sta_reset(wlandevice_t *wlandev );
206 static int prism2sta_txframe(wlandevice_t *wlandev, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep);
207 static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg);
208 static int prism2sta_getcardinfo(wlandevice_t *wlandev);
209 static int prism2sta_globalsetup(wlandevice_t *wlandev);
210 static int prism2sta_setmulticast(wlandevice_t *wlandev,
213 static void prism2sta_inf_handover(
214 wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
215 static void prism2sta_inf_tallies(
216 wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
217 static void prism2sta_inf_hostscanresults(
218 wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
219 static void prism2sta_inf_scanresults(
220 wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
221 static void prism2sta_inf_chinforesults(
222 wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
223 static void prism2sta_inf_linkstatus(
224 wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
225 static void prism2sta_inf_assocstatus(
226 wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
227 static void prism2sta_inf_authreq(
228 wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
229 static void prism2sta_inf_authreq_defer(
230 wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
231 static void prism2sta_inf_psusercnt(
232 wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
234 #ifdef CONFIG_PROC_FS
245 /*================================================================*/
246 /* Function Definitions */
248 /*----------------------------------------------------------------
251 * Debug utility function to dump memory to the kernel debug log.
254 * buf ptr data we want dumped
264 ----------------------------------------------------------------*/
265 inline void dmpmem(void *buf, int n)
268 for ( c= 0; c < n; c++) {
269 if ( (c % 16) == 0 ) printk(KERN_DEBUG"dmp[%d]: ", c);
270 printk("%02x ", ((UINT8*)buf)[c]);
271 if ( (c % 16) == 15 ) printk("\n");
273 if ( (c % 16) != 0 ) printk("\n");
277 /*----------------------------------------------------------------
280 * WLAN device open method. Called from p80211netdev when kernel
281 * device open (start) method is called in response to the
282 * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
286 * wlandev wlan device structure
290 * >0 f/w reported error
291 * <0 driver reported error
297 ----------------------------------------------------------------*/
298 static int prism2sta_open(wlandevice_t *wlandev)
302 #ifdef ANCIENT_MODULE_CODE
306 /* We don't currently have to do anything else.
307 * The setup of the MAC should be subsequently completed via
309 * Higher layers know we're ready from dev->start==1 and
310 * dev->tbusy==0. Our rx path knows to pass up received/
311 * frames because of dev->flags&IFF_UP is true.
319 /*----------------------------------------------------------------
322 * WLAN device close method. Called from p80211netdev when kernel
323 * device close method is called in response to the
324 * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
328 * wlandev wlan device structure
332 * >0 f/w reported error
333 * <0 driver reported error
339 ----------------------------------------------------------------*/
340 static int prism2sta_close(wlandevice_t *wlandev)
344 #ifdef ANCIENT_MODULE_CODE
348 /* We don't currently have to do anything else.
349 * Higher layers know we're not ready from dev->start==0 and
350 * dev->tbusy==1. Our rx path knows to not pass up received
351 * frames because of dev->flags&IFF_UP is false.
359 /*----------------------------------------------------------------
362 * Not currently implented.
365 * wlandev wlan device structure
375 ----------------------------------------------------------------*/
376 static void prism2sta_reset(wlandevice_t *wlandev )
384 /*----------------------------------------------------------------
387 * Takes a frame from p80211 and queues it for transmission.
390 * wlandev wlan device structure
391 * pb packet buffer struct. Contains an 802.11
393 * p80211_hdr points to the 802.11 header for the packet.
395 * 0 Success and more buffs available
396 * 1 Success but no more buffs
397 * 2 Allocation failure
398 * 4 Buffer full or queue busy
404 ----------------------------------------------------------------*/
405 static int prism2sta_txframe(wlandevice_t *wlandev, struct sk_buff *skb,
406 p80211_hdr_t *p80211_hdr,
407 p80211_metawep_t *p80211_wep)
409 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
413 /* If necessary, set the 802.11 WEP bit */
414 if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) {
415 p80211_hdr->a3.fc |= host2ieee16(WLAN_SET_FC_ISWEP(1));
418 result = hfa384x_drvr_txframe(hw, skb, p80211_hdr, p80211_wep);
425 /*----------------------------------------------------------------
426 * prism2sta_mlmerequest
428 * wlan command message handler. All we do here is pass the message
429 * over to the prism2sta_mgmt_handler.
432 * wlandev wlan device structure
433 * msg wlan command message
436 * <0 successful acceptance of message, but we're
437 * waiting for an async process to finish before
438 * we're done with the msg. When the asynch
439 * process is done, we'll call the p80211
440 * function p80211req_confirm() .
441 * >0 An error occurred while we were handling
448 ----------------------------------------------------------------*/
449 static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg)
451 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
456 switch( msg->msgcode )
458 case DIDmsg_dot11req_mibget :
459 WLAN_LOG_DEBUG(2,"Received mibget request\n");
460 result = prism2mgmt_mibset_mibget(wlandev, msg);
462 case DIDmsg_dot11req_mibset :
463 WLAN_LOG_DEBUG(2,"Received mibset request\n");
464 result = prism2mgmt_mibset_mibget(wlandev, msg);
466 case DIDmsg_dot11req_powermgmt :
467 WLAN_LOG_DEBUG(2,"Received powermgmt request\n");
468 result = prism2mgmt_powermgmt(wlandev, msg);
470 case DIDmsg_dot11req_scan :
471 WLAN_LOG_DEBUG(2,"Received scan request\n");
472 result = prism2mgmt_scan(wlandev, msg);
474 case DIDmsg_dot11req_scan_results :
475 WLAN_LOG_DEBUG(2,"Received scan_results request\n");
476 result = prism2mgmt_scan_results(wlandev, msg);
478 case DIDmsg_dot11req_join :
479 WLAN_LOG_DEBUG(2,"Received join request\n");
480 result = prism2mgmt_join(wlandev, msg);
482 case DIDmsg_dot11req_authenticate :
483 WLAN_LOG_DEBUG(2,"Received authenticate request\n");
484 result = prism2mgmt_authenticate(wlandev, msg);
486 case DIDmsg_dot11req_deauthenticate :
487 WLAN_LOG_DEBUG(2,"Received mlme deauthenticate request\n");
488 result = prism2mgmt_deauthenticate(wlandev, msg);
490 case DIDmsg_dot11req_associate :
491 WLAN_LOG_DEBUG(2,"Received mlme associate request\n");
492 result = prism2mgmt_associate(wlandev, msg);
494 case DIDmsg_dot11req_reassociate :
495 WLAN_LOG_DEBUG(2,"Received mlme reassociate request\n");
496 result = prism2mgmt_reassociate(wlandev, msg);
498 case DIDmsg_dot11req_disassociate :
499 WLAN_LOG_DEBUG(2,"Received mlme disassociate request\n");
500 result = prism2mgmt_disassociate(wlandev, msg);
502 case DIDmsg_dot11req_reset :
503 WLAN_LOG_DEBUG(2,"Received mlme reset request\n");
504 result = prism2mgmt_reset(wlandev, msg);
506 case DIDmsg_dot11req_start :
507 WLAN_LOG_DEBUG(2,"Received mlme start request\n");
508 result = prism2mgmt_start(wlandev, msg);
511 * Prism2 specific messages
513 case DIDmsg_p2req_join :
514 WLAN_LOG_DEBUG(2,"Received p2 join request\n");
515 result = prism2mgmt_p2_join(wlandev, msg);
517 case DIDmsg_p2req_readpda :
518 WLAN_LOG_DEBUG(2,"Received mlme readpda request\n");
519 result = prism2mgmt_readpda(wlandev, msg);
521 case DIDmsg_p2req_readcis :
522 WLAN_LOG_DEBUG(2,"Received mlme readcis request\n");
523 result = prism2mgmt_readcis(wlandev, msg);
525 case DIDmsg_p2req_auxport_state :
526 WLAN_LOG_DEBUG(2,"Received mlme auxport_state request\n");
527 result = prism2mgmt_auxport_state(wlandev, msg);
529 case DIDmsg_p2req_auxport_read :
530 WLAN_LOG_DEBUG(2,"Received mlme auxport_read request\n");
531 result = prism2mgmt_auxport_read(wlandev, msg);
533 case DIDmsg_p2req_auxport_write :
534 WLAN_LOG_DEBUG(2,"Received mlme auxport_write request\n");
535 result = prism2mgmt_auxport_write(wlandev, msg);
537 case DIDmsg_p2req_low_level :
538 WLAN_LOG_DEBUG(2,"Received mlme low_level request\n");
539 result = prism2mgmt_low_level(wlandev, msg);
541 case DIDmsg_p2req_test_command :
542 WLAN_LOG_DEBUG(2,"Received mlme test_command request\n");
543 result = prism2mgmt_test_command(wlandev, msg);
545 case DIDmsg_p2req_mmi_read :
546 WLAN_LOG_DEBUG(2,"Received mlme mmi_read request\n");
547 result = prism2mgmt_mmi_read(wlandev, msg);
549 case DIDmsg_p2req_mmi_write :
550 WLAN_LOG_DEBUG(2,"Received mlme mmi_write request\n");
551 result = prism2mgmt_mmi_write(wlandev, msg);
553 case DIDmsg_p2req_ramdl_state :
554 WLAN_LOG_DEBUG(2,"Received mlme ramdl_state request\n");
555 result = prism2mgmt_ramdl_state(wlandev, msg);
557 case DIDmsg_p2req_ramdl_write :
558 WLAN_LOG_DEBUG(2,"Received mlme ramdl_write request\n");
559 result = prism2mgmt_ramdl_write(wlandev, msg);
561 case DIDmsg_p2req_flashdl_state :
562 WLAN_LOG_DEBUG(2,"Received mlme flashdl_state request\n");
563 result = prism2mgmt_flashdl_state(wlandev, msg);
565 case DIDmsg_p2req_flashdl_write :
566 WLAN_LOG_DEBUG(2,"Received mlme flashdl_write request\n");
567 result = prism2mgmt_flashdl_write(wlandev, msg);
569 case DIDmsg_p2req_dump_state :
570 WLAN_LOG_DEBUG(2,"Received mlme dump_state request\n");
571 result = prism2mgmt_dump_state(wlandev, msg);
573 case DIDmsg_p2req_channel_info :
574 WLAN_LOG_DEBUG(2,"Received mlme channel_info request\n");
575 result = prism2mgmt_channel_info(wlandev, msg);
577 case DIDmsg_p2req_channel_info_results :
578 WLAN_LOG_DEBUG(2,"Received mlme channel_info_results request\n");
579 result = prism2mgmt_channel_info_results(wlandev, msg);
582 * Linux specific messages
584 case DIDmsg_lnxreq_hostwep :
586 case DIDmsg_lnxreq_ifstate :
588 p80211msg_lnxreq_ifstate_t *ifstatemsg;
589 WLAN_LOG_DEBUG(2,"Received mlme ifstate request\n");
590 ifstatemsg = (p80211msg_lnxreq_ifstate_t*)msg;
591 result = prism2sta_ifstate(wlandev, ifstatemsg->ifstate.data);
592 ifstatemsg->resultcode.status =
593 P80211ENUM_msgitem_status_data_ok;
594 ifstatemsg->resultcode.data = result;
598 case DIDmsg_lnxreq_wlansniff :
599 WLAN_LOG_DEBUG(2,"Received mlme wlansniff request\n");
600 result = prism2mgmt_wlansniff(wlandev, msg);
602 case DIDmsg_lnxreq_autojoin :
603 WLAN_LOG_DEBUG(2,"Received mlme autojoin request\n");
604 result = prism2mgmt_autojoin(wlandev, msg);
606 case DIDmsg_p2req_enable :
607 WLAN_LOG_DEBUG(2,"Received mlme enable request\n");
608 result = prism2mgmt_enable(wlandev, msg);
610 case DIDmsg_lnxreq_commsquality: {
611 p80211msg_lnxreq_commsquality_t *qualmsg;
613 WLAN_LOG_DEBUG(2,"Received commsquality request\n");
618 qualmsg = (p80211msg_lnxreq_commsquality_t*) msg;
620 qualmsg->link.status = P80211ENUM_msgitem_status_data_ok;
621 qualmsg->level.status = P80211ENUM_msgitem_status_data_ok;
622 qualmsg->noise.status = P80211ENUM_msgitem_status_data_ok;
625 qualmsg->link.data = hfa384x2host_16(hw->qual.CQ_currBSS);
626 qualmsg->level.data = hfa384x2host_16(hw->qual.ASL_currBSS);
627 qualmsg->noise.data = hfa384x2host_16(hw->qual.ANL_currFC);
632 WLAN_LOG_WARNING("Unknown mgmt request message 0x%08x", msg->msgcode);
641 /*----------------------------------------------------------------
644 * Interface state. This is the primary WLAN interface enable/disable
645 * handler. Following the driver/load/deviceprobe sequence, this
646 * function must be called with a state of "enable" before any other
647 * commands will be accepted.
650 * wlandev wlan device structure
651 * msgp ptr to msg buffer
654 * A p80211 message resultcode value.
659 * process thread (usually)
661 ----------------------------------------------------------------*/
662 UINT32 prism2sta_ifstate(wlandevice_t *wlandev, UINT32 ifstate)
664 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
668 result = P80211ENUM_resultcode_implementation_failure;
670 WLAN_LOG_DEBUG(2, "Current MSD state(%d), requesting(%d)\n",
671 wlandev->msdstate, ifstate);
674 case P80211ENUM_ifstate_fwload:
675 switch (wlandev->msdstate) {
676 case WLAN_MSD_HWPRESENT:
677 wlandev->msdstate = WLAN_MSD_FWLOAD_PENDING;
679 * Initialize the device+driver sufficiently
680 * for firmware loading.
682 #if (WLAN_HOSTIF != WLAN_USB)
683 result=hfa384x_cmd_initialize(hw);
685 if ((result=hfa384x_drvr_start(hw))) {
687 "hfa384x_drvr_start() failed,"
688 "result=%d\n", (int)result);
690 P80211ENUM_resultcode_implementation_failure;
691 wlandev->msdstate = WLAN_MSD_HWPRESENT;
695 wlandev->msdstate = WLAN_MSD_FWLOAD;
696 result = P80211ENUM_resultcode_success;
698 case WLAN_MSD_FWLOAD:
699 hfa384x_cmd_initialize(hw);
700 result = P80211ENUM_resultcode_success;
702 case WLAN_MSD_RUNNING:
704 "Cannot enter fwload state from enable state,"
705 "you must disable first.\n");
706 result = P80211ENUM_resultcode_invalid_parameters;
708 case WLAN_MSD_HWFAIL:
710 /* probe() had a problem or the msdstate contains
711 * an unrecognized value, there's nothing we can do.
713 result = P80211ENUM_resultcode_implementation_failure;
717 case P80211ENUM_ifstate_enable:
718 switch (wlandev->msdstate) {
719 case WLAN_MSD_HWPRESENT:
720 case WLAN_MSD_FWLOAD:
721 wlandev->msdstate = WLAN_MSD_RUNNING_PENDING;
722 /* Initialize the device+driver for full
723 * operation. Note that this might me an FWLOAD to
724 * to RUNNING transition so we must not do a chip
725 * or board level reset. Note that on failure,
726 * the MSD state is set to HWPRESENT because we
727 * can't make any assumptions about the state
728 * of the hardware or a previous firmware load.
730 if ((result=hfa384x_drvr_start(hw))) {
732 "hfa384x_drvr_start() failed,"
733 "result=%d\n", (int)result);
735 P80211ENUM_resultcode_implementation_failure;
736 wlandev->msdstate = WLAN_MSD_HWPRESENT;
740 if ((result=prism2sta_getcardinfo(wlandev))) {
742 "prism2sta_getcardinfo() failed,"
743 "result=%d\n", (int)result);
745 P80211ENUM_resultcode_implementation_failure;
746 hfa384x_drvr_stop(hw);
747 wlandev->msdstate = WLAN_MSD_HWPRESENT;
750 if ((result=prism2sta_globalsetup(wlandev))) {
752 "prism2sta_globalsetup() failed,"
753 "result=%d\n", (int)result);
755 P80211ENUM_resultcode_implementation_failure;
756 hfa384x_drvr_stop(hw);
757 wlandev->msdstate = WLAN_MSD_HWPRESENT;
760 wlandev->msdstate = WLAN_MSD_RUNNING;
762 hw->join_retries = 60;
763 result = P80211ENUM_resultcode_success;
765 case WLAN_MSD_RUNNING:
766 /* Do nothing, we're already in this state.*/
767 result = P80211ENUM_resultcode_success;
769 case WLAN_MSD_HWFAIL:
771 /* probe() had a problem or the msdstate contains
772 * an unrecognized value, there's nothing we can do.
774 result = P80211ENUM_resultcode_implementation_failure;
778 case P80211ENUM_ifstate_disable:
779 switch (wlandev->msdstate) {
780 case WLAN_MSD_HWPRESENT:
781 /* Do nothing, we're already in this state.*/
782 result = P80211ENUM_resultcode_success;
784 case WLAN_MSD_FWLOAD:
785 case WLAN_MSD_RUNNING:
786 wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING;
788 * TODO: Shut down the MAC completely. Here a chip
789 * or board level reset is probably called for.
790 * After a "disable" _all_ results are lost, even
791 * those from a fwload.
793 if (!wlandev->hwremoved)
794 netif_carrier_off(wlandev->netdev);
796 hfa384x_drvr_stop(hw);
798 wlandev->macmode = WLAN_MACMODE_NONE;
799 wlandev->msdstate = WLAN_MSD_HWPRESENT;
800 result = P80211ENUM_resultcode_success;
802 case WLAN_MSD_HWFAIL:
804 /* probe() had a problem or the msdstate contains
805 * an unrecognized value, there's nothing we can do.
807 result = P80211ENUM_resultcode_implementation_failure;
812 result = P80211ENUM_resultcode_invalid_parameters;
821 /*----------------------------------------------------------------
822 * prism2sta_getcardinfo
824 * Collect the NICID, firmware version and any other identifiers
825 * we'd like to have in host-side data structures.
828 * wlandev wlan device structure
832 * >0 f/w reported error
833 * <0 driver reported error
839 ----------------------------------------------------------------*/
840 static int prism2sta_getcardinfo(wlandevice_t *wlandev)
843 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
845 UINT8 snum[HFA384x_RID_NICSERIALNUMBER_LEN];
846 char pstr[(HFA384x_RID_NICSERIALNUMBER_LEN * 4) + 1];
850 /* Collect version and compatibility info */
851 /* Some are critical, some are not */
853 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICIDENTITY,
854 &hw->ident_nic, sizeof(hfa384x_compident_t));
856 WLAN_LOG_ERROR("Failed to retrieve NICIDENTITY\n");
860 /* get all the nic id fields in host byte order */
861 hw->ident_nic.id = hfa384x2host_16(hw->ident_nic.id);
862 hw->ident_nic.variant = hfa384x2host_16(hw->ident_nic.variant);
863 hw->ident_nic.major = hfa384x2host_16(hw->ident_nic.major);
864 hw->ident_nic.minor = hfa384x2host_16(hw->ident_nic.minor);
866 WLAN_LOG_INFO( "ident: nic h/w: id=0x%02x %d.%d.%d\n",
867 hw->ident_nic.id, hw->ident_nic.major,
868 hw->ident_nic.minor, hw->ident_nic.variant);
870 /* Primary f/w identity */
871 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRIIDENTITY,
872 &hw->ident_pri_fw, sizeof(hfa384x_compident_t));
874 WLAN_LOG_ERROR("Failed to retrieve PRIIDENTITY\n");
878 /* get all the private fw id fields in host byte order */
879 hw->ident_pri_fw.id = hfa384x2host_16(hw->ident_pri_fw.id);
880 hw->ident_pri_fw.variant = hfa384x2host_16(hw->ident_pri_fw.variant);
881 hw->ident_pri_fw.major = hfa384x2host_16(hw->ident_pri_fw.major);
882 hw->ident_pri_fw.minor = hfa384x2host_16(hw->ident_pri_fw.minor);
884 WLAN_LOG_INFO( "ident: pri f/w: id=0x%02x %d.%d.%d\n",
885 hw->ident_pri_fw.id, hw->ident_pri_fw.major,
886 hw->ident_pri_fw.minor, hw->ident_pri_fw.variant);
888 /* Station (Secondary?) f/w identity */
889 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STAIDENTITY,
890 &hw->ident_sta_fw, sizeof(hfa384x_compident_t));
892 WLAN_LOG_ERROR("Failed to retrieve STAIDENTITY\n");
896 if (hw->ident_nic.id < 0x8000) {
897 WLAN_LOG_ERROR("FATAL: Card is not an Intersil Prism2/2.5/3\n");
902 /* get all the station fw id fields in host byte order */
903 hw->ident_sta_fw.id = hfa384x2host_16(hw->ident_sta_fw.id);
904 hw->ident_sta_fw.variant = hfa384x2host_16(hw->ident_sta_fw.variant);
905 hw->ident_sta_fw.major = hfa384x2host_16(hw->ident_sta_fw.major);
906 hw->ident_sta_fw.minor = hfa384x2host_16(hw->ident_sta_fw.minor);
908 /* strip out the 'special' variant bits */
909 hw->mm_mods = hw->ident_sta_fw.variant & (BIT14 | BIT15);
910 hw->ident_sta_fw.variant &= ~((UINT16)(BIT14 | BIT15));
912 if ( hw->ident_sta_fw.id == 0x1f ) {
915 "ident: sta f/w: id=0x%02x %d.%d.%d\n",
916 hw->ident_sta_fw.id, hw->ident_sta_fw.major,
917 hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
921 "ident: ap f/w: id=0x%02x %d.%d.%d\n",
922 hw->ident_sta_fw.id, hw->ident_sta_fw.major,
923 hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
926 /* Compatibility range, Modem supplier */
927 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_MFISUPRANGE,
928 &hw->cap_sup_mfi, sizeof(hfa384x_caplevel_t));
930 WLAN_LOG_ERROR("Failed to retrieve MFISUPRANGE\n");
934 /* get all the Compatibility range, modem interface supplier
935 fields in byte order */
936 hw->cap_sup_mfi.role = hfa384x2host_16(hw->cap_sup_mfi.role);
937 hw->cap_sup_mfi.id = hfa384x2host_16(hw->cap_sup_mfi.id);
938 hw->cap_sup_mfi.variant = hfa384x2host_16(hw->cap_sup_mfi.variant);
939 hw->cap_sup_mfi.bottom = hfa384x2host_16(hw->cap_sup_mfi.bottom);
940 hw->cap_sup_mfi.top = hfa384x2host_16(hw->cap_sup_mfi.top);
943 "MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
944 hw->cap_sup_mfi.role, hw->cap_sup_mfi.id,
945 hw->cap_sup_mfi.variant, hw->cap_sup_mfi.bottom,
946 hw->cap_sup_mfi.top);
948 /* Compatibility range, Controller supplier */
949 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CFISUPRANGE,
950 &hw->cap_sup_cfi, sizeof(hfa384x_caplevel_t));
952 WLAN_LOG_ERROR("Failed to retrieve CFISUPRANGE\n");
956 /* get all the Compatibility range, controller interface supplier
957 fields in byte order */
958 hw->cap_sup_cfi.role = hfa384x2host_16(hw->cap_sup_cfi.role);
959 hw->cap_sup_cfi.id = hfa384x2host_16(hw->cap_sup_cfi.id);
960 hw->cap_sup_cfi.variant = hfa384x2host_16(hw->cap_sup_cfi.variant);
961 hw->cap_sup_cfi.bottom = hfa384x2host_16(hw->cap_sup_cfi.bottom);
962 hw->cap_sup_cfi.top = hfa384x2host_16(hw->cap_sup_cfi.top);
965 "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
966 hw->cap_sup_cfi.role, hw->cap_sup_cfi.id,
967 hw->cap_sup_cfi.variant, hw->cap_sup_cfi.bottom,
968 hw->cap_sup_cfi.top);
970 /* Compatibility range, Primary f/w supplier */
971 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRISUPRANGE,
972 &hw->cap_sup_pri, sizeof(hfa384x_caplevel_t));
974 WLAN_LOG_ERROR("Failed to retrieve PRISUPRANGE\n");
978 /* get all the Compatibility range, primary firmware supplier
979 fields in byte order */
980 hw->cap_sup_pri.role = hfa384x2host_16(hw->cap_sup_pri.role);
981 hw->cap_sup_pri.id = hfa384x2host_16(hw->cap_sup_pri.id);
982 hw->cap_sup_pri.variant = hfa384x2host_16(hw->cap_sup_pri.variant);
983 hw->cap_sup_pri.bottom = hfa384x2host_16(hw->cap_sup_pri.bottom);
984 hw->cap_sup_pri.top = hfa384x2host_16(hw->cap_sup_pri.top);
987 "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
988 hw->cap_sup_pri.role, hw->cap_sup_pri.id,
989 hw->cap_sup_pri.variant, hw->cap_sup_pri.bottom,
990 hw->cap_sup_pri.top);
992 /* Compatibility range, Station f/w supplier */
993 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STASUPRANGE,
994 &hw->cap_sup_sta, sizeof(hfa384x_caplevel_t));
996 WLAN_LOG_ERROR("Failed to retrieve STASUPRANGE\n");
1000 /* get all the Compatibility range, station firmware supplier
1001 fields in byte order */
1002 hw->cap_sup_sta.role = hfa384x2host_16(hw->cap_sup_sta.role);
1003 hw->cap_sup_sta.id = hfa384x2host_16(hw->cap_sup_sta.id);
1004 hw->cap_sup_sta.variant = hfa384x2host_16(hw->cap_sup_sta.variant);
1005 hw->cap_sup_sta.bottom = hfa384x2host_16(hw->cap_sup_sta.bottom);
1006 hw->cap_sup_sta.top = hfa384x2host_16(hw->cap_sup_sta.top);
1008 if ( hw->cap_sup_sta.id == 0x04 ) {
1010 "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
1011 hw->cap_sup_sta.role, hw->cap_sup_sta.id,
1012 hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
1013 hw->cap_sup_sta.top);
1016 "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
1017 hw->cap_sup_sta.role, hw->cap_sup_sta.id,
1018 hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
1019 hw->cap_sup_sta.top);
1022 /* Compatibility range, primary f/w actor, CFI supplier */
1023 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRI_CFIACTRANGES,
1024 &hw->cap_act_pri_cfi, sizeof(hfa384x_caplevel_t));
1026 WLAN_LOG_ERROR("Failed to retrieve PRI_CFIACTRANGES\n");
1030 /* get all the Compatibility range, primary f/w actor, CFI supplier
1031 fields in byte order */
1032 hw->cap_act_pri_cfi.role = hfa384x2host_16(hw->cap_act_pri_cfi.role);
1033 hw->cap_act_pri_cfi.id = hfa384x2host_16(hw->cap_act_pri_cfi.id);
1034 hw->cap_act_pri_cfi.variant = hfa384x2host_16(hw->cap_act_pri_cfi.variant);
1035 hw->cap_act_pri_cfi.bottom = hfa384x2host_16(hw->cap_act_pri_cfi.bottom);
1036 hw->cap_act_pri_cfi.top = hfa384x2host_16(hw->cap_act_pri_cfi.top);
1039 "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
1040 hw->cap_act_pri_cfi.role, hw->cap_act_pri_cfi.id,
1041 hw->cap_act_pri_cfi.variant, hw->cap_act_pri_cfi.bottom,
1042 hw->cap_act_pri_cfi.top);
1044 /* Compatibility range, sta f/w actor, CFI supplier */
1045 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_CFIACTRANGES,
1046 &hw->cap_act_sta_cfi, sizeof(hfa384x_caplevel_t));
1048 WLAN_LOG_ERROR("Failed to retrieve STA_CFIACTRANGES\n");
1052 /* get all the Compatibility range, station f/w actor, CFI supplier
1053 fields in byte order */
1054 hw->cap_act_sta_cfi.role = hfa384x2host_16(hw->cap_act_sta_cfi.role);
1055 hw->cap_act_sta_cfi.id = hfa384x2host_16(hw->cap_act_sta_cfi.id);
1056 hw->cap_act_sta_cfi.variant = hfa384x2host_16(hw->cap_act_sta_cfi.variant);
1057 hw->cap_act_sta_cfi.bottom = hfa384x2host_16(hw->cap_act_sta_cfi.bottom);
1058 hw->cap_act_sta_cfi.top = hfa384x2host_16(hw->cap_act_sta_cfi.top);
1061 "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
1062 hw->cap_act_sta_cfi.role, hw->cap_act_sta_cfi.id,
1063 hw->cap_act_sta_cfi.variant, hw->cap_act_sta_cfi.bottom,
1064 hw->cap_act_sta_cfi.top);
1066 /* Compatibility range, sta f/w actor, MFI supplier */
1067 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_MFIACTRANGES,
1068 &hw->cap_act_sta_mfi, sizeof(hfa384x_caplevel_t));
1070 WLAN_LOG_ERROR("Failed to retrieve STA_MFIACTRANGES\n");
1074 /* get all the Compatibility range, station f/w actor, MFI supplier
1075 fields in byte order */
1076 hw->cap_act_sta_mfi.role = hfa384x2host_16(hw->cap_act_sta_mfi.role);
1077 hw->cap_act_sta_mfi.id = hfa384x2host_16(hw->cap_act_sta_mfi.id);
1078 hw->cap_act_sta_mfi.variant = hfa384x2host_16(hw->cap_act_sta_mfi.variant);
1079 hw->cap_act_sta_mfi.bottom = hfa384x2host_16(hw->cap_act_sta_mfi.bottom);
1080 hw->cap_act_sta_mfi.top = hfa384x2host_16(hw->cap_act_sta_mfi.top);
1083 "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
1084 hw->cap_act_sta_mfi.role, hw->cap_act_sta_mfi.id,
1085 hw->cap_act_sta_mfi.variant, hw->cap_act_sta_mfi.bottom,
1086 hw->cap_act_sta_mfi.top);
1089 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICSERIALNUMBER,
1090 snum, HFA384x_RID_NICSERIALNUMBER_LEN);
1092 wlan_mkprintstr(snum, HFA384x_RID_NICSERIALNUMBER_LEN,
1093 pstr, sizeof(pstr));
1094 WLAN_LOG_INFO("Prism2 card SN: %s\n", pstr);
1096 WLAN_LOG_ERROR("Failed to retrieve Prism2 Card SN\n");
1100 /* Collect the MAC address */
1101 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFOWNMACADDR,
1102 wlandev->netdev->dev_addr, WLAN_ADDR_LEN);
1103 if ( result != 0 ) {
1104 WLAN_LOG_ERROR("Failed to retrieve mac address\n");
1108 /* short preamble is always implemented */
1109 wlandev->nsdcaps |= P80211_NSDCAP_SHORT_PREAMBLE;
1111 /* find out if hardware wep is implemented */
1112 hfa384x_drvr_getconfig16(hw, HFA384x_RID_PRIVACYOPTIMP, &temp);
1114 wlandev->nsdcaps |= P80211_NSDCAP_HARDWAREWEP;
1116 /* get the dBm Scaling constant */
1117 hfa384x_drvr_getconfig16(hw, HFA384x_RID_CNFDBMADJUST, &temp);
1118 hw->dbmadjust = temp;
1120 /* Only enable scan by default on newer firmware */
1121 if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
1122 hw->ident_sta_fw.minor,
1123 hw->ident_sta_fw.variant) <
1124 HFA384x_FIRMWARE_VERSION(1,5,5)) {
1125 wlandev->nsdcaps |= P80211_NSDCAP_NOSCAN;
1128 /* TODO: Set any internally managed config items */
1132 WLAN_LOG_ERROR("Failed, result=%d\n", result);
1139 /*----------------------------------------------------------------
1140 * prism2sta_globalsetup
1142 * Set any global RIDs that we want to set at device activation.
1145 * wlandev wlan device structure
1149 * >0 f/w reported error
1150 * <0 driver reported error
1156 ----------------------------------------------------------------*/
1157 static int prism2sta_globalsetup(wlandevice_t *wlandev)
1159 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
1161 /* Set the maximum frame size */
1162 return hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN,
1166 static int prism2sta_setmulticast(wlandevice_t *wlandev, netdevice_t *dev)
1169 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
1175 /* If we're not ready, what's the point? */
1176 if ( hw->state != HFA384x_STATE_RUNNING )
1179 /* If we're an AP, do nothing here */
1183 if ( (dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0 )
1184 promisc = P80211ENUM_truth_true;
1186 promisc = P80211ENUM_truth_false;
1188 result = hfa384x_drvr_setconfig16_async(hw, HFA384x_RID_PROMISCMODE, promisc);
1190 /* XXX TODO: configure the multicast list */
1191 // CLEAR_HW_MULTICAST_LIST
1192 // struct dev_mc_list element = dev->mc_list;
1193 // while (element != null) {
1194 // HW_ADD_MULTICAST_ADDR(element->dmi_addr, dmi_addrlen)
1195 // element = element->next;
1203 /*----------------------------------------------------------------
1204 * prism2sta_inf_handover
1206 * Handles the receipt of a Handover info frame. Should only be present
1210 * wlandev wlan device structure
1211 * inf ptr to info frame (contents in hfa384x order)
1220 ----------------------------------------------------------------*/
1221 static void prism2sta_inf_handover(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf)
1224 WLAN_LOG_DEBUG(2,"received infoframe:HANDOVER (unhandled)\n");
1230 /*----------------------------------------------------------------
1231 * prism2sta_inf_tallies
1233 * Handles the receipt of a CommTallies info frame.
1236 * wlandev wlan device structure
1237 * inf ptr to info frame (contents in hfa384x order)
1246 ----------------------------------------------------------------*/
1247 static void prism2sta_inf_tallies(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf)
1249 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
1259 ** Determine if these are 16-bit or 32-bit tallies, based on the
1260 ** record length of the info record.
1263 cnt = sizeof(hfa384x_CommTallies32_t) / sizeof(UINT32);
1264 if (inf->framelen > 22) {
1265 dst = (UINT32 *) &hw->tallies;
1266 src32 = (UINT32 *) &inf->info.commtallies32;
1267 for (i = 0; i < cnt; i++, dst++, src32++)
1268 *dst += hfa384x2host_32(*src32);
1270 dst = (UINT32 *) &hw->tallies;
1271 src16 = (UINT16 *) &inf->info.commtallies16;
1272 for (i = 0; i < cnt; i++, dst++, src16++)
1273 *dst += hfa384x2host_16(*src16);
1281 /*----------------------------------------------------------------
1282 * prism2sta_inf_scanresults
1284 * Handles the receipt of a Scan Results info frame.
1287 * wlandev wlan device structure
1288 * inf ptr to info frame (contents in hfa384x order)
1297 ----------------------------------------------------------------*/
1298 static void prism2sta_inf_scanresults(wlandevice_t *wlandev,
1299 hfa384x_InfFrame_t *inf)
1302 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
1304 hfa384x_ScanResult_t *sr = &(inf->info.scanresult);
1306 hfa384x_JoinRequest_data_t joinreq;
1310 /* Get the number of results, first in bytes, then in results */
1311 nbss = (inf->framelen * sizeof(UINT16)) -
1312 sizeof(inf->infotype) -
1313 sizeof(inf->info.scanresult.scanreason);
1314 nbss /= sizeof(hfa384x_ScanResultSub_t);
1317 WLAN_LOG_DEBUG(1,"rx scanresults, reason=%d, nbss=%d:\n",
1318 inf->info.scanresult.scanreason, nbss);
1319 for ( i = 0; i < nbss; i++) {
1320 WLAN_LOG_DEBUG(1, "chid=%d anl=%d sl=%d bcnint=%d\n",
1324 sr->result[i].bcnint);
1325 WLAN_LOG_DEBUG(1, " capinfo=0x%04x proberesp_rate=%d\n",
1326 sr->result[i].capinfo,
1327 sr->result[i].proberesp_rate);
1329 /* issue a join request */
1330 joinreq.channel = sr->result[0].chid;
1331 memcpy( joinreq.bssid, sr->result[0].bssid, WLAN_BSSID_LEN);
1332 result = hfa384x_drvr_setconfig( hw,
1333 HFA384x_RID_JOINREQUEST,
1334 &joinreq, HFA384x_RID_JOINREQUEST_LEN);
1336 WLAN_LOG_ERROR("setconfig(joinreq) failed, result=%d\n", result);
1343 /*----------------------------------------------------------------
1344 * prism2sta_inf_hostscanresults
1346 * Handles the receipt of a Scan Results info frame.
1349 * wlandev wlan device structure
1350 * inf ptr to info frame (contents in hfa384x order)
1359 ----------------------------------------------------------------*/
1360 static void prism2sta_inf_hostscanresults(wlandevice_t *wlandev,
1361 hfa384x_InfFrame_t *inf)
1363 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
1367 nbss = (inf->framelen - 3) / 32;
1368 WLAN_LOG_DEBUG(1, "Received %d hostscan results\n", nbss);
1373 if (hw->scanresults)
1374 kfree(hw->scanresults);
1376 hw->scanresults = kmalloc(sizeof(hfa384x_InfFrame_t), GFP_ATOMIC);
1377 memcpy(hw->scanresults, inf, sizeof(hfa384x_InfFrame_t));
1382 /* Notify/wake the sleeping caller. */
1383 hw->scanflag = nbss;
1384 wake_up_interruptible(&hw->cmdq);
1389 /*----------------------------------------------------------------
1390 * prism2sta_inf_chinforesults
1392 * Handles the receipt of a Channel Info Results info frame.
1395 * wlandev wlan device structure
1396 * inf ptr to info frame (contents in hfa384x order)
1405 ----------------------------------------------------------------*/
1406 static void prism2sta_inf_chinforesults(wlandevice_t *wlandev,
1407 hfa384x_InfFrame_t *inf)
1409 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
1413 hw->channel_info.results.scanchannels =
1414 hfa384x2host_16(inf->info.chinforesult.scanchannels);
1416 memcpy(&inf->info.chinforesult, &hw->channel_info.results, sizeof(hfa384x_ChInfoResult_t));
1419 for (i=0, n=0; i<HFA384x_CHINFORESULT_MAX; i++) {
1420 if (hw->channel_info.results.scanchannels & (1<<i)) {
1421 int channel=hfa384x2host_16(inf->info.chinforesult.result[n].chid)-1;
1422 hfa384x_ChInfoResultSub_t *chinforesult=&hw->channel_info.results.result[channel];
1423 chinforesult->chid = channel;
1424 chinforesult->anl = hfa384x2host_16(inf->info.chinforesult.result[n].anl);
1425 chinforesult->pnl = hfa384x2host_16(inf->info.chinforesult.result[n].pnl);
1426 chinforesult->active = hfa384x2host_16(inf->info.chinforesult.result[n].active);
1427 WLAN_LOG_DEBUG(2, "chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n",
1429 chinforesult->active &
1430 HFA384x_CHINFORESULT_BSSACTIVE ? "signal" : "noise",
1431 chinforesult->anl, chinforesult->pnl,
1432 chinforesult->active & HFA384x_CHINFORESULT_PCFACTIVE ? 1 : 0
1437 atomic_set(&hw->channel_info.done, 2);
1439 hw->channel_info.count = n;
1444 void prism2sta_processing_defer(struct work_struct *data)
1446 hfa384x_t *hw = container_of(data, struct hfa384x, link_bh);
1447 wlandevice_t *wlandev = hw->wlandev;
1448 hfa384x_bytestr32_t ssid;
1452 /* First let's process the auth frames */
1454 struct sk_buff *skb;
1455 hfa384x_InfFrame_t *inf;
1457 while ( (skb = skb_dequeue(&hw->authq)) ) {
1458 inf = (hfa384x_InfFrame_t *) skb->data;
1459 prism2sta_inf_authreq_defer(wlandev, inf);
1464 /* Now let's handle the linkstatus stuff */
1465 if (hw->link_status == hw->link_status_new)
1468 hw->link_status = hw->link_status_new;
1470 switch(hw->link_status) {
1471 case HFA384x_LINK_NOTCONNECTED:
1472 /* I'm currently assuming that this is the initial link
1473 * state. It should only be possible immediately
1474 * following an Enable command.
1476 * Block Transmits, Ignore receives of data frames
1478 netif_carrier_off(wlandev->netdev);
1480 WLAN_LOG_INFO("linkstatus=NOTCONNECTED (unhandled)\n");
1483 case HFA384x_LINK_CONNECTED:
1484 /* This one indicates a successful scan/join/auth/assoc.
1485 * When we have the full MLME complement, this event will
1486 * signify successful completion of both mlme_authenticate
1487 * and mlme_associate. State management will get a little
1490 * Indicate authentication and/or association
1491 * Enable Transmits, Receives and pass up data frames
1494 netif_carrier_on(wlandev->netdev);
1496 /* If we are joining a specific AP, set our state and reset retries */
1497 if(hw->join_ap == 1)
1499 hw->join_retries = 60;
1501 /* Don't call this in monitor mode */
1502 if ( wlandev->netdev->type == ARPHRD_ETHER ) {
1505 WLAN_LOG_INFO("linkstatus=CONNECTED\n");
1507 /* For non-usb devices, we can use the sync versions */
1508 /* Collect the BSSID, and set state to allow tx */
1510 result = hfa384x_drvr_getconfig(hw,
1511 HFA384x_RID_CURRENTBSSID,
1512 wlandev->bssid, WLAN_BSSID_LEN);
1515 "getconfig(0x%02x) failed, result = %d\n",
1516 HFA384x_RID_CURRENTBSSID, result);
1520 result = hfa384x_drvr_getconfig(hw,
1521 HFA384x_RID_CURRENTSSID,
1522 &ssid, sizeof(ssid));
1525 "getconfig(0x%02x) failed, result = %d\n",
1526 HFA384x_RID_CURRENTSSID, result);
1529 prism2mgmt_bytestr2pstr((hfa384x_bytestr_t *)&ssid,
1530 (p80211pstrd_t *) &wlandev->ssid);
1532 /* Collect the port status */
1533 result = hfa384x_drvr_getconfig16(hw,
1534 HFA384x_RID_PORTSTATUS, &portstatus);
1537 "getconfig(0x%02x) failed, result = %d\n",
1538 HFA384x_RID_PORTSTATUS, result);
1542 (portstatus == HFA384x_PSTATUS_CONN_IBSS) ?
1543 WLAN_MACMODE_IBSS_STA : WLAN_MACMODE_ESS_STA;
1545 /* Get the ball rolling on the comms quality stuff */
1546 prism2sta_commsqual_defer(&hw->commsqual_bh);
1550 case HFA384x_LINK_DISCONNECTED:
1551 /* This one indicates that our association is gone. We've
1552 * lost connection with the AP and/or been disassociated.
1553 * This indicates that the MAC has completely cleared it's
1554 * associated state. We * should send a deauth indication
1555 * (implying disassoc) up * to the MLME.
1557 * Indicate Deauthentication
1558 * Block Transmits, Ignore receives of data frames
1560 if(hw->join_ap == 2)
1562 hfa384x_JoinRequest_data_t joinreq;
1563 joinreq = hw->joinreq;
1564 /* Send the join request */
1565 hfa384x_drvr_setconfig( hw,
1566 HFA384x_RID_JOINREQUEST,
1567 &joinreq, HFA384x_RID_JOINREQUEST_LEN);
1568 WLAN_LOG_INFO("linkstatus=DISCONNECTED (re-submitting join)\n");
1570 if (wlandev->netdev->type == ARPHRD_ETHER)
1571 WLAN_LOG_INFO("linkstatus=DISCONNECTED (unhandled)\n");
1573 wlandev->macmode = WLAN_MACMODE_NONE;
1575 netif_carrier_off(wlandev->netdev);
1579 case HFA384x_LINK_AP_CHANGE:
1580 /* This one indicates that the MAC has decided to and
1581 * successfully completed a change to another AP. We
1582 * should probably implement a reassociation indication
1583 * in response to this one. I'm thinking that the the
1584 * p80211 layer needs to be notified in case of
1585 * buffering/queueing issues. User mode also needs to be
1586 * notified so that any BSS dependent elements can be
1588 * associated state. We * should send a deauth indication
1589 * (implying disassoc) up * to the MLME.
1591 * Indicate Reassociation
1592 * Enable Transmits, Receives and pass up data frames
1594 WLAN_LOG_INFO("linkstatus=AP_CHANGE\n");
1596 result = hfa384x_drvr_getconfig(hw,
1597 HFA384x_RID_CURRENTBSSID,
1598 wlandev->bssid, WLAN_BSSID_LEN);
1601 "getconfig(0x%02x) failed, result = %d\n",
1602 HFA384x_RID_CURRENTBSSID, result);
1606 result = hfa384x_drvr_getconfig(hw,
1607 HFA384x_RID_CURRENTSSID,
1608 &ssid, sizeof(ssid));
1611 "getconfig(0x%02x) failed, result = %d\n",
1612 HFA384x_RID_CURRENTSSID, result);
1615 prism2mgmt_bytestr2pstr((hfa384x_bytestr_t *)&ssid,
1616 (p80211pstrd_t *) &wlandev->ssid);
1619 hw->link_status = HFA384x_LINK_CONNECTED;
1620 netif_carrier_on(wlandev->netdev);
1624 case HFA384x_LINK_AP_OUTOFRANGE:
1625 /* This one indicates that the MAC has decided that the
1626 * AP is out of range, but hasn't found a better candidate
1627 * so the MAC maintains its "associated" state in case
1628 * we get back in range. We should block transmits and
1629 * receives in this state. Do we need an indication here?
1630 * Probably not since a polling user-mode element would
1631 * get this status from from p2PortStatus(FD40). What about
1634 * Block Transmits, Ignore receives of data frames
1636 WLAN_LOG_INFO("linkstatus=AP_OUTOFRANGE (unhandled)\n");
1638 netif_carrier_off(wlandev->netdev);
1642 case HFA384x_LINK_AP_INRANGE:
1643 /* This one indicates that the MAC has decided that the
1644 * AP is back in range. We continue working with our
1645 * existing association.
1647 * Enable Transmits, Receives and pass up data frames
1649 WLAN_LOG_INFO("linkstatus=AP_INRANGE\n");
1651 hw->link_status = HFA384x_LINK_CONNECTED;
1652 netif_carrier_on(wlandev->netdev);
1656 case HFA384x_LINK_ASSOCFAIL:
1657 /* This one is actually a peer to CONNECTED. We've
1658 * requested a join for a given SSID and optionally BSSID.
1659 * We can use this one to indicate authentication and
1660 * association failures. The trick is going to be
1661 * 1) identifying the failure, and 2) state management.
1663 * Disable Transmits, Ignore receives of data frames
1665 if(hw->join_ap && --hw->join_retries > 0)
1667 hfa384x_JoinRequest_data_t joinreq;
1668 joinreq = hw->joinreq;
1669 /* Send the join request */
1670 hfa384x_drvr_setconfig( hw,
1671 HFA384x_RID_JOINREQUEST,
1672 &joinreq, HFA384x_RID_JOINREQUEST_LEN);
1673 WLAN_LOG_INFO("linkstatus=ASSOCFAIL (re-submitting join)\n");
1675 WLAN_LOG_INFO("linkstatus=ASSOCFAIL (unhandled)\n");
1678 netif_carrier_off(wlandev->netdev);
1683 /* This is bad, IO port problems? */
1685 "unknown linkstatus=0x%02x\n", hw->link_status);
1690 wlandev->linkstatus = (hw->link_status == HFA384x_LINK_CONNECTED);
1692 p80211wext_event_associated(wlandev, wlandev->linkstatus);
1699 /*----------------------------------------------------------------
1700 * prism2sta_inf_linkstatus
1702 * Handles the receipt of a Link Status info frame.
1705 * wlandev wlan device structure
1706 * inf ptr to info frame (contents in hfa384x order)
1715 ----------------------------------------------------------------*/
1716 static void prism2sta_inf_linkstatus(wlandevice_t *wlandev,
1717 hfa384x_InfFrame_t *inf)
1719 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
1723 hw->link_status_new = hfa384x2host_16(inf->info.linkstatus.linkstatus);
1725 schedule_work(&hw->link_bh);
1731 /*----------------------------------------------------------------
1732 * prism2sta_inf_assocstatus
1734 * Handles the receipt of an Association Status info frame. Should
1735 * be present in APs only.
1738 * wlandev wlan device structure
1739 * inf ptr to info frame (contents in hfa384x order)
1748 ----------------------------------------------------------------*/
1749 static void prism2sta_inf_assocstatus(wlandevice_t *wlandev,
1750 hfa384x_InfFrame_t *inf)
1752 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
1753 hfa384x_AssocStatus_t rec;
1758 memcpy(&rec, &inf->info.assocstatus, sizeof(rec));
1759 rec.assocstatus = hfa384x2host_16(rec.assocstatus);
1760 rec.reason = hfa384x2host_16(rec.reason);
1763 ** Find the address in the list of authenticated stations. If it wasn't
1764 ** found, then this address has not been previously authenticated and
1765 ** something weird has happened if this is anything other than an
1766 ** "authentication failed" message. If the address was found, then
1767 ** set the "associated" flag for that station, based on whether the
1768 ** station is associating or losing its association. Something weird
1769 ** has also happened if we find the address in the list of authenticated
1770 ** stations but we are getting an "authentication failed" message.
1773 for (i = 0; i < hw->authlist.cnt; i++)
1774 if (memcmp(rec.sta_addr, hw->authlist.addr[i], WLAN_ADDR_LEN) == 0)
1777 if (i >= hw->authlist.cnt) {
1778 if (rec.assocstatus != HFA384x_ASSOCSTATUS_AUTHFAIL)
1779 WLAN_LOG_WARNING("assocstatus info frame received for non-authenticated station.\n");
1781 hw->authlist.assoc[i] =
1782 (rec.assocstatus == HFA384x_ASSOCSTATUS_STAASSOC ||
1783 rec.assocstatus == HFA384x_ASSOCSTATUS_REASSOC);
1785 if (rec.assocstatus == HFA384x_ASSOCSTATUS_AUTHFAIL)
1786 WLAN_LOG_WARNING("authfail assocstatus info frame received for authenticated station.\n");
1794 /*----------------------------------------------------------------
1795 * prism2sta_inf_authreq
1797 * Handles the receipt of an Authentication Request info frame. Should
1798 * be present in APs only.
1801 * wlandev wlan device structure
1802 * inf ptr to info frame (contents in hfa384x order)
1812 ----------------------------------------------------------------*/
1813 static void prism2sta_inf_authreq(wlandevice_t *wlandev,
1814 hfa384x_InfFrame_t *inf)
1816 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
1817 struct sk_buff *skb;
1821 skb = dev_alloc_skb(sizeof(*inf));
1823 skb_put(skb, sizeof(*inf));
1824 memcpy(skb->data, inf, sizeof(*inf));
1825 skb_queue_tail(&hw->authq, skb);
1826 schedule_work(&hw->link_bh);
1832 static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
1833 hfa384x_InfFrame_t *inf)
1835 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
1836 hfa384x_authenticateStation_data_t rec;
1838 int i, added, result, cnt;
1844 ** Build the AuthenticateStation record. Initialize it for denying
1848 memcpy(rec.address, inf->info.authreq.sta_addr, WLAN_ADDR_LEN);
1849 rec.status = P80211ENUM_status_unspec_failure;
1852 ** Authenticate based on the access mode.
1855 switch (hw->accessmode) {
1856 case WLAN_ACCESS_NONE:
1859 ** Deny all new authentications. However, if a station
1860 ** is ALREADY authenticated, then accept it.
1863 for (i = 0; i < hw->authlist.cnt; i++)
1864 if (memcmp(rec.address, hw->authlist.addr[i],
1865 WLAN_ADDR_LEN) == 0) {
1866 rec.status = P80211ENUM_status_successful;
1872 case WLAN_ACCESS_ALL:
1875 ** Allow all authentications.
1878 rec.status = P80211ENUM_status_successful;
1881 case WLAN_ACCESS_ALLOW:
1884 ** Only allow the authentication if the MAC address
1885 ** is in the list of allowed addresses.
1887 ** Since this is the interrupt handler, we may be here
1888 ** while the access list is in the middle of being
1889 ** updated. Choose the list which is currently okay.
1890 ** See "prism2mib_priv_accessallow()" for details.
1893 if (hw->allow.modify == 0) {
1894 cnt = hw->allow.cnt;
1895 addr = hw->allow.addr[0];
1897 cnt = hw->allow.cnt1;
1898 addr = hw->allow.addr1[0];
1901 for (i = 0; i < cnt; i++, addr += WLAN_ADDR_LEN)
1902 if (memcmp(rec.address, addr, WLAN_ADDR_LEN) == 0) {
1903 rec.status = P80211ENUM_status_successful;
1909 case WLAN_ACCESS_DENY:
1912 ** Allow the authentication UNLESS the MAC address is
1913 ** in the list of denied addresses.
1915 ** Since this is the interrupt handler, we may be here
1916 ** while the access list is in the middle of being
1917 ** updated. Choose the list which is currently okay.
1918 ** See "prism2mib_priv_accessdeny()" for details.
1921 if (hw->deny.modify == 0) {
1923 addr = hw->deny.addr[0];
1925 cnt = hw->deny.cnt1;
1926 addr = hw->deny.addr1[0];
1929 rec.status = P80211ENUM_status_successful;
1931 for (i = 0; i < cnt; i++, addr += WLAN_ADDR_LEN)
1932 if (memcmp(rec.address, addr, WLAN_ADDR_LEN) == 0) {
1933 rec.status = P80211ENUM_status_unspec_failure;
1941 ** If the authentication is okay, then add the MAC address to the list
1942 ** of authenticated stations. Don't add the address if it is already in
1943 ** the list. (802.11b does not seem to disallow a station from issuing
1944 ** an authentication request when the station is already authenticated.
1945 ** Does this sort of thing ever happen? We might as well do the check
1951 if (rec.status == P80211ENUM_status_successful) {
1952 for (i = 0; i < hw->authlist.cnt; i++)
1953 if (memcmp(rec.address, hw->authlist.addr[i], WLAN_ADDR_LEN) == 0)
1956 if (i >= hw->authlist.cnt) {
1957 if (hw->authlist.cnt >= WLAN_AUTH_MAX) {
1958 rec.status = P80211ENUM_status_ap_full;
1960 memcpy(hw->authlist.addr[hw->authlist.cnt],
1961 rec.address, WLAN_ADDR_LEN);
1969 ** Send back the results of the authentication. If this doesn't work,
1970 ** then make sure to remove the address from the authenticated list if
1974 rec.status = host2hfa384x_16(rec.status);
1975 rec.algorithm = inf->info.authreq.algorithm;
1977 result = hfa384x_drvr_setconfig(hw, HFA384x_RID_AUTHENTICATESTA,
1980 if (added) hw->authlist.cnt--;
1981 WLAN_LOG_ERROR("setconfig(authenticatestation) failed, result=%d\n", result);
1990 /*----------------------------------------------------------------
1991 * prism2sta_inf_psusercnt
1993 * Handles the receipt of a PowerSaveUserCount info frame. Should
1994 * be present in APs only.
1997 * wlandev wlan device structure
1998 * inf ptr to info frame (contents in hfa384x order)
2007 ----------------------------------------------------------------*/
2008 static void prism2sta_inf_psusercnt(wlandevice_t *wlandev,
2009 hfa384x_InfFrame_t *inf)
2011 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
2015 hw->psusercount = hfa384x2host_16(inf->info.psusercnt.usercnt);
2022 /*----------------------------------------------------------------
2025 * Handles the DTIM early warning event.
2028 * wlandev wlan device structure
2037 ----------------------------------------------------------------*/
2038 void prism2sta_ev_dtim(wlandevice_t *wlandev)
2041 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
2044 WLAN_LOG_DEBUG(3, "DTIM event, currently unhandled.\n");
2050 /*----------------------------------------------------------------
2051 * prism2sta_ev_infdrop
2053 * Handles the InfDrop event.
2056 * wlandev wlan device structure
2065 ----------------------------------------------------------------*/
2066 void prism2sta_ev_infdrop(wlandevice_t *wlandev)
2069 hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
2072 WLAN_LOG_DEBUG(3, "Info frame dropped due to card mem low.\n");
2078 /*----------------------------------------------------------------
2081 * Handles the Info event.
2084 * wlandev wlan device structure
2085 * inf ptr to a generic info frame
2094 ----------------------------------------------------------------*/
2095 void prism2sta_ev_info(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf)
2098 inf->infotype = hfa384x2host_16(inf->infotype);
2100 switch ( inf->infotype ) {
2101 case HFA384x_IT_HANDOVERADDR:
2102 prism2sta_inf_handover(wlandev, inf);
2104 case HFA384x_IT_COMMTALLIES:
2105 prism2sta_inf_tallies(wlandev, inf);
2107 case HFA384x_IT_HOSTSCANRESULTS:
2108 prism2sta_inf_hostscanresults(wlandev, inf);
2110 case HFA384x_IT_SCANRESULTS:
2111 prism2sta_inf_scanresults(wlandev, inf);
2113 case HFA384x_IT_CHINFORESULTS:
2114 prism2sta_inf_chinforesults(wlandev, inf);
2116 case HFA384x_IT_LINKSTATUS:
2117 prism2sta_inf_linkstatus(wlandev, inf);
2119 case HFA384x_IT_ASSOCSTATUS:
2120 prism2sta_inf_assocstatus(wlandev, inf);
2122 case HFA384x_IT_AUTHREQ:
2123 prism2sta_inf_authreq(wlandev, inf);
2125 case HFA384x_IT_PSUSERCNT:
2126 prism2sta_inf_psusercnt(wlandev, inf);
2128 case HFA384x_IT_KEYIDCHANGED:
2129 WLAN_LOG_WARNING("Unhandled IT_KEYIDCHANGED\n");
2131 case HFA384x_IT_ASSOCREQ:
2132 WLAN_LOG_WARNING("Unhandled IT_ASSOCREQ\n");
2134 case HFA384x_IT_MICFAILURE:
2135 WLAN_LOG_WARNING("Unhandled IT_MICFAILURE\n");
2139 "Unknown info type=0x%02x\n", inf->infotype);
2147 /*----------------------------------------------------------------
2148 * prism2sta_ev_txexc
2150 * Handles the TxExc event. A Transmit Exception event indicates
2151 * that the MAC's TX process was unsuccessful - so the packet did
2152 * not get transmitted.
2155 * wlandev wlan device structure
2156 * status tx frame status word
2165 ----------------------------------------------------------------*/
2166 void prism2sta_ev_txexc(wlandevice_t *wlandev, UINT16 status)
2170 WLAN_LOG_DEBUG(3, "TxExc status=0x%x.\n", status);
2177 /*----------------------------------------------------------------
2180 * Handles the Tx event.
2183 * wlandev wlan device structure
2184 * status tx frame status word
2192 ----------------------------------------------------------------*/
2193 void prism2sta_ev_tx(wlandevice_t *wlandev, UINT16 status)
2196 WLAN_LOG_DEBUG(4, "Tx Complete, status=0x%04x\n", status);
2197 /* update linux network stats */
2198 wlandev->linux_stats.tx_packets++;
2204 /*----------------------------------------------------------------
2207 * Handles the Rx event.
2210 * wlandev wlan device structure
2219 ----------------------------------------------------------------*/
2220 void prism2sta_ev_rx(wlandevice_t *wlandev, struct sk_buff *skb)
2224 p80211netdev_rx(wlandev, skb);
2230 /*----------------------------------------------------------------
2231 * prism2sta_ev_alloc
2233 * Handles the Alloc event.
2236 * wlandev wlan device structure
2245 ----------------------------------------------------------------*/
2246 void prism2sta_ev_alloc(wlandevice_t *wlandev)
2250 p80211netdev_wake_queue(wlandev);
2256 #if (WLAN_HOSTIF == WLAN_PLX || WLAN_HOSTIF == WLAN_PCI)
2258 static int prism2sta_suspend_pci(struct pci_dev *pdev, pm_message_t state)
2260 wlandevice_t *wlandev;
2262 wlandev = (wlandevice_t *) pci_get_drvdata(pdev);
2264 /* reset hardware */
2266 prism2sta_ifstate(wlandev, P80211ENUM_ifstate_disable);
2267 p80211_suspend(wlandev);
2270 // call a netif_device_detach(wlandev->netdev) ?
2275 static int prism2sta_resume_pci (struct pci_dev *pdev)
2277 wlandevice_t *wlandev;
2279 wlandev = (wlandevice_t *) pci_get_drvdata(pdev);
2282 prism2sta_ifstate(wlandev, P80211ENUM_ifstate_disable);
2283 p80211_resume(wlandev);
2291 /*----------------------------------------------------------------
2294 * Called at module init time. This creates the wlandevice_t structure
2295 * and initializes it with relevant bits.
2301 * the created wlandevice_t structure.
2304 * also allocates the priv/hw structures.
2309 ----------------------------------------------------------------*/
2310 static wlandevice_t *create_wlan(void)
2312 wlandevice_t *wlandev = NULL;
2313 hfa384x_t *hw = NULL;
2315 /* Alloc our structures */
2316 wlandev = kmalloc(sizeof(wlandevice_t), GFP_KERNEL);
2317 hw = kmalloc(sizeof(hfa384x_t), GFP_KERNEL);
2319 if (!wlandev || !hw) {
2320 WLAN_LOG_ERROR("%s: Memory allocation failure.\n", dev_info);
2321 if (wlandev) kfree(wlandev);
2326 /* Clear all the structs */
2327 memset(wlandev, 0, sizeof(wlandevice_t));
2328 memset(hw, 0, sizeof(hfa384x_t));
2330 /* Initialize the network device object. */
2331 wlandev->nsdname = dev_info;
2332 wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING;
2334 wlandev->open = prism2sta_open;
2335 wlandev->close = prism2sta_close;
2336 wlandev->reset = prism2sta_reset;
2337 #ifdef CONFIG_PROC_FS
2338 wlandev->nsd_proc_read = prism2sta_proc_read;
2340 wlandev->txframe = prism2sta_txframe;
2341 wlandev->mlmerequest = prism2sta_mlmerequest;
2342 wlandev->set_multicast_list = prism2sta_setmulticast;
2343 wlandev->tx_timeout = hfa384x_tx_timeout;
2345 wlandev->nsdcaps = P80211_NSDCAP_HWFRAGMENT |
2346 P80211_NSDCAP_AUTOJOIN;
2348 /* Initialize the device private data stucture. */
2349 hw->dot11_desired_bss_type = 1;
2354 #ifdef CONFIG_PROC_FS
2356 prism2sta_proc_read(
2365 wlandevice_t *wlandev = (wlandevice_t *) data;
2366 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
2376 // XXX 0x0001 for prism2.5/3, 0x0000 for prism2.
2379 #if (WLAN_HOSTIF != WLAN_USB)
2384 #if (WLAN_HOSTIF == WLAN_PCI)
2388 #define PRISM2_CVS_ID "$Id: prism2sta.c 1826 2007-03-19 15:37:00Z pizza $"
2390 p += sprintf(p, "# %s version %s (%s) '%s'\n\n",
2392 WLAN_RELEASE, WLAN_BUILD_DATE, PRISM2_CVS_ID);
2394 p += sprintf(p, "# nic h/w: id=0x%02x %d.%d.%d\n",
2395 hw->ident_nic.id, hw->ident_nic.major,
2396 hw->ident_nic.minor, hw->ident_nic.variant);
2398 p += sprintf(p, "# pri f/w: id=0x%02x %d.%d.%d\n",
2399 hw->ident_pri_fw.id, hw->ident_pri_fw.major,
2400 hw->ident_pri_fw.minor, hw->ident_pri_fw.variant);
2402 if (hw->ident_sta_fw.id == 0x1f) {
2403 p += sprintf(p, "# sta f/w: id=0x%02x %d.%d.%d\n",
2404 hw->ident_sta_fw.id, hw->ident_sta_fw.major,
2405 hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
2407 p += sprintf(p, "# ap f/w: id=0x%02x %d.%d.%d\n",
2408 hw->ident_sta_fw.id, hw->ident_sta_fw.major,
2409 hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
2412 #if (WLAN_HOSTIF != WLAN_USB)
2413 p += sprintf(p, "# initial nic hw type, needed for SSF ramdl\n");
2414 p += sprintf(p, "initnichw=%04x\n", hwtype);
2423 void prism2sta_commsqual_defer(struct work_struct *data)
2425 hfa384x_t *hw = container_of(data, struct hfa384x, commsqual_bh);
2426 wlandevice_t *wlandev = hw->wlandev;
2427 hfa384x_bytestr32_t ssid;
2432 if (hw->wlandev->hwremoved)
2435 /* we don't care if we're in AP mode */
2436 if ((wlandev->macmode == WLAN_MACMODE_NONE) ||
2437 (wlandev->macmode == WLAN_MACMODE_ESS_AP)) {
2441 /* It only makes sense to poll these in non-IBSS */
2442 if (wlandev->macmode != WLAN_MACMODE_IBSS_STA) {
2443 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_DBMCOMMSQUALITY,
2445 HFA384x_RID_DBMCOMMSQUALITY_LEN);
2448 WLAN_LOG_ERROR("error fetching commsqual\n");
2452 // qual.CQ_currBSS; // link
2453 // ASL_currBSS; // level
2454 // qual.ANL_currFC; // noise
2456 WLAN_LOG_DEBUG(3, "commsqual %d %d %d\n",
2457 hfa384x2host_16(hw->qual.CQ_currBSS),
2458 hfa384x2host_16(hw->qual.ASL_currBSS),
2459 hfa384x2host_16(hw->qual.ANL_currFC));
2462 /* Lastly, we need to make sure the BSSID didn't change on us */
2463 result = hfa384x_drvr_getconfig(hw,
2464 HFA384x_RID_CURRENTBSSID,
2465 wlandev->bssid, WLAN_BSSID_LEN);
2468 "getconfig(0x%02x) failed, result = %d\n",
2469 HFA384x_RID_CURRENTBSSID, result);
2473 result = hfa384x_drvr_getconfig(hw,
2474 HFA384x_RID_CURRENTSSID,
2475 &ssid, sizeof(ssid));
2478 "getconfig(0x%02x) failed, result = %d\n",
2479 HFA384x_RID_CURRENTSSID, result);
2482 prism2mgmt_bytestr2pstr((hfa384x_bytestr_t *)&ssid,
2483 (p80211pstrd_t *) &wlandev->ssid);
2486 /* Reschedule timer */
2487 mod_timer(&hw->commsqual_timer, jiffies + HZ);
2493 void prism2sta_commsqual_timer(unsigned long data)
2495 hfa384x_t *hw = (hfa384x_t *) data;
2499 schedule_work(&hw->commsqual_bh);