Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | |
| 3 | Intel PRO/1000 Linux driver |
Bruce Allan | f5e261e | 2012-01-01 16:00:03 +0000 | [diff] [blame] | 4 | Copyright(c) 1999 - 2012 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 | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 35 | /* 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] | 36 | * maximum number of ports that the driver can manage. |
| 37 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 38 | #define E1000_MAX_NIC 32 |
| 39 | |
| 40 | #define OPTION_UNSET -1 |
| 41 | #define OPTION_DISABLED 0 |
| 42 | #define OPTION_ENABLED 1 |
| 43 | |
| 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"); |
| 49 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 50 | /* All parameters are treated the same, as an integer array of values. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 51 | * This macro just reduces the need to repeat the same declaration code |
| 52 | * over and over (plus this helps to avoid typo bugs). |
| 53 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 54 | #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET } |
Stephen Hemminger | 5a9147b | 2007-10-29 10:46:05 -0700 | [diff] [blame] | 55 | #define E1000_PARAM(X, desc) \ |
Bill Pemberton | 9f9a12f | 2012-12-03 09:24:25 -0500 | [diff] [blame] | 56 | static int X[E1000_MAX_NIC+1] \ |
Stephen Hemminger | 5a9147b | 2007-10-29 10:46:05 -0700 | [diff] [blame] | 57 | = E1000_PARAM_INIT; \ |
| 58 | static unsigned int num_##X; \ |
| 59 | module_param_array_named(X, X, int, &num_##X, 0); \ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 60 | MODULE_PARM_DESC(X, desc); |
| 61 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 62 | /* Transmit Interrupt Delay in units of 1.024 microseconds |
Bruce Allan | af667a2 | 2010-12-31 06:10:01 +0000 | [diff] [blame] | 63 | * Tx interrupt delay needs to typically be set to something non-zero |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 64 | * |
| 65 | * Valid Range: 0-65535 |
| 66 | */ |
| 67 | E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay"); |
| 68 | #define DEFAULT_TIDV 8 |
| 69 | #define MAX_TXDELAY 0xFFFF |
| 70 | #define MIN_TXDELAY 0 |
| 71 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 72 | /* Transmit Absolute Interrupt Delay in units of 1.024 microseconds |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 73 | * |
| 74 | * Valid Range: 0-65535 |
| 75 | */ |
| 76 | E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay"); |
| 77 | #define DEFAULT_TADV 32 |
| 78 | #define MAX_TXABSDELAY 0xFFFF |
| 79 | #define MIN_TXABSDELAY 0 |
| 80 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 81 | /* Receive Interrupt Delay in units of 1.024 microseconds |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 82 | * hardware will likely hang if you set this to anything but zero. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 83 | * |
| 84 | * Valid Range: 0-65535 |
| 85 | */ |
| 86 | E1000_PARAM(RxIntDelay, "Receive Interrupt Delay"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 87 | #define MAX_RXDELAY 0xFFFF |
| 88 | #define MIN_RXDELAY 0 |
| 89 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 90 | /* Receive Absolute Interrupt Delay in units of 1.024 microseconds |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 91 | * |
| 92 | * Valid Range: 0-65535 |
| 93 | */ |
| 94 | E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 95 | #define MAX_RXABSDELAY 0xFFFF |
| 96 | #define MIN_RXABSDELAY 0 |
| 97 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 98 | /* Interrupt Throttle Rate (interrupts/sec) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 99 | * |
Jeff Kirsher | 727c356 | 2012-04-20 08:51:45 +0000 | [diff] [blame] | 100 | * Valid Range: 100-100000 or one of: 0=off, 1=dynamic, 3=dynamic conservative |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 101 | */ |
| 102 | E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate"); |
| 103 | #define DEFAULT_ITR 3 |
| 104 | #define MAX_ITR 100000 |
| 105 | #define MIN_ITR 100 |
Bruce Allan | af667a2 | 2010-12-31 06:10:01 +0000 | [diff] [blame] | 106 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 107 | /* IntMode (Interrupt Mode) |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 108 | * |
Bruce Allan | b6fbca2 | 2011-12-16 00:45:56 +0000 | [diff] [blame] | 109 | * Valid Range: varies depending on kernel configuration & hardware support |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 110 | * |
Bruce Allan | b6fbca2 | 2011-12-16 00:45:56 +0000 | [diff] [blame] | 111 | * legacy=0, MSI=1, MSI-X=2 |
| 112 | * |
| 113 | * When MSI/MSI-X support is enabled in kernel- |
| 114 | * Default Value: 2 (MSI-X) when supported by hardware, 1 (MSI) otherwise |
| 115 | * When MSI/MSI-X support is not enabled in kernel- |
| 116 | * Default Value: 0 (legacy) |
| 117 | * |
| 118 | * When a mode is specified that is not allowed/supported, it will be |
| 119 | * demoted to the most advanced interrupt mode available. |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 120 | */ |
| 121 | E1000_PARAM(IntMode, "Interrupt Mode"); |
| 122 | #define MAX_INTMODE 2 |
| 123 | #define MIN_INTMODE 0 |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 124 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 125 | /* Enable Smart Power Down of the PHY |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 126 | * |
| 127 | * Valid Range: 0, 1 |
| 128 | * |
| 129 | * Default Value: 0 (disabled) |
| 130 | */ |
| 131 | E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down"); |
| 132 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 133 | /* Enable Kumeran Lock Loss workaround |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 134 | * |
| 135 | * Valid Range: 0, 1 |
| 136 | * |
| 137 | * Default Value: 1 (enabled) |
| 138 | */ |
| 139 | E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround"); |
| 140 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 141 | /* Write Protect NVM |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 142 | * |
| 143 | * Valid Range: 0, 1 |
| 144 | * |
| 145 | * Default Value: 1 (enabled) |
| 146 | */ |
| 147 | E1000_PARAM(WriteProtectNVM, "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]"); |
| 148 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 149 | /* Enable CRC Stripping |
Jeff Kirsher | eb7c3ad | 2008-11-14 06:45:23 +0000 | [diff] [blame] | 150 | * |
| 151 | * Valid Range: 0, 1 |
| 152 | * |
| 153 | * Default Value: 1 (enabled) |
| 154 | */ |
Bruce Allan | 6ad6514 | 2012-04-12 05:47:09 +0000 | [diff] [blame] | 155 | E1000_PARAM(CrcStripping, |
| 156 | "Enable CRC Stripping, disable if your BMC needs the CRC"); |
Jeff Kirsher | eb7c3ad | 2008-11-14 06:45:23 +0000 | [diff] [blame] | 157 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 158 | struct e1000_option { |
| 159 | enum { enable_option, range_option, list_option } type; |
Stephen Hemminger | 5a9147b | 2007-10-29 10:46:05 -0700 | [diff] [blame] | 160 | const char *name; |
| 161 | const char *err; |
| 162 | int def; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 163 | union { |
| 164 | struct { /* range_option info */ |
| 165 | int min; |
| 166 | int max; |
| 167 | } r; |
| 168 | struct { /* list_option info */ |
| 169 | int nr; |
| 170 | struct e1000_opt_list { int i; char *str; } *p; |
| 171 | } l; |
| 172 | } arg; |
| 173 | }; |
| 174 | |
Bill Pemberton | 9f9a12f | 2012-12-03 09:24:25 -0500 | [diff] [blame] | 175 | static int e1000_validate_option(unsigned int *value, |
Greg Kroah-Hartman | 1dd06ae | 2012-12-06 14:30:56 +0000 | [diff] [blame^] | 176 | const struct e1000_option *opt, |
| 177 | struct e1000_adapter *adapter) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 178 | { |
| 179 | if (*value == OPTION_UNSET) { |
| 180 | *value = opt->def; |
| 181 | return 0; |
| 182 | } |
| 183 | |
| 184 | switch (opt->type) { |
| 185 | case enable_option: |
| 186 | switch (*value) { |
| 187 | case OPTION_ENABLED: |
Bruce Allan | 185095f | 2012-06-07 02:23:37 +0000 | [diff] [blame] | 188 | dev_info(&adapter->pdev->dev, "%s Enabled\n", |
| 189 | opt->name); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 190 | return 0; |
| 191 | case OPTION_DISABLED: |
Bruce Allan | 185095f | 2012-06-07 02:23:37 +0000 | [diff] [blame] | 192 | dev_info(&adapter->pdev->dev, "%s Disabled\n", |
| 193 | opt->name); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 194 | return 0; |
| 195 | } |
| 196 | break; |
| 197 | case range_option: |
| 198 | if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) { |
Bruce Allan | 185095f | 2012-06-07 02:23:37 +0000 | [diff] [blame] | 199 | dev_info(&adapter->pdev->dev, "%s set to %i\n", |
| 200 | opt->name, *value); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 201 | return 0; |
| 202 | } |
| 203 | break; |
| 204 | case list_option: { |
| 205 | int i; |
| 206 | struct e1000_opt_list *ent; |
| 207 | |
| 208 | for (i = 0; i < opt->arg.l.nr; i++) { |
| 209 | ent = &opt->arg.l.p[i]; |
| 210 | if (*value == ent->i) { |
| 211 | if (ent->str[0] != '\0') |
Bruce Allan | 185095f | 2012-06-07 02:23:37 +0000 | [diff] [blame] | 212 | dev_info(&adapter->pdev->dev, "%s\n", |
| 213 | ent->str); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 214 | return 0; |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | break; |
| 219 | default: |
| 220 | BUG(); |
| 221 | } |
| 222 | |
Bruce Allan | 185095f | 2012-06-07 02:23:37 +0000 | [diff] [blame] | 223 | dev_info(&adapter->pdev->dev, "Invalid %s value specified (%i) %s\n", |
| 224 | opt->name, *value, opt->err); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 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 | **/ |
Bill Pemberton | 9f9a12f | 2012-12-03 09:24:25 -0500 | [diff] [blame] | 238 | void e1000e_check_options(struct e1000_adapter *adapter) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 239 | { |
| 240 | struct e1000_hw *hw = &adapter->hw; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 241 | int bd = adapter->bd_number; |
| 242 | |
| 243 | if (bd >= E1000_MAX_NIC) { |
Bruce Allan | 185095f | 2012-06-07 02:23:37 +0000 | [diff] [blame] | 244 | dev_notice(&adapter->pdev->dev, |
| 245 | "Warning: no configuration for board #%i\n", bd); |
| 246 | dev_notice(&adapter->pdev->dev, |
| 247 | "Using defaults for all values\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | { /* Transmit Interrupt Delay */ |
Jesse Brandeburg | 6f59d66 | 2010-04-09 10:51:09 +0000 | [diff] [blame] | 251 | static const struct e1000_option opt = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 252 | .type = range_option, |
| 253 | .name = "Transmit Interrupt Delay", |
| 254 | .err = "using default of " |
| 255 | __MODULE_STRING(DEFAULT_TIDV), |
| 256 | .def = DEFAULT_TIDV, |
| 257 | .arg = { .r = { .min = MIN_TXDELAY, |
| 258 | .max = MAX_TXDELAY } } |
| 259 | }; |
| 260 | |
| 261 | if (num_TxIntDelay > bd) { |
| 262 | adapter->tx_int_delay = TxIntDelay[bd]; |
| 263 | e1000_validate_option(&adapter->tx_int_delay, &opt, |
| 264 | adapter); |
| 265 | } else { |
| 266 | adapter->tx_int_delay = opt.def; |
| 267 | } |
| 268 | } |
| 269 | { /* Transmit Absolute Interrupt Delay */ |
Jesse Brandeburg | 6f59d66 | 2010-04-09 10:51:09 +0000 | [diff] [blame] | 270 | static const struct e1000_option opt = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 271 | .type = range_option, |
| 272 | .name = "Transmit Absolute Interrupt Delay", |
| 273 | .err = "using default of " |
| 274 | __MODULE_STRING(DEFAULT_TADV), |
| 275 | .def = DEFAULT_TADV, |
| 276 | .arg = { .r = { .min = MIN_TXABSDELAY, |
| 277 | .max = MAX_TXABSDELAY } } |
| 278 | }; |
| 279 | |
| 280 | if (num_TxAbsIntDelay > bd) { |
| 281 | adapter->tx_abs_int_delay = TxAbsIntDelay[bd]; |
| 282 | e1000_validate_option(&adapter->tx_abs_int_delay, &opt, |
| 283 | adapter); |
| 284 | } else { |
| 285 | adapter->tx_abs_int_delay = opt.def; |
| 286 | } |
| 287 | } |
| 288 | { /* Receive Interrupt Delay */ |
Bruce Allan | 4fe4491 | 2010-05-10 14:59:10 +0000 | [diff] [blame] | 289 | static struct e1000_option opt = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 290 | .type = range_option, |
| 291 | .name = "Receive Interrupt Delay", |
| 292 | .err = "using default of " |
| 293 | __MODULE_STRING(DEFAULT_RDTR), |
| 294 | .def = DEFAULT_RDTR, |
| 295 | .arg = { .r = { .min = MIN_RXDELAY, |
| 296 | .max = MAX_RXDELAY } } |
| 297 | }; |
| 298 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 299 | if (num_RxIntDelay > bd) { |
| 300 | adapter->rx_int_delay = RxIntDelay[bd]; |
| 301 | e1000_validate_option(&adapter->rx_int_delay, &opt, |
| 302 | adapter); |
| 303 | } else { |
| 304 | adapter->rx_int_delay = opt.def; |
| 305 | } |
| 306 | } |
| 307 | { /* Receive Absolute Interrupt Delay */ |
Jesse Brandeburg | 6f59d66 | 2010-04-09 10:51:09 +0000 | [diff] [blame] | 308 | static const struct e1000_option opt = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 309 | .type = range_option, |
| 310 | .name = "Receive Absolute Interrupt Delay", |
| 311 | .err = "using default of " |
| 312 | __MODULE_STRING(DEFAULT_RADV), |
| 313 | .def = DEFAULT_RADV, |
| 314 | .arg = { .r = { .min = MIN_RXABSDELAY, |
| 315 | .max = MAX_RXABSDELAY } } |
| 316 | }; |
| 317 | |
| 318 | if (num_RxAbsIntDelay > bd) { |
| 319 | adapter->rx_abs_int_delay = RxAbsIntDelay[bd]; |
| 320 | e1000_validate_option(&adapter->rx_abs_int_delay, &opt, |
| 321 | adapter); |
| 322 | } else { |
| 323 | adapter->rx_abs_int_delay = opt.def; |
| 324 | } |
| 325 | } |
| 326 | { /* Interrupt Throttling Rate */ |
Jesse Brandeburg | 6f59d66 | 2010-04-09 10:51:09 +0000 | [diff] [blame] | 327 | static const struct e1000_option opt = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 328 | .type = range_option, |
| 329 | .name = "Interrupt Throttling Rate (ints/sec)", |
| 330 | .err = "using default of " |
| 331 | __MODULE_STRING(DEFAULT_ITR), |
| 332 | .def = DEFAULT_ITR, |
| 333 | .arg = { .r = { .min = MIN_ITR, |
| 334 | .max = MAX_ITR } } |
| 335 | }; |
| 336 | |
| 337 | if (num_InterruptThrottleRate > bd) { |
| 338 | adapter->itr = InterruptThrottleRate[bd]; |
Jeff Kirsher | 2e7d21c | 2012-05-09 02:23:46 -0700 | [diff] [blame] | 339 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 340 | /* Make sure a message is printed for non-special |
Jeff Kirsher | 2e7d21c | 2012-05-09 02:23:46 -0700 | [diff] [blame] | 341 | * values. And in case of an invalid option, display |
| 342 | * warning, use default and go through itr/itr_setting |
| 343 | * adjustment logic below |
| 344 | */ |
| 345 | if ((adapter->itr > 4) && |
| 346 | e1000_validate_option(&adapter->itr, &opt, adapter)) |
| 347 | adapter->itr = opt.def; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 348 | } else { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 349 | /* If no option specified, use default value and go |
Jeff Kirsher | 727c356 | 2012-04-20 08:51:45 +0000 | [diff] [blame] | 350 | * through the logic below to adjust itr/itr_setting |
| 351 | */ |
| 352 | adapter->itr = opt.def; |
| 353 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 354 | /* Make sure a message is printed for non-special |
Jeff Kirsher | 727c356 | 2012-04-20 08:51:45 +0000 | [diff] [blame] | 355 | * default values |
| 356 | */ |
Jeff Kirsher | 2e7d21c | 2012-05-09 02:23:46 -0700 | [diff] [blame] | 357 | if (adapter->itr > 4) |
Bruce Allan | 185095f | 2012-06-07 02:23:37 +0000 | [diff] [blame] | 358 | dev_info(&adapter->pdev->dev, |
| 359 | "%s set to default %d\n", opt.name, |
| 360 | adapter->itr); |
Jeff Kirsher | 727c356 | 2012-04-20 08:51:45 +0000 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | adapter->itr_setting = adapter->itr; |
| 364 | switch (adapter->itr) { |
| 365 | case 0: |
Bruce Allan | 185095f | 2012-06-07 02:23:37 +0000 | [diff] [blame] | 366 | dev_info(&adapter->pdev->dev, "%s turned off\n", |
| 367 | opt.name); |
Jeff Kirsher | 727c356 | 2012-04-20 08:51:45 +0000 | [diff] [blame] | 368 | break; |
| 369 | case 1: |
Bruce Allan | 185095f | 2012-06-07 02:23:37 +0000 | [diff] [blame] | 370 | dev_info(&adapter->pdev->dev, |
| 371 | "%s set to dynamic mode\n", opt.name); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 372 | adapter->itr = 20000; |
Jeff Kirsher | 727c356 | 2012-04-20 08:51:45 +0000 | [diff] [blame] | 373 | break; |
| 374 | case 3: |
Bruce Allan | 185095f | 2012-06-07 02:23:37 +0000 | [diff] [blame] | 375 | dev_info(&adapter->pdev->dev, |
| 376 | "%s set to dynamic conservative mode\n", |
| 377 | opt.name); |
Jeff Kirsher | 727c356 | 2012-04-20 08:51:45 +0000 | [diff] [blame] | 378 | adapter->itr = 20000; |
| 379 | break; |
| 380 | case 4: |
Bruce Allan | 185095f | 2012-06-07 02:23:37 +0000 | [diff] [blame] | 381 | dev_info(&adapter->pdev->dev, |
| 382 | "%s set to simplified (2000-8000 ints) mode\n", |
| 383 | opt.name); |
Jeff Kirsher | 727c356 | 2012-04-20 08:51:45 +0000 | [diff] [blame] | 384 | break; |
| 385 | default: |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 386 | /* Save the setting, because the dynamic bits |
Jeff Kirsher | 727c356 | 2012-04-20 08:51:45 +0000 | [diff] [blame] | 387 | * change itr. |
| 388 | * |
| 389 | * Clear the lower two bits because |
| 390 | * they are used as control. |
| 391 | */ |
| 392 | adapter->itr_setting &= ~3; |
| 393 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 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); |
Ben Greear | 0184039 | 2012-02-11 15:39:25 +0000 | [diff] [blame] | 466 | if (crc_stripping == OPTION_ENABLED) { |
Jeff Kirsher | eb7c3ad | 2008-11-14 06:45:23 +0000 | [diff] [blame] | 467 | adapter->flags2 |= FLAG2_CRC_STRIPPING; |
Ben Greear | 0184039 | 2012-02-11 15:39:25 +0000 | [diff] [blame] | 468 | adapter->flags2 |= FLAG2_DFLT_CRC_STRIPPING; |
| 469 | } |
Bruce Allan | 6e50912a | 2009-06-02 11:28:01 +0000 | [diff] [blame] | 470 | } else { |
| 471 | adapter->flags2 |= FLAG2_CRC_STRIPPING; |
Ben Greear | 0184039 | 2012-02-11 15:39:25 +0000 | [diff] [blame] | 472 | adapter->flags2 |= FLAG2_DFLT_CRC_STRIPPING; |
Jeff Kirsher | eb7c3ad | 2008-11-14 06:45:23 +0000 | [diff] [blame] | 473 | } |
| 474 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 475 | { /* Kumeran Lock Loss Workaround */ |
Jesse Brandeburg | 6f59d66 | 2010-04-09 10:51:09 +0000 | [diff] [blame] | 476 | static const struct e1000_option opt = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 477 | .type = enable_option, |
| 478 | .name = "Kumeran Lock Loss Workaround", |
| 479 | .err = "defaulting to Enabled", |
| 480 | .def = OPTION_ENABLED |
| 481 | }; |
| 482 | |
| 483 | if (num_KumeranLockLoss > bd) { |
Stephen Hemminger | 5a9147b | 2007-10-29 10:46:05 -0700 | [diff] [blame] | 484 | unsigned int kmrn_lock_loss = KumeranLockLoss[bd]; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 485 | e1000_validate_option(&kmrn_lock_loss, &opt, adapter); |
| 486 | if (hw->mac.type == e1000_ich8lan) |
| 487 | e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, |
| 488 | kmrn_lock_loss); |
| 489 | } else { |
| 490 | if (hw->mac.type == e1000_ich8lan) |
| 491 | e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, |
| 492 | opt.def); |
| 493 | } |
| 494 | } |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 495 | { /* Write-protect NVM */ |
Jesse Brandeburg | 6f59d66 | 2010-04-09 10:51:09 +0000 | [diff] [blame] | 496 | static const struct e1000_option opt = { |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 497 | .type = enable_option, |
| 498 | .name = "Write-protect NVM", |
| 499 | .err = "defaulting to Enabled", |
| 500 | .def = OPTION_ENABLED |
| 501 | }; |
| 502 | |
| 503 | if (adapter->flags & FLAG_IS_ICH) { |
| 504 | if (num_WriteProtectNVM > bd) { |
| 505 | unsigned int write_protect_nvm = WriteProtectNVM[bd]; |
| 506 | e1000_validate_option(&write_protect_nvm, &opt, |
| 507 | adapter); |
| 508 | if (write_protect_nvm) |
| 509 | adapter->flags |= FLAG_READ_ONLY_NVM; |
| 510 | } else { |
| 511 | if (opt.def) |
| 512 | adapter->flags |= FLAG_READ_ONLY_NVM; |
| 513 | } |
| 514 | } |
| 515 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 516 | } |