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