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