blob: 004f4419a044b08e09cb6bc41d614bc80ee30d60 [file] [log] [blame]
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001/*!
2 * @file wilc_wfi_cfgopertaions.c
3 * @brief CFG80211 Function Implementation functionality
4 * @author aabouzaeid
5 * mabubakr
6 * mdaftedar
7 * zsalah
8 * @sa wilc_wfi_cfgopertaions.h top level OS wrapper file
9 * @date 31 Aug 2010
10 * @version 1.0
11 */
12
13#include "wilc_wfi_cfgoperations.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +090014#ifdef WILC_SDIO
Chaehyun Limcdc9cba2015-09-22 18:34:47 +090015#include "linux_wlan_sdio.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +090016#endif
Leo Kim7ae43362015-09-16 18:35:59 +090017#include <linux/errno.h>
Johnny Kimc5c77ba2015-05-11 14:30:56 +090018
19#define IS_MANAGMEMENT 0x100
20#define IS_MANAGMEMENT_CALLBACK 0x080
21#define IS_MGMT_STATUS_SUCCES 0x040
22#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
23
Johnny Kimc5c77ba2015-05-11 14:30:56 +090024extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic);
Dean Lee72ed4dc2015-06-12 14:11:44 +090025extern u16 Set_machw_change_vir_if(bool bValue);
Johnny Kimc5c77ba2015-05-11 14:30:56 +090026
27extern int mac_open(struct net_device *ndev);
28extern int mac_close(struct net_device *ndev);
29
30tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +090031u32 u32LastScannedNtwrksCountShadow;
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070032struct timer_list hDuringIpTimer;
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070033struct timer_list hAgingTimer;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090034static u8 op_ifcs;
35extern u8 u8ConnectedSSID[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +090036
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090037u8 g_wilc_initialized = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090038extern linux_wlan_t *g_linux_wlan;
Dean Lee72ed4dc2015-06-12 14:11:44 +090039extern bool g_obtainingIP;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090040
41#define CHAN2G(_channel, _freq, _flags) { \
42 .band = IEEE80211_BAND_2GHZ, \
43 .center_freq = (_freq), \
44 .hw_value = (_channel), \
45 .flags = (_flags), \
46 .max_antenna_gain = 0, \
47 .max_power = 30, \
48}
49
50/*Frequency range for channels*/
51static struct ieee80211_channel WILC_WFI_2ghz_channels[] = {
52 CHAN2G(1, 2412, 0),
53 CHAN2G(2, 2417, 0),
54 CHAN2G(3, 2422, 0),
55 CHAN2G(4, 2427, 0),
56 CHAN2G(5, 2432, 0),
57 CHAN2G(6, 2437, 0),
58 CHAN2G(7, 2442, 0),
59 CHAN2G(8, 2447, 0),
60 CHAN2G(9, 2452, 0),
61 CHAN2G(10, 2457, 0),
62 CHAN2G(11, 2462, 0),
63 CHAN2G(12, 2467, 0),
64 CHAN2G(13, 2472, 0),
65 CHAN2G(14, 2484, 0),
66};
67
68#define RATETAB_ENT(_rate, _hw_value, _flags) { \
69 .bitrate = (_rate), \
70 .hw_value = (_hw_value), \
71 .flags = (_flags), \
72}
73
74
75/* Table 6 in section 3.2.1.1 */
76static struct ieee80211_rate WILC_WFI_rates[] = {
77 RATETAB_ENT(10, 0, 0),
78 RATETAB_ENT(20, 1, 0),
79 RATETAB_ENT(55, 2, 0),
80 RATETAB_ENT(110, 3, 0),
81 RATETAB_ENT(60, 9, 0),
82 RATETAB_ENT(90, 6, 0),
83 RATETAB_ENT(120, 7, 0),
84 RATETAB_ENT(180, 8, 0),
85 RATETAB_ENT(240, 9, 0),
86 RATETAB_ENT(360, 10, 0),
87 RATETAB_ENT(480, 11, 0),
88 RATETAB_ENT(540, 12, 0),
89};
90
Johnny Kimc5c77ba2015-05-11 14:30:56 +090091struct p2p_mgmt_data {
92 int size;
93 u8 *buff;
94};
95
96/*Global variable used to state the current connected STA channel*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090097u8 u8WLANChannel = INVALID_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090098
Chaehyun Lim866a2c22015-10-02 16:41:21 +090099u8 curr_channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900100
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900101u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09};
102u8 u8P2Plocalrandom = 0x01;
103u8 u8P2Precvrandom = 0x00;
104u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
Daniel Machon7fc80962015-08-05 00:09:35 +0200105bool bWilc_ie;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900106
107static struct ieee80211_supported_band WILC_WFI_band_2ghz = {
108 .channels = WILC_WFI_2ghz_channels,
109 .n_channels = ARRAY_SIZE(WILC_WFI_2ghz_channels),
110 .bitrates = WILC_WFI_rates,
111 .n_bitrates = ARRAY_SIZE(WILC_WFI_rates),
112};
113
114
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900115struct add_key_params {
116 u8 key_idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900117 bool pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900118 u8 *mac_addr;
119};
120struct add_key_params g_add_gtk_key_params;
121struct wilc_wfi_key g_key_gtk_params;
122struct add_key_params g_add_ptk_key_params;
123struct wilc_wfi_key g_key_ptk_params;
124struct wilc_wfi_wep_key g_key_wep_params;
Daniel Machon7fc80962015-08-05 00:09:35 +0200125bool g_ptk_keys_saved;
126bool g_gtk_keys_saved;
127bool g_wep_keys_saved;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900128
129#define AGING_TIME (9 * 1000)
130#define duringIP_TIME 15000
131
132void clear_shadow_scan(void *pUserVoid)
133{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900134 int i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900135
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900136 if (op_ifcs == 0) {
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -0700137 del_timer_sync(&hAgingTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900138 PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n");
139
140 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
141 if (astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +0900142 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900143 astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs = NULL;
144 }
145
146 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
147 astrLastScannedNtwrksShadow[i].pJoinParams = NULL;
148 }
149 u32LastScannedNtwrksCountShadow = 0;
150 }
151
152}
153
Chaehyun Limfbc2fe12015-09-15 14:06:16 +0900154u32 get_rssi_avg(tstrNetworkInfo *pstrNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900155{
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900156 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900157 int rssi_v = 0;
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900158 u8 num_rssi = (pstrNetworkInfo->strRssi.u8Full) ? NUM_RSSI : (pstrNetworkInfo->strRssi.u8Index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900159
160 for (i = 0; i < num_rssi; i++)
161 rssi_v += pstrNetworkInfo->strRssi.as8RSSI[i];
162
163 rssi_v /= num_rssi;
164 return rssi_v;
165}
166
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900167void refresh_scan(void *pUserVoid, u8 all, bool bDirectScan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900168{
Chaehyun Lim27268872015-09-15 14:06:13 +0900169 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900170 struct wiphy *wiphy;
171 struct cfg80211_bss *bss = NULL;
172 int i;
173 int rssi = 0;
174
Chaehyun Lim27268872015-09-15 14:06:13 +0900175 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900176 wiphy = priv->dev->ieee80211_ptr->wiphy;
177
178 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
179 tstrNetworkInfo *pstrNetworkInfo;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900180
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900181 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
182
183
184 if ((!pstrNetworkInfo->u8Found) || all) {
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900185 s32 s32Freq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900186 struct ieee80211_channel *channel;
187
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900188 if (pstrNetworkInfo != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900189
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900190 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900191 channel = ieee80211_get_channel(wiphy, s32Freq);
192
193 rssi = get_rssi_avg(pstrNetworkInfo);
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900194 if (memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900195 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
196 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900197 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)rssi) * 100), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900198 cfg80211_put_bss(wiphy, bss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900199 }
200 }
201
202 }
203 }
204
205}
206
207void reset_shadow_found(void *pUserVoid)
208{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900209 int i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900210
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900211 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
212 astrLastScannedNtwrksShadow[i].u8Found = 0;
213
214 }
215}
216
217void update_scan_time(void *pUserVoid)
218{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900219 int i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900220
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900221 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
222 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
223 }
224}
225
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -0700226static void remove_network_from_shadow(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900227{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900228 unsigned long now = jiffies;
229 int i, j;
230
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900231
232 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
233 if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530234 PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900235
Shraddha Barkecccfc392015-10-12 20:49:19 +0530236 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
237 astrLastScannedNtwrksShadow[i].pu8IEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900238
239 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
240
241 for (j = i; (j < u32LastScannedNtwrksCountShadow - 1); j++) {
242 astrLastScannedNtwrksShadow[j] = astrLastScannedNtwrksShadow[j + 1];
243 }
244 u32LastScannedNtwrksCountShadow--;
245 }
246 }
247
248 PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow);
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -0700249 if (u32LastScannedNtwrksCountShadow != 0) {
250 hAgingTimer.data = arg;
251 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
252 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900253 PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -0700254 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900255}
256
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -0700257static void clear_duringIP(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900258{
259 PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +0900260 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900261}
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900262
Chaehyun Lima74cc6b2015-10-02 16:41:17 +0900263int is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900264{
Chaehyun Lima74cc6b2015-10-02 16:41:17 +0900265 int state = -1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900266 int i;
267
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900268 if (u32LastScannedNtwrksCountShadow == 0) {
269 PRINT_D(CFG80211_DBG, "Starting Aging timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -0700270 hAgingTimer.data = (unsigned long)pUserVoid;
271 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900272 state = -1;
273 } else {
274 /* Linear search for now */
275 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900276 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900277 pstrNetworkInfo->au8bssid, 6) == 0) {
278 state = i;
279 break;
280 }
281 }
282 }
283 return state;
284}
285
286void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
287{
Chaehyun Lima74cc6b2015-10-02 16:41:17 +0900288 int ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid);
Chaehyun Limfbc2fe12015-09-15 14:06:16 +0900289 u32 ap_index = 0;
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900290 u8 rssi_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900291
292 if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) {
293 PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n");
294 return;
295 }
296 if (ap_found == -1) {
297 ap_index = u32LastScannedNtwrksCountShadow;
298 u32LastScannedNtwrksCountShadow++;
299
300 } else {
301 ap_index = ap_found;
302 }
303 rssi_index = astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index;
304 astrLastScannedNtwrksShadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi;
305 if (rssi_index == NUM_RSSI) {
306 rssi_index = 0;
307 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Full = 1;
308 }
309 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index = rssi_index;
310
311 astrLastScannedNtwrksShadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi;
312 astrLastScannedNtwrksShadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo;
313
314 astrLastScannedNtwrksShadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900315 memcpy(astrLastScannedNtwrksShadow[ap_index].au8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900316 pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen);
317
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900318 memcpy(astrLastScannedNtwrksShadow[ap_index].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900319 pstrNetworkInfo->au8bssid, ETH_ALEN);
320
321 astrLastScannedNtwrksShadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod;
322 astrLastScannedNtwrksShadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod;
323 astrLastScannedNtwrksShadow[ap_index].u8channel = pstrNetworkInfo->u8channel;
324
325 astrLastScannedNtwrksShadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen;
326 astrLastScannedNtwrksShadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf;
327 if (ap_found != -1)
Chaehyun Lim49188af2015-08-11 10:32:41 +0900328 kfree(astrLastScannedNtwrksShadow[ap_index].pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900329 astrLastScannedNtwrksShadow[ap_index].pu8IEs =
Glen Leef3052582015-09-10 12:03:04 +0900330 kmalloc(pstrNetworkInfo->u16IEsLen, GFP_KERNEL); /* will be deallocated by the WILC_WFI_CfgScan() function */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900331 memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900332 pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen);
333
334 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScan = jiffies;
335 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScanCached = jiffies;
336 astrLastScannedNtwrksShadow[ap_index].u8Found = 1;
337 if (ap_found != -1)
338 host_int_freeJoinParams(astrLastScannedNtwrksShadow[ap_index].pJoinParams);
339 astrLastScannedNtwrksShadow[ap_index].pJoinParams = pJoinParams;
340
341}
342
343
344/**
345 * @brief CfgScanResult
346 * @details Callback function which returns the scan results found
347 *
348 * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
349 * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
350 * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
351 * void* pUserVoid: Private structure associated with the wireless interface
352 * @return NONE
353 * @author mabubakr
354 * @date
355 * @version 1.0
356 */
Leo Kim1ec38152015-10-12 16:55:59 +0900357static void CfgScanResult(enum scan_event enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900358{
Chaehyun Lim27268872015-09-15 14:06:13 +0900359 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900360 struct wiphy *wiphy;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900361 s32 s32Freq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900362 struct ieee80211_channel *channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900363 struct cfg80211_bss *bss = NULL;
364
Chaehyun Lim27268872015-09-15 14:06:13 +0900365 priv = (struct wilc_priv *)pUserVoid;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900366 if (priv->bCfgScanning == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900367 if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) {
368 wiphy = priv->dev->ieee80211_ptr->wiphy;
Leo Kim7ae43362015-09-16 18:35:59 +0900369
370 if (!wiphy)
371 return;
372
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900373 if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC
374 &&
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900375 ((((s32)pstrNetworkInfo->s8rssi) * 100) < 0
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900376 ||
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900377 (((s32)pstrNetworkInfo->s8rssi) * 100) > 100)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900378 ) {
Leo Kim24db7132015-09-16 18:36:01 +0900379 PRINT_ER("wiphy signal type fial\n");
380 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900381 }
382
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900383 if (pstrNetworkInfo != NULL) {
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900384 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900385 channel = ieee80211_get_channel(wiphy, s32Freq);
386
Leo Kim7ae43362015-09-16 18:35:59 +0900387 if (!channel)
388 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900389
390 PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530391 "BeaconPeriod: %d\n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100),
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900392 pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod);
393
Dean Lee72ed4dc2015-06-12 14:11:44 +0900394 if (pstrNetworkInfo->bNewNetwork == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900395 if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
396 /* max_scan_ssids */
397 PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid);
398
399
400 priv->u32RcvdChCount++;
401
402
403
404 if (pJoinParams == NULL) {
405 PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n");
406 }
407 add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams);
408
409 /*P2P peers are sent to WPA supplicant and added to shadow table*/
410
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900411 if (!(memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900412 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
413 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900414 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900415 cfg80211_put_bss(wiphy, bss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900416 }
417
418
419 } else {
420 PRINT_ER("Discovered networks exceeded the max limit\n");
421 }
422 } else {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900423 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900424 /* So this network is discovered before, we'll just update its RSSI */
425 for (i = 0; i < priv->u32RcvdChCount; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900426 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530427 PRINT_D(CFG80211_DBG, "Update RSSI of %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900428
429 astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi;
430 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
431 break;
432 }
433 }
434 }
435 }
436 } else if (enuScanEvent == SCAN_EVENT_DONE) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530437 PRINT_D(CFG80211_DBG, "Scan Done[%p]\n", priv->dev);
438 PRINT_D(CFG80211_DBG, "Refreshing Scan ...\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +0900439 refresh_scan(priv, 1, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900440
Chandra S Gorentla78174ad2015-08-08 17:41:36 +0530441 if (priv->u32RcvdChCount > 0)
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530442 PRINT_D(CFG80211_DBG, "%d Network(s) found\n", priv->u32RcvdChCount);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +0530443 else
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530444 PRINT_D(CFG80211_DBG, "No networks found\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900445
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200446 down(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900447
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900448 if (priv->pstrScanReq != NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900449 cfg80211_scan_done(priv->pstrScanReq, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900450 priv->u32RcvdChCount = 0;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900451 priv->bCfgScanning = false;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900452 priv->pstrScanReq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900453 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200454 up(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900455
456 }
457 /*Aborting any scan operation during mac close*/
458 else if (enuScanEvent == SCAN_EVENT_ABORTED) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200459 down(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900460
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530461 PRINT_D(CFG80211_DBG, "Scan Aborted\n");
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900462 if (priv->pstrScanReq != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900463
464 update_scan_time(priv);
Dean Lee72ed4dc2015-06-12 14:11:44 +0900465 refresh_scan(priv, 1, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900466
Dean Lee72ed4dc2015-06-12 14:11:44 +0900467 cfg80211_scan_done(priv->pstrScanReq, false);
468 priv->bCfgScanning = false;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900469 priv->pstrScanReq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900470 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200471 up(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900472 }
473 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900474}
475
476
477/**
478 * @brief WILC_WFI_Set_PMKSA
479 * @details Check if pmksa is cached and set it.
480 * @param[in]
481 * @return int : Return 0 on Success
482 * @author mdaftedar
483 * @date 01 MAR 2012
484 * @version 1.0
485 */
Chaehyun Lim27268872015-09-15 14:06:13 +0900486int WILC_WFI_Set_PMKSA(u8 *bssid, struct wilc_priv *priv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900487{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900488 u32 i;
Leo Kime6e12662015-09-16 18:36:03 +0900489 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900490
491
492 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
493
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900494 if (!memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900495 ETH_ALEN)) {
496 PRINT_D(CFG80211_DBG, "PMKID successful comparison");
497
498 /*If bssid is found, set the values*/
499 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
500
Leo Kime6e12662015-09-16 18:36:03 +0900501 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900502 PRINT_ER("Error in pmkid\n");
503
504 break;
505 }
506 }
507
508 return s32Error;
509
510
511}
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900512int linux_wlan_set_bssid(struct net_device *wilc_netdev, u8 *pBSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900513
514
515/**
516 * @brief CfgConnectResult
517 * @details
518 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
519 * connection response or disconnection notification.
520 * tstrConnectInfo* pstrConnectInfo: COnnection information.
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900521 * u8 u8MacStatus: Mac Status from firmware
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900522 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
523 * void* pUserVoid: Private data associated with wireless interface
524 * @return NONE
525 * @author mabubakr
526 * @date 01 MAR 2012
527 * @version 1.0
528 */
529int connecting;
530
Leo Kimed3f0372015-10-12 16:56:01 +0900531static void CfgConnectResult(enum conn_event enuConnDisconnEvent,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900532 tstrConnectInfo *pstrConnectInfo,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900533 u8 u8MacStatus,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900534 tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
535 void *pUserVoid)
536{
Chaehyun Lim27268872015-09-15 14:06:13 +0900537 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900538 struct net_device *dev;
Leo Kim441dc602015-10-12 16:55:35 +0900539 struct host_if_drv *pstrWFIDrv;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900540 u8 NullBssid[ETH_ALEN] = {0};
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900541
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900542 connecting = 0;
543
Chaehyun Lim27268872015-09-15 14:06:13 +0900544 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900545 dev = priv->dev;
Leo Kim441dc602015-10-12 16:55:35 +0900546 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900547
548 if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
549 /*Initialization*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900550 u16 u16ConnectStatus = WLAN_STATUS_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900551
552 u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
553
554 PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus);
555
556 if ((u8MacStatus == MAC_DISCONNECTED) &&
557 (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
558 /* The case here is that our station was waiting for association response frame and has just received it containing status code
559 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
560 u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
561 linux_wlan_set_bssid(priv->dev, NullBssid);
Shraddha Barkebcf02652015-10-05 17:00:32 +0530562 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900563
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900564 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900565 if (!pstrWFIDrv->u8P2PConnect)
566 u8WLANChannel = INVALID_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900567
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530568 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d\n", u16ConnectStatus, u8MacStatus);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900569 }
570
571 if (u16ConnectStatus == WLAN_STATUS_SUCCESS) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900572 bool bNeedScanRefresh = false;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900573 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900574
575 PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0],
576 pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900577 memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900578
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900579
580 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900581 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900582 pstrConnectInfo->au8bssid, ETH_ALEN) == 0) {
583 unsigned long now = jiffies;
584
585 if (time_after(now,
586 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900587 bNeedScanRefresh = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900588 }
589
590 break;
591 }
592 }
593
Abdul Hussain5a66bf22015-06-16 09:44:06 +0000594 if (bNeedScanRefresh) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900595 /*Also, refrsh DIRECT- results if */
Dean Lee72ed4dc2015-06-12 14:11:44 +0900596 refresh_scan(priv, 1, true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900597
598 }
599
600 }
601
602
Sudip Mukherjee52db75202015-06-02 14:28:17 +0530603 PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900604
605 PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen);
606
607 cfg80211_connect_result(dev, pstrConnectInfo->au8bssid,
608 pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen,
609 pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen,
610 u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */
611 /* be replaced by pstrConnectInfo->u16ConnectStatus */
612 } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900613 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900614 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
615 pstrDisconnectNotifInfo->u16reason, priv->dev);
616 u8P2Plocalrandom = 0x01;
617 u8P2Precvrandom = 0x00;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900618 bWilc_ie = false;
Shraddha Barkebcf02652015-10-05 17:00:32 +0530619 eth_zero_addr(priv->au8AssociatedBss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900620 linux_wlan_set_bssid(priv->dev, NullBssid);
Shraddha Barkebcf02652015-10-05 17:00:32 +0530621 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900622
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900623 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900624 if (!pstrWFIDrv->u8P2PConnect)
625 u8WLANChannel = INVALID_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900626 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
627 * virtual interface to station*/
628 if ((pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
629 pstrDisconnectNotifInfo->u16reason = 3;
630 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900631 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
632 * to scan again and retry the connection*/
633 else if ((!pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
634 pstrDisconnectNotifInfo->u16reason = 1;
635 }
636 cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
Sudip Mukherjeee26bb712015-06-30 13:51:51 +0530637 pstrDisconnectNotifInfo->ie_len, false,
638 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900639
640 }
641
642}
643
644
645/**
Chaehyun Lim80785a92015-09-14 12:24:01 +0900646 * @brief set_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900647 * @details Set channel for a given wireless interface. Some devices
648 * may support multi-channel operation (by channel hopping) so cfg80211
649 * doesn't verify much. Note, however, that the passed netdev may be
650 * %NULL as well if the user requested changing the channel for the
651 * device itself, or for a monitor interface.
652 * @param[in]
653 * @return int : Return 0 on Success
654 * @author mdaftedar
655 * @date 01 MAR 2012
656 * @version 1.0
657 */
Chaehyun Lim80785a92015-09-14 12:24:01 +0900658static int set_channel(struct wiphy *wiphy,
659 struct cfg80211_chan_def *chandef)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900660{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900661 u32 channelnum = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +0900662 struct wilc_priv *priv;
Chaehyun Limdd739ea2015-10-02 16:41:20 +0900663 int result = 0;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900664
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900665 priv = wiphy_priv(wiphy);
666
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900667 channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq);
668 PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900669
Chaehyun Lim866a2c22015-10-02 16:41:21 +0900670 curr_channel = channelnum;
Chaehyun Limdd739ea2015-10-02 16:41:20 +0900671 result = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900672
Chaehyun Limdd739ea2015-10-02 16:41:20 +0900673 if (result != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900674 PRINT_ER("Error in setting channel %d\n", channelnum);
675
Chaehyun Limdd739ea2015-10-02 16:41:20 +0900676 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900677}
678
679/**
Chaehyun Lim0e30d062015-09-14 12:24:02 +0900680 * @brief scan
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900681 * @details Request to do a scan. If returning zero, the scan request is given
682 * the driver, and will be valid until passed to cfg80211_scan_done().
683 * For scan results, call cfg80211_inform_bss(); you can call this outside
684 * the scan/scan_done bracket too.
685 * @param[in]
686 * @return int : Return 0 on Success
687 * @author mabubakr
688 * @date 01 MAR 2012
689 * @version 1.0
690 */
691
Chaehyun Lim0e30d062015-09-14 12:24:02 +0900692static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900693{
Chaehyun Lim27268872015-09-15 14:06:13 +0900694 struct wilc_priv *priv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900695 u32 i;
Leo Kime6e12662015-09-16 18:36:03 +0900696 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900697 u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS];
Leo Kim607db442015-10-05 15:25:37 +0900698 struct hidden_network strHiddenNetwork;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900699
700 priv = wiphy_priv(wiphy);
701
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900702 priv->pstrScanReq = request;
703
704 priv->u32RcvdChCount = 0;
705
Johnny Kim218dc402015-08-13 13:41:19 +0900706 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900707
708
709 reset_shadow_found(priv);
710
Dean Lee72ed4dc2015-06-12 14:11:44 +0900711 priv->bCfgScanning = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900712 if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
713 /* max_scan_ssids */
714 for (i = 0; i < request->n_channels; i++) {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900715 au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900716 PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]);
717 }
718
719 PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels);
Sudip Mukherjee52db75202015-06-02 14:28:17 +0530720 PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900721
722 PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
723
724 if (request->n_ssids >= 1) {
725
726
Leo Kim607db442015-10-05 15:25:37 +0900727 strHiddenNetwork.pstrHiddenNetworkInfo = kmalloc(request->n_ssids * sizeof(struct hidden_network), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900728 strHiddenNetwork.u8ssidnum = request->n_ssids;
729
730
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900731 for (i = 0; i < request->n_ssids; i++) {
732
733 if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) {
Glen Leef3052582015-09-10 12:03:04 +0900734 strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900735 memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900736 strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len;
737 } else {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530738 PRINT_D(CFG80211_DBG, "Received one NULL SSID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900739 strHiddenNetwork.u8ssidnum -= 1;
740 }
741 }
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530742 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900743 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
744 au8ScanChanList, request->n_channels,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900745 (const u8 *)request->ie, request->ie_len,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900746 CfgScanResult, (void *)priv, &strHiddenNetwork);
747 } else {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530748 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900749 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
750 au8ScanChanList, request->n_channels,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900751 (const u8 *)request->ie, request->ie_len,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900752 CfgScanResult, (void *)priv, NULL);
753 }
754
755 } else {
756 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530757 " channels\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900758 }
759
Leo Kime6e12662015-09-16 18:36:03 +0900760 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900761 s32Error = -EBUSY;
762 PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error);
763 }
764
765 return s32Error;
766}
767
768/**
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +0900769 * @brief connect
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900770 * @details Connect to the ESS with the specified parameters. When connected,
771 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
772 * If the connection fails for some reason, call cfg80211_connect_result()
773 * with the status from the AP.
774 * @param[in]
775 * @return int : Return 0 on Success
776 * @author mabubakr
777 * @date 01 MAR 2012
778 * @version 1.0
779 */
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +0900780static int connect(struct wiphy *wiphy, struct net_device *dev,
781 struct cfg80211_connect_params *sme)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900782{
Leo Kime6e12662015-09-16 18:36:03 +0900783 s32 s32Error = 0;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900784 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900785 u8 u8security = NO_ENCRYPT;
Leo Kim841dfc42015-10-05 15:25:39 +0900786 enum AUTHTYPE tenuAuth_type = ANY;
Dean Lee576917a2015-06-15 11:58:57 +0900787 char *pcgroup_encrypt_val = NULL;
788 char *pccipher_group = NULL;
789 char *pcwpa_version = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900790
Chaehyun Lim27268872015-09-15 14:06:13 +0900791 struct wilc_priv *priv;
Leo Kim441dc602015-10-12 16:55:35 +0900792 struct host_if_drv *pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900793 tstrNetworkInfo *pstrNetworkInfo = NULL;
794
795
796 connecting = 1;
797 priv = wiphy_priv(wiphy);
Leo Kim441dc602015-10-12 16:55:35 +0900798 pstrWFIDrv = (struct host_if_drv *)(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900799
Johnny Kim218dc402015-08-13 13:41:19 +0900800 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900801
Johnny Kim8a143302015-06-10 17:06:46 +0900802 PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme->ssid, dev, priv->hWILCWFIDrv);
Chaehyun Lim3f882892015-08-10 11:33:17 +0900803 if (!(strncmp(sme->ssid, "DIRECT-", 7))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900804 PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n");
805 pstrWFIDrv->u8P2PConnect = 1;
806 } else
807 pstrWFIDrv->u8P2PConnect = 0;
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530808 PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d\n", sme->ssid, sme->auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900809
810 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
811 if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) &&
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900812 memcmp(astrLastScannedNtwrksShadow[i].au8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900813 sme->ssid,
814 sme->ssid_len) == 0) {
815 PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid);
816 if (sme->bssid == NULL) {
817 /* BSSID is not passed from the user, so decision of matching
818 * is done by SSID only */
819 PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n");
820 break;
821 } else {
822 /* BSSID is also passed from the user, so decision of matching
823 * should consider also this passed BSSID */
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900824 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900825 sme->bssid,
826 ETH_ALEN) == 0) {
827 PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n");
828 break;
829 }
830 }
831 }
832 }
833
834 if (i < u32LastScannedNtwrksCountShadow) {
835 PRINT_D(CFG80211_DBG, "Required bss is in scan results\n");
836
837 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
838
839 PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n",
840 pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1],
841 pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3],
842 pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]);
843 } else {
844 s32Error = -ENOENT;
845 if (u32LastScannedNtwrksCountShadow == 0)
846 PRINT_D(CFG80211_DBG, "No Scan results yet\n");
847 else
848 PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error);
849
850 goto done;
851 }
852
853 priv->WILC_WFI_wep_default = 0;
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900854 memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
855 memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900856
857 PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions);
858 PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group);
859
860 PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise);
861
862 if (INFO) {
863 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++)
864 PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]);
865 }
866
867 if (sme->crypto.cipher_group != NO_ENCRYPT) {
868 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
869 * we will add to it the pairwise cipher suite(s) */
870 pcwpa_version = "Default";
871 PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900872 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900873 u8security = ENCRYPT_ENABLED | WEP;
874 pcgroup_encrypt_val = "WEP40";
875 pccipher_group = "WLAN_CIPHER_SUITE_WEP40";
876 PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx);
877
878 if (INFO) {
879 for (i = 0; i < sme->key_len; i++)
880 PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]);
881 }
882 priv->WILC_WFI_wep_default = sme->key_idx;
883 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900884 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900885
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900886 g_key_wep_params.key_len = sme->key_len;
Glen Leef3052582015-09-10 12:03:04 +0900887 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900888 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
889 g_key_wep_params.key_idx = sme->key_idx;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900890 g_wep_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900891
892 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
893 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
894 } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900895 u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
896 pcgroup_encrypt_val = "WEP104";
897 pccipher_group = "WLAN_CIPHER_SUITE_WEP104";
898
899 priv->WILC_WFI_wep_default = sme->key_idx;
900 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900901 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900902
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900903 g_key_wep_params.key_len = sme->key_len;
Glen Leef3052582015-09-10 12:03:04 +0900904 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900905 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
906 g_key_wep_params.key_idx = sme->key_idx;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900907 g_wep_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900908
909 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
910 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
911 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900912 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900913 u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
914 pcgroup_encrypt_val = "WPA2_TKIP";
915 pccipher_group = "TKIP";
916 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
917 /* tenuSecurity_t = WPA2_AES; */
918 u8security = ENCRYPT_ENABLED | WPA2 | AES;
919 pcgroup_encrypt_val = "WPA2_AES";
920 pccipher_group = "AES";
921 }
922 pcwpa_version = "WPA_VERSION_2";
923 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
924 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900925 u8security = ENCRYPT_ENABLED | WPA | TKIP;
926 pcgroup_encrypt_val = "WPA_TKIP";
927 pccipher_group = "TKIP";
928 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
929 /* tenuSecurity_t = WPA_AES; */
930 u8security = ENCRYPT_ENABLED | WPA | AES;
931 pcgroup_encrypt_val = "WPA_AES";
932 pccipher_group = "AES";
933
934 }
935 pcwpa_version = "WPA_VERSION_1";
936
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900937 } else {
938 s32Error = -ENOTSUPP;
939 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
940
941 goto done;
942 }
943
944 }
945
946 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
947 * add to it the pairwise cipher suite(s) */
948 if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
949 || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
950 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
951 if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) {
952 u8security = u8security | TKIP;
953 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
954 u8security = u8security | AES;
955 }
956 }
957 }
958
959 PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group);
960
961 PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type);
962 switch (sme->auth_type) {
963 case NL80211_AUTHTYPE_OPEN_SYSTEM:
964 PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n");
965 tenuAuth_type = OPEN_SYSTEM;
966 break;
967
968 case NL80211_AUTHTYPE_SHARED_KEY:
969 tenuAuth_type = SHARED_KEY;
970 PRINT_D(CFG80211_DBG, "In SHARED KEY\n");
971 break;
972
973 default:
974 PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type);
975 }
976
977
978 /* ai: key_mgmt: enterprise case */
979 if (sme->crypto.n_akm_suites) {
980 switch (sme->crypto.akm_suites[0]) {
981 case WLAN_AKM_SUITE_8021X:
982 tenuAuth_type = IEEE8021;
983 break;
984
985 default:
986 break;
987 }
988 }
989
990
991 PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel);
992
993 PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
994 pcgroup_encrypt_val, pccipher_group, pcwpa_version);
995
Chaehyun Lim866a2c22015-10-02 16:41:21 +0900996 curr_channel = pstrNetworkInfo->u8channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900997
998 if (!pstrWFIDrv->u8P2PConnect) {
999 u8WLANChannel = pstrNetworkInfo->u8channel;
1000 }
1001
1002 linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid);
1003
1004 s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid,
1005 sme->ssid_len, sme->ie, sme->ie_len,
1006 CfgConnectResult, (void *)priv, u8security,
1007 tenuAuth_type, pstrNetworkInfo->u8channel,
1008 pstrNetworkInfo->pJoinParams);
Leo Kime6e12662015-09-16 18:36:03 +09001009 if (s32Error != 0) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301010 PRINT_ER("host_int_set_join_req(): Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001011 s32Error = -ENOENT;
1012 goto done;
1013 }
1014
1015done:
1016
1017 return s32Error;
1018}
1019
1020
1021/**
Chaehyun Limb027cde2015-09-14 12:24:04 +09001022 * @brief disconnect
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001023 * @details Disconnect from the BSS/ESS.
1024 * @param[in]
1025 * @return int : Return 0 on Success
1026 * @author mdaftedar
1027 * @date 01 MAR 2012
1028 * @version 1.0
1029 */
Chaehyun Limb027cde2015-09-14 12:24:04 +09001030static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001031{
Leo Kime6e12662015-09-16 18:36:03 +09001032 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09001033 struct wilc_priv *priv;
Leo Kim441dc602015-10-12 16:55:35 +09001034 struct host_if_drv *pstrWFIDrv;
Chaehyun Lim51e825f2015-09-15 14:06:14 +09001035 u8 NullBssid[ETH_ALEN] = {0};
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001036
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001037 connecting = 0;
1038 priv = wiphy_priv(wiphy);
1039
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001040 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
Leo Kim441dc602015-10-12 16:55:35 +09001041 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001042 if (!pstrWFIDrv->u8P2PConnect)
1043 u8WLANChannel = INVALID_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001044 linux_wlan_set_bssid(priv->dev, NullBssid);
1045
1046 PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code);
1047
1048 u8P2Plocalrandom = 0x01;
1049 u8P2Precvrandom = 0x00;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001050 bWilc_ie = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001051 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001052
1053 s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code);
Leo Kime6e12662015-09-16 18:36:03 +09001054 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001055 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error);
1056 s32Error = -EINVAL;
1057 }
1058
1059 return s32Error;
1060}
1061
1062/**
Chaehyun Lim953d4172015-09-14 12:24:05 +09001063 * @brief add_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001064 * @details Add a key with the given parameters. @mac_addr will be %NULL
1065 * when adding a group key.
1066 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1067 * @return int : Return 0 on Success
1068 * @author mdaftedar
1069 * @date 01 MAR 2012
1070 * @version 1.0
1071 */
Chaehyun Lim953d4172015-09-14 12:24:05 +09001072static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1073 bool pairwise,
1074 const u8 *mac_addr, struct key_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001075
1076{
Leo Kime6e12662015-09-16 18:36:03 +09001077 s32 s32Error = 0, KeyLen = params->key_len;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001078 u32 i;
Chaehyun Lim27268872015-09-15 14:06:13 +09001079 struct wilc_priv *priv;
Arnd Bergmann057d1e92015-06-01 21:06:44 +02001080 const u8 *pu8RxMic = NULL;
1081 const u8 *pu8TxMic = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001082 u8 u8mode = NO_ENCRYPT;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001083 u8 u8gmode = NO_ENCRYPT;
1084 u8 u8pmode = NO_ENCRYPT;
Leo Kim841dfc42015-10-05 15:25:39 +09001085 enum AUTHTYPE tenuAuth_type = ANY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001086
1087 priv = wiphy_priv(wiphy);
1088
1089 PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
1090
Johnny Kim8a143302015-06-10 17:06:46 +09001091 PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001092
1093 PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0],
1094 params->key[1],
1095 params->key[2]);
1096
1097
1098 switch (params->cipher) {
1099 case WLAN_CIPHER_SUITE_WEP40:
1100 case WLAN_CIPHER_SUITE_WEP104:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001101 if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
1102
1103 priv->WILC_WFI_wep_default = key_index;
1104 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001105 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001106
1107 PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index);
1108 PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len);
1109
1110 for (i = 0; i < params->key_len; i++)
1111 PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]);
1112
1113 tenuAuth_type = OPEN_SYSTEM;
1114
1115 if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
1116 u8mode = ENCRYPT_ENABLED | WEP;
1117 else
1118 u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
1119
1120 host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type);
1121 break;
1122 }
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001123 if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001124 priv->WILC_WFI_wep_default = key_index;
1125 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001126 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001127
1128 PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index);
1129 PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len);
1130 if (INFO) {
1131 for (i = 0; i < params->key_len; i++)
1132 PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]);
1133 }
1134 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index);
1135 }
1136
1137 break;
1138
1139 case WLAN_CIPHER_SUITE_TKIP:
1140 case WLAN_CIPHER_SUITE_CCMP:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001141 if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
1142
1143 if (priv->wilc_gtk[key_index] == NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001144 priv->wilc_gtk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001145 priv->wilc_gtk[key_index]->key = NULL;
1146 priv->wilc_gtk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001147
1148 }
1149 if (priv->wilc_ptk[key_index] == NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001150 priv->wilc_ptk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001151 priv->wilc_ptk[key_index]->key = NULL;
1152 priv->wilc_ptk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001153 }
1154
1155
1156
Daniel Machon19132212015-08-05 08:18:31 +02001157 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001158 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1159 u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
1160 else
1161 u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
1162
1163 priv->wilc_groupkey = u8gmode;
1164
1165 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1166
1167 pu8TxMic = params->key + 24;
1168 pu8RxMic = params->key + 16;
1169 KeyLen = params->key_len - 16;
1170 }
1171 /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
Shraddha Barkecccfc392015-10-12 20:49:19 +05301172 kfree(priv->wilc_gtk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001173
Glen Leef3052582015-09-10 12:03:04 +09001174 priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001175 memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001176
1177 /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
Shraddha Barkecccfc392015-10-12 20:49:19 +05301178 kfree(priv->wilc_gtk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001179
1180 if ((params->seq_len) > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001181 priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001182 memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001183 }
1184
1185 priv->wilc_gtk[key_index]->cipher = params->cipher;
1186 priv->wilc_gtk[key_index]->key_len = params->key_len;
1187 priv->wilc_gtk[key_index]->seq_len = params->seq_len;
1188
1189 if (INFO) {
1190 for (i = 0; i < params->key_len; i++)
1191 PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]);
1192 for (i = 0; i < params->seq_len; i++)
1193 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1194 }
1195
1196
1197 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1198 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode);
1199
1200 } else {
1201 PRINT_INFO(CFG80211_DBG, "STA Address: %x%x%x%x%x\n", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4]);
1202
1203 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1204 u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
1205 else
1206 u8pmode = priv->wilc_groupkey | AES;
1207
1208
1209 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1210
1211 pu8TxMic = params->key + 24;
1212 pu8RxMic = params->key + 16;
1213 KeyLen = params->key_len - 16;
1214 }
1215
Shraddha Barkecccfc392015-10-12 20:49:19 +05301216 kfree(priv->wilc_ptk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001217
Glen Leef3052582015-09-10 12:03:04 +09001218 priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001219
Shraddha Barkecccfc392015-10-12 20:49:19 +05301220 kfree(priv->wilc_ptk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001221
1222 if ((params->seq_len) > 0)
Glen Leef3052582015-09-10 12:03:04 +09001223 priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001224
1225 if (INFO) {
1226 for (i = 0; i < params->key_len; i++)
1227 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]);
1228
1229 for (i = 0; i < params->seq_len; i++)
1230 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1231 }
1232
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001233 memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001234
1235 if ((params->seq_len) > 0)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001236 memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001237
1238 priv->wilc_ptk[key_index]->cipher = params->cipher;
1239 priv->wilc_ptk[key_index]->key_len = params->key_len;
1240 priv->wilc_ptk[key_index]->seq_len = params->seq_len;
1241
1242 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1243 pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index);
1244 }
1245 break;
1246 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001247
1248 {
1249 u8mode = 0;
Daniel Machon19132212015-08-05 08:18:31 +02001250 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001251 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1252 /* swap the tx mic by rx mic */
1253 pu8RxMic = params->key + 24;
1254 pu8TxMic = params->key + 16;
1255 KeyLen = params->key_len - 16;
1256 }
1257
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001258 /*save keys only on interface 0 (wifi interface)*/
1259 if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1260 g_add_gtk_key_params.key_idx = key_index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001261 g_add_gtk_key_params.pairwise = pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001262 if (!mac_addr) {
1263 g_add_gtk_key_params.mac_addr = NULL;
1264 } else {
Glen Leef3052582015-09-10 12:03:04 +09001265 g_add_gtk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001266 memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
1267 }
1268 g_key_gtk_params.key_len = params->key_len;
1269 g_key_gtk_params.seq_len = params->seq_len;
Glen Leef3052582015-09-10 12:03:04 +09001270 g_key_gtk_params.key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001271 memcpy(g_key_gtk_params.key, params->key, params->key_len);
1272 if (params->seq_len > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001273 g_key_gtk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001274 memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
1275 }
1276 g_key_gtk_params.cipher = params->cipher;
1277
1278 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0],
1279 g_key_gtk_params.key[1],
1280 g_key_gtk_params.key[2]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09001281 g_gtk_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001282 }
1283
1284 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1285 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001286 } else {
1287 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1288 /* swap the tx mic by rx mic */
1289 pu8RxMic = params->key + 24;
1290 pu8TxMic = params->key + 16;
1291 KeyLen = params->key_len - 16;
1292 }
1293
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001294 /*save keys only on interface 0 (wifi interface)*/
1295 if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1296 g_add_ptk_key_params.key_idx = key_index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001297 g_add_ptk_key_params.pairwise = pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001298 if (!mac_addr) {
1299 g_add_ptk_key_params.mac_addr = NULL;
1300 } else {
Glen Leef3052582015-09-10 12:03:04 +09001301 g_add_ptk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001302 memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
1303 }
1304 g_key_ptk_params.key_len = params->key_len;
1305 g_key_ptk_params.seq_len = params->seq_len;
Glen Leef3052582015-09-10 12:03:04 +09001306 g_key_ptk_params.key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001307 memcpy(g_key_ptk_params.key, params->key, params->key_len);
1308 if (params->seq_len > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001309 g_key_ptk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001310 memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
1311 }
1312 g_key_ptk_params.cipher = params->cipher;
1313
1314 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0],
1315 g_key_ptk_params.key[1],
1316 g_key_ptk_params.key[2]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09001317 g_ptk_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001318 }
1319
1320 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1321 pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index);
1322 PRINT_D(CFG80211_DBG, "Adding pairwise key\n");
1323 if (INFO) {
1324 for (i = 0; i < params->key_len; i++)
1325 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]);
1326 }
1327 }
1328 }
1329 break;
1330
1331 default:
1332 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
1333 s32Error = -ENOTSUPP;
1334
1335 }
1336
1337 return s32Error;
1338}
1339
1340/**
Chaehyun Lim3044ba72015-09-14 12:24:06 +09001341 * @brief del_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001342 * @details Remove a key given the @mac_addr (%NULL for a group key)
1343 * and @key_index, return -ENOENT if the key doesn't exist.
1344 * @param[in]
1345 * @return int : Return 0 on Success
1346 * @author mdaftedar
1347 * @date 01 MAR 2012
1348 * @version 1.0
1349 */
Chaehyun Lim3044ba72015-09-14 12:24:06 +09001350static int del_key(struct wiphy *wiphy, struct net_device *netdev,
1351 u8 key_index,
1352 bool pairwise,
1353 const u8 *mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001354{
Chaehyun Lim27268872015-09-15 14:06:13 +09001355 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001356
1357 priv = wiphy_priv(wiphy);
1358
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001359 /*delete saved keys, if any*/
1360 if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001361 g_ptk_keys_saved = false;
1362 g_gtk_keys_saved = false;
1363 g_wep_keys_saved = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001364
1365 /*Delete saved WEP keys params, if any*/
Shraddha Barkecccfc392015-10-12 20:49:19 +05301366 kfree(g_key_wep_params.key);
1367 g_key_wep_params.key = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001368
1369 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1370
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001371 if ((priv->wilc_gtk[key_index]) != NULL) {
1372
Shraddha Barkecccfc392015-10-12 20:49:19 +05301373 kfree(priv->wilc_gtk[key_index]->key);
1374 priv->wilc_gtk[key_index]->key = NULL;
1375 kfree(priv->wilc_gtk[key_index]->seq);
1376 priv->wilc_gtk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001377
Chaehyun Lim49188af2015-08-11 10:32:41 +09001378 kfree(priv->wilc_gtk[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001379 priv->wilc_gtk[key_index] = NULL;
1380
1381 }
1382
1383 if ((priv->wilc_ptk[key_index]) != NULL) {
1384
Shraddha Barkecccfc392015-10-12 20:49:19 +05301385 kfree(priv->wilc_ptk[key_index]->key);
1386 priv->wilc_ptk[key_index]->key = NULL;
1387 kfree(priv->wilc_ptk[key_index]->seq);
1388 priv->wilc_ptk[key_index]->seq = NULL;
Chaehyun Lim49188af2015-08-11 10:32:41 +09001389 kfree(priv->wilc_ptk[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001390 priv->wilc_ptk[key_index] = NULL;
1391 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001392
1393 /*Delete saved PTK and GTK keys params, if any*/
Shraddha Barkecccfc392015-10-12 20:49:19 +05301394 kfree(g_key_ptk_params.key);
1395 g_key_ptk_params.key = NULL;
1396 kfree(g_key_ptk_params.seq);
1397 g_key_ptk_params.seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001398
Shraddha Barkecccfc392015-10-12 20:49:19 +05301399 kfree(g_key_gtk_params.key);
1400 g_key_gtk_params.key = NULL;
1401 kfree(g_key_gtk_params.seq);
1402 g_key_gtk_params.seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001403
1404 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
Dean Lee72ed4dc2015-06-12 14:11:44 +09001405 Set_machw_change_vir_if(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001406 }
1407
1408 if (key_index >= 0 && key_index <= 3) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001409 memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001410 priv->WILC_WFI_wep_key_len[key_index] = 0;
1411
1412 PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
1413 host_int_remove_wep_key(priv->hWILCWFIDrv, key_index);
1414 } else {
1415 PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
1416 host_int_remove_key(priv->hWILCWFIDrv, mac_addr);
1417 }
1418
Leo Kimaaed3292015-10-12 16:55:38 +09001419 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001420}
1421
1422/**
Chaehyun Limf4893df2015-09-14 12:24:07 +09001423 * @brief get_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001424 * @details Get information about the key with the given parameters.
1425 * @mac_addr will be %NULL when requesting information for a group
1426 * key. All pointers given to the @callback function need not be valid
1427 * after it returns. This function should return an error if it is
1428 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1429 * @param[in]
1430 * @return int : Return 0 on Success
1431 * @author mdaftedar
1432 * @date 01 MAR 2012
1433 * @version 1.0
1434 */
Chaehyun Limf4893df2015-09-14 12:24:07 +09001435static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1436 bool pairwise,
1437 const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001438{
Chaehyun Lim27268872015-09-15 14:06:13 +09001439 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001440 struct key_params key_params;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001441 u32 i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001442
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001443 priv = wiphy_priv(wiphy);
1444
1445
Alison Schofield3604af52015-10-12 13:22:44 -07001446 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001447 PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
1448
1449 key_params.key = priv->wilc_gtk[key_index]->key;
1450 key_params.cipher = priv->wilc_gtk[key_index]->cipher;
1451 key_params.key_len = priv->wilc_gtk[key_index]->key_len;
1452 key_params.seq = priv->wilc_gtk[key_index]->seq;
1453 key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
1454 if (INFO) {
1455 for (i = 0; i < key_params.key_len; i++)
1456 PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
1457 }
1458 } else {
1459 PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
1460
1461 key_params.key = priv->wilc_ptk[key_index]->key;
1462 key_params.cipher = priv->wilc_ptk[key_index]->cipher;
1463 key_params.key_len = priv->wilc_ptk[key_index]->key_len;
1464 key_params.seq = priv->wilc_ptk[key_index]->seq;
1465 key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
1466 }
1467
1468 callback(cookie, &key_params);
1469
Leo Kimaaed3292015-10-12 16:55:38 +09001470 return 0; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001471}
1472
1473/**
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09001474 * @brief set_default_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001475 * @details Set the default management frame key on an interface
1476 * @param[in]
1477 * @return int : Return 0 on Success.
1478 * @author mdaftedar
1479 * @date 01 MAR 2012
1480 * @version 1.0
1481 */
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09001482static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1483 bool unicast, bool multicast)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001484{
Chaehyun Lim27268872015-09-15 14:06:13 +09001485 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001486
1487
1488 priv = wiphy_priv(wiphy);
1489
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301490 PRINT_D(CFG80211_DBG, "Setting default key with idx = %d\n", key_index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001491
1492 if (key_index != priv->WILC_WFI_wep_default) {
1493
1494 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index);
1495 }
1496
Leo Kimaaed3292015-10-12 16:55:38 +09001497 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001498}
1499
1500/**
Chaehyun Limf06f5622015-09-14 12:24:18 +09001501 * @brief get_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001502 * @details Get station information for the station identified by @mac
1503 * @param[in] NONE
1504 * @return int : Return 0 on Success.
1505 * @author mdaftedar
1506 * @date 01 MAR 2012
1507 * @version 1.0
1508 */
1509
Chaehyun Limf06f5622015-09-14 12:24:18 +09001510static int get_station(struct wiphy *wiphy, struct net_device *dev,
1511 const u8 *mac, struct station_info *sinfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001512{
Chaehyun Lim27268872015-09-15 14:06:13 +09001513 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001514 perInterface_wlan_t *nic;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001515 u32 i = 0;
1516 u32 associatedsta = 0;
1517 u32 inactive_time = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001518 priv = wiphy_priv(wiphy);
1519 nic = netdev_priv(dev);
1520
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001521 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
1522 PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
1523
1524 PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
1525
1526 for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
1527
1528 if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
1529 associatedsta = i;
1530 break;
1531 }
1532
1533 }
1534
1535 if (associatedsta == -1) {
Leo Kimaaed3292015-10-12 16:55:38 +09001536 PRINT_ER("Station required is not associated\n");
1537 return -ENOENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001538 }
1539
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001540 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001541
1542 host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time));
1543 sinfo->inactive_time = 1000 * inactive_time;
1544 PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
1545
1546 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001547
1548 if (nic->iftype == STATION_MODE) {
Leo Kim03e7b9c2015-10-12 16:55:58 +09001549 struct rf_info strStatistics;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001550
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001551 host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
1552
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001553 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
Chandra S Gorentla62129902015-08-05 22:11:57 +05301554 BIT(NL80211_STA_INFO_RX_PACKETS) |
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001555 BIT(NL80211_STA_INFO_TX_PACKETS) |
1556 BIT(NL80211_STA_INFO_TX_FAILED) |
1557 BIT(NL80211_STA_INFO_TX_BITRATE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001558
1559 sinfo->signal = strStatistics.s8RSSI;
1560 sinfo->rx_packets = strStatistics.u32RxCount;
1561 sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001562 sinfo->tx_failed = strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001563 sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10;
1564
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301565 if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED))
Dean Lee72ed4dc2015-06-12 14:11:44 +09001566 Enable_TCP_ACK_Filter(true);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301567 else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001568 Enable_TCP_ACK_Filter(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001569
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001570 PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets,
1571 sinfo->tx_failed, sinfo->txrate.legacy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001572 }
Leo Kimaaed3292015-10-12 16:55:38 +09001573 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001574}
1575
1576
1577/**
Chaehyun Lima5f7db62015-09-14 12:24:20 +09001578 * @brief change_bss
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001579 * @details Modify parameters for a given BSS.
1580 * @param[in]
1581 * -use_cts_prot: Whether to use CTS protection
1582 * (0 = no, 1 = yes, -1 = do not change)
1583 * -use_short_preamble: Whether the use of short preambles is allowed
1584 * (0 = no, 1 = yes, -1 = do not change)
1585 * -use_short_slot_time: Whether the use of short slot time is allowed
1586 * (0 = no, 1 = yes, -1 = do not change)
1587 * -basic_rates: basic rates in IEEE 802.11 format
1588 * (or NULL for no change)
1589 * -basic_rates_len: number of basic rates
1590 * -ap_isolate: do not forward packets between connected stations
1591 * -ht_opmode: HT Operation mode
1592 * (u16 = opmode, -1 = do not change)
1593 * @return int : Return 0 on Success.
1594 * @author mdaftedar
1595 * @date 01 MAR 2012
1596 * @version 1.0
1597 */
Chaehyun Lima5f7db62015-09-14 12:24:20 +09001598static int change_bss(struct wiphy *wiphy, struct net_device *dev,
1599 struct bss_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001600{
1601 PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
1602 return 0;
1603}
1604
1605/**
Chaehyun Lima76b63e2015-09-14 12:24:21 +09001606 * @brief set_wiphy_params
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001607 * @details Notify that wiphy parameters have changed;
1608 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1609 * have changed.
1610 * @return int : Return 0 on Success
1611 * @author mdaftedar
1612 * @date 01 MAR 2012
1613 * @version 1.0
1614 */
Chaehyun Lima76b63e2015-09-14 12:24:21 +09001615static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001616{
Leo Kime6e12662015-09-16 18:36:03 +09001617 s32 s32Error = 0;
Leo Kim95296502015-10-05 15:25:46 +09001618 struct cfg_param_val pstrCfgParamVal;
Chaehyun Lim27268872015-09-15 14:06:13 +09001619 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001620
1621 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001622
Tony Cho87c05b22015-10-12 16:56:07 +09001623 pstrCfgParamVal.flag = 0;
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301624 PRINT_D(CFG80211_DBG, "Setting Wiphy params\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001625
1626 if (changed & WIPHY_PARAM_RETRY_SHORT) {
1627 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1628 priv->dev->ieee80211_ptr->wiphy->retry_short);
Tony Cho87c05b22015-10-12 16:56:07 +09001629 pstrCfgParamVal.flag |= RETRY_SHORT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001630 pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
1631 }
1632 if (changed & WIPHY_PARAM_RETRY_LONG) {
1633
1634 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long);
Tony Cho87c05b22015-10-12 16:56:07 +09001635 pstrCfgParamVal.flag |= RETRY_LONG;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001636 pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
1637
1638 }
1639 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1640 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold);
Tony Cho87c05b22015-10-12 16:56:07 +09001641 pstrCfgParamVal.flag |= FRAG_THRESHOLD;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001642 pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
1643
1644 }
1645
1646 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1647 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
1648
Tony Cho87c05b22015-10-12 16:56:07 +09001649 pstrCfgParamVal.flag |= RTS_THRESHOLD;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001650 pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
1651
1652 }
1653
1654 PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
1655 s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
1656 if (s32Error)
1657 PRINT_ER("Error in setting WIPHY PARAMS\n");
1658
1659
1660 return s32Error;
1661}
Arnd Bergmanne5af0562015-05-29 22:52:12 +02001662
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001663/**
Chaehyun Lim4d466572015-09-14 12:24:22 +09001664 * @brief set_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001665 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1666 * devices running firmwares capable of generating the (re) association
1667 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1668 * @param[in]
1669 * @return int : Return 0 on Success
1670 * @author mdaftedar
1671 * @date 01 MAR 2012
1672 * @version 1.0
1673 */
Chaehyun Lim4d466572015-09-14 12:24:22 +09001674static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1675 struct cfg80211_pmksa *pmksa)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001676{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001677 u32 i;
Leo Kime6e12662015-09-16 18:36:03 +09001678 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001679 u8 flag = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001680
Chaehyun Lim27268872015-09-15 14:06:13 +09001681 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001682
1683 PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
1684
1685
1686 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001687 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001688 ETH_ALEN)) {
1689 /*If bssid already exists and pmkid value needs to reset*/
1690 flag = PMKID_FOUND;
1691 PRINT_D(CFG80211_DBG, "PMKID already exists\n");
1692 break;
1693 }
1694 }
1695 if (i < WILC_MAX_NUM_PMKIDS) {
1696 PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001697 memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001698 ETH_ALEN);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001699 memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001700 PMKID_LEN);
1701 if (!(flag == PMKID_FOUND))
1702 priv->pmkid_list.numpmkid++;
1703 } else {
1704 PRINT_ER("Invalid PMKID index\n");
1705 s32Error = -EINVAL;
1706 }
1707
1708 if (!s32Error) {
1709 PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
1710 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
1711 }
1712 return s32Error;
1713}
1714
1715/**
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09001716 * @brief del_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001717 * @details Delete a cached PMKID.
1718 * @param[in]
1719 * @return int : Return 0 on Success
1720 * @author mdaftedar
1721 * @date 01 MAR 2012
1722 * @version 1.0
1723 */
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09001724static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1725 struct cfg80211_pmksa *pmksa)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001726{
1727
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001728 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001729 u8 flag = 0;
Leo Kime6e12662015-09-16 18:36:03 +09001730 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001731
Chaehyun Lim27268872015-09-15 14:06:13 +09001732 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001733
1734 PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
1735
1736 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001737 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001738 ETH_ALEN)) {
1739 /*If bssid is found, reset the values*/
1740 PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
Leo Kimcd1e6cb2015-10-05 15:25:45 +09001741 memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(struct host_if_pmkid));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001742 flag = PMKID_FOUND;
1743 break;
1744 }
1745 }
1746
1747 if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
1748 for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001749 memcpy(priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001750 priv->pmkid_list.pmkidlist[i + 1].bssid,
1751 ETH_ALEN);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001752 memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001753 priv->pmkid_list.pmkidlist[i].pmkid,
1754 PMKID_LEN);
1755 }
1756 priv->pmkid_list.numpmkid--;
1757 } else {
1758 s32Error = -EINVAL;
1759 }
1760
1761 return s32Error;
1762}
1763
1764/**
Chaehyun Limb33c39b2015-09-14 12:24:24 +09001765 * @brief flush_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001766 * @details Flush all cached PMKIDs.
1767 * @param[in]
1768 * @return int : Return 0 on Success
1769 * @author mdaftedar
1770 * @date 01 MAR 2012
1771 * @version 1.0
1772 */
Chaehyun Limb33c39b2015-09-14 12:24:24 +09001773static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001774{
Chaehyun Lim27268872015-09-15 14:06:13 +09001775 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001776
1777 PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
1778
1779 /*Get cashed Pmkids and set all with zeros*/
Leo Kima949f902015-10-05 15:25:44 +09001780 memset(&priv->pmkid_list, 0, sizeof(struct host_if_pmkid_attr));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001781
1782 return 0;
1783}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001784
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001785
1786/**
1787 * @brief WILC_WFI_CfgParseRxAction
1788 * @details Function parses the received frames and modifies the following attributes:
1789 * -GO Intent
1790 * -Channel list
1791 * -Operating Channel
1792 *
1793 * @param[in] u8* Buffer, u32 length
1794 * @return NONE.
1795 * @author mdaftedar
1796 * @date 12 DEC 2012
1797 * @version
1798 */
1799
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001800void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001801{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001802 u32 index = 0;
1803 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001804
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001805 u8 op_channel_attr_index = 0;
1806 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001807
1808 while (index < len) {
1809 if (buf[index] == GO_INTENT_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001810 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001811 }
1812
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301813 if (buf[index] == CHANLIST_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001814 channel_list_attr_index = index;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301815 else if (buf[index] == OPERCHAN_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001816 op_channel_attr_index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001817 index += buf[index + 1] + 3; /* ID,Length byte */
1818 }
Alison Schofield3604af52015-10-12 13:22:44 -07001819 if (u8WLANChannel != INVALID_CHANNEL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001820
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001821 /*Modify channel list attribute*/
1822 if (channel_list_attr_index) {
1823 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
1824 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
1825 if (buf[i] == 0x51) {
1826 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
1827 buf[j] = u8WLANChannel;
1828 }
1829 break;
1830 }
1831 }
1832 }
1833 /*Modify operating channel attribute*/
1834 if (op_channel_attr_index) {
1835 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
1836 buf[op_channel_attr_index + 6] = 0x51;
1837 buf[op_channel_attr_index + 7] = u8WLANChannel;
1838 }
1839 }
1840}
1841
1842/**
1843 * @brief WILC_WFI_CfgParseTxAction
1844 * @details Function parses the transmitted action frames and modifies the
1845 * GO Intent attribute
1846 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
1847 * @return NONE.
1848 * @author mdaftedar
1849 * @date 12 DEC 2012
1850 * @version
1851 */
Dean Lee72ed4dc2015-06-12 14:11:44 +09001852void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001853{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001854 u32 index = 0;
1855 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001856
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001857 u8 op_channel_attr_index = 0;
1858 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001859
1860 while (index < len) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001861 if (buf[index] == GO_INTENT_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001862 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001863
1864 break;
1865 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001866
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301867 if (buf[index] == CHANLIST_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001868 channel_list_attr_index = index;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301869 else if (buf[index] == OPERCHAN_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001870 op_channel_attr_index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001871 index += buf[index + 1] + 3; /* ID,Length byte */
1872 }
Alison Schofield3604af52015-10-12 13:22:44 -07001873 if (u8WLANChannel != INVALID_CHANNEL && bOperChan) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001874
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001875 /*Modify channel list attribute*/
1876 if (channel_list_attr_index) {
1877 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
1878 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
1879 if (buf[i] == 0x51) {
1880 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
1881 buf[j] = u8WLANChannel;
1882 }
1883 break;
1884 }
1885 }
1886 }
1887 /*Modify operating channel attribute*/
1888 if (op_channel_attr_index) {
1889 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
1890 buf[op_channel_attr_index + 6] = 0x51;
1891 buf[op_channel_attr_index + 7] = u8WLANChannel;
1892 }
1893 }
1894}
1895
1896/* @brief WILC_WFI_p2p_rx
1897 * @details
1898 * @param[in]
1899 *
1900 * @return None
1901 * @author Mai Daftedar
1902 * @date 2 JUN 2013
1903 * @version 1.0
1904 */
1905
Chaehyun Limfbc2fe12015-09-15 14:06:16 +09001906void WILC_WFI_p2p_rx (struct net_device *dev, u8 *buff, u32 size)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001907{
1908
Chaehyun Lim27268872015-09-15 14:06:13 +09001909 struct wilc_priv *priv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001910 u32 header, pkt_offset;
Leo Kim441dc602015-10-12 16:55:35 +09001911 struct host_if_drv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001912 u32 i = 0;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001913 s32 s32Freq;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001914
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001915 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
Leo Kim441dc602015-10-12 16:55:35 +09001916 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001917
1918 /* Get WILC header */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001919 memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001920
1921 /* The packet offset field conain info about what type of managment frame */
1922 /* we are dealing with and ack status */
1923 pkt_offset = GET_PKT_OFFSET(header);
1924
1925 if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
1926 if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
1927 PRINT_D(GENERIC_DBG, "Probe response ACK\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001928 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001929 return;
1930 } else {
1931 if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
1932 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],
1933 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001934 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001935 } else {
1936 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],
1937 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001938 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001939 }
1940 return;
1941 }
1942 } else {
1943
1944 PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
1945
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001946 /*Upper layer is informed that the frame is received on this freq*/
Chaehyun Lim866a2c22015-10-02 16:41:21 +09001947 s32Freq = ieee80211_channel_to_frequency(curr_channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001948
1949 if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
1950 PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
1951
Dean Lee72ed4dc2015-06-12 14:11:44 +09001952 if (priv->bCfgScanning == true && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001953 PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
1954 return;
1955 }
1956 if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
1957
1958 switch (buff[ACTION_SUBTYPE_ID]) {
1959 case GAS_INTIAL_REQ:
1960 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
1961 break;
1962
1963 case GAS_INTIAL_RSP:
1964 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
1965 break;
1966
1967 case PUBLIC_ACT_VENDORSPEC:
1968 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
1969 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001970 if (!memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001971 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
1972 if (!bWilc_ie) {
1973 for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001974 if (!memcmp(u8P2P_vendorspec, &buff[i], 6)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001975 u8P2Precvrandom = buff[i + 6];
Dean Lee72ed4dc2015-06-12 14:11:44 +09001976 bWilc_ie = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001977 PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom);
1978 break;
1979 }
1980 }
1981 }
1982 }
1983 if (u8P2Plocalrandom > u8P2Precvrandom) {
1984 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
1985 || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
1986 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001987 if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buff[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001988 WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
1989 break;
1990 }
1991 }
1992 }
1993 } else
1994 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
1995 }
1996
1997
1998 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) {
1999 PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
2000 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002001 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002002 return;
2003 }
2004 break;
2005
2006 default:
2007 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
2008 break;
2009 }
2010 }
2011 }
2012
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002013 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002014 }
2015}
2016
2017/**
2018 * @brief WILC_WFI_mgmt_tx_complete
2019 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2020 * @param[in] priv
2021 * transmitting status
2022 * @return None
2023 * @author Amr Abdelmoghny
2024 * @date 20 MAY 2013
2025 * @version 1.0
2026 */
2027static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
2028{
2029 struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
2030
2031
2032 kfree(pv_data->buff);
2033 kfree(pv_data);
2034}
2035
2036/**
2037 * @brief WILC_WFI_RemainOnChannelReady
2038 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2039 * @param
2040 * @return none
2041 * @author Amr abdelmoghny
2042 * @date 9 JUNE 2013
2043 * @version
2044 */
2045
2046static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
2047{
Chaehyun Lim27268872015-09-15 14:06:13 +09002048 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002049
Chaehyun Lim27268872015-09-15 14:06:13 +09002050 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002051
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302052 PRINT_D(HOSTINF_DBG, "Remain on channel ready\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002053
Dean Lee72ed4dc2015-06-12 14:11:44 +09002054 priv->bInP2PlistenState = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002055
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002056 cfg80211_ready_on_channel(priv->wdev,
2057 priv->strRemainOnChanParams.u64ListenCookie,
2058 priv->strRemainOnChanParams.pstrListenChan,
2059 priv->strRemainOnChanParams.u32ListenDuration,
2060 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002061}
2062
2063/**
2064 * @brief WILC_WFI_RemainOnChannelExpired
2065 * @details Callback function, called on expiration of remain-on-channel duration
2066 * @param
2067 * @return none
2068 * @author Amr abdelmoghny
2069 * @date 15 MAY 2013
2070 * @version
2071 */
2072
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002073static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002074{
Chaehyun Lim27268872015-09-15 14:06:13 +09002075 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002076
Chaehyun Lim27268872015-09-15 14:06:13 +09002077 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002078
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002079 if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302080 PRINT_D(GENERIC_DBG, "Remain on channel expired\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002081
Dean Lee72ed4dc2015-06-12 14:11:44 +09002082 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002083
2084 /*Inform wpas of remain-on-channel expiration*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002085 cfg80211_remain_on_channel_expired(priv->wdev,
2086 priv->strRemainOnChanParams.u64ListenCookie,
2087 priv->strRemainOnChanParams.pstrListenChan,
2088 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002089 } else {
2090 PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2091 , priv->strRemainOnChanParams.u32ListenSessionID);
2092 }
2093}
2094
2095
2096/**
Chaehyun Lim6d19d692015-09-14 12:24:25 +09002097 * @brief remain_on_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002098 * @details Request the driver to remain awake on the specified
2099 * channel for the specified duration to complete an off-channel
2100 * operation (e.g., public action frame exchange). When the driver is
2101 * ready on the requested channel, it must indicate this with an event
2102 * notification by calling cfg80211_ready_on_channel().
2103 * @param[in]
2104 * @return int : Return 0 on Success
2105 * @author mdaftedar
2106 * @date 01 MAR 2012
2107 * @version 1.0
2108 */
Chaehyun Lim6d19d692015-09-14 12:24:25 +09002109static int remain_on_channel(struct wiphy *wiphy,
2110 struct wireless_dev *wdev,
2111 struct ieee80211_channel *chan,
2112 unsigned int duration, u64 *cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002113{
Leo Kime6e12662015-09-16 18:36:03 +09002114 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002115 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002116
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002117 priv = wiphy_priv(wiphy);
2118
2119 PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
2120
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002121
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002122 if (wdev->iftype == NL80211_IFTYPE_AP) {
2123 PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
2124 return s32Error;
2125 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002126
Chaehyun Lim866a2c22015-10-02 16:41:21 +09002127 curr_channel = chan->hw_value;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002128
2129 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2130 priv->strRemainOnChanParams.pstrListenChan = chan;
2131 priv->strRemainOnChanParams.u64ListenCookie = *cookie;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002132 priv->strRemainOnChanParams.u32ListenDuration = duration;
2133 priv->strRemainOnChanParams.u32ListenSessionID++;
2134
2135 s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv
2136 , priv->strRemainOnChanParams.u32ListenSessionID
2137 , duration
2138 , chan->hw_value
2139 , WILC_WFI_RemainOnChannelExpired
2140 , WILC_WFI_RemainOnChannelReady
2141 , (void *)priv);
2142
2143 return s32Error;
2144}
2145
2146/**
Chaehyun Lim1dd54402015-09-14 12:24:26 +09002147 * @brief cancel_remain_on_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002148 * @details Cancel an on-going remain-on-channel operation.
2149 * This allows the operation to be terminated prior to timeout based on
2150 * the duration value.
2151 * @param[in] struct wiphy *wiphy,
2152 * @param[in] struct net_device *dev
2153 * @param[in] u64 cookie,
2154 * @return int : Return 0 on Success
2155 * @author mdaftedar
2156 * @date 01 MAR 2012
2157 * @version 1.0
2158 */
Chaehyun Lim1dd54402015-09-14 12:24:26 +09002159static int cancel_remain_on_channel(struct wiphy *wiphy,
2160 struct wireless_dev *wdev,
2161 u64 cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002162{
Leo Kime6e12662015-09-16 18:36:03 +09002163 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002164 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002165
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002166 priv = wiphy_priv(wiphy);
2167
2168 PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
2169
2170 s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
2171 return s32Error;
2172}
2173/**
2174 * @brief WILC_WFI_add_wilcvendorspec
2175 * @details Adding WILC information elemet to allow two WILC devices to
2176 * identify each other and connect
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002177 * @param[in] u8 * buf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002178 * @return void
2179 * @author mdaftedar
2180 * @date 01 JAN 2014
2181 * @version 1.0
2182 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002183void WILC_WFI_add_wilcvendorspec(u8 *buff)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002184{
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002185 memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002186}
2187/**
2188 * @brief WILC_WFI_mgmt_tx_frame
2189 * @details
2190 *
2191 * @param[in]
2192 * @return NONE.
2193 * @author mdaftedar
2194 * @date 01 JUL 2012
2195 * @version
2196 */
2197extern linux_wlan_t *g_linux_wlan;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002198extern bool bEnablePS;
Chaehyun Limc1560322015-09-22 18:34:51 +09002199static int mgmt_tx(struct wiphy *wiphy,
2200 struct wireless_dev *wdev,
2201 struct cfg80211_mgmt_tx_params *params,
2202 u64 *cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002203{
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002204 struct ieee80211_channel *chan = params->chan;
2205 unsigned int wait = params->wait;
2206 const u8 *buf = params->buf;
2207 size_t len = params->len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002208 const struct ieee80211_mgmt *mgmt;
2209 struct p2p_mgmt_data *mgmt_tx;
Chaehyun Lim27268872015-09-15 14:06:13 +09002210 struct wilc_priv *priv;
Leo Kim441dc602015-10-12 16:55:35 +09002211 struct host_if_drv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002212 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002213 perInterface_wlan_t *nic;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002214 u32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002215
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002216 nic = netdev_priv(wdev->netdev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002217 priv = wiphy_priv(wiphy);
Leo Kim441dc602015-10-12 16:55:35 +09002218 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002219
2220 *cookie = (unsigned long)buf;
2221 priv->u64tx_cookie = *cookie;
2222 mgmt = (const struct ieee80211_mgmt *) buf;
2223
2224 if (ieee80211_is_mgmt(mgmt->frame_control)) {
2225
2226 /*mgmt frame allocation*/
Glen Leef3052582015-09-10 12:03:04 +09002227 mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002228 if (mgmt_tx == NULL) {
2229 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
Leo Kime6e12662015-09-16 18:36:03 +09002230 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002231 }
Glen Leef3052582015-09-10 12:03:04 +09002232 mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002233 if (mgmt_tx->buff == NULL) {
2234 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
Tony Chof638dd32015-09-07 19:09:31 +09002235 kfree(mgmt_tx);
Leo Kime6e12662015-09-16 18:36:03 +09002236 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002237 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002238 memcpy(mgmt_tx->buff, buf, len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002239 mgmt_tx->size = len;
2240
2241
2242 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
2243 PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
2244 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2245 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2246 /*Save the current channel after we tune to it*/
Chaehyun Lim866a2c22015-10-02 16:41:21 +09002247 curr_channel = chan->hw_value;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002248 } else if (ieee80211_is_action(mgmt->frame_control)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09002249 PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002250
2251
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002252 if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002253 /*Only set the channel, if not a negotiation confirmation frame
2254 * (If Negotiation confirmation frame, force it
2255 * to be transmitted on the same negotiation channel)*/
2256
2257 if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
2258 buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
2259 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2260 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2261 /*Save the current channel after we tune to it*/
Chaehyun Lim866a2c22015-10-02 16:41:21 +09002262 curr_channel = chan->hw_value;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002263 }
2264 switch (buf[ACTION_SUBTYPE_ID]) {
2265 case GAS_INTIAL_REQ:
2266 {
2267 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
2268 break;
2269 }
2270
2271 case GAS_INTIAL_RSP:
2272 {
2273 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
2274 break;
2275 }
2276
2277 case PUBLIC_ACT_VENDORSPEC:
2278 {
2279 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2280 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002281 if (!memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002282 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2283 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2284 if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) {
2285 get_random_bytes(&u8P2Plocalrandom, 1);
2286 /*Increment the number to prevent if its 0*/
2287 u8P2Plocalrandom++;
2288 }
2289 }
2290
2291 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2292 || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2293 if (u8P2Plocalrandom > u8P2Precvrandom) {
2294 PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2295
2296 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2297 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002298 if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buf[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002299 if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
Dean Lee72ed4dc2015-06-12 14:11:44 +09002300 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002301
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002302 /*If using supplicant go intent, no need at all*/
2303 /*to parse transmitted negotiation frames*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002304 else
Dean Lee72ed4dc2015-06-12 14:11:44 +09002305 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002306 break;
2307 }
2308 }
2309
2310 if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
2311 WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]);
2312 mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
2313 mgmt_tx->size = buf_len;
2314 }
2315 } else
2316 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2317 }
2318
2319 } else {
2320 PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
2321 }
2322
2323 break;
2324 }
2325
2326 default:
2327 {
2328 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
2329 break;
2330 }
2331 }
2332
2333 }
2334
2335 PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
2336 pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait));
2337
2338 PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
2339
2340 }
2341
Glen Leec9d48342015-10-01 16:03:43 +09002342 wilc_wlan_txq_add_mgmt_pkt(mgmt_tx, mgmt_tx->buff,
2343 mgmt_tx->size,
2344 WILC_WFI_mgmt_tx_complete);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002345 } else {
2346 PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
2347 }
Leo Kimaaed3292015-10-12 16:55:38 +09002348 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002349}
2350
Chaehyun Lim85c587a2015-09-22 18:34:50 +09002351static int mgmt_tx_cancel_wait(struct wiphy *wiphy,
2352 struct wireless_dev *wdev,
2353 u64 cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002354{
Chaehyun Lim27268872015-09-15 14:06:13 +09002355 struct wilc_priv *priv;
Leo Kim441dc602015-10-12 16:55:35 +09002356 struct host_if_drv *pstrWFIDrv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002357
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002358 priv = wiphy_priv(wiphy);
Leo Kim441dc602015-10-12 16:55:35 +09002359 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002360
2361
2362 PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
2363 pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
2364
Dean Lee72ed4dc2015-06-12 14:11:44 +09002365 if (priv->bInP2PlistenState == false) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002366 cfg80211_remain_on_channel_expired(priv->wdev,
2367 priv->strRemainOnChanParams.u64ListenCookie,
2368 priv->strRemainOnChanParams.pstrListenChan,
2369 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002370 }
2371
2372 return 0;
2373}
2374
2375/**
Chaehyun Lim8e0735c2015-09-20 15:51:16 +09002376 * @brief wilc_mgmt_frame_register
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002377 * @details Notify driver that a management frame type was
2378 * registered. Note that this callback may not sleep, and cannot run
2379 * concurrently with itself.
2380 * @param[in]
2381 * @return NONE.
2382 * @author mdaftedar
2383 * @date 01 JUL 2012
2384 * @version
2385 */
Chaehyun Lim8e0735c2015-09-20 15:51:16 +09002386void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
2387 u16 frame_type, bool reg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002388{
2389
Chaehyun Lim27268872015-09-15 14:06:13 +09002390 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002391 perInterface_wlan_t *nic;
2392
2393
2394 priv = wiphy_priv(wiphy);
2395 nic = netdev_priv(priv->wdev->netdev);
2396
2397
2398
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002399 if (!frame_type)
2400 return;
2401
2402 PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
2403 switch (frame_type) {
2404 case PROBE_REQ:
2405 {
2406 nic->g_struct_frame_reg[0].frame_type = frame_type;
2407 nic->g_struct_frame_reg[0].reg = reg;
2408 }
2409 break;
2410
2411 case ACTION:
2412 {
2413 nic->g_struct_frame_reg[1].frame_type = frame_type;
2414 nic->g_struct_frame_reg[1].reg = reg;
2415 }
2416 break;
2417
2418 default:
2419 {
2420 break;
2421 }
2422
2423 }
2424 /*If mac is closed, then return*/
2425 if (!g_linux_wlan->wilc1000_initialized) {
2426 PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
2427 return;
2428 }
2429 host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg);
2430
2431
2432}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002433
2434/**
Chaehyun Lima8047e22015-09-22 18:34:48 +09002435 * @brief set_cqm_rssi_config
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002436 * @details Configure connection quality monitor RSSI threshold.
2437 * @param[in] struct wiphy *wiphy:
2438 * @param[in] struct net_device *dev:
2439 * @param[in] s32 rssi_thold:
2440 * @param[in] u32 rssi_hyst:
2441 * @return int : Return 0 on Success
2442 * @author mdaftedar
2443 * @date 01 MAR 2012
2444 * @version 1.0
2445 */
Chaehyun Lima8047e22015-09-22 18:34:48 +09002446static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev,
2447 s32 rssi_thold, u32 rssi_hyst)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002448{
2449 PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
2450 return 0;
2451
2452}
2453/**
Chaehyun Limbdb63382015-09-14 12:24:19 +09002454 * @brief dump_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002455 * @details Configure connection quality monitor RSSI threshold.
2456 * @param[in] struct wiphy *wiphy:
2457 * @param[in] struct net_device *dev
2458 * @param[in] int idx
2459 * @param[in] u8 *mac
2460 * @param[in] struct station_info *sinfo
2461 * @return int : Return 0 on Success
2462 * @author mdaftedar
2463 * @date 01 MAR 2012
2464 * @version 1.0
2465 */
Chaehyun Limbdb63382015-09-14 12:24:19 +09002466static int dump_station(struct wiphy *wiphy, struct net_device *dev,
2467 int idx, u8 *mac, struct station_info *sinfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002468{
Chaehyun Lim27268872015-09-15 14:06:13 +09002469 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002470
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002471 PRINT_D(CFG80211_DBG, "Dumping station information\n");
2472
2473 if (idx != 0)
2474 return -ENOENT;
2475
2476 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002477
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002478 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002479
2480 host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal));
2481
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002482 return 0;
2483
2484}
2485
2486
2487/**
Chaehyun Lim46530672015-09-22 18:34:46 +09002488 * @brief set_power_mgmt
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002489 * @details
2490 * @param[in]
2491 * @return int : Return 0 on Success.
2492 * @author mdaftedar
2493 * @date 01 JUL 2012
Chaehyun Limcdc9cba2015-09-22 18:34:47 +09002494 * @version 1.0
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002495 */
Chaehyun Lim46530672015-09-22 18:34:46 +09002496static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2497 bool enabled, int timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002498{
Chaehyun Lim27268872015-09-15 14:06:13 +09002499 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002500
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002501 PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
2502
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002503 if (wiphy == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002504 return -ENOENT;
2505
2506 priv = wiphy_priv(wiphy);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002507 if (priv->hWILCWFIDrv == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002508 PRINT_ER("Driver is NULL\n");
2509 return -EIO;
2510 }
2511
Abdul Hussain5a66bf22015-06-16 09:44:06 +00002512 if (bEnablePS)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002513 host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout);
2514
2515
Leo Kime6e12662015-09-16 18:36:03 +09002516 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002517
2518}
Glen Lee108b3432015-09-16 18:53:20 +09002519
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002520/**
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09002521 * @brief change_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002522 * @details Change type/configuration of virtual interface,
2523 * keep the struct wireless_dev's iftype updated.
2524 * @param[in] NONE
2525 * @return int : Return 0 on Success.
2526 * @author mdaftedar
2527 * @date 01 MAR 2012
2528 * @version 1.0
2529 */
2530void wilc1000_wlan_deinit(linux_wlan_t *nic);
2531int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
2532
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09002533static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
2534 enum nl80211_iftype type, u32 *flags, struct vif_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002535{
Chaehyun Lim27268872015-09-15 14:06:13 +09002536 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002537 perInterface_wlan_t *nic;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002538 u8 interface_type;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002539 u16 TID = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002540 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002541
2542 nic = netdev_priv(dev);
2543 priv = wiphy_priv(wiphy);
2544
2545 PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
2546 PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
2547 u8P2Plocalrandom = 0x01;
2548 u8P2Precvrandom = 0x00;
2549
Dean Lee72ed4dc2015-06-12 14:11:44 +09002550 bWilc_ie = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002551
Dean Lee72ed4dc2015-06-12 14:11:44 +09002552 g_obtainingIP = false;
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002553 del_timer(&hDuringIpTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002554 PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002555 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2556 if (g_ptk_keys_saved && g_gtk_keys_saved) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002557 Set_machw_change_vir_if(true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002558 }
2559
2560 switch (type) {
2561 case NL80211_IFTYPE_STATION:
2562 connecting = 0;
2563 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002564
2565 /* send delba over wlan interface */
2566
2567
2568 dev->ieee80211_ptr->iftype = type;
2569 priv->wdev->iftype = type;
2570 nic->monitor_flag = 0;
2571 nic->iftype = STATION_MODE;
2572
2573 /*Remove the enteries of the previously connected clients*/
2574 memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002575 interface_type = nic->iftype;
2576 nic->iftype = STATION_MODE;
2577
2578 if (g_linux_wlan->wilc1000_initialized) {
2579 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2580 /* ensure that the message Q is empty */
2581 host_int_wait_msg_queue_idle();
2582
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002583 /*Eliminate host interface blocking state*/
Greg Kroah-Hartman8990d852015-09-03 20:07:58 -07002584 up(&g_linux_wlan->cfg_event);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002585
2586 wilc1000_wlan_deinit(g_linux_wlan);
2587 wilc1000_wlan_init(dev, nic);
2588 g_wilc_initialized = 1;
2589 nic->iftype = interface_type;
2590
2591 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2592 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
Johnny Kim218dc402015-08-13 13:41:19 +09002593 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002594 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2595 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2596
2597 /*Add saved WEP keys, if any*/
2598 if (g_wep_keys_saved) {
Johnny Kim218dc402015-08-13 13:41:19 +09002599 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002600 g_key_wep_params.key_idx);
Johnny Kim218dc402015-08-13 13:41:19 +09002601 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002602 g_key_wep_params.key,
2603 g_key_wep_params.key_len,
2604 g_key_wep_params.key_idx);
2605 }
2606
2607 /*No matter the driver handler passed here, it will be overwriiten*/
2608 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2609 host_int_flush_join_req(priv->hWILCWFIDrv);
2610
2611 /*Add saved PTK and GTK keys, if any*/
2612 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2613 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2614 g_key_ptk_params.key[1],
2615 g_key_ptk_params.key[2]);
2616 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2617 g_key_gtk_params.key[1],
2618 g_key_gtk_params.key[2]);
Chaehyun Lim953d4172015-09-14 12:24:05 +09002619 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2620 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2621 g_add_ptk_key_params.key_idx,
2622 g_add_ptk_key_params.pairwise,
2623 g_add_ptk_key_params.mac_addr,
2624 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002625
Chaehyun Lim953d4172015-09-14 12:24:05 +09002626 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2627 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2628 g_add_gtk_key_params.key_idx,
2629 g_add_gtk_key_params.pairwise,
2630 g_add_gtk_key_params.mac_addr,
2631 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002632 }
2633
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002634 if (g_linux_wlan->wilc1000_initialized) {
2635 for (i = 0; i < num_reg_frame; i++) {
2636 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2637 nic->g_struct_frame_reg[i].reg);
2638 host_int_frame_register(priv->hWILCWFIDrv,
2639 nic->g_struct_frame_reg[i].frame_type,
2640 nic->g_struct_frame_reg[i].reg);
2641 }
2642 }
2643
Dean Lee72ed4dc2015-06-12 14:11:44 +09002644 bEnablePS = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002645 host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0);
2646 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002647 break;
2648
2649 case NL80211_IFTYPE_P2P_CLIENT:
Dean Lee72ed4dc2015-06-12 14:11:44 +09002650 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002651 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
2652 connecting = 0;
2653 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002654
2655 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2656
2657 dev->ieee80211_ptr->iftype = type;
2658 priv->wdev->iftype = type;
2659 nic->monitor_flag = 0;
2660
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002661 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2662 nic->iftype = CLIENT_MODE;
2663
2664
2665 if (g_linux_wlan->wilc1000_initialized) {
2666 /* ensure that the message Q is empty */
2667 host_int_wait_msg_queue_idle();
2668
2669 wilc1000_wlan_deinit(g_linux_wlan);
2670 wilc1000_wlan_init(dev, nic);
2671 g_wilc_initialized = 1;
2672
2673 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
Johnny Kim218dc402015-08-13 13:41:19 +09002674 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002675 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2676 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2677
2678 /*Add saved WEP keys, if any*/
2679 if (g_wep_keys_saved) {
Johnny Kim218dc402015-08-13 13:41:19 +09002680 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002681 g_key_wep_params.key_idx);
Johnny Kim218dc402015-08-13 13:41:19 +09002682 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002683 g_key_wep_params.key,
2684 g_key_wep_params.key_len,
2685 g_key_wep_params.key_idx);
2686 }
2687
2688 /*No matter the driver handler passed here, it will be overwriiten*/
2689 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2690 host_int_flush_join_req(priv->hWILCWFIDrv);
2691
2692 /*Add saved PTK and GTK keys, if any*/
2693 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2694 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2695 g_key_ptk_params.key[1],
2696 g_key_ptk_params.key[2]);
2697 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2698 g_key_gtk_params.key[1],
2699 g_key_gtk_params.key[2]);
Chaehyun Lim953d4172015-09-14 12:24:05 +09002700 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2701 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2702 g_add_ptk_key_params.key_idx,
2703 g_add_ptk_key_params.pairwise,
2704 g_add_ptk_key_params.mac_addr,
2705 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002706
Chaehyun Lim953d4172015-09-14 12:24:05 +09002707 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2708 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2709 g_add_gtk_key_params.key_idx,
2710 g_add_gtk_key_params.pairwise,
2711 g_add_gtk_key_params.mac_addr,
2712 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002713 }
2714
2715 /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/
Dean Lee72ed4dc2015-06-12 14:11:44 +09002716 refresh_scan(priv, 1, true);
2717 Set_machw_change_vir_if(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002718
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002719 if (g_linux_wlan->wilc1000_initialized) {
2720 for (i = 0; i < num_reg_frame; i++) {
2721 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2722 nic->g_struct_frame_reg[i].reg);
2723 host_int_frame_register(priv->hWILCWFIDrv,
2724 nic->g_struct_frame_reg[i].frame_type,
2725 nic->g_struct_frame_reg[i].reg);
2726 }
2727 }
2728 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002729 break;
2730
2731 case NL80211_IFTYPE_AP:
Dean Lee72ed4dc2015-06-12 14:11:44 +09002732 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002733 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002734 dev->ieee80211_ptr->iftype = type;
2735 priv->wdev->iftype = type;
2736 nic->iftype = AP_MODE;
Johnny Kim8a143302015-06-10 17:06:46 +09002737 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002738
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002739 PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
2740 linux_wlan_get_firmware(nic);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002741 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
2742 if (g_linux_wlan->wilc1000_initialized) {
2743 nic->iftype = AP_MODE;
2744 g_linux_wlan->wilc1000_initialized = 1;
2745 mac_close(dev);
2746 mac_open(dev);
2747
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002748 for (i = 0; i < num_reg_frame; i++) {
2749 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2750 nic->g_struct_frame_reg[i].reg);
2751 host_int_frame_register(priv->hWILCWFIDrv,
2752 nic->g_struct_frame_reg[i].frame_type,
2753 nic->g_struct_frame_reg[i].reg);
2754 }
2755 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002756 break;
2757
2758 case NL80211_IFTYPE_P2P_GO:
2759 PRINT_D(GENERIC_DBG, "start duringIP timer\n");
2760
Dean Lee72ed4dc2015-06-12 14:11:44 +09002761 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002762 mod_timer(&hDuringIpTimer, jiffies + msecs_to_jiffies(duringIP_TIME));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002763 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002764 /*Delete block ack has to be the latest config packet*/
2765 /*sent before downloading new FW. This is because it blocks on*/
2766 /*hWaitResponse semaphore, which allows previous config*/
2767 /*packets to actually take action on old FW*/
2768 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
Dean Lee72ed4dc2015-06-12 14:11:44 +09002769 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002770 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002771 dev->ieee80211_ptr->iftype = type;
2772 priv->wdev->iftype = type;
2773
Johnny Kim8a143302015-06-10 17:06:46 +09002774 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002775
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002776 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2777
2778
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002779 nic->iftype = GO_MODE;
2780
2781 /* ensure that the message Q is empty */
2782 host_int_wait_msg_queue_idle();
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002783 wilc1000_wlan_deinit(g_linux_wlan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002784 wilc1000_wlan_init(dev, nic);
2785 g_wilc_initialized = 1;
2786
2787
2788 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2789 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
Johnny Kim218dc402015-08-13 13:41:19 +09002790 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002791 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2792 host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
2793
2794 /*Add saved WEP keys, if any*/
2795 if (g_wep_keys_saved) {
Johnny Kim218dc402015-08-13 13:41:19 +09002796 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002797 g_key_wep_params.key_idx);
Johnny Kim218dc402015-08-13 13:41:19 +09002798 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002799 g_key_wep_params.key,
2800 g_key_wep_params.key_len,
2801 g_key_wep_params.key_idx);
2802 }
2803
2804 /*No matter the driver handler passed here, it will be overwriiten*/
2805 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2806 host_int_flush_join_req(priv->hWILCWFIDrv);
2807
2808 /*Add saved PTK and GTK keys, if any*/
2809 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2810 PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0],
2811 g_key_ptk_params.key[1],
2812 g_key_ptk_params.key[2],
2813 g_key_ptk_params.cipher);
2814 PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0],
2815 g_key_gtk_params.key[1],
2816 g_key_gtk_params.key[2],
2817 g_key_gtk_params.cipher);
Chaehyun Lim953d4172015-09-14 12:24:05 +09002818 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2819 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2820 g_add_ptk_key_params.key_idx,
2821 g_add_ptk_key_params.pairwise,
2822 g_add_ptk_key_params.mac_addr,
2823 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002824
Chaehyun Lim953d4172015-09-14 12:24:05 +09002825 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2826 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2827 g_add_gtk_key_params.key_idx,
2828 g_add_gtk_key_params.pairwise,
2829 g_add_gtk_key_params.mac_addr,
2830 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002831 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002832
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002833 if (g_linux_wlan->wilc1000_initialized) {
2834 for (i = 0; i < num_reg_frame; i++) {
2835 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2836 nic->g_struct_frame_reg[i].reg);
2837 host_int_frame_register(priv->hWILCWFIDrv,
2838 nic->g_struct_frame_reg[i].frame_type,
2839 nic->g_struct_frame_reg[i].reg);
2840 }
2841 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002842 break;
2843
2844 default:
2845 PRINT_ER("Unknown interface type= %d\n", type);
Leo Kimaaed3292015-10-12 16:55:38 +09002846 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002847 }
2848
Leo Kimaaed3292015-10-12 16:55:38 +09002849 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002850}
2851
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002852/* (austin.2013-07-23)
2853 *
2854 * To support revised cfg80211_ops
2855 *
2856 * add_beacon --> start_ap
2857 * set_beacon --> change_beacon
2858 * del_beacon --> stop_ap
2859 *
2860 * beacon_parameters --> cfg80211_ap_settings
2861 * cfg80211_beacon_data
2862 *
2863 * applicable for linux kernel 3.4+
2864 */
2865
2866/**
Chaehyun Lima13168d2015-09-14 12:24:12 +09002867 * @brief start_ap
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002868 * @details Add a beacon with given parameters, @head, @interval
2869 * and @dtim_period will be valid, @tail is optional.
2870 * @param[in] wiphy
2871 * @param[in] dev The net device structure
2872 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
2873 * @return int : Return 0 on Success.
2874 * @author austin
2875 * @date 23 JUL 2013
2876 * @version 1.0
2877 */
Chaehyun Lima13168d2015-09-14 12:24:12 +09002878static int start_ap(struct wiphy *wiphy, struct net_device *dev,
2879 struct cfg80211_ap_settings *settings)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002880{
2881 struct cfg80211_beacon_data *beacon = &(settings->beacon);
Chaehyun Lim27268872015-09-15 14:06:13 +09002882 struct wilc_priv *priv;
Leo Kime6e12662015-09-16 18:36:03 +09002883 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002884
2885 priv = wiphy_priv(wiphy);
2886 PRINT_D(HOSTAPD_DBG, "Starting ap\n");
2887
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302888 PRINT_D(HOSTAPD_DBG, "Interval = %d\n DTIM period = %d\n Head length = %zu Tail length = %zu\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002889 settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
2890
Chaehyun Lim80785a92015-09-14 12:24:01 +09002891 s32Error = set_channel(wiphy, &settings->chandef);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002892
Leo Kime6e12662015-09-16 18:36:03 +09002893 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002894 PRINT_ER("Error in setting channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002895
2896 linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2897
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002898 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
2899 settings->beacon_interval,
2900 settings->dtim_period,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002901 beacon->head_len, (u8 *)beacon->head,
2902 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002903
2904 return s32Error;
2905}
2906
2907/**
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09002908 * @brief change_beacon
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002909 * @details Add a beacon with given parameters, @head, @interval
2910 * and @dtim_period will be valid, @tail is optional.
2911 * @param[in] wiphy
2912 * @param[in] dev The net device structure
2913 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
2914 * @return int : Return 0 on Success.
2915 * @author austin
2916 * @date 23 JUL 2013
2917 * @version 1.0
2918 */
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09002919static int change_beacon(struct wiphy *wiphy, struct net_device *dev,
2920 struct cfg80211_beacon_data *beacon)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002921{
Chaehyun Lim27268872015-09-15 14:06:13 +09002922 struct wilc_priv *priv;
Leo Kime6e12662015-09-16 18:36:03 +09002923 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002924
2925 priv = wiphy_priv(wiphy);
2926 PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
2927
2928
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002929 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
2930 0,
2931 0,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002932 beacon->head_len, (u8 *)beacon->head,
2933 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002934
2935 return s32Error;
2936}
2937
2938/**
Chaehyun Limc8cddd72015-09-14 12:24:14 +09002939 * @brief stop_ap
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002940 * @details Remove beacon configuration and stop sending the beacon.
2941 * @param[in]
2942 * @return int : Return 0 on Success.
2943 * @author austin
2944 * @date 23 JUL 2013
2945 * @version 1.0
2946 */
Chaehyun Limc8cddd72015-09-14 12:24:14 +09002947static int stop_ap(struct wiphy *wiphy, struct net_device *dev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002948{
Leo Kime6e12662015-09-16 18:36:03 +09002949 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002950 struct wilc_priv *priv;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002951 u8 NullBssid[ETH_ALEN] = {0};
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002952
Leo Kim7ae43362015-09-16 18:35:59 +09002953 if (!wiphy)
2954 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002955
2956 priv = wiphy_priv(wiphy);
2957
2958 PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
2959
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002960 linux_wlan_set_bssid(dev, NullBssid);
2961
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002962 s32Error = host_int_del_beacon(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002963
Leo Kim7dc1d0c2015-09-16 18:36:00 +09002964 if (s32Error)
2965 PRINT_ER("Host delete beacon fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002966
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002967 return s32Error;
2968}
2969
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002970/**
Chaehyun Limed269552015-09-14 12:24:15 +09002971 * @brief add_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002972 * @details Add a new station.
2973 * @param[in]
2974 * @return int : Return 0 on Success.
2975 * @author mdaftedar
2976 * @date 01 MAR 2012
2977 * @version 1.0
2978 */
Chaehyun Limed269552015-09-14 12:24:15 +09002979static int add_station(struct wiphy *wiphy, struct net_device *dev,
2980 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002981{
Leo Kime6e12662015-09-16 18:36:03 +09002982 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002983 struct wilc_priv *priv;
Tony Cho6a89ba92015-09-21 12:16:46 +09002984 struct add_sta_param strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002985 perInterface_wlan_t *nic;
2986
Leo Kim7ae43362015-09-16 18:35:59 +09002987 if (!wiphy)
2988 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002989
2990 priv = wiphy_priv(wiphy);
2991 nic = netdev_priv(dev);
2992
2993 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002994 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
2995 memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002996 strStaParams.u16AssocID = params->aid;
2997 strStaParams.u8NumRates = params->supported_rates_len;
2998 strStaParams.pu8Rates = params->supported_rates;
2999
3000 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3001
3002 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],
3003 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3004 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3005 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3006
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003007 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003008 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003009 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003010 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003011 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3012 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003013 memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003014 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3015 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3016 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3017 }
3018
3019 strStaParams.u16FlagsMask = params->sta_flags_mask;
3020 strStaParams.u16FlagsSet = params->sta_flags_set;
3021
3022 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3023 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3024 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3025 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3026 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3027 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3028 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3029 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3030
3031 s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams);
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003032 if (s32Error)
3033 PRINT_ER("Host add station fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003034 }
3035
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003036 return s32Error;
3037}
3038
3039/**
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003040 * @brief del_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003041 * @details Remove a station; @mac may be NULL to remove all stations.
3042 * @param[in]
3043 * @return int : Return 0 on Success.
3044 * @author mdaftedar
3045 * @date 01 MAR 2012
3046 * @version 1.0
3047 */
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003048static int del_station(struct wiphy *wiphy, struct net_device *dev,
3049 struct station_del_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003050{
Arnd Bergmann057d1e92015-06-01 21:06:44 +02003051 const u8 *mac = params->mac;
Leo Kime6e12662015-09-16 18:36:03 +09003052 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09003053 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003054 perInterface_wlan_t *nic;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003055
Leo Kim7ae43362015-09-16 18:35:59 +09003056 if (!wiphy)
3057 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003058
3059 priv = wiphy_priv(wiphy);
3060 nic = netdev_priv(dev);
3061
3062 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3063 PRINT_D(HOSTAPD_DBG, "Deleting station\n");
3064
3065
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003066 if (mac == NULL) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05303067 PRINT_D(HOSTAPD_DBG, "All associated stations\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003068 s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss);
3069 } else {
3070 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]);
3071 }
3072
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003073 s32Error = host_int_del_station(priv->hWILCWFIDrv, mac);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003074
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003075 if (s32Error)
3076 PRINT_ER("Host delete station fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003077 }
3078 return s32Error;
3079}
3080
3081/**
Chaehyun Lim14b42082015-09-14 12:24:17 +09003082 * @brief change_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003083 * @details Modify a given station.
3084 * @param[in]
3085 * @return int : Return 0 on Success.
3086 * @author mdaftedar
3087 * @date 01 MAR 2012
3088 * @version 1.0
3089 */
Chaehyun Lim14b42082015-09-14 12:24:17 +09003090static int change_station(struct wiphy *wiphy, struct net_device *dev,
3091 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003092{
Leo Kime6e12662015-09-16 18:36:03 +09003093 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09003094 struct wilc_priv *priv;
Tony Cho6a89ba92015-09-21 12:16:46 +09003095 struct add_sta_param strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003096 perInterface_wlan_t *nic;
3097
3098
3099 PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
3100
Leo Kim7ae43362015-09-16 18:35:59 +09003101 if (!wiphy)
3102 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003103
3104 priv = wiphy_priv(wiphy);
3105 nic = netdev_priv(dev);
3106
3107 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003108 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003109 strStaParams.u16AssocID = params->aid;
3110 strStaParams.u8NumRates = params->supported_rates_len;
3111 strStaParams.pu8Rates = params->supported_rates;
3112
3113 PRINT_D(HOSTAPD_DBG, "BSSID = %x%x%x%x%x%x\n", strStaParams.au8BSSID[0], strStaParams.au8BSSID[1], strStaParams.au8BSSID[2], strStaParams.au8BSSID[3], strStaParams.au8BSSID[4],
3114 strStaParams.au8BSSID[5]);
3115 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3116 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3117
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003118 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003119 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003120 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003121 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003122 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3123 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003124 memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003125 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3126 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3127 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3128
3129 }
3130
3131 strStaParams.u16FlagsMask = params->sta_flags_mask;
3132 strStaParams.u16FlagsSet = params->sta_flags_set;
3133
3134 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3135 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3136 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3137 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3138 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3139 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3140 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3141 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3142
3143 s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams);
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003144 if (s32Error)
3145 PRINT_ER("Host edit station fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003146 }
3147 return s32Error;
3148}
3149
3150
3151/**
Chaehyun Lim69deb4c2015-09-14 12:24:09 +09003152 * @brief add_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003153 * @details
3154 * @param[in]
3155 * @return int : Return 0 on Success.
3156 * @author mdaftedar
3157 * @date 01 JUL 2012
3158 * @version 1.0
3159 */
Chaehyun Lim37316e82015-09-22 18:34:52 +09003160static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy,
3161 const char *name,
3162 unsigned char name_assign_type,
3163 enum nl80211_iftype type,
3164 u32 *flags,
3165 struct vif_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003166{
3167 perInterface_wlan_t *nic;
Chaehyun Lim27268872015-09-15 14:06:13 +09003168 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003169 struct net_device *new_ifc = NULL;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003170
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003171 priv = wiphy_priv(wiphy);
3172
3173
3174
3175 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
3176
3177 nic = netdev_priv(priv->wdev->netdev);
3178
3179
3180 if (type == NL80211_IFTYPE_MONITOR) {
3181 PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3182 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev);
3183 new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev);
3184 if (new_ifc != NULL) {
3185 PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003186 nic = netdev_priv(priv->wdev->netdev);
3187 nic->monitor_flag = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003188 } else
3189 PRINT_ER("Error in initializing monitor interface\n ");
3190 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003191 return priv->wdev;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003192}
3193
3194/**
Chaehyun Limb4a73352015-09-14 12:24:10 +09003195 * @brief del_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003196 * @details
3197 * @param[in]
3198 * @return int : Return 0 on Success.
3199 * @author mdaftedar
3200 * @date 01 JUL 2012
3201 * @version 1.0
3202 */
Chaehyun Lim956d7212015-09-22 18:34:49 +09003203static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003204{
3205 PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
Leo Kime6e12662015-09-16 18:36:03 +09003206 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003207}
3208
Chaehyun Lim08241922015-09-15 14:06:12 +09003209static struct cfg80211_ops wilc_cfg80211_ops = {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003210
Chaehyun Lim80785a92015-09-14 12:24:01 +09003211 .set_monitor_channel = set_channel,
Chaehyun Lim0e30d062015-09-14 12:24:02 +09003212 .scan = scan,
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +09003213 .connect = connect,
Chaehyun Limb027cde2015-09-14 12:24:04 +09003214 .disconnect = disconnect,
Chaehyun Lim953d4172015-09-14 12:24:05 +09003215 .add_key = add_key,
Chaehyun Lim3044ba72015-09-14 12:24:06 +09003216 .del_key = del_key,
Chaehyun Limf4893df2015-09-14 12:24:07 +09003217 .get_key = get_key,
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09003218 .set_default_key = set_default_key,
Chaehyun Lim69deb4c2015-09-14 12:24:09 +09003219 .add_virtual_intf = add_virtual_intf,
Chaehyun Limb4a73352015-09-14 12:24:10 +09003220 .del_virtual_intf = del_virtual_intf,
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09003221 .change_virtual_intf = change_virtual_intf,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003222
Chaehyun Lima13168d2015-09-14 12:24:12 +09003223 .start_ap = start_ap,
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09003224 .change_beacon = change_beacon,
Chaehyun Limc8cddd72015-09-14 12:24:14 +09003225 .stop_ap = stop_ap,
Chaehyun Limed269552015-09-14 12:24:15 +09003226 .add_station = add_station,
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003227 .del_station = del_station,
Chaehyun Lim14b42082015-09-14 12:24:17 +09003228 .change_station = change_station,
Chaehyun Limf06f5622015-09-14 12:24:18 +09003229 .get_station = get_station,
Chaehyun Limbdb63382015-09-14 12:24:19 +09003230 .dump_station = dump_station,
Chaehyun Lima5f7db62015-09-14 12:24:20 +09003231 .change_bss = change_bss,
Chaehyun Lima76b63e2015-09-14 12:24:21 +09003232 .set_wiphy_params = set_wiphy_params,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003233
Chaehyun Lim4d466572015-09-14 12:24:22 +09003234 .set_pmksa = set_pmksa,
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09003235 .del_pmksa = del_pmksa,
Chaehyun Limb33c39b2015-09-14 12:24:24 +09003236 .flush_pmksa = flush_pmksa,
Chaehyun Lim6d19d692015-09-14 12:24:25 +09003237 .remain_on_channel = remain_on_channel,
Chaehyun Lim1dd54402015-09-14 12:24:26 +09003238 .cancel_remain_on_channel = cancel_remain_on_channel,
Chaehyun Lim4a2f9b32015-09-14 12:24:27 +09003239 .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait,
Chaehyun Lim12a26a32015-09-14 12:24:28 +09003240 .mgmt_tx = mgmt_tx,
Chaehyun Lim8e0735c2015-09-20 15:51:16 +09003241 .mgmt_frame_register = wilc_mgmt_frame_register,
Chaehyun Lim46530672015-09-22 18:34:46 +09003242 .set_power_mgmt = set_power_mgmt,
Chaehyun Lima8047e22015-09-22 18:34:48 +09003243 .set_cqm_rssi_config = set_cqm_rssi_config,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003244
3245};
3246
3247
3248
3249
3250
3251/**
3252 * @brief WILC_WFI_update_stats
3253 * @details Modify parameters for a given BSS.
3254 * @param[in]
3255 * @return int : Return 0 on Success.
3256 * @author mdaftedar
3257 * @date 01 MAR 2012
Chaehyun Limcdc9cba2015-09-22 18:34:47 +09003258 * @version 1.0
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003259 */
3260int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
3261{
3262
Chaehyun Lim27268872015-09-15 14:06:13 +09003263 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003264
3265 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003266 switch (changed) {
3267
3268 case WILC_WFI_RX_PKT:
3269 {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003270 priv->netstats.rx_packets++;
3271 priv->netstats.rx_bytes += pktlen;
3272 priv->netstats.rx_time = get_jiffies_64();
3273 }
3274 break;
3275
3276 case WILC_WFI_TX_PKT:
3277 {
3278 priv->netstats.tx_packets++;
3279 priv->netstats.tx_bytes += pktlen;
3280 priv->netstats.tx_time = get_jiffies_64();
3281
3282 }
3283 break;
3284
3285 default:
3286 break;
3287 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003288 return 0;
3289}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003290
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003291/**
3292 * @brief WILC_WFI_CfgAlloc
3293 * @details Allocation of the wireless device structure and assigning it
3294 * to the cfg80211 operations structure.
3295 * @param[in] NONE
3296 * @return wireless_dev : Returns pointer to wireless_dev structure.
3297 * @author mdaftedar
3298 * @date 01 MAR 2012
3299 * @version 1.0
3300 */
3301struct wireless_dev *WILC_WFI_CfgAlloc(void)
3302{
3303
3304 struct wireless_dev *wdev;
3305
3306
3307 PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
3308 /*Allocating the wireless device structure*/
3309 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
3310 if (!wdev) {
3311 PRINT_ER("Cannot allocate wireless device\n");
3312 goto _fail_;
3313 }
3314
3315 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
Chaehyun Lim27268872015-09-15 14:06:13 +09003316 wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003317 if (!wdev->wiphy) {
3318 PRINT_ER("Cannot allocate wiphy\n");
3319 goto _fail_mem_;
3320
3321 }
3322
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003323 /* enable 802.11n HT */
3324 WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
3325 WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
3326 WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
3327 WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
3328 WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003329
3330 /*wiphy bands*/
3331 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
3332
3333 return wdev;
3334
3335_fail_mem_:
3336 kfree(wdev);
3337_fail_:
3338 return NULL;
3339
3340}
3341/**
Chaehyun Lim8459fd52015-09-20 15:51:09 +09003342 * @brief wilc_create_wiphy
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003343 * @details Registering of the wiphy structure and interface modes
3344 * @param[in] NONE
3345 * @return NONE
3346 * @author mdaftedar
3347 * @date 01 MAR 2012
3348 * @version 1.0
3349 */
Chaehyun Lim8459fd52015-09-20 15:51:09 +09003350struct wireless_dev *wilc_create_wiphy(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003351{
Chaehyun Lim27268872015-09-15 14:06:13 +09003352 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003353 struct wireless_dev *wdev;
Leo Kime6e12662015-09-16 18:36:03 +09003354 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003355
3356 PRINT_D(CFG80211_DBG, "Registering wifi device\n");
3357
3358 wdev = WILC_WFI_CfgAlloc();
3359 if (wdev == NULL) {
3360 PRINT_ER("CfgAlloc Failed\n");
3361 return NULL;
3362 }
3363
3364
3365 /*Return hardware description structure (wiphy)'s priv*/
3366 priv = wdev_priv(wdev);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003367 sema_init(&(priv->SemHandleUpdateStats), 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003368
3369 /*Link the wiphy with wireless structure*/
3370 priv->wdev = wdev;
3371
3372 /*Maximum number of probed ssid to be added by user for the scan request*/
3373 wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003374 /*Maximum number of pmkids to be cashed*/
3375 wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
3376 PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003377
3378 wdev->wiphy->max_scan_ie_len = 1000;
3379
3380 /*signal strength in mBm (100*dBm) */
3381 wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
3382
3383 /*Set the availaible cipher suites*/
3384 wdev->wiphy->cipher_suites = cipher_suites;
3385 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003386 /*Setting default managment types: for register action frame: */
3387 wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003388
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003389 wdev->wiphy->max_remain_on_channel_duration = 500;
3390 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3391 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
3392 BIT(NL80211_IFTYPE_P2P_CLIENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003393 wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003394 wdev->iftype = NL80211_IFTYPE_STATION;
3395
3396
3397
3398 PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3399 wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
3400 wdev->wiphy->interface_modes, wdev->iftype);
3401
3402 #ifdef WILC_SDIO
Chaehyun Limcdc9cba2015-09-22 18:34:47 +09003403 set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003404 #endif
3405
3406 /*Register wiphy structure*/
3407 s32Error = wiphy_register(wdev->wiphy);
3408 if (s32Error) {
3409 PRINT_ER("Cannot register wiphy device\n");
3410 /*should define what action to be taken in such failure*/
3411 } else {
3412 PRINT_D(CFG80211_DBG, "Successful Registering\n");
3413 }
3414
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003415 priv->dev = net;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003416 return wdev;
3417
3418
3419}
3420/**
3421 * @brief WILC_WFI_WiphyFree
3422 * @details Freeing allocation of the wireless device structure
3423 * @param[in] NONE
3424 * @return NONE
3425 * @author mdaftedar
3426 * @date 01 MAR 2012
3427 * @version 1.0
3428 */
Chaehyun Limdd4b6a82015-09-20 15:51:25 +09003429int wilc_init_host_int(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003430{
3431
Chaehyun Lim1a8ccd82015-09-20 15:51:23 +09003432 int s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003433
Chaehyun Lim27268872015-09-15 14:06:13 +09003434 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003435
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003436 PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
3437 priv = wdev_priv(net->ieee80211_ptr);
3438 if (op_ifcs == 0) {
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003439 setup_timer(&hAgingTimer, remove_network_from_shadow, 0);
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003440 setup_timer(&hDuringIpTimer, clear_duringIP, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003441 }
3442 op_ifcs++;
3443 if (s32Error < 0) {
3444 PRINT_ER("Failed to creat refresh Timer\n");
3445 return s32Error;
3446 }
3447
Dean Lee72ed4dc2015-06-12 14:11:44 +09003448 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003449
Dean Lee72ed4dc2015-06-12 14:11:44 +09003450 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003451
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003452 sema_init(&(priv->hSemScanReq), 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003453 s32Error = host_int_init(&priv->hWILCWFIDrv);
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003454 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003455 PRINT_ER("Error while initializing hostinterface\n");
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003456
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003457 return s32Error;
3458}
3459
3460/**
3461 * @brief WILC_WFI_WiphyFree
3462 * @details Freeing allocation of the wireless device structure
3463 * @param[in] NONE
3464 * @return NONE
3465 * @author mdaftedar
3466 * @date 01 MAR 2012
3467 * @version 1.0
3468 */
Chaehyun Lima9a16822015-09-20 15:51:24 +09003469int wilc_deinit_host_int(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003470{
Chaehyun Lim1a8ccd82015-09-20 15:51:23 +09003471 int s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003472
Chaehyun Lim27268872015-09-15 14:06:13 +09003473 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003474
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003475 priv = wdev_priv(net->ieee80211_ptr);
3476
Dean Lee72ed4dc2015-06-12 14:11:44 +09003477 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003478
Dean Lee72ed4dc2015-06-12 14:11:44 +09003479 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003480
3481 op_ifcs--;
3482
3483 s32Error = host_int_deinit(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003484
3485 /* Clear the Shadow scan */
3486 clear_shadow_scan(priv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003487 if (op_ifcs == 0) {
3488 PRINT_D(CORECONFIG_DBG, "destroy during ip\n");
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07003489 del_timer_sync(&hDuringIpTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003490 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003491
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003492 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003493 PRINT_ER("Error while deintializing host interface\n");
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003494
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003495 return s32Error;
3496}
3497
3498
3499/**
3500 * @brief WILC_WFI_WiphyFree
3501 * @details Freeing allocation of the wireless device structure
3502 * @param[in] NONE
3503 * @return NONE
3504 * @author mdaftedar
3505 * @date 01 MAR 2012
3506 * @version 1.0
3507 */
Chaehyun Lim96da20a2015-09-20 15:51:08 +09003508void wilc_free_wiphy(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003509{
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003510 PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
3511
Chaehyun Lim619837a2015-09-20 15:51:10 +09003512 if (!net) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003513 PRINT_D(INIT_DBG, "net_device is NULL\n");
3514 return;
3515 }
3516
Chaehyun Lim619837a2015-09-20 15:51:10 +09003517 if (!net->ieee80211_ptr) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003518 PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
3519 return;
3520 }
3521
Chaehyun Lim619837a2015-09-20 15:51:10 +09003522 if (!net->ieee80211_ptr->wiphy) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003523 PRINT_D(INIT_DBG, "wiphy is NULL\n");
3524 return;
3525 }
3526
3527 wiphy_unregister(net->ieee80211_ptr->wiphy);
3528
3529 PRINT_D(INIT_DBG, "Freeing wiphy\n");
3530 wiphy_free(net->ieee80211_ptr->wiphy);
3531 kfree(net->ieee80211_ptr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003532}