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
)
149 WILC_TimerDestroy(&hAgingTimer
, NULL
);
150 PRINT_INFO(CORECONFIG_DBG
, "destroy aging timer\n");
152 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
153 if (astrLastScannedNtwrksShadow
[u32LastScannedNtwrksCountShadow
].pu8IEs
!= NULL
) {
154 WILC_FREE(astrLastScannedNtwrksShadow
[i
].pu8IEs
);
155 astrLastScannedNtwrksShadow
[u32LastScannedNtwrksCountShadow
].pu8IEs
= NULL
;
158 host_int_freeJoinParams(astrLastScannedNtwrksShadow
[i
].pJoinParams
);
159 astrLastScannedNtwrksShadow
[i
].pJoinParams
= NULL
;
161 u32LastScannedNtwrksCountShadow
= 0;
166 uint32_t get_rssi_avg(tstrNetworkInfo
*pstrNetworkInfo
)
170 uint8_t num_rssi
= (pstrNetworkInfo
->strRssi
.u8Full
) ? NUM_RSSI
: (pstrNetworkInfo
->strRssi
.u8Index
);
172 for (i
= 0; i
< num_rssi
; i
++)
173 rssi_v
+= pstrNetworkInfo
->strRssi
.as8RSSI
[i
];
179 void refresh_scan(void *pUserVoid
, uint8_t all
, bool bDirectScan
)
181 struct WILC_WFI_priv
*priv
;
183 struct cfg80211_bss
*bss
= NULL
;
187 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
188 wiphy
= priv
->dev
->ieee80211_ptr
->wiphy
;
190 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
191 tstrNetworkInfo
*pstrNetworkInfo
;
192 pstrNetworkInfo
= &(astrLastScannedNtwrksShadow
[i
]);
195 if ((!pstrNetworkInfo
->u8Found
) || all
) {
197 struct ieee80211_channel
*channel
;
199 if (pstrNetworkInfo
!= NULL
) {
201 s32Freq
= ieee80211_channel_to_frequency((s32
)pstrNetworkInfo
->u8channel
, IEEE80211_BAND_2GHZ
);
202 channel
= ieee80211_get_channel(wiphy
, s32Freq
);
204 rssi
= get_rssi_avg(pstrNetworkInfo
);
205 if (WILC_memcmp("DIRECT-", pstrNetworkInfo
->au8ssid
, 7) || bDirectScan
) {
206 bss
= cfg80211_inform_bss(wiphy
, channel
, CFG80211_BSS_FTYPE_UNKNOWN
, pstrNetworkInfo
->au8bssid
, pstrNetworkInfo
->u64Tsf
, pstrNetworkInfo
->u16CapInfo
,
207 pstrNetworkInfo
->u16BeaconPeriod
, (const u8
*)pstrNetworkInfo
->pu8IEs
,
208 (size_t)pstrNetworkInfo
->u16IEsLen
, (((s32
)rssi
) * 100), GFP_KERNEL
);
209 cfg80211_put_bss(wiphy
, bss
);
218 void reset_shadow_found(void *pUserVoid
)
221 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
222 astrLastScannedNtwrksShadow
[i
].u8Found
= 0;
227 void update_scan_time(void *pUserVoid
)
230 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
231 astrLastScannedNtwrksShadow
[i
].u32TimeRcvdInScan
= jiffies
;
235 void remove_network_from_shadow(void *pUserVoid
)
237 unsigned long now
= jiffies
;
241 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
242 if (time_after(now
, astrLastScannedNtwrksShadow
[i
].u32TimeRcvdInScan
+ (unsigned long)(SCAN_RESULT_EXPIRE
))) {
243 PRINT_D(CFG80211_DBG
, "Network expired in ScanShadow: %s \n", astrLastScannedNtwrksShadow
[i
].au8ssid
);
245 if (astrLastScannedNtwrksShadow
[i
].pu8IEs
!= NULL
) {
246 WILC_FREE(astrLastScannedNtwrksShadow
[i
].pu8IEs
);
247 astrLastScannedNtwrksShadow
[i
].pu8IEs
= NULL
;
250 host_int_freeJoinParams(astrLastScannedNtwrksShadow
[i
].pJoinParams
);
252 for (j
= i
; (j
< u32LastScannedNtwrksCountShadow
- 1); j
++) {
253 astrLastScannedNtwrksShadow
[j
] = astrLastScannedNtwrksShadow
[j
+ 1];
255 u32LastScannedNtwrksCountShadow
--;
259 PRINT_D(CFG80211_DBG
, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow
);
260 if (u32LastScannedNtwrksCountShadow
!= 0)
261 WILC_TimerStart(&(hAgingTimer
), AGING_TIME
, pUserVoid
, NULL
);
263 PRINT_D(CFG80211_DBG
, "No need to restart Aging timer\n");
266 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
267 void clear_duringIP(void *pUserVoid
)
269 PRINT_D(GENERIC_DBG
, "GO:IP Obtained , enable scan\n");
270 g_obtainingIP
= false;
274 int8_t is_network_in_shadow(tstrNetworkInfo
*pstrNetworkInfo
, void *pUserVoid
)
279 if (u32LastScannedNtwrksCountShadow
== 0) {
280 PRINT_D(CFG80211_DBG
, "Starting Aging timer\n");
281 WILC_TimerStart(&(hAgingTimer
), AGING_TIME
, pUserVoid
, NULL
);
284 /* Linear search for now */
285 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
286 if (WILC_memcmp(astrLastScannedNtwrksShadow
[i
].au8bssid
,
287 pstrNetworkInfo
->au8bssid
, 6) == 0) {
296 void add_network_to_shadow(tstrNetworkInfo
*pstrNetworkInfo
, void *pUserVoid
, void *pJoinParams
)
298 int8_t ap_found
= is_network_in_shadow(pstrNetworkInfo
, pUserVoid
);
299 uint32_t ap_index
= 0;
300 uint8_t rssi_index
= 0;
302 if (u32LastScannedNtwrksCountShadow
>= MAX_NUM_SCANNED_NETWORKS_SHADOW
) {
303 PRINT_D(CFG80211_DBG
, "Shadow network reached its maximum limit\n");
306 if (ap_found
== -1) {
307 ap_index
= u32LastScannedNtwrksCountShadow
;
308 u32LastScannedNtwrksCountShadow
++;
313 rssi_index
= astrLastScannedNtwrksShadow
[ap_index
].strRssi
.u8Index
;
314 astrLastScannedNtwrksShadow
[ap_index
].strRssi
.as8RSSI
[rssi_index
++] = pstrNetworkInfo
->s8rssi
;
315 if (rssi_index
== NUM_RSSI
) {
317 astrLastScannedNtwrksShadow
[ap_index
].strRssi
.u8Full
= 1;
319 astrLastScannedNtwrksShadow
[ap_index
].strRssi
.u8Index
= rssi_index
;
321 astrLastScannedNtwrksShadow
[ap_index
].s8rssi
= pstrNetworkInfo
->s8rssi
;
322 astrLastScannedNtwrksShadow
[ap_index
].u16CapInfo
= pstrNetworkInfo
->u16CapInfo
;
324 astrLastScannedNtwrksShadow
[ap_index
].u8SsidLen
= pstrNetworkInfo
->u8SsidLen
;
325 WILC_memcpy(astrLastScannedNtwrksShadow
[ap_index
].au8ssid
,
326 pstrNetworkInfo
->au8ssid
, pstrNetworkInfo
->u8SsidLen
);
328 WILC_memcpy(astrLastScannedNtwrksShadow
[ap_index
].au8bssid
,
329 pstrNetworkInfo
->au8bssid
, ETH_ALEN
);
331 astrLastScannedNtwrksShadow
[ap_index
].u16BeaconPeriod
= pstrNetworkInfo
->u16BeaconPeriod
;
332 astrLastScannedNtwrksShadow
[ap_index
].u8DtimPeriod
= pstrNetworkInfo
->u8DtimPeriod
;
333 astrLastScannedNtwrksShadow
[ap_index
].u8channel
= pstrNetworkInfo
->u8channel
;
335 astrLastScannedNtwrksShadow
[ap_index
].u16IEsLen
= pstrNetworkInfo
->u16IEsLen
;
336 astrLastScannedNtwrksShadow
[ap_index
].u64Tsf
= pstrNetworkInfo
->u64Tsf
;
338 WILC_FREE(astrLastScannedNtwrksShadow
[ap_index
].pu8IEs
);
339 astrLastScannedNtwrksShadow
[ap_index
].pu8IEs
=
340 (u8
*)WILC_MALLOC(pstrNetworkInfo
->u16IEsLen
); /* will be deallocated by the WILC_WFI_CfgScan() function */
341 WILC_memcpy(astrLastScannedNtwrksShadow
[ap_index
].pu8IEs
,
342 pstrNetworkInfo
->pu8IEs
, pstrNetworkInfo
->u16IEsLen
);
344 astrLastScannedNtwrksShadow
[ap_index
].u32TimeRcvdInScan
= jiffies
;
345 astrLastScannedNtwrksShadow
[ap_index
].u32TimeRcvdInScanCached
= jiffies
;
346 astrLastScannedNtwrksShadow
[ap_index
].u8Found
= 1;
348 host_int_freeJoinParams(astrLastScannedNtwrksShadow
[ap_index
].pJoinParams
);
349 astrLastScannedNtwrksShadow
[ap_index
].pJoinParams
= pJoinParams
;
355 * @brief CfgScanResult
356 * @details Callback function which returns the scan results found
358 * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
359 * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
360 * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
361 * void* pUserVoid: Private structure associated with the wireless interface
367 static void CfgScanResult(tenuScanEvent enuScanEvent
, tstrNetworkInfo
*pstrNetworkInfo
, void *pUserVoid
, void *pJoinParams
)
369 struct WILC_WFI_priv
*priv
;
372 struct ieee80211_channel
*channel
;
373 s32 s32Error
= WILC_SUCCESS
;
374 struct cfg80211_bss
*bss
= NULL
;
376 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
377 if (priv
->bCfgScanning
== true) {
378 if (enuScanEvent
== SCAN_EVENT_NETWORK_FOUND
) {
379 wiphy
= priv
->dev
->ieee80211_ptr
->wiphy
;
380 WILC_NULLCHECK(s32Error
, wiphy
);
381 if (wiphy
->signal_type
== CFG80211_SIGNAL_TYPE_UNSPEC
383 ((((s32
)pstrNetworkInfo
->s8rssi
) * 100) < 0
385 (((s32
)pstrNetworkInfo
->s8rssi
) * 100) > 100)
387 WILC_ERRORREPORT(s32Error
, WILC_FAIL
);
390 if (pstrNetworkInfo
!= NULL
) {
391 s32Freq
= ieee80211_channel_to_frequency((s32
)pstrNetworkInfo
->u8channel
, IEEE80211_BAND_2GHZ
);
392 channel
= ieee80211_get_channel(wiphy
, s32Freq
);
394 WILC_NULLCHECK(s32Error
, channel
);
396 PRINT_INFO(CFG80211_DBG
, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
397 "BeaconPeriod: %d \n", channel
->center_freq
, (((s32
)pstrNetworkInfo
->s8rssi
) * 100),
398 pstrNetworkInfo
->u16CapInfo
, pstrNetworkInfo
->u16BeaconPeriod
);
400 if (pstrNetworkInfo
->bNewNetwork
== true) {
401 if (priv
->u32RcvdChCount
< MAX_NUM_SCANNED_NETWORKS
) { /* TODO: mostafa: to be replaced by */
403 PRINT_D(CFG80211_DBG
, "Network %s found\n", pstrNetworkInfo
->au8ssid
);
406 priv
->u32RcvdChCount
++;
410 if (pJoinParams
== NULL
) {
411 PRINT_INFO(CORECONFIG_DBG
, ">> Something really bad happened\n");
413 add_network_to_shadow(pstrNetworkInfo
, priv
, pJoinParams
);
415 /*P2P peers are sent to WPA supplicant and added to shadow table*/
417 if (!(WILC_memcmp("DIRECT-", pstrNetworkInfo
->au8ssid
, 7))) {
418 bss
= cfg80211_inform_bss(wiphy
, channel
, CFG80211_BSS_FTYPE_UNKNOWN
, pstrNetworkInfo
->au8bssid
, pstrNetworkInfo
->u64Tsf
, pstrNetworkInfo
->u16CapInfo
,
419 pstrNetworkInfo
->u16BeaconPeriod
, (const u8
*)pstrNetworkInfo
->pu8IEs
,
420 (size_t)pstrNetworkInfo
->u16IEsLen
, (((s32
)pstrNetworkInfo
->s8rssi
) * 100), GFP_KERNEL
);
421 cfg80211_put_bss(wiphy
, bss
);
426 PRINT_ER("Discovered networks exceeded the max limit\n");
430 /* So this network is discovered before, we'll just update its RSSI */
431 for (i
= 0; i
< priv
->u32RcvdChCount
; i
++) {
432 if (WILC_memcmp(astrLastScannedNtwrksShadow
[i
].au8bssid
, pstrNetworkInfo
->au8bssid
, 6) == 0) {
433 PRINT_D(CFG80211_DBG
, "Update RSSI of %s \n", astrLastScannedNtwrksShadow
[i
].au8ssid
);
435 astrLastScannedNtwrksShadow
[i
].s8rssi
= pstrNetworkInfo
->s8rssi
;
436 astrLastScannedNtwrksShadow
[i
].u32TimeRcvdInScan
= jiffies
;
442 } else if (enuScanEvent
== SCAN_EVENT_DONE
) {
443 PRINT_D(CFG80211_DBG
, "Scan Done[%p] \n", priv
->dev
);
444 PRINT_D(CFG80211_DBG
, "Refreshing Scan ... \n");
445 refresh_scan(priv
, 1, false);
447 if (priv
->u32RcvdChCount
> 0) {
448 PRINT_D(CFG80211_DBG
, "%d Network(s) found \n", priv
->u32RcvdChCount
);
450 PRINT_D(CFG80211_DBG
, "No networks found \n");
453 down(&(priv
->hSemScanReq
));
455 if (priv
->pstrScanReq
!= NULL
) {
456 cfg80211_scan_done(priv
->pstrScanReq
, false);
457 priv
->u32RcvdChCount
= 0;
458 priv
->bCfgScanning
= false;
459 priv
->pstrScanReq
= NULL
;
461 up(&(priv
->hSemScanReq
));
464 /*Aborting any scan operation during mac close*/
465 else if (enuScanEvent
== SCAN_EVENT_ABORTED
) {
466 down(&(priv
->hSemScanReq
));
468 PRINT_D(CFG80211_DBG
, "Scan Aborted \n");
469 if (priv
->pstrScanReq
!= NULL
) {
471 update_scan_time(priv
);
472 refresh_scan(priv
, 1, false);
474 cfg80211_scan_done(priv
->pstrScanReq
, false);
475 priv
->bCfgScanning
= false;
476 priv
->pstrScanReq
= NULL
;
478 up(&(priv
->hSemScanReq
));
490 * @brief WILC_WFI_Set_PMKSA
491 * @details Check if pmksa is cached and set it.
493 * @return int : Return 0 on Success
498 int WILC_WFI_Set_PMKSA(u8
*bssid
, struct WILC_WFI_priv
*priv
)
501 s32 s32Error
= WILC_SUCCESS
;
504 for (i
= 0; i
< priv
->pmkid_list
.numpmkid
; i
++) {
506 if (!WILC_memcmp(bssid
, priv
->pmkid_list
.pmkidlist
[i
].bssid
,
508 PRINT_D(CFG80211_DBG
, "PMKID successful comparison");
510 /*If bssid is found, set the values*/
511 s32Error
= host_int_set_pmkid_info(priv
->hWILCWFIDrv
, &priv
->pmkid_list
);
513 if (s32Error
!= WILC_SUCCESS
)
514 PRINT_ER("Error in pmkid\n");
524 int linux_wlan_set_bssid(struct net_device
*wilc_netdev
, uint8_t *pBSSID
);
528 * @brief CfgConnectResult
530 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
531 * connection response or disconnection notification.
532 * tstrConnectInfo* pstrConnectInfo: COnnection information.
533 * u8 u8MacStatus: Mac Status from firmware
534 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
535 * void* pUserVoid: Private data associated with wireless interface
543 static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent
,
544 tstrConnectInfo
*pstrConnectInfo
,
546 tstrDisconnectNotifInfo
*pstrDisconnectNotifInfo
,
549 struct WILC_WFI_priv
*priv
;
550 struct net_device
*dev
;
552 tstrWILC_WFIDrv
*pstrWFIDrv
;
554 u8 NullBssid
[ETH_ALEN
] = {0};
557 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
560 pstrWFIDrv
= (tstrWILC_WFIDrv
*)priv
->hWILCWFIDrv
;
563 if (enuConnDisconnEvent
== CONN_DISCONN_EVENT_CONN_RESP
) {
565 u16 u16ConnectStatus
= WLAN_STATUS_SUCCESS
;
567 u16ConnectStatus
= pstrConnectInfo
->u16ConnectStatus
;
569 PRINT_D(CFG80211_DBG
, " Connection response received = %d\n", u8MacStatus
);
571 if ((u8MacStatus
== MAC_DISCONNECTED
) &&
572 (pstrConnectInfo
->u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
573 /* The case here is that our station was waiting for association response frame and has just received it containing status code
574 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
575 u16ConnectStatus
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
576 linux_wlan_set_bssid(priv
->dev
, NullBssid
);
577 WILC_memset(u8ConnectedSSID
, 0, ETH_ALEN
);
580 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
582 if (!pstrWFIDrv
->u8P2PConnect
)
583 u8WLANChannel
= INVALID_CHANNEL
;
586 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d \n", u16ConnectStatus
, u8MacStatus
);
589 if (u16ConnectStatus
== WLAN_STATUS_SUCCESS
) {
590 bool bNeedScanRefresh
= false;
593 PRINT_INFO(CFG80211_DBG
, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo
->au8bssid
[0],
594 pstrConnectInfo
->au8bssid
[1], pstrConnectInfo
->au8bssid
[2], pstrConnectInfo
->au8bssid
[3], pstrConnectInfo
->au8bssid
[4], pstrConnectInfo
->au8bssid
[5]);
595 WILC_memcpy(priv
->au8AssociatedBss
, pstrConnectInfo
->au8bssid
, ETH_ALEN
);
597 /* BugID_4209: if this network has expired in the scan results in the above nl80211 layer, refresh them here by calling
598 * cfg80211_inform_bss() with the last Scan results before calling cfg80211_connect_result() to avoid
599 * Linux kernel warning generated at the nl80211 layer */
601 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
602 if (WILC_memcmp(astrLastScannedNtwrksShadow
[i
].au8bssid
,
603 pstrConnectInfo
->au8bssid
, ETH_ALEN
) == 0) {
604 unsigned long now
= jiffies
;
607 astrLastScannedNtwrksShadow
[i
].u32TimeRcvdInScanCached
+ (unsigned long)(nl80211_SCAN_RESULT_EXPIRE
- (1 * HZ
)))) {
608 bNeedScanRefresh
= true;
615 if (bNeedScanRefresh
) {
617 /*Also, refrsh DIRECT- results if */
618 refresh_scan(priv
, 1, true);
625 PRINT_D(CFG80211_DBG
, "Association request info elements length = %zu\n", pstrConnectInfo
->ReqIEsLen
);
627 PRINT_D(CFG80211_DBG
, "Association response info elements length = %d\n", pstrConnectInfo
->u16RespIEsLen
);
629 cfg80211_connect_result(dev
, pstrConnectInfo
->au8bssid
,
630 pstrConnectInfo
->pu8ReqIEs
, pstrConnectInfo
->ReqIEsLen
,
631 pstrConnectInfo
->pu8RespIEs
, pstrConnectInfo
->u16RespIEsLen
,
632 u16ConnectStatus
, GFP_KERNEL
); /* TODO: mostafa: u16ConnectStatus to */
633 /* be replaced by pstrConnectInfo->u16ConnectStatus */
634 } else if (enuConnDisconnEvent
== CONN_DISCONN_EVENT_DISCONN_NOTIF
) {
635 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
636 g_obtainingIP
= false;
638 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
639 pstrDisconnectNotifInfo
->u16reason
, priv
->dev
);
640 u8P2Plocalrandom
= 0x01;
641 u8P2Precvrandom
= 0x00;
643 WILC_memset(priv
->au8AssociatedBss
, 0, ETH_ALEN
);
644 linux_wlan_set_bssid(priv
->dev
, NullBssid
);
645 WILC_memset(u8ConnectedSSID
, 0, ETH_ALEN
);
648 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
650 if (!pstrWFIDrv
->u8P2PConnect
)
651 u8WLANChannel
= INVALID_CHANNEL
;
654 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
655 * virtual interface to station*/
656 if ((pstrWFIDrv
->IFC_UP
) && (dev
== g_linux_wlan
->strInterfaceInfo
[1].wilc_netdev
)) {
657 pstrDisconnectNotifInfo
->u16reason
= 3;
660 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
661 * to scan again and retry the connection*/
662 else if ((!pstrWFIDrv
->IFC_UP
) && (dev
== g_linux_wlan
->strInterfaceInfo
[1].wilc_netdev
)) {
663 pstrDisconnectNotifInfo
->u16reason
= 1;
665 cfg80211_disconnected(dev
, pstrDisconnectNotifInfo
->u16reason
, pstrDisconnectNotifInfo
->ie
,
666 pstrDisconnectNotifInfo
->ie_len
, false,
675 * @brief WILC_WFI_CfgSetChannel
676 * @details Set channel for a given wireless interface. Some devices
677 * may support multi-channel operation (by channel hopping) so cfg80211
678 * doesn't verify much. Note, however, that the passed netdev may be
679 * %NULL as well if the user requested changing the channel for the
680 * device itself, or for a monitor interface.
682 * @return int : Return 0 on Success
687 static int WILC_WFI_CfgSetChannel(struct wiphy
*wiphy
,
688 struct cfg80211_chan_def
*chandef
)
692 struct WILC_WFI_priv
*priv
;
693 s32 s32Error
= WILC_SUCCESS
;
694 priv
= wiphy_priv(wiphy
);
696 channelnum
= ieee80211_frequency_to_channel(chandef
->chan
->center_freq
);
697 PRINT_D(CFG80211_DBG
, "Setting channel %d with frequency %d\n", channelnum
, chandef
->chan
->center_freq
);
699 u8CurrChannel
= channelnum
;
700 s32Error
= host_int_set_mac_chnl_num(priv
->hWILCWFIDrv
, channelnum
);
702 if (s32Error
!= WILC_SUCCESS
)
703 PRINT_ER("Error in setting channel %d\n", channelnum
);
709 * @brief WILC_WFI_CfgScan
710 * @details Request to do a scan. If returning zero, the scan request is given
711 * the driver, and will be valid until passed to cfg80211_scan_done().
712 * For scan results, call cfg80211_inform_bss(); you can call this outside
713 * the scan/scan_done bracket too.
715 * @return int : Return 0 on Success
722 * kernel version 3.8.8 supported
723 * tony, sswd, WILC-KR, 2013-10-29
725 static int WILC_WFI_CfgScan(struct wiphy
*wiphy
, struct cfg80211_scan_request
*request
)
727 struct WILC_WFI_priv
*priv
;
729 s32 s32Error
= WILC_SUCCESS
;
730 u8 au8ScanChanList
[MAX_NUM_SCANNED_NETWORKS
];
731 tstrHiddenNetwork strHiddenNetwork
;
733 priv
= wiphy_priv(wiphy
);
735 priv
->pstrScanReq
= request
;
737 priv
->u32RcvdChCount
= 0;
739 host_int_set_wfi_drv_handler((u32
)priv
->hWILCWFIDrv
);
742 reset_shadow_found(priv
);
744 priv
->bCfgScanning
= true;
745 if (request
->n_channels
<= MAX_NUM_SCANNED_NETWORKS
) { /* TODO: mostafa: to be replaced by */
747 for (i
= 0; i
< request
->n_channels
; i
++) {
748 au8ScanChanList
[i
] = (u8
)ieee80211_frequency_to_channel(request
->channels
[i
]->center_freq
);
749 PRINT_INFO(CFG80211_DBG
, "ScanChannel List[%d] = %d,", i
, au8ScanChanList
[i
]);
752 PRINT_D(CFG80211_DBG
, "Requested num of scan channel %d\n", request
->n_channels
);
753 PRINT_D(CFG80211_DBG
, "Scan Request IE len = %zu\n", request
->ie_len
);
755 PRINT_D(CFG80211_DBG
, "Number of SSIDs %d\n", request
->n_ssids
);
757 if (request
->n_ssids
>= 1) {
760 strHiddenNetwork
.pstrHiddenNetworkInfo
= WILC_MALLOC(request
->n_ssids
* sizeof(tstrHiddenNetwork
));
761 strHiddenNetwork
.u8ssidnum
= request
->n_ssids
;
765 for (i
= 0; i
< request
->n_ssids
; i
++) {
767 if (request
->ssids
[i
].ssid
!= NULL
&& request
->ssids
[i
].ssid_len
!= 0) {
768 strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].pu8ssid
= WILC_MALLOC(request
->ssids
[i
].ssid_len
);
769 WILC_memcpy(strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].pu8ssid
, request
->ssids
[i
].ssid
, request
->ssids
[i
].ssid_len
);
770 strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].u8ssidlen
= request
->ssids
[i
].ssid_len
;
772 PRINT_D(CFG80211_DBG
, "Received one NULL SSID \n");
773 strHiddenNetwork
.u8ssidnum
-= 1;
776 PRINT_D(CFG80211_DBG
, "Trigger Scan Request \n");
777 s32Error
= host_int_scan(priv
->hWILCWFIDrv
, USER_SCAN
, ACTIVE_SCAN
,
778 au8ScanChanList
, request
->n_channels
,
779 (const u8
*)request
->ie
, request
->ie_len
,
780 CfgScanResult
, (void *)priv
, &strHiddenNetwork
);
782 PRINT_D(CFG80211_DBG
, "Trigger Scan Request \n");
783 s32Error
= host_int_scan(priv
->hWILCWFIDrv
, USER_SCAN
, ACTIVE_SCAN
,
784 au8ScanChanList
, request
->n_channels
,
785 (const u8
*)request
->ie
, request
->ie_len
,
786 CfgScanResult
, (void *)priv
, NULL
);
790 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
794 if (s32Error
!= WILC_SUCCESS
) {
796 PRINT_WRN(CFG80211_DBG
, "Device is busy: Error(%d)\n", s32Error
);
803 * @brief WILC_WFI_CfgConnect
804 * @details Connect to the ESS with the specified parameters. When connected,
805 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
806 * If the connection fails for some reason, call cfg80211_connect_result()
807 * with the status from the AP.
809 * @return int : Return 0 on Success
814 static int WILC_WFI_CfgConnect(struct wiphy
*wiphy
, struct net_device
*dev
,
815 struct cfg80211_connect_params
*sme
)
817 s32 s32Error
= WILC_SUCCESS
;
819 u8 u8security
= NO_ENCRYPT
;
820 AUTHTYPE_T tenuAuth_type
= ANY
;
821 char *pcgroup_encrypt_val
= NULL
;
822 char *pccipher_group
= NULL
;
823 char *pcwpa_version
= NULL
;
825 struct WILC_WFI_priv
*priv
;
826 tstrWILC_WFIDrv
*pstrWFIDrv
;
827 tstrNetworkInfo
*pstrNetworkInfo
= NULL
;
831 priv
= wiphy_priv(wiphy
);
832 pstrWFIDrv
= (tstrWILC_WFIDrv
*)(priv
->hWILCWFIDrv
);
834 host_int_set_wfi_drv_handler((u32
)priv
->hWILCWFIDrv
);
836 PRINT_D(CFG80211_DBG
, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme
->ssid
, dev
, priv
->hWILCWFIDrv
);
838 if (!(WILC_strncmp(sme
->ssid
, "DIRECT-", 7))) {
839 PRINT_D(CFG80211_DBG
, "Connected to Direct network,OBSS disabled\n");
840 pstrWFIDrv
->u8P2PConnect
= 1;
842 pstrWFIDrv
->u8P2PConnect
= 0;
844 PRINT_INFO(CFG80211_DBG
, "Required SSID = %s\n , AuthType = %d \n", sme
->ssid
, sme
->auth_type
);
846 for (i
= 0; i
< u32LastScannedNtwrksCountShadow
; i
++) {
847 if ((sme
->ssid_len
== astrLastScannedNtwrksShadow
[i
].u8SsidLen
) &&
848 WILC_memcmp(astrLastScannedNtwrksShadow
[i
].au8ssid
,
850 sme
->ssid_len
) == 0) {
851 PRINT_INFO(CFG80211_DBG
, "Network with required SSID is found %s\n", sme
->ssid
);
852 if (sme
->bssid
== NULL
) {
853 /* BSSID is not passed from the user, so decision of matching
854 * is done by SSID only */
855 PRINT_INFO(CFG80211_DBG
, "BSSID is not passed from the user\n");
858 /* BSSID is also passed from the user, so decision of matching
859 * should consider also this passed BSSID */
860 if (WILC_memcmp(astrLastScannedNtwrksShadow
[i
].au8bssid
,
863 PRINT_INFO(CFG80211_DBG
, "BSSID is passed from the user and matched\n");
870 if (i
< u32LastScannedNtwrksCountShadow
) {
871 PRINT_D(CFG80211_DBG
, "Required bss is in scan results\n");
873 pstrNetworkInfo
= &(astrLastScannedNtwrksShadow
[i
]);
875 PRINT_INFO(CFG80211_DBG
, "network BSSID to be associated: %x%x%x%x%x%x\n",
876 pstrNetworkInfo
->au8bssid
[0], pstrNetworkInfo
->au8bssid
[1],
877 pstrNetworkInfo
->au8bssid
[2], pstrNetworkInfo
->au8bssid
[3],
878 pstrNetworkInfo
->au8bssid
[4], pstrNetworkInfo
->au8bssid
[5]);
881 if (u32LastScannedNtwrksCountShadow
== 0)
882 PRINT_D(CFG80211_DBG
, "No Scan results yet\n");
884 PRINT_D(CFG80211_DBG
, "Required bss not in scan results: Error(%d)\n", s32Error
);
889 priv
->WILC_WFI_wep_default
= 0;
890 WILC_memset(priv
->WILC_WFI_wep_key
, 0, sizeof(priv
->WILC_WFI_wep_key
));
891 WILC_memset(priv
->WILC_WFI_wep_key_len
, 0, sizeof(priv
->WILC_WFI_wep_key_len
));
893 PRINT_INFO(CFG80211_DBG
, "sme->crypto.wpa_versions=%x\n", sme
->crypto
.wpa_versions
);
894 PRINT_INFO(CFG80211_DBG
, "sme->crypto.cipher_group=%x\n", sme
->crypto
.cipher_group
);
896 PRINT_INFO(CFG80211_DBG
, "sme->crypto.n_ciphers_pairwise=%d\n", sme
->crypto
.n_ciphers_pairwise
);
899 for (i
= 0; i
< sme
->crypto
.n_ciphers_pairwise
; i
++)
900 PRINT_D(CORECONFIG_DBG
, "sme->crypto.ciphers_pairwise[%d]=%x\n", i
, sme
->crypto
.ciphers_pairwise
[i
]);
903 if (sme
->crypto
.cipher_group
!= NO_ENCRYPT
) {
904 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
905 * we will add to it the pairwise cipher suite(s) */
906 pcwpa_version
= "Default";
907 PRINT_D(CORECONFIG_DBG
, ">> sme->crypto.wpa_versions: %x\n", sme
->crypto
.wpa_versions
);
908 if (sme
->crypto
.cipher_group
== WLAN_CIPHER_SUITE_WEP40
) {
909 u8security
= ENCRYPT_ENABLED
| WEP
;
910 pcgroup_encrypt_val
= "WEP40";
911 pccipher_group
= "WLAN_CIPHER_SUITE_WEP40";
912 PRINT_INFO(CFG80211_DBG
, "WEP Default Key Idx = %d\n", sme
->key_idx
);
915 for (i
= 0; i
< sme
->key_len
; i
++)
916 PRINT_D(CORECONFIG_DBG
, "WEP Key Value[%d] = %d\n", i
, sme
->key
[i
]);
918 priv
->WILC_WFI_wep_default
= sme
->key_idx
;
919 priv
->WILC_WFI_wep_key_len
[sme
->key_idx
] = sme
->key_len
;
920 WILC_memcpy(priv
->WILC_WFI_wep_key
[sme
->key_idx
], sme
->key
, sme
->key_len
);
923 g_key_wep_params
.key_len
= sme
->key_len
;
924 g_key_wep_params
.key
= WILC_MALLOC(sme
->key_len
);
925 memcpy(g_key_wep_params
.key
, sme
->key
, sme
->key_len
);
926 g_key_wep_params
.key_idx
= sme
->key_idx
;
927 g_wep_keys_saved
= true;
929 host_int_set_WEPDefaultKeyID(priv
->hWILCWFIDrv
, sme
->key_idx
);
930 host_int_add_wep_key_bss_sta(priv
->hWILCWFIDrv
, sme
->key
, sme
->key_len
, sme
->key_idx
);
931 } else if (sme
->crypto
.cipher_group
== WLAN_CIPHER_SUITE_WEP104
) {
932 u8security
= ENCRYPT_ENABLED
| WEP
| WEP_EXTENDED
;
933 pcgroup_encrypt_val
= "WEP104";
934 pccipher_group
= "WLAN_CIPHER_SUITE_WEP104";
936 priv
->WILC_WFI_wep_default
= sme
->key_idx
;
937 priv
->WILC_WFI_wep_key_len
[sme
->key_idx
] = sme
->key_len
;
938 WILC_memcpy(priv
->WILC_WFI_wep_key
[sme
->key_idx
], sme
->key
, sme
->key_len
);
941 g_key_wep_params
.key_len
= sme
->key_len
;
942 g_key_wep_params
.key
= WILC_MALLOC(sme
->key_len
);
943 memcpy(g_key_wep_params
.key
, sme
->key
, sme
->key_len
);
944 g_key_wep_params
.key_idx
= sme
->key_idx
;
945 g_wep_keys_saved
= true;
947 host_int_set_WEPDefaultKeyID(priv
->hWILCWFIDrv
, sme
->key_idx
);
948 host_int_add_wep_key_bss_sta(priv
->hWILCWFIDrv
, sme
->key
, sme
->key_len
, sme
->key_idx
);
949 } else if (sme
->crypto
.wpa_versions
& NL80211_WPA_VERSION_2
) {
950 if (sme
->crypto
.cipher_group
== WLAN_CIPHER_SUITE_TKIP
) {
951 u8security
= ENCRYPT_ENABLED
| WPA2
| TKIP
;
952 pcgroup_encrypt_val
= "WPA2_TKIP";
953 pccipher_group
= "TKIP";
954 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
955 /* tenuSecurity_t = WPA2_AES; */
956 u8security
= ENCRYPT_ENABLED
| WPA2
| AES
;
957 pcgroup_encrypt_val
= "WPA2_AES";
958 pccipher_group
= "AES";
960 pcwpa_version
= "WPA_VERSION_2";
961 } else if (sme
->crypto
.wpa_versions
& NL80211_WPA_VERSION_1
) {
962 if (sme
->crypto
.cipher_group
== WLAN_CIPHER_SUITE_TKIP
) {
963 u8security
= ENCRYPT_ENABLED
| WPA
| TKIP
;
964 pcgroup_encrypt_val
= "WPA_TKIP";
965 pccipher_group
= "TKIP";
966 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
967 /* tenuSecurity_t = WPA_AES; */
968 u8security
= ENCRYPT_ENABLED
| WPA
| AES
;
969 pcgroup_encrypt_val
= "WPA_AES";
970 pccipher_group
= "AES";
973 pcwpa_version
= "WPA_VERSION_1";
976 s32Error
= -ENOTSUPP
;
977 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error
);
984 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
985 * add to it the pairwise cipher suite(s) */
986 if ((sme
->crypto
.wpa_versions
& NL80211_WPA_VERSION_1
)
987 || (sme
->crypto
.wpa_versions
& NL80211_WPA_VERSION_2
)) {
988 for (i
= 0; i
< sme
->crypto
.n_ciphers_pairwise
; i
++) {
989 if (sme
->crypto
.ciphers_pairwise
[i
] == WLAN_CIPHER_SUITE_TKIP
) {
990 u8security
= u8security
| TKIP
;
991 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
992 u8security
= u8security
| AES
;
997 PRINT_D(CFG80211_DBG
, "Adding key with cipher group = %x\n", sme
->crypto
.cipher_group
);
999 PRINT_D(CFG80211_DBG
, "Authentication Type = %d\n", sme
->auth_type
);
1000 switch (sme
->auth_type
) {
1001 case NL80211_AUTHTYPE_OPEN_SYSTEM
:
1002 PRINT_D(CFG80211_DBG
, "In OPEN SYSTEM\n");
1003 tenuAuth_type
= OPEN_SYSTEM
;
1006 case NL80211_AUTHTYPE_SHARED_KEY
:
1007 tenuAuth_type
= SHARED_KEY
;
1008 PRINT_D(CFG80211_DBG
, "In SHARED KEY\n");
1012 PRINT_D(CFG80211_DBG
, "Automatic Authentation type = %d\n", sme
->auth_type
);
1016 /* ai: key_mgmt: enterprise case */
1017 if (sme
->crypto
.n_akm_suites
) {
1018 switch (sme
->crypto
.akm_suites
[0]) {
1019 case WLAN_AKM_SUITE_8021X
:
1020 tenuAuth_type
= IEEE8021
;
1029 PRINT_INFO(CFG80211_DBG
, "Required Channel = %d\n", pstrNetworkInfo
->u8channel
);
1031 PRINT_INFO(CFG80211_DBG
, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
1032 pcgroup_encrypt_val
, pccipher_group
, pcwpa_version
);
1035 u8CurrChannel
= pstrNetworkInfo
->u8channel
;
1037 if (!pstrWFIDrv
->u8P2PConnect
) {
1038 u8WLANChannel
= pstrNetworkInfo
->u8channel
;
1041 linux_wlan_set_bssid(dev
, pstrNetworkInfo
->au8bssid
);
1043 s32Error
= host_int_set_join_req(priv
->hWILCWFIDrv
, pstrNetworkInfo
->au8bssid
, sme
->ssid
,
1044 sme
->ssid_len
, sme
->ie
, sme
->ie_len
,
1045 CfgConnectResult
, (void *)priv
, u8security
,
1046 tenuAuth_type
, pstrNetworkInfo
->u8channel
,
1047 pstrNetworkInfo
->pJoinParams
);
1048 if (s32Error
!= WILC_SUCCESS
) {
1049 PRINT_ER("host_int_set_join_req(): Error(%d) \n", s32Error
);
1061 * @brief WILC_WFI_disconnect
1062 * @details Disconnect from the BSS/ESS.
1064 * @return int : Return 0 on Success
1069 static int WILC_WFI_disconnect(struct wiphy
*wiphy
, struct net_device
*dev
, u16 reason_code
)
1071 s32 s32Error
= WILC_SUCCESS
;
1072 struct WILC_WFI_priv
*priv
;
1074 tstrWILC_WFIDrv
*pstrWFIDrv
;
1076 uint8_t NullBssid
[ETH_ALEN
] = {0};
1078 priv
= wiphy_priv(wiphy
);
1081 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
1083 pstrWFIDrv
= (tstrWILC_WFIDrv
*)priv
->hWILCWFIDrv
;
1084 if (!pstrWFIDrv
->u8P2PConnect
)
1085 u8WLANChannel
= INVALID_CHANNEL
;
1087 linux_wlan_set_bssid(priv
->dev
, NullBssid
);
1089 PRINT_D(CFG80211_DBG
, "Disconnecting with reason code(%d)\n", reason_code
);
1091 u8P2Plocalrandom
= 0x01;
1092 u8P2Precvrandom
= 0x00;
1095 pstrWFIDrv
->u64P2p_MgmtTimeout
= 0;
1098 s32Error
= host_int_disconnect(priv
->hWILCWFIDrv
, reason_code
);
1099 if (s32Error
!= WILC_SUCCESS
) {
1100 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error
);
1108 * @brief WILC_WFI_add_key
1109 * @details Add a key with the given parameters. @mac_addr will be %NULL
1110 * when adding a group key.
1111 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1112 * @return int : Return 0 on Success
1117 static int WILC_WFI_add_key(struct wiphy
*wiphy
, struct net_device
*netdev
, u8 key_index
,
1119 const u8
*mac_addr
, struct key_params
*params
)
1122 s32 s32Error
= WILC_SUCCESS
, KeyLen
= params
->key_len
;
1124 struct WILC_WFI_priv
*priv
;
1125 const u8
*pu8RxMic
= NULL
;
1126 const u8
*pu8TxMic
= NULL
;
1127 u8 u8mode
= NO_ENCRYPT
;
1128 #ifdef WILC_AP_EXTERNAL_MLME
1129 u8 u8gmode
= NO_ENCRYPT
;
1130 u8 u8pmode
= NO_ENCRYPT
;
1131 AUTHTYPE_T tenuAuth_type
= ANY
;
1134 priv
= wiphy_priv(wiphy
);
1136 PRINT_D(CFG80211_DBG
, "Adding key with cipher suite = %x\n", params
->cipher
);
1139 PRINT_D(CFG80211_DBG
, "%p %p %d\n", wiphy
, netdev
, key_index
);
1141 PRINT_D(CFG80211_DBG
, "key %x %x %x\n", params
->key
[0],
1146 switch (params
->cipher
) {
1147 case WLAN_CIPHER_SUITE_WEP40
:
1148 case WLAN_CIPHER_SUITE_WEP104
:
1149 #ifdef WILC_AP_EXTERNAL_MLME
1150 if (priv
->wdev
->iftype
== NL80211_IFTYPE_AP
) {
1152 priv
->WILC_WFI_wep_default
= key_index
;
1153 priv
->WILC_WFI_wep_key_len
[key_index
] = params
->key_len
;
1154 WILC_memcpy(priv
->WILC_WFI_wep_key
[key_index
], params
->key
, params
->key_len
);
1156 PRINT_D(CFG80211_DBG
, "Adding AP WEP Default key Idx = %d\n", key_index
);
1157 PRINT_D(CFG80211_DBG
, "Adding AP WEP Key len= %d\n", params
->key_len
);
1159 for (i
= 0; i
< params
->key_len
; i
++)
1160 PRINT_D(CFG80211_DBG
, "WEP AP key val[%d] = %x\n", i
, params
->key
[i
]);
1162 tenuAuth_type
= OPEN_SYSTEM
;
1164 if (params
->cipher
== WLAN_CIPHER_SUITE_WEP40
)
1165 u8mode
= ENCRYPT_ENABLED
| WEP
;
1167 u8mode
= ENCRYPT_ENABLED
| WEP
| WEP_EXTENDED
;
1169 host_int_add_wep_key_bss_ap(priv
->hWILCWFIDrv
, params
->key
, params
->key_len
, key_index
, u8mode
, tenuAuth_type
);
1173 if (WILC_memcmp(params
->key
, priv
->WILC_WFI_wep_key
[key_index
], params
->key_len
)) {
1174 priv
->WILC_WFI_wep_default
= key_index
;
1175 priv
->WILC_WFI_wep_key_len
[key_index
] = params
->key_len
;
1176 WILC_memcpy(priv
->WILC_WFI_wep_key
[key_index
], params
->key
, params
->key_len
);
1178 PRINT_D(CFG80211_DBG
, "Adding WEP Default key Idx = %d\n", key_index
);
1179 PRINT_D(CFG80211_DBG
, "Adding WEP Key length = %d\n", params
->key_len
);
1181 for (i
= 0; i
< params
->key_len
; i
++)
1182 PRINT_INFO(CFG80211_DBG
, "WEP key value[%d] = %d\n", i
, params
->key
[i
]);
1184 host_int_add_wep_key_bss_sta(priv
->hWILCWFIDrv
, params
->key
, params
->key_len
, key_index
);
1189 case WLAN_CIPHER_SUITE_TKIP
:
1190 case WLAN_CIPHER_SUITE_CCMP
:
1191 #ifdef WILC_AP_EXTERNAL_MLME
1192 if (priv
->wdev
->iftype
== NL80211_IFTYPE_AP
|| priv
->wdev
->iftype
== NL80211_IFTYPE_P2P_GO
) {
1194 if (priv
->wilc_gtk
[key_index
] == NULL
) {
1195 priv
->wilc_gtk
[key_index
] = (struct wilc_wfi_key
*)WILC_MALLOC(sizeof(struct wilc_wfi_key
));
1196 priv
->wilc_gtk
[key_index
]->key
= NULL
;
1197 priv
->wilc_gtk
[key_index
]->seq
= NULL
;
1200 if (priv
->wilc_ptk
[key_index
] == NULL
) {
1201 priv
->wilc_ptk
[key_index
] = (struct wilc_wfi_key
*)WILC_MALLOC(sizeof(struct wilc_wfi_key
));
1202 priv
->wilc_ptk
[key_index
]->key
= NULL
;
1203 priv
->wilc_ptk
[key_index
]->seq
= NULL
;
1210 if (params
->cipher
== WLAN_CIPHER_SUITE_TKIP
)
1211 u8gmode
= ENCRYPT_ENABLED
| WPA
| TKIP
;
1213 u8gmode
= ENCRYPT_ENABLED
| WPA2
| AES
;
1215 priv
->wilc_groupkey
= u8gmode
;
1217 if (params
->key_len
> 16 && params
->cipher
== WLAN_CIPHER_SUITE_TKIP
) {
1219 pu8TxMic
= params
->key
+ 24;
1220 pu8RxMic
= params
->key
+ 16;
1221 KeyLen
= params
->key_len
- 16;
1223 /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
1224 if (priv
->wilc_gtk
[key_index
]->key
)
1225 WILC_FREE(priv
->wilc_gtk
[key_index
]->key
);
1227 priv
->wilc_gtk
[key_index
]->key
= (u8
*)WILC_MALLOC(params
->key_len
);
1228 WILC_memcpy(priv
->wilc_gtk
[key_index
]->key
, params
->key
, params
->key_len
);
1230 /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
1231 if (priv
->wilc_gtk
[key_index
]->seq
)
1232 WILC_FREE(priv
->wilc_gtk
[key_index
]->seq
);
1234 if ((params
->seq_len
) > 0) {
1235 priv
->wilc_gtk
[key_index
]->seq
= (u8
*)WILC_MALLOC(params
->seq_len
);
1236 WILC_memcpy(priv
->wilc_gtk
[key_index
]->seq
, params
->seq
, params
->seq_len
);
1239 priv
->wilc_gtk
[key_index
]->cipher
= params
->cipher
;
1240 priv
->wilc_gtk
[key_index
]->key_len
= params
->key_len
;
1241 priv
->wilc_gtk
[key_index
]->seq_len
= params
->seq_len
;
1244 for (i
= 0; i
< params
->key_len
; i
++)
1245 PRINT_INFO(CFG80211_DBG
, "Adding group key value[%d] = %x\n", i
, params
->key
[i
]);
1246 for (i
= 0; i
< params
->seq_len
; i
++)
1247 PRINT_INFO(CFG80211_DBG
, "Adding group seq value[%d] = %x\n", i
, params
->seq
[i
]);
1251 host_int_add_rx_gtk(priv
->hWILCWFIDrv
, params
->key
, KeyLen
,
1252 key_index
, params
->seq_len
, params
->seq
, pu8RxMic
, pu8TxMic
, AP_MODE
, u8gmode
);
1255 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]);
1257 if (params
->cipher
== WLAN_CIPHER_SUITE_TKIP
)
1258 u8pmode
= ENCRYPT_ENABLED
| WPA
| TKIP
;
1260 u8pmode
= priv
->wilc_groupkey
| AES
;
1263 if (params
->key_len
> 16 && params
->cipher
== WLAN_CIPHER_SUITE_TKIP
) {
1265 pu8TxMic
= params
->key
+ 24;
1266 pu8RxMic
= params
->key
+ 16;
1267 KeyLen
= params
->key_len
- 16;
1270 if (priv
->wilc_ptk
[key_index
]->key
)
1271 WILC_FREE(priv
->wilc_ptk
[key_index
]->key
);
1273 priv
->wilc_ptk
[key_index
]->key
= (u8
*)WILC_MALLOC(params
->key_len
);
1275 if (priv
->wilc_ptk
[key_index
]->seq
)
1276 WILC_FREE(priv
->wilc_ptk
[key_index
]->seq
);
1278 if ((params
->seq_len
) > 0)
1279 priv
->wilc_ptk
[key_index
]->seq
= (u8
*)WILC_MALLOC(params
->seq_len
);
1282 for (i
= 0; i
< params
->key_len
; i
++)
1283 PRINT_INFO(CFG80211_DBG
, "Adding pairwise key value[%d] = %x\n", i
, params
->key
[i
]);
1285 for (i
= 0; i
< params
->seq_len
; i
++)
1286 PRINT_INFO(CFG80211_DBG
, "Adding group seq value[%d] = %x\n", i
, params
->seq
[i
]);
1289 WILC_memcpy(priv
->wilc_ptk
[key_index
]->key
, params
->key
, params
->key_len
);
1291 if ((params
->seq_len
) > 0)
1292 WILC_memcpy(priv
->wilc_ptk
[key_index
]->seq
, params
->seq
, params
->seq_len
);
1294 priv
->wilc_ptk
[key_index
]->cipher
= params
->cipher
;
1295 priv
->wilc_ptk
[key_index
]->key_len
= params
->key_len
;
1296 priv
->wilc_ptk
[key_index
]->seq_len
= params
->seq_len
;
1298 host_int_add_ptk(priv
->hWILCWFIDrv
, params
->key
, KeyLen
, mac_addr
,
1299 pu8RxMic
, pu8TxMic
, AP_MODE
, u8pmode
, key_index
);
1309 if (params
->key_len
> 16 && params
->cipher
== WLAN_CIPHER_SUITE_TKIP
) {
1310 /* swap the tx mic by rx mic */
1311 pu8RxMic
= params
->key
+ 24;
1312 pu8TxMic
= params
->key
+ 16;
1313 KeyLen
= params
->key_len
- 16;
1317 /*save keys only on interface 0 (wifi interface)*/
1318 if (!g_gtk_keys_saved
&& netdev
== g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
) {
1319 g_add_gtk_key_params
.key_idx
= key_index
;
1320 g_add_gtk_key_params
.pairwise
= pairwise
;
1322 g_add_gtk_key_params
.mac_addr
= NULL
;
1324 g_add_gtk_key_params
.mac_addr
= WILC_MALLOC(ETH_ALEN
);
1325 memcpy(g_add_gtk_key_params
.mac_addr
, mac_addr
, ETH_ALEN
);
1327 g_key_gtk_params
.key_len
= params
->key_len
;
1328 g_key_gtk_params
.seq_len
= params
->seq_len
;
1329 g_key_gtk_params
.key
= WILC_MALLOC(params
->key_len
);
1330 memcpy(g_key_gtk_params
.key
, params
->key
, params
->key_len
);
1331 if (params
->seq_len
> 0) {
1332 g_key_gtk_params
.seq
= WILC_MALLOC(params
->seq_len
);
1333 memcpy(g_key_gtk_params
.seq
, params
->seq
, params
->seq_len
);
1335 g_key_gtk_params
.cipher
= params
->cipher
;
1337 PRINT_D(CFG80211_DBG
, "key %x %x %x\n", g_key_gtk_params
.key
[0],
1338 g_key_gtk_params
.key
[1],
1339 g_key_gtk_params
.key
[2]);
1340 g_gtk_keys_saved
= true;
1343 host_int_add_rx_gtk(priv
->hWILCWFIDrv
, params
->key
, KeyLen
,
1344 key_index
, params
->seq_len
, params
->seq
, pu8RxMic
, pu8TxMic
, STATION_MODE
, u8mode
);
1346 if (params
->key_len
> 16 && params
->cipher
== WLAN_CIPHER_SUITE_TKIP
) {
1347 /* swap the tx mic by rx mic */
1348 pu8RxMic
= params
->key
+ 24;
1349 pu8TxMic
= params
->key
+ 16;
1350 KeyLen
= params
->key_len
- 16;
1354 /*save keys only on interface 0 (wifi interface)*/
1355 if (!g_ptk_keys_saved
&& netdev
== g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
) {
1356 g_add_ptk_key_params
.key_idx
= key_index
;
1357 g_add_ptk_key_params
.pairwise
= pairwise
;
1359 g_add_ptk_key_params
.mac_addr
= NULL
;
1361 g_add_ptk_key_params
.mac_addr
= WILC_MALLOC(ETH_ALEN
);
1362 memcpy(g_add_ptk_key_params
.mac_addr
, mac_addr
, ETH_ALEN
);
1364 g_key_ptk_params
.key_len
= params
->key_len
;
1365 g_key_ptk_params
.seq_len
= params
->seq_len
;
1366 g_key_ptk_params
.key
= WILC_MALLOC(params
->key_len
);
1367 memcpy(g_key_ptk_params
.key
, params
->key
, params
->key_len
);
1368 if (params
->seq_len
> 0) {
1369 g_key_ptk_params
.seq
= WILC_MALLOC(params
->seq_len
);
1370 memcpy(g_key_ptk_params
.seq
, params
->seq
, params
->seq_len
);
1372 g_key_ptk_params
.cipher
= params
->cipher
;
1374 PRINT_D(CFG80211_DBG
, "key %x %x %x\n", g_key_ptk_params
.key
[0],
1375 g_key_ptk_params
.key
[1],
1376 g_key_ptk_params
.key
[2]);
1377 g_ptk_keys_saved
= true;
1380 host_int_add_ptk(priv
->hWILCWFIDrv
, params
->key
, KeyLen
, mac_addr
,
1381 pu8RxMic
, pu8TxMic
, STATION_MODE
, u8mode
, key_index
);
1382 PRINT_D(CFG80211_DBG
, "Adding pairwise key\n");
1384 for (i
= 0; i
< params
->key_len
; i
++)
1385 PRINT_INFO(CFG80211_DBG
, "Adding pairwise key value[%d] = %d\n", i
, params
->key
[i
]);
1392 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error
);
1393 s32Error
= -ENOTSUPP
;
1401 * @brief WILC_WFI_del_key
1402 * @details Remove a key given the @mac_addr (%NULL for a group key)
1403 * and @key_index, return -ENOENT if the key doesn't exist.
1405 * @return int : Return 0 on Success
1410 static int WILC_WFI_del_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
1415 struct WILC_WFI_priv
*priv
;
1416 s32 s32Error
= WILC_SUCCESS
;
1418 priv
= wiphy_priv(wiphy
);
1421 /*delete saved keys, if any*/
1422 if (netdev
== g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
) {
1423 g_ptk_keys_saved
= false;
1424 g_gtk_keys_saved
= false;
1425 g_wep_keys_saved
= false;
1427 /*Delete saved WEP keys params, if any*/
1428 if (g_key_wep_params
.key
!= NULL
) {
1429 WILC_FREE(g_key_wep_params
.key
);
1430 g_key_wep_params
.key
= NULL
;
1433 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1435 #ifdef WILC_AP_EXTERNAL_MLME
1436 if ((priv
->wilc_gtk
[key_index
]) != NULL
) {
1438 if (priv
->wilc_gtk
[key_index
]->key
!= NULL
) {
1440 WILC_FREE(priv
->wilc_gtk
[key_index
]->key
);
1441 priv
->wilc_gtk
[key_index
]->key
= NULL
;
1443 if (priv
->wilc_gtk
[key_index
]->seq
) {
1445 WILC_FREE(priv
->wilc_gtk
[key_index
]->seq
);
1446 priv
->wilc_gtk
[key_index
]->seq
= NULL
;
1449 WILC_FREE(priv
->wilc_gtk
[key_index
]);
1450 priv
->wilc_gtk
[key_index
] = NULL
;
1454 if ((priv
->wilc_ptk
[key_index
]) != NULL
) {
1456 if (priv
->wilc_ptk
[key_index
]->key
) {
1458 WILC_FREE(priv
->wilc_ptk
[key_index
]->key
);
1459 priv
->wilc_ptk
[key_index
]->key
= NULL
;
1461 if (priv
->wilc_ptk
[key_index
]->seq
) {
1463 WILC_FREE(priv
->wilc_ptk
[key_index
]->seq
);
1464 priv
->wilc_ptk
[key_index
]->seq
= NULL
;
1466 WILC_FREE(priv
->wilc_ptk
[key_index
]);
1467 priv
->wilc_ptk
[key_index
] = NULL
;
1471 /*Delete saved PTK and GTK keys params, if any*/
1472 if (g_key_ptk_params
.key
!= NULL
) {
1473 WILC_FREE(g_key_ptk_params
.key
);
1474 g_key_ptk_params
.key
= NULL
;
1476 if (g_key_ptk_params
.seq
!= NULL
) {
1477 WILC_FREE(g_key_ptk_params
.seq
);
1478 g_key_ptk_params
.seq
= NULL
;
1481 if (g_key_gtk_params
.key
!= NULL
) {
1482 WILC_FREE(g_key_gtk_params
.key
);
1483 g_key_gtk_params
.key
= NULL
;
1485 if (g_key_gtk_params
.seq
!= NULL
) {
1486 WILC_FREE(g_key_gtk_params
.seq
);
1487 g_key_gtk_params
.seq
= NULL
;
1490 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
1491 Set_machw_change_vir_if(false);
1494 if (key_index
>= 0 && key_index
<= 3) {
1495 WILC_memset(priv
->WILC_WFI_wep_key
[key_index
], 0, priv
->WILC_WFI_wep_key_len
[key_index
]);
1496 priv
->WILC_WFI_wep_key_len
[key_index
] = 0;
1498 PRINT_D(CFG80211_DBG
, "Removing WEP key with index = %d\n", key_index
);
1499 host_int_remove_wep_key(priv
->hWILCWFIDrv
, key_index
);
1501 PRINT_D(CFG80211_DBG
, "Removing all installed keys\n");
1502 host_int_remove_key(priv
->hWILCWFIDrv
, mac_addr
);
1509 * @brief WILC_WFI_get_key
1510 * @details Get information about the key with the given parameters.
1511 * @mac_addr will be %NULL when requesting information for a group
1512 * key. All pointers given to the @callback function need not be valid
1513 * after it returns. This function should return an error if it is
1514 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1516 * @return int : Return 0 on Success
1521 static int WILC_WFI_get_key(struct wiphy
*wiphy
, struct net_device
*netdev
, u8 key_index
,
1523 const u8
*mac_addr
, void *cookie
, void (*callback
)(void *cookie
, struct key_params
*))
1526 s32 s32Error
= WILC_SUCCESS
;
1528 struct WILC_WFI_priv
*priv
;
1529 struct key_params key_params
;
1531 priv
= wiphy_priv(wiphy
);
1536 PRINT_D(CFG80211_DBG
, "Getting group key idx: %x\n", key_index
);
1538 key_params
.key
= priv
->wilc_gtk
[key_index
]->key
;
1539 key_params
.cipher
= priv
->wilc_gtk
[key_index
]->cipher
;
1540 key_params
.key_len
= priv
->wilc_gtk
[key_index
]->key_len
;
1541 key_params
.seq
= priv
->wilc_gtk
[key_index
]->seq
;
1542 key_params
.seq_len
= priv
->wilc_gtk
[key_index
]->seq_len
;
1544 for (i
= 0; i
< key_params
.key_len
; i
++)
1545 PRINT_INFO(CFG80211_DBG
, "Retrieved key value %x\n", key_params
.key
[i
]);
1548 PRINT_D(CFG80211_DBG
, "Getting pairwise key\n");
1550 key_params
.key
= priv
->wilc_ptk
[key_index
]->key
;
1551 key_params
.cipher
= priv
->wilc_ptk
[key_index
]->cipher
;
1552 key_params
.key_len
= priv
->wilc_ptk
[key_index
]->key_len
;
1553 key_params
.seq
= priv
->wilc_ptk
[key_index
]->seq
;
1554 key_params
.seq_len
= priv
->wilc_ptk
[key_index
]->seq_len
;
1557 callback(cookie
, &key_params
);
1559 return s32Error
; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
1563 * @brief WILC_WFI_set_default_key
1564 * @details Set the default management frame key on an interface
1566 * @return int : Return 0 on Success.
1571 static int WILC_WFI_set_default_key(struct wiphy
*wiphy
, struct net_device
*netdev
, u8 key_index
,
1572 bool unicast
, bool multicast
)
1574 s32 s32Error
= WILC_SUCCESS
;
1575 struct WILC_WFI_priv
*priv
;
1578 priv
= wiphy_priv(wiphy
);
1580 PRINT_D(CFG80211_DBG
, "Setting default key with idx = %d \n", key_index
);
1582 if (key_index
!= priv
->WILC_WFI_wep_default
) {
1584 host_int_set_WEPDefaultKeyID(priv
->hWILCWFIDrv
, key_index
);
1591 * @brief WILC_WFI_dump_survey
1592 * @details Get site survey information
1594 * @return int : Return 0 on Success.
1599 static int WILC_WFI_dump_survey(struct wiphy
*wiphy
, struct net_device
*netdev
,
1600 int idx
, struct survey_info
*info
)
1602 s32 s32Error
= WILC_SUCCESS
;
1607 PRINT_ER("Error Idx value doesn't equal zero: Error(%d)\n", s32Error
);
1616 * @brief WILC_WFI_get_station
1617 * @details Get station information for the station identified by @mac
1619 * @return int : Return 0 on Success.
1625 extern uint32_t Statisitcs_totalAcks
, Statisitcs_DroppedAcks
;
1626 static int WILC_WFI_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1627 const u8
*mac
, struct station_info
*sinfo
)
1629 s32 s32Error
= WILC_SUCCESS
;
1630 struct WILC_WFI_priv
*priv
;
1631 perInterface_wlan_t
*nic
;
1632 #ifdef WILC_AP_EXTERNAL_MLME
1634 u32 associatedsta
= 0;
1635 u32 inactive_time
= 0;
1637 priv
= wiphy_priv(wiphy
);
1638 nic
= netdev_priv(dev
);
1640 #ifdef WILC_AP_EXTERNAL_MLME
1641 if (nic
->iftype
== AP_MODE
|| nic
->iftype
== GO_MODE
) {
1642 PRINT_D(HOSTAPD_DBG
, "Getting station parameters\n");
1644 PRINT_INFO(HOSTAPD_DBG
, ": %x%x%x%x%x\n", mac
[0], mac
[1], mac
[2], mac
[3], mac
[4]);
1646 for (i
= 0; i
< NUM_STA_ASSOCIATED
; i
++) {
1648 if (!(memcmp(mac
, priv
->assoc_stainfo
.au8Sta_AssociatedBss
[i
], ETH_ALEN
))) {
1655 if (associatedsta
== -1) {
1657 PRINT_ER("Station required is not associated : Error(%d)\n", s32Error
);
1662 sinfo
->filled
|= BIT(NL80211_STA_INFO_INACTIVE_TIME
);
1664 host_int_get_inactive_time(priv
->hWILCWFIDrv
, mac
, &(inactive_time
));
1665 sinfo
->inactive_time
= 1000 * inactive_time
;
1666 PRINT_D(CFG80211_DBG
, "Inactive time %d\n", sinfo
->inactive_time
);
1671 if (nic
->iftype
== STATION_MODE
) {
1672 tstrStatistics strStatistics
;
1673 host_int_get_statistics(priv
->hWILCWFIDrv
, &strStatistics
);
1677 * tx_failed introduced more than
1678 * kernel version 3.0.0
1680 sinfo
->filled
|= BIT(NL80211_STA_INFO_SIGNAL
) |
1681 BIT( NL80211_STA_INFO_RX_PACKETS
) |
1682 BIT(NL80211_STA_INFO_TX_PACKETS
) |
1683 BIT(NL80211_STA_INFO_TX_FAILED
) |
1684 BIT(NL80211_STA_INFO_TX_BITRATE
);
1686 sinfo
->signal
= strStatistics
.s8RSSI
;
1687 sinfo
->rx_packets
= strStatistics
.u32RxCount
;
1688 sinfo
->tx_packets
= strStatistics
.u32TxCount
+ strStatistics
.u32TxFailureCount
;
1689 sinfo
->tx_failed
= strStatistics
.u32TxFailureCount
;
1690 sinfo
->txrate
.legacy
= strStatistics
.u8LinkSpeed
* 10;
1692 #ifdef TCP_ENHANCEMENTS
1693 if ((strStatistics
.u8LinkSpeed
> TCP_ACK_FILTER_LINK_SPEED_THRESH
) && (strStatistics
.u8LinkSpeed
!= DEFAULT_LINK_SPEED
)) {
1694 Enable_TCP_ACK_Filter(true);
1695 } else if (strStatistics
.u8LinkSpeed
!= DEFAULT_LINK_SPEED
) {
1696 Enable_TCP_ACK_Filter(false);
1700 PRINT_D(CORECONFIG_DBG
, "*** stats[%d][%d][%d][%d][%d]\n", sinfo
->signal
, sinfo
->rx_packets
, sinfo
->tx_packets
,
1701 sinfo
->tx_failed
, sinfo
->txrate
.legacy
);
1708 * @brief WILC_WFI_change_bss
1709 * @details Modify parameters for a given BSS.
1711 * -use_cts_prot: Whether to use CTS protection
1712 * (0 = no, 1 = yes, -1 = do not change)
1713 * -use_short_preamble: Whether the use of short preambles is allowed
1714 * (0 = no, 1 = yes, -1 = do not change)
1715 * -use_short_slot_time: Whether the use of short slot time is allowed
1716 * (0 = no, 1 = yes, -1 = do not change)
1717 * -basic_rates: basic rates in IEEE 802.11 format
1718 * (or NULL for no change)
1719 * -basic_rates_len: number of basic rates
1720 * -ap_isolate: do not forward packets between connected stations
1721 * -ht_opmode: HT Operation mode
1722 * (u16 = opmode, -1 = do not change)
1723 * @return int : Return 0 on Success.
1728 static int WILC_WFI_change_bss(struct wiphy
*wiphy
, struct net_device
*dev
,
1729 struct bss_parameters
*params
)
1731 PRINT_D(CFG80211_DBG
, "Changing Bss parametrs\n");
1736 * @brief WILC_WFI_auth
1737 * @details Request to authenticate with the specified peer
1739 * @return int : Return 0 on Success.
1744 static int WILC_WFI_auth(struct wiphy
*wiphy
, struct net_device
*dev
,
1745 struct cfg80211_auth_request
*req
)
1747 PRINT_D(CFG80211_DBG
, "In Authentication Function\n");
1752 * @brief WILC_WFI_assoc
1753 * @details Request to (re)associate with the specified peer
1755 * @return int : Return 0 on Success.
1760 static int WILC_WFI_assoc(struct wiphy
*wiphy
, struct net_device
*dev
,
1761 struct cfg80211_assoc_request
*req
)
1763 PRINT_D(CFG80211_DBG
, "In Association Function\n");
1768 * @brief WILC_WFI_deauth
1769 * @details Request to deauthenticate from the specified peer
1771 * @return int : Return 0 on Success.
1776 static int WILC_WFI_deauth(struct wiphy
*wiphy
, struct net_device
*dev
,
1777 struct cfg80211_deauth_request
*req
, void *cookie
)
1779 PRINT_D(CFG80211_DBG
, "In De-authentication Function\n");
1784 * @brief WILC_WFI_disassoc
1785 * @details Request to disassociate from the specified peer
1787 * @return int : Return 0 on Success
1792 static int WILC_WFI_disassoc(struct wiphy
*wiphy
, struct net_device
*dev
,
1793 struct cfg80211_disassoc_request
*req
, void *cookie
)
1795 PRINT_D(CFG80211_DBG
, "In Disassociation Function\n");
1800 * @brief WILC_WFI_set_wiphy_params
1801 * @details Notify that wiphy parameters have changed;
1802 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1804 * @return int : Return 0 on Success
1809 static int WILC_WFI_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
1811 s32 s32Error
= WILC_SUCCESS
;
1812 tstrCfgParamVal pstrCfgParamVal
;
1813 struct WILC_WFI_priv
*priv
;
1815 priv
= wiphy_priv(wiphy
);
1817 pstrCfgParamVal
.u32SetCfgFlag
= 0;
1818 PRINT_D(CFG80211_DBG
, "Setting Wiphy params \n");
1820 if (changed
& WIPHY_PARAM_RETRY_SHORT
) {
1821 PRINT_D(CFG80211_DBG
, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1822 priv
->dev
->ieee80211_ptr
->wiphy
->retry_short
);
1823 pstrCfgParamVal
.u32SetCfgFlag
|= RETRY_SHORT
;
1824 pstrCfgParamVal
.short_retry_limit
= priv
->dev
->ieee80211_ptr
->wiphy
->retry_short
;
1826 if (changed
& WIPHY_PARAM_RETRY_LONG
) {
1828 PRINT_D(CFG80211_DBG
, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv
->dev
->ieee80211_ptr
->wiphy
->retry_long
);
1829 pstrCfgParamVal
.u32SetCfgFlag
|= RETRY_LONG
;
1830 pstrCfgParamVal
.long_retry_limit
= priv
->dev
->ieee80211_ptr
->wiphy
->retry_long
;
1833 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
) {
1834 PRINT_D(CFG80211_DBG
, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv
->dev
->ieee80211_ptr
->wiphy
->frag_threshold
);
1835 pstrCfgParamVal
.u32SetCfgFlag
|= FRAG_THRESHOLD
;
1836 pstrCfgParamVal
.frag_threshold
= priv
->dev
->ieee80211_ptr
->wiphy
->frag_threshold
;
1840 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
1841 PRINT_D(CFG80211_DBG
, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv
->dev
->ieee80211_ptr
->wiphy
->rts_threshold
);
1843 pstrCfgParamVal
.u32SetCfgFlag
|= RTS_THRESHOLD
;
1844 pstrCfgParamVal
.rts_threshold
= priv
->dev
->ieee80211_ptr
->wiphy
->rts_threshold
;
1848 PRINT_D(CFG80211_DBG
, "Setting CFG params in the host interface\n");
1849 s32Error
= hif_set_cfg(priv
->hWILCWFIDrv
, &pstrCfgParamVal
);
1851 PRINT_ER("Error in setting WIPHY PARAMS\n");
1858 * @brief WILC_WFI_set_bitrate_mask
1859 * @details set the bitrate mask configuration
1861 * @return int : Return 0 on Success
1866 static int WILC_WFI_set_bitrate_mask(struct wiphy
*wiphy
,
1867 struct net_device
*dev
, const u8
*peer
,
1868 const struct cfg80211_bitrate_mask
*mask
)
1870 s32 s32Error
= WILC_SUCCESS
;
1872 PRINT_D(CFG80211_DBG
, "Setting Bitrate mask function\n");
1878 * @brief WILC_WFI_set_pmksa
1879 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1880 * devices running firmwares capable of generating the (re) association
1881 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1883 * @return int : Return 0 on Success
1888 static int WILC_WFI_set_pmksa(struct wiphy
*wiphy
, struct net_device
*netdev
,
1889 struct cfg80211_pmksa
*pmksa
)
1892 s32 s32Error
= WILC_SUCCESS
;
1895 struct WILC_WFI_priv
*priv
= wiphy_priv(wiphy
);
1897 PRINT_D(CFG80211_DBG
, "Setting PMKSA\n");
1900 for (i
= 0; i
< priv
->pmkid_list
.numpmkid
; i
++) {
1901 if (!WILC_memcmp(pmksa
->bssid
, priv
->pmkid_list
.pmkidlist
[i
].bssid
,
1903 /*If bssid already exists and pmkid value needs to reset*/
1905 PRINT_D(CFG80211_DBG
, "PMKID already exists\n");
1909 if (i
< WILC_MAX_NUM_PMKIDS
) {
1910 PRINT_D(CFG80211_DBG
, "Setting PMKID in private structure\n");
1911 WILC_memcpy(priv
->pmkid_list
.pmkidlist
[i
].bssid
, pmksa
->bssid
,
1913 WILC_memcpy(priv
->pmkid_list
.pmkidlist
[i
].pmkid
, pmksa
->pmkid
,
1915 if (!(flag
== PMKID_FOUND
))
1916 priv
->pmkid_list
.numpmkid
++;
1918 PRINT_ER("Invalid PMKID index\n");
1923 PRINT_D(CFG80211_DBG
, "Setting pmkid in the host interface\n");
1924 s32Error
= host_int_set_pmkid_info(priv
->hWILCWFIDrv
, &priv
->pmkid_list
);
1930 * @brief WILC_WFI_del_pmksa
1931 * @details Delete a cached PMKID.
1933 * @return int : Return 0 on Success
1938 static int WILC_WFI_del_pmksa(struct wiphy
*wiphy
, struct net_device
*netdev
,
1939 struct cfg80211_pmksa
*pmksa
)
1944 s32 s32Error
= WILC_SUCCESS
;
1946 struct WILC_WFI_priv
*priv
= wiphy_priv(wiphy
);
1948 PRINT_D(CFG80211_DBG
, "Deleting PMKSA keys\n");
1950 for (i
= 0; i
< priv
->pmkid_list
.numpmkid
; i
++) {
1951 if (!WILC_memcmp(pmksa
->bssid
, priv
->pmkid_list
.pmkidlist
[i
].bssid
,
1953 /*If bssid is found, reset the values*/
1954 PRINT_D(CFG80211_DBG
, "Reseting PMKID values\n");
1955 WILC_memset(&priv
->pmkid_list
.pmkidlist
[i
], 0, sizeof(tstrHostIFpmkid
));
1961 if (i
< priv
->pmkid_list
.numpmkid
&& priv
->pmkid_list
.numpmkid
> 0) {
1962 for (; i
< (priv
->pmkid_list
.numpmkid
- 1); i
++) {
1963 WILC_memcpy(priv
->pmkid_list
.pmkidlist
[i
].bssid
,
1964 priv
->pmkid_list
.pmkidlist
[i
+ 1].bssid
,
1966 WILC_memcpy(priv
->pmkid_list
.pmkidlist
[i
].pmkid
,
1967 priv
->pmkid_list
.pmkidlist
[i
].pmkid
,
1970 priv
->pmkid_list
.numpmkid
--;
1979 * @brief WILC_WFI_flush_pmksa
1980 * @details Flush all cached PMKIDs.
1982 * @return int : Return 0 on Success
1987 static int WILC_WFI_flush_pmksa(struct wiphy
*wiphy
, struct net_device
*netdev
)
1989 struct WILC_WFI_priv
*priv
= wiphy_priv(wiphy
);
1991 PRINT_D(CFG80211_DBG
, "Flushing PMKID key values\n");
1993 /*Get cashed Pmkids and set all with zeros*/
1994 WILC_memset(&priv
->pmkid_list
, 0, sizeof(tstrHostIFpmkidAttr
));
2002 * @brief WILC_WFI_CfgParseRxAction
2003 * @details Function parses the received frames and modifies the following attributes:
2006 * -Operating Channel
2008 * @param[in] u8* Buffer, u32 length
2015 void WILC_WFI_CfgParseRxAction(u8
*buf
, u32 len
)
2021 #ifdef USE_SUPPLICANT_GO_INTENT
2024 bool is_wilc_go
= true;
2026 u8 op_channel_attr_index
= 0;
2027 u8 channel_list_attr_index
= 0;
2029 while (index
< len
) {
2030 if (buf
[index
] == GO_INTENT_ATTR_ID
) {
2031 #ifdef USE_SUPPLICANT_GO_INTENT
2033 /*Case 1: If we are going to be p2p client, no need to modify channels attributes*/
2034 /*In negotiation frames, go intent attr value determines who will be GO*/
2035 intent
= GET_GO_INTENT(buf
[index
+ 3]);
2036 tie_breaker
= GET_TIE_BREAKER(buf
[index
+ 3]);
2037 if (intent
> SUPPLICANT_GO_INTENT
2038 || (intent
== SUPPLICANT_GO_INTENT
&& tie_breaker
== 1)) {
2039 PRINT_D(GENERIC_DBG
, "WILC will be client (intent %d tie breaker %d)\n", intent
, tie_breaker
);
2042 PRINT_D(GENERIC_DBG
, "WILC will be GO (intent %d tie breaker %d)\n", intent
, tie_breaker
);
2046 #else /* USE_SUPPLICANT_GO_INTENT */
2047 #ifdef FORCE_P2P_CLIENT
2048 buf
[index
+ 3] = (buf
[index
+ 3] & 0x01) | (0x0f << 1);
2050 buf
[index
+ 3] = (buf
[index
+ 3] & 0x01) | (0x00 << 1);
2052 #endif /* USE_SUPPLICANT_GO_INTENT */
2055 #ifdef USE_SUPPLICANT_GO_INTENT
2056 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2057 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2058 if (buf
[index
] == GROUP_BSSID_ATTR_ID
) {
2059 PRINT_D(GENERIC_DBG
, "Group BSSID: %2x:%2x:%2x\n", buf
[index
+ 3]
2064 #endif /* USE_SUPPLICANT_GO_INTENT */
2066 if (buf
[index
] == CHANLIST_ATTR_ID
) {
2067 channel_list_attr_index
= index
;
2068 } else if (buf
[index
] == OPERCHAN_ATTR_ID
) {
2069 op_channel_attr_index
= index
;
2071 index
+= buf
[index
+ 1] + 3; /* ID,Length byte */
2074 #ifdef USE_SUPPLICANT_GO_INTENT
2075 if (u8WLANChannel
!= INVALID_CHANNEL
&& is_wilc_go
)
2077 if (u8WLANChannel
!= INVALID_CHANNEL
)
2080 /*Modify channel list attribute*/
2081 if (channel_list_attr_index
) {
2082 PRINT_D(GENERIC_DBG
, "Modify channel list attribute\n");
2083 for (i
= channel_list_attr_index
+ 3; i
< ((channel_list_attr_index
+ 3) + buf
[channel_list_attr_index
+ 1]); i
++) {
2084 if (buf
[i
] == 0x51) {
2085 for (j
= i
+ 2; j
< ((i
+ 2) + buf
[i
+ 1]); j
++) {
2086 buf
[j
] = u8WLANChannel
;
2092 /*Modify operating channel attribute*/
2093 if (op_channel_attr_index
) {
2094 PRINT_D(GENERIC_DBG
, "Modify operating channel attribute\n");
2095 buf
[op_channel_attr_index
+ 6] = 0x51;
2096 buf
[op_channel_attr_index
+ 7] = u8WLANChannel
;
2102 * @brief WILC_WFI_CfgParseTxAction
2103 * @details Function parses the transmitted action frames and modifies the
2104 * GO Intent attribute
2105 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
2111 void WILC_WFI_CfgParseTxAction(u8
*buf
, u32 len
, bool bOperChan
, u8 iftype
)
2116 u8 op_channel_attr_index
= 0;
2117 u8 channel_list_attr_index
= 0;
2118 #ifdef USE_SUPPLICANT_GO_INTENT
2119 bool is_wilc_go
= false;
2122 /*Case 1: If we are already p2p client, no need to modify channels attributes*/
2123 /*This to handle the case of inviting a p2p peer to join an existing group which we are a member in*/
2124 if (iftype
== CLIENT_MODE
)
2128 while (index
< len
) {
2129 #ifdef USE_SUPPLICANT_GO_INTENT
2130 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2131 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2132 /*Note: If we are already p2p client, group bssid attr may also be present (handled in Case 1)*/
2133 if (buf
[index
] == GROUP_BSSID_ATTR_ID
) {
2134 PRINT_D(GENERIC_DBG
, "Group BSSID: %2x:%2x:%2x\n", buf
[index
+ 3]
2140 #else /* USE_SUPPLICANT_GO_INTENT */
2141 if (buf
[index
] == GO_INTENT_ATTR_ID
) {
2142 #ifdef FORCE_P2P_CLIENT
2143 buf
[index
+ 3] = (buf
[index
+ 3] & 0x01) | (0x00 << 1);
2145 buf
[index
+ 3] = (buf
[index
+ 3] & 0x01) | (0x0f << 1);
2152 if (buf
[index
] == CHANLIST_ATTR_ID
) {
2153 channel_list_attr_index
= index
;
2154 } else if (buf
[index
] == OPERCHAN_ATTR_ID
) {
2155 op_channel_attr_index
= index
;
2157 index
+= buf
[index
+ 1] + 3; /* ID,Length byte */
2160 #ifdef USE_SUPPLICANT_GO_INTENT
2161 /*No need to check bOperChan since only transmitted invitation frames are parsed*/
2162 if (u8WLANChannel
!= INVALID_CHANNEL
&& is_wilc_go
)
2164 if (u8WLANChannel
!= INVALID_CHANNEL
&& bOperChan
)
2167 /*Modify channel list attribute*/
2168 if (channel_list_attr_index
) {
2169 PRINT_D(GENERIC_DBG
, "Modify channel list attribute\n");
2170 for (i
= channel_list_attr_index
+ 3; i
< ((channel_list_attr_index
+ 3) + buf
[channel_list_attr_index
+ 1]); i
++) {
2171 if (buf
[i
] == 0x51) {
2172 for (j
= i
+ 2; j
< ((i
+ 2) + buf
[i
+ 1]); j
++) {
2173 buf
[j
] = u8WLANChannel
;
2179 /*Modify operating channel attribute*/
2180 if (op_channel_attr_index
) {
2181 PRINT_D(GENERIC_DBG
, "Modify operating channel attribute\n");
2182 buf
[op_channel_attr_index
+ 6] = 0x51;
2183 buf
[op_channel_attr_index
+ 7] = u8WLANChannel
;
2188 /* @brief WILC_WFI_p2p_rx
2193 * @author Mai Daftedar
2198 void WILC_WFI_p2p_rx (struct net_device
*dev
, uint8_t *buff
, uint32_t size
)
2201 struct WILC_WFI_priv
*priv
;
2202 u32 header
, pkt_offset
;
2203 tstrWILC_WFIDrv
*pstrWFIDrv
;
2206 priv
= wiphy_priv(dev
->ieee80211_ptr
->wiphy
);
2207 pstrWFIDrv
= (tstrWILC_WFIDrv
*)priv
->hWILCWFIDrv
;
2209 /* Get WILC header */
2210 WILC_memcpy(&header
, (buff
- HOST_HDR_OFFSET
), HOST_HDR_OFFSET
);
2212 /* The packet offset field conain info about what type of managment frame */
2213 /* we are dealing with and ack status */
2214 pkt_offset
= GET_PKT_OFFSET(header
);
2216 if (pkt_offset
& IS_MANAGMEMENT_CALLBACK
) {
2217 if (buff
[FRAME_TYPE_ID
] == IEEE80211_STYPE_PROBE_RESP
) {
2218 PRINT_D(GENERIC_DBG
, "Probe response ACK\n");
2219 cfg80211_mgmt_tx_status(priv
->wdev
, priv
->u64tx_cookie
, buff
, size
, true, GFP_KERNEL
);
2222 if (pkt_offset
& IS_MGMT_STATUS_SUCCES
) {
2223 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
],
2224 buff
[ACTION_SUBTYPE_ID
+ 1], buff
[P2P_PUB_ACTION_SUBTYPE
+ 1]);
2225 cfg80211_mgmt_tx_status(priv
->wdev
, priv
->u64tx_cookie
, buff
, size
, true, GFP_KERNEL
);
2227 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
],
2228 buff
[ACTION_SUBTYPE_ID
+ 1], buff
[P2P_PUB_ACTION_SUBTYPE
+ 1]);
2229 cfg80211_mgmt_tx_status(priv
->wdev
, priv
->u64tx_cookie
, buff
, size
, false, GFP_KERNEL
);
2235 PRINT_D(GENERIC_DBG
, "Rx Frame Type:%x\n", buff
[FRAME_TYPE_ID
]);
2238 /*Upper layer is informed that the frame is received on this freq*/
2239 s32Freq
= ieee80211_channel_to_frequency(u8CurrChannel
, IEEE80211_BAND_2GHZ
);
2241 if (ieee80211_is_action(buff
[FRAME_TYPE_ID
])) {
2242 PRINT_D(GENERIC_DBG
, "Rx Action Frame Type: %x %x\n", buff
[ACTION_SUBTYPE_ID
], buff
[P2P_PUB_ACTION_SUBTYPE
]);
2244 if (priv
->bCfgScanning
== true && time_after_eq(jiffies
, (unsigned long)pstrWFIDrv
->u64P2p_MgmtTimeout
)) {
2245 PRINT_D(GENERIC_DBG
, "Receiving action frames from wrong channels\n");
2248 if (buff
[ACTION_CAT_ID
] == PUB_ACTION_ATTR_ID
) {
2250 switch (buff
[ACTION_SUBTYPE_ID
]) {
2251 case GAS_INTIAL_REQ
:
2252 PRINT_D(GENERIC_DBG
, "GAS INITIAL REQ %x\n", buff
[ACTION_SUBTYPE_ID
]);
2255 case GAS_INTIAL_RSP
:
2256 PRINT_D(GENERIC_DBG
, "GAS INITIAL RSP %x\n", buff
[ACTION_SUBTYPE_ID
]);
2259 case PUBLIC_ACT_VENDORSPEC
:
2260 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2261 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
2262 if (!WILC_memcmp(u8P2P_oui
, &buff
[ACTION_SUBTYPE_ID
+ 1], 4)) {
2263 if ((buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_REQ
|| buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_RSP
)) {
2265 for (i
= P2P_PUB_ACTION_SUBTYPE
; i
< size
; i
++) {
2266 if (!WILC_memcmp(u8P2P_vendorspec
, &buff
[i
], 6)) {
2267 u8P2Precvrandom
= buff
[i
+ 6];
2269 PRINT_D(GENERIC_DBG
, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom
);
2275 if (u8P2Plocalrandom
> u8P2Precvrandom
) {
2276 if ((buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_REQ
|| buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_RSP
2277 || buff
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_REQ
|| buff
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_RSP
)) {
2278 for (i
= P2P_PUB_ACTION_SUBTYPE
+ 2; i
< size
; i
++) {
2279 if (buff
[i
] == P2PELEM_ATTR_ID
&& !(WILC_memcmp(u8P2P_oui
, &buff
[i
+ 2], 4))) {
2280 WILC_WFI_CfgParseRxAction(&buff
[i
+ 6], size
- (i
+ 6));
2286 PRINT_D(GENERIC_DBG
, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom
, u8P2Precvrandom
);
2290 if ((buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_REQ
|| buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_RSP
) && (bWilc_ie
)) {
2291 PRINT_D(GENERIC_DBG
, "Sending P2P to host without extra elemnt\n");
2292 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
2293 cfg80211_rx_mgmt(priv
->wdev
, s32Freq
, 0, buff
, size
- 7, 0);
2299 PRINT_D(GENERIC_DBG
, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff
[ACTION_SUBTYPE_ID
]);
2305 cfg80211_rx_mgmt(priv
->wdev
, s32Freq
, 0, buff
, size
- 7, 0);
2310 * @brief WILC_WFI_mgmt_tx_complete
2311 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2313 * transmitting status
2315 * @author Amr Abdelmoghny
2319 static void WILC_WFI_mgmt_tx_complete(void *priv
, int status
)
2321 struct p2p_mgmt_data
*pv_data
= (struct p2p_mgmt_data
*)priv
;
2324 kfree(pv_data
->buff
);
2329 * @brief WILC_WFI_RemainOnChannelReady
2330 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2333 * @author Amr abdelmoghny
2338 static void WILC_WFI_RemainOnChannelReady(void *pUserVoid
)
2340 struct WILC_WFI_priv
*priv
;
2341 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
2343 PRINT_D(HOSTINF_DBG
, "Remain on channel ready \n");
2345 priv
->bInP2PlistenState
= true;
2347 cfg80211_ready_on_channel(priv
->wdev
,
2348 priv
->strRemainOnChanParams
.u64ListenCookie
,
2349 priv
->strRemainOnChanParams
.pstrListenChan
,
2350 priv
->strRemainOnChanParams
.u32ListenDuration
,
2355 * @brief WILC_WFI_RemainOnChannelExpired
2356 * @details Callback function, called on expiration of remain-on-channel duration
2359 * @author Amr abdelmoghny
2364 static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid
, u32 u32SessionID
)
2366 struct WILC_WFI_priv
*priv
;
2367 priv
= (struct WILC_WFI_priv
*)pUserVoid
;
2370 if (u32SessionID
== priv
->strRemainOnChanParams
.u32ListenSessionID
) {
2371 PRINT_D(GENERIC_DBG
, "Remain on channel expired \n");
2373 priv
->bInP2PlistenState
= false;
2375 /*Inform wpas of remain-on-channel expiration*/
2376 cfg80211_remain_on_channel_expired(priv
->wdev
,
2377 priv
->strRemainOnChanParams
.u64ListenCookie
,
2378 priv
->strRemainOnChanParams
.pstrListenChan
,
2381 PRINT_D(GENERIC_DBG
, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2382 , priv
->strRemainOnChanParams
.u32ListenSessionID
);
2388 * @brief WILC_WFI_remain_on_channel
2389 * @details Request the driver to remain awake on the specified
2390 * channel for the specified duration to complete an off-channel
2391 * operation (e.g., public action frame exchange). When the driver is
2392 * ready on the requested channel, it must indicate this with an event
2393 * notification by calling cfg80211_ready_on_channel().
2395 * @return int : Return 0 on Success
2400 static int WILC_WFI_remain_on_channel(struct wiphy
*wiphy
,
2401 struct wireless_dev
*wdev
,
2402 struct ieee80211_channel
*chan
,
2403 unsigned int duration
, u64
*cookie
)
2405 s32 s32Error
= WILC_SUCCESS
;
2406 struct WILC_WFI_priv
*priv
;
2407 priv
= wiphy_priv(wiphy
);
2409 PRINT_D(GENERIC_DBG
, "Remaining on channel %d\n", chan
->hw_value
);
2411 /*BugID_4800: if in AP mode, return.*/
2412 /*This check is to handle the situation when user*/
2413 /*requests "create group" during a running scan*/
2415 if (wdev
->iftype
== NL80211_IFTYPE_AP
) {
2416 PRINT_D(GENERIC_DBG
, "Required remain-on-channel while in AP mode");
2420 u8CurrChannel
= chan
->hw_value
;
2422 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2423 priv
->strRemainOnChanParams
.pstrListenChan
= chan
;
2424 priv
->strRemainOnChanParams
.u64ListenCookie
= *cookie
;
2425 priv
->strRemainOnChanParams
.u32ListenDuration
= duration
;
2426 priv
->strRemainOnChanParams
.u32ListenSessionID
++;
2428 s32Error
= host_int_remain_on_channel(priv
->hWILCWFIDrv
2429 , priv
->strRemainOnChanParams
.u32ListenSessionID
2432 , WILC_WFI_RemainOnChannelExpired
2433 , WILC_WFI_RemainOnChannelReady
2440 * @brief WILC_WFI_cancel_remain_on_channel
2441 * @details Cancel an on-going remain-on-channel operation.
2442 * This allows the operation to be terminated prior to timeout based on
2443 * the duration value.
2444 * @param[in] struct wiphy *wiphy,
2445 * @param[in] struct net_device *dev
2446 * @param[in] u64 cookie,
2447 * @return int : Return 0 on Success
2452 static int WILC_WFI_cancel_remain_on_channel(struct wiphy
*wiphy
,
2453 struct wireless_dev
*wdev
,
2456 s32 s32Error
= WILC_SUCCESS
;
2457 struct WILC_WFI_priv
*priv
;
2458 priv
= wiphy_priv(wiphy
);
2460 PRINT_D(CFG80211_DBG
, "Cancel remain on channel\n");
2462 s32Error
= host_int_ListenStateExpired(priv
->hWILCWFIDrv
, priv
->strRemainOnChanParams
.u32ListenSessionID
);
2466 * @brief WILC_WFI_add_wilcvendorspec
2467 * @details Adding WILC information elemet to allow two WILC devices to
2468 * identify each other and connect
2469 * @param[in] u8 * buf
2475 void WILC_WFI_add_wilcvendorspec(u8
*buff
)
2477 WILC_memcpy(buff
, u8P2P_vendorspec
, sizeof(u8P2P_vendorspec
));
2480 * @brief WILC_WFI_mgmt_tx_frame
2489 extern linux_wlan_t
*g_linux_wlan
;
2490 extern bool bEnablePS
;
2491 int WILC_WFI_mgmt_tx(struct wiphy
*wiphy
,
2492 struct wireless_dev
*wdev
,
2493 struct cfg80211_mgmt_tx_params
*params
,
2496 struct ieee80211_channel
*chan
= params
->chan
;
2497 unsigned int wait
= params
->wait
;
2498 const u8
*buf
= params
->buf
;
2499 size_t len
= params
->len
;
2500 const struct ieee80211_mgmt
*mgmt
;
2501 struct p2p_mgmt_data
*mgmt_tx
;
2502 struct WILC_WFI_priv
*priv
;
2503 s32 s32Error
= WILC_SUCCESS
;
2504 tstrWILC_WFIDrv
*pstrWFIDrv
;
2506 perInterface_wlan_t
*nic
;
2507 u32 buf_len
= len
+ sizeof(u8P2P_vendorspec
) + sizeof(u8P2Plocalrandom
);
2509 nic
= netdev_priv(wdev
->netdev
);
2510 priv
= wiphy_priv(wiphy
);
2511 pstrWFIDrv
= (tstrWILC_WFIDrv
*)priv
->hWILCWFIDrv
;
2513 *cookie
= (unsigned long)buf
;
2514 priv
->u64tx_cookie
= *cookie
;
2515 mgmt
= (const struct ieee80211_mgmt
*) buf
;
2517 if (ieee80211_is_mgmt(mgmt
->frame_control
)) {
2519 /*mgmt frame allocation*/
2520 mgmt_tx
= (struct p2p_mgmt_data
*)WILC_MALLOC(sizeof(struct p2p_mgmt_data
));
2521 if (mgmt_tx
== NULL
) {
2522 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
2525 mgmt_tx
->buff
= (char *)WILC_MALLOC(buf_len
);
2526 if (mgmt_tx
->buff
== NULL
) {
2527 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
2530 WILC_memcpy(mgmt_tx
->buff
, buf
, len
);
2531 mgmt_tx
->size
= len
;
2534 if (ieee80211_is_probe_resp(mgmt
->frame_control
)) {
2535 PRINT_D(GENERIC_DBG
, "TX: Probe Response\n");
2536 PRINT_D(GENERIC_DBG
, "Setting channel: %d\n", chan
->hw_value
);
2537 host_int_set_mac_chnl_num(priv
->hWILCWFIDrv
, chan
->hw_value
);
2538 /*Save the current channel after we tune to it*/
2539 u8CurrChannel
= chan
->hw_value
;
2540 } else if (ieee80211_is_action(mgmt
->frame_control
)) {
2541 PRINT_D(GENERIC_DBG
, "ACTION FRAME:%x\n", (u16
)mgmt
->frame_control
);
2545 if (buf
[ACTION_CAT_ID
] == PUB_ACTION_ATTR_ID
) {
2547 /*Only set the channel, if not a negotiation confirmation frame
2548 * (If Negotiation confirmation frame, force it
2549 * to be transmitted on the same negotiation channel)*/
2551 if (buf
[ACTION_SUBTYPE_ID
] != PUBLIC_ACT_VENDORSPEC
||
2552 buf
[P2P_PUB_ACTION_SUBTYPE
] != GO_NEG_CONF
) {
2553 PRINT_D(GENERIC_DBG
, "Setting channel: %d\n", chan
->hw_value
);
2554 host_int_set_mac_chnl_num(priv
->hWILCWFIDrv
, chan
->hw_value
);
2555 /*Save the current channel after we tune to it*/
2556 u8CurrChannel
= chan
->hw_value
;
2558 switch (buf
[ACTION_SUBTYPE_ID
]) {
2559 case GAS_INTIAL_REQ
:
2561 PRINT_D(GENERIC_DBG
, "GAS INITIAL REQ %x\n", buf
[ACTION_SUBTYPE_ID
]);
2565 case GAS_INTIAL_RSP
:
2567 PRINT_D(GENERIC_DBG
, "GAS INITIAL RSP %x\n", buf
[ACTION_SUBTYPE_ID
]);
2571 case PUBLIC_ACT_VENDORSPEC
:
2573 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2574 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
2575 if (!WILC_memcmp(u8P2P_oui
, &buf
[ACTION_SUBTYPE_ID
+ 1], 4)) {
2576 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2577 if ((buf
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_REQ
|| buf
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_RSP
)) {
2578 if (u8P2Plocalrandom
== 1 && u8P2Precvrandom
< u8P2Plocalrandom
) {
2579 get_random_bytes(&u8P2Plocalrandom
, 1);
2580 /*Increment the number to prevent if its 0*/
2585 if ((buf
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_REQ
|| buf
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_RSP
2586 || buf
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_REQ
|| buf
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_RSP
)) {
2587 if (u8P2Plocalrandom
> u8P2Precvrandom
) {
2588 PRINT_D(GENERIC_DBG
, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom
, u8P2Precvrandom
);
2590 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2591 for (i
= P2P_PUB_ACTION_SUBTYPE
+ 2; i
< len
; i
++) {
2592 if (buf
[i
] == P2PELEM_ATTR_ID
&& !(WILC_memcmp(u8P2P_oui
, &buf
[i
+ 2], 4))) {
2593 if (buf
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_REQ
|| buf
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_RSP
)
2594 WILC_WFI_CfgParseTxAction(&mgmt_tx
->buff
[i
+ 6], len
- (i
+ 6), true, nic
->iftype
);
2597 /*If using supplicant go intent, no need at all*/
2598 /*to parse transmitted negotiation frames*/
2599 #ifndef USE_SUPPLICANT_GO_INTENT
2601 WILC_WFI_CfgParseTxAction(&mgmt_tx
->buff
[i
+ 6], len
- (i
+ 6), false, nic
->iftype
);
2607 if (buf
[P2P_PUB_ACTION_SUBTYPE
] != P2P_INV_REQ
&& buf
[P2P_PUB_ACTION_SUBTYPE
] != P2P_INV_RSP
) {
2608 WILC_WFI_add_wilcvendorspec(&mgmt_tx
->buff
[len
]);
2609 mgmt_tx
->buff
[len
+ sizeof(u8P2P_vendorspec
)] = u8P2Plocalrandom
;
2610 mgmt_tx
->size
= buf_len
;
2613 PRINT_D(GENERIC_DBG
, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom
, u8P2Precvrandom
);
2617 PRINT_D(GENERIC_DBG
, "Not a P2P public action frame\n");
2625 PRINT_D(GENERIC_DBG
, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf
[ACTION_SUBTYPE_ID
]);
2632 PRINT_D(GENERIC_DBG
, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf
[ACTION_SUBTYPE_ID
], chan
->hw_value
);
2633 pstrWFIDrv
->u64P2p_MgmtTimeout
= (jiffies
+ msecs_to_jiffies(wait
));
2635 PRINT_D(GENERIC_DBG
, "Current Jiffies: %lu Timeout:%llu\n", jiffies
, pstrWFIDrv
->u64P2p_MgmtTimeout
);
2639 g_linux_wlan
->oup
.wlan_add_mgmt_to_tx_que(mgmt_tx
, mgmt_tx
->buff
, mgmt_tx
->size
, WILC_WFI_mgmt_tx_complete
);
2641 PRINT_D(GENERIC_DBG
, "This function transmits only management frames\n");
2646 int WILC_WFI_mgmt_tx_cancel_wait(struct wiphy
*wiphy
,
2647 struct wireless_dev
*wdev
,
2650 struct WILC_WFI_priv
*priv
;
2651 tstrWILC_WFIDrv
*pstrWFIDrv
;
2652 priv
= wiphy_priv(wiphy
);
2653 pstrWFIDrv
= (tstrWILC_WFIDrv
*)priv
->hWILCWFIDrv
;
2656 PRINT_D(GENERIC_DBG
, "Tx Cancel wait :%lu\n", jiffies
);
2657 pstrWFIDrv
->u64P2p_MgmtTimeout
= jiffies
;
2659 if (priv
->bInP2PlistenState
== false) {
2660 /* Bug 5504: This is just to avoid connection failure when getting stuck when the supplicant
2661 * considers the driver falsely that it is in Listen state */
2662 cfg80211_remain_on_channel_expired(priv
->wdev
,
2663 priv
->strRemainOnChanParams
.u64ListenCookie
,
2664 priv
->strRemainOnChanParams
.pstrListenChan
,
2672 * @brief WILC_WFI_frame_register
2673 * @details Notify driver that a management frame type was
2674 * registered. Note that this callback may not sleep, and cannot run
2675 * concurrently with itself.
2682 void WILC_WFI_frame_register(struct wiphy
*wiphy
,
2683 struct wireless_dev
*wdev
,
2684 u16 frame_type
, bool reg
)
2687 struct WILC_WFI_priv
*priv
;
2688 perInterface_wlan_t
*nic
;
2691 priv
= wiphy_priv(wiphy
);
2692 nic
= netdev_priv(priv
->wdev
->netdev
);
2700 PRINT_D(GENERIC_DBG
, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type
, reg
);
2701 switch (frame_type
) {
2704 nic
->g_struct_frame_reg
[0].frame_type
= frame_type
;
2705 nic
->g_struct_frame_reg
[0].reg
= reg
;
2711 nic
->g_struct_frame_reg
[1].frame_type
= frame_type
;
2712 nic
->g_struct_frame_reg
[1].reg
= reg
;
2722 /*If mac is closed, then return*/
2723 if (!g_linux_wlan
->wilc1000_initialized
) {
2724 PRINT_D(GENERIC_DBG
, "Return since mac is closed\n");
2727 host_int_frame_register(priv
->hWILCWFIDrv
, frame_type
, reg
);
2734 * @brief WILC_WFI_set_cqm_rssi_config
2735 * @details Configure connection quality monitor RSSI threshold.
2736 * @param[in] struct wiphy *wiphy:
2737 * @param[in] struct net_device *dev:
2738 * @param[in] s32 rssi_thold:
2739 * @param[in] u32 rssi_hyst:
2740 * @return int : Return 0 on Success
2745 static int WILC_WFI_set_cqm_rssi_config(struct wiphy
*wiphy
,
2746 struct net_device
*dev
, s32 rssi_thold
, u32 rssi_hyst
)
2748 PRINT_D(CFG80211_DBG
, "Setting CQM RSSi Function\n");
2753 * @brief WILC_WFI_dump_station
2754 * @details Configure connection quality monitor RSSI threshold.
2755 * @param[in] struct wiphy *wiphy:
2756 * @param[in] struct net_device *dev
2757 * @param[in] int idx
2758 * @param[in] u8 *mac
2759 * @param[in] struct station_info *sinfo
2760 * @return int : Return 0 on Success
2765 static int WILC_WFI_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
2766 int idx
, u8
*mac
, struct station_info
*sinfo
)
2768 struct WILC_WFI_priv
*priv
;
2769 PRINT_D(CFG80211_DBG
, "Dumping station information\n");
2774 priv
= wiphy_priv(wiphy
);
2776 sinfo
->filled
|= BIT(NL80211_STA_INFO_SIGNAL
);
2778 host_int_get_rssi(priv
->hWILCWFIDrv
, &(sinfo
->signal
));
2786 * @brief WILC_WFI_set_power_mgmt
2789 * @return int : Return 0 on Success.
2792 * @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
2794 int WILC_WFI_set_power_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
2795 bool enabled
, int timeout
)
2797 struct WILC_WFI_priv
*priv
;
2798 PRINT_D(CFG80211_DBG
, " Power save Enabled= %d , TimeOut = %d\n", enabled
, timeout
);
2803 priv
= wiphy_priv(wiphy
);
2804 if (priv
->hWILCWFIDrv
== NULL
) {
2805 PRINT_ER("Driver is NULL\n");
2810 host_int_set_power_mgmt(priv
->hWILCWFIDrv
, enabled
, timeout
);
2813 return WILC_SUCCESS
;
2816 #ifdef WILC_AP_EXTERNAL_MLME
2818 * @brief WILC_WFI_change_virt_intf
2819 * @details Change type/configuration of virtual interface,
2820 * keep the struct wireless_dev's iftype updated.
2822 * @return int : Return 0 on Success.
2827 void wilc1000_wlan_deinit(linux_wlan_t
*nic
);
2828 int wilc1000_wlan_init(struct net_device
*dev
, perInterface_wlan_t
*p_nic
);
2830 static int WILC_WFI_change_virt_intf(struct wiphy
*wiphy
, struct net_device
*dev
,
2831 enum nl80211_iftype type
, u32
*flags
, struct vif_params
*params
)
2833 s32 s32Error
= WILC_SUCCESS
;
2834 struct WILC_WFI_priv
*priv
;
2835 perInterface_wlan_t
*nic
;
2842 nic
= netdev_priv(dev
);
2843 priv
= wiphy_priv(wiphy
);
2845 PRINT_D(HOSTAPD_DBG
, "In Change virtual interface function\n");
2846 PRINT_D(HOSTAPD_DBG
, "Wireless interface name =%s\n", dev
->name
);
2847 u8P2Plocalrandom
= 0x01;
2848 u8P2Precvrandom
= 0x00;
2852 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2853 g_obtainingIP
= false;
2854 WILC_TimerStop(&hDuringIpTimer
, NULL
);
2855 PRINT_D(GENERIC_DBG
, "Changing virtual interface, enable scan\n");
2858 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2859 if (g_ptk_keys_saved
&& g_gtk_keys_saved
) {
2860 Set_machw_change_vir_if(true);
2864 case NL80211_IFTYPE_STATION
:
2866 PRINT_D(HOSTAPD_DBG
, "Interface type = NL80211_IFTYPE_STATION\n");
2868 /* send delba over wlan interface */
2871 dev
->ieee80211_ptr
->iftype
= type
;
2872 priv
->wdev
->iftype
= type
;
2873 nic
->monitor_flag
= 0;
2874 nic
->iftype
= STATION_MODE
;
2876 /*Remove the enteries of the previously connected clients*/
2877 memset(priv
->assoc_stainfo
.au8Sta_AssociatedBss
, 0, MAX_NUM_STA
* ETH_ALEN
);
2880 interface_type
= nic
->iftype
;
2881 nic
->iftype
= STATION_MODE
;
2883 if (g_linux_wlan
->wilc1000_initialized
) {
2884 host_int_del_All_Rx_BASession(priv
->hWILCWFIDrv
, g_linux_wlan
->strInterfaceInfo
[0].aBSSID
, TID
);
2885 /* ensure that the message Q is empty */
2886 host_int_wait_msg_queue_idle();
2889 /*Eliminate host interface blocking state*/
2890 linux_wlan_unlock((void *)&g_linux_wlan
->cfg_event
);
2892 wilc1000_wlan_deinit(g_linux_wlan
);
2893 wilc1000_wlan_init(dev
, nic
);
2894 g_wilc_initialized
= 1;
2895 nic
->iftype
= interface_type
;
2897 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2898 host_int_set_wfi_drv_handler(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
);
2899 host_int_set_MacAddress((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
2900 g_linux_wlan
->strInterfaceInfo
[0].aSrcAddress
);
2901 host_int_set_operation_mode(priv
->hWILCWFIDrv
, STATION_MODE
);
2903 /*Add saved WEP keys, if any*/
2904 if (g_wep_keys_saved
) {
2905 host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
2906 g_key_wep_params
.key_idx
);
2907 host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
2908 g_key_wep_params
.key
,
2909 g_key_wep_params
.key_len
,
2910 g_key_wep_params
.key_idx
);
2913 /*No matter the driver handler passed here, it will be overwriiten*/
2914 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2915 host_int_flush_join_req(priv
->hWILCWFIDrv
);
2917 /*Add saved PTK and GTK keys, if any*/
2918 if (g_ptk_keys_saved
&& g_gtk_keys_saved
) {
2919 PRINT_D(CFG80211_DBG
, "ptk %x %x %x\n", g_key_ptk_params
.key
[0],
2920 g_key_ptk_params
.key
[1],
2921 g_key_ptk_params
.key
[2]);
2922 PRINT_D(CFG80211_DBG
, "gtk %x %x %x\n", g_key_gtk_params
.key
[0],
2923 g_key_gtk_params
.key
[1],
2924 g_key_gtk_params
.key
[2]);
2925 WILC_WFI_add_key(g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
->ieee80211_ptr
->wiphy
,
2926 g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
,
2927 g_add_ptk_key_params
.key_idx
,
2928 g_add_ptk_key_params
.pairwise
,
2929 g_add_ptk_key_params
.mac_addr
,
2930 (struct key_params
*)(&g_key_ptk_params
));
2932 WILC_WFI_add_key(g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
->ieee80211_ptr
->wiphy
,
2933 g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
,
2934 g_add_gtk_key_params
.key_idx
,
2935 g_add_gtk_key_params
.pairwise
,
2936 g_add_gtk_key_params
.mac_addr
,
2937 (struct key_params
*)(&g_key_gtk_params
));
2940 /*BugID_4847: registered frames in firmware are now*/
2941 /*lost due to mac close. So re-register those frames*/
2942 if (g_linux_wlan
->wilc1000_initialized
) {
2943 for (i
= 0; i
< num_reg_frame
; i
++) {
2944 PRINT_D(INIT_DBG
, "Frame registering Type: %x - Reg: %d\n", nic
->g_struct_frame_reg
[i
].frame_type
,
2945 nic
->g_struct_frame_reg
[i
].reg
);
2946 host_int_frame_register(priv
->hWILCWFIDrv
,
2947 nic
->g_struct_frame_reg
[i
].frame_type
,
2948 nic
->g_struct_frame_reg
[i
].reg
);
2953 host_int_set_power_mgmt(priv
->hWILCWFIDrv
, 1, 0);
2959 case NL80211_IFTYPE_P2P_CLIENT
:
2961 host_int_set_power_mgmt(priv
->hWILCWFIDrv
, 0, 0);
2963 PRINT_D(HOSTAPD_DBG
, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
2965 host_int_del_All_Rx_BASession(priv
->hWILCWFIDrv
, g_linux_wlan
->strInterfaceInfo
[0].aBSSID
, TID
);
2967 dev
->ieee80211_ptr
->iftype
= type
;
2968 priv
->wdev
->iftype
= type
;
2969 nic
->monitor_flag
= 0;
2974 PRINT_D(HOSTAPD_DBG
, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2975 nic
->iftype
= CLIENT_MODE
;
2978 if (g_linux_wlan
->wilc1000_initialized
) {
2979 /* ensure that the message Q is empty */
2980 host_int_wait_msg_queue_idle();
2982 wilc1000_wlan_deinit(g_linux_wlan
);
2983 wilc1000_wlan_init(dev
, nic
);
2984 g_wilc_initialized
= 1;
2986 host_int_set_wfi_drv_handler(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
);
2987 host_int_set_MacAddress((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
2988 g_linux_wlan
->strInterfaceInfo
[0].aSrcAddress
);
2989 host_int_set_operation_mode(priv
->hWILCWFIDrv
, STATION_MODE
);
2991 /*Add saved WEP keys, if any*/
2992 if (g_wep_keys_saved
) {
2993 host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
2994 g_key_wep_params
.key_idx
);
2995 host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
2996 g_key_wep_params
.key
,
2997 g_key_wep_params
.key_len
,
2998 g_key_wep_params
.key_idx
);
3001 /*No matter the driver handler passed here, it will be overwriiten*/
3002 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3003 host_int_flush_join_req(priv
->hWILCWFIDrv
);
3005 /*Add saved PTK and GTK keys, if any*/
3006 if (g_ptk_keys_saved
&& g_gtk_keys_saved
) {
3007 PRINT_D(CFG80211_DBG
, "ptk %x %x %x\n", g_key_ptk_params
.key
[0],
3008 g_key_ptk_params
.key
[1],
3009 g_key_ptk_params
.key
[2]);
3010 PRINT_D(CFG80211_DBG
, "gtk %x %x %x\n", g_key_gtk_params
.key
[0],
3011 g_key_gtk_params
.key
[1],
3012 g_key_gtk_params
.key
[2]);
3013 WILC_WFI_add_key(g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
->ieee80211_ptr
->wiphy
,
3014 g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
,
3015 g_add_ptk_key_params
.key_idx
,
3016 g_add_ptk_key_params
.pairwise
,
3017 g_add_ptk_key_params
.mac_addr
,
3018 (struct key_params
*)(&g_key_ptk_params
));
3020 WILC_WFI_add_key(g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
->ieee80211_ptr
->wiphy
,
3021 g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
,
3022 g_add_gtk_key_params
.key_idx
,
3023 g_add_gtk_key_params
.pairwise
,
3024 g_add_gtk_key_params
.mac_addr
,
3025 (struct key_params
*)(&g_key_gtk_params
));
3028 /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/
3029 refresh_scan(priv
, 1, true);
3030 Set_machw_change_vir_if(false);
3032 /*BugID_4847: registered frames in firmware are now lost
3033 * due to mac close. So re-register those frames */
3034 if (g_linux_wlan
->wilc1000_initialized
) {
3035 for (i
= 0; i
< num_reg_frame
; i
++) {
3036 PRINT_D(INIT_DBG
, "Frame registering Type: %x - Reg: %d\n", nic
->g_struct_frame_reg
[i
].frame_type
,
3037 nic
->g_struct_frame_reg
[i
].reg
);
3038 host_int_frame_register(priv
->hWILCWFIDrv
,
3039 nic
->g_struct_frame_reg
[i
].frame_type
,
3040 nic
->g_struct_frame_reg
[i
].reg
);
3048 case NL80211_IFTYPE_AP
:
3050 PRINT_D(HOSTAPD_DBG
, "Interface type = NL80211_IFTYPE_AP %d\n", type
);
3051 dev
->ieee80211_ptr
->iftype
= type
;
3052 priv
->wdev
->iftype
= type
;
3053 nic
->iftype
= AP_MODE
;
3054 PRINT_D(CORECONFIG_DBG
, "priv->hWILCWFIDrv[%p]\n", priv
->hWILCWFIDrv
);
3057 PRINT_D(HOSTAPD_DBG
, "Downloading AP firmware\n");
3058 linux_wlan_get_firmware(nic
);
3060 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
3061 if (g_linux_wlan
->wilc1000_initialized
) {
3062 nic
->iftype
= AP_MODE
;
3063 g_linux_wlan
->wilc1000_initialized
= 1;
3067 /*BugID_4847: registered frames in firmware are now lost
3068 * due to mac close. So re-register those frames */
3069 for (i
= 0; i
< num_reg_frame
; i
++) {
3070 PRINT_D(INIT_DBG
, "Frame registering Type: %x - Reg: %d\n", nic
->g_struct_frame_reg
[i
].frame_type
,
3071 nic
->g_struct_frame_reg
[i
].reg
);
3072 host_int_frame_register(priv
->hWILCWFIDrv
,
3073 nic
->g_struct_frame_reg
[i
].frame_type
,
3074 nic
->g_struct_frame_reg
[i
].reg
);
3081 case NL80211_IFTYPE_P2P_GO
:
3082 PRINT_D(GENERIC_DBG
, "start duringIP timer\n");
3084 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3085 g_obtainingIP
= true;
3086 WILC_TimerStart(&hDuringIpTimer
, duringIP_TIME
, NULL
, NULL
);
3088 host_int_set_power_mgmt(priv
->hWILCWFIDrv
, 0, 0);
3090 /*Delete block ack has to be the latest config packet*/
3091 /*sent before downloading new FW. This is because it blocks on*/
3092 /*hWaitResponse semaphore, which allows previous config*/
3093 /*packets to actually take action on old FW*/
3094 host_int_del_All_Rx_BASession(priv
->hWILCWFIDrv
, g_linux_wlan
->strInterfaceInfo
[0].aBSSID
, TID
);
3096 PRINT_D(HOSTAPD_DBG
, "Interface type = NL80211_IFTYPE_GO\n");
3097 dev
->ieee80211_ptr
->iftype
= type
;
3098 priv
->wdev
->iftype
= type
;
3100 PRINT_D(CORECONFIG_DBG
, "priv->hWILCWFIDrv[%p]\n", priv
->hWILCWFIDrv
);
3104 PRINT_D(HOSTAPD_DBG
, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
3108 nic
->iftype
= GO_MODE
;
3110 /* ensure that the message Q is empty */
3111 host_int_wait_msg_queue_idle();
3112 wilc1000_wlan_deinit(g_linux_wlan
);
3113 wilc1000_wlan_init(dev
, nic
);
3114 g_wilc_initialized
= 1;
3117 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
3118 host_int_set_wfi_drv_handler(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
);
3119 host_int_set_MacAddress((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
3120 g_linux_wlan
->strInterfaceInfo
[0].aSrcAddress
);
3121 host_int_set_operation_mode(priv
->hWILCWFIDrv
, AP_MODE
);
3123 /*Add saved WEP keys, if any*/
3124 if (g_wep_keys_saved
) {
3125 host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
3126 g_key_wep_params
.key_idx
);
3127 host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle
)(g_linux_wlan
->strInterfaceInfo
[0].drvHandler
),
3128 g_key_wep_params
.key
,
3129 g_key_wep_params
.key_len
,
3130 g_key_wep_params
.key_idx
);
3133 /*No matter the driver handler passed here, it will be overwriiten*/
3134 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3135 host_int_flush_join_req(priv
->hWILCWFIDrv
);
3137 /*Add saved PTK and GTK keys, if any*/
3138 if (g_ptk_keys_saved
&& g_gtk_keys_saved
) {
3139 PRINT_D(CFG80211_DBG
, "ptk %x %x %x cipher %x\n", g_key_ptk_params
.key
[0],
3140 g_key_ptk_params
.key
[1],
3141 g_key_ptk_params
.key
[2],
3142 g_key_ptk_params
.cipher
);
3143 PRINT_D(CFG80211_DBG
, "gtk %x %x %x cipher %x\n", g_key_gtk_params
.key
[0],
3144 g_key_gtk_params
.key
[1],
3145 g_key_gtk_params
.key
[2],
3146 g_key_gtk_params
.cipher
);
3148 WILC_WFI_add_key(g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
->ieee80211_ptr
->wiphy
,
3149 g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
,
3150 g_add_ptk_key_params
.key_idx
,
3151 g_add_ptk_key_params
.pairwise
,
3152 g_add_ptk_key_params
.mac_addr
,
3153 (struct key_params
*)(&g_key_ptk_params
));
3155 WILC_WFI_add_key(g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
->ieee80211_ptr
->wiphy
,
3156 g_linux_wlan
->strInterfaceInfo
[0].wilc_netdev
,
3157 g_add_gtk_key_params
.key_idx
,
3158 g_add_gtk_key_params
.pairwise
,
3159 g_add_gtk_key_params
.mac_addr
,
3160 (struct key_params
*)(&g_key_gtk_params
));
3165 /*BugID_4847: registered frames in firmware are now*/
3166 /*lost due to mac close. So re-register those frames*/
3167 if (g_linux_wlan
->wilc1000_initialized
) {
3168 for (i
= 0; i
< num_reg_frame
; i
++) {
3169 PRINT_D(INIT_DBG
, "Frame registering Type: %x - Reg: %d\n", nic
->g_struct_frame_reg
[i
].frame_type
,
3170 nic
->g_struct_frame_reg
[i
].reg
);
3171 host_int_frame_register(priv
->hWILCWFIDrv
,
3172 nic
->g_struct_frame_reg
[i
].frame_type
,
3173 nic
->g_struct_frame_reg
[i
].reg
);
3181 PRINT_ER("Unknown interface type= %d\n", type
);
3190 /* (austin.2013-07-23)
3192 * To support revised cfg80211_ops
3194 * add_beacon --> start_ap
3195 * set_beacon --> change_beacon
3196 * del_beacon --> stop_ap
3198 * beacon_parameters --> cfg80211_ap_settings
3199 * cfg80211_beacon_data
3201 * applicable for linux kernel 3.4+
3205 * @brief WILC_WFI_start_ap
3206 * @details Add a beacon with given parameters, @head, @interval
3207 * and @dtim_period will be valid, @tail is optional.
3209 * @param[in] dev The net device structure
3210 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
3211 * @return int : Return 0 on Success.
3216 static int WILC_WFI_start_ap(struct wiphy
*wiphy
, struct net_device
*dev
,
3217 struct cfg80211_ap_settings
*settings
)
3219 struct cfg80211_beacon_data
*beacon
= &(settings
->beacon
);
3220 struct WILC_WFI_priv
*priv
;
3221 s32 s32Error
= WILC_SUCCESS
;
3223 priv
= wiphy_priv(wiphy
);
3224 PRINT_D(HOSTAPD_DBG
, "Starting ap\n");
3226 PRINT_D(HOSTAPD_DBG
, "Interval = %d \n DTIM period = %d\n Head length = %zu Tail length = %zu\n",
3227 settings
->beacon_interval
, settings
->dtim_period
, beacon
->head_len
, beacon
->tail_len
);
3229 s32Error
= WILC_WFI_CfgSetChannel(wiphy
, &settings
->chandef
);
3231 if (s32Error
!= WILC_SUCCESS
)
3232 PRINT_ER("Error in setting channel\n");
3234 linux_wlan_set_bssid(dev
, g_linux_wlan
->strInterfaceInfo
[0].aSrcAddress
);
3236 #ifndef WILC_FULLY_HOSTING_AP
3237 s32Error
= host_int_add_beacon(priv
->hWILCWFIDrv
,
3238 settings
->beacon_interval
,
3239 settings
->dtim_period
,
3240 beacon
->head_len
, (u8
*)beacon
->head
,
3241 beacon
->tail_len
, (u8
*)beacon
->tail
);
3243 s32Error
= host_add_beacon(priv
->hWILCWFIDrv
,
3244 settings
->beacon_interval
,
3245 settings
->dtim_period
,
3246 beacon
->head_len
, (u8
*)beacon
->head
,
3247 beacon
->tail_len
, (u8
*)beacon
->tail
);
3254 * @brief WILC_WFI_change_beacon
3255 * @details Add a beacon with given parameters, @head, @interval
3256 * and @dtim_period will be valid, @tail is optional.
3258 * @param[in] dev The net device structure
3259 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
3260 * @return int : Return 0 on Success.
3265 static int WILC_WFI_change_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
3266 struct cfg80211_beacon_data
*beacon
)
3268 struct WILC_WFI_priv
*priv
;
3269 s32 s32Error
= WILC_SUCCESS
;
3271 priv
= wiphy_priv(wiphy
);
3272 PRINT_D(HOSTAPD_DBG
, "Setting beacon\n");
3275 #ifndef WILC_FULLY_HOSTING_AP
3276 s32Error
= host_int_add_beacon(priv
->hWILCWFIDrv
,
3279 beacon
->head_len
, (u8
*)beacon
->head
,
3280 beacon
->tail_len
, (u8
*)beacon
->tail
);
3282 s32Error
= host_add_beacon(priv
->hWILCWFIDrv
,
3285 beacon
->head_len
, (u8
*)beacon
->head
,
3286 beacon
->tail_len
, (u8
*)beacon
->tail
);
3293 * @brief WILC_WFI_stop_ap
3294 * @details Remove beacon configuration and stop sending the beacon.
3296 * @return int : Return 0 on Success.
3301 static int WILC_WFI_stop_ap(struct wiphy
*wiphy
, struct net_device
*dev
)
3303 s32 s32Error
= WILC_SUCCESS
;
3304 struct WILC_WFI_priv
*priv
;
3305 u8 NullBssid
[ETH_ALEN
] = {0};
3308 WILC_NULLCHECK(s32Error
, wiphy
);
3310 priv
= wiphy_priv(wiphy
);
3312 PRINT_D(HOSTAPD_DBG
, "Deleting beacon\n");
3315 linux_wlan_set_bssid(dev
, NullBssid
);
3317 #ifndef WILC_FULLY_HOSTING_AP
3318 s32Error
= host_int_del_beacon(priv
->hWILCWFIDrv
);
3320 s32Error
= host_del_beacon(priv
->hWILCWFIDrv
);
3323 WILC_ERRORCHECK(s32Error
);
3325 WILC_CATCH(s32Error
)
3332 * @brief WILC_WFI_add_station
3333 * @details Add a new station.
3335 * @return int : Return 0 on Success.
3340 static int WILC_WFI_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3341 const u8
*mac
, struct station_parameters
*params
)
3343 s32 s32Error
= WILC_SUCCESS
;
3344 struct WILC_WFI_priv
*priv
;
3345 tstrWILC_AddStaParam strStaParams
= {{0}};
3346 perInterface_wlan_t
*nic
;
3349 WILC_NULLCHECK(s32Error
, wiphy
);
3351 priv
= wiphy_priv(wiphy
);
3352 nic
= netdev_priv(dev
);
3354 if (nic
->iftype
== AP_MODE
|| nic
->iftype
== GO_MODE
) {
3355 #ifndef WILC_FULLY_HOSTING_AP
3357 WILC_memcpy(strStaParams
.au8BSSID
, mac
, ETH_ALEN
);
3358 WILC_memcpy(priv
->assoc_stainfo
.au8Sta_AssociatedBss
[params
->aid
], mac
, ETH_ALEN
);
3359 strStaParams
.u16AssocID
= params
->aid
;
3360 strStaParams
.u8NumRates
= params
->supported_rates_len
;
3361 strStaParams
.pu8Rates
= params
->supported_rates
;
3363 PRINT_D(CFG80211_DBG
, "Adding station parameters %d\n", params
->aid
);
3365 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],
3366 priv
->assoc_stainfo
.au8Sta_AssociatedBss
[params
->aid
][5]);
3367 PRINT_D(HOSTAPD_DBG
, "ASSOC ID = %d\n", strStaParams
.u16AssocID
);
3368 PRINT_D(HOSTAPD_DBG
, "Number of supported rates = %d\n", strStaParams
.u8NumRates
);
3370 if (params
->ht_capa
== NULL
) {
3371 strStaParams
.bIsHTSupported
= false;
3373 strStaParams
.bIsHTSupported
= true;
3374 strStaParams
.u16HTCapInfo
= params
->ht_capa
->cap_info
;
3375 strStaParams
.u8AmpduParams
= params
->ht_capa
->ampdu_params_info
;
3376 WILC_memcpy(strStaParams
.au8SuppMCsSet
, ¶ms
->ht_capa
->mcs
, WILC_SUPP_MCS_SET_SIZE
);
3377 strStaParams
.u16HTExtParams
= params
->ht_capa
->extended_ht_cap_info
;
3378 strStaParams
.u32TxBeamformingCap
= params
->ht_capa
->tx_BF_cap_info
;
3379 strStaParams
.u8ASELCap
= params
->ht_capa
->antenna_selection_info
;
3382 strStaParams
.u16FlagsMask
= params
->sta_flags_mask
;
3383 strStaParams
.u16FlagsSet
= params
->sta_flags_set
;
3385 PRINT_D(HOSTAPD_DBG
, "IS HT supported = %d\n", strStaParams
.bIsHTSupported
);
3386 PRINT_D(HOSTAPD_DBG
, "Capability Info = %d\n", strStaParams
.u16HTCapInfo
);
3387 PRINT_D(HOSTAPD_DBG
, "AMPDU Params = %d\n", strStaParams
.u8AmpduParams
);
3388 PRINT_D(HOSTAPD_DBG
, "HT Extended params = %d\n", strStaParams
.u16HTExtParams
);
3389 PRINT_D(HOSTAPD_DBG
, "Tx Beamforming Cap = %d\n", strStaParams
.u32TxBeamformingCap
);
3390 PRINT_D(HOSTAPD_DBG
, "Antenna selection info = %d\n", strStaParams
.u8ASELCap
);
3391 PRINT_D(HOSTAPD_DBG
, "Flag Mask = %d\n", strStaParams
.u16FlagsMask
);
3392 PRINT_D(HOSTAPD_DBG
, "Flag Set = %d\n", strStaParams
.u16FlagsSet
);
3394 s32Error
= host_int_add_station(priv
->hWILCWFIDrv
, &strStaParams
);
3395 WILC_ERRORCHECK(s32Error
);
3398 PRINT_D(CFG80211_DBG
, "Adding station parameters %d\n", params
->aid
);
3399 WILC_memcpy(priv
->assoc_stainfo
.au8Sta_AssociatedBss
[params
->aid
], mac
, ETH_ALEN
);
3401 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],
3402 priv
->assoc_stainfo
.au8Sta_AssociatedBss
[params
->aid
][5]);
3404 WILC_AP_AddSta(mac
, params
);
3405 WILC_ERRORCHECK(s32Error
);
3406 #endif /* WILC_FULLY_HOSTING_AP */
3410 WILC_CATCH(s32Error
)
3417 * @brief WILC_WFI_del_station
3418 * @details Remove a station; @mac may be NULL to remove all stations.
3420 * @return int : Return 0 on Success.
3425 static int WILC_WFI_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3426 struct station_del_parameters
*params
)
3428 const u8
*mac
= params
->mac
;
3429 s32 s32Error
= WILC_SUCCESS
;
3430 struct WILC_WFI_priv
*priv
;
3431 perInterface_wlan_t
*nic
;
3432 WILC_NULLCHECK(s32Error
, wiphy
);
3434 priv
= wiphy_priv(wiphy
);
3435 nic
= netdev_priv(dev
);
3437 if (nic
->iftype
== AP_MODE
|| nic
->iftype
== GO_MODE
) {
3438 PRINT_D(HOSTAPD_DBG
, "Deleting station\n");
3442 PRINT_D(HOSTAPD_DBG
, "All associated stations \n");
3443 s32Error
= host_int_del_allstation(priv
->hWILCWFIDrv
, priv
->assoc_stainfo
.au8Sta_AssociatedBss
);
3445 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]);
3448 #ifndef WILC_FULLY_HOSTING_AP
3449 s32Error
= host_int_del_station(priv
->hWILCWFIDrv
, mac
);
3451 WILC_AP_RemoveSta(mac
);
3452 #endif /* WILC_FULLY_HOSTING_AP */
3454 WILC_ERRORCHECK(s32Error
);
3456 WILC_CATCH(s32Error
)
3463 * @brief WILC_WFI_change_station
3464 * @details Modify a given station.
3466 * @return int : Return 0 on Success.
3471 static int WILC_WFI_change_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3472 const u8
*mac
, struct station_parameters
*params
)
3474 s32 s32Error
= WILC_SUCCESS
;
3475 struct WILC_WFI_priv
*priv
;
3476 tstrWILC_AddStaParam strStaParams
= {{0}};
3477 perInterface_wlan_t
*nic
;
3480 PRINT_D(HOSTAPD_DBG
, "Change station paramters\n");
3482 WILC_NULLCHECK(s32Error
, wiphy
);
3484 priv
= wiphy_priv(wiphy
);
3485 nic
= netdev_priv(dev
);
3487 if (nic
->iftype
== AP_MODE
|| nic
->iftype
== GO_MODE
) {
3488 #ifndef WILC_FULLY_HOSTING_AP
3490 WILC_memcpy(strStaParams
.au8BSSID
, mac
, ETH_ALEN
);
3491 strStaParams
.u16AssocID
= params
->aid
;
3492 strStaParams
.u8NumRates
= params
->supported_rates_len
;
3493 strStaParams
.pu8Rates
= params
->supported_rates
;
3495 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],
3496 strStaParams
.au8BSSID
[5]);
3497 PRINT_D(HOSTAPD_DBG
, "ASSOC ID = %d\n", strStaParams
.u16AssocID
);
3498 PRINT_D(HOSTAPD_DBG
, "Number of supported rates = %d\n", strStaParams
.u8NumRates
);
3500 if (params
->ht_capa
== NULL
) {
3501 strStaParams
.bIsHTSupported
= false;
3503 strStaParams
.bIsHTSupported
= true;
3504 strStaParams
.u16HTCapInfo
= params
->ht_capa
->cap_info
;
3505 strStaParams
.u8AmpduParams
= params
->ht_capa
->ampdu_params_info
;
3506 WILC_memcpy(strStaParams
.au8SuppMCsSet
, ¶ms
->ht_capa
->mcs
, WILC_SUPP_MCS_SET_SIZE
);
3507 strStaParams
.u16HTExtParams
= params
->ht_capa
->extended_ht_cap_info
;
3508 strStaParams
.u32TxBeamformingCap
= params
->ht_capa
->tx_BF_cap_info
;
3509 strStaParams
.u8ASELCap
= params
->ht_capa
->antenna_selection_info
;
3513 strStaParams
.u16FlagsMask
= params
->sta_flags_mask
;
3514 strStaParams
.u16FlagsSet
= params
->sta_flags_set
;
3516 PRINT_D(HOSTAPD_DBG
, "IS HT supported = %d\n", strStaParams
.bIsHTSupported
);
3517 PRINT_D(HOSTAPD_DBG
, "Capability Info = %d\n", strStaParams
.u16HTCapInfo
);
3518 PRINT_D(HOSTAPD_DBG
, "AMPDU Params = %d\n", strStaParams
.u8AmpduParams
);
3519 PRINT_D(HOSTAPD_DBG
, "HT Extended params = %d\n", strStaParams
.u16HTExtParams
);
3520 PRINT_D(HOSTAPD_DBG
, "Tx Beamforming Cap = %d\n", strStaParams
.u32TxBeamformingCap
);
3521 PRINT_D(HOSTAPD_DBG
, "Antenna selection info = %d\n", strStaParams
.u8ASELCap
);
3522 PRINT_D(HOSTAPD_DBG
, "Flag Mask = %d\n", strStaParams
.u16FlagsMask
);
3523 PRINT_D(HOSTAPD_DBG
, "Flag Set = %d\n", strStaParams
.u16FlagsSet
);
3525 s32Error
= host_int_edit_station(priv
->hWILCWFIDrv
, &strStaParams
);
3526 WILC_ERRORCHECK(s32Error
);
3529 WILC_AP_EditSta(mac
, params
);
3530 WILC_ERRORCHECK(s32Error
);
3531 #endif /* WILC_FULLY_HOSTING_AP */
3534 WILC_CATCH(s32Error
)
3542 * @brief WILC_WFI_add_virt_intf
3545 * @return int : Return 0 on Success.
3550 struct wireless_dev
*WILC_WFI_add_virt_intf(struct wiphy
*wiphy
, const char *name
,
3551 unsigned char name_assign_type
,
3552 enum nl80211_iftype type
, u32
*flags
,
3553 struct vif_params
*params
)
3555 perInterface_wlan_t
*nic
;
3556 struct WILC_WFI_priv
*priv
;
3557 struct net_device
*new_ifc
= NULL
;
3558 priv
= wiphy_priv(wiphy
);
3562 PRINT_D(HOSTAPD_DBG
, "Adding monitor interface[%p]\n", priv
->wdev
->netdev
);
3564 nic
= netdev_priv(priv
->wdev
->netdev
);
3567 if (type
== NL80211_IFTYPE_MONITOR
) {
3568 PRINT_D(HOSTAPD_DBG
, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3569 PRINT_D(HOSTAPD_DBG
, "Adding monitor interface[%p]\n", nic
->wilc_netdev
);
3570 new_ifc
= WILC_WFI_init_mon_interface(name
, nic
->wilc_netdev
);
3571 if (new_ifc
!= NULL
) {
3572 PRINT_D(HOSTAPD_DBG
, "Setting monitor flag in private structure\n");
3574 priv
= netdev_priv(priv
->wdev
->netdev
);
3575 priv
->monitor_flag
= 1;
3577 nic
= netdev_priv(priv
->wdev
->netdev
);
3578 nic
->monitor_flag
= 1;
3581 PRINT_ER("Error in initializing monitor interface\n ");
3587 * @brief WILC_WFI_del_virt_intf
3590 * @return int : Return 0 on Success.
3595 int WILC_WFI_del_virt_intf(struct wiphy
*wiphy
, struct wireless_dev
*wdev
) /* tony for v3.8 support */
3597 PRINT_D(HOSTAPD_DBG
, "Deleting virtual interface\n");
3598 return WILC_SUCCESS
;
3603 #endif /*WILC_AP_EXTERNAL_MLME*/
3604 static struct cfg80211_ops WILC_WFI_cfg80211_ops
= {
3606 .set_monitor_channel
= WILC_WFI_CfgSetChannel
,
3607 .scan
= WILC_WFI_CfgScan
,
3608 .connect
= WILC_WFI_CfgConnect
,
3609 .disconnect
= WILC_WFI_disconnect
,
3610 .add_key
= WILC_WFI_add_key
,
3611 .del_key
= WILC_WFI_del_key
,
3612 .get_key
= WILC_WFI_get_key
,
3613 .set_default_key
= WILC_WFI_set_default_key
,
3614 #ifdef WILC_AP_EXTERNAL_MLME
3615 .add_virtual_intf
= WILC_WFI_add_virt_intf
,
3616 .del_virtual_intf
= WILC_WFI_del_virt_intf
,
3617 .change_virtual_intf
= WILC_WFI_change_virt_intf
,
3619 .start_ap
= WILC_WFI_start_ap
,
3620 .change_beacon
= WILC_WFI_change_beacon
,
3621 .stop_ap
= WILC_WFI_stop_ap
,
3622 .add_station
= WILC_WFI_add_station
,
3623 .del_station
= WILC_WFI_del_station
,
3624 .change_station
= WILC_WFI_change_station
,
3625 #endif /* WILC_AP_EXTERNAL_MLME*/
3626 #ifndef WILC_FULLY_HOSTING_AP
3627 .get_station
= WILC_WFI_get_station
,
3629 .dump_station
= WILC_WFI_dump_station
,
3630 .change_bss
= WILC_WFI_change_bss
,
3631 .set_wiphy_params
= WILC_WFI_set_wiphy_params
,
3633 .set_pmksa
= WILC_WFI_set_pmksa
,
3634 .del_pmksa
= WILC_WFI_del_pmksa
,
3635 .flush_pmksa
= WILC_WFI_flush_pmksa
,
3637 .remain_on_channel
= WILC_WFI_remain_on_channel
,
3638 .cancel_remain_on_channel
= WILC_WFI_cancel_remain_on_channel
,
3639 .mgmt_tx_cancel_wait
= WILC_WFI_mgmt_tx_cancel_wait
,
3640 .mgmt_tx
= WILC_WFI_mgmt_tx
,
3641 .mgmt_frame_register
= WILC_WFI_frame_register
,
3642 .set_power_mgmt
= WILC_WFI_set_power_mgmt
,
3643 .set_cqm_rssi_config
= WILC_WFI_set_cqm_rssi_config
,
3653 * @brief WILC_WFI_update_stats
3654 * @details Modify parameters for a given BSS.
3656 * @return int : Return 0 on Success.
3659 * @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
3661 int WILC_WFI_update_stats(struct wiphy
*wiphy
, u32 pktlen
, u8 changed
)
3664 struct WILC_WFI_priv
*priv
;
3666 priv
= wiphy_priv(wiphy
);
3670 case WILC_WFI_RX_PKT
:
3672 priv
->netstats
.rx_packets
++;
3673 priv
->netstats
.rx_bytes
+= pktlen
;
3674 priv
->netstats
.rx_time
= get_jiffies_64();
3678 case WILC_WFI_TX_PKT
:
3680 priv
->netstats
.tx_packets
++;
3681 priv
->netstats
.tx_bytes
+= pktlen
;
3682 priv
->netstats
.tx_time
= get_jiffies_64();
3695 * @brief WILC_WFI_CfgAlloc
3696 * @details Allocation of the wireless device structure and assigning it
3697 * to the cfg80211 operations structure.
3699 * @return wireless_dev : Returns pointer to wireless_dev structure.
3704 struct wireless_dev
*WILC_WFI_CfgAlloc(void)
3707 struct wireless_dev
*wdev
;
3710 PRINT_D(CFG80211_DBG
, "Allocating wireless device\n");
3711 /*Allocating the wireless device structure*/
3712 wdev
= kzalloc(sizeof(struct wireless_dev
), GFP_KERNEL
);
3714 PRINT_ER("Cannot allocate wireless device\n");
3718 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
3719 wdev
->wiphy
= wiphy_new(&WILC_WFI_cfg80211_ops
, sizeof(struct WILC_WFI_priv
));
3721 PRINT_ER("Cannot allocate wiphy\n");
3726 #ifdef WILC_AP_EXTERNAL_MLME
3727 /* enable 802.11n HT */
3728 WILC_WFI_band_2ghz
.ht_cap
.ht_supported
= 1;
3729 WILC_WFI_band_2ghz
.ht_cap
.cap
|= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT
);
3730 WILC_WFI_band_2ghz
.ht_cap
.mcs
.rx_mask
[0] = 0xff;
3731 WILC_WFI_band_2ghz
.ht_cap
.ampdu_factor
= IEEE80211_HT_MAX_AMPDU_8K
;
3732 WILC_WFI_band_2ghz
.ht_cap
.ampdu_density
= IEEE80211_HT_MPDU_DENSITY_NONE
;
3736 wdev
->wiphy
->bands
[IEEE80211_BAND_2GHZ
] = &WILC_WFI_band_2ghz
;
3747 * @brief WILC_WFI_WiphyRegister
3748 * @details Registering of the wiphy structure and interface modes
3755 struct wireless_dev
*WILC_WFI_WiphyRegister(struct net_device
*net
)
3757 struct WILC_WFI_priv
*priv
;
3758 struct wireless_dev
*wdev
;
3759 s32 s32Error
= WILC_SUCCESS
;
3761 PRINT_D(CFG80211_DBG
, "Registering wifi device\n");
3763 wdev
= WILC_WFI_CfgAlloc();
3765 PRINT_ER("CfgAlloc Failed\n");
3770 /*Return hardware description structure (wiphy)'s priv*/
3771 priv
= wdev_priv(wdev
);
3772 sema_init(&(priv
->SemHandleUpdateStats
), 1);
3774 /*Link the wiphy with wireless structure*/
3777 /*Maximum number of probed ssid to be added by user for the scan request*/
3778 wdev
->wiphy
->max_scan_ssids
= MAX_NUM_PROBED_SSID
;
3779 /*Maximum number of pmkids to be cashed*/
3780 wdev
->wiphy
->max_num_pmkids
= WILC_MAX_NUM_PMKIDS
;
3781 PRINT_INFO(CFG80211_DBG
, "Max number of PMKIDs = %d\n", wdev
->wiphy
->max_num_pmkids
);
3783 wdev
->wiphy
->max_scan_ie_len
= 1000;
3785 /*signal strength in mBm (100*dBm) */
3786 wdev
->wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_MBM
;
3788 /*Set the availaible cipher suites*/
3789 wdev
->wiphy
->cipher_suites
= cipher_suites
;
3790 wdev
->wiphy
->n_cipher_suites
= ARRAY_SIZE(cipher_suites
);
3791 /*Setting default managment types: for register action frame: */
3792 wdev
->wiphy
->mgmt_stypes
= wilc_wfi_cfg80211_mgmt_types
;
3795 wdev
->wiphy
->max_remain_on_channel_duration
= 500;
3796 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3797 wdev
->wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) | BIT(NL80211_IFTYPE_AP
) | BIT(NL80211_IFTYPE_MONITOR
) | BIT(NL80211_IFTYPE_P2P_GO
) |
3798 BIT(NL80211_IFTYPE_P2P_CLIENT
);
3799 wdev
->wiphy
->flags
|= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
;
3801 wdev
->wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) | BIT(NL80211_IFTYPE_AP
) | BIT(NL80211_IFTYPE_MONITOR
);
3803 wdev
->iftype
= NL80211_IFTYPE_STATION
;
3807 PRINT_INFO(CFG80211_DBG
, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3808 wdev
->wiphy
->max_scan_ssids
, wdev
->wiphy
->max_scan_ie_len
, wdev
->wiphy
->signal_type
,
3809 wdev
->wiphy
->interface_modes
, wdev
->iftype
);
3812 set_wiphy_dev(wdev
->wiphy
, &local_sdio_func
->dev
); /* tony */
3815 /*Register wiphy structure*/
3816 s32Error
= wiphy_register(wdev
->wiphy
);
3818 PRINT_ER("Cannot register wiphy device\n");
3819 /*should define what action to be taken in such failure*/
3821 PRINT_D(CFG80211_DBG
, "Successful Registering\n");
3830 * @brief WILC_WFI_WiphyFree
3831 * @details Freeing allocation of the wireless device structure
3838 int WILC_WFI_InitHostInt(struct net_device
*net
)
3841 s32 s32Error
= WILC_SUCCESS
;
3843 struct WILC_WFI_priv
*priv
;
3845 PRINT_D(INIT_DBG
, "Host[%p][%p]\n", net
, net
->ieee80211_ptr
);
3846 priv
= wdev_priv(net
->ieee80211_ptr
);
3848 s32Error
= WILC_TimerCreate(&(hAgingTimer
), remove_network_from_shadow
, NULL
);
3849 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3850 s32Error
= WILC_TimerCreate(&(hDuringIpTimer
), clear_duringIP
, NULL
);
3855 PRINT_ER("Failed to creat refresh Timer\n");
3859 priv
->gbAutoRateAdjusted
= false;
3861 priv
->bInP2PlistenState
= false;
3863 sema_init(&(priv
->hSemScanReq
), 1);
3864 s32Error
= host_int_init(&priv
->hWILCWFIDrv
);
3866 PRINT_ER("Error while initializing hostinterface\n");
3872 * @brief WILC_WFI_WiphyFree
3873 * @details Freeing allocation of the wireless device structure
3880 int WILC_WFI_DeInitHostInt(struct net_device
*net
)
3882 s32 s32Error
= WILC_SUCCESS
;
3884 struct WILC_WFI_priv
*priv
;
3885 priv
= wdev_priv(net
->ieee80211_ptr
);
3887 priv
->gbAutoRateAdjusted
= false;
3889 priv
->bInP2PlistenState
= false;
3893 s32Error
= host_int_deinit(priv
->hWILCWFIDrv
);
3895 /* Clear the Shadow scan */
3896 clear_shadow_scan(priv
);
3897 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3899 PRINT_D(CORECONFIG_DBG
, "destroy during ip\n");
3900 WILC_TimerDestroy(&hDuringIpTimer
, NULL
);
3905 PRINT_ER("Error while deintializing host interface\n");
3912 * @brief WILC_WFI_WiphyFree
3913 * @details Freeing allocation of the wireless device structure
3920 void WILC_WFI_WiphyFree(struct net_device
*net
)
3923 PRINT_D(CFG80211_DBG
, "Unregistering wiphy\n");
3926 PRINT_D(INIT_DBG
, "net_device is NULL\n");
3930 if (net
->ieee80211_ptr
== NULL
) {
3931 PRINT_D(INIT_DBG
, "ieee80211_ptr is NULL\n");
3935 if (net
->ieee80211_ptr
->wiphy
== NULL
) {
3936 PRINT_D(INIT_DBG
, "wiphy is NULL\n");
3940 wiphy_unregister(net
->ieee80211_ptr
->wiphy
);
3942 PRINT_D(INIT_DBG
, "Freeing wiphy\n");
3943 wiphy_free(net
->ieee80211_ptr
->wiphy
);
3944 kfree(net
->ieee80211_ptr
);