diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-07-20 09:22:40 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-07-20 09:22:40 -0700 |
commit | ba5cad5145b11345fb195b79c806a02d9545bf0b (patch) | |
tree | bc6e3393ad75b04c9352539447436a537331a6c5 /lib/Vyatta | |
parent | 97c6b53404e71fe1b6ccb617dafea346f8211ee4 (diff) | |
download | vyatta-cfg-qos-ba5cad5145b11345fb195b79c806a02d9545bf0b.tar.gz vyatta-cfg-qos-ba5cad5145b11345fb195b79c806a02d9545bf0b.zip |
Allow larger queue size for sub-queues in Shaper and RoundRobin
For queue-type (other than fair-queue), it is allowable to have larger queue size.
Move validation into class checking.
Diffstat (limited to 'lib/Vyatta')
-rw-r--r-- | lib/Vyatta/Qos/RoundRobin.pm | 20 | ||||
-rw-r--r-- | lib/Vyatta/Qos/ShaperClass.pm | 117 |
2 files changed, 89 insertions, 48 deletions
diff --git a/lib/Vyatta/Qos/RoundRobin.pm b/lib/Vyatta/Qos/RoundRobin.pm index b7d72b2..d9e90e9 100644 --- a/lib/Vyatta/Qos/RoundRobin.pm +++ b/lib/Vyatta/Qos/RoundRobin.pm @@ -26,8 +26,10 @@ require Vyatta::Qos::ShaperClass; # Create a new instance based on config information sub new { my ( $that, $config, $name ) = @_; - my @classes = _getClasses( $config->setLevel() ); + + _checkClasses( @classes ); + my $self = {}; my $class = ref($that) || $that; bless $self, $class; @@ -36,6 +38,22 @@ sub new { return $self; } +# Check constraints on sub queues +sub _checkClasses { + my $level = shift; + + foreach my $class (@_) { + my $level = $class->{level}; + my $qtype = $class->{_qdisc}; + my $qlimit = $class->{_limit}; + + if ($qtype eq 'random-detect' && defined($qlimit) && $qlimit >= 128) { + print STDERR "Configuration error in: $level\n"; + die "queue limit must be between 1 and 127 for random-detect\n"; + } + } +} + sub _getClasses { my $level = shift; my @classes; diff --git a/lib/Vyatta/Qos/ShaperClass.pm b/lib/Vyatta/Qos/ShaperClass.pm index 7082aa3..088d37f 100644 --- a/lib/Vyatta/Qos/ShaperClass.pm +++ b/lib/Vyatta/Qos/ShaperClass.pm @@ -96,53 +96,6 @@ sub _getPercentRate { return $rate; } -sub rateCheck { - my ( $self, $limit, $level ) = @_; - - my $rate = _getPercentRate( $self->{_rate}, $limit ); - if ( $rate > $limit ) { - print STDERR "Configuration error in: $level\n"; - printf STDERR - "The bandwidth reserved for this class (%dKbps) must be less than\n", - $rate / 1000; - printf STDERR "the bandwidth for the overall policy (%dKbps)\n", - $limit / 1000; - exit 1; - } - - my $ceil = _getPercentRate( $self->{_ceiling}, $limit ); - if ( defined $ceil && $ceil < $rate ) { - print STDERR "Configuration error in: $level\n"; - printf STDERR -"The bandwidth ceiling for this class (%dKbps) must be greater or equal to\n", - $ceil / 1000; - printf STDERR "the reserved bandwidth for the class (%dKbps)\n", - $rate / 1000; - exit 1; - } - - my $qlimit = $self->{_limit}; - if ( $self->{_qdisc} eq 'random-detect' ) { - my $qmax = redQsize($rate); - if ( defined($qlimit) && $qlimit * AVGPKT < $qmax ) { - print STDERR "Configuration error in: $level\n"; - printf STDERR -"The queue limit (%d) is too small, must be greater than %d when using random-detect\n", - $level, $qmax / AVGPKT; - exit 1; - } - - if ( $qmax < 3 * AVGPKT ) { - my $minbw = ( 3 * AVGPKT * 8 ) / LATENCY; - - print STDERR "Configuration error in: $level\n"; - die -"Random-detect queue type requires effective bandwidth of %d Kbit/sec or greater\n", - $minbw; - } - } -} - sub prioQdisc { my ( $self, $dev, $rate ) = @_; my $prio_id = 0x4000 + $self->{id}; @@ -166,6 +119,16 @@ sub sfqQdisc { print "\n"; } +sub sfqValidate { + my ( $self, $level ) = @_; + my $limit = $self->{_limit}; + + if ( defined $limit && $limit > 127 ) { + print STDERR "Configuration error in: $level\n"; + die "queue limit must be between 1 and 127 for random-detect\n"; + } +} + sub fifoQdisc { my ( $self, $dev, $rate ) = @_; @@ -210,6 +173,29 @@ sub redQdisc { printf " burst %d probability 0.1 bandwidth %s ecn\n", $burst, $rate; } +sub redValidate { + my ( $self, $level, $rate ) = @_; + my $limit = $self->{_limit}; + my $qmax = redQsize($rate); + + if ( defined($limit) && $limit * AVGPKT < $qmax ) { + print STDERR "Configuration error in: $level\n"; + printf STDERR +"The queue limit (%d) is too small, must be greater than %d when using random-detect\n", + $level, $qmax / AVGPKT; + exit 1; + } + + if ( $qmax < 3 * AVGPKT ) { + my $minbw = ( 3 * AVGPKT * 8 ) / LATENCY; + + print STDERR "Configuration error in: $level\n"; + die +"Random-detect queue type requires effective bandwidth of %d Kbit/sec or greater\n", + $minbw; + } +} + my %qdiscOptions = ( 'priority' => \&prioQdisc, 'fair-queue' => \&sfqQdisc, @@ -217,6 +203,43 @@ my %qdiscOptions = ( 'drop-tail' => \&fifoQdisc, ); +my %qdiscValidate = ( + 'fair-queue' => \&sfqValidate, + 'random-detect' => \&redValidate, +); + +sub rateCheck { + my ( $self, $ifspeed, $level ) = @_; + + my $rate = _getPercentRate( $self->{_rate}, $ifspeed ); + if ( $rate > $ifspeed ) { + print STDERR "Configuration error in: $level\n"; + printf STDERR + "The bandwidth reserved for this class (%dKbps) must be less than\n", + $rate / 1000; + printf STDERR "the bandwidth for the overall policy (%dKbps)\n", + $ifspeed / 1000; + exit 1; + } + + my $ceil = _getPercentRate( $self->{_ceiling}, $ifspeed ); + if ( defined $ceil && $ceil < $rate ) { + print STDERR "Configuration error in: $level\n"; + printf STDERR +"The bandwidth ceiling for this class (%dKbps) must be greater or equal to\n", + $ceil / 1000; + printf STDERR "the reserved bandwidth for the class (%dKbps)\n", + $rate / 1000; + exit 1; + } + + my $qtype = $self->{_qdisc}; + my $q = $qdiscValidate{$qtype}; + return unless $q; + + $q->( $self, $level, $rate ); +} + sub get_rate { my ( $self, $speed ) = @_; |