Jelajahi Sumber

qcacld-3.0: Use system time instead of jiffies for BSS received time

qcacld-2.0 to qcacld-3.0 propagation

During late suspend jiffies will not be incremented. Because of this
scan results are not age out as the delta of current time and the BSS
received time is not correct.

To address this, use the system time instead of jiffies for the
BSS received time and also make sure to use system time in all
other functions.

CRs-Fixed: 1018460
Change-Id: Ia14b84f1039dc4ffec6ad63550fed21e932f8012
Deepthi Gowri 8 tahun lalu
induk
melakukan
e2e3dfd997

+ 2 - 2
core/hdd/inc/wlan_hdd_main.h

@@ -1070,10 +1070,10 @@ struct hdd_adapter_s {
 	int temperature;
 
 	/* Time stamp for last completed RoC request */
-	unsigned long last_roc_ts;
+	uint64_t last_roc_ts;
 
 	/* Time stamp for start RoC request */
-	unsigned long start_roc_ts;
+	uint64_t start_roc_ts;
 
 	/* State for synchronous OCB requests to WMI */
 	struct sir_ocb_set_config_response ocb_set_config_resp;

+ 8 - 2
core/hdd/src/wlan_hdd_cfg80211.c

@@ -10594,8 +10594,14 @@ struct cfg80211_bss *wlan_hdd_cfg80211_inform_bss_frame(hdd_adapter_t *pAdapter,
 	qie_age->oui_2 = QCOM_OUI2;
 	qie_age->oui_3 = QCOM_OUI3;
 	qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
+	/*
+	 * Lowi expects the timestamp of bss in units of 1/10 ms. In driver
+	 * all bss related timestamp is in units of ms. Due to this when scan
+	 * results are sent to lowi the scan age is high.To address this,
+	 * send age in units of 1/10 ms.
+	 */
 	qie_age->age =
-		qdf_mc_timer_get_system_ticks() - bss_desc->nReceivedTime;
+		(qdf_mc_timer_get_system_time() - bss_desc->received_time)/10;
 	qie_age->tsf_delta = bss_desc->tsf_delta;
 	memcpy(&qie_age->beacon_tsf, bss_desc->timeStamp,
 	       sizeof(qie_age->beacon_tsf));
@@ -10769,7 +10775,7 @@ int wlan_hdd_cfg80211_update_bss(struct wiphy *wiphy,
 		 */
 		if ((scan_time == 0) ||
 			(scan_time <
-				pScanResult->BssDescriptor.nReceivedTime)) {
+				pScanResult->BssDescriptor.received_time)) {
 			bss_status =
 				wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
 						&pScanResult->BssDescriptor);

+ 3 - 3
core/hdd/src/wlan_hdd_ipa.c

@@ -362,7 +362,7 @@ static uint8_t vdev_to_iface[CSR_ROAM_SESSION_MAX];
  * @rx_destructor_call: IPA Rx packet destructor count
  */
 struct uc_rt_debug_info {
-	unsigned long time;
+	uint64_t time;
 	uint64_t ipa_excep_count;
 	uint64_t rx_drop_count;
 	uint64_t net_sent_count;
@@ -726,7 +726,7 @@ static void hdd_ipa_uc_rt_debug_host_fill(void *ctext)
 	dump_info = &hdd_ipa->rt_bug_buffer[
 		hdd_ipa->rt_buf_fill_index % HDD_IPA_UC_RT_DEBUG_BUF_COUNT];
 
-	dump_info->time = qdf_mc_timer_get_system_time();
+	dump_info->time = (uint64_t)qdf_mc_timer_get_system_time();
 	dump_info->ipa_excep_count = hdd_ipa->stats.num_rx_excep;
 	dump_info->rx_drop_count = hdd_ipa->ipa_rx_internel_drop_count;
 	dump_info->net_sent_count = hdd_ipa->ipa_rx_net_send_count;
@@ -779,7 +779,7 @@ void hdd_ipa_uc_rt_debug_host_dump(hdd_context_t *hdd_ctx)
 			HDD_IPA_UC_RT_DEBUG_BUF_COUNT;
 		dump_info = &hdd_ipa->rt_bug_buffer[dump_index];
 		HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR,
-			"%12lu:%10llu:%10llu:%10llu:%10llu:%10llu:%10llu:%10llu\n",
+			"%12llu:%10llu:%10llu:%10llu:%10llu:%10llu:%10llu:%10llu\n",
 			dump_info->time, dump_info->ipa_excep_count,
 			dump_info->rx_drop_count, dump_info->net_sent_count,
 			dump_info->tx_mcbc_count, dump_info->tx_fwd_count,

+ 6 - 4
core/hdd/src/wlan_hdd_p2p.c

@@ -215,7 +215,8 @@ QDF_STATUS wlan_hdd_remain_on_channel_callback(tHalHandle hHal, void *pCtx,
 			cookie,
 			&pRemainChanCtx->chan,
 			GFP_KERNEL);
-		pAdapter->last_roc_ts = qdf_mc_timer_get_system_time();
+		pAdapter->last_roc_ts =
+			(uint64_t)qdf_mc_timer_get_system_time();
 	}
 
 	/* Schedule any pending RoC: Any new roc request during this time
@@ -840,7 +841,7 @@ static int wlan_hdd_request_remain_on_channel(struct wiphy *wiphy,
 			hdd_conn_is_connected(
 				WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter))) {
 			if (pAdapter->last_roc_ts != 0 &&
-				((qdf_mc_timer_get_system_time() -
+				(((uint64_t)qdf_mc_timer_get_system_time() -
 					 pAdapter->last_roc_ts) <
 				pHddCtx->config->p2p_listen_defer_interval)) {
 			if (pRemainChanCtx->duration > HDD_P2P_MAX_ROC_DURATION)
@@ -961,7 +962,7 @@ void hdd_remain_chan_ready_handler(hdd_adapter_t *pAdapter,
 	cfgState = WLAN_HDD_GET_CFG_STATE_PTR(pAdapter);
 	hdd_notice("Ready on chan ind %d", scan_id);
 
-	pAdapter->start_roc_ts = qdf_mc_timer_get_system_time();
+	pAdapter->start_roc_ts = (uint64_t)qdf_mc_timer_get_system_time();
 	mutex_lock(&cfgState->remain_on_chan_ctx_lock);
 	pRemainChanCtx = cfgState->remain_on_chan_ctx;
 	if (pRemainChanCtx != NULL) {
@@ -1270,7 +1271,8 @@ static int __wlan_hdd_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
 		mutex_lock(&cfgState->remain_on_chan_ctx_lock);
 		if (cfgState->remain_on_chan_ctx) {
 
-			uint32_t current_time = qdf_mc_timer_get_system_time();
+			uint64_t current_time =
+				(uint64_t)qdf_mc_timer_get_system_time();
 			int remaining_roc_time =
 				((int) cfgState->remain_on_chan_ctx->duration -
 				(current_time - pAdapter->start_roc_ts));

+ 3 - 3
core/hdd/src/wlan_hdd_scan.c

@@ -482,9 +482,9 @@ static int hdd_indicate_scan_result(hdd_scan_info_t *scanInfo,
 	/* AGE */
 	event.cmd = IWEVCUSTOM;
 	p = custom;
-	p += scnprintf(p, MAX_CUSTOM_LEN, " Age: %lu",
-		       qdf_mc_timer_get_system_ticks() -
-		       descriptor->nReceivedTime);
+	p += scnprintf(p, MAX_CUSTOM_LEN, " Age: %llu",
+		       qdf_mc_timer_get_system_time() -
+		       descriptor->received_time);
 	event.u.data.length = p - custom;
 	current_event = iwe_stream_add_point(scanInfo->info, current_event, end,
 					     &event, custom);

+ 2 - 2
core/mac/inc/sir_api.h

@@ -724,8 +724,8 @@ typedef struct sSirBssDescription {
 	/* used only in scan case. */
 	uint8_t channelIdSelf;
 	uint8_t sSirBssDescriptionRsvd[3];
-	/* base on a tick count. It is a time stamp, not a relative time. */
-	uint32_t nReceivedTime;
+	/* Based on system time, not a relative time. */
+	uint64_t received_time;
 	uint32_t parentTSF;
 	uint32_t startTSF[2];
 	uint8_t mdiePresent;

+ 2 - 2
core/mac/src/pe/lim/lim_api.c

@@ -1871,8 +1871,8 @@ lim_roam_fill_bss_descr(tpAniSirGlobal pMac,
 	qdf_mem_copy((uint8_t *) &bss_desc_ptr->bssId,
 			(uint8_t *) mac_hdr->bssId,
 			sizeof(tSirMacAddr));
-	bss_desc_ptr->nReceivedTime =
-		(uint32_t)qdf_mc_timer_get_system_ticks();
+	bss_desc_ptr->received_time =
+		      (uint64_t)qdf_mc_timer_get_system_time();
 	if (parsed_frm_ptr->mdiePresent) {
 		bss_desc_ptr->mdiePresent = parsed_frm_ptr->mdiePresent;
 		qdf_mem_copy((uint8_t *)bss_desc_ptr->mdie,

+ 4 - 4
core/mac/src/pe/lim/lim_p2p.c

@@ -175,11 +175,11 @@ void lim_process_insert_single_shot_noa_timeout(tpAniSirGlobal pMac)
  *------------------------------------------------------------------*/
 void lim_convert_active_channel_to_passive_channel(tpAniSirGlobal pMac)
 {
-	uint32_t currentTime;
-	uint32_t lastTime = 0;
-	uint32_t timeDiff;
+	uint64_t currentTime;
+	uint64_t lastTime = 0;
+	uint64_t timeDiff;
 	uint8_t i;
-	currentTime = qdf_mc_timer_get_system_time();
+	currentTime = (uint64_t)qdf_mc_timer_get_system_time();
 	for (i = 1; i < SIR_MAX_24G_5G_CHANNEL_RANGE; i++) {
 		if ((pMac->lim.dfschannelList.timeStamp[i]) != 0) {
 			lastTime = pMac->lim.dfschannelList.timeStamp[i];

+ 3 - 3
core/mac/src/pe/lim/lim_scan_result_utils.c

@@ -177,14 +177,14 @@ lim_collect_bss_description(tpAniSirGlobal pMac,
 		MAC_ADDR_ARRAY(pHdr->bssId), pBssDescr->rssi,
 		pBssDescr->rssi_raw);
 
-	pBssDescr->nReceivedTime = (uint32_t) qdf_mc_timer_get_system_ticks();
+	pBssDescr->received_time = (uint64_t)qdf_mc_timer_get_system_time();
 	pBssDescr->tsf_delta = WMA_GET_RX_TSF_DELTA(pRxPacketInfo);
 	pBssDescr->seq_ctrl = pHdr->seqControl;
 
 	lim_log(pMac, LOG1,
-		  FL("BSSID: "MAC_ADDRESS_STR " tsf_delta = %u ReceivedTime = %u ssid = %s"),
+		  FL("BSSID: "MAC_ADDRESS_STR " tsf_delta = %u ReceivedTime = %llu ssid = %s"),
 		  MAC_ADDR_ARRAY(pHdr->bssId), pBssDescr->tsf_delta,
-		  pBssDescr->nReceivedTime,
+		  pBssDescr->received_time,
 		  ((pBPR->ssidPresent) ? (char *)pBPR->ssId.ssId : ""));
 
 	lim_log(pMac, LOG1, FL("Seq Ctrl: Frag Num: %d, Seq Num: LO:%02x HI:%02x"),

+ 19 - 21
core/sme/src/csr/csr_api_scan.c

@@ -2858,8 +2858,8 @@ static void csr_purge_old_scan_results(tpAniSirGlobal mac_ctx)
 {
 	tListElem *pentry, *tmp_entry;
 	tCsrScanResult *presult, *oldest_bss = NULL;
-	uint32_t oldest_entry = 0;
-	uint32_t curr_time = qdf_mc_timer_get_system_ticks();
+	uint64_t oldest_entry = 0;
+	uint64_t curr_time = (uint64_t)qdf_mc_timer_get_system_time();
 
 	csr_ll_unlock(&mac_ctx->scan.scanResultList);
 	pentry = csr_ll_peek_head(&mac_ctx->scan.scanResultList,
@@ -2868,10 +2868,10 @@ static void csr_purge_old_scan_results(tpAniSirGlobal mac_ctx)
 		tmp_entry = csr_ll_next(&mac_ctx->scan.scanResultList, pentry,
 			LL_ACCESS_NOLOCK);
 		presult = GET_BASE_ADDR(pentry, tCsrScanResult, Link);
-		if ((curr_time - presult->Result.BssDescriptor.nReceivedTime) >
+		if ((curr_time - presult->Result.BssDescriptor.received_time) >
 		     oldest_entry) {
 			oldest_entry = curr_time -
-				presult->Result.BssDescriptor.nReceivedTime;
+				presult->Result.BssDescriptor.received_time;
 			oldest_bss = presult;
 		}
 		pentry = tmp_entry;
@@ -2881,9 +2881,9 @@ static void csr_purge_old_scan_results(tpAniSirGlobal mac_ctx)
 		if (csr_ll_remove_entry(&mac_ctx->scan.scanResultList,
 		    &oldest_bss->Link, LL_ACCESS_NOLOCK)) {
 			sms_log(mac_ctx, LOG1,
-				FL("Current time delta (%d) of BSSID to be removed" MAC_ADDRESS_STR),
+				FL("Current time delta (%llu) of BSSID to be removed" MAC_ADDRESS_STR),
 				(curr_time -
-				oldest_bss->Result.BssDescriptor.nReceivedTime),
+				oldest_bss->Result.BssDescriptor.received_time),
 				MAC_ADDR_ARRAY(
 				oldest_bss->Result.BssDescriptor.bssId));
 			csr_free_scan_result_entry(mac_ctx, oldest_bss);
@@ -2961,8 +2961,9 @@ csr_remove_from_tmp_list(tpAniSirGlobal mac_ctx,
 			 * hidden ssid from the profile i.e., forget the SSID
 			 * via GUI that SSID shouldn't see in the profile
 			 */
-			unsigned long time_gap = qdf_mc_timer_get_system_time() -
-									timer;
+			uint64_t time_gap =
+				(uint64_t)qdf_mc_timer_get_system_time() -
+									 timer;
 			if ((0 == bss_dscp->Result.ssId.length)
 			    && (time_gap <= HIDDEN_TIMER)
 			    && tmpSsid.length) {
@@ -3097,7 +3098,7 @@ tCsrScanResult *csr_scan_append_bss_description(tpAniSirGlobal pMac,
 			 * hidden ssid from the profile i.e., forget the SSID
 			 * via GUI that SSID shouldn't see in the profile
 			 */
-			if ((qdf_mc_timer_get_system_time() - timer) <=
+			if (((uint64_t)qdf_mc_timer_get_system_time() - timer) <=
 			    HIDDEN_TIMER) {
 				pCsrBssDescription->Result.ssId = tmpSsid;
 				pCsrBssDescription->Result.timer = timer;
@@ -4887,8 +4888,8 @@ static bool csr_scan_age_out_bss(tpAniSirGlobal pMac, tCsrScanResult *pResult)
 			FL("Connected BSS, Set Aging Count=%d for BSS "
 			   MAC_ADDRESS_STR), pResult->AgingCount,
 			MAC_ADDR_ARRAY(pResult->Result.BssDescriptor.bssId));
-		pResult->Result.BssDescriptor.nReceivedTime =
-			(uint32_t) qdf_mc_timer_get_system_ticks();
+		pResult->Result.BssDescriptor.received_time =
+			(uint64_t)qdf_mc_timer_get_system_time();
 		return fRet;
 	}
 	/*
@@ -5941,23 +5942,20 @@ static void csr_purge_scan_result_by_age(void *pv)
 	tpAniSirGlobal mac_ctx = PMAC_STRUCT(pv);
 	tListElem *entry, *tmp_entry;
 	tCsrScanResult *result;
-	unsigned long ageout_time =
-		mac_ctx->scan.scanResultCfgAgingTime * QDF_TICKS_PER_SECOND/10;
-	unsigned long cur_time =  qdf_mc_timer_get_system_ticks();
+	uint64_t ageout_time =
+		mac_ctx->scan.scanResultCfgAgingTime * SYSTEM_TIME_SEC_TO_MSEC;
+	uint64_t cur_time = qdf_mc_timer_get_system_time();
 	uint8_t *bssId;
 
 	csr_ll_lock(&mac_ctx->scan.scanResultList);
 	entry = csr_ll_peek_head(&mac_ctx->scan.scanResultList, LL_ACCESS_NOLOCK);
-	sms_log(mac_ctx, LOG1, FL(" Ageout time=%ld"), ageout_time);
+	sms_log(mac_ctx, LOG1, FL(" Ageout time=%llu"), ageout_time);
 	while (entry) {
 		tmp_entry = csr_ll_next(&mac_ctx->scan.scanResultList, entry,
 					LL_ACCESS_NOLOCK);
 		result = GET_BASE_ADDR(entry, tCsrScanResult, Link);
-		/*
-		 * qdf_mc_timer_get_system_ticks() returns in 10ms interval.
-		 * so ageout time value also updated to 10ms interval value.
-		 */
-		if ((cur_time - result->Result.BssDescriptor.nReceivedTime) >
+
+		if ((cur_time - result->Result.BssDescriptor.received_time) >
 			    ageout_time) {
 			bssId = result->Result.BssDescriptor.bssId;
 			sms_log(mac_ctx, LOGW,
@@ -7055,7 +7053,7 @@ QDF_STATUS csr_scan_save_preferred_network_found(tpAniSirGlobal pMac,
 	pBssDescr->capabilityInfo = *((uint16_t *)&parsed_frm->capabilityInfo);
 	qdf_mem_copy((uint8_t *) &pBssDescr->bssId,
 		     (uint8_t *) macHeader->bssId, sizeof(tSirMacAddr));
-	pBssDescr->nReceivedTime = (uint32_t) qdf_mc_timer_get_system_ticks();
+	pBssDescr->received_time = (uint64_t)qdf_mc_timer_get_system_time();
 	sms_log(pMac, LOG2, FL("Bssid= "MAC_ADDRESS_STR" chan= %d, rssi = %d"),
 		MAC_ADDR_ARRAY(pBssDescr->bssId), pBssDescr->channelId,
 		pBssDescr->rssi);

+ 5 - 6
core/sme/src/csr/csr_host_scan_roam.c

@@ -149,9 +149,7 @@ void csr_neighbor_roam_process_scan_results(tpAniSirGlobal mac_ctx,
 	tpCsrNeighborRoamControlInfo n_roam_info =
 		&mac_ctx->roam.neighborRoamInfo[sessionid];
 	tpCsrNeighborRoamBSSInfo bss_info;
-	uint32_t age_ticks = 0;
-	uint32_t limit_ticks =
-		qdf_system_msecs_to_ticks(ROAM_AP_AGE_LIMIT_MS);
+	uint64_t age = 0;
 	uint8_t num_candidates = 0;
 	uint8_t num_dropped = 0;
 	/*
@@ -296,9 +294,10 @@ void csr_neighbor_roam_process_scan_results(tpAniSirGlobal mac_ctx,
 			}
 
 			/* check the age of the AP */
-			age_ticks = (uint32_t) qdf_mc_timer_get_system_ticks() -
-					descr->nReceivedTime;
-			if (age_constraint == true && age_ticks > limit_ticks) {
+			age = (uint64_t) qdf_mc_timer_get_system_time() -
+					descr->received_time;
+			if (age_constraint == true &&
+				age > ROAM_AP_AGE_LIMIT_MS) {
 				num_dropped++;
 				QDF_TRACE(QDF_MODULE_ID_SME,
 					QDF_TRACE_LEVEL_WARN,

+ 1 - 0
core/sme/src/csr/csr_inside_api.h

@@ -66,6 +66,7 @@
 
 #define CSR_MAX_BSS_SUPPORT            512
 #define SYSTEM_TIME_MSEC_TO_USEC      1000
+#define SYSTEM_TIME_SEC_TO_MSEC       1000
 
 /* This number minus 1 means the number of times a channel is scanned before a BSS is remvoed from */
 /* cache scan result */

+ 6 - 6
core/sme/src/rrm/sme_rrm.c

@@ -71,7 +71,7 @@
 #define RRM_ROAM_SCORE_NEIGHBOR_IAPP_LIST                       30
 #endif
 
-unsigned long rrm_scan_timer;
+uint64_t rrm_scan_timer;
 
 /**
  * rrm_ll_purge_neighbor_cache() -Purges all the entries in the neighbor cache
@@ -532,7 +532,7 @@ static QDF_STATUS sme_rrm_send_scan_result(tpAniSirGlobal mac_ctx,
 
 	while (scan_results) {
 		next_result = sme_scan_result_get_next(mac_ctx, result_handle);
-		sms_log(mac_ctx, LOG1, "Scan res timer:%lu, rrm scan timer:%lu",
+		sms_log(mac_ctx, LOG1, "Scan res timer:%lu, rrm scan timer:%llu",
 				scan_results->timer, rrm_scan_timer);
 		if (scan_results->timer >= rrm_scan_timer) {
 			qdf_mem_zero(roam_info, sizeof(*roam_info));
@@ -655,7 +655,7 @@ static QDF_STATUS sme_rrm_issue_scan_req(tpAniSirGlobal mac_ctx)
 	tpRrmSMEContext sme_rrm_ctx = &mac_ctx->rrm.rrmSmeContext;
 	uint32_t session_id;
 	tSirScanType scan_type;
-	unsigned long current_time;
+	uint64_t current_time;
 
 	status = csr_roam_get_session_id_from_bssid(mac_ctx,
 			&sme_rrm_ctx->sessionBssId, &session_id);
@@ -726,8 +726,8 @@ static QDF_STATUS sme_rrm_issue_scan_req(tpAniSirGlobal mac_ctx)
 		 * and hence there is a check to see if the requests are atleast
 		 * 1 second apart.
 		 */
-		current_time = qdf_mc_timer_get_system_time();
-		sms_log(mac_ctx, LOG1, "prev scan triggered before %ld ms, totalchannels %d",
+		current_time = (uint64_t)qdf_mc_timer_get_system_time();
+		sms_log(mac_ctx, LOG1, "prev scan triggered before %llu ms, totalchannels %d",
 				current_time - rrm_scan_timer,
 				sme_rrm_ctx->channelList.numOfChannels);
 		if ((abs(current_time - rrm_scan_timer) > 1000) &&
@@ -737,7 +737,7 @@ static QDF_STATUS sme_rrm_issue_scan_req(tpAniSirGlobal mac_ctx)
 			scan_req.idle_time = 1;
 		}
 
-		rrm_scan_timer = qdf_mc_timer_get_system_time();
+		rrm_scan_timer = (uint64_t)qdf_mc_timer_get_system_time();
 
 		/* set BSSType to default type */
 		scan_req.BSSType = eCSR_BSS_TYPE_ANY;