1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2007 Intel Corporation.
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.
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
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.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
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
27 *******************************************************************************/
29 #include <linux/netdevice.h>
33 /* This is the only thing that needs to be changed to adjust the
34 * maximum number of ports that the driver can manage.
37 #define E1000_MAX_NIC 32
39 #define OPTION_UNSET -1
40 #define OPTION_DISABLED 0
41 #define OPTION_ENABLED 1
43 #define COPYBREAK_DEFAULT 256
44 unsigned int copybreak = COPYBREAK_DEFAULT;
45 module_param(copybreak, uint, 0644);
46 MODULE_PARM_DESC(copybreak,
47 "Maximum size of packet that is copied to a new buffer on receive");
49 /* All parameters are treated the same, as an integer array of values.
50 * This macro just reduces the need to repeat the same declaration code
51 * over and over (plus this helps to avoid typo bugs).
54 #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
55 #define E1000_PARAM(X, desc) \
56 static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
58 module_param_array_named(X, X, int, &num_##X, 0); \
59 MODULE_PARM_DESC(X, desc);
62 /* Transmit Interrupt Delay in units of 1.024 microseconds
63 * Tx interrupt delay needs to typically be set to something non zero
65 * Valid Range: 0-65535
67 E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
68 #define DEFAULT_TIDV 8
69 #define MAX_TXDELAY 0xFFFF
72 /* Transmit Absolute Interrupt Delay in units of 1.024 microseconds
74 * Valid Range: 0-65535
76 E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
77 #define DEFAULT_TADV 32
78 #define MAX_TXABSDELAY 0xFFFF
79 #define MIN_TXABSDELAY 0
81 /* Receive Interrupt Delay in units of 1.024 microseconds
82 * hardware will likely hang if you set this to anything but zero.
84 * Valid Range: 0-65535
86 E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
87 #define DEFAULT_RDTR 0
88 #define MAX_RXDELAY 0xFFFF
91 /* Receive Absolute Interrupt Delay in units of 1.024 microseconds
93 * Valid Range: 0-65535
95 E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
96 #define DEFAULT_RADV 8
97 #define MAX_RXABSDELAY 0xFFFF
98 #define MIN_RXABSDELAY 0
100 /* Interrupt Throttle Rate (interrupts/sec)
102 * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative)
104 E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
105 #define DEFAULT_ITR 3
106 #define MAX_ITR 100000
109 /* Enable Smart Power Down of the PHY
113 * Default Value: 0 (disabled)
115 E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
117 /* Enable Kumeran Lock Loss workaround
121 * Default Value: 1 (enabled)
123 E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");
125 struct e1000_option {
126 enum { enable_option, range_option, list_option } type;
131 struct { /* range_option info */
135 struct { /* list_option info */
137 struct e1000_opt_list { int i; char *str; } *p;
142 static int __devinit e1000_validate_option(int *value,
143 struct e1000_option *opt,
144 struct e1000_adapter *adapter)
146 if (*value == OPTION_UNSET) {
155 ndev_info(adapter->netdev, "%s Enabled\n", opt->name);
157 case OPTION_DISABLED:
158 ndev_info(adapter->netdev, "%s Disabled\n", opt->name);
163 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
164 ndev_info(adapter->netdev,
165 "%s set to %i\n", opt->name, *value);
171 struct e1000_opt_list *ent;
173 for (i = 0; i < opt->arg.l.nr; i++) {
174 ent = &opt->arg.l.p[i];
175 if (*value == ent->i) {
176 if (ent->str[0] != '\0')
177 ndev_info(adapter->netdev, "%s\n",
188 ndev_info(adapter->netdev, "Invalid %s value specified (%i) %s\n",
189 opt->name, *value, opt->err);
195 * e1000e_check_options - Range Checking for Command Line Parameters
196 * @adapter: board private structure
198 * This routine checks all command line parameters for valid user
199 * input. If an invalid value is given, or if no user specified
200 * value exists, a default value is used. The final value is stored
201 * in a variable in the adapter structure.
203 void __devinit e1000e_check_options(struct e1000_adapter *adapter)
205 struct e1000_hw *hw = &adapter->hw;
206 struct net_device *netdev = adapter->netdev;
207 int bd = adapter->bd_number;
209 if (bd >= E1000_MAX_NIC) {
211 "Warning: no configuration for board #%i\n", bd);
212 ndev_notice(netdev, "Using defaults for all values\n");
215 { /* Transmit Interrupt Delay */
216 struct e1000_option opt = {
217 .type = range_option,
218 .name = "Transmit Interrupt Delay",
219 .err = "using default of "
220 __MODULE_STRING(DEFAULT_TIDV),
222 .arg = { .r = { .min = MIN_TXDELAY,
223 .max = MAX_TXDELAY } }
226 if (num_TxIntDelay > bd) {
227 adapter->tx_int_delay = TxIntDelay[bd];
228 e1000_validate_option(&adapter->tx_int_delay, &opt,
231 adapter->tx_int_delay = opt.def;
234 { /* Transmit Absolute Interrupt Delay */
235 struct e1000_option opt = {
236 .type = range_option,
237 .name = "Transmit Absolute Interrupt Delay",
238 .err = "using default of "
239 __MODULE_STRING(DEFAULT_TADV),
241 .arg = { .r = { .min = MIN_TXABSDELAY,
242 .max = MAX_TXABSDELAY } }
245 if (num_TxAbsIntDelay > bd) {
246 adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
247 e1000_validate_option(&adapter->tx_abs_int_delay, &opt,
250 adapter->tx_abs_int_delay = opt.def;
253 { /* Receive Interrupt Delay */
254 struct e1000_option opt = {
255 .type = range_option,
256 .name = "Receive Interrupt Delay",
257 .err = "using default of "
258 __MODULE_STRING(DEFAULT_RDTR),
260 .arg = { .r = { .min = MIN_RXDELAY,
261 .max = MAX_RXDELAY } }
264 /* modify min and default if 82573 for slow ping w/a,
265 * a value greater than 8 needs to be set for RDTR */
266 if (adapter->flags & FLAG_HAS_ASPM) {
271 if (num_RxIntDelay > bd) {
272 adapter->rx_int_delay = RxIntDelay[bd];
273 e1000_validate_option(&adapter->rx_int_delay, &opt,
276 adapter->rx_int_delay = opt.def;
279 { /* Receive Absolute Interrupt Delay */
280 struct e1000_option opt = {
281 .type = range_option,
282 .name = "Receive Absolute Interrupt Delay",
283 .err = "using default of "
284 __MODULE_STRING(DEFAULT_RADV),
286 .arg = { .r = { .min = MIN_RXABSDELAY,
287 .max = MAX_RXABSDELAY } }
290 if (num_RxAbsIntDelay > bd) {
291 adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
292 e1000_validate_option(&adapter->rx_abs_int_delay, &opt,
295 adapter->rx_abs_int_delay = opt.def;
298 { /* Interrupt Throttling Rate */
299 struct e1000_option opt = {
300 .type = range_option,
301 .name = "Interrupt Throttling Rate (ints/sec)",
302 .err = "using default of "
303 __MODULE_STRING(DEFAULT_ITR),
305 .arg = { .r = { .min = MIN_ITR,
309 if (num_InterruptThrottleRate > bd) {
310 adapter->itr = InterruptThrottleRate[bd];
311 switch (adapter->itr) {
313 ndev_info(netdev, "%s turned off\n",
318 "%s set to dynamic mode\n",
320 adapter->itr_setting = adapter->itr;
321 adapter->itr = 20000;
325 "%s set to dynamic conservative mode\n",
327 adapter->itr_setting = adapter->itr;
328 adapter->itr = 20000;
331 e1000_validate_option(&adapter->itr, &opt,
334 * save the setting, because the dynamic bits
335 * change itr. clear the lower two bits
336 * because they are used as control
338 adapter->itr_setting = adapter->itr & ~3;
342 adapter->itr_setting = opt.def;
343 adapter->itr = 20000;
346 { /* Smart Power Down */
347 struct e1000_option opt = {
348 .type = enable_option,
349 .name = "PHY Smart Power Down",
350 .err = "defaulting to Disabled",
351 .def = OPTION_DISABLED
354 if (num_SmartPowerDownEnable > bd) {
355 int spd = SmartPowerDownEnable[bd];
356 e1000_validate_option(&spd, &opt, adapter);
357 if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN)
359 adapter->flags |= FLAG_SMART_POWER_DOWN;
362 { /* Kumeran Lock Loss Workaround */
363 struct e1000_option opt = {
364 .type = enable_option,
365 .name = "Kumeran Lock Loss Workaround",
366 .err = "defaulting to Enabled",
367 .def = OPTION_ENABLED
370 if (num_KumeranLockLoss > bd) {
371 int kmrn_lock_loss = KumeranLockLoss[bd];
372 e1000_validate_option(&kmrn_lock_loss, &opt, adapter);
373 if (hw->mac.type == e1000_ich8lan)
374 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw,
377 if (hw->mac.type == e1000_ich8lan)
378 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw,