1 /* src/prism2/driver/prism2sta.c
2 *
3 * Implements the station functionality for prism2
4 *
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
6 * --------------------------------------------------------------------
7 *
8 * linux-wlan
9 *
10 * The contents of this file are subject to the Mozilla Public
11 * License Version 1.1 (the "License"); you may not use this file
12 * except in compliance with the License. You may obtain a copy of
13 * the License at http://www.mozilla.org/MPL/
14 *
15 * Software distributed under the License is distributed on an "AS
16 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 * implied. See the License for the specific language governing
18 * rights and limitations under the License.
19 *
20 * Alternatively, the contents of this file may be used under the
21 * terms of the GNU Public License version 2 (the "GPL"), in which
22 * case the provisions of the GPL are applicable instead of the
23 * above. If you wish to allow the use of your version of this file
24 * only under the terms of the GPL and not to allow others to use
25 * your version of this file under the MPL, indicate your decision
26 * by deleting the provisions above and replace them with the notice
27 * and other provisions required by the GPL. If you do not delete
28 * the provisions above, a recipient may use your version of this
29 * file under either the MPL or the GPL.
30 *
31 * --------------------------------------------------------------------
32 *
33 * Inquiries regarding the linux-wlan Open Source project can be
34 * made directly to:
35 *
36 * AbsoluteValue Systems Inc.
37 * info@linux-wlan.com
38 * http://www.linux-wlan.com
39 *
40 * --------------------------------------------------------------------
41 *
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
44 *
45 * --------------------------------------------------------------------
46 *
47 * This file implements the module and linux pcmcia routines for the
48 * prism2 driver.
49 *
50 * --------------------------------------------------------------------
51 */
52
53 #include <linux/module.h>
54 #include <linux/kernel.h>
55 #include <linux/sched.h>
56 #include <linux/types.h>
57 #include <linux/slab.h>
58 #include <linux/wireless.h>
59 #include <linux/netdevice.h>
60 #include <linux/workqueue.h>
61 #include <linux/byteorder/generic.h>
62 #include <linux/etherdevice.h>
63
64 #include <linux/io.h>
65 #include <linux/delay.h>
66 #include <asm/byteorder.h>
67 #include <linux/if_arp.h>
68 #include <linux/if_ether.h>
69 #include <linux/bitops.h>
70
71 #include "p80211types.h"
72 #include "p80211hdr.h"
73 #include "p80211mgmt.h"
74 #include "p80211conv.h"
75 #include "p80211msg.h"
76 #include "p80211netdev.h"
77 #include "p80211req.h"
78 #include "p80211metadef.h"
79 #include "p80211metastruct.h"
80 #include "hfa384x.h"
81 #include "prism2mgmt.h"
82
83 static char *dev_info = "prism2_usb";
84 static struct wlandevice *create_wlan(void);
85
86 int prism2_reset_holdtime = 30; /* Reset hold time in ms */
87 int prism2_reset_settletime = 100; /* Reset settle time in ms */
88
89 static int prism2_doreset; /* Do a reset at init? */
90
91 module_param(prism2_doreset, int, 0644);
92 MODULE_PARM_DESC(prism2_doreset, "Issue a reset on initialization");
93
94 module_param(prism2_reset_holdtime, int, 0644);
95 MODULE_PARM_DESC(prism2_reset_holdtime, "reset hold time in ms");
96 module_param(prism2_reset_settletime, int, 0644);
97 MODULE_PARM_DESC(prism2_reset_settletime, "reset settle time in ms");
98
99 MODULE_LICENSE("Dual MPL/GPL");
100
101 static int prism2sta_open(struct wlandevice *wlandev);
102 static int prism2sta_close(struct wlandevice *wlandev);
103 static void prism2sta_reset(struct wlandevice *wlandev);
104 static int prism2sta_txframe(struct wlandevice *wlandev, struct sk_buff *skb,
105 union p80211_hdr *p80211_hdr,
106 struct p80211_metawep *p80211_wep);
107 static int prism2sta_mlmerequest(struct wlandevice *wlandev, struct p80211msg *msg);
108 static int prism2sta_getcardinfo(struct wlandevice *wlandev);
109 static int prism2sta_globalsetup(struct wlandevice *wlandev);
110 static int prism2sta_setmulticast(struct wlandevice *wlandev,
111 struct net_device *dev);
112
113 static void prism2sta_inf_handover(struct wlandevice *wlandev,
114 struct hfa384x_InfFrame *inf);
115 static void prism2sta_inf_tallies(struct wlandevice *wlandev,
116 struct hfa384x_InfFrame *inf);
117 static void prism2sta_inf_hostscanresults(struct wlandevice *wlandev,
118 struct hfa384x_InfFrame *inf);
119 static void prism2sta_inf_scanresults(struct wlandevice *wlandev,
120 struct hfa384x_InfFrame *inf);
121 static void prism2sta_inf_chinforesults(struct wlandevice *wlandev,
122 struct hfa384x_InfFrame *inf);
123 static void prism2sta_inf_linkstatus(struct wlandevice *wlandev,
124 struct hfa384x_InfFrame *inf);
125 static void prism2sta_inf_assocstatus(struct wlandevice *wlandev,
126 struct hfa384x_InfFrame *inf);
127 static void prism2sta_inf_authreq(struct wlandevice *wlandev,
128 struct hfa384x_InfFrame *inf);
129 static void prism2sta_inf_authreq_defer(struct wlandevice *wlandev,
130 struct hfa384x_InfFrame *inf);
131 static void prism2sta_inf_psusercnt(struct wlandevice *wlandev,
132 struct hfa384x_InfFrame *inf);
133
134 /*
135 * prism2sta_open
136 *
137 * WLAN device open method. Called from p80211netdev when kernel
138 * device open (start) method is called in response to the
139 * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
140 * from clear to set.
141 *
142 * Arguments:
143 * wlandev wlan device structure
144 *
145 * Returns:
146 * 0 success
147 * >0 f/w reported error
148 * <0 driver reported error
149 *
150 * Side effects:
151 *
152 * Call context:
153 * process thread
154 */
prism2sta_open(struct wlandevice * wlandev)155 static int prism2sta_open(struct wlandevice *wlandev)
156 {
157 /* We don't currently have to do anything else.
158 * The setup of the MAC should be subsequently completed via
159 * the mlme commands.
160 * Higher layers know we're ready from dev->start==1 and
161 * dev->tbusy==0. Our rx path knows to pass up received/
162 * frames because of dev->flags&IFF_UP is true.
163 */
164
165 return 0;
166 }
167
168 /*
169 * prism2sta_close
170 *
171 * WLAN device close method. Called from p80211netdev when kernel
172 * device close method is called in response to the
173 * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
174 * from set to clear.
175 *
176 * Arguments:
177 * wlandev wlan device structure
178 *
179 * Returns:
180 * 0 success
181 * >0 f/w reported error
182 * <0 driver reported error
183 *
184 * Side effects:
185 *
186 * Call context:
187 * process thread
188 */
prism2sta_close(struct wlandevice * wlandev)189 static int prism2sta_close(struct wlandevice *wlandev)
190 {
191 /* We don't currently have to do anything else.
192 * Higher layers know we're not ready from dev->start==0 and
193 * dev->tbusy==1. Our rx path knows to not pass up received
194 * frames because of dev->flags&IFF_UP is false.
195 */
196
197 return 0;
198 }
199
200 /*
201 * prism2sta_reset
202 *
203 * Currently not implemented.
204 *
205 * Arguments:
206 * wlandev wlan device structure
207 * none
208 *
209 * Returns:
210 * nothing
211 *
212 * Side effects:
213 *
214 * Call context:
215 * process thread
216 */
prism2sta_reset(struct wlandevice * wlandev)217 static void prism2sta_reset(struct wlandevice *wlandev)
218 {
219 }
220
221 /*
222 * prism2sta_txframe
223 *
224 * Takes a frame from p80211 and queues it for transmission.
225 *
226 * Arguments:
227 * wlandev wlan device structure
228 * pb packet buffer struct. Contains an 802.11
229 * data frame.
230 * p80211_hdr points to the 802.11 header for the packet.
231 * Returns:
232 * 0 Success and more buffs available
233 * 1 Success but no more buffs
234 * 2 Allocation failure
235 * 4 Buffer full or queue busy
236 *
237 * Side effects:
238 *
239 * Call context:
240 * process thread
241 */
prism2sta_txframe(struct wlandevice * wlandev,struct sk_buff * skb,union p80211_hdr * p80211_hdr,struct p80211_metawep * p80211_wep)242 static int prism2sta_txframe(struct wlandevice *wlandev, struct sk_buff *skb,
243 union p80211_hdr *p80211_hdr,
244 struct p80211_metawep *p80211_wep)
245 {
246 struct hfa384x *hw = wlandev->priv;
247
248 /* If necessary, set the 802.11 WEP bit */
249 if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) ==
250 HOSTWEP_PRIVACYINVOKED) {
251 p80211_hdr->a3.fc |= cpu_to_le16(WLAN_SET_FC_ISWEP(1));
252 }
253
254 return hfa384x_drvr_txframe(hw, skb, p80211_hdr, p80211_wep);
255 }
256
257 /*
258 * prism2sta_mlmerequest
259 *
260 * wlan command message handler. All we do here is pass the message
261 * over to the prism2sta_mgmt_handler.
262 *
263 * Arguments:
264 * wlandev wlan device structure
265 * msg wlan command message
266 * Returns:
267 * 0 success
268 * <0 successful acceptance of message, but we're
269 * waiting for an async process to finish before
270 * we're done with the msg. When the asynch
271 * process is done, we'll call the p80211
272 * function p80211req_confirm() .
273 * >0 An error occurred while we were handling
274 * the message.
275 *
276 * Side effects:
277 *
278 * Call context:
279 * process thread
280 */
prism2sta_mlmerequest(struct wlandevice * wlandev,struct p80211msg * msg)281 static int prism2sta_mlmerequest(struct wlandevice *wlandev, struct p80211msg *msg)
282 {
283 struct hfa384x *hw = wlandev->priv;
284
285 int result = 0;
286
287 switch (msg->msgcode) {
288 case DIDmsg_dot11req_mibget:
289 pr_debug("Received mibget request\n");
290 result = prism2mgmt_mibset_mibget(wlandev, msg);
291 break;
292 case DIDmsg_dot11req_mibset:
293 pr_debug("Received mibset request\n");
294 result = prism2mgmt_mibset_mibget(wlandev, msg);
295 break;
296 case DIDmsg_dot11req_scan:
297 pr_debug("Received scan request\n");
298 result = prism2mgmt_scan(wlandev, msg);
299 break;
300 case DIDmsg_dot11req_scan_results:
301 pr_debug("Received scan_results request\n");
302 result = prism2mgmt_scan_results(wlandev, msg);
303 break;
304 case DIDmsg_dot11req_start:
305 pr_debug("Received mlme start request\n");
306 result = prism2mgmt_start(wlandev, msg);
307 break;
308 /*
309 * Prism2 specific messages
310 */
311 case DIDmsg_p2req_readpda:
312 pr_debug("Received mlme readpda request\n");
313 result = prism2mgmt_readpda(wlandev, msg);
314 break;
315 case DIDmsg_p2req_ramdl_state:
316 pr_debug("Received mlme ramdl_state request\n");
317 result = prism2mgmt_ramdl_state(wlandev, msg);
318 break;
319 case DIDmsg_p2req_ramdl_write:
320 pr_debug("Received mlme ramdl_write request\n");
321 result = prism2mgmt_ramdl_write(wlandev, msg);
322 break;
323 case DIDmsg_p2req_flashdl_state:
324 pr_debug("Received mlme flashdl_state request\n");
325 result = prism2mgmt_flashdl_state(wlandev, msg);
326 break;
327 case DIDmsg_p2req_flashdl_write:
328 pr_debug("Received mlme flashdl_write request\n");
329 result = prism2mgmt_flashdl_write(wlandev, msg);
330 break;
331 /*
332 * Linux specific messages
333 */
334 case DIDmsg_lnxreq_hostwep:
335 break; /* ignore me. */
336 case DIDmsg_lnxreq_ifstate:
337 {
338 struct p80211msg_lnxreq_ifstate *ifstatemsg;
339
340 pr_debug("Received mlme ifstate request\n");
341 ifstatemsg = (struct p80211msg_lnxreq_ifstate *)msg;
342 result =
343 prism2sta_ifstate(wlandev,
344 ifstatemsg->ifstate.data);
345 ifstatemsg->resultcode.status =
346 P80211ENUM_msgitem_status_data_ok;
347 ifstatemsg->resultcode.data = result;
348 result = 0;
349 }
350 break;
351 case DIDmsg_lnxreq_wlansniff:
352 pr_debug("Received mlme wlansniff request\n");
353 result = prism2mgmt_wlansniff(wlandev, msg);
354 break;
355 case DIDmsg_lnxreq_autojoin:
356 pr_debug("Received mlme autojoin request\n");
357 result = prism2mgmt_autojoin(wlandev, msg);
358 break;
359 case DIDmsg_lnxreq_commsquality:{
360 struct p80211msg_lnxreq_commsquality *qualmsg;
361
362 pr_debug("Received commsquality request\n");
363
364 qualmsg = (struct p80211msg_lnxreq_commsquality *)msg;
365
366 qualmsg->link.status =
367 P80211ENUM_msgitem_status_data_ok;
368 qualmsg->level.status =
369 P80211ENUM_msgitem_status_data_ok;
370 qualmsg->noise.status =
371 P80211ENUM_msgitem_status_data_ok;
372
373 qualmsg->link.data = le16_to_cpu(hw->qual.CQ_currBSS);
374 qualmsg->level.data = le16_to_cpu(hw->qual.ASL_currBSS);
375 qualmsg->noise.data = le16_to_cpu(hw->qual.ANL_currFC);
376 qualmsg->txrate.data = hw->txrate;
377
378 break;
379 }
380 default:
381 netdev_warn(wlandev->netdev,
382 "Unknown mgmt request message 0x%08x",
383 msg->msgcode);
384 break;
385 }
386
387 return result;
388 }
389
390 /*
391 * prism2sta_ifstate
392 *
393 * Interface state. This is the primary WLAN interface enable/disable
394 * handler. Following the driver/load/deviceprobe sequence, this
395 * function must be called with a state of "enable" before any other
396 * commands will be accepted.
397 *
398 * Arguments:
399 * wlandev wlan device structure
400 * msgp ptr to msg buffer
401 *
402 * Returns:
403 * A p80211 message resultcode value.
404 *
405 * Side effects:
406 *
407 * Call context:
408 * process thread (usually)
409 * interrupt
410 */
prism2sta_ifstate(struct wlandevice * wlandev,u32 ifstate)411 u32 prism2sta_ifstate(struct wlandevice *wlandev, u32 ifstate)
412 {
413 struct hfa384x *hw = wlandev->priv;
414 u32 result;
415
416 result = P80211ENUM_resultcode_implementation_failure;
417
418 pr_debug("Current MSD state(%d), requesting(%d)\n",
419 wlandev->msdstate, ifstate);
420 switch (ifstate) {
421 case P80211ENUM_ifstate_fwload:
422 switch (wlandev->msdstate) {
423 case WLAN_MSD_HWPRESENT:
424 wlandev->msdstate = WLAN_MSD_FWLOAD_PENDING;
425 /*
426 * Initialize the device+driver sufficiently
427 * for firmware loading.
428 */
429 result = hfa384x_drvr_start(hw);
430 if (result) {
431 netdev_err(wlandev->netdev,
432 "hfa384x_drvr_start() failed,result=%d\n",
433 (int)result);
434 result =
435 P80211ENUM_resultcode_implementation_failure;
436 wlandev->msdstate = WLAN_MSD_HWPRESENT;
437 break;
438 }
439 wlandev->msdstate = WLAN_MSD_FWLOAD;
440 result = P80211ENUM_resultcode_success;
441 break;
442 case WLAN_MSD_FWLOAD:
443 hfa384x_cmd_initialize(hw);
444 result = P80211ENUM_resultcode_success;
445 break;
446 case WLAN_MSD_RUNNING:
447 netdev_warn(wlandev->netdev,
448 "Cannot enter fwload state from enable state, you must disable first.\n");
449 result = P80211ENUM_resultcode_invalid_parameters;
450 break;
451 case WLAN_MSD_HWFAIL:
452 default:
453 /* probe() had a problem or the msdstate contains
454 * an unrecognized value, there's nothing we can do.
455 */
456 result = P80211ENUM_resultcode_implementation_failure;
457 break;
458 }
459 break;
460 case P80211ENUM_ifstate_enable:
461 switch (wlandev->msdstate) {
462 case WLAN_MSD_HWPRESENT:
463 case WLAN_MSD_FWLOAD:
464 wlandev->msdstate = WLAN_MSD_RUNNING_PENDING;
465 /* Initialize the device+driver for full
466 * operation. Note that this might me an FWLOAD to
467 * to RUNNING transition so we must not do a chip
468 * or board level reset. Note that on failure,
469 * the MSD state is set to HWPRESENT because we
470 * can't make any assumptions about the state
471 * of the hardware or a previous firmware load.
472 */
473 result = hfa384x_drvr_start(hw);
474 if (result) {
475 netdev_err(wlandev->netdev,
476 "hfa384x_drvr_start() failed,result=%d\n",
477 (int)result);
478 result =
479 P80211ENUM_resultcode_implementation_failure;
480 wlandev->msdstate = WLAN_MSD_HWPRESENT;
481 break;
482 }
483
484 result = prism2sta_getcardinfo(wlandev);
485 if (result) {
486 netdev_err(wlandev->netdev,
487 "prism2sta_getcardinfo() failed,result=%d\n",
488 (int)result);
489 result =
490 P80211ENUM_resultcode_implementation_failure;
491 hfa384x_drvr_stop(hw);
492 wlandev->msdstate = WLAN_MSD_HWPRESENT;
493 break;
494 }
495 result = prism2sta_globalsetup(wlandev);
496 if (result) {
497 netdev_err(wlandev->netdev,
498 "prism2sta_globalsetup() failed,result=%d\n",
499 (int)result);
500 result =
501 P80211ENUM_resultcode_implementation_failure;
502 hfa384x_drvr_stop(hw);
503 wlandev->msdstate = WLAN_MSD_HWPRESENT;
504 break;
505 }
506 wlandev->msdstate = WLAN_MSD_RUNNING;
507 hw->join_ap = 0;
508 hw->join_retries = 60;
509 result = P80211ENUM_resultcode_success;
510 break;
511 case WLAN_MSD_RUNNING:
512 /* Do nothing, we're already in this state. */
513 result = P80211ENUM_resultcode_success;
514 break;
515 case WLAN_MSD_HWFAIL:
516 default:
517 /* probe() had a problem or the msdstate contains
518 * an unrecognized value, there's nothing we can do.
519 */
520 result = P80211ENUM_resultcode_implementation_failure;
521 break;
522 }
523 break;
524 case P80211ENUM_ifstate_disable:
525 switch (wlandev->msdstate) {
526 case WLAN_MSD_HWPRESENT:
527 /* Do nothing, we're already in this state. */
528 result = P80211ENUM_resultcode_success;
529 break;
530 case WLAN_MSD_FWLOAD:
531 case WLAN_MSD_RUNNING:
532 wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING;
533 /*
534 * TODO: Shut down the MAC completely. Here a chip
535 * or board level reset is probably called for.
536 * After a "disable" _all_ results are lost, even
537 * those from a fwload.
538 */
539 if (!wlandev->hwremoved)
540 netif_carrier_off(wlandev->netdev);
541
542 hfa384x_drvr_stop(hw);
543
544 wlandev->macmode = WLAN_MACMODE_NONE;
545 wlandev->msdstate = WLAN_MSD_HWPRESENT;
546 result = P80211ENUM_resultcode_success;
547 break;
548 case WLAN_MSD_HWFAIL:
549 default:
550 /* probe() had a problem or the msdstate contains
551 * an unrecognized value, there's nothing we can do.
552 */
553 result = P80211ENUM_resultcode_implementation_failure;
554 break;
555 }
556 break;
557 default:
558 result = P80211ENUM_resultcode_invalid_parameters;
559 break;
560 }
561
562 return result;
563 }
564
565 /*
566 * prism2sta_getcardinfo
567 *
568 * Collect the NICID, firmware version and any other identifiers
569 * we'd like to have in host-side data structures.
570 *
571 * Arguments:
572 * wlandev wlan device structure
573 *
574 * Returns:
575 * 0 success
576 * >0 f/w reported error
577 * <0 driver reported error
578 *
579 * Side effects:
580 *
581 * Call context:
582 * Either.
583 */
prism2sta_getcardinfo(struct wlandevice * wlandev)584 static int prism2sta_getcardinfo(struct wlandevice *wlandev)
585 {
586 int result = 0;
587 struct hfa384x *hw = wlandev->priv;
588 u16 temp;
589 u8 snum[HFA384x_RID_NICSERIALNUMBER_LEN];
590
591 /* Collect version and compatibility info */
592 /* Some are critical, some are not */
593 /* NIC identity */
594 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICIDENTITY,
595 &hw->ident_nic,
596 sizeof(struct hfa384x_compident));
597 if (result) {
598 netdev_err(wlandev->netdev, "Failed to retrieve NICIDENTITY\n");
599 goto failed;
600 }
601
602 /* get all the nic id fields in host byte order */
603 hw->ident_nic.id = le16_to_cpu(hw->ident_nic.id);
604 hw->ident_nic.variant = le16_to_cpu(hw->ident_nic.variant);
605 hw->ident_nic.major = le16_to_cpu(hw->ident_nic.major);
606 hw->ident_nic.minor = le16_to_cpu(hw->ident_nic.minor);
607
608 netdev_info(wlandev->netdev, "ident: nic h/w: id=0x%02x %d.%d.%d\n",
609 hw->ident_nic.id, hw->ident_nic.major,
610 hw->ident_nic.minor, hw->ident_nic.variant);
611
612 /* Primary f/w identity */
613 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRIIDENTITY,
614 &hw->ident_pri_fw,
615 sizeof(struct hfa384x_compident));
616 if (result) {
617 netdev_err(wlandev->netdev, "Failed to retrieve PRIIDENTITY\n");
618 goto failed;
619 }
620
621 /* get all the private fw id fields in host byte order */
622 hw->ident_pri_fw.id = le16_to_cpu(hw->ident_pri_fw.id);
623 hw->ident_pri_fw.variant = le16_to_cpu(hw->ident_pri_fw.variant);
624 hw->ident_pri_fw.major = le16_to_cpu(hw->ident_pri_fw.major);
625 hw->ident_pri_fw.minor = le16_to_cpu(hw->ident_pri_fw.minor);
626
627 netdev_info(wlandev->netdev, "ident: pri f/w: id=0x%02x %d.%d.%d\n",
628 hw->ident_pri_fw.id, hw->ident_pri_fw.major,
629 hw->ident_pri_fw.minor, hw->ident_pri_fw.variant);
630
631 /* Station (Secondary?) f/w identity */
632 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STAIDENTITY,
633 &hw->ident_sta_fw,
634 sizeof(struct hfa384x_compident));
635 if (result) {
636 netdev_err(wlandev->netdev, "Failed to retrieve STAIDENTITY\n");
637 goto failed;
638 }
639
640 if (hw->ident_nic.id < 0x8000) {
641 netdev_err(wlandev->netdev,
642 "FATAL: Card is not an Intersil Prism2/2.5/3\n");
643 result = -1;
644 goto failed;
645 }
646
647 /* get all the station fw id fields in host byte order */
648 hw->ident_sta_fw.id = le16_to_cpu(hw->ident_sta_fw.id);
649 hw->ident_sta_fw.variant = le16_to_cpu(hw->ident_sta_fw.variant);
650 hw->ident_sta_fw.major = le16_to_cpu(hw->ident_sta_fw.major);
651 hw->ident_sta_fw.minor = le16_to_cpu(hw->ident_sta_fw.minor);
652
653 /* strip out the 'special' variant bits */
654 hw->mm_mods = hw->ident_sta_fw.variant & (BIT(14) | BIT(15));
655 hw->ident_sta_fw.variant &= ~((u16)(BIT(14) | BIT(15)));
656
657 if (hw->ident_sta_fw.id == 0x1f) {
658 netdev_info(wlandev->netdev,
659 "ident: sta f/w: id=0x%02x %d.%d.%d\n",
660 hw->ident_sta_fw.id, hw->ident_sta_fw.major,
661 hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
662 } else {
663 netdev_info(wlandev->netdev,
664 "ident: ap f/w: id=0x%02x %d.%d.%d\n",
665 hw->ident_sta_fw.id, hw->ident_sta_fw.major,
666 hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
667 netdev_err(wlandev->netdev, "Unsupported Tertiary AP firmware loaded!\n");
668 goto failed;
669 }
670
671 /* Compatibility range, Modem supplier */
672 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_MFISUPRANGE,
673 &hw->cap_sup_mfi,
674 sizeof(struct hfa384x_caplevel));
675 if (result) {
676 netdev_err(wlandev->netdev, "Failed to retrieve MFISUPRANGE\n");
677 goto failed;
678 }
679
680 /* get all the Compatibility range, modem interface supplier
681 * fields in byte order
682 */
683 hw->cap_sup_mfi.role = le16_to_cpu(hw->cap_sup_mfi.role);
684 hw->cap_sup_mfi.id = le16_to_cpu(hw->cap_sup_mfi.id);
685 hw->cap_sup_mfi.variant = le16_to_cpu(hw->cap_sup_mfi.variant);
686 hw->cap_sup_mfi.bottom = le16_to_cpu(hw->cap_sup_mfi.bottom);
687 hw->cap_sup_mfi.top = le16_to_cpu(hw->cap_sup_mfi.top);
688
689 netdev_info(wlandev->netdev,
690 "MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
691 hw->cap_sup_mfi.role, hw->cap_sup_mfi.id,
692 hw->cap_sup_mfi.variant, hw->cap_sup_mfi.bottom,
693 hw->cap_sup_mfi.top);
694
695 /* Compatibility range, Controller supplier */
696 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CFISUPRANGE,
697 &hw->cap_sup_cfi,
698 sizeof(struct hfa384x_caplevel));
699 if (result) {
700 netdev_err(wlandev->netdev, "Failed to retrieve CFISUPRANGE\n");
701 goto failed;
702 }
703
704 /* get all the Compatibility range, controller interface supplier
705 * fields in byte order
706 */
707 hw->cap_sup_cfi.role = le16_to_cpu(hw->cap_sup_cfi.role);
708 hw->cap_sup_cfi.id = le16_to_cpu(hw->cap_sup_cfi.id);
709 hw->cap_sup_cfi.variant = le16_to_cpu(hw->cap_sup_cfi.variant);
710 hw->cap_sup_cfi.bottom = le16_to_cpu(hw->cap_sup_cfi.bottom);
711 hw->cap_sup_cfi.top = le16_to_cpu(hw->cap_sup_cfi.top);
712
713 netdev_info(wlandev->netdev,
714 "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
715 hw->cap_sup_cfi.role, hw->cap_sup_cfi.id,
716 hw->cap_sup_cfi.variant, hw->cap_sup_cfi.bottom,
717 hw->cap_sup_cfi.top);
718
719 /* Compatibility range, Primary f/w supplier */
720 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRISUPRANGE,
721 &hw->cap_sup_pri,
722 sizeof(struct hfa384x_caplevel));
723 if (result) {
724 netdev_err(wlandev->netdev, "Failed to retrieve PRISUPRANGE\n");
725 goto failed;
726 }
727
728 /* get all the Compatibility range, primary firmware supplier
729 * fields in byte order
730 */
731 hw->cap_sup_pri.role = le16_to_cpu(hw->cap_sup_pri.role);
732 hw->cap_sup_pri.id = le16_to_cpu(hw->cap_sup_pri.id);
733 hw->cap_sup_pri.variant = le16_to_cpu(hw->cap_sup_pri.variant);
734 hw->cap_sup_pri.bottom = le16_to_cpu(hw->cap_sup_pri.bottom);
735 hw->cap_sup_pri.top = le16_to_cpu(hw->cap_sup_pri.top);
736
737 netdev_info(wlandev->netdev,
738 "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
739 hw->cap_sup_pri.role, hw->cap_sup_pri.id,
740 hw->cap_sup_pri.variant, hw->cap_sup_pri.bottom,
741 hw->cap_sup_pri.top);
742
743 /* Compatibility range, Station f/w supplier */
744 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STASUPRANGE,
745 &hw->cap_sup_sta,
746 sizeof(struct hfa384x_caplevel));
747 if (result) {
748 netdev_err(wlandev->netdev, "Failed to retrieve STASUPRANGE\n");
749 goto failed;
750 }
751
752 /* get all the Compatibility range, station firmware supplier
753 * fields in byte order
754 */
755 hw->cap_sup_sta.role = le16_to_cpu(hw->cap_sup_sta.role);
756 hw->cap_sup_sta.id = le16_to_cpu(hw->cap_sup_sta.id);
757 hw->cap_sup_sta.variant = le16_to_cpu(hw->cap_sup_sta.variant);
758 hw->cap_sup_sta.bottom = le16_to_cpu(hw->cap_sup_sta.bottom);
759 hw->cap_sup_sta.top = le16_to_cpu(hw->cap_sup_sta.top);
760
761 if (hw->cap_sup_sta.id == 0x04) {
762 netdev_info(wlandev->netdev,
763 "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
764 hw->cap_sup_sta.role, hw->cap_sup_sta.id,
765 hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
766 hw->cap_sup_sta.top);
767 } else {
768 netdev_info(wlandev->netdev,
769 "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
770 hw->cap_sup_sta.role, hw->cap_sup_sta.id,
771 hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
772 hw->cap_sup_sta.top);
773 }
774
775 /* Compatibility range, primary f/w actor, CFI supplier */
776 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRI_CFIACTRANGES,
777 &hw->cap_act_pri_cfi,
778 sizeof(struct hfa384x_caplevel));
779 if (result) {
780 netdev_err(wlandev->netdev, "Failed to retrieve PRI_CFIACTRANGES\n");
781 goto failed;
782 }
783
784 /* get all the Compatibility range, primary f/w actor, CFI supplier
785 * fields in byte order
786 */
787 hw->cap_act_pri_cfi.role = le16_to_cpu(hw->cap_act_pri_cfi.role);
788 hw->cap_act_pri_cfi.id = le16_to_cpu(hw->cap_act_pri_cfi.id);
789 hw->cap_act_pri_cfi.variant = le16_to_cpu(hw->cap_act_pri_cfi.variant);
790 hw->cap_act_pri_cfi.bottom = le16_to_cpu(hw->cap_act_pri_cfi.bottom);
791 hw->cap_act_pri_cfi.top = le16_to_cpu(hw->cap_act_pri_cfi.top);
792
793 netdev_info(wlandev->netdev,
794 "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
795 hw->cap_act_pri_cfi.role, hw->cap_act_pri_cfi.id,
796 hw->cap_act_pri_cfi.variant, hw->cap_act_pri_cfi.bottom,
797 hw->cap_act_pri_cfi.top);
798
799 /* Compatibility range, sta f/w actor, CFI supplier */
800 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_CFIACTRANGES,
801 &hw->cap_act_sta_cfi,
802 sizeof(struct hfa384x_caplevel));
803 if (result) {
804 netdev_err(wlandev->netdev, "Failed to retrieve STA_CFIACTRANGES\n");
805 goto failed;
806 }
807
808 /* get all the Compatibility range, station f/w actor, CFI supplier
809 * fields in byte order
810 */
811 hw->cap_act_sta_cfi.role = le16_to_cpu(hw->cap_act_sta_cfi.role);
812 hw->cap_act_sta_cfi.id = le16_to_cpu(hw->cap_act_sta_cfi.id);
813 hw->cap_act_sta_cfi.variant = le16_to_cpu(hw->cap_act_sta_cfi.variant);
814 hw->cap_act_sta_cfi.bottom = le16_to_cpu(hw->cap_act_sta_cfi.bottom);
815 hw->cap_act_sta_cfi.top = le16_to_cpu(hw->cap_act_sta_cfi.top);
816
817 netdev_info(wlandev->netdev,
818 "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
819 hw->cap_act_sta_cfi.role, hw->cap_act_sta_cfi.id,
820 hw->cap_act_sta_cfi.variant, hw->cap_act_sta_cfi.bottom,
821 hw->cap_act_sta_cfi.top);
822
823 /* Compatibility range, sta f/w actor, MFI supplier */
824 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_MFIACTRANGES,
825 &hw->cap_act_sta_mfi,
826 sizeof(struct hfa384x_caplevel));
827 if (result) {
828 netdev_err(wlandev->netdev, "Failed to retrieve STA_MFIACTRANGES\n");
829 goto failed;
830 }
831
832 /* get all the Compatibility range, station f/w actor, MFI supplier
833 * fields in byte order
834 */
835 hw->cap_act_sta_mfi.role = le16_to_cpu(hw->cap_act_sta_mfi.role);
836 hw->cap_act_sta_mfi.id = le16_to_cpu(hw->cap_act_sta_mfi.id);
837 hw->cap_act_sta_mfi.variant = le16_to_cpu(hw->cap_act_sta_mfi.variant);
838 hw->cap_act_sta_mfi.bottom = le16_to_cpu(hw->cap_act_sta_mfi.bottom);
839 hw->cap_act_sta_mfi.top = le16_to_cpu(hw->cap_act_sta_mfi.top);
840
841 netdev_info(wlandev->netdev,
842 "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
843 hw->cap_act_sta_mfi.role, hw->cap_act_sta_mfi.id,
844 hw->cap_act_sta_mfi.variant, hw->cap_act_sta_mfi.bottom,
845 hw->cap_act_sta_mfi.top);
846
847 /* Serial Number */
848 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICSERIALNUMBER,
849 snum, HFA384x_RID_NICSERIALNUMBER_LEN);
850 if (!result) {
851 netdev_info(wlandev->netdev, "Prism2 card SN: %*pEhp\n",
852 HFA384x_RID_NICSERIALNUMBER_LEN, snum);
853 } else {
854 netdev_err(wlandev->netdev, "Failed to retrieve Prism2 Card SN\n");
855 goto failed;
856 }
857
858 /* Collect the MAC address */
859 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFOWNMACADDR,
860 wlandev->netdev->dev_addr, ETH_ALEN);
861 if (result != 0) {
862 netdev_err(wlandev->netdev, "Failed to retrieve mac address\n");
863 goto failed;
864 }
865
866 /* short preamble is always implemented */
867 wlandev->nsdcaps |= P80211_NSDCAP_SHORT_PREAMBLE;
868
869 /* find out if hardware wep is implemented */
870 hfa384x_drvr_getconfig16(hw, HFA384x_RID_PRIVACYOPTIMP, &temp);
871 if (temp)
872 wlandev->nsdcaps |= P80211_NSDCAP_HARDWAREWEP;
873
874 /* get the dBm Scaling constant */
875 hfa384x_drvr_getconfig16(hw, HFA384x_RID_CNFDBMADJUST, &temp);
876 hw->dbmadjust = temp;
877
878 /* Only enable scan by default on newer firmware */
879 if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
880 hw->ident_sta_fw.minor,
881 hw->ident_sta_fw.variant) <
882 HFA384x_FIRMWARE_VERSION(1, 5, 5)) {
883 wlandev->nsdcaps |= P80211_NSDCAP_NOSCAN;
884 }
885
886 /* TODO: Set any internally managed config items */
887
888 goto done;
889 failed:
890 netdev_err(wlandev->netdev, "Failed, result=%d\n", result);
891 done:
892 return result;
893 }
894
895 /*
896 * prism2sta_globalsetup
897 *
898 * Set any global RIDs that we want to set at device activation.
899 *
900 * Arguments:
901 * wlandev wlan device structure
902 *
903 * Returns:
904 * 0 success
905 * >0 f/w reported error
906 * <0 driver reported error
907 *
908 * Side effects:
909 *
910 * Call context:
911 * process thread
912 */
prism2sta_globalsetup(struct wlandevice * wlandev)913 static int prism2sta_globalsetup(struct wlandevice *wlandev)
914 {
915 struct hfa384x *hw = wlandev->priv;
916
917 /* Set the maximum frame size */
918 return hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN,
919 WLAN_DATA_MAXLEN);
920 }
921
prism2sta_setmulticast(struct wlandevice * wlandev,struct net_device * dev)922 static int prism2sta_setmulticast(struct wlandevice *wlandev,
923 struct net_device *dev)
924 {
925 int result = 0;
926 struct hfa384x *hw = wlandev->priv;
927
928 u16 promisc;
929
930 /* If we're not ready, what's the point? */
931 if (hw->state != HFA384x_STATE_RUNNING)
932 goto exit;
933
934 if ((dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0)
935 promisc = P80211ENUM_truth_true;
936 else
937 promisc = P80211ENUM_truth_false;
938
939 result =
940 hfa384x_drvr_setconfig16_async(hw, HFA384x_RID_PROMISCMODE,
941 promisc);
942 exit:
943 return result;
944 }
945
946 /*
947 * prism2sta_inf_handover
948 *
949 * Handles the receipt of a Handover info frame. Should only be present
950 * in APs only.
951 *
952 * Arguments:
953 * wlandev wlan device structure
954 * inf ptr to info frame (contents in hfa384x order)
955 *
956 * Returns:
957 * nothing
958 *
959 * Side effects:
960 *
961 * Call context:
962 * interrupt
963 */
prism2sta_inf_handover(struct wlandevice * wlandev,struct hfa384x_InfFrame * inf)964 static void prism2sta_inf_handover(struct wlandevice *wlandev,
965 struct hfa384x_InfFrame *inf)
966 {
967 pr_debug("received infoframe:HANDOVER (unhandled)\n");
968 }
969
970 /*
971 * prism2sta_inf_tallies
972 *
973 * Handles the receipt of a CommTallies info frame.
974 *
975 * Arguments:
976 * wlandev wlan device structure
977 * inf ptr to info frame (contents in hfa384x order)
978 *
979 * Returns:
980 * nothing
981 *
982 * Side effects:
983 *
984 * Call context:
985 * interrupt
986 */
prism2sta_inf_tallies(struct wlandevice * wlandev,struct hfa384x_InfFrame * inf)987 static void prism2sta_inf_tallies(struct wlandevice *wlandev,
988 struct hfa384x_InfFrame *inf)
989 {
990 struct hfa384x *hw = wlandev->priv;
991 u16 *src16;
992 u32 *dst;
993 u32 *src32;
994 int i;
995 int cnt;
996
997 /*
998 * Determine if these are 16-bit or 32-bit tallies, based on the
999 * record length of the info record.
1000 */
1001
1002 cnt = sizeof(struct hfa384x_CommTallies32) / sizeof(u32);
1003 if (inf->framelen > 22) {
1004 dst = (u32 *)&hw->tallies;
1005 src32 = (u32 *)&inf->info.commtallies32;
1006 for (i = 0; i < cnt; i++, dst++, src32++)
1007 *dst += le32_to_cpu(*src32);
1008 } else {
1009 dst = (u32 *)&hw->tallies;
1010 src16 = (u16 *)&inf->info.commtallies16;
1011 for (i = 0; i < cnt; i++, dst++, src16++)
1012 *dst += le16_to_cpu(*src16);
1013 }
1014 }
1015
1016 /*
1017 * prism2sta_inf_scanresults
1018 *
1019 * Handles the receipt of a Scan Results info frame.
1020 *
1021 * Arguments:
1022 * wlandev wlan device structure
1023 * inf ptr to info frame (contents in hfa384x order)
1024 *
1025 * Returns:
1026 * nothing
1027 *
1028 * Side effects:
1029 *
1030 * Call context:
1031 * interrupt
1032 */
prism2sta_inf_scanresults(struct wlandevice * wlandev,struct hfa384x_InfFrame * inf)1033 static void prism2sta_inf_scanresults(struct wlandevice *wlandev,
1034 struct hfa384x_InfFrame *inf)
1035 {
1036 struct hfa384x *hw = wlandev->priv;
1037 int nbss;
1038 struct hfa384x_ScanResult *sr = &(inf->info.scanresult);
1039 int i;
1040 struct hfa384x_JoinRequest_data joinreq;
1041 int result;
1042
1043 /* Get the number of results, first in bytes, then in results */
1044 nbss = (inf->framelen * sizeof(u16)) -
1045 sizeof(inf->infotype) - sizeof(inf->info.scanresult.scanreason);
1046 nbss /= sizeof(struct hfa384x_ScanResultSub);
1047
1048 /* Print em */
1049 pr_debug("rx scanresults, reason=%d, nbss=%d:\n",
1050 inf->info.scanresult.scanreason, nbss);
1051 for (i = 0; i < nbss; i++) {
1052 pr_debug("chid=%d anl=%d sl=%d bcnint=%d\n",
1053 sr->result[i].chid,
1054 sr->result[i].anl,
1055 sr->result[i].sl, sr->result[i].bcnint);
1056 pr_debug(" capinfo=0x%04x proberesp_rate=%d\n",
1057 sr->result[i].capinfo, sr->result[i].proberesp_rate);
1058 }
1059 /* issue a join request */
1060 joinreq.channel = sr->result[0].chid;
1061 memcpy(joinreq.bssid, sr->result[0].bssid, WLAN_BSSID_LEN);
1062 result = hfa384x_drvr_setconfig(hw,
1063 HFA384x_RID_JOINREQUEST,
1064 &joinreq, HFA384x_RID_JOINREQUEST_LEN);
1065 if (result) {
1066 netdev_err(wlandev->netdev, "setconfig(joinreq) failed, result=%d\n",
1067 result);
1068 }
1069 }
1070
1071 /*
1072 * prism2sta_inf_hostscanresults
1073 *
1074 * Handles the receipt of a Scan Results info frame.
1075 *
1076 * Arguments:
1077 * wlandev wlan device structure
1078 * inf ptr to info frame (contents in hfa384x order)
1079 *
1080 * Returns:
1081 * nothing
1082 *
1083 * Side effects:
1084 *
1085 * Call context:
1086 * interrupt
1087 */
prism2sta_inf_hostscanresults(struct wlandevice * wlandev,struct hfa384x_InfFrame * inf)1088 static void prism2sta_inf_hostscanresults(struct wlandevice *wlandev,
1089 struct hfa384x_InfFrame *inf)
1090 {
1091 struct hfa384x *hw = wlandev->priv;
1092 int nbss;
1093
1094 nbss = (inf->framelen - 3) / 32;
1095 pr_debug("Received %d hostscan results\n", nbss);
1096
1097 if (nbss > 32)
1098 nbss = 32;
1099
1100 kfree(hw->scanresults);
1101
1102 hw->scanresults = kmemdup(inf, sizeof(struct hfa384x_InfFrame), GFP_ATOMIC);
1103
1104 if (nbss == 0)
1105 nbss = -1;
1106
1107 /* Notify/wake the sleeping caller. */
1108 hw->scanflag = nbss;
1109 wake_up_interruptible(&hw->cmdq);
1110 };
1111
1112 /*
1113 * prism2sta_inf_chinforesults
1114 *
1115 * Handles the receipt of a Channel Info Results info frame.
1116 *
1117 * Arguments:
1118 * wlandev wlan device structure
1119 * inf ptr to info frame (contents in hfa384x order)
1120 *
1121 * Returns:
1122 * nothing
1123 *
1124 * Side effects:
1125 *
1126 * Call context:
1127 * interrupt
1128 */
prism2sta_inf_chinforesults(struct wlandevice * wlandev,struct hfa384x_InfFrame * inf)1129 static void prism2sta_inf_chinforesults(struct wlandevice *wlandev,
1130 struct hfa384x_InfFrame *inf)
1131 {
1132 struct hfa384x *hw = wlandev->priv;
1133 unsigned int i, n;
1134
1135 hw->channel_info.results.scanchannels =
1136 le16_to_cpu(inf->info.chinforesult.scanchannels);
1137
1138 for (i = 0, n = 0; i < HFA384x_CHINFORESULT_MAX; i++) {
1139 struct hfa384x_ChInfoResultSub *result;
1140 struct hfa384x_ChInfoResultSub *chinforesult;
1141 int chan;
1142
1143 if (!(hw->channel_info.results.scanchannels & (1 << i)))
1144 continue;
1145
1146 result = &inf->info.chinforesult.result[n];
1147 chan = le16_to_cpu(result->chid) - 1;
1148
1149 if (chan < 0 || chan >= HFA384x_CHINFORESULT_MAX)
1150 continue;
1151
1152 chinforesult = &hw->channel_info.results.result[chan];
1153 chinforesult->chid = chan;
1154 chinforesult->anl = le16_to_cpu(result->anl);
1155 chinforesult->pnl = le16_to_cpu(result->pnl);
1156 chinforesult->active = le16_to_cpu(result->active);
1157
1158 pr_debug("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n",
1159 chan + 1,
1160 (chinforesult->active & HFA384x_CHINFORESULT_BSSACTIVE)
1161 ? "signal" : "noise",
1162 chinforesult->anl, chinforesult->pnl,
1163 (chinforesult->active & HFA384x_CHINFORESULT_PCFACTIVE)
1164 ? 1 : 0);
1165 n++;
1166 }
1167 atomic_set(&hw->channel_info.done, 2);
1168
1169 hw->channel_info.count = n;
1170 }
1171
prism2sta_processing_defer(struct work_struct * data)1172 void prism2sta_processing_defer(struct work_struct *data)
1173 {
1174 struct hfa384x *hw = container_of(data, struct hfa384x, link_bh);
1175 struct wlandevice *wlandev = hw->wlandev;
1176 struct hfa384x_bytestr32 ssid;
1177 int result;
1178
1179 /* First let's process the auth frames */
1180 {
1181 struct sk_buff *skb;
1182 struct hfa384x_InfFrame *inf;
1183
1184 while ((skb = skb_dequeue(&hw->authq))) {
1185 inf = (struct hfa384x_InfFrame *)skb->data;
1186 prism2sta_inf_authreq_defer(wlandev, inf);
1187 }
1188
1189 }
1190
1191 /* Now let's handle the linkstatus stuff */
1192 if (hw->link_status == hw->link_status_new)
1193 return;
1194
1195 hw->link_status = hw->link_status_new;
1196
1197 switch (hw->link_status) {
1198 case HFA384x_LINK_NOTCONNECTED:
1199 /* I'm currently assuming that this is the initial link
1200 * state. It should only be possible immediately
1201 * following an Enable command.
1202 * Response:
1203 * Block Transmits, Ignore receives of data frames
1204 */
1205 netif_carrier_off(wlandev->netdev);
1206
1207 netdev_info(wlandev->netdev, "linkstatus=NOTCONNECTED (unhandled)\n");
1208 break;
1209
1210 case HFA384x_LINK_CONNECTED:
1211 /* This one indicates a successful scan/join/auth/assoc.
1212 * When we have the full MLME complement, this event will
1213 * signify successful completion of both mlme_authenticate
1214 * and mlme_associate. State management will get a little
1215 * ugly here.
1216 * Response:
1217 * Indicate authentication and/or association
1218 * Enable Transmits, Receives and pass up data frames
1219 */
1220
1221 netif_carrier_on(wlandev->netdev);
1222
1223 /* If we are joining a specific AP, set our
1224 * state and reset retries
1225 */
1226 if (hw->join_ap == 1)
1227 hw->join_ap = 2;
1228 hw->join_retries = 60;
1229
1230 /* Don't call this in monitor mode */
1231 if (wlandev->netdev->type == ARPHRD_ETHER) {
1232 u16 portstatus;
1233
1234 netdev_info(wlandev->netdev, "linkstatus=CONNECTED\n");
1235
1236 /* For non-usb devices, we can use the sync versions */
1237 /* Collect the BSSID, and set state to allow tx */
1238
1239 result = hfa384x_drvr_getconfig(hw,
1240 HFA384x_RID_CURRENTBSSID,
1241 wlandev->bssid,
1242 WLAN_BSSID_LEN);
1243 if (result) {
1244 pr_debug
1245 ("getconfig(0x%02x) failed, result = %d\n",
1246 HFA384x_RID_CURRENTBSSID, result);
1247 return;
1248 }
1249
1250 result = hfa384x_drvr_getconfig(hw,
1251 HFA384x_RID_CURRENTSSID,
1252 &ssid, sizeof(ssid));
1253 if (result) {
1254 pr_debug
1255 ("getconfig(0x%02x) failed, result = %d\n",
1256 HFA384x_RID_CURRENTSSID, result);
1257 return;
1258 }
1259 prism2mgmt_bytestr2pstr(
1260 (struct hfa384x_bytestr *)&ssid,
1261 (struct p80211pstrd *)&wlandev->ssid);
1262
1263 /* Collect the port status */
1264 result = hfa384x_drvr_getconfig16(hw,
1265 HFA384x_RID_PORTSTATUS,
1266 &portstatus);
1267 if (result) {
1268 pr_debug
1269 ("getconfig(0x%02x) failed, result = %d\n",
1270 HFA384x_RID_PORTSTATUS, result);
1271 return;
1272 }
1273 wlandev->macmode =
1274 (portstatus == HFA384x_PSTATUS_CONN_IBSS) ?
1275 WLAN_MACMODE_IBSS_STA : WLAN_MACMODE_ESS_STA;
1276
1277 /* signal back up to cfg80211 layer */
1278 prism2_connect_result(wlandev, P80211ENUM_truth_false);
1279
1280 /* Get the ball rolling on the comms quality stuff */
1281 prism2sta_commsqual_defer(&hw->commsqual_bh);
1282 }
1283 break;
1284
1285 case HFA384x_LINK_DISCONNECTED:
1286 /* This one indicates that our association is gone. We've
1287 * lost connection with the AP and/or been disassociated.
1288 * This indicates that the MAC has completely cleared it's
1289 * associated state. We * should send a deauth indication
1290 * (implying disassoc) up * to the MLME.
1291 * Response:
1292 * Indicate Deauthentication
1293 * Block Transmits, Ignore receives of data frames
1294 */
1295 if (wlandev->netdev->type == ARPHRD_ETHER)
1296 netdev_info(wlandev->netdev,
1297 "linkstatus=DISCONNECTED (unhandled)\n");
1298 wlandev->macmode = WLAN_MACMODE_NONE;
1299
1300 netif_carrier_off(wlandev->netdev);
1301
1302 /* signal back up to cfg80211 layer */
1303 prism2_disconnected(wlandev);
1304
1305 break;
1306
1307 case HFA384x_LINK_AP_CHANGE:
1308 /* This one indicates that the MAC has decided to and
1309 * successfully completed a change to another AP. We
1310 * should probably implement a reassociation indication
1311 * in response to this one. I'm thinking that the the
1312 * p80211 layer needs to be notified in case of
1313 * buffering/queueing issues. User mode also needs to be
1314 * notified so that any BSS dependent elements can be
1315 * updated.
1316 * associated state. We * should send a deauth indication
1317 * (implying disassoc) up * to the MLME.
1318 * Response:
1319 * Indicate Reassociation
1320 * Enable Transmits, Receives and pass up data frames
1321 */
1322 netdev_info(wlandev->netdev, "linkstatus=AP_CHANGE\n");
1323
1324 result = hfa384x_drvr_getconfig(hw,
1325 HFA384x_RID_CURRENTBSSID,
1326 wlandev->bssid, WLAN_BSSID_LEN);
1327 if (result) {
1328 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1329 HFA384x_RID_CURRENTBSSID, result);
1330 return;
1331 }
1332
1333 result = hfa384x_drvr_getconfig(hw,
1334 HFA384x_RID_CURRENTSSID,
1335 &ssid, sizeof(ssid));
1336 if (result) {
1337 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1338 HFA384x_RID_CURRENTSSID, result);
1339 return;
1340 }
1341 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *)&ssid,
1342 (struct p80211pstrd *)&wlandev->ssid);
1343
1344 hw->link_status = HFA384x_LINK_CONNECTED;
1345 netif_carrier_on(wlandev->netdev);
1346
1347 /* signal back up to cfg80211 layer */
1348 prism2_roamed(wlandev);
1349
1350 break;
1351
1352 case HFA384x_LINK_AP_OUTOFRANGE:
1353 /* This one indicates that the MAC has decided that the
1354 * AP is out of range, but hasn't found a better candidate
1355 * so the MAC maintains its "associated" state in case
1356 * we get back in range. We should block transmits and
1357 * receives in this state. Do we need an indication here?
1358 * Probably not since a polling user-mode element would
1359 * get this status from from p2PortStatus(FD40). What about
1360 * p80211?
1361 * Response:
1362 * Block Transmits, Ignore receives of data frames
1363 */
1364 netdev_info(wlandev->netdev, "linkstatus=AP_OUTOFRANGE (unhandled)\n");
1365
1366 netif_carrier_off(wlandev->netdev);
1367
1368 break;
1369
1370 case HFA384x_LINK_AP_INRANGE:
1371 /* This one indicates that the MAC has decided that the
1372 * AP is back in range. We continue working with our
1373 * existing association.
1374 * Response:
1375 * Enable Transmits, Receives and pass up data frames
1376 */
1377 netdev_info(wlandev->netdev, "linkstatus=AP_INRANGE\n");
1378
1379 hw->link_status = HFA384x_LINK_CONNECTED;
1380 netif_carrier_on(wlandev->netdev);
1381
1382 break;
1383
1384 case HFA384x_LINK_ASSOCFAIL:
1385 /* This one is actually a peer to CONNECTED. We've
1386 * requested a join for a given SSID and optionally BSSID.
1387 * We can use this one to indicate authentication and
1388 * association failures. The trick is going to be
1389 * 1) identifying the failure, and 2) state management.
1390 * Response:
1391 * Disable Transmits, Ignore receives of data frames
1392 */
1393 if (hw->join_ap && --hw->join_retries > 0) {
1394 struct hfa384x_JoinRequest_data joinreq;
1395
1396 joinreq = hw->joinreq;
1397 /* Send the join request */
1398 hfa384x_drvr_setconfig(hw,
1399 HFA384x_RID_JOINREQUEST,
1400 &joinreq,
1401 HFA384x_RID_JOINREQUEST_LEN);
1402 netdev_info(wlandev->netdev,
1403 "linkstatus=ASSOCFAIL (re-submitting join)\n");
1404 } else {
1405 netdev_info(wlandev->netdev, "linkstatus=ASSOCFAIL (unhandled)\n");
1406 }
1407
1408 netif_carrier_off(wlandev->netdev);
1409
1410 /* signal back up to cfg80211 layer */
1411 prism2_connect_result(wlandev, P80211ENUM_truth_true);
1412
1413 break;
1414
1415 default:
1416 /* This is bad, IO port problems? */
1417 netdev_warn(wlandev->netdev,
1418 "unknown linkstatus=0x%02x\n", hw->link_status);
1419 return;
1420 }
1421
1422 wlandev->linkstatus = (hw->link_status == HFA384x_LINK_CONNECTED);
1423 }
1424
1425 /*
1426 * prism2sta_inf_linkstatus
1427 *
1428 * Handles the receipt of a Link Status info frame.
1429 *
1430 * Arguments:
1431 * wlandev wlan device structure
1432 * inf ptr to info frame (contents in hfa384x order)
1433 *
1434 * Returns:
1435 * nothing
1436 *
1437 * Side effects:
1438 *
1439 * Call context:
1440 * interrupt
1441 */
prism2sta_inf_linkstatus(struct wlandevice * wlandev,struct hfa384x_InfFrame * inf)1442 static void prism2sta_inf_linkstatus(struct wlandevice *wlandev,
1443 struct hfa384x_InfFrame *inf)
1444 {
1445 struct hfa384x *hw = wlandev->priv;
1446
1447 hw->link_status_new = le16_to_cpu(inf->info.linkstatus.linkstatus);
1448
1449 schedule_work(&hw->link_bh);
1450 }
1451
1452 /*
1453 * prism2sta_inf_assocstatus
1454 *
1455 * Handles the receipt of an Association Status info frame. Should
1456 * be present in APs only.
1457 *
1458 * Arguments:
1459 * wlandev wlan device structure
1460 * inf ptr to info frame (contents in hfa384x order)
1461 *
1462 * Returns:
1463 * nothing
1464 *
1465 * Side effects:
1466 *
1467 * Call context:
1468 * interrupt
1469 */
prism2sta_inf_assocstatus(struct wlandevice * wlandev,struct hfa384x_InfFrame * inf)1470 static void prism2sta_inf_assocstatus(struct wlandevice *wlandev,
1471 struct hfa384x_InfFrame *inf)
1472 {
1473 struct hfa384x *hw = wlandev->priv;
1474 struct hfa384x_AssocStatus rec;
1475 int i;
1476
1477 memcpy(&rec, &inf->info.assocstatus, sizeof(rec));
1478 rec.assocstatus = le16_to_cpu(rec.assocstatus);
1479 rec.reason = le16_to_cpu(rec.reason);
1480
1481 /*
1482 * Find the address in the list of authenticated stations.
1483 * If it wasn't found, then this address has not been previously
1484 * authenticated and something weird has happened if this is
1485 * anything other than an "authentication failed" message.
1486 * If the address was found, then set the "associated" flag for
1487 * that station, based on whether the station is associating or
1488 * losing its association. Something weird has also happened
1489 * if we find the address in the list of authenticated stations
1490 * but we are getting an "authentication failed" message.
1491 */
1492
1493 for (i = 0; i < hw->authlist.cnt; i++)
1494 if (ether_addr_equal(rec.sta_addr, hw->authlist.addr[i]))
1495 break;
1496
1497 if (i >= hw->authlist.cnt) {
1498 if (rec.assocstatus != HFA384x_ASSOCSTATUS_AUTHFAIL)
1499 netdev_warn(wlandev->netdev,
1500 "assocstatus info frame received for non-authenticated station.\n");
1501 } else {
1502 hw->authlist.assoc[i] =
1503 (rec.assocstatus == HFA384x_ASSOCSTATUS_STAASSOC ||
1504 rec.assocstatus == HFA384x_ASSOCSTATUS_REASSOC);
1505
1506 if (rec.assocstatus == HFA384x_ASSOCSTATUS_AUTHFAIL)
1507 netdev_warn(wlandev->netdev,
1508 "authfail assocstatus info frame received for authenticated station.\n");
1509 }
1510 }
1511
1512 /*
1513 * prism2sta_inf_authreq
1514 *
1515 * Handles the receipt of an Authentication Request info frame. Should
1516 * be present in APs only.
1517 *
1518 * Arguments:
1519 * wlandev wlan device structure
1520 * inf ptr to info frame (contents in hfa384x order)
1521 *
1522 * Returns:
1523 * nothing
1524 *
1525 * Side effects:
1526 *
1527 * Call context:
1528 * interrupt
1529 *
1530 */
prism2sta_inf_authreq(struct wlandevice * wlandev,struct hfa384x_InfFrame * inf)1531 static void prism2sta_inf_authreq(struct wlandevice *wlandev,
1532 struct hfa384x_InfFrame *inf)
1533 {
1534 struct hfa384x *hw = wlandev->priv;
1535 struct sk_buff *skb;
1536
1537 skb = dev_alloc_skb(sizeof(*inf));
1538 if (skb) {
1539 skb_put(skb, sizeof(*inf));
1540 memcpy(skb->data, inf, sizeof(*inf));
1541 skb_queue_tail(&hw->authq, skb);
1542 schedule_work(&hw->link_bh);
1543 }
1544 }
1545
prism2sta_inf_authreq_defer(struct wlandevice * wlandev,struct hfa384x_InfFrame * inf)1546 static void prism2sta_inf_authreq_defer(struct wlandevice *wlandev,
1547 struct hfa384x_InfFrame *inf)
1548 {
1549 struct hfa384x *hw = wlandev->priv;
1550 struct hfa384x_authenticateStation_data rec;
1551
1552 int i, added, result, cnt;
1553 u8 *addr;
1554
1555 /*
1556 * Build the AuthenticateStation record. Initialize it for denying
1557 * authentication.
1558 */
1559
1560 ether_addr_copy(rec.address, inf->info.authreq.sta_addr);
1561 rec.status = P80211ENUM_status_unspec_failure;
1562
1563 /*
1564 * Authenticate based on the access mode.
1565 */
1566
1567 switch (hw->accessmode) {
1568 case WLAN_ACCESS_NONE:
1569
1570 /*
1571 * Deny all new authentications. However, if a station
1572 * is ALREADY authenticated, then accept it.
1573 */
1574
1575 for (i = 0; i < hw->authlist.cnt; i++)
1576 if (ether_addr_equal(rec.address,
1577 hw->authlist.addr[i])) {
1578 rec.status = P80211ENUM_status_successful;
1579 break;
1580 }
1581
1582 break;
1583
1584 case WLAN_ACCESS_ALL:
1585
1586 /*
1587 * Allow all authentications.
1588 */
1589
1590 rec.status = P80211ENUM_status_successful;
1591 break;
1592
1593 case WLAN_ACCESS_ALLOW:
1594
1595 /*
1596 * Only allow the authentication if the MAC address
1597 * is in the list of allowed addresses.
1598 *
1599 * Since this is the interrupt handler, we may be here
1600 * while the access list is in the middle of being
1601 * updated. Choose the list which is currently okay.
1602 * See "prism2mib_priv_accessallow()" for details.
1603 */
1604
1605 if (hw->allow.modify == 0) {
1606 cnt = hw->allow.cnt;
1607 addr = hw->allow.addr[0];
1608 } else {
1609 cnt = hw->allow.cnt1;
1610 addr = hw->allow.addr1[0];
1611 }
1612
1613 for (i = 0; i < cnt; i++, addr += ETH_ALEN)
1614 if (ether_addr_equal(rec.address, addr)) {
1615 rec.status = P80211ENUM_status_successful;
1616 break;
1617 }
1618
1619 break;
1620
1621 case WLAN_ACCESS_DENY:
1622
1623 /*
1624 * Allow the authentication UNLESS the MAC address is
1625 * in the list of denied addresses.
1626 *
1627 * Since this is the interrupt handler, we may be here
1628 * while the access list is in the middle of being
1629 * updated. Choose the list which is currently okay.
1630 * See "prism2mib_priv_accessdeny()" for details.
1631 */
1632
1633 if (hw->deny.modify == 0) {
1634 cnt = hw->deny.cnt;
1635 addr = hw->deny.addr[0];
1636 } else {
1637 cnt = hw->deny.cnt1;
1638 addr = hw->deny.addr1[0];
1639 }
1640
1641 rec.status = P80211ENUM_status_successful;
1642
1643 for (i = 0; i < cnt; i++, addr += ETH_ALEN)
1644 if (ether_addr_equal(rec.address, addr)) {
1645 rec.status = P80211ENUM_status_unspec_failure;
1646 break;
1647 }
1648
1649 break;
1650 }
1651
1652 /*
1653 * If the authentication is okay, then add the MAC address to the
1654 * list of authenticated stations. Don't add the address if it
1655 * is already in the list. (802.11b does not seem to disallow
1656 * a station from issuing an authentication request when the
1657 * station is already authenticated. Does this sort of thing
1658 * ever happen? We might as well do the check just in case.)
1659 */
1660
1661 added = 0;
1662
1663 if (rec.status == P80211ENUM_status_successful) {
1664 for (i = 0; i < hw->authlist.cnt; i++)
1665 if (ether_addr_equal(rec.address,
1666 hw->authlist.addr[i]))
1667 break;
1668
1669 if (i >= hw->authlist.cnt) {
1670 if (hw->authlist.cnt >= WLAN_AUTH_MAX) {
1671 rec.status = P80211ENUM_status_ap_full;
1672 } else {
1673 ether_addr_copy(
1674 hw->authlist.addr[hw->authlist.cnt],
1675 rec.address);
1676 hw->authlist.cnt++;
1677 added = 1;
1678 }
1679 }
1680 }
1681
1682 /*
1683 * Send back the results of the authentication. If this doesn't work,
1684 * then make sure to remove the address from the authenticated list if
1685 * it was added.
1686 */
1687
1688 rec.status = cpu_to_le16(rec.status);
1689 rec.algorithm = inf->info.authreq.algorithm;
1690
1691 result = hfa384x_drvr_setconfig(hw, HFA384x_RID_AUTHENTICATESTA,
1692 &rec, sizeof(rec));
1693 if (result) {
1694 if (added)
1695 hw->authlist.cnt--;
1696 netdev_err(wlandev->netdev,
1697 "setconfig(authenticatestation) failed, result=%d\n",
1698 result);
1699 }
1700 }
1701
1702 /*
1703 * prism2sta_inf_psusercnt
1704 *
1705 * Handles the receipt of a PowerSaveUserCount info frame. Should
1706 * be present in APs only.
1707 *
1708 * Arguments:
1709 * wlandev wlan device structure
1710 * inf ptr to info frame (contents in hfa384x order)
1711 *
1712 * Returns:
1713 * nothing
1714 *
1715 * Side effects:
1716 *
1717 * Call context:
1718 * interrupt
1719 */
prism2sta_inf_psusercnt(struct wlandevice * wlandev,struct hfa384x_InfFrame * inf)1720 static void prism2sta_inf_psusercnt(struct wlandevice *wlandev,
1721 struct hfa384x_InfFrame *inf)
1722 {
1723 struct hfa384x *hw = wlandev->priv;
1724
1725 hw->psusercount = le16_to_cpu(inf->info.psusercnt.usercnt);
1726 }
1727
1728 /*
1729 * prism2sta_ev_info
1730 *
1731 * Handles the Info event.
1732 *
1733 * Arguments:
1734 * wlandev wlan device structure
1735 * inf ptr to a generic info frame
1736 *
1737 * Returns:
1738 * nothing
1739 *
1740 * Side effects:
1741 *
1742 * Call context:
1743 * interrupt
1744 */
prism2sta_ev_info(struct wlandevice * wlandev,struct hfa384x_InfFrame * inf)1745 void prism2sta_ev_info(struct wlandevice *wlandev, struct hfa384x_InfFrame *inf)
1746 {
1747 inf->infotype = le16_to_cpu(inf->infotype);
1748 /* Dispatch */
1749 switch (inf->infotype) {
1750 case HFA384x_IT_HANDOVERADDR:
1751 prism2sta_inf_handover(wlandev, inf);
1752 break;
1753 case HFA384x_IT_COMMTALLIES:
1754 prism2sta_inf_tallies(wlandev, inf);
1755 break;
1756 case HFA384x_IT_HOSTSCANRESULTS:
1757 prism2sta_inf_hostscanresults(wlandev, inf);
1758 break;
1759 case HFA384x_IT_SCANRESULTS:
1760 prism2sta_inf_scanresults(wlandev, inf);
1761 break;
1762 case HFA384x_IT_CHINFORESULTS:
1763 prism2sta_inf_chinforesults(wlandev, inf);
1764 break;
1765 case HFA384x_IT_LINKSTATUS:
1766 prism2sta_inf_linkstatus(wlandev, inf);
1767 break;
1768 case HFA384x_IT_ASSOCSTATUS:
1769 prism2sta_inf_assocstatus(wlandev, inf);
1770 break;
1771 case HFA384x_IT_AUTHREQ:
1772 prism2sta_inf_authreq(wlandev, inf);
1773 break;
1774 case HFA384x_IT_PSUSERCNT:
1775 prism2sta_inf_psusercnt(wlandev, inf);
1776 break;
1777 case HFA384x_IT_KEYIDCHANGED:
1778 netdev_warn(wlandev->netdev, "Unhandled IT_KEYIDCHANGED\n");
1779 break;
1780 case HFA384x_IT_ASSOCREQ:
1781 netdev_warn(wlandev->netdev, "Unhandled IT_ASSOCREQ\n");
1782 break;
1783 case HFA384x_IT_MICFAILURE:
1784 netdev_warn(wlandev->netdev, "Unhandled IT_MICFAILURE\n");
1785 break;
1786 default:
1787 netdev_warn(wlandev->netdev,
1788 "Unknown info type=0x%02x\n", inf->infotype);
1789 break;
1790 }
1791 }
1792
1793 /*
1794 * prism2sta_ev_txexc
1795 *
1796 * Handles the TxExc event. A Transmit Exception event indicates
1797 * that the MAC's TX process was unsuccessful - so the packet did
1798 * not get transmitted.
1799 *
1800 * Arguments:
1801 * wlandev wlan device structure
1802 * status tx frame status word
1803 *
1804 * Returns:
1805 * nothing
1806 *
1807 * Side effects:
1808 *
1809 * Call context:
1810 * interrupt
1811 */
prism2sta_ev_txexc(struct wlandevice * wlandev,u16 status)1812 void prism2sta_ev_txexc(struct wlandevice *wlandev, u16 status)
1813 {
1814 pr_debug("TxExc status=0x%x.\n", status);
1815 }
1816
1817 /*
1818 * prism2sta_ev_tx
1819 *
1820 * Handles the Tx event.
1821 *
1822 * Arguments:
1823 * wlandev wlan device structure
1824 * status tx frame status word
1825 * Returns:
1826 * nothing
1827 *
1828 * Side effects:
1829 *
1830 * Call context:
1831 * interrupt
1832 */
prism2sta_ev_tx(struct wlandevice * wlandev,u16 status)1833 void prism2sta_ev_tx(struct wlandevice *wlandev, u16 status)
1834 {
1835 pr_debug("Tx Complete, status=0x%04x\n", status);
1836 /* update linux network stats */
1837 wlandev->netdev->stats.tx_packets++;
1838 }
1839
1840 /*
1841 * prism2sta_ev_alloc
1842 *
1843 * Handles the Alloc event.
1844 *
1845 * Arguments:
1846 * wlandev wlan device structure
1847 *
1848 * Returns:
1849 * nothing
1850 *
1851 * Side effects:
1852 *
1853 * Call context:
1854 * interrupt
1855 */
prism2sta_ev_alloc(struct wlandevice * wlandev)1856 void prism2sta_ev_alloc(struct wlandevice *wlandev)
1857 {
1858 netif_wake_queue(wlandev->netdev);
1859 }
1860
1861 /*
1862 * create_wlan
1863 *
1864 * Called at module init time. This creates the struct wlandevice structure
1865 * and initializes it with relevant bits.
1866 *
1867 * Arguments:
1868 * none
1869 *
1870 * Returns:
1871 * the created struct wlandevice structure.
1872 *
1873 * Side effects:
1874 * also allocates the priv/hw structures.
1875 *
1876 * Call context:
1877 * process thread
1878 *
1879 */
create_wlan(void)1880 static struct wlandevice *create_wlan(void)
1881 {
1882 struct wlandevice *wlandev = NULL;
1883 struct hfa384x *hw = NULL;
1884
1885 /* Alloc our structures */
1886 wlandev = kzalloc(sizeof(struct wlandevice), GFP_KERNEL);
1887 hw = kzalloc(sizeof(struct hfa384x), GFP_KERNEL);
1888
1889 if (!wlandev || !hw) {
1890 kfree(wlandev);
1891 kfree(hw);
1892 return NULL;
1893 }
1894
1895 /* Initialize the network device object. */
1896 wlandev->nsdname = dev_info;
1897 wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING;
1898 wlandev->priv = hw;
1899 wlandev->open = prism2sta_open;
1900 wlandev->close = prism2sta_close;
1901 wlandev->reset = prism2sta_reset;
1902 wlandev->txframe = prism2sta_txframe;
1903 wlandev->mlmerequest = prism2sta_mlmerequest;
1904 wlandev->set_multicast_list = prism2sta_setmulticast;
1905 wlandev->tx_timeout = hfa384x_tx_timeout;
1906
1907 wlandev->nsdcaps = P80211_NSDCAP_HWFRAGMENT | P80211_NSDCAP_AUTOJOIN;
1908
1909 /* Initialize the device private data structure. */
1910 hw->dot11_desired_bss_type = 1;
1911
1912 return wlandev;
1913 }
1914
prism2sta_commsqual_defer(struct work_struct * data)1915 void prism2sta_commsqual_defer(struct work_struct *data)
1916 {
1917 struct hfa384x *hw = container_of(data, struct hfa384x, commsqual_bh);
1918 struct wlandevice *wlandev = hw->wlandev;
1919 struct hfa384x_bytestr32 ssid;
1920 struct p80211msg_dot11req_mibget msg;
1921 struct p80211item_uint32 *mibitem = (struct p80211item_uint32 *)
1922 &msg.mibattribute.data;
1923 int result = 0;
1924
1925 if (hw->wlandev->hwremoved)
1926 return;
1927
1928 /* we don't care if we're in AP mode */
1929 if ((wlandev->macmode == WLAN_MACMODE_NONE) ||
1930 (wlandev->macmode == WLAN_MACMODE_ESS_AP)) {
1931 return;
1932 }
1933
1934 /* It only makes sense to poll these in non-IBSS */
1935 if (wlandev->macmode != WLAN_MACMODE_IBSS_STA) {
1936 result = hfa384x_drvr_getconfig(
1937 hw, HFA384x_RID_DBMCOMMSQUALITY,
1938 &hw->qual, HFA384x_RID_DBMCOMMSQUALITY_LEN);
1939
1940 if (result) {
1941 netdev_err(wlandev->netdev, "error fetching commsqual\n");
1942 return;
1943 }
1944
1945 pr_debug("commsqual %d %d %d\n",
1946 le16_to_cpu(hw->qual.CQ_currBSS),
1947 le16_to_cpu(hw->qual.ASL_currBSS),
1948 le16_to_cpu(hw->qual.ANL_currFC));
1949 }
1950
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);
1955
1956 if (result) {
1957 pr_debug("get signal rate failed, result = %d\n",
1958 result);
1959 return;
1960 }
1961
1962 switch (mibitem->data) {
1963 case HFA384x_RATEBIT_1:
1964 hw->txrate = 10;
1965 break;
1966 case HFA384x_RATEBIT_2:
1967 hw->txrate = 20;
1968 break;
1969 case HFA384x_RATEBIT_5dot5:
1970 hw->txrate = 55;
1971 break;
1972 case HFA384x_RATEBIT_11:
1973 hw->txrate = 110;
1974 break;
1975 default:
1976 pr_debug("Bad ratebit (%d)\n", mibitem->data);
1977 }
1978
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);
1983 if (result) {
1984 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1985 HFA384x_RID_CURRENTBSSID, result);
1986 return;
1987 }
1988
1989 result = hfa384x_drvr_getconfig(hw,
1990 HFA384x_RID_CURRENTSSID,
1991 &ssid, sizeof(ssid));
1992 if (result) {
1993 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1994 HFA384x_RID_CURRENTSSID, result);
1995 return;
1996 }
1997 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *)&ssid,
1998 (struct p80211pstrd *)&wlandev->ssid);
1999
2000 /* Reschedule timer */
2001 mod_timer(&hw->commsqual_timer, jiffies + HZ);
2002 }
2003
prism2sta_commsqual_timer(unsigned long data)2004 void prism2sta_commsqual_timer(unsigned long data)
2005 {
2006 struct hfa384x *hw = (struct hfa384x *)data;
2007
2008 schedule_work(&hw->commsqual_bh);
2009 }
2010