Lines Matching defs:fq
10 #include <net/fq.h>
14 static void fq_adjust_removal(struct fq *fq,
23 fq->backlog--;
24 fq->memory_usage -= skb->truesize;
27 static void fq_rejigger_backlog(struct fq *fq, struct fq_flow *flow)
36 list_for_each_entry_continue(i, &fq->backlogs, backlogchain)
45 static struct sk_buff *fq_flow_dequeue(struct fq *fq,
50 lockdep_assert_held(&fq->lock);
56 fq_adjust_removal(fq, flow, skb);
57 fq_rejigger_backlog(fq, flow);
62 static struct sk_buff *fq_tin_dequeue(struct fq *fq,
70 lockdep_assert_held(&fq->lock);
83 flow->deficit += fq->quantum;
89 skb = dequeue_func(fq, tin, flow);
109 static u32 fq_flow_idx(struct fq *fq, struct sk_buff *skb)
113 return reciprocal_scale(hash, fq->flows_cnt);
116 static struct fq_flow *fq_flow_classify(struct fq *fq,
123 lockdep_assert_held(&fq->lock);
125 flow = &fq->flows[idx];
127 flow = get_default_func(fq, tin, idx, skb);
129 fq->collisions++;
138 static void fq_recalc_backlog(struct fq *fq,
145 list_add_tail(&flow->backlogchain, &fq->backlogs);
148 list_for_each_entry_continue_reverse(i, &fq->backlogs,
156 static void fq_tin_enqueue(struct fq *fq,
165 lockdep_assert_held(&fq->lock);
167 flow = fq_flow_classify(fq, tin, idx, skb, get_default_func);
173 fq->memory_usage += skb->truesize;
174 fq->backlog++;
176 fq_recalc_backlog(fq, tin, flow);
179 flow->deficit = fq->quantum;
185 oom = (fq->memory_usage > fq->memory_limit);
186 while (fq->backlog > fq->limit || oom) {
187 flow = list_first_entry_or_null(&fq->backlogs,
193 skb = fq_flow_dequeue(fq, flow);
197 free_func(fq, flow->tin, flow, skb);
200 fq->overlimit++;
202 fq->overmemory++;
203 oom = (fq->memory_usage > fq->memory_limit);
208 static void fq_flow_filter(struct fq *fq,
217 lockdep_assert_held(&fq->lock);
220 if (!filter_func(fq, tin, flow, skb, filter_data))
224 fq_adjust_removal(fq, flow, skb);
225 free_func(fq, tin, flow, skb);
228 fq_rejigger_backlog(fq, flow);
231 static void fq_tin_filter(struct fq *fq,
239 lockdep_assert_held(&fq->lock);
242 fq_flow_filter(fq, flow, filter_func, filter_data, free_func);
244 fq_flow_filter(fq, flow, filter_func, filter_data, free_func);
247 static void fq_flow_reset(struct fq *fq,
253 while ((skb = fq_flow_dequeue(fq, flow)))
254 free_func(fq, flow->tin, flow, skb);
267 static void fq_tin_reset(struct fq *fq,
283 fq_flow_reset(fq, flow, free_func);
303 static int fq_init(struct fq *fq, int flows_cnt)
307 memset(fq, 0, sizeof(fq[0]));
308 INIT_LIST_HEAD(&fq->backlogs);
309 spin_lock_init(&fq->lock);
310 fq->flows_cnt = max_t(u32, flows_cnt, 1);
311 fq->quantum = 300;
312 fq->limit = 8192;
313 fq->memory_limit = 16 << 20; /* 16 MBytes */
315 fq->flows = kvcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL);
316 if (!fq->flows)
319 for (i = 0; i < fq->flows_cnt; i++)
320 fq_flow_init(&fq->flows[i]);
325 static void fq_reset(struct fq *fq,
330 for (i = 0; i < fq->flows_cnt; i++)
331 fq_flow_reset(fq, &fq->flows[i], free_func);
333 kvfree(fq->flows);
334 fq->flows = NULL;