linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/5] Add radiotap flag to prevent frame reordering
@ 2020-07-24  5:47 Mathy Vanhoef
  2020-07-24  5:51 ` [RFC 1/5] mac80211: add radiotap flag to assure frames are not reordered Mathy Vanhoef
  0 siblings, 1 reply; 6+ messages in thread
From: Mathy Vanhoef @ 2020-07-24  5:47 UTC (permalink / raw)
  To: Johannes Berg, linux-wireless, ath9k-devel, Kalle Valo; +Cc: Mathy Vanhoef

Add a flag to radiotap's Tx flag field to prevent frame reordering
and assure that selected drivers also adhere to this flag. Previously,
injected frames might otherwise be reordered relative to each other
before transmission based on their QoS TID priority.

This is a new radiotag flag and, I assume, will first have to be
approved by the radiotap standard. I'll send a mail to the radiotap
mailing list shortly to start this discussion/process.

These patches depend on the patch set "[PATCH 0/6] mac80211: monitor
mode injection fixes". I can single out the individual patches that
it depends on if needed.

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                             | 12 ++++++++----
 net/mac80211/wme.c                            | 15 +++++++++++++--
 5 files changed, 32 insertions(+), 7 deletions(-)

-- 
2.27.0


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

* [RFC 1/5] mac80211: add radiotap flag to assure frames are not reordered
  2020-07-24  5:47 [RFC 0/5] Add radiotap flag to prevent frame reordering Mathy Vanhoef
@ 2020-07-24  5:51 ` Mathy Vanhoef
  2020-07-24  5:51   ` [RFC 2/5] mac80211: adhere to Tx control flag that prevents frame reordering Mathy Vanhoef
                     ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Mathy Vanhoef @ 2020-07-24  5:51 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.

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 4e23ad385..d0f5c8f27 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -827,6 +827,9 @@ enum mac80211_tx_info_flags {
  *	(header conversion)
  * @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.
  */
@@ -839,6 +842,7 @@ enum mac80211_tx_control_flags {
 	IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP	= BIT(5),
 	IEEE80211_TX_CTRL_HW_80211_ENCAP	= 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 dac73baeb..23fa19148 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2097,6 +2097,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.27.0


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

* [RFC 2/5] mac80211: adhere to Tx control flag that prevents frame reordering
  2020-07-24  5:51 ` [RFC 1/5] mac80211: add radiotap flag to assure frames are not reordered Mathy Vanhoef
@ 2020-07-24  5:51   ` Mathy Vanhoef
  2020-07-24  5:51   ` [RFC 3/5] mac80211: don't overwrite QoS TID of injected frames Mathy Vanhoef
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Mathy Vanhoef @ 2020-07-24  5:51 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 72920d829..a49dd7f1f 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.27.0


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

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

Currently ieee80211_set_qos_hdr overwrites the QoS TID of injected
frames based on the value assigned to skb->priority. The commit
753ffad3d624 ("mac80211: fix TID field in monitor mode transmit")
worked around this problem 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 of injected frames.

To avoid this, and to simplify 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 23fa19148..96069683f 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2266,10 +2266,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 a49dd7f1f..e66d1463d 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.27.0


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

* [RFC 4/5] mac80211: assure that certain drivers adhere to DONT_REORDER flag
  2020-07-24  5:51 ` [RFC 1/5] mac80211: add radiotap flag to assure frames are not reordered Mathy Vanhoef
  2020-07-24  5:51   ` [RFC 2/5] mac80211: adhere to Tx control flag that prevents frame reordering Mathy Vanhoef
  2020-07-24  5:51   ` [RFC 3/5] mac80211: don't overwrite QoS TID of injected frames Mathy Vanhoef
@ 2020-07-24  5:51   ` Mathy Vanhoef
  2020-07-24  5:51   ` [RFC 5/5] ath9k_htc: adhere to the DONT_REORDER transmit flag Mathy Vanhoef
  3 siblings, 0 replies; 6+ messages in thread
From: Mathy Vanhoef @ 2020-07-24  5:51 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 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 | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 96069683f..33697c5dc 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2266,8 +2266,12 @@ 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, stick to the default value 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.27.0


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

* [RFC 5/5] ath9k_htc: adhere to the DONT_REORDER transmit flag
  2020-07-24  5:51 ` [RFC 1/5] mac80211: add radiotap flag to assure frames are not reordered Mathy Vanhoef
                     ` (2 preceding siblings ...)
  2020-07-24  5:51   ` [RFC 4/5] mac80211: assure that certain drivers adhere to DONT_REORDER flag Mathy Vanhoef
@ 2020-07-24  5:51   ` Mathy Vanhoef
  3 siblings, 0 replies; 6+ messages in thread
From: Mathy Vanhoef @ 2020-07-24  5:51 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 b353995bd..4cbc62234 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.27.0


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

end of thread, other threads:[~2020-07-24  5:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24  5:47 [RFC 0/5] Add radiotap flag to prevent frame reordering Mathy Vanhoef
2020-07-24  5:51 ` [RFC 1/5] mac80211: add radiotap flag to assure frames are not reordered Mathy Vanhoef
2020-07-24  5:51   ` [RFC 2/5] mac80211: adhere to Tx control flag that prevents frame reordering Mathy Vanhoef
2020-07-24  5:51   ` [RFC 3/5] mac80211: don't overwrite QoS TID of injected frames Mathy Vanhoef
2020-07-24  5:51   ` [RFC 4/5] mac80211: assure that certain drivers adhere to DONT_REORDER flag Mathy Vanhoef
2020-07-24  5:51   ` [RFC 5/5] ath9k_htc: adhere to the DONT_REORDER transmit flag Mathy Vanhoef

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).