Lines Matching +full:1 +full:q
38 #define SFB_NUMBUCKETS (1 << SFB_BUCKET_SHIFT) /* N bins per Level */
39 #define SFB_BUCKET_MASK (SFB_NUMBUCKETS - 1)
73 u8 slot; /* current active bins (0 or 1) */
127 static void increment_one_qlen(u32 sfbhash, u32 slot, struct sfb_sched_data *q) in increment_one_qlen() argument
130 struct sfb_bucket *b = &q->bins[slot].bins[0][0]; in increment_one_qlen()
142 static void increment_qlen(const struct sk_buff *skb, struct sfb_sched_data *q) in increment_qlen() argument
148 increment_one_qlen(sfbhash, 0, q); in increment_qlen()
150 sfbhash = sfb_hash(skb, 1); in increment_qlen()
152 increment_one_qlen(sfbhash, 1, q); in increment_qlen()
156 struct sfb_sched_data *q) in decrement_one_qlen() argument
159 struct sfb_bucket *b = &q->bins[slot].bins[0][0]; in decrement_one_qlen()
171 static void decrement_qlen(const struct sk_buff *skb, struct sfb_sched_data *q) in decrement_qlen() argument
177 decrement_one_qlen(sfbhash, 0, q); in decrement_qlen()
179 sfbhash = sfb_hash(skb, 1); in decrement_qlen()
181 decrement_one_qlen(sfbhash, 1, q); in decrement_qlen()
184 static void decrement_prob(struct sfb_bucket *b, struct sfb_sched_data *q) in decrement_prob() argument
186 b->p_mark = prob_minus(b->p_mark, q->decrement); in decrement_prob()
189 static void increment_prob(struct sfb_bucket *b, struct sfb_sched_data *q) in increment_prob() argument
191 b->p_mark = prob_plus(b->p_mark, q->increment); in increment_prob()
194 static void sfb_zero_all_buckets(struct sfb_sched_data *q) in sfb_zero_all_buckets() argument
196 memset(&q->bins, 0, sizeof(q->bins)); in sfb_zero_all_buckets()
202 static u32 sfb_compute_qlen(u32 *prob_r, u32 *avgpm_r, const struct sfb_sched_data *q) in sfb_compute_qlen() argument
206 const struct sfb_bucket *b = &q->bins[q->slot].bins[0][0]; in sfb_compute_qlen()
222 static void sfb_init_perturbation(u32 slot, struct sfb_sched_data *q) in sfb_init_perturbation() argument
224 get_random_bytes(&q->bins[slot].perturbation, in sfb_init_perturbation()
225 sizeof(q->bins[slot].perturbation)); in sfb_init_perturbation()
228 static void sfb_swap_slot(struct sfb_sched_data *q) in sfb_swap_slot() argument
230 sfb_init_perturbation(q->slot, q); in sfb_swap_slot()
231 q->slot ^= 1; in sfb_swap_slot()
232 q->double_buffering = false; in sfb_swap_slot()
238 static bool sfb_rate_limit(struct sk_buff *skb, struct sfb_sched_data *q) in sfb_rate_limit() argument
240 if (q->penalty_rate == 0 || q->penalty_burst == 0) in sfb_rate_limit()
243 if (q->tokens_avail < 1) { in sfb_rate_limit()
244 unsigned long age = min(10UL * HZ, jiffies - q->token_time); in sfb_rate_limit()
246 q->tokens_avail = (age * q->penalty_rate) / HZ; in sfb_rate_limit()
247 if (q->tokens_avail > q->penalty_burst) in sfb_rate_limit()
248 q->tokens_avail = q->penalty_burst; in sfb_rate_limit()
249 q->token_time = jiffies; in sfb_rate_limit()
250 if (q->tokens_avail < 1) in sfb_rate_limit()
254 q->tokens_avail--; in sfb_rate_limit()
287 struct sfb_sched_data *q = qdisc_priv(sch); in sfb_enqueue() local
288 struct Qdisc *child = q->qdisc; in sfb_enqueue()
294 u32 slot = q->slot; in sfb_enqueue()
297 if (unlikely(sch->q.qlen >= q->limit)) { in sfb_enqueue()
299 q->stats.queuedrop++; in sfb_enqueue()
303 if (q->rehash_interval > 0) { in sfb_enqueue()
304 unsigned long limit = q->rehash_time + q->rehash_interval; in sfb_enqueue()
307 sfb_swap_slot(q); in sfb_enqueue()
308 q->rehash_time = jiffies; in sfb_enqueue()
309 } else if (unlikely(!q->double_buffering && q->warmup_time > 0 && in sfb_enqueue()
310 time_after(jiffies, limit - q->warmup_time))) { in sfb_enqueue()
311 q->double_buffering = true; in sfb_enqueue()
315 fl = rcu_dereference_bh(q->filter_list); in sfb_enqueue()
322 sfbhash = siphash_1u32(salt, &q->bins[slot].perturbation); in sfb_enqueue()
324 sfbhash = skb_get_hash_perturb(skb, &q->bins[slot].perturbation); in sfb_enqueue()
329 sfbhash = 1; in sfb_enqueue()
334 struct sfb_bucket *b = &q->bins[slot].bins[i][hash]; in sfb_enqueue()
338 decrement_prob(b, q); in sfb_enqueue()
339 else if (b->qlen >= q->bin_size) in sfb_enqueue()
340 increment_prob(b, q); in sfb_enqueue()
347 slot ^= 1; in sfb_enqueue()
350 if (unlikely(minqlen >= q->max)) { in sfb_enqueue()
352 q->stats.bucketdrop++; in sfb_enqueue()
358 if (q->double_buffering) { in sfb_enqueue()
360 &q->bins[slot].perturbation); in sfb_enqueue()
362 sfbhash = 1; in sfb_enqueue()
367 struct sfb_bucket *b = &q->bins[slot].bins[i][hash]; in sfb_enqueue()
371 decrement_prob(b, q); in sfb_enqueue()
372 else if (b->qlen >= q->bin_size) in sfb_enqueue()
373 increment_prob(b, q); in sfb_enqueue()
376 if (sfb_rate_limit(skb, q)) { in sfb_enqueue()
378 q->stats.penaltydrop++; 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->q.qlen++; in sfb_enqueue()
410 increment_qlen(skb, q); in sfb_enqueue()
412 q->stats.childdrop++; in sfb_enqueue()
429 struct sfb_sched_data *q = qdisc_priv(sch); in sfb_dequeue() local
430 struct Qdisc *child = q->qdisc; in sfb_dequeue()
433 skb = child->dequeue(q->qdisc); in sfb_dequeue()
438 sch->q.qlen--; in sfb_dequeue()
439 decrement_qlen(skb, q); in sfb_dequeue()
447 struct sfb_sched_data *q = qdisc_priv(sch); in sfb_peek() local
448 struct Qdisc *child = q->qdisc; in sfb_peek()
457 struct sfb_sched_data *q = qdisc_priv(sch); in sfb_reset() local
459 qdisc_reset(q->qdisc); in sfb_reset()
461 sch->q.qlen = 0; in sfb_reset()
462 q->slot = 0; in sfb_reset()
463 q->double_buffering = false; in sfb_reset()
464 sfb_zero_all_buckets(q); in sfb_reset()
465 sfb_init_perturbation(0, q); in sfb_reset()
470 struct sfb_sched_data *q = qdisc_priv(sch); in sfb_destroy() local
472 tcf_block_put(q->block); in sfb_destroy()
473 qdisc_destroy(q->qdisc); in sfb_destroy()
476 static const struct nla_policy sfb_policy[TCA_SFB_MAX + 1] = {
495 struct sfb_sched_data *q = qdisc_priv(sch); in sfb_change() local
497 struct nlattr *tb[TCA_SFB_MAX + 1]; in sfb_change()
525 qdisc_tree_reduce_backlog(q->qdisc, q->qdisc->q.qlen, in sfb_change()
526 q->qdisc->qstats.backlog); in sfb_change()
527 qdisc_destroy(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()
545 sfb_zero_all_buckets(q); in sfb_change()
546 sfb_init_perturbation(0, q); in sfb_change()
547 sfb_init_perturbation(1, q); in sfb_change()
557 struct sfb_sched_data *q = qdisc_priv(sch); in sfb_init() local
560 err = tcf_block_get(&q->block, &q->filter_list, sch, extack); in sfb_init()
564 q->qdisc = &noop_qdisc; in sfb_init()
570 struct sfb_sched_data *q = qdisc_priv(sch); in sfb_dump() local
573 .rehash_interval = jiffies_to_msecs(q->rehash_interval), in sfb_dump()
574 .warmup_time = jiffies_to_msecs(q->warmup_time), in sfb_dump()
575 .limit = q->limit, in sfb_dump()
576 .max = q->max, in sfb_dump()
577 .bin_size = q->bin_size, in sfb_dump()
578 .increment = q->increment, in sfb_dump()
579 .decrement = q->decrement, in sfb_dump()
580 .penalty_rate = q->penalty_rate, in sfb_dump()
581 .penalty_burst = q->penalty_burst, in sfb_dump()
584 sch->qstats.backlog = q->qdisc->qstats.backlog; in sfb_dump()
599 struct sfb_sched_data *q = qdisc_priv(sch); in sfb_dump_stats() local
601 .earlydrop = q->stats.earlydrop, in sfb_dump_stats()
602 .penaltydrop = q->stats.penaltydrop, in sfb_dump_stats()
603 .bucketdrop = q->stats.bucketdrop, in sfb_dump_stats()
604 .queuedrop = q->stats.queuedrop, in sfb_dump_stats()
605 .childdrop = q->stats.childdrop, in sfb_dump_stats()
606 .marked = q->stats.marked, in sfb_dump_stats()
609 st.maxqlen = sfb_compute_qlen(&st.maxprob, &st.avgprob, q); in sfb_dump_stats()
623 struct sfb_sched_data *q = qdisc_priv(sch); in sfb_graft() local
628 *old = qdisc_replace(sch, new, &q->qdisc); in sfb_graft()
634 struct sfb_sched_data *q = qdisc_priv(sch); in sfb_leaf() local
636 return q->qdisc; in sfb_leaf()
641 return 1; in sfb_find()
664 if (walker->fn(sch, 1, walker) < 0) { in sfb_walk()
665 walker->stop = 1; in sfb_walk()
675 struct sfb_sched_data *q = qdisc_priv(sch); in sfb_tcf_block() local
679 return q->block; in sfb_tcf_block()