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