1 // SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
2 /* src/prism2/driver/prism2sta.c
4 * Implements the station functionality for prism2
6 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
7 * --------------------------------------------------------------------
11 * The contents of this file are subject to the Mozilla Public
12 * License Version 1.1 (the "License"); you may not use this file
13 * except in compliance with the License. You may obtain a copy of
14 * the License at http://www.mozilla.org/MPL/
16 * Software distributed under the License is distributed on an "AS
17 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
18 * implied. See the License for the specific language governing
19 * rights and limitations under the License.
21 * Alternatively, the contents of this file may be used under the
22 * terms of the GNU Public License version 2 (the "GPL"), in which
23 * case the provisions of the GPL are applicable instead of the
24 * above. If you wish to allow the use of your version of this file
25 * only under the terms of the GPL and not to allow others to use
26 * your version of this file under the MPL, indicate your decision
27 * by deleting the provisions above and replace them with the notice
28 * and other provisions required by the GPL. If you do not delete
29 * the provisions above, a recipient may use your version of this
30 * file under either the MPL or the GPL.
32 * --------------------------------------------------------------------
34 * Inquiries regarding the linux-wlan Open Source project can be
37 * AbsoluteValue Systems Inc.
39 * http://www.linux-wlan.com
41 * --------------------------------------------------------------------
43 * Portions of the development of this software were funded by
44 * Intersil Corporation as part of PRISM(R) chipset product development.
46 * --------------------------------------------------------------------
48 * This file implements the module and linux pcmcia routines for the
51 * --------------------------------------------------------------------
54 #include <linux/module.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/etherdevice.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 static char *dev_info = "prism2_usb";
85 static struct wlandevice *create_wlan(void);
87 int prism2_reset_holdtime = 30; /* Reset hold time in ms */
88 int prism2_reset_settletime = 100; /* Reset settle time in ms */
90 static int prism2_doreset; /* Do a reset at init? */
92 module_param(prism2_doreset, int, 0644);
93 MODULE_PARM_DESC(prism2_doreset, "Issue a reset on initialization");
95 module_param(prism2_reset_holdtime, int, 0644);
96 MODULE_PARM_DESC(prism2_reset_holdtime, "reset hold time in ms");
97 module_param(prism2_reset_settletime, int, 0644);
98 MODULE_PARM_DESC(prism2_reset_settletime, "reset settle time in ms");
100 MODULE_LICENSE("Dual MPL/GPL");
102 static int prism2sta_open(struct wlandevice *wlandev);
103 static int prism2sta_close(struct wlandevice *wlandev);
104 static void prism2sta_reset(struct wlandevice *wlandev);
105 static int prism2sta_txframe(struct wlandevice *wlandev, struct sk_buff *skb,
106 union p80211_hdr *p80211_hdr,
107 struct p80211_metawep *p80211_wep);
108 static int prism2sta_mlmerequest(struct wlandevice *wlandev,
109 struct p80211msg *msg);
110 static int prism2sta_getcardinfo(struct wlandevice *wlandev);
111 static int prism2sta_globalsetup(struct wlandevice *wlandev);
112 static int prism2sta_setmulticast(struct wlandevice *wlandev,
113 struct net_device *dev);
115 static void prism2sta_inf_handover(struct wlandevice *wlandev,
116 struct hfa384x_inf_frame *inf);
117 static void prism2sta_inf_tallies(struct wlandevice *wlandev,
118 struct hfa384x_inf_frame *inf);
119 static void prism2sta_inf_hostscanresults(struct wlandevice *wlandev,
120 struct hfa384x_inf_frame *inf);
121 static void prism2sta_inf_scanresults(struct wlandevice *wlandev,
122 struct hfa384x_inf_frame *inf);
123 static void prism2sta_inf_chinforesults(struct wlandevice *wlandev,
124 struct hfa384x_inf_frame *inf);
125 static void prism2sta_inf_linkstatus(struct wlandevice *wlandev,
126 struct hfa384x_inf_frame *inf);
127 static void prism2sta_inf_assocstatus(struct wlandevice *wlandev,
128 struct hfa384x_inf_frame *inf);
129 static void prism2sta_inf_authreq(struct wlandevice *wlandev,
130 struct hfa384x_inf_frame *inf);
131 static void prism2sta_inf_authreq_defer(struct wlandevice *wlandev,
132 struct hfa384x_inf_frame *inf);
133 static void prism2sta_inf_psusercnt(struct wlandevice *wlandev,
134 struct hfa384x_inf_frame *inf);
139 * WLAN device open method. Called from p80211netdev when kernel
140 * device open (start) method is called in response to the
141 * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
145 * wlandev wlan device structure
149 * >0 f/w reported error
150 * <0 driver reported error
157 static int prism2sta_open(struct wlandevice *wlandev)
159 /* We don't currently have to do anything else.
160 * The setup of the MAC should be subsequently completed via
162 * Higher layers know we're ready from dev->start==1 and
163 * dev->tbusy==0. Our rx path knows to pass up received/
164 * frames because of dev->flags&IFF_UP is true.
173 * WLAN device close method. Called from p80211netdev when kernel
174 * device close method is called in response to the
175 * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
179 * wlandev wlan device structure
183 * >0 f/w reported error
184 * <0 driver reported error
191 static int prism2sta_close(struct wlandevice *wlandev)
193 /* We don't currently have to do anything else.
194 * Higher layers know we're not ready from dev->start==0 and
195 * dev->tbusy==1. Our rx path knows to not pass up received
196 * frames because of dev->flags&IFF_UP is false.
205 * Currently not implemented.
208 * wlandev wlan device structure
219 static void prism2sta_reset(struct wlandevice *wlandev)
226 * Takes a frame from p80211 and queues it for transmission.
229 * wlandev wlan device structure
230 * pb packet buffer struct. Contains an 802.11
232 * p80211_hdr points to the 802.11 header for the packet.
234 * 0 Success and more buffs available
235 * 1 Success but no more buffs
236 * 2 Allocation failure
237 * 4 Buffer full or queue busy
244 static int prism2sta_txframe(struct wlandevice *wlandev, struct sk_buff *skb,
245 union p80211_hdr *p80211_hdr,
246 struct p80211_metawep *p80211_wep)
248 struct hfa384x *hw = wlandev->priv;
250 /* If necessary, set the 802.11 WEP bit */
251 if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) ==
252 HOSTWEP_PRIVACYINVOKED) {
253 p80211_hdr->a3.fc |= cpu_to_le16(WLAN_SET_FC_ISWEP(1));
256 return hfa384x_drvr_txframe(hw, skb, p80211_hdr, p80211_wep);
260 * prism2sta_mlmerequest
262 * wlan command message handler. All we do here is pass the message
263 * over to the prism2sta_mgmt_handler.
266 * wlandev wlan device structure
267 * msg wlan command message
270 * <0 successful acceptance of message, but we're
271 * waiting for an async process to finish before
272 * we're done with the msg. When the asynch
273 * process is done, we'll call the p80211
274 * function p80211req_confirm() .
275 * >0 An error occurred while we were handling
283 static int prism2sta_mlmerequest(struct wlandevice *wlandev,
284 struct p80211msg *msg)
286 struct hfa384x *hw = wlandev->priv;
290 switch (msg->msgcode) {
291 case DIDmsg_dot11req_mibget:
292 pr_debug("Received mibget request\n");
293 result = prism2mgmt_mibset_mibget(wlandev, msg);
295 case DIDmsg_dot11req_mibset:
296 pr_debug("Received mibset request\n");
297 result = prism2mgmt_mibset_mibget(wlandev, msg);
299 case DIDmsg_dot11req_scan:
300 pr_debug("Received scan request\n");
301 result = prism2mgmt_scan(wlandev, msg);
303 case DIDmsg_dot11req_scan_results:
304 pr_debug("Received scan_results request\n");
305 result = prism2mgmt_scan_results(wlandev, msg);
307 case DIDmsg_dot11req_start:
308 pr_debug("Received mlme start request\n");
309 result = prism2mgmt_start(wlandev, msg);
312 * Prism2 specific messages
314 case DIDmsg_p2req_readpda:
315 pr_debug("Received mlme readpda request\n");
316 result = prism2mgmt_readpda(wlandev, msg);
318 case DIDmsg_p2req_ramdl_state:
319 pr_debug("Received mlme ramdl_state request\n");
320 result = prism2mgmt_ramdl_state(wlandev, msg);
322 case DIDmsg_p2req_ramdl_write:
323 pr_debug("Received mlme ramdl_write request\n");
324 result = prism2mgmt_ramdl_write(wlandev, msg);
326 case DIDmsg_p2req_flashdl_state:
327 pr_debug("Received mlme flashdl_state request\n");
328 result = prism2mgmt_flashdl_state(wlandev, msg);
330 case DIDmsg_p2req_flashdl_write:
331 pr_debug("Received mlme flashdl_write request\n");
332 result = prism2mgmt_flashdl_write(wlandev, msg);
335 * Linux specific messages
337 case DIDmsg_lnxreq_hostwep:
338 break; /* ignore me. */
339 case DIDmsg_lnxreq_ifstate:
341 struct p80211msg_lnxreq_ifstate *ifstatemsg;
343 pr_debug("Received mlme ifstate request\n");
344 ifstatemsg = (struct p80211msg_lnxreq_ifstate *)msg;
346 prism2sta_ifstate(wlandev,
347 ifstatemsg->ifstate.data);
348 ifstatemsg->resultcode.status =
349 P80211ENUM_msgitem_status_data_ok;
350 ifstatemsg->resultcode.data = result;
354 case DIDmsg_lnxreq_wlansniff:
355 pr_debug("Received mlme wlansniff request\n");
356 result = prism2mgmt_wlansniff(wlandev, msg);
358 case DIDmsg_lnxreq_autojoin:
359 pr_debug("Received mlme autojoin request\n");
360 result = prism2mgmt_autojoin(wlandev, msg);
362 case DIDmsg_lnxreq_commsquality:{
363 struct p80211msg_lnxreq_commsquality *qualmsg;
365 pr_debug("Received commsquality request\n");
367 qualmsg = (struct p80211msg_lnxreq_commsquality *)msg;
369 qualmsg->link.status =
370 P80211ENUM_msgitem_status_data_ok;
371 qualmsg->level.status =
372 P80211ENUM_msgitem_status_data_ok;
373 qualmsg->noise.status =
374 P80211ENUM_msgitem_status_data_ok;
376 qualmsg->link.data = le16_to_cpu(hw->qual.cq_curr_bss);
377 qualmsg->level.data =
378 le16_to_cpu(hw->qual.asl_curr_bss);
379 qualmsg->noise.data = le16_to_cpu(hw->qual.anl_curr_fc);
380 qualmsg->txrate.data = hw->txrate;
385 netdev_warn(wlandev->netdev,
386 "Unknown mgmt request message 0x%08x",
397 * Interface state. This is the primary WLAN interface enable/disable
398 * handler. Following the driver/load/deviceprobe sequence, this
399 * function must be called with a state of "enable" before any other
400 * commands will be accepted.
403 * wlandev wlan device structure
404 * msgp ptr to msg buffer
407 * A p80211 message resultcode value.
412 * process thread (usually)
415 u32 prism2sta_ifstate(struct wlandevice *wlandev, u32 ifstate)
417 struct hfa384x *hw = wlandev->priv;
420 result = P80211ENUM_resultcode_implementation_failure;
422 pr_debug("Current MSD state(%d), requesting(%d)\n",
423 wlandev->msdstate, ifstate);
425 case P80211ENUM_ifstate_fwload:
426 switch (wlandev->msdstate) {
427 case WLAN_MSD_HWPRESENT:
428 wlandev->msdstate = WLAN_MSD_FWLOAD_PENDING;
430 * Initialize the device+driver sufficiently
431 * for firmware loading.
433 result = hfa384x_drvr_start(hw);
435 netdev_err(wlandev->netdev,
436 "hfa384x_drvr_start() failed,result=%d\n",
439 P80211ENUM_resultcode_implementation_failure;
440 wlandev->msdstate = WLAN_MSD_HWPRESENT;
443 wlandev->msdstate = WLAN_MSD_FWLOAD;
444 result = P80211ENUM_resultcode_success;
446 case WLAN_MSD_FWLOAD:
447 hfa384x_cmd_initialize(hw);
448 result = P80211ENUM_resultcode_success;
450 case WLAN_MSD_RUNNING:
451 netdev_warn(wlandev->netdev,
452 "Cannot enter fwload state from enable state, you must disable first.\n");
453 result = P80211ENUM_resultcode_invalid_parameters;
455 case WLAN_MSD_HWFAIL:
457 /* probe() had a problem or the msdstate contains
458 * an unrecognized value, there's nothing we can do.
460 result = P80211ENUM_resultcode_implementation_failure;
464 case P80211ENUM_ifstate_enable:
465 switch (wlandev->msdstate) {
466 case WLAN_MSD_HWPRESENT:
467 case WLAN_MSD_FWLOAD:
468 wlandev->msdstate = WLAN_MSD_RUNNING_PENDING;
469 /* Initialize the device+driver for full
470 * operation. Note that this might me an FWLOAD to
471 * to RUNNING transition so we must not do a chip
472 * or board level reset. Note that on failure,
473 * the MSD state is set to HWPRESENT because we
474 * can't make any assumptions about the state
475 * of the hardware or a previous firmware load.
477 result = hfa384x_drvr_start(hw);
479 netdev_err(wlandev->netdev,
480 "hfa384x_drvr_start() failed,result=%d\n",
483 P80211ENUM_resultcode_implementation_failure;
484 wlandev->msdstate = WLAN_MSD_HWPRESENT;
488 result = prism2sta_getcardinfo(wlandev);
490 netdev_err(wlandev->netdev,
491 "prism2sta_getcardinfo() failed,result=%d\n",
494 P80211ENUM_resultcode_implementation_failure;
495 hfa384x_drvr_stop(hw);
496 wlandev->msdstate = WLAN_MSD_HWPRESENT;
499 result = prism2sta_globalsetup(wlandev);
501 netdev_err(wlandev->netdev,
502 "prism2sta_globalsetup() failed,result=%d\n",
505 P80211ENUM_resultcode_implementation_failure;
506 hfa384x_drvr_stop(hw);
507 wlandev->msdstate = WLAN_MSD_HWPRESENT;
510 wlandev->msdstate = WLAN_MSD_RUNNING;
512 hw->join_retries = 60;
513 result = P80211ENUM_resultcode_success;
515 case WLAN_MSD_RUNNING:
516 /* Do nothing, we're already in this state. */
517 result = P80211ENUM_resultcode_success;
519 case WLAN_MSD_HWFAIL:
521 /* probe() had a problem or the msdstate contains
522 * an unrecognized value, there's nothing we can do.
524 result = P80211ENUM_resultcode_implementation_failure;
528 case P80211ENUM_ifstate_disable:
529 switch (wlandev->msdstate) {
530 case WLAN_MSD_HWPRESENT:
531 /* Do nothing, we're already in this state. */
532 result = P80211ENUM_resultcode_success;
534 case WLAN_MSD_FWLOAD:
535 case WLAN_MSD_RUNNING:
536 wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING;
538 * TODO: Shut down the MAC completely. Here a chip
539 * or board level reset is probably called for.
540 * After a "disable" _all_ results are lost, even
541 * those from a fwload.
543 if (!wlandev->hwremoved)
544 netif_carrier_off(wlandev->netdev);
546 hfa384x_drvr_stop(hw);
548 wlandev->macmode = WLAN_MACMODE_NONE;
549 wlandev->msdstate = WLAN_MSD_HWPRESENT;
550 result = P80211ENUM_resultcode_success;
552 case WLAN_MSD_HWFAIL:
554 /* probe() had a problem or the msdstate contains
555 * an unrecognized value, there's nothing we can do.
557 result = P80211ENUM_resultcode_implementation_failure;
562 result = P80211ENUM_resultcode_invalid_parameters;
570 * prism2sta_getcardinfo
572 * Collect the NICID, firmware version and any other identifiers
573 * we'd like to have in host-side data structures.
576 * wlandev wlan device structure
580 * >0 f/w reported error
581 * <0 driver reported error
588 static int prism2sta_getcardinfo(struct wlandevice *wlandev)
591 struct hfa384x *hw = wlandev->priv;
593 u8 snum[HFA384x_RID_NICSERIALNUMBER_LEN];
595 /* Collect version and compatibility info */
596 /* Some are critical, some are not */
598 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICIDENTITY,
600 sizeof(struct hfa384x_compident));
602 netdev_err(wlandev->netdev, "Failed to retrieve NICIDENTITY\n");
606 /* get all the nic id fields in host byte order */
607 le16_to_cpus(&hw->ident_nic.id);
608 le16_to_cpus(&hw->ident_nic.variant);
609 le16_to_cpus(&hw->ident_nic.major);
610 le16_to_cpus(&hw->ident_nic.minor);
612 netdev_info(wlandev->netdev, "ident: nic h/w: id=0x%02x %d.%d.%d\n",
613 hw->ident_nic.id, hw->ident_nic.major,
614 hw->ident_nic.minor, hw->ident_nic.variant);
616 /* Primary f/w identity */
617 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRIIDENTITY,
619 sizeof(struct hfa384x_compident));
621 netdev_err(wlandev->netdev, "Failed to retrieve PRIIDENTITY\n");
625 /* get all the private fw id fields in host byte order */
626 le16_to_cpus(&hw->ident_pri_fw.id);
627 le16_to_cpus(&hw->ident_pri_fw.variant);
628 le16_to_cpus(&hw->ident_pri_fw.major);
629 le16_to_cpus(&hw->ident_pri_fw.minor);
631 netdev_info(wlandev->netdev, "ident: pri f/w: id=0x%02x %d.%d.%d\n",
632 hw->ident_pri_fw.id, hw->ident_pri_fw.major,
633 hw->ident_pri_fw.minor, hw->ident_pri_fw.variant);
635 /* Station (Secondary?) f/w identity */
636 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STAIDENTITY,
638 sizeof(struct hfa384x_compident));
640 netdev_err(wlandev->netdev, "Failed to retrieve STAIDENTITY\n");
644 if (hw->ident_nic.id < 0x8000) {
645 netdev_err(wlandev->netdev,
646 "FATAL: Card is not an Intersil Prism2/2.5/3\n");
651 /* get all the station fw id fields in host byte order */
652 le16_to_cpus(&hw->ident_sta_fw.id);
653 le16_to_cpus(&hw->ident_sta_fw.variant);
654 le16_to_cpus(&hw->ident_sta_fw.major);
655 le16_to_cpus(&hw->ident_sta_fw.minor);
657 /* strip out the 'special' variant bits */
658 hw->mm_mods = hw->ident_sta_fw.variant & GENMASK(15, 14);
659 hw->ident_sta_fw.variant &= ~((u16)GENMASK(15, 14));
661 if (hw->ident_sta_fw.id == 0x1f) {
662 netdev_info(wlandev->netdev,
663 "ident: sta f/w: id=0x%02x %d.%d.%d\n",
664 hw->ident_sta_fw.id, hw->ident_sta_fw.major,
665 hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
667 netdev_info(wlandev->netdev,
668 "ident: ap f/w: id=0x%02x %d.%d.%d\n",
669 hw->ident_sta_fw.id, hw->ident_sta_fw.major,
670 hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
671 netdev_err(wlandev->netdev, "Unsupported Tertiary AP firmware loaded!\n");
675 /* Compatibility range, Modem supplier */
676 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_MFISUPRANGE,
678 sizeof(struct hfa384x_caplevel));
680 netdev_err(wlandev->netdev, "Failed to retrieve MFISUPRANGE\n");
684 /* get all the Compatibility range, modem interface supplier
685 * fields in byte order
687 le16_to_cpus(&hw->cap_sup_mfi.role);
688 le16_to_cpus(&hw->cap_sup_mfi.id);
689 le16_to_cpus(&hw->cap_sup_mfi.variant);
690 le16_to_cpus(&hw->cap_sup_mfi.bottom);
691 le16_to_cpus(&hw->cap_sup_mfi.top);
693 netdev_info(wlandev->netdev,
694 "MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
695 hw->cap_sup_mfi.role, hw->cap_sup_mfi.id,
696 hw->cap_sup_mfi.variant, hw->cap_sup_mfi.bottom,
697 hw->cap_sup_mfi.top);
699 /* Compatibility range, Controller supplier */
700 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CFISUPRANGE,
702 sizeof(struct hfa384x_caplevel));
704 netdev_err(wlandev->netdev, "Failed to retrieve CFISUPRANGE\n");
708 /* get all the Compatibility range, controller interface supplier
709 * fields in byte order
711 le16_to_cpus(&hw->cap_sup_cfi.role);
712 le16_to_cpus(&hw->cap_sup_cfi.id);
713 le16_to_cpus(&hw->cap_sup_cfi.variant);
714 le16_to_cpus(&hw->cap_sup_cfi.bottom);
715 le16_to_cpus(&hw->cap_sup_cfi.top);
717 netdev_info(wlandev->netdev,
718 "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
719 hw->cap_sup_cfi.role, hw->cap_sup_cfi.id,
720 hw->cap_sup_cfi.variant, hw->cap_sup_cfi.bottom,
721 hw->cap_sup_cfi.top);
723 /* Compatibility range, Primary f/w supplier */
724 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRISUPRANGE,
726 sizeof(struct hfa384x_caplevel));
728 netdev_err(wlandev->netdev, "Failed to retrieve PRISUPRANGE\n");
732 /* get all the Compatibility range, primary firmware supplier
733 * fields in byte order
735 le16_to_cpus(&hw->cap_sup_pri.role);
736 le16_to_cpus(&hw->cap_sup_pri.id);
737 le16_to_cpus(&hw->cap_sup_pri.variant);
738 le16_to_cpus(&hw->cap_sup_pri.bottom);
739 le16_to_cpus(&hw->cap_sup_pri.top);
741 netdev_info(wlandev->netdev,
742 "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
743 hw->cap_sup_pri.role, hw->cap_sup_pri.id,
744 hw->cap_sup_pri.variant, hw->cap_sup_pri.bottom,
745 hw->cap_sup_pri.top);
747 /* Compatibility range, Station f/w supplier */
748 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STASUPRANGE,
750 sizeof(struct hfa384x_caplevel));
752 netdev_err(wlandev->netdev, "Failed to retrieve STASUPRANGE\n");
756 /* get all the Compatibility range, station firmware supplier
757 * fields in byte order
759 le16_to_cpus(&hw->cap_sup_sta.role);
760 le16_to_cpus(&hw->cap_sup_sta.id);
761 le16_to_cpus(&hw->cap_sup_sta.variant);
762 le16_to_cpus(&hw->cap_sup_sta.bottom);
763 le16_to_cpus(&hw->cap_sup_sta.top);
765 if (hw->cap_sup_sta.id == 0x04) {
766 netdev_info(wlandev->netdev,
767 "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
768 hw->cap_sup_sta.role, hw->cap_sup_sta.id,
769 hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
770 hw->cap_sup_sta.top);
772 netdev_info(wlandev->netdev,
773 "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
774 hw->cap_sup_sta.role, hw->cap_sup_sta.id,
775 hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
776 hw->cap_sup_sta.top);
779 /* Compatibility range, primary f/w actor, CFI supplier */
780 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRI_CFIACTRANGES,
781 &hw->cap_act_pri_cfi,
782 sizeof(struct hfa384x_caplevel));
784 netdev_err(wlandev->netdev, "Failed to retrieve PRI_CFIACTRANGES\n");
788 /* get all the Compatibility range, primary f/w actor, CFI supplier
789 * fields in byte order
791 le16_to_cpus(&hw->cap_act_pri_cfi.role);
792 le16_to_cpus(&hw->cap_act_pri_cfi.id);
793 le16_to_cpus(&hw->cap_act_pri_cfi.variant);
794 le16_to_cpus(&hw->cap_act_pri_cfi.bottom);
795 le16_to_cpus(&hw->cap_act_pri_cfi.top);
797 netdev_info(wlandev->netdev,
798 "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
799 hw->cap_act_pri_cfi.role, hw->cap_act_pri_cfi.id,
800 hw->cap_act_pri_cfi.variant, hw->cap_act_pri_cfi.bottom,
801 hw->cap_act_pri_cfi.top);
803 /* Compatibility range, sta f/w actor, CFI supplier */
804 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_CFIACTRANGES,
805 &hw->cap_act_sta_cfi,
806 sizeof(struct hfa384x_caplevel));
808 netdev_err(wlandev->netdev, "Failed to retrieve STA_CFIACTRANGES\n");
812 /* get all the Compatibility range, station f/w actor, CFI supplier
813 * fields in byte order
815 le16_to_cpus(&hw->cap_act_sta_cfi.role);
816 le16_to_cpus(&hw->cap_act_sta_cfi.id);
817 le16_to_cpus(&hw->cap_act_sta_cfi.variant);
818 le16_to_cpus(&hw->cap_act_sta_cfi.bottom);
819 le16_to_cpus(&hw->cap_act_sta_cfi.top);
821 netdev_info(wlandev->netdev,
822 "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
823 hw->cap_act_sta_cfi.role, hw->cap_act_sta_cfi.id,
824 hw->cap_act_sta_cfi.variant, hw->cap_act_sta_cfi.bottom,
825 hw->cap_act_sta_cfi.top);
827 /* Compatibility range, sta f/w actor, MFI supplier */
828 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_MFIACTRANGES,
829 &hw->cap_act_sta_mfi,
830 sizeof(struct hfa384x_caplevel));
832 netdev_err(wlandev->netdev, "Failed to retrieve STA_MFIACTRANGES\n");
836 /* get all the Compatibility range, station f/w actor, MFI supplier
837 * fields in byte order
839 le16_to_cpus(&hw->cap_act_sta_mfi.role);
840 le16_to_cpus(&hw->cap_act_sta_mfi.id);
841 le16_to_cpus(&hw->cap_act_sta_mfi.variant);
842 le16_to_cpus(&hw->cap_act_sta_mfi.bottom);
843 le16_to_cpus(&hw->cap_act_sta_mfi.top);
845 netdev_info(wlandev->netdev,
846 "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
847 hw->cap_act_sta_mfi.role, hw->cap_act_sta_mfi.id,
848 hw->cap_act_sta_mfi.variant, hw->cap_act_sta_mfi.bottom,
849 hw->cap_act_sta_mfi.top);
852 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICSERIALNUMBER,
853 snum, HFA384x_RID_NICSERIALNUMBER_LEN);
855 netdev_info(wlandev->netdev, "Prism2 card SN: %*pEhp\n",
856 HFA384x_RID_NICSERIALNUMBER_LEN, snum);
858 netdev_err(wlandev->netdev, "Failed to retrieve Prism2 Card SN\n");
862 /* Collect the MAC address */
863 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFOWNMACADDR,
864 wlandev->netdev->dev_addr, ETH_ALEN);
866 netdev_err(wlandev->netdev, "Failed to retrieve mac address\n");
870 /* short preamble is always implemented */
871 wlandev->nsdcaps |= P80211_NSDCAP_SHORT_PREAMBLE;
873 /* find out if hardware wep is implemented */
874 hfa384x_drvr_getconfig16(hw, HFA384x_RID_PRIVACYOPTIMP, &temp);
876 wlandev->nsdcaps |= P80211_NSDCAP_HARDWAREWEP;
878 /* get the dBm Scaling constant */
879 hfa384x_drvr_getconfig16(hw, HFA384x_RID_CNFDBMADJUST, &temp);
880 hw->dbmadjust = temp;
882 /* Only enable scan by default on newer firmware */
883 if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
884 hw->ident_sta_fw.minor,
885 hw->ident_sta_fw.variant) <
886 HFA384x_FIRMWARE_VERSION(1, 5, 5)) {
887 wlandev->nsdcaps |= P80211_NSDCAP_NOSCAN;
890 /* TODO: Set any internally managed config items */
894 netdev_err(wlandev->netdev, "Failed, result=%d\n", result);
900 * prism2sta_globalsetup
902 * Set any global RIDs that we want to set at device activation.
905 * wlandev wlan device structure
909 * >0 f/w reported error
910 * <0 driver reported error
917 static int prism2sta_globalsetup(struct wlandevice *wlandev)
919 struct hfa384x *hw = wlandev->priv;
921 /* Set the maximum frame size */
922 return hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN,
926 static int prism2sta_setmulticast(struct wlandevice *wlandev,
927 struct net_device *dev)
930 struct hfa384x *hw = wlandev->priv;
934 /* If we're not ready, what's the point? */
935 if (hw->state != HFA384x_STATE_RUNNING)
938 if ((dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0)
939 promisc = P80211ENUM_truth_true;
941 promisc = P80211ENUM_truth_false;
944 hfa384x_drvr_setconfig16_async(hw, HFA384x_RID_PROMISCMODE,
951 * prism2sta_inf_handover
953 * Handles the receipt of a Handover info frame. Should only be present
957 * wlandev wlan device structure
958 * inf ptr to info frame (contents in hfa384x order)
968 static void prism2sta_inf_handover(struct wlandevice *wlandev,
969 struct hfa384x_inf_frame *inf)
971 pr_debug("received infoframe:HANDOVER (unhandled)\n");
975 * prism2sta_inf_tallies
977 * Handles the receipt of a CommTallies info frame.
980 * wlandev wlan device structure
981 * inf ptr to info frame (contents in hfa384x order)
991 static void prism2sta_inf_tallies(struct wlandevice *wlandev,
992 struct hfa384x_inf_frame *inf)
994 struct hfa384x *hw = wlandev->priv;
1002 * Determine if these are 16-bit or 32-bit tallies, based on the
1003 * record length of the info record.
1006 cnt = sizeof(struct hfa384x_comm_tallies_32) / sizeof(u32);
1007 if (inf->framelen > 22) {
1008 dst = (u32 *)&hw->tallies;
1009 src32 = (__le32 *)&inf->info.commtallies32;
1010 for (i = 0; i < cnt; i++, dst++, src32++)
1011 *dst += le32_to_cpu(*src32);
1013 dst = (u32 *)&hw->tallies;
1014 src16 = (__le16 *)&inf->info.commtallies16;
1015 for (i = 0; i < cnt; i++, dst++, src16++)
1016 *dst += le16_to_cpu(*src16);
1021 * prism2sta_inf_scanresults
1023 * Handles the receipt of a Scan Results info frame.
1026 * wlandev wlan device structure
1027 * inf ptr to info frame (contents in hfa384x order)
1037 static void prism2sta_inf_scanresults(struct wlandevice *wlandev,
1038 struct hfa384x_inf_frame *inf)
1040 struct hfa384x *hw = wlandev->priv;
1042 struct hfa384x_scan_result *sr = &inf->info.scanresult;
1044 struct hfa384x_join_request_data joinreq;
1047 /* Get the number of results, first in bytes, then in results */
1048 nbss = (inf->framelen * sizeof(u16)) -
1049 sizeof(inf->infotype) - sizeof(inf->info.scanresult.scanreason);
1050 nbss /= sizeof(struct hfa384x_scan_result_sub);
1053 pr_debug("rx scanresults, reason=%d, nbss=%d:\n",
1054 inf->info.scanresult.scanreason, nbss);
1055 for (i = 0; i < nbss; i++) {
1056 pr_debug("chid=%d anl=%d sl=%d bcnint=%d\n",
1059 sr->result[i].sl, sr->result[i].bcnint);
1060 pr_debug(" capinfo=0x%04x proberesp_rate=%d\n",
1061 sr->result[i].capinfo, sr->result[i].proberesp_rate);
1063 /* issue a join request */
1064 joinreq.channel = sr->result[0].chid;
1065 memcpy(joinreq.bssid, sr->result[0].bssid, WLAN_BSSID_LEN);
1066 result = hfa384x_drvr_setconfig(hw,
1067 HFA384x_RID_JOINREQUEST,
1068 &joinreq, HFA384x_RID_JOINREQUEST_LEN);
1070 netdev_err(wlandev->netdev, "setconfig(joinreq) failed, result=%d\n",
1076 * prism2sta_inf_hostscanresults
1078 * Handles the receipt of a Scan Results info frame.
1081 * wlandev wlan device structure
1082 * inf ptr to info frame (contents in hfa384x order)
1092 static void prism2sta_inf_hostscanresults(struct wlandevice *wlandev,
1093 struct hfa384x_inf_frame *inf)
1095 struct hfa384x *hw = wlandev->priv;
1098 nbss = (inf->framelen - 3) / 32;
1099 pr_debug("Received %d hostscan results\n", nbss);
1104 kfree(hw->scanresults);
1106 hw->scanresults = kmemdup(inf, sizeof(*inf), GFP_ATOMIC);
1111 /* Notify/wake the sleeping caller. */
1112 hw->scanflag = nbss;
1113 wake_up_interruptible(&hw->cmdq);
1117 * prism2sta_inf_chinforesults
1119 * Handles the receipt of a Channel Info Results info frame.
1122 * wlandev wlan device structure
1123 * inf ptr to info frame (contents in hfa384x order)
1133 static void prism2sta_inf_chinforesults(struct wlandevice *wlandev,
1134 struct hfa384x_inf_frame *inf)
1136 struct hfa384x *hw = wlandev->priv;
1139 hw->channel_info.results.scanchannels =
1140 inf->info.chinforesult.scanchannels;
1142 for (i = 0, n = 0; i < HFA384x_CHINFORESULT_MAX; i++) {
1143 struct hfa384x_ch_info_result_sub *result;
1144 struct hfa384x_ch_info_result_sub *chinforesult;
1147 if (!(hw->channel_info.results.scanchannels & (1 << i)))
1150 result = &inf->info.chinforesult.result[n];
1151 chan = result->chid - 1;
1153 if (chan < 0 || chan >= HFA384x_CHINFORESULT_MAX)
1156 chinforesult = &hw->channel_info.results.result[chan];
1157 chinforesult->chid = chan;
1158 chinforesult->anl = result->anl;
1159 chinforesult->pnl = result->pnl;
1160 chinforesult->active = result->active;
1162 pr_debug("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n",
1164 (chinforesult->active & HFA384x_CHINFORESULT_BSSACTIVE)
1165 ? "signal" : "noise",
1166 chinforesult->anl, chinforesult->pnl,
1167 (chinforesult->active & HFA384x_CHINFORESULT_PCFACTIVE)
1171 atomic_set(&hw->channel_info.done, 2);
1173 hw->channel_info.count = n;
1176 void prism2sta_processing_defer(struct work_struct *data)
1178 struct hfa384x *hw = container_of(data, struct hfa384x, link_bh);
1179 struct wlandevice *wlandev = hw->wlandev;
1180 struct hfa384x_bytestr32 ssid;
1183 /* First let's process the auth frames */
1185 struct sk_buff *skb;
1186 struct hfa384x_inf_frame *inf;
1188 while ((skb = skb_dequeue(&hw->authq))) {
1189 inf = (struct hfa384x_inf_frame *)skb->data;
1190 prism2sta_inf_authreq_defer(wlandev, inf);
1195 /* Now let's handle the linkstatus stuff */
1196 if (hw->link_status == hw->link_status_new)
1199 hw->link_status = hw->link_status_new;
1201 switch (hw->link_status) {
1202 case HFA384x_LINK_NOTCONNECTED:
1203 /* I'm currently assuming that this is the initial link
1204 * state. It should only be possible immediately
1205 * following an Enable command.
1207 * Block Transmits, Ignore receives of data frames
1209 netif_carrier_off(wlandev->netdev);
1211 netdev_info(wlandev->netdev, "linkstatus=NOTCONNECTED (unhandled)\n");
1214 case HFA384x_LINK_CONNECTED:
1215 /* This one indicates a successful scan/join/auth/assoc.
1216 * When we have the full MLME complement, this event will
1217 * signify successful completion of both mlme_authenticate
1218 * and mlme_associate. State management will get a little
1221 * Indicate authentication and/or association
1222 * Enable Transmits, Receives and pass up data frames
1225 netif_carrier_on(wlandev->netdev);
1227 /* If we are joining a specific AP, set our
1228 * state and reset retries
1230 if (hw->join_ap == 1)
1232 hw->join_retries = 60;
1234 /* Don't call this in monitor mode */
1235 if (wlandev->netdev->type == ARPHRD_ETHER) {
1238 netdev_info(wlandev->netdev, "linkstatus=CONNECTED\n");
1240 /* For non-usb devices, we can use the sync versions */
1241 /* Collect the BSSID, and set state to allow tx */
1243 result = hfa384x_drvr_getconfig(hw,
1244 HFA384x_RID_CURRENTBSSID,
1249 ("getconfig(0x%02x) failed, result = %d\n",
1250 HFA384x_RID_CURRENTBSSID, result);
1254 result = hfa384x_drvr_getconfig(hw,
1255 HFA384x_RID_CURRENTSSID,
1256 &ssid, sizeof(ssid));
1259 ("getconfig(0x%02x) failed, result = %d\n",
1260 HFA384x_RID_CURRENTSSID, result);
1263 prism2mgmt_bytestr2pstr(
1264 (struct hfa384x_bytestr *)&ssid,
1265 (struct p80211pstrd *)&wlandev->ssid);
1267 /* Collect the port status */
1268 result = hfa384x_drvr_getconfig16(hw,
1269 HFA384x_RID_PORTSTATUS,
1273 ("getconfig(0x%02x) failed, result = %d\n",
1274 HFA384x_RID_PORTSTATUS, result);
1278 (portstatus == HFA384x_PSTATUS_CONN_IBSS) ?
1279 WLAN_MACMODE_IBSS_STA : WLAN_MACMODE_ESS_STA;
1281 /* signal back up to cfg80211 layer */
1282 prism2_connect_result(wlandev, P80211ENUM_truth_false);
1284 /* Get the ball rolling on the comms quality stuff */
1285 prism2sta_commsqual_defer(&hw->commsqual_bh);
1289 case HFA384x_LINK_DISCONNECTED:
1290 /* This one indicates that our association is gone. We've
1291 * lost connection with the AP and/or been disassociated.
1292 * This indicates that the MAC has completely cleared it's
1293 * associated state. We * should send a deauth indication
1294 * (implying disassoc) up * to the MLME.
1296 * Indicate Deauthentication
1297 * Block Transmits, Ignore receives of data frames
1299 if (wlandev->netdev->type == ARPHRD_ETHER)
1300 netdev_info(wlandev->netdev,
1301 "linkstatus=DISCONNECTED (unhandled)\n");
1302 wlandev->macmode = WLAN_MACMODE_NONE;
1304 netif_carrier_off(wlandev->netdev);
1306 /* signal back up to cfg80211 layer */
1307 prism2_disconnected(wlandev);
1311 case HFA384x_LINK_AP_CHANGE:
1312 /* This one indicates that the MAC has decided to and
1313 * successfully completed a change to another AP. We
1314 * should probably implement a reassociation indication
1315 * in response to this one. I'm thinking that the
1316 * p80211 layer needs to be notified in case of
1317 * buffering/queueing issues. User mode also needs to be
1318 * notified so that any BSS dependent elements can be
1320 * associated state. We * should send a deauth indication
1321 * (implying disassoc) up * to the MLME.
1323 * Indicate Reassociation
1324 * Enable Transmits, Receives and pass up data frames
1326 netdev_info(wlandev->netdev, "linkstatus=AP_CHANGE\n");
1328 result = hfa384x_drvr_getconfig(hw,
1329 HFA384x_RID_CURRENTBSSID,
1330 wlandev->bssid, WLAN_BSSID_LEN);
1332 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1333 HFA384x_RID_CURRENTBSSID, result);
1337 result = hfa384x_drvr_getconfig(hw,
1338 HFA384x_RID_CURRENTSSID,
1339 &ssid, sizeof(ssid));
1341 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1342 HFA384x_RID_CURRENTSSID, result);
1345 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *)&ssid,
1346 (struct p80211pstrd *)&wlandev->ssid);
1348 hw->link_status = HFA384x_LINK_CONNECTED;
1349 netif_carrier_on(wlandev->netdev);
1351 /* signal back up to cfg80211 layer */
1352 prism2_roamed(wlandev);
1356 case HFA384x_LINK_AP_OUTOFRANGE:
1357 /* This one indicates that the MAC has decided that the
1358 * AP is out of range, but hasn't found a better candidate
1359 * so the MAC maintains its "associated" state in case
1360 * we get back in range. We should block transmits and
1361 * receives in this state. Do we need an indication here?
1362 * Probably not since a polling user-mode element would
1363 * get this status from from p2PortStatus(FD40). What about
1366 * Block Transmits, Ignore receives of data frames
1368 netdev_info(wlandev->netdev, "linkstatus=AP_OUTOFRANGE (unhandled)\n");
1370 netif_carrier_off(wlandev->netdev);
1374 case HFA384x_LINK_AP_INRANGE:
1375 /* This one indicates that the MAC has decided that the
1376 * AP is back in range. We continue working with our
1377 * existing association.
1379 * Enable Transmits, Receives and pass up data frames
1381 netdev_info(wlandev->netdev, "linkstatus=AP_INRANGE\n");
1383 hw->link_status = HFA384x_LINK_CONNECTED;
1384 netif_carrier_on(wlandev->netdev);
1388 case HFA384x_LINK_ASSOCFAIL:
1389 /* This one is actually a peer to CONNECTED. We've
1390 * requested a join for a given SSID and optionally BSSID.
1391 * We can use this one to indicate authentication and
1392 * association failures. The trick is going to be
1393 * 1) identifying the failure, and 2) state management.
1395 * Disable Transmits, Ignore receives of data frames
1397 if (hw->join_ap && --hw->join_retries > 0) {
1398 struct hfa384x_join_request_data joinreq;
1400 joinreq = hw->joinreq;
1401 /* Send the join request */
1402 hfa384x_drvr_setconfig(hw,
1403 HFA384x_RID_JOINREQUEST,
1405 HFA384x_RID_JOINREQUEST_LEN);
1406 netdev_info(wlandev->netdev,
1407 "linkstatus=ASSOCFAIL (re-submitting join)\n");
1409 netdev_info(wlandev->netdev, "linkstatus=ASSOCFAIL (unhandled)\n");
1412 netif_carrier_off(wlandev->netdev);
1414 /* signal back up to cfg80211 layer */
1415 prism2_connect_result(wlandev, P80211ENUM_truth_true);
1420 /* This is bad, IO port problems? */
1421 netdev_warn(wlandev->netdev,
1422 "unknown linkstatus=0x%02x\n", hw->link_status);
1426 wlandev->linkstatus = (hw->link_status == HFA384x_LINK_CONNECTED);
1430 * prism2sta_inf_linkstatus
1432 * Handles the receipt of a Link Status info frame.
1435 * wlandev wlan device structure
1436 * inf ptr to info frame (contents in hfa384x order)
1446 static void prism2sta_inf_linkstatus(struct wlandevice *wlandev,
1447 struct hfa384x_inf_frame *inf)
1449 struct hfa384x *hw = wlandev->priv;
1451 hw->link_status_new = le16_to_cpu(inf->info.linkstatus.linkstatus);
1453 schedule_work(&hw->link_bh);
1457 * prism2sta_inf_assocstatus
1459 * Handles the receipt of an Association Status info frame. Should
1460 * be present in APs only.
1463 * wlandev wlan device structure
1464 * inf ptr to info frame (contents in hfa384x order)
1474 static void prism2sta_inf_assocstatus(struct wlandevice *wlandev,
1475 struct hfa384x_inf_frame *inf)
1477 struct hfa384x *hw = wlandev->priv;
1478 struct hfa384x_assoc_status rec;
1481 memcpy(&rec, &inf->info.assocstatus, sizeof(rec));
1482 le16_to_cpus(&rec.assocstatus);
1483 le16_to_cpus(&rec.reason);
1486 * Find the address in the list of authenticated stations.
1487 * If it wasn't found, then this address has not been previously
1488 * authenticated and something weird has happened if this is
1489 * anything other than an "authentication failed" message.
1490 * If the address was found, then set the "associated" flag for
1491 * that station, based on whether the station is associating or
1492 * losing its association. Something weird has also happened
1493 * if we find the address in the list of authenticated stations
1494 * but we are getting an "authentication failed" message.
1497 for (i = 0; i < hw->authlist.cnt; i++)
1498 if (ether_addr_equal(rec.sta_addr, hw->authlist.addr[i]))
1501 if (i >= hw->authlist.cnt) {
1502 if (rec.assocstatus != HFA384x_ASSOCSTATUS_AUTHFAIL)
1503 netdev_warn(wlandev->netdev,
1504 "assocstatus info frame received for non-authenticated station.\n");
1506 hw->authlist.assoc[i] =
1507 (rec.assocstatus == HFA384x_ASSOCSTATUS_STAASSOC ||
1508 rec.assocstatus == HFA384x_ASSOCSTATUS_REASSOC);
1510 if (rec.assocstatus == HFA384x_ASSOCSTATUS_AUTHFAIL)
1511 netdev_warn(wlandev->netdev,
1512 "authfail assocstatus info frame received for authenticated station.\n");
1517 * prism2sta_inf_authreq
1519 * Handles the receipt of an Authentication Request info frame. Should
1520 * be present in APs only.
1523 * wlandev wlan device structure
1524 * inf ptr to info frame (contents in hfa384x order)
1535 static void prism2sta_inf_authreq(struct wlandevice *wlandev,
1536 struct hfa384x_inf_frame *inf)
1538 struct hfa384x *hw = wlandev->priv;
1539 struct sk_buff *skb;
1541 skb = dev_alloc_skb(sizeof(*inf));
1543 skb_put(skb, sizeof(*inf));
1544 memcpy(skb->data, inf, sizeof(*inf));
1545 skb_queue_tail(&hw->authq, skb);
1546 schedule_work(&hw->link_bh);
1550 static void prism2sta_inf_authreq_defer(struct wlandevice *wlandev,
1551 struct hfa384x_inf_frame *inf)
1553 struct hfa384x *hw = wlandev->priv;
1554 struct hfa384x_authenticate_station_data rec;
1556 int i, added, result, cnt;
1560 * Build the AuthenticateStation record. Initialize it for denying
1564 ether_addr_copy(rec.address, inf->info.authreq.sta_addr);
1565 rec.status = cpu_to_le16(P80211ENUM_status_unspec_failure);
1568 * Authenticate based on the access mode.
1571 switch (hw->accessmode) {
1572 case WLAN_ACCESS_NONE:
1575 * Deny all new authentications. However, if a station
1576 * is ALREADY authenticated, then accept it.
1579 for (i = 0; i < hw->authlist.cnt; i++)
1580 if (ether_addr_equal(rec.address,
1581 hw->authlist.addr[i])) {
1582 rec.status = cpu_to_le16(P80211ENUM_status_successful);
1588 case WLAN_ACCESS_ALL:
1591 * Allow all authentications.
1594 rec.status = cpu_to_le16(P80211ENUM_status_successful);
1597 case WLAN_ACCESS_ALLOW:
1600 * Only allow the authentication if the MAC address
1601 * is in the list of allowed addresses.
1603 * Since this is the interrupt handler, we may be here
1604 * while the access list is in the middle of being
1605 * updated. Choose the list which is currently okay.
1606 * See "prism2mib_priv_accessallow()" for details.
1609 if (hw->allow.modify == 0) {
1610 cnt = hw->allow.cnt;
1611 addr = hw->allow.addr[0];
1613 cnt = hw->allow.cnt1;
1614 addr = hw->allow.addr1[0];
1617 for (i = 0; i < cnt; i++, addr += ETH_ALEN)
1618 if (ether_addr_equal(rec.address, addr)) {
1619 rec.status = cpu_to_le16(P80211ENUM_status_successful);
1625 case WLAN_ACCESS_DENY:
1628 * Allow the authentication UNLESS the MAC address is
1629 * in the list of denied addresses.
1631 * Since this is the interrupt handler, we may be here
1632 * while the access list is in the middle of being
1633 * updated. Choose the list which is currently okay.
1634 * See "prism2mib_priv_accessdeny()" for details.
1637 if (hw->deny.modify == 0) {
1639 addr = hw->deny.addr[0];
1641 cnt = hw->deny.cnt1;
1642 addr = hw->deny.addr1[0];
1645 rec.status = cpu_to_le16(P80211ENUM_status_successful);
1647 for (i = 0; i < cnt; i++, addr += ETH_ALEN)
1648 if (ether_addr_equal(rec.address, addr)) {
1649 rec.status = cpu_to_le16(P80211ENUM_status_unspec_failure);
1657 * If the authentication is okay, then add the MAC address to the
1658 * list of authenticated stations. Don't add the address if it
1659 * is already in the list. (802.11b does not seem to disallow
1660 * a station from issuing an authentication request when the
1661 * station is already authenticated. Does this sort of thing
1662 * ever happen? We might as well do the check just in case.)
1667 if (rec.status == cpu_to_le16(P80211ENUM_status_successful)) {
1668 for (i = 0; i < hw->authlist.cnt; i++)
1669 if (ether_addr_equal(rec.address,
1670 hw->authlist.addr[i]))
1673 if (i >= hw->authlist.cnt) {
1674 if (hw->authlist.cnt >= WLAN_AUTH_MAX) {
1675 rec.status = cpu_to_le16(P80211ENUM_status_ap_full);
1678 hw->authlist.addr[hw->authlist.cnt],
1687 * Send back the results of the authentication. If this doesn't work,
1688 * then make sure to remove the address from the authenticated list if
1692 rec.algorithm = inf->info.authreq.algorithm;
1694 result = hfa384x_drvr_setconfig(hw, HFA384x_RID_AUTHENTICATESTA,
1699 netdev_err(wlandev->netdev,
1700 "setconfig(authenticatestation) failed, result=%d\n",
1706 * prism2sta_inf_psusercnt
1708 * Handles the receipt of a PowerSaveUserCount info frame. Should
1709 * be present in APs only.
1712 * wlandev wlan device structure
1713 * inf ptr to info frame (contents in hfa384x order)
1723 static void prism2sta_inf_psusercnt(struct wlandevice *wlandev,
1724 struct hfa384x_inf_frame *inf)
1726 struct hfa384x *hw = wlandev->priv;
1728 hw->psusercount = le16_to_cpu(inf->info.psusercnt.usercnt);
1734 * Handles the Info event.
1737 * wlandev wlan device structure
1738 * inf ptr to a generic info frame
1748 void prism2sta_ev_info(struct wlandevice *wlandev,
1749 struct hfa384x_inf_frame *inf)
1751 le16_to_cpus(&inf->infotype);
1753 switch (inf->infotype) {
1754 case HFA384x_IT_HANDOVERADDR:
1755 prism2sta_inf_handover(wlandev, inf);
1757 case HFA384x_IT_COMMTALLIES:
1758 prism2sta_inf_tallies(wlandev, inf);
1760 case HFA384x_IT_HOSTSCANRESULTS:
1761 prism2sta_inf_hostscanresults(wlandev, inf);
1763 case HFA384x_IT_SCANRESULTS:
1764 prism2sta_inf_scanresults(wlandev, inf);
1766 case HFA384x_IT_CHINFORESULTS:
1767 prism2sta_inf_chinforesults(wlandev, inf);
1769 case HFA384x_IT_LINKSTATUS:
1770 prism2sta_inf_linkstatus(wlandev, inf);
1772 case HFA384x_IT_ASSOCSTATUS:
1773 prism2sta_inf_assocstatus(wlandev, inf);
1775 case HFA384x_IT_AUTHREQ:
1776 prism2sta_inf_authreq(wlandev, inf);
1778 case HFA384x_IT_PSUSERCNT:
1779 prism2sta_inf_psusercnt(wlandev, inf);
1781 case HFA384x_IT_KEYIDCHANGED:
1782 netdev_warn(wlandev->netdev, "Unhandled IT_KEYIDCHANGED\n");
1784 case HFA384x_IT_ASSOCREQ:
1785 netdev_warn(wlandev->netdev, "Unhandled IT_ASSOCREQ\n");
1787 case HFA384x_IT_MICFAILURE:
1788 netdev_warn(wlandev->netdev, "Unhandled IT_MICFAILURE\n");
1791 netdev_warn(wlandev->netdev,
1792 "Unknown info type=0x%02x\n", inf->infotype);
1798 * prism2sta_ev_txexc
1800 * Handles the TxExc event. A Transmit Exception event indicates
1801 * that the MAC's TX process was unsuccessful - so the packet did
1802 * not get transmitted.
1805 * wlandev wlan device structure
1806 * status tx frame status word
1816 void prism2sta_ev_txexc(struct wlandevice *wlandev, u16 status)
1818 pr_debug("TxExc status=0x%x.\n", status);
1824 * Handles the Tx event.
1827 * wlandev wlan device structure
1828 * status tx frame status word
1837 void prism2sta_ev_tx(struct wlandevice *wlandev, u16 status)
1839 pr_debug("Tx Complete, status=0x%04x\n", status);
1840 /* update linux network stats */
1841 wlandev->netdev->stats.tx_packets++;
1845 * prism2sta_ev_alloc
1847 * Handles the Alloc event.
1850 * wlandev wlan device structure
1860 void prism2sta_ev_alloc(struct wlandevice *wlandev)
1862 netif_wake_queue(wlandev->netdev);
1868 * Called at module init time. This creates the struct wlandevice structure
1869 * and initializes it with relevant bits.
1875 * the created struct wlandevice structure.
1878 * also allocates the priv/hw structures.
1884 static struct wlandevice *create_wlan(void)
1886 struct wlandevice *wlandev = NULL;
1887 struct hfa384x *hw = NULL;
1889 /* Alloc our structures */
1890 wlandev = kzalloc(sizeof(*wlandev), GFP_KERNEL);
1891 hw = kzalloc(sizeof(*hw), GFP_KERNEL);
1893 if (!wlandev || !hw) {
1899 /* Initialize the network device object. */
1900 wlandev->nsdname = dev_info;
1901 wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING;
1903 wlandev->open = prism2sta_open;
1904 wlandev->close = prism2sta_close;
1905 wlandev->reset = prism2sta_reset;
1906 wlandev->txframe = prism2sta_txframe;
1907 wlandev->mlmerequest = prism2sta_mlmerequest;
1908 wlandev->set_multicast_list = prism2sta_setmulticast;
1909 wlandev->tx_timeout = hfa384x_tx_timeout;
1911 wlandev->nsdcaps = P80211_NSDCAP_HWFRAGMENT | P80211_NSDCAP_AUTOJOIN;
1913 /* Initialize the device private data structure. */
1914 hw->dot11_desired_bss_type = 1;
1919 void prism2sta_commsqual_defer(struct work_struct *data)
1921 struct hfa384x *hw = container_of(data, struct hfa384x, commsqual_bh);
1922 struct wlandevice *wlandev = hw->wlandev;
1923 struct hfa384x_bytestr32 ssid;
1924 struct p80211msg_dot11req_mibget msg;
1925 struct p80211item_uint32 *mibitem = (struct p80211item_uint32 *)
1926 &msg.mibattribute.data;
1929 if (hw->wlandev->hwremoved)
1932 /* we don't care if we're in AP mode */
1933 if ((wlandev->macmode == WLAN_MACMODE_NONE) ||
1934 (wlandev->macmode == WLAN_MACMODE_ESS_AP)) {
1938 /* It only makes sense to poll these in non-IBSS */
1939 if (wlandev->macmode != WLAN_MACMODE_IBSS_STA) {
1940 result = hfa384x_drvr_getconfig(
1941 hw, HFA384x_RID_DBMCOMMSQUALITY,
1942 &hw->qual, HFA384x_RID_DBMCOMMSQUALITY_LEN);
1945 netdev_err(wlandev->netdev, "error fetching commsqual\n");
1949 pr_debug("commsqual %d %d %d\n",
1950 le16_to_cpu(hw->qual.cq_curr_bss),
1951 le16_to_cpu(hw->qual.asl_curr_bss),
1952 le16_to_cpu(hw->qual.anl_curr_fc));
1955 /* Get the signal rate */
1956 msg.msgcode = DIDmsg_dot11req_mibget;
1957 mibitem->did = DIDmib_p2_p2MAC_p2CurrentTxRate;
1958 result = p80211req_dorequest(wlandev, (u8 *)&msg);
1961 pr_debug("get signal rate failed, result = %d\n",
1966 switch (mibitem->data) {
1967 case HFA384x_RATEBIT_1:
1970 case HFA384x_RATEBIT_2:
1973 case HFA384x_RATEBIT_5dot5:
1976 case HFA384x_RATEBIT_11:
1980 pr_debug("Bad ratebit (%d)\n", mibitem->data);
1983 /* Lastly, we need to make sure the BSSID didn't change on us */
1984 result = hfa384x_drvr_getconfig(hw,
1985 HFA384x_RID_CURRENTBSSID,
1986 wlandev->bssid, WLAN_BSSID_LEN);
1988 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1989 HFA384x_RID_CURRENTBSSID, result);
1993 result = hfa384x_drvr_getconfig(hw,
1994 HFA384x_RID_CURRENTSSID,
1995 &ssid, sizeof(ssid));
1997 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1998 HFA384x_RID_CURRENTSSID, result);
2001 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *)&ssid,
2002 (struct p80211pstrd *)&wlandev->ssid);
2004 /* Reschedule timer */
2005 mod_timer(&hw->commsqual_timer, jiffies + HZ);
2008 void prism2sta_commsqual_timer(struct timer_list *t)
2010 struct hfa384x *hw = from_timer(hw, t, commsqual_timer);
2012 schedule_work(&hw->commsqual_bh);