blob: fe275c7ed32d7aca54057f8c435e14f02523df38 [file] [log] [blame]
Vipin Mehta30295c82010-09-01 12:06:33 -07001//------------------------------------------------------------------------------
2// Copyright (c) 2004-2010 Atheros Communications Inc.
3// All rights reserved.
4//
5//
6//
7// Permission to use, copy, modify, and/or distribute this software for any
8// purpose with or without fee is hereby granted, provided that the above
9// copyright notice and this permission notice appear in all copies.
10//
11// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18//
19//
20//
21// Author(s): ="Atheros"
22//------------------------------------------------------------------------------
23
24#include "ar6000_drv.h"
25#include "ieee80211_ioctl.h"
26#include "ar6kap_common.h"
27#include "targaddrs.h"
28#include "a_hci.h"
29#include "wlan_config.h"
30
31extern int enablerssicompensation;
Joe Perchese1ce2a32011-02-02 14:05:51 -080032u32 tcmdRxFreq;
Vipin Mehta30295c82010-09-01 12:06:33 -070033extern unsigned int wmitimeout;
34extern A_WAITQUEUE_HEAD arEvent;
35extern int tspecCompliance;
36extern int bmienable;
Vipin Mehta30295c82010-09-01 12:06:33 -070037extern int loghci;
38
39static int
40ar6000_ioctl_get_roam_tbl(struct net_device *dev, struct ifreq *rq)
41{
42 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
43
Joe Perches1071a132011-02-02 14:05:47 -080044 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -070045 return -EIO;
46 }
47
Joe Perches4f69cef2011-02-02 14:05:57 -080048 if(wmi_get_roam_tbl_cmd(ar->arWmi) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -070049 return -EIO;
50 }
51
52 return 0;
53}
54
55static int
56ar6000_ioctl_get_roam_data(struct net_device *dev, struct ifreq *rq)
57{
58 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
59
Joe Perches1071a132011-02-02 14:05:47 -080060 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -070061 return -EIO;
62 }
63
64
65 /* currently assume only roam times are required */
Joe Perches4f69cef2011-02-02 14:05:57 -080066 if(wmi_get_roam_data_cmd(ar->arWmi, ROAM_DATA_TIME) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -070067 return -EIO;
68 }
69
70
71 return 0;
72}
73
74static int
75ar6000_ioctl_set_roam_ctrl(struct net_device *dev, char *userdata)
76{
77 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
78 WMI_SET_ROAM_CTRL_CMD cmd;
Joe Perchesab3655d2011-02-02 14:05:49 -080079 u8 size = sizeof(cmd);
Vipin Mehta30295c82010-09-01 12:06:33 -070080
Joe Perches1071a132011-02-02 14:05:47 -080081 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -070082 return -EIO;
83 }
84
85
86 if (copy_from_user(&cmd, userdata, size)) {
87 return -EFAULT;
88 }
89
90 if (cmd.roamCtrlType == WMI_SET_HOST_BIAS) {
91 if (cmd.info.bssBiasInfo.numBss > 1) {
92 size += (cmd.info.bssBiasInfo.numBss - 1) * sizeof(WMI_BSS_BIAS);
93 }
94 }
95
96 if (copy_from_user(&cmd, userdata, size)) {
97 return -EFAULT;
98 }
99
Joe Perches4f69cef2011-02-02 14:05:57 -0800100 if(wmi_set_roam_ctrl_cmd(ar->arWmi, &cmd, size) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700101 return -EIO;
102 }
103
104 return 0;
105}
106
107static int
108ar6000_ioctl_set_powersave_timers(struct net_device *dev, char *userdata)
109{
110 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
111 WMI_POWERSAVE_TIMERS_POLICY_CMD cmd;
Joe Perchesab3655d2011-02-02 14:05:49 -0800112 u8 size = sizeof(cmd);
Vipin Mehta30295c82010-09-01 12:06:33 -0700113
Joe Perches1071a132011-02-02 14:05:47 -0800114 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700115 return -EIO;
116 }
117
118 if (copy_from_user(&cmd, userdata, size)) {
119 return -EFAULT;
120 }
121
122 if (copy_from_user(&cmd, userdata, size)) {
123 return -EFAULT;
124 }
125
Joe Perches4f69cef2011-02-02 14:05:57 -0800126 if(wmi_set_powersave_timers_cmd(ar->arWmi, &cmd, size) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700127 return -EIO;
128 }
129
130 return 0;
131}
132
133static int
134ar6000_ioctl_set_qos_supp(struct net_device *dev, struct ifreq *rq)
135{
136 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
137 WMI_SET_QOS_SUPP_CMD cmd;
Joe Perches1f4c34b2011-01-27 20:04:19 -0800138 int ret;
Vipin Mehta30295c82010-09-01 12:06:33 -0700139
140 if ((dev->flags & IFF_UP) != IFF_UP) {
141 return -EIO;
142 }
Joe Perches1071a132011-02-02 14:05:47 -0800143 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700144 return -EIO;
145 }
146
147 if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
148 sizeof(cmd)))
149 {
150 return -EFAULT;
151 }
152
153 ret = wmi_set_qos_supp_cmd(ar->arWmi, cmd.status);
154
155 switch (ret) {
Joe Perches4f69cef2011-02-02 14:05:57 -0800156 case 0:
Vipin Mehta30295c82010-09-01 12:06:33 -0700157 return 0;
158 case A_EBUSY :
159 return -EBUSY;
160 case A_NO_MEMORY:
161 return -ENOMEM;
162 case A_EINVAL:
163 default:
164 return -EFAULT;
165 }
166}
167
168static int
169ar6000_ioctl_set_wmm(struct net_device *dev, struct ifreq *rq)
170{
171 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
172 WMI_SET_WMM_CMD cmd;
Joe Perches1f4c34b2011-01-27 20:04:19 -0800173 int ret;
Vipin Mehta30295c82010-09-01 12:06:33 -0700174
175 if ((dev->flags & IFF_UP) != IFF_UP) {
176 return -EIO;
177 }
Joe Perches1071a132011-02-02 14:05:47 -0800178 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700179 return -EIO;
180 }
181
182 if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
183 sizeof(cmd)))
184 {
185 return -EFAULT;
186 }
187
188 if (cmd.status == WMI_WMM_ENABLED) {
Joe Perches1071a132011-02-02 14:05:47 -0800189 ar->arWmmEnabled = true;
Vipin Mehta30295c82010-09-01 12:06:33 -0700190 } else {
Joe Perches1071a132011-02-02 14:05:47 -0800191 ar->arWmmEnabled = false;
Vipin Mehta30295c82010-09-01 12:06:33 -0700192 }
193
194 ret = wmi_set_wmm_cmd(ar->arWmi, cmd.status);
195
196 switch (ret) {
Joe Perches4f69cef2011-02-02 14:05:57 -0800197 case 0:
Vipin Mehta30295c82010-09-01 12:06:33 -0700198 return 0;
199 case A_EBUSY :
200 return -EBUSY;
201 case A_NO_MEMORY:
202 return -ENOMEM;
203 case A_EINVAL:
204 default:
205 return -EFAULT;
206 }
207}
208
209static int
210ar6000_ioctl_set_txop(struct net_device *dev, struct ifreq *rq)
211{
212 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
213 WMI_SET_WMM_TXOP_CMD cmd;
Joe Perches1f4c34b2011-01-27 20:04:19 -0800214 int ret;
Vipin Mehta30295c82010-09-01 12:06:33 -0700215
216 if ((dev->flags & IFF_UP) != IFF_UP) {
217 return -EIO;
218 }
Joe Perches1071a132011-02-02 14:05:47 -0800219 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700220 return -EIO;
221 }
222
223 if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
224 sizeof(cmd)))
225 {
226 return -EFAULT;
227 }
228
229 ret = wmi_set_wmm_txop(ar->arWmi, cmd.txopEnable);
230
231 switch (ret) {
Joe Perches4f69cef2011-02-02 14:05:57 -0800232 case 0:
Vipin Mehta30295c82010-09-01 12:06:33 -0700233 return 0;
234 case A_EBUSY :
235 return -EBUSY;
236 case A_NO_MEMORY:
237 return -ENOMEM;
238 case A_EINVAL:
239 default:
240 return -EFAULT;
241 }
242}
243
244static int
245ar6000_ioctl_get_rd(struct net_device *dev, struct ifreq *rq)
246{
247 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
Joe Perches1f4c34b2011-01-27 20:04:19 -0800248 int ret = 0;
Vipin Mehta30295c82010-09-01 12:06:33 -0700249
Joe Perches1071a132011-02-02 14:05:47 -0800250 if ((dev->flags & IFF_UP) != IFF_UP || ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700251 return -EIO;
252 }
253
254 if(copy_to_user((char *)((unsigned int*)rq->ifr_data + 1),
255 &ar->arRegCode, sizeof(ar->arRegCode)))
256 ret = -EFAULT;
257
258 return ret;
259}
260
261static int
262ar6000_ioctl_set_country(struct net_device *dev, struct ifreq *rq)
263{
264 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
265 WMI_AP_SET_COUNTRY_CMD cmd;
Joe Perches1f4c34b2011-01-27 20:04:19 -0800266 int ret;
Vipin Mehta30295c82010-09-01 12:06:33 -0700267
268 if ((dev->flags & IFF_UP) != IFF_UP) {
269 return -EIO;
270 }
Joe Perches1071a132011-02-02 14:05:47 -0800271 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700272 return -EIO;
273 }
274
275 if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
276 sizeof(cmd)))
277 {
278 return -EFAULT;
279 }
280
281 ar->ap_profile_flag = 1; /* There is a change in profile */
282
283 ret = wmi_set_country(ar->arWmi, cmd.countryCode);
284 A_MEMCPY(ar->ap_country_code, cmd.countryCode, 3);
285
286 switch (ret) {
Joe Perches4f69cef2011-02-02 14:05:57 -0800287 case 0:
Vipin Mehta30295c82010-09-01 12:06:33 -0700288 return 0;
289 case A_EBUSY :
290 return -EBUSY;
291 case A_NO_MEMORY:
292 return -ENOMEM;
293 case A_EINVAL:
294 default:
295 return -EFAULT;
296 }
297}
298
299
300/* Get power mode command */
301static int
302ar6000_ioctl_get_power_mode(struct net_device *dev, struct ifreq *rq)
303{
304 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
305 WMI_POWER_MODE_CMD power_mode;
306 int ret = 0;
307
Joe Perches1071a132011-02-02 14:05:47 -0800308 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700309 return -EIO;
310 }
311
312 power_mode.powerMode = wmi_get_power_mode_cmd(ar->arWmi);
313 if (copy_to_user(rq->ifr_data, &power_mode, sizeof(WMI_POWER_MODE_CMD))) {
314 ret = -EFAULT;
315 }
316
317 return ret;
318}
319
320
321static int
322ar6000_ioctl_set_channelParams(struct net_device *dev, struct ifreq *rq)
323{
324 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
325 WMI_CHANNEL_PARAMS_CMD cmd, *cmdp;
326 int ret = 0;
327
Joe Perches1071a132011-02-02 14:05:47 -0800328 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700329 return -EIO;
330 }
331
332
333 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
334 return -EFAULT;
335 }
336
337 if( (ar->arNextMode == AP_NETWORK) && (cmd.numChannels || cmd.scanParam) ) {
338 A_PRINTF("ERROR: Only wmode is allowed in AP mode\n");
339 return -EIO;
340 }
341
342 if (cmd.numChannels > 1) {
343 cmdp = A_MALLOC(130);
344 if (copy_from_user(cmdp, rq->ifr_data,
345 sizeof (*cmdp) +
Joe Perches4853ac02011-02-02 14:05:50 -0800346 ((cmd.numChannels - 1) * sizeof(u16))))
Vipin Mehta30295c82010-09-01 12:06:33 -0700347 {
348 kfree(cmdp);
349 return -EFAULT;
350 }
351 } else {
352 cmdp = &cmd;
353 }
354
355 if ((ar->arPhyCapability == WMI_11G_CAPABILITY) &&
356 ((cmdp->phyMode == WMI_11A_MODE) || (cmdp->phyMode == WMI_11AG_MODE)))
357 {
358 ret = -EINVAL;
359 }
360
361 if (!ret &&
362 (wmi_set_channelParams_cmd(ar->arWmi, cmdp->scanParam, cmdp->phyMode,
363 cmdp->numChannels, cmdp->channelList)
Joe Perches4f69cef2011-02-02 14:05:57 -0800364 != 0))
Vipin Mehta30295c82010-09-01 12:06:33 -0700365 {
366 ret = -EIO;
367 }
368
369 if (cmd.numChannels > 1) {
370 kfree(cmdp);
371 }
372
373 ar->ap_wmode = cmdp->phyMode;
374 /* Set the profile change flag to allow a commit cmd */
375 ar->ap_profile_flag = 1;
376
377 return ret;
378}
379
380
381static int
382ar6000_ioctl_set_snr_threshold(struct net_device *dev, struct ifreq *rq)
383{
384
385 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
386 WMI_SNR_THRESHOLD_PARAMS_CMD cmd;
387 int ret = 0;
388
Joe Perches1071a132011-02-02 14:05:47 -0800389 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700390 return -EIO;
391 }
392
393 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
394 return -EFAULT;
395 }
396
Joe Perches4f69cef2011-02-02 14:05:57 -0800397 if( wmi_set_snr_threshold_params(ar->arWmi, &cmd) != 0 ) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700398 ret = -EIO;
399 }
400
401 return ret;
402}
403
404static int
405ar6000_ioctl_set_rssi_threshold(struct net_device *dev, struct ifreq *rq)
406{
407#define SWAP_THOLD(thold1, thold2) do { \
408 USER_RSSI_THOLD tmpThold; \
409 tmpThold.tag = thold1.tag; \
410 tmpThold.rssi = thold1.rssi; \
411 thold1.tag = thold2.tag; \
412 thold1.rssi = thold2.rssi; \
413 thold2.tag = tmpThold.tag; \
414 thold2.rssi = tmpThold.rssi; \
415} while (0)
416
417 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
418 WMI_RSSI_THRESHOLD_PARAMS_CMD cmd;
419 USER_RSSI_PARAMS rssiParams;
Joe Perchesf68057e2011-02-02 14:05:55 -0800420 s32 i, j;
Vipin Mehta30295c82010-09-01 12:06:33 -0700421 int ret = 0;
422
Joe Perches1071a132011-02-02 14:05:47 -0800423 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700424 return -EIO;
425 }
426
427 if (copy_from_user((char *)&rssiParams, (char *)((unsigned int *)rq->ifr_data + 1), sizeof(USER_RSSI_PARAMS))) {
428 return -EFAULT;
429 }
430 cmd.weight = rssiParams.weight;
431 cmd.pollTime = rssiParams.pollTime;
432
433 A_MEMCPY(ar->rssi_map, &rssiParams.tholds, sizeof(ar->rssi_map));
434 /*
435 * only 6 elements, so use bubble sorting, in ascending order
436 */
437 for (i = 5; i > 0; i--) {
438 for (j = 0; j < i; j++) { /* above tholds */
439 if (ar->rssi_map[j+1].rssi < ar->rssi_map[j].rssi) {
440 SWAP_THOLD(ar->rssi_map[j+1], ar->rssi_map[j]);
441 } else if (ar->rssi_map[j+1].rssi == ar->rssi_map[j].rssi) {
Ralph Loader3ec60802011-01-21 19:27:53 +1300442 return -EFAULT;
Vipin Mehta30295c82010-09-01 12:06:33 -0700443 }
444 }
445 }
446 for (i = 11; i > 6; i--) {
447 for (j = 6; j < i; j++) { /* below tholds */
448 if (ar->rssi_map[j+1].rssi < ar->rssi_map[j].rssi) {
449 SWAP_THOLD(ar->rssi_map[j+1], ar->rssi_map[j]);
450 } else if (ar->rssi_map[j+1].rssi == ar->rssi_map[j].rssi) {
Ralph Loader3ec60802011-01-21 19:27:53 +1300451 return -EFAULT;
Vipin Mehta30295c82010-09-01 12:06:33 -0700452 }
453 }
454 }
455
456#ifdef DEBUG
457 for (i = 0; i < 12; i++) {
458 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("thold[%d].tag: %d, thold[%d].rssi: %d \n",
459 i, ar->rssi_map[i].tag, i, ar->rssi_map[i].rssi));
460 }
461#endif
462
463 if (enablerssicompensation) {
464 for (i = 0; i < 6; i++)
Joe Perches1071a132011-02-02 14:05:47 -0800465 ar->rssi_map[i].rssi = rssi_compensation_reverse_calc(ar, ar->rssi_map[i].rssi, true);
Vipin Mehta30295c82010-09-01 12:06:33 -0700466 for (i = 6; i < 12; i++)
Joe Perches1071a132011-02-02 14:05:47 -0800467 ar->rssi_map[i].rssi = rssi_compensation_reverse_calc(ar, ar->rssi_map[i].rssi, false);
Vipin Mehta30295c82010-09-01 12:06:33 -0700468 }
469
470 cmd.thresholdAbove1_Val = ar->rssi_map[0].rssi;
471 cmd.thresholdAbove2_Val = ar->rssi_map[1].rssi;
472 cmd.thresholdAbove3_Val = ar->rssi_map[2].rssi;
473 cmd.thresholdAbove4_Val = ar->rssi_map[3].rssi;
474 cmd.thresholdAbove5_Val = ar->rssi_map[4].rssi;
475 cmd.thresholdAbove6_Val = ar->rssi_map[5].rssi;
476 cmd.thresholdBelow1_Val = ar->rssi_map[6].rssi;
477 cmd.thresholdBelow2_Val = ar->rssi_map[7].rssi;
478 cmd.thresholdBelow3_Val = ar->rssi_map[8].rssi;
479 cmd.thresholdBelow4_Val = ar->rssi_map[9].rssi;
480 cmd.thresholdBelow5_Val = ar->rssi_map[10].rssi;
481 cmd.thresholdBelow6_Val = ar->rssi_map[11].rssi;
482
Joe Perches4f69cef2011-02-02 14:05:57 -0800483 if( wmi_set_rssi_threshold_params(ar->arWmi, &cmd) != 0 ) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700484 ret = -EIO;
485 }
486
487 return ret;
488}
489
490static int
491ar6000_ioctl_set_lq_threshold(struct net_device *dev, struct ifreq *rq)
492{
493
494 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
495 WMI_LQ_THRESHOLD_PARAMS_CMD cmd;
496 int ret = 0;
497
Joe Perches1071a132011-02-02 14:05:47 -0800498 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700499 return -EIO;
500 }
501
502 if (copy_from_user(&cmd, (char *)((unsigned int *)rq->ifr_data + 1), sizeof(cmd))) {
503 return -EFAULT;
504 }
505
Joe Perches4f69cef2011-02-02 14:05:57 -0800506 if( wmi_set_lq_threshold_params(ar->arWmi, &cmd) != 0 ) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700507 ret = -EIO;
508 }
509
510 return ret;
511}
512
513
514static int
515ar6000_ioctl_set_probedSsid(struct net_device *dev, struct ifreq *rq)
516{
517 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
518 WMI_PROBED_SSID_CMD cmd;
519 int ret = 0;
520
Joe Perches1071a132011-02-02 14:05:47 -0800521 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700522 return -EIO;
523 }
524
525 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
526 return -EFAULT;
527 }
528
529 if (wmi_probedSsid_cmd(ar->arWmi, cmd.entryIndex, cmd.flag, cmd.ssidLength,
Joe Perches4f69cef2011-02-02 14:05:57 -0800530 cmd.ssid) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -0700531 {
532 ret = -EIO;
533 }
534
535 return ret;
536}
537
538static int
539ar6000_ioctl_set_badAp(struct net_device *dev, struct ifreq *rq)
540{
541 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
542 WMI_ADD_BAD_AP_CMD cmd;
543 int ret = 0;
544
Joe Perches1071a132011-02-02 14:05:47 -0800545 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700546 return -EIO;
547 }
548
549
550 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
551 return -EFAULT;
552 }
553
554 if (cmd.badApIndex > WMI_MAX_BAD_AP_INDEX) {
555 return -EIO;
556 }
557
558 if (A_MEMCMP(cmd.bssid, null_mac, AR6000_ETH_ADDR_LEN) == 0) {
559 /*
560 * This is a delete badAP.
561 */
Joe Perches4f69cef2011-02-02 14:05:57 -0800562 if (wmi_deleteBadAp_cmd(ar->arWmi, cmd.badApIndex) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700563 ret = -EIO;
564 }
565 } else {
Joe Perches4f69cef2011-02-02 14:05:57 -0800566 if (wmi_addBadAp_cmd(ar->arWmi, cmd.badApIndex, cmd.bssid) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700567 ret = -EIO;
568 }
569 }
570
571 return ret;
572}
573
574static int
575ar6000_ioctl_create_qos(struct net_device *dev, struct ifreq *rq)
576{
577 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
578 WMI_CREATE_PSTREAM_CMD cmd;
Joe Perches1f4c34b2011-01-27 20:04:19 -0800579 int ret;
Vipin Mehta30295c82010-09-01 12:06:33 -0700580
Joe Perches1071a132011-02-02 14:05:47 -0800581 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700582 return -EIO;
583 }
584
585
586 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
587 return -EFAULT;
588 }
589
590 ret = wmi_verify_tspec_params(&cmd, tspecCompliance);
Joe Perches4f69cef2011-02-02 14:05:57 -0800591 if (ret == 0)
Vipin Mehta30295c82010-09-01 12:06:33 -0700592 ret = wmi_create_pstream_cmd(ar->arWmi, &cmd);
593
594 switch (ret) {
Joe Perches4f69cef2011-02-02 14:05:57 -0800595 case 0:
Vipin Mehta30295c82010-09-01 12:06:33 -0700596 return 0;
597 case A_EBUSY :
598 return -EBUSY;
599 case A_NO_MEMORY:
600 return -ENOMEM;
601 case A_EINVAL:
602 default:
603 return -EFAULT;
604 }
605}
606
607static int
608ar6000_ioctl_delete_qos(struct net_device *dev, struct ifreq *rq)
609{
610 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
611 WMI_DELETE_PSTREAM_CMD cmd;
612 int ret = 0;
613
Joe Perches1071a132011-02-02 14:05:47 -0800614 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700615 return -EIO;
616 }
617
618 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
619 return -EFAULT;
620 }
621
622 ret = wmi_delete_pstream_cmd(ar->arWmi, cmd.trafficClass, cmd.tsid);
623
624 switch (ret) {
Joe Perches4f69cef2011-02-02 14:05:57 -0800625 case 0:
Vipin Mehta30295c82010-09-01 12:06:33 -0700626 return 0;
627 case A_EBUSY :
628 return -EBUSY;
629 case A_NO_MEMORY:
630 return -ENOMEM;
631 case A_EINVAL:
632 default:
633 return -EFAULT;
634 }
635}
636
637static int
638ar6000_ioctl_get_qos_queue(struct net_device *dev, struct ifreq *rq)
639{
640 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
641 struct ar6000_queuereq qreq;
642 int ret = 0;
643
Joe Perches1071a132011-02-02 14:05:47 -0800644 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700645 return -EIO;
646 }
647
648 if( copy_from_user(&qreq, rq->ifr_data,
649 sizeof(struct ar6000_queuereq)))
650 return -EFAULT;
651
652 qreq.activeTsids = wmi_get_mapped_qos_queue(ar->arWmi, qreq.trafficClass);
653
654 if (copy_to_user(rq->ifr_data, &qreq,
655 sizeof(struct ar6000_queuereq)))
656 {
657 ret = -EFAULT;
658 }
659
660 return ret;
661}
662
663#ifdef CONFIG_HOST_TCMD_SUPPORT
Joe Perches1f4c34b2011-01-27 20:04:19 -0800664static int
Vipin Mehta30295c82010-09-01 12:06:33 -0700665ar6000_ioctl_tcmd_get_rx_report(struct net_device *dev,
Joe Perchese1ce2a32011-02-02 14:05:51 -0800666 struct ifreq *rq, u8 *data, u32 len)
Vipin Mehta30295c82010-09-01 12:06:33 -0700667{
668 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
Joe Perchese1ce2a32011-02-02 14:05:51 -0800669 u32 buf[4+TCMD_MAX_RATES];
Vipin Mehta30295c82010-09-01 12:06:33 -0700670 int ret = 0;
671
672 if (ar->bIsDestroyProgress) {
673 return -EBUSY;
674 }
675
Joe Perches1071a132011-02-02 14:05:47 -0800676 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700677 return -EIO;
678 }
679
680 if (down_interruptible(&ar->arSem)) {
681 return -ERESTARTSYS;
682 }
683
684 if (ar->bIsDestroyProgress) {
685 up(&ar->arSem);
686 return -EBUSY;
687 }
688
689 ar->tcmdRxReport = 0;
Joe Perches4f69cef2011-02-02 14:05:57 -0800690 if (wmi_test_cmd(ar->arWmi, data, len) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700691 up(&ar->arSem);
692 return -EIO;
693 }
694
695 wait_event_interruptible_timeout(arEvent, ar->tcmdRxReport != 0, wmitimeout * HZ);
696
697 if (signal_pending(current)) {
698 ret = -EINTR;
699 }
700
701 buf[0] = ar->tcmdRxTotalPkt;
702 buf[1] = ar->tcmdRxRssi;
703 buf[2] = ar->tcmdRxcrcErrPkt;
704 buf[3] = ar->tcmdRxsecErrPkt;
Joe Perchese1ce2a32011-02-02 14:05:51 -0800705 A_MEMCPY(((A_UCHAR *)buf)+(4*sizeof(u32)), ar->tcmdRateCnt, sizeof(ar->tcmdRateCnt));
706 A_MEMCPY(((A_UCHAR *)buf)+(4*sizeof(u32))+(TCMD_MAX_RATES *sizeof(u16)), ar->tcmdRateCntShortGuard, sizeof(ar->tcmdRateCntShortGuard));
Vipin Mehta30295c82010-09-01 12:06:33 -0700707
708 if (!ret && copy_to_user(rq->ifr_data, buf, sizeof(buf))) {
709 ret = -EFAULT;
710 }
711
712 up(&ar->arSem);
713
714 return ret;
715}
716
717void
Joe Perchesab3655d2011-02-02 14:05:49 -0800718ar6000_tcmd_rx_report_event(void *devt, u8 *results, int len)
Vipin Mehta30295c82010-09-01 12:06:33 -0700719{
720 AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
721 TCMD_CONT_RX * rx_rep = (TCMD_CONT_RX *)results;
722
723 if (enablerssicompensation) {
724 rx_rep->u.report.rssiInDBm = rssi_compensation_calc_tcmd(tcmdRxFreq, rx_rep->u.report.rssiInDBm,rx_rep->u.report.totalPkt);
725 }
726
727
728 ar->tcmdRxTotalPkt = rx_rep->u.report.totalPkt;
729 ar->tcmdRxRssi = rx_rep->u.report.rssiInDBm;
730 ar->tcmdRxcrcErrPkt = rx_rep->u.report.crcErrPkt;
731 ar->tcmdRxsecErrPkt = rx_rep->u.report.secErrPkt;
732 ar->tcmdRxReport = 1;
733 A_MEMZERO(ar->tcmdRateCnt, sizeof(ar->tcmdRateCnt));
734 A_MEMZERO(ar->tcmdRateCntShortGuard, sizeof(ar->tcmdRateCntShortGuard));
735 A_MEMCPY(ar->tcmdRateCnt, rx_rep->u.report.rateCnt, sizeof(ar->tcmdRateCnt));
736 A_MEMCPY(ar->tcmdRateCntShortGuard, rx_rep->u.report.rateCntShortGuard, sizeof(ar->tcmdRateCntShortGuard));
737
738 wake_up(&arEvent);
739}
740#endif /* CONFIG_HOST_TCMD_SUPPORT*/
741
742static int
743ar6000_ioctl_set_error_report_bitmask(struct net_device *dev, struct ifreq *rq)
744{
745 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
746 WMI_TARGET_ERROR_REPORT_BITMASK cmd;
747 int ret = 0;
748
Joe Perches1071a132011-02-02 14:05:47 -0800749 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700750 return -EIO;
751 }
752
753 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
754 return -EFAULT;
755 }
756
757 ret = wmi_set_error_report_bitmask(ar->arWmi, cmd.bitmask);
758
759 return (ret==0 ? ret : -EINVAL);
760}
761
762static int
763ar6000_clear_target_stats(struct net_device *dev)
764{
765 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
766 TARGET_STATS *pStats = &ar->arTargetStats;
767 int ret = 0;
768
Joe Perches1071a132011-02-02 14:05:47 -0800769 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700770 return -EIO;
771 }
772 AR6000_SPIN_LOCK(&ar->arLock, 0);
773 A_MEMZERO(pStats, sizeof(TARGET_STATS));
774 AR6000_SPIN_UNLOCK(&ar->arLock, 0);
775 return ret;
776}
777
778static int
779ar6000_ioctl_get_target_stats(struct net_device *dev, struct ifreq *rq)
780{
781 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
782 TARGET_STATS_CMD cmd;
783 TARGET_STATS *pStats = &ar->arTargetStats;
784 int ret = 0;
785
786 if (ar->bIsDestroyProgress) {
787 return -EBUSY;
788 }
Joe Perches1071a132011-02-02 14:05:47 -0800789 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700790 return -EIO;
791 }
792 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
793 return -EFAULT;
794 }
795 if (down_interruptible(&ar->arSem)) {
796 return -ERESTARTSYS;
797 }
798 if (ar->bIsDestroyProgress) {
799 up(&ar->arSem);
800 return -EBUSY;
801 }
802
Joe Perches1071a132011-02-02 14:05:47 -0800803 ar->statsUpdatePending = true;
Vipin Mehta30295c82010-09-01 12:06:33 -0700804
Joe Perches4f69cef2011-02-02 14:05:57 -0800805 if(wmi_get_stats_cmd(ar->arWmi) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700806 up(&ar->arSem);
807 return -EIO;
808 }
809
Joe Perches1071a132011-02-02 14:05:47 -0800810 wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == false, wmitimeout * HZ);
Vipin Mehta30295c82010-09-01 12:06:33 -0700811
812 if (signal_pending(current)) {
813 ret = -EINTR;
814 }
815
816 if (!ret && copy_to_user(rq->ifr_data, pStats, sizeof(*pStats))) {
817 ret = -EFAULT;
818 }
819
820 if (cmd.clearStats == 1) {
821 ret = ar6000_clear_target_stats(dev);
822 }
823
824 up(&ar->arSem);
825
826 return ret;
827}
828
829static int
830ar6000_ioctl_get_ap_stats(struct net_device *dev, struct ifreq *rq)
831{
832 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
Joe Perchese1ce2a32011-02-02 14:05:51 -0800833 u32 action; /* Allocating only the desired space on the frame. Declaring is as a WMI_AP_MODE_STAT variable results in exceeding the compiler imposed limit on the maximum frame size */
Vipin Mehta30295c82010-09-01 12:06:33 -0700834 WMI_AP_MODE_STAT *pStats = &ar->arAPStats;
835 int ret = 0;
836
Joe Perches1071a132011-02-02 14:05:47 -0800837 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700838 return -EIO;
839 }
840 if (copy_from_user(&action, (char *)((unsigned int*)rq->ifr_data + 1),
Joe Perchese1ce2a32011-02-02 14:05:51 -0800841 sizeof(u32)))
Vipin Mehta30295c82010-09-01 12:06:33 -0700842 {
843 return -EFAULT;
844 }
845 if (action == AP_CLEAR_STATS) {
Joe Perchesab3655d2011-02-02 14:05:49 -0800846 u8 i;
Vipin Mehta30295c82010-09-01 12:06:33 -0700847 AR6000_SPIN_LOCK(&ar->arLock, 0);
848 for(i = 0; i < AP_MAX_NUM_STA; i++) {
849 pStats->sta[i].tx_bytes = 0;
850 pStats->sta[i].tx_pkts = 0;
851 pStats->sta[i].tx_error = 0;
852 pStats->sta[i].tx_discard = 0;
853 pStats->sta[i].rx_bytes = 0;
854 pStats->sta[i].rx_pkts = 0;
855 pStats->sta[i].rx_error = 0;
856 pStats->sta[i].rx_discard = 0;
857 }
858 AR6000_SPIN_UNLOCK(&ar->arLock, 0);
859 return ret;
860 }
861
862 if (down_interruptible(&ar->arSem)) {
863 return -ERESTARTSYS;
864 }
865
Joe Perches1071a132011-02-02 14:05:47 -0800866 ar->statsUpdatePending = true;
Vipin Mehta30295c82010-09-01 12:06:33 -0700867
Joe Perches4f69cef2011-02-02 14:05:57 -0800868 if(wmi_get_stats_cmd(ar->arWmi) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700869 up(&ar->arSem);
870 return -EIO;
871 }
872
Joe Perches1071a132011-02-02 14:05:47 -0800873 wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == false, wmitimeout * HZ);
Vipin Mehta30295c82010-09-01 12:06:33 -0700874
875 if (signal_pending(current)) {
876 ret = -EINTR;
877 }
878
879 if (!ret && copy_to_user(rq->ifr_data, pStats, sizeof(*pStats))) {
880 ret = -EFAULT;
881 }
882
883 up(&ar->arSem);
884
885 return ret;
886}
887
888static int
889ar6000_ioctl_set_access_params(struct net_device *dev, struct ifreq *rq)
890{
891 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
892 WMI_SET_ACCESS_PARAMS_CMD cmd;
893 int ret = 0;
894
Joe Perches1071a132011-02-02 14:05:47 -0800895 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700896 return -EIO;
897 }
898
899 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
900 return -EFAULT;
901 }
902
903 if (wmi_set_access_params_cmd(ar->arWmi, cmd.ac, cmd.txop, cmd.eCWmin, cmd.eCWmax,
Joe Perches4f69cef2011-02-02 14:05:57 -0800904 cmd.aifsn) == 0)
Vipin Mehta30295c82010-09-01 12:06:33 -0700905 {
906 ret = 0;
907 } else {
908 ret = -EINVAL;
909 }
910
911 return (ret);
912}
913
914static int
915ar6000_ioctl_set_disconnect_timeout(struct net_device *dev, struct ifreq *rq)
916{
917 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
918 WMI_DISC_TIMEOUT_CMD cmd;
919 int ret = 0;
920
Joe Perches1071a132011-02-02 14:05:47 -0800921 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700922 return -EIO;
923 }
924
925 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
926 return -EFAULT;
927 }
928
Joe Perches4f69cef2011-02-02 14:05:57 -0800929 if (wmi_disctimeout_cmd(ar->arWmi, cmd.disconnectTimeout) == 0)
Vipin Mehta30295c82010-09-01 12:06:33 -0700930 {
931 ret = 0;
932 } else {
933 ret = -EINVAL;
934 }
935
936 return (ret);
937}
938
939static int
Joe Perches4c42080f2011-02-02 14:05:48 -0800940ar6000_xioctl_set_voice_pkt_size(struct net_device *dev, char *userdata)
Vipin Mehta30295c82010-09-01 12:06:33 -0700941{
942 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
943 WMI_SET_VOICE_PKT_SIZE_CMD cmd;
944 int ret = 0;
945
Joe Perches1071a132011-02-02 14:05:47 -0800946 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700947 return -EIO;
948 }
949
950 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
951 return -EFAULT;
952 }
953
Joe Perches4f69cef2011-02-02 14:05:57 -0800954 if (wmi_set_voice_pkt_size_cmd(ar->arWmi, cmd.voicePktSize) == 0)
Vipin Mehta30295c82010-09-01 12:06:33 -0700955 {
956 ret = 0;
957 } else {
958 ret = -EINVAL;
959 }
960
961
962 return (ret);
963}
964
965static int
Joe Perches4c42080f2011-02-02 14:05:48 -0800966ar6000_xioctl_set_max_sp_len(struct net_device *dev, char *userdata)
Vipin Mehta30295c82010-09-01 12:06:33 -0700967{
968 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
969 WMI_SET_MAX_SP_LEN_CMD cmd;
970 int ret = 0;
971
Joe Perches1071a132011-02-02 14:05:47 -0800972 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700973 return -EIO;
974 }
975
976 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
977 return -EFAULT;
978 }
979
Joe Perches4f69cef2011-02-02 14:05:57 -0800980 if (wmi_set_max_sp_len_cmd(ar->arWmi, cmd.maxSPLen) == 0)
Vipin Mehta30295c82010-09-01 12:06:33 -0700981 {
982 ret = 0;
983 } else {
984 ret = -EINVAL;
985 }
986
987 return (ret);
988}
989
990
991static int
Joe Perches4c42080f2011-02-02 14:05:48 -0800992ar6000_xioctl_set_bt_status_cmd(struct net_device *dev, char *userdata)
Vipin Mehta30295c82010-09-01 12:06:33 -0700993{
994 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
995 WMI_SET_BT_STATUS_CMD cmd;
996 int ret = 0;
997
Joe Perches1071a132011-02-02 14:05:47 -0800998 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -0700999 return -EIO;
1000 }
1001
1002 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1003 return -EFAULT;
1004 }
1005
Joe Perches4f69cef2011-02-02 14:05:57 -08001006 if (wmi_set_bt_status_cmd(ar->arWmi, cmd.streamType, cmd.status) == 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07001007 {
1008 ret = 0;
1009 } else {
1010 ret = -EINVAL;
1011 }
1012
1013 return (ret);
1014}
1015
1016static int
Joe Perches4c42080f2011-02-02 14:05:48 -08001017ar6000_xioctl_set_bt_params_cmd(struct net_device *dev, char *userdata)
Vipin Mehta30295c82010-09-01 12:06:33 -07001018{
1019 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1020 WMI_SET_BT_PARAMS_CMD cmd;
1021 int ret = 0;
1022
Joe Perches1071a132011-02-02 14:05:47 -08001023 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001024 return -EIO;
1025 }
1026
1027 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1028 return -EFAULT;
1029 }
1030
Joe Perches4f69cef2011-02-02 14:05:57 -08001031 if (wmi_set_bt_params_cmd(ar->arWmi, &cmd) == 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07001032 {
1033 ret = 0;
1034 } else {
1035 ret = -EINVAL;
1036 }
1037
1038 return (ret);
1039}
1040
1041static int
Joe Perches4c42080f2011-02-02 14:05:48 -08001042ar6000_xioctl_set_btcoex_fe_ant_cmd(struct net_device * dev, char *userdata)
Vipin Mehta30295c82010-09-01 12:06:33 -07001043{
1044 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1045 WMI_SET_BTCOEX_FE_ANT_CMD cmd;
1046 int ret = 0;
1047
Joe Perches1071a132011-02-02 14:05:47 -08001048 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001049 return -EIO;
1050 }
1051 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1052 return -EFAULT;
1053 }
1054
Joe Perches4f69cef2011-02-02 14:05:57 -08001055 if (wmi_set_btcoex_fe_ant_cmd(ar->arWmi, &cmd) == 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07001056 {
1057 ret = 0;
1058 } else {
1059 ret = -EINVAL;
1060 }
1061
1062 return(ret);
1063}
1064
1065static int
Joe Perches4c42080f2011-02-02 14:05:48 -08001066ar6000_xioctl_set_btcoex_colocated_bt_dev_cmd(struct net_device * dev, char *userdata)
Vipin Mehta30295c82010-09-01 12:06:33 -07001067{
1068 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1069 WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD cmd;
1070 int ret = 0;
1071
Joe Perches1071a132011-02-02 14:05:47 -08001072 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001073 return -EIO;
1074 }
1075
1076 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1077 return -EFAULT;
1078 }
1079
Joe Perches4f69cef2011-02-02 14:05:57 -08001080 if (wmi_set_btcoex_colocated_bt_dev_cmd(ar->arWmi, &cmd) == 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07001081 {
1082 ret = 0;
1083 } else {
1084 ret = -EINVAL;
1085 }
1086
1087 return(ret);
1088}
1089
1090static int
Joe Perches4c42080f2011-02-02 14:05:48 -08001091ar6000_xioctl_set_btcoex_btinquiry_page_config_cmd(struct net_device * dev, char *userdata)
Vipin Mehta30295c82010-09-01 12:06:33 -07001092{
1093 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1094 WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG_CMD cmd;
1095 int ret = 0;
1096
Joe Perches1071a132011-02-02 14:05:47 -08001097 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001098 return -EIO;
1099 }
1100
1101 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1102 return -EFAULT;
1103 }
1104
Joe Perches4f69cef2011-02-02 14:05:57 -08001105 if (wmi_set_btcoex_btinquiry_page_config_cmd(ar->arWmi, &cmd) == 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07001106 {
1107 ret = 0;
1108 } else {
1109 ret = -EINVAL;
1110 }
1111
1112 return(ret);
1113}
1114
1115static int
Joe Perches4c42080f2011-02-02 14:05:48 -08001116ar6000_xioctl_set_btcoex_sco_config_cmd(struct net_device * dev, char *userdata)
Vipin Mehta30295c82010-09-01 12:06:33 -07001117{
1118 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1119 WMI_SET_BTCOEX_SCO_CONFIG_CMD cmd;
1120 int ret = 0;
1121
Joe Perches1071a132011-02-02 14:05:47 -08001122 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001123 return -EIO;
1124 }
1125
1126 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1127 return -EFAULT;
1128 }
1129
Joe Perches4f69cef2011-02-02 14:05:57 -08001130 if (wmi_set_btcoex_sco_config_cmd(ar->arWmi, &cmd) == 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07001131 {
1132 ret = 0;
1133 } else {
1134 ret = -EINVAL;
1135 }
1136
1137 return(ret);
1138}
1139
1140static int
1141ar6000_xioctl_set_btcoex_a2dp_config_cmd(struct net_device * dev,
Joe Perches4c42080f2011-02-02 14:05:48 -08001142 char *userdata)
Vipin Mehta30295c82010-09-01 12:06:33 -07001143{
1144 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1145 WMI_SET_BTCOEX_A2DP_CONFIG_CMD cmd;
1146 int ret = 0;
1147
Joe Perches1071a132011-02-02 14:05:47 -08001148 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001149 return -EIO;
1150 }
1151
1152 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1153 return -EFAULT;
1154 }
1155
Joe Perches4f69cef2011-02-02 14:05:57 -08001156 if (wmi_set_btcoex_a2dp_config_cmd(ar->arWmi, &cmd) == 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07001157 {
1158 ret = 0;
1159 } else {
1160 ret = -EINVAL;
1161 }
1162
1163 return(ret);
1164}
1165
1166static int
Joe Perches4c42080f2011-02-02 14:05:48 -08001167ar6000_xioctl_set_btcoex_aclcoex_config_cmd(struct net_device * dev, char *userdata)
Vipin Mehta30295c82010-09-01 12:06:33 -07001168{
1169 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1170 WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD cmd;
1171 int ret = 0;
1172
Joe Perches1071a132011-02-02 14:05:47 -08001173 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001174 return -EIO;
1175 }
1176
1177 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1178 return -EFAULT;
1179 }
1180
Joe Perches4f69cef2011-02-02 14:05:57 -08001181 if (wmi_set_btcoex_aclcoex_config_cmd(ar->arWmi, &cmd) == 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07001182 {
1183 ret = 0;
1184 } else {
1185 ret = -EINVAL;
1186 }
1187
1188 return(ret);
1189}
1190
1191static int
Joe Perches4c42080f2011-02-02 14:05:48 -08001192ar60000_xioctl_set_btcoex_debug_cmd(struct net_device * dev, char *userdata)
Vipin Mehta30295c82010-09-01 12:06:33 -07001193{
1194 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1195 WMI_SET_BTCOEX_DEBUG_CMD cmd;
1196 int ret = 0;
1197
Joe Perches1071a132011-02-02 14:05:47 -08001198 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001199 return -EIO;
1200 }
1201
1202 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1203 return -EFAULT;
1204 }
1205
Joe Perches4f69cef2011-02-02 14:05:57 -08001206 if (wmi_set_btcoex_debug_cmd(ar->arWmi, &cmd) == 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07001207 {
1208 ret = 0;
1209 } else {
1210 ret = -EINVAL;
1211 }
1212
1213 return(ret);
1214}
1215
1216static int
Joe Perches4c42080f2011-02-02 14:05:48 -08001217ar6000_xioctl_set_btcoex_bt_operating_status_cmd(struct net_device * dev, char *userdata)
Vipin Mehta30295c82010-09-01 12:06:33 -07001218{
1219 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1220 WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMD cmd;
1221 int ret = 0;
1222
Joe Perches1071a132011-02-02 14:05:47 -08001223 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001224 return -EIO;
1225 }
1226
1227 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1228 return -EFAULT;
1229 }
1230
Joe Perches4f69cef2011-02-02 14:05:57 -08001231 if (wmi_set_btcoex_bt_operating_status_cmd(ar->arWmi, &cmd) == 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07001232 {
1233 ret = 0;
1234 } else {
1235 ret = -EINVAL;
1236 }
1237 return(ret);
1238}
1239
1240static int
Joe Perches4c42080f2011-02-02 14:05:48 -08001241ar6000_xioctl_get_btcoex_config_cmd(struct net_device * dev, char *userdata,
Vipin Mehta30295c82010-09-01 12:06:33 -07001242 struct ifreq *rq)
1243{
1244
1245 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1246 AR6000_BTCOEX_CONFIG btcoexConfig;
1247 WMI_BTCOEX_CONFIG_EVENT *pbtcoexConfigEv = &ar->arBtcoexConfig;
1248
1249 int ret = 0;
1250
1251 if (ar->bIsDestroyProgress) {
1252 return -EBUSY;
1253 }
Joe Perches1071a132011-02-02 14:05:47 -08001254 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001255 return -EIO;
1256 }
1257 if (copy_from_user(&btcoexConfig.configCmd, userdata, sizeof(AR6000_BTCOEX_CONFIG))) {
1258 return -EFAULT;
1259 }
1260 if (down_interruptible(&ar->arSem)) {
1261 return -ERESTARTSYS;
1262 }
1263
Joe Perches4f69cef2011-02-02 14:05:57 -08001264 if (wmi_get_btcoex_config_cmd(ar->arWmi, (WMI_GET_BTCOEX_CONFIG_CMD *)&btcoexConfig.configCmd) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07001265 {
1266 up(&ar->arSem);
1267 return -EIO;
1268 }
1269
Joe Perches1071a132011-02-02 14:05:47 -08001270 ar->statsUpdatePending = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001271
Joe Perches1071a132011-02-02 14:05:47 -08001272 wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == false, wmitimeout * HZ);
Vipin Mehta30295c82010-09-01 12:06:33 -07001273
1274 if (signal_pending(current)) {
1275 ret = -EINTR;
1276 }
1277
1278 if (!ret && copy_to_user(btcoexConfig.configEvent, pbtcoexConfigEv, sizeof(WMI_BTCOEX_CONFIG_EVENT))) {
1279 ret = -EFAULT;
1280 }
1281 up(&ar->arSem);
1282 return ret;
1283}
1284
1285static int
Joe Perches4c42080f2011-02-02 14:05:48 -08001286ar6000_xioctl_get_btcoex_stats_cmd(struct net_device * dev, char *userdata, struct ifreq *rq)
Vipin Mehta30295c82010-09-01 12:06:33 -07001287{
1288 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1289 AR6000_BTCOEX_STATS btcoexStats;
1290 WMI_BTCOEX_STATS_EVENT *pbtcoexStats = &ar->arBtcoexStats;
1291 int ret = 0;
1292
1293 if (ar->bIsDestroyProgress) {
1294 return -EBUSY;
1295 }
Joe Perches1071a132011-02-02 14:05:47 -08001296 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001297 return -EIO;
1298 }
1299
1300 if (down_interruptible(&ar->arSem)) {
1301 return -ERESTARTSYS;
1302 }
1303
1304 if (copy_from_user(&btcoexStats.statsEvent, userdata, sizeof(AR6000_BTCOEX_CONFIG))) {
1305 return -EFAULT;
1306 }
1307
Joe Perches4f69cef2011-02-02 14:05:57 -08001308 if (wmi_get_btcoex_stats_cmd(ar->arWmi) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07001309 {
1310 up(&ar->arSem);
1311 return -EIO;
1312 }
1313
Joe Perches1071a132011-02-02 14:05:47 -08001314 ar->statsUpdatePending = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001315
Joe Perches1071a132011-02-02 14:05:47 -08001316 wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == false, wmitimeout * HZ);
Vipin Mehta30295c82010-09-01 12:06:33 -07001317
1318 if (signal_pending(current)) {
1319 ret = -EINTR;
1320 }
1321
1322 if (!ret && copy_to_user(btcoexStats.statsEvent, pbtcoexStats, sizeof(WMI_BTCOEX_STATS_EVENT))) {
1323 ret = -EFAULT;
1324 }
1325
1326
1327 up(&ar->arSem);
1328
1329 return(ret);
1330}
1331
Vipin Mehta711a1bc2011-02-18 13:13:11 -08001332static int
1333ar6000_xioctl_set_excess_tx_retry_thres_cmd(struct net_device * dev, char * userdata)
1334{
1335 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1336 WMI_SET_EXCESS_TX_RETRY_THRES_CMD cmd;
1337 int ret = 0;
1338
1339 if (ar->arWmiReady == false) {
1340 return -EIO;
1341 }
1342
1343 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1344 return -EFAULT;
1345 }
1346
1347 if (wmi_set_excess_tx_retry_thres_cmd(ar->arWmi, &cmd) != 0)
1348 {
1349 ret = -EINVAL;
1350 }
1351 return(ret);
1352}
1353
Vipin Mehta30295c82010-09-01 12:06:33 -07001354#ifdef CONFIG_HOST_GPIO_SUPPORT
1355struct ar6000_gpio_intr_wait_cmd_s gpio_intr_results;
1356/* gpio_reg_results and gpio_data_available are protected by arSem */
1357static struct ar6000_gpio_register_cmd_s gpio_reg_results;
Joe Perches1071a132011-02-02 14:05:47 -08001358static bool gpio_data_available; /* Requested GPIO data available */
1359static bool gpio_intr_available; /* GPIO interrupt info available */
1360static bool gpio_ack_received; /* GPIO ack was received */
Vipin Mehta30295c82010-09-01 12:06:33 -07001361
1362/* Host-side initialization for General Purpose I/O support */
1363void ar6000_gpio_init(void)
1364{
Joe Perches1071a132011-02-02 14:05:47 -08001365 gpio_intr_available = false;
1366 gpio_data_available = false;
1367 gpio_ack_received = false;
Vipin Mehta30295c82010-09-01 12:06:33 -07001368}
1369
1370/*
1371 * Called when a GPIO interrupt is received from the Target.
1372 * intr_values shows which GPIO pins have interrupted.
1373 * input_values shows a recent value of GPIO pins.
1374 */
1375void
Joe Perchese1ce2a32011-02-02 14:05:51 -08001376ar6000_gpio_intr_rx(u32 intr_mask, u32 input_values)
Vipin Mehta30295c82010-09-01 12:06:33 -07001377{
1378 gpio_intr_results.intr_mask = intr_mask;
1379 gpio_intr_results.input_values = input_values;
Joe Perches1071a132011-02-02 14:05:47 -08001380 *((volatile bool *)&gpio_intr_available) = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001381 wake_up(&arEvent);
1382}
1383
1384/*
1385 * This is called when a response is received from the Target
1386 * for a previous or ar6000_gpio_input_get or ar6000_gpio_register_get
1387 * call.
1388 */
1389void
Joe Perchese1ce2a32011-02-02 14:05:51 -08001390ar6000_gpio_data_rx(u32 reg_id, u32 value)
Vipin Mehta30295c82010-09-01 12:06:33 -07001391{
1392 gpio_reg_results.gpioreg_id = reg_id;
1393 gpio_reg_results.value = value;
Joe Perches1071a132011-02-02 14:05:47 -08001394 *((volatile bool *)&gpio_data_available) = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001395 wake_up(&arEvent);
1396}
1397
1398/*
1399 * This is called when an acknowledgement is received from the Target
1400 * for a previous or ar6000_gpio_output_set or ar6000_gpio_register_set
1401 * call.
1402 */
1403void
1404ar6000_gpio_ack_rx(void)
1405{
Joe Perches1071a132011-02-02 14:05:47 -08001406 gpio_ack_received = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001407 wake_up(&arEvent);
1408}
1409
Joe Perches1f4c34b2011-01-27 20:04:19 -08001410int
Vipin Mehta30295c82010-09-01 12:06:33 -07001411ar6000_gpio_output_set(struct net_device *dev,
Joe Perchese1ce2a32011-02-02 14:05:51 -08001412 u32 set_mask,
1413 u32 clear_mask,
1414 u32 enable_mask,
1415 u32 disable_mask)
Vipin Mehta30295c82010-09-01 12:06:33 -07001416{
1417 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1418
Joe Perches1071a132011-02-02 14:05:47 -08001419 gpio_ack_received = false;
Vipin Mehta30295c82010-09-01 12:06:33 -07001420 return wmi_gpio_output_set(ar->arWmi,
1421 set_mask, clear_mask, enable_mask, disable_mask);
1422}
1423
Joe Perches1f4c34b2011-01-27 20:04:19 -08001424static int
Vipin Mehta30295c82010-09-01 12:06:33 -07001425ar6000_gpio_input_get(struct net_device *dev)
1426{
1427 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1428
Joe Perches1071a132011-02-02 14:05:47 -08001429 *((volatile bool *)&gpio_data_available) = false;
Vipin Mehta30295c82010-09-01 12:06:33 -07001430 return wmi_gpio_input_get(ar->arWmi);
1431}
1432
Joe Perches1f4c34b2011-01-27 20:04:19 -08001433static int
Vipin Mehta30295c82010-09-01 12:06:33 -07001434ar6000_gpio_register_set(struct net_device *dev,
Joe Perchese1ce2a32011-02-02 14:05:51 -08001435 u32 gpioreg_id,
1436 u32 value)
Vipin Mehta30295c82010-09-01 12:06:33 -07001437{
1438 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1439
Joe Perches1071a132011-02-02 14:05:47 -08001440 gpio_ack_received = false;
Vipin Mehta30295c82010-09-01 12:06:33 -07001441 return wmi_gpio_register_set(ar->arWmi, gpioreg_id, value);
1442}
1443
Joe Perches1f4c34b2011-01-27 20:04:19 -08001444static int
Vipin Mehta30295c82010-09-01 12:06:33 -07001445ar6000_gpio_register_get(struct net_device *dev,
Joe Perchese1ce2a32011-02-02 14:05:51 -08001446 u32 gpioreg_id)
Vipin Mehta30295c82010-09-01 12:06:33 -07001447{
1448 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1449
Joe Perches1071a132011-02-02 14:05:47 -08001450 *((volatile bool *)&gpio_data_available) = false;
Vipin Mehta30295c82010-09-01 12:06:33 -07001451 return wmi_gpio_register_get(ar->arWmi, gpioreg_id);
1452}
1453
Joe Perches1f4c34b2011-01-27 20:04:19 -08001454static int
Vipin Mehta30295c82010-09-01 12:06:33 -07001455ar6000_gpio_intr_ack(struct net_device *dev,
Joe Perchese1ce2a32011-02-02 14:05:51 -08001456 u32 ack_mask)
Vipin Mehta30295c82010-09-01 12:06:33 -07001457{
1458 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1459
Joe Perches1071a132011-02-02 14:05:47 -08001460 gpio_intr_available = false;
Vipin Mehta30295c82010-09-01 12:06:33 -07001461 return wmi_gpio_intr_ack(ar->arWmi, ack_mask);
1462}
1463#endif /* CONFIG_HOST_GPIO_SUPPORT */
1464
1465#if defined(CONFIG_TARGET_PROFILE_SUPPORT)
1466static struct prof_count_s prof_count_results;
Joe Perches1071a132011-02-02 14:05:47 -08001467static bool prof_count_available; /* Requested GPIO data available */
Vipin Mehta30295c82010-09-01 12:06:33 -07001468
Joe Perches1f4c34b2011-01-27 20:04:19 -08001469static int
Vipin Mehta30295c82010-09-01 12:06:33 -07001470prof_count_get(struct net_device *dev)
1471{
1472 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1473
Joe Perches1071a132011-02-02 14:05:47 -08001474 *((volatile bool *)&prof_count_available) = false;
Vipin Mehta30295c82010-09-01 12:06:33 -07001475 return wmi_prof_count_get_cmd(ar->arWmi);
1476}
1477
1478/*
1479 * This is called when a response is received from the Target
1480 * for a previous prof_count_get call.
1481 */
1482void
Joe Perchese1ce2a32011-02-02 14:05:51 -08001483prof_count_rx(u32 addr, u32 count)
Vipin Mehta30295c82010-09-01 12:06:33 -07001484{
1485 prof_count_results.addr = addr;
1486 prof_count_results.count = count;
Joe Perches1071a132011-02-02 14:05:47 -08001487 *((volatile bool *)&prof_count_available) = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001488 wake_up(&arEvent);
1489}
1490#endif /* CONFIG_TARGET_PROFILE_SUPPORT */
1491
1492
Joe Perches1f4c34b2011-01-27 20:04:19 -08001493static int
Joe Perchesab3655d2011-02-02 14:05:49 -08001494ar6000_create_acl_data_osbuf(struct net_device *dev, u8 *userdata, void **p_osbuf)
Vipin Mehta30295c82010-09-01 12:06:33 -07001495{
1496 void *osbuf = NULL;
Joe Perchesab3655d2011-02-02 14:05:49 -08001497 u8 tmp_space[8];
Vipin Mehta30295c82010-09-01 12:06:33 -07001498 HCI_ACL_DATA_PKT *acl;
Joe Perchesab3655d2011-02-02 14:05:49 -08001499 u8 hdr_size, *datap=NULL;
Joe Perches4f69cef2011-02-02 14:05:57 -08001500 int ret = 0;
Vipin Mehta30295c82010-09-01 12:06:33 -07001501
1502 /* ACL is in data path. There is a need to create pool
1503 * mechanism for allocating and freeing NETBUFs - ToDo later.
1504 */
1505
1506 *p_osbuf = NULL;
1507 acl = (HCI_ACL_DATA_PKT *)tmp_space;
1508 hdr_size = sizeof(acl->hdl_and_flags) + sizeof(acl->data_len);
1509
1510 do {
1511 if (a_copy_from_user(acl, userdata, hdr_size)) {
1512 ret = A_EFAULT;
1513 break;
1514 }
1515
1516 osbuf = A_NETBUF_ALLOC(hdr_size + acl->data_len);
1517 if (osbuf == NULL) {
1518 ret = A_NO_MEMORY;
1519 break;
1520 }
1521 A_NETBUF_PUT(osbuf, hdr_size + acl->data_len);
Joe Perchesab3655d2011-02-02 14:05:49 -08001522 datap = (u8 *)A_NETBUF_DATA(osbuf);
Vipin Mehta30295c82010-09-01 12:06:33 -07001523
1524 /* Real copy to osbuf */
1525 acl = (HCI_ACL_DATA_PKT *)(datap);
1526 A_MEMCPY(acl, tmp_space, hdr_size);
1527 if (a_copy_from_user(acl->data, userdata + hdr_size, acl->data_len)) {
1528 ret = A_EFAULT;
1529 break;
1530 }
Joe Perches1071a132011-02-02 14:05:47 -08001531 } while(false);
Vipin Mehta30295c82010-09-01 12:06:33 -07001532
Joe Perches4f69cef2011-02-02 14:05:57 -08001533 if (ret == 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001534 *p_osbuf = osbuf;
1535 } else {
1536 A_NETBUF_FREE(osbuf);
1537 }
1538 return ret;
1539}
1540
1541
1542
1543int
1544ar6000_ioctl_ap_setparam(AR_SOFTC_T *ar, int param, int value)
1545{
1546 int ret=0;
1547
1548 switch(param) {
1549 case IEEE80211_PARAM_WPA:
1550 switch (value) {
1551 case WPA_MODE_WPA1:
1552 ar->arAuthMode = WPA_AUTH;
1553 break;
1554 case WPA_MODE_WPA2:
1555 ar->arAuthMode = WPA2_AUTH;
1556 break;
1557 case WPA_MODE_AUTO:
1558 ar->arAuthMode = WPA_AUTH | WPA2_AUTH;
1559 break;
1560 case WPA_MODE_NONE:
1561 ar->arAuthMode = NONE_AUTH;
1562 break;
1563 }
1564 break;
1565 case IEEE80211_PARAM_AUTHMODE:
1566 if(value == IEEE80211_AUTH_WPA_PSK) {
1567 if (WPA_AUTH == ar->arAuthMode) {
1568 ar->arAuthMode = WPA_PSK_AUTH;
1569 } else if (WPA2_AUTH == ar->arAuthMode) {
1570 ar->arAuthMode = WPA2_PSK_AUTH;
1571 } else if ((WPA_AUTH | WPA2_AUTH) == ar->arAuthMode) {
1572 ar->arAuthMode = WPA_PSK_AUTH | WPA2_PSK_AUTH;
1573 } else {
1574 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Error - Setting PSK "\
1575 "mode when WPA param was set to %d\n",
1576 ar->arAuthMode));
1577 ret = -EIO;
1578 }
1579 }
1580 break;
1581 case IEEE80211_PARAM_UCASTCIPHER:
1582 ar->arPairwiseCrypto = 0;
1583 if(value & (1<<IEEE80211_CIPHER_AES_CCM)) {
1584 ar->arPairwiseCrypto |= AES_CRYPT;
1585 }
1586 if(value & (1<<IEEE80211_CIPHER_TKIP)) {
1587 ar->arPairwiseCrypto |= TKIP_CRYPT;
1588 }
1589 if(!ar->arPairwiseCrypto) {
1590 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
1591 ("Error - Invalid cipher in WPA \n"));
1592 ret = -EIO;
1593 }
1594 break;
1595 case IEEE80211_PARAM_PRIVACY:
1596 if(value == 0) {
1597 ar->arDot11AuthMode = OPEN_AUTH;
1598 ar->arAuthMode = NONE_AUTH;
1599 ar->arPairwiseCrypto = NONE_CRYPT;
1600 ar->arPairwiseCryptoLen = 0;
1601 ar->arGroupCrypto = NONE_CRYPT;
1602 ar->arGroupCryptoLen = 0;
1603 }
1604 break;
1605#ifdef WAPI_ENABLE
1606 case IEEE80211_PARAM_WAPI:
1607 A_PRINTF("WAPI Policy: %d\n", value);
1608 ar->arDot11AuthMode = OPEN_AUTH;
1609 ar->arAuthMode = NONE_AUTH;
1610 if(value & 0x1) {
1611 ar->arPairwiseCrypto = WAPI_CRYPT;
1612 ar->arGroupCrypto = WAPI_CRYPT;
1613 } else {
1614 ar->arPairwiseCrypto = NONE_CRYPT;
1615 ar->arGroupCrypto = NONE_CRYPT;
1616 }
1617 break;
1618#endif
1619 }
1620 return ret;
1621}
1622
1623int
1624ar6000_ioctl_setparam(AR_SOFTC_T *ar, int param, int value)
1625{
Joe Perches1071a132011-02-02 14:05:47 -08001626 bool profChanged = false;
Vipin Mehta30295c82010-09-01 12:06:33 -07001627 int ret=0;
1628
1629 if(ar->arNextMode == AP_NETWORK) {
1630 ar->ap_profile_flag = 1; /* There is a change in profile */
1631 switch (param) {
1632 case IEEE80211_PARAM_WPA:
1633 case IEEE80211_PARAM_AUTHMODE:
1634 case IEEE80211_PARAM_UCASTCIPHER:
1635 case IEEE80211_PARAM_PRIVACY:
1636 case IEEE80211_PARAM_WAPI:
1637 ret = ar6000_ioctl_ap_setparam(ar, param, value);
1638 return ret;
1639 }
1640 }
1641
1642 switch (param) {
1643 case IEEE80211_PARAM_WPA:
1644 switch (value) {
1645 case WPA_MODE_WPA1:
1646 ar->arAuthMode = WPA_AUTH;
Joe Perches1071a132011-02-02 14:05:47 -08001647 profChanged = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001648 break;
1649 case WPA_MODE_WPA2:
1650 ar->arAuthMode = WPA2_AUTH;
Joe Perches1071a132011-02-02 14:05:47 -08001651 profChanged = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001652 break;
1653 case WPA_MODE_NONE:
1654 ar->arAuthMode = NONE_AUTH;
Joe Perches1071a132011-02-02 14:05:47 -08001655 profChanged = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001656 break;
1657 }
1658 break;
1659 case IEEE80211_PARAM_AUTHMODE:
1660 switch(value) {
1661 case IEEE80211_AUTH_WPA_PSK:
1662 if (WPA_AUTH == ar->arAuthMode) {
1663 ar->arAuthMode = WPA_PSK_AUTH;
Joe Perches1071a132011-02-02 14:05:47 -08001664 profChanged = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001665 } else if (WPA2_AUTH == ar->arAuthMode) {
1666 ar->arAuthMode = WPA2_PSK_AUTH;
Joe Perches1071a132011-02-02 14:05:47 -08001667 profChanged = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001668 } else {
1669 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Error - Setting PSK "\
1670 "mode when WPA param was set to %d\n",
1671 ar->arAuthMode));
1672 ret = -EIO;
1673 }
1674 break;
1675 case IEEE80211_AUTH_WPA_CCKM:
1676 if (WPA2_AUTH == ar->arAuthMode) {
1677 ar->arAuthMode = WPA2_AUTH_CCKM;
1678 } else {
1679 ar->arAuthMode = WPA_AUTH_CCKM;
1680 }
1681 break;
1682 default:
1683 break;
1684 }
1685 break;
1686 case IEEE80211_PARAM_UCASTCIPHER:
1687 switch (value) {
1688 case IEEE80211_CIPHER_AES_CCM:
1689 ar->arPairwiseCrypto = AES_CRYPT;
Joe Perches1071a132011-02-02 14:05:47 -08001690 profChanged = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001691 break;
1692 case IEEE80211_CIPHER_TKIP:
1693 ar->arPairwiseCrypto = TKIP_CRYPT;
Joe Perches1071a132011-02-02 14:05:47 -08001694 profChanged = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001695 break;
1696 case IEEE80211_CIPHER_WEP:
1697 ar->arPairwiseCrypto = WEP_CRYPT;
Joe Perches1071a132011-02-02 14:05:47 -08001698 profChanged = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001699 break;
1700 case IEEE80211_CIPHER_NONE:
1701 ar->arPairwiseCrypto = NONE_CRYPT;
Joe Perches1071a132011-02-02 14:05:47 -08001702 profChanged = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001703 break;
1704 }
1705 break;
1706 case IEEE80211_PARAM_UCASTKEYLEN:
1707 if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(value)) {
1708 ret = -EIO;
1709 } else {
1710 ar->arPairwiseCryptoLen = value;
1711 }
1712 break;
1713 case IEEE80211_PARAM_MCASTCIPHER:
1714 switch (value) {
1715 case IEEE80211_CIPHER_AES_CCM:
1716 ar->arGroupCrypto = AES_CRYPT;
Joe Perches1071a132011-02-02 14:05:47 -08001717 profChanged = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001718 break;
1719 case IEEE80211_CIPHER_TKIP:
1720 ar->arGroupCrypto = TKIP_CRYPT;
Joe Perches1071a132011-02-02 14:05:47 -08001721 profChanged = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001722 break;
1723 case IEEE80211_CIPHER_WEP:
1724 ar->arGroupCrypto = WEP_CRYPT;
Joe Perches1071a132011-02-02 14:05:47 -08001725 profChanged = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001726 break;
1727 case IEEE80211_CIPHER_NONE:
1728 ar->arGroupCrypto = NONE_CRYPT;
Joe Perches1071a132011-02-02 14:05:47 -08001729 profChanged = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001730 break;
1731 }
1732 break;
1733 case IEEE80211_PARAM_MCASTKEYLEN:
1734 if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(value)) {
1735 ret = -EIO;
1736 } else {
1737 ar->arGroupCryptoLen = value;
1738 }
1739 break;
1740 case IEEE80211_PARAM_COUNTERMEASURES:
Joe Perches1071a132011-02-02 14:05:47 -08001741 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001742 return -EIO;
1743 }
1744 wmi_set_tkip_countermeasures_cmd(ar->arWmi, value);
1745 break;
1746 default:
1747 break;
1748 }
Joe Perches1071a132011-02-02 14:05:47 -08001749 if ((ar->arNextMode != AP_NETWORK) && (profChanged == true)) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001750 /*
1751 * profile has changed. Erase ssid to signal change
1752 */
1753 A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
1754 }
1755
1756 return ret;
1757}
1758
1759int
1760ar6000_ioctl_setkey(AR_SOFTC_T *ar, struct ieee80211req_key *ik)
1761{
1762 KEY_USAGE keyUsage;
Joe Perches1f4c34b2011-01-27 20:04:19 -08001763 int status;
Vipin Mehta30295c82010-09-01 12:06:33 -07001764 CRYPTO_TYPE keyType = NONE_CRYPT;
1765
1766#ifdef USER_KEYS
Joe Perches1071a132011-02-02 14:05:47 -08001767 ar->user_saved_keys.keyOk = false;
Vipin Mehta30295c82010-09-01 12:06:33 -07001768#endif
1769 if ( (0 == memcmp(ik->ik_macaddr, null_mac, IEEE80211_ADDR_LEN)) ||
1770 (0 == memcmp(ik->ik_macaddr, bcast_mac, IEEE80211_ADDR_LEN)) ) {
1771 keyUsage = GROUP_USAGE;
1772 if(ar->arNextMode == AP_NETWORK) {
1773 A_MEMCPY(&ar->ap_mode_bkey, ik,
1774 sizeof(struct ieee80211req_key));
1775#ifdef WAPI_ENABLE
1776 if(ar->arPairwiseCrypto == WAPI_CRYPT) {
1777 return ap_set_wapi_key(ar, ik);
1778 }
1779#endif
1780 }
1781#ifdef USER_KEYS
1782 A_MEMCPY(&ar->user_saved_keys.bcast_ik, ik,
1783 sizeof(struct ieee80211req_key));
1784#endif
1785 } else {
1786 keyUsage = PAIRWISE_USAGE;
1787#ifdef USER_KEYS
1788 A_MEMCPY(&ar->user_saved_keys.ucast_ik, ik,
1789 sizeof(struct ieee80211req_key));
1790#endif
1791#ifdef WAPI_ENABLE
1792 if(ar->arNextMode == AP_NETWORK) {
1793 if(ar->arPairwiseCrypto == WAPI_CRYPT) {
1794 return ap_set_wapi_key(ar, ik);
1795 }
1796 }
1797#endif
1798 }
1799
1800 switch (ik->ik_type) {
1801 case IEEE80211_CIPHER_WEP:
1802 keyType = WEP_CRYPT;
1803 break;
1804 case IEEE80211_CIPHER_TKIP:
1805 keyType = TKIP_CRYPT;
1806 break;
1807 case IEEE80211_CIPHER_AES_CCM:
1808 keyType = AES_CRYPT;
1809 break;
1810 default:
1811 break;
1812 }
1813#ifdef USER_KEYS
1814 ar->user_saved_keys.keyType = keyType;
1815#endif
1816 if (IEEE80211_CIPHER_CCKM_KRK != ik->ik_type) {
1817 if (NONE_CRYPT == keyType) {
1818 return -EIO;
1819 }
1820
1821 if ((WEP_CRYPT == keyType)&&(!ar->arConnected)) {
1822 int index = ik->ik_keyix;
1823
1824 if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(ik->ik_keylen)) {
1825 return -EIO;
1826 }
1827
1828 A_MEMZERO(ar->arWepKeyList[index].arKey,
1829 sizeof(ar->arWepKeyList[index].arKey));
1830 A_MEMCPY(ar->arWepKeyList[index].arKey, ik->ik_keydata, ik->ik_keylen);
1831 ar->arWepKeyList[index].arKeyLen = ik->ik_keylen;
1832
1833 if(ik->ik_flags & IEEE80211_KEY_DEFAULT){
1834 ar->arDefTxKeyIndex = index;
1835 }
1836
1837 return 0;
1838 }
1839
1840 if (((WPA_PSK_AUTH == ar->arAuthMode) || (WPA2_PSK_AUTH == ar->arAuthMode)) &&
1841 (GROUP_USAGE & keyUsage))
1842 {
1843 A_UNTIMEOUT(&ar->disconnect_timer);
1844 }
1845
1846 status = wmi_addKey_cmd(ar->arWmi, ik->ik_keyix, keyType, keyUsage,
Joe Perchesab3655d2011-02-02 14:05:49 -08001847 ik->ik_keylen, (u8 *)&ik->ik_keyrsc,
Vipin Mehta30295c82010-09-01 12:06:33 -07001848 ik->ik_keydata, KEY_OP_INIT_VAL, ik->ik_macaddr,
1849 SYNC_BOTH_WMIFLAG);
1850
Joe Perchesa1d46522011-02-02 14:05:56 -08001851 if (status) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001852 return -EIO;
1853 }
1854 } else {
1855 status = wmi_add_krk_cmd(ar->arWmi, ik->ik_keydata);
1856 }
1857
1858#ifdef USER_KEYS
Joe Perches1071a132011-02-02 14:05:47 -08001859 ar->user_saved_keys.keyOk = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07001860#endif
1861
1862 return 0;
1863}
1864
1865int ar6000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1866{
1867 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1868 HIF_DEVICE *hifDevice = ar->arHifDevice;
1869 int ret = 0, param;
1870 unsigned int address = 0;
1871 unsigned int length = 0;
1872 unsigned char *buffer;
1873 char *userdata;
Joe Perchese1ce2a32011-02-02 14:05:51 -08001874 u32 connectCtrlFlags;
Vipin Mehta30295c82010-09-01 12:06:33 -07001875
1876
1877 WMI_SET_AKMP_PARAMS_CMD akmpParams;
1878 WMI_SET_PMKID_LIST_CMD pmkidInfo;
1879
1880 WMI_SET_HT_CAP_CMD htCap;
1881 WMI_SET_HT_OP_CMD htOp;
1882
1883 /*
1884 * ioctl operations may have to wait for the Target, so we cannot hold rtnl.
1885 * Prevent the device from disappearing under us and release the lock during
1886 * the ioctl operation.
1887 */
1888 dev_hold(dev);
1889 rtnl_unlock();
1890
1891 if (cmd == AR6000_IOCTL_EXTENDED) {
1892 /*
1893 * This allows for many more wireless ioctls than would otherwise
1894 * be available. Applications embed the actual ioctl command in
1895 * the first word of the parameter block, and use the command
1896 * AR6000_IOCTL_EXTENDED_CMD on the ioctl call.
1897 */
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04001898 if (get_user(cmd, (int *)rq->ifr_data)) {
1899 ret = -EFAULT;
1900 goto ioctl_done;
1901 }
Vipin Mehta30295c82010-09-01 12:06:33 -07001902 userdata = (char *)(((unsigned int *)rq->ifr_data)+1);
Joe Perches4f69cef2011-02-02 14:05:57 -08001903 if(is_xioctl_allowed(ar->arNextMode, cmd) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001904 A_PRINTF("xioctl: cmd=%d not allowed in this mode\n",cmd);
1905 ret = -EOPNOTSUPP;
1906 goto ioctl_done;
1907 }
1908 } else {
Joe Perches1f4c34b2011-01-27 20:04:19 -08001909 int ret = is_iwioctl_allowed(ar->arNextMode, cmd);
Vipin Mehta30295c82010-09-01 12:06:33 -07001910 if(ret == A_ENOTSUP) {
1911 A_PRINTF("iwioctl: cmd=0x%x not allowed in this mode\n", cmd);
1912 ret = -EOPNOTSUPP;
1913 goto ioctl_done;
1914 } else if (ret == A_ERROR) {
1915 /* It is not our ioctl (out of range ioctl) */
1916 ret = -EOPNOTSUPP;
1917 goto ioctl_done;
1918 }
1919 userdata = (char *)rq->ifr_data;
1920 }
1921
1922 if ((ar->arWlanState == WLAN_DISABLED) &&
1923 ((cmd != AR6000_XIOCTRL_WMI_SET_WLAN_STATE) &&
1924 (cmd != AR6000_XIOCTL_GET_WLAN_SLEEP_STATE) &&
1925 (cmd != AR6000_XIOCTL_DIAG_READ) &&
1926 (cmd != AR6000_XIOCTL_DIAG_WRITE) &&
1927 (cmd != AR6000_XIOCTL_SET_BT_HW_POWER_STATE) &&
1928 (cmd != AR6000_XIOCTL_GET_BT_HW_POWER_STATE) &&
1929 (cmd != AR6000_XIOCTL_ADD_AP_INTERFACE) &&
1930 (cmd != AR6000_XIOCTL_REMOVE_AP_INTERFACE) &&
1931 (cmd != AR6000_IOCTL_WMI_GETREV)))
1932 {
1933 ret = -EIO;
1934 goto ioctl_done;
1935 }
1936
1937 ret = 0;
1938 switch(cmd)
1939 {
1940 case IEEE80211_IOCTL_SETPARAM:
1941 {
1942 int param, value;
1943 int *ptr = (int *)rq->ifr_ifru.ifru_newname;
Joe Perches1071a132011-02-02 14:05:47 -08001944 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001945 ret = -EIO;
1946 } else {
1947 param = *ptr++;
1948 value = *ptr;
1949 ret = ar6000_ioctl_setparam(ar,param,value);
1950 }
1951 break;
1952 }
1953 case IEEE80211_IOCTL_SETKEY:
1954 {
1955 struct ieee80211req_key keydata;
Joe Perches1071a132011-02-02 14:05:47 -08001956 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001957 ret = -EIO;
1958 } else if (copy_from_user(&keydata, userdata,
1959 sizeof(struct ieee80211req_key))) {
1960 ret = -EFAULT;
1961 } else {
1962 ar6000_ioctl_setkey(ar, &keydata);
1963 }
1964 break;
1965 }
1966 case IEEE80211_IOCTL_DELKEY:
1967 case IEEE80211_IOCTL_SETOPTIE:
1968 {
1969 //ret = -EIO;
1970 break;
1971 }
1972 case IEEE80211_IOCTL_SETMLME:
1973 {
1974 struct ieee80211req_mlme mlme;
Joe Perches1071a132011-02-02 14:05:47 -08001975 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07001976 ret = -EIO;
1977 } else if (copy_from_user(&mlme, userdata,
1978 sizeof(struct ieee80211req_mlme))) {
1979 ret = -EFAULT;
1980 } else {
1981 switch (mlme.im_op) {
1982 case IEEE80211_MLME_AUTHORIZE:
1983 A_PRINTF("setmlme AUTHORIZE %02X:%02X\n",
1984 mlme.im_macaddr[4], mlme.im_macaddr[5]);
1985 break;
1986 case IEEE80211_MLME_UNAUTHORIZE:
1987 A_PRINTF("setmlme UNAUTHORIZE %02X:%02X\n",
1988 mlme.im_macaddr[4], mlme.im_macaddr[5]);
1989 break;
1990 case IEEE80211_MLME_DEAUTH:
1991 A_PRINTF("setmlme DEAUTH %02X:%02X\n",
1992 mlme.im_macaddr[4], mlme.im_macaddr[5]);
1993 //remove_sta(ar, mlme.im_macaddr);
1994 break;
1995 case IEEE80211_MLME_DISASSOC:
1996 A_PRINTF("setmlme DISASSOC %02X:%02X\n",
1997 mlme.im_macaddr[4], mlme.im_macaddr[5]);
1998 //remove_sta(ar, mlme.im_macaddr);
1999 break;
2000 default:
2001 ret = 0;
2002 goto ioctl_done;
2003 }
2004
2005 wmi_ap_set_mlme(ar->arWmi, mlme.im_op, mlme.im_macaddr,
2006 mlme.im_reason);
2007 }
2008 break;
2009 }
2010 case IEEE80211_IOCTL_ADDPMKID:
2011 {
2012 struct ieee80211req_addpmkid req;
Joe Perches1071a132011-02-02 14:05:47 -08002013 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002014 ret = -EIO;
2015 } else if (copy_from_user(&req, userdata, sizeof(struct ieee80211req_addpmkid))) {
2016 ret = -EFAULT;
2017 } else {
Joe Perches1f4c34b2011-01-27 20:04:19 -08002018 int status;
Vipin Mehta30295c82010-09-01 12:06:33 -07002019
2020 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("Add pmkid for %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x en=%d\n",
2021 req.pi_bssid[0], req.pi_bssid[1], req.pi_bssid[2],
2022 req.pi_bssid[3], req.pi_bssid[4], req.pi_bssid[5],
2023 req.pi_enable));
2024
2025 status = wmi_setPmkid_cmd(ar->arWmi, req.pi_bssid, req.pi_pmkid,
2026 req.pi_enable);
2027
Joe Perchesa1d46522011-02-02 14:05:56 -08002028 if (status) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002029 ret = -EIO;
2030 goto ioctl_done;
2031 }
2032 }
2033 break;
2034 }
2035#ifdef CONFIG_HOST_TCMD_SUPPORT
2036 case AR6000_XIOCTL_TCMD_CONT_TX:
2037 {
2038 TCMD_CONT_TX txCmd;
2039
2040 if ((ar->tcmdPm == TCMD_PM_SLEEP) ||
2041 (ar->tcmdPm == TCMD_PM_DEEPSLEEP))
2042 {
2043 A_PRINTF("Can NOT send tx tcmd when target is asleep! \n");
2044 ret = -EFAULT;
2045 goto ioctl_done;
2046 }
2047
2048 if(copy_from_user(&txCmd, userdata, sizeof(TCMD_CONT_TX))) {
2049 ret = -EFAULT;
2050 goto ioctl_done;
2051 } else {
Joe Perchesab3655d2011-02-02 14:05:49 -08002052 wmi_test_cmd(ar->arWmi,(u8 *)&txCmd, sizeof(TCMD_CONT_TX));
Vipin Mehta30295c82010-09-01 12:06:33 -07002053 }
2054 }
2055 break;
2056 case AR6000_XIOCTL_TCMD_CONT_RX:
2057 {
2058 TCMD_CONT_RX rxCmd;
2059
2060 if ((ar->tcmdPm == TCMD_PM_SLEEP) ||
2061 (ar->tcmdPm == TCMD_PM_DEEPSLEEP))
2062 {
2063 A_PRINTF("Can NOT send rx tcmd when target is asleep! \n");
2064 ret = -EFAULT;
2065 goto ioctl_done;
2066 }
2067 if(copy_from_user(&rxCmd, userdata, sizeof(TCMD_CONT_RX))) {
2068 ret = -EFAULT;
2069 goto ioctl_done;
2070 }
2071
2072 switch(rxCmd.act)
2073 {
2074 case TCMD_CONT_RX_PROMIS:
2075 case TCMD_CONT_RX_FILTER:
2076 case TCMD_CONT_RX_SETMAC:
2077 case TCMD_CONT_RX_SET_ANT_SWITCH_TABLE:
Joe Perchesab3655d2011-02-02 14:05:49 -08002078 wmi_test_cmd(ar->arWmi,(u8 *)&rxCmd,
Vipin Mehta30295c82010-09-01 12:06:33 -07002079 sizeof(TCMD_CONT_RX));
2080 tcmdRxFreq = rxCmd.u.para.freq;
2081 break;
2082 case TCMD_CONT_RX_REPORT:
2083 ar6000_ioctl_tcmd_get_rx_report(dev, rq,
Joe Perchesab3655d2011-02-02 14:05:49 -08002084 (u8 *)&rxCmd, sizeof(TCMD_CONT_RX));
Vipin Mehta30295c82010-09-01 12:06:33 -07002085 break;
2086 default:
2087 A_PRINTF("Unknown Cont Rx mode: %d\n",rxCmd.act);
2088 ret = -EINVAL;
2089 goto ioctl_done;
2090 }
2091 }
2092 break;
2093 case AR6000_XIOCTL_TCMD_PM:
2094 {
2095 TCMD_PM pmCmd;
2096
2097 if(copy_from_user(&pmCmd, userdata, sizeof(TCMD_PM))) {
2098 ret = -EFAULT;
2099 goto ioctl_done;
2100 }
2101 ar->tcmdPm = pmCmd.mode;
Joe Perchesab3655d2011-02-02 14:05:49 -08002102 wmi_test_cmd(ar->arWmi, (u8 *)&pmCmd, sizeof(TCMD_PM));
Vipin Mehta30295c82010-09-01 12:06:33 -07002103 }
2104 break;
2105#endif /* CONFIG_HOST_TCMD_SUPPORT */
2106
2107 case AR6000_XIOCTL_BMI_DONE:
2108 if(bmienable)
2109 {
2110 rtnl_lock(); /* ar6000_init expects to be called holding rtnl lock */
2111 ret = ar6000_init(dev);
2112 rtnl_unlock();
2113 }
2114 else
2115 {
2116 ret = BMIDone(hifDevice);
2117 }
2118 break;
2119
2120 case AR6000_XIOCTL_BMI_READ_MEMORY:
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002121 if (get_user(address, (unsigned int *)userdata) ||
2122 get_user(length, (unsigned int *)userdata + 1)) {
2123 ret = -EFAULT;
2124 break;
2125 }
2126
Vipin Mehta30295c82010-09-01 12:06:33 -07002127 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Read Memory (address: 0x%x, length: %d)\n",
2128 address, length));
2129 if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
2130 A_MEMZERO(buffer, length);
2131 ret = BMIReadMemory(hifDevice, address, buffer, length);
2132 if (copy_to_user(rq->ifr_data, buffer, length)) {
2133 ret = -EFAULT;
2134 }
2135 A_FREE(buffer);
2136 } else {
2137 ret = -ENOMEM;
2138 }
2139 break;
2140
2141 case AR6000_XIOCTL_BMI_WRITE_MEMORY:
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002142 if (get_user(address, (unsigned int *)userdata) ||
2143 get_user(length, (unsigned int *)userdata + 1)) {
2144 ret = -EFAULT;
2145 break;
2146 }
Vipin Mehta30295c82010-09-01 12:06:33 -07002147 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Write Memory (address: 0x%x, length: %d)\n",
2148 address, length));
2149 if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
2150 A_MEMZERO(buffer, length);
2151 if (copy_from_user(buffer, &userdata[sizeof(address) +
2152 sizeof(length)], length))
2153 {
2154 ret = -EFAULT;
2155 } else {
2156 ret = BMIWriteMemory(hifDevice, address, buffer, length);
2157 }
2158 A_FREE(buffer);
2159 } else {
2160 ret = -ENOMEM;
2161 }
2162 break;
2163
2164 case AR6000_XIOCTL_BMI_TEST:
2165 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("No longer supported\n"));
2166 ret = -EOPNOTSUPP;
2167 break;
2168
2169 case AR6000_XIOCTL_BMI_EXECUTE:
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002170 if (get_user(address, (unsigned int *)userdata) ||
2171 get_user(param, (unsigned int *)userdata + 1)) {
2172 ret = -EFAULT;
2173 break;
2174 }
Vipin Mehta30295c82010-09-01 12:06:33 -07002175 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Execute (address: 0x%x, param: %d)\n",
2176 address, param));
Joe Perchese1ce2a32011-02-02 14:05:51 -08002177 ret = BMIExecute(hifDevice, address, (u32 *)&param);
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002178 /* return value */
2179 if (put_user(param, (unsigned int *)rq->ifr_data)) {
2180 ret = -EFAULT;
2181 break;
2182 }
Vipin Mehta30295c82010-09-01 12:06:33 -07002183 break;
2184
2185 case AR6000_XIOCTL_BMI_SET_APP_START:
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002186 if (get_user(address, (unsigned int *)userdata)) {
2187 ret = -EFAULT;
2188 break;
2189 }
Vipin Mehta30295c82010-09-01 12:06:33 -07002190 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Set App Start (address: 0x%x)\n", address));
2191 ret = BMISetAppStart(hifDevice, address);
2192 break;
2193
2194 case AR6000_XIOCTL_BMI_READ_SOC_REGISTER:
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002195 if (get_user(address, (unsigned int *)userdata)) {
2196 ret = -EFAULT;
2197 break;
2198 }
Joe Perchese1ce2a32011-02-02 14:05:51 -08002199 ret = BMIReadSOCRegister(hifDevice, address, (u32 *)&param);
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002200 /* return value */
2201 if (put_user(param, (unsigned int *)rq->ifr_data)) {
2202 ret = -EFAULT;
2203 break;
2204 }
Vipin Mehta30295c82010-09-01 12:06:33 -07002205 break;
2206
2207 case AR6000_XIOCTL_BMI_WRITE_SOC_REGISTER:
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002208 if (get_user(address, (unsigned int *)userdata) ||
2209 get_user(param, (unsigned int *)userdata + 1)) {
2210 ret = -EFAULT;
2211 break;
2212 }
Vipin Mehta30295c82010-09-01 12:06:33 -07002213 ret = BMIWriteSOCRegister(hifDevice, address, param);
2214 break;
2215
2216#ifdef HTC_RAW_INTERFACE
2217 case AR6000_XIOCTL_HTC_RAW_OPEN:
Joe Perches4f69cef2011-02-02 14:05:57 -08002218 ret = 0;
Vipin Mehta30295c82010-09-01 12:06:33 -07002219 if (!arRawIfEnabled(ar)) {
2220 /* make sure block size is set in case the target was reset since last
2221 * BMI phase (i.e. flashup downloads) */
2222 ret = ar6000_set_htc_params(ar->arHifDevice,
2223 ar->arTargetType,
2224 0, /* use default yield */
2225 0 /* use default number of HTC ctrl buffers */
2226 );
Joe Perches391bb212011-01-27 20:04:21 -08002227 if (ret) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002228 break;
2229 }
2230 /* Terminate the BMI phase */
2231 ret = BMIDone(hifDevice);
Joe Perches4f69cef2011-02-02 14:05:57 -08002232 if (ret == 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002233 ret = ar6000_htc_raw_open(ar);
2234 }
2235 }
2236 break;
2237
2238 case AR6000_XIOCTL_HTC_RAW_CLOSE:
2239 if (arRawIfEnabled(ar)) {
2240 ret = ar6000_htc_raw_close(ar);
Joe Perches1071a132011-02-02 14:05:47 -08002241 arRawIfEnabled(ar) = false;
Vipin Mehta30295c82010-09-01 12:06:33 -07002242 } else {
2243 ret = A_ERROR;
2244 }
2245 break;
2246
2247 case AR6000_XIOCTL_HTC_RAW_READ:
2248 if (arRawIfEnabled(ar)) {
2249 unsigned int streamID;
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002250 if (get_user(streamID, (unsigned int *)userdata) ||
2251 get_user(length, (unsigned int *)userdata + 1)) {
2252 ret = -EFAULT;
2253 break;
2254 }
Vipin Mehta30295c82010-09-01 12:06:33 -07002255 buffer = (unsigned char*)rq->ifr_data + sizeof(length);
2256 ret = ar6000_htc_raw_read(ar, (HTC_RAW_STREAM_ID)streamID,
2257 (char*)buffer, length);
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002258 if (put_user(ret, (unsigned int *)rq->ifr_data)) {
2259 ret = -EFAULT;
2260 break;
2261 }
Vipin Mehta30295c82010-09-01 12:06:33 -07002262 } else {
2263 ret = A_ERROR;
2264 }
2265 break;
2266
2267 case AR6000_XIOCTL_HTC_RAW_WRITE:
2268 if (arRawIfEnabled(ar)) {
2269 unsigned int streamID;
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002270 if (get_user(streamID, (unsigned int *)userdata) ||
2271 get_user(length, (unsigned int *)userdata + 1)) {
2272 ret = -EFAULT;
2273 break;
2274 }
Vipin Mehta30295c82010-09-01 12:06:33 -07002275 buffer = (unsigned char*)userdata + sizeof(streamID) + sizeof(length);
2276 ret = ar6000_htc_raw_write(ar, (HTC_RAW_STREAM_ID)streamID,
2277 (char*)buffer, length);
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002278 if (put_user(ret, (unsigned int *)rq->ifr_data)) {
2279 ret = -EFAULT;
2280 break;
2281 }
Vipin Mehta30295c82010-09-01 12:06:33 -07002282 } else {
2283 ret = A_ERROR;
2284 }
2285 break;
2286#endif /* HTC_RAW_INTERFACE */
2287
2288 case AR6000_XIOCTL_BMI_LZ_STREAM_START:
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002289 if (get_user(address, (unsigned int *)userdata)) {
2290 ret = -EFAULT;
2291 break;
2292 }
Vipin Mehta30295c82010-09-01 12:06:33 -07002293 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Start Compressed Stream (address: 0x%x)\n", address));
2294 ret = BMILZStreamStart(hifDevice, address);
2295 break;
2296
2297 case AR6000_XIOCTL_BMI_LZ_DATA:
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002298 if (get_user(length, (unsigned int *)userdata)) {
2299 ret = -EFAULT;
2300 break;
2301 }
Vipin Mehta30295c82010-09-01 12:06:33 -07002302 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Send Compressed Data (length: %d)\n", length));
2303 if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
2304 A_MEMZERO(buffer, length);
2305 if (copy_from_user(buffer, &userdata[sizeof(length)], length))
2306 {
2307 ret = -EFAULT;
2308 } else {
2309 ret = BMILZData(hifDevice, buffer, length);
2310 }
2311 A_FREE(buffer);
2312 } else {
2313 ret = -ENOMEM;
2314 }
2315 break;
2316
2317#if defined(CONFIG_TARGET_PROFILE_SUPPORT)
2318 /*
2319 * Optional support for Target-side profiling.
2320 * Not needed in production.
2321 */
2322
2323 /* Configure Target-side profiling */
2324 case AR6000_XIOCTL_PROF_CFG:
2325 {
Joe Perchese1ce2a32011-02-02 14:05:51 -08002326 u32 period;
2327 u32 nbins;
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002328 if (get_user(period, (unsigned int *)userdata) ||
2329 get_user(nbins, (unsigned int *)userdata + 1)) {
2330 ret = -EFAULT;
2331 break;
2332 }
Vipin Mehta30295c82010-09-01 12:06:33 -07002333
Joe Perches4f69cef2011-02-02 14:05:57 -08002334 if (wmi_prof_cfg_cmd(ar->arWmi, period, nbins) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002335 ret = -EIO;
2336 }
2337
2338 break;
2339 }
2340
2341 /* Start a profiling bucket/bin at the specified address */
2342 case AR6000_XIOCTL_PROF_ADDR_SET:
2343 {
Joe Perchese1ce2a32011-02-02 14:05:51 -08002344 u32 addr;
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002345 if (get_user(addr, (unsigned int *)userdata)) {
2346 ret = -EFAULT;
2347 break;
2348 }
Vipin Mehta30295c82010-09-01 12:06:33 -07002349
Joe Perches4f69cef2011-02-02 14:05:57 -08002350 if (wmi_prof_addr_set_cmd(ar->arWmi, addr) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002351 ret = -EIO;
2352 }
2353
2354 break;
2355 }
2356
2357 /* START Target-side profiling */
2358 case AR6000_XIOCTL_PROF_START:
2359 wmi_prof_start_cmd(ar->arWmi);
2360 break;
2361
2362 /* STOP Target-side profiling */
2363 case AR6000_XIOCTL_PROF_STOP:
2364 wmi_prof_stop_cmd(ar->arWmi);
2365 break;
2366 case AR6000_XIOCTL_PROF_COUNT_GET:
2367 {
2368 if (ar->bIsDestroyProgress) {
2369 ret = -EBUSY;
2370 goto ioctl_done;
2371 }
Joe Perches1071a132011-02-02 14:05:47 -08002372 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002373 ret = -EIO;
2374 goto ioctl_done;
2375 }
2376 if (down_interruptible(&ar->arSem)) {
2377 ret = -ERESTARTSYS;
2378 goto ioctl_done;
2379 }
2380 if (ar->bIsDestroyProgress) {
2381 up(&ar->arSem);
2382 ret = -EBUSY;
2383 goto ioctl_done;
2384 }
2385
Joe Perches1071a132011-02-02 14:05:47 -08002386 prof_count_available = false;
Vipin Mehta30295c82010-09-01 12:06:33 -07002387 ret = prof_count_get(dev);
Joe Perches4f69cef2011-02-02 14:05:57 -08002388 if (ret != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002389 up(&ar->arSem);
2390 ret = -EIO;
2391 goto ioctl_done;
2392 }
2393
2394 /* Wait for Target to respond. */
2395 wait_event_interruptible(arEvent, prof_count_available);
2396 if (signal_pending(current)) {
2397 ret = -EINTR;
2398 } else {
2399 if (copy_to_user(userdata, &prof_count_results,
2400 sizeof(prof_count_results)))
2401 {
2402 ret = -EFAULT;
2403 }
2404 }
2405 up(&ar->arSem);
2406 break;
2407 }
2408#endif /* CONFIG_TARGET_PROFILE_SUPPORT */
2409
2410 case AR6000_IOCTL_WMI_GETREV:
2411 {
2412 if (copy_to_user(rq->ifr_data, &ar->arVersion,
2413 sizeof(ar->arVersion)))
2414 {
2415 ret = -EFAULT;
2416 }
2417 break;
2418 }
2419 case AR6000_IOCTL_WMI_SETPWR:
2420 {
2421 WMI_POWER_MODE_CMD pwrModeCmd;
2422
Joe Perches1071a132011-02-02 14:05:47 -08002423 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002424 ret = -EIO;
2425 } else if (copy_from_user(&pwrModeCmd, userdata,
2426 sizeof(pwrModeCmd)))
2427 {
2428 ret = -EFAULT;
2429 } else {
2430 if (wmi_powermode_cmd(ar->arWmi, pwrModeCmd.powerMode)
Joe Perches4f69cef2011-02-02 14:05:57 -08002431 != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07002432 {
2433 ret = -EIO;
2434 }
2435 }
2436 break;
2437 }
2438 case AR6000_IOCTL_WMI_SET_IBSS_PM_CAPS:
2439 {
2440 WMI_IBSS_PM_CAPS_CMD ibssPmCaps;
2441
Joe Perches1071a132011-02-02 14:05:47 -08002442 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002443 ret = -EIO;
2444 } else if (copy_from_user(&ibssPmCaps, userdata,
2445 sizeof(ibssPmCaps)))
2446 {
2447 ret = -EFAULT;
2448 } else {
2449 if (wmi_ibsspmcaps_cmd(ar->arWmi, ibssPmCaps.power_saving, ibssPmCaps.ttl,
Joe Perches4f69cef2011-02-02 14:05:57 -08002450 ibssPmCaps.atim_windows, ibssPmCaps.timeout_value) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07002451 {
2452 ret = -EIO;
2453 }
2454 AR6000_SPIN_LOCK(&ar->arLock, 0);
2455 ar->arIbssPsEnable = ibssPmCaps.power_saving;
2456 AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2457 }
2458 break;
2459 }
2460 case AR6000_XIOCTL_WMI_SET_AP_PS:
2461 {
2462 WMI_AP_PS_CMD apPsCmd;
2463
Joe Perches1071a132011-02-02 14:05:47 -08002464 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002465 ret = -EIO;
2466 } else if (copy_from_user(&apPsCmd, userdata,
2467 sizeof(apPsCmd)))
2468 {
2469 ret = -EFAULT;
2470 } else {
2471 if (wmi_apps_cmd(ar->arWmi, apPsCmd.psType, apPsCmd.idle_time,
Joe Perches4f69cef2011-02-02 14:05:57 -08002472 apPsCmd.ps_period, apPsCmd.sleep_period) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07002473 {
2474 ret = -EIO;
2475 }
2476 }
2477 break;
2478 }
2479 case AR6000_IOCTL_WMI_SET_PMPARAMS:
2480 {
2481 WMI_POWER_PARAMS_CMD pmParams;
2482
Joe Perches1071a132011-02-02 14:05:47 -08002483 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002484 ret = -EIO;
2485 } else if (copy_from_user(&pmParams, userdata,
2486 sizeof(pmParams)))
2487 {
2488 ret = -EFAULT;
2489 } else {
2490 if (wmi_pmparams_cmd(ar->arWmi, pmParams.idle_period,
2491 pmParams.pspoll_number,
2492 pmParams.dtim_policy,
2493 pmParams.tx_wakeup_policy,
2494 pmParams.num_tx_to_wakeup,
2495#if WLAN_CONFIG_IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
2496 IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
2497#else
2498 SEND_POWER_SAVE_FAIL_EVENT_ALWAYS
2499#endif
Joe Perches4f69cef2011-02-02 14:05:57 -08002500 ) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07002501 {
2502 ret = -EIO;
2503 }
2504 }
2505 break;
2506 }
2507 case AR6000_IOCTL_WMI_SETSCAN:
2508 {
Joe Perches1071a132011-02-02 14:05:47 -08002509 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002510 ret = -EIO;
2511 } else if (copy_from_user(&ar->scParams, userdata,
2512 sizeof(ar->scParams)))
2513 {
2514 ret = -EFAULT;
2515 } else {
2516 if (CAN_SCAN_IN_CONNECT(ar->scParams.scanCtrlFlags)) {
Joe Perches1071a132011-02-02 14:05:47 -08002517 ar->arSkipScan = false;
Vipin Mehta30295c82010-09-01 12:06:33 -07002518 } else {
Joe Perches1071a132011-02-02 14:05:47 -08002519 ar->arSkipScan = true;
Vipin Mehta30295c82010-09-01 12:06:33 -07002520 }
2521
2522 if (wmi_scanparams_cmd(ar->arWmi, ar->scParams.fg_start_period,
2523 ar->scParams.fg_end_period,
2524 ar->scParams.bg_period,
2525 ar->scParams.minact_chdwell_time,
2526 ar->scParams.maxact_chdwell_time,
2527 ar->scParams.pas_chdwell_time,
2528 ar->scParams.shortScanRatio,
2529 ar->scParams.scanCtrlFlags,
2530 ar->scParams.max_dfsch_act_time,
Joe Perches4f69cef2011-02-02 14:05:57 -08002531 ar->scParams.maxact_scan_per_ssid) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07002532 {
2533 ret = -EIO;
2534 }
2535 }
2536 break;
2537 }
2538 case AR6000_IOCTL_WMI_SETLISTENINT:
2539 {
2540 WMI_LISTEN_INT_CMD listenCmd;
2541
Joe Perches1071a132011-02-02 14:05:47 -08002542 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002543 ret = -EIO;
2544 } else if (copy_from_user(&listenCmd, userdata,
2545 sizeof(listenCmd)))
2546 {
2547 ret = -EFAULT;
2548 } else {
Joe Perches4f69cef2011-02-02 14:05:57 -08002549 if (wmi_listeninterval_cmd(ar->arWmi, listenCmd.listenInterval, listenCmd.numBeacons) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002550 ret = -EIO;
2551 } else {
2552 AR6000_SPIN_LOCK(&ar->arLock, 0);
2553 ar->arListenIntervalT = listenCmd.listenInterval;
2554 ar->arListenIntervalB = listenCmd.numBeacons;
2555 AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2556 }
2557
2558 }
2559 break;
2560 }
2561 case AR6000_IOCTL_WMI_SET_BMISS_TIME:
2562 {
2563 WMI_BMISS_TIME_CMD bmissCmd;
2564
Joe Perches1071a132011-02-02 14:05:47 -08002565 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002566 ret = -EIO;
2567 } else if (copy_from_user(&bmissCmd, userdata,
2568 sizeof(bmissCmd)))
2569 {
2570 ret = -EFAULT;
2571 } else {
Joe Perches4f69cef2011-02-02 14:05:57 -08002572 if (wmi_bmisstime_cmd(ar->arWmi, bmissCmd.bmissTime, bmissCmd.numBeacons) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002573 ret = -EIO;
2574 }
2575 }
2576 break;
2577 }
2578 case AR6000_IOCTL_WMI_SETBSSFILTER:
2579 {
2580 WMI_BSS_FILTER_CMD filt;
2581
Joe Perches1071a132011-02-02 14:05:47 -08002582 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002583 ret = -EIO;
2584 } else if (copy_from_user(&filt, userdata,
2585 sizeof(filt)))
2586 {
2587 ret = -EFAULT;
2588 } else {
2589 if (wmi_bssfilter_cmd(ar->arWmi, filt.bssFilter, filt.ieMask)
Joe Perches4f69cef2011-02-02 14:05:57 -08002590 != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002591 ret = -EIO;
2592 } else {
2593 ar->arUserBssFilter = param;
2594 }
2595 }
2596 break;
2597 }
2598
2599 case AR6000_IOCTL_WMI_SET_SNRTHRESHOLD:
2600 {
2601 ret = ar6000_ioctl_set_snr_threshold(dev, rq);
2602 break;
2603 }
2604 case AR6000_XIOCTL_WMI_SET_RSSITHRESHOLD:
2605 {
2606 ret = ar6000_ioctl_set_rssi_threshold(dev, rq);
2607 break;
2608 }
2609 case AR6000_XIOCTL_WMI_CLR_RSSISNR:
2610 {
Joe Perches1071a132011-02-02 14:05:47 -08002611 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002612 ret = -EIO;
2613 }
2614 ret = wmi_clr_rssi_snr(ar->arWmi);
2615 break;
2616 }
2617 case AR6000_XIOCTL_WMI_SET_LQTHRESHOLD:
2618 {
2619 ret = ar6000_ioctl_set_lq_threshold(dev, rq);
2620 break;
2621 }
2622 case AR6000_XIOCTL_WMI_SET_LPREAMBLE:
2623 {
2624 WMI_SET_LPREAMBLE_CMD setLpreambleCmd;
2625
Joe Perches1071a132011-02-02 14:05:47 -08002626 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002627 ret = -EIO;
2628 } else if (copy_from_user(&setLpreambleCmd, userdata,
2629 sizeof(setLpreambleCmd)))
2630 {
2631 ret = -EFAULT;
2632 } else {
2633 if (wmi_set_lpreamble_cmd(ar->arWmi, setLpreambleCmd.status,
2634#if WLAN_CONFIG_DONOT_IGNORE_BARKER_IN_ERP
2635 WMI_DONOT_IGNORE_BARKER_IN_ERP
2636#else
2637 WMI_IGNORE_BARKER_IN_ERP
2638#endif
Joe Perches4f69cef2011-02-02 14:05:57 -08002639 ) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07002640 {
2641 ret = -EIO;
2642 }
2643 }
2644
2645 break;
2646 }
2647 case AR6000_XIOCTL_WMI_SET_RTS:
2648 {
2649 WMI_SET_RTS_CMD rtsCmd;
Joe Perches1071a132011-02-02 14:05:47 -08002650 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002651 ret = -EIO;
2652 } else if (copy_from_user(&rtsCmd, userdata,
2653 sizeof(rtsCmd)))
2654 {
2655 ret = -EFAULT;
2656 } else {
2657 ar->arRTS = rtsCmd.threshold;
2658 if (wmi_set_rts_cmd(ar->arWmi, rtsCmd.threshold)
Joe Perches4f69cef2011-02-02 14:05:57 -08002659 != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07002660 {
2661 ret = -EIO;
2662 }
2663 }
2664
2665 break;
2666 }
2667 case AR6000_XIOCTL_WMI_SET_WMM:
2668 {
2669 ret = ar6000_ioctl_set_wmm(dev, rq);
2670 break;
2671 }
2672 case AR6000_XIOCTL_WMI_SET_QOS_SUPP:
2673 {
2674 ret = ar6000_ioctl_set_qos_supp(dev, rq);
2675 break;
2676 }
2677 case AR6000_XIOCTL_WMI_SET_TXOP:
2678 {
2679 ret = ar6000_ioctl_set_txop(dev, rq);
2680 break;
2681 }
2682 case AR6000_XIOCTL_WMI_GET_RD:
2683 {
2684 ret = ar6000_ioctl_get_rd(dev, rq);
2685 break;
2686 }
2687 case AR6000_IOCTL_WMI_SET_CHANNELPARAMS:
2688 {
2689 ret = ar6000_ioctl_set_channelParams(dev, rq);
2690 break;
2691 }
2692 case AR6000_IOCTL_WMI_SET_PROBEDSSID:
2693 {
2694 ret = ar6000_ioctl_set_probedSsid(dev, rq);
2695 break;
2696 }
2697 case AR6000_IOCTL_WMI_SET_BADAP:
2698 {
2699 ret = ar6000_ioctl_set_badAp(dev, rq);
2700 break;
2701 }
2702 case AR6000_IOCTL_WMI_CREATE_QOS:
2703 {
2704 ret = ar6000_ioctl_create_qos(dev, rq);
2705 break;
2706 }
2707 case AR6000_IOCTL_WMI_DELETE_QOS:
2708 {
2709 ret = ar6000_ioctl_delete_qos(dev, rq);
2710 break;
2711 }
2712 case AR6000_IOCTL_WMI_GET_QOS_QUEUE:
2713 {
2714 ret = ar6000_ioctl_get_qos_queue(dev, rq);
2715 break;
2716 }
2717 case AR6000_IOCTL_WMI_GET_TARGET_STATS:
2718 {
2719 ret = ar6000_ioctl_get_target_stats(dev, rq);
2720 break;
2721 }
2722 case AR6000_IOCTL_WMI_SET_ERROR_REPORT_BITMASK:
2723 {
2724 ret = ar6000_ioctl_set_error_report_bitmask(dev, rq);
2725 break;
2726 }
2727 case AR6000_IOCTL_WMI_SET_ASSOC_INFO:
2728 {
2729 WMI_SET_ASSOC_INFO_CMD cmd;
Joe Perchesab3655d2011-02-02 14:05:49 -08002730 u8 assocInfo[WMI_MAX_ASSOC_INFO_LEN];
Vipin Mehta30295c82010-09-01 12:06:33 -07002731
Joe Perches1071a132011-02-02 14:05:47 -08002732 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002733 ret = -EIO;
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002734 break;
2735 }
2736
Vipin Mehtab6c78752010-09-07 17:06:50 -07002737 if (get_user(cmd.ieType, userdata)) {
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002738 ret = -EFAULT;
2739 break;
2740 }
2741 if (cmd.ieType >= WMI_MAX_ASSOC_INFO_TYPE) {
2742 ret = -EIO;
2743 break;
2744 }
2745
2746 if (get_user(cmd.bufferSize, userdata + 1) ||
2747 (cmd.bufferSize > WMI_MAX_ASSOC_INFO_LEN) ||
2748 copy_from_user(assocInfo, userdata + 2, cmd.bufferSize)) {
2749 ret = -EFAULT;
2750 break;
2751 }
2752 if (wmi_associnfo_cmd(ar->arWmi, cmd.ieType,
Joe Perches4f69cef2011-02-02 14:05:57 -08002753 cmd.bufferSize, assocInfo) != 0) {
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04002754 ret = -EIO;
2755 break;
2756 }
Vipin Mehta30295c82010-09-01 12:06:33 -07002757 break;
2758 }
2759 case AR6000_IOCTL_WMI_SET_ACCESS_PARAMS:
2760 {
2761 ret = ar6000_ioctl_set_access_params(dev, rq);
2762 break;
2763 }
2764 case AR6000_IOCTL_WMI_SET_DISC_TIMEOUT:
2765 {
2766 ret = ar6000_ioctl_set_disconnect_timeout(dev, rq);
2767 break;
2768 }
2769 case AR6000_XIOCTL_FORCE_TARGET_RESET:
2770 {
2771 if (ar->arHtcTarget)
2772 {
2773// HTCForceReset(htcTarget);
2774 }
2775 else
2776 {
2777 AR_DEBUG_PRINTF(ATH_DEBUG_WARN,("ar6000_ioctl cannot attempt reset.\n"));
2778 }
2779 break;
2780 }
2781 case AR6000_XIOCTL_TARGET_INFO:
2782 case AR6000_XIOCTL_CHECK_TARGET_READY: /* backwards compatibility */
2783 {
2784 /* If we made it to here, then the Target exists and is ready. */
2785
2786 if (cmd == AR6000_XIOCTL_TARGET_INFO) {
Joe Perchese1ce2a32011-02-02 14:05:51 -08002787 if (copy_to_user((u32 *)rq->ifr_data, &ar->arVersion.target_ver,
Vipin Mehta30295c82010-09-01 12:06:33 -07002788 sizeof(ar->arVersion.target_ver)))
2789 {
2790 ret = -EFAULT;
2791 }
Joe Perchese1ce2a32011-02-02 14:05:51 -08002792 if (copy_to_user(((u32 *)rq->ifr_data)+1, &ar->arTargetType,
Vipin Mehta30295c82010-09-01 12:06:33 -07002793 sizeof(ar->arTargetType)))
2794 {
2795 ret = -EFAULT;
2796 }
2797 }
2798 break;
2799 }
2800 case AR6000_XIOCTL_WMI_SET_HB_CHALLENGE_RESP_PARAMS:
2801 {
2802 WMI_SET_HB_CHALLENGE_RESP_PARAMS_CMD hbparam;
2803
2804 if (copy_from_user(&hbparam, userdata, sizeof(hbparam)))
2805 {
2806 ret = -EFAULT;
2807 } else {
2808 AR6000_SPIN_LOCK(&ar->arLock, 0);
2809 /* Start a cyclic timer with the parameters provided. */
2810 if (hbparam.frequency) {
2811 ar->arHBChallengeResp.frequency = hbparam.frequency;
2812 }
2813 if (hbparam.threshold) {
2814 ar->arHBChallengeResp.missThres = hbparam.threshold;
2815 }
2816
2817 /* Delete the pending timer and start a new one */
2818 if (timer_pending(&ar->arHBChallengeResp.timer)) {
2819 A_UNTIMEOUT(&ar->arHBChallengeResp.timer);
2820 }
2821 A_TIMEOUT_MS(&ar->arHBChallengeResp.timer, ar->arHBChallengeResp.frequency * 1000, 0);
2822 AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2823 }
2824 break;
2825 }
2826 case AR6000_XIOCTL_WMI_GET_HB_CHALLENGE_RESP:
2827 {
Joe Perchese1ce2a32011-02-02 14:05:51 -08002828 u32 cookie;
Vipin Mehta30295c82010-09-01 12:06:33 -07002829
2830 if (copy_from_user(&cookie, userdata, sizeof(cookie))) {
2831 ret = -EFAULT;
2832 goto ioctl_done;
2833 }
2834
2835 /* Send the challenge on the control channel */
Joe Perches4f69cef2011-02-02 14:05:57 -08002836 if (wmi_get_challenge_resp_cmd(ar->arWmi, cookie, APP_HB_CHALLENGE) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002837 ret = -EIO;
2838 goto ioctl_done;
2839 }
2840 break;
2841 }
2842#ifdef USER_KEYS
2843 case AR6000_XIOCTL_USER_SETKEYS:
2844 {
2845
2846 ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_RUN;
2847
2848 if (copy_from_user(&ar->user_key_ctrl, userdata,
2849 sizeof(ar->user_key_ctrl)))
2850 {
2851 ret = -EFAULT;
2852 goto ioctl_done;
2853 }
2854
2855 A_PRINTF("ar6000 USER set key %x\n", ar->user_key_ctrl);
2856 break;
2857 }
2858#endif /* USER_KEYS */
2859
2860#ifdef CONFIG_HOST_GPIO_SUPPORT
2861 case AR6000_XIOCTL_GPIO_OUTPUT_SET:
2862 {
2863 struct ar6000_gpio_output_set_cmd_s gpio_output_set_cmd;
2864
2865 if (ar->bIsDestroyProgress) {
2866 ret = -EBUSY;
2867 goto ioctl_done;
2868 }
Joe Perches1071a132011-02-02 14:05:47 -08002869 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002870 ret = -EIO;
2871 goto ioctl_done;
2872 }
2873 if (down_interruptible(&ar->arSem)) {
2874 ret = -ERESTARTSYS;
2875 goto ioctl_done;
2876 }
2877 if (ar->bIsDestroyProgress) {
2878 up(&ar->arSem);
2879 ret = -EBUSY;
2880 goto ioctl_done;
2881 }
2882
2883 if (copy_from_user(&gpio_output_set_cmd, userdata,
2884 sizeof(gpio_output_set_cmd)))
2885 {
2886 ret = -EFAULT;
2887 } else {
2888 ret = ar6000_gpio_output_set(dev,
2889 gpio_output_set_cmd.set_mask,
2890 gpio_output_set_cmd.clear_mask,
2891 gpio_output_set_cmd.enable_mask,
2892 gpio_output_set_cmd.disable_mask);
Joe Perches4f69cef2011-02-02 14:05:57 -08002893 if (ret != 0) {
Ralph Loader3ec60802011-01-21 19:27:53 +13002894 ret = -EIO;
Vipin Mehta30295c82010-09-01 12:06:33 -07002895 }
2896 }
2897 up(&ar->arSem);
2898 break;
2899 }
2900 case AR6000_XIOCTL_GPIO_INPUT_GET:
2901 {
2902 if (ar->bIsDestroyProgress) {
2903 ret = -EBUSY;
2904 goto ioctl_done;
2905 }
Joe Perches1071a132011-02-02 14:05:47 -08002906 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002907 ret = -EIO;
2908 goto ioctl_done;
2909 }
2910 if (down_interruptible(&ar->arSem)) {
2911 ret = -ERESTARTSYS;
2912 goto ioctl_done;
2913 }
2914 if (ar->bIsDestroyProgress) {
2915 up(&ar->arSem);
2916 ret = -EBUSY;
2917 goto ioctl_done;
2918 }
2919
2920 ret = ar6000_gpio_input_get(dev);
Joe Perches4f69cef2011-02-02 14:05:57 -08002921 if (ret != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002922 up(&ar->arSem);
2923 ret = -EIO;
2924 goto ioctl_done;
2925 }
2926
2927 /* Wait for Target to respond. */
2928 wait_event_interruptible(arEvent, gpio_data_available);
2929 if (signal_pending(current)) {
2930 ret = -EINTR;
2931 } else {
2932 A_ASSERT(gpio_reg_results.gpioreg_id == GPIO_ID_NONE);
2933
2934 if (copy_to_user(userdata, &gpio_reg_results.value,
2935 sizeof(gpio_reg_results.value)))
2936 {
2937 ret = -EFAULT;
2938 }
2939 }
2940 up(&ar->arSem);
2941 break;
2942 }
2943 case AR6000_XIOCTL_GPIO_REGISTER_SET:
2944 {
2945 struct ar6000_gpio_register_cmd_s gpio_register_cmd;
2946
2947 if (ar->bIsDestroyProgress) {
2948 ret = -EBUSY;
2949 goto ioctl_done;
2950 }
Joe Perches1071a132011-02-02 14:05:47 -08002951 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002952 ret = -EIO;
2953 goto ioctl_done;
2954 }
2955 if (down_interruptible(&ar->arSem)) {
2956 ret = -ERESTARTSYS;
2957 goto ioctl_done;
2958 }
2959 if (ar->bIsDestroyProgress) {
2960 up(&ar->arSem);
2961 ret = -EBUSY;
2962 goto ioctl_done;
2963 }
2964
2965 if (copy_from_user(&gpio_register_cmd, userdata,
2966 sizeof(gpio_register_cmd)))
2967 {
2968 ret = -EFAULT;
2969 } else {
2970 ret = ar6000_gpio_register_set(dev,
2971 gpio_register_cmd.gpioreg_id,
2972 gpio_register_cmd.value);
Joe Perches4f69cef2011-02-02 14:05:57 -08002973 if (ret != 0) {
Ralph Loader3ec60802011-01-21 19:27:53 +13002974 ret = -EIO;
Vipin Mehta30295c82010-09-01 12:06:33 -07002975 }
2976
2977 /* Wait for acknowledgement from Target */
2978 wait_event_interruptible(arEvent, gpio_ack_received);
2979 if (signal_pending(current)) {
2980 ret = -EINTR;
2981 }
2982 }
2983 up(&ar->arSem);
2984 break;
2985 }
2986 case AR6000_XIOCTL_GPIO_REGISTER_GET:
2987 {
2988 struct ar6000_gpio_register_cmd_s gpio_register_cmd;
2989
2990 if (ar->bIsDestroyProgress) {
2991 ret = -EBUSY;
2992 goto ioctl_done;
2993 }
Joe Perches1071a132011-02-02 14:05:47 -08002994 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07002995 ret = -EIO;
2996 goto ioctl_done;
2997 }
2998 if (down_interruptible(&ar->arSem)) {
2999 ret = -ERESTARTSYS;
3000 goto ioctl_done;
3001 }
3002 if (ar->bIsDestroyProgress) {
3003 up(&ar->arSem);
3004 ret = -EBUSY;
3005 goto ioctl_done;
3006 }
3007
3008 if (copy_from_user(&gpio_register_cmd, userdata,
3009 sizeof(gpio_register_cmd)))
3010 {
3011 ret = -EFAULT;
3012 } else {
3013 ret = ar6000_gpio_register_get(dev, gpio_register_cmd.gpioreg_id);
Joe Perches4f69cef2011-02-02 14:05:57 -08003014 if (ret != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003015 up(&ar->arSem);
3016 ret = -EIO;
3017 goto ioctl_done;
3018 }
3019
3020 /* Wait for Target to respond. */
3021 wait_event_interruptible(arEvent, gpio_data_available);
3022 if (signal_pending(current)) {
3023 ret = -EINTR;
3024 } else {
3025 A_ASSERT(gpio_register_cmd.gpioreg_id == gpio_reg_results.gpioreg_id);
3026 if (copy_to_user(userdata, &gpio_reg_results,
3027 sizeof(gpio_reg_results)))
3028 {
3029 ret = -EFAULT;
3030 }
3031 }
3032 }
3033 up(&ar->arSem);
3034 break;
3035 }
3036 case AR6000_XIOCTL_GPIO_INTR_ACK:
3037 {
3038 struct ar6000_gpio_intr_ack_cmd_s gpio_intr_ack_cmd;
3039
3040 if (ar->bIsDestroyProgress) {
3041 ret = -EBUSY;
3042 goto ioctl_done;
3043 }
Joe Perches1071a132011-02-02 14:05:47 -08003044 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003045 ret = -EIO;
3046 goto ioctl_done;
3047 }
3048 if (down_interruptible(&ar->arSem)) {
3049 ret = -ERESTARTSYS;
3050 goto ioctl_done;
3051 }
3052 if (ar->bIsDestroyProgress) {
3053 up(&ar->arSem);
3054 ret = -EBUSY;
3055 goto ioctl_done;
3056 }
3057
3058 if (copy_from_user(&gpio_intr_ack_cmd, userdata,
3059 sizeof(gpio_intr_ack_cmd)))
3060 {
3061 ret = -EFAULT;
3062 } else {
3063 ret = ar6000_gpio_intr_ack(dev, gpio_intr_ack_cmd.ack_mask);
Joe Perches4f69cef2011-02-02 14:05:57 -08003064 if (ret != 0) {
Ralph Loader3ec60802011-01-21 19:27:53 +13003065 ret = -EIO;
Vipin Mehta30295c82010-09-01 12:06:33 -07003066 }
3067 }
3068 up(&ar->arSem);
3069 break;
3070 }
3071 case AR6000_XIOCTL_GPIO_INTR_WAIT:
3072 {
3073 /* Wait for Target to report an interrupt. */
3074 wait_event_interruptible(arEvent, gpio_intr_available);
3075
3076 if (signal_pending(current)) {
3077 ret = -EINTR;
3078 } else {
3079 if (copy_to_user(userdata, &gpio_intr_results,
3080 sizeof(gpio_intr_results)))
3081 {
3082 ret = -EFAULT;
3083 }
3084 }
3085 break;
3086 }
3087#endif /* CONFIG_HOST_GPIO_SUPPORT */
3088
3089 case AR6000_XIOCTL_DBGLOG_CFG_MODULE:
3090 {
3091 struct ar6000_dbglog_module_config_s config;
3092
3093 if (copy_from_user(&config, userdata, sizeof(config))) {
3094 ret = -EFAULT;
3095 goto ioctl_done;
3096 }
3097
3098 /* Send the challenge on the control channel */
3099 if (wmi_config_debug_module_cmd(ar->arWmi, config.mmask,
3100 config.tsr, config.rep,
Joe Perches4f69cef2011-02-02 14:05:57 -08003101 config.size, config.valid) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003102 {
3103 ret = -EIO;
3104 goto ioctl_done;
3105 }
3106 break;
3107 }
3108
3109 case AR6000_XIOCTL_DBGLOG_GET_DEBUG_LOGS:
3110 {
3111 /* Send the challenge on the control channel */
Joe Perches4f69cef2011-02-02 14:05:57 -08003112 if (ar6000_dbglog_get_debug_logs(ar) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003113 {
3114 ret = -EIO;
3115 goto ioctl_done;
3116 }
3117 break;
3118 }
3119
3120 case AR6000_XIOCTL_SET_ADHOC_BSSID:
3121 {
3122 WMI_SET_ADHOC_BSSID_CMD adhocBssid;
3123
Joe Perches1071a132011-02-02 14:05:47 -08003124 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003125 ret = -EIO;
3126 } else if (copy_from_user(&adhocBssid, userdata,
3127 sizeof(adhocBssid)))
3128 {
3129 ret = -EFAULT;
3130 } else if (A_MEMCMP(adhocBssid.bssid, bcast_mac,
3131 AR6000_ETH_ADDR_LEN) == 0)
3132 {
3133 ret = -EFAULT;
3134 } else {
3135
3136 A_MEMCPY(ar->arReqBssid, adhocBssid.bssid, sizeof(ar->arReqBssid));
3137 }
3138 break;
3139 }
3140
3141 case AR6000_XIOCTL_SET_OPT_MODE:
3142 {
3143 WMI_SET_OPT_MODE_CMD optModeCmd;
3144 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
3145
Joe Perches1071a132011-02-02 14:05:47 -08003146 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003147 ret = -EIO;
3148 } else if (copy_from_user(&optModeCmd, userdata,
3149 sizeof(optModeCmd)))
3150 {
3151 ret = -EFAULT;
3152 } else if (ar->arConnected && optModeCmd.optMode == SPECIAL_ON) {
3153 ret = -EFAULT;
3154
3155 } else if (wmi_set_opt_mode_cmd(ar->arWmi, optModeCmd.optMode)
Joe Perches4f69cef2011-02-02 14:05:57 -08003156 != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003157 {
3158 ret = -EIO;
3159 }
3160 break;
3161 }
3162
3163 case AR6000_XIOCTL_OPT_SEND_FRAME:
3164 {
3165 WMI_OPT_TX_FRAME_CMD optTxFrmCmd;
Joe Perchesab3655d2011-02-02 14:05:49 -08003166 u8 data[MAX_OPT_DATA_LEN];
Vipin Mehta30295c82010-09-01 12:06:33 -07003167
Joe Perches1071a132011-02-02 14:05:47 -08003168 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003169 ret = -EIO;
3170 } else if (copy_from_user(&optTxFrmCmd, userdata,
3171 sizeof(optTxFrmCmd)))
3172 {
3173 ret = -EFAULT;
3174 } else if (copy_from_user(data,
3175 userdata+sizeof(WMI_OPT_TX_FRAME_CMD)-1,
3176 optTxFrmCmd.optIEDataLen))
3177 {
3178 ret = -EFAULT;
3179 } else {
3180 ret = wmi_opt_tx_frame_cmd(ar->arWmi,
3181 optTxFrmCmd.frmType,
3182 optTxFrmCmd.dstAddr,
3183 optTxFrmCmd.bssid,
3184 optTxFrmCmd.optIEDataLen,
3185 data);
3186 }
3187
3188 break;
3189 }
3190 case AR6000_XIOCTL_WMI_SETRETRYLIMITS:
3191 {
3192 WMI_SET_RETRY_LIMITS_CMD setRetryParams;
3193
Joe Perches1071a132011-02-02 14:05:47 -08003194 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003195 ret = -EIO;
3196 } else if (copy_from_user(&setRetryParams, userdata,
3197 sizeof(setRetryParams)))
3198 {
3199 ret = -EFAULT;
3200 } else {
3201 if (wmi_set_retry_limits_cmd(ar->arWmi, setRetryParams.frameType,
3202 setRetryParams.trafficClass,
3203 setRetryParams.maxRetries,
Joe Perches4f69cef2011-02-02 14:05:57 -08003204 setRetryParams.enableNotify) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003205 {
3206 ret = -EIO;
3207 }
3208 AR6000_SPIN_LOCK(&ar->arLock, 0);
3209 ar->arMaxRetries = setRetryParams.maxRetries;
3210 AR6000_SPIN_UNLOCK(&ar->arLock, 0);
3211 }
3212 break;
3213 }
3214
3215 case AR6000_XIOCTL_SET_BEACON_INTVAL:
3216 {
3217 WMI_BEACON_INT_CMD bIntvlCmd;
3218
Joe Perches1071a132011-02-02 14:05:47 -08003219 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003220 ret = -EIO;
3221 } else if (copy_from_user(&bIntvlCmd, userdata,
3222 sizeof(bIntvlCmd)))
3223 {
3224 ret = -EFAULT;
3225 } else if (wmi_set_adhoc_bconIntvl_cmd(ar->arWmi, bIntvlCmd.beaconInterval)
Joe Perches4f69cef2011-02-02 14:05:57 -08003226 != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003227 {
3228 ret = -EIO;
3229 }
3230 if(ret == 0) {
3231 ar->ap_beacon_interval = bIntvlCmd.beaconInterval;
3232 ar->ap_profile_flag = 1; /* There is a change in profile */
3233 }
3234 break;
3235 }
3236 case IEEE80211_IOCTL_SETAUTHALG:
3237 {
3238 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
3239 struct ieee80211req_authalg req;
3240
Joe Perches1071a132011-02-02 14:05:47 -08003241 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003242 ret = -EIO;
3243 } else if (copy_from_user(&req, userdata,
3244 sizeof(struct ieee80211req_authalg)))
3245 {
3246 ret = -EFAULT;
3247 } else {
3248 if (req.auth_alg & AUTH_ALG_OPEN_SYSTEM) {
3249 ar->arDot11AuthMode |= OPEN_AUTH;
3250 ar->arPairwiseCrypto = NONE_CRYPT;
3251 ar->arGroupCrypto = NONE_CRYPT;
3252 }
3253 if (req.auth_alg & AUTH_ALG_SHARED_KEY) {
3254 ar->arDot11AuthMode |= SHARED_AUTH;
3255 ar->arPairwiseCrypto = WEP_CRYPT;
3256 ar->arGroupCrypto = WEP_CRYPT;
3257 ar->arAuthMode = NONE_AUTH;
3258 }
3259 if (req.auth_alg == AUTH_ALG_LEAP) {
3260 ar->arDot11AuthMode = LEAP_AUTH;
3261 }
3262 }
3263 break;
3264 }
3265
3266 case AR6000_XIOCTL_SET_VOICE_PKT_SIZE:
3267 ret = ar6000_xioctl_set_voice_pkt_size(dev, userdata);
3268 break;
3269
3270 case AR6000_XIOCTL_SET_MAX_SP:
3271 ret = ar6000_xioctl_set_max_sp_len(dev, userdata);
3272 break;
3273
3274 case AR6000_XIOCTL_WMI_GET_ROAM_TBL:
3275 ret = ar6000_ioctl_get_roam_tbl(dev, rq);
3276 break;
3277 case AR6000_XIOCTL_WMI_SET_ROAM_CTRL:
3278 ret = ar6000_ioctl_set_roam_ctrl(dev, userdata);
3279 break;
3280 case AR6000_XIOCTRL_WMI_SET_POWERSAVE_TIMERS:
3281 ret = ar6000_ioctl_set_powersave_timers(dev, userdata);
3282 break;
3283 case AR6000_XIOCTRL_WMI_GET_POWER_MODE:
3284 ret = ar6000_ioctl_get_power_mode(dev, rq);
3285 break;
3286 case AR6000_XIOCTRL_WMI_SET_WLAN_STATE:
3287 {
3288 AR6000_WLAN_STATE state;
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04003289 if (get_user(state, (unsigned int *)userdata))
3290 ret = -EFAULT;
Joe Perches4f69cef2011-02-02 14:05:57 -08003291 else if (ar6000_set_wlan_state(ar, state) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003292 ret = -EIO;
Vipin Mehta30295c82010-09-01 12:06:33 -07003293 break;
3294 }
3295 case AR6000_XIOCTL_WMI_GET_ROAM_DATA:
3296 ret = ar6000_ioctl_get_roam_data(dev, rq);
3297 break;
3298
3299 case AR6000_XIOCTL_WMI_SET_BT_STATUS:
3300 ret = ar6000_xioctl_set_bt_status_cmd(dev, userdata);
3301 break;
3302
3303 case AR6000_XIOCTL_WMI_SET_BT_PARAMS:
3304 ret = ar6000_xioctl_set_bt_params_cmd(dev, userdata);
3305 break;
3306
3307 case AR6000_XIOCTL_WMI_SET_BTCOEX_FE_ANT:
3308 ret = ar6000_xioctl_set_btcoex_fe_ant_cmd(dev, userdata);
3309 break;
3310
3311 case AR6000_XIOCTL_WMI_SET_BTCOEX_COLOCATED_BT_DEV:
3312 ret = ar6000_xioctl_set_btcoex_colocated_bt_dev_cmd(dev, userdata);
3313 break;
3314
3315 case AR6000_XIOCTL_WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG:
3316 ret = ar6000_xioctl_set_btcoex_btinquiry_page_config_cmd(dev, userdata);
3317 break;
3318
3319 case AR6000_XIOCTL_WMI_SET_BTCOEX_SCO_CONFIG:
3320 ret = ar6000_xioctl_set_btcoex_sco_config_cmd( dev, userdata);
3321 break;
3322
3323 case AR6000_XIOCTL_WMI_SET_BTCOEX_A2DP_CONFIG:
3324 ret = ar6000_xioctl_set_btcoex_a2dp_config_cmd(dev, userdata);
3325 break;
3326
3327 case AR6000_XIOCTL_WMI_SET_BTCOEX_ACLCOEX_CONFIG:
3328 ret = ar6000_xioctl_set_btcoex_aclcoex_config_cmd(dev, userdata);
3329 break;
3330
3331 case AR6000_XIOCTL_WMI_SET_BTCOEX_DEBUG:
3332 ret = ar60000_xioctl_set_btcoex_debug_cmd(dev, userdata);
3333 break;
3334
3335 case AR6000_XIOCTL_WMI_SET_BT_OPERATING_STATUS:
3336 ret = ar6000_xioctl_set_btcoex_bt_operating_status_cmd(dev, userdata);
3337 break;
3338
3339 case AR6000_XIOCTL_WMI_GET_BTCOEX_CONFIG:
3340 ret = ar6000_xioctl_get_btcoex_config_cmd(dev, userdata, rq);
3341 break;
3342
3343 case AR6000_XIOCTL_WMI_GET_BTCOEX_STATS:
3344 ret = ar6000_xioctl_get_btcoex_stats_cmd(dev, userdata, rq);
3345 break;
3346
3347 case AR6000_XIOCTL_WMI_STARTSCAN:
3348 {
3349 WMI_START_SCAN_CMD setStartScanCmd, *cmdp;
3350
Joe Perches1071a132011-02-02 14:05:47 -08003351 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003352 ret = -EIO;
3353 } else if (copy_from_user(&setStartScanCmd, userdata,
3354 sizeof(setStartScanCmd)))
3355 {
3356 ret = -EFAULT;
3357 } else {
3358 if (setStartScanCmd.numChannels > 1) {
3359 cmdp = A_MALLOC(130);
3360 if (copy_from_user(cmdp, userdata,
3361 sizeof (*cmdp) +
3362 ((setStartScanCmd.numChannels - 1) *
Joe Perches4853ac02011-02-02 14:05:50 -08003363 sizeof(u16))))
Vipin Mehta30295c82010-09-01 12:06:33 -07003364 {
3365 kfree(cmdp);
3366 ret = -EFAULT;
3367 goto ioctl_done;
3368 }
3369 } else {
3370 cmdp = &setStartScanCmd;
3371 }
3372
3373 if (wmi_startscan_cmd(ar->arWmi, cmdp->scanType,
3374 cmdp->forceFgScan,
3375 cmdp->isLegacy,
3376 cmdp->homeDwellTime,
3377 cmdp->forceScanInterval,
3378 cmdp->numChannels,
Joe Perches4f69cef2011-02-02 14:05:57 -08003379 cmdp->channelList) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003380 {
3381 ret = -EIO;
3382 }
3383 }
3384 break;
3385 }
3386 case AR6000_XIOCTL_WMI_SETFIXRATES:
3387 {
3388 WMI_FIX_RATES_CMD setFixRatesCmd;
Joe Perches1f4c34b2011-01-27 20:04:19 -08003389 int returnStatus;
Vipin Mehta30295c82010-09-01 12:06:33 -07003390
Joe Perches1071a132011-02-02 14:05:47 -08003391 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003392 ret = -EIO;
3393 } else if (copy_from_user(&setFixRatesCmd, userdata,
3394 sizeof(setFixRatesCmd)))
3395 {
3396 ret = -EFAULT;
3397 } else {
3398 returnStatus = wmi_set_fixrates_cmd(ar->arWmi, setFixRatesCmd.fixRateMask);
3399 if (returnStatus == A_EINVAL) {
3400 ret = -EINVAL;
Joe Perches4f69cef2011-02-02 14:05:57 -08003401 } else if(returnStatus != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003402 ret = -EIO;
3403 } else {
3404 ar->ap_profile_flag = 1; /* There is a change in profile */
3405 }
3406 }
3407 break;
3408 }
3409
3410 case AR6000_XIOCTL_WMI_GETFIXRATES:
3411 {
3412 WMI_FIX_RATES_CMD getFixRatesCmd;
3413 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
3414 int ret = 0;
3415
3416 if (ar->bIsDestroyProgress) {
3417 ret = -EBUSY;
3418 goto ioctl_done;
3419 }
Joe Perches1071a132011-02-02 14:05:47 -08003420 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003421 ret = -EIO;
3422 goto ioctl_done;
3423 }
3424
3425 if (down_interruptible(&ar->arSem)) {
3426 ret = -ERESTARTSYS;
3427 goto ioctl_done;
3428 }
3429 if (ar->bIsDestroyProgress) {
3430 up(&ar->arSem);
3431 ret = -EBUSY;
3432 goto ioctl_done;
3433 }
3434 /* Used copy_from_user/copy_to_user to access user space data */
3435 if (copy_from_user(&getFixRatesCmd, userdata, sizeof(getFixRatesCmd))) {
3436 ret = -EFAULT;
3437 } else {
3438 ar->arRateMask = 0xFFFFFFFF;
3439
Joe Perches4f69cef2011-02-02 14:05:57 -08003440 if (wmi_get_ratemask_cmd(ar->arWmi) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003441 up(&ar->arSem);
3442 ret = -EIO;
3443 goto ioctl_done;
3444 }
3445
3446 wait_event_interruptible_timeout(arEvent, ar->arRateMask != 0xFFFFFFFF, wmitimeout * HZ);
3447
3448 if (signal_pending(current)) {
3449 ret = -EINTR;
3450 }
3451
3452 if (!ret) {
3453 getFixRatesCmd.fixRateMask = ar->arRateMask;
3454 }
3455
3456 if(copy_to_user(userdata, &getFixRatesCmd, sizeof(getFixRatesCmd))) {
3457 ret = -EFAULT;
3458 }
3459
3460 up(&ar->arSem);
3461 }
3462 break;
3463 }
3464 case AR6000_XIOCTL_WMI_SET_AUTHMODE:
3465 {
3466 WMI_SET_AUTH_MODE_CMD setAuthMode;
3467
Joe Perches1071a132011-02-02 14:05:47 -08003468 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003469 ret = -EIO;
3470 } else if (copy_from_user(&setAuthMode, userdata,
3471 sizeof(setAuthMode)))
3472 {
3473 ret = -EFAULT;
3474 } else {
Joe Perches4f69cef2011-02-02 14:05:57 -08003475 if (wmi_set_authmode_cmd(ar->arWmi, setAuthMode.mode) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003476 {
3477 ret = -EIO;
3478 }
3479 }
3480 break;
3481 }
3482 case AR6000_XIOCTL_WMI_SET_REASSOCMODE:
3483 {
3484 WMI_SET_REASSOC_MODE_CMD setReassocMode;
3485
Joe Perches1071a132011-02-02 14:05:47 -08003486 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003487 ret = -EIO;
3488 } else if (copy_from_user(&setReassocMode, userdata,
3489 sizeof(setReassocMode)))
3490 {
3491 ret = -EFAULT;
3492 } else {
Joe Perches4f69cef2011-02-02 14:05:57 -08003493 if (wmi_set_reassocmode_cmd(ar->arWmi, setReassocMode.mode) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003494 {
3495 ret = -EIO;
3496 }
3497 }
3498 break;
3499 }
3500 case AR6000_XIOCTL_DIAG_READ:
3501 {
Joe Perchese1ce2a32011-02-02 14:05:51 -08003502 u32 addr, data;
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04003503 if (get_user(addr, (unsigned int *)userdata)) {
3504 ret = -EFAULT;
3505 break;
3506 }
Vipin Mehta30295c82010-09-01 12:06:33 -07003507 addr = TARG_VTOP(ar->arTargetType, addr);
Joe Perches4f69cef2011-02-02 14:05:57 -08003508 if (ar6000_ReadRegDiag(ar->arHifDevice, &addr, &data) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003509 ret = -EIO;
3510 }
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04003511 if (put_user(data, (unsigned int *)userdata + 1)) {
3512 ret = -EFAULT;
3513 break;
3514 }
Vipin Mehta30295c82010-09-01 12:06:33 -07003515 break;
3516 }
3517 case AR6000_XIOCTL_DIAG_WRITE:
3518 {
Joe Perchese1ce2a32011-02-02 14:05:51 -08003519 u32 addr, data;
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04003520 if (get_user(addr, (unsigned int *)userdata) ||
3521 get_user(data, (unsigned int *)userdata + 1)) {
3522 ret = -EFAULT;
3523 break;
3524 }
Vipin Mehta30295c82010-09-01 12:06:33 -07003525 addr = TARG_VTOP(ar->arTargetType, addr);
Joe Perches4f69cef2011-02-02 14:05:57 -08003526 if (ar6000_WriteRegDiag(ar->arHifDevice, &addr, &data) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003527 ret = -EIO;
3528 }
3529 break;
3530 }
3531 case AR6000_XIOCTL_WMI_SET_KEEPALIVE:
3532 {
3533 WMI_SET_KEEPALIVE_CMD setKeepAlive;
Joe Perches1071a132011-02-02 14:05:47 -08003534 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003535 ret = -EIO;
3536 goto ioctl_done;
3537 } else if (copy_from_user(&setKeepAlive, userdata,
3538 sizeof(setKeepAlive))){
3539 ret = -EFAULT;
3540 } else {
Joe Perches4f69cef2011-02-02 14:05:57 -08003541 if (wmi_set_keepalive_cmd(ar->arWmi, setKeepAlive.keepaliveInterval) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003542 ret = -EIO;
3543 }
3544 }
3545 break;
3546 }
3547 case AR6000_XIOCTL_WMI_SET_PARAMS:
3548 {
3549 WMI_SET_PARAMS_CMD cmd;
Joe Perches1071a132011-02-02 14:05:47 -08003550 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003551 ret = -EIO;
3552 goto ioctl_done;
3553 } else if (copy_from_user(&cmd, userdata,
3554 sizeof(cmd))){
3555 ret = -EFAULT;
3556 } else if (copy_from_user(&cmd, userdata,
3557 sizeof(cmd) + cmd.length))
3558 {
3559 ret = -EFAULT;
3560 } else {
Joe Perches4f69cef2011-02-02 14:05:57 -08003561 if (wmi_set_params_cmd(ar->arWmi, cmd.opcode, cmd.length, cmd.buffer) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003562 ret = -EIO;
3563 }
3564 }
3565 break;
3566 }
3567 case AR6000_XIOCTL_WMI_SET_MCAST_FILTER:
3568 {
3569 WMI_SET_MCAST_FILTER_CMD cmd;
Joe Perches1071a132011-02-02 14:05:47 -08003570 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003571 ret = -EIO;
3572 goto ioctl_done;
3573 } else if (copy_from_user(&cmd, userdata,
3574 sizeof(cmd))){
3575 ret = -EFAULT;
3576 } else {
3577 if (wmi_set_mcast_filter_cmd(ar->arWmi, cmd.multicast_mac[0],
3578 cmd.multicast_mac[1],
3579 cmd.multicast_mac[2],
Joe Perches4f69cef2011-02-02 14:05:57 -08003580 cmd.multicast_mac[3]) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003581 ret = -EIO;
3582 }
3583 }
3584 break;
3585 }
3586 case AR6000_XIOCTL_WMI_DEL_MCAST_FILTER:
3587 {
3588 WMI_SET_MCAST_FILTER_CMD cmd;
Joe Perches1071a132011-02-02 14:05:47 -08003589 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003590 ret = -EIO;
3591 goto ioctl_done;
3592 } else if (copy_from_user(&cmd, userdata,
3593 sizeof(cmd))){
3594 ret = -EFAULT;
3595 } else {
3596 if (wmi_del_mcast_filter_cmd(ar->arWmi, cmd.multicast_mac[0],
3597 cmd.multicast_mac[1],
3598 cmd.multicast_mac[2],
Joe Perches4f69cef2011-02-02 14:05:57 -08003599 cmd.multicast_mac[3]) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003600 ret = -EIO;
3601 }
3602 }
3603 break;
3604 }
3605 case AR6000_XIOCTL_WMI_MCAST_FILTER:
3606 {
3607 WMI_MCAST_FILTER_CMD cmd;
Joe Perches1071a132011-02-02 14:05:47 -08003608 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003609 ret = -EIO;
3610 goto ioctl_done;
3611 } else if (copy_from_user(&cmd, userdata,
3612 sizeof(cmd))){
3613 ret = -EFAULT;
3614 } else {
Joe Perches4f69cef2011-02-02 14:05:57 -08003615 if (wmi_mcast_filter_cmd(ar->arWmi, cmd.enable) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003616 ret = -EIO;
3617 }
3618 }
3619 break;
3620 }
3621 case AR6000_XIOCTL_WMI_GET_KEEPALIVE:
3622 {
3623 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
3624 WMI_GET_KEEPALIVE_CMD getKeepAlive;
3625 int ret = 0;
3626 if (ar->bIsDestroyProgress) {
3627 ret =-EBUSY;
3628 goto ioctl_done;
3629 }
Joe Perches1071a132011-02-02 14:05:47 -08003630 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003631 ret = -EIO;
3632 goto ioctl_done;
3633 }
3634 if (down_interruptible(&ar->arSem)) {
3635 ret = -ERESTARTSYS;
3636 goto ioctl_done;
3637 }
3638 if (ar->bIsDestroyProgress) {
3639 up(&ar->arSem);
3640 ret = -EBUSY;
3641 goto ioctl_done;
3642 }
3643 if (copy_from_user(&getKeepAlive, userdata,sizeof(getKeepAlive))) {
3644 ret = -EFAULT;
3645 } else {
3646 getKeepAlive.keepaliveInterval = wmi_get_keepalive_cmd(ar->arWmi);
3647 ar->arKeepaliveConfigured = 0xFF;
Joe Perches4f69cef2011-02-02 14:05:57 -08003648 if (wmi_get_keepalive_configured(ar->arWmi) != 0){
Vipin Mehta30295c82010-09-01 12:06:33 -07003649 up(&ar->arSem);
3650 ret = -EIO;
3651 goto ioctl_done;
3652 }
3653 wait_event_interruptible_timeout(arEvent, ar->arKeepaliveConfigured != 0xFF, wmitimeout * HZ);
3654 if (signal_pending(current)) {
3655 ret = -EINTR;
3656 }
3657
3658 if (!ret) {
3659 getKeepAlive.configured = ar->arKeepaliveConfigured;
3660 }
3661 if (copy_to_user(userdata, &getKeepAlive, sizeof(getKeepAlive))) {
3662 ret = -EFAULT;
3663 }
3664 up(&ar->arSem);
3665 }
3666 break;
3667 }
3668 case AR6000_XIOCTL_WMI_SET_APPIE:
3669 {
3670 WMI_SET_APPIE_CMD appIEcmd;
Joe Perchesab3655d2011-02-02 14:05:49 -08003671 u8 appIeInfo[IEEE80211_APPIE_FRAME_MAX_LEN];
Joe Perchese1ce2a32011-02-02 14:05:51 -08003672 u32 fType,ieLen;
Vipin Mehta30295c82010-09-01 12:06:33 -07003673
Joe Perches1071a132011-02-02 14:05:47 -08003674 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003675 ret = -EIO;
3676 goto ioctl_done;
3677 }
Joe Perchese1ce2a32011-02-02 14:05:51 -08003678 if (get_user(fType, (u32 *)userdata)) {
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04003679 ret = -EFAULT;
3680 break;
3681 }
Vipin Mehta30295c82010-09-01 12:06:33 -07003682 appIEcmd.mgmtFrmType = fType;
3683 if (appIEcmd.mgmtFrmType >= IEEE80211_APPIE_NUM_OF_FRAME) {
3684 ret = -EIO;
3685 } else {
Joe Perchese1ce2a32011-02-02 14:05:51 -08003686 if (get_user(ieLen, (u32 *)(userdata + 4))) {
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04003687 ret = -EFAULT;
3688 break;
3689 }
Vipin Mehta30295c82010-09-01 12:06:33 -07003690 appIEcmd.ieLen = ieLen;
3691 A_PRINTF("WPSIE: Type-%d, Len-%d\n",appIEcmd.mgmtFrmType, appIEcmd.ieLen);
3692 if (appIEcmd.ieLen > IEEE80211_APPIE_FRAME_MAX_LEN) {
3693 ret = -EIO;
3694 break;
3695 }
3696 if (copy_from_user(appIeInfo, userdata + 8, appIEcmd.ieLen)) {
3697 ret = -EFAULT;
3698 } else {
3699 if (wmi_set_appie_cmd(ar->arWmi, appIEcmd.mgmtFrmType,
Joe Perches4f69cef2011-02-02 14:05:57 -08003700 appIEcmd.ieLen, appIeInfo) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003701 {
3702 ret = -EIO;
3703 }
3704 }
3705 }
3706 break;
3707 }
3708 case AR6000_XIOCTL_WMI_SET_MGMT_FRM_RX_FILTER:
3709 {
3710 WMI_BSS_FILTER_CMD cmd;
Joe Perchese1ce2a32011-02-02 14:05:51 -08003711 u32 filterType;
Vipin Mehta30295c82010-09-01 12:06:33 -07003712
Joe Perchese1ce2a32011-02-02 14:05:51 -08003713 if (copy_from_user(&filterType, userdata, sizeof(u32)))
Vipin Mehta30295c82010-09-01 12:06:33 -07003714 {
3715 ret = -EFAULT;
3716 goto ioctl_done;
3717 }
3718 if (filterType & (IEEE80211_FILTER_TYPE_BEACON |
3719 IEEE80211_FILTER_TYPE_PROBE_RESP))
3720 {
3721 cmd.bssFilter = ALL_BSS_FILTER;
3722 } else {
3723 cmd.bssFilter = NONE_BSS_FILTER;
3724 }
Joe Perches4f69cef2011-02-02 14:05:57 -08003725 if (wmi_bssfilter_cmd(ar->arWmi, cmd.bssFilter, 0) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003726 ret = -EIO;
3727 } else {
3728 ar->arUserBssFilter = cmd.bssFilter;
3729 }
3730
3731 AR6000_SPIN_LOCK(&ar->arLock, 0);
3732 ar->arMgmtFilter = filterType;
3733 AR6000_SPIN_UNLOCK(&ar->arLock, 0);
3734 break;
3735 }
3736 case AR6000_XIOCTL_WMI_SET_WSC_STATUS:
3737 {
Joe Perchese1ce2a32011-02-02 14:05:51 -08003738 u32 wsc_status;
Vipin Mehta30295c82010-09-01 12:06:33 -07003739
Joe Perches1071a132011-02-02 14:05:47 -08003740 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003741 ret = -EIO;
3742 goto ioctl_done;
Joe Perchese1ce2a32011-02-02 14:05:51 -08003743 } else if (copy_from_user(&wsc_status, userdata, sizeof(u32)))
Vipin Mehta30295c82010-09-01 12:06:33 -07003744 {
3745 ret = -EFAULT;
3746 goto ioctl_done;
3747 }
Joe Perches4f69cef2011-02-02 14:05:57 -08003748 if (wmi_set_wsc_status_cmd(ar->arWmi, wsc_status) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003749 ret = -EIO;
3750 }
3751 break;
3752 }
3753 case AR6000_XIOCTL_BMI_ROMPATCH_INSTALL:
3754 {
Joe Perchese1ce2a32011-02-02 14:05:51 -08003755 u32 ROM_addr;
3756 u32 RAM_addr;
3757 u32 nbytes;
3758 u32 do_activate;
3759 u32 rompatch_id;
Vipin Mehta30295c82010-09-01 12:06:33 -07003760
Joe Perchese1ce2a32011-02-02 14:05:51 -08003761 if (get_user(ROM_addr, (u32 *)userdata) ||
3762 get_user(RAM_addr, (u32 *)userdata + 1) ||
3763 get_user(nbytes, (u32 *)userdata + 2) ||
3764 get_user(do_activate, (u32 *)userdata + 3)) {
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04003765 ret = -EFAULT;
3766 break;
3767 }
Vipin Mehta30295c82010-09-01 12:06:33 -07003768 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Install rompatch from ROM: 0x%x to RAM: 0x%x length: %d\n",
3769 ROM_addr, RAM_addr, nbytes));
3770 ret = BMIrompatchInstall(hifDevice, ROM_addr, RAM_addr,
3771 nbytes, do_activate, &rompatch_id);
Joe Perches4f69cef2011-02-02 14:05:57 -08003772 if (ret == 0) {
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04003773 /* return value */
3774 if (put_user(rompatch_id, (unsigned int *)rq->ifr_data)) {
3775 ret = -EFAULT;
3776 break;
3777 }
Vipin Mehta30295c82010-09-01 12:06:33 -07003778 }
3779 break;
3780 }
3781
3782 case AR6000_XIOCTL_BMI_ROMPATCH_UNINSTALL:
3783 {
Joe Perchese1ce2a32011-02-02 14:05:51 -08003784 u32 rompatch_id;
Vipin Mehta30295c82010-09-01 12:06:33 -07003785
Joe Perchese1ce2a32011-02-02 14:05:51 -08003786 if (get_user(rompatch_id, (u32 *)userdata)) {
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04003787 ret = -EFAULT;
3788 break;
3789 }
Vipin Mehta30295c82010-09-01 12:06:33 -07003790 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("UNinstall rompatch_id %d\n", rompatch_id));
3791 ret = BMIrompatchUninstall(hifDevice, rompatch_id);
3792 break;
3793 }
3794
3795 case AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE:
3796 case AR6000_XIOCTL_BMI_ROMPATCH_DEACTIVATE:
3797 {
Joe Perchese1ce2a32011-02-02 14:05:51 -08003798 u32 rompatch_count;
Vipin Mehta30295c82010-09-01 12:06:33 -07003799
Joe Perchese1ce2a32011-02-02 14:05:51 -08003800 if (get_user(rompatch_count, (u32 *)userdata)) {
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04003801 ret = -EFAULT;
3802 break;
3803 }
Vipin Mehta30295c82010-09-01 12:06:33 -07003804 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Change rompatch activation count=%d\n", rompatch_count));
Joe Perchese1ce2a32011-02-02 14:05:51 -08003805 length = sizeof(u32) * rompatch_count;
Vipin Mehta30295c82010-09-01 12:06:33 -07003806 if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
3807 A_MEMZERO(buffer, length);
3808 if (copy_from_user(buffer, &userdata[sizeof(rompatch_count)], length))
3809 {
3810 ret = -EFAULT;
3811 } else {
3812 if (cmd == AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE) {
Joe Perchese1ce2a32011-02-02 14:05:51 -08003813 ret = BMIrompatchActivate(hifDevice, rompatch_count, (u32 *)buffer);
Vipin Mehta30295c82010-09-01 12:06:33 -07003814 } else {
Joe Perchese1ce2a32011-02-02 14:05:51 -08003815 ret = BMIrompatchDeactivate(hifDevice, rompatch_count, (u32 *)buffer);
Vipin Mehta30295c82010-09-01 12:06:33 -07003816 }
3817 }
3818 A_FREE(buffer);
3819 } else {
3820 ret = -ENOMEM;
3821 }
3822
3823 break;
3824 }
3825 case AR6000_XIOCTL_SET_IP:
3826 {
3827 WMI_SET_IP_CMD setIP;
3828
Joe Perches1071a132011-02-02 14:05:47 -08003829 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003830 ret = -EIO;
3831 } else if (copy_from_user(&setIP, userdata,
3832 sizeof(setIP)))
3833 {
3834 ret = -EFAULT;
3835 } else {
3836 if (wmi_set_ip_cmd(ar->arWmi,
Joe Perches4f69cef2011-02-02 14:05:57 -08003837 &setIP) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003838 {
3839 ret = -EIO;
3840 }
3841 }
3842 break;
3843 }
3844
3845 case AR6000_XIOCTL_WMI_SET_HOST_SLEEP_MODE:
3846 {
3847 WMI_SET_HOST_SLEEP_MODE_CMD setHostSleepMode;
3848
Joe Perches1071a132011-02-02 14:05:47 -08003849 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003850 ret = -EIO;
3851 } else if (copy_from_user(&setHostSleepMode, userdata,
3852 sizeof(setHostSleepMode)))
3853 {
3854 ret = -EFAULT;
3855 } else {
3856 if (wmi_set_host_sleep_mode_cmd(ar->arWmi,
Joe Perches4f69cef2011-02-02 14:05:57 -08003857 &setHostSleepMode) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003858 {
3859 ret = -EIO;
3860 }
3861 }
3862 break;
3863 }
3864 case AR6000_XIOCTL_WMI_SET_WOW_MODE:
3865 {
3866 WMI_SET_WOW_MODE_CMD setWowMode;
3867
Joe Perches1071a132011-02-02 14:05:47 -08003868 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003869 ret = -EIO;
3870 } else if (copy_from_user(&setWowMode, userdata,
3871 sizeof(setWowMode)))
3872 {
3873 ret = -EFAULT;
3874 } else {
3875 if (wmi_set_wow_mode_cmd(ar->arWmi,
Joe Perches4f69cef2011-02-02 14:05:57 -08003876 &setWowMode) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003877 {
3878 ret = -EIO;
3879 }
3880 }
3881 break;
3882 }
3883 case AR6000_XIOCTL_WMI_GET_WOW_LIST:
3884 {
3885 WMI_GET_WOW_LIST_CMD getWowList;
3886
Joe Perches1071a132011-02-02 14:05:47 -08003887 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003888 ret = -EIO;
3889 } else if (copy_from_user(&getWowList, userdata,
3890 sizeof(getWowList)))
3891 {
3892 ret = -EFAULT;
3893 } else {
3894 if (wmi_get_wow_list_cmd(ar->arWmi,
Joe Perches4f69cef2011-02-02 14:05:57 -08003895 &getWowList) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003896 {
3897 ret = -EIO;
3898 }
3899 }
3900 break;
3901 }
3902 case AR6000_XIOCTL_WMI_ADD_WOW_PATTERN:
3903 {
3904#define WOW_PATTERN_SIZE 64
3905#define WOW_MASK_SIZE 64
3906
3907 WMI_ADD_WOW_PATTERN_CMD cmd;
Joe Perchesab3655d2011-02-02 14:05:49 -08003908 u8 mask_data[WOW_PATTERN_SIZE]={0};
3909 u8 pattern_data[WOW_PATTERN_SIZE]={0};
Vipin Mehta30295c82010-09-01 12:06:33 -07003910
3911 do {
Joe Perches1071a132011-02-02 14:05:47 -08003912 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003913 ret = -EIO;
3914 break;
3915 }
3916 if(copy_from_user(&cmd, userdata,
3917 sizeof(WMI_ADD_WOW_PATTERN_CMD)))
3918 {
3919 ret = -EFAULT;
3920 break;
3921 }
3922 if (copy_from_user(pattern_data,
3923 userdata + 3,
3924 cmd.filter_size))
3925 {
3926 ret = -EFAULT;
3927 break;
3928 }
3929 if (copy_from_user(mask_data,
3930 (userdata + 3 + cmd.filter_size),
3931 cmd.filter_size))
3932 {
3933 ret = -EFAULT;
3934 break;
3935 }
3936 if (wmi_add_wow_pattern_cmd(ar->arWmi,
Joe Perches4f69cef2011-02-02 14:05:57 -08003937 &cmd, pattern_data, mask_data, cmd.filter_size) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003938 {
3939 ret = -EIO;
3940 }
Joe Perches1071a132011-02-02 14:05:47 -08003941 } while(false);
Vipin Mehta30295c82010-09-01 12:06:33 -07003942#undef WOW_PATTERN_SIZE
3943#undef WOW_MASK_SIZE
3944 break;
3945 }
3946 case AR6000_XIOCTL_WMI_DEL_WOW_PATTERN:
3947 {
3948 WMI_DEL_WOW_PATTERN_CMD delWowPattern;
3949
Joe Perches1071a132011-02-02 14:05:47 -08003950 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07003951 ret = -EIO;
3952 } else if (copy_from_user(&delWowPattern, userdata,
3953 sizeof(delWowPattern)))
3954 {
3955 ret = -EFAULT;
3956 } else {
3957 if (wmi_del_wow_pattern_cmd(ar->arWmi,
Joe Perches4f69cef2011-02-02 14:05:57 -08003958 &delWowPattern) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07003959 {
3960 ret = -EIO;
3961 }
3962 }
3963 break;
3964 }
3965 case AR6000_XIOCTL_DUMP_HTC_CREDIT_STATE:
3966 if (ar->arHtcTarget != NULL) {
3967#ifdef ATH_DEBUG_MODULE
3968 HTCDumpCreditStates(ar->arHtcTarget);
3969#endif /* ATH_DEBUG_MODULE */
3970#ifdef HTC_EP_STAT_PROFILING
3971 {
3972 HTC_ENDPOINT_STATS stats;
3973 int i;
3974
3975 for (i = 0; i < 5; i++) {
3976 if (HTCGetEndpointStatistics(ar->arHtcTarget,
3977 i,
3978 HTC_EP_STAT_SAMPLE_AND_CLEAR,
3979 &stats)) {
3980 A_PRINTF(KERN_ALERT"------- Profiling Endpoint : %d \n", i);
3981 A_PRINTF(KERN_ALERT"TxCreditLowIndications : %d \n", stats.TxCreditLowIndications);
3982 A_PRINTF(KERN_ALERT"TxIssued : %d \n", stats.TxIssued);
3983 A_PRINTF(KERN_ALERT"TxDropped: %d \n", stats.TxDropped);
3984 A_PRINTF(KERN_ALERT"TxPacketsBundled : %d \n", stats.TxPacketsBundled);
3985 A_PRINTF(KERN_ALERT"TxBundles : %d \n", stats.TxBundles);
3986 A_PRINTF(KERN_ALERT"TxCreditRpts : %d \n", stats.TxCreditRpts);
3987 A_PRINTF(KERN_ALERT"TxCreditsRptsFromRx : %d \n", stats.TxCreditRptsFromRx);
3988 A_PRINTF(KERN_ALERT"TxCreditsRptsFromOther : %d \n", stats.TxCreditRptsFromOther);
3989 A_PRINTF(KERN_ALERT"TxCreditsRptsFromEp0 : %d \n", stats.TxCreditRptsFromEp0);
3990 A_PRINTF(KERN_ALERT"TxCreditsFromRx : %d \n", stats.TxCreditsFromRx);
3991 A_PRINTF(KERN_ALERT"TxCreditsFromOther : %d \n", stats.TxCreditsFromOther);
3992 A_PRINTF(KERN_ALERT"TxCreditsFromEp0 : %d \n", stats.TxCreditsFromEp0);
3993 A_PRINTF(KERN_ALERT"TxCreditsConsummed : %d \n", stats.TxCreditsConsummed);
3994 A_PRINTF(KERN_ALERT"TxCreditsReturned : %d \n", stats.TxCreditsReturned);
3995 A_PRINTF(KERN_ALERT"RxReceived : %d \n", stats.RxReceived);
3996 A_PRINTF(KERN_ALERT"RxPacketsBundled : %d \n", stats.RxPacketsBundled);
3997 A_PRINTF(KERN_ALERT"RxLookAheads : %d \n", stats.RxLookAheads);
3998 A_PRINTF(KERN_ALERT"RxBundleLookAheads : %d \n", stats.RxBundleLookAheads);
3999 A_PRINTF(KERN_ALERT"RxBundleIndFromHdr : %d \n", stats.RxBundleIndFromHdr);
4000 A_PRINTF(KERN_ALERT"RxAllocThreshHit : %d \n", stats.RxAllocThreshHit);
4001 A_PRINTF(KERN_ALERT"RxAllocThreshBytes : %d \n", stats.RxAllocThreshBytes);
4002 A_PRINTF(KERN_ALERT"---- \n");
4003
4004 }
4005 }
4006 }
4007#endif
4008 }
4009 break;
4010 case AR6000_XIOCTL_TRAFFIC_ACTIVITY_CHANGE:
4011 if (ar->arHtcTarget != NULL) {
4012 struct ar6000_traffic_activity_change data;
4013
4014 if (copy_from_user(&data, userdata, sizeof(data)))
4015 {
4016 ret = -EFAULT;
4017 goto ioctl_done;
4018 }
4019 /* note, this is used for testing (mbox ping testing), indicate activity
4020 * change using the stream ID as the traffic class */
4021 ar6000_indicate_tx_activity(ar,
Joe Perchesab3655d2011-02-02 14:05:49 -08004022 (u8)data.StreamID,
Joe Perches1071a132011-02-02 14:05:47 -08004023 data.Active ? true : false);
Vipin Mehta30295c82010-09-01 12:06:33 -07004024 }
4025 break;
4026 case AR6000_XIOCTL_WMI_SET_CONNECT_CTRL_FLAGS:
Joe Perches1071a132011-02-02 14:05:47 -08004027 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004028 ret = -EIO;
4029 } else if (copy_from_user(&connectCtrlFlags, userdata,
4030 sizeof(connectCtrlFlags)))
4031 {
4032 ret = -EFAULT;
4033 } else {
4034 ar->arConnectCtrlFlags = connectCtrlFlags;
4035 }
4036 break;
4037 case AR6000_XIOCTL_WMI_SET_AKMP_PARAMS:
Joe Perches1071a132011-02-02 14:05:47 -08004038 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004039 ret = -EIO;
4040 } else if (copy_from_user(&akmpParams, userdata,
4041 sizeof(WMI_SET_AKMP_PARAMS_CMD)))
4042 {
4043 ret = -EFAULT;
4044 } else {
Joe Perches4f69cef2011-02-02 14:05:57 -08004045 if (wmi_set_akmp_params_cmd(ar->arWmi, &akmpParams) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004046 ret = -EIO;
4047 }
4048 }
4049 break;
4050 case AR6000_XIOCTL_WMI_SET_PMKID_LIST:
Joe Perches1071a132011-02-02 14:05:47 -08004051 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004052 ret = -EIO;
4053 } else {
4054 if (copy_from_user(&pmkidInfo.numPMKID, userdata,
4055 sizeof(pmkidInfo.numPMKID)))
4056 {
4057 ret = -EFAULT;
4058 break;
4059 }
4060 if (copy_from_user(&pmkidInfo.pmkidList,
4061 userdata + sizeof(pmkidInfo.numPMKID),
4062 pmkidInfo.numPMKID * sizeof(WMI_PMKID)))
4063 {
4064 ret = -EFAULT;
4065 break;
4066 }
Joe Perches4f69cef2011-02-02 14:05:57 -08004067 if (wmi_set_pmkid_list_cmd(ar->arWmi, &pmkidInfo) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004068 ret = -EIO;
4069 }
4070 }
4071 break;
4072 case AR6000_XIOCTL_WMI_GET_PMKID_LIST:
Joe Perches1071a132011-02-02 14:05:47 -08004073 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004074 ret = -EIO;
4075 } else {
Joe Perches4f69cef2011-02-02 14:05:57 -08004076 if (wmi_get_pmkid_list_cmd(ar->arWmi) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004077 ret = -EIO;
4078 }
4079 }
4080 break;
4081 case AR6000_XIOCTL_WMI_ABORT_SCAN:
Joe Perches1071a132011-02-02 14:05:47 -08004082 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004083 ret = -EIO;
4084 }
4085 ret = wmi_abort_scan_cmd(ar->arWmi);
4086 break;
4087 case AR6000_XIOCTL_AP_HIDDEN_SSID:
4088 {
Joe Perchesab3655d2011-02-02 14:05:49 -08004089 u8 hidden_ssid;
Joe Perches1071a132011-02-02 14:05:47 -08004090 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004091 ret = -EIO;
4092 } else if (copy_from_user(&hidden_ssid, userdata, sizeof(hidden_ssid))) {
4093 ret = -EFAULT;
4094 } else {
4095 wmi_ap_set_hidden_ssid(ar->arWmi, hidden_ssid);
4096 ar->ap_hidden_ssid = hidden_ssid;
4097 ar->ap_profile_flag = 1; /* There is a change in profile */
4098 }
4099 break;
4100 }
4101 case AR6000_XIOCTL_AP_GET_STA_LIST:
4102 {
Joe Perches1071a132011-02-02 14:05:47 -08004103 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004104 ret = -EIO;
4105 } else {
Joe Perchesab3655d2011-02-02 14:05:49 -08004106 u8 i;
Vipin Mehta30295c82010-09-01 12:06:33 -07004107 ap_get_sta_t temp;
4108 A_MEMZERO(&temp, sizeof(temp));
4109 for(i=0;i<AP_MAX_NUM_STA;i++) {
4110 A_MEMCPY(temp.sta[i].mac, ar->sta_list[i].mac, ATH_MAC_LEN);
4111 temp.sta[i].aid = ar->sta_list[i].aid;
4112 temp.sta[i].keymgmt = ar->sta_list[i].keymgmt;
4113 temp.sta[i].ucipher = ar->sta_list[i].ucipher;
4114 temp.sta[i].auth = ar->sta_list[i].auth;
4115 }
4116 if(copy_to_user((ap_get_sta_t *)rq->ifr_data, &temp,
4117 sizeof(ar->sta_list))) {
4118 ret = -EFAULT;
4119 }
4120 }
4121 break;
4122 }
4123 case AR6000_XIOCTL_AP_SET_NUM_STA:
4124 {
Joe Perchesab3655d2011-02-02 14:05:49 -08004125 u8 num_sta;
Joe Perches1071a132011-02-02 14:05:47 -08004126 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004127 ret = -EIO;
4128 } else if (copy_from_user(&num_sta, userdata, sizeof(num_sta))) {
4129 ret = -EFAULT;
4130 } else if(num_sta > AP_MAX_NUM_STA) {
4131 /* value out of range */
4132 ret = -EINVAL;
4133 } else {
4134 wmi_ap_set_num_sta(ar->arWmi, num_sta);
4135 }
4136 break;
4137 }
4138 case AR6000_XIOCTL_AP_SET_ACL_POLICY:
4139 {
Joe Perchesab3655d2011-02-02 14:05:49 -08004140 u8 policy;
Joe Perches1071a132011-02-02 14:05:47 -08004141 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004142 ret = -EIO;
4143 } else if (copy_from_user(&policy, userdata, sizeof(policy))) {
4144 ret = -EFAULT;
4145 } else if(policy == ar->g_acl.policy) {
4146 /* No change in policy */
4147 } else {
4148 if(!(policy & AP_ACL_RETAIN_LIST_MASK)) {
4149 /* clear ACL list */
4150 memset(&ar->g_acl,0,sizeof(WMI_AP_ACL));
4151 }
4152 ar->g_acl.policy = policy;
4153 wmi_ap_set_acl_policy(ar->arWmi, policy);
4154 }
4155 break;
4156 }
4157 case AR6000_XIOCTL_AP_SET_ACL_MAC:
4158 {
4159 WMI_AP_ACL_MAC_CMD acl;
Joe Perches1071a132011-02-02 14:05:47 -08004160 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004161 ret = -EIO;
4162 } else if (copy_from_user(&acl, userdata, sizeof(acl))) {
4163 ret = -EFAULT;
4164 } else {
4165 if(acl_add_del_mac(&ar->g_acl, &acl)) {
4166 wmi_ap_acl_mac_list(ar->arWmi, &acl);
4167 } else {
4168 A_PRINTF("ACL list error\n");
4169 ret = -EIO;
4170 }
4171 }
4172 break;
4173 }
4174 case AR6000_XIOCTL_AP_GET_ACL_LIST:
4175 {
Joe Perches1071a132011-02-02 14:05:47 -08004176 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004177 ret = -EIO;
4178 } else if(copy_to_user((WMI_AP_ACL *)rq->ifr_data, &ar->g_acl,
4179 sizeof(WMI_AP_ACL))) {
4180 ret = -EFAULT;
4181 }
4182 break;
4183 }
4184 case AR6000_XIOCTL_AP_COMMIT_CONFIG:
4185 {
4186 ret = ar6000_ap_mode_profile_commit(ar);
4187 break;
4188 }
4189 case IEEE80211_IOCTL_GETWPAIE:
4190 {
4191 struct ieee80211req_wpaie wpaie;
Joe Perches1071a132011-02-02 14:05:47 -08004192 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004193 ret = -EIO;
4194 } else if (copy_from_user(&wpaie, userdata, sizeof(wpaie))) {
4195 ret = -EFAULT;
4196 } else if (ar6000_ap_mode_get_wpa_ie(ar, &wpaie)) {
4197 ret = -EFAULT;
4198 } else if(copy_to_user(userdata, &wpaie, sizeof(wpaie))) {
4199 ret = -EFAULT;
4200 }
4201 break;
4202 }
4203 case AR6000_XIOCTL_AP_CONN_INACT_TIME:
4204 {
Joe Perchese1ce2a32011-02-02 14:05:51 -08004205 u32 period;
Joe Perches1071a132011-02-02 14:05:47 -08004206 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004207 ret = -EIO;
4208 } else if (copy_from_user(&period, userdata, sizeof(period))) {
4209 ret = -EFAULT;
4210 } else {
4211 wmi_ap_conn_inact_time(ar->arWmi, period);
4212 }
4213 break;
4214 }
4215 case AR6000_XIOCTL_AP_PROT_SCAN_TIME:
4216 {
4217 WMI_AP_PROT_SCAN_TIME_CMD bgscan;
Joe Perches1071a132011-02-02 14:05:47 -08004218 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004219 ret = -EIO;
4220 } else if (copy_from_user(&bgscan, userdata, sizeof(bgscan))) {
4221 ret = -EFAULT;
4222 } else {
4223 wmi_ap_bgscan_time(ar->arWmi, bgscan.period_min, bgscan.dwell_ms);
4224 }
4225 break;
4226 }
4227 case AR6000_XIOCTL_AP_SET_COUNTRY:
4228 {
4229 ret = ar6000_ioctl_set_country(dev, rq);
4230 break;
4231 }
4232 case AR6000_XIOCTL_AP_SET_DTIM:
4233 {
4234 WMI_AP_SET_DTIM_CMD d;
Joe Perches1071a132011-02-02 14:05:47 -08004235 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004236 ret = -EIO;
4237 } else if (copy_from_user(&d, userdata, sizeof(d))) {
4238 ret = -EFAULT;
4239 } else {
4240 if(d.dtim > 0 && d.dtim < 11) {
4241 ar->ap_dtim_period = d.dtim;
4242 wmi_ap_set_dtim(ar->arWmi, d.dtim);
4243 ar->ap_profile_flag = 1; /* There is a change in profile */
4244 } else {
4245 A_PRINTF("DTIM out of range. Valid range is [1-10]\n");
4246 ret = -EIO;
4247 }
4248 }
4249 break;
4250 }
4251 case AR6000_XIOCTL_WMI_TARGET_EVENT_REPORT:
4252 {
4253 WMI_SET_TARGET_EVENT_REPORT_CMD evtCfgCmd;
4254
Joe Perches1071a132011-02-02 14:05:47 -08004255 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004256 ret = -EIO;
4257 }
4258 if (copy_from_user(&evtCfgCmd, userdata,
4259 sizeof(evtCfgCmd))) {
4260 ret = -EFAULT;
4261 break;
4262 }
4263 ret = wmi_set_target_event_report_cmd(ar->arWmi, &evtCfgCmd);
4264 break;
4265 }
4266 case AR6000_XIOCTL_AP_INTRA_BSS_COMM:
4267 {
Joe Perchesab3655d2011-02-02 14:05:49 -08004268 u8 intra=0;
Joe Perches1071a132011-02-02 14:05:47 -08004269 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004270 ret = -EIO;
4271 } else if (copy_from_user(&intra, userdata, sizeof(intra))) {
4272 ret = -EFAULT;
4273 } else {
4274 ar->intra_bss = (intra?1:0);
4275 }
4276 break;
4277 }
4278 case AR6000_XIOCTL_DUMP_MODULE_DEBUG_INFO:
4279 {
4280 struct drv_debug_module_s moduleinfo;
4281
4282 if (copy_from_user(&moduleinfo, userdata, sizeof(moduleinfo))) {
4283 ret = -EFAULT;
4284 break;
4285 }
4286
4287 a_dump_module_debug_info_by_name(moduleinfo.modulename);
4288 ret = 0;
4289 break;
4290 }
4291 case AR6000_XIOCTL_MODULE_DEBUG_SET_MASK:
4292 {
4293 struct drv_debug_module_s moduleinfo;
4294
4295 if (copy_from_user(&moduleinfo, userdata, sizeof(moduleinfo))) {
4296 ret = -EFAULT;
4297 break;
4298 }
4299
Joe Perches391bb212011-01-27 20:04:21 -08004300 if (a_set_module_mask(moduleinfo.modulename, moduleinfo.mask)) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004301 ret = -EFAULT;
4302 }
4303
4304 break;
4305 }
4306 case AR6000_XIOCTL_MODULE_DEBUG_GET_MASK:
4307 {
4308 struct drv_debug_module_s moduleinfo;
4309
4310 if (copy_from_user(&moduleinfo, userdata, sizeof(moduleinfo))) {
4311 ret = -EFAULT;
4312 break;
4313 }
4314
Joe Perches391bb212011-01-27 20:04:21 -08004315 if (a_get_module_mask(moduleinfo.modulename, &moduleinfo.mask)) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004316 ret = -EFAULT;
4317 break;
4318 }
4319
4320 if (copy_to_user(userdata, &moduleinfo, sizeof(moduleinfo))) {
4321 ret = -EFAULT;
4322 break;
4323 }
4324
4325 break;
4326 }
4327#ifdef ATH_AR6K_11N_SUPPORT
4328 case AR6000_XIOCTL_DUMP_RCV_AGGR_STATS:
4329 {
4330 PACKET_LOG *copy_of_pkt_log;
4331
4332 aggr_dump_stats(ar->aggr_cntxt, &copy_of_pkt_log);
4333 if (copy_to_user(rq->ifr_data, copy_of_pkt_log, sizeof(PACKET_LOG))) {
4334 ret = -EFAULT;
4335 }
4336 break;
4337 }
4338 case AR6000_XIOCTL_SETUP_AGGR:
4339 {
4340 WMI_ADDBA_REQ_CMD cmd;
4341
Joe Perches1071a132011-02-02 14:05:47 -08004342 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004343 ret = -EIO;
4344 } else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
4345 ret = -EFAULT;
4346 } else {
4347 wmi_setup_aggr_cmd(ar->arWmi, cmd.tid);
4348 }
4349 }
4350 break;
4351
4352 case AR6000_XIOCTL_DELE_AGGR:
4353 {
4354 WMI_DELBA_REQ_CMD cmd;
4355
Joe Perches1071a132011-02-02 14:05:47 -08004356 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004357 ret = -EIO;
4358 } else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
4359 ret = -EFAULT;
4360 } else {
4361 wmi_delete_aggr_cmd(ar->arWmi, cmd.tid, cmd.is_sender_initiator);
4362 }
4363 }
4364 break;
4365
4366 case AR6000_XIOCTL_ALLOW_AGGR:
4367 {
4368 WMI_ALLOW_AGGR_CMD cmd;
4369
Joe Perches1071a132011-02-02 14:05:47 -08004370 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004371 ret = -EIO;
4372 } else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
4373 ret = -EFAULT;
4374 } else {
4375 wmi_allow_aggr_cmd(ar->arWmi, cmd.tx_allow_aggr, cmd.rx_allow_aggr);
4376 }
4377 }
4378 break;
4379
4380 case AR6000_XIOCTL_SET_HT_CAP:
4381 {
Joe Perches1071a132011-02-02 14:05:47 -08004382 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004383 ret = -EIO;
4384 } else if (copy_from_user(&htCap, userdata,
4385 sizeof(htCap)))
4386 {
4387 ret = -EFAULT;
4388 } else {
4389
Joe Perches4f69cef2011-02-02 14:05:57 -08004390 if (wmi_set_ht_cap_cmd(ar->arWmi, &htCap) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07004391 {
4392 ret = -EIO;
4393 }
4394 }
4395 break;
4396 }
4397 case AR6000_XIOCTL_SET_HT_OP:
4398 {
Joe Perches1071a132011-02-02 14:05:47 -08004399 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004400 ret = -EIO;
4401 } else if (copy_from_user(&htOp, userdata,
4402 sizeof(htOp)))
4403 {
4404 ret = -EFAULT;
4405 } else {
4406
Joe Perches4f69cef2011-02-02 14:05:57 -08004407 if (wmi_set_ht_op_cmd(ar->arWmi, htOp.sta_chan_width) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07004408 {
4409 ret = -EIO;
4410 }
4411 }
4412 break;
4413 }
4414#endif
4415 case AR6000_XIOCTL_ACL_DATA:
4416 {
4417 void *osbuf = NULL;
Joe Perches1071a132011-02-02 14:05:47 -08004418 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004419 ret = -EIO;
Joe Perches4f69cef2011-02-02 14:05:57 -08004420 } else if (ar6000_create_acl_data_osbuf(dev, (u8 *)userdata, &osbuf) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004421 ret = -EIO;
4422 } else {
Joe Perches4f69cef2011-02-02 14:05:57 -08004423 if (wmi_data_hdr_add(ar->arWmi, osbuf, DATA_MSGTYPE, 0, WMI_DATA_HDR_DATA_TYPE_ACL,0,NULL) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004424 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("XIOCTL_ACL_DATA - wmi_data_hdr_add failed\n"));
4425 } else {
4426 /* Send data buffer over HTC */
4427 ar6000_acl_data_tx(osbuf, ar->arNetDev);
4428 }
4429 }
4430 break;
4431 }
4432 case AR6000_XIOCTL_HCI_CMD:
4433 {
4434 char tmp_buf[512];
Joe Perchesf2ab1272011-02-02 14:05:53 -08004435 s8 i;
Vipin Mehta30295c82010-09-01 12:06:33 -07004436 WMI_HCI_CMD *cmd = (WMI_HCI_CMD *)tmp_buf;
Joe Perchesab3655d2011-02-02 14:05:49 -08004437 u8 size;
Vipin Mehta30295c82010-09-01 12:06:33 -07004438
4439 size = sizeof(cmd->cmd_buf_sz);
Joe Perches1071a132011-02-02 14:05:47 -08004440 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004441 ret = -EIO;
4442 } else if (copy_from_user(cmd, userdata, size)) {
4443 ret = -EFAULT;
4444 } else if(copy_from_user(cmd->buf, userdata + size, cmd->cmd_buf_sz)) {
4445 ret = -EFAULT;
4446 } else {
Joe Perches4f69cef2011-02-02 14:05:57 -08004447 if (wmi_send_hci_cmd(ar->arWmi, cmd->buf, cmd->cmd_buf_sz) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004448 ret = -EIO;
4449 }else if(loghci) {
4450 A_PRINTF_LOG("HCI Command To PAL --> \n");
4451 for(i = 0; i < cmd->cmd_buf_sz; i++) {
4452 A_PRINTF_LOG("0x%02x ",cmd->buf[i]);
4453 if((i % 10) == 0) {
4454 A_PRINTF_LOG("\n");
4455 }
4456 }
4457 A_PRINTF_LOG("\n");
4458 A_PRINTF_LOG("==================================\n");
4459 }
4460 }
4461 break;
4462 }
4463 case AR6000_XIOCTL_WLAN_CONN_PRECEDENCE:
4464 {
4465 WMI_SET_BT_WLAN_CONN_PRECEDENCE cmd;
Joe Perches1071a132011-02-02 14:05:47 -08004466 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004467 ret = -EIO;
4468 } else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
4469 ret = -EFAULT;
4470 } else {
4471 if (cmd.precedence == BT_WLAN_CONN_PRECDENCE_WLAN ||
4472 cmd.precedence == BT_WLAN_CONN_PRECDENCE_PAL) {
Joe Perches4f69cef2011-02-02 14:05:57 -08004473 if ( wmi_set_wlan_conn_precedence_cmd(ar->arWmi, cmd.precedence) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004474 ret = -EIO;
4475 }
4476 } else {
4477 ret = -EINVAL;
4478 }
4479 }
4480 break;
4481 }
4482 case AR6000_XIOCTL_AP_GET_STAT:
4483 {
4484 ret = ar6000_ioctl_get_ap_stats(dev, rq);
4485 break;
4486 }
4487 case AR6000_XIOCTL_SET_TX_SELECT_RATES:
4488 {
4489 WMI_SET_TX_SELECT_RATES_CMD masks;
4490
Joe Perches1071a132011-02-02 14:05:47 -08004491 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004492 ret = -EIO;
4493 } else if (copy_from_user(&masks, userdata,
4494 sizeof(masks)))
4495 {
4496 ret = -EFAULT;
4497 } else {
4498
Joe Perches4f69cef2011-02-02 14:05:57 -08004499 if (wmi_set_tx_select_rates_cmd(ar->arWmi, masks.rateMasks) != 0)
Vipin Mehta30295c82010-09-01 12:06:33 -07004500 {
4501 ret = -EIO;
4502 }
4503 }
4504 break;
4505 }
4506 case AR6000_XIOCTL_AP_GET_HIDDEN_SSID:
4507 {
4508 WMI_AP_HIDDEN_SSID_CMD ssid;
4509 ssid.hidden_ssid = ar->ap_hidden_ssid;
4510
Joe Perches1071a132011-02-02 14:05:47 -08004511 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004512 ret = -EIO;
4513 } else if(copy_to_user((WMI_AP_HIDDEN_SSID_CMD *)rq->ifr_data,
4514 &ssid, sizeof(WMI_AP_HIDDEN_SSID_CMD))) {
4515 ret = -EFAULT;
4516 }
4517 break;
4518 }
4519 case AR6000_XIOCTL_AP_GET_COUNTRY:
4520 {
4521 WMI_AP_SET_COUNTRY_CMD cty;
4522 A_MEMCPY(cty.countryCode, ar->ap_country_code, 3);
4523
Joe Perches1071a132011-02-02 14:05:47 -08004524 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004525 ret = -EIO;
4526 } else if(copy_to_user((WMI_AP_SET_COUNTRY_CMD *)rq->ifr_data,
4527 &cty, sizeof(WMI_AP_SET_COUNTRY_CMD))) {
4528 ret = -EFAULT;
4529 }
4530 break;
4531 }
4532 case AR6000_XIOCTL_AP_GET_WMODE:
4533 {
Joe Perches1071a132011-02-02 14:05:47 -08004534 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004535 ret = -EIO;
Joe Perchesab3655d2011-02-02 14:05:49 -08004536 } else if(copy_to_user((u8 *)rq->ifr_data,
4537 &ar->ap_wmode, sizeof(u8))) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004538 ret = -EFAULT;
4539 }
4540 break;
4541 }
4542 case AR6000_XIOCTL_AP_GET_DTIM:
4543 {
4544 WMI_AP_SET_DTIM_CMD dtim;
4545 dtim.dtim = ar->ap_dtim_period;
4546
Joe Perches1071a132011-02-02 14:05:47 -08004547 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004548 ret = -EIO;
4549 } else if(copy_to_user((WMI_AP_SET_DTIM_CMD *)rq->ifr_data,
4550 &dtim, sizeof(WMI_AP_SET_DTIM_CMD))) {
4551 ret = -EFAULT;
4552 }
4553 break;
4554 }
4555 case AR6000_XIOCTL_AP_GET_BINTVL:
4556 {
4557 WMI_BEACON_INT_CMD bi;
4558 bi.beaconInterval = ar->ap_beacon_interval;
4559
Joe Perches1071a132011-02-02 14:05:47 -08004560 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004561 ret = -EIO;
4562 } else if(copy_to_user((WMI_BEACON_INT_CMD *)rq->ifr_data,
4563 &bi, sizeof(WMI_BEACON_INT_CMD))) {
4564 ret = -EFAULT;
4565 }
4566 break;
4567 }
4568 case AR6000_XIOCTL_AP_GET_RTS:
4569 {
4570 WMI_SET_RTS_CMD rts;
4571 rts.threshold = ar->arRTS;
4572
Joe Perches1071a132011-02-02 14:05:47 -08004573 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004574 ret = -EIO;
4575 } else if(copy_to_user((WMI_SET_RTS_CMD *)rq->ifr_data,
4576 &rts, sizeof(WMI_SET_RTS_CMD))) {
4577 ret = -EFAULT;
4578 }
4579 break;
4580 }
4581 case AR6000_XIOCTL_FETCH_TARGET_REGS:
4582 {
Joe Perchese1ce2a32011-02-02 14:05:51 -08004583 u32 targregs[AR6003_FETCH_TARG_REGS_COUNT];
Vipin Mehta30295c82010-09-01 12:06:33 -07004584
4585 if (ar->arTargetType == TARGET_TYPE_AR6003) {
4586 ar6k_FetchTargetRegs(hifDevice, targregs);
Joe Perchese1ce2a32011-02-02 14:05:51 -08004587 if (copy_to_user((u32 *)rq->ifr_data, &targregs, sizeof(targregs)))
Vipin Mehta30295c82010-09-01 12:06:33 -07004588 {
4589 ret = -EFAULT;
4590 }
4591 } else {
4592 ret = -EOPNOTSUPP;
4593 }
4594 break;
4595 }
4596 case AR6000_XIOCTL_AP_SET_11BG_RATESET:
4597 {
4598 WMI_AP_SET_11BG_RATESET_CMD rate;
Joe Perches1071a132011-02-02 14:05:47 -08004599 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004600 ret = -EIO;
4601 } else if (copy_from_user(&rate, userdata, sizeof(rate))) {
4602 ret = -EFAULT;
4603 } else {
4604 wmi_ap_set_rateset(ar->arWmi, rate.rateset);
4605 }
4606 break;
4607 }
4608 case AR6000_XIOCTL_GET_WLAN_SLEEP_STATE:
4609 {
4610 WMI_REPORT_SLEEP_STATE_EVENT wmiSleepEvent ;
4611
4612 if (ar->arWlanState == WLAN_ENABLED) {
4613 wmiSleepEvent.sleepState = WMI_REPORT_SLEEP_STATUS_IS_AWAKE;
4614 } else {
4615 wmiSleepEvent.sleepState = WMI_REPORT_SLEEP_STATUS_IS_DEEP_SLEEP;
4616 }
4617 rq->ifr_ifru.ifru_ivalue = ar->arWlanState; /* return value */
4618
Joe Perchesab3655d2011-02-02 14:05:49 -08004619 ar6000_send_event_to_app(ar, WMI_REPORT_SLEEP_STATE_EVENTID, (u8 *)&wmiSleepEvent,
Vipin Mehta30295c82010-09-01 12:06:33 -07004620 sizeof(WMI_REPORT_SLEEP_STATE_EVENTID));
4621 break;
4622 }
4623#ifdef CONFIG_PM
4624 case AR6000_XIOCTL_SET_BT_HW_POWER_STATE:
4625 {
4626 unsigned int state;
Vasiliy Kulikovec53d612010-09-05 22:32:29 +04004627 if (get_user(state, (unsigned int *)userdata)) {
4628 ret = -EFAULT;
4629 break;
4630 }
Joe Perches4f69cef2011-02-02 14:05:57 -08004631 if (ar6000_set_bt_hw_state(ar, state)!= 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004632 ret = -EIO;
4633 }
4634 }
4635 break;
4636 case AR6000_XIOCTL_GET_BT_HW_POWER_STATE:
4637 rq->ifr_ifru.ifru_ivalue = !ar->arBTOff; /* return value */
4638 break;
4639#endif
4640
4641 case AR6000_XIOCTL_WMI_SET_TX_SGI_PARAM:
4642 {
4643 WMI_SET_TX_SGI_PARAM_CMD SGICmd;
4644
Joe Perches1071a132011-02-02 14:05:47 -08004645 if (ar->arWmiReady == false) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004646 ret = -EIO;
4647 } else if (copy_from_user(&SGICmd, userdata,
4648 sizeof(SGICmd))){
4649 ret = -EFAULT;
4650 } else{
Joe Perches4f69cef2011-02-02 14:05:57 -08004651 if (wmi_SGI_cmd(ar->arWmi, SGICmd.sgiMask, SGICmd.sgiPERThreshold) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004652 ret = -EIO;
4653 }
4654
4655 }
4656 break;
4657 }
4658
4659 case AR6000_XIOCTL_ADD_AP_INTERFACE:
4660#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
4661 {
4662 char ap_ifname[IFNAMSIZ] = {0,};
4663 if (copy_from_user(ap_ifname, userdata, IFNAMSIZ)) {
4664 ret = -EFAULT;
4665 } else {
Joe Perches4f69cef2011-02-02 14:05:57 -08004666 if (ar6000_add_ap_interface(ar, ap_ifname) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004667 ret = -EIO;
4668 }
4669 }
4670 }
4671#else
4672 ret = -EOPNOTSUPP;
4673#endif
4674 break;
4675 case AR6000_XIOCTL_REMOVE_AP_INTERFACE:
4676#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
Joe Perches4f69cef2011-02-02 14:05:57 -08004677 if (ar6000_remove_ap_interface(ar) != 0) {
Vipin Mehta30295c82010-09-01 12:06:33 -07004678 ret = -EIO;
4679 }
4680#else
4681 ret = -EOPNOTSUPP;
4682#endif
4683 break;
4684
Vipin Mehta711a1bc2011-02-18 13:13:11 -08004685 case AR6000_XIOCTL_WMI_SET_EXCESS_TX_RETRY_THRES:
4686 {
4687 ret = ar6000_xioctl_set_excess_tx_retry_thres_cmd(dev, userdata);
4688 break;
4689 }
4690
Vipin Mehta30295c82010-09-01 12:06:33 -07004691 default:
4692 ret = -EOPNOTSUPP;
4693 }
4694
4695ioctl_done:
4696 rtnl_lock(); /* restore rtnl state */
4697 dev_put(dev);
4698
4699 return ret;
4700}
4701
Joe Perchesab3655d2011-02-02 14:05:49 -08004702u8 mac_cmp_wild(u8 *mac, u8 *new_mac, u8 wild, u8 new_wild)
Vipin Mehta30295c82010-09-01 12:06:33 -07004703{
Joe Perchesab3655d2011-02-02 14:05:49 -08004704 u8 i;
Vipin Mehta30295c82010-09-01 12:06:33 -07004705
4706 for(i=0;i<ATH_MAC_LEN;i++) {
4707 if((wild & 1<<i) && (new_wild & 1<<i)) continue;
4708 if(mac[i] != new_mac[i]) return 1;
4709 }
4710 if((A_MEMCMP(new_mac, null_mac, 6)==0) && new_wild &&
4711 (wild != new_wild)) {
4712 return 1;
4713 }
4714
4715 return 0;
4716}
4717
Joe Perchesab3655d2011-02-02 14:05:49 -08004718u8 acl_add_del_mac(WMI_AP_ACL *a, WMI_AP_ACL_MAC_CMD *acl)
Vipin Mehta30295c82010-09-01 12:06:33 -07004719{
Joe Perchesf2ab1272011-02-02 14:05:53 -08004720 s8 already_avail=-1, free_slot=-1, i;
Vipin Mehta30295c82010-09-01 12:06:33 -07004721
4722 /* To check whether this mac is already there in our list */
4723 for(i=AP_ACL_SIZE-1;i>=0;i--)
4724 {
4725 if(mac_cmp_wild(a->acl_mac[i], acl->mac, a->wildcard[i],
4726 acl->wildcard)==0)
4727 already_avail = i;
4728
4729 if(!((1 << i) & a->index))
4730 free_slot = i;
4731 }
4732
4733 if(acl->action == ADD_MAC_ADDR)
4734 {
4735 /* Dont add mac if it is already available */
4736 if((already_avail >= 0) || (free_slot == -1))
4737 return 0;
4738
4739 A_MEMCPY(a->acl_mac[free_slot], acl->mac, ATH_MAC_LEN);
4740 a->index = a->index | (1 << free_slot);
4741 acl->index = free_slot;
4742 a->wildcard[free_slot] = acl->wildcard;
4743 return 1;
4744 }
4745 else if(acl->action == DEL_MAC_ADDR)
4746 {
4747 if(acl->index > AP_ACL_SIZE)
4748 return 0;
4749
4750 if(!(a->index & (1 << acl->index)))
4751 return 0;
4752
4753 A_MEMZERO(a->acl_mac[acl->index],ATH_MAC_LEN);
4754 a->index = a->index & ~(1 << acl->index);
4755 a->wildcard[acl->index] = 0;
4756 return 1;
4757 }
4758
4759 return 0;
4760}