From 5a1cd4852016a11a66a42dcdfa0861b3223a3077 Mon Sep 17 00:00:00 2001 From: jinbaoliu Date: Thu, 15 Dec 2022 02:39:07 -0800 Subject: [PATCH] qcacmn: Fix TX stastics failed to take TSO segment into account Currently, we record TX musdu number and packet length, which falls into three categories: from stack, from host and successfully transmitted. In TSO mode, the msdu from stack will be divided into several fragments and each of the fragment will be transmitted as an individual msdu. This change will take TSO into account when it comes to the 3 forms of TX statstics. Change-Id: Ie11cb7541b4e109609bf3104739a5e19f51dcc13 CRs-Fixed: 3361412 --- dp/wifi3.0/be/dp_be_tx.c | 2 +- dp/wifi3.0/dp_tx.c | 8 ++++++-- dp/wifi3.0/dp_tx.h | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/dp/wifi3.0/be/dp_be_tx.c b/dp/wifi3.0/be/dp_be_tx.c index fba8ab3497..8cc96d983a 100644 --- a/dp/wifi3.0/be/dp_be_tx.c +++ b/dp/wifi3.0/be/dp_be_tx.c @@ -1101,7 +1101,7 @@ dp_tx_hw_enqueue_be(struct dp_soc *soc, struct dp_vdev *vdev, coalesce = dp_tx_attempt_coalescing(soc, vdev, tx_desc, tid, msdu_info, ring_id); - DP_STATS_INC_PKT(vdev, tx_i.processed, 1, tx_desc->length); + DP_STATS_INC_PKT(vdev, tx_i.processed, 1, dp_tx_get_pkt_len(tx_desc)); DP_STATS_INC(soc, tx.tcl_enq[ring_id], 1); dp_tx_update_stats(soc, tx_desc, ring_id); status = QDF_STATUS_SUCCESS; diff --git a/dp/wifi3.0/dp_tx.c b/dp/wifi3.0/dp_tx.c index 51190ad202..a236181f4f 100644 --- a/dp/wifi3.0/dp_tx.c +++ b/dp/wifi3.0/dp_tx.c @@ -3344,6 +3344,8 @@ dp_tx_send_exception(struct cdp_soc_t *soc_hdl, uint8_t vdev_id, goto fail; } + DP_STATS_INC(vdev, tx_i.rcvd.num, msdu_info.num_seg - 1); + goto send_multiple; } @@ -3668,7 +3670,7 @@ qdf_nbuf_t dp_tx_send(struct cdp_soc_t *soc_hdl, uint8_t vdev_id, * (TID override disabled) */ msdu_info.tid = HTT_TX_EXT_TID_INVALID; - DP_STATS_INC_PKT(vdev, tx_i.rcvd, 1, qdf_nbuf_headlen(nbuf)); + DP_STATS_INC_PKT(vdev, tx_i.rcvd, 1, qdf_nbuf_len(nbuf)); if (qdf_unlikely(vdev->mesh_vdev)) { qdf_nbuf_t nbuf_mesh = dp_tx_extract_mesh_meta_data(vdev, nbuf, @@ -3722,6 +3724,8 @@ qdf_nbuf_t dp_tx_send(struct cdp_soc_t *soc_hdl, uint8_t vdev_id, return nbuf; } + DP_STATS_INC(vdev, tx_i.rcvd.num, msdu_info.num_seg - 1); + goto send_multiple; } @@ -5331,7 +5335,7 @@ void dp_tx_comp_process_tx_status(struct dp_soc *soc, } eh = (qdf_ether_header_t *)qdf_nbuf_data(nbuf); - length = qdf_nbuf_len(nbuf); + length = dp_tx_get_pkt_len(tx_desc); dp_status = dp_tx_hw_to_qdf(ts->status); DPTRACE(qdf_dp_trace_ptr(tx_desc->nbuf, diff --git a/dp/wifi3.0/dp_tx.h b/dp/wifi3.0/dp_tx.h index 086258313f..c3390db2f4 100644 --- a/dp/wifi3.0/dp_tx.h +++ b/dp/wifi3.0/dp_tx.h @@ -1320,4 +1320,25 @@ dp_tx_outstanding_dec(struct dp_pdev *pdev) dp_update_tx_desc_stats(pdev); } #endif //QCA_TX_LIMIT_CHECK +/** + * dp_tx_get_pkt_len() - Get the packet length of a msdu + * @tx_desc: tx descriptor + * + * Return: Packet length of a msdu. If the packet is fragmented, + * it will return the single fragment length. + * + * In TSO mode, the msdu from stack will be fragmented into small + * fragments and each of these new fragments will be transmitted + * as an individual msdu. + * + * Please note that the length of a msdu from stack may be smaller + * than the length of the total length of the fragments it has been + * fragmentted because each of the fragments has a nbuf header. + */ +static inline uint32_t dp_tx_get_pkt_len(struct dp_tx_desc_s *tx_desc) +{ + return tx_desc->frm_type == dp_tx_frm_tso ? + tx_desc->msdu_ext_desc->tso_desc->seg.total_len : + qdf_nbuf_len(tx_desc->nbuf); +} #endif