From 40d1805fceea439015eb0947afab37bff2e2932b Mon Sep 17 00:00:00 2001 From: Amit Mehta Date: Tue, 31 Oct 2023 03:04:46 -0700 Subject: [PATCH] qcacmn: Add changes to update band info in txrx_peer NULL case Currently if txrx_peer is NULL in Tx completion or rx process band update will not happen, which will result in invalid band issue during connectivity logging. To fix the issue maintain local link id and use link id to find link peer and update band information in nbuf cb based on peer frequency. Change-Id: Ia5a6001fbc167a497660dc7be39a3e641dd28896 CRs-Fixed: 3654696 --- dp/wifi3.0/dp_main.c | 53 ++++++++++++++++++++++++++++++++++++++ dp/wifi3.0/dp_peer.c | 7 ----- dp/wifi3.0/dp_peer.h | 8 ++++++ dp/wifi3.0/dp_rings_main.c | 27 +++++++++++++++++++ dp/wifi3.0/dp_rx.c | 40 ++++++++++++++++++++++++++++ dp/wifi3.0/dp_tx.c | 52 +++++++++++++++++++++++++++++++++++++ dp/wifi3.0/dp_tx.h | 2 +- dp/wifi3.0/dp_types.h | 5 ++++ 8 files changed, 186 insertions(+), 8 deletions(-) diff --git a/dp/wifi3.0/dp_main.c b/dp/wifi3.0/dp_main.c index fd85d8a292..2038601c7f 100644 --- a/dp/wifi3.0/dp_main.c +++ b/dp/wifi3.0/dp_main.c @@ -5556,6 +5556,29 @@ void dp_txrx_peer_stats_clr(struct dp_txrx_peer *txrx_peer) dp_peer_jitter_stats_ctx_clr(txrx_peer); } +#if defined WLAN_FEATURE_11BE_MLO && defined DP_MLO_LINK_STATS_SUPPORT +/** + * dp_txrx_peer_reset_local_link_id() - Reset local link id + * @txrx_peer: txrx peer handle + * + * Return: None + */ +static inline void +dp_txrx_peer_reset_local_link_id(struct dp_txrx_peer *txrx_peer) +{ + int i; + + txrx_peer->local_link_id = 0; + for (i = 0; i <= DP_MAX_MLO_LINKS; i++) + txrx_peer->ll_band[i] = DP_BAND_INVALID; +} +#else +static inline void +dp_txrx_peer_reset_local_link_id(struct dp_txrx_peer *txrx_peer) +{ +} +#endif + /** * dp_peer_create_wifi3() - attach txrx peer * @soc_hdl: Datapath soc handle @@ -5645,6 +5668,7 @@ dp_peer_create_wifi3(struct cdp_soc_t *soc_hdl, uint8_t vdev_id, dp_set_peer_isolation(peer->txrx_peer, false); dp_wds_ext_peer_init(peer->txrx_peer); dp_peer_hw_txrx_stats_init(soc, peer->txrx_peer); + dp_txrx_peer_reset_local_link_id(peer->txrx_peer); } dp_cfg_event_record_peer_evt(soc, DP_CFG_EVENT_PEER_CREATE, @@ -8012,11 +8036,39 @@ dp_check_map_link_id_band(struct dp_peer *peer) if (peer->link_id_valid) dp_map_link_id_band(peer); } + +/** + * dp_map_local_link_id_band() - map local link id band + * @peer: dp peer handle + * + * Return: None + */ +static inline +void dp_map_local_link_id_band(struct dp_peer *peer) +{ + struct dp_txrx_peer *txrx_peer = NULL; + enum dp_bands band; + + txrx_peer = dp_get_txrx_peer(peer); + if (txrx_peer && peer->local_link_id) { + band = dp_freq_to_band(peer->freq); + txrx_peer->ll_band[peer->local_link_id] = band; + } else { + dp_info("txrx_peer NULL or local link id not set: %u " + QDF_MAC_ADDR_FMT, peer->local_link_id, + QDF_MAC_ADDR_REF(peer->mac_addr.raw)); + } +} #else static inline void dp_check_map_link_id_band(struct dp_peer *peer) { } + +static inline +void dp_map_local_link_id_band(struct dp_peer *peer) +{ +} #endif /** @@ -8051,6 +8103,7 @@ dp_set_peer_freq(struct cdp_soc_t *cdp_soc, uint8_t vdev_id, peer->freq = val.cdp_peer_param_freq; dp_check_map_link_id_band(peer); + dp_map_local_link_id_band(peer); dp_peer_unref_delete(peer, DP_MOD_ID_CDP); dp_info("Peer " QDF_MAC_ADDR_FMT " vdev_id %u, frequency %u", diff --git a/dp/wifi3.0/dp_peer.c b/dp/wifi3.0/dp_peer.c index 33a8f1756d..178a9d3bbb 100644 --- a/dp/wifi3.0/dp_peer.c +++ b/dp/wifi3.0/dp_peer.c @@ -3106,13 +3106,6 @@ dp_rx_peer_unmap_handler(struct dp_soc *soc, uint16_t peer_id, } #if defined(WLAN_FEATURE_11BE_MLO) && defined(DP_MLO_LINK_STATS_SUPPORT) -/** - * dp_freq_to_band() - Convert frequency to band - * @freq: peer frequency - * - * Return: band for input frequency - */ -static inline enum dp_bands dp_freq_to_band(qdf_freq_t freq) { if (REG_IS_24GHZ_CH_FREQ(freq)) diff --git a/dp/wifi3.0/dp_peer.h b/dp/wifi3.0/dp_peer.h index e54028c30c..c9a12d9fb9 100644 --- a/dp/wifi3.0/dp_peer.h +++ b/dp/wifi3.0/dp_peer.h @@ -65,6 +65,14 @@ enum dp_bands { DP_BAND_6GHZ = 3, DP_BAND_UNKNOWN = 4, }; + +/** + * dp_freq_to_band() - Convert frequency to band + * @freq: peer frequency + * + * Return: band for input frequency + */ +enum dp_bands dp_freq_to_band(qdf_freq_t freq); #endif void check_free_list_for_invalid_flush(struct dp_soc *soc); diff --git a/dp/wifi3.0/dp_rings_main.c b/dp/wifi3.0/dp_rings_main.c index 522ac0601d..50c351205b 100644 --- a/dp/wifi3.0/dp_rings_main.c +++ b/dp/wifi3.0/dp_rings_main.c @@ -2510,6 +2510,31 @@ static void dp_peer_setup_get_reo_hash(struct dp_vdev *vdev, lmac_peer_id_msb); } #endif /* IPA_OFFLOAD */ +#if defined WLAN_FEATURE_11BE_MLO && defined DP_MLO_LINK_STATS_SUPPORT +/** + * dp_peer_set_local_link_id() - Set local link id + * @peer: dp peer handle + * + * Return: None + */ +static inline void +dp_peer_set_local_link_id(struct dp_peer *peer) +{ + struct dp_txrx_peer *txrx_peer; + + if (!IS_MLO_DP_LINK_PEER(peer)) + return; + + txrx_peer = dp_get_txrx_peer(peer); + if (txrx_peer) + peer->local_link_id = ++txrx_peer->local_link_id; +} +#else +static inline void +dp_peer_set_local_link_id(struct dp_peer *peer) +{ +} +#endif /** * dp_peer_setup_wifi3() - initialize the peer @@ -2621,6 +2646,8 @@ dp_peer_setup_wifi3(struct cdp_soc_t *soc_hdl, uint8_t vdev_id, } } + dp_peer_set_local_link_id(peer); + if (!IS_MLO_DP_MLD_PEER(peer)) dp_peer_ppdu_delayed_ba_init(peer); diff --git a/dp/wifi3.0/dp_rx.c b/dp/wifi3.0/dp_rx.c index 9b89ee7335..84556e2814 100644 --- a/dp/wifi3.0/dp_rx.c +++ b/dp/wifi3.0/dp_rx.c @@ -2787,6 +2787,45 @@ static bool dp_rx_is_udp_allowed_over_roam_peer(struct dp_vdev *vdev, return false; } #endif + +#if defined(WLAN_FEATURE_11BE_MLO) && defined(DP_MLO_LINK_STATS_SUPPORT) +/** + * dp_rx_nbuf_band_set() - set nbuf band. + * @soc: dp soc handle + * @nbuf: nbuf handle + * + * Return: None + */ +static inline void +dp_rx_nbuf_band_set(struct dp_soc *soc, qdf_nbuf_t nbuf) +{ + struct qdf_mac_addr *mac_addr; + struct dp_peer *peer; + struct dp_txrx_peer *txrx_peer; + + uint8_t link_id; + + mac_addr = (struct qdf_mac_addr *)(qdf_nbuf_data(nbuf) + + QDF_NBUF_SRC_MAC_OFFSET); + + peer = dp_mld_peer_find_hash_find(soc, mac_addr->bytes, 0, + DP_VDEV_ALL, DP_MOD_ID_RX); + if (qdf_likely(peer)) { + txrx_peer = dp_get_txrx_peer(peer); + if (qdf_likely(txrx_peer)) { + link_id = QDF_NBUF_CB_RX_LOGICAL_LINK_ID(nbuf); + qdf_nbuf_rx_set_band(nbuf, txrx_peer->ll_band[link_id]); + } + dp_peer_unref_delete(peer, DP_MOD_ID_RX); + } +} +#else +static inline void +dp_rx_nbuf_band_set(struct dp_soc *soc, qdf_nbuf_t nbuf) +{ +} +#endif + void dp_rx_deliver_to_stack_no_peer(struct dp_soc *soc, qdf_nbuf_t nbuf) { uint16_t peer_id; @@ -2829,6 +2868,7 @@ void dp_rx_deliver_to_stack_no_peer(struct dp_soc *soc, qdf_nbuf_t nbuf) if (is_special_frame || dp_rx_is_udp_allowed_over_roam_peer(vdev, rx_tlv_hdr, nbuf)) { + dp_rx_nbuf_band_set(soc, nbuf); qdf_nbuf_set_exc_frame(nbuf, 1); if (QDF_STATUS_SUCCESS != vdev->osif_rx(vdev->osif_vdev, nbuf)) diff --git a/dp/wifi3.0/dp_tx.c b/dp/wifi3.0/dp_tx.c index 5efa5c1d97..2aa61ec713 100644 --- a/dp/wifi3.0/dp_tx.c +++ b/dp/wifi3.0/dp_tx.c @@ -6001,6 +6001,57 @@ dp_update_mcast_stats(struct dp_txrx_peer *txrx_peer, uint8_t link_id, { } #endif +#if defined(WLAN_FEATURE_11BE_MLO) && defined(DP_MLO_LINK_STATS_SUPPORT) +/** + * dp_tx_comp_set_nbuf_band() - set nbuf band. + * @soc: dp soc handle + * @nbuf: nbuf handle + * @ts: tx completion status + * + * Return: None + */ +static inline void +dp_tx_comp_set_nbuf_band(struct dp_soc *soc, qdf_nbuf_t nbuf, + struct hal_tx_completion_status *ts) +{ + struct qdf_mac_addr *mac_addr; + struct dp_peer *peer; + struct dp_txrx_peer *txrx_peer; + uint8_t link_id; + + if ((QDF_NBUF_CB_GET_PACKET_TYPE(nbuf) != + QDF_NBUF_CB_PACKET_TYPE_EAPOL && + QDF_NBUF_CB_GET_PACKET_TYPE(nbuf) != + QDF_NBUF_CB_PACKET_TYPE_DHCP && + QDF_NBUF_CB_GET_PACKET_TYPE(nbuf) != + QDF_NBUF_CB_PACKET_TYPE_DHCPV6) || + QDF_NBUF_CB_GET_IS_BCAST(nbuf)) + return; + + mac_addr = (struct qdf_mac_addr *)(qdf_nbuf_data(nbuf) + + QDF_NBUF_DEST_MAC_OFFSET); + + peer = dp_mld_peer_find_hash_find(soc, mac_addr->bytes, 0, + DP_VDEV_ALL, DP_MOD_ID_TX_COMP); + if (qdf_likely(peer)) { + txrx_peer = dp_get_txrx_peer(peer); + if (qdf_likely(txrx_peer)) { + link_id = + dp_tx_get_link_id_from_ppdu_id(soc, ts, + txrx_peer, + txrx_peer->vdev); + qdf_nbuf_tx_set_band(nbuf, txrx_peer->ll_band[link_id]); + } + dp_peer_unref_delete(peer, DP_MOD_ID_TX_COMP); + } +} +#else +static inline void +dp_tx_comp_set_nbuf_band(struct dp_soc *soc, qdf_nbuf_t nbuf, + struct hal_tx_completion_status *ts) +{ +} +#endif void dp_tx_comp_process_tx_status(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc, @@ -6063,6 +6114,7 @@ void dp_tx_comp_process_tx_status(struct dp_soc *soc, (ts->status == HAL_TX_TQM_RR_REM_CMD_REM)); if (!txrx_peer) { + dp_tx_comp_set_nbuf_band(soc, nbuf, ts); dp_info_rl("peer is null or deletion in progress"); DP_STATS_INC_PKT(soc, tx.tx_invalid_peer, 1, length); diff --git a/dp/wifi3.0/dp_tx.h b/dp/wifi3.0/dp_tx.h index 6765d20c14..372628f42e 100644 --- a/dp/wifi3.0/dp_tx.h +++ b/dp/wifi3.0/dp_tx.h @@ -2148,7 +2148,7 @@ static inline int dp_get_rtpm_tput_policy_requirement(struct dp_soc *soc) * @txrx_peer: txrx_peer pointer * @link_id: Peer Link ID * - * Returen: None + * Return: None */ static inline void dp_tx_set_nbuf_band(qdf_nbuf_t nbuf, struct dp_txrx_peer *txrx_peer, diff --git a/dp/wifi3.0/dp_types.h b/dp/wifi3.0/dp_types.h index da882ef4f8..3e883103b6 100644 --- a/dp/wifi3.0/dp_types.h +++ b/dp/wifi3.0/dp_types.h @@ -4914,6 +4914,8 @@ struct dp_peer_stats { * @bw: bandwidth of peer connection * @mpdu_retry_threshold: MPDU retry threshold to increment tx bad count * @band: Link ID to band mapping + * @local_link_id: Local host link ID. + * @ll_band: Local link id band mapping * @stats_arr_size: peer stats array size * @stats: Peer link and mld statistics */ @@ -4967,6 +4969,8 @@ struct dp_txrx_peer { #if defined WLAN_FEATURE_11BE_MLO && defined DP_MLO_LINK_STATS_SUPPORT /* Link ID to band mapping, (1 MLD + DP_MAX_MLO_LINKS) */ uint8_t band[DP_MAX_MLO_LINKS + 1]; + uint8_t local_link_id; + uint8_t ll_band[DP_MAX_MLO_LINKS + 1]; #endif uint8_t stats_arr_size; @@ -5070,6 +5074,7 @@ struct dp_peer { /*Link ID of link peer*/ uint8_t link_id; bool link_id_valid; + uint8_t local_link_id; /*---------for mld peer----------*/ struct dp_peer_link_info link_peers[DP_MAX_MLO_LINKS];