qcacld-3.0: Featurize WLAN_FEATURE_LINK_LAYER_STATS

Featurize WLAN_FEATURE_LINK_LAYER_STATS to compile out
in mission mode.

Change-Id: If0f27efa3661f4b3083180690160109084c5da67
CRs-Fixed: 2255035
diff --git a/Kbuild b/Kbuild
index f7047e1..5dc1593 100644
--- a/Kbuild
+++ b/Kbuild
@@ -66,8 +66,10 @@
 
 ifeq ($(CONFIG_WLAN_DEBUGFS), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_debugfs.o
+ifeq ($(CONFIG_WLAN_FEATURE_LINK_LAYER_STATS), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_debugfs_llstat.o
 endif
+endif
 
 ifeq ($(CONFIG_WLAN_CONV_SPECTRAL_ENABLE),y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_spectralscan.o
diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c
index fcaa2ae..8b633a9 100644
--- a/core/hdd/src/wlan_hdd_assoc.c
+++ b/core/hdd/src/wlan_hdd_assoc.c
@@ -60,6 +60,7 @@
 #include "wlan_utility.h"
 #include "wlan_p2p_ucfg_api.h"
 #include "wlan_ipa_ucfg_api.h"
+#include "wlan_hdd_stats.h"
 
 #include "wlan_hdd_nud_tracking.h"
 /* These are needed to recognize WPA and RSN suite types */
diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c
index ca3f0aa..f356981 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.c
+++ b/core/hdd/src/wlan_hdd_cfg80211.c
@@ -75,9 +75,7 @@
 
 #include "wlan_hdd_ext_scan.h"
 
-#ifdef WLAN_FEATURE_LINK_LAYER_STATS
 #include "wlan_hdd_stats.h"
-#endif
 #include "cds_api.h"
 #include "wlan_policy_mgr_api.h"
 #include "qwlan_version.h"
@@ -21881,26 +21879,6 @@
 }
 #endif
 
-/**
- * wlan_hdd_clear_link_layer_stats() - clear link layer stats
- * @adapter: pointer to adapter
- *
- * Wrapper function to clear link layer stats.
- * return - void
- */
-void wlan_hdd_clear_link_layer_stats(struct hdd_adapter *adapter)
-{
-	tSirLLStatsClearReq link_layer_stats_clear_req;
-	tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
-
-	link_layer_stats_clear_req.statsClearReqMask = WIFI_STATS_IFACE_AC |
-		WIFI_STATS_IFACE_ALL_PEER;
-	link_layer_stats_clear_req.stopReq = 0;
-	link_layer_stats_clear_req.reqId = 1;
-	link_layer_stats_clear_req.staId = adapter->session_id;
-	sme_ll_stats_clear_req(hal, &link_layer_stats_clear_req);
-}
-
 #define CNT_DIFF(cur, prev) \
 	((cur >= prev) ? (cur - prev) : (cur + (MAX_COUNT - (prev) + 1)))
 #define MAX_COUNT 0xffffffff
diff --git a/core/hdd/src/wlan_hdd_cfg80211.h b/core/hdd/src/wlan_hdd_cfg80211.h
index af13007..2a8db15 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.h
+++ b/core/hdd/src/wlan_hdd_cfg80211.h
@@ -125,12 +125,6 @@
 
 #endif
 
-#ifdef WLAN_FEATURE_LINK_LAYER_STATS
-void wlan_hdd_clear_link_layer_stats(struct hdd_adapter *adapter);
-#else
-static inline void wlan_hdd_clear_link_layer_stats(struct hdd_adapter *adapter) {}
-#endif
-
 #define MAX_CHANNEL (NUM_24GHZ_CHANNELS + NUM_5GHZ_CHANNELS)
 #define MAX_SCAN_SSID 10
 
@@ -494,15 +488,6 @@
  */
 void hdd_set_rate_bw(struct rate_info *info, enum hdd_rate_info_bw hdd_bw);
 
-/**
- * hdd_lost_link_info_cb() - callback function to get lost link information
- * @context: HDD context
- * @lost_link_info: lost link information
- *
- * Return: none
- */
-void hdd_lost_link_info_cb(void *context,
-			struct sir_lost_link_info *lost_link_info);
 /*
  * hdd_get_sap_operating_band:  Get current operating channel
  * for sap.
diff --git a/core/hdd/src/wlan_hdd_stats.c b/core/hdd/src/wlan_hdd_stats.c
index 1468e1d..1b5e0b5 100644
--- a/core/hdd/src/wlan_hdd_stats.c
+++ b/core/hdd/src/wlan_hdd_stats.c
@@ -1672,6 +1672,26 @@
 }
 
 /**
+ * wlan_hdd_clear_link_layer_stats() - clear link layer stats
+ * @adapter: pointer to adapter
+ *
+ * Wrapper function to clear link layer stats.
+ * return - void
+ */
+void wlan_hdd_clear_link_layer_stats(struct hdd_adapter *adapter)
+{
+	tSirLLStatsClearReq link_layer_stats_clear_req;
+	tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
+
+	link_layer_stats_clear_req.statsClearReqMask = WIFI_STATS_IFACE_AC |
+		WIFI_STATS_IFACE_ALL_PEER;
+	link_layer_stats_clear_req.stopReq = 0;
+	link_layer_stats_clear_req.reqId = 1;
+	link_layer_stats_clear_req.staId = adapter->session_id;
+	sme_ll_stats_clear_req(hal, &link_layer_stats_clear_req);
+}
+
+/**
  * hdd_populate_per_peer_ps_info() - populate per peer sta's PS info
  * @wifi_peer_info: peer information
  * @vendor_event: buffer for vendor event
@@ -2801,6 +2821,18 @@
 
 	return ret;
 }
+
+/**
+ * hdd_init_ll_stats_ctx() - initialize link layer stats context
+ *
+ * Return: none
+ */
+inline void hdd_init_ll_stats_ctx(void)
+{
+	spin_lock_init(&ll_stats_context.context_lock);
+	init_completion(&ll_stats_context.response_event);
+	ll_stats_context.request_bitmap = 0;
+}
 #endif /* WLAN_FEATURE_LINK_LAYER_STATS */
 
 #ifdef WLAN_FEATURE_STATS_EXT
@@ -4708,17 +4740,6 @@
 
 	return ret;
 }
-/**
- * hdd_init_ll_stats_ctx() - initialize link layer stats context
- *
- * Return: none
- */
-inline void hdd_init_ll_stats_ctx(void)
-{
-	spin_lock_init(&ll_stats_context.context_lock);
-	init_completion(&ll_stats_context.response_event);
-	ll_stats_context.request_bitmap = 0;
-}
 
 /**
  * hdd_display_hif_stats() - display hif stats
diff --git a/core/hdd/src/wlan_hdd_stats.h b/core/hdd/src/wlan_hdd_stats.h
index c01ce87..46fedb7 100644
--- a/core/hdd/src/wlan_hdd_stats.h
+++ b/core/hdd/src/wlan_hdd_stats.h
@@ -145,6 +145,8 @@
 				     const void *data,
 				     int data_len);
 
+void wlan_hdd_clear_link_layer_stats(struct hdd_adapter *adapter);
+
 void hdd_init_ll_stats_ctx(void);
 
 static inline bool hdd_link_layer_stats_supported(void)
@@ -186,7 +188,34 @@
 int wlan_hdd_ll_stats_get(struct hdd_adapter *adapter, uint32_t req_id,
 			  uint32_t req_mask);
 
-#else
+void wlan_hdd_cfg80211_link_layer_stats_callback(void *ctx,
+						 int indType, void *pRsp);
+/**
+ * wlan_hdd_cfg80211_link_layer_stats_ext_callback() - Callback for LL ext
+ * @ctx: HDD context
+ * @rsp: msg from FW
+ *
+ * This function is an extension of
+ * wlan_hdd_cfg80211_link_layer_stats_callback. It converts
+ * monitoring parameters offloaded to NL data and send the same to the
+ * kernel/upper layers.
+ *
+ * Return: None.
+ */
+void wlan_hdd_cfg80211_link_layer_stats_ext_callback(hdd_handle_t ctx,
+						     tSirLLStatsResults *rsp);
+
+/**
+ * hdd_lost_link_info_cb() - callback function to get lost link information
+ * @context: HDD context
+ * @lost_link_info: lost link information
+ *
+ * Return: none
+ */
+void hdd_lost_link_info_cb(void *context,
+			   struct sir_lost_link_info *lost_link_info);
+
+#else /* WLAN_FEATURE_LINK_LAYER_STATS */
 
 static inline void hdd_init_ll_stats_ctx(void)
 {
@@ -206,13 +235,36 @@
 	return -EINVAL;
 }
 
-static inline
-int wlan_hdd_ll_stats_get(hdd_adapter_t *adapter, uint32_t req_id,
-			  uint32_t req_mask)
+static inline int
+wlan_hdd_ll_stats_get(struct hdd_adapter *adapter, uint32_t req_id,
+		      uint32_t req_mask)
 {
 	return -EINVAL;
 }
 
+static inline void
+wlan_hdd_clear_link_layer_stats(struct hdd_adapter *adapter)
+{
+}
+
+static inline void
+wlan_hdd_cfg80211_link_layer_stats_callback(void *ctx,
+					    int indType, void *pRsp)
+{
+}
+
+static inline void
+wlan_hdd_cfg80211_link_layer_stats_ext_callback(hdd_handle_t ctx,
+						tSirLLStatsResults *rsp)
+{
+}
+
+static inline void
+hdd_lost_link_info_cb(void *context,
+		      struct sir_lost_link_info *lost_link_info)
+{
+}
+
 #endif /* End of WLAN_FEATURE_LINK_LAYER_STATS */
 
 #ifdef WLAN_FEATURE_STATS_EXT
@@ -288,23 +340,6 @@
 void wlan_hdd_cfg80211_stats_ext2_callback(void *ctx,
 				struct sir_sme_rx_aggr_hole_ind *pmsg);
 
-void wlan_hdd_cfg80211_link_layer_stats_callback(void *ctx,
-						 int indType, void *pRsp);
-/**
- * wlan_hdd_cfg80211_link_layer_stats_ext_callback() - Callback for LL ext
- * @ctx: HDD context
- * @rsp: msg from FW
- *
- * This function is an extension of
- * wlan_hdd_cfg80211_link_layer_stats_callback. It converts
- * monitoring parameters offloaded to NL data and send the same to the
- * kernel/upper layers.
- *
- * Return: None.
- */
-void wlan_hdd_cfg80211_link_layer_stats_ext_callback(hdd_handle_t ctx,
-						     tSirLLStatsResults *rsp);
-
 /**
  * wlan_hdd_get_rcpi() - Wrapper to get current RCPI
  * @adapter: adapter upon which the measurement is requested
diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h
index e12a59d..68ea680 100644
--- a/core/mac/inc/sir_api.h
+++ b/core/mac/inc/sir_api.h
@@ -4487,28 +4487,6 @@
 } tSirAutoShutdownEvtParams;
 #endif
 
-#ifdef WLAN_FEATURE_LINK_LAYER_STATS
-
-typedef struct {
-	uint32_t reqId;
-	uint8_t staId;
-	uint32_t mpduSizeThreshold;
-	uint32_t aggressiveStatisticsGathering;
-} tSirLLStatsSetReq, *tpSirLLStatsSetReq;
-
-typedef struct {
-	uint32_t reqId;
-	uint8_t staId;
-	uint32_t paramIdMask;
-} tSirLLStatsGetReq, *tpSirLLStatsGetReq;
-
-typedef struct {
-	uint32_t reqId;
-	uint8_t staId;
-	uint32_t statsClearReqMask;
-	uint8_t stopReq;
-} tSirLLStatsClearReq, *tpSirLLStatsClearReq;
-
 #ifdef WLAN_POWER_DEBUGFS
 /**
  * struct power_stats_response - Power stats response
@@ -4595,6 +4573,27 @@
 	uint32_t dot11mode;
 };
 
+#define WIFI_INVALID_PEER_ID            (-1)
+#define WIFI_INVALID_VDEV_ID            (-1)
+#define WIFI_MAX_AC                     (4)
+
+typedef struct {
+	uint32_t paramId;
+	uint8_t ifaceId;
+	uint32_t rspId;
+	uint32_t moreResultToFollow;
+	uint32_t nr_received;
+	union {
+		uint32_t num_peers;
+		uint32_t num_radio;
+	};
+
+	uint32_t peer_event_number;
+	/* Variable  length field - Do not add anything after this */
+	uint8_t results[0];
+} tSirLLStatsResults, *tpSirLLStatsResults;
+
+#ifdef WLAN_FEATURE_LINK_LAYER_STATS
 /*---------------------------------------------------------------------------
    WLAN_HAL_LL_NOTIFY_STATS
    ---------------------------------------------------------------------------*/
@@ -4605,6 +4604,26 @@
 typedef int tSirWifiChannel;
 typedef int tSirwifiTxRate;
 
+typedef struct {
+	uint32_t reqId;
+	uint8_t staId;
+	uint32_t mpduSizeThreshold;
+	uint32_t aggressiveStatisticsGathering;
+} tSirLLStatsSetReq, *tpSirLLStatsSetReq;
+
+typedef struct {
+	uint32_t reqId;
+	uint8_t staId;
+	uint32_t paramIdMask;
+} tSirLLStatsGetReq, *tpSirLLStatsGetReq;
+
+typedef struct {
+	uint32_t reqId;
+	uint8_t staId;
+	uint32_t statsClearReqMask;
+	uint8_t stopReq;
+} tSirLLStatsClearReq, *tpSirLLStatsClearReq;
+
 /* channel operating width */
 typedef enum {
 	WIFI_CHAN_WIDTH_20 = 0,
@@ -5145,10 +5164,6 @@
 	struct sir_wifi_rx *rx_stats;
 };
 
-#define WIFI_INVALID_PEER_ID            (-1)
-#define WIFI_INVALID_VDEV_ID            (-1)
-#define WIFI_MAX_AC                     (4)
-
 /**
  * struct sir_wifi_ll_ext_peer_stats - per peer stats
  * @peer_id: peer ID
@@ -5456,22 +5471,6 @@
 #define LL_STATS_MIN_PERIOD          10
 #define LL_STATS_INVALID_PERIOD      0xFFFFFFFF
 
-typedef struct {
-	uint32_t paramId;
-	uint8_t ifaceId;
-	uint32_t rspId;
-	uint32_t moreResultToFollow;
-	uint32_t nr_received;
-	union {
-		uint32_t num_peers;
-		uint32_t num_radio;
-	};
-
-	uint32_t peer_event_number;
-	/* Variable  length field - Do not add anything after this */
-	uint8_t results[0];
-} tSirLLStatsResults, *tpSirLLStatsResults;
-
 /* Result ID for LL stats extension */
 #define WMI_LL_STATS_EXT_PS_CHG             0x00000100
 #define WMI_LL_STATS_EXT_TX_FAIL            0x00000200
diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h
index 8881bc1..271a663 100644
--- a/core/sme/inc/sme_api.h
+++ b/core/sme/inc/sme_api.h
@@ -972,6 +972,27 @@
 QDF_STATUS sme_reset_link_layer_stats_ind_cb(tHalHandle hhal);
 QDF_STATUS sme_ll_stats_set_thresh(tHalHandle hal,
 				struct sir_ll_ext_stats_threshold *threshold);
+#else /* WLAN_FEATURE_LINK_LAYER_STATS */
+static inline QDF_STATUS
+sme_set_link_layer_ext_cb(tHalHandle hal, void (*ll_stats_ext_cb)
+			  (hdd_handle_t callback_ctx, tSirLLStatsResults
+			  *rsp))
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline QDF_STATUS
+sme_set_link_layer_stats_ind_cb(tHalHandle hHal, void (*callback_routine)
+				(void *callbackCtx, int indType, void *pRsp))
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline QDF_STATUS
+sme_reset_link_layer_stats_ind_cb(tHalHandle hhal)
+{
+	return QDF_STATUS_SUCCESS;
+}
 #endif /* WLAN_FEATURE_LINK_LAYER_STATS */
 
 QDF_STATUS sme_set_wisa_params(tHalHandle hal,
diff --git a/core/sme/inc/sme_internal.h b/core/sme/inc/sme_internal.h
index 9e9d534..83d4e77 100644
--- a/core/sme/inc/sme_internal.h
+++ b/core/sme/inc/sme_internal.h
@@ -179,13 +179,10 @@
 #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
 	host_event_wlan_status_payload_type eventPayload;
 #endif
-#ifdef WLAN_FEATURE_LINK_LAYER_STATS
 	void (*pLinkLayerStatsIndCallback)(void *callbackContext,
 			int indType, void *pRsp);
 	void (*link_layer_stats_ext_cb)(hdd_handle_t callback_ctx,
 					tSirLLStatsResults *rsp);
-#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
-
 #ifdef WLAN_POWER_DEBUGFS
 	void *power_debug_stats_context;
 	void (*power_stats_resp_callback)(struct power_stats_response *rsp,
diff --git a/core/wma/inc/wma_api.h b/core/wma/inc/wma_api.h
index 54b195b..8f203bf 100644
--- a/core/wma/inc/wma_api.h
+++ b/core/wma/inc/wma_api.h
@@ -174,7 +174,16 @@
 QDF_STATUS wma_get_caps_for_phyidx_hwmode(struct wma_caps_per_phy *caps_per_phy,
 		enum hw_mode_dbs_capab hw_mode, enum cds_band_type band);
 bool wma_is_rx_ldpc_supported_for_channel(uint32_t channel);
+
+#ifdef WLAN_FEATURE_LINK_LAYER_STATS
 int wma_unified_radio_tx_mem_free(void *handle);
+#else /* WLAN_FEATURE_LINK_LAYER_STATS */
+static inline int wma_unified_radio_tx_mem_free(void *handle)
+{
+	return 0;
+}
+#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
+
 /**
  * wma_form_unit_test_cmd_and_send() - to form a wma command and send it to FW
  * @session_id: wma session id to be filled while forming the command
@@ -327,6 +336,7 @@
  */
 void wma_store_pdev(void *wma_ctx, struct wlan_objmgr_pdev *pdev);
 
+#ifdef WLAN_FEATURE_LINK_LAYER_STATS
 /**
  * wmi_to_sir_peer_type() - convert peer type from WMI to SIR enum
  * @type: enum wmi_peer_type
@@ -334,6 +344,7 @@
  * Return: tSirWifiPeerType
  */
 tSirWifiPeerType wmi_to_sir_peer_type(enum wmi_peer_type type);
+#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
 
 QDF_STATUS wma_crash_inject(WMA_HANDLE wma_handle, uint32_t type,
 			    uint32_t delay_time_ms);
diff --git a/core/wma/src/wma_utils.c b/core/wma/src/wma_utils.c
index 6b26d0e..71ec0bf 100644
--- a/core/wma/src/wma_utils.c
+++ b/core/wma/src/wma_utils.c
@@ -4511,6 +4511,7 @@
 	return status;
 }
 
+#ifdef WLAN_FEATURE_LINK_LAYER_STATS
 tSirWifiPeerType wmi_to_sir_peer_type(enum wmi_peer_type type)
 {
 	switch (type) {
@@ -4527,6 +4528,7 @@
 		return WIFI_PEER_INVALID;
 	}
 }
+#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
 
 /**
  * wma_set_vc_mode_config() - set voltage corner mode config to FW.