소스 검색

qcacmn: Add API to send set TPC power command

Add new API to handle the logic of sending the WMI command,
WMI_SET_TPC_POWER_CMDID. Create the struct to hold this new
transmit power information.

Change-Id: Ibc7c6109176577f56d149baf87022de557e84445
CRs-fixed: 2841781
Lincoln Tran 4 년 전
부모
커밋
e9c3eda862
4개의 변경된 파일97개의 추가작업 그리고 2개의 파일을 삭제
  1. 13 1
      wmi/inc/wmi_unified_api.h
  2. 4 0
      wmi/inc/wmi_unified_priv.h
  3. 13 1
      wmi/src/wmi_unified_api.c
  4. 67 0
      wmi/src/wmi_unified_tlv.c

+ 13 - 1
wmi/inc/wmi_unified_api.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2021 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -4280,4 +4280,16 @@ QDF_STATUS wmi_extract_pdev_csa_switch_count_status(
         __wmi_validate_handle(wmi_handle, __func__)
 int __wmi_validate_handle(wmi_unified_t wmi_handle, const char *func);
 
+/**
+ * wmi_unified_send_set_tpc_power_cmd() - send set transmit power info
+ * @wmi_handle: wmi handle
+ * @vdev_id: vdev id
+ * @param: regulatory TPC info
+ *
+ * Return: QDF_STATUS_SUCCESS for success or error code
+ */
+QDF_STATUS wmi_unified_send_set_tpc_power_cmd(wmi_unified_t wmi_handle,
+					      uint8_t vdev_id,
+					      struct reg_tpc_power_info *param);
+
 #endif /* _WMI_UNIFIED_API_H_ */

+ 4 - 0
wmi/inc/wmi_unified_priv.h

@@ -2490,6 +2490,10 @@ QDF_STATUS (*send_lcr_cmd)(wmi_unified_t wmi_handle,
 QDF_STATUS (*send_lci_cmd)(wmi_unified_t wmi_handle,
 			   struct wifi_pos_lci_info *lci_info);
 #endif
+
+QDF_STATUS (*send_set_tpc_power_cmd)(wmi_unified_t wmi_handle,
+				     uint8_t vdev_id,
+				     struct reg_tpc_power_info *param);
 };
 
 /* Forward declartion for psoc*/

+ 13 - 1
wmi/src/wmi_unified_api.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -3393,3 +3393,15 @@ QDF_STATUS wmi_extract_pdev_csa_switch_count_status(
 
 	return QDF_STATUS_E_FAILURE;
 }
+
+QDF_STATUS wmi_unified_send_set_tpc_power_cmd(wmi_unified_t wmi_handle,
+					      uint8_t vdev_id,
+					      struct reg_tpc_power_info *param)
+{
+	if (wmi_handle->ops->send_set_tpc_power_cmd)
+		return wmi_handle->ops->send_set_tpc_power_cmd(wmi_handle,
+								   vdev_id,
+								   param);
+
+	return QDF_STATUS_E_FAILURE;
+}

+ 67 - 0
wmi/src/wmi_unified_tlv.c

@@ -14517,6 +14517,72 @@ static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
 	return QDF_STATUS_SUCCESS;
 }
 
+/**
+ * send_set_tpc_power_cmd_tlv() - Sends the set TPC power level to FW
+ * @wmi_handle: wmi handle
+ * @param: Pointer to hold TX power info
+ *
+ * Return: QDF_STATUS_SUCCESS for success or error code
+ */
+static QDF_STATUS send_set_tpc_power_cmd_tlv(wmi_unified_t wmi_handle,
+					     uint8_t vdev_id,
+					     struct reg_tpc_power_info *param)
+{
+	wmi_buf_t buf;
+	wmi_vdev_set_tpc_power_fixed_param *tpc_power_info_param;
+	wmi_vdev_ch_power_info *ch_power_info;
+	uint8_t *buf_ptr;
+	uint16_t idx;
+	uint32_t len;
+	QDF_STATUS ret;
+
+	len = sizeof(wmi_vdev_set_tpc_power_fixed_param) + WMI_TLV_HDR_SIZE;
+	len += (sizeof(wmi_vdev_ch_power_info) * param->num_pwr_levels);
+
+	buf = wmi_buf_alloc(wmi_handle, len);
+	if (!buf)
+		return QDF_STATUS_E_NOMEM;
+
+	buf_ptr = (uint8_t *)wmi_buf_data(buf);
+	tpc_power_info_param = (wmi_vdev_set_tpc_power_fixed_param *)buf_ptr;
+
+	WMITLV_SET_HDR(&tpc_power_info_param->tlv_header,
+		WMITLV_TAG_STRUC_wmi_vdev_set_tpc_power_cmd_fixed_param,
+		WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_set_tpc_power_fixed_param));
+
+	tpc_power_info_param->vdev_id = vdev_id;
+	tpc_power_info_param->psd_power = param->is_psd_power;
+	tpc_power_info_param->eirp_power = param->eirp_power;
+	tpc_power_info_param->power_type_6ghz = param->power_type_6g;
+
+	buf_ptr += sizeof(wmi_vdev_set_tpc_power_fixed_param);
+	WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
+		       param->num_pwr_levels * sizeof(wmi_vdev_ch_power_info));
+
+	buf_ptr += WMI_TLV_HDR_SIZE;
+	ch_power_info = (wmi_vdev_ch_power_info *)buf_ptr;
+
+	for (idx = 0; idx < param->num_pwr_levels; ++idx) {
+		WMITLV_SET_HDR(&ch_power_info[idx].tlv_header,
+			WMITLV_TAG_STRUC_wmi_vdev_ch_power_info,
+			WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_ch_power_info));
+		ch_power_info[idx].chan_cfreq =
+			param->chan_power_info[idx].chan_cfreq;
+		ch_power_info[idx].tx_power =
+			param->chan_power_info[idx].tx_power;
+		buf_ptr += sizeof(wmi_vdev_ch_power_info);
+	}
+
+	wmi_mtrace(WMI_VDEV_SET_TPC_POWER_CMDID, vdev_id, 0);
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
+				   WMI_VDEV_SET_TPC_POWER_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret))
+		wmi_buf_free(buf);
+
+
+	return ret;
+}
+
 struct wmi_ops tlv_ops =  {
 	.send_vdev_create_cmd = send_vdev_create_cmd_tlv,
 	.send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
@@ -14879,6 +14945,7 @@ struct wmi_ops tlv_ops =  {
 	.extract_vdev_tsf_report_event = extract_vdev_tsf_report_event_tlv,
 	.extract_pdev_csa_switch_count_status =
 		extract_pdev_csa_switch_count_status_tlv,
+	.send_set_tpc_power_cmd = send_set_tpc_power_cmd_tlv,
 };
 
 /**