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 static int prism2sta_open(wlandevice_t
*wlandev
);
124 static int prism2sta_close(wlandevice_t
*wlandev
);
125 static void prism2sta_reset(wlandevice_t
*wlandev
);
126 static int prism2sta_txframe(wlandevice_t
*wlandev
, struct sk_buff
*skb
,
127 union p80211_hdr
*p80211_hdr
,
128 struct p80211_metawep
*p80211_wep
);
129 static int prism2sta_mlmerequest(wlandevice_t
*wlandev
, struct p80211msg
*msg
);
130 static int prism2sta_getcardinfo(wlandevice_t
*wlandev
);
131 static int prism2sta_globalsetup(wlandevice_t
*wlandev
);
132 static int prism2sta_setmulticast(wlandevice_t
*wlandev
, netdevice_t
*dev
);
134 static void prism2sta_inf_handover(wlandevice_t
*wlandev
,
135 hfa384x_InfFrame_t
*inf
);
136 static void prism2sta_inf_tallies(wlandevice_t
*wlandev
,
137 hfa384x_InfFrame_t
*inf
);
138 static void prism2sta_inf_hostscanresults(wlandevice_t
*wlandev
,
139 hfa384x_InfFrame_t
*inf
);
140 static void prism2sta_inf_scanresults(wlandevice_t
*wlandev
,
141 hfa384x_InfFrame_t
*inf
);
142 static void prism2sta_inf_chinforesults(wlandevice_t
*wlandev
,
143 hfa384x_InfFrame_t
*inf
);
144 static void prism2sta_inf_linkstatus(wlandevice_t
*wlandev
,
145 hfa384x_InfFrame_t
*inf
);
146 static void prism2sta_inf_assocstatus(wlandevice_t
*wlandev
,
147 hfa384x_InfFrame_t
*inf
);
148 static void prism2sta_inf_authreq(wlandevice_t
*wlandev
,
149 hfa384x_InfFrame_t
*inf
);
150 static void prism2sta_inf_authreq_defer(wlandevice_t
*wlandev
,
151 hfa384x_InfFrame_t
*inf
);
152 static void prism2sta_inf_psusercnt(wlandevice_t
*wlandev
,
153 hfa384x_InfFrame_t
*inf
);
155 /*----------------------------------------------------------------
158 * WLAN device open method. Called from p80211netdev when kernel
159 * device open (start) method is called in response to the
160 * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
164 * wlandev wlan device structure
168 * >0 f/w reported error
169 * <0 driver reported error
175 ----------------------------------------------------------------*/
176 static int prism2sta_open(wlandevice_t
*wlandev
)
178 /* We don't currently have to do anything else.
179 * The setup of the MAC should be subsequently completed via
181 * Higher layers know we're ready from dev->start==1 and
182 * dev->tbusy==0. Our rx path knows to pass up received/
183 * frames because of dev->flags&IFF_UP is true.
189 /*----------------------------------------------------------------
192 * WLAN device close method. Called from p80211netdev when kernel
193 * device close method is called in response to the
194 * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
198 * wlandev wlan device structure
202 * >0 f/w reported error
203 * <0 driver reported error
209 ----------------------------------------------------------------*/
210 static int prism2sta_close(wlandevice_t
*wlandev
)
212 /* We don't currently have to do anything else.
213 * Higher layers know we're not ready from dev->start==0 and
214 * dev->tbusy==1. Our rx path knows to not pass up received
215 * frames because of dev->flags&IFF_UP is false.
221 /*----------------------------------------------------------------
224 * Not currently implented.
227 * wlandev wlan device structure
237 ----------------------------------------------------------------*/
238 static void prism2sta_reset(wlandevice_t
*wlandev
)
242 /*----------------------------------------------------------------
245 * Takes a frame from p80211 and queues it for transmission.
248 * wlandev wlan device structure
249 * pb packet buffer struct. Contains an 802.11
251 * p80211_hdr points to the 802.11 header for the packet.
253 * 0 Success and more buffs available
254 * 1 Success but no more buffs
255 * 2 Allocation failure
256 * 4 Buffer full or queue busy
262 ----------------------------------------------------------------*/
263 static int prism2sta_txframe(wlandevice_t
*wlandev
, struct sk_buff
*skb
,
264 union p80211_hdr
*p80211_hdr
,
265 struct p80211_metawep
*p80211_wep
)
267 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
270 /* If necessary, set the 802.11 WEP bit */
271 if ((wlandev
->hostwep
& (HOSTWEP_PRIVACYINVOKED
| HOSTWEP_ENCRYPT
)) ==
272 HOSTWEP_PRIVACYINVOKED
) {
273 p80211_hdr
->a3
.fc
|= cpu_to_le16(WLAN_SET_FC_ISWEP(1));
276 result
= hfa384x_drvr_txframe(hw
, skb
, p80211_hdr
, p80211_wep
);
281 /*----------------------------------------------------------------
282 * prism2sta_mlmerequest
284 * wlan command message handler. All we do here is pass the message
285 * over to the prism2sta_mgmt_handler.
288 * wlandev wlan device structure
289 * msg wlan command message
292 * <0 successful acceptance of message, but we're
293 * waiting for an async process to finish before
294 * we're done with the msg. When the asynch
295 * process is done, we'll call the p80211
296 * function p80211req_confirm() .
297 * >0 An error occurred while we were handling
304 ----------------------------------------------------------------*/
305 static int prism2sta_mlmerequest(wlandevice_t
*wlandev
, struct p80211msg
*msg
)
307 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
311 switch (msg
->msgcode
) {
312 case DIDmsg_dot11req_mibget
:
313 pr_debug("Received mibget request\n");
314 result
= prism2mgmt_mibset_mibget(wlandev
, msg
);
316 case DIDmsg_dot11req_mibset
:
317 pr_debug("Received mibset request\n");
318 result
= prism2mgmt_mibset_mibget(wlandev
, msg
);
320 case DIDmsg_dot11req_scan
:
321 pr_debug("Received scan request\n");
322 result
= prism2mgmt_scan(wlandev
, msg
);
324 case DIDmsg_dot11req_scan_results
:
325 pr_debug("Received scan_results request\n");
326 result
= prism2mgmt_scan_results(wlandev
, msg
);
328 case DIDmsg_dot11req_start
:
329 pr_debug("Received mlme start request\n");
330 result
= prism2mgmt_start(wlandev
, msg
);
333 * Prism2 specific messages
335 case DIDmsg_p2req_readpda
:
336 pr_debug("Received mlme readpda request\n");
337 result
= prism2mgmt_readpda(wlandev
, msg
);
339 case DIDmsg_p2req_ramdl_state
:
340 pr_debug("Received mlme ramdl_state request\n");
341 result
= prism2mgmt_ramdl_state(wlandev
, msg
);
343 case DIDmsg_p2req_ramdl_write
:
344 pr_debug("Received mlme ramdl_write request\n");
345 result
= prism2mgmt_ramdl_write(wlandev
, msg
);
347 case DIDmsg_p2req_flashdl_state
:
348 pr_debug("Received mlme flashdl_state request\n");
349 result
= prism2mgmt_flashdl_state(wlandev
, msg
);
351 case DIDmsg_p2req_flashdl_write
:
352 pr_debug("Received mlme flashdl_write request\n");
353 result
= prism2mgmt_flashdl_write(wlandev
, msg
);
356 * Linux specific messages
358 case DIDmsg_lnxreq_hostwep
:
359 break; /* ignore me. */
360 case DIDmsg_lnxreq_ifstate
:
362 struct p80211msg_lnxreq_ifstate
*ifstatemsg
;
363 pr_debug("Received mlme ifstate request\n");
364 ifstatemsg
= (struct p80211msg_lnxreq_ifstate
*) msg
;
366 prism2sta_ifstate(wlandev
,
367 ifstatemsg
->ifstate
.data
);
368 ifstatemsg
->resultcode
.status
=
369 P80211ENUM_msgitem_status_data_ok
;
370 ifstatemsg
->resultcode
.data
= result
;
374 case DIDmsg_lnxreq_wlansniff
:
375 pr_debug("Received mlme wlansniff request\n");
376 result
= prism2mgmt_wlansniff(wlandev
, msg
);
378 case DIDmsg_lnxreq_autojoin
:
379 pr_debug("Received mlme autojoin request\n");
380 result
= prism2mgmt_autojoin(wlandev
, msg
);
382 case DIDmsg_lnxreq_commsquality
:{
383 struct p80211msg_lnxreq_commsquality
*qualmsg
;
385 pr_debug("Received commsquality request\n");
387 qualmsg
= (struct p80211msg_lnxreq_commsquality
*) msg
;
389 qualmsg
->link
.status
=
390 P80211ENUM_msgitem_status_data_ok
;
391 qualmsg
->level
.status
=
392 P80211ENUM_msgitem_status_data_ok
;
393 qualmsg
->noise
.status
=
394 P80211ENUM_msgitem_status_data_ok
;
396 qualmsg
->link
.data
= le16_to_cpu(hw
->qual
.CQ_currBSS
);
397 qualmsg
->level
.data
= le16_to_cpu(hw
->qual
.ASL_currBSS
);
398 qualmsg
->noise
.data
= le16_to_cpu(hw
->qual
.ANL_currFC
);
399 qualmsg
->txrate
.data
= hw
->txrate
;
404 printk(KERN_WARNING
"Unknown mgmt request message 0x%08x",
412 /*----------------------------------------------------------------
415 * Interface state. This is the primary WLAN interface enable/disable
416 * handler. Following the driver/load/deviceprobe sequence, this
417 * function must be called with a state of "enable" before any other
418 * commands will be accepted.
421 * wlandev wlan device structure
422 * msgp ptr to msg buffer
425 * A p80211 message resultcode value.
430 * process thread (usually)
432 ----------------------------------------------------------------*/
433 u32
prism2sta_ifstate(wlandevice_t
*wlandev
, u32 ifstate
)
435 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
438 result
= P80211ENUM_resultcode_implementation_failure
;
440 pr_debug("Current MSD state(%d), requesting(%d)\n",
441 wlandev
->msdstate
, ifstate
);
443 case P80211ENUM_ifstate_fwload
:
444 switch (wlandev
->msdstate
) {
445 case WLAN_MSD_HWPRESENT
:
446 wlandev
->msdstate
= WLAN_MSD_FWLOAD_PENDING
;
448 * Initialize the device+driver sufficiently
449 * for firmware loading.
451 result
= hfa384x_drvr_start(hw
);
453 netdev_err(wlandev
->netdev
,
454 "hfa384x_drvr_start() failed,result=%d\n", (int)result
);
456 P80211ENUM_resultcode_implementation_failure
;
457 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
460 wlandev
->msdstate
= WLAN_MSD_FWLOAD
;
461 result
= P80211ENUM_resultcode_success
;
463 case WLAN_MSD_FWLOAD
:
464 hfa384x_cmd_initialize(hw
);
465 result
= P80211ENUM_resultcode_success
;
467 case WLAN_MSD_RUNNING
:
469 "Cannot enter fwload state from enable state,"
470 "you must disable first.\n");
471 result
= P80211ENUM_resultcode_invalid_parameters
;
473 case WLAN_MSD_HWFAIL
:
475 /* probe() had a problem or the msdstate contains
476 * an unrecognized value, there's nothing we can do.
478 result
= P80211ENUM_resultcode_implementation_failure
;
482 case P80211ENUM_ifstate_enable
:
483 switch (wlandev
->msdstate
) {
484 case WLAN_MSD_HWPRESENT
:
485 case WLAN_MSD_FWLOAD
:
486 wlandev
->msdstate
= WLAN_MSD_RUNNING_PENDING
;
487 /* Initialize the device+driver for full
488 * operation. Note that this might me an FWLOAD to
489 * to RUNNING transition so we must not do a chip
490 * or board level reset. Note that on failure,
491 * the MSD state is set to HWPRESENT because we
492 * can't make any assumptions about the state
493 * of the hardware or a previous firmware load.
495 result
= hfa384x_drvr_start(hw
);
497 netdev_err(wlandev
->netdev
,
498 "hfa384x_drvr_start() failed,result=%d\n", (int)result
);
500 P80211ENUM_resultcode_implementation_failure
;
501 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
505 result
= prism2sta_getcardinfo(wlandev
);
507 netdev_err(wlandev
->netdev
,
508 "prism2sta_getcardinfo() failed,result=%d\n", (int)result
);
510 P80211ENUM_resultcode_implementation_failure
;
511 hfa384x_drvr_stop(hw
);
512 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
515 result
= prism2sta_globalsetup(wlandev
);
517 netdev_err(wlandev
->netdev
,
518 "prism2sta_globalsetup() failed,result=%d\n", (int)result
);
520 P80211ENUM_resultcode_implementation_failure
;
521 hfa384x_drvr_stop(hw
);
522 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
525 wlandev
->msdstate
= WLAN_MSD_RUNNING
;
527 hw
->join_retries
= 60;
528 result
= P80211ENUM_resultcode_success
;
530 case WLAN_MSD_RUNNING
:
531 /* Do nothing, we're already in this state. */
532 result
= P80211ENUM_resultcode_success
;
534 case WLAN_MSD_HWFAIL
:
536 /* probe() had a problem or the msdstate contains
537 * an unrecognized value, there's nothing we can do.
539 result
= P80211ENUM_resultcode_implementation_failure
;
543 case P80211ENUM_ifstate_disable
:
544 switch (wlandev
->msdstate
) {
545 case WLAN_MSD_HWPRESENT
:
546 /* Do nothing, we're already in this state. */
547 result
= P80211ENUM_resultcode_success
;
549 case WLAN_MSD_FWLOAD
:
550 case WLAN_MSD_RUNNING
:
551 wlandev
->msdstate
= WLAN_MSD_HWPRESENT_PENDING
;
553 * TODO: Shut down the MAC completely. Here a chip
554 * or board level reset is probably called for.
555 * After a "disable" _all_ results are lost, even
556 * those from a fwload.
558 if (!wlandev
->hwremoved
)
559 netif_carrier_off(wlandev
->netdev
);
561 hfa384x_drvr_stop(hw
);
563 wlandev
->macmode
= WLAN_MACMODE_NONE
;
564 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
565 result
= P80211ENUM_resultcode_success
;
567 case WLAN_MSD_HWFAIL
:
569 /* probe() had a problem or the msdstate contains
570 * an unrecognized value, there's nothing we can do.
572 result
= P80211ENUM_resultcode_implementation_failure
;
577 result
= P80211ENUM_resultcode_invalid_parameters
;
584 /*----------------------------------------------------------------
585 * prism2sta_getcardinfo
587 * Collect the NICID, firmware version and any other identifiers
588 * we'd like to have in host-side data structures.
591 * wlandev wlan device structure
595 * >0 f/w reported error
596 * <0 driver reported error
602 ----------------------------------------------------------------*/
603 static int prism2sta_getcardinfo(wlandevice_t
*wlandev
)
606 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
608 u8 snum
[HFA384x_RID_NICSERIALNUMBER_LEN
];
609 char pstr
[(HFA384x_RID_NICSERIALNUMBER_LEN
* 4) + 1];
611 /* Collect version and compatibility info */
612 /* Some are critical, some are not */
614 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_NICIDENTITY
,
616 sizeof(hfa384x_compident_t
));
618 netdev_err(wlandev
->netdev
, "Failed to retrieve NICIDENTITY\n");
622 /* get all the nic id fields in host byte order */
623 hw
->ident_nic
.id
= le16_to_cpu(hw
->ident_nic
.id
);
624 hw
->ident_nic
.variant
= le16_to_cpu(hw
->ident_nic
.variant
);
625 hw
->ident_nic
.major
= le16_to_cpu(hw
->ident_nic
.major
);
626 hw
->ident_nic
.minor
= le16_to_cpu(hw
->ident_nic
.minor
);
628 netdev_info(wlandev
->netdev
, "ident: nic h/w: id=0x%02x %d.%d.%d\n",
629 hw
->ident_nic
.id
, hw
->ident_nic
.major
,
630 hw
->ident_nic
.minor
, hw
->ident_nic
.variant
);
632 /* Primary f/w identity */
633 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_PRIIDENTITY
,
635 sizeof(hfa384x_compident_t
));
637 netdev_err(wlandev
->netdev
, "Failed to retrieve PRIIDENTITY\n");
641 /* get all the private fw id fields in host byte order */
642 hw
->ident_pri_fw
.id
= le16_to_cpu(hw
->ident_pri_fw
.id
);
643 hw
->ident_pri_fw
.variant
= le16_to_cpu(hw
->ident_pri_fw
.variant
);
644 hw
->ident_pri_fw
.major
= le16_to_cpu(hw
->ident_pri_fw
.major
);
645 hw
->ident_pri_fw
.minor
= le16_to_cpu(hw
->ident_pri_fw
.minor
);
647 netdev_info(wlandev
->netdev
, "ident: pri f/w: id=0x%02x %d.%d.%d\n",
648 hw
->ident_pri_fw
.id
, hw
->ident_pri_fw
.major
,
649 hw
->ident_pri_fw
.minor
, hw
->ident_pri_fw
.variant
);
651 /* Station (Secondary?) f/w identity */
652 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_STAIDENTITY
,
654 sizeof(hfa384x_compident_t
));
656 netdev_err(wlandev
->netdev
, "Failed to retrieve STAIDENTITY\n");
660 if (hw
->ident_nic
.id
< 0x8000) {
661 netdev_err(wlandev
->netdev
,
662 "FATAL: Card is not an Intersil Prism2/2.5/3\n");
667 /* get all the station fw id fields in host byte order */
668 hw
->ident_sta_fw
.id
= le16_to_cpu(hw
->ident_sta_fw
.id
);
669 hw
->ident_sta_fw
.variant
= le16_to_cpu(hw
->ident_sta_fw
.variant
);
670 hw
->ident_sta_fw
.major
= le16_to_cpu(hw
->ident_sta_fw
.major
);
671 hw
->ident_sta_fw
.minor
= le16_to_cpu(hw
->ident_sta_fw
.minor
);
673 /* strip out the 'special' variant bits */
674 hw
->mm_mods
= hw
->ident_sta_fw
.variant
& (BIT(14) | BIT(15));
675 hw
->ident_sta_fw
.variant
&= ~((u16
) (BIT(14) | BIT(15)));
677 if (hw
->ident_sta_fw
.id
== 0x1f) {
678 netdev_info(wlandev
->netdev
,
679 "ident: sta f/w: id=0x%02x %d.%d.%d\n",
680 hw
->ident_sta_fw
.id
, hw
->ident_sta_fw
.major
,
681 hw
->ident_sta_fw
.minor
, hw
->ident_sta_fw
.variant
);
683 netdev_info(wlandev
->netdev
,
684 "ident: ap f/w: id=0x%02x %d.%d.%d\n",
685 hw
->ident_sta_fw
.id
, hw
->ident_sta_fw
.major
,
686 hw
->ident_sta_fw
.minor
, hw
->ident_sta_fw
.variant
);
687 netdev_err(wlandev
->netdev
, "Unsupported Tertiary AP firmeare loaded!\n");
691 /* Compatibility range, Modem supplier */
692 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_MFISUPRANGE
,
694 sizeof(hfa384x_caplevel_t
));
696 netdev_err(wlandev
->netdev
, "Failed to retrieve MFISUPRANGE\n");
700 /* get all the Compatibility range, modem interface supplier
701 fields in byte order */
702 hw
->cap_sup_mfi
.role
= le16_to_cpu(hw
->cap_sup_mfi
.role
);
703 hw
->cap_sup_mfi
.id
= le16_to_cpu(hw
->cap_sup_mfi
.id
);
704 hw
->cap_sup_mfi
.variant
= le16_to_cpu(hw
->cap_sup_mfi
.variant
);
705 hw
->cap_sup_mfi
.bottom
= le16_to_cpu(hw
->cap_sup_mfi
.bottom
);
706 hw
->cap_sup_mfi
.top
= le16_to_cpu(hw
->cap_sup_mfi
.top
);
708 netdev_info(wlandev
->netdev
,
709 "MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
710 hw
->cap_sup_mfi
.role
, hw
->cap_sup_mfi
.id
,
711 hw
->cap_sup_mfi
.variant
, hw
->cap_sup_mfi
.bottom
,
712 hw
->cap_sup_mfi
.top
);
714 /* Compatibility range, Controller supplier */
715 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_CFISUPRANGE
,
717 sizeof(hfa384x_caplevel_t
));
719 netdev_err(wlandev
->netdev
, "Failed to retrieve CFISUPRANGE\n");
723 /* get all the Compatibility range, controller interface supplier
724 fields in byte order */
725 hw
->cap_sup_cfi
.role
= le16_to_cpu(hw
->cap_sup_cfi
.role
);
726 hw
->cap_sup_cfi
.id
= le16_to_cpu(hw
->cap_sup_cfi
.id
);
727 hw
->cap_sup_cfi
.variant
= le16_to_cpu(hw
->cap_sup_cfi
.variant
);
728 hw
->cap_sup_cfi
.bottom
= le16_to_cpu(hw
->cap_sup_cfi
.bottom
);
729 hw
->cap_sup_cfi
.top
= le16_to_cpu(hw
->cap_sup_cfi
.top
);
731 netdev_info(wlandev
->netdev
,
732 "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
733 hw
->cap_sup_cfi
.role
, hw
->cap_sup_cfi
.id
,
734 hw
->cap_sup_cfi
.variant
, hw
->cap_sup_cfi
.bottom
,
735 hw
->cap_sup_cfi
.top
);
737 /* Compatibility range, Primary f/w supplier */
738 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_PRISUPRANGE
,
740 sizeof(hfa384x_caplevel_t
));
742 netdev_err(wlandev
->netdev
, "Failed to retrieve PRISUPRANGE\n");
746 /* get all the Compatibility range, primary firmware supplier
747 fields in byte order */
748 hw
->cap_sup_pri
.role
= le16_to_cpu(hw
->cap_sup_pri
.role
);
749 hw
->cap_sup_pri
.id
= le16_to_cpu(hw
->cap_sup_pri
.id
);
750 hw
->cap_sup_pri
.variant
= le16_to_cpu(hw
->cap_sup_pri
.variant
);
751 hw
->cap_sup_pri
.bottom
= le16_to_cpu(hw
->cap_sup_pri
.bottom
);
752 hw
->cap_sup_pri
.top
= le16_to_cpu(hw
->cap_sup_pri
.top
);
754 netdev_info(wlandev
->netdev
,
755 "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
756 hw
->cap_sup_pri
.role
, hw
->cap_sup_pri
.id
,
757 hw
->cap_sup_pri
.variant
, hw
->cap_sup_pri
.bottom
,
758 hw
->cap_sup_pri
.top
);
760 /* Compatibility range, Station f/w supplier */
761 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_STASUPRANGE
,
763 sizeof(hfa384x_caplevel_t
));
765 netdev_err(wlandev
->netdev
, "Failed to retrieve STASUPRANGE\n");
769 /* get all the Compatibility range, station firmware supplier
770 fields in byte order */
771 hw
->cap_sup_sta
.role
= le16_to_cpu(hw
->cap_sup_sta
.role
);
772 hw
->cap_sup_sta
.id
= le16_to_cpu(hw
->cap_sup_sta
.id
);
773 hw
->cap_sup_sta
.variant
= le16_to_cpu(hw
->cap_sup_sta
.variant
);
774 hw
->cap_sup_sta
.bottom
= le16_to_cpu(hw
->cap_sup_sta
.bottom
);
775 hw
->cap_sup_sta
.top
= le16_to_cpu(hw
->cap_sup_sta
.top
);
777 if (hw
->cap_sup_sta
.id
== 0x04) {
778 netdev_info(wlandev
->netdev
,
779 "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
780 hw
->cap_sup_sta
.role
, hw
->cap_sup_sta
.id
,
781 hw
->cap_sup_sta
.variant
, hw
->cap_sup_sta
.bottom
,
782 hw
->cap_sup_sta
.top
);
784 netdev_info(wlandev
->netdev
,
785 "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
786 hw
->cap_sup_sta
.role
, hw
->cap_sup_sta
.id
,
787 hw
->cap_sup_sta
.variant
, hw
->cap_sup_sta
.bottom
,
788 hw
->cap_sup_sta
.top
);
791 /* Compatibility range, primary f/w actor, CFI supplier */
792 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_PRI_CFIACTRANGES
,
793 &hw
->cap_act_pri_cfi
,
794 sizeof(hfa384x_caplevel_t
));
796 netdev_err(wlandev
->netdev
, "Failed to retrieve PRI_CFIACTRANGES\n");
800 /* get all the Compatibility range, primary f/w actor, CFI supplier
801 fields in byte order */
802 hw
->cap_act_pri_cfi
.role
= le16_to_cpu(hw
->cap_act_pri_cfi
.role
);
803 hw
->cap_act_pri_cfi
.id
= le16_to_cpu(hw
->cap_act_pri_cfi
.id
);
804 hw
->cap_act_pri_cfi
.variant
= le16_to_cpu(hw
->cap_act_pri_cfi
.variant
);
805 hw
->cap_act_pri_cfi
.bottom
= le16_to_cpu(hw
->cap_act_pri_cfi
.bottom
);
806 hw
->cap_act_pri_cfi
.top
= le16_to_cpu(hw
->cap_act_pri_cfi
.top
);
808 netdev_info(wlandev
->netdev
,
809 "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
810 hw
->cap_act_pri_cfi
.role
, hw
->cap_act_pri_cfi
.id
,
811 hw
->cap_act_pri_cfi
.variant
, hw
->cap_act_pri_cfi
.bottom
,
812 hw
->cap_act_pri_cfi
.top
);
814 /* Compatibility range, sta f/w actor, CFI supplier */
815 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_STA_CFIACTRANGES
,
816 &hw
->cap_act_sta_cfi
,
817 sizeof(hfa384x_caplevel_t
));
819 netdev_err(wlandev
->netdev
, "Failed to retrieve STA_CFIACTRANGES\n");
823 /* get all the Compatibility range, station f/w actor, CFI supplier
824 fields in byte order */
825 hw
->cap_act_sta_cfi
.role
= le16_to_cpu(hw
->cap_act_sta_cfi
.role
);
826 hw
->cap_act_sta_cfi
.id
= le16_to_cpu(hw
->cap_act_sta_cfi
.id
);
827 hw
->cap_act_sta_cfi
.variant
= le16_to_cpu(hw
->cap_act_sta_cfi
.variant
);
828 hw
->cap_act_sta_cfi
.bottom
= le16_to_cpu(hw
->cap_act_sta_cfi
.bottom
);
829 hw
->cap_act_sta_cfi
.top
= le16_to_cpu(hw
->cap_act_sta_cfi
.top
);
831 netdev_info(wlandev
->netdev
,
832 "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
833 hw
->cap_act_sta_cfi
.role
, hw
->cap_act_sta_cfi
.id
,
834 hw
->cap_act_sta_cfi
.variant
, hw
->cap_act_sta_cfi
.bottom
,
835 hw
->cap_act_sta_cfi
.top
);
837 /* Compatibility range, sta f/w actor, MFI supplier */
838 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_STA_MFIACTRANGES
,
839 &hw
->cap_act_sta_mfi
,
840 sizeof(hfa384x_caplevel_t
));
842 netdev_err(wlandev
->netdev
, "Failed to retrieve STA_MFIACTRANGES\n");
846 /* get all the Compatibility range, station f/w actor, MFI supplier
847 fields in byte order */
848 hw
->cap_act_sta_mfi
.role
= le16_to_cpu(hw
->cap_act_sta_mfi
.role
);
849 hw
->cap_act_sta_mfi
.id
= le16_to_cpu(hw
->cap_act_sta_mfi
.id
);
850 hw
->cap_act_sta_mfi
.variant
= le16_to_cpu(hw
->cap_act_sta_mfi
.variant
);
851 hw
->cap_act_sta_mfi
.bottom
= le16_to_cpu(hw
->cap_act_sta_mfi
.bottom
);
852 hw
->cap_act_sta_mfi
.top
= le16_to_cpu(hw
->cap_act_sta_mfi
.top
);
854 netdev_info(wlandev
->netdev
,
855 "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
856 hw
->cap_act_sta_mfi
.role
, hw
->cap_act_sta_mfi
.id
,
857 hw
->cap_act_sta_mfi
.variant
, hw
->cap_act_sta_mfi
.bottom
,
858 hw
->cap_act_sta_mfi
.top
);
861 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_NICSERIALNUMBER
,
862 snum
, HFA384x_RID_NICSERIALNUMBER_LEN
);
864 wlan_mkprintstr(snum
, HFA384x_RID_NICSERIALNUMBER_LEN
,
866 netdev_info(wlandev
->netdev
, "Prism2 card SN: %s\n", pstr
);
868 netdev_err(wlandev
->netdev
, "Failed to retrieve Prism2 Card SN\n");
872 /* Collect the MAC address */
873 result
= hfa384x_drvr_getconfig(hw
, HFA384x_RID_CNFOWNMACADDR
,
874 wlandev
->netdev
->dev_addr
, ETH_ALEN
);
876 netdev_err(wlandev
->netdev
, "Failed to retrieve mac address\n");
880 /* short preamble is always implemented */
881 wlandev
->nsdcaps
|= P80211_NSDCAP_SHORT_PREAMBLE
;
883 /* find out if hardware wep is implemented */
884 hfa384x_drvr_getconfig16(hw
, HFA384x_RID_PRIVACYOPTIMP
, &temp
);
886 wlandev
->nsdcaps
|= P80211_NSDCAP_HARDWAREWEP
;
888 /* get the dBm Scaling constant */
889 hfa384x_drvr_getconfig16(hw
, HFA384x_RID_CNFDBMADJUST
, &temp
);
890 hw
->dbmadjust
= temp
;
892 /* Only enable scan by default on newer firmware */
893 if (HFA384x_FIRMWARE_VERSION(hw
->ident_sta_fw
.major
,
894 hw
->ident_sta_fw
.minor
,
895 hw
->ident_sta_fw
.variant
) <
896 HFA384x_FIRMWARE_VERSION(1, 5, 5)) {
897 wlandev
->nsdcaps
|= P80211_NSDCAP_NOSCAN
;
900 /* TODO: Set any internally managed config items */
904 netdev_err(wlandev
->netdev
, "Failed, result=%d\n", result
);
909 /*----------------------------------------------------------------
910 * prism2sta_globalsetup
912 * Set any global RIDs that we want to set at device activation.
915 * wlandev wlan device structure
919 * >0 f/w reported error
920 * <0 driver reported error
926 ----------------------------------------------------------------*/
927 static int prism2sta_globalsetup(wlandevice_t
*wlandev
)
929 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
931 /* Set the maximum frame size */
932 return hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFMAXDATALEN
,
936 static int prism2sta_setmulticast(wlandevice_t
*wlandev
, netdevice_t
*dev
)
939 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
943 /* If we're not ready, what's the point? */
944 if (hw
->state
!= HFA384x_STATE_RUNNING
)
947 if ((dev
->flags
& (IFF_PROMISC
| IFF_ALLMULTI
)) != 0)
948 promisc
= P80211ENUM_truth_true
;
950 promisc
= P80211ENUM_truth_false
;
953 hfa384x_drvr_setconfig16_async(hw
, HFA384x_RID_PROMISCMODE
,
959 /*----------------------------------------------------------------
960 * prism2sta_inf_handover
962 * Handles the receipt of a Handover info frame. Should only be present
966 * wlandev wlan device structure
967 * inf ptr to info frame (contents in hfa384x order)
976 ----------------------------------------------------------------*/
977 static void prism2sta_inf_handover(wlandevice_t
*wlandev
,
978 hfa384x_InfFrame_t
*inf
)
980 pr_debug("received infoframe:HANDOVER (unhandled)\n");
983 /*----------------------------------------------------------------
984 * prism2sta_inf_tallies
986 * Handles the receipt of a CommTallies info frame.
989 * wlandev wlan device structure
990 * inf ptr to info frame (contents in hfa384x order)
999 ----------------------------------------------------------------*/
1000 static void prism2sta_inf_tallies(wlandevice_t
*wlandev
,
1001 hfa384x_InfFrame_t
*inf
)
1003 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1011 ** Determine if these are 16-bit or 32-bit tallies, based on the
1012 ** record length of the info record.
1015 cnt
= sizeof(hfa384x_CommTallies32_t
) / sizeof(u32
);
1016 if (inf
->framelen
> 22) {
1017 dst
= (u32
*) &hw
->tallies
;
1018 src32
= (u32
*) &inf
->info
.commtallies32
;
1019 for (i
= 0; i
< cnt
; i
++, dst
++, src32
++)
1020 *dst
+= le32_to_cpu(*src32
);
1022 dst
= (u32
*) &hw
->tallies
;
1023 src16
= (u16
*) &inf
->info
.commtallies16
;
1024 for (i
= 0; i
< cnt
; i
++, dst
++, src16
++)
1025 *dst
+= le16_to_cpu(*src16
);
1029 /*----------------------------------------------------------------
1030 * prism2sta_inf_scanresults
1032 * Handles the receipt of a Scan Results info frame.
1035 * wlandev wlan device structure
1036 * inf ptr to info frame (contents in hfa384x order)
1045 ----------------------------------------------------------------*/
1046 static void prism2sta_inf_scanresults(wlandevice_t
*wlandev
,
1047 hfa384x_InfFrame_t
*inf
)
1050 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1052 hfa384x_ScanResult_t
*sr
= &(inf
->info
.scanresult
);
1054 hfa384x_JoinRequest_data_t joinreq
;
1057 /* Get the number of results, first in bytes, then in results */
1058 nbss
= (inf
->framelen
* sizeof(u16
)) -
1059 sizeof(inf
->infotype
) - sizeof(inf
->info
.scanresult
.scanreason
);
1060 nbss
/= sizeof(hfa384x_ScanResultSub_t
);
1063 pr_debug("rx scanresults, reason=%d, nbss=%d:\n",
1064 inf
->info
.scanresult
.scanreason
, nbss
);
1065 for (i
= 0; i
< nbss
; i
++) {
1066 pr_debug("chid=%d anl=%d sl=%d bcnint=%d\n",
1069 sr
->result
[i
].sl
, sr
->result
[i
].bcnint
);
1070 pr_debug(" capinfo=0x%04x proberesp_rate=%d\n",
1071 sr
->result
[i
].capinfo
, sr
->result
[i
].proberesp_rate
);
1073 /* issue a join request */
1074 joinreq
.channel
= sr
->result
[0].chid
;
1075 memcpy(joinreq
.bssid
, sr
->result
[0].bssid
, WLAN_BSSID_LEN
);
1076 result
= hfa384x_drvr_setconfig(hw
,
1077 HFA384x_RID_JOINREQUEST
,
1078 &joinreq
, HFA384x_RID_JOINREQUEST_LEN
);
1080 netdev_err(wlandev
->netdev
, "setconfig(joinreq) failed, result=%d\n",
1085 /*----------------------------------------------------------------
1086 * prism2sta_inf_hostscanresults
1088 * Handles the receipt of a Scan Results info frame.
1091 * wlandev wlan device structure
1092 * inf ptr to info frame (contents in hfa384x order)
1101 ----------------------------------------------------------------*/
1102 static void prism2sta_inf_hostscanresults(wlandevice_t
*wlandev
,
1103 hfa384x_InfFrame_t
*inf
)
1105 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1108 nbss
= (inf
->framelen
- 3) / 32;
1109 pr_debug("Received %d hostscan results\n", nbss
);
1114 kfree(hw
->scanresults
);
1116 hw
->scanresults
= kmemdup(inf
, sizeof(hfa384x_InfFrame_t
), GFP_ATOMIC
);
1121 /* Notify/wake the sleeping caller. */
1122 hw
->scanflag
= nbss
;
1123 wake_up_interruptible(&hw
->cmdq
);
1126 /*----------------------------------------------------------------
1127 * prism2sta_inf_chinforesults
1129 * Handles the receipt of a Channel Info Results info frame.
1132 * wlandev wlan device structure
1133 * inf ptr to info frame (contents in hfa384x order)
1142 ----------------------------------------------------------------*/
1143 static void prism2sta_inf_chinforesults(wlandevice_t
*wlandev
,
1144 hfa384x_InfFrame_t
*inf
)
1146 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1149 hw
->channel_info
.results
.scanchannels
=
1150 le16_to_cpu(inf
->info
.chinforesult
.scanchannels
);
1152 for (i
= 0, n
= 0; i
< HFA384x_CHINFORESULT_MAX
; i
++) {
1153 hfa384x_ChInfoResultSub_t
*result
;
1154 hfa384x_ChInfoResultSub_t
*chinforesult
;
1157 if (!(hw
->channel_info
.results
.scanchannels
& (1 << i
)))
1160 result
= &inf
->info
.chinforesult
.result
[n
];
1161 chan
= le16_to_cpu(result
->chid
) - 1;
1163 if (chan
< 0 || chan
>= HFA384x_CHINFORESULT_MAX
)
1166 chinforesult
= &hw
->channel_info
.results
.result
[chan
];
1167 chinforesult
->chid
= chan
;
1168 chinforesult
->anl
= le16_to_cpu(result
->anl
);
1169 chinforesult
->pnl
= le16_to_cpu(result
->pnl
);
1170 chinforesult
->active
= le16_to_cpu(result
->active
);
1172 pr_debug("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n",
1174 (chinforesult
->active
& HFA384x_CHINFORESULT_BSSACTIVE
)
1175 ? "signal" : "noise",
1176 chinforesult
->anl
, chinforesult
->pnl
,
1177 (chinforesult
->active
& HFA384x_CHINFORESULT_PCFACTIVE
)
1181 atomic_set(&hw
->channel_info
.done
, 2);
1183 hw
->channel_info
.count
= n
;
1186 void prism2sta_processing_defer(struct work_struct
*data
)
1188 hfa384x_t
*hw
= container_of(data
, struct hfa384x
, link_bh
);
1189 wlandevice_t
*wlandev
= hw
->wlandev
;
1190 hfa384x_bytestr32_t ssid
;
1193 /* First let's process the auth frames */
1195 struct sk_buff
*skb
;
1196 hfa384x_InfFrame_t
*inf
;
1198 while ((skb
= skb_dequeue(&hw
->authq
))) {
1199 inf
= (hfa384x_InfFrame_t
*) skb
->data
;
1200 prism2sta_inf_authreq_defer(wlandev
, inf
);
1205 /* Now let's handle the linkstatus stuff */
1206 if (hw
->link_status
== hw
->link_status_new
)
1209 hw
->link_status
= hw
->link_status_new
;
1211 switch (hw
->link_status
) {
1212 case HFA384x_LINK_NOTCONNECTED
:
1213 /* I'm currently assuming that this is the initial link
1214 * state. It should only be possible immediately
1215 * following an Enable command.
1217 * Block Transmits, Ignore receives of data frames
1219 netif_carrier_off(wlandev
->netdev
);
1221 netdev_info(wlandev
->netdev
, "linkstatus=NOTCONNECTED (unhandled)\n");
1224 case HFA384x_LINK_CONNECTED
:
1225 /* This one indicates a successful scan/join/auth/assoc.
1226 * When we have the full MLME complement, this event will
1227 * signify successful completion of both mlme_authenticate
1228 * and mlme_associate. State management will get a little
1231 * Indicate authentication and/or association
1232 * Enable Transmits, Receives and pass up data frames
1235 netif_carrier_on(wlandev
->netdev
);
1237 /* If we are joining a specific AP, set our
1238 * state and reset retries
1240 if (hw
->join_ap
== 1)
1242 hw
->join_retries
= 60;
1244 /* Don't call this in monitor mode */
1245 if (wlandev
->netdev
->type
== ARPHRD_ETHER
) {
1248 netdev_info(wlandev
->netdev
, "linkstatus=CONNECTED\n");
1250 /* For non-usb devices, we can use the sync versions */
1251 /* Collect the BSSID, and set state to allow tx */
1253 result
= hfa384x_drvr_getconfig(hw
,
1254 HFA384x_RID_CURRENTBSSID
,
1259 ("getconfig(0x%02x) failed, result = %d\n",
1260 HFA384x_RID_CURRENTBSSID
, result
);
1264 result
= hfa384x_drvr_getconfig(hw
,
1265 HFA384x_RID_CURRENTSSID
,
1266 &ssid
, sizeof(ssid
));
1269 ("getconfig(0x%02x) failed, result = %d\n",
1270 HFA384x_RID_CURRENTSSID
, result
);
1273 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr
*) &ssid
,
1277 /* Collect the port status */
1278 result
= hfa384x_drvr_getconfig16(hw
,
1279 HFA384x_RID_PORTSTATUS
,
1283 ("getconfig(0x%02x) failed, result = %d\n",
1284 HFA384x_RID_PORTSTATUS
, result
);
1288 (portstatus
== HFA384x_PSTATUS_CONN_IBSS
) ?
1289 WLAN_MACMODE_IBSS_STA
: WLAN_MACMODE_ESS_STA
;
1291 /* signal back up to cfg80211 layer */
1292 prism2_connect_result(wlandev
, P80211ENUM_truth_false
);
1294 /* Get the ball rolling on the comms quality stuff */
1295 prism2sta_commsqual_defer(&hw
->commsqual_bh
);
1299 case HFA384x_LINK_DISCONNECTED
:
1300 /* This one indicates that our association is gone. We've
1301 * lost connection with the AP and/or been disassociated.
1302 * This indicates that the MAC has completely cleared it's
1303 * associated state. We * should send a deauth indication
1304 * (implying disassoc) up * to the MLME.
1306 * Indicate Deauthentication
1307 * Block Transmits, Ignore receives of data frames
1309 if (wlandev
->netdev
->type
== ARPHRD_ETHER
)
1310 netdev_info(wlandev
->netdev
,
1311 "linkstatus=DISCONNECTED (unhandled)\n");
1312 wlandev
->macmode
= WLAN_MACMODE_NONE
;
1314 netif_carrier_off(wlandev
->netdev
);
1316 /* signal back up to cfg80211 layer */
1317 prism2_disconnected(wlandev
);
1321 case HFA384x_LINK_AP_CHANGE
:
1322 /* This one indicates that the MAC has decided to and
1323 * successfully completed a change to another AP. We
1324 * should probably implement a reassociation indication
1325 * in response to this one. I'm thinking that the the
1326 * p80211 layer needs to be notified in case of
1327 * buffering/queueing issues. User mode also needs to be
1328 * notified so that any BSS dependent elements can be
1330 * associated state. We * should send a deauth indication
1331 * (implying disassoc) up * to the MLME.
1333 * Indicate Reassociation
1334 * Enable Transmits, Receives and pass up data frames
1336 netdev_info(wlandev
->netdev
, "linkstatus=AP_CHANGE\n");
1338 result
= hfa384x_drvr_getconfig(hw
,
1339 HFA384x_RID_CURRENTBSSID
,
1340 wlandev
->bssid
, WLAN_BSSID_LEN
);
1342 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1343 HFA384x_RID_CURRENTBSSID
, result
);
1347 result
= hfa384x_drvr_getconfig(hw
,
1348 HFA384x_RID_CURRENTSSID
,
1349 &ssid
, sizeof(ssid
));
1351 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1352 HFA384x_RID_CURRENTSSID
, result
);
1355 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr
*) &ssid
,
1356 (p80211pstrd_t
*) &wlandev
->ssid
);
1358 hw
->link_status
= HFA384x_LINK_CONNECTED
;
1359 netif_carrier_on(wlandev
->netdev
);
1361 /* signal back up to cfg80211 layer */
1362 prism2_roamed(wlandev
);
1366 case HFA384x_LINK_AP_OUTOFRANGE
:
1367 /* This one indicates that the MAC has decided that the
1368 * AP is out of range, but hasn't found a better candidate
1369 * so the MAC maintains its "associated" state in case
1370 * we get back in range. We should block transmits and
1371 * receives in this state. Do we need an indication here?
1372 * Probably not since a polling user-mode element would
1373 * get this status from from p2PortStatus(FD40). What about
1376 * Block Transmits, Ignore receives of data frames
1378 netdev_info(wlandev
->netdev
, "linkstatus=AP_OUTOFRANGE (unhandled)\n");
1380 netif_carrier_off(wlandev
->netdev
);
1384 case HFA384x_LINK_AP_INRANGE
:
1385 /* This one indicates that the MAC has decided that the
1386 * AP is back in range. We continue working with our
1387 * existing association.
1389 * Enable Transmits, Receives and pass up data frames
1391 netdev_info(wlandev
->netdev
, "linkstatus=AP_INRANGE\n");
1393 hw
->link_status
= HFA384x_LINK_CONNECTED
;
1394 netif_carrier_on(wlandev
->netdev
);
1398 case HFA384x_LINK_ASSOCFAIL
:
1399 /* This one is actually a peer to CONNECTED. We've
1400 * requested a join for a given SSID and optionally BSSID.
1401 * We can use this one to indicate authentication and
1402 * association failures. The trick is going to be
1403 * 1) identifying the failure, and 2) state management.
1405 * Disable Transmits, Ignore receives of data frames
1407 if (hw
->join_ap
&& --hw
->join_retries
> 0) {
1408 hfa384x_JoinRequest_data_t joinreq
;
1409 joinreq
= hw
->joinreq
;
1410 /* Send the join request */
1411 hfa384x_drvr_setconfig(hw
,
1412 HFA384x_RID_JOINREQUEST
,
1414 HFA384x_RID_JOINREQUEST_LEN
);
1415 netdev_info(wlandev
->netdev
,
1416 "linkstatus=ASSOCFAIL (re-submitting join)\n");
1418 netdev_info(wlandev
->netdev
, "linkstatus=ASSOCFAIL (unhandled)\n");
1421 netif_carrier_off(wlandev
->netdev
);
1423 /* signal back up to cfg80211 layer */
1424 prism2_connect_result(wlandev
, P80211ENUM_truth_true
);
1429 /* This is bad, IO port problems? */
1431 "unknown linkstatus=0x%02x\n", hw
->link_status
);
1435 wlandev
->linkstatus
= (hw
->link_status
== HFA384x_LINK_CONNECTED
);
1438 /*----------------------------------------------------------------
1439 * prism2sta_inf_linkstatus
1441 * Handles the receipt of a Link Status info frame.
1444 * wlandev wlan device structure
1445 * inf ptr to info frame (contents in hfa384x order)
1454 ----------------------------------------------------------------*/
1455 static void prism2sta_inf_linkstatus(wlandevice_t
*wlandev
,
1456 hfa384x_InfFrame_t
*inf
)
1458 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1460 hw
->link_status_new
= le16_to_cpu(inf
->info
.linkstatus
.linkstatus
);
1462 schedule_work(&hw
->link_bh
);
1465 /*----------------------------------------------------------------
1466 * prism2sta_inf_assocstatus
1468 * Handles the receipt of an Association Status info frame. Should
1469 * be present in APs only.
1472 * wlandev wlan device structure
1473 * inf ptr to info frame (contents in hfa384x order)
1482 ----------------------------------------------------------------*/
1483 static void prism2sta_inf_assocstatus(wlandevice_t
*wlandev
,
1484 hfa384x_InfFrame_t
*inf
)
1486 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1487 hfa384x_AssocStatus_t rec
;
1490 memcpy(&rec
, &inf
->info
.assocstatus
, sizeof(rec
));
1491 rec
.assocstatus
= le16_to_cpu(rec
.assocstatus
);
1492 rec
.reason
= le16_to_cpu(rec
.reason
);
1495 ** Find the address in the list of authenticated stations.
1496 ** If it wasn't found, then this address has not been previously
1497 ** authenticated and something weird has happened if this is
1498 ** anything other than an "authentication failed" message.
1499 ** If the address was found, then set the "associated" flag for
1500 ** that station, based on whether the station is associating or
1501 ** losing its association. Something weird has also happened
1502 ** if we find the address in the list of authenticated stations
1503 ** but we are getting an "authentication failed" message.
1506 for (i
= 0; i
< hw
->authlist
.cnt
; i
++)
1507 if (memcmp(rec
.sta_addr
, hw
->authlist
.addr
[i
], ETH_ALEN
) == 0)
1510 if (i
>= hw
->authlist
.cnt
) {
1511 if (rec
.assocstatus
!= HFA384x_ASSOCSTATUS_AUTHFAIL
)
1513 "assocstatus info frame received for non-authenticated station.\n");
1515 hw
->authlist
.assoc
[i
] =
1516 (rec
.assocstatus
== HFA384x_ASSOCSTATUS_STAASSOC
||
1517 rec
.assocstatus
== HFA384x_ASSOCSTATUS_REASSOC
);
1519 if (rec
.assocstatus
== HFA384x_ASSOCSTATUS_AUTHFAIL
)
1521 "authfail assocstatus info frame received for authenticated station.\n");
1525 /*----------------------------------------------------------------
1526 * prism2sta_inf_authreq
1528 * Handles the receipt of an Authentication Request info frame. Should
1529 * be present in APs only.
1532 * wlandev wlan device structure
1533 * inf ptr to info frame (contents in hfa384x order)
1543 ----------------------------------------------------------------*/
1544 static void prism2sta_inf_authreq(wlandevice_t
*wlandev
,
1545 hfa384x_InfFrame_t
*inf
)
1547 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1548 struct sk_buff
*skb
;
1550 skb
= dev_alloc_skb(sizeof(*inf
));
1552 skb_put(skb
, sizeof(*inf
));
1553 memcpy(skb
->data
, inf
, sizeof(*inf
));
1554 skb_queue_tail(&hw
->authq
, skb
);
1555 schedule_work(&hw
->link_bh
);
1559 static void prism2sta_inf_authreq_defer(wlandevice_t
*wlandev
,
1560 hfa384x_InfFrame_t
*inf
)
1562 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1563 hfa384x_authenticateStation_data_t rec
;
1565 int i
, added
, result
, cnt
;
1569 ** Build the AuthenticateStation record. Initialize it for denying
1573 memcpy(rec
.address
, inf
->info
.authreq
.sta_addr
, ETH_ALEN
);
1574 rec
.status
= P80211ENUM_status_unspec_failure
;
1577 ** Authenticate based on the access mode.
1580 switch (hw
->accessmode
) {
1581 case WLAN_ACCESS_NONE
:
1584 ** Deny all new authentications. However, if a station
1585 ** is ALREADY authenticated, then accept it.
1588 for (i
= 0; i
< hw
->authlist
.cnt
; i
++)
1589 if (memcmp(rec
.address
, hw
->authlist
.addr
[i
],
1591 rec
.status
= P80211ENUM_status_successful
;
1597 case WLAN_ACCESS_ALL
:
1600 ** Allow all authentications.
1603 rec
.status
= P80211ENUM_status_successful
;
1606 case WLAN_ACCESS_ALLOW
:
1609 ** Only allow the authentication if the MAC address
1610 ** is in the list of allowed addresses.
1612 ** Since this is the interrupt handler, we may be here
1613 ** while the access list is in the middle of being
1614 ** updated. Choose the list which is currently okay.
1615 ** See "prism2mib_priv_accessallow()" for details.
1618 if (hw
->allow
.modify
== 0) {
1619 cnt
= hw
->allow
.cnt
;
1620 addr
= hw
->allow
.addr
[0];
1622 cnt
= hw
->allow
.cnt1
;
1623 addr
= hw
->allow
.addr1
[0];
1626 for (i
= 0; i
< cnt
; i
++, addr
+= ETH_ALEN
)
1627 if (memcmp(rec
.address
, addr
, ETH_ALEN
) == 0) {
1628 rec
.status
= P80211ENUM_status_successful
;
1634 case WLAN_ACCESS_DENY
:
1637 ** Allow the authentication UNLESS the MAC address is
1638 ** in the list of denied addresses.
1640 ** Since this is the interrupt handler, we may be here
1641 ** while the access list is in the middle of being
1642 ** updated. Choose the list which is currently okay.
1643 ** See "prism2mib_priv_accessdeny()" for details.
1646 if (hw
->deny
.modify
== 0) {
1648 addr
= hw
->deny
.addr
[0];
1650 cnt
= hw
->deny
.cnt1
;
1651 addr
= hw
->deny
.addr1
[0];
1654 rec
.status
= P80211ENUM_status_successful
;
1656 for (i
= 0; i
< cnt
; i
++, addr
+= ETH_ALEN
)
1657 if (memcmp(rec
.address
, addr
, ETH_ALEN
) == 0) {
1658 rec
.status
= P80211ENUM_status_unspec_failure
;
1666 ** If the authentication is okay, then add the MAC address to the
1667 ** list of authenticated stations. Don't add the address if it
1668 ** is already in the list. (802.11b does not seem to disallow
1669 ** a station from issuing an authentication request when the
1670 ** station is already authenticated. Does this sort of thing
1671 ** ever happen? We might as well do the check just in case.)
1676 if (rec
.status
== P80211ENUM_status_successful
) {
1677 for (i
= 0; i
< hw
->authlist
.cnt
; i
++)
1678 if (memcmp(rec
.address
, hw
->authlist
.addr
[i
], ETH_ALEN
)
1682 if (i
>= hw
->authlist
.cnt
) {
1683 if (hw
->authlist
.cnt
>= WLAN_AUTH_MAX
) {
1684 rec
.status
= P80211ENUM_status_ap_full
;
1686 memcpy(hw
->authlist
.addr
[hw
->authlist
.cnt
],
1687 rec
.address
, ETH_ALEN
);
1695 ** Send back the results of the authentication. If this doesn't work,
1696 ** then make sure to remove the address from the authenticated list if
1700 rec
.status
= cpu_to_le16(rec
.status
);
1701 rec
.algorithm
= inf
->info
.authreq
.algorithm
;
1703 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_AUTHENTICATESTA
,
1708 netdev_err(wlandev
->netdev
,
1709 "setconfig(authenticatestation) failed, result=%d\n",
1714 /*----------------------------------------------------------------
1715 * prism2sta_inf_psusercnt
1717 * Handles the receipt of a PowerSaveUserCount info frame. Should
1718 * be present in APs only.
1721 * wlandev wlan device structure
1722 * inf ptr to info frame (contents in hfa384x order)
1731 ----------------------------------------------------------------*/
1732 static void prism2sta_inf_psusercnt(wlandevice_t
*wlandev
,
1733 hfa384x_InfFrame_t
*inf
)
1735 hfa384x_t
*hw
= (hfa384x_t
*) wlandev
->priv
;
1737 hw
->psusercount
= le16_to_cpu(inf
->info
.psusercnt
.usercnt
);
1740 /*----------------------------------------------------------------
1743 * Handles the Info event.
1746 * wlandev wlan device structure
1747 * inf ptr to a generic info frame
1756 ----------------------------------------------------------------*/
1757 void prism2sta_ev_info(wlandevice_t
*wlandev
, hfa384x_InfFrame_t
*inf
)
1759 inf
->infotype
= le16_to_cpu(inf
->infotype
);
1761 switch (inf
->infotype
) {
1762 case HFA384x_IT_HANDOVERADDR
:
1763 prism2sta_inf_handover(wlandev
, inf
);
1765 case HFA384x_IT_COMMTALLIES
:
1766 prism2sta_inf_tallies(wlandev
, inf
);
1768 case HFA384x_IT_HOSTSCANRESULTS
:
1769 prism2sta_inf_hostscanresults(wlandev
, inf
);
1771 case HFA384x_IT_SCANRESULTS
:
1772 prism2sta_inf_scanresults(wlandev
, inf
);
1774 case HFA384x_IT_CHINFORESULTS
:
1775 prism2sta_inf_chinforesults(wlandev
, inf
);
1777 case HFA384x_IT_LINKSTATUS
:
1778 prism2sta_inf_linkstatus(wlandev
, inf
);
1780 case HFA384x_IT_ASSOCSTATUS
:
1781 prism2sta_inf_assocstatus(wlandev
, inf
);
1783 case HFA384x_IT_AUTHREQ
:
1784 prism2sta_inf_authreq(wlandev
, inf
);
1786 case HFA384x_IT_PSUSERCNT
:
1787 prism2sta_inf_psusercnt(wlandev
, inf
);
1789 case HFA384x_IT_KEYIDCHANGED
:
1790 printk(KERN_WARNING
"Unhandled IT_KEYIDCHANGED\n");
1792 case HFA384x_IT_ASSOCREQ
:
1793 printk(KERN_WARNING
"Unhandled IT_ASSOCREQ\n");
1795 case HFA384x_IT_MICFAILURE
:
1796 printk(KERN_WARNING
"Unhandled IT_MICFAILURE\n");
1800 "Unknown info type=0x%02x\n", inf
->infotype
);
1805 /*----------------------------------------------------------------
1806 * prism2sta_ev_txexc
1808 * Handles the TxExc event. A Transmit Exception event indicates
1809 * that the MAC's TX process was unsuccessful - so the packet did
1810 * not get transmitted.
1813 * wlandev wlan device structure
1814 * status tx frame status word
1823 ----------------------------------------------------------------*/
1824 void prism2sta_ev_txexc(wlandevice_t
*wlandev
, u16 status
)
1826 pr_debug("TxExc status=0x%x.\n", status
);
1829 /*----------------------------------------------------------------
1832 * Handles the Tx event.
1835 * wlandev wlan device structure
1836 * status tx frame status word
1844 ----------------------------------------------------------------*/
1845 void prism2sta_ev_tx(wlandevice_t
*wlandev
, u16 status
)
1847 pr_debug("Tx Complete, status=0x%04x\n", status
);
1848 /* update linux network stats */
1849 wlandev
->linux_stats
.tx_packets
++;
1852 /*----------------------------------------------------------------
1855 * Handles the Rx event.
1858 * wlandev wlan device structure
1867 ----------------------------------------------------------------*/
1868 void prism2sta_ev_rx(wlandevice_t
*wlandev
, struct sk_buff
*skb
)
1870 p80211netdev_rx(wlandev
, skb
);
1873 /*----------------------------------------------------------------
1874 * prism2sta_ev_alloc
1876 * Handles the Alloc event.
1879 * wlandev wlan device structure
1888 ----------------------------------------------------------------*/
1889 void prism2sta_ev_alloc(wlandevice_t
*wlandev
)
1891 netif_wake_queue(wlandev
->netdev
);
1894 /*----------------------------------------------------------------
1897 * Called at module init time. This creates the wlandevice_t structure
1898 * and initializes it with relevant bits.
1904 * the created wlandevice_t structure.
1907 * also allocates the priv/hw structures.
1912 ----------------------------------------------------------------*/
1913 static wlandevice_t
*create_wlan(void)
1915 wlandevice_t
*wlandev
= NULL
;
1916 hfa384x_t
*hw
= NULL
;
1918 /* Alloc our structures */
1919 wlandev
= kzalloc(sizeof(wlandevice_t
), GFP_KERNEL
);
1920 hw
= kzalloc(sizeof(hfa384x_t
), GFP_KERNEL
);
1922 if (!wlandev
|| !hw
) {
1923 pr_err("%s: Memory allocation failure.\n", dev_info
);
1929 /* Initialize the network device object. */
1930 wlandev
->nsdname
= dev_info
;
1931 wlandev
->msdstate
= WLAN_MSD_HWPRESENT_PENDING
;
1933 wlandev
->open
= prism2sta_open
;
1934 wlandev
->close
= prism2sta_close
;
1935 wlandev
->reset
= prism2sta_reset
;
1936 wlandev
->txframe
= prism2sta_txframe
;
1937 wlandev
->mlmerequest
= prism2sta_mlmerequest
;
1938 wlandev
->set_multicast_list
= prism2sta_setmulticast
;
1939 wlandev
->tx_timeout
= hfa384x_tx_timeout
;
1941 wlandev
->nsdcaps
= P80211_NSDCAP_HWFRAGMENT
| P80211_NSDCAP_AUTOJOIN
;
1943 /* Initialize the device private data structure. */
1944 hw
->dot11_desired_bss_type
= 1;
1949 void prism2sta_commsqual_defer(struct work_struct
*data
)
1951 hfa384x_t
*hw
= container_of(data
, struct hfa384x
, commsqual_bh
);
1952 wlandevice_t
*wlandev
= hw
->wlandev
;
1953 hfa384x_bytestr32_t ssid
;
1954 struct p80211msg_dot11req_mibget msg
;
1955 p80211item_uint32_t
*mibitem
= (p80211item_uint32_t
*)
1956 &msg
.mibattribute
.data
;
1959 if (hw
->wlandev
->hwremoved
)
1962 /* we don't care if we're in AP mode */
1963 if ((wlandev
->macmode
== WLAN_MACMODE_NONE
) ||
1964 (wlandev
->macmode
== WLAN_MACMODE_ESS_AP
)) {
1968 /* It only makes sense to poll these in non-IBSS */
1969 if (wlandev
->macmode
!= WLAN_MACMODE_IBSS_STA
) {
1970 result
= hfa384x_drvr_getconfig(
1971 hw
, HFA384x_RID_DBMCOMMSQUALITY
,
1972 &hw
->qual
, HFA384x_RID_DBMCOMMSQUALITY_LEN
);
1975 netdev_err(wlandev
->netdev
, "error fetching commsqual\n");
1979 pr_debug("commsqual %d %d %d\n",
1980 le16_to_cpu(hw
->qual
.CQ_currBSS
),
1981 le16_to_cpu(hw
->qual
.ASL_currBSS
),
1982 le16_to_cpu(hw
->qual
.ANL_currFC
));
1985 /* Get the signal rate */
1986 msg
.msgcode
= DIDmsg_dot11req_mibget
;
1987 mibitem
->did
= DIDmib_p2_p2MAC_p2CurrentTxRate
;
1988 result
= p80211req_dorequest(wlandev
, (u8
*) &msg
);
1991 pr_debug("get signal rate failed, result = %d\n",
1996 switch (mibitem
->data
) {
1997 case HFA384x_RATEBIT_1
:
2000 case HFA384x_RATEBIT_2
:
2003 case HFA384x_RATEBIT_5dot5
:
2006 case HFA384x_RATEBIT_11
:
2010 pr_debug("Bad ratebit (%d)\n", mibitem
->data
);
2013 /* Lastly, we need to make sure the BSSID didn't change on us */
2014 result
= hfa384x_drvr_getconfig(hw
,
2015 HFA384x_RID_CURRENTBSSID
,
2016 wlandev
->bssid
, WLAN_BSSID_LEN
);
2018 pr_debug("getconfig(0x%02x) failed, result = %d\n",
2019 HFA384x_RID_CURRENTBSSID
, result
);
2023 result
= hfa384x_drvr_getconfig(hw
,
2024 HFA384x_RID_CURRENTSSID
,
2025 &ssid
, sizeof(ssid
));
2027 pr_debug("getconfig(0x%02x) failed, result = %d\n",
2028 HFA384x_RID_CURRENTSSID
, result
);
2031 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr
*) &ssid
,
2032 (p80211pstrd_t
*) &wlandev
->ssid
);
2034 /* Reschedule timer */
2035 mod_timer(&hw
->commsqual_timer
, jiffies
+ HZ
);
2038 void prism2sta_commsqual_timer(unsigned long data
)
2040 hfa384x_t
*hw
= (hfa384x_t
*) data
;
2042 schedule_work(&hw
->commsqual_bh
);