diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /drivers/net/e1000e/param.c | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'drivers/net/e1000e/param.c')
-rw-r--r-- | drivers/net/e1000e/param.c | 478 |
1 files changed, 478 insertions, 0 deletions
diff --git a/drivers/net/e1000e/param.c b/drivers/net/e1000e/param.c new file mode 100644 index 00000000000..4dd9b63273f --- /dev/null +++ b/drivers/net/e1000e/param.c | |||
@@ -0,0 +1,478 @@ | |||
1 | /******************************************************************************* | ||
2 | |||
3 | Intel PRO/1000 Linux driver | ||
4 | Copyright(c) 1999 - 2011 Intel Corporation. | ||
5 | |||
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> | ||
30 | #include <linux/pci.h> | ||
31 | |||
32 | #include "e1000.h" | ||
33 | |||
34 | /* | ||
35 | * This is the only thing that needs to be changed to adjust the | ||
36 | * maximum number of ports that the driver can manage. | ||
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 | ||
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"); | ||
50 | |||
51 | /* | ||
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). | ||
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 | * Transmit Interrupt Delay in units of 1.024 microseconds | ||
67 | * Tx interrupt delay needs to typically be set to something non-zero | ||
68 | * | ||
69 | * Valid Range: 0-65535 | ||
70 | */ | ||
71 | E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay"); | ||
72 | #define DEFAULT_TIDV 8 | ||
73 | #define MAX_TXDELAY 0xFFFF | ||
74 | #define MIN_TXDELAY 0 | ||
75 | |||
76 | /* | ||
77 | * Transmit Absolute Interrupt Delay in units of 1.024 microseconds | ||
78 | * | ||
79 | * Valid Range: 0-65535 | ||
80 | */ | ||
81 | E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay"); | ||
82 | #define DEFAULT_TADV 32 | ||
83 | #define MAX_TXABSDELAY 0xFFFF | ||
84 | #define MIN_TXABSDELAY 0 | ||
85 | |||
86 | /* | ||
87 | * Receive Interrupt Delay in units of 1.024 microseconds | ||
88 | * hardware will likely hang if you set this to anything but zero. | ||
89 | * | ||
90 | * Valid Range: 0-65535 | ||
91 | */ | ||
92 | E1000_PARAM(RxIntDelay, "Receive Interrupt Delay"); | ||
93 | #define MAX_RXDELAY 0xFFFF | ||
94 | #define MIN_RXDELAY 0 | ||
95 | |||
96 | /* | ||
97 | * Receive Absolute Interrupt Delay in units of 1.024 microseconds | ||
98 | * | ||
99 | * Valid Range: 0-65535 | ||
100 | */ | ||
101 | E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay"); | ||
102 | #define MAX_RXABSDELAY 0xFFFF | ||
103 | #define MIN_RXABSDELAY 0 | ||
104 | |||
105 | /* | ||
106 | * Interrupt Throttle Rate (interrupts/sec) | ||
107 | * | ||
108 | * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative) | ||
109 | */ | ||
110 | E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate"); | ||
111 | #define DEFAULT_ITR 3 | ||
112 | #define MAX_ITR 100000 | ||
113 | #define MIN_ITR 100 | ||
114 | |||
115 | /* IntMode (Interrupt Mode) | ||
116 | * | ||
117 | * Valid Range: 0 - 2 | ||
118 | * | ||
119 | * Default Value: 2 (MSI-X) | ||
120 | */ | ||
121 | E1000_PARAM(IntMode, "Interrupt Mode"); | ||
122 | #define MAX_INTMODE 2 | ||
123 | #define MIN_INTMODE 0 | ||
124 | |||
125 | /* | ||
126 | * Enable Smart Power Down of the PHY | ||
127 | * | ||
128 | * Valid Range: 0, 1 | ||
129 | * | ||
130 | * Default Value: 0 (disabled) | ||
131 | */ | ||
132 | E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down"); | ||
133 | |||
134 | /* | ||
135 | * Enable Kumeran Lock Loss workaround | ||
136 | * | ||
137 | * Valid Range: 0, 1 | ||
138 | * | ||
139 | * Default Value: 1 (enabled) | ||
140 | */ | ||
141 | E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround"); | ||
142 | |||
143 | /* | ||
144 | * Write Protect NVM | ||
145 | * | ||
146 | * Valid Range: 0, 1 | ||
147 | * | ||
148 | * Default Value: 1 (enabled) | ||
149 | */ | ||
150 | E1000_PARAM(WriteProtectNVM, "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]"); | ||
151 | |||
152 | /* | ||
153 | * Enable CRC Stripping | ||
154 | * | ||
155 | * Valid Range: 0, 1 | ||
156 | * | ||
157 | * Default Value: 1 (enabled) | ||
158 | */ | ||
159 | E1000_PARAM(CrcStripping, "Enable CRC Stripping, disable if your BMC needs " \ | ||
160 | "the CRC"); | ||
161 | |||
162 | struct e1000_option { | ||
163 | enum { enable_option, range_option, list_option } type; | ||
164 | const char *name; | ||
165 | const char *err; | ||
166 | int def; | ||
167 | union { | ||
168 | struct { /* range_option info */ | ||
169 | int min; | ||
170 | int max; | ||
171 | } r; | ||
172 | struct { /* list_option info */ | ||
173 | int nr; | ||
174 | struct e1000_opt_list { int i; char *str; } *p; | ||
175 | } l; | ||
176 | } arg; | ||
177 | }; | ||
178 | |||
179 | static int __devinit e1000_validate_option(unsigned int *value, | ||
180 | const struct e1000_option *opt, | ||
181 | struct e1000_adapter *adapter) | ||
182 | { | ||
183 | if (*value == OPTION_UNSET) { | ||
184 | *value = opt->def; | ||
185 | return 0; | ||
186 | } | ||
187 | |||
188 | switch (opt->type) { | ||
189 | case enable_option: | ||
190 | switch (*value) { | ||
191 | case OPTION_ENABLED: | ||
192 | e_info("%s Enabled\n", opt->name); | ||
193 | return 0; | ||
194 | case OPTION_DISABLED: | ||
195 | e_info("%s Disabled\n", opt->name); | ||
196 | return 0; | ||
197 | } | ||
198 | break; | ||
199 | case range_option: | ||
200 | if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) { | ||
201 | e_info("%s set to %i\n", opt->name, *value); | ||
202 | return 0; | ||
203 | } | ||
204 | break; | ||
205 | case list_option: { | ||
206 | int i; | ||
207 | struct e1000_opt_list *ent; | ||
208 | |||
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); | ||
214 | return 0; | ||
215 | } | ||
216 | } | ||
217 | } | ||
218 | break; | ||
219 | default: | ||
220 | BUG(); | ||
221 | } | ||
222 | |||
223 | e_info("Invalid %s value specified (%i) %s\n", opt->name, *value, | ||
224 | opt->err); | ||
225 | *value = opt->def; | ||
226 | return -1; | ||
227 | } | ||
228 | |||
229 | /** | ||
230 | * e1000e_check_options - Range Checking for Command Line Parameters | ||
231 | * @adapter: board private structure | ||
232 | * | ||
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. | ||
237 | **/ | ||
238 | void __devinit e1000e_check_options(struct e1000_adapter *adapter) | ||
239 | { | ||
240 | struct e1000_hw *hw = &adapter->hw; | ||
241 | int bd = adapter->bd_number; | ||
242 | |||
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"); | ||
246 | } | ||
247 | |||
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), | ||
254 | .def = DEFAULT_TIDV, | ||
255 | .arg = { .r = { .min = MIN_TXDELAY, | ||
256 | .max = MAX_TXDELAY } } | ||
257 | }; | ||
258 | |||
259 | if (num_TxIntDelay > bd) { | ||
260 | adapter->tx_int_delay = TxIntDelay[bd]; | ||
261 | e1000_validate_option(&adapter->tx_int_delay, &opt, | ||
262 | adapter); | ||
263 | } else { | ||
264 | adapter->tx_int_delay = opt.def; | ||
265 | } | ||
266 | } | ||
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), | ||
273 | .def = DEFAULT_TADV, | ||
274 | .arg = { .r = { .min = MIN_TXABSDELAY, | ||
275 | .max = MAX_TXABSDELAY } } | ||
276 | }; | ||
277 | |||
278 | if (num_TxAbsIntDelay > bd) { | ||
279 | adapter->tx_abs_int_delay = TxAbsIntDelay[bd]; | ||
280 | e1000_validate_option(&adapter->tx_abs_int_delay, &opt, | ||
281 | adapter); | ||
282 | } else { | ||
283 | adapter->tx_abs_int_delay = opt.def; | ||
284 | } | ||
285 | } | ||
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), | ||
292 | .def = DEFAULT_RDTR, | ||
293 | .arg = { .r = { .min = MIN_RXDELAY, | ||
294 | .max = MAX_RXDELAY } } | ||
295 | }; | ||
296 | |||
297 | if (num_RxIntDelay > bd) { | ||
298 | adapter->rx_int_delay = RxIntDelay[bd]; | ||
299 | e1000_validate_option(&adapter->rx_int_delay, &opt, | ||
300 | adapter); | ||
301 | } else { | ||
302 | adapter->rx_int_delay = opt.def; | ||
303 | } | ||
304 | } | ||
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), | ||
311 | .def = DEFAULT_RADV, | ||
312 | .arg = { .r = { .min = MIN_RXABSDELAY, | ||
313 | .max = MAX_RXABSDELAY } } | ||
314 | }; | ||
315 | |||
316 | if (num_RxAbsIntDelay > bd) { | ||
317 | adapter->rx_abs_int_delay = RxAbsIntDelay[bd]; | ||
318 | e1000_validate_option(&adapter->rx_abs_int_delay, &opt, | ||
319 | adapter); | ||
320 | } else { | ||
321 | adapter->rx_abs_int_delay = opt.def; | ||
322 | } | ||
323 | } | ||
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), | ||
330 | .def = DEFAULT_ITR, | ||
331 | .arg = { .r = { .min = MIN_ITR, | ||
332 | .max = MAX_ITR } } | ||
333 | }; | ||
334 | |||
335 | if (num_InterruptThrottleRate > bd) { | ||
336 | adapter->itr = InterruptThrottleRate[bd]; | ||
337 | switch (adapter->itr) { | ||
338 | case 0: | ||
339 | e_info("%s turned off\n", opt.name); | ||
340 | break; | ||
341 | case 1: | ||
342 | e_info("%s set to dynamic mode\n", opt.name); | ||
343 | adapter->itr_setting = adapter->itr; | ||
344 | adapter->itr = 20000; | ||
345 | break; | ||
346 | case 3: | ||
347 | e_info("%s set to dynamic conservative mode\n", | ||
348 | opt.name); | ||
349 | adapter->itr_setting = adapter->itr; | ||
350 | adapter->itr = 20000; | ||
351 | break; | ||
352 | case 4: | ||
353 | e_info("%s set to simplified (2000-8000 ints) " | ||
354 | "mode\n", opt.name); | ||
355 | adapter->itr_setting = 4; | ||
356 | break; | ||
357 | default: | ||
358 | /* | ||
359 | * Save the setting, because the dynamic bits | ||
360 | * change itr. | ||
361 | */ | ||
362 | if (e1000_validate_option(&adapter->itr, &opt, | ||
363 | adapter) && | ||
364 | (adapter->itr == 3)) { | ||
365 | /* | ||
366 | * In case of invalid user value, | ||
367 | * default to conservative mode. | ||
368 | */ | ||
369 | adapter->itr_setting = adapter->itr; | ||
370 | adapter->itr = 20000; | ||
371 | } else { | ||
372 | /* | ||
373 | * Clear the lower two bits because | ||
374 | * they are used as control. | ||
375 | */ | ||
376 | adapter->itr_setting = | ||
377 | adapter->itr & ~3; | ||
378 | } | ||
379 | break; | ||
380 | } | ||
381 | } else { | ||
382 | adapter->itr_setting = opt.def; | ||
383 | adapter->itr = 20000; | ||
384 | } | ||
385 | } | ||
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 } } | ||
394 | }; | ||
395 | |||
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; | ||
400 | } else { | ||
401 | adapter->int_mode = opt.def; | ||
402 | } | ||
403 | } | ||
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 | ||
410 | }; | ||
411 | |||
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) | ||
416 | && spd) | ||
417 | adapter->flags |= FLAG_SMART_POWER_DOWN; | ||
418 | } | ||
419 | } | ||
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 | ||
426 | }; | ||
427 | |||
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; | ||
433 | } else { | ||
434 | adapter->flags2 |= FLAG2_CRC_STRIPPING; | ||
435 | } | ||
436 | } | ||
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 | ||
443 | }; | ||
444 | |||
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, | ||
450 | kmrn_lock_loss); | ||
451 | } else { | ||
452 | if (hw->mac.type == e1000_ich8lan) | ||
453 | e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, | ||
454 | opt.def); | ||
455 | } | ||
456 | } | ||
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 | ||
463 | }; | ||
464 | |||
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, | ||
469 | adapter); | ||
470 | if (write_protect_nvm) | ||
471 | adapter->flags |= FLAG_READ_ONLY_NVM; | ||
472 | } else { | ||
473 | if (opt.def) | ||
474 | adapter->flags |= FLAG_READ_ONLY_NVM; | ||
475 | } | ||
476 | } | ||
477 | } | ||
478 | } | ||