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