浏览代码

qcacmn: Add support for link airtime usage telemetry

Add support for link airtime usage telemetry.

Change-Id: I8b796f14d55d56051fb05af255e612e4655db990
CRs-Fixed: 3281355
Himanshu Batra 2 年之前
父节点
当前提交
f147732272
共有 4 个文件被更改,包括 44 次插入20 次删除
  1. 2 0
      dp/inc/cdp_txrx_stats_struct.h
  2. 7 0
      dp/wifi3.0/dp_stats.c
  3. 30 7
      dp/wifi3.0/monitor/dp_mon.c
  4. 5 13
      dp/wifi3.0/monitor/dp_mon.h

+ 2 - 0
dp/inc/cdp_txrx_stats_struct.h

@@ -2659,10 +2659,12 @@ struct cdp_soc_stats {
  * struct cdp_pdev_telemetry_stats- Structure to hold pdev telemetry stats
  * @tx_mpdu_failed: Tx mpdu failed
  * @tx_mpdu_total: Total tx mpdus
+ * @link_airtime: pdev airtime usage per ac per sec
  */
 struct cdp_pdev_telemetry_stats {
 	uint32_t tx_mpdu_failed;
 	uint32_t tx_mpdu_total;
+	uint32_t link_airtime[WME_AC_MAX];
 };
 
 /**

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

@@ -9036,10 +9036,17 @@ dp_get_pdev_telemetry_stats(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
 {
 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
 	struct dp_pdev *pdev = dp_get_pdev_from_soc_pdev_id_wifi3(soc, pdev_id);
+	uint8_t ac = 0;
 
 	if (!pdev)
 		return QDF_STATUS_E_FAILURE;
 
+	/* consumption is in micro seconds, convert it to seconds and
+	 * then calculate %age per sec
+	 */
+	for (ac = 0; ac < WME_AC_MAX; ac++)
+		stats->link_airtime[ac] =
+			((pdev->stats.telemetry_stats.link_airtime[ac] * 100) / 1000000);
 	stats->tx_mpdu_failed = pdev->stats.telemetry_stats.tx_mpdu_failed;
 	stats->tx_mpdu_total = pdev->stats.telemetry_stats.tx_mpdu_total;
 

+ 30 - 7
dp/wifi3.0/monitor/dp_mon.c

@@ -2051,6 +2051,18 @@ QDF_STATUS dp_rx_populate_cbf_hdr(struct dp_soc *soc,
 
 #ifdef ATH_SUPPORT_EXT_STAT
 #ifdef WLAN_TELEMETRY_STATS_SUPPORT
+/* dp_pdev_clear_link_airtime_stats- clear pdev airtime stats for current index
+ * @peer : Datapath peer
+ */
+static inline
+void dp_pdev_clear_link_airtime_stats(struct dp_pdev *pdev)
+{
+	uint8_t ac;
+
+	for (ac = 0; ac < WME_AC_MAX; ac++)
+		pdev->stats.telemetry_stats.link_airtime[ac] = 0;
+}
+
 /* dp_peer_update_telemetry_stats- update peer telemetry stats
  * @peer : Datapath peer
  */
@@ -2060,7 +2072,7 @@ void dp_peer_update_telemetry_stats(struct dp_peer *peer)
 	struct dp_pdev *pdev;
 	struct dp_vdev *vdev;
 	struct dp_mon_peer *mon_peer = NULL;
-	uint8_t idx, ac;
+	uint8_t ac;
 
 	vdev = peer->vdev;
 	if (!vdev)
@@ -2077,18 +2089,25 @@ void dp_peer_update_telemetry_stats(struct dp_peer *peer)
 		DP_STATS_INC(pdev, telemetry_stats.tx_mpdu_total,
 			     mon_peer->stats.tx.tx_mpdus_tried);
 		for (ac = 0; ac < WME_AC_MAX; ac++) {
-			idx = mon_peer->stats.airtime_consumption[ac].avg_consumption.idx;
-			mon_peer->stats.airtime_consumption[ac].avg_consumption.avg_consumption_per_sec[idx] =
+			mon_peer->stats.airtime_consumption[ac].avg_consumption_per_sec =
 					mon_peer->stats.airtime_consumption[ac].consumption;
+			/* Store each peer airtime consumption in pdev
+			 * link_airtime to calculate pdev's total airtime
+			 * consumption
+			 */
+			DP_STATS_INC(
+				pdev,
+				telemetry_stats.link_airtime[ac],
+				mon_peer->stats.airtime_consumption[ac].consumption);
 			mon_peer->stats.airtime_consumption[ac].consumption = 0;
-			mon_peer->stats.airtime_consumption[ac].avg_consumption.idx++;
-			if (mon_peer->stats.airtime_consumption[ac].avg_consumption.idx ==
-			    MAX_CONSUMPTION_TIME)
-				mon_peer->stats.airtime_consumption[ac].avg_consumption.idx = 0;
 		}
 	}
 }
 #else
+static inline
+void dp_pdev_clear_link_airtime_stats(struct dp_pdev *pdev)
+{ }
+
 static inline
 void dp_peer_update_telemetry_stats(struct dp_peer *peer)
 { }
@@ -2167,6 +2186,10 @@ static void dp_iterate_update_peer_list(struct cdp_pdev *pdev_hdl)
 {
 	struct dp_pdev *pdev = (struct dp_pdev *)pdev_hdl;
 
+	/* Clear current airtime stats as the below API will increment the stats
+	 * for all peers on top of current value
+	 */
+	dp_pdev_clear_link_airtime_stats(pdev);
 	dp_pdev_iterate_peer(pdev, dp_peer_cal_clients_stats_update, NULL,
 			     DP_MOD_ID_CDP);
 }

+ 5 - 13
dp/wifi3.0/monitor/dp_mon.h

@@ -885,13 +885,9 @@ struct dp_mon_soc {
 };
 
 #ifdef WLAN_TELEMETRY_STATS_SUPPORT
-#define MAX_CONSUMPTION_TIME 5 /* in sec */
 struct dp_mon_peer_airtime_consumption {
 	uint32_t consumption;
-	struct {
-		uint32_t avg_consumption_per_sec[MAX_CONSUMPTION_TIME];
-		uint8_t idx;
-	} avg_consumption;
+	uint32_t avg_consumption_per_sec;
 };
 #endif
 
@@ -4239,23 +4235,19 @@ void dp_monitor_peer_telemetry_stats(struct dp_peer *peer,
 				     struct cdp_peer_telemetry_stats *stats)
 {
 	struct dp_mon_peer_stats *mon_peer_stats = NULL;
-	uint8_t idx = 0, ac;
-	uint32_t consumption = 0;
+	uint8_t ac;
 
 	if (qdf_unlikely(!peer->monitor_peer))
 		return;
 
 	mon_peer_stats = &peer->monitor_peer->stats;
 	for (ac = 0; ac < WME_AC_MAX; ac++) {
-		consumption = 0;
-		for (idx = 0; idx < MAX_CONSUMPTION_TIME; idx++)
-			consumption +=
-				mon_peer_stats->airtime_consumption[ac].avg_consumption.avg_consumption_per_sec[idx];
 		/* consumption is in micro seconds, convert it to seconds and
-		 * then calculate %age per 5 sec
+		 * then calculate %age per sec
 		 */
 		stats->airtime_consumption[ac] =
-			((consumption * 100) / (MAX_CONSUMPTION_TIME * 1000000));
+			((mon_peer_stats->airtime_consumption[ac].avg_consumption_per_sec * 100) /
+			(1000000));
 	}
 	stats->tx_mpdu_retried = mon_peer_stats->tx.retries;
 	stats->tx_mpdu_total = mon_peer_stats->tx.tx_mpdus_tried;