Browse Source

qcacld-3.0: Update MAC address to FW

Update MAC address to FW if it is provided by host. Otherwise,
MAC address will be out-of-sync between host and FW.

Change-Id: Idcf00d80d6d9e3e39b5a5ccb6d96390c2d883fe6
CRs-Fixed: 1066986
Yuanyuan Liu 8 years ago
parent
commit
245a3e4380
2 changed files with 39 additions and 2 deletions
  1. 1 0
      core/hdd/inc/wlan_hdd_main.h
  2. 38 2
      core/hdd/src/wlan_hdd_main.c

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

@@ -1496,6 +1496,7 @@ struct hdd_context_s {
 	bool napi_enable;
 	bool stop_modules_in_progress;
 	bool start_modules_in_progress;
+	bool update_mac_addr_to_fw;
 };
 
 /*---------------------------------------------------------------------------

+ 38 - 2
core/hdd/src/wlan_hdd_main.c

@@ -1424,6 +1424,7 @@ void hdd_update_tgt_cfg(void *context, void *param)
 
 	if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) {
 		hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr);
+		hdd_ctx->update_mac_addr_to_fw = false;
 	} else {
 		static struct qdf_mac_addr default_mac_addr = {
 			{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}
@@ -1441,6 +1442,7 @@ void hdd_update_tgt_cfg(void *context, void *param)
 				MAC_ADDR_ARRAY(hdd_ctx->config->
 					       intfMacAddr[0].bytes));
 		}
+		hdd_ctx->update_mac_addr_to_fw = true;
 	}
 
 	hdd_ctx->target_fw_version = cfg->target_fw_version;
@@ -6987,6 +6989,30 @@ static int hdd_cnss_wlan_mac(hdd_context_t *hdd_ctx)
 	return 0;
 }
 
+/**
+ * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW
+ * @hdd_ctx: HDD Context
+ *
+ * Update MAC address to FW. If MAC address passed by FW is invalid, host
+ * will generate its own MAC and update it to FW.
+ *
+ * Return: 0 for success
+ *         Non-zero error code for failure
+ */
+static int hdd_update_mac_addr_to_fw(hdd_context_t *hdd_ctx)
+{
+	tSirMacAddr customMacAddr;
+	QDF_STATUS status;
+
+	qdf_mem_copy(&customMacAddr,
+		     &hdd_ctx->config->intfMacAddr[0].bytes[0],
+		     sizeof(tSirMacAddr));
+	status = sme_set_custom_mac_addr(customMacAddr);
+	if (!QDF_IS_STATUS_SUCCESS(status))
+		return -EAGAIN;
+	return 0;
+}
+
 /**
  * hdd_initialize_mac_address() - API to get wlan mac addresses
  * @hdd_ctx: HDD Context
@@ -7010,8 +7036,18 @@ static void hdd_initialize_mac_address(hdd_context_t *hdd_ctx)
 
 	status = hdd_update_mac_config(hdd_ctx);
 
-	if (!QDF_IS_STATUS_SUCCESS(status))
-		hdd_warn("can't update mac config, using MAC from ini file");
+	if (QDF_IS_STATUS_SUCCESS(status))
+		return;
+
+	hdd_warn("can't update mac config via wlan_mac.bin, using MAC from ini file or auto-gen");
+
+	if (hdd_ctx->update_mac_addr_to_fw)
+		ret = hdd_update_mac_addr_to_fw(hdd_ctx);
+
+	if (ret != 0) {
+		hdd_err("MAC address out-of-sync, ret:%d", ret);
+		QDF_ASSERT(ret);
+	}
 }
 
 /**