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