diff --git a/qdf/inc/qdf_nbuf.h b/qdf/inc/qdf_nbuf.h index b19d0b1a65..2318d37bf8 100644 --- a/qdf/inc/qdf_nbuf.h +++ b/qdf/inc/qdf_nbuf.h @@ -1581,6 +1581,24 @@ qdf_nbuf_t qdf_nbuf_clone_debug(qdf_nbuf_t buf, const char *func, */ qdf_nbuf_t qdf_nbuf_copy_debug(qdf_nbuf_t buf, const char *func, uint32_t line); +#define qdf_nbuf_copy_expand(buf, headroom, tailroom) \ + qdf_nbuf_copy_expand_debug(buf, headroom, tailroom, __func__, __LINE__) + +/** + * qdf_nbuf_copy_expand_debug() - copy and expand nbuf + * @buf: Network buf instance + * @headroom: Additional headroom to be added + * @tailroom: Additional tailroom to be added + * @func: name of the calling function + * @line: line number of the callsite + * + * Return: New nbuf that is a copy of buf, with additional head and tailroom + * or NULL if there is no memory + */ +qdf_nbuf_t +qdf_nbuf_copy_expand_debug(qdf_nbuf_t buf, int headroom, int tailroom, + const char *func, uint32_t line); + #else /* NBUF_MEMORY_DEBUG */ static inline void qdf_net_buf_debug_init(void) {} @@ -1648,6 +1666,20 @@ static inline qdf_nbuf_t qdf_nbuf_copy(qdf_nbuf_t buf) return __qdf_nbuf_copy(buf); } +/** + * qdf_nbuf_copy_expand() - copy and expand nbuf + * @buf: Network buf instance + * @headroom: Additional headroom to be added + * @tailroom: Additional tailroom to be added + * + * Return: New nbuf that is a copy of buf, with additional head and tailroom + * or NULL if there is no memory + */ +static inline qdf_nbuf_t qdf_nbuf_copy_expand(qdf_nbuf_t buf, int headroom, + int tailroom) +{ + return __qdf_nbuf_copy_expand(buf, headroom, tailroom); +} #endif /* NBUF_MEMORY_DEBUG */ #ifdef WLAN_FEATURE_FASTPATH diff --git a/qdf/linux/src/i_qdf_nbuf.h b/qdf/linux/src/i_qdf_nbuf.h index 6b50cb1744..bedfc54551 100644 --- a/qdf/linux/src/i_qdf_nbuf.h +++ b/qdf/linux/src/i_qdf_nbuf.h @@ -1915,6 +1915,21 @@ __qdf_nbuf_expand(struct sk_buff *skb, uint32_t headroom, uint32_t tailroom) return NULL; } +/** + * __qdf_nbuf_copy_expand() - copy and expand nbuf + * @buf: Network buf instance + * @headroom: Additional headroom to be added + * @tailroom: Additional tailroom to be added + * + * Return: New nbuf that is a copy of buf, with additional head and tailroom + * or NULL if there is no memory + */ +static inline struct sk_buff * +__qdf_nbuf_copy_expand(struct sk_buff *buf, int headroom, int tailroom) +{ + return skb_copy_expand(buf, headroom, tailroom, GFP_ATOMIC); +} + /** * __qdf_nbuf_tx_cksum_info() - tx checksum info * diff --git a/qdf/linux/src/qdf_nbuf.c b/qdf/linux/src/qdf_nbuf.c index 7443c69633..91f45866cc 100644 --- a/qdf/linux/src/qdf_nbuf.c +++ b/qdf/linux/src/qdf_nbuf.c @@ -555,6 +555,7 @@ enum qdf_nbuf_event_type { QDF_NBUF_FREE, QDF_NBUF_MAP, QDF_NBUF_UNMAP, + QDF_NBUF_ALLOC_COPY_EXPAND, }; struct qdf_nbuf_event { @@ -2681,6 +2682,25 @@ qdf_nbuf_t qdf_nbuf_copy_debug(qdf_nbuf_t buf, const char *func, uint32_t line) } qdf_export_symbol(qdf_nbuf_copy_debug); +qdf_nbuf_t +qdf_nbuf_copy_expand_debug(qdf_nbuf_t buf, int headroom, int tailroom, + const char *func, uint32_t line) +{ + qdf_nbuf_t copied_buf = __qdf_nbuf_copy_expand(buf, headroom, tailroom); + + 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_EXPAND); + + return copied_buf; +} + +qdf_export_symbol(qdf_nbuf_copy_expand_debug); + #endif /* NBUF_MEMORY_DEBUG */ #if defined(FEATURE_TSO)