prism2mib.c 21 KB

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