diff options
Diffstat (limited to 'drivers/net/wireless/libertas/ioctl.c')
-rw-r--r-- | drivers/net/wireless/libertas/ioctl.c | 1349 |
1 files changed, 0 insertions, 1349 deletions
diff --git a/drivers/net/wireless/libertas/ioctl.c b/drivers/net/wireless/libertas/ioctl.c index 636a0897150e..42dfd45890c2 100644 --- a/drivers/net/wireless/libertas/ioctl.c +++ b/drivers/net/wireless/libertas/ioctl.c | |||
@@ -27,95 +27,6 @@ | |||
27 | 27 | ||
28 | #define WAIT_FOR_SCAN_RRESULT_MAX_TIME (10 * HZ) | 28 | #define WAIT_FOR_SCAN_RRESULT_MAX_TIME (10 * HZ) |
29 | 29 | ||
30 | static int setrxantenna(wlan_private * priv, int mode) | ||
31 | { | ||
32 | int ret = 0; | ||
33 | wlan_adapter *adapter = priv->adapter; | ||
34 | |||
35 | if (mode != RF_ANTENNA_1 && mode != RF_ANTENNA_2 | ||
36 | && mode != RF_ANTENNA_AUTO) { | ||
37 | return -EINVAL; | ||
38 | } | ||
39 | |||
40 | adapter->rxantennamode = mode; | ||
41 | |||
42 | lbs_pr_debug(1, "SET RX Antenna mode to 0x%04x\n", adapter->rxantennamode); | ||
43 | |||
44 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, | ||
45 | cmd_act_set_rx, | ||
46 | cmd_option_waitforrsp, 0, | ||
47 | &adapter->rxantennamode); | ||
48 | return ret; | ||
49 | } | ||
50 | |||
51 | static int settxantenna(wlan_private * priv, int mode) | ||
52 | { | ||
53 | int ret = 0; | ||
54 | wlan_adapter *adapter = priv->adapter; | ||
55 | |||
56 | if ((mode != RF_ANTENNA_1) && (mode != RF_ANTENNA_2) | ||
57 | && (mode != RF_ANTENNA_AUTO)) { | ||
58 | return -EINVAL; | ||
59 | } | ||
60 | |||
61 | adapter->txantennamode = mode; | ||
62 | |||
63 | lbs_pr_debug(1, "SET TX Antenna mode to 0x%04x\n", adapter->txantennamode); | ||
64 | |||
65 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, | ||
66 | cmd_act_set_tx, | ||
67 | cmd_option_waitforrsp, 0, | ||
68 | &adapter->txantennamode); | ||
69 | |||
70 | return ret; | ||
71 | } | ||
72 | |||
73 | static int getrxantenna(wlan_private * priv, char *buf) | ||
74 | { | ||
75 | int ret = 0; | ||
76 | wlan_adapter *adapter = priv->adapter; | ||
77 | |||
78 | // clear it, so we will know if the value | ||
79 | // returned below is correct or not. | ||
80 | adapter->rxantennamode = 0; | ||
81 | |||
82 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, | ||
83 | cmd_act_get_rx, | ||
84 | cmd_option_waitforrsp, 0, NULL); | ||
85 | |||
86 | if (ret) { | ||
87 | LEAVE(); | ||
88 | return ret; | ||
89 | } | ||
90 | |||
91 | lbs_pr_debug(1, "Get Rx Antenna mode:0x%04x\n", adapter->rxantennamode); | ||
92 | |||
93 | return sprintf(buf, "0x%04x", adapter->rxantennamode) + 1; | ||
94 | } | ||
95 | |||
96 | static int gettxantenna(wlan_private * priv, char *buf) | ||
97 | { | ||
98 | int ret = 0; | ||
99 | wlan_adapter *adapter = priv->adapter; | ||
100 | |||
101 | // clear it, so we will know if the value | ||
102 | // returned below is correct or not. | ||
103 | adapter->txantennamode = 0; | ||
104 | |||
105 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna, | ||
106 | cmd_act_get_tx, | ||
107 | cmd_option_waitforrsp, 0, NULL); | ||
108 | |||
109 | if (ret) { | ||
110 | LEAVE(); | ||
111 | return ret; | ||
112 | } | ||
113 | |||
114 | lbs_pr_debug(1, "Get Tx Antenna mode:0x%04x\n", adapter->txantennamode); | ||
115 | |||
116 | return sprintf(buf, "0x%04x", adapter->txantennamode) + 1; | ||
117 | } | ||
118 | |||
119 | static int wlan_set_region(wlan_private * priv, u16 region_code) | 30 | static int wlan_set_region(wlan_private * priv, u16 region_code) |
120 | { | 31 | { |
121 | int i; | 32 | int i; |
@@ -144,852 +55,6 @@ static int wlan_set_region(wlan_private * priv, u16 region_code) | |||
144 | return 0; | 55 | return 0; |
145 | } | 56 | } |
146 | 57 | ||
147 | /** | ||
148 | * @brief Get/Set Firmware wakeup method | ||
149 | * | ||
150 | * @param priv A pointer to wlan_private structure | ||
151 | * @param wrq A pointer to user data | ||
152 | * @return 0--success, otherwise fail | ||
153 | */ | ||
154 | static int wlan_txcontrol(wlan_private * priv, struct iwreq *wrq) | ||
155 | { | ||
156 | wlan_adapter *adapter = priv->adapter; | ||
157 | int data; | ||
158 | ENTER(); | ||
159 | |||
160 | if ((int)wrq->u.data.length == 0) { | ||
161 | if (copy_to_user | ||
162 | (wrq->u.data.pointer, &adapter->pkttxctrl, sizeof(u32))) { | ||
163 | lbs_pr_alert("copy_to_user failed!\n"); | ||
164 | return -EFAULT; | ||
165 | } | ||
166 | } else { | ||
167 | if ((int)wrq->u.data.length > 1) { | ||
168 | lbs_pr_alert("ioctl too many args!\n"); | ||
169 | return -EFAULT; | ||
170 | } | ||
171 | if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) { | ||
172 | lbs_pr_alert("Copy from user failed\n"); | ||
173 | return -EFAULT; | ||
174 | } | ||
175 | |||
176 | adapter->pkttxctrl = (u32) data; | ||
177 | } | ||
178 | |||
179 | wrq->u.data.length = 1; | ||
180 | |||
181 | LEAVE(); | ||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | /** | ||
186 | * @brief Get/Set NULL Package generation interval | ||
187 | * | ||
188 | * @param priv A pointer to wlan_private structure | ||
189 | * @param wrq A pointer to user data | ||
190 | * @return 0--success, otherwise fail | ||
191 | */ | ||
192 | static int wlan_null_pkt_interval(wlan_private * priv, struct iwreq *wrq) | ||
193 | { | ||
194 | wlan_adapter *adapter = priv->adapter; | ||
195 | int data; | ||
196 | ENTER(); | ||
197 | |||
198 | if ((int)wrq->u.data.length == 0) { | ||
199 | data = adapter->nullpktinterval; | ||
200 | |||
201 | if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) { | ||
202 | lbs_pr_alert( "copy_to_user failed!\n"); | ||
203 | return -EFAULT; | ||
204 | } | ||
205 | } else { | ||
206 | if ((int)wrq->u.data.length > 1) { | ||
207 | lbs_pr_alert( "ioctl too many args!\n"); | ||
208 | return -EFAULT; | ||
209 | } | ||
210 | if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) { | ||
211 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
212 | return -EFAULT; | ||
213 | } | ||
214 | |||
215 | adapter->nullpktinterval = data; | ||
216 | } | ||
217 | |||
218 | wrq->u.data.length = 1; | ||
219 | |||
220 | LEAVE(); | ||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | static int wlan_get_rxinfo(wlan_private * priv, struct iwreq *wrq) | ||
225 | { | ||
226 | wlan_adapter *adapter = priv->adapter; | ||
227 | int data[2]; | ||
228 | ENTER(); | ||
229 | data[0] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG]; | ||
230 | data[1] = adapter->rxpd_rate; | ||
231 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 2)) { | ||
232 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
233 | return -EFAULT; | ||
234 | } | ||
235 | wrq->u.data.length = 2; | ||
236 | LEAVE(); | ||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static int wlan_get_snr(wlan_private * priv, struct iwreq *wrq) | ||
241 | { | ||
242 | int ret = 0; | ||
243 | wlan_adapter *adapter = priv->adapter; | ||
244 | int data[4]; | ||
245 | |||
246 | ENTER(); | ||
247 | memset(data, 0, sizeof(data)); | ||
248 | if (wrq->u.data.length) { | ||
249 | if (copy_from_user(data, wrq->u.data.pointer, | ||
250 | min_t(size_t, wrq->u.data.length, 4) * sizeof(int))) | ||
251 | return -EFAULT; | ||
252 | } | ||
253 | if ((wrq->u.data.length == 0) || (data[0] == 0) || (data[0] == 1)) { | ||
254 | if (adapter->connect_status == libertas_connected) { | ||
255 | ret = libertas_prepare_and_send_command(priv, | ||
256 | cmd_802_11_rssi, | ||
257 | 0, | ||
258 | cmd_option_waitforrsp, | ||
259 | 0, NULL); | ||
260 | |||
261 | if (ret) { | ||
262 | LEAVE(); | ||
263 | return ret; | ||
264 | } | ||
265 | } | ||
266 | } | ||
267 | |||
268 | if (wrq->u.data.length == 0) { | ||
269 | data[0] = adapter->SNR[TYPE_BEACON][TYPE_NOAVG]; | ||
270 | data[1] = adapter->SNR[TYPE_BEACON][TYPE_AVG]; | ||
271 | data[2] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG]; | ||
272 | data[3] = adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; | ||
273 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 4)) | ||
274 | return -EFAULT; | ||
275 | wrq->u.data.length = 4; | ||
276 | } else if (data[0] == 0) { | ||
277 | data[0] = adapter->SNR[TYPE_BEACON][TYPE_NOAVG]; | ||
278 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) | ||
279 | return -EFAULT; | ||
280 | wrq->u.data.length = 1; | ||
281 | } else if (data[0] == 1) { | ||
282 | data[0] = adapter->SNR[TYPE_BEACON][TYPE_AVG]; | ||
283 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) | ||
284 | return -EFAULT; | ||
285 | wrq->u.data.length = 1; | ||
286 | } else if (data[0] == 2) { | ||
287 | data[0] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG]; | ||
288 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) | ||
289 | return -EFAULT; | ||
290 | wrq->u.data.length = 1; | ||
291 | } else if (data[0] == 3) { | ||
292 | data[0] = adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; | ||
293 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int))) | ||
294 | return -EFAULT; | ||
295 | wrq->u.data.length = 1; | ||
296 | } else | ||
297 | return -ENOTSUPP; | ||
298 | |||
299 | LEAVE(); | ||
300 | return 0; | ||
301 | } | ||
302 | |||
303 | static int wlan_beacon_interval(wlan_private * priv, struct iwreq *wrq) | ||
304 | { | ||
305 | int data; | ||
306 | wlan_adapter *adapter = priv->adapter; | ||
307 | |||
308 | if (wrq->u.data.length > 0) { | ||
309 | if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) | ||
310 | return -EFAULT; | ||
311 | |||
312 | lbs_pr_debug(1, "WLAN SET BEACON INTERVAL: %d\n", data); | ||
313 | if ((data > MRVDRV_MAX_BEACON_INTERVAL) | ||
314 | || (data < MRVDRV_MIN_BEACON_INTERVAL)) | ||
315 | return -ENOTSUPP; | ||
316 | adapter->beaconperiod = data; | ||
317 | } | ||
318 | data = adapter->beaconperiod; | ||
319 | if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) | ||
320 | return -EFAULT; | ||
321 | |||
322 | wrq->u.data.length = 1; | ||
323 | |||
324 | return 0; | ||
325 | } | ||
326 | |||
327 | static int wlan_get_rssi(wlan_private * priv, struct iwreq *wrq) | ||
328 | { | ||
329 | int ret = 0; | ||
330 | wlan_adapter *adapter = priv->adapter; | ||
331 | int temp; | ||
332 | int data = 0; | ||
333 | int *val; | ||
334 | |||
335 | ENTER(); | ||
336 | data = SUBCMD_DATA(wrq); | ||
337 | if ((data == 0) || (data == 1)) { | ||
338 | ret = libertas_prepare_and_send_command(priv, | ||
339 | cmd_802_11_rssi, | ||
340 | 0, cmd_option_waitforrsp, | ||
341 | 0, NULL); | ||
342 | if (ret) { | ||
343 | LEAVE(); | ||
344 | return ret; | ||
345 | } | ||
346 | } | ||
347 | |||
348 | switch (data) { | ||
349 | case 0: | ||
350 | |||
351 | temp = CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_NOAVG], | ||
352 | adapter->NF[TYPE_BEACON][TYPE_NOAVG]); | ||
353 | break; | ||
354 | case 1: | ||
355 | temp = CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_AVG], | ||
356 | adapter->NF[TYPE_BEACON][TYPE_AVG]); | ||
357 | break; | ||
358 | case 2: | ||
359 | temp = CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_NOAVG], | ||
360 | adapter->NF[TYPE_RXPD][TYPE_NOAVG]); | ||
361 | break; | ||
362 | case 3: | ||
363 | temp = CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE, | ||
364 | adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE); | ||
365 | break; | ||
366 | default: | ||
367 | return -ENOTSUPP; | ||
368 | } | ||
369 | val = (int *)wrq->u.name; | ||
370 | *val = temp; | ||
371 | |||
372 | LEAVE(); | ||
373 | return 0; | ||
374 | } | ||
375 | |||
376 | static int wlan_get_nf(wlan_private * priv, struct iwreq *wrq) | ||
377 | { | ||
378 | int ret = 0; | ||
379 | wlan_adapter *adapter = priv->adapter; | ||
380 | int temp; | ||
381 | int data = 0; | ||
382 | int *val; | ||
383 | |||
384 | data = SUBCMD_DATA(wrq); | ||
385 | if ((data == 0) || (data == 1)) { | ||
386 | ret = libertas_prepare_and_send_command(priv, | ||
387 | cmd_802_11_rssi, | ||
388 | 0, cmd_option_waitforrsp, | ||
389 | 0, NULL); | ||
390 | |||
391 | if (ret) { | ||
392 | LEAVE(); | ||
393 | return ret; | ||
394 | } | ||
395 | } | ||
396 | |||
397 | switch (data) { | ||
398 | case 0: | ||
399 | temp = adapter->NF[TYPE_BEACON][TYPE_NOAVG]; | ||
400 | break; | ||
401 | case 1: | ||
402 | temp = adapter->NF[TYPE_BEACON][TYPE_AVG]; | ||
403 | break; | ||
404 | case 2: | ||
405 | temp = adapter->NF[TYPE_RXPD][TYPE_NOAVG]; | ||
406 | break; | ||
407 | case 3: | ||
408 | temp = adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; | ||
409 | break; | ||
410 | default: | ||
411 | return -ENOTSUPP; | ||
412 | } | ||
413 | |||
414 | temp = CAL_NF(temp); | ||
415 | |||
416 | lbs_pr_debug(1, "%s: temp = %d\n", __FUNCTION__, temp); | ||
417 | val = (int *)wrq->u.name; | ||
418 | *val = temp; | ||
419 | return 0; | ||
420 | } | ||
421 | |||
422 | static int wlan_get_txrate_ioctl(wlan_private * priv, struct ifreq *req) | ||
423 | { | ||
424 | wlan_adapter *adapter = priv->adapter; | ||
425 | int *pdata; | ||
426 | struct iwreq *wrq = (struct iwreq *)req; | ||
427 | int ret = 0; | ||
428 | adapter->txrate = 0; | ||
429 | lbs_pr_debug(1, "wlan_get_txrate_ioctl\n"); | ||
430 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_tx_rate_query, | ||
431 | cmd_act_get, cmd_option_waitforrsp, | ||
432 | 0, NULL); | ||
433 | if (ret) | ||
434 | return ret; | ||
435 | |||
436 | pdata = (int *)wrq->u.name; | ||
437 | *pdata = (int)adapter->txrate; | ||
438 | return 0; | ||
439 | } | ||
440 | |||
441 | static int wlan_get_adhoc_status_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
442 | { | ||
443 | char status[64]; | ||
444 | wlan_adapter *adapter = priv->adapter; | ||
445 | |||
446 | memset(status, 0, sizeof(status)); | ||
447 | |||
448 | switch (adapter->mode) { | ||
449 | case IW_MODE_ADHOC: | ||
450 | if (adapter->connect_status == libertas_connected) { | ||
451 | if (adapter->adhoccreate) | ||
452 | memcpy(&status, "AdhocStarted", sizeof(status)); | ||
453 | else | ||
454 | memcpy(&status, "AdhocJoined", sizeof(status)); | ||
455 | } else { | ||
456 | memcpy(&status, "AdhocIdle", sizeof(status)); | ||
457 | } | ||
458 | break; | ||
459 | case IW_MODE_INFRA: | ||
460 | memcpy(&status, "Inframode", sizeof(status)); | ||
461 | break; | ||
462 | default: | ||
463 | memcpy(&status, "AutoUnknownmode", sizeof(status)); | ||
464 | break; | ||
465 | } | ||
466 | |||
467 | lbs_pr_debug(1, "status = %s\n", status); | ||
468 | wrq->u.data.length = strlen(status) + 1; | ||
469 | |||
470 | if (wrq->u.data.pointer) { | ||
471 | if (copy_to_user(wrq->u.data.pointer, | ||
472 | &status, wrq->u.data.length)) | ||
473 | return -EFAULT; | ||
474 | } | ||
475 | |||
476 | LEAVE(); | ||
477 | return 0; | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * @brief Set Auto prescan | ||
482 | * @param priv A pointer to wlan_private structure | ||
483 | * @param wrq A pointer to iwreq structure | ||
484 | * @return 0 --success, otherwise fail | ||
485 | */ | ||
486 | static int wlan_subcmd_setprescan_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
487 | { | ||
488 | int data; | ||
489 | wlan_adapter *adapter = priv->adapter; | ||
490 | int *val; | ||
491 | |||
492 | data = SUBCMD_DATA(wrq); | ||
493 | lbs_pr_debug(1, "WLAN_SUBCMD_SET_PRESCAN %d\n", data); | ||
494 | adapter->prescan = data; | ||
495 | |||
496 | val = (int *)wrq->u.name; | ||
497 | *val = data; | ||
498 | return 0; | ||
499 | } | ||
500 | |||
501 | static int wlan_set_multiple_dtim_ioctl(wlan_private * priv, struct ifreq *req) | ||
502 | { | ||
503 | struct iwreq *wrq = (struct iwreq *)req; | ||
504 | u32 mdtim; | ||
505 | int idata; | ||
506 | int ret = -EINVAL; | ||
507 | |||
508 | ENTER(); | ||
509 | |||
510 | idata = SUBCMD_DATA(wrq); | ||
511 | mdtim = (u32) idata; | ||
512 | if (((mdtim >= MRVDRV_MIN_MULTIPLE_DTIM) | ||
513 | && (mdtim <= MRVDRV_MAX_MULTIPLE_DTIM)) | ||
514 | || (mdtim == MRVDRV_IGNORE_MULTIPLE_DTIM)) { | ||
515 | priv->adapter->multipledtim = mdtim; | ||
516 | ret = 0; | ||
517 | } | ||
518 | if (ret) | ||
519 | lbs_pr_debug(1, "Invalid parameter, multipledtim not changed.\n"); | ||
520 | |||
521 | LEAVE(); | ||
522 | return ret; | ||
523 | } | ||
524 | |||
525 | static void adjust_mtu(wlan_private * priv) | ||
526 | { | ||
527 | int mtu_increment = 0; | ||
528 | |||
529 | if (priv->adapter->linkmode == WLAN_LINKMODE_802_11) | ||
530 | mtu_increment += sizeof(struct ieee80211_hdr_4addr); | ||
531 | |||
532 | if (priv->adapter->radiomode == WLAN_RADIOMODE_RADIOTAP) | ||
533 | mtu_increment += max(sizeof(struct tx_radiotap_hdr), | ||
534 | sizeof(struct rx_radiotap_hdr)); | ||
535 | priv->wlan_dev.netdev->mtu = ETH_FRAME_LEN | ||
536 | - sizeof(struct ethhdr) | ||
537 | + mtu_increment; | ||
538 | } | ||
539 | |||
540 | /** | ||
541 | * @brief Set Link-Layer Layer mode | ||
542 | * @param priv A pointer to wlan_private structure | ||
543 | * @param req A pointer to ifreq structure | ||
544 | * @return 0 --success, otherwise fail | ||
545 | */ | ||
546 | static int wlan_set_linkmode_ioctl(wlan_private * priv, struct ifreq *req) | ||
547 | { | ||
548 | int mode; | ||
549 | |||
550 | mode = (int)((struct ifreq *)((u8 *) req + 4))->ifr_data; | ||
551 | |||
552 | switch (mode) { | ||
553 | case WLAN_LINKMODE_802_3: | ||
554 | priv->adapter->linkmode = mode; | ||
555 | break; | ||
556 | case WLAN_LINKMODE_802_11: | ||
557 | priv->adapter->linkmode = mode; | ||
558 | break; | ||
559 | default: | ||
560 | lbs_pr_info("usb8388-5: invalid link-layer mode (%#x)\n", | ||
561 | mode); | ||
562 | return -EINVAL; | ||
563 | break; | ||
564 | } | ||
565 | lbs_pr_debug(1, "usb8388-5: link-layer mode is %#x\n", mode); | ||
566 | |||
567 | adjust_mtu(priv); | ||
568 | |||
569 | return 0; | ||
570 | } | ||
571 | |||
572 | /** | ||
573 | * @brief Set Radio header mode | ||
574 | * @param priv A pointer to wlan_private structure | ||
575 | * @param req A pointer to ifreq structure | ||
576 | * @return 0 --success, otherwise fail | ||
577 | */ | ||
578 | static int wlan_set_radiomode_ioctl(wlan_private * priv, struct ifreq *req) | ||
579 | { | ||
580 | int mode; | ||
581 | |||
582 | mode = (int)((struct ifreq *)((u8 *) req + 4))->ifr_data; | ||
583 | |||
584 | switch (mode) { | ||
585 | case WLAN_RADIOMODE_NONE: | ||
586 | priv->adapter->radiomode = mode; | ||
587 | break; | ||
588 | case WLAN_RADIOMODE_RADIOTAP: | ||
589 | priv->adapter->radiomode = mode; | ||
590 | break; | ||
591 | default: | ||
592 | lbs_pr_debug(1, "usb8388-5: invalid radio header mode (%#x)\n", | ||
593 | mode); | ||
594 | return -EINVAL; | ||
595 | } | ||
596 | lbs_pr_debug(1, "usb8388-5: radio-header mode is %#x\n", mode); | ||
597 | |||
598 | adjust_mtu(priv); | ||
599 | return 0; | ||
600 | } | ||
601 | |||
602 | /** | ||
603 | * @brief Set Debug header mode | ||
604 | * @param priv A pointer to wlan_private structure | ||
605 | * @param req A pointer to ifreq structure | ||
606 | * @return 0 --success, otherwise fail | ||
607 | */ | ||
608 | static int wlan_set_debugmode_ioctl(wlan_private * priv, struct ifreq *req) | ||
609 | { | ||
610 | priv->adapter->debugmode = (int)((struct ifreq *) | ||
611 | ((u8 *) req + 4))->ifr_data; | ||
612 | return 0; | ||
613 | } | ||
614 | |||
615 | static int wlan_subcmd_getrxantenna_ioctl(wlan_private * priv, | ||
616 | struct ifreq *req) | ||
617 | { | ||
618 | int len; | ||
619 | char buf[8]; | ||
620 | struct iwreq *wrq = (struct iwreq *)req; | ||
621 | |||
622 | lbs_pr_debug(1, "WLAN_SUBCMD_GETRXANTENNA\n"); | ||
623 | len = getrxantenna(priv, buf); | ||
624 | |||
625 | wrq->u.data.length = len; | ||
626 | if (wrq->u.data.pointer) { | ||
627 | if (copy_to_user(wrq->u.data.pointer, &buf, len)) { | ||
628 | lbs_pr_debug(1, "CopyToUser failed\n"); | ||
629 | return -EFAULT; | ||
630 | } | ||
631 | } | ||
632 | |||
633 | return 0; | ||
634 | } | ||
635 | |||
636 | static int wlan_subcmd_gettxantenna_ioctl(wlan_private * priv, | ||
637 | struct ifreq *req) | ||
638 | { | ||
639 | int len; | ||
640 | char buf[8]; | ||
641 | struct iwreq *wrq = (struct iwreq *)req; | ||
642 | |||
643 | lbs_pr_debug(1, "WLAN_SUBCMD_GETTXANTENNA\n"); | ||
644 | len = gettxantenna(priv, buf); | ||
645 | |||
646 | wrq->u.data.length = len; | ||
647 | if (wrq->u.data.pointer) { | ||
648 | if (copy_to_user(wrq->u.data.pointer, &buf, len)) { | ||
649 | lbs_pr_debug(1, "CopyToUser failed\n"); | ||
650 | return -EFAULT; | ||
651 | } | ||
652 | } | ||
653 | return 0; | ||
654 | } | ||
655 | |||
656 | /** | ||
657 | * @brief Get the MAC TSF value from the firmware | ||
658 | * | ||
659 | * @param priv A pointer to wlan_private structure | ||
660 | * @param wrq A pointer to iwreq structure containing buffer | ||
661 | * space to store a TSF value retrieved from the firmware | ||
662 | * | ||
663 | * @return 0 if successful; IOCTL error code otherwise | ||
664 | */ | ||
665 | static int wlan_get_tsf_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
666 | { | ||
667 | u64 tsfval; | ||
668 | int ret; | ||
669 | |||
670 | ret = libertas_prepare_and_send_command(priv, | ||
671 | cmd_get_tsf, | ||
672 | 0, cmd_option_waitforrsp, 0, &tsfval); | ||
673 | |||
674 | lbs_pr_debug(1, "IOCTL: Get TSF = 0x%016llx\n", tsfval); | ||
675 | |||
676 | if (ret != 0) { | ||
677 | lbs_pr_debug(1, "IOCTL: Get TSF; command exec failed\n"); | ||
678 | ret = -EFAULT; | ||
679 | } else { | ||
680 | if (copy_to_user(wrq->u.data.pointer, | ||
681 | &tsfval, | ||
682 | min_t(size_t, wrq->u.data.length, | ||
683 | sizeof(tsfval))) != 0) { | ||
684 | |||
685 | lbs_pr_debug(1, "IOCTL: Get TSF; Copy to user failed\n"); | ||
686 | ret = -EFAULT; | ||
687 | } else { | ||
688 | ret = 0; | ||
689 | } | ||
690 | } | ||
691 | return ret; | ||
692 | } | ||
693 | |||
694 | /** | ||
695 | * @brief Get/Set adapt rate | ||
696 | * @param priv A pointer to wlan_private structure | ||
697 | * @param wrq A pointer to iwreq structure | ||
698 | * @return 0 --success, otherwise fail | ||
699 | */ | ||
700 | static int wlan_adapt_rateset(wlan_private * priv, struct iwreq *wrq) | ||
701 | { | ||
702 | int ret; | ||
703 | wlan_adapter *adapter = priv->adapter; | ||
704 | int data[2]; | ||
705 | |||
706 | memset(data, 0, sizeof(data)); | ||
707 | if (!wrq->u.data.length) { | ||
708 | lbs_pr_debug(1, "Get ADAPT RATE SET\n"); | ||
709 | ret = libertas_prepare_and_send_command(priv, | ||
710 | cmd_802_11_rate_adapt_rateset, | ||
711 | cmd_act_get, | ||
712 | cmd_option_waitforrsp, 0, NULL); | ||
713 | data[0] = adapter->enablehwauto; | ||
714 | data[1] = adapter->ratebitmap; | ||
715 | if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 2)) { | ||
716 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
717 | return -EFAULT; | ||
718 | } | ||
719 | #define GET_TWO_INT 2 | ||
720 | wrq->u.data.length = GET_TWO_INT; | ||
721 | } else { | ||
722 | lbs_pr_debug(1, "Set ADAPT RATE SET\n"); | ||
723 | if (wrq->u.data.length > 2) | ||
724 | return -EINVAL; | ||
725 | if (copy_from_user | ||
726 | (data, wrq->u.data.pointer, | ||
727 | sizeof(int) * wrq->u.data.length)) { | ||
728 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
729 | return -EFAULT; | ||
730 | } | ||
731 | |||
732 | adapter->enablehwauto = data[0]; | ||
733 | adapter->ratebitmap = data[1]; | ||
734 | ret = libertas_prepare_and_send_command(priv, | ||
735 | cmd_802_11_rate_adapt_rateset, | ||
736 | cmd_act_set, | ||
737 | cmd_option_waitforrsp, 0, NULL); | ||
738 | } | ||
739 | return ret; | ||
740 | } | ||
741 | |||
742 | /** | ||
743 | * @brief Get/Set inactivity timeout | ||
744 | * @param priv A pointer to wlan_private structure | ||
745 | * @param wrq A pointer to iwreq structure | ||
746 | * @return 0 --success, otherwise fail | ||
747 | */ | ||
748 | static int wlan_inactivity_timeout(wlan_private * priv, struct iwreq *wrq) | ||
749 | { | ||
750 | int ret; | ||
751 | int data = 0; | ||
752 | u16 timeout = 0; | ||
753 | |||
754 | ENTER(); | ||
755 | if (wrq->u.data.length > 1) | ||
756 | return -ENOTSUPP; | ||
757 | |||
758 | if (wrq->u.data.length == 0) { | ||
759 | /* Get */ | ||
760 | ret = libertas_prepare_and_send_command(priv, | ||
761 | cmd_802_11_inactivity_timeout, | ||
762 | cmd_act_get, | ||
763 | cmd_option_waitforrsp, 0, | ||
764 | &timeout); | ||
765 | data = timeout; | ||
766 | if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) { | ||
767 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
768 | return -EFAULT; | ||
769 | } | ||
770 | } else { | ||
771 | /* Set */ | ||
772 | if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) { | ||
773 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
774 | return -EFAULT; | ||
775 | } | ||
776 | |||
777 | timeout = data; | ||
778 | ret = libertas_prepare_and_send_command(priv, | ||
779 | cmd_802_11_inactivity_timeout, | ||
780 | cmd_act_set, | ||
781 | cmd_option_waitforrsp, 0, | ||
782 | &timeout); | ||
783 | } | ||
784 | |||
785 | wrq->u.data.length = 1; | ||
786 | |||
787 | LEAVE(); | ||
788 | return ret; | ||
789 | } | ||
790 | |||
791 | static int wlan_do_getlog_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
792 | { | ||
793 | int ret; | ||
794 | char buf[GETLOG_BUFSIZE - 1]; | ||
795 | wlan_adapter *adapter = priv->adapter; | ||
796 | |||
797 | lbs_pr_debug(1, " GET STATS\n"); | ||
798 | |||
799 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_get_log, | ||
800 | 0, cmd_option_waitforrsp, 0, NULL); | ||
801 | |||
802 | if (ret) { | ||
803 | return ret; | ||
804 | } | ||
805 | |||
806 | if (wrq->u.data.pointer) { | ||
807 | sprintf(buf, "\n mcasttxframe %u failed %u retry %u " | ||
808 | "multiretry %u framedup %u " | ||
809 | "rtssuccess %u rtsfailure %u ackfailure %u\n" | ||
810 | "rxfrag %u mcastrxframe %u fcserror %u " | ||
811 | "txframe %u wepundecryptable %u ", | ||
812 | adapter->logmsg.mcasttxframe, | ||
813 | adapter->logmsg.failed, | ||
814 | adapter->logmsg.retry, | ||
815 | adapter->logmsg.multiretry, | ||
816 | adapter->logmsg.framedup, | ||
817 | adapter->logmsg.rtssuccess, | ||
818 | adapter->logmsg.rtsfailure, | ||
819 | adapter->logmsg.ackfailure, | ||
820 | adapter->logmsg.rxfrag, | ||
821 | adapter->logmsg.mcastrxframe, | ||
822 | adapter->logmsg.fcserror, | ||
823 | adapter->logmsg.txframe, | ||
824 | adapter->logmsg.wepundecryptable); | ||
825 | wrq->u.data.length = strlen(buf) + 1; | ||
826 | if (copy_to_user(wrq->u.data.pointer, buf, wrq->u.data.length)) { | ||
827 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
828 | return -EFAULT; | ||
829 | } | ||
830 | } | ||
831 | |||
832 | return 0; | ||
833 | } | ||
834 | |||
835 | static int wlan_scan_type_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
836 | { | ||
837 | u8 buf[12]; | ||
838 | u8 *option[] = { "active", "passive", "get", }; | ||
839 | int i, max_options = (sizeof(option) / sizeof(option[0])); | ||
840 | int ret = 0; | ||
841 | wlan_adapter *adapter = priv->adapter; | ||
842 | |||
843 | if (priv->adapter->enable11d) { | ||
844 | lbs_pr_debug(1, "11D: Cannot set scantype when 11D enabled\n"); | ||
845 | return -EFAULT; | ||
846 | } | ||
847 | |||
848 | memset(buf, 0, sizeof(buf)); | ||
849 | |||
850 | if (copy_from_user(buf, wrq->u.data.pointer, min_t(size_t, sizeof(buf), | ||
851 | wrq->u.data.length))) | ||
852 | return -EFAULT; | ||
853 | |||
854 | lbs_pr_debug(1, "Scan type Option = %s\n", buf); | ||
855 | |||
856 | buf[sizeof(buf) - 1] = '\0'; | ||
857 | |||
858 | for (i = 0; i < max_options; i++) { | ||
859 | if (!strcmp(buf, option[i])) | ||
860 | break; | ||
861 | } | ||
862 | |||
863 | switch (i) { | ||
864 | case 0: | ||
865 | adapter->scantype = cmd_scan_type_active; | ||
866 | break; | ||
867 | case 1: | ||
868 | adapter->scantype = cmd_scan_type_passive; | ||
869 | break; | ||
870 | case 2: | ||
871 | wrq->u.data.length = strlen(option[adapter->scantype]) + 1; | ||
872 | |||
873 | if (copy_to_user(wrq->u.data.pointer, | ||
874 | option[adapter->scantype], | ||
875 | wrq->u.data.length)) { | ||
876 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
877 | ret = -EFAULT; | ||
878 | } | ||
879 | |||
880 | break; | ||
881 | default: | ||
882 | lbs_pr_debug(1, "Invalid Scan type Ioctl Option\n"); | ||
883 | ret = -EINVAL; | ||
884 | break; | ||
885 | } | ||
886 | |||
887 | return ret; | ||
888 | } | ||
889 | |||
890 | static int wlan_scan_mode_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
891 | { | ||
892 | wlan_adapter *adapter = priv->adapter; | ||
893 | u8 buf[12]; | ||
894 | u8 *option[] = { "bss", "ibss", "any", "get" }; | ||
895 | int i, max_options = (sizeof(option) / sizeof(option[0])); | ||
896 | int ret = 0; | ||
897 | |||
898 | ENTER(); | ||
899 | |||
900 | memset(buf, 0, sizeof(buf)); | ||
901 | |||
902 | if (copy_from_user(buf, wrq->u.data.pointer, min_t(size_t, sizeof(buf), | ||
903 | wrq->u.data.length))) { | ||
904 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
905 | return -EFAULT; | ||
906 | } | ||
907 | |||
908 | lbs_pr_debug(1, "Scan mode Option = %s\n", buf); | ||
909 | |||
910 | buf[sizeof(buf) - 1] = '\0'; | ||
911 | |||
912 | for (i = 0; i < max_options; i++) { | ||
913 | if (!strcmp(buf, option[i])) | ||
914 | break; | ||
915 | } | ||
916 | |||
917 | switch (i) { | ||
918 | |||
919 | case 0: | ||
920 | adapter->scanmode = cmd_bss_type_bss; | ||
921 | break; | ||
922 | case 1: | ||
923 | adapter->scanmode = cmd_bss_type_ibss; | ||
924 | break; | ||
925 | case 2: | ||
926 | adapter->scanmode = cmd_bss_type_any; | ||
927 | break; | ||
928 | case 3: | ||
929 | |||
930 | wrq->u.data.length = strlen(option[adapter->scanmode - 1]) + 1; | ||
931 | |||
932 | lbs_pr_debug(1, "Get Scan mode Option = %s\n", | ||
933 | option[adapter->scanmode - 1]); | ||
934 | |||
935 | lbs_pr_debug(1, "Scan mode length %d\n", wrq->u.data.length); | ||
936 | |||
937 | if (copy_to_user(wrq->u.data.pointer, | ||
938 | option[adapter->scanmode - 1], | ||
939 | wrq->u.data.length)) { | ||
940 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
941 | ret = -EFAULT; | ||
942 | } | ||
943 | lbs_pr_debug(1, "GET Scan type Option after copy = %s\n", | ||
944 | (char *)wrq->u.data.pointer); | ||
945 | |||
946 | break; | ||
947 | |||
948 | default: | ||
949 | lbs_pr_debug(1, "Invalid Scan mode Ioctl Option\n"); | ||
950 | ret = -EINVAL; | ||
951 | break; | ||
952 | } | ||
953 | |||
954 | LEAVE(); | ||
955 | return ret; | ||
956 | } | ||
957 | |||
958 | /** | ||
959 | * @brief Get/Set Adhoc G Rate | ||
960 | * | ||
961 | * @param priv A pointer to wlan_private structure | ||
962 | * @param wrq A pointer to user data | ||
963 | * @return 0--success, otherwise fail | ||
964 | */ | ||
965 | static int wlan_do_set_grate_ioctl(wlan_private * priv, struct iwreq *wrq) | ||
966 | { | ||
967 | wlan_adapter *adapter = priv->adapter; | ||
968 | int data, data1; | ||
969 | int *val; | ||
970 | |||
971 | ENTER(); | ||
972 | |||
973 | data1 = SUBCMD_DATA(wrq); | ||
974 | switch (data1) { | ||
975 | case 0: | ||
976 | adapter->adhoc_grate_enabled = 0; | ||
977 | break; | ||
978 | case 1: | ||
979 | adapter->adhoc_grate_enabled = 1; | ||
980 | break; | ||
981 | case 2: | ||
982 | break; | ||
983 | default: | ||
984 | return -EINVAL; | ||
985 | } | ||
986 | data = adapter->adhoc_grate_enabled; | ||
987 | val = (int *)wrq->u.name; | ||
988 | *val = data; | ||
989 | LEAVE(); | ||
990 | return 0; | ||
991 | } | ||
992 | |||
993 | static inline int hex2int(char c) | 58 | static inline int hex2int(char c) |
994 | { | 59 | { |
995 | if (c >= '0' && c <= '9') | 60 | if (c >= '0' && c <= '9') |
@@ -1752,36 +817,8 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
1752 | 817 | ||
1753 | lbs_pr_debug(1, "libertas_do_ioctl: ioctl cmd = 0x%x\n", cmd); | 818 | lbs_pr_debug(1, "libertas_do_ioctl: ioctl cmd = 0x%x\n", cmd); |
1754 | switch (cmd) { | 819 | switch (cmd) { |
1755 | case WLANSCAN_TYPE: | ||
1756 | lbs_pr_debug(1, "Scan type Ioctl\n"); | ||
1757 | ret = wlan_scan_type_ioctl(priv, wrq); | ||
1758 | break; | ||
1759 | |||
1760 | case WLAN_SETNONE_GETNONE: /* set WPA mode on/off ioctl #20 */ | 820 | case WLAN_SETNONE_GETNONE: /* set WPA mode on/off ioctl #20 */ |
1761 | switch (wrq->u.data.flags) { | 821 | switch (wrq->u.data.flags) { |
1762 | case WLANDEAUTH: | ||
1763 | lbs_pr_debug(1, "Deauth\n"); | ||
1764 | libertas_send_deauth(priv); | ||
1765 | break; | ||
1766 | |||
1767 | case WLANADHOCSTOP: | ||
1768 | lbs_pr_debug(1, "Adhoc stop\n"); | ||
1769 | ret = libertas_do_adhocstop_ioctl(priv); | ||
1770 | break; | ||
1771 | |||
1772 | case WLANRADIOON: | ||
1773 | wlan_radio_ioctl(priv, 1); | ||
1774 | break; | ||
1775 | |||
1776 | case WLANRADIOOFF: | ||
1777 | wlan_radio_ioctl(priv, 0); | ||
1778 | break; | ||
1779 | case WLANWLANIDLEON: | ||
1780 | libertas_idle_on(priv); | ||
1781 | break; | ||
1782 | case WLANWLANIDLEOFF: | ||
1783 | libertas_idle_off(priv); | ||
1784 | break; | ||
1785 | case WLAN_SUBCMD_BT_RESET: /* bt_reset */ | 822 | case WLAN_SUBCMD_BT_RESET: /* bt_reset */ |
1786 | wlan_bt_reset_ioctl(priv); | 823 | wlan_bt_reset_ioctl(priv); |
1787 | break; | 824 | break; |
@@ -1791,81 +828,6 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
1791 | } /* End of switch */ | 828 | } /* End of switch */ |
1792 | break; | 829 | break; |
1793 | 830 | ||
1794 | case WLAN_SETINT_GETINT: | ||
1795 | /* The first 4 bytes of req->ifr_data is sub-ioctl number | ||
1796 | * after 4 bytes sits the payload. | ||
1797 | */ | ||
1798 | subcmd = (int)req->ifr_data; //from iwpriv subcmd | ||
1799 | switch (subcmd) { | ||
1800 | case WLANNF: | ||
1801 | ret = wlan_get_nf(priv, wrq); | ||
1802 | break; | ||
1803 | case WLANRSSI: | ||
1804 | ret = wlan_get_rssi(priv, wrq); | ||
1805 | break; | ||
1806 | case WLANENABLE11D: | ||
1807 | ret = libertas_cmd_enable_11d(priv, wrq); | ||
1808 | break; | ||
1809 | case WLANADHOCGRATE: | ||
1810 | ret = wlan_do_set_grate_ioctl(priv, wrq); | ||
1811 | break; | ||
1812 | case WLAN_SUBCMD_SET_PRESCAN: | ||
1813 | ret = wlan_subcmd_setprescan_ioctl(priv, wrq); | ||
1814 | break; | ||
1815 | } | ||
1816 | break; | ||
1817 | |||
1818 | case WLAN_SETONEINT_GETONEINT: | ||
1819 | switch (wrq->u.data.flags) { | ||
1820 | case WLAN_BEACON_INTERVAL: | ||
1821 | ret = wlan_beacon_interval(priv, wrq); | ||
1822 | break; | ||
1823 | |||
1824 | case WLAN_LISTENINTRVL: | ||
1825 | if (!wrq->u.data.length) { | ||
1826 | int data; | ||
1827 | lbs_pr_debug(1, "Get locallisteninterval value\n"); | ||
1828 | #define GET_ONE_INT 1 | ||
1829 | data = adapter->locallisteninterval; | ||
1830 | if (copy_to_user(wrq->u.data.pointer, | ||
1831 | &data, sizeof(int))) { | ||
1832 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
1833 | return -EFAULT; | ||
1834 | } | ||
1835 | |||
1836 | wrq->u.data.length = GET_ONE_INT; | ||
1837 | } else { | ||
1838 | int data; | ||
1839 | if (copy_from_user | ||
1840 | (&data, wrq->u.data.pointer, sizeof(int))) { | ||
1841 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
1842 | return -EFAULT; | ||
1843 | } | ||
1844 | |||
1845 | lbs_pr_debug(1, "Set locallisteninterval = %d\n", | ||
1846 | data); | ||
1847 | #define MAX_U16_VAL 65535 | ||
1848 | if (data > MAX_U16_VAL) { | ||
1849 | lbs_pr_debug(1, "Exceeds U16 value\n"); | ||
1850 | return -EINVAL; | ||
1851 | } | ||
1852 | adapter->locallisteninterval = data; | ||
1853 | } | ||
1854 | break; | ||
1855 | case WLAN_TXCONTROL: | ||
1856 | ret = wlan_txcontrol(priv, wrq); //adds for txcontrol ioctl | ||
1857 | break; | ||
1858 | |||
1859 | case WLAN_NULLPKTINTERVAL: | ||
1860 | ret = wlan_null_pkt_interval(priv, wrq); | ||
1861 | break; | ||
1862 | |||
1863 | default: | ||
1864 | ret = -EOPNOTSUPP; | ||
1865 | break; | ||
1866 | } | ||
1867 | break; | ||
1868 | |||
1869 | case WLAN_SETONEINT_GETNONE: | 831 | case WLAN_SETONEINT_GETNONE: |
1870 | /* The first 4 bytes of req->ifr_data is sub-ioctl number | 832 | /* The first 4 bytes of req->ifr_data is sub-ioctl number |
1871 | * after 4 bytes sits the payload. | 833 | * after 4 bytes sits the payload. |
@@ -1876,62 +838,10 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
1876 | subcmd = (int)req->ifr_data; //from iwpriv subcmd | 838 | subcmd = (int)req->ifr_data; //from iwpriv subcmd |
1877 | 839 | ||
1878 | switch (subcmd) { | 840 | switch (subcmd) { |
1879 | case WLAN_SUBCMD_SETRXANTENNA: /* SETRXANTENNA */ | ||
1880 | idata = SUBCMD_DATA(wrq); | ||
1881 | ret = setrxantenna(priv, idata); | ||
1882 | break; | ||
1883 | case WLAN_SUBCMD_SETTXANTENNA: /* SETTXANTENNA */ | ||
1884 | idata = SUBCMD_DATA(wrq); | ||
1885 | ret = settxantenna(priv, idata); | ||
1886 | break; | ||
1887 | case WLAN_SET_ATIM_WINDOW: | ||
1888 | adapter->atimwindow = SUBCMD_DATA(wrq); | ||
1889 | adapter->atimwindow = min_t(__u16, adapter->atimwindow, 50); | ||
1890 | break; | ||
1891 | case WLANSETBCNAVG: | ||
1892 | adapter->bcn_avg_factor = SUBCMD_DATA(wrq); | ||
1893 | if (adapter->bcn_avg_factor == 0) | ||
1894 | adapter->bcn_avg_factor = | ||
1895 | DEFAULT_BCN_AVG_FACTOR; | ||
1896 | if (adapter->bcn_avg_factor > DEFAULT_BCN_AVG_FACTOR) | ||
1897 | adapter->bcn_avg_factor = | ||
1898 | DEFAULT_BCN_AVG_FACTOR; | ||
1899 | break; | ||
1900 | case WLANSETDATAAVG: | ||
1901 | adapter->data_avg_factor = SUBCMD_DATA(wrq); | ||
1902 | if (adapter->data_avg_factor == 0) | ||
1903 | adapter->data_avg_factor = | ||
1904 | DEFAULT_DATA_AVG_FACTOR; | ||
1905 | if (adapter->data_avg_factor > DEFAULT_DATA_AVG_FACTOR) | ||
1906 | adapter->data_avg_factor = | ||
1907 | DEFAULT_DATA_AVG_FACTOR; | ||
1908 | break; | ||
1909 | case WLANSETREGION: | 841 | case WLANSETREGION: |
1910 | idata = SUBCMD_DATA(wrq); | 842 | idata = SUBCMD_DATA(wrq); |
1911 | ret = wlan_set_region(priv, (u16) idata); | 843 | ret = wlan_set_region(priv, (u16) idata); |
1912 | break; | 844 | break; |
1913 | |||
1914 | case WLAN_SET_LISTEN_INTERVAL: | ||
1915 | idata = SUBCMD_DATA(wrq); | ||
1916 | adapter->listeninterval = (u16) idata; | ||
1917 | break; | ||
1918 | |||
1919 | case WLAN_SET_MULTIPLE_DTIM: | ||
1920 | ret = wlan_set_multiple_dtim_ioctl(priv, req); | ||
1921 | break; | ||
1922 | |||
1923 | case WLAN_SET_LINKMODE: | ||
1924 | ret = wlan_set_linkmode_ioctl(priv, req); | ||
1925 | break; | ||
1926 | |||
1927 | case WLAN_SET_RADIOMODE: | ||
1928 | ret = wlan_set_radiomode_ioctl(priv, req); | ||
1929 | break; | ||
1930 | |||
1931 | case WLAN_SET_DEBUGMODE: | ||
1932 | ret = wlan_set_debugmode_ioctl(priv, req); | ||
1933 | break; | ||
1934 | |||
1935 | case WLAN_SUBCMD_MESH_SET_TTL: | 845 | case WLAN_SUBCMD_MESH_SET_TTL: |
1936 | idata = SUBCMD_DATA(wrq); | 846 | idata = SUBCMD_DATA(wrq); |
1937 | ret = wlan_mesh_set_ttl_ioctl(priv, idata); | 847 | ret = wlan_mesh_set_ttl_ioctl(priv, idata); |
@@ -1944,38 +854,8 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
1944 | 854 | ||
1945 | break; | 855 | break; |
1946 | 856 | ||
1947 | case WLAN_SETNONE_GETTWELVE_CHAR: /* Get Antenna settings */ | ||
1948 | /* | ||
1949 | * We've not used IW_PRIV_TYPE_FIXED so sub-ioctl number is | ||
1950 | * in flags of iwreq structure, otherwise it will be in | ||
1951 | * mode member of iwreq structure. | ||
1952 | */ | ||
1953 | switch ((int)wrq->u.data.flags) { | ||
1954 | case WLAN_SUBCMD_GETRXANTENNA: /* Get Rx Antenna */ | ||
1955 | ret = wlan_subcmd_getrxantenna_ioctl(priv, req); | ||
1956 | break; | ||
1957 | |||
1958 | case WLAN_SUBCMD_GETTXANTENNA: /* Get Tx Antenna */ | ||
1959 | ret = wlan_subcmd_gettxantenna_ioctl(priv, req); | ||
1960 | break; | ||
1961 | |||
1962 | case WLAN_GET_TSF: | ||
1963 | ret = wlan_get_tsf_ioctl(priv, wrq); | ||
1964 | break; | ||
1965 | } | ||
1966 | break; | ||
1967 | |||
1968 | case WLAN_SET128CHAR_GET128CHAR: | 857 | case WLAN_SET128CHAR_GET128CHAR: |
1969 | switch ((int)wrq->u.data.flags) { | 858 | switch ((int)wrq->u.data.flags) { |
1970 | |||
1971 | case WLANSCAN_MODE: | ||
1972 | lbs_pr_debug(1, "Scan mode Ioctl\n"); | ||
1973 | ret = wlan_scan_mode_ioctl(priv, wrq); | ||
1974 | break; | ||
1975 | |||
1976 | case WLAN_GET_ADHOC_STATUS: | ||
1977 | ret = wlan_get_adhoc_status_ioctl(priv, wrq); | ||
1978 | break; | ||
1979 | case WLAN_SUBCMD_BT_ADD: | 859 | case WLAN_SUBCMD_BT_ADD: |
1980 | ret = wlan_bt_add_ioctl(priv, req); | 860 | ret = wlan_bt_add_ioctl(priv, req); |
1981 | break; | 861 | break; |
@@ -2008,40 +888,10 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
2008 | 888 | ||
2009 | case WLAN_SETNONE_GETONEINT: | 889 | case WLAN_SETNONE_GETONEINT: |
2010 | switch ((int)req->ifr_data) { | 890 | switch ((int)req->ifr_data) { |
2011 | case WLANGETBCNAVG: | ||
2012 | pdata = (int *)wrq->u.name; | ||
2013 | *pdata = (int)adapter->bcn_avg_factor; | ||
2014 | break; | ||
2015 | |||
2016 | case WLANGETREGION: | 891 | case WLANGETREGION: |
2017 | pdata = (int *)wrq->u.name; | 892 | pdata = (int *)wrq->u.name; |
2018 | *pdata = (int)adapter->regioncode; | 893 | *pdata = (int)adapter->regioncode; |
2019 | break; | 894 | break; |
2020 | |||
2021 | case WLAN_GET_LISTEN_INTERVAL: | ||
2022 | pdata = (int *)wrq->u.name; | ||
2023 | *pdata = (int)adapter->listeninterval; | ||
2024 | break; | ||
2025 | |||
2026 | case WLAN_GET_LINKMODE: | ||
2027 | req->ifr_data = (char *)((u32) adapter->linkmode); | ||
2028 | break; | ||
2029 | |||
2030 | case WLAN_GET_RADIOMODE: | ||
2031 | req->ifr_data = (char *)((u32) adapter->radiomode); | ||
2032 | break; | ||
2033 | |||
2034 | case WLAN_GET_DEBUGMODE: | ||
2035 | req->ifr_data = (char *)((u32) adapter->debugmode); | ||
2036 | break; | ||
2037 | |||
2038 | case WLAN_GET_MULTIPLE_DTIM: | ||
2039 | pdata = (int *)wrq->u.name; | ||
2040 | *pdata = (int)adapter->multipledtim; | ||
2041 | break; | ||
2042 | case WLAN_GET_TX_RATE: | ||
2043 | ret = wlan_get_txrate_ioctl(priv, req); | ||
2044 | break; | ||
2045 | case WLAN_SUBCMD_FWT_CLEANUP: /* fwt_cleanup */ | 895 | case WLAN_SUBCMD_FWT_CLEANUP: /* fwt_cleanup */ |
2046 | ret = wlan_fwt_cleanup_ioctl(priv, req); | 896 | ret = wlan_fwt_cleanup_ioctl(priv, req); |
2047 | break; | 897 | break; |
@@ -2061,196 +911,8 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
2061 | 911 | ||
2062 | break; | 912 | break; |
2063 | 913 | ||
2064 | case WLANGETLOG: | ||
2065 | ret = wlan_do_getlog_ioctl(priv, wrq); | ||
2066 | break; | ||
2067 | |||
2068 | case WLAN_SET_GET_SIXTEEN_INT: | 914 | case WLAN_SET_GET_SIXTEEN_INT: |
2069 | switch ((int)wrq->u.data.flags) { | 915 | switch ((int)wrq->u.data.flags) { |
2070 | case WLAN_TPCCFG: | ||
2071 | { | ||
2072 | int data[5]; | ||
2073 | struct cmd_ds_802_11_tpc_cfg cfg; | ||
2074 | memset(&cfg, 0, sizeof(cfg)); | ||
2075 | if ((wrq->u.data.length > 1) | ||
2076 | && (wrq->u.data.length != 5)) | ||
2077 | return -1; | ||
2078 | |||
2079 | if (wrq->u.data.length == 0) { | ||
2080 | cfg.action = | ||
2081 | cpu_to_le16 | ||
2082 | (cmd_act_get); | ||
2083 | } else { | ||
2084 | if (copy_from_user | ||
2085 | (data, wrq->u.data.pointer, | ||
2086 | sizeof(int) * 5)) { | ||
2087 | lbs_pr_debug(1, | ||
2088 | "Copy from user failed\n"); | ||
2089 | return -EFAULT; | ||
2090 | } | ||
2091 | |||
2092 | cfg.action = | ||
2093 | cpu_to_le16 | ||
2094 | (cmd_act_set); | ||
2095 | cfg.enable = data[0]; | ||
2096 | cfg.usesnr = data[1]; | ||
2097 | cfg.P0 = data[2]; | ||
2098 | cfg.P1 = data[3]; | ||
2099 | cfg.P2 = data[4]; | ||
2100 | } | ||
2101 | |||
2102 | ret = | ||
2103 | libertas_prepare_and_send_command(priv, | ||
2104 | cmd_802_11_tpc_cfg, | ||
2105 | 0, | ||
2106 | cmd_option_waitforrsp, | ||
2107 | 0, (void *)&cfg); | ||
2108 | |||
2109 | data[0] = cfg.enable; | ||
2110 | data[1] = cfg.usesnr; | ||
2111 | data[2] = cfg.P0; | ||
2112 | data[3] = cfg.P1; | ||
2113 | data[4] = cfg.P2; | ||
2114 | if (copy_to_user | ||
2115 | (wrq->u.data.pointer, data, | ||
2116 | sizeof(int) * 5)) { | ||
2117 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
2118 | return -EFAULT; | ||
2119 | } | ||
2120 | |||
2121 | wrq->u.data.length = 5; | ||
2122 | } | ||
2123 | break; | ||
2124 | |||
2125 | case WLAN_POWERCFG: | ||
2126 | { | ||
2127 | int data[4]; | ||
2128 | struct cmd_ds_802_11_pwr_cfg cfg; | ||
2129 | memset(&cfg, 0, sizeof(cfg)); | ||
2130 | if ((wrq->u.data.length > 1) | ||
2131 | && (wrq->u.data.length != 4)) | ||
2132 | return -1; | ||
2133 | if (wrq->u.data.length == 0) { | ||
2134 | cfg.action = | ||
2135 | cpu_to_le16 | ||
2136 | (cmd_act_get); | ||
2137 | } else { | ||
2138 | if (copy_from_user | ||
2139 | (data, wrq->u.data.pointer, | ||
2140 | sizeof(int) * 4)) { | ||
2141 | lbs_pr_debug(1, | ||
2142 | "Copy from user failed\n"); | ||
2143 | return -EFAULT; | ||
2144 | } | ||
2145 | |||
2146 | cfg.action = | ||
2147 | cpu_to_le16 | ||
2148 | (cmd_act_set); | ||
2149 | cfg.enable = data[0]; | ||
2150 | cfg.PA_P0 = data[1]; | ||
2151 | cfg.PA_P1 = data[2]; | ||
2152 | cfg.PA_P2 = data[3]; | ||
2153 | } | ||
2154 | ret = | ||
2155 | libertas_prepare_and_send_command(priv, | ||
2156 | cmd_802_11_pwr_cfg, | ||
2157 | 0, | ||
2158 | cmd_option_waitforrsp, | ||
2159 | 0, (void *)&cfg); | ||
2160 | data[0] = cfg.enable; | ||
2161 | data[1] = cfg.PA_P0; | ||
2162 | data[2] = cfg.PA_P1; | ||
2163 | data[3] = cfg.PA_P2; | ||
2164 | if (copy_to_user | ||
2165 | (wrq->u.data.pointer, data, | ||
2166 | sizeof(int) * 4)) { | ||
2167 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
2168 | return -EFAULT; | ||
2169 | } | ||
2170 | |||
2171 | wrq->u.data.length = 4; | ||
2172 | } | ||
2173 | break; | ||
2174 | case WLAN_AUTO_FREQ_SET: | ||
2175 | { | ||
2176 | int data[3]; | ||
2177 | struct cmd_ds_802_11_afc afc; | ||
2178 | memset(&afc, 0, sizeof(afc)); | ||
2179 | if (wrq->u.data.length != 3) | ||
2180 | return -1; | ||
2181 | if (copy_from_user | ||
2182 | (data, wrq->u.data.pointer, | ||
2183 | sizeof(int) * 3)) { | ||
2184 | lbs_pr_debug(1, "Copy from user failed\n"); | ||
2185 | return -EFAULT; | ||
2186 | } | ||
2187 | afc.afc_auto = data[0]; | ||
2188 | |||
2189 | if (afc.afc_auto != 0) { | ||
2190 | afc.threshold = data[1]; | ||
2191 | afc.period = data[2]; | ||
2192 | } else { | ||
2193 | afc.timing_offset = data[1]; | ||
2194 | afc.carrier_offset = data[2]; | ||
2195 | } | ||
2196 | ret = | ||
2197 | libertas_prepare_and_send_command(priv, | ||
2198 | cmd_802_11_set_afc, | ||
2199 | 0, | ||
2200 | cmd_option_waitforrsp, | ||
2201 | 0, (void *)&afc); | ||
2202 | } | ||
2203 | break; | ||
2204 | case WLAN_AUTO_FREQ_GET: | ||
2205 | { | ||
2206 | int data[3]; | ||
2207 | struct cmd_ds_802_11_afc afc; | ||
2208 | memset(&afc, 0, sizeof(afc)); | ||
2209 | ret = | ||
2210 | libertas_prepare_and_send_command(priv, | ||
2211 | cmd_802_11_get_afc, | ||
2212 | 0, | ||
2213 | cmd_option_waitforrsp, | ||
2214 | 0, (void *)&afc); | ||
2215 | data[0] = afc.afc_auto; | ||
2216 | data[1] = afc.timing_offset; | ||
2217 | data[2] = afc.carrier_offset; | ||
2218 | if (copy_to_user | ||
2219 | (wrq->u.data.pointer, data, | ||
2220 | sizeof(int) * 3)) { | ||
2221 | lbs_pr_debug(1, "Copy to user failed\n"); | ||
2222 | return -EFAULT; | ||
2223 | } | ||
2224 | |||
2225 | wrq->u.data.length = 3; | ||
2226 | } | ||
2227 | break; | ||
2228 | case WLAN_SCANPROBES: | ||
2229 | { | ||
2230 | int data; | ||
2231 | if (wrq->u.data.length > 0) { | ||
2232 | if (copy_from_user | ||
2233 | (&data, wrq->u.data.pointer, | ||
2234 | sizeof(int))) { | ||
2235 | lbs_pr_debug(1, | ||
2236 | "Copy from user failed\n"); | ||
2237 | return -EFAULT; | ||
2238 | } | ||
2239 | |||
2240 | adapter->scanprobes = data; | ||
2241 | } else { | ||
2242 | data = adapter->scanprobes; | ||
2243 | if (copy_to_user | ||
2244 | (wrq->u.data.pointer, &data, | ||
2245 | sizeof(int))) { | ||
2246 | lbs_pr_debug(1, | ||
2247 | "Copy to user failed\n"); | ||
2248 | return -EFAULT; | ||
2249 | } | ||
2250 | } | ||
2251 | wrq->u.data.length = 1; | ||
2252 | } | ||
2253 | break; | ||
2254 | case WLAN_LED_GPIO_CTRL: | 916 | case WLAN_LED_GPIO_CTRL: |
2255 | { | 917 | { |
2256 | int i; | 918 | int i; |
@@ -2314,17 +976,6 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
2314 | wrq->u.data.length = gpio->header.len; | 976 | wrq->u.data.length = gpio->header.len; |
2315 | } | 977 | } |
2316 | break; | 978 | break; |
2317 | case WLAN_ADAPT_RATESET: | ||
2318 | ret = wlan_adapt_rateset(priv, wrq); | ||
2319 | break; | ||
2320 | case WLAN_INACTIVITY_TIMEOUT: | ||
2321 | ret = wlan_inactivity_timeout(priv, wrq); | ||
2322 | break; | ||
2323 | case WLANSNR: | ||
2324 | ret = wlan_get_snr(priv, wrq); | ||
2325 | break; | ||
2326 | case WLAN_GET_RXINFO: | ||
2327 | ret = wlan_get_rxinfo(priv, wrq); | ||
2328 | } | 979 | } |
2329 | break; | 980 | break; |
2330 | 981 | ||