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