9cd5c74c778c931ea00fe92a2f9327583cdc5399
[firefly-linux-kernel-4.4.55.git] / 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_bytestr2pstr(
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_bytearea2pstr(
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_uint32(
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_uint32array(
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_uint32offset(
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_truth(
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_preamble(
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_flag(
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 static int prism2mib_regulatorydomains(
180 mibrec_t                     *mib,
181 int                          isget,
182 wlandevice_t                 *wlandev,
183 hfa384x_t                    *hw,
184 p80211msg_dot11req_mibset_t  *msg,
185 void                         *data);
186
187 static int prism2mib_wepdefaultkey(
188 mibrec_t                     *mib,
189 int                          isget,
190 wlandevice_t                 *wlandev,
191 hfa384x_t                    *hw,
192 p80211msg_dot11req_mibset_t  *msg,
193 void                         *data);
194
195 static int prism2mib_powermanagement(
196 mibrec_t                     *mib,
197 int                          isget,
198 wlandevice_t                 *wlandev,
199 hfa384x_t                    *hw,
200 p80211msg_dot11req_mibset_t  *msg,
201 void                         *data);
202
203 static int prism2mib_privacyinvoked(
204 mibrec_t                     *mib,
205 int                          isget,
206 wlandevice_t                 *wlandev,
207 hfa384x_t                    *hw,
208 p80211msg_dot11req_mibset_t  *msg,
209 void                         *data);
210
211 static int prism2mib_excludeunencrypted(
212 mibrec_t                     *mib,
213 int                          isget,
214 wlandevice_t                 *wlandev,
215 hfa384x_t                    *hw,
216 p80211msg_dot11req_mibset_t  *msg,
217 void                         *data);
218
219 static int prism2mib_fragmentationthreshold(
220 mibrec_t                     *mib,
221 int                          isget,
222 wlandevice_t                 *wlandev,
223 hfa384x_t                    *hw,
224 p80211msg_dot11req_mibset_t  *msg,
225 void                         *data);
226
227 static int prism2mib_operationalrateset(
228 mibrec_t                     *mib,
229 int                          isget,
230 wlandevice_t                 *wlandev,
231 hfa384x_t                    *hw,
232 p80211msg_dot11req_mibset_t  *msg,
233 void                         *data);
234
235 static int prism2mib_fwid(
236 mibrec_t                     *mib,
237 int                          isget,
238 wlandevice_t                 *wlandev,
239 hfa384x_t                    *hw,
240 p80211msg_dot11req_mibset_t  *msg,
241 void                         *data);
242
243 static int prism2mib_authalg(
244 mibrec_t                     *mib,
245 int                          isget,
246 wlandevice_t                 *wlandev,
247 hfa384x_t                    *hw,
248 p80211msg_dot11req_mibset_t  *msg,
249 void                         *data);
250
251 static int prism2mib_authalgenable(
252 mibrec_t                     *mib,
253 int                          isget,
254 wlandevice_t                 *wlandev,
255 hfa384x_t                    *hw,
256 p80211msg_dot11req_mibset_t  *msg,
257 void                         *data);
258
259 static int prism2mib_priv(
260 mibrec_t                     *mib,
261 int                          isget,
262 wlandevice_t                 *wlandev,
263 hfa384x_t                    *hw,
264 p80211msg_dot11req_mibset_t  *msg,
265 void                         *data);
266
267 /*================================================================*/
268 /* Local Static Definitions */
269
270 static mibrec_t mibtab[] = {
271
272     /* dot11smt MIB's */
273
274     { DIDmib_dot11smt_dot11StationConfigTable_dot11StationID,
275           F_STA | F_READ | F_WRITE,
276           HFA384x_RID_CNFOWNMACADDR, HFA384x_RID_CNFOWNMACADDR_LEN, 0,
277           prism2mib_bytearea2pstr },
278     { DIDmib_dot11smt_dot11StationConfigTable_dot11CFPollable,
279           F_STA | F_READ,
280           HFA384x_RID_CFPOLLABLE, 0, 0,
281           prism2mib_uint32 },
282     { DIDmib_dot11smt_dot11StationConfigTable_dot11AuthenticationResponseTimeOut,
283           F_STA | F_READ | F_WRITE,
284           HFA384x_RID_CNFAUTHRSPTIMEOUT, 0, 0,
285           prism2mib_uint32 },
286     { DIDmib_dot11smt_dot11StationConfigTable_dot11PrivacyOptionImplemented,
287           F_STA | F_READ,
288           HFA384x_RID_PRIVACYOPTIMP, 0, 0,
289           prism2mib_uint32 },
290     { DIDmib_dot11smt_dot11StationConfigTable_dot11PowerManagementMode,
291           F_STA | F_READ | F_WRITE,
292           HFA384x_RID_CNFPMENABLED, 0, 0,
293           prism2mib_powermanagement },
294     { DIDmib_dot11smt_dot11StationConfigTable_dot11DesiredSSID,
295           F_STA | F_READ | F_WRITE,
296           HFA384x_RID_CNFDESIREDSSID, HFA384x_RID_CNFDESIREDSSID_LEN, 0,
297           prism2mib_bytestr2pstr },
298     { DIDmib_dot11smt_dot11StationConfigTable_dot11DesiredBSSType,
299           F_STA | F_READ | F_WRITE,
300           0, 0, 0,
301           prism2mib_priv },
302     { DIDmib_dot11smt_dot11StationConfigTable_dot11OperationalRateSet,
303           F_STA | F_READ | F_WRITE,
304           HFA384x_RID_TXRATECNTL, 0, 0,
305           prism2mib_operationalrateset },
306     { DIDmib_dot11smt_dot11StationConfigTable_dot11DTIMPeriod,
307           F_STA | F_READ | F_WRITE,
308           HFA384x_RID_CNFOWNDTIMPER, 0, 0,
309           prism2mib_uint32 },
310     { DIDmib_dot11smt_dot11StationConfigTable_dot11AssociationResponseTimeOut,
311           F_STA | F_READ,
312           HFA384x_RID_PROTOCOLRSPTIME, 0, 0,
313           prism2mib_uint32 },
314     { DIDmib_dot11smt_dot11AuthenticationAlgorithmsTable_dot11AuthenticationAlgorithm1,
315           F_STA | F_READ,
316           1, 0, 0,
317           prism2mib_authalg },
318     { DIDmib_dot11smt_dot11AuthenticationAlgorithmsTable_dot11AuthenticationAlgorithm2,
319           F_STA | F_READ,
320           2, 0, 0,
321           prism2mib_authalg },
322     { DIDmib_dot11smt_dot11AuthenticationAlgorithmsTable_dot11AuthenticationAlgorithm3,
323           F_STA | F_READ,
324           3, 0, 0,
325           prism2mib_authalg },
326     { DIDmib_dot11smt_dot11AuthenticationAlgorithmsTable_dot11AuthenticationAlgorithm4,
327           F_STA | F_READ,
328           4, 0, 0,
329           prism2mib_authalg },
330     { DIDmib_dot11smt_dot11AuthenticationAlgorithmsTable_dot11AuthenticationAlgorithm5,
331           F_STA | F_READ,
332           5, 0, 0,
333           prism2mib_authalg },
334     { DIDmib_dot11smt_dot11AuthenticationAlgorithmsTable_dot11AuthenticationAlgorithm6,
335           F_STA | F_READ,
336           6, 0, 0,
337           prism2mib_authalg },
338     { DIDmib_dot11smt_dot11AuthenticationAlgorithmsTable_dot11AuthenticationAlgorithmsEnable1,
339           F_STA | F_READ | F_WRITE,
340           1, 0, 0,
341           prism2mib_authalgenable },
342     { DIDmib_dot11smt_dot11AuthenticationAlgorithmsTable_dot11AuthenticationAlgorithmsEnable2,
343           F_STA | F_READ | F_WRITE,
344           2, 0, 0,
345           prism2mib_authalgenable },
346     { DIDmib_dot11smt_dot11AuthenticationAlgorithmsTable_dot11AuthenticationAlgorithmsEnable3,
347           F_STA | F_READ | F_WRITE,
348           3, 0, 0,
349           prism2mib_authalgenable },
350     { DIDmib_dot11smt_dot11AuthenticationAlgorithmsTable_dot11AuthenticationAlgorithmsEnable4,
351           F_STA | F_READ | F_WRITE,
352           4, 0, 0,
353           prism2mib_authalgenable },
354     { DIDmib_dot11smt_dot11AuthenticationAlgorithmsTable_dot11AuthenticationAlgorithmsEnable5,
355           F_STA | F_READ | F_WRITE,
356           5, 0, 0,
357           prism2mib_authalgenable },
358     { DIDmib_dot11smt_dot11AuthenticationAlgorithmsTable_dot11AuthenticationAlgorithmsEnable6,
359           F_STA | F_READ | F_WRITE,
360           6, 0, 0,
361           prism2mib_authalgenable },
362     { DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0,
363           F_STA | F_WRITE,
364           HFA384x_RID_CNFWEPDEFAULTKEY0, 0, 0,
365           prism2mib_wepdefaultkey },
366     { DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1,
367           F_STA | F_WRITE,
368           HFA384x_RID_CNFWEPDEFAULTKEY1, 0, 0,
369           prism2mib_wepdefaultkey },
370     { DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2,
371           F_STA | F_WRITE,
372           HFA384x_RID_CNFWEPDEFAULTKEY2, 0, 0,
373           prism2mib_wepdefaultkey },
374     { DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3,
375           F_STA | F_WRITE,
376           HFA384x_RID_CNFWEPDEFAULTKEY3, 0, 0,
377           prism2mib_wepdefaultkey },
378     { DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
379           F_STA | F_READ | F_WRITE,
380           HFA384x_RID_CNFWEPFLAGS, HFA384x_WEPFLAGS_PRIVINVOKED, 0,
381           prism2mib_privacyinvoked },
382     { DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
383           F_STA | F_READ | F_WRITE,
384           HFA384x_RID_CNFWEPDEFAULTKEYID, 0, 0,
385           prism2mib_uint32 },
386     { DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
387           F_STA | F_READ | F_WRITE,
388           HFA384x_RID_CNFWEPFLAGS, HFA384x_WEPFLAGS_EXCLUDE, 0,
389           prism2mib_excludeunencrypted },
390     { DIDmib_dot11phy_dot11PhyOperationTable_dot11ShortPreambleEnabled,
391           F_STA | F_READ | F_WRITE,
392           HFA384x_RID_CNFSHORTPREAMBLE, 0, 0,
393           prism2mib_preamble },
394
395     /* dot11mac MIB's */
396
397     { DIDmib_dot11mac_dot11OperationTable_dot11MACAddress,
398           F_STA | F_READ | F_WRITE,
399           HFA384x_RID_CNFOWNMACADDR, HFA384x_RID_CNFOWNMACADDR_LEN, 0,
400           prism2mib_bytearea2pstr },
401     { DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold,
402           F_STA | F_READ | F_WRITE,
403           HFA384x_RID_RTSTHRESH, 0, 0,
404           prism2mib_uint32 },
405     { DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit,
406           F_STA | F_READ,
407           HFA384x_RID_SHORTRETRYLIMIT, 0, 0,
408           prism2mib_uint32 },
409     { DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit,
410           F_STA | F_READ,
411           HFA384x_RID_LONGRETRYLIMIT, 0, 0,
412           prism2mib_uint32 },
413     { DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold,
414           F_STA | F_READ | F_WRITE,
415           HFA384x_RID_FRAGTHRESH, 0, 0,
416           prism2mib_fragmentationthreshold },
417     { DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime,
418           F_STA | F_READ,
419           HFA384x_RID_MAXTXLIFETIME, 0, 0,
420           prism2mib_uint32 },
421     { DIDmib_dot11mac_dot11OperationTable_dot11MaxReceiveLifetime,
422           F_STA | F_READ,
423           HFA384x_RID_MAXRXLIFETIME, 0, 0,
424           prism2mib_uint32 },
425
426     /* dot11phy MIB's */
427
428     { DIDmib_dot11phy_dot11PhyOperationTable_dot11PHYType,
429           F_STA | F_READ,
430           HFA384x_RID_PHYTYPE, 0, 0,
431           prism2mib_uint32 },
432     { DIDmib_dot11phy_dot11PhyOperationTable_dot11TempType,
433           F_STA | F_READ,
434           HFA384x_RID_TEMPTYPE, 0, 0,
435           prism2mib_uint32 },
436     { DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel,
437           F_STA | F_READ,
438           HFA384x_RID_CURRENTCHANNEL, 0, 0,
439           prism2mib_uint32 },
440     { DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentCCAMode,
441           F_STA | F_READ,
442           HFA384x_RID_CCAMODE, 0, 0,
443           prism2mib_uint32 },
444
445     /* p2Table MIB's */
446
447     { DIDmib_p2_p2Table_p2MMTx,
448           F_STA | F_READ | F_WRITE,
449           0, 0, 0,
450           prism2mib_priv },
451     { DIDmib_p2_p2Table_p2ReceivedFrameStatistics,
452           F_STA | F_READ,
453           0, 0, 0,
454           prism2mib_priv },
455     { DIDmib_p2_p2Table_p2CommunicationTallies,
456           F_STA | F_READ,
457           0, 0, 0,
458           prism2mib_priv },
459     { DIDmib_p2_p2Table_p2Comment,
460           F_STA | F_READ | F_WRITE,
461           0, 0, 0,
462           prism2mib_priv },
463
464     /* p2Static MIB's */
465
466     { DIDmib_p2_p2Static_p2CnfPortType,
467           F_STA | F_READ | F_WRITE,
468           HFA384x_RID_CNFPORTTYPE, 0, 0,
469           prism2mib_uint32 },
470     { DIDmib_p2_p2Static_p2CnfOwnMACAddress,
471           F_STA | F_READ | F_WRITE,
472           HFA384x_RID_CNFOWNMACADDR, HFA384x_RID_CNFOWNMACADDR_LEN, 0,
473           prism2mib_bytearea2pstr },
474     { DIDmib_p2_p2Static_p2CnfDesiredSSID,
475           F_STA | F_READ | F_WRITE,
476           HFA384x_RID_CNFDESIREDSSID, HFA384x_RID_CNFDESIREDSSID_LEN, 0,
477           prism2mib_bytestr2pstr },
478     { DIDmib_p2_p2Static_p2CnfOwnChannel,
479           F_STA | F_READ | F_WRITE,
480           HFA384x_RID_CNFOWNCHANNEL, 0, 0,
481           prism2mib_uint32 },
482     { DIDmib_p2_p2Static_p2CnfOwnSSID,
483           F_STA | F_READ | F_WRITE,
484           HFA384x_RID_CNFOWNSSID, HFA384x_RID_CNFOWNSSID_LEN, 0,
485           prism2mib_bytestr2pstr },
486     { DIDmib_p2_p2Static_p2CnfOwnATIMWindow,
487           F_STA | F_READ | F_WRITE,
488           HFA384x_RID_CNFOWNATIMWIN, 0, 0,
489           prism2mib_uint32 },
490     { DIDmib_p2_p2Static_p2CnfSystemScale,
491           F_STA | F_READ | F_WRITE,
492           HFA384x_RID_CNFSYSSCALE, 0, 0,
493           prism2mib_uint32 },
494     { DIDmib_p2_p2Static_p2CnfMaxDataLength,
495           F_STA | F_READ | F_WRITE,
496           HFA384x_RID_CNFMAXDATALEN, 0, 0,
497           prism2mib_uint32 },
498     { DIDmib_p2_p2Static_p2CnfWDSAddress,
499           F_STA | F_READ | F_WRITE,
500           HFA384x_RID_CNFWDSADDR, HFA384x_RID_CNFWDSADDR_LEN, 0,
501           prism2mib_bytearea2pstr },
502     { DIDmib_p2_p2Static_p2CnfPMEnabled,
503           F_STA | F_READ | F_WRITE,
504           HFA384x_RID_CNFPMENABLED, 0, 0,
505           prism2mib_truth },
506     { DIDmib_p2_p2Static_p2CnfPMEPS,
507           F_STA | F_READ | F_WRITE,
508           HFA384x_RID_CNFPMEPS, 0, 0,
509           prism2mib_truth },
510     { DIDmib_p2_p2Static_p2CnfMulticastReceive,
511           F_STA | F_READ | F_WRITE,
512           HFA384x_RID_CNFMULTICASTRX, 0, 0,
513           prism2mib_truth },
514     { DIDmib_p2_p2Static_p2CnfMaxSleepDuration,
515           F_STA | F_READ | F_WRITE,
516           HFA384x_RID_CNFMAXSLEEPDUR, 0, 0,
517           prism2mib_uint32 },
518     { DIDmib_p2_p2Static_p2CnfPMHoldoverDuration,
519           F_STA | F_READ | F_WRITE,
520           HFA384x_RID_CNFPMHOLDDUR, 0, 0,
521           prism2mib_uint32 },
522     { DIDmib_p2_p2Static_p2CnfOwnName,
523           F_STA | F_READ | F_WRITE,
524           HFA384x_RID_CNFOWNNAME, HFA384x_RID_CNFOWNNAME_LEN, 0,
525           prism2mib_bytestr2pstr },
526     { DIDmib_p2_p2Static_p2CnfOwnDTIMPeriod,
527           F_STA | F_READ | F_WRITE,
528           HFA384x_RID_CNFOWNDTIMPER, 0, 0,
529           prism2mib_uint32 },
530     { DIDmib_p2_p2Static_p2CnfWEPDefaultKeyID,
531           F_STA | F_READ | F_WRITE,
532           HFA384x_RID_CNFWEPDEFAULTKEYID, 0, 0,
533           prism2mib_uint32 },
534     { DIDmib_p2_p2Static_p2CnfWEPDefaultKey0,
535           F_STA | F_WRITE,
536           HFA384x_RID_CNFWEPDEFAULTKEY0, 0, 0,
537           prism2mib_wepdefaultkey },
538     { DIDmib_p2_p2Static_p2CnfWEPDefaultKey1,
539           F_STA | F_WRITE,
540           HFA384x_RID_CNFWEPDEFAULTKEY1, 0, 0,
541           prism2mib_wepdefaultkey },
542     { DIDmib_p2_p2Static_p2CnfWEPDefaultKey2,
543           F_STA | F_WRITE,
544           HFA384x_RID_CNFWEPDEFAULTKEY2, 0, 0,
545           prism2mib_wepdefaultkey },
546     { DIDmib_p2_p2Static_p2CnfWEPDefaultKey3,
547           F_STA | F_WRITE,
548           HFA384x_RID_CNFWEPDEFAULTKEY3, 0, 0,
549           prism2mib_wepdefaultkey },
550     { DIDmib_p2_p2Static_p2CnfWEPFlags,
551           F_STA | F_READ | F_WRITE,
552           HFA384x_RID_CNFWEPFLAGS, 0, 0,
553           prism2mib_uint32 },
554     { DIDmib_p2_p2Static_p2CnfAuthentication,
555           F_STA | F_READ | F_WRITE,
556           HFA384x_RID_CNFAUTHENTICATION, 0, 0,
557           prism2mib_uint32 },
558     { DIDmib_p2_p2Static_p2CnfTxControl,
559           F_STA | F_READ | F_WRITE,
560           HFA384x_RID_CNFTXCONTROL, 0, 0,
561           prism2mib_uint32 },
562     { DIDmib_p2_p2Static_p2CnfRoamingMode,
563           F_STA | F_READ | F_WRITE,
564           HFA384x_RID_CNFROAMINGMODE, 0, 0,
565           prism2mib_uint32 },
566     { DIDmib_p2_p2Static_p2CnfRcvCrcError,
567           F_STA | F_READ | F_WRITE,
568           HFA384x_RID_CNFRCVCRCERROR, 0, 0,
569           prism2mib_uint32 },
570     { DIDmib_p2_p2Static_p2CnfAltRetryCount,
571           F_STA | F_READ | F_WRITE,
572           HFA384x_RID_CNFALTRETRYCNT, 0, 0,
573           prism2mib_uint32 },
574     { DIDmib_p2_p2Static_p2CnfSTAPCFInfo,
575           F_STA | F_READ | F_WRITE,
576           HFA384x_RID_CNFSTAPCFINFO, 0, 0,
577           prism2mib_uint32 },
578     { DIDmib_p2_p2Static_p2CnfPriorityQUsage,
579           F_STA | F_READ | F_WRITE,
580           HFA384x_RID_CNFPRIORITYQUSAGE, HFA384x_RID_CNFPRIOQUSAGE_LEN, 0,
581           prism2mib_uint32array },
582     { DIDmib_p2_p2Static_p2CnfTIMCtrl,
583           F_STA | F_READ | F_WRITE,
584           HFA384x_RID_CNFTIMCTRL, 0, 0,
585           prism2mib_uint32 },
586     { DIDmib_p2_p2Static_p2CnfThirty2Tally,
587           F_STA | F_READ | F_WRITE,
588           HFA384x_RID_CNFTHIRTY2TALLY, 0, 0,
589           prism2mib_truth },
590     { DIDmib_p2_p2Static_p2CnfShortPreamble,
591           F_STA | F_READ | F_WRITE,
592           HFA384x_RID_CNFSHORTPREAMBLE, 0, 0,
593           prism2mib_preamble },
594     { DIDmib_p2_p2Static_p2CnfAuthenticationRspTO,
595           F_STA | F_READ | F_WRITE,
596           HFA384x_RID_CNFAUTHRSPTIMEOUT, 0, 0,
597           prism2mib_uint32 },
598     { DIDmib_p2_p2Static_p2CnfBasicRates,
599           F_STA | F_READ | F_WRITE,
600           HFA384x_RID_CNFBASICRATES, 0, 0,
601           prism2mib_uint32 },
602     { DIDmib_p2_p2Static_p2CnfSupportedRates,
603           F_STA | F_READ | F_WRITE,
604           HFA384x_RID_CNFSUPPRATES, 0, 0,
605           prism2mib_uint32 },
606
607     /* p2Dynamic MIB's */
608
609     { DIDmib_p2_p2Dynamic_p2CreateIBSS,
610           F_STA | F_READ | F_WRITE,
611           HFA384x_RID_CREATEIBSS, 0, 0,
612           prism2mib_truth },
613     { DIDmib_p2_p2Dynamic_p2FragmentationThreshold,
614           F_STA | F_READ | F_WRITE,
615           HFA384x_RID_FRAGTHRESH, 0, 0,
616           prism2mib_fragmentationthreshold },
617     { DIDmib_p2_p2Dynamic_p2RTSThreshold,
618           F_STA | F_READ | F_WRITE,
619           HFA384x_RID_RTSTHRESH, 0, 0,
620           prism2mib_uint32 },
621     { DIDmib_p2_p2Dynamic_p2TxRateControl,
622           F_STA | F_READ | F_WRITE,
623           HFA384x_RID_TXRATECNTL, 0, 0,
624           prism2mib_uint32 },
625     { DIDmib_p2_p2Dynamic_p2PromiscuousMode,
626           F_STA | F_READ | F_WRITE,
627           HFA384x_RID_PROMISCMODE, 0, 0,
628           prism2mib_truth },
629
630     /* p2Behavior MIB's */
631
632     { DIDmib_p2_p2Behavior_p2TickTime,
633           F_STA | F_READ | F_WRITE,
634           HFA384x_RID_ITICKTIME, 0, 0,
635           prism2mib_uint32 },
636
637     /* p2NIC MIB's */
638
639     { DIDmib_p2_p2NIC_p2MaxLoadTime,
640           F_STA | F_READ,
641           HFA384x_RID_MAXLOADTIME, 0, 0,
642           prism2mib_uint32 },
643     { DIDmib_p2_p2NIC_p2DLBufferPage,
644           F_STA | F_READ,
645           HFA384x_RID_DOWNLOADBUFFER, HFA384x_RID_DOWNLOADBUFFER_LEN, 0,
646           prism2mib_uint32offset },
647     { DIDmib_p2_p2NIC_p2DLBufferOffset,
648           F_STA | F_READ,
649           HFA384x_RID_DOWNLOADBUFFER, HFA384x_RID_DOWNLOADBUFFER_LEN, 1,
650           prism2mib_uint32offset },
651     { DIDmib_p2_p2NIC_p2DLBufferLength,
652           F_STA | F_READ,
653           HFA384x_RID_DOWNLOADBUFFER, HFA384x_RID_DOWNLOADBUFFER_LEN, 2,
654           prism2mib_uint32offset },
655     { DIDmib_p2_p2NIC_p2PRIIdentity,
656           F_STA | F_READ,
657           HFA384x_RID_PRIIDENTITY, HFA384x_RID_PRIIDENTITY_LEN, 0,
658           prism2mib_uint32array },
659     { DIDmib_p2_p2NIC_p2PRISupRange,
660           F_STA | F_READ,
661           HFA384x_RID_PRISUPRANGE, HFA384x_RID_PRISUPRANGE_LEN, 0,
662           prism2mib_uint32array },
663     { DIDmib_p2_p2NIC_p2CFIActRanges,
664           F_STA | F_READ,
665           HFA384x_RID_PRI_CFIACTRANGES, HFA384x_RID_CFIACTRANGES_LEN, 0,
666           prism2mib_uint32array },
667     { DIDmib_p2_p2NIC_p2BuildSequence,
668           F_STA | F_READ,
669           HFA384x_RID_BUILDSEQ, HFA384x_RID_BUILDSEQ_LEN, 0,
670           prism2mib_uint32array },
671     { DIDmib_p2_p2NIC_p2PrimaryFWID,
672           F_STA | F_READ,
673           0, 0, 0,
674           prism2mib_fwid },
675     { DIDmib_p2_p2NIC_p2SecondaryFWID,
676           F_STA | F_READ,
677           0, 0, 0,
678           prism2mib_fwid },
679     { DIDmib_p2_p2NIC_p2NICSerialNumber,
680           F_STA | F_READ,
681           HFA384x_RID_NICSERIALNUMBER, HFA384x_RID_NICSERIALNUMBER_LEN, 0,
682           prism2mib_bytearea2pstr },
683     { DIDmib_p2_p2NIC_p2NICIdentity,
684           F_STA | F_READ,
685           HFA384x_RID_NICIDENTITY, HFA384x_RID_NICIDENTITY_LEN, 0,
686           prism2mib_uint32array },
687     { DIDmib_p2_p2NIC_p2MFISupRange,
688           F_STA | F_READ,
689           HFA384x_RID_MFISUPRANGE, HFA384x_RID_MFISUPRANGE_LEN, 0,
690           prism2mib_uint32array },
691     { DIDmib_p2_p2NIC_p2CFISupRange,
692           F_STA | F_READ,
693           HFA384x_RID_CFISUPRANGE, HFA384x_RID_CFISUPRANGE_LEN, 0,
694           prism2mib_uint32array },
695     { DIDmib_p2_p2NIC_p2ChannelList,
696           F_STA | F_READ,
697           HFA384x_RID_CHANNELLIST, 0, 0,
698           prism2mib_uint32 },
699     { DIDmib_p2_p2NIC_p2RegulatoryDomains,
700           F_STA | F_READ,
701           HFA384x_RID_REGULATORYDOMAINS, HFA384x_RID_REGULATORYDOMAINS_LEN, 0,
702           prism2mib_regulatorydomains },
703     { DIDmib_p2_p2NIC_p2TempType,
704           F_STA | F_READ,
705           HFA384x_RID_TEMPTYPE, 0, 0,
706           prism2mib_uint32 },
707     { DIDmib_p2_p2NIC_p2STAIdentity,
708           F_STA | F_READ,
709           HFA384x_RID_STAIDENTITY, HFA384x_RID_STAIDENTITY_LEN, 0,
710           prism2mib_uint32array },
711     { DIDmib_p2_p2NIC_p2STASupRange,
712           F_STA | F_READ,
713           HFA384x_RID_STASUPRANGE, HFA384x_RID_STASUPRANGE_LEN, 0,
714           prism2mib_uint32array },
715     { DIDmib_p2_p2NIC_p2MFIActRanges,
716           F_STA | F_READ,
717           HFA384x_RID_STA_MFIACTRANGES, HFA384x_RID_MFIACTRANGES_LEN, 0,
718           prism2mib_uint32array },
719     { DIDmib_p2_p2NIC_p2STACFIActRanges,
720           F_STA | F_READ,
721           HFA384x_RID_STA_CFIACTRANGES, HFA384x_RID_CFIACTRANGES2_LEN, 0,
722           prism2mib_uint32array },
723
724     /* p2MAC MIB's */
725
726     { DIDmib_p2_p2MAC_p2PortStatus,
727           F_STA | F_READ,
728           HFA384x_RID_PORTSTATUS, 0, 0,
729           prism2mib_uint32 },
730     { DIDmib_p2_p2MAC_p2CurrentSSID,
731           F_STA | F_READ,
732           HFA384x_RID_CURRENTSSID, HFA384x_RID_CURRENTSSID_LEN, 0,
733           prism2mib_bytestr2pstr },
734     { DIDmib_p2_p2MAC_p2CurrentBSSID,
735           F_STA | F_READ,
736           HFA384x_RID_CURRENTBSSID, HFA384x_RID_CURRENTBSSID_LEN, 0,
737           prism2mib_bytearea2pstr },
738     { DIDmib_p2_p2MAC_p2CommsQuality,
739           F_STA | F_READ,
740           HFA384x_RID_COMMSQUALITY, HFA384x_RID_COMMSQUALITY_LEN, 0,
741           prism2mib_uint32array },
742     { DIDmib_p2_p2MAC_p2CommsQualityCQ,
743           F_STA | F_READ,
744           HFA384x_RID_COMMSQUALITY, HFA384x_RID_COMMSQUALITY_LEN, 0,
745           prism2mib_uint32offset },
746     { DIDmib_p2_p2MAC_p2CommsQualityASL,
747           F_STA | F_READ,
748           HFA384x_RID_COMMSQUALITY, HFA384x_RID_COMMSQUALITY_LEN, 1,
749           prism2mib_uint32offset },
750     { DIDmib_p2_p2MAC_p2CommsQualityANL,
751           F_STA | F_READ,
752           HFA384x_RID_COMMSQUALITY, HFA384x_RID_COMMSQUALITY_LEN, 2,
753           prism2mib_uint32offset },
754     { DIDmib_p2_p2MAC_p2dbmCommsQuality,
755           F_STA | F_READ,
756           HFA384x_RID_DBMCOMMSQUALITY, HFA384x_RID_DBMCOMMSQUALITY_LEN, 0,
757           prism2mib_uint32array },
758     { DIDmib_p2_p2MAC_p2dbmCommsQualityCQ,
759           F_STA | F_READ,
760           HFA384x_RID_COMMSQUALITY, HFA384x_RID_COMMSQUALITY_LEN, 0,
761           prism2mib_uint32offset },
762     { DIDmib_p2_p2MAC_p2dbmCommsQualityASL,
763           F_STA | F_READ,
764           HFA384x_RID_COMMSQUALITY, HFA384x_RID_COMMSQUALITY_LEN, 1,
765           prism2mib_uint32offset },
766     { DIDmib_p2_p2MAC_p2dbmCommsQualityANL,
767           F_STA | F_READ,
768           HFA384x_RID_COMMSQUALITY, HFA384x_RID_COMMSQUALITY_LEN, 2,
769           prism2mib_uint32offset },
770     { DIDmib_p2_p2MAC_p2CurrentTxRate,
771           F_STA | F_READ,
772           HFA384x_RID_CURRENTTXRATE, 0, 0,
773           prism2mib_uint32 },
774     { DIDmib_p2_p2MAC_p2CurrentBeaconInterval,
775           F_STA | F_READ,
776           HFA384x_RID_CURRENTBCNint, 0, 0,
777           prism2mib_uint32 },
778     { DIDmib_p2_p2MAC_p2StaCurrentScaleThresholds,
779           F_STA | F_READ,
780           HFA384x_RID_CURRENTSCALETHRESH, HFA384x_RID_STACURSCALETHRESH_LEN, 0,
781           prism2mib_uint32array },
782     { DIDmib_p2_p2MAC_p2ProtocolRspTime,
783           F_STA | F_READ,
784           HFA384x_RID_PROTOCOLRSPTIME, 0, 0,
785           prism2mib_uint32 },
786     { DIDmib_p2_p2MAC_p2ShortRetryLimit,
787           F_STA | F_READ,
788           HFA384x_RID_SHORTRETRYLIMIT, 0, 0,
789           prism2mib_uint32 },
790     { DIDmib_p2_p2MAC_p2LongRetryLimit,
791           F_STA | F_READ,
792           HFA384x_RID_LONGRETRYLIMIT, 0, 0,
793           prism2mib_uint32 },
794     { DIDmib_p2_p2MAC_p2MaxTransmitLifetime,
795           F_STA | F_READ,
796           HFA384x_RID_MAXTXLIFETIME, 0, 0,
797           prism2mib_uint32 },
798     { DIDmib_p2_p2MAC_p2MaxReceiveLifetime,
799           F_STA | F_READ,
800           HFA384x_RID_MAXRXLIFETIME, 0, 0,
801           prism2mib_uint32 },
802     { DIDmib_p2_p2MAC_p2CFPollable,
803           F_STA | F_READ,
804           HFA384x_RID_CFPOLLABLE, 0, 0,
805           prism2mib_uint32 },
806     { DIDmib_p2_p2MAC_p2AuthenticationAlgorithms,
807           F_STA | F_READ,
808           HFA384x_RID_AUTHALGORITHMS, HFA384x_RID_AUTHALGORITHMS_LEN, 0,
809           prism2mib_uint32array },
810     { DIDmib_p2_p2MAC_p2PrivacyOptionImplemented,
811           F_STA | F_READ,
812           HFA384x_RID_PRIVACYOPTIMP, 0, 0,
813           prism2mib_uint32 },
814
815     /* p2Modem MIB's */
816
817     { DIDmib_p2_p2Modem_p2PHYType,
818           F_STA | F_READ,
819           HFA384x_RID_PHYTYPE, 0, 0,
820           prism2mib_uint32 },
821     { DIDmib_p2_p2Modem_p2CurrentChannel,
822           F_STA | F_READ,
823           HFA384x_RID_CURRENTCHANNEL, 0, 0,
824           prism2mib_uint32 },
825     { DIDmib_p2_p2Modem_p2CurrentPowerState,
826           F_STA | F_READ,
827           HFA384x_RID_CURRENTPOWERSTATE, 0, 0,
828           prism2mib_uint32 },
829     { DIDmib_p2_p2Modem_p2CCAMode,
830           F_STA | F_READ,
831           HFA384x_RID_CCAMODE, 0, 0,
832           prism2mib_uint32 },
833     { DIDmib_p2_p2Modem_p2TxPowerMax,
834           F_STA | F_READ | F_WRITE,
835           HFA384x_RID_TXPOWERMAX, 0, 0,
836           prism2mib_uint32 },
837     { DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel,
838           F_STA | F_READ | F_WRITE,
839           HFA384x_RID_TXPOWERMAX, 0, 0,
840           prism2mib_uint32 },
841     { DIDmib_p2_p2Modem_p2SupportedDataRates,
842           F_STA | F_READ,
843           HFA384x_RID_SUPPORTEDDATARATES, HFA384x_RID_SUPPORTEDDATARATES_LEN, 0,
844           prism2mib_bytestr2pstr },
845
846     /* And finally, lnx mibs */
847     { DIDmib_lnx_lnxConfigTable_lnxRSNAIE,
848           F_STA | F_READ | F_WRITE,
849           HFA384x_RID_CNFWPADATA, 0, 0,
850           prism2mib_priv },
851     { 0, 0, 0, 0, 0, NULL}};
852
853 /*----------------------------------------------------------------
854 These MIB's are not supported at this time:
855
856 DIDmib_dot11phy_dot11PhyOperationTable_dot11ChannelAgilityPresent
857 DIDmib_dot11phy_dot11PhyOperationTable_dot11ChannelAgilityEnabled
858 DIDmib_dot11phy_dot11PhyDSSSTable_dot11PBCCOptionImplemented
859 DIDmib_dot11phy_dot11RegDomainsSupportedTable_dot11RegDomainsSupportIndex
860 DIDmib_dot11phy_dot11SupportedDataRatesTxTable_dot11SupportedDataRatesTxIndex
861 DIDmib_dot11phy_dot11SupportedDataRatesTxTable_dot11SupportedDataRatesTxValue
862 DIDmib_dot11phy_dot11SupportedDataRatesRxTable_dot11SupportedDataRatesRxIndex
863 DIDmib_dot11phy_dot11SupportedDataRatesRxTable_dot11SupportedDataRatesRxValue
864
865 DIDmib_dot11phy_dot11RegDomainsSupportedTable_dot11RegDomainsSupportValue
866 TODO: need to investigate why wlan has this as enumerated and Prism2 has this
867       as btye str.
868
869 DIDmib_dot11phy_dot11PhyDSSSTable_dot11ShortPreambleOptionImplemented
870 TODO: Find out the firmware version number(s) for identifying
871       whether the firmware is capable of short preamble. TRUE or FALSE
872       will be returned based on the version of the firmware.
873
874 WEP Key mappings aren't supported in the f/w.
875 DIDmib_dot11smt_dot11WEPKeyMappingsTable_dot11WEPKeyMappingIndex
876 DIDmib_dot11smt_dot11WEPKeyMappingsTable_dot11WEPKeyMappingAddress
877 DIDmib_dot11smt_dot11WEPKeyMappingsTable_dot11WEPKeyMappingWEPOn
878 DIDmib_dot11smt_dot11WEPKeyMappingsTable_dot11WEPKeyMappingValue
879 DIDmib_dot11smt_dot11PrivacyTable_dot11WEPKeyMappingLength
880
881 TODO: implement counters.
882 DIDmib_dot11smt_dot11PrivacyTable_dot11WEPICVErrorCount
883 DIDmib_dot11smt_dot11PrivacyTable_dot11WEPExcludedCount
884 DIDmib_dot11mac_dot11CountersTable_dot11TransmittedFragmentCount
885 DIDmib_dot11mac_dot11CountersTable_dot11MulticastTransmittedFrameCount
886 DIDmib_dot11mac_dot11CountersTable_dot11FailedCount
887 DIDmib_dot11mac_dot11CountersTable_dot11RetryCount
888 DIDmib_dot11mac_dot11CountersTable_dot11MultipleRetryCount
889 DIDmib_dot11mac_dot11CountersTable_dot11FrameDuplicateCount
890 DIDmib_dot11mac_dot11CountersTable_dot11RTSSuccessCount
891 DIDmib_dot11mac_dot11CountersTable_dot11RTSFailureCount
892 DIDmib_dot11mac_dot11CountersTable_dot11ACKFailureCount
893 DIDmib_dot11mac_dot11CountersTable_dot11ReceivedFragmentCount
894 DIDmib_dot11mac_dot11CountersTable_dot11MulticastReceivedFrameCount
895 DIDmib_dot11mac_dot11CountersTable_dot11FCSErrorCount
896 DIDmib_dot11mac_dot11CountersTable_dot11TransmittedFrameCount
897 DIDmib_dot11mac_dot11CountersTable_dot11WEPUndecryptableCount
898
899 TODO: implement sane values for these.
900 DIDmib_dot11mac_dot11OperationTable_dot11ManufacturerID
901 DIDmib_dot11mac_dot11OperationTable_dot11ProductID
902
903 Not too worried about these at the moment.
904 DIDmib_dot11phy_dot11PhyAntennaTable_dot11CurrentTxAntenna
905 DIDmib_dot11phy_dot11PhyAntennaTable_dot11DiversitySupport
906 DIDmib_dot11phy_dot11PhyAntennaTable_dot11CurrentRxAntenna
907 DIDmib_dot11phy_dot11PhyTxPowerTable_dot11NumberSupportedPowerLevels
908 DIDmib_dot11phy_dot11PhyTxPowerTable_dot11TxPowerLevel1
909 DIDmib_dot11phy_dot11PhyTxPowerTable_dot11TxPowerLevel2
910 DIDmib_dot11phy_dot11PhyTxPowerTable_dot11TxPowerLevel3
911 DIDmib_dot11phy_dot11PhyTxPowerTable_dot11TxPowerLevel4
912 DIDmib_dot11phy_dot11PhyTxPowerTable_dot11TxPowerLevel5
913 DIDmib_dot11phy_dot11PhyTxPowerTable_dot11TxPowerLevel6
914 DIDmib_dot11phy_dot11PhyTxPowerTable_dot11TxPowerLevel7
915 DIDmib_dot11phy_dot11PhyTxPowerTable_dot11TxPowerLevel8
916 DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel
917
918 Ummm, FH and IR don't apply
919 DIDmib_dot11phy_dot11PhyFHSSTable_dot11HopTime
920 DIDmib_dot11phy_dot11PhyFHSSTable_dot11CurrentChannelNumber
921 DIDmib_dot11phy_dot11PhyFHSSTable_dot11MaxDwellTime
922 DIDmib_dot11phy_dot11PhyFHSSTable_dot11CurrentDwellTime
923 DIDmib_dot11phy_dot11PhyFHSSTable_dot11CurrentSet
924 DIDmib_dot11phy_dot11PhyFHSSTable_dot11CurrentPattern
925 DIDmib_dot11phy_dot11PhyFHSSTable_dot11CurrentIndex
926 DIDmib_dot11phy_dot11PhyDSSSTable_dot11CCAModeSupported
927 DIDmib_dot11phy_dot11PhyDSSSTable_dot11EDThreshold
928 DIDmib_dot11phy_dot11PhyIRTable_dot11CCAWatchdogTimerMax
929 DIDmib_dot11phy_dot11PhyIRTable_dot11CCAWatchdogCountMax
930 DIDmib_dot11phy_dot11PhyIRTable_dot11CCAWatchdogTimerMin
931 DIDmib_dot11phy_dot11PhyIRTable_dot11CCAWatchdogCountMin
932
933 We just don't have enough antennas right now to worry about this.
934 DIDmib_dot11phy_dot11AntennasListTable_dot11AntennaListIndex
935 DIDmib_dot11phy_dot11AntennasListTable_dot11SupportedTxAntenna
936 DIDmib_dot11phy_dot11AntennasListTable_dot11SupportedRxAntenna
937 DIDmib_dot11phy_dot11AntennasListTable_dot11DiversitySelectionRx
938
939 ------------------------------------------------------------------*/
940
941 /*================================================================*/
942 /* Function Definitions */
943
944 /*----------------------------------------------------------------
945 * prism2mgmt_mibset_mibget
946 *
947 * Set the value of a mib item.
948 *
949 * Arguments:
950 *       wlandev         wlan device structure
951 *       msgp            ptr to msg buffer
952 *
953 * Returns:
954 *       0       success and done
955 *       <0      success, but we're waiting for something to finish.
956 *       >0      an error occurred while handling the message.
957 * Side effects:
958 *
959 * Call context:
960 *       process thread  (usually)
961 *       interrupt
962 ----------------------------------------------------------------*/
963
964 int prism2mgmt_mibset_mibget(wlandevice_t *wlandev, void *msgp)
965 {
966         hfa384x_t               *hw = wlandev->priv;
967         int                     result, isget;
968         mibrec_t                *mib;
969
970         u16                     which;
971
972         p80211msg_dot11req_mibset_t     *msg = msgp;
973         p80211itemd_t                   *mibitem;
974
975         DBFENTER;
976
977         msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
978         msg->resultcode.data = P80211ENUM_resultcode_success;
979
980         /*
981         ** Determine if this is an Access Point or a station.
982         */
983
984         which = F_STA;
985
986         /*
987         ** Find the MIB in the MIB table.  Note that a MIB may be in the
988         ** table twice...once for an AP and once for a station.  Make sure
989         ** to get the correct one.  Note that DID=0 marks the end of the
990         ** MIB table.
991         */
992
993         mibitem = (p80211itemd_t *) msg->mibattribute.data;
994
995         for (mib = mibtab; mib->did != 0; mib++)
996                 if (mib->did == mibitem->did && (mib->flag & which))
997                         break;
998
999         if (mib->did == 0) {
1000                 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1001                 goto done;
1002         }
1003
1004         /*
1005         ** Determine if this is a "mibget" or a "mibset".  If this is a
1006         ** "mibget", then make sure that the MIB may be read.  Otherwise,
1007         ** this is a "mibset" so make make sure that the MIB may be written.
1008         */
1009
1010         isget = (msg->msgcode == DIDmsg_dot11req_mibget);
1011
1012         if (isget) {
1013                 if (!(mib->flag & F_READ)) {
1014                         msg->resultcode.data =
1015                                 P80211ENUM_resultcode_cant_get_writeonly_mib;
1016                         goto done;
1017                 }
1018         } else {
1019                 if (!(mib->flag & F_WRITE)) {
1020                         msg->resultcode.data =
1021                                 P80211ENUM_resultcode_cant_set_readonly_mib;
1022                         goto done;
1023                 }
1024         }
1025
1026         /*
1027         ** Execute the MIB function.  If things worked okay, then make
1028         ** sure that the MIB function also worked okay.  If so, and this
1029         ** is a "mibget", then the status value must be set for both the
1030         ** "mibattribute" parameter and the mib item within the data
1031         ** portion of the "mibattribute".
1032         */
1033
1034         result = mib->func(mib, isget, wlandev, hw, msg,
1035                            (void *) mibitem->data);
1036
1037         if (msg->resultcode.data == P80211ENUM_resultcode_success) {
1038                 if (result != 0) {
1039                         WLAN_LOG_DEBUG(1, "get/set failure, result=%d\n",
1040                                         result);
1041                         msg->resultcode.data =
1042                                  P80211ENUM_resultcode_implementation_failure;
1043                 } else {
1044                         if (isget) {
1045                                 msg->mibattribute.status =
1046                                         P80211ENUM_msgitem_status_data_ok;
1047                                 mibitem->status =
1048                                         P80211ENUM_msgitem_status_data_ok;
1049                         }
1050                 }
1051         }
1052
1053 done:
1054         DBFEXIT;
1055
1056         return(0);
1057 }
1058
1059 /*----------------------------------------------------------------
1060 * prism2mib_bytestr2pstr
1061 *
1062 * Get/set pstr data to/from a byte string.
1063 *
1064 * MIB record parameters:
1065 *       parm1    Prism2 RID value.
1066 *       parm2    Number of bytes of RID data.
1067 *       parm3    Not used.
1068 *
1069 * Arguments:
1070 *       mib      MIB record.
1071 *       isget    MIBGET/MIBSET flag.
1072 *       wlandev  wlan device structure.
1073 *       priv     "priv" structure.
1074 *       hw       "hw" structure.
1075 *       msg      Message structure.
1076 *       data     Data buffer.
1077 *
1078 * Returns:
1079 *       0   - Success.
1080 *       ~0  - Error.
1081 *
1082 ----------------------------------------------------------------*/
1083
1084 static int prism2mib_bytestr2pstr(
1085 mibrec_t                     *mib,
1086 int                          isget,
1087 wlandevice_t                 *wlandev,
1088 hfa384x_t                    *hw,
1089 p80211msg_dot11req_mibset_t  *msg,
1090 void                         *data)
1091 {
1092         int                result;
1093         p80211pstrd_t      *pstr = (p80211pstrd_t*) data;
1094         u8              bytebuf[MIB_TMP_MAXLEN];
1095         hfa384x_bytestr_t  *p2bytestr = (hfa384x_bytestr_t*) bytebuf;
1096
1097         DBFENTER;
1098
1099         if (isget) {
1100                 result = hfa384x_drvr_getconfig(hw, mib->parm1, bytebuf, mib->parm2);
1101                 prism2mgmt_bytestr2pstr(p2bytestr, pstr);
1102         } else {
1103                 memset(bytebuf, 0, mib->parm2);
1104                 prism2mgmt_pstr2bytestr(p2bytestr, pstr);
1105                 result = hfa384x_drvr_setconfig(hw, mib->parm1, bytebuf, mib->parm2);
1106         }
1107
1108         DBFEXIT;
1109         return(result);
1110 }
1111
1112 /*----------------------------------------------------------------
1113 * prism2mib_bytearea2pstr
1114 *
1115 * Get/set pstr data to/from a byte area.
1116 *
1117 * MIB record parameters:
1118 *       parm1    Prism2 RID value.
1119 *       parm2    Number of bytes of RID data.
1120 *       parm3    Not used.
1121 *
1122 * Arguments:
1123 *       mib      MIB record.
1124 *       isget    MIBGET/MIBSET flag.
1125 *       wlandev  wlan device structure.
1126 *       priv     "priv" structure.
1127 *       hw       "hw" structure.
1128 *       msg      Message structure.
1129 *       data     Data buffer.
1130 *
1131 * Returns:
1132 *       0   - Success.
1133 *       ~0  - Error.
1134 *
1135 ----------------------------------------------------------------*/
1136
1137 static int prism2mib_bytearea2pstr(
1138 mibrec_t                     *mib,
1139 int                          isget,
1140 wlandevice_t                 *wlandev,
1141 hfa384x_t                    *hw,
1142 p80211msg_dot11req_mibset_t  *msg,
1143 void                         *data)
1144 {
1145         int            result;
1146         p80211pstrd_t  *pstr = (p80211pstrd_t*) data;
1147         u8          bytebuf[MIB_TMP_MAXLEN];
1148
1149         DBFENTER;
1150
1151         if (isget) {
1152                 result = hfa384x_drvr_getconfig(hw, mib->parm1, bytebuf, mib->parm2);
1153                 prism2mgmt_bytearea2pstr(bytebuf, pstr, mib->parm2);
1154         } else {
1155                 memset(bytebuf, 0, mib->parm2);
1156                 prism2mgmt_pstr2bytearea(bytebuf, pstr);
1157                 result = hfa384x_drvr_setconfig(hw, mib->parm1, bytebuf, mib->parm2);
1158         }
1159
1160         DBFEXIT;
1161         return(result);
1162 }
1163
1164 /*----------------------------------------------------------------
1165 * prism2mib_uint32
1166 *
1167 * Get/set uint32 data.
1168 *
1169 * MIB record parameters:
1170 *       parm1    Prism2 RID value.
1171 *       parm2    Not used.
1172 *       parm3    Not used.
1173 *
1174 * Arguments:
1175 *       mib      MIB record.
1176 *       isget    MIBGET/MIBSET flag.
1177 *       wlandev  wlan device structure.
1178 *       priv     "priv" structure.
1179 *       hw       "hw" structure.
1180 *       msg      Message structure.
1181 *       data     Data buffer.
1182 *
1183 * Returns:
1184 *       0   - Success.
1185 *       ~0  - Error.
1186 *
1187 ----------------------------------------------------------------*/
1188
1189 static int prism2mib_uint32(
1190 mibrec_t                     *mib,
1191 int                          isget,
1192 wlandevice_t                 *wlandev,
1193 hfa384x_t                    *hw,
1194 p80211msg_dot11req_mibset_t  *msg,
1195 void                         *data)
1196 {
1197         int     result;
1198         u32  *uint32 = (u32*) data;
1199         u8   bytebuf[MIB_TMP_MAXLEN];
1200         u16  *wordbuf = (u16*) bytebuf;
1201
1202         DBFENTER;
1203
1204         if (isget) {
1205                 result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
1206                 *uint32 = *wordbuf;
1207                 /* [MSM] Removed, getconfig16 returns the value in host order.
1208                  * prism2mgmt_prism2int2p80211int(wordbuf, uint32);
1209                  */
1210         } else {
1211                 /* [MSM] Removed, setconfig16 expects host order.
1212                  * prism2mgmt_p80211int2prism2int(wordbuf, uint32);
1213                  */
1214                 *wordbuf = *uint32;
1215                 result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
1216         }
1217
1218         DBFEXIT;
1219         return(result);
1220 }
1221
1222 /*----------------------------------------------------------------
1223 * prism2mib_uint32array
1224 *
1225 * Get/set an array of uint32 data.
1226 *
1227 * MIB record parameters:
1228 *       parm1    Prism2 RID value.
1229 *       parm2    Number of bytes of RID data.
1230 *       parm3    Not used.
1231 *
1232 * Arguments:
1233 *       mib      MIB record.
1234 *       isget    MIBGET/MIBSET flag.
1235 *       wlandev  wlan device structure.
1236 *       priv     "priv" structure.
1237 *       hw       "hw" structure.
1238 *       msg      Message structure.
1239 *       data     Data buffer.
1240 *
1241 * Returns:
1242 *       0   - Success.
1243 *       ~0  - Error.
1244 *
1245 ----------------------------------------------------------------*/
1246
1247 static int prism2mib_uint32array(
1248 mibrec_t                     *mib,
1249 int                          isget,
1250 wlandevice_t                 *wlandev,
1251 hfa384x_t                    *hw,
1252 p80211msg_dot11req_mibset_t  *msg,
1253 void                         *data)
1254 {
1255         int     result;
1256         u32  *uint32 = (u32 *) data;
1257         u8   bytebuf[MIB_TMP_MAXLEN];
1258         u16  *wordbuf = (u16*) bytebuf;
1259         int     i, cnt;
1260
1261         DBFENTER;
1262
1263         cnt = mib->parm2 / sizeof(u16);
1264
1265         if (isget) {
1266                 result = hfa384x_drvr_getconfig(hw, mib->parm1, wordbuf, mib->parm2);
1267                 for (i = 0; i < cnt; i++)
1268                         prism2mgmt_prism2int2p80211int(wordbuf+i, uint32+i);
1269         } else {
1270                 for (i = 0; i < cnt; i++)
1271                         prism2mgmt_p80211int2prism2int(wordbuf+i, uint32+i);
1272                 result = hfa384x_drvr_setconfig(hw, mib->parm1, wordbuf, mib->parm2);
1273                 }
1274
1275         DBFEXIT;
1276         return(result);
1277 }
1278
1279 /*----------------------------------------------------------------
1280 * prism2mib_uint32offset
1281 *
1282 * Get/set a single element in an array of uint32 data.
1283 *
1284 * MIB record parameters:
1285 *       parm1    Prism2 RID value.
1286 *       parm2    Number of bytes of RID data.
1287 *       parm3    Element index.
1288 *
1289 * Arguments:
1290 *       mib      MIB record.
1291 *       isget    MIBGET/MIBSET flag.
1292 *       wlandev  wlan device structure.
1293 *       priv     "priv" structure.
1294 *       hw       "hw" structure.
1295 *       msg      Message structure.
1296 *       data     Data buffer.
1297 *
1298 * Returns:
1299 *       0   - Success.
1300 *       ~0  - Error.
1301 *
1302 ----------------------------------------------------------------*/
1303
1304 static int prism2mib_uint32offset(
1305 mibrec_t                     *mib,
1306 int                          isget,
1307 wlandevice_t                 *wlandev,
1308 hfa384x_t                    *hw,
1309 p80211msg_dot11req_mibset_t  *msg,
1310 void                         *data)
1311 {
1312         int     result;
1313         u32  *uint32 = (u32*) data;
1314         u8   bytebuf[MIB_TMP_MAXLEN];
1315         u16  *wordbuf = (u16*) bytebuf;
1316         u16  cnt;
1317
1318         DBFENTER;
1319
1320         cnt = mib->parm2 / sizeof(u16);
1321
1322         result = hfa384x_drvr_getconfig(hw, mib->parm1, wordbuf, mib->parm2);
1323         if (result == 0) {
1324                 if (isget) {
1325                         if (mib->parm3 < cnt)
1326                                 prism2mgmt_prism2int2p80211int(wordbuf+mib->parm3, uint32);
1327                         else
1328                                 *uint32 = 0;
1329                 } else {
1330                         if (mib->parm3 < cnt) {
1331                                 prism2mgmt_p80211int2prism2int(wordbuf+mib->parm3, uint32);
1332                                 result = hfa384x_drvr_setconfig(hw, mib->parm1, wordbuf, mib->parm2);
1333                         }
1334                 }
1335         }
1336
1337         DBFEXIT;
1338         return(result);
1339 }
1340
1341 /*----------------------------------------------------------------
1342 * prism2mib_truth
1343 *
1344 * Get/set truth data.
1345 *
1346 * MIB record parameters:
1347 *       parm1    Prism2 RID value.
1348 *       parm2    Not used.
1349 *       parm3    Not used.
1350 *
1351 * Arguments:
1352 *       mib      MIB record.
1353 *       isget    MIBGET/MIBSET flag.
1354 *       wlandev  wlan device structure.
1355 *       priv     "priv" structure.
1356 *       hw       "hw" structure.
1357 *       msg      Message structure.
1358 *       data     Data buffer.
1359 *
1360 * Returns:
1361 *       0   - Success.
1362 *       ~0  - Error.
1363 *
1364 ----------------------------------------------------------------*/
1365
1366 static int prism2mib_truth(
1367 mibrec_t                     *mib,
1368 int                          isget,
1369 wlandevice_t                 *wlandev,
1370 hfa384x_t                    *hw,
1371 p80211msg_dot11req_mibset_t  *msg,
1372 void                         *data)
1373 {
1374         int     result;
1375         u32  *uint32 = (u32*) data;
1376         u8   bytebuf[MIB_TMP_MAXLEN];
1377         u16  *wordbuf = (u16*) bytebuf;
1378
1379         DBFENTER;
1380
1381         if (isget) {
1382                 result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
1383                 *uint32 = (*wordbuf) ?
1384                                 P80211ENUM_truth_true : P80211ENUM_truth_false;
1385         } else {
1386                 *wordbuf = ((*uint32) == P80211ENUM_truth_true) ? 1 : 0;
1387                 result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
1388         }
1389
1390         DBFEXIT;
1391         return(result);
1392 }
1393
1394 /*----------------------------------------------------------------
1395 * prism2mib_flag
1396 *
1397 * Get/set a flag.
1398 *
1399 * MIB record parameters:
1400 *       parm1    Prism2 RID value.
1401 *       parm2    Bit to get/set.
1402 *       parm3    Not used.
1403 *
1404 * Arguments:
1405 *       mib      MIB record.
1406 *       isget    MIBGET/MIBSET flag.
1407 *       wlandev  wlan device structure.
1408 *       priv     "priv" structure.
1409 *       hw       "hw" structure.
1410 *       msg      Message structure.
1411 *       data     Data buffer.
1412 *
1413 * Returns:
1414 *       0   - Success.
1415 *       ~0  - Error.
1416 *
1417 ----------------------------------------------------------------*/
1418
1419 static int prism2mib_flag(
1420 mibrec_t                     *mib,
1421 int                          isget,
1422 wlandevice_t                 *wlandev,
1423 hfa384x_t                    *hw,
1424 p80211msg_dot11req_mibset_t  *msg,
1425 void                         *data)
1426 {
1427         int     result;
1428         u32  *uint32 = (u32*) data;
1429         u8   bytebuf[MIB_TMP_MAXLEN];
1430         u16  *wordbuf = (u16*) bytebuf;
1431         u32  flags;
1432
1433         DBFENTER;
1434
1435         result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
1436         if (result == 0) {
1437                 /* [MSM] Removed, getconfig16 returns the value in host order.
1438                  * prism2mgmt_prism2int2p80211int(wordbuf, &flags);
1439                  */
1440                 flags = *wordbuf;
1441                 if (isget) {
1442                         *uint32 = (flags & mib->parm2) ?
1443                                 P80211ENUM_truth_true : P80211ENUM_truth_false;
1444                 } else {
1445                         if ((*uint32) == P80211ENUM_truth_true)
1446                                 flags |= mib->parm2;
1447                         else
1448                                 flags &= ~mib->parm2;
1449                         /* [MSM] Removed, setconfig16 expects host order.
1450                          * prism2mgmt_p80211int2prism2int(wordbuf, &flags);
1451                          */
1452                         *wordbuf = flags;
1453                         result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
1454                 }
1455         }
1456
1457         DBFEXIT;
1458         return(result);
1459 }
1460
1461 /*----------------------------------------------------------------
1462 * prism2mib_regulatorydomains
1463 *
1464 * Get regulatory domain data.
1465 *
1466 * MIB record parameters:
1467 *       parm1    Prism2 RID value.
1468 *       parm2    Number of bytes of RID data.
1469 *       parm3    Not used.
1470 *
1471 * Arguments:
1472 *       mib      MIB record.
1473 *       isget    MIBGET/MIBSET flag.
1474 *       wlandev  wlan device structure.
1475 *       priv     "priv" structure.
1476 *       hw       "hw" structure.
1477 *       msg      Message structure.
1478 *       data     Data buffer.
1479 *
1480 * Returns:
1481 *       0   - Success.
1482 *       ~0  - Error.
1483 *
1484 ----------------------------------------------------------------*/
1485
1486 static int prism2mib_regulatorydomains(
1487 mibrec_t                     *mib,
1488 int                          isget,
1489 wlandevice_t                 *wlandev,
1490 hfa384x_t                    *hw,
1491 p80211msg_dot11req_mibset_t  *msg,
1492 void                         *data)
1493 {
1494         int            result;
1495         u32         cnt;
1496         p80211pstrd_t  *pstr = (p80211pstrd_t*) data;
1497         u8          bytebuf[MIB_TMP_MAXLEN];
1498         u16         *wordbuf = (u16*) bytebuf;
1499
1500         DBFENTER;
1501
1502         result = 0;
1503
1504         if (isget) {
1505                 result = hfa384x_drvr_getconfig(hw, mib->parm1, wordbuf, mib->parm2);
1506                 prism2mgmt_prism2int2p80211int(wordbuf, &cnt);
1507                 pstr->len = (u8) cnt;
1508                 memcpy(pstr->data, &wordbuf[1], pstr->len);
1509         }
1510
1511         DBFEXIT;
1512         return(result);
1513 }
1514
1515 /*----------------------------------------------------------------
1516 * prism2mib_wepdefaultkey
1517 *
1518 * Get/set WEP default keys.
1519 *
1520 * MIB record parameters:
1521 *       parm1    Prism2 RID value.
1522 *       parm2    Number of bytes of RID data.
1523 *       parm3    Not used.
1524 *
1525 * Arguments:
1526 *       mib      MIB record.
1527 *       isget    MIBGET/MIBSET flag.
1528 *       wlandev  wlan device structure.
1529 *       priv     "priv" structure.
1530 *       hw       "hw" structure.
1531 *       msg      Message structure.
1532 *       data     Data buffer.
1533 *
1534 * Returns:
1535 *       0   - Success.
1536 *       ~0  - Error.
1537 *
1538 ----------------------------------------------------------------*/
1539
1540 static int prism2mib_wepdefaultkey(
1541 mibrec_t                     *mib,
1542 int                          isget,
1543 wlandevice_t                 *wlandev,
1544 hfa384x_t                    *hw,
1545 p80211msg_dot11req_mibset_t  *msg,
1546 void                         *data)
1547 {
1548         int            result;
1549         p80211pstrd_t  *pstr = (p80211pstrd_t*) data;
1550         u8          bytebuf[MIB_TMP_MAXLEN];
1551         u16         len;
1552
1553         DBFENTER;
1554
1555         if (isget) {
1556                 result = 0;    /* Should never happen. */
1557         } else {
1558                 len = (pstr->len > 5) ? HFA384x_RID_CNFWEP128DEFAULTKEY_LEN :
1559                                         HFA384x_RID_CNFWEPDEFAULTKEY_LEN;
1560                 memset(bytebuf, 0, len);
1561                 prism2mgmt_pstr2bytearea(bytebuf, pstr);
1562                 result = hfa384x_drvr_setconfig(hw, mib->parm1, bytebuf, len);
1563         }
1564
1565         DBFEXIT;
1566         return(result);
1567 }
1568
1569 /*----------------------------------------------------------------
1570 * prism2mib_powermanagement
1571 *
1572 * Get/set 802.11 power management value.  Note that this is defined differently
1573 * by 802.11 and Prism2:
1574 *
1575 *       Meaning     802.11       Prism2
1576 *        active       1           false
1577 *      powersave      2           true
1578 *
1579 * MIB record parameters:
1580 *       parm1    Prism2 RID value.
1581 *       parm2    Not used.
1582 *       parm3    Not used.
1583 *
1584 * Arguments:
1585 *       mib      MIB record.
1586 *       isget    MIBGET/MIBSET flag.
1587 *       wlandev  wlan device structure.
1588 *       priv     "priv" structure.
1589 *       hw       "hw" structure.
1590 *       msg      Message structure.
1591 *       data     Data buffer.
1592 *
1593 * Returns:
1594 *       0   - Success.
1595 *       ~0  - Error.
1596 *
1597 ----------------------------------------------------------------*/
1598
1599 static int prism2mib_powermanagement(
1600 mibrec_t                     *mib,
1601 int                          isget,
1602 wlandevice_t                 *wlandev,
1603 hfa384x_t                    *hw,
1604 p80211msg_dot11req_mibset_t  *msg,
1605 void                         *data)
1606 {
1607         int     result;
1608         u32  *uint32 = (u32*) data;
1609         u32  value;
1610
1611         DBFENTER;
1612
1613         if (isget) {
1614                 result = prism2mib_uint32(mib, isget, wlandev, hw, msg, &value);
1615                 *uint32 = (value == 0) ? 1 : 2;
1616         } else {
1617                 value = ((*uint32) == 1) ? 0 : 1;
1618                 result = prism2mib_uint32(mib, isget, wlandev, hw, msg, &value);
1619         }
1620
1621         DBFEXIT;
1622         return(result);
1623 }
1624
1625 /*----------------------------------------------------------------
1626 * prism2mib_preamble
1627 *
1628 * Get/set Prism2 short preamble
1629 *
1630 * MIB record parameters:
1631 *       parm1    Prism2 RID value.
1632 *       parm2    Not used.
1633 *       parm3    Not used.
1634 *
1635 * Arguments:
1636 *       mib      MIB record.
1637 *       isget    MIBGET/MIBSET flag.
1638 *       wlandev  wlan device structure.
1639 *       priv     "priv" structure.
1640 *       hw       "hw" structure.
1641 *       msg      Message structure.
1642 *       data     Data buffer.
1643 *
1644 * Returns:
1645 *       0   - Success.
1646 *       ~0  - Error.
1647 *
1648 ----------------------------------------------------------------*/
1649
1650 static int prism2mib_preamble(
1651 mibrec_t                     *mib,
1652 int                          isget,
1653 wlandevice_t                 *wlandev,
1654 hfa384x_t                    *hw,
1655 p80211msg_dot11req_mibset_t  *msg,
1656 void                         *data)
1657 {
1658         int     result;
1659         u32  *uint32 = (u32*) data;
1660         u8   bytebuf[MIB_TMP_MAXLEN];
1661         u16  *wordbuf = (u16*) bytebuf;
1662
1663         DBFENTER;
1664
1665         if (isget) {
1666                 result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
1667                 *uint32 = *wordbuf;
1668         } else {
1669                 *wordbuf = *uint32;
1670                 result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
1671         }
1672
1673         DBFEXIT;
1674         return(result);
1675 }
1676
1677 /*----------------------------------------------------------------
1678 * prism2mib_privacyinvoked
1679 *
1680 * Get/set the dot11PrivacyInvoked value.
1681 *
1682 * MIB record parameters:
1683 *       parm1    Prism2 RID value.
1684 *       parm2    Bit value for PrivacyInvoked flag.
1685 *       parm3    Not used.
1686 *
1687 * Arguments:
1688 *       mib      MIB record.
1689 *       isget    MIBGET/MIBSET flag.
1690 *       wlandev  wlan device structure.
1691 *       priv     "priv" structure.
1692 *       hw       "hw" structure.
1693 *       msg      Message structure.
1694 *       data     Data buffer.
1695 *
1696 * Returns:
1697 *       0   - Success.
1698 *       ~0  - Error.
1699 *
1700 ----------------------------------------------------------------*/
1701
1702 static int prism2mib_privacyinvoked(
1703 mibrec_t                     *mib,
1704 int                          isget,
1705 wlandevice_t                 *wlandev,
1706 hfa384x_t                    *hw,
1707 p80211msg_dot11req_mibset_t  *msg,
1708 void                         *data)
1709 {
1710         int     result;
1711
1712         DBFENTER;
1713
1714         if (wlandev->hostwep & HOSTWEP_DECRYPT) {
1715                 if (wlandev->hostwep & HOSTWEP_DECRYPT)
1716                         mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_RXCRYPT;
1717                 if (wlandev->hostwep & HOSTWEP_ENCRYPT)
1718                         mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_TXCRYPT;
1719         }
1720
1721         result = prism2mib_flag(mib, isget, wlandev, hw, msg, data);
1722
1723         DBFEXIT;
1724         return(result);
1725 }
1726
1727 /*----------------------------------------------------------------
1728 * prism2mib_excludeunencrypted
1729 *
1730 * Get/set the dot11ExcludeUnencrypted value.
1731 *
1732 * MIB record parameters:
1733 *       parm1    Prism2 RID value.
1734 *       parm2    Bit value for ExcludeUnencrypted flag.
1735 *       parm3    Not used.
1736 *
1737 * Arguments:
1738 *       mib      MIB record.
1739 *       isget    MIBGET/MIBSET flag.
1740 *       wlandev  wlan device structure.
1741 *       priv     "priv" structure.
1742 *       hw       "hw" structure.
1743 *       msg      Message structure.
1744 *       data     Data buffer.
1745 *
1746 * Returns:
1747 *       0   - Success.
1748 *       ~0  - Error.
1749 *
1750 ----------------------------------------------------------------*/
1751
1752 static int prism2mib_excludeunencrypted(
1753 mibrec_t                     *mib,
1754 int                          isget,
1755 wlandevice_t                 *wlandev,
1756 hfa384x_t                    *hw,
1757 p80211msg_dot11req_mibset_t  *msg,
1758 void                         *data)
1759 {
1760         int     result;
1761
1762         DBFENTER;
1763
1764         result = prism2mib_flag(mib, isget, wlandev, hw, msg, data);
1765
1766         DBFEXIT;
1767         return(result);
1768 }
1769
1770 /*----------------------------------------------------------------
1771 * prism2mib_fragmentationthreshold
1772 *
1773 * Get/set the fragmentation threshold.
1774 *
1775 * MIB record parameters:
1776 *       parm1    Prism2 RID value.
1777 *       parm2    Not used.
1778 *       parm3    Not used.
1779 *
1780 * Arguments:
1781 *       mib      MIB record.
1782 *       isget    MIBGET/MIBSET flag.
1783 *       wlandev  wlan device structure.
1784 *       priv     "priv" structure.
1785 *       hw       "hw" structure.
1786 *       msg      Message structure.
1787 *       data     Data buffer.
1788 *
1789 * Returns:
1790 *       0   - Success.
1791 *       ~0  - Error.
1792 *
1793 ----------------------------------------------------------------*/
1794
1795 static int prism2mib_fragmentationthreshold(
1796 mibrec_t                     *mib,
1797 int                          isget,
1798 wlandevice_t                 *wlandev,
1799 hfa384x_t                    *hw,
1800 p80211msg_dot11req_mibset_t  *msg,
1801 void                         *data)
1802 {
1803         int     result;
1804         u32  *uint32 = (u32*) data;
1805
1806         DBFENTER;
1807
1808         if (!isget)
1809                 if ((*uint32) % 2) {
1810                         WLAN_LOG_WARNING("Attempt to set odd number "
1811                                           "FragmentationThreshold\n");
1812                         msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1813                         return(0);
1814                 }
1815
1816         result = prism2mib_uint32(mib, isget, wlandev, hw, msg, data);
1817
1818         DBFEXIT;
1819         return(result);
1820 }
1821
1822 /*----------------------------------------------------------------
1823 * prism2mib_operationalrateset
1824 *
1825 * Get/set the operational rate set.
1826 *
1827 * MIB record parameters:
1828 *       parm1    Prism2 RID value.
1829 *       parm2    Not used.
1830 *       parm3    Not used.
1831 *
1832 * Arguments:
1833 *       mib      MIB record.
1834 *       isget    MIBGET/MIBSET flag.
1835 *       wlandev  wlan device structure.
1836 *       priv     "priv" structure.
1837 *       hw       "hw" structure.
1838 *       msg      Message structure.
1839 *       data     Data buffer.
1840 *
1841 * Returns:
1842 *       0   - Success.
1843 *       ~0  - Error.
1844 *
1845 ----------------------------------------------------------------*/
1846
1847 static int prism2mib_operationalrateset(
1848 mibrec_t                     *mib,
1849 int                          isget,
1850 wlandevice_t                 *wlandev,
1851 hfa384x_t                    *hw,
1852 p80211msg_dot11req_mibset_t  *msg,
1853 void                         *data)
1854 {
1855         int            result;
1856         p80211pstrd_t  *pstr = (p80211pstrd_t *) data;
1857         u8          bytebuf[MIB_TMP_MAXLEN];
1858         u16         *wordbuf = (u16*) bytebuf;
1859
1860         DBFENTER;
1861
1862         if (isget) {
1863                 result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
1864                 prism2mgmt_get_oprateset(wordbuf, pstr);
1865         } else {
1866                 prism2mgmt_set_oprateset(wordbuf, pstr);
1867                 result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
1868                 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFSUPPRATES, *wordbuf);
1869         }
1870
1871         DBFEXIT;
1872         return(result);
1873 }
1874
1875 /*----------------------------------------------------------------
1876 * prism2mib_fwid
1877 *
1878 * Get the firmware ID.
1879 *
1880 * MIB record parameters:
1881 *       parm1    Not used.
1882 *       parm2    Not used.
1883 *       parm3    Not used.
1884 *
1885 * Arguments:
1886 *       mib      MIB record.
1887 *       isget    MIBGET/MIBSET flag.
1888 *       wlandev  wlan device structure.
1889 *       priv     "priv" structure.
1890 *       hw       "hw" structure.
1891 *       msg      Message structure.
1892 *       data     Data buffer.
1893 *
1894 * Returns:
1895 *       0   - Success.
1896 *       ~0  - Error.
1897 *
1898 ----------------------------------------------------------------*/
1899
1900 static int prism2mib_fwid(
1901 mibrec_t                     *mib,
1902 int                          isget,
1903 wlandevice_t                 *wlandev,
1904 hfa384x_t                    *hw,
1905 p80211msg_dot11req_mibset_t  *msg,
1906 void                         *data)
1907 {
1908         int             result;
1909         p80211pstrd_t   *pstr = (p80211pstrd_t *) data;
1910         hfa384x_FWID_t  fwid;
1911
1912         DBFENTER;
1913
1914         if (isget) {
1915                 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_FWID,
1916                                                 &fwid, HFA384x_RID_FWID_LEN);
1917                 if (mib->did == DIDmib_p2_p2NIC_p2PrimaryFWID) {
1918                         fwid.primary[HFA384x_FWID_LEN - 1] = '\0';
1919                         pstr->len = strlen(fwid.primary);
1920                         memcpy(pstr->data, fwid.primary, pstr->len);
1921                 } else {
1922                         fwid.secondary[HFA384x_FWID_LEN - 1] = '\0';
1923                         pstr->len = strlen(fwid.secondary);
1924                         memcpy(pstr->data, fwid.secondary, pstr->len);
1925                 }
1926         } else
1927                 result = 0;     /* Should never happen. */
1928
1929         DBFEXIT;
1930         return(result);
1931 }
1932
1933 /*----------------------------------------------------------------
1934 * prism2mib_authalg
1935 *
1936 * Get values from the AuhtenticationAlgorithmsTable.
1937 *
1938 * MIB record parameters:
1939 *       parm1    Table index (1-6).
1940 *       parm2    Not used.
1941 *       parm3    Not used.
1942 *
1943 * Arguments:
1944 *       mib      MIB record.
1945 *       isget    MIBGET/MIBSET flag.
1946 *       wlandev  wlan device structure.
1947 *       priv     "priv" structure.
1948 *       hw       "hw" structure.
1949 *       msg      Message structure.
1950 *       data     Data buffer.
1951 *
1952 * Returns:
1953 *       0   - Success.
1954 *       ~0  - Error.
1955 *
1956 ----------------------------------------------------------------*/
1957
1958 static int prism2mib_authalg(
1959 mibrec_t                     *mib,
1960 int                          isget,
1961 wlandevice_t                 *wlandev,
1962 hfa384x_t                    *hw,
1963 p80211msg_dot11req_mibset_t  *msg,
1964 void                         *data)
1965 {
1966         u32  *uint32 = (u32*) data;
1967
1968         DBFENTER;
1969
1970         /* MSM: pkx supplied code that  code queries RID FD4D....but the f/w's
1971          *  results are bogus. Therefore, we have to simulate the appropriate
1972          *  results here in the driver based on our knowledge of existing MAC
1973          *  features.  That's the whole point behind this ugly function.
1974          */
1975
1976         if (isget) {
1977                 msg->resultcode.data = P80211ENUM_resultcode_success;
1978                 switch (mib->parm1) {
1979                         case 1: /* Open System */
1980                                 *uint32 = P80211ENUM_authalg_opensystem;
1981                                 break;
1982                         case 2: /* SharedKey */
1983                                 *uint32 = P80211ENUM_authalg_sharedkey;
1984                                 break;
1985                         default:
1986                                 *uint32 = 0;
1987                                 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1988                                 break;
1989                 }
1990         }
1991
1992         DBFEXIT;
1993         return(0);
1994 }
1995
1996 /*----------------------------------------------------------------
1997 * prism2mib_authalgenable
1998 *
1999 * Get/set the enable values from the AuhtenticationAlgorithmsTable.
2000 *
2001 * MIB record parameters:
2002 *       parm1    Table index (1-6).
2003 *       parm2    Not used.
2004 *       parm3    Not used.
2005 *
2006 * Arguments:
2007 *       mib      MIB record.
2008 *       isget    MIBGET/MIBSET flag.
2009 *       wlandev  wlan device structure.
2010 *       priv     "priv" structure.
2011 *       hw       "hw" structure.
2012 *       msg      Message structure.
2013 *       data     Data buffer.
2014 *
2015 * Returns:
2016 *       0   - Success.
2017 *       ~0  - Error.
2018 *
2019 ----------------------------------------------------------------*/
2020
2021 static int prism2mib_authalgenable(
2022 mibrec_t                     *mib,
2023 int                          isget,
2024 wlandevice_t                 *wlandev,
2025 hfa384x_t                    *hw,
2026 p80211msg_dot11req_mibset_t  *msg,
2027 void                         *data)
2028 {
2029         int     result;
2030         u32  *uint32 = (u32*) data;
2031
2032         int     index;
2033         u16  cnf_auth;
2034         u16     mask;
2035
2036         DBFENTER;
2037
2038         index = mib->parm1 - 1;
2039
2040         result = hfa384x_drvr_getconfig16( hw,
2041                         HFA384x_RID_CNFAUTHENTICATION, &cnf_auth);
2042         WLAN_LOG_DEBUG(2,"cnfAuthentication0=%d, index=%d\n", cnf_auth, index);
2043
2044         if (isget) {
2045                 if ( index == 0 || index == 1 ) {
2046                         *uint32 = (cnf_auth & (1<<index)) ?
2047                                 P80211ENUM_truth_true: P80211ENUM_truth_false;
2048                 } else {
2049                         *uint32 = P80211ENUM_truth_false;
2050                         msg->resultcode.data = P80211ENUM_resultcode_not_supported;
2051                 }
2052         } else {
2053                 if ( index == 0 || index == 1 ) {
2054                         mask = 1 << index;
2055                         if (*uint32==P80211ENUM_truth_true ) {
2056                                 cnf_auth |= mask;
2057                         } else {
2058                                 cnf_auth &= ~mask;
2059                         }
2060                         result = hfa384x_drvr_setconfig16( hw,
2061                                         HFA384x_RID_CNFAUTHENTICATION, cnf_auth);
2062                         WLAN_LOG_DEBUG(2,"cnfAuthentication:=%d\n", cnf_auth);
2063                         if ( result ) {
2064                                 WLAN_LOG_DEBUG(1,"Unable to set p2cnfAuthentication to %d\n", cnf_auth);
2065                                 msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;
2066                         }
2067                 } else {
2068                         msg->resultcode.data = P80211ENUM_resultcode_not_supported;
2069                 }
2070         }
2071
2072         DBFEXIT;
2073         return(result);
2074 }
2075
2076 /*----------------------------------------------------------------
2077 * prism2mib_priv
2078 *
2079 * Get/set values in the "priv" data structure.
2080 *
2081 * MIB record parameters:
2082 *       parm1    Not used.
2083 *       parm2    Not used.
2084 *       parm3    Not used.
2085 *
2086 * Arguments:
2087 *       mib      MIB record.
2088 *       isget    MIBGET/MIBSET flag.
2089 *       wlandev  wlan device structure.
2090 *       priv     "priv" structure.
2091 *       hw       "hw" structure.
2092 *       msg      Message structure.
2093 *       data     Data buffer.
2094 *
2095 * Returns:
2096 *       0   - Success.
2097 *       ~0  - Error.
2098 *
2099 ----------------------------------------------------------------*/
2100
2101 static int prism2mib_priv(
2102 mibrec_t                     *mib,
2103 int                          isget,
2104 wlandevice_t                 *wlandev,
2105 hfa384x_t                    *hw,
2106 p80211msg_dot11req_mibset_t  *msg,
2107 void                         *data)
2108 {
2109         u32            *uint32 = (u32*) data;
2110         p80211pstrd_t     *pstr = (p80211pstrd_t*) data;
2111
2112         int  i, cnt, result;
2113
2114         /*
2115         ** "test" is a lot longer than necessary but who cares?  ...as long as
2116         ** it is long enough!
2117         */
2118
2119         u8  test[sizeof(wlandev->rx) + sizeof(hw->tallies)];
2120
2121         DBFENTER;
2122
2123         switch (mib->did) {
2124         case DIDmib_p2_p2Table_p2ReceivedFrameStatistics:
2125
2126                 /*
2127                 ** Note: The values in this record are changed by the
2128                 ** interrupt handler and therefore cannot be guaranteed
2129                 ** to be stable while they are being copied.  However,
2130                 ** the interrupt handler will take priority over this
2131                 ** code.  Hence, if the same values are copied twice,
2132                 ** then we are ensured that the values have not been
2133                 ** changed.  If they have, then just try again.  Don't
2134                 ** try more than 10 times...if we still haven't got it,
2135                 ** then the values we do have are probably good enough.
2136                 ** This scheme for copying values is used in order to
2137                 ** prevent having to block the interrupt handler while
2138                 ** we copy the values.
2139                 */
2140
2141                 if (isget)
2142                         for (i = 0; i < 10; i++) {
2143                                 memcpy(data, &wlandev->rx, sizeof(wlandev->rx));
2144                                 memcpy(test, &wlandev->rx, sizeof(wlandev->rx));
2145                                 if (memcmp(data, test, sizeof(wlandev->rx)) == 0) break;
2146                         }
2147
2148                 break;
2149
2150         case DIDmib_p2_p2Table_p2CommunicationTallies:
2151
2152                 /*
2153                 ** Note: The values in this record are changed by the
2154                 ** interrupt handler and therefore cannot be guaranteed
2155                 ** to be stable while they are being copied.  See the
2156                 ** note above about copying values.
2157                 */
2158
2159                 if (isget) {
2160                         result = hfa384x_drvr_commtallies(hw);
2161
2162                         /* ?????? We need to wait a bit here for the */
2163                         /*   tallies to get updated. ?????? */
2164                         /* MSM: TODO: The right way to do this is to
2165                          *      add a "commtallie" wait queue to the
2166                          *      priv structure that gets run every time
2167                          *      we receive a commtally info frame.
2168                          *      This process would sleep on that
2169                          *      queue and get awakened when the
2170                          *      the requested info frame arrives.
2171                          *      Don't have time to do and test this
2172                          *      right now.
2173                          */
2174
2175                         /* Ugh, this is nasty. */
2176                         for (i = 0; i < 10; i++) {
2177                                 memcpy(data,
2178                                        &hw->tallies,
2179                                        sizeof(hw->tallies));
2180                                 memcpy(test,
2181                                        &hw->tallies,
2182                                        sizeof(hw->tallies));
2183                                 if ( memcmp(data,
2184                                             test,
2185                                             sizeof(hw->tallies)) == 0)
2186                                         break;
2187                         }
2188                 }
2189
2190                 break;
2191
2192         case DIDmib_p2_p2Table_p2Comment:
2193
2194                 if (isget) {
2195                         pstr->len = strlen(hw->comment);
2196                         memcpy(pstr->data, hw->comment, pstr->len);
2197                 } else {
2198                         cnt = pstr->len;
2199                         if (cnt < 0) cnt = 0;
2200                         if (cnt >= sizeof(hw->comment))
2201                                 cnt = sizeof(hw->comment)-1;
2202                         memcpy(hw->comment, pstr->data, cnt);
2203                         pstr->data[cnt] = '\0';
2204                 }
2205
2206                 break;
2207
2208         case DIDmib_dot11smt_dot11StationConfigTable_dot11DesiredBSSType:
2209
2210                 if (isget)
2211                         *uint32 = hw->dot11_desired_bss_type;
2212                 else
2213                         hw->dot11_desired_bss_type = *uint32;
2214
2215                 break;
2216
2217         case DIDmib_lnx_lnxConfigTable_lnxRSNAIE: {
2218                 hfa384x_WPAData_t wpa;
2219                 if (isget) {
2220                         hfa384x_drvr_getconfig( hw, HFA384x_RID_CNFWPADATA,
2221                                                 (u8 *) &wpa, sizeof(wpa));
2222                         pstr->len = hfa384x2host_16(wpa.datalen);
2223                         memcpy(pstr->data, wpa.data, pstr->len);
2224                 } else {
2225                         wpa.datalen = host2hfa384x_16(pstr->len);
2226                         memcpy(wpa.data, pstr->data, pstr->len);
2227
2228                         result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFWPADATA,
2229                                 (u8 *) &wpa, sizeof(wpa));
2230                 }
2231                 break;
2232         }
2233         default:
2234                 WLAN_LOG_ERROR("Unhandled DID 0x%08x\n", mib->did);
2235         }
2236
2237         DBFEXIT;
2238         return(0);
2239 }
2240
2241 /*----------------------------------------------------------------
2242 * prism2mgmt_pstr2bytestr
2243 *
2244 * Convert the pstr data in the WLAN message structure into an hfa384x
2245 * byte string format.
2246 *
2247 * Arguments:
2248 *       bytestr         hfa384x byte string data type
2249 *       pstr            wlan message data
2250 *
2251 * Returns:
2252 *       Nothing
2253 *
2254 ----------------------------------------------------------------*/
2255
2256 void prism2mgmt_pstr2bytestr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr)
2257 {
2258         DBFENTER;
2259
2260         bytestr->len = host2hfa384x_16((u16)(pstr->len));
2261         memcpy(bytestr->data, pstr->data, pstr->len);
2262         DBFEXIT;
2263 }
2264
2265
2266 /*----------------------------------------------------------------
2267 * prism2mgmt_pstr2bytearea
2268 *
2269 * Convert the pstr data in the WLAN message structure into an hfa384x
2270 * byte area format.
2271 *
2272 * Arguments:
2273 *       bytearea        hfa384x byte area data type
2274 *       pstr            wlan message data
2275 *
2276 * Returns:
2277 *       Nothing
2278 *
2279 ----------------------------------------------------------------*/
2280
2281 void prism2mgmt_pstr2bytearea(u8 *bytearea, p80211pstrd_t *pstr)
2282 {
2283         DBFENTER;
2284
2285         memcpy(bytearea, pstr->data, pstr->len);
2286         DBFEXIT;
2287 }
2288
2289
2290 /*----------------------------------------------------------------
2291 * prism2mgmt_bytestr2pstr
2292 *
2293 * Convert the data in an hfa384x byte string format into a
2294 * pstr in the WLAN message.
2295 *
2296 * Arguments:
2297 *       bytestr         hfa384x byte string data type
2298 *       msg             wlan message
2299 *
2300 * Returns:
2301 *       Nothing
2302 *
2303 ----------------------------------------------------------------*/
2304
2305 void prism2mgmt_bytestr2pstr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr)
2306 {
2307         DBFENTER;
2308
2309         pstr->len = (u8)(hfa384x2host_16((u16)(bytestr->len)));
2310         memcpy(pstr->data, bytestr->data, pstr->len);
2311         DBFEXIT;
2312 }
2313
2314
2315 /*----------------------------------------------------------------
2316 * prism2mgmt_bytearea2pstr
2317 *
2318 * Convert the data in an hfa384x byte area format into a pstr
2319 * in the WLAN message.
2320 *
2321 * Arguments:
2322 *       bytearea        hfa384x byte area data type
2323 *       msg             wlan message
2324 *
2325 * Returns:
2326 *       Nothing
2327 *
2328 ----------------------------------------------------------------*/
2329
2330 void prism2mgmt_bytearea2pstr(u8 *bytearea, p80211pstrd_t *pstr, int len)
2331 {
2332         DBFENTER;
2333
2334         pstr->len = (u8)len;
2335         memcpy(pstr->data, bytearea, len);
2336         DBFEXIT;
2337 }
2338
2339
2340 /*----------------------------------------------------------------
2341 * prism2mgmt_prism2int2p80211int
2342 *
2343 * Convert an hfa384x integer into a wlan integer
2344 *
2345 * Arguments:
2346 *       prism2enum      pointer to hfa384x integer
2347 *       wlanenum        pointer to p80211 integer
2348 *
2349 * Returns:
2350 *       Nothing
2351 *
2352 ----------------------------------------------------------------*/
2353
2354 void prism2mgmt_prism2int2p80211int(u16 *prism2int, u32 *wlanint)
2355 {
2356         DBFENTER;
2357
2358         *wlanint = (u32)hfa384x2host_16(*prism2int);
2359         DBFEXIT;
2360 }
2361
2362
2363 /*----------------------------------------------------------------
2364 * prism2mgmt_p80211int2prism2int
2365 *
2366 * Convert a wlan integer into an hfa384x integer
2367 *
2368 * Arguments:
2369 *       prism2enum      pointer to hfa384x integer
2370 *       wlanenum        pointer to p80211 integer
2371 *
2372 * Returns:
2373 *       Nothing
2374 *
2375 ----------------------------------------------------------------*/
2376
2377 void prism2mgmt_p80211int2prism2int(u16 *prism2int, u32 *wlanint)
2378 {
2379         DBFENTER;
2380
2381         *prism2int = host2hfa384x_16((u16)(*wlanint));
2382         DBFEXIT;
2383 }
2384
2385
2386 /*----------------------------------------------------------------
2387 * prism2mgmt_prism2enum2p80211enum
2388 *
2389 * Convert the hfa384x enumerated int into a p80211 enumerated int
2390 *
2391 * Arguments:
2392 *       prism2enum      pointer to hfa384x integer
2393 *       wlanenum        pointer to p80211 integer
2394 *       rid             hfa384x record id
2395 *
2396 * Returns:
2397 *       Nothing
2398 *
2399 ----------------------------------------------------------------*/
2400 void prism2mgmt_prism2enum2p80211enum(u16 *prism2enum, u32 *wlanenum, u16 rid)
2401 {
2402         DBFENTER;
2403
2404         /* At the moment, the need for this functionality hasn't
2405         presented itself. All the wlan enumerated values are
2406         a 1-to-1 match against the Prism2 enumerated values*/
2407         DBFEXIT;
2408         return;
2409 }
2410
2411
2412 /*----------------------------------------------------------------
2413 * prism2mgmt_p80211enum2prism2enum
2414 *
2415 * Convert the p80211 enumerated int into an hfa384x enumerated int
2416 *
2417 * Arguments:
2418 *       prism2enum      pointer to hfa384x integer
2419 *       wlanenum        pointer to p80211 integer
2420 *       rid             hfa384x record id
2421 *
2422 * Returns:
2423 *       Nothing
2424 *
2425 ----------------------------------------------------------------*/
2426 void prism2mgmt_p80211enum2prism2enum(u16 *prism2enum, u32 *wlanenum, u16 rid)
2427 {
2428         DBFENTER;
2429
2430         /* At the moment, the need for this functionality hasn't
2431         presented itself. All the wlan enumerated values are
2432         a 1-to-1 match against the Prism2 enumerated values*/
2433         DBFEXIT;
2434         return;
2435 }
2436
2437
2438
2439 /*----------------------------------------------------------------
2440 * prism2mgmt_get_oprateset
2441 *
2442 * Convert the hfa384x bit area into a wlan octet string.
2443 *
2444 * Arguments:
2445 *       rate            Prism2 bit area
2446 *       pstr            wlan octet string
2447 *
2448 * Returns:
2449 *       Nothing
2450 *
2451 ----------------------------------------------------------------*/
2452 void prism2mgmt_get_oprateset(u16 *rate, p80211pstrd_t *pstr)
2453 {
2454         u8      len;
2455         u8      *datarate;
2456
2457         DBFENTER;
2458
2459         len = 0;
2460         datarate = pstr->data;
2461
2462         /* 1 Mbps */
2463         if ( BIT0 & (*rate) ) {
2464                 len += (u8)1;
2465                 *datarate = (u8)2;
2466                 datarate++;
2467         }
2468
2469         /* 2 Mbps */
2470         if ( BIT1 & (*rate) ) {
2471                 len += (u8)1;
2472                 *datarate = (u8)4;
2473                 datarate++;
2474         }
2475
2476         /* 5.5 Mbps */
2477         if ( BIT2 & (*rate) ) {
2478                 len += (u8)1;
2479                 *datarate = (u8)11;
2480                 datarate++;
2481         }
2482
2483         /* 11 Mbps */
2484         if ( BIT3 & (*rate) ) {
2485                 len += (u8)1;
2486                 *datarate = (u8)22;
2487                 datarate++;
2488         }
2489
2490         pstr->len = len;
2491
2492         DBFEXIT;
2493         return;
2494 }
2495
2496
2497
2498 /*----------------------------------------------------------------
2499 * prism2mgmt_set_oprateset
2500 *
2501 * Convert the wlan octet string into an hfa384x bit area.
2502 *
2503 * Arguments:
2504 *       rate            Prism2 bit area
2505 *       pstr            wlan octet string
2506 *
2507 * Returns:
2508 *       Nothing
2509 *
2510 ----------------------------------------------------------------*/
2511 void prism2mgmt_set_oprateset(u16 *rate, p80211pstrd_t *pstr)
2512 {
2513         u8      *datarate;
2514         int     i;
2515
2516         DBFENTER;
2517
2518         *rate = 0;
2519
2520         datarate = pstr->data;
2521
2522         for ( i=0; i < pstr->len; i++, datarate++ ) {
2523                 switch (*datarate) {
2524                 case 2: /* 1 Mbps */
2525                         *rate |= BIT0;
2526                         break;
2527                 case 4: /* 2 Mbps */
2528                         *rate |= BIT1;
2529                         break;
2530                 case 11: /* 5.5 Mbps */
2531                         *rate |= BIT2;
2532                         break;
2533                 case 22: /* 11 Mbps */
2534                         *rate |= BIT3;
2535                         break;
2536                 default:
2537                         WLAN_LOG_DEBUG(1, "Unrecoginzed Rate of %d\n",
2538                                 *datarate);
2539                         break;
2540                 }
2541         }
2542
2543         DBFEXIT;
2544         return;
2545 }
2546
2547
2548
2549 /*----------------------------------------------------------------
2550 * prism2mgmt_get_grpaddr
2551 *
2552 * Retrieves a particular group address from the list of
2553 * group addresses.
2554 *
2555 * Arguments:
2556 *       did             mibitem did
2557 *       pstr            wlan octet string
2558 *       priv            prism2 driver private data structure
2559 *
2560 * Returns:
2561 *       Nothing
2562 *
2563 ----------------------------------------------------------------*/
2564 void prism2mgmt_get_grpaddr(u32 did, p80211pstrd_t *pstr,
2565         hfa384x_t *hw )
2566 {
2567         int     index;
2568
2569         DBFENTER;
2570
2571         index = prism2mgmt_get_grpaddr_index(did);
2572
2573         if ( index >= 0 ) {
2574                 pstr->len = WLAN_ADDR_LEN;
2575                 memcpy(pstr->data, hw->dot11_grp_addr[index],
2576                         WLAN_ADDR_LEN);
2577         }
2578
2579         DBFEXIT;
2580         return;
2581 }
2582
2583
2584
2585 /*----------------------------------------------------------------
2586 * prism2mgmt_set_grpaddr
2587 *
2588 * Convert the wlan octet string into an hfa384x bit area.
2589 *
2590 * Arguments:
2591 *       did             mibitem did
2592 *       buf
2593 *       groups
2594 *
2595 * Returns:
2596 *       0       Success
2597 *       !0      Error
2598 *
2599 ----------------------------------------------------------------*/
2600 int prism2mgmt_set_grpaddr(u32 did, u8 *prism2buf,
2601         p80211pstrd_t *pstr, hfa384x_t *hw )
2602 {
2603         u8      no_addr[WLAN_ADDR_LEN];
2604         int     index;
2605
2606         DBFENTER;
2607
2608         memset(no_addr, 0, WLAN_ADDR_LEN);
2609         if (memcmp(no_addr, pstr->data, WLAN_ADDR_LEN) != 0) {
2610
2611                 /*
2612                 ** The address is NOT 0 so we are "adding" an address to the
2613                 ** group address list.  Check to make sure we aren't trying
2614                 ** to add more than the maximum allowed number of group
2615                 ** addresses in the list.  The new address is added to the
2616                 ** end of the list regardless of the DID used to add the
2617                 ** address.
2618                 */
2619
2620                 if (hw->dot11_grpcnt >= MAX_GRP_ADDR) return(-1);
2621
2622                 memcpy(hw->dot11_grp_addr[hw->dot11_grpcnt], pstr->data,
2623                                                                  WLAN_ADDR_LEN);
2624                 hw->dot11_grpcnt += 1;
2625         } else {
2626
2627                 /*
2628                 ** The address is 0.  Interpret this as "deleting" an address
2629                 ** from the group address list.  Get the address index from
2630                 ** the DID.  If this is within the range of used addresses,
2631                 ** then delete the specified address by shifting all following
2632                 ** addresses down.  Then clear the last address (which should
2633                 ** now be unused).  If the address index is NOT within the
2634                 ** range of used addresses, then just ignore the address.
2635                 */
2636
2637                 index = prism2mgmt_get_grpaddr_index(did);
2638                 if (index >= 0 && index < hw->dot11_grpcnt) {
2639                         hw->dot11_grpcnt -= 1;
2640                         memmove(hw->dot11_grp_addr[index],
2641                                 hw->dot11_grp_addr[index + 1],
2642                                 ((hw->dot11_grpcnt)-index) * WLAN_ADDR_LEN);
2643                         memset(hw->dot11_grp_addr[hw->dot11_grpcnt], 0,
2644                                                                  WLAN_ADDR_LEN);
2645                 }
2646         }
2647
2648         DBFEXIT;
2649         return(0);
2650 }