Commit | Line | Data |
---|---|---|
bc7f75fa AK |
1 | /******************************************************************************* |
2 | ||
3 | Intel PRO/1000 Linux driver | |
ad68076e | 4 | Copyright(c) 1999 - 2008 Intel Corporation. |
bc7f75fa AK |
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> | |
44defeb3 | 30 | #include <linux/pci.h> |
bc7f75fa AK |
31 | |
32 | #include "e1000.h" | |
33 | ||
ad68076e BA |
34 | /* |
35 | * This is the only thing that needs to be changed to adjust the | |
bc7f75fa AK |
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 | ||
ad68076e BA |
51 | /* |
52 | * All parameters are treated the same, as an integer array of values. | |
bc7f75fa AK |
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 } | |
5a9147bb SH |
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); \ | |
bc7f75fa AK |
63 | MODULE_PARM_DESC(X, desc); |
64 | ||
65 | ||
ad68076e BA |
66 | /* |
67 | * Transmit Interrupt Delay in units of 1.024 microseconds | |
68 | * Tx interrupt delay needs to typically be set to something non zero | |
bc7f75fa AK |
69 | * |
70 | * Valid Range: 0-65535 | |
71 | */ | |
72 | E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay"); | |
73 | #define DEFAULT_TIDV 8 | |
74 | #define MAX_TXDELAY 0xFFFF | |
75 | #define MIN_TXDELAY 0 | |
76 | ||
ad68076e BA |
77 | /* |
78 | * Transmit Absolute Interrupt Delay in units of 1.024 microseconds | |
bc7f75fa AK |
79 | * |
80 | * Valid Range: 0-65535 | |
81 | */ | |
82 | E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay"); | |
83 | #define DEFAULT_TADV 32 | |
84 | #define MAX_TXABSDELAY 0xFFFF | |
85 | #define MIN_TXABSDELAY 0 | |
86 | ||
ad68076e BA |
87 | /* |
88 | * Receive Interrupt Delay in units of 1.024 microseconds | |
89 | * hardware will likely hang if you set this to anything but zero. | |
bc7f75fa AK |
90 | * |
91 | * Valid Range: 0-65535 | |
92 | */ | |
93 | E1000_PARAM(RxIntDelay, "Receive Interrupt Delay"); | |
94 | #define DEFAULT_RDTR 0 | |
95 | #define MAX_RXDELAY 0xFFFF | |
96 | #define MIN_RXDELAY 0 | |
97 | ||
ad68076e BA |
98 | /* |
99 | * Receive Absolute Interrupt Delay in units of 1.024 microseconds | |
bc7f75fa AK |
100 | * |
101 | * Valid Range: 0-65535 | |
102 | */ | |
103 | E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay"); | |
104 | #define DEFAULT_RADV 8 | |
105 | #define MAX_RXABSDELAY 0xFFFF | |
106 | #define MIN_RXABSDELAY 0 | |
107 | ||
ad68076e BA |
108 | /* |
109 | * Interrupt Throttle Rate (interrupts/sec) | |
bc7f75fa AK |
110 | * |
111 | * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative) | |
112 | */ | |
113 | E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate"); | |
114 | #define DEFAULT_ITR 3 | |
115 | #define MAX_ITR 100000 | |
116 | #define MIN_ITR 100 | |
4662e82b BA |
117 | /* IntMode (Interrupt Mode) |
118 | * | |
119 | * Valid Range: 0 - 2 | |
120 | * | |
121 | * Default Value: 2 (MSI-X) | |
122 | */ | |
123 | E1000_PARAM(IntMode, "Interrupt Mode"); | |
124 | #define MAX_INTMODE 2 | |
125 | #define MIN_INTMODE 0 | |
bc7f75fa | 126 | |
ad68076e BA |
127 | /* |
128 | * Enable Smart Power Down of the PHY | |
bc7f75fa AK |
129 | * |
130 | * Valid Range: 0, 1 | |
131 | * | |
132 | * Default Value: 0 (disabled) | |
133 | */ | |
134 | E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down"); | |
135 | ||
ad68076e BA |
136 | /* |
137 | * Enable Kumeran Lock Loss workaround | |
bc7f75fa AK |
138 | * |
139 | * Valid Range: 0, 1 | |
140 | * | |
141 | * Default Value: 1 (enabled) | |
142 | */ | |
143 | E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround"); | |
144 | ||
145 | struct e1000_option { | |
146 | enum { enable_option, range_option, list_option } type; | |
5a9147bb SH |
147 | const char *name; |
148 | const char *err; | |
149 | int def; | |
bc7f75fa AK |
150 | union { |
151 | struct { /* range_option info */ | |
152 | int min; | |
153 | int max; | |
154 | } r; | |
155 | struct { /* list_option info */ | |
156 | int nr; | |
157 | struct e1000_opt_list { int i; char *str; } *p; | |
158 | } l; | |
159 | } arg; | |
160 | }; | |
161 | ||
5a9147bb SH |
162 | static int __devinit e1000_validate_option(unsigned int *value, |
163 | const struct e1000_option *opt, | |
bc7f75fa AK |
164 | struct e1000_adapter *adapter) |
165 | { | |
166 | if (*value == OPTION_UNSET) { | |
167 | *value = opt->def; | |
168 | return 0; | |
169 | } | |
170 | ||
171 | switch (opt->type) { | |
172 | case enable_option: | |
173 | switch (*value) { | |
174 | case OPTION_ENABLED: | |
44defeb3 | 175 | e_info("%s Enabled\n", opt->name); |
bc7f75fa AK |
176 | return 0; |
177 | case OPTION_DISABLED: | |
44defeb3 | 178 | e_info("%s Disabled\n", opt->name); |
bc7f75fa AK |
179 | return 0; |
180 | } | |
181 | break; | |
182 | case range_option: | |
183 | if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) { | |
44defeb3 | 184 | e_info("%s set to %i\n", opt->name, *value); |
bc7f75fa AK |
185 | return 0; |
186 | } | |
187 | break; | |
188 | case list_option: { | |
189 | int i; | |
190 | struct e1000_opt_list *ent; | |
191 | ||
192 | for (i = 0; i < opt->arg.l.nr; i++) { | |
193 | ent = &opt->arg.l.p[i]; | |
194 | if (*value == ent->i) { | |
195 | if (ent->str[0] != '\0') | |
44defeb3 | 196 | e_info("%s\n", ent->str); |
bc7f75fa AK |
197 | return 0; |
198 | } | |
199 | } | |
200 | } | |
201 | break; | |
202 | default: | |
203 | BUG(); | |
204 | } | |
205 | ||
44defeb3 JK |
206 | e_info("Invalid %s value specified (%i) %s\n", opt->name, *value, |
207 | opt->err); | |
bc7f75fa AK |
208 | *value = opt->def; |
209 | return -1; | |
210 | } | |
211 | ||
212 | /** | |
213 | * e1000e_check_options - Range Checking for Command Line Parameters | |
214 | * @adapter: board private structure | |
215 | * | |
216 | * This routine checks all command line parameters for valid user | |
217 | * input. If an invalid value is given, or if no user specified | |
218 | * value exists, a default value is used. The final value is stored | |
219 | * in a variable in the adapter structure. | |
220 | **/ | |
221 | void __devinit e1000e_check_options(struct e1000_adapter *adapter) | |
222 | { | |
223 | struct e1000_hw *hw = &adapter->hw; | |
bc7f75fa AK |
224 | int bd = adapter->bd_number; |
225 | ||
226 | if (bd >= E1000_MAX_NIC) { | |
44defeb3 JK |
227 | e_notice("Warning: no configuration for board #%i\n", bd); |
228 | e_notice("Using defaults for all values\n"); | |
bc7f75fa AK |
229 | } |
230 | ||
231 | { /* Transmit Interrupt Delay */ | |
5a9147bb | 232 | const struct e1000_option opt = { |
bc7f75fa AK |
233 | .type = range_option, |
234 | .name = "Transmit Interrupt Delay", | |
235 | .err = "using default of " | |
236 | __MODULE_STRING(DEFAULT_TIDV), | |
237 | .def = DEFAULT_TIDV, | |
238 | .arg = { .r = { .min = MIN_TXDELAY, | |
239 | .max = MAX_TXDELAY } } | |
240 | }; | |
241 | ||
242 | if (num_TxIntDelay > bd) { | |
243 | adapter->tx_int_delay = TxIntDelay[bd]; | |
244 | e1000_validate_option(&adapter->tx_int_delay, &opt, | |
245 | adapter); | |
246 | } else { | |
247 | adapter->tx_int_delay = opt.def; | |
248 | } | |
249 | } | |
250 | { /* Transmit Absolute Interrupt Delay */ | |
5a9147bb | 251 | const struct e1000_option opt = { |
bc7f75fa AK |
252 | .type = range_option, |
253 | .name = "Transmit Absolute Interrupt Delay", | |
254 | .err = "using default of " | |
255 | __MODULE_STRING(DEFAULT_TADV), | |
256 | .def = DEFAULT_TADV, | |
257 | .arg = { .r = { .min = MIN_TXABSDELAY, | |
258 | .max = MAX_TXABSDELAY } } | |
259 | }; | |
260 | ||
261 | if (num_TxAbsIntDelay > bd) { | |
262 | adapter->tx_abs_int_delay = TxAbsIntDelay[bd]; | |
263 | e1000_validate_option(&adapter->tx_abs_int_delay, &opt, | |
264 | adapter); | |
265 | } else { | |
266 | adapter->tx_abs_int_delay = opt.def; | |
267 | } | |
268 | } | |
269 | { /* Receive Interrupt Delay */ | |
270 | struct e1000_option opt = { | |
271 | .type = range_option, | |
272 | .name = "Receive Interrupt Delay", | |
273 | .err = "using default of " | |
274 | __MODULE_STRING(DEFAULT_RDTR), | |
275 | .def = DEFAULT_RDTR, | |
276 | .arg = { .r = { .min = MIN_RXDELAY, | |
277 | .max = MAX_RXDELAY } } | |
278 | }; | |
279 | ||
bc7f75fa AK |
280 | if (num_RxIntDelay > bd) { |
281 | adapter->rx_int_delay = RxIntDelay[bd]; | |
282 | e1000_validate_option(&adapter->rx_int_delay, &opt, | |
283 | adapter); | |
284 | } else { | |
285 | adapter->rx_int_delay = opt.def; | |
286 | } | |
287 | } | |
288 | { /* Receive Absolute Interrupt Delay */ | |
5a9147bb | 289 | const struct e1000_option opt = { |
bc7f75fa AK |
290 | .type = range_option, |
291 | .name = "Receive Absolute Interrupt Delay", | |
292 | .err = "using default of " | |
293 | __MODULE_STRING(DEFAULT_RADV), | |
294 | .def = DEFAULT_RADV, | |
295 | .arg = { .r = { .min = MIN_RXABSDELAY, | |
296 | .max = MAX_RXABSDELAY } } | |
297 | }; | |
298 | ||
299 | if (num_RxAbsIntDelay > bd) { | |
300 | adapter->rx_abs_int_delay = RxAbsIntDelay[bd]; | |
301 | e1000_validate_option(&adapter->rx_abs_int_delay, &opt, | |
302 | adapter); | |
303 | } else { | |
304 | adapter->rx_abs_int_delay = opt.def; | |
305 | } | |
306 | } | |
307 | { /* Interrupt Throttling Rate */ | |
5a9147bb | 308 | const struct e1000_option opt = { |
bc7f75fa AK |
309 | .type = range_option, |
310 | .name = "Interrupt Throttling Rate (ints/sec)", | |
311 | .err = "using default of " | |
312 | __MODULE_STRING(DEFAULT_ITR), | |
313 | .def = DEFAULT_ITR, | |
314 | .arg = { .r = { .min = MIN_ITR, | |
315 | .max = MAX_ITR } } | |
316 | }; | |
317 | ||
318 | if (num_InterruptThrottleRate > bd) { | |
319 | adapter->itr = InterruptThrottleRate[bd]; | |
320 | switch (adapter->itr) { | |
321 | case 0: | |
44defeb3 | 322 | e_info("%s turned off\n", opt.name); |
bc7f75fa AK |
323 | break; |
324 | case 1: | |
44defeb3 | 325 | e_info("%s set to dynamic mode\n", opt.name); |
bc7f75fa AK |
326 | adapter->itr_setting = adapter->itr; |
327 | adapter->itr = 20000; | |
328 | break; | |
329 | case 3: | |
44defeb3 | 330 | e_info("%s set to dynamic conservative mode\n", |
bc7f75fa AK |
331 | opt.name); |
332 | adapter->itr_setting = adapter->itr; | |
333 | adapter->itr = 20000; | |
334 | break; | |
335 | default: | |
bc7f75fa | 336 | /* |
2d06cad1 BA |
337 | * Save the setting, because the dynamic bits |
338 | * change itr. | |
bc7f75fa | 339 | */ |
2d06cad1 BA |
340 | if (e1000_validate_option(&adapter->itr, &opt, |
341 | adapter) && | |
342 | (adapter->itr == 3)) { | |
343 | /* | |
344 | * In case of invalid user value, | |
345 | * default to conservative mode. | |
346 | */ | |
347 | adapter->itr_setting = adapter->itr; | |
348 | adapter->itr = 20000; | |
349 | } else { | |
350 | /* | |
351 | * Clear the lower two bits because | |
352 | * they are used as control. | |
353 | */ | |
354 | adapter->itr_setting = | |
355 | adapter->itr & ~3; | |
356 | } | |
bc7f75fa AK |
357 | break; |
358 | } | |
359 | } else { | |
360 | adapter->itr_setting = opt.def; | |
361 | adapter->itr = 20000; | |
362 | } | |
363 | } | |
4662e82b BA |
364 | { /* Interrupt Mode */ |
365 | struct e1000_option opt = { | |
366 | .type = range_option, | |
367 | .name = "Interrupt Mode", | |
368 | .err = "defaulting to 2 (MSI-X)", | |
369 | .def = E1000E_INT_MODE_MSIX, | |
370 | .arg = { .r = { .min = MIN_INTMODE, | |
371 | .max = MAX_INTMODE } } | |
372 | }; | |
373 | ||
374 | if (num_IntMode > bd) { | |
375 | unsigned int int_mode = IntMode[bd]; | |
376 | e1000_validate_option(&int_mode, &opt, adapter); | |
377 | adapter->int_mode = int_mode; | |
378 | } else { | |
379 | adapter->int_mode = opt.def; | |
380 | } | |
381 | } | |
bc7f75fa | 382 | { /* Smart Power Down */ |
5a9147bb | 383 | const struct e1000_option opt = { |
bc7f75fa AK |
384 | .type = enable_option, |
385 | .name = "PHY Smart Power Down", | |
386 | .err = "defaulting to Disabled", | |
387 | .def = OPTION_DISABLED | |
388 | }; | |
389 | ||
390 | if (num_SmartPowerDownEnable > bd) { | |
5a9147bb | 391 | unsigned int spd = SmartPowerDownEnable[bd]; |
bc7f75fa AK |
392 | e1000_validate_option(&spd, &opt, adapter); |
393 | if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) | |
394 | && spd) | |
395 | adapter->flags |= FLAG_SMART_POWER_DOWN; | |
396 | } | |
397 | } | |
398 | { /* Kumeran Lock Loss Workaround */ | |
5a9147bb | 399 | const struct e1000_option opt = { |
bc7f75fa AK |
400 | .type = enable_option, |
401 | .name = "Kumeran Lock Loss Workaround", | |
402 | .err = "defaulting to Enabled", | |
403 | .def = OPTION_ENABLED | |
404 | }; | |
405 | ||
406 | if (num_KumeranLockLoss > bd) { | |
5a9147bb | 407 | unsigned int kmrn_lock_loss = KumeranLockLoss[bd]; |
bc7f75fa AK |
408 | e1000_validate_option(&kmrn_lock_loss, &opt, adapter); |
409 | if (hw->mac.type == e1000_ich8lan) | |
410 | e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, | |
411 | kmrn_lock_loss); | |
412 | } else { | |
413 | if (hw->mac.type == e1000_ich8lan) | |
414 | e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, | |
415 | opt.def); | |
416 | } | |
417 | } | |
418 | } |