Просмотр исходного кода

qcacmn: Add Support of MLO Link Stats for ML Peer

1) Allocation of memory to hold MLO Link Stats
   at MLD Peer level.
2) Modify the Macros to update MLO link stats.
3) Init and reset the Stats

Change-Id: Id4e9d40e212c5093159ae0c7d6316e93d19cf928
CRs-Fixed: 3397721
Kenvish Butani 2 лет назад
Родитель
Сommit
4ae60e4df1
3 измененных файлов с 108 добавлено и 39 удалено
  1. 72 30
      dp/wifi3.0/dp_internal.h
  2. 26 4
      dp/wifi3.0/dp_main.c
  3. 10 5
      dp/wifi3.0/dp_types.h

+ 72 - 30
dp/wifi3.0/dp_internal.h

@@ -1072,9 +1072,15 @@ void DP_PRINT_STATS(const char *fmt, ...);
 #define DP_STATS_INIT(_handle) \
 	qdf_mem_zero(&((_handle)->stats), sizeof((_handle)->stats))
 
+#define DP_TXRX_PEER_STATS_INIT(_handle, size) \
+	qdf_mem_zero(&((_handle)->stats[0]), size)
+
 #define DP_STATS_CLR(_handle) \
 	qdf_mem_zero(&((_handle)->stats), sizeof((_handle)->stats))
 
+#define DP_TXRX_PEER_STATS_CLR(_handle, size) \
+	qdf_mem_zero(&((_handle)->stats[0]), size)
+
 #ifndef DISABLE_DP_STATS
 #define DP_STATS_INC(_handle, _field, _delta) \
 { \
@@ -1082,6 +1088,12 @@ void DP_PRINT_STATS(const char *fmt, ...);
 		_handle->stats._field += _delta; \
 }
 
+#define DP_PEER_LINK_STATS_INC(_handle, _field, _delta, _link) \
+{ \
+	if (likely(_handle)) \
+		_handle->stats[_link]._field += _delta; \
+}
+
 #define DP_PEER_STATS_FLAT_INC(_handle, _field, _delta) \
 { \
 	if (likely(_handle)) \
@@ -1094,6 +1106,12 @@ void DP_PRINT_STATS(const char *fmt, ...);
 		_handle->stats._field += _delta; \
 }
 
+#define DP_PEER_LINK_STATS_INCC(_handle, _field, _delta, _cond, _link) \
+{ \
+	if (_cond && likely(_handle)) \
+		_handle->stats[_link]._field += _delta; \
+}
+
 #define DP_STATS_DEC(_handle, _field, _delta) \
 { \
 	if (likely(_handle)) \
@@ -1112,6 +1130,12 @@ void DP_PRINT_STATS(const char *fmt, ...);
 		_handle->stats._field = _delta; \
 }
 
+#define DP_PEER_LINK_STATS_UPD(_handle, _field, _delta, _link) \
+{ \
+	if (likely(_handle)) \
+		_handle->stats[_link]._field = _delta; \
+}
+
 #define DP_STATS_INC_PKT(_handle, _field, _count, _bytes) \
 { \
 	DP_STATS_INC(_handle, _field.num, _count); \
@@ -1148,11 +1172,14 @@ void DP_PRINT_STATS(const char *fmt, ...);
 
 #else
 #define DP_STATS_INC(_handle, _field, _delta)
+#define DP_PEER_LINK_STATS_INC(_handle, _field, _delta, _link)
 #define DP_PEER_STATS_FLAT_INC(_handle, _field, _delta)
 #define DP_STATS_INCC(_handle, _field, _delta, _cond)
+#define DP_PEER_LINK_STATS_INCC(_handle, _field, _delta, _cond, _link)
 #define DP_STATS_DEC(_handle, _field, _delta)
 #define DP_PEER_STATS_FLAT_DEC(_handle, _field, _delta)
 #define DP_STATS_UPD(_handle, _field, _delta)
+#define DP_PEER_LINK_STATS_UPD(_handle, _field, _delta, _link)
 #define DP_STATS_INC_PKT(_handle, _field, _count, _bytes)
 #define DP_PEER_STATS_FLAT_INC_PKT(_handle, _field, _count, _bytes)
 #define DP_STATS_INCC_PKT(_handle, _field, _count, _bytes, _cond)
@@ -1160,47 +1187,47 @@ void DP_PRINT_STATS(const char *fmt, ...);
 #define DP_STATS_AGGR_PKT(_handle_a, _handle_b, _field)
 #endif
 
-#define DP_PEER_PER_PKT_STATS_INC(_handle, _field, _delta) \
+#define DP_PEER_PER_PKT_STATS_INC(_handle, _field, _delta, _link) \
 { \
-	DP_STATS_INC(_handle, per_pkt_stats._field, _delta); \
+	DP_PEER_LINK_STATS_INC(_handle, per_pkt_stats._field, _delta, _link); \
 }
 
-#define DP_PEER_PER_PKT_STATS_INCC(_handle, _field, _delta, _cond) \
+#define DP_PEER_PER_PKT_STATS_INCC(_handle, _field, _delta, _cond, _link) \
 { \
-	DP_STATS_INCC(_handle, per_pkt_stats._field, _delta, _cond); \
+	DP_PEER_LINK_STATS_INCC(_handle, per_pkt_stats._field, _delta, _cond, _link); \
 }
 
-#define DP_PEER_PER_PKT_STATS_INC_PKT(_handle, _field, _count, _bytes) \
+#define DP_PEER_PER_PKT_STATS_INC_PKT(_handle, _field, _count, _bytes, _link) \
 { \
-	DP_PEER_PER_PKT_STATS_INC(_handle, _field.num, _count); \
-	DP_PEER_PER_PKT_STATS_INC(_handle, _field.bytes, _bytes) \
+	DP_PEER_PER_PKT_STATS_INC(_handle, _field.num, _count, _link); \
+	DP_PEER_PER_PKT_STATS_INC(_handle, _field.bytes, _bytes, _link) \
 }
 
-#define DP_PEER_PER_PKT_STATS_INCC_PKT(_handle, _field, _count, _bytes, _cond) \
+#define DP_PEER_PER_PKT_STATS_INCC_PKT(_handle, _field, _count, _bytes, _cond, _link) \
 { \
-	DP_PEER_PER_PKT_STATS_INCC(_handle, _field.num, _count, _cond); \
-	DP_PEER_PER_PKT_STATS_INCC(_handle, _field.bytes, _bytes, _cond) \
+	DP_PEER_PER_PKT_STATS_INCC(_handle, _field.num, _count, _cond, _link); \
+	DP_PEER_PER_PKT_STATS_INCC(_handle, _field.bytes, _bytes, _cond, _link) \
 }
 
-#define DP_PEER_PER_PKT_STATS_UPD(_handle, _field, _delta) \
+#define DP_PEER_PER_PKT_STATS_UPD(_handle, _field, _delta, _link) \
 { \
-	DP_STATS_UPD(_handle, per_pkt_stats._field, _delta); \
+	DP_PEER_LINK_STATS_UPD(_handle, per_pkt_stats._field, _delta, _link); \
 }
 
 #ifndef QCA_ENHANCED_STATS_SUPPORT
-#define DP_PEER_EXTD_STATS_INC(_handle, _field, _delta) \
+#define DP_PEER_EXTD_STATS_INC(_handle, _field, _delta, _link) \
 { \
-	DP_STATS_INC(_handle, extd_stats._field, _delta); \
+	DP_PEER_LINK_STATS_INC(_handle, extd_stats._field, _delta, _link); \
 }
 
-#define DP_PEER_EXTD_STATS_INCC(_handle, _field, _delta, _cond) \
+#define DP_PEER_EXTD_STATS_INCC(_handle, _field, _delta, _cond, _link) \
 { \
-	DP_STATS_INCC(_handle, extd_stats._field, _delta, _cond); \
+	DP_PEER_LINK_STATS_INCC(_handle, extd_stats._field, _delta, _cond, _link); \
 }
 
-#define DP_PEER_EXTD_STATS_UPD(_handle, _field, _delta) \
+#define DP_PEER_EXTD_STATS_UPD(_handle, _field, _delta, _link) \
 { \
-	DP_STATS_UPD(_handle, extd_stats._field, _delta); \
+	DP_PEER_LINK_STATS_UPD(_handle, extd_stats._field, _delta, _link); \
 }
 #endif
 
@@ -1218,16 +1245,22 @@ void DP_PRINT_STATS(const char *fmt, ...);
 		DP_PEER_STATS_FLAT_DEC(_handle, to_stack.num, _count); \
 }
 
-#define DP_PEER_MC_INCC_PKT(_handle, _count, _bytes, _cond) \
+#define DP_PEER_MC_INCC_PKT(_handle, _count, _bytes, _cond, _link) \
+{ \
+	if (_cond || !(_handle->hw_txrx_stats_en)) \
+		DP_PEER_PER_PKT_STATS_INC_PKT(_handle, rx.multicast, _count, _bytes, _link); \
+}
+
+#define DP_PEER_BC_INCC_PKT(_handle, _count, _bytes, _cond, _link) \
 { \
 	if (_cond || !(_handle->hw_txrx_stats_en)) \
-		DP_PEER_PER_PKT_STATS_INC_PKT(_handle, rx.multicast, _count, _bytes); \
+		DP_PEER_PER_PKT_STATS_INC_PKT(_handle, rx.bcast, _count, _bytes, _link); \
 }
 
-#define DP_PEER_BC_INCC_PKT(_handle, _count, _bytes, _cond) \
+#define DP_PEER_UC_INCC_PKT(_handle, _count, _bytes, _cond, _link) \
 { \
 	if (_cond || !(_handle->hw_txrx_stats_en)) \
-		DP_PEER_PER_PKT_STATS_INC_PKT(_handle, rx.bcast, _count, _bytes); \
+		DP_PEER_PER_PKT_STATS_INC_PKT(_handle, rx.unicast, _count, _bytes, _link); \
 }
 #elif defined(QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT)
 #define DP_PEER_TO_STACK_INCC_PKT(_handle, _count, _bytes, _cond) \
@@ -1242,16 +1275,22 @@ void DP_PRINT_STATS(const char *fmt, ...);
 		DP_PEER_STATS_FLAT_DEC(_handle, to_stack.num, _count); \
 }
 
-#define DP_PEER_MC_INCC_PKT(_handle, _count, _bytes, _cond) \
+#define DP_PEER_MC_INCC_PKT(_handle, _count, _bytes, _cond, _link) \
 { \
 	if (!(_handle->hw_txrx_stats_en)) \
-		DP_PEER_PER_PKT_STATS_INC_PKT(_handle, rx.multicast, _count, _bytes); \
+		DP_PEER_PER_PKT_STATS_INC_PKT(_handle, rx.multicast, _count, _bytes, _link); \
 }
 
-#define DP_PEER_BC_INCC_PKT(_handle, _count, _bytes, _cond) \
+#define DP_PEER_BC_INCC_PKT(_handle, _count, _bytes, _cond, _link) \
 { \
 	if (!(_handle->hw_txrx_stats_en)) \
-		DP_PEER_PER_PKT_STATS_INC_PKT(_handle, rx.bcast, _count, _bytes); \
+		DP_PEER_PER_PKT_STATS_INC_PKT(_handle, rx.bcast, _count, _bytes, _link); \
+}
+
+#define DP_PEER_UC_INCC_PKT(_handle, _count, _bytes, _cond, _link) \
+{ \
+	if (!(_handle->hw_txrx_stats_en)) \
+		DP_PEER_PER_PKT_STATS_INC_PKT(_handle, rx.unicast, _count, _bytes, _link); \
 }
 #else
 #define DP_PEER_TO_STACK_INCC_PKT(_handle, _count, _bytes, _cond) \
@@ -1260,11 +1299,14 @@ void DP_PRINT_STATS(const char *fmt, ...);
 #define DP_PEER_TO_STACK_DECC(_handle, _count, _cond) \
 	DP_PEER_STATS_FLAT_DEC(_handle, to_stack.num, _count);
 
-#define DP_PEER_MC_INCC_PKT(_handle, _count, _bytes, _cond) \
-	DP_PEER_PER_PKT_STATS_INC_PKT(_handle, rx.multicast, _count, _bytes);
+#define DP_PEER_MC_INCC_PKT(_handle, _count, _bytes, _cond, _link) \
+	DP_PEER_PER_PKT_STATS_INC_PKT(_handle, rx.multicast, _count, _bytes, _link);
+
+#define DP_PEER_BC_INCC_PKT(_handle, _count, _bytes, _cond, _link) \
+	DP_PEER_PER_PKT_STATS_INC_PKT(_handle, rx.bcast, _count, _bytes, _link);
 
-#define DP_PEER_BC_INCC_PKT(_handle, _count, _bytes, _cond) \
-	DP_PEER_PER_PKT_STATS_INC_PKT(_handle, rx.bcast, _count, _bytes);
+#define DP_PEER_UC_INCC_PKT(_handle, _count, _bytes, _cond, _link) \
+	DP_PEER_PER_PKT_STATS_INC_PKT(_handle, rx.unicast, _count, _bytes, _link);
 #endif
 
 #ifdef ENABLE_DP_HIST_STATS

+ 26 - 4
dp/wifi3.0/dp_main.c

@@ -7871,13 +7871,27 @@ static QDF_STATUS dp_txrx_peer_detach(struct dp_soc *soc, struct dp_peer *peer)
 	return QDF_STATUS_SUCCESS;
 }
 
+static inline
+uint8_t dp_txrx_peer_calculate_stats_size(struct dp_peer *peer)
+{
+	if (IS_MLO_DP_MLD_PEER(peer)) {
+		return (DP_MAX_MLO_LINKS + 1);
+	}
+	return 1;
+}
+
 static QDF_STATUS dp_txrx_peer_attach(struct dp_soc *soc, struct dp_peer *peer)
 {
 	struct dp_txrx_peer *txrx_peer;
 	struct dp_pdev *pdev;
 	struct cdp_txrx_peer_params_update params = {0};
+	uint8_t stats_arr_size = 0;
 
-	txrx_peer = (struct dp_txrx_peer *)qdf_mem_malloc(sizeof(*txrx_peer));
+	stats_arr_size = dp_txrx_peer_calculate_stats_size(peer);
+
+	txrx_peer = (struct dp_txrx_peer *)qdf_mem_malloc(sizeof(*txrx_peer) +
+							  (stats_arr_size *
+							   sizeof(struct dp_peer_stats)));
 
 	if (!txrx_peer)
 		return QDF_STATUS_E_NOMEM; /* failure */
@@ -7886,8 +7900,14 @@ static QDF_STATUS dp_txrx_peer_attach(struct dp_soc *soc, struct dp_peer *peer)
 	/* initialize the peer_id */
 	txrx_peer->vdev = peer->vdev;
 	pdev = peer->vdev->pdev;
+	txrx_peer->stats_arr_size = stats_arr_size;
+
+	DP_TXRX_PEER_STATS_INIT(txrx_peer,
+				(txrx_peer->stats_arr_size *
+				sizeof(struct dp_peer_stats)));
 
-	DP_STATS_INIT(txrx_peer);
+	if (!IS_DP_LEGACY_PEER(peer))
+		txrx_peer->is_mld_peer = 1;
 
 	dp_wds_ext_peer_init(txrx_peer);
 	dp_peer_rx_bufq_resources_init(txrx_peer);
@@ -7943,7 +7963,9 @@ void dp_txrx_peer_stats_clr(struct dp_txrx_peer *txrx_peer)
 	txrx_peer->to_stack.num = 0;
 	txrx_peer->to_stack.bytes = 0;
 
-	DP_STATS_CLR(txrx_peer);
+	DP_TXRX_PEER_STATS_CLR(txrx_peer,
+			       (txrx_peer->stats_arr_size *
+			       sizeof(struct dp_peer_stats)));
 	dp_peer_delay_stats_ctx_clr(txrx_peer);
 	dp_peer_jitter_stats_ctx_clr(txrx_peer);
 }
@@ -8308,7 +8330,7 @@ QDF_STATUS dp_peer_mlo_setup(
 		dp_link_peer_add_mld_peer(peer, mld_peer);
 		dp_mld_peer_add_link_peer(mld_peer, peer);
 
-		mld_peer->txrx_peer->mld_peer = 1;
+		mld_peer->txrx_peer->is_mld_peer = 1;
 		dp_peer_unref_delete(mld_peer, DP_MOD_ID_CDP);
 	} else {
 		peer->mld_peer = NULL;

+ 10 - 5
dp/wifi3.0/dp_types.h

@@ -4174,6 +4174,8 @@ struct dp_mld_link_peers {
 	struct dp_peer *link_peers[DP_MAX_MLO_LINKS];
 	uint8_t num_links;
 };
+#else
+#define DP_MAX_MLO_LINKS 0
 #endif
 
 typedef void *dp_txrx_ref_handle;
@@ -4583,11 +4585,10 @@ struct dp_peer_stats {
  * @authorize: Set when authorized
  * @in_twt: in TWT session
  * @hw_txrx_stats_en: Indicate HW offload vdev stats
- * @mld_peer:1: MLD peer
+ * @is_mld_peer:1: MLD peer
  * @tx_failed: Total Tx failure
  * @comp_pkt: Pkt Info for which completions were received
  * @to_stack: Total packets sent up the stack
- * @stats: Peer stats
  * @delay_stats: Peer delay stats
  * @jitter_stats: Peer jitter stats
  * @security: Security credentials
@@ -4606,6 +4607,8 @@ struct dp_peer_stats {
  * @sawf_stats:
  * @bw: bandwidth of peer connection
  * @mpdu_retry_threshold: MPDU retry threshold to increment tx bad count
+ * @stats_arr_size: peer stats array size
+ * @stats: Peer link and mld statistics
  */
 struct dp_txrx_peer {
 	struct dp_vdev *vdev;
@@ -4613,13 +4616,11 @@ struct dp_txrx_peer {
 	uint8_t authorize:1,
 		in_twt:1,
 		hw_txrx_stats_en:1,
-		mld_peer:1;
+		is_mld_peer:1;
 	uint32_t tx_failed;
 	struct cdp_pkt_info comp_pkt;
 	struct cdp_pkt_info to_stack;
 
-	struct dp_peer_stats stats;
-
 	struct dp_peer_delay_stats *delay_stats;
 
 	struct cdp_peer_tid_stats *jitter_stats;
@@ -4656,6 +4657,10 @@ struct dp_txrx_peer {
 	enum cdp_peer_bw bw;
 	uint8_t mpdu_retry_threshold;
 #endif
+	uint8_t stats_arr_size;
+
+	/* dp_peer_stats should be the last member in the structure */
+	struct dp_peer_stats stats[];
 };
 
 /* Peer structure for data path state */