• Home
  • Raw
  • Download

Lines Matching refs:cl

216 	struct htb_class *cl;  in htb_classify()  local
227 cl = htb_find(skb->priority, sch); in htb_classify()
228 if (cl) { in htb_classify()
229 if (cl->level == 0) in htb_classify()
230 return cl; in htb_classify()
232 tcf = rcu_dereference_bh(cl->filter_list); in htb_classify()
250 cl = (void *)res.class; in htb_classify()
251 if (!cl) { in htb_classify()
254 cl = htb_find(res.classid, sch); in htb_classify()
255 if (!cl) in htb_classify()
258 if (!cl->level) in htb_classify()
259 return cl; /* we hit leaf; return it */ in htb_classify()
262 tcf = rcu_dereference_bh(cl->filter_list); in htb_classify()
265 cl = htb_find(TC_H_MAKE(TC_H_MAJ(sch->handle), q->defcls), sch); in htb_classify()
266 if (!cl || cl->level) in htb_classify()
268 return cl; in htb_classify()
278 struct htb_class *cl, int prio) in htb_add_to_id_tree() argument
287 if (cl->common.classid > c->common.classid) in htb_add_to_id_tree()
292 rb_link_node(&cl->node[prio], parent, p); in htb_add_to_id_tree()
293 rb_insert_color(&cl->node[prio], root); in htb_add_to_id_tree()
304 struct htb_class *cl, s64 delay) in htb_add_to_wait_tree() argument
306 struct rb_node **p = &q->hlevel[cl->level].wait_pq.rb_node, *parent = NULL; in htb_add_to_wait_tree()
308 cl->pq_key = q->now + delay; in htb_add_to_wait_tree()
309 if (cl->pq_key == q->now) in htb_add_to_wait_tree()
310 cl->pq_key++; in htb_add_to_wait_tree()
313 if (q->near_ev_cache[cl->level] > cl->pq_key) in htb_add_to_wait_tree()
314 q->near_ev_cache[cl->level] = cl->pq_key; in htb_add_to_wait_tree()
320 if (cl->pq_key >= c->pq_key) in htb_add_to_wait_tree()
325 rb_link_node(&cl->pq_node, parent, p); in htb_add_to_wait_tree()
326 rb_insert_color(&cl->pq_node, &q->hlevel[cl->level].wait_pq); in htb_add_to_wait_tree()
347 struct htb_class *cl, int mask) in htb_add_class_to_row() argument
349 q->row_mask[cl->level] |= mask; in htb_add_class_to_row()
353 htb_add_to_id_tree(&q->hlevel[cl->level].hprio[prio].row, cl, prio); in htb_add_class_to_row()
376 struct htb_class *cl, int mask) in htb_remove_class_from_row() argument
379 struct htb_level *hlevel = &q->hlevel[cl->level]; in htb_remove_class_from_row()
386 if (hprio->ptr == cl->node + prio) in htb_remove_class_from_row()
389 htb_safe_rb_erase(cl->node + prio, &hprio->row); in htb_remove_class_from_row()
393 q->row_mask[cl->level] &= ~m; in htb_remove_class_from_row()
403 static void htb_activate_prios(struct htb_sched *q, struct htb_class *cl) in htb_activate_prios() argument
405 struct htb_class *p = cl->parent; in htb_activate_prios()
406 long m, mask = cl->prio_activity; in htb_activate_prios()
408 while (cl->cmode == HTB_MAY_BORROW && p && mask) { in htb_activate_prios()
420 htb_add_to_id_tree(&p->un.inner.clprio[prio].feed, cl, prio); in htb_activate_prios()
423 cl = p; in htb_activate_prios()
424 p = cl->parent; in htb_activate_prios()
427 if (cl->cmode == HTB_CAN_SEND && mask) in htb_activate_prios()
428 htb_add_class_to_row(q, cl, mask); in htb_activate_prios()
438 static void htb_deactivate_prios(struct htb_sched *q, struct htb_class *cl) in htb_deactivate_prios() argument
440 struct htb_class *p = cl->parent; in htb_deactivate_prios()
441 long m, mask = cl->prio_activity; in htb_deactivate_prios()
443 while (cl->cmode == HTB_MAY_BORROW && p && mask) { in htb_deactivate_prios()
450 if (p->un.inner.clprio[prio].ptr == cl->node + prio) { in htb_deactivate_prios()
455 p->un.inner.clprio[prio].last_ptr_id = cl->common.classid; in htb_deactivate_prios()
459 htb_safe_rb_erase(cl->node + prio, in htb_deactivate_prios()
467 cl = p; in htb_deactivate_prios()
468 p = cl->parent; in htb_deactivate_prios()
471 if (cl->cmode == HTB_CAN_SEND && mask) in htb_deactivate_prios()
472 htb_remove_class_from_row(q, cl, mask); in htb_deactivate_prios()
475 static inline s64 htb_lowater(const struct htb_class *cl) in htb_lowater() argument
478 return cl->cmode != HTB_CANT_SEND ? -cl->cbuffer : 0; in htb_lowater()
482 static inline s64 htb_hiwater(const struct htb_class *cl) in htb_hiwater() argument
485 return cl->cmode == HTB_CAN_SEND ? -cl->buffer : 0; in htb_hiwater()
503 htb_class_mode(struct htb_class *cl, s64 *diff) in htb_class_mode() argument
507 if ((toks = (cl->ctokens + *diff)) < htb_lowater(cl)) { in htb_class_mode()
512 if ((toks = (cl->tokens + *diff)) >= htb_hiwater(cl)) in htb_class_mode()
529 htb_change_class_mode(struct htb_sched *q, struct htb_class *cl, s64 *diff) in htb_change_class_mode() argument
531 enum htb_cmode new_mode = htb_class_mode(cl, diff); in htb_change_class_mode()
533 if (new_mode == cl->cmode) in htb_change_class_mode()
537 cl->overlimits++; in htb_change_class_mode()
539 if (cl->prio_activity) { /* not necessary: speed optimization */ in htb_change_class_mode()
540 if (cl->cmode != HTB_CANT_SEND) in htb_change_class_mode()
541 htb_deactivate_prios(q, cl); in htb_change_class_mode()
542 cl->cmode = new_mode; in htb_change_class_mode()
544 htb_activate_prios(q, cl); in htb_change_class_mode()
546 cl->cmode = new_mode; in htb_change_class_mode()
556 static inline void htb_activate(struct htb_sched *q, struct htb_class *cl) in htb_activate() argument
558 WARN_ON(cl->level || !cl->un.leaf.q || !cl->un.leaf.q->q.qlen); in htb_activate()
560 if (!cl->prio_activity) { in htb_activate()
561 cl->prio_activity = 1 << cl->prio; in htb_activate()
562 htb_activate_prios(q, cl); in htb_activate()
572 static inline void htb_deactivate(struct htb_sched *q, struct htb_class *cl) in htb_deactivate() argument
574 WARN_ON(!cl->prio_activity); in htb_deactivate()
576 htb_deactivate_prios(q, cl); in htb_deactivate()
577 cl->prio_activity = 0; in htb_deactivate()
601 struct htb_class *cl = htb_classify(skb, sch, &ret); in htb_enqueue() local
603 if (cl == HTB_DIRECT) { in htb_enqueue()
612 } else if (!cl) { in htb_enqueue()
618 } else if ((ret = qdisc_enqueue(skb, cl->un.leaf.q, in htb_enqueue()
622 cl->drops++; in htb_enqueue()
626 htb_activate(q, cl); in htb_enqueue()
634 static inline void htb_accnt_tokens(struct htb_class *cl, int bytes, s64 diff) in htb_accnt_tokens() argument
636 s64 toks = diff + cl->tokens; in htb_accnt_tokens()
638 if (toks > cl->buffer) in htb_accnt_tokens()
639 toks = cl->buffer; in htb_accnt_tokens()
640 toks -= (s64) psched_l2t_ns(&cl->rate, bytes); in htb_accnt_tokens()
641 if (toks <= -cl->mbuffer) in htb_accnt_tokens()
642 toks = 1 - cl->mbuffer; in htb_accnt_tokens()
644 cl->tokens = toks; in htb_accnt_tokens()
647 static inline void htb_accnt_ctokens(struct htb_class *cl, int bytes, s64 diff) in htb_accnt_ctokens() argument
649 s64 toks = diff + cl->ctokens; in htb_accnt_ctokens()
651 if (toks > cl->cbuffer) in htb_accnt_ctokens()
652 toks = cl->cbuffer; in htb_accnt_ctokens()
653 toks -= (s64) psched_l2t_ns(&cl->ceil, bytes); in htb_accnt_ctokens()
654 if (toks <= -cl->mbuffer) in htb_accnt_ctokens()
655 toks = 1 - cl->mbuffer; in htb_accnt_ctokens()
657 cl->ctokens = toks; in htb_accnt_ctokens()
671 static void htb_charge_class(struct htb_sched *q, struct htb_class *cl, in htb_charge_class() argument
678 while (cl) { in htb_charge_class()
679 diff = min_t(s64, q->now - cl->t_c, cl->mbuffer); in htb_charge_class()
680 if (cl->level >= level) { in htb_charge_class()
681 if (cl->level == level) in htb_charge_class()
682 cl->xstats.lends++; in htb_charge_class()
683 htb_accnt_tokens(cl, bytes, diff); in htb_charge_class()
685 cl->xstats.borrows++; in htb_charge_class()
686 cl->tokens += diff; /* we moved t_c; update tokens */ in htb_charge_class()
688 htb_accnt_ctokens(cl, bytes, diff); in htb_charge_class()
689 cl->t_c = q->now; in htb_charge_class()
691 old_mode = cl->cmode; in htb_charge_class()
693 htb_change_class_mode(q, cl, &diff); in htb_charge_class()
694 if (old_mode != cl->cmode) { in htb_charge_class()
696 htb_safe_rb_erase(&cl->pq_node, &q->hlevel[cl->level].wait_pq); in htb_charge_class()
697 if (cl->cmode != HTB_CAN_SEND) in htb_charge_class()
698 htb_add_to_wait_tree(q, cl, diff); in htb_charge_class()
702 if (cl->level) in htb_charge_class()
703 bstats_update(&cl->bstats, skb); in htb_charge_class()
705 cl = cl->parent; in htb_charge_class()
727 struct htb_class *cl; in htb_do_events() local
734 cl = rb_entry(p, struct htb_class, pq_node); in htb_do_events()
735 if (cl->pq_key > q->now) in htb_do_events()
736 return cl->pq_key; in htb_do_events()
739 diff = min_t(s64, q->now - cl->t_c, cl->mbuffer); in htb_do_events()
740 htb_change_class_mode(q, cl, &diff); in htb_do_events()
741 if (cl->cmode != HTB_CAN_SEND) in htb_do_events()
742 htb_add_to_wait_tree(q, cl, diff); in htb_do_events()
762 struct htb_class *cl = in htb_id_find_next_upper() local
765 if (id > cl->common.classid) { in htb_id_find_next_upper()
767 } else if (id < cl->common.classid) { in htb_id_find_next_upper()
820 struct htb_class *cl; in htb_lookup_leaf() local
823 cl = rb_entry(*sp->pptr, struct htb_class, node[prio]); in htb_lookup_leaf()
824 if (!cl->level) in htb_lookup_leaf()
825 return cl; in htb_lookup_leaf()
826 clp = &cl->un.inner.clprio[prio]; in htb_lookup_leaf()
843 struct htb_class *cl, *start; in htb_dequeue_tree() local
848 start = cl = htb_lookup_leaf(hprio, prio); in htb_dequeue_tree()
852 if (unlikely(!cl)) in htb_dequeue_tree()
860 if (unlikely(cl->un.leaf.q->q.qlen == 0)) { in htb_dequeue_tree()
862 htb_deactivate(q, cl); in htb_dequeue_tree()
870 if (cl == start) /* fix start if we just deleted it */ in htb_dequeue_tree()
872 cl = next; in htb_dequeue_tree()
876 skb = cl->un.leaf.q->dequeue(cl->un.leaf.q); in htb_dequeue_tree()
880 qdisc_warn_nonwc("htb", cl->un.leaf.q); in htb_dequeue_tree()
881 htb_next_rb_node(level ? &cl->parent->un.inner.clprio[prio].ptr: in htb_dequeue_tree()
883 cl = htb_lookup_leaf(hprio, prio); in htb_dequeue_tree()
885 } while (cl != start); in htb_dequeue_tree()
888 bstats_update(&cl->bstats, skb); in htb_dequeue_tree()
889 cl->un.leaf.deficit[level] -= qdisc_pkt_len(skb); in htb_dequeue_tree()
890 if (cl->un.leaf.deficit[level] < 0) { in htb_dequeue_tree()
891 cl->un.leaf.deficit[level] += cl->quantum; in htb_dequeue_tree()
892 htb_next_rb_node(level ? &cl->parent->un.inner.clprio[prio].ptr : in htb_dequeue_tree()
898 if (!cl->un.leaf.q->q.qlen) in htb_dequeue_tree()
899 htb_deactivate(q, cl); in htb_dequeue_tree()
900 htb_charge_class(q, cl, level, skb); in htb_dequeue_tree()
969 struct htb_class *cl; in htb_reset() local
973 hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) { in htb_reset()
974 if (cl->level) in htb_reset()
975 memset(&cl->un.inner, 0, sizeof(cl->un.inner)); in htb_reset()
977 if (cl->un.leaf.q) in htb_reset()
978 qdisc_reset(cl->un.leaf.q); in htb_reset()
980 cl->prio_activity = 0; in htb_reset()
981 cl->cmode = HTB_CAN_SEND; in htb_reset()
1092 struct htb_class *cl = (struct htb_class *)arg; in htb_dump_class() local
1099 tcm->tcm_parent = cl->parent ? cl->parent->common.classid : TC_H_ROOT; in htb_dump_class()
1100 tcm->tcm_handle = cl->common.classid; in htb_dump_class()
1101 if (!cl->level && cl->un.leaf.q) in htb_dump_class()
1102 tcm->tcm_info = cl->un.leaf.q->handle; in htb_dump_class()
1110 psched_ratecfg_getrate(&opt.rate, &cl->rate); in htb_dump_class()
1111 opt.buffer = PSCHED_NS2TICKS(cl->buffer); in htb_dump_class()
1112 psched_ratecfg_getrate(&opt.ceil, &cl->ceil); in htb_dump_class()
1113 opt.cbuffer = PSCHED_NS2TICKS(cl->cbuffer); in htb_dump_class()
1114 opt.quantum = cl->quantum; in htb_dump_class()
1115 opt.prio = cl->prio; in htb_dump_class()
1116 opt.level = cl->level; in htb_dump_class()
1119 if ((cl->rate.rate_bytes_ps >= (1ULL << 32)) && in htb_dump_class()
1120 nla_put_u64_64bit(skb, TCA_HTB_RATE64, cl->rate.rate_bytes_ps, in htb_dump_class()
1123 if ((cl->ceil.rate_bytes_ps >= (1ULL << 32)) && in htb_dump_class()
1124 nla_put_u64_64bit(skb, TCA_HTB_CEIL64, cl->ceil.rate_bytes_ps, in htb_dump_class()
1138 struct htb_class *cl = (struct htb_class *)arg; in htb_dump_class_stats() local
1140 .drops = cl->drops, in htb_dump_class_stats()
1141 .overlimits = cl->overlimits, in htb_dump_class_stats()
1145 if (!cl->level && cl->un.leaf.q) { in htb_dump_class_stats()
1146 qlen = cl->un.leaf.q->q.qlen; in htb_dump_class_stats()
1147 qs.backlog = cl->un.leaf.q->qstats.backlog; in htb_dump_class_stats()
1149 cl->xstats.tokens = clamp_t(s64, PSCHED_NS2TICKS(cl->tokens), in htb_dump_class_stats()
1151 cl->xstats.ctokens = clamp_t(s64, PSCHED_NS2TICKS(cl->ctokens), in htb_dump_class_stats()
1155 d, NULL, &cl->bstats) < 0 || in htb_dump_class_stats()
1156 gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 || in htb_dump_class_stats()
1160 return gnet_stats_copy_app(d, &cl->xstats, sizeof(cl->xstats)); in htb_dump_class_stats()
1166 struct htb_class *cl = (struct htb_class *)arg; in htb_graft() local
1168 if (cl->level) in htb_graft()
1172 cl->common.classid, extack)) == NULL) in htb_graft()
1175 *old = qdisc_replace(sch, new, &cl->un.leaf.q); in htb_graft()
1181 struct htb_class *cl = (struct htb_class *)arg; in htb_leaf() local
1182 return !cl->level ? cl->un.leaf.q : NULL; in htb_leaf()
1187 struct htb_class *cl = (struct htb_class *)arg; in htb_qlen_notify() local
1189 htb_deactivate(qdisc_priv(sch), cl); in htb_qlen_notify()
1192 static inline int htb_parent_last_child(struct htb_class *cl) in htb_parent_last_child() argument
1194 if (!cl->parent) in htb_parent_last_child()
1197 if (cl->parent->children > 1) in htb_parent_last_child()
1203 static void htb_parent_to_leaf(struct htb_sched *q, struct htb_class *cl, in htb_parent_to_leaf() argument
1206 struct htb_class *parent = cl->parent; in htb_parent_to_leaf()
1208 WARN_ON(cl->level || !cl->un.leaf.q || cl->prio_activity); in htb_parent_to_leaf()
1223 static void htb_destroy_class(struct Qdisc *sch, struct htb_class *cl) in htb_destroy_class() argument
1225 if (!cl->level) { in htb_destroy_class()
1226 WARN_ON(!cl->un.leaf.q); in htb_destroy_class()
1227 qdisc_destroy(cl->un.leaf.q); in htb_destroy_class()
1229 gen_kill_estimator(&cl->rate_est); in htb_destroy_class()
1230 tcf_block_put(cl->block); in htb_destroy_class()
1231 kfree(cl); in htb_destroy_class()
1238 struct htb_class *cl; in htb_destroy() local
1251 hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) { in htb_destroy()
1252 tcf_block_put(cl->block); in htb_destroy()
1253 cl->block = NULL; in htb_destroy()
1257 hlist_for_each_entry_safe(cl, next, &q->clhash.hash[i], in htb_destroy()
1259 htb_destroy_class(sch, cl); in htb_destroy()
1268 struct htb_class *cl = (struct htb_class *)arg; in htb_delete() local
1276 if (cl->children || cl->filter_cnt) in htb_delete()
1279 if (!cl->level && htb_parent_last_child(cl)) { in htb_delete()
1281 cl->parent->common.classid, in htb_delete()
1288 if (!cl->level) { in htb_delete()
1289 unsigned int qlen = cl->un.leaf.q->q.qlen; in htb_delete()
1290 unsigned int backlog = cl->un.leaf.q->qstats.backlog; in htb_delete()
1292 qdisc_reset(cl->un.leaf.q); in htb_delete()
1293 qdisc_tree_reduce_backlog(cl->un.leaf.q, qlen, backlog); in htb_delete()
1297 qdisc_class_hash_remove(&q->clhash, &cl->common); in htb_delete()
1298 if (cl->parent) in htb_delete()
1299 cl->parent->children--; in htb_delete()
1301 if (cl->prio_activity) in htb_delete()
1302 htb_deactivate(q, cl); in htb_delete()
1304 if (cl->cmode != HTB_CAN_SEND) in htb_delete()
1305 htb_safe_rb_erase(&cl->pq_node, in htb_delete()
1306 &q->hlevel[cl->level].wait_pq); in htb_delete()
1309 htb_parent_to_leaf(q, cl, new_q); in htb_delete()
1313 htb_destroy_class(sch, cl); in htb_delete()
1323 struct htb_class *cl = (struct htb_class *)*arg, *parent; in htb_change_class() local
1357 if (!cl) { /* new class */ in htb_change_class()
1386 cl = kzalloc(sizeof(*cl), GFP_KERNEL); in htb_change_class()
1387 if (!cl) in htb_change_class()
1390 err = tcf_block_get(&cl->block, &cl->filter_list, sch, extack); in htb_change_class()
1392 kfree(cl); in htb_change_class()
1396 err = gen_new_estimator(&cl->bstats, NULL, in htb_change_class()
1397 &cl->rate_est, in htb_change_class()
1402 tcf_block_put(cl->block); in htb_change_class()
1403 kfree(cl); in htb_change_class()
1408 cl->children = 0; in htb_change_class()
1409 RB_CLEAR_NODE(&cl->pq_node); in htb_change_class()
1412 RB_CLEAR_NODE(&cl->node[prio]); in htb_change_class()
1442 cl->un.leaf.q = new_q ? new_q : &noop_qdisc; in htb_change_class()
1444 cl->common.classid = classid; in htb_change_class()
1445 cl->parent = parent; in htb_change_class()
1448 cl->tokens = PSCHED_TICKS2NS(hopt->buffer); in htb_change_class()
1449 cl->ctokens = PSCHED_TICKS2NS(hopt->cbuffer); in htb_change_class()
1450 cl->mbuffer = 60ULL * NSEC_PER_SEC; /* 1min */ in htb_change_class()
1451 cl->t_c = ktime_get_ns(); in htb_change_class()
1452 cl->cmode = HTB_CAN_SEND; in htb_change_class()
1455 qdisc_class_hash_insert(&q->clhash, &cl->common); in htb_change_class()
1458 if (cl->un.leaf.q != &noop_qdisc) in htb_change_class()
1459 qdisc_hash_add(cl->un.leaf.q, true); in htb_change_class()
1462 err = gen_replace_estimator(&cl->bstats, NULL, in htb_change_class()
1463 &cl->rate_est, in htb_change_class()
1477 psched_ratecfg_precompute(&cl->rate, &hopt->rate, rate64); in htb_change_class()
1478 psched_ratecfg_precompute(&cl->ceil, &hopt->ceil, ceil64); in htb_change_class()
1483 if (!cl->level) { in htb_change_class()
1484 u64 quantum = cl->rate.rate_bytes_ps; in htb_change_class()
1487 cl->quantum = min_t(u64, quantum, INT_MAX); in htb_change_class()
1489 if (!hopt->quantum && cl->quantum < 1000) { in htb_change_class()
1491 cl->quantum = 1000; in htb_change_class()
1493 if (!hopt->quantum && cl->quantum > 200000) { in htb_change_class()
1495 cl->quantum = 200000; in htb_change_class()
1498 cl->quantum = hopt->quantum; in htb_change_class()
1499 if ((cl->prio = hopt->prio) >= TC_HTB_NUMPRIO) in htb_change_class()
1500 cl->prio = TC_HTB_NUMPRIO - 1; in htb_change_class()
1503 cl->buffer = PSCHED_TICKS2NS(hopt->buffer); in htb_change_class()
1504 cl->cbuffer = PSCHED_TICKS2NS(hopt->cbuffer); in htb_change_class()
1510 cl->common.classid, (warn == -1 ? "small" : "big")); in htb_change_class()
1514 *arg = (unsigned long)cl; in htb_change_class()
1525 struct htb_class *cl = (struct htb_class *)arg; in htb_tcf_block() local
1527 return cl ? cl->block : q->block; in htb_tcf_block()
1533 struct htb_class *cl = htb_find(classid, sch); in htb_bind_filter() local
1544 if (cl) in htb_bind_filter()
1545 cl->filter_cnt++; in htb_bind_filter()
1546 return (unsigned long)cl; in htb_bind_filter()
1551 struct htb_class *cl = (struct htb_class *)arg; in htb_unbind_filter() local
1553 if (cl) in htb_unbind_filter()
1554 cl->filter_cnt--; in htb_unbind_filter()
1560 struct htb_class *cl; in htb_walk() local
1567 hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) { in htb_walk()
1572 if (arg->fn(sch, (unsigned long)cl, arg) < 0) { in htb_walk()