From a7441f61f3a779bc8698fb5b6c8c2becdaa2fc6a Mon Sep 17 00:00:00 2001 From: Karthik Kantamneni Date: Sun, 7 Mar 2021 11:50:32 +0530 Subject: [PATCH] qcacmn: Add support for Rx refill ring history Add support for Rx refill ring history, maintain records of refill info during RXDMA ring replenish. Change-Id: I034014eacfc510ec6f416fca601fa864326de9c2 CRs-Fixed: 2930005 --- dp/wifi3.0/dp_main.c | 16 ++++++++++++++ dp/wifi3.0/dp_rx.c | 50 +++++++++++++++++++++++++++++++++++++++++++ dp/wifi3.0/dp_types.h | 38 ++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) diff --git a/dp/wifi3.0/dp_main.c b/dp/wifi3.0/dp_main.c index ee5147e19713..705bb091873a 100644 --- a/dp/wifi3.0/dp_main.c +++ b/dp/wifi3.0/dp_main.c @@ -4198,10 +4198,12 @@ static void dp_soc_rx_history_attach(struct dp_soc *soc) uint32_t rx_ring_hist_size; uint32_t rx_err_ring_hist_size; uint32_t rx_reinject_hist_size; + uint32_t rx_refill_ring_hist_size; rx_ring_hist_size = sizeof(*soc->rx_ring_history[0]); rx_err_ring_hist_size = sizeof(*soc->rx_err_ring_history); rx_reinject_hist_size = sizeof(*soc->rx_reinject_ring_history); + rx_refill_ring_hist_size = sizeof(*soc->rx_refill_ring_history[0]); for (i = 0; i < MAX_REO_DEST_RINGS; i++) { soc->rx_ring_history[i] = dp_context_alloc_mem( @@ -4216,6 +4218,16 @@ static void dp_soc_rx_history_attach(struct dp_soc *soc) qdf_atomic_init(&soc->rx_err_ring_history->index); dp_soc_rx_reinject_ring_history_attach(soc); + + for (i = 0; i < MAX_PDEV_CNT; i++) { + soc->rx_refill_ring_history[i] = dp_context_alloc_mem( + soc, + DP_RX_REFILL_RING_HIST_TYPE, + rx_refill_ring_hist_size); + + if (soc->rx_refill_ring_history[i]) + qdf_atomic_init(&soc->rx_refill_ring_history[i]->index); + } } static void dp_soc_rx_history_detach(struct dp_soc *soc) @@ -4235,6 +4247,10 @@ static void dp_soc_rx_history_detach(struct dp_soc *soc) */ dp_context_free_mem(soc, DP_RX_REINJECT_RING_HIST_TYPE, soc->rx_reinject_ring_history); + + for (i = 0; i < MAX_PDEV_CNT; i++) + dp_context_free_mem(soc, DP_RX_REFILL_RING_HIST_TYPE, + soc->rx_refill_ring_history[i]); } #else diff --git a/dp/wifi3.0/dp_rx.c b/dp/wifi3.0/dp_rx.c index eabaf3a8ae65..cce66cf2c672 100644 --- a/dp/wifi3.0/dp_rx.c +++ b/dp/wifi3.0/dp_rx.c @@ -190,6 +190,51 @@ dp_pdev_frag_alloc_and_map(struct dp_soc *dp_soc, } #endif /* DP_RX_MON_MEM_FRAG */ +#ifdef WLAN_FEATURE_DP_RX_RING_HISTORY +/** + * dp_rx_refill_ring_record_entry() - Record an entry into refill_ring history + * @soc: Datapath soc structure + * @ring_num: Refill ring number + * @num_req: number of buffers requested for refill + * @num_refill: number of buffers refilled + * + * Returns: None + */ +static inline void +dp_rx_refill_ring_record_entry(struct dp_soc *soc, uint8_t ring_num, + hal_ring_handle_t hal_ring_hdl, + uint32_t num_req, uint32_t num_refill) +{ + struct dp_refill_info_record *record; + uint32_t idx; + uint32_t tp; + uint32_t hp; + + if (qdf_unlikely(!soc->rx_refill_ring_history[ring_num])) + return; + + idx = dp_history_get_next_index(&soc->rx_refill_ring_history[ring_num]->index, + DP_RX_REFILL_HIST_MAX); + + /* No NULL check needed for record since its an array */ + record = &soc->rx_refill_ring_history[ring_num]->entry[idx]; + + hal_get_sw_hptp(soc->hal_soc, hal_ring_hdl, &tp, &hp); + record->timestamp = qdf_get_log_timestamp(); + record->num_req = num_req; + record->num_refill = num_refill; + record->hp = hp; + record->tp = tp; +} +#else +static inline void +dp_rx_refill_ring_record_entry(struct dp_soc *soc, uint8_t ring_num, + hal_ring_handle_t hal_ring_hdl, + uint32_t num_req, uint32_t num_refill) +{ +} +#endif + /** * dp_pdev_nbuf_alloc_and_map() - Allocate nbuf for desc buffer and map * @@ -416,6 +461,9 @@ QDF_STATUS __dp_rx_buffers_replenish(struct dp_soc *dp_soc, uint32_t mac_id, dp_rx_refill_buff_pool_unlock(dp_soc); + dp_rx_refill_ring_record_entry(dp_soc, mac_id, rxdma_srng, + num_req_buffers, count); + hal_srng_access_end(dp_soc->hal_soc, rxdma_srng); dp_rx_schedule_refill_thread(dp_soc); @@ -3167,6 +3215,8 @@ dp_pdev_rx_buffers_attach(struct dp_soc *dp_soc, uint32_t mac_id, desc_list = next; } + dp_rx_refill_ring_record_entry(dp_soc, mac_id, rxdma_srng, + nr_nbuf, nr_nbuf); hal_srng_access_end(dp_soc->hal_soc, rxdma_srng); } diff --git a/dp/wifi3.0/dp_types.h b/dp/wifi3.0/dp_types.h index c1f22b7346a4..f6d9e15218a1 100644 --- a/dp/wifi3.0/dp_types.h +++ b/dp/wifi3.0/dp_types.h @@ -377,6 +377,7 @@ struct dp_rx_nbuf_frag_info { * @DP_RX_RING_HIST_TYPE: Datapath rx ring history * @DP_RX_ERR_RING_HIST_TYPE: Datapath rx error ring history * @DP_RX_REINJECT_RING_HIST_TYPE: Datapath reinject ring history + * @DP_RX_REFILL_RING_HIST_TYPE: Datapath rx refill ring history */ enum dp_ctxt_type { DP_PDEV_TYPE, @@ -384,6 +385,7 @@ enum dp_ctxt_type { DP_RX_ERR_RING_HIST_TYPE, DP_RX_REINJECT_RING_HIST_TYPE, DP_FISA_RX_FT_TYPE, + DP_RX_REFILL_RING_HIST_TYPE, }; /** @@ -1129,6 +1131,7 @@ struct rx_refill_buff_pool { bool is_initialized; }; +#ifdef WLAN_FEATURE_DP_RX_RING_HISTORY /* * The logic for get current index of these history is dependent on this * value being power of 2. @@ -1136,6 +1139,7 @@ struct rx_refill_buff_pool { #define DP_RX_HIST_MAX 2048 #define DP_RX_ERR_HIST_MAX 4096 #define DP_RX_REINJECT_HIST_MAX 1024 +#define DP_RX_REFILL_HIST_MAX 2048 QDF_COMPILE_TIME_ASSERT(rx_history_size, (DP_RX_HIST_MAX & @@ -1146,6 +1150,10 @@ QDF_COMPILE_TIME_ASSERT(rx_err_history_size, QDF_COMPILE_TIME_ASSERT(rx_reinject_history_size, (DP_RX_REINJECT_HIST_MAX & (DP_RX_REINJECT_HIST_MAX - 1)) == 0); +QDF_COMPILE_TIME_ASSERT(rx_refill_history_size, + (DP_RX_REFILL_HIST_MAX & + (DP_RX_REFILL_HIST_MAX - 1)) == 0); + /** * struct dp_buf_info_record - ring buffer info @@ -1157,6 +1165,22 @@ struct dp_buf_info_record { uint64_t timestamp; }; +/** + * struct dp_refill_info_record - ring refill buffer info + * @hp: HP value after refill + * @tp: cached tail value during refill + * @num_req: number of buffers requested to refill + * @num_refill: number of buffers refilled to ring + * @timestamp: timestamp when this entry was recorded + */ +struct dp_refill_info_record { + uint32_t hp; + uint32_t tp; + uint32_t num_req; + uint32_t num_refill; + uint64_t timestamp; +}; + /* struct dp_rx_history - rx ring hisotry * @index: Index where the last entry is written * @entry: history entries @@ -1184,6 +1208,17 @@ struct dp_rx_reinject_history { struct dp_buf_info_record entry[DP_RX_REINJECT_HIST_MAX]; }; +/* struct dp_rx_refill_history - rx buf refill hisotry + * @index: Index where the last entry is written + * @entry: history entries + */ +struct dp_rx_refill_history { + qdf_atomic_t index; + struct dp_refill_info_record entry[DP_RX_REFILL_HIST_MAX]; +}; + +#endif + /* structure to record recent operation related variable */ struct dp_last_op_info { /* last link desc buf info through WBM release ring */ @@ -1559,9 +1594,12 @@ struct dp_soc { TAILQ_HEAD(, dp_ast_entry) * bins; } ast_hash; +#ifdef WLAN_FEATURE_DP_RX_RING_HISTORY struct dp_rx_history *rx_ring_history[MAX_REO_DEST_RINGS]; + struct dp_rx_refill_history *rx_refill_ring_history[MAX_PDEV_CNT]; struct dp_rx_err_history *rx_err_ring_history; struct dp_rx_reinject_history *rx_reinject_ring_history; +#endif qdf_spinlock_t ast_lock; /*Timer for AST entry ageout maintainance */