Merge branch 'urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
[linux-2.6-block.git] / drivers / staging / wlan-ng / prism2mib.c
CommitLineData
00b3ed16
GKH
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
00b3ed16
GKH
53#include <linux/module.h>
54#include <linux/kernel.h>
55#include <linux/sched.h>
56#include <linux/types.h>
00b3ed16
GKH
57#include <linux/wireless.h>
58#include <linux/netdevice.h>
ec7466f0 59#include <linux/io.h>
00b3ed16
GKH
60#include <linux/delay.h>
61#include <asm/byteorder.h>
00b3ed16 62#include <linux/usb.h>
7f6e0e44 63#include <linux/bitops.h>
00b3ed16 64
00b3ed16
GKH
65#include "p80211types.h"
66#include "p80211hdr.h"
67#include "p80211mgmt.h"
68#include "p80211conv.h"
69#include "p80211msg.h"
70#include "p80211netdev.h"
71#include "p80211metadef.h"
72#include "p80211metastruct.h"
73#include "hfa384x.h"
74#include "prism2mgmt.h"
75
ec7466f0
MM
76#define MIB_TMP_MAXLEN 200 /* Max length of RID record (in bytes). */
77
78#define F_STA 0x1 /* MIB is supported on stations. */
79#define F_READ 0x2 /* MIB may be read. */
80#define F_WRITE 0x4 /* MIB may be written. */
81
82typedef struct mibrec {
83 u32 did;
84 u16 flag;
85 u16 parm1;
86 u16 parm2;
87 u16 parm3;
297f06ce 88 int (*func) (struct mibrec *mib,
ec7466f0 89 int isget,
297f06ce
MT
90 wlandevice_t *wlandev,
91 hfa384x_t *hw,
92 p80211msg_dot11req_mibset_t *msg, void *data);
00b3ed16
GKH
93} mibrec_t;
94
297f06ce 95static int prism2mib_bytearea2pstr(mibrec_t *mib,
ec7466f0 96 int isget,
297f06ce
MT
97 wlandevice_t *wlandev,
98 hfa384x_t *hw,
99 p80211msg_dot11req_mibset_t *msg,
ec7466f0
MM
100 void *data);
101
297f06ce 102static int prism2mib_uint32(mibrec_t *mib,
ec7466f0 103 int isget,
297f06ce
MT
104 wlandevice_t *wlandev,
105 hfa384x_t *hw,
106 p80211msg_dot11req_mibset_t *msg, void *data);
ec7466f0 107
297f06ce 108static int prism2mib_flag(mibrec_t *mib,
ec7466f0 109 int isget,
297f06ce
MT
110 wlandevice_t *wlandev,
111 hfa384x_t *hw,
112 p80211msg_dot11req_mibset_t *msg, void *data);
ec7466f0 113
297f06ce 114static int prism2mib_wepdefaultkey(mibrec_t *mib,
ec7466f0 115 int isget,
5dd8acc8 116 wlandevice_t *wlandev,
297f06ce
MT
117 hfa384x_t *hw,
118 p80211msg_dot11req_mibset_t *msg,
ec7466f0
MM
119 void *data);
120
297f06ce 121static int prism2mib_privacyinvoked(mibrec_t *mib,
ec7466f0 122 int isget,
297f06ce
MT
123 wlandevice_t *wlandev,
124 hfa384x_t *hw,
125 p80211msg_dot11req_mibset_t *msg,
ec7466f0
MM
126 void *data);
127
297f06ce 128static int prism2mib_excludeunencrypted(mibrec_t *mib,
ec7466f0 129 int isget,
297f06ce
MT
130 wlandevice_t *wlandev,
131 hfa384x_t *hw,
132 p80211msg_dot11req_mibset_t *msg,
ec7466f0
MM
133 void *data);
134
297f06ce 135static int prism2mib_fragmentationthreshold(mibrec_t *mib,
ec7466f0 136 int isget,
297f06ce
MT
137 wlandevice_t *wlandev,
138 hfa384x_t *hw,
139 p80211msg_dot11req_mibset_t *msg,
ec7466f0
MM
140 void *data);
141
297f06ce 142static int prism2mib_priv(mibrec_t *mib,
ec7466f0 143 int isget,
297f06ce
MT
144 wlandevice_t *wlandev,
145 hfa384x_t *hw,
146 p80211msg_dot11req_mibset_t *msg, void *data);
00b3ed16
GKH
147
148static mibrec_t mibtab[] = {
149
ec7466f0
MM
150 /* dot11smt MIB's */
151 {DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0,
152 F_STA | F_WRITE,
153 HFA384x_RID_CNFWEPDEFAULTKEY0, 0, 0,
154 prism2mib_wepdefaultkey},
155 {DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1,
156 F_STA | F_WRITE,
157 HFA384x_RID_CNFWEPDEFAULTKEY1, 0, 0,
158 prism2mib_wepdefaultkey},
159 {DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2,
160 F_STA | F_WRITE,
161 HFA384x_RID_CNFWEPDEFAULTKEY2, 0, 0,
162 prism2mib_wepdefaultkey},
163 {DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3,
164 F_STA | F_WRITE,
165 HFA384x_RID_CNFWEPDEFAULTKEY3, 0, 0,
166 prism2mib_wepdefaultkey},
167 {DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
168 F_STA | F_READ | F_WRITE,
169 HFA384x_RID_CNFWEPFLAGS, HFA384x_WEPFLAGS_PRIVINVOKED, 0,
170 prism2mib_privacyinvoked},
171 {DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
172 F_STA | F_READ | F_WRITE,
173 HFA384x_RID_CNFWEPDEFAULTKEYID, 0, 0,
174 prism2mib_uint32},
175 {DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
176 F_STA | F_READ | F_WRITE,
177 HFA384x_RID_CNFWEPFLAGS, HFA384x_WEPFLAGS_EXCLUDE, 0,
178 prism2mib_excludeunencrypted},
179
180 /* dot11mac MIB's */
181
182 {DIDmib_dot11mac_dot11OperationTable_dot11MACAddress,
183 F_STA | F_READ | F_WRITE,
184 HFA384x_RID_CNFOWNMACADDR, HFA384x_RID_CNFOWNMACADDR_LEN, 0,
185 prism2mib_bytearea2pstr},
186 {DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold,
187 F_STA | F_READ | F_WRITE,
188 HFA384x_RID_RTSTHRESH, 0, 0,
189 prism2mib_uint32},
190 {DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit,
191 F_STA | F_READ,
192 HFA384x_RID_SHORTRETRYLIMIT, 0, 0,
193 prism2mib_uint32},
194 {DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit,
195 F_STA | F_READ,
196 HFA384x_RID_LONGRETRYLIMIT, 0, 0,
197 prism2mib_uint32},
198 {DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold,
199 F_STA | F_READ | F_WRITE,
200 HFA384x_RID_FRAGTHRESH, 0, 0,
201 prism2mib_fragmentationthreshold},
202 {DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime,
203 F_STA | F_READ,
204 HFA384x_RID_MAXTXLIFETIME, 0, 0,
205 prism2mib_uint32},
206
207 /* dot11phy MIB's */
208
209 {DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel,
210 F_STA | F_READ,
211 HFA384x_RID_CURRENTCHANNEL, 0, 0,
212 prism2mib_uint32},
213 {DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel,
214 F_STA | F_READ | F_WRITE,
215 HFA384x_RID_TXPOWERMAX, 0, 0,
216 prism2mib_uint32},
217
218 /* p2Static MIB's */
219
220 {DIDmib_p2_p2Static_p2CnfPortType,
221 F_STA | F_READ | F_WRITE,
222 HFA384x_RID_CNFPORTTYPE, 0, 0,
223 prism2mib_uint32},
224
225 /* p2MAC MIB's */
226
227 {DIDmib_p2_p2MAC_p2CurrentTxRate,
228 F_STA | F_READ,
229 HFA384x_RID_CURRENTTXRATE, 0, 0,
230 prism2mib_uint32},
231
232 /* And finally, lnx mibs */
233 {DIDmib_lnx_lnxConfigTable_lnxRSNAIE,
234 F_STA | F_READ | F_WRITE,
235 HFA384x_RID_CNFWPADATA, 0, 0,
236 prism2mib_priv},
237 {0, 0, 0, 0, 0, NULL}
238};
00b3ed16
GKH
239
240/*----------------------------------------------------------------
241* prism2mgmt_mibset_mibget
242*
243* Set the value of a mib item.
244*
245* Arguments:
246* wlandev wlan device structure
247* msgp ptr to msg buffer
248*
249* Returns:
250* 0 success and done
251* <0 success, but we're waiting for something to finish.
252* >0 an error occurred while handling the message.
253* Side effects:
254*
255* Call context:
256* process thread (usually)
257* interrupt
258----------------------------------------------------------------*/
259
297f06ce 260int prism2mgmt_mibset_mibget(wlandevice_t *wlandev, void *msgp)
00b3ed16 261{
ec7466f0
MM
262 hfa384x_t *hw = wlandev->priv;
263 int result, isget;
264 mibrec_t *mib;
f980c178 265
ec7466f0 266 u16 which;
00b3ed16 267
ec7466f0
MM
268 p80211msg_dot11req_mibset_t *msg = msgp;
269 p80211itemd_t *mibitem;
00b3ed16 270
00b3ed16
GKH
271 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
272 msg->resultcode.data = P80211ENUM_resultcode_success;
273
274 /*
ec7466f0
MM
275 ** Determine if this is an Access Point or a station.
276 */
00b3ed16 277
f980c178 278 which = F_STA;
00b3ed16
GKH
279
280 /*
ec7466f0
MM
281 ** Find the MIB in the MIB table. Note that a MIB may be in the
282 ** table twice...once for an AP and once for a station. Make sure
283 ** to get the correct one. Note that DID=0 marks the end of the
284 ** MIB table.
285 */
00b3ed16
GKH
286
287 mibitem = (p80211itemd_t *) msg->mibattribute.data;
288
289 for (mib = mibtab; mib->did != 0; mib++)
290 if (mib->did == mibitem->did && (mib->flag & which))
291 break;
292
293 if (mib->did == 0) {
294 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
295 goto done;
296 }
297
298 /*
ec7466f0
MM
299 ** Determine if this is a "mibget" or a "mibset". If this is a
300 ** "mibget", then make sure that the MIB may be read. Otherwise,
301 ** this is a "mibset" so make make sure that the MIB may be written.
302 */
00b3ed16
GKH
303
304 isget = (msg->msgcode == DIDmsg_dot11req_mibget);
305
306 if (isget) {
307 if (!(mib->flag & F_READ)) {
308 msg->resultcode.data =
ec7466f0 309 P80211ENUM_resultcode_cant_get_writeonly_mib;
00b3ed16
GKH
310 goto done;
311 }
312 } else {
313 if (!(mib->flag & F_WRITE)) {
314 msg->resultcode.data =
ec7466f0 315 P80211ENUM_resultcode_cant_set_readonly_mib;
00b3ed16
GKH
316 goto done;
317 }
318 }
319
320 /*
ec7466f0
MM
321 ** Execute the MIB function. If things worked okay, then make
322 ** sure that the MIB function also worked okay. If so, and this
323 ** is a "mibget", then the status value must be set for both the
324 ** "mibattribute" parameter and the mib item within the data
325 ** portion of the "mibattribute".
326 */
00b3ed16 327
ec7466f0 328 result = mib->func(mib, isget, wlandev, hw, msg, (void *)mibitem->data);
00b3ed16
GKH
329
330 if (msg->resultcode.data == P80211ENUM_resultcode_success) {
331 if (result != 0) {
75f49e07 332 pr_debug("get/set failure, result=%d\n", result);
00b3ed16 333 msg->resultcode.data =
ec7466f0 334 P80211ENUM_resultcode_implementation_failure;
00b3ed16
GKH
335 } else {
336 if (isget) {
337 msg->mibattribute.status =
ec7466f0 338 P80211ENUM_msgitem_status_data_ok;
00b3ed16 339 mibitem->status =
ec7466f0 340 P80211ENUM_msgitem_status_data_ok;
00b3ed16
GKH
341 }
342 }
343 }
344
345done:
ec7466f0 346 return 0;
00b3ed16
GKH
347}
348
349/*----------------------------------------------------------------
56afef56 350* prism2mib_bytearea2pstr
00b3ed16 351*
56afef56 352* Get/set pstr data to/from a byte area.
00b3ed16
GKH
353*
354* MIB record parameters:
355* parm1 Prism2 RID value.
56afef56 356* parm2 Number of bytes of RID data.
00b3ed16
GKH
357* parm3 Not used.
358*
359* Arguments:
360* mib MIB record.
361* isget MIBGET/MIBSET flag.
362* wlandev wlan device structure.
363* priv "priv" structure.
364* hw "hw" structure.
365* msg Message structure.
366* data Data buffer.
367*
368* Returns:
369* 0 - Success.
370* ~0 - Error.
371*
372----------------------------------------------------------------*/
373
297f06ce 374static int prism2mib_bytearea2pstr(mibrec_t *mib,
ec7466f0 375 int isget,
297f06ce
MT
376 wlandevice_t *wlandev,
377 hfa384x_t *hw,
378 p80211msg_dot11req_mibset_t *msg,
ec7466f0 379 void *data)
00b3ed16 380{
ec7466f0
MM
381 int result;
382 p80211pstrd_t *pstr = (p80211pstrd_t *) data;
383 u8 bytebuf[MIB_TMP_MAXLEN];
00b3ed16 384
00b3ed16 385 if (isget) {
ec7466f0
MM
386 result =
387 hfa384x_drvr_getconfig(hw, mib->parm1, bytebuf, mib->parm2);
56afef56 388 prism2mgmt_bytearea2pstr(bytebuf, pstr, mib->parm2);
00b3ed16 389 } else {
56afef56
SP
390 memset(bytebuf, 0, mib->parm2);
391 prism2mgmt_pstr2bytearea(bytebuf, pstr);
ec7466f0
MM
392 result =
393 hfa384x_drvr_setconfig(hw, mib->parm1, bytebuf, mib->parm2);
00b3ed16
GKH
394 }
395
ec7466f0 396 return result;
00b3ed16
GKH
397}
398
399/*----------------------------------------------------------------
56afef56 400* prism2mib_uint32
00b3ed16 401*
56afef56 402* Get/set uint32 data.
00b3ed16
GKH
403*
404* MIB record parameters:
405* parm1 Prism2 RID value.
406* parm2 Not used.
407* parm3 Not used.
408*
409* Arguments:
410* mib MIB record.
411* isget MIBGET/MIBSET flag.
412* wlandev wlan device structure.
413* priv "priv" structure.
414* hw "hw" structure.
415* msg Message structure.
416* data Data buffer.
417*
418* Returns:
419* 0 - Success.
420* ~0 - Error.
421*
422----------------------------------------------------------------*/
423
297f06ce 424static int prism2mib_uint32(mibrec_t *mib,
ec7466f0 425 int isget,
297f06ce
MT
426 wlandevice_t *wlandev,
427 hfa384x_t *hw,
428 p80211msg_dot11req_mibset_t *msg, void *data)
00b3ed16 429{
ec7466f0
MM
430 int result;
431 u32 *uint32 = (u32 *) data;
432 u8 bytebuf[MIB_TMP_MAXLEN];
433 u16 *wordbuf = (u16 *) bytebuf;
00b3ed16 434
00b3ed16
GKH
435 if (isget) {
436 result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
437 *uint32 = *wordbuf;
438 } else {
439 *wordbuf = *uint32;
440 result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
441 }
442
ec7466f0 443 return result;
00b3ed16
GKH
444}
445
446/*----------------------------------------------------------------
56afef56 447* prism2mib_flag
00b3ed16 448*
56afef56 449* Get/set a flag.
00b3ed16
GKH
450*
451* MIB record parameters:
452* parm1 Prism2 RID value.
56afef56 453* parm2 Bit to get/set.
00b3ed16
GKH
454* parm3 Not used.
455*
456* Arguments:
457* mib MIB record.
458* isget MIBGET/MIBSET flag.
459* wlandev wlan device structure.
460* priv "priv" structure.
461* hw "hw" structure.
462* msg Message structure.
463* data Data buffer.
464*
465* Returns:
466* 0 - Success.
467* ~0 - Error.
468*
469----------------------------------------------------------------*/
470
297f06ce 471static int prism2mib_flag(mibrec_t *mib,
ec7466f0 472 int isget,
297f06ce
MT
473 wlandevice_t *wlandev,
474 hfa384x_t *hw,
475 p80211msg_dot11req_mibset_t *msg, void *data)
00b3ed16 476{
ec7466f0
MM
477 int result;
478 u32 *uint32 = (u32 *) data;
479 u8 bytebuf[MIB_TMP_MAXLEN];
480 u16 *wordbuf = (u16 *) bytebuf;
481 u32 flags;
00b3ed16 482
56afef56
SP
483 result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
484 if (result == 0) {
56afef56
SP
485 flags = *wordbuf;
486 if (isget) {
487 *uint32 = (flags & mib->parm2) ?
ec7466f0 488 P80211ENUM_truth_true : P80211ENUM_truth_false;
56afef56
SP
489 } else {
490 if ((*uint32) == P80211ENUM_truth_true)
491 flags |= mib->parm2;
492 else
493 flags &= ~mib->parm2;
56afef56 494 *wordbuf = flags;
ec7466f0
MM
495 result =
496 hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
00b3ed16 497 }
56afef56 498 }
00b3ed16 499
ec7466f0 500 return result;
00b3ed16
GKH
501}
502
503/*----------------------------------------------------------------
56afef56 504* prism2mib_wepdefaultkey
00b3ed16 505*
56afef56 506* Get/set WEP default keys.
00b3ed16
GKH
507*
508* MIB record parameters:
509* parm1 Prism2 RID value.
56afef56 510* parm2 Number of bytes of RID data.
00b3ed16
GKH
511* parm3 Not used.
512*
513* Arguments:
514* mib MIB record.
515* isget MIBGET/MIBSET flag.
516* wlandev wlan device structure.
517* priv "priv" structure.
518* hw "hw" structure.
519* msg Message structure.
520* data Data buffer.
521*
522* Returns:
523* 0 - Success.
524* ~0 - Error.
525*
526----------------------------------------------------------------*/
527
297f06ce 528static int prism2mib_wepdefaultkey(mibrec_t *mib,
ec7466f0 529 int isget,
297f06ce
MT
530 wlandevice_t *wlandev,
531 hfa384x_t *hw,
532 p80211msg_dot11req_mibset_t *msg,
ec7466f0 533 void *data)
00b3ed16 534{
ec7466f0
MM
535 int result;
536 p80211pstrd_t *pstr = (p80211pstrd_t *) data;
537 u8 bytebuf[MIB_TMP_MAXLEN];
538 u16 len;
00b3ed16 539
00b3ed16 540 if (isget) {
ec7466f0 541 result = 0; /* Should never happen. */
00b3ed16 542 } else {
56afef56 543 len = (pstr->len > 5) ? HFA384x_RID_CNFWEP128DEFAULTKEY_LEN :
ec7466f0 544 HFA384x_RID_CNFWEPDEFAULTKEY_LEN;
56afef56
SP
545 memset(bytebuf, 0, len);
546 prism2mgmt_pstr2bytearea(bytebuf, pstr);
547 result = hfa384x_drvr_setconfig(hw, mib->parm1, bytebuf, len);
00b3ed16
GKH
548 }
549
ec7466f0 550 return result;
00b3ed16
GKH
551}
552
00b3ed16 553/*----------------------------------------------------------------
56afef56 554* prism2mib_privacyinvoked
00b3ed16 555*
56afef56 556* Get/set the dot11PrivacyInvoked value.
00b3ed16
GKH
557*
558* MIB record parameters:
56afef56
SP
559* parm1 Prism2 RID value.
560* parm2 Bit value for PrivacyInvoked flag.
00b3ed16
GKH
561* parm3 Not used.
562*
563* Arguments:
564* mib MIB record.
565* isget MIBGET/MIBSET flag.
566* wlandev wlan device structure.
567* priv "priv" structure.
568* hw "hw" structure.
569* msg Message structure.
570* data Data buffer.
571*
572* Returns:
573* 0 - Success.
574* ~0 - Error.
575*
576----------------------------------------------------------------*/
577
297f06ce 578static int prism2mib_privacyinvoked(mibrec_t *mib,
ec7466f0 579 int isget,
297f06ce
MT
580 wlandevice_t *wlandev,
581 hfa384x_t *hw,
582 p80211msg_dot11req_mibset_t *msg,
ec7466f0 583 void *data)
00b3ed16 584{
ec7466f0 585 int result;
00b3ed16 586
56afef56
SP
587 if (wlandev->hostwep & HOSTWEP_DECRYPT) {
588 if (wlandev->hostwep & HOSTWEP_DECRYPT)
589 mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_RXCRYPT;
590 if (wlandev->hostwep & HOSTWEP_ENCRYPT)
591 mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_TXCRYPT;
592 }
593
594 result = prism2mib_flag(mib, isget, wlandev, hw, msg, data);
00b3ed16 595
ec7466f0 596 return result;
00b3ed16
GKH
597}
598
599/*----------------------------------------------------------------
56afef56 600* prism2mib_excludeunencrypted
00b3ed16 601*
56afef56 602* Get/set the dot11ExcludeUnencrypted value.
00b3ed16
GKH
603*
604* MIB record parameters:
56afef56
SP
605* parm1 Prism2 RID value.
606* parm2 Bit value for ExcludeUnencrypted flag.
00b3ed16
GKH
607* parm3 Not used.
608*
609* Arguments:
610* mib MIB record.
611* isget MIBGET/MIBSET flag.
612* wlandev wlan device structure.
613* priv "priv" structure.
614* hw "hw" structure.
615* msg Message structure.
616* data Data buffer.
617*
618* Returns:
619* 0 - Success.
620* ~0 - Error.
621*
622----------------------------------------------------------------*/
623
297f06ce 624static int prism2mib_excludeunencrypted(mibrec_t *mib,
ec7466f0 625 int isget,
297f06ce
MT
626 wlandevice_t *wlandev,
627 hfa384x_t *hw,
628 p80211msg_dot11req_mibset_t *msg,
ec7466f0 629 void *data)
00b3ed16 630{
ec7466f0 631 int result;
00b3ed16 632
56afef56 633 result = prism2mib_flag(mib, isget, wlandev, hw, msg, data);
00b3ed16 634
ec7466f0 635 return result;
00b3ed16
GKH
636}
637
638/*----------------------------------------------------------------
56afef56 639* prism2mib_fragmentationthreshold
00b3ed16 640*
56afef56 641* Get/set the fragmentation threshold.
00b3ed16
GKH
642*
643* MIB record parameters:
56afef56 644* parm1 Prism2 RID value.
00b3ed16
GKH
645* parm2 Not used.
646* parm3 Not used.
647*
648* Arguments:
649* mib MIB record.
650* isget MIBGET/MIBSET flag.
651* wlandev wlan device structure.
652* priv "priv" structure.
653* hw "hw" structure.
654* msg Message structure.
655* data Data buffer.
656*
657* Returns:
658* 0 - Success.
659* ~0 - Error.
660*
661----------------------------------------------------------------*/
662
297f06ce 663static int prism2mib_fragmentationthreshold(mibrec_t *mib,
ec7466f0 664 int isget,
297f06ce
MT
665 wlandevice_t *wlandev,
666 hfa384x_t *hw,
667 p80211msg_dot11req_mibset_t *msg,
ec7466f0 668 void *data)
00b3ed16 669{
ec7466f0
MM
670 int result;
671 u32 *uint32 = (u32 *) data;
00b3ed16 672
56afef56
SP
673 if (!isget)
674 if ((*uint32) % 2) {
9b9556ec 675 printk(KERN_WARNING "Attempt to set odd number "
ec7466f0
MM
676 "FragmentationThreshold\n");
677 msg->resultcode.data =
678 P80211ENUM_resultcode_not_supported;
679 return 0;
00b3ed16 680 }
56afef56
SP
681
682 result = prism2mib_uint32(mib, isget, wlandev, hw, msg, data);
00b3ed16 683
ec7466f0 684 return result;
00b3ed16
GKH
685}
686
687/*----------------------------------------------------------------
688* prism2mib_priv
689*
690* Get/set values in the "priv" data structure.
691*
692* MIB record parameters:
693* parm1 Not used.
694* parm2 Not used.
695* parm3 Not used.
696*
697* Arguments:
698* mib MIB record.
699* isget MIBGET/MIBSET flag.
700* wlandev wlan device structure.
701* priv "priv" structure.
702* hw "hw" structure.
703* msg Message structure.
704* data Data buffer.
705*
706* Returns:
707* 0 - Success.
708* ~0 - Error.
709*
710----------------------------------------------------------------*/
711
297f06ce 712static int prism2mib_priv(mibrec_t *mib,
ec7466f0 713 int isget,
297f06ce
MT
714 wlandevice_t *wlandev,
715 hfa384x_t *hw,
716 p80211msg_dot11req_mibset_t *msg, void *data)
00b3ed16 717{
ec7466f0 718 p80211pstrd_t *pstr = (p80211pstrd_t *) data;
00b3ed16 719
ec7466f0 720 int result;
00b3ed16 721
00b3ed16 722 switch (mib->did) {
ec7466f0
MM
723 case DIDmib_lnx_lnxConfigTable_lnxRSNAIE:{
724 hfa384x_WPAData_t wpa;
725 if (isget) {
726 hfa384x_drvr_getconfig(hw,
727 HFA384x_RID_CNFWPADATA,
5dd8acc8 728 (u8 *) &wpa,
ec7466f0 729 sizeof(wpa));
18c7f792 730 pstr->len = le16_to_cpu(wpa.datalen);
ec7466f0
MM
731 memcpy(pstr->data, wpa.data, pstr->len);
732 } else {
18c7f792 733 wpa.datalen = cpu_to_le16(pstr->len);
ec7466f0
MM
734 memcpy(wpa.data, pstr->data, pstr->len);
735
736 result =
737 hfa384x_drvr_setconfig(hw,
ef1a0ed7
AE
738 HFA384x_RID_CNFWPADATA,
739 (u8 *) &wpa,
740 sizeof(wpa));
ec7466f0
MM
741 }
742 break;
00b3ed16 743 }
00b3ed16 744 default:
edbd606c 745 printk(KERN_ERR "Unhandled DID 0x%08x\n", mib->did);
00b3ed16
GKH
746 }
747
ec7466f0 748 return 0;
00b3ed16
GKH
749}
750
00b3ed16
GKH
751/*----------------------------------------------------------------
752* prism2mgmt_pstr2bytestr
753*
754* Convert the pstr data in the WLAN message structure into an hfa384x
755* byte string format.
756*
757* Arguments:
758* bytestr hfa384x byte string data type
759* pstr wlan message data
760*
761* Returns:
762* Nothing
763*
764----------------------------------------------------------------*/
765
297f06ce 766void prism2mgmt_pstr2bytestr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr)
00b3ed16 767{
18c7f792 768 bytestr->len = cpu_to_le16((u16) (pstr->len));
00b3ed16 769 memcpy(bytestr->data, pstr->data, pstr->len);
00b3ed16
GKH
770}
771
00b3ed16
GKH
772/*----------------------------------------------------------------
773* prism2mgmt_pstr2bytearea
774*
775* Convert the pstr data in the WLAN message structure into an hfa384x
776* byte area format.
777*
778* Arguments:
779* bytearea hfa384x byte area data type
780* pstr wlan message data
781*
782* Returns:
783* Nothing
784*
785----------------------------------------------------------------*/
786
297f06ce 787void prism2mgmt_pstr2bytearea(u8 *bytearea, p80211pstrd_t *pstr)
00b3ed16 788{
00b3ed16 789 memcpy(bytearea, pstr->data, pstr->len);
00b3ed16
GKH
790}
791
00b3ed16
GKH
792/*----------------------------------------------------------------
793* prism2mgmt_bytestr2pstr
794*
795* Convert the data in an hfa384x byte string format into a
796* pstr in the WLAN message.
797*
798* Arguments:
799* bytestr hfa384x byte string data type
800* msg wlan message
801*
802* Returns:
803* Nothing
804*
805----------------------------------------------------------------*/
806
297f06ce 807void prism2mgmt_bytestr2pstr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr)
00b3ed16 808{
18c7f792 809 pstr->len = (u8) (le16_to_cpu((u16) (bytestr->len)));
00b3ed16 810 memcpy(pstr->data, bytestr->data, pstr->len);
00b3ed16
GKH
811}
812
00b3ed16
GKH
813/*----------------------------------------------------------------
814* prism2mgmt_bytearea2pstr
815*
816* Convert the data in an hfa384x byte area format into a pstr
817* in the WLAN message.
818*
819* Arguments:
820* bytearea hfa384x byte area data type
821* msg wlan message
822*
823* Returns:
824* Nothing
825*
826----------------------------------------------------------------*/
827
297f06ce 828void prism2mgmt_bytearea2pstr(u8 *bytearea, p80211pstrd_t *pstr, int len)
00b3ed16 829{
ec7466f0 830 pstr->len = (u8) len;
00b3ed16 831 memcpy(pstr->data, bytearea, len);
00b3ed16 832}