1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53#include <linux/version.h>
54#include <linux/module.h>
55#include <linux/moduleparam.h>
56#include <linux/kernel.h>
57#include <linux/sched.h>
58#include <linux/types.h>
59#include <linux/init.h>
60#include <linux/slab.h>
61#include <linux/wireless.h>
62#include <linux/netdevice.h>
63#include <linux/workqueue.h>
64#include <linux/byteorder/generic.h>
65#include <linux/ctype.h>
66
67#include <asm/io.h>
68#include <linux/delay.h>
69#include <asm/byteorder.h>
70#include <linux/if_arp.h>
71#include <linux/if_ether.h>
72#include <linux/bitops.h>
73
74#include "p80211types.h"
75#include "p80211hdr.h"
76#include "p80211mgmt.h"
77#include "p80211conv.h"
78#include "p80211msg.h"
79#include "p80211netdev.h"
80#include "p80211req.h"
81#include "p80211metadef.h"
82#include "p80211metastruct.h"
83#include "hfa384x.h"
84#include "prism2mgmt.h"
85
86#define wlan_hexchar(x) (((x) < 0x0a) ? ('0' + (x)) : ('a' + ((x) - 0x0a)))
87
88
89
90#define wlan_mkprintstr(buf, buflen, str, strlen) \
91{ \
92 int i = 0; \
93 int j = 0; \
94 memset(str, 0, (strlen)); \
95 for (i = 0; i < (buflen); i++) { \
96 if (isprint((buf)[i])) { \
97 (str)[j] = (buf)[i]; \
98 j++; \
99 } else { \
100 (str)[j] = '\\'; \
101 (str)[j+1] = 'x'; \
102 (str)[j+2] = wlan_hexchar(((buf)[i] & 0xf0) >> 4); \
103 (str)[j+3] = wlan_hexchar(((buf)[i] & 0x0f)); \
104 j += 4; \
105 } \
106 } \
107}
108
109static char *dev_info = "prism2_usb";
110static wlandevice_t *create_wlan(void);
111
112int prism2_reset_holdtime = 30;
113int prism2_reset_settletime = 100;
114
115static int prism2_doreset;
116
117module_param(prism2_doreset, int, 0644);
118MODULE_PARM_DESC(prism2_doreset, "Issue a reset on initialization");
119
120module_param(prism2_reset_holdtime, int, 0644);
121MODULE_PARM_DESC(prism2_reset_holdtime, "reset hold time in ms");
122module_param(prism2_reset_settletime, int, 0644);
123MODULE_PARM_DESC(prism2_reset_settletime, "reset settle time in ms");
124
125MODULE_LICENSE("Dual MPL/GPL");
126
127static int prism2sta_open(wlandevice_t *wlandev);
128static int prism2sta_close(wlandevice_t *wlandev);
129static void prism2sta_reset(wlandevice_t *wlandev);
130static int prism2sta_txframe(wlandevice_t *wlandev, struct sk_buff *skb,
131 p80211_hdr_t *p80211_hdr,
132 p80211_metawep_t *p80211_wep);
133static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg);
134static int prism2sta_getcardinfo(wlandevice_t *wlandev);
135static int prism2sta_globalsetup(wlandevice_t *wlandev);
136static int prism2sta_setmulticast(wlandevice_t *wlandev, netdevice_t *dev);
137
138static void prism2sta_inf_handover(wlandevice_t *wlandev,
139 hfa384x_InfFrame_t *inf);
140static void prism2sta_inf_tallies(wlandevice_t *wlandev,
141 hfa384x_InfFrame_t *inf);
142static void prism2sta_inf_hostscanresults(wlandevice_t *wlandev,
143 hfa384x_InfFrame_t *inf);
144static void prism2sta_inf_scanresults(wlandevice_t *wlandev,
145 hfa384x_InfFrame_t *inf);
146static void prism2sta_inf_chinforesults(wlandevice_t *wlandev,
147 hfa384x_InfFrame_t *inf);
148static void prism2sta_inf_linkstatus(wlandevice_t *wlandev,
149 hfa384x_InfFrame_t *inf);
150static void prism2sta_inf_assocstatus(wlandevice_t *wlandev,
151 hfa384x_InfFrame_t *inf);
152static void prism2sta_inf_authreq(wlandevice_t *wlandev,
153 hfa384x_InfFrame_t *inf);
154static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
155 hfa384x_InfFrame_t *inf);
156static void prism2sta_inf_psusercnt(wlandevice_t *wlandev,
157 hfa384x_InfFrame_t *inf);
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180static int prism2sta_open(wlandevice_t *wlandev)
181{
182
183
184
185
186
187
188
189
190 return 0;
191}
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214static int prism2sta_close(wlandevice_t *wlandev)
215{
216
217
218
219
220
221
222 return 0;
223}
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242static void prism2sta_reset(wlandevice_t *wlandev)
243{
244 return;
245}
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268static int prism2sta_txframe(wlandevice_t *wlandev, struct sk_buff *skb,
269 p80211_hdr_t *p80211_hdr,
270 p80211_metawep_t *p80211_wep)
271{
272 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
273 int result;
274
275
276 if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) ==
277 HOSTWEP_PRIVACYINVOKED) {
278 p80211_hdr->a3.fc |= cpu_to_le16(WLAN_SET_FC_ISWEP(1));
279 }
280
281 result = hfa384x_drvr_txframe(hw, skb, p80211_hdr, p80211_wep);
282
283 return result;
284}
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg)
311{
312 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
313
314 int result = 0;
315
316 switch (msg->msgcode) {
317 case DIDmsg_dot11req_mibget:
318 pr_debug("Received mibget request\n");
319 result = prism2mgmt_mibset_mibget(wlandev, msg);
320 break;
321 case DIDmsg_dot11req_mibset:
322 pr_debug("Received mibset request\n");
323 result = prism2mgmt_mibset_mibget(wlandev, msg);
324 break;
325 case DIDmsg_dot11req_scan:
326 pr_debug("Received scan request\n");
327 result = prism2mgmt_scan(wlandev, msg);
328 break;
329 case DIDmsg_dot11req_scan_results:
330 pr_debug("Received scan_results request\n");
331 result = prism2mgmt_scan_results(wlandev, msg);
332 break;
333 case DIDmsg_dot11req_start:
334 pr_debug("Received mlme start request\n");
335 result = prism2mgmt_start(wlandev, msg);
336 break;
337
338
339
340 case DIDmsg_p2req_readpda:
341 pr_debug("Received mlme readpda request\n");
342 result = prism2mgmt_readpda(wlandev, msg);
343 break;
344 case DIDmsg_p2req_ramdl_state:
345 pr_debug("Received mlme ramdl_state request\n");
346 result = prism2mgmt_ramdl_state(wlandev, msg);
347 break;
348 case DIDmsg_p2req_ramdl_write:
349 pr_debug("Received mlme ramdl_write request\n");
350 result = prism2mgmt_ramdl_write(wlandev, msg);
351 break;
352 case DIDmsg_p2req_flashdl_state:
353 pr_debug("Received mlme flashdl_state request\n");
354 result = prism2mgmt_flashdl_state(wlandev, msg);
355 break;
356 case DIDmsg_p2req_flashdl_write:
357 pr_debug("Received mlme flashdl_write request\n");
358 result = prism2mgmt_flashdl_write(wlandev, msg);
359 break;
360
361
362
363 case DIDmsg_lnxreq_hostwep:
364 break;
365 case DIDmsg_lnxreq_ifstate:
366 {
367 p80211msg_lnxreq_ifstate_t *ifstatemsg;
368 pr_debug("Received mlme ifstate request\n");
369 ifstatemsg = (p80211msg_lnxreq_ifstate_t *) msg;
370 result =
371 prism2sta_ifstate(wlandev,
372 ifstatemsg->ifstate.data);
373 ifstatemsg->resultcode.status =
374 P80211ENUM_msgitem_status_data_ok;
375 ifstatemsg->resultcode.data = result;
376 result = 0;
377 }
378 break;
379 case DIDmsg_lnxreq_wlansniff:
380 pr_debug("Received mlme wlansniff request\n");
381 result = prism2mgmt_wlansniff(wlandev, msg);
382 break;
383 case DIDmsg_lnxreq_autojoin:
384 pr_debug("Received mlme autojoin request\n");
385 result = prism2mgmt_autojoin(wlandev, msg);
386 break;
387 case DIDmsg_lnxreq_commsquality:{
388 p80211msg_lnxreq_commsquality_t *qualmsg;
389
390 pr_debug("Received commsquality request\n");
391
392 qualmsg = (p80211msg_lnxreq_commsquality_t *) msg;
393
394 qualmsg->link.status =
395 P80211ENUM_msgitem_status_data_ok;
396 qualmsg->level.status =
397 P80211ENUM_msgitem_status_data_ok;
398 qualmsg->noise.status =
399 P80211ENUM_msgitem_status_data_ok;
400
401 qualmsg->link.data = le16_to_cpu(hw->qual.CQ_currBSS);
402 qualmsg->level.data = le16_to_cpu(hw->qual.ASL_currBSS);
403 qualmsg->noise.data = le16_to_cpu(hw->qual.ANL_currFC);
404
405 break;
406 }
407 default:
408 printk(KERN_WARNING "Unknown mgmt request message 0x%08x",
409 msg->msgcode);
410 break;
411 }
412
413 return result;
414}
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate)
438{
439 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
440 u32 result;
441
442 result = P80211ENUM_resultcode_implementation_failure;
443
444 pr_debug("Current MSD state(%d), requesting(%d)\n",
445 wlandev->msdstate, ifstate);
446 switch (ifstate) {
447 case P80211ENUM_ifstate_fwload:
448 switch (wlandev->msdstate) {
449 case WLAN_MSD_HWPRESENT:
450 wlandev->msdstate = WLAN_MSD_FWLOAD_PENDING;
451
452
453
454
455 result = hfa384x_drvr_start(hw);
456 if (result) {
457 printk(KERN_ERR
458 "hfa384x_drvr_start() failed,"
459 "result=%d\n", (int)result);
460 result =
461 P80211ENUM_resultcode_implementation_failure;
462 wlandev->msdstate = WLAN_MSD_HWPRESENT;
463 break;
464 }
465 wlandev->msdstate = WLAN_MSD_FWLOAD;
466 result = P80211ENUM_resultcode_success;
467 break;
468 case WLAN_MSD_FWLOAD:
469 hfa384x_cmd_initialize(hw);
470 result = P80211ENUM_resultcode_success;
471 break;
472 case WLAN_MSD_RUNNING:
473 printk(KERN_WARNING
474 "Cannot enter fwload state from enable state,"
475 "you must disable first.\n");
476 result = P80211ENUM_resultcode_invalid_parameters;
477 break;
478 case WLAN_MSD_HWFAIL:
479 default:
480
481
482
483 result = P80211ENUM_resultcode_implementation_failure;
484 break;
485 }
486 break;
487 case P80211ENUM_ifstate_enable:
488 switch (wlandev->msdstate) {
489 case WLAN_MSD_HWPRESENT:
490 case WLAN_MSD_FWLOAD:
491 wlandev->msdstate = WLAN_MSD_RUNNING_PENDING;
492
493
494
495
496
497
498
499
500 result = hfa384x_drvr_start(hw);
501 if (result) {
502 printk(KERN_ERR
503 "hfa384x_drvr_start() failed,"
504 "result=%d\n", (int)result);
505 result =
506 P80211ENUM_resultcode_implementation_failure;
507 wlandev->msdstate = WLAN_MSD_HWPRESENT;
508 break;
509 }
510
511 result = prism2sta_getcardinfo(wlandev);
512 if (result) {
513 printk(KERN_ERR
514 "prism2sta_getcardinfo() failed,"
515 "result=%d\n", (int)result);
516 result =
517 P80211ENUM_resultcode_implementation_failure;
518 hfa384x_drvr_stop(hw);
519 wlandev->msdstate = WLAN_MSD_HWPRESENT;
520 break;
521 }
522 result = prism2sta_globalsetup(wlandev);
523 if (result) {
524 printk(KERN_ERR
525 "prism2sta_globalsetup() failed,"
526 "result=%d\n", (int)result);
527 result =
528 P80211ENUM_resultcode_implementation_failure;
529 hfa384x_drvr_stop(hw);
530 wlandev->msdstate = WLAN_MSD_HWPRESENT;
531 break;
532 }
533 wlandev->msdstate = WLAN_MSD_RUNNING;
534 hw->join_ap = 0;
535 hw->join_retries = 60;
536 result = P80211ENUM_resultcode_success;
537 break;
538 case WLAN_MSD_RUNNING:
539
540 result = P80211ENUM_resultcode_success;
541 break;
542 case WLAN_MSD_HWFAIL:
543 default:
544
545
546
547 result = P80211ENUM_resultcode_implementation_failure;
548 break;
549 }
550 break;
551 case P80211ENUM_ifstate_disable:
552 switch (wlandev->msdstate) {
553 case WLAN_MSD_HWPRESENT:
554
555 result = P80211ENUM_resultcode_success;
556 break;
557 case WLAN_MSD_FWLOAD:
558 case WLAN_MSD_RUNNING:
559 wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING;
560
561
562
563
564
565
566 if (!wlandev->hwremoved)
567 netif_carrier_off(wlandev->netdev);
568
569 hfa384x_drvr_stop(hw);
570
571 wlandev->macmode = WLAN_MACMODE_NONE;
572 wlandev->msdstate = WLAN_MSD_HWPRESENT;
573 result = P80211ENUM_resultcode_success;
574 break;
575 case WLAN_MSD_HWFAIL:
576 default:
577
578
579
580 result = P80211ENUM_resultcode_implementation_failure;
581 break;
582 }
583 break;
584 default:
585 result = P80211ENUM_resultcode_invalid_parameters;
586 break;
587 }
588
589 return result;
590}
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611static int prism2sta_getcardinfo(wlandevice_t *wlandev)
612{
613 int result = 0;
614 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
615 u16 temp;
616 u8 snum[HFA384x_RID_NICSERIALNUMBER_LEN];
617 char pstr[(HFA384x_RID_NICSERIALNUMBER_LEN * 4) + 1];
618
619
620
621
622 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICIDENTITY,
623 &hw->ident_nic,
624 sizeof(hfa384x_compident_t));
625 if (result) {
626 printk(KERN_ERR "Failed to retrieve NICIDENTITY\n");
627 goto failed;
628 }
629
630
631 hw->ident_nic.id = le16_to_cpu(hw->ident_nic.id);
632 hw->ident_nic.variant = le16_to_cpu(hw->ident_nic.variant);
633 hw->ident_nic.major = le16_to_cpu(hw->ident_nic.major);
634 hw->ident_nic.minor = le16_to_cpu(hw->ident_nic.minor);
635
636 printk(KERN_INFO "ident: nic h/w: id=0x%02x %d.%d.%d\n",
637 hw->ident_nic.id, hw->ident_nic.major,
638 hw->ident_nic.minor, hw->ident_nic.variant);
639
640
641 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRIIDENTITY,
642 &hw->ident_pri_fw,
643 sizeof(hfa384x_compident_t));
644 if (result) {
645 printk(KERN_ERR "Failed to retrieve PRIIDENTITY\n");
646 goto failed;
647 }
648
649
650 hw->ident_pri_fw.id = le16_to_cpu(hw->ident_pri_fw.id);
651 hw->ident_pri_fw.variant = le16_to_cpu(hw->ident_pri_fw.variant);
652 hw->ident_pri_fw.major = le16_to_cpu(hw->ident_pri_fw.major);
653 hw->ident_pri_fw.minor = le16_to_cpu(hw->ident_pri_fw.minor);
654
655 printk(KERN_INFO "ident: pri f/w: id=0x%02x %d.%d.%d\n",
656 hw->ident_pri_fw.id, hw->ident_pri_fw.major,
657 hw->ident_pri_fw.minor, hw->ident_pri_fw.variant);
658
659
660 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STAIDENTITY,
661 &hw->ident_sta_fw,
662 sizeof(hfa384x_compident_t));
663 if (result) {
664 printk(KERN_ERR "Failed to retrieve STAIDENTITY\n");
665 goto failed;
666 }
667
668 if (hw->ident_nic.id < 0x8000) {
669 printk(KERN_ERR
670 "FATAL: Card is not an Intersil Prism2/2.5/3\n");
671 result = -1;
672 goto failed;
673 }
674
675
676 hw->ident_sta_fw.id = le16_to_cpu(hw->ident_sta_fw.id);
677 hw->ident_sta_fw.variant = le16_to_cpu(hw->ident_sta_fw.variant);
678 hw->ident_sta_fw.major = le16_to_cpu(hw->ident_sta_fw.major);
679 hw->ident_sta_fw.minor = le16_to_cpu(hw->ident_sta_fw.minor);
680
681
682 hw->mm_mods = hw->ident_sta_fw.variant & (BIT(14) | BIT(15));
683 hw->ident_sta_fw.variant &= ~((u16) (BIT(14) | BIT(15)));
684
685 if (hw->ident_sta_fw.id == 0x1f) {
686 printk(KERN_INFO
687 "ident: sta f/w: id=0x%02x %d.%d.%d\n",
688 hw->ident_sta_fw.id, hw->ident_sta_fw.major,
689 hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
690 } else {
691 printk(KERN_INFO
692 "ident: ap f/w: id=0x%02x %d.%d.%d\n",
693 hw->ident_sta_fw.id, hw->ident_sta_fw.major,
694 hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
695 printk(KERN_ERR "Unsupported Tertiary AP firmeare loaded!\n");
696 goto failed;
697 }
698
699
700 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_MFISUPRANGE,
701 &hw->cap_sup_mfi,
702 sizeof(hfa384x_caplevel_t));
703 if (result) {
704 printk(KERN_ERR "Failed to retrieve MFISUPRANGE\n");
705 goto failed;
706 }
707
708
709
710 hw->cap_sup_mfi.role = le16_to_cpu(hw->cap_sup_mfi.role);
711 hw->cap_sup_mfi.id = le16_to_cpu(hw->cap_sup_mfi.id);
712 hw->cap_sup_mfi.variant = le16_to_cpu(hw->cap_sup_mfi.variant);
713 hw->cap_sup_mfi.bottom = le16_to_cpu(hw->cap_sup_mfi.bottom);
714 hw->cap_sup_mfi.top = le16_to_cpu(hw->cap_sup_mfi.top);
715
716 printk(KERN_INFO
717 "MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
718 hw->cap_sup_mfi.role, hw->cap_sup_mfi.id,
719 hw->cap_sup_mfi.variant, hw->cap_sup_mfi.bottom,
720 hw->cap_sup_mfi.top);
721
722
723 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CFISUPRANGE,
724 &hw->cap_sup_cfi,
725 sizeof(hfa384x_caplevel_t));
726 if (result) {
727 printk(KERN_ERR "Failed to retrieve CFISUPRANGE\n");
728 goto failed;
729 }
730
731
732
733 hw->cap_sup_cfi.role = le16_to_cpu(hw->cap_sup_cfi.role);
734 hw->cap_sup_cfi.id = le16_to_cpu(hw->cap_sup_cfi.id);
735 hw->cap_sup_cfi.variant = le16_to_cpu(hw->cap_sup_cfi.variant);
736 hw->cap_sup_cfi.bottom = le16_to_cpu(hw->cap_sup_cfi.bottom);
737 hw->cap_sup_cfi.top = le16_to_cpu(hw->cap_sup_cfi.top);
738
739 printk(KERN_INFO
740 "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
741 hw->cap_sup_cfi.role, hw->cap_sup_cfi.id,
742 hw->cap_sup_cfi.variant, hw->cap_sup_cfi.bottom,
743 hw->cap_sup_cfi.top);
744
745
746 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRISUPRANGE,
747 &hw->cap_sup_pri,
748 sizeof(hfa384x_caplevel_t));
749 if (result) {
750 printk(KERN_ERR "Failed to retrieve PRISUPRANGE\n");
751 goto failed;
752 }
753
754
755
756 hw->cap_sup_pri.role = le16_to_cpu(hw->cap_sup_pri.role);
757 hw->cap_sup_pri.id = le16_to_cpu(hw->cap_sup_pri.id);
758 hw->cap_sup_pri.variant = le16_to_cpu(hw->cap_sup_pri.variant);
759 hw->cap_sup_pri.bottom = le16_to_cpu(hw->cap_sup_pri.bottom);
760 hw->cap_sup_pri.top = le16_to_cpu(hw->cap_sup_pri.top);
761
762 printk(KERN_INFO
763 "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
764 hw->cap_sup_pri.role, hw->cap_sup_pri.id,
765 hw->cap_sup_pri.variant, hw->cap_sup_pri.bottom,
766 hw->cap_sup_pri.top);
767
768
769 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STASUPRANGE,
770 &hw->cap_sup_sta,
771 sizeof(hfa384x_caplevel_t));
772 if (result) {
773 printk(KERN_ERR "Failed to retrieve STASUPRANGE\n");
774 goto failed;
775 }
776
777
778
779 hw->cap_sup_sta.role = le16_to_cpu(hw->cap_sup_sta.role);
780 hw->cap_sup_sta.id = le16_to_cpu(hw->cap_sup_sta.id);
781 hw->cap_sup_sta.variant = le16_to_cpu(hw->cap_sup_sta.variant);
782 hw->cap_sup_sta.bottom = le16_to_cpu(hw->cap_sup_sta.bottom);
783 hw->cap_sup_sta.top = le16_to_cpu(hw->cap_sup_sta.top);
784
785 if (hw->cap_sup_sta.id == 0x04) {
786 printk(KERN_INFO
787 "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
788 hw->cap_sup_sta.role, hw->cap_sup_sta.id,
789 hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
790 hw->cap_sup_sta.top);
791 } else {
792 printk(KERN_INFO
793 "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
794 hw->cap_sup_sta.role, hw->cap_sup_sta.id,
795 hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
796 hw->cap_sup_sta.top);
797 }
798
799
800 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRI_CFIACTRANGES,
801 &hw->cap_act_pri_cfi,
802 sizeof(hfa384x_caplevel_t));
803 if (result) {
804 printk(KERN_ERR "Failed to retrieve PRI_CFIACTRANGES\n");
805 goto failed;
806 }
807
808
809
810 hw->cap_act_pri_cfi.role = le16_to_cpu(hw->cap_act_pri_cfi.role);
811 hw->cap_act_pri_cfi.id = le16_to_cpu(hw->cap_act_pri_cfi.id);
812 hw->cap_act_pri_cfi.variant = le16_to_cpu(hw->cap_act_pri_cfi.variant);
813 hw->cap_act_pri_cfi.bottom = le16_to_cpu(hw->cap_act_pri_cfi.bottom);
814 hw->cap_act_pri_cfi.top = le16_to_cpu(hw->cap_act_pri_cfi.top);
815
816 printk(KERN_INFO
817 "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
818 hw->cap_act_pri_cfi.role, hw->cap_act_pri_cfi.id,
819 hw->cap_act_pri_cfi.variant, hw->cap_act_pri_cfi.bottom,
820 hw->cap_act_pri_cfi.top);
821
822
823 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_CFIACTRANGES,
824 &hw->cap_act_sta_cfi,
825 sizeof(hfa384x_caplevel_t));
826 if (result) {
827 printk(KERN_ERR "Failed to retrieve STA_CFIACTRANGES\n");
828 goto failed;
829 }
830
831
832
833 hw->cap_act_sta_cfi.role = le16_to_cpu(hw->cap_act_sta_cfi.role);
834 hw->cap_act_sta_cfi.id = le16_to_cpu(hw->cap_act_sta_cfi.id);
835 hw->cap_act_sta_cfi.variant = le16_to_cpu(hw->cap_act_sta_cfi.variant);
836 hw->cap_act_sta_cfi.bottom = le16_to_cpu(hw->cap_act_sta_cfi.bottom);
837 hw->cap_act_sta_cfi.top = le16_to_cpu(hw->cap_act_sta_cfi.top);
838
839 printk(KERN_INFO
840 "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
841 hw->cap_act_sta_cfi.role, hw->cap_act_sta_cfi.id,
842 hw->cap_act_sta_cfi.variant, hw->cap_act_sta_cfi.bottom,
843 hw->cap_act_sta_cfi.top);
844
845
846 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_MFIACTRANGES,
847 &hw->cap_act_sta_mfi,
848 sizeof(hfa384x_caplevel_t));
849 if (result) {
850 printk(KERN_ERR "Failed to retrieve STA_MFIACTRANGES\n");
851 goto failed;
852 }
853
854
855
856 hw->cap_act_sta_mfi.role = le16_to_cpu(hw->cap_act_sta_mfi.role);
857 hw->cap_act_sta_mfi.id = le16_to_cpu(hw->cap_act_sta_mfi.id);
858 hw->cap_act_sta_mfi.variant = le16_to_cpu(hw->cap_act_sta_mfi.variant);
859 hw->cap_act_sta_mfi.bottom = le16_to_cpu(hw->cap_act_sta_mfi.bottom);
860 hw->cap_act_sta_mfi.top = le16_to_cpu(hw->cap_act_sta_mfi.top);
861
862 printk(KERN_INFO
863 "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
864 hw->cap_act_sta_mfi.role, hw->cap_act_sta_mfi.id,
865 hw->cap_act_sta_mfi.variant, hw->cap_act_sta_mfi.bottom,
866 hw->cap_act_sta_mfi.top);
867
868
869 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICSERIALNUMBER,
870 snum, HFA384x_RID_NICSERIALNUMBER_LEN);
871 if (!result) {
872 wlan_mkprintstr(snum, HFA384x_RID_NICSERIALNUMBER_LEN,
873 pstr, sizeof(pstr));
874 printk(KERN_INFO "Prism2 card SN: %s\n", pstr);
875 } else {
876 printk(KERN_ERR "Failed to retrieve Prism2 Card SN\n");
877 goto failed;
878 }
879
880
881 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFOWNMACADDR,
882 wlandev->netdev->dev_addr, ETH_ALEN);
883 if (result != 0) {
884 printk(KERN_ERR "Failed to retrieve mac address\n");
885 goto failed;
886 }
887
888
889 wlandev->nsdcaps |= P80211_NSDCAP_SHORT_PREAMBLE;
890
891
892 hfa384x_drvr_getconfig16(hw, HFA384x_RID_PRIVACYOPTIMP, &temp);
893 if (temp)
894 wlandev->nsdcaps |= P80211_NSDCAP_HARDWAREWEP;
895
896
897 hfa384x_drvr_getconfig16(hw, HFA384x_RID_CNFDBMADJUST, &temp);
898 hw->dbmadjust = temp;
899
900
901 if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
902 hw->ident_sta_fw.minor,
903 hw->ident_sta_fw.variant) <
904 HFA384x_FIRMWARE_VERSION(1, 5, 5)) {
905 wlandev->nsdcaps |= P80211_NSDCAP_NOSCAN;
906 }
907
908
909
910 goto done;
911failed:
912 printk(KERN_ERR "Failed, result=%d\n", result);
913done:
914 return result;
915}
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935static int prism2sta_globalsetup(wlandevice_t *wlandev)
936{
937 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
938
939
940 return hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN,
941 WLAN_DATA_MAXLEN);
942}
943
944static int prism2sta_setmulticast(wlandevice_t *wlandev, netdevice_t *dev)
945{
946 int result = 0;
947 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
948
949 u16 promisc;
950
951
952 if (hw->state != HFA384x_STATE_RUNNING)
953 goto exit;
954
955 if ((dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0)
956 promisc = P80211ENUM_truth_true;
957 else
958 promisc = P80211ENUM_truth_false;
959
960 result =
961 hfa384x_drvr_setconfig16_async(hw, HFA384x_RID_PROMISCMODE,
962 promisc);
963exit:
964 return result;
965}
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985static void prism2sta_inf_handover(wlandevice_t *wlandev,
986 hfa384x_InfFrame_t *inf)
987{
988 pr_debug("received infoframe:HANDOVER (unhandled)\n");
989 return;
990}
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009static void prism2sta_inf_tallies(wlandevice_t *wlandev,
1010 hfa384x_InfFrame_t *inf)
1011{
1012 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
1013 u16 *src16;
1014 u32 *dst;
1015 u32 *src32;
1016 int i;
1017 int cnt;
1018
1019
1020
1021
1022
1023
1024 cnt = sizeof(hfa384x_CommTallies32_t) / sizeof(u32);
1025 if (inf->framelen > 22) {
1026 dst = (u32 *) & hw->tallies;
1027 src32 = (u32 *) & inf->info.commtallies32;
1028 for (i = 0; i < cnt; i++, dst++, src32++)
1029 *dst += le32_to_cpu(*src32);
1030 } else {
1031 dst = (u32 *) & hw->tallies;
1032 src16 = (u16 *) & inf->info.commtallies16;
1033 for (i = 0; i < cnt; i++, dst++, src16++)
1034 *dst += le16_to_cpu(*src16);
1035 }
1036
1037 return;
1038}
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057static void prism2sta_inf_scanresults(wlandevice_t *wlandev,
1058 hfa384x_InfFrame_t *inf)
1059{
1060
1061 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
1062 int nbss;
1063 hfa384x_ScanResult_t *sr = &(inf->info.scanresult);
1064 int i;
1065 hfa384x_JoinRequest_data_t joinreq;
1066 int result;
1067
1068
1069 nbss = (inf->framelen * sizeof(u16)) -
1070 sizeof(inf->infotype) - sizeof(inf->info.scanresult.scanreason);
1071 nbss /= sizeof(hfa384x_ScanResultSub_t);
1072
1073
1074 pr_debug("rx scanresults, reason=%d, nbss=%d:\n",
1075 inf->info.scanresult.scanreason, nbss);
1076 for (i = 0; i < nbss; i++) {
1077 pr_debug("chid=%d anl=%d sl=%d bcnint=%d\n",
1078 sr->result[i].chid,
1079 sr->result[i].anl,
1080 sr->result[i].sl, sr->result[i].bcnint);
1081 pr_debug(" capinfo=0x%04x proberesp_rate=%d\n",
1082 sr->result[i].capinfo, sr->result[i].proberesp_rate);
1083 }
1084
1085 joinreq.channel = sr->result[0].chid;
1086 memcpy(joinreq.bssid, sr->result[0].bssid, WLAN_BSSID_LEN);
1087 result = hfa384x_drvr_setconfig(hw,
1088 HFA384x_RID_JOINREQUEST,
1089 &joinreq, HFA384x_RID_JOINREQUEST_LEN);
1090 if (result) {
1091 printk(KERN_ERR "setconfig(joinreq) failed, result=%d\n",
1092 result);
1093 }
1094
1095 return;
1096}
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115static void prism2sta_inf_hostscanresults(wlandevice_t *wlandev,
1116 hfa384x_InfFrame_t *inf)
1117{
1118 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
1119 int nbss;
1120
1121 nbss = (inf->framelen - 3) / 32;
1122 pr_debug("Received %d hostscan results\n", nbss);
1123
1124 if (nbss > 32)
1125 nbss = 32;
1126
1127 kfree(hw->scanresults);
1128
1129 hw->scanresults = kmalloc(sizeof(hfa384x_InfFrame_t), GFP_ATOMIC);
1130 memcpy(hw->scanresults, inf, sizeof(hfa384x_InfFrame_t));
1131
1132 if (nbss == 0)
1133 nbss = -1;
1134
1135
1136 hw->scanflag = nbss;
1137 wake_up_interruptible(&hw->cmdq);
1138};
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157static void prism2sta_inf_chinforesults(wlandevice_t *wlandev,
1158 hfa384x_InfFrame_t *inf)
1159{
1160 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
1161 unsigned int i, n;
1162
1163 hw->channel_info.results.scanchannels =
1164 le16_to_cpu(inf->info.chinforesult.scanchannels);
1165
1166 for (i = 0, n = 0; i < HFA384x_CHINFORESULT_MAX; i++) {
1167 if (hw->channel_info.results.scanchannels & (1 << i)) {
1168 int channel =
1169 le16_to_cpu(inf->info.chinforesult.result[n].chid) -
1170 1;
1171 hfa384x_ChInfoResultSub_t *chinforesult =
1172 &hw->channel_info.results.result[channel];
1173 chinforesult->chid = channel;
1174 chinforesult->anl =
1175 le16_to_cpu(inf->info.chinforesult.result[n].anl);
1176 chinforesult->pnl =
1177 le16_to_cpu(inf->info.chinforesult.result[n].pnl);
1178 chinforesult->active =
1179 le16_to_cpu(inf->info.chinforesult.result[n].
1180 active);
1181 pr_debug
1182 ("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n",
1183 channel + 1,
1184 chinforesult->
1185 active & HFA384x_CHINFORESULT_BSSACTIVE ? "signal"
1186 : "noise", chinforesult->anl, chinforesult->pnl,
1187 chinforesult->
1188 active & HFA384x_CHINFORESULT_PCFACTIVE ? 1 : 0);
1189 n++;
1190 }
1191 }
1192 atomic_set(&hw->channel_info.done, 2);
1193
1194 hw->channel_info.count = n;
1195 return;
1196}
1197
1198void prism2sta_processing_defer(struct work_struct *data)
1199{
1200 hfa384x_t *hw = container_of(data, struct hfa384x, link_bh);
1201 wlandevice_t *wlandev = hw->wlandev;
1202 hfa384x_bytestr32_t ssid;
1203 int result;
1204
1205
1206 {
1207 struct sk_buff *skb;
1208 hfa384x_InfFrame_t *inf;
1209
1210 while ((skb = skb_dequeue(&hw->authq))) {
1211 inf = (hfa384x_InfFrame_t *) skb->data;
1212 prism2sta_inf_authreq_defer(wlandev, inf);
1213 }
1214
1215 }
1216
1217
1218 if (hw->link_status == hw->link_status_new)
1219 goto failed;
1220
1221 hw->link_status = hw->link_status_new;
1222
1223 switch (hw->link_status) {
1224 case HFA384x_LINK_NOTCONNECTED:
1225
1226
1227
1228
1229
1230
1231 netif_carrier_off(wlandev->netdev);
1232
1233 printk(KERN_INFO "linkstatus=NOTCONNECTED (unhandled)\n");
1234 break;
1235
1236 case HFA384x_LINK_CONNECTED:
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247 netif_carrier_on(wlandev->netdev);
1248
1249
1250 if (hw->join_ap == 1)
1251 hw->join_ap = 2;
1252 hw->join_retries = 60;
1253
1254
1255 if (wlandev->netdev->type == ARPHRD_ETHER) {
1256 u16 portstatus;
1257
1258 printk(KERN_INFO "linkstatus=CONNECTED\n");
1259
1260
1261
1262
1263 result = hfa384x_drvr_getconfig(hw,
1264 HFA384x_RID_CURRENTBSSID,
1265 wlandev->bssid,
1266 WLAN_BSSID_LEN);
1267 if (result) {
1268 pr_debug
1269 ("getconfig(0x%02x) failed, result = %d\n",
1270 HFA384x_RID_CURRENTBSSID, result);
1271 goto failed;
1272 }
1273
1274 result = hfa384x_drvr_getconfig(hw,
1275 HFA384x_RID_CURRENTSSID,
1276 &ssid, sizeof(ssid));
1277 if (result) {
1278 pr_debug
1279 ("getconfig(0x%02x) failed, result = %d\n",
1280 HFA384x_RID_CURRENTSSID, result);
1281 goto failed;
1282 }
1283 prism2mgmt_bytestr2pstr((hfa384x_bytestr_t *) & ssid,
1284 (p80211pstrd_t *) &
1285 wlandev->ssid);
1286
1287
1288 result = hfa384x_drvr_getconfig16(hw,
1289 HFA384x_RID_PORTSTATUS,
1290 &portstatus);
1291 if (result) {
1292 pr_debug
1293 ("getconfig(0x%02x) failed, result = %d\n",
1294 HFA384x_RID_PORTSTATUS, result);
1295 goto failed;
1296 }
1297 wlandev->macmode =
1298 (portstatus == HFA384x_PSTATUS_CONN_IBSS) ?
1299 WLAN_MACMODE_IBSS_STA : WLAN_MACMODE_ESS_STA;
1300
1301
1302 prism2sta_commsqual_defer(&hw->commsqual_bh);
1303 }
1304 break;
1305
1306 case HFA384x_LINK_DISCONNECTED:
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316 if (hw->join_ap == 2) {
1317 hfa384x_JoinRequest_data_t joinreq;
1318 joinreq = hw->joinreq;
1319
1320 hfa384x_drvr_setconfig(hw,
1321 HFA384x_RID_JOINREQUEST,
1322 &joinreq,
1323 HFA384x_RID_JOINREQUEST_LEN);
1324 printk(KERN_INFO
1325 "linkstatus=DISCONNECTED (re-submitting join)\n");
1326 } else {
1327 if (wlandev->netdev->type == ARPHRD_ETHER)
1328 printk(KERN_INFO
1329 "linkstatus=DISCONNECTED (unhandled)\n");
1330 }
1331 wlandev->macmode = WLAN_MACMODE_NONE;
1332
1333 netif_carrier_off(wlandev->netdev);
1334
1335 break;
1336
1337 case HFA384x_LINK_AP_CHANGE:
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352 printk(KERN_INFO "linkstatus=AP_CHANGE\n");
1353
1354 result = hfa384x_drvr_getconfig(hw,
1355 HFA384x_RID_CURRENTBSSID,
1356 wlandev->bssid, WLAN_BSSID_LEN);
1357 if (result) {
1358 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1359 HFA384x_RID_CURRENTBSSID, result);
1360 goto failed;
1361 }
1362
1363 result = hfa384x_drvr_getconfig(hw,
1364 HFA384x_RID_CURRENTSSID,
1365 &ssid, sizeof(ssid));
1366 if (result) {
1367 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1368 HFA384x_RID_CURRENTSSID, result);
1369 goto failed;
1370 }
1371 prism2mgmt_bytestr2pstr((hfa384x_bytestr_t *) & ssid,
1372 (p80211pstrd_t *) & wlandev->ssid);
1373
1374 hw->link_status = HFA384x_LINK_CONNECTED;
1375 netif_carrier_on(wlandev->netdev);
1376
1377 break;
1378
1379 case HFA384x_LINK_AP_OUTOFRANGE:
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391 printk(KERN_INFO "linkstatus=AP_OUTOFRANGE (unhandled)\n");
1392
1393 netif_carrier_off(wlandev->netdev);
1394
1395 break;
1396
1397 case HFA384x_LINK_AP_INRANGE:
1398
1399
1400
1401
1402
1403
1404 printk(KERN_INFO "linkstatus=AP_INRANGE\n");
1405
1406 hw->link_status = HFA384x_LINK_CONNECTED;
1407 netif_carrier_on(wlandev->netdev);
1408
1409 break;
1410
1411 case HFA384x_LINK_ASSOCFAIL:
1412
1413
1414
1415
1416
1417
1418
1419
1420 if (hw->join_ap && --hw->join_retries > 0) {
1421 hfa384x_JoinRequest_data_t joinreq;
1422 joinreq = hw->joinreq;
1423
1424 hfa384x_drvr_setconfig(hw,
1425 HFA384x_RID_JOINREQUEST,
1426 &joinreq,
1427 HFA384x_RID_JOINREQUEST_LEN);
1428 printk(KERN_INFO
1429 "linkstatus=ASSOCFAIL (re-submitting join)\n");
1430 } else {
1431 printk(KERN_INFO "linkstatus=ASSOCFAIL (unhandled)\n");
1432 }
1433
1434 netif_carrier_off(wlandev->netdev);
1435
1436 break;
1437
1438 default:
1439
1440 printk(KERN_WARNING
1441 "unknown linkstatus=0x%02x\n", hw->link_status);
1442 goto failed;
1443 break;
1444 }
1445
1446 wlandev->linkstatus = (hw->link_status == HFA384x_LINK_CONNECTED);
1447 p80211wext_event_associated(wlandev, wlandev->linkstatus);
1448
1449failed:
1450 return;
1451}
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470static void prism2sta_inf_linkstatus(wlandevice_t *wlandev,
1471 hfa384x_InfFrame_t *inf)
1472{
1473 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
1474
1475 hw->link_status_new = le16_to_cpu(inf->info.linkstatus.linkstatus);
1476
1477 schedule_work(&hw->link_bh);
1478
1479 return;
1480}
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500static void prism2sta_inf_assocstatus(wlandevice_t *wlandev,
1501 hfa384x_InfFrame_t *inf)
1502{
1503 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
1504 hfa384x_AssocStatus_t rec;
1505 int i;
1506
1507 memcpy(&rec, &inf->info.assocstatus, sizeof(rec));
1508 rec.assocstatus = le16_to_cpu(rec.assocstatus);
1509 rec.reason = le16_to_cpu(rec.reason);
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522 for (i = 0; i < hw->authlist.cnt; i++)
1523 if (memcmp(rec.sta_addr, hw->authlist.addr[i], ETH_ALEN) == 0)
1524 break;
1525
1526 if (i >= hw->authlist.cnt) {
1527 if (rec.assocstatus != HFA384x_ASSOCSTATUS_AUTHFAIL)
1528 printk(KERN_WARNING
1529 "assocstatus info frame received for non-authenticated station.\n");
1530 } else {
1531 hw->authlist.assoc[i] =
1532 (rec.assocstatus == HFA384x_ASSOCSTATUS_STAASSOC ||
1533 rec.assocstatus == HFA384x_ASSOCSTATUS_REASSOC);
1534
1535 if (rec.assocstatus == HFA384x_ASSOCSTATUS_AUTHFAIL)
1536 printk(KERN_WARNING
1537 "authfail assocstatus info frame received for authenticated station.\n");
1538 }
1539
1540 return;
1541}
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562static void prism2sta_inf_authreq(wlandevice_t *wlandev,
1563 hfa384x_InfFrame_t *inf)
1564{
1565 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
1566 struct sk_buff *skb;
1567
1568 skb = dev_alloc_skb(sizeof(*inf));
1569 if (skb) {
1570 skb_put(skb, sizeof(*inf));
1571 memcpy(skb->data, inf, sizeof(*inf));
1572 skb_queue_tail(&hw->authq, skb);
1573 schedule_work(&hw->link_bh);
1574 }
1575}
1576
1577static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
1578 hfa384x_InfFrame_t *inf)
1579{
1580 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
1581 hfa384x_authenticateStation_data_t rec;
1582
1583 int i, added, result, cnt;
1584 u8 *addr;
1585
1586
1587
1588
1589
1590
1591 memcpy(rec.address, inf->info.authreq.sta_addr, ETH_ALEN);
1592 rec.status = P80211ENUM_status_unspec_failure;
1593
1594
1595
1596
1597
1598 switch (hw->accessmode) {
1599 case WLAN_ACCESS_NONE:
1600
1601
1602
1603
1604
1605
1606 for (i = 0; i < hw->authlist.cnt; i++)
1607 if (memcmp(rec.address, hw->authlist.addr[i],
1608 ETH_ALEN) == 0) {
1609 rec.status = P80211ENUM_status_successful;
1610 break;
1611 }
1612
1613 break;
1614
1615 case WLAN_ACCESS_ALL:
1616
1617
1618
1619
1620
1621 rec.status = P80211ENUM_status_successful;
1622 break;
1623
1624 case WLAN_ACCESS_ALLOW:
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636 if (hw->allow.modify == 0) {
1637 cnt = hw->allow.cnt;
1638 addr = hw->allow.addr[0];
1639 } else {
1640 cnt = hw->allow.cnt1;
1641 addr = hw->allow.addr1[0];
1642 }
1643
1644 for (i = 0; i < cnt; i++, addr += ETH_ALEN)
1645 if (memcmp(rec.address, addr, ETH_ALEN) == 0) {
1646 rec.status = P80211ENUM_status_successful;
1647 break;
1648 }
1649
1650 break;
1651
1652 case WLAN_ACCESS_DENY:
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664 if (hw->deny.modify == 0) {
1665 cnt = hw->deny.cnt;
1666 addr = hw->deny.addr[0];
1667 } else {
1668 cnt = hw->deny.cnt1;
1669 addr = hw->deny.addr1[0];
1670 }
1671
1672 rec.status = P80211ENUM_status_successful;
1673
1674 for (i = 0; i < cnt; i++, addr += ETH_ALEN)
1675 if (memcmp(rec.address, addr, ETH_ALEN) == 0) {
1676 rec.status = P80211ENUM_status_unspec_failure;
1677 break;
1678 }
1679
1680 break;
1681 }
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692 added = 0;
1693
1694 if (rec.status == P80211ENUM_status_successful) {
1695 for (i = 0; i < hw->authlist.cnt; i++)
1696 if (memcmp(rec.address, hw->authlist.addr[i], ETH_ALEN)
1697 == 0)
1698 break;
1699
1700 if (i >= hw->authlist.cnt) {
1701 if (hw->authlist.cnt >= WLAN_AUTH_MAX) {
1702 rec.status = P80211ENUM_status_ap_full;
1703 } else {
1704 memcpy(hw->authlist.addr[hw->authlist.cnt],
1705 rec.address, ETH_ALEN);
1706 hw->authlist.cnt++;
1707 added = 1;
1708 }
1709 }
1710 }
1711
1712
1713
1714
1715
1716
1717
1718 rec.status = cpu_to_le16(rec.status);
1719 rec.algorithm = inf->info.authreq.algorithm;
1720
1721 result = hfa384x_drvr_setconfig(hw, HFA384x_RID_AUTHENTICATESTA,
1722 &rec, sizeof(rec));
1723 if (result) {
1724 if (added)
1725 hw->authlist.cnt--;
1726 printk(KERN_ERR
1727 "setconfig(authenticatestation) failed, result=%d\n",
1728 result);
1729 }
1730 return;
1731}
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751static void prism2sta_inf_psusercnt(wlandevice_t *wlandev,
1752 hfa384x_InfFrame_t *inf)
1753{
1754 hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
1755
1756 hw->psusercount = le16_to_cpu(inf->info.psusercnt.usercnt);
1757
1758 return;
1759}
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778void prism2sta_ev_info(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf)
1779{
1780 inf->infotype = le16_to_cpu(inf->infotype);
1781
1782 switch (inf->infotype) {
1783 case HFA384x_IT_HANDOVERADDR:
1784 prism2sta_inf_handover(wlandev, inf);
1785 break;
1786 case HFA384x_IT_COMMTALLIES:
1787 prism2sta_inf_tallies(wlandev, inf);
1788 break;
1789 case HFA384x_IT_HOSTSCANRESULTS:
1790 prism2sta_inf_hostscanresults(wlandev, inf);
1791 break;
1792 case HFA384x_IT_SCANRESULTS:
1793 prism2sta_inf_scanresults(wlandev, inf);
1794 break;
1795 case HFA384x_IT_CHINFORESULTS:
1796 prism2sta_inf_chinforesults(wlandev, inf);
1797 break;
1798 case HFA384x_IT_LINKSTATUS:
1799 prism2sta_inf_linkstatus(wlandev, inf);
1800 break;
1801 case HFA384x_IT_ASSOCSTATUS:
1802 prism2sta_inf_assocstatus(wlandev, inf);
1803 break;
1804 case HFA384x_IT_AUTHREQ:
1805 prism2sta_inf_authreq(wlandev, inf);
1806 break;
1807 case HFA384x_IT_PSUSERCNT:
1808 prism2sta_inf_psusercnt(wlandev, inf);
1809 break;
1810 case HFA384x_IT_KEYIDCHANGED:
1811 printk(KERN_WARNING "Unhandled IT_KEYIDCHANGED\n");
1812 break;
1813 case HFA384x_IT_ASSOCREQ:
1814 printk(KERN_WARNING "Unhandled IT_ASSOCREQ\n");
1815 break;
1816 case HFA384x_IT_MICFAILURE:
1817 printk(KERN_WARNING "Unhandled IT_MICFAILURE\n");
1818 break;
1819 default:
1820 printk(KERN_WARNING
1821 "Unknown info type=0x%02x\n", inf->infotype);
1822 break;
1823 }
1824 return;
1825}
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846void prism2sta_ev_txexc(wlandevice_t *wlandev, u16 status)
1847{
1848 pr_debug("TxExc status=0x%x.\n", status);
1849
1850 return;
1851}
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869void prism2sta_ev_tx(wlandevice_t *wlandev, u16 status)
1870{
1871 pr_debug("Tx Complete, status=0x%04x\n", status);
1872
1873 wlandev->linux_stats.tx_packets++;
1874 return;
1875}
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893void prism2sta_ev_rx(wlandevice_t *wlandev, struct sk_buff *skb)
1894{
1895 p80211netdev_rx(wlandev, skb);
1896 return;
1897}
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915void prism2sta_ev_alloc(wlandevice_t *wlandev)
1916{
1917 netif_wake_queue(wlandev->netdev);
1918 return;
1919}
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940static wlandevice_t *create_wlan(void)
1941{
1942 wlandevice_t *wlandev = NULL;
1943 hfa384x_t *hw = NULL;
1944
1945
1946 wlandev = kmalloc(sizeof(wlandevice_t), GFP_KERNEL);
1947 hw = kmalloc(sizeof(hfa384x_t), GFP_KERNEL);
1948
1949 if (!wlandev || !hw) {
1950 printk(KERN_ERR "%s: Memory allocation failure.\n", dev_info);
1951 kfree(wlandev);
1952 kfree(hw);
1953 return NULL;
1954 }
1955
1956
1957 memset(wlandev, 0, sizeof(wlandevice_t));
1958 memset(hw, 0, sizeof(hfa384x_t));
1959
1960
1961 wlandev->nsdname = dev_info;
1962 wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING;
1963 wlandev->priv = hw;
1964 wlandev->open = prism2sta_open;
1965 wlandev->close = prism2sta_close;
1966 wlandev->reset = prism2sta_reset;
1967 wlandev->txframe = prism2sta_txframe;
1968 wlandev->mlmerequest = prism2sta_mlmerequest;
1969 wlandev->set_multicast_list = prism2sta_setmulticast;
1970 wlandev->tx_timeout = hfa384x_tx_timeout;
1971
1972 wlandev->nsdcaps = P80211_NSDCAP_HWFRAGMENT | P80211_NSDCAP_AUTOJOIN;
1973
1974
1975 hw->dot11_desired_bss_type = 1;
1976
1977 return wlandev;
1978}
1979
1980void prism2sta_commsqual_defer(struct work_struct *data)
1981{
1982 hfa384x_t *hw = container_of(data, struct hfa384x, commsqual_bh);
1983 wlandevice_t *wlandev = hw->wlandev;
1984 hfa384x_bytestr32_t ssid;
1985 int result = 0;
1986
1987 if (hw->wlandev->hwremoved)
1988 goto done;
1989
1990
1991 if ((wlandev->macmode == WLAN_MACMODE_NONE) ||
1992 (wlandev->macmode == WLAN_MACMODE_ESS_AP)) {
1993 goto done;
1994 }
1995
1996
1997 if (wlandev->macmode != WLAN_MACMODE_IBSS_STA) {
1998 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_DBMCOMMSQUALITY,
1999 &hw->qual,
2000 HFA384x_RID_DBMCOMMSQUALITY_LEN);
2001
2002 if (result) {
2003 printk(KERN_ERR "error fetching commsqual\n");
2004 goto done;
2005 }
2006
2007 pr_debug("commsqual %d %d %d\n",
2008 le16_to_cpu(hw->qual.CQ_currBSS),
2009 le16_to_cpu(hw->qual.ASL_currBSS),
2010 le16_to_cpu(hw->qual.ANL_currFC));
2011 }
2012
2013
2014 result = hfa384x_drvr_getconfig(hw,
2015 HFA384x_RID_CURRENTBSSID,
2016 wlandev->bssid, WLAN_BSSID_LEN);
2017 if (result) {
2018 pr_debug("getconfig(0x%02x) failed, result = %d\n",
2019 HFA384x_RID_CURRENTBSSID, result);
2020 goto done;
2021 }
2022
2023 result = hfa384x_drvr_getconfig(hw,
2024 HFA384x_RID_CURRENTSSID,
2025 &ssid, sizeof(ssid));
2026 if (result) {
2027 pr_debug("getconfig(0x%02x) failed, result = %d\n",
2028 HFA384x_RID_CURRENTSSID, result);
2029 goto done;
2030 }
2031 prism2mgmt_bytestr2pstr((hfa384x_bytestr_t *) & ssid,
2032 (p80211pstrd_t *) & wlandev->ssid);
2033
2034
2035 mod_timer(&hw->commsqual_timer, jiffies + HZ);
2036
2037done:
2038 ;
2039}
2040
2041void prism2sta_commsqual_timer(unsigned long data)
2042{
2043 hfa384x_t *hw = (hfa384x_t *) data;
2044
2045 schedule_work(&hw->commsqual_bh);
2046}
2047