浏览代码

qcacmn: Alloc/Dealloc the peer extended stats

Allocate/Deallocated the peer extended object in the
peer_create() and peer_del() paths respectively.

Change-Id: I3e93e1ec85aefb22d3fb40d1b01bbd07d660aff5
Aniruddha Paul 5 年之前
父节点
当前提交
b07ed991ec
共有 3 个文件被更改,包括 115 次插入0 次删除
  1. 14 0
      dp/wifi3.0/dp_main.c
  2. 83 0
      dp/wifi3.0/dp_peer.c
  3. 18 0
      dp/wifi3.0/dp_peer.h

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

@@ -5507,6 +5507,15 @@ dp_peer_create_wifi3(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
 		}
 	}
 
+	/*
+	 * Allocate peer extended stats context. Fall through in
+	 * case of failure as its not an implicit requirement to have
+	 * this object for regular statistics updates.
+	 */
+	if (dp_peer_ext_stats_ctx_alloc(soc, peer) !=
+			QDF_STATUS_SUCCESS)
+		dp_warn("peer ext_stats ctx alloc failed");
+
 	/*
 	 * In tx_monitor mode, filter may be set for unassociated peer
 	 * when unassociated peer get associated peer need to
@@ -6220,6 +6229,11 @@ void dp_peer_unref_delete(struct dp_peer *peer)
 				  peer, vdev, &peer->vdev->peer_list);
 		}
 
+		/*
+		 * Deallocate the extended stats contenxt
+		 */
+		dp_peer_ext_stats_ctx_dealloc(soc, peer);
+
 		/* send peer destroy event to upper layer */
 		qdf_mem_copy(peer_cookie.mac_addr, peer->mac_addr.raw,
 			     QDF_MAC_ADDR_SIZE);

+ 83 - 0
dp/wifi3.0/dp_peer.c

@@ -34,6 +34,10 @@
 #include "dp_tx_capture.h"
 #endif
 
+#ifdef QCA_PEER_EXT_STATS
+#include "dp_hist.h"
+#endif
+
 #ifdef FEATURE_WDS
 static inline bool
 dp_peer_ast_free_in_unmap_supported(struct dp_peer *peer,
@@ -3361,6 +3365,85 @@ dp_rx_sec_ind_handler(struct dp_soc *soc, uint16_t peer_id,
 	dp_peer_unref_del_find_by_id(peer);
 }
 
+#ifdef QCA_PEER_EXT_STATS
+/*
+ * dp_peer_ext_stats_ctx_alloc() - Allocate peer ext
+ *                                 stats content
+ * @soc: DP SoC context
+ * @peer: DP peer context
+ *
+ * Allocate the peer extended stats context
+ *
+ * Return: QDF_STATUS_SUCCESS if allocation is
+ *	   successful
+ */
+QDF_STATUS dp_peer_ext_stats_ctx_alloc(struct dp_soc *soc,
+				       struct dp_peer *peer)
+{
+	uint8_t tid, ctx_id;
+
+	if (!soc || !peer) {
+		dp_warn("Null soc%x or peer%x", soc, peer);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	if (!wlan_cfg_is_peer_ext_stats_enabled(soc->wlan_cfg_ctx))
+		return QDF_STATUS_SUCCESS;
+
+	/*
+	 * Allocate memory for peer extended stats.
+	 */
+	peer->pext_stats = qdf_mem_malloc(sizeof(struct cdp_peer_ext_stats));
+	if (!peer->pext_stats) {
+		dp_err("Peer extended stats obj alloc failed!!");
+		return QDF_STATUS_E_NOMEM;
+	}
+
+	for (tid = 0; tid < CDP_MAX_DATA_TIDS; tid++) {
+		for (ctx_id = 0; ctx_id < CDP_MAX_TXRX_CTX; ctx_id++) {
+			struct cdp_delay_tx_stats *tx_delay =
+			&peer->pext_stats->delay_stats[tid][ctx_id].tx_delay;
+			struct cdp_delay_rx_stats *rx_delay =
+			&peer->pext_stats->delay_stats[tid][ctx_id].rx_delay;
+
+			dp_hist_init(&tx_delay->tx_swq_delay,
+				     CDP_HIST_TYPE_SW_ENQEUE_DELAY);
+			dp_hist_init(&tx_delay->hwtx_delay,
+				     CDP_HIST_TYPE_HW_COMP_DELAY);
+			dp_hist_init(&rx_delay->to_stack_delay,
+				     CDP_HIST_TYPE_REAP_STACK);
+		}
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
+
+/*
+ * dp_peer_ext_stats_ctx_dealloc() - Dealloc the peer context
+ * @peer: DP peer context
+ *
+ * Free the peer extended stats context
+ *
+ * Return: Void
+ */
+void dp_peer_ext_stats_ctx_dealloc(struct dp_soc *soc, struct dp_peer *peer)
+{
+	if (!peer) {
+		dp_warn("peer_ext dealloc failed due to NULL peer object");
+		return;
+	}
+
+	if (!wlan_cfg_is_peer_ext_stats_enabled(soc->wlan_cfg_ctx))
+		return;
+
+	if (!peer->pext_stats)
+		return;
+
+	qdf_mem_free(peer->pext_stats);
+	peer->pext_stats = NULL;
+}
+#endif
+
 QDF_STATUS
 dp_rx_delba_ind_handler(void *soc_handle, uint16_t peer_id,
 			uint8_t tid, uint16_t win_sz)

+ 18 - 0
dp/wifi3.0/dp_peer.h

@@ -383,4 +383,22 @@ dp_peer_update_80211_hdr(struct dp_vdev *vdev, struct dp_peer *peer)
 }
 #endif
 
+#ifdef QCA_PEER_EXT_STATS
+QDF_STATUS dp_peer_ext_stats_ctx_alloc(struct dp_soc *soc,
+				       struct dp_peer *peer);
+void dp_peer_ext_stats_ctx_dealloc(struct dp_soc *soc,
+				   struct dp_peer *peer);
+#else
+static inline QDF_STATUS dp_peer_ext_stats_ctx_alloc(struct dp_soc *soc,
+						     struct dp_peer *peer)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline void dp_peer_ext_stats_ctx_dealloc(struct dp_soc *soc,
+						 struct dp_peer *peer)
+{
+}
+#endif
+
 #endif /* _DP_PEER_H_ */