ソースを参照

qcacmn: Memory stats for SKB usage and Tx desc cnt in datapath

Add sysfs node for DP level memory stats:
/sys/kernel/wifi/wlan/wlan_dp_mem_stats
These include Tx, Rx SKB memory allocated, Tx/Rx
buffer count, outstanding Tx desc count.

Change-Id: I839a5f2ec4e763ca11cdea2093368ca6dc52d8cf
CRs-Fixed: 2724460
Nisha Menon 4 年 前
コミット
4677d5bdf5
4 ファイル変更41 行追加4 行削除
  1. 4 0
      dp/wifi3.0/dp_ipa.c
  2. 3 3
      dp/wifi3.0/dp_main.c
  3. 33 1
      dp/wifi3.0/dp_tx.c
  4. 1 0
      dp/wifi3.0/dp_types.h

+ 4 - 0
dp/wifi3.0/dp_ipa.c

@@ -309,6 +309,8 @@ static void dp_tx_ipa_uc_detach(struct dp_soc *soc, struct dp_pdev *pdev)
 		if (!nbuf)
 			continue;
 		qdf_nbuf_unmap_single(soc->osdev, nbuf, QDF_DMA_BIDIRECTIONAL);
+		qdf_mem_dp_tx_skb_cnt_dec();
+		qdf_mem_dp_tx_skb_dec(qdf_nbuf_get_data_len(nbuf));
 		qdf_nbuf_free(nbuf);
 		soc->ipa_uc_tx_rsc.tx_buf_pool_vaddr_unaligned[idx] =
 						(void *)NULL;
@@ -442,6 +444,8 @@ static int dp_tx_ipa_uc_attach(struct dp_soc *soc, struct dp_pdev *pdev)
 		qdf_nbuf_map_single(soc->osdev, nbuf,
 				    QDF_DMA_BIDIRECTIONAL);
 		buffer_paddr = qdf_nbuf_get_frag_paddr(nbuf, 0);
+		qdf_mem_dp_tx_skb_cnt_inc();
+		qdf_mem_dp_tx_skb_inc(qdf_nbuf_get_data_len(nbuf));
 
 		paddr_lo = ((uint64_t)buffer_paddr & 0x00000000ffffffff);
 		paddr_hi = ((uint64_t)buffer_paddr & 0x0000001f00000000) >> 32;

+ 3 - 3
dp/wifi3.0/dp_main.c

@@ -11914,7 +11914,7 @@ dp_soc_attach(struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
 	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());
+		qdf_skb_total_mem_stats_read());
 
 	return soc;
 fail5:
@@ -12115,7 +12115,7 @@ void *dp_soc_init(struct dp_soc *soc, HTC_HANDLE htc_handle,
 	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());
+		qdf_skb_total_mem_stats_read());
 
 	return soc;
 fail6:
@@ -13764,7 +13764,7 @@ static inline QDF_STATUS dp_pdev_init(struct cdp_soc_t *txrx_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());
+		qdf_skb_total_mem_stats_read());
 
 	return QDF_STATUS_SUCCESS;
 fail9:

+ 33 - 1
dp/wifi3.0/dp_tx.c

@@ -74,6 +74,34 @@ static const uint8_t sec_type_map[MAX_CDP_SEC_TYPE] = {
 					HAL_TX_ENCRYPT_TYPE_AES_GCMP_256,
 					HAL_TX_ENCRYPT_TYPE_WAPI_GCM_SM4};
 
+#ifdef CONFIG_WLAN_SYSFS_MEM_STATS
+/**
+ * dp_update_tx_desc_stats - Update the increase or decrease in
+ * outstanding tx desc count
+ * values on pdev and soc
+ * @vdev: DP pdev handle
+ *
+ * Return: void
+ */
+static inline void
+dp_update_tx_desc_stats(struct dp_pdev *pdev)
+{
+	int32_t tx_descs_cnt =
+		qdf_atomic_read(&pdev->num_tx_outstanding);
+	if (pdev->tx_descs_max < tx_descs_cnt)
+		pdev->tx_descs_max = tx_descs_cnt;
+	qdf_mem_tx_desc_cnt_update(pdev->num_tx_outstanding,
+				   pdev->tx_descs_max);
+}
+
+#else /* CONFIG_WLAN_SYSFS_MEM_STATS */
+
+static inline void
+dp_update_tx_desc_stats(struct dp_pdev *pdev)
+{
+}
+#endif /* CONFIG_WLAN_SYSFS_MEM_STATS */
+
 #ifdef QCA_TX_LIMIT_CHECK
 /**
  * dp_tx_limit_check - Check if allocated tx descriptors reached
@@ -146,6 +174,7 @@ dp_tx_outstanding_inc(struct dp_pdev *pdev)
 
 	qdf_atomic_inc(&pdev->num_tx_outstanding);
 	qdf_atomic_inc(&soc->num_tx_outstanding);
+	dp_update_tx_desc_stats(pdev);
 }
 
 /**
@@ -161,6 +190,7 @@ dp_tx_outstanding_dec(struct dp_pdev *pdev)
 
 	qdf_atomic_dec(&pdev->num_tx_outstanding);
 	qdf_atomic_dec(&soc->num_tx_outstanding);
+	dp_update_tx_desc_stats(pdev);
 }
 
 #else //QCA_TX_LIMIT_CHECK
@@ -180,12 +210,14 @@ static inline void
 dp_tx_outstanding_inc(struct dp_pdev *pdev)
 {
 	qdf_atomic_inc(&pdev->num_tx_outstanding);
+	dp_update_tx_desc_stats(pdev);
 }
 
 static inline void
 dp_tx_outstanding_dec(struct dp_pdev *pdev)
 {
 	qdf_atomic_dec(&pdev->num_tx_outstanding);
+	dp_update_tx_desc_stats(pdev);
 }
 #endif //QCA_TX_LIMIT_CHECK
 
@@ -5034,7 +5066,7 @@ QDF_STATUS dp_tx_pdev_init(struct dp_pdev *pdev)
 
 	/* Initialize Flow control counters */
 	qdf_atomic_init(&pdev->num_tx_outstanding);
-
+	pdev->tx_descs_max = 0;
 	if (wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
 		/* Initialize descriptors in TCL Ring */
 		hal_tx_init_data_ring(soc->hal_soc,

+ 1 - 0
dp/wifi3.0/dp_types.h

@@ -2049,6 +2049,7 @@ struct dp_pdev {
 	uint16_t md_data_filter;
 
 	qdf_atomic_t num_tx_outstanding;
+	int32_t tx_descs_max;
 
 	qdf_atomic_t num_tx_exception;