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/wireless.h>
59#include <linux/netdevice.h>
60#include <linux/io.h>
61#include <linux/delay.h>
62#include <asm/byteorder.h>
63#include <linux/usb.h>
64#include <linux/bitops.h>
65
66#include "p80211types.h"
67#include "p80211hdr.h"
68#include "p80211mgmt.h"
69#include "p80211conv.h"
70#include "p80211msg.h"
71#include "p80211netdev.h"
72#include "p80211metadef.h"
73#include "p80211metastruct.h"
74#include "hfa384x.h"
75#include "prism2mgmt.h"
76
77#define MIB_TMP_MAXLEN 200
78
79#define F_STA 0x1
80#define F_READ 0x2
81#define F_WRITE 0x4
82
83struct mibrec {
84 u32 did;
85 u16 flag;
86 u16 parm1;
87 u16 parm2;
88 u16 parm3;
89 int (*func)(struct mibrec *mib,
90 int isget,
91 struct wlandevice *wlandev,
92 struct hfa384x *hw,
93 struct p80211msg_dot11req_mibset *msg, void *data);
94};
95
96static int prism2mib_bytearea2pstr(struct mibrec *mib,
97 int isget,
98 struct wlandevice *wlandev,
99 struct hfa384x *hw,
100 struct p80211msg_dot11req_mibset *msg,
101 void *data);
102
103static int prism2mib_uint32(struct mibrec *mib,
104 int isget,
105 struct wlandevice *wlandev,
106 struct hfa384x *hw,
107 struct p80211msg_dot11req_mibset *msg, void *data);
108
109static int prism2mib_flag(struct mibrec *mib,
110 int isget,
111 struct wlandevice *wlandev,
112 struct hfa384x *hw,
113 struct p80211msg_dot11req_mibset *msg, void *data);
114
115static int prism2mib_wepdefaultkey(struct mibrec *mib,
116 int isget,
117 struct wlandevice *wlandev,
118 struct hfa384x *hw,
119 struct p80211msg_dot11req_mibset *msg,
120 void *data);
121
122static int prism2mib_privacyinvoked(struct mibrec *mib,
123 int isget,
124 struct wlandevice *wlandev,
125 struct hfa384x *hw,
126 struct p80211msg_dot11req_mibset *msg,
127 void *data);
128
129static int prism2mib_excludeunencrypted(struct mibrec *mib,
130 int isget,
131 struct wlandevice *wlandev,
132 struct hfa384x *hw,
133 struct p80211msg_dot11req_mibset *msg,
134 void *data);
135
136static int prism2mib_fragmentationthreshold(struct mibrec *mib,
137 int isget,
138 struct wlandevice *wlandev,
139 struct hfa384x *hw,
140 struct p80211msg_dot11req_mibset *msg,
141 void *data);
142
143static int prism2mib_priv(struct mibrec *mib,
144 int isget,
145 struct wlandevice *wlandev,
146 struct hfa384x *hw,
147 struct p80211msg_dot11req_mibset *msg, void *data);
148
149static struct mibrec mibtab[] = {
150
151 {DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(1),
152 F_STA | F_WRITE,
153 HFA384x_RID_CNFWEPDEFAULTKEY0, 0, 0,
154 prism2mib_wepdefaultkey},
155 {DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(2),
156 F_STA | F_WRITE,
157 HFA384x_RID_CNFWEPDEFAULTKEY1, 0, 0,
158 prism2mib_wepdefaultkey},
159 {DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(3),
160 F_STA | F_WRITE,
161 HFA384x_RID_CNFWEPDEFAULTKEY2, 0, 0,
162 prism2mib_wepdefaultkey},
163 {DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(4),
164 F_STA | F_WRITE,
165 HFA384x_RID_CNFWEPDEFAULTKEY3, 0, 0,
166 prism2mib_wepdefaultkey},
167 {DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
168 F_STA | F_READ | F_WRITE,
169 HFA384x_RID_CNFWEPFLAGS, HFA384x_WEPFLAGS_PRIVINVOKED, 0,
170 prism2mib_privacyinvoked},
171 {DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
172 F_STA | F_READ | F_WRITE,
173 HFA384x_RID_CNFWEPDEFAULTKEYID, 0, 0,
174 prism2mib_uint32},
175 {DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
176 F_STA | F_READ | F_WRITE,
177 HFA384x_RID_CNFWEPFLAGS, HFA384x_WEPFLAGS_EXCLUDE, 0,
178 prism2mib_excludeunencrypted},
179
180
181
182 {DIDmib_dot11mac_dot11OperationTable_dot11MACAddress,
183 F_STA | F_READ | F_WRITE,
184 HFA384x_RID_CNFOWNMACADDR, HFA384x_RID_CNFOWNMACADDR_LEN, 0,
185 prism2mib_bytearea2pstr},
186 {DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold,
187 F_STA | F_READ | F_WRITE,
188 HFA384x_RID_RTSTHRESH, 0, 0,
189 prism2mib_uint32},
190 {DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit,
191 F_STA | F_READ,
192 HFA384x_RID_SHORTRETRYLIMIT, 0, 0,
193 prism2mib_uint32},
194 {DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit,
195 F_STA | F_READ,
196 HFA384x_RID_LONGRETRYLIMIT, 0, 0,
197 prism2mib_uint32},
198 {DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold,
199 F_STA | F_READ | F_WRITE,
200 HFA384x_RID_FRAGTHRESH, 0, 0,
201 prism2mib_fragmentationthreshold},
202 {DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime,
203 F_STA | F_READ,
204 HFA384x_RID_MAXTXLIFETIME, 0, 0,
205 prism2mib_uint32},
206
207
208
209 {DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel,
210 F_STA | F_READ,
211 HFA384x_RID_CURRENTCHANNEL, 0, 0,
212 prism2mib_uint32},
213 {DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel,
214 F_STA | F_READ | F_WRITE,
215 HFA384x_RID_TXPOWERMAX, 0, 0,
216 prism2mib_uint32},
217
218
219
220 {DIDmib_p2_p2Static_p2CnfPortType,
221 F_STA | F_READ | F_WRITE,
222 HFA384x_RID_CNFPORTTYPE, 0, 0,
223 prism2mib_uint32},
224
225
226
227 {DIDmib_p2_p2MAC_p2CurrentTxRate,
228 F_STA | F_READ,
229 HFA384x_RID_CURRENTTXRATE, 0, 0,
230 prism2mib_uint32},
231
232
233 {DIDmib_lnx_lnxConfigTable_lnxRSNAIE,
234 F_STA | F_READ | F_WRITE,
235 HFA384x_RID_CNFWPADATA, 0, 0,
236 prism2mib_priv},
237 {0, 0, 0, 0, 0, NULL}
238};
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260int prism2mgmt_mibset_mibget(struct wlandevice *wlandev, void *msgp)
261{
262 struct hfa384x *hw = wlandev->priv;
263 int result, isget;
264 struct mibrec *mib;
265
266 u16 which;
267
268 struct p80211msg_dot11req_mibset *msg = msgp;
269 struct p80211itemd *mibitem;
270
271 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
272 msg->resultcode.data = P80211ENUM_resultcode_success;
273
274
275
276
277
278 which = F_STA;
279
280
281
282
283
284
285
286
287 mibitem = (struct p80211itemd *)msg->mibattribute.data;
288
289 for (mib = mibtab; mib->did != 0; mib++)
290 if (mib->did == mibitem->did && (mib->flag & which))
291 break;
292
293 if (mib->did == 0) {
294 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
295 goto done;
296 }
297
298
299
300
301
302
303
304 isget = (msg->msgcode == DIDmsg_dot11req_mibget);
305
306 if (isget) {
307 if (!(mib->flag & F_READ)) {
308 msg->resultcode.data =
309 P80211ENUM_resultcode_cant_get_writeonly_mib;
310 goto done;
311 }
312 } else {
313 if (!(mib->flag & F_WRITE)) {
314 msg->resultcode.data =
315 P80211ENUM_resultcode_cant_set_readonly_mib;
316 goto done;
317 }
318 }
319
320
321
322
323
324
325
326
327
328 result = mib->func(mib, isget, wlandev, hw, msg, (void *)mibitem->data);
329
330 if (msg->resultcode.data == P80211ENUM_resultcode_success) {
331 if (result != 0) {
332 pr_debug("get/set failure, result=%d\n", result);
333 msg->resultcode.data =
334 P80211ENUM_resultcode_implementation_failure;
335 } else {
336 if (isget) {
337 msg->mibattribute.status =
338 P80211ENUM_msgitem_status_data_ok;
339 mibitem->status =
340 P80211ENUM_msgitem_status_data_ok;
341 }
342 }
343 }
344
345done:
346 return 0;
347}
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374static int prism2mib_bytearea2pstr(struct mibrec *mib,
375 int isget,
376 struct wlandevice *wlandev,
377 struct hfa384x *hw,
378 struct p80211msg_dot11req_mibset *msg,
379 void *data)
380{
381 int result;
382 struct p80211pstrd *pstr = data;
383 u8 bytebuf[MIB_TMP_MAXLEN];
384
385 if (isget) {
386 result =
387 hfa384x_drvr_getconfig(hw, mib->parm1, bytebuf, mib->parm2);
388 prism2mgmt_bytearea2pstr(bytebuf, pstr, mib->parm2);
389 } else {
390 memset(bytebuf, 0, mib->parm2);
391 memcpy(bytebuf, pstr->data, pstr->len);
392 result =
393 hfa384x_drvr_setconfig(hw, mib->parm1, bytebuf, mib->parm2);
394 }
395
396 return result;
397}
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424static int prism2mib_uint32(struct mibrec *mib,
425 int isget,
426 struct wlandevice *wlandev,
427 struct hfa384x *hw,
428 struct p80211msg_dot11req_mibset *msg, void *data)
429{
430 int result;
431 u32 *uint32 = data;
432 u8 bytebuf[MIB_TMP_MAXLEN];
433 u16 *wordbuf = (u16 *)bytebuf;
434
435 if (isget) {
436 result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
437 *uint32 = *wordbuf;
438 } else {
439 *wordbuf = *uint32;
440 result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
441 }
442
443 return result;
444}
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471static int prism2mib_flag(struct mibrec *mib,
472 int isget,
473 struct wlandevice *wlandev,
474 struct hfa384x *hw,
475 struct p80211msg_dot11req_mibset *msg, void *data)
476{
477 int result;
478 u32 *uint32 = data;
479 u8 bytebuf[MIB_TMP_MAXLEN];
480 u16 *wordbuf = (u16 *)bytebuf;
481 u32 flags;
482
483 result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
484 if (result == 0) {
485 flags = *wordbuf;
486 if (isget) {
487 *uint32 = (flags & mib->parm2) ?
488 P80211ENUM_truth_true : P80211ENUM_truth_false;
489 } else {
490 if ((*uint32) == P80211ENUM_truth_true)
491 flags |= mib->parm2;
492 else
493 flags &= ~mib->parm2;
494 *wordbuf = flags;
495 result =
496 hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
497 }
498 }
499
500 return result;
501}
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528static int prism2mib_wepdefaultkey(struct mibrec *mib,
529 int isget,
530 struct wlandevice *wlandev,
531 struct hfa384x *hw,
532 struct p80211msg_dot11req_mibset *msg,
533 void *data)
534{
535 int result;
536 struct p80211pstrd *pstr = data;
537 u8 bytebuf[MIB_TMP_MAXLEN];
538 u16 len;
539
540 if (isget) {
541 result = 0;
542 } else {
543 len = (pstr->len > 5) ? HFA384x_RID_CNFWEP128DEFAULTKEY_LEN :
544 HFA384x_RID_CNFWEPDEFAULTKEY_LEN;
545 memset(bytebuf, 0, len);
546 memcpy(bytebuf, pstr->data, pstr->len);
547 result = hfa384x_drvr_setconfig(hw, mib->parm1, bytebuf, len);
548 }
549
550 return result;
551}
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578static int prism2mib_privacyinvoked(struct mibrec *mib,
579 int isget,
580 struct wlandevice *wlandev,
581 struct hfa384x *hw,
582 struct p80211msg_dot11req_mibset *msg,
583 void *data)
584{
585 if (wlandev->hostwep & HOSTWEP_DECRYPT) {
586 if (wlandev->hostwep & HOSTWEP_DECRYPT)
587 mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_RXCRYPT;
588 if (wlandev->hostwep & HOSTWEP_ENCRYPT)
589 mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_TXCRYPT;
590 }
591
592 return prism2mib_flag(mib, isget, wlandev, hw, msg, data);
593}
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620static int prism2mib_excludeunencrypted(struct mibrec *mib,
621 int isget,
622 struct wlandevice *wlandev,
623 struct hfa384x *hw,
624 struct p80211msg_dot11req_mibset *msg,
625 void *data)
626{
627 return prism2mib_flag(mib, isget, wlandev, hw, msg, data);
628}
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655static int prism2mib_fragmentationthreshold(struct mibrec *mib,
656 int isget,
657 struct wlandevice *wlandev,
658 struct hfa384x *hw,
659 struct p80211msg_dot11req_mibset *msg,
660 void *data)
661{
662 u32 *uint32 = data;
663
664 if (!isget)
665 if ((*uint32) % 2) {
666 netdev_warn(wlandev->netdev,
667 "Attempt to set odd number FragmentationThreshold\n");
668 msg->resultcode.data =
669 P80211ENUM_resultcode_not_supported;
670 return 0;
671 }
672
673 return prism2mib_uint32(mib, isget, wlandev, hw, msg, data);
674}
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701static int prism2mib_priv(struct mibrec *mib,
702 int isget,
703 struct wlandevice *wlandev,
704 struct hfa384x *hw,
705 struct p80211msg_dot11req_mibset *msg, void *data)
706{
707 struct p80211pstrd *pstr = data;
708
709 switch (mib->did) {
710 case DIDmib_lnx_lnxConfigTable_lnxRSNAIE:{
711 struct hfa384x_wpa_data wpa;
712
713 if (isget) {
714 hfa384x_drvr_getconfig(hw,
715 HFA384x_RID_CNFWPADATA,
716 (u8 *)&wpa,
717 sizeof(wpa));
718 pstr->len = le16_to_cpu(wpa.datalen);
719 memcpy(pstr->data, wpa.data, pstr->len);
720 } else {
721 wpa.datalen = cpu_to_le16(pstr->len);
722 memcpy(wpa.data, pstr->data, pstr->len);
723
724 hfa384x_drvr_setconfig(hw,
725 HFA384x_RID_CNFWPADATA,
726 (u8 *)&wpa,
727 sizeof(wpa));
728 }
729 break;
730 }
731 default:
732 netdev_err(wlandev->netdev, "Unhandled DID 0x%08x\n", mib->did);
733 }
734
735 return 0;
736}
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753void prism2mgmt_pstr2bytestr(struct hfa384x_bytestr *bytestr,
754 struct p80211pstrd *pstr)
755{
756 bytestr->len = cpu_to_le16((u16)(pstr->len));
757 memcpy(bytestr->data, pstr->data, pstr->len);
758}
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775void prism2mgmt_bytestr2pstr(struct hfa384x_bytestr *bytestr,
776 struct p80211pstrd *pstr)
777{
778 pstr->len = (u8)(le16_to_cpu(bytestr->len));
779 memcpy(pstr->data, bytestr->data, pstr->len);
780}
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797void prism2mgmt_bytearea2pstr(u8 *bytearea, struct p80211pstrd *pstr, int len)
798{
799 pstr->len = (u8)len;
800 memcpy(pstr->data, bytearea, len);
801}
802