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/pci.h>
35 * This is the only thing that needs to be changed to adjust the
36 * maximum number of ports that the driver can manage.
39 #define E1000_MAX_NIC 32
41 #define OPTION_UNSET -1
42 #define OPTION_DISABLED 0
43 #define OPTION_ENABLED 1
45 #define COPYBREAK_DEFAULT 256
46 unsigned int copybreak
= COPYBREAK_DEFAULT
;
47 module_param(copybreak
, uint
, 0644);
48 MODULE_PARM_DESC(copybreak
,
49 "Maximum size of packet that is copied to a new buffer on receive");
52 * All parameters are treated the same, as an integer array of values.
53 * This macro just reduces the need to repeat the same declaration code
54 * over and over (plus this helps to avoid typo bugs).
57 #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
58 #define E1000_PARAM(X, desc) \
59 static int __devinitdata X[E1000_MAX_NIC+1] \
61 static unsigned int num_##X; \
62 module_param_array_named(X, X, int, &num_##X, 0); \
63 MODULE_PARM_DESC(X, desc);
66 * Transmit Interrupt Delay in units of 1.024 microseconds
67 * Tx interrupt delay needs to typically be set to something non-zero
69 * Valid Range: 0-65535
71 E1000_PARAM(TxIntDelay
, "Transmit Interrupt Delay");
72 #define DEFAULT_TIDV 8
73 #define MAX_TXDELAY 0xFFFF
77 * Transmit Absolute Interrupt Delay in units of 1.024 microseconds
79 * Valid Range: 0-65535
81 E1000_PARAM(TxAbsIntDelay
, "Transmit Absolute Interrupt Delay");
82 #define DEFAULT_TADV 32
83 #define MAX_TXABSDELAY 0xFFFF
84 #define MIN_TXABSDELAY 0
87 * Receive Interrupt Delay in units of 1.024 microseconds
88 * hardware will likely hang if you set this to anything but zero.
90 * Valid Range: 0-65535
92 E1000_PARAM(RxIntDelay
, "Receive Interrupt Delay");
93 #define MAX_RXDELAY 0xFFFF
97 * Receive Absolute Interrupt Delay in units of 1.024 microseconds
99 * Valid Range: 0-65535
101 E1000_PARAM(RxAbsIntDelay
, "Receive Absolute Interrupt Delay");
102 #define MAX_RXABSDELAY 0xFFFF
103 #define MIN_RXABSDELAY 0
106 * Interrupt Throttle Rate (interrupts/sec)
108 * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative)
110 E1000_PARAM(InterruptThrottleRate
, "Interrupt Throttling Rate");
111 #define DEFAULT_ITR 3
112 #define MAX_ITR 100000
115 /* IntMode (Interrupt Mode)
119 * Default Value: 2 (MSI-X)
121 E1000_PARAM(IntMode
, "Interrupt Mode");
122 #define MAX_INTMODE 2
123 #define MIN_INTMODE 0
126 * Enable Smart Power Down of the PHY
130 * Default Value: 0 (disabled)
132 E1000_PARAM(SmartPowerDownEnable
, "Enable PHY smart power down");
135 * Enable Kumeran Lock Loss workaround
139 * Default Value: 1 (enabled)
141 E1000_PARAM(KumeranLockLoss
, "Enable Kumeran lock loss workaround");
148 * Default Value: 1 (enabled)
150 E1000_PARAM(WriteProtectNVM
, "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]");
153 * Enable CRC Stripping
157 * Default Value: 1 (enabled)
159 E1000_PARAM(CrcStripping
, "Enable CRC Stripping, disable if your BMC needs " \
162 struct e1000_option
{
163 enum { enable_option
, range_option
, list_option
} type
;
168 struct { /* range_option info */
172 struct { /* list_option info */
174 struct e1000_opt_list
{ int i
; char *str
; } *p
;
179 static int __devinit
e1000_validate_option(unsigned int *value
,
180 const struct e1000_option
*opt
,
181 struct e1000_adapter
*adapter
)
183 if (*value
== OPTION_UNSET
) {
192 e_info("%s Enabled\n", opt
->name
);
194 case OPTION_DISABLED
:
195 e_info("%s Disabled\n", opt
->name
);
200 if (*value
>= opt
->arg
.r
.min
&& *value
<= opt
->arg
.r
.max
) {
201 e_info("%s set to %i\n", opt
->name
, *value
);
207 struct e1000_opt_list
*ent
;
209 for (i
= 0; i
< opt
->arg
.l
.nr
; i
++) {
210 ent
= &opt
->arg
.l
.p
[i
];
211 if (*value
== ent
->i
) {
212 if (ent
->str
[0] != '\0')
213 e_info("%s\n", ent
->str
);
223 e_info("Invalid %s value specified (%i) %s\n", opt
->name
, *value
,
230 * e1000e_check_options - Range Checking for Command Line Parameters
231 * @adapter: board private structure
233 * This routine checks all command line parameters for valid user
234 * input. If an invalid value is given, or if no user specified
235 * value exists, a default value is used. The final value is stored
236 * in a variable in the adapter structure.
238 void __devinit
e1000e_check_options(struct e1000_adapter
*adapter
)
240 struct e1000_hw
*hw
= &adapter
->hw
;
241 int bd
= adapter
->bd_number
;
243 if (bd
>= E1000_MAX_NIC
) {
244 e_notice("Warning: no configuration for board #%i\n", bd
);
245 e_notice("Using defaults for all values\n");
248 { /* Transmit Interrupt Delay */
249 static const struct e1000_option opt
= {
250 .type
= range_option
,
251 .name
= "Transmit Interrupt Delay",
252 .err
= "using default of "
253 __MODULE_STRING(DEFAULT_TIDV
),
255 .arg
= { .r
= { .min
= MIN_TXDELAY
,
256 .max
= MAX_TXDELAY
} }
259 if (num_TxIntDelay
> bd
) {
260 adapter
->tx_int_delay
= TxIntDelay
[bd
];
261 e1000_validate_option(&adapter
->tx_int_delay
, &opt
,
264 adapter
->tx_int_delay
= opt
.def
;
267 { /* Transmit Absolute Interrupt Delay */
268 static const struct e1000_option opt
= {
269 .type
= range_option
,
270 .name
= "Transmit Absolute Interrupt Delay",
271 .err
= "using default of "
272 __MODULE_STRING(DEFAULT_TADV
),
274 .arg
= { .r
= { .min
= MIN_TXABSDELAY
,
275 .max
= MAX_TXABSDELAY
} }
278 if (num_TxAbsIntDelay
> bd
) {
279 adapter
->tx_abs_int_delay
= TxAbsIntDelay
[bd
];
280 e1000_validate_option(&adapter
->tx_abs_int_delay
, &opt
,
283 adapter
->tx_abs_int_delay
= opt
.def
;
286 { /* Receive Interrupt Delay */
287 static struct e1000_option opt
= {
288 .type
= range_option
,
289 .name
= "Receive Interrupt Delay",
290 .err
= "using default of "
291 __MODULE_STRING(DEFAULT_RDTR
),
293 .arg
= { .r
= { .min
= MIN_RXDELAY
,
294 .max
= MAX_RXDELAY
} }
297 if (num_RxIntDelay
> bd
) {
298 adapter
->rx_int_delay
= RxIntDelay
[bd
];
299 e1000_validate_option(&adapter
->rx_int_delay
, &opt
,
302 adapter
->rx_int_delay
= opt
.def
;
305 { /* Receive Absolute Interrupt Delay */
306 static const struct e1000_option opt
= {
307 .type
= range_option
,
308 .name
= "Receive Absolute Interrupt Delay",
309 .err
= "using default of "
310 __MODULE_STRING(DEFAULT_RADV
),
312 .arg
= { .r
= { .min
= MIN_RXABSDELAY
,
313 .max
= MAX_RXABSDELAY
} }
316 if (num_RxAbsIntDelay
> bd
) {
317 adapter
->rx_abs_int_delay
= RxAbsIntDelay
[bd
];
318 e1000_validate_option(&adapter
->rx_abs_int_delay
, &opt
,
321 adapter
->rx_abs_int_delay
= opt
.def
;
324 { /* Interrupt Throttling Rate */
325 static const struct e1000_option opt
= {
326 .type
= range_option
,
327 .name
= "Interrupt Throttling Rate (ints/sec)",
328 .err
= "using default of "
329 __MODULE_STRING(DEFAULT_ITR
),
331 .arg
= { .r
= { .min
= MIN_ITR
,
335 if (num_InterruptThrottleRate
> bd
) {
336 adapter
->itr
= InterruptThrottleRate
[bd
];
337 switch (adapter
->itr
) {
339 e_info("%s turned off\n", opt
.name
);
342 e_info("%s set to dynamic mode\n", opt
.name
);
343 adapter
->itr_setting
= adapter
->itr
;
344 adapter
->itr
= 20000;
347 e_info("%s set to dynamic conservative mode\n",
349 adapter
->itr_setting
= adapter
->itr
;
350 adapter
->itr
= 20000;
353 e_info("%s set to simplified (2000-8000 ints) "
355 adapter
->itr_setting
= 4;
359 * Save the setting, because the dynamic bits
362 if (e1000_validate_option(&adapter
->itr
, &opt
,
364 (adapter
->itr
== 3)) {
366 * In case of invalid user value,
367 * default to conservative mode.
369 adapter
->itr_setting
= adapter
->itr
;
370 adapter
->itr
= 20000;
373 * Clear the lower two bits because
374 * they are used as control.
376 adapter
->itr_setting
=
382 adapter
->itr_setting
= opt
.def
;
383 adapter
->itr
= 20000;
386 { /* Interrupt Mode */
387 static struct e1000_option opt
= {
388 .type
= range_option
,
389 .name
= "Interrupt Mode",
390 .err
= "defaulting to 2 (MSI-X)",
391 .def
= E1000E_INT_MODE_MSIX
,
392 .arg
= { .r
= { .min
= MIN_INTMODE
,
393 .max
= MAX_INTMODE
} }
396 if (num_IntMode
> bd
) {
397 unsigned int int_mode
= IntMode
[bd
];
398 e1000_validate_option(&int_mode
, &opt
, adapter
);
399 adapter
->int_mode
= int_mode
;
401 adapter
->int_mode
= opt
.def
;
404 { /* Smart Power Down */
405 static const struct e1000_option opt
= {
406 .type
= enable_option
,
407 .name
= "PHY Smart Power Down",
408 .err
= "defaulting to Disabled",
409 .def
= OPTION_DISABLED
412 if (num_SmartPowerDownEnable
> bd
) {
413 unsigned int spd
= SmartPowerDownEnable
[bd
];
414 e1000_validate_option(&spd
, &opt
, adapter
);
415 if ((adapter
->flags
& FLAG_HAS_SMART_POWER_DOWN
)
417 adapter
->flags
|= FLAG_SMART_POWER_DOWN
;
420 { /* CRC Stripping */
421 static const struct e1000_option opt
= {
422 .type
= enable_option
,
423 .name
= "CRC Stripping",
424 .err
= "defaulting to Enabled",
425 .def
= OPTION_ENABLED
428 if (num_CrcStripping
> bd
) {
429 unsigned int crc_stripping
= CrcStripping
[bd
];
430 e1000_validate_option(&crc_stripping
, &opt
, adapter
);
431 if (crc_stripping
== OPTION_ENABLED
)
432 adapter
->flags2
|= FLAG2_CRC_STRIPPING
;
434 adapter
->flags2
|= FLAG2_CRC_STRIPPING
;
437 { /* Kumeran Lock Loss Workaround */
438 static const struct e1000_option opt
= {
439 .type
= enable_option
,
440 .name
= "Kumeran Lock Loss Workaround",
441 .err
= "defaulting to Enabled",
442 .def
= OPTION_ENABLED
445 if (num_KumeranLockLoss
> bd
) {
446 unsigned int kmrn_lock_loss
= KumeranLockLoss
[bd
];
447 e1000_validate_option(&kmrn_lock_loss
, &opt
, adapter
);
448 if (hw
->mac
.type
== e1000_ich8lan
)
449 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw
,
452 if (hw
->mac
.type
== e1000_ich8lan
)
453 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw
,
457 { /* Write-protect NVM */
458 static const struct e1000_option opt
= {
459 .type
= enable_option
,
460 .name
= "Write-protect NVM",
461 .err
= "defaulting to Enabled",
462 .def
= OPTION_ENABLED
465 if (adapter
->flags
& FLAG_IS_ICH
) {
466 if (num_WriteProtectNVM
> bd
) {
467 unsigned int write_protect_nvm
= WriteProtectNVM
[bd
];
468 e1000_validate_option(&write_protect_nvm
, &opt
,
470 if (write_protect_nvm
)
471 adapter
->flags
|= FLAG_READ_ONLY_NVM
;
474 adapter
->flags
|= FLAG_READ_ONLY_NVM
;