1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2008 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>
34 * This is the only thing that needs to be changed to adjust the
35 * maximum number of ports that the driver can manage.
38 #define E1000_MAX_NIC 32
40 #define OPTION_UNSET -1
41 #define OPTION_DISABLED 0
42 #define OPTION_ENABLED 1
44 #define COPYBREAK_DEFAULT 256
45 unsigned int copybreak = COPYBREAK_DEFAULT;
46 module_param(copybreak, uint, 0644);
47 MODULE_PARM_DESC(copybreak,
48 "Maximum size of packet that is copied to a new buffer on receive");
51 * All parameters are treated the same, as an integer array of values.
52 * This macro just reduces the need to repeat the same declaration code
53 * over and over (plus this helps to avoid typo bugs).
56 #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
57 #define E1000_PARAM(X, desc) \
58 static int __devinitdata X[E1000_MAX_NIC+1] \
60 static unsigned int num_##X; \
61 module_param_array_named(X, X, int, &num_##X, 0); \
62 MODULE_PARM_DESC(X, desc);
66 * Transmit Interrupt Delay in units of 1.024 microseconds
67 * Tx interrupt delay needs to typically be set to something non zero
69 * Valid Range: 0-65535
71 E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
72 #define DEFAULT_TIDV 8
73 #define MAX_TXDELAY 0xFFFF
77 * Transmit Absolute Interrupt Delay in units of 1.024 microseconds
79 * Valid Range: 0-65535
81 E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
82 #define DEFAULT_TADV 32
83 #define MAX_TXABSDELAY 0xFFFF
84 #define MIN_TXABSDELAY 0
87 * Receive Interrupt Delay in units of 1.024 microseconds
88 * hardware will likely hang if you set this to anything but zero.
90 * Valid Range: 0-65535
92 E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
93 #define DEFAULT_RDTR 0
94 #define MAX_RXDELAY 0xFFFF
98 * Receive Absolute Interrupt Delay in units of 1.024 microseconds
100 * Valid Range: 0-65535
102 E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
103 #define DEFAULT_RADV 8
104 #define MAX_RXABSDELAY 0xFFFF
105 #define MIN_RXABSDELAY 0
108 * Interrupt Throttle Rate (interrupts/sec)
110 * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative)
112 E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
113 #define DEFAULT_ITR 3
114 #define MAX_ITR 100000
118 * Enable Smart Power Down of the PHY
122 * Default Value: 0 (disabled)
124 E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
127 * Enable Kumeran Lock Loss workaround
131 * Default Value: 1 (enabled)
133 E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");
135 struct e1000_option {
136 enum { enable_option, range_option, list_option } type;
141 struct { /* range_option info */
145 struct { /* list_option info */
147 struct e1000_opt_list { int i; char *str; } *p;
152 static int __devinit e1000_validate_option(unsigned int *value,
153 const struct e1000_option *opt,
154 struct e1000_adapter *adapter)
156 if (*value == OPTION_UNSET) {
165 ndev_info(adapter->netdev, "%s Enabled\n", opt->name);
167 case OPTION_DISABLED:
168 ndev_info(adapter->netdev, "%s Disabled\n", opt->name);
173 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
174 ndev_info(adapter->netdev,
175 "%s set to %i\n", opt->name, *value);
181 struct e1000_opt_list *ent;
183 for (i = 0; i < opt->arg.l.nr; i++) {
184 ent = &opt->arg.l.p[i];
185 if (*value == ent->i) {
186 if (ent->str[0] != '\0')
187 ndev_info(adapter->netdev, "%s\n",
198 ndev_info(adapter->netdev, "Invalid %s value specified (%i) %s\n",
199 opt->name, *value, opt->err);
205 * e1000e_check_options - Range Checking for Command Line Parameters
206 * @adapter: board private structure
208 * This routine checks all command line parameters for valid user
209 * input. If an invalid value is given, or if no user specified
210 * value exists, a default value is used. The final value is stored
211 * in a variable in the adapter structure.
213 void __devinit e1000e_check_options(struct e1000_adapter *adapter)
215 struct e1000_hw *hw = &adapter->hw;
216 struct net_device *netdev = adapter->netdev;
217 int bd = adapter->bd_number;
219 if (bd >= E1000_MAX_NIC) {
221 "Warning: no configuration for board #%i\n", bd);
222 ndev_notice(netdev, "Using defaults for all values\n");
225 { /* Transmit Interrupt Delay */
226 const struct e1000_option opt = {
227 .type = range_option,
228 .name = "Transmit Interrupt Delay",
229 .err = "using default of "
230 __MODULE_STRING(DEFAULT_TIDV),
232 .arg = { .r = { .min = MIN_TXDELAY,
233 .max = MAX_TXDELAY } }
236 if (num_TxIntDelay > bd) {
237 adapter->tx_int_delay = TxIntDelay[bd];
238 e1000_validate_option(&adapter->tx_int_delay, &opt,
241 adapter->tx_int_delay = opt.def;
244 { /* Transmit Absolute Interrupt Delay */
245 const struct e1000_option opt = {
246 .type = range_option,
247 .name = "Transmit Absolute Interrupt Delay",
248 .err = "using default of "
249 __MODULE_STRING(DEFAULT_TADV),
251 .arg = { .r = { .min = MIN_TXABSDELAY,
252 .max = MAX_TXABSDELAY } }
255 if (num_TxAbsIntDelay > bd) {
256 adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
257 e1000_validate_option(&adapter->tx_abs_int_delay, &opt,
260 adapter->tx_abs_int_delay = opt.def;
263 { /* Receive Interrupt Delay */
264 struct e1000_option opt = {
265 .type = range_option,
266 .name = "Receive Interrupt Delay",
267 .err = "using default of "
268 __MODULE_STRING(DEFAULT_RDTR),
270 .arg = { .r = { .min = MIN_RXDELAY,
271 .max = MAX_RXDELAY } }
274 if (num_RxIntDelay > bd) {
275 adapter->rx_int_delay = RxIntDelay[bd];
276 e1000_validate_option(&adapter->rx_int_delay, &opt,
279 adapter->rx_int_delay = opt.def;
282 { /* Receive Absolute Interrupt Delay */
283 const struct e1000_option opt = {
284 .type = range_option,
285 .name = "Receive Absolute Interrupt Delay",
286 .err = "using default of "
287 __MODULE_STRING(DEFAULT_RADV),
289 .arg = { .r = { .min = MIN_RXABSDELAY,
290 .max = MAX_RXABSDELAY } }
293 if (num_RxAbsIntDelay > bd) {
294 adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
295 e1000_validate_option(&adapter->rx_abs_int_delay, &opt,
298 adapter->rx_abs_int_delay = opt.def;
301 { /* Interrupt Throttling Rate */
302 const struct e1000_option opt = {
303 .type = range_option,
304 .name = "Interrupt Throttling Rate (ints/sec)",
305 .err = "using default of "
306 __MODULE_STRING(DEFAULT_ITR),
308 .arg = { .r = { .min = MIN_ITR,
312 if (num_InterruptThrottleRate > bd) {
313 adapter->itr = InterruptThrottleRate[bd];
314 switch (adapter->itr) {
316 ndev_info(netdev, "%s turned off\n",
321 "%s set to dynamic mode\n",
323 adapter->itr_setting = adapter->itr;
324 adapter->itr = 20000;
328 "%s set to dynamic conservative mode\n",
330 adapter->itr_setting = adapter->itr;
331 adapter->itr = 20000;
334 e1000_validate_option(&adapter->itr, &opt,
337 * save the setting, because the dynamic bits
338 * change itr. clear the lower two bits
339 * because they are used as control
341 adapter->itr_setting = adapter->itr & ~3;
345 adapter->itr_setting = opt.def;
346 adapter->itr = 20000;
349 { /* Smart Power Down */
350 const struct e1000_option opt = {
351 .type = enable_option,
352 .name = "PHY Smart Power Down",
353 .err = "defaulting to Disabled",
354 .def = OPTION_DISABLED
357 if (num_SmartPowerDownEnable > bd) {
358 unsigned int spd = SmartPowerDownEnable[bd];
359 e1000_validate_option(&spd, &opt, adapter);
360 if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN)
362 adapter->flags |= FLAG_SMART_POWER_DOWN;
365 { /* Kumeran Lock Loss Workaround */
366 const struct e1000_option opt = {
367 .type = enable_option,
368 .name = "Kumeran Lock Loss Workaround",
369 .err = "defaulting to Enabled",
370 .def = OPTION_ENABLED
373 if (num_KumeranLockLoss > bd) {
374 unsigned int kmrn_lock_loss = KumeranLockLoss[bd];
375 e1000_validate_option(&kmrn_lock_loss, &opt, adapter);
376 if (hw->mac.type == e1000_ich8lan)
377 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw,
380 if (hw->mac.type == e1000_ich8lan)
381 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw,