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