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