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