341-mac80211-parse-VHT-info-in-injected-frames.patch 2.0 KB

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