375-mac80211-call-ieee80211_tx_h_rate_ctrl-when-dequeue.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. From: Ryder Lee <[email protected]>
  2. Date: Fri, 28 May 2021 14:05:41 +0800
  3. Subject: [PATCH] mac80211: call ieee80211_tx_h_rate_ctrl() when dequeue
  4. Make ieee80211_tx_h_rate_ctrl() get called on dequeue to improve
  5. performance since it reduces the turnaround time for rate control.
  6. Signed-off-by: Ryder Lee <[email protected]>
  7. ---
  8. --- a/net/mac80211/tx.c
  9. +++ b/net/mac80211/tx.c
  10. @@ -1768,8 +1768,6 @@ static int invoke_tx_handlers_early(stru
  11. CALL_TXH(ieee80211_tx_h_ps_buf);
  12. CALL_TXH(ieee80211_tx_h_check_control_port_protocol);
  13. CALL_TXH(ieee80211_tx_h_select_key);
  14. - if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL))
  15. - CALL_TXH(ieee80211_tx_h_rate_ctrl);
  16. txh_done:
  17. if (unlikely(res == TX_DROP)) {
  18. @@ -1802,6 +1800,9 @@ static int invoke_tx_handlers_late(struc
  19. goto txh_done;
  20. }
  21. + if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL))
  22. + CALL_TXH(ieee80211_tx_h_rate_ctrl);
  23. +
  24. CALL_TXH(ieee80211_tx_h_michael_mic_add);
  25. CALL_TXH(ieee80211_tx_h_sequence);
  26. CALL_TXH(ieee80211_tx_h_fragment);
  27. @@ -3391,15 +3392,21 @@ out:
  28. * Can be called while the sta lock is held. Anything that can cause packets to
  29. * be generated will cause deadlock!
  30. */
  31. -static void ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata,
  32. - struct sta_info *sta, u8 pn_offs,
  33. - struct ieee80211_key *key,
  34. - struct sk_buff *skb)
  35. +static ieee80211_tx_result
  36. +ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata,
  37. + struct sta_info *sta, u8 pn_offs,
  38. + struct ieee80211_key *key,
  39. + struct ieee80211_tx_data *tx)
  40. {
  41. + struct sk_buff *skb = tx->skb;
  42. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  43. struct ieee80211_hdr *hdr = (void *)skb->data;
  44. u8 tid = IEEE80211_NUM_TIDS;
  45. + if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL) &&
  46. + ieee80211_tx_h_rate_ctrl(tx) != TX_CONTINUE)
  47. + return TX_DROP;
  48. +
  49. if (key)
  50. info->control.hw_key = &key->conf;
  51. @@ -3448,6 +3455,8 @@ static void ieee80211_xmit_fast_finish(s
  52. break;
  53. }
  54. }
  55. +
  56. + return TX_CONTINUE;
  57. }
  58. static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
  59. @@ -3551,24 +3560,17 @@ static bool ieee80211_xmit_fast(struct i
  60. tx.sta = sta;
  61. tx.key = fast_tx->key;
  62. - if (!ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
  63. - tx.skb = skb;
  64. - r = ieee80211_tx_h_rate_ctrl(&tx);
  65. - skb = tx.skb;
  66. - tx.skb = NULL;
  67. -
  68. - if (r != TX_CONTINUE) {
  69. - if (r != TX_QUEUED)
  70. - kfree_skb(skb);
  71. - return true;
  72. - }
  73. - }
  74. -
  75. if (ieee80211_queue_skb(local, sdata, sta, skb))
  76. return true;
  77. - ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs,
  78. - fast_tx->key, skb);
  79. + tx.skb = skb;
  80. + r = ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs,
  81. + fast_tx->key, &tx);
  82. + tx.skb = NULL;
  83. + if (r == TX_DROP) {
  84. + kfree_skb(skb);
  85. + return true;
  86. + }
  87. if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  88. sdata = container_of(sdata->bss,
  89. @@ -3685,8 +3687,12 @@ begin:
  90. (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
  91. pn_offs = ieee80211_hdrlen(hdr->frame_control);
  92. - ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs,
  93. - tx.key, skb);
  94. + r = ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs,
  95. + tx.key, &tx);
  96. + if (r != TX_CONTINUE) {
  97. + ieee80211_free_txskb(&local->hw, skb);
  98. + goto begin;
  99. + }
  100. } else {
  101. if (invoke_tx_handlers_late(&tx))
  102. goto begin;