Lines Matching refs:q
75 static unsigned int choke_len(const struct choke_sched_data *q) in choke_len() argument
77 return (q->tail - q->head) & q->tab_mask; in choke_len()
81 static int use_ecn(const struct choke_sched_data *q) in use_ecn() argument
83 return q->flags & TC_RED_ECN; in use_ecn()
87 static int use_harddrop(const struct choke_sched_data *q) in use_harddrop() argument
89 return q->flags & TC_RED_HARDDROP; in use_harddrop()
93 static void choke_zap_head_holes(struct choke_sched_data *q) in choke_zap_head_holes() argument
96 q->head = (q->head + 1) & q->tab_mask; in choke_zap_head_holes()
97 if (q->head == q->tail) in choke_zap_head_holes()
99 } while (q->tab[q->head] == NULL); in choke_zap_head_holes()
103 static void choke_zap_tail_holes(struct choke_sched_data *q) in choke_zap_tail_holes() argument
106 q->tail = (q->tail - 1) & q->tab_mask; in choke_zap_tail_holes()
107 if (q->head == q->tail) in choke_zap_tail_holes()
109 } while (q->tab[q->tail] == NULL); in choke_zap_tail_holes()
116 struct choke_sched_data *q = qdisc_priv(sch); in choke_drop_by_idx() local
117 struct sk_buff *skb = q->tab[idx]; in choke_drop_by_idx()
119 q->tab[idx] = NULL; in choke_drop_by_idx()
121 if (idx == q->head) in choke_drop_by_idx()
122 choke_zap_head_holes(q); in choke_drop_by_idx()
123 if (idx == q->tail) in choke_drop_by_idx()
124 choke_zap_tail_holes(q); in choke_drop_by_idx()
129 --sch->q.qlen; in choke_drop_by_idx()
179 static struct sk_buff *choke_peek_random(const struct choke_sched_data *q, in choke_peek_random() argument
186 *pidx = (q->head + get_random_u32_below(choke_len(q))) & q->tab_mask; in choke_peek_random()
187 skb = q->tab[*pidx]; in choke_peek_random()
192 return q->tab[*pidx = q->head]; in choke_peek_random()
199 static bool choke_match_random(const struct choke_sched_data *q, in choke_match_random() argument
205 if (q->head == q->tail) in choke_match_random()
208 oskb = choke_peek_random(q, pidx); in choke_match_random()
215 struct choke_sched_data *q = qdisc_priv(sch); in choke_enqueue() local
216 const struct red_parms *p = &q->parms; in choke_enqueue()
220 q->vars.qavg = red_calc_qavg(p, &q->vars, sch->q.qlen); in choke_enqueue()
221 if (red_is_idling(&q->vars)) in choke_enqueue()
222 red_end_of_idle_period(&q->vars); in choke_enqueue()
225 if (q->vars.qavg <= p->qth_min) in choke_enqueue()
226 q->vars.qcount = -1; in choke_enqueue()
231 if (choke_match_random(q, skb, &idx)) { in choke_enqueue()
232 q->stats.matched++; in choke_enqueue()
238 if (q->vars.qavg > p->qth_max) { in choke_enqueue()
239 q->vars.qcount = -1; in choke_enqueue()
242 if (use_harddrop(q) || !use_ecn(q) || in choke_enqueue()
244 q->stats.forced_drop++; in choke_enqueue()
248 q->stats.forced_mark++; in choke_enqueue()
249 } else if (++q->vars.qcount) { in choke_enqueue()
250 if (red_mark_probability(p, &q->vars, q->vars.qavg)) { in choke_enqueue()
251 q->vars.qcount = 0; in choke_enqueue()
252 q->vars.qR = red_random(p); in choke_enqueue()
255 if (!use_ecn(q) || !INET_ECN_set_ce(skb)) { in choke_enqueue()
256 q->stats.prob_drop++; in choke_enqueue()
260 q->stats.prob_mark++; in choke_enqueue()
263 q->vars.qR = red_random(p); in choke_enqueue()
267 if (sch->q.qlen < q->limit) { in choke_enqueue()
268 q->tab[q->tail] = skb; in choke_enqueue()
269 q->tail = (q->tail + 1) & q->tab_mask; in choke_enqueue()
270 ++sch->q.qlen; in choke_enqueue()
275 q->stats.pdrop++; in choke_enqueue()
285 struct choke_sched_data *q = qdisc_priv(sch); in choke_dequeue() local
288 if (q->head == q->tail) { in choke_dequeue()
289 if (!red_is_idling(&q->vars)) in choke_dequeue()
290 red_start_of_idle_period(&q->vars); in choke_dequeue()
294 skb = q->tab[q->head]; in choke_dequeue()
295 q->tab[q->head] = NULL; in choke_dequeue()
296 choke_zap_head_holes(q); in choke_dequeue()
297 --sch->q.qlen; in choke_dequeue()
306 struct choke_sched_data *q = qdisc_priv(sch); in choke_reset() local
308 while (q->head != q->tail) { in choke_reset()
309 struct sk_buff *skb = q->tab[q->head]; in choke_reset()
311 q->head = (q->head + 1) & q->tab_mask; in choke_reset()
317 if (q->tab) in choke_reset()
318 memset(q->tab, 0, (q->tab_mask + 1) * sizeof(struct sk_buff *)); in choke_reset()
319 q->head = q->tail = 0; in choke_reset()
320 red_restart(&q->vars); in choke_reset()
338 struct choke_sched_data *q = qdisc_priv(sch); in choke_change() local
370 if (mask != q->tab_mask) { in choke_change()
378 old = q->tab; in choke_change()
380 unsigned int oqlen = sch->q.qlen, tail = 0; in choke_change()
383 while (q->head != q->tail) { in choke_change()
384 struct sk_buff *skb = q->tab[q->head]; in choke_change()
386 q->head = (q->head + 1) & q->tab_mask; in choke_change()
395 --sch->q.qlen; in choke_change()
398 qdisc_tree_reduce_backlog(sch, oqlen - sch->q.qlen, dropped); in choke_change()
399 q->head = 0; in choke_change()
400 q->tail = tail; in choke_change()
403 q->tab_mask = mask; in choke_change()
404 q->tab = ntab; in choke_change()
408 q->flags = ctl->flags; in choke_change()
409 q->limit = ctl->limit; in choke_change()
411 red_set_parms(&q->parms, ctl->qth_min, ctl->qth_max, ctl->Wlog, in choke_change()
415 red_set_vars(&q->vars); in choke_change()
417 if (q->head == q->tail) in choke_change()
418 red_end_of_idle_period(&q->vars); in choke_change()
433 struct choke_sched_data *q = qdisc_priv(sch); in choke_dump() local
436 .limit = q->limit, in choke_dump()
437 .flags = q->flags, in choke_dump()
438 .qth_min = q->parms.qth_min >> q->parms.Wlog, in choke_dump()
439 .qth_max = q->parms.qth_max >> q->parms.Wlog, in choke_dump()
440 .Wlog = q->parms.Wlog, in choke_dump()
441 .Plog = q->parms.Plog, in choke_dump()
442 .Scell_log = q->parms.Scell_log, in choke_dump()
450 nla_put_u32(skb, TCA_CHOKE_MAX_P, q->parms.max_P)) in choke_dump()
461 struct choke_sched_data *q = qdisc_priv(sch); in choke_dump_stats() local
463 .early = q->stats.prob_drop + q->stats.forced_drop, in choke_dump_stats()
464 .marked = q->stats.prob_mark + q->stats.forced_mark, in choke_dump_stats()
465 .pdrop = q->stats.pdrop, in choke_dump_stats()
466 .matched = q->stats.matched, in choke_dump_stats()
474 struct choke_sched_data *q = qdisc_priv(sch); in choke_destroy() local
476 choke_free(q->tab); in choke_destroy()
481 struct choke_sched_data *q = qdisc_priv(sch); in choke_peek_head() local
483 return (q->head != q->tail) ? q->tab[q->head] : NULL; in choke_peek_head()