qcacmn: Smart antenna API convergence

Added sa_api_tx_ops, sa_api_rx_ops and their initialization. SA API component
id is also added along with sa_api objmanager calls.

Change-Id: I2e912106dcc900e5eba19090c0157827e08264f3
CRs-fixed: 2038298
diff --git a/init_deinit/dispatcher/src/dispatcher_init_deinit.c b/init_deinit/dispatcher/src/dispatcher_init_deinit.c
index cfd32cf..2d6664c 100644
--- a/init_deinit/dispatcher/src/dispatcher_init_deinit.c
+++ b/init_deinit/dispatcher/src/dispatcher_init_deinit.c
@@ -36,6 +36,9 @@
 #ifdef QCA_SUPPORT_SON
 #include <wlan_son_pub.h>
 #endif
+#ifdef WLAN_SA_API_ENABLE
+#include <wlan_sa_api_utils_api.h>
+#endif
 #ifdef WIFI_POS_CONVERGED
 #include "wifi_pos_api.h"
 #endif /* WIFI_POS_CONVERGED */
@@ -351,6 +354,49 @@
 }
 #endif /* END of WLAN_POLICY_MGR_ENABLE */
 
+#ifdef WLAN_SA_API_ENABLE
+static QDF_STATUS dispatcher_init_sa_api(void)
+{
+	return wlan_sa_api_init();
+}
+
+static QDF_STATUS dispatcher_deinit_sa_api(void)
+{
+	return wlan_sa_api_deinit();
+}
+
+static QDF_STATUS sa_api_psoc_enable(struct wlan_objmgr_psoc *psoc)
+{
+	return wlan_sa_api_enable(psoc);
+}
+
+static QDF_STATUS sa_api_psoc_disable(struct wlan_objmgr_psoc *psoc)
+{
+	return wlan_sa_api_disable(psoc);
+}
+#else
+static QDF_STATUS dispatcher_init_sa_api(void)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS dispatcher_deinit_sa_api(void)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS sa_api_psoc_enable(struct wlan_objmgr_psoc *psoc)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS sa_api_psoc_disable(struct wlan_objmgr_psoc *psoc)
+{
+	return QDF_STATUS_SUCCESS;
+}
+#endif /* END of WLAN_SA_API_ENABLE */
+
+
 #ifdef WLAN_ATF_ENABLE
 static QDF_STATUS dispatcher_init_atf(void)
 {
@@ -615,6 +661,9 @@
 	if (QDF_STATUS_SUCCESS != dispatcher_init_atf())
 		goto atf_init_fail;
 
+	if (QDF_STATUS_SUCCESS != dispatcher_init_sa_api())
+		goto sa_api_init_fail;
+
 	if (QDF_STATUS_SUCCESS != dispatcher_init_wifi_pos())
 		goto wifi_pos_init_fail;
 
@@ -656,6 +705,8 @@
 nan_init_fail:
 	dispatcher_deinit_wifi_pos();
 wifi_pos_init_fail:
+	dispatcher_deinit_sa_api();
+sa_api_init_fail:
 	dispatcher_deinit_atf();
 atf_init_fail:
 	dispatcher_policy_mgr_deinit();
@@ -701,6 +752,8 @@
 
 	QDF_BUG(QDF_STATUS_SUCCESS == dispatcher_deinit_wifi_pos());
 
+	QDF_BUG(QDF_STATUS_SUCCESS == dispatcher_deinit_sa_api());
+
 	QDF_BUG(QDF_STATUS_SUCCESS == dispatcher_deinit_atf());
 
 	QDF_BUG(QDF_STATUS_SUCCESS == dispatcher_policy_mgr_deinit());
@@ -808,6 +861,9 @@
 	if (QDF_STATUS_SUCCESS != dispatcher_policy_mgr_psoc_enable(psoc))
 		goto policy_mgr_psoc_enable_fail;
 
+	if (QDF_STATUS_SUCCESS != sa_api_psoc_enable(psoc))
+		goto sa_api_psoc_enable_fail;
+
 	if (QDF_STATUS_SUCCESS != atf_psoc_enable(psoc))
 		goto atf_psoc_enable_fail;
 
@@ -829,6 +885,8 @@
 wifi_pos_psoc_enable_fail:
 	atf_psoc_disable(psoc);
 atf_psoc_enable_fail:
+	sa_api_psoc_disable(psoc);
+sa_api_psoc_enable_fail:
 	dispatcher_policy_mgr_psoc_disable(psoc);
 policy_mgr_psoc_enable_fail:
 	tdls_psoc_disable(psoc);
@@ -848,6 +906,8 @@
 
 	QDF_BUG(QDF_STATUS_SUCCESS == dispatcher_wifi_pos_disable(psoc));
 
+	QDF_BUG(QDF_STATUS_SUCCESS == sa_api_psoc_disable(psoc));
+
 	QDF_BUG(QDF_STATUS_SUCCESS == atf_psoc_disable(psoc));
 
 	QDF_BUG(QDF_STATUS_SUCCESS ==
diff --git a/qdf/inc/qdf_types.h b/qdf/inc/qdf_types.h
index 7690928..24be729 100644
--- a/qdf/inc/qdf_types.h
+++ b/qdf/inc/qdf_types.h
@@ -388,6 +388,7 @@
 	QDF_MODULE_ID_POLICY_MGR,
 	QDF_MODULE_ID_CONFIG,
 	QDF_MODULE_ID_REGULATORY,
+	QDF_MODULE_ID_SA_API,
 	QDF_MODULE_ID_NAN,
 	QDF_MODULE_ID_OFFCHAN_TXRX,
 	QDF_MODULE_ID_SON,
diff --git a/target_if/core/src/target_if_main.c b/target_if/core/src/target_if_main.c
index caf479b..c2c2cf1 100644
--- a/target_if/core/src/target_if_main.c
+++ b/target_if/core/src/target_if_main.c
@@ -28,6 +28,9 @@
 #ifdef WLAN_ATF_ENABLE
 #include "target_if_atf.h"
 #endif
+#ifdef WLAN_SA_API_ENABLE
+#include "target_if_sa_api.h"
+#endif
 #include <target_if_reg.h>
 #include <target_if_scan.h>
 #ifdef DFS_COMPONENT_ENABLE
@@ -119,6 +122,12 @@
 }
 #endif /* WLAN_ATF_ENABLE */
 
+#ifndef WLAN_SA_API_ENABLE
+static void target_if_sa_api_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
+{
+}
+#endif /* WLAN_SA_API_ENABLE */
+
 #ifdef WIFI_POS_CONVERGED
 static void target_if_wifi_pos_tx_ops_register(
 			struct wlan_lmac_if_tx_ops *tx_ops)
@@ -194,6 +203,8 @@
 
 	target_if_atf_tx_ops_register(tx_ops);
 
+	target_if_sa_api_tx_ops_register(tx_ops);
+
 	target_if_wifi_pos_tx_ops_register(tx_ops);
 
 	target_if_nan_tx_ops_register(tx_ops);
diff --git a/umac/cmn_services/inc/wlan_cmn.h b/umac/cmn_services/inc/wlan_cmn.h
index eb8e166..2cc452e 100644
--- a/umac/cmn_services/inc/wlan_cmn.h
+++ b/umac/cmn_services/inc/wlan_cmn.h
@@ -106,6 +106,7 @@
  * @WLAN_UMAC_COMP_WIFI_POS:      WIFI Positioning
  * @WLAN_UMAC_COMP_TDLS:          TDLS
  * @WLAN_UMAC_COMP_ATF:           Airtime Fairness
+ * @WLAN_UMAC_COMP_SA_API:        Smart Antenna API
  * @WLAN_UMAC_COMP_REGULATORY:    REGULATORY
  * @WLAN_UMAC_COMP_CRYPTO:        CRYPTO
  * @WLAN_UMAC_COMP_NAN:           Neighbor Aware Networking
@@ -128,6 +129,7 @@
 	WLAN_UMAC_COMP_WIFI_POS,
 	WLAN_UMAC_COMP_TDLS,
 	WLAN_UMAC_COMP_ATF,
+	WLAN_UMAC_COMP_SA_API,
 	WLAN_UMAC_COMP_REGULATORY,
 	WLAN_UMAC_COMP_CRYPTO,
 	WLAN_UMAC_COMP_NAN,
diff --git a/umac/cmn_services/obj_mgr/inc/wlan_objmgr_cmn.h b/umac/cmn_services/obj_mgr/inc/wlan_objmgr_cmn.h
index af2739d..88573ac 100644
--- a/umac/cmn_services/obj_mgr/inc/wlan_objmgr_cmn.h
+++ b/umac/cmn_services/obj_mgr/inc/wlan_objmgr_cmn.h
@@ -208,6 +208,7 @@
 	WLAN_OFFCHAN_TXRX_ID  = 23,
 	WLAN_POLICY_MGR_ID    = 24,
 	WLAN_SON_ID           = 25,
+	WLAN_SA_API_ID        = 26,
 	WLAN_REF_ID_MAX,
 } wlan_objmgr_ref_dbgid;
 
diff --git a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h
index 415e1fd..d6679d0 100644
--- a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h
+++ b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h
@@ -34,6 +34,9 @@
 #ifdef QCA_SUPPORT_SON
 #include <wlan_son_tgt_api.h>
 #endif
+#ifdef WLAN_SA_API_ENABLE
+#include "wlan_sa_api_utils_defs.h"
+#endif
 #include <reg_services_public_struct.h>
 
 #ifdef WLAN_CONV_CRYPTO_SUPPORTED
@@ -364,6 +367,37 @@
 };
 #endif
 
+#ifdef WLAN_SA_API_ENABLE
+
+/**
+ * struct wlan_lmac_if_sa_api_tx_ops - SA API specific tx function pointers
+ */
+
+struct wlan_lmac_if_sa_api_tx_ops {
+	void (*sa_api_register_event_handler)(struct wlan_objmgr_psoc *psoc);
+	void (*sa_api_unregister_event_handler)(struct wlan_objmgr_psoc *posc);
+	void (*sa_api_enable_sa) (struct wlan_objmgr_pdev *pdev,
+			uint32_t enable, uint32_t mode, uint32_t rx_antenna);
+	void (*sa_api_set_rx_antenna) (struct wlan_objmgr_pdev *pdev,
+			uint32_t antenna);
+	void (*sa_api_set_tx_antenna) (struct wlan_objmgr_peer *peer,
+			uint32_t *antenna_array);
+	void (*sa_api_set_tx_default_antenna) (struct wlan_objmgr_pdev *pdev,
+			u_int32_t antenna);
+	void (*sa_api_set_training_info) (struct wlan_objmgr_peer *peer,
+			uint32_t *rate_array,
+			uint32_t *antenna_array,
+			uint32_t numpkts);
+	void (*sa_api_prepare_rateset)(struct wlan_objmgr_pdev *pdev,
+			struct wlan_objmgr_peer *peer,
+			struct sa_rate_info *rate_info);
+	void (*sa_api_set_node_config_ops) (struct wlan_objmgr_peer *peer,
+			uint32_t cmd_id, uint16_t args_count,
+			u_int32_t args_arr[]);
+};
+
+#endif
+
 #ifdef WIFI_POS_CONVERGED
 /*
  * struct wlan_lmac_if_wifi_pos_tx_ops - structure of firmware tx function
@@ -555,6 +589,9 @@
 #ifdef WLAN_ATF_ENABLE
 	struct wlan_lmac_if_atf_tx_ops atf_tx_ops;
 #endif
+#ifdef WLAN_SA_API_ENABLE
+	struct wlan_lmac_if_sa_api_tx_ops sa_api_tx_ops;
+#endif
 
 #ifdef WLAN_CONV_CRYPTO_SUPPORTED
 	struct wlan_lmac_if_crypto_tx_ops crypto_tx_ops;
@@ -744,6 +781,41 @@
 };
 #endif
 
+#ifdef WLAN_SA_API_ENABLE
+
+/**
+ * struct wlan_lmac_if_sa_api_rx_ops - SA API south bound rx function pointers
+ */
+struct wlan_lmac_if_sa_api_rx_ops {
+	uint32_t (*sa_api_get_sa_supported)(struct wlan_objmgr_psoc *psoc);
+	uint32_t (*sa_api_get_validate_sw)(struct wlan_objmgr_psoc *psoc);
+	void (*sa_api_enable_sa)(struct wlan_objmgr_psoc *psoc, uint32_t value);
+	uint32_t (*sa_api_get_sa_enable)(struct wlan_objmgr_psoc *psoc);
+	void (*sa_api_peer_assoc_hanldler)(struct wlan_objmgr_pdev *pdev,
+			struct wlan_objmgr_peer *peer, struct sa_rate_cap *);
+	uint32_t (*sa_api_update_tx_feedback)(struct wlan_objmgr_pdev *pdev,
+			struct wlan_objmgr_peer *peer,
+			struct sa_tx_feedback *feedback);
+	uint32_t (*sa_api_update_rx_feedback)(struct wlan_objmgr_pdev *pdev,
+			struct wlan_objmgr_peer *peer,
+			struct sa_rx_feedback *feedback);
+	uint32_t (*sa_api_ucfg_set_param)(struct wlan_objmgr_pdev *pdev,
+			char *val);
+	uint32_t (*sa_api_ucfg_get_param)(struct wlan_objmgr_pdev *pdev,
+			char *val);
+	uint32_t (*sa_api_is_tx_feedback_enabled)
+			(struct wlan_objmgr_pdev *pdev);
+	uint32_t (*sa_api_is_rx_feedback_enabled)
+			(struct wlan_objmgr_pdev *pdev);
+	uint32_t (*sa_api_convert_rate_2g)(uint32_t rate);
+	uint32_t (*sa_api_convert_rate_5g)(uint32_t rate);
+	uint32_t (*sa_api_get_sa_mode)(struct wlan_objmgr_pdev *pdev);
+	uint32_t (*sa_api_get_beacon_txantenna)(struct wlan_objmgr_pdev *pdev);
+	uint32_t (*sa_api_cwm_action)(struct wlan_objmgr_pdev *pdev);
+};
+#endif
+
+
 #ifdef WIFI_POS_CONVERGED
 /**
  * struct wlan_lmac_if_wifi_pos_rx_ops - structure of rx function
@@ -935,6 +1007,9 @@
 #ifdef WLAN_ATF_ENABLE
 	struct wlan_lmac_if_atf_rx_ops atf_rx_ops;
 #endif
+#ifdef WLAN_SA_API_ENABLE
+	struct wlan_lmac_if_sa_api_rx_ops sa_api_rx_ops;
+#endif
 #ifdef WLAN_CONV_CRYPTO_SUPPORTED
 	struct wlan_lmac_if_crypto_rx_ops crypto_rx_ops;
 #endif
diff --git a/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c b/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c
index 3b858cd..18145b1 100644
--- a/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c
+++ b/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c
@@ -25,6 +25,9 @@
 #ifdef WLAN_ATF_ENABLE
 #include "wlan_atf_tgt_api.h"
 #endif
+#ifdef WLAN_SA_API_ENABLE
+#include "wlan_sa_api_tgt_api.h"
+#endif
 #ifdef WIFI_POS_CONVERGED
 #include "target_if_wifi_pos.h"
 #endif /* WIFI_POS_CONVERGED */
@@ -111,6 +114,46 @@
 }
 #endif
 
+#ifdef WLAN_SA_API_ENABLE
+/**
+ * wlan_lmac_if_sa_api_rx_ops_register() - Function to register SA_API RX ops.
+ */
+static void
+wlan_lmac_if_sa_api_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops)
+{
+	struct wlan_lmac_if_sa_api_rx_ops *sa_api_rx_ops = &rx_ops->sa_api_rx_ops;
+
+	/* SA API rx ops */
+	sa_api_rx_ops->sa_api_get_sa_supported = tgt_sa_api_get_sa_supported;
+	sa_api_rx_ops->sa_api_get_validate_sw  = tgt_sa_api_get_validate_sw;
+	sa_api_rx_ops->sa_api_enable_sa        = tgt_sa_api_enable_sa;
+	sa_api_rx_ops->sa_api_get_sa_enable    = tgt_sa_api_get_sa_enable;
+
+	sa_api_rx_ops->sa_api_peer_assoc_hanldler = tgt_sa_api_peer_assoc_hanldler;
+	sa_api_rx_ops->sa_api_update_tx_feedback = tgt_sa_api_update_tx_feedback;
+	sa_api_rx_ops->sa_api_update_rx_feedback = tgt_sa_api_update_rx_feedback;
+
+	sa_api_rx_ops->sa_api_ucfg_set_param = tgt_sa_api_ucfg_set_param;
+	sa_api_rx_ops->sa_api_ucfg_get_param = tgt_sa_api_ucfg_get_param;
+
+	sa_api_rx_ops->sa_api_is_tx_feedback_enabled = tgt_sa_api_is_tx_feedback_enabled;
+	sa_api_rx_ops->sa_api_is_rx_feedback_enabled = tgt_sa_api_is_rx_feedback_enabled;
+
+	sa_api_rx_ops->sa_api_convert_rate_2g = tgt_sa_api_convert_rate_2g;
+	sa_api_rx_ops->sa_api_convert_rate_5g = tgt_sa_api_convert_rate_5g;
+	sa_api_rx_ops->sa_api_get_sa_mode = tgt_sa_api_get_sa_mode;
+
+	sa_api_rx_ops->sa_api_get_beacon_txantenna = tgt_sa_api_get_beacon_txantenna;
+	sa_api_rx_ops->sa_api_cwm_action = tgt_sa_api_cwm_action;
+}
+#else
+static void
+wlan_lmac_if_sa_api_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops)
+{
+}
+#endif
+
+
 #ifdef WLAN_CONV_CRYPTO_SUPPORTED
 static void
 wlan_lmac_if_crypto_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops)
@@ -262,6 +305,8 @@
 
 	wlan_lmac_if_atf_rx_ops_register(rx_ops);
 
+	wlan_lmac_if_sa_api_rx_ops_register(rx_ops);
+
 	wlan_lmac_if_crypto_rx_ops_register(rx_ops);
 	/* wifi_pos rx ops */
 	wlan_lmac_if_umac_rx_ops_register_wifi_pos(rx_ops);