blob: 36bf39d54d79b95ab3e972e90a7dfb698c598381 [file] [log] [blame]
Auke Kokbc7f75f2007-09-17 12:30:59 -07001/*******************************************************************************
2
3 Intel PRO/1000 Linux driver
Bruce Allanbf670442013-01-01 16:00:01 +00004 Copyright(c) 1999 - 2013 Intel Corporation.
Auke Kokbc7f75f2007-09-17 12:30:59 -07005
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.
9
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.
14
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.
18
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
21
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
26
27*******************************************************************************/
28
29#include <linux/netdevice.h>
Paul Gortmaker9d9779e2011-07-03 15:21:01 -040030#include <linux/module.h>
Jeff Kirsher44defeb2008-08-04 17:20:41 -070031#include <linux/pci.h>
Auke Kokbc7f75f2007-09-17 12:30:59 -070032
33#include "e1000.h"
34
Bruce Allane921eb12012-11-28 09:28:37 +000035/* This is the only thing that needs to be changed to adjust the
Auke Kokbc7f75f2007-09-17 12:30:59 -070036 * maximum number of ports that the driver can manage.
37 */
Auke Kokbc7f75f2007-09-17 12:30:59 -070038#define E1000_MAX_NIC 32
39
40#define OPTION_UNSET -1
41#define OPTION_DISABLED 0
42#define OPTION_ENABLED 1
43
44#define COPYBREAK_DEFAULT 256
45unsigned int copybreak = COPYBREAK_DEFAULT;
46module_param(copybreak, uint, 0644);
47MODULE_PARM_DESC(copybreak,
Bruce Allan17e813e2013-02-20 04:06:01 +000048 "Maximum size of packet that is copied to a new buffer on receive");
Auke Kokbc7f75f2007-09-17 12:30:59 -070049
Bruce Allane921eb12012-11-28 09:28:37 +000050/* All parameters are treated the same, as an integer array of values.
Auke Kokbc7f75f2007-09-17 12:30:59 -070051 * This macro just reduces the need to repeat the same declaration code
52 * over and over (plus this helps to avoid typo bugs).
53 */
Auke Kokbc7f75f2007-09-17 12:30:59 -070054#define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
Stephen Hemminger5a9147b2007-10-29 10:46:05 -070055#define E1000_PARAM(X, desc) \
Bruce Allan55c5f552013-01-12 07:28:24 +000056 static int X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
Stephen Hemminger5a9147b2007-10-29 10:46:05 -070057 static unsigned int num_##X; \
58 module_param_array_named(X, X, int, &num_##X, 0); \
Auke Kokbc7f75f2007-09-17 12:30:59 -070059 MODULE_PARM_DESC(X, desc);
60
Bruce Allane921eb12012-11-28 09:28:37 +000061/* Transmit Interrupt Delay in units of 1.024 microseconds
Bruce Allanaf667a22010-12-31 06:10:01 +000062 * Tx interrupt delay needs to typically be set to something non-zero
Auke Kokbc7f75f2007-09-17 12:30:59 -070063 *
64 * Valid Range: 0-65535
65 */
66E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
67#define DEFAULT_TIDV 8
68#define MAX_TXDELAY 0xFFFF
69#define MIN_TXDELAY 0
70
Bruce Allane921eb12012-11-28 09:28:37 +000071/* Transmit Absolute Interrupt Delay in units of 1.024 microseconds
Auke Kokbc7f75f2007-09-17 12:30:59 -070072 *
73 * Valid Range: 0-65535
74 */
75E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
76#define DEFAULT_TADV 32
77#define MAX_TXABSDELAY 0xFFFF
78#define MIN_TXABSDELAY 0
79
Bruce Allane921eb12012-11-28 09:28:37 +000080/* Receive Interrupt Delay in units of 1.024 microseconds
Bruce Allanad680762008-03-28 09:15:03 -070081 * hardware will likely hang if you set this to anything but zero.
Auke Kokbc7f75f2007-09-17 12:30:59 -070082 *
83 * Valid Range: 0-65535
84 */
85E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
Auke Kokbc7f75f2007-09-17 12:30:59 -070086#define MAX_RXDELAY 0xFFFF
87#define MIN_RXDELAY 0
88
Bruce Allane921eb12012-11-28 09:28:37 +000089/* Receive Absolute Interrupt Delay in units of 1.024 microseconds
Auke Kokbc7f75f2007-09-17 12:30:59 -070090 *
91 * Valid Range: 0-65535
92 */
93E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
Auke Kokbc7f75f2007-09-17 12:30:59 -070094#define MAX_RXABSDELAY 0xFFFF
95#define MIN_RXABSDELAY 0
96
Bruce Allane921eb12012-11-28 09:28:37 +000097/* Interrupt Throttle Rate (interrupts/sec)
Auke Kokbc7f75f2007-09-17 12:30:59 -070098 *
Jeff Kirsher727c3562012-04-20 08:51:45 +000099 * Valid Range: 100-100000 or one of: 0=off, 1=dynamic, 3=dynamic conservative
Auke Kokbc7f75f2007-09-17 12:30:59 -0700100 */
101E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
102#define DEFAULT_ITR 3
103#define MAX_ITR 100000
104#define MIN_ITR 100
Bruce Allanaf667a22010-12-31 06:10:01 +0000105
Bruce Allane921eb12012-11-28 09:28:37 +0000106/* IntMode (Interrupt Mode)
Bruce Allan4662e822008-08-26 18:37:06 -0700107 *
Bruce Allanb6fbca22011-12-16 00:45:56 +0000108 * Valid Range: varies depending on kernel configuration & hardware support
Bruce Allan4662e822008-08-26 18:37:06 -0700109 *
Bruce Allanb6fbca22011-12-16 00:45:56 +0000110 * legacy=0, MSI=1, MSI-X=2
111 *
112 * When MSI/MSI-X support is enabled in kernel-
113 * Default Value: 2 (MSI-X) when supported by hardware, 1 (MSI) otherwise
114 * When MSI/MSI-X support is not enabled in kernel-
115 * Default Value: 0 (legacy)
116 *
117 * When a mode is specified that is not allowed/supported, it will be
118 * demoted to the most advanced interrupt mode available.
Bruce Allan4662e822008-08-26 18:37:06 -0700119 */
120E1000_PARAM(IntMode, "Interrupt Mode");
121#define MAX_INTMODE 2
122#define MIN_INTMODE 0
Auke Kokbc7f75f2007-09-17 12:30:59 -0700123
Bruce Allane921eb12012-11-28 09:28:37 +0000124/* Enable Smart Power Down of the PHY
Auke Kokbc7f75f2007-09-17 12:30:59 -0700125 *
126 * Valid Range: 0, 1
127 *
128 * Default Value: 0 (disabled)
129 */
130E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
131
Bruce Allane921eb12012-11-28 09:28:37 +0000132/* Enable Kumeran Lock Loss workaround
Auke Kokbc7f75f2007-09-17 12:30:59 -0700133 *
134 * Valid Range: 0, 1
135 *
136 * Default Value: 1 (enabled)
137 */
138E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");
139
Bruce Allane921eb12012-11-28 09:28:37 +0000140/* Write Protect NVM
Bruce Allan4a770352008-10-01 17:18:35 -0700141 *
142 * Valid Range: 0, 1
143 *
144 * Default Value: 1 (enabled)
145 */
Bruce Allanc29c3ba2013-02-20 04:05:50 +0000146E1000_PARAM(WriteProtectNVM,
147 "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]");
Bruce Allan4a770352008-10-01 17:18:35 -0700148
Bruce Allane921eb12012-11-28 09:28:37 +0000149/* Enable CRC Stripping
Jeff Kirshereb7c3ad2008-11-14 06:45:23 +0000150 *
151 * Valid Range: 0, 1
152 *
153 * Default Value: 1 (enabled)
154 */
Bruce Allan6ad65142012-04-12 05:47:09 +0000155E1000_PARAM(CrcStripping,
156 "Enable CRC Stripping, disable if your BMC needs the CRC");
Jeff Kirshereb7c3ad2008-11-14 06:45:23 +0000157
Auke Kokbc7f75f2007-09-17 12:30:59 -0700158struct e1000_option {
159 enum { enable_option, range_option, list_option } type;
Stephen Hemminger5a9147b2007-10-29 10:46:05 -0700160 const char *name;
161 const char *err;
162 int def;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700163 union {
Bruce Allan33550ce2013-02-20 04:06:16 +0000164 /* range_option info */
165 struct {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700166 int min;
167 int max;
168 } r;
Bruce Allan33550ce2013-02-20 04:06:16 +0000169 /* list_option info */
170 struct {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700171 int nr;
172 struct e1000_opt_list { int i; char *str; } *p;
173 } l;
174 } arg;
175};
176
Bill Pemberton9f9a12f2012-12-03 09:24:25 -0500177static int e1000_validate_option(unsigned int *value,
Greg Kroah-Hartman1dd06ae2012-12-06 14:30:56 +0000178 const struct e1000_option *opt,
179 struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700180{
181 if (*value == OPTION_UNSET) {
182 *value = opt->def;
183 return 0;
184 }
185
186 switch (opt->type) {
187 case enable_option:
188 switch (*value) {
189 case OPTION_ENABLED:
Bruce Allan185095f2012-06-07 02:23:37 +0000190 dev_info(&adapter->pdev->dev, "%s Enabled\n",
191 opt->name);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700192 return 0;
193 case OPTION_DISABLED:
Bruce Allan185095f2012-06-07 02:23:37 +0000194 dev_info(&adapter->pdev->dev, "%s Disabled\n",
195 opt->name);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700196 return 0;
197 }
198 break;
199 case range_option:
200 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
Bruce Allan185095f2012-06-07 02:23:37 +0000201 dev_info(&adapter->pdev->dev, "%s set to %i\n",
202 opt->name, *value);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700203 return 0;
204 }
205 break;
206 case list_option: {
207 int i;
208 struct e1000_opt_list *ent;
209
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')
Bruce Allan185095f2012-06-07 02:23:37 +0000214 dev_info(&adapter->pdev->dev, "%s\n",
215 ent->str);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700216 return 0;
217 }
218 }
219 }
220 break;
221 default:
222 BUG();
223 }
224
Bruce Allan185095f2012-06-07 02:23:37 +0000225 dev_info(&adapter->pdev->dev, "Invalid %s value specified (%i) %s\n",
226 opt->name, *value, opt->err);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700227 *value = opt->def;
228 return -1;
229}
230
231/**
232 * e1000e_check_options - Range Checking for Command Line Parameters
233 * @adapter: board private structure
234 *
235 * This routine checks all command line parameters for valid user
236 * input. If an invalid value is given, or if no user specified
237 * value exists, a default value is used. The final value is stored
238 * in a variable in the adapter structure.
239 **/
Bill Pemberton9f9a12f2012-12-03 09:24:25 -0500240void e1000e_check_options(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700241{
242 struct e1000_hw *hw = &adapter->hw;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700243 int bd = adapter->bd_number;
244
245 if (bd >= E1000_MAX_NIC) {
Bruce Allan185095f2012-06-07 02:23:37 +0000246 dev_notice(&adapter->pdev->dev,
247 "Warning: no configuration for board #%i\n", bd);
248 dev_notice(&adapter->pdev->dev,
249 "Using defaults for all values\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700250 }
251
Bruce Allan33550ce2013-02-20 04:06:16 +0000252 /* Transmit Interrupt Delay */
253 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000254 static const struct e1000_option opt = {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700255 .type = range_option,
256 .name = "Transmit Interrupt Delay",
257 .err = "using default of "
258 __MODULE_STRING(DEFAULT_TIDV),
259 .def = DEFAULT_TIDV,
260 .arg = { .r = { .min = MIN_TXDELAY,
261 .max = MAX_TXDELAY } }
262 };
263
264 if (num_TxIntDelay > bd) {
265 adapter->tx_int_delay = TxIntDelay[bd];
266 e1000_validate_option(&adapter->tx_int_delay, &opt,
267 adapter);
268 } else {
269 adapter->tx_int_delay = opt.def;
270 }
271 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000272 /* Transmit Absolute Interrupt Delay */
273 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000274 static const struct e1000_option opt = {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700275 .type = range_option,
276 .name = "Transmit Absolute Interrupt Delay",
277 .err = "using default of "
278 __MODULE_STRING(DEFAULT_TADV),
279 .def = DEFAULT_TADV,
280 .arg = { .r = { .min = MIN_TXABSDELAY,
281 .max = MAX_TXABSDELAY } }
282 };
283
284 if (num_TxAbsIntDelay > bd) {
285 adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
286 e1000_validate_option(&adapter->tx_abs_int_delay, &opt,
287 adapter);
288 } else {
289 adapter->tx_abs_int_delay = opt.def;
290 }
291 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000292 /* Receive Interrupt Delay */
293 {
Bruce Allan4fe44912010-05-10 14:59:10 +0000294 static struct e1000_option opt = {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700295 .type = range_option,
296 .name = "Receive Interrupt Delay",
297 .err = "using default of "
298 __MODULE_STRING(DEFAULT_RDTR),
299 .def = DEFAULT_RDTR,
300 .arg = { .r = { .min = MIN_RXDELAY,
301 .max = MAX_RXDELAY } }
302 };
303
Auke Kokbc7f75f2007-09-17 12:30:59 -0700304 if (num_RxIntDelay > bd) {
305 adapter->rx_int_delay = RxIntDelay[bd];
306 e1000_validate_option(&adapter->rx_int_delay, &opt,
307 adapter);
308 } else {
309 adapter->rx_int_delay = opt.def;
310 }
311 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000312 /* Receive Absolute Interrupt Delay */
313 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000314 static const struct e1000_option opt = {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700315 .type = range_option,
316 .name = "Receive Absolute Interrupt Delay",
317 .err = "using default of "
318 __MODULE_STRING(DEFAULT_RADV),
319 .def = DEFAULT_RADV,
320 .arg = { .r = { .min = MIN_RXABSDELAY,
321 .max = MAX_RXABSDELAY } }
322 };
323
324 if (num_RxAbsIntDelay > bd) {
325 adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
326 e1000_validate_option(&adapter->rx_abs_int_delay, &opt,
327 adapter);
328 } else {
329 adapter->rx_abs_int_delay = opt.def;
330 }
331 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000332 /* Interrupt Throttling Rate */
333 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000334 static const struct e1000_option opt = {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700335 .type = range_option,
336 .name = "Interrupt Throttling Rate (ints/sec)",
337 .err = "using default of "
338 __MODULE_STRING(DEFAULT_ITR),
339 .def = DEFAULT_ITR,
340 .arg = { .r = { .min = MIN_ITR,
341 .max = MAX_ITR } }
342 };
343
344 if (num_InterruptThrottleRate > bd) {
345 adapter->itr = InterruptThrottleRate[bd];
Jeff Kirsher2e7d21c2012-05-09 02:23:46 -0700346
Bruce Allane921eb12012-11-28 09:28:37 +0000347 /* Make sure a message is printed for non-special
Jeff Kirsher2e7d21c2012-05-09 02:23:46 -0700348 * values. And in case of an invalid option, display
349 * warning, use default and go through itr/itr_setting
350 * adjustment logic below
351 */
352 if ((adapter->itr > 4) &&
353 e1000_validate_option(&adapter->itr, &opt, adapter))
354 adapter->itr = opt.def;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700355 } else {
Bruce Allane921eb12012-11-28 09:28:37 +0000356 /* If no option specified, use default value and go
Jeff Kirsher727c3562012-04-20 08:51:45 +0000357 * through the logic below to adjust itr/itr_setting
358 */
359 adapter->itr = opt.def;
360
Bruce Allane921eb12012-11-28 09:28:37 +0000361 /* Make sure a message is printed for non-special
Jeff Kirsher727c3562012-04-20 08:51:45 +0000362 * default values
363 */
Jeff Kirsher2e7d21c2012-05-09 02:23:46 -0700364 if (adapter->itr > 4)
Bruce Allan185095f2012-06-07 02:23:37 +0000365 dev_info(&adapter->pdev->dev,
366 "%s set to default %d\n", opt.name,
367 adapter->itr);
Jeff Kirsher727c3562012-04-20 08:51:45 +0000368 }
369
370 adapter->itr_setting = adapter->itr;
371 switch (adapter->itr) {
372 case 0:
Bruce Allan185095f2012-06-07 02:23:37 +0000373 dev_info(&adapter->pdev->dev, "%s turned off\n",
374 opt.name);
Jeff Kirsher727c3562012-04-20 08:51:45 +0000375 break;
376 case 1:
Bruce Allan185095f2012-06-07 02:23:37 +0000377 dev_info(&adapter->pdev->dev,
378 "%s set to dynamic mode\n", opt.name);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700379 adapter->itr = 20000;
Jeff Kirsher727c3562012-04-20 08:51:45 +0000380 break;
381 case 3:
Bruce Allan185095f2012-06-07 02:23:37 +0000382 dev_info(&adapter->pdev->dev,
383 "%s set to dynamic conservative mode\n",
384 opt.name);
Jeff Kirsher727c3562012-04-20 08:51:45 +0000385 adapter->itr = 20000;
386 break;
387 case 4:
Bruce Allan185095f2012-06-07 02:23:37 +0000388 dev_info(&adapter->pdev->dev,
389 "%s set to simplified (2000-8000 ints) mode\n",
390 opt.name);
Jeff Kirsher727c3562012-04-20 08:51:45 +0000391 break;
392 default:
Bruce Allane921eb12012-11-28 09:28:37 +0000393 /* Save the setting, because the dynamic bits
Jeff Kirsher727c3562012-04-20 08:51:45 +0000394 * change itr.
395 *
396 * Clear the lower two bits because
397 * they are used as control.
398 */
399 adapter->itr_setting &= ~3;
400 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700401 }
402 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000403 /* Interrupt Mode */
404 {
Bruce Allan4fe44912010-05-10 14:59:10 +0000405 static struct e1000_option opt = {
Bruce Allan4662e822008-08-26 18:37:06 -0700406 .type = range_option,
407 .name = "Interrupt Mode",
Bruce Allanb6fbca22011-12-16 00:45:56 +0000408#ifndef CONFIG_PCI_MSI
409 .err = "defaulting to 0 (legacy)",
410 .def = E1000E_INT_MODE_LEGACY,
411 .arg = { .r = { .min = 0,
412 .max = 0 } }
413#endif
Bruce Allan4662e822008-08-26 18:37:06 -0700414 };
415
Bruce Allanb6fbca22011-12-16 00:45:56 +0000416#ifdef CONFIG_PCI_MSI
417 if (adapter->flags & FLAG_HAS_MSIX) {
418 opt.err = kstrdup("defaulting to 2 (MSI-X)",
419 GFP_KERNEL);
420 opt.def = E1000E_INT_MODE_MSIX;
421 opt.arg.r.max = E1000E_INT_MODE_MSIX;
422 } else {
423 opt.err = kstrdup("defaulting to 1 (MSI)", GFP_KERNEL);
424 opt.def = E1000E_INT_MODE_MSI;
425 opt.arg.r.max = E1000E_INT_MODE_MSI;
426 }
427
428 if (!opt.err) {
429 dev_err(&adapter->pdev->dev,
430 "Failed to allocate memory\n");
431 return;
432 }
433#endif
434
Bruce Allan4662e822008-08-26 18:37:06 -0700435 if (num_IntMode > bd) {
436 unsigned int int_mode = IntMode[bd];
437 e1000_validate_option(&int_mode, &opt, adapter);
438 adapter->int_mode = int_mode;
439 } else {
440 adapter->int_mode = opt.def;
441 }
Bruce Allanb6fbca22011-12-16 00:45:56 +0000442
443#ifdef CONFIG_PCI_MSI
444 kfree(opt.err);
445#endif
Bruce Allan4662e822008-08-26 18:37:06 -0700446 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000447 /* Smart Power Down */
448 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000449 static const struct e1000_option opt = {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700450 .type = enable_option,
451 .name = "PHY Smart Power Down",
452 .err = "defaulting to Disabled",
453 .def = OPTION_DISABLED
454 };
455
456 if (num_SmartPowerDownEnable > bd) {
Stephen Hemminger5a9147b2007-10-29 10:46:05 -0700457 unsigned int spd = SmartPowerDownEnable[bd];
Auke Kokbc7f75f2007-09-17 12:30:59 -0700458 e1000_validate_option(&spd, &opt, adapter);
Bruce Allan1860ac82012-12-05 06:26:40 +0000459 if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) && spd)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700460 adapter->flags |= FLAG_SMART_POWER_DOWN;
461 }
462 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000463 /* CRC Stripping */
464 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000465 static const struct e1000_option opt = {
Jeff Kirshereb7c3ad2008-11-14 06:45:23 +0000466 .type = enable_option,
467 .name = "CRC Stripping",
Bruce Allane9262442010-11-24 06:02:06 +0000468 .err = "defaulting to Enabled",
Jeff Kirshereb7c3ad2008-11-14 06:45:23 +0000469 .def = OPTION_ENABLED
470 };
471
472 if (num_CrcStripping > bd) {
473 unsigned int crc_stripping = CrcStripping[bd];
474 e1000_validate_option(&crc_stripping, &opt, adapter);
Ben Greear01840392012-02-11 15:39:25 +0000475 if (crc_stripping == OPTION_ENABLED) {
Jeff Kirshereb7c3ad2008-11-14 06:45:23 +0000476 adapter->flags2 |= FLAG2_CRC_STRIPPING;
Ben Greear01840392012-02-11 15:39:25 +0000477 adapter->flags2 |= FLAG2_DFLT_CRC_STRIPPING;
478 }
Bruce Allan6e50912a2009-06-02 11:28:01 +0000479 } else {
480 adapter->flags2 |= FLAG2_CRC_STRIPPING;
Ben Greear01840392012-02-11 15:39:25 +0000481 adapter->flags2 |= FLAG2_DFLT_CRC_STRIPPING;
Jeff Kirshereb7c3ad2008-11-14 06:45:23 +0000482 }
483 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000484 /* Kumeran Lock Loss Workaround */
485 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000486 static const struct e1000_option opt = {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700487 .type = enable_option,
488 .name = "Kumeran Lock Loss Workaround",
489 .err = "defaulting to Enabled",
490 .def = OPTION_ENABLED
491 };
Bruce Allan17e813e2013-02-20 04:06:01 +0000492 bool enabled = opt.def;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700493
494 if (num_KumeranLockLoss > bd) {
Stephen Hemminger5a9147b2007-10-29 10:46:05 -0700495 unsigned int kmrn_lock_loss = KumeranLockLoss[bd];
Auke Kokbc7f75f2007-09-17 12:30:59 -0700496 e1000_validate_option(&kmrn_lock_loss, &opt, adapter);
Bruce Allan17e813e2013-02-20 04:06:01 +0000497 enabled = kmrn_lock_loss;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700498 }
Bruce Allan17e813e2013-02-20 04:06:01 +0000499
500 if (hw->mac.type == e1000_ich8lan)
501 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw,
502 enabled);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700503 }
Bruce Allan33550ce2013-02-20 04:06:16 +0000504 /* Write-protect NVM */
505 {
Jesse Brandeburg6f59d662010-04-09 10:51:09 +0000506 static const struct e1000_option opt = {
Bruce Allan4a770352008-10-01 17:18:35 -0700507 .type = enable_option,
508 .name = "Write-protect NVM",
509 .err = "defaulting to Enabled",
510 .def = OPTION_ENABLED
511 };
512
513 if (adapter->flags & FLAG_IS_ICH) {
514 if (num_WriteProtectNVM > bd) {
Bruce Allanc29c3ba2013-02-20 04:05:50 +0000515 unsigned int write_protect_nvm =
516 WriteProtectNVM[bd];
Bruce Allan4a770352008-10-01 17:18:35 -0700517 e1000_validate_option(&write_protect_nvm, &opt,
518 adapter);
519 if (write_protect_nvm)
520 adapter->flags |= FLAG_READ_ONLY_NVM;
521 } else {
522 if (opt.def)
523 adapter->flags |= FLAG_READ_ONLY_NVM;
524 }
525 }
526 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700527}