added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / drivers / staging / wlan-ng / prism2mib.c
blob539c4479d381ddc9d68383102191b56fac816565
1 /* src/prism2/driver/prism2mib.c
3 * Management request for mibset/mibget
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
6 * --------------------------------------------------------------------
8 * linux-wlan
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/
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.
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.
31 * --------------------------------------------------------------------
33 * Inquiries regarding the linux-wlan Open Source project can be
34 * made directly to:
36 * AbsoluteValue Systems Inc.
37 * info@linux-wlan.com
38 * http://www.linux-wlan.com
40 * --------------------------------------------------------------------
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
45 * --------------------------------------------------------------------
47 * The functions in this file handle the mibset/mibget management
48 * functions.
50 * --------------------------------------------------------------------
53 /*================================================================*/
54 /* System Includes */
55 #define WLAN_DBVAR prism2_debug
57 #include <linux/version.h>
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>
71 /*================================================================*/
72 /* Project Includes */
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"
85 /*================================================================*/
86 /* Local Constants */
88 #define MIB_TMP_MAXLEN 200 /* Max length of RID record (in bytes). */
90 /*================================================================*/
91 /* Local Types */
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. */
97 typedef struct mibrec
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;
112 /*================================================================*/
113 /* Local Function Declarations */
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);
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);
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);
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);
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);
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);
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);
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);
179 /*================================================================*/
180 /* Local Static Definitions */
182 static mibrec_t mibtab[] = {
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 },
214 /* dot11mac MIB's */
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 },
241 /* dot11phy MIB's */
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 },
252 /* p2Static MIB's */
254 { DIDmib_p2_p2Static_p2CnfPortType,
255 F_STA | F_READ | F_WRITE,
256 HFA384x_RID_CNFPORTTYPE, 0, 0,
257 prism2mib_uint32 },
259 /* p2MAC MIB's */
261 { DIDmib_p2_p2MAC_p2CurrentTxRate,
262 F_STA | F_READ,
263 HFA384x_RID_CURRENTTXRATE, 0, 0,
264 prism2mib_uint32 },
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}};
273 /*================================================================*/
274 /* Function Definitions */
276 /*----------------------------------------------------------------
277 * prism2mgmt_mibset_mibget
279 * Set the value of a mib item.
281 * Arguments:
282 * wlandev wlan device structure
283 * msgp ptr to msg buffer
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:
291 * Call context:
292 * process thread (usually)
293 * interrupt
294 ----------------------------------------------------------------*/
296 int prism2mgmt_mibset_mibget(wlandevice_t *wlandev, void *msgp)
298 hfa384x_t *hw = wlandev->priv;
299 int result, isget;
300 mibrec_t *mib;
302 u16 which;
304 p80211msg_dot11req_mibset_t *msg = msgp;
305 p80211itemd_t *mibitem;
307 DBFENTER;
309 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
310 msg->resultcode.data = P80211ENUM_resultcode_success;
313 ** Determine if this is an Access Point or a station.
316 which = F_STA;
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.
325 mibitem = (p80211itemd_t *) msg->mibattribute.data;
327 for (mib = mibtab; mib->did != 0; mib++)
328 if (mib->did == mibitem->did && (mib->flag & which))
329 break;
331 if (mib->did == 0) {
332 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
333 goto done;
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.
342 isget = (msg->msgcode == DIDmsg_dot11req_mibget);
344 if (isget) {
345 if (!(mib->flag & F_READ)) {
346 msg->resultcode.data =
347 P80211ENUM_resultcode_cant_get_writeonly_mib;
348 goto done;
350 } else {
351 if (!(mib->flag & F_WRITE)) {
352 msg->resultcode.data =
353 P80211ENUM_resultcode_cant_set_readonly_mib;
354 goto done;
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".
366 result = mib->func(mib, isget, wlandev, hw, msg,
367 (void *) mibitem->data);
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;
385 done:
386 DBFEXIT;
388 return(0);
391 /*----------------------------------------------------------------
392 * prism2mib_bytearea2pstr
394 * Get/set pstr data to/from a byte area.
396 * MIB record parameters:
397 * parm1 Prism2 RID value.
398 * parm2 Number of bytes of RID data.
399 * parm3 Not used.
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.
410 * Returns:
411 * 0 - Success.
412 * ~0 - Error.
414 ----------------------------------------------------------------*/
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)
424 int result;
425 p80211pstrd_t *pstr = (p80211pstrd_t*) data;
426 u8 bytebuf[MIB_TMP_MAXLEN];
428 DBFENTER;
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);
439 DBFEXIT;
440 return(result);
443 /*----------------------------------------------------------------
444 * prism2mib_uint32
446 * Get/set uint32 data.
448 * MIB record parameters:
449 * parm1 Prism2 RID value.
450 * parm2 Not used.
451 * parm3 Not used.
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.
462 * Returns:
463 * 0 - Success.
464 * ~0 - Error.
466 ----------------------------------------------------------------*/
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)
476 int result;
477 u32 *uint32 = (u32*) data;
478 u8 bytebuf[MIB_TMP_MAXLEN];
479 u16 *wordbuf = (u16*) bytebuf;
481 DBFENTER;
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);
489 } else {
490 /* [MSM] Removed, setconfig16 expects host order.
491 * prism2mgmt_p80211int2prism2int(wordbuf, uint32);
493 *wordbuf = *uint32;
494 result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
497 DBFEXIT;
498 return(result);
501 /*----------------------------------------------------------------
502 * prism2mib_flag
504 * Get/set a flag.
506 * MIB record parameters:
507 * parm1 Prism2 RID value.
508 * parm2 Bit to get/set.
509 * parm3 Not used.
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.
520 * Returns:
521 * 0 - Success.
522 * ~0 - Error.
524 ----------------------------------------------------------------*/
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)
534 int result;
535 u32 *uint32 = (u32*) data;
536 u8 bytebuf[MIB_TMP_MAXLEN];
537 u16 *wordbuf = (u16*) bytebuf;
538 u32 flags;
540 DBFENTER;
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);
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);
559 *wordbuf = flags;
560 result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
564 DBFEXIT;
565 return(result);
568 /*----------------------------------------------------------------
569 * prism2mib_wepdefaultkey
571 * Get/set WEP default keys.
573 * MIB record parameters:
574 * parm1 Prism2 RID value.
575 * parm2 Number of bytes of RID data.
576 * parm3 Not used.
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.
587 * Returns:
588 * 0 - Success.
589 * ~0 - Error.
591 ----------------------------------------------------------------*/
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)
601 int result;
602 p80211pstrd_t *pstr = (p80211pstrd_t*) data;
603 u8 bytebuf[MIB_TMP_MAXLEN];
604 u16 len;
606 DBFENTER;
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);
618 DBFEXIT;
619 return(result);
622 /*----------------------------------------------------------------
623 * prism2mib_privacyinvoked
625 * Get/set the dot11PrivacyInvoked value.
627 * MIB record parameters:
628 * parm1 Prism2 RID value.
629 * parm2 Bit value for PrivacyInvoked flag.
630 * parm3 Not used.
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.
641 * Returns:
642 * 0 - Success.
643 * ~0 - Error.
645 ----------------------------------------------------------------*/
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)
655 int result;
657 DBFENTER;
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;
666 result = prism2mib_flag(mib, isget, wlandev, hw, msg, data);
668 DBFEXIT;
669 return(result);
672 /*----------------------------------------------------------------
673 * prism2mib_excludeunencrypted
675 * Get/set the dot11ExcludeUnencrypted value.
677 * MIB record parameters:
678 * parm1 Prism2 RID value.
679 * parm2 Bit value for ExcludeUnencrypted flag.
680 * parm3 Not used.
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.
691 * Returns:
692 * 0 - Success.
693 * ~0 - Error.
695 ----------------------------------------------------------------*/
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)
705 int result;
707 DBFENTER;
709 result = prism2mib_flag(mib, isget, wlandev, hw, msg, data);
711 DBFEXIT;
712 return(result);
715 /*----------------------------------------------------------------
716 * prism2mib_fragmentationthreshold
718 * Get/set the fragmentation threshold.
720 * MIB record parameters:
721 * parm1 Prism2 RID value.
722 * parm2 Not used.
723 * parm3 Not used.
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.
734 * Returns:
735 * 0 - Success.
736 * ~0 - Error.
738 ----------------------------------------------------------------*/
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)
748 int result;
749 u32 *uint32 = (u32*) data;
751 DBFENTER;
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);
761 result = prism2mib_uint32(mib, isget, wlandev, hw, msg, data);
763 DBFEXIT;
764 return(result);
767 /*----------------------------------------------------------------
768 * prism2mib_priv
770 * Get/set values in the "priv" data structure.
772 * MIB record parameters:
773 * parm1 Not used.
774 * parm2 Not used.
775 * parm3 Not used.
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.
786 * Returns:
787 * 0 - Success.
788 * ~0 - Error.
790 ----------------------------------------------------------------*/
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)
800 p80211pstrd_t *pstr = (p80211pstrd_t*) data;
802 int result;
804 DBFENTER;
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);
818 result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFWPADATA,
819 (u8 *) &wpa, sizeof(wpa));
821 break;
823 default:
824 WLAN_LOG_ERROR("Unhandled DID 0x%08x\n", mib->did);
827 DBFEXIT;
828 return(0);
831 /*----------------------------------------------------------------
832 * prism2mgmt_pstr2bytestr
834 * Convert the pstr data in the WLAN message structure into an hfa384x
835 * byte string format.
837 * Arguments:
838 * bytestr hfa384x byte string data type
839 * pstr wlan message data
841 * Returns:
842 * Nothing
844 ----------------------------------------------------------------*/
846 void prism2mgmt_pstr2bytestr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr)
848 DBFENTER;
850 bytestr->len = host2hfa384x_16((u16)(pstr->len));
851 memcpy(bytestr->data, pstr->data, pstr->len);
852 DBFEXIT;
856 /*----------------------------------------------------------------
857 * prism2mgmt_pstr2bytearea
859 * Convert the pstr data in the WLAN message structure into an hfa384x
860 * byte area format.
862 * Arguments:
863 * bytearea hfa384x byte area data type
864 * pstr wlan message data
866 * Returns:
867 * Nothing
869 ----------------------------------------------------------------*/
871 void prism2mgmt_pstr2bytearea(u8 *bytearea, p80211pstrd_t *pstr)
873 DBFENTER;
875 memcpy(bytearea, pstr->data, pstr->len);
876 DBFEXIT;
880 /*----------------------------------------------------------------
881 * prism2mgmt_bytestr2pstr
883 * Convert the data in an hfa384x byte string format into a
884 * pstr in the WLAN message.
886 * Arguments:
887 * bytestr hfa384x byte string data type
888 * msg wlan message
890 * Returns:
891 * Nothing
893 ----------------------------------------------------------------*/
895 void prism2mgmt_bytestr2pstr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr)
897 DBFENTER;
899 pstr->len = (u8)(hfa384x2host_16((u16)(bytestr->len)));
900 memcpy(pstr->data, bytestr->data, pstr->len);
901 DBFEXIT;
905 /*----------------------------------------------------------------
906 * prism2mgmt_bytearea2pstr
908 * Convert the data in an hfa384x byte area format into a pstr
909 * in the WLAN message.
911 * Arguments:
912 * bytearea hfa384x byte area data type
913 * msg wlan message
915 * Returns:
916 * Nothing
918 ----------------------------------------------------------------*/
920 void prism2mgmt_bytearea2pstr(u8 *bytearea, p80211pstrd_t *pstr, int len)
922 DBFENTER;
924 pstr->len = (u8)len;
925 memcpy(pstr->data, bytearea, len);
926 DBFEXIT;
930 /*----------------------------------------------------------------
931 * prism2mgmt_prism2int2p80211int
933 * Convert an hfa384x integer into a wlan integer
935 * Arguments:
936 * prism2enum pointer to hfa384x integer
937 * wlanenum pointer to p80211 integer
939 * Returns:
940 * Nothing
942 ----------------------------------------------------------------*/
944 void prism2mgmt_prism2int2p80211int(u16 *prism2int, u32 *wlanint)
946 DBFENTER;
948 *wlanint = (u32)hfa384x2host_16(*prism2int);
949 DBFEXIT;
953 /*----------------------------------------------------------------
954 * prism2mgmt_p80211int2prism2int
956 * Convert a wlan integer into an hfa384x integer
958 * Arguments:
959 * prism2enum pointer to hfa384x integer
960 * wlanenum pointer to p80211 integer
962 * Returns:
963 * Nothing
965 ----------------------------------------------------------------*/
967 void prism2mgmt_p80211int2prism2int(u16 *prism2int, u32 *wlanint)
969 DBFENTER;
971 *prism2int = host2hfa384x_16((u16)(*wlanint));
972 DBFEXIT;
976 /*----------------------------------------------------------------
977 * prism2mgmt_prism2enum2p80211enum
979 * Convert the hfa384x enumerated int into a p80211 enumerated int
981 * Arguments:
982 * prism2enum pointer to hfa384x integer
983 * wlanenum pointer to p80211 integer
984 * rid hfa384x record id
986 * Returns:
987 * Nothing
989 ----------------------------------------------------------------*/
990 void prism2mgmt_prism2enum2p80211enum(u16 *prism2enum, u32 *wlanenum, u16 rid)
992 DBFENTER;
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;
1002 /*----------------------------------------------------------------
1003 * prism2mgmt_p80211enum2prism2enum
1005 * Convert the p80211 enumerated int into an hfa384x enumerated int
1007 * Arguments:
1008 * prism2enum pointer to hfa384x integer
1009 * wlanenum pointer to p80211 integer
1010 * rid hfa384x record id
1012 * Returns:
1013 * Nothing
1015 ----------------------------------------------------------------*/
1016 void prism2mgmt_p80211enum2prism2enum(u16 *prism2enum, u32 *wlanenum, u16 rid)
1018 DBFENTER;
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;
1029 /*----------------------------------------------------------------
1030 * prism2mgmt_get_oprateset
1032 * Convert the hfa384x bit area into a wlan octet string.
1034 * Arguments:
1035 * rate Prism2 bit area
1036 * pstr wlan octet string
1038 * Returns:
1039 * Nothing
1041 ----------------------------------------------------------------*/
1042 void prism2mgmt_get_oprateset(u16 *rate, p80211pstrd_t *pstr)
1044 u8 len;
1045 u8 *datarate;
1047 DBFENTER;
1049 len = 0;
1050 datarate = pstr->data;
1052 /* 1 Mbps */
1053 if ( BIT0 & (*rate) ) {
1054 len += (u8)1;
1055 *datarate = (u8)2;
1056 datarate++;
1059 /* 2 Mbps */
1060 if ( BIT1 & (*rate) ) {
1061 len += (u8)1;
1062 *datarate = (u8)4;
1063 datarate++;
1066 /* 5.5 Mbps */
1067 if ( BIT2 & (*rate) ) {
1068 len += (u8)1;
1069 *datarate = (u8)11;
1070 datarate++;
1073 /* 11 Mbps */
1074 if ( BIT3 & (*rate) ) {
1075 len += (u8)1;
1076 *datarate = (u8)22;
1077 datarate++;
1080 pstr->len = len;
1082 DBFEXIT;
1083 return;
1088 /*----------------------------------------------------------------
1089 * prism2mgmt_set_oprateset
1091 * Convert the wlan octet string into an hfa384x bit area.
1093 * Arguments:
1094 * rate Prism2 bit area
1095 * pstr wlan octet string
1097 * Returns:
1098 * Nothing
1100 ----------------------------------------------------------------*/
1101 void prism2mgmt_set_oprateset(u16 *rate, p80211pstrd_t *pstr)
1103 u8 *datarate;
1104 int i;
1106 DBFENTER;
1108 *rate = 0;
1110 datarate = pstr->data;
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;
1133 DBFEXIT;
1134 return;