Sfoglia il codice sorgente

qcacmn: Set country code for full-offload using iwpriv command

For full-offload, send user country code to FW using WMI
command.

Change-Id: I84acbd7ce30aa9a8ce590c8fadea2cb5914240fe
CRs-Fixed: 2053849
Abhijit Pradhan 7 anni fa
parent
commit
59626eba4b

+ 17 - 0
target_if/regulatory/src/target_if_reg.c

@@ -251,6 +251,20 @@ static QDF_STATUS tgt_if_regulatory_set_country_code(
 
 }
 
+static QDF_STATUS tgt_if_regulatory_set_user_country_code(
+	struct wlan_objmgr_psoc *psoc, uint8_t pdev_id, struct cc_regdmn_s *rd)
+{
+	wmi_unified_t wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc);
+
+	if (wmi_unified_set_user_country_code_cmd_send(wmi_handle, pdev_id,
+				rd) != QDF_STATUS_SUCCESS) {
+		target_if_err("Set user country code failed");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
+
 static QDF_STATUS tgt_if_regulatory_register_11d_new_cc_handler(
 	struct wlan_objmgr_psoc *psoc, void *arg)
 {
@@ -319,6 +333,9 @@ QDF_STATUS target_if_register_regulatory_tx_ops(struct wlan_lmac_if_tx_ops
 	reg_ops->is_there_serv_ready_extn =
 		tgt_if_regulatory_is_there_serv_ready_extn;
 
+	reg_ops->set_user_country_code =
+		tgt_if_regulatory_set_user_country_code;
+
 	return QDF_STATUS_SUCCESS;
 }
 

+ 3 - 0
umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h

@@ -563,6 +563,9 @@ struct wlan_lmac_if_reg_tx_ops {
 	QDF_STATUS (*stop_11d_scan)(struct wlan_objmgr_psoc *psoc,
 			struct reg_stop_11d_scan_req *reg_stop_11d_scan_req);
 	bool (*is_there_serv_ready_extn)(struct wlan_objmgr_psoc *psoc);
+	QDF_STATUS (*set_user_country_code)(struct wlan_objmgr_psoc *psoc,
+					    uint8_t pdev_id,
+					    struct cc_regdmn_s *rd);
 };
 
 /**

+ 1 - 2
umac/regulatory/core/src/reg_db_parser.c

@@ -100,8 +100,7 @@ QDF_STATUS reg_get_rdpair_from_country_iso(uint8_t *alpha,
 
 	for (i = 0; i < num_countries; i++) {
 		if ((g_all_countries[i].alpha2_11d[0] == alpha[0]) &&
-			(g_all_countries[i].alpha2_11d[1] == alpha[1]) &&
-			(g_all_countries[i].alpha2_11d[2] == alpha[2]))
+			(g_all_countries[i].alpha2_11d[1] == alpha[1]))
 			break;
 	}
 

+ 29 - 6
umac/regulatory/core/src/reg_services.c

@@ -2867,6 +2867,9 @@ QDF_STATUS reg_program_chan_list(struct wlan_objmgr_pdev *pdev,
 	struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj;
 	uint16_t country_index = -1, regdmn_pair = -1;
 	struct wlan_objmgr_psoc *psoc;
+	struct wlan_lmac_if_reg_tx_ops *tx_ops;
+	struct wlan_regulatory_psoc_priv_obj *soc_reg;
+	uint8_t pdev_id;
 	QDF_STATUS err;
 
 	pdev_priv_obj = (struct wlan_regulatory_pdev_priv_obj *)
@@ -2878,6 +2881,32 @@ QDF_STATUS reg_program_chan_list(struct wlan_objmgr_pdev *pdev,
 		return QDF_STATUS_E_FAILURE;
 	}
 
+	psoc = wlan_pdev_get_psoc(pdev);
+	if (!psoc) {
+		reg_err("psoc is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	soc_reg = reg_get_psoc_obj(psoc);
+	if (!IS_VALID_PSOC_REG_OBJ(soc_reg)) {
+		reg_err("psoc reg component is NULL");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	if (soc_reg->offload_enabled) {
+		if ((rd->flags == ALPHA_IS_SET) && (rd->cc.alpha[2] == 'O'))
+			pdev_priv_obj->indoor_chan_enabled = false;
+		else
+			pdev_priv_obj->indoor_chan_enabled = true;
+
+		pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
+		tx_ops = reg_get_psoc_tx_ops(psoc);
+		if (tx_ops->set_user_country_code)
+			return tx_ops->set_user_country_code(psoc, pdev_id, rd);
+
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	reg_info = (struct cur_regulatory_info *)qdf_mem_malloc
 		(sizeof(struct cur_regulatory_info));
 	if (reg_info == NULL) {
@@ -2885,12 +2914,6 @@ QDF_STATUS reg_program_chan_list(struct wlan_objmgr_pdev *pdev,
 		return QDF_STATUS_E_NOMEM;
 	}
 
-	psoc = wlan_pdev_get_psoc(pdev);
-	if (!psoc) {
-		reg_err("psoc is NULL");
-		return QDF_STATUS_E_INVAL;
-	}
-
 	reg_info->psoc = psoc;
 	reg_info->phy_id = wlan_objmgr_pdev_get_pdev_id(pdev);
 

+ 0 - 23
umac/regulatory/core/src/reg_services.h

@@ -70,29 +70,6 @@
 /* EEPROM setting is a country code */
 #define    COUNTRY_ERD_FLAG     0x8000
 
-/**
- * enum cc_regdmn_flag: Regdomain flags
- * @INVALID:       Invalid flag
- * @CC_IS_SET:     Country code is set
- * @REGDMN_IS_SET: Regdomain ID is set
- * @ALPHA_IS_SET:  Country ISO is set
- */
-enum cc_regdmn_flag {
-	INVALID,
-	CC_IS_SET,
-	REGDMN_IS_SET,
-	ALPHA_IS_SET,
-};
-
-struct cc_regdmn_s {
-	union {
-		uint16_t country_code;
-		uint16_t regdmn_id;
-		uint8_t alpha[REG_ALPHA2_LEN + 1];
-	} cc;
-	uint8_t flags;
-};
-
 extern const struct chan_map channel_map[NUM_CHANNELS];
 
 enum channel_enum reg_get_chan_enum(uint32_t chan_num);

+ 30 - 0
umac/regulatory/dispatcher/inc/reg_services_public_struct.h

@@ -574,4 +574,34 @@ struct mas_chan_params {
 	uint16_t ctry_code;
 };
 
+/**
+ * enum cc_regdmn_flag: Regdomain flags
+ * @INVALID:       Invalid flag
+ * @CC_IS_SET:     Country code is set
+ * @REGDMN_IS_SET: Regdomain ID is set
+ * @ALPHA_IS_SET:  Country ISO is set
+ */
+enum cc_regdmn_flag {
+	INVALID_CC,
+	CC_IS_SET,
+	REGDMN_IS_SET,
+	ALPHA_IS_SET,
+};
+
+/**
+ * struct cc_regdmn_s: User country code or regdomain
+ * @country_code: Country code
+ * @regdmn_id:    Regdomain pair ID
+ * @alpha:        Country ISO
+ * @flags:        Regdomain flags
+ */
+struct cc_regdmn_s {
+	union {
+		uint16_t country_code;
+		uint16_t regdmn_id;
+		uint8_t alpha[REG_ALPHA2_LEN + 1];
+	} cc;
+	uint8_t flags;
+};
+
 #endif

+ 7 - 0
umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h

@@ -119,6 +119,13 @@ QDF_STATUS ucfg_reg_init_handler(uint8_t pdev_id);
 QDF_STATUS ucfg_reg_program_default_cc(struct wlan_objmgr_pdev *pdev,
 				       uint16_t regdmn);
 
+/**
+ * ucfg_reg_program_cc() - Program user country code or regdomain
+ * @pdev: The physical dev to program country code or regdomain
+ * @rd: User country code or regdomain
+ *
+ * Return: QDF_STATUS
+ */
 QDF_STATUS ucfg_reg_program_cc(struct wlan_objmgr_pdev *pdev,
 			       struct cc_regdmn_s *rd);
 

+ 2 - 0
wmi/inc/wmi_unified_priv.h

@@ -1349,6 +1349,8 @@ QDF_STATUS (*send_set_country_cmd)(wmi_unified_t wmi_handle,
 uint32_t (*convert_pdev_id_host_to_target)(uint32_t pdev_id);
 uint32_t (*convert_pdev_id_target_to_host)(uint32_t pdev_id);
 
+QDF_STATUS (*send_user_country_code_cmd)(wmi_unified_t wmi_handle,
+		uint8_t pdev_id, struct cc_regdmn_s *rd);
 };
 
 struct target_abi_version {

+ 11 - 0
wmi/inc/wmi_unified_reg_api.h

@@ -71,4 +71,15 @@ QDF_STATUS wmi_extract_reg_11d_new_cc_event(void *wmi_hdl,
 		uint8_t *evt_buf,
 		struct reg_11d_new_country *reg_11d_new_cc,
 		uint32_t len);
+
+/**
+ * wmi_unified_set_user_country_code_cmd_send() - WMI set country function
+ * @wmi_handle: wmi handle.
+ * @pdev_id: Pdev id
+ * @rd: User country code or regdomain
+ *
+ * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
+ */
+QDF_STATUS wmi_unified_set_user_country_code_cmd_send(void *wmi_hdl,
+		uint8_t pdev_id, struct cc_regdmn_s *rd);
 #endif /* _WMI_UNIFIED_REG_API_H_ */

+ 11 - 0
wmi/src/wmi_unified_reg_api.c

@@ -90,3 +90,14 @@ QDF_STATUS wmi_extract_reg_11d_new_cc_event(void *wmi_hdl,
 	return QDF_STATUS_E_FAILURE;
 }
 
+QDF_STATUS wmi_unified_set_user_country_code_cmd_send(void *wmi_hdl,
+		uint8_t pdev_id, struct cc_regdmn_s *rd)
+{
+	struct wmi_unified *wmi_handle = (struct wmi_unified *) wmi_hdl;
+
+	if (wmi_handle->ops->send_user_country_code_cmd)
+		return wmi_handle->ops->send_user_country_code_cmd(
+				wmi_handle, pdev_id, rd);
+
+	return QDF_STATUS_E_FAILURE;
+}

+ 54 - 0
wmi/src/wmi_unified_tlv.c

@@ -18114,6 +18114,59 @@ end:
 	return qdf_status;
 }
 
+#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2)          do { \
+	    WMI_SET_BITS(alpha, 0, 8, val0); \
+	    WMI_SET_BITS(alpha, 8, 8, val1); \
+	    WMI_SET_BITS(alpha, 16, 8, val2); \
+	    } while (0)
+
+static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
+		uint8_t pdev_id, struct cc_regdmn_s *rd)
+{
+	wmi_set_init_country_cmd_fixed_param *cmd;
+	uint16_t len;
+	wmi_buf_t buf;
+	int ret;
+
+	len = sizeof(wmi_set_init_country_cmd_fixed_param);
+	buf = wmi_buf_alloc(wmi_handle, len);
+	if (!buf) {
+		WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
+		return QDF_STATUS_E_NOMEM;
+	}
+	cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
+	WMITLV_SET_HDR(&cmd->tlv_header,
+			WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
+			WMITLV_GET_STRUCT_TLVLEN
+			(wmi_set_init_country_cmd_fixed_param));
+
+	cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
+
+	if (rd->flags == CC_IS_SET) {
+		cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
+		cmd->country_code.country_id = rd->cc.country_code;
+	} else if (rd->flags == ALPHA_IS_SET) {
+		cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
+		WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
+				rd->cc.alpha[0],
+				rd->cc.alpha[1],
+				rd->cc.alpha[2]);
+	} else if (rd->flags == REGDMN_IS_SET) {
+		cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
+		cmd->country_code.domain_code = rd->cc.regdmn_id;
+	}
+
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
+			WMI_SET_INIT_COUNTRY_CMDID);
+	if (ret) {
+		WMI_LOGE("Failed to config wow wakeup event");
+		wmi_buf_free(buf);
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
+
 struct wmi_ops tlv_ops =  {
 	.send_vdev_create_cmd = send_vdev_create_cmd_tlv,
 	.send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
@@ -18495,6 +18548,7 @@ struct wmi_ops tlv_ops =  {
 	.send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
 	.extract_reg_11d_new_country_event =
 		extract_reg_11d_new_country_event_tlv,
+	.send_user_country_code_cmd = send_user_country_code_cmd_tlv,
 };
 
 /**