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