From 8a711cbd49affcaac91e7c0d47f4a03fadcee4a0 Mon Sep 17 00:00:00 2001 From: Arun Khandavalli Date: Tue, 3 Jan 2017 20:23:56 +0530 Subject: [PATCH] qcacld-3.0: update timestamp of bss while informing frame to kernel Inform the bss using the new API cfg80211_inform_bss_frame_data() which also has the ability to inform the timestamp when the frame has been received. If the support is not present in the kernel fallback to the legacy inform bss. Change-Id: Iaa512248a5e56d77cff39da562e0c9ee4eaeeefd CRs-Fixed: 1082423 --- core/hdd/src/wlan_hdd_cfg80211.c | 43 +++++++++++++++++++-- core/mac/inc/sir_api.h | 2 +- core/mac/src/pe/lim/lim_scan_result_utils.c | 2 +- core/sme/src/csr/csr_api_roam.c | 10 ++--- core/sme/src/csr/csr_api_scan.c | 4 +- core/sme/src/csr/csr_inside_api.h | 3 +- 6 files changed, 51 insertions(+), 13 deletions(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 5e0f4661d5af..e1d9c446fb7e 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -12170,6 +12170,42 @@ struct cfg80211_bss *wlan_hdd_cfg80211_update_bss_list( return bss; } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4 , 3, 0)) || \ + defined (CFG80211_INFORM_BSS_FRAME_DATA) +static struct cfg80211_bss * +wlan_hdd_cfg80211_inform_bss_frame_data(struct wiphy *wiphy, + struct ieee80211_channel *chan, + struct ieee80211_mgmt *mgmt, + size_t frame_len, + int rssi, gfp_t gfp, + uint64_t boottime_ns) +{ + struct cfg80211_bss *bss_status = NULL; + struct cfg80211_inform_bss data = {0}; + + data.chan = chan; + data.boottime_ns = boottime_ns; + data.signal = rssi; + bss_status = cfg80211_inform_bss_frame_data(wiphy, &data, mgmt, + frame_len, gfp); + return bss_status; +} +#else +static struct cfg80211_bss * +wlan_hdd_cfg80211_inform_bss_frame_data(struct wiphy *wiphy, + struct ieee80211_channel *chan, + struct ieee80211_mgmt *mgmt, + size_t frame_len, + int rssi, gfp_t gfp, + uint64_t boottime_ns) +{ + struct cfg80211_bss *bss_status = NULL; + + bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt, frame_len, + rssi, gfp); + return bss_status; +} +#endif /** * wlan_hdd_cfg80211_inform_bss_frame() - inform bss details to NL80211 @@ -12335,9 +12371,10 @@ struct cfg80211_bss *wlan_hdd_cfg80211_inform_bss_frame(hdd_adapter_t *pAdapter, (int)(rssi / 100), bss_desc->timeStamp[0]); - bss_status = - cfg80211_inform_bss_frame(wiphy, chan, mgmt, frame_len, rssi, - GFP_KERNEL); + bss_status = wlan_hdd_cfg80211_inform_bss_frame_data(wiphy, chan, mgmt, + frame_len, rssi, + GFP_KERNEL, + bss_desc->scansystimensec); pHddCtx->beacon_probe_rsp_cnt_per_scan++; qdf_mem_free(mgmt); return bss_status; diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h index da4acaa8f244..ee97df57984a 100644 --- a/core/mac/inc/sir_api.h +++ b/core/mac/inc/sir_api.h @@ -711,7 +711,7 @@ typedef struct sSirBssDescription { /* offset of the ieFields from bssId. */ uint16_t length; tSirMacAddr bssId; - unsigned long scanSysTimeMsec; + unsigned long scansystimensec; uint32_t timeStamp[2]; uint16_t beaconInterval; uint16_t capabilityInfo; diff --git a/core/mac/src/pe/lim/lim_scan_result_utils.c b/core/mac/src/pe/lim/lim_scan_result_utils.c index cda5ed4fb959..07aa75c26bf9 100644 --- a/core/mac/src/pe/lim/lim_scan_result_utils.c +++ b/core/mac/src/pe/lim/lim_scan_result_utils.c @@ -115,7 +115,7 @@ lim_collect_bss_description(tpAniSirGlobal pMac, (uint8_t *) pHdr->bssId, sizeof(tSirMacAddr)); /* Copy Timestamp, Beacon Interval and Capability Info */ - pBssDescr->scanSysTimeMsec = qdf_mc_timer_get_system_time(); + pBssDescr->scansystimensec = qdf_get_monotonic_boottime_ns(); pBssDescr->timeStamp[0] = pBPR->timeStamp[0]; pBssDescr->timeStamp[1] = pBPR->timeStamp[1]; diff --git a/core/sme/src/csr/csr_api_roam.c b/core/sme/src/csr/csr_api_roam.c index 3fa97920076f..8c99e488a932 100644 --- a/core/sme/src/csr/csr_api_roam.c +++ b/core/sme/src/csr/csr_api_roam.c @@ -1971,16 +1971,16 @@ QDF_STATUS csr_roam_read_tsf(tpAniSirGlobal pMac, uint8_t *pTimestamp, { QDF_STATUS status = QDF_STATUS_SUCCESS; tCsrNeighborRoamBSSInfo handoffNode = {{0} }; - uint32_t timer_diff = 0; + uint64_t timer_diff = 0; uint32_t timeStamp[2]; tpSirBssDescription pBssDescription = NULL; csr_neighbor_roam_get_handoff_ap_info(pMac, &handoffNode, sessionId); pBssDescription = handoffNode.pBssDescription; - /* Get the time diff in milli seconds */ - timer_diff = qdf_mc_timer_get_system_time() - - pBssDescription->scanSysTimeMsec; + /* Get the time diff in nano seconds */ + timer_diff = (qdf_get_monotonic_boottime_ns() - + pBssDescription->scansystimensec); /* Convert msec to micro sec timer */ - timer_diff = (uint32_t) (timer_diff * SYSTEM_TIME_MSEC_TO_USEC); + timer_diff = (timer_diff / SYSTEM_TIME_NSEC_TO_USEC); timeStamp[0] = pBssDescription->timeStamp[0]; timeStamp[1] = pBssDescription->timeStamp[1]; update_cckmtsf(&(timeStamp[0]), &(timeStamp[1]), &timer_diff); diff --git a/core/sme/src/csr/csr_api_scan.c b/core/sme/src/csr/csr_api_scan.c index b965f70e65a6..f43c0b223b45 100644 --- a/core/sme/src/csr/csr_api_scan.c +++ b/core/sme/src/csr/csr_api_scan.c @@ -7305,10 +7305,10 @@ free_mem: #ifdef FEATURE_WLAN_ESE /* Update the TSF with the difference in system time */ void update_cckmtsf(uint32_t *timeStamp0, uint32_t *timeStamp1, - uint32_t *incr) + uint64_t *incr) { uint64_t timeStamp64 = ((uint64_t) *timeStamp1 << 32) | (*timeStamp0); - timeStamp64 = (uint64_t) (timeStamp64 + (uint64_t) *incr); + timeStamp64 = (uint64_t)(timeStamp64 + (*incr)); *timeStamp0 = (uint32_t) (timeStamp64 & 0xffffffff); *timeStamp1 = (uint32_t) ((timeStamp64 >> 32) & 0xffffffff); } diff --git a/core/sme/src/csr/csr_inside_api.h b/core/sme/src/csr/csr_inside_api.h index 2ee4b20f87fc..b95060daf91e 100644 --- a/core/sme/src/csr/csr_inside_api.h +++ b/core/sme/src/csr/csr_inside_api.h @@ -67,6 +67,7 @@ #define CSR_MAX_BSS_SUPPORT 512 #define SYSTEM_TIME_MSEC_TO_USEC 1000 #define SYSTEM_TIME_SEC_TO_MSEC 1000 +#define SYSTEM_TIME_NSEC_TO_USEC 1000 /* This number minus 1 means the number of times a channel is scanned before a BSS is remvoed from */ /* cache scan result */ @@ -996,7 +997,7 @@ static inline void csr_release_command_preauth(tpAniSirGlobal mac_ctx, #if defined(FEATURE_WLAN_ESE) void update_cckmtsf(uint32_t *timeStamp0, uint32_t *timeStamp1, - uint32_t *incr); + uint64_t *incr); #endif QDF_STATUS csr_roam_enqueue_preauth(tpAniSirGlobal pMac, uint32_t sessionId,