Lines Matching +full:set +full:- +full:rate +full:- +full:parent
55 #define is_sc_null(sc) (((sc) == NULL) || ((sc)->m1 == 0 && (sc)->m2 == 0))
135 memcpy(&altq->pa, a, sizeof(struct pf_altq)); in pfaltq_store()
136 memset(&altq->meta, 0, sizeof(altq->meta)); in pfaltq_store()
138 if (a->qname[0] == 0) { in pfaltq_store()
139 item.key = altq->pa.ifname; in pfaltq_store()
145 key_size = sizeof(a->ifname) + sizeof(a->qname); in pfaltq_store()
148 snprintf(item.key, key_size, "%s:%s", a->ifname, a->qname); in pfaltq_store()
153 item.key = altq->pa.qname; in pfaltq_store()
154 item.data = &altq->pa.qid; in pfaltq_store()
170 return (ret_item->data); in pfaltq_lookup()
185 return (ret_item->data); in qname_to_pfaltq()
203 qid = *(uint32_t *)ret_item->data; in qname_to_qid()
211 if (a->qname[0] != 0) { in print_altq()
217 if (a->local_flags & PFALTQ_FLAG_IF_REMOVED) in print_altq()
221 printf("altq on %s ", a->ifname); in print_altq()
223 switch (a->scheduler) { in print_altq()
246 if (bw != NULL && bw->bw_percent > 0) { in print_altq()
247 if (bw->bw_percent < 100) in print_altq()
248 printf("bandwidth %u%% ", bw->bw_percent); in print_altq()
250 printf("bandwidth %s ", rate2str((double)a->ifbandwidth)); in print_altq()
252 if (a->qlimit != DEFAULT_QLIMIT) in print_altq()
253 printf("qlimit %u ", a->qlimit); in print_altq()
254 printf("tbrsize %u ", a->tbrsize); in print_altq()
265 if (a->local_flags & PFALTQ_FLAG_IF_REMOVED) in print_queue()
271 printf("%s ", a->qname); in print_queue()
273 printf("on %s ", a->ifname); in print_queue()
274 if (a->scheduler == ALTQT_CBQ || a->scheduler == ALTQT_HFSC || in print_queue()
275 a->scheduler == ALTQT_FAIRQ) { in print_queue()
276 if (bw != NULL && bw->bw_percent > 0) { in print_queue()
277 if (bw->bw_percent < 100) in print_queue()
278 printf("bandwidth %u%% ", bw->bw_percent); in print_queue()
280 printf("bandwidth %s ", rate2str((double)a->bandwidth)); in print_queue()
282 if (a->priority != DEFAULT_PRIORITY) in print_queue()
283 printf("priority %u ", a->priority); in print_queue()
284 if (a->qlimit != DEFAULT_QLIMIT) in print_queue()
285 printf("qlimit %u ", a->qlimit); in print_queue()
286 switch (a->scheduler) { in print_queue()
309 u_int64_t rate; in eval_pfaltq() local
312 if (bw->bw_absolute > 0) in eval_pfaltq()
313 pa->ifbandwidth = bw->bw_absolute; in eval_pfaltq()
315 if ((rate = getifspeed(pa->ifname)) == 0) { in eval_pfaltq()
318 pa->ifname); in eval_pfaltq()
320 } else if ((pa->ifbandwidth = eval_bwspec(bw, rate)) == 0) in eval_pfaltq()
321 pa->ifbandwidth = rate; in eval_pfaltq()
324 * Limit bandwidth to UINT_MAX for schedulers that aren't 64-bit ready. in eval_pfaltq()
326 if ((pa->scheduler != ALTQT_HFSC) && (pa->ifbandwidth > UINT_MAX)) { in eval_pfaltq()
327 pa->ifbandwidth = UINT_MAX; in eval_pfaltq()
329 "because selected scheduler is 32-bit limited\n", pa->ifname, in eval_pfaltq()
330 pa->ifbandwidth); in eval_pfaltq()
332 errors += eval_queue_opts(pa, opts, pa->ifbandwidth); in eval_pfaltq()
335 if (pa->tbrsize == 0) { in eval_pfaltq()
336 rate = pa->ifbandwidth; in eval_pfaltq()
337 if (rate <= 1 * 1000 * 1000) in eval_pfaltq()
339 else if (rate <= 10 * 1000 * 1000) in eval_pfaltq()
341 else if (rate <= 200 * 1000 * 1000) in eval_pfaltq()
343 else if (rate <= 2500 * 1000 * 1000ULL) in eval_pfaltq()
347 size = size * getifmtu(pa->ifname); in eval_pfaltq()
348 pa->tbrsize = size; in eval_pfaltq()
364 switch (if_ppa->pa.scheduler) { in check_commit_altq()
392 struct pfctl_altq *if_ppa, *parent; in eval_pfqueue() local
396 if ((if_ppa = pfaltq_lookup(pa->ifname)) == NULL) { in eval_pfqueue()
397 fprintf(stderr, "altq not defined on %s\n", pa->ifname); in eval_pfqueue()
400 pa->scheduler = if_ppa->pa.scheduler; in eval_pfqueue()
401 pa->ifbandwidth = if_ppa->pa.ifbandwidth; in eval_pfqueue()
403 if (qname_to_pfaltq(pa->qname, pa->ifname) != NULL) { in eval_pfqueue()
405 pa->qname, pa->ifname); in eval_pfqueue()
408 pa->qid = qname_to_qid(pa->qname); in eval_pfqueue()
410 parent = NULL; in eval_pfqueue()
411 if (pa->parent[0] != 0) { in eval_pfqueue()
412 parent = qname_to_pfaltq(pa->parent, pa->ifname); in eval_pfqueue()
413 if (parent == NULL) { in eval_pfqueue()
414 fprintf(stderr, "parent %s not found for %s\n", in eval_pfqueue()
415 pa->parent, pa->qname); in eval_pfqueue()
418 pa->parent_qid = parent->pa.qid; in eval_pfqueue()
420 if (pa->qlimit == 0) in eval_pfqueue()
421 pa->qlimit = DEFAULT_QLIMIT; in eval_pfqueue()
423 if (pa->scheduler == ALTQT_CBQ || pa->scheduler == ALTQT_HFSC || in eval_pfqueue()
424 pa->scheduler == ALTQT_FAIRQ) { in eval_pfqueue()
425 pa->bandwidth = eval_bwspec(bw, in eval_pfqueue()
426 parent == NULL ? pa->ifbandwidth : parent->pa.bandwidth); in eval_pfqueue()
428 if (pa->bandwidth > pa->ifbandwidth) { in eval_pfqueue()
430 "interface\n", pa->qname); in eval_pfqueue()
435 * bandwidths is less than the parent's bandwidth. For in eval_pfqueue()
437 * the child linkshare service curves are under the parent's in eval_pfqueue()
441 if ((parent != NULL) && (pa->scheduler != ALTQT_HFSC)) { in eval_pfqueue()
442 if (pa->bandwidth > parent->pa.bandwidth) { in eval_pfqueue()
443 warnx("bandwidth for %s higher than parent", in eval_pfqueue()
444 pa->qname); in eval_pfqueue()
447 parent->meta.bwsum += pa->bandwidth; in eval_pfqueue()
448 if (parent->meta.bwsum > parent->pa.bandwidth) { in eval_pfqueue()
450 ") higher than parent \"%s\" (%" PRIu64 ")", in eval_pfqueue()
451 parent->meta.bwsum, parent->pa.qname, in eval_pfqueue()
452 parent->pa.bandwidth); in eval_pfqueue()
458 parent == NULL ? pa->ifbandwidth : parent->pa.bandwidth)) in eval_pfqueue()
461 if (parent != NULL) in eval_pfqueue()
462 parent->meta.children++; in eval_pfqueue()
464 switch (pa->scheduler) { in eval_pfqueue()
472 error = eval_pfqueue_hfsc(pf, pa, if_ppa, parent); in eval_pfqueue()
475 error = eval_pfqueue_fairq(pf, pa, if_ppa, parent); in eval_pfqueue()
495 if (pa->priority >= CBQ_MAXPRI) { in eval_pfqueue_cbq()
496 warnx("priority out of range: max %d", CBQ_MAXPRI - 1); in eval_pfqueue_cbq()
497 return (-1); in eval_pfqueue_cbq()
500 ifmtu = getifmtu(pa->ifname); in eval_pfqueue_cbq()
501 opts = &pa->pq_u.cbq_opts; in eval_pfqueue_cbq()
503 if (opts->pktsize == 0) { /* use default */ in eval_pfqueue_cbq()
504 opts->pktsize = ifmtu; in eval_pfqueue_cbq()
505 if (opts->pktsize > MCLBYTES) /* do what TCP does */ in eval_pfqueue_cbq()
506 opts->pktsize &= ~MCLBYTES; in eval_pfqueue_cbq()
507 } else if (opts->pktsize > ifmtu) in eval_pfqueue_cbq()
508 opts->pktsize = ifmtu; in eval_pfqueue_cbq()
509 if (opts->maxpktsize == 0) /* use default */ in eval_pfqueue_cbq()
510 opts->maxpktsize = ifmtu; in eval_pfqueue_cbq()
511 else if (opts->maxpktsize > ifmtu) in eval_pfqueue_cbq()
512 opts->pktsize = ifmtu; in eval_pfqueue_cbq()
514 if (opts->pktsize > opts->maxpktsize) in eval_pfqueue_cbq()
515 opts->pktsize = opts->maxpktsize; in eval_pfqueue_cbq()
517 if (pa->parent[0] == 0) in eval_pfqueue_cbq()
518 opts->flags |= (CBQCLF_ROOTCLASS | CBQCLF_WRR); in eval_pfqueue_cbq()
520 if (pa->pq_u.cbq_opts.flags & CBQCLF_ROOTCLASS) in eval_pfqueue_cbq()
521 if_ppa->meta.root_classes++; in eval_pfqueue_cbq()
522 if (pa->pq_u.cbq_opts.flags & CBQCLF_DEFCLASS) in eval_pfqueue_cbq()
523 if_ppa->meta.default_classes++; in eval_pfqueue_cbq()
541 opts = &pa->pq_u.cbq_opts; in cbq_compute_idletime()
542 ifnsPerByte = (1.0 / (double)pa->ifbandwidth) * RM_NS_PER_SEC * 8; in cbq_compute_idletime()
543 minburst = opts->minburst; in cbq_compute_idletime()
544 maxburst = opts->maxburst; in cbq_compute_idletime()
546 if (pa->bandwidth == 0) in cbq_compute_idletime()
549 f = ((double) pa->bandwidth / (double) pa->ifbandwidth); in cbq_compute_idletime()
552 ptime = (double)opts->pktsize * ifnsPerByte; in cbq_compute_idletime()
553 cptime = ptime * (1.0 - f) / f; in cbq_compute_idletime()
555 if (nsPerByte * (double)opts->maxpktsize > (double)INT_MAX) { in cbq_compute_idletime()
560 if (pa->bandwidth != 0 && (pf->opts & PF_OPT_QUIET) == 0) { in cbq_compute_idletime()
562 rate2str(ifnsPerByte * (double)opts->maxpktsize / in cbq_compute_idletime()
563 (double)INT_MAX * (double)pa->ifbandwidth)); in cbq_compute_idletime()
565 pa->qname); in cbq_compute_idletime()
567 nsPerByte = (double)(INT_MAX / opts->maxpktsize); in cbq_compute_idletime()
582 g = (1.0 - 1.0 / z); in cbq_compute_idletime()
584 gtom = pow(g, (double)(minburst-1)); in cbq_compute_idletime()
585 maxidle = ((1.0 / f - 1.0) * ((1.0 - gton) / gton)); in cbq_compute_idletime()
586 maxidle_s = (1.0 - g); in cbq_compute_idletime()
591 offtime = cptime * (1.0 + 1.0/(1.0 - g) * (1.0 - gtom) / gtom); in cbq_compute_idletime()
592 minidle = -((double)opts->maxpktsize * (double)nsPerByte); in cbq_compute_idletime()
606 opts->minburst = minburst; in cbq_compute_idletime()
607 opts->maxburst = maxburst; in cbq_compute_idletime()
608 opts->ns_per_byte = (u_int)nsPerByte; in cbq_compute_idletime()
609 opts->maxidle = (u_int)fabs(maxidle); in cbq_compute_idletime()
610 opts->minidle = (int)minidle; in cbq_compute_idletime()
611 opts->offtime = (u_int)fabs(offtime); in cbq_compute_idletime()
625 if (if_ppa->meta.root_classes != 1) { in check_commit_cbq()
626 warnx("should have one root queue on %s", if_ppa->pa.ifname); in check_commit_cbq()
629 if (if_ppa->meta.default_classes != 1) { in check_commit_cbq()
630 warnx("should have one default queue on %s", if_ppa->pa.ifname); in check_commit_cbq()
641 opts = &a->pq_u.cbq_opts; in print_cbq_opts()
642 if (opts->flags) { in print_cbq_opts()
644 if (opts->flags & CBQCLF_RED) in print_cbq_opts()
646 if (opts->flags & CBQCLF_ECN) in print_cbq_opts()
648 if (opts->flags & CBQCLF_RIO) in print_cbq_opts()
650 if (opts->flags & CBQCLF_CODEL) in print_cbq_opts()
652 if (opts->flags & CBQCLF_CLEARDSCP) in print_cbq_opts()
654 if (opts->flags & CBQCLF_FLOWVALVE) in print_cbq_opts()
656 if (opts->flags & CBQCLF_BORROW) in print_cbq_opts()
658 if (opts->flags & CBQCLF_WRR) in print_cbq_opts()
660 if (opts->flags & CBQCLF_EFFICIENT) in print_cbq_opts()
662 if (opts->flags & CBQCLF_ROOTCLASS) in print_cbq_opts()
664 if (opts->flags & CBQCLF_DEFCLASS) in print_cbq_opts()
680 if (pa->priority >= PRIQ_MAXPRI) { in eval_pfqueue_priq()
681 warnx("priority out of range: max %d", PRIQ_MAXPRI - 1); in eval_pfqueue_priq()
682 return (-1); in eval_pfqueue_priq()
684 if (BIT_ISSET(QPRI_BITSET_SIZE, pa->priority, &if_ppa->meta.qpris)) { in eval_pfqueue_priq()
686 pa->qname, pa->ifname); in eval_pfqueue_priq()
687 return (-1); in eval_pfqueue_priq()
689 BIT_SET(QPRI_BITSET_SIZE, pa->priority, &if_ppa->meta.qpris); in eval_pfqueue_priq()
691 if (pa->pq_u.priq_opts.flags & PRCF_DEFAULTCLASS) in eval_pfqueue_priq()
692 if_ppa->meta.default_classes++; in eval_pfqueue_priq()
703 if (if_ppa->meta.default_classes != 1) { in check_commit_priq()
704 warnx("should have one default queue on %s", if_ppa->pa.ifname); in check_commit_priq()
715 opts = &a->pq_u.priq_opts; in print_priq_opts()
717 if (opts->flags) { in print_priq_opts()
719 if (opts->flags & PRCF_RED) in print_priq_opts()
721 if (opts->flags & PRCF_ECN) in print_priq_opts()
723 if (opts->flags & PRCF_RIO) in print_priq_opts()
725 if (opts->flags & PRCF_CODEL) in print_priq_opts()
727 if (opts->flags & PRCF_CLEARDSCP) in print_priq_opts()
729 if (opts->flags & PRCF_DEFAULTCLASS) in print_priq_opts()
743 struct pfctl_altq *parent) in eval_pfqueue_hfsc() argument
748 opts = &pa->pq_u.hfsc_opts; in eval_pfqueue_hfsc()
750 if (parent == NULL) { in eval_pfqueue_hfsc()
752 opts->lssc_m1 = pa->ifbandwidth; in eval_pfqueue_hfsc()
753 opts->lssc_m2 = pa->ifbandwidth; in eval_pfqueue_hfsc()
754 opts->lssc_d = 0; in eval_pfqueue_hfsc()
758 /* First child initializes the parent's service curve accumulators. */ in eval_pfqueue_hfsc()
759 if (parent->meta.children == 1) { in eval_pfqueue_hfsc()
760 LIST_INIT(&parent->meta.rtsc); in eval_pfqueue_hfsc()
761 LIST_INIT(&parent->meta.lssc); in eval_pfqueue_hfsc()
764 if (parent->pa.pq_u.hfsc_opts.flags & HFCF_DEFAULTCLASS) { in eval_pfqueue_hfsc()
766 pa->qname, pa->parent); in eval_pfqueue_hfsc()
767 return (-1); in eval_pfqueue_hfsc()
770 if (pa->pq_u.hfsc_opts.flags & HFCF_DEFAULTCLASS) in eval_pfqueue_hfsc()
771 if_ppa->meta.default_classes++; in eval_pfqueue_hfsc()
774 if (opts->lssc_m2 == 0) in eval_pfqueue_hfsc()
775 opts->lssc_m2 = pa->bandwidth; in eval_pfqueue_hfsc()
777 if ((opts->rtsc_m1 > 0 && opts->rtsc_m2 == 0) || in eval_pfqueue_hfsc()
778 (opts->lssc_m1 > 0 && opts->lssc_m2 == 0) || in eval_pfqueue_hfsc()
779 (opts->ulsc_m1 > 0 && opts->ulsc_m2 == 0)) { in eval_pfqueue_hfsc()
780 warnx("m2 is zero for %s", pa->qname); in eval_pfqueue_hfsc()
781 return (-1); in eval_pfqueue_hfsc()
784 if ((opts->rtsc_m1 < opts->rtsc_m2 && opts->rtsc_m1 != 0) || in eval_pfqueue_hfsc()
785 (opts->lssc_m1 < opts->lssc_m2 && opts->lssc_m1 != 0) || in eval_pfqueue_hfsc()
786 (opts->ulsc_m1 < opts->ulsc_m2 && opts->ulsc_m1 != 0)) { in eval_pfqueue_hfsc()
787 warnx("m1 must be zero for convex curve: %s", pa->qname); in eval_pfqueue_hfsc()
788 return (-1); in eval_pfqueue_hfsc()
793 * for the real-time service curve, the sum of the service curves in eval_pfqueue_hfsc()
795 * not to over-commit the actual interface bandwidth. in eval_pfqueue_hfsc()
797 * curve should not exceed the parent service curve. in eval_pfqueue_hfsc()
798 * for the upper-limit service curve, the assigned bandwidth should in eval_pfqueue_hfsc()
799 * be smaller than the interface bandwidth, and the upper-limit should in eval_pfqueue_hfsc()
800 * be larger than the real-time service curve when both are defined. in eval_pfqueue_hfsc()
803 /* check the real-time service curve. reserve 20% of interface bw */ in eval_pfqueue_hfsc()
804 if (opts->rtsc_m2 != 0) { in eval_pfqueue_hfsc()
806 sc.m1 = opts->rtsc_m1; in eval_pfqueue_hfsc()
807 sc.d = opts->rtsc_d; in eval_pfqueue_hfsc()
808 sc.m2 = opts->rtsc_m2; in eval_pfqueue_hfsc()
809 gsc_add_sc(&parent->meta.rtsc, &sc); in eval_pfqueue_hfsc()
813 sc.m2 = pa->ifbandwidth / 100 * 80; in eval_pfqueue_hfsc()
814 if (!is_gsc_under_sc(&parent->meta.rtsc, &sc)) { in eval_pfqueue_hfsc()
815 warnx("real-time sc exceeds 80%% of the interface " in eval_pfqueue_hfsc()
817 return (-1); in eval_pfqueue_hfsc()
822 if (opts->lssc_m2 != 0) { in eval_pfqueue_hfsc()
824 sc.m1 = opts->lssc_m1; in eval_pfqueue_hfsc()
825 sc.d = opts->lssc_d; in eval_pfqueue_hfsc()
826 sc.m2 = opts->lssc_m2; in eval_pfqueue_hfsc()
827 gsc_add_sc(&parent->meta.lssc, &sc); in eval_pfqueue_hfsc()
828 /* compare the sum of the children with parent's sc */ in eval_pfqueue_hfsc()
829 sc.m1 = parent->pa.pq_u.hfsc_opts.lssc_m1; in eval_pfqueue_hfsc()
830 sc.d = parent->pa.pq_u.hfsc_opts.lssc_d; in eval_pfqueue_hfsc()
831 sc.m2 = parent->pa.pq_u.hfsc_opts.lssc_m2; in eval_pfqueue_hfsc()
832 if (!is_gsc_under_sc(&parent->meta.lssc, &sc)) { in eval_pfqueue_hfsc()
833 warnx("linkshare sc exceeds parent's sc"); in eval_pfqueue_hfsc()
834 return (-1); in eval_pfqueue_hfsc()
838 /* check the upper-limit service curve. */ in eval_pfqueue_hfsc()
839 if (opts->ulsc_m2 != 0) { in eval_pfqueue_hfsc()
840 if (opts->ulsc_m1 > pa->ifbandwidth || in eval_pfqueue_hfsc()
841 opts->ulsc_m2 > pa->ifbandwidth) { in eval_pfqueue_hfsc()
842 warnx("upper-limit larger than interface bandwidth"); in eval_pfqueue_hfsc()
843 return (-1); in eval_pfqueue_hfsc()
845 if (opts->rtsc_m2 != 0 && opts->rtsc_m2 > opts->ulsc_m2) { in eval_pfqueue_hfsc()
846 warnx("upper-limit sc smaller than real-time sc"); in eval_pfqueue_hfsc()
847 return (-1); in eval_pfqueue_hfsc()
859 struct pfctl_altq *if_ppa, struct pfctl_altq *parent) in eval_pfqueue_fairq() argument
864 opts = &pa->pq_u.fairq_opts; in eval_pfqueue_fairq()
866 if (parent == NULL) { in eval_pfqueue_fairq()
868 opts->lssc_m1 = pa->ifbandwidth; in eval_pfqueue_fairq()
869 opts->lssc_m2 = pa->ifbandwidth; in eval_pfqueue_fairq()
870 opts->lssc_d = 0; in eval_pfqueue_fairq()
874 /* First child initializes the parent's service curve accumulator. */ in eval_pfqueue_fairq()
875 if (parent->meta.children == 1) in eval_pfqueue_fairq()
876 LIST_INIT(&parent->meta.lssc); in eval_pfqueue_fairq()
878 if (parent->pa.pq_u.fairq_opts.flags & FARF_DEFAULTCLASS) { in eval_pfqueue_fairq()
880 pa->qname, pa->parent); in eval_pfqueue_fairq()
881 return (-1); in eval_pfqueue_fairq()
884 if (pa->pq_u.fairq_opts.flags & FARF_DEFAULTCLASS) in eval_pfqueue_fairq()
885 if_ppa->meta.default_classes++; in eval_pfqueue_fairq()
888 if (opts->lssc_m2 == 0) in eval_pfqueue_fairq()
889 opts->lssc_m2 = pa->bandwidth; in eval_pfqueue_fairq()
893 * for the real-time service curve, the sum of the service curves in eval_pfqueue_fairq()
895 * not to over-commit the actual interface bandwidth. in eval_pfqueue_fairq()
896 * for the link-sharing service curve, the sum of the child service in eval_pfqueue_fairq()
897 * curve should not exceed the parent service curve. in eval_pfqueue_fairq()
898 * for the upper-limit service curve, the assigned bandwidth should in eval_pfqueue_fairq()
899 * be smaller than the interface bandwidth, and the upper-limit should in eval_pfqueue_fairq()
900 * be larger than the real-time service curve when both are defined. in eval_pfqueue_fairq()
904 if (opts->lssc_m2 != 0) { in eval_pfqueue_fairq()
906 sc.m1 = opts->lssc_m1; in eval_pfqueue_fairq()
907 sc.d = opts->lssc_d; in eval_pfqueue_fairq()
908 sc.m2 = opts->lssc_m2; in eval_pfqueue_fairq()
909 gsc_add_sc(&parent->meta.lssc, &sc); in eval_pfqueue_fairq()
910 /* compare the sum of the children with parent's sc */ in eval_pfqueue_fairq()
911 sc.m1 = parent->pa.pq_u.fairq_opts.lssc_m1; in eval_pfqueue_fairq()
912 sc.d = parent->pa.pq_u.fairq_opts.lssc_d; in eval_pfqueue_fairq()
913 sc.m2 = parent->pa.pq_u.fairq_opts.lssc_m2; in eval_pfqueue_fairq()
914 if (!is_gsc_under_sc(&parent->meta.lssc, &sc)) { in eval_pfqueue_fairq()
915 warnx("link-sharing sc exceeds parent's sc"); in eval_pfqueue_fairq()
916 return (-1); in eval_pfqueue_fairq()
928 if (if_ppa->meta.default_classes != 1) { in check_commit_hfsc()
929 warnx("should have one default queue on %s", if_ppa->pa.ifname); in check_commit_hfsc()
940 if (if_ppa->meta.default_classes != 1) { in check_commit_fairq()
941 warnx("should have one default queue on %s", if_ppa->pa.ifname); in check_commit_fairq()
953 opts = &a->pq_u.hfsc_opts; in print_hfsc_opts()
957 rtsc = &qopts->data.hfsc_opts.realtime; in print_hfsc_opts()
958 lssc = &qopts->data.hfsc_opts.linkshare; in print_hfsc_opts()
959 ulsc = &qopts->data.hfsc_opts.upperlimit; in print_hfsc_opts()
962 if (opts->flags || opts->rtsc_m2 != 0 || opts->ulsc_m2 != 0 || in print_hfsc_opts()
963 (opts->lssc_m2 != 0 && (opts->lssc_m2 != a->bandwidth || in print_hfsc_opts()
964 opts->lssc_d != 0))) { in print_hfsc_opts()
966 if (opts->flags & HFCF_RED) in print_hfsc_opts()
968 if (opts->flags & HFCF_ECN) in print_hfsc_opts()
970 if (opts->flags & HFCF_RIO) in print_hfsc_opts()
972 if (opts->flags & HFCF_CODEL) in print_hfsc_opts()
974 if (opts->flags & HFCF_CLEARDSCP) in print_hfsc_opts()
976 if (opts->flags & HFCF_DEFAULTCLASS) in print_hfsc_opts()
978 if (opts->rtsc_m2 != 0) in print_hfsc_opts()
979 print_hfsc_sc("realtime", opts->rtsc_m1, opts->rtsc_d, in print_hfsc_opts()
980 opts->rtsc_m2, rtsc); in print_hfsc_opts()
981 if (opts->lssc_m2 != 0 && (opts->lssc_m2 != a->bandwidth || in print_hfsc_opts()
982 opts->lssc_d != 0)) in print_hfsc_opts()
983 print_hfsc_sc("linkshare", opts->lssc_m1, opts->lssc_d, in print_hfsc_opts()
984 opts->lssc_m2, lssc); in print_hfsc_opts()
985 if (opts->ulsc_m2 != 0) in print_hfsc_opts()
986 print_hfsc_sc("upperlimit", opts->ulsc_m1, opts->ulsc_d, in print_hfsc_opts()
987 opts->ulsc_m2, ulsc); in print_hfsc_opts()
1000 opts = &a->pq_u.codel_opts; in print_codel_opts()
1001 if (opts->target || opts->interval || opts->ecn) { in print_codel_opts()
1003 if (opts->target) in print_codel_opts()
1004 printf(" target %d", opts->target); in print_codel_opts()
1005 if (opts->interval) in print_codel_opts()
1006 printf(" interval %d", opts->interval); in print_codel_opts()
1007 if (opts->ecn) in print_codel_opts()
1023 opts = &a->pq_u.fairq_opts; in print_fairq_opts()
1027 loc_lssc = &qopts->data.fairq_opts.linkshare; in print_fairq_opts()
1029 if (opts->flags || in print_fairq_opts()
1030 (opts->lssc_m2 != 0 && (opts->lssc_m2 != a->bandwidth || in print_fairq_opts()
1031 opts->lssc_d != 0))) { in print_fairq_opts()
1033 if (opts->flags & FARF_RED) in print_fairq_opts()
1035 if (opts->flags & FARF_ECN) in print_fairq_opts()
1037 if (opts->flags & FARF_RIO) in print_fairq_opts()
1039 if (opts->flags & FARF_CODEL) in print_fairq_opts()
1041 if (opts->flags & FARF_CLEARDSCP) in print_fairq_opts()
1043 if (opts->flags & FARF_DEFAULTCLASS) in print_fairq_opts()
1045 if (opts->lssc_m2 != 0 && (opts->lssc_m2 != a->bandwidth || in print_fairq_opts()
1046 opts->lssc_d != 0)) in print_fairq_opts()
1047 print_fairq_sc("linkshare", opts->lssc_m1, opts->lssc_d, in print_fairq_opts()
1048 opts->lssc_m2, loc_lssc); in print_fairq_opts()
1066 if (sc->d != 0) in gsc_add_sc()
1067 gsc_add_seg(gsc, 0.0, 0.0, (double)sc->d, (double)sc->m1); in gsc_add_sc()
1068 gsc_add_seg(gsc, (double)sc->d, 0.0, INFINITY, (double)sc->m2); in gsc_add_sc()
1073 * their y-coordinates no larger than a given two-piece linear
1086 if (s->m != 0) in is_gsc_under_sc()
1100 if (s->y > sc_x2y(sc, s->x)) in is_gsc_under_sc()
1107 if (last->m > sc->m2) in is_gsc_under_sc()
1109 if (last->x < sc->d && last->m > sc->m1) { in is_gsc_under_sc()
1110 y = last->y + (sc->d - last->x) * last->m; in is_gsc_under_sc()
1111 if (y > sc_x2y(sc, sc->d)) in is_gsc_under_sc()
1128 if (s->x == x) in gsc_getentry()
1130 else if (s->x < x) in gsc_getentry()
1140 new->x = x; in gsc_getentry()
1142 new->d = 0; in gsc_getentry()
1143 else if (s->x == INFINITY) in gsc_getentry()
1144 new->d = INFINITY; in gsc_getentry()
1146 new->d = s->x - x; in gsc_getentry()
1149 new->y = 0; in gsc_getentry()
1150 new->m = 0; in gsc_getentry()
1158 prev->d = INFINITY; in gsc_getentry()
1159 if (prev->m == 0) in gsc_getentry()
1160 new->y = prev->y; in gsc_getentry()
1162 new->y = INFINITY; in gsc_getentry()
1164 prev->d = x - prev->x; in gsc_getentry()
1165 new->y = prev->d * prev->m + prev->y; in gsc_getentry()
1167 new->m = prev->m; in gsc_getentry()
1187 return (-1); in gsc_add_seg()
1190 s->m += m; in gsc_add_seg()
1191 s->y += y + (s->x - x) * m; in gsc_add_seg()
1196 s->y += m * d; in gsc_add_seg()
1202 /* get y-projection of a service curve */
1208 if (x <= (double)sc->d) in sc_x2y()
1210 y = x * (double)sc->m1; in sc_x2y()
1213 y = (double)sc->d * (double)sc->m1 in sc_x2y()
1214 + (x - (double)sc->d) * (double)sc->m2; in sc_x2y()
1225 rate2str(double rate) in rate2str() argument
1237 for (i = 0; rate >= 1000 && i <= 3; i++) in rate2str()
1238 rate /= 1000; in rate2str()
1240 if ((int)(rate * 100) % 100) in rate2str()
1241 snprintf(buf, RATESTR_MAX, "%.2f%cb", rate, unit[i]); in rate2str()
1243 snprintf(buf, RATESTR_MAX, "%d%cb", (int)rate, unit[i]); in rate2str()
1261 if (ioctl(s, SIOCGIFDATA, (caddr_t)&ifr) == -1) in getifspeed()
1277 if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) == -1) in getifmtu()
1297 switch (pa->scheduler) { in eval_queue_opts()
1299 pa->pq_u.cbq_opts = opts->data.cbq_opts; in eval_queue_opts()
1302 pa->pq_u.priq_opts = opts->data.priq_opts; in eval_queue_opts()
1305 pa->pq_u.hfsc_opts.flags = opts->data.hfsc_opts.flags; in eval_queue_opts()
1306 if (opts->data.hfsc_opts.linkshare.used) { in eval_queue_opts()
1307 pa->pq_u.hfsc_opts.lssc_m1 = in eval_queue_opts()
1308 eval_bwspec(&opts->data.hfsc_opts.linkshare.m1, in eval_queue_opts()
1310 pa->pq_u.hfsc_opts.lssc_m2 = in eval_queue_opts()
1311 eval_bwspec(&opts->data.hfsc_opts.linkshare.m2, in eval_queue_opts()
1313 pa->pq_u.hfsc_opts.lssc_d = in eval_queue_opts()
1314 opts->data.hfsc_opts.linkshare.d; in eval_queue_opts()
1316 if (opts->data.hfsc_opts.realtime.used) { in eval_queue_opts()
1317 pa->pq_u.hfsc_opts.rtsc_m1 = in eval_queue_opts()
1318 eval_bwspec(&opts->data.hfsc_opts.realtime.m1, in eval_queue_opts()
1320 pa->pq_u.hfsc_opts.rtsc_m2 = in eval_queue_opts()
1321 eval_bwspec(&opts->data.hfsc_opts.realtime.m2, in eval_queue_opts()
1323 pa->pq_u.hfsc_opts.rtsc_d = in eval_queue_opts()
1324 opts->data.hfsc_opts.realtime.d; in eval_queue_opts()
1326 if (opts->data.hfsc_opts.upperlimit.used) { in eval_queue_opts()
1327 pa->pq_u.hfsc_opts.ulsc_m1 = in eval_queue_opts()
1328 eval_bwspec(&opts->data.hfsc_opts.upperlimit.m1, in eval_queue_opts()
1330 pa->pq_u.hfsc_opts.ulsc_m2 = in eval_queue_opts()
1331 eval_bwspec(&opts->data.hfsc_opts.upperlimit.m2, in eval_queue_opts()
1333 pa->pq_u.hfsc_opts.ulsc_d = in eval_queue_opts()
1334 opts->data.hfsc_opts.upperlimit.d; in eval_queue_opts()
1338 pa->pq_u.fairq_opts.flags = opts->data.fairq_opts.flags; in eval_queue_opts()
1339 pa->pq_u.fairq_opts.nbuckets = opts->data.fairq_opts.nbuckets; in eval_queue_opts()
1340 pa->pq_u.fairq_opts.hogs_m1 = in eval_queue_opts()
1341 eval_bwspec(&opts->data.fairq_opts.hogs_bw, ref_bw); in eval_queue_opts()
1343 if (opts->data.fairq_opts.linkshare.used) { in eval_queue_opts()
1344 pa->pq_u.fairq_opts.lssc_m1 = in eval_queue_opts()
1345 eval_bwspec(&opts->data.fairq_opts.linkshare.m1, in eval_queue_opts()
1347 pa->pq_u.fairq_opts.lssc_m2 = in eval_queue_opts()
1348 eval_bwspec(&opts->data.fairq_opts.linkshare.m2, in eval_queue_opts()
1350 pa->pq_u.fairq_opts.lssc_d = in eval_queue_opts()
1351 opts->data.fairq_opts.linkshare.d; in eval_queue_opts()
1355 pa->pq_u.codel_opts.target = opts->data.codel_opts.target; in eval_queue_opts()
1356 pa->pq_u.codel_opts.interval = opts->data.codel_opts.interval; in eval_queue_opts()
1357 pa->pq_u.codel_opts.ecn = opts->data.codel_opts.ecn; in eval_queue_opts()
1361 opts->qtype); in eval_queue_opts()
1370 * If absolute bandwidth if set, return the lesser of that value and the
1373 * 32-bit limited, as the root/interface bandwidth (top-level reference
1376 * Otherwise, if the absolute bandwidth is not set, return given percentage
1382 if (bw->bw_absolute > 0) in eval_bwspec()
1383 return (MIN(bw->bw_absolute, ref_bw)); in eval_bwspec()
1385 if (bw->bw_percent > 0) in eval_bwspec()
1386 return (ref_bw / 100 * bw->bw_percent); in eval_bwspec()
1399 if (sc != NULL && sc->m1.bw_percent > 0) in print_hfsc_sc()
1400 printf("%u%%", sc->m1.bw_percent); in print_hfsc_sc()
1406 if (sc != NULL && sc->m2.bw_percent > 0) in print_hfsc_sc()
1407 printf(" %u%%", sc->m2.bw_percent); in print_hfsc_sc()
1423 if (sc != NULL && sc->m1.bw_percent > 0) in print_fairq_sc()
1424 printf("%u%%", sc->m1.bw_percent); in print_fairq_sc()
1430 if (sc != NULL && sc->m2.bw_percent > 0) in print_fairq_sc()
1431 printf(" %u%%", sc->m2.bw_percent); in print_fairq_sc()