All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhi-Jun You <hujy652@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: ath10k@lists.infradead.org, Zhi-Jun You <hujy652@gmail.com>
Subject: [RFC] wifi: ath10k: Implement duplicate detection for non-offloaded PCIe
Date: Tue,  6 Dec 2022 00:18:51 +0800	[thread overview]
Message-ID: <20221205161851.780-1-hujy652@gmail.com> (raw)

Chips like QCA9984, IPQ4019 doesn't do duplicate detection in firmware.
Implement it in driver so it can skip a check in mac80211.

Check only the first skb since all the skbs in amsdu share the same
header.

Tested-on: QCA9984 10.4-3.9.0.2-00159
Signed-off-by: Zhi-Jun You <hujy652@gmail.com>
---

I am not sure what's the formal name for chips like QCA9984 so I will
call it non-offloaded PCIe for now.
---
 drivers/net/wireless/ath/ath10k/core.h   |  1 +
 drivers/net/wireless/ath/ath10k/htt_rx.c | 51 ++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/txrx.c   |  3 ++
 3 files changed, 55 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index f5de8ce8fb45..6b4f5208f32f 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -436,6 +436,7 @@ struct ath10k_peer {
 		enum htt_security_types sec_type;
 		int pn_len;
 	} rx_pn[ATH10K_HTT_TXRX_PEER_SECURITY_MAX];
+	u16 last_rx_seq_ctrl[IEEE80211_NUM_TIDS + 1];
 };
 
 struct ath10k_txq {
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
index 438b0caaceb7..e241eab4cce1 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -1344,6 +1344,56 @@ static char *ath10k_get_tid(struct ieee80211_hdr *hdr, char *out, size_t size)
 	return out;
 }
 
+static void ath10k_htt_rx_h_check_dup(struct ath10k *ar,
+				      struct sk_buff_head *amsdu,
+				      struct ieee80211_rx_status *status)
+{
+	struct ath10k_hw_params *hw = &ar->hw_params;
+	struct sk_buff *first;
+	struct ath10k_peer *peer;
+	struct ieee80211_hdr *hdr;
+	struct htt_rx_desc *rxd;
+	struct rx_mpdu_start *rxd_mpdu_start;
+	u16 peer_id;
+	u8 tid;
+
+	if (skb_queue_empty(amsdu))
+		return;
+
+	first = skb_peek(amsdu);
+	rxd = HTT_RX_BUF_TO_RX_DESC(hw,
+				    (void *)first->data - hw->rx_desc_ops->rx_desc_size);
+
+	rxd_mpdu_start = ath10k_htt_rx_desc_get_mpdu_start(hw, rxd);
+	peer_id = MS(__le32_to_cpu(rxd_mpdu_start->info0),
+		     RX_MPDU_START_INFO0_PEER_IDX);
+
+	spin_lock_bh(&ar->data_lock);
+
+	peer = ath10k_peer_find_by_id(ar, peer_id);
+	if (!peer)
+		goto out;
+
+	hdr = (void *)ath10k_htt_rx_desc_get_rx_hdr_status(hw, rxd);
+	if (ieee80211_is_data_qos(hdr->frame_control))
+		tid = ieee80211_get_tid(hdr);
+	else
+		tid = ATH10K_TXRX_NON_QOS_TID;
+
+	if (ieee80211_has_retry(hdr->frame_control) &&
+	    peer->last_rx_seq_ctrl[tid] == __le16_to_cpu(hdr->seq_ctrl)) {
+		__skb_queue_purge(amsdu);
+		goto out;
+	}
+
+	peer->last_rx_seq_ctrl[tid] = __le16_to_cpu(hdr->seq_ctrl);
+
+	status->flag |= RX_FLAG_DUP_VALIDATED;
+
+out:
+	spin_unlock_bh(&ar->data_lock);
+}
+
 static void ath10k_htt_rx_h_queue_msdu(struct ath10k *ar,
 				       struct ieee80211_rx_status *rx_status,
 				       struct sk_buff *skb)
@@ -2356,6 +2406,7 @@ static int ath10k_htt_rx_handle_amsdu(struct ath10k_htt *htt)
 		ath10k_htt_rx_h_unchain(ar, &amsdu, &drop_cnt, &unchain_cnt);
 
 	ath10k_htt_rx_h_filter(ar, &amsdu, rx_status, &drop_cnt_filter);
+	ath10k_htt_rx_h_check_dup(ar, &amsdu, rx_status);
 	ath10k_htt_rx_h_mpdu(ar, &amsdu, rx_status, true, first_hdr, &err, 0,
 			     false);
 	msdus_to_queue = skb_queue_len(&amsdu);
diff --git a/drivers/net/wireless/ath/ath10k/txrx.c b/drivers/net/wireless/ath/ath10k/txrx.c
index da3bc35e41aa..a8b8186537f4 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.c
+++ b/drivers/net/wireless/ath/ath10k/txrx.c
@@ -219,6 +219,7 @@ void ath10k_peer_map_event(struct ath10k_htt *htt,
 {
 	struct ath10k *ar = htt->ar;
 	struct ath10k_peer *peer;
+	int i;
 
 	if (ev->peer_id >= ATH10K_MAX_NUM_PEER_IDS) {
 		ath10k_warn(ar,
@@ -237,6 +238,8 @@ void ath10k_peer_map_event(struct ath10k_htt *htt,
 		peer->vdev_id = ev->vdev_id;
 		ether_addr_copy(peer->addr, ev->addr);
 		list_add(&peer->list, &ar->peers);
+		for (i = 0; i <= IEEE80211_NUM_TIDS; i++)
+			peer->last_rx_sec_ctrl[i] = USHRT_MAX;
 		wake_up(&ar->peer_mapping_wq);
 	}
 
-- 
2.34.1


WARNING: multiple messages have this Message-ID (diff)
From: Zhi-Jun You <hujy652@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: ath10k@lists.infradead.org, Zhi-Jun You <hujy652@gmail.com>
Subject: [RFC] wifi: ath10k: Implement duplicate detection for non-offloaded PCIe
Date: Tue,  6 Dec 2022 00:18:51 +0800	[thread overview]
Message-ID: <20221205161851.780-1-hujy652@gmail.com> (raw)

Chips like QCA9984, IPQ4019 doesn't do duplicate detection in firmware.
Implement it in driver so it can skip a check in mac80211.

Check only the first skb since all the skbs in amsdu share the same
header.

Tested-on: QCA9984 10.4-3.9.0.2-00159
Signed-off-by: Zhi-Jun You <hujy652@gmail.com>
---

I am not sure what's the formal name for chips like QCA9984 so I will
call it non-offloaded PCIe for now.
---
 drivers/net/wireless/ath/ath10k/core.h   |  1 +
 drivers/net/wireless/ath/ath10k/htt_rx.c | 51 ++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/txrx.c   |  3 ++
 3 files changed, 55 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index f5de8ce8fb45..6b4f5208f32f 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -436,6 +436,7 @@ struct ath10k_peer {
 		enum htt_security_types sec_type;
 		int pn_len;
 	} rx_pn[ATH10K_HTT_TXRX_PEER_SECURITY_MAX];
+	u16 last_rx_seq_ctrl[IEEE80211_NUM_TIDS + 1];
 };
 
 struct ath10k_txq {
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
index 438b0caaceb7..e241eab4cce1 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -1344,6 +1344,56 @@ static char *ath10k_get_tid(struct ieee80211_hdr *hdr, char *out, size_t size)
 	return out;
 }
 
+static void ath10k_htt_rx_h_check_dup(struct ath10k *ar,
+				      struct sk_buff_head *amsdu,
+				      struct ieee80211_rx_status *status)
+{
+	struct ath10k_hw_params *hw = &ar->hw_params;
+	struct sk_buff *first;
+	struct ath10k_peer *peer;
+	struct ieee80211_hdr *hdr;
+	struct htt_rx_desc *rxd;
+	struct rx_mpdu_start *rxd_mpdu_start;
+	u16 peer_id;
+	u8 tid;
+
+	if (skb_queue_empty(amsdu))
+		return;
+
+	first = skb_peek(amsdu);
+	rxd = HTT_RX_BUF_TO_RX_DESC(hw,
+				    (void *)first->data - hw->rx_desc_ops->rx_desc_size);
+
+	rxd_mpdu_start = ath10k_htt_rx_desc_get_mpdu_start(hw, rxd);
+	peer_id = MS(__le32_to_cpu(rxd_mpdu_start->info0),
+		     RX_MPDU_START_INFO0_PEER_IDX);
+
+	spin_lock_bh(&ar->data_lock);
+
+	peer = ath10k_peer_find_by_id(ar, peer_id);
+	if (!peer)
+		goto out;
+
+	hdr = (void *)ath10k_htt_rx_desc_get_rx_hdr_status(hw, rxd);
+	if (ieee80211_is_data_qos(hdr->frame_control))
+		tid = ieee80211_get_tid(hdr);
+	else
+		tid = ATH10K_TXRX_NON_QOS_TID;
+
+	if (ieee80211_has_retry(hdr->frame_control) &&
+	    peer->last_rx_seq_ctrl[tid] == __le16_to_cpu(hdr->seq_ctrl)) {
+		__skb_queue_purge(amsdu);
+		goto out;
+	}
+
+	peer->last_rx_seq_ctrl[tid] = __le16_to_cpu(hdr->seq_ctrl);
+
+	status->flag |= RX_FLAG_DUP_VALIDATED;
+
+out:
+	spin_unlock_bh(&ar->data_lock);
+}
+
 static void ath10k_htt_rx_h_queue_msdu(struct ath10k *ar,
 				       struct ieee80211_rx_status *rx_status,
 				       struct sk_buff *skb)
@@ -2356,6 +2406,7 @@ static int ath10k_htt_rx_handle_amsdu(struct ath10k_htt *htt)
 		ath10k_htt_rx_h_unchain(ar, &amsdu, &drop_cnt, &unchain_cnt);
 
 	ath10k_htt_rx_h_filter(ar, &amsdu, rx_status, &drop_cnt_filter);
+	ath10k_htt_rx_h_check_dup(ar, &amsdu, rx_status);
 	ath10k_htt_rx_h_mpdu(ar, &amsdu, rx_status, true, first_hdr, &err, 0,
 			     false);
 	msdus_to_queue = skb_queue_len(&amsdu);
diff --git a/drivers/net/wireless/ath/ath10k/txrx.c b/drivers/net/wireless/ath/ath10k/txrx.c
index da3bc35e41aa..a8b8186537f4 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.c
+++ b/drivers/net/wireless/ath/ath10k/txrx.c
@@ -219,6 +219,7 @@ void ath10k_peer_map_event(struct ath10k_htt *htt,
 {
 	struct ath10k *ar = htt->ar;
 	struct ath10k_peer *peer;
+	int i;
 
 	if (ev->peer_id >= ATH10K_MAX_NUM_PEER_IDS) {
 		ath10k_warn(ar,
@@ -237,6 +238,8 @@ void ath10k_peer_map_event(struct ath10k_htt *htt,
 		peer->vdev_id = ev->vdev_id;
 		ether_addr_copy(peer->addr, ev->addr);
 		list_add(&peer->list, &ar->peers);
+		for (i = 0; i <= IEEE80211_NUM_TIDS; i++)
+			peer->last_rx_sec_ctrl[i] = USHRT_MAX;
 		wake_up(&ar->peer_mapping_wq);
 	}
 
-- 
2.34.1


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

             reply	other threads:[~2022-12-05 16:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05 16:18 Zhi-Jun You [this message]
2022-12-05 16:18 ` [RFC] wifi: ath10k: Implement duplicate detection for non-offloaded PCIe Zhi-Jun You
2022-12-06  4:18 ` kernel test robot
2022-12-06  7:00 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221205161851.780-1-hujy652@gmail.com \
    --to=hujy652@gmail.com \
    --cc=ath10k@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.