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