blob: 6d8c39abee1676980e7abfd6acbde7545f4ee528 [file] [log] [blame]
David Ertmane78b80b2014-02-04 01:56:06 +00001/* Intel PRO/1000 Linux driver
Yanir Lubetkin529498c2015-06-02 17:05:50 +03002 * Copyright(c) 1999 - 2015 Intel Corporation.
David Ertmane78b80b2014-02-04 01:56:06 +00003 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * The full GNU General Public License is included in this distribution in
14 * the file called "COPYING".
15 *
16 * Contact Information:
17 * Linux NICS <linux.nics@intel.com>
18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 */
Auke Kokbc7f75f2007-09-17 12:30:59 -070021
22#include <linux/netdevice.h>
Paul Gortmaker9d9779e2011-07-03 15:21:01 -040023#include <linux/module.h>
Jeff Kirsher44defeb2008-08-04 17:20:41 -070024#include <linux/pci.h>
Auke Kokbc7f75f2007-09-17 12:30:59 -070025
26#include "e1000.h"
27
Bruce Allane921eb12012-11-28 09:28:37 +000028/* This is the only thing that needs to be changed to adjust the
Auke Kokbc7f75f2007-09-17 12:30:59 -070029 * maximum number of ports that the driver can manage.
30 */
Auke Kokbc7f75f2007-09-17 12:30:59 -070031#define E1000_MAX_NIC 32
32
33#define OPTION_UNSET -1
34#define OPTION_DISABLED 0
35#define OPTION_ENABLED 1
36
37#define COPYBREAK_DEFAULT 256
38unsigned int copybreak = COPYBREAK_DEFAULT;
39module_param(copybreak, uint, 0644);
40MODULE_PARM_DESC(copybreak,
Bruce Allan17e813e2013-02-20 04:06:01 +000041 "Maximum size of packet that is copied to a new buffer on receive");
Auke Kokbc7f75f2007-09-17 12:30:59 -070042
Bruce Allane921eb12012-11-28 09:28:37 +000043/* All parameters are treated the same, as an integer array of values.
Auke Kokbc7f75f2007-09-17 12:30:59 -070044 * This macro just reduces the need to repeat the same declaration code
45 * over and over (plus this helps to avoid typo bugs).
46 */
Auke Kokbc7f75f2007-09-17 12:30:59 -070047#define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
Stephen Hemminger5a9147b2007-10-29 10:46:05 -070048#define E1000_PARAM(X, desc) \
Bruce Allan55c5f552013-01-12 07:28:24 +000049 static int X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
Stephen Hemminger5a9147b2007-10-29 10:46:05 -070050 static unsigned int num_##X; \
51 module_param_array_named(X, X, int, &num_##X, 0); \
Auke Kokbc7f75f2007-09-17 12:30:59 -070052 MODULE_PARM_DESC(X, desc);
53
Bruce Allane921eb12012-11-28 09:28:37 +000054/* Transmit Interrupt Delay in units of 1.024 microseconds
Bruce Allanaf667a22010-12-31 06:10:01 +000055 * Tx interrupt delay needs to typically be set to something non-zero
Auke Kokbc7f75f2007-09-17 12:30:59 -070056 *
57 * Valid Range: 0-65535
58 */
59E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
60#define DEFAULT_TIDV 8
61#define MAX_TXDELAY 0xFFFF
62#define MIN_TXDELAY 0
63
Bruce Allane921eb12012-11-28 09:28:37 +000064/* Transmit Absolute Interrupt Delay in units of 1.024 microseconds
Auke Kokbc7f75f2007-09-17 12:30:59 -070065 *
66 * Valid Range: 0-65535
67 */
68E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
69#define DEFAULT_TADV 32
70#define MAX_TXABSDELAY 0xFFFF
71#define MIN_TXABSDELAY 0
72
Bruce Allane921eb12012-11-28 09:28:37 +000073/* Receive Interrupt Delay in units of 1.024 microseconds
Bruce Allanad680762008-03-28 09:15:03 -070074 * hardware will likely hang if you set this to anything but zero.
Auke Kokbc7f75f2007-09-17 12:30:59 -070075 *
76 * Valid Range: 0-65535
77 */
78E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
Auke Kokbc7f75f2007-09-17 12:30:59 -070079#define MAX_RXDELAY 0xFFFF
80#define MIN_RXDELAY 0
81
Bruce Allane921eb12012-11-28 09:28:37 +000082/* Receive Absolute Interrupt Delay in units of 1.024 microseconds
Auke Kokbc7f75f2007-09-17 12:30:59 -070083 *
84 * Valid Range: 0-65535
85 */
86E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
Auke Kokbc7f75f2007-09-17 12:30:59 -070087#define MAX_RXABSDELAY 0xFFFF
88#define MIN_RXABSDELAY 0
89
Bruce Allane921eb12012-11-28 09:28:37 +000090/* Interrupt Throttle Rate (interrupts/sec)
Auke Kokbc7f75f2007-09-17 12:30:59 -070091 *
Jeff Kirsher727c3562012-04-20 08:51:45 +000092 * Valid Range: 100-100000 or one of: 0=off, 1=dynamic, 3=dynamic conservative
Auke Kokbc7f75f2007-09-17 12:30:59 -070093 */
94E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
95#define DEFAULT_ITR 3
96#define MAX_ITR 100000
97#define MIN_ITR 100
Bruce Allanaf667a22010-12-31 06:10:01 +000098
Bruce Allane921eb12012-11-28 09:28:37 +000099/* IntMode (Interrupt Mode)
Bruce Allan4662e822008-08-26 18:37:06 -0700100 *
Bruce Allanb6fbca22011-12-16 00:45:56 +0000101 * Valid Range: varies depending on kernel configuration & hardware support
Bruce Allan4662e822008-08-26 18:37:06 -0700102 *
Bruce Allanb6fbca22011-12-16 00:45:56 +0000103 * legacy=0, MSI=1, MSI-X=2
104 *
105 * When MSI/MSI-X support is enabled in kernel-
106 * Default Value: 2 (MSI-X) when supported by hardware, 1 (MSI) otherwise
107 * When MSI/MSI-X support is not enabled in kernel-
108 * Default Value: 0 (legacy)
109 *
110 * When a mode is specified that is not allowed/supported, it will be
111 * demoted to the most advanced interrupt mode available.
Bruce Allan4662e822008-08-26 18:37:06 -0700112 */
113E1000_PARAM(IntMode, "Interrupt Mode");
114#define MAX_INTMODE 2
115#define MIN_INTMODE 0
Auke Kokbc7f75f2007-09-17 12:30:59 -0700116
Bruce Allane921eb12012-11-28 09:28:37 +0000117/* Enable Smart Power Down of the PHY
Auke Kokbc7f75f2007-09-17 12:30:59 -0700118 *
119 * Valid Range: 0, 1
120 *
121 * Default Value: 0 (disabled)
122 */
123E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
124
Bruce Allane921eb12012-11-28 09:28:37 +0000125/* Enable Kumeran Lock Loss workaround
Auke Kokbc7f75f2007-09-17 12:30:59 -0700126 *
127 * Valid Range: 0, 1
128 *
129 * Default Value: 1 (enabled)
130 */
131E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");
132
Bruce Allane921eb12012-11-28 09:28:37 +0000133/* Write Protect NVM
Bruce Allan4a770352008-10-01 17:18:35 -0700134 *
135 * Valid Range: 0, 1
136 *
137 * Default Value: 1 (enabled)
138 */
Bruce Allanc29c3ba2013-02-20 04:05:50 +0000139E1000_PARAM(WriteProtectNVM,
140 "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]");
Bruce Allan4a770352008-10-01 17:18:35 -0700141
Bruce Allane921eb12012-11-28 09:28:37 +0000142/* Enable CRC Stripping
Jeff Kirshereb7c3ad2008-11-14 06:45:23 +0000143 *
144 * Valid Range: 0, 1
145 *
146 * Default Value: 1 (enabled)
147 */
Bruce Allan6ad65142012-04-12 05:47:09 +0000148E1000_PARAM(CrcStripping,
149 "Enable CRC Stripping, disable if your BMC needs the CRC");
Jeff Kirshereb7c3ad2008-11-14 06:45:23 +0000150
Auke Kokbc7f75f2007-09-17 12:30:59 -0700151struct e1000_option {
152 enum { enable_option, range_option, list_option } type;
Stephen Hemminger5a9147b2007-10-29 10:46:05 -0700153 const char *name;
154 const char *err;
155 int def;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700156 union {
Bruce Allan33550ce2013-02-20 04:06:16 +0000157 /* range_option info */
158 struct {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700159 int min;
160 int max;
161 } r;
Bruce Allan33550ce2013-02-20 04:06:16 +0000162 /* list_option info */
163 struct {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700164 int nr;
Bruce Allanbbf441272013-02-20 04:06:37 +0000165 struct e1000_opt_list {
166 int i;
167 char *str;
168 } *p;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700169 } l;
170 } arg;
171};
172
Bill Pemberton9f9a12f2012-12-03 09:24:25 -0500173static int e1000_validate_option(unsigned int *value,
Greg Kroah-Hartman1dd06ae2012-12-06 14:30:56 +0000174 const struct e1000_option *opt,
175 struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700176{
177 if (*value == OPTION_UNSET) {
178 *value = opt->def;
179 return 0;
180 }
181
182 switch (opt->type) {
183 case enable_option:
184 switch (*value) {
185 case OPTION_ENABLED:
Bruce Allan185095f2012-06-07 02:23:37 +0000186 dev_info(&adapter->pdev->dev, "%s Enabled\n",
187 opt->name);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700188 return 0;
189 case OPTION_DISABLED:
Bruce Allan185095f2012-06-07 02:23:37 +0000190 dev_info(&adapter->pdev->dev, "%s Disabled\n",
191 opt->name);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700192 return 0;
193 }
194 break;
195 case range_option:
196 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
Bruce Allan185095f2012-06-07 02:23:37 +0000197 dev_info(&adapter->pdev->dev, "%s set to %i\n",
198 opt->name, *value);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700199 return 0;
200 }
201 break;
202 case list_option: {
203 int i;
204 struct e1000_opt_list *ent;
205
206 for (i = 0; i < opt->arg.l.nr; i++) {
207 ent = &opt->arg.l.p[i];
208 if (*value == ent->i) {
209 if (ent->str[0] != '\0')
Bruce Allan185095f2012-06-07 02:23:37 +0000210 dev_info(&adapter->pdev->dev, "%s\n",
211 ent->str);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700212 return 0;
213 }
214 }
215 }
216 break;
217 default:
218 BUG();
219 }
220
Bruce Allan185095f2012-06-07 02:23:37 +0000221 dev_info(&adapter->pdev->dev, "Invalid %s value specified (%i) %s\n",
222 opt->name, *value, opt->err);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700223 *value = opt->def;
224 return -1;
225}
226
227/**
228 * e1000e_check_options - Range Checking for Command Line Parameters
229 * @adapter: board private structure
230 *
231 * This routine checks all command line parameters for valid user
232 * input. If an invalid value is given, or if no user specified
233 * value exists, a default value is used. The final value is stored
234 * in a variable in the adapter structure.
235 **/
Bill Pemberton9f9a12f2012-12-03 09:24:25 -0500236void e1000e_check_options(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700237{
238 struct e1000_hw *hw = &adapter->hw;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700239 int bd = adapter->bd_number;
240
241 if (bd >= E1000_MAX_NIC) {
Bruce Allan185095f2012-06-07 02:23:37 +0000242 dev_notice(&adapter->pdev->dev,
243 "Warning: no configuration for board #%i\n", bd);
244 dev_notice(&adapter->pdev->dev,
245 "Using defaults for all values\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700246 }
247
Bruce Allan33550ce2013-02-20 04:06:16 +0000248 /* Transmit Interrupt Delay */
249 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000250 static const struct e1000_option opt = {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700251 .type = range_option,
252 .name = "Transmit Interrupt Delay",
253 .err = "using default of "
254 __MODULE_STRING(DEFAULT_TIDV),
255 .def = DEFAULT_TIDV,
256 .arg = { .r = { .min = MIN_TXDELAY,
257 .max = MAX_TXDELAY } }
258 };
259
260 if (num_TxIntDelay > bd) {
261 adapter->tx_int_delay = TxIntDelay[bd];
262 e1000_validate_option(&adapter->tx_int_delay, &opt,
263 adapter);
264 } else {
265 adapter->tx_int_delay = opt.def;
266 }
267 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000268 /* Transmit Absolute Interrupt Delay */
269 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000270 static const struct e1000_option opt = {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700271 .type = range_option,
272 .name = "Transmit Absolute Interrupt Delay",
273 .err = "using default of "
274 __MODULE_STRING(DEFAULT_TADV),
275 .def = DEFAULT_TADV,
276 .arg = { .r = { .min = MIN_TXABSDELAY,
277 .max = MAX_TXABSDELAY } }
278 };
279
280 if (num_TxAbsIntDelay > bd) {
281 adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
282 e1000_validate_option(&adapter->tx_abs_int_delay, &opt,
283 adapter);
284 } else {
285 adapter->tx_abs_int_delay = opt.def;
286 }
287 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000288 /* Receive Interrupt Delay */
289 {
Bruce Allan4fe44912010-05-10 14:59:10 +0000290 static struct e1000_option opt = {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700291 .type = range_option,
292 .name = "Receive Interrupt Delay",
293 .err = "using default of "
294 __MODULE_STRING(DEFAULT_RDTR),
295 .def = DEFAULT_RDTR,
296 .arg = { .r = { .min = MIN_RXDELAY,
297 .max = MAX_RXDELAY } }
298 };
299
Auke Kokbc7f75f2007-09-17 12:30:59 -0700300 if (num_RxIntDelay > bd) {
301 adapter->rx_int_delay = RxIntDelay[bd];
302 e1000_validate_option(&adapter->rx_int_delay, &opt,
303 adapter);
304 } else {
305 adapter->rx_int_delay = opt.def;
306 }
307 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000308 /* Receive Absolute Interrupt Delay */
309 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000310 static const struct e1000_option opt = {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700311 .type = range_option,
312 .name = "Receive Absolute Interrupt Delay",
313 .err = "using default of "
314 __MODULE_STRING(DEFAULT_RADV),
315 .def = DEFAULT_RADV,
316 .arg = { .r = { .min = MIN_RXABSDELAY,
317 .max = MAX_RXABSDELAY } }
318 };
319
320 if (num_RxAbsIntDelay > bd) {
321 adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
322 e1000_validate_option(&adapter->rx_abs_int_delay, &opt,
323 adapter);
324 } else {
325 adapter->rx_abs_int_delay = opt.def;
326 }
327 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000328 /* Interrupt Throttling Rate */
329 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000330 static const struct e1000_option opt = {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700331 .type = range_option,
332 .name = "Interrupt Throttling Rate (ints/sec)",
333 .err = "using default of "
334 __MODULE_STRING(DEFAULT_ITR),
335 .def = DEFAULT_ITR,
336 .arg = { .r = { .min = MIN_ITR,
337 .max = MAX_ITR } }
338 };
339
340 if (num_InterruptThrottleRate > bd) {
341 adapter->itr = InterruptThrottleRate[bd];
Jeff Kirsher2e7d21c2012-05-09 02:23:46 -0700342
Bruce Allane921eb12012-11-28 09:28:37 +0000343 /* Make sure a message is printed for non-special
Jeff Kirsher2e7d21c2012-05-09 02:23:46 -0700344 * values. And in case of an invalid option, display
345 * warning, use default and go through itr/itr_setting
346 * adjustment logic below
347 */
348 if ((adapter->itr > 4) &&
349 e1000_validate_option(&adapter->itr, &opt, adapter))
350 adapter->itr = opt.def;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700351 } else {
Bruce Allane921eb12012-11-28 09:28:37 +0000352 /* If no option specified, use default value and go
Jeff Kirsher727c3562012-04-20 08:51:45 +0000353 * through the logic below to adjust itr/itr_setting
354 */
355 adapter->itr = opt.def;
356
Bruce Allane921eb12012-11-28 09:28:37 +0000357 /* Make sure a message is printed for non-special
Jeff Kirsher727c3562012-04-20 08:51:45 +0000358 * default values
359 */
Jeff Kirsher2e7d21c2012-05-09 02:23:46 -0700360 if (adapter->itr > 4)
Bruce Allan185095f2012-06-07 02:23:37 +0000361 dev_info(&adapter->pdev->dev,
362 "%s set to default %d\n", opt.name,
363 adapter->itr);
Jeff Kirsher727c3562012-04-20 08:51:45 +0000364 }
365
366 adapter->itr_setting = adapter->itr;
367 switch (adapter->itr) {
368 case 0:
Bruce Allan185095f2012-06-07 02:23:37 +0000369 dev_info(&adapter->pdev->dev, "%s turned off\n",
370 opt.name);
Jeff Kirsher727c3562012-04-20 08:51:45 +0000371 break;
372 case 1:
Bruce Allan185095f2012-06-07 02:23:37 +0000373 dev_info(&adapter->pdev->dev,
374 "%s set to dynamic mode\n", opt.name);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700375 adapter->itr = 20000;
Jeff Kirsher727c3562012-04-20 08:51:45 +0000376 break;
David Ertman5bb73172014-02-26 00:02:24 +0000377 case 2:
378 dev_info(&adapter->pdev->dev,
379 "%s Invalid mode - setting default\n",
380 opt.name);
381 adapter->itr_setting = opt.def;
382 /* fall-through */
Jeff Kirsher727c3562012-04-20 08:51:45 +0000383 case 3:
Bruce Allan185095f2012-06-07 02:23:37 +0000384 dev_info(&adapter->pdev->dev,
385 "%s set to dynamic conservative mode\n",
386 opt.name);
Jeff Kirsher727c3562012-04-20 08:51:45 +0000387 adapter->itr = 20000;
388 break;
389 case 4:
Bruce Allan185095f2012-06-07 02:23:37 +0000390 dev_info(&adapter->pdev->dev,
391 "%s set to simplified (2000-8000 ints) mode\n",
392 opt.name);
Jeff Kirsher727c3562012-04-20 08:51:45 +0000393 break;
394 default:
Bruce Allane921eb12012-11-28 09:28:37 +0000395 /* Save the setting, because the dynamic bits
Jeff Kirsher727c3562012-04-20 08:51:45 +0000396 * change itr.
397 *
398 * Clear the lower two bits because
399 * they are used as control.
400 */
401 adapter->itr_setting &= ~3;
402 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700403 }
404 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000405 /* Interrupt Mode */
406 {
Bruce Allan4fe44912010-05-10 14:59:10 +0000407 static struct e1000_option opt = {
Bruce Allan4662e822008-08-26 18:37:06 -0700408 .type = range_option,
409 .name = "Interrupt Mode",
Bruce Allanb6fbca22011-12-16 00:45:56 +0000410#ifndef CONFIG_PCI_MSI
411 .err = "defaulting to 0 (legacy)",
412 .def = E1000E_INT_MODE_LEGACY,
413 .arg = { .r = { .min = 0,
414 .max = 0 } }
415#endif
Bruce Allan4662e822008-08-26 18:37:06 -0700416 };
417
Bruce Allanb6fbca22011-12-16 00:45:56 +0000418#ifdef CONFIG_PCI_MSI
419 if (adapter->flags & FLAG_HAS_MSIX) {
420 opt.err = kstrdup("defaulting to 2 (MSI-X)",
421 GFP_KERNEL);
422 opt.def = E1000E_INT_MODE_MSIX;
423 opt.arg.r.max = E1000E_INT_MODE_MSIX;
424 } else {
425 opt.err = kstrdup("defaulting to 1 (MSI)", GFP_KERNEL);
426 opt.def = E1000E_INT_MODE_MSI;
427 opt.arg.r.max = E1000E_INT_MODE_MSI;
428 }
429
430 if (!opt.err) {
431 dev_err(&adapter->pdev->dev,
432 "Failed to allocate memory\n");
433 return;
434 }
435#endif
436
Bruce Allan4662e822008-08-26 18:37:06 -0700437 if (num_IntMode > bd) {
438 unsigned int int_mode = IntMode[bd];
David Ertman6cf08d12014-04-05 06:07:00 +0000439
Bruce Allan4662e822008-08-26 18:37:06 -0700440 e1000_validate_option(&int_mode, &opt, adapter);
441 adapter->int_mode = int_mode;
442 } else {
443 adapter->int_mode = opt.def;
444 }
Bruce Allanb6fbca22011-12-16 00:45:56 +0000445
446#ifdef CONFIG_PCI_MSI
447 kfree(opt.err);
448#endif
Bruce Allan4662e822008-08-26 18:37:06 -0700449 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000450 /* Smart Power Down */
451 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000452 static const struct e1000_option opt = {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700453 .type = enable_option,
454 .name = "PHY Smart Power Down",
455 .err = "defaulting to Disabled",
456 .def = OPTION_DISABLED
457 };
458
459 if (num_SmartPowerDownEnable > bd) {
Stephen Hemminger5a9147b2007-10-29 10:46:05 -0700460 unsigned int spd = SmartPowerDownEnable[bd];
David Ertman6cf08d12014-04-05 06:07:00 +0000461
Auke Kokbc7f75f2007-09-17 12:30:59 -0700462 e1000_validate_option(&spd, &opt, adapter);
Bruce Allan1860ac82012-12-05 06:26:40 +0000463 if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) && spd)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700464 adapter->flags |= FLAG_SMART_POWER_DOWN;
465 }
466 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000467 /* CRC Stripping */
468 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000469 static const struct e1000_option opt = {
Jeff Kirshereb7c3ad2008-11-14 06:45:23 +0000470 .type = enable_option,
471 .name = "CRC Stripping",
Bruce Allane9262442010-11-24 06:02:06 +0000472 .err = "defaulting to Enabled",
Jeff Kirshereb7c3ad2008-11-14 06:45:23 +0000473 .def = OPTION_ENABLED
474 };
475
476 if (num_CrcStripping > bd) {
477 unsigned int crc_stripping = CrcStripping[bd];
David Ertman6cf08d12014-04-05 06:07:00 +0000478
Jeff Kirshereb7c3ad2008-11-14 06:45:23 +0000479 e1000_validate_option(&crc_stripping, &opt, adapter);
Ben Greear01840392012-02-11 15:39:25 +0000480 if (crc_stripping == OPTION_ENABLED) {
Jeff Kirshereb7c3ad2008-11-14 06:45:23 +0000481 adapter->flags2 |= FLAG2_CRC_STRIPPING;
Ben Greear01840392012-02-11 15:39:25 +0000482 adapter->flags2 |= FLAG2_DFLT_CRC_STRIPPING;
483 }
Bruce Allan6e50912a2009-06-02 11:28:01 +0000484 } else {
485 adapter->flags2 |= FLAG2_CRC_STRIPPING;
Ben Greear01840392012-02-11 15:39:25 +0000486 adapter->flags2 |= FLAG2_DFLT_CRC_STRIPPING;
Jeff Kirshereb7c3ad2008-11-14 06:45:23 +0000487 }
488 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000489 /* Kumeran Lock Loss Workaround */
490 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000491 static const struct e1000_option opt = {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700492 .type = enable_option,
493 .name = "Kumeran Lock Loss Workaround",
494 .err = "defaulting to Enabled",
495 .def = OPTION_ENABLED
496 };
Bruce Allan17e813e2013-02-20 04:06:01 +0000497 bool enabled = opt.def;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700498
499 if (num_KumeranLockLoss > bd) {
Stephen Hemminger5a9147b2007-10-29 10:46:05 -0700500 unsigned int kmrn_lock_loss = KumeranLockLoss[bd];
David Ertman6cf08d12014-04-05 06:07:00 +0000501
Auke Kokbc7f75f2007-09-17 12:30:59 -0700502 e1000_validate_option(&kmrn_lock_loss, &opt, adapter);
Bruce Allan17e813e2013-02-20 04:06:01 +0000503 enabled = kmrn_lock_loss;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700504 }
Bruce Allan17e813e2013-02-20 04:06:01 +0000505
506 if (hw->mac.type == e1000_ich8lan)
507 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw,
508 enabled);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700509 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000510 /* Write-protect NVM */
511 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000512 static const struct e1000_option opt = {
Bruce Allan4a770352008-10-01 17:18:35 -0700513 .type = enable_option,
514 .name = "Write-protect NVM",
515 .err = "defaulting to Enabled",
516 .def = OPTION_ENABLED
517 };
518
519 if (adapter->flags & FLAG_IS_ICH) {
520 if (num_WriteProtectNVM > bd) {
Bruce Allanc29c3ba2013-02-20 04:05:50 +0000521 unsigned int write_protect_nvm =
522 WriteProtectNVM[bd];
Bruce Allan4a770352008-10-01 17:18:35 -0700523 e1000_validate_option(&write_protect_nvm, &opt,
524 adapter);
525 if (write_protect_nvm)
526 adapter->flags |= FLAG_READ_ONLY_NVM;
527 } else {
528 if (opt.def)
529 adapter->flags |= FLAG_READ_ONLY_NVM;
530 }
531 }
532 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700533}