.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2016 Qualcomm Atheros, Inc |
---|
3 | | - * |
---|
4 | | - * GPL v2 |
---|
5 | 4 | * |
---|
6 | 5 | * Based on net/sched/sch_fq_codel.c |
---|
7 | 6 | */ |
---|
.. | .. |
---|
107 | 106 | return skb; |
---|
108 | 107 | } |
---|
109 | 108 | |
---|
| 109 | +static u32 fq_flow_idx(struct fq *fq, struct sk_buff *skb) |
---|
| 110 | +{ |
---|
| 111 | + u32 hash = skb_get_hash(skb); |
---|
| 112 | + |
---|
| 113 | + return reciprocal_scale(hash, fq->flows_cnt); |
---|
| 114 | +} |
---|
| 115 | + |
---|
110 | 116 | static struct fq_flow *fq_flow_classify(struct fq *fq, |
---|
111 | | - struct fq_tin *tin, |
---|
| 117 | + struct fq_tin *tin, u32 idx, |
---|
112 | 118 | struct sk_buff *skb, |
---|
113 | 119 | fq_flow_get_default_t get_default_func) |
---|
114 | 120 | { |
---|
115 | 121 | struct fq_flow *flow; |
---|
116 | | - u32 hash; |
---|
117 | | - u32 idx; |
---|
118 | 122 | |
---|
119 | 123 | lockdep_assert_held(&fq->lock); |
---|
120 | 124 | |
---|
121 | | - hash = skb_get_hash_perturb(skb, &fq->perturbation); |
---|
122 | | - idx = reciprocal_scale(hash, fq->flows_cnt); |
---|
123 | 125 | flow = &fq->flows[idx]; |
---|
124 | | - |
---|
125 | 126 | if (flow->tin && flow->tin != tin) { |
---|
126 | 127 | flow = get_default_func(fq, tin, idx, skb); |
---|
127 | 128 | tin->collisions++; |
---|
.. | .. |
---|
153 | 154 | } |
---|
154 | 155 | |
---|
155 | 156 | static void fq_tin_enqueue(struct fq *fq, |
---|
156 | | - struct fq_tin *tin, |
---|
| 157 | + struct fq_tin *tin, u32 idx, |
---|
157 | 158 | struct sk_buff *skb, |
---|
158 | 159 | fq_skb_free_t free_func, |
---|
159 | 160 | fq_flow_get_default_t get_default_func) |
---|
.. | .. |
---|
163 | 164 | |
---|
164 | 165 | lockdep_assert_held(&fq->lock); |
---|
165 | 166 | |
---|
166 | | - flow = fq_flow_classify(fq, tin, skb, get_default_func); |
---|
| 167 | + flow = fq_flow_classify(fq, tin, idx, skb, get_default_func); |
---|
167 | 168 | |
---|
168 | 169 | flow->tin = tin; |
---|
169 | 170 | flow->backlog += skb->len; |
---|
.. | .. |
---|
307 | 308 | INIT_LIST_HEAD(&fq->backlogs); |
---|
308 | 309 | spin_lock_init(&fq->lock); |
---|
309 | 310 | fq->flows_cnt = max_t(u32, flows_cnt, 1); |
---|
310 | | - get_random_bytes(&fq->perturbation, sizeof(fq->perturbation)); |
---|
311 | 311 | fq->quantum = 300; |
---|
312 | 312 | fq->limit = 8192; |
---|
313 | 313 | fq->memory_limit = 16 << 20; /* 16 MBytes */ |
---|