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; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 365 | if (priv->bCfgScanning == true) { |
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 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 393 | if (pstrNetworkInfo->bNewNetwork == true) { |
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*/ |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 549 | u16 u16ConnectStatus = WLAN_STATUS_SUCCESS; |
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*/ |
| 627 | if ((pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) { |
| 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*/ |
| 632 | else if ((!pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) { |
| 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)*/ |
| 1258 | if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) { |
| 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)*/ |
| 1294 | if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) { |
| 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*/ |
| 1359 | if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) { |
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 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1949 | if (priv->bCfgScanning == true && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 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 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2361 | if (priv->bInP2PlistenState == false) { |
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*/ |
| 2421 | if (!g_linux_wlan->wilc1000_initialized) { |
| 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 | */ |
Tony Cho | f61c5af | 2015-10-14 20:46:30 +0900 | [diff] [blame] | 2526 | void wilc1000_wlan_deinit(struct wilc *nic); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2527 | int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic); |
| 2528 | |
Chaehyun Lim | 3615e9a | 2015-09-14 12:24:11 +0900 | [diff] [blame] | 2529 | static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, |
| 2530 | enum nl80211_iftype type, u32 *flags, struct vif_params *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2531 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2532 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2533 | perInterface_wlan_t *nic; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2534 | u8 interface_type; |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 2535 | u16 TID = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2536 | u8 i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2537 | |
| 2538 | nic = netdev_priv(dev); |
| 2539 | priv = wiphy_priv(wiphy); |
| 2540 | |
| 2541 | PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n"); |
| 2542 | PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name); |
| 2543 | u8P2Plocalrandom = 0x01; |
| 2544 | u8P2Precvrandom = 0x00; |
| 2545 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2546 | bWilc_ie = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2547 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2548 | g_obtainingIP = false; |
Greg Kroah-Hartman | 8972d0f | 2015-08-14 20:04:13 -0700 | [diff] [blame] | 2549 | del_timer(&hDuringIpTimer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2550 | PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2551 | /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/ |
| 2552 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2553 | Set_machw_change_vir_if(true); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2554 | } |
| 2555 | |
| 2556 | switch (type) { |
| 2557 | case NL80211_IFTYPE_STATION: |
| 2558 | connecting = 0; |
| 2559 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2560 | |
| 2561 | /* send delba over wlan interface */ |
| 2562 | |
| 2563 | |
| 2564 | dev->ieee80211_ptr->iftype = type; |
| 2565 | priv->wdev->iftype = type; |
| 2566 | nic->monitor_flag = 0; |
| 2567 | nic->iftype = STATION_MODE; |
| 2568 | |
| 2569 | /*Remove the enteries of the previously connected clients*/ |
| 2570 | memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2571 | interface_type = nic->iftype; |
| 2572 | nic->iftype = STATION_MODE; |
| 2573 | |
| 2574 | if (g_linux_wlan->wilc1000_initialized) { |
| 2575 | host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID); |
| 2576 | /* ensure that the message Q is empty */ |
| 2577 | host_int_wait_msg_queue_idle(); |
| 2578 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2579 | /*Eliminate host interface blocking state*/ |
Greg Kroah-Hartman | 8990d85 | 2015-09-03 20:07:58 -0700 | [diff] [blame] | 2580 | up(&g_linux_wlan->cfg_event); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2581 | |
| 2582 | wilc1000_wlan_deinit(g_linux_wlan); |
| 2583 | wilc1000_wlan_init(dev, nic); |
| 2584 | g_wilc_initialized = 1; |
| 2585 | nic->iftype = interface_type; |
| 2586 | |
| 2587 | /*Setting interface 1 drv handler and mac address in newly downloaded FW*/ |
| 2588 | host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler); |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2589 | host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2590 | g_linux_wlan->strInterfaceInfo[0].aSrcAddress); |
| 2591 | host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE); |
| 2592 | |
| 2593 | /*Add saved WEP keys, if any*/ |
| 2594 | if (g_wep_keys_saved) { |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2595 | host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2596 | g_key_wep_params.key_idx); |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2597 | host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2598 | g_key_wep_params.key, |
| 2599 | g_key_wep_params.key_len, |
| 2600 | g_key_wep_params.key_idx); |
| 2601 | } |
| 2602 | |
| 2603 | /*No matter the driver handler passed here, it will be overwriiten*/ |
| 2604 | /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/ |
| 2605 | host_int_flush_join_req(priv->hWILCWFIDrv); |
| 2606 | |
| 2607 | /*Add saved PTK and GTK keys, if any*/ |
| 2608 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
| 2609 | PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0], |
| 2610 | g_key_ptk_params.key[1], |
| 2611 | g_key_ptk_params.key[2]); |
| 2612 | PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0], |
| 2613 | g_key_gtk_params.key[1], |
| 2614 | g_key_gtk_params.key[2]); |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2615 | add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, |
| 2616 | g_linux_wlan->strInterfaceInfo[0].wilc_netdev, |
| 2617 | g_add_ptk_key_params.key_idx, |
| 2618 | g_add_ptk_key_params.pairwise, |
| 2619 | g_add_ptk_key_params.mac_addr, |
| 2620 | (struct key_params *)(&g_key_ptk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2621 | |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2622 | add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, |
| 2623 | g_linux_wlan->strInterfaceInfo[0].wilc_netdev, |
| 2624 | g_add_gtk_key_params.key_idx, |
| 2625 | g_add_gtk_key_params.pairwise, |
| 2626 | g_add_gtk_key_params.mac_addr, |
| 2627 | (struct key_params *)(&g_key_gtk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2628 | } |
| 2629 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2630 | if (g_linux_wlan->wilc1000_initialized) { |
| 2631 | for (i = 0; i < num_reg_frame; i++) { |
| 2632 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2633 | nic->g_struct_frame_reg[i].reg); |
| 2634 | host_int_frame_register(priv->hWILCWFIDrv, |
| 2635 | nic->g_struct_frame_reg[i].frame_type, |
| 2636 | nic->g_struct_frame_reg[i].reg); |
| 2637 | } |
| 2638 | } |
| 2639 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2640 | bEnablePS = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2641 | host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0); |
| 2642 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2643 | break; |
| 2644 | |
| 2645 | case NL80211_IFTYPE_P2P_CLIENT: |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2646 | bEnablePS = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2647 | host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0); |
| 2648 | connecting = 0; |
| 2649 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2650 | |
| 2651 | host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID); |
| 2652 | |
| 2653 | dev->ieee80211_ptr->iftype = type; |
| 2654 | priv->wdev->iftype = type; |
| 2655 | nic->monitor_flag = 0; |
| 2656 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2657 | PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n"); |
| 2658 | nic->iftype = CLIENT_MODE; |
| 2659 | |
| 2660 | |
| 2661 | if (g_linux_wlan->wilc1000_initialized) { |
| 2662 | /* ensure that the message Q is empty */ |
| 2663 | host_int_wait_msg_queue_idle(); |
| 2664 | |
| 2665 | wilc1000_wlan_deinit(g_linux_wlan); |
| 2666 | wilc1000_wlan_init(dev, nic); |
| 2667 | g_wilc_initialized = 1; |
| 2668 | |
| 2669 | host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler); |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2670 | host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2671 | g_linux_wlan->strInterfaceInfo[0].aSrcAddress); |
| 2672 | host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE); |
| 2673 | |
| 2674 | /*Add saved WEP keys, if any*/ |
| 2675 | if (g_wep_keys_saved) { |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2676 | host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2677 | g_key_wep_params.key_idx); |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2678 | host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2679 | g_key_wep_params.key, |
| 2680 | g_key_wep_params.key_len, |
| 2681 | g_key_wep_params.key_idx); |
| 2682 | } |
| 2683 | |
| 2684 | /*No matter the driver handler passed here, it will be overwriiten*/ |
| 2685 | /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/ |
| 2686 | host_int_flush_join_req(priv->hWILCWFIDrv); |
| 2687 | |
| 2688 | /*Add saved PTK and GTK keys, if any*/ |
| 2689 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
| 2690 | PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0], |
| 2691 | g_key_ptk_params.key[1], |
| 2692 | g_key_ptk_params.key[2]); |
| 2693 | PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0], |
| 2694 | g_key_gtk_params.key[1], |
| 2695 | g_key_gtk_params.key[2]); |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2696 | add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, |
| 2697 | g_linux_wlan->strInterfaceInfo[0].wilc_netdev, |
| 2698 | g_add_ptk_key_params.key_idx, |
| 2699 | g_add_ptk_key_params.pairwise, |
| 2700 | g_add_ptk_key_params.mac_addr, |
| 2701 | (struct key_params *)(&g_key_ptk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2702 | |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2703 | add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, |
| 2704 | g_linux_wlan->strInterfaceInfo[0].wilc_netdev, |
| 2705 | g_add_gtk_key_params.key_idx, |
| 2706 | g_add_gtk_key_params.pairwise, |
| 2707 | g_add_gtk_key_params.mac_addr, |
| 2708 | (struct key_params *)(&g_key_gtk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2709 | } |
| 2710 | |
| 2711 | /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/ |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2712 | refresh_scan(priv, 1, true); |
| 2713 | Set_machw_change_vir_if(false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2714 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2715 | if (g_linux_wlan->wilc1000_initialized) { |
| 2716 | for (i = 0; i < num_reg_frame; i++) { |
| 2717 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2718 | nic->g_struct_frame_reg[i].reg); |
| 2719 | host_int_frame_register(priv->hWILCWFIDrv, |
| 2720 | nic->g_struct_frame_reg[i].frame_type, |
| 2721 | nic->g_struct_frame_reg[i].reg); |
| 2722 | } |
| 2723 | } |
| 2724 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2725 | break; |
| 2726 | |
| 2727 | case NL80211_IFTYPE_AP: |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2728 | bEnablePS = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2729 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2730 | dev->ieee80211_ptr->iftype = type; |
| 2731 | priv->wdev->iftype = type; |
| 2732 | nic->iftype = AP_MODE; |
Johnny Kim | 8a14330 | 2015-06-10 17:06:46 +0900 | [diff] [blame] | 2733 | PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2734 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2735 | PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n"); |
| 2736 | linux_wlan_get_firmware(nic); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2737 | /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/ |
| 2738 | if (g_linux_wlan->wilc1000_initialized) { |
| 2739 | nic->iftype = AP_MODE; |
| 2740 | g_linux_wlan->wilc1000_initialized = 1; |
| 2741 | mac_close(dev); |
| 2742 | mac_open(dev); |
| 2743 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2744 | for (i = 0; i < num_reg_frame; i++) { |
| 2745 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2746 | nic->g_struct_frame_reg[i].reg); |
| 2747 | host_int_frame_register(priv->hWILCWFIDrv, |
| 2748 | nic->g_struct_frame_reg[i].frame_type, |
| 2749 | nic->g_struct_frame_reg[i].reg); |
| 2750 | } |
| 2751 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2752 | break; |
| 2753 | |
| 2754 | case NL80211_IFTYPE_P2P_GO: |
| 2755 | PRINT_D(GENERIC_DBG, "start duringIP timer\n"); |
| 2756 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2757 | g_obtainingIP = true; |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 2758 | mod_timer(&hDuringIpTimer, jiffies + msecs_to_jiffies(duringIP_TIME)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2759 | host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2760 | /*Delete block ack has to be the latest config packet*/ |
| 2761 | /*sent before downloading new FW. This is because it blocks on*/ |
| 2762 | /*hWaitResponse semaphore, which allows previous config*/ |
| 2763 | /*packets to actually take action on old FW*/ |
| 2764 | host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2765 | bEnablePS = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2766 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2767 | dev->ieee80211_ptr->iftype = type; |
| 2768 | priv->wdev->iftype = type; |
| 2769 | |
Johnny Kim | 8a14330 | 2015-06-10 17:06:46 +0900 | [diff] [blame] | 2770 | PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2771 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2772 | PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n"); |
| 2773 | |
| 2774 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2775 | nic->iftype = GO_MODE; |
| 2776 | |
| 2777 | /* ensure that the message Q is empty */ |
| 2778 | host_int_wait_msg_queue_idle(); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2779 | wilc1000_wlan_deinit(g_linux_wlan); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2780 | wilc1000_wlan_init(dev, nic); |
| 2781 | g_wilc_initialized = 1; |
| 2782 | |
| 2783 | |
| 2784 | /*Setting interface 1 drv handler and mac address in newly downloaded FW*/ |
| 2785 | host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler); |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2786 | host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2787 | g_linux_wlan->strInterfaceInfo[0].aSrcAddress); |
| 2788 | host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE); |
| 2789 | |
| 2790 | /*Add saved WEP keys, if any*/ |
| 2791 | if (g_wep_keys_saved) { |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2792 | host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2793 | g_key_wep_params.key_idx); |
Johnny Kim | 218dc40 | 2015-08-13 13:41:19 +0900 | [diff] [blame] | 2794 | host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2795 | g_key_wep_params.key, |
| 2796 | g_key_wep_params.key_len, |
| 2797 | g_key_wep_params.key_idx); |
| 2798 | } |
| 2799 | |
| 2800 | /*No matter the driver handler passed here, it will be overwriiten*/ |
| 2801 | /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/ |
| 2802 | host_int_flush_join_req(priv->hWILCWFIDrv); |
| 2803 | |
| 2804 | /*Add saved PTK and GTK keys, if any*/ |
| 2805 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
| 2806 | PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0], |
| 2807 | g_key_ptk_params.key[1], |
| 2808 | g_key_ptk_params.key[2], |
| 2809 | g_key_ptk_params.cipher); |
| 2810 | PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0], |
| 2811 | g_key_gtk_params.key[1], |
| 2812 | g_key_gtk_params.key[2], |
| 2813 | g_key_gtk_params.cipher); |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2814 | add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, |
| 2815 | g_linux_wlan->strInterfaceInfo[0].wilc_netdev, |
| 2816 | g_add_ptk_key_params.key_idx, |
| 2817 | g_add_ptk_key_params.pairwise, |
| 2818 | g_add_ptk_key_params.mac_addr, |
| 2819 | (struct key_params *)(&g_key_ptk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2820 | |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2821 | add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy, |
| 2822 | g_linux_wlan->strInterfaceInfo[0].wilc_netdev, |
| 2823 | g_add_gtk_key_params.key_idx, |
| 2824 | g_add_gtk_key_params.pairwise, |
| 2825 | g_add_gtk_key_params.mac_addr, |
| 2826 | (struct key_params *)(&g_key_gtk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2827 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2828 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2829 | if (g_linux_wlan->wilc1000_initialized) { |
| 2830 | for (i = 0; i < num_reg_frame; i++) { |
| 2831 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2832 | nic->g_struct_frame_reg[i].reg); |
| 2833 | host_int_frame_register(priv->hWILCWFIDrv, |
| 2834 | nic->g_struct_frame_reg[i].frame_type, |
| 2835 | nic->g_struct_frame_reg[i].reg); |
| 2836 | } |
| 2837 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2838 | break; |
| 2839 | |
| 2840 | default: |
| 2841 | PRINT_ER("Unknown interface type= %d\n", type); |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 2842 | return -EINVAL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2843 | } |
| 2844 | |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 2845 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2846 | } |
| 2847 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2848 | /* (austin.2013-07-23) |
| 2849 | * |
| 2850 | * To support revised cfg80211_ops |
| 2851 | * |
| 2852 | * add_beacon --> start_ap |
| 2853 | * set_beacon --> change_beacon |
| 2854 | * del_beacon --> stop_ap |
| 2855 | * |
| 2856 | * beacon_parameters --> cfg80211_ap_settings |
| 2857 | * cfg80211_beacon_data |
| 2858 | * |
| 2859 | * applicable for linux kernel 3.4+ |
| 2860 | */ |
| 2861 | |
| 2862 | /** |
Chaehyun Lim | a13168d | 2015-09-14 12:24:12 +0900 | [diff] [blame] | 2863 | * @brief start_ap |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2864 | * @details Add a beacon with given parameters, @head, @interval |
| 2865 | * and @dtim_period will be valid, @tail is optional. |
| 2866 | * @param[in] wiphy |
| 2867 | * @param[in] dev The net device structure |
| 2868 | * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added |
| 2869 | * @return int : Return 0 on Success. |
| 2870 | * @author austin |
| 2871 | * @date 23 JUL 2013 |
| 2872 | * @version 1.0 |
| 2873 | */ |
Chaehyun Lim | a13168d | 2015-09-14 12:24:12 +0900 | [diff] [blame] | 2874 | static int start_ap(struct wiphy *wiphy, struct net_device *dev, |
| 2875 | struct cfg80211_ap_settings *settings) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2876 | { |
| 2877 | struct cfg80211_beacon_data *beacon = &(settings->beacon); |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2878 | struct wilc_priv *priv; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2879 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2880 | |
| 2881 | priv = wiphy_priv(wiphy); |
| 2882 | PRINT_D(HOSTAPD_DBG, "Starting ap\n"); |
| 2883 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 2884 | 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] | 2885 | settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len); |
| 2886 | |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 2887 | s32Error = set_channel(wiphy, &settings->chandef); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2888 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2889 | if (s32Error != 0) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2890 | PRINT_ER("Error in setting channel\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2891 | |
| 2892 | linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress); |
| 2893 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2894 | s32Error = host_int_add_beacon(priv->hWILCWFIDrv, |
| 2895 | settings->beacon_interval, |
| 2896 | settings->dtim_period, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2897 | beacon->head_len, (u8 *)beacon->head, |
| 2898 | beacon->tail_len, (u8 *)beacon->tail); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2899 | |
| 2900 | return s32Error; |
| 2901 | } |
| 2902 | |
| 2903 | /** |
Chaehyun Lim | 2a4c84d | 2015-09-14 12:24:13 +0900 | [diff] [blame] | 2904 | * @brief change_beacon |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2905 | * @details Add a beacon with given parameters, @head, @interval |
| 2906 | * and @dtim_period will be valid, @tail is optional. |
| 2907 | * @param[in] wiphy |
| 2908 | * @param[in] dev The net device structure |
| 2909 | * @param[in] beacon cfg80211_beacon_data for the beacon to be changed |
| 2910 | * @return int : Return 0 on Success. |
| 2911 | * @author austin |
| 2912 | * @date 23 JUL 2013 |
| 2913 | * @version 1.0 |
| 2914 | */ |
Chaehyun Lim | 2a4c84d | 2015-09-14 12:24:13 +0900 | [diff] [blame] | 2915 | static int change_beacon(struct wiphy *wiphy, struct net_device *dev, |
| 2916 | struct cfg80211_beacon_data *beacon) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2917 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2918 | struct wilc_priv *priv; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2919 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2920 | |
| 2921 | priv = wiphy_priv(wiphy); |
| 2922 | PRINT_D(HOSTAPD_DBG, "Setting beacon\n"); |
| 2923 | |
| 2924 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2925 | s32Error = host_int_add_beacon(priv->hWILCWFIDrv, |
| 2926 | 0, |
| 2927 | 0, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2928 | beacon->head_len, (u8 *)beacon->head, |
| 2929 | beacon->tail_len, (u8 *)beacon->tail); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2930 | |
| 2931 | return s32Error; |
| 2932 | } |
| 2933 | |
| 2934 | /** |
Chaehyun Lim | c8cddd7 | 2015-09-14 12:24:14 +0900 | [diff] [blame] | 2935 | * @brief stop_ap |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2936 | * @details Remove beacon configuration and stop sending the beacon. |
| 2937 | * @param[in] |
| 2938 | * @return int : Return 0 on Success. |
| 2939 | * @author austin |
| 2940 | * @date 23 JUL 2013 |
| 2941 | * @version 1.0 |
| 2942 | */ |
Chaehyun Lim | c8cddd7 | 2015-09-14 12:24:14 +0900 | [diff] [blame] | 2943 | static int stop_ap(struct wiphy *wiphy, struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2944 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2945 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2946 | struct wilc_priv *priv; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2947 | u8 NullBssid[ETH_ALEN] = {0}; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2948 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 2949 | if (!wiphy) |
| 2950 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2951 | |
| 2952 | priv = wiphy_priv(wiphy); |
| 2953 | |
| 2954 | PRINT_D(HOSTAPD_DBG, "Deleting beacon\n"); |
| 2955 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2956 | linux_wlan_set_bssid(dev, NullBssid); |
| 2957 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2958 | s32Error = host_int_del_beacon(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2959 | |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 2960 | if (s32Error) |
| 2961 | PRINT_ER("Host delete beacon fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2962 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2963 | return s32Error; |
| 2964 | } |
| 2965 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2966 | /** |
Chaehyun Lim | ed26955 | 2015-09-14 12:24:15 +0900 | [diff] [blame] | 2967 | * @brief add_station |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2968 | * @details Add a new station. |
| 2969 | * @param[in] |
| 2970 | * @return int : Return 0 on Success. |
| 2971 | * @author mdaftedar |
| 2972 | * @date 01 MAR 2012 |
| 2973 | * @version 1.0 |
| 2974 | */ |
Chaehyun Lim | ed26955 | 2015-09-14 12:24:15 +0900 | [diff] [blame] | 2975 | static int add_station(struct wiphy *wiphy, struct net_device *dev, |
| 2976 | const u8 *mac, struct station_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2977 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2978 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2979 | struct wilc_priv *priv; |
Tony Cho | 6a89ba9 | 2015-09-21 12:16:46 +0900 | [diff] [blame] | 2980 | struct add_sta_param strStaParams = { {0} }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2981 | perInterface_wlan_t *nic; |
| 2982 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 2983 | if (!wiphy) |
| 2984 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2985 | |
| 2986 | priv = wiphy_priv(wiphy); |
| 2987 | nic = netdev_priv(dev); |
| 2988 | |
| 2989 | if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 2990 | memcpy(strStaParams.au8BSSID, mac, ETH_ALEN); |
| 2991 | memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2992 | strStaParams.u16AssocID = params->aid; |
| 2993 | strStaParams.u8NumRates = params->supported_rates_len; |
| 2994 | strStaParams.pu8Rates = params->supported_rates; |
| 2995 | |
| 2996 | PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid); |
| 2997 | |
| 2998 | 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], |
| 2999 | priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]); |
| 3000 | PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID); |
| 3001 | PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates); |
| 3002 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 3003 | if (params->ht_capa == NULL) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3004 | strStaParams.bIsHTSupported = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3005 | } else { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3006 | strStaParams.bIsHTSupported = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3007 | strStaParams.u16HTCapInfo = params->ht_capa->cap_info; |
| 3008 | strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 3009 | memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3010 | strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info; |
| 3011 | strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info; |
| 3012 | strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info; |
| 3013 | } |
| 3014 | |
| 3015 | strStaParams.u16FlagsMask = params->sta_flags_mask; |
| 3016 | strStaParams.u16FlagsSet = params->sta_flags_set; |
| 3017 | |
| 3018 | PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported); |
| 3019 | PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo); |
| 3020 | PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams); |
| 3021 | PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams); |
| 3022 | PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap); |
| 3023 | PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap); |
| 3024 | PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask); |
| 3025 | PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet); |
| 3026 | |
| 3027 | s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams); |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 3028 | if (s32Error) |
| 3029 | PRINT_ER("Host add station fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3030 | } |
| 3031 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3032 | return s32Error; |
| 3033 | } |
| 3034 | |
| 3035 | /** |
Chaehyun Lim | a0a8be9 | 2015-09-14 12:24:16 +0900 | [diff] [blame] | 3036 | * @brief del_station |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3037 | * @details Remove a station; @mac may be NULL to remove all stations. |
| 3038 | * @param[in] |
| 3039 | * @return int : Return 0 on Success. |
| 3040 | * @author mdaftedar |
| 3041 | * @date 01 MAR 2012 |
| 3042 | * @version 1.0 |
| 3043 | */ |
Chaehyun Lim | a0a8be9 | 2015-09-14 12:24:16 +0900 | [diff] [blame] | 3044 | static int del_station(struct wiphy *wiphy, struct net_device *dev, |
| 3045 | struct station_del_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3046 | { |
Arnd Bergmann | 057d1e9 | 2015-06-01 21:06:44 +0200 | [diff] [blame] | 3047 | const u8 *mac = params->mac; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3048 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3049 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3050 | perInterface_wlan_t *nic; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 3051 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 3052 | if (!wiphy) |
| 3053 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3054 | |
| 3055 | priv = wiphy_priv(wiphy); |
| 3056 | nic = netdev_priv(dev); |
| 3057 | |
| 3058 | if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { |
| 3059 | PRINT_D(HOSTAPD_DBG, "Deleting station\n"); |
| 3060 | |
| 3061 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 3062 | if (mac == NULL) { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 3063 | PRINT_D(HOSTAPD_DBG, "All associated stations\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3064 | s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss); |
| 3065 | } else { |
| 3066 | 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]); |
| 3067 | } |
| 3068 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3069 | s32Error = host_int_del_station(priv->hWILCWFIDrv, mac); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3070 | |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 3071 | if (s32Error) |
| 3072 | PRINT_ER("Host delete station fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3073 | } |
| 3074 | return s32Error; |
| 3075 | } |
| 3076 | |
| 3077 | /** |
Chaehyun Lim | 14b4208 | 2015-09-14 12:24:17 +0900 | [diff] [blame] | 3078 | * @brief change_station |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3079 | * @details Modify a given station. |
| 3080 | * @param[in] |
| 3081 | * @return int : Return 0 on Success. |
| 3082 | * @author mdaftedar |
| 3083 | * @date 01 MAR 2012 |
| 3084 | * @version 1.0 |
| 3085 | */ |
Chaehyun Lim | 14b4208 | 2015-09-14 12:24:17 +0900 | [diff] [blame] | 3086 | static int change_station(struct wiphy *wiphy, struct net_device *dev, |
| 3087 | const u8 *mac, struct station_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3088 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3089 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3090 | struct wilc_priv *priv; |
Tony Cho | 6a89ba9 | 2015-09-21 12:16:46 +0900 | [diff] [blame] | 3091 | struct add_sta_param strStaParams = { {0} }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3092 | perInterface_wlan_t *nic; |
| 3093 | |
| 3094 | |
| 3095 | PRINT_D(HOSTAPD_DBG, "Change station paramters\n"); |
| 3096 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 3097 | if (!wiphy) |
| 3098 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3099 | |
| 3100 | priv = wiphy_priv(wiphy); |
| 3101 | nic = netdev_priv(dev); |
| 3102 | |
| 3103 | if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 3104 | memcpy(strStaParams.au8BSSID, mac, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3105 | strStaParams.u16AssocID = params->aid; |
| 3106 | strStaParams.u8NumRates = params->supported_rates_len; |
| 3107 | strStaParams.pu8Rates = params->supported_rates; |
| 3108 | |
| 3109 | 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], |
| 3110 | strStaParams.au8BSSID[5]); |
| 3111 | PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID); |
| 3112 | PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates); |
| 3113 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 3114 | if (params->ht_capa == NULL) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3115 | strStaParams.bIsHTSupported = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3116 | } else { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3117 | strStaParams.bIsHTSupported = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3118 | strStaParams.u16HTCapInfo = params->ht_capa->cap_info; |
| 3119 | strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 3120 | memcpy(strStaParams.au8SuppMCsSet, ¶ms->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3121 | strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info; |
| 3122 | strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info; |
| 3123 | strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info; |
| 3124 | |
| 3125 | } |
| 3126 | |
| 3127 | strStaParams.u16FlagsMask = params->sta_flags_mask; |
| 3128 | strStaParams.u16FlagsSet = params->sta_flags_set; |
| 3129 | |
| 3130 | PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported); |
| 3131 | PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo); |
| 3132 | PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams); |
| 3133 | PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams); |
| 3134 | PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap); |
| 3135 | PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap); |
| 3136 | PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask); |
| 3137 | PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet); |
| 3138 | |
| 3139 | s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams); |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 3140 | if (s32Error) |
| 3141 | PRINT_ER("Host edit station fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3142 | } |
| 3143 | return s32Error; |
| 3144 | } |
| 3145 | |
| 3146 | |
| 3147 | /** |
Chaehyun Lim | 69deb4c | 2015-09-14 12:24:09 +0900 | [diff] [blame] | 3148 | * @brief add_virtual_intf |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3149 | * @details |
| 3150 | * @param[in] |
| 3151 | * @return int : Return 0 on Success. |
| 3152 | * @author mdaftedar |
| 3153 | * @date 01 JUL 2012 |
| 3154 | * @version 1.0 |
| 3155 | */ |
Chaehyun Lim | 37316e8 | 2015-09-22 18:34:52 +0900 | [diff] [blame] | 3156 | static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, |
| 3157 | const char *name, |
| 3158 | unsigned char name_assign_type, |
| 3159 | enum nl80211_iftype type, |
| 3160 | u32 *flags, |
| 3161 | struct vif_params *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3162 | { |
| 3163 | perInterface_wlan_t *nic; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3164 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3165 | struct net_device *new_ifc = NULL; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 3166 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3167 | priv = wiphy_priv(wiphy); |
| 3168 | |
| 3169 | |
| 3170 | |
| 3171 | PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev); |
| 3172 | |
| 3173 | nic = netdev_priv(priv->wdev->netdev); |
| 3174 | |
| 3175 | |
| 3176 | if (type == NL80211_IFTYPE_MONITOR) { |
| 3177 | PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n"); |
| 3178 | PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev); |
| 3179 | new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev); |
| 3180 | if (new_ifc != NULL) { |
| 3181 | PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3182 | nic = netdev_priv(priv->wdev->netdev); |
| 3183 | nic->monitor_flag = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3184 | } else |
| 3185 | PRINT_ER("Error in initializing monitor interface\n "); |
| 3186 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3187 | return priv->wdev; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3188 | } |
| 3189 | |
| 3190 | /** |
Chaehyun Lim | b4a7335 | 2015-09-14 12:24:10 +0900 | [diff] [blame] | 3191 | * @brief del_virtual_intf |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3192 | * @details |
| 3193 | * @param[in] |
| 3194 | * @return int : Return 0 on Success. |
| 3195 | * @author mdaftedar |
| 3196 | * @date 01 JUL 2012 |
| 3197 | * @version 1.0 |
| 3198 | */ |
Chaehyun Lim | 956d721 | 2015-09-22 18:34:49 +0900 | [diff] [blame] | 3199 | static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3200 | { |
| 3201 | PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n"); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3202 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3203 | } |
| 3204 | |
Chaehyun Lim | 0824192 | 2015-09-15 14:06:12 +0900 | [diff] [blame] | 3205 | static struct cfg80211_ops wilc_cfg80211_ops = { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3206 | |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 3207 | .set_monitor_channel = set_channel, |
Chaehyun Lim | 0e30d06 | 2015-09-14 12:24:02 +0900 | [diff] [blame] | 3208 | .scan = scan, |
Chaehyun Lim | 4ffbcdb | 2015-09-14 12:24:03 +0900 | [diff] [blame] | 3209 | .connect = connect, |
Chaehyun Lim | b027cde | 2015-09-14 12:24:04 +0900 | [diff] [blame] | 3210 | .disconnect = disconnect, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 3211 | .add_key = add_key, |
Chaehyun Lim | 3044ba7 | 2015-09-14 12:24:06 +0900 | [diff] [blame] | 3212 | .del_key = del_key, |
Chaehyun Lim | f4893df | 2015-09-14 12:24:07 +0900 | [diff] [blame] | 3213 | .get_key = get_key, |
Chaehyun Lim | 0f5b8ca | 2015-09-14 12:24:08 +0900 | [diff] [blame] | 3214 | .set_default_key = set_default_key, |
Chaehyun Lim | 69deb4c | 2015-09-14 12:24:09 +0900 | [diff] [blame] | 3215 | .add_virtual_intf = add_virtual_intf, |
Chaehyun Lim | b4a7335 | 2015-09-14 12:24:10 +0900 | [diff] [blame] | 3216 | .del_virtual_intf = del_virtual_intf, |
Chaehyun Lim | 3615e9a | 2015-09-14 12:24:11 +0900 | [diff] [blame] | 3217 | .change_virtual_intf = change_virtual_intf, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3218 | |
Chaehyun Lim | a13168d | 2015-09-14 12:24:12 +0900 | [diff] [blame] | 3219 | .start_ap = start_ap, |
Chaehyun Lim | 2a4c84d | 2015-09-14 12:24:13 +0900 | [diff] [blame] | 3220 | .change_beacon = change_beacon, |
Chaehyun Lim | c8cddd7 | 2015-09-14 12:24:14 +0900 | [diff] [blame] | 3221 | .stop_ap = stop_ap, |
Chaehyun Lim | ed26955 | 2015-09-14 12:24:15 +0900 | [diff] [blame] | 3222 | .add_station = add_station, |
Chaehyun Lim | a0a8be9 | 2015-09-14 12:24:16 +0900 | [diff] [blame] | 3223 | .del_station = del_station, |
Chaehyun Lim | 14b4208 | 2015-09-14 12:24:17 +0900 | [diff] [blame] | 3224 | .change_station = change_station, |
Chaehyun Lim | f06f562 | 2015-09-14 12:24:18 +0900 | [diff] [blame] | 3225 | .get_station = get_station, |
Chaehyun Lim | bdb6338 | 2015-09-14 12:24:19 +0900 | [diff] [blame] | 3226 | .dump_station = dump_station, |
Chaehyun Lim | a5f7db6 | 2015-09-14 12:24:20 +0900 | [diff] [blame] | 3227 | .change_bss = change_bss, |
Chaehyun Lim | a76b63e | 2015-09-14 12:24:21 +0900 | [diff] [blame] | 3228 | .set_wiphy_params = set_wiphy_params, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3229 | |
Chaehyun Lim | 4d46657 | 2015-09-14 12:24:22 +0900 | [diff] [blame] | 3230 | .set_pmksa = set_pmksa, |
Chaehyun Lim | 1ff86d9 | 2015-09-14 12:24:23 +0900 | [diff] [blame] | 3231 | .del_pmksa = del_pmksa, |
Chaehyun Lim | b33c39b | 2015-09-14 12:24:24 +0900 | [diff] [blame] | 3232 | .flush_pmksa = flush_pmksa, |
Chaehyun Lim | 6d19d69 | 2015-09-14 12:24:25 +0900 | [diff] [blame] | 3233 | .remain_on_channel = remain_on_channel, |
Chaehyun Lim | 1dd5440 | 2015-09-14 12:24:26 +0900 | [diff] [blame] | 3234 | .cancel_remain_on_channel = cancel_remain_on_channel, |
Chaehyun Lim | 4a2f9b3 | 2015-09-14 12:24:27 +0900 | [diff] [blame] | 3235 | .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait, |
Chaehyun Lim | 12a26a3 | 2015-09-14 12:24:28 +0900 | [diff] [blame] | 3236 | .mgmt_tx = mgmt_tx, |
Chaehyun Lim | 8e0735c | 2015-09-20 15:51:16 +0900 | [diff] [blame] | 3237 | .mgmt_frame_register = wilc_mgmt_frame_register, |
Chaehyun Lim | 4653067 | 2015-09-22 18:34:46 +0900 | [diff] [blame] | 3238 | .set_power_mgmt = set_power_mgmt, |
Chaehyun Lim | a8047e2 | 2015-09-22 18:34:48 +0900 | [diff] [blame] | 3239 | .set_cqm_rssi_config = set_cqm_rssi_config, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3240 | |
| 3241 | }; |
| 3242 | |
| 3243 | |
| 3244 | |
| 3245 | |
| 3246 | |
| 3247 | /** |
| 3248 | * @brief WILC_WFI_update_stats |
| 3249 | * @details Modify parameters for a given BSS. |
| 3250 | * @param[in] |
| 3251 | * @return int : Return 0 on Success. |
| 3252 | * @author mdaftedar |
| 3253 | * @date 01 MAR 2012 |
Chaehyun Lim | cdc9cba | 2015-09-22 18:34:47 +0900 | [diff] [blame] | 3254 | * @version 1.0 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3255 | */ |
| 3256 | int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed) |
| 3257 | { |
| 3258 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3259 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3260 | |
| 3261 | priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3262 | switch (changed) { |
| 3263 | |
| 3264 | case WILC_WFI_RX_PKT: |
| 3265 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3266 | priv->netstats.rx_packets++; |
| 3267 | priv->netstats.rx_bytes += pktlen; |
| 3268 | priv->netstats.rx_time = get_jiffies_64(); |
| 3269 | } |
| 3270 | break; |
| 3271 | |
| 3272 | case WILC_WFI_TX_PKT: |
| 3273 | { |
| 3274 | priv->netstats.tx_packets++; |
| 3275 | priv->netstats.tx_bytes += pktlen; |
| 3276 | priv->netstats.tx_time = get_jiffies_64(); |
| 3277 | |
| 3278 | } |
| 3279 | break; |
| 3280 | |
| 3281 | default: |
| 3282 | break; |
| 3283 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3284 | return 0; |
| 3285 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3286 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3287 | /** |
| 3288 | * @brief WILC_WFI_CfgAlloc |
| 3289 | * @details Allocation of the wireless device structure and assigning it |
| 3290 | * to the cfg80211 operations structure. |
| 3291 | * @param[in] NONE |
| 3292 | * @return wireless_dev : Returns pointer to wireless_dev structure. |
| 3293 | * @author mdaftedar |
| 3294 | * @date 01 MAR 2012 |
| 3295 | * @version 1.0 |
| 3296 | */ |
| 3297 | struct wireless_dev *WILC_WFI_CfgAlloc(void) |
| 3298 | { |
| 3299 | |
| 3300 | struct wireless_dev *wdev; |
| 3301 | |
| 3302 | |
| 3303 | PRINT_D(CFG80211_DBG, "Allocating wireless device\n"); |
| 3304 | /*Allocating the wireless device structure*/ |
| 3305 | wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); |
| 3306 | if (!wdev) { |
| 3307 | PRINT_ER("Cannot allocate wireless device\n"); |
| 3308 | goto _fail_; |
| 3309 | } |
| 3310 | |
| 3311 | /*Creating a new wiphy, linking wireless structure with the wiphy structure*/ |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3312 | wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3313 | if (!wdev->wiphy) { |
| 3314 | PRINT_ER("Cannot allocate wiphy\n"); |
| 3315 | goto _fail_mem_; |
| 3316 | |
| 3317 | } |
| 3318 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3319 | /* enable 802.11n HT */ |
| 3320 | WILC_WFI_band_2ghz.ht_cap.ht_supported = 1; |
| 3321 | WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT); |
| 3322 | WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff; |
| 3323 | WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K; |
| 3324 | 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] | 3325 | |
| 3326 | /*wiphy bands*/ |
| 3327 | wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz; |
| 3328 | |
| 3329 | return wdev; |
| 3330 | |
| 3331 | _fail_mem_: |
| 3332 | kfree(wdev); |
| 3333 | _fail_: |
| 3334 | return NULL; |
| 3335 | |
| 3336 | } |
| 3337 | /** |
Chaehyun Lim | 8459fd5 | 2015-09-20 15:51:09 +0900 | [diff] [blame] | 3338 | * @brief wilc_create_wiphy |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3339 | * @details Registering of the wiphy structure and interface modes |
| 3340 | * @param[in] NONE |
| 3341 | * @return NONE |
| 3342 | * @author mdaftedar |
| 3343 | * @date 01 MAR 2012 |
| 3344 | * @version 1.0 |
| 3345 | */ |
Chaehyun Lim | 8459fd5 | 2015-09-20 15:51:09 +0900 | [diff] [blame] | 3346 | struct wireless_dev *wilc_create_wiphy(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3347 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3348 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3349 | struct wireless_dev *wdev; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3350 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3351 | |
| 3352 | PRINT_D(CFG80211_DBG, "Registering wifi device\n"); |
| 3353 | |
| 3354 | wdev = WILC_WFI_CfgAlloc(); |
| 3355 | if (wdev == NULL) { |
| 3356 | PRINT_ER("CfgAlloc Failed\n"); |
| 3357 | return NULL; |
| 3358 | } |
| 3359 | |
| 3360 | |
| 3361 | /*Return hardware description structure (wiphy)'s priv*/ |
| 3362 | priv = wdev_priv(wdev); |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 3363 | sema_init(&(priv->SemHandleUpdateStats), 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3364 | |
| 3365 | /*Link the wiphy with wireless structure*/ |
| 3366 | priv->wdev = wdev; |
| 3367 | |
| 3368 | /*Maximum number of probed ssid to be added by user for the scan request*/ |
| 3369 | wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3370 | /*Maximum number of pmkids to be cashed*/ |
| 3371 | wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS; |
| 3372 | 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] | 3373 | |
| 3374 | wdev->wiphy->max_scan_ie_len = 1000; |
| 3375 | |
| 3376 | /*signal strength in mBm (100*dBm) */ |
| 3377 | wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 3378 | |
| 3379 | /*Set the availaible cipher suites*/ |
| 3380 | wdev->wiphy->cipher_suites = cipher_suites; |
| 3381 | wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3382 | /*Setting default managment types: for register action frame: */ |
| 3383 | wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3384 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3385 | wdev->wiphy->max_remain_on_channel_duration = 500; |
| 3386 | /*Setting the wiphy interfcae mode and type before registering the wiphy*/ |
| 3387 | wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) | |
| 3388 | BIT(NL80211_IFTYPE_P2P_CLIENT); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3389 | wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3390 | wdev->iftype = NL80211_IFTYPE_STATION; |
| 3391 | |
| 3392 | |
| 3393 | |
| 3394 | PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n", |
| 3395 | wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type, |
| 3396 | wdev->wiphy->interface_modes, wdev->iftype); |
| 3397 | |
| 3398 | #ifdef WILC_SDIO |
Chaehyun Lim | cdc9cba | 2015-09-22 18:34:47 +0900 | [diff] [blame] | 3399 | set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3400 | #endif |
| 3401 | |
| 3402 | /*Register wiphy structure*/ |
| 3403 | s32Error = wiphy_register(wdev->wiphy); |
| 3404 | if (s32Error) { |
| 3405 | PRINT_ER("Cannot register wiphy device\n"); |
| 3406 | /*should define what action to be taken in such failure*/ |
| 3407 | } else { |
| 3408 | PRINT_D(CFG80211_DBG, "Successful Registering\n"); |
| 3409 | } |
| 3410 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3411 | priv->dev = net; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3412 | return wdev; |
| 3413 | |
| 3414 | |
| 3415 | } |
| 3416 | /** |
| 3417 | * @brief WILC_WFI_WiphyFree |
| 3418 | * @details Freeing allocation of the wireless device structure |
| 3419 | * @param[in] NONE |
| 3420 | * @return NONE |
| 3421 | * @author mdaftedar |
| 3422 | * @date 01 MAR 2012 |
| 3423 | * @version 1.0 |
| 3424 | */ |
Chaehyun Lim | dd4b6a8 | 2015-09-20 15:51:25 +0900 | [diff] [blame] | 3425 | int wilc_init_host_int(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3426 | { |
| 3427 | |
Chaehyun Lim | 1a8ccd8 | 2015-09-20 15:51:23 +0900 | [diff] [blame] | 3428 | int s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3429 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3430 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3431 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3432 | PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr); |
| 3433 | priv = wdev_priv(net->ieee80211_ptr); |
| 3434 | if (op_ifcs == 0) { |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 3435 | setup_timer(&hAgingTimer, remove_network_from_shadow, 0); |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 3436 | setup_timer(&hDuringIpTimer, clear_duringIP, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3437 | } |
| 3438 | op_ifcs++; |
| 3439 | if (s32Error < 0) { |
| 3440 | PRINT_ER("Failed to creat refresh Timer\n"); |
| 3441 | return s32Error; |
| 3442 | } |
| 3443 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3444 | priv->gbAutoRateAdjusted = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3445 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3446 | priv->bInP2PlistenState = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3447 | |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 3448 | sema_init(&(priv->hSemScanReq), 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3449 | s32Error = host_int_init(&priv->hWILCWFIDrv); |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 3450 | if (s32Error) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3451 | PRINT_ER("Error while initializing hostinterface\n"); |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 3452 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3453 | return s32Error; |
| 3454 | } |
| 3455 | |
| 3456 | /** |
| 3457 | * @brief WILC_WFI_WiphyFree |
| 3458 | * @details Freeing allocation of the wireless device structure |
| 3459 | * @param[in] NONE |
| 3460 | * @return NONE |
| 3461 | * @author mdaftedar |
| 3462 | * @date 01 MAR 2012 |
| 3463 | * @version 1.0 |
| 3464 | */ |
Chaehyun Lim | a9a1682 | 2015-09-20 15:51:24 +0900 | [diff] [blame] | 3465 | int wilc_deinit_host_int(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3466 | { |
Chaehyun Lim | 1a8ccd8 | 2015-09-20 15:51:23 +0900 | [diff] [blame] | 3467 | int s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3468 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3469 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 3470 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3471 | priv = wdev_priv(net->ieee80211_ptr); |
| 3472 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3473 | priv->gbAutoRateAdjusted = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3474 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3475 | priv->bInP2PlistenState = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3476 | |
| 3477 | op_ifcs--; |
| 3478 | |
| 3479 | s32Error = host_int_deinit(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3480 | |
| 3481 | /* Clear the Shadow scan */ |
| 3482 | clear_shadow_scan(priv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3483 | if (op_ifcs == 0) { |
| 3484 | PRINT_D(CORECONFIG_DBG, "destroy during ip\n"); |
Greg Kroah-Hartman | 4183e97 | 2015-08-14 20:11:16 -0700 | [diff] [blame] | 3485 | del_timer_sync(&hDuringIpTimer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3486 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3487 | |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 3488 | if (s32Error) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3489 | PRINT_ER("Error while deintializing host interface\n"); |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 3490 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3491 | return s32Error; |
| 3492 | } |
| 3493 | |
| 3494 | |
| 3495 | /** |
| 3496 | * @brief WILC_WFI_WiphyFree |
| 3497 | * @details Freeing allocation of the wireless device structure |
| 3498 | * @param[in] NONE |
| 3499 | * @return NONE |
| 3500 | * @author mdaftedar |
| 3501 | * @date 01 MAR 2012 |
| 3502 | * @version 1.0 |
| 3503 | */ |
Chaehyun Lim | 96da20a | 2015-09-20 15:51:08 +0900 | [diff] [blame] | 3504 | void wilc_free_wiphy(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3505 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3506 | PRINT_D(CFG80211_DBG, "Unregistering wiphy\n"); |
| 3507 | |
Chaehyun Lim | 619837a | 2015-09-20 15:51:10 +0900 | [diff] [blame] | 3508 | if (!net) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3509 | PRINT_D(INIT_DBG, "net_device is NULL\n"); |
| 3510 | return; |
| 3511 | } |
| 3512 | |
Chaehyun Lim | 619837a | 2015-09-20 15:51:10 +0900 | [diff] [blame] | 3513 | if (!net->ieee80211_ptr) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3514 | PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n"); |
| 3515 | return; |
| 3516 | } |
| 3517 | |
Chaehyun Lim | 619837a | 2015-09-20 15:51:10 +0900 | [diff] [blame] | 3518 | if (!net->ieee80211_ptr->wiphy) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3519 | PRINT_D(INIT_DBG, "wiphy is NULL\n"); |
| 3520 | return; |
| 3521 | } |
| 3522 | |
| 3523 | wiphy_unregister(net->ieee80211_ptr->wiphy); |
| 3524 | |
| 3525 | PRINT_D(INIT_DBG, "Freeing wiphy\n"); |
| 3526 | wiphy_free(net->ieee80211_ptr->wiphy); |
| 3527 | kfree(net->ieee80211_ptr); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3528 | } |