prism2mib.c 20 KB

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