diff --git a/dp/inc/cdp_txrx_stats_struct.h b/dp/inc/cdp_txrx_stats_struct.h index d9e6099f8f..2508266dcf 100644 --- a/dp/inc/cdp_txrx_stats_struct.h +++ b/dp/inc/cdp_txrx_stats_struct.h @@ -51,8 +51,11 @@ #else #define MAX_MCS (14 + 1) #endif + +#define MCS_INVALID_ARRAY_INDEX MAX_MCS #define MAX_MCS_11A 8 #define MAX_MCS_11B 7 +#define MAX_MCS_11N 8 #define MAX_MCS_11AC 12 #define MAX_MCS_11AX 14 /* 1 additional GI is for invalid values */ @@ -428,6 +431,16 @@ enum cdp_packet_type { #define MCS_VALID 1 #define MCS_INVALID 0 +#ifdef WLAN_FEATURE_11BE +#define CDP_IS_PKT_TYPE_SUPPORT_NSS(_pkt_type) \ + (DOT11_N == (_pkt_type) || DOT11_AC == (_pkt_type) || \ + DOT11_AX == (_pkt_type) || DOT11_BE == (_pkt_type)) +#else +#define CDP_IS_PKT_TYPE_SUPPORT_NSS(_pkt_type) \ + (DOT11_N == (_pkt_type) || DOT11_AC == (_pkt_type) || \ + DOT11_AX == (_pkt_type)) +#endif /* WLAN_FEATURE_11BE */ + #define CDP_MAX_MCS_STRING_LEN 34 /* * struct cdp_rate_debug diff --git a/dp/wifi3.0/dp_internal.h b/dp/wifi3.0/dp_internal.h index 758f2c9008..60c2722061 100644 --- a/dp/wifi3.0/dp_internal.h +++ b/dp/wifi3.0/dp_internal.h @@ -156,6 +156,103 @@ struct htt_dbgfs_cfg { (1 << HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV) | \ (1 << HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_256_TLV)) +static const enum cdp_packet_type hal_2_dp_pkt_type_map[HAL_DOT11_MAX] = { + [HAL_DOT11A] = DOT11_A, + [HAL_DOT11B] = DOT11_B, + [HAL_DOT11N_MM] = DOT11_N, + [HAL_DOT11AC] = DOT11_AC, + [HAL_DOT11AX] = DOT11_AX, + [HAL_DOT11BA] = DOT11_MAX, +#ifdef WLAN_FEATURE_11BE + [HAL_DOT11BE] = DOT11_BE, +#else + [HAL_DOT11BE] = DOT11_MAX, +#endif + [HAL_DOT11AZ] = DOT11_MAX, + [HAL_DOT11N_GF] = DOT11_MAX, +}; + +#ifdef WLAN_FEATURE_11BE +/** + * dp_get_mcs_array_index_by_pkt_type_mcs () - get the destination mcs index + in array + * @pkt_type: host SW pkt type + * @mcs: mcs value for TX/RX rate + * + * Return: succeeded - valid index in mcs array + fail - same value as MCS_MAX + */ +static inline uint8_t +dp_get_mcs_array_index_by_pkt_type_mcs(uint32_t pkt_type, uint32_t mcs) +{ + uint8_t dst_mcs_idx = MCS_INVALID_ARRAY_INDEX; + + switch (pkt_type) { + case DOT11_A: + dst_mcs_idx = + mcs >= MAX_MCS_11A ? (MAX_MCS - 1) : mcs; + break; + case DOT11_B: + dst_mcs_idx = + mcs >= MAX_MCS_11B ? (MAX_MCS - 1) : mcs; + break; + case DOT11_N: + dst_mcs_idx = + mcs >= MAX_MCS_11N ? (MAX_MCS - 1) : mcs; + break; + case DOT11_AC: + dst_mcs_idx = + mcs >= MAX_MCS_11AC ? (MAX_MCS - 1) : mcs; + break; + case DOT11_AX: + dst_mcs_idx = + mcs >= MAX_MCS_11AX ? (MAX_MCS - 1) : mcs; + break; + case DOT11_BE: + dst_mcs_idx = + mcs >= MAX_MCS_11BE ? (MAX_MCS - 1) : mcs; + break; + default: + break; + } + + return dst_mcs_idx; +} +#else +static inline uint8_t +dp_get_mcs_array_index_by_pkt_type_mcs(uint32_t pkt_type, uint32_t mcs) +{ + uint8_t dst_mcs_idx = MCS_INVALID_ARRAY_INDEX; + + switch (pkt_type) { + case DOT11_A: + dst_mcs_idx = + mcs >= MAX_MCS_11A ? (MAX_MCS - 1) : mcs; + break; + case DOT11_B: + dst_mcs_idx = + mcs >= MAX_MCS_11B ? (MAX_MCS - 1) : mcs; + break; + case DOT11_N: + dst_mcs_idx = + mcs >= MAX_MCS_11N ? (MAX_MCS - 1) : mcs; + break; + case DOT11_AC: + dst_mcs_idx = + mcs >= MAX_MCS_11AC ? (MAX_MCS - 1) : mcs; + break; + case DOT11_AX: + dst_mcs_idx = + mcs >= MAX_MCS_11AX ? (MAX_MCS - 1) : mcs; + break; + default: + break; + } + + return dst_mcs_idx; +} +#endif + QDF_STATUS dp_mon_soc_attach(struct dp_soc *soc); QDF_STATUS dp_mon_soc_detach(struct dp_soc *soc); diff --git a/dp/wifi3.0/dp_rx.c b/dp/wifi3.0/dp_rx.c index 8fde1da701..b411ba7fe0 100644 --- a/dp/wifi3.0/dp_rx.c +++ b/dp/wifi3.0/dp_rx.c @@ -2091,6 +2091,7 @@ void dp_rx_msdu_extd_stats_update(struct dp_soc *soc, qdf_nbuf_t nbuf, { bool is_ampdu; uint32_t sgi, mcs, tid, nss, bw, reception_type, pkt_type; + uint8_t dst_mcs_idx; /* * TODO - For KIWI this field is present in ring_desc @@ -2108,6 +2109,9 @@ void dp_rx_msdu_extd_stats_update(struct dp_soc *soc, qdf_nbuf_t nbuf, rx_tlv_hdr); nss = hal_rx_msdu_start_nss_get(soc->hal_soc, rx_tlv_hdr); pkt_type = hal_rx_tlv_get_pkt_type(soc->hal_soc, rx_tlv_hdr); + /* do HW to SW pkt type conversion */ + pkt_type = (pkt_type >= HAL_DOT11_MAX ? DOT11_MAX : + hal_2_dp_pkt_type_map[pkt_type]); DP_PEER_EXTD_STATS_INCC(txrx_peer, rx.rx_mpdu_cnt[mcs], 1, ((mcs < MAX_MCS) && QDF_NBUF_CB_RX_CHFRAG_START(nbuf))); @@ -2118,9 +2122,7 @@ void dp_rx_msdu_extd_stats_update(struct dp_soc *soc, qdf_nbuf_t nbuf, * only if nss > 0 and pkt_type is 11N/AC/AX, * then increase index [nss - 1] in array counter. */ - if (nss > 0 && (pkt_type == DOT11_N || - pkt_type == DOT11_AC || - pkt_type == DOT11_AX)) + if (nss > 0 && CDP_IS_PKT_TYPE_SUPPORT_NSS(pkt_type)) DP_PEER_EXTD_STATS_INC(txrx_peer, rx.nss[nss - 1], 1); DP_PEER_EXTD_STATS_INC(txrx_peer, rx.sgi_count[sgi], 1); @@ -2134,36 +2136,11 @@ void dp_rx_msdu_extd_stats_update(struct dp_soc *soc, qdf_nbuf_t nbuf, DP_PEER_EXTD_STATS_INC(txrx_peer, rx.wme_ac_type[TID_TO_WME_AC(tid)], 1); DP_PEER_EXTD_STATS_INC(txrx_peer, rx.reception_type[reception_type], 1); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - rx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1, - ((mcs >= MAX_MCS_11A) && (pkt_type == DOT11_A))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - rx.pkt_type[pkt_type].mcs_count[mcs], 1, - ((mcs <= MAX_MCS_11A) && (pkt_type == DOT11_A))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - rx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1, - ((mcs >= MAX_MCS_11B) && (pkt_type == DOT11_B))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - rx.pkt_type[pkt_type].mcs_count[mcs], 1, - ((mcs <= MAX_MCS_11B) && (pkt_type == DOT11_B))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - rx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1, - ((mcs >= MAX_MCS_11A) && (pkt_type == DOT11_N))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - rx.pkt_type[pkt_type].mcs_count[mcs], 1, - ((mcs <= MAX_MCS_11A) && (pkt_type == DOT11_N))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - rx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1, - ((mcs >= MAX_MCS_11AC) && (pkt_type == DOT11_AC))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - rx.pkt_type[pkt_type].mcs_count[mcs], 1, - ((mcs <= MAX_MCS_11AC) && (pkt_type == DOT11_AC))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - rx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1, - ((mcs >= MAX_MCS) && (pkt_type == DOT11_AX))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - rx.pkt_type[pkt_type].mcs_count[mcs], 1, - ((mcs < MAX_MCS) && (pkt_type == DOT11_AX))); + dst_mcs_idx = dp_get_mcs_array_index_by_pkt_type_mcs(pkt_type, mcs); + if (MCS_INVALID_ARRAY_INDEX != dst_mcs_idx) + DP_PEER_EXTD_STATS_INC(txrx_peer, + rx.pkt_type[pkt_type].mcs_count[dst_mcs_idx], + 1); } #else static inline diff --git a/dp/wifi3.0/dp_tx.c b/dp/wifi3.0/dp_tx.c index 7f5c700526..22adec9538 100644 --- a/dp/wifi3.0/dp_tx.c +++ b/dp/wifi3.0/dp_tx.c @@ -4034,42 +4034,20 @@ static inline void dp_tx_update_peer_extd_stats(struct hal_tx_completion_status *ts, struct dp_txrx_peer *txrx_peer) { - uint8_t mcs, pkt_type; + uint8_t mcs, pkt_type, dst_mcs_idx; uint8_t retry_threshold = txrx_peer->mpdu_retry_threshold; mcs = ts->mcs; pkt_type = ts->pkt_type; + /* do HW to SW pkt type conversion */ + pkt_type = (pkt_type >= HAL_DOT11_MAX ? DOT11_MAX : + hal_2_dp_pkt_type_map[pkt_type]); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1, - ((mcs >= MAX_MCS_11A) && (pkt_type == DOT11_A))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - tx.pkt_type[pkt_type].mcs_count[mcs], 1, - ((mcs < (MAX_MCS_11A)) && (pkt_type == DOT11_A))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1, - ((mcs >= MAX_MCS_11B) && (pkt_type == DOT11_B))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - tx.pkt_type[pkt_type].mcs_count[mcs], 1, - ((mcs < MAX_MCS_11B) && (pkt_type == DOT11_B))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1, - ((mcs >= MAX_MCS_11A) && (pkt_type == DOT11_N))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - tx.pkt_type[pkt_type].mcs_count[mcs], 1, - ((mcs < MAX_MCS_11A) && (pkt_type == DOT11_N))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1, - ((mcs >= MAX_MCS_11AC) && (pkt_type == DOT11_AC))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - tx.pkt_type[pkt_type].mcs_count[mcs], 1, - ((mcs < MAX_MCS_11AC) && (pkt_type == DOT11_AC))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1, - ((mcs >= (MAX_MCS - 1)) && (pkt_type == DOT11_AX))); - DP_PEER_EXTD_STATS_INCC(txrx_peer, - tx.pkt_type[pkt_type].mcs_count[mcs], 1, - ((mcs < (MAX_MCS - 1)) && (pkt_type == DOT11_AX))); + dst_mcs_idx = dp_get_mcs_array_index_by_pkt_type_mcs(pkt_type, mcs); + if (MCS_INVALID_ARRAY_INDEX != dst_mcs_idx) + DP_PEER_EXTD_STATS_INC(txrx_peer, + tx.pkt_type[pkt_type].mcs_count[dst_mcs_idx], + 1); DP_PEER_EXTD_STATS_INC(txrx_peer, tx.sgi_count[ts->sgi], 1); DP_PEER_EXTD_STATS_INC(txrx_peer, tx.bw[ts->bw], 1); diff --git a/hal/wifi3.0/hal_internal.h b/hal/wifi3.0/hal_internal.h index 0891577ba2..f82b18e2ec 100644 --- a/hal/wifi3.0/hal_internal.h +++ b/hal/wifi3.0/hal_internal.h @@ -1325,4 +1325,33 @@ struct hal_srng *hal_ring_handle_to_hal_srng(hal_ring_handle_t hal_ring) * REO2PPE destination indication */ #define REO2PPE_DST_IND 11 + +/** + * enum hal_pkt_type - Type of packet type reported by HW + * @HAL_DOT11A: 802.11a PPDU type + * @HAL_DOT11B: 802.11b PPDU type + * @HAL_DOT11N_MM: 802.11n Mixed Mode PPDU type + * @HAL_DOT11AC: 802.11ac PPDU type + * @HAL_DOT11AX: 802.11ax PPDU type + * @HAL_DOT11BA: 802.11ba (WUR) PPDU type + * @HAL_DOT11BE: 802.11be PPDU type + * @HAL_DOT11AZ: 802.11az (ranging) PPDU type + * @HAL_DOT11N_GF: 802.11n Green Field PPDU type + * + * Enum indicating the packet type reported by HW in rx_pkt_tlvs (RX data) + * or WBM2SW ring entry's descriptor (TX data completion) + */ +enum hal_pkt_type { + HAL_DOT11A = 0, + HAL_DOT11B = 1, + HAL_DOT11N_MM = 2, + HAL_DOT11AC = 3, + HAL_DOT11AX = 4, + HAL_DOT11BA = 5, + HAL_DOT11BE = 6, + HAL_DOT11AZ = 7, + HAL_DOT11N_GF = 8, + HAL_DOT11_MAX, +}; + #endif /* _HAL_INTERNAL_H_ */