Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/fq_impl: drop get_default_func, move default flow to fq_tin

Simplifies the code and prepares for a rework of scanning for flows on
overmemory drop.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Link: https://lore.kernel.org/r/20201218184718.93650-2-nbd@nbd.name
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Felix Fietkau and committed by
Johannes Berg
bf9009bf 07be2fed

+10 -25
+1
include/net/fq.h
··· 47 47 struct fq_tin { 48 48 struct list_head new_flows; 49 49 struct list_head old_flows; 50 + struct fq_flow default_flow; 50 51 u32 backlog_bytes; 51 52 u32 backlog_packets; 52 53 u32 overlimit;
+5 -6
include/net/fq_impl.h
··· 151 151 152 152 static struct fq_flow *fq_flow_classify(struct fq *fq, 153 153 struct fq_tin *tin, u32 idx, 154 - struct sk_buff *skb, 155 - fq_flow_get_default_t get_default_func) 154 + struct sk_buff *skb) 156 155 { 157 156 struct fq_flow *flow; 158 157 ··· 159 160 160 161 flow = &fq->flows[idx]; 161 162 if (flow->tin && flow->tin != tin) { 162 - flow = get_default_func(fq, tin, idx, skb); 163 + flow = &tin->default_flow; 163 164 tin->collisions++; 164 165 fq->collisions++; 165 166 } ··· 191 192 static void fq_tin_enqueue(struct fq *fq, 192 193 struct fq_tin *tin, u32 idx, 193 194 struct sk_buff *skb, 194 - fq_skb_free_t free_func, 195 - fq_flow_get_default_t get_default_func) 195 + fq_skb_free_t free_func) 196 196 { 197 197 struct fq_flow *flow; 198 198 bool oom; 199 199 200 200 lockdep_assert_held(&fq->lock); 201 201 202 - flow = fq_flow_classify(fq, tin, idx, skb, get_default_func); 202 + flow = fq_flow_classify(fq, tin, idx, skb); 203 203 204 204 flow->tin = tin; 205 205 flow->backlog += skb->len; ··· 329 331 { 330 332 INIT_LIST_HEAD(&tin->new_flows); 331 333 INIT_LIST_HEAD(&tin->old_flows); 334 + fq_flow_init(&tin->default_flow); 332 335 } 333 336 334 337 static int fq_init(struct fq *fq, int flows_cnt)
-1
net/mac80211/ieee80211_i.h
··· 848 848 */ 849 849 struct txq_info { 850 850 struct fq_tin tin; 851 - struct fq_flow def_flow; 852 851 struct codel_vars def_cvars; 853 852 struct codel_stats cstats; 854 853 struct sk_buff_head frags;
+4 -18
net/mac80211/tx.c
··· 1309 1309 fq = &local->fq; 1310 1310 1311 1311 if (cvars == &txqi->def_cvars) 1312 - flow = &txqi->def_flow; 1312 + flow = &txqi->tin.default_flow; 1313 1313 else 1314 1314 flow = &fq->flows[cvars - local->cvars]; 1315 1315 ··· 1352 1352 cparams = &local->cparams; 1353 1353 } 1354 1354 1355 - if (flow == &txqi->def_flow) 1355 + if (flow == &tin->default_flow) 1356 1356 cvars = &txqi->def_cvars; 1357 1357 else 1358 1358 cvars = &local->cvars[flow - fq->flows]; ··· 1379 1379 ieee80211_free_txskb(&local->hw, skb); 1380 1380 } 1381 1381 1382 - static struct fq_flow *fq_flow_get_default_func(struct fq *fq, 1383 - struct fq_tin *tin, 1384 - int idx, 1385 - struct sk_buff *skb) 1386 - { 1387 - struct txq_info *txqi; 1388 - 1389 - txqi = container_of(tin, struct txq_info, tin); 1390 - return &txqi->def_flow; 1391 - } 1392 - 1393 1382 static void ieee80211_txq_enqueue(struct ieee80211_local *local, 1394 1383 struct txq_info *txqi, 1395 1384 struct sk_buff *skb) ··· 1391 1402 1392 1403 spin_lock_bh(&fq->lock); 1393 1404 fq_tin_enqueue(fq, tin, flow_idx, skb, 1394 - fq_skb_free_func, 1395 - fq_flow_get_default_func); 1405 + fq_skb_free_func); 1396 1406 spin_unlock_bh(&fq->lock); 1397 1407 } 1398 1408 ··· 1434 1446 struct txq_info *txqi, int tid) 1435 1447 { 1436 1448 fq_tin_init(&txqi->tin); 1437 - fq_flow_init(&txqi->def_flow); 1438 1449 codel_vars_init(&txqi->def_cvars); 1439 1450 codel_stats_init(&txqi->cstats); 1440 1451 __skb_queue_head_init(&txqi->frags); ··· 3270 3283 */ 3271 3284 3272 3285 tin = &txqi->tin; 3273 - flow = fq_flow_classify(fq, tin, flow_idx, skb, 3274 - fq_flow_get_default_func); 3286 + flow = fq_flow_classify(fq, tin, flow_idx, skb); 3275 3287 head = skb_peek_tail(&flow->queue); 3276 3288 if (!head || skb_is_gso(head)) 3277 3289 goto out;