319-mac80211-reduce-duplication-in-tx-status-functions.patch 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. From: Felix Fietkau <[email protected]>
  2. Date: Mon, 17 Aug 2020 13:16:59 +0200
  3. Subject: [PATCH] mac80211: reduce duplication in tx status functions
  4. Move redundant functionality from __ieee80211_tx_status into
  5. ieee80211_tx_status_ext. Preparation for unifying with the 802.3 tx status
  6. codepath.
  7. Signed-off-by: Felix Fietkau <[email protected]>
  8. ---
  9. --- a/net/mac80211/status.c
  10. +++ b/net/mac80211/status.c
  11. @@ -184,18 +184,6 @@ static void ieee80211_frame_acked(struct
  12. struct ieee80211_mgmt *mgmt = (void *) skb->data;
  13. struct ieee80211_local *local = sta->local;
  14. struct ieee80211_sub_if_data *sdata = sta->sdata;
  15. - struct ieee80211_tx_info *txinfo = IEEE80211_SKB_CB(skb);
  16. -
  17. - if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
  18. - sta->status_stats.last_ack = jiffies;
  19. - if (txinfo->status.is_valid_ack_signal) {
  20. - sta->status_stats.last_ack_signal =
  21. - (s8)txinfo->status.ack_signal;
  22. - sta->status_stats.ack_signal_filled = true;
  23. - ewma_avg_signal_add(&sta->status_stats.avg_ack_signal,
  24. - -txinfo->status.ack_signal);
  25. - }
  26. - }
  27. if (ieee80211_is_data_qos(mgmt->frame_control)) {
  28. struct ieee80211_hdr *hdr = (void *) skb->data;
  29. @@ -897,7 +885,8 @@ void ieee80211_tx_monitor(struct ieee802
  30. }
  31. static void __ieee80211_tx_status(struct ieee80211_hw *hw,
  32. - struct ieee80211_tx_status *status)
  33. + struct ieee80211_tx_status *status,
  34. + int rates_idx, int retry_count)
  35. {
  36. struct sk_buff *skb = status->skb;
  37. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  38. @@ -906,8 +895,6 @@ static void __ieee80211_tx_status(struct
  39. struct sta_info *sta;
  40. __le16 fc;
  41. struct ieee80211_supported_band *sband;
  42. - int retry_count;
  43. - int rates_idx;
  44. bool send_to_cooked;
  45. bool acked;
  46. bool noack_success;
  47. @@ -916,8 +903,6 @@ static void __ieee80211_tx_status(struct
  48. int tid = IEEE80211_NUM_TIDS;
  49. u16 tx_time_est;
  50. - rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
  51. -
  52. sband = local->hw.wiphy->bands[info->band];
  53. fc = hdr->frame_control;
  54. @@ -994,24 +979,14 @@ static void __ieee80211_tx_status(struct
  55. if (info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
  56. ieee80211_handle_filtered_frame(local, sta, skb);
  57. return;
  58. - } else {
  59. + } else if (ieee80211_is_data_present(fc)) {
  60. if (!acked && !noack_success)
  61. - sta->status_stats.retry_failed++;
  62. - sta->status_stats.retry_count += retry_count;
  63. + sta->status_stats.msdu_failed[tid]++;
  64. - if (ieee80211_is_data_present(fc)) {
  65. - if (!acked && !noack_success)
  66. - sta->status_stats.msdu_failed[tid]++;
  67. -
  68. - sta->status_stats.msdu_retries[tid] +=
  69. - retry_count;
  70. - }
  71. + sta->status_stats.msdu_retries[tid] +=
  72. + retry_count;
  73. }
  74. - rate_control_tx_status(local, sband, status);
  75. - if (ieee80211_vif_is_mesh(&sta->sdata->vif))
  76. - ieee80211s_update_metric(local, sta, status);
  77. -
  78. if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked)
  79. ieee80211_frame_acked(sta, skb);
  80. @@ -1036,20 +1011,6 @@ static void __ieee80211_tx_status(struct
  81. true);
  82. ieee80211_info_set_tx_time_est(info, 0);
  83. }
  84. -
  85. - if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
  86. - if (acked) {
  87. - if (sta->status_stats.lost_packets)
  88. - sta->status_stats.lost_packets = 0;
  89. -
  90. - /* Track when last TDLS packet was ACKed */
  91. - sta->status_stats.last_pkt_time = jiffies;
  92. - } else if (noack_success) {
  93. - /* nothing to do here, do not account as lost */
  94. - } else {
  95. - ieee80211_lost_packet(sta, info);
  96. - }
  97. - }
  98. }
  99. /* SNMP counters
  100. @@ -1133,7 +1094,7 @@ void ieee80211_tx_status(struct ieee8021
  101. if (sta)
  102. status.sta = &sta->sta;
  103. - __ieee80211_tx_status(hw, &status);
  104. + ieee80211_tx_status_ext(hw, &status);
  105. rcu_read_unlock();
  106. }
  107. EXPORT_SYMBOL(ieee80211_tx_status);
  108. @@ -1146,7 +1107,7 @@ void ieee80211_tx_status_ext(struct ieee
  109. struct ieee80211_sta *pubsta = status->sta;
  110. struct ieee80211_supported_band *sband;
  111. struct sta_info *sta;
  112. - int retry_count;
  113. + int rates_idx, retry_count;
  114. bool acked, noack_success;
  115. if (pubsta) {
  116. @@ -1156,13 +1117,7 @@ void ieee80211_tx_status_ext(struct ieee
  117. sta->tx_stats.last_rate_info = *status->rate;
  118. }
  119. - if (status->skb)
  120. - return __ieee80211_tx_status(hw, status);
  121. -
  122. - if (!status->sta)
  123. - return;
  124. -
  125. - ieee80211_tx_get_rates(hw, info, &retry_count);
  126. + rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
  127. sband = hw->wiphy->bands[info->band];
  128. @@ -1174,20 +1129,30 @@ void ieee80211_tx_status_ext(struct ieee
  129. sta->status_stats.retry_failed++;
  130. sta->status_stats.retry_count += retry_count;
  131. - if (acked) {
  132. - sta->status_stats.last_ack = jiffies;
  133. + if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
  134. + if (acked) {
  135. + sta->status_stats.last_ack = jiffies;
  136. - if (sta->status_stats.lost_packets)
  137. - sta->status_stats.lost_packets = 0;
  138. + if (sta->status_stats.lost_packets)
  139. + sta->status_stats.lost_packets = 0;
  140. - /* Track when last packet was ACKed */
  141. - sta->status_stats.last_pkt_time = jiffies;
  142. - } else if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
  143. - return;
  144. - } else if (noack_success) {
  145. - /* nothing to do here, do not account as lost */
  146. - } else {
  147. - ieee80211_lost_packet(sta, info);
  148. + /* Track when last packet was ACKed */
  149. + sta->status_stats.last_pkt_time = jiffies;
  150. +
  151. + if (info->status.is_valid_ack_signal) {
  152. + sta->status_stats.last_ack_signal =
  153. + (s8)info->status.ack_signal;
  154. + sta->status_stats.ack_signal_filled = true;
  155. + ewma_avg_signal_add(&sta->status_stats.avg_ack_signal,
  156. + -info->status.ack_signal);
  157. + }
  158. + } else if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
  159. + return;
  160. + } else if (noack_success) {
  161. + /* nothing to do here, do not account as lost */
  162. + } else {
  163. + ieee80211_lost_packet(sta, info);
  164. + }
  165. }
  166. rate_control_tx_status(local, sband, status);
  167. @@ -1195,6 +1160,10 @@ void ieee80211_tx_status_ext(struct ieee
  168. ieee80211s_update_metric(local, sta, status);
  169. }
  170. + if (status->skb)
  171. + return __ieee80211_tx_status(hw, status, rates_idx,
  172. + retry_count);
  173. +
  174. if (acked || noack_success) {
  175. I802_DEBUG_INC(local->dot11TransmittedFrameCount);
  176. if (!pubsta)