浏览代码

qcacld-3.0: hdd: Refactor wlan_startup (phase 4)

In HDD, hdd_wlan_startup which is called by probe is beast of a
function to maintain. Over time it has grown to such an extent
that it is almost 800 lines of code with in a single function.
Divide the beast into logical smaller functions.

Fix style issues like conditional compilation with in the
function and other minor ones.

Change-Id: Iec2dc3aac934bbb90b87d4e8581e877e5b0a561c
CRs-fixed: 959287
Prashanth Bhatta 9 年之前
父节点
当前提交
9229132f4b

+ 4 - 1
core/cds/inc/cds_packet.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -109,6 +109,9 @@ void cds_pkt_proto_trace_init(void);
 
    ---------------------------------------------------------------------------*/
 void cds_pkt_proto_trace_close(void);
+#else
+static inline void cds_pkt_proto_trace_init(void) { }
+static inline void cds_pkt_proto_trace_close(void) {}
 #endif /* QCA_PKT_PROTO_TRACE */
 
 /**

+ 0 - 21
core/hdd/inc/wlan_hdd_main.h

@@ -1147,10 +1147,6 @@ struct hdd_context_s {
 	/* Lock to avoid race condition during start/stop bss */
 	struct mutex sap_lock;
 
-#ifdef WLAN_KD_READY_NOTIFIER
-	bool kd_nl_init;
-#endif /* WLAN_KD_READY_NOTIFIER */
-
 #ifdef FEATURE_OEM_DATA_SUPPORT
 	/* OEM App registered or not */
 	bool oem_app_registered;
@@ -1462,23 +1458,6 @@ bool hdd_is_5g_supported(hdd_context_t *pHddCtx);
 
 int wlan_hdd_scan_abort(hdd_adapter_t *pAdapter);
 
-#ifdef WLAN_FEATURE_STATS_EXT
-void wlan_hdd_cfg80211_stats_ext_init(hdd_context_t *pHddCtx);
-#endif
-
-#ifdef WLAN_FEATURE_LINK_LAYER_STATS
-void wlan_hdd_cfg80211_link_layer_stats_init(hdd_context_t *pHddCtx);
-static inline bool hdd_link_layer_stats_supported(void)
-{
-	return true;
-}
-#else
-static inline bool hdd_link_layer_stats_supported(void)
-{
-	return false;
-}
-#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
-
 void hdd_get_fw_version(hdd_context_t *hdd_ctx,
 			uint32_t *major_spid, uint32_t *minor_spid,
 			uint32_t *siid, uint32_t *crmid);

+ 9 - 6
core/hdd/inc/wlan_hdd_oemdata.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -25,8 +25,6 @@
  * to the Linux Foundation.
  */
 
-#ifdef FEATURE_OEM_DATA_SUPPORT
-
 /**
  * DOC: wlan_hdd_oemdata.h
  *
@@ -36,6 +34,8 @@
 #ifndef __WLAN_HDD_OEM_DATA_H__
 #define __WLAN_HDD_OEM_DATA_H__
 
+#ifdef FEATURE_OEM_DATA_SUPPORT
+
 #ifndef OEM_DATA_REQ_SIZE
 #define OEM_DATA_REQ_SIZE 280
 #endif
@@ -166,7 +166,10 @@ int iw_get_oem_data_cap(struct net_device *dev, struct iw_request_info *info,
 int oem_activate_service(struct hdd_context_s *hdd_ctx);
 
 void hdd_send_oem_data_rsp_msg(int length, uint8_t *oemDataRsp);
-
-#endif /* __WLAN_HDD_OEM_DATA_H__ */
-
+#else
+static inline int oem_activate_service(struct hdd_context_s *hdd_ctx)
+{
+	return 0;
+}
 #endif /* FEATURE_OEM_DATA_SUPPORT */
+#endif /* __WLAN_HDD_OEM_DATA_H__ */

+ 55 - 75
core/hdd/src/wlan_hdd_main.c

@@ -5448,8 +5448,9 @@ int hdd_wlan_startup(struct device *dev, void *hif_sc)
 	hdd_adapter_t *adapter = NULL;
 	hdd_context_t *hdd_ctx = NULL;
 	int ret;
-	tSirTxPowerLimit *hddtxlimit;
+	tSirTxPowerLimit hddtxlimit;
 	bool rtnl_held;
+	tSirRetStatus hal_status;
 
 	ENTER();
 
@@ -5473,10 +5474,6 @@ int hdd_wlan_startup(struct device *dev, void *hif_sc)
 		goto success;
 	}
 
-	cds_set_recovery_in_progress(false);
-
-	cds_set_connection_in_progress(false);
-
 	hdd_wlan_green_ap_init(hdd_ctx);
 
 	status = cds_open();
@@ -5559,27 +5556,19 @@ int hdd_wlan_startup(struct device *dev, void *hif_sc)
 		       FL("can't update mac config, using MAC from ini file"));
 	}
 
-	{
-		CDF_STATUS cdf_ret_status;
-		/*
-		 * Set the MAC Address Currently this is used by HAL to
-		 * add self sta. Remove this once self sta is added as
-		 * part of session open.
-		 */
-		cdf_ret_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID,
-					     (uint8_t *) &hdd_ctx->config->
-					     intfMacAddr[0],
-					     sizeof(hdd_ctx->config->
-						    intfMacAddr[0]));
+	/*
+	 * Set the MAC Address Currently this is used by HAL to add self sta.
+	 * Remove this once self sta is added as part of session open.
+	 */
+	hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID,
+				     hdd_ctx->config->intfMacAddr[0].bytes,
+				     sizeof(hdd_ctx->config->intfMacAddr[0]));
 
-		if (!CDF_IS_STATUS_SUCCESS(cdf_ret_status)) {
-			hddLog(CDF_TRACE_LEVEL_ERROR,
-			       FL(
-				  "Failed to set MAC Address. HALStatus is %08d [x%08x]"
-				 ),
-			       cdf_ret_status, cdf_ret_status);
-			goto err_wiphy_unregister;
-		}
+	if (!IS_SIR_STATUS_SUCCESS(hal_status)) {
+		hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]",
+			hal_status, hal_status);
+		ret = -EINVAL;
+		goto err_wiphy_unregister;
 	}
 
 	if (hdd_ipa_init(hdd_ctx) == CDF_STATUS_E_FAILURE)
@@ -5603,9 +5592,8 @@ int hdd_wlan_startup(struct device *dev, void *hif_sc)
 		       FL("hdd_post_cds_enable_config failed"));
 		goto err_cds_disable;
 	}
-#ifdef QCA_PKT_PROTO_TRACE
+
 	cds_pkt_proto_trace_init();
-#endif /* QCA_PKT_PROTO_TRACE */
 
 	rtnl_held = hdd_hold_rtnl_lock();
 
@@ -5637,16 +5625,13 @@ int hdd_wlan_startup(struct device *dev, void *hif_sc)
 
 	sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done);
 
-#ifdef FEATURE_OEM_DATA_SUPPORT
 	sme_register_oem_data_rsp_callback(hdd_ctx->hHal,
 					hdd_send_oem_data_rsp_msg);
-#endif
 
-	/* Open debugfs interface */
-	if (CDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) {
-		hddLog(CDF_TRACE_LEVEL_ERROR,
-		       FL("hdd_debugfs_init failed!"));
-	}
+	status = hdd_debugfs_init(adapter);
+
+	if (CDF_IS_STATUS_SUCCESS(status))
+		hdd_err("hdd_debugfs_init failed: %d!", status);
 
 	/* FW capabilities received, Set the Dot11 mode */
 	sme_setdef_dot11mode(hdd_ctx->hHal);
@@ -5656,32 +5641,22 @@ int hdd_wlan_startup(struct device *dev, void *hif_sc)
 		hddLog(CDF_TRACE_LEVEL_FATAL, FL("nl_srv_init failed"));
 		goto err_close_adapter;
 	}
-#ifdef WLAN_KD_READY_NOTIFIER
-	hdd_ctx->kd_nl_init = 1;
-#endif /* WLAN_KD_READY_NOTIFIER */
 
-#ifdef FEATURE_OEM_DATA_SUPPORT
-	/* Initialize the OEM service */
-	if (oem_activate_service(hdd_ctx) != 0) {
-		hddLog(CDF_TRACE_LEVEL_FATAL,
-		       FL("oem_activate_service failed"));
+	ret = oem_activate_service(hdd_ctx);
+	if (ret) {
+		hdd_alert("oem_activate_service failed: %d", ret);
 		goto err_nl_srv;
 	}
-#endif
 
-#ifdef PTT_SOCK_SVC_ENABLE
-	/* Initialize the PTT service */
-	if (ptt_sock_activate_svc() != 0) {
-		hddLog(CDF_TRACE_LEVEL_FATAL,
-		       FL("ptt_sock_activate_svc failed"));
+	ret = ptt_sock_activate_svc();
+	if (ret) {
+		hdd_alert("ptt_sock_activate_svc failed: %d", ret);
 		goto err_nl_srv;
 	}
-#endif
 
-	/* Initialize the CNSS-DIAG service */
-	if (cnss_diag_activate_service() < 0) {
-		hddLog(CDF_TRACE_LEVEL_FATAL,
-		       FL("cnss_diag_activate_service failed"));
+	ret = cnss_diag_activate_service();
+	if (ret) {
+		hdd_alert("cnss_diag_activate_service failed: %d", ret);
 		goto err_nl_srv;
 	}
 
@@ -5749,19 +5724,11 @@ int hdd_wlan_startup(struct device *dev, void *hif_sc)
 	if (0 != hdd_lro_init(hdd_ctx))
 		hdd_err("Unable to initialize LRO in fw");
 
-	/* SAR power limit */
-	hddtxlimit = cdf_mem_malloc(sizeof(tSirTxPowerLimit));
-	if (!hddtxlimit) {
-		hddLog(CDF_TRACE_LEVEL_ERROR,
-		       FL("Memory allocation for TxPowerLimit failed!"));
-		goto err_unreg_netdev_notifier;
-	}
-	hddtxlimit->txPower2g = hdd_ctx->config->TxPower2g;
-	hddtxlimit->txPower5g = hdd_ctx->config->TxPower5g;
-
-	if (CDF_STATUS_SUCCESS != sme_txpower_limit(hdd_ctx->hHal, hddtxlimit))
-		hddLog(CDF_TRACE_LEVEL_ERROR,
-		       FL("Error setting txlimit in sme"));
+	hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g;
+	hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g;
+	status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit);
+	if (CDF_IS_STATUS_SUCCESS(status))
+		hdd_err("Error setting txlimit in sme: %d", status);
 
 #ifdef MSM_PLATFORM
 	spin_lock_init(&hdd_ctx->bus_bw_lock);
@@ -5770,25 +5737,20 @@ int hdd_wlan_startup(struct device *dev, void *hif_sc)
 			  hdd_bus_bw_compute_cbk, (void *)hdd_ctx);
 #endif
 
-#ifdef WLAN_FEATURE_STATS_EXT
 	wlan_hdd_cfg80211_stats_ext_init(hdd_ctx);
-#endif
-#ifdef FEATURE_WLAN_EXTSCAN
+
 	sme_ext_scan_register_callback(hdd_ctx->hHal,
 				       wlan_hdd_cfg80211_extscan_callback);
-#endif /* FEATURE_WLAN_EXTSCAN */
+
 	sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal,
 				hdd_rssi_threshold_breached);
-#ifdef WLAN_FEATURE_LINK_LAYER_STATS
-	wlan_hdd_cfg80211_link_layer_stats_init(hdd_ctx);
-#endif
 
-#ifdef WLAN_FEATURE_LPSS
+	hdd_cfg80211_link_layer_stats_init(hdd_ctx);
+
 	wlan_hdd_send_all_scan_intf_info(hdd_ctx);
 	wlan_hdd_send_version_pkg(hdd_ctx->target_fw_version,
 				  hdd_ctx->target_hw_version,
 				  hdd_ctx->target_hw_name);
-#endif
 
 	cdf_spinlock_init(&hdd_ctx->hdd_roc_req_q_lock);
 	cdf_list_init((&hdd_ctx->hdd_roc_req_q), MAX_ROC_REQ_QUEUE_ENTRY);
@@ -6328,6 +6290,24 @@ void wlan_hdd_send_all_scan_intf_info(hdd_context_t *hdd_ctx)
 	if (!scan_intf_found)
 		wlan_hdd_send_status_pkg(pDataAdapter, NULL, 1, 0);
 }
+#else
+static inline void wlan_hdd_send_status_pkg(hdd_adapter_t *pAdapter,
+					    hdd_station_ctx_t *pHddStaCtx,
+					    uint8_t is_on, uint8_t is_connected)
+{
+	return;
+}
+
+static inline void wlan_hdd_send_version_pkg(uint32_t fw_version, uint32_t
+					     chip_id, const char *chip_name)
+{
+	return;
+}
+
+static inline void wlan_hdd_send_all_scan_intf_info(hdd_context_t *pHddCtx)
+{
+	return;
+}
 #endif
 
 #ifdef FEATURE_WLAN_AUTO_SHUTDOWN

+ 2 - 2
core/hdd/src/wlan_hdd_stats.c

@@ -1100,12 +1100,12 @@ static void wlan_hdd_cfg80211_link_layer_stats_callback(void *ctx,
 }
 
 /**
- * wlan_hdd_cfg80211_link_layer_stats_init() - initialize link layer stats
+ * hdd_cfg80211_link_layer_stats_init() - Initialize link layer stats
  * @pHddCtx: Pointer to hdd context
  *
  * Return: None
  */
-void wlan_hdd_cfg80211_link_layer_stats_init(hdd_context_t *pHddCtx)
+void hdd_cfg80211_link_layer_stats_init(hdd_context_t *pHddCtx)
 {
 	sme_set_link_layer_stats_ind_cb(pHddCtx->hHal,
 					wlan_hdd_cfg80211_link_layer_stats_callback);

+ 23 - 0
core/hdd/src/wlan_hdd_stats.h

@@ -90,6 +90,8 @@ struct index_data_rate_type {
  */
 #define LL_STATS_EVENT_BUF_SIZE 4096
 
+void hdd_cfg80211_link_layer_stats_init(hdd_context_t *pHddCtx);
+
 /**
  * wlan_hdd_cfg80211_ll_stats_set() - set link layer stats
  * @wiphy: Pointer to wiphy
@@ -134,12 +136,29 @@ int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
 				     int data_len);
 
 void hdd_init_ll_stats_ctx(void);
+
+static inline bool hdd_link_layer_stats_supported(void)
+{
+	return true;
+}
+
 #else
+
+static inline void hdd_cfg80211_link_layer_stats_init(hdd_context_t *pHddCtx)
+{
+	return;
+}
+
 static inline void hdd_init_ll_stats_ctx(void)
 {
 	return;
 }
 
+static inline bool hdd_link_layer_stats_supported(void)
+{
+	return false;
+}
+
 #endif /* End of WLAN_FEATURE_LINK_LAYER_STATS */
 
 #ifdef WLAN_FEATURE_STATS_EXT
@@ -156,6 +175,10 @@ int wlan_hdd_cfg80211_stats_ext_request(struct wiphy *wiphy,
 					struct wireless_dev *wdev,
 					const void *data,
 					int data_len);
+
+void wlan_hdd_cfg80211_stats_ext_init(hdd_context_t *pHddCtx);
+#else
+static inline void wlan_hdd_cfg80211_stats_ext_init(hdd_context_t *pHddCtx) {}
 #endif /* End of WLAN_FEATURE_STATS_EXT */
 
 /**

+ 12 - 0
core/sme/inc/sme_api.h

@@ -357,6 +357,12 @@ extern CDF_STATUS sme_register11d_scan_done_callback(tHalHandle hHal,
 #ifdef FEATURE_OEM_DATA_SUPPORT
 extern CDF_STATUS sme_register_oem_data_rsp_callback(tHalHandle h_hal,
 		sme_send_oem_data_rsp_msg callback);
+#else
+static inline CDF_STATUS sme_register_oem_data_rsp_callback(tHalHandle h_hal,
+		sme_send_oem_data_rsp_msg callback)
+{
+	return CDF_STATUS_SUCCESS;
+}
 #endif
 
 extern CDF_STATUS sme_wow_add_pattern(tHalHandle hHal,
@@ -832,6 +838,12 @@ sme_set_ssid_hotlist(tHalHandle hal,
 
 CDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
 		void (*pExtScanIndCb)(void *, const uint16_t, void *));
+#else
+static inline CDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
+		void (*pExtScanIndCb)(void *, const uint16_t, void *))
+{
+	return CDF_STATUS_SUCCESS;
+}
 #endif /* FEATURE_WLAN_EXTSCAN */
 CDF_STATUS sme_abort_roam_scan(tHalHandle hHal, uint8_t sessionId);
 #ifdef WLAN_FEATURE_LINK_LAYER_STATS

+ 13 - 10
core/sme/src/common/sme_api.c

@@ -12047,12 +12047,23 @@ CDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx)
 	CDF_STATUS cdf_status = CDF_STATUS_SUCCESS;
 	cds_msg_t cds_message;
 	tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
+	tSirTxPowerLimit *tx_power_limit;
+
+	tx_power_limit = cdf_mem_malloc(sizeof(*tx_power_limit));
+	if (!tx_power_limit) {
+		CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_ERROR,
+			  "%s: Memory allocation for TxPowerLimit failed!",
+			  __func__);
+		return CDF_STATUS_E_FAILURE;
+	}
+
+	*tx_power_limit = *psmetx;
 
 	status = sme_acquire_global_lock(&pMac->sme);
 	if (CDF_IS_STATUS_SUCCESS(status)) {
 		cds_message.type = WMA_TX_POWER_LIMIT;
 		cds_message.reserved = 0;
-		cds_message.bodyptr = psmetx;
+		cds_message.bodyptr = tx_power_limit;
 
 		cdf_status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
 		if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
@@ -12060,7 +12071,7 @@ CDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx)
 				  "%s: not able to post WMA_TX_POWER_LIMIT",
 				  __func__);
 			status = CDF_STATUS_E_FAILURE;
-			cdf_mem_free(psmetx);
+			cdf_mem_free(tx_power_limit);
 		}
 		sme_release_global_lock(&pMac->sme);
 	}
@@ -13079,14 +13090,6 @@ CDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
 	}
 	return status;
 }
-
-#else
-CDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
-		  void (*pExtScanIndCb)(void *, const uint16_t, void *))
-{
-	return CDF_STATUS_SUCCESS;
-}
-
 #endif /* FEATURE_WLAN_EXTSCAN */
 
 #ifdef WLAN_FEATURE_LINK_LAYER_STATS

+ 3 - 6
core/utils/fwlog/dbglog_host.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2015 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -57,7 +57,6 @@
 
 static bool appstarted = false;
 static bool senddriverstatus = false;
-static bool kd_nl_init = false;
 static int cnss_diag_pid = INVALID_PID;
 static int get_version = 0;
 static int gprint_limiter = 0;
@@ -4264,12 +4263,11 @@ int cnss_diag_activate_service()
 
 	/* Register the msg handler for msgs addressed to WLAN_NL_MSG_OEM */
 	ret = nl_srv_register(WLAN_NL_MSG_CNSS_DIAG, cnss_diag_msg_callback);
-	if (ret == -EINVAL) {
+	if (ret) {
 		AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
-				("CNSS-DIAG Registeration failed \n"));
+				("CNSS-DIAG Registration failed"));
 		return ret;
 	}
-	kd_nl_init = true;
 	return 0;
 }
 
@@ -4459,6 +4457,5 @@ int dbglog_deinit(wmi_unified_t wmi_handle)
 	if (res != 0)
 		return res;
 
-	kd_nl_init = false;
 	return res;
 }

+ 11 - 1
core/utils/ptt/inc/wlan_ptt_sock_svc.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -92,9 +92,19 @@
  * Length      : 4 bytes [LEN_PAYLOAD]
  * Payload     : LEN_PAYLOAD bytes
  */
+#ifdef PTT_SOCK_SVC_ENABLE
 int ptt_sock_activate_svc(void);
 void ptt_sock_deactivate_svc(void);
 int ptt_sock_send_msg_to_app(tAniHdr *wmsg, int radio, int src_mod, int pid);
+#else
+static inline int ptt_sock_activate_svc(void) { return 0; }
+static inline void ptt_sock_deactivate_svc(void) { return; }
+static inline int ptt_sock_send_msg_to_app(tAniHdr *wmsg, int radio,
+					   int src_mod, int pid)
+{
+	return 0;
+}
+#endif
 
 /*
  * Format of message exchanged between the PTT Socket App in userspace and the