Jelajahi Sumber

qcacld-3.0: move component 'coex' to qcacld project

'coex' component is MCC specific, move to qcacld project.

CRs-Fixed: 2721758
Change-Id: Ic1769ddf7eab6a6acc96349c020a6f311cda6bff
Yu Wang 4 tahun lalu
induk
melakukan
6088e94490

+ 9 - 9
Kbuild

@@ -1974,15 +1974,15 @@ endif
 #######################################################
 
 ###### COEX ########
-COEX_OS_IF_SRC      := $(WLAN_COMMON_ROOT)/os_if/linux/coex/src
-COEX_TGT_SRC        := $(WLAN_COMMON_ROOT)/target_if/coex/src
-COEX_CORE_SRC       := $(WLAN_COMMON_ROOT)/umac/coex/core/src
-COEX_DISPATCHER_SRC := $(WLAN_COMMON_ROOT)/umac/coex/dispatcher/src
-
-COEX_OS_IF_INC      := -I$(WLAN_COMMON_INC)/os_if/linux/coex/inc
-COEX_TGT_INC        := -I$(WLAN_COMMON_INC)/target_if/coex/inc
-COEX_DISPATCHER_INC := -I$(WLAN_COMMON_INC)/umac/coex/dispatcher/inc
-COEX_CORE_INC       := -I$(WLAN_COMMON_INC)/umac/coex/core/inc
+COEX_OS_IF_SRC      := os_if/coex/src
+COEX_TGT_SRC        := components/target_if/coex/src
+COEX_CORE_SRC       := components/coex/core/src
+COEX_DISPATCHER_SRC := components/coex/dispatcher/src
+
+COEX_OS_IF_INC      := -I$(WLAN_ROOT)/os_if/coex/inc
+COEX_TGT_INC        := -I$(WLAN_ROOT)/components/target_if/coex/inc
+COEX_DISPATCHER_INC := -I$(WLAN_ROOT)/components/coex/dispatcher/inc
+COEX_CORE_INC       := -I$(WLAN_ROOT)/components/coex/core/inc
 
 ifeq ($(CONFIG_FEATURE_COEX), y)
 COEX_OBJS := $(COEX_TGT_SRC)/target_if_coex.o                 \

+ 160 - 0
components/coex/core/inc/wlan_coex_main.h

@@ -0,0 +1,160 @@
+/*
+ * 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: contains declarations for coex core functions
+ */
+
+#ifndef _WLAN_COEX_MAIN_API_H_
+#define _WLAN_COEX_MAIN_API_H_
+
+#ifdef FEATURE_COEX
+#include "wlan_coex_ucfg_api.h"
+#include "wmi_unified_param.h"
+#include "wlan_objmgr_psoc_obj.h"
+#include "wlan_objmgr_vdev_obj.h"
+
+#define coex_err(params...) \
+	QDF_TRACE_ERROR(QDF_MODULE_ID_COEX, params)
+#define coex_info(params...) \
+	QDF_TRACE_INFO(QDF_MODULE_ID_COEX, params)
+#define coex_debug(params...) \
+	QDF_TRACE_DEBUG(QDF_MODULE_ID_COEX, params)
+
+/**
+ * struct coex_psoc_obj - coex object definition
+ * @btc_chain_mode: BT Coex chain mode.
+ * @coex_config_updated: callback functions for each config type, which will
+ *  be called when config is updated.
+ */
+struct coex_psoc_obj {
+	uint8_t btc_chain_mode;
+	update_coex_cb coex_config_updated[COEX_CONFIG_TYPE_MAX];
+};
+
+/**
+ * wlan_psoc_get_coex_obj() - private API to get coex object from psoc
+ * @psoc: psoc object
+ *
+ * Return: coex object
+ */
+#define wlan_psoc_get_coex_obj(psoc) \
+	wlan_psoc_get_coex_obj_fl(psoc, __func__, __LINE__)
+
+static inline struct coex_psoc_obj *
+wlan_psoc_get_coex_obj_fl(struct wlan_objmgr_psoc *psoc,
+			  const char *func, uint32_t line)
+{
+	struct coex_psoc_obj *psoc_obj;
+
+	psoc_obj = (struct coex_psoc_obj *)
+		wlan_objmgr_psoc_get_comp_private_obj(psoc,
+						      WLAN_UMAC_COMP_COEX);
+	if (!psoc_obj) {
+		coex_err("%s:%u, Failed to get coex psoc object", func, line);
+		return NULL;
+	}
+	return psoc_obj;
+}
+
+/**
+ * wlan_coex_psoc_init() - API to initialize coex component
+ * @psoc: soc context
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_coex_psoc_init(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * wlan_coex_psoc_deinit() - API to deinitialize coex component
+ * @psoc: soc context
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_coex_psoc_deinit(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * wlan_coex_config_send() - private API to send coex config
+ * @vdev: pointer to vdev object
+ * @param: parameters of coex config
+ *
+ * Return: status of operation
+ */
+QDF_STATUS wlan_coex_config_send(struct wlan_objmgr_vdev *vdev,
+				 struct coex_config_params *param);
+
+/**
+ * wlan_coex_config_updated() - private API to notify that coex config
+ * is updated.
+ * @vdev: pointer to vdev object
+ * @type: type of coex config
+ *
+ * Return: status of operation
+ */
+QDF_STATUS
+wlan_coex_config_updated(struct wlan_objmgr_vdev *vdev, uint8_t type);
+
+/**
+ * wlan_coex_psoc_created_notification() - PSOC obj create callback
+ * @psoc: PSOC object
+ * @arg_list: Variable argument list
+ *
+ * This callback is registered with object manager during initialization to
+ * get notified when the object is created.
+ *
+ * Return: Success or Failure
+ */
+QDF_STATUS wlan_coex_psoc_created_notification(struct wlan_objmgr_psoc *psoc,
+					       void *arg_list);
+
+/**
+ * wlan_coex_psoc_destroyed_notification() - PSOC obj delete callback
+ * @psoc: PSOC object
+ * @arg_list: Variable argument list
+ *
+ * This callback is registered with object manager during initialization to
+ * get notified when the object is deleted.
+ *
+ * Return: Success or Failure
+ */
+QDF_STATUS wlan_coex_psoc_destroyed_notification(struct wlan_objmgr_psoc *psoc,
+						 void *arg_list);
+
+/**
+ * wlan_coex_psoc_set_btc_chain_mode() - private API to set BT coex chain mode
+ * for psoc
+ * @psoc: pointer to psoc object
+ * @val: BT coex chain mode
+ *
+ * Return : status of operation
+ */
+QDF_STATUS
+wlan_coex_psoc_set_btc_chain_mode(struct wlan_objmgr_psoc *psoc, uint8_t val);
+
+/**
+ * wlan_coex_psoc_get_btc_chain_mode() - private API to get BT coex chain mode
+ * from psoc
+ * @psoc: pointer to psoc object
+ * @val: pointer to BT coex chain mode
+ *
+ * Return : status of operation
+ */
+QDF_STATUS
+wlan_coex_psoc_get_btc_chain_mode(struct wlan_objmgr_psoc *psoc, uint8_t *val);
+#endif
+#endif

+ 160 - 0
components/coex/core/src/wlan_coex_main.c

@@ -0,0 +1,160 @@
+/*
+ * 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: contains definitions for coex core functions
+ */
+
+#include <wlan_coex_ucfg_api.h>
+#include <wlan_coex_tgt_api.h>
+#include <wlan_coex_main.h>
+
+QDF_STATUS wlan_coex_psoc_created_notification(struct wlan_objmgr_psoc *psoc,
+					       void *arg_list)
+{
+	struct coex_psoc_obj *psoc_obj;
+	QDF_STATUS status;
+
+	psoc_obj = qdf_mem_malloc(sizeof(*psoc_obj));
+	if (!psoc_obj)
+		return QDF_STATUS_E_NOMEM;
+
+	psoc_obj->btc_chain_mode = WLAN_COEX_BTC_CHAIN_MODE_UNSETTLED;
+
+	/* Attach scan private date to psoc */
+	status = wlan_objmgr_psoc_component_obj_attach(psoc,
+						       WLAN_UMAC_COMP_COEX,
+						       psoc_obj,
+						       QDF_STATUS_SUCCESS);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		coex_err("Failed to attach psoc coex component");
+		qdf_mem_free(psoc_obj);
+	} else {
+		coex_debug("Coex object attach to psoc successful");
+	}
+
+	return status;
+}
+
+QDF_STATUS wlan_coex_psoc_destroyed_notification(struct wlan_objmgr_psoc *psoc,
+						 void *arg_list)
+{
+	void *psoc_obj;
+	QDF_STATUS status;
+
+	psoc_obj = wlan_psoc_get_coex_obj(psoc);
+	if (!psoc_obj)
+		return QDF_STATUS_E_FAILURE;
+
+	status = wlan_objmgr_psoc_component_obj_detach(psoc,
+						       WLAN_UMAC_COMP_COEX,
+						       psoc_obj);
+	if (QDF_IS_STATUS_ERROR(status))
+		coex_err("Failed to detach psoc coex component");
+
+	qdf_mem_free(psoc_obj);
+
+	return status;
+}
+
+QDF_STATUS
+wlan_coex_psoc_init(struct wlan_objmgr_psoc *psoc)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_coex_psoc_deinit(struct wlan_objmgr_psoc *psoc)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS wlan_coex_config_send(struct wlan_objmgr_vdev *vdev,
+				 struct coex_config_params *param)
+{
+	QDF_STATUS status;
+
+	status = tgt_send_coex_config(vdev, param);
+	if (QDF_IS_STATUS_ERROR(status))
+		coex_err("failed to send coex config");
+
+	return status;
+}
+
+QDF_STATUS
+wlan_coex_config_updated(struct wlan_objmgr_vdev *vdev, uint8_t type)
+{
+	struct wlan_objmgr_psoc *psoc;
+	struct coex_psoc_obj *coex_obj;
+	QDF_STATUS status = QDF_STATUS_SUCCESS;
+
+	if (!vdev) {
+		coex_err("NULL vdev");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	if (type >= COEX_CONFIG_TYPE_MAX) {
+		coex_err("config type out of range: %d", type);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	psoc = wlan_vdev_get_psoc(vdev);
+	if (!psoc) {
+		coex_err("NULL psoc");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	coex_obj = wlan_psoc_get_coex_obj(psoc);
+	if (!coex_obj)
+		return QDF_STATUS_E_INVAL;
+
+	if (coex_obj->coex_config_updated[type])
+		status = coex_obj->coex_config_updated[type](vdev);
+
+	return status;
+}
+
+QDF_STATUS
+wlan_coex_psoc_set_btc_chain_mode(struct wlan_objmgr_psoc *psoc, uint8_t val)
+{
+	struct coex_psoc_obj *coex_obj;
+
+	coex_obj = wlan_psoc_get_coex_obj(psoc);
+	if (!coex_obj)
+		return QDF_STATUS_E_INVAL;
+
+	coex_obj->btc_chain_mode = val;
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_coex_psoc_get_btc_chain_mode(struct wlan_objmgr_psoc *psoc, uint8_t *val)
+{
+	struct coex_psoc_obj *coex_obj;
+
+	if (!val) {
+		coex_err("invalid param for getting btc chain mode");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	coex_obj = wlan_psoc_get_coex_obj(psoc);
+	if (!coex_obj)
+		return QDF_STATUS_E_INVAL;
+
+	*val = coex_obj->btc_chain_mode;
+	return QDF_STATUS_SUCCESS;
+}

+ 38 - 0
components/coex/dispatcher/inc/wlan_coex_tgt_api.h

@@ -0,0 +1,38 @@
+/*
+ * 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: contains coex south bound interface definitions
+ */
+
+#ifndef _WLAN_COEX_TGT_API_H_
+#define _WLAN_COEX_TGT_API_H_
+
+#ifdef FEATURE_COEX
+struct coex_config_params;
+
+/**
+ * tgt_send_coex_config() - invoke target_if send coex config
+ * @vdev: vdev object
+ * @param: coex config parameters
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+tgt_send_coex_config(struct wlan_objmgr_vdev *vdev,
+		     struct coex_config_params *param);
+#endif
+#endif

+ 120 - 0
components/coex/dispatcher/inc/wlan_coex_ucfg_api.h

@@ -0,0 +1,120 @@
+/*
+ * 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: contains coex north bound interface declarations
+ */
+
+#ifndef _WLAN_COEX_UCFG_API_H_
+#define _WLAN_COEX_UCFG_API_H_
+
+#include "qdf_status.h"
+#include <wlan_objmgr_vdev_obj.h>
+#include <wlan_objmgr_psoc_obj.h>
+#include "qca_vendor.h"
+
+#define WLAN_COEX_BTC_CHAIN_MODE_SHARED QCA_BTC_CHAIN_SHARED
+#define WLAN_COEX_BTC_CHAIN_MODE_SEPARATED QCA_BTC_CHAIN_SEPARATED
+#define WLAN_COEX_BTC_CHAIN_MODE_UNSETTLED 0xFF
+
+/**
+ * enum coex_config_type - coex config type definitions
+ * @COEX_CONFIG_BTC_CHAIN_MODE: config BT coex chain mode
+ * @COEX_CONFIG_TYPE_MAX: max value
+ */
+enum coex_config_type {
+	COEX_CONFIG_BTC_CHAIN_MODE,
+	/* keep last */
+	COEX_CONFIG_TYPE_MAX,
+};
+
+/**
+ * typedef update_coex_cb() - cb to inform coex config
+ * @vdev: vdev pointer
+ *
+ * Return: void
+ */
+typedef QDF_STATUS (*update_coex_cb)(struct wlan_objmgr_vdev *vdev);
+
+#ifdef FEATURE_COEX
+/**
+ * ucfg_coex_register_cfg_updated_handler() - API to register coex config
+ * updated handler.
+ * @psoc: pointer to psoc object
+ * @type: type of coex config
+ * @handler: handler to be registered
+ *
+ * Return: status of operation
+ */
+QDF_STATUS
+ucfg_coex_register_cfg_updated_handler(struct wlan_objmgr_psoc *psoc,
+				       enum coex_config_type type,
+				       update_coex_cb handler);
+
+/**
+ * ucfg_coex_psoc_set_btc_chain_mode() - API to set BT coex chain mode for psoc
+ * @psoc: pointer to psoc object
+ * @val: BT coex chain mode
+ *
+ * Return : status of operation
+ */
+QDF_STATUS
+ucfg_coex_psoc_set_btc_chain_mode(struct wlan_objmgr_psoc *psoc, uint8_t val);
+
+/**
+ * ucfg_coex_psoc_get_btc_chain_mode() - API to get BT coex chain mode from psoc
+ * @psoc: pointer to psoc object
+ * @val: pointer to BT coex chain mode
+ *
+ * Return : status of operation
+ */
+QDF_STATUS
+ucfg_coex_psoc_get_btc_chain_mode(struct wlan_objmgr_psoc *psoc, uint8_t *val);
+
+/**
+ * ucfg_coex_send_btc_chain_mode() - API to send BT coex config to target if
+ * @vdev: pointer to vdev object
+ * @mode: BT coex chain mode
+ *
+ * Return: status of operation
+ */
+QDF_STATUS
+ucfg_coex_send_btc_chain_mode(struct wlan_objmgr_vdev *vdev, uint8_t mode);
+#else
+static inline QDF_STATUS
+ucfg_coex_register_cfg_updated_handler(struct wlan_objmgr_psoc *psoc,
+				       enum coex_config_type type,
+				       update_coex_cb handler)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline QDF_STATUS
+ucfg_coex_psoc_get_btc_chain_mode(struct wlan_objmgr_psoc *psoc, uint8_t *val)
+{
+	if (val)
+		*val = WLAN_COEX_BTC_CHAIN_MODE_UNSETTLED;
+
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline QDF_STATUS
+ucfg_coex_send_btc_chain_mode(struct wlan_objmgr_vdev *vdev, uint8_t mode)
+{
+	return QDF_STATUS_SUCCESS;
+}
+#endif
+#endif

+ 63 - 0
components/coex/dispatcher/inc/wlan_coex_utils_api.h

@@ -0,0 +1,63 @@
+/*
+ * 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: wlan_coex_utils_api.h
+ *
+ * This header file provides declaration of public APIs exposed to other UMAC
+ * components.
+ */
+
+#ifndef _WLAN_COEX_UTILS_API_H_
+#define _WLAN_COEX_UTILS_API_H_
+#include <wlan_objmgr_psoc_obj.h>
+
+/*
+ * wlan_coex_init() - Coex module initialization API
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS wlan_coex_init(void);
+
+/*
+ * wlan_coex_deinit() - Coex module deinitialization API
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS wlan_coex_deinit(void);
+
+/**
+ * wlan_coex_psoc_open() - Open coex component
+ * @psoc: soc context
+ *
+ * This function gets called when dispatcher opening.
+ *
+ * Return: QDF_STATUS_SUCCESS - in case of success
+ */
+QDF_STATUS
+wlan_coex_psoc_open(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * wlan_coex_psoc_close() - Close coex component
+ * @psoc: soc context
+ *
+ * This function gets called when dispatcher closing.
+ *
+ * Return: QDF_STATUS_SUCCESS - in case of success
+ */
+QDF_STATUS
+wlan_coex_psoc_close(struct wlan_objmgr_psoc *psoc);
+#endif

+ 84 - 0
components/coex/dispatcher/src/wlan_coex_tgt_api.c

@@ -0,0 +1,84 @@
+/*
+ * 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: contains coex south bound interface definitions
+ */
+
+#include <wlan_coex_main.h>
+#include <wlan_coex_tgt_api.h>
+#include <wlan_lmac_if_def.h>
+#include "wlan_objmgr_pdev_obj.h"
+
+static inline struct wlan_lmac_if_coex_tx_ops *
+wlan_psoc_get_coex_txops(struct wlan_objmgr_psoc *psoc)
+{
+	struct wlan_lmac_if_tx_ops *tx_ops;
+
+	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
+	if (!tx_ops) {
+		coex_err("tx_ops is NULL");
+		return NULL;
+	}
+
+	return &tx_ops->coex_ops;
+}
+
+static inline struct wlan_lmac_if_coex_tx_ops *
+wlan_vdev_get_coex_txops(struct wlan_objmgr_vdev *vdev)
+{
+	struct wlan_objmgr_psoc *psoc;
+
+	psoc = wlan_vdev_get_psoc(vdev);
+	if (!psoc) {
+		coex_err("NULL psoc");
+		return NULL;
+	}
+
+	return wlan_psoc_get_coex_txops(psoc);
+}
+
+QDF_STATUS
+tgt_send_coex_config(struct wlan_objmgr_vdev *vdev,
+		     struct coex_config_params *param)
+{
+	struct wlan_lmac_if_coex_tx_ops *coex_ops;
+	struct wlan_objmgr_psoc *psoc;
+	struct wlan_objmgr_pdev *pdev;
+
+	if (!vdev) {
+		coex_err("NULL vdev");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	psoc = wlan_vdev_get_psoc(vdev);
+	if (!psoc) {
+		coex_err("NULL psoc");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	pdev = wlan_vdev_get_pdev(vdev);
+	if (!pdev) {
+		coex_err("NULL pdev");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	coex_ops = wlan_psoc_get_coex_txops(psoc);
+	if (coex_ops && coex_ops->coex_config_send)
+		return coex_ops->coex_config_send(pdev, param);
+
+	return QDF_STATUS_SUCCESS;
+}

+ 74 - 0
components/coex/dispatcher/src/wlan_coex_ucfg_api.c

@@ -0,0 +1,74 @@
+/*
+ * 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: contains coex north bound interface definitions
+ */
+
+#include <wlan_coex_main.h>
+#include <wlan_coex_ucfg_api.h>
+#include "wmi_unified.h"
+
+QDF_STATUS
+ucfg_coex_register_cfg_updated_handler(struct wlan_objmgr_psoc *psoc,
+				       enum coex_config_type type,
+				       update_coex_cb handler)
+{
+	struct coex_psoc_obj *coex_obj;
+
+	if (type >= COEX_CONFIG_TYPE_MAX) {
+		coex_err("invalid coex type: %d", type);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	coex_obj = wlan_psoc_get_coex_obj(psoc);
+	if (!coex_obj)
+		return QDF_STATUS_E_INVAL;
+
+	coex_obj->coex_config_updated[type] = handler;
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+ucfg_coex_psoc_set_btc_chain_mode(struct wlan_objmgr_psoc *psoc, uint8_t val)
+{
+	return wlan_coex_psoc_set_btc_chain_mode(psoc, val);
+}
+
+QDF_STATUS
+ucfg_coex_psoc_get_btc_chain_mode(struct wlan_objmgr_psoc *psoc, uint8_t *val)
+{
+	return wlan_coex_psoc_get_btc_chain_mode(psoc, val);
+}
+
+QDF_STATUS
+ucfg_coex_send_btc_chain_mode(struct wlan_objmgr_vdev *vdev, uint8_t mode)
+{
+	struct coex_config_params param = {0};
+
+	if (mode != WLAN_COEX_BTC_CHAIN_MODE_SHARED &&
+	    mode != WLAN_COEX_BTC_CHAIN_MODE_SEPARATED)
+		return QDF_STATUS_E_INVAL;
+
+	param.vdev_id = wlan_vdev_get_id(vdev);
+	param.config_type = WMI_COEX_CONFIG_BTCOEX_SEPARATE_CHAIN_MODE;
+	param.config_arg1 = mode;
+
+	coex_debug("send btc chain mode %d for vdev %d", mode, param.vdev_id);
+
+	return wlan_coex_config_send(vdev, &param);
+}

+ 88 - 0
components/coex/dispatcher/src/wlan_coex_utils_api.c

@@ -0,0 +1,88 @@
+/*
+ * 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: wlan_coex_utils_api.c
+ *
+ * This file provides definitions of public APIs exposed to other UMAC
+ * components.
+ */
+
+#include <wlan_coex_main.h>
+#include <wlan_objmgr_global_obj.h>
+#include <wlan_coex_utils_api.h>
+
+QDF_STATUS wlan_coex_init(void)
+{
+	QDF_STATUS status;
+
+	status = wlan_objmgr_register_psoc_create_handler(
+			WLAN_UMAC_COMP_COEX,
+			wlan_coex_psoc_created_notification, NULL);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		coex_err("Failed to register psoc create handler");
+		goto fail_create_psoc;
+	}
+
+	status = wlan_objmgr_register_psoc_destroy_handler(
+			WLAN_UMAC_COMP_COEX,
+			wlan_coex_psoc_destroyed_notification, NULL);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		coex_err("Failed to create psoc delete handler");
+		goto fail_psoc_destroy;
+	}
+
+	coex_debug("coex psoc create and delete handler registered");
+	return status;
+
+fail_psoc_destroy:
+	wlan_objmgr_unregister_psoc_create_handler(
+			WLAN_UMAC_COMP_COEX,
+			wlan_coex_psoc_created_notification, NULL);
+fail_create_psoc:
+	return status;
+}
+
+QDF_STATUS wlan_coex_deinit(void)
+{
+	QDF_STATUS status;
+
+	status = wlan_objmgr_unregister_psoc_destroy_handler(
+			WLAN_UMAC_COMP_COEX,
+			wlan_coex_psoc_destroyed_notification, NULL);
+	if (status != QDF_STATUS_SUCCESS)
+		coex_err("Failed to unregister psoc delete handler");
+
+	status = wlan_objmgr_unregister_psoc_create_handler(
+			WLAN_UMAC_COMP_COEX,
+			wlan_coex_psoc_created_notification, NULL);
+	if (status != QDF_STATUS_SUCCESS)
+		coex_err("Failed to unregister psoc create handler");
+
+	return status;
+}
+
+QDF_STATUS
+wlan_coex_psoc_open(struct wlan_objmgr_psoc *psoc)
+{
+	return wlan_coex_psoc_init(psoc);
+}
+
+QDF_STATUS
+wlan_coex_psoc_close(struct wlan_objmgr_psoc *psoc)
+{
+	return wlan_coex_psoc_deinit(psoc);
+}

+ 33 - 0
components/target_if/coex/inc/target_if_coex.h

@@ -0,0 +1,33 @@
+/*
+ * 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: contains coex target if declarations
+ */
+#ifndef __TARGET_IF_COEX_H__
+#define __TARGET_IF_COEX_H__
+
+#include <target_if.h>
+
+/**
+ * target_if_coex_register_tx_ops() - Register coex target_if tx ops
+ * @tx_ops: pointer to target if tx ops
+ *
+ * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
+ */
+QDF_STATUS
+target_if_coex_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops);
+#endif

+ 52 - 0
components/target_if/coex/src/target_if_coex.c

@@ -0,0 +1,52 @@
+/*
+ * 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: contains coex target if functions
+ */
+#include <wlan_coex_main.h>
+#include <target_if_coex.h>
+
+static QDF_STATUS
+target_if_coex_config_send(struct wlan_objmgr_pdev *pdev,
+			   struct coex_config_params *param)
+{
+	wmi_unified_t pdev_wmi_handle;
+
+	pdev_wmi_handle = GET_WMI_HDL_FROM_PDEV(pdev);
+	if (!pdev_wmi_handle) {
+		coex_err("Invalid PDEV WMI handle");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	return wmi_unified_send_coex_config_cmd(pdev_wmi_handle, param);
+}
+
+QDF_STATUS
+target_if_coex_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
+{
+	struct wlan_lmac_if_coex_tx_ops *coex_ops;
+
+	if (!tx_ops) {
+		coex_err("target if tx ops is NULL!");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	coex_ops = &tx_ops->coex_ops;
+	coex_ops->coex_config_send = target_if_coex_config_send;
+
+	return QDF_STATUS_SUCCESS;
+}

+ 41 - 0
os_if/coex/inc/wlan_cfg80211_coex.h

@@ -0,0 +1,41 @@
+/*
+ * 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: declares driver functions interfacing with linux kernel
+ */
+
+#ifndef _WLAN_CFG80211_COEX_H_
+#define _WLAN_CFG80211_COEX_H_
+#include <wlan_cfg80211.h>
+#include <wlan_objmgr_cmn.h>
+
+extern const struct nla_policy
+	btc_chain_mode_policy
+	[QCA_VENDOR_ATTR_BTC_CHAIN_MODE_MAX + 1];
+
+#ifdef FEATURE_COEX
+int wlan_cfg80211_coex_set_btc_chain_mode(struct wlan_objmgr_vdev *vdev,
+					  const void *data, int data_len);
+#else
+static inline int
+wlan_cfg80211_coex_set_btc_chain_mode(struct wlan_objmgr_vdev *vdev,
+				      const void *data, int data_len)
+{
+	return -ENOTSUPP;
+}
+#endif
+#endif

+ 135 - 0
os_if/coex/src/wlan_cfg80211_coex.c

@@ -0,0 +1,135 @@
+/*
+ * 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: defines driver functions interfacing with linux kernel
+ */
+#include <wmi_unified_param.h>
+#include <wlan_osif_request_manager.h>
+#include <osif_sync.h>
+#include <wlan_objmgr_psoc_obj_i.h>
+#include <wlan_coex_main.h>
+#include <wlan_coex_ucfg_api.h>
+#include <wlan_cfg80211_coex.h>
+
+const struct nla_policy
+btc_chain_mode_policy[QCA_VENDOR_ATTR_BTC_CHAIN_MODE_MAX + 1] = {
+	[QCA_VENDOR_ATTR_BTC_CHAIN_MODE] = {.type = NLA_U32},
+	[QCA_VENDOR_ATTR_BTC_CHAIN_MODE_RESTART] = {.type = NLA_FLAG},
+};
+
+static int
+__wlan_cfg80211_coex_set_btc_chain_mode(struct wlan_objmgr_vdev *vdev,
+					uint8_t mode, bool do_restart)
+{
+	QDF_STATUS status;
+	uint8_t cur_mode;
+	int err;
+	struct wlan_objmgr_psoc *psoc;
+	struct wlan_objmgr_vdev *vdev_tmp;
+	int vdev_id;
+	struct coex_psoc_obj *coex_obj;
+
+	if (!vdev) {
+		coex_err("Null vdev");
+		return -EINVAL;
+	}
+
+	psoc = wlan_vdev_get_psoc(vdev);
+	if (!psoc) {
+		coex_err("NULL psoc");
+		return -EINVAL;
+	}
+
+	coex_obj = wlan_psoc_get_coex_obj(psoc);
+	if (!coex_obj)
+		return -EINVAL;
+
+	status = ucfg_coex_psoc_get_btc_chain_mode(psoc, &cur_mode);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		coex_err("failed to get cur BTC chain mode, status %d", status);
+		return -EFAULT;
+	}
+
+	if (cur_mode == mode)
+		return -EALREADY;
+
+	status = ucfg_coex_psoc_set_btc_chain_mode(psoc, mode);
+	if (!QDF_IS_STATUS_SUCCESS(status)) {
+		coex_err("unable to set BTC chain mode to %d", mode);
+		return -EFAULT;
+	}
+
+	wlan_objmgr_for_each_psoc_vdev(psoc, vdev_id, vdev_tmp) {
+		status = ucfg_coex_send_btc_chain_mode(vdev_tmp, mode);
+		err = qdf_status_to_os_return(status);
+		if (err) {
+			coex_err("Failed to set btc chain mode to %d for vdev %d",
+				 mode, vdev_id);
+			return err;
+		}
+		coex_debug("Set btc chain mode to %d for vdev %d",
+			   mode, vdev_id);
+
+		if (!do_restart)
+			continue;
+
+		wlan_coex_config_updated(vdev_tmp, COEX_CONFIG_BTC_CHAIN_MODE);
+	}
+
+	return 0;
+}
+
+/**
+ * wlan_hdd_cfg80211_set_btc_chain_mode() - set btc chain mode
+ * @wiphy: pointer to wireless wiphy structure.
+ * @wdev: pointer to wireless_dev structure.
+ * @data: pointer to btc chain mode command parameters.
+ * @data_len: the length in byte of btc chain mode command parameters.
+ *
+ * Return: An error code or 0 on success.
+ */
+int wlan_cfg80211_coex_set_btc_chain_mode(struct wlan_objmgr_vdev *vdev,
+					  const void *data, int data_len)
+{
+	struct nlattr *tb[QCA_VENDOR_ATTR_BTC_CHAIN_MODE_MAX + 1];
+	uint32_t mode;
+	bool restart;
+
+	if (wlan_cfg80211_nla_parse(tb, QCA_VENDOR_ATTR_BTC_CHAIN_MODE_MAX,
+				    data, data_len, btc_chain_mode_policy)) {
+		coex_err("Invalid btc chain mode ATTR");
+		return -EINVAL;
+	}
+
+	if (!tb[QCA_VENDOR_ATTR_BTC_CHAIN_MODE]) {
+		coex_err("btc chain mode - no attr mode");
+		return -EINVAL;
+	}
+
+	mode = nla_get_u32(tb[QCA_VENDOR_ATTR_BTC_CHAIN_MODE]);
+	if (mode < QCA_BTC_CHAIN_SHARED || mode > QCA_BTC_CHAIN_SEPARATED) {
+		coex_err("Invalid btc chain mode %d", mode);
+		return -EINVAL;
+	}
+
+	restart = nla_get_flag(tb[QCA_VENDOR_ATTR_BTC_CHAIN_MODE_RESTART]);
+
+	coex_debug("vdev_id %u mode %u restart %u",
+		   wlan_vdev_get_id(vdev), mode, restart);
+
+	return __wlan_cfg80211_coex_set_btc_chain_mode(vdev, mode, restart);
+}