Lines Matching +full:elastic +full:- +full:limit

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (c) 2008-2011 Juliusz Chroboczek <jch@pps.jussieu.fr>
10 * U. Michigan CSE-TR-387-99, April 1999.
12 * http://www.thefengs.com/wuchang/blue/CSE-TR-387-99.pdf
35 #define SFB_BUCKET_MASK (SFB_NUMBUCKETS - 1)
62 u32 limit; /* HARD maximal queue length */ member
95 return (struct sfb_skb_cb *)qdisc_skb_cb(skb)->data; in sfb_skb_cb()
104 return sfb_skb_cb(skb)->hashes[slot]; in sfb_hash()
107 /* Probabilities are coded as Q0.16 fixed-point values,
120 return p1 > p2 ? p1 - p2 : 0; in prob_minus()
126 struct sfb_bucket *b = &q->bins[slot].bins[0][0]; in increment_one_qlen()
142 sfbhash = cb->hashes[0]; in increment_qlen()
146 sfbhash = cb->hashes[1]; in increment_qlen()
155 struct sfb_bucket *b = &q->bins[slot].bins[0][0]; in decrement_one_qlen()
162 b[hash].qlen--; in decrement_one_qlen()
182 b->p_mark = prob_minus(b->p_mark, q->decrement); in decrement_prob()
187 b->p_mark = prob_plus(b->p_mark, q->increment); in increment_prob()
192 memset(&q->bins, 0, sizeof(q->bins)); in sfb_zero_all_buckets()
202 const struct sfb_bucket *b = &q->bins[q->slot].bins[0][0]; in sfb_compute_qlen()
205 if (qlen < b->qlen) in sfb_compute_qlen()
206 qlen = b->qlen; in sfb_compute_qlen()
207 totalpm += b->p_mark; in sfb_compute_qlen()
208 if (prob < b->p_mark) in sfb_compute_qlen()
209 prob = b->p_mark; in sfb_compute_qlen()
220 get_random_bytes(&q->bins[slot].perturbation, in sfb_init_perturbation()
221 sizeof(q->bins[slot].perturbation)); in sfb_init_perturbation()
226 sfb_init_perturbation(q->slot, q); in sfb_swap_slot()
227 q->slot ^= 1; in sfb_swap_slot()
228 q->double_buffering = false; in sfb_swap_slot()
231 /* Non elastic flows are allowed to use part of the bandwidth, expressed
236 if (q->penalty_rate == 0 || q->penalty_burst == 0) in sfb_rate_limit()
239 if (q->tokens_avail < 1) { in sfb_rate_limit()
240 unsigned long age = min(10UL * HZ, jiffies - q->token_time); in sfb_rate_limit()
242 q->tokens_avail = (age * q->penalty_rate) / HZ; in sfb_rate_limit()
243 if (q->tokens_avail > q->penalty_burst) in sfb_rate_limit()
244 q->tokens_avail = q->penalty_burst; in sfb_rate_limit()
245 q->token_time = jiffies; in sfb_rate_limit()
246 if (q->tokens_avail < 1) in sfb_rate_limit()
250 q->tokens_avail--; in sfb_rate_limit()
285 struct Qdisc *child = q->qdisc; in sfb_enqueue()
292 u32 slot = q->slot; in sfb_enqueue()
295 if (unlikely(sch->q.qlen >= q->limit)) { in sfb_enqueue()
297 q->stats.queuedrop++; in sfb_enqueue()
301 if (q->rehash_interval > 0) { in sfb_enqueue()
302 unsigned long limit = q->rehash_time + q->rehash_interval; in sfb_enqueue() local
304 if (unlikely(time_after(jiffies, limit))) { in sfb_enqueue()
306 q->rehash_time = jiffies; in sfb_enqueue()
307 } else if (unlikely(!q->double_buffering && q->warmup_time > 0 && in sfb_enqueue()
308 time_after(jiffies, limit - q->warmup_time))) { in sfb_enqueue()
309 q->double_buffering = true; in sfb_enqueue()
313 fl = rcu_dereference_bh(q->filter_list); in sfb_enqueue()
320 sfbhash = siphash_1u32(salt, &q->bins[slot].perturbation); in sfb_enqueue()
322 sfbhash = skb_get_hash_perturb(skb, &q->bins[slot].perturbation); in sfb_enqueue()
328 sfb_skb_cb(skb)->hashes[slot] = sfbhash; in sfb_enqueue()
332 struct sfb_bucket *b = &q->bins[slot].bins[i][hash]; in sfb_enqueue()
335 if (b->qlen == 0) in sfb_enqueue()
337 else if (b->qlen >= q->bin_size) in sfb_enqueue()
339 if (minqlen > b->qlen) in sfb_enqueue()
340 minqlen = b->qlen; in sfb_enqueue()
341 if (p_min > b->p_mark) in sfb_enqueue()
342 p_min = b->p_mark; in sfb_enqueue()
346 sfb_skb_cb(skb)->hashes[slot] = 0; in sfb_enqueue()
348 if (unlikely(minqlen >= q->max)) { in sfb_enqueue()
350 q->stats.bucketdrop++; in sfb_enqueue()
356 if (q->double_buffering) { in sfb_enqueue()
358 &q->bins[slot].perturbation); in sfb_enqueue()
361 sfb_skb_cb(skb)->hashes[slot] = sfbhash; in sfb_enqueue()
365 struct sfb_bucket *b = &q->bins[slot].bins[i][hash]; in sfb_enqueue()
368 if (b->qlen == 0) in sfb_enqueue()
370 else if (b->qlen >= q->bin_size) in sfb_enqueue()
376 q->stats.penaltydrop++; in sfb_enqueue()
390 if (r < (p_min - SFB_MAX_PROB / 2) * 2) { in sfb_enqueue()
391 q->stats.earlydrop++; in sfb_enqueue()
396 q->stats.marked++; in sfb_enqueue()
398 q->stats.earlydrop++; in sfb_enqueue()
407 sch->qstats.backlog += len; in sfb_enqueue()
408 sch->q.qlen++; in sfb_enqueue()
411 q->stats.childdrop++; in sfb_enqueue()
429 struct Qdisc *child = q->qdisc; in sfb_dequeue()
432 skb = child->dequeue(q->qdisc); in sfb_dequeue()
437 sch->q.qlen--; in sfb_dequeue()
447 struct Qdisc *child = q->qdisc; in sfb_peek()
449 return child->ops->peek(child); in sfb_peek()
452 /* No sfb_drop -- impossible since the child doesn't return the dropped skb. */
458 if (likely(q->qdisc)) in sfb_reset()
459 qdisc_reset(q->qdisc); in sfb_reset()
460 q->slot = 0; in sfb_reset()
461 q->double_buffering = false; in sfb_reset()
470 tcf_block_put(q->block); in sfb_destroy()
471 qdisc_put(q->qdisc); in sfb_destroy()
481 .limit = 0,
497 u32 limit; in sfb_change() local
504 return -EINVAL; in sfb_change()
507 return -EINVAL; in sfb_change()
512 limit = ctl->limit; in sfb_change()
513 if (limit == 0) in sfb_change()
514 limit = qdisc_dev(sch)->tx_queue_len; in sfb_change()
516 child = fifo_create_dflt(sch, &pfifo_qdisc_ops, limit, extack); in sfb_change()
524 qdisc_purge_queue(q->qdisc); in sfb_change()
525 old = q->qdisc; in sfb_change()
526 q->qdisc = child; in sfb_change()
528 q->rehash_interval = msecs_to_jiffies(ctl->rehash_interval); in sfb_change()
529 q->warmup_time = msecs_to_jiffies(ctl->warmup_time); in sfb_change()
530 q->rehash_time = jiffies; in sfb_change()
531 q->limit = limit; in sfb_change()
532 q->increment = ctl->increment; in sfb_change()
533 q->decrement = ctl->decrement; in sfb_change()
534 q->max = ctl->max; in sfb_change()
535 q->bin_size = ctl->bin_size; in sfb_change()
536 q->penalty_rate = ctl->penalty_rate; in sfb_change()
537 q->penalty_burst = ctl->penalty_burst; in sfb_change()
538 q->tokens_avail = ctl->penalty_burst; in sfb_change()
539 q->token_time = jiffies; in sfb_change()
541 q->slot = 0; in sfb_change()
542 q->double_buffering = false; in sfb_change()
559 err = tcf_block_get(&q->block, &q->filter_list, sch, extack); in sfb_init()
563 q->qdisc = &noop_qdisc; in sfb_init()
572 .rehash_interval = jiffies_to_msecs(q->rehash_interval), in sfb_dump()
573 .warmup_time = jiffies_to_msecs(q->warmup_time), in sfb_dump()
574 .limit = q->limit, in sfb_dump()
575 .max = q->max, in sfb_dump()
576 .bin_size = q->bin_size, in sfb_dump()
577 .increment = q->increment, in sfb_dump()
578 .decrement = q->decrement, in sfb_dump()
579 .penalty_rate = q->penalty_rate, in sfb_dump()
580 .penalty_burst = q->penalty_burst, in sfb_dump()
583 sch->qstats.backlog = q->qdisc->qstats.backlog; in sfb_dump()
593 return -EMSGSIZE; in sfb_dump()
600 .earlydrop = q->stats.earlydrop, in sfb_dump_stats()
601 .penaltydrop = q->stats.penaltydrop, in sfb_dump_stats()
602 .bucketdrop = q->stats.bucketdrop, in sfb_dump_stats()
603 .queuedrop = q->stats.queuedrop, in sfb_dump_stats()
604 .childdrop = q->stats.childdrop, in sfb_dump_stats()
605 .marked = q->stats.marked, in sfb_dump_stats()
616 return -ENOSYS; in sfb_dump_class()
627 *old = qdisc_replace(sch, new, &q->qdisc); in sfb_graft()
635 return q->qdisc; in sfb_leaf()
651 return -ENOSYS; in sfb_change_class()
657 return -ENOSYS; in sfb_delete()
662 if (!walker->stop) { in sfb_walk()
674 return q->block; in sfb_tcf_block()