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