Lines Matching refs:fq

14 static void fq_adjust_removal(struct fq *fq,  in fq_adjust_removal()  argument
23 fq->backlog--; in fq_adjust_removal()
24 fq->memory_usage -= skb->truesize; in fq_adjust_removal()
27 static void fq_rejigger_backlog(struct fq *fq, struct fq_flow *flow) in fq_rejigger_backlog() argument
36 list_for_each_entry_continue(i, &fq->backlogs, backlogchain) in fq_rejigger_backlog()
45 static struct sk_buff *fq_flow_dequeue(struct fq *fq, in fq_flow_dequeue() argument
50 lockdep_assert_held(&fq->lock); in fq_flow_dequeue()
56 fq_adjust_removal(fq, flow, skb); in fq_flow_dequeue()
57 fq_rejigger_backlog(fq, flow); in fq_flow_dequeue()
62 static struct sk_buff *fq_tin_dequeue(struct fq *fq, in fq_tin_dequeue() argument
70 lockdep_assert_held(&fq->lock); in fq_tin_dequeue()
83 flow->deficit += fq->quantum; in fq_tin_dequeue()
89 skb = dequeue_func(fq, tin, flow); in fq_tin_dequeue()
109 static u32 fq_flow_idx(struct fq *fq, struct sk_buff *skb) in fq_flow_idx() argument
113 return reciprocal_scale(hash, fq->flows_cnt); in fq_flow_idx()
116 static struct fq_flow *fq_flow_classify(struct fq *fq, in fq_flow_classify() argument
123 lockdep_assert_held(&fq->lock); in fq_flow_classify()
125 flow = &fq->flows[idx]; in fq_flow_classify()
127 flow = get_default_func(fq, tin, idx, skb); in fq_flow_classify()
129 fq->collisions++; in fq_flow_classify()
138 static void fq_recalc_backlog(struct fq *fq, in fq_recalc_backlog() argument
145 list_add_tail(&flow->backlogchain, &fq->backlogs); in fq_recalc_backlog()
148 list_for_each_entry_continue_reverse(i, &fq->backlogs, in fq_recalc_backlog()
156 static void fq_tin_enqueue(struct fq *fq, in fq_tin_enqueue() argument
165 lockdep_assert_held(&fq->lock); in fq_tin_enqueue()
167 flow = fq_flow_classify(fq, tin, idx, skb, get_default_func); in fq_tin_enqueue()
173 fq->memory_usage += skb->truesize; in fq_tin_enqueue()
174 fq->backlog++; in fq_tin_enqueue()
176 fq_recalc_backlog(fq, tin, flow); in fq_tin_enqueue()
179 flow->deficit = fq->quantum; in fq_tin_enqueue()
185 oom = (fq->memory_usage > fq->memory_limit); in fq_tin_enqueue()
186 while (fq->backlog > fq->limit || oom) { in fq_tin_enqueue()
187 flow = list_first_entry_or_null(&fq->backlogs, in fq_tin_enqueue()
193 skb = fq_flow_dequeue(fq, flow); in fq_tin_enqueue()
197 free_func(fq, flow->tin, flow, skb); in fq_tin_enqueue()
200 fq->overlimit++; in fq_tin_enqueue()
202 fq->overmemory++; in fq_tin_enqueue()
203 oom = (fq->memory_usage > fq->memory_limit); in fq_tin_enqueue()
208 static void fq_flow_filter(struct fq *fq, in fq_flow_filter() argument
217 lockdep_assert_held(&fq->lock); in fq_flow_filter()
220 if (!filter_func(fq, tin, flow, skb, filter_data)) in fq_flow_filter()
224 fq_adjust_removal(fq, flow, skb); in fq_flow_filter()
225 free_func(fq, tin, flow, skb); in fq_flow_filter()
228 fq_rejigger_backlog(fq, flow); in fq_flow_filter()
231 static void fq_tin_filter(struct fq *fq, in fq_tin_filter() argument
239 lockdep_assert_held(&fq->lock); in fq_tin_filter()
242 fq_flow_filter(fq, flow, filter_func, filter_data, free_func); in fq_tin_filter()
244 fq_flow_filter(fq, flow, filter_func, filter_data, free_func); in fq_tin_filter()
247 static void fq_flow_reset(struct fq *fq, in fq_flow_reset() argument
253 while ((skb = fq_flow_dequeue(fq, flow))) in fq_flow_reset()
254 free_func(fq, flow->tin, flow, skb); in fq_flow_reset()
267 static void fq_tin_reset(struct fq *fq, in fq_tin_reset() argument
283 fq_flow_reset(fq, flow, free_func); in fq_tin_reset()
303 static int fq_init(struct fq *fq, int flows_cnt) in fq_init() argument
307 memset(fq, 0, sizeof(fq[0])); in fq_init()
308 INIT_LIST_HEAD(&fq->backlogs); in fq_init()
309 spin_lock_init(&fq->lock); in fq_init()
310 fq->flows_cnt = max_t(u32, flows_cnt, 1); 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 = kvcalloc(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 kvfree(fq->flows); in fq_reset()
334 fq->flows = NULL; in fq_reset()