Skip to contentSkip to conversation

ath11k: switch to using ieee80211_tx_status_ext()

PATCH In review John Crispin 2 participants 8 messages Aug 3, 2020 – Aug 26, 2020 Qualcomm Atheros ATH11K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/2 ath11k: switch to using ieee80211_tx_status_ext()

This allows us to pass HE rates down into the stack.

---
Changes in V5
* fix sparse warnings

 drivers/net/wireless/ath/ath11k/dp_tx.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath11k/dp_tx.c +19 -5
index 1af76775b1a8..a1f16f589b98 100644
@@ -393,9 +393,12 @@ static void ath11k_dp_tx_complete_msdu(struct ath11k *ar,
 				       struct sk_buff *msdu,
 				       struct hal_tx_status *ts)
 {
+	struct ieee80211_tx_status status = { };
 	struct ath11k_base *ab = ar->ab;
 	struct ieee80211_tx_info *info;
 	struct ath11k_skb_cb *skb_cb;
+	struct ath11k_peer *peer;
+	struct ath11k_sta *arsta;
 
 	if (WARN_ON_ONCE(ts->buf_rel_source != HAL_WBM_REL_SRC_MODULE_TQM)) {
 		/* Must not happen */
@@ -459,12 +462,23 @@ static void ath11k_dp_tx_complete_msdu(struct ath11k *ar,
 		ath11k_dp_tx_cache_peer_stats(ar, msdu, ts);
 	}
 
-	/* NOTE: Tx rate status reporting. Tx completion status does not have
-	 * necessary information (for example nss) to build the tx rate.
-	 * Might end up reporting it out-of-band from HTT stats.
-	 */
 
-	ieee80211_tx_status(ar->hw, msdu);
+	spin_lock_bh(&ab->base_lock);
+	peer = ath11k_peer_find_by_id(ab, ts->peer_id);
+	if (peer) {
+		arsta = (struct ath11k_sta *)peer->sta->drv_priv;
+		status.sta = peer->sta;
+		status.skb = msdu;
+		status.info = info;
+		status.rate = &arsta->last_txrate;
+	}
+	rcu_read_unlock();
+	if (peer)
+		ieee80211_tx_status_ext(ar->hw, &status);
+	else
+		dev_kfree_skb_any(msdu);
+	spin_unlock_bh(&ab->base_lock);
+	return;
 
 exit:
 	rcu_read_unlock();
Signature · 7 lines
2.25.1


-- 
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#1 lore raw

PATCH v6 2/2 ath11k: add more HE fields into radiotap header

From: Miles Hu <[email protected]>

This patch adds code to parse HE fields inside ppdu TLVs. Then it adds the populates the additional info into the ratiotap header. Also fix missing QoS tag in native wifi mode. Finally rssi and tsf are also added.

---
Changes in V6
* remove an unused variable that kernel test robot complained about

Changes in V5
* fix sparse warnings

 drivers/net/wireless/ath/ath11k/dp_rx.c    | 106 ++++-
 drivers/net/wireless/ath/ath11k/hal_desc.h |   1 +
 drivers/net/wireless/ath/ath11k/hal_rx.c   | 440 +++++++++++++++++++--
 drivers/net/wireless/ath/ath11k/hal_rx.h   | 226 ++++++++++-
 4 files changed, 706 insertions(+), 67 deletions(-)
drivers/net/wireless/ath/ath11k/dp_rx.c +87 -19
index 5680b99a4f5c..e79aefc4a3e7 100644
@@ -240,7 +240,7 @@ static u8 *ath11k_dp_rxdesc_get_80211hdr(struct hal_rx_desc *rx_desc)
 {
 	u8 *rx_pkt_hdr;
 
-	rx_pkt_hdr = &rx_desc->msdu_payload[0];
+	rx_pkt_hdr = &rx_desc->hdr_status[0];
 
 	return rx_pkt_hdr;
 }
@@ -2251,7 +2251,7 @@ static void ath11k_dp_rx_deliver_msdu(struct ath11k *ar, struct napi_struct *nap
 	char tid[32];
 
 	status = IEEE80211_SKB_RXCB(msdu);
-	if (status->encoding == RX_ENC_HE) {
+	if (status->encoding == RX_ENC_HE && !(status->flag & RX_FLAG_RADIOTAP_HE)) {
 		he = skb_push(msdu, sizeof(known));
 		memcpy(he, &known, sizeof(known));
 		status->flag |= RX_FLAG_RADIOTAP_HE;
@@ -4522,11 +4522,14 @@ ath11k_dp_rx_mon_merg_msdus(struct ath11k *ar,
 			    struct ieee80211_rx_status *rxs)
 {
 	struct sk_buff *msdu, *mpdu_buf, *prev_buf;
-	u32 decap_format, wifi_hdr_len;
+	u32 decap_format;
 	struct hal_rx_desc *rx_desc;
 	char *hdr_desc;
 	u8 *dest;
 	struct ieee80211_hdr_3addr *wh;
+	static u32 pkt_type;
+
+	pkt_type++;
 
 	mpdu_buf = NULL;
 
@@ -4559,38 +4562,27 @@ ath11k_dp_rx_mon_merg_msdus(struct ath11k *ar,
 
 		skb_trim(prev_buf, prev_buf->len - HAL_RX_FCS_LEN);
 	} else if (decap_format == DP_RX_DECAP_TYPE_NATIVE_WIFI) {
-		__le16 qos_field;
 		u8 qos_pkt = 0;
 
 		rx_desc = (struct hal_rx_desc *)head_msdu->data;
 		hdr_desc = ath11k_dp_rxdesc_get_80211hdr(rx_desc);
 
 		/* Base size */
-		wifi_hdr_len = sizeof(struct ieee80211_hdr_3addr);
 		wh = (struct ieee80211_hdr_3addr *)hdr_desc;
 
 		if (ieee80211_is_data_qos(wh->frame_control)) {
-			struct ieee80211_qos_hdr *qwh =
-					(struct ieee80211_qos_hdr *)hdr_desc;
-
-			qos_field = qwh->qos_ctrl;
 			qos_pkt = 1;
 		}
 		msdu = head_msdu;
 
 		while (msdu) {
-			rx_desc = (struct hal_rx_desc *)msdu->data;
-			hdr_desc = ath11k_dp_rxdesc_get_80211hdr(rx_desc);
-
+			ath11k_dp_rx_msdus_set_payload(msdu);
 			if (qos_pkt) {
 				dest = skb_push(msdu, sizeof(__le16));
 				if (!dest)
 					goto err_merge_fail;
-				memcpy(dest, hdr_desc, wifi_hdr_len);
-				memcpy(dest + wifi_hdr_len,
-				       (u8 *)&qos_field, sizeof(__le16));
+				memcpy(dest, hdr_desc, sizeof(struct ieee80211_qos_hdr));
 			}
-			ath11k_dp_rx_msdus_set_payload(msdu);
 			prev_buf = msdu;
 			msdu = msdu->next;
 		}
@@ -4620,8 +4612,83 @@ ath11k_dp_rx_mon_merg_msdus(struct ath11k *ar,
 	return NULL;
 }
 
+static void
+ath11k_dp_rx_update_radiotap_he(struct hal_rx_mon_ppdu_info *rx_status,
+				u8 *rtap_buf)
+{
+	u32 rtap_len = 0;
+
+	put_unaligned_le16(rx_status->he_data1, &rtap_buf[rtap_len]);
+	rtap_len += 2;
+
+	put_unaligned_le16(rx_status->he_data2, &rtap_buf[rtap_len]);
+	rtap_len += 2;
+
+	put_unaligned_le16(rx_status->he_data3, &rtap_buf[rtap_len]);
+	rtap_len += 2;
+
+	put_unaligned_le16(rx_status->he_data4, &rtap_buf[rtap_len]);
+	rtap_len += 2;
+
+	put_unaligned_le16(rx_status->he_data5, &rtap_buf[rtap_len]);
+	rtap_len += 2;
+
+	put_unaligned_le16(rx_status->he_data6, &rtap_buf[rtap_len]);
+}
+
+static void
+ath11k_dp_rx_update_radiotap_he_mu(struct hal_rx_mon_ppdu_info *rx_status,
+				   u8 *rtap_buf)
+{
+	u32 rtap_len = 0;
+
+	put_unaligned_le16(rx_status->he_flags1, &rtap_buf[rtap_len]);
+	rtap_len += 2;
+
+	put_unaligned_le16(rx_status->he_flags2, &rtap_buf[rtap_len]);
+	rtap_len += 2;
+
+	rtap_buf[rtap_len] = rx_status->he_RU[0];
+	rtap_len += 1;
+
+	rtap_buf[rtap_len] = rx_status->he_RU[1];
+	rtap_len += 1;
+
+	rtap_buf[rtap_len] = rx_status->he_RU[2];
+	rtap_len += 1;
+
+	rtap_buf[rtap_len] = rx_status->he_RU[3];
+}
+
+static void ath11k_update_radiotap(struct hal_rx_mon_ppdu_info *ppduinfo,
+				   struct sk_buff *mon_skb,
+				   struct ieee80211_rx_status *rxs)
+{
+	u8 *ptr = NULL;
+
+	if (ppduinfo->he_mu_flags) {
+		rxs->flag |= RX_FLAG_RADIOTAP_HE_MU;
+		rxs->encoding = RX_ENC_HE;
+		ptr = skb_push(mon_skb, sizeof(struct ieee80211_radiotap_he_mu));
+		ath11k_dp_rx_update_radiotap_he_mu(ppduinfo, ptr);
+	}
+	if (ppduinfo->he_flags) {
+		rxs->flag |= RX_FLAG_RADIOTAP_HE;
+		rxs->encoding = RX_ENC_HE;
+		ptr = skb_push(mon_skb, sizeof(struct ieee80211_radiotap_he));
+		ath11k_dp_rx_update_radiotap_he(ppduinfo, ptr);
+	}
+
+	rxs->flag |= RX_FLAG_MACTIME_START;
+	rxs->signal = ppduinfo->rssi_comb + ATH11K_DEFAULT_NOISE_FLOOR;
+	rxs->nss = ppduinfo->nss;
+
+	rxs->mactime = ppduinfo->tsft;
+}
+
 static int ath11k_dp_rx_mon_deliver(struct ath11k *ar, u32 mac_id,
 				    struct sk_buff *head_msdu,
+				    struct hal_rx_mon_ppdu_info *ppduinfo,
 				    struct sk_buff *tail_msdu,
 				    struct napi_struct *napi)
 {
@@ -4651,11 +4718,9 @@ static int ath11k_dp_rx_mon_deliver(struct ath11k *ar, u32 mac_id,
 		} else {
 			rxs->flag |= RX_FLAG_ALLOW_SAME_PN;
 		}
-		rxs->flag |= RX_FLAG_ONLY_MONITOR;
-
+		ath11k_update_radiotap(ppduinfo, mon_skb, rxs);
 		status = IEEE80211_SKB_RXCB(mon_skb);
 		*status = *rxs;
-
 		ath11k_dp_rx_deliver_msdu(ar, napi, mon_skb);
 		mon_skb = skb_next;
 	} while (mon_skb);
@@ -4722,6 +4787,7 @@ static void ath11k_dp_rx_mon_dest_process(struct ath11k *ar, u32 quota,
 		}
 		if (head_msdu && tail_msdu) {
 			ath11k_dp_rx_mon_deliver(ar, dp->mac_id, head_msdu,
+						 &pmon->mon_ppdu_info,
 						 tail_msdu, napi);
 			rx_mon_stats->dest_mpdu_done++;
 		}
@@ -4762,6 +4828,8 @@ static void ath11k_dp_rx_mon_status_process_tlv(struct ath11k *ar,
 	while (!skb_queue_empty(&pmon->rx_status_q)) {
 		status_skb = skb_dequeue(&pmon->rx_status_q);
 
+		memset(ppdu_info, 0, sizeof(struct hal_rx_mon_ppdu_info));
+
 		tlv_status = ath11k_hal_rx_parse_mon_status(ar->ab, ppdu_info,
 							    status_skb);
 		if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
drivers/net/wireless/ath/ath11k/hal_desc.h +1 -0
index 8a592814efa0..d0ec8c0d1457 100644
@@ -474,6 +474,7 @@ enum hal_tlv_tag {
 
 #define HAL_TLV_HDR_TAG		GENMASK(9, 1)
 #define HAL_TLV_HDR_LEN		GENMASK(25, 10)
+#define HAL_TLV_USR_ID		GENMASK(31, 26)
 
 #define HAL_TLV_ALIGN	4
 
drivers/net/wireless/ath/ath11k/hal_rx.c +397 -43

557 lines not on this page · raw message

drivers/net/wireless/ath/ath11k/hal_rx.h +221 -5

300 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH V6 2/2] ath11k: add more HE fields into radiotap header

Quoted 8 lines · John Crispin

From: Miles Hu <[email protected]>

This patch adds code to parse HE fields inside ppdu TLVs. Then it adds the populates the additional info into the ratiotap header. Also fix missing QoS tag in native wifi mode. Finally rssi and tsf are also added.

[...]

drivers/net/wireless/ath/ath11k/dp_rx.c ath11k_dp_rx_mon_merg_msdus(struct ath11k *ar, · line 4532

Quoted 13 lines
drivers/net/wireless/ath/ath11k/dp_rx.c +4 -1
@@ -4522,11 +4522,14 @@ ath11k_dp_rx_mon_merg_msdus(struct ath11k *ar,
 			    struct ieee80211_rx_status *rxs)
 {
 	struct sk_buff *msdu, *mpdu_buf, *prev_buf;
-	u32 decap_format, wifi_hdr_len;
+	u32 decap_format;
 	struct hal_rx_desc *rx_desc;
 	char *hdr_desc;
 	u8 *dest;
 	struct ieee80211_hdr_3addr *wh;
+	static u32 pkt_type;
+
+	pkt_type++;

We cannot use static non-const variables in ath11k, that would be racy. As this seems to be an unused variable I have just removed it in the pending branch.

Signature · 1 line
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#3 lore raw

Re: [PATCH V6 2/2] ath11k: add more HE fields into radiotap header

In reply to John Crispin
Quoted 8 lines · John Crispin

From: Miles Hu <[email protected]>

This patch adds code to parse HE fields inside ppdu TLVs. Then it adds the populates the additional info into the ratiotap header. Also fix missing QoS tag in native wifi mode. Finally rssi and tsf are also added.

On what hardware and firmware was this tested?

I did quite a few cosmetic changes in the pending branch.

Quoted 4 lines
drivers/net/wireless/ath/ath11k/hal_rx.c +4 -0
+		value = FIELD_GET(HAL_RX_HE_SIG_A_SU_INFO_INFO0_BSS_COLOR, info0);
+		ppdu_info->he_data3 = value;
+		value = FIELD_GET(HAL_RX_HE_SIG_A_SU_INFO_INFO0_BEAM_CHANGE, info0);
+		value = value << HE_BEAM_CHANGE_SHIFT;

[...]

Review

Quoted 2 lines
(quoted diff) +2 -0
+#define HAL_RX_HE_SIG_A_SU_INFO_INFO0_BEAM_CHANGE	BIT(1)
+#define HE_BEAM_CHANGE_SHIFT 6

There's a lot of these shifts which I don't understand. Why not fix the actual defines so that FIELD_GET() works correctly and no manual shifting is needed? In this example from BIT(1) to BIT(7).

Signature · 1 line
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#5 lore raw
Quoted 7 lines · Kalle Valo
Quoted 3 lines · John Crispin

This allows us to pass HE rates down into the stack.

On what hardware and firmware was this tested?

Miles can give more insight, the patch was written by him, I just rebased it, removed the checkpatch warnings and did some basic testing.

    John

#6 lore raw
In reply to John Crispin
Quoted 4 lines · John Crispin

This allows us to pass HE rates down into the stack.

Dropping the per and expecting Miles will address the issues. Miles, as I did some changes to the patches in pending branch please incorporate my changes in v7:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=52a632ec5dd0eab7e82051164d42bd35fe06af00

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=0ed5b5fc10d08b565183008a14267779d6da4bd4

2 patches set to Changes Requested.

11698305 [V6,1/2] ath11k: switch to using ieee80211_tx_status_ext() 11698303 [V6,2/2] ath11k: add more HE fields into radiotap header

Signature · 9 lines
https://patchwork.kernel.org/patch/11698305/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


-- 
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#7 lore raw
In reply to John Crispin
Quoted 4 lines · John Crispin

This allows us to pass HE rates down into the stack.

Dropping the per and expecting Miles will address the issues. Miles, as I did some changes to the patches in pending branch please incorporate my changes in v7:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=52a632ec5dd0eab7e82051164d42bd35fe06af00

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=0ed5b5fc10d08b565183008a14267779d6da4bd4

2 patches set to Changes Requested.

11698305 [V6,1/2] ath11k: switch to using ieee80211_tx_status_ext() 11698303 [V6,2/2] ath11k: add more HE fields into radiotap header

Signature · 3 lines
https://patchwork.kernel.org/patch/11698305/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches