1
0

020-14-rt2x00-use-txdone_nomatch-on-rt2800usb.patch 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. From 293dff78ee058ec1e0b90e05a803c512b6a2097f Mon Sep 17 00:00:00 2001
  2. From: Stanislaw Gruszka <sgruszka@redhat.com>
  3. Date: Wed, 15 Feb 2017 10:25:10 +0100
  4. Subject: [PATCH 14/19] rt2x00: use txdone_nomatch on rt2800usb
  5. If we do not match skb entry, provide tx status via nomatch procedure.
  6. Currently in that case we do rt2x00lib_txdone_noinfo(TXDONE_NOINFO),
  7. which actually assume that entry->skb was posted without retries and
  8. provide rate saved in skb desc as successful. Patch changed that to
  9. rate read from TX_STAT_FIFO, however still do not provide correct
  10. number of retries.
  11. On SoC/PCI devices we keep providing status via standard txdone
  12. procedure, no change in those devices, though we should thing about it.
  13. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
  14. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  15. ---
  16. drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 31 ++++++++++++++++++++-----
  17. drivers/net/wireless/ralink/rt2x00/rt2800lib.h | 3 ++-
  18. drivers/net/wireless/ralink/rt2x00/rt2800mmio.c | 2 +-
  19. drivers/net/wireless/ralink/rt2x00/rt2800usb.c | 18 ++++++--------
  20. 4 files changed, 35 insertions(+), 19 deletions(-)
  21. diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  22. index 46405cce35e0..4a7bec708a13 100644
  23. --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  24. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  25. @@ -852,7 +852,8 @@ void rt2800_process_rxwi(struct queue_entry *entry,
  26. }
  27. EXPORT_SYMBOL_GPL(rt2800_process_rxwi);
  28. -void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi)
  29. +void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi,
  30. + bool match)
  31. {
  32. struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
  33. struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;
  34. @@ -860,8 +861,7 @@ void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi)
  35. struct txdone_entry_desc txdesc;
  36. u32 word;
  37. u16 mcs, real_mcs;
  38. - int aggr, ampdu;
  39. - int wcid;
  40. + int aggr, ampdu, wcid, ack_req;
  41. /*
  42. * Obtain the status about this packet.
  43. @@ -875,6 +875,7 @@ void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi)
  44. real_mcs = rt2x00_get_field32(status, TX_STA_FIFO_MCS);
  45. aggr = rt2x00_get_field32(status, TX_STA_FIFO_TX_AGGRE);
  46. wcid = rt2x00_get_field32(status, TX_STA_FIFO_WCID);
  47. + ack_req = rt2x00_get_field32(status, TX_STA_FIFO_TX_ACK_REQUIRED);
  48. /*
  49. * If a frame was meant to be sent as a single non-aggregated MPDU
  50. @@ -891,8 +892,12 @@ void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi)
  51. * Hence, replace the requested rate with the real tx rate to not
  52. * confuse the rate control algortihm by providing clearly wrong
  53. * data.
  54. - */
  55. - if (unlikely(aggr == 1 && ampdu == 0 && real_mcs != mcs)) {
  56. + *
  57. + * FIXME: if we do not find matching entry, we tell that frame was
  58. + * posted without any retries. We need to find a way to fix that
  59. + * and provide retry count.
  60. + */
  61. + if (unlikely((aggr == 1 && ampdu == 0 && real_mcs != mcs)) || !match) {
  62. skbdesc->tx_rate_idx = real_mcs;
  63. mcs = real_mcs;
  64. }
  65. @@ -900,6 +905,9 @@ void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi)
  66. if (aggr == 1 || ampdu == 1)
  67. __set_bit(TXDONE_AMPDU, &txdesc.flags);
  68. + if (!ack_req)
  69. + __set_bit(TXDONE_NO_ACK_REQ, &txdesc.flags);
  70. +
  71. /*
  72. * Ralink has a retry mechanism using a global fallback
  73. * table. We setup this fallback table to try the immediate
  74. @@ -931,7 +939,18 @@ void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi)
  75. if (txdesc.retry)
  76. __set_bit(TXDONE_FALLBACK, &txdesc.flags);
  77. - rt2x00lib_txdone(entry, &txdesc);
  78. + if (!match) {
  79. + /* RCU assures non-null sta will not be freed by mac80211. */
  80. + rcu_read_lock();
  81. + if (likely(wcid >= WCID_START && wcid <= WCID_END))
  82. + skbdesc->sta = drv_data->wcid_to_sta[wcid - WCID_START];
  83. + else
  84. + skbdesc->sta = NULL;
  85. + rt2x00lib_txdone_nomatch(entry, &txdesc);
  86. + rcu_read_unlock();
  87. + } else {
  88. + rt2x00lib_txdone(entry, &txdesc);
  89. + }
  90. }
  91. EXPORT_SYMBOL_GPL(rt2800_txdone_entry);
  92. diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
  93. index 6811d677a6e7..d9ef260d542a 100644
  94. --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
  95. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
  96. @@ -191,7 +191,8 @@ void rt2800_write_tx_data(struct queue_entry *entry,
  97. struct txentry_desc *txdesc);
  98. void rt2800_process_rxwi(struct queue_entry *entry, struct rxdone_entry_desc *txdesc);
  99. -void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32* txwi);
  100. +void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi,
  101. + bool match);
  102. void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc);
  103. void rt2800_clear_beacon(struct queue_entry *entry);
  104. diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
  105. index de4790b41be7..3ab3b5323897 100644
  106. --- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
  107. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
  108. @@ -239,7 +239,7 @@ static bool rt2800mmio_txdone_release_entries(struct queue_entry *entry,
  109. {
  110. if (test_bit(ENTRY_DATA_STATUS_SET, &entry->flags)) {
  111. rt2800_txdone_entry(entry, entry->status,
  112. - rt2800mmio_get_txwi(entry));
  113. + rt2800mmio_get_txwi(entry), true);
  114. return false;
  115. }
  116. diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800usb.c b/drivers/net/wireless/ralink/rt2x00/rt2800usb.c
  117. index 205a7b8ac8a7..f11e3f532a84 100644
  118. --- a/drivers/net/wireless/ralink/rt2x00/rt2800usb.c
  119. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800usb.c
  120. @@ -501,8 +501,7 @@ static int rt2800usb_get_tx_data_len(struct queue_entry *entry)
  121. /*
  122. * TX control handlers
  123. */
  124. -static enum txdone_entry_desc_flags
  125. -rt2800usb_txdone_entry_check(struct queue_entry *entry, u32 reg)
  126. +static bool rt2800usb_txdone_entry_check(struct queue_entry *entry, u32 reg)
  127. {
  128. __le32 *txwi;
  129. u32 word;
  130. @@ -515,7 +514,7 @@ rt2800usb_txdone_entry_check(struct queue_entry *entry, u32 reg)
  131. * frame.
  132. */
  133. if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags))
  134. - return TXDONE_FAILURE;
  135. + return false;
  136. wcid = rt2x00_get_field32(reg, TX_STA_FIFO_WCID);
  137. ack = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED);
  138. @@ -537,10 +536,10 @@ rt2800usb_txdone_entry_check(struct queue_entry *entry, u32 reg)
  139. rt2x00_dbg(entry->queue->rt2x00dev,
  140. "TX status report missed for queue %d entry %d\n",
  141. entry->queue->qid, entry->entry_idx);
  142. - return TXDONE_UNKNOWN;
  143. + return false;
  144. }
  145. - return TXDONE_SUCCESS;
  146. + return true;
  147. }
  148. static void rt2800usb_txdone(struct rt2x00_dev *rt2x00dev)
  149. @@ -549,7 +548,7 @@ static void rt2800usb_txdone(struct rt2x00_dev *rt2x00dev)
  150. struct queue_entry *entry;
  151. u32 reg;
  152. u8 qid;
  153. - enum txdone_entry_desc_flags done_status;
  154. + bool match;
  155. while (kfifo_get(&rt2x00dev->txstatus_fifo, &reg)) {
  156. /*
  157. @@ -574,11 +573,8 @@ static void rt2800usb_txdone(struct rt2x00_dev *rt2x00dev)
  158. break;
  159. }
  160. - done_status = rt2800usb_txdone_entry_check(entry, reg);
  161. - if (likely(done_status == TXDONE_SUCCESS))
  162. - rt2800_txdone_entry(entry, reg, rt2800usb_get_txwi(entry));
  163. - else
  164. - rt2x00lib_txdone_noinfo(entry, done_status);
  165. + match = rt2800usb_txdone_entry_check(entry, reg);
  166. + rt2800_txdone_entry(entry, reg, rt2800usb_get_txwi(entry), match);
  167. }
  168. }
  169. --
  170. 2.12.1