qcacld-3.0: Add sysfs entry to display ftm time sync offset
Add the sysfs entry ftm_time_sync in STA mode to show the offset derived for the STA(slave) with respect to connected AP(master). Change-Id: I05b16ccdb983c53fb86eeb14ba98bd3cc9a2dce6 CRs-Fixed: 2621152
This commit is contained in:

committed by
nshrivas

parent
21ca52c9e4
commit
4eaa25c659
4
Kbuild
4
Kbuild
@@ -277,6 +277,10 @@ ifeq ($(CONFIG_QCACLD_FEATURE_BTC_CHAIN_MODE), y)
|
||||
HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_btc_chain_mode.o
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_FEATURE_WLAN_TIME_SYNC_FTM), y)
|
||||
HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_ftm_time_sync.o
|
||||
endif
|
||||
|
||||
###### OSIF_SYNC ########
|
||||
SYNC_DIR := os_if/sync
|
||||
SYNC_INC_DIR := $(SYNC_DIR)/inc
|
||||
|
@@ -160,4 +160,12 @@ QDF_STATUS ftm_time_sync_send_trigger(struct wlan_objmgr_vdev *vdev);
|
||||
*/
|
||||
QDF_STATUS ftm_time_sync_stop(struct wlan_objmgr_vdev *vdev);
|
||||
|
||||
/**
|
||||
* ftm_time_sync_show() - Handler to print the offset derived
|
||||
* @vdev: vdev for which offset is to be shown
|
||||
* @buf: buffer in which the values to be printed
|
||||
*
|
||||
* Return: the number of bytes written in buf
|
||||
*/
|
||||
ssize_t ftm_time_sync_show(struct wlan_objmgr_vdev *vdev, char *buf);
|
||||
#endif /* end of _FTM_TIME_SYNC_MAIN_H_ */
|
||||
|
@@ -372,3 +372,30 @@ QDF_STATUS ftm_time_sync_stop(struct wlan_objmgr_vdev *vdev)
|
||||
|
||||
return QDF_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
ssize_t ftm_time_sync_show(struct wlan_objmgr_vdev *vdev, char *buf)
|
||||
{
|
||||
struct ftm_time_sync_vdev_priv *vdev_priv;
|
||||
uint64_t q_master, q_slave;
|
||||
ssize_t size = 0;
|
||||
int iter;
|
||||
|
||||
vdev_priv = ftm_time_sync_vdev_get_priv(vdev);
|
||||
if (!vdev_priv) {
|
||||
ftm_time_sync_debug("Failed to get ftm time sync vdev_priv");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (iter = 0; iter < vdev_priv->num_qtime_pair; iter++) {
|
||||
q_master = vdev_priv->ftm_ts_priv.time_pair[iter].qtime_master;
|
||||
q_slave = vdev_priv->ftm_ts_priv.time_pair[iter].qtime_slave;
|
||||
|
||||
size += qdf_scnprintf(buf + size, PAGE_SIZE,
|
||||
"%s %llu %s %llu %s %lld\n",
|
||||
"Qtime_master", q_master, "Qtime_slave",
|
||||
q_slave, "Offset", q_slave > q_master ?
|
||||
q_slave - q_master : q_master - q_slave);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
|
@@ -96,6 +96,18 @@ ucfg_ftm_time_sync_update_sta_connect_state(struct wlan_objmgr_vdev *vdev,
|
||||
*/
|
||||
void ucfg_ftm_time_sync_update_bss_state(struct wlan_objmgr_vdev *vdev,
|
||||
enum ftm_time_sync_bss_state ap_state);
|
||||
|
||||
/**
|
||||
* ucfg_ftm_time_sync_show() - Show the ftm time sync offset values derived
|
||||
* @vdev: vdev context
|
||||
* @buf: buffer in which the values to be written
|
||||
*
|
||||
* This function prints the offset values derived after ftm time sync
|
||||
* between the qtime of STA(slave) and connected SAP(master).
|
||||
*
|
||||
* Return: number of bytes written in buffer
|
||||
*/
|
||||
ssize_t ucfg_ftm_time_sync_show(struct wlan_objmgr_vdev *vdev, char *buf);
|
||||
#else
|
||||
|
||||
static inline
|
||||
@@ -131,5 +143,11 @@ ucfg_ftm_time_sync_update_bss_state(struct wlan_objmgr_vdev *vdev,
|
||||
enum ftm_time_sync_bss_state ap_state)
|
||||
{
|
||||
}
|
||||
|
||||
static inline
|
||||
ssize_t ucfg_ftm_time_sync_show(struct wlan_objmgr_vdev *vdev, char *buf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* FEATURE_WLAN_TIME_SYNC_FTM */
|
||||
#endif /* _FTM_TIME_SYNC_UCFG_API_H_ */
|
||||
|
@@ -166,3 +166,8 @@ void ucfg_ftm_time_sync_update_bss_state(struct wlan_objmgr_vdev *vdev,
|
||||
ftm_time_sync_stop(vdev);
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t ucfg_ftm_time_sync_show(struct wlan_objmgr_vdev *vdev, char *buf)
|
||||
{
|
||||
return ftm_time_sync_show(vdev, buf);
|
||||
}
|
||||
|
43
core/hdd/inc/wlan_hdd_ftm_time_sync.h
Normal file
43
core/hdd/inc/wlan_hdd_ftm_time_sync.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2020, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "ftm_time_sync_ucfg_api.h"
|
||||
#include "wlan_hdd_main.h"
|
||||
|
||||
#ifdef FEATURE_WLAN_TIME_SYNC_FTM
|
||||
/**
|
||||
* hdd_ftm_time_sync_sta_state_notify() - notify FTM TIME SYNC sta state change
|
||||
* @adapter: pointer to adapter
|
||||
* @state: enum ftm_time_sync_sta_state
|
||||
*
|
||||
* This function is called by hdd connect and disconnect handler and notifies
|
||||
* the FTM TIME SYNC component about the sta state.
|
||||
*
|
||||
* Return: None
|
||||
*/
|
||||
void
|
||||
hdd_ftm_time_sync_sta_state_notify(struct hdd_adapter *adapter,
|
||||
enum ftm_time_sync_sta_state state);
|
||||
|
||||
#else
|
||||
|
||||
static inline void
|
||||
hdd_ftm_time_sync_sta_state_notify(struct hdd_adapter *adapter,
|
||||
enum ftm_time_sync_sta_state state)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
@@ -71,7 +71,7 @@
|
||||
#include <wlan_crypto_global_api.h>
|
||||
#include "wlan_blm_ucfg_api.h"
|
||||
#include "wlan_hdd_sta_info.h"
|
||||
#include "ftm_time_sync_ucfg_api.h"
|
||||
#include "wlan_hdd_ftm_time_sync.h"
|
||||
|
||||
#include <ol_defines.h>
|
||||
|
||||
@@ -1669,32 +1669,6 @@ static void hdd_print_bss_info(struct hdd_station_ctx *hdd_sta_ctx)
|
||||
conn_info->hs20vendor_ie.release_num : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* hdd_ftm_time_sync_sta_state_notify() - notify FTM TIME SYNC sta state change
|
||||
* @adapter: pointer to adapter
|
||||
* @state: enum ftm_time_sync_sta_state
|
||||
*
|
||||
* This function is called by hdd connect and disconnect handler and notifies
|
||||
* the FTM TIME SYNC component about the sta state.
|
||||
*
|
||||
* Return: None
|
||||
*/
|
||||
static void
|
||||
hdd_ftm_time_sync_sta_state_notify(struct hdd_adapter *adapter,
|
||||
enum ftm_time_sync_sta_state state)
|
||||
{
|
||||
struct wlan_objmgr_psoc *psoc;
|
||||
|
||||
psoc = wlan_vdev_get_psoc(adapter->vdev);
|
||||
if (!psoc)
|
||||
return;
|
||||
|
||||
if (!ucfg_is_ftm_time_sync_enable(psoc))
|
||||
return;
|
||||
|
||||
ucfg_ftm_time_sync_update_sta_connect_state(adapter->vdev, state);
|
||||
}
|
||||
|
||||
/**
|
||||
* hdd_dis_connect_handler() - disconnect event handler
|
||||
* @adapter: pointer to adapter
|
||||
|
69
core/hdd/src/wlan_hdd_ftm_time_sync.c
Normal file
69
core/hdd/src/wlan_hdd_ftm_time_sync.c
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2020, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "wlan_hdd_ftm_time_sync.h"
|
||||
#include "ftm_time_sync_ucfg_api.h"
|
||||
|
||||
static ssize_t hdd_ftm_time_sync_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct hdd_station_ctx *hdd_sta_ctx;
|
||||
struct hdd_adapter *adapter;
|
||||
ssize_t size = 0;
|
||||
|
||||
struct net_device *net_dev = qdf_container_of(dev, struct net_device,
|
||||
dev);
|
||||
|
||||
adapter = (struct hdd_adapter *)(netdev_priv(net_dev));
|
||||
if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)
|
||||
return scnprintf(buf, PAGE_SIZE, "Invalid device\n");
|
||||
|
||||
hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
|
||||
if (adapter->device_mode == QDF_STA_MODE)
|
||||
return ucfg_ftm_time_sync_show(adapter->vdev, buf);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(ftm_time_sync, 0400, hdd_ftm_time_sync_show, NULL);
|
||||
|
||||
void
|
||||
hdd_ftm_time_sync_sta_state_notify(struct hdd_adapter *adapter,
|
||||
enum ftm_time_sync_sta_state state)
|
||||
{
|
||||
struct wlan_objmgr_psoc *psoc;
|
||||
struct net_device *net_dev;
|
||||
|
||||
psoc = wlan_vdev_get_psoc(adapter->vdev);
|
||||
if (!psoc)
|
||||
return;
|
||||
|
||||
if (!ucfg_is_ftm_time_sync_enable(psoc))
|
||||
return;
|
||||
|
||||
net_dev = adapter->dev;
|
||||
|
||||
if (net_dev) {
|
||||
if (state == FTM_TIME_SYNC_STA_CONNECTED)
|
||||
device_create_file(&net_dev->dev,
|
||||
&dev_attr_ftm_time_sync);
|
||||
else
|
||||
device_remove_file(&net_dev->dev,
|
||||
&dev_attr_ftm_time_sync);
|
||||
}
|
||||
|
||||
ucfg_ftm_time_sync_update_sta_connect_state(adapter->vdev, state);
|
||||
}
|
Reference in New Issue
Block a user