linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] mac80211: implement DONT_REORDER radiotap flag
@ 2020-11-04  6:18 Mathy Vanhoef
  2020-11-04  6:18 ` [PATCH 1/5] mac80211: add radiotap flag to assure frames are not reordered Mathy Vanhoef
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Mathy Vanhoef @ 2020-11-04  6:18 UTC (permalink / raw)
  To: Johannes Berg, linux-wireless, ath9k-devel, Kalle Valo; +Cc: Mathy Vanhoef

The radiotap TX flags field has recently been properly standardized,
including a new DONT_REORDER bit. This set of patches implements
the new DONT_REORDER bit in mac80211 and for selected drivers.

Mathy Vanhoef (5):
  mac80211: add radiotap flag to assure frames are not reordered
  mac80211: adhere to Tx control flag that prevents frame reordering
  mac80211: don't overwrite QoS TID of injected frames
  mac80211: assure that certain drivers adhere to DONT_REORDER flag
  ath9k_htc: adhere to the DONT_REORDER transmit flag

 drivers/net/wireless/ath/ath9k/htc_drv_txrx.c |  7 ++++++-
 include/net/ieee80211_radiotap.h              |  1 +
 include/net/mac80211.h                        |  4 ++++
 net/mac80211/tx.c                             | 13 +++++++++----
 net/mac80211/wme.c                            | 15 +++++++++++++--
 5 files changed, 33 insertions(+), 7 deletions(-)

-- 
2.28.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] mac80211: add radiotap flag to assure frames are not reordered
  2020-11-04  6:18 [PATCH 0/5] mac80211: implement DONT_REORDER radiotap flag Mathy Vanhoef
@ 2020-11-04  6:18 ` Mathy Vanhoef
  2020-11-04  6:18 ` [PATCH 2/5] mac80211: adhere to Tx control flag that prevents frame reordering Mathy Vanhoef
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Mathy Vanhoef @ 2020-11-04  6:18 UTC (permalink / raw)
  To: Johannes Berg, linux-wireless, ath9k-devel, Kalle Valo; +Cc: Mathy Vanhoef

Add a new radiotap flag to indicate injected frames must not be
reordered relative to other frames that also have this flag set,
independent of priority field values in the transmitted frame.
Parse this radiotap flag and define and set a corresponding Tx
control flag. Note that this flag has recently been standardized
as part of an update to radiotap.

Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
---
 include/net/ieee80211_radiotap.h | 1 +
 include/net/mac80211.h           | 4 ++++
 net/mac80211/tx.c                | 3 +++
 3 files changed, 8 insertions(+)

diff --git a/include/net/ieee80211_radiotap.h b/include/net/ieee80211_radiotap.h
index 19c00d100..c0854933e 100644
--- a/include/net/ieee80211_radiotap.h
+++ b/include/net/ieee80211_radiotap.h
@@ -118,6 +118,7 @@ enum ieee80211_radiotap_tx_flags {
 	IEEE80211_RADIOTAP_F_TX_RTS = 0x0004,
 	IEEE80211_RADIOTAP_F_TX_NOACK = 0x0008,
 	IEEE80211_RADIOTAP_F_TX_NOSEQNO = 0x0010,
+	IEEE80211_RADIOTAP_F_TX_ORDER = 0x0020,
 };
 
 /* for IEEE80211_RADIOTAP_MCS "have" flags */
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index e8e295dae..69864b5ef 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -856,6 +856,9 @@ enum mac80211_tx_info_flags {
  *	it can be sent out.
  * @IEEE80211_TX_CTRL_NO_SEQNO: Do not overwrite the sequence number that
  *	has already been assigned to this frame.
+ * @IEEE80211_TX_CTRL_DONT_REORDER: This frame should not be reordered
+ *	relative to other frames that have this flag set, independent
+ *	of their QoS TID or other priority field values.
  *
  * These flags are used in tx_info->control.flags.
  */
@@ -868,6 +871,7 @@ enum mac80211_tx_control_flags {
 	IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP	= BIT(5),
 	IEEE80211_TX_INTCFL_NEED_TXPROCESSING	= BIT(6),
 	IEEE80211_TX_CTRL_NO_SEQNO		= BIT(7),
+	IEEE80211_TX_CTRL_DONT_REORDER		= BIT(8),
 };
 
 /*
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 8ba10a48d..d4e1a2720 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2102,6 +2102,9 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,
 				info->flags |= IEEE80211_TX_CTL_NO_ACK;
 			if (txflags & IEEE80211_RADIOTAP_F_TX_NOSEQNO)
 				info->control.flags |= IEEE80211_TX_CTRL_NO_SEQNO;
+			if (txflags & IEEE80211_RADIOTAP_F_TX_ORDER)
+				info->control.flags |=
+					IEEE80211_TX_CTRL_DONT_REORDER;
 			break;
 
 		case IEEE80211_RADIOTAP_RATE:
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] mac80211: adhere to Tx control flag that prevents frame reordering
  2020-11-04  6:18 [PATCH 0/5] mac80211: implement DONT_REORDER radiotap flag Mathy Vanhoef
  2020-11-04  6:18 ` [PATCH 1/5] mac80211: add radiotap flag to assure frames are not reordered Mathy Vanhoef
@ 2020-11-04  6:18 ` Mathy Vanhoef
  2020-11-04  6:18 ` [PATCH 3/5] mac80211: don't overwrite QoS TID of injected frames Mathy Vanhoef
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Mathy Vanhoef @ 2020-11-04  6:18 UTC (permalink / raw)
  To: Johannes Berg, linux-wireless, ath9k-devel, Kalle Valo; +Cc: Mathy Vanhoef

When the Tx control flag is set to prevent frame reordering, send
all frames that have this flag set on the same queue. This assures
that frames that have this flag set are not reordered relative to
other frames that have this flag set.

Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
---
 net/mac80211/wme.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c
index 2fb993251..3d7dea387 100644
--- a/net/mac80211/wme.c
+++ b/net/mac80211/wme.c
@@ -118,9 +118,11 @@ u16 ieee80211_select_queue_80211(struct ieee80211_sub_if_data *sdata,
 				 struct ieee80211_hdr *hdr)
 {
 	struct ieee80211_local *local = sdata->local;
+	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
 	u8 *p;
 
-	if (local->hw.queues < IEEE80211_NUM_ACS)
+	if ((info->control.flags & IEEE80211_TX_CTRL_DONT_REORDER) ||
+	    local->hw.queues < IEEE80211_NUM_ACS)
 		return 0;
 
 	if (!ieee80211_is_data(hdr->frame_control)) {
@@ -141,6 +143,7 @@ u16 ieee80211_select_queue_80211(struct ieee80211_sub_if_data *sdata,
 u16 __ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,
 			     struct sta_info *sta, struct sk_buff *skb)
 {
+	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
 	struct mac80211_qos_map *qos_map;
 	bool qos;
 
@@ -153,7 +156,7 @@ u16 __ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,
 	else
 		qos = false;
 
-	if (!qos) {
+	if (!qos || (info->control.flags & IEEE80211_TX_CTRL_DONT_REORDER)) {
 		skb->priority = 0; /* required for correct WPA/11i MIC */
 		return IEEE80211_AC_BE;
 	}
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] mac80211: don't overwrite QoS TID of injected frames
  2020-11-04  6:18 [PATCH 0/5] mac80211: implement DONT_REORDER radiotap flag Mathy Vanhoef
  2020-11-04  6:18 ` [PATCH 1/5] mac80211: add radiotap flag to assure frames are not reordered Mathy Vanhoef
  2020-11-04  6:18 ` [PATCH 2/5] mac80211: adhere to Tx control flag that prevents frame reordering Mathy Vanhoef
@ 2020-11-04  6:18 ` Mathy Vanhoef
  2020-11-04  6:18 ` [PATCH 4/5] mac80211: assure that certain drivers adhere to DONT_REORDER flag Mathy Vanhoef
  2020-11-04  6:18 ` [PATCH 5/5] ath9k_htc: adhere to the DONT_REORDER transmit flag Mathy Vanhoef
  4 siblings, 0 replies; 7+ messages in thread
From: Mathy Vanhoef @ 2020-11-04  6:18 UTC (permalink / raw)
  To: Johannes Berg, linux-wireless, ath9k-devel, Kalle Valo; +Cc: Mathy Vanhoef

Currently ieee80211_set_qos_hdr set the QoS TID of all frames based
on the value assigned to skb->priority. This means it will also
overwrite the QoS TID of injected frames. The commit 753ffad3d624
("mac80211: fix TID field in monitor mode transmit") prevented
injected frames from being modified because of this by setting
skb->priority to the TID of the injected frame, which assured the
QoS TID will not be changed to a different value. Unfortunately,
this workaround complicates the handling of injected frames because
we can't set skb->priority without affecting the TID value in the
QoS field of injected frames.

To avoid this, and to implify the next patch, detect if a frame is
injected in ieee80211_set_qos_hdr and if so do not change its QoS
field.

Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
---
 net/mac80211/tx.c  | 5 +----
 net/mac80211/wme.c | 8 ++++++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index d4e1a2720..8bf80b675 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2271,10 +2271,7 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
 						    payload[7]);
 	}
 
-	/*
-	 * Initialize skb->priority for QoS frames. This is put in the TID field
-	 * of the frame before passing it to the driver.
-	 */
+	/* Initialize skb->priority for QoS frames */
 	if (ieee80211_is_data_qos(hdr->frame_control)) {
 		u8 *p = ieee80211_get_qos_ctl(hdr);
 		skb->priority = *p & IEEE80211_QOS_CTL_TAG1D_MASK;
diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c
index 3d7dea387..2702d314e 100644
--- a/net/mac80211/wme.c
+++ b/net/mac80211/wme.c
@@ -252,6 +252,14 @@ void ieee80211_set_qos_hdr(struct ieee80211_sub_if_data *sdata,
 
 	p = ieee80211_get_qos_ctl(hdr);
 
+	/* don't overwrite the QoS field of injected frames */
+	if (info->flags & IEEE80211_TX_CTL_INJECTED) {
+		/* do take into account Ack policy of injected frames */
+		if (*p & IEEE80211_QOS_CTL_ACK_POLICY_NOACK)
+			info->flags |= IEEE80211_TX_CTL_NO_ACK;
+		return;
+	}
+
 	/* set up the first byte */
 
 	/*
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] mac80211: assure that certain drivers adhere to DONT_REORDER flag
  2020-11-04  6:18 [PATCH 0/5] mac80211: implement DONT_REORDER radiotap flag Mathy Vanhoef
                   ` (2 preceding siblings ...)
  2020-11-04  6:18 ` [PATCH 3/5] mac80211: don't overwrite QoS TID of injected frames Mathy Vanhoef
@ 2020-11-04  6:18 ` Mathy Vanhoef
  2020-11-04  6:18 ` [PATCH 5/5] ath9k_htc: adhere to the DONT_REORDER transmit flag Mathy Vanhoef
  4 siblings, 0 replies; 7+ messages in thread
From: Mathy Vanhoef @ 2020-11-04  6:18 UTC (permalink / raw)
  To: Johannes Berg, linux-wireless, ath9k-devel, Kalle Valo; +Cc: Mathy Vanhoef

Some drivers use skb->priority to determine on which queue to send
a frame. An example is mt76x2u (this was tested on an AWUS036ACM).
This means these drivers currently do not adhere to the DONT_REORDER
flag. To fix this, we do not set skb->priority based on the QoS TID
of injected frames when the DONT_REORDER flag is set.

Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
---
 net/mac80211/tx.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 8bf80b675..1651cf7b2 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2271,8 +2271,13 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
 						    payload[7]);
 	}
 
-	/* Initialize skb->priority for QoS frames */
-	if (ieee80211_is_data_qos(hdr->frame_control)) {
+	/* Initialize skb->priority for QoS frames. If the DONT_REORDER flag
+	 * is set, stick to the default value for skb->priority to assure
+	 * frames injected with this flag are not reordered relative to each
+	 * other.
+	 */
+	if (ieee80211_is_data_qos(hdr->frame_control) &&
+	    !(info->control.flags & IEEE80211_TX_CTRL_DONT_REORDER)) {
 		u8 *p = ieee80211_get_qos_ctl(hdr);
 		skb->priority = *p & IEEE80211_QOS_CTL_TAG1D_MASK;
 	}
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] ath9k_htc: adhere to the DONT_REORDER transmit flag
  2020-11-04  6:18 [PATCH 0/5] mac80211: implement DONT_REORDER radiotap flag Mathy Vanhoef
                   ` (3 preceding siblings ...)
  2020-11-04  6:18 ` [PATCH 4/5] mac80211: assure that certain drivers adhere to DONT_REORDER flag Mathy Vanhoef
@ 2020-11-04  6:18 ` Mathy Vanhoef
  2020-12-09  7:05   ` Kalle Valo
  4 siblings, 1 reply; 7+ messages in thread
From: Mathy Vanhoef @ 2020-11-04  6:18 UTC (permalink / raw)
  To: Johannes Berg, linux-wireless, ath9k-devel, Kalle Valo; +Cc: Mathy Vanhoef

Assure that frames with the fixed order flag are not reordered
relative to each other. This is accomplished by transmitting them
using a fixed priority independent of their QoS field.

Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
---
 drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
index 0bdc4dcb7..8e69e8989 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
@@ -297,7 +297,12 @@ static void ath9k_htc_tx_data(struct ath9k_htc_priv *priv,
 		tx_hdr.data_type = ATH9K_HTC_NORMAL;
 	}
 
-	if (ieee80211_is_data_qos(hdr->frame_control)) {
+	/* Transmit all frames that should not be reordered relative
+	 * to each other using the same priority. For other QoS data
+	 * frames extract the priority from the header.
+	 */
+	if (!(tx_info->control.flags & IEEE80211_TX_CTRL_DONT_REORDER) &&
+	    ieee80211_is_data_qos(hdr->frame_control)) {
 		qc = ieee80211_get_qos_ctl(hdr);
 		tx_hdr.tidno = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
 	}
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 5/5] ath9k_htc: adhere to the DONT_REORDER transmit flag
  2020-11-04  6:18 ` [PATCH 5/5] ath9k_htc: adhere to the DONT_REORDER transmit flag Mathy Vanhoef
@ 2020-12-09  7:05   ` Kalle Valo
  0 siblings, 0 replies; 7+ messages in thread
From: Kalle Valo @ 2020-12-09  7:05 UTC (permalink / raw)
  To: Mathy Vanhoef; +Cc: Johannes Berg, linux-wireless, ath9k-devel, Mathy Vanhoef

Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be> wrote:

> Assure that frames with the fixed order flag are not reordered
> relative to each other. This is accomplished by transmitting them
> using a fixed priority independent of their QoS field.
> 
> Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

Patch applied to ath-next branch of ath.git, thanks.

8a71f34bb251 ath9k_htc: adhere to the DONT_REORDER transmit flag

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20201104061823.197407-6-Mathy.Vanhoef@kuleuven.be/

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-12-09  7:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-04  6:18 [PATCH 0/5] mac80211: implement DONT_REORDER radiotap flag Mathy Vanhoef
2020-11-04  6:18 ` [PATCH 1/5] mac80211: add radiotap flag to assure frames are not reordered Mathy Vanhoef
2020-11-04  6:18 ` [PATCH 2/5] mac80211: adhere to Tx control flag that prevents frame reordering Mathy Vanhoef
2020-11-04  6:18 ` [PATCH 3/5] mac80211: don't overwrite QoS TID of injected frames Mathy Vanhoef
2020-11-04  6:18 ` [PATCH 4/5] mac80211: assure that certain drivers adhere to DONT_REORDER flag Mathy Vanhoef
2020-11-04  6:18 ` [PATCH 5/5] ath9k_htc: adhere to the DONT_REORDER transmit flag Mathy Vanhoef
2020-12-09  7:05   ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).