diff options
author | Daniil Baturin <daniil@baturin.org> | 2014-10-30 05:08:53 +0600 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2014-10-30 05:08:53 +0600 |
commit | 7a5a8500091589f0ede3d5a1dbc8b6b4b3fabf1d (patch) | |
tree | fddf140c7fd91bdbd581738d592292315f155d75 | |
parent | 5f32c6830b1b3eda523ae451435ff26e04c1612f (diff) | |
parent | 2f97a9155cda583132408bbd29637010386177ed (diff) | |
download | vyatta-cfg-system-7a5a8500091589f0ede3d5a1dbc8b6b4b3fabf1d.tar.gz vyatta-cfg-system-7a5a8500091589f0ede3d5a1dbc8b6b4b3fabf1d.zip |
Merge pull request #28 from jhendryUK/ethernet_tso_options
Bug #365: Ethernet tso options
6 files changed, 107 insertions, 1 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index c455bb74..621596a0 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -50,7 +50,7 @@ my ($dev, $mac, $mac_update); my %skip_interface; my ($check_name, $show_names, $vif_name, $warn_name); my ($check_up, $dhcp_command, $allowed_speed); -my (@speed_duplex, @addr_commit, @check_speed); +my (@speed_duplex, @addr_commit, @check_speed, @offload_option); sub usage { print <<EOF; @@ -62,6 +62,7 @@ Usage: $0 --dev=<interface> --check=<type> $0 --dev=<interface> --check-speed=speed,duplex $0 --dev=<interface> --allowed-speed $0 --dev=<interface> --isup + $0 --dev=<interface> --offload-settings={tcp,udp,segmentation,receive} {value} $0 --show=<type> EOF exit 1; @@ -81,6 +82,7 @@ GetOptions("valid-addr-commit=s{,}" => \@addr_commit, "speed-duplex=s{2}" => \@speed_duplex, "check-speed=s{2}" => \@check_speed, "allowed-speed" => \$allowed_speed, + "offload-settings=s{2}" => \@offload_option, ) or usage(); is_valid_addr_commit($dev, @addr_commit) if (@addr_commit); @@ -94,6 +96,7 @@ is_up($dev) if ($check_up); set_speed_duplex($dev, @speed_duplex) if (@speed_duplex); check_speed_duplex($dev, @check_speed) if (@check_speed); allowed_speed($dev) if ($allowed_speed); +set_offload_setting($dev, @offload_option) if (@offload_option); exit 0; sub is_ip_configured { @@ -571,3 +574,42 @@ sub allowed_speed { close $ethtool; print 'auto ', join(' ', sort keys %speeds), "\n"; } + +sub get_offload_setting { + my ($dev, $option) = @_; + my ($val); + + open( my $ethtool, '-|', "$ETHTOOL -k $dev 2>&1" ) or die "ethtool failed: $!\n"; + while (<$ethtool>) { + next if ($_ !~ m/$option:/); + chomp; + $val = (split(/: /, $_))[1]; + } + close $ethtool; + return ($val); + +} + +sub set_offload_setting { + my ($intf, $option, $nvalue) = @_; + die "Missing --dev argument\n" unless $intf; + + my $ovalue = get_offload_setting($intf, $option); + + my %ethtool_opts = ( 'generic-receive-offload' => 'gro', + 'generic-segmentation-offload' => 'gso', + 'tcp-segmentation-offload' => 'tso', + 'udp-fragmentation-offload' => 'ufo', + ); + + if (defined($nvalue) && $nvalue ne $ovalue) { + my $cmd = "$ETHTOOL -K $intf $ethtool_opts{$option} $nvalue"; + + system($cmd); + if ($? >> 8) { + die "exec of $ETHTOOL failed: '$cmd'"; + } + } + +} + diff --git a/templates/interfaces/ethernet/node.tag/offload/generic-receive-offload/node.def b/templates/interfaces/ethernet/node.tag/offload/generic-receive-offload/node.def new file mode 100644 index 00000000..3491e074 --- /dev/null +++ b/templates/interfaces/ethernet/node.tag/offload/generic-receive-offload/node.def @@ -0,0 +1,16 @@ +# +# Configuration template for offload settings +# + +priority: 319 # Failure barrier only - no ordering constraints + +type: txt +help: Configure generic-receive-offload option +val_help: on; Enable generic-receive-offload +val_help: off; Disable generic-receive-offload + +syntax:expression: $VAR(@) == "on" || $VAR(@) == "off" ; "Must be either 'on' or 'off'" + +update: sudo /opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(../../@) --offload-settings generic-receive-offload $VAR(@) + + diff --git a/templates/interfaces/ethernet/node.tag/offload/generic-segmentation-offload/node.def b/templates/interfaces/ethernet/node.tag/offload/generic-segmentation-offload/node.def new file mode 100644 index 00000000..1ed7133b --- /dev/null +++ b/templates/interfaces/ethernet/node.tag/offload/generic-segmentation-offload/node.def @@ -0,0 +1,16 @@ +# +# Configuration template for offload settings +# + +priority: 319 # Failure barrier only - no ordering constraints + +type: txt +help: Configure generic-segmentation-offload option +val_help: on; Enable generic-segmentation-offload +val_help: off; Disable generic-segmentation-offload + +syntax:expression: $VAR(@) == "on" || $VAR(@) == "off" ; "Must be either 'on' or 'off'" + +update: sudo /opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(../../@) --offload-settings generic-segmentation-offload $VAR(@) + + diff --git a/templates/interfaces/ethernet/node.tag/offload/node.def b/templates/interfaces/ethernet/node.tag/offload/node.def new file mode 100644 index 00000000..180a9e7c --- /dev/null +++ b/templates/interfaces/ethernet/node.tag/offload/node.def @@ -0,0 +1 @@ +help: Configuraable offload settings diff --git a/templates/interfaces/ethernet/node.tag/offload/tcp-segmentation-offload/node.def b/templates/interfaces/ethernet/node.tag/offload/tcp-segmentation-offload/node.def new file mode 100644 index 00000000..95a37369 --- /dev/null +++ b/templates/interfaces/ethernet/node.tag/offload/tcp-segmentation-offload/node.def @@ -0,0 +1,15 @@ +# +# Configuration template for offload settings +# + +priority: 319 # Failure barrier only - no ordering constraints + +type: txt +help: Configure tcp-segmentation-offload option +val_help: on; Enable tcp-segmentation-offload +val_help: off; Disable tcp-segmentation-offload + +syntax:expression: $VAR(@) == "on" || $VAR(@) == "off" ; "Must be either 'on' or 'off'" + +update: sudo /opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(../../@) --offload-settings tcp-segmentation-offload $VAR(@) + diff --git a/templates/interfaces/ethernet/node.tag/offload/udp-fragmentation-offload/node.def b/templates/interfaces/ethernet/node.tag/offload/udp-fragmentation-offload/node.def new file mode 100644 index 00000000..796c791d --- /dev/null +++ b/templates/interfaces/ethernet/node.tag/offload/udp-fragmentation-offload/node.def @@ -0,0 +1,16 @@ +# +# Configuration template for offload settings +# + +priority: 319 # Failure barrier only - no ordering constraints + +type: txt +help: Configure udp-fragmentation-offload option +val_help: on; Enable udp-fragmentation-offload +val_help: off; Disable udp-fragmentation-offload + +syntax:expression: $VAR(@) == "on" || $VAR(@) == "off" ; "Must be either 'on' or 'off'" + +update: sudo /opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(../../@) --offload-settings udp-fragmentation-offload $VAR(@) + + |