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