Browse Source

qcacld-3.0: update country code in hdd_regulatory_init

hdd_regulatory_dyn_cbk() is a call back function for
channel change and is registered by hdd_regulatory_init.

hdd_update_country_code will send
WMI_SET_CURRENT_COUNTRY_CMMDID to fw, and get
WMI_REG_CHAN_LIST_CC_EVENTID event, and then it
will try to call hdd_regulatory_dyn_cbk if it's registered.

When hdd_update_country_code is placed in
hdd_wlan_start_modules it will be called before
hdd_regulatory_init. There is a failed case that, FW event
WMI_REG_CHAN_LIST_CC_EVENTID happens but
hdd_regulatory_dyn_cbk is not registered and will not be
called. In this case even we set country code with CN
the STA still cannot scan 12/13 channel.

The change make sure that hdd_regualtory_dyn_cbk is
registered by hdd_regulatory_init before
WMI_REG_CHAN_LIST_CC_EVENTID event from
WLan FW.

Change-Id: Iac8617264d7f5afd80510abb90cca63d8b38fb4d
CRs-Fixed: 3135000
wei yang 3 years ago
parent
commit
8e5e3ae5c7
3 changed files with 18 additions and 7 deletions
  1. 10 0
      core/hdd/inc/wlan_hdd_main.h
  2. 1 7
      core/hdd/src/wlan_hdd_main.c
  3. 7 0
      core/hdd/src/wlan_hdd_regulatory.c

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

@@ -4587,6 +4587,16 @@ uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx,
  */
 int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate);
 
+/**
+ * hdd_update_country_code - Update country code
+ * @hdd_ctx: HDD context
+ *
+ * Update country code based on module parameter country_code
+ *
+ * Return: 0 on success and errno on failure
+ */
+int hdd_update_country_code(struct hdd_context *hdd_ctx);
+
 /**
  * hdd_set_11ax_rate() - set 11ax rate
  * @adapter: adapter being modified

+ 1 - 7
core/hdd/src/wlan_hdd_main.c

@@ -4072,7 +4072,7 @@ static void hdd_skip_acs_scan_timer_deinit(struct hdd_context *hdd_ctx) {}
  *
  * Return: 0 on success and errno on failure
  */
-static int hdd_update_country_code(struct hdd_context *hdd_ctx)
+int hdd_update_country_code(struct hdd_context *hdd_ctx)
 {
 	if (!country_code)
 		return 0;
@@ -14713,12 +14713,6 @@ static int hdd_features_init(struct hdd_context *hdd_ctx)
 
 	hdd_enter();
 
-	ret = hdd_update_country_code(hdd_ctx);
-	if (ret) {
-		hdd_err("Failed to update country code; errno:%d", ret);
-		return -EINVAL;
-	}
-
 	ret = hdd_init_mws_coex(hdd_ctx);
 	if (ret)
 		hdd_warn("Error initializing mws-coex");

+ 7 - 0
core/hdd/src/wlan_hdd_regulatory.c

@@ -1901,6 +1901,7 @@ int hdd_regulatory_init(struct hdd_context *hdd_ctx, struct wiphy *wiphy)
 	struct regulatory_channel *cur_chan_list;
 	enum country_src cc_src;
 	uint8_t alpha2[REG_ALPHA2_LEN + 1];
+	int ret;
 
 	cur_chan_list = qdf_mem_malloc(sizeof(*cur_chan_list) * NUM_CHANNELS);
 	if (!cur_chan_list) {
@@ -1913,6 +1914,12 @@ int hdd_regulatory_init(struct hdd_context *hdd_ctx, struct wiphy *wiphy)
 					       hdd_regulatory_dyn_cbk,
 					       NULL);
 
+	ret = hdd_update_country_code(hdd_ctx);
+	if (ret) {
+		hdd_err("Failed to update country code; errno:%d", ret);
+		return -EINVAL;
+	}
+
 	wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED;
 	/* Check the kernel version for upstream commit aced43ce780dc5 that
 	 * has support for processing user cell_base hints when wiphy is