|
@@ -16,16 +16,91 @@
|
|
|
|
|
|
/**
|
|
|
* DOC: Implement various notification handlers which are accessed
|
|
|
- * internally in ftm_timesync component only.
|
|
|
+ * internally in ftm_time_sync component only.
|
|
|
*/
|
|
|
|
|
|
#include "ftm_time_sync_main.h"
|
|
|
#include "target_if_ftm_time_sync.h"
|
|
|
+#include "wlan_objmgr_vdev_obj.h"
|
|
|
+#include "cfg_ftm_time_sync.h"
|
|
|
+#include "cfg_ucfg_api.h"
|
|
|
#include <pld_common.h>
|
|
|
|
|
|
+void ftm_time_sync_set_enable(struct wlan_objmgr_psoc *psoc, bool value)
|
|
|
+{
|
|
|
+ struct ftm_time_sync_psoc_priv *psoc_priv;
|
|
|
+
|
|
|
+ if (!psoc) {
|
|
|
+ ftm_time_sync_err("psoc is NULL");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ psoc_priv = ftm_time_sync_psoc_get_priv(psoc);
|
|
|
+ if (!psoc_priv) {
|
|
|
+ ftm_time_sync_err("psoc priv is NULL");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ psoc_priv->cfg_param.enable &= value;
|
|
|
+}
|
|
|
+
|
|
|
+bool ftm_time_sync_is_enable(struct wlan_objmgr_psoc *psoc)
|
|
|
+{
|
|
|
+ struct ftm_time_sync_psoc_priv *psoc_priv;
|
|
|
+
|
|
|
+ if (!psoc) {
|
|
|
+ ftm_time_sync_err("psoc is NULL");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ psoc_priv = ftm_time_sync_psoc_get_priv(psoc);
|
|
|
+ if (!psoc_priv) {
|
|
|
+ ftm_time_sync_err("psoc priv is NULL");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return psoc_priv->cfg_param.enable;
|
|
|
+}
|
|
|
+
|
|
|
+enum ftm_time_sync_mode ftm_time_sync_get_mode(struct wlan_objmgr_psoc *psoc)
|
|
|
+{
|
|
|
+ struct ftm_time_sync_psoc_priv *psoc_priv;
|
|
|
+
|
|
|
+ if (!psoc) {
|
|
|
+ ftm_time_sync_err("psoc is NULL");
|
|
|
+ return FTM_TIMESYNC_AGGREGATED_MODE;
|
|
|
+ }
|
|
|
+
|
|
|
+ psoc_priv = ftm_time_sync_psoc_get_priv(psoc);
|
|
|
+ if (!psoc_priv) {
|
|
|
+ ftm_time_sync_err("psoc priv is NULL");
|
|
|
+ return FTM_TIMESYNC_AGGREGATED_MODE;
|
|
|
+ }
|
|
|
+
|
|
|
+ return psoc_priv->cfg_param.mode;
|
|
|
+}
|
|
|
+
|
|
|
+enum ftm_time_sync_role ftm_time_sync_get_role(struct wlan_objmgr_psoc *psoc)
|
|
|
+{
|
|
|
+ struct ftm_time_sync_psoc_priv *psoc_priv;
|
|
|
+
|
|
|
+ if (!psoc) {
|
|
|
+ ftm_time_sync_err("psoc is NULL");
|
|
|
+ return FTM_TIMESYNC_SLAVE_ROLE;
|
|
|
+ }
|
|
|
+
|
|
|
+ psoc_priv = ftm_time_sync_psoc_get_priv(psoc);
|
|
|
+ if (!psoc_priv) {
|
|
|
+ ftm_time_sync_err("psoc priv is NULL");
|
|
|
+ return FTM_TIMESYNC_SLAVE_ROLE;
|
|
|
+ }
|
|
|
+
|
|
|
+ return psoc_priv->cfg_param.role;
|
|
|
+}
|
|
|
+
|
|
|
static void ftm_time_sync_work_handler(void *arg)
|
|
|
{
|
|
|
- struct ftm_timesync_vdev_priv *vdev_priv = arg;
|
|
|
+ struct ftm_time_sync_vdev_priv *vdev_priv = arg;
|
|
|
struct wlan_objmgr_psoc *psoc;
|
|
|
qdf_device_t qdf_dev;
|
|
|
QDF_STATUS status;
|
|
@@ -73,12 +148,21 @@ static void ftm_time_sync_work_handler(void *arg)
|
|
|
}
|
|
|
|
|
|
QDF_STATUS
|
|
|
-ftm_timesync_vdev_create_notification(struct wlan_objmgr_vdev *vdev, void *arg)
|
|
|
+ftm_time_sync_vdev_create_notification(struct wlan_objmgr_vdev *vdev, void *arg)
|
|
|
{
|
|
|
- struct ftm_timesync_vdev_priv *vdev_priv;
|
|
|
+ struct ftm_time_sync_vdev_priv *vdev_priv;
|
|
|
struct wlan_objmgr_psoc *psoc;
|
|
|
QDF_STATUS status;
|
|
|
|
|
|
+ psoc = wlan_vdev_get_psoc(vdev);
|
|
|
+ if (!psoc) {
|
|
|
+ ftm_time_sync_err("Failed to get psoc");
|
|
|
+ return QDF_STATUS_E_INVAL;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!ftm_time_sync_is_enable(psoc))
|
|
|
+ return QDF_STATUS_SUCCESS;
|
|
|
+
|
|
|
vdev_priv = qdf_mem_malloc(sizeof(*vdev_priv));
|
|
|
if (!vdev_priv) {
|
|
|
status = QDF_STATUS_E_NOMEM;
|
|
@@ -93,12 +177,6 @@ ftm_timesync_vdev_create_notification(struct wlan_objmgr_vdev *vdev, void *arg)
|
|
|
goto free_vdev_priv;
|
|
|
}
|
|
|
|
|
|
- psoc = wlan_vdev_get_psoc(vdev);
|
|
|
- if (!psoc) {
|
|
|
- ftm_time_sync_err("Failed to get psoc");
|
|
|
- return QDF_STATUS_E_INVAL;
|
|
|
- }
|
|
|
-
|
|
|
vdev_priv->vdev = vdev;
|
|
|
status = qdf_delayed_work_create(&vdev_priv->ftm_time_sync_work,
|
|
|
ftm_time_sync_work_handler, vdev_priv);
|
|
@@ -108,11 +186,12 @@ ftm_timesync_vdev_create_notification(struct wlan_objmgr_vdev *vdev, void *arg)
|
|
|
}
|
|
|
|
|
|
qdf_mutex_create(&vdev_priv->ftm_time_sync_mutex);
|
|
|
+
|
|
|
target_if_ftm_time_sync_register_tx_ops(&vdev_priv->tx_ops);
|
|
|
target_if_ftm_time_sync_register_rx_ops(&vdev_priv->rx_ops);
|
|
|
|
|
|
- vdev_priv->rx_ops.ftm_timesync_register_start_stop(psoc);
|
|
|
- vdev_priv->rx_ops.ftm_timesync_regiser_master_slave_offset(psoc);
|
|
|
+ vdev_priv->rx_ops.ftm_time_sync_register_start_stop(psoc);
|
|
|
+ vdev_priv->rx_ops.ftm_time_sync_regiser_master_slave_offset(psoc);
|
|
|
|
|
|
vdev_priv->valid = true;
|
|
|
|
|
@@ -142,12 +221,24 @@ ftm_time_sync_deregister_wmi_events(struct wlan_objmgr_vdev *vdev)
|
|
|
}
|
|
|
|
|
|
QDF_STATUS
|
|
|
-ftm_timesync_vdev_destroy_notification(struct wlan_objmgr_vdev *vdev, void *arg)
|
|
|
+ftm_time_sync_vdev_destroy_notification(struct wlan_objmgr_vdev *vdev,
|
|
|
+ void *arg)
|
|
|
+
|
|
|
{
|
|
|
- struct ftm_timesync_vdev_priv *vdev_priv = NULL;
|
|
|
+ struct ftm_time_sync_vdev_priv *vdev_priv = NULL;
|
|
|
+ struct wlan_objmgr_psoc *psoc;
|
|
|
QDF_STATUS status = QDF_STATUS_E_FAILURE;
|
|
|
|
|
|
- vdev_priv = ftm_timesync_vdev_get_priv(vdev);
|
|
|
+ psoc = wlan_vdev_get_psoc(vdev);
|
|
|
+ if (!psoc) {
|
|
|
+ ftm_time_sync_err("Failed to get psoc");
|
|
|
+ return QDF_STATUS_E_INVAL;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!ftm_time_sync_is_enable(psoc))
|
|
|
+ return QDF_STATUS_SUCCESS;
|
|
|
+
|
|
|
+ vdev_priv = ftm_time_sync_vdev_get_priv(vdev);
|
|
|
if (!vdev_priv) {
|
|
|
ftm_time_sync_err("vdev priv is NULL");
|
|
|
goto exit;
|
|
@@ -170,3 +261,67 @@ ftm_timesync_vdev_destroy_notification(struct wlan_objmgr_vdev *vdev, void *arg)
|
|
|
exit:
|
|
|
return status;
|
|
|
}
|
|
|
+
|
|
|
+static void
|
|
|
+ftm_time_sync_cfg_init(struct ftm_time_sync_psoc_priv *psoc_priv)
|
|
|
+{
|
|
|
+ psoc_priv->cfg_param.enable = cfg_get(psoc_priv->psoc,
|
|
|
+ CFG_ENABLE_TIME_SYNC_FTM);
|
|
|
+ psoc_priv->cfg_param.role = cfg_get(psoc_priv->psoc,
|
|
|
+ CFG_TIME_SYNC_FTM_ROLE);
|
|
|
+ psoc_priv->cfg_param.mode = cfg_get(psoc_priv->psoc,
|
|
|
+ CFG_TIME_SYNC_FTM_MODE);
|
|
|
+}
|
|
|
+
|
|
|
+QDF_STATUS
|
|
|
+ftm_time_sync_psoc_create_notification(struct wlan_objmgr_psoc *psoc, void *arg)
|
|
|
+{
|
|
|
+ struct ftm_time_sync_psoc_priv *psoc_priv;
|
|
|
+ QDF_STATUS status;
|
|
|
+
|
|
|
+ psoc_priv = qdf_mem_malloc(sizeof(*psoc_priv));
|
|
|
+ if (!psoc_priv)
|
|
|
+ return QDF_STATUS_E_NOMEM;
|
|
|
+
|
|
|
+ status = wlan_objmgr_psoc_component_obj_attach(
|
|
|
+ psoc, WLAN_UMAC_COMP_FTM_TIME_SYNC,
|
|
|
+ psoc_priv, QDF_STATUS_SUCCESS);
|
|
|
+ if (QDF_IS_STATUS_ERROR(status)) {
|
|
|
+ ftm_time_sync_err("Failed to attach psoc component obj");
|
|
|
+ goto free_psoc_priv;
|
|
|
+ }
|
|
|
+
|
|
|
+ psoc_priv->psoc = psoc;
|
|
|
+ ftm_time_sync_cfg_init(psoc_priv);
|
|
|
+
|
|
|
+ return status;
|
|
|
+
|
|
|
+free_psoc_priv:
|
|
|
+ qdf_mem_free(psoc_priv);
|
|
|
+ return status;
|
|
|
+}
|
|
|
+
|
|
|
+QDF_STATUS
|
|
|
+ftm_time_sync_psoc_destroy_notification(struct wlan_objmgr_psoc *psoc,
|
|
|
+ void *arg)
|
|
|
+{
|
|
|
+ struct ftm_time_sync_psoc_priv *psoc_priv;
|
|
|
+ QDF_STATUS status;
|
|
|
+
|
|
|
+ psoc_priv = ftm_time_sync_psoc_get_priv(psoc);
|
|
|
+ if (!psoc_priv) {
|
|
|
+ ftm_time_sync_err("psoc priv is NULL");
|
|
|
+ return QDF_STATUS_E_FAILURE;
|
|
|
+ }
|
|
|
+
|
|
|
+ status = wlan_objmgr_psoc_component_obj_detach(
|
|
|
+ psoc, WLAN_UMAC_COMP_FTM_TIME_SYNC,
|
|
|
+ psoc_priv);
|
|
|
+ if (QDF_IS_STATUS_ERROR(status)) {
|
|
|
+ ftm_time_sync_err("Failed to detach psoc component obj");
|
|
|
+ return status;
|
|
|
+ }
|
|
|
+
|
|
|
+ qdf_mem_free(psoc_priv);
|
|
|
+ return status;
|
|
|
+}
|