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