linux/drivers/staging/wlan-ng/prism2mib.c
<<
>>
Prefs
   1// SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1)
   2/* src/prism2/driver/prism2mib.c
   3 *
   4 * Management request for mibset/mibget
   5 *
   6 * Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
   7 * --------------------------------------------------------------------
   8 *
   9 * linux-wlan
  10 *
  11 *   The contents of this file are subject to the Mozilla Public
  12 *   License Version 1.1 (the "License"); you may not use this file
  13 *   except in compliance with the License. You may obtain a copy of
  14 *   the License at http://www.mozilla.org/MPL/
  15 *
  16 *   Software distributed under the License is distributed on an "AS
  17 *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  18 *   implied. See the License for the specific language governing
  19 *   rights and limitations under the License.
  20 *
  21 *   Alternatively, the contents of this file may be used under the
  22 *   terms of the GNU Public License version 2 (the "GPL"), in which
  23 *   case the provisions of the GPL are applicable instead of the
  24 *   above.  If you wish to allow the use of your version of this file
  25 *   only under the terms of the GPL and not to allow others to use
  26 *   your version of this file under the MPL, indicate your decision
  27 *   by deleting the provisions above and replace them with the notice
  28 *   and other provisions required by the GPL.  If you do not delete
  29 *   the provisions above, a recipient may use your version of this
  30 *   file under either the MPL or the GPL.
  31 *
  32 * --------------------------------------------------------------------
  33 *
  34 * Inquiries regarding the linux-wlan Open Source project can be
  35 * made directly to:
  36 *
  37 * AbsoluteValue Systems Inc.
  38 * info@linux-wlan.com
  39 * http://www.linux-wlan.com
  40 *
  41 * --------------------------------------------------------------------
  42 *
  43 * Portions of the development of this software were funded by
  44 * Intersil Corporation as part of PRISM(R) chipset product development.
  45 *
  46 * --------------------------------------------------------------------
  47 *
  48 * The functions in this file handle the mibset/mibget management
  49 * functions.
  50 *
  51 * --------------------------------------------------------------------
  52 */
  53
  54#include <linux/module.h>
  55#include <linux/kernel.h>
  56#include <linux/sched.h>
  57#include <linux/types.h>
  58#include <linux/wireless.h>
  59#include <linux/netdevice.h>
  60#include <linux/io.h>
  61#include <linux/delay.h>
  62#include <asm/byteorder.h>
  63#include <linux/usb.h>
  64#include <linux/bitops.h>
  65
  66#include "p80211types.h"
  67#include "p80211hdr.h"
  68#include "p80211mgmt.h"
  69#include "p80211conv.h"
  70#include "p80211msg.h"
  71#include "p80211netdev.h"
  72#include "p80211metadef.h"
  73#include "p80211metastruct.h"
  74#include "hfa384x.h"
  75#include "prism2mgmt.h"
  76
  77#define MIB_TMP_MAXLEN    200   /* Max length of RID record (in bytes). */
  78
  79#define  F_STA        0x1       /* MIB is supported on stations. */
  80#define  F_READ       0x2       /* MIB may be read. */
  81#define  F_WRITE      0x4       /* MIB may be written. */
  82
  83struct mibrec {
  84        u32 did;
  85        u16 flag;
  86        u16 parm1;
  87        u16 parm2;
  88        u16 parm3;
  89        int (*func)(struct mibrec *mib,
  90                    int isget,
  91                    struct wlandevice *wlandev,
  92                    struct hfa384x *hw,
  93                    struct p80211msg_dot11req_mibset *msg, void *data);
  94};
  95
  96static int prism2mib_bytearea2pstr(struct mibrec *mib,
  97                                   int isget,
  98                                   struct wlandevice *wlandev,
  99                                   struct hfa384x *hw,
 100                                   struct p80211msg_dot11req_mibset *msg,
 101                                   void *data);
 102
 103static int prism2mib_uint32(struct mibrec *mib,
 104                            int isget,
 105                            struct wlandevice *wlandev,
 106                            struct hfa384x *hw,
 107                            struct p80211msg_dot11req_mibset *msg, void *data);
 108
 109static int prism2mib_flag(struct mibrec *mib,
 110                          int isget,
 111                          struct wlandevice *wlandev,
 112                          struct hfa384x *hw,
 113                          struct p80211msg_dot11req_mibset *msg, void *data);
 114
 115static int prism2mib_wepdefaultkey(struct mibrec *mib,
 116                                   int isget,
 117                                   struct wlandevice *wlandev,
 118                                   struct hfa384x *hw,
 119                                   struct p80211msg_dot11req_mibset *msg,
 120                                   void *data);
 121
 122static int prism2mib_privacyinvoked(struct mibrec *mib,
 123                                    int isget,
 124                                    struct wlandevice *wlandev,
 125                                    struct hfa384x *hw,
 126                                    struct p80211msg_dot11req_mibset *msg,
 127                                    void *data);
 128
 129static int
 130prism2mib_fragmentationthreshold(struct mibrec *mib,
 131                                 int isget,
 132                                 struct wlandevice *wlandev,
 133                                 struct hfa384x *hw,
 134                                 struct p80211msg_dot11req_mibset *msg,
 135                                 void *data);
 136
 137static int prism2mib_priv(struct mibrec *mib,
 138                          int isget,
 139                          struct wlandevice *wlandev,
 140                          struct hfa384x *hw,
 141                          struct p80211msg_dot11req_mibset *msg, void *data);
 142
 143static struct mibrec mibtab[] = {
 144        /* dot11smt MIB's */
 145        {didmib_dot11smt_wepdefaultkeystable_key(1),
 146         F_STA | F_WRITE,
 147         HFA384x_RID_CNFWEPDEFAULTKEY0, 0, 0,
 148         prism2mib_wepdefaultkey},
 149        {didmib_dot11smt_wepdefaultkeystable_key(2),
 150         F_STA | F_WRITE,
 151         HFA384x_RID_CNFWEPDEFAULTKEY1, 0, 0,
 152         prism2mib_wepdefaultkey},
 153        {didmib_dot11smt_wepdefaultkeystable_key(3),
 154         F_STA | F_WRITE,
 155         HFA384x_RID_CNFWEPDEFAULTKEY2, 0, 0,
 156         prism2mib_wepdefaultkey},
 157        {didmib_dot11smt_wepdefaultkeystable_key(4),
 158         F_STA | F_WRITE,
 159         HFA384x_RID_CNFWEPDEFAULTKEY3, 0, 0,
 160         prism2mib_wepdefaultkey},
 161        {DIDMIB_DOT11SMT_PRIVACYTABLE_PRIVACYINVOKED,
 162         F_STA | F_READ | F_WRITE,
 163         HFA384x_RID_CNFWEPFLAGS, HFA384x_WEPFLAGS_PRIVINVOKED, 0,
 164         prism2mib_privacyinvoked},
 165        {DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID,
 166         F_STA | F_READ | F_WRITE,
 167         HFA384x_RID_CNFWEPDEFAULTKEYID, 0, 0,
 168         prism2mib_uint32},
 169        {DIDMIB_DOT11SMT_PRIVACYTABLE_EXCLUDEUNENCRYPTED,
 170         F_STA | F_READ | F_WRITE,
 171         HFA384x_RID_CNFWEPFLAGS, HFA384x_WEPFLAGS_EXCLUDE, 0,
 172         prism2mib_flag},
 173
 174        /* dot11mac MIB's */
 175
 176        {DIDMIB_DOT11MAC_OPERATIONTABLE_MACADDRESS,
 177         F_STA | F_READ | F_WRITE,
 178         HFA384x_RID_CNFOWNMACADDR, HFA384x_RID_CNFOWNMACADDR_LEN, 0,
 179         prism2mib_bytearea2pstr},
 180        {DIDMIB_DOT11MAC_OPERATIONTABLE_RTSTHRESHOLD,
 181         F_STA | F_READ | F_WRITE,
 182         HFA384x_RID_RTSTHRESH, 0, 0,
 183         prism2mib_uint32},
 184        {DIDMIB_DOT11MAC_OPERATIONTABLE_SHORTRETRYLIMIT,
 185         F_STA | F_READ,
 186         HFA384x_RID_SHORTRETRYLIMIT, 0, 0,
 187         prism2mib_uint32},
 188        {DIDMIB_DOT11MAC_OPERATIONTABLE_LONGRETRYLIMIT,
 189         F_STA | F_READ,
 190         HFA384x_RID_LONGRETRYLIMIT, 0, 0,
 191         prism2mib_uint32},
 192        {DIDMIB_DOT11MAC_OPERATIONTABLE_FRAGMENTATIONTHRESHOLD,
 193         F_STA | F_READ | F_WRITE,
 194         HFA384x_RID_FRAGTHRESH, 0, 0,
 195         prism2mib_fragmentationthreshold},
 196        {DIDMIB_DOT11MAC_OPERATIONTABLE_MAXTRANSMITMSDULIFETIME,
 197         F_STA | F_READ,
 198         HFA384x_RID_MAXTXLIFETIME, 0, 0,
 199         prism2mib_uint32},
 200
 201        /* dot11phy MIB's */
 202
 203        {DIDMIB_DOT11PHY_DSSSTABLE_CURRENTCHANNEL,
 204         F_STA | F_READ,
 205         HFA384x_RID_CURRENTCHANNEL, 0, 0,
 206         prism2mib_uint32},
 207        {DIDMIB_DOT11PHY_TXPOWERTABLE_CURRENTTXPOWERLEVEL,
 208         F_STA | F_READ | F_WRITE,
 209         HFA384x_RID_TXPOWERMAX, 0, 0,
 210         prism2mib_uint32},
 211
 212        /* p2Static MIB's */
 213
 214        {DIDMIB_P2_STATIC_CNFPORTTYPE,
 215         F_STA | F_READ | F_WRITE,
 216         HFA384x_RID_CNFPORTTYPE, 0, 0,
 217         prism2mib_uint32},
 218
 219        /* p2MAC MIB's */
 220
 221        {DIDMIB_P2_MAC_CURRENTTXRATE,
 222         F_STA | F_READ,
 223         HFA384x_RID_CURRENTTXRATE, 0, 0,
 224         prism2mib_uint32},
 225
 226        /* And finally, lnx mibs */
 227        {DIDMIB_LNX_CONFIGTABLE_RSNAIE,
 228         F_STA | F_READ | F_WRITE,
 229         HFA384x_RID_CNFWPADATA, 0, 0,
 230         prism2mib_priv},
 231        {0, 0, 0, 0, 0, NULL}
 232};
 233
 234/*
 235 * prism2mgmt_mibset_mibget
 236 *
 237 * Set the value of a mib item.
 238 *
 239 * Arguments:
 240 *      wlandev         wlan device structure
 241 *      msgp            ptr to msg buffer
 242 *
 243 * Returns:
 244 *      0       success and done
 245 *      <0      success, but we're waiting for something to finish.
 246 *      >0      an error occurred while handling the message.
 247 * Side effects:
 248 *
 249 * Call context:
 250 *      process thread  (usually)
 251 *      interrupt
 252 */
 253
 254int prism2mgmt_mibset_mibget(struct wlandevice *wlandev, void *msgp)
 255{
 256        struct hfa384x *hw = wlandev->priv;
 257        int result, isget;
 258        struct mibrec *mib;
 259
 260        u16 which;
 261
 262        struct p80211msg_dot11req_mibset *msg = msgp;
 263        struct p80211itemd *mibitem;
 264
 265        msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
 266        msg->resultcode.data = P80211ENUM_resultcode_success;
 267
 268        /*
 269         ** Determine if this is an Access Point or a station.
 270         */
 271
 272        which = F_STA;
 273
 274        /*
 275         ** Find the MIB in the MIB table.  Note that a MIB may be in the
 276         ** table twice...once for an AP and once for a station.  Make sure
 277         ** to get the correct one.  Note that DID=0 marks the end of the
 278         ** MIB table.
 279         */
 280
 281        mibitem = (struct p80211itemd *)msg->mibattribute.data;
 282
 283        for (mib = mibtab; mib->did != 0; mib++)
 284                if (mib->did == mibitem->did && (mib->flag & which))
 285                        break;
 286
 287        if (mib->did == 0) {
 288                msg->resultcode.data = P80211ENUM_resultcode_not_supported;
 289                goto done;
 290        }
 291
 292        /*
 293         ** Determine if this is a "mibget" or a "mibset".  If this is a
 294         ** "mibget", then make sure that the MIB may be read.  Otherwise,
 295         ** this is a "mibset" so make make sure that the MIB may be written.
 296         */
 297
 298        isget = (msg->msgcode == DIDMSG_DOT11REQ_MIBGET);
 299
 300        if (isget) {
 301                if (!(mib->flag & F_READ)) {
 302                        msg->resultcode.data =
 303                            P80211ENUM_resultcode_cant_get_writeonly_mib;
 304                        goto done;
 305                }
 306        } else {
 307                if (!(mib->flag & F_WRITE)) {
 308                        msg->resultcode.data =
 309                            P80211ENUM_resultcode_cant_set_readonly_mib;
 310                        goto done;
 311                }
 312        }
 313
 314        /*
 315         ** Execute the MIB function.  If things worked okay, then make
 316         ** sure that the MIB function also worked okay.  If so, and this
 317         ** is a "mibget", then the status value must be set for both the
 318         ** "mibattribute" parameter and the mib item within the data
 319         ** portion of the "mibattribute".
 320         */
 321
 322        result = mib->func(mib, isget, wlandev, hw, msg, (void *)mibitem->data);
 323
 324        if (msg->resultcode.data == P80211ENUM_resultcode_success) {
 325                if (result != 0) {
 326                        pr_debug("get/set failure, result=%d\n", result);
 327                        msg->resultcode.data =
 328                            P80211ENUM_resultcode_implementation_failure;
 329                } else {
 330                        if (isget) {
 331                                msg->mibattribute.status =
 332                                    P80211ENUM_msgitem_status_data_ok;
 333                                mibitem->status =
 334                                    P80211ENUM_msgitem_status_data_ok;
 335                        }
 336                }
 337        }
 338
 339done:
 340        return 0;
 341}
 342
 343/*
 344 * prism2mib_bytearea2pstr
 345 *
 346 * Get/set pstr data to/from a byte area.
 347 *
 348 * MIB record parameters:
 349 *       parm1    Prism2 RID value.
 350 *       parm2    Number of bytes of RID data.
 351 *       parm3    Not used.
 352 *
 353 * Arguments:
 354 *       mib      MIB record.
 355 *       isget    MIBGET/MIBSET flag.
 356 *       wlandev  wlan device structure.
 357 *       priv     "priv" structure.
 358 *       hw       "hw" structure.
 359 *       msg      Message structure.
 360 *       data     Data buffer.
 361 *
 362 * Returns:
 363 *       0   - Success.
 364 *       ~0  - Error.
 365 *
 366 */
 367
 368static int prism2mib_bytearea2pstr(struct mibrec *mib,
 369                                   int isget,
 370                                   struct wlandevice *wlandev,
 371                                   struct hfa384x *hw,
 372                                   struct p80211msg_dot11req_mibset *msg,
 373                                   void *data)
 374{
 375        int result;
 376        struct p80211pstrd *pstr = data;
 377        u8 bytebuf[MIB_TMP_MAXLEN];
 378
 379        if (isget) {
 380                result =
 381                    hfa384x_drvr_getconfig(hw, mib->parm1, bytebuf, mib->parm2);
 382                prism2mgmt_bytearea2pstr(bytebuf, pstr, mib->parm2);
 383        } else {
 384                memset(bytebuf, 0, mib->parm2);
 385                memcpy(bytebuf, pstr->data, pstr->len);
 386                result =
 387                    hfa384x_drvr_setconfig(hw, mib->parm1, bytebuf, mib->parm2);
 388        }
 389
 390        return result;
 391}
 392
 393/*
 394 * prism2mib_uint32
 395 *
 396 * Get/set uint32 data.
 397 *
 398 * MIB record parameters:
 399 *       parm1    Prism2 RID value.
 400 *       parm2    Not used.
 401 *       parm3    Not used.
 402 *
 403 * Arguments:
 404 *       mib      MIB record.
 405 *       isget    MIBGET/MIBSET flag.
 406 *       wlandev  wlan device structure.
 407 *       priv     "priv" structure.
 408 *       hw       "hw" structure.
 409 *       msg      Message structure.
 410 *       data     Data buffer.
 411 *
 412 * Returns:
 413 *       0   - Success.
 414 *       ~0  - Error.
 415 *
 416 */
 417
 418static int prism2mib_uint32(struct mibrec *mib,
 419                            int isget,
 420                            struct wlandevice *wlandev,
 421                            struct hfa384x *hw,
 422                            struct p80211msg_dot11req_mibset *msg, void *data)
 423{
 424        int result;
 425        u32 *uint32 = data;
 426        u8 bytebuf[MIB_TMP_MAXLEN];
 427        u16 *wordbuf = (u16 *)bytebuf;
 428
 429        if (isget) {
 430                result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
 431                *uint32 = *wordbuf;
 432        } else {
 433                *wordbuf = *uint32;
 434                result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
 435        }
 436
 437        return result;
 438}
 439
 440/*
 441 * prism2mib_flag
 442 *
 443 * Get/set a flag.
 444 *
 445 * MIB record parameters:
 446 *       parm1    Prism2 RID value.
 447 *       parm2    Bit to get/set.
 448 *       parm3    Not used.
 449 *
 450 * Arguments:
 451 *       mib      MIB record.
 452 *       isget    MIBGET/MIBSET flag.
 453 *       wlandev  wlan device structure.
 454 *       priv     "priv" structure.
 455 *       hw       "hw" structure.
 456 *       msg      Message structure.
 457 *       data     Data buffer.
 458 *
 459 * Returns:
 460 *       0   - Success.
 461 *       ~0  - Error.
 462 *
 463 */
 464
 465static int prism2mib_flag(struct mibrec *mib,
 466                          int isget,
 467                          struct wlandevice *wlandev,
 468                          struct hfa384x *hw,
 469                          struct p80211msg_dot11req_mibset *msg, void *data)
 470{
 471        int result;
 472        u32 *uint32 = data;
 473        u8 bytebuf[MIB_TMP_MAXLEN];
 474        u16 *wordbuf = (u16 *)bytebuf;
 475        u32 flags;
 476
 477        result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
 478        if (result == 0) {
 479                flags = *wordbuf;
 480                if (isget) {
 481                        *uint32 = (flags & mib->parm2) ?
 482                            P80211ENUM_truth_true : P80211ENUM_truth_false;
 483                } else {
 484                        if ((*uint32) == P80211ENUM_truth_true)
 485                                flags |= mib->parm2;
 486                        else
 487                                flags &= ~mib->parm2;
 488                        *wordbuf = flags;
 489                        result =
 490                            hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
 491                }
 492        }
 493
 494        return result;
 495}
 496
 497/*
 498 * prism2mib_wepdefaultkey
 499 *
 500 * Get/set WEP default keys.
 501 *
 502 * MIB record parameters:
 503 *       parm1    Prism2 RID value.
 504 *       parm2    Number of bytes of RID data.
 505 *       parm3    Not used.
 506 *
 507 * Arguments:
 508 *       mib      MIB record.
 509 *       isget    MIBGET/MIBSET flag.
 510 *       wlandev  wlan device structure.
 511 *       priv     "priv" structure.
 512 *       hw       "hw" structure.
 513 *       msg      Message structure.
 514 *       data     Data buffer.
 515 *
 516 * Returns:
 517 *       0   - Success.
 518 *       ~0  - Error.
 519 *
 520 */
 521
 522static int prism2mib_wepdefaultkey(struct mibrec *mib,
 523                                   int isget,
 524                                   struct wlandevice *wlandev,
 525                                   struct hfa384x *hw,
 526                                   struct p80211msg_dot11req_mibset *msg,
 527                                   void *data)
 528{
 529        int result;
 530        struct p80211pstrd *pstr = data;
 531        u8 bytebuf[MIB_TMP_MAXLEN];
 532        u16 len;
 533
 534        if (isget) {
 535                result = 0;     /* Should never happen. */
 536        } else {
 537                len = (pstr->len > 5) ? HFA384x_RID_CNFWEP128DEFAULTKEY_LEN :
 538                    HFA384x_RID_CNFWEPDEFAULTKEY_LEN;
 539                memset(bytebuf, 0, len);
 540                memcpy(bytebuf, pstr->data, pstr->len);
 541                result = hfa384x_drvr_setconfig(hw, mib->parm1, bytebuf, len);
 542        }
 543
 544        return result;
 545}
 546
 547/*
 548 * prism2mib_privacyinvoked
 549 *
 550 * Get/set the dot11PrivacyInvoked value.
 551 *
 552 * MIB record parameters:
 553 *       parm1    Prism2 RID value.
 554 *       parm2    Bit value for PrivacyInvoked flag.
 555 *       parm3    Not used.
 556 *
 557 * Arguments:
 558 *       mib      MIB record.
 559 *       isget    MIBGET/MIBSET flag.
 560 *       wlandev  wlan device structure.
 561 *       priv     "priv" structure.
 562 *       hw       "hw" structure.
 563 *       msg      Message structure.
 564 *       data     Data buffer.
 565 *
 566 * Returns:
 567 *       0   - Success.
 568 *       ~0  - Error.
 569 *
 570 */
 571
 572static int prism2mib_privacyinvoked(struct mibrec *mib,
 573                                    int isget,
 574                                    struct wlandevice *wlandev,
 575                                    struct hfa384x *hw,
 576                                    struct p80211msg_dot11req_mibset *msg,
 577                                    void *data)
 578{
 579        if (wlandev->hostwep & HOSTWEP_DECRYPT) {
 580                if (wlandev->hostwep & HOSTWEP_DECRYPT)
 581                        mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_RXCRYPT;
 582                if (wlandev->hostwep & HOSTWEP_ENCRYPT)
 583                        mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_TXCRYPT;
 584        }
 585
 586        return prism2mib_flag(mib, isget, wlandev, hw, msg, data);
 587}
 588
 589/*
 590 * prism2mib_fragmentationthreshold
 591 *
 592 * Get/set the fragmentation threshold.
 593 *
 594 * MIB record parameters:
 595 *       parm1    Prism2 RID value.
 596 *       parm2    Not used.
 597 *       parm3    Not used.
 598 *
 599 * Arguments:
 600 *       mib      MIB record.
 601 *       isget    MIBGET/MIBSET flag.
 602 *       wlandev  wlan device structure.
 603 *       priv     "priv" structure.
 604 *       hw       "hw" structure.
 605 *       msg      Message structure.
 606 *       data     Data buffer.
 607 *
 608 * Returns:
 609 *       0   - Success.
 610 *       ~0  - Error.
 611 *
 612 */
 613
 614static int
 615prism2mib_fragmentationthreshold(struct mibrec *mib,
 616                                 int isget,
 617                                 struct wlandevice *wlandev,
 618                                 struct hfa384x *hw,
 619                                 struct p80211msg_dot11req_mibset *msg,
 620                                 void *data)
 621{
 622        u32 *uint32 = data;
 623
 624        if (!isget)
 625                if ((*uint32) % 2) {
 626                        netdev_warn(wlandev->netdev,
 627                                    "Attempt to set odd number FragmentationThreshold\n");
 628                        msg->resultcode.data =
 629                            P80211ENUM_resultcode_not_supported;
 630                        return 0;
 631                }
 632
 633        return prism2mib_uint32(mib, isget, wlandev, hw, msg, data);
 634}
 635
 636/*
 637 * prism2mib_priv
 638 *
 639 * Get/set values in the "priv" data structure.
 640 *
 641 * MIB record parameters:
 642 *       parm1    Not used.
 643 *       parm2    Not used.
 644 *       parm3    Not used.
 645 *
 646 * Arguments:
 647 *       mib      MIB record.
 648 *       isget    MIBGET/MIBSET flag.
 649 *       wlandev  wlan device structure.
 650 *       priv     "priv" structure.
 651 *       hw       "hw" structure.
 652 *       msg      Message structure.
 653 *       data     Data buffer.
 654 *
 655 * Returns:
 656 *       0   - Success.
 657 *       ~0  - Error.
 658 *
 659 */
 660
 661static int prism2mib_priv(struct mibrec *mib,
 662                          int isget,
 663                          struct wlandevice *wlandev,
 664                          struct hfa384x *hw,
 665                          struct p80211msg_dot11req_mibset *msg, void *data)
 666{
 667        struct p80211pstrd *pstr = data;
 668
 669        switch (mib->did) {
 670        case DIDMIB_LNX_CONFIGTABLE_RSNAIE: {
 671                struct hfa384x_wpa_data wpa;
 672
 673                if (isget) {
 674                        hfa384x_drvr_getconfig(hw,
 675                                               HFA384x_RID_CNFWPADATA,
 676                                               (u8 *)&wpa,
 677                                               sizeof(wpa));
 678                        pstr->len = le16_to_cpu(wpa.datalen);
 679                        memcpy(pstr->data, wpa.data, pstr->len);
 680                } else {
 681                        wpa.datalen = cpu_to_le16(pstr->len);
 682                        memcpy(wpa.data, pstr->data, pstr->len);
 683
 684                        hfa384x_drvr_setconfig(hw,
 685                                               HFA384x_RID_CNFWPADATA,
 686                                               (u8 *)&wpa,
 687                                               sizeof(wpa));
 688                }
 689                break;
 690        }
 691        default:
 692                netdev_err(wlandev->netdev, "Unhandled DID 0x%08x\n", mib->did);
 693        }
 694
 695        return 0;
 696}
 697
 698/*
 699 * prism2mgmt_pstr2bytestr
 700 *
 701 * Convert the pstr data in the WLAN message structure into an hfa384x
 702 * byte string format.
 703 *
 704 * Arguments:
 705 *      bytestr         hfa384x byte string data type
 706 *      pstr            wlan message data
 707 *
 708 * Returns:
 709 *      Nothing
 710 *
 711 */
 712
 713void prism2mgmt_pstr2bytestr(struct hfa384x_bytestr *bytestr,
 714                             struct p80211pstrd *pstr)
 715{
 716        bytestr->len = cpu_to_le16((u16)(pstr->len));
 717        memcpy(bytestr->data, pstr->data, pstr->len);
 718}
 719
 720/*
 721 * prism2mgmt_bytestr2pstr
 722 *
 723 * Convert the data in an hfa384x byte string format into a
 724 * pstr in the WLAN message.
 725 *
 726 * Arguments:
 727 *      bytestr         hfa384x byte string data type
 728 *      msg             wlan message
 729 *
 730 * Returns:
 731 *      Nothing
 732 *
 733 */
 734
 735void prism2mgmt_bytestr2pstr(struct hfa384x_bytestr *bytestr,
 736                             struct p80211pstrd *pstr)
 737{
 738        pstr->len = (u8)(le16_to_cpu(bytestr->len));
 739        memcpy(pstr->data, bytestr->data, pstr->len);
 740}
 741
 742/*
 743 * prism2mgmt_bytearea2pstr
 744 *
 745 * Convert the data in an hfa384x byte area format into a pstr
 746 * in the WLAN message.
 747 *
 748 * Arguments:
 749 *      bytearea        hfa384x byte area data type
 750 *      msg             wlan message
 751 *
 752 * Returns:
 753 *      Nothing
 754 *
 755 */
 756
 757void prism2mgmt_bytearea2pstr(u8 *bytearea, struct p80211pstrd *pstr, int len)
 758{
 759        pstr->len = (u8)len;
 760        memcpy(pstr->data, bytearea, len);
 761}
 762