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