Browse Source

qcacld-3.0: Refactor adapter deinit APIs

To deinitialize per link information, introduce new API
to deinit each active links in adapter.

New API: hdd_deinit_session()

Change-Id: Icc4bedd85818e40b8543c4f397c04367405f8889
CRs-Fixed: 3523981
Vinod Kumar Pirla 2 years ago
parent
commit
faca61889f

+ 23 - 1
core/hdd/inc/wlan_hdd_main.h

@@ -2911,6 +2911,18 @@ struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx,
  */
 enum QDF_OPMODE hdd_get_device_mode(uint32_t vdev_id);
 
+/**
+ * hdd_deinit_session() - Cleanup session context in
+ * adapter
+ * @adapter: HDD adapter
+ *
+ * The API cleans up session context and scan IEs
+ * in link_info and adapter.
+ *
+ * Return: None
+ */
+void hdd_deinit_session(struct hdd_adapter *adapter);
+
 void hdd_deinit_adapter(struct hdd_context *hdd_ctx,
 			struct hdd_adapter *adapter,
 			bool rtnl_held);
@@ -4036,7 +4048,17 @@ bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx,
 
 int hdd_enable_disable_ca_event(struct hdd_context *hddctx,
 				uint8_t set_value);
-void wlan_hdd_undo_acs(struct hdd_adapter *adapter);
+
+/**
+ * wlan_hdd_undo_acs : Do cleanup of DO_ACS
+ * @link_info: Pointer of link_info in adapter
+ *
+ * This function handle cleanup of what was done in DO_ACS, including free
+ * memory.
+ *
+ * Return: void
+ */
+void wlan_hdd_undo_acs(struct wlan_hdd_link_info *link_info);
 
 /**
  * wlan_hdd_set_restriction_mask() - set restriction mask for hdd context

+ 4 - 13
core/hdd/src/wlan_hdd_cfg80211.c

@@ -3854,7 +3854,7 @@ static int __wlan_hdd_cfg80211_do_acs(struct wiphy *wiphy,
 	sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(link_info);
 
 	/* Check and free if memory is already allocated for acs channel list */
-	wlan_hdd_undo_acs(adapter);
+	wlan_hdd_undo_acs(link_info);
 
 	qdf_mem_zero(&sap_config->acs_cfg, sizeof(struct sap_acs_cfg));
 
@@ -4208,19 +4208,10 @@ static int wlan_hdd_cfg80211_do_acs(struct wiphy *wiphy,
 	return errno;
 }
 
-/**
- * wlan_hdd_undo_acs : Do cleanup of DO_ACS
- * @adapter:  Pointer to adapter struct
- *
- * This function handle cleanup of what was done in DO_ACS, including free
- * memory.
- *
- * Return: void
- */
-void wlan_hdd_undo_acs(struct hdd_adapter *adapter)
+void wlan_hdd_undo_acs(struct wlan_hdd_link_info *link_info)
 {
-	sap_undo_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter->deflink),
-		     &adapter->deflink->session.ap.sap_config);
+	sap_undo_acs(WLAN_HDD_GET_SAP_CTX_PTR(link_info),
+		     &link_info->session.ap.sap_config);
 }
 
 /**

+ 27 - 26
core/hdd/src/wlan_hdd_hostapd.c

@@ -315,7 +315,7 @@ error:
 
 /**
  * hdd_hostapd_deinit_sap_session() - To de-init the sap session completely
- * @adapter: SAP/GO adapter
+ * @link_info: Pointer of link_info in adapter
  *
  * This API will do
  * 1) sap_init_ctx()
@@ -323,29 +323,25 @@ error:
  *
  * Return: 0 if success else non-zero value.
  */
-static int hdd_hostapd_deinit_sap_session(struct hdd_adapter *adapter)
+static int
+hdd_hostapd_deinit_sap_session(struct wlan_hdd_link_info *link_info)
 {
 	struct sap_context *sap_ctx;
 	int status = 0;
 
-	if (!adapter) {
-		hdd_err("invalid adapter");
-		return -EINVAL;
-	}
-
-	sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(adapter->deflink);
+	sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(link_info);
 	if (!sap_ctx) {
 		hdd_debug("sap context already released, nothing to be done");
 		return 0;
 	}
 
-	wlan_hdd_undo_acs(adapter);
+	wlan_hdd_undo_acs(link_info);
 	if (!QDF_IS_STATUS_SUCCESS(sap_deinit_ctx(sap_ctx))) {
 		hdd_err("Error stopping the sap session");
 		status = -EINVAL;
 	}
 
-	if (!hdd_sap_destroy_ctx(adapter)) {
+	if (!hdd_sap_destroy_ctx(link_info)) {
 		hdd_err("Error closing the sap session");
 		status = -EINVAL;
 	}
@@ -4175,13 +4171,13 @@ bool hdd_sap_create_ctx(struct hdd_adapter *adapter)
 	return false;
 }
 
-bool hdd_sap_destroy_ctx(struct hdd_adapter *adapter)
+bool hdd_sap_destroy_ctx(struct wlan_hdd_link_info *link_info)
 {
-	struct sap_context *sap_ctx = adapter->deflink->session.ap.sap_context;
+	struct sap_context *sap_ctx = link_info->session.ap.sap_context;
 
-	if (adapter->deflink->session.ap.beacon) {
-		qdf_mem_free(adapter->deflink->session.ap.beacon);
-		adapter->deflink->session.ap.beacon = NULL;
+	if (link_info->session.ap.beacon) {
+		qdf_mem_free(link_info->session.ap.beacon);
+		link_info->session.ap.beacon = NULL;
 	}
 
 	if (!sap_ctx) {
@@ -4194,7 +4190,7 @@ bool hdd_sap_destroy_ctx(struct hdd_adapter *adapter)
 	if (QDF_IS_STATUS_ERROR(sap_destroy_ctx(sap_ctx)))
 		return false;
 
-	adapter->deflink->session.ap.sap_context = NULL;
+	link_info->session.ap.sap_context = NULL;
 
 	return true;
 }
@@ -4202,6 +4198,7 @@ bool hdd_sap_destroy_ctx(struct hdd_adapter *adapter)
 void hdd_sap_destroy_ctx_all(struct hdd_context *hdd_ctx, bool is_ssr)
 {
 	struct hdd_adapter *adapter, *next_adapter = NULL;
+	struct wlan_hdd_link_info *link_info;
 
 	/* sap_ctx is not destroyed as it will be leveraged for sap restart */
 	if (is_ssr)
@@ -4211,8 +4208,12 @@ void hdd_sap_destroy_ctx_all(struct hdd_context *hdd_ctx, bool is_ssr)
 
 	hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter,
 					   NET_DEV_HOLD_SAP_DESTROY_CTX_ALL) {
-		if (adapter->device_mode == QDF_SAP_MODE)
-			hdd_sap_destroy_ctx(adapter);
+		if (adapter->device_mode == QDF_SAP_MODE) {
+			hdd_adapter_for_each_active_link_info(adapter,
+							      link_info) {
+				hdd_sap_destroy_ctx(link_info);
+			}
+		}
 		hdd_adapter_dev_put_debug(adapter,
 					  NET_DEV_HOLD_SAP_DESTROY_CTX_ALL);
 	}
@@ -4372,36 +4373,36 @@ QDF_STATUS hdd_init_ap_mode(struct hdd_adapter *adapter, bool reinit)
 error_release_softap_tx_rx:
 	hdd_unregister_wext(adapter->dev);
 error_deinit_sap_session:
-	hdd_hostapd_deinit_sap_session(adapter);
+	hdd_hostapd_deinit_sap_session(adapter->deflink);
 error_release_vdev:
 	hdd_exit();
 	return status;
 }
 
-void hdd_deinit_ap_mode(struct hdd_context *hdd_ctx,
-			struct hdd_adapter *adapter,
-			bool rtnl_held)
+void hdd_deinit_ap_mode(struct wlan_hdd_link_info *link_info)
 {
 	struct hdd_ap_ctx *ap_ctx;
+	struct hdd_adapter *adapter = link_info->adapter;
 
 	hdd_enter_dev(adapter->dev);
 
-	ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter->deflink);
+	ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(link_info);
 	if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) {
 		hdd_wmm_adapter_close(adapter);
 		clear_bit(WMM_INIT_DONE, &adapter->event_flags);
 	}
+
 	qdf_atomic_set(&ap_ctx->acs_in_progress, 0);
 	if (qdf_atomic_read(&ap_ctx->ch_switch_in_progress)) {
 		qdf_atomic_set(&ap_ctx->ch_switch_in_progress, 0);
-		policy_mgr_set_chan_switch_complete_evt(hdd_ctx->psoc);
+		policy_mgr_set_chan_switch_complete_evt(adapter->hdd_ctx->psoc);
 
 		/* Re-enable roaming on all connected STA vdev */
-		wlan_hdd_set_roaming_state(adapter->deflink,
+		wlan_hdd_set_roaming_state(link_info,
 					   RSO_SAP_CHANNEL_CHANGE, true);
 	}
 
-	if (hdd_hostapd_deinit_sap_session(adapter))
+	if (hdd_hostapd_deinit_sap_session(link_info))
 		hdd_err("Failed:hdd_hostapd_deinit_sap_session");
 
 	hdd_exit();

+ 5 - 7
core/hdd/src/wlan_hdd_hostapd.h

@@ -251,16 +251,14 @@ QDF_STATUS hdd_init_ap_mode(struct hdd_adapter *adapter, bool reinit);
 
 /**
  * hdd_deinit_ap_mode() - to deinit the AP adaptor
- * @hdd_ctx: pointer to hdd_ctx
- * @adapter: SAP/GO adapter
- * @rtnl_held: flag to indicate if RTNL lock needs to be acquired
+ * @link_info: Link info pointer in HDD adapter
  *
  * This API can be called to close the SAP session as well as
  * release the vdev object completely. It also deinitializes necessary
  * SAP adapter related params.
  */
-void hdd_deinit_ap_mode(struct hdd_context *hdd_ctx,
-			struct hdd_adapter *adapter, bool rtnl_held);
+void hdd_deinit_ap_mode(struct wlan_hdd_link_info *link_info);
+
 void hdd_set_ap_ops(struct net_device *dev);
 /**
  * hdd_sap_create_ctx() - Wrapper API to create SAP context
@@ -274,14 +272,14 @@ void hdd_set_ap_ops(struct net_device *dev);
 bool hdd_sap_create_ctx(struct hdd_adapter *adapter);
 /**
  * hdd_sap_destroy_ctx() - Wrapper API to destroy SAP context
- * @adapter: pointer to adapter
+ * @link_info: Pointer of link_info in adapter
  *
  * This wrapper API can be called to destroy the sap context. It will
  * eventually calls SAP API to destroy the sap context
  *
  * Return: true or false based on overall success or failure
  */
-bool hdd_sap_destroy_ctx(struct hdd_adapter *adapter);
+bool hdd_sap_destroy_ctx(struct wlan_hdd_link_info *link_info);
 /**
  * hdd_sap_destroy_ctx_all() - Wrapper API to destroy all SAP context
  * @hdd_ctx: pointer to HDD context

+ 20 - 20
core/hdd/src/wlan_hdd_main.c

@@ -7437,37 +7437,25 @@ void hdd_check_for_net_dev_ref_leak(struct hdd_adapter *adapter)
 
 /**
  * hdd_deinit_station_mode() - De-initialize the station adapter
- * @hdd_ctx: global hdd context
- * @adapter: HDD adapter
- * @rtnl_held: Used to indicate whether or not the caller is holding
- *             the kernel rtnl_mutex
+ * @adapter: HDD adapter pointer
  *
  * This function De-initializes the STA/P2P/OCB adapter.
  *
  * Return: None.
  */
-static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx,
-				       struct hdd_adapter *adapter,
-				       bool rtnl_held)
+static void hdd_deinit_station_mode(struct hdd_adapter *adapter)
 {
-	hdd_enter_dev(adapter->dev);
-
 	if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) {
 		hdd_wmm_adapter_close(adapter);
 		clear_bit(WMM_INIT_DONE, &adapter->event_flags);
 	}
-
-
-	hdd_exit();
 }
 
-void hdd_deinit_adapter(struct hdd_context *hdd_ctx,
-			struct hdd_adapter *adapter,
-			bool rtnl_held)
+void hdd_deinit_session(struct hdd_adapter *adapter)
 {
-	hdd_enter();
+	struct wlan_hdd_link_info *link_info;
 
-	hdd_wext_unregister(adapter->dev, rtnl_held);
+	hdd_enter();
 
 	switch (adapter->device_mode) {
 	case QDF_STA_MODE:
@@ -7477,14 +7465,15 @@ void hdd_deinit_adapter(struct hdd_context *hdd_ctx,
 	case QDF_NDI_MODE:
 	case QDF_NAN_DISC_MODE:
 	{
-		hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held);
+		hdd_deinit_station_mode(adapter);
 		break;
 	}
 
 	case QDF_SAP_MODE:
 	case QDF_P2P_GO_MODE:
 	{
-		hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held);
+		hdd_adapter_for_each_active_link_info(adapter, link_info)
+			hdd_deinit_ap_mode(link_info);
 		break;
 	}
 
@@ -7501,6 +7490,17 @@ void hdd_deinit_adapter(struct hdd_context *hdd_ctx,
 	hdd_exit();
 }
 
+void hdd_deinit_adapter(struct hdd_context *hdd_ctx,
+			struct hdd_adapter *adapter,
+			bool rtnl_held)
+{
+	hdd_enter_dev(adapter->dev);
+
+	hdd_wext_unregister(adapter->dev, rtnl_held);
+	hdd_deinit_session(adapter);
+	hdd_exit();
+}
+
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) && \
      defined(WLAN_FEATURE_11AX)
 /**
@@ -14074,7 +14074,7 @@ sap_release_ref:
 sap_vdev_destroy:
 	hdd_vdev_destroy(link_info);
 sap_destroy_ctx:
-	hdd_sap_destroy_ctx(adapter);
+	hdd_sap_destroy_ctx(link_info);
 	return ret;
 }
 

+ 1 - 1
core/hdd/src/wlan_hdd_son.c

@@ -1972,7 +1972,7 @@ static int hdd_son_start_acs(struct wlan_objmgr_vdev *vdev, uint8_t enable)
 		hdd_err("ACS is in-progress");
 		return -EAGAIN;
 	}
-	wlan_hdd_undo_acs(adapter);
+	wlan_hdd_undo_acs(link_info);
 	sap_config = &link_info->session.ap.sap_config;
 	hdd_debug("ACS Config country %s hw_mode %d ACS_BW: %d START_CH: %d END_CH: %d band %d",
 		  hdd_ctx->reg.alpha2, sap_config->acs_cfg.hw_mode,