1 |
commit: dfd42d139357b23fb7629bea3bc39918a660cd4c |
2 |
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Feb 22 02:54:26 2011 +0000 |
4 |
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Feb 22 02:59:38 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=dfd42d13 |
7 |
|
8 |
net/ethtool: official interface for changing ethtool params (bug #195479) |
9 |
|
10 |
Implement a consistent interface for changing ethtool parameters, as |
11 |
suggested in bug 195479. All variable names are based on the long option |
12 |
to ethtool to set each group of parameters. Multiple entries seperated |
13 |
by newlines are permitted for variable values. |
14 |
|
15 |
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org> |
16 |
X-Gentoo-Bug: 195479 |
17 |
|
18 |
--- |
19 |
doc/net.example.Linux.in | 66 ++++++++++++++++++++++++++++++++++++++++++++++ |
20 |
net/Makefile.Linux | 4 +- |
21 |
net/ethtool.sh | 54 +++++++++++++++++++++++++++++++++++++ |
22 |
3 files changed, 122 insertions(+), 2 deletions(-) |
23 |
|
24 |
diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in |
25 |
index d3b97c5..69c9ba6 100644 |
26 |
--- a/doc/net.example.Linux.in |
27 |
+++ b/doc/net.example.Linux.in |
28 |
@@ -980,6 +980,72 @@ |
29 |
#ifplugd_eth0="--api-mode=wlan" |
30 |
# man ifplugd for more options |
31 |
|
32 |
+#----------------------------------------------------------------------------- |
33 |
+# Interface hardware tuning & configuration via ethtool |
34 |
+# If you need to change explicit hardware settings on your network card prior |
35 |
+# to bringing the interface up, the following is available. |
36 |
+# |
37 |
+# For a full listing of settings, please consulting ethtool(8) and the output |
38 |
+# of "ethtool --help". |
39 |
+# |
40 |
+# Multiple entries (seperated by newlines) are supported in all of the |
41 |
+# variables as some settings cannot be changed at the same time. |
42 |
+# |
43 |
+# Valid variable name fragments: change pause coalesce ring offload |
44 |
+# change_eeprom identify nfc flash rxfh_indir ntuple |
45 |
+ |
46 |
+# Set Wake-On-Lan to listen for SecureOn MagicPacket(tm), the message level to |
47 |
+# notify us of WOL changes, and the SecureOn password to 'DE:AD:BE:EF:CA:FE'. |
48 |
+#ethtool_change_eth0="wol gs |
49 |
+#msglvl wol on |
50 |
+#sopass DE:AD:BE:EF:CA:FE" |
51 |
+ |
52 |
+# Disable pause auto-negotiation and explicitly enable RX and TX pause. |
53 |
+#ethtool_pause_eth0="autoneg off |
54 |
+#rx on tx on" |
55 |
+ |
56 |
+# Enasble adaptive RX and TX coalescing |
57 |
+#ethtool_coalesce_eth0="adaptive-rx on adaptive-tx on" |
58 |
+ |
59 |
+# Change ring buffer settings |
60 |
+#ethtool_ring_eth0="" |
61 |
+ |
62 |
+# Enable all offload settings |
63 |
+#ethtool_offload_eth0="rx on tx on sg on tso on ufo on gso on gro on lro on" |
64 |
+ |
65 |
+# Change specific bytes in the EEPROM |
66 |
+#ethtool_change_eeprom_eth0="" |
67 |
+ |
68 |
+# Run the identify sequence on the interface for 1 second (does not return until completion) |
69 |
+#ethtool_identify_eth0="1" |
70 |
+ |
71 |
+# Configure receive network flow classification |
72 |
+#ethtool_nfc_eth0=" |
73 |
+#rx-flow-hash tcp4 f |
74 |
+#rx-flow-hash udp4 s" |
75 |
+ |
76 |
+# Flash firmware to all regions |
77 |
+#ethtool_flash_eth0="/some/path/firmware1 0" |
78 |
+ |
79 |
+# Flash firmware to region 1 |
80 |
+#ethtool_flash_eth0="/some/path/firmware2 1" |
81 |
+ |
82 |
+# Set receive flow hash indirection table for even balancing between N receive queues |
83 |
+#ethtool_rxfh_indir_eth0="equal 4" |
84 |
+ |
85 |
+# Configure Rx ntuple filters and actions |
86 |
+#ethtool_ntuple_eth0="" |
87 |
+ |
88 |
+# Additionally, there is a special control variable, if you need to change the |
89 |
+# order of option processing. The default order is: |
90 |
+# flash change-eeprom change pause coalesce ring offload identify nfc rxfh-indir ntuple |
91 |
+ |
92 |
+# Set global order to default |
93 |
+#ethtool_order="flash change-eeprom change pause coalesce ring offload identify nfc rxfh-indir ntuple" |
94 |
+ |
95 |
+# Hypothetical network card that requires a change-eeprom toggle to enable flashing |
96 |
+#ethtool_order_eth0="change-eeprom flash change pause coalesce ring offload nfc rxfh-indir ntuple" |
97 |
+ |
98 |
############################################################################## |
99 |
# ADVANCED CONFIGURATION |
100 |
# |
101 |
|
102 |
diff --git a/net/Makefile.Linux b/net/Makefile.Linux |
103 |
index 7006d74..f7fb087 100644 |
104 |
--- a/net/Makefile.Linux |
105 |
+++ b/net/Makefile.Linux |
106 |
@@ -1,7 +1,7 @@ |
107 |
SRCS+= iwconfig.sh.in |
108 |
INC+= adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \ |
109 |
- ccwgroup.sh clip.sh iproute2.sh ifplugd.sh ip6to4.sh ipppd.sh \ |
110 |
- iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \ |
111 |
+ ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \ |
112 |
+ ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \ |
113 |
vlan.sh |
114 |
|
115 |
.SUFFIXES: .sh.Linux.in |
116 |
|
117 |
diff --git a/net/ethtool.sh b/net/ethtool.sh |
118 |
new file mode 100644 |
119 |
index 0000000..64b44a6 |
120 |
--- /dev/null |
121 |
+++ b/net/ethtool.sh |
122 |
@@ -0,0 +1,54 @@ |
123 |
+# Copyright (c) 2011 by Gentoo Foundation |
124 |
+# All rights reserved. Released under the 2-clause BSD license. |
125 |
+ |
126 |
+_ethtool() { |
127 |
+ echo /usr/sbin/ethtool |
128 |
+} |
129 |
+ |
130 |
+ethtool_depend() |
131 |
+{ |
132 |
+ program $(_ethtool) |
133 |
+ before interface |
134 |
+} |
135 |
+ |
136 |
+# This is just to trim whitespace, do not add any quoting! |
137 |
+_trim() { |
138 |
+ echo $* |
139 |
+} |
140 |
+ |
141 |
+ethtool_pre_start() { |
142 |
+ local order opt OFS="${OIFS}" |
143 |
+ eval order=\$ethtool_order_${IFVAR} |
144 |
+ [ -z "${order}" ] && eval order=\$ethtool_order |
145 |
+ [ -z "${order}" ] && order="flash change-eeprom change pause coalesce ring offload identify nfc rxfh-indir ntuple" |
146 |
+ # ethtool options not used: --driver, --register-dump, --eeprom-dump, --negotiate, --test, --statistics |
147 |
+ eindent |
148 |
+ for opt in ${order} ; do |
149 |
+ local args |
150 |
+ eval args=\$ethtool_${opt//-/_}_${IFVAR} |
151 |
+ |
152 |
+ # Skip everything if no arguments |
153 |
+ [ -z "${args}" ] && continue |
154 |
+ |
155 |
+ # Split on \n |
156 |
+ local IFS="$__IFS" |
157 |
+ |
158 |
+ for p in ${args} ; do |
159 |
+ IFS="${OIFS}" |
160 |
+ local args_pretty="$(_trim "${p}")" |
161 |
+ # Do nothing if empty |
162 |
+ [ -z "${args_prety}" ] && continue |
163 |
+ args_pretty="--${opt} $IFACE ${args_pretty}" |
164 |
+ args="--${opt} $IFACE ${args}" |
165 |
+ ebegin "ethtool ${args_pretty}" |
166 |
+ $(_ethtool) ${args} |
167 |
+ rc=$? |
168 |
+ eend $rc "ethtool exit code $rc" |
169 |
+ # TODO: ethtool has MANY different exit codes, with no |
170 |
+ # documentation as to which ones are fatal or not. For now we |
171 |
+ # simply print the exit code and don't stop the start sequence. |
172 |
+ done |
173 |
+ IFS="${OIFS}" |
174 |
+ done |
175 |
+ eoutdent |
176 |
+} |