net/ethtool: official interface for changing ethtool params (bug #195479)

Implement a consistent interface for changing ethtool parameters, as
suggested in bug 195479. All variable names are based on the long option
to ethtool to set each group of parameters. Multiple entries seperated
by newlines are permitted for variable values.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
X-Gentoo-Bug: 195479
This commit is contained in:
Robin H. Johnson 2011-02-22 02:54:26 +00:00
parent 22918ccf51
commit dfd42d1393
3 changed files with 122 additions and 2 deletions

View File

@ -980,6 +980,72 @@
#ifplugd_eth0="--api-mode=wlan" #ifplugd_eth0="--api-mode=wlan"
# man ifplugd for more options # man ifplugd for more options
#-----------------------------------------------------------------------------
# Interface hardware tuning & configuration via ethtool
# If you need to change explicit hardware settings on your network card prior
# to bringing the interface up, the following is available.
#
# For a full listing of settings, please consulting ethtool(8) and the output
# of "ethtool --help".
#
# Multiple entries (seperated by newlines) are supported in all of the
# variables as some settings cannot be changed at the same time.
#
# Valid variable name fragments: change pause coalesce ring offload
# change_eeprom identify nfc flash rxfh_indir ntuple
# Set Wake-On-Lan to listen for SecureOn MagicPacket(tm), the message level to
# notify us of WOL changes, and the SecureOn password to 'DE:AD:BE:EF:CA:FE'.
#ethtool_change_eth0="wol gs
#msglvl wol on
#sopass DE:AD:BE:EF:CA:FE"
# Disable pause auto-negotiation and explicitly enable RX and TX pause.
#ethtool_pause_eth0="autoneg off
#rx on tx on"
# Enasble adaptive RX and TX coalescing
#ethtool_coalesce_eth0="adaptive-rx on adaptive-tx on"
# Change ring buffer settings
#ethtool_ring_eth0=""
# Enable all offload settings
#ethtool_offload_eth0="rx on tx on sg on tso on ufo on gso on gro on lro on"
# Change specific bytes in the EEPROM
#ethtool_change_eeprom_eth0=""
# Run the identify sequence on the interface for 1 second (does not return until completion)
#ethtool_identify_eth0="1"
# Configure receive network flow classification
#ethtool_nfc_eth0="
#rx-flow-hash tcp4 f
#rx-flow-hash udp4 s"
# Flash firmware to all regions
#ethtool_flash_eth0="/some/path/firmware1 0"
# Flash firmware to region 1
#ethtool_flash_eth0="/some/path/firmware2 1"
# Set receive flow hash indirection table for even balancing between N receive queues
#ethtool_rxfh_indir_eth0="equal 4"
# Configure Rx ntuple filters and actions
#ethtool_ntuple_eth0=""
# Additionally, there is a special control variable, if you need to change the
# order of option processing. The default order is:
# flash change-eeprom change pause coalesce ring offload identify nfc rxfh-indir ntuple
# Set global order to default
#ethtool_order="flash change-eeprom change pause coalesce ring offload identify nfc rxfh-indir ntuple"
# Hypothetical network card that requires a change-eeprom toggle to enable flashing
#ethtool_order_eth0="change-eeprom flash change pause coalesce ring offload nfc rxfh-indir ntuple"
############################################################################## ##############################################################################
# ADVANCED CONFIGURATION # ADVANCED CONFIGURATION
# #

View File

@ -1,7 +1,7 @@
SRCS+= iwconfig.sh.in SRCS+= iwconfig.sh.in
INC+= adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \ INC+= adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
ccwgroup.sh clip.sh iproute2.sh ifplugd.sh ip6to4.sh ipppd.sh \ ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \
iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \ ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \
vlan.sh vlan.sh
.SUFFIXES: .sh.Linux.in .SUFFIXES: .sh.Linux.in

54
net/ethtool.sh Normal file
View File

@ -0,0 +1,54 @@
# Copyright (c) 2011 by Gentoo Foundation
# All rights reserved. Released under the 2-clause BSD license.
_ethtool() {
echo /usr/sbin/ethtool
}
ethtool_depend()
{
program $(_ethtool)
before interface
}
# This is just to trim whitespace, do not add any quoting!
_trim() {
echo $*
}
ethtool_pre_start() {
local order opt OFS="${OIFS}"
eval order=\$ethtool_order_${IFVAR}
[ -z "${order}" ] && eval order=\$ethtool_order
[ -z "${order}" ] && order="flash change-eeprom change pause coalesce ring offload identify nfc rxfh-indir ntuple"
# ethtool options not used: --driver, --register-dump, --eeprom-dump, --negotiate, --test, --statistics
eindent
for opt in ${order} ; do
local args
eval args=\$ethtool_${opt//-/_}_${IFVAR}
# Skip everything if no arguments
[ -z "${args}" ] && continue
# Split on \n
local IFS="$__IFS"
for p in ${args} ; do
IFS="${OIFS}"
local args_pretty="$(_trim "${p}")"
# Do nothing if empty
[ -z "${args_prety}" ] && continue
args_pretty="--${opt} $IFACE ${args_pretty}"
args="--${opt} $IFACE ${args}"
ebegin "ethtool ${args_pretty}"
$(_ethtool) ${args}
rc=$?
eend $rc "ethtool exit code $rc"
# TODO: ethtool has MANY different exit codes, with no
# documentation as to which ones are fatal or not. For now we
# simply print the exit code and don't stop the start sequence.
done
IFS="${OIFS}"
done
eoutdent
}