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