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 #include <linux/version.h>
54 #include <linux/module.h>
55 #include <linux/moduleparam.h>
56 #include <linux/kernel.h>
57 #include <linux/sched.h>
58 #include <linux/types.h>
59 #include <linux/init.h>
60 #include <linux/slab.h>
61 #include <linux/wireless.h>
62 #include <linux/netdevice.h>
63 #include <linux/workqueue.h>
64 #include <linux/byteorder/generic.h>
65 #include <linux/ctype.h>
68 #include <linux/delay.h>
69 #include <asm/byteorder.h>
70 #include <linux/if_arp.h>
71 #include <linux/if_ether.h>
72 #include <linux/bitops.h>
74 /*================================================================*/
75 /* Project Includes */
77 #include "p80211types.h"
78 #include "p80211hdr.h"
79 #include "p80211mgmt.h"
80 #include "p80211conv.h"
81 #include "p80211msg.h"
82 #include "p80211netdev.h"
83 #include "p80211req.h"
84 #include "p80211metadef.h"
85 #include "p80211metastruct.h"
87 #include "prism2mgmt.h"
89 #define wlan_hexchar(x) (((x) < 0x0a) ? ('0' + (x)) : ('a' + ((x) - 0x0a)))
91 /* Create a string of printable chars from something that might not be */
92 /* It's recommended that the str be 4*len + 1 bytes long */
93 #define wlan_mkprintstr(buf, buflen, str, strlen) \
97 memset(str, 0, (strlen)); \
98 for (i = 0; i < (buflen); i++) { \
99 if (isprint((buf)[i])) { \
100 (str)[j] = (buf)[i]; \
105 (str)[j+2] = wlan_hexchar(((buf)[i] & 0xf0) >> 4); \
106 (str)[j+3] = wlan_hexchar(((buf)[i] & 0x0f)); \
112 static char *dev_info
= "prism2_usb";
113 static wlandevice_t
*create_wlan(void);
115 int prism2_reset_holdtime
= 30; /* Reset hold time in ms */
116 int prism2_reset_settletime
= 100; /* Reset settle time in ms */
118 static int prism2_doreset
= 0; /* Do a reset at init? */
120 module_param(prism2_doreset
, int, 0644);
121 MODULE_PARM_DESC(prism2_doreset
, "Issue a reset on initialization");
123 module_param(prism2_reset_holdtime
, int, 0644);
124 MODULE_PARM_DESC(prism2_reset_holdtime
, "reset hold time in ms");
125 module_param(prism2_reset_settletime
, int, 0644);
126 MODULE_PARM_DESC(prism2_reset_settletime
, "reset settle time in ms");
128 MODULE_LICENSE("Dual MPL/GPL");
130 static int prism2sta_open(wlandevice_t
* wlandev
);
131 static int prism2sta_close(wlandevice_t
* wlandev
);
132 static void prism2sta_reset(wlandevice_t
* wlandev
);
133 static int prism2sta_txframe(wlandevice_t
* wlandev
, struct sk_buff
*skb
,
134 p80211_hdr_t
* p80211_hdr
,
135 p80211_metawep_t
* p80211_wep
);
136 static int prism2sta_mlmerequest(wlandevice_t
* wlandev
, p80211msg_t
* msg
);
137 static int prism2sta_getcardinfo(wlandevice_t
* wlandev
);
138 static int prism2sta_globalsetup(wlandevice_t
* wlandev
);
139 static int prism2sta_setmulticast(wlandevice_t
* wlandev
, netdevice_t
* dev
);
141 static void prism2sta_inf_handover(wlandevice_t
* wlandev
,
142 hfa384x_InfFrame_t
* inf
);
143 static void prism2sta_inf_tallies(wlandevice_t
* wlandev
,
144 hfa384x_InfFrame_t
* inf
);
145 static void prism2sta_inf_hostscanresults(wlandevice_t
* wlandev
,
146 hfa384x_InfFrame_t
* inf
);
147 static void prism2sta_inf_scanresults(wlandevice_t
* wlandev
,
148 hfa384x_InfFrame_t
* inf
);
149 static void prism2sta_inf_chinforesults(wlandevice_t
* wlandev
,
150 hfa384x_InfFrame_t
* inf
);
151 static void prism2sta_inf_linkstatus(wlandevice_t
* wlandev
,
152 hfa384x_InfFrame_t
* inf
);
153 static void prism2sta_inf_assocstatus(wlandevice_t
* wlandev
,
154 hfa384x_InfFrame_t
* inf
);
155 static void prism2sta_inf_authreq(wlandevice_t
* wlandev
,
156 hfa384x_InfFrame_t
* inf
);
157 static void prism2sta_inf_authreq_defer(wlandevice_t
* wlandev
,
158 hfa384x_InfFrame_t
* inf
);
159 static void prism2sta_inf_psusercnt(wlandevice_t
* wlandev
,
160 hfa384x_InfFrame_t
* inf
);
162 /*----------------------------------------------------------------
165 * WLAN device open method. Called from p80211netdev when kernel
166 * device open (start) method is called in response to the
167 * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
171 * wlandev wlan device structure
175 * >0 f/w reported error
176 * <0 driver reported error
182 ----------------------------------------------------------------*/
183 static int prism2sta_open(wlandevice_t
* wlandev
)
185 /* We don't currently have to do anything else.
186 * The setup of the MAC should be subsequently completed via
188 * Higher layers know we're ready from dev->start==1 and
189 * dev->tbusy==0. Our rx path knows to pass up received/
190 * frames because of dev->flags&IFF_UP is true.
196 /*----------------------------------------------------------------
199 * WLAN device close method. Called from p80211netdev when kernel
200 * device close method is called in response to the
201 * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
205 * wlandev wlan device structure
209 * >0 f/w reported error
210 * <0 driver reported error
216 ----------------------------------------------------------------*/
217 static int prism2sta_close(wlandevice_t
* wlandev
)
219 /* We don't currently have to do anything else.
220 * Higher layers know we're not ready from dev->start==0 and
221 * dev->tbusy==1. Our rx path knows to not pass up received
222 * frames because of dev->flags&IFF_UP is false.
228 /*----------------------------------------------------------------
231 * Not currently implented.
234 * wlandev wlan device structure
244 ----------------------------------------------------------------*/
245 static void prism2sta_reset(wlandevice_t
* wlandev
)
250 /*----------------------------------------------------------------
253 * Takes a frame from p80211 and queues it for transmission.
256 * wlandev wlan device structure
257 * pb packet buffer struct. Contains an 802.11
259 * p80211_hdr points to the 802.11 header for the packet.
261 * 0 Success and more buffs available
262 * 1 Success but no more buffs
263 * 2 Allocation failure
264 * 4 Buffer full or queue busy
270 ----------------------------------------------------------------*/
271 static int prism2sta_txframe(wlandevice_t
* wlandev
, struct sk_buff
*skb
,
272 p80211_hdr_t
* p80211_hdr
,
273 p80211_metawep_t
* p80211_wep
)
275 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
278 /* If necessary, set the 802.11 WEP bit */
279 if ((wlandev
->hostwep
& (HOSTWEP_PRIVACYINVOKED
| HOSTWEP_ENCRYPT
)) ==
280 HOSTWEP_PRIVACYINVOKED
) {
281 p80211_hdr
->a3
.fc
|= cpu_to_le16(WLAN_SET_FC_ISWEP(1));
284 result
= hfa384x_drvr_txframe(hw
, skb
, p80211_hdr
, p80211_wep
);
289 /*----------------------------------------------------------------
290 * prism2sta_mlmerequest
292 * wlan command message handler. All we do here is pass the message
293 * over to the prism2sta_mgmt_handler.
296 * wlandev wlan device structure
297 * msg wlan command message
300 * <0 successful acceptance of message, but we're
301 * waiting for an async process to finish before
302 * we're done with the msg. When the asynch
303 * process is done, we'll call the p80211
304 * function p80211req_confirm() .
305 * >0 An error occurred while we were handling
312 ----------------------------------------------------------------*/
313 static int prism2sta_mlmerequest(wlandevice_t
* wlandev
, p80211msg_t
* msg
)
315 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
319 switch (msg
->msgcode
) {
320 case DIDmsg_dot11req_mibget
:
321 pr_debug("Received mibget request\n");
322 result
= prism2mgmt_mibset_mibget(wlandev
, msg
);
324 case DIDmsg_dot11req_mibset
:
325 pr_debug("Received mibset request\n");
326 result
= prism2mgmt_mibset_mibget(wlandev
, msg
);
328 case DIDmsg_dot11req_scan
:
329 pr_debug("Received scan request\n");
330 result
= prism2mgmt_scan(wlandev
, msg
);
332 case DIDmsg_dot11req_scan_results
:
333 pr_debug("Received scan_results request\n");
334 result
= prism2mgmt_scan_results(wlandev
, msg
);
336 case DIDmsg_dot11req_start
:
337 pr_debug("Received mlme start request\n");
338 result
= prism2mgmt_start(wlandev
, msg
);
341 * Prism2 specific messages
343 case DIDmsg_p2req_readpda
:
344 pr_debug("Received mlme readpda request\n");
345 result
= prism2mgmt_readpda(wlandev
, msg
);
347 case DIDmsg_p2req_ramdl_state
:
348 pr_debug("Received mlme ramdl_state request\n");
349 result
= prism2mgmt_ramdl_state(wlandev
, msg
);
351 case DIDmsg_p2req_ramdl_write
:
352 pr_debug("Received mlme ramdl_write request\n");
353 result
= prism2mgmt_ramdl_write(wlandev
, msg
);
355 case DIDmsg_p2req_flashdl_state
:
356 pr_debug("Received mlme flashdl_state request\n");
357 result
= prism2mgmt_flashdl_state(wlandev
, msg
);
359 case DIDmsg_p2req_flashdl_write
:
360 pr_debug("Received mlme flashdl_write request\n");
361 result
= prism2mgmt_flashdl_write(wlandev
, msg
);
364 * Linux specific messages
366 case DIDmsg_lnxreq_hostwep
:
367 break; /* ignore me. */
368 case DIDmsg_lnxreq_ifstate
:
370 p80211msg_lnxreq_ifstate_t
*ifstatemsg
;
371 pr_debug("Received mlme ifstate request\n");
372 ifstatemsg
= (p80211msg_lnxreq_ifstate_t
*) msg
;
374 prism2sta_ifstate(wlandev
,
375 ifstatemsg
->ifstate
.data
);
376 ifstatemsg
->resultcode
.status
=
377 P80211ENUM_msgitem_status_data_ok
;
378 ifstatemsg
->resultcode
.data
= result
;
382 case DIDmsg_lnxreq_wlansniff
:
383 pr_debug("Received mlme wlansniff request\n");
384 result
= prism2mgmt_wlansniff(wlandev
, msg
);
386 case DIDmsg_lnxreq_autojoin
:
387 pr_debug("Received mlme autojoin request\n");
388 result
= prism2mgmt_autojoin(wlandev
, msg
);
390 case DIDmsg_lnxreq_commsquality
:{
391 p80211msg_lnxreq_commsquality_t
*qualmsg
;
393 pr_debug("Received commsquality request\n");
395 qualmsg
= (p80211msg_lnxreq_commsquality_t
*) msg
;
397 qualmsg
->link
.status
=
398 P80211ENUM_msgitem_status_data_ok
;
399 qualmsg
->level
.status
=
400 P80211ENUM_msgitem_status_data_ok
;
401 qualmsg
->noise
.status
=
402 P80211ENUM_msgitem_status_data_ok
;
404 qualmsg
->link
.data
= le16_to_cpu(hw
->qual
.CQ_currBSS
);
405 qualmsg
->level
.data
= le16_to_cpu(hw
->qual
.ASL_currBSS
);
406 qualmsg
->noise
.data
= le16_to_cpu(hw
->qual
.ANL_currFC
);
411 printk(KERN_WARNING
"Unknown mgmt request message 0x%08x",
419 /*----------------------------------------------------------------
422 * Interface state. This is the primary WLAN interface enable/disable
423 * handler. Following the driver/load/deviceprobe sequence, this
424 * function must be called with a state of "enable" before any other
425 * commands will be accepted.
428 * wlandev wlan device structure
429 * msgp ptr to msg buffer
432 * A p80211 message resultcode value.
437 * process thread (usually)
439 ----------------------------------------------------------------*/
440 u32
prism2sta_ifstate(wlandevice_t
* wlandev
, u32 ifstate
)
442 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
445 result
= P80211ENUM_resultcode_implementation_failure
;
447 pr_debug("Current MSD state(%d), requesting(%d)\n",
448 wlandev
->msdstate
, ifstate
);
450 case P80211ENUM_ifstate_fwload
:
451 switch (wlandev
->msdstate
) {
452 case WLAN_MSD_HWPRESENT
:
453 wlandev
->msdstate
= WLAN_MSD_FWLOAD_PENDING
;
455 * Initialize the device+driver sufficiently
456 * for firmware loading.
458 if ((result
= hfa384x_drvr_start(hw
))) {
460 "hfa384x_drvr_start() failed,"
461 "result=%d\n", (int)result
);
463 P80211ENUM_resultcode_implementation_failure
;
464 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
467 wlandev
->msdstate
= WLAN_MSD_FWLOAD
;
468 result
= P80211ENUM_resultcode_success
;
470 case WLAN_MSD_FWLOAD
:
471 hfa384x_cmd_initialize(hw
);
472 result
= P80211ENUM_resultcode_success
;
474 case WLAN_MSD_RUNNING
:
476 "Cannot enter fwload state from enable state,"
477 "you must disable first.\n");
478 result
= P80211ENUM_resultcode_invalid_parameters
;
480 case WLAN_MSD_HWFAIL
:
482 /* probe() had a problem or the msdstate contains
483 * an unrecognized value, there's nothing we can do.
485 result
= P80211ENUM_resultcode_implementation_failure
;
489 case P80211ENUM_ifstate_enable
:
490 switch (wlandev
->msdstate
) {
491 case WLAN_MSD_HWPRESENT
:
492 case WLAN_MSD_FWLOAD
:
493 wlandev
->msdstate
= WLAN_MSD_RUNNING_PENDING
;
494 /* Initialize the device+driver for full
495 * operation. Note that this might me an FWLOAD to
496 * to RUNNING transition so we must not do a chip
497 * or board level reset. Note that on failure,
498 * the MSD state is set to HWPRESENT because we
499 * can't make any assumptions about the state
500 * of the hardware or a previous firmware load.
502 if ((result
= hfa384x_drvr_start(hw
))) {
504 "hfa384x_drvr_start() failed,"
505 "result=%d\n", (int)result
);
507 P80211ENUM_resultcode_implementation_failure
;
508 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
512 if ((result
= prism2sta_getcardinfo(wlandev
))) {
514 "prism2sta_getcardinfo() failed,"
515 "result=%d\n", (int)result
);
517 P80211ENUM_resultcode_implementation_failure
;
518 hfa384x_drvr_stop(hw
);
519 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
522 if ((result
= prism2sta_globalsetup(wlandev
))) {
524 "prism2sta_globalsetup() failed,"
525 "result=%d\n", (int)result
);
527 P80211ENUM_resultcode_implementation_failure
;
528 hfa384x_drvr_stop(hw
);
529 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
532 wlandev
->msdstate
= WLAN_MSD_RUNNING
;
534 hw
->join_retries
= 60;
535 result
= P80211ENUM_resultcode_success
;
537 case WLAN_MSD_RUNNING
:
538 /* Do nothing, we're already in this state. */
539 result
= P80211ENUM_resultcode_success
;
541 case WLAN_MSD_HWFAIL
:
543 /* probe() had a problem or the msdstate contains
544 * an unrecognized value, there's nothing we can do.
546 result
= P80211ENUM_resultcode_implementation_failure
;
550 case P80211ENUM_ifstate_disable
:
551 switch (wlandev
->msdstate
) {
552 case WLAN_MSD_HWPRESENT
:
553 /* Do nothing, we're already in this state. */
554 result
= P80211ENUM_resultcode_success
;
556 case WLAN_MSD_FWLOAD
:
557 case WLAN_MSD_RUNNING
:
558 wlandev
->msdstate
= WLAN_MSD_HWPRESENT_PENDING
;
560 * TODO: Shut down the MAC completely. Here a chip
561 * or board level reset is probably called for.
562 * After a "disable" _all_ results are lost, even
563 * those from a fwload.
565 if (!wlandev
->hwremoved
)
566 netif_carrier_off(wlandev
->netdev
);
568 hfa384x_drvr_stop(hw
);
570 wlandev
->macmode
= WLAN_MACMODE_NONE
;
571 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
572 result
= P80211ENUM_resultcode_success
;
574 case WLAN_MSD_HWFAIL
:
576 /* probe() had a problem or the msdstate contains
577 * an unrecognized value, there's nothing we can do.
579 result
= P80211ENUM_resultcode_implementation_failure
;
584 result
= P80211ENUM_resultcode_invalid_parameters
;
591 /*----------------------------------------------------------------
592 * prism2sta_getcardinfo
594 * Collect the NICID, firmware version and any other identifiers
595 * we'd like to have in host-side data structures.
598 * wlandev wlan device structure
602 * >0 f/w reported error
603 * <0 driver reported error
609 ----------------------------------------------------------------*/
610 static int prism2sta_getcardinfo(wlandevice_t
* wlandev
)
613 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
615 u8 snum
[HFA384x_RID_NICSERIALNUMBER_LEN
];
616 char pstr
[(HFA384x_RID_NICSERIALNUMBER_LEN
* 4) + 1];
618 /* Collect version and compatibility info */
619 /* Some are critical, some are not */
621 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_NICIDENTITY
,
623 sizeof(hfa384x_compident_t
));
625 printk(KERN_ERR
"Failed to retrieve NICIDENTITY\n");
629 /* get all the nic id fields in host byte order */
630 hw
->ident_nic
.id
= le16_to_cpu(hw
->ident_nic
.id
);
631 hw
->ident_nic
.variant
= le16_to_cpu(hw
->ident_nic
.variant
);
632 hw
->ident_nic
.major
= le16_to_cpu(hw
->ident_nic
.major
);
633 hw
->ident_nic
.minor
= le16_to_cpu(hw
->ident_nic
.minor
);
635 printk(KERN_INFO
"ident: nic h/w: id=0x%02x %d.%d.%d\n",
636 hw
->ident_nic
.id
, hw
->ident_nic
.major
,
637 hw
->ident_nic
.minor
, hw
->ident_nic
.variant
);
639 /* Primary f/w identity */
640 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_PRIIDENTITY
,
642 sizeof(hfa384x_compident_t
));
644 printk(KERN_ERR
"Failed to retrieve PRIIDENTITY\n");
648 /* get all the private fw id fields in host byte order */
649 hw
->ident_pri_fw
.id
= le16_to_cpu(hw
->ident_pri_fw
.id
);
650 hw
->ident_pri_fw
.variant
= le16_to_cpu(hw
->ident_pri_fw
.variant
);
651 hw
->ident_pri_fw
.major
= le16_to_cpu(hw
->ident_pri_fw
.major
);
652 hw
->ident_pri_fw
.minor
= le16_to_cpu(hw
->ident_pri_fw
.minor
);
654 printk(KERN_INFO
"ident: pri f/w: id=0x%02x %d.%d.%d\n",
655 hw
->ident_pri_fw
.id
, hw
->ident_pri_fw
.major
,
656 hw
->ident_pri_fw
.minor
, hw
->ident_pri_fw
.variant
);
658 /* Station (Secondary?) f/w identity */
659 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_STAIDENTITY
,
661 sizeof(hfa384x_compident_t
));
663 printk(KERN_ERR
"Failed to retrieve STAIDENTITY\n");
667 if (hw
->ident_nic
.id
< 0x8000) {
669 "FATAL: Card is not an Intersil Prism2/2.5/3\n");
674 /* get all the station fw id fields in host byte order */
675 hw
->ident_sta_fw
.id
= le16_to_cpu(hw
->ident_sta_fw
.id
);
676 hw
->ident_sta_fw
.variant
= le16_to_cpu(hw
->ident_sta_fw
.variant
);
677 hw
->ident_sta_fw
.major
= le16_to_cpu(hw
->ident_sta_fw
.major
);
678 hw
->ident_sta_fw
.minor
= le16_to_cpu(hw
->ident_sta_fw
.minor
);
680 /* strip out the 'special' variant bits */
681 hw
->mm_mods
= hw
->ident_sta_fw
.variant
& (BIT(14) | BIT(15));
682 hw
->ident_sta_fw
.variant
&= ~((u16
) (BIT(14) | BIT(15)));
684 if (hw
->ident_sta_fw
.id
== 0x1f) {
686 "ident: sta f/w: id=0x%02x %d.%d.%d\n",
687 hw
->ident_sta_fw
.id
, hw
->ident_sta_fw
.major
,
688 hw
->ident_sta_fw
.minor
, hw
->ident_sta_fw
.variant
);
691 "ident: ap f/w: id=0x%02x %d.%d.%d\n",
692 hw
->ident_sta_fw
.id
, hw
->ident_sta_fw
.major
,
693 hw
->ident_sta_fw
.minor
, hw
->ident_sta_fw
.variant
);
694 printk(KERN_ERR
"Unsupported Tertiary AP firmeare loaded!\n");
698 /* Compatibility range, Modem supplier */
699 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_MFISUPRANGE
,
701 sizeof(hfa384x_caplevel_t
));
703 printk(KERN_ERR
"Failed to retrieve MFISUPRANGE\n");
707 /* get all the Compatibility range, modem interface supplier
708 fields in byte order */
709 hw
->cap_sup_mfi
.role
= le16_to_cpu(hw
->cap_sup_mfi
.role
);
710 hw
->cap_sup_mfi
.id
= le16_to_cpu(hw
->cap_sup_mfi
.id
);
711 hw
->cap_sup_mfi
.variant
= le16_to_cpu(hw
->cap_sup_mfi
.variant
);
712 hw
->cap_sup_mfi
.bottom
= le16_to_cpu(hw
->cap_sup_mfi
.bottom
);
713 hw
->cap_sup_mfi
.top
= le16_to_cpu(hw
->cap_sup_mfi
.top
);
716 "MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
717 hw
->cap_sup_mfi
.role
, hw
->cap_sup_mfi
.id
,
718 hw
->cap_sup_mfi
.variant
, hw
->cap_sup_mfi
.bottom
,
719 hw
->cap_sup_mfi
.top
);
721 /* Compatibility range, Controller supplier */
722 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_CFISUPRANGE
,
724 sizeof(hfa384x_caplevel_t
));
726 printk(KERN_ERR
"Failed to retrieve CFISUPRANGE\n");
730 /* get all the Compatibility range, controller interface supplier
731 fields in byte order */
732 hw
->cap_sup_cfi
.role
= le16_to_cpu(hw
->cap_sup_cfi
.role
);
733 hw
->cap_sup_cfi
.id
= le16_to_cpu(hw
->cap_sup_cfi
.id
);
734 hw
->cap_sup_cfi
.variant
= le16_to_cpu(hw
->cap_sup_cfi
.variant
);
735 hw
->cap_sup_cfi
.bottom
= le16_to_cpu(hw
->cap_sup_cfi
.bottom
);
736 hw
->cap_sup_cfi
.top
= le16_to_cpu(hw
->cap_sup_cfi
.top
);
739 "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
740 hw
->cap_sup_cfi
.role
, hw
->cap_sup_cfi
.id
,
741 hw
->cap_sup_cfi
.variant
, hw
->cap_sup_cfi
.bottom
,
742 hw
->cap_sup_cfi
.top
);
744 /* Compatibility range, Primary f/w supplier */
745 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_PRISUPRANGE
,
747 sizeof(hfa384x_caplevel_t
));
749 printk(KERN_ERR
"Failed to retrieve PRISUPRANGE\n");
753 /* get all the Compatibility range, primary firmware supplier
754 fields in byte order */
755 hw
->cap_sup_pri
.role
= le16_to_cpu(hw
->cap_sup_pri
.role
);
756 hw
->cap_sup_pri
.id
= le16_to_cpu(hw
->cap_sup_pri
.id
);
757 hw
->cap_sup_pri
.variant
= le16_to_cpu(hw
->cap_sup_pri
.variant
);
758 hw
->cap_sup_pri
.bottom
= le16_to_cpu(hw
->cap_sup_pri
.bottom
);
759 hw
->cap_sup_pri
.top
= le16_to_cpu(hw
->cap_sup_pri
.top
);
762 "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
763 hw
->cap_sup_pri
.role
, hw
->cap_sup_pri
.id
,
764 hw
->cap_sup_pri
.variant
, hw
->cap_sup_pri
.bottom
,
765 hw
->cap_sup_pri
.top
);
767 /* Compatibility range, Station f/w supplier */
768 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_STASUPRANGE
,
770 sizeof(hfa384x_caplevel_t
));
772 printk(KERN_ERR
"Failed to retrieve STASUPRANGE\n");
776 /* get all the Compatibility range, station firmware supplier
777 fields in byte order */
778 hw
->cap_sup_sta
.role
= le16_to_cpu(hw
->cap_sup_sta
.role
);
779 hw
->cap_sup_sta
.id
= le16_to_cpu(hw
->cap_sup_sta
.id
);
780 hw
->cap_sup_sta
.variant
= le16_to_cpu(hw
->cap_sup_sta
.variant
);
781 hw
->cap_sup_sta
.bottom
= le16_to_cpu(hw
->cap_sup_sta
.bottom
);
782 hw
->cap_sup_sta
.top
= le16_to_cpu(hw
->cap_sup_sta
.top
);
784 if (hw
->cap_sup_sta
.id
== 0x04) {
786 "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
787 hw
->cap_sup_sta
.role
, hw
->cap_sup_sta
.id
,
788 hw
->cap_sup_sta
.variant
, hw
->cap_sup_sta
.bottom
,
789 hw
->cap_sup_sta
.top
);
792 "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
793 hw
->cap_sup_sta
.role
, hw
->cap_sup_sta
.id
,
794 hw
->cap_sup_sta
.variant
, hw
->cap_sup_sta
.bottom
,
795 hw
->cap_sup_sta
.top
);
798 /* Compatibility range, primary f/w actor, CFI supplier */
799 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_PRI_CFIACTRANGES
,
800 &hw
->cap_act_pri_cfi
,
801 sizeof(hfa384x_caplevel_t
));
803 printk(KERN_ERR
"Failed to retrieve PRI_CFIACTRANGES\n");
807 /* get all the Compatibility range, primary f/w actor, CFI supplier
808 fields in byte order */
809 hw
->cap_act_pri_cfi
.role
= le16_to_cpu(hw
->cap_act_pri_cfi
.role
);
810 hw
->cap_act_pri_cfi
.id
= le16_to_cpu(hw
->cap_act_pri_cfi
.id
);
811 hw
->cap_act_pri_cfi
.variant
= le16_to_cpu(hw
->cap_act_pri_cfi
.variant
);
812 hw
->cap_act_pri_cfi
.bottom
= le16_to_cpu(hw
->cap_act_pri_cfi
.bottom
);
813 hw
->cap_act_pri_cfi
.top
= le16_to_cpu(hw
->cap_act_pri_cfi
.top
);
816 "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
817 hw
->cap_act_pri_cfi
.role
, hw
->cap_act_pri_cfi
.id
,
818 hw
->cap_act_pri_cfi
.variant
, hw
->cap_act_pri_cfi
.bottom
,
819 hw
->cap_act_pri_cfi
.top
);
821 /* Compatibility range, sta f/w actor, CFI supplier */
822 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_STA_CFIACTRANGES
,
823 &hw
->cap_act_sta_cfi
,
824 sizeof(hfa384x_caplevel_t
));
826 printk(KERN_ERR
"Failed to retrieve STA_CFIACTRANGES\n");
830 /* get all the Compatibility range, station f/w actor, CFI supplier
831 fields in byte order */
832 hw
->cap_act_sta_cfi
.role
= le16_to_cpu(hw
->cap_act_sta_cfi
.role
);
833 hw
->cap_act_sta_cfi
.id
= le16_to_cpu(hw
->cap_act_sta_cfi
.id
);
834 hw
->cap_act_sta_cfi
.variant
= le16_to_cpu(hw
->cap_act_sta_cfi
.variant
);
835 hw
->cap_act_sta_cfi
.bottom
= le16_to_cpu(hw
->cap_act_sta_cfi
.bottom
);
836 hw
->cap_act_sta_cfi
.top
= le16_to_cpu(hw
->cap_act_sta_cfi
.top
);
839 "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
840 hw
->cap_act_sta_cfi
.role
, hw
->cap_act_sta_cfi
.id
,
841 hw
->cap_act_sta_cfi
.variant
, hw
->cap_act_sta_cfi
.bottom
,
842 hw
->cap_act_sta_cfi
.top
);
844 /* Compatibility range, sta f/w actor, MFI supplier */
845 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_STA_MFIACTRANGES
,
846 &hw
->cap_act_sta_mfi
,
847 sizeof(hfa384x_caplevel_t
));
849 printk(KERN_ERR
"Failed to retrieve STA_MFIACTRANGES\n");
853 /* get all the Compatibility range, station f/w actor, MFI supplier
854 fields in byte order */
855 hw
->cap_act_sta_mfi
.role
= le16_to_cpu(hw
->cap_act_sta_mfi
.role
);
856 hw
->cap_act_sta_mfi
.id
= le16_to_cpu(hw
->cap_act_sta_mfi
.id
);
857 hw
->cap_act_sta_mfi
.variant
= le16_to_cpu(hw
->cap_act_sta_mfi
.variant
);
858 hw
->cap_act_sta_mfi
.bottom
= le16_to_cpu(hw
->cap_act_sta_mfi
.bottom
);
859 hw
->cap_act_sta_mfi
.top
= le16_to_cpu(hw
->cap_act_sta_mfi
.top
);
862 "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
863 hw
->cap_act_sta_mfi
.role
, hw
->cap_act_sta_mfi
.id
,
864 hw
->cap_act_sta_mfi
.variant
, hw
->cap_act_sta_mfi
.bottom
,
865 hw
->cap_act_sta_mfi
.top
);
868 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_NICSERIALNUMBER
,
869 snum
, HFA384x_RID_NICSERIALNUMBER_LEN
);
871 wlan_mkprintstr(snum
, HFA384x_RID_NICSERIALNUMBER_LEN
,
873 printk(KERN_INFO
"Prism2 card SN: %s\n", pstr
);
875 printk(KERN_ERR
"Failed to retrieve Prism2 Card SN\n");
879 /* Collect the MAC address */
880 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_CNFOWNMACADDR
,
881 wlandev
->netdev
->dev_addr
, ETH_ALEN
);
883 printk(KERN_ERR
"Failed to retrieve mac address\n");
887 /* short preamble is always implemented */
888 wlandev
->nsdcaps
|= P80211_NSDCAP_SHORT_PREAMBLE
;
890 /* find out if hardware wep is implemented */
891 hfa384x_drvr_getconfig16(hw
, HFA384x_RID_PRIVACYOPTIMP
, &temp
);
893 wlandev
->nsdcaps
|= P80211_NSDCAP_HARDWAREWEP
;
895 /* get the dBm Scaling constant */
896 hfa384x_drvr_getconfig16(hw
, HFA384x_RID_CNFDBMADJUST
, &temp
);
897 hw
->dbmadjust
= temp
;
899 /* Only enable scan by default on newer firmware */
900 if (HFA384x_FIRMWARE_VERSION(hw
->ident_sta_fw
.major
,
901 hw
->ident_sta_fw
.minor
,
902 hw
->ident_sta_fw
.variant
) <
903 HFA384x_FIRMWARE_VERSION(1, 5, 5)) {
904 wlandev
->nsdcaps
|= P80211_NSDCAP_NOSCAN
;
907 /* TODO: Set any internally managed config items */
911 printk(KERN_ERR
"Failed, result=%d\n", result
);
916 /*----------------------------------------------------------------
917 * prism2sta_globalsetup
919 * Set any global RIDs that we want to set at device activation.
922 * wlandev wlan device structure
926 * >0 f/w reported error
927 * <0 driver reported error
933 ----------------------------------------------------------------*/
934 static int prism2sta_globalsetup(wlandevice_t
* wlandev
)
936 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
938 /* Set the maximum frame size */
939 return hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFMAXDATALEN
,
943 static int prism2sta_setmulticast(wlandevice_t
* wlandev
, netdevice_t
* dev
)
946 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
950 /* If we're not ready, what's the point? */
951 if (hw
->state
!= HFA384x_STATE_RUNNING
)
954 if ((dev
->flags
& (IFF_PROMISC
| IFF_ALLMULTI
)) != 0)
955 promisc
= P80211ENUM_truth_true
;
957 promisc
= P80211ENUM_truth_false
;
960 hfa384x_drvr_setconfig16_async(hw
, HFA384x_RID_PROMISCMODE
,
966 /*----------------------------------------------------------------
967 * prism2sta_inf_handover
969 * Handles the receipt of a Handover info frame. Should only be present
973 * wlandev wlan device structure
974 * inf ptr to info frame (contents in hfa384x order)
983 ----------------------------------------------------------------*/
984 static void prism2sta_inf_handover(wlandevice_t
* wlandev
,
985 hfa384x_InfFrame_t
* inf
)
987 pr_debug("received infoframe:HANDOVER (unhandled)\n");
991 /*----------------------------------------------------------------
992 * prism2sta_inf_tallies
994 * Handles the receipt of a CommTallies info frame.
997 * wlandev wlan device structure
998 * inf ptr to info frame (contents in hfa384x order)
1007 ----------------------------------------------------------------*/
1008 static void prism2sta_inf_tallies(wlandevice_t
* wlandev
,
1009 hfa384x_InfFrame_t
* inf
)
1011 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1019 ** Determine if these are 16-bit or 32-bit tallies, based on the
1020 ** record length of the info record.
1023 cnt
= sizeof(hfa384x_CommTallies32_t
) / sizeof(u32
);
1024 if (inf
->framelen
> 22) {
1025 dst
= (u32
*) & hw
->tallies
;
1026 src32
= (u32
*) & inf
->info
.commtallies32
;
1027 for (i
= 0; i
< cnt
; i
++, dst
++, src32
++)
1028 *dst
+= le32_to_cpu(*src32
);
1030 dst
= (u32
*) & hw
->tallies
;
1031 src16
= (u16
*) & inf
->info
.commtallies16
;
1032 for (i
= 0; i
< cnt
; i
++, dst
++, src16
++)
1033 *dst
+= le16_to_cpu(*src16
);
1039 /*----------------------------------------------------------------
1040 * prism2sta_inf_scanresults
1042 * Handles the receipt of a Scan Results info frame.
1045 * wlandev wlan device structure
1046 * inf ptr to info frame (contents in hfa384x order)
1055 ----------------------------------------------------------------*/
1056 static void prism2sta_inf_scanresults(wlandevice_t
* wlandev
,
1057 hfa384x_InfFrame_t
* inf
)
1060 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1062 hfa384x_ScanResult_t
*sr
= &(inf
->info
.scanresult
);
1064 hfa384x_JoinRequest_data_t joinreq
;
1067 /* Get the number of results, first in bytes, then in results */
1068 nbss
= (inf
->framelen
* sizeof(u16
)) -
1069 sizeof(inf
->infotype
) - sizeof(inf
->info
.scanresult
.scanreason
);
1070 nbss
/= sizeof(hfa384x_ScanResultSub_t
);
1073 pr_debug("rx scanresults, reason=%d, nbss=%d:\n",
1074 inf
->info
.scanresult
.scanreason
, nbss
);
1075 for (i
= 0; i
< nbss
; i
++) {
1076 pr_debug("chid=%d anl=%d sl=%d bcnint=%d\n",
1079 sr
->result
[i
].sl
, sr
->result
[i
].bcnint
);
1080 pr_debug(" capinfo=0x%04x proberesp_rate=%d\n",
1081 sr
->result
[i
].capinfo
, sr
->result
[i
].proberesp_rate
);
1083 /* issue a join request */
1084 joinreq
.channel
= sr
->result
[0].chid
;
1085 memcpy(joinreq
.bssid
, sr
->result
[0].bssid
, WLAN_BSSID_LEN
);
1086 result
= hfa384x_drvr_setconfig(hw
,
1087 HFA384x_RID_JOINREQUEST
,
1088 &joinreq
, HFA384x_RID_JOINREQUEST_LEN
);
1090 printk(KERN_ERR
"setconfig(joinreq) failed, result=%d\n",
1097 /*----------------------------------------------------------------
1098 * prism2sta_inf_hostscanresults
1100 * Handles the receipt of a Scan Results info frame.
1103 * wlandev wlan device structure
1104 * inf ptr to info frame (contents in hfa384x order)
1113 ----------------------------------------------------------------*/
1114 static void prism2sta_inf_hostscanresults(wlandevice_t
* wlandev
,
1115 hfa384x_InfFrame_t
* inf
)
1117 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1120 nbss
= (inf
->framelen
- 3) / 32;
1121 pr_debug("Received %d hostscan results\n", nbss
);
1126 kfree(hw
->scanresults
);
1128 hw
->scanresults
= kmalloc(sizeof(hfa384x_InfFrame_t
), GFP_ATOMIC
);
1129 memcpy(hw
->scanresults
, inf
, sizeof(hfa384x_InfFrame_t
));
1134 /* Notify/wake the sleeping caller. */
1135 hw
->scanflag
= nbss
;
1136 wake_up_interruptible(&hw
->cmdq
);
1139 /*----------------------------------------------------------------
1140 * prism2sta_inf_chinforesults
1142 * Handles the receipt of a Channel Info Results info frame.
1145 * wlandev wlan device structure
1146 * inf ptr to info frame (contents in hfa384x order)
1155 ----------------------------------------------------------------*/
1156 static void prism2sta_inf_chinforesults(wlandevice_t
* wlandev
,
1157 hfa384x_InfFrame_t
* inf
)
1159 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1162 hw
->channel_info
.results
.scanchannels
=
1163 le16_to_cpu(inf
->info
.chinforesult
.scanchannels
);
1165 for (i
= 0, n
= 0; i
< HFA384x_CHINFORESULT_MAX
; i
++) {
1166 if (hw
->channel_info
.results
.scanchannels
& (1 << i
)) {
1168 le16_to_cpu(inf
->info
.chinforesult
.result
[n
].chid
) -
1170 hfa384x_ChInfoResultSub_t
*chinforesult
=
1171 &hw
->channel_info
.results
.result
[channel
];
1172 chinforesult
->chid
= channel
;
1174 le16_to_cpu(inf
->info
.chinforesult
.result
[n
].anl
);
1176 le16_to_cpu(inf
->info
.chinforesult
.result
[n
].pnl
);
1177 chinforesult
->active
=
1178 le16_to_cpu(inf
->info
.chinforesult
.result
[n
].
1181 ("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n",
1184 active
& HFA384x_CHINFORESULT_BSSACTIVE
? "signal"
1185 : "noise", chinforesult
->anl
, chinforesult
->pnl
,
1187 active
& HFA384x_CHINFORESULT_PCFACTIVE
? 1 : 0);
1191 atomic_set(&hw
->channel_info
.done
, 2);
1193 hw
->channel_info
.count
= n
;
1197 void prism2sta_processing_defer(struct work_struct
*data
)
1199 hfa384x_t
*hw
= container_of(data
, struct hfa384x
, link_bh
);
1200 wlandevice_t
*wlandev
= hw
->wlandev
;
1201 hfa384x_bytestr32_t ssid
;
1204 /* First let's process the auth frames */
1206 struct sk_buff
*skb
;
1207 hfa384x_InfFrame_t
*inf
;
1209 while ((skb
= skb_dequeue(&hw
->authq
))) {
1210 inf
= (hfa384x_InfFrame_t
*) skb
->data
;
1211 prism2sta_inf_authreq_defer(wlandev
, inf
);
1216 /* Now let's handle the linkstatus stuff */
1217 if (hw
->link_status
== hw
->link_status_new
)
1220 hw
->link_status
= hw
->link_status_new
;
1222 switch (hw
->link_status
) {
1223 case HFA384x_LINK_NOTCONNECTED
:
1224 /* I'm currently assuming that this is the initial link
1225 * state. It should only be possible immediately
1226 * following an Enable command.
1228 * Block Transmits, Ignore receives of data frames
1230 netif_carrier_off(wlandev
->netdev
);
1232 printk(KERN_INFO
"linkstatus=NOTCONNECTED (unhandled)\n");
1235 case HFA384x_LINK_CONNECTED
:
1236 /* This one indicates a successful scan/join/auth/assoc.
1237 * When we have the full MLME complement, this event will
1238 * signify successful completion of both mlme_authenticate
1239 * and mlme_associate. State management will get a little
1242 * Indicate authentication and/or association
1243 * Enable Transmits, Receives and pass up data frames
1246 netif_carrier_on(wlandev
->netdev
);
1248 /* If we are joining a specific AP, set our state and reset retries */
1249 if (hw
->join_ap
== 1)
1251 hw
->join_retries
= 60;
1253 /* Don't call this in monitor mode */
1254 if (wlandev
->netdev
->type
== ARPHRD_ETHER
) {
1257 printk(KERN_INFO
"linkstatus=CONNECTED\n");
1259 /* For non-usb devices, we can use the sync versions */
1260 /* Collect the BSSID, and set state to allow tx */
1262 result
= hfa384x_drvr_getconfig(hw
,
1263 HFA384x_RID_CURRENTBSSID
,
1268 ("getconfig(0x%02x) failed, result = %d\n",
1269 HFA384x_RID_CURRENTBSSID
, result
);
1273 result
= hfa384x_drvr_getconfig(hw
,
1274 HFA384x_RID_CURRENTSSID
,
1275 &ssid
, sizeof(ssid
));
1278 ("getconfig(0x%02x) failed, result = %d\n",
1279 HFA384x_RID_CURRENTSSID
, result
);
1282 prism2mgmt_bytestr2pstr((hfa384x_bytestr_t
*) & ssid
,
1286 /* Collect the port status */
1287 result
= hfa384x_drvr_getconfig16(hw
,
1288 HFA384x_RID_PORTSTATUS
,
1292 ("getconfig(0x%02x) failed, result = %d\n",
1293 HFA384x_RID_PORTSTATUS
, result
);
1297 (portstatus
== HFA384x_PSTATUS_CONN_IBSS
) ?
1298 WLAN_MACMODE_IBSS_STA
: WLAN_MACMODE_ESS_STA
;
1300 /* Get the ball rolling on the comms quality stuff */
1301 prism2sta_commsqual_defer(&hw
->commsqual_bh
);
1305 case HFA384x_LINK_DISCONNECTED
:
1306 /* This one indicates that our association is gone. We've
1307 * lost connection with the AP and/or been disassociated.
1308 * This indicates that the MAC has completely cleared it's
1309 * associated state. We * should send a deauth indication
1310 * (implying disassoc) up * to the MLME.
1312 * Indicate Deauthentication
1313 * Block Transmits, Ignore receives of data frames
1315 if (hw
->join_ap
== 2) {
1316 hfa384x_JoinRequest_data_t joinreq
;
1317 joinreq
= hw
->joinreq
;
1318 /* Send the join request */
1319 hfa384x_drvr_setconfig(hw
,
1320 HFA384x_RID_JOINREQUEST
,
1322 HFA384x_RID_JOINREQUEST_LEN
);
1324 "linkstatus=DISCONNECTED (re-submitting join)\n");
1326 if (wlandev
->netdev
->type
== ARPHRD_ETHER
)
1328 "linkstatus=DISCONNECTED (unhandled)\n");
1330 wlandev
->macmode
= WLAN_MACMODE_NONE
;
1332 netif_carrier_off(wlandev
->netdev
);
1336 case HFA384x_LINK_AP_CHANGE
:
1337 /* This one indicates that the MAC has decided to and
1338 * successfully completed a change to another AP. We
1339 * should probably implement a reassociation indication
1340 * in response to this one. I'm thinking that the the
1341 * p80211 layer needs to be notified in case of
1342 * buffering/queueing issues. User mode also needs to be
1343 * notified so that any BSS dependent elements can be
1345 * associated state. We * should send a deauth indication
1346 * (implying disassoc) up * to the MLME.
1348 * Indicate Reassociation
1349 * Enable Transmits, Receives and pass up data frames
1351 printk(KERN_INFO
"linkstatus=AP_CHANGE\n");
1353 result
= hfa384x_drvr_getconfig(hw
,
1354 HFA384x_RID_CURRENTBSSID
,
1355 wlandev
->bssid
, WLAN_BSSID_LEN
);
1357 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1358 HFA384x_RID_CURRENTBSSID
, result
);
1362 result
= hfa384x_drvr_getconfig(hw
,
1363 HFA384x_RID_CURRENTSSID
,
1364 &ssid
, sizeof(ssid
));
1366 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1367 HFA384x_RID_CURRENTSSID
, result
);
1370 prism2mgmt_bytestr2pstr((hfa384x_bytestr_t
*) & ssid
,
1371 (p80211pstrd_t
*) & wlandev
->ssid
);
1373 hw
->link_status
= HFA384x_LINK_CONNECTED
;
1374 netif_carrier_on(wlandev
->netdev
);
1378 case HFA384x_LINK_AP_OUTOFRANGE
:
1379 /* This one indicates that the MAC has decided that the
1380 * AP is out of range, but hasn't found a better candidate
1381 * so the MAC maintains its "associated" state in case
1382 * we get back in range. We should block transmits and
1383 * receives in this state. Do we need an indication here?
1384 * Probably not since a polling user-mode element would
1385 * get this status from from p2PortStatus(FD40). What about
1388 * Block Transmits, Ignore receives of data frames
1390 printk(KERN_INFO
"linkstatus=AP_OUTOFRANGE (unhandled)\n");
1392 netif_carrier_off(wlandev
->netdev
);
1396 case HFA384x_LINK_AP_INRANGE
:
1397 /* This one indicates that the MAC has decided that the
1398 * AP is back in range. We continue working with our
1399 * existing association.
1401 * Enable Transmits, Receives and pass up data frames
1403 printk(KERN_INFO
"linkstatus=AP_INRANGE\n");
1405 hw
->link_status
= HFA384x_LINK_CONNECTED
;
1406 netif_carrier_on(wlandev
->netdev
);
1410 case HFA384x_LINK_ASSOCFAIL
:
1411 /* This one is actually a peer to CONNECTED. We've
1412 * requested a join for a given SSID and optionally BSSID.
1413 * We can use this one to indicate authentication and
1414 * association failures. The trick is going to be
1415 * 1) identifying the failure, and 2) state management.
1417 * Disable Transmits, Ignore receives of data frames
1419 if (hw
->join_ap
&& --hw
->join_retries
> 0) {
1420 hfa384x_JoinRequest_data_t joinreq
;
1421 joinreq
= hw
->joinreq
;
1422 /* Send the join request */
1423 hfa384x_drvr_setconfig(hw
,
1424 HFA384x_RID_JOINREQUEST
,
1426 HFA384x_RID_JOINREQUEST_LEN
);
1428 "linkstatus=ASSOCFAIL (re-submitting join)\n");
1430 printk(KERN_INFO
"linkstatus=ASSOCFAIL (unhandled)\n");
1433 netif_carrier_off(wlandev
->netdev
);
1438 /* This is bad, IO port problems? */
1440 "unknown linkstatus=0x%02x\n", hw
->link_status
);
1445 wlandev
->linkstatus
= (hw
->link_status
== HFA384x_LINK_CONNECTED
);
1447 p80211wext_event_associated(wlandev
, wlandev
->linkstatus
);
1454 /*----------------------------------------------------------------
1455 * prism2sta_inf_linkstatus
1457 * Handles the receipt of a Link Status info frame.
1460 * wlandev wlan device structure
1461 * inf ptr to info frame (contents in hfa384x order)
1470 ----------------------------------------------------------------*/
1471 static void prism2sta_inf_linkstatus(wlandevice_t
* wlandev
,
1472 hfa384x_InfFrame_t
* inf
)
1474 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1476 hw
->link_status_new
= le16_to_cpu(inf
->info
.linkstatus
.linkstatus
);
1478 schedule_work(&hw
->link_bh
);
1483 /*----------------------------------------------------------------
1484 * prism2sta_inf_assocstatus
1486 * Handles the receipt of an Association Status info frame. Should
1487 * be present in APs only.
1490 * wlandev wlan device structure
1491 * inf ptr to info frame (contents in hfa384x order)
1500 ----------------------------------------------------------------*/
1501 static void prism2sta_inf_assocstatus(wlandevice_t
* wlandev
,
1502 hfa384x_InfFrame_t
* inf
)
1504 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1505 hfa384x_AssocStatus_t rec
;
1508 memcpy(&rec
, &inf
->info
.assocstatus
, sizeof(rec
));
1509 rec
.assocstatus
= le16_to_cpu(rec
.assocstatus
);
1510 rec
.reason
= le16_to_cpu(rec
.reason
);
1513 ** Find the address in the list of authenticated stations. If it wasn't
1514 ** found, then this address has not been previously authenticated and
1515 ** something weird has happened if this is anything other than an
1516 ** "authentication failed" message. If the address was found, then
1517 ** set the "associated" flag for that station, based on whether the
1518 ** station is associating or losing its association. Something weird
1519 ** has also happened if we find the address in the list of authenticated
1520 ** stations but we are getting an "authentication failed" message.
1523 for (i
= 0; i
< hw
->authlist
.cnt
; i
++)
1524 if (memcmp(rec
.sta_addr
, hw
->authlist
.addr
[i
], ETH_ALEN
) == 0)
1527 if (i
>= hw
->authlist
.cnt
) {
1528 if (rec
.assocstatus
!= HFA384x_ASSOCSTATUS_AUTHFAIL
)
1530 "assocstatus info frame received for non-authenticated station.\n");
1532 hw
->authlist
.assoc
[i
] =
1533 (rec
.assocstatus
== HFA384x_ASSOCSTATUS_STAASSOC
||
1534 rec
.assocstatus
== HFA384x_ASSOCSTATUS_REASSOC
);
1536 if (rec
.assocstatus
== HFA384x_ASSOCSTATUS_AUTHFAIL
)
1538 "authfail assocstatus info frame received for authenticated station.\n");
1544 /*----------------------------------------------------------------
1545 * prism2sta_inf_authreq
1547 * Handles the receipt of an Authentication Request info frame. Should
1548 * be present in APs only.
1551 * wlandev wlan device structure
1552 * inf ptr to info frame (contents in hfa384x order)
1562 ----------------------------------------------------------------*/
1563 static void prism2sta_inf_authreq(wlandevice_t
* wlandev
,
1564 hfa384x_InfFrame_t
* inf
)
1566 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1567 struct sk_buff
*skb
;
1569 skb
= dev_alloc_skb(sizeof(*inf
));
1571 skb_put(skb
, sizeof(*inf
));
1572 memcpy(skb
->data
, inf
, sizeof(*inf
));
1573 skb_queue_tail(&hw
->authq
, skb
);
1574 schedule_work(&hw
->link_bh
);
1578 static void prism2sta_inf_authreq_defer(wlandevice_t
* wlandev
,
1579 hfa384x_InfFrame_t
* inf
)
1581 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1582 hfa384x_authenticateStation_data_t rec
;
1584 int i
, added
, result
, cnt
;
1588 ** Build the AuthenticateStation record. Initialize it for denying
1592 memcpy(rec
.address
, inf
->info
.authreq
.sta_addr
, ETH_ALEN
);
1593 rec
.status
= P80211ENUM_status_unspec_failure
;
1596 ** Authenticate based on the access mode.
1599 switch (hw
->accessmode
) {
1600 case WLAN_ACCESS_NONE
:
1603 ** Deny all new authentications. However, if a station
1604 ** is ALREADY authenticated, then accept it.
1607 for (i
= 0; i
< hw
->authlist
.cnt
; i
++)
1608 if (memcmp(rec
.address
, hw
->authlist
.addr
[i
],
1610 rec
.status
= P80211ENUM_status_successful
;
1616 case WLAN_ACCESS_ALL
:
1619 ** Allow all authentications.
1622 rec
.status
= P80211ENUM_status_successful
;
1625 case WLAN_ACCESS_ALLOW
:
1628 ** Only allow the authentication if the MAC address
1629 ** is in the list of allowed addresses.
1631 ** Since this is the interrupt handler, we may be here
1632 ** while the access list is in the middle of being
1633 ** updated. Choose the list which is currently okay.
1634 ** See "prism2mib_priv_accessallow()" for details.
1637 if (hw
->allow
.modify
== 0) {
1638 cnt
= hw
->allow
.cnt
;
1639 addr
= hw
->allow
.addr
[0];
1641 cnt
= hw
->allow
.cnt1
;
1642 addr
= hw
->allow
.addr1
[0];
1645 for (i
= 0; i
< cnt
; i
++, addr
+= ETH_ALEN
)
1646 if (memcmp(rec
.address
, addr
, ETH_ALEN
) == 0) {
1647 rec
.status
= P80211ENUM_status_successful
;
1653 case WLAN_ACCESS_DENY
:
1656 ** Allow the authentication UNLESS the MAC address is
1657 ** in the list of denied addresses.
1659 ** Since this is the interrupt handler, we may be here
1660 ** while the access list is in the middle of being
1661 ** updated. Choose the list which is currently okay.
1662 ** See "prism2mib_priv_accessdeny()" for details.
1665 if (hw
->deny
.modify
== 0) {
1667 addr
= hw
->deny
.addr
[0];
1669 cnt
= hw
->deny
.cnt1
;
1670 addr
= hw
->deny
.addr1
[0];
1673 rec
.status
= P80211ENUM_status_successful
;
1675 for (i
= 0; i
< cnt
; i
++, addr
+= ETH_ALEN
)
1676 if (memcmp(rec
.address
, addr
, ETH_ALEN
) == 0) {
1677 rec
.status
= P80211ENUM_status_unspec_failure
;
1685 ** If the authentication is okay, then add the MAC address to the list
1686 ** of authenticated stations. Don't add the address if it is already in
1687 ** the list. (802.11b does not seem to disallow a station from issuing
1688 ** an authentication request when the station is already authenticated.
1689 ** Does this sort of thing ever happen? We might as well do the check
1695 if (rec
.status
== P80211ENUM_status_successful
) {
1696 for (i
= 0; i
< hw
->authlist
.cnt
; i
++)
1697 if (memcmp(rec
.address
, hw
->authlist
.addr
[i
], ETH_ALEN
)
1701 if (i
>= hw
->authlist
.cnt
) {
1702 if (hw
->authlist
.cnt
>= WLAN_AUTH_MAX
) {
1703 rec
.status
= P80211ENUM_status_ap_full
;
1705 memcpy(hw
->authlist
.addr
[hw
->authlist
.cnt
],
1706 rec
.address
, ETH_ALEN
);
1714 ** Send back the results of the authentication. If this doesn't work,
1715 ** then make sure to remove the address from the authenticated list if
1719 rec
.status
= cpu_to_le16(rec
.status
);
1720 rec
.algorithm
= inf
->info
.authreq
.algorithm
;
1722 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_AUTHENTICATESTA
,
1728 "setconfig(authenticatestation) failed, result=%d\n",
1734 /*----------------------------------------------------------------
1735 * prism2sta_inf_psusercnt
1737 * Handles the receipt of a PowerSaveUserCount info frame. Should
1738 * be present in APs only.
1741 * wlandev wlan device structure
1742 * inf ptr to info frame (contents in hfa384x order)
1751 ----------------------------------------------------------------*/
1752 static void prism2sta_inf_psusercnt(wlandevice_t
* wlandev
,
1753 hfa384x_InfFrame_t
* inf
)
1755 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1757 hw
->psusercount
= le16_to_cpu(inf
->info
.psusercnt
.usercnt
);
1762 /*----------------------------------------------------------------
1765 * Handles the Info event.
1768 * wlandev wlan device structure
1769 * inf ptr to a generic info frame
1778 ----------------------------------------------------------------*/
1779 void prism2sta_ev_info(wlandevice_t
* wlandev
, hfa384x_InfFrame_t
* inf
)
1781 inf
->infotype
= le16_to_cpu(inf
->infotype
);
1783 switch (inf
->infotype
) {
1784 case HFA384x_IT_HANDOVERADDR
:
1785 prism2sta_inf_handover(wlandev
, inf
);
1787 case HFA384x_IT_COMMTALLIES
:
1788 prism2sta_inf_tallies(wlandev
, inf
);
1790 case HFA384x_IT_HOSTSCANRESULTS
:
1791 prism2sta_inf_hostscanresults(wlandev
, inf
);
1793 case HFA384x_IT_SCANRESULTS
:
1794 prism2sta_inf_scanresults(wlandev
, inf
);
1796 case HFA384x_IT_CHINFORESULTS
:
1797 prism2sta_inf_chinforesults(wlandev
, inf
);
1799 case HFA384x_IT_LINKSTATUS
:
1800 prism2sta_inf_linkstatus(wlandev
, inf
);
1802 case HFA384x_IT_ASSOCSTATUS
:
1803 prism2sta_inf_assocstatus(wlandev
, inf
);
1805 case HFA384x_IT_AUTHREQ
:
1806 prism2sta_inf_authreq(wlandev
, inf
);
1808 case HFA384x_IT_PSUSERCNT
:
1809 prism2sta_inf_psusercnt(wlandev
, inf
);
1811 case HFA384x_IT_KEYIDCHANGED
:
1812 printk(KERN_WARNING
"Unhandled IT_KEYIDCHANGED\n");
1814 case HFA384x_IT_ASSOCREQ
:
1815 printk(KERN_WARNING
"Unhandled IT_ASSOCREQ\n");
1817 case HFA384x_IT_MICFAILURE
:
1818 printk(KERN_WARNING
"Unhandled IT_MICFAILURE\n");
1822 "Unknown info type=0x%02x\n", inf
->infotype
);
1828 /*----------------------------------------------------------------
1829 * prism2sta_ev_txexc
1831 * Handles the TxExc event. A Transmit Exception event indicates
1832 * that the MAC's TX process was unsuccessful - so the packet did
1833 * not get transmitted.
1836 * wlandev wlan device structure
1837 * status tx frame status word
1846 ----------------------------------------------------------------*/
1847 void prism2sta_ev_txexc(wlandevice_t
* wlandev
, u16 status
)
1849 pr_debug("TxExc status=0x%x.\n", status
);
1854 /*----------------------------------------------------------------
1857 * Handles the Tx event.
1860 * wlandev wlan device structure
1861 * status tx frame status word
1869 ----------------------------------------------------------------*/
1870 void prism2sta_ev_tx(wlandevice_t
* wlandev
, u16 status
)
1872 pr_debug("Tx Complete, status=0x%04x\n", status
);
1873 /* update linux network stats */
1874 wlandev
->linux_stats
.tx_packets
++;
1878 /*----------------------------------------------------------------
1881 * Handles the Rx event.
1884 * wlandev wlan device structure
1893 ----------------------------------------------------------------*/
1894 void prism2sta_ev_rx(wlandevice_t
* wlandev
, struct sk_buff
*skb
)
1896 p80211netdev_rx(wlandev
, skb
);
1900 /*----------------------------------------------------------------
1901 * prism2sta_ev_alloc
1903 * Handles the Alloc event.
1906 * wlandev wlan device structure
1915 ----------------------------------------------------------------*/
1916 void prism2sta_ev_alloc(wlandevice_t
* wlandev
)
1918 netif_wake_queue(wlandev
->netdev
);
1922 /*----------------------------------------------------------------
1925 * Called at module init time. This creates the wlandevice_t structure
1926 * and initializes it with relevant bits.
1932 * the created wlandevice_t structure.
1935 * also allocates the priv/hw structures.
1940 ----------------------------------------------------------------*/
1941 static wlandevice_t
*create_wlan(void)
1943 wlandevice_t
*wlandev
= NULL
;
1944 hfa384x_t
*hw
= NULL
;
1946 /* Alloc our structures */
1947 wlandev
= kmalloc(sizeof(wlandevice_t
), GFP_KERNEL
);
1948 hw
= kmalloc(sizeof(hfa384x_t
), GFP_KERNEL
);
1950 if (!wlandev
|| !hw
) {
1951 printk(KERN_ERR
"%s: Memory allocation failure.\n", dev_info
);
1957 /* Clear all the structs */
1958 memset(wlandev
, 0, sizeof(wlandevice_t
));
1959 memset(hw
, 0, sizeof(hfa384x_t
));
1961 /* Initialize the network device object. */
1962 wlandev
->nsdname
= dev_info
;
1963 wlandev
->msdstate
= WLAN_MSD_HWPRESENT_PENDING
;
1965 wlandev
->open
= prism2sta_open
;
1966 wlandev
->close
= prism2sta_close
;
1967 wlandev
->reset
= prism2sta_reset
;
1968 wlandev
->txframe
= prism2sta_txframe
;
1969 wlandev
->mlmerequest
= prism2sta_mlmerequest
;
1970 wlandev
->set_multicast_list
= prism2sta_setmulticast
;
1971 wlandev
->tx_timeout
= hfa384x_tx_timeout
;
1973 wlandev
->nsdcaps
= P80211_NSDCAP_HWFRAGMENT
| P80211_NSDCAP_AUTOJOIN
;
1975 /* Initialize the device private data stucture. */
1976 hw
->dot11_desired_bss_type
= 1;
1981 void prism2sta_commsqual_defer(struct work_struct
*data
)
1983 hfa384x_t
*hw
= container_of(data
, struct hfa384x
, commsqual_bh
);
1984 wlandevice_t
*wlandev
= hw
->wlandev
;
1985 hfa384x_bytestr32_t ssid
;
1988 if (hw
->wlandev
->hwremoved
)
1991 /* we don't care if we're in AP mode */
1992 if ((wlandev
->macmode
== WLAN_MACMODE_NONE
) ||
1993 (wlandev
->macmode
== WLAN_MACMODE_ESS_AP
)) {
1997 /* It only makes sense to poll these in non-IBSS */
1998 if (wlandev
->macmode
!= WLAN_MACMODE_IBSS_STA
) {
1999 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_DBMCOMMSQUALITY
,
2001 HFA384x_RID_DBMCOMMSQUALITY_LEN
);
2004 printk(KERN_ERR
"error fetching commsqual\n");
2008 pr_debug("commsqual %d %d %d\n",
2009 le16_to_cpu(hw
->qual
.CQ_currBSS
),
2010 le16_to_cpu(hw
->qual
.ASL_currBSS
),
2011 le16_to_cpu(hw
->qual
.ANL_currFC
));
2014 /* Lastly, we need to make sure the BSSID didn't change on us */
2015 result
= hfa384x_drvr_getconfig(hw
,
2016 HFA384x_RID_CURRENTBSSID
,
2017 wlandev
->bssid
, WLAN_BSSID_LEN
);
2019 pr_debug("getconfig(0x%02x) failed, result = %d\n",
2020 HFA384x_RID_CURRENTBSSID
, result
);
2024 result
= hfa384x_drvr_getconfig(hw
,
2025 HFA384x_RID_CURRENTSSID
,
2026 &ssid
, sizeof(ssid
));
2028 pr_debug("getconfig(0x%02x) failed, result = %d\n",
2029 HFA384x_RID_CURRENTSSID
, result
);
2032 prism2mgmt_bytestr2pstr((hfa384x_bytestr_t
*) & ssid
,
2033 (p80211pstrd_t
*) & wlandev
->ssid
);
2035 /* Reschedule timer */
2036 mod_timer(&hw
->commsqual_timer
, jiffies
+ HZ
);
2042 void prism2sta_commsqual_timer(unsigned long data
)
2044 hfa384x_t
*hw
= (hfa384x_t
*) data
;
2046 schedule_work(&hw
->commsqual_bh
);