Lines Matching refs:f
144 static void fq_flow_set_detached(struct fq_flow *f) in fq_flow_set_detached() argument
146 f->age = jiffies | 1UL; in fq_flow_set_detached()
149 static bool fq_flow_is_detached(const struct fq_flow *f) in fq_flow_is_detached() argument
151 return !!(f->age & 1UL); in fq_flow_is_detached()
157 static bool fq_flow_is_throttled(const struct fq_flow *f) in fq_flow_is_throttled() argument
159 return f->next == &throttled; in fq_flow_is_throttled()
172 static void fq_flow_unset_throttled(struct fq_sched_data *q, struct fq_flow *f) in fq_flow_unset_throttled() argument
174 rb_erase(&f->rate_node, &q->delayed); in fq_flow_unset_throttled()
176 fq_flow_add_tail(&q->old_flows, f); in fq_flow_unset_throttled()
179 static void fq_flow_set_throttled(struct fq_sched_data *q, struct fq_flow *f) in fq_flow_set_throttled() argument
188 if (f->time_next_packet >= aux->time_next_packet) in fq_flow_set_throttled()
193 rb_link_node(&f->rate_node, parent, p); in fq_flow_set_throttled()
194 rb_insert_color(&f->rate_node, &q->delayed); in fq_flow_set_throttled()
198 f->next = &throttled; in fq_flow_set_throttled()
199 if (q->time_next_delayed_flow > f->time_next_packet) in fq_flow_set_throttled()
200 q->time_next_delayed_flow = f->time_next_packet; in fq_flow_set_throttled()
211 static bool fq_gc_candidate(const struct fq_flow *f) in fq_gc_candidate() argument
213 return fq_flow_is_detached(f) && in fq_gc_candidate()
214 time_after(jiffies, f->age + FQ_GC_AGE); in fq_gc_candidate()
223 struct fq_flow *f; in fq_gc() local
231 f = rb_entry(parent, struct fq_flow, fq_node); in fq_gc()
232 if (f->sk == sk) in fq_gc()
235 if (fq_gc_candidate(f)) { in fq_gc()
236 tofree[fcnt++] = f; in fq_gc()
241 if (f->sk > sk) in fq_gc()
251 f = tofree[--i]; in fq_gc()
252 rb_erase(&f->fq_node, root); in fq_gc()
266 struct fq_flow *f; in fq_classify() local
313 f = rb_entry(parent, struct fq_flow, fq_node); in fq_classify()
314 if (f->sk == sk) { in fq_classify()
321 f->socket_hash != sk->sk_hash)) { in fq_classify()
322 f->credit = q->initial_quantum; in fq_classify()
323 f->socket_hash = sk->sk_hash; in fq_classify()
327 if (fq_flow_is_throttled(f)) in fq_classify()
328 fq_flow_unset_throttled(q, f); in fq_classify()
329 f->time_next_packet = 0ULL; in fq_classify()
331 return f; in fq_classify()
333 if (f->sk > sk) in fq_classify()
339 f = kmem_cache_zalloc(fq_flow_cachep, GFP_ATOMIC | __GFP_NOWARN); in fq_classify()
340 if (unlikely(!f)) { in fq_classify()
346 fq_flow_set_detached(f); in fq_classify()
347 f->sk = sk; in fq_classify()
349 f->socket_hash = sk->sk_hash; in fq_classify()
354 f->credit = q->initial_quantum; in fq_classify()
356 rb_link_node(&f->fq_node, parent, p); in fq_classify()
357 rb_insert_color(&f->fq_node, root); in fq_classify()
361 return f; in fq_classify()
446 struct fq_flow *f; in fq_enqueue() local
473 f = fq_classify(skb, q); in fq_enqueue()
474 if (unlikely(f->qlen >= q->flow_plimit && f != &q->internal)) { in fq_enqueue()
479 f->qlen++; in fq_enqueue()
481 if (fq_flow_is_detached(f)) { in fq_enqueue()
482 fq_flow_add_tail(&q->new_flows, f); in fq_enqueue()
483 if (time_after(jiffies, f->age + q->flow_refill_delay)) in fq_enqueue()
484 f->credit = max_t(u32, f->credit, q->quantum); in fq_enqueue()
489 flow_queue_add(f, skb); in fq_enqueue()
491 if (unlikely(f == &q->internal)) { in fq_enqueue()
516 struct fq_flow *f = rb_entry(p, struct fq_flow, rate_node); in fq_check_throttled() local
518 if (f->time_next_packet > now) { in fq_check_throttled()
519 q->time_next_delayed_flow = f->time_next_packet; in fq_check_throttled()
522 fq_flow_unset_throttled(q, f); in fq_check_throttled()
531 struct fq_flow *f; in fq_dequeue() local
559 f = head->first; in fq_dequeue()
561 if (f->credit <= 0) { in fq_dequeue()
562 f->credit += q->quantum; in fq_dequeue()
563 head->first = f->next; in fq_dequeue()
564 fq_flow_add_tail(&q->old_flows, f); in fq_dequeue()
568 skb = fq_peek(f); in fq_dequeue()
571 f->time_next_packet); in fq_dequeue()
574 head->first = f->next; in fq_dequeue()
575 f->time_next_packet = time_next_packet; in fq_dequeue()
576 fq_flow_set_throttled(q, f); in fq_dequeue()
584 fq_dequeue_skb(sch, f, skb); in fq_dequeue()
586 head->first = f->next; in fq_dequeue()
589 fq_flow_add_tail(&q->old_flows, f); in fq_dequeue()
591 fq_flow_set_detached(f); in fq_dequeue()
597 f->credit -= plen; in fq_dequeue()
613 f->credit = 0; in fq_dequeue()
616 if (f->credit > 0) in fq_dequeue()
637 if (f->time_next_packet) in fq_dequeue()
638 len -= min(len/2, now - f->time_next_packet); in fq_dequeue()
639 f->time_next_packet = now + len; in fq_dequeue()
667 struct fq_flow *f; in fq_reset() local
681 f = rb_entry(p, struct fq_flow, fq_node); in fq_reset()
684 fq_flow_purge(f); in fq_reset()
686 kmem_cache_free(fq_flow_cachep, f); in fq_reset()