Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of version 2 of the GNU General Public License as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along with |
| 15 | * this program; if not, write to the Free Software Foundation, Inc., |
| 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA |
| 17 | * |
| 18 | * |
| 19 | ******************************************************************************/ |
| 20 | #define _IOCTL_LINUX_C_ |
| 21 | |
| 22 | #include <osdep_service.h> |
| 23 | #include <drv_types.h> |
| 24 | #include <wlan_bssdef.h> |
| 25 | #include <rtw_debug.h> |
| 26 | #include <wifi.h> |
| 27 | #include <rtw_mlme.h> |
| 28 | #include <rtw_mlme_ext.h> |
| 29 | #include <rtw_ioctl.h> |
| 30 | #include <rtw_ioctl_set.h> |
| 31 | #include <rtw_mp_ioctl.h> |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 32 | #include <usb_ops.h> |
| 33 | #include <rtw_version.h> |
| 34 | #include <rtl8188e_hal.h> |
| 35 | |
| 36 | #include <rtw_mp.h> |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 37 | #include <rtw_iol.h> |
| 38 | |
| 39 | #define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) |
| 40 | |
| 41 | #define SCAN_ITEM_SIZE 768 |
| 42 | #define MAX_CUSTOM_LEN 64 |
| 43 | #define RATE_COUNT 4 |
| 44 | |
| 45 | /* combo scan */ |
| 46 | #define WEXT_CSCAN_AMOUNT 9 |
| 47 | #define WEXT_CSCAN_BUF_LEN 360 |
| 48 | #define WEXT_CSCAN_HEADER "CSCAN S\x01\x00\x00S\x00" |
| 49 | #define WEXT_CSCAN_HEADER_SIZE 12 |
| 50 | #define WEXT_CSCAN_SSID_SECTION 'S' |
| 51 | #define WEXT_CSCAN_CHANNEL_SECTION 'C' |
| 52 | #define WEXT_CSCAN_NPROBE_SECTION 'N' |
| 53 | #define WEXT_CSCAN_ACTV_DWELL_SECTION 'A' |
| 54 | #define WEXT_CSCAN_PASV_DWELL_SECTION 'P' |
| 55 | #define WEXT_CSCAN_HOME_DWELL_SECTION 'H' |
| 56 | #define WEXT_CSCAN_TYPE_SECTION 'T' |
| 57 | |
| 58 | static struct mp_ioctl_handler mp_ioctl_hdl[] = { |
Larry Finger | d33b128 | 2013-08-25 11:55:15 -0500 | [diff] [blame] | 59 | /*0*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_start_test_hdl, OID_RT_PRO_START_TEST) |
| 60 | GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_stop_test_hdl, OID_RT_PRO_STOP_TEST) |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 61 | |
Larry Finger | d33b128 | 2013-08-25 11:55:15 -0500 | [diff] [blame] | 62 | GEN_HANDLER(sizeof(struct rwreg_param), rtl8188eu_oid_rt_pro_read_register_hdl, OID_RT_PRO_READ_REGISTER) |
| 63 | GEN_HANDLER(sizeof(struct rwreg_param), rtl8188eu_oid_rt_pro_write_register_hdl, OID_RT_PRO_WRITE_REGISTER) |
| 64 | GEN_HANDLER(sizeof(struct bb_reg_param), rtl8188eu_oid_rt_pro_read_bb_reg_hdl, OID_RT_PRO_READ_BB_REG) |
| 65 | /*5*/ GEN_HANDLER(sizeof(struct bb_reg_param), rtl8188eu_oid_rt_pro_write_bb_reg_hdl, OID_RT_PRO_WRITE_BB_REG) |
| 66 | GEN_HANDLER(sizeof(struct rf_reg_param), rtl8188eu_oid_rt_pro_read_rf_reg_hdl, OID_RT_PRO_RF_READ_REGISTRY) |
| 67 | GEN_HANDLER(sizeof(struct rf_reg_param), rtl8188eu_oid_rt_pro_write_rf_reg_hdl, OID_RT_PRO_RF_WRITE_REGISTRY) |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 68 | |
Larry Finger | d33b128 | 2013-08-25 11:55:15 -0500 | [diff] [blame] | 69 | GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl, OID_RT_PRO_SET_CHANNEL_DIRECT_CALL) |
| 70 | GEN_HANDLER(sizeof(struct txpower_param), rtl8188eu_oid_rt_pro_set_tx_power_control_hdl, OID_RT_PRO_SET_TX_POWER_CONTROL) |
| 71 | /*10*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_data_rate_hdl, OID_RT_PRO_SET_DATA_RATE) |
| 72 | GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_set_bandwidth_hdl, OID_RT_SET_BANDWIDTH) |
| 73 | GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_antenna_bb_hdl, OID_RT_PRO_SET_ANTENNA_BB) |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 74 | |
Larry Finger | d33b128 | 2013-08-25 11:55:15 -0500 | [diff] [blame] | 75 | GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_continuous_tx_hdl, OID_RT_PRO_SET_CONTINUOUS_TX) |
| 76 | GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl, OID_RT_PRO_SET_SINGLE_CARRIER_TX) |
| 77 | /*15*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl, OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX) |
| 78 | GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl, OID_RT_PRO_SET_SINGLE_TONE_TX) |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 79 | |
| 80 | EXT_MP_IOCTL_HANDLER(0, xmit_packet, 0) |
| 81 | |
Larry Finger | d33b128 | 2013-08-25 11:55:15 -0500 | [diff] [blame] | 82 | GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_set_rx_packet_type_hdl, OID_RT_SET_RX_PACKET_TYPE) |
| 83 | GEN_HANDLER(0, rtl8188eu_oid_rt_reset_phy_rx_packet_count_hdl, OID_RT_RESET_PHY_RX_PACKET_COUNT) |
| 84 | /*20*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl, OID_RT_GET_PHY_RX_PACKET_RECEIVED) |
| 85 | GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl, OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR) |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 86 | |
| 87 | GEN_HANDLER(sizeof(struct eeprom_rw_param), NULL, 0) |
| 88 | GEN_HANDLER(sizeof(struct eeprom_rw_param), NULL, 0) |
Larry Finger | d33b128 | 2013-08-25 11:55:15 -0500 | [diff] [blame] | 89 | GEN_HANDLER(sizeof(struct efuse_access_struct), rtl8188eu_oid_rt_pro_efuse_hdl, OID_RT_PRO_EFUSE) |
| 90 | /*25*/ GEN_HANDLER(0, rtl8188eu_oid_rt_pro_efuse_map_hdl, OID_RT_PRO_EFUSE_MAP) |
| 91 | GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_efuse_max_size_hdl, OID_RT_GET_EFUSE_MAX_SIZE) |
| 92 | GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_efuse_current_size_hdl, OID_RT_GET_EFUSE_CURRENT_SIZE) |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 93 | |
Larry Finger | d33b128 | 2013-08-25 11:55:15 -0500 | [diff] [blame] | 94 | GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_thermal_meter_hdl, OID_RT_PRO_GET_THERMAL_METER) |
| 95 | GEN_HANDLER(sizeof(u8), rtl8188eu_oid_rt_pro_set_power_tracking_hdl, OID_RT_PRO_SET_POWER_TRACKING) |
| 96 | /*30*/ GEN_HANDLER(sizeof(u8), rtl8188eu_oid_rt_set_power_down_hdl, OID_RT_SET_POWER_DOWN) |
| 97 | /*31*/ GEN_HANDLER(0, rtl8188eu_oid_rt_pro_trigger_gpio_hdl, 0) |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000, |
| 101 | 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, |
| 102 | 48000000, 54000000}; |
| 103 | |
| 104 | static const char * const iw_operation_mode[] = { |
| 105 | "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", |
| 106 | "Secondary", "Monitor" |
| 107 | }; |
| 108 | |
| 109 | static int hex2num_i(char c) |
| 110 | { |
| 111 | if (c >= '0' && c <= '9') |
| 112 | return c - '0'; |
| 113 | if (c >= 'a' && c <= 'f') |
| 114 | return c - 'a' + 10; |
| 115 | if (c >= 'A' && c <= 'F') |
| 116 | return c - 'A' + 10; |
| 117 | return -1; |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * hwaddr_aton - Convert ASCII string to MAC address |
| 122 | * @txt: MAC address as a string (e.g., "00:11:22:33:44:55") |
| 123 | * @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes) |
| 124 | * Returns: 0 on success, -1 on failure (e.g., string not a MAC address) |
| 125 | */ |
| 126 | static int hwaddr_aton_i(const char *txt, u8 *addr) |
| 127 | { |
| 128 | int i; |
| 129 | |
| 130 | for (i = 0; i < 6; i++) { |
| 131 | int a, b; |
| 132 | |
| 133 | a = hex2num_i(*txt++); |
| 134 | if (a < 0) |
| 135 | return -1; |
| 136 | b = hex2num_i(*txt++); |
| 137 | if (b < 0) |
| 138 | return -1; |
| 139 | *addr++ = (a << 4) | b; |
| 140 | if (i < 5 && *txt++ != ':') |
| 141 | return -1; |
| 142 | } |
| 143 | |
| 144 | return 0; |
| 145 | } |
| 146 | |
| 147 | void indicate_wx_scan_complete_event(struct adapter *padapter) |
| 148 | { |
| 149 | union iwreq_data wrqu; |
| 150 | |
| 151 | _rtw_memset(&wrqu, 0, sizeof(union iwreq_data)); |
| 152 | wireless_send_event(padapter->pnetdev, SIOCGIWSCAN, &wrqu, NULL); |
| 153 | } |
| 154 | |
| 155 | void rtw_indicate_wx_assoc_event(struct adapter *padapter) |
| 156 | { |
| 157 | union iwreq_data wrqu; |
| 158 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 159 | |
| 160 | _rtw_memset(&wrqu, 0, sizeof(union iwreq_data)); |
| 161 | |
| 162 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 163 | |
| 164 | memcpy(wrqu.ap_addr.sa_data, pmlmepriv->cur_network.network.MacAddress, ETH_ALEN); |
| 165 | |
| 166 | DBG_88E_LEVEL(_drv_always_, "assoc success\n"); |
| 167 | wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL); |
| 168 | } |
| 169 | |
| 170 | void rtw_indicate_wx_disassoc_event(struct adapter *padapter) |
| 171 | { |
| 172 | union iwreq_data wrqu; |
| 173 | |
| 174 | _rtw_memset(&wrqu, 0, sizeof(union iwreq_data)); |
| 175 | |
| 176 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 177 | _rtw_memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); |
| 178 | |
| 179 | DBG_88E_LEVEL(_drv_always_, "indicate disassoc\n"); |
| 180 | wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL); |
| 181 | } |
| 182 | |
| 183 | static char *translate_scan(struct adapter *padapter, |
| 184 | struct iw_request_info *info, |
| 185 | struct wlan_network *pnetwork, |
| 186 | char *start, char *stop) |
| 187 | { |
| 188 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 189 | struct iw_event iwe; |
| 190 | u16 cap; |
| 191 | __le16 le_tmp; |
| 192 | u32 ht_ielen = 0; |
| 193 | char custom[MAX_CUSTOM_LEN]; |
| 194 | char *p; |
| 195 | u16 max_rate = 0, rate, ht_cap = false; |
| 196 | u32 i = 0; |
| 197 | u8 bw_40MHz = 0, short_GI = 0; |
| 198 | u16 mcs_rate = 0; |
| 199 | u8 ss, sq; |
| 200 | #ifdef CONFIG_88EU_P2P |
| 201 | struct wifidirect_info *pwdinfo = &padapter->wdinfo; |
| 202 | |
| 203 | if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { |
| 204 | u32 blnGotP2PIE = false; |
| 205 | |
| 206 | /* User is doing the P2P device discovery */ |
| 207 | /* The prefix of SSID should be "DIRECT-" and the IE should contains the P2P IE. */ |
| 208 | /* If not, the driver should ignore this AP and go to the next AP. */ |
| 209 | |
| 210 | /* Verifying the SSID */ |
| 211 | if (!memcmp(pnetwork->network.Ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN)) { |
| 212 | u32 p2pielen = 0; |
| 213 | |
| 214 | if (pnetwork->network.Reserved[0] == 2) {/* Probe Request */ |
| 215 | /* Verifying the P2P IE */ |
| 216 | if (rtw_get_p2p_ie(pnetwork->network.IEs, pnetwork->network.IELength, NULL, &p2pielen)) |
| 217 | blnGotP2PIE = true; |
| 218 | } else {/* Beacon or Probe Respones */ |
| 219 | /* Verifying the P2P IE */ |
| 220 | if (rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen)) |
| 221 | blnGotP2PIE = true; |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | if (!blnGotP2PIE) |
| 226 | return start; |
| 227 | } |
| 228 | #endif /* CONFIG_88EU_P2P */ |
| 229 | |
| 230 | /* AP MAC address */ |
| 231 | iwe.cmd = SIOCGIWAP; |
| 232 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; |
| 233 | |
| 234 | memcpy(iwe.u.ap_addr.sa_data, pnetwork->network.MacAddress, ETH_ALEN); |
| 235 | start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN); |
| 236 | |
| 237 | /* Add the ESSID */ |
| 238 | iwe.cmd = SIOCGIWESSID; |
| 239 | iwe.u.data.flags = 1; |
| 240 | iwe.u.data.length = min_t(u16, pnetwork->network.Ssid.SsidLength, 32); |
| 241 | start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid); |
| 242 | |
| 243 | /* parsing HT_CAP_IE */ |
| 244 | p = rtw_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength-12); |
| 245 | |
| 246 | if (p && ht_ielen > 0) { |
| 247 | struct rtw_ieee80211_ht_cap *pht_capie; |
| 248 | ht_cap = true; |
| 249 | pht_capie = (struct rtw_ieee80211_ht_cap *)(p+2); |
| 250 | memcpy(&mcs_rate, pht_capie->supp_mcs_set, 2); |
| 251 | bw_40MHz = (pht_capie->cap_info&IEEE80211_HT_CAP_SUP_WIDTH) ? 1 : 0; |
| 252 | short_GI = (pht_capie->cap_info&(IEEE80211_HT_CAP_SGI_20|IEEE80211_HT_CAP_SGI_40)) ? 1 : 0; |
| 253 | } |
| 254 | |
| 255 | /* Add the protocol name */ |
| 256 | iwe.cmd = SIOCGIWNAME; |
| 257 | if ((rtw_is_cckratesonly_included((u8 *)&pnetwork->network.SupportedRates))) { |
| 258 | if (ht_cap) |
| 259 | snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn"); |
| 260 | else |
| 261 | snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b"); |
| 262 | } else if ((rtw_is_cckrates_included((u8 *)&pnetwork->network.SupportedRates))) { |
| 263 | if (ht_cap) |
| 264 | snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn"); |
| 265 | else |
| 266 | snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg"); |
| 267 | } else { |
| 268 | if (pnetwork->network.Configuration.DSConfig > 14) { |
| 269 | if (ht_cap) |
| 270 | snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11an"); |
| 271 | else |
| 272 | snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11a"); |
| 273 | } else { |
| 274 | if (ht_cap) |
| 275 | snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); |
| 276 | else |
| 277 | snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g"); |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN); |
| 282 | |
| 283 | /* Add mode */ |
| 284 | iwe.cmd = SIOCGIWMODE; |
| 285 | memcpy(&le_tmp, rtw_get_capability_from_ie(pnetwork->network.IEs), 2); |
| 286 | |
| 287 | cap = le16_to_cpu(le_tmp); |
| 288 | |
| 289 | if (cap & (WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_BSS)) { |
| 290 | if (cap & WLAN_CAPABILITY_BSS) |
| 291 | iwe.u.mode = IW_MODE_MASTER; |
| 292 | else |
| 293 | iwe.u.mode = IW_MODE_ADHOC; |
| 294 | |
| 295 | start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN); |
| 296 | } |
| 297 | |
| 298 | if (pnetwork->network.Configuration.DSConfig < 1) |
| 299 | pnetwork->network.Configuration.DSConfig = 1; |
| 300 | |
| 301 | /* Add frequency/channel */ |
| 302 | iwe.cmd = SIOCGIWFREQ; |
| 303 | iwe.u.freq.m = rtw_ch2freq(pnetwork->network.Configuration.DSConfig) * 100000; |
| 304 | iwe.u.freq.e = 1; |
| 305 | iwe.u.freq.i = pnetwork->network.Configuration.DSConfig; |
| 306 | start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN); |
| 307 | |
| 308 | /* Add encryption capability */ |
| 309 | iwe.cmd = SIOCGIWENCODE; |
| 310 | if (cap & WLAN_CAPABILITY_PRIVACY) |
| 311 | iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; |
| 312 | else |
| 313 | iwe.u.data.flags = IW_ENCODE_DISABLED; |
| 314 | iwe.u.data.length = 0; |
| 315 | start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid); |
| 316 | |
| 317 | /*Add basic and extended rates */ |
| 318 | max_rate = 0; |
| 319 | p = custom; |
| 320 | p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); |
| 321 | while (pnetwork->network.SupportedRates[i] != 0) { |
| 322 | rate = pnetwork->network.SupportedRates[i]&0x7F; |
| 323 | if (rate > max_rate) |
| 324 | max_rate = rate; |
| 325 | p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), |
| 326 | "%d%s ", rate >> 1, (rate & 1) ? ".5" : ""); |
| 327 | i++; |
| 328 | } |
| 329 | |
| 330 | if (ht_cap) { |
| 331 | if (mcs_rate&0x8000)/* MCS15 */ |
| 332 | max_rate = (bw_40MHz) ? ((short_GI) ? 300 : 270) : ((short_GI) ? 144 : 130); |
| 333 | else if (mcs_rate&0x0080)/* MCS7 */ |
| 334 | ; |
| 335 | else/* default MCS7 */ |
| 336 | max_rate = (bw_40MHz) ? ((short_GI) ? 150 : 135) : ((short_GI) ? 72 : 65); |
| 337 | |
| 338 | max_rate = max_rate*2;/* Mbps/2; */ |
| 339 | } |
| 340 | |
| 341 | iwe.cmd = SIOCGIWRATE; |
| 342 | iwe.u.bitrate.fixed = 0; |
| 343 | iwe.u.bitrate.disabled = 0; |
| 344 | iwe.u.bitrate.value = max_rate * 500000; |
| 345 | start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_PARAM_LEN); |
| 346 | |
| 347 | /* parsing WPA/WPA2 IE */ |
| 348 | { |
| 349 | u8 buf[MAX_WPA_IE_LEN]; |
| 350 | u8 wpa_ie[255], rsn_ie[255]; |
| 351 | u16 wpa_len = 0, rsn_len = 0; |
| 352 | u8 *p; |
| 353 | |
| 354 | rtw_get_sec_ie(pnetwork->network.IEs, pnetwork->network.IELength, rsn_ie, &rsn_len, wpa_ie, &wpa_len); |
| 355 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: ssid =%s\n", pnetwork->network.Ssid.Ssid)); |
| 356 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); |
| 357 | |
| 358 | if (wpa_len > 0) { |
| 359 | p = buf; |
| 360 | _rtw_memset(buf, 0, MAX_WPA_IE_LEN); |
| 361 | p += sprintf(p, "wpa_ie ="); |
| 362 | for (i = 0; i < wpa_len; i++) |
| 363 | p += sprintf(p, "%02x", wpa_ie[i]); |
| 364 | |
| 365 | _rtw_memset(&iwe, 0, sizeof(iwe)); |
| 366 | iwe.cmd = IWEVCUSTOM; |
| 367 | iwe.u.data.length = strlen(buf); |
| 368 | start = iwe_stream_add_point(info, start, stop, &iwe, buf); |
| 369 | |
| 370 | _rtw_memset(&iwe, 0, sizeof(iwe)); |
| 371 | iwe.cmd = IWEVGENIE; |
| 372 | iwe.u.data.length = wpa_len; |
| 373 | start = iwe_stream_add_point(info, start, stop, &iwe, wpa_ie); |
| 374 | } |
| 375 | if (rsn_len > 0) { |
| 376 | p = buf; |
| 377 | _rtw_memset(buf, 0, MAX_WPA_IE_LEN); |
| 378 | p += sprintf(p, "rsn_ie ="); |
| 379 | for (i = 0; i < rsn_len; i++) |
| 380 | p += sprintf(p, "%02x", rsn_ie[i]); |
| 381 | _rtw_memset(&iwe, 0, sizeof(iwe)); |
| 382 | iwe.cmd = IWEVCUSTOM; |
| 383 | iwe.u.data.length = strlen(buf); |
| 384 | start = iwe_stream_add_point(info, start, stop, &iwe, buf); |
| 385 | |
| 386 | _rtw_memset(&iwe, 0, sizeof(iwe)); |
| 387 | iwe.cmd = IWEVGENIE; |
| 388 | iwe.u.data.length = rsn_len; |
| 389 | start = iwe_stream_add_point(info, start, stop, &iwe, rsn_ie); |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | {/* parsing WPS IE */ |
| 394 | uint cnt = 0, total_ielen; |
| 395 | u8 *wpsie_ptr = NULL; |
| 396 | uint wps_ielen = 0; |
| 397 | |
| 398 | u8 *ie_ptr = pnetwork->network.IEs + _FIXED_IE_LENGTH_; |
| 399 | total_ielen = pnetwork->network.IELength - _FIXED_IE_LENGTH_; |
| 400 | |
| 401 | while (cnt < total_ielen) { |
| 402 | if (rtw_is_wps_ie(&ie_ptr[cnt], &wps_ielen) && (wps_ielen > 2)) { |
| 403 | wpsie_ptr = &ie_ptr[cnt]; |
| 404 | iwe.cmd = IWEVGENIE; |
| 405 | iwe.u.data.length = (u16)wps_ielen; |
| 406 | start = iwe_stream_add_point(info, start, stop, &iwe, wpsie_ptr); |
| 407 | } |
| 408 | cnt += ie_ptr[cnt+1]+2; /* goto next */ |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | /* Add quality statistics */ |
| 413 | iwe.cmd = IWEVQUAL; |
| 414 | iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_INVALID; |
| 415 | |
| 416 | if (check_fwstate(pmlmepriv, _FW_LINKED) == true && |
| 417 | is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network)) { |
| 418 | ss = padapter->recvpriv.signal_strength; |
| 419 | sq = padapter->recvpriv.signal_qual; |
| 420 | } else { |
| 421 | ss = pnetwork->network.PhyInfo.SignalStrength; |
| 422 | sq = pnetwork->network.PhyInfo.SignalQuality; |
| 423 | } |
| 424 | |
| 425 | iwe.u.qual.level = (u8)ss; |
| 426 | iwe.u.qual.qual = (u8)sq; /* signal quality */ |
| 427 | iwe.u.qual.noise = 0; /* noise level */ |
| 428 | start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN); |
| 429 | return start; |
| 430 | } |
| 431 | |
| 432 | static int wpa_set_auth_algs(struct net_device *dev, u32 value) |
| 433 | { |
| 434 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 435 | int ret = 0; |
| 436 | |
| 437 | if ((value & AUTH_ALG_SHARED_KEY) && (value & AUTH_ALG_OPEN_SYSTEM)) { |
| 438 | DBG_88E("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY and AUTH_ALG_OPEN_SYSTEM [value:0x%x]\n", value); |
| 439 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; |
| 440 | padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeAutoSwitch; |
| 441 | padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Auto; |
| 442 | } else if (value & AUTH_ALG_SHARED_KEY) { |
| 443 | DBG_88E("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY [value:0x%x]\n", value); |
| 444 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; |
| 445 | |
| 446 | padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeShared; |
| 447 | padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared; |
| 448 | } else if (value & AUTH_ALG_OPEN_SYSTEM) { |
| 449 | DBG_88E("wpa_set_auth_algs, AUTH_ALG_OPEN_SYSTEM\n"); |
| 450 | if (padapter->securitypriv.ndisauthtype < Ndis802_11AuthModeWPAPSK) { |
| 451 | padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; |
| 452 | padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; |
| 453 | } |
| 454 | } else if (value & AUTH_ALG_LEAP) { |
| 455 | DBG_88E("wpa_set_auth_algs, AUTH_ALG_LEAP\n"); |
| 456 | } else { |
| 457 | DBG_88E("wpa_set_auth_algs, error!\n"); |
| 458 | ret = -EINVAL; |
| 459 | } |
| 460 | return ret; |
| 461 | } |
| 462 | |
| 463 | static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len) |
| 464 | { |
| 465 | int ret = 0; |
| 466 | u32 wep_key_idx, wep_key_len, wep_total_len; |
| 467 | struct ndis_802_11_wep *pwep = NULL; |
| 468 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 469 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 470 | struct security_priv *psecuritypriv = &padapter->securitypriv; |
| 471 | #ifdef CONFIG_88EU_P2P |
| 472 | struct wifidirect_info *pwdinfo = &padapter->wdinfo; |
| 473 | #endif /* CONFIG_88EU_P2P */ |
| 474 | |
| 475 | _func_enter_; |
| 476 | |
| 477 | param->u.crypt.err = 0; |
| 478 | param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; |
| 479 | |
| 480 | if (param_len < (u32) ((u8 *)param->u.crypt.key - (u8 *)param) + param->u.crypt.key_len) { |
| 481 | ret = -EINVAL; |
| 482 | goto exit; |
| 483 | } |
| 484 | |
| 485 | if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && |
| 486 | param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && |
| 487 | param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) { |
| 488 | if (param->u.crypt.idx >= WEP_KEYS) { |
| 489 | ret = -EINVAL; |
| 490 | goto exit; |
| 491 | } |
| 492 | } else { |
| 493 | ret = -EINVAL; |
| 494 | goto exit; |
| 495 | } |
| 496 | |
| 497 | if (strcmp(param->u.crypt.alg, "WEP") == 0) { |
| 498 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("wpa_set_encryption, crypt.alg = WEP\n")); |
| 499 | DBG_88E("wpa_set_encryption, crypt.alg = WEP\n"); |
| 500 | |
| 501 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; |
| 502 | padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; |
| 503 | padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; |
| 504 | |
| 505 | wep_key_idx = param->u.crypt.idx; |
| 506 | wep_key_len = param->u.crypt.key_len; |
| 507 | |
| 508 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("(1)wep_key_idx =%d\n", wep_key_idx)); |
| 509 | DBG_88E("(1)wep_key_idx =%d\n", wep_key_idx); |
| 510 | |
| 511 | if (wep_key_idx > WEP_KEYS) |
| 512 | return -EINVAL; |
| 513 | |
| 514 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("(2)wep_key_idx =%d\n", wep_key_idx)); |
| 515 | |
| 516 | if (wep_key_len > 0) { |
| 517 | wep_key_len = wep_key_len <= 5 ? 5 : 13; |
| 518 | wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); |
| 519 | pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); |
| 520 | if (pwep == NULL) { |
| 521 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n")); |
| 522 | goto exit; |
| 523 | } |
| 524 | _rtw_memset(pwep, 0, wep_total_len); |
| 525 | pwep->KeyLength = wep_key_len; |
| 526 | pwep->Length = wep_total_len; |
| 527 | if (wep_key_len == 13) { |
| 528 | padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; |
| 529 | padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; |
| 530 | } |
| 531 | } else { |
| 532 | ret = -EINVAL; |
| 533 | goto exit; |
| 534 | } |
| 535 | pwep->KeyIndex = wep_key_idx; |
| 536 | pwep->KeyIndex |= 0x80000000; |
| 537 | memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); |
| 538 | if (param->u.crypt.set_tx) { |
| 539 | DBG_88E("wep, set_tx = 1\n"); |
| 540 | if (rtw_set_802_11_add_wep(padapter, pwep) == (u8)_FAIL) |
| 541 | ret = -EOPNOTSUPP; |
| 542 | } else { |
| 543 | DBG_88E("wep, set_tx = 0\n"); |
| 544 | if (wep_key_idx >= WEP_KEYS) { |
| 545 | ret = -EOPNOTSUPP; |
| 546 | goto exit; |
| 547 | } |
| 548 | memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); |
| 549 | psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; |
| 550 | rtw_set_key(padapter, psecuritypriv, wep_key_idx, 0); |
| 551 | } |
| 552 | goto exit; |
| 553 | } |
| 554 | |
| 555 | if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { /* 802_1x */ |
| 556 | struct sta_info *psta, *pbcmc_sta; |
| 557 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 558 | |
| 559 | if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_MP_STATE)) { /* sta mode */ |
| 560 | psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv)); |
| 561 | if (psta == NULL) { |
| 562 | ; |
| 563 | } else { |
| 564 | if (strcmp(param->u.crypt.alg, "none") != 0) |
| 565 | psta->ieee8021x_blocked = false; |
| 566 | |
| 567 | if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled) || |
| 568 | (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) |
| 569 | psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; |
| 570 | |
| 571 | if (param->u.crypt.set_tx == 1) { /* pairwise key */ |
| 572 | memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); |
| 573 | |
| 574 | if (strcmp(param->u.crypt.alg, "TKIP") == 0) { /* set mic key */ |
| 575 | memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8); |
| 576 | memcpy(psta->dot11tkiprxmickey.skey, &(param->u.crypt.key[24]), 8); |
| 577 | padapter->securitypriv.busetkipkey = false; |
| 578 | } |
| 579 | |
| 580 | DBG_88E(" ~~~~set sta key:unicastkey\n"); |
| 581 | |
| 582 | rtw_setstakey_cmd(padapter, (unsigned char *)psta, true); |
| 583 | } else { /* group key */ |
| 584 | memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); |
| 585 | memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); |
| 586 | memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); |
| 587 | padapter->securitypriv.binstallGrpkey = true; |
| 588 | DBG_88E(" ~~~~set sta key:groupkey\n"); |
| 589 | |
| 590 | padapter->securitypriv.dot118021XGrpKeyid = param->u.crypt.idx; |
| 591 | |
| 592 | rtw_set_key(padapter, &padapter->securitypriv, param->u.crypt.idx, 1); |
| 593 | #ifdef CONFIG_88EU_P2P |
| 594 | if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) |
| 595 | rtw_p2p_set_state(pwdinfo, P2P_STATE_PROVISIONING_DONE); |
| 596 | #endif /* CONFIG_88EU_P2P */ |
| 597 | } |
| 598 | } |
| 599 | pbcmc_sta = rtw_get_bcmc_stainfo(padapter); |
| 600 | if (pbcmc_sta == NULL) { |
| 601 | ; |
| 602 | } else { |
| 603 | /* Jeff: don't disable ieee8021x_blocked while clearing key */ |
| 604 | if (strcmp(param->u.crypt.alg, "none") != 0) |
| 605 | pbcmc_sta->ieee8021x_blocked = false; |
| 606 | |
| 607 | if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled) || |
| 608 | (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) |
| 609 | pbcmc_sta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | exit: |
| 615 | |
| 616 | kfree(pwep); |
| 617 | |
| 618 | _func_exit_; |
| 619 | |
| 620 | return ret; |
| 621 | } |
| 622 | |
| 623 | static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ielen) |
| 624 | { |
| 625 | u8 *buf = NULL; |
| 626 | int group_cipher = 0, pairwise_cipher = 0; |
| 627 | int ret = 0; |
| 628 | #ifdef CONFIG_88EU_P2P |
| 629 | struct wifidirect_info *pwdinfo = &padapter->wdinfo; |
| 630 | #endif /* CONFIG_88EU_P2P */ |
| 631 | |
| 632 | if ((ielen > MAX_WPA_IE_LEN) || (pie == NULL)) { |
| 633 | _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); |
| 634 | if (pie == NULL) |
| 635 | return ret; |
| 636 | else |
| 637 | return -EINVAL; |
| 638 | } |
| 639 | |
| 640 | if (ielen) { |
| 641 | buf = rtw_zmalloc(ielen); |
| 642 | if (buf == NULL) { |
| 643 | ret = -ENOMEM; |
| 644 | goto exit; |
| 645 | } |
| 646 | |
| 647 | memcpy(buf, pie, ielen); |
| 648 | |
| 649 | /* dump */ |
| 650 | { |
| 651 | int i; |
| 652 | DBG_88E("\n wpa_ie(length:%d):\n", ielen); |
| 653 | for (i = 0; i < ielen; i += 8) |
| 654 | DBG_88E("0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", buf[i], buf[i+1], buf[i+2], buf[i+3], buf[i+4], buf[i+5], buf[i+6], buf[i+7]); |
| 655 | } |
| 656 | |
| 657 | if (ielen < RSN_HEADER_LEN) { |
| 658 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("Ie len too short %d\n", ielen)); |
| 659 | ret = -1; |
| 660 | goto exit; |
| 661 | } |
| 662 | |
| 663 | if (rtw_parse_wpa_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { |
| 664 | padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; |
| 665 | padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; |
| 666 | memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen); |
| 667 | } |
| 668 | |
| 669 | if (rtw_parse_wpa2_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { |
| 670 | padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; |
| 671 | padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; |
| 672 | memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen); |
| 673 | } |
| 674 | |
| 675 | switch (group_cipher) { |
| 676 | case WPA_CIPHER_NONE: |
| 677 | padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; |
| 678 | padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; |
| 679 | break; |
| 680 | case WPA_CIPHER_WEP40: |
| 681 | padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; |
| 682 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; |
| 683 | break; |
| 684 | case WPA_CIPHER_TKIP: |
| 685 | padapter->securitypriv.dot118021XGrpPrivacy = _TKIP_; |
| 686 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; |
| 687 | break; |
| 688 | case WPA_CIPHER_CCMP: |
| 689 | padapter->securitypriv.dot118021XGrpPrivacy = _AES_; |
| 690 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; |
| 691 | break; |
| 692 | case WPA_CIPHER_WEP104: |
| 693 | padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; |
| 694 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; |
| 695 | break; |
| 696 | } |
| 697 | |
| 698 | switch (pairwise_cipher) { |
| 699 | case WPA_CIPHER_NONE: |
| 700 | padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; |
| 701 | padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; |
| 702 | break; |
| 703 | case WPA_CIPHER_WEP40: |
| 704 | padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; |
| 705 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; |
| 706 | break; |
| 707 | case WPA_CIPHER_TKIP: |
| 708 | padapter->securitypriv.dot11PrivacyAlgrthm = _TKIP_; |
| 709 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; |
| 710 | break; |
| 711 | case WPA_CIPHER_CCMP: |
| 712 | padapter->securitypriv.dot11PrivacyAlgrthm = _AES_; |
| 713 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; |
| 714 | break; |
| 715 | case WPA_CIPHER_WEP104: |
| 716 | padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; |
| 717 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; |
| 718 | break; |
| 719 | } |
| 720 | |
| 721 | _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); |
| 722 | {/* set wps_ie */ |
| 723 | u16 cnt = 0; |
| 724 | u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; |
| 725 | |
| 726 | while (cnt < ielen) { |
| 727 | eid = buf[cnt]; |
| 728 | if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&buf[cnt+2], wps_oui, 4))) { |
| 729 | DBG_88E("SET WPS_IE\n"); |
| 730 | |
| 731 | padapter->securitypriv.wps_ie_len = ((buf[cnt+1]+2) < (MAX_WPA_IE_LEN<<2)) ? (buf[cnt+1]+2) : (MAX_WPA_IE_LEN<<2); |
| 732 | |
| 733 | memcpy(padapter->securitypriv.wps_ie, &buf[cnt], padapter->securitypriv.wps_ie_len); |
| 734 | |
| 735 | set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS); |
| 736 | #ifdef CONFIG_88EU_P2P |
| 737 | if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_OK)) |
| 738 | rtw_p2p_set_state(pwdinfo, P2P_STATE_PROVISIONING_ING); |
| 739 | #endif /* CONFIG_88EU_P2P */ |
| 740 | cnt += buf[cnt+1]+2; |
| 741 | break; |
| 742 | } else { |
| 743 | cnt += buf[cnt+1]+2; /* goto next */ |
| 744 | } |
| 745 | } |
| 746 | } |
| 747 | } |
| 748 | |
| 749 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, |
| 750 | ("rtw_set_wpa_ie: pairwise_cipher = 0x%08x padapter->securitypriv.ndisencryptstatus =%d padapter->securitypriv.ndisauthtype =%d\n", |
| 751 | pairwise_cipher, padapter->securitypriv.ndisencryptstatus, padapter->securitypriv.ndisauthtype)); |
| 752 | exit: |
| 753 | kfree(buf); |
| 754 | return ret; |
| 755 | } |
| 756 | |
| 757 | typedef unsigned char NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX]; |
| 758 | |
| 759 | static int rtw_wx_get_name(struct net_device *dev, |
| 760 | struct iw_request_info *info, |
| 761 | union iwreq_data *wrqu, char *extra) |
| 762 | { |
| 763 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 764 | u32 ht_ielen = 0; |
| 765 | char *p; |
| 766 | u8 ht_cap = false; |
| 767 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 768 | struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; |
| 769 | NDIS_802_11_RATES_EX *prates = NULL; |
| 770 | |
| 771 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("cmd_code =%x\n", info->cmd)); |
| 772 | |
| 773 | _func_enter_; |
| 774 | |
| 775 | if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { |
| 776 | /* parsing HT_CAP_IE */ |
| 777 | p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12); |
| 778 | if (p && ht_ielen > 0) |
| 779 | ht_cap = true; |
| 780 | |
| 781 | prates = &pcur_bss->SupportedRates; |
| 782 | |
| 783 | if (rtw_is_cckratesonly_included((u8 *)prates) == true) { |
| 784 | if (ht_cap) |
| 785 | snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bn"); |
| 786 | else |
| 787 | snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b"); |
| 788 | } else if ((rtw_is_cckrates_included((u8 *)prates)) == true) { |
| 789 | if (ht_cap) |
| 790 | snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bgn"); |
| 791 | else |
| 792 | snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg"); |
| 793 | } else { |
| 794 | if (pcur_bss->Configuration.DSConfig > 14) { |
| 795 | if (ht_cap) |
| 796 | snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11an"); |
| 797 | else |
| 798 | snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11a"); |
| 799 | } else { |
| 800 | if (ht_cap) |
| 801 | snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); |
| 802 | else |
| 803 | snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); |
| 804 | } |
| 805 | } |
| 806 | } else { |
| 807 | snprintf(wrqu->name, IFNAMSIZ, "unassociated"); |
| 808 | } |
| 809 | |
| 810 | _func_exit_; |
| 811 | |
| 812 | return 0; |
| 813 | } |
| 814 | |
| 815 | static int rtw_wx_set_freq(struct net_device *dev, |
| 816 | struct iw_request_info *info, |
| 817 | union iwreq_data *wrqu, char *extra) |
| 818 | { |
| 819 | _func_enter_; |
| 820 | |
| 821 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_wx_set_freq\n")); |
| 822 | |
| 823 | _func_exit_; |
| 824 | |
| 825 | return 0; |
| 826 | } |
| 827 | |
| 828 | static int rtw_wx_get_freq(struct net_device *dev, |
| 829 | struct iw_request_info *info, |
| 830 | union iwreq_data *wrqu, char *extra) |
| 831 | { |
| 832 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 833 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 834 | struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; |
| 835 | |
| 836 | if (check_fwstate(pmlmepriv, _FW_LINKED)) { |
| 837 | /* wrqu->freq.m = ieee80211_wlan_frequencies[pcur_bss->Configuration.DSConfig-1] * 100000; */ |
| 838 | wrqu->freq.m = rtw_ch2freq(pcur_bss->Configuration.DSConfig) * 100000; |
| 839 | wrqu->freq.e = 1; |
| 840 | wrqu->freq.i = pcur_bss->Configuration.DSConfig; |
| 841 | } else { |
| 842 | wrqu->freq.m = rtw_ch2freq(padapter->mlmeextpriv.cur_channel) * 100000; |
| 843 | wrqu->freq.e = 1; |
| 844 | wrqu->freq.i = padapter->mlmeextpriv.cur_channel; |
| 845 | } |
| 846 | |
| 847 | return 0; |
| 848 | } |
| 849 | |
| 850 | static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a, |
| 851 | union iwreq_data *wrqu, char *b) |
| 852 | { |
| 853 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 854 | enum ndis_802_11_network_infra networkType; |
| 855 | int ret = 0; |
| 856 | |
| 857 | _func_enter_; |
| 858 | |
| 859 | if (_FAIL == rtw_pwr_wakeup(padapter)) { |
| 860 | ret = -EPERM; |
| 861 | goto exit; |
| 862 | } |
| 863 | |
| 864 | if (!padapter->hw_init_completed) { |
| 865 | ret = -EPERM; |
| 866 | goto exit; |
| 867 | } |
| 868 | |
| 869 | switch (wrqu->mode) { |
| 870 | case IW_MODE_AUTO: |
| 871 | networkType = Ndis802_11AutoUnknown; |
| 872 | DBG_88E("set_mode = IW_MODE_AUTO\n"); |
| 873 | break; |
| 874 | case IW_MODE_ADHOC: |
| 875 | networkType = Ndis802_11IBSS; |
| 876 | DBG_88E("set_mode = IW_MODE_ADHOC\n"); |
| 877 | break; |
| 878 | case IW_MODE_MASTER: |
| 879 | networkType = Ndis802_11APMode; |
| 880 | DBG_88E("set_mode = IW_MODE_MASTER\n"); |
| 881 | break; |
| 882 | case IW_MODE_INFRA: |
| 883 | networkType = Ndis802_11Infrastructure; |
| 884 | DBG_88E("set_mode = IW_MODE_INFRA\n"); |
| 885 | break; |
| 886 | default: |
| 887 | ret = -EINVAL; |
| 888 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("\n Mode: %s is not supported\n", iw_operation_mode[wrqu->mode])); |
| 889 | goto exit; |
| 890 | } |
| 891 | if (rtw_set_802_11_infrastructure_mode(padapter, networkType) == false) { |
| 892 | ret = -EPERM; |
| 893 | goto exit; |
| 894 | } |
| 895 | rtw_setopmode_cmd(padapter, networkType); |
| 896 | exit: |
| 897 | _func_exit_; |
| 898 | return ret; |
| 899 | } |
| 900 | |
| 901 | static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a, |
| 902 | union iwreq_data *wrqu, char *b) |
| 903 | { |
| 904 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 905 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 906 | |
| 907 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_get_mode\n")); |
| 908 | |
| 909 | _func_enter_; |
| 910 | |
| 911 | if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) |
| 912 | wrqu->mode = IW_MODE_INFRA; |
| 913 | else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || |
| 914 | (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) |
| 915 | wrqu->mode = IW_MODE_ADHOC; |
| 916 | else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) |
| 917 | wrqu->mode = IW_MODE_MASTER; |
| 918 | else |
| 919 | wrqu->mode = IW_MODE_AUTO; |
| 920 | |
| 921 | _func_exit_; |
| 922 | |
| 923 | return 0; |
| 924 | } |
| 925 | |
| 926 | static int rtw_wx_set_pmkid(struct net_device *dev, |
| 927 | struct iw_request_info *a, |
| 928 | union iwreq_data *wrqu, char *extra) |
| 929 | { |
| 930 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 931 | u8 j, blInserted = false; |
| 932 | int ret = false; |
| 933 | struct security_priv *psecuritypriv = &padapter->securitypriv; |
| 934 | struct iw_pmksa *pPMK = (struct iw_pmksa *)extra; |
| 935 | u8 strZeroMacAddress[ETH_ALEN] = {0x00}; |
| 936 | u8 strIssueBssid[ETH_ALEN] = {0x00}; |
| 937 | |
| 938 | memcpy(strIssueBssid, pPMK->bssid.sa_data, ETH_ALEN); |
| 939 | if (pPMK->cmd == IW_PMKSA_ADD) { |
| 940 | DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_ADD!\n"); |
Larry Finger | dc14a62 | 2013-09-04 15:56:02 -0500 | [diff] [blame] | 941 | if (!memcmp(strIssueBssid, strZeroMacAddress, ETH_ALEN)) |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 942 | return ret; |
| 943 | else |
| 944 | ret = true; |
| 945 | blInserted = false; |
| 946 | |
| 947 | /* overwrite PMKID */ |
| 948 | for (j = 0; j < NUM_PMKID_CACHE; j++) { |
| 949 | if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) { |
| 950 | /* BSSID is matched, the same AP => rewrite with new PMKID. */ |
| 951 | DBG_88E("[rtw_wx_set_pmkid] BSSID exists in the PMKList.\n"); |
| 952 | memcpy(psecuritypriv->PMKIDList[j].PMKID, pPMK->pmkid, IW_PMKID_LEN); |
| 953 | psecuritypriv->PMKIDList[j].bUsed = true; |
| 954 | psecuritypriv->PMKIDIndex = j+1; |
| 955 | blInserted = true; |
| 956 | break; |
| 957 | } |
| 958 | } |
| 959 | |
| 960 | if (!blInserted) { |
| 961 | /* Find a new entry */ |
| 962 | DBG_88E("[rtw_wx_set_pmkid] Use the new entry index = %d for this PMKID.\n", |
| 963 | psecuritypriv->PMKIDIndex); |
| 964 | |
| 965 | memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].Bssid, strIssueBssid, ETH_ALEN); |
| 966 | memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].PMKID, pPMK->pmkid, IW_PMKID_LEN); |
| 967 | |
| 968 | psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].bUsed = true; |
| 969 | psecuritypriv->PMKIDIndex++; |
| 970 | if (psecuritypriv->PMKIDIndex == 16) |
| 971 | psecuritypriv->PMKIDIndex = 0; |
| 972 | } |
| 973 | } else if (pPMK->cmd == IW_PMKSA_REMOVE) { |
| 974 | DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_REMOVE!\n"); |
| 975 | ret = true; |
| 976 | for (j = 0; j < NUM_PMKID_CACHE; j++) { |
| 977 | if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) { |
| 978 | /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */ |
| 979 | _rtw_memset(psecuritypriv->PMKIDList[j].Bssid, 0x00, ETH_ALEN); |
| 980 | psecuritypriv->PMKIDList[j].bUsed = false; |
| 981 | break; |
| 982 | } |
| 983 | } |
| 984 | } else if (pPMK->cmd == IW_PMKSA_FLUSH) { |
| 985 | DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n"); |
| 986 | _rtw_memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); |
| 987 | psecuritypriv->PMKIDIndex = 0; |
| 988 | ret = true; |
| 989 | } |
| 990 | return ret; |
| 991 | } |
| 992 | |
| 993 | static int rtw_wx_get_sens(struct net_device *dev, |
| 994 | struct iw_request_info *info, |
| 995 | union iwreq_data *wrqu, char *extra) |
| 996 | { |
| 997 | wrqu->sens.value = 0; |
| 998 | wrqu->sens.fixed = 0; /* no auto select */ |
| 999 | wrqu->sens.disabled = 1; |
| 1000 | return 0; |
| 1001 | } |
| 1002 | |
| 1003 | static int rtw_wx_get_range(struct net_device *dev, |
| 1004 | struct iw_request_info *info, |
| 1005 | union iwreq_data *wrqu, char *extra) |
| 1006 | { |
| 1007 | struct iw_range *range = (struct iw_range *)extra; |
| 1008 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 1009 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 1010 | |
| 1011 | u16 val; |
| 1012 | int i; |
| 1013 | |
| 1014 | _func_enter_; |
| 1015 | |
| 1016 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_range. cmd_code =%x\n", info->cmd)); |
| 1017 | |
| 1018 | wrqu->data.length = sizeof(*range); |
| 1019 | _rtw_memset(range, 0, sizeof(*range)); |
| 1020 | |
| 1021 | /* Let's try to keep this struct in the same order as in |
| 1022 | * linux/include/wireless.h |
| 1023 | */ |
| 1024 | |
| 1025 | /* TODO: See what values we can set, and remove the ones we can't |
| 1026 | * set, or fill them with some default data. |
| 1027 | */ |
| 1028 | |
| 1029 | /* ~5 Mb/s real (802.11b) */ |
| 1030 | range->throughput = 5 * 1000 * 1000; |
| 1031 | |
| 1032 | /* signal level threshold range */ |
| 1033 | |
| 1034 | /* percent values between 0 and 100. */ |
| 1035 | range->max_qual.qual = 100; |
| 1036 | range->max_qual.level = 100; |
| 1037 | range->max_qual.noise = 100; |
| 1038 | range->max_qual.updated = 7; /* Updated all three */ |
| 1039 | |
| 1040 | range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */ |
| 1041 | /* TODO: Find real 'good' to 'bad' threshol value for RSSI */ |
Larry Finger | dc14a62 | 2013-09-04 15:56:02 -0500 | [diff] [blame] | 1042 | range->avg_qual.level = 178; /* -78 dBm */ |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1043 | range->avg_qual.noise = 0; |
| 1044 | range->avg_qual.updated = 7; /* Updated all three */ |
| 1045 | |
| 1046 | range->num_bitrates = RATE_COUNT; |
| 1047 | |
| 1048 | for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) |
| 1049 | range->bitrate[i] = rtw_rates[i]; |
| 1050 | |
| 1051 | range->min_frag = MIN_FRAG_THRESHOLD; |
| 1052 | range->max_frag = MAX_FRAG_THRESHOLD; |
| 1053 | |
| 1054 | range->pm_capa = 0; |
| 1055 | |
| 1056 | range->we_version_compiled = WIRELESS_EXT; |
| 1057 | range->we_version_source = 16; |
| 1058 | |
| 1059 | for (i = 0, val = 0; i < MAX_CHANNEL_NUM; i++) { |
| 1060 | /* Include only legal frequencies for some countries */ |
| 1061 | if (pmlmeext->channel_set[i].ChannelNum != 0) { |
| 1062 | range->freq[val].i = pmlmeext->channel_set[i].ChannelNum; |
| 1063 | range->freq[val].m = rtw_ch2freq(pmlmeext->channel_set[i].ChannelNum) * 100000; |
| 1064 | range->freq[val].e = 1; |
| 1065 | val++; |
| 1066 | } |
| 1067 | |
| 1068 | if (val == IW_MAX_FREQUENCIES) |
| 1069 | break; |
| 1070 | } |
| 1071 | |
| 1072 | range->num_channels = val; |
| 1073 | range->num_frequency = val; |
| 1074 | |
| 1075 | /* The following code will proivde the security capability to network manager. */ |
| 1076 | /* If the driver doesn't provide this capability to network manager, */ |
Masanari Iida | 7efc02c | 2013-09-27 00:11:46 +0900 | [diff] [blame] | 1077 | /* the WPA/WPA2 routers can't be chosen in the network manager. */ |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1078 | |
| 1079 | /* |
| 1080 | #define IW_SCAN_CAPA_NONE 0x00 |
| 1081 | #define IW_SCAN_CAPA_ESSID 0x01 |
| 1082 | #define IW_SCAN_CAPA_BSSID 0x02 |
| 1083 | #define IW_SCAN_CAPA_CHANNEL 0x04 |
| 1084 | #define IW_SCAN_CAPA_MODE 0x08 |
| 1085 | #define IW_SCAN_CAPA_RATE 0x10 |
| 1086 | #define IW_SCAN_CAPA_TYPE 0x20 |
| 1087 | #define IW_SCAN_CAPA_TIME 0x40 |
| 1088 | */ |
| 1089 | |
| 1090 | range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | |
| 1091 | IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; |
| 1092 | |
| 1093 | range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | |
| 1094 | IW_SCAN_CAPA_BSSID | IW_SCAN_CAPA_CHANNEL | |
| 1095 | IW_SCAN_CAPA_MODE | IW_SCAN_CAPA_RATE; |
| 1096 | _func_exit_; |
| 1097 | |
| 1098 | return 0; |
| 1099 | } |
| 1100 | |
| 1101 | /* set bssid flow */ |
| 1102 | /* s1. rtw_set_802_11_infrastructure_mode() */ |
| 1103 | /* s2. rtw_set_802_11_authentication_mode() */ |
| 1104 | /* s3. set_802_11_encryption_mode() */ |
| 1105 | /* s4. rtw_set_802_11_bssid() */ |
| 1106 | static int rtw_wx_set_wap(struct net_device *dev, |
| 1107 | struct iw_request_info *info, |
| 1108 | union iwreq_data *awrq, |
| 1109 | char *extra) |
| 1110 | { |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1111 | uint ret = 0; |
| 1112 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 1113 | struct sockaddr *temp = (struct sockaddr *)awrq; |
| 1114 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 1115 | struct list_head *phead; |
| 1116 | u8 *dst_bssid, *src_bssid; |
| 1117 | struct __queue *queue = &(pmlmepriv->scanned_queue); |
| 1118 | struct wlan_network *pnetwork = NULL; |
| 1119 | enum ndis_802_11_auth_mode authmode; |
| 1120 | |
| 1121 | _func_enter_; |
| 1122 | |
| 1123 | if (_FAIL == rtw_pwr_wakeup(padapter)) { |
| 1124 | ret = -1; |
| 1125 | goto exit; |
| 1126 | } |
| 1127 | |
| 1128 | if (!padapter->bup) { |
| 1129 | ret = -1; |
| 1130 | goto exit; |
| 1131 | } |
| 1132 | |
| 1133 | if (temp->sa_family != ARPHRD_ETHER) { |
| 1134 | ret = -EINVAL; |
| 1135 | goto exit; |
| 1136 | } |
| 1137 | |
| 1138 | authmode = padapter->securitypriv.ndisauthtype; |
Larry Finger | 7057dcb | 2013-12-19 22:38:34 -0600 | [diff] [blame] | 1139 | spin_lock_bh(&queue->lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1140 | phead = get_list_head(queue); |
| 1141 | pmlmepriv->pscanned = get_next(phead); |
| 1142 | |
| 1143 | while (1) { |
| 1144 | if ((rtw_end_of_queue_search(phead, pmlmepriv->pscanned)) == true) |
| 1145 | break; |
| 1146 | |
| 1147 | pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); |
| 1148 | |
| 1149 | pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); |
| 1150 | |
| 1151 | dst_bssid = pnetwork->network.MacAddress; |
| 1152 | |
| 1153 | src_bssid = temp->sa_data; |
| 1154 | |
| 1155 | if ((!memcmp(dst_bssid, src_bssid, ETH_ALEN))) { |
| 1156 | if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) { |
| 1157 | ret = -1; |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 1158 | spin_unlock_bh(&queue->lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1159 | goto exit; |
| 1160 | } |
| 1161 | |
| 1162 | break; |
| 1163 | } |
| 1164 | } |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 1165 | spin_unlock_bh(&queue->lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1166 | |
| 1167 | rtw_set_802_11_authentication_mode(padapter, authmode); |
| 1168 | /* set_802_11_encryption_mode(padapter, padapter->securitypriv.ndisencryptstatus); */ |
| 1169 | if (rtw_set_802_11_bssid(padapter, temp->sa_data) == false) { |
| 1170 | ret = -1; |
| 1171 | goto exit; |
| 1172 | } |
| 1173 | |
| 1174 | exit: |
| 1175 | |
| 1176 | _func_exit_; |
| 1177 | |
| 1178 | return ret; |
| 1179 | } |
| 1180 | |
| 1181 | static int rtw_wx_get_wap(struct net_device *dev, |
| 1182 | struct iw_request_info *info, |
| 1183 | union iwreq_data *wrqu, char *extra) |
| 1184 | { |
| 1185 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 1186 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 1187 | struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; |
| 1188 | |
| 1189 | wrqu->ap_addr.sa_family = ARPHRD_ETHER; |
| 1190 | |
| 1191 | _rtw_memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); |
| 1192 | |
| 1193 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_wap\n")); |
| 1194 | |
| 1195 | _func_enter_; |
| 1196 | |
| 1197 | if (((check_fwstate(pmlmepriv, _FW_LINKED)) == true) || |
| 1198 | ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) || |
| 1199 | ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) |
| 1200 | memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN); |
| 1201 | else |
| 1202 | _rtw_memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); |
| 1203 | |
| 1204 | _func_exit_; |
| 1205 | |
| 1206 | return 0; |
| 1207 | } |
| 1208 | |
| 1209 | static int rtw_wx_set_mlme(struct net_device *dev, |
| 1210 | struct iw_request_info *info, |
| 1211 | union iwreq_data *wrqu, char *extra) |
| 1212 | { |
| 1213 | int ret = 0; |
| 1214 | u16 reason; |
| 1215 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 1216 | struct iw_mlme *mlme = (struct iw_mlme *)extra; |
| 1217 | |
| 1218 | if (mlme == NULL) |
| 1219 | return -1; |
| 1220 | |
| 1221 | DBG_88E("%s\n", __func__); |
| 1222 | |
| 1223 | reason = mlme->reason_code; |
| 1224 | |
| 1225 | DBG_88E("%s, cmd =%d, reason =%d\n", __func__, mlme->cmd, reason); |
| 1226 | |
| 1227 | switch (mlme->cmd) { |
| 1228 | case IW_MLME_DEAUTH: |
| 1229 | if (!rtw_set_802_11_disassociate(padapter)) |
| 1230 | ret = -1; |
| 1231 | break; |
| 1232 | case IW_MLME_DISASSOC: |
| 1233 | if (!rtw_set_802_11_disassociate(padapter)) |
| 1234 | ret = -1; |
| 1235 | break; |
| 1236 | default: |
| 1237 | return -EOPNOTSUPP; |
| 1238 | } |
| 1239 | return ret; |
| 1240 | } |
| 1241 | |
| 1242 | static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, |
| 1243 | union iwreq_data *wrqu, char *extra) |
| 1244 | { |
| 1245 | u8 _status = false; |
| 1246 | int ret = 0; |
| 1247 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 1248 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 1249 | struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1250 | #ifdef CONFIG_88EU_P2P |
| 1251 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 1252 | #endif /* CONFIG_88EU_P2P */ |
| 1253 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_set_scan\n")); |
| 1254 | |
| 1255 | _func_enter_; |
| 1256 | if (padapter->registrypriv.mp_mode == 1) { |
| 1257 | if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { |
| 1258 | ret = -1; |
| 1259 | goto exit; |
| 1260 | } |
| 1261 | } |
| 1262 | if (_FAIL == rtw_pwr_wakeup(padapter)) { |
| 1263 | ret = -1; |
| 1264 | goto exit; |
| 1265 | } |
| 1266 | |
| 1267 | if (padapter->bDriverStopped) { |
| 1268 | DBG_88E("bDriverStopped =%d\n", padapter->bDriverStopped); |
| 1269 | ret = -1; |
| 1270 | goto exit; |
| 1271 | } |
| 1272 | |
| 1273 | if (!padapter->bup) { |
| 1274 | ret = -1; |
| 1275 | goto exit; |
| 1276 | } |
| 1277 | |
| 1278 | if (!padapter->hw_init_completed) { |
| 1279 | ret = -1; |
| 1280 | goto exit; |
| 1281 | } |
| 1282 | |
| 1283 | /* When Busy Traffic, driver do not site survey. So driver return success. */ |
| 1284 | /* wpa_supplicant will not issue SIOCSIWSCAN cmd again after scan timeout. */ |
| 1285 | /* modify by thomas 2011-02-22. */ |
| 1286 | if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { |
| 1287 | indicate_wx_scan_complete_event(padapter); |
| 1288 | goto exit; |
| 1289 | } |
| 1290 | |
| 1291 | if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) { |
| 1292 | indicate_wx_scan_complete_event(padapter); |
| 1293 | goto exit; |
| 1294 | } |
| 1295 | |
| 1296 | /* For the DMP WiFi Display project, the driver won't to scan because */ |
| 1297 | /* the pmlmepriv->scan_interval is always equal to 3. */ |
| 1298 | /* So, the wpa_supplicant won't find out the WPS SoftAP. */ |
| 1299 | |
| 1300 | #ifdef CONFIG_88EU_P2P |
| 1301 | if (pwdinfo->p2p_state != P2P_STATE_NONE) { |
| 1302 | rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); |
| 1303 | rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH); |
| 1304 | rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_FULL); |
| 1305 | rtw_free_network_queue(padapter, true); |
| 1306 | } |
| 1307 | #endif /* CONFIG_88EU_P2P */ |
| 1308 | |
| 1309 | _rtw_memset(ssid, 0, sizeof(struct ndis_802_11_ssid)*RTW_SSID_SCAN_AMOUNT); |
| 1310 | |
| 1311 | if (wrqu->data.length == sizeof(struct iw_scan_req)) { |
| 1312 | struct iw_scan_req *req = (struct iw_scan_req *)extra; |
| 1313 | |
| 1314 | if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { |
| 1315 | int len = min((int)req->essid_len, IW_ESSID_MAX_SIZE); |
| 1316 | |
| 1317 | memcpy(ssid[0].Ssid, req->essid, len); |
| 1318 | ssid[0].SsidLength = len; |
| 1319 | |
| 1320 | DBG_88E("IW_SCAN_THIS_ESSID, ssid =%s, len =%d\n", req->essid, req->essid_len); |
| 1321 | |
Larry Finger | 7057dcb | 2013-12-19 22:38:34 -0600 | [diff] [blame] | 1322 | spin_lock_bh(&pmlmepriv->lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1323 | |
| 1324 | _status = rtw_sitesurvey_cmd(padapter, ssid, 1, NULL, 0); |
| 1325 | |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 1326 | spin_unlock_bh(&pmlmepriv->lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1327 | } else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) { |
| 1328 | DBG_88E("rtw_wx_set_scan, req->scan_type == IW_SCAN_TYPE_PASSIVE\n"); |
| 1329 | } |
| 1330 | } else { |
| 1331 | if (wrqu->data.length >= WEXT_CSCAN_HEADER_SIZE && |
| 1332 | !memcmp(extra, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { |
| 1333 | int len = wrqu->data.length - WEXT_CSCAN_HEADER_SIZE; |
| 1334 | char *pos = extra+WEXT_CSCAN_HEADER_SIZE; |
| 1335 | char section; |
| 1336 | char sec_len; |
| 1337 | int ssid_index = 0; |
| 1338 | |
| 1339 | while (len >= 1) { |
| 1340 | section = *(pos++); |
| 1341 | len -= 1; |
| 1342 | |
| 1343 | switch (section) { |
| 1344 | case WEXT_CSCAN_SSID_SECTION: |
| 1345 | if (len < 1) { |
| 1346 | len = 0; |
| 1347 | break; |
| 1348 | } |
| 1349 | sec_len = *(pos++); len -= 1; |
| 1350 | if (sec_len > 0 && sec_len <= len) { |
| 1351 | ssid[ssid_index].SsidLength = sec_len; |
| 1352 | memcpy(ssid[ssid_index].Ssid, pos, ssid[ssid_index].SsidLength); |
| 1353 | ssid_index++; |
| 1354 | } |
| 1355 | pos += sec_len; |
| 1356 | len -= sec_len; |
| 1357 | break; |
| 1358 | case WEXT_CSCAN_TYPE_SECTION: |
| 1359 | case WEXT_CSCAN_CHANNEL_SECTION: |
| 1360 | pos += 1; |
| 1361 | len -= 1; |
| 1362 | break; |
| 1363 | case WEXT_CSCAN_PASV_DWELL_SECTION: |
| 1364 | case WEXT_CSCAN_HOME_DWELL_SECTION: |
| 1365 | case WEXT_CSCAN_ACTV_DWELL_SECTION: |
| 1366 | pos += 2; |
| 1367 | len -= 2; |
| 1368 | break; |
| 1369 | default: |
| 1370 | len = 0; /* stop parsing */ |
| 1371 | } |
| 1372 | } |
| 1373 | |
Masanari Iida | 7efc02c | 2013-09-27 00:11:46 +0900 | [diff] [blame] | 1374 | /* it has still some scan parameter to parse, we only do this now... */ |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1375 | _status = rtw_set_802_11_bssid_list_scan(padapter, ssid, RTW_SSID_SCAN_AMOUNT); |
| 1376 | } else { |
| 1377 | _status = rtw_set_802_11_bssid_list_scan(padapter, NULL, 0); |
| 1378 | } |
| 1379 | } |
| 1380 | |
| 1381 | if (!_status) |
| 1382 | ret = -1; |
| 1383 | |
| 1384 | exit: |
| 1385 | |
| 1386 | _func_exit_; |
| 1387 | return ret; |
| 1388 | } |
| 1389 | |
| 1390 | static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, |
| 1391 | union iwreq_data *wrqu, char *extra) |
| 1392 | { |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1393 | struct list_head *plist, *phead; |
| 1394 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 1395 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 1396 | struct __queue *queue = &(pmlmepriv->scanned_queue); |
| 1397 | struct wlan_network *pnetwork = NULL; |
| 1398 | char *ev = extra; |
| 1399 | char *stop = ev + wrqu->data.length; |
| 1400 | u32 ret = 0; |
| 1401 | u32 cnt = 0; |
| 1402 | u32 wait_for_surveydone; |
| 1403 | int wait_status; |
| 1404 | #ifdef CONFIG_88EU_P2P |
| 1405 | struct wifidirect_info *pwdinfo = &padapter->wdinfo; |
| 1406 | #endif /* CONFIG_88EU_P2P */ |
| 1407 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan\n")); |
| 1408 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, (" Start of Query SIOCGIWSCAN .\n")); |
| 1409 | |
| 1410 | _func_enter_; |
| 1411 | |
| 1412 | if (padapter->pwrctrlpriv.brfoffbyhw && padapter->bDriverStopped) { |
| 1413 | ret = -EINVAL; |
| 1414 | goto exit; |
| 1415 | } |
| 1416 | |
| 1417 | #ifdef CONFIG_88EU_P2P |
| 1418 | if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { |
| 1419 | /* P2P is enabled */ |
| 1420 | wait_for_surveydone = 200; |
| 1421 | } else { |
| 1422 | /* P2P is disabled */ |
| 1423 | wait_for_surveydone = 100; |
| 1424 | } |
| 1425 | #else |
| 1426 | { |
| 1427 | wait_for_surveydone = 100; |
| 1428 | } |
| 1429 | #endif /* CONFIG_88EU_P2P */ |
| 1430 | |
| 1431 | wait_status = _FW_UNDER_SURVEY | _FW_UNDER_LINKING; |
| 1432 | |
| 1433 | while (check_fwstate(pmlmepriv, wait_status)) { |
Larry Finger | 0da46e6 | 2013-12-19 22:38:41 -0600 | [diff] [blame] | 1434 | msleep(30); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1435 | cnt++; |
| 1436 | if (cnt > wait_for_surveydone) |
| 1437 | break; |
| 1438 | } |
| 1439 | |
Larry Finger | 7057dcb | 2013-12-19 22:38:34 -0600 | [diff] [blame] | 1440 | spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1441 | |
| 1442 | phead = get_list_head(queue); |
| 1443 | plist = get_next(phead); |
| 1444 | |
| 1445 | while (1) { |
| 1446 | if (rtw_end_of_queue_search(phead, plist)) |
| 1447 | break; |
| 1448 | |
| 1449 | if ((stop - ev) < SCAN_ITEM_SIZE) { |
| 1450 | ret = -E2BIG; |
| 1451 | break; |
| 1452 | } |
| 1453 | |
| 1454 | pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); |
| 1455 | |
| 1456 | /* report network only if the current channel set contains the channel to which this network belongs */ |
| 1457 | if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0) |
| 1458 | ev = translate_scan(padapter, a, pnetwork, ev, stop); |
| 1459 | |
| 1460 | plist = get_next(plist); |
| 1461 | } |
| 1462 | |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 1463 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1464 | |
| 1465 | wrqu->data.length = ev-extra; |
| 1466 | wrqu->data.flags = 0; |
| 1467 | |
| 1468 | exit: |
| 1469 | _func_exit_; |
| 1470 | return ret; |
| 1471 | } |
| 1472 | |
| 1473 | /* set ssid flow */ |
| 1474 | /* s1. rtw_set_802_11_infrastructure_mode() */ |
| 1475 | /* s2. set_802_11_authenticaion_mode() */ |
| 1476 | /* s3. set_802_11_encryption_mode() */ |
| 1477 | /* s4. rtw_set_802_11_ssid() */ |
| 1478 | static int rtw_wx_set_essid(struct net_device *dev, |
| 1479 | struct iw_request_info *a, |
| 1480 | union iwreq_data *wrqu, char *extra) |
| 1481 | { |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1482 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 1483 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 1484 | struct __queue *queue = &pmlmepriv->scanned_queue; |
| 1485 | struct list_head *phead; |
| 1486 | struct wlan_network *pnetwork = NULL; |
| 1487 | enum ndis_802_11_auth_mode authmode; |
| 1488 | struct ndis_802_11_ssid ndis_ssid; |
| 1489 | u8 *dst_ssid, *src_ssid; |
| 1490 | |
| 1491 | uint ret = 0, len; |
| 1492 | |
| 1493 | _func_enter_; |
| 1494 | |
| 1495 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, |
| 1496 | ("+rtw_wx_set_essid: fw_state = 0x%08x\n", get_fwstate(pmlmepriv))); |
| 1497 | if (_FAIL == rtw_pwr_wakeup(padapter)) { |
| 1498 | ret = -1; |
| 1499 | goto exit; |
| 1500 | } |
| 1501 | |
| 1502 | if (!padapter->bup) { |
| 1503 | ret = -1; |
| 1504 | goto exit; |
| 1505 | } |
| 1506 | |
| 1507 | if (wrqu->essid.length > IW_ESSID_MAX_SIZE) { |
| 1508 | ret = -E2BIG; |
| 1509 | goto exit; |
| 1510 | } |
| 1511 | |
| 1512 | if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { |
| 1513 | ret = -1; |
| 1514 | goto exit; |
| 1515 | } |
| 1516 | |
| 1517 | authmode = padapter->securitypriv.ndisauthtype; |
| 1518 | DBG_88E("=>%s\n", __func__); |
| 1519 | if (wrqu->essid.flags && wrqu->essid.length) { |
| 1520 | len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE; |
| 1521 | |
| 1522 | if (wrqu->essid.length != 33) |
| 1523 | DBG_88E("ssid =%s, len =%d\n", extra, wrqu->essid.length); |
| 1524 | |
| 1525 | _rtw_memset(&ndis_ssid, 0, sizeof(struct ndis_802_11_ssid)); |
| 1526 | ndis_ssid.SsidLength = len; |
| 1527 | memcpy(ndis_ssid.Ssid, extra, len); |
| 1528 | src_ssid = ndis_ssid.Ssid; |
| 1529 | |
| 1530 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("rtw_wx_set_essid: ssid =[%s]\n", src_ssid)); |
Larry Finger | 7057dcb | 2013-12-19 22:38:34 -0600 | [diff] [blame] | 1531 | spin_lock_bh(&queue->lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1532 | phead = get_list_head(queue); |
| 1533 | pmlmepriv->pscanned = get_next(phead); |
| 1534 | |
| 1535 | while (1) { |
| 1536 | if (rtw_end_of_queue_search(phead, pmlmepriv->pscanned) == true) { |
| 1537 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_warning_, |
| 1538 | ("rtw_wx_set_essid: scan_q is empty, set ssid to check if scanning again!\n")); |
| 1539 | |
| 1540 | break; |
| 1541 | } |
| 1542 | |
| 1543 | pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); |
| 1544 | |
| 1545 | pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); |
| 1546 | |
| 1547 | dst_ssid = pnetwork->network.Ssid.Ssid; |
| 1548 | |
| 1549 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, |
| 1550 | ("rtw_wx_set_essid: dst_ssid =%s\n", |
| 1551 | pnetwork->network.Ssid.Ssid)); |
| 1552 | |
| 1553 | if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength)) && |
| 1554 | (pnetwork->network.Ssid.SsidLength == ndis_ssid.SsidLength)) { |
| 1555 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, |
| 1556 | ("rtw_wx_set_essid: find match, set infra mode\n")); |
| 1557 | |
| 1558 | if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { |
| 1559 | if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) |
| 1560 | continue; |
| 1561 | } |
| 1562 | |
| 1563 | if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) { |
| 1564 | ret = -1; |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 1565 | spin_unlock_bh(&queue->lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1566 | goto exit; |
| 1567 | } |
| 1568 | |
| 1569 | break; |
| 1570 | } |
| 1571 | } |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 1572 | spin_unlock_bh(&queue->lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 1573 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, |
| 1574 | ("set ssid: set_802_11_auth. mode =%d\n", authmode)); |
| 1575 | rtw_set_802_11_authentication_mode(padapter, authmode); |
| 1576 | if (rtw_set_802_11_ssid(padapter, &ndis_ssid) == false) { |
| 1577 | ret = -1; |
| 1578 | goto exit; |
| 1579 | } |
| 1580 | } |
| 1581 | |
| 1582 | exit: |
| 1583 | |
| 1584 | DBG_88E("<=%s, ret %d\n", __func__, ret); |
| 1585 | |
| 1586 | _func_exit_; |
| 1587 | |
| 1588 | return ret; |
| 1589 | } |
| 1590 | |
| 1591 | static int rtw_wx_get_essid(struct net_device *dev, |
| 1592 | struct iw_request_info *a, |
| 1593 | union iwreq_data *wrqu, char *extra) |
| 1594 | { |
| 1595 | u32 len, ret = 0; |
| 1596 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 1597 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 1598 | struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; |
| 1599 | |
| 1600 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_essid\n")); |
| 1601 | |
| 1602 | _func_enter_; |
| 1603 | |
| 1604 | if ((check_fwstate(pmlmepriv, _FW_LINKED)) || |
| 1605 | (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) { |
| 1606 | len = pcur_bss->Ssid.SsidLength; |
| 1607 | |
| 1608 | wrqu->essid.length = len; |
| 1609 | |
| 1610 | memcpy(extra, pcur_bss->Ssid.Ssid, len); |
| 1611 | |
| 1612 | wrqu->essid.flags = 1; |
| 1613 | } else { |
| 1614 | ret = -1; |
| 1615 | goto exit; |
| 1616 | } |
| 1617 | |
| 1618 | exit: |
| 1619 | |
| 1620 | _func_exit_; |
| 1621 | |
| 1622 | return ret; |
| 1623 | } |
| 1624 | |
| 1625 | static int rtw_wx_set_rate(struct net_device *dev, |
| 1626 | struct iw_request_info *a, |
| 1627 | union iwreq_data *wrqu, char *extra) |
| 1628 | { |
| 1629 | int i, ret = 0; |
| 1630 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 1631 | u8 datarates[NumRates]; |
| 1632 | u32 target_rate = wrqu->bitrate.value; |
| 1633 | u32 fixed = wrqu->bitrate.fixed; |
| 1634 | u32 ratevalue = 0; |
| 1635 | u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff}; |
| 1636 | |
| 1637 | _func_enter_; |
| 1638 | |
| 1639 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_set_rate\n")); |
| 1640 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("target_rate = %d, fixed = %d\n", target_rate, fixed)); |
| 1641 | |
| 1642 | if (target_rate == -1) { |
| 1643 | ratevalue = 11; |
| 1644 | goto set_rate; |
| 1645 | } |
| 1646 | target_rate = target_rate/100000; |
| 1647 | |
| 1648 | switch (target_rate) { |
| 1649 | case 10: |
| 1650 | ratevalue = 0; |
| 1651 | break; |
| 1652 | case 20: |
| 1653 | ratevalue = 1; |
| 1654 | break; |
| 1655 | case 55: |
| 1656 | ratevalue = 2; |
| 1657 | break; |
| 1658 | case 60: |
| 1659 | ratevalue = 3; |
| 1660 | break; |
| 1661 | case 90: |
| 1662 | ratevalue = 4; |
| 1663 | break; |
| 1664 | case 110: |
| 1665 | ratevalue = 5; |
| 1666 | break; |
| 1667 | case 120: |
| 1668 | ratevalue = 6; |
| 1669 | break; |
| 1670 | case 180: |
| 1671 | ratevalue = 7; |
| 1672 | break; |
| 1673 | case 240: |
| 1674 | ratevalue = 8; |
| 1675 | break; |
| 1676 | case 360: |
| 1677 | ratevalue = 9; |
| 1678 | break; |
| 1679 | case 480: |
| 1680 | ratevalue = 10; |
| 1681 | break; |
| 1682 | case 540: |
| 1683 | ratevalue = 11; |
| 1684 | break; |
| 1685 | default: |
| 1686 | ratevalue = 11; |
| 1687 | break; |
| 1688 | } |
| 1689 | |
| 1690 | set_rate: |
| 1691 | |
| 1692 | for (i = 0; i < NumRates; i++) { |
| 1693 | if (ratevalue == mpdatarate[i]) { |
| 1694 | datarates[i] = mpdatarate[i]; |
| 1695 | if (fixed == 0) |
| 1696 | break; |
| 1697 | } else { |
| 1698 | datarates[i] = 0xff; |
| 1699 | } |
| 1700 | |
| 1701 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("datarate_inx =%d\n", datarates[i])); |
| 1702 | } |
| 1703 | |
| 1704 | if (rtw_setdatarate_cmd(padapter, datarates) != _SUCCESS) { |
| 1705 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("rtw_wx_set_rate Fail!!!\n")); |
| 1706 | ret = -1; |
| 1707 | } |
| 1708 | |
| 1709 | _func_exit_; |
| 1710 | |
| 1711 | return ret; |
| 1712 | } |
| 1713 | |
| 1714 | static int rtw_wx_get_rate(struct net_device *dev, |
| 1715 | struct iw_request_info *info, |
| 1716 | union iwreq_data *wrqu, char *extra) |
| 1717 | { |
| 1718 | u16 max_rate = 0; |
| 1719 | |
| 1720 | max_rate = rtw_get_cur_max_rate((struct adapter *)rtw_netdev_priv(dev)); |
| 1721 | |
| 1722 | if (max_rate == 0) |
| 1723 | return -EPERM; |
| 1724 | |
| 1725 | wrqu->bitrate.fixed = 0; /* no auto select */ |
| 1726 | wrqu->bitrate.value = max_rate * 100000; |
| 1727 | |
| 1728 | return 0; |
| 1729 | } |
| 1730 | |
| 1731 | static int rtw_wx_set_rts(struct net_device *dev, |
| 1732 | struct iw_request_info *info, |
| 1733 | union iwreq_data *wrqu, char *extra) |
| 1734 | { |
| 1735 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 1736 | |
| 1737 | _func_enter_; |
| 1738 | |
| 1739 | if (wrqu->rts.disabled) { |
| 1740 | padapter->registrypriv.rts_thresh = 2347; |
| 1741 | } else { |
| 1742 | if (wrqu->rts.value < 0 || |
| 1743 | wrqu->rts.value > 2347) |
| 1744 | return -EINVAL; |
| 1745 | |
| 1746 | padapter->registrypriv.rts_thresh = wrqu->rts.value; |
| 1747 | } |
| 1748 | |
| 1749 | DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh); |
| 1750 | |
| 1751 | _func_exit_; |
| 1752 | |
| 1753 | return 0; |
| 1754 | } |
| 1755 | |
| 1756 | static int rtw_wx_get_rts(struct net_device *dev, |
| 1757 | struct iw_request_info *info, |
| 1758 | union iwreq_data *wrqu, char *extra) |
| 1759 | { |
| 1760 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 1761 | |
| 1762 | _func_enter_; |
| 1763 | |
| 1764 | DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh); |
| 1765 | |
| 1766 | wrqu->rts.value = padapter->registrypriv.rts_thresh; |
| 1767 | wrqu->rts.fixed = 0; /* no auto select */ |
| 1768 | /* wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); */ |
| 1769 | |
| 1770 | _func_exit_; |
| 1771 | |
| 1772 | return 0; |
| 1773 | } |
| 1774 | |
| 1775 | static int rtw_wx_set_frag(struct net_device *dev, |
| 1776 | struct iw_request_info *info, |
| 1777 | union iwreq_data *wrqu, char *extra) |
| 1778 | { |
| 1779 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 1780 | |
| 1781 | _func_enter_; |
| 1782 | |
| 1783 | if (wrqu->frag.disabled) { |
| 1784 | padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD; |
| 1785 | } else { |
| 1786 | if (wrqu->frag.value < MIN_FRAG_THRESHOLD || |
| 1787 | wrqu->frag.value > MAX_FRAG_THRESHOLD) |
| 1788 | return -EINVAL; |
| 1789 | |
| 1790 | padapter->xmitpriv.frag_len = wrqu->frag.value & ~0x1; |
| 1791 | } |
| 1792 | |
| 1793 | DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); |
| 1794 | |
| 1795 | _func_exit_; |
| 1796 | |
| 1797 | return 0; |
| 1798 | } |
| 1799 | |
| 1800 | static int rtw_wx_get_frag(struct net_device *dev, |
| 1801 | struct iw_request_info *info, |
| 1802 | union iwreq_data *wrqu, char *extra) |
| 1803 | { |
| 1804 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 1805 | |
| 1806 | _func_enter_; |
| 1807 | |
| 1808 | DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); |
| 1809 | |
| 1810 | wrqu->frag.value = padapter->xmitpriv.frag_len; |
| 1811 | wrqu->frag.fixed = 0; /* no auto select */ |
| 1812 | |
| 1813 | _func_exit_; |
| 1814 | |
| 1815 | return 0; |
| 1816 | } |
| 1817 | |
| 1818 | static int rtw_wx_get_retry(struct net_device *dev, |
| 1819 | struct iw_request_info *info, |
| 1820 | union iwreq_data *wrqu, char *extra) |
| 1821 | { |
| 1822 | wrqu->retry.value = 7; |
| 1823 | wrqu->retry.fixed = 0; /* no auto select */ |
| 1824 | wrqu->retry.disabled = 1; |
| 1825 | |
| 1826 | return 0; |
| 1827 | } |
| 1828 | |
| 1829 | static int rtw_wx_set_enc(struct net_device *dev, |
| 1830 | struct iw_request_info *info, |
| 1831 | union iwreq_data *wrqu, char *keybuf) |
| 1832 | { |
| 1833 | u32 key, ret = 0; |
| 1834 | u32 keyindex_provided; |
| 1835 | struct ndis_802_11_wep wep; |
| 1836 | enum ndis_802_11_auth_mode authmode; |
| 1837 | |
| 1838 | struct iw_point *erq = &(wrqu->encoding); |
| 1839 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 1840 | struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; |
| 1841 | DBG_88E("+rtw_wx_set_enc, flags = 0x%x\n", erq->flags); |
| 1842 | |
| 1843 | _rtw_memset(&wep, 0, sizeof(struct ndis_802_11_wep)); |
| 1844 | |
| 1845 | key = erq->flags & IW_ENCODE_INDEX; |
| 1846 | |
| 1847 | _func_enter_; |
| 1848 | |
| 1849 | if (erq->flags & IW_ENCODE_DISABLED) { |
| 1850 | DBG_88E("EncryptionDisabled\n"); |
| 1851 | padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; |
| 1852 | padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; |
| 1853 | padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; |
| 1854 | padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ |
| 1855 | authmode = Ndis802_11AuthModeOpen; |
| 1856 | padapter->securitypriv.ndisauthtype = authmode; |
| 1857 | |
| 1858 | goto exit; |
| 1859 | } |
| 1860 | |
| 1861 | if (key) { |
| 1862 | if (key > WEP_KEYS) |
| 1863 | return -EINVAL; |
| 1864 | key--; |
| 1865 | keyindex_provided = 1; |
| 1866 | } else { |
| 1867 | keyindex_provided = 0; |
| 1868 | key = padapter->securitypriv.dot11PrivacyKeyIndex; |
| 1869 | DBG_88E("rtw_wx_set_enc, key =%d\n", key); |
| 1870 | } |
| 1871 | |
| 1872 | /* set authentication mode */ |
| 1873 | if (erq->flags & IW_ENCODE_OPEN) { |
| 1874 | DBG_88E("rtw_wx_set_enc():IW_ENCODE_OPEN\n"); |
| 1875 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */ |
| 1876 | padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; |
| 1877 | padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; |
| 1878 | padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; |
| 1879 | authmode = Ndis802_11AuthModeOpen; |
| 1880 | padapter->securitypriv.ndisauthtype = authmode; |
| 1881 | } else if (erq->flags & IW_ENCODE_RESTRICTED) { |
| 1882 | DBG_88E("rtw_wx_set_enc():IW_ENCODE_RESTRICTED\n"); |
| 1883 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; |
| 1884 | padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared; |
| 1885 | padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; |
| 1886 | padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; |
| 1887 | authmode = Ndis802_11AuthModeShared; |
| 1888 | padapter->securitypriv.ndisauthtype = authmode; |
| 1889 | } else { |
| 1890 | DBG_88E("rtw_wx_set_enc():erq->flags = 0x%x\n", erq->flags); |
| 1891 | |
| 1892 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */ |
| 1893 | padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ |
| 1894 | padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; |
| 1895 | padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; |
| 1896 | authmode = Ndis802_11AuthModeOpen; |
| 1897 | padapter->securitypriv.ndisauthtype = authmode; |
| 1898 | } |
| 1899 | |
| 1900 | wep.KeyIndex = key; |
| 1901 | if (erq->length > 0) { |
| 1902 | wep.KeyLength = erq->length <= 5 ? 5 : 13; |
| 1903 | |
| 1904 | wep.Length = wep.KeyLength + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); |
| 1905 | } else { |
| 1906 | wep.KeyLength = 0; |
| 1907 | |
| 1908 | if (keyindex_provided == 1) { |
| 1909 | /* set key_id only, no given KeyMaterial(erq->length == 0). */ |
| 1910 | padapter->securitypriv.dot11PrivacyKeyIndex = key; |
| 1911 | |
| 1912 | DBG_88E("(keyindex_provided == 1), keyid =%d, key_len =%d\n", key, padapter->securitypriv.dot11DefKeylen[key]); |
| 1913 | |
| 1914 | switch (padapter->securitypriv.dot11DefKeylen[key]) { |
| 1915 | case 5: |
| 1916 | padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; |
| 1917 | break; |
| 1918 | case 13: |
| 1919 | padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; |
| 1920 | break; |
| 1921 | default: |
| 1922 | padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; |
| 1923 | break; |
| 1924 | } |
| 1925 | |
| 1926 | goto exit; |
| 1927 | } |
| 1928 | } |
| 1929 | |
| 1930 | wep.KeyIndex |= 0x80000000; |
| 1931 | |
| 1932 | memcpy(wep.KeyMaterial, keybuf, wep.KeyLength); |
| 1933 | |
| 1934 | if (rtw_set_802_11_add_wep(padapter, &wep) == false) { |
| 1935 | if (rf_on == pwrpriv->rf_pwrstate) |
| 1936 | ret = -EOPNOTSUPP; |
| 1937 | goto exit; |
| 1938 | } |
| 1939 | |
| 1940 | exit: |
| 1941 | |
| 1942 | _func_exit_; |
| 1943 | |
| 1944 | return ret; |
| 1945 | } |
| 1946 | |
| 1947 | static int rtw_wx_get_enc(struct net_device *dev, |
| 1948 | struct iw_request_info *info, |
| 1949 | union iwreq_data *wrqu, char *keybuf) |
| 1950 | { |
| 1951 | uint key, ret = 0; |
| 1952 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 1953 | struct iw_point *erq = &(wrqu->encoding); |
| 1954 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 1955 | |
| 1956 | _func_enter_; |
| 1957 | |
| 1958 | if (check_fwstate(pmlmepriv, _FW_LINKED) != true) { |
| 1959 | if (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { |
| 1960 | erq->length = 0; |
| 1961 | erq->flags |= IW_ENCODE_DISABLED; |
| 1962 | return 0; |
| 1963 | } |
| 1964 | } |
| 1965 | |
| 1966 | key = erq->flags & IW_ENCODE_INDEX; |
| 1967 | |
| 1968 | if (key) { |
| 1969 | if (key > WEP_KEYS) |
| 1970 | return -EINVAL; |
| 1971 | key--; |
| 1972 | } else { |
| 1973 | key = padapter->securitypriv.dot11PrivacyKeyIndex; |
| 1974 | } |
| 1975 | |
| 1976 | erq->flags = key + 1; |
| 1977 | |
| 1978 | switch (padapter->securitypriv.ndisencryptstatus) { |
| 1979 | case Ndis802_11EncryptionNotSupported: |
| 1980 | case Ndis802_11EncryptionDisabled: |
| 1981 | erq->length = 0; |
| 1982 | erq->flags |= IW_ENCODE_DISABLED; |
| 1983 | break; |
| 1984 | case Ndis802_11Encryption1Enabled: |
| 1985 | erq->length = padapter->securitypriv.dot11DefKeylen[key]; |
| 1986 | if (erq->length) { |
| 1987 | memcpy(keybuf, padapter->securitypriv.dot11DefKey[key].skey, padapter->securitypriv.dot11DefKeylen[key]); |
| 1988 | |
| 1989 | erq->flags |= IW_ENCODE_ENABLED; |
| 1990 | |
| 1991 | if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeOpen) |
| 1992 | erq->flags |= IW_ENCODE_OPEN; |
| 1993 | else if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeShared) |
| 1994 | erq->flags |= IW_ENCODE_RESTRICTED; |
| 1995 | } else { |
| 1996 | erq->length = 0; |
| 1997 | erq->flags |= IW_ENCODE_DISABLED; |
| 1998 | } |
| 1999 | break; |
| 2000 | case Ndis802_11Encryption2Enabled: |
| 2001 | case Ndis802_11Encryption3Enabled: |
| 2002 | erq->length = 16; |
| 2003 | erq->flags |= (IW_ENCODE_ENABLED | IW_ENCODE_OPEN | IW_ENCODE_NOKEY); |
| 2004 | break; |
| 2005 | default: |
| 2006 | erq->length = 0; |
| 2007 | erq->flags |= IW_ENCODE_DISABLED; |
| 2008 | break; |
| 2009 | } |
| 2010 | _func_exit_; |
| 2011 | |
| 2012 | return ret; |
| 2013 | } |
| 2014 | |
| 2015 | static int rtw_wx_get_power(struct net_device *dev, |
| 2016 | struct iw_request_info *info, |
| 2017 | union iwreq_data *wrqu, char *extra) |
| 2018 | { |
| 2019 | wrqu->power.value = 0; |
| 2020 | wrqu->power.fixed = 0; /* no auto select */ |
| 2021 | wrqu->power.disabled = 1; |
| 2022 | |
| 2023 | return 0; |
| 2024 | } |
| 2025 | |
| 2026 | static int rtw_wx_set_gen_ie(struct net_device *dev, |
| 2027 | struct iw_request_info *info, |
| 2028 | union iwreq_data *wrqu, char *extra) |
| 2029 | { |
| 2030 | int ret; |
| 2031 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2032 | |
| 2033 | ret = rtw_set_wpa_ie(padapter, extra, wrqu->data.length); |
| 2034 | return ret; |
| 2035 | } |
| 2036 | |
| 2037 | static int rtw_wx_set_auth(struct net_device *dev, |
| 2038 | struct iw_request_info *info, |
| 2039 | union iwreq_data *wrqu, char *extra) |
| 2040 | { |
| 2041 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2042 | struct iw_param *param = (struct iw_param *)&(wrqu->param); |
| 2043 | int ret = 0; |
| 2044 | |
| 2045 | switch (param->flags & IW_AUTH_INDEX) { |
| 2046 | case IW_AUTH_WPA_VERSION: |
| 2047 | break; |
| 2048 | case IW_AUTH_CIPHER_PAIRWISE: |
| 2049 | |
| 2050 | break; |
| 2051 | case IW_AUTH_CIPHER_GROUP: |
| 2052 | |
| 2053 | break; |
| 2054 | case IW_AUTH_KEY_MGMT: |
| 2055 | /* |
| 2056 | * ??? does not use these parameters |
| 2057 | */ |
| 2058 | break; |
| 2059 | case IW_AUTH_TKIP_COUNTERMEASURES: |
| 2060 | if (param->value) { |
| 2061 | /* wpa_supplicant is enabling the tkip countermeasure. */ |
| 2062 | padapter->securitypriv.btkip_countermeasure = true; |
| 2063 | } else { |
| 2064 | /* wpa_supplicant is disabling the tkip countermeasure. */ |
| 2065 | padapter->securitypriv.btkip_countermeasure = false; |
| 2066 | } |
| 2067 | break; |
| 2068 | case IW_AUTH_DROP_UNENCRYPTED: |
| 2069 | /* HACK: |
| 2070 | * |
| 2071 | * wpa_supplicant calls set_wpa_enabled when the driver |
| 2072 | * is loaded and unloaded, regardless of if WPA is being |
| 2073 | * used. No other calls are made which can be used to |
| 2074 | * determine if encryption will be used or not prior to |
| 2075 | * association being expected. If encryption is not being |
| 2076 | * used, drop_unencrypted is set to false, else true -- we |
| 2077 | * can use this to determine if the CAP_PRIVACY_ON bit should |
| 2078 | * be set. |
| 2079 | */ |
| 2080 | |
| 2081 | if (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption1Enabled) |
| 2082 | break;/* it means init value, or using wep, ndisencryptstatus = Ndis802_11Encryption1Enabled, */ |
| 2083 | /* then it needn't reset it; */ |
| 2084 | |
| 2085 | if (param->value) { |
| 2086 | padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; |
| 2087 | padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; |
| 2088 | padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; |
| 2089 | padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ |
| 2090 | padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; |
| 2091 | } |
| 2092 | |
| 2093 | break; |
| 2094 | case IW_AUTH_80211_AUTH_ALG: |
| 2095 | /* |
| 2096 | * It's the starting point of a link layer connection using wpa_supplicant |
| 2097 | */ |
| 2098 | if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { |
| 2099 | LeaveAllPowerSaveMode(padapter); |
| 2100 | rtw_disassoc_cmd(padapter, 500, false); |
| 2101 | DBG_88E("%s...call rtw_indicate_disconnect\n ", __func__); |
| 2102 | rtw_indicate_disconnect(padapter); |
| 2103 | rtw_free_assoc_resources(padapter, 1); |
| 2104 | } |
| 2105 | ret = wpa_set_auth_algs(dev, (u32)param->value); |
| 2106 | break; |
| 2107 | case IW_AUTH_WPA_ENABLED: |
| 2108 | break; |
| 2109 | case IW_AUTH_RX_UNENCRYPTED_EAPOL: |
| 2110 | break; |
| 2111 | case IW_AUTH_PRIVACY_INVOKED: |
| 2112 | break; |
| 2113 | default: |
| 2114 | return -EOPNOTSUPP; |
| 2115 | } |
| 2116 | |
| 2117 | return ret; |
| 2118 | } |
| 2119 | |
| 2120 | static int rtw_wx_set_enc_ext(struct net_device *dev, |
| 2121 | struct iw_request_info *info, |
| 2122 | union iwreq_data *wrqu, char *extra) |
| 2123 | { |
| 2124 | char *alg_name; |
| 2125 | u32 param_len; |
| 2126 | struct ieee_param *param = NULL; |
| 2127 | struct iw_point *pencoding = &wrqu->encoding; |
| 2128 | struct iw_encode_ext *pext = (struct iw_encode_ext *)extra; |
| 2129 | int ret = 0; |
| 2130 | |
| 2131 | param_len = sizeof(struct ieee_param) + pext->key_len; |
| 2132 | param = (struct ieee_param *)rtw_malloc(param_len); |
| 2133 | if (param == NULL) |
| 2134 | return -1; |
| 2135 | |
| 2136 | _rtw_memset(param, 0, param_len); |
| 2137 | |
| 2138 | param->cmd = IEEE_CMD_SET_ENCRYPTION; |
| 2139 | _rtw_memset(param->sta_addr, 0xff, ETH_ALEN); |
| 2140 | |
| 2141 | switch (pext->alg) { |
| 2142 | case IW_ENCODE_ALG_NONE: |
| 2143 | /* todo: remove key */ |
| 2144 | /* remove = 1; */ |
| 2145 | alg_name = "none"; |
| 2146 | break; |
| 2147 | case IW_ENCODE_ALG_WEP: |
| 2148 | alg_name = "WEP"; |
| 2149 | break; |
| 2150 | case IW_ENCODE_ALG_TKIP: |
| 2151 | alg_name = "TKIP"; |
| 2152 | break; |
| 2153 | case IW_ENCODE_ALG_CCMP: |
| 2154 | alg_name = "CCMP"; |
| 2155 | break; |
| 2156 | default: |
| 2157 | return -1; |
| 2158 | } |
| 2159 | |
| 2160 | strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); |
| 2161 | |
| 2162 | if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) |
| 2163 | param->u.crypt.set_tx = 1; |
| 2164 | |
| 2165 | /* cliW: WEP does not have group key |
| 2166 | * just not checking GROUP key setting |
| 2167 | */ |
| 2168 | if ((pext->alg != IW_ENCODE_ALG_WEP) && |
| 2169 | (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)) |
| 2170 | param->u.crypt.set_tx = 0; |
| 2171 | |
| 2172 | param->u.crypt.idx = (pencoding->flags&0x00FF) - 1; |
| 2173 | |
| 2174 | if (pext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) |
| 2175 | memcpy(param->u.crypt.seq, pext->rx_seq, 8); |
| 2176 | |
| 2177 | if (pext->key_len) { |
| 2178 | param->u.crypt.key_len = pext->key_len; |
| 2179 | memcpy(param->u.crypt.key, pext + 1, pext->key_len); |
| 2180 | } |
| 2181 | |
| 2182 | ret = wpa_set_encryption(dev, param, param_len); |
| 2183 | |
| 2184 | kfree(param); |
| 2185 | return ret; |
| 2186 | } |
| 2187 | |
| 2188 | static int rtw_wx_get_nick(struct net_device *dev, |
| 2189 | struct iw_request_info *info, |
| 2190 | union iwreq_data *wrqu, char *extra) |
| 2191 | { |
| 2192 | if (extra) { |
| 2193 | wrqu->data.length = 14; |
| 2194 | wrqu->data.flags = 1; |
| 2195 | memcpy(extra, "<WIFI@REALTEK>", 14); |
| 2196 | } |
| 2197 | |
| 2198 | /* dump debug info here */ |
| 2199 | return 0; |
| 2200 | } |
| 2201 | |
| 2202 | static int rtw_wx_read32(struct net_device *dev, |
| 2203 | struct iw_request_info *info, |
| 2204 | union iwreq_data *wrqu, char *extra) |
| 2205 | { |
| 2206 | struct adapter *padapter; |
| 2207 | struct iw_point *p; |
| 2208 | u16 len; |
| 2209 | u32 addr; |
| 2210 | u32 data32; |
| 2211 | u32 bytes; |
| 2212 | u8 *ptmp; |
| 2213 | |
| 2214 | padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2215 | p = &wrqu->data; |
| 2216 | len = p->length; |
| 2217 | ptmp = (u8 *)rtw_malloc(len); |
| 2218 | if (NULL == ptmp) |
| 2219 | return -ENOMEM; |
| 2220 | |
| 2221 | if (copy_from_user(ptmp, p->pointer, len)) { |
| 2222 | kfree(ptmp); |
| 2223 | return -EFAULT; |
| 2224 | } |
| 2225 | |
| 2226 | bytes = 0; |
| 2227 | addr = 0; |
| 2228 | sscanf(ptmp, "%d,%x", &bytes, &addr); |
| 2229 | |
| 2230 | switch (bytes) { |
| 2231 | case 1: |
| 2232 | data32 = rtw_read8(padapter, addr); |
| 2233 | sprintf(extra, "0x%02X", data32); |
| 2234 | break; |
| 2235 | case 2: |
| 2236 | data32 = rtw_read16(padapter, addr); |
| 2237 | sprintf(extra, "0x%04X", data32); |
| 2238 | break; |
| 2239 | case 4: |
| 2240 | data32 = rtw_read32(padapter, addr); |
| 2241 | sprintf(extra, "0x%08X", data32); |
| 2242 | break; |
| 2243 | default: |
| 2244 | DBG_88E(KERN_INFO "%s: usage> read [bytes],[address(hex)]\n", __func__); |
| 2245 | return -EINVAL; |
| 2246 | } |
| 2247 | DBG_88E(KERN_INFO "%s: addr = 0x%08X data =%s\n", __func__, addr, extra); |
| 2248 | |
| 2249 | kfree(ptmp); |
| 2250 | return 0; |
| 2251 | } |
| 2252 | |
| 2253 | static int rtw_wx_write32(struct net_device *dev, |
| 2254 | struct iw_request_info *info, |
| 2255 | union iwreq_data *wrqu, char *extra) |
| 2256 | { |
| 2257 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2258 | |
| 2259 | u32 addr; |
| 2260 | u32 data32; |
| 2261 | u32 bytes; |
| 2262 | |
| 2263 | bytes = 0; |
| 2264 | addr = 0; |
| 2265 | data32 = 0; |
| 2266 | sscanf(extra, "%d,%x,%x", &bytes, &addr, &data32); |
| 2267 | |
| 2268 | switch (bytes) { |
| 2269 | case 1: |
| 2270 | rtw_write8(padapter, addr, (u8)data32); |
| 2271 | DBG_88E(KERN_INFO "%s: addr = 0x%08X data = 0x%02X\n", __func__, addr, (u8)data32); |
| 2272 | break; |
| 2273 | case 2: |
| 2274 | rtw_write16(padapter, addr, (u16)data32); |
| 2275 | DBG_88E(KERN_INFO "%s: addr = 0x%08X data = 0x%04X\n", __func__, addr, (u16)data32); |
| 2276 | break; |
| 2277 | case 4: |
| 2278 | rtw_write32(padapter, addr, data32); |
| 2279 | DBG_88E(KERN_INFO "%s: addr = 0x%08X data = 0x%08X\n", __func__, addr, data32); |
| 2280 | break; |
| 2281 | default: |
| 2282 | DBG_88E(KERN_INFO "%s: usage> write [bytes],[address(hex)],[data(hex)]\n", __func__); |
| 2283 | return -EINVAL; |
| 2284 | } |
| 2285 | |
| 2286 | return 0; |
| 2287 | } |
| 2288 | |
| 2289 | static int rtw_wx_read_rf(struct net_device *dev, |
| 2290 | struct iw_request_info *info, |
| 2291 | union iwreq_data *wrqu, char *extra) |
| 2292 | { |
| 2293 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2294 | u32 path, addr, data32; |
| 2295 | |
| 2296 | path = *(u32 *)extra; |
| 2297 | addr = *((u32 *)extra + 1); |
| 2298 | data32 = rtw_hal_read_rfreg(padapter, path, addr, 0xFFFFF); |
| 2299 | /* |
| 2300 | * IMPORTANT!! |
| 2301 | * Only when wireless private ioctl is at odd order, |
| 2302 | * "extra" would be copied to user space. |
| 2303 | */ |
| 2304 | sprintf(extra, "0x%05x", data32); |
| 2305 | |
| 2306 | return 0; |
| 2307 | } |
| 2308 | |
| 2309 | static int rtw_wx_write_rf(struct net_device *dev, |
| 2310 | struct iw_request_info *info, |
| 2311 | union iwreq_data *wrqu, char *extra) |
| 2312 | { |
| 2313 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2314 | u32 path, addr, data32; |
| 2315 | |
| 2316 | path = *(u32 *)extra; |
| 2317 | addr = *((u32 *)extra + 1); |
| 2318 | data32 = *((u32 *)extra + 2); |
| 2319 | rtw_hal_write_rfreg(padapter, path, addr, 0xFFFFF, data32); |
| 2320 | |
| 2321 | return 0; |
| 2322 | } |
| 2323 | |
| 2324 | static int rtw_wx_priv_null(struct net_device *dev, struct iw_request_info *a, |
| 2325 | union iwreq_data *wrqu, char *b) |
| 2326 | { |
| 2327 | return -1; |
| 2328 | } |
| 2329 | |
| 2330 | static int dummy(struct net_device *dev, struct iw_request_info *a, |
| 2331 | union iwreq_data *wrqu, char *b) |
| 2332 | { |
| 2333 | return -1; |
| 2334 | } |
| 2335 | |
| 2336 | static int rtw_wx_set_channel_plan(struct net_device *dev, |
| 2337 | struct iw_request_info *info, |
| 2338 | union iwreq_data *wrqu, char *extra) |
| 2339 | { |
| 2340 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2341 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 2342 | u8 channel_plan_req = (u8) (*((int *)wrqu)); |
| 2343 | |
| 2344 | if (_SUCCESS == rtw_set_chplan_cmd(padapter, channel_plan_req, 1)) |
| 2345 | DBG_88E("%s set channel_plan = 0x%02X\n", __func__, pmlmepriv->ChannelPlan); |
| 2346 | else |
| 2347 | return -EPERM; |
| 2348 | |
| 2349 | return 0; |
| 2350 | } |
| 2351 | |
| 2352 | static int rtw_wx_set_mtk_wps_probe_ie(struct net_device *dev, |
| 2353 | struct iw_request_info *a, |
| 2354 | union iwreq_data *wrqu, char *b) |
| 2355 | { |
| 2356 | return 0; |
| 2357 | } |
| 2358 | |
| 2359 | static int rtw_wx_get_sensitivity(struct net_device *dev, |
| 2360 | struct iw_request_info *info, |
| 2361 | union iwreq_data *wrqu, char *buf) |
| 2362 | { |
| 2363 | return 0; |
| 2364 | } |
| 2365 | |
| 2366 | static int rtw_wx_set_mtk_wps_ie(struct net_device *dev, |
| 2367 | struct iw_request_info *info, |
| 2368 | union iwreq_data *wrqu, char *extra) |
| 2369 | { |
| 2370 | return 0; |
| 2371 | } |
| 2372 | |
| 2373 | /* |
| 2374 | * For all data larger than 16 octets, we need to use a |
| 2375 | * pointer to memory allocated in user space. |
| 2376 | */ |
| 2377 | static int rtw_drvext_hdl(struct net_device *dev, struct iw_request_info *info, |
| 2378 | union iwreq_data *wrqu, char *extra) |
| 2379 | { |
| 2380 | return 0; |
| 2381 | } |
| 2382 | |
| 2383 | static void rtw_dbg_mode_hdl(struct adapter *padapter, u32 id, u8 *pdata, u32 len) |
| 2384 | { |
| 2385 | struct mp_rw_reg *RegRWStruct; |
| 2386 | struct rf_reg_param *prfreg; |
| 2387 | u8 path; |
| 2388 | u8 offset; |
| 2389 | u32 value; |
| 2390 | |
| 2391 | DBG_88E("%s\n", __func__); |
| 2392 | |
| 2393 | switch (id) { |
| 2394 | case GEN_MP_IOCTL_SUBCODE(MP_START): |
| 2395 | DBG_88E("871x_driver is only for normal mode, can't enter mp mode\n"); |
| 2396 | break; |
| 2397 | case GEN_MP_IOCTL_SUBCODE(READ_REG): |
| 2398 | RegRWStruct = (struct mp_rw_reg *)pdata; |
| 2399 | switch (RegRWStruct->width) { |
| 2400 | case 1: |
| 2401 | RegRWStruct->value = rtw_read8(padapter, RegRWStruct->offset); |
| 2402 | break; |
| 2403 | case 2: |
| 2404 | RegRWStruct->value = rtw_read16(padapter, RegRWStruct->offset); |
| 2405 | break; |
| 2406 | case 4: |
| 2407 | RegRWStruct->value = rtw_read32(padapter, RegRWStruct->offset); |
| 2408 | break; |
| 2409 | default: |
| 2410 | break; |
| 2411 | } |
| 2412 | |
| 2413 | break; |
| 2414 | case GEN_MP_IOCTL_SUBCODE(WRITE_REG): |
| 2415 | RegRWStruct = (struct mp_rw_reg *)pdata; |
| 2416 | switch (RegRWStruct->width) { |
| 2417 | case 1: |
| 2418 | rtw_write8(padapter, RegRWStruct->offset, (u8)RegRWStruct->value); |
| 2419 | break; |
| 2420 | case 2: |
| 2421 | rtw_write16(padapter, RegRWStruct->offset, (u16)RegRWStruct->value); |
| 2422 | break; |
| 2423 | case 4: |
| 2424 | rtw_write32(padapter, RegRWStruct->offset, (u32)RegRWStruct->value); |
| 2425 | break; |
| 2426 | default: |
| 2427 | break; |
| 2428 | } |
| 2429 | |
| 2430 | break; |
| 2431 | case GEN_MP_IOCTL_SUBCODE(READ_RF_REG): |
| 2432 | |
| 2433 | prfreg = (struct rf_reg_param *)pdata; |
| 2434 | |
| 2435 | path = (u8)prfreg->path; |
| 2436 | offset = (u8)prfreg->offset; |
| 2437 | |
| 2438 | value = rtw_hal_read_rfreg(padapter, path, offset, 0xffffffff); |
| 2439 | |
| 2440 | prfreg->value = value; |
| 2441 | |
| 2442 | break; |
| 2443 | case GEN_MP_IOCTL_SUBCODE(WRITE_RF_REG): |
| 2444 | |
| 2445 | prfreg = (struct rf_reg_param *)pdata; |
| 2446 | |
| 2447 | path = (u8)prfreg->path; |
| 2448 | offset = (u8)prfreg->offset; |
| 2449 | value = prfreg->value; |
| 2450 | |
| 2451 | rtw_hal_write_rfreg(padapter, path, offset, 0xffffffff, value); |
| 2452 | |
| 2453 | break; |
| 2454 | case GEN_MP_IOCTL_SUBCODE(TRIGGER_GPIO): |
| 2455 | DBG_88E("==> trigger gpio 0\n"); |
| 2456 | rtw_hal_set_hwreg(padapter, HW_VAR_TRIGGER_GPIO_0, NULL); |
| 2457 | break; |
| 2458 | case GEN_MP_IOCTL_SUBCODE(GET_WIFI_STATUS): |
| 2459 | *pdata = rtw_hal_sreset_get_wifi_status(padapter); |
| 2460 | break; |
| 2461 | default: |
| 2462 | break; |
| 2463 | } |
| 2464 | } |
| 2465 | |
| 2466 | static int rtw_mp_ioctl_hdl(struct net_device *dev, struct iw_request_info *info, |
| 2467 | union iwreq_data *wrqu, char *extra) |
| 2468 | { |
| 2469 | int ret = 0; |
| 2470 | u32 BytesRead, BytesWritten, BytesNeeded; |
| 2471 | struct oid_par_priv oid_par; |
| 2472 | struct mp_ioctl_handler *phandler; |
| 2473 | struct mp_ioctl_param *poidparam; |
| 2474 | uint status = 0; |
| 2475 | u16 len; |
| 2476 | u8 *pparmbuf = NULL, bset; |
| 2477 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2478 | struct iw_point *p = &wrqu->data; |
| 2479 | |
| 2480 | if ((!p->length) || (!p->pointer)) { |
| 2481 | ret = -EINVAL; |
| 2482 | goto _rtw_mp_ioctl_hdl_exit; |
| 2483 | } |
| 2484 | pparmbuf = NULL; |
| 2485 | bset = (u8)(p->flags & 0xFFFF); |
| 2486 | len = p->length; |
| 2487 | pparmbuf = (u8 *)rtw_malloc(len); |
| 2488 | if (pparmbuf == NULL) { |
| 2489 | ret = -ENOMEM; |
| 2490 | goto _rtw_mp_ioctl_hdl_exit; |
| 2491 | } |
| 2492 | |
| 2493 | if (copy_from_user(pparmbuf, p->pointer, len)) { |
| 2494 | ret = -EFAULT; |
| 2495 | goto _rtw_mp_ioctl_hdl_exit; |
| 2496 | } |
| 2497 | |
| 2498 | poidparam = (struct mp_ioctl_param *)pparmbuf; |
| 2499 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, |
| 2500 | ("rtw_mp_ioctl_hdl: subcode [%d], len[%d], buffer_len[%d]\r\n", |
| 2501 | poidparam->subcode, poidparam->len, len)); |
| 2502 | |
Dan Carpenter | 893134b | 2014-02-04 01:38:03 +0300 | [diff] [blame] | 2503 | if (poidparam->subcode >= ARRAY_SIZE(mp_ioctl_hdl)) { |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 2504 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("no matching drvext subcodes\r\n")); |
| 2505 | ret = -EINVAL; |
| 2506 | goto _rtw_mp_ioctl_hdl_exit; |
| 2507 | } |
| 2508 | |
| 2509 | if (padapter->registrypriv.mp_mode == 1) { |
| 2510 | phandler = mp_ioctl_hdl + poidparam->subcode; |
| 2511 | |
| 2512 | if ((phandler->paramsize != 0) && (poidparam->len < phandler->paramsize)) { |
| 2513 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, |
| 2514 | ("no matching drvext param size %d vs %d\r\n", |
| 2515 | poidparam->len, phandler->paramsize)); |
| 2516 | ret = -EINVAL; |
| 2517 | goto _rtw_mp_ioctl_hdl_exit; |
| 2518 | } |
| 2519 | |
| 2520 | if (phandler->handler) { |
| 2521 | oid_par.adapter_context = padapter; |
| 2522 | oid_par.oid = phandler->oid; |
| 2523 | oid_par.information_buf = poidparam->data; |
| 2524 | oid_par.information_buf_len = poidparam->len; |
| 2525 | oid_par.dbg = 0; |
| 2526 | |
| 2527 | BytesWritten = 0; |
| 2528 | BytesNeeded = 0; |
| 2529 | |
| 2530 | if (bset) { |
| 2531 | oid_par.bytes_rw = &BytesRead; |
| 2532 | oid_par.bytes_needed = &BytesNeeded; |
| 2533 | oid_par.type_of_oid = SET_OID; |
| 2534 | } else { |
| 2535 | oid_par.bytes_rw = &BytesWritten; |
| 2536 | oid_par.bytes_needed = &BytesNeeded; |
| 2537 | oid_par.type_of_oid = QUERY_OID; |
| 2538 | } |
| 2539 | |
| 2540 | status = phandler->handler(&oid_par); |
| 2541 | } else { |
| 2542 | DBG_88E("rtw_mp_ioctl_hdl(): err!, subcode =%d, oid =%d, handler =%p\n", |
| 2543 | poidparam->subcode, phandler->oid, phandler->handler); |
| 2544 | ret = -EFAULT; |
| 2545 | goto _rtw_mp_ioctl_hdl_exit; |
| 2546 | } |
| 2547 | } else { |
| 2548 | rtw_dbg_mode_hdl(padapter, poidparam->subcode, poidparam->data, poidparam->len); |
| 2549 | } |
| 2550 | |
| 2551 | if (bset == 0x00) {/* query info */ |
| 2552 | if (copy_to_user(p->pointer, pparmbuf, len)) |
| 2553 | ret = -EFAULT; |
| 2554 | } |
| 2555 | |
| 2556 | if (status) { |
| 2557 | ret = -EFAULT; |
| 2558 | goto _rtw_mp_ioctl_hdl_exit; |
| 2559 | } |
| 2560 | |
| 2561 | _rtw_mp_ioctl_hdl_exit: |
| 2562 | |
| 2563 | kfree(pparmbuf); |
| 2564 | return ret; |
| 2565 | } |
| 2566 | |
| 2567 | static int rtw_get_ap_info(struct net_device *dev, |
| 2568 | struct iw_request_info *info, |
| 2569 | union iwreq_data *wrqu, char *extra) |
| 2570 | { |
| 2571 | int ret = 0; |
| 2572 | u32 cnt = 0, wpa_ielen; |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 2573 | struct list_head *plist, *phead; |
| 2574 | unsigned char *pbuf; |
| 2575 | u8 bssid[ETH_ALEN]; |
| 2576 | char data[32]; |
| 2577 | struct wlan_network *pnetwork = NULL; |
| 2578 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2579 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 2580 | struct __queue *queue = &(pmlmepriv->scanned_queue); |
| 2581 | struct iw_point *pdata = &wrqu->data; |
| 2582 | |
| 2583 | DBG_88E("+rtw_get_aplist_info\n"); |
| 2584 | |
| 2585 | if ((padapter->bDriverStopped) || (pdata == NULL)) { |
| 2586 | ret = -EINVAL; |
| 2587 | goto exit; |
| 2588 | } |
| 2589 | |
| 2590 | while ((check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)))) { |
Larry Finger | 0da46e6 | 2013-12-19 22:38:41 -0600 | [diff] [blame] | 2591 | msleep(30); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 2592 | cnt++; |
| 2593 | if (cnt > 100) |
| 2594 | break; |
| 2595 | } |
| 2596 | pdata->flags = 0; |
| 2597 | if (pdata->length >= 32) { |
| 2598 | if (copy_from_user(data, pdata->pointer, 32)) { |
| 2599 | ret = -EINVAL; |
| 2600 | goto exit; |
| 2601 | } |
| 2602 | } else { |
| 2603 | ret = -EINVAL; |
| 2604 | goto exit; |
| 2605 | } |
| 2606 | |
Larry Finger | 7057dcb | 2013-12-19 22:38:34 -0600 | [diff] [blame] | 2607 | spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 2608 | |
| 2609 | phead = get_list_head(queue); |
| 2610 | plist = get_next(phead); |
| 2611 | |
| 2612 | while (1) { |
| 2613 | if (rtw_end_of_queue_search(phead, plist) == true) |
| 2614 | break; |
| 2615 | |
| 2616 | pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); |
| 2617 | |
| 2618 | if (hwaddr_aton_i(data, bssid)) { |
| 2619 | DBG_88E("Invalid BSSID '%s'.\n", (u8 *)data); |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 2620 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 2621 | return -EINVAL; |
| 2622 | } |
| 2623 | |
Larry Finger | dc14a62 | 2013-09-04 15:56:02 -0500 | [diff] [blame] | 2624 | if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN)) { |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 2625 | /* BSSID match, then check if supporting wpa/wpa2 */ |
| 2626 | DBG_88E("BSSID:%pM\n", (bssid)); |
| 2627 | |
| 2628 | pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); |
| 2629 | if (pbuf && (wpa_ielen > 0)) { |
| 2630 | pdata->flags = 1; |
| 2631 | break; |
| 2632 | } |
| 2633 | |
| 2634 | pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); |
| 2635 | if (pbuf && (wpa_ielen > 0)) { |
| 2636 | pdata->flags = 2; |
| 2637 | break; |
| 2638 | } |
| 2639 | } |
| 2640 | |
| 2641 | plist = get_next(plist); |
| 2642 | } |
| 2643 | |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 2644 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 2645 | |
| 2646 | if (pdata->length >= 34) { |
| 2647 | if (copy_to_user(pdata->pointer+32, (u8 *)&pdata->flags, 1)) { |
| 2648 | ret = -EINVAL; |
| 2649 | goto exit; |
| 2650 | } |
| 2651 | } |
| 2652 | |
| 2653 | exit: |
| 2654 | |
| 2655 | return ret; |
| 2656 | } |
| 2657 | |
| 2658 | static int rtw_set_pid(struct net_device *dev, |
| 2659 | struct iw_request_info *info, |
| 2660 | union iwreq_data *wrqu, char *extra) |
| 2661 | { |
| 2662 | int ret = 0; |
| 2663 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 2664 | int *pdata = (int *)wrqu; |
| 2665 | int selector; |
| 2666 | |
| 2667 | if ((padapter->bDriverStopped) || (pdata == NULL)) { |
| 2668 | ret = -EINVAL; |
| 2669 | goto exit; |
| 2670 | } |
| 2671 | |
| 2672 | selector = *pdata; |
| 2673 | if (selector < 3 && selector >= 0) { |
| 2674 | padapter->pid[selector] = *(pdata+1); |
| 2675 | ui_pid[selector] = *(pdata+1); |
| 2676 | DBG_88E("%s set pid[%d] =%d\n", __func__, selector, padapter->pid[selector]); |
| 2677 | } else { |
| 2678 | DBG_88E("%s selector %d error\n", __func__, selector); |
| 2679 | } |
| 2680 | exit: |
| 2681 | return ret; |
| 2682 | } |
| 2683 | |
| 2684 | static int rtw_wps_start(struct net_device *dev, |
| 2685 | struct iw_request_info *info, |
| 2686 | union iwreq_data *wrqu, char *extra) |
| 2687 | { |
| 2688 | int ret = 0; |
| 2689 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2690 | struct iw_point *pdata = &wrqu->data; |
| 2691 | u32 u32wps_start = 0; |
| 2692 | |
| 2693 | ret = copy_from_user((void *)&u32wps_start, pdata->pointer, 4); |
| 2694 | if (ret) { |
| 2695 | ret = -EINVAL; |
| 2696 | goto exit; |
| 2697 | } |
| 2698 | |
| 2699 | if ((padapter->bDriverStopped) || (pdata == NULL)) { |
| 2700 | ret = -EINVAL; |
| 2701 | goto exit; |
| 2702 | } |
| 2703 | |
| 2704 | if (u32wps_start == 0) |
| 2705 | u32wps_start = *extra; |
| 2706 | |
| 2707 | DBG_88E("[%s] wps_start = %d\n", __func__, u32wps_start); |
| 2708 | |
| 2709 | if (u32wps_start == 1) /* WPS Start */ |
| 2710 | rtw_led_control(padapter, LED_CTL_START_WPS); |
| 2711 | else if (u32wps_start == 2) /* WPS Stop because of wps success */ |
| 2712 | rtw_led_control(padapter, LED_CTL_STOP_WPS); |
| 2713 | else if (u32wps_start == 3) /* WPS Stop because of wps fail */ |
| 2714 | rtw_led_control(padapter, LED_CTL_STOP_WPS_FAIL); |
| 2715 | |
| 2716 | exit: |
| 2717 | return ret; |
| 2718 | } |
| 2719 | |
| 2720 | #ifdef CONFIG_88EU_P2P |
| 2721 | static int rtw_wext_p2p_enable(struct net_device *dev, |
| 2722 | struct iw_request_info *info, |
| 2723 | union iwreq_data *wrqu, char *extra) |
| 2724 | { |
| 2725 | int ret = 0; |
| 2726 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2727 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 2728 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 2729 | enum P2P_ROLE init_role = P2P_ROLE_DISABLE; |
| 2730 | |
| 2731 | if (*extra == '0') |
| 2732 | init_role = P2P_ROLE_DISABLE; |
| 2733 | else if (*extra == '1') |
| 2734 | init_role = P2P_ROLE_DEVICE; |
| 2735 | else if (*extra == '2') |
| 2736 | init_role = P2P_ROLE_CLIENT; |
| 2737 | else if (*extra == '3') |
| 2738 | init_role = P2P_ROLE_GO; |
| 2739 | |
| 2740 | if (_FAIL == rtw_p2p_enable(padapter, init_role)) { |
| 2741 | ret = -EFAULT; |
| 2742 | goto exit; |
| 2743 | } |
| 2744 | |
| 2745 | /* set channel/bandwidth */ |
| 2746 | if (init_role != P2P_ROLE_DISABLE) { |
| 2747 | u8 channel, ch_offset; |
| 2748 | u16 bwmode; |
| 2749 | |
| 2750 | if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_LISTEN)) { |
| 2751 | /* Stay at the listen state and wait for discovery. */ |
| 2752 | channel = pwdinfo->listen_channel; |
| 2753 | pwdinfo->operating_channel = pwdinfo->listen_channel; |
| 2754 | ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; |
| 2755 | bwmode = HT_CHANNEL_WIDTH_20; |
| 2756 | } else { |
| 2757 | pwdinfo->operating_channel = pmlmeext->cur_channel; |
| 2758 | |
| 2759 | channel = pwdinfo->operating_channel; |
| 2760 | ch_offset = pmlmeext->cur_ch_offset; |
| 2761 | bwmode = pmlmeext->cur_bwmode; |
| 2762 | } |
| 2763 | |
| 2764 | set_channel_bwmode(padapter, channel, ch_offset, bwmode); |
| 2765 | } |
| 2766 | |
| 2767 | exit: |
| 2768 | return ret; |
| 2769 | } |
| 2770 | |
| 2771 | static int rtw_p2p_set_go_nego_ssid(struct net_device *dev, |
| 2772 | struct iw_request_info *info, |
| 2773 | union iwreq_data *wrqu, char *extra) |
| 2774 | { |
| 2775 | int ret = 0; |
| 2776 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2777 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 2778 | |
| 2779 | DBG_88E("[%s] ssid = %s, len = %zu\n", __func__, extra, strlen(extra)); |
| 2780 | memcpy(pwdinfo->nego_ssid, extra, strlen(extra)); |
| 2781 | pwdinfo->nego_ssidlen = strlen(extra); |
| 2782 | |
| 2783 | return ret; |
| 2784 | } |
| 2785 | |
| 2786 | static int rtw_p2p_set_intent(struct net_device *dev, |
| 2787 | struct iw_request_info *info, |
| 2788 | union iwreq_data *wrqu, char *extra) |
| 2789 | { |
| 2790 | int ret = 0; |
| 2791 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2792 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 2793 | u8 intent = pwdinfo->intent; |
| 2794 | |
| 2795 | switch (wrqu->data.length) { |
| 2796 | case 1: |
| 2797 | intent = extra[0] - '0'; |
| 2798 | break; |
| 2799 | case 2: |
| 2800 | intent = str_2char2num(extra[0], extra[1]); |
| 2801 | break; |
| 2802 | } |
| 2803 | if (intent <= 15) |
| 2804 | pwdinfo->intent = intent; |
| 2805 | else |
| 2806 | ret = -1; |
| 2807 | DBG_88E("[%s] intent = %d\n", __func__, intent); |
| 2808 | return ret; |
| 2809 | } |
| 2810 | |
| 2811 | static int rtw_p2p_set_listen_ch(struct net_device *dev, |
| 2812 | struct iw_request_info *info, |
| 2813 | union iwreq_data *wrqu, char *extra) |
| 2814 | { |
| 2815 | int ret = 0; |
| 2816 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2817 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 2818 | u8 listen_ch = pwdinfo->listen_channel; /* Listen channel number */ |
| 2819 | |
| 2820 | switch (wrqu->data.length) { |
| 2821 | case 1: |
| 2822 | listen_ch = extra[0] - '0'; |
| 2823 | break; |
| 2824 | case 2: |
| 2825 | listen_ch = str_2char2num(extra[0], extra[1]); |
| 2826 | break; |
| 2827 | } |
| 2828 | |
| 2829 | if ((listen_ch == 1) || (listen_ch == 6) || (listen_ch == 11)) { |
| 2830 | pwdinfo->listen_channel = listen_ch; |
| 2831 | set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); |
| 2832 | } else { |
| 2833 | ret = -1; |
| 2834 | } |
| 2835 | |
| 2836 | DBG_88E("[%s] listen_ch = %d\n", __func__, pwdinfo->listen_channel); |
| 2837 | |
| 2838 | return ret; |
| 2839 | } |
| 2840 | |
| 2841 | static int rtw_p2p_set_op_ch(struct net_device *dev, |
| 2842 | struct iw_request_info *info, |
| 2843 | union iwreq_data *wrqu, char *extra) |
| 2844 | { |
| 2845 | /* Commented by Albert 20110524 */ |
| 2846 | /* This function is used to set the operating channel if the driver will become the group owner */ |
| 2847 | |
| 2848 | int ret = 0; |
| 2849 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2850 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 2851 | u8 op_ch = pwdinfo->operating_channel; /* Operating channel number */ |
| 2852 | |
| 2853 | switch (wrqu->data.length) { |
| 2854 | case 1: |
| 2855 | op_ch = extra[0] - '0'; |
| 2856 | break; |
| 2857 | case 2: |
| 2858 | op_ch = str_2char2num(extra[0], extra[1]); |
| 2859 | break; |
| 2860 | } |
| 2861 | |
| 2862 | if (op_ch > 0) |
| 2863 | pwdinfo->operating_channel = op_ch; |
| 2864 | else |
| 2865 | ret = -1; |
| 2866 | |
| 2867 | DBG_88E("[%s] op_ch = %d\n", __func__, pwdinfo->operating_channel); |
| 2868 | |
| 2869 | return ret; |
| 2870 | } |
| 2871 | |
| 2872 | static int rtw_p2p_profilefound(struct net_device *dev, |
| 2873 | struct iw_request_info *info, |
| 2874 | union iwreq_data *wrqu, char *extra) |
| 2875 | { |
| 2876 | int ret = 0; |
| 2877 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2878 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 2879 | |
| 2880 | /* Comment by Albert 2010/10/13 */ |
| 2881 | /* Input data format: */ |
| 2882 | /* Ex: 0 */ |
| 2883 | /* Ex: 1XX:XX:XX:XX:XX:XXYYSSID */ |
| 2884 | /* 0 => Reflush the profile record list. */ |
| 2885 | /* 1 => Add the profile list */ |
| 2886 | /* XX:XX:XX:XX:XX:XX => peer's MAC Address (ex: 00:E0:4C:00:00:01) */ |
| 2887 | /* YY => SSID Length */ |
| 2888 | /* SSID => SSID for persistence group */ |
| 2889 | |
| 2890 | DBG_88E("[%s] In value = %s, len = %d\n", __func__, extra, wrqu->data.length - 1); |
| 2891 | |
| 2892 | /* The upper application should pass the SSID to driver by using this rtw_p2p_profilefound function. */ |
| 2893 | if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { |
| 2894 | if (extra[0] == '0') { |
| 2895 | /* Remove all the profile information of wifidirect_info structure. */ |
| 2896 | _rtw_memset(&pwdinfo->profileinfo[0], 0x00, sizeof(struct profile_info) * P2P_MAX_PERSISTENT_GROUP_NUM); |
| 2897 | pwdinfo->profileindex = 0; |
| 2898 | } else { |
| 2899 | if (pwdinfo->profileindex >= P2P_MAX_PERSISTENT_GROUP_NUM) { |
| 2900 | ret = -1; |
| 2901 | } else { |
| 2902 | int jj, kk; |
| 2903 | |
| 2904 | /* Add this profile information into pwdinfo->profileinfo */ |
| 2905 | /* Ex: 1XX:XX:XX:XX:XX:XXYYSSID */ |
| 2906 | for (jj = 0, kk = 1; jj < ETH_ALEN; jj++, kk += 3) |
| 2907 | pwdinfo->profileinfo[pwdinfo->profileindex].peermac[jj] = key_2char2num(extra[kk], extra[kk + 1]); |
| 2908 | |
| 2909 | pwdinfo->profileinfo[pwdinfo->profileindex].ssidlen = (extra[18] - '0') * 10 + (extra[19] - '0'); |
| 2910 | memcpy(pwdinfo->profileinfo[pwdinfo->profileindex].ssid, &extra[20], pwdinfo->profileinfo[pwdinfo->profileindex].ssidlen); |
| 2911 | pwdinfo->profileindex++; |
| 2912 | } |
| 2913 | } |
| 2914 | } |
| 2915 | |
| 2916 | return ret; |
| 2917 | } |
| 2918 | |
| 2919 | static int rtw_p2p_setDN(struct net_device *dev, |
| 2920 | struct iw_request_info *info, |
| 2921 | union iwreq_data *wrqu, char *extra) |
| 2922 | { |
| 2923 | int ret = 0; |
| 2924 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2925 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 2926 | |
| 2927 | DBG_88E("[%s] %s %d\n", __func__, extra, wrqu->data.length - 1); |
| 2928 | _rtw_memset(pwdinfo->device_name, 0x00, WPS_MAX_DEVICE_NAME_LEN); |
| 2929 | memcpy(pwdinfo->device_name, extra, wrqu->data.length - 1); |
| 2930 | pwdinfo->device_name_len = wrqu->data.length - 1; |
| 2931 | |
| 2932 | return ret; |
| 2933 | } |
| 2934 | |
| 2935 | static int rtw_p2p_get_status(struct net_device *dev, |
| 2936 | struct iw_request_info *info, |
| 2937 | union iwreq_data *wrqu, char *extra) |
| 2938 | { |
| 2939 | int ret = 0; |
| 2940 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2941 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 2942 | |
| 2943 | if (padapter->bShowGetP2PState) |
| 2944 | DBG_88E("[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), |
| 2945 | pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], pwdinfo->p2p_peer_interface_addr[2], |
| 2946 | pwdinfo->p2p_peer_interface_addr[3], pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]); |
| 2947 | |
| 2948 | /* Commented by Albert 2010/10/12 */ |
| 2949 | /* Because of the output size limitation, I had removed the "Role" information. */ |
| 2950 | /* About the "Role" information, we will use the new private IOCTL to get the "Role" information. */ |
| 2951 | sprintf(extra, "\n\nStatus =%.2d\n", rtw_p2p_state(pwdinfo)); |
| 2952 | wrqu->data.length = strlen(extra); |
| 2953 | |
| 2954 | return ret; |
| 2955 | } |
| 2956 | |
| 2957 | /* Commented by Albert 20110520 */ |
| 2958 | /* This function will return the config method description */ |
Masanari Iida | 7efc02c | 2013-09-27 00:11:46 +0900 | [diff] [blame] | 2959 | /* This config method description will show us which config method the remote P2P device is intended to use */ |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 2960 | /* by sending the provisioning discovery request frame. */ |
| 2961 | |
| 2962 | static int rtw_p2p_get_req_cm(struct net_device *dev, |
| 2963 | struct iw_request_info *info, |
| 2964 | union iwreq_data *wrqu, char *extra) |
| 2965 | { |
| 2966 | int ret = 0; |
| 2967 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2968 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 2969 | |
| 2970 | sprintf(extra, "\n\nCM =%s\n", pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req); |
| 2971 | wrqu->data.length = strlen(extra); |
| 2972 | return ret; |
| 2973 | } |
| 2974 | |
| 2975 | static int rtw_p2p_get_role(struct net_device *dev, |
| 2976 | struct iw_request_info *info, |
| 2977 | union iwreq_data *wrqu, char *extra) |
| 2978 | { |
| 2979 | int ret = 0; |
| 2980 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2981 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 2982 | |
| 2983 | DBG_88E("[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), |
| 2984 | pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], pwdinfo->p2p_peer_interface_addr[2], |
| 2985 | pwdinfo->p2p_peer_interface_addr[3], pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]); |
| 2986 | |
| 2987 | sprintf(extra, "\n\nRole =%.2d\n", rtw_p2p_role(pwdinfo)); |
| 2988 | wrqu->data.length = strlen(extra); |
| 2989 | return ret; |
| 2990 | } |
| 2991 | |
| 2992 | static int rtw_p2p_get_peer_ifaddr(struct net_device *dev, |
| 2993 | struct iw_request_info *info, |
| 2994 | union iwreq_data *wrqu, char *extra) |
| 2995 | { |
| 2996 | int ret = 0; |
| 2997 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 2998 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 2999 | |
| 3000 | DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", __func__, |
| 3001 | rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), |
| 3002 | pwdinfo->p2p_peer_interface_addr); |
| 3003 | sprintf(extra, "\nMAC %pM", |
| 3004 | pwdinfo->p2p_peer_interface_addr); |
| 3005 | wrqu->data.length = strlen(extra); |
| 3006 | return ret; |
| 3007 | } |
| 3008 | |
| 3009 | static int rtw_p2p_get_peer_devaddr(struct net_device *dev, |
| 3010 | struct iw_request_info *info, |
| 3011 | union iwreq_data *wrqu, char *extra) |
| 3012 | |
| 3013 | { |
| 3014 | int ret = 0; |
| 3015 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3016 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 3017 | |
| 3018 | DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", __func__, |
| 3019 | rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), |
| 3020 | pwdinfo->rx_prov_disc_info.peerDevAddr); |
| 3021 | sprintf(extra, "\n%pM", |
| 3022 | pwdinfo->rx_prov_disc_info.peerDevAddr); |
| 3023 | wrqu->data.length = strlen(extra); |
| 3024 | return ret; |
| 3025 | } |
| 3026 | |
| 3027 | static int rtw_p2p_get_peer_devaddr_by_invitation(struct net_device *dev, |
| 3028 | struct iw_request_info *info, |
| 3029 | union iwreq_data *wrqu, char *extra) |
| 3030 | |
| 3031 | { |
| 3032 | int ret = 0; |
| 3033 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3034 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 3035 | |
| 3036 | DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", |
| 3037 | __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), |
| 3038 | pwdinfo->p2p_peer_device_addr); |
| 3039 | sprintf(extra, "\nMAC %pM", |
| 3040 | pwdinfo->p2p_peer_device_addr); |
| 3041 | wrqu->data.length = strlen(extra); |
| 3042 | return ret; |
| 3043 | } |
| 3044 | |
| 3045 | static int rtw_p2p_get_groupid(struct net_device *dev, |
| 3046 | struct iw_request_info *info, |
| 3047 | union iwreq_data *wrqu, char *extra) |
| 3048 | |
| 3049 | { |
| 3050 | int ret = 0; |
| 3051 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3052 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 3053 | |
| 3054 | sprintf(extra, "\n%.2X:%.2X:%.2X:%.2X:%.2X:%.2X %s", |
| 3055 | pwdinfo->groupid_info.go_device_addr[0], pwdinfo->groupid_info.go_device_addr[1], |
| 3056 | pwdinfo->groupid_info.go_device_addr[2], pwdinfo->groupid_info.go_device_addr[3], |
| 3057 | pwdinfo->groupid_info.go_device_addr[4], pwdinfo->groupid_info.go_device_addr[5], |
| 3058 | pwdinfo->groupid_info.ssid); |
| 3059 | wrqu->data.length = strlen(extra); |
| 3060 | return ret; |
| 3061 | } |
| 3062 | |
| 3063 | static int rtw_p2p_get_op_ch(struct net_device *dev, |
| 3064 | struct iw_request_info *info, |
| 3065 | union iwreq_data *wrqu, char *extra) |
| 3066 | |
| 3067 | { |
| 3068 | int ret = 0; |
| 3069 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3070 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 3071 | |
| 3072 | DBG_88E("[%s] Op_ch = %02x\n", __func__, pwdinfo->operating_channel); |
| 3073 | |
| 3074 | sprintf(extra, "\n\nOp_ch =%.2d\n", pwdinfo->operating_channel); |
| 3075 | wrqu->data.length = strlen(extra); |
| 3076 | return ret; |
| 3077 | } |
| 3078 | |
| 3079 | static int rtw_p2p_get_wps_configmethod(struct net_device *dev, |
| 3080 | struct iw_request_info *info, |
| 3081 | union iwreq_data *wrqu, char *extra) |
| 3082 | { |
| 3083 | int ret = 0; |
| 3084 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3085 | u8 peerMAC[ETH_ALEN] = {0x00}; |
| 3086 | int jj, kk; |
| 3087 | u8 peerMACStr[17] = {0x00}; |
| 3088 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3089 | struct list_head *plist, *phead; |
| 3090 | struct __queue *queue = &(pmlmepriv->scanned_queue); |
| 3091 | struct wlan_network *pnetwork = NULL; |
| 3092 | u8 blnMatch = 0; |
| 3093 | u16 attr_content = 0; |
| 3094 | uint attr_contentlen = 0; |
| 3095 | /* 6 is the string "wpsCM =", 17 is the MAC addr, we have to clear it at wrqu->data.pointer */ |
| 3096 | u8 attr_content_str[6 + 17] = {0x00}; |
| 3097 | |
| 3098 | /* Commented by Albert 20110727 */ |
| 3099 | /* The input data is the MAC address which the application wants to know its WPS config method. */ |
| 3100 | /* After knowing its WPS config method, the application can decide the config method for provisioning discovery. */ |
| 3101 | /* Format: iwpriv wlanx p2p_get_wpsCM 00:E0:4C:00:00:05 */ |
| 3102 | |
| 3103 | DBG_88E("[%s] data = %s\n", __func__, (char *)extra); |
| 3104 | if (copy_from_user(peerMACStr, wrqu->data.pointer + 6, 17)) |
| 3105 | return -EFAULT; |
| 3106 | |
| 3107 | for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) |
| 3108 | peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); |
| 3109 | |
Larry Finger | 7057dcb | 2013-12-19 22:38:34 -0600 | [diff] [blame] | 3110 | spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3111 | |
| 3112 | phead = get_list_head(queue); |
| 3113 | plist = get_next(phead); |
| 3114 | |
| 3115 | while (1) { |
| 3116 | if (rtw_end_of_queue_search(phead, plist) == true) |
| 3117 | break; |
| 3118 | |
| 3119 | pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); |
| 3120 | if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { |
| 3121 | u8 *wpsie; |
| 3122 | uint wpsie_len = 0; |
| 3123 | __be16 be_tmp; |
| 3124 | |
| 3125 | /* The mac address is matched. */ |
| 3126 | wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &wpsie_len); |
| 3127 | if (wpsie) { |
| 3128 | rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_CONF_METHOD, (u8 *) &be_tmp, &attr_contentlen); |
| 3129 | if (attr_contentlen) { |
| 3130 | attr_content = be16_to_cpu(be_tmp); |
| 3131 | sprintf(attr_content_str, "\n\nM =%.4d", attr_content); |
| 3132 | blnMatch = 1; |
| 3133 | } |
| 3134 | } |
| 3135 | break; |
| 3136 | } |
| 3137 | plist = get_next(plist); |
| 3138 | } |
| 3139 | |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 3140 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3141 | |
| 3142 | if (!blnMatch) |
| 3143 | sprintf(attr_content_str, "\n\nM = 0000"); |
| 3144 | |
| 3145 | if (copy_to_user(wrqu->data.pointer, attr_content_str, 6 + 17)) |
| 3146 | return -EFAULT; |
| 3147 | return ret; |
| 3148 | } |
| 3149 | |
| 3150 | static int rtw_p2p_get_go_device_address(struct net_device *dev, |
| 3151 | struct iw_request_info *info, |
| 3152 | union iwreq_data *wrqu, char *extra) |
| 3153 | { |
| 3154 | int ret = 0; |
| 3155 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3156 | u8 peerMAC[ETH_ALEN] = {0x00}; |
| 3157 | int jj, kk; |
| 3158 | u8 peerMACStr[17] = {0x00}; |
| 3159 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3160 | struct list_head *plist, *phead; |
| 3161 | struct __queue *queue = &(pmlmepriv->scanned_queue); |
| 3162 | struct wlan_network *pnetwork = NULL; |
| 3163 | u8 blnMatch = 0; |
| 3164 | u8 *p2pie; |
| 3165 | uint p2pielen = 0, attr_contentlen = 0; |
| 3166 | u8 attr_content[100] = {0x00}; |
Dan Carpenter | e6ff3f4 | 2014-02-04 01:38:35 +0300 | [diff] [blame] | 3167 | u8 go_devadd_str[17 + 12] = {}; |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3168 | |
| 3169 | /* Commented by Albert 20121209 */ |
| 3170 | /* The input data is the GO's interface address which the application wants to know its device address. */ |
| 3171 | /* Format: iwpriv wlanx p2p_get2 go_devadd = 00:E0:4C:00:00:05 */ |
| 3172 | |
| 3173 | DBG_88E("[%s] data = %s\n", __func__, (char *)extra); |
| 3174 | if (copy_from_user(peerMACStr, wrqu->data.pointer + 10, 17)) |
| 3175 | return -EFAULT; |
| 3176 | |
| 3177 | for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) |
| 3178 | peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); |
| 3179 | |
Larry Finger | 7057dcb | 2013-12-19 22:38:34 -0600 | [diff] [blame] | 3180 | spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3181 | |
| 3182 | phead = get_list_head(queue); |
| 3183 | plist = get_next(phead); |
| 3184 | |
| 3185 | while (1) { |
| 3186 | if (rtw_end_of_queue_search(phead, plist) == true) |
| 3187 | break; |
| 3188 | |
| 3189 | pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); |
| 3190 | if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { |
| 3191 | /* Commented by Albert 2011/05/18 */ |
| 3192 | /* Match the device address located in the P2P IE */ |
| 3193 | /* This is for the case that the P2P device address is not the same as the P2P interface address. */ |
| 3194 | |
| 3195 | p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); |
| 3196 | if (p2pie) { |
| 3197 | while (p2pie) { |
| 3198 | /* The P2P Device ID attribute is included in the Beacon frame. */ |
| 3199 | /* The P2P Device Info attribute is included in the probe response frame. */ |
| 3200 | |
| 3201 | _rtw_memset(attr_content, 0x00, 100); |
| 3202 | if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) { |
| 3203 | /* Handle the P2P Device ID attribute of Beacon first */ |
| 3204 | blnMatch = 1; |
| 3205 | break; |
| 3206 | } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) { |
| 3207 | /* Handle the P2P Device Info attribute of probe response */ |
| 3208 | blnMatch = 1; |
| 3209 | break; |
| 3210 | } |
| 3211 | |
| 3212 | /* Get the next P2P IE */ |
| 3213 | p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); |
| 3214 | } |
| 3215 | } |
| 3216 | } |
| 3217 | |
| 3218 | plist = get_next(plist); |
| 3219 | } |
| 3220 | |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 3221 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3222 | |
| 3223 | if (!blnMatch) |
Dan Carpenter | e6ff3f4 | 2014-02-04 01:38:35 +0300 | [diff] [blame] | 3224 | snprintf(go_devadd_str, sizeof(go_devadd_str), "\n\ndev_add = NULL"); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3225 | else |
Dan Carpenter | e6ff3f4 | 2014-02-04 01:38:35 +0300 | [diff] [blame] | 3226 | snprintf(go_devadd_str, sizeof(go_devadd_str), "\n\ndev_add =%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3227 | attr_content[0], attr_content[1], attr_content[2], attr_content[3], attr_content[4], attr_content[5]); |
| 3228 | |
Dan Carpenter | e6ff3f4 | 2014-02-04 01:38:35 +0300 | [diff] [blame] | 3229 | if (copy_to_user(wrqu->data.pointer, go_devadd_str, sizeof(go_devadd_str))) |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3230 | return -EFAULT; |
| 3231 | return ret; |
| 3232 | } |
| 3233 | |
| 3234 | static int rtw_p2p_get_device_type(struct net_device *dev, |
| 3235 | struct iw_request_info *info, |
| 3236 | union iwreq_data *wrqu, char *extra) |
| 3237 | { |
| 3238 | int ret = 0; |
| 3239 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3240 | u8 peerMAC[ETH_ALEN] = {0x00}; |
| 3241 | int jj, kk; |
| 3242 | u8 peerMACStr[17] = {0x00}; |
| 3243 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3244 | struct list_head *plist, *phead; |
| 3245 | struct __queue *queue = &(pmlmepriv->scanned_queue); |
| 3246 | struct wlan_network *pnetwork = NULL; |
| 3247 | u8 blnMatch = 0; |
| 3248 | u8 dev_type[8] = {0x00}; |
| 3249 | uint dev_type_len = 0; |
| 3250 | u8 dev_type_str[17 + 9] = {0x00}; /* +9 is for the str "dev_type =", we have to clear it at wrqu->data.pointer */ |
| 3251 | |
| 3252 | /* Commented by Albert 20121209 */ |
| 3253 | /* The input data is the MAC address which the application wants to know its device type. */ |
| 3254 | /* Such user interface could know the device type. */ |
| 3255 | /* Format: iwpriv wlanx p2p_get2 dev_type = 00:E0:4C:00:00:05 */ |
| 3256 | |
| 3257 | DBG_88E("[%s] data = %s\n", __func__, (char *)extra); |
| 3258 | if (copy_from_user(peerMACStr, wrqu->data.pointer + 9, 17)) |
| 3259 | return -EFAULT; |
| 3260 | |
| 3261 | for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) |
| 3262 | peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); |
| 3263 | |
Larry Finger | 7057dcb | 2013-12-19 22:38:34 -0600 | [diff] [blame] | 3264 | spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3265 | |
| 3266 | phead = get_list_head(queue); |
| 3267 | plist = get_next(phead); |
| 3268 | |
| 3269 | while (1) { |
| 3270 | if (rtw_end_of_queue_search(phead, plist) == true) |
| 3271 | break; |
| 3272 | |
| 3273 | pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); |
| 3274 | if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { |
| 3275 | u8 *wpsie; |
| 3276 | uint wpsie_len = 0; |
| 3277 | |
| 3278 | /* The mac address is matched. */ |
| 3279 | |
| 3280 | wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], |
| 3281 | pnetwork->network.IELength - 12, |
| 3282 | NULL, &wpsie_len); |
| 3283 | if (wpsie) { |
| 3284 | rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_PRIMARY_DEV_TYPE, dev_type, &dev_type_len); |
| 3285 | if (dev_type_len) { |
| 3286 | u16 type = 0; |
| 3287 | __be16 be_tmp; |
| 3288 | |
| 3289 | memcpy(&be_tmp, dev_type, 2); |
| 3290 | type = be16_to_cpu(be_tmp); |
| 3291 | sprintf(dev_type_str, "\n\nN =%.2d", type); |
| 3292 | blnMatch = 1; |
| 3293 | } |
| 3294 | } |
| 3295 | break; |
| 3296 | } |
| 3297 | |
| 3298 | plist = get_next(plist); |
| 3299 | } |
| 3300 | |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 3301 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3302 | |
| 3303 | if (!blnMatch) |
| 3304 | sprintf(dev_type_str, "\n\nN = 00"); |
| 3305 | |
| 3306 | if (copy_to_user(wrqu->data.pointer, dev_type_str, 9 + 17)) { |
| 3307 | return -EFAULT; |
| 3308 | } |
| 3309 | |
| 3310 | return ret; |
| 3311 | } |
| 3312 | |
| 3313 | static int rtw_p2p_get_device_name(struct net_device *dev, |
| 3314 | struct iw_request_info *info, |
| 3315 | union iwreq_data *wrqu, char *extra) |
| 3316 | { |
| 3317 | int ret = 0; |
| 3318 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3319 | u8 peerMAC[ETH_ALEN] = {0x00}; |
| 3320 | int jj, kk; |
| 3321 | u8 peerMACStr[17] = {0x00}; |
| 3322 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3323 | struct list_head *plist, *phead; |
| 3324 | struct __queue *queue = &(pmlmepriv->scanned_queue); |
| 3325 | struct wlan_network *pnetwork = NULL; |
| 3326 | u8 blnMatch = 0; |
| 3327 | u8 dev_name[WPS_MAX_DEVICE_NAME_LEN] = {0x00}; |
| 3328 | uint dev_len = 0; |
| 3329 | u8 dev_name_str[WPS_MAX_DEVICE_NAME_LEN + 5] = {0x00}; /* +5 is for the str "devN =", we have to clear it at wrqu->data.pointer */ |
| 3330 | |
| 3331 | /* Commented by Albert 20121225 */ |
| 3332 | /* The input data is the MAC address which the application wants to know its device name. */ |
| 3333 | /* Such user interface could show peer device's device name instead of ssid. */ |
| 3334 | /* Format: iwpriv wlanx p2p_get2 devN = 00:E0:4C:00:00:05 */ |
| 3335 | |
| 3336 | DBG_88E("[%s] data = %s\n", __func__, (char *)extra); |
| 3337 | if (copy_from_user(peerMACStr, wrqu->data.pointer + 5, 17)) |
| 3338 | return -EFAULT; |
| 3339 | |
| 3340 | for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) |
| 3341 | peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); |
| 3342 | |
Larry Finger | 7057dcb | 2013-12-19 22:38:34 -0600 | [diff] [blame] | 3343 | spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3344 | |
| 3345 | phead = get_list_head(queue); |
| 3346 | plist = get_next(phead); |
| 3347 | |
| 3348 | while (1) { |
| 3349 | if (rtw_end_of_queue_search(phead, plist) == true) |
| 3350 | break; |
| 3351 | |
| 3352 | pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); |
| 3353 | if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { |
| 3354 | u8 *wpsie; |
| 3355 | uint wpsie_len = 0; |
| 3356 | |
| 3357 | /* The mac address is matched. */ |
| 3358 | wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &wpsie_len); |
| 3359 | if (wpsie) { |
| 3360 | rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_DEVICE_NAME, dev_name, &dev_len); |
| 3361 | if (dev_len) { |
| 3362 | sprintf(dev_name_str, "\n\nN =%s", dev_name); |
| 3363 | blnMatch = 1; |
| 3364 | } |
| 3365 | } |
| 3366 | break; |
| 3367 | } |
| 3368 | |
| 3369 | plist = get_next(plist); |
| 3370 | } |
| 3371 | |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 3372 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3373 | |
| 3374 | if (!blnMatch) |
| 3375 | sprintf(dev_name_str, "\n\nN = 0000"); |
| 3376 | |
| 3377 | if (copy_to_user(wrqu->data.pointer, dev_name_str, 5 + ((dev_len > 17) ? dev_len : 17))) |
| 3378 | return -EFAULT; |
| 3379 | return ret; |
| 3380 | } |
| 3381 | |
| 3382 | static int rtw_p2p_get_invitation_procedure(struct net_device *dev, |
| 3383 | struct iw_request_info *info, |
| 3384 | union iwreq_data *wrqu, char *extra) |
| 3385 | { |
| 3386 | int ret = 0; |
| 3387 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3388 | u8 peerMAC[ETH_ALEN] = {0x00}; |
| 3389 | int jj, kk; |
| 3390 | u8 peerMACStr[17] = {0x00}; |
| 3391 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3392 | struct list_head *plist, *phead; |
| 3393 | struct __queue *queue = &(pmlmepriv->scanned_queue); |
| 3394 | struct wlan_network *pnetwork = NULL; |
| 3395 | u8 blnMatch = 0; |
| 3396 | u8 *p2pie; |
| 3397 | uint p2pielen = 0, attr_contentlen = 0; |
| 3398 | u8 attr_content[2] = {0x00}; |
| 3399 | |
| 3400 | u8 inv_proc_str[17 + 8] = {0x00}; |
| 3401 | /* +8 is for the str "InvProc =", we have to clear it at wrqu->data.pointer */ |
| 3402 | |
| 3403 | /* Commented by Ouden 20121226 */ |
Masanari Iida | 7efc02c | 2013-09-27 00:11:46 +0900 | [diff] [blame] | 3404 | /* The application wants to know P2P initiation procedure is supported or not. */ |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3405 | /* Format: iwpriv wlanx p2p_get2 InvProc = 00:E0:4C:00:00:05 */ |
| 3406 | |
| 3407 | DBG_88E("[%s] data = %s\n", __func__, (char *)extra); |
| 3408 | if (copy_from_user(peerMACStr, wrqu->data.pointer + 8, 17)) |
| 3409 | return -EFAULT; |
| 3410 | |
| 3411 | for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) |
| 3412 | peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); |
| 3413 | |
Larry Finger | 7057dcb | 2013-12-19 22:38:34 -0600 | [diff] [blame] | 3414 | spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3415 | |
| 3416 | phead = get_list_head(queue); |
| 3417 | plist = get_next(phead); |
| 3418 | |
| 3419 | while (1) { |
| 3420 | if (rtw_end_of_queue_search(phead, plist) == true) |
| 3421 | break; |
| 3422 | |
| 3423 | pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); |
| 3424 | if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { |
| 3425 | /* Commented by Albert 20121226 */ |
| 3426 | /* Match the device address located in the P2P IE */ |
| 3427 | /* This is for the case that the P2P device address is not the same as the P2P interface address. */ |
| 3428 | |
| 3429 | p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); |
| 3430 | if (p2pie) { |
| 3431 | while (p2pie) { |
| 3432 | if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_CAPABILITY, attr_content, &attr_contentlen)) { |
| 3433 | /* Handle the P2P capability attribute */ |
| 3434 | blnMatch = 1; |
| 3435 | break; |
| 3436 | } |
| 3437 | |
| 3438 | /* Get the next P2P IE */ |
| 3439 | p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); |
| 3440 | } |
| 3441 | } |
| 3442 | } |
| 3443 | plist = get_next(plist); |
| 3444 | } |
| 3445 | |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 3446 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3447 | |
| 3448 | if (!blnMatch) { |
| 3449 | sprintf(inv_proc_str, "\nIP =-1"); |
| 3450 | } else { |
| 3451 | if (attr_content[0] & 0x20) |
| 3452 | sprintf(inv_proc_str, "\nIP = 1"); |
| 3453 | else |
| 3454 | sprintf(inv_proc_str, "\nIP = 0"); |
| 3455 | } |
| 3456 | if (copy_to_user(wrqu->data.pointer, inv_proc_str, 8 + 17)) |
| 3457 | return -EFAULT; |
| 3458 | return ret; |
| 3459 | } |
| 3460 | |
| 3461 | static int rtw_p2p_connect(struct net_device *dev, |
| 3462 | struct iw_request_info *info, |
| 3463 | union iwreq_data *wrqu, char *extra) |
| 3464 | { |
| 3465 | int ret = 0; |
| 3466 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3467 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 3468 | u8 peerMAC[ETH_ALEN] = {0x00}; |
| 3469 | int jj, kk; |
| 3470 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3471 | struct list_head *plist, *phead; |
| 3472 | struct __queue *queue = &(pmlmepriv->scanned_queue); |
| 3473 | struct wlan_network *pnetwork = NULL; |
| 3474 | uint uintPeerChannel = 0; |
| 3475 | |
| 3476 | /* Commented by Albert 20110304 */ |
| 3477 | /* The input data contains two informations. */ |
| 3478 | /* 1. First information is the MAC address which wants to formate with */ |
| 3479 | /* 2. Second information is the WPS PINCode or "pbc" string for push button method */ |
| 3480 | /* Format: 00:E0:4C:00:00:05 */ |
| 3481 | /* Format: 00:E0:4C:00:00:05 */ |
| 3482 | |
| 3483 | DBG_88E("[%s] data = %s\n", __func__, extra); |
| 3484 | |
| 3485 | if (pwdinfo->p2p_state == P2P_STATE_NONE) { |
| 3486 | DBG_88E("[%s] WiFi Direct is disable!\n", __func__); |
| 3487 | return ret; |
| 3488 | } |
| 3489 | |
| 3490 | if (pwdinfo->ui_got_wps_info == P2P_NO_WPSINFO) |
| 3491 | return -1; |
| 3492 | |
| 3493 | for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) |
| 3494 | peerMAC[jj] = key_2char2num(extra[kk], extra[kk + 1]); |
| 3495 | |
Larry Finger | 7057dcb | 2013-12-19 22:38:34 -0600 | [diff] [blame] | 3496 | spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3497 | |
| 3498 | phead = get_list_head(queue); |
| 3499 | plist = get_next(phead); |
| 3500 | |
| 3501 | while (1) { |
| 3502 | if (rtw_end_of_queue_search(phead, plist) == true) |
| 3503 | break; |
| 3504 | |
| 3505 | pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); |
| 3506 | if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { |
| 3507 | uintPeerChannel = pnetwork->network.Configuration.DSConfig; |
| 3508 | break; |
| 3509 | } |
| 3510 | |
| 3511 | plist = get_next(plist); |
| 3512 | } |
| 3513 | |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 3514 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3515 | |
| 3516 | if (uintPeerChannel) { |
| 3517 | _rtw_memset(&pwdinfo->nego_req_info, 0x00, sizeof(struct tx_nego_req_info)); |
| 3518 | _rtw_memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info)); |
| 3519 | |
| 3520 | pwdinfo->nego_req_info.peer_channel_num[0] = uintPeerChannel; |
| 3521 | memcpy(pwdinfo->nego_req_info.peerDevAddr, pnetwork->network.MacAddress, ETH_ALEN); |
| 3522 | pwdinfo->nego_req_info.benable = true; |
| 3523 | |
| 3524 | _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); |
| 3525 | if (rtw_p2p_state(pwdinfo) != P2P_STATE_GONEGO_OK) { |
| 3526 | /* Restore to the listen state if the current p2p state is not nego OK */ |
| 3527 | rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); |
| 3528 | } |
| 3529 | |
| 3530 | rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); |
| 3531 | rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_ING); |
| 3532 | |
| 3533 | DBG_88E("[%s] Start PreTx Procedure!\n", __func__); |
| 3534 | _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); |
| 3535 | _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_GO_NEGO_TIMEOUT); |
| 3536 | } else { |
| 3537 | DBG_88E("[%s] Not Found in Scanning Queue~\n", __func__); |
| 3538 | ret = -1; |
| 3539 | } |
| 3540 | return ret; |
| 3541 | } |
| 3542 | |
| 3543 | static int rtw_p2p_invite_req(struct net_device *dev, |
| 3544 | struct iw_request_info *info, |
| 3545 | union iwreq_data *wrqu, char *extra) |
| 3546 | { |
| 3547 | int ret = 0; |
| 3548 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3549 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 3550 | int jj, kk; |
| 3551 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 3552 | struct list_head *plist, *phead; |
| 3553 | struct __queue *queue = &(pmlmepriv->scanned_queue); |
| 3554 | struct wlan_network *pnetwork = NULL; |
| 3555 | uint uintPeerChannel = 0; |
| 3556 | u8 attr_content[50] = {0x00}; |
| 3557 | u8 *p2pie; |
| 3558 | uint p2pielen = 0, attr_contentlen = 0; |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3559 | struct tx_invite_req_info *pinvite_req_info = &pwdinfo->invitereq_info; |
| 3560 | |
| 3561 | /* The input data contains two informations. */ |
| 3562 | /* 1. First information is the P2P device address which you want to send to. */ |
| 3563 | /* 2. Second information is the group id which combines with GO's mac address, space and GO's ssid. */ |
| 3564 | /* Command line sample: iwpriv wlan0 p2p_set invite ="00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy" */ |
| 3565 | /* Format: 00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy */ |
| 3566 | |
| 3567 | DBG_88E("[%s] data = %s\n", __func__, extra); |
| 3568 | |
| 3569 | if (wrqu->data.length <= 37) { |
| 3570 | DBG_88E("[%s] Wrong format!\n", __func__); |
| 3571 | return ret; |
| 3572 | } |
| 3573 | |
| 3574 | if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { |
| 3575 | DBG_88E("[%s] WiFi Direct is disable!\n", __func__); |
| 3576 | return ret; |
| 3577 | } else { |
| 3578 | /* Reset the content of struct tx_invite_req_info */ |
| 3579 | pinvite_req_info->benable = false; |
| 3580 | _rtw_memset(pinvite_req_info->go_bssid, 0x00, ETH_ALEN); |
| 3581 | _rtw_memset(pinvite_req_info->go_ssid, 0x00, WLAN_SSID_MAXLEN); |
| 3582 | pinvite_req_info->ssidlen = 0x00; |
| 3583 | pinvite_req_info->operating_ch = pwdinfo->operating_channel; |
| 3584 | _rtw_memset(pinvite_req_info->peer_macaddr, 0x00, ETH_ALEN); |
| 3585 | pinvite_req_info->token = 3; |
| 3586 | } |
| 3587 | |
| 3588 | for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) |
| 3589 | pinvite_req_info->peer_macaddr[jj] = key_2char2num(extra[kk], extra[kk + 1]); |
| 3590 | |
Larry Finger | 7057dcb | 2013-12-19 22:38:34 -0600 | [diff] [blame] | 3591 | spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3592 | |
| 3593 | phead = get_list_head(queue); |
| 3594 | plist = get_next(phead); |
| 3595 | |
| 3596 | while (1) { |
| 3597 | if (rtw_end_of_queue_search(phead, plist) == true) |
| 3598 | break; |
| 3599 | |
| 3600 | pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); |
| 3601 | |
| 3602 | /* Commented by Albert 2011/05/18 */ |
| 3603 | /* Match the device address located in the P2P IE */ |
| 3604 | /* This is for the case that the P2P device address is not the same as the P2P interface address. */ |
| 3605 | |
| 3606 | p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); |
| 3607 | if (p2pie) { |
| 3608 | /* The P2P Device ID attribute is included in the Beacon frame. */ |
| 3609 | /* The P2P Device Info attribute is included in the probe response frame. */ |
| 3610 | |
| 3611 | if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) { |
| 3612 | /* Handle the P2P Device ID attribute of Beacon first */ |
| 3613 | if (!memcmp(attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN)) { |
| 3614 | uintPeerChannel = pnetwork->network.Configuration.DSConfig; |
| 3615 | break; |
| 3616 | } |
| 3617 | } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) { |
| 3618 | /* Handle the P2P Device Info attribute of probe response */ |
| 3619 | if (!memcmp(attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN)) { |
| 3620 | uintPeerChannel = pnetwork->network.Configuration.DSConfig; |
| 3621 | break; |
| 3622 | } |
| 3623 | } |
| 3624 | } |
| 3625 | plist = get_next(plist); |
| 3626 | } |
| 3627 | |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 3628 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3629 | |
| 3630 | if (uintPeerChannel) { |
| 3631 | /* Store the GO's bssid */ |
| 3632 | for (jj = 0, kk = 18; jj < ETH_ALEN; jj++, kk += 3) |
| 3633 | pinvite_req_info->go_bssid[jj] = key_2char2num(extra[kk], extra[kk + 1]); |
| 3634 | |
| 3635 | /* Store the GO's ssid */ |
| 3636 | pinvite_req_info->ssidlen = wrqu->data.length - 36; |
| 3637 | memcpy(pinvite_req_info->go_ssid, &extra[36], (u32) pinvite_req_info->ssidlen); |
| 3638 | pinvite_req_info->benable = true; |
| 3639 | pinvite_req_info->peer_ch = uintPeerChannel; |
| 3640 | |
| 3641 | rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); |
| 3642 | rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_INVITE_REQ); |
| 3643 | |
| 3644 | set_channel_bwmode(padapter, uintPeerChannel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); |
| 3645 | |
| 3646 | _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); |
| 3647 | |
| 3648 | _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_INVITE_TIMEOUT); |
| 3649 | } else { |
| 3650 | DBG_88E("[%s] NOT Found in the Scanning Queue!\n", __func__); |
| 3651 | } |
| 3652 | return ret; |
| 3653 | } |
| 3654 | |
| 3655 | static int rtw_p2p_set_persistent(struct net_device *dev, |
| 3656 | struct iw_request_info *info, |
| 3657 | union iwreq_data *wrqu, char *extra) |
| 3658 | { |
| 3659 | int ret = 0; |
| 3660 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3661 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 3662 | |
| 3663 | /* The input data is 0 or 1 */ |
| 3664 | /* 0: disable persistent group functionality */ |
| 3665 | /* 1: enable persistent group founctionality */ |
| 3666 | |
| 3667 | DBG_88E("[%s] data = %s\n", __func__, extra); |
| 3668 | |
| 3669 | if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { |
| 3670 | DBG_88E("[%s] WiFi Direct is disable!\n", __func__); |
| 3671 | return ret; |
| 3672 | } else { |
| 3673 | if (extra[0] == '0') /* Disable the persistent group function. */ |
| 3674 | pwdinfo->persistent_supported = false; |
| 3675 | else if (extra[0] == '1') /* Enable the persistent group function. */ |
| 3676 | pwdinfo->persistent_supported = true; |
| 3677 | else |
| 3678 | pwdinfo->persistent_supported = false; |
| 3679 | } |
| 3680 | pr_info("[%s] persistent_supported = %d\n", __func__, pwdinfo->persistent_supported); |
| 3681 | return ret; |
| 3682 | } |
| 3683 | |
| 3684 | static int rtw_p2p_prov_disc(struct net_device *dev, |
| 3685 | struct iw_request_info *info, |
| 3686 | union iwreq_data *wrqu, char *extra) |
| 3687 | { |
| 3688 | int ret = 0; |
| 3689 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3690 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 3691 | u8 peerMAC[ETH_ALEN] = {0x00}; |
| 3692 | int jj, kk; |
| 3693 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 3694 | struct list_head *plist, *phead; |
| 3695 | struct __queue *queue = &(pmlmepriv->scanned_queue); |
| 3696 | struct wlan_network *pnetwork = NULL; |
| 3697 | uint uintPeerChannel = 0; |
| 3698 | u8 attr_content[100] = {0x00}; |
| 3699 | u8 *p2pie; |
| 3700 | uint p2pielen = 0, attr_contentlen = 0; |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3701 | |
| 3702 | /* The input data contains two informations. */ |
| 3703 | /* 1. First information is the MAC address which wants to issue the provisioning discovery request frame. */ |
| 3704 | /* 2. Second information is the WPS configuration method which wants to discovery */ |
| 3705 | /* Format: 00:E0:4C:00:00:05_display */ |
| 3706 | /* Format: 00:E0:4C:00:00:05_keypad */ |
| 3707 | /* Format: 00:E0:4C:00:00:05_pbc */ |
| 3708 | /* Format: 00:E0:4C:00:00:05_label */ |
| 3709 | |
| 3710 | DBG_88E("[%s] data = %s\n", __func__, extra); |
| 3711 | |
| 3712 | if (pwdinfo->p2p_state == P2P_STATE_NONE) { |
| 3713 | DBG_88E("[%s] WiFi Direct is disable!\n", __func__); |
| 3714 | return ret; |
| 3715 | } else { |
| 3716 | /* Reset the content of struct tx_provdisc_req_info excluded the wps_config_method_request. */ |
| 3717 | _rtw_memset(pwdinfo->tx_prov_disc_info.peerDevAddr, 0x00, ETH_ALEN); |
| 3718 | _rtw_memset(pwdinfo->tx_prov_disc_info.peerIFAddr, 0x00, ETH_ALEN); |
| 3719 | _rtw_memset(&pwdinfo->tx_prov_disc_info.ssid, 0x00, sizeof(struct ndis_802_11_ssid)); |
| 3720 | pwdinfo->tx_prov_disc_info.peer_channel_num[0] = 0; |
| 3721 | pwdinfo->tx_prov_disc_info.peer_channel_num[1] = 0; |
| 3722 | pwdinfo->tx_prov_disc_info.benable = false; |
| 3723 | } |
| 3724 | |
| 3725 | for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) |
| 3726 | peerMAC[jj] = key_2char2num(extra[kk], extra[kk + 1]); |
| 3727 | |
| 3728 | if (!memcmp(&extra[18], "display", 7)) { |
| 3729 | pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_DISPLYA; |
| 3730 | } else if (!memcmp(&extra[18], "keypad", 7)) { |
| 3731 | pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_KEYPAD; |
| 3732 | } else if (!memcmp(&extra[18], "pbc", 3)) { |
| 3733 | pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_PUSH_BUTTON; |
| 3734 | } else if (!memcmp(&extra[18], "label", 5)) { |
| 3735 | pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_LABEL; |
| 3736 | } else { |
| 3737 | DBG_88E("[%s] Unknown WPS config methodn", __func__); |
| 3738 | return ret; |
| 3739 | } |
| 3740 | |
Larry Finger | 7057dcb | 2013-12-19 22:38:34 -0600 | [diff] [blame] | 3741 | spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3742 | |
| 3743 | phead = get_list_head(queue); |
| 3744 | plist = get_next(phead); |
| 3745 | |
| 3746 | while (1) { |
| 3747 | if (rtw_end_of_queue_search(phead, plist) == true) |
| 3748 | break; |
| 3749 | |
| 3750 | if (uintPeerChannel != 0) |
| 3751 | break; |
| 3752 | |
| 3753 | pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); |
| 3754 | |
| 3755 | /* Commented by Albert 2011/05/18 */ |
| 3756 | /* Match the device address located in the P2P IE */ |
| 3757 | /* This is for the case that the P2P device address is not the same as the P2P interface address. */ |
| 3758 | |
| 3759 | p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); |
| 3760 | if (p2pie) { |
| 3761 | while (p2pie) { |
| 3762 | /* The P2P Device ID attribute is included in the Beacon frame. */ |
| 3763 | /* The P2P Device Info attribute is included in the probe response frame. */ |
| 3764 | |
| 3765 | if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) { |
| 3766 | /* Handle the P2P Device ID attribute of Beacon first */ |
| 3767 | if (!memcmp(attr_content, peerMAC, ETH_ALEN)) { |
| 3768 | uintPeerChannel = pnetwork->network.Configuration.DSConfig; |
| 3769 | break; |
| 3770 | } |
| 3771 | } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) { |
| 3772 | /* Handle the P2P Device Info attribute of probe response */ |
| 3773 | if (!memcmp(attr_content, peerMAC, ETH_ALEN)) { |
| 3774 | uintPeerChannel = pnetwork->network.Configuration.DSConfig; |
| 3775 | break; |
| 3776 | } |
| 3777 | } |
| 3778 | |
| 3779 | /* Get the next P2P IE */ |
| 3780 | p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); |
| 3781 | } |
| 3782 | } |
| 3783 | |
| 3784 | plist = get_next(plist); |
| 3785 | } |
| 3786 | |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 3787 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 3788 | |
| 3789 | if (uintPeerChannel) { |
| 3790 | DBG_88E("[%s] peer channel: %d!\n", __func__, uintPeerChannel); |
| 3791 | memcpy(pwdinfo->tx_prov_disc_info.peerIFAddr, pnetwork->network.MacAddress, ETH_ALEN); |
| 3792 | memcpy(pwdinfo->tx_prov_disc_info.peerDevAddr, peerMAC, ETH_ALEN); |
| 3793 | pwdinfo->tx_prov_disc_info.peer_channel_num[0] = (u16) uintPeerChannel; |
| 3794 | pwdinfo->tx_prov_disc_info.benable = true; |
| 3795 | rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); |
| 3796 | rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ); |
| 3797 | |
| 3798 | if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { |
| 3799 | memcpy(&pwdinfo->tx_prov_disc_info.ssid, &pnetwork->network.Ssid, sizeof(struct ndis_802_11_ssid)); |
| 3800 | } else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { |
| 3801 | memcpy(pwdinfo->tx_prov_disc_info.ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN); |
| 3802 | pwdinfo->tx_prov_disc_info.ssid.SsidLength = P2P_WILDCARD_SSID_LEN; |
| 3803 | } |
| 3804 | |
| 3805 | set_channel_bwmode(padapter, uintPeerChannel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); |
| 3806 | |
| 3807 | _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); |
| 3808 | |
| 3809 | _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT); |
| 3810 | } else { |
| 3811 | DBG_88E("[%s] NOT Found in the Scanning Queue!\n", __func__); |
| 3812 | } |
| 3813 | return ret; |
| 3814 | } |
| 3815 | |
| 3816 | /* This function is used to inform the driver the user had specified the pin code value or pbc */ |
| 3817 | /* to application. */ |
| 3818 | |
| 3819 | static int rtw_p2p_got_wpsinfo(struct net_device *dev, |
| 3820 | struct iw_request_info *info, |
| 3821 | union iwreq_data *wrqu, char *extra) |
| 3822 | { |
| 3823 | int ret = 0; |
| 3824 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3825 | struct wifidirect_info *pwdinfo = &(padapter->wdinfo); |
| 3826 | |
| 3827 | DBG_88E("[%s] data = %s\n", __func__, extra); |
| 3828 | /* Added by Albert 20110328 */ |
| 3829 | /* if the input data is P2P_NO_WPSINFO -> reset the wpsinfo */ |
| 3830 | /* if the input data is P2P_GOT_WPSINFO_PEER_DISPLAY_PIN -> the utility just input the PIN code got from the peer P2P device. */ |
| 3831 | /* if the input data is P2P_GOT_WPSINFO_SELF_DISPLAY_PIN -> the utility just got the PIN code from itself. */ |
| 3832 | /* if the input data is P2P_GOT_WPSINFO_PBC -> the utility just determine to use the PBC */ |
| 3833 | |
| 3834 | if (*extra == '0') |
| 3835 | pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO; |
| 3836 | else if (*extra == '1') |
| 3837 | pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_PEER_DISPLAY_PIN; |
| 3838 | else if (*extra == '2') |
| 3839 | pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_SELF_DISPLAY_PIN; |
| 3840 | else if (*extra == '3') |
| 3841 | pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_PBC; |
| 3842 | else |
| 3843 | pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO; |
| 3844 | return ret; |
| 3845 | } |
| 3846 | |
| 3847 | #endif /* CONFIG_88EU_P2P */ |
| 3848 | |
| 3849 | static int rtw_p2p_set(struct net_device *dev, |
| 3850 | struct iw_request_info *info, |
| 3851 | union iwreq_data *wrqu, char *extra) |
| 3852 | { |
| 3853 | int ret = 0; |
| 3854 | |
| 3855 | #ifdef CONFIG_88EU_P2P |
| 3856 | DBG_88E("[%s] extra = %s\n", __func__, extra); |
| 3857 | if (!memcmp(extra, "enable =", 7)) { |
| 3858 | rtw_wext_p2p_enable(dev, info, wrqu, &extra[7]); |
| 3859 | } else if (!memcmp(extra, "setDN =", 6)) { |
| 3860 | wrqu->data.length -= 6; |
| 3861 | rtw_p2p_setDN(dev, info, wrqu, &extra[6]); |
| 3862 | } else if (!memcmp(extra, "profilefound =", 13)) { |
| 3863 | wrqu->data.length -= 13; |
| 3864 | rtw_p2p_profilefound(dev, info, wrqu, &extra[13]); |
| 3865 | } else if (!memcmp(extra, "prov_disc =", 10)) { |
| 3866 | wrqu->data.length -= 10; |
| 3867 | rtw_p2p_prov_disc(dev, info, wrqu, &extra[10]); |
| 3868 | } else if (!memcmp(extra, "nego =", 5)) { |
| 3869 | wrqu->data.length -= 5; |
| 3870 | rtw_p2p_connect(dev, info, wrqu, &extra[5]); |
| 3871 | } else if (!memcmp(extra, "intent =", 7)) { |
| 3872 | /* Commented by Albert 2011/03/23 */ |
| 3873 | /* The wrqu->data.length will include the null character */ |
| 3874 | /* So, we will decrease 7 + 1 */ |
| 3875 | wrqu->data.length -= 8; |
| 3876 | rtw_p2p_set_intent(dev, info, wrqu, &extra[7]); |
| 3877 | } else if (!memcmp(extra, "ssid =", 5)) { |
| 3878 | wrqu->data.length -= 5; |
| 3879 | rtw_p2p_set_go_nego_ssid(dev, info, wrqu, &extra[5]); |
| 3880 | } else if (!memcmp(extra, "got_wpsinfo =", 12)) { |
| 3881 | wrqu->data.length -= 12; |
| 3882 | rtw_p2p_got_wpsinfo(dev, info, wrqu, &extra[12]); |
| 3883 | } else if (!memcmp(extra, "listen_ch =", 10)) { |
| 3884 | /* Commented by Albert 2011/05/24 */ |
| 3885 | /* The wrqu->data.length will include the null character */ |
| 3886 | /* So, we will decrease (10 + 1) */ |
| 3887 | wrqu->data.length -= 11; |
| 3888 | rtw_p2p_set_listen_ch(dev, info, wrqu, &extra[10]); |
| 3889 | } else if (!memcmp(extra, "op_ch =", 6)) { |
| 3890 | /* Commented by Albert 2011/05/24 */ |
| 3891 | /* The wrqu->data.length will include the null character */ |
| 3892 | /* So, we will decrease (6 + 1) */ |
| 3893 | wrqu->data.length -= 7; |
| 3894 | rtw_p2p_set_op_ch(dev, info, wrqu, &extra[6]); |
| 3895 | } else if (!memcmp(extra, "invite =", 7)) { |
| 3896 | wrqu->data.length -= 8; |
| 3897 | rtw_p2p_invite_req(dev, info, wrqu, &extra[7]); |
| 3898 | } else if (!memcmp(extra, "persistent =", 11)) { |
| 3899 | wrqu->data.length -= 11; |
| 3900 | rtw_p2p_set_persistent(dev, info, wrqu, &extra[11]); |
| 3901 | } |
| 3902 | #endif /* CONFIG_88EU_P2P */ |
| 3903 | |
| 3904 | return ret; |
| 3905 | } |
| 3906 | |
| 3907 | static int rtw_p2p_get(struct net_device *dev, |
| 3908 | struct iw_request_info *info, |
| 3909 | union iwreq_data *wrqu, char *extra) |
| 3910 | { |
| 3911 | int ret = 0; |
| 3912 | |
| 3913 | #ifdef CONFIG_88EU_P2P |
| 3914 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3915 | |
| 3916 | if (padapter->bShowGetP2PState) |
| 3917 | DBG_88E("[%s] extra = %s\n", __func__, (char *)wrqu->data.pointer); |
| 3918 | if (!memcmp(wrqu->data.pointer, "status", 6)) { |
| 3919 | rtw_p2p_get_status(dev, info, wrqu, extra); |
| 3920 | } else if (!memcmp(wrqu->data.pointer, "role", 4)) { |
| 3921 | rtw_p2p_get_role(dev, info, wrqu, extra); |
| 3922 | } else if (!memcmp(wrqu->data.pointer, "peer_ifa", 8)) { |
| 3923 | rtw_p2p_get_peer_ifaddr(dev, info, wrqu, extra); |
| 3924 | } else if (!memcmp(wrqu->data.pointer, "req_cm", 6)) { |
| 3925 | rtw_p2p_get_req_cm(dev, info, wrqu, extra); |
| 3926 | } else if (!memcmp(wrqu->data.pointer, "peer_deva", 9)) { |
| 3927 | /* Get the P2P device address when receiving the provision discovery request frame. */ |
| 3928 | rtw_p2p_get_peer_devaddr(dev, info, wrqu, extra); |
| 3929 | } else if (!memcmp(wrqu->data.pointer, "group_id", 8)) { |
| 3930 | rtw_p2p_get_groupid(dev, info, wrqu, extra); |
| 3931 | } else if (!memcmp(wrqu->data.pointer, "peer_deva_inv", 9)) { |
| 3932 | /* Get the P2P device address when receiving the P2P Invitation request frame. */ |
| 3933 | rtw_p2p_get_peer_devaddr_by_invitation(dev, info, wrqu, extra); |
| 3934 | } else if (!memcmp(wrqu->data.pointer, "op_ch", 5)) { |
| 3935 | rtw_p2p_get_op_ch(dev, info, wrqu, extra); |
| 3936 | } |
| 3937 | #endif /* CONFIG_88EU_P2P */ |
| 3938 | return ret; |
| 3939 | } |
| 3940 | |
| 3941 | static int rtw_p2p_get2(struct net_device *dev, |
| 3942 | struct iw_request_info *info, |
| 3943 | union iwreq_data *wrqu, char *extra) |
| 3944 | { |
| 3945 | int ret = 0; |
| 3946 | |
| 3947 | #ifdef CONFIG_88EU_P2P |
| 3948 | DBG_88E("[%s] extra = %s\n", __func__, (char *)wrqu->data.pointer); |
| 3949 | if (!memcmp(extra, "wpsCM =", 6)) { |
| 3950 | wrqu->data.length -= 6; |
| 3951 | rtw_p2p_get_wps_configmethod(dev, info, wrqu, &extra[6]); |
| 3952 | } else if (!memcmp(extra, "devN =", 5)) { |
| 3953 | wrqu->data.length -= 5; |
| 3954 | rtw_p2p_get_device_name(dev, info, wrqu, &extra[5]); |
| 3955 | } else if (!memcmp(extra, "dev_type =", 9)) { |
| 3956 | wrqu->data.length -= 9; |
| 3957 | rtw_p2p_get_device_type(dev, info, wrqu, &extra[9]); |
| 3958 | } else if (!memcmp(extra, "go_devadd =", 10)) { |
| 3959 | wrqu->data.length -= 10; |
| 3960 | rtw_p2p_get_go_device_address(dev, info, wrqu, &extra[10]); |
| 3961 | } else if (!memcmp(extra, "InvProc =", 8)) { |
| 3962 | wrqu->data.length -= 8; |
| 3963 | rtw_p2p_get_invitation_procedure(dev, info, wrqu, &extra[8]); |
| 3964 | } |
| 3965 | |
| 3966 | #endif /* CONFIG_88EU_P2P */ |
| 3967 | |
| 3968 | return ret; |
| 3969 | } |
| 3970 | |
| 3971 | static int rtw_cta_test_start(struct net_device *dev, |
| 3972 | struct iw_request_info *info, |
| 3973 | union iwreq_data *wrqu, char *extra) |
| 3974 | { |
| 3975 | int ret = 0; |
| 3976 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 3977 | DBG_88E("%s %s\n", __func__, extra); |
| 3978 | if (!strcmp(extra, "1")) |
| 3979 | padapter->in_cta_test = 1; |
| 3980 | else |
| 3981 | padapter->in_cta_test = 0; |
| 3982 | |
| 3983 | if (padapter->in_cta_test) { |
| 3984 | u32 v = rtw_read32(padapter, REG_RCR); |
| 3985 | v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);/* RCR_ADF */ |
| 3986 | rtw_write32(padapter, REG_RCR, v); |
| 3987 | DBG_88E("enable RCR_ADF\n"); |
| 3988 | } else { |
| 3989 | u32 v = rtw_read32(padapter, REG_RCR); |
| 3990 | v |= RCR_CBSSID_DATA | RCR_CBSSID_BCN;/* RCR_ADF */ |
| 3991 | rtw_write32(padapter, REG_RCR, v); |
| 3992 | DBG_88E("disable RCR_ADF\n"); |
| 3993 | } |
| 3994 | return ret; |
| 3995 | } |
| 3996 | |
| 3997 | static int rtw_rereg_nd_name(struct net_device *dev, |
| 3998 | struct iw_request_info *info, |
| 3999 | union iwreq_data *wrqu, char *extra) |
| 4000 | { |
| 4001 | int ret = 0; |
| 4002 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 4003 | struct rereg_nd_name_data *rereg_priv = &padapter->rereg_nd_name_priv; |
| 4004 | char new_ifname[IFNAMSIZ]; |
| 4005 | |
| 4006 | if (rereg_priv->old_ifname[0] == 0) { |
| 4007 | char *reg_ifname; |
| 4008 | reg_ifname = padapter->registrypriv.if2name; |
| 4009 | |
| 4010 | strncpy(rereg_priv->old_ifname, reg_ifname, IFNAMSIZ); |
| 4011 | rereg_priv->old_ifname[IFNAMSIZ-1] = 0; |
| 4012 | } |
| 4013 | |
| 4014 | if (wrqu->data.length > IFNAMSIZ) |
| 4015 | return -EFAULT; |
| 4016 | |
| 4017 | if (copy_from_user(new_ifname, wrqu->data.pointer, IFNAMSIZ)) |
| 4018 | return -EFAULT; |
| 4019 | |
| 4020 | if (0 == strcmp(rereg_priv->old_ifname, new_ifname)) |
| 4021 | return ret; |
| 4022 | |
| 4023 | DBG_88E("%s new_ifname:%s\n", __func__, new_ifname); |
| 4024 | ret = rtw_change_ifname(padapter, new_ifname); |
| 4025 | if (0 != ret) |
| 4026 | goto exit; |
| 4027 | |
Larry Finger | dc14a62 | 2013-09-04 15:56:02 -0500 | [diff] [blame] | 4028 | if (!memcmp(rereg_priv->old_ifname, "disable%d", 9)) { |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 4029 | padapter->ledpriv.bRegUseLed = rereg_priv->old_bRegUseLed; |
| 4030 | rtw_hal_sw_led_init(padapter); |
| 4031 | rtw_ips_mode_req(&padapter->pwrctrlpriv, rereg_priv->old_ips_mode); |
| 4032 | } |
| 4033 | |
| 4034 | strncpy(rereg_priv->old_ifname, new_ifname, IFNAMSIZ); |
| 4035 | rereg_priv->old_ifname[IFNAMSIZ-1] = 0; |
| 4036 | |
Larry Finger | dc14a62 | 2013-09-04 15:56:02 -0500 | [diff] [blame] | 4037 | if (!memcmp(new_ifname, "disable%d", 9)) { |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 4038 | DBG_88E("%s disable\n", __func__); |
| 4039 | /* free network queue for Android's timming issue */ |
| 4040 | rtw_free_network_queue(padapter, true); |
| 4041 | |
| 4042 | /* close led */ |
| 4043 | rtw_led_control(padapter, LED_CTL_POWER_OFF); |
| 4044 | rereg_priv->old_bRegUseLed = padapter->ledpriv.bRegUseLed; |
| 4045 | padapter->ledpriv.bRegUseLed = false; |
| 4046 | rtw_hal_sw_led_deinit(padapter); |
| 4047 | |
| 4048 | /* the interface is being "disabled", we can do deeper IPS */ |
| 4049 | rereg_priv->old_ips_mode = rtw_get_ips_mode_req(&padapter->pwrctrlpriv); |
| 4050 | rtw_ips_mode_req(&padapter->pwrctrlpriv, IPS_NORMAL); |
| 4051 | } |
| 4052 | exit: |
| 4053 | return ret; |
| 4054 | } |
| 4055 | |
| 4056 | static void mac_reg_dump(struct adapter *padapter) |
| 4057 | { |
| 4058 | int i, j = 1; |
| 4059 | pr_info("\n ======= MAC REG =======\n"); |
| 4060 | for (i = 0x0; i < 0x300; i += 4) { |
| 4061 | if (j%4 == 1) |
| 4062 | pr_info("0x%02x", i); |
| 4063 | pr_info(" 0x%08x ", rtw_read32(padapter, i)); |
| 4064 | if ((j++)%4 == 0) |
| 4065 | pr_info("\n"); |
| 4066 | } |
| 4067 | for (i = 0x400; i < 0x800; i += 4) { |
| 4068 | if (j%4 == 1) |
| 4069 | pr_info("0x%02x", i); |
| 4070 | pr_info(" 0x%08x ", rtw_read32(padapter, i)); |
| 4071 | if ((j++)%4 == 0) |
| 4072 | pr_info("\n"); |
| 4073 | } |
| 4074 | } |
| 4075 | |
| 4076 | static void bb_reg_dump(struct adapter *padapter) |
| 4077 | { |
| 4078 | int i, j = 1; |
| 4079 | pr_info("\n ======= BB REG =======\n"); |
| 4080 | for (i = 0x800; i < 0x1000; i += 4) { |
| 4081 | if (j%4 == 1) |
| 4082 | pr_info("0x%02x", i); |
| 4083 | |
| 4084 | pr_info(" 0x%08x ", rtw_read32(padapter, i)); |
| 4085 | if ((j++)%4 == 0) |
| 4086 | pr_info("\n"); |
| 4087 | } |
| 4088 | } |
| 4089 | |
| 4090 | static void rf_reg_dump(struct adapter *padapter) |
| 4091 | { |
| 4092 | int i, j = 1, path; |
| 4093 | u32 value; |
| 4094 | u8 rf_type, path_nums = 0; |
| 4095 | rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); |
| 4096 | |
| 4097 | pr_info("\n ======= RF REG =======\n"); |
| 4098 | if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) |
| 4099 | path_nums = 1; |
| 4100 | else |
| 4101 | path_nums = 2; |
| 4102 | |
| 4103 | for (path = 0; path < path_nums; path++) { |
| 4104 | pr_info("\nRF_Path(%x)\n", path); |
| 4105 | for (i = 0; i < 0x100; i++) { |
| 4106 | value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); |
| 4107 | if (j%4 == 1) |
| 4108 | pr_info("0x%02x ", i); |
| 4109 | pr_info(" 0x%08x ", value); |
| 4110 | if ((j++)%4 == 0) |
| 4111 | pr_info("\n"); |
| 4112 | } |
| 4113 | } |
| 4114 | } |
| 4115 | |
| 4116 | static int rtw_dbg_port(struct net_device *dev, |
| 4117 | struct iw_request_info *info, |
| 4118 | union iwreq_data *wrqu, char *extra) |
| 4119 | { |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 4120 | int ret = 0; |
| 4121 | u8 major_cmd, minor_cmd; |
| 4122 | u16 arg; |
| 4123 | s32 extra_arg; |
| 4124 | u32 *pdata, val32; |
| 4125 | struct sta_info *psta; |
| 4126 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 4127 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 4128 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 4129 | struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); |
| 4130 | struct security_priv *psecuritypriv = &padapter->securitypriv; |
| 4131 | struct wlan_network *cur_network = &(pmlmepriv->cur_network); |
| 4132 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 4133 | |
| 4134 | pdata = (u32 *)&wrqu->data; |
| 4135 | |
| 4136 | val32 = *pdata; |
| 4137 | arg = (u16)(val32 & 0x0000ffff); |
| 4138 | major_cmd = (u8)(val32 >> 24); |
| 4139 | minor_cmd = (u8)((val32 >> 16) & 0x00ff); |
| 4140 | |
| 4141 | extra_arg = *(pdata+1); |
| 4142 | |
| 4143 | switch (major_cmd) { |
| 4144 | case 0x70:/* read_reg */ |
| 4145 | switch (minor_cmd) { |
| 4146 | case 1: |
| 4147 | DBG_88E("rtw_read8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg)); |
| 4148 | break; |
| 4149 | case 2: |
| 4150 | DBG_88E("rtw_read16(0x%x) = 0x%04x\n", arg, rtw_read16(padapter, arg)); |
| 4151 | break; |
| 4152 | case 4: |
| 4153 | DBG_88E("rtw_read32(0x%x) = 0x%08x\n", arg, rtw_read32(padapter, arg)); |
| 4154 | break; |
| 4155 | } |
| 4156 | break; |
| 4157 | case 0x71:/* write_reg */ |
| 4158 | switch (minor_cmd) { |
| 4159 | case 1: |
| 4160 | rtw_write8(padapter, arg, extra_arg); |
| 4161 | DBG_88E("rtw_write8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg)); |
| 4162 | break; |
| 4163 | case 2: |
| 4164 | rtw_write16(padapter, arg, extra_arg); |
| 4165 | DBG_88E("rtw_write16(0x%x) = 0x%04x\n", arg, rtw_read16(padapter, arg)); |
| 4166 | break; |
| 4167 | case 4: |
| 4168 | rtw_write32(padapter, arg, extra_arg); |
| 4169 | DBG_88E("rtw_write32(0x%x) = 0x%08x\n", arg, rtw_read32(padapter, arg)); |
| 4170 | break; |
| 4171 | } |
| 4172 | break; |
| 4173 | case 0x72:/* read_bb */ |
| 4174 | DBG_88E("read_bbreg(0x%x) = 0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff)); |
| 4175 | break; |
| 4176 | case 0x73:/* write_bb */ |
| 4177 | rtw_hal_write_bbreg(padapter, arg, 0xffffffff, extra_arg); |
| 4178 | DBG_88E("write_bbreg(0x%x) = 0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff)); |
| 4179 | break; |
| 4180 | case 0x74:/* read_rf */ |
| 4181 | DBG_88E("read RF_reg path(0x%02x), offset(0x%x), value(0x%08x)\n", minor_cmd, arg, rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff)); |
| 4182 | break; |
| 4183 | case 0x75:/* write_rf */ |
| 4184 | rtw_hal_write_rfreg(padapter, minor_cmd, arg, 0xffffffff, extra_arg); |
| 4185 | DBG_88E("write RF_reg path(0x%02x), offset(0x%x), value(0x%08x)\n", minor_cmd, arg, rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff)); |
| 4186 | break; |
| 4187 | |
| 4188 | case 0x76: |
| 4189 | switch (minor_cmd) { |
| 4190 | case 0x00: /* normal mode, */ |
| 4191 | padapter->recvpriv.is_signal_dbg = 0; |
| 4192 | break; |
| 4193 | case 0x01: /* dbg mode */ |
| 4194 | padapter->recvpriv.is_signal_dbg = 1; |
| 4195 | extra_arg = extra_arg > 100 ? 100 : extra_arg; |
| 4196 | extra_arg = extra_arg < 0 ? 0 : extra_arg; |
| 4197 | padapter->recvpriv.signal_strength_dbg = extra_arg; |
| 4198 | break; |
| 4199 | } |
| 4200 | break; |
| 4201 | case 0x78: /* IOL test */ |
| 4202 | switch (minor_cmd) { |
| 4203 | case 0x04: /* LLT table initialization test */ |
| 4204 | { |
| 4205 | u8 page_boundary = 0xf9; |
| 4206 | struct xmit_frame *xmit_frame; |
| 4207 | |
| 4208 | xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); |
| 4209 | if (xmit_frame == NULL) { |
| 4210 | ret = -ENOMEM; |
| 4211 | break; |
| 4212 | } |
| 4213 | |
| 4214 | rtw_IOL_append_LLT_cmd(xmit_frame, page_boundary); |
| 4215 | |
| 4216 | if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 500, 0)) |
| 4217 | ret = -EPERM; |
| 4218 | } |
| 4219 | break; |
| 4220 | case 0x05: /* blink LED test */ |
| 4221 | { |
| 4222 | u16 reg = 0x4c; |
| 4223 | u32 blink_num = 50; |
| 4224 | u32 blink_delay_ms = 200; |
| 4225 | int i; |
| 4226 | struct xmit_frame *xmit_frame; |
| 4227 | |
| 4228 | xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); |
| 4229 | if (xmit_frame == NULL) { |
| 4230 | ret = -ENOMEM; |
| 4231 | break; |
| 4232 | } |
| 4233 | |
| 4234 | for (i = 0; i < blink_num; i++) { |
| 4235 | rtw_IOL_append_WB_cmd(xmit_frame, reg, 0x00, 0xff); |
| 4236 | rtw_IOL_append_DELAY_MS_cmd(xmit_frame, blink_delay_ms); |
| 4237 | rtw_IOL_append_WB_cmd(xmit_frame, reg, 0x08, 0xff); |
| 4238 | rtw_IOL_append_DELAY_MS_cmd(xmit_frame, blink_delay_ms); |
| 4239 | } |
| 4240 | if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, (blink_delay_ms*blink_num*2)+200, 0)) |
| 4241 | ret = -EPERM; |
| 4242 | } |
| 4243 | break; |
| 4244 | |
| 4245 | case 0x06: /* continuous write byte test */ |
| 4246 | { |
| 4247 | u16 reg = arg; |
| 4248 | u16 start_value = 0; |
| 4249 | u32 write_num = extra_arg; |
| 4250 | int i; |
| 4251 | u8 final; |
| 4252 | struct xmit_frame *xmit_frame; |
| 4253 | |
| 4254 | xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); |
| 4255 | if (xmit_frame == NULL) { |
| 4256 | ret = -ENOMEM; |
| 4257 | break; |
| 4258 | } |
| 4259 | |
| 4260 | for (i = 0; i < write_num; i++) |
| 4261 | rtw_IOL_append_WB_cmd(xmit_frame, reg, i+start_value, 0xFF); |
| 4262 | if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) |
| 4263 | ret = -EPERM; |
| 4264 | |
| 4265 | final = rtw_read8(padapter, reg); |
| 4266 | if (start_value+write_num-1 == final) |
| 4267 | DBG_88E("continuous IOL_CMD_WB_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final); |
| 4268 | else |
| 4269 | DBG_88E("continuous IOL_CMD_WB_REG to 0x%x %u times Fail, start:%u, final:%u\n", reg, write_num, start_value, final); |
| 4270 | } |
| 4271 | break; |
| 4272 | |
| 4273 | case 0x07: /* continuous write word test */ |
| 4274 | { |
| 4275 | u16 reg = arg; |
| 4276 | u16 start_value = 200; |
| 4277 | u32 write_num = extra_arg; |
| 4278 | |
| 4279 | int i; |
| 4280 | u16 final; |
| 4281 | struct xmit_frame *xmit_frame; |
| 4282 | |
| 4283 | xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); |
| 4284 | if (xmit_frame == NULL) { |
| 4285 | ret = -ENOMEM; |
| 4286 | break; |
| 4287 | } |
| 4288 | |
| 4289 | for (i = 0; i < write_num; i++) |
| 4290 | rtw_IOL_append_WW_cmd(xmit_frame, reg, i+start_value, 0xFFFF); |
| 4291 | if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) |
| 4292 | ret = -EPERM; |
| 4293 | |
| 4294 | final = rtw_read16(padapter, reg); |
| 4295 | if (start_value+write_num-1 == final) |
| 4296 | DBG_88E("continuous IOL_CMD_WW_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final); |
| 4297 | else |
| 4298 | DBG_88E("continuous IOL_CMD_WW_REG to 0x%x %u times Fail, start:%u, final:%u\n", reg, write_num, start_value, final); |
| 4299 | } |
| 4300 | break; |
| 4301 | case 0x08: /* continuous write dword test */ |
| 4302 | { |
| 4303 | u16 reg = arg; |
| 4304 | u32 start_value = 0x110000c7; |
| 4305 | u32 write_num = extra_arg; |
| 4306 | |
| 4307 | int i; |
| 4308 | u32 final; |
| 4309 | struct xmit_frame *xmit_frame; |
| 4310 | |
| 4311 | xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); |
| 4312 | if (xmit_frame == NULL) { |
| 4313 | ret = -ENOMEM; |
| 4314 | break; |
| 4315 | } |
| 4316 | |
| 4317 | for (i = 0; i < write_num; i++) |
| 4318 | rtw_IOL_append_WD_cmd(xmit_frame, reg, i+start_value, 0xFFFFFFFF); |
| 4319 | if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) |
| 4320 | ret = -EPERM; |
| 4321 | |
| 4322 | final = rtw_read32(padapter, reg); |
| 4323 | if (start_value+write_num-1 == final) |
| 4324 | DBG_88E("continuous IOL_CMD_WD_REG to 0x%x %u times Success, start:%u, final:%u\n", |
| 4325 | reg, write_num, start_value, final); |
| 4326 | else |
| 4327 | DBG_88E("continuous IOL_CMD_WD_REG to 0x%x %u times Fail, start:%u, final:%u\n", |
| 4328 | reg, write_num, start_value, final); |
| 4329 | } |
| 4330 | break; |
| 4331 | } |
| 4332 | break; |
| 4333 | case 0x79: |
| 4334 | { |
| 4335 | /* |
| 4336 | * dbg 0x79000000 [value], set RESP_TXAGC to + value, value:0~15 |
| 4337 | * dbg 0x79010000 [value], set RESP_TXAGC to - value, value:0~15 |
| 4338 | */ |
| 4339 | u8 value = extra_arg & 0x0f; |
| 4340 | u8 sign = minor_cmd; |
| 4341 | u16 write_value = 0; |
| 4342 | |
| 4343 | DBG_88E("%s set RESP_TXAGC to %s %u\n", __func__, sign ? "minus" : "plus", value); |
| 4344 | |
| 4345 | if (sign) |
| 4346 | value = value | 0x10; |
| 4347 | |
| 4348 | write_value = value | (value << 5); |
| 4349 | rtw_write16(padapter, 0x6d9, write_value); |
| 4350 | } |
| 4351 | break; |
| 4352 | case 0x7a: |
| 4353 | receive_disconnect(padapter, pmlmeinfo->network.MacAddress |
| 4354 | , WLAN_REASON_EXPIRATION_CHK); |
| 4355 | break; |
| 4356 | case 0x7F: |
| 4357 | switch (minor_cmd) { |
| 4358 | case 0x0: |
| 4359 | DBG_88E("fwstate = 0x%x\n", get_fwstate(pmlmepriv)); |
| 4360 | break; |
| 4361 | case 0x01: |
| 4362 | DBG_88E("auth_alg = 0x%x, enc_alg = 0x%x, auth_type = 0x%x, enc_type = 0x%x\n", |
| 4363 | psecuritypriv->dot11AuthAlgrthm, psecuritypriv->dot11PrivacyAlgrthm, |
| 4364 | psecuritypriv->ndisauthtype, psecuritypriv->ndisencryptstatus); |
| 4365 | break; |
| 4366 | case 0x02: |
| 4367 | DBG_88E("pmlmeinfo->state = 0x%x\n", pmlmeinfo->state); |
| 4368 | break; |
| 4369 | case 0x03: |
| 4370 | DBG_88E("qos_option =%d\n", pmlmepriv->qospriv.qos_option); |
| 4371 | DBG_88E("ht_option =%d\n", pmlmepriv->htpriv.ht_option); |
| 4372 | break; |
| 4373 | case 0x04: |
| 4374 | DBG_88E("cur_ch =%d\n", pmlmeext->cur_channel); |
| 4375 | DBG_88E("cur_bw =%d\n", pmlmeext->cur_bwmode); |
| 4376 | DBG_88E("cur_ch_off =%d\n", pmlmeext->cur_ch_offset); |
| 4377 | break; |
| 4378 | case 0x05: |
| 4379 | psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); |
| 4380 | if (psta) { |
| 4381 | int i; |
| 4382 | struct recv_reorder_ctrl *preorder_ctrl; |
| 4383 | |
| 4384 | DBG_88E("SSID =%s\n", cur_network->network.Ssid.Ssid); |
| 4385 | DBG_88E("sta's macaddr: %pM\n", psta->hwaddr); |
| 4386 | DBG_88E("cur_channel =%d, cur_bwmode =%d, cur_ch_offset =%d\n", pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset); |
| 4387 | DBG_88E("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self); |
| 4388 | DBG_88E("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); |
| 4389 | DBG_88E("qos_en =%d, ht_en =%d, init_rate =%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); |
| 4390 | DBG_88E("bwmode =%d, ch_offset =%d, sgi =%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); |
| 4391 | DBG_88E("ampdu_enable = %d\n", psta->htpriv.ampdu_enable); |
| 4392 | DBG_88E("agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); |
| 4393 | for (i = 0; i < 16; i++) { |
| 4394 | preorder_ctrl = &psta->recvreorder_ctrl[i]; |
| 4395 | if (preorder_ctrl->enable) |
| 4396 | DBG_88E("tid =%d, indicate_seq =%d\n", i, preorder_ctrl->indicate_seq); |
| 4397 | } |
| 4398 | } else { |
| 4399 | DBG_88E("can't get sta's macaddr, cur_network's macaddr:%pM\n", (cur_network->network.MacAddress)); |
| 4400 | } |
| 4401 | break; |
| 4402 | case 0x06: |
| 4403 | { |
| 4404 | u32 ODMFlag; |
| 4405 | rtw_hal_get_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag)); |
| 4406 | DBG_88E("(B)DMFlag = 0x%x, arg = 0x%x\n", ODMFlag, arg); |
| 4407 | ODMFlag = (u32)(0x0f&arg); |
| 4408 | DBG_88E("(A)DMFlag = 0x%x\n", ODMFlag); |
| 4409 | rtw_hal_set_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag)); |
| 4410 | } |
| 4411 | break; |
| 4412 | case 0x07: |
| 4413 | DBG_88E("bSurpriseRemoved =%d, bDriverStopped =%d\n", |
| 4414 | padapter->bSurpriseRemoved, padapter->bDriverStopped); |
| 4415 | break; |
| 4416 | case 0x08: |
| 4417 | { |
| 4418 | struct xmit_priv *pxmitpriv = &padapter->xmitpriv; |
| 4419 | struct recv_priv *precvpriv = &padapter->recvpriv; |
| 4420 | |
| 4421 | DBG_88E("free_xmitbuf_cnt =%d, free_xmitframe_cnt =%d, free_xmit_extbuf_cnt =%d\n", |
| 4422 | pxmitpriv->free_xmitbuf_cnt, pxmitpriv->free_xmitframe_cnt, pxmitpriv->free_xmit_extbuf_cnt); |
| 4423 | DBG_88E("rx_urb_pending_cn =%d\n", precvpriv->rx_pending_cnt); |
| 4424 | } |
| 4425 | break; |
| 4426 | case 0x09: |
| 4427 | { |
| 4428 | int i, j; |
| 4429 | struct list_head *plist, *phead; |
| 4430 | struct recv_reorder_ctrl *preorder_ctrl; |
| 4431 | |
| 4432 | #ifdef CONFIG_88EU_AP_MODE |
| 4433 | DBG_88E("sta_dz_bitmap = 0x%x, tim_bitmap = 0x%x\n", pstapriv->sta_dz_bitmap, pstapriv->tim_bitmap); |
| 4434 | #endif |
Larry Finger | 7057dcb | 2013-12-19 22:38:34 -0600 | [diff] [blame] | 4435 | spin_lock_bh(&pstapriv->sta_hash_lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 4436 | |
| 4437 | for (i = 0; i < NUM_STA; i++) { |
| 4438 | phead = &(pstapriv->sta_hash[i]); |
| 4439 | plist = get_next(phead); |
| 4440 | |
| 4441 | while ((rtw_end_of_queue_search(phead, plist)) == false) { |
| 4442 | psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); |
| 4443 | |
| 4444 | plist = get_next(plist); |
| 4445 | |
| 4446 | if (extra_arg == psta->aid) { |
| 4447 | DBG_88E("sta's macaddr:%pM\n", (psta->hwaddr)); |
| 4448 | DBG_88E("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self); |
| 4449 | DBG_88E("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); |
| 4450 | DBG_88E("qos_en =%d, ht_en =%d, init_rate =%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); |
| 4451 | DBG_88E("bwmode =%d, ch_offset =%d, sgi =%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); |
| 4452 | DBG_88E("ampdu_enable = %d\n", psta->htpriv.ampdu_enable); |
| 4453 | DBG_88E("agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); |
| 4454 | |
| 4455 | #ifdef CONFIG_88EU_AP_MODE |
| 4456 | DBG_88E("capability = 0x%x\n", psta->capability); |
| 4457 | DBG_88E("flags = 0x%x\n", psta->flags); |
| 4458 | DBG_88E("wpa_psk = 0x%x\n", psta->wpa_psk); |
| 4459 | DBG_88E("wpa2_group_cipher = 0x%x\n", psta->wpa2_group_cipher); |
| 4460 | DBG_88E("wpa2_pairwise_cipher = 0x%x\n", psta->wpa2_pairwise_cipher); |
| 4461 | DBG_88E("qos_info = 0x%x\n", psta->qos_info); |
| 4462 | #endif |
| 4463 | DBG_88E("dot118021XPrivacy = 0x%x\n", psta->dot118021XPrivacy); |
| 4464 | |
| 4465 | for (j = 0; j < 16; j++) { |
| 4466 | preorder_ctrl = &psta->recvreorder_ctrl[j]; |
| 4467 | if (preorder_ctrl->enable) |
| 4468 | DBG_88E("tid =%d, indicate_seq =%d\n", j, preorder_ctrl->indicate_seq); |
| 4469 | } |
| 4470 | } |
| 4471 | } |
| 4472 | } |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 4473 | spin_unlock_bh(&pstapriv->sta_hash_lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 4474 | } |
| 4475 | break; |
| 4476 | case 0x0c:/* dump rx/tx packet */ |
| 4477 | if (arg == 0) { |
| 4478 | DBG_88E("dump rx packet (%d)\n", extra_arg); |
| 4479 | rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_RXPKT, &(extra_arg)); |
| 4480 | } else if (arg == 1) { |
| 4481 | DBG_88E("dump tx packet (%d)\n", extra_arg); |
| 4482 | rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(extra_arg)); |
| 4483 | } |
| 4484 | break; |
| 4485 | case 0x0f: |
| 4486 | if (extra_arg == 0) { |
| 4487 | DBG_88E("###### silent reset test.......#####\n"); |
| 4488 | rtw_hal_sreset_reset(padapter); |
| 4489 | } |
| 4490 | break; |
| 4491 | case 0x15: |
| 4492 | { |
| 4493 | struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; |
| 4494 | DBG_88E("==>silent resete cnts:%d\n", pwrpriv->ips_enter_cnts); |
| 4495 | } |
| 4496 | break; |
| 4497 | case 0x10:/* driver version display */ |
| 4498 | DBG_88E("rtw driver version =%s\n", DRIVERVERSION); |
| 4499 | break; |
| 4500 | case 0x11: |
| 4501 | DBG_88E("turn %s Rx RSSI display function\n", (extra_arg == 1) ? "on" : "off"); |
| 4502 | padapter->bRxRSSIDisplay = extra_arg; |
| 4503 | rtw_hal_set_def_var(padapter, HW_DEF_FA_CNT_DUMP, &extra_arg); |
| 4504 | break; |
| 4505 | case 0x12: /* set rx_stbc */ |
| 4506 | { |
| 4507 | struct registry_priv *pregpriv = &padapter->registrypriv; |
| 4508 | /* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, 0x3: enable both 2.4g and 5g */ |
| 4509 | /* default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ |
| 4510 | if (pregpriv && |
| 4511 | (extra_arg == 0 || |
| 4512 | extra_arg == 1 || |
| 4513 | extra_arg == 2 || |
| 4514 | extra_arg == 3)) { |
| 4515 | pregpriv->rx_stbc = extra_arg; |
| 4516 | DBG_88E("set rx_stbc =%d\n", pregpriv->rx_stbc); |
| 4517 | } else { |
| 4518 | DBG_88E("get rx_stbc =%d\n", pregpriv->rx_stbc); |
| 4519 | } |
| 4520 | } |
| 4521 | break; |
| 4522 | case 0x13: /* set ampdu_enable */ |
| 4523 | { |
| 4524 | struct registry_priv *pregpriv = &padapter->registrypriv; |
| 4525 | /* 0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */ |
| 4526 | if (pregpriv && extra_arg >= 0 && extra_arg < 3) { |
| 4527 | pregpriv->ampdu_enable = extra_arg; |
| 4528 | DBG_88E("set ampdu_enable =%d\n", pregpriv->ampdu_enable); |
| 4529 | } else { |
| 4530 | DBG_88E("get ampdu_enable =%d\n", pregpriv->ampdu_enable); |
| 4531 | } |
| 4532 | } |
| 4533 | break; |
| 4534 | case 0x14: /* get wifi_spec */ |
| 4535 | { |
| 4536 | struct registry_priv *pregpriv = &padapter->registrypriv; |
| 4537 | DBG_88E("get wifi_spec =%d\n", pregpriv->wifi_spec); |
| 4538 | } |
| 4539 | break; |
| 4540 | case 0x16: |
| 4541 | if (arg == 0xff) { |
| 4542 | pr_info("ODM_COMP_DIG\t\tBIT0\n"); |
| 4543 | pr_info("ODM_COMP_RA_MASK\t\tBIT1\n"); |
| 4544 | pr_info("ODM_COMP_DYNAMIC_TXPWR\tBIT2\n"); |
| 4545 | pr_info("ODM_COMP_FA_CNT\t\tBIT3\n"); |
| 4546 | pr_info("ODM_COMP_RSSI_MONITOR\tBIT4\n"); |
| 4547 | pr_info("ODM_COMP_CCK_PD\t\tBIT5\n"); |
| 4548 | pr_info("ODM_COMP_ANT_DIV\t\tBIT6\n"); |
| 4549 | pr_info("ODM_COMP_PWR_SAVE\t\tBIT7\n"); |
| 4550 | pr_info("ODM_COMP_PWR_TRAIN\tBIT8\n"); |
| 4551 | pr_info("ODM_COMP_RATE_ADAPTIVE\tBIT9\n"); |
| 4552 | pr_info("ODM_COMP_PATH_DIV\t\tBIT10\n"); |
| 4553 | pr_info("ODM_COMP_PSD \tBIT11\n"); |
| 4554 | pr_info("ODM_COMP_DYNAMIC_PRICCA\tBIT12\n"); |
| 4555 | pr_info("ODM_COMP_RXHP\t\tBIT13\n"); |
| 4556 | pr_info("ODM_COMP_EDCA_TURBO\tBIT16\n"); |
| 4557 | pr_info("ODM_COMP_EARLY_MODE\tBIT17\n"); |
| 4558 | pr_info("ODM_COMP_TX_PWR_TRACK\tBIT24\n"); |
| 4559 | pr_info("ODM_COMP_RX_GAIN_TRACK\tBIT25\n"); |
| 4560 | pr_info("ODM_COMP_CALIBRATION\tBIT26\n"); |
| 4561 | rtw_hal_get_def_var(padapter, HW_DEF_ODM_DBG_FLAG, &extra_arg); |
| 4562 | } else { |
| 4563 | rtw_hal_set_def_var(padapter, HW_DEF_ODM_DBG_FLAG, &extra_arg); |
| 4564 | } |
| 4565 | break; |
| 4566 | case 0x23: |
| 4567 | DBG_88E("turn %s the bNotifyChannelChange Variable\n", (extra_arg == 1) ? "on" : "off"); |
| 4568 | padapter->bNotifyChannelChange = extra_arg; |
| 4569 | break; |
| 4570 | case 0x24: |
| 4571 | #ifdef CONFIG_88EU_P2P |
| 4572 | DBG_88E("turn %s the bShowGetP2PState Variable\n", (extra_arg == 1) ? "on" : "off"); |
| 4573 | padapter->bShowGetP2PState = extra_arg; |
| 4574 | #endif /* CONFIG_88EU_P2P */ |
| 4575 | break; |
| 4576 | case 0xaa: |
| 4577 | if (extra_arg > 0x13) |
| 4578 | extra_arg = 0xFF; |
| 4579 | DBG_88E("chang data rate to :0x%02x\n", extra_arg); |
| 4580 | padapter->fix_rate = extra_arg; |
| 4581 | break; |
| 4582 | case 0xdd:/* registers dump, 0 for mac reg, 1 for bb reg, 2 for rf reg */ |
| 4583 | if (extra_arg == 0) |
| 4584 | mac_reg_dump(padapter); |
| 4585 | else if (extra_arg == 1) |
| 4586 | bb_reg_dump(padapter); |
| 4587 | else if (extra_arg == 2) |
| 4588 | rf_reg_dump(padapter); |
| 4589 | break; |
| 4590 | case 0xee:/* turn on/off dynamic funcs */ |
| 4591 | { |
| 4592 | u32 odm_flag; |
| 4593 | |
| 4594 | if (0xf == extra_arg) { |
| 4595 | rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &odm_flag); |
| 4596 | DBG_88E(" === DMFlag(0x%08x) ===\n", odm_flag); |
| 4597 | DBG_88E("extra_arg = 0 - disable all dynamic func\n"); |
| 4598 | DBG_88E("extra_arg = 1 - disable DIG- BIT(0)\n"); |
| 4599 | DBG_88E("extra_arg = 2 - disable High power - BIT(1)\n"); |
| 4600 | DBG_88E("extra_arg = 3 - disable tx power tracking - BIT(2)\n"); |
| 4601 | DBG_88E("extra_arg = 4 - disable BT coexistence - BIT(3)\n"); |
| 4602 | DBG_88E("extra_arg = 5 - disable antenna diversity - BIT(4)\n"); |
| 4603 | DBG_88E("extra_arg = 6 - enable all dynamic func\n"); |
| 4604 | } else { |
| 4605 | /* extra_arg = 0 - disable all dynamic func |
| 4606 | extra_arg = 1 - disable DIG |
| 4607 | extra_arg = 2 - disable tx power tracking |
| 4608 | extra_arg = 3 - turn on all dynamic func |
| 4609 | */ |
| 4610 | rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &(extra_arg)); |
| 4611 | rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &odm_flag); |
| 4612 | DBG_88E(" === DMFlag(0x%08x) ===\n", odm_flag); |
| 4613 | } |
| 4614 | } |
| 4615 | break; |
| 4616 | |
| 4617 | case 0xfd: |
| 4618 | rtw_write8(padapter, 0xc50, arg); |
| 4619 | DBG_88E("wr(0xc50) = 0x%x\n", rtw_read8(padapter, 0xc50)); |
| 4620 | rtw_write8(padapter, 0xc58, arg); |
| 4621 | DBG_88E("wr(0xc58) = 0x%x\n", rtw_read8(padapter, 0xc58)); |
| 4622 | break; |
| 4623 | case 0xfe: |
| 4624 | DBG_88E("rd(0xc50) = 0x%x\n", rtw_read8(padapter, 0xc50)); |
| 4625 | DBG_88E("rd(0xc58) = 0x%x\n", rtw_read8(padapter, 0xc58)); |
| 4626 | break; |
| 4627 | case 0xff: |
| 4628 | DBG_88E("dbg(0x210) = 0x%x\n", rtw_read32(padapter, 0x210)); |
| 4629 | DBG_88E("dbg(0x608) = 0x%x\n", rtw_read32(padapter, 0x608)); |
| 4630 | DBG_88E("dbg(0x280) = 0x%x\n", rtw_read32(padapter, 0x280)); |
| 4631 | DBG_88E("dbg(0x284) = 0x%x\n", rtw_read32(padapter, 0x284)); |
| 4632 | DBG_88E("dbg(0x288) = 0x%x\n", rtw_read32(padapter, 0x288)); |
| 4633 | |
| 4634 | DBG_88E("dbg(0x664) = 0x%x\n", rtw_read32(padapter, 0x664)); |
| 4635 | |
| 4636 | DBG_88E("\n"); |
| 4637 | |
| 4638 | DBG_88E("dbg(0x430) = 0x%x\n", rtw_read32(padapter, 0x430)); |
| 4639 | DBG_88E("dbg(0x438) = 0x%x\n", rtw_read32(padapter, 0x438)); |
| 4640 | |
| 4641 | DBG_88E("dbg(0x440) = 0x%x\n", rtw_read32(padapter, 0x440)); |
| 4642 | |
| 4643 | DBG_88E("dbg(0x458) = 0x%x\n", rtw_read32(padapter, 0x458)); |
| 4644 | |
| 4645 | DBG_88E("dbg(0x484) = 0x%x\n", rtw_read32(padapter, 0x484)); |
| 4646 | DBG_88E("dbg(0x488) = 0x%x\n", rtw_read32(padapter, 0x488)); |
| 4647 | |
| 4648 | DBG_88E("dbg(0x444) = 0x%x\n", rtw_read32(padapter, 0x444)); |
| 4649 | DBG_88E("dbg(0x448) = 0x%x\n", rtw_read32(padapter, 0x448)); |
| 4650 | DBG_88E("dbg(0x44c) = 0x%x\n", rtw_read32(padapter, 0x44c)); |
| 4651 | DBG_88E("dbg(0x450) = 0x%x\n", rtw_read32(padapter, 0x450)); |
| 4652 | break; |
| 4653 | } |
| 4654 | break; |
| 4655 | default: |
| 4656 | DBG_88E("error dbg cmd!\n"); |
| 4657 | break; |
| 4658 | } |
| 4659 | return ret; |
| 4660 | } |
| 4661 | |
| 4662 | static int wpa_set_param(struct net_device *dev, u8 name, u32 value) |
| 4663 | { |
| 4664 | uint ret = 0; |
| 4665 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 4666 | |
| 4667 | switch (name) { |
| 4668 | case IEEE_PARAM_WPA_ENABLED: |
| 4669 | padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; /* 802.1x */ |
| 4670 | switch ((value)&0xff) { |
| 4671 | case 1: /* WPA */ |
| 4672 | padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; /* WPA_PSK */ |
| 4673 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; |
| 4674 | break; |
| 4675 | case 2: /* WPA2 */ |
| 4676 | padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; /* WPA2_PSK */ |
| 4677 | padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; |
| 4678 | break; |
| 4679 | } |
| 4680 | RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, |
| 4681 | ("wpa_set_param:padapter->securitypriv.ndisauthtype =%d\n", padapter->securitypriv.ndisauthtype)); |
| 4682 | break; |
| 4683 | case IEEE_PARAM_TKIP_COUNTERMEASURES: |
| 4684 | break; |
| 4685 | case IEEE_PARAM_DROP_UNENCRYPTED: { |
| 4686 | /* HACK: |
| 4687 | * |
| 4688 | * wpa_supplicant calls set_wpa_enabled when the driver |
| 4689 | * is loaded and unloaded, regardless of if WPA is being |
| 4690 | * used. No other calls are made which can be used to |
| 4691 | * determine if encryption will be used or not prior to |
| 4692 | * association being expected. If encryption is not being |
| 4693 | * used, drop_unencrypted is set to false, else true -- we |
| 4694 | * can use this to determine if the CAP_PRIVACY_ON bit should |
| 4695 | * be set. |
| 4696 | */ |
| 4697 | |
| 4698 | break; |
| 4699 | } |
| 4700 | case IEEE_PARAM_PRIVACY_INVOKED: |
| 4701 | break; |
| 4702 | |
| 4703 | case IEEE_PARAM_AUTH_ALGS: |
| 4704 | ret = wpa_set_auth_algs(dev, value); |
| 4705 | break; |
| 4706 | case IEEE_PARAM_IEEE_802_1X: |
| 4707 | break; |
| 4708 | case IEEE_PARAM_WPAX_SELECT: |
| 4709 | break; |
| 4710 | default: |
| 4711 | ret = -EOPNOTSUPP; |
| 4712 | break; |
| 4713 | } |
| 4714 | return ret; |
| 4715 | } |
| 4716 | |
| 4717 | static int wpa_mlme(struct net_device *dev, u32 command, u32 reason) |
| 4718 | { |
| 4719 | int ret = 0; |
| 4720 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 4721 | |
| 4722 | switch (command) { |
| 4723 | case IEEE_MLME_STA_DEAUTH: |
| 4724 | if (!rtw_set_802_11_disassociate(padapter)) |
| 4725 | ret = -1; |
| 4726 | break; |
| 4727 | case IEEE_MLME_STA_DISASSOC: |
| 4728 | if (!rtw_set_802_11_disassociate(padapter)) |
| 4729 | ret = -1; |
| 4730 | break; |
| 4731 | default: |
| 4732 | ret = -EOPNOTSUPP; |
| 4733 | break; |
| 4734 | } |
| 4735 | |
| 4736 | return ret; |
| 4737 | } |
| 4738 | |
| 4739 | static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) |
| 4740 | { |
| 4741 | struct ieee_param *param; |
| 4742 | uint ret = 0; |
| 4743 | |
| 4744 | if (p->length < sizeof(struct ieee_param) || !p->pointer) { |
| 4745 | ret = -EINVAL; |
| 4746 | goto out; |
| 4747 | } |
| 4748 | |
| 4749 | param = (struct ieee_param *)rtw_malloc(p->length); |
| 4750 | if (param == NULL) { |
| 4751 | ret = -ENOMEM; |
| 4752 | goto out; |
| 4753 | } |
| 4754 | |
| 4755 | if (copy_from_user(param, p->pointer, p->length)) { |
| 4756 | kfree(param); |
| 4757 | ret = -EFAULT; |
| 4758 | goto out; |
| 4759 | } |
| 4760 | |
| 4761 | switch (param->cmd) { |
| 4762 | case IEEE_CMD_SET_WPA_PARAM: |
| 4763 | ret = wpa_set_param(dev, param->u.wpa_param.name, param->u.wpa_param.value); |
| 4764 | break; |
| 4765 | |
| 4766 | case IEEE_CMD_SET_WPA_IE: |
| 4767 | ret = rtw_set_wpa_ie((struct adapter *)rtw_netdev_priv(dev), |
| 4768 | (char *)param->u.wpa_ie.data, (u16)param->u.wpa_ie.len); |
| 4769 | break; |
| 4770 | |
| 4771 | case IEEE_CMD_SET_ENCRYPTION: |
| 4772 | ret = wpa_set_encryption(dev, param, p->length); |
| 4773 | break; |
| 4774 | |
| 4775 | case IEEE_CMD_MLME: |
| 4776 | ret = wpa_mlme(dev, param->u.mlme.command, param->u.mlme.reason_code); |
| 4777 | break; |
| 4778 | |
| 4779 | default: |
| 4780 | DBG_88E("Unknown WPA supplicant request: %d\n", param->cmd); |
| 4781 | ret = -EOPNOTSUPP; |
| 4782 | break; |
| 4783 | } |
| 4784 | |
| 4785 | if (ret == 0 && copy_to_user(p->pointer, param, p->length)) |
| 4786 | ret = -EFAULT; |
| 4787 | |
| 4788 | kfree(param); |
| 4789 | |
| 4790 | out: |
| 4791 | |
| 4792 | return ret; |
| 4793 | } |
| 4794 | |
| 4795 | #ifdef CONFIG_88EU_AP_MODE |
| 4796 | static u8 set_pairwise_key(struct adapter *padapter, struct sta_info *psta) |
| 4797 | { |
| 4798 | struct cmd_obj *ph2c; |
| 4799 | struct set_stakey_parm *psetstakey_para; |
| 4800 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 4801 | u8 res = _SUCCESS; |
| 4802 | |
| 4803 | ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); |
| 4804 | if (ph2c == NULL) { |
| 4805 | res = _FAIL; |
| 4806 | goto exit; |
| 4807 | } |
| 4808 | |
| 4809 | psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); |
| 4810 | if (psetstakey_para == NULL) { |
| 4811 | kfree(ph2c); |
| 4812 | res = _FAIL; |
| 4813 | goto exit; |
| 4814 | } |
| 4815 | |
| 4816 | init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); |
| 4817 | |
| 4818 | psetstakey_para->algorithm = (u8)psta->dot118021XPrivacy; |
| 4819 | |
| 4820 | memcpy(psetstakey_para->addr, psta->hwaddr, ETH_ALEN); |
| 4821 | |
| 4822 | memcpy(psetstakey_para->key, &psta->dot118021x_UncstKey, 16); |
| 4823 | |
| 4824 | res = rtw_enqueue_cmd(pcmdpriv, ph2c); |
| 4825 | |
| 4826 | exit: |
| 4827 | |
| 4828 | return res; |
| 4829 | } |
| 4830 | |
| 4831 | static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid) |
| 4832 | { |
| 4833 | u8 keylen; |
| 4834 | struct cmd_obj *pcmd; |
| 4835 | struct setkey_parm *psetkeyparm; |
| 4836 | struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); |
| 4837 | int res = _SUCCESS; |
| 4838 | |
| 4839 | DBG_88E("%s\n", __func__); |
| 4840 | |
| 4841 | pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); |
| 4842 | if (pcmd == NULL) { |
| 4843 | res = _FAIL; |
| 4844 | goto exit; |
| 4845 | } |
| 4846 | psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); |
| 4847 | if (psetkeyparm == NULL) { |
| 4848 | kfree(pcmd); |
| 4849 | res = _FAIL; |
| 4850 | goto exit; |
| 4851 | } |
| 4852 | |
| 4853 | _rtw_memset(psetkeyparm, 0, sizeof(struct setkey_parm)); |
| 4854 | |
| 4855 | psetkeyparm->keyid = (u8)keyid; |
| 4856 | |
| 4857 | psetkeyparm->algorithm = alg; |
| 4858 | |
| 4859 | psetkeyparm->set_tx = 1; |
| 4860 | |
| 4861 | switch (alg) { |
| 4862 | case _WEP40_: |
| 4863 | keylen = 5; |
| 4864 | break; |
| 4865 | case _WEP104_: |
| 4866 | keylen = 13; |
| 4867 | break; |
| 4868 | case _TKIP_: |
| 4869 | case _TKIP_WTMIC_: |
| 4870 | case _AES_: |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 4871 | default: |
| 4872 | keylen = 16; |
| 4873 | } |
| 4874 | |
| 4875 | memcpy(&(psetkeyparm->key[0]), key, keylen); |
| 4876 | |
| 4877 | pcmd->cmdcode = _SetKey_CMD_; |
| 4878 | pcmd->parmbuf = (u8 *)psetkeyparm; |
| 4879 | pcmd->cmdsz = (sizeof(struct setkey_parm)); |
| 4880 | pcmd->rsp = NULL; |
| 4881 | pcmd->rspsz = 0; |
| 4882 | |
| 4883 | _rtw_init_listhead(&pcmd->list); |
| 4884 | |
| 4885 | res = rtw_enqueue_cmd(pcmdpriv, pcmd); |
| 4886 | |
| 4887 | exit: |
| 4888 | |
| 4889 | return res; |
| 4890 | } |
| 4891 | |
| 4892 | static int set_wep_key(struct adapter *padapter, u8 *key, u8 keylen, int keyid) |
| 4893 | { |
| 4894 | u8 alg; |
| 4895 | |
| 4896 | switch (keylen) { |
| 4897 | case 5: |
| 4898 | alg = _WEP40_; |
| 4899 | break; |
| 4900 | case 13: |
| 4901 | alg = _WEP104_; |
| 4902 | break; |
| 4903 | default: |
| 4904 | alg = _NO_PRIVACY_; |
| 4905 | } |
| 4906 | |
| 4907 | return set_group_key(padapter, key, alg, keyid); |
| 4908 | } |
| 4909 | |
| 4910 | static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len) |
| 4911 | { |
| 4912 | int ret = 0; |
| 4913 | u32 wep_key_idx, wep_key_len, wep_total_len; |
| 4914 | struct ndis_802_11_wep *pwep = NULL; |
| 4915 | struct sta_info *psta = NULL, *pbcmc_sta = NULL; |
| 4916 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 4917 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 4918 | struct security_priv *psecuritypriv = &(padapter->securitypriv); |
| 4919 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 4920 | |
| 4921 | DBG_88E("%s\n", __func__); |
| 4922 | param->u.crypt.err = 0; |
| 4923 | param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; |
| 4924 | if (param_len != sizeof(struct ieee_param) + param->u.crypt.key_len) { |
| 4925 | ret = -EINVAL; |
| 4926 | goto exit; |
| 4927 | } |
| 4928 | if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && |
| 4929 | param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && |
| 4930 | param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) { |
| 4931 | if (param->u.crypt.idx >= WEP_KEYS) { |
| 4932 | ret = -EINVAL; |
| 4933 | goto exit; |
| 4934 | } |
| 4935 | } else { |
| 4936 | psta = rtw_get_stainfo(pstapriv, param->sta_addr); |
| 4937 | if (!psta) { |
| 4938 | DBG_88E("rtw_set_encryption(), sta has already been removed or never been added\n"); |
| 4939 | goto exit; |
| 4940 | } |
| 4941 | } |
| 4942 | |
| 4943 | if (strcmp(param->u.crypt.alg, "none") == 0 && (psta == NULL)) { |
| 4944 | /* todo:clear default encryption keys */ |
| 4945 | |
| 4946 | DBG_88E("clear default encryption keys, keyid =%d\n", param->u.crypt.idx); |
| 4947 | goto exit; |
| 4948 | } |
| 4949 | if (strcmp(param->u.crypt.alg, "WEP") == 0 && (psta == NULL)) { |
| 4950 | DBG_88E("r871x_set_encryption, crypt.alg = WEP\n"); |
| 4951 | wep_key_idx = param->u.crypt.idx; |
| 4952 | wep_key_len = param->u.crypt.key_len; |
| 4953 | DBG_88E("r871x_set_encryption, wep_key_idx=%d, len=%d\n", wep_key_idx, wep_key_len); |
| 4954 | if ((wep_key_idx >= WEP_KEYS) || (wep_key_len <= 0)) { |
| 4955 | ret = -EINVAL; |
| 4956 | goto exit; |
| 4957 | } |
| 4958 | |
| 4959 | if (wep_key_len > 0) { |
| 4960 | wep_key_len = wep_key_len <= 5 ? 5 : 13; |
| 4961 | wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); |
| 4962 | pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); |
| 4963 | if (pwep == NULL) { |
| 4964 | DBG_88E(" r871x_set_encryption: pwep allocate fail !!!\n"); |
| 4965 | goto exit; |
| 4966 | } |
| 4967 | |
| 4968 | _rtw_memset(pwep, 0, wep_total_len); |
| 4969 | |
| 4970 | pwep->KeyLength = wep_key_len; |
| 4971 | pwep->Length = wep_total_len; |
| 4972 | } |
| 4973 | |
| 4974 | pwep->KeyIndex = wep_key_idx; |
| 4975 | |
| 4976 | memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); |
| 4977 | |
| 4978 | if (param->u.crypt.set_tx) { |
| 4979 | DBG_88E("wep, set_tx = 1\n"); |
| 4980 | |
| 4981 | psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled; |
| 4982 | psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; |
| 4983 | psecuritypriv->dot118021XGrpPrivacy = _WEP40_; |
| 4984 | |
| 4985 | if (pwep->KeyLength == 13) { |
| 4986 | psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; |
| 4987 | psecuritypriv->dot118021XGrpPrivacy = _WEP104_; |
| 4988 | } |
| 4989 | |
| 4990 | psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx; |
| 4991 | |
| 4992 | memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); |
| 4993 | |
| 4994 | psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; |
| 4995 | |
| 4996 | set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx); |
| 4997 | } else { |
| 4998 | DBG_88E("wep, set_tx = 0\n"); |
| 4999 | |
| 5000 | /* don't update "psecuritypriv->dot11PrivacyAlgrthm" and */ |
| 5001 | /* psecuritypriv->dot11PrivacyKeyIndex = keyid", but can rtw_set_key to cam */ |
| 5002 | |
| 5003 | memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); |
| 5004 | |
| 5005 | psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; |
| 5006 | |
| 5007 | set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx); |
| 5008 | } |
| 5009 | |
| 5010 | goto exit; |
| 5011 | } |
| 5012 | |
| 5013 | if (!psta && check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* group key */ |
| 5014 | if (param->u.crypt.set_tx == 1) { |
| 5015 | if (strcmp(param->u.crypt.alg, "WEP") == 0) { |
| 5016 | DBG_88E("%s, set group_key, WEP\n", __func__); |
| 5017 | |
| 5018 | memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, |
| 5019 | param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); |
| 5020 | |
| 5021 | psecuritypriv->dot118021XGrpPrivacy = _WEP40_; |
| 5022 | if (param->u.crypt.key_len == 13) |
| 5023 | psecuritypriv->dot118021XGrpPrivacy = _WEP104_; |
| 5024 | } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { |
| 5025 | DBG_88E("%s, set group_key, TKIP\n", __func__); |
| 5026 | psecuritypriv->dot118021XGrpPrivacy = _TKIP_; |
| 5027 | memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, |
| 5028 | param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); |
| 5029 | /* set mic key */ |
| 5030 | memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); |
| 5031 | memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); |
| 5032 | |
| 5033 | psecuritypriv->busetkipkey = true; |
| 5034 | } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { |
| 5035 | DBG_88E("%s, set group_key, CCMP\n", __func__); |
| 5036 | psecuritypriv->dot118021XGrpPrivacy = _AES_; |
| 5037 | memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, |
| 5038 | param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); |
| 5039 | } else { |
| 5040 | DBG_88E("%s, set group_key, none\n", __func__); |
| 5041 | psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; |
| 5042 | } |
| 5043 | psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx; |
| 5044 | psecuritypriv->binstallGrpkey = true; |
| 5045 | psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/* */ |
| 5046 | set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx); |
| 5047 | pbcmc_sta = rtw_get_bcmc_stainfo(padapter); |
| 5048 | if (pbcmc_sta) { |
| 5049 | pbcmc_sta->ieee8021x_blocked = false; |
| 5050 | pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */ |
| 5051 | } |
| 5052 | } |
| 5053 | goto exit; |
| 5054 | } |
| 5055 | |
| 5056 | if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && psta) { /* psk/802_1x */ |
| 5057 | if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { |
| 5058 | if (param->u.crypt.set_tx == 1) { |
| 5059 | memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); |
| 5060 | |
| 5061 | if (strcmp(param->u.crypt.alg, "WEP") == 0) { |
| 5062 | DBG_88E("%s, set pairwise key, WEP\n", __func__); |
| 5063 | |
| 5064 | psta->dot118021XPrivacy = _WEP40_; |
| 5065 | if (param->u.crypt.key_len == 13) |
| 5066 | psta->dot118021XPrivacy = _WEP104_; |
| 5067 | } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { |
| 5068 | DBG_88E("%s, set pairwise key, TKIP\n", __func__); |
| 5069 | |
| 5070 | psta->dot118021XPrivacy = _TKIP_; |
| 5071 | |
| 5072 | /* set mic key */ |
| 5073 | memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8); |
| 5074 | memcpy(psta->dot11tkiprxmickey.skey, &(param->u.crypt.key[24]), 8); |
| 5075 | |
| 5076 | psecuritypriv->busetkipkey = true; |
| 5077 | } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { |
| 5078 | DBG_88E("%s, set pairwise key, CCMP\n", __func__); |
| 5079 | |
| 5080 | psta->dot118021XPrivacy = _AES_; |
| 5081 | } else { |
| 5082 | DBG_88E("%s, set pairwise key, none\n", __func__); |
| 5083 | |
| 5084 | psta->dot118021XPrivacy = _NO_PRIVACY_; |
| 5085 | } |
| 5086 | |
| 5087 | set_pairwise_key(padapter, psta); |
| 5088 | |
| 5089 | psta->ieee8021x_blocked = false; |
| 5090 | } else { /* group key??? */ |
| 5091 | if (strcmp(param->u.crypt.alg, "WEP") == 0) { |
| 5092 | memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, |
| 5093 | param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); |
| 5094 | psecuritypriv->dot118021XGrpPrivacy = _WEP40_; |
| 5095 | if (param->u.crypt.key_len == 13) |
| 5096 | psecuritypriv->dot118021XGrpPrivacy = _WEP104_; |
| 5097 | } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { |
| 5098 | psecuritypriv->dot118021XGrpPrivacy = _TKIP_; |
| 5099 | |
| 5100 | memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, |
| 5101 | param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); |
| 5102 | |
| 5103 | /* set mic key */ |
| 5104 | memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); |
| 5105 | memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); |
| 5106 | |
| 5107 | psecuritypriv->busetkipkey = true; |
| 5108 | } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { |
| 5109 | psecuritypriv->dot118021XGrpPrivacy = _AES_; |
| 5110 | |
| 5111 | memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, |
| 5112 | param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); |
| 5113 | } else { |
| 5114 | psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; |
| 5115 | } |
| 5116 | |
| 5117 | psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx; |
| 5118 | |
| 5119 | psecuritypriv->binstallGrpkey = true; |
| 5120 | |
| 5121 | psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/* */ |
| 5122 | |
| 5123 | set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx); |
| 5124 | |
| 5125 | pbcmc_sta = rtw_get_bcmc_stainfo(padapter); |
| 5126 | if (pbcmc_sta) { |
| 5127 | pbcmc_sta->ieee8021x_blocked = false; |
| 5128 | pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */ |
| 5129 | } |
| 5130 | } |
| 5131 | } |
| 5132 | } |
| 5133 | |
| 5134 | exit: |
| 5135 | |
| 5136 | kfree(pwep); |
| 5137 | |
| 5138 | return ret; |
| 5139 | } |
| 5140 | |
| 5141 | static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int len) |
| 5142 | { |
| 5143 | int ret = 0; |
| 5144 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5145 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 5146 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 5147 | unsigned char *pbuf = param->u.bcn_ie.buf; |
| 5148 | |
| 5149 | DBG_88E("%s, len =%d\n", __func__, len); |
| 5150 | |
| 5151 | if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) |
| 5152 | return -EINVAL; |
| 5153 | |
| 5154 | memcpy(&pstapriv->max_num_sta, param->u.bcn_ie.reserved, 2); |
| 5155 | |
| 5156 | if ((pstapriv->max_num_sta > NUM_STA) || (pstapriv->max_num_sta <= 0)) |
| 5157 | pstapriv->max_num_sta = NUM_STA; |
| 5158 | |
| 5159 | if (rtw_check_beacon_data(padapter, pbuf, (len-12-2)) == _SUCCESS)/* 12 = param header, 2:no packed */ |
| 5160 | ret = 0; |
| 5161 | else |
| 5162 | ret = -EINVAL; |
| 5163 | |
| 5164 | return ret; |
| 5165 | } |
| 5166 | |
| 5167 | static int rtw_hostapd_sta_flush(struct net_device *dev) |
| 5168 | { |
| 5169 | int ret = 0; |
| 5170 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5171 | |
| 5172 | DBG_88E("%s\n", __func__); |
| 5173 | |
| 5174 | flush_all_cam_entry(padapter); /* clear CAM */ |
| 5175 | |
| 5176 | ret = rtw_sta_flush(padapter); |
| 5177 | |
| 5178 | return ret; |
| 5179 | } |
| 5180 | |
| 5181 | static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) |
| 5182 | { |
| 5183 | int ret = 0; |
| 5184 | struct sta_info *psta = NULL; |
| 5185 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5186 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 5187 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 5188 | |
| 5189 | DBG_88E("rtw_add_sta(aid =%d) =%pM\n", param->u.add_sta.aid, (param->sta_addr)); |
| 5190 | |
| 5191 | if (!check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE))) |
| 5192 | return -EINVAL; |
| 5193 | |
| 5194 | if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && |
| 5195 | param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && |
| 5196 | param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) |
| 5197 | return -EINVAL; |
| 5198 | |
| 5199 | psta = rtw_get_stainfo(pstapriv, param->sta_addr); |
| 5200 | if (psta) { |
| 5201 | int flags = param->u.add_sta.flags; |
| 5202 | |
| 5203 | psta->aid = param->u.add_sta.aid;/* aid = 1~2007 */ |
| 5204 | |
| 5205 | memcpy(psta->bssrateset, param->u.add_sta.tx_supp_rates, 16); |
| 5206 | |
| 5207 | /* check wmm cap. */ |
| 5208 | if (WLAN_STA_WME&flags) |
| 5209 | psta->qos_option = 1; |
| 5210 | else |
| 5211 | psta->qos_option = 0; |
| 5212 | |
| 5213 | if (pmlmepriv->qospriv.qos_option == 0) |
| 5214 | psta->qos_option = 0; |
| 5215 | |
| 5216 | /* chec 802.11n ht cap. */ |
| 5217 | if (WLAN_STA_HT&flags) { |
| 5218 | psta->htpriv.ht_option = true; |
| 5219 | psta->qos_option = 1; |
| 5220 | memcpy((void *)&psta->htpriv.ht_cap, (void *)¶m->u.add_sta.ht_cap, sizeof(struct rtw_ieee80211_ht_cap)); |
| 5221 | } else { |
| 5222 | psta->htpriv.ht_option = false; |
| 5223 | } |
| 5224 | |
| 5225 | if (pmlmepriv->htpriv.ht_option == false) |
| 5226 | psta->htpriv.ht_option = false; |
| 5227 | |
| 5228 | update_sta_info_apmode(padapter, psta); |
| 5229 | } else { |
| 5230 | ret = -ENOMEM; |
| 5231 | } |
| 5232 | |
| 5233 | return ret; |
| 5234 | } |
| 5235 | |
| 5236 | static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) |
| 5237 | { |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 5238 | int ret = 0; |
| 5239 | struct sta_info *psta = NULL; |
| 5240 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5241 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 5242 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 5243 | int updated = 0; |
| 5244 | |
| 5245 | DBG_88E("rtw_del_sta =%pM\n", (param->sta_addr)); |
| 5246 | |
| 5247 | if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) |
| 5248 | return -EINVAL; |
| 5249 | |
| 5250 | if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && |
| 5251 | param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && |
| 5252 | param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) |
| 5253 | return -EINVAL; |
| 5254 | |
| 5255 | psta = rtw_get_stainfo(pstapriv, param->sta_addr); |
| 5256 | if (psta) { |
Larry Finger | 7057dcb | 2013-12-19 22:38:34 -0600 | [diff] [blame] | 5257 | spin_lock_bh(&pstapriv->asoc_list_lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 5258 | if (!rtw_is_list_empty(&psta->asoc_list)) { |
| 5259 | rtw_list_delete(&psta->asoc_list); |
| 5260 | pstapriv->asoc_list_cnt--; |
| 5261 | updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); |
| 5262 | } |
Larry Finger | e02bcf6 | 2013-12-19 22:38:35 -0600 | [diff] [blame] | 5263 | spin_unlock_bh(&pstapriv->asoc_list_lock); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 5264 | associated_clients_update(padapter, updated); |
| 5265 | psta = NULL; |
| 5266 | } else { |
| 5267 | DBG_88E("rtw_del_sta(), sta has already been removed or never been added\n"); |
| 5268 | } |
| 5269 | |
| 5270 | return ret; |
| 5271 | } |
| 5272 | |
| 5273 | static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *param, int len) |
| 5274 | { |
| 5275 | int ret = 0; |
| 5276 | struct sta_info *psta = NULL; |
| 5277 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5278 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 5279 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 5280 | struct ieee_param_ex *param_ex = (struct ieee_param_ex *)param; |
| 5281 | struct sta_data *psta_data = (struct sta_data *)param_ex->data; |
| 5282 | |
| 5283 | DBG_88E("rtw_ioctl_get_sta_info, sta_addr: %pM\n", (param_ex->sta_addr)); |
| 5284 | |
| 5285 | if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) |
| 5286 | return -EINVAL; |
| 5287 | |
| 5288 | if (param_ex->sta_addr[0] == 0xff && param_ex->sta_addr[1] == 0xff && |
| 5289 | param_ex->sta_addr[2] == 0xff && param_ex->sta_addr[3] == 0xff && |
| 5290 | param_ex->sta_addr[4] == 0xff && param_ex->sta_addr[5] == 0xff) |
| 5291 | return -EINVAL; |
| 5292 | |
| 5293 | psta = rtw_get_stainfo(pstapriv, param_ex->sta_addr); |
| 5294 | if (psta) { |
| 5295 | psta_data->aid = (u16)psta->aid; |
| 5296 | psta_data->capability = psta->capability; |
| 5297 | psta_data->flags = psta->flags; |
| 5298 | |
| 5299 | /* |
| 5300 | nonerp_set : BIT(0) |
| 5301 | no_short_slot_time_set : BIT(1) |
| 5302 | no_short_preamble_set : BIT(2) |
| 5303 | no_ht_gf_set : BIT(3) |
| 5304 | no_ht_set : BIT(4) |
| 5305 | ht_20mhz_set : BIT(5) |
| 5306 | */ |
| 5307 | |
| 5308 | psta_data->sta_set = ((psta->nonerp_set) | |
| 5309 | (psta->no_short_slot_time_set << 1) | |
| 5310 | (psta->no_short_preamble_set << 2) | |
| 5311 | (psta->no_ht_gf_set << 3) | |
| 5312 | (psta->no_ht_set << 4) | |
| 5313 | (psta->ht_20mhz_set << 5)); |
| 5314 | psta_data->tx_supp_rates_len = psta->bssratelen; |
| 5315 | memcpy(psta_data->tx_supp_rates, psta->bssrateset, psta->bssratelen); |
| 5316 | memcpy(&psta_data->ht_cap, &psta->htpriv.ht_cap, sizeof(struct rtw_ieee80211_ht_cap)); |
| 5317 | psta_data->rx_pkts = psta->sta_stats.rx_data_pkts; |
| 5318 | psta_data->rx_bytes = psta->sta_stats.rx_bytes; |
| 5319 | psta_data->rx_drops = psta->sta_stats.rx_drops; |
| 5320 | psta_data->tx_pkts = psta->sta_stats.tx_pkts; |
| 5321 | psta_data->tx_bytes = psta->sta_stats.tx_bytes; |
| 5322 | psta_data->tx_drops = psta->sta_stats.tx_drops; |
| 5323 | } else { |
| 5324 | ret = -1; |
| 5325 | } |
| 5326 | |
| 5327 | return ret; |
| 5328 | } |
| 5329 | |
| 5330 | static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param) |
| 5331 | { |
| 5332 | int ret = 0; |
| 5333 | struct sta_info *psta = NULL; |
| 5334 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5335 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 5336 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 5337 | |
| 5338 | DBG_88E("rtw_get_sta_wpaie, sta_addr: %pM\n", (param->sta_addr)); |
| 5339 | |
| 5340 | if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) |
| 5341 | return -EINVAL; |
| 5342 | |
| 5343 | if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && |
| 5344 | param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && |
| 5345 | param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) |
| 5346 | return -EINVAL; |
| 5347 | |
| 5348 | psta = rtw_get_stainfo(pstapriv, param->sta_addr); |
| 5349 | if (psta) { |
| 5350 | if ((psta->wpa_ie[0] == WLAN_EID_RSN) || (psta->wpa_ie[0] == WLAN_EID_GENERIC)) { |
| 5351 | int wpa_ie_len; |
| 5352 | int copy_len; |
| 5353 | |
| 5354 | wpa_ie_len = psta->wpa_ie[1]; |
| 5355 | copy_len = ((wpa_ie_len+2) > sizeof(psta->wpa_ie)) ? (sizeof(psta->wpa_ie)) : (wpa_ie_len+2); |
| 5356 | param->u.wpa_ie.len = copy_len; |
| 5357 | memcpy(param->u.wpa_ie.reserved, psta->wpa_ie, copy_len); |
| 5358 | } else { |
| 5359 | DBG_88E("sta's wpa_ie is NONE\n"); |
| 5360 | } |
| 5361 | } else { |
| 5362 | ret = -1; |
| 5363 | } |
| 5364 | |
| 5365 | return ret; |
| 5366 | } |
| 5367 | |
| 5368 | static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, int len) |
| 5369 | { |
| 5370 | int ret = 0; |
| 5371 | unsigned char wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; |
| 5372 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5373 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 5374 | struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); |
| 5375 | int ie_len; |
| 5376 | |
| 5377 | DBG_88E("%s, len =%d\n", __func__, len); |
| 5378 | |
| 5379 | if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) |
| 5380 | return -EINVAL; |
| 5381 | |
| 5382 | ie_len = len-12-2;/* 12 = param header, 2:no packed */ |
| 5383 | |
| 5384 | if (pmlmepriv->wps_beacon_ie) { |
| 5385 | kfree(pmlmepriv->wps_beacon_ie); |
| 5386 | pmlmepriv->wps_beacon_ie = NULL; |
| 5387 | } |
| 5388 | |
| 5389 | if (ie_len > 0) { |
| 5390 | pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len); |
| 5391 | pmlmepriv->wps_beacon_ie_len = ie_len; |
| 5392 | if (pmlmepriv->wps_beacon_ie == NULL) { |
| 5393 | DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); |
| 5394 | return -EINVAL; |
| 5395 | } |
| 5396 | |
| 5397 | memcpy(pmlmepriv->wps_beacon_ie, param->u.bcn_ie.buf, ie_len); |
| 5398 | |
| 5399 | update_beacon(padapter, _VENDOR_SPECIFIC_IE_, wps_oui, true); |
| 5400 | |
| 5401 | pmlmeext->bstart_bss = true; |
| 5402 | } |
| 5403 | |
| 5404 | return ret; |
| 5405 | } |
| 5406 | |
| 5407 | static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *param, int len) |
| 5408 | { |
| 5409 | int ret = 0; |
| 5410 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5411 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 5412 | int ie_len; |
| 5413 | |
| 5414 | DBG_88E("%s, len =%d\n", __func__, len); |
| 5415 | |
| 5416 | if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) |
| 5417 | return -EINVAL; |
| 5418 | |
| 5419 | ie_len = len-12-2;/* 12 = param header, 2:no packed */ |
| 5420 | |
| 5421 | if (pmlmepriv->wps_probe_resp_ie) { |
| 5422 | kfree(pmlmepriv->wps_probe_resp_ie); |
| 5423 | pmlmepriv->wps_probe_resp_ie = NULL; |
| 5424 | } |
| 5425 | |
| 5426 | if (ie_len > 0) { |
| 5427 | pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len); |
| 5428 | pmlmepriv->wps_probe_resp_ie_len = ie_len; |
| 5429 | if (pmlmepriv->wps_probe_resp_ie == NULL) { |
| 5430 | DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); |
| 5431 | return -EINVAL; |
| 5432 | } |
| 5433 | memcpy(pmlmepriv->wps_probe_resp_ie, param->u.bcn_ie.buf, ie_len); |
| 5434 | } |
| 5435 | |
| 5436 | return ret; |
| 5437 | } |
| 5438 | |
| 5439 | static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *param, int len) |
| 5440 | { |
| 5441 | int ret = 0; |
| 5442 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5443 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 5444 | int ie_len; |
| 5445 | |
| 5446 | DBG_88E("%s, len =%d\n", __func__, len); |
| 5447 | |
| 5448 | if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) |
| 5449 | return -EINVAL; |
| 5450 | |
| 5451 | ie_len = len-12-2;/* 12 = param header, 2:no packed */ |
| 5452 | |
| 5453 | if (pmlmepriv->wps_assoc_resp_ie) { |
| 5454 | kfree(pmlmepriv->wps_assoc_resp_ie); |
| 5455 | pmlmepriv->wps_assoc_resp_ie = NULL; |
| 5456 | } |
| 5457 | |
| 5458 | if (ie_len > 0) { |
| 5459 | pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len); |
| 5460 | pmlmepriv->wps_assoc_resp_ie_len = ie_len; |
| 5461 | if (pmlmepriv->wps_assoc_resp_ie == NULL) { |
| 5462 | DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); |
| 5463 | return -EINVAL; |
| 5464 | } |
| 5465 | |
| 5466 | memcpy(pmlmepriv->wps_assoc_resp_ie, param->u.bcn_ie.buf, ie_len); |
| 5467 | } |
| 5468 | |
| 5469 | return ret; |
| 5470 | } |
| 5471 | |
| 5472 | static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, int len) |
| 5473 | { |
| 5474 | int ret = 0; |
| 5475 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5476 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 5477 | struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); |
| 5478 | struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); |
| 5479 | |
| 5480 | u8 value; |
| 5481 | |
| 5482 | if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) |
| 5483 | return -EINVAL; |
| 5484 | |
| 5485 | if (param->u.wpa_param.name != 0) /* dummy test... */ |
| 5486 | DBG_88E("%s name(%u) != 0\n", __func__, param->u.wpa_param.name); |
| 5487 | value = param->u.wpa_param.value; |
| 5488 | |
| 5489 | /* use the same definition of hostapd's ignore_broadcast_ssid */ |
| 5490 | if (value != 1 && value != 2) |
| 5491 | value = 0; |
| 5492 | DBG_88E("%s value(%u)\n", __func__, value); |
| 5493 | pmlmeinfo->hidden_ssid_mode = value; |
| 5494 | return ret; |
| 5495 | } |
| 5496 | |
| 5497 | static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len) |
| 5498 | { |
| 5499 | int ret = 0; |
| 5500 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5501 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 5502 | |
| 5503 | if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) |
| 5504 | return -EINVAL; |
| 5505 | |
| 5506 | if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && |
| 5507 | param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && |
| 5508 | param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) |
| 5509 | return -EINVAL; |
| 5510 | ret = rtw_acl_remove_sta(padapter, param->sta_addr); |
| 5511 | return ret; |
| 5512 | } |
| 5513 | |
| 5514 | static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *param, int len) |
| 5515 | { |
| 5516 | int ret = 0; |
| 5517 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5518 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 5519 | |
| 5520 | if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) |
| 5521 | return -EINVAL; |
| 5522 | |
| 5523 | if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && |
| 5524 | param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && |
| 5525 | param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) |
| 5526 | return -EINVAL; |
| 5527 | ret = rtw_acl_add_sta(padapter, param->sta_addr); |
| 5528 | return ret; |
| 5529 | } |
| 5530 | |
| 5531 | static int rtw_ioctl_set_macaddr_acl(struct net_device *dev, struct ieee_param *param, int len) |
| 5532 | { |
| 5533 | int ret = 0; |
| 5534 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5535 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 5536 | |
| 5537 | if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) |
| 5538 | return -EINVAL; |
| 5539 | |
| 5540 | rtw_set_macaddr_acl(padapter, param->u.mlme.command); |
| 5541 | |
| 5542 | return ret; |
| 5543 | } |
| 5544 | |
| 5545 | static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) |
| 5546 | { |
| 5547 | struct ieee_param *param; |
| 5548 | int ret = 0; |
| 5549 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5550 | |
| 5551 | /* |
| 5552 | * this function is expect to call in master mode, which allows no power saving |
| 5553 | * so, we just check hw_init_completed |
| 5554 | */ |
| 5555 | |
| 5556 | if (!padapter->hw_init_completed) { |
| 5557 | ret = -EPERM; |
| 5558 | goto out; |
| 5559 | } |
| 5560 | |
| 5561 | if (!p->pointer) { |
| 5562 | ret = -EINVAL; |
| 5563 | goto out; |
| 5564 | } |
| 5565 | |
| 5566 | param = (struct ieee_param *)rtw_malloc(p->length); |
| 5567 | if (param == NULL) { |
| 5568 | ret = -ENOMEM; |
| 5569 | goto out; |
| 5570 | } |
| 5571 | |
| 5572 | if (copy_from_user(param, p->pointer, p->length)) { |
| 5573 | kfree(param); |
| 5574 | ret = -EFAULT; |
| 5575 | goto out; |
| 5576 | } |
| 5577 | |
| 5578 | switch (param->cmd) { |
| 5579 | case RTL871X_HOSTAPD_FLUSH: |
| 5580 | ret = rtw_hostapd_sta_flush(dev); |
| 5581 | break; |
| 5582 | case RTL871X_HOSTAPD_ADD_STA: |
| 5583 | ret = rtw_add_sta(dev, param); |
| 5584 | break; |
| 5585 | case RTL871X_HOSTAPD_REMOVE_STA: |
| 5586 | ret = rtw_del_sta(dev, param); |
| 5587 | break; |
| 5588 | case RTL871X_HOSTAPD_SET_BEACON: |
| 5589 | ret = rtw_set_beacon(dev, param, p->length); |
| 5590 | break; |
| 5591 | case RTL871X_SET_ENCRYPTION: |
| 5592 | ret = rtw_set_encryption(dev, param, p->length); |
| 5593 | break; |
| 5594 | case RTL871X_HOSTAPD_GET_WPAIE_STA: |
| 5595 | ret = rtw_get_sta_wpaie(dev, param); |
| 5596 | break; |
| 5597 | case RTL871X_HOSTAPD_SET_WPS_BEACON: |
| 5598 | ret = rtw_set_wps_beacon(dev, param, p->length); |
| 5599 | break; |
| 5600 | case RTL871X_HOSTAPD_SET_WPS_PROBE_RESP: |
| 5601 | ret = rtw_set_wps_probe_resp(dev, param, p->length); |
| 5602 | break; |
| 5603 | case RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP: |
| 5604 | ret = rtw_set_wps_assoc_resp(dev, param, p->length); |
| 5605 | break; |
| 5606 | case RTL871X_HOSTAPD_SET_HIDDEN_SSID: |
| 5607 | ret = rtw_set_hidden_ssid(dev, param, p->length); |
| 5608 | break; |
| 5609 | case RTL871X_HOSTAPD_GET_INFO_STA: |
| 5610 | ret = rtw_ioctl_get_sta_data(dev, param, p->length); |
| 5611 | break; |
| 5612 | case RTL871X_HOSTAPD_SET_MACADDR_ACL: |
| 5613 | ret = rtw_ioctl_set_macaddr_acl(dev, param, p->length); |
| 5614 | break; |
| 5615 | case RTL871X_HOSTAPD_ACL_ADD_STA: |
| 5616 | ret = rtw_ioctl_acl_add_sta(dev, param, p->length); |
| 5617 | break; |
| 5618 | case RTL871X_HOSTAPD_ACL_REMOVE_STA: |
| 5619 | ret = rtw_ioctl_acl_remove_sta(dev, param, p->length); |
| 5620 | break; |
| 5621 | default: |
| 5622 | DBG_88E("Unknown hostapd request: %d\n", param->cmd); |
| 5623 | ret = -EOPNOTSUPP; |
| 5624 | break; |
| 5625 | } |
| 5626 | |
| 5627 | if (ret == 0 && copy_to_user(p->pointer, param, p->length)) |
| 5628 | ret = -EFAULT; |
| 5629 | kfree(param); |
| 5630 | out: |
| 5631 | return ret; |
| 5632 | } |
| 5633 | #endif |
| 5634 | |
| 5635 | #include <rtw_android.h> |
| 5636 | static int rtw_wx_set_priv(struct net_device *dev, |
| 5637 | struct iw_request_info *info, |
| 5638 | union iwreq_data *awrq, |
| 5639 | char *extra) |
| 5640 | { |
| 5641 | int ret = 0; |
| 5642 | int len = 0; |
| 5643 | char *ext; |
| 5644 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5645 | struct iw_point *dwrq = (struct iw_point *)awrq; |
| 5646 | |
| 5647 | if (dwrq->length == 0) |
| 5648 | return -EFAULT; |
| 5649 | |
| 5650 | len = dwrq->length; |
| 5651 | ext = rtw_vmalloc(len); |
| 5652 | if (!ext) |
| 5653 | return -ENOMEM; |
| 5654 | |
| 5655 | if (copy_from_user(ext, dwrq->pointer, len)) { |
| 5656 | rtw_vmfree(ext, len); |
| 5657 | return -EFAULT; |
| 5658 | } |
| 5659 | |
| 5660 | /* added for wps2.0 @20110524 */ |
| 5661 | if (dwrq->flags == 0x8766 && len > 8) { |
| 5662 | u32 cp_sz; |
| 5663 | struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); |
| 5664 | u8 *probereq_wpsie = ext; |
| 5665 | int probereq_wpsie_len = len; |
| 5666 | u8 wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; |
| 5667 | |
| 5668 | if ((_VENDOR_SPECIFIC_IE_ == probereq_wpsie[0]) && |
| 5669 | (!memcmp(&probereq_wpsie[2], wps_oui, 4))) { |
| 5670 | cp_sz = probereq_wpsie_len > MAX_WPS_IE_LEN ? MAX_WPS_IE_LEN : probereq_wpsie_len; |
| 5671 | |
| 5672 | pmlmepriv->wps_probe_req_ie_len = 0; |
| 5673 | kfree(pmlmepriv->wps_probe_req_ie); |
| 5674 | pmlmepriv->wps_probe_req_ie = NULL; |
| 5675 | |
| 5676 | pmlmepriv->wps_probe_req_ie = rtw_malloc(cp_sz); |
| 5677 | if (pmlmepriv->wps_probe_req_ie == NULL) { |
| 5678 | pr_info("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); |
| 5679 | ret = -EINVAL; |
| 5680 | goto FREE_EXT; |
| 5681 | } |
| 5682 | memcpy(pmlmepriv->wps_probe_req_ie, probereq_wpsie, cp_sz); |
| 5683 | pmlmepriv->wps_probe_req_ie_len = cp_sz; |
| 5684 | } |
| 5685 | goto FREE_EXT; |
| 5686 | } |
| 5687 | |
| 5688 | if (len >= WEXT_CSCAN_HEADER_SIZE && |
| 5689 | !memcmp(ext, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { |
| 5690 | ret = rtw_wx_set_scan(dev, info, awrq, ext); |
| 5691 | goto FREE_EXT; |
| 5692 | } |
| 5693 | |
| 5694 | FREE_EXT: |
| 5695 | |
| 5696 | rtw_vmfree(ext, len); |
| 5697 | |
| 5698 | return ret; |
| 5699 | } |
| 5700 | |
| 5701 | static int rtw_pm_set(struct net_device *dev, |
| 5702 | struct iw_request_info *info, |
| 5703 | union iwreq_data *wrqu, char *extra) |
| 5704 | { |
| 5705 | int ret = 0; |
| 5706 | unsigned mode = 0; |
| 5707 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 5708 | |
| 5709 | DBG_88E("[%s] extra = %s\n", __func__, extra); |
| 5710 | |
| 5711 | if (!memcmp(extra, "lps =", 4)) { |
| 5712 | sscanf(extra+4, "%u", &mode); |
| 5713 | ret = rtw_pm_set_lps(padapter, mode); |
| 5714 | } else if (!memcmp(extra, "ips =", 4)) { |
| 5715 | sscanf(extra+4, "%u", &mode); |
| 5716 | ret = rtw_pm_set_ips(padapter, mode); |
| 5717 | } else { |
| 5718 | ret = -EINVAL; |
| 5719 | } |
| 5720 | |
| 5721 | return ret; |
| 5722 | } |
| 5723 | |
| 5724 | static int rtw_mp_efuse_get(struct net_device *dev, |
| 5725 | struct iw_request_info *info, |
| 5726 | union iwreq_data *wdata, char *extra) |
| 5727 | { |
| 5728 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 5729 | struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); |
| 5730 | struct hal_data_8188e *haldata = GET_HAL_DATA(padapter); |
| 5731 | struct efuse_hal *pEfuseHal; |
| 5732 | struct iw_point *wrqu; |
| 5733 | |
| 5734 | u8 *PROMContent = pEEPROM->efuse_eeprom_data; |
| 5735 | u8 ips_mode = 0, lps_mode = 0; |
| 5736 | struct pwrctrl_priv *pwrctrlpriv; |
| 5737 | u8 *data = NULL; |
| 5738 | u8 *rawdata = NULL; |
| 5739 | char *pch, *ptmp, *token, *tmp[3] = {NULL, NULL, NULL}; |
| 5740 | u16 i = 0, j = 0, mapLen = 0, addr = 0, cnts = 0; |
| 5741 | u16 max_available_size = 0, raw_cursize = 0, raw_maxsize = 0; |
| 5742 | int err; |
| 5743 | u8 org_fw_iol = padapter->registrypriv.fw_iol;/* 0:Disable, 1:enable, 2:by usb speed */ |
| 5744 | |
| 5745 | wrqu = (struct iw_point *)wdata; |
| 5746 | pwrctrlpriv = &padapter->pwrctrlpriv; |
| 5747 | pEfuseHal = &haldata->EfuseHal; |
| 5748 | |
| 5749 | err = 0; |
| 5750 | data = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); |
| 5751 | if (data == NULL) { |
| 5752 | err = -ENOMEM; |
| 5753 | goto exit; |
| 5754 | } |
| 5755 | rawdata = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); |
| 5756 | if (rawdata == NULL) { |
| 5757 | err = -ENOMEM; |
| 5758 | goto exit; |
| 5759 | } |
| 5760 | |
| 5761 | if (copy_from_user(extra, wrqu->pointer, wrqu->length)) { |
| 5762 | err = -EFAULT; |
| 5763 | goto exit; |
| 5764 | } |
| 5765 | lps_mode = pwrctrlpriv->power_mgnt;/* keep org value */ |
| 5766 | rtw_pm_set_lps(padapter, PS_MODE_ACTIVE); |
| 5767 | |
| 5768 | ips_mode = pwrctrlpriv->ips_mode;/* keep org value */ |
| 5769 | rtw_pm_set_ips(padapter, IPS_NONE); |
| 5770 | |
| 5771 | pch = extra; |
| 5772 | DBG_88E("%s: in =%s\n", __func__, extra); |
| 5773 | |
| 5774 | i = 0; |
| 5775 | /* mac 16 "00e04c871200" rmap, 00, 2 */ |
| 5776 | while ((token = strsep(&pch, ",")) != NULL) { |
| 5777 | if (i > 2) |
| 5778 | break; |
| 5779 | tmp[i] = token; |
| 5780 | i++; |
| 5781 | } |
| 5782 | padapter->registrypriv.fw_iol = 0;/* 0:Disable, 1:enable, 2:by usb speed */ |
| 5783 | |
| 5784 | if (strcmp(tmp[0], "status") == 0) { |
| 5785 | sprintf(extra, "Load File efuse =%s, Load File MAC =%s", (pEEPROM->bloadfile_fail_flag ? "FAIL" : "OK"), (pEEPROM->bloadmac_fail_flag ? "FAIL" : "OK")); |
| 5786 | |
| 5787 | goto exit; |
| 5788 | } else if (strcmp(tmp[0], "filemap") == 0) { |
| 5789 | mapLen = EFUSE_MAP_SIZE; |
| 5790 | |
| 5791 | sprintf(extra, "\n"); |
| 5792 | for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { |
| 5793 | sprintf(extra, "%s0x%02x\t", extra, i); |
| 5794 | for (j = 0; j < 8; j++) |
| 5795 | sprintf(extra, "%s%02X ", extra, PROMContent[i+j]); |
| 5796 | sprintf(extra, "%s\t", extra); |
| 5797 | for (; j < 16; j++) |
| 5798 | sprintf(extra, "%s%02X ", extra, PROMContent[i+j]); |
| 5799 | sprintf(extra, "%s\n", extra); |
| 5800 | } |
| 5801 | } else if (strcmp(tmp[0], "realmap") == 0) { |
| 5802 | mapLen = EFUSE_MAP_SIZE; |
| 5803 | if (rtw_efuse_map_read(padapter, 0, mapLen, pEfuseHal->fakeEfuseInitMap) == _FAIL) { |
| 5804 | DBG_88E("%s: read realmap Fail!!\n", __func__); |
| 5805 | err = -EFAULT; |
| 5806 | goto exit; |
| 5807 | } |
| 5808 | |
| 5809 | sprintf(extra, "\n"); |
| 5810 | for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { |
| 5811 | sprintf(extra, "%s0x%02x\t", extra, i); |
| 5812 | for (j = 0; j < 8; j++) |
| 5813 | sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]); |
| 5814 | sprintf(extra, "%s\t", extra); |
| 5815 | for (; j < 16; j++) |
| 5816 | sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]); |
| 5817 | sprintf(extra, "%s\n", extra); |
| 5818 | } |
| 5819 | } else if (strcmp(tmp[0], "rmap") == 0) { |
| 5820 | if ((tmp[1] == NULL) || (tmp[2] == NULL)) { |
| 5821 | DBG_88E("%s: rmap Fail!! Parameters error!\n", __func__); |
| 5822 | err = -EINVAL; |
| 5823 | goto exit; |
| 5824 | } |
| 5825 | |
| 5826 | /* rmap addr cnts */ |
| 5827 | addr = simple_strtoul(tmp[1], &ptmp, 16); |
| 5828 | DBG_88E("%s: addr =%x\n", __func__, addr); |
| 5829 | |
| 5830 | cnts = simple_strtoul(tmp[2], &ptmp, 10); |
| 5831 | if (cnts == 0) { |
| 5832 | DBG_88E("%s: rmap Fail!! cnts error!\n", __func__); |
| 5833 | err = -EINVAL; |
| 5834 | goto exit; |
| 5835 | } |
| 5836 | DBG_88E("%s: cnts =%d\n", __func__, cnts); |
| 5837 | |
| 5838 | EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); |
| 5839 | if ((addr + cnts) > max_available_size) { |
| 5840 | DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); |
| 5841 | err = -EINVAL; |
| 5842 | goto exit; |
| 5843 | } |
| 5844 | |
| 5845 | if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { |
| 5846 | DBG_88E("%s: rtw_efuse_map_read error!\n", __func__); |
| 5847 | err = -EFAULT; |
| 5848 | goto exit; |
| 5849 | } |
| 5850 | |
| 5851 | *extra = 0; |
| 5852 | for (i = 0; i < cnts; i++) |
| 5853 | sprintf(extra, "%s0x%02X ", extra, data[i]); |
| 5854 | } else if (strcmp(tmp[0], "realraw") == 0) { |
| 5855 | addr = 0; |
| 5856 | mapLen = EFUSE_MAX_SIZE; |
| 5857 | if (rtw_efuse_access(padapter, false, addr, mapLen, rawdata) == _FAIL) { |
| 5858 | DBG_88E("%s: rtw_efuse_access Fail!!\n", __func__); |
| 5859 | err = -EFAULT; |
| 5860 | goto exit; |
| 5861 | } |
| 5862 | |
| 5863 | sprintf(extra, "\n"); |
| 5864 | for (i = 0; i < mapLen; i++) { |
| 5865 | sprintf(extra, "%s%02X", extra, rawdata[i]); |
| 5866 | |
| 5867 | if ((i & 0xF) == 0xF) |
| 5868 | sprintf(extra, "%s\n", extra); |
| 5869 | else if ((i & 0x7) == 0x7) |
| 5870 | sprintf(extra, "%s\t", extra); |
| 5871 | else |
| 5872 | sprintf(extra, "%s ", extra); |
| 5873 | } |
| 5874 | } else if (strcmp(tmp[0], "mac") == 0) { |
| 5875 | cnts = 6; |
| 5876 | |
| 5877 | EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); |
| 5878 | if ((addr + cnts) > max_available_size) { |
| 5879 | DBG_88E("%s: addr(0x%02x)+cnts(%d) parameter error!\n", __func__, addr, cnts); |
| 5880 | err = -EFAULT; |
| 5881 | goto exit; |
| 5882 | } |
| 5883 | |
| 5884 | if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { |
| 5885 | DBG_88E("%s: rtw_efuse_map_read error!\n", __func__); |
| 5886 | err = -EFAULT; |
| 5887 | goto exit; |
| 5888 | } |
| 5889 | |
| 5890 | *extra = 0; |
| 5891 | for (i = 0; i < cnts; i++) { |
| 5892 | sprintf(extra, "%s%02X", extra, data[i]); |
| 5893 | if (i != (cnts-1)) |
| 5894 | sprintf(extra, "%s:", extra); |
| 5895 | } |
| 5896 | } else if (strcmp(tmp[0], "vidpid") == 0) { |
| 5897 | cnts = 4; |
| 5898 | |
| 5899 | EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); |
| 5900 | if ((addr + cnts) > max_available_size) { |
| 5901 | DBG_88E("%s: addr(0x%02x)+cnts(%d) parameter error!\n", __func__, addr, cnts); |
| 5902 | err = -EFAULT; |
| 5903 | goto exit; |
| 5904 | } |
| 5905 | if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { |
| 5906 | DBG_88E("%s: rtw_efuse_access error!!\n", __func__); |
| 5907 | err = -EFAULT; |
| 5908 | goto exit; |
| 5909 | } |
| 5910 | |
| 5911 | *extra = 0; |
| 5912 | for (i = 0; i < cnts; i++) { |
| 5913 | sprintf(extra, "%s0x%02X", extra, data[i]); |
| 5914 | if (i != (cnts-1)) |
| 5915 | sprintf(extra, "%s,", extra); |
| 5916 | } |
| 5917 | } else if (strcmp(tmp[0], "ableraw") == 0) { |
| 5918 | efuse_GetCurrentSize(padapter, &raw_cursize); |
| 5919 | raw_maxsize = efuse_GetMaxSize(padapter); |
| 5920 | sprintf(extra, "[available raw size] = %d bytes", raw_maxsize-raw_cursize); |
| 5921 | } else if (strcmp(tmp[0], "btfmap") == 0) { |
| 5922 | mapLen = EFUSE_BT_MAX_MAP_LEN; |
| 5923 | if (rtw_BT_efuse_map_read(padapter, 0, mapLen, pEfuseHal->BTEfuseInitMap) == _FAIL) { |
| 5924 | DBG_88E("%s: rtw_BT_efuse_map_read Fail!!\n", __func__); |
| 5925 | err = -EFAULT; |
| 5926 | goto exit; |
| 5927 | } |
| 5928 | |
| 5929 | sprintf(extra, "\n"); |
| 5930 | for (i = 0; i < 512; i += 16) { |
| 5931 | /* set 512 because the iwpriv's extra size have limit 0x7FF */ |
| 5932 | sprintf(extra, "%s0x%03x\t", extra, i); |
| 5933 | for (j = 0; j < 8; j++) |
| 5934 | sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); |
| 5935 | sprintf(extra, "%s\t", extra); |
| 5936 | for (; j < 16; j++) |
| 5937 | sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); |
| 5938 | sprintf(extra, "%s\n", extra); |
| 5939 | } |
| 5940 | } else if (strcmp(tmp[0], "btbmap") == 0) { |
| 5941 | mapLen = EFUSE_BT_MAX_MAP_LEN; |
| 5942 | if (rtw_BT_efuse_map_read(padapter, 0, mapLen, pEfuseHal->BTEfuseInitMap) == _FAIL) { |
| 5943 | DBG_88E("%s: rtw_BT_efuse_map_read Fail!!\n", __func__); |
| 5944 | err = -EFAULT; |
| 5945 | goto exit; |
| 5946 | } |
| 5947 | |
| 5948 | sprintf(extra, "\n"); |
| 5949 | for (i = 512; i < 1024; i += 16) { |
| 5950 | sprintf(extra, "%s0x%03x\t", extra, i); |
| 5951 | for (j = 0; j < 8; j++) |
| 5952 | sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); |
| 5953 | sprintf(extra, "%s\t", extra); |
| 5954 | for (; j < 16; j++) |
| 5955 | sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); |
| 5956 | sprintf(extra, "%s\n", extra); |
| 5957 | } |
| 5958 | } else if (strcmp(tmp[0], "btrmap") == 0) { |
| 5959 | if ((tmp[1] == NULL) || (tmp[2] == NULL)) { |
| 5960 | err = -EINVAL; |
| 5961 | goto exit; |
| 5962 | } |
| 5963 | |
| 5964 | /* rmap addr cnts */ |
| 5965 | addr = simple_strtoul(tmp[1], &ptmp, 16); |
| 5966 | DBG_88E("%s: addr = 0x%X\n", __func__, addr); |
| 5967 | |
| 5968 | cnts = simple_strtoul(tmp[2], &ptmp, 10); |
| 5969 | if (cnts == 0) { |
| 5970 | DBG_88E("%s: btrmap Fail!! cnts error!\n", __func__); |
| 5971 | err = -EINVAL; |
| 5972 | goto exit; |
| 5973 | } |
| 5974 | DBG_88E("%s: cnts =%d\n", __func__, cnts); |
| 5975 | |
| 5976 | EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); |
| 5977 | if ((addr + cnts) > max_available_size) { |
| 5978 | DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); |
| 5979 | err = -EFAULT; |
| 5980 | goto exit; |
| 5981 | } |
| 5982 | |
| 5983 | if (rtw_BT_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { |
| 5984 | DBG_88E("%s: rtw_BT_efuse_map_read error!!\n", __func__); |
| 5985 | err = -EFAULT; |
| 5986 | goto exit; |
| 5987 | } |
| 5988 | |
| 5989 | *extra = 0; |
| 5990 | for (i = 0; i < cnts; i++) |
| 5991 | sprintf(extra, "%s 0x%02X ", extra, data[i]); |
| 5992 | } else if (strcmp(tmp[0], "btffake") == 0) { |
| 5993 | sprintf(extra, "\n"); |
| 5994 | for (i = 0; i < 512; i += 16) { |
| 5995 | sprintf(extra, "%s0x%03x\t", extra, i); |
| 5996 | for (j = 0; j < 8; j++) |
| 5997 | sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); |
| 5998 | sprintf(extra, "%s\t", extra); |
| 5999 | for (; j < 16; j++) |
| 6000 | sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); |
| 6001 | sprintf(extra, "%s\n", extra); |
| 6002 | } |
| 6003 | } else if (strcmp(tmp[0], "btbfake") == 0) { |
| 6004 | sprintf(extra, "\n"); |
| 6005 | for (i = 512; i < 1024; i += 16) { |
| 6006 | sprintf(extra, "%s0x%03x\t", extra, i); |
| 6007 | for (j = 0; j < 8; j++) |
| 6008 | sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); |
| 6009 | sprintf(extra, "%s\t", extra); |
| 6010 | for (; j < 16; j++) |
| 6011 | sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); |
| 6012 | sprintf(extra, "%s\n", extra); |
| 6013 | } |
| 6014 | } else if (strcmp(tmp[0], "wlrfkmap") == 0) { |
| 6015 | sprintf(extra, "\n"); |
| 6016 | for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { |
| 6017 | sprintf(extra, "%s0x%02x\t", extra, i); |
| 6018 | for (j = 0; j < 8; j++) |
| 6019 | sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]); |
| 6020 | sprintf(extra, "%s\t", extra); |
| 6021 | for (; j < 16; j++) |
| 6022 | sprintf(extra, "%s %02X", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]); |
| 6023 | sprintf(extra, "%s\n", extra); |
| 6024 | } |
| 6025 | } else { |
| 6026 | sprintf(extra, "Command not found!"); |
| 6027 | } |
| 6028 | |
| 6029 | exit: |
| 6030 | kfree(data); |
| 6031 | kfree(rawdata); |
| 6032 | if (!err) |
| 6033 | wrqu->length = strlen(extra); |
| 6034 | |
| 6035 | rtw_pm_set_ips(padapter, ips_mode); |
| 6036 | rtw_pm_set_lps(padapter, lps_mode); |
| 6037 | padapter->registrypriv.fw_iol = org_fw_iol;/* 0:Disable, 1:enable, 2:by usb speed */ |
| 6038 | return err; |
| 6039 | } |
| 6040 | |
| 6041 | static int rtw_mp_efuse_set(struct net_device *dev, |
| 6042 | struct iw_request_info *info, |
| 6043 | union iwreq_data *wdata, char *extra) |
| 6044 | { |
| 6045 | struct adapter *padapter; |
| 6046 | struct pwrctrl_priv *pwrctrlpriv; |
| 6047 | struct hal_data_8188e *haldata; |
| 6048 | struct efuse_hal *pEfuseHal; |
| 6049 | |
| 6050 | u8 ips_mode = 0, lps_mode = 0; |
| 6051 | u32 i, jj, kk; |
| 6052 | u8 *setdata = NULL; |
| 6053 | u8 *ShadowMapBT = NULL; |
| 6054 | u8 *ShadowMapWiFi = NULL; |
| 6055 | u8 *setrawdata = NULL; |
| 6056 | char *pch, *ptmp, *token, *tmp[3] = {NULL, NULL, NULL}; |
| 6057 | u16 addr = 0, cnts = 0, max_available_size = 0; |
| 6058 | int err; |
| 6059 | |
| 6060 | padapter = rtw_netdev_priv(dev); |
| 6061 | pwrctrlpriv = &padapter->pwrctrlpriv; |
| 6062 | haldata = GET_HAL_DATA(padapter); |
| 6063 | pEfuseHal = &haldata->EfuseHal; |
| 6064 | err = 0; |
| 6065 | setdata = _rtw_zmalloc(1024); |
| 6066 | if (setdata == NULL) { |
| 6067 | err = -ENOMEM; |
| 6068 | goto exit; |
| 6069 | } |
| 6070 | ShadowMapBT = _rtw_malloc(EFUSE_BT_MAX_MAP_LEN); |
| 6071 | if (ShadowMapBT == NULL) { |
| 6072 | err = -ENOMEM; |
| 6073 | goto exit; |
| 6074 | } |
| 6075 | ShadowMapWiFi = _rtw_malloc(EFUSE_MAP_SIZE); |
| 6076 | if (ShadowMapWiFi == NULL) { |
| 6077 | err = -ENOMEM; |
| 6078 | goto exit; |
| 6079 | } |
| 6080 | setrawdata = _rtw_malloc(EFUSE_MAX_SIZE); |
| 6081 | if (setrawdata == NULL) { |
| 6082 | err = -ENOMEM; |
| 6083 | goto exit; |
| 6084 | } |
| 6085 | |
| 6086 | lps_mode = pwrctrlpriv->power_mgnt;/* keep org value */ |
| 6087 | rtw_pm_set_lps(padapter, PS_MODE_ACTIVE); |
| 6088 | |
| 6089 | ips_mode = pwrctrlpriv->ips_mode;/* keep org value */ |
| 6090 | rtw_pm_set_ips(padapter, IPS_NONE); |
| 6091 | |
| 6092 | pch = extra; |
| 6093 | DBG_88E("%s: in =%s\n", __func__, extra); |
| 6094 | |
| 6095 | i = 0; |
| 6096 | while ((token = strsep(&pch, ",")) != NULL) { |
| 6097 | if (i > 2) |
| 6098 | break; |
| 6099 | tmp[i] = token; |
| 6100 | i++; |
| 6101 | } |
| 6102 | |
| 6103 | /* tmp[0],[1],[2] */ |
| 6104 | /* wmap, addr, 00e04c871200 */ |
| 6105 | if (strcmp(tmp[0], "wmap") == 0) { |
| 6106 | if ((tmp[1] == NULL) || (tmp[2] == NULL)) { |
| 6107 | err = -EINVAL; |
| 6108 | goto exit; |
| 6109 | } |
| 6110 | |
| 6111 | addr = simple_strtoul(tmp[1], &ptmp, 16); |
| 6112 | addr &= 0xFFF; |
| 6113 | |
| 6114 | cnts = strlen(tmp[2]); |
| 6115 | if (cnts%2) { |
| 6116 | err = -EINVAL; |
| 6117 | goto exit; |
| 6118 | } |
| 6119 | cnts /= 2; |
| 6120 | if (cnts == 0) { |
| 6121 | err = -EINVAL; |
| 6122 | goto exit; |
| 6123 | } |
| 6124 | |
| 6125 | DBG_88E("%s: addr = 0x%X\n", __func__, addr); |
| 6126 | DBG_88E("%s: cnts =%d\n", __func__, cnts); |
| 6127 | DBG_88E("%s: map data =%s\n", __func__, tmp[2]); |
| 6128 | |
| 6129 | for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) |
| 6130 | setdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); |
Masanari Iida | 7efc02c | 2013-09-27 00:11:46 +0900 | [diff] [blame] | 6131 | /* Change to check TYPE_EFUSE_MAP_LEN, because 8188E raw 256, logic map over 256. */ |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 6132 | EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&max_available_size, false); |
| 6133 | if ((addr+cnts) > max_available_size) { |
| 6134 | DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); |
| 6135 | err = -EFAULT; |
| 6136 | goto exit; |
| 6137 | } |
| 6138 | |
| 6139 | if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { |
| 6140 | DBG_88E("%s: rtw_efuse_map_write error!!\n", __func__); |
| 6141 | err = -EFAULT; |
| 6142 | goto exit; |
| 6143 | } |
| 6144 | } else if (strcmp(tmp[0], "wraw") == 0) { |
| 6145 | if ((tmp[1] == NULL) || (tmp[2] == NULL)) { |
| 6146 | err = -EINVAL; |
| 6147 | goto exit; |
| 6148 | } |
| 6149 | |
| 6150 | addr = simple_strtoul(tmp[1], &ptmp, 16); |
| 6151 | addr &= 0xFFF; |
| 6152 | |
| 6153 | cnts = strlen(tmp[2]); |
| 6154 | if (cnts%2) { |
| 6155 | err = -EINVAL; |
| 6156 | goto exit; |
| 6157 | } |
| 6158 | cnts /= 2; |
| 6159 | if (cnts == 0) { |
| 6160 | err = -EINVAL; |
| 6161 | goto exit; |
| 6162 | } |
| 6163 | |
| 6164 | DBG_88E("%s: addr = 0x%X\n", __func__, addr); |
| 6165 | DBG_88E("%s: cnts =%d\n", __func__, cnts); |
| 6166 | DBG_88E("%s: raw data =%s\n", __func__, tmp[2]); |
| 6167 | |
| 6168 | for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) |
| 6169 | setrawdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); |
| 6170 | |
| 6171 | if (rtw_efuse_access(padapter, true, addr, cnts, setrawdata) == _FAIL) { |
| 6172 | DBG_88E("%s: rtw_efuse_access error!!\n", __func__); |
| 6173 | err = -EFAULT; |
| 6174 | goto exit; |
| 6175 | } |
| 6176 | } else if (strcmp(tmp[0], "mac") == 0) { |
| 6177 | if (tmp[1] == NULL) { |
| 6178 | err = -EINVAL; |
| 6179 | goto exit; |
| 6180 | } |
| 6181 | |
| 6182 | /* mac, 00e04c871200 */ |
| 6183 | addr = EEPROM_MAC_ADDR_88EU; |
| 6184 | cnts = strlen(tmp[1]); |
| 6185 | if (cnts%2) { |
| 6186 | err = -EINVAL; |
| 6187 | goto exit; |
| 6188 | } |
| 6189 | cnts /= 2; |
| 6190 | if (cnts == 0) { |
| 6191 | err = -EINVAL; |
| 6192 | goto exit; |
| 6193 | } |
| 6194 | if (cnts > 6) { |
| 6195 | DBG_88E("%s: error data for mac addr =\"%s\"\n", __func__, tmp[1]); |
| 6196 | err = -EFAULT; |
| 6197 | goto exit; |
| 6198 | } |
| 6199 | |
| 6200 | DBG_88E("%s: addr = 0x%X\n", __func__, addr); |
| 6201 | DBG_88E("%s: cnts =%d\n", __func__, cnts); |
| 6202 | DBG_88E("%s: MAC address =%s\n", __func__, tmp[1]); |
| 6203 | |
| 6204 | for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) |
| 6205 | setdata[jj] = key_2char2num(tmp[1][kk], tmp[1][kk + 1]); |
Masanari Iida | 7efc02c | 2013-09-27 00:11:46 +0900 | [diff] [blame] | 6206 | /* Change to check TYPE_EFUSE_MAP_LEN, because 8188E raw 256, logic map over 256. */ |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 6207 | EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&max_available_size, false); |
| 6208 | if ((addr+cnts) > max_available_size) { |
| 6209 | DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); |
| 6210 | err = -EFAULT; |
| 6211 | goto exit; |
| 6212 | } |
| 6213 | |
| 6214 | if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { |
| 6215 | DBG_88E("%s: rtw_efuse_map_write error!!\n", __func__); |
| 6216 | err = -EFAULT; |
| 6217 | goto exit; |
| 6218 | } |
| 6219 | } else if (strcmp(tmp[0], "vidpid") == 0) { |
| 6220 | if (tmp[1] == NULL) { |
| 6221 | err = -EINVAL; |
| 6222 | goto exit; |
| 6223 | } |
| 6224 | |
| 6225 | /* pidvid, da0b7881 */ |
| 6226 | addr = EEPROM_VID_88EE; |
| 6227 | cnts = strlen(tmp[1]); |
| 6228 | if (cnts%2) { |
| 6229 | err = -EINVAL; |
| 6230 | goto exit; |
| 6231 | } |
| 6232 | cnts /= 2; |
| 6233 | if (cnts == 0) { |
| 6234 | err = -EINVAL; |
| 6235 | goto exit; |
| 6236 | } |
| 6237 | |
| 6238 | DBG_88E("%s: addr = 0x%X\n", __func__, addr); |
| 6239 | DBG_88E("%s: cnts =%d\n", __func__, cnts); |
| 6240 | DBG_88E("%s: VID/PID =%s\n", __func__, tmp[1]); |
| 6241 | |
| 6242 | for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) |
| 6243 | setdata[jj] = key_2char2num(tmp[1][kk], tmp[1][kk + 1]); |
| 6244 | |
| 6245 | EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); |
| 6246 | if ((addr+cnts) > max_available_size) { |
| 6247 | DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); |
| 6248 | err = -EFAULT; |
| 6249 | goto exit; |
| 6250 | } |
| 6251 | |
| 6252 | if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { |
| 6253 | DBG_88E("%s: rtw_efuse_map_write error!!\n", __func__); |
| 6254 | err = -EFAULT; |
| 6255 | goto exit; |
| 6256 | } |
| 6257 | } else if (strcmp(tmp[0], "btwmap") == 0) { |
| 6258 | if ((tmp[1] == NULL) || (tmp[2] == NULL)) { |
| 6259 | err = -EINVAL; |
| 6260 | goto exit; |
| 6261 | } |
| 6262 | |
| 6263 | addr = simple_strtoul(tmp[1], &ptmp, 16); |
| 6264 | addr &= 0xFFF; |
| 6265 | |
| 6266 | cnts = strlen(tmp[2]); |
| 6267 | if (cnts%2) { |
| 6268 | err = -EINVAL; |
| 6269 | goto exit; |
| 6270 | } |
| 6271 | cnts /= 2; |
| 6272 | if (cnts == 0) { |
| 6273 | err = -EINVAL; |
| 6274 | goto exit; |
| 6275 | } |
| 6276 | |
| 6277 | DBG_88E("%s: addr = 0x%X\n", __func__, addr); |
| 6278 | DBG_88E("%s: cnts =%d\n", __func__, cnts); |
| 6279 | DBG_88E("%s: BT data =%s\n", __func__, tmp[2]); |
| 6280 | |
| 6281 | for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) |
| 6282 | setdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); |
| 6283 | |
| 6284 | EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); |
| 6285 | if ((addr+cnts) > max_available_size) { |
| 6286 | DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); |
| 6287 | err = -EFAULT; |
| 6288 | goto exit; |
| 6289 | } |
| 6290 | |
| 6291 | if (rtw_BT_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { |
| 6292 | DBG_88E("%s: rtw_BT_efuse_map_write error!!\n", __func__); |
| 6293 | err = -EFAULT; |
| 6294 | goto exit; |
| 6295 | } |
| 6296 | } else if (strcmp(tmp[0], "btwfake") == 0) { |
| 6297 | if ((tmp[1] == NULL) || (tmp[2] == NULL)) { |
| 6298 | err = -EINVAL; |
| 6299 | goto exit; |
| 6300 | } |
| 6301 | |
| 6302 | addr = simple_strtoul(tmp[1], &ptmp, 16); |
| 6303 | addr &= 0xFFF; |
| 6304 | |
| 6305 | cnts = strlen(tmp[2]); |
| 6306 | if (cnts%2) { |
| 6307 | err = -EINVAL; |
| 6308 | goto exit; |
| 6309 | } |
| 6310 | cnts /= 2; |
| 6311 | if (cnts == 0) { |
| 6312 | err = -EINVAL; |
| 6313 | goto exit; |
| 6314 | } |
| 6315 | |
| 6316 | DBG_88E("%s: addr = 0x%X\n", __func__, addr); |
| 6317 | DBG_88E("%s: cnts =%d\n", __func__, cnts); |
| 6318 | DBG_88E("%s: BT tmp data =%s\n", __func__, tmp[2]); |
| 6319 | |
| 6320 | for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) |
| 6321 | pEfuseHal->fakeBTEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); |
| 6322 | } else if (strcmp(tmp[0], "btdumpfake") == 0) { |
| 6323 | if (rtw_BT_efuse_map_read(padapter, 0, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeBTEfuseModifiedMap) == _SUCCESS) { |
| 6324 | DBG_88E("%s: BT read all map success\n", __func__); |
| 6325 | } else { |
| 6326 | DBG_88E("%s: BT read all map Fail!\n", __func__); |
| 6327 | err = -EFAULT; |
| 6328 | } |
| 6329 | } else if (strcmp(tmp[0], "wldumpfake") == 0) { |
| 6330 | if (rtw_efuse_map_read(padapter, 0, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeEfuseModifiedMap) == _SUCCESS) { |
| 6331 | DBG_88E("%s: BT read all map success\n", __func__); |
| 6332 | } else { |
| 6333 | DBG_88E("%s: BT read all map Fail\n", __func__); |
| 6334 | err = -EFAULT; |
| 6335 | } |
| 6336 | } else if (strcmp(tmp[0], "btfk2map") == 0) { |
| 6337 | memcpy(pEfuseHal->BTEfuseModifiedMap, pEfuseHal->fakeBTEfuseModifiedMap, EFUSE_BT_MAX_MAP_LEN); |
| 6338 | |
| 6339 | EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); |
| 6340 | if (max_available_size < 1) { |
| 6341 | err = -EFAULT; |
| 6342 | goto exit; |
| 6343 | } |
| 6344 | |
| 6345 | if (rtw_BT_efuse_map_write(padapter, 0x00, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeBTEfuseModifiedMap) == _FAIL) { |
| 6346 | DBG_88E("%s: rtw_BT_efuse_map_write error!\n", __func__); |
| 6347 | err = -EFAULT; |
| 6348 | goto exit; |
| 6349 | } |
| 6350 | } else if (strcmp(tmp[0], "wlfk2map") == 0) { |
| 6351 | EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); |
| 6352 | if (max_available_size < 1) { |
| 6353 | err = -EFAULT; |
| 6354 | goto exit; |
| 6355 | } |
| 6356 | |
| 6357 | if (rtw_efuse_map_write(padapter, 0x00, EFUSE_MAX_MAP_LEN, pEfuseHal->fakeEfuseModifiedMap) == _FAIL) { |
| 6358 | DBG_88E("%s: rtw_efuse_map_write error!\n", __func__); |
| 6359 | err = -EFAULT; |
| 6360 | goto exit; |
| 6361 | } |
| 6362 | } else if (strcmp(tmp[0], "wlwfake") == 0) { |
| 6363 | if ((tmp[1] == NULL) || (tmp[2] == NULL)) { |
| 6364 | err = -EINVAL; |
| 6365 | goto exit; |
| 6366 | } |
| 6367 | |
| 6368 | addr = simple_strtoul(tmp[1], &ptmp, 16); |
| 6369 | addr &= 0xFFF; |
| 6370 | |
| 6371 | cnts = strlen(tmp[2]); |
| 6372 | if (cnts%2) { |
| 6373 | err = -EINVAL; |
| 6374 | goto exit; |
| 6375 | } |
| 6376 | cnts /= 2; |
| 6377 | if (cnts == 0) { |
| 6378 | err = -EINVAL; |
| 6379 | goto exit; |
| 6380 | } |
| 6381 | |
| 6382 | DBG_88E("%s: addr = 0x%X\n", __func__, addr); |
| 6383 | DBG_88E("%s: cnts =%d\n", __func__, cnts); |
| 6384 | DBG_88E("%s: map tmp data =%s\n", __func__, tmp[2]); |
| 6385 | |
| 6386 | for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) |
| 6387 | pEfuseHal->fakeEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); |
| 6388 | } |
| 6389 | |
| 6390 | exit: |
| 6391 | kfree(setdata); |
| 6392 | kfree(ShadowMapBT); |
| 6393 | kfree(ShadowMapWiFi); |
| 6394 | kfree(setrawdata); |
| 6395 | |
| 6396 | rtw_pm_set_ips(padapter, ips_mode); |
| 6397 | rtw_pm_set_lps(padapter, lps_mode); |
| 6398 | |
| 6399 | return err; |
| 6400 | } |
| 6401 | |
| 6402 | /* |
| 6403 | * Input Format: %s,%d,%d |
| 6404 | * %s is width, could be |
| 6405 | * "b" for 1 byte |
| 6406 | * "w" for WORD (2 bytes) |
| 6407 | * "dw" for DWORD (4 bytes) |
| 6408 | * 1st %d is address(offset) |
| 6409 | * 2st %d is data to write |
| 6410 | */ |
| 6411 | static int rtw_mp_write_reg(struct net_device *dev, |
| 6412 | struct iw_request_info *info, |
| 6413 | struct iw_point *wrqu, char *extra) |
| 6414 | { |
| 6415 | char *pch, *pnext, *ptmp; |
| 6416 | char *width_str; |
| 6417 | char width; |
| 6418 | u32 addr, data; |
| 6419 | int ret; |
| 6420 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 6421 | |
| 6422 | pch = extra; |
| 6423 | pnext = strpbrk(pch, ",.-"); |
| 6424 | if (pnext == NULL) |
| 6425 | return -EINVAL; |
| 6426 | *pnext = 0; |
| 6427 | width_str = pch; |
| 6428 | |
| 6429 | pch = pnext + 1; |
| 6430 | pnext = strpbrk(pch, ",.-"); |
| 6431 | if (pnext == NULL) |
| 6432 | return -EINVAL; |
| 6433 | *pnext = 0; |
| 6434 | addr = simple_strtoul(pch, &ptmp, 16); |
| 6435 | if (addr > 0x3FFF) |
| 6436 | return -EINVAL; |
| 6437 | |
| 6438 | pch = pnext + 1; |
| 6439 | if ((pch - extra) >= wrqu->length) |
| 6440 | return -EINVAL; |
| 6441 | data = simple_strtoul(pch, &ptmp, 16); |
| 6442 | |
| 6443 | ret = 0; |
| 6444 | width = width_str[0]; |
| 6445 | switch (width) { |
| 6446 | case 'b': |
| 6447 | /* 1 byte */ |
| 6448 | if (data > 0xFF) { |
| 6449 | ret = -EINVAL; |
| 6450 | break; |
| 6451 | } |
| 6452 | rtw_write8(padapter, addr, data); |
| 6453 | break; |
| 6454 | case 'w': |
| 6455 | /* 2 bytes */ |
| 6456 | if (data > 0xFFFF) { |
| 6457 | ret = -EINVAL; |
| 6458 | break; |
| 6459 | } |
| 6460 | rtw_write16(padapter, addr, data); |
| 6461 | break; |
| 6462 | case 'd': |
| 6463 | /* 4 bytes */ |
| 6464 | rtw_write32(padapter, addr, data); |
| 6465 | break; |
| 6466 | default: |
| 6467 | ret = -EINVAL; |
| 6468 | break; |
| 6469 | } |
| 6470 | |
| 6471 | return ret; |
| 6472 | } |
| 6473 | |
| 6474 | /* |
| 6475 | * Input Format: %s,%d |
| 6476 | * %s is width, could be |
| 6477 | * "b" for 1 byte |
| 6478 | * "w" for WORD (2 bytes) |
| 6479 | * "dw" for DWORD (4 bytes) |
| 6480 | * %d is address(offset) |
| 6481 | * |
| 6482 | * Return: |
| 6483 | * %d for data readed |
| 6484 | */ |
| 6485 | static int rtw_mp_read_reg(struct net_device *dev, |
| 6486 | struct iw_request_info *info, |
| 6487 | struct iw_point *wrqu, char *extra) |
| 6488 | { |
| 6489 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 6490 | char *input = kmalloc(wrqu->length, GFP_KERNEL); |
| 6491 | char *pch, *pnext, *ptmp; |
| 6492 | char *width_str; |
| 6493 | char width; |
| 6494 | char data[20], tmp[20]; |
| 6495 | u32 addr; |
| 6496 | u32 ret, i = 0, j = 0, strtout = 0; |
| 6497 | |
| 6498 | if (!input) |
| 6499 | return -ENOMEM; |
| 6500 | if (copy_from_user(input, wrqu->pointer, wrqu->length)) { |
| 6501 | kfree(input); |
| 6502 | return -EFAULT; |
| 6503 | } |
| 6504 | _rtw_memset(data, 0, 20); |
| 6505 | _rtw_memset(tmp, 0, 20); |
| 6506 | _rtw_memset(extra, 0, wrqu->length); |
| 6507 | |
| 6508 | pch = input; |
| 6509 | pnext = strpbrk(pch, ",.-"); |
| 6510 | if (pnext == NULL) { |
| 6511 | kfree(input); |
| 6512 | return -EINVAL; |
| 6513 | } |
| 6514 | *pnext = 0; |
| 6515 | width_str = pch; |
| 6516 | |
| 6517 | pch = pnext + 1; |
| 6518 | if ((pch - input) >= wrqu->length) { |
| 6519 | kfree(input); |
| 6520 | return -EINVAL; |
| 6521 | } |
| 6522 | kfree(input); |
| 6523 | addr = simple_strtoul(pch, &ptmp, 16); |
| 6524 | if (addr > 0x3FFF) |
| 6525 | return -EINVAL; |
| 6526 | |
| 6527 | ret = 0; |
| 6528 | width = width_str[0]; |
| 6529 | switch (width) { |
| 6530 | case 'b': |
| 6531 | /* 1 byte */ |
| 6532 | sprintf(extra, "%d\n", rtw_read8(padapter, addr)); |
| 6533 | wrqu->length = strlen(extra); |
| 6534 | break; |
| 6535 | case 'w': |
| 6536 | /* 2 bytes */ |
| 6537 | sprintf(data, "%04x\n", rtw_read16(padapter, addr)); |
| 6538 | for (i = 0; i <= strlen(data); i++) { |
| 6539 | if (i%2 == 0) { |
| 6540 | tmp[j] = ' '; |
| 6541 | j++; |
| 6542 | } |
| 6543 | if (data[i] != '\0') |
| 6544 | tmp[j] = data[i]; |
| 6545 | j++; |
| 6546 | } |
| 6547 | pch = tmp; |
| 6548 | DBG_88E("pch =%s", pch); |
| 6549 | |
| 6550 | while (*pch != '\0') { |
| 6551 | pnext = strpbrk(pch, " "); |
| 6552 | if (!pnext) |
| 6553 | break; |
| 6554 | |
| 6555 | pnext++; |
| 6556 | if (*pnext != '\0') { |
| 6557 | strtout = simple_strtoul(pnext, &ptmp, 16); |
| 6558 | sprintf(extra, "%s %d", extra, strtout); |
| 6559 | } else { |
| 6560 | break; |
| 6561 | } |
| 6562 | pch = pnext; |
| 6563 | } |
| 6564 | wrqu->length = 6; |
| 6565 | break; |
| 6566 | case 'd': |
| 6567 | /* 4 bytes */ |
| 6568 | sprintf(data, "%08x", rtw_read32(padapter, addr)); |
| 6569 | /* add read data format blank */ |
| 6570 | for (i = 0; i <= strlen(data); i++) { |
| 6571 | if (i%2 == 0) { |
| 6572 | tmp[j] = ' '; |
| 6573 | j++; |
| 6574 | } |
| 6575 | if (data[i] != '\0') |
| 6576 | tmp[j] = data[i]; |
| 6577 | |
| 6578 | j++; |
| 6579 | } |
| 6580 | pch = tmp; |
| 6581 | DBG_88E("pch =%s", pch); |
| 6582 | |
| 6583 | while (*pch != '\0') { |
| 6584 | pnext = strpbrk(pch, " "); |
| 6585 | if (!pnext) |
| 6586 | break; |
| 6587 | pnext++; |
| 6588 | if (*pnext != '\0') { |
| 6589 | strtout = simple_strtoul(pnext, &ptmp, 16); |
| 6590 | sprintf(extra, "%s %d", extra, strtout); |
| 6591 | } else { |
| 6592 | break; |
| 6593 | } |
| 6594 | pch = pnext; |
| 6595 | } |
| 6596 | wrqu->length = strlen(extra); |
| 6597 | break; |
| 6598 | default: |
| 6599 | wrqu->length = 0; |
| 6600 | ret = -EINVAL; |
| 6601 | break; |
| 6602 | } |
| 6603 | |
| 6604 | return ret; |
| 6605 | } |
| 6606 | |
| 6607 | /* |
| 6608 | * Input Format: %d,%x,%x |
| 6609 | * %d is RF path, should be smaller than MAX_RF_PATH_NUMS |
| 6610 | * 1st %x is address(offset) |
| 6611 | * 2st %x is data to write |
| 6612 | */ |
| 6613 | static int rtw_mp_write_rf(struct net_device *dev, |
| 6614 | struct iw_request_info *info, |
| 6615 | struct iw_point *wrqu, char *extra) |
| 6616 | { |
| 6617 | u32 path, addr, data; |
| 6618 | int ret; |
| 6619 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 6620 | |
| 6621 | ret = sscanf(extra, "%d,%x,%x", &path, &addr, &data); |
| 6622 | if (ret < 3) |
| 6623 | return -EINVAL; |
| 6624 | |
| 6625 | if (path >= MAX_RF_PATH_NUMS) |
| 6626 | return -EINVAL; |
| 6627 | if (addr > 0xFF) |
| 6628 | return -EINVAL; |
| 6629 | if (data > 0xFFFFF) |
| 6630 | return -EINVAL; |
| 6631 | |
| 6632 | _rtw_memset(extra, 0, wrqu->length); |
| 6633 | |
| 6634 | write_rfreg(padapter, path, addr, data); |
| 6635 | |
| 6636 | sprintf(extra, "write_rf completed\n"); |
| 6637 | wrqu->length = strlen(extra); |
| 6638 | |
| 6639 | return 0; |
| 6640 | } |
| 6641 | |
| 6642 | /* |
| 6643 | * Input Format: %d,%x |
| 6644 | * %d is RF path, should be smaller than MAX_RF_PATH_NUMS |
| 6645 | * %x is address(offset) |
| 6646 | * |
| 6647 | * Return: |
| 6648 | * %d for data readed |
| 6649 | */ |
| 6650 | static int rtw_mp_read_rf(struct net_device *dev, |
| 6651 | struct iw_request_info *info, |
| 6652 | struct iw_point *wrqu, char *extra) |
| 6653 | { |
| 6654 | char *input = kmalloc(wrqu->length, GFP_KERNEL); |
| 6655 | char *pch, *pnext, *ptmp; |
| 6656 | char data[20], tmp[20]; |
| 6657 | u32 path, addr; |
| 6658 | u32 ret, i = 0, j = 0, strtou = 0; |
| 6659 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 6660 | |
| 6661 | if (!input) |
| 6662 | return -ENOMEM; |
| 6663 | if (copy_from_user(input, wrqu->pointer, wrqu->length)) { |
| 6664 | kfree(input); |
| 6665 | return -EFAULT; |
| 6666 | } |
| 6667 | ret = sscanf(input, "%d,%x", &path, &addr); |
| 6668 | kfree(input); |
| 6669 | if (ret < 2) |
| 6670 | return -EINVAL; |
| 6671 | |
| 6672 | if (path >= MAX_RF_PATH_NUMS) |
| 6673 | return -EINVAL; |
| 6674 | if (addr > 0xFF) |
| 6675 | return -EINVAL; |
| 6676 | |
| 6677 | _rtw_memset(extra, 0, wrqu->length); |
| 6678 | |
| 6679 | sprintf(data, "%08x", read_rfreg(padapter, path, addr)); |
| 6680 | /* add read data format blank */ |
| 6681 | for (i = 0; i <= strlen(data); i++) { |
| 6682 | if (i%2 == 0) { |
| 6683 | tmp[j] = ' '; |
| 6684 | j++; |
| 6685 | } |
| 6686 | tmp[j] = data[i]; |
| 6687 | j++; |
| 6688 | } |
| 6689 | pch = tmp; |
| 6690 | DBG_88E("pch =%s", pch); |
| 6691 | |
| 6692 | while (*pch != '\0') { |
| 6693 | pnext = strpbrk(pch, " "); |
| 6694 | pnext++; |
| 6695 | if (*pnext != '\0') { |
| 6696 | strtou = simple_strtoul(pnext, &ptmp, 16); |
| 6697 | sprintf(extra, "%s %d", extra, strtou); |
| 6698 | } else { |
| 6699 | break; |
| 6700 | } |
| 6701 | pch = pnext; |
| 6702 | } |
| 6703 | wrqu->length = strlen(extra); |
| 6704 | return 0; |
| 6705 | } |
| 6706 | |
| 6707 | static int rtw_mp_start(struct net_device *dev, |
| 6708 | struct iw_request_info *info, |
| 6709 | struct iw_point *wrqu, char *extra) |
| 6710 | { |
| 6711 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 6712 | |
| 6713 | if (padapter->registrypriv.mp_mode == 0) { |
| 6714 | padapter->registrypriv.mp_mode = 1; |
| 6715 | |
| 6716 | rtw_pm_set_ips(padapter, IPS_NONE); |
| 6717 | LeaveAllPowerSaveMode(padapter); |
| 6718 | |
| 6719 | MPT_InitializeAdapter(padapter, 1); |
| 6720 | } |
| 6721 | if (padapter->registrypriv.mp_mode == 0) |
| 6722 | return -EPERM; |
| 6723 | if (padapter->mppriv.mode == MP_OFF) { |
| 6724 | if (mp_start_test(padapter) == _FAIL) |
| 6725 | return -EPERM; |
| 6726 | padapter->mppriv.mode = MP_ON; |
| 6727 | } |
| 6728 | return 0; |
| 6729 | } |
| 6730 | |
| 6731 | static int rtw_mp_stop(struct net_device *dev, |
| 6732 | struct iw_request_info *info, |
| 6733 | struct iw_point *wrqu, char *extra) |
| 6734 | { |
| 6735 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 6736 | |
| 6737 | if (padapter->registrypriv.mp_mode == 1) { |
| 6738 | MPT_DeInitAdapter(padapter); |
| 6739 | padapter->registrypriv.mp_mode = 0; |
| 6740 | } |
| 6741 | |
| 6742 | if (padapter->mppriv.mode != MP_OFF) { |
| 6743 | mp_stop_test(padapter); |
| 6744 | padapter->mppriv.mode = MP_OFF; |
| 6745 | } |
| 6746 | |
| 6747 | return 0; |
| 6748 | } |
| 6749 | |
| 6750 | extern int wifirate2_ratetbl_inx(unsigned char rate); |
| 6751 | |
| 6752 | static int rtw_mp_rate(struct net_device *dev, |
| 6753 | struct iw_request_info *info, |
| 6754 | struct iw_point *wrqu, char *extra) |
| 6755 | { |
| 6756 | u32 rate = MPT_RATE_1M; |
| 6757 | char *input = kmalloc(wrqu->length, GFP_KERNEL); |
| 6758 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 6759 | |
| 6760 | if (!input) |
| 6761 | return -ENOMEM; |
| 6762 | if (copy_from_user(input, wrqu->pointer, wrqu->length)) { |
| 6763 | kfree(input); |
| 6764 | return -EFAULT; |
| 6765 | } |
| 6766 | rate = rtw_atoi(input); |
| 6767 | sprintf(extra, "Set data rate to %d", rate); |
| 6768 | kfree(input); |
| 6769 | if (rate <= 0x7f) |
| 6770 | rate = wifirate2_ratetbl_inx((u8)rate); |
| 6771 | else |
| 6772 | rate = (rate-0x80+MPT_RATE_MCS0); |
| 6773 | |
| 6774 | if (rate >= MPT_RATE_LAST) |
| 6775 | return -EINVAL; |
| 6776 | |
| 6777 | padapter->mppriv.rateidx = rate; |
| 6778 | Hal_SetDataRate(padapter); |
| 6779 | |
| 6780 | wrqu->length = strlen(extra) + 1; |
| 6781 | return 0; |
| 6782 | } |
| 6783 | |
| 6784 | static int rtw_mp_channel(struct net_device *dev, |
| 6785 | struct iw_request_info *info, |
| 6786 | struct iw_point *wrqu, char *extra) |
| 6787 | { |
| 6788 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 6789 | char *input = kmalloc(wrqu->length, GFP_KERNEL); |
| 6790 | u32 channel = 1; |
| 6791 | |
| 6792 | if (!input) |
| 6793 | return -ENOMEM; |
| 6794 | if (copy_from_user(input, wrqu->pointer, wrqu->length)) { |
| 6795 | kfree(input); |
| 6796 | return -EFAULT; |
| 6797 | } |
| 6798 | channel = rtw_atoi(input); |
| 6799 | sprintf(extra, "Change channel %d to channel %d", padapter->mppriv.channel, channel); |
| 6800 | |
| 6801 | padapter->mppriv.channel = channel; |
| 6802 | Hal_SetChannel(padapter); |
| 6803 | |
| 6804 | wrqu->length = strlen(extra) + 1; |
| 6805 | kfree(input); |
| 6806 | return 0; |
| 6807 | } |
| 6808 | |
| 6809 | static int rtw_mp_bandwidth(struct net_device *dev, |
| 6810 | struct iw_request_info *info, |
| 6811 | struct iw_point *wrqu, char *extra) |
| 6812 | { |
| 6813 | u32 bandwidth = 0, sg = 0; |
| 6814 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 6815 | |
| 6816 | sscanf(extra, "40M =%d, shortGI =%d", &bandwidth, &sg); |
| 6817 | |
| 6818 | if (bandwidth != HT_CHANNEL_WIDTH_40) |
| 6819 | bandwidth = HT_CHANNEL_WIDTH_20; |
| 6820 | |
| 6821 | padapter->mppriv.bandwidth = (u8)bandwidth; |
| 6822 | padapter->mppriv.preamble = sg; |
| 6823 | |
| 6824 | SetBandwidth(padapter); |
| 6825 | |
| 6826 | return 0; |
| 6827 | } |
| 6828 | |
| 6829 | static int rtw_mp_txpower(struct net_device *dev, |
| 6830 | struct iw_request_info *info, |
| 6831 | struct iw_point *wrqu, char *extra) |
| 6832 | { |
| 6833 | u32 idx_a = 0, idx_b = 0; |
| 6834 | char *input = kmalloc(wrqu->length, GFP_KERNEL); |
| 6835 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 6836 | |
| 6837 | if (!input) |
| 6838 | return -ENOMEM; |
| 6839 | if (copy_from_user(input, wrqu->pointer, wrqu->length)) { |
| 6840 | kfree(input); |
| 6841 | return -EFAULT; |
| 6842 | } |
| 6843 | sscanf(input, "patha =%d, pathb =%d", &idx_a, &idx_b); |
| 6844 | |
| 6845 | sprintf(extra, "Set power level path_A:%d path_B:%d", idx_a, idx_b); |
| 6846 | padapter->mppriv.txpoweridx = (u8)idx_a; |
| 6847 | padapter->mppriv.txpoweridx_b = (u8)idx_b; |
| 6848 | padapter->mppriv.bSetTxPower = 1; |
| 6849 | Hal_SetAntennaPathPower(padapter); |
| 6850 | |
| 6851 | wrqu->length = strlen(extra) + 1; |
| 6852 | kfree(input); |
| 6853 | return 0; |
| 6854 | } |
| 6855 | |
| 6856 | static int rtw_mp_ant_tx(struct net_device *dev, |
| 6857 | struct iw_request_info *info, |
| 6858 | struct iw_point *wrqu, char *extra) |
| 6859 | { |
| 6860 | u8 i; |
| 6861 | char *input = kmalloc(wrqu->length, GFP_KERNEL); |
| 6862 | u16 antenna = 0; |
| 6863 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 6864 | |
| 6865 | if (!input) |
| 6866 | return -ENOMEM; |
| 6867 | if (copy_from_user(input, wrqu->pointer, wrqu->length)) { |
| 6868 | kfree(input); |
| 6869 | return -EFAULT; |
| 6870 | } |
| 6871 | |
| 6872 | sprintf(extra, "switch Tx antenna to %s", input); |
| 6873 | |
| 6874 | for (i = 0; i < strlen(input); i++) { |
| 6875 | switch (input[i]) { |
| 6876 | case 'a': |
| 6877 | antenna |= ANTENNA_A; |
| 6878 | break; |
| 6879 | case 'b': |
| 6880 | antenna |= ANTENNA_B; |
| 6881 | break; |
| 6882 | } |
| 6883 | } |
| 6884 | padapter->mppriv.antenna_tx = antenna; |
| 6885 | |
| 6886 | Hal_SetAntenna(padapter); |
| 6887 | |
| 6888 | wrqu->length = strlen(extra) + 1; |
| 6889 | kfree(input); |
| 6890 | return 0; |
| 6891 | } |
| 6892 | |
| 6893 | static int rtw_mp_ant_rx(struct net_device *dev, |
| 6894 | struct iw_request_info *info, |
| 6895 | struct iw_point *wrqu, char *extra) |
| 6896 | { |
| 6897 | u8 i; |
| 6898 | u16 antenna = 0; |
| 6899 | char *input = kmalloc(wrqu->length, GFP_KERNEL); |
| 6900 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 6901 | |
| 6902 | if (!input) |
| 6903 | return -ENOMEM; |
| 6904 | if (copy_from_user(input, wrqu->pointer, wrqu->length)) { |
| 6905 | kfree(input); |
| 6906 | return -EFAULT; |
| 6907 | } |
| 6908 | _rtw_memset(extra, 0, wrqu->length); |
| 6909 | |
| 6910 | sprintf(extra, "switch Rx antenna to %s", input); |
| 6911 | |
| 6912 | for (i = 0; i < strlen(input); i++) { |
| 6913 | switch (input[i]) { |
| 6914 | case 'a': |
| 6915 | antenna |= ANTENNA_A; |
| 6916 | break; |
| 6917 | case 'b': |
| 6918 | antenna |= ANTENNA_B; |
| 6919 | break; |
| 6920 | } |
| 6921 | } |
| 6922 | |
| 6923 | padapter->mppriv.antenna_rx = antenna; |
| 6924 | Hal_SetAntenna(padapter); |
| 6925 | wrqu->length = strlen(extra); |
| 6926 | kfree(input); |
| 6927 | return 0; |
| 6928 | } |
| 6929 | |
| 6930 | static int rtw_mp_ctx(struct net_device *dev, |
| 6931 | struct iw_request_info *info, |
| 6932 | struct iw_point *wrqu, char *extra) |
| 6933 | { |
| 6934 | u32 pkTx = 1, countPkTx = 1, cotuTx = 1, CarrSprTx = 1, scTx = 1, sgleTx = 1, stop = 1; |
| 6935 | u32 bStartTest = 1; |
| 6936 | u32 count = 0; |
| 6937 | struct mp_priv *pmp_priv; |
| 6938 | struct pkt_attrib *pattrib; |
| 6939 | |
| 6940 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 6941 | |
| 6942 | pmp_priv = &padapter->mppriv; |
| 6943 | |
| 6944 | if (copy_from_user(extra, wrqu->pointer, wrqu->length)) |
| 6945 | return -EFAULT; |
| 6946 | |
| 6947 | DBG_88E("%s: in =%s\n", __func__, extra); |
| 6948 | |
| 6949 | countPkTx = strncmp(extra, "count =", 5); /* strncmp true is 0 */ |
| 6950 | cotuTx = strncmp(extra, "background", 20); |
| 6951 | CarrSprTx = strncmp(extra, "background, cs", 20); |
| 6952 | scTx = strncmp(extra, "background, sc", 20); |
| 6953 | sgleTx = strncmp(extra, "background, stone", 20); |
| 6954 | pkTx = strncmp(extra, "background, pkt", 20); |
| 6955 | stop = strncmp(extra, "stop", 4); |
| 6956 | sscanf(extra, "count =%d, pkt", &count); |
| 6957 | |
Thomas Meyer | 5a2d829 | 2013-09-19 23:45:46 +0200 | [diff] [blame] | 6958 | _rtw_memset(extra, '\0', sizeof(*extra)); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 6959 | |
| 6960 | if (stop == 0) { |
| 6961 | bStartTest = 0; /* To set Stop */ |
| 6962 | pmp_priv->tx.stop = 1; |
| 6963 | sprintf(extra, "Stop continuous Tx"); |
| 6964 | } else { |
| 6965 | bStartTest = 1; |
| 6966 | if (pmp_priv->mode != MP_ON) { |
| 6967 | if (pmp_priv->tx.stop != 1) { |
| 6968 | DBG_88E("%s: MP_MODE != ON %d\n", __func__, pmp_priv->mode); |
| 6969 | return -EFAULT; |
| 6970 | } |
| 6971 | } |
| 6972 | } |
| 6973 | |
| 6974 | if (pkTx == 0 || countPkTx == 0) |
| 6975 | pmp_priv->mode = MP_PACKET_TX; |
| 6976 | if (sgleTx == 0) |
| 6977 | pmp_priv->mode = MP_SINGLE_TONE_TX; |
| 6978 | if (cotuTx == 0) |
| 6979 | pmp_priv->mode = MP_CONTINUOUS_TX; |
| 6980 | if (CarrSprTx == 0) |
| 6981 | pmp_priv->mode = MP_CARRIER_SUPPRISSION_TX; |
| 6982 | if (scTx == 0) |
| 6983 | pmp_priv->mode = MP_SINGLE_CARRIER_TX; |
| 6984 | |
| 6985 | switch (pmp_priv->mode) { |
| 6986 | case MP_PACKET_TX: |
| 6987 | if (bStartTest == 0) { |
| 6988 | pmp_priv->tx.stop = 1; |
| 6989 | pmp_priv->mode = MP_ON; |
| 6990 | sprintf(extra, "Stop continuous Tx"); |
| 6991 | } else if (pmp_priv->tx.stop == 1) { |
| 6992 | sprintf(extra, "Start continuous DA = ffffffffffff len = 1500 count =%u,\n", count); |
| 6993 | pmp_priv->tx.stop = 0; |
| 6994 | pmp_priv->tx.count = count; |
| 6995 | pmp_priv->tx.payload = 2; |
| 6996 | pattrib = &pmp_priv->tx.attrib; |
| 6997 | pattrib->pktlen = 1500; |
| 6998 | _rtw_memset(pattrib->dst, 0xFF, ETH_ALEN); |
| 6999 | SetPacketTx(padapter); |
| 7000 | } else { |
| 7001 | return -EFAULT; |
| 7002 | } |
| 7003 | wrqu->length = strlen(extra); |
| 7004 | return 0; |
| 7005 | case MP_SINGLE_TONE_TX: |
| 7006 | if (bStartTest != 0) |
| 7007 | sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); |
| 7008 | Hal_SetSingleToneTx(padapter, (u8)bStartTest); |
| 7009 | break; |
| 7010 | case MP_CONTINUOUS_TX: |
| 7011 | if (bStartTest != 0) |
| 7012 | sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); |
| 7013 | Hal_SetContinuousTx(padapter, (u8)bStartTest); |
| 7014 | break; |
| 7015 | case MP_CARRIER_SUPPRISSION_TX: |
| 7016 | if (bStartTest != 0) { |
| 7017 | if (pmp_priv->rateidx <= MPT_RATE_11M) { |
| 7018 | sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); |
| 7019 | Hal_SetCarrierSuppressionTx(padapter, (u8)bStartTest); |
| 7020 | } else { |
| 7021 | sprintf(extra, "Specify carrier suppression but not CCK rate"); |
| 7022 | } |
| 7023 | } |
| 7024 | break; |
| 7025 | case MP_SINGLE_CARRIER_TX: |
| 7026 | if (bStartTest != 0) |
| 7027 | sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); |
| 7028 | Hal_SetSingleCarrierTx(padapter, (u8)bStartTest); |
| 7029 | break; |
| 7030 | default: |
| 7031 | sprintf(extra, "Error! Continuous-Tx is not on-going."); |
| 7032 | return -EFAULT; |
| 7033 | } |
| 7034 | |
| 7035 | if (bStartTest == 1 && pmp_priv->mode != MP_ON) { |
| 7036 | struct mp_priv *pmp_priv = &padapter->mppriv; |
| 7037 | if (pmp_priv->tx.stop == 0) { |
| 7038 | pmp_priv->tx.stop = 1; |
Larry Finger | 0da46e6 | 2013-12-19 22:38:41 -0600 | [diff] [blame] | 7039 | msleep(5); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 7040 | } |
| 7041 | pmp_priv->tx.stop = 0; |
| 7042 | pmp_priv->tx.count = 1; |
| 7043 | SetPacketTx(padapter); |
| 7044 | } else { |
| 7045 | pmp_priv->mode = MP_ON; |
| 7046 | } |
| 7047 | |
| 7048 | wrqu->length = strlen(extra); |
| 7049 | return 0; |
| 7050 | } |
| 7051 | |
| 7052 | static int rtw_mp_arx(struct net_device *dev, |
| 7053 | struct iw_request_info *info, |
| 7054 | struct iw_point *wrqu, char *extra) |
| 7055 | { |
| 7056 | u8 bStartRx = 0, bStopRx = 0, bQueryPhy; |
| 7057 | u32 cckok = 0, cckcrc = 0, ofdmok = 0, ofdmcrc = 0, htok = 0, htcrc = 0, OFDM_FA = 0, CCK_FA = 0; |
| 7058 | char *input = kmalloc(wrqu->length, GFP_KERNEL); |
| 7059 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 7060 | |
| 7061 | if (!input) |
| 7062 | return -ENOMEM; |
| 7063 | |
| 7064 | if (copy_from_user(input, wrqu->pointer, wrqu->length)) { |
| 7065 | kfree(input); |
| 7066 | return -EFAULT; |
| 7067 | } |
| 7068 | DBG_88E("%s: %s\n", __func__, input); |
| 7069 | |
| 7070 | bStartRx = (strncmp(input, "start", 5) == 0) ? 1 : 0; /* strncmp true is 0 */ |
| 7071 | bStopRx = (strncmp(input, "stop", 5) == 0) ? 1 : 0; /* strncmp true is 0 */ |
| 7072 | bQueryPhy = (strncmp(input, "phy", 3) == 0) ? 1 : 0; /* strncmp true is 0 */ |
| 7073 | |
| 7074 | if (bStartRx) { |
| 7075 | sprintf(extra, "start"); |
| 7076 | SetPacketRx(padapter, bStartRx); |
| 7077 | } else if (bStopRx) { |
| 7078 | SetPacketRx(padapter, 0); |
| 7079 | sprintf(extra, "Received packet OK:%d CRC error:%d", padapter->mppriv.rx_pktcount, padapter->mppriv.rx_crcerrpktcount); |
| 7080 | } else if (bQueryPhy) { |
| 7081 | /* |
| 7082 | OFDM FA |
| 7083 | RegCF0[15:0] |
| 7084 | RegCF2[31:16] |
| 7085 | RegDA0[31:16] |
| 7086 | RegDA4[15:0] |
| 7087 | RegDA4[31:16] |
| 7088 | RegDA8[15:0] |
| 7089 | CCK FA |
| 7090 | (RegA5B<<8) | RegA5C |
| 7091 | */ |
| 7092 | cckok = read_bbreg(padapter, 0xf88, 0xffffffff); |
| 7093 | cckcrc = read_bbreg(padapter, 0xf84, 0xffffffff); |
| 7094 | ofdmok = read_bbreg(padapter, 0xf94, 0x0000FFFF); |
| 7095 | ofdmcrc = read_bbreg(padapter, 0xf94, 0xFFFF0000); |
| 7096 | htok = read_bbreg(padapter, 0xf90, 0x0000FFFF); |
| 7097 | htcrc = read_bbreg(padapter, 0xf90, 0xFFFF0000); |
| 7098 | |
| 7099 | OFDM_FA = read_bbreg(padapter, 0xcf0, 0x0000FFFF); |
| 7100 | OFDM_FA = read_bbreg(padapter, 0xcf2, 0xFFFF0000); |
| 7101 | OFDM_FA = read_bbreg(padapter, 0xda0, 0xFFFF0000); |
| 7102 | OFDM_FA = read_bbreg(padapter, 0xda4, 0x0000FFFF); |
| 7103 | OFDM_FA = read_bbreg(padapter, 0xda4, 0xFFFF0000); |
| 7104 | OFDM_FA = read_bbreg(padapter, 0xda8, 0x0000FFFF); |
| 7105 | CCK_FA = (rtw_read8(padapter, 0xa5b)<<8) | (rtw_read8(padapter, 0xa5c)); |
| 7106 | |
| 7107 | sprintf(extra, "Phy Received packet OK:%d CRC error:%d FA Counter: %d", cckok+ofdmok+htok, cckcrc+ofdmcrc+htcrc, OFDM_FA+CCK_FA); |
| 7108 | } |
| 7109 | wrqu->length = strlen(extra) + 1; |
| 7110 | kfree(input); |
| 7111 | return 0; |
| 7112 | } |
| 7113 | |
| 7114 | static int rtw_mp_trx_query(struct net_device *dev, |
| 7115 | struct iw_request_info *info, |
| 7116 | struct iw_point *wrqu, char *extra) |
| 7117 | { |
| 7118 | u32 txok, txfail, rxok, rxfail; |
| 7119 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 7120 | |
| 7121 | txok = padapter->mppriv.tx.sended; |
| 7122 | txfail = 0; |
| 7123 | rxok = padapter->mppriv.rx_pktcount; |
| 7124 | rxfail = padapter->mppriv.rx_crcerrpktcount; |
| 7125 | |
| 7126 | _rtw_memset(extra, '\0', 128); |
| 7127 | |
| 7128 | sprintf(extra, "Tx OK:%d, Tx Fail:%d, Rx OK:%d, CRC error:%d ", txok, txfail, rxok, rxfail); |
| 7129 | |
| 7130 | wrqu->length = strlen(extra)+1; |
| 7131 | |
| 7132 | return 0; |
| 7133 | } |
| 7134 | |
| 7135 | static int rtw_mp_pwrtrk(struct net_device *dev, |
| 7136 | struct iw_request_info *info, |
| 7137 | struct iw_point *wrqu, char *extra) |
| 7138 | { |
| 7139 | u8 enable; |
| 7140 | u32 thermal; |
| 7141 | s32 ret; |
| 7142 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 7143 | char *input = kmalloc(wrqu->length, GFP_KERNEL); |
| 7144 | |
| 7145 | if (!input) |
| 7146 | return -ENOMEM; |
| 7147 | if (copy_from_user(input, wrqu->pointer, wrqu->length)) { |
| 7148 | kfree(input); |
| 7149 | return -EFAULT; |
| 7150 | } |
| 7151 | _rtw_memset(extra, 0, wrqu->length); |
| 7152 | |
| 7153 | enable = 1; |
| 7154 | if (wrqu->length > 1) {/* not empty string */ |
| 7155 | if (strncmp(input, "stop", 4) == 0) { |
| 7156 | enable = 0; |
| 7157 | sprintf(extra, "mp tx power tracking stop"); |
| 7158 | } else if (sscanf(input, "ther =%d", &thermal)) { |
| 7159 | ret = Hal_SetThermalMeter(padapter, (u8)thermal); |
| 7160 | if (ret == _FAIL) |
| 7161 | return -EPERM; |
| 7162 | sprintf(extra, "mp tx power tracking start, target value =%d ok ", thermal); |
| 7163 | } else { |
| 7164 | kfree(input); |
| 7165 | return -EINVAL; |
| 7166 | } |
| 7167 | } |
| 7168 | |
| 7169 | kfree(input); |
| 7170 | ret = Hal_SetPowerTracking(padapter, enable); |
| 7171 | if (ret == _FAIL) |
| 7172 | return -EPERM; |
| 7173 | |
| 7174 | wrqu->length = strlen(extra); |
| 7175 | return 0; |
| 7176 | } |
| 7177 | |
| 7178 | static int rtw_mp_psd(struct net_device *dev, |
| 7179 | struct iw_request_info *info, |
| 7180 | struct iw_point *wrqu, char *extra) |
| 7181 | { |
| 7182 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 7183 | char *input = kmalloc(wrqu->length, GFP_KERNEL); |
| 7184 | |
| 7185 | if (!input) |
| 7186 | return -ENOMEM; |
| 7187 | if (copy_from_user(input, wrqu->pointer, wrqu->length)) { |
| 7188 | kfree(input); |
| 7189 | return -EFAULT; |
| 7190 | } |
| 7191 | |
| 7192 | strcpy(extra, input); |
| 7193 | |
| 7194 | wrqu->length = mp_query_psd(padapter, extra); |
| 7195 | kfree(input); |
| 7196 | return 0; |
| 7197 | } |
| 7198 | |
| 7199 | static int rtw_mp_thermal(struct net_device *dev, |
| 7200 | struct iw_request_info *info, |
| 7201 | struct iw_point *wrqu, char *extra) |
| 7202 | { |
| 7203 | u8 val; |
| 7204 | u16 bwrite = 1; |
| 7205 | u16 addr = EEPROM_THERMAL_METER_88E; |
| 7206 | |
| 7207 | u16 cnt = 1; |
| 7208 | u16 max_available_size = 0; |
| 7209 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 7210 | |
| 7211 | if (copy_from_user(extra, wrqu->pointer, wrqu->length)) |
| 7212 | return -EFAULT; |
| 7213 | |
Teodora Baluta | 1f9d82d | 2013-11-08 00:13:46 +0200 | [diff] [blame] | 7214 | bwrite = strncmp(extra, "write", 6); /* strncmp true is 0 */ |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 7215 | |
Teodora Baluta | 1f9d82d | 2013-11-08 00:13:46 +0200 | [diff] [blame] | 7216 | Hal_GetThermalMeter(padapter, &val); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 7217 | |
Teodora Baluta | 1f9d82d | 2013-11-08 00:13:46 +0200 | [diff] [blame] | 7218 | if (bwrite == 0) { |
| 7219 | EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); |
| 7220 | if (2 > max_available_size) { |
| 7221 | DBG_88E("no available efuse!\n"); |
| 7222 | return -EFAULT; |
| 7223 | } |
| 7224 | if (rtw_efuse_map_write(padapter, addr, cnt, &val) == _FAIL) { |
| 7225 | DBG_88E("rtw_efuse_map_write error\n"); |
| 7226 | return -EFAULT; |
| 7227 | } else { |
| 7228 | sprintf(extra, " efuse write ok :%d", val); |
| 7229 | } |
| 7230 | } else { |
| 7231 | sprintf(extra, "%d", val); |
| 7232 | } |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 7233 | wrqu->length = strlen(extra); |
| 7234 | |
| 7235 | return 0; |
| 7236 | } |
| 7237 | |
| 7238 | static int rtw_mp_reset_stats(struct net_device *dev, |
| 7239 | struct iw_request_info *info, |
| 7240 | struct iw_point *wrqu, char *extra) |
| 7241 | { |
| 7242 | struct mp_priv *pmp_priv; |
| 7243 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 7244 | |
| 7245 | pmp_priv = &padapter->mppriv; |
| 7246 | |
| 7247 | pmp_priv->tx.sended = 0; |
| 7248 | pmp_priv->tx_pktcount = 0; |
| 7249 | pmp_priv->rx_pktcount = 0; |
| 7250 | pmp_priv->rx_crcerrpktcount = 0; |
| 7251 | |
| 7252 | /* reset phy counter */ |
| 7253 | write_bbreg(padapter, 0xf14, BIT16, 0x1); |
Larry Finger | 0da46e6 | 2013-12-19 22:38:41 -0600 | [diff] [blame] | 7254 | msleep(10); |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 7255 | write_bbreg(padapter, 0xf14, BIT16, 0x0); |
| 7256 | |
| 7257 | return 0; |
| 7258 | } |
| 7259 | |
| 7260 | static int rtw_mp_dump(struct net_device *dev, |
| 7261 | struct iw_request_info *info, |
| 7262 | struct iw_point *wrqu, char *extra) |
| 7263 | { |
| 7264 | u32 value; |
| 7265 | u8 rf_type, path_nums = 0; |
| 7266 | u32 i, j = 1, path; |
| 7267 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 7268 | |
| 7269 | if (strncmp(extra, "all", 4) == 0) { |
| 7270 | DBG_88E("\n ======= MAC REG =======\n"); |
| 7271 | for (i = 0x0; i < 0x300; i += 4) { |
| 7272 | if (j%4 == 1) |
| 7273 | DBG_88E("0x%02x", i); |
| 7274 | DBG_88E(" 0x%08x ", rtw_read32(padapter, i)); |
| 7275 | if ((j++)%4 == 0) |
| 7276 | DBG_88E("\n"); |
| 7277 | } |
| 7278 | for (i = 0x400; i < 0x1000; i += 4) { |
| 7279 | if (j%4 == 1) |
| 7280 | DBG_88E("0x%02x", i); |
| 7281 | DBG_88E(" 0x%08x ", rtw_read32(padapter, i)); |
| 7282 | if ((j++)%4 == 0) |
| 7283 | DBG_88E("\n"); |
| 7284 | } |
| 7285 | |
| 7286 | j = 1; |
| 7287 | rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); |
| 7288 | |
| 7289 | DBG_88E("\n ======= RF REG =======\n"); |
| 7290 | if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) |
| 7291 | path_nums = 1; |
| 7292 | else |
| 7293 | path_nums = 2; |
| 7294 | |
| 7295 | for (path = 0; path < path_nums; path++) { |
| 7296 | for (i = 0; i < 0x34; i++) { |
| 7297 | value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); |
| 7298 | if (j%4 == 1) |
| 7299 | DBG_88E("0x%02x ", i); |
| 7300 | DBG_88E(" 0x%08x ", value); |
| 7301 | if ((j++)%4 == 0) |
| 7302 | DBG_88E("\n"); |
| 7303 | } |
| 7304 | } |
| 7305 | } |
| 7306 | return 0; |
| 7307 | } |
| 7308 | |
| 7309 | static int rtw_mp_phypara(struct net_device *dev, |
| 7310 | struct iw_request_info *info, |
| 7311 | struct iw_point *wrqu, char *extra) |
| 7312 | { |
| 7313 | char *input = kmalloc(wrqu->length, GFP_KERNEL); |
| 7314 | u32 valxcap; |
| 7315 | |
| 7316 | if (!input) |
| 7317 | return -ENOMEM; |
| 7318 | if (copy_from_user(input, wrqu->pointer, wrqu->length)) { |
| 7319 | kfree(input); |
| 7320 | return -EFAULT; |
| 7321 | } |
| 7322 | |
| 7323 | DBG_88E("%s:iwpriv in =%s\n", __func__, input); |
| 7324 | |
| 7325 | sscanf(input, "xcap =%d", &valxcap); |
| 7326 | |
| 7327 | kfree(input); |
| 7328 | return 0; |
| 7329 | } |
| 7330 | |
| 7331 | static int rtw_mp_SetRFPath(struct net_device *dev, |
| 7332 | struct iw_request_info *info, |
| 7333 | union iwreq_data *wrqu, char *extra) |
| 7334 | { |
| 7335 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 7336 | char *input = kmalloc(wrqu->data.length, GFP_KERNEL); |
| 7337 | u8 bMain = 1, bTurnoff = 1; |
| 7338 | |
| 7339 | if (!input) |
| 7340 | return -ENOMEM; |
| 7341 | if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) |
| 7342 | return -EFAULT; |
| 7343 | DBG_88E("%s:iwpriv in =%s\n", __func__, input); |
| 7344 | |
| 7345 | bMain = strncmp(input, "1", 2); /* strncmp true is 0 */ |
| 7346 | bTurnoff = strncmp(input, "0", 3); /* strncmp true is 0 */ |
| 7347 | |
| 7348 | if (bMain == 0) { |
| 7349 | MP_PHY_SetRFPathSwitch(padapter, true); |
| 7350 | DBG_88E("%s:PHY_SetRFPathSwitch = true\n", __func__); |
| 7351 | } else if (bTurnoff == 0) { |
| 7352 | MP_PHY_SetRFPathSwitch(padapter, false); |
| 7353 | DBG_88E("%s:PHY_SetRFPathSwitch = false\n", __func__); |
| 7354 | } |
| 7355 | kfree(input); |
| 7356 | return 0; |
| 7357 | } |
| 7358 | |
| 7359 | static int rtw_mp_QueryDrv(struct net_device *dev, |
| 7360 | struct iw_request_info *info, |
| 7361 | union iwreq_data *wrqu, char *extra) |
| 7362 | { |
| 7363 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 7364 | char *input = kmalloc(wrqu->data.length, GFP_KERNEL); |
| 7365 | u8 qAutoLoad = 1; |
| 7366 | struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); |
| 7367 | |
| 7368 | if (!input) |
| 7369 | return -ENOMEM; |
| 7370 | |
| 7371 | if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) |
| 7372 | return -EFAULT; |
| 7373 | DBG_88E("%s:iwpriv in =%s\n", __func__, input); |
| 7374 | |
| 7375 | qAutoLoad = strncmp(input, "autoload", 8); /* strncmp true is 0 */ |
| 7376 | |
| 7377 | if (qAutoLoad == 0) { |
| 7378 | DBG_88E("%s:qAutoLoad\n", __func__); |
| 7379 | |
| 7380 | if (pEEPROM->bautoload_fail_flag) |
| 7381 | sprintf(extra, "fail"); |
| 7382 | else |
| 7383 | sprintf(extra, "ok"); |
| 7384 | } |
| 7385 | wrqu->data.length = strlen(extra) + 1; |
| 7386 | kfree(input); |
| 7387 | return 0; |
| 7388 | } |
| 7389 | |
| 7390 | static int rtw_mp_set(struct net_device *dev, |
| 7391 | struct iw_request_info *info, |
| 7392 | union iwreq_data *wdata, char *extra) |
| 7393 | { |
| 7394 | struct iw_point *wrqu = (struct iw_point *)wdata; |
| 7395 | u32 subcmd = wrqu->flags; |
| 7396 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 7397 | |
| 7398 | if (padapter == NULL) |
| 7399 | return -ENETDOWN; |
| 7400 | |
| 7401 | if (extra == NULL) { |
| 7402 | wrqu->length = 0; |
| 7403 | return -EIO; |
| 7404 | } |
| 7405 | |
| 7406 | switch (subcmd) { |
| 7407 | case MP_START: |
| 7408 | DBG_88E("set case mp_start\n"); |
| 7409 | rtw_mp_start(dev, info, wrqu, extra); |
| 7410 | break; |
| 7411 | case MP_STOP: |
| 7412 | DBG_88E("set case mp_stop\n"); |
| 7413 | rtw_mp_stop(dev, info, wrqu, extra); |
| 7414 | break; |
| 7415 | case MP_BANDWIDTH: |
| 7416 | DBG_88E("set case mp_bandwidth\n"); |
| 7417 | rtw_mp_bandwidth(dev, info, wrqu, extra); |
| 7418 | break; |
| 7419 | case MP_RESET_STATS: |
| 7420 | DBG_88E("set case MP_RESET_STATS\n"); |
| 7421 | rtw_mp_reset_stats(dev, info, wrqu, extra); |
| 7422 | break; |
| 7423 | case MP_SetRFPathSwh: |
| 7424 | DBG_88E("set MP_SetRFPathSwitch\n"); |
| 7425 | rtw_mp_SetRFPath(dev, info, wdata, extra); |
| 7426 | break; |
| 7427 | case CTA_TEST: |
| 7428 | DBG_88E("set CTA_TEST\n"); |
| 7429 | rtw_cta_test_start(dev, info, wdata, extra); |
| 7430 | break; |
| 7431 | } |
| 7432 | |
| 7433 | return 0; |
| 7434 | } |
| 7435 | |
| 7436 | static int rtw_mp_get(struct net_device *dev, |
| 7437 | struct iw_request_info *info, |
| 7438 | union iwreq_data *wdata, char *extra) |
| 7439 | { |
| 7440 | struct iw_point *wrqu = (struct iw_point *)wdata; |
| 7441 | u32 subcmd = wrqu->flags; |
| 7442 | struct adapter *padapter = rtw_netdev_priv(dev); |
| 7443 | |
| 7444 | if (padapter == NULL) |
| 7445 | return -ENETDOWN; |
| 7446 | if (extra == NULL) { |
| 7447 | wrqu->length = 0; |
| 7448 | return -EIO; |
| 7449 | } |
| 7450 | |
| 7451 | switch (subcmd) { |
| 7452 | case WRITE_REG: |
| 7453 | rtw_mp_write_reg(dev, info, wrqu, extra); |
| 7454 | break; |
| 7455 | case WRITE_RF: |
| 7456 | rtw_mp_write_rf(dev, info, wrqu, extra); |
| 7457 | break; |
| 7458 | case MP_PHYPARA: |
| 7459 | DBG_88E("mp_get MP_PHYPARA\n"); |
| 7460 | rtw_mp_phypara(dev, info, wrqu, extra); |
| 7461 | break; |
| 7462 | case MP_CHANNEL: |
| 7463 | DBG_88E("set case mp_channel\n"); |
| 7464 | rtw_mp_channel(dev, info, wrqu, extra); |
| 7465 | break; |
| 7466 | case READ_REG: |
| 7467 | DBG_88E("mp_get READ_REG\n"); |
| 7468 | rtw_mp_read_reg(dev, info, wrqu, extra); |
| 7469 | break; |
| 7470 | case READ_RF: |
| 7471 | DBG_88E("mp_get READ_RF\n"); |
| 7472 | rtw_mp_read_rf(dev, info, wrqu, extra); |
| 7473 | break; |
| 7474 | case MP_RATE: |
| 7475 | DBG_88E("set case mp_rate\n"); |
| 7476 | rtw_mp_rate(dev, info, wrqu, extra); |
| 7477 | break; |
| 7478 | case MP_TXPOWER: |
| 7479 | DBG_88E("set case MP_TXPOWER\n"); |
| 7480 | rtw_mp_txpower(dev, info, wrqu, extra); |
| 7481 | break; |
| 7482 | case MP_ANT_TX: |
| 7483 | DBG_88E("set case MP_ANT_TX\n"); |
| 7484 | rtw_mp_ant_tx(dev, info, wrqu, extra); |
| 7485 | break; |
| 7486 | case MP_ANT_RX: |
| 7487 | DBG_88E("set case MP_ANT_RX\n"); |
| 7488 | rtw_mp_ant_rx(dev, info, wrqu, extra); |
| 7489 | break; |
| 7490 | case MP_QUERY: |
| 7491 | rtw_mp_trx_query(dev, info, wrqu, extra); |
| 7492 | break; |
| 7493 | case MP_CTX: |
| 7494 | DBG_88E("set case MP_CTX\n"); |
| 7495 | rtw_mp_ctx(dev, info, wrqu, extra); |
| 7496 | break; |
| 7497 | case MP_ARX: |
| 7498 | DBG_88E("set case MP_ARX\n"); |
| 7499 | rtw_mp_arx(dev, info, wrqu, extra); |
| 7500 | break; |
| 7501 | case EFUSE_GET: |
| 7502 | DBG_88E("efuse get EFUSE_GET\n"); |
| 7503 | rtw_mp_efuse_get(dev, info, wdata, extra); |
| 7504 | break; |
| 7505 | case MP_DUMP: |
| 7506 | DBG_88E("set case MP_DUMP\n"); |
| 7507 | rtw_mp_dump(dev, info, wrqu, extra); |
| 7508 | break; |
| 7509 | case MP_PSD: |
| 7510 | DBG_88E("set case MP_PSD\n"); |
| 7511 | rtw_mp_psd(dev, info, wrqu, extra); |
| 7512 | break; |
| 7513 | case MP_THER: |
| 7514 | DBG_88E("set case MP_THER\n"); |
| 7515 | rtw_mp_thermal(dev, info, wrqu, extra); |
| 7516 | break; |
| 7517 | case MP_QueryDrvStats: |
| 7518 | DBG_88E("mp_get MP_QueryDrvStats\n"); |
| 7519 | rtw_mp_QueryDrv (dev, info, wdata, extra); |
| 7520 | break; |
| 7521 | case MP_PWRTRK: |
| 7522 | DBG_88E("set case MP_PWRTRK\n"); |
| 7523 | rtw_mp_pwrtrk(dev, info, wrqu, extra); |
| 7524 | break; |
| 7525 | case EFUSE_SET: |
| 7526 | DBG_88E("set case efuse set\n"); |
| 7527 | rtw_mp_efuse_set(dev, info, wdata, extra); |
| 7528 | break; |
| 7529 | } |
| 7530 | |
Larry Finger | 0da46e6 | 2013-12-19 22:38:41 -0600 | [diff] [blame] | 7531 | msleep(10); /* delay 5ms for sending pkt before exit adb shell operation */ |
Larry Finger | a2c60d4 | 2013-08-21 22:33:58 -0500 | [diff] [blame] | 7532 | return 0; |
| 7533 | } |
| 7534 | |
| 7535 | static int rtw_tdls(struct net_device *dev, |
| 7536 | struct iw_request_info *info, |
| 7537 | union iwreq_data *wrqu, char *extra) |
| 7538 | { |
| 7539 | return 0; |
| 7540 | } |
| 7541 | |
| 7542 | static int rtw_tdls_get(struct net_device *dev, |
| 7543 | struct iw_request_info *info, |
| 7544 | union iwreq_data *wrqu, char *extra) |
| 7545 | { |
| 7546 | return 0; |
| 7547 | } |
| 7548 | |
| 7549 | static int rtw_test( |
| 7550 | struct net_device *dev, |
| 7551 | struct iw_request_info *info, |
| 7552 | union iwreq_data *wrqu, char *extra) |
| 7553 | { |
| 7554 | u32 len; |
| 7555 | u8 *pbuf, *pch; |
| 7556 | char *ptmp; |
| 7557 | u8 *delim = ","; |
| 7558 | |
| 7559 | DBG_88E("+%s\n", __func__); |
| 7560 | len = wrqu->data.length; |
| 7561 | |
| 7562 | pbuf = (u8 *)rtw_zmalloc(len); |
| 7563 | if (pbuf == NULL) { |
| 7564 | DBG_88E("%s: no memory!\n", __func__); |
| 7565 | return -ENOMEM; |
| 7566 | } |
| 7567 | |
| 7568 | if (copy_from_user(pbuf, wrqu->data.pointer, len)) { |
| 7569 | kfree(pbuf); |
| 7570 | DBG_88E("%s: copy from user fail!\n", __func__); |
| 7571 | return -EFAULT; |
| 7572 | } |
| 7573 | DBG_88E("%s: string =\"%s\"\n", __func__, pbuf); |
| 7574 | |
| 7575 | ptmp = (char *)pbuf; |
| 7576 | pch = strsep(&ptmp, delim); |
| 7577 | if ((pch == NULL) || (strlen(pch) == 0)) { |
| 7578 | kfree(pbuf); |
| 7579 | DBG_88E("%s: parameter error(level 1)!\n", __func__); |
| 7580 | return -EFAULT; |
| 7581 | } |
| 7582 | kfree(pbuf); |
| 7583 | return 0; |
| 7584 | } |
| 7585 | |
| 7586 | static iw_handler rtw_handlers[] = { |
| 7587 | NULL, /* SIOCSIWCOMMIT */ |
| 7588 | rtw_wx_get_name, /* SIOCGIWNAME */ |
| 7589 | dummy, /* SIOCSIWNWID */ |
| 7590 | dummy, /* SIOCGIWNWID */ |
| 7591 | rtw_wx_set_freq, /* SIOCSIWFREQ */ |
| 7592 | rtw_wx_get_freq, /* SIOCGIWFREQ */ |
| 7593 | rtw_wx_set_mode, /* SIOCSIWMODE */ |
| 7594 | rtw_wx_get_mode, /* SIOCGIWMODE */ |
| 7595 | dummy, /* SIOCSIWSENS */ |
| 7596 | rtw_wx_get_sens, /* SIOCGIWSENS */ |
| 7597 | NULL, /* SIOCSIWRANGE */ |
| 7598 | rtw_wx_get_range, /* SIOCGIWRANGE */ |
| 7599 | rtw_wx_set_priv, /* SIOCSIWPRIV */ |
| 7600 | NULL, /* SIOCGIWPRIV */ |
| 7601 | NULL, /* SIOCSIWSTATS */ |
| 7602 | NULL, /* SIOCGIWSTATS */ |
| 7603 | dummy, /* SIOCSIWSPY */ |
| 7604 | dummy, /* SIOCGIWSPY */ |
| 7605 | NULL, /* SIOCGIWTHRSPY */ |
| 7606 | NULL, /* SIOCWIWTHRSPY */ |
| 7607 | rtw_wx_set_wap, /* SIOCSIWAP */ |
| 7608 | rtw_wx_get_wap, /* SIOCGIWAP */ |
| 7609 | rtw_wx_set_mlme, /* request MLME operation; uses struct iw_mlme */ |
| 7610 | dummy, /* SIOCGIWAPLIST -- depricated */ |
| 7611 | rtw_wx_set_scan, /* SIOCSIWSCAN */ |
| 7612 | rtw_wx_get_scan, /* SIOCGIWSCAN */ |
| 7613 | rtw_wx_set_essid, /* SIOCSIWESSID */ |
| 7614 | rtw_wx_get_essid, /* SIOCGIWESSID */ |
| 7615 | dummy, /* SIOCSIWNICKN */ |
| 7616 | rtw_wx_get_nick, /* SIOCGIWNICKN */ |
| 7617 | NULL, /* -- hole -- */ |
| 7618 | NULL, /* -- hole -- */ |
| 7619 | rtw_wx_set_rate, /* SIOCSIWRATE */ |
| 7620 | rtw_wx_get_rate, /* SIOCGIWRATE */ |
| 7621 | rtw_wx_set_rts, /* SIOCSIWRTS */ |
| 7622 | rtw_wx_get_rts, /* SIOCGIWRTS */ |
| 7623 | rtw_wx_set_frag, /* SIOCSIWFRAG */ |
| 7624 | rtw_wx_get_frag, /* SIOCGIWFRAG */ |
| 7625 | dummy, /* SIOCSIWTXPOW */ |
| 7626 | dummy, /* SIOCGIWTXPOW */ |
| 7627 | dummy, /* SIOCSIWRETRY */ |
| 7628 | rtw_wx_get_retry, /* SIOCGIWRETRY */ |
| 7629 | rtw_wx_set_enc, /* SIOCSIWENCODE */ |
| 7630 | rtw_wx_get_enc, /* SIOCGIWENCODE */ |
| 7631 | dummy, /* SIOCSIWPOWER */ |
| 7632 | rtw_wx_get_power, /* SIOCGIWPOWER */ |
| 7633 | NULL, /*---hole---*/ |
| 7634 | NULL, /*---hole---*/ |
| 7635 | rtw_wx_set_gen_ie, /* SIOCSIWGENIE */ |
| 7636 | NULL, /* SIOCGWGENIE */ |
| 7637 | rtw_wx_set_auth, /* SIOCSIWAUTH */ |
| 7638 | NULL, /* SIOCGIWAUTH */ |
| 7639 | rtw_wx_set_enc_ext, /* SIOCSIWENCODEEXT */ |
| 7640 | NULL, /* SIOCGIWENCODEEXT */ |
| 7641 | rtw_wx_set_pmkid, /* SIOCSIWPMKSA */ |
| 7642 | NULL, /*---hole---*/ |
| 7643 | }; |
| 7644 | |
| 7645 | static const struct iw_priv_args rtw_private_args[] = { |
| 7646 | { |
| 7647 | SIOCIWFIRSTPRIV + 0x0, |
| 7648 | IW_PRIV_TYPE_CHAR | 0x7FF, 0, "write" |
| 7649 | }, |
| 7650 | { |
| 7651 | SIOCIWFIRSTPRIV + 0x1, |
| 7652 | IW_PRIV_TYPE_CHAR | 0x7FF, |
| 7653 | IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "read" |
| 7654 | }, |
| 7655 | { |
| 7656 | SIOCIWFIRSTPRIV + 0x2, 0, 0, "driver_ext" |
| 7657 | }, |
| 7658 | { |
| 7659 | SIOCIWFIRSTPRIV + 0x3, 0, 0, "mp_ioctl" |
| 7660 | }, |
| 7661 | { |
| 7662 | SIOCIWFIRSTPRIV + 0x4, |
| 7663 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "apinfo" |
| 7664 | }, |
| 7665 | { |
| 7666 | SIOCIWFIRSTPRIV + 0x5, |
| 7667 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setpid" |
| 7668 | }, |
| 7669 | { |
| 7670 | SIOCIWFIRSTPRIV + 0x6, |
| 7671 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_start" |
| 7672 | }, |
| 7673 | { |
| 7674 | SIOCIWFIRSTPRIV + 0x7, |
| 7675 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "get_sensitivity" |
| 7676 | }, |
| 7677 | { |
| 7678 | SIOCIWFIRSTPRIV + 0x8, |
| 7679 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_prob_req_ie" |
| 7680 | }, |
| 7681 | { |
| 7682 | SIOCIWFIRSTPRIV + 0x9, |
| 7683 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_assoc_req_ie" |
| 7684 | }, |
| 7685 | |
| 7686 | { |
| 7687 | SIOCIWFIRSTPRIV + 0xA, |
| 7688 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "channel_plan" |
| 7689 | }, |
| 7690 | |
| 7691 | { |
| 7692 | SIOCIWFIRSTPRIV + 0xB, |
| 7693 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "dbg" |
| 7694 | }, |
| 7695 | { |
| 7696 | SIOCIWFIRSTPRIV + 0xC, |
| 7697 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "rfw" |
| 7698 | }, |
| 7699 | { |
| 7700 | SIOCIWFIRSTPRIV + 0xD, |
| 7701 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "rfr" |
| 7702 | }, |
| 7703 | { |
| 7704 | SIOCIWFIRSTPRIV + 0x10, |
| 7705 | IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, 0, "p2p_set" |
| 7706 | }, |
| 7707 | { |
| 7708 | SIOCIWFIRSTPRIV + 0x11, |
| 7709 | IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | P2P_PRIVATE_IOCTL_SET_LEN, "p2p_get" |
| 7710 | }, |
| 7711 | { |
| 7712 | SIOCIWFIRSTPRIV + 0x12, |
| 7713 | IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IFNAMSIZ, "p2p_get2" |
| 7714 | }, |
| 7715 | {SIOCIWFIRSTPRIV + 0x13, IW_PRIV_TYPE_CHAR | 128, 0, "NULL"}, |
| 7716 | { |
| 7717 | SIOCIWFIRSTPRIV + 0x14, |
| 7718 | IW_PRIV_TYPE_CHAR | 64, 0, "tdls" |
| 7719 | }, |
| 7720 | { |
| 7721 | SIOCIWFIRSTPRIV + 0x15, |
| 7722 | IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | P2P_PRIVATE_IOCTL_SET_LEN, "tdls_get" |
| 7723 | }, |
| 7724 | { |
| 7725 | SIOCIWFIRSTPRIV + 0x16, |
| 7726 | IW_PRIV_TYPE_CHAR | 64, 0, "pm_set" |
| 7727 | }, |
| 7728 | |
| 7729 | {SIOCIWFIRSTPRIV + 0x18, IW_PRIV_TYPE_CHAR | IFNAMSIZ, 0, "rereg_nd_name"}, |
| 7730 | |
| 7731 | {SIOCIWFIRSTPRIV + 0x1A, IW_PRIV_TYPE_CHAR | 1024, 0, "efuse_set"}, |
| 7732 | {SIOCIWFIRSTPRIV + 0x1B, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_get"}, |
| 7733 | {SIOCIWFIRSTPRIV + 0x1D, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 0x7FF, "test" |
| 7734 | }, |
| 7735 | |
| 7736 | {SIOCIWFIRSTPRIV + 0x0E, IW_PRIV_TYPE_CHAR | 1024, 0, ""}, /* set */ |
| 7737 | {SIOCIWFIRSTPRIV + 0x0F, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, ""},/* get */ |
| 7738 | /* --- sub-ioctls definitions --- */ |
| 7739 | |
| 7740 | {MP_START, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_start"}, /* set */ |
| 7741 | {MP_PHYPARA, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_phypara"},/* get */ |
| 7742 | {MP_STOP, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_stop"}, /* set */ |
| 7743 | {MP_CHANNEL, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_channel"},/* get */ |
| 7744 | {MP_BANDWIDTH, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_bandwidth"}, /* set */ |
| 7745 | {MP_RATE, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_rate"},/* get */ |
| 7746 | {MP_RESET_STATS, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_reset_stats"}, |
| 7747 | {MP_QUERY, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_query"}, /* get */ |
| 7748 | {READ_REG, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "read_reg"}, |
| 7749 | {MP_RATE, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_rate"}, |
| 7750 | {READ_RF, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "read_rf"}, |
| 7751 | {MP_PSD, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_psd"}, |
| 7752 | {MP_DUMP, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_dump"}, |
| 7753 | {MP_TXPOWER, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_txpower"}, |
| 7754 | {MP_ANT_TX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ant_tx"}, |
| 7755 | {MP_ANT_RX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ant_rx"}, |
| 7756 | {WRITE_REG, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "write_reg"}, |
| 7757 | {WRITE_RF, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "write_rf"}, |
| 7758 | {MP_CTX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ctx"}, |
| 7759 | {MP_ARX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_arx"}, |
| 7760 | {MP_THER, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ther"}, |
| 7761 | {EFUSE_SET, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_set"}, |
| 7762 | {EFUSE_GET, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_get"}, |
| 7763 | {MP_PWRTRK, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_pwrtrk"}, |
| 7764 | {MP_QueryDrvStats, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_drvquery"}, |
| 7765 | {MP_IOCTL, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_ioctl"}, /* mp_ioctl */ |
| 7766 | {MP_SetRFPathSwh, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_setrfpath"}, |
| 7767 | {CTA_TEST, IW_PRIV_TYPE_CHAR | 1024, 0, "cta_test"}, |
| 7768 | }; |
| 7769 | |
| 7770 | static iw_handler rtw_private_handler[] = { |
| 7771 | rtw_wx_write32, /* 0x00 */ |
| 7772 | rtw_wx_read32, /* 0x01 */ |
| 7773 | rtw_drvext_hdl, /* 0x02 */ |
| 7774 | rtw_mp_ioctl_hdl, /* 0x03 */ |
| 7775 | |
| 7776 | /* for MM DTV platform */ |
| 7777 | rtw_get_ap_info, /* 0x04 */ |
| 7778 | |
| 7779 | rtw_set_pid, /* 0x05 */ |
| 7780 | rtw_wps_start, /* 0x06 */ |
| 7781 | |
| 7782 | rtw_wx_get_sensitivity, /* 0x07 */ |
| 7783 | rtw_wx_set_mtk_wps_probe_ie, /* 0x08 */ |
| 7784 | rtw_wx_set_mtk_wps_ie, /* 0x09 */ |
| 7785 | |
| 7786 | /* Set Channel depend on the country code */ |
| 7787 | rtw_wx_set_channel_plan, /* 0x0A */ |
| 7788 | |
| 7789 | rtw_dbg_port, /* 0x0B */ |
| 7790 | rtw_wx_write_rf, /* 0x0C */ |
| 7791 | rtw_wx_read_rf, /* 0x0D */ |
| 7792 | |
| 7793 | rtw_mp_set, /* 0x0E */ |
| 7794 | rtw_mp_get, /* 0x0F */ |
| 7795 | rtw_p2p_set, /* 0x10 */ |
| 7796 | rtw_p2p_get, /* 0x11 */ |
| 7797 | rtw_p2p_get2, /* 0x12 */ |
| 7798 | |
| 7799 | NULL, /* 0x13 */ |
| 7800 | rtw_tdls, /* 0x14 */ |
| 7801 | rtw_tdls_get, /* 0x15 */ |
| 7802 | |
| 7803 | rtw_pm_set, /* 0x16 */ |
| 7804 | rtw_wx_priv_null, /* 0x17 */ |
| 7805 | rtw_rereg_nd_name, /* 0x18 */ |
| 7806 | rtw_wx_priv_null, /* 0x19 */ |
| 7807 | |
| 7808 | rtw_mp_efuse_set, /* 0x1A */ |
| 7809 | rtw_mp_efuse_get, /* 0x1B */ |
| 7810 | NULL, /* 0x1C is reserved for hostapd */ |
| 7811 | rtw_test, /* 0x1D */ |
| 7812 | }; |
| 7813 | |
| 7814 | static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev) |
| 7815 | { |
| 7816 | struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); |
| 7817 | struct iw_statistics *piwstats = &padapter->iwstats; |
| 7818 | int tmp_level = 0; |
| 7819 | int tmp_qual = 0; |
| 7820 | int tmp_noise = 0; |
| 7821 | |
| 7822 | if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { |
| 7823 | piwstats->qual.qual = 0; |
| 7824 | piwstats->qual.level = 0; |
| 7825 | piwstats->qual.noise = 0; |
| 7826 | } else { |
| 7827 | tmp_level = padapter->recvpriv.signal_strength; |
| 7828 | tmp_qual = padapter->recvpriv.signal_qual; |
| 7829 | tmp_noise = padapter->recvpriv.noise; |
| 7830 | |
| 7831 | piwstats->qual.level = tmp_level; |
| 7832 | piwstats->qual.qual = tmp_qual; |
| 7833 | piwstats->qual.noise = tmp_noise; |
| 7834 | } |
| 7835 | piwstats->qual.updated = IW_QUAL_ALL_UPDATED;/* IW_QUAL_DBM; */ |
| 7836 | return &padapter->iwstats; |
| 7837 | } |
| 7838 | |
| 7839 | struct iw_handler_def rtw_handlers_def = { |
| 7840 | .standard = rtw_handlers, |
| 7841 | .num_standard = sizeof(rtw_handlers) / sizeof(iw_handler), |
| 7842 | .private = rtw_private_handler, |
| 7843 | .private_args = (struct iw_priv_args *)rtw_private_args, |
| 7844 | .num_private = sizeof(rtw_private_handler) / sizeof(iw_handler), |
| 7845 | .num_private_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args), |
| 7846 | .get_wireless_stats = rtw_get_wireless_stats, |
| 7847 | }; |
| 7848 | |
| 7849 | /* copy from net/wireless/wext.c start */ |
| 7850 | /* ---------------------------------------------------------------- */ |
| 7851 | /* |
| 7852 | * Calculate size of private arguments |
| 7853 | */ |
| 7854 | static const char iw_priv_type_size[] = { |
| 7855 | 0, /* IW_PRIV_TYPE_NONE */ |
| 7856 | 1, /* IW_PRIV_TYPE_BYTE */ |
| 7857 | 1, /* IW_PRIV_TYPE_CHAR */ |
| 7858 | 0, /* Not defined */ |
| 7859 | sizeof(__u32), /* IW_PRIV_TYPE_INT */ |
| 7860 | sizeof(struct iw_freq), /* IW_PRIV_TYPE_FLOAT */ |
| 7861 | sizeof(struct sockaddr), /* IW_PRIV_TYPE_ADDR */ |
| 7862 | 0, /* Not defined */ |
| 7863 | }; |
| 7864 | |
| 7865 | static int get_priv_size(__u16 args) |
| 7866 | { |
| 7867 | int num = args & IW_PRIV_SIZE_MASK; |
| 7868 | int type = (args & IW_PRIV_TYPE_MASK) >> 12; |
| 7869 | |
| 7870 | return num * iw_priv_type_size[type]; |
| 7871 | } |
| 7872 | /* copy from net/wireless/wext.c end */ |
| 7873 | |
| 7874 | static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_data) |
| 7875 | { |
| 7876 | int err = 0; |
| 7877 | u8 *input = NULL; |
| 7878 | u32 input_len = 0; |
| 7879 | const char delim[] = " "; |
| 7880 | u8 *output = NULL; |
| 7881 | u32 output_len = 0; |
| 7882 | u32 count = 0; |
| 7883 | u8 *buffer = NULL; |
| 7884 | u32 buffer_len = 0; |
| 7885 | char *ptr = NULL; |
| 7886 | u8 cmdname[17] = {0}; /* IFNAMSIZ+1 */ |
| 7887 | u32 cmdlen; |
| 7888 | s32 len; |
| 7889 | u8 *extra = NULL; |
| 7890 | u32 extra_size = 0; |
| 7891 | |
| 7892 | s32 k; |
| 7893 | const iw_handler *priv; /* Private ioctl */ |
| 7894 | const struct iw_priv_args *priv_args; /* Private ioctl description */ |
| 7895 | u32 num_priv_args; /* Number of descriptions */ |
| 7896 | iw_handler handler; |
| 7897 | int temp; |
| 7898 | int subcmd = 0; /* sub-ioctl index */ |
| 7899 | int offset = 0; /* Space for sub-ioctl index */ |
| 7900 | |
| 7901 | union iwreq_data wdata; |
| 7902 | |
| 7903 | memcpy(&wdata, wrq_data, sizeof(wdata)); |
| 7904 | |
| 7905 | input_len = wdata.data.length; |
| 7906 | input = rtw_zmalloc(input_len); |
| 7907 | if (NULL == input) |
| 7908 | return -ENOMEM; |
| 7909 | if (copy_from_user(input, wdata.data.pointer, input_len)) { |
| 7910 | err = -EFAULT; |
| 7911 | goto exit; |
| 7912 | } |
| 7913 | ptr = input; |
| 7914 | len = input_len; |
| 7915 | |
| 7916 | sscanf(ptr, "%16s", cmdname); |
| 7917 | cmdlen = strlen(cmdname); |
| 7918 | DBG_88E("%s: cmd =%s\n", __func__, cmdname); |
| 7919 | |
| 7920 | /* skip command string */ |
| 7921 | if (cmdlen > 0) |
| 7922 | cmdlen += 1; /* skip one space */ |
| 7923 | ptr += cmdlen; |
| 7924 | len -= cmdlen; |
| 7925 | DBG_88E("%s: parameters =%s\n", __func__, ptr); |
| 7926 | |
| 7927 | priv = rtw_private_handler; |
| 7928 | priv_args = rtw_private_args; |
| 7929 | num_priv_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args); |
| 7930 | |
| 7931 | if (num_priv_args == 0) { |
| 7932 | err = -EOPNOTSUPP; |
| 7933 | goto exit; |
| 7934 | } |
| 7935 | |
| 7936 | /* Search the correct ioctl */ |
| 7937 | k = -1; |
| 7938 | while ((++k < num_priv_args) && strcmp(priv_args[k].name, cmdname)); |
| 7939 | |
| 7940 | /* If not found... */ |
| 7941 | if (k == num_priv_args) { |
| 7942 | err = -EOPNOTSUPP; |
| 7943 | goto exit; |
| 7944 | } |
| 7945 | |
| 7946 | /* Watch out for sub-ioctls ! */ |
| 7947 | if (priv_args[k].cmd < SIOCDEVPRIVATE) { |
| 7948 | int j = -1; |
| 7949 | |
| 7950 | /* Find the matching *real* ioctl */ |
| 7951 | while ((++j < num_priv_args) && ((priv_args[j].name[0] != '\0') || |
| 7952 | (priv_args[j].set_args != priv_args[k].set_args) || |
| 7953 | (priv_args[j].get_args != priv_args[k].get_args))); |
| 7954 | |
| 7955 | /* If not found... */ |
| 7956 | if (j == num_priv_args) { |
| 7957 | err = -EINVAL; |
| 7958 | goto exit; |
| 7959 | } |
| 7960 | |
| 7961 | /* Save sub-ioctl number */ |
| 7962 | subcmd = priv_args[k].cmd; |
| 7963 | /* Reserve one int (simplify alignment issues) */ |
| 7964 | offset = sizeof(__u32); |
| 7965 | /* Use real ioctl definition from now on */ |
| 7966 | k = j; |
| 7967 | } |
| 7968 | |
| 7969 | buffer = rtw_zmalloc(4096); |
| 7970 | if (NULL == buffer) { |
| 7971 | err = -ENOMEM; |
| 7972 | goto exit; |
| 7973 | } |
| 7974 | |
| 7975 | /* If we have to set some data */ |
| 7976 | if ((priv_args[k].set_args & IW_PRIV_TYPE_MASK) && |
| 7977 | (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) { |
| 7978 | u8 *str; |
| 7979 | |
| 7980 | switch (priv_args[k].set_args & IW_PRIV_TYPE_MASK) { |
| 7981 | case IW_PRIV_TYPE_BYTE: |
| 7982 | /* Fetch args */ |
| 7983 | count = 0; |
| 7984 | do { |
| 7985 | str = strsep(&ptr, delim); |
| 7986 | if (NULL == str) |
| 7987 | break; |
| 7988 | sscanf(str, "%i", &temp); |
| 7989 | buffer[count++] = (u8)temp; |
| 7990 | } while (1); |
| 7991 | buffer_len = count; |
| 7992 | /* Number of args to fetch */ |
| 7993 | wdata.data.length = count; |
| 7994 | if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) |
| 7995 | wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; |
| 7996 | break; |
| 7997 | case IW_PRIV_TYPE_INT: |
| 7998 | /* Fetch args */ |
| 7999 | count = 0; |
| 8000 | do { |
| 8001 | str = strsep(&ptr, delim); |
| 8002 | if (NULL == str) |
| 8003 | break; |
| 8004 | sscanf(str, "%i", &temp); |
| 8005 | ((s32 *)buffer)[count++] = (s32)temp; |
| 8006 | } while (1); |
| 8007 | buffer_len = count * sizeof(s32); |
| 8008 | /* Number of args to fetch */ |
| 8009 | wdata.data.length = count; |
| 8010 | if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) |
| 8011 | wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; |
| 8012 | break; |
| 8013 | case IW_PRIV_TYPE_CHAR: |
| 8014 | if (len > 0) { |
| 8015 | /* Size of the string to fetch */ |
| 8016 | wdata.data.length = len; |
| 8017 | if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) |
| 8018 | wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; |
| 8019 | |
| 8020 | /* Fetch string */ |
| 8021 | memcpy(buffer, ptr, wdata.data.length); |
| 8022 | } else { |
| 8023 | wdata.data.length = 1; |
| 8024 | buffer[0] = '\0'; |
| 8025 | } |
| 8026 | buffer_len = wdata.data.length; |
| 8027 | break; |
| 8028 | default: |
| 8029 | DBG_88E("%s: Not yet implemented...\n", __func__); |
| 8030 | err = -1; |
| 8031 | goto exit; |
| 8032 | } |
| 8033 | |
| 8034 | if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && |
| 8035 | (wdata.data.length != (priv_args[k].set_args & IW_PRIV_SIZE_MASK))) { |
| 8036 | DBG_88E("%s: The command %s needs exactly %d argument(s)...\n", |
| 8037 | __func__, cmdname, priv_args[k].set_args & IW_PRIV_SIZE_MASK); |
| 8038 | err = -EINVAL; |
| 8039 | goto exit; |
| 8040 | } |
| 8041 | } else { |
| 8042 | /* if args to set */ |
| 8043 | wdata.data.length = 0L; |
| 8044 | } |
| 8045 | |
| 8046 | /* Those two tests are important. They define how the driver |
| 8047 | * will have to handle the data */ |
| 8048 | if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && |
| 8049 | ((get_priv_size(priv_args[k].set_args) + offset) <= IFNAMSIZ)) { |
| 8050 | /* First case : all SET args fit within wrq */ |
| 8051 | if (offset) |
| 8052 | wdata.mode = subcmd; |
| 8053 | memcpy(wdata.name + offset, buffer, IFNAMSIZ - offset); |
| 8054 | } else { |
| 8055 | if ((priv_args[k].set_args == 0) && |
| 8056 | (priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && |
| 8057 | (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) { |
| 8058 | /* Second case : no SET args, GET args fit within wrq */ |
| 8059 | if (offset) |
| 8060 | wdata.mode = subcmd; |
| 8061 | } else { |
| 8062 | /* Third case : args won't fit in wrq, or variable number of args */ |
| 8063 | if (copy_to_user(wdata.data.pointer, buffer, buffer_len)) { |
| 8064 | err = -EFAULT; |
| 8065 | goto exit; |
| 8066 | } |
| 8067 | wdata.data.flags = subcmd; |
| 8068 | } |
| 8069 | } |
| 8070 | |
| 8071 | kfree(input); |
| 8072 | input = NULL; |
| 8073 | |
| 8074 | extra_size = 0; |
| 8075 | if (IW_IS_SET(priv_args[k].cmd)) { |
| 8076 | /* Size of set arguments */ |
| 8077 | extra_size = get_priv_size(priv_args[k].set_args); |
| 8078 | |
| 8079 | /* Does it fits in iwr ? */ |
| 8080 | if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && |
| 8081 | ((extra_size + offset) <= IFNAMSIZ)) |
| 8082 | extra_size = 0; |
| 8083 | } else { |
| 8084 | /* Size of get arguments */ |
| 8085 | extra_size = get_priv_size(priv_args[k].get_args); |
| 8086 | |
| 8087 | /* Does it fits in iwr ? */ |
| 8088 | if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && |
| 8089 | (extra_size <= IFNAMSIZ)) |
| 8090 | extra_size = 0; |
| 8091 | } |
| 8092 | |
| 8093 | if (extra_size == 0) { |
| 8094 | extra = (u8 *)&wdata; |
| 8095 | kfree(buffer); |
| 8096 | buffer = NULL; |
| 8097 | } else { |
| 8098 | extra = buffer; |
| 8099 | } |
| 8100 | |
| 8101 | handler = priv[priv_args[k].cmd - SIOCIWFIRSTPRIV]; |
| 8102 | err = handler(dev, NULL, &wdata, extra); |
| 8103 | |
| 8104 | /* If we have to get some data */ |
| 8105 | if ((priv_args[k].get_args & IW_PRIV_TYPE_MASK) && |
| 8106 | (priv_args[k].get_args & IW_PRIV_SIZE_MASK)) { |
| 8107 | int j; |
| 8108 | int n = 0; /* number of args */ |
| 8109 | u8 str[20] = {0}; |
| 8110 | |
| 8111 | /* Check where is the returned data */ |
| 8112 | if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && |
| 8113 | (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) |
| 8114 | n = priv_args[k].get_args & IW_PRIV_SIZE_MASK; |
| 8115 | else |
| 8116 | n = wdata.data.length; |
| 8117 | |
| 8118 | output = rtw_zmalloc(4096); |
| 8119 | if (NULL == output) { |
| 8120 | err = -ENOMEM; |
| 8121 | goto exit; |
| 8122 | } |
| 8123 | switch (priv_args[k].get_args & IW_PRIV_TYPE_MASK) { |
| 8124 | case IW_PRIV_TYPE_BYTE: |
| 8125 | /* Display args */ |
| 8126 | for (j = 0; j < n; j++) { |
| 8127 | sprintf(str, "%d ", extra[j]); |
| 8128 | len = strlen(str); |
| 8129 | output_len = strlen(output); |
| 8130 | if ((output_len + len + 1) > 4096) { |
| 8131 | err = -E2BIG; |
| 8132 | goto exit; |
| 8133 | } |
| 8134 | memcpy(output+output_len, str, len); |
| 8135 | } |
| 8136 | break; |
| 8137 | case IW_PRIV_TYPE_INT: |
| 8138 | /* Display args */ |
| 8139 | for (j = 0; j < n; j++) { |
| 8140 | sprintf(str, "%d ", ((__s32 *)extra)[j]); |
| 8141 | len = strlen(str); |
| 8142 | output_len = strlen(output); |
| 8143 | if ((output_len + len + 1) > 4096) { |
| 8144 | err = -E2BIG; |
| 8145 | goto exit; |
| 8146 | } |
| 8147 | memcpy(output+output_len, str, len); |
| 8148 | } |
| 8149 | break; |
| 8150 | case IW_PRIV_TYPE_CHAR: |
| 8151 | /* Display args */ |
| 8152 | memcpy(output, extra, n); |
| 8153 | break; |
| 8154 | default: |
| 8155 | DBG_88E("%s: Not yet implemented...\n", __func__); |
| 8156 | err = -1; |
| 8157 | goto exit; |
| 8158 | } |
| 8159 | |
| 8160 | output_len = strlen(output) + 1; |
| 8161 | wrq_data->data.length = output_len; |
| 8162 | if (copy_to_user(wrq_data->data.pointer, output, output_len)) { |
| 8163 | err = -EFAULT; |
| 8164 | goto exit; |
| 8165 | } |
| 8166 | } else { |
| 8167 | /* if args to set */ |
| 8168 | wrq_data->data.length = 0; |
| 8169 | } |
| 8170 | |
| 8171 | exit: |
| 8172 | kfree(input); |
| 8173 | kfree(buffer); |
| 8174 | kfree(output); |
| 8175 | return err; |
| 8176 | } |
| 8177 | |
| 8178 | #include <rtw_android.h> |
| 8179 | int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
| 8180 | { |
| 8181 | struct iwreq *wrq = (struct iwreq *)rq; |
| 8182 | int ret = 0; |
| 8183 | |
| 8184 | switch (cmd) { |
| 8185 | case RTL_IOCTL_WPA_SUPPLICANT: |
| 8186 | ret = wpa_supplicant_ioctl(dev, &wrq->u.data); |
| 8187 | break; |
| 8188 | #ifdef CONFIG_88EU_AP_MODE |
| 8189 | case RTL_IOCTL_HOSTAPD: |
| 8190 | ret = rtw_hostapd_ioctl(dev, &wrq->u.data); |
| 8191 | break; |
| 8192 | #endif /* CONFIG_88EU_AP_MODE */ |
| 8193 | case SIOCDEVPRIVATE: |
| 8194 | ret = rtw_ioctl_wext_private(dev, &wrq->u); |
| 8195 | break; |
| 8196 | case (SIOCDEVPRIVATE+1): |
| 8197 | ret = rtw_android_priv_cmd(dev, rq, cmd); |
| 8198 | break; |
| 8199 | default: |
| 8200 | ret = -EOPNOTSUPP; |
| 8201 | break; |
| 8202 | } |
| 8203 | return ret; |
| 8204 | } |