Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | |
| 3 | Intel PRO/1000 Linux driver |
Bruce Allan | 0d6057e | 2011-01-04 01:16:44 +0000 | [diff] [blame] | 4 | Copyright(c) 1999 - 2011 Intel Corporation. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 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> |
Paul Gortmaker | 9d9779e | 2011-07-03 15:21:01 -0400 | [diff] [blame] | 30 | #include <linux/module.h> |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 31 | #include <linux/pci.h> |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 32 | |
| 33 | #include "e1000.h" |
| 34 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 35 | /* |
| 36 | * This is the only thing that needs to be changed to adjust the |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 37 | * maximum number of ports that the driver can manage. |
| 38 | */ |
| 39 | |
| 40 | #define E1000_MAX_NIC 32 |
| 41 | |
| 42 | #define OPTION_UNSET -1 |
| 43 | #define OPTION_DISABLED 0 |
| 44 | #define OPTION_ENABLED 1 |
| 45 | |
| 46 | #define COPYBREAK_DEFAULT 256 |
| 47 | unsigned int copybreak = COPYBREAK_DEFAULT; |
| 48 | module_param(copybreak, uint, 0644); |
| 49 | MODULE_PARM_DESC(copybreak, |
| 50 | "Maximum size of packet that is copied to a new buffer on receive"); |
| 51 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 52 | /* |
| 53 | * All parameters are treated the same, as an integer array of values. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 54 | * This macro just reduces the need to repeat the same declaration code |
| 55 | * over and over (plus this helps to avoid typo bugs). |
| 56 | */ |
| 57 | |
| 58 | #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET } |
Stephen Hemminger | 5a9147b | 2007-10-29 10:46:05 -0700 | [diff] [blame] | 59 | #define E1000_PARAM(X, desc) \ |
| 60 | static int __devinitdata X[E1000_MAX_NIC+1] \ |
| 61 | = E1000_PARAM_INIT; \ |
| 62 | static unsigned int num_##X; \ |
| 63 | module_param_array_named(X, X, int, &num_##X, 0); \ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 64 | MODULE_PARM_DESC(X, desc); |
| 65 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 66 | /* |
| 67 | * Transmit Interrupt Delay in units of 1.024 microseconds |
Bruce Allan | af667a2 | 2010-12-31 06:10:01 +0000 | [diff] [blame] | 68 | * Tx interrupt delay needs to typically be set to something non-zero |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 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 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 77 | /* |
| 78 | * Transmit Absolute Interrupt Delay in units of 1.024 microseconds |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 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 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 87 | /* |
| 88 | * Receive Interrupt Delay in units of 1.024 microseconds |
| 89 | * hardware will likely hang if you set this to anything but zero. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 90 | * |
| 91 | * Valid Range: 0-65535 |
| 92 | */ |
| 93 | E1000_PARAM(RxIntDelay, "Receive Interrupt Delay"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 94 | #define MAX_RXDELAY 0xFFFF |
| 95 | #define MIN_RXDELAY 0 |
| 96 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 97 | /* |
| 98 | * Receive Absolute Interrupt Delay in units of 1.024 microseconds |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 99 | * |
| 100 | * Valid Range: 0-65535 |
| 101 | */ |
| 102 | E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 103 | #define MAX_RXABSDELAY 0xFFFF |
| 104 | #define MIN_RXABSDELAY 0 |
| 105 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 106 | /* |
| 107 | * Interrupt Throttle Rate (interrupts/sec) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 108 | * |
| 109 | * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative) |
| 110 | */ |
| 111 | E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate"); |
| 112 | #define DEFAULT_ITR 3 |
| 113 | #define MAX_ITR 100000 |
| 114 | #define MIN_ITR 100 |
Bruce Allan | af667a2 | 2010-12-31 06:10:01 +0000 | [diff] [blame] | 115 | |
Bruce Allan | b6fbca2 | 2011-12-16 00:45:56 +0000 | [diff] [blame] | 116 | /* |
| 117 | * IntMode (Interrupt Mode) |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 118 | * |
Bruce Allan | b6fbca2 | 2011-12-16 00:45:56 +0000 | [diff] [blame] | 119 | * Valid Range: varies depending on kernel configuration & hardware support |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 120 | * |
Bruce Allan | b6fbca2 | 2011-12-16 00:45:56 +0000 | [diff] [blame] | 121 | * legacy=0, MSI=1, MSI-X=2 |
| 122 | * |
| 123 | * When MSI/MSI-X support is enabled in kernel- |
| 124 | * Default Value: 2 (MSI-X) when supported by hardware, 1 (MSI) otherwise |
| 125 | * When MSI/MSI-X support is not enabled in kernel- |
| 126 | * Default Value: 0 (legacy) |
| 127 | * |
| 128 | * When a mode is specified that is not allowed/supported, it will be |
| 129 | * demoted to the most advanced interrupt mode available. |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 130 | */ |
| 131 | E1000_PARAM(IntMode, "Interrupt Mode"); |
| 132 | #define MAX_INTMODE 2 |
| 133 | #define MIN_INTMODE 0 |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 134 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 135 | /* |
| 136 | * Enable Smart Power Down of the PHY |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 137 | * |
| 138 | * Valid Range: 0, 1 |
| 139 | * |
| 140 | * Default Value: 0 (disabled) |
| 141 | */ |
| 142 | E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down"); |
| 143 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 144 | /* |
| 145 | * Enable Kumeran Lock Loss workaround |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 146 | * |
| 147 | * Valid Range: 0, 1 |
| 148 | * |
| 149 | * Default Value: 1 (enabled) |
| 150 | */ |
| 151 | E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround"); |
| 152 | |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 153 | /* |
| 154 | * Write Protect NVM |
| 155 | * |
| 156 | * Valid Range: 0, 1 |
| 157 | * |
| 158 | * Default Value: 1 (enabled) |
| 159 | */ |
| 160 | E1000_PARAM(WriteProtectNVM, "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]"); |
| 161 | |
Jeff Kirsher | eb7c3ad | 2008-11-14 06:45:23 +0000 | [diff] [blame] | 162 | /* |
| 163 | * Enable CRC Stripping |
| 164 | * |
| 165 | * Valid Range: 0, 1 |
| 166 | * |
| 167 | * Default Value: 1 (enabled) |
| 168 | */ |
| 169 | E1000_PARAM(CrcStripping, "Enable CRC Stripping, disable if your BMC needs " \ |
| 170 | "the CRC"); |
| 171 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 172 | struct e1000_option { |
| 173 | enum { enable_option, range_option, list_option } type; |
Stephen Hemminger | 5a9147b | 2007-10-29 10:46:05 -0700 | [diff] [blame] | 174 | const char *name; |
| 175 | const char *err; |
| 176 | int def; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 177 | union { |
| 178 | struct { /* range_option info */ |
| 179 | int min; |
| 180 | int max; |
| 181 | } r; |
| 182 | struct { /* list_option info */ |
| 183 | int nr; |
| 184 | struct e1000_opt_list { int i; char *str; } *p; |
| 185 | } l; |
| 186 | } arg; |
| 187 | }; |
| 188 | |
Stephen Hemminger | 5a9147b | 2007-10-29 10:46:05 -0700 | [diff] [blame] | 189 | static int __devinit e1000_validate_option(unsigned int *value, |
| 190 | const struct e1000_option *opt, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 191 | struct e1000_adapter *adapter) |
| 192 | { |
| 193 | if (*value == OPTION_UNSET) { |
| 194 | *value = opt->def; |
| 195 | return 0; |
| 196 | } |
| 197 | |
| 198 | switch (opt->type) { |
| 199 | case enable_option: |
| 200 | switch (*value) { |
| 201 | case OPTION_ENABLED: |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 202 | e_info("%s Enabled\n", opt->name); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 203 | return 0; |
| 204 | case OPTION_DISABLED: |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 205 | e_info("%s Disabled\n", opt->name); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 206 | return 0; |
| 207 | } |
| 208 | break; |
| 209 | case range_option: |
| 210 | if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) { |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 211 | e_info("%s set to %i\n", opt->name, *value); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 212 | return 0; |
| 213 | } |
| 214 | break; |
| 215 | case list_option: { |
| 216 | int i; |
| 217 | struct e1000_opt_list *ent; |
| 218 | |
| 219 | for (i = 0; i < opt->arg.l.nr; i++) { |
| 220 | ent = &opt->arg.l.p[i]; |
| 221 | if (*value == ent->i) { |
| 222 | if (ent->str[0] != '\0') |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 223 | e_info("%s\n", ent->str); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 224 | return 0; |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | break; |
| 229 | default: |
| 230 | BUG(); |
| 231 | } |
| 232 | |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 233 | e_info("Invalid %s value specified (%i) %s\n", opt->name, *value, |
| 234 | opt->err); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 235 | *value = opt->def; |
| 236 | return -1; |
| 237 | } |
| 238 | |
| 239 | /** |
| 240 | * e1000e_check_options - Range Checking for Command Line Parameters |
| 241 | * @adapter: board private structure |
| 242 | * |
| 243 | * This routine checks all command line parameters for valid user |
| 244 | * input. If an invalid value is given, or if no user specified |
| 245 | * value exists, a default value is used. The final value is stored |
| 246 | * in a variable in the adapter structure. |
| 247 | **/ |
| 248 | void __devinit e1000e_check_options(struct e1000_adapter *adapter) |
| 249 | { |
| 250 | struct e1000_hw *hw = &adapter->hw; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 251 | int bd = adapter->bd_number; |
| 252 | |
| 253 | if (bd >= E1000_MAX_NIC) { |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 254 | e_notice("Warning: no configuration for board #%i\n", bd); |
| 255 | e_notice("Using defaults for all values\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | { /* Transmit Interrupt Delay */ |
Jesse Brandeburg | 6f59d66 | 2010-04-09 10:51:09 +0000 | [diff] [blame] | 259 | static const struct e1000_option opt = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 260 | .type = range_option, |
| 261 | .name = "Transmit Interrupt Delay", |
| 262 | .err = "using default of " |
| 263 | __MODULE_STRING(DEFAULT_TIDV), |
| 264 | .def = DEFAULT_TIDV, |
| 265 | .arg = { .r = { .min = MIN_TXDELAY, |
| 266 | .max = MAX_TXDELAY } } |
| 267 | }; |
| 268 | |
| 269 | if (num_TxIntDelay > bd) { |
| 270 | adapter->tx_int_delay = TxIntDelay[bd]; |
| 271 | e1000_validate_option(&adapter->tx_int_delay, &opt, |
| 272 | adapter); |
| 273 | } else { |
| 274 | adapter->tx_int_delay = opt.def; |
| 275 | } |
| 276 | } |
| 277 | { /* Transmit Absolute Interrupt Delay */ |
Jesse Brandeburg | 6f59d66 | 2010-04-09 10:51:09 +0000 | [diff] [blame] | 278 | static const struct e1000_option opt = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 279 | .type = range_option, |
| 280 | .name = "Transmit Absolute Interrupt Delay", |
| 281 | .err = "using default of " |
| 282 | __MODULE_STRING(DEFAULT_TADV), |
| 283 | .def = DEFAULT_TADV, |
| 284 | .arg = { .r = { .min = MIN_TXABSDELAY, |
| 285 | .max = MAX_TXABSDELAY } } |
| 286 | }; |
| 287 | |
| 288 | if (num_TxAbsIntDelay > bd) { |
| 289 | adapter->tx_abs_int_delay = TxAbsIntDelay[bd]; |
| 290 | e1000_validate_option(&adapter->tx_abs_int_delay, &opt, |
| 291 | adapter); |
| 292 | } else { |
| 293 | adapter->tx_abs_int_delay = opt.def; |
| 294 | } |
| 295 | } |
| 296 | { /* Receive Interrupt Delay */ |
Bruce Allan | 4fe4491 | 2010-05-10 14:59:10 +0000 | [diff] [blame] | 297 | static struct e1000_option opt = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 298 | .type = range_option, |
| 299 | .name = "Receive Interrupt Delay", |
| 300 | .err = "using default of " |
| 301 | __MODULE_STRING(DEFAULT_RDTR), |
| 302 | .def = DEFAULT_RDTR, |
| 303 | .arg = { .r = { .min = MIN_RXDELAY, |
| 304 | .max = MAX_RXDELAY } } |
| 305 | }; |
| 306 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 307 | if (num_RxIntDelay > bd) { |
| 308 | adapter->rx_int_delay = RxIntDelay[bd]; |
| 309 | e1000_validate_option(&adapter->rx_int_delay, &opt, |
| 310 | adapter); |
| 311 | } else { |
| 312 | adapter->rx_int_delay = opt.def; |
| 313 | } |
| 314 | } |
| 315 | { /* Receive Absolute Interrupt Delay */ |
Jesse Brandeburg | 6f59d66 | 2010-04-09 10:51:09 +0000 | [diff] [blame] | 316 | static const struct e1000_option opt = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 317 | .type = range_option, |
| 318 | .name = "Receive Absolute Interrupt Delay", |
| 319 | .err = "using default of " |
| 320 | __MODULE_STRING(DEFAULT_RADV), |
| 321 | .def = DEFAULT_RADV, |
| 322 | .arg = { .r = { .min = MIN_RXABSDELAY, |
| 323 | .max = MAX_RXABSDELAY } } |
| 324 | }; |
| 325 | |
| 326 | if (num_RxAbsIntDelay > bd) { |
| 327 | adapter->rx_abs_int_delay = RxAbsIntDelay[bd]; |
| 328 | e1000_validate_option(&adapter->rx_abs_int_delay, &opt, |
| 329 | adapter); |
| 330 | } else { |
| 331 | adapter->rx_abs_int_delay = opt.def; |
| 332 | } |
| 333 | } |
| 334 | { /* Interrupt Throttling Rate */ |
Jesse Brandeburg | 6f59d66 | 2010-04-09 10:51:09 +0000 | [diff] [blame] | 335 | static const struct e1000_option opt = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 336 | .type = range_option, |
| 337 | .name = "Interrupt Throttling Rate (ints/sec)", |
| 338 | .err = "using default of " |
| 339 | __MODULE_STRING(DEFAULT_ITR), |
| 340 | .def = DEFAULT_ITR, |
| 341 | .arg = { .r = { .min = MIN_ITR, |
| 342 | .max = MAX_ITR } } |
| 343 | }; |
| 344 | |
| 345 | if (num_InterruptThrottleRate > bd) { |
| 346 | adapter->itr = InterruptThrottleRate[bd]; |
| 347 | switch (adapter->itr) { |
| 348 | case 0: |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 349 | e_info("%s turned off\n", opt.name); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 350 | break; |
| 351 | case 1: |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 352 | e_info("%s set to dynamic mode\n", opt.name); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 353 | adapter->itr_setting = adapter->itr; |
| 354 | adapter->itr = 20000; |
| 355 | break; |
| 356 | case 3: |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 357 | e_info("%s set to dynamic conservative mode\n", |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 358 | opt.name); |
| 359 | adapter->itr_setting = adapter->itr; |
| 360 | adapter->itr = 20000; |
| 361 | break; |
Jesse Brandeburg | eab2abf | 2010-05-04 22:26:03 +0000 | [diff] [blame] | 362 | case 4: |
| 363 | e_info("%s set to simplified (2000-8000 ints) " |
| 364 | "mode\n", opt.name); |
| 365 | adapter->itr_setting = 4; |
| 366 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 367 | default: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 368 | /* |
Bruce Allan | 2d06cad | 2008-08-08 18:35:51 -0700 | [diff] [blame] | 369 | * Save the setting, because the dynamic bits |
| 370 | * change itr. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 371 | */ |
Bruce Allan | 2d06cad | 2008-08-08 18:35:51 -0700 | [diff] [blame] | 372 | if (e1000_validate_option(&adapter->itr, &opt, |
| 373 | adapter) && |
| 374 | (adapter->itr == 3)) { |
| 375 | /* |
| 376 | * In case of invalid user value, |
| 377 | * default to conservative mode. |
| 378 | */ |
| 379 | adapter->itr_setting = adapter->itr; |
| 380 | adapter->itr = 20000; |
| 381 | } else { |
| 382 | /* |
| 383 | * Clear the lower two bits because |
| 384 | * they are used as control. |
| 385 | */ |
| 386 | adapter->itr_setting = |
| 387 | adapter->itr & ~3; |
| 388 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 389 | break; |
| 390 | } |
| 391 | } else { |
| 392 | adapter->itr_setting = opt.def; |
| 393 | adapter->itr = 20000; |
| 394 | } |
| 395 | } |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 396 | { /* Interrupt Mode */ |
Bruce Allan | 4fe4491 | 2010-05-10 14:59:10 +0000 | [diff] [blame] | 397 | static struct e1000_option opt = { |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 398 | .type = range_option, |
| 399 | .name = "Interrupt Mode", |
Bruce Allan | b6fbca2 | 2011-12-16 00:45:56 +0000 | [diff] [blame] | 400 | #ifndef CONFIG_PCI_MSI |
| 401 | .err = "defaulting to 0 (legacy)", |
| 402 | .def = E1000E_INT_MODE_LEGACY, |
| 403 | .arg = { .r = { .min = 0, |
| 404 | .max = 0 } } |
| 405 | #endif |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 406 | }; |
| 407 | |
Bruce Allan | b6fbca2 | 2011-12-16 00:45:56 +0000 | [diff] [blame] | 408 | #ifdef CONFIG_PCI_MSI |
| 409 | if (adapter->flags & FLAG_HAS_MSIX) { |
| 410 | opt.err = kstrdup("defaulting to 2 (MSI-X)", |
| 411 | GFP_KERNEL); |
| 412 | opt.def = E1000E_INT_MODE_MSIX; |
| 413 | opt.arg.r.max = E1000E_INT_MODE_MSIX; |
| 414 | } else { |
| 415 | opt.err = kstrdup("defaulting to 1 (MSI)", GFP_KERNEL); |
| 416 | opt.def = E1000E_INT_MODE_MSI; |
| 417 | opt.arg.r.max = E1000E_INT_MODE_MSI; |
| 418 | } |
| 419 | |
| 420 | if (!opt.err) { |
| 421 | dev_err(&adapter->pdev->dev, |
| 422 | "Failed to allocate memory\n"); |
| 423 | return; |
| 424 | } |
| 425 | #endif |
| 426 | |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 427 | if (num_IntMode > bd) { |
| 428 | unsigned int int_mode = IntMode[bd]; |
| 429 | e1000_validate_option(&int_mode, &opt, adapter); |
| 430 | adapter->int_mode = int_mode; |
| 431 | } else { |
| 432 | adapter->int_mode = opt.def; |
| 433 | } |
Bruce Allan | b6fbca2 | 2011-12-16 00:45:56 +0000 | [diff] [blame] | 434 | |
| 435 | #ifdef CONFIG_PCI_MSI |
| 436 | kfree(opt.err); |
| 437 | #endif |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 438 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 439 | { /* Smart Power Down */ |
Jesse Brandeburg | 6f59d66 | 2010-04-09 10:51:09 +0000 | [diff] [blame] | 440 | static const struct e1000_option opt = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 441 | .type = enable_option, |
| 442 | .name = "PHY Smart Power Down", |
| 443 | .err = "defaulting to Disabled", |
| 444 | .def = OPTION_DISABLED |
| 445 | }; |
| 446 | |
| 447 | if (num_SmartPowerDownEnable > bd) { |
Stephen Hemminger | 5a9147b | 2007-10-29 10:46:05 -0700 | [diff] [blame] | 448 | unsigned int spd = SmartPowerDownEnable[bd]; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 449 | e1000_validate_option(&spd, &opt, adapter); |
| 450 | if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) |
| 451 | && spd) |
| 452 | adapter->flags |= FLAG_SMART_POWER_DOWN; |
| 453 | } |
| 454 | } |
Jeff Kirsher | eb7c3ad | 2008-11-14 06:45:23 +0000 | [diff] [blame] | 455 | { /* CRC Stripping */ |
Jesse Brandeburg | 6f59d66 | 2010-04-09 10:51:09 +0000 | [diff] [blame] | 456 | static const struct e1000_option opt = { |
Jeff Kirsher | eb7c3ad | 2008-11-14 06:45:23 +0000 | [diff] [blame] | 457 | .type = enable_option, |
| 458 | .name = "CRC Stripping", |
Bruce Allan | e926244 | 2010-11-24 06:02:06 +0000 | [diff] [blame] | 459 | .err = "defaulting to Enabled", |
Jeff Kirsher | eb7c3ad | 2008-11-14 06:45:23 +0000 | [diff] [blame] | 460 | .def = OPTION_ENABLED |
| 461 | }; |
| 462 | |
| 463 | if (num_CrcStripping > bd) { |
| 464 | unsigned int crc_stripping = CrcStripping[bd]; |
| 465 | e1000_validate_option(&crc_stripping, &opt, adapter); |
| 466 | if (crc_stripping == OPTION_ENABLED) |
| 467 | adapter->flags2 |= FLAG2_CRC_STRIPPING; |
Bruce Allan | 6e50912a | 2009-06-02 11:28:01 +0000 | [diff] [blame] | 468 | } else { |
| 469 | adapter->flags2 |= FLAG2_CRC_STRIPPING; |
Jeff Kirsher | eb7c3ad | 2008-11-14 06:45:23 +0000 | [diff] [blame] | 470 | } |
| 471 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 472 | { /* Kumeran Lock Loss Workaround */ |
Jesse Brandeburg | 6f59d66 | 2010-04-09 10:51:09 +0000 | [diff] [blame] | 473 | static const struct e1000_option opt = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 474 | .type = enable_option, |
| 475 | .name = "Kumeran Lock Loss Workaround", |
| 476 | .err = "defaulting to Enabled", |
| 477 | .def = OPTION_ENABLED |
| 478 | }; |
| 479 | |
| 480 | if (num_KumeranLockLoss > bd) { |
Stephen Hemminger | 5a9147b | 2007-10-29 10:46:05 -0700 | [diff] [blame] | 481 | unsigned int kmrn_lock_loss = KumeranLockLoss[bd]; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 482 | e1000_validate_option(&kmrn_lock_loss, &opt, adapter); |
| 483 | if (hw->mac.type == e1000_ich8lan) |
| 484 | e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, |
| 485 | kmrn_lock_loss); |
| 486 | } else { |
| 487 | if (hw->mac.type == e1000_ich8lan) |
| 488 | e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, |
| 489 | opt.def); |
| 490 | } |
| 491 | } |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 492 | { /* Write-protect NVM */ |
Jesse Brandeburg | 6f59d66 | 2010-04-09 10:51:09 +0000 | [diff] [blame] | 493 | static const struct e1000_option opt = { |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 494 | .type = enable_option, |
| 495 | .name = "Write-protect NVM", |
| 496 | .err = "defaulting to Enabled", |
| 497 | .def = OPTION_ENABLED |
| 498 | }; |
| 499 | |
| 500 | if (adapter->flags & FLAG_IS_ICH) { |
| 501 | if (num_WriteProtectNVM > bd) { |
| 502 | unsigned int write_protect_nvm = WriteProtectNVM[bd]; |
| 503 | e1000_validate_option(&write_protect_nvm, &opt, |
| 504 | adapter); |
| 505 | if (write_protect_nvm) |
| 506 | adapter->flags |= FLAG_READ_ONLY_NVM; |
| 507 | } else { |
| 508 | if (opt.def) |
| 509 | adapter->flags |= FLAG_READ_ONLY_NVM; |
| 510 | } |
| 511 | } |
| 512 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 513 | } |