020-15-rt2800-status-based-rate-flags-for-nomatch-case.patch 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. From 9d7a7a4d2b02bcd30fb5fe4270278212353cc332 Mon Sep 17 00:00:00 2001
  2. From: Stanislaw Gruszka <sgruszka@redhat.com>
  3. Date: Wed, 15 Feb 2017 10:25:11 +0100
  4. Subject: [PATCH 15/19] rt2800: status based rate flags for nomatch case
  5. We use skb_desc->tx_rate_flags from entry as rate[].flags even if
  6. skb does not match status. Patch corrects flags and also fixes
  7. mcs for legacy rates.
  8. rt2800_rate_from_status() is based on Felix's mt76
  9. mt76x2_mac_process_tx_rate() function.
  10. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
  11. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  12. ---
  13. drivers/net/wireless/ralink/rt2x00/rt2800.h | 2 ++
  14. drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 35 +++++++++++++++++++++++++-
  15. 2 files changed, 36 insertions(+), 1 deletion(-)
  16. diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h b/drivers/net/wireless/ralink/rt2x00/rt2800.h
  17. index 0e7051d8132f..480b08601785 100644
  18. --- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
  19. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
  20. @@ -1760,6 +1760,8 @@
  21. #define TX_STA_FIFO_WCID FIELD32(0x0000ff00)
  22. #define TX_STA_FIFO_SUCCESS_RATE FIELD32(0xffff0000)
  23. #define TX_STA_FIFO_MCS FIELD32(0x007f0000)
  24. +#define TX_STA_FIFO_BW FIELD32(0x00800000)
  25. +#define TX_STA_FIFO_SGI FIELD32(0x01000000)
  26. #define TX_STA_FIFO_PHYMODE FIELD32(0xc0000000)
  27. /*
  28. diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  29. index 4a7bec708a13..8d00c599e47a 100644
  30. --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  31. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  32. @@ -852,6 +852,39 @@ void rt2800_process_rxwi(struct queue_entry *entry,
  33. }
  34. EXPORT_SYMBOL_GPL(rt2800_process_rxwi);
  35. +static void rt2800_rate_from_status(struct skb_frame_desc *skbdesc,
  36. + u32 status, enum nl80211_band band)
  37. +{
  38. + u8 flags = 0;
  39. + u8 idx = rt2x00_get_field32(status, TX_STA_FIFO_MCS);
  40. +
  41. + switch (rt2x00_get_field32(status, TX_STA_FIFO_PHYMODE)) {
  42. + case RATE_MODE_HT_GREENFIELD:
  43. + flags |= IEEE80211_TX_RC_GREEN_FIELD;
  44. + /* fall through */
  45. + case RATE_MODE_HT_MIX:
  46. + flags |= IEEE80211_TX_RC_MCS;
  47. + break;
  48. + case RATE_MODE_OFDM:
  49. + if (band == NL80211_BAND_2GHZ)
  50. + idx += 4;
  51. + break;
  52. + case RATE_MODE_CCK:
  53. + if (idx >= 8)
  54. + idx -= 8;
  55. + break;
  56. + }
  57. +
  58. + if (rt2x00_get_field32(status, TX_STA_FIFO_BW))
  59. + flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
  60. +
  61. + if (rt2x00_get_field32(status, TX_STA_FIFO_SGI))
  62. + flags |= IEEE80211_TX_RC_SHORT_GI;
  63. +
  64. + skbdesc->tx_rate_idx = idx;
  65. + skbdesc->tx_rate_flags = flags;
  66. +}
  67. +
  68. void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi,
  69. bool match)
  70. {
  71. @@ -898,7 +931,7 @@ void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi,
  72. * and provide retry count.
  73. */
  74. if (unlikely((aggr == 1 && ampdu == 0 && real_mcs != mcs)) || !match) {
  75. - skbdesc->tx_rate_idx = real_mcs;
  76. + rt2800_rate_from_status(skbdesc, status, rt2x00dev->curr_band);
  77. mcs = real_mcs;
  78. }
  79. --
  80. 2.12.1