Lines Matching refs:fq

15 static void fq_adjust_removal(struct fq *fq,  in fq_adjust_removal()  argument
24 fq->backlog--; in fq_adjust_removal()
25 fq->memory_usage -= skb->truesize; in fq_adjust_removal()
28 static void fq_rejigger_backlog(struct fq *fq, struct fq_flow *flow) in fq_rejigger_backlog() argument
37 list_for_each_entry_continue(i, &fq->backlogs, backlogchain) in fq_rejigger_backlog()
46 static struct sk_buff *fq_flow_dequeue(struct fq *fq, in fq_flow_dequeue() argument
51 lockdep_assert_held(&fq->lock); in fq_flow_dequeue()
57 fq_adjust_removal(fq, flow, skb); in fq_flow_dequeue()
58 fq_rejigger_backlog(fq, flow); in fq_flow_dequeue()
63 static struct sk_buff *fq_tin_dequeue(struct fq *fq, in fq_tin_dequeue() argument
71 lockdep_assert_held(&fq->lock); in fq_tin_dequeue()
84 flow->deficit += fq->quantum; in fq_tin_dequeue()
90 skb = dequeue_func(fq, tin, flow); in fq_tin_dequeue()
110 static struct fq_flow *fq_flow_classify(struct fq *fq, in fq_flow_classify() argument
119 lockdep_assert_held(&fq->lock); in fq_flow_classify()
121 hash = skb_get_hash_perturb(skb, fq->perturbation); in fq_flow_classify()
122 idx = reciprocal_scale(hash, fq->flows_cnt); in fq_flow_classify()
123 flow = &fq->flows[idx]; in fq_flow_classify()
126 flow = get_default_func(fq, tin, idx, skb); in fq_flow_classify()
128 fq->collisions++; in fq_flow_classify()
137 static void fq_recalc_backlog(struct fq *fq, in fq_recalc_backlog() argument
144 list_add_tail(&flow->backlogchain, &fq->backlogs); in fq_recalc_backlog()
147 list_for_each_entry_continue_reverse(i, &fq->backlogs, in fq_recalc_backlog()
155 static void fq_tin_enqueue(struct fq *fq, in fq_tin_enqueue() argument
164 lockdep_assert_held(&fq->lock); in fq_tin_enqueue()
166 flow = fq_flow_classify(fq, tin, skb, get_default_func); in fq_tin_enqueue()
172 fq->memory_usage += skb->truesize; in fq_tin_enqueue()
173 fq->backlog++; in fq_tin_enqueue()
175 fq_recalc_backlog(fq, tin, flow); in fq_tin_enqueue()
178 flow->deficit = fq->quantum; in fq_tin_enqueue()
184 oom = (fq->memory_usage > fq->memory_limit); in fq_tin_enqueue()
185 while (fq->backlog > fq->limit || oom) { in fq_tin_enqueue()
186 flow = list_first_entry_or_null(&fq->backlogs, in fq_tin_enqueue()
192 skb = fq_flow_dequeue(fq, flow); in fq_tin_enqueue()
196 free_func(fq, flow->tin, flow, skb); in fq_tin_enqueue()
199 fq->overlimit++; in fq_tin_enqueue()
201 fq->overmemory++; in fq_tin_enqueue()
202 oom = (fq->memory_usage > fq->memory_limit); in fq_tin_enqueue()
207 static void fq_flow_filter(struct fq *fq, in fq_flow_filter() argument
216 lockdep_assert_held(&fq->lock); in fq_flow_filter()
219 if (!filter_func(fq, tin, flow, skb, filter_data)) in fq_flow_filter()
223 fq_adjust_removal(fq, flow, skb); in fq_flow_filter()
224 free_func(fq, tin, flow, skb); in fq_flow_filter()
227 fq_rejigger_backlog(fq, flow); in fq_flow_filter()
230 static void fq_tin_filter(struct fq *fq, in fq_tin_filter() argument
238 lockdep_assert_held(&fq->lock); in fq_tin_filter()
241 fq_flow_filter(fq, flow, filter_func, filter_data, free_func); in fq_tin_filter()
243 fq_flow_filter(fq, flow, filter_func, filter_data, free_func); in fq_tin_filter()
246 static void fq_flow_reset(struct fq *fq, in fq_flow_reset() argument
252 while ((skb = fq_flow_dequeue(fq, flow))) in fq_flow_reset()
253 free_func(fq, flow->tin, flow, skb); in fq_flow_reset()
266 static void fq_tin_reset(struct fq *fq, in fq_tin_reset() argument
282 fq_flow_reset(fq, flow, free_func); in fq_tin_reset()
302 static int fq_init(struct fq *fq, int flows_cnt) in fq_init() argument
306 memset(fq, 0, sizeof(fq[0])); in fq_init()
307 INIT_LIST_HEAD(&fq->backlogs); in fq_init()
308 spin_lock_init(&fq->lock); in fq_init()
309 fq->flows_cnt = max_t(u32, flows_cnt, 1); in fq_init()
310 fq->perturbation = prandom_u32(); in fq_init()
311 fq->quantum = 300; in fq_init()
312 fq->limit = 8192; in fq_init()
313 fq->memory_limit = 16 << 20; /* 16 MBytes */ in fq_init()
315 fq->flows = kcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL); in fq_init()
316 if (!fq->flows) in fq_init()
319 for (i = 0; i < fq->flows_cnt; i++) in fq_init()
320 fq_flow_init(&fq->flows[i]); in fq_init()
325 static void fq_reset(struct fq *fq, in fq_reset() argument
330 for (i = 0; i < fq->flows_cnt; i++) in fq_reset()
331 fq_flow_reset(fq, &fq->flows[i], free_func); in fq_reset()
333 kfree(fq->flows); in fq_reset()
334 fq->flows = NULL; in fq_reset()