Ver código fonte

qcacmn: Add support to send new country to FW

Add support to set new country code to the FW

Change-Id: Id24967b7c9e93bfbf045f494f142be9e33e16483
CRs-Fixed: 2042879
Kiran Kumar Lokere 8 anos atrás
pai
commit
a843634983

+ 1 - 0
qdf/linux/src/qdf_trace.c

@@ -1800,6 +1800,7 @@ struct category_name_info g_qdf_category_name[MAX_SUPPORTED_CATEGORY] = {
 	[QDF_MODULE_ID_SPECTRAL] = {"SPECTRAL"},
 	[QDF_MODULE_ID_P2P] = {"P2P"},
 	[QDF_MODULE_ID_OFFCHAN_TXRX] = {"OFFCHAN"},
+	[QDF_MODULE_ID_REGULATORY] = {"REGULATORY"},
 	[QDF_MODULE_ID_ANY] = {"ANY"},
 };
 EXPORT_SYMBOL(g_qdf_category_name);

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

@@ -129,6 +129,13 @@ static QDF_STATUS tgt_if_regulatory_unregister_master_list_handler(
 					       get_chan_list_cc_event_id());
 }
 
+static QDF_STATUS tgt_if_regulatory_set_country_code(
+	struct wlan_objmgr_psoc *psoc, void *arg)
+{
+	wmi_unified_t wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc);
+
+	return wmi_unified_set_country_cmd_send(wmi_handle, arg);
+}
 QDF_STATUS target_if_register_regulatory_tx_ops(struct wlan_lmac_if_tx_ops
 						*tx_ops)
 {
@@ -140,6 +147,7 @@ QDF_STATUS target_if_register_regulatory_tx_ops(struct wlan_lmac_if_tx_ops
 	reg_ops->unregister_master_handler =
 		tgt_if_regulatory_unregister_master_list_handler;
 
+	reg_ops->set_country_code = tgt_if_regulatory_set_country_code;
 	return QDF_STATUS_SUCCESS;
 }
 

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

@@ -533,6 +533,8 @@ struct wlan_lmac_if_reg_tx_ops {
 					      void *arg);
 	QDF_STATUS (*unregister_master_handler)(struct wlan_objmgr_psoc *psoc,
 						void *arg);
+	QDF_STATUS (*set_country_code)(struct wlan_objmgr_psoc *psoc,
+						void *arg);
 };
 
 /**

+ 9 - 0
umac/regulatory/core/src/reg_services.c

@@ -858,6 +858,8 @@ QDF_STATUS reg_set_default_country(struct wlan_objmgr_psoc *psoc,
 QDF_STATUS reg_set_country(struct wlan_objmgr_pdev *pdev, uint8_t *country)
 {
 	struct wlan_regulatory_psoc_priv_obj *psoc_reg;
+	struct wlan_lmac_if_reg_tx_ops *tx_ops;
+	struct set_country country_code;
 	struct wlan_objmgr_psoc *psoc;
 
 	if (!country) {
@@ -866,7 +868,9 @@ QDF_STATUS reg_set_country(struct wlan_objmgr_pdev *pdev, uint8_t *country)
 	}
 
 	psoc = wlan_pdev_get_psoc(pdev);
+
 	psoc_reg = reg_get_psoc_obj(psoc);
+
 	if (!IS_VALID_REG_OBJ(psoc_reg)) {
 		reg_alert("psoc reg component is NULL");
 		return QDF_STATUS_E_INVAL;
@@ -875,6 +879,11 @@ QDF_STATUS reg_set_country(struct wlan_objmgr_pdev *pdev, uint8_t *country)
 	reg_info("setting current_country:%s", country);
 	qdf_mem_copy(psoc_reg->current_country,
 		     country, sizeof(psoc_reg->current_country));
+	qdf_mem_copy(country_code.country,
+		     country, sizeof(psoc_reg->current_country));
+	country_code.pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
+	tx_ops = get_reg_psoc_tx_ops(psoc);
+	tx_ops->set_country_code(psoc, &country_code);
 
 	return QDF_STATUS_SUCCESS;
 }

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

@@ -381,6 +381,10 @@ struct bonded_channel {
 	uint16_t end_ch;
 };
 
+struct set_country {
+	uint8_t country[REG_ALPHA2_LEN + 1];
+	uint8_t pdev_id;
+};
 /**
  * enum ht_sec_ch_offset
  * @NO_SEC_CH: no secondary

+ 0 - 1
umac/regulatory/dispatcher/inc/wlan_reg_services_api.h

@@ -81,7 +81,6 @@ QDF_STATUS wlan_reg_get_channel_list_with_power(struct wlan_objmgr_pdev *pdev,
  */
 QDF_STATUS wlan_reg_read_default_country(struct wlan_objmgr_psoc *psoc,
 				   uint8_t *country);
-
 /**
  * wlan_reg_get_channel_state() - Get channel state from regulatory
  * @ch: channel number.

+ 4 - 0
wmi/inc/wmi_unified_api.h

@@ -1454,6 +1454,9 @@ QDF_STATUS wmi_unified_dfs_phyerr_offload_en_cmd(void *wmi_hdl,
 QDF_STATUS wmi_unified_dfs_phyerr_offload_dis_cmd(void *wmi_hdl,
 		uint32_t pdev_id);
 
+QDF_STATUS wmi_unified_set_country_cmd_send(void *wmi_hdl,
+				struct set_country *param);
+
 #ifdef WMI_INTERFACE_EVENT_LOGGING
 void wmi_print_cmd_log(wmi_unified_t wmi, uint32_t count,
 		       qdf_abstract_print *print, void *print_priv);
@@ -1475,6 +1478,7 @@ void wmi_print_rx_event_log(wmi_unified_t wmi, uint32_t count,
 
 void wmi_print_mgmt_event_log(wmi_unified_t wmi, uint32_t count,
 			      qdf_abstract_print *print, void *print_priv);
+
 #endif /* WMI_INTERFACE_EVENT_LOGGING */
 
 #endif /* _WMI_UNIFIED_API_H_ */

+ 3 - 0
wmi/inc/wmi_unified_priv.h

@@ -1313,6 +1313,9 @@ QDF_STATUS (*extract_dfs_radar_detection_event)(wmi_unified_t wmi_handle,
 		struct radar_found_info *radar_found,
 		uint32_t len);
 #endif
+
+QDF_STATUS (*send_set_country_cmd)(wmi_unified_t wmi_handle,
+				struct set_country *param);
 };
 
 struct target_abi_version {

+ 1 - 0
wmi/src/wmi_unified.c

@@ -1869,6 +1869,7 @@ static uint8_t *wmi_id_to_name(uint32_t wmi_command)
 		CASE_RETURN_STRING(WMI_VDEV_ADFS_CH_CFG_CMDID);
 		CASE_RETURN_STRING(WMI_VDEV_ADFS_OCAC_ABORT_CMDID);
 		CASE_RETURN_STRING(WMI_SAR_LIMITS_CMDID);
+		CASE_RETURN_STRING(WMI_SET_CURRENT_COUNTRY_CMDID);
 	}
 
 	return "Invalid WMI cmd";

+ 19 - 0
wmi/src/wmi_unified_api.c

@@ -6633,3 +6633,22 @@ QDF_STATUS wmi_extract_chainmask_tables(void *wmi_hdl, uint8_t *evt_buf,
 
 	return QDF_STATUS_E_FAILURE;
 }
+/**
+ *  wmi_unified_set_country_cmd_send() - WMI set country function
+ *  @param wmi_handle      : handle to WMI.
+ *  @param param    : pointer to hold set country cmd parameter
+ *
+ *  Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
+ */
+QDF_STATUS wmi_unified_set_country_cmd_send(void *wmi_hdl,
+				struct set_country *param)
+{
+	wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl;
+
+	if (wmi_handle->ops->send_set_country_cmd)
+		return wmi_handle->ops->send_set_country_cmd(wmi_handle,
+				  param);
+
+	return QDF_STATUS_E_FAILURE;
+}
+

+ 53 - 0
wmi/src/wmi_unified_tlv.c

@@ -17317,7 +17317,13 @@ static QDF_STATUS extract_reg_chan_list_update_event_tlv(
 	num_2g_reg_rules = reg_info->num_2g_reg_rules;
 	num_5g_reg_rules = reg_info->num_5g_reg_rules;
 
+	WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
+			__func__, reg_info->alpha2, reg_info->dfs_region,
+			reg_info->min_bw_2g, reg_info->max_bw_2g,
+			reg_info->min_bw_5g, reg_info->max_bw_5g);
 
+	WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
+			num_2g_reg_rules, num_5g_reg_rules);
 	wmi_reg_rule =
 		(wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
 			+ sizeof(wmi_reg_chan_list_cc_event_fixed_param)
@@ -17405,6 +17411,52 @@ static QDF_STATUS extract_dfs_radar_detection_event_tlv(
 }
 #endif
 
+/**
+ *  send_set_country_cmd_tlv() - WMI scan channel list function
+ *  @param wmi_handle      : handle to WMI.
+ *  @param param    : pointer to hold scan channel list parameter
+ *
+ *  Return: 0  on success and -ve on failure.
+ */
+static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
+				struct set_country *params)
+{
+	wmi_buf_t buf;
+	QDF_STATUS qdf_status;
+	wmi_set_current_country_cmd_fixed_param *cmd;
+	uint16_t len = sizeof(*cmd);
+
+	buf = wmi_buf_alloc(wmi_handle, len);
+	if (!buf) {
+		WMI_LOGE("Failed to allocate memory");
+		qdf_status = QDF_STATUS_E_NOMEM;
+		goto end;
+	}
+
+	cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
+	WMITLV_SET_HDR(&cmd->tlv_header,
+		       WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
+		       WMITLV_GET_STRUCT_TLVLEN
+			       (wmi_set_current_country_cmd_fixed_param));
+
+	WMI_LOGD("setting cuurnet country to  %s", params->country);
+
+	qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
+
+	cmd->pdev_id = params->pdev_id;
+
+	qdf_status = wmi_unified_cmd_send(wmi_handle,
+			buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
+
+	if (QDF_IS_STATUS_ERROR(qdf_status)) {
+		WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
+		wmi_buf_free(buf);
+	}
+
+end:
+	return qdf_status;
+}
+
 struct wmi_ops tlv_ops =  {
 	.send_vdev_create_cmd = send_vdev_create_cmd_tlv,
 	.send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
@@ -17680,6 +17732,7 @@ struct wmi_ops tlv_ops =  {
 	.send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
 	.send_wmm_update_cmd = send_wmm_update_cmd_tlv,
 	.send_coex_config_cmd = send_coex_config_cmd_tlv,
+	.send_set_country_cmd = send_set_country_cmd_tlv,
 	.get_target_cap_from_service_ready = extract_service_ready_tlv,
 	.extract_hal_reg_cap = extract_hal_reg_cap_tlv,
 	.extract_host_mem_req = extract_host_mem_req_tlv,