Lines Matching refs:q

152 static inline struct sfq_head *sfq_dep_head(struct sfq_sched_data *q, sfq_index val)  in sfq_dep_head()  argument
155 return &q->slots[val].dep; in sfq_dep_head()
156 return &q->dep[val - SFQ_MAX_FLOWS]; in sfq_dep_head()
173 static unsigned int sfq_hash(const struct sfq_sched_data *q, in sfq_hash() argument
181 (__force u32)keys->ports, q->perturbation); in sfq_hash()
182 return hash & (q->divisor - 1); in sfq_hash()
188 struct sfq_sched_data *q = qdisc_priv(sch); in sfq_classify() local
195 TC_H_MIN(skb->priority) <= q->divisor) in sfq_classify()
198 fl = rcu_dereference_bh(q->filter_list); in sfq_classify()
201 return sfq_hash(q, skb) + 1; in sfq_classify()
216 if (TC_H_MIN(res.classid) <= q->divisor) in sfq_classify()
225 static inline void sfq_link(struct sfq_sched_data *q, sfq_index x) in sfq_link() argument
228 struct sfq_slot *slot = &q->slots[x]; in sfq_link()
232 n = q->dep[qlen].next; in sfq_link()
237 q->dep[qlen].next = x; /* sfq_dep_head(q, p)->next = x */ in sfq_link()
238 sfq_dep_head(q, n)->prev = x; in sfq_link()
241 #define sfq_unlink(q, x, n, p) \ argument
243 n = q->slots[x].dep.next; \
244 p = q->slots[x].dep.prev; \
245 sfq_dep_head(q, p)->next = n; \
246 sfq_dep_head(q, n)->prev = p; \
250 static inline void sfq_dec(struct sfq_sched_data *q, sfq_index x) in sfq_dec() argument
255 sfq_unlink(q, x, n, p); in sfq_dec()
257 d = q->slots[x].qlen--; in sfq_dec()
258 if (n == p && q->cur_depth == d) in sfq_dec()
259 q->cur_depth--; in sfq_dec()
260 sfq_link(q, x); in sfq_dec()
263 static inline void sfq_inc(struct sfq_sched_data *q, sfq_index x) in sfq_inc() argument
268 sfq_unlink(q, x, n, p); in sfq_inc()
270 d = ++q->slots[x].qlen; in sfq_inc()
271 if (q->cur_depth < d) in sfq_inc()
272 q->cur_depth = d; in sfq_inc()
273 sfq_link(q, x); in sfq_inc()
317 struct sfq_sched_data *q = qdisc_priv(sch); in sfq_drop() local
318 sfq_index x, d = q->cur_depth; in sfq_drop()
325 x = q->dep[d].next; in sfq_drop()
326 slot = &q->slots[x]; in sfq_drop()
328 skb = q->headdrop ? slot_dequeue_head(slot) : slot_dequeue_tail(slot); in sfq_drop()
331 sfq_dec(q, x); in sfq_drop()
333 sch->q.qlen--; in sfq_drop()
341 x = q->tail->next; in sfq_drop()
342 slot = &q->slots[x]; in sfq_drop()
343 q->tail->next = slot->next; in sfq_drop()
344 q->ht[slot->hash] = SFQ_EMPTY_SLOT; in sfq_drop()
352 static int sfq_prob_mark(const struct sfq_sched_data *q) in sfq_prob_mark() argument
354 return q->flags & TC_RED_ECN; in sfq_prob_mark()
358 static int sfq_hard_mark(const struct sfq_sched_data *q) in sfq_hard_mark() argument
360 return (q->flags & (TC_RED_ECN | TC_RED_HARDDROP)) == TC_RED_ECN; in sfq_hard_mark()
363 static int sfq_headdrop(const struct sfq_sched_data *q) in sfq_headdrop() argument
365 return q->headdrop; in sfq_headdrop()
371 struct sfq_sched_data *q = qdisc_priv(sch); in sfq_enqueue() local
388 x = q->ht[hash]; in sfq_enqueue()
389 slot = &q->slots[x]; in sfq_enqueue()
391 x = q->dep[0].next; /* get a free slot */ in sfq_enqueue()
394 q->ht[hash] = x; in sfq_enqueue()
395 slot = &q->slots[x]; in sfq_enqueue()
401 if (q->red_parms) { in sfq_enqueue()
402 slot->vars.qavg = red_calc_qavg_no_idle_time(q->red_parms, in sfq_enqueue()
405 switch (red_action(q->red_parms, in sfq_enqueue()
413 if (sfq_prob_mark(q)) { in sfq_enqueue()
415 if (sfq_headdrop(q) && in sfq_enqueue()
417 q->stats.prob_mark_head++; in sfq_enqueue()
421 q->stats.prob_mark++; in sfq_enqueue()
425 q->stats.prob_drop++; in sfq_enqueue()
430 if (sfq_hard_mark(q)) { in sfq_enqueue()
432 if (sfq_headdrop(q) && in sfq_enqueue()
434 q->stats.forced_mark_head++; in sfq_enqueue()
438 q->stats.forced_mark++; in sfq_enqueue()
442 q->stats.forced_drop++; in sfq_enqueue()
447 if (slot->qlen >= q->maxdepth) { in sfq_enqueue()
449 if (!sfq_headdrop(q)) in sfq_enqueue()
467 sfq_inc(q, x); in sfq_enqueue()
469 if (q->tail == NULL) { /* It is the first flow */ in sfq_enqueue()
472 slot->next = q->tail->next; in sfq_enqueue()
473 q->tail->next = x; in sfq_enqueue()
479 q->tail = slot; in sfq_enqueue()
481 slot->allot = q->scaled_quantum; in sfq_enqueue()
483 if (++sch->q.qlen <= q->limit) in sfq_enqueue()
502 struct sfq_sched_data *q = qdisc_priv(sch); in sfq_dequeue() local
508 if (q->tail == NULL) in sfq_dequeue()
512 a = q->tail->next; in sfq_dequeue()
513 slot = &q->slots[a]; in sfq_dequeue()
515 q->tail = slot; in sfq_dequeue()
516 slot->allot += q->scaled_quantum; in sfq_dequeue()
520 sfq_dec(q, a); in sfq_dequeue()
522 sch->q.qlen--; in sfq_dequeue()
527 q->ht[slot->hash] = SFQ_EMPTY_SLOT; in sfq_dequeue()
530 q->tail = NULL; /* no more active slots */ in sfq_dequeue()
533 q->tail->next = next_a; in sfq_dequeue()
557 struct sfq_sched_data *q = qdisc_priv(sch); in sfq_rehash() local
566 for (i = 0; i < q->maxflows; i++) { in sfq_rehash()
567 slot = &q->slots[i]; in sfq_rehash()
572 sfq_dec(q, i); in sfq_rehash()
577 q->ht[slot->hash] = SFQ_EMPTY_SLOT; in sfq_rehash()
579 q->tail = NULL; in sfq_rehash()
582 unsigned int hash = sfq_hash(q, skb); in sfq_rehash()
583 sfq_index x = q->ht[hash]; in sfq_rehash()
585 slot = &q->slots[x]; in sfq_rehash()
587 x = q->dep[0].next; /* get a free slot */ in sfq_rehash()
595 q->ht[hash] = x; in sfq_rehash()
596 slot = &q->slots[x]; in sfq_rehash()
599 if (slot->qlen >= q->maxdepth) in sfq_rehash()
602 if (q->red_parms) in sfq_rehash()
603 slot->vars.qavg = red_calc_qavg(q->red_parms, in sfq_rehash()
607 sfq_inc(q, x); in sfq_rehash()
609 if (q->tail == NULL) { /* It is the first flow */ in sfq_rehash()
612 slot->next = q->tail->next; in sfq_rehash()
613 q->tail->next = x; in sfq_rehash()
615 q->tail = slot; in sfq_rehash()
616 slot->allot = q->scaled_quantum; in sfq_rehash()
619 sch->q.qlen -= dropped; in sfq_rehash()
626 struct sfq_sched_data *q = qdisc_priv(sch); in sfq_perturbation() local
630 q->perturbation = prandom_u32(); in sfq_perturbation()
631 if (!q->filter_list && q->tail) in sfq_perturbation()
635 if (q->perturb_period) in sfq_perturbation()
636 mod_timer(&q->perturb_timer, jiffies + q->perturb_period); in sfq_perturbation()
641 struct sfq_sched_data *q = qdisc_priv(sch); in sfq_change() local
661 q->quantum = ctl->quantum; in sfq_change()
662 q->scaled_quantum = SFQ_ALLOT_SIZE(q->quantum); in sfq_change()
664 q->perturb_period = ctl->perturb_period * HZ; in sfq_change()
666 q->maxflows = min_t(u32, ctl->flows, SFQ_MAX_FLOWS); in sfq_change()
668 q->divisor = ctl->divisor; in sfq_change()
669 q->maxflows = min_t(u32, q->maxflows, q->divisor); in sfq_change()
673 q->maxdepth = min_t(u32, ctl_v1->depth, SFQ_MAX_DEPTH); in sfq_change()
675 swap(q->red_parms, p); in sfq_change()
676 red_set_parms(q->red_parms, in sfq_change()
683 q->flags = ctl_v1->flags; in sfq_change()
684 q->headdrop = ctl_v1->headdrop; in sfq_change()
687 q->limit = min_t(u32, ctl->limit, q->maxdepth * q->maxflows); in sfq_change()
688 q->maxflows = min_t(u32, q->maxflows, q->limit); in sfq_change()
691 qlen = sch->q.qlen; in sfq_change()
692 while (sch->q.qlen > q->limit) in sfq_change()
694 qdisc_tree_decrease_qlen(sch, qlen - sch->q.qlen); in sfq_change()
696 del_timer(&q->perturb_timer); in sfq_change()
697 if (q->perturb_period) { in sfq_change()
698 mod_timer(&q->perturb_timer, jiffies + q->perturb_period); in sfq_change()
699 q->perturbation = prandom_u32(); in sfq_change()
722 struct sfq_sched_data *q = qdisc_priv(sch); in sfq_destroy() local
724 tcf_destroy_chain(&q->filter_list); in sfq_destroy()
725 q->perturb_period = 0; in sfq_destroy()
726 del_timer_sync(&q->perturb_timer); in sfq_destroy()
727 sfq_free(q->ht); in sfq_destroy()
728 sfq_free(q->slots); in sfq_destroy()
729 kfree(q->red_parms); in sfq_destroy()
734 struct sfq_sched_data *q = qdisc_priv(sch); in sfq_init() local
737 q->perturb_timer.function = sfq_perturbation; in sfq_init()
738 q->perturb_timer.data = (unsigned long)sch; in sfq_init()
739 init_timer_deferrable(&q->perturb_timer); in sfq_init()
742 q->dep[i].next = i + SFQ_MAX_FLOWS; in sfq_init()
743 q->dep[i].prev = i + SFQ_MAX_FLOWS; in sfq_init()
746 q->limit = SFQ_MAX_DEPTH; in sfq_init()
747 q->maxdepth = SFQ_MAX_DEPTH; in sfq_init()
748 q->cur_depth = 0; in sfq_init()
749 q->tail = NULL; in sfq_init()
750 q->divisor = SFQ_DEFAULT_HASH_DIVISOR; in sfq_init()
751 q->maxflows = SFQ_DEFAULT_FLOWS; in sfq_init()
752 q->quantum = psched_mtu(qdisc_dev(sch)); in sfq_init()
753 q->scaled_quantum = SFQ_ALLOT_SIZE(q->quantum); in sfq_init()
754 q->perturb_period = 0; in sfq_init()
755 q->perturbation = prandom_u32(); in sfq_init()
763 q->ht = sfq_alloc(sizeof(q->ht[0]) * q->divisor); in sfq_init()
764 q->slots = sfq_alloc(sizeof(q->slots[0]) * q->maxflows); in sfq_init()
765 if (!q->ht || !q->slots) { in sfq_init()
769 for (i = 0; i < q->divisor; i++) in sfq_init()
770 q->ht[i] = SFQ_EMPTY_SLOT; in sfq_init()
772 for (i = 0; i < q->maxflows; i++) { in sfq_init()
773 slot_queue_init(&q->slots[i]); in sfq_init()
774 sfq_link(q, i); in sfq_init()
776 if (q->limit >= 1) in sfq_init()
785 struct sfq_sched_data *q = qdisc_priv(sch); in sfq_dump() local
788 struct red_parms *p = q->red_parms; in sfq_dump()
791 opt.v0.quantum = q->quantum; in sfq_dump()
792 opt.v0.perturb_period = q->perturb_period / HZ; in sfq_dump()
793 opt.v0.limit = q->limit; in sfq_dump()
794 opt.v0.divisor = q->divisor; in sfq_dump()
795 opt.v0.flows = q->maxflows; in sfq_dump()
796 opt.depth = q->maxdepth; in sfq_dump()
797 opt.headdrop = q->headdrop; in sfq_dump()
807 memcpy(&opt.stats, &q->stats, sizeof(opt.stats)); in sfq_dump()
808 opt.flags = q->flags; in sfq_dump()
838 static void sfq_put(struct Qdisc *q, unsigned long cl) in sfq_put() argument
845 struct sfq_sched_data *q = qdisc_priv(sch); in sfq_find_tcf() local
849 return &q->filter_list; in sfq_find_tcf()
862 struct sfq_sched_data *q = qdisc_priv(sch); in sfq_dump_class_stats() local
863 sfq_index idx = q->ht[cl - 1]; in sfq_dump_class_stats()
868 const struct sfq_slot *slot = &q->slots[idx]; in sfq_dump_class_stats()
881 struct sfq_sched_data *q = qdisc_priv(sch); in sfq_walk() local
887 for (i = 0; i < q->divisor; i++) { in sfq_walk()
888 if (q->ht[i] == SFQ_EMPTY_SLOT || in sfq_walk()