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