Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / drivers / net / e1000e / param.c
blobdf266c32ac4bc022fa6f5b75877e4ebd707315f5
1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2007 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *******************************************************************************/
29 #include <linux/netdevice.h>
31 #include "e1000.h"
33 /* This is the only thing that needs to be changed to adjust the
34 * maximum number of ports that the driver can manage.
37 #define E1000_MAX_NIC 32
39 #define OPTION_UNSET -1
40 #define OPTION_DISABLED 0
41 #define OPTION_ENABLED 1
43 #define COPYBREAK_DEFAULT 256
44 unsigned int copybreak = COPYBREAK_DEFAULT;
45 module_param(copybreak, uint, 0644);
46 MODULE_PARM_DESC(copybreak,
47 "Maximum size of packet that is copied to a new buffer on receive");
49 /* All parameters are treated the same, as an integer array of values.
50 * This macro just reduces the need to repeat the same declaration code
51 * over and over (plus this helps to avoid typo bugs).
54 #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
55 #define E1000_PARAM(X, desc) \
56 static int __devinitdata X[E1000_MAX_NIC+1] \
57 = E1000_PARAM_INIT; \
58 static unsigned int num_##X; \
59 module_param_array_named(X, X, int, &num_##X, 0); \
60 MODULE_PARM_DESC(X, desc);
63 /* Transmit Interrupt Delay in units of 1.024 microseconds
64 * Tx interrupt delay needs to typically be set to something non zero
66 * Valid Range: 0-65535
68 E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
69 #define DEFAULT_TIDV 8
70 #define MAX_TXDELAY 0xFFFF
71 #define MIN_TXDELAY 0
73 /* Transmit Absolute Interrupt Delay in units of 1.024 microseconds
75 * Valid Range: 0-65535
77 E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
78 #define DEFAULT_TADV 32
79 #define MAX_TXABSDELAY 0xFFFF
80 #define MIN_TXABSDELAY 0
82 /* Receive Interrupt Delay in units of 1.024 microseconds
83 * hardware will likely hang if you set this to anything but zero.
85 * Valid Range: 0-65535
87 E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
88 #define DEFAULT_RDTR 0
89 #define MAX_RXDELAY 0xFFFF
90 #define MIN_RXDELAY 0
92 /* Receive Absolute Interrupt Delay in units of 1.024 microseconds
94 * Valid Range: 0-65535
96 E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
97 #define DEFAULT_RADV 8
98 #define MAX_RXABSDELAY 0xFFFF
99 #define MIN_RXABSDELAY 0
101 /* Interrupt Throttle Rate (interrupts/sec)
103 * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative)
105 E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
106 #define DEFAULT_ITR 3
107 #define MAX_ITR 100000
108 #define MIN_ITR 100
110 /* Enable Smart Power Down of the PHY
112 * Valid Range: 0, 1
114 * Default Value: 0 (disabled)
116 E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
118 /* Enable Kumeran Lock Loss workaround
120 * Valid Range: 0, 1
122 * Default Value: 1 (enabled)
124 E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");
126 struct e1000_option {
127 enum { enable_option, range_option, list_option } type;
128 const char *name;
129 const char *err;
130 int def;
131 union {
132 struct { /* range_option info */
133 int min;
134 int max;
135 } r;
136 struct { /* list_option info */
137 int nr;
138 struct e1000_opt_list { int i; char *str; } *p;
139 } l;
140 } arg;
143 static int __devinit e1000_validate_option(unsigned int *value,
144 const struct e1000_option *opt,
145 struct e1000_adapter *adapter)
147 if (*value == OPTION_UNSET) {
148 *value = opt->def;
149 return 0;
152 switch (opt->type) {
153 case enable_option:
154 switch (*value) {
155 case OPTION_ENABLED:
156 ndev_info(adapter->netdev, "%s Enabled\n", opt->name);
157 return 0;
158 case OPTION_DISABLED:
159 ndev_info(adapter->netdev, "%s Disabled\n", opt->name);
160 return 0;
162 break;
163 case range_option:
164 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
165 ndev_info(adapter->netdev,
166 "%s set to %i\n", opt->name, *value);
167 return 0;
169 break;
170 case list_option: {
171 int i;
172 struct e1000_opt_list *ent;
174 for (i = 0; i < opt->arg.l.nr; i++) {
175 ent = &opt->arg.l.p[i];
176 if (*value == ent->i) {
177 if (ent->str[0] != '\0')
178 ndev_info(adapter->netdev, "%s\n",
179 ent->str);
180 return 0;
184 break;
185 default:
186 BUG();
189 ndev_info(adapter->netdev, "Invalid %s value specified (%i) %s\n",
190 opt->name, *value, opt->err);
191 *value = opt->def;
192 return -1;
196 * e1000e_check_options - Range Checking for Command Line Parameters
197 * @adapter: board private structure
199 * This routine checks all command line parameters for valid user
200 * input. If an invalid value is given, or if no user specified
201 * value exists, a default value is used. The final value is stored
202 * in a variable in the adapter structure.
204 void __devinit e1000e_check_options(struct e1000_adapter *adapter)
206 struct e1000_hw *hw = &adapter->hw;
207 struct net_device *netdev = adapter->netdev;
208 int bd = adapter->bd_number;
210 if (bd >= E1000_MAX_NIC) {
211 ndev_notice(netdev,
212 "Warning: no configuration for board #%i\n", bd);
213 ndev_notice(netdev, "Using defaults for all values\n");
216 { /* Transmit Interrupt Delay */
217 const struct e1000_option opt = {
218 .type = range_option,
219 .name = "Transmit Interrupt Delay",
220 .err = "using default of "
221 __MODULE_STRING(DEFAULT_TIDV),
222 .def = DEFAULT_TIDV,
223 .arg = { .r = { .min = MIN_TXDELAY,
224 .max = MAX_TXDELAY } }
227 if (num_TxIntDelay > bd) {
228 adapter->tx_int_delay = TxIntDelay[bd];
229 e1000_validate_option(&adapter->tx_int_delay, &opt,
230 adapter);
231 } else {
232 adapter->tx_int_delay = opt.def;
235 { /* Transmit Absolute Interrupt Delay */
236 const struct e1000_option opt = {
237 .type = range_option,
238 .name = "Transmit Absolute Interrupt Delay",
239 .err = "using default of "
240 __MODULE_STRING(DEFAULT_TADV),
241 .def = DEFAULT_TADV,
242 .arg = { .r = { .min = MIN_TXABSDELAY,
243 .max = MAX_TXABSDELAY } }
246 if (num_TxAbsIntDelay > bd) {
247 adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
248 e1000_validate_option(&adapter->tx_abs_int_delay, &opt,
249 adapter);
250 } else {
251 adapter->tx_abs_int_delay = opt.def;
254 { /* Receive Interrupt Delay */
255 struct e1000_option opt = {
256 .type = range_option,
257 .name = "Receive Interrupt Delay",
258 .err = "using default of "
259 __MODULE_STRING(DEFAULT_RDTR),
260 .def = DEFAULT_RDTR,
261 .arg = { .r = { .min = MIN_RXDELAY,
262 .max = MAX_RXDELAY } }
265 if (num_RxIntDelay > bd) {
266 adapter->rx_int_delay = RxIntDelay[bd];
267 e1000_validate_option(&adapter->rx_int_delay, &opt,
268 adapter);
269 } else {
270 adapter->rx_int_delay = opt.def;
273 { /* Receive Absolute Interrupt Delay */
274 const struct e1000_option opt = {
275 .type = range_option,
276 .name = "Receive Absolute Interrupt Delay",
277 .err = "using default of "
278 __MODULE_STRING(DEFAULT_RADV),
279 .def = DEFAULT_RADV,
280 .arg = { .r = { .min = MIN_RXABSDELAY,
281 .max = MAX_RXABSDELAY } }
284 if (num_RxAbsIntDelay > bd) {
285 adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
286 e1000_validate_option(&adapter->rx_abs_int_delay, &opt,
287 adapter);
288 } else {
289 adapter->rx_abs_int_delay = opt.def;
292 { /* Interrupt Throttling Rate */
293 const struct e1000_option opt = {
294 .type = range_option,
295 .name = "Interrupt Throttling Rate (ints/sec)",
296 .err = "using default of "
297 __MODULE_STRING(DEFAULT_ITR),
298 .def = DEFAULT_ITR,
299 .arg = { .r = { .min = MIN_ITR,
300 .max = MAX_ITR } }
303 if (num_InterruptThrottleRate > bd) {
304 adapter->itr = InterruptThrottleRate[bd];
305 switch (adapter->itr) {
306 case 0:
307 ndev_info(netdev, "%s turned off\n",
308 opt.name);
309 break;
310 case 1:
311 ndev_info(netdev,
312 "%s set to dynamic mode\n",
313 opt.name);
314 adapter->itr_setting = adapter->itr;
315 adapter->itr = 20000;
316 break;
317 case 3:
318 ndev_info(netdev,
319 "%s set to dynamic conservative mode\n",
320 opt.name);
321 adapter->itr_setting = adapter->itr;
322 adapter->itr = 20000;
323 break;
324 default:
325 e1000_validate_option(&adapter->itr, &opt,
326 adapter);
328 * save the setting, because the dynamic bits
329 * change itr. clear the lower two bits
330 * because they are used as control
332 adapter->itr_setting = adapter->itr & ~3;
333 break;
335 } else {
336 adapter->itr_setting = opt.def;
337 adapter->itr = 20000;
340 { /* Smart Power Down */
341 const struct e1000_option opt = {
342 .type = enable_option,
343 .name = "PHY Smart Power Down",
344 .err = "defaulting to Disabled",
345 .def = OPTION_DISABLED
348 if (num_SmartPowerDownEnable > bd) {
349 unsigned int spd = SmartPowerDownEnable[bd];
350 e1000_validate_option(&spd, &opt, adapter);
351 if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN)
352 && spd)
353 adapter->flags |= FLAG_SMART_POWER_DOWN;
356 { /* Kumeran Lock Loss Workaround */
357 const struct e1000_option opt = {
358 .type = enable_option,
359 .name = "Kumeran Lock Loss Workaround",
360 .err = "defaulting to Enabled",
361 .def = OPTION_ENABLED
364 if (num_KumeranLockLoss > bd) {
365 unsigned int kmrn_lock_loss = KumeranLockLoss[bd];
366 e1000_validate_option(&kmrn_lock_loss, &opt, adapter);
367 if (hw->mac.type == e1000_ich8lan)
368 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw,
369 kmrn_lock_loss);
370 } else {
371 if (hw->mac.type == e1000_ich8lan)
372 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw,
373 opt.def);