311-net-fq_impl-drop-get_default_func-move-default-flow-.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. From: Felix Fietkau <[email protected]>
  2. Date: Wed, 25 Nov 2020 18:09:10 +0100
  3. Subject: [PATCH] net/fq_impl: drop get_default_func, move default flow to
  4. fq_tin
  5. Simplifies the code and prepares for a rework of scanning for flows on
  6. overmemory drop.
  7. Signed-off-by: Felix Fietkau <[email protected]>
  8. ---
  9. --- a/include/net/fq.h
  10. +++ b/include/net/fq.h
  11. @@ -47,6 +47,7 @@ struct fq_flow {
  12. struct fq_tin {
  13. struct list_head new_flows;
  14. struct list_head old_flows;
  15. + struct fq_flow default_flow;
  16. u32 backlog_bytes;
  17. u32 backlog_packets;
  18. u32 overlimit;
  19. --- a/include/net/fq_impl.h
  20. +++ b/include/net/fq_impl.h
  21. @@ -151,8 +151,7 @@ static u32 fq_flow_idx(struct fq *fq, st
  22. static struct fq_flow *fq_flow_classify(struct fq *fq,
  23. struct fq_tin *tin, u32 idx,
  24. - struct sk_buff *skb,
  25. - fq_flow_get_default_t get_default_func)
  26. + struct sk_buff *skb)
  27. {
  28. struct fq_flow *flow;
  29. @@ -160,7 +159,7 @@ static struct fq_flow *fq_flow_classify(
  30. flow = &fq->flows[idx];
  31. if (flow->tin && flow->tin != tin) {
  32. - flow = get_default_func(fq, tin, idx, skb);
  33. + flow = &tin->default_flow;
  34. tin->collisions++;
  35. fq->collisions++;
  36. }
  37. @@ -192,15 +191,14 @@ static void fq_recalc_backlog(struct fq
  38. static void fq_tin_enqueue(struct fq *fq,
  39. struct fq_tin *tin, u32 idx,
  40. struct sk_buff *skb,
  41. - fq_skb_free_t free_func,
  42. - fq_flow_get_default_t get_default_func)
  43. + fq_skb_free_t free_func)
  44. {
  45. struct fq_flow *flow;
  46. bool oom;
  47. lockdep_assert_held(&fq->lock);
  48. - flow = fq_flow_classify(fq, tin, idx, skb, get_default_func);
  49. + flow = fq_flow_classify(fq, tin, idx, skb);
  50. flow->tin = tin;
  51. flow->backlog += skb->len;
  52. @@ -331,6 +329,7 @@ static void fq_tin_init(struct fq_tin *t
  53. {
  54. INIT_LIST_HEAD(&tin->new_flows);
  55. INIT_LIST_HEAD(&tin->old_flows);
  56. + fq_flow_init(&tin->default_flow);
  57. }
  58. static int fq_init(struct fq *fq, int flows_cnt)
  59. --- a/net/mac80211/ieee80211_i.h
  60. +++ b/net/mac80211/ieee80211_i.h
  61. @@ -857,7 +857,6 @@ enum txq_info_flags {
  62. */
  63. struct txq_info {
  64. struct fq_tin tin;
  65. - struct fq_flow def_flow;
  66. struct codel_vars def_cvars;
  67. struct codel_stats cstats;
  68. struct sk_buff_head frags;
  69. --- a/net/mac80211/tx.c
  70. +++ b/net/mac80211/tx.c
  71. @@ -1322,7 +1322,7 @@ static struct sk_buff *codel_dequeue_fun
  72. fq = &local->fq;
  73. if (cvars == &txqi->def_cvars)
  74. - flow = &txqi->def_flow;
  75. + flow = &txqi->tin.default_flow;
  76. else
  77. flow = &fq->flows[cvars - local->cvars];
  78. @@ -1365,7 +1365,7 @@ static struct sk_buff *fq_tin_dequeue_fu
  79. cparams = &local->cparams;
  80. }
  81. - if (flow == &txqi->def_flow)
  82. + if (flow == &tin->default_flow)
  83. cvars = &txqi->def_cvars;
  84. else
  85. cvars = &local->cvars[flow - fq->flows];
  86. @@ -1392,17 +1392,6 @@ static void fq_skb_free_func(struct fq *
  87. ieee80211_free_txskb(&local->hw, skb);
  88. }
  89. -static struct fq_flow *fq_flow_get_default_func(struct fq *fq,
  90. - struct fq_tin *tin,
  91. - int idx,
  92. - struct sk_buff *skb)
  93. -{
  94. - struct txq_info *txqi;
  95. -
  96. - txqi = container_of(tin, struct txq_info, tin);
  97. - return &txqi->def_flow;
  98. -}
  99. -
  100. static void ieee80211_txq_enqueue(struct ieee80211_local *local,
  101. struct txq_info *txqi,
  102. struct sk_buff *skb)
  103. @@ -1415,8 +1404,7 @@ static void ieee80211_txq_enqueue(struct
  104. spin_lock_bh(&fq->lock);
  105. fq_tin_enqueue(fq, tin, flow_idx, skb,
  106. - fq_skb_free_func,
  107. - fq_flow_get_default_func);
  108. + fq_skb_free_func);
  109. spin_unlock_bh(&fq->lock);
  110. }
  111. @@ -1459,7 +1447,6 @@ void ieee80211_txq_init(struct ieee80211
  112. struct txq_info *txqi, int tid)
  113. {
  114. fq_tin_init(&txqi->tin);
  115. - fq_flow_init(&txqi->def_flow);
  116. codel_vars_init(&txqi->def_cvars);
  117. codel_stats_init(&txqi->cstats);
  118. __skb_queue_head_init(&txqi->frags);
  119. @@ -3310,8 +3297,7 @@ static bool ieee80211_amsdu_aggregate(st
  120. */
  121. tin = &txqi->tin;
  122. - flow = fq_flow_classify(fq, tin, flow_idx, skb,
  123. - fq_flow_get_default_func);
  124. + flow = fq_flow_classify(fq, tin, flow_idx, skb);
  125. head = skb_peek_tail(&flow->queue);
  126. if (!head || skb_is_gso(head))
  127. goto out;