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/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);