1 From 6257c702264c44d74c6b71f0c62a7665da2dc356 Mon Sep 17 00:00:00 2001
2 From: Pradeep Kumar Chitrapu <quic_pradeepc@quicinc.com>
3 Date: Mon, 17 Apr 2023 13:35:02 +0300
4 Subject: [PATCH] wifi: ath11k: fix tx status reporting in encap offload mode
6 ieee80211_tx_status() treats packets in 802.11 frame format and
7 tries to extract sta address from packet header. When tx encap
8 offload is enabled, this becomes invalid operation. Hence, switch
9 to using ieee80211_tx_status_ext() after filling in station
10 address for handling both 802.11 and 802.3 frames.
12 Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
14 Signed-off-by: Pradeep Kumar Chitrapu <quic_pradeepc@quicinc.com>
15 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
16 Link: https://lore.kernel.org/r/20230403195738.25367-2-quic_pradeepc@quicinc.com
18 drivers/net/wireless/ath/ath11k/dp.h | 4 +++
19 drivers/net/wireless/ath/ath11k/dp_tx.c | 33 ++++++++++++++++++++++++-
20 drivers/net/wireless/ath/ath11k/dp_tx.h | 1 +
21 3 files changed, 37 insertions(+), 1 deletion(-)
23 --- a/drivers/net/wireless/ath/ath11k/dp.h
24 +++ b/drivers/net/wireless/ath/ath11k/dp.h
25 @@ -303,12 +303,16 @@ struct ath11k_dp {
27 #define HTT_TX_WBM_COMP_STATUS_OFFSET 8
29 +#define HTT_INVALID_PEER_ID 0xffff
31 /* HTT tx completion is overlaid in wbm_release_ring */
32 #define HTT_TX_WBM_COMP_INFO0_STATUS GENMASK(12, 9)
33 #define HTT_TX_WBM_COMP_INFO0_REINJECT_REASON GENMASK(16, 13)
34 #define HTT_TX_WBM_COMP_INFO0_REINJECT_REASON GENMASK(16, 13)
36 #define HTT_TX_WBM_COMP_INFO1_ACK_RSSI GENMASK(31, 24)
37 +#define HTT_TX_WBM_COMP_INFO2_SW_PEER_ID GENMASK(15, 0)
38 +#define HTT_TX_WBM_COMP_INFO2_VALID BIT(21)
40 struct htt_tx_wbm_completion {
42 --- a/drivers/net/wireless/ath/ath11k/dp_tx.c
43 +++ b/drivers/net/wireless/ath/ath11k/dp_tx.c
44 @@ -316,10 +316,12 @@ ath11k_dp_tx_htt_tx_complete_buf(struct
45 struct dp_tx_ring *tx_ring,
46 struct ath11k_dp_htt_wbm_tx_status *ts)
48 + struct ieee80211_tx_status status = { 0 };
50 struct ieee80211_tx_info *info;
51 struct ath11k_skb_cb *skb_cb;
53 + struct ath11k_peer *peer;
55 spin_lock(&tx_ring->tx_idr_lock);
56 msdu = idr_remove(&tx_ring->txbuf_idr, ts->msdu_id);
57 @@ -341,6 +343,11 @@ ath11k_dp_tx_htt_tx_complete_buf(struct
59 dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
62 + dev_kfree_skb_any(msdu);
66 memset(&info->status, 0, sizeof(info->status));
69 @@ -355,7 +362,23 @@ ath11k_dp_tx_htt_tx_complete_buf(struct
73 - ieee80211_tx_status(ar->hw, msdu);
74 + spin_lock_bh(&ab->base_lock);
75 + peer = ath11k_peer_find_by_id(ab, ts->peer_id);
76 + if (!peer || !peer->sta) {
77 + ath11k_dbg(ab, ATH11K_DBG_DATA,
78 + "dp_tx: failed to find the peer with peer_id %d\n",
80 + spin_unlock_bh(&ab->base_lock);
81 + dev_kfree_skb_any(msdu);
84 + spin_unlock_bh(&ab->base_lock);
86 + status.sta = peer->sta;
90 + ieee80211_tx_status_ext(ar->hw, &status);
94 @@ -379,7 +402,15 @@ ath11k_dp_tx_process_htt_tx_complete(str
96 ts.ack_rssi = FIELD_GET(HTT_TX_WBM_COMP_INFO1_ACK_RSSI,
99 + if (FIELD_GET(HTT_TX_WBM_COMP_INFO2_VALID, status_desc->info2))
100 + ts.peer_id = FIELD_GET(HTT_TX_WBM_COMP_INFO2_SW_PEER_ID,
101 + status_desc->info2);
103 + ts.peer_id = HTT_INVALID_PEER_ID;
105 ath11k_dp_tx_htt_tx_complete_buf(ab, tx_ring, &ts);
108 case HAL_WBM_REL_HTT_TX_COMP_STATUS_REINJ:
109 case HAL_WBM_REL_HTT_TX_COMP_STATUS_INSPECT:
110 --- a/drivers/net/wireless/ath/ath11k/dp_tx.h
111 +++ b/drivers/net/wireless/ath/ath11k/dp_tx.h
112 @@ -13,6 +13,7 @@ struct ath11k_dp_htt_wbm_tx_status {
119 void ath11k_dp_tx_update_txcompl(struct ath11k *ar, struct hal_tx_status *ts);