Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | |
| 3 | |
Malli Chilakala | 2648345 | 2005-04-28 19:44:46 -0700 | [diff] [blame] | 4 | Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | |
| 6 | This program is free software; you can redistribute it and/or modify it |
| 7 | under the terms of the GNU General Public License as published by the Free |
| 8 | Software Foundation; either version 2 of the License, or (at your option) |
| 9 | any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 14 | more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License along with |
| 17 | this program; if not, write to the Free Software Foundation, Inc., 59 |
| 18 | Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 | |
| 20 | The full GNU General Public License is included in this distribution in the |
| 21 | file called LICENSE. |
| 22 | |
| 23 | Contact Information: |
| 24 | Linux NICS <linux.nics@intel.com> |
| 25 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 26 | |
| 27 | *******************************************************************************/ |
| 28 | |
| 29 | #include "e1000.h" |
| 30 | |
| 31 | /* This is the only thing that needs to be changed to adjust the |
| 32 | * maximum number of ports that the driver can manage. |
| 33 | */ |
| 34 | |
| 35 | #define E1000_MAX_NIC 32 |
| 36 | |
| 37 | #define OPTION_UNSET -1 |
| 38 | #define OPTION_DISABLED 0 |
| 39 | #define OPTION_ENABLED 1 |
| 40 | |
| 41 | /* All parameters are treated the same, as an integer array of values. |
| 42 | * This macro just reduces the need to repeat the same declaration code |
| 43 | * over and over (plus this helps to avoid typo bugs). |
| 44 | */ |
| 45 | |
| 46 | #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET } |
| 47 | #define E1000_PARAM(X, desc) \ |
| 48 | static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \ |
| 49 | static int num_##X = 0; \ |
| 50 | module_param_array_named(X, X, int, &num_##X, 0); \ |
| 51 | MODULE_PARM_DESC(X, desc); |
| 52 | |
| 53 | /* Transmit Descriptor Count |
| 54 | * |
| 55 | * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers |
| 56 | * Valid Range: 80-4096 for 82544 and newer |
| 57 | * |
| 58 | * Default Value: 256 |
| 59 | */ |
| 60 | |
| 61 | E1000_PARAM(TxDescriptors, "Number of transmit descriptors"); |
| 62 | |
| 63 | /* Receive Descriptor Count |
| 64 | * |
| 65 | * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers |
| 66 | * Valid Range: 80-4096 for 82544 and newer |
| 67 | * |
| 68 | * Default Value: 256 |
| 69 | */ |
| 70 | |
| 71 | E1000_PARAM(RxDescriptors, "Number of receive descriptors"); |
| 72 | |
| 73 | /* User Specified Speed Override |
| 74 | * |
| 75 | * Valid Range: 0, 10, 100, 1000 |
| 76 | * - 0 - auto-negotiate at all supported speeds |
| 77 | * - 10 - only link at 10 Mbps |
| 78 | * - 100 - only link at 100 Mbps |
| 79 | * - 1000 - only link at 1000 Mbps |
| 80 | * |
| 81 | * Default Value: 0 |
| 82 | */ |
| 83 | |
| 84 | E1000_PARAM(Speed, "Speed setting"); |
| 85 | |
| 86 | /* User Specified Duplex Override |
| 87 | * |
| 88 | * Valid Range: 0-2 |
| 89 | * - 0 - auto-negotiate for duplex |
| 90 | * - 1 - only link at half duplex |
| 91 | * - 2 - only link at full duplex |
| 92 | * |
| 93 | * Default Value: 0 |
| 94 | */ |
| 95 | |
| 96 | E1000_PARAM(Duplex, "Duplex setting"); |
| 97 | |
| 98 | /* Auto-negotiation Advertisement Override |
| 99 | * |
| 100 | * Valid Range: 0x01-0x0F, 0x20-0x2F (copper); 0x20 (fiber) |
| 101 | * |
| 102 | * The AutoNeg value is a bit mask describing which speed and duplex |
| 103 | * combinations should be advertised during auto-negotiation. |
| 104 | * The supported speed and duplex modes are listed below |
| 105 | * |
| 106 | * Bit 7 6 5 4 3 2 1 0 |
| 107 | * Speed (Mbps) N/A N/A 1000 N/A 100 100 10 10 |
| 108 | * Duplex Full Full Half Full Half |
| 109 | * |
| 110 | * Default Value: 0x2F (copper); 0x20 (fiber) |
| 111 | */ |
| 112 | |
| 113 | E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting"); |
| 114 | |
| 115 | /* User Specified Flow Control Override |
| 116 | * |
| 117 | * Valid Range: 0-3 |
| 118 | * - 0 - No Flow Control |
| 119 | * - 1 - Rx only, respond to PAUSE frames but do not generate them |
| 120 | * - 2 - Tx only, generate PAUSE frames but ignore them on receive |
| 121 | * - 3 - Full Flow Control Support |
| 122 | * |
| 123 | * Default Value: Read flow control settings from the EEPROM |
| 124 | */ |
| 125 | |
| 126 | E1000_PARAM(FlowControl, "Flow Control setting"); |
| 127 | |
| 128 | /* XsumRX - Receive Checksum Offload Enable/Disable |
| 129 | * |
| 130 | * Valid Range: 0, 1 |
| 131 | * - 0 - disables all checksum offload |
| 132 | * - 1 - enables receive IP/TCP/UDP checksum offload |
| 133 | * on 82543 and newer -based NICs |
| 134 | * |
| 135 | * Default Value: 1 |
| 136 | */ |
| 137 | |
| 138 | E1000_PARAM(XsumRX, "Disable or enable Receive Checksum offload"); |
| 139 | |
| 140 | /* Transmit Interrupt Delay in units of 1.024 microseconds |
| 141 | * |
| 142 | * Valid Range: 0-65535 |
| 143 | * |
| 144 | * Default Value: 64 |
| 145 | */ |
| 146 | |
| 147 | E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay"); |
| 148 | |
| 149 | /* Transmit Absolute Interrupt Delay in units of 1.024 microseconds |
| 150 | * |
| 151 | * Valid Range: 0-65535 |
| 152 | * |
| 153 | * Default Value: 0 |
| 154 | */ |
| 155 | |
| 156 | E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay"); |
| 157 | |
| 158 | /* Receive Interrupt Delay in units of 1.024 microseconds |
| 159 | * |
| 160 | * Valid Range: 0-65535 |
| 161 | * |
| 162 | * Default Value: 0 |
| 163 | */ |
| 164 | |
| 165 | E1000_PARAM(RxIntDelay, "Receive Interrupt Delay"); |
| 166 | |
| 167 | /* Receive Absolute Interrupt Delay in units of 1.024 microseconds |
| 168 | * |
| 169 | * Valid Range: 0-65535 |
| 170 | * |
| 171 | * Default Value: 128 |
| 172 | */ |
| 173 | |
| 174 | E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay"); |
| 175 | |
| 176 | /* Interrupt Throttle Rate (interrupts/sec) |
| 177 | * |
| 178 | * Valid Range: 100-100000 (0=off, 1=dynamic) |
| 179 | * |
| 180 | * Default Value: 1 |
| 181 | */ |
| 182 | |
| 183 | E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate"); |
| 184 | |
| 185 | #define AUTONEG_ADV_DEFAULT 0x2F |
| 186 | #define AUTONEG_ADV_MASK 0x2F |
| 187 | #define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL |
| 188 | |
| 189 | #define DEFAULT_RDTR 0 |
| 190 | #define MAX_RXDELAY 0xFFFF |
| 191 | #define MIN_RXDELAY 0 |
| 192 | |
| 193 | #define DEFAULT_RADV 128 |
| 194 | #define MAX_RXABSDELAY 0xFFFF |
| 195 | #define MIN_RXABSDELAY 0 |
| 196 | |
| 197 | #define DEFAULT_TIDV 64 |
| 198 | #define MAX_TXDELAY 0xFFFF |
| 199 | #define MIN_TXDELAY 0 |
| 200 | |
| 201 | #define DEFAULT_TADV 64 |
| 202 | #define MAX_TXABSDELAY 0xFFFF |
| 203 | #define MIN_TXABSDELAY 0 |
| 204 | |
| 205 | #define DEFAULT_ITR 8000 |
| 206 | #define MAX_ITR 100000 |
| 207 | #define MIN_ITR 100 |
| 208 | |
| 209 | struct e1000_option { |
| 210 | enum { enable_option, range_option, list_option } type; |
| 211 | char *name; |
| 212 | char *err; |
| 213 | int def; |
| 214 | union { |
| 215 | struct { /* range_option info */ |
| 216 | int min; |
| 217 | int max; |
| 218 | } r; |
| 219 | struct { /* list_option info */ |
| 220 | int nr; |
| 221 | struct e1000_opt_list { int i; char *str; } *p; |
| 222 | } l; |
| 223 | } arg; |
| 224 | }; |
| 225 | |
| 226 | static int __devinit |
| 227 | e1000_validate_option(int *value, struct e1000_option *opt, |
| 228 | struct e1000_adapter *adapter) |
| 229 | { |
| 230 | if(*value == OPTION_UNSET) { |
| 231 | *value = opt->def; |
| 232 | return 0; |
| 233 | } |
| 234 | |
| 235 | switch (opt->type) { |
| 236 | case enable_option: |
| 237 | switch (*value) { |
| 238 | case OPTION_ENABLED: |
| 239 | DPRINTK(PROBE, INFO, "%s Enabled\n", opt->name); |
| 240 | return 0; |
| 241 | case OPTION_DISABLED: |
| 242 | DPRINTK(PROBE, INFO, "%s Disabled\n", opt->name); |
| 243 | return 0; |
| 244 | } |
| 245 | break; |
| 246 | case range_option: |
| 247 | if(*value >= opt->arg.r.min && *value <= opt->arg.r.max) { |
| 248 | DPRINTK(PROBE, INFO, |
| 249 | "%s set to %i\n", opt->name, *value); |
| 250 | return 0; |
| 251 | } |
| 252 | break; |
| 253 | case list_option: { |
| 254 | int i; |
| 255 | struct e1000_opt_list *ent; |
| 256 | |
| 257 | for(i = 0; i < opt->arg.l.nr; i++) { |
| 258 | ent = &opt->arg.l.p[i]; |
| 259 | if(*value == ent->i) { |
| 260 | if(ent->str[0] != '\0') |
| 261 | DPRINTK(PROBE, INFO, "%s\n", ent->str); |
| 262 | return 0; |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | break; |
| 267 | default: |
| 268 | BUG(); |
| 269 | } |
| 270 | |
| 271 | DPRINTK(PROBE, INFO, "Invalid %s specified (%i) %s\n", |
| 272 | opt->name, *value, opt->err); |
| 273 | *value = opt->def; |
| 274 | return -1; |
| 275 | } |
| 276 | |
| 277 | static void e1000_check_fiber_options(struct e1000_adapter *adapter); |
| 278 | static void e1000_check_copper_options(struct e1000_adapter *adapter); |
| 279 | |
| 280 | /** |
| 281 | * e1000_check_options - Range Checking for Command Line Parameters |
| 282 | * @adapter: board private structure |
| 283 | * |
| 284 | * This routine checks all command line parameters for valid user |
| 285 | * input. If an invalid value is given, or if no user specified |
| 286 | * value exists, a default value is used. The final value is stored |
| 287 | * in a variable in the adapter structure. |
| 288 | **/ |
| 289 | |
| 290 | void __devinit |
| 291 | e1000_check_options(struct e1000_adapter *adapter) |
| 292 | { |
| 293 | int bd = adapter->bd_number; |
| 294 | if(bd >= E1000_MAX_NIC) { |
| 295 | DPRINTK(PROBE, NOTICE, |
| 296 | "Warning: no configuration for board #%i\n", bd); |
| 297 | DPRINTK(PROBE, NOTICE, "Using defaults for all values\n"); |
| 298 | } |
| 299 | |
| 300 | { /* Transmit Descriptor Count */ |
| 301 | struct e1000_option opt = { |
| 302 | .type = range_option, |
| 303 | .name = "Transmit Descriptors", |
| 304 | .err = "using default of " |
| 305 | __MODULE_STRING(E1000_DEFAULT_TXD), |
| 306 | .def = E1000_DEFAULT_TXD, |
| 307 | .arg = { .r = { .min = E1000_MIN_TXD }} |
| 308 | }; |
Mallikarjuna R Chilakala | 581d708 | 2005-10-04 07:01:55 -0400 | [diff] [blame] | 309 | struct e1000_tx_ring *tx_ring = adapter->tx_ring; |
| 310 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | e1000_mac_type mac_type = adapter->hw.mac_type; |
| 312 | opt.arg.r.max = mac_type < e1000_82544 ? |
| 313 | E1000_MAX_TXD : E1000_MAX_82544_TXD; |
| 314 | |
| 315 | if (num_TxDescriptors > bd) { |
| 316 | tx_ring->count = TxDescriptors[bd]; |
| 317 | e1000_validate_option(&tx_ring->count, &opt, adapter); |
| 318 | E1000_ROUNDUP(tx_ring->count, |
| 319 | REQ_TX_DESCRIPTOR_MULTIPLE); |
| 320 | } else { |
| 321 | tx_ring->count = opt.def; |
| 322 | } |
Mallikarjuna R Chilakala | 581d708 | 2005-10-04 07:01:55 -0400 | [diff] [blame] | 323 | for (i = 0; i < adapter->num_queues; i++) |
| 324 | tx_ring[i].count = tx_ring->count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | } |
| 326 | { /* Receive Descriptor Count */ |
| 327 | struct e1000_option opt = { |
| 328 | .type = range_option, |
| 329 | .name = "Receive Descriptors", |
| 330 | .err = "using default of " |
| 331 | __MODULE_STRING(E1000_DEFAULT_RXD), |
| 332 | .def = E1000_DEFAULT_RXD, |
| 333 | .arg = { .r = { .min = E1000_MIN_RXD }} |
| 334 | }; |
Mallikarjuna R Chilakala | 581d708 | 2005-10-04 07:01:55 -0400 | [diff] [blame] | 335 | struct e1000_rx_ring *rx_ring = adapter->rx_ring; |
| 336 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | e1000_mac_type mac_type = adapter->hw.mac_type; |
| 338 | opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD : |
| 339 | E1000_MAX_82544_RXD; |
| 340 | |
| 341 | if (num_RxDescriptors > bd) { |
| 342 | rx_ring->count = RxDescriptors[bd]; |
| 343 | e1000_validate_option(&rx_ring->count, &opt, adapter); |
| 344 | E1000_ROUNDUP(rx_ring->count, |
| 345 | REQ_RX_DESCRIPTOR_MULTIPLE); |
| 346 | } else { |
| 347 | rx_ring->count = opt.def; |
| 348 | } |
Mallikarjuna R Chilakala | 581d708 | 2005-10-04 07:01:55 -0400 | [diff] [blame] | 349 | for (i = 0; i < adapter->num_queues; i++) |
| 350 | rx_ring[i].count = rx_ring->count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | } |
| 352 | { /* Checksum Offload Enable/Disable */ |
| 353 | struct e1000_option opt = { |
| 354 | .type = enable_option, |
| 355 | .name = "Checksum Offload", |
| 356 | .err = "defaulting to Enabled", |
| 357 | .def = OPTION_ENABLED |
| 358 | }; |
| 359 | |
| 360 | if (num_XsumRX > bd) { |
| 361 | int rx_csum = XsumRX[bd]; |
| 362 | e1000_validate_option(&rx_csum, &opt, adapter); |
| 363 | adapter->rx_csum = rx_csum; |
| 364 | } else { |
| 365 | adapter->rx_csum = opt.def; |
| 366 | } |
| 367 | } |
| 368 | { /* Flow Control */ |
| 369 | |
| 370 | struct e1000_opt_list fc_list[] = |
| 371 | {{ e1000_fc_none, "Flow Control Disabled" }, |
| 372 | { e1000_fc_rx_pause,"Flow Control Receive Only" }, |
| 373 | { e1000_fc_tx_pause,"Flow Control Transmit Only" }, |
| 374 | { e1000_fc_full, "Flow Control Enabled" }, |
| 375 | { e1000_fc_default, "Flow Control Hardware Default" }}; |
| 376 | |
| 377 | struct e1000_option opt = { |
| 378 | .type = list_option, |
| 379 | .name = "Flow Control", |
| 380 | .err = "reading default settings from EEPROM", |
| 381 | .def = e1000_fc_default, |
| 382 | .arg = { .l = { .nr = ARRAY_SIZE(fc_list), |
| 383 | .p = fc_list }} |
| 384 | }; |
| 385 | |
| 386 | if (num_FlowControl > bd) { |
| 387 | int fc = FlowControl[bd]; |
| 388 | e1000_validate_option(&fc, &opt, adapter); |
| 389 | adapter->hw.fc = adapter->hw.original_fc = fc; |
| 390 | } else { |
| 391 | adapter->hw.fc = opt.def; |
| 392 | } |
| 393 | } |
| 394 | { /* Transmit Interrupt Delay */ |
| 395 | struct e1000_option opt = { |
| 396 | .type = range_option, |
| 397 | .name = "Transmit Interrupt Delay", |
| 398 | .err = "using default of " __MODULE_STRING(DEFAULT_TIDV), |
| 399 | .def = DEFAULT_TIDV, |
| 400 | .arg = { .r = { .min = MIN_TXDELAY, |
| 401 | .max = MAX_TXDELAY }} |
| 402 | }; |
| 403 | |
| 404 | if (num_TxIntDelay > bd) { |
| 405 | adapter->tx_int_delay = TxIntDelay[bd]; |
| 406 | e1000_validate_option(&adapter->tx_int_delay, &opt, |
| 407 | adapter); |
| 408 | } else { |
| 409 | adapter->tx_int_delay = opt.def; |
| 410 | } |
| 411 | } |
| 412 | { /* Transmit Absolute Interrupt Delay */ |
| 413 | struct e1000_option opt = { |
| 414 | .type = range_option, |
| 415 | .name = "Transmit Absolute Interrupt Delay", |
| 416 | .err = "using default of " __MODULE_STRING(DEFAULT_TADV), |
| 417 | .def = DEFAULT_TADV, |
| 418 | .arg = { .r = { .min = MIN_TXABSDELAY, |
| 419 | .max = MAX_TXABSDELAY }} |
| 420 | }; |
| 421 | |
| 422 | if (num_TxAbsIntDelay > bd) { |
| 423 | adapter->tx_abs_int_delay = TxAbsIntDelay[bd]; |
| 424 | e1000_validate_option(&adapter->tx_abs_int_delay, &opt, |
| 425 | adapter); |
| 426 | } else { |
| 427 | adapter->tx_abs_int_delay = opt.def; |
| 428 | } |
| 429 | } |
| 430 | { /* Receive Interrupt Delay */ |
| 431 | struct e1000_option opt = { |
| 432 | .type = range_option, |
| 433 | .name = "Receive Interrupt Delay", |
| 434 | .err = "using default of " __MODULE_STRING(DEFAULT_RDTR), |
| 435 | .def = DEFAULT_RDTR, |
| 436 | .arg = { .r = { .min = MIN_RXDELAY, |
| 437 | .max = MAX_RXDELAY }} |
| 438 | }; |
| 439 | |
| 440 | if (num_RxIntDelay > bd) { |
| 441 | adapter->rx_int_delay = RxIntDelay[bd]; |
| 442 | e1000_validate_option(&adapter->rx_int_delay, &opt, |
| 443 | adapter); |
| 444 | } else { |
| 445 | adapter->rx_int_delay = opt.def; |
| 446 | } |
| 447 | } |
| 448 | { /* Receive Absolute Interrupt Delay */ |
| 449 | struct e1000_option opt = { |
| 450 | .type = range_option, |
| 451 | .name = "Receive Absolute Interrupt Delay", |
| 452 | .err = "using default of " __MODULE_STRING(DEFAULT_RADV), |
| 453 | .def = DEFAULT_RADV, |
| 454 | .arg = { .r = { .min = MIN_RXABSDELAY, |
| 455 | .max = MAX_RXABSDELAY }} |
| 456 | }; |
| 457 | |
| 458 | if (num_RxAbsIntDelay > bd) { |
| 459 | adapter->rx_abs_int_delay = RxAbsIntDelay[bd]; |
| 460 | e1000_validate_option(&adapter->rx_abs_int_delay, &opt, |
| 461 | adapter); |
| 462 | } else { |
| 463 | adapter->rx_abs_int_delay = opt.def; |
| 464 | } |
| 465 | } |
| 466 | { /* Interrupt Throttling Rate */ |
| 467 | struct e1000_option opt = { |
| 468 | .type = range_option, |
| 469 | .name = "Interrupt Throttling Rate (ints/sec)", |
| 470 | .err = "using default of " __MODULE_STRING(DEFAULT_ITR), |
| 471 | .def = DEFAULT_ITR, |
| 472 | .arg = { .r = { .min = MIN_ITR, |
| 473 | .max = MAX_ITR }} |
| 474 | }; |
| 475 | |
| 476 | if (num_InterruptThrottleRate > bd) { |
| 477 | adapter->itr = InterruptThrottleRate[bd]; |
| 478 | switch(adapter->itr) { |
| 479 | case 0: |
| 480 | DPRINTK(PROBE, INFO, "%s turned off\n", |
| 481 | opt.name); |
| 482 | break; |
| 483 | case 1: |
| 484 | DPRINTK(PROBE, INFO, "%s set to dynamic mode\n", |
| 485 | opt.name); |
| 486 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | default: |
| 488 | e1000_validate_option(&adapter->itr, &opt, |
| 489 | adapter); |
| 490 | break; |
| 491 | } |
| 492 | } else { |
| 493 | adapter->itr = opt.def; |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | switch(adapter->hw.media_type) { |
| 498 | case e1000_media_type_fiber: |
| 499 | case e1000_media_type_internal_serdes: |
| 500 | e1000_check_fiber_options(adapter); |
| 501 | break; |
| 502 | case e1000_media_type_copper: |
| 503 | e1000_check_copper_options(adapter); |
| 504 | break; |
| 505 | default: |
| 506 | BUG(); |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | /** |
| 511 | * e1000_check_fiber_options - Range Checking for Link Options, Fiber Version |
| 512 | * @adapter: board private structure |
| 513 | * |
| 514 | * Handles speed and duplex options on fiber adapters |
| 515 | **/ |
| 516 | |
| 517 | static void __devinit |
| 518 | e1000_check_fiber_options(struct e1000_adapter *adapter) |
| 519 | { |
| 520 | int bd = adapter->bd_number; |
| 521 | if(num_Speed > bd) { |
| 522 | DPRINTK(PROBE, INFO, "Speed not valid for fiber adapters, " |
| 523 | "parameter ignored\n"); |
| 524 | } |
| 525 | |
| 526 | if(num_Duplex > bd) { |
| 527 | DPRINTK(PROBE, INFO, "Duplex not valid for fiber adapters, " |
| 528 | "parameter ignored\n"); |
| 529 | } |
| 530 | |
| 531 | if((num_AutoNeg > bd) && (AutoNeg[bd] != 0x20)) { |
| 532 | DPRINTK(PROBE, INFO, "AutoNeg other than 1000/Full is " |
| 533 | "not valid for fiber adapters, " |
| 534 | "parameter ignored\n"); |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | /** |
| 539 | * e1000_check_copper_options - Range Checking for Link Options, Copper Version |
| 540 | * @adapter: board private structure |
| 541 | * |
| 542 | * Handles speed and duplex options on copper adapters |
| 543 | **/ |
| 544 | |
| 545 | static void __devinit |
| 546 | e1000_check_copper_options(struct e1000_adapter *adapter) |
| 547 | { |
Kenji Kaneshige | 32a4ec9 | 2006-01-05 22:45:44 -0800 | [diff] [blame] | 548 | int speed, dplx, an; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | int bd = adapter->bd_number; |
| 550 | |
| 551 | { /* Speed */ |
| 552 | struct e1000_opt_list speed_list[] = {{ 0, "" }, |
| 553 | { SPEED_10, "" }, |
| 554 | { SPEED_100, "" }, |
| 555 | { SPEED_1000, "" }}; |
| 556 | |
| 557 | struct e1000_option opt = { |
| 558 | .type = list_option, |
| 559 | .name = "Speed", |
| 560 | .err = "parameter ignored", |
| 561 | .def = 0, |
| 562 | .arg = { .l = { .nr = ARRAY_SIZE(speed_list), |
| 563 | .p = speed_list }} |
| 564 | }; |
| 565 | |
| 566 | if (num_Speed > bd) { |
| 567 | speed = Speed[bd]; |
| 568 | e1000_validate_option(&speed, &opt, adapter); |
| 569 | } else { |
| 570 | speed = opt.def; |
| 571 | } |
| 572 | } |
| 573 | { /* Duplex */ |
| 574 | struct e1000_opt_list dplx_list[] = {{ 0, "" }, |
| 575 | { HALF_DUPLEX, "" }, |
| 576 | { FULL_DUPLEX, "" }}; |
| 577 | |
| 578 | struct e1000_option opt = { |
| 579 | .type = list_option, |
| 580 | .name = "Duplex", |
| 581 | .err = "parameter ignored", |
| 582 | .def = 0, |
| 583 | .arg = { .l = { .nr = ARRAY_SIZE(dplx_list), |
| 584 | .p = dplx_list }} |
| 585 | }; |
| 586 | |
| 587 | if (num_Duplex > bd) { |
| 588 | dplx = Duplex[bd]; |
| 589 | e1000_validate_option(&dplx, &opt, adapter); |
| 590 | } else { |
| 591 | dplx = opt.def; |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | if((num_AutoNeg > bd) && (speed != 0 || dplx != 0)) { |
| 596 | DPRINTK(PROBE, INFO, |
| 597 | "AutoNeg specified along with Speed or Duplex, " |
| 598 | "parameter ignored\n"); |
| 599 | adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT; |
| 600 | } else { /* Autoneg */ |
| 601 | struct e1000_opt_list an_list[] = |
| 602 | #define AA "AutoNeg advertising " |
| 603 | {{ 0x01, AA "10/HD" }, |
| 604 | { 0x02, AA "10/FD" }, |
| 605 | { 0x03, AA "10/FD, 10/HD" }, |
| 606 | { 0x04, AA "100/HD" }, |
| 607 | { 0x05, AA "100/HD, 10/HD" }, |
| 608 | { 0x06, AA "100/HD, 10/FD" }, |
| 609 | { 0x07, AA "100/HD, 10/FD, 10/HD" }, |
| 610 | { 0x08, AA "100/FD" }, |
| 611 | { 0x09, AA "100/FD, 10/HD" }, |
| 612 | { 0x0a, AA "100/FD, 10/FD" }, |
| 613 | { 0x0b, AA "100/FD, 10/FD, 10/HD" }, |
| 614 | { 0x0c, AA "100/FD, 100/HD" }, |
| 615 | { 0x0d, AA "100/FD, 100/HD, 10/HD" }, |
| 616 | { 0x0e, AA "100/FD, 100/HD, 10/FD" }, |
| 617 | { 0x0f, AA "100/FD, 100/HD, 10/FD, 10/HD" }, |
| 618 | { 0x20, AA "1000/FD" }, |
| 619 | { 0x21, AA "1000/FD, 10/HD" }, |
| 620 | { 0x22, AA "1000/FD, 10/FD" }, |
| 621 | { 0x23, AA "1000/FD, 10/FD, 10/HD" }, |
| 622 | { 0x24, AA "1000/FD, 100/HD" }, |
| 623 | { 0x25, AA "1000/FD, 100/HD, 10/HD" }, |
| 624 | { 0x26, AA "1000/FD, 100/HD, 10/FD" }, |
| 625 | { 0x27, AA "1000/FD, 100/HD, 10/FD, 10/HD" }, |
| 626 | { 0x28, AA "1000/FD, 100/FD" }, |
| 627 | { 0x29, AA "1000/FD, 100/FD, 10/HD" }, |
| 628 | { 0x2a, AA "1000/FD, 100/FD, 10/FD" }, |
| 629 | { 0x2b, AA "1000/FD, 100/FD, 10/FD, 10/HD" }, |
| 630 | { 0x2c, AA "1000/FD, 100/FD, 100/HD" }, |
| 631 | { 0x2d, AA "1000/FD, 100/FD, 100/HD, 10/HD" }, |
| 632 | { 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" }, |
| 633 | { 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }}; |
| 634 | |
| 635 | struct e1000_option opt = { |
| 636 | .type = list_option, |
| 637 | .name = "AutoNeg", |
| 638 | .err = "parameter ignored", |
| 639 | .def = AUTONEG_ADV_DEFAULT, |
| 640 | .arg = { .l = { .nr = ARRAY_SIZE(an_list), |
| 641 | .p = an_list }} |
| 642 | }; |
| 643 | |
Kenji Kaneshige | 32a4ec9 | 2006-01-05 22:45:44 -0800 | [diff] [blame] | 644 | if (num_AutoNeg > bd) { |
| 645 | an = AutoNeg[bd]; |
| 646 | e1000_validate_option(&an, &opt, adapter); |
| 647 | } else { |
| 648 | an = opt.def; |
| 649 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | adapter->hw.autoneg_advertised = an; |
| 651 | } |
| 652 | |
| 653 | switch (speed + dplx) { |
| 654 | case 0: |
| 655 | adapter->hw.autoneg = adapter->fc_autoneg = 1; |
| 656 | if((num_Speed > bd) && (speed != 0 || dplx != 0)) |
| 657 | DPRINTK(PROBE, INFO, |
| 658 | "Speed and duplex autonegotiation enabled\n"); |
| 659 | break; |
| 660 | case HALF_DUPLEX: |
| 661 | DPRINTK(PROBE, INFO, "Half Duplex specified without Speed\n"); |
| 662 | DPRINTK(PROBE, INFO, "Using Autonegotiation at " |
| 663 | "Half Duplex only\n"); |
| 664 | adapter->hw.autoneg = adapter->fc_autoneg = 1; |
| 665 | adapter->hw.autoneg_advertised = ADVERTISE_10_HALF | |
| 666 | ADVERTISE_100_HALF; |
| 667 | break; |
| 668 | case FULL_DUPLEX: |
| 669 | DPRINTK(PROBE, INFO, "Full Duplex specified without Speed\n"); |
| 670 | DPRINTK(PROBE, INFO, "Using Autonegotiation at " |
| 671 | "Full Duplex only\n"); |
| 672 | adapter->hw.autoneg = adapter->fc_autoneg = 1; |
| 673 | adapter->hw.autoneg_advertised = ADVERTISE_10_FULL | |
| 674 | ADVERTISE_100_FULL | |
| 675 | ADVERTISE_1000_FULL; |
| 676 | break; |
| 677 | case SPEED_10: |
| 678 | DPRINTK(PROBE, INFO, "10 Mbps Speed specified " |
| 679 | "without Duplex\n"); |
| 680 | DPRINTK(PROBE, INFO, "Using Autonegotiation at 10 Mbps only\n"); |
| 681 | adapter->hw.autoneg = adapter->fc_autoneg = 1; |
| 682 | adapter->hw.autoneg_advertised = ADVERTISE_10_HALF | |
| 683 | ADVERTISE_10_FULL; |
| 684 | break; |
| 685 | case SPEED_10 + HALF_DUPLEX: |
| 686 | DPRINTK(PROBE, INFO, "Forcing to 10 Mbps Half Duplex\n"); |
| 687 | adapter->hw.autoneg = adapter->fc_autoneg = 0; |
| 688 | adapter->hw.forced_speed_duplex = e1000_10_half; |
| 689 | adapter->hw.autoneg_advertised = 0; |
| 690 | break; |
| 691 | case SPEED_10 + FULL_DUPLEX: |
| 692 | DPRINTK(PROBE, INFO, "Forcing to 10 Mbps Full Duplex\n"); |
| 693 | adapter->hw.autoneg = adapter->fc_autoneg = 0; |
| 694 | adapter->hw.forced_speed_duplex = e1000_10_full; |
| 695 | adapter->hw.autoneg_advertised = 0; |
| 696 | break; |
| 697 | case SPEED_100: |
| 698 | DPRINTK(PROBE, INFO, "100 Mbps Speed specified " |
| 699 | "without Duplex\n"); |
| 700 | DPRINTK(PROBE, INFO, "Using Autonegotiation at " |
| 701 | "100 Mbps only\n"); |
| 702 | adapter->hw.autoneg = adapter->fc_autoneg = 1; |
| 703 | adapter->hw.autoneg_advertised = ADVERTISE_100_HALF | |
| 704 | ADVERTISE_100_FULL; |
| 705 | break; |
| 706 | case SPEED_100 + HALF_DUPLEX: |
| 707 | DPRINTK(PROBE, INFO, "Forcing to 100 Mbps Half Duplex\n"); |
| 708 | adapter->hw.autoneg = adapter->fc_autoneg = 0; |
| 709 | adapter->hw.forced_speed_duplex = e1000_100_half; |
| 710 | adapter->hw.autoneg_advertised = 0; |
| 711 | break; |
| 712 | case SPEED_100 + FULL_DUPLEX: |
| 713 | DPRINTK(PROBE, INFO, "Forcing to 100 Mbps Full Duplex\n"); |
| 714 | adapter->hw.autoneg = adapter->fc_autoneg = 0; |
| 715 | adapter->hw.forced_speed_duplex = e1000_100_full; |
| 716 | adapter->hw.autoneg_advertised = 0; |
| 717 | break; |
| 718 | case SPEED_1000: |
| 719 | DPRINTK(PROBE, INFO, "1000 Mbps Speed specified without " |
| 720 | "Duplex\n"); |
| 721 | DPRINTK(PROBE, INFO, |
| 722 | "Using Autonegotiation at 1000 Mbps " |
| 723 | "Full Duplex only\n"); |
| 724 | adapter->hw.autoneg = adapter->fc_autoneg = 1; |
| 725 | adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL; |
| 726 | break; |
| 727 | case SPEED_1000 + HALF_DUPLEX: |
| 728 | DPRINTK(PROBE, INFO, |
| 729 | "Half Duplex is not supported at 1000 Mbps\n"); |
| 730 | DPRINTK(PROBE, INFO, |
| 731 | "Using Autonegotiation at 1000 Mbps " |
| 732 | "Full Duplex only\n"); |
| 733 | adapter->hw.autoneg = adapter->fc_autoneg = 1; |
| 734 | adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL; |
| 735 | break; |
| 736 | case SPEED_1000 + FULL_DUPLEX: |
| 737 | DPRINTK(PROBE, INFO, |
| 738 | "Using Autonegotiation at 1000 Mbps Full Duplex only\n"); |
| 739 | adapter->hw.autoneg = adapter->fc_autoneg = 1; |
| 740 | adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL; |
| 741 | break; |
| 742 | default: |
| 743 | BUG(); |
| 744 | } |
| 745 | |
| 746 | /* Speed, AutoNeg and MDI/MDI-X must all play nice */ |
| 747 | if (e1000_validate_mdi_setting(&(adapter->hw)) < 0) { |
| 748 | DPRINTK(PROBE, INFO, |
| 749 | "Speed, AutoNeg and MDI-X specifications are " |
| 750 | "incompatible. Setting MDI-X to a compatible value.\n"); |
| 751 | } |
| 752 | } |
| 753 | |