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