Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 041cf611 authored by Govind Singh's avatar Govind Singh Committed by nshrivas
Browse files

qcacld-3.0: Add FTM TIME SYNC component

Add support for FTM TIME SYNC feature.

Change-Id: Idd022b3b105febd25b9353d7f7c4a046c9143585
CRs-Fixed: 2615242
parent eddfcbdd
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -1047,6 +1047,17 @@ PKT_CAPTURE_OBJS := $(PKT_CAPTURE_DIR)/core/src/wlan_pkt_capture_main.o \
		$(PKT_CAPTURE_DIR)/dispatcher/src/wlan_pkt_capture_ucfg_api.o
endif

########## FTM TIME SYNC ##########

FTM_TIME_SYNC_DIR := components/ftm_time_sync
FTM_TIME_SYNC_INC := -I$(WLAN_ROOT)/$(FTM_TIME_SYNC_DIR)/core/inc \
		  -I$(WLAN_ROOT)/$(FTM_TIME_SYNC_DIR)/dispatcher/inc

ifeq ($(CONFIG_FEATURE_WLAN_TIME_SYNC_FTM), y)
FTM_TIME_SYNC_OBJS := $(FTM_TIME_SYNC_DIR)/core/src/ftm_time_sync_main.o \
		$(FTM_TIME_SYNC_DIR)/dispatcher/src/ftm_time_sync_ucfg_api.o
endif

########## CLD TARGET_IF #######
CLD_TARGET_IF_DIR := components/target_if

@@ -1996,6 +2007,7 @@ INCS += $(HOST_DIAG_LOG_INC)
INCS +=		$(DISA_INC)
INCS +=		$(ACTION_OUI_INC)
INCS +=		$(PKT_CAPTURE_INC)
INCS +=		$(FTM_TIME_SYNC_INC)

INCS +=		$(UMAC_DISP_INC)
INCS +=		$(UMAC_SCAN_INC)
@@ -2108,6 +2120,10 @@ ifeq ($(CONFIG_WLAN_FEATURE_PKT_CAPTURE), y)
OBJS +=		$(PKT_CAPTURE_OBJS)
endif

ifeq ($(CONFIG_FEATURE_WLAN_TIME_SYNC_FTM), y)
OBJS +=		$(FTM_TIME_SYNC_OBJS)
endif

OBJS +=		$(UMAC_DISP_OBJS)
OBJS +=		$(UMAC_SCAN_OBJS)
OBJS +=		$(UMAC_COMMON_OBJS)
@@ -2205,6 +2221,7 @@ cppflags-$(CONFIG_WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT) += -DWLAN_FEATURE_RX_SOFTI
cppflags-$(CONFIG_PLD_USB_CNSS) += -DCONFIG_PLD_USB_CNSS
cppflags-$(CONFIG_PLD_SDIO_CNSS2) += -DCONFIG_PLD_SDIO_CNSS2
cppflags-$(CONFIG_WLAN_RECORD_RX_PADDR) += -DHIF_RECORD_RX_PADDR
cppflags-$(CONFIG_FEATURE_WLAN_TIME_SYNC_FTM) += -DFEATURE_WLAN_TIME_SYNC_FTM

#For both legacy and lithium chip's monitor mode config
ifeq ($(CONFIG_FEATURE_MONITOR_MODE_SUPPORT), y)
+77 −0
Original line number Diff line number Diff line
/*
 * 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.
 */

/**
 * DOC: Declare private API which shall be used internally only
 * in ftm_time_sync component. This file shall include prototypes of
 * various notification handlers and logging functions.
 *
 * Note: This API should be never accessed out of ftm_time_sync component.
 */

#ifndef _FTM_TIME_SYNC_MAIN_H_
#define _FTM_TIME_SYNC_MAIN_H_

#include <qdf_types.h>
#include "ftm_time_sync_priv.h"
#include "ftm_time_sync_objmgr.h"

#define ftm_time_sync_log(level, args...) \
	QDF_TRACE(QDF_MODULE_ID_FTM_TIME_SYNC, level, ## args)

#define ftm_time_sync_logfl(level, format, args...) \
	ftm_time_sync_log(level, FL(format), ## args)

#define ftm_time_sync_fatal(format, args...) \
		ftm_time_sync_logfl(QDF_TRACE_LEVEL_FATAL, format, ## args)
#define ftm_time_sync_err(format, args...) \
		ftm_time_sync_logfl(QDF_TRACE_LEVEL_ERROR, format, ## args)
#define ftm_time_sync_warn(format, args...) \
		ftm_time_sync_logfl(QDF_TRACE_LEVEL_WARN, format, ## args)
#define ftm_time_sync_info(format, args...) \
		ftm_time_sync_logfl(QDF_TRACE_LEVEL_INFO, format, ## args)
#define ftm_time_sync_debug(format, args...) \
		ftm_time_sync_logfl(QDF_TRACE_LEVEL_DEBUG, format, ## args)

#define FTM_TIME_SYNC_ENTER() ftm_time_sync_debug("enter")
#define FTM_TIME_SYNC_EXIT() ftm_time_sync_debug("exit")

/**
 * ftm_time_sync_vdev_create_notification(): Handler for vdev create notify.
 * @vdev: vdev which is going to be created by objmgr
 * @arg: argument for notification handler.
 *
 * Allocate and attach vdev private object.
 *
 * Return: QDF_STATUS status in case of success else return error.
 */
QDF_STATUS ftm_timesync_vdev_create_notification(struct wlan_objmgr_vdev *vdev,
						 void *arg);

/**
 * ftm_time_sync_vdev_destroy_notification(): Handler for vdev destroy notify.
 * @vdev: vdev which is going to be destroyed by objmgr
 * @arg: argument for notification handler.
 *
 * Deallocate and detach vdev private object.
 *
 * Return QDF_STATUS status in case of success else return error
 */
QDF_STATUS
ftm_timesync_vdev_destroy_notification(struct wlan_objmgr_vdev *vdev,
				       void *arg);

#endif /* end of _FTM_TIME_SYNC_MAIN_H_ */
+78 −0
Original line number Diff line number Diff line
/*
 * 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.
 */

/**
 * DOC: This file contains various object manager related wrappers and helpers
 */

#ifndef _FTM_TIME_SYNC_OBJMGR_H
#define _FTM_TIME_SYNC_OBJMGR_H

#include "wlan_cmn.h"
#include "wlan_objmgr_cmn.h"
#include "wlan_objmgr_vdev_obj.h"
#include "wlan_objmgr_global_obj.h"

/**
 * ftm_timesync_vdev_get_ref() - Wrapper to increment ftm_timesync ref count
 * @vdev: vdev object
 *
 * Wrapper for ftm_timesync to increment ref count after checking valid
 * object state.
 *
 * Return: SUCCESS/FAILURE
 */
static inline
QDF_STATUS ftm_timesync_vdev_get_ref(struct wlan_objmgr_vdev *vdev)
{
	return wlan_objmgr_vdev_try_get_ref(vdev, FTM_TIME_SYNC_ID);
}

/**
 * ftm_timesync_vdev_put_ref() - Wrapper to decrement ftm_timesync ref count
 * @vdev: vdev object
 *
 * Wrapper for ftm_timesync to decrement ref count of vdev.
 *
 * Return: SUCCESS/FAILURE
 */
static inline
void ftm_timesync_vdev_put_ref(struct wlan_objmgr_vdev *vdev)
{
	return wlan_objmgr_vdev_release_ref(vdev, FTM_TIME_SYNC_ID);
}

/**
 * ftm_timesync_vdev_get_priv(): Wrapper to retrieve vdev priv obj
 * @vdev: vdev pointer
 *
 * Wrapper for ftm_timesync to get vdev private object pointer.
 *
 * Return: Private object of vdev
 */
static inline struct ftm_timesync_vdev_priv *
ftm_timesync_vdev_get_priv(struct wlan_objmgr_vdev *vdev)
{
	struct ftm_timesync_vdev_priv *vdev_priv;

	vdev_priv = wlan_objmgr_vdev_get_comp_private_obj(
					vdev, WLAN_UMAC_COMP_FTM_TIME_SYNC);
	QDF_BUG(vdev_priv);

	return vdev_priv;
}

#endif /* _FTM_TIME_SYNC_OBJMGR_H */
+67 −0
Original line number Diff line number Diff line
/*
 * 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.
 */

/**
 * DOC: Declare private API which shall be used internally only
 * in ftm_timesync component. This file shall include prototypes of
 * ftm_timesync parsing and send logic.
 *
 * Note: This API should be never accessed out of ftm_timesync component.
 */

#ifndef _FTM_TIME_SYNC_PRIV_STRUCT_H_
#define _FTM_TIME_SYNC_PRIV_STRUCT_H_

#include <qdf_list.h>
#include <qdf_types.h>
#include "ftm_time_sync_objmgr.h"

#define WLAN_FTM_TIME_SYNC_PAIR_MAX 32

/**
 * struct wlan_time_sync_pair - wlan time sync pair
 * @qtime_master: master qtime
 * @qtime_slave: slave qtime
 */
struct wlan_time_sync_pair {
	uint64_t qtime_master;
	uint64_t qtime_slave;
};

/**
 * struct ftm_timesync_vdev_priv - Private object to be stored in vdev
 * @qtime_ref: qtime ref
 * @mac_ref: mac time ref
 * @time_pair: array of master/slave qtime pair
 */

struct ftm_timesync_priv {
	uint64_t qtime_ref;
	uint64_t mac_ref;
	struct wlan_time_sync_pair time_pair[WLAN_FTM_TIME_SYNC_PAIR_MAX];
};

/**
 * struct ftm_timesync_vdev_priv - Private object to be stored in vdev
 * @vdev: pointer to vdev object
 * @ftm_ts_priv: time sync private struct
 */
struct ftm_timesync_vdev_priv {
	struct wlan_objmgr_vdev *vdev;
	struct ftm_timesync_priv ftm_ts_priv;
};

#endif /* End  of _FTM_TIME_SYNC_PRIV_STRUCT_H_ */
+77 −0
Original line number Diff line number Diff line
/*
 * 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.
 */

/**
 * DOC: Implement various notification handlers which are accessed
 * internally in ftm_timesync component only.
 */

#include "ftm_time_sync_main.h"

QDF_STATUS
ftm_timesync_vdev_create_notification(struct wlan_objmgr_vdev *vdev, void *arg)
{
	struct ftm_timesync_vdev_priv *vdev_priv;
	QDF_STATUS status;

	vdev_priv = qdf_mem_malloc(sizeof(*vdev_priv));
	if (!vdev_priv) {
		status = QDF_STATUS_E_NOMEM;
		goto exit;
	}

	status = wlan_objmgr_vdev_component_obj_attach(
				vdev, WLAN_UMAC_COMP_FTM_TIME_SYNC,
				(void *)vdev_priv, QDF_STATUS_SUCCESS);
	if (QDF_IS_STATUS_ERROR(status)) {
		ftm_time_sync_err("Failed to attach priv with vdev");
		goto free_vdev_priv;
	}

	vdev_priv->vdev = vdev;
	goto exit;

free_vdev_priv:
	qdf_mem_free(vdev_priv);
	status = QDF_STATUS_E_INVAL;
exit:
	return status;
}

QDF_STATUS
ftm_timesync_vdev_destroy_notification(struct wlan_objmgr_vdev *vdev, void *arg)
{
	struct ftm_timesync_vdev_priv *vdev_priv = NULL;
	QDF_STATUS status = QDF_STATUS_E_FAILURE;

	vdev_priv = ftm_timesync_vdev_get_priv(vdev);
	if (!vdev_priv) {
		ftm_time_sync_err("vdev priv is NULL");
		goto exit;
	}

	status = wlan_objmgr_vdev_component_obj_detach(
					vdev, WLAN_UMAC_COMP_FTM_TIME_SYNC,
					(void *)vdev_priv);
	if (QDF_IS_STATUS_ERROR(status))
		ftm_time_sync_err("Failed to detach priv with vdev");

	qdf_mem_free(vdev_priv);
	vdev_priv = NULL;

exit:
	return status;
}
Loading