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