prism2mib.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  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. #include <linux/module.h>
  54. #include <linux/kernel.h>
  55. #include <linux/sched.h>
  56. #include <linux/types.h>
  57. #include <linux/wireless.h>
  58. #include <linux/netdevice.h>
  59. #include <linux/io.h>
  60. #include <linux/delay.h>
  61. #include <asm/byteorder.h>
  62. #include <linux/usb.h>
  63. #include <linux/bitops.h>
  64. #include "p80211types.h"
  65. #include "p80211hdr.h"
  66. #include "p80211mgmt.h"
  67. #include "p80211conv.h"
  68. #include "p80211msg.h"
  69. #include "p80211netdev.h"
  70. #include "p80211metadef.h"
  71. #include "p80211metastruct.h"
  72. #include "hfa384x.h"
  73. #include "prism2mgmt.h"
  74. #define MIB_TMP_MAXLEN 200 /* Max length of RID record (in bytes). */
  75. #define F_STA 0x1 /* MIB is supported on stations. */
  76. #define F_READ 0x2 /* MIB may be read. */
  77. #define F_WRITE 0x4 /* MIB may be written. */
  78. struct mibrec {
  79. u32 did;
  80. u16 flag;
  81. u16 parm1;
  82. u16 parm2;
  83. u16 parm3;
  84. int (*func)(struct mibrec *mib,
  85. int isget,
  86. struct wlandevice *wlandev,
  87. struct hfa384x *hw,
  88. struct p80211msg_dot11req_mibset *msg, void *data);
  89. };
  90. static int prism2mib_bytearea2pstr(struct mibrec *mib,
  91. int isget,
  92. struct wlandevice *wlandev,
  93. struct hfa384x *hw,
  94. struct p80211msg_dot11req_mibset *msg,
  95. void *data);
  96. static int prism2mib_uint32(struct mibrec *mib,
  97. int isget,
  98. struct wlandevice *wlandev,
  99. struct hfa384x *hw,
  100. struct p80211msg_dot11req_mibset *msg, void *data);
  101. static int prism2mib_flag(struct mibrec *mib,
  102. int isget,
  103. struct wlandevice *wlandev,
  104. struct hfa384x *hw,
  105. struct p80211msg_dot11req_mibset *msg, void *data);
  106. static int prism2mib_wepdefaultkey(struct mibrec *mib,
  107. int isget,
  108. struct wlandevice *wlandev,
  109. struct hfa384x *hw,
  110. struct p80211msg_dot11req_mibset *msg,
  111. void *data);
  112. static int prism2mib_privacyinvoked(struct mibrec *mib,
  113. int isget,
  114. struct wlandevice *wlandev,
  115. struct hfa384x *hw,
  116. struct p80211msg_dot11req_mibset *msg,
  117. void *data);
  118. static int
  119. prism2mib_fragmentationthreshold(struct mibrec *mib,
  120. int isget,
  121. struct wlandevice *wlandev,
  122. struct hfa384x *hw,
  123. struct p80211msg_dot11req_mibset *msg,
  124. void *data);
  125. static int prism2mib_priv(struct mibrec *mib,
  126. int isget,
  127. struct wlandevice *wlandev,
  128. struct hfa384x *hw,
  129. struct p80211msg_dot11req_mibset *msg, void *data);
  130. static struct mibrec mibtab[] = {
  131. /* dot11smt MIB's */
  132. {didmib_dot11smt_wepdefaultkeystable_key(1),
  133. F_STA | F_WRITE,
  134. HFA384x_RID_CNFWEPDEFAULTKEY0, 0, 0,
  135. prism2mib_wepdefaultkey},
  136. {didmib_dot11smt_wepdefaultkeystable_key(2),
  137. F_STA | F_WRITE,
  138. HFA384x_RID_CNFWEPDEFAULTKEY1, 0, 0,
  139. prism2mib_wepdefaultkey},
  140. {didmib_dot11smt_wepdefaultkeystable_key(3),
  141. F_STA | F_WRITE,
  142. HFA384x_RID_CNFWEPDEFAULTKEY2, 0, 0,
  143. prism2mib_wepdefaultkey},
  144. {didmib_dot11smt_wepdefaultkeystable_key(4),
  145. F_STA | F_WRITE,
  146. HFA384x_RID_CNFWEPDEFAULTKEY3, 0, 0,
  147. prism2mib_wepdefaultkey},
  148. {DIDMIB_DOT11SMT_PRIVACYTABLE_PRIVACYINVOKED,
  149. F_STA | F_READ | F_WRITE,
  150. HFA384x_RID_CNFWEPFLAGS, HFA384x_WEPFLAGS_PRIVINVOKED, 0,
  151. prism2mib_privacyinvoked},
  152. {DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID,
  153. F_STA | F_READ | F_WRITE,
  154. HFA384x_RID_CNFWEPDEFAULTKEYID, 0, 0,
  155. prism2mib_uint32},
  156. {DIDMIB_DOT11SMT_PRIVACYTABLE_EXCLUDEUNENCRYPTED,
  157. F_STA | F_READ | F_WRITE,
  158. HFA384x_RID_CNFWEPFLAGS, HFA384x_WEPFLAGS_EXCLUDE, 0,
  159. prism2mib_flag},
  160. /* dot11mac MIB's */
  161. {DIDMIB_DOT11MAC_OPERATIONTABLE_MACADDRESS,
  162. F_STA | F_READ | F_WRITE,
  163. HFA384x_RID_CNFOWNMACADDR, HFA384x_RID_CNFOWNMACADDR_LEN, 0,
  164. prism2mib_bytearea2pstr},
  165. {DIDMIB_DOT11MAC_OPERATIONTABLE_RTSTHRESHOLD,
  166. F_STA | F_READ | F_WRITE,
  167. HFA384x_RID_RTSTHRESH, 0, 0,
  168. prism2mib_uint32},
  169. {DIDMIB_DOT11MAC_OPERATIONTABLE_SHORTRETRYLIMIT,
  170. F_STA | F_READ,
  171. HFA384x_RID_SHORTRETRYLIMIT, 0, 0,
  172. prism2mib_uint32},
  173. {DIDMIB_DOT11MAC_OPERATIONTABLE_LONGRETRYLIMIT,
  174. F_STA | F_READ,
  175. HFA384x_RID_LONGRETRYLIMIT, 0, 0,
  176. prism2mib_uint32},
  177. {DIDMIB_DOT11MAC_OPERATIONTABLE_FRAGMENTATIONTHRESHOLD,
  178. F_STA | F_READ | F_WRITE,
  179. HFA384x_RID_FRAGTHRESH, 0, 0,
  180. prism2mib_fragmentationthreshold},
  181. {DIDMIB_DOT11MAC_OPERATIONTABLE_MAXTRANSMITMSDULIFETIME,
  182. F_STA | F_READ,
  183. HFA384x_RID_MAXTXLIFETIME, 0, 0,
  184. prism2mib_uint32},
  185. /* dot11phy MIB's */
  186. {DIDMIB_DOT11PHY_DSSSTABLE_CURRENTCHANNEL,
  187. F_STA | F_READ,
  188. HFA384x_RID_CURRENTCHANNEL, 0, 0,
  189. prism2mib_uint32},
  190. {DIDMIB_DOT11PHY_TXPOWERTABLE_CURRENTTXPOWERLEVEL,
  191. F_STA | F_READ | F_WRITE,
  192. HFA384x_RID_TXPOWERMAX, 0, 0,
  193. prism2mib_uint32},
  194. /* p2Static MIB's */
  195. {DIDMIB_P2_STATIC_CNFPORTTYPE,
  196. F_STA | F_READ | F_WRITE,
  197. HFA384x_RID_CNFPORTTYPE, 0, 0,
  198. prism2mib_uint32},
  199. /* p2MAC MIB's */
  200. {DIDMIB_P2_MAC_CURRENTTXRATE,
  201. F_STA | F_READ,
  202. HFA384x_RID_CURRENTTXRATE, 0, 0,
  203. prism2mib_uint32},
  204. /* And finally, lnx mibs */
  205. {DIDMIB_LNX_CONFIGTABLE_RSNAIE,
  206. F_STA | F_READ | F_WRITE,
  207. HFA384x_RID_CNFWPADATA, 0, 0,
  208. prism2mib_priv},
  209. {0, 0, 0, 0, 0, NULL}
  210. };
  211. /*
  212. * prism2mgmt_mibset_mibget
  213. *
  214. * Set the value of a mib item.
  215. *
  216. * Arguments:
  217. * wlandev wlan device structure
  218. * msgp ptr to msg buffer
  219. *
  220. * Returns:
  221. * 0 success and done
  222. * <0 success, but we're waiting for something to finish.
  223. * >0 an error occurred while handling the message.
  224. * Side effects:
  225. *
  226. * Call context:
  227. * process thread (usually)
  228. * interrupt
  229. */
  230. int prism2mgmt_mibset_mibget(struct wlandevice *wlandev, void *msgp)
  231. {
  232. struct hfa384x *hw = wlandev->priv;
  233. int result, isget;
  234. struct mibrec *mib;
  235. u16 which;
  236. struct p80211msg_dot11req_mibset *msg = msgp;
  237. struct p80211itemd *mibitem;
  238. msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
  239. msg->resultcode.data = P80211ENUM_resultcode_success;
  240. /*
  241. ** Determine if this is an Access Point or a station.
  242. */
  243. which = F_STA;
  244. /*
  245. ** Find the MIB in the MIB table. Note that a MIB may be in the
  246. ** table twice...once for an AP and once for a station. Make sure
  247. ** to get the correct one. Note that DID=0 marks the end of the
  248. ** MIB table.
  249. */
  250. mibitem = (struct p80211itemd *)msg->mibattribute.data;
  251. for (mib = mibtab; mib->did != 0; mib++)
  252. if (mib->did == mibitem->did && (mib->flag & which))
  253. break;
  254. if (mib->did == 0) {
  255. msg->resultcode.data = P80211ENUM_resultcode_not_supported;
  256. goto done;
  257. }
  258. /*
  259. ** Determine if this is a "mibget" or a "mibset". If this is a
  260. ** "mibget", then make sure that the MIB may be read. Otherwise,
  261. ** this is a "mibset" so make sure that the MIB may be written.
  262. */
  263. isget = (msg->msgcode == DIDMSG_DOT11REQ_MIBGET);
  264. if (isget) {
  265. if (!(mib->flag & F_READ)) {
  266. msg->resultcode.data =
  267. P80211ENUM_resultcode_cant_get_writeonly_mib;
  268. goto done;
  269. }
  270. } else {
  271. if (!(mib->flag & F_WRITE)) {
  272. msg->resultcode.data =
  273. P80211ENUM_resultcode_cant_set_readonly_mib;
  274. goto done;
  275. }
  276. }
  277. /*
  278. ** Execute the MIB function. If things worked okay, then make
  279. ** sure that the MIB function also worked okay. If so, and this
  280. ** is a "mibget", then the status value must be set for both the
  281. ** "mibattribute" parameter and the mib item within the data
  282. ** portion of the "mibattribute".
  283. */
  284. result = mib->func(mib, isget, wlandev, hw, msg, (void *)mibitem->data);
  285. if (msg->resultcode.data == P80211ENUM_resultcode_success) {
  286. if (result != 0) {
  287. pr_debug("get/set failure, result=%d\n", result);
  288. msg->resultcode.data =
  289. P80211ENUM_resultcode_implementation_failure;
  290. } else {
  291. if (isget) {
  292. msg->mibattribute.status =
  293. P80211ENUM_msgitem_status_data_ok;
  294. mibitem->status =
  295. P80211ENUM_msgitem_status_data_ok;
  296. }
  297. }
  298. }
  299. done:
  300. return 0;
  301. }
  302. /*
  303. * prism2mib_bytearea2pstr
  304. *
  305. * Get/set pstr data to/from a byte area.
  306. *
  307. * MIB record parameters:
  308. * parm1 Prism2 RID value.
  309. * parm2 Number of bytes of RID data.
  310. * parm3 Not used.
  311. *
  312. * Arguments:
  313. * mib MIB record.
  314. * isget MIBGET/MIBSET flag.
  315. * wlandev wlan device structure.
  316. * priv "priv" structure.
  317. * hw "hw" structure.
  318. * msg Message structure.
  319. * data Data buffer.
  320. *
  321. * Returns:
  322. * 0 - Success.
  323. * ~0 - Error.
  324. *
  325. */
  326. static int prism2mib_bytearea2pstr(struct mibrec *mib,
  327. int isget,
  328. struct wlandevice *wlandev,
  329. struct hfa384x *hw,
  330. struct p80211msg_dot11req_mibset *msg,
  331. void *data)
  332. {
  333. int result;
  334. struct p80211pstrd *pstr = data;
  335. u8 bytebuf[MIB_TMP_MAXLEN];
  336. if (isget) {
  337. result =
  338. hfa384x_drvr_getconfig(hw, mib->parm1, bytebuf, mib->parm2);
  339. prism2mgmt_bytearea2pstr(bytebuf, pstr, mib->parm2);
  340. } else {
  341. memset(bytebuf, 0, mib->parm2);
  342. memcpy(bytebuf, pstr->data, pstr->len);
  343. result =
  344. hfa384x_drvr_setconfig(hw, mib->parm1, bytebuf, mib->parm2);
  345. }
  346. return result;
  347. }
  348. /*
  349. * prism2mib_uint32
  350. *
  351. * Get/set uint32 data.
  352. *
  353. * MIB record parameters:
  354. * parm1 Prism2 RID value.
  355. * parm2 Not used.
  356. * parm3 Not used.
  357. *
  358. * Arguments:
  359. * mib MIB record.
  360. * isget MIBGET/MIBSET flag.
  361. * wlandev wlan device structure.
  362. * priv "priv" structure.
  363. * hw "hw" structure.
  364. * msg Message structure.
  365. * data Data buffer.
  366. *
  367. * Returns:
  368. * 0 - Success.
  369. * ~0 - Error.
  370. *
  371. */
  372. static int prism2mib_uint32(struct mibrec *mib,
  373. int isget,
  374. struct wlandevice *wlandev,
  375. struct hfa384x *hw,
  376. struct p80211msg_dot11req_mibset *msg, void *data)
  377. {
  378. int result;
  379. u32 *uint32 = data;
  380. u8 bytebuf[MIB_TMP_MAXLEN];
  381. u16 *wordbuf = (u16 *)bytebuf;
  382. if (isget) {
  383. result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
  384. *uint32 = *wordbuf;
  385. } else {
  386. *wordbuf = *uint32;
  387. result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
  388. }
  389. return result;
  390. }
  391. /*
  392. * prism2mib_flag
  393. *
  394. * Get/set a flag.
  395. *
  396. * MIB record parameters:
  397. * parm1 Prism2 RID value.
  398. * parm2 Bit to get/set.
  399. * parm3 Not used.
  400. *
  401. * Arguments:
  402. * mib MIB record.
  403. * isget MIBGET/MIBSET flag.
  404. * wlandev wlan device structure.
  405. * priv "priv" structure.
  406. * hw "hw" structure.
  407. * msg Message structure.
  408. * data Data buffer.
  409. *
  410. * Returns:
  411. * 0 - Success.
  412. * ~0 - Error.
  413. *
  414. */
  415. static int prism2mib_flag(struct mibrec *mib,
  416. int isget,
  417. struct wlandevice *wlandev,
  418. struct hfa384x *hw,
  419. struct p80211msg_dot11req_mibset *msg, void *data)
  420. {
  421. int result;
  422. u32 *uint32 = data;
  423. u8 bytebuf[MIB_TMP_MAXLEN];
  424. u16 *wordbuf = (u16 *)bytebuf;
  425. u32 flags;
  426. result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
  427. if (result == 0) {
  428. flags = *wordbuf;
  429. if (isget) {
  430. *uint32 = (flags & mib->parm2) ?
  431. P80211ENUM_truth_true : P80211ENUM_truth_false;
  432. } else {
  433. if ((*uint32) == P80211ENUM_truth_true)
  434. flags |= mib->parm2;
  435. else
  436. flags &= ~mib->parm2;
  437. *wordbuf = flags;
  438. result =
  439. hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
  440. }
  441. }
  442. return result;
  443. }
  444. /*
  445. * prism2mib_wepdefaultkey
  446. *
  447. * Get/set WEP default keys.
  448. *
  449. * MIB record parameters:
  450. * parm1 Prism2 RID value.
  451. * parm2 Number of bytes of RID data.
  452. * parm3 Not used.
  453. *
  454. * Arguments:
  455. * mib MIB record.
  456. * isget MIBGET/MIBSET flag.
  457. * wlandev wlan device structure.
  458. * priv "priv" structure.
  459. * hw "hw" structure.
  460. * msg Message structure.
  461. * data Data buffer.
  462. *
  463. * Returns:
  464. * 0 - Success.
  465. * ~0 - Error.
  466. *
  467. */
  468. static int prism2mib_wepdefaultkey(struct mibrec *mib,
  469. int isget,
  470. struct wlandevice *wlandev,
  471. struct hfa384x *hw,
  472. struct p80211msg_dot11req_mibset *msg,
  473. void *data)
  474. {
  475. int result;
  476. struct p80211pstrd *pstr = data;
  477. u8 bytebuf[MIB_TMP_MAXLEN];
  478. u16 len;
  479. if (isget) {
  480. result = 0; /* Should never happen. */
  481. } else {
  482. len = (pstr->len > 5) ? HFA384x_RID_CNFWEP128DEFAULTKEY_LEN :
  483. HFA384x_RID_CNFWEPDEFAULTKEY_LEN;
  484. memset(bytebuf, 0, len);
  485. memcpy(bytebuf, pstr->data, pstr->len);
  486. result = hfa384x_drvr_setconfig(hw, mib->parm1, bytebuf, len);
  487. }
  488. return result;
  489. }
  490. /*
  491. * prism2mib_privacyinvoked
  492. *
  493. * Get/set the dot11PrivacyInvoked value.
  494. *
  495. * MIB record parameters:
  496. * parm1 Prism2 RID value.
  497. * parm2 Bit value for PrivacyInvoked flag.
  498. * parm3 Not used.
  499. *
  500. * Arguments:
  501. * mib MIB record.
  502. * isget MIBGET/MIBSET flag.
  503. * wlandev wlan device structure.
  504. * priv "priv" structure.
  505. * hw "hw" structure.
  506. * msg Message structure.
  507. * data Data buffer.
  508. *
  509. * Returns:
  510. * 0 - Success.
  511. * ~0 - Error.
  512. *
  513. */
  514. static int prism2mib_privacyinvoked(struct mibrec *mib,
  515. int isget,
  516. struct wlandevice *wlandev,
  517. struct hfa384x *hw,
  518. struct p80211msg_dot11req_mibset *msg,
  519. void *data)
  520. {
  521. if (wlandev->hostwep & HOSTWEP_DECRYPT) {
  522. if (wlandev->hostwep & HOSTWEP_DECRYPT)
  523. mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_RXCRYPT;
  524. if (wlandev->hostwep & HOSTWEP_ENCRYPT)
  525. mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_TXCRYPT;
  526. }
  527. return prism2mib_flag(mib, isget, wlandev, hw, msg, data);
  528. }
  529. /*
  530. * prism2mib_fragmentationthreshold
  531. *
  532. * Get/set the fragmentation threshold.
  533. *
  534. * MIB record parameters:
  535. * parm1 Prism2 RID value.
  536. * parm2 Not used.
  537. * parm3 Not used.
  538. *
  539. * Arguments:
  540. * mib MIB record.
  541. * isget MIBGET/MIBSET flag.
  542. * wlandev wlan device structure.
  543. * priv "priv" structure.
  544. * hw "hw" structure.
  545. * msg Message structure.
  546. * data Data buffer.
  547. *
  548. * Returns:
  549. * 0 - Success.
  550. * ~0 - Error.
  551. *
  552. */
  553. static int
  554. prism2mib_fragmentationthreshold(struct mibrec *mib,
  555. int isget,
  556. struct wlandevice *wlandev,
  557. struct hfa384x *hw,
  558. struct p80211msg_dot11req_mibset *msg,
  559. void *data)
  560. {
  561. u32 *uint32 = data;
  562. if (!isget)
  563. if ((*uint32) % 2) {
  564. netdev_warn(wlandev->netdev,
  565. "Attempt to set odd number FragmentationThreshold\n");
  566. msg->resultcode.data =
  567. P80211ENUM_resultcode_not_supported;
  568. return 0;
  569. }
  570. return prism2mib_uint32(mib, isget, wlandev, hw, msg, data);
  571. }
  572. /*
  573. * prism2mib_priv
  574. *
  575. * Get/set values in the "priv" data structure.
  576. *
  577. * MIB record parameters:
  578. * parm1 Not used.
  579. * parm2 Not used.
  580. * parm3 Not used.
  581. *
  582. * Arguments:
  583. * mib MIB record.
  584. * isget MIBGET/MIBSET flag.
  585. * wlandev wlan device structure.
  586. * priv "priv" structure.
  587. * hw "hw" structure.
  588. * msg Message structure.
  589. * data Data buffer.
  590. *
  591. * Returns:
  592. * 0 - Success.
  593. * ~0 - Error.
  594. *
  595. */
  596. static int prism2mib_priv(struct mibrec *mib,
  597. int isget,
  598. struct wlandevice *wlandev,
  599. struct hfa384x *hw,
  600. struct p80211msg_dot11req_mibset *msg, void *data)
  601. {
  602. struct p80211pstrd *pstr = data;
  603. switch (mib->did) {
  604. case DIDMIB_LNX_CONFIGTABLE_RSNAIE: {
  605. struct hfa384x_wpa_data wpa;
  606. if (isget) {
  607. hfa384x_drvr_getconfig(hw,
  608. HFA384x_RID_CNFWPADATA,
  609. (u8 *)&wpa,
  610. sizeof(wpa));
  611. pstr->len = le16_to_cpu(wpa.datalen);
  612. memcpy(pstr->data, wpa.data, pstr->len);
  613. } else {
  614. wpa.datalen = cpu_to_le16(pstr->len);
  615. memcpy(wpa.data, pstr->data, pstr->len);
  616. hfa384x_drvr_setconfig(hw,
  617. HFA384x_RID_CNFWPADATA,
  618. (u8 *)&wpa,
  619. sizeof(wpa));
  620. }
  621. break;
  622. }
  623. default:
  624. netdev_err(wlandev->netdev, "Unhandled DID 0x%08x\n", mib->did);
  625. }
  626. return 0;
  627. }
  628. /*
  629. * prism2mgmt_pstr2bytestr
  630. *
  631. * Convert the pstr data in the WLAN message structure into an hfa384x
  632. * byte string format.
  633. *
  634. * Arguments:
  635. * bytestr hfa384x byte string data type
  636. * pstr wlan message data
  637. *
  638. * Returns:
  639. * Nothing
  640. *
  641. */
  642. void prism2mgmt_pstr2bytestr(struct hfa384x_bytestr *bytestr,
  643. struct p80211pstrd *pstr)
  644. {
  645. bytestr->len = cpu_to_le16((u16)(pstr->len));
  646. memcpy(bytestr->data, pstr->data, pstr->len);
  647. }
  648. /*
  649. * prism2mgmt_bytestr2pstr
  650. *
  651. * Convert the data in an hfa384x byte string format into a
  652. * pstr in the WLAN message.
  653. *
  654. * Arguments:
  655. * bytestr hfa384x byte string data type
  656. * msg wlan message
  657. *
  658. * Returns:
  659. * Nothing
  660. *
  661. */
  662. void prism2mgmt_bytestr2pstr(struct hfa384x_bytestr *bytestr,
  663. struct p80211pstrd *pstr)
  664. {
  665. pstr->len = (u8)(le16_to_cpu(bytestr->len));
  666. memcpy(pstr->data, bytestr->data, pstr->len);
  667. }
  668. /*
  669. * prism2mgmt_bytearea2pstr
  670. *
  671. * Convert the data in an hfa384x byte area format into a pstr
  672. * in the WLAN message.
  673. *
  674. * Arguments:
  675. * bytearea hfa384x byte area data type
  676. * msg wlan message
  677. *
  678. * Returns:
  679. * Nothing
  680. *
  681. */
  682. void prism2mgmt_bytearea2pstr(u8 *bytearea, struct p80211pstrd *pstr, int len)
  683. {
  684. pstr->len = (u8)len;
  685. memcpy(pstr->data, bytearea, len);
  686. }