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()
328 if (gnet_stats_copy_basic(d, NULL, &cl_q->bstats, true) < 0 || in ets_class_dump_stats()
330 return -1; in ets_class_dump_stats()
340 if (arg->stop) in ets_qdisc_walk()
343 for (i = 0; i < q->nbands; i++) { in ets_qdisc_walk()
360 return q->block; in ets_qdisc_tcf_block()
377 u32 band = skb->priority; in ets_classify() local
383 if (TC_H_MAJ(skb->priority) != sch->handle) { in ets_classify()
384 fl = rcu_dereference_bh(q->filter_list); in ets_classify()
398 if (TC_H_MAJ(band)) in ets_classify()
399 band = 0; in ets_classify()
400 return &q->classes[q->prio2band[band & TC_PRIO_MAX]]; in ets_classify()
402 band = res.classid; in ets_classify()
404 band = TC_H_MIN(band) - 1; in ets_classify()
405 if (band >= q->nbands) in ets_classify()
406 return &q->classes[q->prio2band[0]]; in ets_classify()
407 return &q->classes[band]; in ets_classify()
427 first = !cl->qdisc->q.qlen; in ets_qdisc_enqueue()
428 err = qdisc_enqueue(skb, cl->qdisc, to_free); in ets_qdisc_enqueue()
431 cl->qstats.drops++; in ets_qdisc_enqueue()
438 list_add_tail(&cl->alist, &q->active); in ets_qdisc_enqueue()
439 cl->deficit = cl->quantum; in ets_qdisc_enqueue()
442 sch->qstats.backlog += len; in ets_qdisc_enqueue()
443 sch->q.qlen++; in ets_qdisc_enqueue()
452 sch->q.qlen--; in ets_qdisc_dequeue_skb()
461 unsigned int band; in ets_qdisc_dequeue() local
465 for (band = 0; band < q->nstrict; band++) { in ets_qdisc_dequeue()
466 cl = &q->classes[band]; in ets_qdisc_dequeue()
467 skb = qdisc_dequeue_peeked(cl->qdisc); in ets_qdisc_dequeue()
472 if (list_empty(&q->active)) in ets_qdisc_dequeue()
473 goto out; in ets_qdisc_dequeue()
475 cl = list_first_entry(&q->active, struct ets_class, alist); in ets_qdisc_dequeue()
476 skb = cl->qdisc->ops->peek(cl->qdisc); in ets_qdisc_dequeue()
478 qdisc_warn_nonwc(__func__, cl->qdisc); in ets_qdisc_dequeue()
479 goto out; in ets_qdisc_dequeue()
483 if (len <= cl->deficit) { in ets_qdisc_dequeue()
484 cl->deficit -= len; in ets_qdisc_dequeue()
485 skb = qdisc_dequeue_peeked(cl->qdisc); in ets_qdisc_dequeue()
487 goto out; in ets_qdisc_dequeue()
488 if (cl->qdisc->q.qlen == 0) in ets_qdisc_dequeue()
489 list_del(&cl->alist); in ets_qdisc_dequeue()
493 cl->deficit += cl->quantum; in ets_qdisc_dequeue()
494 list_move_tail(&cl->alist, &q->active); in ets_qdisc_dequeue()
496 out: in ets_qdisc_dequeue()
506 u8 band; in ets_qdisc_priomap_parse() local
521 return -EINVAL; in ets_qdisc_priomap_parse()
523 band = nla_get_u8(attr); in ets_qdisc_priomap_parse()
524 if (band >= nbands) { in ets_qdisc_priomap_parse()
525 NL_SET_ERR_MSG_MOD(extack, "Invalid band number in ETS priomap"); in ets_qdisc_priomap_parse()
526 return -EINVAL; in ets_qdisc_priomap_parse()
528 priomap[prio++] = band; in ets_qdisc_priomap_parse()
532 return -EINVAL; in ets_qdisc_priomap_parse()
545 int band = nstrict; in ets_qdisc_quanta_parse() local
558 if (band >= nbands) { in ets_qdisc_quanta_parse()
560 return -EINVAL; in ets_qdisc_quanta_parse()
562 err = ets_quantum_parse(sch, attr, &quanta[band++], in ets_qdisc_quanta_parse()
569 return -EINVAL; in ets_qdisc_quanta_parse()
583 unsigned int oldbands = q->nbands; in ets_qdisc_change()
595 NL_SET_ERR_MSG_MOD(extack, "Number of bands is a required argument"); in ets_qdisc_change()
596 return -EINVAL; in ets_qdisc_change()
600 NL_SET_ERR_MSG_MOD(extack, "Invalid number of bands"); in ets_qdisc_change()
601 return -EINVAL; in ets_qdisc_change()
603 /* Unless overridden, traffic goes to the last band. */ in ets_qdisc_change()
604 memset(priomap, nbands - 1, sizeof(priomap)); in ets_qdisc_change()
609 NL_SET_ERR_MSG_MOD(extack, "Invalid number of strict bands"); in ets_qdisc_change()
610 return -EINVAL; in ets_qdisc_change()
628 * ones are ETS with quantum of MTU. Initialize the missing values here. in ets_qdisc_change()
637 queues[i] = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, in ets_qdisc_change()
638 ets_class_id(sch, &q->classes[i]), in ets_qdisc_change()
642 qdisc_put(queues[--i]); in ets_qdisc_change()
643 return -ENOMEM; in ets_qdisc_change()
649 WRITE_ONCE(q->nbands, nbands); in ets_qdisc_change()
650 for (i = nstrict; i < q->nstrict; i++) { in ets_qdisc_change()
651 if (q->classes[i].qdisc->q.qlen) { in ets_qdisc_change()
652 list_add_tail(&q->classes[i].alist, &q->active); in ets_qdisc_change()
653 q->classes[i].deficit = quanta[i]; in ets_qdisc_change()
656 for (i = q->nbands; i < oldbands; i++) { in ets_qdisc_change()
657 if (i >= q->nstrict && q->classes[i].qdisc->q.qlen) in ets_qdisc_change()
658 list_del(&q->classes[i].alist); in ets_qdisc_change()
659 qdisc_tree_flush_backlog(q->classes[i].qdisc); in ets_qdisc_change()
661 WRITE_ONCE(q->nstrict, nstrict); in ets_qdisc_change()
662 memcpy(q->prio2band, priomap, sizeof(priomap)); in ets_qdisc_change()
664 for (i = 0; i < q->nbands; i++) in ets_qdisc_change()
665 WRITE_ONCE(q->classes[i].quantum, quanta[i]); in ets_qdisc_change()
667 for (i = oldbands; i < q->nbands; i++) { in ets_qdisc_change()
668 q->classes[i].qdisc = queues[i]; in ets_qdisc_change()
669 if (q->classes[i].qdisc != &noop_qdisc) in ets_qdisc_change()
670 qdisc_hash_add(q->classes[i].qdisc, true); in ets_qdisc_change()
676 for (i = q->nbands; i < oldbands; i++) { in ets_qdisc_change()
677 qdisc_put(q->classes[i].qdisc); in ets_qdisc_change()
678 q->classes[i].qdisc = NULL; in ets_qdisc_change()
679 WRITE_ONCE(q->classes[i].quantum, 0); in ets_qdisc_change()
680 q->classes[i].deficit = 0; in ets_qdisc_change()
681 gnet_stats_basic_sync_init(&q->classes[i].bstats); in ets_qdisc_change()
682 memset(&q->classes[i].qstats, 0, sizeof(q->classes[i].qstats)); in ets_qdisc_change()
694 return -EINVAL; in ets_qdisc_init()
696 err = tcf_block_get(&q->block, &q->filter_list, sch, extack); in ets_qdisc_init()
700 INIT_LIST_HEAD(&q->active); in ets_qdisc_init()
702 INIT_LIST_HEAD(&q->classes[i].alist); in ets_qdisc_init()
710 int band; in ets_qdisc_reset() local
712 for (band = q->nstrict; band < q->nbands; band++) { in ets_qdisc_reset()
713 if (q->classes[band].qdisc->q.qlen) in ets_qdisc_reset()
714 list_del(&q->classes[band].alist); in ets_qdisc_reset()
716 for (band = 0; band < q->nbands; band++) in ets_qdisc_reset()
717 qdisc_reset(q->classes[band].qdisc); 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()
737 int band; in ets_qdisc_dump() local
749 nbands = READ_ONCE(q->nbands); in ets_qdisc_dump()
753 nstrict = READ_ONCE(q->nstrict); in ets_qdisc_dump()
762 for (band = nstrict; band < nbands; band++) { in ets_qdisc_dump()
764 READ_ONCE(q->classes[band].quantum))) in ets_qdisc_dump()
777 READ_ONCE(q->prio2band[prio]))) in ets_qdisc_dump()
787 return -EMSGSIZE; in ets_qdisc_dump()