1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29#include <linux/netdevice.h>
30#include <linux/pci.h>
31
32#include "e1000.h"
33
34
35
36
37
38
39#define E1000_MAX_NIC 32
40
41#define OPTION_UNSET -1
42#define OPTION_DISABLED 0
43#define OPTION_ENABLED 1
44
45#define COPYBREAK_DEFAULT 256
46unsigned int copybreak = COPYBREAK_DEFAULT;
47module_param(copybreak, uint, 0644);
48MODULE_PARM_DESC(copybreak,
49 "Maximum size of packet that is copied to a new buffer on receive");
50
51
52
53
54
55
56
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] \
60 = E1000_PARAM_INIT; \
61 static unsigned int num_##X; \
62 module_param_array_named(X, X, int, &num_##X, 0); \
63 MODULE_PARM_DESC(X, desc);
64
65
66
67
68
69
70
71
72E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
73#define DEFAULT_TIDV 8
74#define MAX_TXDELAY 0xFFFF
75#define MIN_TXDELAY 0
76
77
78
79
80
81
82E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
83#define DEFAULT_TADV 32
84#define MAX_TXABSDELAY 0xFFFF
85#define MIN_TXABSDELAY 0
86
87
88
89
90
91
92
93E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
94#define DEFAULT_RDTR 0
95#define MAX_RXDELAY 0xFFFF
96#define MIN_RXDELAY 0
97
98
99
100
101
102
103E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
104#define DEFAULT_RADV 8
105#define MAX_RXABSDELAY 0xFFFF
106#define MIN_RXABSDELAY 0
107
108
109
110
111
112
113E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
114#define DEFAULT_ITR 3
115#define MAX_ITR 100000
116#define MIN_ITR 100
117
118
119
120
121
122
123E1000_PARAM(IntMode, "Interrupt Mode");
124#define MAX_INTMODE 2
125#define MIN_INTMODE 0
126
127
128
129
130
131
132
133
134E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
135
136
137
138
139
140
141
142
143E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");
144
145
146
147
148
149
150
151
152E1000_PARAM(WriteProtectNVM, "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]");
153
154
155
156
157
158
159
160
161E1000_PARAM(CrcStripping, "Enable CRC Stripping, disable if your BMC needs " \
162 "the CRC");
163
164struct e1000_option {
165 enum { enable_option, range_option, list_option } type;
166 const char *name;
167 const char *err;
168 int def;
169 union {
170 struct {
171 int min;
172 int max;
173 } r;
174 struct {
175 int nr;
176 struct e1000_opt_list { int i; char *str; } *p;
177 } l;
178 } arg;
179};
180
181static int __devinit e1000_validate_option(unsigned int *value,
182 const struct e1000_option *opt,
183 struct e1000_adapter *adapter)
184{
185 if (*value == OPTION_UNSET) {
186 *value = opt->def;
187 return 0;
188 }
189
190 switch (opt->type) {
191 case enable_option:
192 switch (*value) {
193 case OPTION_ENABLED:
194 e_info("%s Enabled\n", opt->name);
195 return 0;
196 case OPTION_DISABLED:
197 e_info("%s Disabled\n", opt->name);
198 return 0;
199 }
200 break;
201 case range_option:
202 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
203 e_info("%s set to %i\n", opt->name, *value);
204 return 0;
205 }
206 break;
207 case list_option: {
208 int i;
209 struct e1000_opt_list *ent;
210
211 for (i = 0; i < opt->arg.l.nr; i++) {
212 ent = &opt->arg.l.p[i];
213 if (*value == ent->i) {
214 if (ent->str[0] != '\0')
215 e_info("%s\n", ent->str);
216 return 0;
217 }
218 }
219 }
220 break;
221 default:
222 BUG();
223 }
224
225 e_info("Invalid %s value specified (%i) %s\n", opt->name, *value,
226 opt->err);
227 *value = opt->def;
228 return -1;
229}
230
231
232
233
234
235
236
237
238
239
240void __devinit e1000e_check_options(struct e1000_adapter *adapter)
241{
242 struct e1000_hw *hw = &adapter->hw;
243 int bd = adapter->bd_number;
244
245 if (bd >= E1000_MAX_NIC) {
246 e_notice("Warning: no configuration for board #%i\n", bd);
247 e_notice("Using defaults for all values\n");
248 }
249
250 {
251 const struct e1000_option opt = {
252 .type = range_option,
253 .name = "Transmit Interrupt Delay",
254 .err = "using default of "
255 __MODULE_STRING(DEFAULT_TIDV),
256 .def = DEFAULT_TIDV,
257 .arg = { .r = { .min = MIN_TXDELAY,
258 .max = MAX_TXDELAY } }
259 };
260
261 if (num_TxIntDelay > bd) {
262 adapter->tx_int_delay = TxIntDelay[bd];
263 e1000_validate_option(&adapter->tx_int_delay, &opt,
264 adapter);
265 } else {
266 adapter->tx_int_delay = opt.def;
267 }
268 }
269 {
270 const struct e1000_option opt = {
271 .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 }
288 {
289 struct e1000_option opt = {
290 .type = range_option,
291 .name = "Receive Interrupt Delay",
292 .err = "using default of "
293 __MODULE_STRING(DEFAULT_RDTR),
294 .def = DEFAULT_RDTR,
295 .arg = { .r = { .min = MIN_RXDELAY,
296 .max = MAX_RXDELAY } }
297 };
298
299 if (num_RxIntDelay > bd) {
300 adapter->rx_int_delay = RxIntDelay[bd];
301 e1000_validate_option(&adapter->rx_int_delay, &opt,
302 adapter);
303 } else {
304 adapter->rx_int_delay = opt.def;
305 }
306 }
307 {
308 const struct e1000_option opt = {
309 .type = range_option,
310 .name = "Receive Absolute Interrupt Delay",
311 .err = "using default of "
312 __MODULE_STRING(DEFAULT_RADV),
313 .def = DEFAULT_RADV,
314 .arg = { .r = { .min = MIN_RXABSDELAY,
315 .max = MAX_RXABSDELAY } }
316 };
317
318 if (num_RxAbsIntDelay > bd) {
319 adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
320 e1000_validate_option(&adapter->rx_abs_int_delay, &opt,
321 adapter);
322 } else {
323 adapter->rx_abs_int_delay = opt.def;
324 }
325 }
326 {
327 const struct e1000_option opt = {
328 .type = range_option,
329 .name = "Interrupt Throttling Rate (ints/sec)",
330 .err = "using default of "
331 __MODULE_STRING(DEFAULT_ITR),
332 .def = DEFAULT_ITR,
333 .arg = { .r = { .min = MIN_ITR,
334 .max = MAX_ITR } }
335 };
336
337 if (num_InterruptThrottleRate > bd) {
338 adapter->itr = InterruptThrottleRate[bd];
339 switch (adapter->itr) {
340 case 0:
341 e_info("%s turned off\n", opt.name);
342 break;
343 case 1:
344 e_info("%s set to dynamic mode\n", opt.name);
345 adapter->itr_setting = adapter->itr;
346 adapter->itr = 20000;
347 break;
348 case 3:
349 e_info("%s set to dynamic conservative mode\n",
350 opt.name);
351 adapter->itr_setting = adapter->itr;
352 adapter->itr = 20000;
353 break;
354 default:
355
356
357
358
359 if (e1000_validate_option(&adapter->itr, &opt,
360 adapter) &&
361 (adapter->itr == 3)) {
362
363
364
365
366 adapter->itr_setting = adapter->itr;
367 adapter->itr = 20000;
368 } else {
369
370
371
372
373 adapter->itr_setting =
374 adapter->itr & ~3;
375 }
376 break;
377 }
378 } else {
379 adapter->itr_setting = opt.def;
380 adapter->itr = 20000;
381 }
382 }
383 {
384 struct e1000_option opt = {
385 .type = range_option,
386 .name = "Interrupt Mode",
387 .err = "defaulting to 2 (MSI-X)",
388 .def = E1000E_INT_MODE_MSIX,
389 .arg = { .r = { .min = MIN_INTMODE,
390 .max = MAX_INTMODE } }
391 };
392
393 if (num_IntMode > bd) {
394 unsigned int int_mode = IntMode[bd];
395 e1000_validate_option(&int_mode, &opt, adapter);
396 adapter->int_mode = int_mode;
397 } else {
398 adapter->int_mode = opt.def;
399 }
400 }
401 {
402 const struct e1000_option opt = {
403 .type = enable_option,
404 .name = "PHY Smart Power Down",
405 .err = "defaulting to Disabled",
406 .def = OPTION_DISABLED
407 };
408
409 if (num_SmartPowerDownEnable > bd) {
410 unsigned int spd = SmartPowerDownEnable[bd];
411 e1000_validate_option(&spd, &opt, adapter);
412 if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN)
413 && spd)
414 adapter->flags |= FLAG_SMART_POWER_DOWN;
415 }
416 }
417 {
418 const struct e1000_option opt = {
419 .type = enable_option,
420 .name = "CRC Stripping",
421 .err = "defaulting to enabled",
422 .def = OPTION_ENABLED
423 };
424
425 if (num_CrcStripping > bd) {
426 unsigned int crc_stripping = CrcStripping[bd];
427 e1000_validate_option(&crc_stripping, &opt, adapter);
428 if (crc_stripping == OPTION_ENABLED)
429 adapter->flags2 |= FLAG2_CRC_STRIPPING;
430 } else {
431 adapter->flags2 |= FLAG2_CRC_STRIPPING;
432 }
433 }
434 {
435 const struct e1000_option opt = {
436 .type = enable_option,
437 .name = "Kumeran Lock Loss Workaround",
438 .err = "defaulting to Enabled",
439 .def = OPTION_ENABLED
440 };
441
442 if (num_KumeranLockLoss > bd) {
443 unsigned int kmrn_lock_loss = KumeranLockLoss[bd];
444 e1000_validate_option(&kmrn_lock_loss, &opt, adapter);
445 if (hw->mac.type == e1000_ich8lan)
446 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw,
447 kmrn_lock_loss);
448 } else {
449 if (hw->mac.type == e1000_ich8lan)
450 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw,
451 opt.def);
452 }
453 }
454 {
455 const struct e1000_option opt = {
456 .type = enable_option,
457 .name = "Write-protect NVM",
458 .err = "defaulting to Enabled",
459 .def = OPTION_ENABLED
460 };
461
462 if (adapter->flags & FLAG_IS_ICH) {
463 if (num_WriteProtectNVM > bd) {
464 unsigned int write_protect_nvm = WriteProtectNVM[bd];
465 e1000_validate_option(&write_protect_nvm, &opt,
466 adapter);
467 if (write_protect_nvm)
468 adapter->flags |= FLAG_READ_ONLY_NVM;
469 } else {
470 if (opt.def)
471 adapter->flags |= FLAG_READ_ONLY_NVM;
472 }
473 }
474 }
475}
476