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/kernel.h>
55 #include <linux/sched.h>
56 #include <linux/types.h>
57 #include <linux/slab.h>
58 #include <linux/wireless.h>
59 #include <linux/netdevice.h>
60 #include <linux/workqueue.h>
61 #include <linux/byteorder/generic.h>
62 #include <linux/etherdevice.h>
65 #include <linux/delay.h>
66 #include <asm/byteorder.h>
67 #include <linux/if_arp.h>
68 #include <linux/if_ether.h>
69 #include <linux/bitops.h>
71 #include "p80211types.h"
72 #include "p80211hdr.h"
73 #include "p80211mgmt.h"
74 #include "p80211conv.h"
75 #include "p80211msg.h"
76 #include "p80211netdev.h"
77 #include "p80211req.h"
78 #include "p80211metadef.h"
79 #include "p80211metastruct.h"
81 #include "prism2mgmt.h"
83 static char *dev_info = "prism2_usb";
84 static struct wlandevice *create_wlan(void);
86 int prism2_reset_holdtime = 30; /* Reset hold time in ms */
87 int prism2_reset_settletime = 100; /* Reset settle time in ms */
89 static int prism2_doreset; /* Do a reset at init? */
91 module_param(prism2_doreset, int, 0644);
92 MODULE_PARM_DESC(prism2_doreset, "Issue a reset on initialization");
94 module_param(prism2_reset_holdtime, int, 0644);
95 MODULE_PARM_DESC(prism2_reset_holdtime, "reset hold time in ms");
96 module_param(prism2_reset_settletime, int, 0644);
97 MODULE_PARM_DESC(prism2_reset_settletime, "reset settle time in ms");
99 MODULE_LICENSE("Dual MPL/GPL");
101 static int prism2sta_open(struct wlandevice *wlandev);
102 static int prism2sta_close(struct wlandevice *wlandev);
103 static void prism2sta_reset(struct wlandevice *wlandev);
104 static int prism2sta_txframe(struct wlandevice *wlandev, struct sk_buff *skb,
105 union p80211_hdr *p80211_hdr,
106 struct p80211_metawep *p80211_wep);
107 static int prism2sta_mlmerequest(struct wlandevice *wlandev, struct p80211msg *msg);
108 static int prism2sta_getcardinfo(struct wlandevice *wlandev);
109 static int prism2sta_globalsetup(struct wlandevice *wlandev);
110 static int prism2sta_setmulticast(struct wlandevice *wlandev,
111 struct net_device *dev);
113 static void prism2sta_inf_handover(struct wlandevice *wlandev,
114 hfa384x_InfFrame_t *inf);
115 static void prism2sta_inf_tallies(struct wlandevice *wlandev,
116 hfa384x_InfFrame_t *inf);
117 static void prism2sta_inf_hostscanresults(struct wlandevice *wlandev,
118 hfa384x_InfFrame_t *inf);
119 static void prism2sta_inf_scanresults(struct wlandevice *wlandev,
120 hfa384x_InfFrame_t *inf);
121 static void prism2sta_inf_chinforesults(struct wlandevice *wlandev,
122 hfa384x_InfFrame_t *inf);
123 static void prism2sta_inf_linkstatus(struct wlandevice *wlandev,
124 hfa384x_InfFrame_t *inf);
125 static void prism2sta_inf_assocstatus(struct wlandevice *wlandev,
126 hfa384x_InfFrame_t *inf);
127 static void prism2sta_inf_authreq(struct wlandevice *wlandev,
128 hfa384x_InfFrame_t *inf);
129 static void prism2sta_inf_authreq_defer(struct wlandevice *wlandev,
130 hfa384x_InfFrame_t *inf);
131 static void prism2sta_inf_psusercnt(struct wlandevice *wlandev,
132 hfa384x_InfFrame_t *inf);
137 * WLAN device open method. Called from p80211netdev when kernel
138 * device open (start) method is called in response to the
139 * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
143 * wlandev wlan device structure
147 * >0 f/w reported error
148 * <0 driver reported error
155 static int prism2sta_open(struct wlandevice *wlandev)
157 /* We don't currently have to do anything else.
158 * The setup of the MAC should be subsequently completed via
160 * Higher layers know we're ready from dev->start==1 and
161 * dev->tbusy==0. Our rx path knows to pass up received/
162 * frames because of dev->flags&IFF_UP is true.
171 * WLAN device close method. Called from p80211netdev when kernel
172 * device close method is called in response to the
173 * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
177 * wlandev wlan device structure
181 * >0 f/w reported error
182 * <0 driver reported error
189 static int prism2sta_close(struct wlandevice *wlandev)
191 /* We don't currently have to do anything else.
192 * Higher layers know we're not ready from dev->start==0 and
193 * dev->tbusy==1. Our rx path knows to not pass up received
194 * frames because of dev->flags&IFF_UP is false.
203 * Currently not implemented.
206 * wlandev wlan device structure
217 static void prism2sta_reset(struct wlandevice *wlandev)
224 * Takes a frame from p80211 and queues it for transmission.
227 * wlandev wlan device structure
228 * pb packet buffer struct. Contains an 802.11
230 * p80211_hdr points to the 802.11 header for the packet.
232 * 0 Success and more buffs available
233 * 1 Success but no more buffs
234 * 2 Allocation failure
235 * 4 Buffer full or queue busy
242 static int prism2sta_txframe(struct wlandevice *wlandev, struct sk_buff *skb,
243 union p80211_hdr *p80211_hdr,
244 struct p80211_metawep *p80211_wep)
246 hfa384x_t *hw = wlandev->priv;
248 /* If necessary, set the 802.11 WEP bit */
249 if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) ==
250 HOSTWEP_PRIVACYINVOKED) {
251 p80211_hdr->a3.fc |= cpu_to_le16(WLAN_SET_FC_ISWEP(1));
254 return hfa384x_drvr_txframe(hw, skb, p80211_hdr, p80211_wep);
258 * prism2sta_mlmerequest
260 * wlan command message handler. All we do here is pass the message
261 * over to the prism2sta_mgmt_handler.
264 * wlandev wlan device structure
265 * msg wlan command message
268 * <0 successful acceptance of message, but we're
269 * waiting for an async process to finish before
270 * we're done with the msg. When the asynch
271 * process is done, we'll call the p80211
272 * function p80211req_confirm() .
273 * >0 An error occurred while we were handling
281 static int prism2sta_mlmerequest(struct wlandevice *wlandev, struct p80211msg *msg)
283 hfa384x_t *hw = wlandev->priv;
287 switch (msg->msgcode) {
288 case DIDmsg_dot11req_mibget:
289 pr_debug("Received mibget request\n");
290 result = prism2mgmt_mibset_mibget(wlandev, msg);
292 case DIDmsg_dot11req_mibset:
293 pr_debug("Received mibset request\n");
294 result = prism2mgmt_mibset_mibget(wlandev, msg);
296 case DIDmsg_dot11req_scan:
297 pr_debug("Received scan request\n");
298 result = prism2mgmt_scan(wlandev, msg);
300 case DIDmsg_dot11req_scan_results:
301 pr_debug("Received scan_results request\n");
302 result = prism2mgmt_scan_results(wlandev, msg);
304 case DIDmsg_dot11req_start:
305 pr_debug("Received mlme start request\n");
306 result = prism2mgmt_start(wlandev, msg);
309 * Prism2 specific messages
311 case DIDmsg_p2req_readpda:
312 pr_debug("Received mlme readpda request\n");
313 result = prism2mgmt_readpda(wlandev, msg);
315 case DIDmsg_p2req_ramdl_state:
316 pr_debug("Received mlme ramdl_state request\n");
317 result = prism2mgmt_ramdl_state(wlandev, msg);
319 case DIDmsg_p2req_ramdl_write:
320 pr_debug("Received mlme ramdl_write request\n");
321 result = prism2mgmt_ramdl_write(wlandev, msg);
323 case DIDmsg_p2req_flashdl_state:
324 pr_debug("Received mlme flashdl_state request\n");
325 result = prism2mgmt_flashdl_state(wlandev, msg);
327 case DIDmsg_p2req_flashdl_write:
328 pr_debug("Received mlme flashdl_write request\n");
329 result = prism2mgmt_flashdl_write(wlandev, msg);
332 * Linux specific messages
334 case DIDmsg_lnxreq_hostwep:
335 break; /* ignore me. */
336 case DIDmsg_lnxreq_ifstate:
338 struct p80211msg_lnxreq_ifstate *ifstatemsg;
340 pr_debug("Received mlme ifstate request\n");
341 ifstatemsg = (struct p80211msg_lnxreq_ifstate *)msg;
343 prism2sta_ifstate(wlandev,
344 ifstatemsg->ifstate.data);
345 ifstatemsg->resultcode.status =
346 P80211ENUM_msgitem_status_data_ok;
347 ifstatemsg->resultcode.data = result;
351 case DIDmsg_lnxreq_wlansniff:
352 pr_debug("Received mlme wlansniff request\n");
353 result = prism2mgmt_wlansniff(wlandev, msg);
355 case DIDmsg_lnxreq_autojoin:
356 pr_debug("Received mlme autojoin request\n");
357 result = prism2mgmt_autojoin(wlandev, msg);
359 case DIDmsg_lnxreq_commsquality:{
360 struct p80211msg_lnxreq_commsquality *qualmsg;
362 pr_debug("Received commsquality request\n");
364 qualmsg = (struct p80211msg_lnxreq_commsquality *)msg;
366 qualmsg->link.status =
367 P80211ENUM_msgitem_status_data_ok;
368 qualmsg->level.status =
369 P80211ENUM_msgitem_status_data_ok;
370 qualmsg->noise.status =
371 P80211ENUM_msgitem_status_data_ok;
373 qualmsg->link.data = le16_to_cpu(hw->qual.CQ_currBSS);
374 qualmsg->level.data = le16_to_cpu(hw->qual.ASL_currBSS);
375 qualmsg->noise.data = le16_to_cpu(hw->qual.ANL_currFC);
376 qualmsg->txrate.data = hw->txrate;
381 netdev_warn(wlandev->netdev,
382 "Unknown mgmt request message 0x%08x",
393 * Interface state. This is the primary WLAN interface enable/disable
394 * handler. Following the driver/load/deviceprobe sequence, this
395 * function must be called with a state of "enable" before any other
396 * commands will be accepted.
399 * wlandev wlan device structure
400 * msgp ptr to msg buffer
403 * A p80211 message resultcode value.
408 * process thread (usually)
411 u32 prism2sta_ifstate(struct wlandevice *wlandev, u32 ifstate)
413 hfa384x_t *hw = wlandev->priv;
416 result = P80211ENUM_resultcode_implementation_failure;
418 pr_debug("Current MSD state(%d), requesting(%d)\n",
419 wlandev->msdstate, ifstate);
421 case P80211ENUM_ifstate_fwload:
422 switch (wlandev->msdstate) {
423 case WLAN_MSD_HWPRESENT:
424 wlandev->msdstate = WLAN_MSD_FWLOAD_PENDING;
426 * Initialize the device+driver sufficiently
427 * for firmware loading.
429 result = hfa384x_drvr_start(hw);
431 netdev_err(wlandev->netdev,
432 "hfa384x_drvr_start() failed,result=%d\n",
435 P80211ENUM_resultcode_implementation_failure;
436 wlandev->msdstate = WLAN_MSD_HWPRESENT;
439 wlandev->msdstate = WLAN_MSD_FWLOAD;
440 result = P80211ENUM_resultcode_success;
442 case WLAN_MSD_FWLOAD:
443 hfa384x_cmd_initialize(hw);
444 result = P80211ENUM_resultcode_success;
446 case WLAN_MSD_RUNNING:
447 netdev_warn(wlandev->netdev,
448 "Cannot enter fwload state from enable state, you must disable first.\n");
449 result = P80211ENUM_resultcode_invalid_parameters;
451 case WLAN_MSD_HWFAIL:
453 /* probe() had a problem or the msdstate contains
454 * an unrecognized value, there's nothing we can do.
456 result = P80211ENUM_resultcode_implementation_failure;
460 case P80211ENUM_ifstate_enable:
461 switch (wlandev->msdstate) {
462 case WLAN_MSD_HWPRESENT:
463 case WLAN_MSD_FWLOAD:
464 wlandev->msdstate = WLAN_MSD_RUNNING_PENDING;
465 /* Initialize the device+driver for full
466 * operation. Note that this might me an FWLOAD to
467 * to RUNNING transition so we must not do a chip
468 * or board level reset. Note that on failure,
469 * the MSD state is set to HWPRESENT because we
470 * can't make any assumptions about the state
471 * of the hardware or a previous firmware load.
473 result = hfa384x_drvr_start(hw);
475 netdev_err(wlandev->netdev,
476 "hfa384x_drvr_start() failed,result=%d\n",
479 P80211ENUM_resultcode_implementation_failure;
480 wlandev->msdstate = WLAN_MSD_HWPRESENT;
484 result = prism2sta_getcardinfo(wlandev);
486 netdev_err(wlandev->netdev,
487 "prism2sta_getcardinfo() failed,result=%d\n",
490 P80211ENUM_resultcode_implementation_failure;
491 hfa384x_drvr_stop(hw);
492 wlandev->msdstate = WLAN_MSD_HWPRESENT;
495 result = prism2sta_globalsetup(wlandev);
497 netdev_err(wlandev->netdev,
498 "prism2sta_globalsetup() failed,result=%d\n",
501 P80211ENUM_resultcode_implementation_failure;
502 hfa384x_drvr_stop(hw);
503 wlandev->msdstate = WLAN_MSD_HWPRESENT;
506 wlandev->msdstate = WLAN_MSD_RUNNING;
508 hw->join_retries = 60;
509 result = P80211ENUM_resultcode_success;
511 case WLAN_MSD_RUNNING:
512 /* Do nothing, we're already in this state. */
513 result = P80211ENUM_resultcode_success;
515 case WLAN_MSD_HWFAIL:
517 /* probe() had a problem or the msdstate contains
518 * an unrecognized value, there's nothing we can do.
520 result = P80211ENUM_resultcode_implementation_failure;
524 case P80211ENUM_ifstate_disable:
525 switch (wlandev->msdstate) {
526 case WLAN_MSD_HWPRESENT:
527 /* Do nothing, we're already in this state. */
528 result = P80211ENUM_resultcode_success;
530 case WLAN_MSD_FWLOAD:
531 case WLAN_MSD_RUNNING:
532 wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING;
534 * TODO: Shut down the MAC completely. Here a chip
535 * or board level reset is probably called for.
536 * After a "disable" _all_ results are lost, even
537 * those from a fwload.
539 if (!wlandev->hwremoved)
540 netif_carrier_off(wlandev->netdev);
542 hfa384x_drvr_stop(hw);
544 wlandev->macmode = WLAN_MACMODE_NONE;
545 wlandev->msdstate = WLAN_MSD_HWPRESENT;
546 result = P80211ENUM_resultcode_success;
548 case WLAN_MSD_HWFAIL:
550 /* probe() had a problem or the msdstate contains
551 * an unrecognized value, there's nothing we can do.
553 result = P80211ENUM_resultcode_implementation_failure;
558 result = P80211ENUM_resultcode_invalid_parameters;
566 * prism2sta_getcardinfo
568 * Collect the NICID, firmware version and any other identifiers
569 * we'd like to have in host-side data structures.
572 * wlandev wlan device structure
576 * >0 f/w reported error
577 * <0 driver reported error
584 static int prism2sta_getcardinfo(struct wlandevice *wlandev)
587 hfa384x_t *hw = wlandev->priv;
589 u8 snum[HFA384x_RID_NICSERIALNUMBER_LEN];
591 /* Collect version and compatibility info */
592 /* Some are critical, some are not */
594 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICIDENTITY,
596 sizeof(struct hfa384x_compident));
598 netdev_err(wlandev->netdev, "Failed to retrieve NICIDENTITY\n");
602 /* get all the nic id fields in host byte order */
603 hw->ident_nic.id = le16_to_cpu(hw->ident_nic.id);
604 hw->ident_nic.variant = le16_to_cpu(hw->ident_nic.variant);
605 hw->ident_nic.major = le16_to_cpu(hw->ident_nic.major);
606 hw->ident_nic.minor = le16_to_cpu(hw->ident_nic.minor);
608 netdev_info(wlandev->netdev, "ident: nic h/w: id=0x%02x %d.%d.%d\n",
609 hw->ident_nic.id, hw->ident_nic.major,
610 hw->ident_nic.minor, hw->ident_nic.variant);
612 /* Primary f/w identity */
613 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRIIDENTITY,
615 sizeof(struct hfa384x_compident));
617 netdev_err(wlandev->netdev, "Failed to retrieve PRIIDENTITY\n");
621 /* get all the private fw id fields in host byte order */
622 hw->ident_pri_fw.id = le16_to_cpu(hw->ident_pri_fw.id);
623 hw->ident_pri_fw.variant = le16_to_cpu(hw->ident_pri_fw.variant);
624 hw->ident_pri_fw.major = le16_to_cpu(hw->ident_pri_fw.major);
625 hw->ident_pri_fw.minor = le16_to_cpu(hw->ident_pri_fw.minor);
627 netdev_info(wlandev->netdev, "ident: pri f/w: id=0x%02x %d.%d.%d\n",
628 hw->ident_pri_fw.id, hw->ident_pri_fw.major,
629 hw->ident_pri_fw.minor, hw->ident_pri_fw.variant);
631 /* Station (Secondary?) f/w identity */
632 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STAIDENTITY,
634 sizeof(struct hfa384x_compident));
636 netdev_err(wlandev->netdev, "Failed to retrieve STAIDENTITY\n");
640 if (hw->ident_nic.id < 0x8000) {
641 netdev_err(wlandev->netdev,
642 "FATAL: Card is not an Intersil Prism2/2.5/3\n");
647 /* get all the station fw id fields in host byte order */
648 hw->ident_sta_fw.id = le16_to_cpu(hw->ident_sta_fw.id);
649 hw->ident_sta_fw.variant = le16_to_cpu(hw->ident_sta_fw.variant);
650 hw->ident_sta_fw.major = le16_to_cpu(hw->ident_sta_fw.major);
651 hw->ident_sta_fw.minor = le16_to_cpu(hw->ident_sta_fw.minor);
653 /* strip out the 'special' variant bits */
654 hw->mm_mods = hw->ident_sta_fw.variant & (BIT(14) | BIT(15));
655 hw->ident_sta_fw.variant &= ~((u16)(BIT(14) | BIT(15)));
657 if (hw->ident_sta_fw.id == 0x1f) {
658 netdev_info(wlandev->netdev,
659 "ident: sta f/w: id=0x%02x %d.%d.%d\n",
660 hw->ident_sta_fw.id, hw->ident_sta_fw.major,
661 hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
663 netdev_info(wlandev->netdev,
664 "ident: ap f/w: id=0x%02x %d.%d.%d\n",
665 hw->ident_sta_fw.id, hw->ident_sta_fw.major,
666 hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
667 netdev_err(wlandev->netdev, "Unsupported Tertiary AP firmware loaded!\n");
671 /* Compatibility range, Modem supplier */
672 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_MFISUPRANGE,
674 sizeof(struct hfa384x_caplevel));
676 netdev_err(wlandev->netdev, "Failed to retrieve MFISUPRANGE\n");
680 /* get all the Compatibility range, modem interface supplier
681 * fields in byte order
683 hw->cap_sup_mfi.role = le16_to_cpu(hw->cap_sup_mfi.role);
684 hw->cap_sup_mfi.id = le16_to_cpu(hw->cap_sup_mfi.id);
685 hw->cap_sup_mfi.variant = le16_to_cpu(hw->cap_sup_mfi.variant);
686 hw->cap_sup_mfi.bottom = le16_to_cpu(hw->cap_sup_mfi.bottom);
687 hw->cap_sup_mfi.top = le16_to_cpu(hw->cap_sup_mfi.top);
689 netdev_info(wlandev->netdev,
690 "MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
691 hw->cap_sup_mfi.role, hw->cap_sup_mfi.id,
692 hw->cap_sup_mfi.variant, hw->cap_sup_mfi.bottom,
693 hw->cap_sup_mfi.top);
695 /* Compatibility range, Controller supplier */
696 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CFISUPRANGE,
698 sizeof(struct hfa384x_caplevel));
700 netdev_err(wlandev->netdev, "Failed to retrieve CFISUPRANGE\n");
704 /* get all the Compatibility range, controller interface supplier
705 * fields in byte order
707 hw->cap_sup_cfi.role = le16_to_cpu(hw->cap_sup_cfi.role);
708 hw->cap_sup_cfi.id = le16_to_cpu(hw->cap_sup_cfi.id);
709 hw->cap_sup_cfi.variant = le16_to_cpu(hw->cap_sup_cfi.variant);
710 hw->cap_sup_cfi.bottom = le16_to_cpu(hw->cap_sup_cfi.bottom);
711 hw->cap_sup_cfi.top = le16_to_cpu(hw->cap_sup_cfi.top);
713 netdev_info(wlandev->netdev,
714 "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
715 hw->cap_sup_cfi.role, hw->cap_sup_cfi.id,
716 hw->cap_sup_cfi.variant, hw->cap_sup_cfi.bottom,
717 hw->cap_sup_cfi.top);
719 /* Compatibility range, Primary f/w supplier */
720 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRISUPRANGE,
722 sizeof(struct hfa384x_caplevel));
724 netdev_err(wlandev->netdev, "Failed to retrieve PRISUPRANGE\n");
728 /* get all the Compatibility range, primary firmware supplier
729 * fields in byte order
731 hw->cap_sup_pri.role = le16_to_cpu(hw->cap_sup_pri.role);
732 hw->cap_sup_pri.id = le16_to_cpu(hw->cap_sup_pri.id);
733 hw->cap_sup_pri.variant = le16_to_cpu(hw->cap_sup_pri.variant);
734 hw->cap_sup_pri.bottom = le16_to_cpu(hw->cap_sup_pri.bottom);
735 hw->cap_sup_pri.top = le16_to_cpu(hw->cap_sup_pri.top);
737 netdev_info(wlandev->netdev,
738 "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
739 hw->cap_sup_pri.role, hw->cap_sup_pri.id,
740 hw->cap_sup_pri.variant, hw->cap_sup_pri.bottom,
741 hw->cap_sup_pri.top);
743 /* Compatibility range, Station f/w supplier */
744 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STASUPRANGE,
746 sizeof(struct hfa384x_caplevel));
748 netdev_err(wlandev->netdev, "Failed to retrieve STASUPRANGE\n");
752 /* get all the Compatibility range, station firmware supplier
753 * fields in byte order
755 hw->cap_sup_sta.role = le16_to_cpu(hw->cap_sup_sta.role);
756 hw->cap_sup_sta.id = le16_to_cpu(hw->cap_sup_sta.id);
757 hw->cap_sup_sta.variant = le16_to_cpu(hw->cap_sup_sta.variant);
758 hw->cap_sup_sta.bottom = le16_to_cpu(hw->cap_sup_sta.bottom);
759 hw->cap_sup_sta.top = le16_to_cpu(hw->cap_sup_sta.top);
761 if (hw->cap_sup_sta.id == 0x04) {
762 netdev_info(wlandev->netdev,
763 "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
764 hw->cap_sup_sta.role, hw->cap_sup_sta.id,
765 hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
766 hw->cap_sup_sta.top);
768 netdev_info(wlandev->netdev,
769 "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
770 hw->cap_sup_sta.role, hw->cap_sup_sta.id,
771 hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
772 hw->cap_sup_sta.top);
775 /* Compatibility range, primary f/w actor, CFI supplier */
776 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRI_CFIACTRANGES,
777 &hw->cap_act_pri_cfi,
778 sizeof(struct hfa384x_caplevel));
780 netdev_err(wlandev->netdev, "Failed to retrieve PRI_CFIACTRANGES\n");
784 /* get all the Compatibility range, primary f/w actor, CFI supplier
785 * fields in byte order
787 hw->cap_act_pri_cfi.role = le16_to_cpu(hw->cap_act_pri_cfi.role);
788 hw->cap_act_pri_cfi.id = le16_to_cpu(hw->cap_act_pri_cfi.id);
789 hw->cap_act_pri_cfi.variant = le16_to_cpu(hw->cap_act_pri_cfi.variant);
790 hw->cap_act_pri_cfi.bottom = le16_to_cpu(hw->cap_act_pri_cfi.bottom);
791 hw->cap_act_pri_cfi.top = le16_to_cpu(hw->cap_act_pri_cfi.top);
793 netdev_info(wlandev->netdev,
794 "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
795 hw->cap_act_pri_cfi.role, hw->cap_act_pri_cfi.id,
796 hw->cap_act_pri_cfi.variant, hw->cap_act_pri_cfi.bottom,
797 hw->cap_act_pri_cfi.top);
799 /* Compatibility range, sta f/w actor, CFI supplier */
800 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_CFIACTRANGES,
801 &hw->cap_act_sta_cfi,
802 sizeof(struct hfa384x_caplevel));
804 netdev_err(wlandev->netdev, "Failed to retrieve STA_CFIACTRANGES\n");
808 /* get all the Compatibility range, station f/w actor, CFI supplier
809 * fields in byte order
811 hw->cap_act_sta_cfi.role = le16_to_cpu(hw->cap_act_sta_cfi.role);
812 hw->cap_act_sta_cfi.id = le16_to_cpu(hw->cap_act_sta_cfi.id);
813 hw->cap_act_sta_cfi.variant = le16_to_cpu(hw->cap_act_sta_cfi.variant);
814 hw->cap_act_sta_cfi.bottom = le16_to_cpu(hw->cap_act_sta_cfi.bottom);
815 hw->cap_act_sta_cfi.top = le16_to_cpu(hw->cap_act_sta_cfi.top);
817 netdev_info(wlandev->netdev,
818 "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
819 hw->cap_act_sta_cfi.role, hw->cap_act_sta_cfi.id,
820 hw->cap_act_sta_cfi.variant, hw->cap_act_sta_cfi.bottom,
821 hw->cap_act_sta_cfi.top);
823 /* Compatibility range, sta f/w actor, MFI supplier */
824 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_MFIACTRANGES,
825 &hw->cap_act_sta_mfi,
826 sizeof(struct hfa384x_caplevel));
828 netdev_err(wlandev->netdev, "Failed to retrieve STA_MFIACTRANGES\n");
832 /* get all the Compatibility range, station f/w actor, MFI supplier
833 * fields in byte order
835 hw->cap_act_sta_mfi.role = le16_to_cpu(hw->cap_act_sta_mfi.role);
836 hw->cap_act_sta_mfi.id = le16_to_cpu(hw->cap_act_sta_mfi.id);
837 hw->cap_act_sta_mfi.variant = le16_to_cpu(hw->cap_act_sta_mfi.variant);
838 hw->cap_act_sta_mfi.bottom = le16_to_cpu(hw->cap_act_sta_mfi.bottom);
839 hw->cap_act_sta_mfi.top = le16_to_cpu(hw->cap_act_sta_mfi.top);
841 netdev_info(wlandev->netdev,
842 "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
843 hw->cap_act_sta_mfi.role, hw->cap_act_sta_mfi.id,
844 hw->cap_act_sta_mfi.variant, hw->cap_act_sta_mfi.bottom,
845 hw->cap_act_sta_mfi.top);
848 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICSERIALNUMBER,
849 snum, HFA384x_RID_NICSERIALNUMBER_LEN);
851 netdev_info(wlandev->netdev, "Prism2 card SN: %*pEhp\n",
852 HFA384x_RID_NICSERIALNUMBER_LEN, snum);
854 netdev_err(wlandev->netdev, "Failed to retrieve Prism2 Card SN\n");
858 /* Collect the MAC address */
859 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFOWNMACADDR,
860 wlandev->netdev->dev_addr, ETH_ALEN);
862 netdev_err(wlandev->netdev, "Failed to retrieve mac address\n");
866 /* short preamble is always implemented */
867 wlandev->nsdcaps |= P80211_NSDCAP_SHORT_PREAMBLE;
869 /* find out if hardware wep is implemented */
870 hfa384x_drvr_getconfig16(hw, HFA384x_RID_PRIVACYOPTIMP, &temp);
872 wlandev->nsdcaps |= P80211_NSDCAP_HARDWAREWEP;
874 /* get the dBm Scaling constant */
875 hfa384x_drvr_getconfig16(hw, HFA384x_RID_CNFDBMADJUST, &temp);
876 hw->dbmadjust = temp;
878 /* Only enable scan by default on newer firmware */
879 if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
880 hw->ident_sta_fw.minor,
881 hw->ident_sta_fw.variant) <
882 HFA384x_FIRMWARE_VERSION(1, 5, 5)) {
883 wlandev->nsdcaps |= P80211_NSDCAP_NOSCAN;
886 /* TODO: Set any internally managed config items */
890 netdev_err(wlandev->netdev, "Failed, result=%d\n", result);
896 * prism2sta_globalsetup
898 * Set any global RIDs that we want to set at device activation.
901 * wlandev wlan device structure
905 * >0 f/w reported error
906 * <0 driver reported error
913 static int prism2sta_globalsetup(struct wlandevice *wlandev)
915 hfa384x_t *hw = wlandev->priv;
917 /* Set the maximum frame size */
918 return hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN,
922 static int prism2sta_setmulticast(struct wlandevice *wlandev,
923 struct net_device *dev)
926 hfa384x_t *hw = wlandev->priv;
930 /* If we're not ready, what's the point? */
931 if (hw->state != HFA384x_STATE_RUNNING)
934 if ((dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0)
935 promisc = P80211ENUM_truth_true;
937 promisc = P80211ENUM_truth_false;
940 hfa384x_drvr_setconfig16_async(hw, HFA384x_RID_PROMISCMODE,
947 * prism2sta_inf_handover
949 * Handles the receipt of a Handover info frame. Should only be present
953 * wlandev wlan device structure
954 * inf ptr to info frame (contents in hfa384x order)
964 static void prism2sta_inf_handover(struct wlandevice *wlandev,
965 hfa384x_InfFrame_t *inf)
967 pr_debug("received infoframe:HANDOVER (unhandled)\n");
971 * prism2sta_inf_tallies
973 * Handles the receipt of a CommTallies info frame.
976 * wlandev wlan device structure
977 * inf ptr to info frame (contents in hfa384x order)
987 static void prism2sta_inf_tallies(struct wlandevice *wlandev,
988 hfa384x_InfFrame_t *inf)
990 hfa384x_t *hw = wlandev->priv;
998 * Determine if these are 16-bit or 32-bit tallies, based on the
999 * record length of the info record.
1002 cnt = sizeof(struct hfa384x_CommTallies32) / sizeof(u32);
1003 if (inf->framelen > 22) {
1004 dst = (u32 *)&hw->tallies;
1005 src32 = (u32 *)&inf->info.commtallies32;
1006 for (i = 0; i < cnt; i++, dst++, src32++)
1007 *dst += le32_to_cpu(*src32);
1009 dst = (u32 *)&hw->tallies;
1010 src16 = (u16 *)&inf->info.commtallies16;
1011 for (i = 0; i < cnt; i++, dst++, src16++)
1012 *dst += le16_to_cpu(*src16);
1017 * prism2sta_inf_scanresults
1019 * Handles the receipt of a Scan Results info frame.
1022 * wlandev wlan device structure
1023 * inf ptr to info frame (contents in hfa384x order)
1033 static void prism2sta_inf_scanresults(struct wlandevice *wlandev,
1034 hfa384x_InfFrame_t *inf)
1036 hfa384x_t *hw = wlandev->priv;
1038 struct hfa384x_ScanResult *sr = &(inf->info.scanresult);
1040 struct hfa384x_JoinRequest_data joinreq;
1043 /* Get the number of results, first in bytes, then in results */
1044 nbss = (inf->framelen * sizeof(u16)) -
1045 sizeof(inf->infotype) - sizeof(inf->info.scanresult.scanreason);
1046 nbss /= sizeof(struct hfa384x_ScanResultSub);
1049 pr_debug("rx scanresults, reason=%d, nbss=%d:\n",
1050 inf->info.scanresult.scanreason, nbss);
1051 for (i = 0; i < nbss; i++) {
1052 pr_debug("chid=%d anl=%d sl=%d bcnint=%d\n",
1055 sr->result[i].sl, sr->result[i].bcnint);
1056 pr_debug(" capinfo=0x%04x proberesp_rate=%d\n",
1057 sr->result[i].capinfo, sr->result[i].proberesp_rate);
1059 /* issue a join request */
1060 joinreq.channel = sr->result[0].chid;
1061 memcpy(joinreq.bssid, sr->result[0].bssid, WLAN_BSSID_LEN);
1062 result = hfa384x_drvr_setconfig(hw,
1063 HFA384x_RID_JOINREQUEST,
1064 &joinreq, HFA384x_RID_JOINREQUEST_LEN);
1066 netdev_err(wlandev->netdev, "setconfig(joinreq) failed, result=%d\n",
1072 * prism2sta_inf_hostscanresults
1074 * Handles the receipt of a Scan Results info frame.
1077 * wlandev wlan device structure
1078 * inf ptr to info frame (contents in hfa384x order)
1088 static void prism2sta_inf_hostscanresults(struct wlandevice *wlandev,
1089 hfa384x_InfFrame_t *inf)
1091 hfa384x_t *hw = wlandev->priv;
1094 nbss = (inf->framelen - 3) / 32;
1095 pr_debug("Received %d hostscan results\n", nbss);
1100 kfree(hw->scanresults);
1102 hw->scanresults = kmemdup(inf, sizeof(hfa384x_InfFrame_t), GFP_ATOMIC);
1107 /* Notify/wake the sleeping caller. */
1108 hw->scanflag = nbss;
1109 wake_up_interruptible(&hw->cmdq);
1113 * prism2sta_inf_chinforesults
1115 * Handles the receipt of a Channel Info Results info frame.
1118 * wlandev wlan device structure
1119 * inf ptr to info frame (contents in hfa384x order)
1129 static void prism2sta_inf_chinforesults(struct wlandevice *wlandev,
1130 hfa384x_InfFrame_t *inf)
1132 hfa384x_t *hw = wlandev->priv;
1135 hw->channel_info.results.scanchannels =
1136 le16_to_cpu(inf->info.chinforesult.scanchannels);
1138 for (i = 0, n = 0; i < HFA384x_CHINFORESULT_MAX; i++) {
1139 struct hfa384x_ChInfoResultSub *result;
1140 struct hfa384x_ChInfoResultSub *chinforesult;
1143 if (!(hw->channel_info.results.scanchannels & (1 << i)))
1146 result = &inf->info.chinforesult.result[n];
1147 chan = le16_to_cpu(result->chid) - 1;
1149 if (chan < 0 || chan >= HFA384x_CHINFORESULT_MAX)
1152 chinforesult = &hw->channel_info.results.result[chan];
1153 chinforesult->chid = chan;
1154 chinforesult->anl = le16_to_cpu(result->anl);
1155 chinforesult->pnl = le16_to_cpu(result->pnl);
1156 chinforesult->active = le16_to_cpu(result->active);
1158 pr_debug("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n",
1160 (chinforesult->active & HFA384x_CHINFORESULT_BSSACTIVE)
1161 ? "signal" : "noise",
1162 chinforesult->anl, chinforesult->pnl,
1163 (chinforesult->active & HFA384x_CHINFORESULT_PCFACTIVE)
1167 atomic_set(&hw->channel_info.done, 2);
1169 hw->channel_info.count = n;
1172 void prism2sta_processing_defer(struct work_struct *data)
1174 hfa384x_t *hw = container_of(data, struct hfa384x, link_bh);
1175 struct wlandevice *wlandev = hw->wlandev;
1176 struct hfa384x_bytestr32 ssid;
1179 /* First let's process the auth frames */
1181 struct sk_buff *skb;
1182 hfa384x_InfFrame_t *inf;
1184 while ((skb = skb_dequeue(&hw->authq))) {
1185 inf = (hfa384x_InfFrame_t *)skb->data;
1186 prism2sta_inf_authreq_defer(wlandev, inf);
1191 /* Now let's handle the linkstatus stuff */
1192 if (hw->link_status == hw->link_status_new)
1195 hw->link_status = hw->link_status_new;
1197 switch (hw->link_status) {
1198 case HFA384x_LINK_NOTCONNECTED:
1199 /* I'm currently assuming that this is the initial link
1200 * state. It should only be possible immediately
1201 * following an Enable command.
1203 * Block Transmits, Ignore receives of data frames
1205 netif_carrier_off(wlandev->netdev);
1207 netdev_info(wlandev->netdev, "linkstatus=NOTCONNECTED (unhandled)\n");
1210 case HFA384x_LINK_CONNECTED:
1211 /* This one indicates a successful scan/join/auth/assoc.
1212 * When we have the full MLME complement, this event will
1213 * signify successful completion of both mlme_authenticate
1214 * and mlme_associate. State management will get a little
1217 * Indicate authentication and/or association
1218 * Enable Transmits, Receives and pass up data frames
1221 netif_carrier_on(wlandev->netdev);
1223 /* If we are joining a specific AP, set our
1224 * state and reset retries
1226 if (hw->join_ap == 1)
1228 hw->join_retries = 60;
1230 /* Don't call this in monitor mode */
1231 if (wlandev->netdev->type == ARPHRD_ETHER) {
1234 netdev_info(wlandev->netdev, "linkstatus=CONNECTED\n");
1236 /* For non-usb devices, we can use the sync versions */
1237 /* Collect the BSSID, and set state to allow tx */
1239 result = hfa384x_drvr_getconfig(hw,
1240 HFA384x_RID_CURRENTBSSID,
1245 ("getconfig(0x%02x) failed, result = %d\n",
1246 HFA384x_RID_CURRENTBSSID, result);
1250 result = hfa384x_drvr_getconfig(hw,
1251 HFA384x_RID_CURRENTSSID,
1252 &ssid, sizeof(ssid));
1255 ("getconfig(0x%02x) failed, result = %d\n",
1256 HFA384x_RID_CURRENTSSID, result);
1259 prism2mgmt_bytestr2pstr(
1260 (struct hfa384x_bytestr *)&ssid,
1261 (struct p80211pstrd *)&wlandev->ssid);
1263 /* Collect the port status */
1264 result = hfa384x_drvr_getconfig16(hw,
1265 HFA384x_RID_PORTSTATUS,
1269 ("getconfig(0x%02x) failed, result = %d\n",
1270 HFA384x_RID_PORTSTATUS, result);
1274 (portstatus == HFA384x_PSTATUS_CONN_IBSS) ?
1275 WLAN_MACMODE_IBSS_STA : WLAN_MACMODE_ESS_STA;
1277 /* signal back up to cfg80211 layer */
1278 prism2_connect_result(wlandev, P80211ENUM_truth_false);
1280 /* Get the ball rolling on the comms quality stuff */
1281 prism2sta_commsqual_defer(&hw->commsqual_bh);
1285 case HFA384x_LINK_DISCONNECTED:
1286 /* This one indicates that our association is gone. We've
1287 * lost connection with the AP and/or been disassociated.
1288 * This indicates that the MAC has completely cleared it's
1289 * associated state. We * should send a deauth indication
1290 * (implying disassoc) up * to the MLME.
1292 * Indicate Deauthentication
1293 * Block Transmits, Ignore receives of data frames
1295 if (wlandev->netdev->type == ARPHRD_ETHER)
1296 netdev_info(wlandev->netdev,
1297 "linkstatus=DISCONNECTED (unhandled)\n");
1298 wlandev->macmode = WLAN_MACMODE_NONE;
1300 netif_carrier_off(wlandev->netdev);
1302 /* signal back up to cfg80211 layer */
1303 prism2_disconnected(wlandev);
1307 case HFA384x_LINK_AP_CHANGE:
1308 /* This one indicates that the MAC has decided to and
1309 * successfully completed a change to another AP. We
1310 * should probably implement a reassociation indication
1311 * in response to this one. I'm thinking that the the
1312 * p80211 layer needs to be notified in case of
1313 * buffering/queueing issues. User mode also needs to be
1314 * notified so that any BSS dependent elements can be
1316 * associated state. We * should send a deauth indication
1317 * (implying disassoc) up * to the MLME.
1319 * Indicate Reassociation
1320 * Enable Transmits, Receives and pass up data frames
1322 netdev_info(wlandev->netdev, "linkstatus=AP_CHANGE\n");
1324 result = hfa384x_drvr_getconfig(hw,
1325 HFA384x_RID_CURRENTBSSID,
1326 wlandev->bssid, WLAN_BSSID_LEN);
1328 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1329 HFA384x_RID_CURRENTBSSID, result);
1333 result = hfa384x_drvr_getconfig(hw,
1334 HFA384x_RID_CURRENTSSID,
1335 &ssid, sizeof(ssid));
1337 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1338 HFA384x_RID_CURRENTSSID, result);
1341 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *)&ssid,
1342 (struct p80211pstrd *)&wlandev->ssid);
1344 hw->link_status = HFA384x_LINK_CONNECTED;
1345 netif_carrier_on(wlandev->netdev);
1347 /* signal back up to cfg80211 layer */
1348 prism2_roamed(wlandev);
1352 case HFA384x_LINK_AP_OUTOFRANGE:
1353 /* This one indicates that the MAC has decided that the
1354 * AP is out of range, but hasn't found a better candidate
1355 * so the MAC maintains its "associated" state in case
1356 * we get back in range. We should block transmits and
1357 * receives in this state. Do we need an indication here?
1358 * Probably not since a polling user-mode element would
1359 * get this status from from p2PortStatus(FD40). What about
1362 * Block Transmits, Ignore receives of data frames
1364 netdev_info(wlandev->netdev, "linkstatus=AP_OUTOFRANGE (unhandled)\n");
1366 netif_carrier_off(wlandev->netdev);
1370 case HFA384x_LINK_AP_INRANGE:
1371 /* This one indicates that the MAC has decided that the
1372 * AP is back in range. We continue working with our
1373 * existing association.
1375 * Enable Transmits, Receives and pass up data frames
1377 netdev_info(wlandev->netdev, "linkstatus=AP_INRANGE\n");
1379 hw->link_status = HFA384x_LINK_CONNECTED;
1380 netif_carrier_on(wlandev->netdev);
1384 case HFA384x_LINK_ASSOCFAIL:
1385 /* This one is actually a peer to CONNECTED. We've
1386 * requested a join for a given SSID and optionally BSSID.
1387 * We can use this one to indicate authentication and
1388 * association failures. The trick is going to be
1389 * 1) identifying the failure, and 2) state management.
1391 * Disable Transmits, Ignore receives of data frames
1393 if (hw->join_ap && --hw->join_retries > 0) {
1394 struct hfa384x_JoinRequest_data joinreq;
1396 joinreq = hw->joinreq;
1397 /* Send the join request */
1398 hfa384x_drvr_setconfig(hw,
1399 HFA384x_RID_JOINREQUEST,
1401 HFA384x_RID_JOINREQUEST_LEN);
1402 netdev_info(wlandev->netdev,
1403 "linkstatus=ASSOCFAIL (re-submitting join)\n");
1405 netdev_info(wlandev->netdev, "linkstatus=ASSOCFAIL (unhandled)\n");
1408 netif_carrier_off(wlandev->netdev);
1410 /* signal back up to cfg80211 layer */
1411 prism2_connect_result(wlandev, P80211ENUM_truth_true);
1416 /* This is bad, IO port problems? */
1417 netdev_warn(wlandev->netdev,
1418 "unknown linkstatus=0x%02x\n", hw->link_status);
1422 wlandev->linkstatus = (hw->link_status == HFA384x_LINK_CONNECTED);
1426 * prism2sta_inf_linkstatus
1428 * Handles the receipt of a Link Status info frame.
1431 * wlandev wlan device structure
1432 * inf ptr to info frame (contents in hfa384x order)
1442 static void prism2sta_inf_linkstatus(struct wlandevice *wlandev,
1443 hfa384x_InfFrame_t *inf)
1445 hfa384x_t *hw = wlandev->priv;
1447 hw->link_status_new = le16_to_cpu(inf->info.linkstatus.linkstatus);
1449 schedule_work(&hw->link_bh);
1453 * prism2sta_inf_assocstatus
1455 * Handles the receipt of an Association Status info frame. Should
1456 * be present in APs only.
1459 * wlandev wlan device structure
1460 * inf ptr to info frame (contents in hfa384x order)
1470 static void prism2sta_inf_assocstatus(struct wlandevice *wlandev,
1471 hfa384x_InfFrame_t *inf)
1473 hfa384x_t *hw = wlandev->priv;
1474 hfa384x_AssocStatus_t rec;
1477 memcpy(&rec, &inf->info.assocstatus, sizeof(rec));
1478 rec.assocstatus = le16_to_cpu(rec.assocstatus);
1479 rec.reason = le16_to_cpu(rec.reason);
1482 * Find the address in the list of authenticated stations.
1483 * If it wasn't found, then this address has not been previously
1484 * authenticated and something weird has happened if this is
1485 * anything other than an "authentication failed" message.
1486 * If the address was found, then set the "associated" flag for
1487 * that station, based on whether the station is associating or
1488 * losing its association. Something weird has also happened
1489 * if we find the address in the list of authenticated stations
1490 * but we are getting an "authentication failed" message.
1493 for (i = 0; i < hw->authlist.cnt; i++)
1494 if (ether_addr_equal(rec.sta_addr, hw->authlist.addr[i]))
1497 if (i >= hw->authlist.cnt) {
1498 if (rec.assocstatus != HFA384x_ASSOCSTATUS_AUTHFAIL)
1499 netdev_warn(wlandev->netdev,
1500 "assocstatus info frame received for non-authenticated station.\n");
1502 hw->authlist.assoc[i] =
1503 (rec.assocstatus == HFA384x_ASSOCSTATUS_STAASSOC ||
1504 rec.assocstatus == HFA384x_ASSOCSTATUS_REASSOC);
1506 if (rec.assocstatus == HFA384x_ASSOCSTATUS_AUTHFAIL)
1507 netdev_warn(wlandev->netdev,
1508 "authfail assocstatus info frame received for authenticated station.\n");
1513 * prism2sta_inf_authreq
1515 * Handles the receipt of an Authentication Request info frame. Should
1516 * be present in APs only.
1519 * wlandev wlan device structure
1520 * inf ptr to info frame (contents in hfa384x order)
1531 static void prism2sta_inf_authreq(struct wlandevice *wlandev,
1532 hfa384x_InfFrame_t *inf)
1534 hfa384x_t *hw = wlandev->priv;
1535 struct sk_buff *skb;
1537 skb = dev_alloc_skb(sizeof(*inf));
1539 skb_put(skb, sizeof(*inf));
1540 memcpy(skb->data, inf, sizeof(*inf));
1541 skb_queue_tail(&hw->authq, skb);
1542 schedule_work(&hw->link_bh);
1546 static void prism2sta_inf_authreq_defer(struct wlandevice *wlandev,
1547 hfa384x_InfFrame_t *inf)
1549 hfa384x_t *hw = wlandev->priv;
1550 struct hfa384x_authenticateStation_data rec;
1552 int i, added, result, cnt;
1556 * Build the AuthenticateStation record. Initialize it for denying
1560 ether_addr_copy(rec.address, inf->info.authreq.sta_addr);
1561 rec.status = P80211ENUM_status_unspec_failure;
1564 * Authenticate based on the access mode.
1567 switch (hw->accessmode) {
1568 case WLAN_ACCESS_NONE:
1571 * Deny all new authentications. However, if a station
1572 * is ALREADY authenticated, then accept it.
1575 for (i = 0; i < hw->authlist.cnt; i++)
1576 if (ether_addr_equal(rec.address,
1577 hw->authlist.addr[i])) {
1578 rec.status = P80211ENUM_status_successful;
1584 case WLAN_ACCESS_ALL:
1587 * Allow all authentications.
1590 rec.status = P80211ENUM_status_successful;
1593 case WLAN_ACCESS_ALLOW:
1596 * Only allow the authentication if the MAC address
1597 * is in the list of allowed addresses.
1599 * Since this is the interrupt handler, we may be here
1600 * while the access list is in the middle of being
1601 * updated. Choose the list which is currently okay.
1602 * See "prism2mib_priv_accessallow()" for details.
1605 if (hw->allow.modify == 0) {
1606 cnt = hw->allow.cnt;
1607 addr = hw->allow.addr[0];
1609 cnt = hw->allow.cnt1;
1610 addr = hw->allow.addr1[0];
1613 for (i = 0; i < cnt; i++, addr += ETH_ALEN)
1614 if (ether_addr_equal(rec.address, addr)) {
1615 rec.status = P80211ENUM_status_successful;
1621 case WLAN_ACCESS_DENY:
1624 * Allow the authentication UNLESS the MAC address is
1625 * in the list of denied addresses.
1627 * Since this is the interrupt handler, we may be here
1628 * while the access list is in the middle of being
1629 * updated. Choose the list which is currently okay.
1630 * See "prism2mib_priv_accessdeny()" for details.
1633 if (hw->deny.modify == 0) {
1635 addr = hw->deny.addr[0];
1637 cnt = hw->deny.cnt1;
1638 addr = hw->deny.addr1[0];
1641 rec.status = P80211ENUM_status_successful;
1643 for (i = 0; i < cnt; i++, addr += ETH_ALEN)
1644 if (ether_addr_equal(rec.address, addr)) {
1645 rec.status = P80211ENUM_status_unspec_failure;
1653 * If the authentication is okay, then add the MAC address to the
1654 * list of authenticated stations. Don't add the address if it
1655 * is already in the list. (802.11b does not seem to disallow
1656 * a station from issuing an authentication request when the
1657 * station is already authenticated. Does this sort of thing
1658 * ever happen? We might as well do the check just in case.)
1663 if (rec.status == P80211ENUM_status_successful) {
1664 for (i = 0; i < hw->authlist.cnt; i++)
1665 if (ether_addr_equal(rec.address,
1666 hw->authlist.addr[i]))
1669 if (i >= hw->authlist.cnt) {
1670 if (hw->authlist.cnt >= WLAN_AUTH_MAX) {
1671 rec.status = P80211ENUM_status_ap_full;
1674 hw->authlist.addr[hw->authlist.cnt],
1683 * Send back the results of the authentication. If this doesn't work,
1684 * then make sure to remove the address from the authenticated list if
1688 rec.status = cpu_to_le16(rec.status);
1689 rec.algorithm = inf->info.authreq.algorithm;
1691 result = hfa384x_drvr_setconfig(hw, HFA384x_RID_AUTHENTICATESTA,
1696 netdev_err(wlandev->netdev,
1697 "setconfig(authenticatestation) failed, result=%d\n",
1703 * prism2sta_inf_psusercnt
1705 * Handles the receipt of a PowerSaveUserCount info frame. Should
1706 * be present in APs only.
1709 * wlandev wlan device structure
1710 * inf ptr to info frame (contents in hfa384x order)
1720 static void prism2sta_inf_psusercnt(struct wlandevice *wlandev,
1721 hfa384x_InfFrame_t *inf)
1723 hfa384x_t *hw = wlandev->priv;
1725 hw->psusercount = le16_to_cpu(inf->info.psusercnt.usercnt);
1731 * Handles the Info event.
1734 * wlandev wlan device structure
1735 * inf ptr to a generic info frame
1745 void prism2sta_ev_info(struct wlandevice *wlandev, hfa384x_InfFrame_t *inf)
1747 inf->infotype = le16_to_cpu(inf->infotype);
1749 switch (inf->infotype) {
1750 case HFA384x_IT_HANDOVERADDR:
1751 prism2sta_inf_handover(wlandev, inf);
1753 case HFA384x_IT_COMMTALLIES:
1754 prism2sta_inf_tallies(wlandev, inf);
1756 case HFA384x_IT_HOSTSCANRESULTS:
1757 prism2sta_inf_hostscanresults(wlandev, inf);
1759 case HFA384x_IT_SCANRESULTS:
1760 prism2sta_inf_scanresults(wlandev, inf);
1762 case HFA384x_IT_CHINFORESULTS:
1763 prism2sta_inf_chinforesults(wlandev, inf);
1765 case HFA384x_IT_LINKSTATUS:
1766 prism2sta_inf_linkstatus(wlandev, inf);
1768 case HFA384x_IT_ASSOCSTATUS:
1769 prism2sta_inf_assocstatus(wlandev, inf);
1771 case HFA384x_IT_AUTHREQ:
1772 prism2sta_inf_authreq(wlandev, inf);
1774 case HFA384x_IT_PSUSERCNT:
1775 prism2sta_inf_psusercnt(wlandev, inf);
1777 case HFA384x_IT_KEYIDCHANGED:
1778 netdev_warn(wlandev->netdev, "Unhandled IT_KEYIDCHANGED\n");
1780 case HFA384x_IT_ASSOCREQ:
1781 netdev_warn(wlandev->netdev, "Unhandled IT_ASSOCREQ\n");
1783 case HFA384x_IT_MICFAILURE:
1784 netdev_warn(wlandev->netdev, "Unhandled IT_MICFAILURE\n");
1787 netdev_warn(wlandev->netdev,
1788 "Unknown info type=0x%02x\n", inf->infotype);
1794 * prism2sta_ev_txexc
1796 * Handles the TxExc event. A Transmit Exception event indicates
1797 * that the MAC's TX process was unsuccessful - so the packet did
1798 * not get transmitted.
1801 * wlandev wlan device structure
1802 * status tx frame status word
1812 void prism2sta_ev_txexc(struct wlandevice *wlandev, u16 status)
1814 pr_debug("TxExc status=0x%x.\n", status);
1820 * Handles the Tx event.
1823 * wlandev wlan device structure
1824 * status tx frame status word
1833 void prism2sta_ev_tx(struct wlandevice *wlandev, u16 status)
1835 pr_debug("Tx Complete, status=0x%04x\n", status);
1836 /* update linux network stats */
1837 wlandev->netdev->stats.tx_packets++;
1841 * prism2sta_ev_alloc
1843 * Handles the Alloc event.
1846 * wlandev wlan device structure
1856 void prism2sta_ev_alloc(struct wlandevice *wlandev)
1858 netif_wake_queue(wlandev->netdev);
1864 * Called at module init time. This creates the struct wlandevice structure
1865 * and initializes it with relevant bits.
1871 * the created struct wlandevice structure.
1874 * also allocates the priv/hw structures.
1880 static struct wlandevice *create_wlan(void)
1882 struct wlandevice *wlandev = NULL;
1883 hfa384x_t *hw = NULL;
1885 /* Alloc our structures */
1886 wlandev = kzalloc(sizeof(struct wlandevice), GFP_KERNEL);
1887 hw = kzalloc(sizeof(hfa384x_t), GFP_KERNEL);
1889 if (!wlandev || !hw) {
1895 /* Initialize the network device object. */
1896 wlandev->nsdname = dev_info;
1897 wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING;
1899 wlandev->open = prism2sta_open;
1900 wlandev->close = prism2sta_close;
1901 wlandev->reset = prism2sta_reset;
1902 wlandev->txframe = prism2sta_txframe;
1903 wlandev->mlmerequest = prism2sta_mlmerequest;
1904 wlandev->set_multicast_list = prism2sta_setmulticast;
1905 wlandev->tx_timeout = hfa384x_tx_timeout;
1907 wlandev->nsdcaps = P80211_NSDCAP_HWFRAGMENT | P80211_NSDCAP_AUTOJOIN;
1909 /* Initialize the device private data structure. */
1910 hw->dot11_desired_bss_type = 1;
1915 void prism2sta_commsqual_defer(struct work_struct *data)
1917 hfa384x_t *hw = container_of(data, struct hfa384x, commsqual_bh);
1918 struct wlandevice *wlandev = hw->wlandev;
1919 struct hfa384x_bytestr32 ssid;
1920 struct p80211msg_dot11req_mibget msg;
1921 struct p80211item_uint32 *mibitem = (struct p80211item_uint32 *)
1922 &msg.mibattribute.data;
1925 if (hw->wlandev->hwremoved)
1928 /* we don't care if we're in AP mode */
1929 if ((wlandev->macmode == WLAN_MACMODE_NONE) ||
1930 (wlandev->macmode == WLAN_MACMODE_ESS_AP)) {
1934 /* It only makes sense to poll these in non-IBSS */
1935 if (wlandev->macmode != WLAN_MACMODE_IBSS_STA) {
1936 result = hfa384x_drvr_getconfig(
1937 hw, HFA384x_RID_DBMCOMMSQUALITY,
1938 &hw->qual, HFA384x_RID_DBMCOMMSQUALITY_LEN);
1941 netdev_err(wlandev->netdev, "error fetching commsqual\n");
1945 pr_debug("commsqual %d %d %d\n",
1946 le16_to_cpu(hw->qual.CQ_currBSS),
1947 le16_to_cpu(hw->qual.ASL_currBSS),
1948 le16_to_cpu(hw->qual.ANL_currFC));
1951 /* Get the signal rate */
1952 msg.msgcode = DIDmsg_dot11req_mibget;
1953 mibitem->did = DIDmib_p2_p2MAC_p2CurrentTxRate;
1954 result = p80211req_dorequest(wlandev, (u8 *)&msg);
1957 pr_debug("get signal rate failed, result = %d\n",
1962 switch (mibitem->data) {
1963 case HFA384x_RATEBIT_1:
1966 case HFA384x_RATEBIT_2:
1969 case HFA384x_RATEBIT_5dot5:
1972 case HFA384x_RATEBIT_11:
1976 pr_debug("Bad ratebit (%d)\n", mibitem->data);
1979 /* Lastly, we need to make sure the BSSID didn't change on us */
1980 result = hfa384x_drvr_getconfig(hw,
1981 HFA384x_RID_CURRENTBSSID,
1982 wlandev->bssid, WLAN_BSSID_LEN);
1984 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1985 HFA384x_RID_CURRENTBSSID, result);
1989 result = hfa384x_drvr_getconfig(hw,
1990 HFA384x_RID_CURRENTSSID,
1991 &ssid, sizeof(ssid));
1993 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1994 HFA384x_RID_CURRENTSSID, result);
1997 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *)&ssid,
1998 (struct p80211pstrd *)&wlandev->ssid);
2000 /* Reschedule timer */
2001 mod_timer(&hw->commsqual_timer, jiffies + HZ);
2004 void prism2sta_commsqual_timer(unsigned long data)
2006 hfa384x_t *hw = (hfa384x_t *)data;
2008 schedule_work(&hw->commsqual_bh);