Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1 | /*! |
| 2 | * @file wilc_wfi_cfgopertaions.c |
| 3 | * @brief CFG80211 Function Implementation functionality |
| 4 | * @author aabouzaeid |
| 5 | * mabubakr |
| 6 | * mdaftedar |
| 7 | * zsalah |
| 8 | * @sa wilc_wfi_cfgopertaions.h top level OS wrapper file |
| 9 | * @date 31 Aug 2010 |
| 10 | * @version 1.0 |
| 11 | */ |
| 12 | |
| 13 | #include "wilc_wfi_cfgoperations.h" |
| 14 | #include "wilc_wlan.c" |
| 15 | #ifdef WILC_SDIO |
Chaehyun Lim | cdc9cba | 2015-09-22 18:34:47 +0900 | [diff] [blame^] | 16 | #include "linux_wlan_sdio.h" |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 17 | #endif |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 18 | #include <linux/errno.h> |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 19 | |
| 20 | #define IS_MANAGMEMENT 0x100 |
| 21 | #define IS_MANAGMEMENT_CALLBACK 0x080 |
| 22 | #define IS_MGMT_STATUS_SUCCES 0x040 |
| 23 | #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff) |
| 24 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 25 | extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 26 | extern u16 Set_machw_change_vir_if(bool bValue); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 27 | |
| 28 | extern int mac_open(struct net_device *ndev); |
| 29 | extern int mac_close(struct net_device *ndev); |
| 30 | |
| 31 | tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW]; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 32 | u32 u32LastScannedNtwrksCountShadow; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 33 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP |
Greg Kroah-Hartman | da711eb | 2015-08-14 19:46:06 -0700 | [diff] [blame] | 34 | struct timer_list hDuringIpTimer; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 35 | #endif |
Greg Kroah-Hartman | da711eb | 2015-08-14 19:46:06 -0700 | [diff] [blame] | 36 | struct timer_list hAgingTimer; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 37 | static u8 op_ifcs; |
| 38 | extern u8 u8ConnectedSSID[6]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 39 | |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 40 | u8 g_wilc_initialized = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 41 | extern linux_wlan_t *g_linux_wlan; |
| 42 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 43 | extern bool g_obtainingIP; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 44 | #endif |
| 45 | |
| 46 | #define CHAN2G(_channel, _freq, _flags) { \ |
| 47 | .band = IEEE80211_BAND_2GHZ, \ |
| 48 | .center_freq = (_freq), \ |
| 49 | .hw_value = (_channel), \ |
| 50 | .flags = (_flags), \ |
| 51 | .max_antenna_gain = 0, \ |
| 52 | .max_power = 30, \ |
| 53 | } |
| 54 | |
| 55 | /*Frequency range for channels*/ |
| 56 | static struct ieee80211_channel WILC_WFI_2ghz_channels[] = { |
| 57 | CHAN2G(1, 2412, 0), |
| 58 | CHAN2G(2, 2417, 0), |
| 59 | CHAN2G(3, 2422, 0), |
| 60 | CHAN2G(4, 2427, 0), |
| 61 | CHAN2G(5, 2432, 0), |
| 62 | CHAN2G(6, 2437, 0), |
| 63 | CHAN2G(7, 2442, 0), |
| 64 | CHAN2G(8, 2447, 0), |
| 65 | CHAN2G(9, 2452, 0), |
| 66 | CHAN2G(10, 2457, 0), |
| 67 | CHAN2G(11, 2462, 0), |
| 68 | CHAN2G(12, 2467, 0), |
| 69 | CHAN2G(13, 2472, 0), |
| 70 | CHAN2G(14, 2484, 0), |
| 71 | }; |
| 72 | |
| 73 | #define RATETAB_ENT(_rate, _hw_value, _flags) { \ |
| 74 | .bitrate = (_rate), \ |
| 75 | .hw_value = (_hw_value), \ |
| 76 | .flags = (_flags), \ |
| 77 | } |
| 78 | |
| 79 | |
| 80 | /* Table 6 in section 3.2.1.1 */ |
| 81 | static struct ieee80211_rate WILC_WFI_rates[] = { |
| 82 | RATETAB_ENT(10, 0, 0), |
| 83 | RATETAB_ENT(20, 1, 0), |
| 84 | RATETAB_ENT(55, 2, 0), |
| 85 | RATETAB_ENT(110, 3, 0), |
| 86 | RATETAB_ENT(60, 9, 0), |
| 87 | RATETAB_ENT(90, 6, 0), |
| 88 | RATETAB_ENT(120, 7, 0), |
| 89 | RATETAB_ENT(180, 8, 0), |
| 90 | RATETAB_ENT(240, 9, 0), |
| 91 | RATETAB_ENT(360, 10, 0), |
| 92 | RATETAB_ENT(480, 11, 0), |
| 93 | RATETAB_ENT(540, 12, 0), |
| 94 | }; |
| 95 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 96 | struct p2p_mgmt_data { |
| 97 | int size; |
| 98 | u8 *buff; |
| 99 | }; |
| 100 | |
| 101 | /*Global variable used to state the current connected STA channel*/ |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 102 | u8 u8WLANChannel = INVALID_CHANNEL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 103 | |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 104 | u8 u8CurrChannel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 105 | |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 106 | u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09}; |
| 107 | u8 u8P2Plocalrandom = 0x01; |
| 108 | u8 u8P2Precvrandom = 0x00; |
| 109 | u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03}; |
Daniel Machon | 7fc8096 | 2015-08-05 00:09:35 +0200 | [diff] [blame] | 110 | bool bWilc_ie; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 111 | |
| 112 | static struct ieee80211_supported_band WILC_WFI_band_2ghz = { |
| 113 | .channels = WILC_WFI_2ghz_channels, |
| 114 | .n_channels = ARRAY_SIZE(WILC_WFI_2ghz_channels), |
| 115 | .bitrates = WILC_WFI_rates, |
| 116 | .n_bitrates = ARRAY_SIZE(WILC_WFI_rates), |
| 117 | }; |
| 118 | |
| 119 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 120 | struct add_key_params { |
| 121 | u8 key_idx; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 122 | bool pairwise; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 123 | u8 *mac_addr; |
| 124 | }; |
| 125 | struct add_key_params g_add_gtk_key_params; |
| 126 | struct wilc_wfi_key g_key_gtk_params; |
| 127 | struct add_key_params g_add_ptk_key_params; |
| 128 | struct wilc_wfi_key g_key_ptk_params; |
| 129 | struct wilc_wfi_wep_key g_key_wep_params; |
Daniel Machon | 7fc8096 | 2015-08-05 00:09:35 +0200 | [diff] [blame] | 130 | bool g_ptk_keys_saved; |
| 131 | bool g_gtk_keys_saved; |
| 132 | bool g_wep_keys_saved; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 133 | |
| 134 | #define AGING_TIME (9 * 1000) |
| 135 | #define duringIP_TIME 15000 |
| 136 | |
| 137 | void clear_shadow_scan(void *pUserVoid) |
| 138 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 139 | int i; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 140 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 141 | if (op_ifcs == 0) { |
Greg Kroah-Hartman | 4183e97 | 2015-08-14 20:11:16 -0700 | [diff] [blame] | 142 | del_timer_sync(&hAgingTimer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 143 | PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n"); |
| 144 | |
| 145 | for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { |
| 146 | if (astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs != NULL) { |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 147 | kfree(astrLastScannedNtwrksShadow[i].pu8IEs); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 148 | astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs = NULL; |
| 149 | } |
| 150 | |
| 151 | host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams); |
| 152 | astrLastScannedNtwrksShadow[i].pJoinParams = NULL; |
| 153 | } |
| 154 | u32LastScannedNtwrksCountShadow = 0; |
| 155 | } |
| 156 | |
| 157 | } |
| 158 | |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 159 | u32 get_rssi_avg(tstrNetworkInfo *pstrNetworkInfo) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 160 | { |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 161 | u8 i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 162 | int rssi_v = 0; |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 163 | u8 num_rssi = (pstrNetworkInfo->strRssi.u8Full) ? NUM_RSSI : (pstrNetworkInfo->strRssi.u8Index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 164 | |
| 165 | for (i = 0; i < num_rssi; i++) |
| 166 | rssi_v += pstrNetworkInfo->strRssi.as8RSSI[i]; |
| 167 | |
| 168 | rssi_v /= num_rssi; |
| 169 | return rssi_v; |
| 170 | } |
| 171 | |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 172 | void refresh_scan(void *pUserVoid, u8 all, bool bDirectScan) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 173 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 174 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 175 | struct wiphy *wiphy; |
| 176 | struct cfg80211_bss *bss = NULL; |
| 177 | int i; |
| 178 | int rssi = 0; |
| 179 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 180 | priv = (struct wilc_priv *)pUserVoid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 181 | wiphy = priv->dev->ieee80211_ptr->wiphy; |
| 182 | |
| 183 | for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { |
| 184 | tstrNetworkInfo *pstrNetworkInfo; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 185 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 186 | pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]); |
| 187 | |
| 188 | |
| 189 | if ((!pstrNetworkInfo->u8Found) || all) { |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 190 | s32 s32Freq; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 191 | struct ieee80211_channel *channel; |
| 192 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 193 | if (pstrNetworkInfo != NULL) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 194 | |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 195 | s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 196 | channel = ieee80211_get_channel(wiphy, s32Freq); |
| 197 | |
| 198 | rssi = get_rssi_avg(pstrNetworkInfo); |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 199 | if (memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 200 | bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo, |
| 201 | pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs, |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 202 | (size_t)pstrNetworkInfo->u16IEsLen, (((s32)rssi) * 100), GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 203 | cfg80211_put_bss(wiphy, bss); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | } |
| 211 | |
| 212 | void reset_shadow_found(void *pUserVoid) |
| 213 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 214 | int i; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 215 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 216 | for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { |
| 217 | astrLastScannedNtwrksShadow[i].u8Found = 0; |
| 218 | |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | void update_scan_time(void *pUserVoid) |
| 223 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 224 | int i; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 225 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 226 | for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { |
| 227 | astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies; |
| 228 | } |
| 229 | } |
| 230 | |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 231 | static void remove_network_from_shadow(unsigned long arg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 232 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 233 | unsigned long now = jiffies; |
| 234 | int i, j; |
| 235 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 236 | |
| 237 | for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { |
| 238 | if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 239 | PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s\n", astrLastScannedNtwrksShadow[i].au8ssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 240 | |
| 241 | if (astrLastScannedNtwrksShadow[i].pu8IEs != NULL) { |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 242 | kfree(astrLastScannedNtwrksShadow[i].pu8IEs); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 243 | astrLastScannedNtwrksShadow[i].pu8IEs = NULL; |
| 244 | } |
| 245 | |
| 246 | host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams); |
| 247 | |
| 248 | for (j = i; (j < u32LastScannedNtwrksCountShadow - 1); j++) { |
| 249 | astrLastScannedNtwrksShadow[j] = astrLastScannedNtwrksShadow[j + 1]; |
| 250 | } |
| 251 | u32LastScannedNtwrksCountShadow--; |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow); |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 256 | if (u32LastScannedNtwrksCountShadow != 0) { |
| 257 | hAgingTimer.data = arg; |
| 258 | mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME)); |
| 259 | } else { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 260 | PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n"); |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 261 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 265 | static void clear_duringIP(unsigned long arg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 266 | { |
| 267 | PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n"); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 268 | g_obtainingIP = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 269 | } |
| 270 | #endif |
| 271 | |
| 272 | int8_t is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid) |
| 273 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 274 | int8_t state = -1; |
| 275 | int i; |
| 276 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 277 | if (u32LastScannedNtwrksCountShadow == 0) { |
| 278 | PRINT_D(CFG80211_DBG, "Starting Aging timer\n"); |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 279 | hAgingTimer.data = (unsigned long)pUserVoid; |
| 280 | mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 281 | state = -1; |
| 282 | } else { |
| 283 | /* Linear search for now */ |
| 284 | for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 285 | if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 286 | pstrNetworkInfo->au8bssid, 6) == 0) { |
| 287 | state = i; |
| 288 | break; |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | return state; |
| 293 | } |
| 294 | |
| 295 | void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams) |
| 296 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 297 | int8_t ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid); |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 298 | u32 ap_index = 0; |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 299 | u8 rssi_index = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 300 | |
| 301 | if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) { |
| 302 | PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n"); |
| 303 | return; |
| 304 | } |
| 305 | if (ap_found == -1) { |
| 306 | ap_index = u32LastScannedNtwrksCountShadow; |
| 307 | u32LastScannedNtwrksCountShadow++; |
| 308 | |
| 309 | } else { |
| 310 | ap_index = ap_found; |
| 311 | } |
| 312 | rssi_index = astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index; |
| 313 | astrLastScannedNtwrksShadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi; |
| 314 | if (rssi_index == NUM_RSSI) { |
| 315 | rssi_index = 0; |
| 316 | astrLastScannedNtwrksShadow[ap_index].strRssi.u8Full = 1; |
| 317 | } |
| 318 | astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index = rssi_index; |
| 319 | |
| 320 | astrLastScannedNtwrksShadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi; |
| 321 | astrLastScannedNtwrksShadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo; |
| 322 | |
| 323 | astrLastScannedNtwrksShadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 324 | memcpy(astrLastScannedNtwrksShadow[ap_index].au8ssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 325 | pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen); |
| 326 | |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 327 | memcpy(astrLastScannedNtwrksShadow[ap_index].au8bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 328 | pstrNetworkInfo->au8bssid, ETH_ALEN); |
| 329 | |
| 330 | astrLastScannedNtwrksShadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod; |
| 331 | astrLastScannedNtwrksShadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod; |
| 332 | astrLastScannedNtwrksShadow[ap_index].u8channel = pstrNetworkInfo->u8channel; |
| 333 | |
| 334 | astrLastScannedNtwrksShadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen; |
| 335 | astrLastScannedNtwrksShadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf; |
| 336 | if (ap_found != -1) |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 337 | kfree(astrLastScannedNtwrksShadow[ap_index].pu8IEs); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 338 | astrLastScannedNtwrksShadow[ap_index].pu8IEs = |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 339 | kmalloc(pstrNetworkInfo->u16IEsLen, GFP_KERNEL); /* will be deallocated by the WILC_WFI_CfgScan() function */ |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 340 | memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 341 | pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen); |
| 342 | |
| 343 | astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScan = jiffies; |
| 344 | astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScanCached = jiffies; |
| 345 | astrLastScannedNtwrksShadow[ap_index].u8Found = 1; |
| 346 | if (ap_found != -1) |
| 347 | host_int_freeJoinParams(astrLastScannedNtwrksShadow[ap_index].pJoinParams); |
| 348 | astrLastScannedNtwrksShadow[ap_index].pJoinParams = pJoinParams; |
| 349 | |
| 350 | } |
| 351 | |
| 352 | |
| 353 | /** |
| 354 | * @brief CfgScanResult |
| 355 | * @details Callback function which returns the scan results found |
| 356 | * |
| 357 | * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is |
| 358 | * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE |
| 359 | * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information |
| 360 | * void* pUserVoid: Private structure associated with the wireless interface |
| 361 | * @return NONE |
| 362 | * @author mabubakr |
| 363 | * @date |
| 364 | * @version 1.0 |
| 365 | */ |
| 366 | static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams) |
| 367 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 368 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 369 | struct wiphy *wiphy; |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 370 | s32 s32Freq; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 371 | struct ieee80211_channel *channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 372 | struct cfg80211_bss *bss = NULL; |
| 373 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 374 | priv = (struct wilc_priv *)pUserVoid; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 375 | if (priv->bCfgScanning == true) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 376 | if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) { |
| 377 | wiphy = priv->dev->ieee80211_ptr->wiphy; |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 378 | |
| 379 | if (!wiphy) |
| 380 | return; |
| 381 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 382 | if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC |
| 383 | && |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 384 | ((((s32)pstrNetworkInfo->s8rssi) * 100) < 0 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 385 | || |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 386 | (((s32)pstrNetworkInfo->s8rssi) * 100) > 100) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 387 | ) { |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 388 | PRINT_ER("wiphy signal type fial\n"); |
| 389 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 390 | } |
| 391 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 392 | if (pstrNetworkInfo != NULL) { |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 393 | s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 394 | channel = ieee80211_get_channel(wiphy, s32Freq); |
| 395 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 396 | if (!channel) |
| 397 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 398 | |
| 399 | PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d," |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 400 | "BeaconPeriod: %d\n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100), |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 401 | pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod); |
| 402 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 403 | if (pstrNetworkInfo->bNewNetwork == true) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 404 | if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */ |
| 405 | /* max_scan_ssids */ |
| 406 | PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid); |
| 407 | |
| 408 | |
| 409 | priv->u32RcvdChCount++; |
| 410 | |
| 411 | |
| 412 | |
| 413 | if (pJoinParams == NULL) { |
| 414 | PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n"); |
| 415 | } |
| 416 | add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams); |
| 417 | |
| 418 | /*P2P peers are sent to WPA supplicant and added to shadow table*/ |
| 419 | |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 420 | if (!(memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 421 | bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo, |
| 422 | pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs, |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 423 | (size_t)pstrNetworkInfo->u16IEsLen, (((s32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 424 | cfg80211_put_bss(wiphy, bss); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | |
| 428 | } else { |
| 429 | PRINT_ER("Discovered networks exceeded the max limit\n"); |
| 430 | } |
| 431 | } else { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 432 | u32 i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 433 | /* So this network is discovered before, we'll just update its RSSI */ |
| 434 | for (i = 0; i < priv->u32RcvdChCount; i++) { |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 435 | if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 436 | PRINT_D(CFG80211_DBG, "Update RSSI of %s\n", astrLastScannedNtwrksShadow[i].au8ssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 437 | |
| 438 | astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi; |
| 439 | astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies; |
| 440 | break; |
| 441 | } |
| 442 | } |
| 443 | } |
| 444 | } |
| 445 | } else if (enuScanEvent == SCAN_EVENT_DONE) { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 446 | PRINT_D(CFG80211_DBG, "Scan Done[%p]\n", priv->dev); |
| 447 | PRINT_D(CFG80211_DBG, "Refreshing Scan ...\n"); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 448 | refresh_scan(priv, 1, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 449 | |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 450 | if (priv->u32RcvdChCount > 0) |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 451 | PRINT_D(CFG80211_DBG, "%d Network(s) found\n", priv->u32RcvdChCount); |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 452 | else |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 453 | PRINT_D(CFG80211_DBG, "No networks found\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 454 | |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 455 | down(&(priv->hSemScanReq)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 456 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 457 | if (priv->pstrScanReq != NULL) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 458 | cfg80211_scan_done(priv->pstrScanReq, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 459 | priv->u32RcvdChCount = 0; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 460 | priv->bCfgScanning = false; |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 461 | priv->pstrScanReq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 462 | } |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 463 | up(&(priv->hSemScanReq)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 464 | |
| 465 | } |
| 466 | /*Aborting any scan operation during mac close*/ |
| 467 | else if (enuScanEvent == SCAN_EVENT_ABORTED) { |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 468 | down(&(priv->hSemScanReq)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 469 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 470 | PRINT_D(CFG80211_DBG, "Scan Aborted\n"); |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 471 | if (priv->pstrScanReq != NULL) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 472 | |
| 473 | update_scan_time(priv); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 474 | refresh_scan(priv, 1, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 475 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 476 | cfg80211_scan_done(priv->pstrScanReq, false); |
| 477 | priv->bCfgScanning = false; |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 478 | priv->pstrScanReq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 479 | } |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 480 | up(&(priv->hSemScanReq)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 481 | } |
| 482 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 483 | } |
| 484 | |
| 485 | |
| 486 | /** |
| 487 | * @brief WILC_WFI_Set_PMKSA |
| 488 | * @details Check if pmksa is cached and set it. |
| 489 | * @param[in] |
| 490 | * @return int : Return 0 on Success |
| 491 | * @author mdaftedar |
| 492 | * @date 01 MAR 2012 |
| 493 | * @version 1.0 |
| 494 | */ |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 495 | int WILC_WFI_Set_PMKSA(u8 *bssid, struct wilc_priv *priv) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 496 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 497 | u32 i; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 498 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 499 | |
| 500 | |
| 501 | for (i = 0; i < priv->pmkid_list.numpmkid; i++) { |
| 502 | |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 503 | if (!memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 504 | ETH_ALEN)) { |
| 505 | PRINT_D(CFG80211_DBG, "PMKID successful comparison"); |
| 506 | |
| 507 | /*If bssid is found, set the values*/ |
| 508 | s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list); |
| 509 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 510 | if (s32Error != 0) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 511 | PRINT_ER("Error in pmkid\n"); |
| 512 | |
| 513 | break; |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | return s32Error; |
| 518 | |
| 519 | |
| 520 | } |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 521 | int linux_wlan_set_bssid(struct net_device *wilc_netdev, u8 *pBSSID); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 522 | |
| 523 | |
| 524 | /** |
| 525 | * @brief CfgConnectResult |
| 526 | * @details |
| 527 | * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either |
| 528 | * connection response or disconnection notification. |
| 529 | * tstrConnectInfo* pstrConnectInfo: COnnection information. |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 530 | * u8 u8MacStatus: Mac Status from firmware |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 531 | * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification |
| 532 | * void* pUserVoid: Private data associated with wireless interface |
| 533 | * @return NONE |
| 534 | * @author mabubakr |
| 535 | * @date 01 MAR 2012 |
| 536 | * @version 1.0 |
| 537 | */ |
| 538 | int connecting; |
| 539 | |
| 540 | static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent, |
| 541 | tstrConnectInfo *pstrConnectInfo, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 542 | u8 u8MacStatus, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 543 | tstrDisconnectNotifInfo *pstrDisconnectNotifInfo, |
| 544 | void *pUserVoid) |
| 545 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 546 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 547 | struct net_device *dev; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 548 | tstrWILC_WFIDrv *pstrWFIDrv; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 549 | u8 NullBssid[ETH_ALEN] = {0}; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 550 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 551 | connecting = 0; |
| 552 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 553 | priv = (struct wilc_priv *)pUserVoid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 554 | dev = priv->dev; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 555 | pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 556 | |
| 557 | if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) { |
| 558 | /*Initialization*/ |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 559 | u16 u16ConnectStatus = WLAN_STATUS_SUCCESS; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 560 | |
| 561 | u16ConnectStatus = pstrConnectInfo->u16ConnectStatus; |
| 562 | |
| 563 | PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus); |
| 564 | |
| 565 | if ((u8MacStatus == MAC_DISCONNECTED) && |
| 566 | (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) { |
| 567 | /* The case here is that our station was waiting for association response frame and has just received it containing status code |
| 568 | * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */ |
| 569 | u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 570 | linux_wlan_set_bssid(priv->dev, NullBssid); |
Chaehyun Lim | 2cc4683 | 2015-08-07 09:02:01 +0900 | [diff] [blame] | 571 | memset(u8ConnectedSSID, 0, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 572 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 573 | /*Invalidate u8WLANChannel value on wlan0 disconnect*/ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 574 | if (!pstrWFIDrv->u8P2PConnect) |
| 575 | u8WLANChannel = INVALID_CHANNEL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 576 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 577 | PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d\n", u16ConnectStatus, u8MacStatus); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | if (u16ConnectStatus == WLAN_STATUS_SUCCESS) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 581 | bool bNeedScanRefresh = false; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 582 | u32 i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 583 | |
| 584 | PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0], |
| 585 | pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 586 | memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 587 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 588 | |
| 589 | for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 590 | if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 591 | pstrConnectInfo->au8bssid, ETH_ALEN) == 0) { |
| 592 | unsigned long now = jiffies; |
| 593 | |
| 594 | if (time_after(now, |
| 595 | astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 596 | bNeedScanRefresh = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | break; |
| 600 | } |
| 601 | } |
| 602 | |
Abdul Hussain | 5a66bf2 | 2015-06-16 09:44:06 +0000 | [diff] [blame] | 603 | if (bNeedScanRefresh) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 604 | /*Also, refrsh DIRECT- results if */ |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 605 | refresh_scan(priv, 1, true); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 606 | |
| 607 | } |
| 608 | |
| 609 | } |
| 610 | |
| 611 | |
Sudip Mukherjee | 52db7520 | 2015-06-02 14:28:17 +0530 | [diff] [blame] | 612 | PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 613 | |
| 614 | PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen); |
| 615 | |
| 616 | cfg80211_connect_result(dev, pstrConnectInfo->au8bssid, |
| 617 | pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen, |
| 618 | pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen, |
| 619 | u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */ |
| 620 | /* be replaced by pstrConnectInfo->u16ConnectStatus */ |
| 621 | } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) { |
| 622 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 623 | g_obtainingIP = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 624 | #endif |
| 625 | PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n", |
| 626 | pstrDisconnectNotifInfo->u16reason, priv->dev); |
| 627 | u8P2Plocalrandom = 0x01; |
| 628 | u8P2Precvrandom = 0x00; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 629 | bWilc_ie = false; |
Chaehyun Lim | 2cc4683 | 2015-08-07 09:02:01 +0900 | [diff] [blame] | 630 | memset(priv->au8AssociatedBss, 0, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 631 | linux_wlan_set_bssid(priv->dev, NullBssid); |
Chaehyun Lim | 2cc4683 | 2015-08-07 09:02:01 +0900 | [diff] [blame] | 632 | memset(u8ConnectedSSID, 0, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 633 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 634 | /*Invalidate u8WLANChannel value on wlan0 disconnect*/ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 635 | if (!pstrWFIDrv->u8P2PConnect) |
| 636 | u8WLANChannel = INVALID_CHANNEL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 637 | /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change |
| 638 | * virtual interface to station*/ |
| 639 | if ((pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) { |
| 640 | pstrDisconnectNotifInfo->u16reason = 3; |
| 641 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 642 | /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT |
| 643 | * to scan again and retry the connection*/ |
| 644 | else if ((!pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) { |
| 645 | pstrDisconnectNotifInfo->u16reason = 1; |
| 646 | } |
| 647 | cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie, |
Sudip Mukherjee | e26bb71 | 2015-06-30 13:51:51 +0530 | [diff] [blame] | 648 | pstrDisconnectNotifInfo->ie_len, false, |
| 649 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 650 | |
| 651 | } |
| 652 | |
| 653 | } |
| 654 | |
| 655 | |
| 656 | /** |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 657 | * @brief set_channel |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 658 | * @details Set channel for a given wireless interface. Some devices |
| 659 | * may support multi-channel operation (by channel hopping) so cfg80211 |
| 660 | * doesn't verify much. Note, however, that the passed netdev may be |
| 661 | * %NULL as well if the user requested changing the channel for the |
| 662 | * device itself, or for a monitor interface. |
| 663 | * @param[in] |
| 664 | * @return int : Return 0 on Success |
| 665 | * @author mdaftedar |
| 666 | * @date 01 MAR 2012 |
| 667 | * @version 1.0 |
| 668 | */ |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 669 | static int set_channel(struct wiphy *wiphy, |
| 670 | struct cfg80211_chan_def *chandef) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 671 | { |
| 672 | |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 673 | u32 channelnum = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 674 | struct wilc_priv *priv; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 675 | s32 s32Error = 0; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 676 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 677 | priv = wiphy_priv(wiphy); |
| 678 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 679 | channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq); |
| 680 | PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 681 | |
| 682 | u8CurrChannel = channelnum; |
| 683 | s32Error = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum); |
| 684 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 685 | if (s32Error != 0) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 686 | PRINT_ER("Error in setting channel %d\n", channelnum); |
| 687 | |
| 688 | return s32Error; |
| 689 | } |
| 690 | |
| 691 | /** |
Chaehyun Lim | 0e30d06 | 2015-09-14 12:24:02 +0900 | [diff] [blame] | 692 | * @brief scan |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 693 | * @details Request to do a scan. If returning zero, the scan request is given |
| 694 | * the driver, and will be valid until passed to cfg80211_scan_done(). |
| 695 | * For scan results, call cfg80211_inform_bss(); you can call this outside |
| 696 | * the scan/scan_done bracket too. |
| 697 | * @param[in] |
| 698 | * @return int : Return 0 on Success |
| 699 | * @author mabubakr |
| 700 | * @date 01 MAR 2012 |
| 701 | * @version 1.0 |
| 702 | */ |
| 703 | |
Chaehyun Lim | 0e30d06 | 2015-09-14 12:24:02 +0900 | [diff] [blame] | 704 | static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 705 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 706 | struct wilc_priv *priv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 707 | u32 i; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 708 | s32 s32Error = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 709 | u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 710 | tstrHiddenNetwork strHiddenNetwork; |
| 711 | |
| 712 | priv = wiphy_priv(wiphy); |
| 713 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 714 | priv->pstrScanReq = request; |
| 715 | |
| 716 | priv->u32RcvdChCount = 0; |
| 717 | |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 718 | host_int_set_wfi_drv_handler(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 719 | |
| 720 | |
| 721 | reset_shadow_found(priv); |
| 722 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 723 | priv->bCfgScanning = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 724 | if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */ |
| 725 | /* max_scan_ssids */ |
| 726 | for (i = 0; i < request->n_channels; i++) { |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 727 | au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 728 | PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]); |
| 729 | } |
| 730 | |
| 731 | PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels); |
Sudip Mukherjee | 52db7520 | 2015-06-02 14:28:17 +0530 | [diff] [blame] | 732 | PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 733 | |
| 734 | PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids); |
| 735 | |
| 736 | if (request->n_ssids >= 1) { |
| 737 | |
| 738 | |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 739 | strHiddenNetwork.pstrHiddenNetworkInfo = kmalloc(request->n_ssids * sizeof(tstrHiddenNetwork), GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 740 | strHiddenNetwork.u8ssidnum = request->n_ssids; |
| 741 | |
| 742 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 743 | for (i = 0; i < request->n_ssids; i++) { |
| 744 | |
| 745 | if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 746 | strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 747 | memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 748 | strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len; |
| 749 | } else { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 750 | PRINT_D(CFG80211_DBG, "Received one NULL SSID\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 751 | strHiddenNetwork.u8ssidnum -= 1; |
| 752 | } |
| 753 | } |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 754 | PRINT_D(CFG80211_DBG, "Trigger Scan Request\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 755 | s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN, |
| 756 | au8ScanChanList, request->n_channels, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 757 | (const u8 *)request->ie, request->ie_len, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 758 | CfgScanResult, (void *)priv, &strHiddenNetwork); |
| 759 | } else { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 760 | PRINT_D(CFG80211_DBG, "Trigger Scan Request\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 761 | s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN, |
| 762 | au8ScanChanList, request->n_channels, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 763 | (const u8 *)request->ie, request->ie_len, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 764 | CfgScanResult, (void *)priv, NULL); |
| 765 | } |
| 766 | |
| 767 | } else { |
| 768 | PRINT_ER("Requested num of scanned channels is greater than the max, supported" |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 769 | " channels\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 770 | } |
| 771 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 772 | if (s32Error != 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 773 | s32Error = -EBUSY; |
| 774 | PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error); |
| 775 | } |
| 776 | |
| 777 | return s32Error; |
| 778 | } |
| 779 | |
| 780 | /** |
Chaehyun Lim | 4ffbcdb | 2015-09-14 12:24:03 +0900 | [diff] [blame] | 781 | * @brief connect |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 782 | * @details Connect to the ESS with the specified parameters. When connected, |
| 783 | * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS. |
| 784 | * If the connection fails for some reason, call cfg80211_connect_result() |
| 785 | * with the status from the AP. |
| 786 | * @param[in] |
| 787 | * @return int : Return 0 on Success |
| 788 | * @author mabubakr |
| 789 | * @date 01 MAR 2012 |
| 790 | * @version 1.0 |
| 791 | */ |
Chaehyun Lim | 4ffbcdb | 2015-09-14 12:24:03 +0900 | [diff] [blame] | 792 | static int connect(struct wiphy *wiphy, struct net_device *dev, |
| 793 | struct cfg80211_connect_params *sme) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 794 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 795 | s32 s32Error = 0; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 796 | u32 i; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 797 | u8 u8security = NO_ENCRYPT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 798 | AUTHTYPE_T tenuAuth_type = ANY; |
Dean Lee | 576917a | 2015-06-15 11:58:57 +0900 | [diff] [blame] | 799 | char *pcgroup_encrypt_val = NULL; |
| 800 | char *pccipher_group = NULL; |
| 801 | char *pcwpa_version = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 802 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 803 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 804 | tstrWILC_WFIDrv *pstrWFIDrv; |
| 805 | tstrNetworkInfo *pstrNetworkInfo = NULL; |
| 806 | |
| 807 | |
| 808 | connecting = 1; |
| 809 | priv = wiphy_priv(wiphy); |
| 810 | pstrWFIDrv = (tstrWILC_WFIDrv *)(priv->hWILCWFIDrv); |
| 811 | |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 812 | host_int_set_wfi_drv_handler(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 813 | |
Johnny Kim | 8a14330 | 2015-06-10 17:06:46 +0900 | [diff] [blame] | 814 | PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme->ssid, dev, priv->hWILCWFIDrv); |
Chaehyun Lim | 3f88289 | 2015-08-10 11:33:17 +0900 | [diff] [blame] | 815 | if (!(strncmp(sme->ssid, "DIRECT-", 7))) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 816 | PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n"); |
| 817 | pstrWFIDrv->u8P2PConnect = 1; |
| 818 | } else |
| 819 | pstrWFIDrv->u8P2PConnect = 0; |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 820 | PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d\n", sme->ssid, sme->auth_type); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 821 | |
| 822 | for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) { |
| 823 | if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) && |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 824 | memcmp(astrLastScannedNtwrksShadow[i].au8ssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 825 | sme->ssid, |
| 826 | sme->ssid_len) == 0) { |
| 827 | PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid); |
| 828 | if (sme->bssid == NULL) { |
| 829 | /* BSSID is not passed from the user, so decision of matching |
| 830 | * is done by SSID only */ |
| 831 | PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n"); |
| 832 | break; |
| 833 | } else { |
| 834 | /* BSSID is also passed from the user, so decision of matching |
| 835 | * should consider also this passed BSSID */ |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 836 | if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 837 | sme->bssid, |
| 838 | ETH_ALEN) == 0) { |
| 839 | PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n"); |
| 840 | break; |
| 841 | } |
| 842 | } |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | if (i < u32LastScannedNtwrksCountShadow) { |
| 847 | PRINT_D(CFG80211_DBG, "Required bss is in scan results\n"); |
| 848 | |
| 849 | pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]); |
| 850 | |
| 851 | PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n", |
| 852 | pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1], |
| 853 | pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3], |
| 854 | pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]); |
| 855 | } else { |
| 856 | s32Error = -ENOENT; |
| 857 | if (u32LastScannedNtwrksCountShadow == 0) |
| 858 | PRINT_D(CFG80211_DBG, "No Scan results yet\n"); |
| 859 | else |
| 860 | PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error); |
| 861 | |
| 862 | goto done; |
| 863 | } |
| 864 | |
| 865 | priv->WILC_WFI_wep_default = 0; |
Chaehyun Lim | 2cc4683 | 2015-08-07 09:02:01 +0900 | [diff] [blame] | 866 | memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key)); |
| 867 | memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 868 | |
| 869 | PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions); |
| 870 | PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group); |
| 871 | |
| 872 | PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise); |
| 873 | |
| 874 | if (INFO) { |
| 875 | for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) |
| 876 | PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]); |
| 877 | } |
| 878 | |
| 879 | if (sme->crypto.cipher_group != NO_ENCRYPT) { |
| 880 | /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2} |
| 881 | * we will add to it the pairwise cipher suite(s) */ |
| 882 | pcwpa_version = "Default"; |
| 883 | PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 884 | if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 885 | u8security = ENCRYPT_ENABLED | WEP; |
| 886 | pcgroup_encrypt_val = "WEP40"; |
| 887 | pccipher_group = "WLAN_CIPHER_SUITE_WEP40"; |
| 888 | PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx); |
| 889 | |
| 890 | if (INFO) { |
| 891 | for (i = 0; i < sme->key_len; i++) |
| 892 | PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]); |
| 893 | } |
| 894 | priv->WILC_WFI_wep_default = sme->key_idx; |
| 895 | priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 896 | memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 897 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 898 | g_key_wep_params.key_len = sme->key_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 899 | g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 900 | memcpy(g_key_wep_params.key, sme->key, sme->key_len); |
| 901 | g_key_wep_params.key_idx = sme->key_idx; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 902 | g_wep_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 903 | |
| 904 | host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx); |
| 905 | host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx); |
| 906 | } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 907 | u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED; |
| 908 | pcgroup_encrypt_val = "WEP104"; |
| 909 | pccipher_group = "WLAN_CIPHER_SUITE_WEP104"; |
| 910 | |
| 911 | priv->WILC_WFI_wep_default = sme->key_idx; |
| 912 | priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 913 | memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 914 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 915 | g_key_wep_params.key_len = sme->key_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 916 | g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 917 | memcpy(g_key_wep_params.key, sme->key, sme->key_len); |
| 918 | g_key_wep_params.key_idx = sme->key_idx; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 919 | g_wep_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 920 | |
| 921 | host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx); |
| 922 | host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx); |
| 923 | } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 924 | if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 925 | u8security = ENCRYPT_ENABLED | WPA2 | TKIP; |
| 926 | pcgroup_encrypt_val = "WPA2_TKIP"; |
| 927 | pccipher_group = "TKIP"; |
| 928 | } else { /* TODO: mostafa: here we assume that any other encryption type is AES */ |
| 929 | /* tenuSecurity_t = WPA2_AES; */ |
| 930 | u8security = ENCRYPT_ENABLED | WPA2 | AES; |
| 931 | pcgroup_encrypt_val = "WPA2_AES"; |
| 932 | pccipher_group = "AES"; |
| 933 | } |
| 934 | pcwpa_version = "WPA_VERSION_2"; |
| 935 | } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) { |
| 936 | if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 937 | u8security = ENCRYPT_ENABLED | WPA | TKIP; |
| 938 | pcgroup_encrypt_val = "WPA_TKIP"; |
| 939 | pccipher_group = "TKIP"; |
| 940 | } else { /* TODO: mostafa: here we assume that any other encryption type is AES */ |
| 941 | /* tenuSecurity_t = WPA_AES; */ |
| 942 | u8security = ENCRYPT_ENABLED | WPA | AES; |
| 943 | pcgroup_encrypt_val = "WPA_AES"; |
| 944 | pccipher_group = "AES"; |
| 945 | |
| 946 | } |
| 947 | pcwpa_version = "WPA_VERSION_1"; |
| 948 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 949 | } else { |
| 950 | s32Error = -ENOTSUPP; |
| 951 | PRINT_ER("Not supported cipher: Error(%d)\n", s32Error); |
| 952 | |
| 953 | goto done; |
| 954 | } |
| 955 | |
| 956 | } |
| 957 | |
| 958 | /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will |
| 959 | * add to it the pairwise cipher suite(s) */ |
| 960 | if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) |
| 961 | || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) { |
| 962 | for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) { |
| 963 | if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) { |
| 964 | u8security = u8security | TKIP; |
| 965 | } else { /* TODO: mostafa: here we assume that any other encryption type is AES */ |
| 966 | u8security = u8security | AES; |
| 967 | } |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group); |
| 972 | |
| 973 | PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type); |
| 974 | switch (sme->auth_type) { |
| 975 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
| 976 | PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n"); |
| 977 | tenuAuth_type = OPEN_SYSTEM; |
| 978 | break; |
| 979 | |
| 980 | case NL80211_AUTHTYPE_SHARED_KEY: |
| 981 | tenuAuth_type = SHARED_KEY; |
| 982 | PRINT_D(CFG80211_DBG, "In SHARED KEY\n"); |
| 983 | break; |
| 984 | |
| 985 | default: |
| 986 | PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type); |
| 987 | } |
| 988 | |
| 989 | |
| 990 | /* ai: key_mgmt: enterprise case */ |
| 991 | if (sme->crypto.n_akm_suites) { |
| 992 | switch (sme->crypto.akm_suites[0]) { |
| 993 | case WLAN_AKM_SUITE_8021X: |
| 994 | tenuAuth_type = IEEE8021; |
| 995 | break; |
| 996 | |
| 997 | default: |
| 998 | break; |
| 999 | } |
| 1000 | } |
| 1001 | |
| 1002 | |
| 1003 | PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel); |
| 1004 | |
| 1005 | PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n", |
| 1006 | pcgroup_encrypt_val, pccipher_group, pcwpa_version); |
| 1007 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1008 | u8CurrChannel = pstrNetworkInfo->u8channel; |
| 1009 | |
| 1010 | if (!pstrWFIDrv->u8P2PConnect) { |
| 1011 | u8WLANChannel = pstrNetworkInfo->u8channel; |
| 1012 | } |
| 1013 | |
| 1014 | linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid); |
| 1015 | |
| 1016 | s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid, |
| 1017 | sme->ssid_len, sme->ie, sme->ie_len, |
| 1018 | CfgConnectResult, (void *)priv, u8security, |
| 1019 | tenuAuth_type, pstrNetworkInfo->u8channel, |
| 1020 | pstrNetworkInfo->pJoinParams); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1021 | if (s32Error != 0) { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 1022 | PRINT_ER("host_int_set_join_req(): Error(%d)\n", s32Error); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1023 | s32Error = -ENOENT; |
| 1024 | goto done; |
| 1025 | } |
| 1026 | |
| 1027 | done: |
| 1028 | |
| 1029 | return s32Error; |
| 1030 | } |
| 1031 | |
| 1032 | |
| 1033 | /** |
Chaehyun Lim | b027cde | 2015-09-14 12:24:04 +0900 | [diff] [blame] | 1034 | * @brief disconnect |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1035 | * @details Disconnect from the BSS/ESS. |
| 1036 | * @param[in] |
| 1037 | * @return int : Return 0 on Success |
| 1038 | * @author mdaftedar |
| 1039 | * @date 01 MAR 2012 |
| 1040 | * @version 1.0 |
| 1041 | */ |
Chaehyun Lim | b027cde | 2015-09-14 12:24:04 +0900 | [diff] [blame] | 1042 | static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1043 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1044 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1045 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1046 | tstrWILC_WFIDrv *pstrWFIDrv; |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 1047 | u8 NullBssid[ETH_ALEN] = {0}; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1048 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1049 | connecting = 0; |
| 1050 | priv = wiphy_priv(wiphy); |
| 1051 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1052 | /*Invalidate u8WLANChannel value on wlan0 disconnect*/ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1053 | pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; |
| 1054 | if (!pstrWFIDrv->u8P2PConnect) |
| 1055 | u8WLANChannel = INVALID_CHANNEL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1056 | linux_wlan_set_bssid(priv->dev, NullBssid); |
| 1057 | |
| 1058 | PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code); |
| 1059 | |
| 1060 | u8P2Plocalrandom = 0x01; |
| 1061 | u8P2Precvrandom = 0x00; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1062 | bWilc_ie = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1063 | pstrWFIDrv->u64P2p_MgmtTimeout = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1064 | |
| 1065 | s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1066 | if (s32Error != 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1067 | PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error); |
| 1068 | s32Error = -EINVAL; |
| 1069 | } |
| 1070 | |
| 1071 | return s32Error; |
| 1072 | } |
| 1073 | |
| 1074 | /** |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 1075 | * @brief add_key |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1076 | * @details Add a key with the given parameters. @mac_addr will be %NULL |
| 1077 | * when adding a group key. |
| 1078 | * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key |
| 1079 | * @return int : Return 0 on Success |
| 1080 | * @author mdaftedar |
| 1081 | * @date 01 MAR 2012 |
| 1082 | * @version 1.0 |
| 1083 | */ |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 1084 | static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, |
| 1085 | bool pairwise, |
| 1086 | const u8 *mac_addr, struct key_params *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1087 | |
| 1088 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1089 | s32 s32Error = 0, KeyLen = params->key_len; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1090 | u32 i; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1091 | struct wilc_priv *priv; |
Arnd Bergmann | 057d1e9 | 2015-06-01 21:06:44 +0200 | [diff] [blame] | 1092 | const u8 *pu8RxMic = NULL; |
| 1093 | const u8 *pu8TxMic = NULL; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1094 | u8 u8mode = NO_ENCRYPT; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1095 | u8 u8gmode = NO_ENCRYPT; |
| 1096 | u8 u8pmode = NO_ENCRYPT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1097 | AUTHTYPE_T tenuAuth_type = ANY; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1098 | |
| 1099 | priv = wiphy_priv(wiphy); |
| 1100 | |
| 1101 | PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher); |
| 1102 | |
Johnny Kim | 8a14330 | 2015-06-10 17:06:46 +0900 | [diff] [blame] | 1103 | PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1104 | |
| 1105 | PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0], |
| 1106 | params->key[1], |
| 1107 | params->key[2]); |
| 1108 | |
| 1109 | |
| 1110 | switch (params->cipher) { |
| 1111 | case WLAN_CIPHER_SUITE_WEP40: |
| 1112 | case WLAN_CIPHER_SUITE_WEP104: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1113 | if (priv->wdev->iftype == NL80211_IFTYPE_AP) { |
| 1114 | |
| 1115 | priv->WILC_WFI_wep_default = key_index; |
| 1116 | priv->WILC_WFI_wep_key_len[key_index] = params->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1117 | memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1118 | |
| 1119 | PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index); |
| 1120 | PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len); |
| 1121 | |
| 1122 | for (i = 0; i < params->key_len; i++) |
| 1123 | PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]); |
| 1124 | |
| 1125 | tenuAuth_type = OPEN_SYSTEM; |
| 1126 | |
| 1127 | if (params->cipher == WLAN_CIPHER_SUITE_WEP40) |
| 1128 | u8mode = ENCRYPT_ENABLED | WEP; |
| 1129 | else |
| 1130 | u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED; |
| 1131 | |
| 1132 | host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type); |
| 1133 | break; |
| 1134 | } |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 1135 | if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1136 | priv->WILC_WFI_wep_default = key_index; |
| 1137 | priv->WILC_WFI_wep_key_len[key_index] = params->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1138 | memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1139 | |
| 1140 | PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index); |
| 1141 | PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len); |
| 1142 | if (INFO) { |
| 1143 | for (i = 0; i < params->key_len; i++) |
| 1144 | PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]); |
| 1145 | } |
| 1146 | host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index); |
| 1147 | } |
| 1148 | |
| 1149 | break; |
| 1150 | |
| 1151 | case WLAN_CIPHER_SUITE_TKIP: |
| 1152 | case WLAN_CIPHER_SUITE_CCMP: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1153 | if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) { |
| 1154 | |
| 1155 | if (priv->wilc_gtk[key_index] == NULL) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1156 | priv->wilc_gtk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL); |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 1157 | priv->wilc_gtk[key_index]->key = NULL; |
| 1158 | priv->wilc_gtk[key_index]->seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1159 | |
| 1160 | } |
| 1161 | if (priv->wilc_ptk[key_index] == NULL) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1162 | priv->wilc_ptk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL); |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 1163 | priv->wilc_ptk[key_index]->key = NULL; |
| 1164 | priv->wilc_ptk[key_index]->seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1165 | } |
| 1166 | |
| 1167 | |
| 1168 | |
Daniel Machon | 1913221 | 2015-08-05 08:18:31 +0200 | [diff] [blame] | 1169 | if (!pairwise) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1170 | if (params->cipher == WLAN_CIPHER_SUITE_TKIP) |
| 1171 | u8gmode = ENCRYPT_ENABLED | WPA | TKIP; |
| 1172 | else |
| 1173 | u8gmode = ENCRYPT_ENABLED | WPA2 | AES; |
| 1174 | |
| 1175 | priv->wilc_groupkey = u8gmode; |
| 1176 | |
| 1177 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
| 1178 | |
| 1179 | pu8TxMic = params->key + 24; |
| 1180 | pu8RxMic = params->key + 16; |
| 1181 | KeyLen = params->key_len - 16; |
| 1182 | } |
| 1183 | /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/ |
| 1184 | if (priv->wilc_gtk[key_index]->key) |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1185 | kfree(priv->wilc_gtk[key_index]->key); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1186 | |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1187 | priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1188 | memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1189 | |
| 1190 | /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/ |
| 1191 | if (priv->wilc_gtk[key_index]->seq) |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1192 | kfree(priv->wilc_gtk[key_index]->seq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1193 | |
| 1194 | if ((params->seq_len) > 0) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1195 | priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1196 | memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1197 | } |
| 1198 | |
| 1199 | priv->wilc_gtk[key_index]->cipher = params->cipher; |
| 1200 | priv->wilc_gtk[key_index]->key_len = params->key_len; |
| 1201 | priv->wilc_gtk[key_index]->seq_len = params->seq_len; |
| 1202 | |
| 1203 | if (INFO) { |
| 1204 | for (i = 0; i < params->key_len; i++) |
| 1205 | PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]); |
| 1206 | for (i = 0; i < params->seq_len; i++) |
| 1207 | PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]); |
| 1208 | } |
| 1209 | |
| 1210 | |
| 1211 | host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen, |
| 1212 | key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode); |
| 1213 | |
| 1214 | } else { |
| 1215 | PRINT_INFO(CFG80211_DBG, "STA Address: %x%x%x%x%x\n", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4]); |
| 1216 | |
| 1217 | if (params->cipher == WLAN_CIPHER_SUITE_TKIP) |
| 1218 | u8pmode = ENCRYPT_ENABLED | WPA | TKIP; |
| 1219 | else |
| 1220 | u8pmode = priv->wilc_groupkey | AES; |
| 1221 | |
| 1222 | |
| 1223 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
| 1224 | |
| 1225 | pu8TxMic = params->key + 24; |
| 1226 | pu8RxMic = params->key + 16; |
| 1227 | KeyLen = params->key_len - 16; |
| 1228 | } |
| 1229 | |
| 1230 | if (priv->wilc_ptk[key_index]->key) |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1231 | kfree(priv->wilc_ptk[key_index]->key); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1232 | |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1233 | priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1234 | |
| 1235 | if (priv->wilc_ptk[key_index]->seq) |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1236 | kfree(priv->wilc_ptk[key_index]->seq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1237 | |
| 1238 | if ((params->seq_len) > 0) |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1239 | priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1240 | |
| 1241 | if (INFO) { |
| 1242 | for (i = 0; i < params->key_len; i++) |
| 1243 | PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]); |
| 1244 | |
| 1245 | for (i = 0; i < params->seq_len; i++) |
| 1246 | PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]); |
| 1247 | } |
| 1248 | |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1249 | memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1250 | |
| 1251 | if ((params->seq_len) > 0) |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1252 | memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1253 | |
| 1254 | priv->wilc_ptk[key_index]->cipher = params->cipher; |
| 1255 | priv->wilc_ptk[key_index]->key_len = params->key_len; |
| 1256 | priv->wilc_ptk[key_index]->seq_len = params->seq_len; |
| 1257 | |
| 1258 | host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr, |
| 1259 | pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index); |
| 1260 | } |
| 1261 | break; |
| 1262 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1263 | |
| 1264 | { |
| 1265 | u8mode = 0; |
Daniel Machon | 1913221 | 2015-08-05 08:18:31 +0200 | [diff] [blame] | 1266 | if (!pairwise) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1267 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
| 1268 | /* swap the tx mic by rx mic */ |
| 1269 | pu8RxMic = params->key + 24; |
| 1270 | pu8TxMic = params->key + 16; |
| 1271 | KeyLen = params->key_len - 16; |
| 1272 | } |
| 1273 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1274 | /*save keys only on interface 0 (wifi interface)*/ |
| 1275 | if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) { |
| 1276 | g_add_gtk_key_params.key_idx = key_index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1277 | g_add_gtk_key_params.pairwise = pairwise; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1278 | if (!mac_addr) { |
| 1279 | g_add_gtk_key_params.mac_addr = NULL; |
| 1280 | } else { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1281 | g_add_gtk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1282 | memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN); |
| 1283 | } |
| 1284 | g_key_gtk_params.key_len = params->key_len; |
| 1285 | g_key_gtk_params.seq_len = params->seq_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1286 | g_key_gtk_params.key = kmalloc(params->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1287 | memcpy(g_key_gtk_params.key, params->key, params->key_len); |
| 1288 | if (params->seq_len > 0) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1289 | g_key_gtk_params.seq = kmalloc(params->seq_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1290 | memcpy(g_key_gtk_params.seq, params->seq, params->seq_len); |
| 1291 | } |
| 1292 | g_key_gtk_params.cipher = params->cipher; |
| 1293 | |
| 1294 | PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0], |
| 1295 | g_key_gtk_params.key[1], |
| 1296 | g_key_gtk_params.key[2]); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1297 | g_gtk_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1298 | } |
| 1299 | |
| 1300 | host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen, |
| 1301 | key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1302 | } else { |
| 1303 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
| 1304 | /* swap the tx mic by rx mic */ |
| 1305 | pu8RxMic = params->key + 24; |
| 1306 | pu8TxMic = params->key + 16; |
| 1307 | KeyLen = params->key_len - 16; |
| 1308 | } |
| 1309 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1310 | /*save keys only on interface 0 (wifi interface)*/ |
| 1311 | if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) { |
| 1312 | g_add_ptk_key_params.key_idx = key_index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1313 | g_add_ptk_key_params.pairwise = pairwise; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1314 | if (!mac_addr) { |
| 1315 | g_add_ptk_key_params.mac_addr = NULL; |
| 1316 | } else { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1317 | g_add_ptk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1318 | memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN); |
| 1319 | } |
| 1320 | g_key_ptk_params.key_len = params->key_len; |
| 1321 | g_key_ptk_params.seq_len = params->seq_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1322 | g_key_ptk_params.key = kmalloc(params->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1323 | memcpy(g_key_ptk_params.key, params->key, params->key_len); |
| 1324 | if (params->seq_len > 0) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1325 | g_key_ptk_params.seq = kmalloc(params->seq_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1326 | memcpy(g_key_ptk_params.seq, params->seq, params->seq_len); |
| 1327 | } |
| 1328 | g_key_ptk_params.cipher = params->cipher; |
| 1329 | |
| 1330 | PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0], |
| 1331 | g_key_ptk_params.key[1], |
| 1332 | g_key_ptk_params.key[2]); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1333 | g_ptk_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1334 | } |
| 1335 | |
| 1336 | host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr, |
| 1337 | pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index); |
| 1338 | PRINT_D(CFG80211_DBG, "Adding pairwise key\n"); |
| 1339 | if (INFO) { |
| 1340 | for (i = 0; i < params->key_len; i++) |
| 1341 | PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]); |
| 1342 | } |
| 1343 | } |
| 1344 | } |
| 1345 | break; |
| 1346 | |
| 1347 | default: |
| 1348 | PRINT_ER("Not supported cipher: Error(%d)\n", s32Error); |
| 1349 | s32Error = -ENOTSUPP; |
| 1350 | |
| 1351 | } |
| 1352 | |
| 1353 | return s32Error; |
| 1354 | } |
| 1355 | |
| 1356 | /** |
Chaehyun Lim | 3044ba7 | 2015-09-14 12:24:06 +0900 | [diff] [blame] | 1357 | * @brief del_key |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1358 | * @details Remove a key given the @mac_addr (%NULL for a group key) |
| 1359 | * and @key_index, return -ENOENT if the key doesn't exist. |
| 1360 | * @param[in] |
| 1361 | * @return int : Return 0 on Success |
| 1362 | * @author mdaftedar |
| 1363 | * @date 01 MAR 2012 |
| 1364 | * @version 1.0 |
| 1365 | */ |
Chaehyun Lim | 3044ba7 | 2015-09-14 12:24:06 +0900 | [diff] [blame] | 1366 | static int del_key(struct wiphy *wiphy, struct net_device *netdev, |
| 1367 | u8 key_index, |
| 1368 | bool pairwise, |
| 1369 | const u8 *mac_addr) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1370 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1371 | struct wilc_priv *priv; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1372 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1373 | |
| 1374 | priv = wiphy_priv(wiphy); |
| 1375 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1376 | /*delete saved keys, if any*/ |
| 1377 | if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1378 | g_ptk_keys_saved = false; |
| 1379 | g_gtk_keys_saved = false; |
| 1380 | g_wep_keys_saved = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1381 | |
| 1382 | /*Delete saved WEP keys params, if any*/ |
| 1383 | if (g_key_wep_params.key != NULL) { |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1384 | kfree(g_key_wep_params.key); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1385 | g_key_wep_params.key = NULL; |
| 1386 | } |
| 1387 | |
| 1388 | /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/ |
| 1389 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1390 | if ((priv->wilc_gtk[key_index]) != NULL) { |
| 1391 | |
| 1392 | if (priv->wilc_gtk[key_index]->key != NULL) { |
| 1393 | |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1394 | kfree(priv->wilc_gtk[key_index]->key); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1395 | priv->wilc_gtk[key_index]->key = NULL; |
| 1396 | } |
| 1397 | if (priv->wilc_gtk[key_index]->seq) { |
| 1398 | |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1399 | kfree(priv->wilc_gtk[key_index]->seq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1400 | priv->wilc_gtk[key_index]->seq = NULL; |
| 1401 | } |
| 1402 | |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1403 | kfree(priv->wilc_gtk[key_index]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1404 | priv->wilc_gtk[key_index] = NULL; |
| 1405 | |
| 1406 | } |
| 1407 | |
| 1408 | if ((priv->wilc_ptk[key_index]) != NULL) { |
| 1409 | |
| 1410 | if (priv->wilc_ptk[key_index]->key) { |
| 1411 | |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1412 | kfree(priv->wilc_ptk[key_index]->key); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1413 | priv->wilc_ptk[key_index]->key = NULL; |
| 1414 | } |
| 1415 | if (priv->wilc_ptk[key_index]->seq) { |
| 1416 | |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1417 | kfree(priv->wilc_ptk[key_index]->seq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1418 | priv->wilc_ptk[key_index]->seq = NULL; |
| 1419 | } |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1420 | kfree(priv->wilc_ptk[key_index]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1421 | priv->wilc_ptk[key_index] = NULL; |
| 1422 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1423 | |
| 1424 | /*Delete saved PTK and GTK keys params, if any*/ |
| 1425 | if (g_key_ptk_params.key != NULL) { |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1426 | kfree(g_key_ptk_params.key); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1427 | g_key_ptk_params.key = NULL; |
| 1428 | } |
| 1429 | if (g_key_ptk_params.seq != NULL) { |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1430 | kfree(g_key_ptk_params.seq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1431 | g_key_ptk_params.seq = NULL; |
| 1432 | } |
| 1433 | |
| 1434 | if (g_key_gtk_params.key != NULL) { |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1435 | kfree(g_key_gtk_params.key); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1436 | g_key_gtk_params.key = NULL; |
| 1437 | } |
| 1438 | if (g_key_gtk_params.seq != NULL) { |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1439 | kfree(g_key_gtk_params.seq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1440 | g_key_gtk_params.seq = NULL; |
| 1441 | } |
| 1442 | |
| 1443 | /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/ |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1444 | Set_machw_change_vir_if(false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1445 | } |
| 1446 | |
| 1447 | if (key_index >= 0 && key_index <= 3) { |
Chaehyun Lim | 2cc4683 | 2015-08-07 09:02:01 +0900 | [diff] [blame] | 1448 | memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1449 | priv->WILC_WFI_wep_key_len[key_index] = 0; |
| 1450 | |
| 1451 | PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index); |
| 1452 | host_int_remove_wep_key(priv->hWILCWFIDrv, key_index); |
| 1453 | } else { |
| 1454 | PRINT_D(CFG80211_DBG, "Removing all installed keys\n"); |
| 1455 | host_int_remove_key(priv->hWILCWFIDrv, mac_addr); |
| 1456 | } |
| 1457 | |
| 1458 | return s32Error; |
| 1459 | } |
| 1460 | |
| 1461 | /** |
Chaehyun Lim | f4893df | 2015-09-14 12:24:07 +0900 | [diff] [blame] | 1462 | * @brief get_key |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1463 | * @details Get information about the key with the given parameters. |
| 1464 | * @mac_addr will be %NULL when requesting information for a group |
| 1465 | * key. All pointers given to the @callback function need not be valid |
| 1466 | * after it returns. This function should return an error if it is |
| 1467 | * not possible to retrieve the key, -ENOENT if it doesn't exist. |
| 1468 | * @param[in] |
| 1469 | * @return int : Return 0 on Success |
| 1470 | * @author mdaftedar |
| 1471 | * @date 01 MAR 2012 |
| 1472 | * @version 1.0 |
| 1473 | */ |
Chaehyun Lim | f4893df | 2015-09-14 12:24:07 +0900 | [diff] [blame] | 1474 | static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, |
| 1475 | bool pairwise, |
| 1476 | const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1477 | { |
| 1478 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1479 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1480 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1481 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1482 | struct key_params key_params; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1483 | u32 i; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1484 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1485 | priv = wiphy_priv(wiphy); |
| 1486 | |
| 1487 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1488 | if (!pairwise) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1489 | { |
| 1490 | PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index); |
| 1491 | |
| 1492 | key_params.key = priv->wilc_gtk[key_index]->key; |
| 1493 | key_params.cipher = priv->wilc_gtk[key_index]->cipher; |
| 1494 | key_params.key_len = priv->wilc_gtk[key_index]->key_len; |
| 1495 | key_params.seq = priv->wilc_gtk[key_index]->seq; |
| 1496 | key_params.seq_len = priv->wilc_gtk[key_index]->seq_len; |
| 1497 | if (INFO) { |
| 1498 | for (i = 0; i < key_params.key_len; i++) |
| 1499 | PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]); |
| 1500 | } |
| 1501 | } else { |
| 1502 | PRINT_D(CFG80211_DBG, "Getting pairwise key\n"); |
| 1503 | |
| 1504 | key_params.key = priv->wilc_ptk[key_index]->key; |
| 1505 | key_params.cipher = priv->wilc_ptk[key_index]->cipher; |
| 1506 | key_params.key_len = priv->wilc_ptk[key_index]->key_len; |
| 1507 | key_params.seq = priv->wilc_ptk[key_index]->seq; |
| 1508 | key_params.seq_len = priv->wilc_ptk[key_index]->seq_len; |
| 1509 | } |
| 1510 | |
| 1511 | callback(cookie, &key_params); |
| 1512 | |
| 1513 | return s32Error; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */ |
| 1514 | } |
| 1515 | |
| 1516 | /** |
Chaehyun Lim | 0f5b8ca | 2015-09-14 12:24:08 +0900 | [diff] [blame] | 1517 | * @brief set_default_key |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1518 | * @details Set the default management frame key on an interface |
| 1519 | * @param[in] |
| 1520 | * @return int : Return 0 on Success. |
| 1521 | * @author mdaftedar |
| 1522 | * @date 01 MAR 2012 |
| 1523 | * @version 1.0 |
| 1524 | */ |
Chaehyun Lim | 0f5b8ca | 2015-09-14 12:24:08 +0900 | [diff] [blame] | 1525 | static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, |
| 1526 | bool unicast, bool multicast) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1527 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1528 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1529 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1530 | |
| 1531 | |
| 1532 | priv = wiphy_priv(wiphy); |
| 1533 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 1534 | PRINT_D(CFG80211_DBG, "Setting default key with idx = %d\n", key_index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1535 | |
| 1536 | if (key_index != priv->WILC_WFI_wep_default) { |
| 1537 | |
| 1538 | host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index); |
| 1539 | } |
| 1540 | |
| 1541 | return s32Error; |
| 1542 | } |
| 1543 | |
| 1544 | /** |
| 1545 | * @brief WILC_WFI_dump_survey |
| 1546 | * @details Get site survey information |
| 1547 | * @param[in] |
| 1548 | * @return int : Return 0 on Success. |
| 1549 | * @author mdaftedar |
| 1550 | * @date 01 MAR 2012 |
| 1551 | * @version 1.0 |
| 1552 | */ |
| 1553 | static int WILC_WFI_dump_survey(struct wiphy *wiphy, struct net_device *netdev, |
| 1554 | int idx, struct survey_info *info) |
| 1555 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1556 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1557 | |
| 1558 | |
| 1559 | if (idx != 0) { |
| 1560 | s32Error = -ENOENT; |
| 1561 | PRINT_ER("Error Idx value doesn't equal zero: Error(%d)\n", s32Error); |
| 1562 | |
| 1563 | } |
| 1564 | |
| 1565 | return s32Error; |
| 1566 | } |
| 1567 | |
| 1568 | |
| 1569 | /** |
Chaehyun Lim | f06f562 | 2015-09-14 12:24:18 +0900 | [diff] [blame] | 1570 | * @brief get_station |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1571 | * @details Get station information for the station identified by @mac |
| 1572 | * @param[in] NONE |
| 1573 | * @return int : Return 0 on Success. |
| 1574 | * @author mdaftedar |
| 1575 | * @date 01 MAR 2012 |
| 1576 | * @version 1.0 |
| 1577 | */ |
| 1578 | |
Chaehyun Lim | f06f562 | 2015-09-14 12:24:18 +0900 | [diff] [blame] | 1579 | static int get_station(struct wiphy *wiphy, struct net_device *dev, |
| 1580 | const u8 *mac, struct station_info *sinfo) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1581 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1582 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1583 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1584 | perInterface_wlan_t *nic; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1585 | u32 i = 0; |
| 1586 | u32 associatedsta = 0; |
| 1587 | u32 inactive_time = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1588 | priv = wiphy_priv(wiphy); |
| 1589 | nic = netdev_priv(dev); |
| 1590 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1591 | if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { |
| 1592 | PRINT_D(HOSTAPD_DBG, "Getting station parameters\n"); |
| 1593 | |
| 1594 | PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]); |
| 1595 | |
| 1596 | for (i = 0; i < NUM_STA_ASSOCIATED; i++) { |
| 1597 | |
| 1598 | if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) { |
| 1599 | associatedsta = i; |
| 1600 | break; |
| 1601 | } |
| 1602 | |
| 1603 | } |
| 1604 | |
| 1605 | if (associatedsta == -1) { |
| 1606 | s32Error = -ENOENT; |
| 1607 | PRINT_ER("Station required is not associated : Error(%d)\n", s32Error); |
| 1608 | |
| 1609 | return s32Error; |
| 1610 | } |
| 1611 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1612 | sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1613 | |
| 1614 | host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time)); |
| 1615 | sinfo->inactive_time = 1000 * inactive_time; |
| 1616 | PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time); |
| 1617 | |
| 1618 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1619 | |
| 1620 | if (nic->iftype == STATION_MODE) { |
| 1621 | tstrStatistics strStatistics; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1622 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1623 | host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics); |
| 1624 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1625 | sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) | |
Chandra S Gorentla | 6212990 | 2015-08-05 22:11:57 +0530 | [diff] [blame] | 1626 | BIT(NL80211_STA_INFO_RX_PACKETS) | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1627 | BIT(NL80211_STA_INFO_TX_PACKETS) | |
| 1628 | BIT(NL80211_STA_INFO_TX_FAILED) | |
| 1629 | BIT(NL80211_STA_INFO_TX_BITRATE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1630 | |
| 1631 | sinfo->signal = strStatistics.s8RSSI; |
| 1632 | sinfo->rx_packets = strStatistics.u32RxCount; |
| 1633 | sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1634 | sinfo->tx_failed = strStatistics.u32TxFailureCount; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1635 | sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10; |
| 1636 | |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1637 | if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)) |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1638 | Enable_TCP_ACK_Filter(true); |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1639 | else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED) |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1640 | Enable_TCP_ACK_Filter(false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1641 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1642 | PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets, |
| 1643 | sinfo->tx_failed, sinfo->txrate.legacy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1644 | } |
| 1645 | return s32Error; |
| 1646 | } |
| 1647 | |
| 1648 | |
| 1649 | /** |
Chaehyun Lim | a5f7db6 | 2015-09-14 12:24:20 +0900 | [diff] [blame] | 1650 | * @brief change_bss |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1651 | * @details Modify parameters for a given BSS. |
| 1652 | * @param[in] |
| 1653 | * -use_cts_prot: Whether to use CTS protection |
| 1654 | * (0 = no, 1 = yes, -1 = do not change) |
| 1655 | * -use_short_preamble: Whether the use of short preambles is allowed |
| 1656 | * (0 = no, 1 = yes, -1 = do not change) |
| 1657 | * -use_short_slot_time: Whether the use of short slot time is allowed |
| 1658 | * (0 = no, 1 = yes, -1 = do not change) |
| 1659 | * -basic_rates: basic rates in IEEE 802.11 format |
| 1660 | * (or NULL for no change) |
| 1661 | * -basic_rates_len: number of basic rates |
| 1662 | * -ap_isolate: do not forward packets between connected stations |
| 1663 | * -ht_opmode: HT Operation mode |
| 1664 | * (u16 = opmode, -1 = do not change) |
| 1665 | * @return int : Return 0 on Success. |
| 1666 | * @author mdaftedar |
| 1667 | * @date 01 MAR 2012 |
| 1668 | * @version 1.0 |
| 1669 | */ |
Chaehyun Lim | a5f7db6 | 2015-09-14 12:24:20 +0900 | [diff] [blame] | 1670 | static int change_bss(struct wiphy *wiphy, struct net_device *dev, |
| 1671 | struct bss_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1672 | { |
| 1673 | PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n"); |
| 1674 | return 0; |
| 1675 | } |
| 1676 | |
| 1677 | /** |
| 1678 | * @brief WILC_WFI_auth |
| 1679 | * @details Request to authenticate with the specified peer |
| 1680 | * @param[in] |
| 1681 | * @return int : Return 0 on Success. |
| 1682 | * @author mdaftedar |
| 1683 | * @date 01 MAR 2012 |
| 1684 | * @version 1.0 |
| 1685 | */ |
| 1686 | static int WILC_WFI_auth(struct wiphy *wiphy, struct net_device *dev, |
| 1687 | struct cfg80211_auth_request *req) |
| 1688 | { |
| 1689 | PRINT_D(CFG80211_DBG, "In Authentication Function\n"); |
| 1690 | return 0; |
| 1691 | } |
| 1692 | |
| 1693 | /** |
| 1694 | * @brief WILC_WFI_assoc |
| 1695 | * @details Request to (re)associate with the specified peer |
| 1696 | * @param[in] |
| 1697 | * @return int : Return 0 on Success. |
| 1698 | * @author mdaftedar |
| 1699 | * @date 01 MAR 2012 |
| 1700 | * @version 1.0 |
| 1701 | */ |
| 1702 | static int WILC_WFI_assoc(struct wiphy *wiphy, struct net_device *dev, |
| 1703 | struct cfg80211_assoc_request *req) |
| 1704 | { |
| 1705 | PRINT_D(CFG80211_DBG, "In Association Function\n"); |
| 1706 | return 0; |
| 1707 | } |
| 1708 | |
| 1709 | /** |
| 1710 | * @brief WILC_WFI_deauth |
| 1711 | * @details Request to deauthenticate from the specified peer |
| 1712 | * @param[in] |
| 1713 | * @return int : Return 0 on Success. |
| 1714 | * @author mdaftedar |
| 1715 | * @date 01 MAR 2012 |
| 1716 | * @version 1.0 |
| 1717 | */ |
| 1718 | static int WILC_WFI_deauth(struct wiphy *wiphy, struct net_device *dev, |
| 1719 | struct cfg80211_deauth_request *req, void *cookie) |
| 1720 | { |
| 1721 | PRINT_D(CFG80211_DBG, "In De-authentication Function\n"); |
| 1722 | return 0; |
| 1723 | } |
| 1724 | |
| 1725 | /** |
| 1726 | * @brief WILC_WFI_disassoc |
| 1727 | * @details Request to disassociate from the specified peer |
| 1728 | * @param[in] |
| 1729 | * @return int : Return 0 on Success |
| 1730 | * @author mdaftedar |
| 1731 | * @date 01 MAR 2012 |
| 1732 | * @version 1.0 |
| 1733 | */ |
| 1734 | static int WILC_WFI_disassoc(struct wiphy *wiphy, struct net_device *dev, |
| 1735 | struct cfg80211_disassoc_request *req, void *cookie) |
| 1736 | { |
| 1737 | PRINT_D(CFG80211_DBG, "In Disassociation Function\n"); |
| 1738 | return 0; |
| 1739 | } |
| 1740 | |
| 1741 | /** |
Chaehyun Lim | a76b63e | 2015-09-14 12:24:21 +0900 | [diff] [blame] | 1742 | * @brief set_wiphy_params |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1743 | * @details Notify that wiphy parameters have changed; |
| 1744 | * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values |
| 1745 | * have changed. |
| 1746 | * @return int : Return 0 on Success |
| 1747 | * @author mdaftedar |
| 1748 | * @date 01 MAR 2012 |
| 1749 | * @version 1.0 |
| 1750 | */ |
Chaehyun Lim | a76b63e | 2015-09-14 12:24:21 +0900 | [diff] [blame] | 1751 | static int set_wiphy_params(struct wiphy *wiphy, u32 changed) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1752 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1753 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1754 | tstrCfgParamVal pstrCfgParamVal; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1755 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1756 | |
| 1757 | priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1758 | |
| 1759 | pstrCfgParamVal.u32SetCfgFlag = 0; |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 1760 | PRINT_D(CFG80211_DBG, "Setting Wiphy params\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1761 | |
| 1762 | if (changed & WIPHY_PARAM_RETRY_SHORT) { |
| 1763 | PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n", |
| 1764 | priv->dev->ieee80211_ptr->wiphy->retry_short); |
| 1765 | pstrCfgParamVal.u32SetCfgFlag |= RETRY_SHORT; |
| 1766 | pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short; |
| 1767 | } |
| 1768 | if (changed & WIPHY_PARAM_RETRY_LONG) { |
| 1769 | |
| 1770 | PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long); |
| 1771 | pstrCfgParamVal.u32SetCfgFlag |= RETRY_LONG; |
| 1772 | pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long; |
| 1773 | |
| 1774 | } |
| 1775 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { |
| 1776 | PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold); |
| 1777 | pstrCfgParamVal.u32SetCfgFlag |= FRAG_THRESHOLD; |
| 1778 | pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold; |
| 1779 | |
| 1780 | } |
| 1781 | |
| 1782 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
| 1783 | PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold); |
| 1784 | |
| 1785 | pstrCfgParamVal.u32SetCfgFlag |= RTS_THRESHOLD; |
| 1786 | pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold; |
| 1787 | |
| 1788 | } |
| 1789 | |
| 1790 | PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n"); |
| 1791 | s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal); |
| 1792 | if (s32Error) |
| 1793 | PRINT_ER("Error in setting WIPHY PARAMS\n"); |
| 1794 | |
| 1795 | |
| 1796 | return s32Error; |
| 1797 | } |
Arnd Bergmann | e5af056 | 2015-05-29 22:52:12 +0200 | [diff] [blame] | 1798 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1799 | /** |
| 1800 | * @brief WILC_WFI_set_bitrate_mask |
| 1801 | * @details set the bitrate mask configuration |
| 1802 | * @param[in] |
| 1803 | * @return int : Return 0 on Success |
| 1804 | * @author mdaftedar |
| 1805 | * @date 01 MAR 2012 |
| 1806 | * @version 1.0 |
| 1807 | */ |
| 1808 | static int WILC_WFI_set_bitrate_mask(struct wiphy *wiphy, |
| 1809 | struct net_device *dev, const u8 *peer, |
| 1810 | const struct cfg80211_bitrate_mask *mask) |
| 1811 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1812 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1813 | |
| 1814 | PRINT_D(CFG80211_DBG, "Setting Bitrate mask function\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1815 | return s32Error; |
| 1816 | |
| 1817 | } |
| 1818 | |
| 1819 | /** |
Chaehyun Lim | 4d46657 | 2015-09-14 12:24:22 +0900 | [diff] [blame] | 1820 | * @brief set_pmksa |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1821 | * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac |
| 1822 | * devices running firmwares capable of generating the (re) association |
| 1823 | * RSN IE. It allows for faster roaming between WPA2 BSSIDs. |
| 1824 | * @param[in] |
| 1825 | * @return int : Return 0 on Success |
| 1826 | * @author mdaftedar |
| 1827 | * @date 01 MAR 2012 |
| 1828 | * @version 1.0 |
| 1829 | */ |
Chaehyun Lim | 4d46657 | 2015-09-14 12:24:22 +0900 | [diff] [blame] | 1830 | static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev, |
| 1831 | struct cfg80211_pmksa *pmksa) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1832 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1833 | u32 i; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1834 | s32 s32Error = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1835 | u8 flag = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1836 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1837 | struct wilc_priv *priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1838 | |
| 1839 | PRINT_D(CFG80211_DBG, "Setting PMKSA\n"); |
| 1840 | |
| 1841 | |
| 1842 | for (i = 0; i < priv->pmkid_list.numpmkid; i++) { |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 1843 | if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1844 | ETH_ALEN)) { |
| 1845 | /*If bssid already exists and pmkid value needs to reset*/ |
| 1846 | flag = PMKID_FOUND; |
| 1847 | PRINT_D(CFG80211_DBG, "PMKID already exists\n"); |
| 1848 | break; |
| 1849 | } |
| 1850 | } |
| 1851 | if (i < WILC_MAX_NUM_PMKIDS) { |
| 1852 | PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n"); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1853 | memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1854 | ETH_ALEN); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1855 | memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1856 | PMKID_LEN); |
| 1857 | if (!(flag == PMKID_FOUND)) |
| 1858 | priv->pmkid_list.numpmkid++; |
| 1859 | } else { |
| 1860 | PRINT_ER("Invalid PMKID index\n"); |
| 1861 | s32Error = -EINVAL; |
| 1862 | } |
| 1863 | |
| 1864 | if (!s32Error) { |
| 1865 | PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n"); |
| 1866 | s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list); |
| 1867 | } |
| 1868 | return s32Error; |
| 1869 | } |
| 1870 | |
| 1871 | /** |
Chaehyun Lim | 1ff86d9 | 2015-09-14 12:24:23 +0900 | [diff] [blame] | 1872 | * @brief del_pmksa |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1873 | * @details Delete a cached PMKID. |
| 1874 | * @param[in] |
| 1875 | * @return int : Return 0 on Success |
| 1876 | * @author mdaftedar |
| 1877 | * @date 01 MAR 2012 |
| 1878 | * @version 1.0 |
| 1879 | */ |
Chaehyun Lim | 1ff86d9 | 2015-09-14 12:24:23 +0900 | [diff] [blame] | 1880 | static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev, |
| 1881 | struct cfg80211_pmksa *pmksa) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1882 | { |
| 1883 | |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1884 | u32 i; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1885 | u8 flag = 0; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1886 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1887 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1888 | struct wilc_priv *priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1889 | |
| 1890 | PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n"); |
| 1891 | |
| 1892 | for (i = 0; i < priv->pmkid_list.numpmkid; i++) { |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 1893 | if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1894 | ETH_ALEN)) { |
| 1895 | /*If bssid is found, reset the values*/ |
| 1896 | PRINT_D(CFG80211_DBG, "Reseting PMKID values\n"); |
Chaehyun Lim | 2cc4683 | 2015-08-07 09:02:01 +0900 | [diff] [blame] | 1897 | memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(tstrHostIFpmkid)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1898 | flag = PMKID_FOUND; |
| 1899 | break; |
| 1900 | } |
| 1901 | } |
| 1902 | |
| 1903 | if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) { |
| 1904 | for (; i < (priv->pmkid_list.numpmkid - 1); i++) { |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1905 | memcpy(priv->pmkid_list.pmkidlist[i].bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1906 | priv->pmkid_list.pmkidlist[i + 1].bssid, |
| 1907 | ETH_ALEN); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1908 | memcpy(priv->pmkid_list.pmkidlist[i].pmkid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1909 | priv->pmkid_list.pmkidlist[i].pmkid, |
| 1910 | PMKID_LEN); |
| 1911 | } |
| 1912 | priv->pmkid_list.numpmkid--; |
| 1913 | } else { |
| 1914 | s32Error = -EINVAL; |
| 1915 | } |
| 1916 | |
| 1917 | return s32Error; |
| 1918 | } |
| 1919 | |
| 1920 | /** |
Chaehyun Lim | b33c39b | 2015-09-14 12:24:24 +0900 | [diff] [blame] | 1921 | * @brief flush_pmksa |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1922 | * @details Flush all cached PMKIDs. |
| 1923 | * @param[in] |
| 1924 | * @return int : Return 0 on Success |
| 1925 | * @author mdaftedar |
| 1926 | * @date 01 MAR 2012 |
| 1927 | * @version 1.0 |
| 1928 | */ |
Chaehyun Lim | b33c39b | 2015-09-14 12:24:24 +0900 | [diff] [blame] | 1929 | static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1930 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1931 | struct wilc_priv *priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1932 | |
| 1933 | PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n"); |
| 1934 | |
| 1935 | /*Get cashed Pmkids and set all with zeros*/ |
Chaehyun Lim | 2cc4683 | 2015-08-07 09:02:01 +0900 | [diff] [blame] | 1936 | memset(&priv->pmkid_list, 0, sizeof(tstrHostIFpmkidAttr)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1937 | |
| 1938 | return 0; |
| 1939 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1940 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1941 | |
| 1942 | /** |
| 1943 | * @brief WILC_WFI_CfgParseRxAction |
| 1944 | * @details Function parses the received frames and modifies the following attributes: |
| 1945 | * -GO Intent |
| 1946 | * -Channel list |
| 1947 | * -Operating Channel |
| 1948 | * |
| 1949 | * @param[in] u8* Buffer, u32 length |
| 1950 | * @return NONE. |
| 1951 | * @author mdaftedar |
| 1952 | * @date 12 DEC 2012 |
| 1953 | * @version |
| 1954 | */ |
| 1955 | |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1956 | void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1957 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1958 | u32 index = 0; |
| 1959 | u32 i = 0, j = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1960 | |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1961 | u8 op_channel_attr_index = 0; |
| 1962 | u8 channel_list_attr_index = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1963 | |
| 1964 | while (index < len) { |
| 1965 | if (buf[index] == GO_INTENT_ATTR_ID) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1966 | buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1967 | } |
| 1968 | |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1969 | if (buf[index] == CHANLIST_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1970 | channel_list_attr_index = index; |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1971 | else if (buf[index] == OPERCHAN_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1972 | op_channel_attr_index = index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1973 | index += buf[index + 1] + 3; /* ID,Length byte */ |
| 1974 | } |
| 1975 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1976 | if (u8WLANChannel != INVALID_CHANNEL) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1977 | { |
| 1978 | /*Modify channel list attribute*/ |
| 1979 | if (channel_list_attr_index) { |
| 1980 | PRINT_D(GENERIC_DBG, "Modify channel list attribute\n"); |
| 1981 | for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) { |
| 1982 | if (buf[i] == 0x51) { |
| 1983 | for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) { |
| 1984 | buf[j] = u8WLANChannel; |
| 1985 | } |
| 1986 | break; |
| 1987 | } |
| 1988 | } |
| 1989 | } |
| 1990 | /*Modify operating channel attribute*/ |
| 1991 | if (op_channel_attr_index) { |
| 1992 | PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n"); |
| 1993 | buf[op_channel_attr_index + 6] = 0x51; |
| 1994 | buf[op_channel_attr_index + 7] = u8WLANChannel; |
| 1995 | } |
| 1996 | } |
| 1997 | } |
| 1998 | |
| 1999 | /** |
| 2000 | * @brief WILC_WFI_CfgParseTxAction |
| 2001 | * @details Function parses the transmitted action frames and modifies the |
| 2002 | * GO Intent attribute |
| 2003 | * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype |
| 2004 | * @return NONE. |
| 2005 | * @author mdaftedar |
| 2006 | * @date 12 DEC 2012 |
| 2007 | * @version |
| 2008 | */ |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2009 | void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2010 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 2011 | u32 index = 0; |
| 2012 | u32 i = 0, j = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2013 | |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2014 | u8 op_channel_attr_index = 0; |
| 2015 | u8 channel_list_attr_index = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2016 | |
| 2017 | while (index < len) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2018 | if (buf[index] == GO_INTENT_ATTR_ID) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2019 | buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2020 | |
| 2021 | break; |
| 2022 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2023 | |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 2024 | if (buf[index] == CHANLIST_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2025 | channel_list_attr_index = index; |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 2026 | else if (buf[index] == OPERCHAN_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2027 | op_channel_attr_index = index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2028 | index += buf[index + 1] + 3; /* ID,Length byte */ |
| 2029 | } |
| 2030 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2031 | if (u8WLANChannel != INVALID_CHANNEL && bOperChan) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2032 | { |
| 2033 | /*Modify channel list attribute*/ |
| 2034 | if (channel_list_attr_index) { |
| 2035 | PRINT_D(GENERIC_DBG, "Modify channel list attribute\n"); |
| 2036 | for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) { |
| 2037 | if (buf[i] == 0x51) { |
| 2038 | for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) { |
| 2039 | buf[j] = u8WLANChannel; |
| 2040 | } |
| 2041 | break; |
| 2042 | } |
| 2043 | } |
| 2044 | } |
| 2045 | /*Modify operating channel attribute*/ |
| 2046 | if (op_channel_attr_index) { |
| 2047 | PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n"); |
| 2048 | buf[op_channel_attr_index + 6] = 0x51; |
| 2049 | buf[op_channel_attr_index + 7] = u8WLANChannel; |
| 2050 | } |
| 2051 | } |
| 2052 | } |
| 2053 | |
| 2054 | /* @brief WILC_WFI_p2p_rx |
| 2055 | * @details |
| 2056 | * @param[in] |
| 2057 | * |
| 2058 | * @return None |
| 2059 | * @author Mai Daftedar |
| 2060 | * @date 2 JUN 2013 |
| 2061 | * @version 1.0 |
| 2062 | */ |
| 2063 | |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 2064 | void WILC_WFI_p2p_rx (struct net_device *dev, u8 *buff, u32 size) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2065 | { |
| 2066 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2067 | struct wilc_priv *priv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 2068 | u32 header, pkt_offset; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2069 | tstrWILC_WFIDrv *pstrWFIDrv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 2070 | u32 i = 0; |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 2071 | s32 s32Freq; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2072 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2073 | priv = wiphy_priv(dev->ieee80211_ptr->wiphy); |
| 2074 | pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; |
| 2075 | |
| 2076 | /* Get WILC header */ |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 2077 | memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2078 | |
| 2079 | /* The packet offset field conain info about what type of managment frame */ |
| 2080 | /* we are dealing with and ack status */ |
| 2081 | pkt_offset = GET_PKT_OFFSET(header); |
| 2082 | |
| 2083 | if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { |
| 2084 | if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) { |
| 2085 | PRINT_D(GENERIC_DBG, "Probe response ACK\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2086 | cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2087 | return; |
| 2088 | } else { |
| 2089 | if (pkt_offset & IS_MGMT_STATUS_SUCCES) { |
| 2090 | PRINT_D(GENERIC_DBG, "Success Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID], |
| 2091 | buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2092 | cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2093 | } else { |
| 2094 | PRINT_D(GENERIC_DBG, "Fail Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID], |
| 2095 | buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2096 | cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2097 | } |
| 2098 | return; |
| 2099 | } |
| 2100 | } else { |
| 2101 | |
| 2102 | PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]); |
| 2103 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2104 | /*Upper layer is informed that the frame is received on this freq*/ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2105 | s32Freq = ieee80211_channel_to_frequency(u8CurrChannel, IEEE80211_BAND_2GHZ); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2106 | |
| 2107 | if (ieee80211_is_action(buff[FRAME_TYPE_ID])) { |
| 2108 | PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]); |
| 2109 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2110 | if (priv->bCfgScanning == true && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2111 | PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n"); |
| 2112 | return; |
| 2113 | } |
| 2114 | if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { |
| 2115 | |
| 2116 | switch (buff[ACTION_SUBTYPE_ID]) { |
| 2117 | case GAS_INTIAL_REQ: |
| 2118 | PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]); |
| 2119 | break; |
| 2120 | |
| 2121 | case GAS_INTIAL_RSP: |
| 2122 | PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]); |
| 2123 | break; |
| 2124 | |
| 2125 | case PUBLIC_ACT_VENDORSPEC: |
| 2126 | /*Now we have a public action vendor specific action frame, check if its a p2p public action frame |
| 2127 | * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/ |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 2128 | if (!memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2129 | if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) { |
| 2130 | if (!bWilc_ie) { |
| 2131 | for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) { |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 2132 | if (!memcmp(u8P2P_vendorspec, &buff[i], 6)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2133 | u8P2Precvrandom = buff[i + 6]; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2134 | bWilc_ie = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2135 | PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom); |
| 2136 | break; |
| 2137 | } |
| 2138 | } |
| 2139 | } |
| 2140 | } |
| 2141 | if (u8P2Plocalrandom > u8P2Precvrandom) { |
| 2142 | if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP |
| 2143 | || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) { |
| 2144 | for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) { |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 2145 | if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buff[i + 2], 4))) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2146 | WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6)); |
| 2147 | break; |
| 2148 | } |
| 2149 | } |
| 2150 | } |
| 2151 | } else |
| 2152 | PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom); |
| 2153 | } |
| 2154 | |
| 2155 | |
| 2156 | if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) { |
| 2157 | PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n"); |
| 2158 | /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2159 | cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2160 | return; |
| 2161 | } |
| 2162 | break; |
| 2163 | |
| 2164 | default: |
| 2165 | PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]); |
| 2166 | break; |
| 2167 | } |
| 2168 | } |
| 2169 | } |
| 2170 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2171 | cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2172 | } |
| 2173 | } |
| 2174 | |
| 2175 | /** |
| 2176 | * @brief WILC_WFI_mgmt_tx_complete |
| 2177 | * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here) |
| 2178 | * @param[in] priv |
| 2179 | * transmitting status |
| 2180 | * @return None |
| 2181 | * @author Amr Abdelmoghny |
| 2182 | * @date 20 MAY 2013 |
| 2183 | * @version 1.0 |
| 2184 | */ |
| 2185 | static void WILC_WFI_mgmt_tx_complete(void *priv, int status) |
| 2186 | { |
| 2187 | struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv; |
| 2188 | |
| 2189 | |
| 2190 | kfree(pv_data->buff); |
| 2191 | kfree(pv_data); |
| 2192 | } |
| 2193 | |
| 2194 | /** |
| 2195 | * @brief WILC_WFI_RemainOnChannelReady |
| 2196 | * @details Callback function, called from handle_remain_on_channel on being ready on channel |
| 2197 | * @param |
| 2198 | * @return none |
| 2199 | * @author Amr abdelmoghny |
| 2200 | * @date 9 JUNE 2013 |
| 2201 | * @version |
| 2202 | */ |
| 2203 | |
| 2204 | static void WILC_WFI_RemainOnChannelReady(void *pUserVoid) |
| 2205 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2206 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2207 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2208 | priv = (struct wilc_priv *)pUserVoid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2209 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 2210 | PRINT_D(HOSTINF_DBG, "Remain on channel ready\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2211 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2212 | priv->bInP2PlistenState = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2213 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2214 | cfg80211_ready_on_channel(priv->wdev, |
| 2215 | priv->strRemainOnChanParams.u64ListenCookie, |
| 2216 | priv->strRemainOnChanParams.pstrListenChan, |
| 2217 | priv->strRemainOnChanParams.u32ListenDuration, |
| 2218 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2219 | } |
| 2220 | |
| 2221 | /** |
| 2222 | * @brief WILC_WFI_RemainOnChannelExpired |
| 2223 | * @details Callback function, called on expiration of remain-on-channel duration |
| 2224 | * @param |
| 2225 | * @return none |
| 2226 | * @author Amr abdelmoghny |
| 2227 | * @date 15 MAY 2013 |
| 2228 | * @version |
| 2229 | */ |
| 2230 | |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 2231 | static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2232 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2233 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2234 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2235 | priv = (struct wilc_priv *)pUserVoid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2236 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2237 | if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 2238 | PRINT_D(GENERIC_DBG, "Remain on channel expired\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2239 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2240 | priv->bInP2PlistenState = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2241 | |
| 2242 | /*Inform wpas of remain-on-channel expiration*/ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2243 | cfg80211_remain_on_channel_expired(priv->wdev, |
| 2244 | priv->strRemainOnChanParams.u64ListenCookie, |
| 2245 | priv->strRemainOnChanParams.pstrListenChan, |
| 2246 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2247 | } else { |
| 2248 | PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID |
| 2249 | , priv->strRemainOnChanParams.u32ListenSessionID); |
| 2250 | } |
| 2251 | } |
| 2252 | |
| 2253 | |
| 2254 | /** |
Chaehyun Lim | 6d19d69 | 2015-09-14 12:24:25 +0900 | [diff] [blame] | 2255 | * @brief remain_on_channel |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2256 | * @details Request the driver to remain awake on the specified |
| 2257 | * channel for the specified duration to complete an off-channel |
| 2258 | * operation (e.g., public action frame exchange). When the driver is |
| 2259 | * ready on the requested channel, it must indicate this with an event |
| 2260 | * notification by calling cfg80211_ready_on_channel(). |
| 2261 | * @param[in] |
| 2262 | * @return int : Return 0 on Success |
| 2263 | * @author mdaftedar |
| 2264 | * @date 01 MAR 2012 |
| 2265 | * @version 1.0 |
| 2266 | */ |
Chaehyun Lim | 6d19d69 | 2015-09-14 12:24:25 +0900 | [diff] [blame] | 2267 | static int remain_on_channel(struct wiphy *wiphy, |
| 2268 | struct wireless_dev *wdev, |
| 2269 | struct ieee80211_channel *chan, |
| 2270 | unsigned int duration, u64 *cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2271 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2272 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2273 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2274 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2275 | priv = wiphy_priv(wiphy); |
| 2276 | |
| 2277 | PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value); |
| 2278 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2279 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2280 | if (wdev->iftype == NL80211_IFTYPE_AP) { |
| 2281 | PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode"); |
| 2282 | return s32Error; |
| 2283 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2284 | |
| 2285 | u8CurrChannel = chan->hw_value; |
| 2286 | |
| 2287 | /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/ |
| 2288 | priv->strRemainOnChanParams.pstrListenChan = chan; |
| 2289 | priv->strRemainOnChanParams.u64ListenCookie = *cookie; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2290 | priv->strRemainOnChanParams.u32ListenDuration = duration; |
| 2291 | priv->strRemainOnChanParams.u32ListenSessionID++; |
| 2292 | |
| 2293 | s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv |
| 2294 | , priv->strRemainOnChanParams.u32ListenSessionID |
| 2295 | , duration |
| 2296 | , chan->hw_value |
| 2297 | , WILC_WFI_RemainOnChannelExpired |
| 2298 | , WILC_WFI_RemainOnChannelReady |
| 2299 | , (void *)priv); |
| 2300 | |
| 2301 | return s32Error; |
| 2302 | } |
| 2303 | |
| 2304 | /** |
Chaehyun Lim | 1dd5440 | 2015-09-14 12:24:26 +0900 | [diff] [blame] | 2305 | * @brief cancel_remain_on_channel |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2306 | * @details Cancel an on-going remain-on-channel operation. |
| 2307 | * This allows the operation to be terminated prior to timeout based on |
| 2308 | * the duration value. |
| 2309 | * @param[in] struct wiphy *wiphy, |
| 2310 | * @param[in] struct net_device *dev |
| 2311 | * @param[in] u64 cookie, |
| 2312 | * @return int : Return 0 on Success |
| 2313 | * @author mdaftedar |
| 2314 | * @date 01 MAR 2012 |
| 2315 | * @version 1.0 |
| 2316 | */ |
Chaehyun Lim | 1dd5440 | 2015-09-14 12:24:26 +0900 | [diff] [blame] | 2317 | static int cancel_remain_on_channel(struct wiphy *wiphy, |
| 2318 | struct wireless_dev *wdev, |
| 2319 | u64 cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2320 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2321 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2322 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2323 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2324 | priv = wiphy_priv(wiphy); |
| 2325 | |
| 2326 | PRINT_D(CFG80211_DBG, "Cancel remain on channel\n"); |
| 2327 | |
| 2328 | s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID); |
| 2329 | return s32Error; |
| 2330 | } |
| 2331 | /** |
| 2332 | * @brief WILC_WFI_add_wilcvendorspec |
| 2333 | * @details Adding WILC information elemet to allow two WILC devices to |
| 2334 | * identify each other and connect |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2335 | * @param[in] u8 * buf |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2336 | * @return void |
| 2337 | * @author mdaftedar |
| 2338 | * @date 01 JAN 2014 |
| 2339 | * @version 1.0 |
| 2340 | */ |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2341 | void WILC_WFI_add_wilcvendorspec(u8 *buff) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2342 | { |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 2343 | memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2344 | } |
| 2345 | /** |
| 2346 | * @brief WILC_WFI_mgmt_tx_frame |
| 2347 | * @details |
| 2348 | * |
| 2349 | * @param[in] |
| 2350 | * @return NONE. |
| 2351 | * @author mdaftedar |
| 2352 | * @date 01 JUL 2012 |
| 2353 | * @version |
| 2354 | */ |
| 2355 | extern linux_wlan_t *g_linux_wlan; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2356 | extern bool bEnablePS; |
Chaehyun Lim | 12a26a3 | 2015-09-14 12:24:28 +0900 | [diff] [blame] | 2357 | int mgmt_tx(struct wiphy *wiphy, |
| 2358 | struct wireless_dev *wdev, |
| 2359 | struct cfg80211_mgmt_tx_params *params, |
| 2360 | u64 *cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2361 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2362 | struct ieee80211_channel *chan = params->chan; |
| 2363 | unsigned int wait = params->wait; |
| 2364 | const u8 *buf = params->buf; |
| 2365 | size_t len = params->len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2366 | const struct ieee80211_mgmt *mgmt; |
| 2367 | struct p2p_mgmt_data *mgmt_tx; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2368 | struct wilc_priv *priv; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2369 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2370 | tstrWILC_WFIDrv *pstrWFIDrv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 2371 | u32 i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2372 | perInterface_wlan_t *nic; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 2373 | u32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2374 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2375 | nic = netdev_priv(wdev->netdev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2376 | priv = wiphy_priv(wiphy); |
| 2377 | pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; |
| 2378 | |
| 2379 | *cookie = (unsigned long)buf; |
| 2380 | priv->u64tx_cookie = *cookie; |
| 2381 | mgmt = (const struct ieee80211_mgmt *) buf; |
| 2382 | |
| 2383 | if (ieee80211_is_mgmt(mgmt->frame_control)) { |
| 2384 | |
| 2385 | /*mgmt frame allocation*/ |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 2386 | mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2387 | if (mgmt_tx == NULL) { |
| 2388 | PRINT_ER("Failed to allocate memory for mgmt_tx structure\n"); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2389 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2390 | } |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 2391 | mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2392 | if (mgmt_tx->buff == NULL) { |
| 2393 | PRINT_ER("Failed to allocate memory for mgmt_tx buff\n"); |
Tony Cho | f638dd3 | 2015-09-07 19:09:31 +0900 | [diff] [blame] | 2394 | kfree(mgmt_tx); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2395 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2396 | } |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 2397 | memcpy(mgmt_tx->buff, buf, len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2398 | mgmt_tx->size = len; |
| 2399 | |
| 2400 | |
| 2401 | if (ieee80211_is_probe_resp(mgmt->frame_control)) { |
| 2402 | PRINT_D(GENERIC_DBG, "TX: Probe Response\n"); |
| 2403 | PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value); |
| 2404 | host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value); |
| 2405 | /*Save the current channel after we tune to it*/ |
| 2406 | u8CurrChannel = chan->hw_value; |
| 2407 | } else if (ieee80211_is_action(mgmt->frame_control)) { |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 2408 | PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2409 | |
| 2410 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2411 | if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2412 | /*Only set the channel, if not a negotiation confirmation frame |
| 2413 | * (If Negotiation confirmation frame, force it |
| 2414 | * to be transmitted on the same negotiation channel)*/ |
| 2415 | |
| 2416 | if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC || |
| 2417 | buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) { |
| 2418 | PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value); |
| 2419 | host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value); |
| 2420 | /*Save the current channel after we tune to it*/ |
| 2421 | u8CurrChannel = chan->hw_value; |
| 2422 | } |
| 2423 | switch (buf[ACTION_SUBTYPE_ID]) { |
| 2424 | case GAS_INTIAL_REQ: |
| 2425 | { |
| 2426 | PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]); |
| 2427 | break; |
| 2428 | } |
| 2429 | |
| 2430 | case GAS_INTIAL_RSP: |
| 2431 | { |
| 2432 | PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]); |
| 2433 | break; |
| 2434 | } |
| 2435 | |
| 2436 | case PUBLIC_ACT_VENDORSPEC: |
| 2437 | { |
| 2438 | /*Now we have a public action vendor specific action frame, check if its a p2p public action frame |
| 2439 | * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/ |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 2440 | if (!memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2441 | /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/ |
| 2442 | if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) { |
| 2443 | if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) { |
| 2444 | get_random_bytes(&u8P2Plocalrandom, 1); |
| 2445 | /*Increment the number to prevent if its 0*/ |
| 2446 | u8P2Plocalrandom++; |
| 2447 | } |
| 2448 | } |
| 2449 | |
| 2450 | if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP |
| 2451 | || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) { |
| 2452 | if (u8P2Plocalrandom > u8P2Precvrandom) { |
| 2453 | PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom); |
| 2454 | |
| 2455 | /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/ |
| 2456 | for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) { |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 2457 | if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buf[i + 2], 4))) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2458 | if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP) |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2459 | WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2460 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2461 | /*If using supplicant go intent, no need at all*/ |
| 2462 | /*to parse transmitted negotiation frames*/ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2463 | else |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2464 | WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2465 | break; |
| 2466 | } |
| 2467 | } |
| 2468 | |
| 2469 | if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) { |
| 2470 | WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]); |
| 2471 | mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom; |
| 2472 | mgmt_tx->size = buf_len; |
| 2473 | } |
| 2474 | } else |
| 2475 | PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom); |
| 2476 | } |
| 2477 | |
| 2478 | } else { |
| 2479 | PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n"); |
| 2480 | } |
| 2481 | |
| 2482 | break; |
| 2483 | } |
| 2484 | |
| 2485 | default: |
| 2486 | { |
| 2487 | PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]); |
| 2488 | break; |
| 2489 | } |
| 2490 | } |
| 2491 | |
| 2492 | } |
| 2493 | |
| 2494 | PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value); |
| 2495 | pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait)); |
| 2496 | |
| 2497 | PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout); |
| 2498 | |
| 2499 | } |
| 2500 | |
| 2501 | g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, WILC_WFI_mgmt_tx_complete); |
| 2502 | } else { |
| 2503 | PRINT_D(GENERIC_DBG, "This function transmits only management frames\n"); |
| 2504 | } |
| 2505 | return s32Error; |
| 2506 | } |
| 2507 | |
Chaehyun Lim | 4a2f9b3 | 2015-09-14 12:24:27 +0900 | [diff] [blame] | 2508 | int mgmt_tx_cancel_wait(struct wiphy *wiphy, |
| 2509 | struct wireless_dev *wdev, |
| 2510 | u64 cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2511 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2512 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2513 | tstrWILC_WFIDrv *pstrWFIDrv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2514 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2515 | priv = wiphy_priv(wiphy); |
| 2516 | pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv; |
| 2517 | |
| 2518 | |
| 2519 | PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies); |
| 2520 | pstrWFIDrv->u64P2p_MgmtTimeout = jiffies; |
| 2521 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2522 | if (priv->bInP2PlistenState == false) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2523 | cfg80211_remain_on_channel_expired(priv->wdev, |
| 2524 | priv->strRemainOnChanParams.u64ListenCookie, |
| 2525 | priv->strRemainOnChanParams.pstrListenChan, |
| 2526 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2527 | } |
| 2528 | |
| 2529 | return 0; |
| 2530 | } |
| 2531 | |
| 2532 | /** |
Chaehyun Lim | 8e0735c | 2015-09-20 15:51:16 +0900 | [diff] [blame] | 2533 | * @brief wilc_mgmt_frame_register |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2534 | * @details Notify driver that a management frame type was |
| 2535 | * registered. Note that this callback may not sleep, and cannot run |
| 2536 | * concurrently with itself. |
| 2537 | * @param[in] |
| 2538 | * @return NONE. |
| 2539 | * @author mdaftedar |
| 2540 | * @date 01 JUL 2012 |
| 2541 | * @version |
| 2542 | */ |
Chaehyun Lim | 8e0735c | 2015-09-20 15:51:16 +0900 | [diff] [blame] | 2543 | void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 2544 | u16 frame_type, bool reg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2545 | { |
| 2546 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2547 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2548 | perInterface_wlan_t *nic; |
| 2549 | |
| 2550 | |
| 2551 | priv = wiphy_priv(wiphy); |
| 2552 | nic = netdev_priv(priv->wdev->netdev); |
| 2553 | |
| 2554 | |
| 2555 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2556 | if (!frame_type) |
| 2557 | return; |
| 2558 | |
| 2559 | PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg); |
| 2560 | switch (frame_type) { |
| 2561 | case PROBE_REQ: |
| 2562 | { |
| 2563 | nic->g_struct_frame_reg[0].frame_type = frame_type; |
| 2564 | nic->g_struct_frame_reg[0].reg = reg; |
| 2565 | } |
| 2566 | break; |
| 2567 | |
| 2568 | case ACTION: |
| 2569 | { |
| 2570 | nic->g_struct_frame_reg[1].frame_type = frame_type; |
| 2571 | nic->g_struct_frame_reg[1].reg = reg; |
| 2572 | } |
| 2573 | break; |
| 2574 | |
| 2575 | default: |
| 2576 | { |
| 2577 | break; |
| 2578 | } |
| 2579 | |
| 2580 | } |
| 2581 | /*If mac is closed, then return*/ |
| 2582 | if (!g_linux_wlan->wilc1000_initialized) { |
| 2583 | PRINT_D(GENERIC_DBG, "Return since mac is closed\n"); |
| 2584 | return; |
| 2585 | } |
| 2586 | host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg); |
| 2587 | |
| 2588 | |
| 2589 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2590 | |
| 2591 | /** |
| 2592 | * @brief WILC_WFI_set_cqm_rssi_config |
| 2593 | * @details Configure connection quality monitor RSSI threshold. |
| 2594 | * @param[in] struct wiphy *wiphy: |
| 2595 | * @param[in] struct net_device *dev: |
| 2596 | * @param[in] s32 rssi_thold: |
| 2597 | * @param[in] u32 rssi_hyst: |
| 2598 | * @return int : Return 0 on Success |
| 2599 | * @author mdaftedar |
| 2600 | * @date 01 MAR 2012 |
| 2601 | * @version 1.0 |
| 2602 | */ |
| 2603 | static int WILC_WFI_set_cqm_rssi_config(struct wiphy *wiphy, |
| 2604 | struct net_device *dev, s32 rssi_thold, u32 rssi_hyst) |
| 2605 | { |
| 2606 | PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n"); |
| 2607 | return 0; |
| 2608 | |
| 2609 | } |
| 2610 | /** |
Chaehyun Lim | bdb6338 | 2015-09-14 12:24:19 +0900 | [diff] [blame] | 2611 | * @brief dump_station |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2612 | * @details Configure connection quality monitor RSSI threshold. |
| 2613 | * @param[in] struct wiphy *wiphy: |
| 2614 | * @param[in] struct net_device *dev |
| 2615 | * @param[in] int idx |
| 2616 | * @param[in] u8 *mac |
| 2617 | * @param[in] struct station_info *sinfo |
| 2618 | * @return int : Return 0 on Success |
| 2619 | * @author mdaftedar |
| 2620 | * @date 01 MAR 2012 |
| 2621 | * @version 1.0 |
| 2622 | */ |
Chaehyun Lim | bdb6338 | 2015-09-14 12:24:19 +0900 | [diff] [blame] | 2623 | static int dump_station(struct wiphy *wiphy, struct net_device *dev, |
| 2624 | int idx, u8 *mac, struct station_info *sinfo) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2625 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2626 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2627 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2628 | PRINT_D(CFG80211_DBG, "Dumping station information\n"); |
| 2629 | |
| 2630 | if (idx != 0) |
| 2631 | return -ENOENT; |
| 2632 | |
| 2633 | priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2634 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2635 | sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2636 | |
| 2637 | host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal)); |
| 2638 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2639 | return 0; |
| 2640 | |
| 2641 | } |
| 2642 | |
| 2643 | |
| 2644 | /** |
Chaehyun Lim | 4653067 | 2015-09-22 18:34:46 +0900 | [diff] [blame] | 2645 | * @brief set_power_mgmt |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2646 | * @details |
| 2647 | * @param[in] |
| 2648 | * @return int : Return 0 on Success. |
| 2649 | * @author mdaftedar |
| 2650 | * @date 01 JUL 2012 |
Chaehyun Lim | cdc9cba | 2015-09-22 18:34:47 +0900 | [diff] [blame^] | 2651 | * @version 1.0 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2652 | */ |
Chaehyun Lim | 4653067 | 2015-09-22 18:34:46 +0900 | [diff] [blame] | 2653 | static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 2654 | bool enabled, int timeout) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2655 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2656 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2657 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2658 | PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout); |
| 2659 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 2660 | if (wiphy == NULL) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2661 | return -ENOENT; |
| 2662 | |
| 2663 | priv = wiphy_priv(wiphy); |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 2664 | if (priv->hWILCWFIDrv == NULL) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2665 | PRINT_ER("Driver is NULL\n"); |
| 2666 | return -EIO; |
| 2667 | } |
| 2668 | |
Abdul Hussain | 5a66bf2 | 2015-06-16 09:44:06 +0000 | [diff] [blame] | 2669 | if (bEnablePS) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2670 | host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout); |
| 2671 | |
| 2672 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2673 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2674 | |
| 2675 | } |
Glen Lee | 108b343 | 2015-09-16 18:53:20 +0900 | [diff] [blame] | 2676 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2677 | /** |
Chaehyun Lim | 3615e9a | 2015-09-14 12:24:11 +0900 | [diff] [blame] | 2678 | * @brief change_virtual_intf |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2679 | * @details Change type/configuration of virtual interface, |
| 2680 | * keep the struct wireless_dev's iftype updated. |
| 2681 | * @param[in] NONE |
| 2682 | * @return int : Return 0 on Success. |
| 2683 | * @author mdaftedar |
| 2684 | * @date 01 MAR 2012 |
| 2685 | * @version 1.0 |
| 2686 | */ |
| 2687 | void wilc1000_wlan_deinit(linux_wlan_t *nic); |
| 2688 | int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic); |
| 2689 | |
Chaehyun Lim | 3615e9a | 2015-09-14 12:24:11 +0900 | [diff] [blame] | 2690 | static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, |
| 2691 | enum nl80211_iftype type, u32 *flags, struct vif_params *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2692 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2693 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2694 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2695 | perInterface_wlan_t *nic; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2696 | u8 interface_type; |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 2697 | u16 TID = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2698 | u8 i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2699 | |
| 2700 | nic = netdev_priv(dev); |
| 2701 | priv = wiphy_priv(wiphy); |
| 2702 | |
| 2703 | PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n"); |
| 2704 | PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name); |
| 2705 | u8P2Plocalrandom = 0x01; |
| 2706 | u8P2Precvrandom = 0x00; |
| 2707 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2708 | bWilc_ie = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2709 | |
| 2710 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2711 | g_obtainingIP = false; |
Greg Kroah-Hartman | 8972d0f | 2015-08-14 20:04:13 -0700 | [diff] [blame] | 2712 | del_timer(&hDuringIpTimer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2713 | PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n"); |
| 2714 | #endif |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2715 | /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/ |
| 2716 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2717 | Set_machw_change_vir_if(true); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2718 | } |
| 2719 | |
| 2720 | switch (type) { |
| 2721 | case NL80211_IFTYPE_STATION: |
| 2722 | connecting = 0; |
| 2723 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2724 | |
| 2725 | /* send delba over wlan interface */ |
| 2726 | |
| 2727 | |
| 2728 | dev->ieee80211_ptr->iftype = type; |
| 2729 | priv->wdev->iftype = type; |
| 2730 | nic->monitor_flag = 0; |
| 2731 | nic->iftype = STATION_MODE; |
| 2732 | |
| 2733 | /*Remove the enteries of the previously connected clients*/ |
| 2734 | memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2735 | interface_type = nic->iftype; |
| 2736 | nic->iftype = STATION_MODE; |
| 2737 | |
| 2738 | if (g_linux_wlan->wilc1000_initialized) { |
| 2739 | host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID); |
| 2740 | /* ensure that the message Q is empty */ |
| 2741 | host_int_wait_msg_queue_idle(); |
| 2742 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2743 | /*Eliminate host interface blocking state*/ |
Greg Kroah-Hartman | 8990d85 | 2015-09-03 20:07:58 -0700 | [diff] [blame] | 2744 | up(&g_linux_wlan->cfg_event); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2745 | |
| 2746 | wilc1000_wlan_deinit(g_linux_wlan); |
| 2747 | wilc1000_wlan_init(dev, nic); |
| 2748 | g_wilc_initialized = 1; |
| 2749 | nic->iftype = interface_type; |
| 2750 | |
| 2751 | /*Setting interface 1 drv handler and mac address in newly downloaded FW*/ |
| 2752 | host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler); |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2753 | host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2754 | g_linux_wlan->strInterfaceInfo[0].aSrcAddress); |
| 2755 | host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE); |
| 2756 | |
| 2757 | /*Add saved WEP keys, if any*/ |
| 2758 | if (g_wep_keys_saved) { |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2759 | host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2760 | g_key_wep_params.key_idx); |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2761 | host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2762 | g_key_wep_params.key, |
| 2763 | g_key_wep_params.key_len, |
| 2764 | g_key_wep_params.key_idx); |
| 2765 | } |
| 2766 | |
| 2767 | /*No matter the driver handler passed here, it will be overwriiten*/ |
| 2768 | /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/ |
| 2769 | host_int_flush_join_req(priv->hWILCWFIDrv); |
| 2770 | |
| 2771 | /*Add saved PTK and GTK keys, if any*/ |
| 2772 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
| 2773 | PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0], |
| 2774 | g_key_ptk_params.key[1], |
| 2775 | g_key_ptk_params.key[2]); |
| 2776 | PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0], |
| 2777 | g_key_gtk_params.key[1], |
| 2778 | g_key_gtk_params.key[2]); |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2779 | add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, |
| 2780 | g_linux_wlan->strInterfaceInfo[0].wilc_netdev, |
| 2781 | g_add_ptk_key_params.key_idx, |
| 2782 | g_add_ptk_key_params.pairwise, |
| 2783 | g_add_ptk_key_params.mac_addr, |
| 2784 | (struct key_params *)(&g_key_ptk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2785 | |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2786 | add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, |
| 2787 | g_linux_wlan->strInterfaceInfo[0].wilc_netdev, |
| 2788 | g_add_gtk_key_params.key_idx, |
| 2789 | g_add_gtk_key_params.pairwise, |
| 2790 | g_add_gtk_key_params.mac_addr, |
| 2791 | (struct key_params *)(&g_key_gtk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2792 | } |
| 2793 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2794 | if (g_linux_wlan->wilc1000_initialized) { |
| 2795 | for (i = 0; i < num_reg_frame; i++) { |
| 2796 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2797 | nic->g_struct_frame_reg[i].reg); |
| 2798 | host_int_frame_register(priv->hWILCWFIDrv, |
| 2799 | nic->g_struct_frame_reg[i].frame_type, |
| 2800 | nic->g_struct_frame_reg[i].reg); |
| 2801 | } |
| 2802 | } |
| 2803 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2804 | bEnablePS = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2805 | host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0); |
| 2806 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2807 | break; |
| 2808 | |
| 2809 | case NL80211_IFTYPE_P2P_CLIENT: |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2810 | bEnablePS = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2811 | host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0); |
| 2812 | connecting = 0; |
| 2813 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2814 | |
| 2815 | host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID); |
| 2816 | |
| 2817 | dev->ieee80211_ptr->iftype = type; |
| 2818 | priv->wdev->iftype = type; |
| 2819 | nic->monitor_flag = 0; |
| 2820 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2821 | PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n"); |
| 2822 | nic->iftype = CLIENT_MODE; |
| 2823 | |
| 2824 | |
| 2825 | if (g_linux_wlan->wilc1000_initialized) { |
| 2826 | /* ensure that the message Q is empty */ |
| 2827 | host_int_wait_msg_queue_idle(); |
| 2828 | |
| 2829 | wilc1000_wlan_deinit(g_linux_wlan); |
| 2830 | wilc1000_wlan_init(dev, nic); |
| 2831 | g_wilc_initialized = 1; |
| 2832 | |
| 2833 | host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler); |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2834 | host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2835 | g_linux_wlan->strInterfaceInfo[0].aSrcAddress); |
| 2836 | host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE); |
| 2837 | |
| 2838 | /*Add saved WEP keys, if any*/ |
| 2839 | if (g_wep_keys_saved) { |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2840 | host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2841 | g_key_wep_params.key_idx); |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2842 | host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2843 | g_key_wep_params.key, |
| 2844 | g_key_wep_params.key_len, |
| 2845 | g_key_wep_params.key_idx); |
| 2846 | } |
| 2847 | |
| 2848 | /*No matter the driver handler passed here, it will be overwriiten*/ |
| 2849 | /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/ |
| 2850 | host_int_flush_join_req(priv->hWILCWFIDrv); |
| 2851 | |
| 2852 | /*Add saved PTK and GTK keys, if any*/ |
| 2853 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
| 2854 | PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0], |
| 2855 | g_key_ptk_params.key[1], |
| 2856 | g_key_ptk_params.key[2]); |
| 2857 | PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0], |
| 2858 | g_key_gtk_params.key[1], |
| 2859 | g_key_gtk_params.key[2]); |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2860 | add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, |
| 2861 | g_linux_wlan->strInterfaceInfo[0].wilc_netdev, |
| 2862 | g_add_ptk_key_params.key_idx, |
| 2863 | g_add_ptk_key_params.pairwise, |
| 2864 | g_add_ptk_key_params.mac_addr, |
| 2865 | (struct key_params *)(&g_key_ptk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2866 | |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2867 | add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, |
| 2868 | g_linux_wlan->strInterfaceInfo[0].wilc_netdev, |
| 2869 | g_add_gtk_key_params.key_idx, |
| 2870 | g_add_gtk_key_params.pairwise, |
| 2871 | g_add_gtk_key_params.mac_addr, |
| 2872 | (struct key_params *)(&g_key_gtk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2873 | } |
| 2874 | |
| 2875 | /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/ |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2876 | refresh_scan(priv, 1, true); |
| 2877 | Set_machw_change_vir_if(false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2878 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2879 | if (g_linux_wlan->wilc1000_initialized) { |
| 2880 | for (i = 0; i < num_reg_frame; i++) { |
| 2881 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2882 | nic->g_struct_frame_reg[i].reg); |
| 2883 | host_int_frame_register(priv->hWILCWFIDrv, |
| 2884 | nic->g_struct_frame_reg[i].frame_type, |
| 2885 | nic->g_struct_frame_reg[i].reg); |
| 2886 | } |
| 2887 | } |
| 2888 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2889 | break; |
| 2890 | |
| 2891 | case NL80211_IFTYPE_AP: |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2892 | bEnablePS = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2893 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2894 | dev->ieee80211_ptr->iftype = type; |
| 2895 | priv->wdev->iftype = type; |
| 2896 | nic->iftype = AP_MODE; |
Johnny Kim | 8a14330 | 2015-06-10 17:06:46 +0900 | [diff] [blame] | 2897 | PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2898 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2899 | PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n"); |
| 2900 | linux_wlan_get_firmware(nic); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2901 | /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/ |
| 2902 | if (g_linux_wlan->wilc1000_initialized) { |
| 2903 | nic->iftype = AP_MODE; |
| 2904 | g_linux_wlan->wilc1000_initialized = 1; |
| 2905 | mac_close(dev); |
| 2906 | mac_open(dev); |
| 2907 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2908 | for (i = 0; i < num_reg_frame; i++) { |
| 2909 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2910 | nic->g_struct_frame_reg[i].reg); |
| 2911 | host_int_frame_register(priv->hWILCWFIDrv, |
| 2912 | nic->g_struct_frame_reg[i].frame_type, |
| 2913 | nic->g_struct_frame_reg[i].reg); |
| 2914 | } |
| 2915 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2916 | break; |
| 2917 | |
| 2918 | case NL80211_IFTYPE_P2P_GO: |
| 2919 | PRINT_D(GENERIC_DBG, "start duringIP timer\n"); |
| 2920 | |
| 2921 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2922 | g_obtainingIP = true; |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 2923 | mod_timer(&hDuringIpTimer, jiffies + msecs_to_jiffies(duringIP_TIME)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2924 | #endif |
| 2925 | host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2926 | /*Delete block ack has to be the latest config packet*/ |
| 2927 | /*sent before downloading new FW. This is because it blocks on*/ |
| 2928 | /*hWaitResponse semaphore, which allows previous config*/ |
| 2929 | /*packets to actually take action on old FW*/ |
| 2930 | host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2931 | bEnablePS = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2932 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2933 | dev->ieee80211_ptr->iftype = type; |
| 2934 | priv->wdev->iftype = type; |
| 2935 | |
Johnny Kim | 8a14330 | 2015-06-10 17:06:46 +0900 | [diff] [blame] | 2936 | PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2937 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2938 | PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n"); |
| 2939 | |
| 2940 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2941 | nic->iftype = GO_MODE; |
| 2942 | |
| 2943 | /* ensure that the message Q is empty */ |
| 2944 | host_int_wait_msg_queue_idle(); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2945 | wilc1000_wlan_deinit(g_linux_wlan); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2946 | wilc1000_wlan_init(dev, nic); |
| 2947 | g_wilc_initialized = 1; |
| 2948 | |
| 2949 | |
| 2950 | /*Setting interface 1 drv handler and mac address in newly downloaded FW*/ |
| 2951 | host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler); |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2952 | host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2953 | g_linux_wlan->strInterfaceInfo[0].aSrcAddress); |
| 2954 | host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE); |
| 2955 | |
| 2956 | /*Add saved WEP keys, if any*/ |
| 2957 | if (g_wep_keys_saved) { |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2958 | host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2959 | g_key_wep_params.key_idx); |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2960 | host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2961 | g_key_wep_params.key, |
| 2962 | g_key_wep_params.key_len, |
| 2963 | g_key_wep_params.key_idx); |
| 2964 | } |
| 2965 | |
| 2966 | /*No matter the driver handler passed here, it will be overwriiten*/ |
| 2967 | /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/ |
| 2968 | host_int_flush_join_req(priv->hWILCWFIDrv); |
| 2969 | |
| 2970 | /*Add saved PTK and GTK keys, if any*/ |
| 2971 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
| 2972 | PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0], |
| 2973 | g_key_ptk_params.key[1], |
| 2974 | g_key_ptk_params.key[2], |
| 2975 | g_key_ptk_params.cipher); |
| 2976 | PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0], |
| 2977 | g_key_gtk_params.key[1], |
| 2978 | g_key_gtk_params.key[2], |
| 2979 | g_key_gtk_params.cipher); |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2980 | add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, |
| 2981 | g_linux_wlan->strInterfaceInfo[0].wilc_netdev, |
| 2982 | g_add_ptk_key_params.key_idx, |
| 2983 | g_add_ptk_key_params.pairwise, |
| 2984 | g_add_ptk_key_params.mac_addr, |
| 2985 | (struct key_params *)(&g_key_ptk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2986 | |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2987 | add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, |
| 2988 | g_linux_wlan->strInterfaceInfo[0].wilc_netdev, |
| 2989 | g_add_gtk_key_params.key_idx, |
| 2990 | g_add_gtk_key_params.pairwise, |
| 2991 | g_add_gtk_key_params.mac_addr, |
| 2992 | (struct key_params *)(&g_key_gtk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2993 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2994 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2995 | if (g_linux_wlan->wilc1000_initialized) { |
| 2996 | for (i = 0; i < num_reg_frame; i++) { |
| 2997 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2998 | nic->g_struct_frame_reg[i].reg); |
| 2999 | host_int_frame_register(priv->hWILCWFIDrv, |
| 3000 | nic->g_struct_frame_reg[i].frame_type, |
| 3001 | nic->g_struct_frame_reg[i].reg); |
| 3002 | } |
| 3003 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3004 | break; |
| 3005 | |
| 3006 | default: |
| 3007 | PRINT_ER("Unknown interface type= %d\n", type); |
| 3008 | s32Error = -EINVAL; |
| 3009 | return s32Error; |
| 3010 | break; |
| 3011 | } |
| 3012 | |
| 3013 | return s32Error; |
| 3014 | } |
| 3015 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3016 | /* (austin.2013-07-23) |
| 3017 | * |
| 3018 | * To support revised cfg80211_ops |
| 3019 | * |
| 3020 | * add_beacon --> start_ap |
| 3021 | * set_beacon --> change_beacon |
| 3022 | * del_beacon --> stop_ap |
| 3023 | * |
| 3024 | * beacon_parameters --> cfg80211_ap_settings |
| 3025 | * cfg80211_beacon_data |
| 3026 | * |
| 3027 | * applicable for linux kernel 3.4+ |
| 3028 | */ |
| 3029 | |
| 3030 | /** |
Chaehyun Lim | a13168d | 2015-09-14 12:24:12 +0900 | [diff] [blame] | 3031 | * @brief start_ap |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3032 | * @details Add a beacon with given parameters, @head, @interval |
| 3033 | * and @dtim_period will be valid, @tail is optional. |
| 3034 | * @param[in] wiphy |
| 3035 | * @param[in] dev The net device structure |
| 3036 | * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added |
| 3037 | * @return int : Return 0 on Success. |
| 3038 | * @author austin |
| 3039 | * @date 23 JUL 2013 |
| 3040 | * @version 1.0 |
| 3041 | */ |
Chaehyun Lim | a13168d | 2015-09-14 12:24:12 +0900 | [diff] [blame] | 3042 | static int start_ap(struct wiphy *wiphy, struct net_device *dev, |
| 3043 | struct cfg80211_ap_settings *settings) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3044 | { |
| 3045 | struct cfg80211_beacon_data *beacon = &(settings->beacon); |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3046 | struct wilc_priv *priv; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3047 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3048 | |
| 3049 | priv = wiphy_priv(wiphy); |
| 3050 | PRINT_D(HOSTAPD_DBG, "Starting ap\n"); |
| 3051 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 3052 | PRINT_D(HOSTAPD_DBG, "Interval = %d\n DTIM period = %d\n Head length = %zu Tail length = %zu\n", |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3053 | settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len); |
| 3054 | |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 3055 | s32Error = set_channel(wiphy, &settings->chandef); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3056 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3057 | if (s32Error != 0) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3058 | PRINT_ER("Error in setting channel\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3059 | |
| 3060 | linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress); |
| 3061 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3062 | s32Error = host_int_add_beacon(priv->hWILCWFIDrv, |
| 3063 | settings->beacon_interval, |
| 3064 | settings->dtim_period, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 3065 | beacon->head_len, (u8 *)beacon->head, |
| 3066 | beacon->tail_len, (u8 *)beacon->tail); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3067 | |
| 3068 | return s32Error; |
| 3069 | } |
| 3070 | |
| 3071 | /** |
Chaehyun Lim | 2a4c84d | 2015-09-14 12:24:13 +0900 | [diff] [blame] | 3072 | * @brief change_beacon |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3073 | * @details Add a beacon with given parameters, @head, @interval |
| 3074 | * and @dtim_period will be valid, @tail is optional. |
| 3075 | * @param[in] wiphy |
| 3076 | * @param[in] dev The net device structure |
| 3077 | * @param[in] beacon cfg80211_beacon_data for the beacon to be changed |
| 3078 | * @return int : Return 0 on Success. |
| 3079 | * @author austin |
| 3080 | * @date 23 JUL 2013 |
| 3081 | * @version 1.0 |
| 3082 | */ |
Chaehyun Lim | 2a4c84d | 2015-09-14 12:24:13 +0900 | [diff] [blame] | 3083 | static int change_beacon(struct wiphy *wiphy, struct net_device *dev, |
| 3084 | struct cfg80211_beacon_data *beacon) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3085 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3086 | struct wilc_priv *priv; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3087 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3088 | |
| 3089 | priv = wiphy_priv(wiphy); |
| 3090 | PRINT_D(HOSTAPD_DBG, "Setting beacon\n"); |
| 3091 | |
| 3092 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3093 | s32Error = host_int_add_beacon(priv->hWILCWFIDrv, |
| 3094 | 0, |
| 3095 | 0, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 3096 | beacon->head_len, (u8 *)beacon->head, |
| 3097 | beacon->tail_len, (u8 *)beacon->tail); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3098 | |
| 3099 | return s32Error; |
| 3100 | } |
| 3101 | |
| 3102 | /** |
Chaehyun Lim | c8cddd7 | 2015-09-14 12:24:14 +0900 | [diff] [blame] | 3103 | * @brief stop_ap |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3104 | * @details Remove beacon configuration and stop sending the beacon. |
| 3105 | * @param[in] |
| 3106 | * @return int : Return 0 on Success. |
| 3107 | * @author austin |
| 3108 | * @date 23 JUL 2013 |
| 3109 | * @version 1.0 |
| 3110 | */ |
Chaehyun Lim | c8cddd7 | 2015-09-14 12:24:14 +0900 | [diff] [blame] | 3111 | static int stop_ap(struct wiphy *wiphy, struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3112 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3113 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3114 | struct wilc_priv *priv; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 3115 | u8 NullBssid[ETH_ALEN] = {0}; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3116 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 3117 | if (!wiphy) |
| 3118 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3119 | |
| 3120 | priv = wiphy_priv(wiphy); |
| 3121 | |
| 3122 | PRINT_D(HOSTAPD_DBG, "Deleting beacon\n"); |
| 3123 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3124 | linux_wlan_set_bssid(dev, NullBssid); |
| 3125 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3126 | s32Error = host_int_del_beacon(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3127 | |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 3128 | if (s32Error) |
| 3129 | PRINT_ER("Host delete beacon fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3130 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3131 | return s32Error; |
| 3132 | } |
| 3133 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3134 | /** |
Chaehyun Lim | ed26955 | 2015-09-14 12:24:15 +0900 | [diff] [blame] | 3135 | * @brief add_station |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3136 | * @details Add a new station. |
| 3137 | * @param[in] |
| 3138 | * @return int : Return 0 on Success. |
| 3139 | * @author mdaftedar |
| 3140 | * @date 01 MAR 2012 |
| 3141 | * @version 1.0 |
| 3142 | */ |
Chaehyun Lim | ed26955 | 2015-09-14 12:24:15 +0900 | [diff] [blame] | 3143 | static int add_station(struct wiphy *wiphy, struct net_device *dev, |
| 3144 | const u8 *mac, struct station_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3145 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3146 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3147 | struct wilc_priv *priv; |
Tony Cho | 6a89ba9 | 2015-09-21 12:16:46 +0900 | [diff] [blame] | 3148 | struct add_sta_param strStaParams = { {0} }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3149 | perInterface_wlan_t *nic; |
| 3150 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 3151 | if (!wiphy) |
| 3152 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3153 | |
| 3154 | priv = wiphy_priv(wiphy); |
| 3155 | nic = netdev_priv(dev); |
| 3156 | |
| 3157 | if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 3158 | memcpy(strStaParams.au8BSSID, mac, ETH_ALEN); |
| 3159 | memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3160 | strStaParams.u16AssocID = params->aid; |
| 3161 | strStaParams.u8NumRates = params->supported_rates_len; |
| 3162 | strStaParams.pu8Rates = params->supported_rates; |
| 3163 | |
| 3164 | PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid); |
| 3165 | |
| 3166 | PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][0], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][1], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][2], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][3], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][4], |
| 3167 | priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]); |
| 3168 | PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID); |
| 3169 | PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates); |
| 3170 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 3171 | if (params->ht_capa == NULL) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3172 | strStaParams.bIsHTSupported = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3173 | } else { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3174 | strStaParams.bIsHTSupported = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3175 | strStaParams.u16HTCapInfo = params->ht_capa->cap_info; |
| 3176 | strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 3177 | memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3178 | strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info; |
| 3179 | strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info; |
| 3180 | strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info; |
| 3181 | } |
| 3182 | |
| 3183 | strStaParams.u16FlagsMask = params->sta_flags_mask; |
| 3184 | strStaParams.u16FlagsSet = params->sta_flags_set; |
| 3185 | |
| 3186 | PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported); |
| 3187 | PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo); |
| 3188 | PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams); |
| 3189 | PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams); |
| 3190 | PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap); |
| 3191 | PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap); |
| 3192 | PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask); |
| 3193 | PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet); |
| 3194 | |
| 3195 | s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams); |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 3196 | if (s32Error) |
| 3197 | PRINT_ER("Host add station fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3198 | } |
| 3199 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3200 | return s32Error; |
| 3201 | } |
| 3202 | |
| 3203 | /** |
Chaehyun Lim | a0a8be9 | 2015-09-14 12:24:16 +0900 | [diff] [blame] | 3204 | * @brief del_station |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3205 | * @details Remove a station; @mac may be NULL to remove all stations. |
| 3206 | * @param[in] |
| 3207 | * @return int : Return 0 on Success. |
| 3208 | * @author mdaftedar |
| 3209 | * @date 01 MAR 2012 |
| 3210 | * @version 1.0 |
| 3211 | */ |
Chaehyun Lim | a0a8be9 | 2015-09-14 12:24:16 +0900 | [diff] [blame] | 3212 | static int del_station(struct wiphy *wiphy, struct net_device *dev, |
| 3213 | struct station_del_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3214 | { |
Arnd Bergmann | 057d1e9 | 2015-06-01 21:06:44 +0200 | [diff] [blame] | 3215 | const u8 *mac = params->mac; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3216 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3217 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3218 | perInterface_wlan_t *nic; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 3219 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 3220 | if (!wiphy) |
| 3221 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3222 | |
| 3223 | priv = wiphy_priv(wiphy); |
| 3224 | nic = netdev_priv(dev); |
| 3225 | |
| 3226 | if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { |
| 3227 | PRINT_D(HOSTAPD_DBG, "Deleting station\n"); |
| 3228 | |
| 3229 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 3230 | if (mac == NULL) { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 3231 | PRINT_D(HOSTAPD_DBG, "All associated stations\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3232 | s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss); |
| 3233 | } else { |
| 3234 | PRINT_D(HOSTAPD_DBG, "With mac address: %x%x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
| 3235 | } |
| 3236 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3237 | s32Error = host_int_del_station(priv->hWILCWFIDrv, mac); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3238 | |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 3239 | if (s32Error) |
| 3240 | PRINT_ER("Host delete station fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3241 | } |
| 3242 | return s32Error; |
| 3243 | } |
| 3244 | |
| 3245 | /** |
Chaehyun Lim | 14b4208 | 2015-09-14 12:24:17 +0900 | [diff] [blame] | 3246 | * @brief change_station |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3247 | * @details Modify a given station. |
| 3248 | * @param[in] |
| 3249 | * @return int : Return 0 on Success. |
| 3250 | * @author mdaftedar |
| 3251 | * @date 01 MAR 2012 |
| 3252 | * @version 1.0 |
| 3253 | */ |
Chaehyun Lim | 14b4208 | 2015-09-14 12:24:17 +0900 | [diff] [blame] | 3254 | static int change_station(struct wiphy *wiphy, struct net_device *dev, |
| 3255 | const u8 *mac, struct station_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3256 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3257 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3258 | struct wilc_priv *priv; |
Tony Cho | 6a89ba9 | 2015-09-21 12:16:46 +0900 | [diff] [blame] | 3259 | struct add_sta_param strStaParams = { {0} }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3260 | perInterface_wlan_t *nic; |
| 3261 | |
| 3262 | |
| 3263 | PRINT_D(HOSTAPD_DBG, "Change station paramters\n"); |
| 3264 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 3265 | if (!wiphy) |
| 3266 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3267 | |
| 3268 | priv = wiphy_priv(wiphy); |
| 3269 | nic = netdev_priv(dev); |
| 3270 | |
| 3271 | if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 3272 | memcpy(strStaParams.au8BSSID, mac, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3273 | strStaParams.u16AssocID = params->aid; |
| 3274 | strStaParams.u8NumRates = params->supported_rates_len; |
| 3275 | strStaParams.pu8Rates = params->supported_rates; |
| 3276 | |
| 3277 | PRINT_D(HOSTAPD_DBG, "BSSID = %x%x%x%x%x%x\n", strStaParams.au8BSSID[0], strStaParams.au8BSSID[1], strStaParams.au8BSSID[2], strStaParams.au8BSSID[3], strStaParams.au8BSSID[4], |
| 3278 | strStaParams.au8BSSID[5]); |
| 3279 | PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID); |
| 3280 | PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates); |
| 3281 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 3282 | if (params->ht_capa == NULL) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3283 | strStaParams.bIsHTSupported = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3284 | } else { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3285 | strStaParams.bIsHTSupported = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3286 | strStaParams.u16HTCapInfo = params->ht_capa->cap_info; |
| 3287 | strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 3288 | memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3289 | strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info; |
| 3290 | strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info; |
| 3291 | strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info; |
| 3292 | |
| 3293 | } |
| 3294 | |
| 3295 | strStaParams.u16FlagsMask = params->sta_flags_mask; |
| 3296 | strStaParams.u16FlagsSet = params->sta_flags_set; |
| 3297 | |
| 3298 | PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported); |
| 3299 | PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo); |
| 3300 | PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams); |
| 3301 | PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams); |
| 3302 | PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap); |
| 3303 | PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap); |
| 3304 | PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask); |
| 3305 | PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet); |
| 3306 | |
| 3307 | s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams); |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 3308 | if (s32Error) |
| 3309 | PRINT_ER("Host edit station fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3310 | } |
| 3311 | return s32Error; |
| 3312 | } |
| 3313 | |
| 3314 | |
| 3315 | /** |
Chaehyun Lim | 69deb4c | 2015-09-14 12:24:09 +0900 | [diff] [blame] | 3316 | * @brief add_virtual_intf |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3317 | * @details |
| 3318 | * @param[in] |
| 3319 | * @return int : Return 0 on Success. |
| 3320 | * @author mdaftedar |
| 3321 | * @date 01 JUL 2012 |
| 3322 | * @version 1.0 |
| 3323 | */ |
Chaehyun Lim | 69deb4c | 2015-09-14 12:24:09 +0900 | [diff] [blame] | 3324 | struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, const char *name, |
| 3325 | unsigned char name_assign_type, |
| 3326 | enum nl80211_iftype type, u32 *flags, |
| 3327 | struct vif_params *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3328 | { |
| 3329 | perInterface_wlan_t *nic; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3330 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3331 | struct net_device *new_ifc = NULL; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 3332 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3333 | priv = wiphy_priv(wiphy); |
| 3334 | |
| 3335 | |
| 3336 | |
| 3337 | PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev); |
| 3338 | |
| 3339 | nic = netdev_priv(priv->wdev->netdev); |
| 3340 | |
| 3341 | |
| 3342 | if (type == NL80211_IFTYPE_MONITOR) { |
| 3343 | PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n"); |
| 3344 | PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev); |
| 3345 | new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev); |
| 3346 | if (new_ifc != NULL) { |
| 3347 | PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3348 | nic = netdev_priv(priv->wdev->netdev); |
| 3349 | nic->monitor_flag = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3350 | } else |
| 3351 | PRINT_ER("Error in initializing monitor interface\n "); |
| 3352 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3353 | return priv->wdev; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3354 | } |
| 3355 | |
| 3356 | /** |
Chaehyun Lim | b4a7335 | 2015-09-14 12:24:10 +0900 | [diff] [blame] | 3357 | * @brief del_virtual_intf |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3358 | * @details |
| 3359 | * @param[in] |
| 3360 | * @return int : Return 0 on Success. |
| 3361 | * @author mdaftedar |
| 3362 | * @date 01 JUL 2012 |
| 3363 | * @version 1.0 |
| 3364 | */ |
Chaehyun Lim | cdc9cba | 2015-09-22 18:34:47 +0900 | [diff] [blame^] | 3365 | int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3366 | { |
| 3367 | PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n"); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3368 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3369 | } |
| 3370 | |
Chaehyun Lim | 0824192 | 2015-09-15 14:06:12 +0900 | [diff] [blame] | 3371 | static struct cfg80211_ops wilc_cfg80211_ops = { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3372 | |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 3373 | .set_monitor_channel = set_channel, |
Chaehyun Lim | 0e30d06 | 2015-09-14 12:24:02 +0900 | [diff] [blame] | 3374 | .scan = scan, |
Chaehyun Lim | 4ffbcdb | 2015-09-14 12:24:03 +0900 | [diff] [blame] | 3375 | .connect = connect, |
Chaehyun Lim | b027cde | 2015-09-14 12:24:04 +0900 | [diff] [blame] | 3376 | .disconnect = disconnect, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 3377 | .add_key = add_key, |
Chaehyun Lim | 3044ba7 | 2015-09-14 12:24:06 +0900 | [diff] [blame] | 3378 | .del_key = del_key, |
Chaehyun Lim | f4893df | 2015-09-14 12:24:07 +0900 | [diff] [blame] | 3379 | .get_key = get_key, |
Chaehyun Lim | 0f5b8ca | 2015-09-14 12:24:08 +0900 | [diff] [blame] | 3380 | .set_default_key = set_default_key, |
Chaehyun Lim | 69deb4c | 2015-09-14 12:24:09 +0900 | [diff] [blame] | 3381 | .add_virtual_intf = add_virtual_intf, |
Chaehyun Lim | b4a7335 | 2015-09-14 12:24:10 +0900 | [diff] [blame] | 3382 | .del_virtual_intf = del_virtual_intf, |
Chaehyun Lim | 3615e9a | 2015-09-14 12:24:11 +0900 | [diff] [blame] | 3383 | .change_virtual_intf = change_virtual_intf, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3384 | |
Chaehyun Lim | a13168d | 2015-09-14 12:24:12 +0900 | [diff] [blame] | 3385 | .start_ap = start_ap, |
Chaehyun Lim | 2a4c84d | 2015-09-14 12:24:13 +0900 | [diff] [blame] | 3386 | .change_beacon = change_beacon, |
Chaehyun Lim | c8cddd7 | 2015-09-14 12:24:14 +0900 | [diff] [blame] | 3387 | .stop_ap = stop_ap, |
Chaehyun Lim | ed26955 | 2015-09-14 12:24:15 +0900 | [diff] [blame] | 3388 | .add_station = add_station, |
Chaehyun Lim | a0a8be9 | 2015-09-14 12:24:16 +0900 | [diff] [blame] | 3389 | .del_station = del_station, |
Chaehyun Lim | 14b4208 | 2015-09-14 12:24:17 +0900 | [diff] [blame] | 3390 | .change_station = change_station, |
Chaehyun Lim | f06f562 | 2015-09-14 12:24:18 +0900 | [diff] [blame] | 3391 | .get_station = get_station, |
Chaehyun Lim | bdb6338 | 2015-09-14 12:24:19 +0900 | [diff] [blame] | 3392 | .dump_station = dump_station, |
Chaehyun Lim | a5f7db6 | 2015-09-14 12:24:20 +0900 | [diff] [blame] | 3393 | .change_bss = change_bss, |
Chaehyun Lim | a76b63e | 2015-09-14 12:24:21 +0900 | [diff] [blame] | 3394 | .set_wiphy_params = set_wiphy_params, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3395 | |
Chaehyun Lim | 4d46657 | 2015-09-14 12:24:22 +0900 | [diff] [blame] | 3396 | .set_pmksa = set_pmksa, |
Chaehyun Lim | 1ff86d9 | 2015-09-14 12:24:23 +0900 | [diff] [blame] | 3397 | .del_pmksa = del_pmksa, |
Chaehyun Lim | b33c39b | 2015-09-14 12:24:24 +0900 | [diff] [blame] | 3398 | .flush_pmksa = flush_pmksa, |
Chaehyun Lim | 6d19d69 | 2015-09-14 12:24:25 +0900 | [diff] [blame] | 3399 | .remain_on_channel = remain_on_channel, |
Chaehyun Lim | 1dd5440 | 2015-09-14 12:24:26 +0900 | [diff] [blame] | 3400 | .cancel_remain_on_channel = cancel_remain_on_channel, |
Chaehyun Lim | 4a2f9b3 | 2015-09-14 12:24:27 +0900 | [diff] [blame] | 3401 | .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait, |
Chaehyun Lim | 12a26a3 | 2015-09-14 12:24:28 +0900 | [diff] [blame] | 3402 | .mgmt_tx = mgmt_tx, |
Chaehyun Lim | 8e0735c | 2015-09-20 15:51:16 +0900 | [diff] [blame] | 3403 | .mgmt_frame_register = wilc_mgmt_frame_register, |
Chaehyun Lim | 4653067 | 2015-09-22 18:34:46 +0900 | [diff] [blame] | 3404 | .set_power_mgmt = set_power_mgmt, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3405 | .set_cqm_rssi_config = WILC_WFI_set_cqm_rssi_config, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3406 | |
| 3407 | }; |
| 3408 | |
| 3409 | |
| 3410 | |
| 3411 | |
| 3412 | |
| 3413 | /** |
| 3414 | * @brief WILC_WFI_update_stats |
| 3415 | * @details Modify parameters for a given BSS. |
| 3416 | * @param[in] |
| 3417 | * @return int : Return 0 on Success. |
| 3418 | * @author mdaftedar |
| 3419 | * @date 01 MAR 2012 |
Chaehyun Lim | cdc9cba | 2015-09-22 18:34:47 +0900 | [diff] [blame^] | 3420 | * @version 1.0 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3421 | */ |
| 3422 | int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed) |
| 3423 | { |
| 3424 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3425 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3426 | |
| 3427 | priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3428 | #if 1 |
| 3429 | switch (changed) { |
| 3430 | |
| 3431 | case WILC_WFI_RX_PKT: |
| 3432 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3433 | priv->netstats.rx_packets++; |
| 3434 | priv->netstats.rx_bytes += pktlen; |
| 3435 | priv->netstats.rx_time = get_jiffies_64(); |
| 3436 | } |
| 3437 | break; |
| 3438 | |
| 3439 | case WILC_WFI_TX_PKT: |
| 3440 | { |
| 3441 | priv->netstats.tx_packets++; |
| 3442 | priv->netstats.tx_bytes += pktlen; |
| 3443 | priv->netstats.tx_time = get_jiffies_64(); |
| 3444 | |
| 3445 | } |
| 3446 | break; |
| 3447 | |
| 3448 | default: |
| 3449 | break; |
| 3450 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3451 | #endif |
| 3452 | return 0; |
| 3453 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3454 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3455 | /** |
| 3456 | * @brief WILC_WFI_CfgAlloc |
| 3457 | * @details Allocation of the wireless device structure and assigning it |
| 3458 | * to the cfg80211 operations structure. |
| 3459 | * @param[in] NONE |
| 3460 | * @return wireless_dev : Returns pointer to wireless_dev structure. |
| 3461 | * @author mdaftedar |
| 3462 | * @date 01 MAR 2012 |
| 3463 | * @version 1.0 |
| 3464 | */ |
| 3465 | struct wireless_dev *WILC_WFI_CfgAlloc(void) |
| 3466 | { |
| 3467 | |
| 3468 | struct wireless_dev *wdev; |
| 3469 | |
| 3470 | |
| 3471 | PRINT_D(CFG80211_DBG, "Allocating wireless device\n"); |
| 3472 | /*Allocating the wireless device structure*/ |
| 3473 | wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); |
| 3474 | if (!wdev) { |
| 3475 | PRINT_ER("Cannot allocate wireless device\n"); |
| 3476 | goto _fail_; |
| 3477 | } |
| 3478 | |
| 3479 | /*Creating a new wiphy, linking wireless structure with the wiphy structure*/ |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3480 | wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3481 | if (!wdev->wiphy) { |
| 3482 | PRINT_ER("Cannot allocate wiphy\n"); |
| 3483 | goto _fail_mem_; |
| 3484 | |
| 3485 | } |
| 3486 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3487 | /* enable 802.11n HT */ |
| 3488 | WILC_WFI_band_2ghz.ht_cap.ht_supported = 1; |
| 3489 | WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT); |
| 3490 | WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff; |
| 3491 | WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K; |
| 3492 | WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3493 | |
| 3494 | /*wiphy bands*/ |
| 3495 | wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz; |
| 3496 | |
| 3497 | return wdev; |
| 3498 | |
| 3499 | _fail_mem_: |
| 3500 | kfree(wdev); |
| 3501 | _fail_: |
| 3502 | return NULL; |
| 3503 | |
| 3504 | } |
| 3505 | /** |
Chaehyun Lim | 8459fd5 | 2015-09-20 15:51:09 +0900 | [diff] [blame] | 3506 | * @brief wilc_create_wiphy |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3507 | * @details Registering of the wiphy structure and interface modes |
| 3508 | * @param[in] NONE |
| 3509 | * @return NONE |
| 3510 | * @author mdaftedar |
| 3511 | * @date 01 MAR 2012 |
| 3512 | * @version 1.0 |
| 3513 | */ |
Chaehyun Lim | 8459fd5 | 2015-09-20 15:51:09 +0900 | [diff] [blame] | 3514 | struct wireless_dev *wilc_create_wiphy(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3515 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3516 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3517 | struct wireless_dev *wdev; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3518 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3519 | |
| 3520 | PRINT_D(CFG80211_DBG, "Registering wifi device\n"); |
| 3521 | |
| 3522 | wdev = WILC_WFI_CfgAlloc(); |
| 3523 | if (wdev == NULL) { |
| 3524 | PRINT_ER("CfgAlloc Failed\n"); |
| 3525 | return NULL; |
| 3526 | } |
| 3527 | |
| 3528 | |
| 3529 | /*Return hardware description structure (wiphy)'s priv*/ |
| 3530 | priv = wdev_priv(wdev); |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 3531 | sema_init(&(priv->SemHandleUpdateStats), 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3532 | |
| 3533 | /*Link the wiphy with wireless structure*/ |
| 3534 | priv->wdev = wdev; |
| 3535 | |
| 3536 | /*Maximum number of probed ssid to be added by user for the scan request*/ |
| 3537 | wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3538 | /*Maximum number of pmkids to be cashed*/ |
| 3539 | wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS; |
| 3540 | PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3541 | |
| 3542 | wdev->wiphy->max_scan_ie_len = 1000; |
| 3543 | |
| 3544 | /*signal strength in mBm (100*dBm) */ |
| 3545 | wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 3546 | |
| 3547 | /*Set the availaible cipher suites*/ |
| 3548 | wdev->wiphy->cipher_suites = cipher_suites; |
| 3549 | wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3550 | /*Setting default managment types: for register action frame: */ |
| 3551 | wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3552 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3553 | wdev->wiphy->max_remain_on_channel_duration = 500; |
| 3554 | /*Setting the wiphy interfcae mode and type before registering the wiphy*/ |
| 3555 | wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) | |
| 3556 | BIT(NL80211_IFTYPE_P2P_CLIENT); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3557 | wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3558 | wdev->iftype = NL80211_IFTYPE_STATION; |
| 3559 | |
| 3560 | |
| 3561 | |
| 3562 | PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n", |
| 3563 | wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type, |
| 3564 | wdev->wiphy->interface_modes, wdev->iftype); |
| 3565 | |
| 3566 | #ifdef WILC_SDIO |
Chaehyun Lim | cdc9cba | 2015-09-22 18:34:47 +0900 | [diff] [blame^] | 3567 | set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3568 | #endif |
| 3569 | |
| 3570 | /*Register wiphy structure*/ |
| 3571 | s32Error = wiphy_register(wdev->wiphy); |
| 3572 | if (s32Error) { |
| 3573 | PRINT_ER("Cannot register wiphy device\n"); |
| 3574 | /*should define what action to be taken in such failure*/ |
| 3575 | } else { |
| 3576 | PRINT_D(CFG80211_DBG, "Successful Registering\n"); |
| 3577 | } |
| 3578 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3579 | priv->dev = net; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3580 | return wdev; |
| 3581 | |
| 3582 | |
| 3583 | } |
| 3584 | /** |
| 3585 | * @brief WILC_WFI_WiphyFree |
| 3586 | * @details Freeing allocation of the wireless device structure |
| 3587 | * @param[in] NONE |
| 3588 | * @return NONE |
| 3589 | * @author mdaftedar |
| 3590 | * @date 01 MAR 2012 |
| 3591 | * @version 1.0 |
| 3592 | */ |
Chaehyun Lim | dd4b6a8 | 2015-09-20 15:51:25 +0900 | [diff] [blame] | 3593 | int wilc_init_host_int(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3594 | { |
| 3595 | |
Chaehyun Lim | 1a8ccd8 | 2015-09-20 15:51:23 +0900 | [diff] [blame] | 3596 | int s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3597 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3598 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3599 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3600 | PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr); |
| 3601 | priv = wdev_priv(net->ieee80211_ptr); |
| 3602 | if (op_ifcs == 0) { |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 3603 | setup_timer(&hAgingTimer, remove_network_from_shadow, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3604 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 3605 | setup_timer(&hDuringIpTimer, clear_duringIP, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3606 | #endif |
| 3607 | } |
| 3608 | op_ifcs++; |
| 3609 | if (s32Error < 0) { |
| 3610 | PRINT_ER("Failed to creat refresh Timer\n"); |
| 3611 | return s32Error; |
| 3612 | } |
| 3613 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3614 | priv->gbAutoRateAdjusted = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3615 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3616 | priv->bInP2PlistenState = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3617 | |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 3618 | sema_init(&(priv->hSemScanReq), 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3619 | s32Error = host_int_init(&priv->hWILCWFIDrv); |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 3620 | if (s32Error) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3621 | PRINT_ER("Error while initializing hostinterface\n"); |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 3622 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3623 | return s32Error; |
| 3624 | } |
| 3625 | |
| 3626 | /** |
| 3627 | * @brief WILC_WFI_WiphyFree |
| 3628 | * @details Freeing allocation of the wireless device structure |
| 3629 | * @param[in] NONE |
| 3630 | * @return NONE |
| 3631 | * @author mdaftedar |
| 3632 | * @date 01 MAR 2012 |
| 3633 | * @version 1.0 |
| 3634 | */ |
Chaehyun Lim | a9a1682 | 2015-09-20 15:51:24 +0900 | [diff] [blame] | 3635 | int wilc_deinit_host_int(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3636 | { |
Chaehyun Lim | 1a8ccd8 | 2015-09-20 15:51:23 +0900 | [diff] [blame] | 3637 | int s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3638 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3639 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 3640 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3641 | priv = wdev_priv(net->ieee80211_ptr); |
| 3642 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3643 | priv->gbAutoRateAdjusted = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3644 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3645 | priv->bInP2PlistenState = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3646 | |
| 3647 | op_ifcs--; |
| 3648 | |
| 3649 | s32Error = host_int_deinit(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3650 | |
| 3651 | /* Clear the Shadow scan */ |
| 3652 | clear_shadow_scan(priv); |
| 3653 | #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP |
| 3654 | if (op_ifcs == 0) { |
| 3655 | PRINT_D(CORECONFIG_DBG, "destroy during ip\n"); |
Greg Kroah-Hartman | 4183e97 | 2015-08-14 20:11:16 -0700 | [diff] [blame] | 3656 | del_timer_sync(&hDuringIpTimer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3657 | } |
| 3658 | #endif |
| 3659 | |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 3660 | if (s32Error) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3661 | PRINT_ER("Error while deintializing host interface\n"); |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 3662 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3663 | return s32Error; |
| 3664 | } |
| 3665 | |
| 3666 | |
| 3667 | /** |
| 3668 | * @brief WILC_WFI_WiphyFree |
| 3669 | * @details Freeing allocation of the wireless device structure |
| 3670 | * @param[in] NONE |
| 3671 | * @return NONE |
| 3672 | * @author mdaftedar |
| 3673 | * @date 01 MAR 2012 |
| 3674 | * @version 1.0 |
| 3675 | */ |
Chaehyun Lim | 96da20a | 2015-09-20 15:51:08 +0900 | [diff] [blame] | 3676 | void wilc_free_wiphy(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3677 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3678 | PRINT_D(CFG80211_DBG, "Unregistering wiphy\n"); |
| 3679 | |
Chaehyun Lim | 619837a | 2015-09-20 15:51:10 +0900 | [diff] [blame] | 3680 | if (!net) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3681 | PRINT_D(INIT_DBG, "net_device is NULL\n"); |
| 3682 | return; |
| 3683 | } |
| 3684 | |
Chaehyun Lim | 619837a | 2015-09-20 15:51:10 +0900 | [diff] [blame] | 3685 | if (!net->ieee80211_ptr) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3686 | PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n"); |
| 3687 | return; |
| 3688 | } |
| 3689 | |
Chaehyun Lim | 619837a | 2015-09-20 15:51:10 +0900 | [diff] [blame] | 3690 | if (!net->ieee80211_ptr->wiphy) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3691 | PRINT_D(INIT_DBG, "wiphy is NULL\n"); |
| 3692 | return; |
| 3693 | } |
| 3694 | |
| 3695 | wiphy_unregister(net->ieee80211_ptr->wiphy); |
| 3696 | |
| 3697 | PRINT_D(INIT_DBG, "Freeing wiphy\n"); |
| 3698 | wiphy_free(net->ieee80211_ptr->wiphy); |
| 3699 | kfree(net->ieee80211_ptr); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3700 | } |