diff --git a/dp/wifi3.0/dp_main.c b/dp/wifi3.0/dp_main.c index e51eb95df5..acd0e3b506 100644 --- a/dp/wifi3.0/dp_main.c +++ b/dp/wifi3.0/dp_main.c @@ -10684,6 +10684,11 @@ dp_soc_attach(struct cdp_ctrl_objmgr_psoc *ctrl_psoc, dp_soc_set_interrupt_mode(soc); dp_soc_set_def_pdev(soc); + dp_info("Mem stats: DMA = %u HEAP = %u SKB = %u", + qdf_dma_mem_stats_read(), + qdf_heap_mem_stats_read(), + qdf_skb_mem_stats_read()); + return soc; fail5: dp_soc_srng_free(soc); @@ -10876,6 +10881,11 @@ void *dp_soc_init(struct dp_soc *soc, HTC_HANDLE htc_handle, /* initialize work queue for stats processing */ qdf_create_work(0, &soc->htt_stats.work, htt_t2h_stats_handler, soc); + dp_info("Mem stats: DMA = %u HEAP = %u SKB = %u", + qdf_dma_mem_stats_read(), + qdf_heap_mem_stats_read(), + qdf_skb_mem_stats_read()); + return soc; fail6: htt_soc_htc_dealloc(soc->htt_handle); @@ -12429,6 +12439,11 @@ static inline QDF_STATUS dp_pdev_init(struct cdp_soc_t *txrx_soc, dp_init_tso_stats(pdev); dp_tx_ppdu_stats_attach(pdev); + dp_info("Mem stats: DMA = %u HEAP = %u SKB = %u", + qdf_dma_mem_stats_read(), + qdf_heap_mem_stats_read(), + qdf_skb_mem_stats_read()); + return QDF_STATUS_SUCCESS; fail9: dp_ipa_uc_detach(soc, pdev); diff --git a/qdf/inc/qdf_mem.h b/qdf/inc/qdf_mem.h index 53409138ac..a53d128b8d 100644 --- a/qdf/inc/qdf_mem.h +++ b/qdf/inc/qdf_mem.h @@ -555,8 +555,6 @@ int qdf_mem_multi_page_link(qdf_device_t osdev, struct qdf_mem_multi_page_t *pages, uint32_t elem_size, uint32_t elem_count, uint8_t cacheable); -#ifdef WLAN_DEBUGFS - /** * qdf_mem_kmalloc_inc() - increment kmalloc allocated bytes count * @size: number of bytes to increment by @@ -573,13 +571,7 @@ void qdf_mem_kmalloc_inc(qdf_size_t size); */ void qdf_mem_kmalloc_dec(qdf_size_t size); -#else - -static inline void qdf_mem_kmalloc_inc(qdf_size_t size) { } -static inline void qdf_mem_kmalloc_dec(qdf_size_t size) { } - -#endif /* WLAN_DEBUGFS */ - +#ifdef CONFIG_WLAN_SYSFS_MEM_STATS /** * qdf_mem_skb_inc() - increment total skb allocation size * @size: size to be added @@ -596,6 +588,16 @@ void qdf_mem_skb_inc(qdf_size_t size); */ void qdf_mem_skb_dec(qdf_size_t size); +#else +static inline void qdf_mem_skb_inc(qdf_size_t size) +{ +} + +static inline void qdf_mem_skb_dec(qdf_size_t size) +{ +} +#endif /* CONFIG_WLAN_SYSFS_MEM_STATS */ + /** * qdf_mem_map_table_alloc() - Allocate shared memory info structure * @num: number of required storage @@ -846,4 +848,28 @@ static inline void qdf_mem_shared_mem_free(qdf_device_t osdev, qdf_mem_free(shared_mem); } +/** + * qdf_dma_mem_stats_read() - Return the DMA memory allocated in + * host driver + * + * Return: None + */ +int32_t qdf_dma_mem_stats_read(void); + +/** + * qdf_heap_mem_stats_read() - Return the heap memory allocated + * in host driver + * + * Return: None + */ +int32_t qdf_heap_mem_stats_read(void); + +/** + * qdf_skb_mem_stats_read() - Return the SKB memory allocated in + * host driver + * + * Return: None + */ +int32_t qdf_skb_mem_stats_read(void); + #endif /* __QDF_MEMORY_H */ diff --git a/qdf/inc/qdf_nbuf.h b/qdf/inc/qdf_nbuf.h index 5d5d0e3cd6..1feaa9a5c2 100644 --- a/qdf/inc/qdf_nbuf.h +++ b/qdf/inc/qdf_nbuf.h @@ -1620,7 +1620,12 @@ static inline qdf_nbuf_t qdf_nbuf_alloc_fl(qdf_device_t osdev, qdf_size_t size, int reserve, int align, int prio, const char *func, uint32_t line) { - return __qdf_nbuf_alloc(osdev, size, reserve, align, prio, func, line); + qdf_nbuf_t nbuf; + + nbuf = __qdf_nbuf_alloc(osdev, size, reserve, align, prio, func, line); + if (qdf_likely(nbuf)) + qdf_mem_skb_inc(nbuf->truesize); + return nbuf; } static inline void qdf_nbuf_free(qdf_nbuf_t buf) diff --git a/qdf/linux/src/qdf_mem.c b/qdf/linux/src/qdf_mem.c index d469aa28af..1e203574b4 100644 --- a/qdf/linux/src/qdf_mem.c +++ b/qdf/linux/src/qdf_mem.c @@ -59,6 +59,18 @@ static bool is_initial_mem_debug_disabled; #define QDF_MEM_WARN_THRESHOLD 300 /* ms */ #define QDF_DEBUG_STRING_SIZE 512 +/** + * struct __qdf_mem_stat - qdf memory statistics + * @kmalloc: total kmalloc allocations + * @dma: total dma allocations + * @skb: total skb allocations + */ +static struct __qdf_mem_stat { + qdf_atomic_t kmalloc; + qdf_atomic_t dma; + qdf_atomic_t skb; +} qdf_mem_stat; + #ifdef MEMORY_DEBUG #include "qdf_debug_domain.h" @@ -292,54 +304,11 @@ u_int8_t prealloc_disabled = 1; qdf_declare_param(prealloc_disabled, byte); qdf_export_symbol(prealloc_disabled); -/** - * struct __qdf_mem_stat - qdf memory statistics - * @kmalloc: total kmalloc allocations - * @dma: total dma allocations - * @skb: total skb allocations - */ -static struct __qdf_mem_stat { - qdf_atomic_t kmalloc; - qdf_atomic_t dma; - qdf_atomic_t skb; -} qdf_mem_stat; - -void qdf_mem_skb_inc(qdf_size_t size) -{ - qdf_atomic_add(size, &qdf_mem_stat.skb); -} - -void qdf_mem_skb_dec(qdf_size_t size) -{ - qdf_atomic_sub(size, &qdf_mem_stat.skb); -} - #if defined WLAN_DEBUGFS /* Debugfs root directory for qdf_mem */ static struct dentry *qdf_mem_debugfs_root; -void qdf_mem_kmalloc_inc(qdf_size_t size) -{ - qdf_atomic_add(size, &qdf_mem_stat.kmalloc); -} - -void qdf_mem_kmalloc_dec(qdf_size_t size) -{ - qdf_atomic_sub(size, &qdf_mem_stat.kmalloc); -} - -static void qdf_mem_dma_inc(qdf_size_t size) -{ - qdf_atomic_add(size, &qdf_mem_stat.dma); -} - -static inline void qdf_mem_dma_dec(qdf_size_t size) -{ - qdf_atomic_sub(size, &qdf_mem_stat.dma); -} - - #ifdef MEMORY_DEBUG static int qdf_err_printer(void *priv, const char *fmt, ...) { @@ -841,9 +810,6 @@ static QDF_STATUS qdf_mem_debugfs_init(void) #else /* WLAN_DEBUGFS */ -static inline void qdf_mem_dma_inc(qdf_size_t size) {} -static inline void qdf_mem_dma_dec(qdf_size_t size) {} - static QDF_STATUS qdf_mem_debugfs_init(void) { return QDF_STATUS_E_NOSUPPORT; @@ -863,6 +829,38 @@ static QDF_STATUS qdf_mem_debug_debugfs_exit(void) #endif /* WLAN_DEBUGFS */ +void qdf_mem_kmalloc_inc(qdf_size_t size) +{ + qdf_atomic_add(size, &qdf_mem_stat.kmalloc); +} + +static void qdf_mem_dma_inc(qdf_size_t size) +{ + qdf_atomic_add(size, &qdf_mem_stat.dma); +} + +#ifdef CONFIG_WLAN_SYSFS_MEM_STATS +void qdf_mem_skb_inc(qdf_size_t size) +{ + qdf_atomic_add(size, &qdf_mem_stat.skb); +} + +void qdf_mem_skb_dec(qdf_size_t size) +{ + qdf_atomic_sub(size, &qdf_mem_stat.skb); +} +#endif + +void qdf_mem_kmalloc_dec(qdf_size_t size) +{ + qdf_atomic_sub(size, &qdf_mem_stat.kmalloc); +} + +static inline void qdf_mem_dma_dec(qdf_size_t size) +{ + qdf_atomic_sub(size, &qdf_mem_stat.dma); +} + /** * __qdf_mempool_init() - Create and initialize memory pool * @@ -2302,3 +2300,24 @@ void qdf_ether_addr_copy(void *dst_addr, const void *src_addr) } qdf_export_symbol(qdf_ether_addr_copy); +int32_t qdf_dma_mem_stats_read(void) +{ + return qdf_atomic_read(&qdf_mem_stat.dma); +} + +qdf_export_symbol(qdf_dma_mem_stats_read); + +int32_t qdf_heap_mem_stats_read(void) +{ + return qdf_atomic_read(&qdf_mem_stat.kmalloc); +} + +qdf_export_symbol(qdf_heap_mem_stats_read); + +int32_t qdf_skb_mem_stats_read(void) +{ + return qdf_atomic_read(&qdf_mem_stat.skb); +} + +qdf_export_symbol(qdf_skb_mem_stats_read); + diff --git a/qdf/linux/src/qdf_nbuf.c b/qdf/linux/src/qdf_nbuf.c index 1cf3323df3..d832def42b 100644 --- a/qdf/linux/src/qdf_nbuf.c +++ b/qdf/linux/src/qdf_nbuf.c @@ -551,6 +551,7 @@ void __qdf_nbuf_free(struct sk_buff *skb) return; qdf_nbuf_count_dec(skb); + qdf_mem_skb_dec(skb->truesize); if (nbuf_free_cb) nbuf_free_cb(skb); else