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