1 //------------------------------------------------------------------------------
2 // Copyright (c) 2004-2010 Atheros Communications Inc.
3 // All rights reserved.
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.
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.
21 // Author(s): ="Atheros"
22 //------------------------------------------------------------------------------
24 #include "ar6000_drv.h"
25 #include "ieee80211_ioctl.h"
26 #include "ar6kap_common.h"
27 #include "targaddrs.h"
29 #include "wlan_config.h"
31 extern int enablerssicompensation;
33 extern unsigned int wmitimeout;
34 extern A_WAITQUEUE_HEAD arEvent;
35 extern int tspecCompliance;
40 ar6000_ioctl_get_roam_tbl(struct net_device *dev, struct ifreq *rq)
42 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
44 if (ar->arWmiReady == false) {
48 if(wmi_get_roam_tbl_cmd(ar->arWmi) != A_OK) {
56 ar6000_ioctl_get_roam_data(struct net_device *dev, struct ifreq *rq)
58 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
60 if (ar->arWmiReady == false) {
65 /* currently assume only roam times are required */
66 if(wmi_get_roam_data_cmd(ar->arWmi, ROAM_DATA_TIME) != A_OK) {
75 ar6000_ioctl_set_roam_ctrl(struct net_device *dev, char *userdata)
77 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
78 WMI_SET_ROAM_CTRL_CMD cmd;
79 u8 size = sizeof(cmd);
81 if (ar->arWmiReady == false) {
86 if (copy_from_user(&cmd, userdata, size)) {
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);
96 if (copy_from_user(&cmd, userdata, size)) {
100 if(wmi_set_roam_ctrl_cmd(ar->arWmi, &cmd, size) != A_OK) {
108 ar6000_ioctl_set_powersave_timers(struct net_device *dev, char *userdata)
110 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
111 WMI_POWERSAVE_TIMERS_POLICY_CMD cmd;
112 u8 size = sizeof(cmd);
114 if (ar->arWmiReady == false) {
118 if (copy_from_user(&cmd, userdata, size)) {
122 if (copy_from_user(&cmd, userdata, size)) {
126 if(wmi_set_powersave_timers_cmd(ar->arWmi, &cmd, size) != A_OK) {
134 ar6000_ioctl_set_qos_supp(struct net_device *dev, struct ifreq *rq)
136 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
137 WMI_SET_QOS_SUPP_CMD cmd;
140 if ((dev->flags & IFF_UP) != IFF_UP) {
143 if (ar->arWmiReady == false) {
147 if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
153 ret = wmi_set_qos_supp_cmd(ar->arWmi, cmd.status);
169 ar6000_ioctl_set_wmm(struct net_device *dev, struct ifreq *rq)
171 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
175 if ((dev->flags & IFF_UP) != IFF_UP) {
178 if (ar->arWmiReady == false) {
182 if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
188 if (cmd.status == WMI_WMM_ENABLED) {
189 ar->arWmmEnabled = true;
191 ar->arWmmEnabled = false;
194 ret = wmi_set_wmm_cmd(ar->arWmi, cmd.status);
210 ar6000_ioctl_set_txop(struct net_device *dev, struct ifreq *rq)
212 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
213 WMI_SET_WMM_TXOP_CMD cmd;
216 if ((dev->flags & IFF_UP) != IFF_UP) {
219 if (ar->arWmiReady == false) {
223 if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
229 ret = wmi_set_wmm_txop(ar->arWmi, cmd.txopEnable);
245 ar6000_ioctl_get_rd(struct net_device *dev, struct ifreq *rq)
247 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
250 if ((dev->flags & IFF_UP) != IFF_UP || ar->arWmiReady == false) {
254 if(copy_to_user((char *)((unsigned int*)rq->ifr_data + 1),
255 &ar->arRegCode, sizeof(ar->arRegCode)))
262 ar6000_ioctl_set_country(struct net_device *dev, struct ifreq *rq)
264 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
265 WMI_AP_SET_COUNTRY_CMD cmd;
268 if ((dev->flags & IFF_UP) != IFF_UP) {
271 if (ar->arWmiReady == false) {
275 if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
281 ar->ap_profile_flag = 1; /* There is a change in profile */
283 ret = wmi_set_country(ar->arWmi, cmd.countryCode);
284 A_MEMCPY(ar->ap_country_code, cmd.countryCode, 3);
300 /* Get power mode command */
302 ar6000_ioctl_get_power_mode(struct net_device *dev, struct ifreq *rq)
304 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
305 WMI_POWER_MODE_CMD power_mode;
308 if (ar->arWmiReady == false) {
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))) {
322 ar6000_ioctl_set_channelParams(struct net_device *dev, struct ifreq *rq)
324 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
325 WMI_CHANNEL_PARAMS_CMD cmd, *cmdp;
328 if (ar->arWmiReady == false) {
333 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
337 if( (ar->arNextMode == AP_NETWORK) && (cmd.numChannels || cmd.scanParam) ) {
338 A_PRINTF("ERROR: Only wmode is allowed in AP mode\n");
342 if (cmd.numChannels > 1) {
343 cmdp = A_MALLOC(130);
344 if (copy_from_user(cmdp, rq->ifr_data,
346 ((cmd.numChannels - 1) * sizeof(A_UINT16))))
355 if ((ar->arPhyCapability == WMI_11G_CAPABILITY) &&
356 ((cmdp->phyMode == WMI_11A_MODE) || (cmdp->phyMode == WMI_11AG_MODE)))
362 (wmi_set_channelParams_cmd(ar->arWmi, cmdp->scanParam, cmdp->phyMode,
363 cmdp->numChannels, cmdp->channelList)
369 if (cmd.numChannels > 1) {
373 ar->ap_wmode = cmdp->phyMode;
374 /* Set the profile change flag to allow a commit cmd */
375 ar->ap_profile_flag = 1;
382 ar6000_ioctl_set_snr_threshold(struct net_device *dev, struct ifreq *rq)
385 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
386 WMI_SNR_THRESHOLD_PARAMS_CMD cmd;
389 if (ar->arWmiReady == false) {
393 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
397 if( wmi_set_snr_threshold_params(ar->arWmi, &cmd) != A_OK ) {
405 ar6000_ioctl_set_rssi_threshold(struct net_device *dev, struct ifreq *rq)
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; \
417 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
418 WMI_RSSI_THRESHOLD_PARAMS_CMD cmd;
419 USER_RSSI_PARAMS rssiParams;
423 if (ar->arWmiReady == false) {
427 if (copy_from_user((char *)&rssiParams, (char *)((unsigned int *)rq->ifr_data + 1), sizeof(USER_RSSI_PARAMS))) {
430 cmd.weight = rssiParams.weight;
431 cmd.pollTime = rssiParams.pollTime;
433 A_MEMCPY(ar->rssi_map, &rssiParams.tholds, sizeof(ar->rssi_map));
435 * only 6 elements, so use bubble sorting, in ascending order
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) {
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) {
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));
463 if (enablerssicompensation) {
464 for (i = 0; i < 6; i++)
465 ar->rssi_map[i].rssi = rssi_compensation_reverse_calc(ar, ar->rssi_map[i].rssi, true);
466 for (i = 6; i < 12; i++)
467 ar->rssi_map[i].rssi = rssi_compensation_reverse_calc(ar, ar->rssi_map[i].rssi, false);
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;
483 if( wmi_set_rssi_threshold_params(ar->arWmi, &cmd) != A_OK ) {
491 ar6000_ioctl_set_lq_threshold(struct net_device *dev, struct ifreq *rq)
494 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
495 WMI_LQ_THRESHOLD_PARAMS_CMD cmd;
498 if (ar->arWmiReady == false) {
502 if (copy_from_user(&cmd, (char *)((unsigned int *)rq->ifr_data + 1), sizeof(cmd))) {
506 if( wmi_set_lq_threshold_params(ar->arWmi, &cmd) != A_OK ) {
515 ar6000_ioctl_set_probedSsid(struct net_device *dev, struct ifreq *rq)
517 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
518 WMI_PROBED_SSID_CMD cmd;
521 if (ar->arWmiReady == false) {
525 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
529 if (wmi_probedSsid_cmd(ar->arWmi, cmd.entryIndex, cmd.flag, cmd.ssidLength,
539 ar6000_ioctl_set_badAp(struct net_device *dev, struct ifreq *rq)
541 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
542 WMI_ADD_BAD_AP_CMD cmd;
545 if (ar->arWmiReady == false) {
550 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
554 if (cmd.badApIndex > WMI_MAX_BAD_AP_INDEX) {
558 if (A_MEMCMP(cmd.bssid, null_mac, AR6000_ETH_ADDR_LEN) == 0) {
560 * This is a delete badAP.
562 if (wmi_deleteBadAp_cmd(ar->arWmi, cmd.badApIndex) != A_OK) {
566 if (wmi_addBadAp_cmd(ar->arWmi, cmd.badApIndex, cmd.bssid) != A_OK) {
575 ar6000_ioctl_create_qos(struct net_device *dev, struct ifreq *rq)
577 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
578 WMI_CREATE_PSTREAM_CMD cmd;
581 if (ar->arWmiReady == false) {
586 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
590 ret = wmi_verify_tspec_params(&cmd, tspecCompliance);
592 ret = wmi_create_pstream_cmd(ar->arWmi, &cmd);
608 ar6000_ioctl_delete_qos(struct net_device *dev, struct ifreq *rq)
610 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
611 WMI_DELETE_PSTREAM_CMD cmd;
614 if (ar->arWmiReady == false) {
618 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
622 ret = wmi_delete_pstream_cmd(ar->arWmi, cmd.trafficClass, cmd.tsid);
638 ar6000_ioctl_get_qos_queue(struct net_device *dev, struct ifreq *rq)
640 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
641 struct ar6000_queuereq qreq;
644 if (ar->arWmiReady == false) {
648 if( copy_from_user(&qreq, rq->ifr_data,
649 sizeof(struct ar6000_queuereq)))
652 qreq.activeTsids = wmi_get_mapped_qos_queue(ar->arWmi, qreq.trafficClass);
654 if (copy_to_user(rq->ifr_data, &qreq,
655 sizeof(struct ar6000_queuereq)))
663 #ifdef CONFIG_HOST_TCMD_SUPPORT
665 ar6000_ioctl_tcmd_get_rx_report(struct net_device *dev,
666 struct ifreq *rq, u8 *data, A_UINT32 len)
668 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
669 A_UINT32 buf[4+TCMD_MAX_RATES];
672 if (ar->bIsDestroyProgress) {
676 if (ar->arWmiReady == false) {
680 if (down_interruptible(&ar->arSem)) {
684 if (ar->bIsDestroyProgress) {
689 ar->tcmdRxReport = 0;
690 if (wmi_test_cmd(ar->arWmi, data, len) != A_OK) {
695 wait_event_interruptible_timeout(arEvent, ar->tcmdRxReport != 0, wmitimeout * HZ);
697 if (signal_pending(current)) {
701 buf[0] = ar->tcmdRxTotalPkt;
702 buf[1] = ar->tcmdRxRssi;
703 buf[2] = ar->tcmdRxcrcErrPkt;
704 buf[3] = ar->tcmdRxsecErrPkt;
705 A_MEMCPY(((A_UCHAR *)buf)+(4*sizeof(A_UINT32)), ar->tcmdRateCnt, sizeof(ar->tcmdRateCnt));
706 A_MEMCPY(((A_UCHAR *)buf)+(4*sizeof(A_UINT32))+(TCMD_MAX_RATES *sizeof(A_UINT16)), ar->tcmdRateCntShortGuard, sizeof(ar->tcmdRateCntShortGuard));
708 if (!ret && copy_to_user(rq->ifr_data, buf, sizeof(buf))) {
718 ar6000_tcmd_rx_report_event(void *devt, u8 *results, int len)
720 AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
721 TCMD_CONT_RX * rx_rep = (TCMD_CONT_RX *)results;
723 if (enablerssicompensation) {
724 rx_rep->u.report.rssiInDBm = rssi_compensation_calc_tcmd(tcmdRxFreq, rx_rep->u.report.rssiInDBm,rx_rep->u.report.totalPkt);
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));
740 #endif /* CONFIG_HOST_TCMD_SUPPORT*/
743 ar6000_ioctl_set_error_report_bitmask(struct net_device *dev, struct ifreq *rq)
745 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
746 WMI_TARGET_ERROR_REPORT_BITMASK cmd;
749 if (ar->arWmiReady == false) {
753 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
757 ret = wmi_set_error_report_bitmask(ar->arWmi, cmd.bitmask);
759 return (ret==0 ? ret : -EINVAL);
763 ar6000_clear_target_stats(struct net_device *dev)
765 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
766 TARGET_STATS *pStats = &ar->arTargetStats;
769 if (ar->arWmiReady == false) {
772 AR6000_SPIN_LOCK(&ar->arLock, 0);
773 A_MEMZERO(pStats, sizeof(TARGET_STATS));
774 AR6000_SPIN_UNLOCK(&ar->arLock, 0);
779 ar6000_ioctl_get_target_stats(struct net_device *dev, struct ifreq *rq)
781 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
782 TARGET_STATS_CMD cmd;
783 TARGET_STATS *pStats = &ar->arTargetStats;
786 if (ar->bIsDestroyProgress) {
789 if (ar->arWmiReady == false) {
792 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
795 if (down_interruptible(&ar->arSem)) {
798 if (ar->bIsDestroyProgress) {
803 ar->statsUpdatePending = true;
805 if(wmi_get_stats_cmd(ar->arWmi) != A_OK) {
810 wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == false, wmitimeout * HZ);
812 if (signal_pending(current)) {
816 if (!ret && copy_to_user(rq->ifr_data, pStats, sizeof(*pStats))) {
820 if (cmd.clearStats == 1) {
821 ret = ar6000_clear_target_stats(dev);
830 ar6000_ioctl_get_ap_stats(struct net_device *dev, struct ifreq *rq)
832 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
833 A_UINT32 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 */
834 WMI_AP_MODE_STAT *pStats = &ar->arAPStats;
837 if (ar->arWmiReady == false) {
840 if (copy_from_user(&action, (char *)((unsigned int*)rq->ifr_data + 1),
845 if (action == AP_CLEAR_STATS) {
847 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;
858 AR6000_SPIN_UNLOCK(&ar->arLock, 0);
862 if (down_interruptible(&ar->arSem)) {
866 ar->statsUpdatePending = true;
868 if(wmi_get_stats_cmd(ar->arWmi) != A_OK) {
873 wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == false, wmitimeout * HZ);
875 if (signal_pending(current)) {
879 if (!ret && copy_to_user(rq->ifr_data, pStats, sizeof(*pStats))) {
889 ar6000_ioctl_set_access_params(struct net_device *dev, struct ifreq *rq)
891 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
892 WMI_SET_ACCESS_PARAMS_CMD cmd;
895 if (ar->arWmiReady == false) {
899 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
903 if (wmi_set_access_params_cmd(ar->arWmi, cmd.ac, cmd.txop, cmd.eCWmin, cmd.eCWmax,
915 ar6000_ioctl_set_disconnect_timeout(struct net_device *dev, struct ifreq *rq)
917 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
918 WMI_DISC_TIMEOUT_CMD cmd;
921 if (ar->arWmiReady == false) {
925 if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
929 if (wmi_disctimeout_cmd(ar->arWmi, cmd.disconnectTimeout) == A_OK)
940 ar6000_xioctl_set_voice_pkt_size(struct net_device *dev, char *userdata)
942 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
943 WMI_SET_VOICE_PKT_SIZE_CMD cmd;
946 if (ar->arWmiReady == false) {
950 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
954 if (wmi_set_voice_pkt_size_cmd(ar->arWmi, cmd.voicePktSize) == A_OK)
966 ar6000_xioctl_set_max_sp_len(struct net_device *dev, char *userdata)
968 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
969 WMI_SET_MAX_SP_LEN_CMD cmd;
972 if (ar->arWmiReady == false) {
976 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
980 if (wmi_set_max_sp_len_cmd(ar->arWmi, cmd.maxSPLen) == A_OK)
992 ar6000_xioctl_set_bt_status_cmd(struct net_device *dev, char *userdata)
994 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
995 WMI_SET_BT_STATUS_CMD cmd;
998 if (ar->arWmiReady == false) {
1002 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1006 if (wmi_set_bt_status_cmd(ar->arWmi, cmd.streamType, cmd.status) == A_OK)
1017 ar6000_xioctl_set_bt_params_cmd(struct net_device *dev, char *userdata)
1019 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1020 WMI_SET_BT_PARAMS_CMD cmd;
1023 if (ar->arWmiReady == false) {
1027 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1031 if (wmi_set_bt_params_cmd(ar->arWmi, &cmd) == A_OK)
1042 ar6000_xioctl_set_btcoex_fe_ant_cmd(struct net_device * dev, char *userdata)
1044 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1045 WMI_SET_BTCOEX_FE_ANT_CMD cmd;
1048 if (ar->arWmiReady == false) {
1051 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1055 if (wmi_set_btcoex_fe_ant_cmd(ar->arWmi, &cmd) == A_OK)
1066 ar6000_xioctl_set_btcoex_colocated_bt_dev_cmd(struct net_device * dev, char *userdata)
1068 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1069 WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD cmd;
1072 if (ar->arWmiReady == false) {
1076 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1080 if (wmi_set_btcoex_colocated_bt_dev_cmd(ar->arWmi, &cmd) == A_OK)
1091 ar6000_xioctl_set_btcoex_btinquiry_page_config_cmd(struct net_device * dev, char *userdata)
1093 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1094 WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG_CMD cmd;
1097 if (ar->arWmiReady == false) {
1101 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1105 if (wmi_set_btcoex_btinquiry_page_config_cmd(ar->arWmi, &cmd) == A_OK)
1116 ar6000_xioctl_set_btcoex_sco_config_cmd(struct net_device * dev, char *userdata)
1118 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1119 WMI_SET_BTCOEX_SCO_CONFIG_CMD cmd;
1122 if (ar->arWmiReady == false) {
1126 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1130 if (wmi_set_btcoex_sco_config_cmd(ar->arWmi, &cmd) == A_OK)
1141 ar6000_xioctl_set_btcoex_a2dp_config_cmd(struct net_device * dev,
1144 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1145 WMI_SET_BTCOEX_A2DP_CONFIG_CMD cmd;
1148 if (ar->arWmiReady == false) {
1152 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1156 if (wmi_set_btcoex_a2dp_config_cmd(ar->arWmi, &cmd) == A_OK)
1167 ar6000_xioctl_set_btcoex_aclcoex_config_cmd(struct net_device * dev, char *userdata)
1169 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1170 WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD cmd;
1173 if (ar->arWmiReady == false) {
1177 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1181 if (wmi_set_btcoex_aclcoex_config_cmd(ar->arWmi, &cmd) == A_OK)
1192 ar60000_xioctl_set_btcoex_debug_cmd(struct net_device * dev, char *userdata)
1194 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1195 WMI_SET_BTCOEX_DEBUG_CMD cmd;
1198 if (ar->arWmiReady == false) {
1202 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1206 if (wmi_set_btcoex_debug_cmd(ar->arWmi, &cmd) == A_OK)
1217 ar6000_xioctl_set_btcoex_bt_operating_status_cmd(struct net_device * dev, char *userdata)
1219 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1220 WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMD cmd;
1223 if (ar->arWmiReady == false) {
1227 if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
1231 if (wmi_set_btcoex_bt_operating_status_cmd(ar->arWmi, &cmd) == A_OK)
1241 ar6000_xioctl_get_btcoex_config_cmd(struct net_device * dev, char *userdata,
1245 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1246 AR6000_BTCOEX_CONFIG btcoexConfig;
1247 WMI_BTCOEX_CONFIG_EVENT *pbtcoexConfigEv = &ar->arBtcoexConfig;
1251 if (ar->bIsDestroyProgress) {
1254 if (ar->arWmiReady == false) {
1257 if (copy_from_user(&btcoexConfig.configCmd, userdata, sizeof(AR6000_BTCOEX_CONFIG))) {
1260 if (down_interruptible(&ar->arSem)) {
1261 return -ERESTARTSYS;
1264 if (wmi_get_btcoex_config_cmd(ar->arWmi, (WMI_GET_BTCOEX_CONFIG_CMD *)&btcoexConfig.configCmd) != A_OK)
1270 ar->statsUpdatePending = true;
1272 wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == false, wmitimeout * HZ);
1274 if (signal_pending(current)) {
1278 if (!ret && copy_to_user(btcoexConfig.configEvent, pbtcoexConfigEv, sizeof(WMI_BTCOEX_CONFIG_EVENT))) {
1286 ar6000_xioctl_get_btcoex_stats_cmd(struct net_device * dev, char *userdata, struct ifreq *rq)
1288 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1289 AR6000_BTCOEX_STATS btcoexStats;
1290 WMI_BTCOEX_STATS_EVENT *pbtcoexStats = &ar->arBtcoexStats;
1293 if (ar->bIsDestroyProgress) {
1296 if (ar->arWmiReady == false) {
1300 if (down_interruptible(&ar->arSem)) {
1301 return -ERESTARTSYS;
1304 if (copy_from_user(&btcoexStats.statsEvent, userdata, sizeof(AR6000_BTCOEX_CONFIG))) {
1308 if (wmi_get_btcoex_stats_cmd(ar->arWmi) != A_OK)
1314 ar->statsUpdatePending = true;
1316 wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == false, wmitimeout * HZ);
1318 if (signal_pending(current)) {
1322 if (!ret && copy_to_user(btcoexStats.statsEvent, pbtcoexStats, sizeof(WMI_BTCOEX_STATS_EVENT))) {
1332 #ifdef CONFIG_HOST_GPIO_SUPPORT
1333 struct ar6000_gpio_intr_wait_cmd_s gpio_intr_results;
1334 /* gpio_reg_results and gpio_data_available are protected by arSem */
1335 static struct ar6000_gpio_register_cmd_s gpio_reg_results;
1336 static bool gpio_data_available; /* Requested GPIO data available */
1337 static bool gpio_intr_available; /* GPIO interrupt info available */
1338 static bool gpio_ack_received; /* GPIO ack was received */
1340 /* Host-side initialization for General Purpose I/O support */
1341 void ar6000_gpio_init(void)
1343 gpio_intr_available = false;
1344 gpio_data_available = false;
1345 gpio_ack_received = false;
1349 * Called when a GPIO interrupt is received from the Target.
1350 * intr_values shows which GPIO pins have interrupted.
1351 * input_values shows a recent value of GPIO pins.
1354 ar6000_gpio_intr_rx(A_UINT32 intr_mask, A_UINT32 input_values)
1356 gpio_intr_results.intr_mask = intr_mask;
1357 gpio_intr_results.input_values = input_values;
1358 *((volatile bool *)&gpio_intr_available) = true;
1363 * This is called when a response is received from the Target
1364 * for a previous or ar6000_gpio_input_get or ar6000_gpio_register_get
1368 ar6000_gpio_data_rx(A_UINT32 reg_id, A_UINT32 value)
1370 gpio_reg_results.gpioreg_id = reg_id;
1371 gpio_reg_results.value = value;
1372 *((volatile bool *)&gpio_data_available) = true;
1377 * This is called when an acknowledgement is received from the Target
1378 * for a previous or ar6000_gpio_output_set or ar6000_gpio_register_set
1382 ar6000_gpio_ack_rx(void)
1384 gpio_ack_received = true;
1389 ar6000_gpio_output_set(struct net_device *dev,
1391 A_UINT32 clear_mask,
1392 A_UINT32 enable_mask,
1393 A_UINT32 disable_mask)
1395 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1397 gpio_ack_received = false;
1398 return wmi_gpio_output_set(ar->arWmi,
1399 set_mask, clear_mask, enable_mask, disable_mask);
1403 ar6000_gpio_input_get(struct net_device *dev)
1405 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1407 *((volatile bool *)&gpio_data_available) = false;
1408 return wmi_gpio_input_get(ar->arWmi);
1412 ar6000_gpio_register_set(struct net_device *dev,
1413 A_UINT32 gpioreg_id,
1416 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1418 gpio_ack_received = false;
1419 return wmi_gpio_register_set(ar->arWmi, gpioreg_id, value);
1423 ar6000_gpio_register_get(struct net_device *dev,
1424 A_UINT32 gpioreg_id)
1426 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1428 *((volatile bool *)&gpio_data_available) = false;
1429 return wmi_gpio_register_get(ar->arWmi, gpioreg_id);
1433 ar6000_gpio_intr_ack(struct net_device *dev,
1436 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1438 gpio_intr_available = false;
1439 return wmi_gpio_intr_ack(ar->arWmi, ack_mask);
1441 #endif /* CONFIG_HOST_GPIO_SUPPORT */
1443 #if defined(CONFIG_TARGET_PROFILE_SUPPORT)
1444 static struct prof_count_s prof_count_results;
1445 static bool prof_count_available; /* Requested GPIO data available */
1448 prof_count_get(struct net_device *dev)
1450 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1452 *((volatile bool *)&prof_count_available) = false;
1453 return wmi_prof_count_get_cmd(ar->arWmi);
1457 * This is called when a response is received from the Target
1458 * for a previous prof_count_get call.
1461 prof_count_rx(A_UINT32 addr, A_UINT32 count)
1463 prof_count_results.addr = addr;
1464 prof_count_results.count = count;
1465 *((volatile bool *)&prof_count_available) = true;
1468 #endif /* CONFIG_TARGET_PROFILE_SUPPORT */
1472 ar6000_create_acl_data_osbuf(struct net_device *dev, u8 *userdata, void **p_osbuf)
1476 HCI_ACL_DATA_PKT *acl;
1477 u8 hdr_size, *datap=NULL;
1480 /* ACL is in data path. There is a need to create pool
1481 * mechanism for allocating and freeing NETBUFs - ToDo later.
1485 acl = (HCI_ACL_DATA_PKT *)tmp_space;
1486 hdr_size = sizeof(acl->hdl_and_flags) + sizeof(acl->data_len);
1489 if (a_copy_from_user(acl, userdata, hdr_size)) {
1494 osbuf = A_NETBUF_ALLOC(hdr_size + acl->data_len);
1495 if (osbuf == NULL) {
1499 A_NETBUF_PUT(osbuf, hdr_size + acl->data_len);
1500 datap = (u8 *)A_NETBUF_DATA(osbuf);
1502 /* Real copy to osbuf */
1503 acl = (HCI_ACL_DATA_PKT *)(datap);
1504 A_MEMCPY(acl, tmp_space, hdr_size);
1505 if (a_copy_from_user(acl->data, userdata + hdr_size, acl->data_len)) {
1514 A_NETBUF_FREE(osbuf);
1522 ar6000_ioctl_ap_setparam(AR_SOFTC_T *ar, int param, int value)
1527 case IEEE80211_PARAM_WPA:
1530 ar->arAuthMode = WPA_AUTH;
1533 ar->arAuthMode = WPA2_AUTH;
1536 ar->arAuthMode = WPA_AUTH | WPA2_AUTH;
1539 ar->arAuthMode = NONE_AUTH;
1543 case IEEE80211_PARAM_AUTHMODE:
1544 if(value == IEEE80211_AUTH_WPA_PSK) {
1545 if (WPA_AUTH == ar->arAuthMode) {
1546 ar->arAuthMode = WPA_PSK_AUTH;
1547 } else if (WPA2_AUTH == ar->arAuthMode) {
1548 ar->arAuthMode = WPA2_PSK_AUTH;
1549 } else if ((WPA_AUTH | WPA2_AUTH) == ar->arAuthMode) {
1550 ar->arAuthMode = WPA_PSK_AUTH | WPA2_PSK_AUTH;
1552 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Error - Setting PSK "\
1553 "mode when WPA param was set to %d\n",
1559 case IEEE80211_PARAM_UCASTCIPHER:
1560 ar->arPairwiseCrypto = 0;
1561 if(value & (1<<IEEE80211_CIPHER_AES_CCM)) {
1562 ar->arPairwiseCrypto |= AES_CRYPT;
1564 if(value & (1<<IEEE80211_CIPHER_TKIP)) {
1565 ar->arPairwiseCrypto |= TKIP_CRYPT;
1567 if(!ar->arPairwiseCrypto) {
1568 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
1569 ("Error - Invalid cipher in WPA \n"));
1573 case IEEE80211_PARAM_PRIVACY:
1575 ar->arDot11AuthMode = OPEN_AUTH;
1576 ar->arAuthMode = NONE_AUTH;
1577 ar->arPairwiseCrypto = NONE_CRYPT;
1578 ar->arPairwiseCryptoLen = 0;
1579 ar->arGroupCrypto = NONE_CRYPT;
1580 ar->arGroupCryptoLen = 0;
1584 case IEEE80211_PARAM_WAPI:
1585 A_PRINTF("WAPI Policy: %d\n", value);
1586 ar->arDot11AuthMode = OPEN_AUTH;
1587 ar->arAuthMode = NONE_AUTH;
1589 ar->arPairwiseCrypto = WAPI_CRYPT;
1590 ar->arGroupCrypto = WAPI_CRYPT;
1592 ar->arPairwiseCrypto = NONE_CRYPT;
1593 ar->arGroupCrypto = NONE_CRYPT;
1602 ar6000_ioctl_setparam(AR_SOFTC_T *ar, int param, int value)
1604 bool profChanged = false;
1607 if(ar->arNextMode == AP_NETWORK) {
1608 ar->ap_profile_flag = 1; /* There is a change in profile */
1610 case IEEE80211_PARAM_WPA:
1611 case IEEE80211_PARAM_AUTHMODE:
1612 case IEEE80211_PARAM_UCASTCIPHER:
1613 case IEEE80211_PARAM_PRIVACY:
1614 case IEEE80211_PARAM_WAPI:
1615 ret = ar6000_ioctl_ap_setparam(ar, param, value);
1621 case IEEE80211_PARAM_WPA:
1624 ar->arAuthMode = WPA_AUTH;
1628 ar->arAuthMode = WPA2_AUTH;
1632 ar->arAuthMode = NONE_AUTH;
1637 case IEEE80211_PARAM_AUTHMODE:
1639 case IEEE80211_AUTH_WPA_PSK:
1640 if (WPA_AUTH == ar->arAuthMode) {
1641 ar->arAuthMode = WPA_PSK_AUTH;
1643 } else if (WPA2_AUTH == ar->arAuthMode) {
1644 ar->arAuthMode = WPA2_PSK_AUTH;
1647 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Error - Setting PSK "\
1648 "mode when WPA param was set to %d\n",
1653 case IEEE80211_AUTH_WPA_CCKM:
1654 if (WPA2_AUTH == ar->arAuthMode) {
1655 ar->arAuthMode = WPA2_AUTH_CCKM;
1657 ar->arAuthMode = WPA_AUTH_CCKM;
1664 case IEEE80211_PARAM_UCASTCIPHER:
1666 case IEEE80211_CIPHER_AES_CCM:
1667 ar->arPairwiseCrypto = AES_CRYPT;
1670 case IEEE80211_CIPHER_TKIP:
1671 ar->arPairwiseCrypto = TKIP_CRYPT;
1674 case IEEE80211_CIPHER_WEP:
1675 ar->arPairwiseCrypto = WEP_CRYPT;
1678 case IEEE80211_CIPHER_NONE:
1679 ar->arPairwiseCrypto = NONE_CRYPT;
1684 case IEEE80211_PARAM_UCASTKEYLEN:
1685 if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(value)) {
1688 ar->arPairwiseCryptoLen = value;
1691 case IEEE80211_PARAM_MCASTCIPHER:
1693 case IEEE80211_CIPHER_AES_CCM:
1694 ar->arGroupCrypto = AES_CRYPT;
1697 case IEEE80211_CIPHER_TKIP:
1698 ar->arGroupCrypto = TKIP_CRYPT;
1701 case IEEE80211_CIPHER_WEP:
1702 ar->arGroupCrypto = WEP_CRYPT;
1705 case IEEE80211_CIPHER_NONE:
1706 ar->arGroupCrypto = NONE_CRYPT;
1711 case IEEE80211_PARAM_MCASTKEYLEN:
1712 if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(value)) {
1715 ar->arGroupCryptoLen = value;
1718 case IEEE80211_PARAM_COUNTERMEASURES:
1719 if (ar->arWmiReady == false) {
1722 wmi_set_tkip_countermeasures_cmd(ar->arWmi, value);
1727 if ((ar->arNextMode != AP_NETWORK) && (profChanged == true)) {
1729 * profile has changed. Erase ssid to signal change
1731 A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
1738 ar6000_ioctl_setkey(AR_SOFTC_T *ar, struct ieee80211req_key *ik)
1742 CRYPTO_TYPE keyType = NONE_CRYPT;
1745 ar->user_saved_keys.keyOk = false;
1747 if ( (0 == memcmp(ik->ik_macaddr, null_mac, IEEE80211_ADDR_LEN)) ||
1748 (0 == memcmp(ik->ik_macaddr, bcast_mac, IEEE80211_ADDR_LEN)) ) {
1749 keyUsage = GROUP_USAGE;
1750 if(ar->arNextMode == AP_NETWORK) {
1751 A_MEMCPY(&ar->ap_mode_bkey, ik,
1752 sizeof(struct ieee80211req_key));
1754 if(ar->arPairwiseCrypto == WAPI_CRYPT) {
1755 return ap_set_wapi_key(ar, ik);
1760 A_MEMCPY(&ar->user_saved_keys.bcast_ik, ik,
1761 sizeof(struct ieee80211req_key));
1764 keyUsage = PAIRWISE_USAGE;
1766 A_MEMCPY(&ar->user_saved_keys.ucast_ik, ik,
1767 sizeof(struct ieee80211req_key));
1770 if(ar->arNextMode == AP_NETWORK) {
1771 if(ar->arPairwiseCrypto == WAPI_CRYPT) {
1772 return ap_set_wapi_key(ar, ik);
1778 switch (ik->ik_type) {
1779 case IEEE80211_CIPHER_WEP:
1780 keyType = WEP_CRYPT;
1782 case IEEE80211_CIPHER_TKIP:
1783 keyType = TKIP_CRYPT;
1785 case IEEE80211_CIPHER_AES_CCM:
1786 keyType = AES_CRYPT;
1792 ar->user_saved_keys.keyType = keyType;
1794 if (IEEE80211_CIPHER_CCKM_KRK != ik->ik_type) {
1795 if (NONE_CRYPT == keyType) {
1799 if ((WEP_CRYPT == keyType)&&(!ar->arConnected)) {
1800 int index = ik->ik_keyix;
1802 if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(ik->ik_keylen)) {
1806 A_MEMZERO(ar->arWepKeyList[index].arKey,
1807 sizeof(ar->arWepKeyList[index].arKey));
1808 A_MEMCPY(ar->arWepKeyList[index].arKey, ik->ik_keydata, ik->ik_keylen);
1809 ar->arWepKeyList[index].arKeyLen = ik->ik_keylen;
1811 if(ik->ik_flags & IEEE80211_KEY_DEFAULT){
1812 ar->arDefTxKeyIndex = index;
1818 if (((WPA_PSK_AUTH == ar->arAuthMode) || (WPA2_PSK_AUTH == ar->arAuthMode)) &&
1819 (GROUP_USAGE & keyUsage))
1821 A_UNTIMEOUT(&ar->disconnect_timer);
1824 status = wmi_addKey_cmd(ar->arWmi, ik->ik_keyix, keyType, keyUsage,
1825 ik->ik_keylen, (u8 *)&ik->ik_keyrsc,
1826 ik->ik_keydata, KEY_OP_INIT_VAL, ik->ik_macaddr,
1829 if (status != A_OK) {
1833 status = wmi_add_krk_cmd(ar->arWmi, ik->ik_keydata);
1837 ar->user_saved_keys.keyOk = true;
1843 int ar6000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1845 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
1846 HIF_DEVICE *hifDevice = ar->arHifDevice;
1848 unsigned int address = 0;
1849 unsigned int length = 0;
1850 unsigned char *buffer;
1852 A_UINT32 connectCtrlFlags;
1855 WMI_SET_AKMP_PARAMS_CMD akmpParams;
1856 WMI_SET_PMKID_LIST_CMD pmkidInfo;
1858 WMI_SET_HT_CAP_CMD htCap;
1859 WMI_SET_HT_OP_CMD htOp;
1862 * ioctl operations may have to wait for the Target, so we cannot hold rtnl.
1863 * Prevent the device from disappearing under us and release the lock during
1864 * the ioctl operation.
1869 if (cmd == AR6000_IOCTL_EXTENDED) {
1871 * This allows for many more wireless ioctls than would otherwise
1872 * be available. Applications embed the actual ioctl command in
1873 * the first word of the parameter block, and use the command
1874 * AR6000_IOCTL_EXTENDED_CMD on the ioctl call.
1876 if (get_user(cmd, (int *)rq->ifr_data)) {
1880 userdata = (char *)(((unsigned int *)rq->ifr_data)+1);
1881 if(is_xioctl_allowed(ar->arNextMode, cmd) != A_OK) {
1882 A_PRINTF("xioctl: cmd=%d not allowed in this mode\n",cmd);
1887 int ret = is_iwioctl_allowed(ar->arNextMode, cmd);
1888 if(ret == A_ENOTSUP) {
1889 A_PRINTF("iwioctl: cmd=0x%x not allowed in this mode\n", cmd);
1892 } else if (ret == A_ERROR) {
1893 /* It is not our ioctl (out of range ioctl) */
1897 userdata = (char *)rq->ifr_data;
1900 if ((ar->arWlanState == WLAN_DISABLED) &&
1901 ((cmd != AR6000_XIOCTRL_WMI_SET_WLAN_STATE) &&
1902 (cmd != AR6000_XIOCTL_GET_WLAN_SLEEP_STATE) &&
1903 (cmd != AR6000_XIOCTL_DIAG_READ) &&
1904 (cmd != AR6000_XIOCTL_DIAG_WRITE) &&
1905 (cmd != AR6000_XIOCTL_SET_BT_HW_POWER_STATE) &&
1906 (cmd != AR6000_XIOCTL_GET_BT_HW_POWER_STATE) &&
1907 (cmd != AR6000_XIOCTL_ADD_AP_INTERFACE) &&
1908 (cmd != AR6000_XIOCTL_REMOVE_AP_INTERFACE) &&
1909 (cmd != AR6000_IOCTL_WMI_GETREV)))
1918 case IEEE80211_IOCTL_SETPARAM:
1921 int *ptr = (int *)rq->ifr_ifru.ifru_newname;
1922 if (ar->arWmiReady == false) {
1927 ret = ar6000_ioctl_setparam(ar,param,value);
1931 case IEEE80211_IOCTL_SETKEY:
1933 struct ieee80211req_key keydata;
1934 if (ar->arWmiReady == false) {
1936 } else if (copy_from_user(&keydata, userdata,
1937 sizeof(struct ieee80211req_key))) {
1940 ar6000_ioctl_setkey(ar, &keydata);
1944 case IEEE80211_IOCTL_DELKEY:
1945 case IEEE80211_IOCTL_SETOPTIE:
1950 case IEEE80211_IOCTL_SETMLME:
1952 struct ieee80211req_mlme mlme;
1953 if (ar->arWmiReady == false) {
1955 } else if (copy_from_user(&mlme, userdata,
1956 sizeof(struct ieee80211req_mlme))) {
1959 switch (mlme.im_op) {
1960 case IEEE80211_MLME_AUTHORIZE:
1961 A_PRINTF("setmlme AUTHORIZE %02X:%02X\n",
1962 mlme.im_macaddr[4], mlme.im_macaddr[5]);
1964 case IEEE80211_MLME_UNAUTHORIZE:
1965 A_PRINTF("setmlme UNAUTHORIZE %02X:%02X\n",
1966 mlme.im_macaddr[4], mlme.im_macaddr[5]);
1968 case IEEE80211_MLME_DEAUTH:
1969 A_PRINTF("setmlme DEAUTH %02X:%02X\n",
1970 mlme.im_macaddr[4], mlme.im_macaddr[5]);
1971 //remove_sta(ar, mlme.im_macaddr);
1973 case IEEE80211_MLME_DISASSOC:
1974 A_PRINTF("setmlme DISASSOC %02X:%02X\n",
1975 mlme.im_macaddr[4], mlme.im_macaddr[5]);
1976 //remove_sta(ar, mlme.im_macaddr);
1983 wmi_ap_set_mlme(ar->arWmi, mlme.im_op, mlme.im_macaddr,
1988 case IEEE80211_IOCTL_ADDPMKID:
1990 struct ieee80211req_addpmkid req;
1991 if (ar->arWmiReady == false) {
1993 } else if (copy_from_user(&req, userdata, sizeof(struct ieee80211req_addpmkid))) {
1998 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",
1999 req.pi_bssid[0], req.pi_bssid[1], req.pi_bssid[2],
2000 req.pi_bssid[3], req.pi_bssid[4], req.pi_bssid[5],
2003 status = wmi_setPmkid_cmd(ar->arWmi, req.pi_bssid, req.pi_pmkid,
2006 if (status != A_OK) {
2013 #ifdef CONFIG_HOST_TCMD_SUPPORT
2014 case AR6000_XIOCTL_TCMD_CONT_TX:
2018 if ((ar->tcmdPm == TCMD_PM_SLEEP) ||
2019 (ar->tcmdPm == TCMD_PM_DEEPSLEEP))
2021 A_PRINTF("Can NOT send tx tcmd when target is asleep! \n");
2026 if(copy_from_user(&txCmd, userdata, sizeof(TCMD_CONT_TX))) {
2030 wmi_test_cmd(ar->arWmi,(u8 *)&txCmd, sizeof(TCMD_CONT_TX));
2034 case AR6000_XIOCTL_TCMD_CONT_RX:
2038 if ((ar->tcmdPm == TCMD_PM_SLEEP) ||
2039 (ar->tcmdPm == TCMD_PM_DEEPSLEEP))
2041 A_PRINTF("Can NOT send rx tcmd when target is asleep! \n");
2045 if(copy_from_user(&rxCmd, userdata, sizeof(TCMD_CONT_RX))) {
2052 case TCMD_CONT_RX_PROMIS:
2053 case TCMD_CONT_RX_FILTER:
2054 case TCMD_CONT_RX_SETMAC:
2055 case TCMD_CONT_RX_SET_ANT_SWITCH_TABLE:
2056 wmi_test_cmd(ar->arWmi,(u8 *)&rxCmd,
2057 sizeof(TCMD_CONT_RX));
2058 tcmdRxFreq = rxCmd.u.para.freq;
2060 case TCMD_CONT_RX_REPORT:
2061 ar6000_ioctl_tcmd_get_rx_report(dev, rq,
2062 (u8 *)&rxCmd, sizeof(TCMD_CONT_RX));
2065 A_PRINTF("Unknown Cont Rx mode: %d\n",rxCmd.act);
2071 case AR6000_XIOCTL_TCMD_PM:
2075 if(copy_from_user(&pmCmd, userdata, sizeof(TCMD_PM))) {
2079 ar->tcmdPm = pmCmd.mode;
2080 wmi_test_cmd(ar->arWmi, (u8 *)&pmCmd, sizeof(TCMD_PM));
2083 #endif /* CONFIG_HOST_TCMD_SUPPORT */
2085 case AR6000_XIOCTL_BMI_DONE:
2088 rtnl_lock(); /* ar6000_init expects to be called holding rtnl lock */
2089 ret = ar6000_init(dev);
2094 ret = BMIDone(hifDevice);
2098 case AR6000_XIOCTL_BMI_READ_MEMORY:
2099 if (get_user(address, (unsigned int *)userdata) ||
2100 get_user(length, (unsigned int *)userdata + 1)) {
2105 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Read Memory (address: 0x%x, length: %d)\n",
2107 if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
2108 A_MEMZERO(buffer, length);
2109 ret = BMIReadMemory(hifDevice, address, buffer, length);
2110 if (copy_to_user(rq->ifr_data, buffer, length)) {
2119 case AR6000_XIOCTL_BMI_WRITE_MEMORY:
2120 if (get_user(address, (unsigned int *)userdata) ||
2121 get_user(length, (unsigned int *)userdata + 1)) {
2125 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Write Memory (address: 0x%x, length: %d)\n",
2127 if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
2128 A_MEMZERO(buffer, length);
2129 if (copy_from_user(buffer, &userdata[sizeof(address) +
2130 sizeof(length)], length))
2134 ret = BMIWriteMemory(hifDevice, address, buffer, length);
2142 case AR6000_XIOCTL_BMI_TEST:
2143 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("No longer supported\n"));
2147 case AR6000_XIOCTL_BMI_EXECUTE:
2148 if (get_user(address, (unsigned int *)userdata) ||
2149 get_user(param, (unsigned int *)userdata + 1)) {
2153 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Execute (address: 0x%x, param: %d)\n",
2155 ret = BMIExecute(hifDevice, address, (A_UINT32*)¶m);
2157 if (put_user(param, (unsigned int *)rq->ifr_data)) {
2163 case AR6000_XIOCTL_BMI_SET_APP_START:
2164 if (get_user(address, (unsigned int *)userdata)) {
2168 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Set App Start (address: 0x%x)\n", address));
2169 ret = BMISetAppStart(hifDevice, address);
2172 case AR6000_XIOCTL_BMI_READ_SOC_REGISTER:
2173 if (get_user(address, (unsigned int *)userdata)) {
2177 ret = BMIReadSOCRegister(hifDevice, address, (A_UINT32*)¶m);
2179 if (put_user(param, (unsigned int *)rq->ifr_data)) {
2185 case AR6000_XIOCTL_BMI_WRITE_SOC_REGISTER:
2186 if (get_user(address, (unsigned int *)userdata) ||
2187 get_user(param, (unsigned int *)userdata + 1)) {
2191 ret = BMIWriteSOCRegister(hifDevice, address, param);
2194 #ifdef HTC_RAW_INTERFACE
2195 case AR6000_XIOCTL_HTC_RAW_OPEN:
2197 if (!arRawIfEnabled(ar)) {
2198 /* make sure block size is set in case the target was reset since last
2199 * BMI phase (i.e. flashup downloads) */
2200 ret = ar6000_set_htc_params(ar->arHifDevice,
2202 0, /* use default yield */
2203 0 /* use default number of HTC ctrl buffers */
2208 /* Terminate the BMI phase */
2209 ret = BMIDone(hifDevice);
2211 ret = ar6000_htc_raw_open(ar);
2216 case AR6000_XIOCTL_HTC_RAW_CLOSE:
2217 if (arRawIfEnabled(ar)) {
2218 ret = ar6000_htc_raw_close(ar);
2219 arRawIfEnabled(ar) = false;
2225 case AR6000_XIOCTL_HTC_RAW_READ:
2226 if (arRawIfEnabled(ar)) {
2227 unsigned int streamID;
2228 if (get_user(streamID, (unsigned int *)userdata) ||
2229 get_user(length, (unsigned int *)userdata + 1)) {
2233 buffer = (unsigned char*)rq->ifr_data + sizeof(length);
2234 ret = ar6000_htc_raw_read(ar, (HTC_RAW_STREAM_ID)streamID,
2235 (char*)buffer, length);
2236 if (put_user(ret, (unsigned int *)rq->ifr_data)) {
2245 case AR6000_XIOCTL_HTC_RAW_WRITE:
2246 if (arRawIfEnabled(ar)) {
2247 unsigned int streamID;
2248 if (get_user(streamID, (unsigned int *)userdata) ||
2249 get_user(length, (unsigned int *)userdata + 1)) {
2253 buffer = (unsigned char*)userdata + sizeof(streamID) + sizeof(length);
2254 ret = ar6000_htc_raw_write(ar, (HTC_RAW_STREAM_ID)streamID,
2255 (char*)buffer, length);
2256 if (put_user(ret, (unsigned int *)rq->ifr_data)) {
2264 #endif /* HTC_RAW_INTERFACE */
2266 case AR6000_XIOCTL_BMI_LZ_STREAM_START:
2267 if (get_user(address, (unsigned int *)userdata)) {
2271 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Start Compressed Stream (address: 0x%x)\n", address));
2272 ret = BMILZStreamStart(hifDevice, address);
2275 case AR6000_XIOCTL_BMI_LZ_DATA:
2276 if (get_user(length, (unsigned int *)userdata)) {
2280 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Send Compressed Data (length: %d)\n", length));
2281 if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
2282 A_MEMZERO(buffer, length);
2283 if (copy_from_user(buffer, &userdata[sizeof(length)], length))
2287 ret = BMILZData(hifDevice, buffer, length);
2295 #if defined(CONFIG_TARGET_PROFILE_SUPPORT)
2297 * Optional support for Target-side profiling.
2298 * Not needed in production.
2301 /* Configure Target-side profiling */
2302 case AR6000_XIOCTL_PROF_CFG:
2306 if (get_user(period, (unsigned int *)userdata) ||
2307 get_user(nbins, (unsigned int *)userdata + 1)) {
2312 if (wmi_prof_cfg_cmd(ar->arWmi, period, nbins) != A_OK) {
2319 /* Start a profiling bucket/bin at the specified address */
2320 case AR6000_XIOCTL_PROF_ADDR_SET:
2323 if (get_user(addr, (unsigned int *)userdata)) {
2328 if (wmi_prof_addr_set_cmd(ar->arWmi, addr) != A_OK) {
2335 /* START Target-side profiling */
2336 case AR6000_XIOCTL_PROF_START:
2337 wmi_prof_start_cmd(ar->arWmi);
2340 /* STOP Target-side profiling */
2341 case AR6000_XIOCTL_PROF_STOP:
2342 wmi_prof_stop_cmd(ar->arWmi);
2344 case AR6000_XIOCTL_PROF_COUNT_GET:
2346 if (ar->bIsDestroyProgress) {
2350 if (ar->arWmiReady == false) {
2354 if (down_interruptible(&ar->arSem)) {
2358 if (ar->bIsDestroyProgress) {
2364 prof_count_available = false;
2365 ret = prof_count_get(dev);
2372 /* Wait for Target to respond. */
2373 wait_event_interruptible(arEvent, prof_count_available);
2374 if (signal_pending(current)) {
2377 if (copy_to_user(userdata, &prof_count_results,
2378 sizeof(prof_count_results)))
2386 #endif /* CONFIG_TARGET_PROFILE_SUPPORT */
2388 case AR6000_IOCTL_WMI_GETREV:
2390 if (copy_to_user(rq->ifr_data, &ar->arVersion,
2391 sizeof(ar->arVersion)))
2397 case AR6000_IOCTL_WMI_SETPWR:
2399 WMI_POWER_MODE_CMD pwrModeCmd;
2401 if (ar->arWmiReady == false) {
2403 } else if (copy_from_user(&pwrModeCmd, userdata,
2404 sizeof(pwrModeCmd)))
2408 if (wmi_powermode_cmd(ar->arWmi, pwrModeCmd.powerMode)
2416 case AR6000_IOCTL_WMI_SET_IBSS_PM_CAPS:
2418 WMI_IBSS_PM_CAPS_CMD ibssPmCaps;
2420 if (ar->arWmiReady == false) {
2422 } else if (copy_from_user(&ibssPmCaps, userdata,
2423 sizeof(ibssPmCaps)))
2427 if (wmi_ibsspmcaps_cmd(ar->arWmi, ibssPmCaps.power_saving, ibssPmCaps.ttl,
2428 ibssPmCaps.atim_windows, ibssPmCaps.timeout_value) != A_OK)
2432 AR6000_SPIN_LOCK(&ar->arLock, 0);
2433 ar->arIbssPsEnable = ibssPmCaps.power_saving;
2434 AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2438 case AR6000_XIOCTL_WMI_SET_AP_PS:
2440 WMI_AP_PS_CMD apPsCmd;
2442 if (ar->arWmiReady == false) {
2444 } else if (copy_from_user(&apPsCmd, userdata,
2449 if (wmi_apps_cmd(ar->arWmi, apPsCmd.psType, apPsCmd.idle_time,
2450 apPsCmd.ps_period, apPsCmd.sleep_period) != A_OK)
2457 case AR6000_IOCTL_WMI_SET_PMPARAMS:
2459 WMI_POWER_PARAMS_CMD pmParams;
2461 if (ar->arWmiReady == false) {
2463 } else if (copy_from_user(&pmParams, userdata,
2468 if (wmi_pmparams_cmd(ar->arWmi, pmParams.idle_period,
2469 pmParams.pspoll_number,
2470 pmParams.dtim_policy,
2471 pmParams.tx_wakeup_policy,
2472 pmParams.num_tx_to_wakeup,
2473 #if WLAN_CONFIG_IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
2474 IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
2476 SEND_POWER_SAVE_FAIL_EVENT_ALWAYS
2485 case AR6000_IOCTL_WMI_SETSCAN:
2487 if (ar->arWmiReady == false) {
2489 } else if (copy_from_user(&ar->scParams, userdata,
2490 sizeof(ar->scParams)))
2494 if (CAN_SCAN_IN_CONNECT(ar->scParams.scanCtrlFlags)) {
2495 ar->arSkipScan = false;
2497 ar->arSkipScan = true;
2500 if (wmi_scanparams_cmd(ar->arWmi, ar->scParams.fg_start_period,
2501 ar->scParams.fg_end_period,
2502 ar->scParams.bg_period,
2503 ar->scParams.minact_chdwell_time,
2504 ar->scParams.maxact_chdwell_time,
2505 ar->scParams.pas_chdwell_time,
2506 ar->scParams.shortScanRatio,
2507 ar->scParams.scanCtrlFlags,
2508 ar->scParams.max_dfsch_act_time,
2509 ar->scParams.maxact_scan_per_ssid) != A_OK)
2516 case AR6000_IOCTL_WMI_SETLISTENINT:
2518 WMI_LISTEN_INT_CMD listenCmd;
2520 if (ar->arWmiReady == false) {
2522 } else if (copy_from_user(&listenCmd, userdata,
2527 if (wmi_listeninterval_cmd(ar->arWmi, listenCmd.listenInterval, listenCmd.numBeacons) != A_OK) {
2530 AR6000_SPIN_LOCK(&ar->arLock, 0);
2531 ar->arListenIntervalT = listenCmd.listenInterval;
2532 ar->arListenIntervalB = listenCmd.numBeacons;
2533 AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2539 case AR6000_IOCTL_WMI_SET_BMISS_TIME:
2541 WMI_BMISS_TIME_CMD bmissCmd;
2543 if (ar->arWmiReady == false) {
2545 } else if (copy_from_user(&bmissCmd, userdata,
2550 if (wmi_bmisstime_cmd(ar->arWmi, bmissCmd.bmissTime, bmissCmd.numBeacons) != A_OK) {
2556 case AR6000_IOCTL_WMI_SETBSSFILTER:
2558 WMI_BSS_FILTER_CMD filt;
2560 if (ar->arWmiReady == false) {
2562 } else if (copy_from_user(&filt, userdata,
2567 if (wmi_bssfilter_cmd(ar->arWmi, filt.bssFilter, filt.ieMask)
2571 ar->arUserBssFilter = param;
2577 case AR6000_IOCTL_WMI_SET_SNRTHRESHOLD:
2579 ret = ar6000_ioctl_set_snr_threshold(dev, rq);
2582 case AR6000_XIOCTL_WMI_SET_RSSITHRESHOLD:
2584 ret = ar6000_ioctl_set_rssi_threshold(dev, rq);
2587 case AR6000_XIOCTL_WMI_CLR_RSSISNR:
2589 if (ar->arWmiReady == false) {
2592 ret = wmi_clr_rssi_snr(ar->arWmi);
2595 case AR6000_XIOCTL_WMI_SET_LQTHRESHOLD:
2597 ret = ar6000_ioctl_set_lq_threshold(dev, rq);
2600 case AR6000_XIOCTL_WMI_SET_LPREAMBLE:
2602 WMI_SET_LPREAMBLE_CMD setLpreambleCmd;
2604 if (ar->arWmiReady == false) {
2606 } else if (copy_from_user(&setLpreambleCmd, userdata,
2607 sizeof(setLpreambleCmd)))
2611 if (wmi_set_lpreamble_cmd(ar->arWmi, setLpreambleCmd.status,
2612 #if WLAN_CONFIG_DONOT_IGNORE_BARKER_IN_ERP
2613 WMI_DONOT_IGNORE_BARKER_IN_ERP
2615 WMI_IGNORE_BARKER_IN_ERP
2625 case AR6000_XIOCTL_WMI_SET_RTS:
2627 WMI_SET_RTS_CMD rtsCmd;
2628 if (ar->arWmiReady == false) {
2630 } else if (copy_from_user(&rtsCmd, userdata,
2635 ar->arRTS = rtsCmd.threshold;
2636 if (wmi_set_rts_cmd(ar->arWmi, rtsCmd.threshold)
2645 case AR6000_XIOCTL_WMI_SET_WMM:
2647 ret = ar6000_ioctl_set_wmm(dev, rq);
2650 case AR6000_XIOCTL_WMI_SET_QOS_SUPP:
2652 ret = ar6000_ioctl_set_qos_supp(dev, rq);
2655 case AR6000_XIOCTL_WMI_SET_TXOP:
2657 ret = ar6000_ioctl_set_txop(dev, rq);
2660 case AR6000_XIOCTL_WMI_GET_RD:
2662 ret = ar6000_ioctl_get_rd(dev, rq);
2665 case AR6000_IOCTL_WMI_SET_CHANNELPARAMS:
2667 ret = ar6000_ioctl_set_channelParams(dev, rq);
2670 case AR6000_IOCTL_WMI_SET_PROBEDSSID:
2672 ret = ar6000_ioctl_set_probedSsid(dev, rq);
2675 case AR6000_IOCTL_WMI_SET_BADAP:
2677 ret = ar6000_ioctl_set_badAp(dev, rq);
2680 case AR6000_IOCTL_WMI_CREATE_QOS:
2682 ret = ar6000_ioctl_create_qos(dev, rq);
2685 case AR6000_IOCTL_WMI_DELETE_QOS:
2687 ret = ar6000_ioctl_delete_qos(dev, rq);
2690 case AR6000_IOCTL_WMI_GET_QOS_QUEUE:
2692 ret = ar6000_ioctl_get_qos_queue(dev, rq);
2695 case AR6000_IOCTL_WMI_GET_TARGET_STATS:
2697 ret = ar6000_ioctl_get_target_stats(dev, rq);
2700 case AR6000_IOCTL_WMI_SET_ERROR_REPORT_BITMASK:
2702 ret = ar6000_ioctl_set_error_report_bitmask(dev, rq);
2705 case AR6000_IOCTL_WMI_SET_ASSOC_INFO:
2707 WMI_SET_ASSOC_INFO_CMD cmd;
2708 u8 assocInfo[WMI_MAX_ASSOC_INFO_LEN];
2710 if (ar->arWmiReady == false) {
2715 if (get_user(cmd.ieType, userdata)) {
2719 if (cmd.ieType >= WMI_MAX_ASSOC_INFO_TYPE) {
2724 if (get_user(cmd.bufferSize, userdata + 1) ||
2725 (cmd.bufferSize > WMI_MAX_ASSOC_INFO_LEN) ||
2726 copy_from_user(assocInfo, userdata + 2, cmd.bufferSize)) {
2730 if (wmi_associnfo_cmd(ar->arWmi, cmd.ieType,
2731 cmd.bufferSize, assocInfo) != A_OK) {
2737 case AR6000_IOCTL_WMI_SET_ACCESS_PARAMS:
2739 ret = ar6000_ioctl_set_access_params(dev, rq);
2742 case AR6000_IOCTL_WMI_SET_DISC_TIMEOUT:
2744 ret = ar6000_ioctl_set_disconnect_timeout(dev, rq);
2747 case AR6000_XIOCTL_FORCE_TARGET_RESET:
2749 if (ar->arHtcTarget)
2751 // HTCForceReset(htcTarget);
2755 AR_DEBUG_PRINTF(ATH_DEBUG_WARN,("ar6000_ioctl cannot attempt reset.\n"));
2759 case AR6000_XIOCTL_TARGET_INFO:
2760 case AR6000_XIOCTL_CHECK_TARGET_READY: /* backwards compatibility */
2762 /* If we made it to here, then the Target exists and is ready. */
2764 if (cmd == AR6000_XIOCTL_TARGET_INFO) {
2765 if (copy_to_user((A_UINT32 *)rq->ifr_data, &ar->arVersion.target_ver,
2766 sizeof(ar->arVersion.target_ver)))
2770 if (copy_to_user(((A_UINT32 *)rq->ifr_data)+1, &ar->arTargetType,
2771 sizeof(ar->arTargetType)))
2778 case AR6000_XIOCTL_WMI_SET_HB_CHALLENGE_RESP_PARAMS:
2780 WMI_SET_HB_CHALLENGE_RESP_PARAMS_CMD hbparam;
2782 if (copy_from_user(&hbparam, userdata, sizeof(hbparam)))
2786 AR6000_SPIN_LOCK(&ar->arLock, 0);
2787 /* Start a cyclic timer with the parameters provided. */
2788 if (hbparam.frequency) {
2789 ar->arHBChallengeResp.frequency = hbparam.frequency;
2791 if (hbparam.threshold) {
2792 ar->arHBChallengeResp.missThres = hbparam.threshold;
2795 /* Delete the pending timer and start a new one */
2796 if (timer_pending(&ar->arHBChallengeResp.timer)) {
2797 A_UNTIMEOUT(&ar->arHBChallengeResp.timer);
2799 A_TIMEOUT_MS(&ar->arHBChallengeResp.timer, ar->arHBChallengeResp.frequency * 1000, 0);
2800 AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2804 case AR6000_XIOCTL_WMI_GET_HB_CHALLENGE_RESP:
2808 if (copy_from_user(&cookie, userdata, sizeof(cookie))) {
2813 /* Send the challenge on the control channel */
2814 if (wmi_get_challenge_resp_cmd(ar->arWmi, cookie, APP_HB_CHALLENGE) != A_OK) {
2821 case AR6000_XIOCTL_USER_SETKEYS:
2824 ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_RUN;
2826 if (copy_from_user(&ar->user_key_ctrl, userdata,
2827 sizeof(ar->user_key_ctrl)))
2833 A_PRINTF("ar6000 USER set key %x\n", ar->user_key_ctrl);
2836 #endif /* USER_KEYS */
2838 #ifdef CONFIG_HOST_GPIO_SUPPORT
2839 case AR6000_XIOCTL_GPIO_OUTPUT_SET:
2841 struct ar6000_gpio_output_set_cmd_s gpio_output_set_cmd;
2843 if (ar->bIsDestroyProgress) {
2847 if (ar->arWmiReady == false) {
2851 if (down_interruptible(&ar->arSem)) {
2855 if (ar->bIsDestroyProgress) {
2861 if (copy_from_user(&gpio_output_set_cmd, userdata,
2862 sizeof(gpio_output_set_cmd)))
2866 ret = ar6000_gpio_output_set(dev,
2867 gpio_output_set_cmd.set_mask,
2868 gpio_output_set_cmd.clear_mask,
2869 gpio_output_set_cmd.enable_mask,
2870 gpio_output_set_cmd.disable_mask);
2878 case AR6000_XIOCTL_GPIO_INPUT_GET:
2880 if (ar->bIsDestroyProgress) {
2884 if (ar->arWmiReady == false) {
2888 if (down_interruptible(&ar->arSem)) {
2892 if (ar->bIsDestroyProgress) {
2898 ret = ar6000_gpio_input_get(dev);
2905 /* Wait for Target to respond. */
2906 wait_event_interruptible(arEvent, gpio_data_available);
2907 if (signal_pending(current)) {
2910 A_ASSERT(gpio_reg_results.gpioreg_id == GPIO_ID_NONE);
2912 if (copy_to_user(userdata, &gpio_reg_results.value,
2913 sizeof(gpio_reg_results.value)))
2921 case AR6000_XIOCTL_GPIO_REGISTER_SET:
2923 struct ar6000_gpio_register_cmd_s gpio_register_cmd;
2925 if (ar->bIsDestroyProgress) {
2929 if (ar->arWmiReady == false) {
2933 if (down_interruptible(&ar->arSem)) {
2937 if (ar->bIsDestroyProgress) {
2943 if (copy_from_user(&gpio_register_cmd, userdata,
2944 sizeof(gpio_register_cmd)))
2948 ret = ar6000_gpio_register_set(dev,
2949 gpio_register_cmd.gpioreg_id,
2950 gpio_register_cmd.value);
2955 /* Wait for acknowledgement from Target */
2956 wait_event_interruptible(arEvent, gpio_ack_received);
2957 if (signal_pending(current)) {
2964 case AR6000_XIOCTL_GPIO_REGISTER_GET:
2966 struct ar6000_gpio_register_cmd_s gpio_register_cmd;
2968 if (ar->bIsDestroyProgress) {
2972 if (ar->arWmiReady == false) {
2976 if (down_interruptible(&ar->arSem)) {
2980 if (ar->bIsDestroyProgress) {
2986 if (copy_from_user(&gpio_register_cmd, userdata,
2987 sizeof(gpio_register_cmd)))
2991 ret = ar6000_gpio_register_get(dev, gpio_register_cmd.gpioreg_id);
2998 /* Wait for Target to respond. */
2999 wait_event_interruptible(arEvent, gpio_data_available);
3000 if (signal_pending(current)) {
3003 A_ASSERT(gpio_register_cmd.gpioreg_id == gpio_reg_results.gpioreg_id);
3004 if (copy_to_user(userdata, &gpio_reg_results,
3005 sizeof(gpio_reg_results)))
3014 case AR6000_XIOCTL_GPIO_INTR_ACK:
3016 struct ar6000_gpio_intr_ack_cmd_s gpio_intr_ack_cmd;
3018 if (ar->bIsDestroyProgress) {
3022 if (ar->arWmiReady == false) {
3026 if (down_interruptible(&ar->arSem)) {
3030 if (ar->bIsDestroyProgress) {
3036 if (copy_from_user(&gpio_intr_ack_cmd, userdata,
3037 sizeof(gpio_intr_ack_cmd)))
3041 ret = ar6000_gpio_intr_ack(dev, gpio_intr_ack_cmd.ack_mask);
3049 case AR6000_XIOCTL_GPIO_INTR_WAIT:
3051 /* Wait for Target to report an interrupt. */
3052 wait_event_interruptible(arEvent, gpio_intr_available);
3054 if (signal_pending(current)) {
3057 if (copy_to_user(userdata, &gpio_intr_results,
3058 sizeof(gpio_intr_results)))
3065 #endif /* CONFIG_HOST_GPIO_SUPPORT */
3067 case AR6000_XIOCTL_DBGLOG_CFG_MODULE:
3069 struct ar6000_dbglog_module_config_s config;
3071 if (copy_from_user(&config, userdata, sizeof(config))) {
3076 /* Send the challenge on the control channel */
3077 if (wmi_config_debug_module_cmd(ar->arWmi, config.mmask,
3078 config.tsr, config.rep,
3079 config.size, config.valid) != A_OK)
3087 case AR6000_XIOCTL_DBGLOG_GET_DEBUG_LOGS:
3089 /* Send the challenge on the control channel */
3090 if (ar6000_dbglog_get_debug_logs(ar) != A_OK)
3098 case AR6000_XIOCTL_SET_ADHOC_BSSID:
3100 WMI_SET_ADHOC_BSSID_CMD adhocBssid;
3102 if (ar->arWmiReady == false) {
3104 } else if (copy_from_user(&adhocBssid, userdata,
3105 sizeof(adhocBssid)))
3108 } else if (A_MEMCMP(adhocBssid.bssid, bcast_mac,
3109 AR6000_ETH_ADDR_LEN) == 0)
3114 A_MEMCPY(ar->arReqBssid, adhocBssid.bssid, sizeof(ar->arReqBssid));
3119 case AR6000_XIOCTL_SET_OPT_MODE:
3121 WMI_SET_OPT_MODE_CMD optModeCmd;
3122 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
3124 if (ar->arWmiReady == false) {
3126 } else if (copy_from_user(&optModeCmd, userdata,
3127 sizeof(optModeCmd)))
3130 } else if (ar->arConnected && optModeCmd.optMode == SPECIAL_ON) {
3133 } else if (wmi_set_opt_mode_cmd(ar->arWmi, optModeCmd.optMode)
3141 case AR6000_XIOCTL_OPT_SEND_FRAME:
3143 WMI_OPT_TX_FRAME_CMD optTxFrmCmd;
3144 u8 data[MAX_OPT_DATA_LEN];
3146 if (ar->arWmiReady == false) {
3148 } else if (copy_from_user(&optTxFrmCmd, userdata,
3149 sizeof(optTxFrmCmd)))
3152 } else if (copy_from_user(data,
3153 userdata+sizeof(WMI_OPT_TX_FRAME_CMD)-1,
3154 optTxFrmCmd.optIEDataLen))
3158 ret = wmi_opt_tx_frame_cmd(ar->arWmi,
3159 optTxFrmCmd.frmType,
3160 optTxFrmCmd.dstAddr,
3162 optTxFrmCmd.optIEDataLen,
3168 case AR6000_XIOCTL_WMI_SETRETRYLIMITS:
3170 WMI_SET_RETRY_LIMITS_CMD setRetryParams;
3172 if (ar->arWmiReady == false) {
3174 } else if (copy_from_user(&setRetryParams, userdata,
3175 sizeof(setRetryParams)))
3179 if (wmi_set_retry_limits_cmd(ar->arWmi, setRetryParams.frameType,
3180 setRetryParams.trafficClass,
3181 setRetryParams.maxRetries,
3182 setRetryParams.enableNotify) != A_OK)
3186 AR6000_SPIN_LOCK(&ar->arLock, 0);
3187 ar->arMaxRetries = setRetryParams.maxRetries;
3188 AR6000_SPIN_UNLOCK(&ar->arLock, 0);
3193 case AR6000_XIOCTL_SET_BEACON_INTVAL:
3195 WMI_BEACON_INT_CMD bIntvlCmd;
3197 if (ar->arWmiReady == false) {
3199 } else if (copy_from_user(&bIntvlCmd, userdata,
3203 } else if (wmi_set_adhoc_bconIntvl_cmd(ar->arWmi, bIntvlCmd.beaconInterval)
3209 ar->ap_beacon_interval = bIntvlCmd.beaconInterval;
3210 ar->ap_profile_flag = 1; /* There is a change in profile */
3214 case IEEE80211_IOCTL_SETAUTHALG:
3216 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
3217 struct ieee80211req_authalg req;
3219 if (ar->arWmiReady == false) {
3221 } else if (copy_from_user(&req, userdata,
3222 sizeof(struct ieee80211req_authalg)))
3226 if (req.auth_alg & AUTH_ALG_OPEN_SYSTEM) {
3227 ar->arDot11AuthMode |= OPEN_AUTH;
3228 ar->arPairwiseCrypto = NONE_CRYPT;
3229 ar->arGroupCrypto = NONE_CRYPT;
3231 if (req.auth_alg & AUTH_ALG_SHARED_KEY) {
3232 ar->arDot11AuthMode |= SHARED_AUTH;
3233 ar->arPairwiseCrypto = WEP_CRYPT;
3234 ar->arGroupCrypto = WEP_CRYPT;
3235 ar->arAuthMode = NONE_AUTH;
3237 if (req.auth_alg == AUTH_ALG_LEAP) {
3238 ar->arDot11AuthMode = LEAP_AUTH;
3244 case AR6000_XIOCTL_SET_VOICE_PKT_SIZE:
3245 ret = ar6000_xioctl_set_voice_pkt_size(dev, userdata);
3248 case AR6000_XIOCTL_SET_MAX_SP:
3249 ret = ar6000_xioctl_set_max_sp_len(dev, userdata);
3252 case AR6000_XIOCTL_WMI_GET_ROAM_TBL:
3253 ret = ar6000_ioctl_get_roam_tbl(dev, rq);
3255 case AR6000_XIOCTL_WMI_SET_ROAM_CTRL:
3256 ret = ar6000_ioctl_set_roam_ctrl(dev, userdata);
3258 case AR6000_XIOCTRL_WMI_SET_POWERSAVE_TIMERS:
3259 ret = ar6000_ioctl_set_powersave_timers(dev, userdata);
3261 case AR6000_XIOCTRL_WMI_GET_POWER_MODE:
3262 ret = ar6000_ioctl_get_power_mode(dev, rq);
3264 case AR6000_XIOCTRL_WMI_SET_WLAN_STATE:
3266 AR6000_WLAN_STATE state;
3267 if (get_user(state, (unsigned int *)userdata))
3269 else if (ar6000_set_wlan_state(ar, state) != A_OK)
3273 case AR6000_XIOCTL_WMI_GET_ROAM_DATA:
3274 ret = ar6000_ioctl_get_roam_data(dev, rq);
3277 case AR6000_XIOCTL_WMI_SET_BT_STATUS:
3278 ret = ar6000_xioctl_set_bt_status_cmd(dev, userdata);
3281 case AR6000_XIOCTL_WMI_SET_BT_PARAMS:
3282 ret = ar6000_xioctl_set_bt_params_cmd(dev, userdata);
3285 case AR6000_XIOCTL_WMI_SET_BTCOEX_FE_ANT:
3286 ret = ar6000_xioctl_set_btcoex_fe_ant_cmd(dev, userdata);
3289 case AR6000_XIOCTL_WMI_SET_BTCOEX_COLOCATED_BT_DEV:
3290 ret = ar6000_xioctl_set_btcoex_colocated_bt_dev_cmd(dev, userdata);
3293 case AR6000_XIOCTL_WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG:
3294 ret = ar6000_xioctl_set_btcoex_btinquiry_page_config_cmd(dev, userdata);
3297 case AR6000_XIOCTL_WMI_SET_BTCOEX_SCO_CONFIG:
3298 ret = ar6000_xioctl_set_btcoex_sco_config_cmd( dev, userdata);
3301 case AR6000_XIOCTL_WMI_SET_BTCOEX_A2DP_CONFIG:
3302 ret = ar6000_xioctl_set_btcoex_a2dp_config_cmd(dev, userdata);
3305 case AR6000_XIOCTL_WMI_SET_BTCOEX_ACLCOEX_CONFIG:
3306 ret = ar6000_xioctl_set_btcoex_aclcoex_config_cmd(dev, userdata);
3309 case AR6000_XIOCTL_WMI_SET_BTCOEX_DEBUG:
3310 ret = ar60000_xioctl_set_btcoex_debug_cmd(dev, userdata);
3313 case AR6000_XIOCTL_WMI_SET_BT_OPERATING_STATUS:
3314 ret = ar6000_xioctl_set_btcoex_bt_operating_status_cmd(dev, userdata);
3317 case AR6000_XIOCTL_WMI_GET_BTCOEX_CONFIG:
3318 ret = ar6000_xioctl_get_btcoex_config_cmd(dev, userdata, rq);
3321 case AR6000_XIOCTL_WMI_GET_BTCOEX_STATS:
3322 ret = ar6000_xioctl_get_btcoex_stats_cmd(dev, userdata, rq);
3325 case AR6000_XIOCTL_WMI_STARTSCAN:
3327 WMI_START_SCAN_CMD setStartScanCmd, *cmdp;
3329 if (ar->arWmiReady == false) {
3331 } else if (copy_from_user(&setStartScanCmd, userdata,
3332 sizeof(setStartScanCmd)))
3336 if (setStartScanCmd.numChannels > 1) {
3337 cmdp = A_MALLOC(130);
3338 if (copy_from_user(cmdp, userdata,
3340 ((setStartScanCmd.numChannels - 1) *
3348 cmdp = &setStartScanCmd;
3351 if (wmi_startscan_cmd(ar->arWmi, cmdp->scanType,
3354 cmdp->homeDwellTime,
3355 cmdp->forceScanInterval,
3357 cmdp->channelList) != A_OK)
3364 case AR6000_XIOCTL_WMI_SETFIXRATES:
3366 WMI_FIX_RATES_CMD setFixRatesCmd;
3369 if (ar->arWmiReady == false) {
3371 } else if (copy_from_user(&setFixRatesCmd, userdata,
3372 sizeof(setFixRatesCmd)))
3376 returnStatus = wmi_set_fixrates_cmd(ar->arWmi, setFixRatesCmd.fixRateMask);
3377 if (returnStatus == A_EINVAL) {
3379 } else if(returnStatus != A_OK) {
3382 ar->ap_profile_flag = 1; /* There is a change in profile */
3388 case AR6000_XIOCTL_WMI_GETFIXRATES:
3390 WMI_FIX_RATES_CMD getFixRatesCmd;
3391 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
3394 if (ar->bIsDestroyProgress) {
3398 if (ar->arWmiReady == false) {
3403 if (down_interruptible(&ar->arSem)) {
3407 if (ar->bIsDestroyProgress) {
3412 /* Used copy_from_user/copy_to_user to access user space data */
3413 if (copy_from_user(&getFixRatesCmd, userdata, sizeof(getFixRatesCmd))) {
3416 ar->arRateMask = 0xFFFFFFFF;
3418 if (wmi_get_ratemask_cmd(ar->arWmi) != A_OK) {
3424 wait_event_interruptible_timeout(arEvent, ar->arRateMask != 0xFFFFFFFF, wmitimeout * HZ);
3426 if (signal_pending(current)) {
3431 getFixRatesCmd.fixRateMask = ar->arRateMask;
3434 if(copy_to_user(userdata, &getFixRatesCmd, sizeof(getFixRatesCmd))) {
3442 case AR6000_XIOCTL_WMI_SET_AUTHMODE:
3444 WMI_SET_AUTH_MODE_CMD setAuthMode;
3446 if (ar->arWmiReady == false) {
3448 } else if (copy_from_user(&setAuthMode, userdata,
3449 sizeof(setAuthMode)))
3453 if (wmi_set_authmode_cmd(ar->arWmi, setAuthMode.mode) != A_OK)
3460 case AR6000_XIOCTL_WMI_SET_REASSOCMODE:
3462 WMI_SET_REASSOC_MODE_CMD setReassocMode;
3464 if (ar->arWmiReady == false) {
3466 } else if (copy_from_user(&setReassocMode, userdata,
3467 sizeof(setReassocMode)))
3471 if (wmi_set_reassocmode_cmd(ar->arWmi, setReassocMode.mode) != A_OK)
3478 case AR6000_XIOCTL_DIAG_READ:
3480 A_UINT32 addr, data;
3481 if (get_user(addr, (unsigned int *)userdata)) {
3485 addr = TARG_VTOP(ar->arTargetType, addr);
3486 if (ar6000_ReadRegDiag(ar->arHifDevice, &addr, &data) != A_OK) {
3489 if (put_user(data, (unsigned int *)userdata + 1)) {
3495 case AR6000_XIOCTL_DIAG_WRITE:
3497 A_UINT32 addr, data;
3498 if (get_user(addr, (unsigned int *)userdata) ||
3499 get_user(data, (unsigned int *)userdata + 1)) {
3503 addr = TARG_VTOP(ar->arTargetType, addr);
3504 if (ar6000_WriteRegDiag(ar->arHifDevice, &addr, &data) != A_OK) {
3509 case AR6000_XIOCTL_WMI_SET_KEEPALIVE:
3511 WMI_SET_KEEPALIVE_CMD setKeepAlive;
3512 if (ar->arWmiReady == false) {
3515 } else if (copy_from_user(&setKeepAlive, userdata,
3516 sizeof(setKeepAlive))){
3519 if (wmi_set_keepalive_cmd(ar->arWmi, setKeepAlive.keepaliveInterval) != A_OK) {
3525 case AR6000_XIOCTL_WMI_SET_PARAMS:
3527 WMI_SET_PARAMS_CMD cmd;
3528 if (ar->arWmiReady == false) {
3531 } else if (copy_from_user(&cmd, userdata,
3534 } else if (copy_from_user(&cmd, userdata,
3535 sizeof(cmd) + cmd.length))
3539 if (wmi_set_params_cmd(ar->arWmi, cmd.opcode, cmd.length, cmd.buffer) != A_OK) {
3545 case AR6000_XIOCTL_WMI_SET_MCAST_FILTER:
3547 WMI_SET_MCAST_FILTER_CMD cmd;
3548 if (ar->arWmiReady == false) {
3551 } else if (copy_from_user(&cmd, userdata,
3555 if (wmi_set_mcast_filter_cmd(ar->arWmi, cmd.multicast_mac[0],
3556 cmd.multicast_mac[1],
3557 cmd.multicast_mac[2],
3558 cmd.multicast_mac[3]) != A_OK) {
3564 case AR6000_XIOCTL_WMI_DEL_MCAST_FILTER:
3566 WMI_SET_MCAST_FILTER_CMD cmd;
3567 if (ar->arWmiReady == false) {
3570 } else if (copy_from_user(&cmd, userdata,
3574 if (wmi_del_mcast_filter_cmd(ar->arWmi, cmd.multicast_mac[0],
3575 cmd.multicast_mac[1],
3576 cmd.multicast_mac[2],
3577 cmd.multicast_mac[3]) != A_OK) {
3583 case AR6000_XIOCTL_WMI_MCAST_FILTER:
3585 WMI_MCAST_FILTER_CMD cmd;
3586 if (ar->arWmiReady == false) {
3589 } else if (copy_from_user(&cmd, userdata,
3593 if (wmi_mcast_filter_cmd(ar->arWmi, cmd.enable) != A_OK) {
3599 case AR6000_XIOCTL_WMI_GET_KEEPALIVE:
3601 AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
3602 WMI_GET_KEEPALIVE_CMD getKeepAlive;
3604 if (ar->bIsDestroyProgress) {
3608 if (ar->arWmiReady == false) {
3612 if (down_interruptible(&ar->arSem)) {
3616 if (ar->bIsDestroyProgress) {
3621 if (copy_from_user(&getKeepAlive, userdata,sizeof(getKeepAlive))) {
3624 getKeepAlive.keepaliveInterval = wmi_get_keepalive_cmd(ar->arWmi);
3625 ar->arKeepaliveConfigured = 0xFF;
3626 if (wmi_get_keepalive_configured(ar->arWmi) != A_OK){
3631 wait_event_interruptible_timeout(arEvent, ar->arKeepaliveConfigured != 0xFF, wmitimeout * HZ);
3632 if (signal_pending(current)) {
3637 getKeepAlive.configured = ar->arKeepaliveConfigured;
3639 if (copy_to_user(userdata, &getKeepAlive, sizeof(getKeepAlive))) {
3646 case AR6000_XIOCTL_WMI_SET_APPIE:
3648 WMI_SET_APPIE_CMD appIEcmd;
3649 u8 appIeInfo[IEEE80211_APPIE_FRAME_MAX_LEN];
3650 A_UINT32 fType,ieLen;
3652 if (ar->arWmiReady == false) {
3656 if (get_user(fType, (A_UINT32 *)userdata)) {
3660 appIEcmd.mgmtFrmType = fType;
3661 if (appIEcmd.mgmtFrmType >= IEEE80211_APPIE_NUM_OF_FRAME) {
3664 if (get_user(ieLen, (A_UINT32 *)(userdata + 4))) {
3668 appIEcmd.ieLen = ieLen;
3669 A_PRINTF("WPSIE: Type-%d, Len-%d\n",appIEcmd.mgmtFrmType, appIEcmd.ieLen);
3670 if (appIEcmd.ieLen > IEEE80211_APPIE_FRAME_MAX_LEN) {
3674 if (copy_from_user(appIeInfo, userdata + 8, appIEcmd.ieLen)) {
3677 if (wmi_set_appie_cmd(ar->arWmi, appIEcmd.mgmtFrmType,
3678 appIEcmd.ieLen, appIeInfo) != A_OK)
3686 case AR6000_XIOCTL_WMI_SET_MGMT_FRM_RX_FILTER:
3688 WMI_BSS_FILTER_CMD cmd;
3689 A_UINT32 filterType;
3691 if (copy_from_user(&filterType, userdata, sizeof(A_UINT32)))
3696 if (filterType & (IEEE80211_FILTER_TYPE_BEACON |
3697 IEEE80211_FILTER_TYPE_PROBE_RESP))
3699 cmd.bssFilter = ALL_BSS_FILTER;
3701 cmd.bssFilter = NONE_BSS_FILTER;
3703 if (wmi_bssfilter_cmd(ar->arWmi, cmd.bssFilter, 0) != A_OK) {
3706 ar->arUserBssFilter = cmd.bssFilter;
3709 AR6000_SPIN_LOCK(&ar->arLock, 0);
3710 ar->arMgmtFilter = filterType;
3711 AR6000_SPIN_UNLOCK(&ar->arLock, 0);
3714 case AR6000_XIOCTL_WMI_SET_WSC_STATUS:
3716 A_UINT32 wsc_status;
3718 if (ar->arWmiReady == false) {
3721 } else if (copy_from_user(&wsc_status, userdata, sizeof(A_UINT32)))
3726 if (wmi_set_wsc_status_cmd(ar->arWmi, wsc_status) != A_OK) {
3731 case AR6000_XIOCTL_BMI_ROMPATCH_INSTALL:
3736 A_UINT32 do_activate;
3737 A_UINT32 rompatch_id;
3739 if (get_user(ROM_addr, (A_UINT32 *)userdata) ||
3740 get_user(RAM_addr, (A_UINT32 *)userdata + 1) ||
3741 get_user(nbytes, (A_UINT32 *)userdata + 2) ||
3742 get_user(do_activate, (A_UINT32 *)userdata + 3)) {
3746 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Install rompatch from ROM: 0x%x to RAM: 0x%x length: %d\n",
3747 ROM_addr, RAM_addr, nbytes));
3748 ret = BMIrompatchInstall(hifDevice, ROM_addr, RAM_addr,
3749 nbytes, do_activate, &rompatch_id);
3752 if (put_user(rompatch_id, (unsigned int *)rq->ifr_data)) {
3760 case AR6000_XIOCTL_BMI_ROMPATCH_UNINSTALL:
3762 A_UINT32 rompatch_id;
3764 if (get_user(rompatch_id, (A_UINT32 *)userdata)) {
3768 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("UNinstall rompatch_id %d\n", rompatch_id));
3769 ret = BMIrompatchUninstall(hifDevice, rompatch_id);
3773 case AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE:
3774 case AR6000_XIOCTL_BMI_ROMPATCH_DEACTIVATE:
3776 A_UINT32 rompatch_count;
3778 if (get_user(rompatch_count, (A_UINT32 *)userdata)) {
3782 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Change rompatch activation count=%d\n", rompatch_count));
3783 length = sizeof(A_UINT32) * rompatch_count;
3784 if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
3785 A_MEMZERO(buffer, length);
3786 if (copy_from_user(buffer, &userdata[sizeof(rompatch_count)], length))
3790 if (cmd == AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE) {
3791 ret = BMIrompatchActivate(hifDevice, rompatch_count, (A_UINT32 *)buffer);
3793 ret = BMIrompatchDeactivate(hifDevice, rompatch_count, (A_UINT32 *)buffer);
3803 case AR6000_XIOCTL_SET_IP:
3805 WMI_SET_IP_CMD setIP;
3807 if (ar->arWmiReady == false) {
3809 } else if (copy_from_user(&setIP, userdata,
3814 if (wmi_set_ip_cmd(ar->arWmi,
3823 case AR6000_XIOCTL_WMI_SET_HOST_SLEEP_MODE:
3825 WMI_SET_HOST_SLEEP_MODE_CMD setHostSleepMode;
3827 if (ar->arWmiReady == false) {
3829 } else if (copy_from_user(&setHostSleepMode, userdata,
3830 sizeof(setHostSleepMode)))
3834 if (wmi_set_host_sleep_mode_cmd(ar->arWmi,
3835 &setHostSleepMode) != A_OK)
3842 case AR6000_XIOCTL_WMI_SET_WOW_MODE:
3844 WMI_SET_WOW_MODE_CMD setWowMode;
3846 if (ar->arWmiReady == false) {
3848 } else if (copy_from_user(&setWowMode, userdata,
3849 sizeof(setWowMode)))
3853 if (wmi_set_wow_mode_cmd(ar->arWmi,
3854 &setWowMode) != A_OK)
3861 case AR6000_XIOCTL_WMI_GET_WOW_LIST:
3863 WMI_GET_WOW_LIST_CMD getWowList;
3865 if (ar->arWmiReady == false) {
3867 } else if (copy_from_user(&getWowList, userdata,
3868 sizeof(getWowList)))
3872 if (wmi_get_wow_list_cmd(ar->arWmi,
3873 &getWowList) != A_OK)
3880 case AR6000_XIOCTL_WMI_ADD_WOW_PATTERN:
3882 #define WOW_PATTERN_SIZE 64
3883 #define WOW_MASK_SIZE 64
3885 WMI_ADD_WOW_PATTERN_CMD cmd;
3886 u8 mask_data[WOW_PATTERN_SIZE]={0};
3887 u8 pattern_data[WOW_PATTERN_SIZE]={0};
3890 if (ar->arWmiReady == false) {
3894 if(copy_from_user(&cmd, userdata,
3895 sizeof(WMI_ADD_WOW_PATTERN_CMD)))
3900 if (copy_from_user(pattern_data,
3907 if (copy_from_user(mask_data,
3908 (userdata + 3 + cmd.filter_size),
3914 if (wmi_add_wow_pattern_cmd(ar->arWmi,
3915 &cmd, pattern_data, mask_data, cmd.filter_size) != A_OK)
3920 #undef WOW_PATTERN_SIZE
3921 #undef WOW_MASK_SIZE
3924 case AR6000_XIOCTL_WMI_DEL_WOW_PATTERN:
3926 WMI_DEL_WOW_PATTERN_CMD delWowPattern;
3928 if (ar->arWmiReady == false) {
3930 } else if (copy_from_user(&delWowPattern, userdata,
3931 sizeof(delWowPattern)))
3935 if (wmi_del_wow_pattern_cmd(ar->arWmi,
3936 &delWowPattern) != A_OK)
3943 case AR6000_XIOCTL_DUMP_HTC_CREDIT_STATE:
3944 if (ar->arHtcTarget != NULL) {
3945 #ifdef ATH_DEBUG_MODULE
3946 HTCDumpCreditStates(ar->arHtcTarget);
3947 #endif /* ATH_DEBUG_MODULE */
3948 #ifdef HTC_EP_STAT_PROFILING
3950 HTC_ENDPOINT_STATS stats;
3953 for (i = 0; i < 5; i++) {
3954 if (HTCGetEndpointStatistics(ar->arHtcTarget,
3956 HTC_EP_STAT_SAMPLE_AND_CLEAR,
3958 A_PRINTF(KERN_ALERT"------- Profiling Endpoint : %d \n", i);
3959 A_PRINTF(KERN_ALERT"TxCreditLowIndications : %d \n", stats.TxCreditLowIndications);
3960 A_PRINTF(KERN_ALERT"TxIssued : %d \n", stats.TxIssued);
3961 A_PRINTF(KERN_ALERT"TxDropped: %d \n", stats.TxDropped);
3962 A_PRINTF(KERN_ALERT"TxPacketsBundled : %d \n", stats.TxPacketsBundled);
3963 A_PRINTF(KERN_ALERT"TxBundles : %d \n", stats.TxBundles);
3964 A_PRINTF(KERN_ALERT"TxCreditRpts : %d \n", stats.TxCreditRpts);
3965 A_PRINTF(KERN_ALERT"TxCreditsRptsFromRx : %d \n", stats.TxCreditRptsFromRx);
3966 A_PRINTF(KERN_ALERT"TxCreditsRptsFromOther : %d \n", stats.TxCreditRptsFromOther);
3967 A_PRINTF(KERN_ALERT"TxCreditsRptsFromEp0 : %d \n", stats.TxCreditRptsFromEp0);
3968 A_PRINTF(KERN_ALERT"TxCreditsFromRx : %d \n", stats.TxCreditsFromRx);
3969 A_PRINTF(KERN_ALERT"TxCreditsFromOther : %d \n", stats.TxCreditsFromOther);
3970 A_PRINTF(KERN_ALERT"TxCreditsFromEp0 : %d \n", stats.TxCreditsFromEp0);
3971 A_PRINTF(KERN_ALERT"TxCreditsConsummed : %d \n", stats.TxCreditsConsummed);
3972 A_PRINTF(KERN_ALERT"TxCreditsReturned : %d \n", stats.TxCreditsReturned);
3973 A_PRINTF(KERN_ALERT"RxReceived : %d \n", stats.RxReceived);
3974 A_PRINTF(KERN_ALERT"RxPacketsBundled : %d \n", stats.RxPacketsBundled);
3975 A_PRINTF(KERN_ALERT"RxLookAheads : %d \n", stats.RxLookAheads);
3976 A_PRINTF(KERN_ALERT"RxBundleLookAheads : %d \n", stats.RxBundleLookAheads);
3977 A_PRINTF(KERN_ALERT"RxBundleIndFromHdr : %d \n", stats.RxBundleIndFromHdr);
3978 A_PRINTF(KERN_ALERT"RxAllocThreshHit : %d \n", stats.RxAllocThreshHit);
3979 A_PRINTF(KERN_ALERT"RxAllocThreshBytes : %d \n", stats.RxAllocThreshBytes);
3980 A_PRINTF(KERN_ALERT"---- \n");
3988 case AR6000_XIOCTL_TRAFFIC_ACTIVITY_CHANGE:
3989 if (ar->arHtcTarget != NULL) {
3990 struct ar6000_traffic_activity_change data;
3992 if (copy_from_user(&data, userdata, sizeof(data)))
3997 /* note, this is used for testing (mbox ping testing), indicate activity
3998 * change using the stream ID as the traffic class */
3999 ar6000_indicate_tx_activity(ar,
4001 data.Active ? true : false);
4004 case AR6000_XIOCTL_WMI_SET_CONNECT_CTRL_FLAGS:
4005 if (ar->arWmiReady == false) {
4007 } else if (copy_from_user(&connectCtrlFlags, userdata,
4008 sizeof(connectCtrlFlags)))
4012 ar->arConnectCtrlFlags = connectCtrlFlags;
4015 case AR6000_XIOCTL_WMI_SET_AKMP_PARAMS:
4016 if (ar->arWmiReady == false) {
4018 } else if (copy_from_user(&akmpParams, userdata,
4019 sizeof(WMI_SET_AKMP_PARAMS_CMD)))
4023 if (wmi_set_akmp_params_cmd(ar->arWmi, &akmpParams) != A_OK) {
4028 case AR6000_XIOCTL_WMI_SET_PMKID_LIST:
4029 if (ar->arWmiReady == false) {
4032 if (copy_from_user(&pmkidInfo.numPMKID, userdata,
4033 sizeof(pmkidInfo.numPMKID)))
4038 if (copy_from_user(&pmkidInfo.pmkidList,
4039 userdata + sizeof(pmkidInfo.numPMKID),
4040 pmkidInfo.numPMKID * sizeof(WMI_PMKID)))
4045 if (wmi_set_pmkid_list_cmd(ar->arWmi, &pmkidInfo) != A_OK) {
4050 case AR6000_XIOCTL_WMI_GET_PMKID_LIST:
4051 if (ar->arWmiReady == false) {
4054 if (wmi_get_pmkid_list_cmd(ar->arWmi) != A_OK) {
4059 case AR6000_XIOCTL_WMI_ABORT_SCAN:
4060 if (ar->arWmiReady == false) {
4063 ret = wmi_abort_scan_cmd(ar->arWmi);
4065 case AR6000_XIOCTL_AP_HIDDEN_SSID:
4068 if (ar->arWmiReady == false) {
4070 } else if (copy_from_user(&hidden_ssid, userdata, sizeof(hidden_ssid))) {
4073 wmi_ap_set_hidden_ssid(ar->arWmi, hidden_ssid);
4074 ar->ap_hidden_ssid = hidden_ssid;
4075 ar->ap_profile_flag = 1; /* There is a change in profile */
4079 case AR6000_XIOCTL_AP_GET_STA_LIST:
4081 if (ar->arWmiReady == false) {
4086 A_MEMZERO(&temp, sizeof(temp));
4087 for(i=0;i<AP_MAX_NUM_STA;i++) {
4088 A_MEMCPY(temp.sta[i].mac, ar->sta_list[i].mac, ATH_MAC_LEN);
4089 temp.sta[i].aid = ar->sta_list[i].aid;
4090 temp.sta[i].keymgmt = ar->sta_list[i].keymgmt;
4091 temp.sta[i].ucipher = ar->sta_list[i].ucipher;
4092 temp.sta[i].auth = ar->sta_list[i].auth;
4094 if(copy_to_user((ap_get_sta_t *)rq->ifr_data, &temp,
4095 sizeof(ar->sta_list))) {
4101 case AR6000_XIOCTL_AP_SET_NUM_STA:
4104 if (ar->arWmiReady == false) {
4106 } else if (copy_from_user(&num_sta, userdata, sizeof(num_sta))) {
4108 } else if(num_sta > AP_MAX_NUM_STA) {
4109 /* value out of range */
4112 wmi_ap_set_num_sta(ar->arWmi, num_sta);
4116 case AR6000_XIOCTL_AP_SET_ACL_POLICY:
4119 if (ar->arWmiReady == false) {
4121 } else if (copy_from_user(&policy, userdata, sizeof(policy))) {
4123 } else if(policy == ar->g_acl.policy) {
4124 /* No change in policy */
4126 if(!(policy & AP_ACL_RETAIN_LIST_MASK)) {
4127 /* clear ACL list */
4128 memset(&ar->g_acl,0,sizeof(WMI_AP_ACL));
4130 ar->g_acl.policy = policy;
4131 wmi_ap_set_acl_policy(ar->arWmi, policy);
4135 case AR6000_XIOCTL_AP_SET_ACL_MAC:
4137 WMI_AP_ACL_MAC_CMD acl;
4138 if (ar->arWmiReady == false) {
4140 } else if (copy_from_user(&acl, userdata, sizeof(acl))) {
4143 if(acl_add_del_mac(&ar->g_acl, &acl)) {
4144 wmi_ap_acl_mac_list(ar->arWmi, &acl);
4146 A_PRINTF("ACL list error\n");
4152 case AR6000_XIOCTL_AP_GET_ACL_LIST:
4154 if (ar->arWmiReady == false) {
4156 } else if(copy_to_user((WMI_AP_ACL *)rq->ifr_data, &ar->g_acl,
4157 sizeof(WMI_AP_ACL))) {
4162 case AR6000_XIOCTL_AP_COMMIT_CONFIG:
4164 ret = ar6000_ap_mode_profile_commit(ar);
4167 case IEEE80211_IOCTL_GETWPAIE:
4169 struct ieee80211req_wpaie wpaie;
4170 if (ar->arWmiReady == false) {
4172 } else if (copy_from_user(&wpaie, userdata, sizeof(wpaie))) {
4174 } else if (ar6000_ap_mode_get_wpa_ie(ar, &wpaie)) {
4176 } else if(copy_to_user(userdata, &wpaie, sizeof(wpaie))) {
4181 case AR6000_XIOCTL_AP_CONN_INACT_TIME:
4184 if (ar->arWmiReady == false) {
4186 } else if (copy_from_user(&period, userdata, sizeof(period))) {
4189 wmi_ap_conn_inact_time(ar->arWmi, period);
4193 case AR6000_XIOCTL_AP_PROT_SCAN_TIME:
4195 WMI_AP_PROT_SCAN_TIME_CMD bgscan;
4196 if (ar->arWmiReady == false) {
4198 } else if (copy_from_user(&bgscan, userdata, sizeof(bgscan))) {
4201 wmi_ap_bgscan_time(ar->arWmi, bgscan.period_min, bgscan.dwell_ms);
4205 case AR6000_XIOCTL_AP_SET_COUNTRY:
4207 ret = ar6000_ioctl_set_country(dev, rq);
4210 case AR6000_XIOCTL_AP_SET_DTIM:
4212 WMI_AP_SET_DTIM_CMD d;
4213 if (ar->arWmiReady == false) {
4215 } else if (copy_from_user(&d, userdata, sizeof(d))) {
4218 if(d.dtim > 0 && d.dtim < 11) {
4219 ar->ap_dtim_period = d.dtim;
4220 wmi_ap_set_dtim(ar->arWmi, d.dtim);
4221 ar->ap_profile_flag = 1; /* There is a change in profile */
4223 A_PRINTF("DTIM out of range. Valid range is [1-10]\n");
4229 case AR6000_XIOCTL_WMI_TARGET_EVENT_REPORT:
4231 WMI_SET_TARGET_EVENT_REPORT_CMD evtCfgCmd;
4233 if (ar->arWmiReady == false) {
4236 if (copy_from_user(&evtCfgCmd, userdata,
4237 sizeof(evtCfgCmd))) {
4241 ret = wmi_set_target_event_report_cmd(ar->arWmi, &evtCfgCmd);
4244 case AR6000_XIOCTL_AP_INTRA_BSS_COMM:
4247 if (ar->arWmiReady == false) {
4249 } else if (copy_from_user(&intra, userdata, sizeof(intra))) {
4252 ar->intra_bss = (intra?1:0);
4256 case AR6000_XIOCTL_DUMP_MODULE_DEBUG_INFO:
4258 struct drv_debug_module_s moduleinfo;
4260 if (copy_from_user(&moduleinfo, userdata, sizeof(moduleinfo))) {
4265 a_dump_module_debug_info_by_name(moduleinfo.modulename);
4269 case AR6000_XIOCTL_MODULE_DEBUG_SET_MASK:
4271 struct drv_debug_module_s moduleinfo;
4273 if (copy_from_user(&moduleinfo, userdata, sizeof(moduleinfo))) {
4278 if (a_set_module_mask(moduleinfo.modulename, moduleinfo.mask)) {
4284 case AR6000_XIOCTL_MODULE_DEBUG_GET_MASK:
4286 struct drv_debug_module_s moduleinfo;
4288 if (copy_from_user(&moduleinfo, userdata, sizeof(moduleinfo))) {
4293 if (a_get_module_mask(moduleinfo.modulename, &moduleinfo.mask)) {
4298 if (copy_to_user(userdata, &moduleinfo, sizeof(moduleinfo))) {
4305 #ifdef ATH_AR6K_11N_SUPPORT
4306 case AR6000_XIOCTL_DUMP_RCV_AGGR_STATS:
4308 PACKET_LOG *copy_of_pkt_log;
4310 aggr_dump_stats(ar->aggr_cntxt, ©_of_pkt_log);
4311 if (copy_to_user(rq->ifr_data, copy_of_pkt_log, sizeof(PACKET_LOG))) {
4316 case AR6000_XIOCTL_SETUP_AGGR:
4318 WMI_ADDBA_REQ_CMD cmd;
4320 if (ar->arWmiReady == false) {
4322 } else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
4325 wmi_setup_aggr_cmd(ar->arWmi, cmd.tid);
4330 case AR6000_XIOCTL_DELE_AGGR:
4332 WMI_DELBA_REQ_CMD cmd;
4334 if (ar->arWmiReady == false) {
4336 } else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
4339 wmi_delete_aggr_cmd(ar->arWmi, cmd.tid, cmd.is_sender_initiator);
4344 case AR6000_XIOCTL_ALLOW_AGGR:
4346 WMI_ALLOW_AGGR_CMD cmd;
4348 if (ar->arWmiReady == false) {
4350 } else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
4353 wmi_allow_aggr_cmd(ar->arWmi, cmd.tx_allow_aggr, cmd.rx_allow_aggr);
4358 case AR6000_XIOCTL_SET_HT_CAP:
4360 if (ar->arWmiReady == false) {
4362 } else if (copy_from_user(&htCap, userdata,
4368 if (wmi_set_ht_cap_cmd(ar->arWmi, &htCap) != A_OK)
4375 case AR6000_XIOCTL_SET_HT_OP:
4377 if (ar->arWmiReady == false) {
4379 } else if (copy_from_user(&htOp, userdata,
4385 if (wmi_set_ht_op_cmd(ar->arWmi, htOp.sta_chan_width) != A_OK)
4393 case AR6000_XIOCTL_ACL_DATA:
4396 if (ar->arWmiReady == false) {
4398 } else if (ar6000_create_acl_data_osbuf(dev, (u8 *)userdata, &osbuf) != A_OK) {
4401 if (wmi_data_hdr_add(ar->arWmi, osbuf, DATA_MSGTYPE, 0, WMI_DATA_HDR_DATA_TYPE_ACL,0,NULL) != A_OK) {
4402 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("XIOCTL_ACL_DATA - wmi_data_hdr_add failed\n"));
4404 /* Send data buffer over HTC */
4405 ar6000_acl_data_tx(osbuf, ar->arNetDev);
4410 case AR6000_XIOCTL_HCI_CMD:
4414 WMI_HCI_CMD *cmd = (WMI_HCI_CMD *)tmp_buf;
4417 size = sizeof(cmd->cmd_buf_sz);
4418 if (ar->arWmiReady == false) {
4420 } else if (copy_from_user(cmd, userdata, size)) {
4422 } else if(copy_from_user(cmd->buf, userdata + size, cmd->cmd_buf_sz)) {
4425 if (wmi_send_hci_cmd(ar->arWmi, cmd->buf, cmd->cmd_buf_sz) != A_OK) {
4428 A_PRINTF_LOG("HCI Command To PAL --> \n");
4429 for(i = 0; i < cmd->cmd_buf_sz; i++) {
4430 A_PRINTF_LOG("0x%02x ",cmd->buf[i]);
4436 A_PRINTF_LOG("==================================\n");
4441 case AR6000_XIOCTL_WLAN_CONN_PRECEDENCE:
4443 WMI_SET_BT_WLAN_CONN_PRECEDENCE cmd;
4444 if (ar->arWmiReady == false) {
4446 } else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
4449 if (cmd.precedence == BT_WLAN_CONN_PRECDENCE_WLAN ||
4450 cmd.precedence == BT_WLAN_CONN_PRECDENCE_PAL) {
4451 if ( wmi_set_wlan_conn_precedence_cmd(ar->arWmi, cmd.precedence) != A_OK) {
4460 case AR6000_XIOCTL_AP_GET_STAT:
4462 ret = ar6000_ioctl_get_ap_stats(dev, rq);
4465 case AR6000_XIOCTL_SET_TX_SELECT_RATES:
4467 WMI_SET_TX_SELECT_RATES_CMD masks;
4469 if (ar->arWmiReady == false) {
4471 } else if (copy_from_user(&masks, userdata,
4477 if (wmi_set_tx_select_rates_cmd(ar->arWmi, masks.rateMasks) != A_OK)
4484 case AR6000_XIOCTL_AP_GET_HIDDEN_SSID:
4486 WMI_AP_HIDDEN_SSID_CMD ssid;
4487 ssid.hidden_ssid = ar->ap_hidden_ssid;
4489 if (ar->arWmiReady == false) {
4491 } else if(copy_to_user((WMI_AP_HIDDEN_SSID_CMD *)rq->ifr_data,
4492 &ssid, sizeof(WMI_AP_HIDDEN_SSID_CMD))) {
4497 case AR6000_XIOCTL_AP_GET_COUNTRY:
4499 WMI_AP_SET_COUNTRY_CMD cty;
4500 A_MEMCPY(cty.countryCode, ar->ap_country_code, 3);
4502 if (ar->arWmiReady == false) {
4504 } else if(copy_to_user((WMI_AP_SET_COUNTRY_CMD *)rq->ifr_data,
4505 &cty, sizeof(WMI_AP_SET_COUNTRY_CMD))) {
4510 case AR6000_XIOCTL_AP_GET_WMODE:
4512 if (ar->arWmiReady == false) {
4514 } else if(copy_to_user((u8 *)rq->ifr_data,
4515 &ar->ap_wmode, sizeof(u8))) {
4520 case AR6000_XIOCTL_AP_GET_DTIM:
4522 WMI_AP_SET_DTIM_CMD dtim;
4523 dtim.dtim = ar->ap_dtim_period;
4525 if (ar->arWmiReady == false) {
4527 } else if(copy_to_user((WMI_AP_SET_DTIM_CMD *)rq->ifr_data,
4528 &dtim, sizeof(WMI_AP_SET_DTIM_CMD))) {
4533 case AR6000_XIOCTL_AP_GET_BINTVL:
4535 WMI_BEACON_INT_CMD bi;
4536 bi.beaconInterval = ar->ap_beacon_interval;
4538 if (ar->arWmiReady == false) {
4540 } else if(copy_to_user((WMI_BEACON_INT_CMD *)rq->ifr_data,
4541 &bi, sizeof(WMI_BEACON_INT_CMD))) {
4546 case AR6000_XIOCTL_AP_GET_RTS:
4548 WMI_SET_RTS_CMD rts;
4549 rts.threshold = ar->arRTS;
4551 if (ar->arWmiReady == false) {
4553 } else if(copy_to_user((WMI_SET_RTS_CMD *)rq->ifr_data,
4554 &rts, sizeof(WMI_SET_RTS_CMD))) {
4559 case AR6000_XIOCTL_FETCH_TARGET_REGS:
4561 A_UINT32 targregs[AR6003_FETCH_TARG_REGS_COUNT];
4563 if (ar->arTargetType == TARGET_TYPE_AR6003) {
4564 ar6k_FetchTargetRegs(hifDevice, targregs);
4565 if (copy_to_user((A_UINT32 *)rq->ifr_data, &targregs, sizeof(targregs)))
4574 case AR6000_XIOCTL_AP_SET_11BG_RATESET:
4576 WMI_AP_SET_11BG_RATESET_CMD rate;
4577 if (ar->arWmiReady == false) {
4579 } else if (copy_from_user(&rate, userdata, sizeof(rate))) {
4582 wmi_ap_set_rateset(ar->arWmi, rate.rateset);
4586 case AR6000_XIOCTL_GET_WLAN_SLEEP_STATE:
4588 WMI_REPORT_SLEEP_STATE_EVENT wmiSleepEvent ;
4590 if (ar->arWlanState == WLAN_ENABLED) {
4591 wmiSleepEvent.sleepState = WMI_REPORT_SLEEP_STATUS_IS_AWAKE;
4593 wmiSleepEvent.sleepState = WMI_REPORT_SLEEP_STATUS_IS_DEEP_SLEEP;
4595 rq->ifr_ifru.ifru_ivalue = ar->arWlanState; /* return value */
4597 ar6000_send_event_to_app(ar, WMI_REPORT_SLEEP_STATE_EVENTID, (u8 *)&wmiSleepEvent,
4598 sizeof(WMI_REPORT_SLEEP_STATE_EVENTID));
4602 case AR6000_XIOCTL_SET_BT_HW_POWER_STATE:
4605 if (get_user(state, (unsigned int *)userdata)) {
4609 if (ar6000_set_bt_hw_state(ar, state)!=A_OK) {
4614 case AR6000_XIOCTL_GET_BT_HW_POWER_STATE:
4615 rq->ifr_ifru.ifru_ivalue = !ar->arBTOff; /* return value */
4619 case AR6000_XIOCTL_WMI_SET_TX_SGI_PARAM:
4621 WMI_SET_TX_SGI_PARAM_CMD SGICmd;
4623 if (ar->arWmiReady == false) {
4625 } else if (copy_from_user(&SGICmd, userdata,
4629 if (wmi_SGI_cmd(ar->arWmi, SGICmd.sgiMask, SGICmd.sgiPERThreshold) != A_OK) {
4637 case AR6000_XIOCTL_ADD_AP_INTERFACE:
4638 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
4640 char ap_ifname[IFNAMSIZ] = {0,};
4641 if (copy_from_user(ap_ifname, userdata, IFNAMSIZ)) {
4644 if (ar6000_add_ap_interface(ar, ap_ifname) != A_OK) {
4653 case AR6000_XIOCTL_REMOVE_AP_INTERFACE:
4654 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
4655 if (ar6000_remove_ap_interface(ar) != A_OK) {
4668 rtnl_lock(); /* restore rtnl state */
4674 u8 mac_cmp_wild(u8 *mac, u8 *new_mac, u8 wild, u8 new_wild)
4678 for(i=0;i<ATH_MAC_LEN;i++) {
4679 if((wild & 1<<i) && (new_wild & 1<<i)) continue;
4680 if(mac[i] != new_mac[i]) return 1;
4682 if((A_MEMCMP(new_mac, null_mac, 6)==0) && new_wild &&
4683 (wild != new_wild)) {
4690 u8 acl_add_del_mac(WMI_AP_ACL *a, WMI_AP_ACL_MAC_CMD *acl)
4692 A_INT8 already_avail=-1, free_slot=-1, i;
4694 /* To check whether this mac is already there in our list */
4695 for(i=AP_ACL_SIZE-1;i>=0;i--)
4697 if(mac_cmp_wild(a->acl_mac[i], acl->mac, a->wildcard[i],
4701 if(!((1 << i) & a->index))
4705 if(acl->action == ADD_MAC_ADDR)
4707 /* Dont add mac if it is already available */
4708 if((already_avail >= 0) || (free_slot == -1))
4711 A_MEMCPY(a->acl_mac[free_slot], acl->mac, ATH_MAC_LEN);
4712 a->index = a->index | (1 << free_slot);
4713 acl->index = free_slot;
4714 a->wildcard[free_slot] = acl->wildcard;
4717 else if(acl->action == DEL_MAC_ADDR)
4719 if(acl->index > AP_ACL_SIZE)
4722 if(!(a->index & (1 << acl->index)))
4725 A_MEMZERO(a->acl_mac[acl->index],ATH_MAC_LEN);
4726 a->index = a->index & ~(1 << acl->index);
4727 a->wildcard[acl->index] = 0;