Lines Matching +full:out +full:- +full:of +full:- +full:band
1 // SPDX-License-Identifier: GPL-2.0-only
6 * -----------
9 * discipline that merges functionality of PRIO and DRR qdiscs in one scheduler.
10 * ETS makes it easy to configure a set of strict and bandwidth-sharing bands to
14 * classes at will. Instead one specifies number of classes, how many are
15 * PRIO-like and how many DRR-like, and quanta for the latter.
18 * ---------
20 * The strict classes, if any, are tried for traffic first: first band 0, if it
21 * has no traffic then band 1, etc.
23 * When there is no traffic in any of the strict queues, the bandwidth-sharing
24 * ones are tried next. Each band is assigned a deficit counter, initialized to
25 * "quantum" of that band. ETS maintains a list of active bandwidth-sharing
26 * bands whose qdiscs are non-empty. A packet is dequeued from the band at the
27 * head of the list if the packet size is smaller or equal to the deficit
29 * scheduler moves on to the next band in the active list.
84 return -EINVAL; in ets_quantum_parse()
94 return &q->classes[arg - 1]; in ets_class_from_arg()
100 int band = cl - q->classes; in ets_class_id() local
102 return TC_H_MAKE(sch->handle, band + 1); in ets_class_id()
118 if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc) in ets_offload_change()
122 qopt.handle = sch->handle; in ets_offload_change()
123 qopt.parent = sch->parent; in ets_offload_change()
124 qopt.replace_params.bands = q->nbands; in ets_offload_change()
125 qopt.replace_params.qstats = &sch->qstats; in ets_offload_change()
127 q->prio2band, sizeof(q->prio2band)); in ets_offload_change()
129 for (i = 0; i < q->nbands; i++) in ets_offload_change()
130 q_sum += q->classes[i].quantum; in ets_offload_change()
132 for (i = 0; i < q->nbands; i++) { in ets_offload_change()
133 quantum = q->classes[i].quantum; in ets_offload_change()
136 weight = w_psum - w_psum_prev; in ets_offload_change()
143 dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_ETS, &qopt); in ets_offload_change()
151 if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc) in ets_offload_destroy()
155 qopt.handle = sch->handle; in ets_offload_destroy()
156 qopt.parent = sch->parent; in ets_offload_destroy()
157 dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_ETS, &qopt); in ets_offload_destroy()
168 qopt.handle = sch->handle; in ets_offload_graft()
169 qopt.parent = sch->parent; in ets_offload_graft()
170 qopt.graft_params.band = arg - 1; in ets_offload_graft()
171 qopt.graft_params.child_handle = new->handle; in ets_offload_graft()
182 qopt.handle = sch->handle; in ets_offload_dump()
183 qopt.parent = sch->parent; in ets_offload_dump()
184 qopt.stats.bstats = &sch->bstats; in ets_offload_dump()
185 qopt.stats.qstats = &sch->qstats; in ets_offload_dump()
192 unsigned int band = cl - q->classes; in ets_class_is_strict() local
194 return band < q->nstrict; in ets_class_is_strict()
212 NL_SET_ERR_MSG(extack, "Fine-grained class addition and removal is not supported"); in ets_class_change()
213 return -EOPNOTSUPP; in ets_class_change()
218 return -EINVAL; in ets_class_change()
231 return -EINVAL; in ets_class_change()
240 cl->quantum = quantum; in ets_class_change()
254 new = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, in ets_class_graft()
262 *old = qdisc_replace(sch, new, &cl->qdisc); in ets_class_graft()
271 return cl->qdisc; in ets_class_leaf()
276 unsigned long band = TC_H_MIN(classid); in ets_class_find() local
279 if (band - 1 >= q->nbands) in ets_class_find()
281 return band; in ets_class_find()
289 /* We get notified about zero-length child Qdiscs as well if they are in ets_class_qlen_notify()
293 if (!ets_class_is_strict(q, cl) && sch->q.qlen) in ets_class_qlen_notify()
294 list_del(&cl->alist); in ets_class_qlen_notify()
304 tcm->tcm_parent = TC_H_ROOT; in ets_class_dump()
305 tcm->tcm_handle = ets_class_id(sch, cl); in ets_class_dump()
306 tcm->tcm_info = cl->qdisc->handle; in ets_class_dump()
312 if (nla_put_u32(skb, TCA_ETS_QUANTA_BAND, cl->quantum)) in ets_class_dump()
319 return -EMSGSIZE; in ets_class_dump()
326 struct Qdisc *cl_q = cl->qdisc; in ets_class_dump_stats()
329 d, NULL, &cl_q->bstats) < 0 || in ets_class_dump_stats()
331 return -1; in ets_class_dump_stats()
341 if (arg->stop) in ets_qdisc_walk()
344 for (i = 0; i < q->nbands; i++) { in ets_qdisc_walk()
345 if (arg->count < arg->skip) { in ets_qdisc_walk()
346 arg->count++; in ets_qdisc_walk()
349 if (arg->fn(sch, i + 1, arg) < 0) { in ets_qdisc_walk()
350 arg->stop = 1; in ets_qdisc_walk()
353 arg->count++; in ets_qdisc_walk()
368 return q->block; in ets_qdisc_tcf_block()
385 u32 band = skb->priority; in ets_classify() local
391 if (TC_H_MAJ(skb->priority) != sch->handle) { in ets_classify()
392 fl = rcu_dereference_bh(q->filter_list); in ets_classify()
406 if (TC_H_MAJ(band)) in ets_classify()
407 band = 0; in ets_classify()
408 return &q->classes[q->prio2band[band & TC_PRIO_MAX]]; in ets_classify()
410 band = res.classid; in ets_classify()
412 band = TC_H_MIN(band) - 1; in ets_classify()
413 if (band >= q->nbands) in ets_classify()
414 return &q->classes[q->prio2band[0]]; in ets_classify()
415 return &q->classes[band]; in ets_classify()
435 first = !cl->qdisc->q.qlen; in ets_qdisc_enqueue()
436 err = qdisc_enqueue(skb, cl->qdisc, to_free); in ets_qdisc_enqueue()
439 cl->qstats.drops++; in ets_qdisc_enqueue()
446 list_add_tail(&cl->alist, &q->active); in ets_qdisc_enqueue()
447 cl->deficit = cl->quantum; in ets_qdisc_enqueue()
450 sch->qstats.backlog += len; in ets_qdisc_enqueue()
451 sch->q.qlen++; in ets_qdisc_enqueue()
460 sch->q.qlen--; in ets_qdisc_dequeue_skb()
469 unsigned int band; in ets_qdisc_dequeue() local
473 for (band = 0; band < q->nstrict; band++) { in ets_qdisc_dequeue()
474 cl = &q->classes[band]; in ets_qdisc_dequeue()
475 skb = qdisc_dequeue_peeked(cl->qdisc); in ets_qdisc_dequeue()
480 if (list_empty(&q->active)) in ets_qdisc_dequeue()
481 goto out; in ets_qdisc_dequeue()
483 cl = list_first_entry(&q->active, struct ets_class, alist); in ets_qdisc_dequeue()
484 skb = cl->qdisc->ops->peek(cl->qdisc); in ets_qdisc_dequeue()
486 qdisc_warn_nonwc(__func__, cl->qdisc); in ets_qdisc_dequeue()
487 goto out; in ets_qdisc_dequeue()
491 if (len <= cl->deficit) { in ets_qdisc_dequeue()
492 cl->deficit -= len; in ets_qdisc_dequeue()
493 skb = qdisc_dequeue_peeked(cl->qdisc); in ets_qdisc_dequeue()
495 goto out; in ets_qdisc_dequeue()
496 if (cl->qdisc->q.qlen == 0) in ets_qdisc_dequeue()
497 list_del(&cl->alist); in ets_qdisc_dequeue()
501 cl->deficit += cl->quantum; in ets_qdisc_dequeue()
502 list_move_tail(&cl->alist, &q->active); in ets_qdisc_dequeue()
504 out: in ets_qdisc_dequeue()
514 u8 band; in ets_qdisc_priomap_parse() local
529 return -EINVAL; in ets_qdisc_priomap_parse()
531 band = nla_get_u8(attr); in ets_qdisc_priomap_parse()
532 if (band >= nbands) { in ets_qdisc_priomap_parse()
533 NL_SET_ERR_MSG_MOD(extack, "Invalid band number in ETS priomap"); in ets_qdisc_priomap_parse()
534 return -EINVAL; in ets_qdisc_priomap_parse()
536 priomap[prio++] = band; in ets_qdisc_priomap_parse()
540 return -EINVAL; in ets_qdisc_priomap_parse()
553 int band = nstrict; in ets_qdisc_quanta_parse() local
566 if (band >= nbands) { in ets_qdisc_quanta_parse()
568 return -EINVAL; in ets_qdisc_quanta_parse()
570 err = ets_quantum_parse(sch, attr, &quanta[band++], in ets_qdisc_quanta_parse()
577 return -EINVAL; in ets_qdisc_quanta_parse()
591 unsigned int oldbands = q->nbands; in ets_qdisc_change()
600 return -EINVAL; in ets_qdisc_change()
608 NL_SET_ERR_MSG_MOD(extack, "Number of bands is a required argument"); in ets_qdisc_change()
609 return -EINVAL; in ets_qdisc_change()
613 NL_SET_ERR_MSG_MOD(extack, "Invalid number of bands"); in ets_qdisc_change()
614 return -EINVAL; in ets_qdisc_change()
616 /* Unless overridden, traffic goes to the last band. */ in ets_qdisc_change()
617 memset(priomap, nbands - 1, sizeof(priomap)); in ets_qdisc_change()
622 NL_SET_ERR_MSG_MOD(extack, "Invalid number of strict bands"); in ets_qdisc_change()
623 return -EINVAL; in ets_qdisc_change()
641 * ones are ETS with quantum of MTU. Initialize the missing values here. in ets_qdisc_change()
650 queues[i] = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, in ets_qdisc_change()
651 ets_class_id(sch, &q->classes[i]), in ets_qdisc_change()
655 qdisc_put(queues[--i]); in ets_qdisc_change()
656 return -ENOMEM; in ets_qdisc_change()
662 q->nbands = nbands; in ets_qdisc_change()
663 q->nstrict = nstrict; in ets_qdisc_change()
664 memcpy(q->prio2band, priomap, sizeof(priomap)); in ets_qdisc_change()
666 for (i = q->nbands; i < oldbands; i++) in ets_qdisc_change()
667 qdisc_tree_flush_backlog(q->classes[i].qdisc); in ets_qdisc_change()
669 for (i = 0; i < q->nbands; i++) in ets_qdisc_change()
670 q->classes[i].quantum = quanta[i]; in ets_qdisc_change()
672 for (i = oldbands; i < q->nbands; i++) { in ets_qdisc_change()
673 q->classes[i].qdisc = queues[i]; in ets_qdisc_change()
674 if (q->classes[i].qdisc != &noop_qdisc) in ets_qdisc_change()
675 qdisc_hash_add(q->classes[i].qdisc, true); in ets_qdisc_change()
681 for (i = q->nbands; i < oldbands; i++) { in ets_qdisc_change()
682 qdisc_put(q->classes[i].qdisc); in ets_qdisc_change()
683 memset(&q->classes[i], 0, sizeof(q->classes[i])); in ets_qdisc_change()
695 return -EINVAL; in ets_qdisc_init()
697 err = tcf_block_get(&q->block, &q->filter_list, sch, extack); in ets_qdisc_init()
701 INIT_LIST_HEAD(&q->active); in ets_qdisc_init()
708 int band; in ets_qdisc_reset() local
710 for (band = q->nstrict; band < q->nbands; band++) { in ets_qdisc_reset()
711 if (q->classes[band].qdisc->q.qlen) in ets_qdisc_reset()
712 list_del(&q->classes[band].alist); in ets_qdisc_reset()
714 for (band = 0; band < q->nbands; band++) in ets_qdisc_reset()
715 qdisc_reset(q->classes[band].qdisc); in ets_qdisc_reset()
716 sch->qstats.backlog = 0; in ets_qdisc_reset()
717 sch->q.qlen = 0; in ets_qdisc_reset()
723 int band; in ets_qdisc_destroy() local
726 tcf_block_put(q->block); in ets_qdisc_destroy()
727 for (band = 0; band < q->nbands; band++) in ets_qdisc_destroy()
728 qdisc_put(q->classes[band].qdisc); in ets_qdisc_destroy()
736 int band; in ets_qdisc_dump() local
748 if (nla_put_u8(skb, TCA_ETS_NBANDS, q->nbands)) in ets_qdisc_dump()
751 if (q->nstrict && in ets_qdisc_dump()
752 nla_put_u8(skb, TCA_ETS_NSTRICT, q->nstrict)) in ets_qdisc_dump()
755 if (q->nbands > q->nstrict) { in ets_qdisc_dump()
760 for (band = q->nstrict; band < q->nbands; band++) { in ets_qdisc_dump()
762 q->classes[band].quantum)) in ets_qdisc_dump()
774 if (nla_put_u8(skb, TCA_ETS_PRIOMAP_BAND, q->prio2band[prio])) in ets_qdisc_dump()
784 return -EMSGSIZE; in ets_qdisc_dump()