Lines Matching +full:max +full:- +full:reason

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (c) 2008-2011 Juliusz Chroboczek <[email protected]>
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)
58 u32 max; 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()
196 * compute max qlen, max p_mark, and avg p_mark
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()
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()
283 enum skb_drop_reason reason = SKB_DROP_REASON_QDISC_OVERLIMIT; in sfb_enqueue() local
286 struct Qdisc *child = q->qdisc; in sfb_enqueue()
293 u32 slot = q->slot; in sfb_enqueue()
296 if (unlikely(sch->q.qlen >= q->limit)) { in sfb_enqueue()
298 q->stats.queuedrop++; in sfb_enqueue()
302 if (q->rehash_interval > 0) { in sfb_enqueue()
303 unsigned long limit = q->rehash_time + q->rehash_interval; in sfb_enqueue()
307 q->rehash_time = jiffies; in sfb_enqueue()
308 } else if (unlikely(!q->double_buffering && q->warmup_time > 0 && in sfb_enqueue()
309 time_after(jiffies, limit - q->warmup_time))) { in sfb_enqueue()
310 q->double_buffering = true; in sfb_enqueue()
314 fl = rcu_dereference_bh(q->filter_list); in sfb_enqueue()
321 sfbhash = siphash_1u32(salt, &q->bins[slot].perturbation); in sfb_enqueue()
323 sfbhash = skb_get_hash_perturb(skb, &q->bins[slot].perturbation); in sfb_enqueue()
329 sfb_skb_cb(skb)->hashes[slot] = sfbhash; in sfb_enqueue()
333 struct sfb_bucket *b = &q->bins[slot].bins[i][hash]; in sfb_enqueue()
336 if (b->qlen == 0) in sfb_enqueue()
338 else if (b->qlen >= q->bin_size) in sfb_enqueue()
340 if (minqlen > b->qlen) in sfb_enqueue()
341 minqlen = b->qlen; in sfb_enqueue()
342 if (p_min > b->p_mark) in sfb_enqueue()
343 p_min = b->p_mark; in sfb_enqueue()
347 sfb_skb_cb(skb)->hashes[slot] = 0; in sfb_enqueue()
349 if (unlikely(minqlen >= q->max)) { in sfb_enqueue()
351 q->stats.bucketdrop++; in sfb_enqueue()
357 if (q->double_buffering) { in sfb_enqueue()
359 &q->bins[slot].perturbation); in sfb_enqueue()
362 sfb_skb_cb(skb)->hashes[slot] = sfbhash; in sfb_enqueue()
366 struct sfb_bucket *b = &q->bins[slot].bins[i][hash]; in sfb_enqueue()
369 if (b->qlen == 0) in sfb_enqueue()
371 else if (b->qlen >= q->bin_size) in sfb_enqueue()
377 q->stats.penaltydrop++; in sfb_enqueue()
384 reason = SKB_DROP_REASON_QDISC_CONGESTED; in sfb_enqueue()
392 if (r < (p_min - SFB_MAX_PROB / 2) * 2) { in sfb_enqueue()
393 q->stats.earlydrop++; in sfb_enqueue()
398 q->stats.marked++; in sfb_enqueue()
400 q->stats.earlydrop++; in sfb_enqueue()
409 sch->qstats.backlog += len; in sfb_enqueue()
410 sch->q.qlen++; in sfb_enqueue()
413 q->stats.childdrop++; in sfb_enqueue()
419 qdisc_drop_reason(skb, sch, to_free, reason); in sfb_enqueue()
431 struct Qdisc *child = q->qdisc; in sfb_dequeue()
434 skb = child->dequeue(q->qdisc); in sfb_dequeue()
439 sch->q.qlen--; in sfb_dequeue()
449 struct Qdisc *child = q->qdisc; in sfb_peek()
451 return child->ops->peek(child); in sfb_peek()
454 /* No sfb_drop -- impossible since the child doesn't return the dropped skb. */
460 if (likely(q->qdisc)) in sfb_reset()
461 qdisc_reset(q->qdisc); in sfb_reset()
462 q->slot = 0; in sfb_reset()
463 q->double_buffering = false; in sfb_reset()
472 tcf_block_put(q->block); in sfb_destroy()
473 qdisc_put(q->qdisc); in sfb_destroy()
484 .max = 25,
506 return -EINVAL; in sfb_change()
509 return -EINVAL; in sfb_change()
514 limit = ctl->limit; in sfb_change()
516 limit = qdisc_dev(sch)->tx_queue_len; in sfb_change()
526 qdisc_purge_queue(q->qdisc); in sfb_change()
527 old = q->qdisc; in sfb_change()
528 q->qdisc = child; in sfb_change()
530 q->rehash_interval = msecs_to_jiffies(ctl->rehash_interval); in sfb_change()
531 q->warmup_time = msecs_to_jiffies(ctl->warmup_time); in sfb_change()
532 q->rehash_time = jiffies; in sfb_change()
533 q->limit = limit; in sfb_change()
534 q->increment = ctl->increment; in sfb_change()
535 q->decrement = ctl->decrement; in sfb_change()
536 q->max = ctl->max; in sfb_change()
537 q->bin_size = ctl->bin_size; in sfb_change()
538 q->penalty_rate = ctl->penalty_rate; in sfb_change()
539 q->penalty_burst = ctl->penalty_burst; in sfb_change()
540 q->tokens_avail = ctl->penalty_burst; in sfb_change()
541 q->token_time = jiffies; in sfb_change()
543 q->slot = 0; in sfb_change()
544 q->double_buffering = false; in sfb_change()
561 err = tcf_block_get(&q->block, &q->filter_list, sch, extack); in sfb_init()
565 q->qdisc = &noop_qdisc; in sfb_init()
574 .rehash_interval = jiffies_to_msecs(q->rehash_interval), in sfb_dump()
575 .warmup_time = jiffies_to_msecs(q->warmup_time), in sfb_dump()
576 .limit = q->limit, in sfb_dump()
577 .max = q->max, in sfb_dump()
578 .bin_size = q->bin_size, in sfb_dump()
579 .increment = q->increment, in sfb_dump()
580 .decrement = q->decrement, in sfb_dump()
581 .penalty_rate = q->penalty_rate, in sfb_dump()
582 .penalty_burst = q->penalty_burst, in sfb_dump()
585 sch->qstats.backlog = q->qdisc->qstats.backlog; in sfb_dump()
595 return -EMSGSIZE; in sfb_dump()
602 .earlydrop = q->stats.earlydrop, in sfb_dump_stats()
603 .penaltydrop = q->stats.penaltydrop, in sfb_dump_stats()
604 .bucketdrop = q->stats.bucketdrop, in sfb_dump_stats()
605 .queuedrop = q->stats.queuedrop, in sfb_dump_stats()
606 .childdrop = q->stats.childdrop, in sfb_dump_stats()
607 .marked = q->stats.marked, in sfb_dump_stats()
618 return -ENOSYS; in sfb_dump_class()
629 *old = qdisc_replace(sch, new, &q->qdisc); in sfb_graft()
637 return q->qdisc; in sfb_leaf()
653 return -ENOSYS; in sfb_change_class()
659 return -ENOSYS; in sfb_delete()
664 if (!walker->stop) { in sfb_walk()
676 return q->block; in sfb_tcf_block()