瀏覽代碼

qcacmn: Add call to API to update delay average

Add call to API to calculate the moving average fo delay for
the following
	NW Delay
	Wifi SW Delay
	Wifi HW Delay

Change-Id: I35afa4d83e474b0173cc1f4b9b6456b9fe2c963c
CRs-Fixed: 3286176
Vivek 2 年之前
父節點
當前提交
d1f06c6992
共有 3 個文件被更改,包括 95 次插入0 次删除
  1. 25 0
      dp/inc/cdp_txrx_stats_struct.h
  2. 51 0
      dp/wifi3.0/dp_stats.c
  3. 19 0
      dp/wifi3.0/dp_tx.c

+ 25 - 0
dp/inc/cdp_txrx_stats_struct.h

@@ -163,6 +163,9 @@
 
 #define CDP_MAX_TIDS 17
 
+#define CDP_MAX_PKT_PER_WIN 1000
+#define CDP_MAX_WIN_MOV_AVG 10
+
 #define CDP_WDI_NUM_EVENTS WDI_NUM_EVENTS
 
 #define CDP_FCTL_RETRY 0x0800
@@ -1078,10 +1081,32 @@ struct cdp_tid_stats_intf {
  * struct cdp_delay_tx_stats: Tx delay stats
  * @tx_swq_delay: software enqueue delay
  * @hwtx_delay: HW enque to completion delay
+ * @nwdelay_avg: Network delay average
+ * @swdelay_avg: Wifi SW Delay Average
+ * @hwdelay_avg: Wifi HW delay Average
+ * @sw_delay_win_total: total NW delay for each window
+ * @hw_delay_win_total: total Wifi SW delay for each window
+ * @nw_delay_win_total: total Wifi HW delay for each window
+ *
+ * @cur_win_num_pkts: number of packets processed in current window
+ * @cur_win_index: current windows index
  */
 struct cdp_delay_tx_stats {
 	struct cdp_hist_stats    tx_swq_delay;
 	struct cdp_hist_stats    hwtx_delay;
+
+#ifdef CONFIG_SAWF
+	uint32_t nwdelay_avg;
+	uint32_t swdelay_avg;
+	uint32_t hwdelay_avg;
+
+	uint64_t nw_delay_win_avg[CDP_MAX_WIN_MOV_AVG];
+	uint64_t sw_delay_win_avg[CDP_MAX_WIN_MOV_AVG];
+	uint64_t hw_delay_win_avg[CDP_MAX_WIN_MOV_AVG];
+
+	uint32_t cur_win_num_pkts;
+	uint32_t curr_win_idx;
+#endif
 };
 
 /*

+ 51 - 0
dp/wifi3.0/dp_stats.c

@@ -6350,6 +6350,54 @@ static void dp_print_hist_stats(struct cdp_hist_stats *hstats,
 	}
 }
 
+#ifdef CONFIG_SAWF
+/*
+ * dp_accumulate_delay_avg_stats(): Accumulate the delay average stats
+ * @stats: cdp_delay_tid stats
+ * @dst_hstats: Destination delay Tx stats
+ * @tid: TID value
+ *
+ * Return: void
+ */
+static void dp_accumulate_delay_avg_stats(struct cdp_delay_tid_stats stats[]
+					  [CDP_MAX_TXRX_CTX],
+					  struct cdp_delay_tx_stats *dst_stats,
+					  uint8_t tid)
+{
+	uint32_t num_rings = 0;
+	uint8_t ring_id;
+
+	for (ring_id = 0; ring_id < CDP_MAX_TXRX_CTX; ring_id++) {
+		struct cdp_delay_tx_stats *dstats =
+				&stats[tid][ring_id].tx_delay;
+
+		if (dstats->swdelay_avg || dstats->hwdelay_avg) {
+			dst_stats->nwdelay_avg += dstats->nwdelay_avg;
+			dst_stats->swdelay_avg += dstats->swdelay_avg;
+			dst_stats->hwdelay_avg += dstats->hwdelay_avg;
+			num_rings++;
+		}
+	}
+
+	if (!num_rings)
+		return;
+
+	dst_stats->nwdelay_avg = qdf_do_div(dst_stats->nwdelay_avg,
+					    num_rings);
+	dst_stats->swdelay_avg = qdf_do_div(dst_stats->swdelay_avg,
+					    num_rings);
+	dst_stats->hwdelay_avg = qdf_do_div(dst_stats->hwdelay_avg,
+					    num_rings);
+}
+#else
+static void dp_accumulate_delay_avg_stats(struct cdp_delay_tid_stats stats[]
+					  [CDP_MAX_TXRX_CTX],
+					  struct cdp_delay_tx_stats *dst_stats,
+					  uint8_t tid)
+{
+}
+#endif
+
 /*
  * dp_accumulate_delay_tid_stats(): Accumulate the tid stats to the
  *                                  hist stats.
@@ -8931,6 +8979,9 @@ dp_txrx_get_peer_delay_stats(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
 					      &rx_delay->to_stack_delay, tid,
 					      CDP_HIST_TYPE_REAP_STACK);
 		tx_delay = &delay_stats[tid].tx_delay;
+		dp_accumulate_delay_avg_stats(pext_stats->delay_tid_stats,
+					      tx_delay,
+					      tid);
 		dp_accumulate_delay_tid_stats(soc, pext_stats->delay_tid_stats,
 					      &tx_delay->tx_swq_delay, tid,
 					      CDP_HIST_TYPE_SW_ENQEUE_DELAY);

+ 19 - 0
dp/wifi3.0/dp_tx.c

@@ -3958,6 +3958,16 @@ static void dp_tx_update_peer_sawf_stats(struct dp_soc *soc,
 					   ts, tid);
 }
 
+static void dp_tx_compute_delay_avg(struct cdp_delay_tx_stats  *tx_delay,
+				    uint32_t nw_delay,
+				    uint32_t sw_delay,
+				    uint32_t hw_delay)
+{
+	dp_peer_tid_delay_avg(tx_delay,
+			      nw_delay,
+			      sw_delay,
+			      hw_delay);
+}
 #else
 static void dp_tx_update_peer_sawf_stats(struct dp_soc *soc,
 					 struct dp_vdev *vdev,
@@ -3968,6 +3978,12 @@ static void dp_tx_update_peer_sawf_stats(struct dp_soc *soc,
 {
 }
 
+static inline void
+dp_tx_compute_delay_avg(struct cdp_delay_tx_stats *tx_delay,
+			uint32_t nw_delay, uint32_t sw_delay,
+			uint32_t hw_delay)
+{
+}
 #endif
 
 #ifdef QCA_PEER_EXT_STATS
@@ -3996,6 +4012,9 @@ static void dp_tx_compute_tid_delay(struct cdp_delay_tid_stats *stats,
 							  &fwhw_transmit_delay))
 			dp_hist_update_stats(&tx_delay->hwtx_delay,
 					     fwhw_transmit_delay);
+
+	dp_tx_compute_delay_avg(tx_delay, 0, sw_enqueue_delay,
+				fwhw_transmit_delay);
 }
 #else
 /*