qcacld-3.0: Convert tx packet send time to Monotonic time
User space timestamping tool expecting Tx packet send time in Monotonic time and host is sending Tx packet send time in Qtime. Currently Qtime is always higher than System monotonic time, This change is to calculate the drift between Qtime and System monotonic time during tsf init and adjust calculated drift to each Tx packet send Qtime to make Qtime and System monotonic time are in sync. Change-Id: Ibd686d5fdea6ebcbc0fe5b37c4211cb8dd073d76 CRs-Fixed: 3230594
This commit is contained in:

committed by
Madan Koyyalamudi

parent
a158d65b8a
commit
f3afa36efa
@@ -1292,6 +1292,7 @@ enum qdisc_filter_status {
|
|||||||
* @is_virtual_iface: Indicates that netdev is called from virtual interface
|
* @is_virtual_iface: Indicates that netdev is called from virtual interface
|
||||||
* @mon_adapter: hdd_adapter of monitor mode.
|
* @mon_adapter: hdd_adapter of monitor mode.
|
||||||
* @set_mac_addr_req_ctx: Set MAC address command request context
|
* @set_mac_addr_req_ctx: Set MAC address command request context
|
||||||
|
* @delta_qtime: delta between host qtime and monotonic time
|
||||||
*/
|
*/
|
||||||
struct hdd_adapter {
|
struct hdd_adapter {
|
||||||
/* Magic cookie for adapter sanity verification. Note that this
|
/* Magic cookie for adapter sanity verification. Note that this
|
||||||
@@ -1607,6 +1608,7 @@ struct hdd_adapter {
|
|||||||
#ifdef WLAN_FEATURE_DYNAMIC_MAC_ADDR_UPDATE
|
#ifdef WLAN_FEATURE_DYNAMIC_MAC_ADDR_UPDATE
|
||||||
void *set_mac_addr_req_ctx;
|
void *set_mac_addr_req_ctx;
|
||||||
#endif
|
#endif
|
||||||
|
int64_t delta_qtime;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define WLAN_HDD_GET_STATION_CTX_PTR(adapter) (&(adapter)->session.station)
|
#define WLAN_HDD_GET_STATION_CTX_PTR(adapter) (&(adapter)->session.station)
|
||||||
|
@@ -1468,6 +1468,7 @@ static enum hdd_tsf_op_result hdd_tsf_sync_init(struct hdd_adapter *adapter)
|
|||||||
QDF_STATUS ret;
|
QDF_STATUS ret;
|
||||||
struct hdd_context *hddctx;
|
struct hdd_context *hddctx;
|
||||||
struct net_device *net_dev;
|
struct net_device *net_dev;
|
||||||
|
uint64_t host_time, qtime;
|
||||||
|
|
||||||
if (!adapter)
|
if (!adapter)
|
||||||
return HDD_TSF_OP_FAIL;
|
return HDD_TSF_OP_FAIL;
|
||||||
@@ -1511,6 +1512,14 @@ static enum hdd_tsf_op_result hdd_tsf_sync_init(struct hdd_adapter *adapter)
|
|||||||
device_create_file(&net_dev->dev, &dev_attr_tsf);
|
device_create_file(&net_dev->dev, &dev_attr_tsf);
|
||||||
hdd_set_th_sync_status(adapter, true);
|
hdd_set_th_sync_status(adapter, true);
|
||||||
|
|
||||||
|
qtime = qdf_get_log_timestamp();
|
||||||
|
host_time = hdd_get_monotonic_host_time(hddctx);
|
||||||
|
|
||||||
|
qtime = qdf_log_timestamp_to_usecs(qtime);
|
||||||
|
do_div(host_time, NSEC_PER_USEC);
|
||||||
|
|
||||||
|
adapter->delta_qtime = (qtime - host_time) * NSEC_PER_USEC;
|
||||||
|
|
||||||
return HDD_TSF_OP_SUCC;
|
return HDD_TSF_OP_SUCC;
|
||||||
fail:
|
fail:
|
||||||
hdd_set_th_sync_status(adapter, false);
|
hdd_set_th_sync_status(adapter, false);
|
||||||
@@ -1774,10 +1783,18 @@ enum hdd_tsf_op_result hdd_netbuf_timestamp(qdf_nbuf_t netbuf,
|
|||||||
int32_t ret = hdd_get_soctime_from_tsf64time(adapter,
|
int32_t ret = hdd_get_soctime_from_tsf64time(adapter,
|
||||||
tsf64_time, &soc_time);
|
tsf64_time, &soc_time);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
hwtstamps.hwtstamp = soc_time;
|
/* Adjust delta_qtime to soc_time(Qtime), so that
|
||||||
|
* System Monotonic time and Qtime are in sync.
|
||||||
|
*/
|
||||||
|
if (soc_time > (adapter->delta_qtime)) {
|
||||||
|
hwtstamps.hwtstamp =
|
||||||
|
soc_time - (adapter->delta_qtime);
|
||||||
*skb_hwtstamps(netbuf) = hwtstamps;
|
*skb_hwtstamps(netbuf) = hwtstamps;
|
||||||
netbuf->tstamp = ktime_set(0, 0);
|
netbuf->tstamp = ktime_set(0, 0);
|
||||||
return HDD_TSF_OP_SUCC;
|
return HDD_TSF_OP_SUCC;
|
||||||
|
} else {
|
||||||
|
return HDD_TSF_OP_FAIL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user