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