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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. From 9d7a7a4d2b02bcd30fb5fe4270278212353cc332 Mon Sep 17 00:00:00 2001
  2. From: Stanislaw Gruszka <[email protected]>
  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 <[email protected]>
  11. Signed-off-by: Kalle Valo <[email protected]>
  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. --- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
  17. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
  18. @@ -1760,6 +1760,8 @@
  19. #define TX_STA_FIFO_WCID FIELD32(0x0000ff00)
  20. #define TX_STA_FIFO_SUCCESS_RATE FIELD32(0xffff0000)
  21. #define TX_STA_FIFO_MCS FIELD32(0x007f0000)
  22. +#define TX_STA_FIFO_BW FIELD32(0x00800000)
  23. +#define TX_STA_FIFO_SGI FIELD32(0x01000000)
  24. #define TX_STA_FIFO_PHYMODE FIELD32(0xc0000000)
  25. /*
  26. --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  27. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  28. @@ -852,6 +852,39 @@ void rt2800_process_rxwi(struct queue_en
  29. }
  30. EXPORT_SYMBOL_GPL(rt2800_process_rxwi);
  31. +static void rt2800_rate_from_status(struct skb_frame_desc *skbdesc,
  32. + u32 status, enum nl80211_band band)
  33. +{
  34. + u8 flags = 0;
  35. + u8 idx = rt2x00_get_field32(status, TX_STA_FIFO_MCS);
  36. +
  37. + switch (rt2x00_get_field32(status, TX_STA_FIFO_PHYMODE)) {
  38. + case RATE_MODE_HT_GREENFIELD:
  39. + flags |= IEEE80211_TX_RC_GREEN_FIELD;
  40. + /* fall through */
  41. + case RATE_MODE_HT_MIX:
  42. + flags |= IEEE80211_TX_RC_MCS;
  43. + break;
  44. + case RATE_MODE_OFDM:
  45. + if (band == NL80211_BAND_2GHZ)
  46. + idx += 4;
  47. + break;
  48. + case RATE_MODE_CCK:
  49. + if (idx >= 8)
  50. + idx -= 8;
  51. + break;
  52. + }
  53. +
  54. + if (rt2x00_get_field32(status, TX_STA_FIFO_BW))
  55. + flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
  56. +
  57. + if (rt2x00_get_field32(status, TX_STA_FIFO_SGI))
  58. + flags |= IEEE80211_TX_RC_SHORT_GI;
  59. +
  60. + skbdesc->tx_rate_idx = idx;
  61. + skbdesc->tx_rate_flags = flags;
  62. +}
  63. +
  64. void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi,
  65. bool match)
  66. {
  67. @@ -898,7 +931,7 @@ void rt2800_txdone_entry(struct queue_en
  68. * and provide retry count.
  69. */
  70. if (unlikely((aggr == 1 && ampdu == 0 && real_mcs != mcs)) || !match) {
  71. - skbdesc->tx_rate_idx = real_mcs;
  72. + rt2800_rate_from_status(skbdesc, status, rt2x00dev->curr_band);
  73. mcs = real_mcs;
  74. }