qcacmn: Add support to retrieve SAR power limits

Recently change "qcacmn: Add SAR power limit configuration"
(Change-Id: I0a214a2af780e9dd8c381c4e9eaa7d8cab6ef853) added the
ability to dynamically configure Specific Absorption Rate (SAR) power
limits. Now add the ability to retrieve the current active power
limits.

Change-Id: I7a6071dee71300daa3a217780ff3523604a11795
CRs-Fixed: 2161451
diff --git a/wmi_unified_api.h b/wmi_unified_api.h
index f41feac..4faa84f 100644
--- a/wmi_unified_api.h
+++ b/wmi_unified_api.h
@@ -1567,8 +1567,37 @@
 QDF_STATUS wmi_unified_send_multiple_vdev_restart_req_cmd(void *wmi_hdl,
 				struct multiple_vdev_restart_params *param);
 
+/**
+ * wmi_unified_send_sar_limit_cmd() - send sar limit cmd to fw
+ * @wmi_hdl: wmi handle
+ * @params: sar limit command params
+ *
+ * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
+ */
 QDF_STATUS wmi_unified_send_sar_limit_cmd(void *wmi_hdl,
-				struct sar_limit_cmd_params *params);
+					  struct sar_limit_cmd_params *params);
+
+/**
+ * wmi_unified_get_sar_limit_cmd() - request current SAR limits from FW
+ * @wmi_hdl: wmi handle
+ *
+ * Return: QDF_STATUS_SUCCESS for success or error code
+ */
+QDF_STATUS wmi_unified_get_sar_limit_cmd(void *wmi_hdl);
+
+/**
+ * wmi_unified_extract_sar_limit_event() - extract SAR limits from FW event
+ * @wmi_hdl: wmi handle
+ * @evt_buf: event buffer received from firmware
+ * @event: SAR limit event which is to be populated by data extracted from
+ *         the @evt_buf buffer
+ *
+ * Return: QDF_STATUS_SUCCESS for success or error code
+ */
+QDF_STATUS wmi_unified_extract_sar_limit_event(void *wmi_hdl,
+					       uint8_t *evt_buf,
+					       struct sar_limit_event *event);
+
 QDF_STATUS wmi_unified_send_adapt_dwelltime_params_cmd(void *wmi_hdl,
 				   struct wmi_adaptive_dwelltime_params *
 				   wmi_param);
diff --git a/wmi_unified_param.h b/wmi_unified_param.h
index bd628a2..5cbcd8e 100644
--- a/wmi_unified_param.h
+++ b/wmi_unified_param.h
@@ -5664,6 +5664,7 @@
 	wmi_dma_buf_release_event_id,
 	wmi_sap_obss_detection_report_event_id,
 	wmi_host_swfda_event_id,
+	wmi_sar_get_limits_event_id,
 
 	wmi_events_max,
 } wmi_conv_event_id;
@@ -7768,12 +7769,15 @@
 
 #define MAX_SAR_LIMIT_ROWS_SUPPORTED 64
 /**
- * struct sar_limit_cmd_row - sar limts row
+ * struct sar_limit_cmd_row - sar limits row
  * @band_id: Optional param for frequency band
+ *           See %enum wmi_sar_band_id_flags for possible values
  * @chain_id: Optional param for antenna chain id
  * @mod_id: Optional param for modulation scheme
+ *          See %enum wmi_sar_mod_id_flags for possible values
  * @limit_value: Mandatory param providing power limits in steps of 0.5 dbm
  * @validity_bitmap: bitmap of valid optional params in sar_limit_cmd_row struct
+ *                   See WMI_SAR_*_VALID_MASK for possible values
  */
 struct sar_limit_cmd_row {
 	uint32_t band_id;
@@ -7784,8 +7788,9 @@
 };
 
 /**
- * struct sar_limit_cmd_params - sar limts params
+ * struct sar_limit_cmd_params - sar limits params
  * @sar_enable: flag to enable SAR
+ *              See %enum wmi_sar_feature_state_flags for possible values
  * @num_limit_rows: number of items in sar_limits
  * @commit_limits: indicates firmware to start apply new SAR values
  * @sar_limit_row_list: pointer to array of sar limit rows
@@ -7797,6 +7802,38 @@
 	struct sar_limit_cmd_row *sar_limit_row_list;
 };
 
+/**
+ * struct sar_limit_event_row - sar limits row
+ * @band_id: Frequency band.
+ *           See %enum wmi_sar_band_id_flags for possible values
+ * @chain_id: Chain id
+ * @mod_id: Modulation scheme
+ *          See %enum wmi_sar_mod_id_flags for possible values
+ * @limit_value: Power limits in steps of 0.5 dbm that is currently active for
+ *     the given @band_id, @chain_id, and @mod_id
+ */
+struct sar_limit_event_row {
+	uint32_t band_id;
+	uint32_t chain_id;
+	uint32_t mod_id;
+	uint32_t limit_value;
+};
+
+/**
+ * struct sar_limit_event - sar limits params
+ * @sar_enable: Current status of SAR enablement.
+ *              See %enum wmi_sar_feature_state_flags for possible values
+ * @num_limit_rows: number of items in sar_limits
+ * @sar_limit_row: array of sar limit rows. Only @num_limit_rows
+ *                 should be considered valid.
+ */
+struct sar_limit_event {
+	uint32_t sar_enable;
+	uint32_t num_limit_rows;
+	struct sar_limit_event_row
+			sar_limit_row[MAX_SAR_LIMIT_ROWS_SUPPORTED];
+};
+
 /*
  * struct wmi_peer_gid_userpos_list_event
  * @usr_list - User list
diff --git a/wmi_unified_priv.h b/wmi_unified_priv.h
index 2136123..0ebf30c 100644
--- a/wmi_unified_priv.h
+++ b/wmi_unified_priv.h
@@ -1350,6 +1350,12 @@
 QDF_STATUS (*send_sar_limit_cmd)(wmi_unified_t wmi_handle,
 				struct sar_limit_cmd_params *params);
 
+QDF_STATUS (*get_sar_limit_cmd)(wmi_unified_t wmi_handle);
+
+QDF_STATUS (*extract_sar_limit_event)(wmi_unified_t wmi_handle,
+				      uint8_t *evt_buf,
+				      struct sar_limit_event *event);
+
 QDF_STATUS (*send_peer_rx_reorder_queue_setup_cmd)(wmi_unified_t wmi_handle,
 		struct rx_reorder_queue_setup_params *param);