2 * @file wilc_wfi_cfgopertaions.c
3 * @brief CFG80211 Function Implementation functionality
8 * @sa wilc_wfi_cfgopertaions.h top level OS wrapper file
13 #include "wilc_wfi_cfgoperations.h"
14 #include "wilc_wlan.c"
16 #include "linux_wlan_sdio.h" /* tony : for set_wiphy_dev() */
20 #define IS_MANAGMEMENT 0x100
21 #define IS_MANAGMEMENT_CALLBACK 0x080
22 #define IS_MGMT_STATUS_SUCCES 0x040
23 #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
25 extern void linux_wlan_free(void *vp
);
26 extern int linux_wlan_get_firmware(perInterface_wlan_t
*p_nic
);
27 extern void linux_wlan_unlock(void *vp
);
28 extern u16
Set_machw_change_vir_if(bool bValue
);
30 extern int mac_open(struct net_device
*ndev
);
31 extern int mac_close(struct net_device
*ndev
);
33 tstrNetworkInfo astrLastScannedNtwrksShadow
[MAX_NUM_SCANNED_NETWORKS_SHADOW
];
34 u32 u32LastScannedNtwrksCountShadow
;
35 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
36 WILC_TimerHandle hDuringIpTimer
;
38 WILC_TimerHandle hAgingTimer
;
40 extern u8 u8ConnectedSSID
[6];
43 u8 g_wilc_initialized
= 1;
44 extern linux_wlan_t
*g_linux_wlan
;
45 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
46 extern bool g_obtainingIP
;
49 #define CHAN2G(_channel, _freq, _flags) { \
50 .band = IEEE80211_BAND_2GHZ, \
51 .center_freq = (_freq), \
52 .hw_value = (_channel), \
54 .max_antenna_gain = 0, \
58 /*Frequency range for channels*/
59 static struct ieee80211_channel WILC_WFI_2ghz_channels
[] = {
76 #define RATETAB_ENT(_rate, _hw_value, _flags) { \
78 .hw_value = (_hw_value), \
83 /* Table 6 in section 3.2.1.1 */
84 static struct ieee80211_rate WILC_WFI_rates
[] = {
85 RATETAB_ENT(10, 0, 0),
86 RATETAB_ENT(20, 1, 0),
87 RATETAB_ENT(55, 2, 0),
88 RATETAB_ENT(110, 3, 0),
89 RATETAB_ENT(60, 9, 0),
90 RATETAB_ENT(90, 6, 0),
91 RATETAB_ENT(120, 7, 0),
92 RATETAB_ENT(180, 8, 0),
93 RATETAB_ENT(240, 9, 0),
94 RATETAB_ENT(360, 10, 0),
95 RATETAB_ENT(480, 11, 0),
96 RATETAB_ENT(540, 12, 0),
100 struct p2p_mgmt_data
{
105 /*Global variable used to state the current connected STA channel*/
106 u8 u8WLANChannel
= INVALID_CHANNEL
;
111 u8 u8P2P_oui
[] = {0x50, 0x6f, 0x9A, 0x09};
112 u8 u8P2Plocalrandom
= 0x01;
113 u8 u8P2Precvrandom
= 0x00;
114 u8 u8P2P_vendorspec
[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
115 bool bWilc_ie
= false;
118 static struct ieee80211_supported_band WILC_WFI_band_2ghz
= {
119 .channels
= WILC_WFI_2ghz_channels
,
120 .n_channels
= ARRAY_SIZE(WILC_WFI_2ghz_channels
),
121 .bitrates
= WILC_WFI_rates
,
122 .n_bitrates
= ARRAY_SIZE(WILC_WFI_rates
),
127 struct add_key_params
{
132 struct add_key_params g_add_gtk_key_params
;
133 struct wilc_wfi_key g_key_gtk_params
;
134 struct add_key_params g_add_ptk_key_params
;
135 struct wilc_wfi_key g_key_ptk_params
;
136 struct wilc_wfi_wep_key g_key_wep_params
;
137 u8 g_flushing_in_progress
;
138 bool g_ptk_keys_saved
= false;
139 bool g_gtk_keys_saved
= false;
140 bool g_wep_keys_saved
= false;
142 #define AGING_TIME (9 * 1000)
143 #define duringIP_TIME 15000
145 void clear_shadow_scan(void *pUserVoid
)
147 struct WILC_WFI_priv
*priv
;
149 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
151 WILC_TimerDestroy(&hAgingTimer
, NULL
);
152 PRINT_INFO(CORECONFIG_DBG
, "destroy aging timer\n");
154 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
155 if (astrLastScannedNtwrksShadow
[u32LastScannedNtwrksCountShadow
].pu8IEs
!= NULL
) {
156 WILC_FREE(astrLastScannedNtwrksShadow
[i
].pu8IEs
);
157 astrLastScannedNtwrksShadow
[u32LastScannedNtwrksCountShadow
].pu8IEs
= NULL
;
160 host_int_freeJoinParams(astrLastScannedNtwrksShadow
[i
].pJoinParams
);
161 astrLastScannedNtwrksShadow
[i
].pJoinParams
= NULL
;
163 u32LastScannedNtwrksCountShadow
= 0;
168 uint32_t get_rssi_avg(tstrNetworkInfo
*pstrNetworkInfo
)
172 uint8_t num_rssi
= (pstrNetworkInfo
->strRssi
.u8Full
) ? NUM_RSSI
: (pstrNetworkInfo
->strRssi
.u8Index
);
174 for (i
= 0; i
< num_rssi
; i
++)
175 rssi_v
+= pstrNetworkInfo
->strRssi
.as8RSSI
[i
];
181 void refresh_scan(void *pUserVoid
, uint8_t all
, bool bDirectScan
)
183 struct WILC_WFI_priv
*priv
;
185 struct cfg80211_bss
*bss
= NULL
;
189 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
190 wiphy
= priv
->dev
->ieee80211_ptr
->wiphy
;
192 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
193 tstrNetworkInfo
*pstrNetworkInfo
;
194 pstrNetworkInfo
= &(astrLastScannedNtwrksShadow
[i
]);
197 if ((!pstrNetworkInfo
->u8Found
) || all
) {
199 struct ieee80211_channel
*channel
;
201 if (pstrNetworkInfo
!= NULL
) {
203 s32Freq
= ieee80211_channel_to_frequency((s32
)pstrNetworkInfo
->u8channel
, IEEE80211_BAND_2GHZ
);
204 channel
= ieee80211_get_channel(wiphy
, s32Freq
);
206 rssi
= get_rssi_avg(pstrNetworkInfo
);
207 if (WILC_memcmp("DIRECT-", pstrNetworkInfo
->au8ssid
, 7) || bDirectScan
) {
208 bss
= cfg80211_inform_bss(wiphy
, channel
, CFG80211_BSS_FTYPE_UNKNOWN
, pstrNetworkInfo
->au8bssid
, pstrNetworkInfo
->u64Tsf
, pstrNetworkInfo
->u16CapInfo
,
209 pstrNetworkInfo
->u16BeaconPeriod
, (const u8
*)pstrNetworkInfo
->pu8IEs
,
210 (size_t)pstrNetworkInfo
->u16IEsLen
, (((s32
)rssi
) * 100), GFP_KERNEL
);
211 cfg80211_put_bss(wiphy
, bss
);
220 void reset_shadow_found(void *pUserVoid
)
222 struct WILC_WFI_priv
*priv
;
224 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
225 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
226 astrLastScannedNtwrksShadow
[i
].u8Found
= 0;
231 void update_scan_time(void *pUserVoid
)
233 struct WILC_WFI_priv
*priv
;
235 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
236 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
237 astrLastScannedNtwrksShadow
[i
].u32TimeRcvdInScan
= jiffies
;
241 void remove_network_from_shadow(void *pUserVoid
)
243 struct WILC_WFI_priv
*priv
;
244 unsigned long now
= jiffies
;
247 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
249 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
250 if (time_after(now
, astrLastScannedNtwrksShadow
[i
].u32TimeRcvdInScan
+ (unsigned long)(SCAN_RESULT_EXPIRE
))) {
251 PRINT_D(CFG80211_DBG
, "Network expired in ScanShadow: %s \n", astrLastScannedNtwrksShadow
[i
].au8ssid
);
253 if (astrLastScannedNtwrksShadow
[i
].pu8IEs
!= NULL
) {
254 WILC_FREE(astrLastScannedNtwrksShadow
[i
].pu8IEs
);
255 astrLastScannedNtwrksShadow
[i
].pu8IEs
= NULL
;
258 host_int_freeJoinParams(astrLastScannedNtwrksShadow
[i
].pJoinParams
);
260 for (j
= i
; (j
< u32LastScannedNtwrksCountShadow
- 1); j
++) {
261 astrLastScannedNtwrksShadow
[j
] = astrLastScannedNtwrksShadow
[j
+ 1];
263 u32LastScannedNtwrksCountShadow
--;
267 PRINT_D(CFG80211_DBG
, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow
);
268 if (u32LastScannedNtwrksCountShadow
!= 0)
269 WILC_TimerStart(&(hAgingTimer
), AGING_TIME
, pUserVoid
, NULL
);
271 PRINT_D(CFG80211_DBG
, "No need to restart Aging timer\n");
274 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
275 void clear_duringIP(void *pUserVoid
)
277 PRINT_D(GENERIC_DBG
, "GO:IP Obtained , enable scan\n");
278 g_obtainingIP
= false;
282 int8_t is_network_in_shadow(tstrNetworkInfo
*pstrNetworkInfo
, void *pUserVoid
)
284 struct WILC_WFI_priv
*priv
;
288 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
289 if (u32LastScannedNtwrksCountShadow
== 0) {
290 PRINT_D(CFG80211_DBG
, "Starting Aging timer\n");
291 WILC_TimerStart(&(hAgingTimer
), AGING_TIME
, pUserVoid
, NULL
);
294 /* Linear search for now */
295 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
296 if (WILC_memcmp(astrLastScannedNtwrksShadow
[i
].au8bssid
,
297 pstrNetworkInfo
->au8bssid
, 6) == 0) {
306 void add_network_to_shadow(tstrNetworkInfo
*pstrNetworkInfo
, void *pUserVoid
, void *pJoinParams
)
308 struct WILC_WFI_priv
*priv
;
309 int8_t ap_found
= is_network_in_shadow(pstrNetworkInfo
, pUserVoid
);
310 uint32_t ap_index
= 0;
311 uint8_t rssi_index
= 0;
312 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
314 if (u32LastScannedNtwrksCountShadow
>= MAX_NUM_SCANNED_NETWORKS_SHADOW
) {
315 PRINT_D(CFG80211_DBG
, "Shadow network reached its maximum limit\n");
318 if (ap_found
== -1) {
319 ap_index
= u32LastScannedNtwrksCountShadow
;
320 u32LastScannedNtwrksCountShadow
++;
325 rssi_index
= astrLastScannedNtwrksShadow
[ap_index
].strRssi
.u8Index
;
326 astrLastScannedNtwrksShadow
[ap_index
].strRssi
.as8RSSI
[rssi_index
++] = pstrNetworkInfo
->s8rssi
;
327 if (rssi_index
== NUM_RSSI
) {
329 astrLastScannedNtwrksShadow
[ap_index
].strRssi
.u8Full
= 1;
331 astrLastScannedNtwrksShadow
[ap_index
].strRssi
.u8Index
= rssi_index
;
333 astrLastScannedNtwrksShadow
[ap_index
].s8rssi
= pstrNetworkInfo
->s8rssi
;
334 astrLastScannedNtwrksShadow
[ap_index
].u16CapInfo
= pstrNetworkInfo
->u16CapInfo
;
336 astrLastScannedNtwrksShadow
[ap_index
].u8SsidLen
= pstrNetworkInfo
->u8SsidLen
;
337 WILC_memcpy(astrLastScannedNtwrksShadow
[ap_index
].au8ssid
,
338 pstrNetworkInfo
->au8ssid
, pstrNetworkInfo
->u8SsidLen
);
340 WILC_memcpy(astrLastScannedNtwrksShadow
[ap_index
].au8bssid
,
341 pstrNetworkInfo
->au8bssid
, ETH_ALEN
);
343 astrLastScannedNtwrksShadow
[ap_index
].u16BeaconPeriod
= pstrNetworkInfo
->u16BeaconPeriod
;
344 astrLastScannedNtwrksShadow
[ap_index
].u8DtimPeriod
= pstrNetworkInfo
->u8DtimPeriod
;
345 astrLastScannedNtwrksShadow
[ap_index
].u8channel
= pstrNetworkInfo
->u8channel
;
347 astrLastScannedNtwrksShadow
[ap_index
].u16IEsLen
= pstrNetworkInfo
->u16IEsLen
;
348 astrLastScannedNtwrksShadow
[ap_index
].u64Tsf
= pstrNetworkInfo
->u64Tsf
;
350 WILC_FREE(astrLastScannedNtwrksShadow
[ap_index
].pu8IEs
);
351 astrLastScannedNtwrksShadow
[ap_index
].pu8IEs
=
352 (u8
*)WILC_MALLOC(pstrNetworkInfo
->u16IEsLen
); /* will be deallocated by the WILC_WFI_CfgScan() function */
353 WILC_memcpy(astrLastScannedNtwrksShadow
[ap_index
].pu8IEs
,
354 pstrNetworkInfo
->pu8IEs
, pstrNetworkInfo
->u16IEsLen
);
356 astrLastScannedNtwrksShadow
[ap_index
].u32TimeRcvdInScan
= jiffies
;
357 astrLastScannedNtwrksShadow
[ap_index
].u32TimeRcvdInScanCached
= jiffies
;
358 astrLastScannedNtwrksShadow
[ap_index
].u8Found
= 1;
360 host_int_freeJoinParams(astrLastScannedNtwrksShadow
[ap_index
].pJoinParams
);
361 astrLastScannedNtwrksShadow
[ap_index
].pJoinParams
= pJoinParams
;
367 * @brief CfgScanResult
368 * @details Callback function which returns the scan results found
370 * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
371 * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
372 * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
373 * void* pUserVoid: Private structure associated with the wireless interface
379 static void CfgScanResult(tenuScanEvent enuScanEvent
, tstrNetworkInfo
*pstrNetworkInfo
, void *pUserVoid
, void *pJoinParams
)
381 struct WILC_WFI_priv
*priv
;
384 struct ieee80211_channel
*channel
;
385 s32 s32Error
= WILC_SUCCESS
;
386 struct cfg80211_bss
*bss
= NULL
;
388 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
389 if (priv
->bCfgScanning
== true) {
390 if (enuScanEvent
== SCAN_EVENT_NETWORK_FOUND
) {
391 wiphy
= priv
->dev
->ieee80211_ptr
->wiphy
;
392 WILC_NULLCHECK(s32Error
, wiphy
);
393 if (wiphy
->signal_type
== CFG80211_SIGNAL_TYPE_UNSPEC
395 ((((s32
)pstrNetworkInfo
->s8rssi
) * 100) < 0
397 (((s32
)pstrNetworkInfo
->s8rssi
) * 100) > 100)
399 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
402 if (pstrNetworkInfo
!= NULL
) {
403 s32Freq
= ieee80211_channel_to_frequency((s32
)pstrNetworkInfo
->u8channel
, IEEE80211_BAND_2GHZ
);
404 channel
= ieee80211_get_channel(wiphy
, s32Freq
);
406 WILC_NULLCHECK(s32Error
, channel
);
408 PRINT_INFO(CFG80211_DBG
, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
409 "BeaconPeriod: %d \n", channel
->center_freq
, (((s32
)pstrNetworkInfo
->s8rssi
) * 100),
410 pstrNetworkInfo
->u16CapInfo
, pstrNetworkInfo
->u16BeaconPeriod
);
412 if (pstrNetworkInfo
->bNewNetwork
== true) {
413 if (priv
->u32RcvdChCount
< MAX_NUM_SCANNED_NETWORKS
) { /* TODO: mostafa: to be replaced by */
415 PRINT_D(CFG80211_DBG
, "Network %s found\n", pstrNetworkInfo
->au8ssid
);
418 priv
->u32RcvdChCount
++;
422 if (pJoinParams
== NULL
) {
423 PRINT_INFO(CORECONFIG_DBG
, ">> Something really bad happened\n");
425 add_network_to_shadow(pstrNetworkInfo
, priv
, pJoinParams
);
427 /*P2P peers are sent to WPA supplicant and added to shadow table*/
429 if (!(WILC_memcmp("DIRECT-", pstrNetworkInfo
->au8ssid
, 7))) {
430 bss
= cfg80211_inform_bss(wiphy
, channel
, CFG80211_BSS_FTYPE_UNKNOWN
, pstrNetworkInfo
->au8bssid
, pstrNetworkInfo
->u64Tsf
, pstrNetworkInfo
->u16CapInfo
,
431 pstrNetworkInfo
->u16BeaconPeriod
, (const u8
*)pstrNetworkInfo
->pu8IEs
,
432 (size_t)pstrNetworkInfo
->u16IEsLen
, (((s32
)pstrNetworkInfo
->s8rssi
) * 100), GFP_KERNEL
);
433 cfg80211_put_bss(wiphy
, bss
);
438 PRINT_ER("Discovered networks exceeded the max limit\n");
442 /* So this network is discovered before, we'll just update its RSSI */
443 for (i
= 0; i
< priv
->u32RcvdChCount
; i
++) {
444 if (WILC_memcmp(astrLastScannedNtwrksShadow
[i
].au8bssid
, pstrNetworkInfo
->au8bssid
, 6) == 0) {
445 PRINT_D(CFG80211_DBG
, "Update RSSI of %s \n", astrLastScannedNtwrksShadow
[i
].au8ssid
);
447 astrLastScannedNtwrksShadow
[i
].s8rssi
= pstrNetworkInfo
->s8rssi
;
448 astrLastScannedNtwrksShadow
[i
].u32TimeRcvdInScan
= jiffies
;
454 } else if (enuScanEvent
== SCAN_EVENT_DONE
) {
455 PRINT_D(CFG80211_DBG
, "Scan Done[%p] \n", priv
->dev
);
456 PRINT_D(CFG80211_DBG
, "Refreshing Scan ... \n");
457 refresh_scan(priv
, 1, false);
459 if (priv
->u32RcvdChCount
> 0) {
460 PRINT_D(CFG80211_DBG
, "%d Network(s) found \n", priv
->u32RcvdChCount
);
462 PRINT_D(CFG80211_DBG
, "No networks found \n");
465 down(&(priv
->hSemScanReq
));
467 if (priv
->pstrScanReq
!= NULL
) {
468 cfg80211_scan_done(priv
->pstrScanReq
, false);
469 priv
->u32RcvdChCount
= 0;
470 priv
->bCfgScanning
= false;
471 priv
->pstrScanReq
= NULL
;
473 up(&(priv
->hSemScanReq
));
476 /*Aborting any scan operation during mac close*/
477 else if (enuScanEvent
== SCAN_EVENT_ABORTED
) {
478 down(&(priv
->hSemScanReq
));
480 PRINT_D(CFG80211_DBG
, "Scan Aborted \n");
481 if (priv
->pstrScanReq
!= NULL
) {
483 update_scan_time(priv
);
484 refresh_scan(priv
, 1, false);
486 cfg80211_scan_done(priv
->pstrScanReq
, false);
487 priv
->bCfgScanning
= false;
488 priv
->pstrScanReq
= NULL
;
490 up(&(priv
->hSemScanReq
));
502 * @brief WILC_WFI_Set_PMKSA
503 * @details Check if pmksa is cached and set it.
505 * @return int : Return 0 on Success
510 int WILC_WFI_Set_PMKSA(u8
*bssid
, struct WILC_WFI_priv
*priv
)
513 s32 s32Error
= WILC_SUCCESS
;
516 for (i
= 0; i
< priv
->pmkid_list
.numpmkid
; i
++) {
518 if (!WILC_memcmp(bssid
, priv
->pmkid_list
.pmkidlist
[i
].bssid
,
520 PRINT_D(CFG80211_DBG
, "PMKID successful comparison");
522 /*If bssid is found, set the values*/
523 s32Error
= host_int_set_pmkid_info(priv
->hWILCWFIDrv
, &priv
->pmkid_list
);
525 if (s32Error
!= WILC_SUCCESS
)
526 PRINT_ER("Error in pmkid\n");
536 int linux_wlan_set_bssid(struct net_device
*wilc_netdev
, uint8_t *pBSSID
);
540 * @brief CfgConnectResult
542 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
543 * connection response or disconnection notification.
544 * tstrConnectInfo* pstrConnectInfo: COnnection information.
545 * u8 u8MacStatus: Mac Status from firmware
546 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
547 * void* pUserVoid: Private data associated with wireless interface
555 static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent
,
556 tstrConnectInfo
*pstrConnectInfo
,
558 tstrDisconnectNotifInfo
*pstrDisconnectNotifInfo
,
561 struct WILC_WFI_priv
*priv
;
562 struct net_device
*dev
;
564 tstrWILC_WFIDrv
*pstrWFIDrv
;
566 u8 NullBssid
[ETH_ALEN
] = {0};
569 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
572 pstrWFIDrv
= (tstrWILC_WFIDrv
*)priv
->hWILCWFIDrv
;
575 if (enuConnDisconnEvent
== CONN_DISCONN_EVENT_CONN_RESP
) {
577 u16 u16ConnectStatus
= WLAN_STATUS_SUCCESS
;
579 u16ConnectStatus
= pstrConnectInfo
->u16ConnectStatus
;
581 PRINT_D(CFG80211_DBG
, " Connection response received = %d\n", u8MacStatus
);
583 if ((u8MacStatus
== MAC_DISCONNECTED
) &&
584 (pstrConnectInfo
->u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
585 /* The case here is that our station was waiting for association response frame and has just received it containing status code
586 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
587 u16ConnectStatus
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
588 linux_wlan_set_bssid(priv
->dev
, NullBssid
);
589 WILC_memset(u8ConnectedSSID
, 0, ETH_ALEN
);
592 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
594 if (!pstrWFIDrv
->u8P2PConnect
)
595 u8WLANChannel
= INVALID_CHANNEL
;
598 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d \n", u16ConnectStatus
, u8MacStatus
);
601 if (u16ConnectStatus
== WLAN_STATUS_SUCCESS
) {
602 bool bNeedScanRefresh
= false;
605 PRINT_INFO(CFG80211_DBG
, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo
->au8bssid
[0],
606 pstrConnectInfo
->au8bssid
[1], pstrConnectInfo
->au8bssid
[2], pstrConnectInfo
->au8bssid
[3], pstrConnectInfo
->au8bssid
[4], pstrConnectInfo
->au8bssid
[5]);
607 WILC_memcpy(priv
->au8AssociatedBss
, pstrConnectInfo
->au8bssid
, ETH_ALEN
);
609 /* BugID_4209: if this network has expired in the scan results in the above nl80211 layer, refresh them here by calling
610 * cfg80211_inform_bss() with the last Scan results before calling cfg80211_connect_result() to avoid
611 * Linux kernel warning generated at the nl80211 layer */
613 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
614 if (WILC_memcmp(astrLastScannedNtwrksShadow
[i
].au8bssid
,
615 pstrConnectInfo
->au8bssid
, ETH_ALEN
) == 0) {
616 unsigned long now
= jiffies
;
619 astrLastScannedNtwrksShadow
[i
].u32TimeRcvdInScanCached
+ (unsigned long)(nl80211_SCAN_RESULT_EXPIRE
- (1 * HZ
)))) {
620 bNeedScanRefresh
= true;
627 if (bNeedScanRefresh
) {
629 /*Also, refrsh DIRECT- results if */
630 refresh_scan(priv
, 1, true);
637 PRINT_D(CFG80211_DBG
, "Association request info elements length = %zu\n", pstrConnectInfo
->ReqIEsLen
);
639 PRINT_D(CFG80211_DBG
, "Association response info elements length = %d\n", pstrConnectInfo
->u16RespIEsLen
);
641 cfg80211_connect_result(dev
, pstrConnectInfo
->au8bssid
,
642 pstrConnectInfo
->pu8ReqIEs
, pstrConnectInfo
->ReqIEsLen
,
643 pstrConnectInfo
->pu8RespIEs
, pstrConnectInfo
->u16RespIEsLen
,
644 u16ConnectStatus
, GFP_KERNEL
); /* TODO: mostafa: u16ConnectStatus to */
645 /* be replaced by pstrConnectInfo->u16ConnectStatus */
646 } else if (enuConnDisconnEvent
== CONN_DISCONN_EVENT_DISCONN_NOTIF
) {
647 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
648 g_obtainingIP
= false;
650 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
651 pstrDisconnectNotifInfo
->u16reason
, priv
->dev
);
652 u8P2Plocalrandom
= 0x01;
653 u8P2Precvrandom
= 0x00;
655 WILC_memset(priv
->au8AssociatedBss
, 0, ETH_ALEN
);
656 linux_wlan_set_bssid(priv
->dev
, NullBssid
);
657 WILC_memset(u8ConnectedSSID
, 0, ETH_ALEN
);
660 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
662 if (!pstrWFIDrv
->u8P2PConnect
)
663 u8WLANChannel
= INVALID_CHANNEL
;
666 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
667 * virtual interface to station*/
668 if ((pstrWFIDrv
->IFC_UP
) && (dev
== g_linux_wlan
->strInterfaceInfo
[1].wilc_netdev
)) {
669 pstrDisconnectNotifInfo
->u16reason
= 3;
672 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
673 * to scan again and retry the connection*/
674 else if ((!pstrWFIDrv
->IFC_UP
) && (dev
== g_linux_wlan
->strInterfaceInfo
[1].wilc_netdev
)) {
675 pstrDisconnectNotifInfo
->u16reason
= 1;
677 cfg80211_disconnected(dev
, pstrDisconnectNotifInfo
->u16reason
, pstrDisconnectNotifInfo
->ie
,
678 pstrDisconnectNotifInfo
->ie_len
, GFP_KERNEL
);
686 * @brief WILC_WFI_CfgSetChannel
687 * @details Set channel for a given wireless interface. Some devices
688 * may support multi-channel operation (by channel hopping) so cfg80211
689 * doesn't verify much. Note, however, that the passed netdev may be
690 * %NULL as well if the user requested changing the channel for the
691 * device itself, or for a monitor interface.
693 * @return int : Return 0 on Success
698 static int WILC_WFI_CfgSetChannel(struct wiphy
*wiphy
,
699 struct cfg80211_chan_def
*chandef
)
703 struct WILC_WFI_priv
*priv
;
704 s32 s32Error
= WILC_SUCCESS
;
705 priv
= wiphy_priv(wiphy
);
707 channelnum
= ieee80211_frequency_to_channel(chandef
->chan
->center_freq
);
708 PRINT_D(CFG80211_DBG
, "Setting channel %d with frequency %d\n", channelnum
, chandef
->chan
->center_freq
);
710 u8CurrChannel
= channelnum
;
711 s32Error
= host_int_set_mac_chnl_num(priv
->hWILCWFIDrv
, channelnum
);
713 if (s32Error
!= WILC_SUCCESS
)
714 PRINT_ER("Error in setting channel %d\n", channelnum
);
720 * @brief WILC_WFI_CfgScan
721 * @details Request to do a scan. If returning zero, the scan request is given
722 * the driver, and will be valid until passed to cfg80211_scan_done().
723 * For scan results, call cfg80211_inform_bss(); you can call this outside
724 * the scan/scan_done bracket too.
726 * @return int : Return 0 on Success
733 * kernel version 3.8.8 supported
734 * tony, sswd, WILC-KR, 2013-10-29
736 static int WILC_WFI_CfgScan(struct wiphy
*wiphy
, struct cfg80211_scan_request
*request
)
738 struct WILC_WFI_priv
*priv
;
740 s32 s32Error
= WILC_SUCCESS
;
741 u8 au8ScanChanList
[MAX_NUM_SCANNED_NETWORKS
];
742 tstrHiddenNetwork strHiddenNetwork
;
744 priv
= wiphy_priv(wiphy
);
746 priv
->pstrScanReq
= request
;
748 priv
->u32RcvdChCount
= 0;
750 host_int_set_wfi_drv_handler((u32
)priv
->hWILCWFIDrv
);
753 reset_shadow_found(priv
);
755 priv
->bCfgScanning
= true;
756 if (request
->n_channels
<= MAX_NUM_SCANNED_NETWORKS
) { /* TODO: mostafa: to be replaced by */
758 for (i
= 0; i
< request
->n_channels
; i
++) {
759 au8ScanChanList
[i
] = (u8
)ieee80211_frequency_to_channel(request
->channels
[i
]->center_freq
);
760 PRINT_INFO(CFG80211_DBG
, "ScanChannel List[%d] = %d,", i
, au8ScanChanList
[i
]);
763 PRINT_D(CFG80211_DBG
, "Requested num of scan channel %d\n", request
->n_channels
);
764 PRINT_D(CFG80211_DBG
, "Scan Request IE len = %zu\n", request
->ie_len
);
766 PRINT_D(CFG80211_DBG
, "Number of SSIDs %d\n", request
->n_ssids
);
768 if (request
->n_ssids
>= 1) {
771 strHiddenNetwork
.pstrHiddenNetworkInfo
= WILC_MALLOC(request
->n_ssids
* sizeof(tstrHiddenNetwork
));
772 strHiddenNetwork
.u8ssidnum
= request
->n_ssids
;
776 for (i
= 0; i
< request
->n_ssids
; i
++) {
778 if (request
->ssids
[i
].ssid
!= NULL
&& request
->ssids
[i
].ssid_len
!= 0) {
779 strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].pu8ssid
= WILC_MALLOC(request
->ssids
[i
].ssid_len
);
780 WILC_memcpy(strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].pu8ssid
, request
->ssids
[i
].ssid
, request
->ssids
[i
].ssid_len
);
781 strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].u8ssidlen
= request
->ssids
[i
].ssid_len
;
783 PRINT_D(CFG80211_DBG
, "Received one NULL SSID \n");
784 strHiddenNetwork
.u8ssidnum
-= 1;
787 PRINT_D(CFG80211_DBG
, "Trigger Scan Request \n");
788 s32Error
= host_int_scan(priv
->hWILCWFIDrv
, USER_SCAN
, ACTIVE_SCAN
,
789 au8ScanChanList
, request
->n_channels
,
790 (const u8
*)request
->ie
, request
->ie_len
,
791 CfgScanResult
, (void *)priv
, &strHiddenNetwork
);
793 PRINT_D(CFG80211_DBG
, "Trigger Scan Request \n");
794 s32Error
= host_int_scan(priv
->hWILCWFIDrv
, USER_SCAN
, ACTIVE_SCAN
,
795 au8ScanChanList
, request
->n_channels
,
796 (const u8
*)request
->ie
, request
->ie_len
,
797 CfgScanResult
, (void *)priv
, NULL
);
801 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
805 if (s32Error
!= WILC_SUCCESS
) {
807 PRINT_WRN(CFG80211_DBG
, "Device is busy: Error(%d)\n", s32Error
);
814 * @brief WILC_WFI_CfgConnect
815 * @details Connect to the ESS with the specified parameters. When connected,
816 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
817 * If the connection fails for some reason, call cfg80211_connect_result()
818 * with the status from the AP.
820 * @return int : Return 0 on Success
825 static int WILC_WFI_CfgConnect(struct wiphy
*wiphy
, struct net_device
*dev
,
826 struct cfg80211_connect_params
*sme
)
828 s32 s32Error
= WILC_SUCCESS
;
830 u8 u8security
= NO_ENCRYPT
;
831 AUTHTYPE_T tenuAuth_type
= ANY
;
832 char *pcgroup_encrypt_val
= NULL
;
833 char *pccipher_group
= NULL
;
834 char *pcwpa_version
= NULL
;
836 struct WILC_WFI_priv
*priv
;
837 tstrWILC_WFIDrv
*pstrWFIDrv
;
838 tstrNetworkInfo
*pstrNetworkInfo
= NULL
;
842 priv
= wiphy_priv(wiphy
);
843 pstrWFIDrv
= (tstrWILC_WFIDrv
*)(priv
->hWILCWFIDrv
);
845 host_int_set_wfi_drv_handler((u32
)priv
->hWILCWFIDrv
);
847 PRINT_D(CFG80211_DBG
, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme
->ssid
, dev
, priv
->hWILCWFIDrv
);
849 if (!(WILC_strncmp(sme
->ssid
, "DIRECT-", 7))) {
850 PRINT_D(CFG80211_DBG
, "Connected to Direct network,OBSS disabled\n");
851 pstrWFIDrv
->u8P2PConnect
= 1;
853 pstrWFIDrv
->u8P2PConnect
= 0;
855 PRINT_INFO(CFG80211_DBG
, "Required SSID = %s\n , AuthType = %d \n", sme
->ssid
, sme
->auth_type
);
857 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
858 if ((sme
->ssid_len
== astrLastScannedNtwrksShadow
[i
].u8SsidLen
) &&
859 WILC_memcmp(astrLastScannedNtwrksShadow
[i
].au8ssid
,
861 sme
->ssid_len
) == 0) {
862 PRINT_INFO(CFG80211_DBG
, "Network with required SSID is found %s\n", sme
->ssid
);
863 if (sme
->bssid
== NULL
) {
864 /* BSSID is not passed from the user, so decision of matching
865 * is done by SSID only */
866 PRINT_INFO(CFG80211_DBG
, "BSSID is not passed from the user\n");
869 /* BSSID is also passed from the user, so decision of matching
870 * should consider also this passed BSSID */
871 if (WILC_memcmp(astrLastScannedNtwrksShadow
[i
].au8bssid
,
874 PRINT_INFO(CFG80211_DBG
, "BSSID is passed from the user and matched\n");
881 if (i
< u32LastScannedNtwrksCountShadow
) {
882 PRINT_D(CFG80211_DBG
, "Required bss is in scan results\n");
884 pstrNetworkInfo
= &(astrLastScannedNtwrksShadow
[i
]);
886 PRINT_INFO(CFG80211_DBG
, "network BSSID to be associated: %x%x%x%x%x%x\n",
887 pstrNetworkInfo
->au8bssid
[0], pstrNetworkInfo
->au8bssid
[1],
888 pstrNetworkInfo
->au8bssid
[2], pstrNetworkInfo
->au8bssid
[3],
889 pstrNetworkInfo
->au8bssid
[4], pstrNetworkInfo
->au8bssid
[5]);
892 if (u32LastScannedNtwrksCountShadow
== 0)
893 PRINT_D(CFG80211_DBG
, "No Scan results yet\n");
895 PRINT_D(CFG80211_DBG
, "Required bss not in scan results: Error(%d)\n", s32Error
);
900 priv
->WILC_WFI_wep_default
= 0;
901 WILC_memset(priv
->WILC_WFI_wep_key
, 0, sizeof(priv
->WILC_WFI_wep_key
));
902 WILC_memset(priv
->WILC_WFI_wep_key_len
, 0, sizeof(priv
->WILC_WFI_wep_key_len
));
904 PRINT_INFO(CFG80211_DBG
, "sme->crypto.wpa_versions=%x\n", sme
->crypto
.wpa_versions
);
905 PRINT_INFO(CFG80211_DBG
, "sme->crypto.cipher_group=%x\n", sme
->crypto
.cipher_group
);
907 PRINT_INFO(CFG80211_DBG
, "sme->crypto.n_ciphers_pairwise=%d\n", sme
->crypto
.n_ciphers_pairwise
);
910 for (i
= 0; i
< sme
->crypto
.n_ciphers_pairwise
; i
++)
911 PRINT_D(CORECONFIG_DBG
, "sme->crypto.ciphers_pairwise[%d]=%x\n", i
, sme
->crypto
.ciphers_pairwise
[i
]);
914 if (sme
->crypto
.cipher_group
!= NO_ENCRYPT
) {
915 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
916 * we will add to it the pairwise cipher suite(s) */
917 pcwpa_version
= "Default";
918 PRINT_D(CORECONFIG_DBG
, ">> sme->crypto.wpa_versions: %x\n", sme
->crypto
.wpa_versions
);
919 if (sme
->crypto
.cipher_group
== WLAN_CIPHER_SUITE_WEP40
) {
920 u8security
= ENCRYPT_ENABLED
| WEP
;
921 pcgroup_encrypt_val
= "WEP40";
922 pccipher_group
= "WLAN_CIPHER_SUITE_WEP40";
923 PRINT_INFO(CFG80211_DBG
, "WEP Default Key Idx = %d\n", sme
->key_idx
);
926 for (i
= 0; i
< sme
->key_len
; i
++)
927 PRINT_D(CORECONFIG_DBG
, "WEP Key Value[%d] = %d\n", i
, sme
->key
[i
]);
929 priv
->WILC_WFI_wep_default
= sme
->key_idx
;
930 priv
->WILC_WFI_wep_key_len
[sme
->key_idx
] = sme
->key_len
;
931 WILC_memcpy(priv
->WILC_WFI_wep_key
[sme
->key_idx
], sme
->key
, sme
->key_len
);
934 g_key_wep_params
.key_len
= sme
->key_len
;
935 g_key_wep_params
.key
= WILC_MALLOC(sme
->key_len
);
936 memcpy(g_key_wep_params
.key
, sme
->key
, sme
->key_len
);
937 g_key_wep_params
.key_idx
= sme
->key_idx
;
938 g_wep_keys_saved
= true;
940 host_int_set_WEPDefaultKeyID(priv
->hWILCWFIDrv
, sme
->key_idx
);
941 host_int_add_wep_key_bss_sta(priv
->hWILCWFIDrv
, sme
->key
, sme
->key_len
, sme
->key_idx
);
942 } else if (sme
->crypto
.cipher_group
== WLAN_CIPHER_SUITE_WEP104
) {
943 u8security
= ENCRYPT_ENABLED
| WEP
| WEP_EXTENDED
;
944 pcgroup_encrypt_val
= "WEP104";
945 pccipher_group
= "WLAN_CIPHER_SUITE_WEP104";
947 priv
->WILC_WFI_wep_default
= sme
->key_idx
;
948 priv
->WILC_WFI_wep_key_len
[sme
->key_idx
] = sme
->key_len
;
949 WILC_memcpy(priv
->WILC_WFI_wep_key
[sme
->key_idx
], sme
->key
, sme
->key_len
);
952 g_key_wep_params
.key_len
= sme
->key_len
;
953 g_key_wep_params
.key
= WILC_MALLOC(sme
->key_len
);
954 memcpy(g_key_wep_params
.key
, sme
->key
, sme
->key_len
);
955 g_key_wep_params
.key_idx
= sme
->key_idx
;
956 g_wep_keys_saved
= true;
958 host_int_set_WEPDefaultKeyID(priv
->hWILCWFIDrv
, sme
->key_idx
);
959 host_int_add_wep_key_bss_sta(priv
->hWILCWFIDrv
, sme
->key
, sme
->key_len
, sme
->key_idx
);
960 } else if (sme
->crypto
.wpa_versions
& NL80211_WPA_VERSION_2
) {
961 if (sme
->crypto
.cipher_group
== WLAN_CIPHER_SUITE_TKIP
) {
962 u8security
= ENCRYPT_ENABLED
| WPA2
| TKIP
;
963 pcgroup_encrypt_val
= "WPA2_TKIP";
964 pccipher_group
= "TKIP";
965 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
966 /* tenuSecurity_t = WPA2_AES; */
967 u8security
= ENCRYPT_ENABLED
| WPA2
| AES
;
968 pcgroup_encrypt_val
= "WPA2_AES";
969 pccipher_group
= "AES";
971 pcwpa_version
= "WPA_VERSION_2";
972 } else if (sme
->crypto
.wpa_versions
& NL80211_WPA_VERSION_1
) {
973 if (sme
->crypto
.cipher_group
== WLAN_CIPHER_SUITE_TKIP
) {
974 u8security
= ENCRYPT_ENABLED
| WPA
| TKIP
;
975 pcgroup_encrypt_val
= "WPA_TKIP";
976 pccipher_group
= "TKIP";
977 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
978 /* tenuSecurity_t = WPA_AES; */
979 u8security
= ENCRYPT_ENABLED
| WPA
| AES
;
980 pcgroup_encrypt_val
= "WPA_AES";
981 pccipher_group
= "AES";
984 pcwpa_version
= "WPA_VERSION_1";
987 s32Error
= -ENOTSUPP
;
988 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error
);
995 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
996 * add to it the pairwise cipher suite(s) */
997 if ((sme
->crypto
.wpa_versions
& NL80211_WPA_VERSION_1
)
998 || (sme
->crypto
.wpa_versions
& NL80211_WPA_VERSION_2
)) {
999 for (i
= 0; i
< sme
->crypto
.n_ciphers_pairwise
; i
++) {
1000 if (sme
->crypto
.ciphers_pairwise
[i
] == WLAN_CIPHER_SUITE_TKIP
) {
1001 u8security
= u8security
| TKIP
;
1002 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
1003 u8security
= u8security
| AES
;
1008 PRINT_D(CFG80211_DBG
, "Adding key with cipher group = %x\n", sme
->crypto
.cipher_group
);
1010 PRINT_D(CFG80211_DBG
, "Authentication Type = %d\n", sme
->auth_type
);
1011 switch (sme
->auth_type
) {
1012 case NL80211_AUTHTYPE_OPEN_SYSTEM
:
1013 PRINT_D(CFG80211_DBG
, "In OPEN SYSTEM\n");
1014 tenuAuth_type
= OPEN_SYSTEM
;
1017 case NL80211_AUTHTYPE_SHARED_KEY
:
1018 tenuAuth_type
= SHARED_KEY
;
1019 PRINT_D(CFG80211_DBG
, "In SHARED KEY\n");
1023 PRINT_D(CFG80211_DBG
, "Automatic Authentation type = %d\n", sme
->auth_type
);
1027 /* ai: key_mgmt: enterprise case */
1028 if (sme
->crypto
.n_akm_suites
) {
1029 switch (sme
->crypto
.akm_suites
[0]) {
1030 case WLAN_AKM_SUITE_8021X
:
1031 tenuAuth_type
= IEEE8021
;
1040 PRINT_INFO(CFG80211_DBG
, "Required Channel = %d\n", pstrNetworkInfo
->u8channel
);
1042 PRINT_INFO(CFG80211_DBG
, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
1043 pcgroup_encrypt_val
, pccipher_group
, pcwpa_version
);
1046 u8CurrChannel
= pstrNetworkInfo
->u8channel
;
1048 if (!pstrWFIDrv
->u8P2PConnect
) {
1049 u8WLANChannel
= pstrNetworkInfo
->u8channel
;
1052 linux_wlan_set_bssid(dev
, pstrNetworkInfo
->au8bssid
);
1054 s32Error
= host_int_set_join_req(priv
->hWILCWFIDrv
, pstrNetworkInfo
->au8bssid
, sme
->ssid
,
1055 sme
->ssid_len
, sme
->ie
, sme
->ie_len
,
1056 CfgConnectResult
, (void *)priv
, u8security
,
1057 tenuAuth_type
, pstrNetworkInfo
->u8channel
,
1058 pstrNetworkInfo
->pJoinParams
);
1059 if (s32Error
!= WILC_SUCCESS
) {
1060 PRINT_ER("host_int_set_join_req(): Error(%d) \n", s32Error
);
1072 * @brief WILC_WFI_disconnect
1073 * @details Disconnect from the BSS/ESS.
1075 * @return int : Return 0 on Success
1080 static int WILC_WFI_disconnect(struct wiphy
*wiphy
, struct net_device
*dev
, u16 reason_code
)
1082 s32 s32Error
= WILC_SUCCESS
;
1083 struct WILC_WFI_priv
*priv
;
1085 tstrWILC_WFIDrv
*pstrWFIDrv
;
1087 uint8_t NullBssid
[ETH_ALEN
] = {0};
1089 priv
= wiphy_priv(wiphy
);
1092 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
1094 pstrWFIDrv
= (tstrWILC_WFIDrv
*)priv
->hWILCWFIDrv
;
1095 if (!pstrWFIDrv
->u8P2PConnect
)
1096 u8WLANChannel
= INVALID_CHANNEL
;
1098 linux_wlan_set_bssid(priv
->dev
, NullBssid
);
1100 PRINT_D(CFG80211_DBG
, "Disconnecting with reason code(%d)\n", reason_code
);
1102 u8P2Plocalrandom
= 0x01;
1103 u8P2Precvrandom
= 0x00;
1106 pstrWFIDrv
->u64P2p_MgmtTimeout
= 0;
1109 s32Error
= host_int_disconnect(priv
->hWILCWFIDrv
, reason_code
);
1110 if (s32Error
!= WILC_SUCCESS
) {
1111 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error
);
1119 * @brief WILC_WFI_add_key
1120 * @details Add a key with the given parameters. @mac_addr will be %NULL
1121 * when adding a group key.
1122 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1123 * @return int : Return 0 on Success
1128 static int WILC_WFI_add_key(struct wiphy
*wiphy
, struct net_device
*netdev
, u8 key_index
,
1130 const u8
*mac_addr
, struct key_params
*params
)
1133 s32 s32Error
= WILC_SUCCESS
, KeyLen
= params
->key_len
;
1135 struct WILC_WFI_priv
*priv
;
1136 const u8
*pu8RxMic
= NULL
;
1137 const u8
*pu8TxMic
= NULL
;
1138 u8 u8mode
= NO_ENCRYPT
;
1139 #ifdef WILC_AP_EXTERNAL_MLME
1140 u8 u8gmode
= NO_ENCRYPT
;
1141 u8 u8pmode
= NO_ENCRYPT
;
1142 AUTHTYPE_T tenuAuth_type
= ANY
;
1145 priv
= wiphy_priv(wiphy
);
1147 PRINT_D(CFG80211_DBG
, "Adding key with cipher suite = %x\n", params
->cipher
);
1150 PRINT_D(CFG80211_DBG
, "%p %p %d\n", wiphy
, netdev
, key_index
);
1152 PRINT_D(CFG80211_DBG
, "key %x %x %x\n", params
->key
[0],
1157 switch (params
->cipher
) {
1158 case WLAN_CIPHER_SUITE_WEP40
:
1159 case WLAN_CIPHER_SUITE_WEP104
:
1160 #ifdef WILC_AP_EXTERNAL_MLME
1161 if (priv
->wdev
->iftype
== NL80211_IFTYPE_AP
) {
1163 priv
->WILC_WFI_wep_default
= key_index
;
1164 priv
->WILC_WFI_wep_key_len
[key_index
] = params
->key_len
;
1165 WILC_memcpy(priv
->WILC_WFI_wep_key
[key_index
], params
->key
, params
->key_len
);
1167 PRINT_D(CFG80211_DBG
, "Adding AP WEP Default key Idx = %d\n", key_index
);
1168 PRINT_D(CFG80211_DBG
, "Adding AP WEP Key len= %d\n", params
->key_len
);
1170 for (i
= 0; i
< params
->key_len
; i
++)
1171 PRINT_D(CFG80211_DBG
, "WEP AP key val[%d] = %x\n", i
, params
->key
[i
]);
1173 tenuAuth_type
= OPEN_SYSTEM
;
1175 if (params
->cipher
== WLAN_CIPHER_SUITE_WEP40
)
1176 u8mode
= ENCRYPT_ENABLED
| WEP
;
1178 u8mode
= ENCRYPT_ENABLED
| WEP
| WEP_EXTENDED
;
1180 host_int_add_wep_key_bss_ap(priv
->hWILCWFIDrv
, params
->key
, params
->key_len
, key_index
, u8mode
, tenuAuth_type
);
1184 if (WILC_memcmp(params
->key
, priv
->WILC_WFI_wep_key
[key_index
], params
->key_len
)) {
1185 priv
->WILC_WFI_wep_default
= key_index
;
1186 priv
->WILC_WFI_wep_key_len
[key_index
] = params
->key_len
;
1187 WILC_memcpy(priv
->WILC_WFI_wep_key
[key_index
], params
->key
, params
->key_len
);
1189 PRINT_D(CFG80211_DBG
, "Adding WEP Default key Idx = %d\n", key_index
);
1190 PRINT_D(CFG80211_DBG
, "Adding WEP Key length = %d\n", params
->key_len
);
1192 for (i
= 0; i
< params
->key_len
; i
++)
1193 PRINT_INFO(CFG80211_DBG
, "WEP key value[%d] = %d\n", i
, params
->key
[i
]);
1195 host_int_add_wep_key_bss_sta(priv
->hWILCWFIDrv
, params
->key
, params
->key_len
, key_index
);
1200 case WLAN_CIPHER_SUITE_TKIP
:
1201 case WLAN_CIPHER_SUITE_CCMP
:
1202 #ifdef WILC_AP_EXTERNAL_MLME
1203 if (priv
->wdev
->iftype
== NL80211_IFTYPE_AP
|| priv
->wdev
->iftype
== NL80211_IFTYPE_P2P_GO
) {
1205 if (priv
->wilc_gtk
[key_index
] == NULL
) {
1206 priv
->wilc_gtk
[key_index
] = (struct wilc_wfi_key
*)WILC_MALLOC(sizeof(struct wilc_wfi_key
));
1207 priv
->wilc_gtk
[key_index
]->key
= NULL
;
1208 priv
->wilc_gtk
[key_index
]->seq
= NULL
;
1211 if (priv
->wilc_ptk
[key_index
] == NULL
) {
1212 priv
->wilc_ptk
[key_index
] = (struct wilc_wfi_key
*)WILC_MALLOC(sizeof(struct wilc_wfi_key
));
1213 priv
->wilc_ptk
[key_index
]->key
= NULL
;
1214 priv
->wilc_ptk
[key_index
]->seq
= NULL
;
1221 if (params
->cipher
== WLAN_CIPHER_SUITE_TKIP
)
1222 u8gmode
= ENCRYPT_ENABLED
| WPA
| TKIP
;
1224 u8gmode
= ENCRYPT_ENABLED
| WPA2
| AES
;
1226 priv
->wilc_groupkey
= u8gmode
;
1228 if (params
->key_len
> 16 && params
->cipher
== WLAN_CIPHER_SUITE_TKIP
) {
1230 pu8TxMic
= params
->key
+ 24;
1231 pu8RxMic
= params
->key
+ 16;
1232 KeyLen
= params
->key_len
- 16;
1234 /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
1235 if (priv
->wilc_gtk
[key_index
]->key
)
1236 WILC_FREE(priv
->wilc_gtk
[key_index
]->key
);
1238 priv
->wilc_gtk
[key_index
]->key
= (u8
*)WILC_MALLOC(params
->key_len
);
1239 WILC_memcpy(priv
->wilc_gtk
[key_index
]->key
, params
->key
, params
->key_len
);
1241 /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
1242 if (priv
->wilc_gtk
[key_index
]->seq
)
1243 WILC_FREE(priv
->wilc_gtk
[key_index
]->seq
);
1245 if ((params
->seq_len
) > 0) {
1246 priv
->wilc_gtk
[key_index
]->seq
= (u8
*)WILC_MALLOC(params
->seq_len
);
1247 WILC_memcpy(priv
->wilc_gtk
[key_index
]->seq
, params
->seq
, params
->seq_len
);
1250 priv
->wilc_gtk
[key_index
]->cipher
= params
->cipher
;
1251 priv
->wilc_gtk
[key_index
]->key_len
= params
->key_len
;
1252 priv
->wilc_gtk
[key_index
]->seq_len
= params
->seq_len
;
1255 for (i
= 0; i
< params
->key_len
; i
++)
1256 PRINT_INFO(CFG80211_DBG
, "Adding group key value[%d] = %x\n", i
, params
->key
[i
]);
1257 for (i
= 0; i
< params
->seq_len
; i
++)
1258 PRINT_INFO(CFG80211_DBG
, "Adding group seq value[%d] = %x\n", i
, params
->seq
[i
]);
1262 host_int_add_rx_gtk(priv
->hWILCWFIDrv
, params
->key
, KeyLen
,
1263 key_index
, params
->seq_len
, params
->seq
, pu8RxMic
, pu8TxMic
, AP_MODE
, u8gmode
);
1266 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]);
1268 if (params
->cipher
== WLAN_CIPHER_SUITE_TKIP
)
1269 u8pmode
= ENCRYPT_ENABLED
| WPA
| TKIP
;
1271 u8pmode
= priv
->wilc_groupkey
| AES
;
1274 if (params
->key_len
> 16 && params
->cipher
== WLAN_CIPHER_SUITE_TKIP
) {
1276 pu8TxMic
= params
->key
+ 24;
1277 pu8RxMic
= params
->key
+ 16;
1278 KeyLen
= params
->key_len
- 16;
1281 if (priv
->wilc_ptk
[key_index
]->key
)
1282 WILC_FREE(priv
->wilc_ptk
[key_index
]->key
);
1284 priv
->wilc_ptk
[key_index
]->key
= (u8
*)WILC_MALLOC(params
->key_len
);
1286 if (priv
->wilc_ptk
[key_index
]->seq
)
1287 WILC_FREE(priv
->wilc_ptk
[key_index
]->seq
);
1289 if ((params
->seq_len
) > 0)
1290 priv
->wilc_ptk
[key_index
]->seq
= (u8
*)WILC_MALLOC(params
->seq_len
);
1293 for (i
= 0; i
< params
->key_len
; i
++)
1294 PRINT_INFO(CFG80211_DBG
, "Adding pairwise key value[%d] = %x\n", i
, params
->key
[i
]);
1296 for (i
= 0; i
< params
->seq_len
; i
++)
1297 PRINT_INFO(CFG80211_DBG
, "Adding group seq value[%d] = %x\n", i
, params
->seq
[i
]);
1300 WILC_memcpy(priv
->wilc_ptk
[key_index
]->key
, params
->key
, params
->key_len
);
1302 if ((params
->seq_len
) > 0)
1303 WILC_memcpy(priv
->wilc_ptk
[key_index
]->seq
, params
->seq
, params
->seq_len
);
1305 priv
->wilc_ptk
[key_index
]->cipher
= params
->cipher
;
1306 priv
->wilc_ptk
[key_index
]->key_len
= params
->key_len
;
1307 priv
->wilc_ptk
[key_index
]->seq_len
= params
->seq_len
;
1309 host_int_add_ptk(priv
->hWILCWFIDrv
, params
->key
, KeyLen
, mac_addr
,
1310 pu8RxMic
, pu8TxMic
, AP_MODE
, u8pmode
, key_index
);
1320 if (params
->key_len
> 16 && params
->cipher
== WLAN_CIPHER_SUITE_TKIP
) {
1321 /* swap the tx mic by rx mic */
1322 pu8RxMic
= params
->key
+ 24;
1323 pu8TxMic
= params
->key
+ 16;
1324 KeyLen
= params
->key_len
- 16;
1328 /*save keys only on interface 0 (wifi interface)*/
1329 if (!g_gtk_keys_saved
&& netdev
== g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
) {
1330 g_add_gtk_key_params
.key_idx
= key_index
;
1331 g_add_gtk_key_params
.pairwise
= pairwise
;
1333 g_add_gtk_key_params
.mac_addr
= NULL
;
1335 g_add_gtk_key_params
.mac_addr
= WILC_MALLOC(ETH_ALEN
);
1336 memcpy(g_add_gtk_key_params
.mac_addr
, mac_addr
, ETH_ALEN
);
1338 g_key_gtk_params
.key_len
= params
->key_len
;
1339 g_key_gtk_params
.seq_len
= params
->seq_len
;
1340 g_key_gtk_params
.key
= WILC_MALLOC(params
->key_len
);
1341 memcpy(g_key_gtk_params
.key
, params
->key
, params
->key_len
);
1342 if (params
->seq_len
> 0) {
1343 g_key_gtk_params
.seq
= WILC_MALLOC(params
->seq_len
);
1344 memcpy(g_key_gtk_params
.seq
, params
->seq
, params
->seq_len
);
1346 g_key_gtk_params
.cipher
= params
->cipher
;
1348 PRINT_D(CFG80211_DBG
, "key %x %x %x\n", g_key_gtk_params
.key
[0],
1349 g_key_gtk_params
.key
[1],
1350 g_key_gtk_params
.key
[2]);
1351 g_gtk_keys_saved
= true;
1354 host_int_add_rx_gtk(priv
->hWILCWFIDrv
, params
->key
, KeyLen
,
1355 key_index
, params
->seq_len
, params
->seq
, pu8RxMic
, pu8TxMic
, STATION_MODE
, u8mode
);
1357 if (params
->key_len
> 16 && params
->cipher
== WLAN_CIPHER_SUITE_TKIP
) {
1358 /* swap the tx mic by rx mic */
1359 pu8RxMic
= params
->key
+ 24;
1360 pu8TxMic
= params
->key
+ 16;
1361 KeyLen
= params
->key_len
- 16;
1365 /*save keys only on interface 0 (wifi interface)*/
1366 if (!g_ptk_keys_saved
&& netdev
== g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
) {
1367 g_add_ptk_key_params
.key_idx
= key_index
;
1368 g_add_ptk_key_params
.pairwise
= pairwise
;
1370 g_add_ptk_key_params
.mac_addr
= NULL
;
1372 g_add_ptk_key_params
.mac_addr
= WILC_MALLOC(ETH_ALEN
);
1373 memcpy(g_add_ptk_key_params
.mac_addr
, mac_addr
, ETH_ALEN
);
1375 g_key_ptk_params
.key_len
= params
->key_len
;
1376 g_key_ptk_params
.seq_len
= params
->seq_len
;
1377 g_key_ptk_params
.key
= WILC_MALLOC(params
->key_len
);
1378 memcpy(g_key_ptk_params
.key
, params
->key
, params
->key_len
);
1379 if (params
->seq_len
> 0) {
1380 g_key_ptk_params
.seq
= WILC_MALLOC(params
->seq_len
);
1381 memcpy(g_key_ptk_params
.seq
, params
->seq
, params
->seq_len
);
1383 g_key_ptk_params
.cipher
= params
->cipher
;
1385 PRINT_D(CFG80211_DBG
, "key %x %x %x\n", g_key_ptk_params
.key
[0],
1386 g_key_ptk_params
.key
[1],
1387 g_key_ptk_params
.key
[2]);
1388 g_ptk_keys_saved
= true;
1391 host_int_add_ptk(priv
->hWILCWFIDrv
, params
->key
, KeyLen
, mac_addr
,
1392 pu8RxMic
, pu8TxMic
, STATION_MODE
, u8mode
, key_index
);
1393 PRINT_D(CFG80211_DBG
, "Adding pairwise key\n");
1395 for (i
= 0; i
< params
->key_len
; i
++)
1396 PRINT_INFO(CFG80211_DBG
, "Adding pairwise key value[%d] = %d\n", i
, params
->key
[i
]);
1403 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error
);
1404 s32Error
= -ENOTSUPP
;
1412 * @brief WILC_WFI_del_key
1413 * @details Remove a key given the @mac_addr (%NULL for a group key)
1414 * and @key_index, return -ENOENT if the key doesn't exist.
1416 * @return int : Return 0 on Success
1421 static int WILC_WFI_del_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
1426 struct WILC_WFI_priv
*priv
;
1427 s32 s32Error
= WILC_SUCCESS
;
1429 priv
= wiphy_priv(wiphy
);
1432 /*delete saved keys, if any*/
1433 if (netdev
== g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
) {
1434 g_ptk_keys_saved
= false;
1435 g_gtk_keys_saved
= false;
1436 g_wep_keys_saved
= false;
1438 /*Delete saved WEP keys params, if any*/
1439 if (g_key_wep_params
.key
!= NULL
) {
1440 WILC_FREE(g_key_wep_params
.key
);
1441 g_key_wep_params
.key
= NULL
;
1444 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1446 #ifdef WILC_AP_EXTERNAL_MLME
1447 if ((priv
->wilc_gtk
[key_index
]) != NULL
) {
1449 if (priv
->wilc_gtk
[key_index
]->key
!= NULL
) {
1451 WILC_FREE(priv
->wilc_gtk
[key_index
]->key
);
1452 priv
->wilc_gtk
[key_index
]->key
= NULL
;
1454 if (priv
->wilc_gtk
[key_index
]->seq
) {
1456 WILC_FREE(priv
->wilc_gtk
[key_index
]->seq
);
1457 priv
->wilc_gtk
[key_index
]->seq
= NULL
;
1460 WILC_FREE(priv
->wilc_gtk
[key_index
]);
1461 priv
->wilc_gtk
[key_index
] = NULL
;
1465 if ((priv
->wilc_ptk
[key_index
]) != NULL
) {
1467 if (priv
->wilc_ptk
[key_index
]->key
) {
1469 WILC_FREE(priv
->wilc_ptk
[key_index
]->key
);
1470 priv
->wilc_ptk
[key_index
]->key
= NULL
;
1472 if (priv
->wilc_ptk
[key_index
]->seq
) {
1474 WILC_FREE(priv
->wilc_ptk
[key_index
]->seq
);
1475 priv
->wilc_ptk
[key_index
]->seq
= NULL
;
1477 WILC_FREE(priv
->wilc_ptk
[key_index
]);
1478 priv
->wilc_ptk
[key_index
] = NULL
;
1482 /*Delete saved PTK and GTK keys params, if any*/
1483 if (g_key_ptk_params
.key
!= NULL
) {
1484 WILC_FREE(g_key_ptk_params
.key
);
1485 g_key_ptk_params
.key
= NULL
;
1487 if (g_key_ptk_params
.seq
!= NULL
) {
1488 WILC_FREE(g_key_ptk_params
.seq
);
1489 g_key_ptk_params
.seq
= NULL
;
1492 if (g_key_gtk_params
.key
!= NULL
) {
1493 WILC_FREE(g_key_gtk_params
.key
);
1494 g_key_gtk_params
.key
= NULL
;
1496 if (g_key_gtk_params
.seq
!= NULL
) {
1497 WILC_FREE(g_key_gtk_params
.seq
);
1498 g_key_gtk_params
.seq
= NULL
;
1501 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
1502 Set_machw_change_vir_if(false);
1505 if (key_index
>= 0 && key_index
<= 3) {
1506 WILC_memset(priv
->WILC_WFI_wep_key
[key_index
], 0, priv
->WILC_WFI_wep_key_len
[key_index
]);
1507 priv
->WILC_WFI_wep_key_len
[key_index
] = 0;
1509 PRINT_D(CFG80211_DBG
, "Removing WEP key with index = %d\n", key_index
);
1510 host_int_remove_wep_key(priv
->hWILCWFIDrv
, key_index
);
1512 PRINT_D(CFG80211_DBG
, "Removing all installed keys\n");
1513 host_int_remove_key(priv
->hWILCWFIDrv
, mac_addr
);
1520 * @brief WILC_WFI_get_key
1521 * @details Get information about the key with the given parameters.
1522 * @mac_addr will be %NULL when requesting information for a group
1523 * key. All pointers given to the @callback function need not be valid
1524 * after it returns. This function should return an error if it is
1525 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1527 * @return int : Return 0 on Success
1532 static int WILC_WFI_get_key(struct wiphy
*wiphy
, struct net_device
*netdev
, u8 key_index
,
1534 const u8
*mac_addr
, void *cookie
, void (*callback
)(void *cookie
, struct key_params
*))
1537 s32 s32Error
= WILC_SUCCESS
;
1539 struct WILC_WFI_priv
*priv
;
1540 struct key_params key_params
;
1542 priv
= wiphy_priv(wiphy
);
1547 PRINT_D(CFG80211_DBG
, "Getting group key idx: %x\n", key_index
);
1549 key_params
.key
= priv
->wilc_gtk
[key_index
]->key
;
1550 key_params
.cipher
= priv
->wilc_gtk
[key_index
]->cipher
;
1551 key_params
.key_len
= priv
->wilc_gtk
[key_index
]->key_len
;
1552 key_params
.seq
= priv
->wilc_gtk
[key_index
]->seq
;
1553 key_params
.seq_len
= priv
->wilc_gtk
[key_index
]->seq_len
;
1555 for (i
= 0; i
< key_params
.key_len
; i
++)
1556 PRINT_INFO(CFG80211_DBG
, "Retrieved key value %x\n", key_params
.key
[i
]);
1559 PRINT_D(CFG80211_DBG
, "Getting pairwise key\n");
1561 key_params
.key
= priv
->wilc_ptk
[key_index
]->key
;
1562 key_params
.cipher
= priv
->wilc_ptk
[key_index
]->cipher
;
1563 key_params
.key_len
= priv
->wilc_ptk
[key_index
]->key_len
;
1564 key_params
.seq
= priv
->wilc_ptk
[key_index
]->seq
;
1565 key_params
.seq_len
= priv
->wilc_ptk
[key_index
]->seq_len
;
1568 callback(cookie
, &key_params
);
1570 return s32Error
; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
1574 * @brief WILC_WFI_set_default_key
1575 * @details Set the default management frame key on an interface
1577 * @return int : Return 0 on Success.
1582 static int WILC_WFI_set_default_key(struct wiphy
*wiphy
, struct net_device
*netdev
, u8 key_index
,
1583 bool unicast
, bool multicast
)
1585 s32 s32Error
= WILC_SUCCESS
;
1586 struct WILC_WFI_priv
*priv
;
1589 priv
= wiphy_priv(wiphy
);
1591 PRINT_D(CFG80211_DBG
, "Setting default key with idx = %d \n", key_index
);
1593 if (key_index
!= priv
->WILC_WFI_wep_default
) {
1595 host_int_set_WEPDefaultKeyID(priv
->hWILCWFIDrv
, key_index
);
1602 * @brief WILC_WFI_dump_survey
1603 * @details Get site survey information
1605 * @return int : Return 0 on Success.
1610 static int WILC_WFI_dump_survey(struct wiphy
*wiphy
, struct net_device
*netdev
,
1611 int idx
, struct survey_info
*info
)
1613 s32 s32Error
= WILC_SUCCESS
;
1618 PRINT_ER("Error Idx value doesn't equal zero: Error(%d)\n", s32Error
);
1627 * @brief WILC_WFI_get_station
1628 * @details Get station information for the station identified by @mac
1630 * @return int : Return 0 on Success.
1636 extern uint32_t Statisitcs_totalAcks
, Statisitcs_DroppedAcks
;
1637 static int WILC_WFI_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1638 const u8
*mac
, struct station_info
*sinfo
)
1640 s32 s32Error
= WILC_SUCCESS
;
1641 struct WILC_WFI_priv
*priv
;
1642 perInterface_wlan_t
*nic
;
1643 #ifdef WILC_AP_EXTERNAL_MLME
1645 u32 associatedsta
= 0;
1646 u32 inactive_time
= 0;
1648 priv
= wiphy_priv(wiphy
);
1649 nic
= netdev_priv(dev
);
1651 #ifdef WILC_AP_EXTERNAL_MLME
1652 if (nic
->iftype
== AP_MODE
|| nic
->iftype
== GO_MODE
) {
1653 PRINT_D(HOSTAPD_DBG
, "Getting station parameters\n");
1655 PRINT_INFO(HOSTAPD_DBG
, ": %x%x%x%x%x\n", mac
[0], mac
[1], mac
[2], mac
[3], mac
[4]);
1657 for (i
= 0; i
< NUM_STA_ASSOCIATED
; i
++) {
1659 if (!(memcmp(mac
, priv
->assoc_stainfo
.au8Sta_AssociatedBss
[i
], ETH_ALEN
))) {
1666 if (associatedsta
== -1) {
1668 PRINT_ER("Station required is not associated : Error(%d)\n", s32Error
);
1673 sinfo
->filled
|= BIT(NL80211_STA_INFO_INACTIVE_TIME
);
1675 host_int_get_inactive_time(priv
->hWILCWFIDrv
, mac
, &(inactive_time
));
1676 sinfo
->inactive_time
= 1000 * inactive_time
;
1677 PRINT_D(CFG80211_DBG
, "Inactive time %d\n", sinfo
->inactive_time
);
1682 if (nic
->iftype
== STATION_MODE
) {
1683 tstrStatistics strStatistics
;
1684 host_int_get_statistics(priv
->hWILCWFIDrv
, &strStatistics
);
1688 * tx_failed introduced more than
1689 * kernel version 3.0.0
1691 sinfo
->filled
|= BIT(NL80211_STA_INFO_SIGNAL
) |
1692 BIT( NL80211_STA_INFO_RX_PACKETS
) |
1693 BIT(NL80211_STA_INFO_TX_PACKETS
) |
1694 BIT(NL80211_STA_INFO_TX_FAILED
) |
1695 BIT(NL80211_STA_INFO_TX_BITRATE
);
1697 sinfo
->signal
= strStatistics
.s8RSSI
;
1698 sinfo
->rx_packets
= strStatistics
.u32RxCount
;
1699 sinfo
->tx_packets
= strStatistics
.u32TxCount
+ strStatistics
.u32TxFailureCount
;
1700 sinfo
->tx_failed
= strStatistics
.u32TxFailureCount
;
1701 sinfo
->txrate
.legacy
= strStatistics
.u8LinkSpeed
* 10;
1703 #ifdef TCP_ENHANCEMENTS
1704 if ((strStatistics
.u8LinkSpeed
> TCP_ACK_FILTER_LINK_SPEED_THRESH
) && (strStatistics
.u8LinkSpeed
!= DEFAULT_LINK_SPEED
)) {
1705 Enable_TCP_ACK_Filter(true);
1706 } else if (strStatistics
.u8LinkSpeed
!= DEFAULT_LINK_SPEED
) {
1707 Enable_TCP_ACK_Filter(false);
1711 PRINT_D(CORECONFIG_DBG
, "*** stats[%d][%d][%d][%d][%d]\n", sinfo
->signal
, sinfo
->rx_packets
, sinfo
->tx_packets
,
1712 sinfo
->tx_failed
, sinfo
->txrate
.legacy
);
1719 * @brief WILC_WFI_change_bss
1720 * @details Modify parameters for a given BSS.
1722 * -use_cts_prot: Whether to use CTS protection
1723 * (0 = no, 1 = yes, -1 = do not change)
1724 * -use_short_preamble: Whether the use of short preambles is allowed
1725 * (0 = no, 1 = yes, -1 = do not change)
1726 * -use_short_slot_time: Whether the use of short slot time is allowed
1727 * (0 = no, 1 = yes, -1 = do not change)
1728 * -basic_rates: basic rates in IEEE 802.11 format
1729 * (or NULL for no change)
1730 * -basic_rates_len: number of basic rates
1731 * -ap_isolate: do not forward packets between connected stations
1732 * -ht_opmode: HT Operation mode
1733 * (u16 = opmode, -1 = do not change)
1734 * @return int : Return 0 on Success.
1739 static int WILC_WFI_change_bss(struct wiphy
*wiphy
, struct net_device
*dev
,
1740 struct bss_parameters
*params
)
1742 PRINT_D(CFG80211_DBG
, "Changing Bss parametrs\n");
1747 * @brief WILC_WFI_auth
1748 * @details Request to authenticate with the specified peer
1750 * @return int : Return 0 on Success.
1755 static int WILC_WFI_auth(struct wiphy
*wiphy
, struct net_device
*dev
,
1756 struct cfg80211_auth_request
*req
)
1758 PRINT_D(CFG80211_DBG
, "In Authentication Function\n");
1763 * @brief WILC_WFI_assoc
1764 * @details Request to (re)associate with the specified peer
1766 * @return int : Return 0 on Success.
1771 static int WILC_WFI_assoc(struct wiphy
*wiphy
, struct net_device
*dev
,
1772 struct cfg80211_assoc_request
*req
)
1774 PRINT_D(CFG80211_DBG
, "In Association Function\n");
1779 * @brief WILC_WFI_deauth
1780 * @details Request to deauthenticate from the specified peer
1782 * @return int : Return 0 on Success.
1787 static int WILC_WFI_deauth(struct wiphy
*wiphy
, struct net_device
*dev
,
1788 struct cfg80211_deauth_request
*req
, void *cookie
)
1790 PRINT_D(CFG80211_DBG
, "In De-authentication Function\n");
1795 * @brief WILC_WFI_disassoc
1796 * @details Request to disassociate from the specified peer
1798 * @return int : Return 0 on Success
1803 static int WILC_WFI_disassoc(struct wiphy
*wiphy
, struct net_device
*dev
,
1804 struct cfg80211_disassoc_request
*req
, void *cookie
)
1806 PRINT_D(CFG80211_DBG
, "In Disassociation Function\n");
1811 * @brief WILC_WFI_set_wiphy_params
1812 * @details Notify that wiphy parameters have changed;
1813 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1815 * @return int : Return 0 on Success
1820 static int WILC_WFI_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
1822 s32 s32Error
= WILC_SUCCESS
;
1823 tstrCfgParamVal pstrCfgParamVal
;
1824 struct WILC_WFI_priv
*priv
;
1826 priv
= wiphy_priv(wiphy
);
1828 pstrCfgParamVal
.u32SetCfgFlag
= 0;
1829 PRINT_D(CFG80211_DBG
, "Setting Wiphy params \n");
1831 if (changed
& WIPHY_PARAM_RETRY_SHORT
) {
1832 PRINT_D(CFG80211_DBG
, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1833 priv
->dev
->ieee80211_ptr
->wiphy
->retry_short
);
1834 pstrCfgParamVal
.u32SetCfgFlag
|= RETRY_SHORT
;
1835 pstrCfgParamVal
.short_retry_limit
= priv
->dev
->ieee80211_ptr
->wiphy
->retry_short
;
1837 if (changed
& WIPHY_PARAM_RETRY_LONG
) {
1839 PRINT_D(CFG80211_DBG
, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv
->dev
->ieee80211_ptr
->wiphy
->retry_long
);
1840 pstrCfgParamVal
.u32SetCfgFlag
|= RETRY_LONG
;
1841 pstrCfgParamVal
.long_retry_limit
= priv
->dev
->ieee80211_ptr
->wiphy
->retry_long
;
1844 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
) {
1845 PRINT_D(CFG80211_DBG
, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv
->dev
->ieee80211_ptr
->wiphy
->frag_threshold
);
1846 pstrCfgParamVal
.u32SetCfgFlag
|= FRAG_THRESHOLD
;
1847 pstrCfgParamVal
.frag_threshold
= priv
->dev
->ieee80211_ptr
->wiphy
->frag_threshold
;
1851 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
1852 PRINT_D(CFG80211_DBG
, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv
->dev
->ieee80211_ptr
->wiphy
->rts_threshold
);
1854 pstrCfgParamVal
.u32SetCfgFlag
|= RTS_THRESHOLD
;
1855 pstrCfgParamVal
.rts_threshold
= priv
->dev
->ieee80211_ptr
->wiphy
->rts_threshold
;
1859 PRINT_D(CFG80211_DBG
, "Setting CFG params in the host interface\n");
1860 s32Error
= hif_set_cfg(priv
->hWILCWFIDrv
, &pstrCfgParamVal
);
1862 PRINT_ER("Error in setting WIPHY PARAMS\n");
1869 * @brief WILC_WFI_set_bitrate_mask
1870 * @details set the bitrate mask configuration
1872 * @return int : Return 0 on Success
1877 static int WILC_WFI_set_bitrate_mask(struct wiphy
*wiphy
,
1878 struct net_device
*dev
, const u8
*peer
,
1879 const struct cfg80211_bitrate_mask
*mask
)
1881 s32 s32Error
= WILC_SUCCESS
;
1883 PRINT_D(CFG80211_DBG
, "Setting Bitrate mask function\n");
1889 * @brief WILC_WFI_set_pmksa
1890 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1891 * devices running firmwares capable of generating the (re) association
1892 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1894 * @return int : Return 0 on Success
1899 static int WILC_WFI_set_pmksa(struct wiphy
*wiphy
, struct net_device
*netdev
,
1900 struct cfg80211_pmksa
*pmksa
)
1903 s32 s32Error
= WILC_SUCCESS
;
1906 struct WILC_WFI_priv
*priv
= wiphy_priv(wiphy
);
1908 PRINT_D(CFG80211_DBG
, "Setting PMKSA\n");
1911 for (i
= 0; i
< priv
->pmkid_list
.numpmkid
; i
++) {
1912 if (!WILC_memcmp(pmksa
->bssid
, priv
->pmkid_list
.pmkidlist
[i
].bssid
,
1914 /*If bssid already exists and pmkid value needs to reset*/
1916 PRINT_D(CFG80211_DBG
, "PMKID already exists\n");
1920 if (i
< WILC_MAX_NUM_PMKIDS
) {
1921 PRINT_D(CFG80211_DBG
, "Setting PMKID in private structure\n");
1922 WILC_memcpy(priv
->pmkid_list
.pmkidlist
[i
].bssid
, pmksa
->bssid
,
1924 WILC_memcpy(priv
->pmkid_list
.pmkidlist
[i
].pmkid
, pmksa
->pmkid
,
1926 if (!(flag
== PMKID_FOUND
))
1927 priv
->pmkid_list
.numpmkid
++;
1929 PRINT_ER("Invalid PMKID index\n");
1934 PRINT_D(CFG80211_DBG
, "Setting pmkid in the host interface\n");
1935 s32Error
= host_int_set_pmkid_info(priv
->hWILCWFIDrv
, &priv
->pmkid_list
);
1941 * @brief WILC_WFI_del_pmksa
1942 * @details Delete a cached PMKID.
1944 * @return int : Return 0 on Success
1949 static int WILC_WFI_del_pmksa(struct wiphy
*wiphy
, struct net_device
*netdev
,
1950 struct cfg80211_pmksa
*pmksa
)
1955 s32 s32Error
= WILC_SUCCESS
;
1957 struct WILC_WFI_priv
*priv
= wiphy_priv(wiphy
);
1959 PRINT_D(CFG80211_DBG
, "Deleting PMKSA keys\n");
1961 for (i
= 0; i
< priv
->pmkid_list
.numpmkid
; i
++) {
1962 if (!WILC_memcmp(pmksa
->bssid
, priv
->pmkid_list
.pmkidlist
[i
].bssid
,
1964 /*If bssid is found, reset the values*/
1965 PRINT_D(CFG80211_DBG
, "Reseting PMKID values\n");
1966 WILC_memset(&priv
->pmkid_list
.pmkidlist
[i
], 0, sizeof(tstrHostIFpmkid
));
1972 if (i
< priv
->pmkid_list
.numpmkid
&& priv
->pmkid_list
.numpmkid
> 0) {
1973 for (; i
< (priv
->pmkid_list
.numpmkid
- 1); i
++) {
1974 WILC_memcpy(priv
->pmkid_list
.pmkidlist
[i
].bssid
,
1975 priv
->pmkid_list
.pmkidlist
[i
+ 1].bssid
,
1977 WILC_memcpy(priv
->pmkid_list
.pmkidlist
[i
].pmkid
,
1978 priv
->pmkid_list
.pmkidlist
[i
].pmkid
,
1981 priv
->pmkid_list
.numpmkid
--;
1990 * @brief WILC_WFI_flush_pmksa
1991 * @details Flush all cached PMKIDs.
1993 * @return int : Return 0 on Success
1998 static int WILC_WFI_flush_pmksa(struct wiphy
*wiphy
, struct net_device
*netdev
)
2000 struct WILC_WFI_priv
*priv
= wiphy_priv(wiphy
);
2002 PRINT_D(CFG80211_DBG
, "Flushing PMKID key values\n");
2004 /*Get cashed Pmkids and set all with zeros*/
2005 WILC_memset(&priv
->pmkid_list
, 0, sizeof(tstrHostIFpmkidAttr
));
2013 * @brief WILC_WFI_CfgParseRxAction
2014 * @details Function parses the received frames and modifies the following attributes:
2017 * -Operating Channel
2019 * @param[in] u8* Buffer, u32 length
2026 void WILC_WFI_CfgParseRxAction(u8
*buf
, u32 len
)
2032 #ifdef USE_SUPPLICANT_GO_INTENT
2035 bool is_wilc_go
= true;
2037 u8 op_channel_attr_index
= 0;
2038 u8 channel_list_attr_index
= 0;
2040 while (index
< len
) {
2041 if (buf
[index
] == GO_INTENT_ATTR_ID
) {
2042 #ifdef USE_SUPPLICANT_GO_INTENT
2044 /*Case 1: If we are going to be p2p client, no need to modify channels attributes*/
2045 /*In negotiation frames, go intent attr value determines who will be GO*/
2046 intent
= GET_GO_INTENT(buf
[index
+ 3]);
2047 tie_breaker
= GET_TIE_BREAKER(buf
[index
+ 3]);
2048 if (intent
> SUPPLICANT_GO_INTENT
2049 || (intent
== SUPPLICANT_GO_INTENT
&& tie_breaker
== 1)) {
2050 PRINT_D(GENERIC_DBG
, "WILC will be client (intent %d tie breaker %d)\n", intent
, tie_breaker
);
2053 PRINT_D(GENERIC_DBG
, "WILC will be GO (intent %d tie breaker %d)\n", intent
, tie_breaker
);
2057 #else /* USE_SUPPLICANT_GO_INTENT */
2058 #ifdef FORCE_P2P_CLIENT
2059 buf
[index
+ 3] = (buf
[index
+ 3] & 0x01) | (0x0f << 1);
2061 buf
[index
+ 3] = (buf
[index
+ 3] & 0x01) | (0x00 << 1);
2063 #endif /* USE_SUPPLICANT_GO_INTENT */
2066 #ifdef USE_SUPPLICANT_GO_INTENT
2067 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2068 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2069 if (buf
[index
] == GROUP_BSSID_ATTR_ID
) {
2070 PRINT_D(GENERIC_DBG
, "Group BSSID: %2x:%2x:%2x\n", buf
[index
+ 3]
2075 #endif /* USE_SUPPLICANT_GO_INTENT */
2077 if (buf
[index
] == CHANLIST_ATTR_ID
) {
2078 channel_list_attr_index
= index
;
2079 } else if (buf
[index
] == OPERCHAN_ATTR_ID
) {
2080 op_channel_attr_index
= index
;
2082 index
+= buf
[index
+ 1] + 3; /* ID,Length byte */
2085 #ifdef USE_SUPPLICANT_GO_INTENT
2086 if (u8WLANChannel
!= INVALID_CHANNEL
&& is_wilc_go
)
2088 if (u8WLANChannel
!= INVALID_CHANNEL
)
2091 /*Modify channel list attribute*/
2092 if (channel_list_attr_index
) {
2093 PRINT_D(GENERIC_DBG
, "Modify channel list attribute\n");
2094 for (i
= channel_list_attr_index
+ 3; i
< ((channel_list_attr_index
+ 3) + buf
[channel_list_attr_index
+ 1]); i
++) {
2095 if (buf
[i
] == 0x51) {
2096 for (j
= i
+ 2; j
< ((i
+ 2) + buf
[i
+ 1]); j
++) {
2097 buf
[j
] = u8WLANChannel
;
2103 /*Modify operating channel attribute*/
2104 if (op_channel_attr_index
) {
2105 PRINT_D(GENERIC_DBG
, "Modify operating channel attribute\n");
2106 buf
[op_channel_attr_index
+ 6] = 0x51;
2107 buf
[op_channel_attr_index
+ 7] = u8WLANChannel
;
2113 * @brief WILC_WFI_CfgParseTxAction
2114 * @details Function parses the transmitted action frames and modifies the
2115 * GO Intent attribute
2116 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
2122 void WILC_WFI_CfgParseTxAction(u8
*buf
, u32 len
, bool bOperChan
, u8 iftype
)
2127 u8 op_channel_attr_index
= 0;
2128 u8 channel_list_attr_index
= 0;
2129 #ifdef USE_SUPPLICANT_GO_INTENT
2130 bool is_wilc_go
= false;
2133 /*Case 1: If we are already p2p client, no need to modify channels attributes*/
2134 /*This to handle the case of inviting a p2p peer to join an existing group which we are a member in*/
2135 if (iftype
== CLIENT_MODE
)
2139 while (index
< len
) {
2140 #ifdef USE_SUPPLICANT_GO_INTENT
2141 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2142 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2143 /*Note: If we are already p2p client, group bssid attr may also be present (handled in Case 1)*/
2144 if (buf
[index
] == GROUP_BSSID_ATTR_ID
) {
2145 PRINT_D(GENERIC_DBG
, "Group BSSID: %2x:%2x:%2x\n", buf
[index
+ 3]
2151 #else /* USE_SUPPLICANT_GO_INTENT */
2152 if (buf
[index
] == GO_INTENT_ATTR_ID
) {
2153 #ifdef FORCE_P2P_CLIENT
2154 buf
[index
+ 3] = (buf
[index
+ 3] & 0x01) | (0x00 << 1);
2156 buf
[index
+ 3] = (buf
[index
+ 3] & 0x01) | (0x0f << 1);
2163 if (buf
[index
] == CHANLIST_ATTR_ID
) {
2164 channel_list_attr_index
= index
;
2165 } else if (buf
[index
] == OPERCHAN_ATTR_ID
) {
2166 op_channel_attr_index
= index
;
2168 index
+= buf
[index
+ 1] + 3; /* ID,Length byte */
2171 #ifdef USE_SUPPLICANT_GO_INTENT
2172 /*No need to check bOperChan since only transmitted invitation frames are parsed*/
2173 if (u8WLANChannel
!= INVALID_CHANNEL
&& is_wilc_go
)
2175 if (u8WLANChannel
!= INVALID_CHANNEL
&& bOperChan
)
2178 /*Modify channel list attribute*/
2179 if (channel_list_attr_index
) {
2180 PRINT_D(GENERIC_DBG
, "Modify channel list attribute\n");
2181 for (i
= channel_list_attr_index
+ 3; i
< ((channel_list_attr_index
+ 3) + buf
[channel_list_attr_index
+ 1]); i
++) {
2182 if (buf
[i
] == 0x51) {
2183 for (j
= i
+ 2; j
< ((i
+ 2) + buf
[i
+ 1]); j
++) {
2184 buf
[j
] = u8WLANChannel
;
2190 /*Modify operating channel attribute*/
2191 if (op_channel_attr_index
) {
2192 PRINT_D(GENERIC_DBG
, "Modify operating channel attribute\n");
2193 buf
[op_channel_attr_index
+ 6] = 0x51;
2194 buf
[op_channel_attr_index
+ 7] = u8WLANChannel
;
2199 /* @brief WILC_WFI_p2p_rx
2204 * @author Mai Daftedar
2209 void WILC_WFI_p2p_rx (struct net_device
*dev
, uint8_t *buff
, uint32_t size
)
2212 struct WILC_WFI_priv
*priv
;
2213 u32 header
, pkt_offset
;
2214 tstrWILC_WFIDrv
*pstrWFIDrv
;
2217 priv
= wiphy_priv(dev
->ieee80211_ptr
->wiphy
);
2218 pstrWFIDrv
= (tstrWILC_WFIDrv
*)priv
->hWILCWFIDrv
;
2220 /* Get WILC header */
2221 WILC_memcpy(&header
, (buff
- HOST_HDR_OFFSET
), HOST_HDR_OFFSET
);
2223 /* The packet offset field conain info about what type of managment frame */
2224 /* we are dealing with and ack status */
2225 pkt_offset
= GET_PKT_OFFSET(header
);
2227 if (pkt_offset
& IS_MANAGMEMENT_CALLBACK
) {
2228 if (buff
[FRAME_TYPE_ID
] == IEEE80211_STYPE_PROBE_RESP
) {
2229 PRINT_D(GENERIC_DBG
, "Probe response ACK\n");
2230 cfg80211_mgmt_tx_status(priv
->wdev
, priv
->u64tx_cookie
, buff
, size
, true, GFP_KERNEL
);
2233 if (pkt_offset
& IS_MGMT_STATUS_SUCCES
) {
2234 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
],
2235 buff
[ACTION_SUBTYPE_ID
+ 1], buff
[P2P_PUB_ACTION_SUBTYPE
+ 1]);
2236 cfg80211_mgmt_tx_status(priv
->wdev
, priv
->u64tx_cookie
, buff
, size
, true, GFP_KERNEL
);
2238 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
],
2239 buff
[ACTION_SUBTYPE_ID
+ 1], buff
[P2P_PUB_ACTION_SUBTYPE
+ 1]);
2240 cfg80211_mgmt_tx_status(priv
->wdev
, priv
->u64tx_cookie
, buff
, size
, false, GFP_KERNEL
);
2246 PRINT_D(GENERIC_DBG
, "Rx Frame Type:%x\n", buff
[FRAME_TYPE_ID
]);
2249 /*Upper layer is informed that the frame is received on this freq*/
2250 s32Freq
= ieee80211_channel_to_frequency(u8CurrChannel
, IEEE80211_BAND_2GHZ
);
2252 if (ieee80211_is_action(buff
[FRAME_TYPE_ID
])) {
2253 PRINT_D(GENERIC_DBG
, "Rx Action Frame Type: %x %x\n", buff
[ACTION_SUBTYPE_ID
], buff
[P2P_PUB_ACTION_SUBTYPE
]);
2255 if (priv
->bCfgScanning
== true && time_after_eq(jiffies
, (unsigned long)pstrWFIDrv
->u64P2p_MgmtTimeout
)) {
2256 PRINT_D(GENERIC_DBG
, "Receiving action frames from wrong channels\n");
2259 if (buff
[ACTION_CAT_ID
] == PUB_ACTION_ATTR_ID
) {
2261 switch (buff
[ACTION_SUBTYPE_ID
]) {
2262 case GAS_INTIAL_REQ
:
2263 PRINT_D(GENERIC_DBG
, "GAS INITIAL REQ %x\n", buff
[ACTION_SUBTYPE_ID
]);
2266 case GAS_INTIAL_RSP
:
2267 PRINT_D(GENERIC_DBG
, "GAS INITIAL RSP %x\n", buff
[ACTION_SUBTYPE_ID
]);
2270 case PUBLIC_ACT_VENDORSPEC
:
2271 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2272 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
2273 if (!WILC_memcmp(u8P2P_oui
, &buff
[ACTION_SUBTYPE_ID
+ 1], 4)) {
2274 if ((buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_REQ
|| buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_RSP
)) {
2276 for (i
= P2P_PUB_ACTION_SUBTYPE
; i
< size
; i
++) {
2277 if (!WILC_memcmp(u8P2P_vendorspec
, &buff
[i
], 6)) {
2278 u8P2Precvrandom
= buff
[i
+ 6];
2280 PRINT_D(GENERIC_DBG
, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom
);
2286 if (u8P2Plocalrandom
> u8P2Precvrandom
) {
2287 if ((buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_REQ
|| buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_RSP
2288 || buff
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_REQ
|| buff
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_RSP
)) {
2289 for (i
= P2P_PUB_ACTION_SUBTYPE
+ 2; i
< size
; i
++) {
2290 if (buff
[i
] == P2PELEM_ATTR_ID
&& !(WILC_memcmp(u8P2P_oui
, &buff
[i
+ 2], 4))) {
2291 WILC_WFI_CfgParseRxAction(&buff
[i
+ 6], size
- (i
+ 6));
2297 PRINT_D(GENERIC_DBG
, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom
, u8P2Precvrandom
);
2301 if ((buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_REQ
|| buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_RSP
) && (bWilc_ie
)) {
2302 PRINT_D(GENERIC_DBG
, "Sending P2P to host without extra elemnt\n");
2303 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
2304 cfg80211_rx_mgmt(priv
->wdev
, s32Freq
, 0, buff
, size
- 7, 0);
2310 PRINT_D(GENERIC_DBG
, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff
[ACTION_SUBTYPE_ID
]);
2316 cfg80211_rx_mgmt(priv
->wdev
, s32Freq
, 0, buff
, size
- 7, 0);
2321 * @brief WILC_WFI_mgmt_tx_complete
2322 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2324 * transmitting status
2326 * @author Amr Abdelmoghny
2330 static void WILC_WFI_mgmt_tx_complete(void *priv
, int status
)
2332 struct p2p_mgmt_data
*pv_data
= (struct p2p_mgmt_data
*)priv
;
2335 kfree(pv_data
->buff
);
2340 * @brief WILC_WFI_RemainOnChannelReady
2341 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2344 * @author Amr abdelmoghny
2349 static void WILC_WFI_RemainOnChannelReady(void *pUserVoid
)
2351 struct WILC_WFI_priv
*priv
;
2352 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
2354 PRINT_D(HOSTINF_DBG
, "Remain on channel ready \n");
2356 priv
->bInP2PlistenState
= true;
2358 cfg80211_ready_on_channel(priv
->wdev
,
2359 priv
->strRemainOnChanParams
.u64ListenCookie
,
2360 priv
->strRemainOnChanParams
.pstrListenChan
,
2361 priv
->strRemainOnChanParams
.u32ListenDuration
,
2366 * @brief WILC_WFI_RemainOnChannelExpired
2367 * @details Callback function, called on expiration of remain-on-channel duration
2370 * @author Amr abdelmoghny
2375 static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid
, u32 u32SessionID
)
2377 struct WILC_WFI_priv
*priv
;
2378 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
2381 if (u32SessionID
== priv
->strRemainOnChanParams
.u32ListenSessionID
) {
2382 PRINT_D(GENERIC_DBG
, "Remain on channel expired \n");
2384 priv
->bInP2PlistenState
= false;
2386 /*Inform wpas of remain-on-channel expiration*/
2387 cfg80211_remain_on_channel_expired(priv
->wdev
,
2388 priv
->strRemainOnChanParams
.u64ListenCookie
,
2389 priv
->strRemainOnChanParams
.pstrListenChan
,
2392 PRINT_D(GENERIC_DBG
, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2393 , priv
->strRemainOnChanParams
.u32ListenSessionID
);
2399 * @brief WILC_WFI_remain_on_channel
2400 * @details Request the driver to remain awake on the specified
2401 * channel for the specified duration to complete an off-channel
2402 * operation (e.g., public action frame exchange). When the driver is
2403 * ready on the requested channel, it must indicate this with an event
2404 * notification by calling cfg80211_ready_on_channel().
2406 * @return int : Return 0 on Success
2411 static int WILC_WFI_remain_on_channel(struct wiphy
*wiphy
,
2412 struct wireless_dev
*wdev
,
2413 struct ieee80211_channel
*chan
,
2414 unsigned int duration
, u64
*cookie
)
2416 s32 s32Error
= WILC_SUCCESS
;
2417 struct WILC_WFI_priv
*priv
;
2418 priv
= wiphy_priv(wiphy
);
2420 PRINT_D(GENERIC_DBG
, "Remaining on channel %d\n", chan
->hw_value
);
2422 /*BugID_4800: if in AP mode, return.*/
2423 /*This check is to handle the situation when user*/
2424 /*requests "create group" during a running scan*/
2426 if (wdev
->iftype
== NL80211_IFTYPE_AP
) {
2427 PRINT_D(GENERIC_DBG
, "Required remain-on-channel while in AP mode");
2431 u8CurrChannel
= chan
->hw_value
;
2433 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2434 priv
->strRemainOnChanParams
.pstrListenChan
= chan
;
2435 priv
->strRemainOnChanParams
.u64ListenCookie
= *cookie
;
2436 priv
->strRemainOnChanParams
.u32ListenDuration
= duration
;
2437 priv
->strRemainOnChanParams
.u32ListenSessionID
++;
2439 s32Error
= host_int_remain_on_channel(priv
->hWILCWFIDrv
2440 , priv
->strRemainOnChanParams
.u32ListenSessionID
2443 , WILC_WFI_RemainOnChannelExpired
2444 , WILC_WFI_RemainOnChannelReady
2451 * @brief WILC_WFI_cancel_remain_on_channel
2452 * @details Cancel an on-going remain-on-channel operation.
2453 * This allows the operation to be terminated prior to timeout based on
2454 * the duration value.
2455 * @param[in] struct wiphy *wiphy,
2456 * @param[in] struct net_device *dev
2457 * @param[in] u64 cookie,
2458 * @return int : Return 0 on Success
2463 static int WILC_WFI_cancel_remain_on_channel(struct wiphy
*wiphy
,
2464 struct wireless_dev
*wdev
,
2467 s32 s32Error
= WILC_SUCCESS
;
2468 struct WILC_WFI_priv
*priv
;
2469 priv
= wiphy_priv(wiphy
);
2471 PRINT_D(CFG80211_DBG
, "Cancel remain on channel\n");
2473 s32Error
= host_int_ListenStateExpired(priv
->hWILCWFIDrv
, priv
->strRemainOnChanParams
.u32ListenSessionID
);
2477 * @brief WILC_WFI_add_wilcvendorspec
2478 * @details Adding WILC information elemet to allow two WILC devices to
2479 * identify each other and connect
2480 * @param[in] u8 * buf
2486 void WILC_WFI_add_wilcvendorspec(u8
*buff
)
2488 WILC_memcpy(buff
, u8P2P_vendorspec
, sizeof(u8P2P_vendorspec
));
2491 * @brief WILC_WFI_mgmt_tx_frame
2500 extern linux_wlan_t
*g_linux_wlan
;
2501 extern bool bEnablePS
;
2502 int WILC_WFI_mgmt_tx(struct wiphy
*wiphy
,
2503 struct wireless_dev
*wdev
,
2504 struct cfg80211_mgmt_tx_params
*params
,
2507 struct ieee80211_channel
*chan
= params
->chan
;
2508 unsigned int wait
= params
->wait
;
2509 const u8
*buf
= params
->buf
;
2510 size_t len
= params
->len
;
2511 const struct ieee80211_mgmt
*mgmt
;
2512 struct p2p_mgmt_data
*mgmt_tx
;
2513 struct WILC_WFI_priv
*priv
;
2514 s32 s32Error
= WILC_SUCCESS
;
2515 tstrWILC_WFIDrv
*pstrWFIDrv
;
2517 perInterface_wlan_t
*nic
;
2518 u32 buf_len
= len
+ sizeof(u8P2P_vendorspec
) + sizeof(u8P2Plocalrandom
);
2520 nic
= netdev_priv(wdev
->netdev
);
2521 priv
= wiphy_priv(wiphy
);
2522 pstrWFIDrv
= (tstrWILC_WFIDrv
*)priv
->hWILCWFIDrv
;
2524 *cookie
= (unsigned long)buf
;
2525 priv
->u64tx_cookie
= *cookie
;
2526 mgmt
= (const struct ieee80211_mgmt
*) buf
;
2528 if (ieee80211_is_mgmt(mgmt
->frame_control
)) {
2530 /*mgmt frame allocation*/
2531 mgmt_tx
= (struct p2p_mgmt_data
*)WILC_MALLOC(sizeof(struct p2p_mgmt_data
));
2532 if (mgmt_tx
== NULL
) {
2533 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
2536 mgmt_tx
->buff
= (char *)WILC_MALLOC(buf_len
);
2537 if (mgmt_tx
->buff
== NULL
) {
2538 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
2541 WILC_memcpy(mgmt_tx
->buff
, buf
, len
);
2542 mgmt_tx
->size
= len
;
2545 if (ieee80211_is_probe_resp(mgmt
->frame_control
)) {
2546 PRINT_D(GENERIC_DBG
, "TX: Probe Response\n");
2547 PRINT_D(GENERIC_DBG
, "Setting channel: %d\n", chan
->hw_value
);
2548 host_int_set_mac_chnl_num(priv
->hWILCWFIDrv
, chan
->hw_value
);
2549 /*Save the current channel after we tune to it*/
2550 u8CurrChannel
= chan
->hw_value
;
2551 } else if (ieee80211_is_action(mgmt
->frame_control
)) {
2552 PRINT_D(GENERIC_DBG
, "ACTION FRAME:%x\n", (u16
)mgmt
->frame_control
);
2556 if (buf
[ACTION_CAT_ID
] == PUB_ACTION_ATTR_ID
) {
2558 /*Only set the channel, if not a negotiation confirmation frame
2559 * (If Negotiation confirmation frame, force it
2560 * to be transmitted on the same negotiation channel)*/
2562 if (buf
[ACTION_SUBTYPE_ID
] != PUBLIC_ACT_VENDORSPEC
||
2563 buf
[P2P_PUB_ACTION_SUBTYPE
] != GO_NEG_CONF
) {
2564 PRINT_D(GENERIC_DBG
, "Setting channel: %d\n", chan
->hw_value
);
2565 host_int_set_mac_chnl_num(priv
->hWILCWFIDrv
, chan
->hw_value
);
2566 /*Save the current channel after we tune to it*/
2567 u8CurrChannel
= chan
->hw_value
;
2569 switch (buf
[ACTION_SUBTYPE_ID
]) {
2570 case GAS_INTIAL_REQ
:
2572 PRINT_D(GENERIC_DBG
, "GAS INITIAL REQ %x\n", buf
[ACTION_SUBTYPE_ID
]);
2576 case GAS_INTIAL_RSP
:
2578 PRINT_D(GENERIC_DBG
, "GAS INITIAL RSP %x\n", buf
[ACTION_SUBTYPE_ID
]);
2582 case PUBLIC_ACT_VENDORSPEC
:
2584 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2585 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
2586 if (!WILC_memcmp(u8P2P_oui
, &buf
[ACTION_SUBTYPE_ID
+ 1], 4)) {
2587 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2588 if ((buf
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_REQ
|| buf
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_RSP
)) {
2589 if (u8P2Plocalrandom
== 1 && u8P2Precvrandom
< u8P2Plocalrandom
) {
2590 get_random_bytes(&u8P2Plocalrandom
, 1);
2591 /*Increment the number to prevent if its 0*/
2596 if ((buf
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_REQ
|| buf
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_RSP
2597 || buf
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_REQ
|| buf
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_RSP
)) {
2598 if (u8P2Plocalrandom
> u8P2Precvrandom
) {
2599 PRINT_D(GENERIC_DBG
, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom
, u8P2Precvrandom
);
2601 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2602 for (i
= P2P_PUB_ACTION_SUBTYPE
+ 2; i
< len
; i
++) {
2603 if (buf
[i
] == P2PELEM_ATTR_ID
&& !(WILC_memcmp(u8P2P_oui
, &buf
[i
+ 2], 4))) {
2604 if (buf
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_REQ
|| buf
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_RSP
)
2605 WILC_WFI_CfgParseTxAction(&mgmt_tx
->buff
[i
+ 6], len
- (i
+ 6), true, nic
->iftype
);
2608 /*If using supplicant go intent, no need at all*/
2609 /*to parse transmitted negotiation frames*/
2610 #ifndef USE_SUPPLICANT_GO_INTENT
2612 WILC_WFI_CfgParseTxAction(&mgmt_tx
->buff
[i
+ 6], len
- (i
+ 6), false, nic
->iftype
);
2618 if (buf
[P2P_PUB_ACTION_SUBTYPE
] != P2P_INV_REQ
&& buf
[P2P_PUB_ACTION_SUBTYPE
] != P2P_INV_RSP
) {
2619 WILC_WFI_add_wilcvendorspec(&mgmt_tx
->buff
[len
]);
2620 mgmt_tx
->buff
[len
+ sizeof(u8P2P_vendorspec
)] = u8P2Plocalrandom
;
2621 mgmt_tx
->size
= buf_len
;
2624 PRINT_D(GENERIC_DBG
, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom
, u8P2Precvrandom
);
2628 PRINT_D(GENERIC_DBG
, "Not a P2P public action frame\n");
2636 PRINT_D(GENERIC_DBG
, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf
[ACTION_SUBTYPE_ID
]);
2643 PRINT_D(GENERIC_DBG
, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf
[ACTION_SUBTYPE_ID
], chan
->hw_value
);
2644 pstrWFIDrv
->u64P2p_MgmtTimeout
= (jiffies
+ msecs_to_jiffies(wait
));
2646 PRINT_D(GENERIC_DBG
, "Current Jiffies: %lu Timeout:%llu\n", jiffies
, pstrWFIDrv
->u64P2p_MgmtTimeout
);
2650 g_linux_wlan
->oup
.wlan_add_mgmt_to_tx_que(mgmt_tx
, mgmt_tx
->buff
, mgmt_tx
->size
, WILC_WFI_mgmt_tx_complete
);
2652 PRINT_D(GENERIC_DBG
, "This function transmits only management frames\n");
2657 int WILC_WFI_mgmt_tx_cancel_wait(struct wiphy
*wiphy
,
2658 struct wireless_dev
*wdev
,
2661 struct WILC_WFI_priv
*priv
;
2662 tstrWILC_WFIDrv
*pstrWFIDrv
;
2663 priv
= wiphy_priv(wiphy
);
2664 pstrWFIDrv
= (tstrWILC_WFIDrv
*)priv
->hWILCWFIDrv
;
2667 PRINT_D(GENERIC_DBG
, "Tx Cancel wait :%lu\n", jiffies
);
2668 pstrWFIDrv
->u64P2p_MgmtTimeout
= jiffies
;
2670 if (priv
->bInP2PlistenState
== false) {
2671 /* Bug 5504: This is just to avoid connection failure when getting stuck when the supplicant
2672 * considers the driver falsely that it is in Listen state */
2673 cfg80211_remain_on_channel_expired(priv
->wdev
,
2674 priv
->strRemainOnChanParams
.u64ListenCookie
,
2675 priv
->strRemainOnChanParams
.pstrListenChan
,
2683 * @brief WILC_WFI_frame_register
2684 * @details Notify driver that a management frame type was
2685 * registered. Note that this callback may not sleep, and cannot run
2686 * concurrently with itself.
2693 void WILC_WFI_frame_register(struct wiphy
*wiphy
,
2694 struct wireless_dev
*wdev
,
2695 u16 frame_type
, bool reg
)
2698 struct WILC_WFI_priv
*priv
;
2699 perInterface_wlan_t
*nic
;
2702 priv
= wiphy_priv(wiphy
);
2703 nic
= netdev_priv(priv
->wdev
->netdev
);
2711 PRINT_D(GENERIC_DBG
, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type
, reg
);
2712 switch (frame_type
) {
2715 nic
->g_struct_frame_reg
[0].frame_type
= frame_type
;
2716 nic
->g_struct_frame_reg
[0].reg
= reg
;
2722 nic
->g_struct_frame_reg
[1].frame_type
= frame_type
;
2723 nic
->g_struct_frame_reg
[1].reg
= reg
;
2733 /*If mac is closed, then return*/
2734 if (!g_linux_wlan
->wilc1000_initialized
) {
2735 PRINT_D(GENERIC_DBG
, "Return since mac is closed\n");
2738 host_int_frame_register(priv
->hWILCWFIDrv
, frame_type
, reg
);
2745 * @brief WILC_WFI_set_cqm_rssi_config
2746 * @details Configure connection quality monitor RSSI threshold.
2747 * @param[in] struct wiphy *wiphy:
2748 * @param[in] struct net_device *dev:
2749 * @param[in] s32 rssi_thold:
2750 * @param[in] u32 rssi_hyst:
2751 * @return int : Return 0 on Success
2756 static int WILC_WFI_set_cqm_rssi_config(struct wiphy
*wiphy
,
2757 struct net_device
*dev
, s32 rssi_thold
, u32 rssi_hyst
)
2759 PRINT_D(CFG80211_DBG
, "Setting CQM RSSi Function\n");
2764 * @brief WILC_WFI_dump_station
2765 * @details Configure connection quality monitor RSSI threshold.
2766 * @param[in] struct wiphy *wiphy:
2767 * @param[in] struct net_device *dev
2768 * @param[in] int idx
2769 * @param[in] u8 *mac
2770 * @param[in] struct station_info *sinfo
2771 * @return int : Return 0 on Success
2776 static int WILC_WFI_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
2777 int idx
, u8
*mac
, struct station_info
*sinfo
)
2779 struct WILC_WFI_priv
*priv
;
2780 PRINT_D(CFG80211_DBG
, "Dumping station information\n");
2785 priv
= wiphy_priv(wiphy
);
2787 sinfo
->filled
|= BIT(NL80211_STA_INFO_SIGNAL
);
2789 host_int_get_rssi(priv
->hWILCWFIDrv
, &(sinfo
->signal
));
2797 * @brief WILC_WFI_set_power_mgmt
2800 * @return int : Return 0 on Success.
2803 * @version 1.0WILC_WFI_set_cqmWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_config_rssi_config
2805 int WILC_WFI_set_power_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
2806 bool enabled
, int timeout
)
2808 struct WILC_WFI_priv
*priv
;
2809 PRINT_D(CFG80211_DBG
, " Power save Enabled= %d , TimeOut = %d\n", enabled
, timeout
);
2814 priv
= wiphy_priv(wiphy
);
2815 if (priv
->hWILCWFIDrv
== NULL
) {
2816 PRINT_ER("Driver is NULL\n");
2821 host_int_set_power_mgmt(priv
->hWILCWFIDrv
, enabled
, timeout
);
2824 return WILC_SUCCESS
;
2827 #ifdef WILC_AP_EXTERNAL_MLME
2829 * @brief WILC_WFI_change_virt_intf
2830 * @details Change type/configuration of virtual interface,
2831 * keep the struct wireless_dev's iftype updated.
2833 * @return int : Return 0 on Success.
2838 void wilc1000_wlan_deinit(linux_wlan_t
*nic
);
2839 int wilc1000_wlan_init(struct net_device
*dev
, perInterface_wlan_t
*p_nic
);
2841 static int WILC_WFI_change_virt_intf(struct wiphy
*wiphy
, struct net_device
*dev
,
2842 enum nl80211_iftype type
, u32
*flags
, struct vif_params
*params
)
2844 s32 s32Error
= WILC_SUCCESS
;
2845 struct WILC_WFI_priv
*priv
;
2846 perInterface_wlan_t
*nic
;
2853 nic
= netdev_priv(dev
);
2854 priv
= wiphy_priv(wiphy
);
2856 PRINT_D(HOSTAPD_DBG
, "In Change virtual interface function\n");
2857 PRINT_D(HOSTAPD_DBG
, "Wireless interface name =%s\n", dev
->name
);
2858 u8P2Plocalrandom
= 0x01;
2859 u8P2Precvrandom
= 0x00;
2863 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2864 g_obtainingIP
= false;
2865 WILC_TimerStop(&hDuringIpTimer
, NULL
);
2866 PRINT_D(GENERIC_DBG
, "Changing virtual interface, enable scan\n");
2869 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2870 if (g_ptk_keys_saved
&& g_gtk_keys_saved
) {
2871 Set_machw_change_vir_if(true);
2875 case NL80211_IFTYPE_STATION
:
2877 PRINT_D(HOSTAPD_DBG
, "Interface type = NL80211_IFTYPE_STATION\n");
2879 /* send delba over wlan interface */
2882 dev
->ieee80211_ptr
->iftype
= type
;
2883 priv
->wdev
->iftype
= type
;
2884 nic
->monitor_flag
= 0;
2885 nic
->iftype
= STATION_MODE
;
2887 /*Remove the enteries of the previously connected clients*/
2888 memset(priv
->assoc_stainfo
.au8Sta_AssociatedBss
, 0, MAX_NUM_STA
* ETH_ALEN
);
2891 interface_type
= nic
->iftype
;
2892 nic
->iftype
= STATION_MODE
;
2894 if (g_linux_wlan
->wilc1000_initialized
) {
2895 host_int_del_All_Rx_BASession(priv
->hWILCWFIDrv
, g_linux_wlan
->strInterfaceInfo
[0].aBSSID
, TID
);
2896 /* ensure that the message Q is empty */
2897 host_int_wait_msg_queue_idle();
2900 /*Eliminate host interface blocking state*/
2901 linux_wlan_unlock((void *)&g_linux_wlan
->cfg_event
);
2903 wilc1000_wlan_deinit(g_linux_wlan
);
2904 wilc1000_wlan_init(dev
, nic
);
2905 g_wilc_initialized
= 1;
2906 nic
->iftype
= interface_type
;
2908 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2909 host_int_set_wfi_drv_handler(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
);
2910 host_int_set_MacAddress((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
2911 g_linux_wlan
->strInterfaceInfo
[0].aSrcAddress
);
2912 host_int_set_operation_mode(priv
->hWILCWFIDrv
, STATION_MODE
);
2914 /*Add saved WEP keys, if any*/
2915 if (g_wep_keys_saved
) {
2916 host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
2917 g_key_wep_params
.key_idx
);
2918 host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
2919 g_key_wep_params
.key
,
2920 g_key_wep_params
.key_len
,
2921 g_key_wep_params
.key_idx
);
2924 /*No matter the driver handler passed here, it will be overwriiten*/
2925 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2926 host_int_flush_join_req(priv
->hWILCWFIDrv
);
2928 /*Add saved PTK and GTK keys, if any*/
2929 if (g_ptk_keys_saved
&& g_gtk_keys_saved
) {
2930 PRINT_D(CFG80211_DBG
, "ptk %x %x %x\n", g_key_ptk_params
.key
[0],
2931 g_key_ptk_params
.key
[1],
2932 g_key_ptk_params
.key
[2]);
2933 PRINT_D(CFG80211_DBG
, "gtk %x %x %x\n", g_key_gtk_params
.key
[0],
2934 g_key_gtk_params
.key
[1],
2935 g_key_gtk_params
.key
[2]);
2936 WILC_WFI_add_key(g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
->ieee80211_ptr
->wiphy
,
2937 g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
,
2938 g_add_ptk_key_params
.key_idx
,
2939 g_add_ptk_key_params
.pairwise
,
2940 g_add_ptk_key_params
.mac_addr
,
2941 (struct key_params
*)(&g_key_ptk_params
));
2943 WILC_WFI_add_key(g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
->ieee80211_ptr
->wiphy
,
2944 g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
,
2945 g_add_gtk_key_params
.key_idx
,
2946 g_add_gtk_key_params
.pairwise
,
2947 g_add_gtk_key_params
.mac_addr
,
2948 (struct key_params
*)(&g_key_gtk_params
));
2951 /*BugID_4847: registered frames in firmware are now*/
2952 /*lost due to mac close. So re-register those frames*/
2953 if (g_linux_wlan
->wilc1000_initialized
) {
2954 for (i
= 0; i
< num_reg_frame
; i
++) {
2955 PRINT_D(INIT_DBG
, "Frame registering Type: %x - Reg: %d\n", nic
->g_struct_frame_reg
[i
].frame_type
,
2956 nic
->g_struct_frame_reg
[i
].reg
);
2957 host_int_frame_register(priv
->hWILCWFIDrv
,
2958 nic
->g_struct_frame_reg
[i
].frame_type
,
2959 nic
->g_struct_frame_reg
[i
].reg
);
2964 host_int_set_power_mgmt(priv
->hWILCWFIDrv
, 1, 0);
2970 case NL80211_IFTYPE_P2P_CLIENT
:
2972 host_int_set_power_mgmt(priv
->hWILCWFIDrv
, 0, 0);
2974 PRINT_D(HOSTAPD_DBG
, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
2976 host_int_del_All_Rx_BASession(priv
->hWILCWFIDrv
, g_linux_wlan
->strInterfaceInfo
[0].aBSSID
, TID
);
2978 dev
->ieee80211_ptr
->iftype
= type
;
2979 priv
->wdev
->iftype
= type
;
2980 nic
->monitor_flag
= 0;
2985 PRINT_D(HOSTAPD_DBG
, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2986 nic
->iftype
= CLIENT_MODE
;
2989 if (g_linux_wlan
->wilc1000_initialized
) {
2990 /* ensure that the message Q is empty */
2991 host_int_wait_msg_queue_idle();
2993 wilc1000_wlan_deinit(g_linux_wlan
);
2994 wilc1000_wlan_init(dev
, nic
);
2995 g_wilc_initialized
= 1;
2997 host_int_set_wfi_drv_handler(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
);
2998 host_int_set_MacAddress((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
2999 g_linux_wlan
->strInterfaceInfo
[0].aSrcAddress
);
3000 host_int_set_operation_mode(priv
->hWILCWFIDrv
, STATION_MODE
);
3002 /*Add saved WEP keys, if any*/
3003 if (g_wep_keys_saved
) {
3004 host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
3005 g_key_wep_params
.key_idx
);
3006 host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
3007 g_key_wep_params
.key
,
3008 g_key_wep_params
.key_len
,
3009 g_key_wep_params
.key_idx
);
3012 /*No matter the driver handler passed here, it will be overwriiten*/
3013 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3014 host_int_flush_join_req(priv
->hWILCWFIDrv
);
3016 /*Add saved PTK and GTK keys, if any*/
3017 if (g_ptk_keys_saved
&& g_gtk_keys_saved
) {
3018 PRINT_D(CFG80211_DBG
, "ptk %x %x %x\n", g_key_ptk_params
.key
[0],
3019 g_key_ptk_params
.key
[1],
3020 g_key_ptk_params
.key
[2]);
3021 PRINT_D(CFG80211_DBG
, "gtk %x %x %x\n", g_key_gtk_params
.key
[0],
3022 g_key_gtk_params
.key
[1],
3023 g_key_gtk_params
.key
[2]);
3024 WILC_WFI_add_key(g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
->ieee80211_ptr
->wiphy
,
3025 g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
,
3026 g_add_ptk_key_params
.key_idx
,
3027 g_add_ptk_key_params
.pairwise
,
3028 g_add_ptk_key_params
.mac_addr
,
3029 (struct key_params
*)(&g_key_ptk_params
));
3031 WILC_WFI_add_key(g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
->ieee80211_ptr
->wiphy
,
3032 g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
,
3033 g_add_gtk_key_params
.key_idx
,
3034 g_add_gtk_key_params
.pairwise
,
3035 g_add_gtk_key_params
.mac_addr
,
3036 (struct key_params
*)(&g_key_gtk_params
));
3039 /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/
3040 refresh_scan(priv
, 1, true);
3041 Set_machw_change_vir_if(false);
3043 /*BugID_4847: registered frames in firmware are now lost
3044 * due to mac close. So re-register those frames */
3045 if (g_linux_wlan
->wilc1000_initialized
) {
3046 for (i
= 0; i
< num_reg_frame
; i
++) {
3047 PRINT_D(INIT_DBG
, "Frame registering Type: %x - Reg: %d\n", nic
->g_struct_frame_reg
[i
].frame_type
,
3048 nic
->g_struct_frame_reg
[i
].reg
);
3049 host_int_frame_register(priv
->hWILCWFIDrv
,
3050 nic
->g_struct_frame_reg
[i
].frame_type
,
3051 nic
->g_struct_frame_reg
[i
].reg
);
3059 case NL80211_IFTYPE_AP
:
3061 PRINT_D(HOSTAPD_DBG
, "Interface type = NL80211_IFTYPE_AP %d\n", type
);
3062 dev
->ieee80211_ptr
->iftype
= type
;
3063 priv
->wdev
->iftype
= type
;
3064 nic
->iftype
= AP_MODE
;
3065 PRINT_D(CORECONFIG_DBG
, "priv->hWILCWFIDrv[%p]\n", priv
->hWILCWFIDrv
);
3068 PRINT_D(HOSTAPD_DBG
, "Downloading AP firmware\n");
3069 linux_wlan_get_firmware(nic
);
3071 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
3072 if (g_linux_wlan
->wilc1000_initialized
) {
3073 nic
->iftype
= AP_MODE
;
3074 g_linux_wlan
->wilc1000_initialized
= 1;
3078 /*BugID_4847: registered frames in firmware are now lost
3079 * due to mac close. So re-register those frames */
3080 for (i
= 0; i
< num_reg_frame
; i
++) {
3081 PRINT_D(INIT_DBG
, "Frame registering Type: %x - Reg: %d\n", nic
->g_struct_frame_reg
[i
].frame_type
,
3082 nic
->g_struct_frame_reg
[i
].reg
);
3083 host_int_frame_register(priv
->hWILCWFIDrv
,
3084 nic
->g_struct_frame_reg
[i
].frame_type
,
3085 nic
->g_struct_frame_reg
[i
].reg
);
3092 case NL80211_IFTYPE_P2P_GO
:
3093 PRINT_D(GENERIC_DBG
, "start duringIP timer\n");
3095 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3096 g_obtainingIP
= true;
3097 WILC_TimerStart(&hDuringIpTimer
, duringIP_TIME
, NULL
, NULL
);
3099 host_int_set_power_mgmt(priv
->hWILCWFIDrv
, 0, 0);
3101 /*Delete block ack has to be the latest config packet*/
3102 /*sent before downloading new FW. This is because it blocks on*/
3103 /*hWaitResponse semaphore, which allows previous config*/
3104 /*packets to actually take action on old FW*/
3105 host_int_del_All_Rx_BASession(priv
->hWILCWFIDrv
, g_linux_wlan
->strInterfaceInfo
[0].aBSSID
, TID
);
3107 PRINT_D(HOSTAPD_DBG
, "Interface type = NL80211_IFTYPE_GO\n");
3108 dev
->ieee80211_ptr
->iftype
= type
;
3109 priv
->wdev
->iftype
= type
;
3111 PRINT_D(CORECONFIG_DBG
, "priv->hWILCWFIDrv[%p]\n", priv
->hWILCWFIDrv
);
3115 PRINT_D(HOSTAPD_DBG
, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
3119 nic
->iftype
= GO_MODE
;
3121 /* ensure that the message Q is empty */
3122 host_int_wait_msg_queue_idle();
3123 wilc1000_wlan_deinit(g_linux_wlan
);
3124 wilc1000_wlan_init(dev
, nic
);
3125 g_wilc_initialized
= 1;
3128 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
3129 host_int_set_wfi_drv_handler(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
);
3130 host_int_set_MacAddress((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
3131 g_linux_wlan
->strInterfaceInfo
[0].aSrcAddress
);
3132 host_int_set_operation_mode(priv
->hWILCWFIDrv
, AP_MODE
);
3134 /*Add saved WEP keys, if any*/
3135 if (g_wep_keys_saved
) {
3136 host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
3137 g_key_wep_params
.key_idx
);
3138 host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
3139 g_key_wep_params
.key
,
3140 g_key_wep_params
.key_len
,
3141 g_key_wep_params
.key_idx
);
3144 /*No matter the driver handler passed here, it will be overwriiten*/
3145 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3146 host_int_flush_join_req(priv
->hWILCWFIDrv
);
3148 /*Add saved PTK and GTK keys, if any*/
3149 if (g_ptk_keys_saved
&& g_gtk_keys_saved
) {
3150 PRINT_D(CFG80211_DBG
, "ptk %x %x %x cipher %x\n", g_key_ptk_params
.key
[0],
3151 g_key_ptk_params
.key
[1],
3152 g_key_ptk_params
.key
[2],
3153 g_key_ptk_params
.cipher
);
3154 PRINT_D(CFG80211_DBG
, "gtk %x %x %x cipher %x\n", g_key_gtk_params
.key
[0],
3155 g_key_gtk_params
.key
[1],
3156 g_key_gtk_params
.key
[2],
3157 g_key_gtk_params
.cipher
);
3159 WILC_WFI_add_key(g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
->ieee80211_ptr
->wiphy
,
3160 g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
,
3161 g_add_ptk_key_params
.key_idx
,
3162 g_add_ptk_key_params
.pairwise
,
3163 g_add_ptk_key_params
.mac_addr
,
3164 (struct key_params
*)(&g_key_ptk_params
));
3166 WILC_WFI_add_key(g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
->ieee80211_ptr
->wiphy
,
3167 g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
,
3168 g_add_gtk_key_params
.key_idx
,
3169 g_add_gtk_key_params
.pairwise
,
3170 g_add_gtk_key_params
.mac_addr
,
3171 (struct key_params
*)(&g_key_gtk_params
));
3176 /*BugID_4847: registered frames in firmware are now*/
3177 /*lost due to mac close. So re-register those frames*/
3178 if (g_linux_wlan
->wilc1000_initialized
) {
3179 for (i
= 0; i
< num_reg_frame
; i
++) {
3180 PRINT_D(INIT_DBG
, "Frame registering Type: %x - Reg: %d\n", nic
->g_struct_frame_reg
[i
].frame_type
,
3181 nic
->g_struct_frame_reg
[i
].reg
);
3182 host_int_frame_register(priv
->hWILCWFIDrv
,
3183 nic
->g_struct_frame_reg
[i
].frame_type
,
3184 nic
->g_struct_frame_reg
[i
].reg
);
3192 PRINT_ER("Unknown interface type= %d\n", type
);
3201 /* (austin.2013-07-23)
3203 * To support revised cfg80211_ops
3205 * add_beacon --> start_ap
3206 * set_beacon --> change_beacon
3207 * del_beacon --> stop_ap
3209 * beacon_parameters --> cfg80211_ap_settings
3210 * cfg80211_beacon_data
3212 * applicable for linux kernel 3.4+
3216 * @brief WILC_WFI_start_ap
3217 * @details Add a beacon with given parameters, @head, @interval
3218 * and @dtim_period will be valid, @tail is optional.
3220 * @param[in] dev The net device structure
3221 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
3222 * @return int : Return 0 on Success.
3227 static int WILC_WFI_start_ap(struct wiphy
*wiphy
, struct net_device
*dev
,
3228 struct cfg80211_ap_settings
*settings
)
3230 struct cfg80211_beacon_data
*beacon
= &(settings
->beacon
);
3231 struct WILC_WFI_priv
*priv
;
3232 s32 s32Error
= WILC_SUCCESS
;
3234 priv
= wiphy_priv(wiphy
);
3235 PRINT_D(HOSTAPD_DBG
, "Starting ap\n");
3237 PRINT_D(HOSTAPD_DBG
, "Interval = %d \n DTIM period = %d\n Head length = %zu Tail length = %zu\n",
3238 settings
->beacon_interval
, settings
->dtim_period
, beacon
->head_len
, beacon
->tail_len
);
3240 s32Error
= WILC_WFI_CfgSetChannel(wiphy
, &settings
->chandef
);
3242 if (s32Error
!= WILC_SUCCESS
)
3243 PRINT_ER("Error in setting channel\n");
3245 linux_wlan_set_bssid(dev
, g_linux_wlan
->strInterfaceInfo
[0].aSrcAddress
);
3247 #ifndef WILC_FULLY_HOSTING_AP
3248 s32Error
= host_int_add_beacon(priv
->hWILCWFIDrv
,
3249 settings
->beacon_interval
,
3250 settings
->dtim_period
,
3251 beacon
->head_len
, (u8
*)beacon
->head
,
3252 beacon
->tail_len
, (u8
*)beacon
->tail
);
3254 s32Error
= host_add_beacon(priv
->hWILCWFIDrv
,
3255 settings
->beacon_interval
,
3256 settings
->dtim_period
,
3257 beacon
->head_len
, (u8
*)beacon
->head
,
3258 beacon
->tail_len
, (u8
*)beacon
->tail
);
3265 * @brief WILC_WFI_change_beacon
3266 * @details Add a beacon with given parameters, @head, @interval
3267 * and @dtim_period will be valid, @tail is optional.
3269 * @param[in] dev The net device structure
3270 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
3271 * @return int : Return 0 on Success.
3276 static int WILC_WFI_change_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
3277 struct cfg80211_beacon_data
*beacon
)
3279 struct WILC_WFI_priv
*priv
;
3280 s32 s32Error
= WILC_SUCCESS
;
3282 priv
= wiphy_priv(wiphy
);
3283 PRINT_D(HOSTAPD_DBG
, "Setting beacon\n");
3286 #ifndef WILC_FULLY_HOSTING_AP
3287 s32Error
= host_int_add_beacon(priv
->hWILCWFIDrv
,
3290 beacon
->head_len
, (u8
*)beacon
->head
,
3291 beacon
->tail_len
, (u8
*)beacon
->tail
);
3293 s32Error
= host_add_beacon(priv
->hWILCWFIDrv
,
3296 beacon
->head_len
, (u8
*)beacon
->head
,
3297 beacon
->tail_len
, (u8
*)beacon
->tail
);
3304 * @brief WILC_WFI_stop_ap
3305 * @details Remove beacon configuration and stop sending the beacon.
3307 * @return int : Return 0 on Success.
3312 static int WILC_WFI_stop_ap(struct wiphy
*wiphy
, struct net_device
*dev
)
3314 s32 s32Error
= WILC_SUCCESS
;
3315 struct WILC_WFI_priv
*priv
;
3316 u8 NullBssid
[ETH_ALEN
] = {0};
3319 WILC_NULLCHECK(s32Error
, wiphy
);
3321 priv
= wiphy_priv(wiphy
);
3323 PRINT_D(HOSTAPD_DBG
, "Deleting beacon\n");
3326 linux_wlan_set_bssid(dev
, NullBssid
);
3328 #ifndef WILC_FULLY_HOSTING_AP
3329 s32Error
= host_int_del_beacon(priv
->hWILCWFIDrv
);
3331 s32Error
= host_del_beacon(priv
->hWILCWFIDrv
);
3334 WILC_ERRORCHECK(s32Error
);
3336 WILC_CATCH(s32Error
)
3343 * @brief WILC_WFI_add_station
3344 * @details Add a new station.
3346 * @return int : Return 0 on Success.
3351 static int WILC_WFI_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3352 const u8
*mac
, struct station_parameters
*params
)
3354 s32 s32Error
= WILC_SUCCESS
;
3355 struct WILC_WFI_priv
*priv
;
3356 tstrWILC_AddStaParam strStaParams
= {{0}};
3357 perInterface_wlan_t
*nic
;
3360 WILC_NULLCHECK(s32Error
, wiphy
);
3362 priv
= wiphy_priv(wiphy
);
3363 nic
= netdev_priv(dev
);
3365 if (nic
->iftype
== AP_MODE
|| nic
->iftype
== GO_MODE
) {
3366 #ifndef WILC_FULLY_HOSTING_AP
3368 WILC_memcpy(strStaParams
.au8BSSID
, mac
, ETH_ALEN
);
3369 WILC_memcpy(priv
->assoc_stainfo
.au8Sta_AssociatedBss
[params
->aid
], mac
, ETH_ALEN
);
3370 strStaParams
.u16AssocID
= params
->aid
;
3371 strStaParams
.u8NumRates
= params
->supported_rates_len
;
3372 strStaParams
.pu8Rates
= params
->supported_rates
;
3374 PRINT_D(CFG80211_DBG
, "Adding station parameters %d\n", params
->aid
);
3376 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],
3377 priv
->assoc_stainfo
.au8Sta_AssociatedBss
[params
->aid
][5]);
3378 PRINT_D(HOSTAPD_DBG
, "ASSOC ID = %d\n", strStaParams
.u16AssocID
);
3379 PRINT_D(HOSTAPD_DBG
, "Number of supported rates = %d\n", strStaParams
.u8NumRates
);
3381 if (params
->ht_capa
== NULL
) {
3382 strStaParams
.bIsHTSupported
= false;
3384 strStaParams
.bIsHTSupported
= true;
3385 strStaParams
.u16HTCapInfo
= params
->ht_capa
->cap_info
;
3386 strStaParams
.u8AmpduParams
= params
->ht_capa
->ampdu_params_info
;
3387 WILC_memcpy(strStaParams
.au8SuppMCsSet
, ¶ms
->ht_capa
->mcs
, WILC_SUPP_MCS_SET_SIZE
);
3388 strStaParams
.u16HTExtParams
= params
->ht_capa
->extended_ht_cap_info
;
3389 strStaParams
.u32TxBeamformingCap
= params
->ht_capa
->tx_BF_cap_info
;
3390 strStaParams
.u8ASELCap
= params
->ht_capa
->antenna_selection_info
;
3393 strStaParams
.u16FlagsMask
= params
->sta_flags_mask
;
3394 strStaParams
.u16FlagsSet
= params
->sta_flags_set
;
3396 PRINT_D(HOSTAPD_DBG
, "IS HT supported = %d\n", strStaParams
.bIsHTSupported
);
3397 PRINT_D(HOSTAPD_DBG
, "Capability Info = %d\n", strStaParams
.u16HTCapInfo
);
3398 PRINT_D(HOSTAPD_DBG
, "AMPDU Params = %d\n", strStaParams
.u8AmpduParams
);
3399 PRINT_D(HOSTAPD_DBG
, "HT Extended params = %d\n", strStaParams
.u16HTExtParams
);
3400 PRINT_D(HOSTAPD_DBG
, "Tx Beamforming Cap = %d\n", strStaParams
.u32TxBeamformingCap
);
3401 PRINT_D(HOSTAPD_DBG
, "Antenna selection info = %d\n", strStaParams
.u8ASELCap
);
3402 PRINT_D(HOSTAPD_DBG
, "Flag Mask = %d\n", strStaParams
.u16FlagsMask
);
3403 PRINT_D(HOSTAPD_DBG
, "Flag Set = %d\n", strStaParams
.u16FlagsSet
);
3405 s32Error
= host_int_add_station(priv
->hWILCWFIDrv
, &strStaParams
);
3406 WILC_ERRORCHECK(s32Error
);
3409 PRINT_D(CFG80211_DBG
, "Adding station parameters %d\n", params
->aid
);
3410 WILC_memcpy(priv
->assoc_stainfo
.au8Sta_AssociatedBss
[params
->aid
], mac
, ETH_ALEN
);
3412 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],
3413 priv
->assoc_stainfo
.au8Sta_AssociatedBss
[params
->aid
][5]);
3415 WILC_AP_AddSta(mac
, params
);
3416 WILC_ERRORCHECK(s32Error
);
3417 #endif /* WILC_FULLY_HOSTING_AP */
3421 WILC_CATCH(s32Error
)
3428 * @brief WILC_WFI_del_station
3429 * @details Remove a station; @mac may be NULL to remove all stations.
3431 * @return int : Return 0 on Success.
3436 static int WILC_WFI_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3437 struct station_del_parameters
*params
)
3439 const u8
*mac
= params
->mac
;
3440 s32 s32Error
= WILC_SUCCESS
;
3441 struct WILC_WFI_priv
*priv
;
3442 perInterface_wlan_t
*nic
;
3443 WILC_NULLCHECK(s32Error
, wiphy
);
3445 priv
= wiphy_priv(wiphy
);
3446 nic
= netdev_priv(dev
);
3448 if (nic
->iftype
== AP_MODE
|| nic
->iftype
== GO_MODE
) {
3449 PRINT_D(HOSTAPD_DBG
, "Deleting station\n");
3453 PRINT_D(HOSTAPD_DBG
, "All associated stations \n");
3454 s32Error
= host_int_del_allstation(priv
->hWILCWFIDrv
, priv
->assoc_stainfo
.au8Sta_AssociatedBss
);
3456 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]);
3459 #ifndef WILC_FULLY_HOSTING_AP
3460 s32Error
= host_int_del_station(priv
->hWILCWFIDrv
, mac
);
3462 WILC_AP_RemoveSta(mac
);
3463 #endif /* WILC_FULLY_HOSTING_AP */
3465 WILC_ERRORCHECK(s32Error
);
3467 WILC_CATCH(s32Error
)
3474 * @brief WILC_WFI_change_station
3475 * @details Modify a given station.
3477 * @return int : Return 0 on Success.
3482 static int WILC_WFI_change_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3483 const u8
*mac
, struct station_parameters
*params
)
3485 s32 s32Error
= WILC_SUCCESS
;
3486 struct WILC_WFI_priv
*priv
;
3487 tstrWILC_AddStaParam strStaParams
= {{0}};
3488 perInterface_wlan_t
*nic
;
3491 PRINT_D(HOSTAPD_DBG
, "Change station paramters\n");
3493 WILC_NULLCHECK(s32Error
, wiphy
);
3495 priv
= wiphy_priv(wiphy
);
3496 nic
= netdev_priv(dev
);
3498 if (nic
->iftype
== AP_MODE
|| nic
->iftype
== GO_MODE
) {
3499 #ifndef WILC_FULLY_HOSTING_AP
3501 WILC_memcpy(strStaParams
.au8BSSID
, mac
, ETH_ALEN
);
3502 strStaParams
.u16AssocID
= params
->aid
;
3503 strStaParams
.u8NumRates
= params
->supported_rates_len
;
3504 strStaParams
.pu8Rates
= params
->supported_rates
;
3506 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],
3507 strStaParams
.au8BSSID
[5]);
3508 PRINT_D(HOSTAPD_DBG
, "ASSOC ID = %d\n", strStaParams
.u16AssocID
);
3509 PRINT_D(HOSTAPD_DBG
, "Number of supported rates = %d\n", strStaParams
.u8NumRates
);
3511 if (params
->ht_capa
== NULL
) {
3512 strStaParams
.bIsHTSupported
= false;
3514 strStaParams
.bIsHTSupported
= true;
3515 strStaParams
.u16HTCapInfo
= params
->ht_capa
->cap_info
;
3516 strStaParams
.u8AmpduParams
= params
->ht_capa
->ampdu_params_info
;
3517 WILC_memcpy(strStaParams
.au8SuppMCsSet
, ¶ms
->ht_capa
->mcs
, WILC_SUPP_MCS_SET_SIZE
);
3518 strStaParams
.u16HTExtParams
= params
->ht_capa
->extended_ht_cap_info
;
3519 strStaParams
.u32TxBeamformingCap
= params
->ht_capa
->tx_BF_cap_info
;
3520 strStaParams
.u8ASELCap
= params
->ht_capa
->antenna_selection_info
;
3524 strStaParams
.u16FlagsMask
= params
->sta_flags_mask
;
3525 strStaParams
.u16FlagsSet
= params
->sta_flags_set
;
3527 PRINT_D(HOSTAPD_DBG
, "IS HT supported = %d\n", strStaParams
.bIsHTSupported
);
3528 PRINT_D(HOSTAPD_DBG
, "Capability Info = %d\n", strStaParams
.u16HTCapInfo
);
3529 PRINT_D(HOSTAPD_DBG
, "AMPDU Params = %d\n", strStaParams
.u8AmpduParams
);
3530 PRINT_D(HOSTAPD_DBG
, "HT Extended params = %d\n", strStaParams
.u16HTExtParams
);
3531 PRINT_D(HOSTAPD_DBG
, "Tx Beamforming Cap = %d\n", strStaParams
.u32TxBeamformingCap
);
3532 PRINT_D(HOSTAPD_DBG
, "Antenna selection info = %d\n", strStaParams
.u8ASELCap
);
3533 PRINT_D(HOSTAPD_DBG
, "Flag Mask = %d\n", strStaParams
.u16FlagsMask
);
3534 PRINT_D(HOSTAPD_DBG
, "Flag Set = %d\n", strStaParams
.u16FlagsSet
);
3536 s32Error
= host_int_edit_station(priv
->hWILCWFIDrv
, &strStaParams
);
3537 WILC_ERRORCHECK(s32Error
);
3540 WILC_AP_EditSta(mac
, params
);
3541 WILC_ERRORCHECK(s32Error
);
3542 #endif /* WILC_FULLY_HOSTING_AP */
3545 WILC_CATCH(s32Error
)
3553 * @brief WILC_WFI_add_virt_intf
3556 * @return int : Return 0 on Success.
3561 struct wireless_dev
*WILC_WFI_add_virt_intf(struct wiphy
*wiphy
, const char *name
,
3562 unsigned char name_assign_type
,
3563 enum nl80211_iftype type
, u32
*flags
,
3564 struct vif_params
*params
)
3566 perInterface_wlan_t
*nic
;
3567 struct WILC_WFI_priv
*priv
;
3568 struct net_device
*new_ifc
= NULL
;
3569 priv
= wiphy_priv(wiphy
);
3573 PRINT_D(HOSTAPD_DBG
, "Adding monitor interface[%p]\n", priv
->wdev
->netdev
);
3575 nic
= netdev_priv(priv
->wdev
->netdev
);
3578 if (type
== NL80211_IFTYPE_MONITOR
) {
3579 PRINT_D(HOSTAPD_DBG
, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3580 PRINT_D(HOSTAPD_DBG
, "Adding monitor interface[%p]\n", nic
->wilc_netdev
);
3581 new_ifc
= WILC_WFI_init_mon_interface(name
, nic
->wilc_netdev
);
3582 if (new_ifc
!= NULL
) {
3583 PRINT_D(HOSTAPD_DBG
, "Setting monitor flag in private structure\n");
3585 priv
= netdev_priv(priv
->wdev
->netdev
);
3586 priv
->monitor_flag
= 1;
3588 nic
= netdev_priv(priv
->wdev
->netdev
);
3589 nic
->monitor_flag
= 1;
3592 PRINT_ER("Error in initializing monitor interface\n ");
3598 * @brief WILC_WFI_del_virt_intf
3601 * @return int : Return 0 on Success.
3606 int WILC_WFI_del_virt_intf(struct wiphy
*wiphy
, struct wireless_dev
*wdev
) /* tony for v3.8 support */
3608 PRINT_D(HOSTAPD_DBG
, "Deleting virtual interface\n");
3609 return WILC_SUCCESS
;
3614 #endif /*WILC_AP_EXTERNAL_MLME*/
3615 static struct cfg80211_ops WILC_WFI_cfg80211_ops
= {
3617 .set_monitor_channel
= WILC_WFI_CfgSetChannel
,
3618 .scan
= WILC_WFI_CfgScan
,
3619 .connect
= WILC_WFI_CfgConnect
,
3620 .disconnect
= WILC_WFI_disconnect
,
3621 .add_key
= WILC_WFI_add_key
,
3622 .del_key
= WILC_WFI_del_key
,
3623 .get_key
= WILC_WFI_get_key
,
3624 .set_default_key
= WILC_WFI_set_default_key
,
3625 #ifdef WILC_AP_EXTERNAL_MLME
3626 .add_virtual_intf
= WILC_WFI_add_virt_intf
,
3627 .del_virtual_intf
= WILC_WFI_del_virt_intf
,
3628 .change_virtual_intf
= WILC_WFI_change_virt_intf
,
3630 .start_ap
= WILC_WFI_start_ap
,
3631 .change_beacon
= WILC_WFI_change_beacon
,
3632 .stop_ap
= WILC_WFI_stop_ap
,
3633 .add_station
= WILC_WFI_add_station
,
3634 .del_station
= WILC_WFI_del_station
,
3635 .change_station
= WILC_WFI_change_station
,
3636 #endif /* WILC_AP_EXTERNAL_MLME*/
3637 #ifndef WILC_FULLY_HOSTING_AP
3638 .get_station
= WILC_WFI_get_station
,
3640 .dump_station
= WILC_WFI_dump_station
,
3641 .change_bss
= WILC_WFI_change_bss
,
3642 .set_wiphy_params
= WILC_WFI_set_wiphy_params
,
3644 .set_pmksa
= WILC_WFI_set_pmksa
,
3645 .del_pmksa
= WILC_WFI_del_pmksa
,
3646 .flush_pmksa
= WILC_WFI_flush_pmksa
,
3648 .remain_on_channel
= WILC_WFI_remain_on_channel
,
3649 .cancel_remain_on_channel
= WILC_WFI_cancel_remain_on_channel
,
3650 .mgmt_tx_cancel_wait
= WILC_WFI_mgmt_tx_cancel_wait
,
3651 .mgmt_tx
= WILC_WFI_mgmt_tx
,
3652 .mgmt_frame_register
= WILC_WFI_frame_register
,
3653 .set_power_mgmt
= WILC_WFI_set_power_mgmt
,
3654 .set_cqm_rssi_config
= WILC_WFI_set_cqm_rssi_config
,
3664 * @brief WILC_WFI_update_stats
3665 * @details Modify parameters for a given BSS.
3667 * @return int : Return 0 on Success.
3670 * @version 1.0WILC_WFI_set_cqmWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_config_rssi_config
3672 int WILC_WFI_update_stats(struct wiphy
*wiphy
, u32 pktlen
, u8 changed
)
3675 struct WILC_WFI_priv
*priv
;
3677 priv
= wiphy_priv(wiphy
);
3681 case WILC_WFI_RX_PKT
:
3683 priv
->netstats
.rx_packets
++;
3684 priv
->netstats
.rx_bytes
+= pktlen
;
3685 priv
->netstats
.rx_time
= get_jiffies_64();
3689 case WILC_WFI_TX_PKT
:
3691 priv
->netstats
.tx_packets
++;
3692 priv
->netstats
.tx_bytes
+= pktlen
;
3693 priv
->netstats
.tx_time
= get_jiffies_64();
3706 * @brief WILC_WFI_CfgAlloc
3707 * @details Allocation of the wireless device structure and assigning it
3708 * to the cfg80211 operations structure.
3710 * @return wireless_dev : Returns pointer to wireless_dev structure.
3715 struct wireless_dev
*WILC_WFI_CfgAlloc(void)
3718 struct wireless_dev
*wdev
;
3721 PRINT_D(CFG80211_DBG
, "Allocating wireless device\n");
3722 /*Allocating the wireless device structure*/
3723 wdev
= kzalloc(sizeof(struct wireless_dev
), GFP_KERNEL
);
3725 PRINT_ER("Cannot allocate wireless device\n");
3729 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
3730 wdev
->wiphy
= wiphy_new(&WILC_WFI_cfg80211_ops
, sizeof(struct WILC_WFI_priv
));
3732 PRINT_ER("Cannot allocate wiphy\n");
3737 #ifdef WILC_AP_EXTERNAL_MLME
3738 /* enable 802.11n HT */
3739 WILC_WFI_band_2ghz
.ht_cap
.ht_supported
= 1;
3740 WILC_WFI_band_2ghz
.ht_cap
.cap
|= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT
);
3741 WILC_WFI_band_2ghz
.ht_cap
.mcs
.rx_mask
[0] = 0xff;
3742 WILC_WFI_band_2ghz
.ht_cap
.ampdu_factor
= IEEE80211_HT_MAX_AMPDU_8K
;
3743 WILC_WFI_band_2ghz
.ht_cap
.ampdu_density
= IEEE80211_HT_MPDU_DENSITY_NONE
;
3747 wdev
->wiphy
->bands
[IEEE80211_BAND_2GHZ
] = &WILC_WFI_band_2ghz
;
3758 * @brief WILC_WFI_WiphyRegister
3759 * @details Registering of the wiphy structure and interface modes
3766 struct wireless_dev
*WILC_WFI_WiphyRegister(struct net_device
*net
)
3768 struct WILC_WFI_priv
*priv
;
3769 struct wireless_dev
*wdev
;
3770 s32 s32Error
= WILC_SUCCESS
;
3772 PRINT_D(CFG80211_DBG
, "Registering wifi device\n");
3774 wdev
= WILC_WFI_CfgAlloc();
3776 PRINT_ER("CfgAlloc Failed\n");
3781 /*Return hardware description structure (wiphy)'s priv*/
3782 priv
= wdev_priv(wdev
);
3783 sema_init(&(priv
->SemHandleUpdateStats
), 1);
3785 /*Link the wiphy with wireless structure*/
3788 /*Maximum number of probed ssid to be added by user for the scan request*/
3789 wdev
->wiphy
->max_scan_ssids
= MAX_NUM_PROBED_SSID
;
3790 /*Maximum number of pmkids to be cashed*/
3791 wdev
->wiphy
->max_num_pmkids
= WILC_MAX_NUM_PMKIDS
;
3792 PRINT_INFO(CFG80211_DBG
, "Max number of PMKIDs = %d\n", wdev
->wiphy
->max_num_pmkids
);
3794 wdev
->wiphy
->max_scan_ie_len
= 1000;
3796 /*signal strength in mBm (100*dBm) */
3797 wdev
->wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_MBM
;
3799 /*Set the availaible cipher suites*/
3800 wdev
->wiphy
->cipher_suites
= cipher_suites
;
3801 wdev
->wiphy
->n_cipher_suites
= ARRAY_SIZE(cipher_suites
);
3802 /*Setting default managment types: for register action frame: */
3803 wdev
->wiphy
->mgmt_stypes
= wilc_wfi_cfg80211_mgmt_types
;
3806 wdev
->wiphy
->max_remain_on_channel_duration
= 500;
3807 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3808 wdev
->wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) | BIT(NL80211_IFTYPE_AP
) | BIT(NL80211_IFTYPE_MONITOR
) | BIT(NL80211_IFTYPE_P2P_GO
) |
3809 BIT(NL80211_IFTYPE_P2P_CLIENT
);
3810 wdev
->wiphy
->flags
|= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
;
3812 wdev
->wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) | BIT(NL80211_IFTYPE_AP
) | BIT(NL80211_IFTYPE_MONITOR
);
3814 wdev
->iftype
= NL80211_IFTYPE_STATION
;
3818 PRINT_INFO(CFG80211_DBG
, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3819 wdev
->wiphy
->max_scan_ssids
, wdev
->wiphy
->max_scan_ie_len
, wdev
->wiphy
->signal_type
,
3820 wdev
->wiphy
->interface_modes
, wdev
->iftype
);
3823 set_wiphy_dev(wdev
->wiphy
, &local_sdio_func
->dev
); /* tony */
3826 /*Register wiphy structure*/
3827 s32Error
= wiphy_register(wdev
->wiphy
);
3829 PRINT_ER("Cannot register wiphy device\n");
3830 /*should define what action to be taken in such failure*/
3832 PRINT_D(CFG80211_DBG
, "Successful Registering\n");
3841 * @brief WILC_WFI_WiphyFree
3842 * @details Freeing allocation of the wireless device structure
3849 int WILC_WFI_InitHostInt(struct net_device
*net
)
3852 s32 s32Error
= WILC_SUCCESS
;
3854 struct WILC_WFI_priv
*priv
;
3856 PRINT_D(INIT_DBG
, "Host[%p][%p]\n", net
, net
->ieee80211_ptr
);
3857 priv
= wdev_priv(net
->ieee80211_ptr
);
3859 s32Error
= WILC_TimerCreate(&(hAgingTimer
), remove_network_from_shadow
, NULL
);
3860 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3861 s32Error
= WILC_TimerCreate(&(hDuringIpTimer
), clear_duringIP
, NULL
);
3866 PRINT_ER("Failed to creat refresh Timer\n");
3870 priv
->gbAutoRateAdjusted
= false;
3872 priv
->bInP2PlistenState
= false;
3874 sema_init(&(priv
->hSemScanReq
), 1);
3875 s32Error
= host_int_init(&priv
->hWILCWFIDrv
);
3877 PRINT_ER("Error while initializing hostinterface\n");
3883 * @brief WILC_WFI_WiphyFree
3884 * @details Freeing allocation of the wireless device structure
3891 int WILC_WFI_DeInitHostInt(struct net_device
*net
)
3893 s32 s32Error
= WILC_SUCCESS
;
3895 struct WILC_WFI_priv
*priv
;
3896 priv
= wdev_priv(net
->ieee80211_ptr
);
3898 priv
->gbAutoRateAdjusted
= false;
3900 priv
->bInP2PlistenState
= false;
3904 s32Error
= host_int_deinit(priv
->hWILCWFIDrv
);
3906 /* Clear the Shadow scan */
3907 clear_shadow_scan(priv
);
3908 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3910 PRINT_D(CORECONFIG_DBG
, "destroy during ip\n");
3911 WILC_TimerDestroy(&hDuringIpTimer
, NULL
);
3916 PRINT_ER("Error while deintializing host interface\n");
3923 * @brief WILC_WFI_WiphyFree
3924 * @details Freeing allocation of the wireless device structure
3931 void WILC_WFI_WiphyFree(struct net_device
*net
)
3934 PRINT_D(CFG80211_DBG
, "Unregistering wiphy\n");
3937 PRINT_D(INIT_DBG
, "net_device is NULL\n");
3941 if (net
->ieee80211_ptr
== NULL
) {
3942 PRINT_D(INIT_DBG
, "ieee80211_ptr is NULL\n");
3946 if (net
->ieee80211_ptr
->wiphy
== NULL
) {
3947 PRINT_D(INIT_DBG
, "wiphy is NULL\n");
3951 wiphy_unregister(net
->ieee80211_ptr
->wiphy
);
3953 PRINT_D(INIT_DBG
, "Freeing wiphy\n");
3954 wiphy_free(net
->ieee80211_ptr
->wiphy
);
3955 kfree(net
->ieee80211_ptr
);