Ver Fonte

qcacmn: Add nbuf history for clone and copy

The network buffer (nbuf) history records the usual nbuf allocations
and frees, but does not record allocations due to copies or clones.
Record these allocations in the nbuf history as well to aid in
debugging.

Change-Id: If5bed9a41d301d43a1e610df4366d0bcf2c3efc4
CRs-Fixed: 2379866
Dustin Brown há 6 anos atrás
pai
commit
ae81599125
2 ficheiros alterados com 39 adições e 30 exclusões
  1. 7 30
      qdf/inc/qdf_nbuf.h
  2. 32 0
      qdf/linux/src/qdf_nbuf.c

+ 7 - 30
qdf/inc/qdf_nbuf.h

@@ -1402,27 +1402,16 @@ void qdf_nbuf_free_debug(qdf_nbuf_t nbuf, const char *func, uint32_t line);
 /**
  * qdf_nbuf_clone_debug() - clone the nbuf (copy is readonly)
  * @buf: nbuf to clone from
- * @func_name: pointer to function name
- * @line_num: line number
+ * @func: name of the calling function
+ * @line: line number of the callsite
  *
  * This function clones the nbuf and creates a memory tracking
  * node corresponding to that cloned skbuff structure.
  *
  * Return: cloned buffer
  */
-static inline qdf_nbuf_t
-qdf_nbuf_clone_debug(qdf_nbuf_t buf, const char *func_name, uint32_t line_num)
-{
-	qdf_nbuf_t cloned_buf;
-
-	cloned_buf = __qdf_nbuf_clone(buf);
-
-	/* Store SKB in internal QDF tracking table */
-	if (qdf_likely(cloned_buf))
-		qdf_net_buf_debug_add_node(cloned_buf, 0, func_name, line_num);
-
-	return cloned_buf;
-}
+qdf_nbuf_t qdf_nbuf_clone_debug(qdf_nbuf_t buf, const char *func,
+				uint32_t line);
 
 #define qdf_nbuf_copy(buf)     \
 	qdf_nbuf_copy_debug(buf, __func__, __LINE__)
@@ -1430,8 +1419,8 @@ qdf_nbuf_clone_debug(qdf_nbuf_t buf, const char *func_name, uint32_t line_num)
 /**
  * qdf_nbuf_copy_debug() - returns a private copy of the buf
  * @buf: nbuf to copy from
- * @func_name: pointer to function name
- * @line_num: line number
+ * @func: name of the calling function
+ * @line: line number of the callsite
  *
  * This API returns a private copy of the buf, the buf returned is completely
  * modifiable by callers. It also creates a memory tracking node corresponding
@@ -1439,19 +1428,7 @@ qdf_nbuf_clone_debug(qdf_nbuf_t buf, const char *func_name, uint32_t line_num)
  *
  * Return: copied buffer
  */
-static inline qdf_nbuf_t
-qdf_nbuf_copy_debug(qdf_nbuf_t buf, const char *func_name, uint32_t line_num)
-{
-	qdf_nbuf_t copied_buf;
-
-	copied_buf = __qdf_nbuf_copy(buf);
-
-	/* Store SKB in internal QDF tracking table */
-	if (qdf_likely(copied_buf))
-		qdf_net_buf_debug_add_node(copied_buf, 0, func_name, line_num);
-
-	return copied_buf;
-}
+qdf_nbuf_t qdf_nbuf_copy_debug(qdf_nbuf_t buf, const char *func, uint32_t line);
 
 #else /* NBUF_MEMORY_DEBUG */
 

+ 32 - 0
qdf/linux/src/qdf_nbuf.c

@@ -536,6 +536,8 @@ qdf_export_symbol(__qdf_nbuf_free);
 #ifdef NBUF_MEMORY_DEBUG
 enum qdf_nbuf_event_type {
 	QDF_NBUF_ALLOC,
+	QDF_NBUF_ALLOC_CLONE,
+	QDF_NBUF_ALLOC_COPY,
 	QDF_NBUF_ALLOC_FAILURE,
 	QDF_NBUF_FREE,
 	QDF_NBUF_MAP,
@@ -2688,6 +2690,36 @@ free_buf:
 }
 qdf_export_symbol(qdf_nbuf_free_debug);
 
+qdf_nbuf_t qdf_nbuf_clone_debug(qdf_nbuf_t buf, const char *func, uint32_t line)
+{
+	qdf_nbuf_t cloned_buf = __qdf_nbuf_clone(buf);
+
+	if (qdf_unlikely(!cloned_buf))
+		return NULL;
+
+	/* Store SKB in internal QDF tracking table */
+	qdf_net_buf_debug_add_node(cloned_buf, 0, func, line);
+	qdf_nbuf_history_add(cloned_buf, func, line, QDF_NBUF_ALLOC_CLONE);
+
+	return cloned_buf;
+}
+qdf_export_symbol(qdf_nbuf_clone_debug);
+
+qdf_nbuf_t qdf_nbuf_copy_debug(qdf_nbuf_t buf, const char *func, uint32_t line)
+{
+	qdf_nbuf_t copied_buf = __qdf_nbuf_copy(buf);
+
+	if (qdf_unlikely(!copied_buf))
+		return NULL;
+
+	/* Store SKB in internal QDF tracking table */
+	qdf_net_buf_debug_add_node(copied_buf, 0, func, line);
+	qdf_nbuf_history_add(copied_buf, func, line, QDF_NBUF_ALLOC_COPY);
+
+	return copied_buf;
+}
+qdf_export_symbol(qdf_nbuf_copy_debug);
+
 #endif /* NBUF_MEMORY_DEBUG */
 
 #if defined(FEATURE_TSO)