1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2011 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
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".
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>
30 #include <linux/module.h>
31 #include <linux/pci.h>
36 * This is the only thing that needs to be changed to adjust the
37 * maximum number of ports that the driver can manage.
40 #define E1000_MAX_NIC 32
42 #define OPTION_UNSET -1
43 #define OPTION_DISABLED 0
44 #define OPTION_ENABLED 1
46 #define COPYBREAK_DEFAULT 256
47 unsigned int copybreak
= COPYBREAK_DEFAULT
;
48 module_param(copybreak
, uint
, 0644);
49 MODULE_PARM_DESC(copybreak
,
50 "Maximum size of packet that is copied to a new buffer on receive");
53 * All parameters are treated the same, as an integer array of values.
54 * This macro just reduces the need to repeat the same declaration code
55 * over and over (plus this helps to avoid typo bugs).
58 #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
59 #define E1000_PARAM(X, desc) \
60 static int __devinitdata X[E1000_MAX_NIC+1] \
62 static unsigned int num_##X; \
63 module_param_array_named(X, X, int, &num_##X, 0); \
64 MODULE_PARM_DESC(X, desc);
67 * Transmit Interrupt Delay in units of 1.024 microseconds
68 * Tx interrupt delay needs to typically be set to something non-zero
70 * Valid Range: 0-65535
72 E1000_PARAM(TxIntDelay
, "Transmit Interrupt Delay");
73 #define DEFAULT_TIDV 8
74 #define MAX_TXDELAY 0xFFFF
78 * Transmit Absolute Interrupt Delay in units of 1.024 microseconds
80 * Valid Range: 0-65535
82 E1000_PARAM(TxAbsIntDelay
, "Transmit Absolute Interrupt Delay");
83 #define DEFAULT_TADV 32
84 #define MAX_TXABSDELAY 0xFFFF
85 #define MIN_TXABSDELAY 0
88 * Receive Interrupt Delay in units of 1.024 microseconds
89 * hardware will likely hang if you set this to anything but zero.
91 * Valid Range: 0-65535
93 E1000_PARAM(RxIntDelay
, "Receive Interrupt Delay");
94 #define MAX_RXDELAY 0xFFFF
98 * Receive Absolute Interrupt Delay in units of 1.024 microseconds
100 * Valid Range: 0-65535
102 E1000_PARAM(RxAbsIntDelay
, "Receive Absolute Interrupt Delay");
103 #define MAX_RXABSDELAY 0xFFFF
104 #define MIN_RXABSDELAY 0
107 * Interrupt Throttle Rate (interrupts/sec)
109 * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative)
111 E1000_PARAM(InterruptThrottleRate
, "Interrupt Throttling Rate");
112 #define DEFAULT_ITR 3
113 #define MAX_ITR 100000
116 /* IntMode (Interrupt Mode)
120 * Default Value: 2 (MSI-X)
122 E1000_PARAM(IntMode
, "Interrupt Mode");
123 #define MAX_INTMODE 2
124 #define MIN_INTMODE 0
127 * Enable Smart Power Down of the PHY
131 * Default Value: 0 (disabled)
133 E1000_PARAM(SmartPowerDownEnable
, "Enable PHY smart power down");
136 * Enable Kumeran Lock Loss workaround
140 * Default Value: 1 (enabled)
142 E1000_PARAM(KumeranLockLoss
, "Enable Kumeran lock loss workaround");
149 * Default Value: 1 (enabled)
151 E1000_PARAM(WriteProtectNVM
, "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]");
154 * Enable CRC Stripping
158 * Default Value: 1 (enabled)
160 E1000_PARAM(CrcStripping
, "Enable CRC Stripping, disable if your BMC needs " \
163 struct e1000_option
{
164 enum { enable_option
, range_option
, list_option
} type
;
169 struct { /* range_option info */
173 struct { /* list_option info */
175 struct e1000_opt_list
{ int i
; char *str
; } *p
;
180 static int __devinit
e1000_validate_option(unsigned int *value
,
181 const struct e1000_option
*opt
,
182 struct e1000_adapter
*adapter
)
184 if (*value
== OPTION_UNSET
) {
193 e_info("%s Enabled\n", opt
->name
);
195 case OPTION_DISABLED
:
196 e_info("%s Disabled\n", opt
->name
);
201 if (*value
>= opt
->arg
.r
.min
&& *value
<= opt
->arg
.r
.max
) {
202 e_info("%s set to %i\n", opt
->name
, *value
);
208 struct e1000_opt_list
*ent
;
210 for (i
= 0; i
< opt
->arg
.l
.nr
; i
++) {
211 ent
= &opt
->arg
.l
.p
[i
];
212 if (*value
== ent
->i
) {
213 if (ent
->str
[0] != '\0')
214 e_info("%s\n", ent
->str
);
224 e_info("Invalid %s value specified (%i) %s\n", opt
->name
, *value
,
231 * e1000e_check_options - Range Checking for Command Line Parameters
232 * @adapter: board private structure
234 * This routine checks all command line parameters for valid user
235 * input. If an invalid value is given, or if no user specified
236 * value exists, a default value is used. The final value is stored
237 * in a variable in the adapter structure.
239 void __devinit
e1000e_check_options(struct e1000_adapter
*adapter
)
241 struct e1000_hw
*hw
= &adapter
->hw
;
242 int bd
= adapter
->bd_number
;
244 if (bd
>= E1000_MAX_NIC
) {
245 e_notice("Warning: no configuration for board #%i\n", bd
);
246 e_notice("Using defaults for all values\n");
249 { /* Transmit Interrupt Delay */
250 static const struct e1000_option opt
= {
251 .type
= range_option
,
252 .name
= "Transmit Interrupt Delay",
253 .err
= "using default of "
254 __MODULE_STRING(DEFAULT_TIDV
),
256 .arg
= { .r
= { .min
= MIN_TXDELAY
,
257 .max
= MAX_TXDELAY
} }
260 if (num_TxIntDelay
> bd
) {
261 adapter
->tx_int_delay
= TxIntDelay
[bd
];
262 e1000_validate_option(&adapter
->tx_int_delay
, &opt
,
265 adapter
->tx_int_delay
= opt
.def
;
268 { /* Transmit Absolute Interrupt Delay */
269 static const struct e1000_option opt
= {
270 .type
= range_option
,
271 .name
= "Transmit Absolute Interrupt Delay",
272 .err
= "using default of "
273 __MODULE_STRING(DEFAULT_TADV
),
275 .arg
= { .r
= { .min
= MIN_TXABSDELAY
,
276 .max
= MAX_TXABSDELAY
} }
279 if (num_TxAbsIntDelay
> bd
) {
280 adapter
->tx_abs_int_delay
= TxAbsIntDelay
[bd
];
281 e1000_validate_option(&adapter
->tx_abs_int_delay
, &opt
,
284 adapter
->tx_abs_int_delay
= opt
.def
;
287 { /* Receive Interrupt Delay */
288 static struct e1000_option opt
= {
289 .type
= range_option
,
290 .name
= "Receive Interrupt Delay",
291 .err
= "using default of "
292 __MODULE_STRING(DEFAULT_RDTR
),
294 .arg
= { .r
= { .min
= MIN_RXDELAY
,
295 .max
= MAX_RXDELAY
} }
298 if (num_RxIntDelay
> bd
) {
299 adapter
->rx_int_delay
= RxIntDelay
[bd
];
300 e1000_validate_option(&adapter
->rx_int_delay
, &opt
,
303 adapter
->rx_int_delay
= opt
.def
;
306 { /* Receive Absolute Interrupt Delay */
307 static const struct e1000_option opt
= {
308 .type
= range_option
,
309 .name
= "Receive Absolute Interrupt Delay",
310 .err
= "using default of "
311 __MODULE_STRING(DEFAULT_RADV
),
313 .arg
= { .r
= { .min
= MIN_RXABSDELAY
,
314 .max
= MAX_RXABSDELAY
} }
317 if (num_RxAbsIntDelay
> bd
) {
318 adapter
->rx_abs_int_delay
= RxAbsIntDelay
[bd
];
319 e1000_validate_option(&adapter
->rx_abs_int_delay
, &opt
,
322 adapter
->rx_abs_int_delay
= opt
.def
;
325 { /* Interrupt Throttling Rate */
326 static const struct e1000_option opt
= {
327 .type
= range_option
,
328 .name
= "Interrupt Throttling Rate (ints/sec)",
329 .err
= "using default of "
330 __MODULE_STRING(DEFAULT_ITR
),
332 .arg
= { .r
= { .min
= MIN_ITR
,
336 if (num_InterruptThrottleRate
> bd
) {
337 adapter
->itr
= InterruptThrottleRate
[bd
];
338 switch (adapter
->itr
) {
340 e_info("%s turned off\n", opt
.name
);
343 e_info("%s set to dynamic mode\n", opt
.name
);
344 adapter
->itr_setting
= adapter
->itr
;
345 adapter
->itr
= 20000;
348 e_info("%s set to dynamic conservative mode\n",
350 adapter
->itr_setting
= adapter
->itr
;
351 adapter
->itr
= 20000;
354 e_info("%s set to simplified (2000-8000 ints) "
356 adapter
->itr_setting
= 4;
360 * Save the setting, because the dynamic bits
363 if (e1000_validate_option(&adapter
->itr
, &opt
,
365 (adapter
->itr
== 3)) {
367 * In case of invalid user value,
368 * default to conservative mode.
370 adapter
->itr_setting
= adapter
->itr
;
371 adapter
->itr
= 20000;
374 * Clear the lower two bits because
375 * they are used as control.
377 adapter
->itr_setting
=
383 adapter
->itr_setting
= opt
.def
;
384 adapter
->itr
= 20000;
387 { /* Interrupt Mode */
388 static struct e1000_option opt
= {
389 .type
= range_option
,
390 .name
= "Interrupt Mode",
391 .err
= "defaulting to 2 (MSI-X)",
392 .def
= E1000E_INT_MODE_MSIX
,
393 .arg
= { .r
= { .min
= MIN_INTMODE
,
394 .max
= MAX_INTMODE
} }
397 if (num_IntMode
> bd
) {
398 unsigned int int_mode
= IntMode
[bd
];
399 e1000_validate_option(&int_mode
, &opt
, adapter
);
400 adapter
->int_mode
= int_mode
;
402 adapter
->int_mode
= opt
.def
;
405 { /* Smart Power Down */
406 static const struct e1000_option opt
= {
407 .type
= enable_option
,
408 .name
= "PHY Smart Power Down",
409 .err
= "defaulting to Disabled",
410 .def
= OPTION_DISABLED
413 if (num_SmartPowerDownEnable
> bd
) {
414 unsigned int spd
= SmartPowerDownEnable
[bd
];
415 e1000_validate_option(&spd
, &opt
, adapter
);
416 if ((adapter
->flags
& FLAG_HAS_SMART_POWER_DOWN
)
418 adapter
->flags
|= FLAG_SMART_POWER_DOWN
;
421 { /* CRC Stripping */
422 static const struct e1000_option opt
= {
423 .type
= enable_option
,
424 .name
= "CRC Stripping",
425 .err
= "defaulting to Enabled",
426 .def
= OPTION_ENABLED
429 if (num_CrcStripping
> bd
) {
430 unsigned int crc_stripping
= CrcStripping
[bd
];
431 e1000_validate_option(&crc_stripping
, &opt
, adapter
);
432 if (crc_stripping
== OPTION_ENABLED
)
433 adapter
->flags2
|= FLAG2_CRC_STRIPPING
;
435 adapter
->flags2
|= FLAG2_CRC_STRIPPING
;
438 { /* Kumeran Lock Loss Workaround */
439 static const struct e1000_option opt
= {
440 .type
= enable_option
,
441 .name
= "Kumeran Lock Loss Workaround",
442 .err
= "defaulting to Enabled",
443 .def
= OPTION_ENABLED
446 if (num_KumeranLockLoss
> bd
) {
447 unsigned int kmrn_lock_loss
= KumeranLockLoss
[bd
];
448 e1000_validate_option(&kmrn_lock_loss
, &opt
, adapter
);
449 if (hw
->mac
.type
== e1000_ich8lan
)
450 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw
,
453 if (hw
->mac
.type
== e1000_ich8lan
)
454 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw
,
458 { /* Write-protect NVM */
459 static const struct e1000_option opt
= {
460 .type
= enable_option
,
461 .name
= "Write-protect NVM",
462 .err
= "defaulting to Enabled",
463 .def
= OPTION_ENABLED
466 if (adapter
->flags
& FLAG_IS_ICH
) {
467 if (num_WriteProtectNVM
> bd
) {
468 unsigned int write_protect_nvm
= WriteProtectNVM
[bd
];
469 e1000_validate_option(&write_protect_nvm
, &opt
,
471 if (write_protect_nvm
)
472 adapter
->flags
|= FLAG_READ_ONLY_NVM
;
475 adapter
->flags
|= FLAG_READ_ONLY_NVM
;