rpcd: iwinfo plugin fixes
[openwrt.git] / package / kernel / mac80211 / patches / 341-mac80211-parse-VHT-info-in-injected-frames.patch
1 From: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
2 Date: Tue, 23 Feb 2016 15:43:35 +0100
3 Subject: [PATCH] mac80211: parse VHT info in injected frames
4
5 Add VHT radiotap parsing support to ieee80211_parse_tx_radiotap().
6 That capability has been tested using a d-link dir-860l rev b1 running
7 OpenWrt trunk and mt76 driver
8
9 Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
10 ---
11
12 --- a/net/mac80211/tx.c
13 +++ b/net/mac80211/tx.c
14 @@ -1690,6 +1690,8 @@ static bool ieee80211_parse_tx_radiotap(
15         u8 rate_retries = 0;
16         u16 rate_flags = 0;
17         u8 mcs_known, mcs_flags, mcs_bw;
18 +       u16 vht_known;
19 +       u8 vht_mcs = 0, vht_nss = 0;
20         int i;
21  
22         info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT |
23 @@ -1771,6 +1773,32 @@ static bool ieee80211_parse_tx_radiotap(
24                                 rate_flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
25                         break;
26  
27 +               case IEEE80211_RADIOTAP_VHT:
28 +                       vht_known = get_unaligned_le16(iterator.this_arg);
29 +                       rate_found = true;
30 +
31 +                       rate_flags = IEEE80211_TX_RC_VHT_MCS;
32 +                       if ((vht_known & IEEE80211_RADIOTAP_VHT_KNOWN_GI) &&
33 +                           (iterator.this_arg[2] &
34 +                            IEEE80211_RADIOTAP_VHT_FLAG_SGI))
35 +                               rate_flags |= IEEE80211_TX_RC_SHORT_GI;
36 +                       if (vht_known &
37 +                           IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH) {
38 +                               if (iterator.this_arg[3] == 1)
39 +                                       rate_flags |=
40 +                                               IEEE80211_TX_RC_40_MHZ_WIDTH;
41 +                               else if (iterator.this_arg[3] == 4)
42 +                                       rate_flags |=
43 +                                               IEEE80211_TX_RC_80_MHZ_WIDTH;
44 +                               else if (iterator.this_arg[3] == 11)
45 +                                       rate_flags |=
46 +                                               IEEE80211_TX_RC_160_MHZ_WIDTH;
47 +                       }
48 +
49 +                       vht_mcs = iterator.this_arg[4] >> 4;
50 +                       vht_nss = iterator.this_arg[4] & 0xF;
51 +                       break;
52 +
53                 /*
54                  * Please update the file
55                  * Documentation/networking/mac80211-injection.txt
56 @@ -1796,6 +1824,9 @@ static bool ieee80211_parse_tx_radiotap(
57  
58                 if (rate_flags & IEEE80211_TX_RC_MCS) {
59                         info->control.rates[0].idx = rate;
60 +               } else if (rate_flags & IEEE80211_TX_RC_VHT_MCS) {
61 +                       ieee80211_rate_set_vht(info->control.rates, vht_mcs,
62 +                                              vht_nss);
63                 } else {
64                         for (i = 0; i < sband->n_bitrates; i++) {
65                                 if (rate * 5 != sband->bitrates[i].bitrate)