sch_fq.c (fb420d5d91c1274d5966917725e71f27ed092a85) | sch_fq.c (76a9ebe811fb3d0605cb084f1ae6be5610541865) |
---|---|
1/* 2 * net/sched/sch_fq.c Fair Queue Packet Scheduler (per flow pacing) 3 * 4 * Copyright (C) 2013-2015 Eric Dumazet <edumazet@google.com> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version --- 78 unchanged lines hidden (view full) --- 87 struct rb_root delayed; /* for rate limited flows */ 88 u64 time_next_delayed_flow; 89 unsigned long unthrottle_latency_ns; 90 91 struct fq_flow internal; /* for non classified or high prio packets */ 92 u32 quantum; 93 u32 initial_quantum; 94 u32 flow_refill_delay; | 1/* 2 * net/sched/sch_fq.c Fair Queue Packet Scheduler (per flow pacing) 3 * 4 * Copyright (C) 2013-2015 Eric Dumazet <edumazet@google.com> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version --- 78 unchanged lines hidden (view full) --- 87 struct rb_root delayed; /* for rate limited flows */ 88 u64 time_next_delayed_flow; 89 unsigned long unthrottle_latency_ns; 90 91 struct fq_flow internal; /* for non classified or high prio packets */ 92 u32 quantum; 93 u32 initial_quantum; 94 u32 flow_refill_delay; |
95 u32 flow_max_rate; /* optional max rate per flow */ | |
96 u32 flow_plimit; /* max packets per flow */ | 95 u32 flow_plimit; /* max packets per flow */ |
96 unsigned long flow_max_rate; /* optional max rate per flow */ |
|
97 u32 orphan_mask; /* mask for orphaned skb */ 98 u32 low_rate_threshold; 99 struct rb_root *fq_root; 100 u8 rate_enable; 101 u8 fq_trees_log; 102 103 u32 flows; 104 u32 inactive_flows; --- 306 unchanged lines hidden (view full) --- 411 412static struct sk_buff *fq_dequeue(struct Qdisc *sch) 413{ 414 struct fq_sched_data *q = qdisc_priv(sch); 415 u64 now = ktime_get_ns(); 416 struct fq_flow_head *head; 417 struct sk_buff *skb; 418 struct fq_flow *f; | 97 u32 orphan_mask; /* mask for orphaned skb */ 98 u32 low_rate_threshold; 99 struct rb_root *fq_root; 100 u8 rate_enable; 101 u8 fq_trees_log; 102 103 u32 flows; 104 u32 inactive_flows; --- 306 unchanged lines hidden (view full) --- 411 412static struct sk_buff *fq_dequeue(struct Qdisc *sch) 413{ 414 struct fq_sched_data *q = qdisc_priv(sch); 415 u64 now = ktime_get_ns(); 416 struct fq_flow_head *head; 417 struct sk_buff *skb; 418 struct fq_flow *f; |
419 u32 rate, plen; | 419 unsigned long rate; 420 u32 plen; |
420 421 skb = fq_dequeue_head(sch, &q->internal); 422 if (skb) 423 goto out; 424 fq_check_throttled(q, now); 425begin: 426 head = &q->new_flows; 427 if (!head->first) { --- 52 unchanged lines hidden (view full) --- 480 if (rate <= q->low_rate_threshold) { 481 f->credit = 0; 482 plen = qdisc_pkt_len(skb); 483 } else { 484 plen = max(qdisc_pkt_len(skb), q->quantum); 485 if (f->credit > 0) 486 goto out; 487 } | 421 422 skb = fq_dequeue_head(sch, &q->internal); 423 if (skb) 424 goto out; 425 fq_check_throttled(q, now); 426begin: 427 head = &q->new_flows; 428 if (!head->first) { --- 52 unchanged lines hidden (view full) --- 481 if (rate <= q->low_rate_threshold) { 482 f->credit = 0; 483 plen = qdisc_pkt_len(skb); 484 } else { 485 plen = max(qdisc_pkt_len(skb), q->quantum); 486 if (f->credit > 0) 487 goto out; 488 } |
488 if (rate != ~0U) { | 489 if (rate != ~0UL) { |
489 u64 len = (u64)plen * NSEC_PER_SEC; 490 491 if (likely(rate)) | 490 u64 len = (u64)plen * NSEC_PER_SEC; 491 492 if (likely(rate)) |
492 do_div(len, rate); | 493 len = div64_ul(len, rate); |
493 /* Since socket rate can change later, 494 * clamp the delay to 1 second. 495 * Really, providers of too big packets should be fixed ! 496 */ 497 if (unlikely(len > NSEC_PER_SEC)) { 498 len = NSEC_PER_SEC; 499 q->stat_pkts_too_long++; 500 } --- 195 unchanged lines hidden (view full) --- 696 697 if (tb[TCA_FQ_INITIAL_QUANTUM]) 698 q->initial_quantum = nla_get_u32(tb[TCA_FQ_INITIAL_QUANTUM]); 699 700 if (tb[TCA_FQ_FLOW_DEFAULT_RATE]) 701 pr_warn_ratelimited("sch_fq: defrate %u ignored.\n", 702 nla_get_u32(tb[TCA_FQ_FLOW_DEFAULT_RATE])); 703 | 494 /* Since socket rate can change later, 495 * clamp the delay to 1 second. 496 * Really, providers of too big packets should be fixed ! 497 */ 498 if (unlikely(len > NSEC_PER_SEC)) { 499 len = NSEC_PER_SEC; 500 q->stat_pkts_too_long++; 501 } --- 195 unchanged lines hidden (view full) --- 697 698 if (tb[TCA_FQ_INITIAL_QUANTUM]) 699 q->initial_quantum = nla_get_u32(tb[TCA_FQ_INITIAL_QUANTUM]); 700 701 if (tb[TCA_FQ_FLOW_DEFAULT_RATE]) 702 pr_warn_ratelimited("sch_fq: defrate %u ignored.\n", 703 nla_get_u32(tb[TCA_FQ_FLOW_DEFAULT_RATE])); 704 |
704 if (tb[TCA_FQ_FLOW_MAX_RATE]) 705 q->flow_max_rate = nla_get_u32(tb[TCA_FQ_FLOW_MAX_RATE]); | 705 if (tb[TCA_FQ_FLOW_MAX_RATE]) { 706 u32 rate = nla_get_u32(tb[TCA_FQ_FLOW_MAX_RATE]); |
706 | 707 |
708 q->flow_max_rate = (rate == ~0U) ? ~0UL : rate; 709 } |
|
707 if (tb[TCA_FQ_LOW_RATE_THRESHOLD]) 708 q->low_rate_threshold = 709 nla_get_u32(tb[TCA_FQ_LOW_RATE_THRESHOLD]); 710 711 if (tb[TCA_FQ_RATE_ENABLE]) { 712 u32 enable = nla_get_u32(tb[TCA_FQ_RATE_ENABLE]); 713 714 if (enable <= 1) --- 46 unchanged lines hidden (view full) --- 761 struct fq_sched_data *q = qdisc_priv(sch); 762 int err; 763 764 sch->limit = 10000; 765 q->flow_plimit = 100; 766 q->quantum = 2 * psched_mtu(qdisc_dev(sch)); 767 q->initial_quantum = 10 * psched_mtu(qdisc_dev(sch)); 768 q->flow_refill_delay = msecs_to_jiffies(40); | 710 if (tb[TCA_FQ_LOW_RATE_THRESHOLD]) 711 q->low_rate_threshold = 712 nla_get_u32(tb[TCA_FQ_LOW_RATE_THRESHOLD]); 713 714 if (tb[TCA_FQ_RATE_ENABLE]) { 715 u32 enable = nla_get_u32(tb[TCA_FQ_RATE_ENABLE]); 716 717 if (enable <= 1) --- 46 unchanged lines hidden (view full) --- 764 struct fq_sched_data *q = qdisc_priv(sch); 765 int err; 766 767 sch->limit = 10000; 768 q->flow_plimit = 100; 769 q->quantum = 2 * psched_mtu(qdisc_dev(sch)); 770 q->initial_quantum = 10 * psched_mtu(qdisc_dev(sch)); 771 q->flow_refill_delay = msecs_to_jiffies(40); |
769 q->flow_max_rate = ~0U; | 772 q->flow_max_rate = ~0UL; |
770 q->time_next_delayed_flow = ~0ULL; 771 q->rate_enable = 1; 772 q->new_flows.first = NULL; 773 q->old_flows.first = NULL; 774 q->delayed = RB_ROOT; 775 q->fq_root = NULL; 776 q->fq_trees_log = ilog2(1024); 777 q->orphan_mask = 1024 - 1; --- 19 unchanged lines hidden (view full) --- 797 798 /* TCA_FQ_FLOW_DEFAULT_RATE is not used anymore */ 799 800 if (nla_put_u32(skb, TCA_FQ_PLIMIT, sch->limit) || 801 nla_put_u32(skb, TCA_FQ_FLOW_PLIMIT, q->flow_plimit) || 802 nla_put_u32(skb, TCA_FQ_QUANTUM, q->quantum) || 803 nla_put_u32(skb, TCA_FQ_INITIAL_QUANTUM, q->initial_quantum) || 804 nla_put_u32(skb, TCA_FQ_RATE_ENABLE, q->rate_enable) || | 773 q->time_next_delayed_flow = ~0ULL; 774 q->rate_enable = 1; 775 q->new_flows.first = NULL; 776 q->old_flows.first = NULL; 777 q->delayed = RB_ROOT; 778 q->fq_root = NULL; 779 q->fq_trees_log = ilog2(1024); 780 q->orphan_mask = 1024 - 1; --- 19 unchanged lines hidden (view full) --- 800 801 /* TCA_FQ_FLOW_DEFAULT_RATE is not used anymore */ 802 803 if (nla_put_u32(skb, TCA_FQ_PLIMIT, sch->limit) || 804 nla_put_u32(skb, TCA_FQ_FLOW_PLIMIT, q->flow_plimit) || 805 nla_put_u32(skb, TCA_FQ_QUANTUM, q->quantum) || 806 nla_put_u32(skb, TCA_FQ_INITIAL_QUANTUM, q->initial_quantum) || 807 nla_put_u32(skb, TCA_FQ_RATE_ENABLE, q->rate_enable) || |
805 nla_put_u32(skb, TCA_FQ_FLOW_MAX_RATE, q->flow_max_rate) || | 808 nla_put_u32(skb, TCA_FQ_FLOW_MAX_RATE, 809 min_t(unsigned long, q->flow_max_rate, ~0U)) || |
806 nla_put_u32(skb, TCA_FQ_FLOW_REFILL_DELAY, 807 jiffies_to_usecs(q->flow_refill_delay)) || 808 nla_put_u32(skb, TCA_FQ_ORPHAN_MASK, q->orphan_mask) || 809 nla_put_u32(skb, TCA_FQ_LOW_RATE_THRESHOLD, 810 q->low_rate_threshold) || 811 nla_put_u32(skb, TCA_FQ_BUCKETS_LOG, q->fq_trees_log)) 812 goto nla_put_failure; 813 --- 73 unchanged lines hidden --- | 810 nla_put_u32(skb, TCA_FQ_FLOW_REFILL_DELAY, 811 jiffies_to_usecs(q->flow_refill_delay)) || 812 nla_put_u32(skb, TCA_FQ_ORPHAN_MASK, q->orphan_mask) || 813 nla_put_u32(skb, TCA_FQ_LOW_RATE_THRESHOLD, 814 q->low_rate_threshold) || 815 nla_put_u32(skb, TCA_FQ_BUCKETS_LOG, q->fq_trees_log)) 816 goto nla_put_failure; 817 --- 73 unchanged lines hidden --- |