323-mac80211-unify-802.3-offload-and-802.11-tx-status-co.patch 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. From: Felix Fietkau <[email protected]>
  2. Date: Mon, 17 Aug 2020 13:54:19 +0200
  3. Subject: [PATCH] mac80211: unify 802.3 (offload) and 802.11 tx status
  4. codepath
  5. Make ieee80211_tx_status_8023 call ieee80211_tx_status_ext, similar to
  6. ieee80211_tx_status.
  7. Signed-off-by: Felix Fietkau <[email protected]>
  8. ---
  9. --- a/net/mac80211/status.c
  10. +++ b/net/mac80211/status.c
  11. @@ -901,7 +901,6 @@ static void __ieee80211_tx_status(struct
  12. struct ieee80211_bar *bar;
  13. int shift = 0;
  14. int tid = IEEE80211_NUM_TIDS;
  15. - u16 tx_time_est;
  16. sband = local->hw.wiphy->bands[info->band];
  17. fc = hdr->frame_control;
  18. @@ -994,17 +993,6 @@ static void __ieee80211_tx_status(struct
  19. ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS))
  20. ieee80211_sta_tx_notify(sta->sdata, (void *) skb->data,
  21. acked, info->status.tx_time);
  22. -
  23. - if ((tx_time_est = ieee80211_info_get_tx_time_est(info)) > 0) {
  24. - /* Do this here to avoid the expensive lookup of the sta
  25. - * in ieee80211_report_used_skb().
  26. - */
  27. - ieee80211_sta_update_pending_airtime(local, sta,
  28. - skb_get_queue_mapping(skb),
  29. - tx_time_est,
  30. - true);
  31. - ieee80211_info_set_tx_time_est(info, 0);
  32. - }
  33. }
  34. /* SNMP counters
  35. @@ -1100,9 +1088,11 @@ void ieee80211_tx_status_ext(struct ieee
  36. struct ieee80211_tx_info *info = status->info;
  37. struct ieee80211_sta *pubsta = status->sta;
  38. struct ieee80211_supported_band *sband;
  39. - struct sta_info *sta;
  40. + struct sk_buff *skb = status->skb;
  41. + struct sta_info *sta = NULL;
  42. int rates_idx, retry_count;
  43. bool acked, noack_success;
  44. + u16 tx_time_est;
  45. if (pubsta) {
  46. sta = container_of(pubsta, struct sta_info, sta);
  47. @@ -1154,7 +1144,18 @@ void ieee80211_tx_status_ext(struct ieee
  48. ieee80211s_update_metric(local, sta, status);
  49. }
  50. - if (status->skb)
  51. + if (skb && (tx_time_est = ieee80211_info_get_tx_time_est(info)) > 0) {
  52. + /* Do this here to avoid the expensive lookup of the sta
  53. + * in ieee80211_report_used_skb().
  54. + */
  55. + ieee80211_sta_update_pending_airtime(local, sta,
  56. + skb_get_queue_mapping(skb),
  57. + tx_time_est,
  58. + true);
  59. + ieee80211_info_set_tx_time_est(info, 0);
  60. + }
  61. +
  62. + if (skb && !(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP))
  63. return __ieee80211_tx_status(hw, status, rates_idx,
  64. retry_count);
  65. @@ -1169,6 +1170,12 @@ void ieee80211_tx_status_ext(struct ieee
  66. } else {
  67. I802_DEBUG_INC(local->dot11FailedCount);
  68. }
  69. +
  70. + if (!skb)
  71. + return;
  72. +
  73. + ieee80211_report_used_skb(local, skb, false);
  74. + dev_kfree_skb(skb);
  75. }
  76. EXPORT_SYMBOL(ieee80211_tx_status_ext);
  77. @@ -1195,66 +1202,23 @@ void ieee80211_tx_status_8023(struct iee
  78. struct ieee80211_vif *vif,
  79. struct sk_buff *skb)
  80. {
  81. - struct ieee80211_local *local = hw_to_local(hw);
  82. struct ieee80211_sub_if_data *sdata;
  83. - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  84. + struct ieee80211_tx_status status = {
  85. + .skb = skb,
  86. + .info = IEEE80211_SKB_CB(skb),
  87. + };
  88. struct sta_info *sta;
  89. - int retry_count;
  90. - int rates_idx;
  91. - bool acked;
  92. sdata = vif_to_sdata(vif);
  93. - acked = info->flags & IEEE80211_TX_STAT_ACK;
  94. - rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
  95. -
  96. rcu_read_lock();
  97. - if (ieee80211_lookup_ra_sta(sdata, skb, &sta))
  98. - goto counters_update;
  99. -
  100. - if (IS_ERR(sta))
  101. - goto counters_update;
  102. -
  103. - if (!acked)
  104. - sta->status_stats.retry_failed++;
  105. -
  106. - if (rates_idx != -1)
  107. - sta->tx_stats.last_rate = info->status.rates[rates_idx];
  108. -
  109. - sta->status_stats.retry_count += retry_count;
  110. -
  111. - if (ieee80211_hw_check(hw, REPORTS_TX_ACK_STATUS)) {
  112. - sta->status_stats.last_ack = jiffies;
  113. - if (info->flags & IEEE80211_TX_STAT_ACK) {
  114. - if (sta->status_stats.lost_packets)
  115. - sta->status_stats.lost_packets = 0;
  116. + if (!ieee80211_lookup_ra_sta(sdata, skb, &sta) && !IS_ERR(sta))
  117. + status.sta = &sta->sta;
  118. - sta->status_stats.last_pkt_time = jiffies;
  119. - } else {
  120. - ieee80211_lost_packet(sta, info);
  121. - }
  122. - }
  123. + ieee80211_tx_status_ext(hw, &status);
  124. -counters_update:
  125. rcu_read_unlock();
  126. - ieee80211_led_tx(local);
  127. -
  128. - if (!(info->flags & IEEE80211_TX_STAT_ACK) &&
  129. - !(info->flags & IEEE80211_TX_STAT_NOACK_TRANSMITTED))
  130. - goto skip_stats_update;
  131. -
  132. - I802_DEBUG_INC(local->dot11TransmittedFrameCount);
  133. - if (is_multicast_ether_addr(skb->data))
  134. - I802_DEBUG_INC(local->dot11MulticastTransmittedFrameCount);
  135. - if (retry_count > 0)
  136. - I802_DEBUG_INC(local->dot11RetryCount);
  137. - if (retry_count > 1)
  138. - I802_DEBUG_INC(local->dot11MultipleRetryCount);
  139. -
  140. -skip_stats_update:
  141. - ieee80211_report_used_skb(local, skb, false);
  142. - dev_kfree_skb(skb);
  143. }
  144. EXPORT_SYMBOL(ieee80211_tx_status_8023);