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/module.h>
54 #include <linux/moduleparam.h>
55 #include <linux/kernel.h>
56 #include <linux/sched.h>
57 #include <linux/types.h>
58 #include <linux/slab.h>
59 #include <linux/wireless.h>
60 #include <linux/netdevice.h>
61 #include <linux/workqueue.h>
62 #include <linux/byteorder/generic.h>
63 #include <linux/ctype.h>
66 #include <linux/delay.h>
67 #include <asm/byteorder.h>
68 #include <linux/if_arp.h>
69 #include <linux/if_ether.h>
70 #include <linux/bitops.h>
72 #include "p80211types.h"
73 #include "p80211hdr.h"
74 #include "p80211mgmt.h"
75 #include "p80211conv.h"
76 #include "p80211msg.h"
77 #include "p80211netdev.h"
78 #include "p80211req.h"
79 #include "p80211metadef.h"
80 #include "p80211metastruct.h"
82 #include "prism2mgmt.h"
84 /* Create a string of printable chars from something that might not be */
85 /* It's recommended that the str be 4*len + 1 bytes long */
86 #define wlan_mkprintstr(buf, buflen, str, strlen) \
90 memset(str, 0, (strlen)); \
91 for (i = 0; i < (buflen); i++) { \
92 if (isprint((buf)[i])) { \
93 (str)[j] = (buf)[i]; \
98 (str)[j+2] = hex_asc_hi((buf)[i]); \
99 (str)[j+3] = hex_asc_lo((buf)[i]); \
105 static char *dev_info
= "prism2_usb";
106 static wlandevice_t
*create_wlan(void);
108 int prism2_reset_holdtime
= 30; /* Reset hold time in ms */
109 int prism2_reset_settletime
= 100; /* Reset settle time in ms */
111 static int prism2_doreset
; /* Do a reset at init? */
113 module_param(prism2_doreset
, int, 0644);
114 MODULE_PARM_DESC(prism2_doreset
, "Issue a reset on initialization");
116 module_param(prism2_reset_holdtime
, int, 0644);
117 MODULE_PARM_DESC(prism2_reset_holdtime
, "reset hold time in ms");
118 module_param(prism2_reset_settletime
, int, 0644);
119 MODULE_PARM_DESC(prism2_reset_settletime
, "reset settle time in ms");
121 MODULE_LICENSE("Dual MPL/GPL");
123 void prism2_connect_result(wlandevice_t
*wlandev
, u8 failed
);
124 void prism2_disconnected(wlandevice_t
*wlandev
);
125 void prism2_roamed(wlandevice_t
*wlandev
);
127 static int prism2sta_open(wlandevice_t
*wlandev
);
128 static int prism2sta_close(wlandevice_t
*wlandev
);
129 static void prism2sta_reset(wlandevice_t
*wlandev
);
130 static int prism2sta_txframe(wlandevice_t
*wlandev
, struct sk_buff
*skb
,
131 union p80211_hdr
*p80211_hdr
,
132 struct p80211_metawep
*p80211_wep
);
133 static int prism2sta_mlmerequest(wlandevice_t
*wlandev
, struct p80211msg
*msg
);
134 static int prism2sta_getcardinfo(wlandevice_t
*wlandev
);
135 static int prism2sta_globalsetup(wlandevice_t
*wlandev
);
136 static int prism2sta_setmulticast(wlandevice_t
*wlandev
, netdevice_t
*dev
);
138 static void prism2sta_inf_handover(wlandevice_t
*wlandev
,
139 hfa384x_InfFrame_t
*inf
);
140 static void prism2sta_inf_tallies(wlandevice_t
*wlandev
,
141 hfa384x_InfFrame_t
*inf
);
142 static void prism2sta_inf_hostscanresults(wlandevice_t
*wlandev
,
143 hfa384x_InfFrame_t
*inf
);
144 static void prism2sta_inf_scanresults(wlandevice_t
*wlandev
,
145 hfa384x_InfFrame_t
*inf
);
146 static void prism2sta_inf_chinforesults(wlandevice_t
*wlandev
,
147 hfa384x_InfFrame_t
*inf
);
148 static void prism2sta_inf_linkstatus(wlandevice_t
*wlandev
,
149 hfa384x_InfFrame_t
*inf
);
150 static void prism2sta_inf_assocstatus(wlandevice_t
*wlandev
,
151 hfa384x_InfFrame_t
*inf
);
152 static void prism2sta_inf_authreq(wlandevice_t
*wlandev
,
153 hfa384x_InfFrame_t
*inf
);
154 static void prism2sta_inf_authreq_defer(wlandevice_t
*wlandev
,
155 hfa384x_InfFrame_t
*inf
);
156 static void prism2sta_inf_psusercnt(wlandevice_t
*wlandev
,
157 hfa384x_InfFrame_t
*inf
);
159 /*----------------------------------------------------------------
162 * WLAN device open method. Called from p80211netdev when kernel
163 * device open (start) method is called in response to the
164 * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
168 * wlandev wlan device structure
172 * >0 f/w reported error
173 * <0 driver reported error
179 ----------------------------------------------------------------*/
180 static int prism2sta_open(wlandevice_t
*wlandev
)
182 /* We don't currently have to do anything else.
183 * The setup of the MAC should be subsequently completed via
185 * Higher layers know we're ready from dev->start==1 and
186 * dev->tbusy==0. Our rx path knows to pass up received/
187 * frames because of dev->flags&IFF_UP is true.
193 /*----------------------------------------------------------------
196 * WLAN device close method. Called from p80211netdev when kernel
197 * device close method is called in response to the
198 * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
202 * wlandev wlan device structure
206 * >0 f/w reported error
207 * <0 driver reported error
213 ----------------------------------------------------------------*/
214 static int prism2sta_close(wlandevice_t
*wlandev
)
216 /* We don't currently have to do anything else.
217 * Higher layers know we're not ready from dev->start==0 and
218 * dev->tbusy==1. Our rx path knows to not pass up received
219 * frames because of dev->flags&IFF_UP is false.
225 /*----------------------------------------------------------------
228 * Not currently implented.
231 * wlandev wlan device structure
241 ----------------------------------------------------------------*/
242 static void prism2sta_reset(wlandevice_t
*wlandev
)
246 /*----------------------------------------------------------------
249 * Takes a frame from p80211 and queues it for transmission.
252 * wlandev wlan device structure
253 * pb packet buffer struct. Contains an 802.11
255 * p80211_hdr points to the 802.11 header for the packet.
257 * 0 Success and more buffs available
258 * 1 Success but no more buffs
259 * 2 Allocation failure
260 * 4 Buffer full or queue busy
266 ----------------------------------------------------------------*/
267 static int prism2sta_txframe(wlandevice_t
*wlandev
, struct sk_buff
*skb
,
268 union p80211_hdr
*p80211_hdr
,
269 struct p80211_metawep
*p80211_wep
)
271 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
274 /* If necessary, set the 802.11 WEP bit */
275 if ((wlandev
->hostwep
& (HOSTWEP_PRIVACYINVOKED
| HOSTWEP_ENCRYPT
)) ==
276 HOSTWEP_PRIVACYINVOKED
) {
277 p80211_hdr
->a3
.fc
|= cpu_to_le16(WLAN_SET_FC_ISWEP(1));
280 result
= hfa384x_drvr_txframe(hw
, skb
, p80211_hdr
, p80211_wep
);
285 /*----------------------------------------------------------------
286 * prism2sta_mlmerequest
288 * wlan command message handler. All we do here is pass the message
289 * over to the prism2sta_mgmt_handler.
292 * wlandev wlan device structure
293 * msg wlan command message
296 * <0 successful acceptance of message, but we're
297 * waiting for an async process to finish before
298 * we're done with the msg. When the asynch
299 * process is done, we'll call the p80211
300 * function p80211req_confirm() .
301 * >0 An error occurred while we were handling
308 ----------------------------------------------------------------*/
309 static int prism2sta_mlmerequest(wlandevice_t
*wlandev
, struct p80211msg
*msg
)
311 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
315 switch (msg
->msgcode
) {
316 case DIDmsg_dot11req_mibget
:
317 pr_debug("Received mibget request\n");
318 result
= prism2mgmt_mibset_mibget(wlandev
, msg
);
320 case DIDmsg_dot11req_mibset
:
321 pr_debug("Received mibset request\n");
322 result
= prism2mgmt_mibset_mibget(wlandev
, msg
);
324 case DIDmsg_dot11req_scan
:
325 pr_debug("Received scan request\n");
326 result
= prism2mgmt_scan(wlandev
, msg
);
328 case DIDmsg_dot11req_scan_results
:
329 pr_debug("Received scan_results request\n");
330 result
= prism2mgmt_scan_results(wlandev
, msg
);
332 case DIDmsg_dot11req_start
:
333 pr_debug("Received mlme start request\n");
334 result
= prism2mgmt_start(wlandev
, msg
);
337 * Prism2 specific messages
339 case DIDmsg_p2req_readpda
:
340 pr_debug("Received mlme readpda request\n");
341 result
= prism2mgmt_readpda(wlandev
, msg
);
343 case DIDmsg_p2req_ramdl_state
:
344 pr_debug("Received mlme ramdl_state request\n");
345 result
= prism2mgmt_ramdl_state(wlandev
, msg
);
347 case DIDmsg_p2req_ramdl_write
:
348 pr_debug("Received mlme ramdl_write request\n");
349 result
= prism2mgmt_ramdl_write(wlandev
, msg
);
351 case DIDmsg_p2req_flashdl_state
:
352 pr_debug("Received mlme flashdl_state request\n");
353 result
= prism2mgmt_flashdl_state(wlandev
, msg
);
355 case DIDmsg_p2req_flashdl_write
:
356 pr_debug("Received mlme flashdl_write request\n");
357 result
= prism2mgmt_flashdl_write(wlandev
, msg
);
360 * Linux specific messages
362 case DIDmsg_lnxreq_hostwep
:
363 break; /* ignore me. */
364 case DIDmsg_lnxreq_ifstate
:
366 struct p80211msg_lnxreq_ifstate
*ifstatemsg
;
367 pr_debug("Received mlme ifstate request\n");
368 ifstatemsg
= (struct p80211msg_lnxreq_ifstate
*) msg
;
370 prism2sta_ifstate(wlandev
,
371 ifstatemsg
->ifstate
.data
);
372 ifstatemsg
->resultcode
.status
=
373 P80211ENUM_msgitem_status_data_ok
;
374 ifstatemsg
->resultcode
.data
= result
;
378 case DIDmsg_lnxreq_wlansniff
:
379 pr_debug("Received mlme wlansniff request\n");
380 result
= prism2mgmt_wlansniff(wlandev
, msg
);
382 case DIDmsg_lnxreq_autojoin
:
383 pr_debug("Received mlme autojoin request\n");
384 result
= prism2mgmt_autojoin(wlandev
, msg
);
386 case DIDmsg_lnxreq_commsquality
:{
387 struct p80211msg_lnxreq_commsquality
*qualmsg
;
389 pr_debug("Received commsquality request\n");
391 qualmsg
= (struct p80211msg_lnxreq_commsquality
*) msg
;
393 qualmsg
->link
.status
=
394 P80211ENUM_msgitem_status_data_ok
;
395 qualmsg
->level
.status
=
396 P80211ENUM_msgitem_status_data_ok
;
397 qualmsg
->noise
.status
=
398 P80211ENUM_msgitem_status_data_ok
;
400 qualmsg
->link
.data
= le16_to_cpu(hw
->qual
.CQ_currBSS
);
401 qualmsg
->level
.data
= le16_to_cpu(hw
->qual
.ASL_currBSS
);
402 qualmsg
->noise
.data
= le16_to_cpu(hw
->qual
.ANL_currFC
);
403 qualmsg
->txrate
.data
= hw
->txrate
;
408 printk(KERN_WARNING
"Unknown mgmt request message 0x%08x",
416 /*----------------------------------------------------------------
419 * Interface state. This is the primary WLAN interface enable/disable
420 * handler. Following the driver/load/deviceprobe sequence, this
421 * function must be called with a state of "enable" before any other
422 * commands will be accepted.
425 * wlandev wlan device structure
426 * msgp ptr to msg buffer
429 * A p80211 message resultcode value.
434 * process thread (usually)
436 ----------------------------------------------------------------*/
437 u32
prism2sta_ifstate(wlandevice_t
*wlandev
, u32 ifstate
)
439 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
442 result
= P80211ENUM_resultcode_implementation_failure
;
444 pr_debug("Current MSD state(%d), requesting(%d)\n",
445 wlandev
->msdstate
, ifstate
);
447 case P80211ENUM_ifstate_fwload
:
448 switch (wlandev
->msdstate
) {
449 case WLAN_MSD_HWPRESENT
:
450 wlandev
->msdstate
= WLAN_MSD_FWLOAD_PENDING
;
452 * Initialize the device+driver sufficiently
453 * for firmware loading.
455 result
= hfa384x_drvr_start(hw
);
457 netdev_err(wlandev
->netdev
,
458 "hfa384x_drvr_start() failed,result=%d\n", (int)result
);
460 P80211ENUM_resultcode_implementation_failure
;
461 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
464 wlandev
->msdstate
= WLAN_MSD_FWLOAD
;
465 result
= P80211ENUM_resultcode_success
;
467 case WLAN_MSD_FWLOAD
:
468 hfa384x_cmd_initialize(hw
);
469 result
= P80211ENUM_resultcode_success
;
471 case WLAN_MSD_RUNNING
:
473 "Cannot enter fwload state from enable state,"
474 "you must disable first.\n");
475 result
= P80211ENUM_resultcode_invalid_parameters
;
477 case WLAN_MSD_HWFAIL
:
479 /* probe() had a problem or the msdstate contains
480 * an unrecognized value, there's nothing we can do.
482 result
= P80211ENUM_resultcode_implementation_failure
;
486 case P80211ENUM_ifstate_enable
:
487 switch (wlandev
->msdstate
) {
488 case WLAN_MSD_HWPRESENT
:
489 case WLAN_MSD_FWLOAD
:
490 wlandev
->msdstate
= WLAN_MSD_RUNNING_PENDING
;
491 /* Initialize the device+driver for full
492 * operation. Note that this might me an FWLOAD to
493 * to RUNNING transition so we must not do a chip
494 * or board level reset. Note that on failure,
495 * the MSD state is set to HWPRESENT because we
496 * can't make any assumptions about the state
497 * of the hardware or a previous firmware load.
499 result
= hfa384x_drvr_start(hw
);
501 netdev_err(wlandev
->netdev
,
502 "hfa384x_drvr_start() failed,result=%d\n", (int)result
);
504 P80211ENUM_resultcode_implementation_failure
;
505 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
509 result
= prism2sta_getcardinfo(wlandev
);
511 netdev_err(wlandev
->netdev
,
512 "prism2sta_getcardinfo() failed,result=%d\n", (int)result
);
514 P80211ENUM_resultcode_implementation_failure
;
515 hfa384x_drvr_stop(hw
);
516 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
519 result
= prism2sta_globalsetup(wlandev
);
521 netdev_err(wlandev
->netdev
,
522 "prism2sta_globalsetup() failed,result=%d\n", (int)result
);
524 P80211ENUM_resultcode_implementation_failure
;
525 hfa384x_drvr_stop(hw
);
526 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
529 wlandev
->msdstate
= WLAN_MSD_RUNNING
;
531 hw
->join_retries
= 60;
532 result
= P80211ENUM_resultcode_success
;
534 case WLAN_MSD_RUNNING
:
535 /* Do nothing, we're already in this state. */
536 result
= P80211ENUM_resultcode_success
;
538 case WLAN_MSD_HWFAIL
:
540 /* probe() had a problem or the msdstate contains
541 * an unrecognized value, there's nothing we can do.
543 result
= P80211ENUM_resultcode_implementation_failure
;
547 case P80211ENUM_ifstate_disable
:
548 switch (wlandev
->msdstate
) {
549 case WLAN_MSD_HWPRESENT
:
550 /* Do nothing, we're already in this state. */
551 result
= P80211ENUM_resultcode_success
;
553 case WLAN_MSD_FWLOAD
:
554 case WLAN_MSD_RUNNING
:
555 wlandev
->msdstate
= WLAN_MSD_HWPRESENT_PENDING
;
557 * TODO: Shut down the MAC completely. Here a chip
558 * or board level reset is probably called for.
559 * After a "disable" _all_ results are lost, even
560 * those from a fwload.
562 if (!wlandev
->hwremoved
)
563 netif_carrier_off(wlandev
->netdev
);
565 hfa384x_drvr_stop(hw
);
567 wlandev
->macmode
= WLAN_MACMODE_NONE
;
568 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
569 result
= P80211ENUM_resultcode_success
;
571 case WLAN_MSD_HWFAIL
:
573 /* probe() had a problem or the msdstate contains
574 * an unrecognized value, there's nothing we can do.
576 result
= P80211ENUM_resultcode_implementation_failure
;
581 result
= P80211ENUM_resultcode_invalid_parameters
;
588 /*----------------------------------------------------------------
589 * prism2sta_getcardinfo
591 * Collect the NICID, firmware version and any other identifiers
592 * we'd like to have in host-side data structures.
595 * wlandev wlan device structure
599 * >0 f/w reported error
600 * <0 driver reported error
606 ----------------------------------------------------------------*/
607 static int prism2sta_getcardinfo(wlandevice_t
*wlandev
)
610 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
612 u8 snum
[HFA384x_RID_NICSERIALNUMBER_LEN
];
613 char pstr
[(HFA384x_RID_NICSERIALNUMBER_LEN
* 4) + 1];
615 /* Collect version and compatibility info */
616 /* Some are critical, some are not */
618 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_NICIDENTITY
,
620 sizeof(hfa384x_compident_t
));
622 netdev_err(wlandev
->netdev
, "Failed to retrieve NICIDENTITY\n");
626 /* get all the nic id fields in host byte order */
627 hw
->ident_nic
.id
= le16_to_cpu(hw
->ident_nic
.id
);
628 hw
->ident_nic
.variant
= le16_to_cpu(hw
->ident_nic
.variant
);
629 hw
->ident_nic
.major
= le16_to_cpu(hw
->ident_nic
.major
);
630 hw
->ident_nic
.minor
= le16_to_cpu(hw
->ident_nic
.minor
);
632 netdev_info(wlandev
->netdev
, "ident: nic h/w: id=0x%02x %d.%d.%d\n",
633 hw
->ident_nic
.id
, hw
->ident_nic
.major
,
634 hw
->ident_nic
.minor
, hw
->ident_nic
.variant
);
636 /* Primary f/w identity */
637 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_PRIIDENTITY
,
639 sizeof(hfa384x_compident_t
));
641 netdev_err(wlandev
->netdev
, "Failed to retrieve PRIIDENTITY\n");
645 /* get all the private fw id fields in host byte order */
646 hw
->ident_pri_fw
.id
= le16_to_cpu(hw
->ident_pri_fw
.id
);
647 hw
->ident_pri_fw
.variant
= le16_to_cpu(hw
->ident_pri_fw
.variant
);
648 hw
->ident_pri_fw
.major
= le16_to_cpu(hw
->ident_pri_fw
.major
);
649 hw
->ident_pri_fw
.minor
= le16_to_cpu(hw
->ident_pri_fw
.minor
);
651 netdev_info(wlandev
->netdev
, "ident: pri f/w: id=0x%02x %d.%d.%d\n",
652 hw
->ident_pri_fw
.id
, hw
->ident_pri_fw
.major
,
653 hw
->ident_pri_fw
.minor
, hw
->ident_pri_fw
.variant
);
655 /* Station (Secondary?) f/w identity */
656 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_STAIDENTITY
,
658 sizeof(hfa384x_compident_t
));
660 netdev_err(wlandev
->netdev
, "Failed to retrieve STAIDENTITY\n");
664 if (hw
->ident_nic
.id
< 0x8000) {
665 netdev_err(wlandev
->netdev
,
666 "FATAL: Card is not an Intersil Prism2/2.5/3\n");
671 /* get all the station fw id fields in host byte order */
672 hw
->ident_sta_fw
.id
= le16_to_cpu(hw
->ident_sta_fw
.id
);
673 hw
->ident_sta_fw
.variant
= le16_to_cpu(hw
->ident_sta_fw
.variant
);
674 hw
->ident_sta_fw
.major
= le16_to_cpu(hw
->ident_sta_fw
.major
);
675 hw
->ident_sta_fw
.minor
= le16_to_cpu(hw
->ident_sta_fw
.minor
);
677 /* strip out the 'special' variant bits */
678 hw
->mm_mods
= hw
->ident_sta_fw
.variant
& (BIT(14) | BIT(15));
679 hw
->ident_sta_fw
.variant
&= ~((u16
) (BIT(14) | BIT(15)));
681 if (hw
->ident_sta_fw
.id
== 0x1f) {
682 netdev_info(wlandev
->netdev
,
683 "ident: sta f/w: id=0x%02x %d.%d.%d\n",
684 hw
->ident_sta_fw
.id
, hw
->ident_sta_fw
.major
,
685 hw
->ident_sta_fw
.minor
, hw
->ident_sta_fw
.variant
);
687 netdev_info(wlandev
->netdev
,
688 "ident: ap f/w: id=0x%02x %d.%d.%d\n",
689 hw
->ident_sta_fw
.id
, hw
->ident_sta_fw
.major
,
690 hw
->ident_sta_fw
.minor
, hw
->ident_sta_fw
.variant
);
691 netdev_err(wlandev
->netdev
, "Unsupported Tertiary AP firmeare loaded!\n");
695 /* Compatibility range, Modem supplier */
696 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_MFISUPRANGE
,
698 sizeof(hfa384x_caplevel_t
));
700 netdev_err(wlandev
->netdev
, "Failed to retrieve MFISUPRANGE\n");
704 /* get all the Compatibility range, modem interface supplier
705 fields in byte order */
706 hw
->cap_sup_mfi
.role
= le16_to_cpu(hw
->cap_sup_mfi
.role
);
707 hw
->cap_sup_mfi
.id
= le16_to_cpu(hw
->cap_sup_mfi
.id
);
708 hw
->cap_sup_mfi
.variant
= le16_to_cpu(hw
->cap_sup_mfi
.variant
);
709 hw
->cap_sup_mfi
.bottom
= le16_to_cpu(hw
->cap_sup_mfi
.bottom
);
710 hw
->cap_sup_mfi
.top
= le16_to_cpu(hw
->cap_sup_mfi
.top
);
712 netdev_info(wlandev
->netdev
,
713 "MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
714 hw
->cap_sup_mfi
.role
, hw
->cap_sup_mfi
.id
,
715 hw
->cap_sup_mfi
.variant
, hw
->cap_sup_mfi
.bottom
,
716 hw
->cap_sup_mfi
.top
);
718 /* Compatibility range, Controller supplier */
719 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_CFISUPRANGE
,
721 sizeof(hfa384x_caplevel_t
));
723 netdev_err(wlandev
->netdev
, "Failed to retrieve CFISUPRANGE\n");
727 /* get all the Compatibility range, controller interface supplier
728 fields in byte order */
729 hw
->cap_sup_cfi
.role
= le16_to_cpu(hw
->cap_sup_cfi
.role
);
730 hw
->cap_sup_cfi
.id
= le16_to_cpu(hw
->cap_sup_cfi
.id
);
731 hw
->cap_sup_cfi
.variant
= le16_to_cpu(hw
->cap_sup_cfi
.variant
);
732 hw
->cap_sup_cfi
.bottom
= le16_to_cpu(hw
->cap_sup_cfi
.bottom
);
733 hw
->cap_sup_cfi
.top
= le16_to_cpu(hw
->cap_sup_cfi
.top
);
735 netdev_info(wlandev
->netdev
,
736 "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
737 hw
->cap_sup_cfi
.role
, hw
->cap_sup_cfi
.id
,
738 hw
->cap_sup_cfi
.variant
, hw
->cap_sup_cfi
.bottom
,
739 hw
->cap_sup_cfi
.top
);
741 /* Compatibility range, Primary f/w supplier */
742 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_PRISUPRANGE
,
744 sizeof(hfa384x_caplevel_t
));
746 netdev_err(wlandev
->netdev
, "Failed to retrieve PRISUPRANGE\n");
750 /* get all the Compatibility range, primary firmware supplier
751 fields in byte order */
752 hw
->cap_sup_pri
.role
= le16_to_cpu(hw
->cap_sup_pri
.role
);
753 hw
->cap_sup_pri
.id
= le16_to_cpu(hw
->cap_sup_pri
.id
);
754 hw
->cap_sup_pri
.variant
= le16_to_cpu(hw
->cap_sup_pri
.variant
);
755 hw
->cap_sup_pri
.bottom
= le16_to_cpu(hw
->cap_sup_pri
.bottom
);
756 hw
->cap_sup_pri
.top
= le16_to_cpu(hw
->cap_sup_pri
.top
);
758 netdev_info(wlandev
->netdev
,
759 "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
760 hw
->cap_sup_pri
.role
, hw
->cap_sup_pri
.id
,
761 hw
->cap_sup_pri
.variant
, hw
->cap_sup_pri
.bottom
,
762 hw
->cap_sup_pri
.top
);
764 /* Compatibility range, Station f/w supplier */
765 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_STASUPRANGE
,
767 sizeof(hfa384x_caplevel_t
));
769 netdev_err(wlandev
->netdev
, "Failed to retrieve STASUPRANGE\n");
773 /* get all the Compatibility range, station firmware supplier
774 fields in byte order */
775 hw
->cap_sup_sta
.role
= le16_to_cpu(hw
->cap_sup_sta
.role
);
776 hw
->cap_sup_sta
.id
= le16_to_cpu(hw
->cap_sup_sta
.id
);
777 hw
->cap_sup_sta
.variant
= le16_to_cpu(hw
->cap_sup_sta
.variant
);
778 hw
->cap_sup_sta
.bottom
= le16_to_cpu(hw
->cap_sup_sta
.bottom
);
779 hw
->cap_sup_sta
.top
= le16_to_cpu(hw
->cap_sup_sta
.top
);
781 if (hw
->cap_sup_sta
.id
== 0x04) {
782 netdev_info(wlandev
->netdev
,
783 "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
784 hw
->cap_sup_sta
.role
, hw
->cap_sup_sta
.id
,
785 hw
->cap_sup_sta
.variant
, hw
->cap_sup_sta
.bottom
,
786 hw
->cap_sup_sta
.top
);
788 netdev_info(wlandev
->netdev
,
789 "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
790 hw
->cap_sup_sta
.role
, hw
->cap_sup_sta
.id
,
791 hw
->cap_sup_sta
.variant
, hw
->cap_sup_sta
.bottom
,
792 hw
->cap_sup_sta
.top
);
795 /* Compatibility range, primary f/w actor, CFI supplier */
796 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_PRI_CFIACTRANGES
,
797 &hw
->cap_act_pri_cfi
,
798 sizeof(hfa384x_caplevel_t
));
800 netdev_err(wlandev
->netdev
, "Failed to retrieve PRI_CFIACTRANGES\n");
804 /* get all the Compatibility range, primary f/w actor, CFI supplier
805 fields in byte order */
806 hw
->cap_act_pri_cfi
.role
= le16_to_cpu(hw
->cap_act_pri_cfi
.role
);
807 hw
->cap_act_pri_cfi
.id
= le16_to_cpu(hw
->cap_act_pri_cfi
.id
);
808 hw
->cap_act_pri_cfi
.variant
= le16_to_cpu(hw
->cap_act_pri_cfi
.variant
);
809 hw
->cap_act_pri_cfi
.bottom
= le16_to_cpu(hw
->cap_act_pri_cfi
.bottom
);
810 hw
->cap_act_pri_cfi
.top
= le16_to_cpu(hw
->cap_act_pri_cfi
.top
);
812 netdev_info(wlandev
->netdev
,
813 "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
814 hw
->cap_act_pri_cfi
.role
, hw
->cap_act_pri_cfi
.id
,
815 hw
->cap_act_pri_cfi
.variant
, hw
->cap_act_pri_cfi
.bottom
,
816 hw
->cap_act_pri_cfi
.top
);
818 /* Compatibility range, sta f/w actor, CFI supplier */
819 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_STA_CFIACTRANGES
,
820 &hw
->cap_act_sta_cfi
,
821 sizeof(hfa384x_caplevel_t
));
823 netdev_err(wlandev
->netdev
, "Failed to retrieve STA_CFIACTRANGES\n");
827 /* get all the Compatibility range, station f/w actor, CFI supplier
828 fields in byte order */
829 hw
->cap_act_sta_cfi
.role
= le16_to_cpu(hw
->cap_act_sta_cfi
.role
);
830 hw
->cap_act_sta_cfi
.id
= le16_to_cpu(hw
->cap_act_sta_cfi
.id
);
831 hw
->cap_act_sta_cfi
.variant
= le16_to_cpu(hw
->cap_act_sta_cfi
.variant
);
832 hw
->cap_act_sta_cfi
.bottom
= le16_to_cpu(hw
->cap_act_sta_cfi
.bottom
);
833 hw
->cap_act_sta_cfi
.top
= le16_to_cpu(hw
->cap_act_sta_cfi
.top
);
835 netdev_info(wlandev
->netdev
,
836 "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
837 hw
->cap_act_sta_cfi
.role
, hw
->cap_act_sta_cfi
.id
,
838 hw
->cap_act_sta_cfi
.variant
, hw
->cap_act_sta_cfi
.bottom
,
839 hw
->cap_act_sta_cfi
.top
);
841 /* Compatibility range, sta f/w actor, MFI supplier */
842 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_STA_MFIACTRANGES
,
843 &hw
->cap_act_sta_mfi
,
844 sizeof(hfa384x_caplevel_t
));
846 netdev_err(wlandev
->netdev
, "Failed to retrieve STA_MFIACTRANGES\n");
850 /* get all the Compatibility range, station f/w actor, MFI supplier
851 fields in byte order */
852 hw
->cap_act_sta_mfi
.role
= le16_to_cpu(hw
->cap_act_sta_mfi
.role
);
853 hw
->cap_act_sta_mfi
.id
= le16_to_cpu(hw
->cap_act_sta_mfi
.id
);
854 hw
->cap_act_sta_mfi
.variant
= le16_to_cpu(hw
->cap_act_sta_mfi
.variant
);
855 hw
->cap_act_sta_mfi
.bottom
= le16_to_cpu(hw
->cap_act_sta_mfi
.bottom
);
856 hw
->cap_act_sta_mfi
.top
= le16_to_cpu(hw
->cap_act_sta_mfi
.top
);
858 netdev_info(wlandev
->netdev
,
859 "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
860 hw
->cap_act_sta_mfi
.role
, hw
->cap_act_sta_mfi
.id
,
861 hw
->cap_act_sta_mfi
.variant
, hw
->cap_act_sta_mfi
.bottom
,
862 hw
->cap_act_sta_mfi
.top
);
865 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_NICSERIALNUMBER
,
866 snum
, HFA384x_RID_NICSERIALNUMBER_LEN
);
868 wlan_mkprintstr(snum
, HFA384x_RID_NICSERIALNUMBER_LEN
,
870 netdev_info(wlandev
->netdev
, "Prism2 card SN: %s\n", pstr
);
872 netdev_err(wlandev
->netdev
, "Failed to retrieve Prism2 Card SN\n");
876 /* Collect the MAC address */
877 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_CNFOWNMACADDR
,
878 wlandev
->netdev
->dev_addr
, ETH_ALEN
);
880 netdev_err(wlandev
->netdev
, "Failed to retrieve mac address\n");
884 /* short preamble is always implemented */
885 wlandev
->nsdcaps
|= P80211_NSDCAP_SHORT_PREAMBLE
;
887 /* find out if hardware wep is implemented */
888 hfa384x_drvr_getconfig16(hw
, HFA384x_RID_PRIVACYOPTIMP
, &temp
);
890 wlandev
->nsdcaps
|= P80211_NSDCAP_HARDWAREWEP
;
892 /* get the dBm Scaling constant */
893 hfa384x_drvr_getconfig16(hw
, HFA384x_RID_CNFDBMADJUST
, &temp
);
894 hw
->dbmadjust
= temp
;
896 /* Only enable scan by default on newer firmware */
897 if (HFA384x_FIRMWARE_VERSION(hw
->ident_sta_fw
.major
,
898 hw
->ident_sta_fw
.minor
,
899 hw
->ident_sta_fw
.variant
) <
900 HFA384x_FIRMWARE_VERSION(1, 5, 5)) {
901 wlandev
->nsdcaps
|= P80211_NSDCAP_NOSCAN
;
904 /* TODO: Set any internally managed config items */
908 netdev_err(wlandev
->netdev
, "Failed, result=%d\n", result
);
913 /*----------------------------------------------------------------
914 * prism2sta_globalsetup
916 * Set any global RIDs that we want to set at device activation.
919 * wlandev wlan device structure
923 * >0 f/w reported error
924 * <0 driver reported error
930 ----------------------------------------------------------------*/
931 static int prism2sta_globalsetup(wlandevice_t
*wlandev
)
933 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
935 /* Set the maximum frame size */
936 return hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFMAXDATALEN
,
940 static int prism2sta_setmulticast(wlandevice_t
*wlandev
, netdevice_t
*dev
)
943 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
947 /* If we're not ready, what's the point? */
948 if (hw
->state
!= HFA384x_STATE_RUNNING
)
951 if ((dev
->flags
& (IFF_PROMISC
| IFF_ALLMULTI
)) != 0)
952 promisc
= P80211ENUM_truth_true
;
954 promisc
= P80211ENUM_truth_false
;
957 hfa384x_drvr_setconfig16_async(hw
, HFA384x_RID_PROMISCMODE
,
963 /*----------------------------------------------------------------
964 * prism2sta_inf_handover
966 * Handles the receipt of a Handover info frame. Should only be present
970 * wlandev wlan device structure
971 * inf ptr to info frame (contents in hfa384x order)
980 ----------------------------------------------------------------*/
981 static void prism2sta_inf_handover(wlandevice_t
*wlandev
,
982 hfa384x_InfFrame_t
*inf
)
984 pr_debug("received infoframe:HANDOVER (unhandled)\n");
987 /*----------------------------------------------------------------
988 * prism2sta_inf_tallies
990 * Handles the receipt of a CommTallies info frame.
993 * wlandev wlan device structure
994 * inf ptr to info frame (contents in hfa384x order)
1003 ----------------------------------------------------------------*/
1004 static void prism2sta_inf_tallies(wlandevice_t
*wlandev
,
1005 hfa384x_InfFrame_t
*inf
)
1007 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1015 ** Determine if these are 16-bit or 32-bit tallies, based on the
1016 ** record length of the info record.
1019 cnt
= sizeof(hfa384x_CommTallies32_t
) / sizeof(u32
);
1020 if (inf
->framelen
> 22) {
1021 dst
= (u32
*) &hw
->tallies
;
1022 src32
= (u32
*) &inf
->info
.commtallies32
;
1023 for (i
= 0; i
< cnt
; i
++, dst
++, src32
++)
1024 *dst
+= le32_to_cpu(*src32
);
1026 dst
= (u32
*) &hw
->tallies
;
1027 src16
= (u16
*) &inf
->info
.commtallies16
;
1028 for (i
= 0; i
< cnt
; i
++, dst
++, src16
++)
1029 *dst
+= le16_to_cpu(*src16
);
1033 /*----------------------------------------------------------------
1034 * prism2sta_inf_scanresults
1036 * Handles the receipt of a Scan Results info frame.
1039 * wlandev wlan device structure
1040 * inf ptr to info frame (contents in hfa384x order)
1049 ----------------------------------------------------------------*/
1050 static void prism2sta_inf_scanresults(wlandevice_t
*wlandev
,
1051 hfa384x_InfFrame_t
*inf
)
1054 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1056 hfa384x_ScanResult_t
*sr
= &(inf
->info
.scanresult
);
1058 hfa384x_JoinRequest_data_t joinreq
;
1061 /* Get the number of results, first in bytes, then in results */
1062 nbss
= (inf
->framelen
* sizeof(u16
)) -
1063 sizeof(inf
->infotype
) - sizeof(inf
->info
.scanresult
.scanreason
);
1064 nbss
/= sizeof(hfa384x_ScanResultSub_t
);
1067 pr_debug("rx scanresults, reason=%d, nbss=%d:\n",
1068 inf
->info
.scanresult
.scanreason
, nbss
);
1069 for (i
= 0; i
< nbss
; i
++) {
1070 pr_debug("chid=%d anl=%d sl=%d bcnint=%d\n",
1073 sr
->result
[i
].sl
, sr
->result
[i
].bcnint
);
1074 pr_debug(" capinfo=0x%04x proberesp_rate=%d\n",
1075 sr
->result
[i
].capinfo
, sr
->result
[i
].proberesp_rate
);
1077 /* issue a join request */
1078 joinreq
.channel
= sr
->result
[0].chid
;
1079 memcpy(joinreq
.bssid
, sr
->result
[0].bssid
, WLAN_BSSID_LEN
);
1080 result
= hfa384x_drvr_setconfig(hw
,
1081 HFA384x_RID_JOINREQUEST
,
1082 &joinreq
, HFA384x_RID_JOINREQUEST_LEN
);
1084 netdev_err(wlandev
->netdev
, "setconfig(joinreq) failed, result=%d\n",
1089 /*----------------------------------------------------------------
1090 * prism2sta_inf_hostscanresults
1092 * Handles the receipt of a Scan Results info frame.
1095 * wlandev wlan device structure
1096 * inf ptr to info frame (contents in hfa384x order)
1105 ----------------------------------------------------------------*/
1106 static void prism2sta_inf_hostscanresults(wlandevice_t
*wlandev
,
1107 hfa384x_InfFrame_t
*inf
)
1109 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1112 nbss
= (inf
->framelen
- 3) / 32;
1113 pr_debug("Received %d hostscan results\n", nbss
);
1118 kfree(hw
->scanresults
);
1120 hw
->scanresults
= kmemdup(inf
, sizeof(hfa384x_InfFrame_t
), GFP_ATOMIC
);
1125 /* Notify/wake the sleeping caller. */
1126 hw
->scanflag
= nbss
;
1127 wake_up_interruptible(&hw
->cmdq
);
1130 /*----------------------------------------------------------------
1131 * prism2sta_inf_chinforesults
1133 * Handles the receipt of a Channel Info Results info frame.
1136 * wlandev wlan device structure
1137 * inf ptr to info frame (contents in hfa384x order)
1146 ----------------------------------------------------------------*/
1147 static void prism2sta_inf_chinforesults(wlandevice_t
*wlandev
,
1148 hfa384x_InfFrame_t
*inf
)
1150 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1153 hw
->channel_info
.results
.scanchannels
=
1154 le16_to_cpu(inf
->info
.chinforesult
.scanchannels
);
1156 for (i
= 0, n
= 0; i
< HFA384x_CHINFORESULT_MAX
; i
++) {
1157 hfa384x_ChInfoResultSub_t
*result
;
1158 hfa384x_ChInfoResultSub_t
*chinforesult
;
1161 if (!(hw
->channel_info
.results
.scanchannels
& (1 << i
)))
1164 result
= &inf
->info
.chinforesult
.result
[n
];
1165 chan
= le16_to_cpu(result
->chid
) - 1;
1167 if (chan
< 0 || chan
>= HFA384x_CHINFORESULT_MAX
)
1170 chinforesult
= &hw
->channel_info
.results
.result
[chan
];
1171 chinforesult
->chid
= chan
;
1172 chinforesult
->anl
= le16_to_cpu(result
->anl
);
1173 chinforesult
->pnl
= le16_to_cpu(result
->pnl
);
1174 chinforesult
->active
= le16_to_cpu(result
->active
);
1176 pr_debug("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n",
1178 (chinforesult
->active
& HFA384x_CHINFORESULT_BSSACTIVE
)
1179 ? "signal" : "noise",
1180 chinforesult
->anl
, chinforesult
->pnl
,
1181 (chinforesult
->active
& HFA384x_CHINFORESULT_PCFACTIVE
)
1185 atomic_set(&hw
->channel_info
.done
, 2);
1187 hw
->channel_info
.count
= n
;
1190 void prism2sta_processing_defer(struct work_struct
*data
)
1192 hfa384x_t
*hw
= container_of(data
, struct hfa384x
, link_bh
);
1193 wlandevice_t
*wlandev
= hw
->wlandev
;
1194 hfa384x_bytestr32_t ssid
;
1197 /* First let's process the auth frames */
1199 struct sk_buff
*skb
;
1200 hfa384x_InfFrame_t
*inf
;
1202 while ((skb
= skb_dequeue(&hw
->authq
))) {
1203 inf
= (hfa384x_InfFrame_t
*) skb
->data
;
1204 prism2sta_inf_authreq_defer(wlandev
, inf
);
1209 /* Now let's handle the linkstatus stuff */
1210 if (hw
->link_status
== hw
->link_status_new
)
1213 hw
->link_status
= hw
->link_status_new
;
1215 switch (hw
->link_status
) {
1216 case HFA384x_LINK_NOTCONNECTED
:
1217 /* I'm currently assuming that this is the initial link
1218 * state. It should only be possible immediately
1219 * following an Enable command.
1221 * Block Transmits, Ignore receives of data frames
1223 netif_carrier_off(wlandev
->netdev
);
1225 netdev_info(wlandev
->netdev
, "linkstatus=NOTCONNECTED (unhandled)\n");
1228 case HFA384x_LINK_CONNECTED
:
1229 /* This one indicates a successful scan/join/auth/assoc.
1230 * When we have the full MLME complement, this event will
1231 * signify successful completion of both mlme_authenticate
1232 * and mlme_associate. State management will get a little
1235 * Indicate authentication and/or association
1236 * Enable Transmits, Receives and pass up data frames
1239 netif_carrier_on(wlandev
->netdev
);
1241 /* If we are joining a specific AP, set our
1242 * state and reset retries
1244 if (hw
->join_ap
== 1)
1246 hw
->join_retries
= 60;
1248 /* Don't call this in monitor mode */
1249 if (wlandev
->netdev
->type
== ARPHRD_ETHER
) {
1252 netdev_info(wlandev
->netdev
, "linkstatus=CONNECTED\n");
1254 /* For non-usb devices, we can use the sync versions */
1255 /* Collect the BSSID, and set state to allow tx */
1257 result
= hfa384x_drvr_getconfig(hw
,
1258 HFA384x_RID_CURRENTBSSID
,
1263 ("getconfig(0x%02x) failed, result = %d\n",
1264 HFA384x_RID_CURRENTBSSID
, result
);
1268 result
= hfa384x_drvr_getconfig(hw
,
1269 HFA384x_RID_CURRENTSSID
,
1270 &ssid
, sizeof(ssid
));
1273 ("getconfig(0x%02x) failed, result = %d\n",
1274 HFA384x_RID_CURRENTSSID
, result
);
1277 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr
*) &ssid
,
1281 /* Collect the port status */
1282 result
= hfa384x_drvr_getconfig16(hw
,
1283 HFA384x_RID_PORTSTATUS
,
1287 ("getconfig(0x%02x) failed, result = %d\n",
1288 HFA384x_RID_PORTSTATUS
, result
);
1292 (portstatus
== HFA384x_PSTATUS_CONN_IBSS
) ?
1293 WLAN_MACMODE_IBSS_STA
: WLAN_MACMODE_ESS_STA
;
1295 /* signal back up to cfg80211 layer */
1296 prism2_connect_result(wlandev
, P80211ENUM_truth_false
);
1298 /* Get the ball rolling on the comms quality stuff */
1299 prism2sta_commsqual_defer(&hw
->commsqual_bh
);
1303 case HFA384x_LINK_DISCONNECTED
:
1304 /* This one indicates that our association is gone. We've
1305 * lost connection with the AP and/or been disassociated.
1306 * This indicates that the MAC has completely cleared it's
1307 * associated state. We * should send a deauth indication
1308 * (implying disassoc) up * to the MLME.
1310 * Indicate Deauthentication
1311 * Block Transmits, Ignore receives of data frames
1313 if (wlandev
->netdev
->type
== ARPHRD_ETHER
)
1314 netdev_info(wlandev
->netdev
,
1315 "linkstatus=DISCONNECTED (unhandled)\n");
1316 wlandev
->macmode
= WLAN_MACMODE_NONE
;
1318 netif_carrier_off(wlandev
->netdev
);
1320 /* signal back up to cfg80211 layer */
1321 prism2_disconnected(wlandev
);
1325 case HFA384x_LINK_AP_CHANGE
:
1326 /* This one indicates that the MAC has decided to and
1327 * successfully completed a change to another AP. We
1328 * should probably implement a reassociation indication
1329 * in response to this one. I'm thinking that the the
1330 * p80211 layer needs to be notified in case of
1331 * buffering/queueing issues. User mode also needs to be
1332 * notified so that any BSS dependent elements can be
1334 * associated state. We * should send a deauth indication
1335 * (implying disassoc) up * to the MLME.
1337 * Indicate Reassociation
1338 * Enable Transmits, Receives and pass up data frames
1340 netdev_info(wlandev
->netdev
, "linkstatus=AP_CHANGE\n");
1342 result
= hfa384x_drvr_getconfig(hw
,
1343 HFA384x_RID_CURRENTBSSID
,
1344 wlandev
->bssid
, WLAN_BSSID_LEN
);
1346 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1347 HFA384x_RID_CURRENTBSSID
, result
);
1351 result
= hfa384x_drvr_getconfig(hw
,
1352 HFA384x_RID_CURRENTSSID
,
1353 &ssid
, sizeof(ssid
));
1355 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1356 HFA384x_RID_CURRENTSSID
, result
);
1359 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr
*) &ssid
,
1360 (p80211pstrd_t
*) &wlandev
->ssid
);
1362 hw
->link_status
= HFA384x_LINK_CONNECTED
;
1363 netif_carrier_on(wlandev
->netdev
);
1365 /* signal back up to cfg80211 layer */
1366 prism2_roamed(wlandev
);
1370 case HFA384x_LINK_AP_OUTOFRANGE
:
1371 /* This one indicates that the MAC has decided that the
1372 * AP is out of range, but hasn't found a better candidate
1373 * so the MAC maintains its "associated" state in case
1374 * we get back in range. We should block transmits and
1375 * receives in this state. Do we need an indication here?
1376 * Probably not since a polling user-mode element would
1377 * get this status from from p2PortStatus(FD40). What about
1380 * Block Transmits, Ignore receives of data frames
1382 netdev_info(wlandev
->netdev
, "linkstatus=AP_OUTOFRANGE (unhandled)\n");
1384 netif_carrier_off(wlandev
->netdev
);
1388 case HFA384x_LINK_AP_INRANGE
:
1389 /* This one indicates that the MAC has decided that the
1390 * AP is back in range. We continue working with our
1391 * existing association.
1393 * Enable Transmits, Receives and pass up data frames
1395 netdev_info(wlandev
->netdev
, "linkstatus=AP_INRANGE\n");
1397 hw
->link_status
= HFA384x_LINK_CONNECTED
;
1398 netif_carrier_on(wlandev
->netdev
);
1402 case HFA384x_LINK_ASSOCFAIL
:
1403 /* This one is actually a peer to CONNECTED. We've
1404 * requested a join for a given SSID and optionally BSSID.
1405 * We can use this one to indicate authentication and
1406 * association failures. The trick is going to be
1407 * 1) identifying the failure, and 2) state management.
1409 * Disable Transmits, Ignore receives of data frames
1411 if (hw
->join_ap
&& --hw
->join_retries
> 0) {
1412 hfa384x_JoinRequest_data_t joinreq
;
1413 joinreq
= hw
->joinreq
;
1414 /* Send the join request */
1415 hfa384x_drvr_setconfig(hw
,
1416 HFA384x_RID_JOINREQUEST
,
1418 HFA384x_RID_JOINREQUEST_LEN
);
1419 netdev_info(wlandev
->netdev
,
1420 "linkstatus=ASSOCFAIL (re-submitting join)\n");
1422 netdev_info(wlandev
->netdev
, "linkstatus=ASSOCFAIL (unhandled)\n");
1425 netif_carrier_off(wlandev
->netdev
);
1427 /* signal back up to cfg80211 layer */
1428 prism2_connect_result(wlandev
, P80211ENUM_truth_true
);
1433 /* This is bad, IO port problems? */
1435 "unknown linkstatus=0x%02x\n", hw
->link_status
);
1439 wlandev
->linkstatus
= (hw
->link_status
== HFA384x_LINK_CONNECTED
);
1442 /*----------------------------------------------------------------
1443 * prism2sta_inf_linkstatus
1445 * Handles the receipt of a Link Status info frame.
1448 * wlandev wlan device structure
1449 * inf ptr to info frame (contents in hfa384x order)
1458 ----------------------------------------------------------------*/
1459 static void prism2sta_inf_linkstatus(wlandevice_t
*wlandev
,
1460 hfa384x_InfFrame_t
*inf
)
1462 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1464 hw
->link_status_new
= le16_to_cpu(inf
->info
.linkstatus
.linkstatus
);
1466 schedule_work(&hw
->link_bh
);
1469 /*----------------------------------------------------------------
1470 * prism2sta_inf_assocstatus
1472 * Handles the receipt of an Association Status info frame. Should
1473 * be present in APs only.
1476 * wlandev wlan device structure
1477 * inf ptr to info frame (contents in hfa384x order)
1486 ----------------------------------------------------------------*/
1487 static void prism2sta_inf_assocstatus(wlandevice_t
*wlandev
,
1488 hfa384x_InfFrame_t
*inf
)
1490 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1491 hfa384x_AssocStatus_t rec
;
1494 memcpy(&rec
, &inf
->info
.assocstatus
, sizeof(rec
));
1495 rec
.assocstatus
= le16_to_cpu(rec
.assocstatus
);
1496 rec
.reason
= le16_to_cpu(rec
.reason
);
1499 ** Find the address in the list of authenticated stations.
1500 ** If it wasn't found, then this address has not been previously
1501 ** authenticated and something weird has happened if this is
1502 ** anything other than an "authentication failed" message.
1503 ** If the address was found, then set the "associated" flag for
1504 ** that station, based on whether the station is associating or
1505 ** losing its association. Something weird has also happened
1506 ** if we find the address in the list of authenticated stations
1507 ** but we are getting an "authentication failed" message.
1510 for (i
= 0; i
< hw
->authlist
.cnt
; i
++)
1511 if (memcmp(rec
.sta_addr
, hw
->authlist
.addr
[i
], ETH_ALEN
) == 0)
1514 if (i
>= hw
->authlist
.cnt
) {
1515 if (rec
.assocstatus
!= HFA384x_ASSOCSTATUS_AUTHFAIL
)
1517 "assocstatus info frame received for non-authenticated station.\n");
1519 hw
->authlist
.assoc
[i
] =
1520 (rec
.assocstatus
== HFA384x_ASSOCSTATUS_STAASSOC
||
1521 rec
.assocstatus
== HFA384x_ASSOCSTATUS_REASSOC
);
1523 if (rec
.assocstatus
== HFA384x_ASSOCSTATUS_AUTHFAIL
)
1525 "authfail assocstatus info frame received for authenticated station.\n");
1529 /*----------------------------------------------------------------
1530 * prism2sta_inf_authreq
1532 * Handles the receipt of an Authentication Request info frame. Should
1533 * be present in APs only.
1536 * wlandev wlan device structure
1537 * inf ptr to info frame (contents in hfa384x order)
1547 ----------------------------------------------------------------*/
1548 static void prism2sta_inf_authreq(wlandevice_t
*wlandev
,
1549 hfa384x_InfFrame_t
*inf
)
1551 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1552 struct sk_buff
*skb
;
1554 skb
= dev_alloc_skb(sizeof(*inf
));
1556 skb_put(skb
, sizeof(*inf
));
1557 memcpy(skb
->data
, inf
, sizeof(*inf
));
1558 skb_queue_tail(&hw
->authq
, skb
);
1559 schedule_work(&hw
->link_bh
);
1563 static void prism2sta_inf_authreq_defer(wlandevice_t
*wlandev
,
1564 hfa384x_InfFrame_t
*inf
)
1566 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1567 hfa384x_authenticateStation_data_t rec
;
1569 int i
, added
, result
, cnt
;
1573 ** Build the AuthenticateStation record. Initialize it for denying
1577 memcpy(rec
.address
, inf
->info
.authreq
.sta_addr
, ETH_ALEN
);
1578 rec
.status
= P80211ENUM_status_unspec_failure
;
1581 ** Authenticate based on the access mode.
1584 switch (hw
->accessmode
) {
1585 case WLAN_ACCESS_NONE
:
1588 ** Deny all new authentications. However, if a station
1589 ** is ALREADY authenticated, then accept it.
1592 for (i
= 0; i
< hw
->authlist
.cnt
; i
++)
1593 if (memcmp(rec
.address
, hw
->authlist
.addr
[i
],
1595 rec
.status
= P80211ENUM_status_successful
;
1601 case WLAN_ACCESS_ALL
:
1604 ** Allow all authentications.
1607 rec
.status
= P80211ENUM_status_successful
;
1610 case WLAN_ACCESS_ALLOW
:
1613 ** Only allow the authentication if the MAC address
1614 ** is in the list of allowed addresses.
1616 ** Since this is the interrupt handler, we may be here
1617 ** while the access list is in the middle of being
1618 ** updated. Choose the list which is currently okay.
1619 ** See "prism2mib_priv_accessallow()" for details.
1622 if (hw
->allow
.modify
== 0) {
1623 cnt
= hw
->allow
.cnt
;
1624 addr
= hw
->allow
.addr
[0];
1626 cnt
= hw
->allow
.cnt1
;
1627 addr
= hw
->allow
.addr1
[0];
1630 for (i
= 0; i
< cnt
; i
++, addr
+= ETH_ALEN
)
1631 if (memcmp(rec
.address
, addr
, ETH_ALEN
) == 0) {
1632 rec
.status
= P80211ENUM_status_successful
;
1638 case WLAN_ACCESS_DENY
:
1641 ** Allow the authentication UNLESS the MAC address is
1642 ** in the list of denied addresses.
1644 ** Since this is the interrupt handler, we may be here
1645 ** while the access list is in the middle of being
1646 ** updated. Choose the list which is currently okay.
1647 ** See "prism2mib_priv_accessdeny()" for details.
1650 if (hw
->deny
.modify
== 0) {
1652 addr
= hw
->deny
.addr
[0];
1654 cnt
= hw
->deny
.cnt1
;
1655 addr
= hw
->deny
.addr1
[0];
1658 rec
.status
= P80211ENUM_status_successful
;
1660 for (i
= 0; i
< cnt
; i
++, addr
+= ETH_ALEN
)
1661 if (memcmp(rec
.address
, addr
, ETH_ALEN
) == 0) {
1662 rec
.status
= P80211ENUM_status_unspec_failure
;
1670 ** If the authentication is okay, then add the MAC address to the
1671 ** list of authenticated stations. Don't add the address if it
1672 ** is already in the list. (802.11b does not seem to disallow
1673 ** a station from issuing an authentication request when the
1674 ** station is already authenticated. Does this sort of thing
1675 ** ever happen? We might as well do the check just in case.)
1680 if (rec
.status
== P80211ENUM_status_successful
) {
1681 for (i
= 0; i
< hw
->authlist
.cnt
; i
++)
1682 if (memcmp(rec
.address
, hw
->authlist
.addr
[i
], ETH_ALEN
)
1686 if (i
>= hw
->authlist
.cnt
) {
1687 if (hw
->authlist
.cnt
>= WLAN_AUTH_MAX
) {
1688 rec
.status
= P80211ENUM_status_ap_full
;
1690 memcpy(hw
->authlist
.addr
[hw
->authlist
.cnt
],
1691 rec
.address
, ETH_ALEN
);
1699 ** Send back the results of the authentication. If this doesn't work,
1700 ** then make sure to remove the address from the authenticated list if
1704 rec
.status
= cpu_to_le16(rec
.status
);
1705 rec
.algorithm
= inf
->info
.authreq
.algorithm
;
1707 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_AUTHENTICATESTA
,
1712 netdev_err(wlandev
->netdev
,
1713 "setconfig(authenticatestation) failed, result=%d\n",
1718 /*----------------------------------------------------------------
1719 * prism2sta_inf_psusercnt
1721 * Handles the receipt of a PowerSaveUserCount info frame. Should
1722 * be present in APs only.
1725 * wlandev wlan device structure
1726 * inf ptr to info frame (contents in hfa384x order)
1735 ----------------------------------------------------------------*/
1736 static void prism2sta_inf_psusercnt(wlandevice_t
*wlandev
,
1737 hfa384x_InfFrame_t
*inf
)
1739 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1741 hw
->psusercount
= le16_to_cpu(inf
->info
.psusercnt
.usercnt
);
1744 /*----------------------------------------------------------------
1747 * Handles the Info event.
1750 * wlandev wlan device structure
1751 * inf ptr to a generic info frame
1760 ----------------------------------------------------------------*/
1761 void prism2sta_ev_info(wlandevice_t
*wlandev
, hfa384x_InfFrame_t
*inf
)
1763 inf
->infotype
= le16_to_cpu(inf
->infotype
);
1765 switch (inf
->infotype
) {
1766 case HFA384x_IT_HANDOVERADDR
:
1767 prism2sta_inf_handover(wlandev
, inf
);
1769 case HFA384x_IT_COMMTALLIES
:
1770 prism2sta_inf_tallies(wlandev
, inf
);
1772 case HFA384x_IT_HOSTSCANRESULTS
:
1773 prism2sta_inf_hostscanresults(wlandev
, inf
);
1775 case HFA384x_IT_SCANRESULTS
:
1776 prism2sta_inf_scanresults(wlandev
, inf
);
1778 case HFA384x_IT_CHINFORESULTS
:
1779 prism2sta_inf_chinforesults(wlandev
, inf
);
1781 case HFA384x_IT_LINKSTATUS
:
1782 prism2sta_inf_linkstatus(wlandev
, inf
);
1784 case HFA384x_IT_ASSOCSTATUS
:
1785 prism2sta_inf_assocstatus(wlandev
, inf
);
1787 case HFA384x_IT_AUTHREQ
:
1788 prism2sta_inf_authreq(wlandev
, inf
);
1790 case HFA384x_IT_PSUSERCNT
:
1791 prism2sta_inf_psusercnt(wlandev
, inf
);
1793 case HFA384x_IT_KEYIDCHANGED
:
1794 printk(KERN_WARNING
"Unhandled IT_KEYIDCHANGED\n");
1796 case HFA384x_IT_ASSOCREQ
:
1797 printk(KERN_WARNING
"Unhandled IT_ASSOCREQ\n");
1799 case HFA384x_IT_MICFAILURE
:
1800 printk(KERN_WARNING
"Unhandled IT_MICFAILURE\n");
1804 "Unknown info type=0x%02x\n", inf
->infotype
);
1809 /*----------------------------------------------------------------
1810 * prism2sta_ev_txexc
1812 * Handles the TxExc event. A Transmit Exception event indicates
1813 * that the MAC's TX process was unsuccessful - so the packet did
1814 * not get transmitted.
1817 * wlandev wlan device structure
1818 * status tx frame status word
1827 ----------------------------------------------------------------*/
1828 void prism2sta_ev_txexc(wlandevice_t
*wlandev
, u16 status
)
1830 pr_debug("TxExc status=0x%x.\n", status
);
1833 /*----------------------------------------------------------------
1836 * Handles the Tx event.
1839 * wlandev wlan device structure
1840 * status tx frame status word
1848 ----------------------------------------------------------------*/
1849 void prism2sta_ev_tx(wlandevice_t
*wlandev
, u16 status
)
1851 pr_debug("Tx Complete, status=0x%04x\n", status
);
1852 /* update linux network stats */
1853 wlandev
->linux_stats
.tx_packets
++;
1856 /*----------------------------------------------------------------
1859 * Handles the Rx event.
1862 * wlandev wlan device structure
1871 ----------------------------------------------------------------*/
1872 void prism2sta_ev_rx(wlandevice_t
*wlandev
, struct sk_buff
*skb
)
1874 p80211netdev_rx(wlandev
, skb
);
1877 /*----------------------------------------------------------------
1878 * prism2sta_ev_alloc
1880 * Handles the Alloc event.
1883 * wlandev wlan device structure
1892 ----------------------------------------------------------------*/
1893 void prism2sta_ev_alloc(wlandevice_t
*wlandev
)
1895 netif_wake_queue(wlandev
->netdev
);
1898 /*----------------------------------------------------------------
1901 * Called at module init time. This creates the wlandevice_t structure
1902 * and initializes it with relevant bits.
1908 * the created wlandevice_t structure.
1911 * also allocates the priv/hw structures.
1916 ----------------------------------------------------------------*/
1917 static wlandevice_t
*create_wlan(void)
1919 wlandevice_t
*wlandev
= NULL
;
1920 hfa384x_t
*hw
= NULL
;
1922 /* Alloc our structures */
1923 wlandev
= kzalloc(sizeof(wlandevice_t
), GFP_KERNEL
);
1924 hw
= kzalloc(sizeof(hfa384x_t
), GFP_KERNEL
);
1926 if (!wlandev
|| !hw
) {
1927 pr_err("%s: Memory allocation failure.\n", dev_info
);
1933 /* Initialize the network device object. */
1934 wlandev
->nsdname
= dev_info
;
1935 wlandev
->msdstate
= WLAN_MSD_HWPRESENT_PENDING
;
1937 wlandev
->open
= prism2sta_open
;
1938 wlandev
->close
= prism2sta_close
;
1939 wlandev
->reset
= prism2sta_reset
;
1940 wlandev
->txframe
= prism2sta_txframe
;
1941 wlandev
->mlmerequest
= prism2sta_mlmerequest
;
1942 wlandev
->set_multicast_list
= prism2sta_setmulticast
;
1943 wlandev
->tx_timeout
= hfa384x_tx_timeout
;
1945 wlandev
->nsdcaps
= P80211_NSDCAP_HWFRAGMENT
| P80211_NSDCAP_AUTOJOIN
;
1947 /* Initialize the device private data structure. */
1948 hw
->dot11_desired_bss_type
= 1;
1953 void prism2sta_commsqual_defer(struct work_struct
*data
)
1955 hfa384x_t
*hw
= container_of(data
, struct hfa384x
, commsqual_bh
);
1956 wlandevice_t
*wlandev
= hw
->wlandev
;
1957 hfa384x_bytestr32_t ssid
;
1958 struct p80211msg_dot11req_mibget msg
;
1959 p80211item_uint32_t
*mibitem
= (p80211item_uint32_t
*)
1960 &msg
.mibattribute
.data
;
1963 if (hw
->wlandev
->hwremoved
)
1966 /* we don't care if we're in AP mode */
1967 if ((wlandev
->macmode
== WLAN_MACMODE_NONE
) ||
1968 (wlandev
->macmode
== WLAN_MACMODE_ESS_AP
)) {
1972 /* It only makes sense to poll these in non-IBSS */
1973 if (wlandev
->macmode
!= WLAN_MACMODE_IBSS_STA
) {
1974 result
= hfa384x_drvr_getconfig(
1975 hw
, HFA384x_RID_DBMCOMMSQUALITY
,
1976 &hw
->qual
, HFA384x_RID_DBMCOMMSQUALITY_LEN
);
1979 netdev_err(wlandev
->netdev
, "error fetching commsqual\n");
1983 pr_debug("commsqual %d %d %d\n",
1984 le16_to_cpu(hw
->qual
.CQ_currBSS
),
1985 le16_to_cpu(hw
->qual
.ASL_currBSS
),
1986 le16_to_cpu(hw
->qual
.ANL_currFC
));
1989 /* Get the signal rate */
1990 msg
.msgcode
= DIDmsg_dot11req_mibget
;
1991 mibitem
->did
= DIDmib_p2_p2MAC_p2CurrentTxRate
;
1992 result
= p80211req_dorequest(wlandev
, (u8
*) &msg
);
1995 pr_debug("get signal rate failed, result = %d\n",
2000 switch (mibitem
->data
) {
2001 case HFA384x_RATEBIT_1
:
2004 case HFA384x_RATEBIT_2
:
2007 case HFA384x_RATEBIT_5dot5
:
2010 case HFA384x_RATEBIT_11
:
2014 pr_debug("Bad ratebit (%d)\n", mibitem
->data
);
2017 /* Lastly, we need to make sure the BSSID didn't change on us */
2018 result
= hfa384x_drvr_getconfig(hw
,
2019 HFA384x_RID_CURRENTBSSID
,
2020 wlandev
->bssid
, WLAN_BSSID_LEN
);
2022 pr_debug("getconfig(0x%02x) failed, result = %d\n",
2023 HFA384x_RID_CURRENTBSSID
, result
);
2027 result
= hfa384x_drvr_getconfig(hw
,
2028 HFA384x_RID_CURRENTSSID
,
2029 &ssid
, sizeof(ssid
));
2031 pr_debug("getconfig(0x%02x) failed, result = %d\n",
2032 HFA384x_RID_CURRENTSSID
, result
);
2035 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr
*) &ssid
,
2036 (p80211pstrd_t
*) &wlandev
->ssid
);
2038 /* Reschedule timer */
2039 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
);