Browse Source

qcacld-3.0: Refactor STA and AP mode start adapter

Start station adapter will iterate through all active links
in the adapter.

Refactor SAP start adapter to point to deflink in adapter.

Change-Id: I32ee223305893007ce4db5370f52054e0ab411ca
CRs-Fixed: 3523950
Vinod Kumar Pirla 2 years ago
parent
commit
618b77fdae
2 changed files with 44 additions and 34 deletions
  1. 18 0
      core/hdd/inc/wlan_hdd_main.h
  2. 26 34
      core/hdd/src/wlan_hdd_main.c

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

@@ -3887,7 +3887,25 @@ QDF_STATUS hdd_sme_close_session_callback(uint8_t vdev_id);
 
 int hdd_register_cb(struct hdd_context *hdd_ctx);
 void hdd_deregister_cb(struct hdd_context *hdd_ctx);
+
+/**
+ * hdd_start_station_adapter()- Start the Station Adapter
+ * @adapter: HDD adapter
+ *
+ * This function initializes the adapter for the station mode.
+ *
+ * Return: 0 on success or errno on failure.
+ */
 int hdd_start_station_adapter(struct hdd_adapter *adapter);
+
+/**
+ * hdd_start_ap_adapter()- Start AP Adapter
+ * @adapter: HDD adapter
+ *
+ * This function initializes the adapter for the AP mode.
+ *
+ * Return: 0 on success errno on failure.
+ */
 int hdd_start_ap_adapter(struct hdd_adapter *adapter);
 int hdd_configure_cds(struct hdd_context *hdd_ctx);
 int hdd_set_fw_params(struct hdd_adapter *adapter);

+ 26 - 34
core/hdd/src/wlan_hdd_main.c

@@ -13938,18 +13938,11 @@ out:
 	hdd_debug("wlm initial mode %u", adapter->latency_level);
 }
 
-/**
- * hdd_start_station_adapter()- Start the Station Adapter
- * @adapter: HDD adapter
- *
- * This function initializes the adapter for the station mode.
- *
- * Return: 0 on success or errno on failure.
- */
 int hdd_start_station_adapter(struct hdd_adapter *adapter)
 {
 	QDF_STATUS status;
 	int ret;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_enter_dev(adapter->dev);
 	if (test_bit(SME_SESSION_OPENED, &adapter->deflink->link_flags)) {
@@ -13962,16 +13955,19 @@ int hdd_start_station_adapter(struct hdd_adapter *adapter)
 	    (adapter->device_mode == QDF_NAN_DISC_MODE))
 		wlan_hdd_lpc_del_monitor_interface(adapter->hdd_ctx);
 
-	ret = hdd_vdev_create(adapter->deflink);
-	if (ret) {
-		hdd_err("failed to create vdev: %d", ret);
-		return ret;
-	}
-	status = hdd_init_station_mode(adapter->deflink);
+	hdd_adapter_for_each_active_link_info(adapter, link_info) {
+		ret = hdd_vdev_create(link_info);
+		if (ret) {
+			hdd_err("failed to create vdev: %d", ret);
+			goto fail;
+		}
 
-	if (QDF_STATUS_SUCCESS != status) {
-		hdd_err("Error Initializing station mode: %d", status);
-		goto fail;
+		status = hdd_init_station_mode(link_info);
+		if (QDF_STATUS_SUCCESS != status) {
+			hdd_err("Error Initializing station mode: %d", status);
+			ret = qdf_status_to_os_return(status);
+			goto fail;
+		}
 	}
 
 	hdd_register_wext(adapter->dev);
@@ -13995,18 +13991,13 @@ int hdd_start_station_adapter(struct hdd_adapter *adapter)
 	return 0;
 
 fail:
+	hdd_adapter_for_each_active_link_info(adapter, link_info)
+		hdd_vdev_destroy(link_info);
+
 	hdd_unregister_wext(adapter->dev);
-	return qdf_status_to_os_return(status);
+	return ret;
 }
 
-/**
- * hdd_start_ap_adapter()- Start AP Adapter
- * @adapter: HDD adapter
- *
- * This function initializes the adapter for the AP mode.
- *
- * Return: 0 on success errno on failure.
- */
 int hdd_start_ap_adapter(struct hdd_adapter *adapter)
 {
 	QDF_STATUS status;
@@ -14014,12 +14005,13 @@ int hdd_start_ap_adapter(struct hdd_adapter *adapter)
 	int ret;
 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
 	struct sap_context *sap_ctx;
+	struct wlan_hdd_link_info *link_info = adapter->deflink;
 
 	hdd_enter();
 
-	if (test_bit(SME_SESSION_OPENED, &adapter->deflink->link_flags)) {
+	if (test_bit(SME_SESSION_OPENED, &link_info->link_flags)) {
 		hdd_err("session is already opened, %d",
-			adapter->deflink->vdev_id);
+			link_info->vdev_id);
 		return qdf_status_to_os_return(QDF_STATUS_SUCCESS);
 	}
 
@@ -14030,25 +14022,25 @@ int hdd_start_ap_adapter(struct hdd_adapter *adapter)
 	 * vdev as while creating the vdev, driver needs to
 	 * register SAP callback and that callback uses sap context
 	 */
-	if (adapter->deflink->session.ap.sap_context) {
+	if (WLAN_HDD_GET_SAP_CTX_PTR(link_info)) {
 		is_ssr = true;
 	} else if (!hdd_sap_create_ctx(adapter)) {
 		hdd_err("sap creation failed");
 		return qdf_status_to_os_return(QDF_STATUS_E_FAILURE);
 	}
 
-	ret = hdd_vdev_create(adapter->deflink);
+	ret = hdd_vdev_create(link_info);
 	if (ret) {
 		hdd_err("failed to create vdev, status:%d", ret);
 		goto sap_destroy_ctx;
 	}
 
-	sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(adapter->deflink);
+	sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(link_info);
 	status = sap_acquire_vdev_ref(hdd_ctx->psoc, sap_ctx,
-				      adapter->deflink->vdev_id);
+				      link_info->vdev_id);
 	if (!QDF_IS_STATUS_SUCCESS(status)) {
 		hdd_err("Failed to get vdev ref for sap for session_id: %u",
-			adapter->deflink->vdev_id);
+			link_info->vdev_id);
 		ret = qdf_status_to_os_return(status);
 		goto sap_vdev_destroy;
 	}
@@ -14080,7 +14072,7 @@ int hdd_start_ap_adapter(struct hdd_adapter *adapter)
 sap_release_ref:
 	sap_release_vdev_ref(sap_ctx);
 sap_vdev_destroy:
-	hdd_vdev_destroy(adapter->deflink);
+	hdd_vdev_destroy(link_info);
 sap_destroy_ctx:
 	hdd_sap_destroy_ctx(adapter);
 	return ret;