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
);
1194 /* Now let's handle the linkstatus stuff */
1195 if (hw
->link_status
== hw
->link_status_new
)
1198 hw
->link_status
= hw
->link_status_new
;
1200 switch (hw
->link_status
) {
1201 case HFA384x_LINK_NOTCONNECTED
:
1202 /* I'm currently assuming that this is the initial link
1203 * state. It should only be possible immediately
1204 * following an Enable command.
1206 * Block Transmits, Ignore receives of data frames
1208 netif_carrier_off(wlandev
->netdev
);
1210 netdev_info(wlandev
->netdev
, "linkstatus=NOTCONNECTED (unhandled)\n");
1213 case HFA384x_LINK_CONNECTED
:
1214 /* This one indicates a successful scan/join/auth/assoc.
1215 * When we have the full MLME complement, this event will
1216 * signify successful completion of both mlme_authenticate
1217 * and mlme_associate. State management will get a little
1220 * Indicate authentication and/or association
1221 * Enable Transmits, Receives and pass up data frames
1224 netif_carrier_on(wlandev
->netdev
);
1226 /* If we are joining a specific AP, set our
1227 * state and reset retries
1229 if (hw
->join_ap
== 1)
1231 hw
->join_retries
= 60;
1233 /* Don't call this in monitor mode */
1234 if (wlandev
->netdev
->type
== ARPHRD_ETHER
) {
1237 netdev_info(wlandev
->netdev
, "linkstatus=CONNECTED\n");
1239 /* For non-usb devices, we can use the sync versions */
1240 /* Collect the BSSID, and set state to allow tx */
1242 result
= hfa384x_drvr_getconfig(hw
,
1243 HFA384x_RID_CURRENTBSSID
,
1248 ("getconfig(0x%02x) failed, result = %d\n",
1249 HFA384x_RID_CURRENTBSSID
, result
);
1253 result
= hfa384x_drvr_getconfig(hw
,
1254 HFA384x_RID_CURRENTSSID
,
1255 &ssid
, sizeof(ssid
));
1258 ("getconfig(0x%02x) failed, result = %d\n",
1259 HFA384x_RID_CURRENTSSID
, result
);
1262 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr
*)&ssid
,
1263 (struct p80211pstrd
*)&wlandev
->ssid
);
1265 /* Collect the port status */
1266 result
= hfa384x_drvr_getconfig16(hw
,
1267 HFA384x_RID_PORTSTATUS
,
1271 ("getconfig(0x%02x) failed, result = %d\n",
1272 HFA384x_RID_PORTSTATUS
, result
);
1276 (portstatus
== HFA384x_PSTATUS_CONN_IBSS
) ?
1277 WLAN_MACMODE_IBSS_STA
: WLAN_MACMODE_ESS_STA
;
1279 /* signal back up to cfg80211 layer */
1280 prism2_connect_result(wlandev
, P80211ENUM_truth_false
);
1282 /* Get the ball rolling on the comms quality stuff */
1283 prism2sta_commsqual_defer(&hw
->commsqual_bh
);
1287 case HFA384x_LINK_DISCONNECTED
:
1288 /* This one indicates that our association is gone. We've
1289 * lost connection with the AP and/or been disassociated.
1290 * This indicates that the MAC has completely cleared it's
1291 * associated state. We * should send a deauth indication
1292 * (implying disassoc) up * to the MLME.
1294 * Indicate Deauthentication
1295 * Block Transmits, Ignore receives of data frames
1297 if (wlandev
->netdev
->type
== ARPHRD_ETHER
)
1298 netdev_info(wlandev
->netdev
,
1299 "linkstatus=DISCONNECTED (unhandled)\n");
1300 wlandev
->macmode
= WLAN_MACMODE_NONE
;
1302 netif_carrier_off(wlandev
->netdev
);
1304 /* signal back up to cfg80211 layer */
1305 prism2_disconnected(wlandev
);
1309 case HFA384x_LINK_AP_CHANGE
:
1310 /* This one indicates that the MAC has decided to and
1311 * successfully completed a change to another AP. We
1312 * should probably implement a reassociation indication
1313 * in response to this one. I'm thinking that the
1314 * p80211 layer needs to be notified in case of
1315 * buffering/queueing issues. User mode also needs to be
1316 * notified so that any BSS dependent elements can be
1318 * associated state. We * should send a deauth indication
1319 * (implying disassoc) up * to the MLME.
1321 * Indicate Reassociation
1322 * Enable Transmits, Receives and pass up data frames
1324 netdev_info(wlandev
->netdev
, "linkstatus=AP_CHANGE\n");
1326 result
= hfa384x_drvr_getconfig(hw
,
1327 HFA384x_RID_CURRENTBSSID
,
1328 wlandev
->bssid
, WLAN_BSSID_LEN
);
1330 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1331 HFA384x_RID_CURRENTBSSID
, result
);
1335 result
= hfa384x_drvr_getconfig(hw
,
1336 HFA384x_RID_CURRENTSSID
,
1337 &ssid
, sizeof(ssid
));
1339 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1340 HFA384x_RID_CURRENTSSID
, result
);
1343 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr
*)&ssid
,
1344 (struct p80211pstrd
*)&wlandev
->ssid
);
1346 hw
->link_status
= HFA384x_LINK_CONNECTED
;
1347 netif_carrier_on(wlandev
->netdev
);
1349 /* signal back up to cfg80211 layer */
1350 prism2_roamed(wlandev
);
1354 case HFA384x_LINK_AP_OUTOFRANGE
:
1355 /* This one indicates that the MAC has decided that the
1356 * AP is out of range, but hasn't found a better candidate
1357 * so the MAC maintains its "associated" state in case
1358 * we get back in range. We should block transmits and
1359 * receives in this state. Do we need an indication here?
1360 * Probably not since a polling user-mode element would
1361 * get this status from from p2PortStatus(FD40). What about
1364 * Block Transmits, Ignore receives of data frames
1366 netdev_info(wlandev
->netdev
, "linkstatus=AP_OUTOFRANGE (unhandled)\n");
1368 netif_carrier_off(wlandev
->netdev
);
1372 case HFA384x_LINK_AP_INRANGE
:
1373 /* This one indicates that the MAC has decided that the
1374 * AP is back in range. We continue working with our
1375 * existing association.
1377 * Enable Transmits, Receives and pass up data frames
1379 netdev_info(wlandev
->netdev
, "linkstatus=AP_INRANGE\n");
1381 hw
->link_status
= HFA384x_LINK_CONNECTED
;
1382 netif_carrier_on(wlandev
->netdev
);
1386 case HFA384x_LINK_ASSOCFAIL
:
1387 /* This one is actually a peer to CONNECTED. We've
1388 * requested a join for a given SSID and optionally BSSID.
1389 * We can use this one to indicate authentication and
1390 * association failures. The trick is going to be
1391 * 1) identifying the failure, and 2) state management.
1393 * Disable Transmits, Ignore receives of data frames
1395 if (hw
->join_ap
&& --hw
->join_retries
> 0) {
1396 struct hfa384x_join_request_data joinreq
;
1398 joinreq
= hw
->joinreq
;
1399 /* Send the join request */
1400 hfa384x_drvr_setconfig(hw
,
1401 HFA384x_RID_JOINREQUEST
,
1403 HFA384x_RID_JOINREQUEST_LEN
);
1404 netdev_info(wlandev
->netdev
,
1405 "linkstatus=ASSOCFAIL (re-submitting join)\n");
1407 netdev_info(wlandev
->netdev
, "linkstatus=ASSOCFAIL (unhandled)\n");
1410 netif_carrier_off(wlandev
->netdev
);
1412 /* signal back up to cfg80211 layer */
1413 prism2_connect_result(wlandev
, P80211ENUM_truth_true
);
1418 /* This is bad, IO port problems? */
1419 netdev_warn(wlandev
->netdev
,
1420 "unknown linkstatus=0x%02x\n", hw
->link_status
);
1424 wlandev
->linkstatus
= (hw
->link_status
== HFA384x_LINK_CONNECTED
);
1428 * prism2sta_inf_linkstatus
1430 * Handles the receipt of a Link Status info frame.
1433 * wlandev wlan device structure
1434 * inf ptr to info frame (contents in hfa384x order)
1444 static void prism2sta_inf_linkstatus(struct wlandevice
*wlandev
,
1445 struct hfa384x_inf_frame
*inf
)
1447 struct hfa384x
*hw
= wlandev
->priv
;
1449 hw
->link_status_new
= le16_to_cpu(inf
->info
.linkstatus
.linkstatus
);
1451 schedule_work(&hw
->link_bh
);
1455 * prism2sta_inf_assocstatus
1457 * Handles the receipt of an Association Status info frame. Should
1458 * be present in APs only.
1461 * wlandev wlan device structure
1462 * inf ptr to info frame (contents in hfa384x order)
1472 static void prism2sta_inf_assocstatus(struct wlandevice
*wlandev
,
1473 struct hfa384x_inf_frame
*inf
)
1475 struct hfa384x
*hw
= wlandev
->priv
;
1476 struct hfa384x_assoc_status rec
;
1479 memcpy(&rec
, &inf
->info
.assocstatus
, sizeof(rec
));
1480 le16_to_cpus(&rec
.assocstatus
);
1481 le16_to_cpus(&rec
.reason
);
1484 * Find the address in the list of authenticated stations.
1485 * If it wasn't found, then this address has not been previously
1486 * authenticated and something weird has happened if this is
1487 * anything other than an "authentication failed" message.
1488 * If the address was found, then set the "associated" flag for
1489 * that station, based on whether the station is associating or
1490 * losing its association. Something weird has also happened
1491 * if we find the address in the list of authenticated stations
1492 * but we are getting an "authentication failed" message.
1495 for (i
= 0; i
< hw
->authlist
.cnt
; i
++)
1496 if (ether_addr_equal(rec
.sta_addr
, hw
->authlist
.addr
[i
]))
1499 if (i
>= hw
->authlist
.cnt
) {
1500 if (rec
.assocstatus
!= HFA384x_ASSOCSTATUS_AUTHFAIL
)
1501 netdev_warn(wlandev
->netdev
,
1502 "assocstatus info frame received for non-authenticated station.\n");
1504 hw
->authlist
.assoc
[i
] =
1505 (rec
.assocstatus
== HFA384x_ASSOCSTATUS_STAASSOC
||
1506 rec
.assocstatus
== HFA384x_ASSOCSTATUS_REASSOC
);
1508 if (rec
.assocstatus
== HFA384x_ASSOCSTATUS_AUTHFAIL
)
1509 netdev_warn(wlandev
->netdev
,
1510 "authfail assocstatus info frame received for authenticated station.\n");
1515 * prism2sta_inf_authreq
1517 * Handles the receipt of an Authentication Request info frame. Should
1518 * be present in APs only.
1521 * wlandev wlan device structure
1522 * inf ptr to info frame (contents in hfa384x order)
1533 static void prism2sta_inf_authreq(struct wlandevice
*wlandev
,
1534 struct hfa384x_inf_frame
*inf
)
1536 struct hfa384x
*hw
= wlandev
->priv
;
1537 struct sk_buff
*skb
;
1539 skb
= dev_alloc_skb(sizeof(*inf
));
1541 skb_put(skb
, sizeof(*inf
));
1542 memcpy(skb
->data
, inf
, sizeof(*inf
));
1543 skb_queue_tail(&hw
->authq
, skb
);
1544 schedule_work(&hw
->link_bh
);
1548 static void prism2sta_inf_authreq_defer(struct wlandevice
*wlandev
,
1549 struct hfa384x_inf_frame
*inf
)
1551 struct hfa384x
*hw
= wlandev
->priv
;
1552 struct hfa384x_authenticate_station_data rec
;
1554 int i
, added
, result
, cnt
;
1558 * Build the AuthenticateStation record. Initialize it for denying
1562 ether_addr_copy(rec
.address
, inf
->info
.authreq
.sta_addr
);
1563 rec
.status
= cpu_to_le16(P80211ENUM_status_unspec_failure
);
1566 * Authenticate based on the access mode.
1569 switch (hw
->accessmode
) {
1570 case WLAN_ACCESS_NONE
:
1573 * Deny all new authentications. However, if a station
1574 * is ALREADY authenticated, then accept it.
1577 for (i
= 0; i
< hw
->authlist
.cnt
; i
++)
1578 if (ether_addr_equal(rec
.address
,
1579 hw
->authlist
.addr
[i
])) {
1580 rec
.status
= cpu_to_le16(P80211ENUM_status_successful
);
1586 case WLAN_ACCESS_ALL
:
1589 * Allow all authentications.
1592 rec
.status
= cpu_to_le16(P80211ENUM_status_successful
);
1595 case WLAN_ACCESS_ALLOW
:
1598 * Only allow the authentication if the MAC address
1599 * is in the list of allowed addresses.
1601 * Since this is the interrupt handler, we may be here
1602 * while the access list is in the middle of being
1603 * updated. Choose the list which is currently okay.
1604 * See "prism2mib_priv_accessallow()" for details.
1607 if (hw
->allow
.modify
== 0) {
1608 cnt
= hw
->allow
.cnt
;
1609 addr
= hw
->allow
.addr
[0];
1611 cnt
= hw
->allow
.cnt1
;
1612 addr
= hw
->allow
.addr1
[0];
1615 for (i
= 0; i
< cnt
; i
++, addr
+= ETH_ALEN
)
1616 if (ether_addr_equal(rec
.address
, addr
)) {
1617 rec
.status
= cpu_to_le16(P80211ENUM_status_successful
);
1623 case WLAN_ACCESS_DENY
:
1626 * Allow the authentication UNLESS the MAC address is
1627 * in the list of denied addresses.
1629 * Since this is the interrupt handler, we may be here
1630 * while the access list is in the middle of being
1631 * updated. Choose the list which is currently okay.
1632 * See "prism2mib_priv_accessdeny()" for details.
1635 if (hw
->deny
.modify
== 0) {
1637 addr
= hw
->deny
.addr
[0];
1639 cnt
= hw
->deny
.cnt1
;
1640 addr
= hw
->deny
.addr1
[0];
1643 rec
.status
= cpu_to_le16(P80211ENUM_status_successful
);
1645 for (i
= 0; i
< cnt
; i
++, addr
+= ETH_ALEN
)
1646 if (ether_addr_equal(rec
.address
, addr
)) {
1647 rec
.status
= cpu_to_le16(P80211ENUM_status_unspec_failure
);
1655 * If the authentication is okay, then add the MAC address to the
1656 * list of authenticated stations. Don't add the address if it
1657 * is already in the list. (802.11b does not seem to disallow
1658 * a station from issuing an authentication request when the
1659 * station is already authenticated. Does this sort of thing
1660 * ever happen? We might as well do the check just in case.)
1665 if (rec
.status
== cpu_to_le16(P80211ENUM_status_successful
)) {
1666 for (i
= 0; i
< hw
->authlist
.cnt
; i
++)
1667 if (ether_addr_equal(rec
.address
,
1668 hw
->authlist
.addr
[i
]))
1671 if (i
>= hw
->authlist
.cnt
) {
1672 if (hw
->authlist
.cnt
>= WLAN_AUTH_MAX
) {
1673 rec
.status
= cpu_to_le16(P80211ENUM_status_ap_full
);
1675 ether_addr_copy(hw
->authlist
.addr
[hw
->authlist
.cnt
],
1684 * Send back the results of the authentication. If this doesn't work,
1685 * then make sure to remove the address from the authenticated list if
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 struct hfa384x_inf_frame
*inf
)
1723 struct hfa384x
*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
,
1746 struct hfa384x_inf_frame
*inf
)
1748 le16_to_cpus(&inf
->infotype
);
1750 switch (inf
->infotype
) {
1751 case HFA384x_IT_HANDOVERADDR
:
1752 prism2sta_inf_handover(wlandev
, inf
);
1754 case HFA384x_IT_COMMTALLIES
:
1755 prism2sta_inf_tallies(wlandev
, inf
);
1757 case HFA384x_IT_HOSTSCANRESULTS
:
1758 prism2sta_inf_hostscanresults(wlandev
, inf
);
1760 case HFA384x_IT_SCANRESULTS
:
1761 prism2sta_inf_scanresults(wlandev
, inf
);
1763 case HFA384x_IT_CHINFORESULTS
:
1764 prism2sta_inf_chinforesults(wlandev
, inf
);
1766 case HFA384x_IT_LINKSTATUS
:
1767 prism2sta_inf_linkstatus(wlandev
, inf
);
1769 case HFA384x_IT_ASSOCSTATUS
:
1770 prism2sta_inf_assocstatus(wlandev
, inf
);
1772 case HFA384x_IT_AUTHREQ
:
1773 prism2sta_inf_authreq(wlandev
, inf
);
1775 case HFA384x_IT_PSUSERCNT
:
1776 prism2sta_inf_psusercnt(wlandev
, inf
);
1778 case HFA384x_IT_KEYIDCHANGED
:
1779 netdev_warn(wlandev
->netdev
, "Unhandled IT_KEYIDCHANGED\n");
1781 case HFA384x_IT_ASSOCREQ
:
1782 netdev_warn(wlandev
->netdev
, "Unhandled IT_ASSOCREQ\n");
1784 case HFA384x_IT_MICFAILURE
:
1785 netdev_warn(wlandev
->netdev
, "Unhandled IT_MICFAILURE\n");
1788 netdev_warn(wlandev
->netdev
,
1789 "Unknown info type=0x%02x\n", inf
->infotype
);
1795 * prism2sta_ev_txexc
1797 * Handles the TxExc event. A Transmit Exception event indicates
1798 * that the MAC's TX process was unsuccessful - so the packet did
1799 * not get transmitted.
1802 * wlandev wlan device structure
1803 * status tx frame status word
1813 void prism2sta_ev_txexc(struct wlandevice
*wlandev
, u16 status
)
1815 pr_debug("TxExc status=0x%x.\n", status
);
1821 * Handles the Tx event.
1824 * wlandev wlan device structure
1825 * status tx frame status word
1834 void prism2sta_ev_tx(struct wlandevice
*wlandev
, u16 status
)
1836 pr_debug("Tx Complete, status=0x%04x\n", status
);
1837 /* update linux network stats */
1838 wlandev
->netdev
->stats
.tx_packets
++;
1842 * prism2sta_ev_alloc
1844 * Handles the Alloc event.
1847 * wlandev wlan device structure
1857 void prism2sta_ev_alloc(struct wlandevice
*wlandev
)
1859 netif_wake_queue(wlandev
->netdev
);
1865 * Called at module init time. This creates the struct wlandevice structure
1866 * and initializes it with relevant bits.
1872 * the created struct wlandevice structure.
1875 * also allocates the priv/hw structures.
1881 static struct wlandevice
*create_wlan(void)
1883 struct wlandevice
*wlandev
= NULL
;
1884 struct hfa384x
*hw
= NULL
;
1886 /* Alloc our structures */
1887 wlandev
= kzalloc(sizeof(*wlandev
), GFP_KERNEL
);
1888 hw
= kzalloc(sizeof(*hw
), GFP_KERNEL
);
1890 if (!wlandev
|| !hw
) {
1896 /* Initialize the network device object. */
1897 wlandev
->nsdname
= dev_info
;
1898 wlandev
->msdstate
= WLAN_MSD_HWPRESENT_PENDING
;
1900 wlandev
->open
= prism2sta_open
;
1901 wlandev
->close
= prism2sta_close
;
1902 wlandev
->reset
= prism2sta_reset
;
1903 wlandev
->txframe
= prism2sta_txframe
;
1904 wlandev
->mlmerequest
= prism2sta_mlmerequest
;
1905 wlandev
->set_multicast_list
= prism2sta_setmulticast
;
1906 wlandev
->tx_timeout
= hfa384x_tx_timeout
;
1908 wlandev
->nsdcaps
= P80211_NSDCAP_HWFRAGMENT
| P80211_NSDCAP_AUTOJOIN
;
1910 /* Initialize the device private data structure. */
1911 hw
->dot11_desired_bss_type
= 1;
1916 void prism2sta_commsqual_defer(struct work_struct
*data
)
1918 struct hfa384x
*hw
= container_of(data
, struct hfa384x
, commsqual_bh
);
1919 struct wlandevice
*wlandev
= hw
->wlandev
;
1920 struct hfa384x_bytestr32 ssid
;
1921 struct p80211msg_dot11req_mibget msg
;
1922 struct p80211item_uint32
*mibitem
= (struct p80211item_uint32
*)
1923 &msg
.mibattribute
.data
;
1926 if (hw
->wlandev
->hwremoved
)
1929 /* we don't care if we're in AP mode */
1930 if ((wlandev
->macmode
== WLAN_MACMODE_NONE
) ||
1931 (wlandev
->macmode
== WLAN_MACMODE_ESS_AP
)) {
1935 /* It only makes sense to poll these in non-IBSS */
1936 if (wlandev
->macmode
!= WLAN_MACMODE_IBSS_STA
) {
1937 result
= hfa384x_drvr_getconfig(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_curr_bss
),
1947 le16_to_cpu(hw
->qual
.asl_curr_bss
),
1948 le16_to_cpu(hw
->qual
.anl_curr_fc
));
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(struct timer_list
*t
)
2006 struct hfa384x
*hw
= from_timer(hw
, t
, commsqual_timer
);
2008 schedule_work(&hw
->commsqual_bh
);