Merge commit 'v2.6.29-rc1' into perfcounters/core
[linux-2.6] / drivers / staging / wlan-ng / prism2mib.c
1 /* src/prism2/driver/prism2mib.c
2 *
3 * Management request for mibset/mibget
4 *
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
6 * --------------------------------------------------------------------
7 *
8 * linux-wlan
9 *
10 *   The contents of this file are subject to the Mozilla Public
11 *   License Version 1.1 (the "License"); you may not use this file
12 *   except in compliance with the License. You may obtain a copy of
13 *   the License at http://www.mozilla.org/MPL/
14 *
15 *   Software distributed under the License is distributed on an "AS
16 *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 *   implied. See the License for the specific language governing
18 *   rights and limitations under the License.
19 *
20 *   Alternatively, the contents of this file may be used under the
21 *   terms of the GNU Public License version 2 (the "GPL"), in which
22 *   case the provisions of the GPL are applicable instead of the
23 *   above.  If you wish to allow the use of your version of this file
24 *   only under the terms of the GPL and not to allow others to use
25 *   your version of this file under the MPL, indicate your decision
26 *   by deleting the provisions above and replace them with the notice
27 *   and other provisions required by the GPL.  If you do not delete
28 *   the provisions above, a recipient may use your version of this
29 *   file under either the MPL or the GPL.
30 *
31 * --------------------------------------------------------------------
32 *
33 * Inquiries regarding the linux-wlan Open Source project can be
34 * made directly to:
35 *
36 * AbsoluteValue Systems Inc.
37 * info@linux-wlan.com
38 * http://www.linux-wlan.com
39 *
40 * --------------------------------------------------------------------
41 *
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
44 *
45 * --------------------------------------------------------------------
46 *
47 * The functions in this file handle the mibset/mibget management
48 * functions.
49 *
50 * --------------------------------------------------------------------
51 */
52
53 /*================================================================*/
54 /* System Includes */
55 #define WLAN_DBVAR      prism2_debug
56
57 #include <linux/version.h>
58
59 #include <linux/module.h>
60 #include <linux/kernel.h>
61 #include <linux/sched.h>
62 #include <linux/types.h>
63 #include <linux/slab.h>
64 #include <linux/wireless.h>
65 #include <linux/netdevice.h>
66 #include <asm/io.h>
67 #include <linux/delay.h>
68 #include <asm/byteorder.h>
69 #include <linux/usb.h>
70
71 /*================================================================*/
72 /* Project Includes */
73
74 #include "p80211types.h"
75 #include "p80211hdr.h"
76 #include "p80211mgmt.h"
77 #include "p80211conv.h"
78 #include "p80211msg.h"
79 #include "p80211netdev.h"
80 #include "p80211metadef.h"
81 #include "p80211metastruct.h"
82 #include "hfa384x.h"
83 #include "prism2mgmt.h"
84
85 /*================================================================*/
86 /* Local Constants */
87
88 #define MIB_TMP_MAXLEN    200    /* Max length of RID record (in bytes). */
89
90 /*================================================================*/
91 /* Local Types */
92
93 #define  F_STA        0x1        /* MIB is supported on stations. */
94 #define  F_READ       0x2        /* MIB may be read. */
95 #define  F_WRITE      0x4        /* MIB may be written. */
96
97 typedef struct mibrec
98 {
99     u32   did;
100     u16   flag;
101     u16   parm1;
102     u16   parm2;
103     u16   parm3;
104     int      (*func)(struct mibrec                *mib,
105                      int                          isget,
106                      wlandevice_t                 *wlandev,
107                      hfa384x_t                    *hw,
108                      p80211msg_dot11req_mibset_t  *msg,
109                      void                         *data);
110 } mibrec_t;
111
112 /*================================================================*/
113 /* Local Function Declarations */
114
115 static int prism2mib_bytearea2pstr(
116 mibrec_t                     *mib,
117 int                          isget,
118 wlandevice_t                 *wlandev,
119 hfa384x_t                    *hw,
120 p80211msg_dot11req_mibset_t  *msg,
121 void                         *data);
122
123 static int prism2mib_uint32(
124 mibrec_t                     *mib,
125 int                          isget,
126 wlandevice_t                 *wlandev,
127 hfa384x_t                    *hw,
128 p80211msg_dot11req_mibset_t  *msg,
129 void                         *data);
130
131 static int prism2mib_flag(
132 mibrec_t                     *mib,
133 int                          isget,
134 wlandevice_t                 *wlandev,
135 hfa384x_t                    *hw,
136 p80211msg_dot11req_mibset_t  *msg,
137 void                         *data);
138
139 static int prism2mib_wepdefaultkey(
140 mibrec_t                     *mib,
141 int                          isget,
142 wlandevice_t                 *wlandev,
143 hfa384x_t                    *hw,
144 p80211msg_dot11req_mibset_t  *msg,
145 void                         *data);
146
147 static int prism2mib_privacyinvoked(
148 mibrec_t                     *mib,
149 int                          isget,
150 wlandevice_t                 *wlandev,
151 hfa384x_t                    *hw,
152 p80211msg_dot11req_mibset_t  *msg,
153 void                         *data);
154
155 static int prism2mib_excludeunencrypted(
156 mibrec_t                     *mib,
157 int                          isget,
158 wlandevice_t                 *wlandev,
159 hfa384x_t                    *hw,
160 p80211msg_dot11req_mibset_t  *msg,
161 void                         *data);
162
163 static int prism2mib_fragmentationthreshold(
164 mibrec_t                     *mib,
165 int                          isget,
166 wlandevice_t                 *wlandev,
167 hfa384x_t                    *hw,
168 p80211msg_dot11req_mibset_t  *msg,
169 void                         *data);
170
171 static int prism2mib_priv(
172 mibrec_t                     *mib,
173 int                          isget,
174 wlandevice_t                 *wlandev,
175 hfa384x_t                    *hw,
176 p80211msg_dot11req_mibset_t  *msg,
177 void                         *data);
178
179 /*================================================================*/
180 /* Local Static Definitions */
181
182 static mibrec_t mibtab[] = {
183
184     /* dot11smt MIB's */
185     { DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0,
186           F_STA | F_WRITE,
187           HFA384x_RID_CNFWEPDEFAULTKEY0, 0, 0,
188           prism2mib_wepdefaultkey },
189     { DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1,
190           F_STA | F_WRITE,
191           HFA384x_RID_CNFWEPDEFAULTKEY1, 0, 0,
192           prism2mib_wepdefaultkey },
193     { DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2,
194           F_STA | F_WRITE,
195           HFA384x_RID_CNFWEPDEFAULTKEY2, 0, 0,
196           prism2mib_wepdefaultkey },
197     { DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3,
198           F_STA | F_WRITE,
199           HFA384x_RID_CNFWEPDEFAULTKEY3, 0, 0,
200           prism2mib_wepdefaultkey },
201     { DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
202           F_STA | F_READ | F_WRITE,
203           HFA384x_RID_CNFWEPFLAGS, HFA384x_WEPFLAGS_PRIVINVOKED, 0,
204           prism2mib_privacyinvoked },
205     { DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
206           F_STA | F_READ | F_WRITE,
207           HFA384x_RID_CNFWEPDEFAULTKEYID, 0, 0,
208           prism2mib_uint32 },
209     { DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
210           F_STA | F_READ | F_WRITE,
211           HFA384x_RID_CNFWEPFLAGS, HFA384x_WEPFLAGS_EXCLUDE, 0,
212           prism2mib_excludeunencrypted },
213
214     /* dot11mac MIB's */
215
216     { DIDmib_dot11mac_dot11OperationTable_dot11MACAddress,
217           F_STA | F_READ | F_WRITE,
218           HFA384x_RID_CNFOWNMACADDR, HFA384x_RID_CNFOWNMACADDR_LEN, 0,
219           prism2mib_bytearea2pstr },
220     { DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold,
221           F_STA | F_READ | F_WRITE,
222           HFA384x_RID_RTSTHRESH, 0, 0,
223           prism2mib_uint32 },
224     { DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit,
225           F_STA | F_READ,
226           HFA384x_RID_SHORTRETRYLIMIT, 0, 0,
227           prism2mib_uint32 },
228     { DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit,
229           F_STA | F_READ,
230           HFA384x_RID_LONGRETRYLIMIT, 0, 0,
231           prism2mib_uint32 },
232     { DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold,
233           F_STA | F_READ | F_WRITE,
234           HFA384x_RID_FRAGTHRESH, 0, 0,
235           prism2mib_fragmentationthreshold },
236     { DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime,
237           F_STA | F_READ,
238           HFA384x_RID_MAXTXLIFETIME, 0, 0,
239           prism2mib_uint32 },
240
241     /* dot11phy MIB's */
242
243     { DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel,
244           F_STA | F_READ,
245           HFA384x_RID_CURRENTCHANNEL, 0, 0,
246           prism2mib_uint32 },
247     { DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel,
248           F_STA | F_READ | F_WRITE,
249           HFA384x_RID_TXPOWERMAX, 0, 0,
250           prism2mib_uint32 },
251
252     /* p2Static MIB's */
253
254     { DIDmib_p2_p2Static_p2CnfPortType,
255           F_STA | F_READ | F_WRITE,
256           HFA384x_RID_CNFPORTTYPE, 0, 0,
257           prism2mib_uint32 },
258
259     /* p2MAC MIB's */
260
261     { DIDmib_p2_p2MAC_p2CurrentTxRate,
262           F_STA | F_READ,
263           HFA384x_RID_CURRENTTXRATE, 0, 0,
264           prism2mib_uint32 },
265
266     /* And finally, lnx mibs */
267     { DIDmib_lnx_lnxConfigTable_lnxRSNAIE,
268           F_STA | F_READ | F_WRITE,
269           HFA384x_RID_CNFWPADATA, 0, 0,
270           prism2mib_priv },
271     { 0, 0, 0, 0, 0, NULL}};
272
273 /*================================================================*/
274 /* Function Definitions */
275
276 /*----------------------------------------------------------------
277 * prism2mgmt_mibset_mibget
278 *
279 * Set the value of a mib item.
280 *
281 * Arguments:
282 *       wlandev         wlan device structure
283 *       msgp            ptr to msg buffer
284 *
285 * Returns:
286 *       0       success and done
287 *       <0      success, but we're waiting for something to finish.
288 *       >0      an error occurred while handling the message.
289 * Side effects:
290 *
291 * Call context:
292 *       process thread  (usually)
293 *       interrupt
294 ----------------------------------------------------------------*/
295
296 int prism2mgmt_mibset_mibget(wlandevice_t *wlandev, void *msgp)
297 {
298         hfa384x_t               *hw = wlandev->priv;
299         int                     result, isget;
300         mibrec_t                *mib;
301
302         u16                     which;
303
304         p80211msg_dot11req_mibset_t     *msg = msgp;
305         p80211itemd_t                   *mibitem;
306
307         DBFENTER;
308
309         msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
310         msg->resultcode.data = P80211ENUM_resultcode_success;
311
312         /*
313         ** Determine if this is an Access Point or a station.
314         */
315
316         which = F_STA;
317
318         /*
319         ** Find the MIB in the MIB table.  Note that a MIB may be in the
320         ** table twice...once for an AP and once for a station.  Make sure
321         ** to get the correct one.  Note that DID=0 marks the end of the
322         ** MIB table.
323         */
324
325         mibitem = (p80211itemd_t *) msg->mibattribute.data;
326
327         for (mib = mibtab; mib->did != 0; mib++)
328                 if (mib->did == mibitem->did && (mib->flag & which))
329                         break;
330
331         if (mib->did == 0) {
332                 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
333                 goto done;
334         }
335
336         /*
337         ** Determine if this is a "mibget" or a "mibset".  If this is a
338         ** "mibget", then make sure that the MIB may be read.  Otherwise,
339         ** this is a "mibset" so make make sure that the MIB may be written.
340         */
341
342         isget = (msg->msgcode == DIDmsg_dot11req_mibget);
343
344         if (isget) {
345                 if (!(mib->flag & F_READ)) {
346                         msg->resultcode.data =
347                                 P80211ENUM_resultcode_cant_get_writeonly_mib;
348                         goto done;
349                 }
350         } else {
351                 if (!(mib->flag & F_WRITE)) {
352                         msg->resultcode.data =
353                                 P80211ENUM_resultcode_cant_set_readonly_mib;
354                         goto done;
355                 }
356         }
357
358         /*
359         ** Execute the MIB function.  If things worked okay, then make
360         ** sure that the MIB function also worked okay.  If so, and this
361         ** is a "mibget", then the status value must be set for both the
362         ** "mibattribute" parameter and the mib item within the data
363         ** portion of the "mibattribute".
364         */
365
366         result = mib->func(mib, isget, wlandev, hw, msg,
367                            (void *) mibitem->data);
368
369         if (msg->resultcode.data == P80211ENUM_resultcode_success) {
370                 if (result != 0) {
371                         WLAN_LOG_DEBUG(1, "get/set failure, result=%d\n",
372                                         result);
373                         msg->resultcode.data =
374                                  P80211ENUM_resultcode_implementation_failure;
375                 } else {
376                         if (isget) {
377                                 msg->mibattribute.status =
378                                         P80211ENUM_msgitem_status_data_ok;
379                                 mibitem->status =
380                                         P80211ENUM_msgitem_status_data_ok;
381                         }
382                 }
383         }
384
385 done:
386         DBFEXIT;
387
388         return(0);
389 }
390
391 /*----------------------------------------------------------------
392 * prism2mib_bytearea2pstr
393 *
394 * Get/set pstr data to/from a byte area.
395 *
396 * MIB record parameters:
397 *       parm1    Prism2 RID value.
398 *       parm2    Number of bytes of RID data.
399 *       parm3    Not used.
400 *
401 * Arguments:
402 *       mib      MIB record.
403 *       isget    MIBGET/MIBSET flag.
404 *       wlandev  wlan device structure.
405 *       priv     "priv" structure.
406 *       hw       "hw" structure.
407 *       msg      Message structure.
408 *       data     Data buffer.
409 *
410 * Returns:
411 *       0   - Success.
412 *       ~0  - Error.
413 *
414 ----------------------------------------------------------------*/
415
416 static int prism2mib_bytearea2pstr(
417 mibrec_t                     *mib,
418 int                          isget,
419 wlandevice_t                 *wlandev,
420 hfa384x_t                    *hw,
421 p80211msg_dot11req_mibset_t  *msg,
422 void                         *data)
423 {
424         int            result;
425         p80211pstrd_t  *pstr = (p80211pstrd_t*) data;
426         u8          bytebuf[MIB_TMP_MAXLEN];
427
428         DBFENTER;
429
430         if (isget) {
431                 result = hfa384x_drvr_getconfig(hw, mib->parm1, bytebuf, mib->parm2);
432                 prism2mgmt_bytearea2pstr(bytebuf, pstr, mib->parm2);
433         } else {
434                 memset(bytebuf, 0, mib->parm2);
435                 prism2mgmt_pstr2bytearea(bytebuf, pstr);
436                 result = hfa384x_drvr_setconfig(hw, mib->parm1, bytebuf, mib->parm2);
437         }
438
439         DBFEXIT;
440         return(result);
441 }
442
443 /*----------------------------------------------------------------
444 * prism2mib_uint32
445 *
446 * Get/set uint32 data.
447 *
448 * MIB record parameters:
449 *       parm1    Prism2 RID value.
450 *       parm2    Not used.
451 *       parm3    Not used.
452 *
453 * Arguments:
454 *       mib      MIB record.
455 *       isget    MIBGET/MIBSET flag.
456 *       wlandev  wlan device structure.
457 *       priv     "priv" structure.
458 *       hw       "hw" structure.
459 *       msg      Message structure.
460 *       data     Data buffer.
461 *
462 * Returns:
463 *       0   - Success.
464 *       ~0  - Error.
465 *
466 ----------------------------------------------------------------*/
467
468 static int prism2mib_uint32(
469 mibrec_t                     *mib,
470 int                          isget,
471 wlandevice_t                 *wlandev,
472 hfa384x_t                    *hw,
473 p80211msg_dot11req_mibset_t  *msg,
474 void                         *data)
475 {
476         int     result;
477         u32  *uint32 = (u32*) data;
478         u8   bytebuf[MIB_TMP_MAXLEN];
479         u16  *wordbuf = (u16*) bytebuf;
480
481         DBFENTER;
482
483         if (isget) {
484                 result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
485                 *uint32 = *wordbuf;
486                 /* [MSM] Removed, getconfig16 returns the value in host order.
487                  * prism2mgmt_prism2int2p80211int(wordbuf, uint32);
488                  */
489         } else {
490                 /* [MSM] Removed, setconfig16 expects host order.
491                  * prism2mgmt_p80211int2prism2int(wordbuf, uint32);
492                  */
493                 *wordbuf = *uint32;
494                 result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
495         }
496
497         DBFEXIT;
498         return(result);
499 }
500
501 /*----------------------------------------------------------------
502 * prism2mib_flag
503 *
504 * Get/set a flag.
505 *
506 * MIB record parameters:
507 *       parm1    Prism2 RID value.
508 *       parm2    Bit to get/set.
509 *       parm3    Not used.
510 *
511 * Arguments:
512 *       mib      MIB record.
513 *       isget    MIBGET/MIBSET flag.
514 *       wlandev  wlan device structure.
515 *       priv     "priv" structure.
516 *       hw       "hw" structure.
517 *       msg      Message structure.
518 *       data     Data buffer.
519 *
520 * Returns:
521 *       0   - Success.
522 *       ~0  - Error.
523 *
524 ----------------------------------------------------------------*/
525
526 static int prism2mib_flag(
527 mibrec_t                     *mib,
528 int                          isget,
529 wlandevice_t                 *wlandev,
530 hfa384x_t                    *hw,
531 p80211msg_dot11req_mibset_t  *msg,
532 void                         *data)
533 {
534         int     result;
535         u32  *uint32 = (u32*) data;
536         u8   bytebuf[MIB_TMP_MAXLEN];
537         u16  *wordbuf = (u16*) bytebuf;
538         u32  flags;
539
540         DBFENTER;
541
542         result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
543         if (result == 0) {
544                 /* [MSM] Removed, getconfig16 returns the value in host order.
545                  * prism2mgmt_prism2int2p80211int(wordbuf, &flags);
546                  */
547                 flags = *wordbuf;
548                 if (isget) {
549                         *uint32 = (flags & mib->parm2) ?
550                                 P80211ENUM_truth_true : P80211ENUM_truth_false;
551                 } else {
552                         if ((*uint32) == P80211ENUM_truth_true)
553                                 flags |= mib->parm2;
554                         else
555                                 flags &= ~mib->parm2;
556                         /* [MSM] Removed, setconfig16 expects host order.
557                          * prism2mgmt_p80211int2prism2int(wordbuf, &flags);
558                          */
559                         *wordbuf = flags;
560                         result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
561                 }
562         }
563
564         DBFEXIT;
565         return(result);
566 }
567
568 /*----------------------------------------------------------------
569 * prism2mib_wepdefaultkey
570 *
571 * Get/set WEP default keys.
572 *
573 * MIB record parameters:
574 *       parm1    Prism2 RID value.
575 *       parm2    Number of bytes of RID data.
576 *       parm3    Not used.
577 *
578 * Arguments:
579 *       mib      MIB record.
580 *       isget    MIBGET/MIBSET flag.
581 *       wlandev  wlan device structure.
582 *       priv     "priv" structure.
583 *       hw       "hw" structure.
584 *       msg      Message structure.
585 *       data     Data buffer.
586 *
587 * Returns:
588 *       0   - Success.
589 *       ~0  - Error.
590 *
591 ----------------------------------------------------------------*/
592
593 static int prism2mib_wepdefaultkey(
594 mibrec_t                     *mib,
595 int                          isget,
596 wlandevice_t                 *wlandev,
597 hfa384x_t                    *hw,
598 p80211msg_dot11req_mibset_t  *msg,
599 void                         *data)
600 {
601         int            result;
602         p80211pstrd_t  *pstr = (p80211pstrd_t*) data;
603         u8          bytebuf[MIB_TMP_MAXLEN];
604         u16         len;
605
606         DBFENTER;
607
608         if (isget) {
609                 result = 0;    /* Should never happen. */
610         } else {
611                 len = (pstr->len > 5) ? HFA384x_RID_CNFWEP128DEFAULTKEY_LEN :
612                                         HFA384x_RID_CNFWEPDEFAULTKEY_LEN;
613                 memset(bytebuf, 0, len);
614                 prism2mgmt_pstr2bytearea(bytebuf, pstr);
615                 result = hfa384x_drvr_setconfig(hw, mib->parm1, bytebuf, len);
616         }
617
618         DBFEXIT;
619         return(result);
620 }
621
622 /*----------------------------------------------------------------
623 * prism2mib_privacyinvoked
624 *
625 * Get/set the dot11PrivacyInvoked value.
626 *
627 * MIB record parameters:
628 *       parm1    Prism2 RID value.
629 *       parm2    Bit value for PrivacyInvoked flag.
630 *       parm3    Not used.
631 *
632 * Arguments:
633 *       mib      MIB record.
634 *       isget    MIBGET/MIBSET flag.
635 *       wlandev  wlan device structure.
636 *       priv     "priv" structure.
637 *       hw       "hw" structure.
638 *       msg      Message structure.
639 *       data     Data buffer.
640 *
641 * Returns:
642 *       0   - Success.
643 *       ~0  - Error.
644 *
645 ----------------------------------------------------------------*/
646
647 static int prism2mib_privacyinvoked(
648 mibrec_t                     *mib,
649 int                          isget,
650 wlandevice_t                 *wlandev,
651 hfa384x_t                    *hw,
652 p80211msg_dot11req_mibset_t  *msg,
653 void                         *data)
654 {
655         int     result;
656
657         DBFENTER;
658
659         if (wlandev->hostwep & HOSTWEP_DECRYPT) {
660                 if (wlandev->hostwep & HOSTWEP_DECRYPT)
661                         mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_RXCRYPT;
662                 if (wlandev->hostwep & HOSTWEP_ENCRYPT)
663                         mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_TXCRYPT;
664         }
665
666         result = prism2mib_flag(mib, isget, wlandev, hw, msg, data);
667
668         DBFEXIT;
669         return(result);
670 }
671
672 /*----------------------------------------------------------------
673 * prism2mib_excludeunencrypted
674 *
675 * Get/set the dot11ExcludeUnencrypted value.
676 *
677 * MIB record parameters:
678 *       parm1    Prism2 RID value.
679 *       parm2    Bit value for ExcludeUnencrypted flag.
680 *       parm3    Not used.
681 *
682 * Arguments:
683 *       mib      MIB record.
684 *       isget    MIBGET/MIBSET flag.
685 *       wlandev  wlan device structure.
686 *       priv     "priv" structure.
687 *       hw       "hw" structure.
688 *       msg      Message structure.
689 *       data     Data buffer.
690 *
691 * Returns:
692 *       0   - Success.
693 *       ~0  - Error.
694 *
695 ----------------------------------------------------------------*/
696
697 static int prism2mib_excludeunencrypted(
698 mibrec_t                     *mib,
699 int                          isget,
700 wlandevice_t                 *wlandev,
701 hfa384x_t                    *hw,
702 p80211msg_dot11req_mibset_t  *msg,
703 void                         *data)
704 {
705         int     result;
706
707         DBFENTER;
708
709         result = prism2mib_flag(mib, isget, wlandev, hw, msg, data);
710
711         DBFEXIT;
712         return(result);
713 }
714
715 /*----------------------------------------------------------------
716 * prism2mib_fragmentationthreshold
717 *
718 * Get/set the fragmentation threshold.
719 *
720 * MIB record parameters:
721 *       parm1    Prism2 RID value.
722 *       parm2    Not used.
723 *       parm3    Not used.
724 *
725 * Arguments:
726 *       mib      MIB record.
727 *       isget    MIBGET/MIBSET flag.
728 *       wlandev  wlan device structure.
729 *       priv     "priv" structure.
730 *       hw       "hw" structure.
731 *       msg      Message structure.
732 *       data     Data buffer.
733 *
734 * Returns:
735 *       0   - Success.
736 *       ~0  - Error.
737 *
738 ----------------------------------------------------------------*/
739
740 static int prism2mib_fragmentationthreshold(
741 mibrec_t                     *mib,
742 int                          isget,
743 wlandevice_t                 *wlandev,
744 hfa384x_t                    *hw,
745 p80211msg_dot11req_mibset_t  *msg,
746 void                         *data)
747 {
748         int     result;
749         u32  *uint32 = (u32*) data;
750
751         DBFENTER;
752
753         if (!isget)
754                 if ((*uint32) % 2) {
755                         WLAN_LOG_WARNING("Attempt to set odd number "
756                                           "FragmentationThreshold\n");
757                         msg->resultcode.data = P80211ENUM_resultcode_not_supported;
758                         return(0);
759                 }
760
761         result = prism2mib_uint32(mib, isget, wlandev, hw, msg, data);
762
763         DBFEXIT;
764         return(result);
765 }
766
767 /*----------------------------------------------------------------
768 * prism2mib_priv
769 *
770 * Get/set values in the "priv" data structure.
771 *
772 * MIB record parameters:
773 *       parm1    Not used.
774 *       parm2    Not used.
775 *       parm3    Not used.
776 *
777 * Arguments:
778 *       mib      MIB record.
779 *       isget    MIBGET/MIBSET flag.
780 *       wlandev  wlan device structure.
781 *       priv     "priv" structure.
782 *       hw       "hw" structure.
783 *       msg      Message structure.
784 *       data     Data buffer.
785 *
786 * Returns:
787 *       0   - Success.
788 *       ~0  - Error.
789 *
790 ----------------------------------------------------------------*/
791
792 static int prism2mib_priv(
793 mibrec_t                     *mib,
794 int                          isget,
795 wlandevice_t                 *wlandev,
796 hfa384x_t                    *hw,
797 p80211msg_dot11req_mibset_t  *msg,
798 void                         *data)
799 {
800         p80211pstrd_t     *pstr = (p80211pstrd_t*) data;
801
802         int  result;
803
804         DBFENTER;
805
806         switch (mib->did) {
807         case DIDmib_lnx_lnxConfigTable_lnxRSNAIE: {
808                 hfa384x_WPAData_t wpa;
809                 if (isget) {
810                         hfa384x_drvr_getconfig( hw, HFA384x_RID_CNFWPADATA,
811                                                 (u8 *) &wpa, sizeof(wpa));
812                         pstr->len = hfa384x2host_16(wpa.datalen);
813                         memcpy(pstr->data, wpa.data, pstr->len);
814                 } else {
815                         wpa.datalen = host2hfa384x_16(pstr->len);
816                         memcpy(wpa.data, pstr->data, pstr->len);
817
818                         result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFWPADATA,
819                                 (u8 *) &wpa, sizeof(wpa));
820                 }
821                 break;
822         }
823         default:
824                 WLAN_LOG_ERROR("Unhandled DID 0x%08x\n", mib->did);
825         }
826
827         DBFEXIT;
828         return(0);
829 }
830
831 /*----------------------------------------------------------------
832 * prism2mgmt_pstr2bytestr
833 *
834 * Convert the pstr data in the WLAN message structure into an hfa384x
835 * byte string format.
836 *
837 * Arguments:
838 *       bytestr         hfa384x byte string data type
839 *       pstr            wlan message data
840 *
841 * Returns:
842 *       Nothing
843 *
844 ----------------------------------------------------------------*/
845
846 void prism2mgmt_pstr2bytestr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr)
847 {
848         DBFENTER;
849
850         bytestr->len = host2hfa384x_16((u16)(pstr->len));
851         memcpy(bytestr->data, pstr->data, pstr->len);
852         DBFEXIT;
853 }
854
855
856 /*----------------------------------------------------------------
857 * prism2mgmt_pstr2bytearea
858 *
859 * Convert the pstr data in the WLAN message structure into an hfa384x
860 * byte area format.
861 *
862 * Arguments:
863 *       bytearea        hfa384x byte area data type
864 *       pstr            wlan message data
865 *
866 * Returns:
867 *       Nothing
868 *
869 ----------------------------------------------------------------*/
870
871 void prism2mgmt_pstr2bytearea(u8 *bytearea, p80211pstrd_t *pstr)
872 {
873         DBFENTER;
874
875         memcpy(bytearea, pstr->data, pstr->len);
876         DBFEXIT;
877 }
878
879
880 /*----------------------------------------------------------------
881 * prism2mgmt_bytestr2pstr
882 *
883 * Convert the data in an hfa384x byte string format into a
884 * pstr in the WLAN message.
885 *
886 * Arguments:
887 *       bytestr         hfa384x byte string data type
888 *       msg             wlan message
889 *
890 * Returns:
891 *       Nothing
892 *
893 ----------------------------------------------------------------*/
894
895 void prism2mgmt_bytestr2pstr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr)
896 {
897         DBFENTER;
898
899         pstr->len = (u8)(hfa384x2host_16((u16)(bytestr->len)));
900         memcpy(pstr->data, bytestr->data, pstr->len);
901         DBFEXIT;
902 }
903
904
905 /*----------------------------------------------------------------
906 * prism2mgmt_bytearea2pstr
907 *
908 * Convert the data in an hfa384x byte area format into a pstr
909 * in the WLAN message.
910 *
911 * Arguments:
912 *       bytearea        hfa384x byte area data type
913 *       msg             wlan message
914 *
915 * Returns:
916 *       Nothing
917 *
918 ----------------------------------------------------------------*/
919
920 void prism2mgmt_bytearea2pstr(u8 *bytearea, p80211pstrd_t *pstr, int len)
921 {
922         DBFENTER;
923
924         pstr->len = (u8)len;
925         memcpy(pstr->data, bytearea, len);
926         DBFEXIT;
927 }
928
929
930 /*----------------------------------------------------------------
931 * prism2mgmt_prism2int2p80211int
932 *
933 * Convert an hfa384x integer into a wlan integer
934 *
935 * Arguments:
936 *       prism2enum      pointer to hfa384x integer
937 *       wlanenum        pointer to p80211 integer
938 *
939 * Returns:
940 *       Nothing
941 *
942 ----------------------------------------------------------------*/
943
944 void prism2mgmt_prism2int2p80211int(u16 *prism2int, u32 *wlanint)
945 {
946         DBFENTER;
947
948         *wlanint = (u32)hfa384x2host_16(*prism2int);
949         DBFEXIT;
950 }
951
952
953 /*----------------------------------------------------------------
954 * prism2mgmt_p80211int2prism2int
955 *
956 * Convert a wlan integer into an hfa384x integer
957 *
958 * Arguments:
959 *       prism2enum      pointer to hfa384x integer
960 *       wlanenum        pointer to p80211 integer
961 *
962 * Returns:
963 *       Nothing
964 *
965 ----------------------------------------------------------------*/
966
967 void prism2mgmt_p80211int2prism2int(u16 *prism2int, u32 *wlanint)
968 {
969         DBFENTER;
970
971         *prism2int = host2hfa384x_16((u16)(*wlanint));
972         DBFEXIT;
973 }
974
975
976 /*----------------------------------------------------------------
977 * prism2mgmt_prism2enum2p80211enum
978 *
979 * Convert the hfa384x enumerated int into a p80211 enumerated int
980 *
981 * Arguments:
982 *       prism2enum      pointer to hfa384x integer
983 *       wlanenum        pointer to p80211 integer
984 *       rid             hfa384x record id
985 *
986 * Returns:
987 *       Nothing
988 *
989 ----------------------------------------------------------------*/
990 void prism2mgmt_prism2enum2p80211enum(u16 *prism2enum, u32 *wlanenum, u16 rid)
991 {
992         DBFENTER;
993
994         /* At the moment, the need for this functionality hasn't
995         presented itself. All the wlan enumerated values are
996         a 1-to-1 match against the Prism2 enumerated values*/
997         DBFEXIT;
998         return;
999 }
1000
1001
1002 /*----------------------------------------------------------------
1003 * prism2mgmt_p80211enum2prism2enum
1004 *
1005 * Convert the p80211 enumerated int into an hfa384x enumerated int
1006 *
1007 * Arguments:
1008 *       prism2enum      pointer to hfa384x integer
1009 *       wlanenum        pointer to p80211 integer
1010 *       rid             hfa384x record id
1011 *
1012 * Returns:
1013 *       Nothing
1014 *
1015 ----------------------------------------------------------------*/
1016 void prism2mgmt_p80211enum2prism2enum(u16 *prism2enum, u32 *wlanenum, u16 rid)
1017 {
1018         DBFENTER;
1019
1020         /* At the moment, the need for this functionality hasn't
1021         presented itself. All the wlan enumerated values are
1022         a 1-to-1 match against the Prism2 enumerated values*/
1023         DBFEXIT;
1024         return;
1025 }
1026
1027
1028
1029 /*----------------------------------------------------------------
1030 * prism2mgmt_get_oprateset
1031 *
1032 * Convert the hfa384x bit area into a wlan octet string.
1033 *
1034 * Arguments:
1035 *       rate            Prism2 bit area
1036 *       pstr            wlan octet string
1037 *
1038 * Returns:
1039 *       Nothing
1040 *
1041 ----------------------------------------------------------------*/
1042 void prism2mgmt_get_oprateset(u16 *rate, p80211pstrd_t *pstr)
1043 {
1044         u8      len;
1045         u8      *datarate;
1046
1047         DBFENTER;
1048
1049         len = 0;
1050         datarate = pstr->data;
1051
1052         /* 1 Mbps */
1053         if ( BIT0 & (*rate) ) {
1054                 len += (u8)1;
1055                 *datarate = (u8)2;
1056                 datarate++;
1057         }
1058
1059         /* 2 Mbps */
1060         if ( BIT1 & (*rate) ) {
1061                 len += (u8)1;
1062                 *datarate = (u8)4;
1063                 datarate++;
1064         }
1065
1066         /* 5.5 Mbps */
1067         if ( BIT2 & (*rate) ) {
1068                 len += (u8)1;
1069                 *datarate = (u8)11;
1070                 datarate++;
1071         }
1072
1073         /* 11 Mbps */
1074         if ( BIT3 & (*rate) ) {
1075                 len += (u8)1;
1076                 *datarate = (u8)22;
1077                 datarate++;
1078         }
1079
1080         pstr->len = len;
1081
1082         DBFEXIT;
1083         return;
1084 }
1085
1086
1087
1088 /*----------------------------------------------------------------
1089 * prism2mgmt_set_oprateset
1090 *
1091 * Convert the wlan octet string into an hfa384x bit area.
1092 *
1093 * Arguments:
1094 *       rate            Prism2 bit area
1095 *       pstr            wlan octet string
1096 *
1097 * Returns:
1098 *       Nothing
1099 *
1100 ----------------------------------------------------------------*/
1101 void prism2mgmt_set_oprateset(u16 *rate, p80211pstrd_t *pstr)
1102 {
1103         u8      *datarate;
1104         int     i;
1105
1106         DBFENTER;
1107
1108         *rate = 0;
1109
1110         datarate = pstr->data;
1111
1112         for ( i=0; i < pstr->len; i++, datarate++ ) {
1113                 switch (*datarate) {
1114                 case 2: /* 1 Mbps */
1115                         *rate |= BIT0;
1116                         break;
1117                 case 4: /* 2 Mbps */
1118                         *rate |= BIT1;
1119                         break;
1120                 case 11: /* 5.5 Mbps */
1121                         *rate |= BIT2;
1122                         break;
1123                 case 22: /* 11 Mbps */
1124                         *rate |= BIT3;
1125                         break;
1126                 default:
1127                         WLAN_LOG_DEBUG(1, "Unrecoginzed Rate of %d\n",
1128                                 *datarate);
1129                         break;
1130                 }
1131         }
1132
1133         DBFEXIT;
1134         return;
1135 }