This patch was actually orginally submitted by Felix Fietkau in the linus-wireless mailing list.

The patch allows userspace applications that use packet injection to specify
the frame transmission rate on a per-packet basis.

Signed-off-by: Roberto Riggio<[email protected]>


--

Index: package/mac80211/patches/810-radiotap_rate.patch
===================================================================
--- package/mac80211/patches/810-radiotap_rate.patch    (revision 0)
+++ package/mac80211/patches/810-radiotap_rate.patch    (revision 0)
@@ -0,0 +1,73 @@
+diff -urN compat-wireless-2010-06-10.old/include/net/mac80211.h compat-wireless-2010-06-10.new/include/net/mac80211.h +--- compat-wireless-2010-06-10.old/include/net/mac80211.h 2010-06-10 22:52:03.000000000 +0200 ++++ compat-wireless-2010-06-10.new/include/net/mac80211.h 2010-06-12 10:18:02.623091853 +0200
+@@ -288,6 +288,7 @@
+  * @IEEE80211_TX_CTL_LDPC: tells the driver to use LDPC for this frame
+  * @IEEE80211_TX_CTL_STBC: Enables Space-Time Block Coding (STBC) for this
+  *    frame and selects the maximum number of streams that it can use.
++ * @IEEE80211_TX_CTL_RC_BYPASS: Don't use rate control on the frame.
+  */
+ enum mac80211_tx_control_flags {
+     IEEE80211_TX_CTL_REQ_TX_STATUS        = BIT(0),
+@@ -313,6 +314,7 @@
+     IEEE80211_TX_INTFL_NL80211_FRAME_TX    = BIT(21),
+     IEEE80211_TX_CTL_LDPC            = BIT(22),
+     IEEE80211_TX_CTL_STBC            = BIT(23) | BIT(24),
++    IEEE80211_TX_CTL_RC_BYPASS        = BIT(25),
+ };
+
+ #define IEEE80211_TX_CTL_STBC_SHIFT        23
+diff -urN compat-wireless-2010-06-10.old/net/mac80211/tx.c compat-wireless-2010-06-10.new/net/mac80211/tx.c +--- compat-wireless-2010-06-10.old/net/mac80211/tx.c 2010-06-10 22:52:03.000000000 +0200 ++++ compat-wireless-2010-06-10.new/net/mac80211/tx.c 2010-06-12 10:20:45.203094264 +0200
+@@ -1068,6 +1068,40 @@
+                 tx->flags |= IEEE80211_TX_FRAGMENTED;
+             break;
+
++        case IEEE80211_RADIOTAP_RATE: {
++            int i, idx = -1;
++            int rate = *iterator.this_arg * 5;
++
++            for (i = 0; i < sband->n_bitrates; i++)
++                if (sband->bitrates[i].bitrate == rate) {
++                idx = i;
++                    break;
++                }
++
++            /* Rate not available - rejecting */
++            if (idx < 0)
++                return false;
++
++            info->flags |= IEEE80211_TX_CTL_RC_BYPASS;
++            info->control.rates[0].idx = idx;
++            info->control.rates[0].count = 1;
++            for (i = 1; i < IEEE80211_TX_MAX_RATES; i++)
++                info->control.rates[i].idx = -1;
++            break;
++        }
++
++        case IEEE80211_RADIOTAP_DATA_RETRIES:
++            /*
++             * Only allow setting the number of retries in
++             * conjunction with the rates, when the rate control
++             * is bypassed.
++             */
++            if (info->flags & IEEE80211_TX_CTL_RC_BYPASS)
++                info->control.rates[0].count =
++                    *iterator.this_arg;
++            break;
++
++
+         /*
+          * Please update the file
+          * Documentation/networking/mac80211-injection.txt
+@@ -1374,7 +1373,8 @@
+     CALL_TXH(ieee80211_tx_h_check_assoc);
+     CALL_TXH(ieee80211_tx_h_ps_buf);
+     CALL_TXH(ieee80211_tx_h_select_key);
+-    if (!(tx->local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL))
++    if (!(tx->local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) &&
++        !(info->flags & IEEE80211_TX_CTL_RC_BYPASS))
+         CALL_TXH(ieee80211_tx_h_rate_ctrl);
+
+     if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION))
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to