Lines Matching refs:f
130 static void fq_flow_set_detached(struct fq_flow *f) in fq_flow_set_detached() argument
132 f->next = &detached; in fq_flow_set_detached()
133 f->age = jiffies; in fq_flow_set_detached()
136 static bool fq_flow_is_detached(const struct fq_flow *f) in fq_flow_is_detached() argument
138 return f->next == &detached; in fq_flow_is_detached()
141 static bool fq_flow_is_throttled(const struct fq_flow *f) in fq_flow_is_throttled() argument
143 return f->next == &throttled; in fq_flow_is_throttled()
156 static void fq_flow_unset_throttled(struct fq_sched_data *q, struct fq_flow *f) in fq_flow_unset_throttled() argument
158 rb_erase(&f->rate_node, &q->delayed); in fq_flow_unset_throttled()
160 fq_flow_add_tail(&q->old_flows, f); in fq_flow_unset_throttled()
163 static void fq_flow_set_throttled(struct fq_sched_data *q, struct fq_flow *f) in fq_flow_set_throttled() argument
172 if (f->time_next_packet >= aux->time_next_packet) in fq_flow_set_throttled()
177 rb_link_node(&f->rate_node, parent, p); in fq_flow_set_throttled()
178 rb_insert_color(&f->rate_node, &q->delayed); in fq_flow_set_throttled()
182 f->next = &throttled; in fq_flow_set_throttled()
183 if (q->time_next_delayed_flow > f->time_next_packet) in fq_flow_set_throttled()
184 q->time_next_delayed_flow = f->time_next_packet; in fq_flow_set_throttled()
195 static bool fq_gc_candidate(const struct fq_flow *f) in fq_gc_candidate() argument
197 return fq_flow_is_detached(f) && in fq_gc_candidate()
198 time_after(jiffies, f->age + FQ_GC_AGE); in fq_gc_candidate()
205 struct fq_flow *f, *tofree[FQ_GC_MAX]; in fq_gc() local
214 f = rb_entry(parent, struct fq_flow, fq_node); in fq_gc()
215 if (f->sk == sk) in fq_gc()
218 if (fq_gc_candidate(f)) { in fq_gc()
219 tofree[fcnt++] = f; in fq_gc()
224 if (f->sk > sk) in fq_gc()
234 struct fq_flow *f = tofree[--fcnt]; in fq_gc() local
236 rb_erase(&f->fq_node, root); in fq_gc()
237 kmem_cache_free(fq_flow_cachep, f); in fq_gc()
246 struct fq_flow *f; in fq_classify() local
293 f = rb_entry(parent, struct fq_flow, fq_node); in fq_classify()
294 if (f->sk == sk) { in fq_classify()
301 f->socket_hash != sk->sk_hash)) { in fq_classify()
302 f->credit = q->initial_quantum; in fq_classify()
303 f->socket_hash = sk->sk_hash; in fq_classify()
307 if (fq_flow_is_throttled(f)) in fq_classify()
308 fq_flow_unset_throttled(q, f); in fq_classify()
309 f->time_next_packet = 0ULL; in fq_classify()
311 return f; in fq_classify()
313 if (f->sk > sk) in fq_classify()
319 f = kmem_cache_zalloc(fq_flow_cachep, GFP_ATOMIC | __GFP_NOWARN); in fq_classify()
320 if (unlikely(!f)) { in fq_classify()
326 fq_flow_set_detached(f); in fq_classify()
327 f->sk = sk; in fq_classify()
329 f->socket_hash = sk->sk_hash; in fq_classify()
334 f->credit = q->initial_quantum; in fq_classify()
336 rb_link_node(&f->fq_node, parent, p); in fq_classify()
337 rb_insert_color(&f->fq_node, root); in fq_classify()
341 return f; in fq_classify()
424 struct fq_flow *f; in fq_enqueue() local
429 f = fq_classify(skb, q); in fq_enqueue()
430 if (unlikely(f->qlen >= q->flow_plimit && f != &q->internal)) { in fq_enqueue()
435 f->qlen++; in fq_enqueue()
437 if (fq_flow_is_detached(f)) { in fq_enqueue()
438 fq_flow_add_tail(&q->new_flows, f); in fq_enqueue()
439 if (time_after(jiffies, f->age + q->flow_refill_delay)) in fq_enqueue()
440 f->credit = max_t(u32, f->credit, q->quantum); in fq_enqueue()
445 flow_queue_add(f, skb); in fq_enqueue()
447 if (unlikely(f == &q->internal)) { in fq_enqueue()
472 struct fq_flow *f = rb_entry(p, struct fq_flow, rate_node); in fq_check_throttled() local
474 if (f->time_next_packet > now) { in fq_check_throttled()
475 q->time_next_delayed_flow = f->time_next_packet; in fq_check_throttled()
478 fq_flow_unset_throttled(q, f); in fq_check_throttled()
487 struct fq_flow *f; in fq_dequeue() local
512 f = head->first; in fq_dequeue()
514 if (f->credit <= 0) { in fq_dequeue()
515 f->credit += q->quantum; in fq_dequeue()
516 head->first = f->next; in fq_dequeue()
517 fq_flow_add_tail(&q->old_flows, f); in fq_dequeue()
521 skb = fq_peek(f); in fq_dequeue()
524 f->time_next_packet); in fq_dequeue()
527 head->first = f->next; in fq_dequeue()
528 f->time_next_packet = time_next_packet; in fq_dequeue()
529 fq_flow_set_throttled(q, f); in fq_dequeue()
539 skb = fq_dequeue_head(sch, f); in fq_dequeue()
541 head->first = f->next; in fq_dequeue()
544 fq_flow_add_tail(&q->old_flows, f); in fq_dequeue()
546 fq_flow_set_detached(f); in fq_dequeue()
553 f->credit -= plen; in fq_dequeue()
569 f->credit = 0; in fq_dequeue()
572 if (f->credit > 0) in fq_dequeue()
593 if (f->time_next_packet) in fq_dequeue()
594 len -= min(len/2, now - f->time_next_packet); in fq_dequeue()
595 f->time_next_packet = now + len; in fq_dequeue()
623 struct fq_flow *f; in fq_reset() local
637 f = rb_entry(p, struct fq_flow, fq_node); in fq_reset()
640 fq_flow_purge(f); in fq_reset()
642 kmem_cache_free(fq_flow_cachep, f); in fq_reset()