Эх сурвалжийг харах

qcacmn: Add logs in wmi_unified_cmd_send()

In wmi_unified_cmd_send() function, pass function name and
line number of caller and log the same in case of failure,
this approach helps to remove error logs in caller function
there by reducing text segment.

Change-Id: Ib70d55959087021c4495c175d5363375037afe00
CRs-Fixed: 2281983
Arif Hussain 6 жил өмнө
parent
commit
ffcaef4344

+ 15 - 8
wmi/inc/wmi_unified_api.h

@@ -223,17 +223,24 @@ wmi_buf_t wmi_buf_alloc_fl(wmi_unified_t wmi_handle, uint32_t len,
 void wmi_buf_free(wmi_buf_t net_buf);
 
 /**
- * generic function to send unified WMI command
+ * wmi_unified_cmd_send() -  generic function to send unified WMI command
+ * @wmi_handle: handle to WMI.
+ * @buf: wmi command buffer
+ * @buflen: wmi command buffer length
+ * @cmd_id: WMI cmd id
  *
- *  @param wmi_handle      : handle to WMI.
- *  @param buf             : wmi command buffer
- *  @param buflen          : wmi command buffer length
- *  @param cmd_id          : WMI cmd id
- *  @return 0  on success and -ve on failure.
+ * Note, it is NOT safe to access buf after calling this function!
+ *
+ * Return: QDF_STATUS
  */
+#define wmi_unified_cmd_send(wmi_handle, buf, buflen, cmd_id) \
+	wmi_unified_cmd_send_fl(wmi_handle, buf, buflen, \
+				cmd_id, __func__, __LINE__)
+
 QDF_STATUS
-wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf, uint32_t buflen,
-			uint32_t cmd_id);
+wmi_unified_cmd_send_fl(wmi_unified_t wmi_handle, wmi_buf_t buf,
+			uint32_t buflen, uint32_t cmd_id,
+			const char *func, uint32_t line);
 
 /**
  * wmi_unified_register_event() - WMI event handler

+ 18 - 37
wmi/src/wmi_unified.c

@@ -1307,19 +1307,9 @@ static bool wmi_is_pm_resume_cmd(uint32_t cmd_id)
 }
 #endif
 
-/**
- * wmi_unified_cmd_send() - WMI command API
- * @wmi_handle: handle to wmi
- * @buf: wmi buf
- * @len: wmi buffer length
- * @cmd_id: wmi command id
- *
- * Note, it is NOT safe to access buf after calling this function!
- *
- * Return: 0 on success
- */
-QDF_STATUS wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf,
-				uint32_t len, uint32_t cmd_id)
+QDF_STATUS wmi_unified_cmd_send_fl(wmi_unified_t wmi_handle, wmi_buf_t buf,
+				   uint32_t len, uint32_t cmd_id,
+				   const char *func, uint32_t line)
 {
 	HTC_PACKET *pkt;
 	QDF_STATUS status;
@@ -1331,14 +1321,12 @@ QDF_STATUS wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf,
 						wmi_handle, buf, cmd_id);
 	} else if (qdf_atomic_read(&wmi_handle->is_target_suspended) &&
 		(!wmi_is_pm_resume_cmd(cmd_id))) {
-		QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
-				  "%s: Target is suspended", __func__);
-		QDF_ASSERT(0);
+		wmi_nofl_err("%s:%d, Target is suspended", func, line);
+		QDF_DEBUG_PANIC();
 		return QDF_STATUS_E_BUSY;
 	}
 	if (wmi_handle->wmi_stopinprogress) {
-		QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
-			"WMI  stop in progress");
+		wmi_nofl_err("%s:%d, WMI stop in progress", func, line);
 		return QDF_STATUS_E_INVAL;
 	}
 
@@ -1349,18 +1337,16 @@ QDF_STATUS wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf,
 
 		if (wmi_handle->ops->wmi_check_command_params(NULL, buf_ptr, len, cmd_id)
 			!= 0) {
-			QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
-			"\nERROR: %s: Invalid WMI Param Buffer for Cmd:%d",
-				__func__, cmd_id);
+			wmi_nofl_err("%s:%d, Invalid WMI Param Buffer for Cmd:%d",
+				     func, line, cmd_id);
 			return QDF_STATUS_E_INVAL;
 		}
 	}
 #endif
 
 	if (qdf_nbuf_push_head(buf, sizeof(WMI_CMD_HDR)) == NULL) {
-		QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
-			 "%s, Failed to send cmd %x, no memory",
-			 __func__, cmd_id);
+		wmi_nofl_err("%s:%d, Failed to send cmd %x, no memory",
+			     func, line, cmd_id);
 		return QDF_STATUS_E_NOMEM;
 	}
 
@@ -1370,24 +1356,19 @@ QDF_STATUS wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf,
 	qdf_atomic_inc(&wmi_handle->pending_cmds);
 	if (qdf_atomic_read(&wmi_handle->pending_cmds) >=
 			wmi_handle->wmi_max_cmds) {
-		QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
-		    "\n%s: hostcredits = %d", __func__,
-		wmi_get_host_credits(wmi_handle));
+		wmi_nofl_err("hostcredits = %d",
+			     wmi_get_host_credits(wmi_handle));
 		htc_dump_counter_info(wmi_handle->htc_handle);
 		qdf_atomic_dec(&wmi_handle->pending_cmds);
-		QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
-			"%s: MAX %d WMI Pending cmds reached.", __func__,
-			wmi_handle->wmi_max_cmds);
+		wmi_nofl_err("%s:%d, MAX %d WMI Pending cmds reached",
+			     func, line, wmi_handle->wmi_max_cmds);
 		QDF_BUG(0);
 		return QDF_STATUS_E_BUSY;
 	}
 
-	pkt = qdf_mem_malloc(sizeof(*pkt));
+	pkt = qdf_mem_malloc_fl(sizeof(*pkt), func, line);
 	if (!pkt) {
 		qdf_atomic_dec(&wmi_handle->pending_cmds);
-		QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
-			 "%s, Failed to alloc htc packet %x, no memory",
-			 __func__, cmd_id);
 		return QDF_STATUS_E_NOMEM;
 	}
 
@@ -1423,15 +1404,15 @@ QDF_STATUS wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf,
 
 	if (QDF_STATUS_SUCCESS != status) {
 		qdf_atomic_dec(&wmi_handle->pending_cmds);
-		QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
-		   "%s %d, htc_send_pkt failed", __func__, __LINE__);
+		wmi_nofl_err("%s:%d, htc_send_pkt failed, status:%d",
+			     func, line, status);
 		qdf_mem_free(pkt);
 		return status;
 	}
 
 	return QDF_STATUS_SUCCESS;
 }
-qdf_export_symbol(wmi_unified_cmd_send);
+qdf_export_symbol(wmi_unified_cmd_send_fl);
 
 /**
  * wmi_unified_get_event_handler_ix() - gives event handler's index