blob: bd6c040b3cfb06629d8f95509b6319e36efe85aa [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************************************
2
3
Auke Kok3d41e302006-04-14 19:05:31 -07004 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
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>
Auke Kok3d41e302006-04-14 19:05:31 -070025 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27
28*******************************************************************************/
29
30#include "e1000.h"
31
32/* This is the only thing that needs to be changed to adjust the
33 * maximum number of ports that the driver can manage.
34 */
35
36#define E1000_MAX_NIC 32
37
38#define OPTION_UNSET -1
39#define OPTION_DISABLED 0
40#define OPTION_ENABLED 1
41
42/* All parameters are treated the same, as an integer array of values.
43 * This macro just reduces the need to repeat the same declaration code
44 * over and over (plus this helps to avoid typo bugs).
45 */
46
47#define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
Auke Kok17231712006-06-27 09:06:59 -070048/* Module Parameters are always initialized to -1, so that the driver
49 * can tell the difference between no user specified value or the
50 * user asking for the default value.
51 * The true default values are loaded in when e1000_check_options is called.
52 *
53 * This is a GCC extension to ANSI C.
54 * See the item "Labeled Elements in Initializers" in the section
55 * "Extensions to the C Language Family" of the GCC documentation.
56 */
57
Linus Torvalds1da177e2005-04-16 15:20:36 -070058#define E1000_PARAM(X, desc) \
59 static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
60 static int num_##X = 0; \
61 module_param_array_named(X, X, int, &num_##X, 0); \
62 MODULE_PARM_DESC(X, desc);
63
64/* Transmit Descriptor Count
65 *
66 * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers
67 * Valid Range: 80-4096 for 82544 and newer
68 *
69 * Default Value: 256
70 */
71
72E1000_PARAM(TxDescriptors, "Number of transmit descriptors");
73
74/* Receive Descriptor Count
75 *
76 * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers
77 * Valid Range: 80-4096 for 82544 and newer
78 *
79 * Default Value: 256
80 */
81
82E1000_PARAM(RxDescriptors, "Number of receive descriptors");
83
84/* User Specified Speed Override
85 *
86 * Valid Range: 0, 10, 100, 1000
87 * - 0 - auto-negotiate at all supported speeds
88 * - 10 - only link at 10 Mbps
89 * - 100 - only link at 100 Mbps
90 * - 1000 - only link at 1000 Mbps
91 *
92 * Default Value: 0
93 */
94
95E1000_PARAM(Speed, "Speed setting");
96
97/* User Specified Duplex Override
98 *
99 * Valid Range: 0-2
100 * - 0 - auto-negotiate for duplex
101 * - 1 - only link at half duplex
102 * - 2 - only link at full duplex
103 *
104 * Default Value: 0
105 */
106
107E1000_PARAM(Duplex, "Duplex setting");
108
109/* Auto-negotiation Advertisement Override
110 *
111 * Valid Range: 0x01-0x0F, 0x20-0x2F (copper); 0x20 (fiber)
112 *
113 * The AutoNeg value is a bit mask describing which speed and duplex
114 * combinations should be advertised during auto-negotiation.
115 * The supported speed and duplex modes are listed below
116 *
117 * Bit 7 6 5 4 3 2 1 0
118 * Speed (Mbps) N/A N/A 1000 N/A 100 100 10 10
119 * Duplex Full Full Half Full Half
120 *
121 * Default Value: 0x2F (copper); 0x20 (fiber)
122 */
123
124E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting");
125
126/* User Specified Flow Control Override
127 *
128 * Valid Range: 0-3
129 * - 0 - No Flow Control
130 * - 1 - Rx only, respond to PAUSE frames but do not generate them
131 * - 2 - Tx only, generate PAUSE frames but ignore them on receive
132 * - 3 - Full Flow Control Support
133 *
134 * Default Value: Read flow control settings from the EEPROM
135 */
136
137E1000_PARAM(FlowControl, "Flow Control setting");
138
139/* XsumRX - Receive Checksum Offload Enable/Disable
140 *
141 * Valid Range: 0, 1
142 * - 0 - disables all checksum offload
143 * - 1 - enables receive IP/TCP/UDP checksum offload
144 * on 82543 and newer -based NICs
145 *
146 * Default Value: 1
147 */
148
149E1000_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
150
151/* Transmit Interrupt Delay in units of 1.024 microseconds
152 *
153 * Valid Range: 0-65535
154 *
155 * Default Value: 64
156 */
157
158E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
159
160/* Transmit Absolute Interrupt Delay in units of 1.024 microseconds
161 *
162 * Valid Range: 0-65535
163 *
164 * Default Value: 0
165 */
166
167E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
168
169/* Receive Interrupt Delay in units of 1.024 microseconds
170 *
171 * Valid Range: 0-65535
172 *
173 * Default Value: 0
174 */
175
176E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
177
178/* Receive Absolute Interrupt Delay in units of 1.024 microseconds
179 *
180 * Valid Range: 0-65535
181 *
182 * Default Value: 128
183 */
184
185E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
186
187/* Interrupt Throttle Rate (interrupts/sec)
188 *
189 * Valid Range: 100-100000 (0=off, 1=dynamic)
190 *
Jeff Kirsher38bd3b22006-01-12 16:51:37 -0800191 * Default Value: 8000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 */
193
194E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
195
Auke Kok9a53a202006-06-27 09:06:45 -0700196/* Enable Smart Power Down of the PHY
197 *
198 * Valid Range: 0, 1
199 *
200 * Default Value: 0 (disabled)
201 */
202
203E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
204
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205#define AUTONEG_ADV_DEFAULT 0x2F
206#define AUTONEG_ADV_MASK 0x2F
207#define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
208
209#define DEFAULT_RDTR 0
210#define MAX_RXDELAY 0xFFFF
211#define MIN_RXDELAY 0
212
213#define DEFAULT_RADV 128
214#define MAX_RXABSDELAY 0xFFFF
215#define MIN_RXABSDELAY 0
216
217#define DEFAULT_TIDV 64
218#define MAX_TXDELAY 0xFFFF
219#define MIN_TXDELAY 0
220
221#define DEFAULT_TADV 64
222#define MAX_TXABSDELAY 0xFFFF
223#define MIN_TXABSDELAY 0
224
225#define DEFAULT_ITR 8000
226#define MAX_ITR 100000
227#define MIN_ITR 100
228
229struct e1000_option {
230 enum { enable_option, range_option, list_option } type;
231 char *name;
232 char *err;
233 int def;
234 union {
235 struct { /* range_option info */
236 int min;
237 int max;
238 } r;
239 struct { /* list_option info */
240 int nr;
241 struct e1000_opt_list { int i; char *str; } *p;
242 } l;
243 } arg;
244};
245
246static int __devinit
247e1000_validate_option(int *value, struct e1000_option *opt,
248 struct e1000_adapter *adapter)
249{
Jesse Brandeburg96838a42006-01-18 13:01:39 -0800250 if (*value == OPTION_UNSET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 *value = opt->def;
252 return 0;
253 }
254
255 switch (opt->type) {
256 case enable_option:
257 switch (*value) {
258 case OPTION_ENABLED:
259 DPRINTK(PROBE, INFO, "%s Enabled\n", opt->name);
260 return 0;
261 case OPTION_DISABLED:
262 DPRINTK(PROBE, INFO, "%s Disabled\n", opt->name);
263 return 0;
264 }
265 break;
266 case range_option:
Jesse Brandeburg96838a42006-01-18 13:01:39 -0800267 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 DPRINTK(PROBE, INFO,
269 "%s set to %i\n", opt->name, *value);
270 return 0;
271 }
272 break;
273 case list_option: {
274 int i;
275 struct e1000_opt_list *ent;
276
Jesse Brandeburg96838a42006-01-18 13:01:39 -0800277 for (i = 0; i < opt->arg.l.nr; i++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 ent = &opt->arg.l.p[i];
Jesse Brandeburg96838a42006-01-18 13:01:39 -0800279 if (*value == ent->i) {
280 if (ent->str[0] != '\0')
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 DPRINTK(PROBE, INFO, "%s\n", ent->str);
282 return 0;
283 }
284 }
285 }
286 break;
287 default:
288 BUG();
289 }
290
Jeff Kirsher7e6c9862006-03-02 18:19:30 -0800291 DPRINTK(PROBE, INFO, "Invalid %s value specified (%i) %s\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 opt->name, *value, opt->err);
293 *value = opt->def;
294 return -1;
295}
296
297static void e1000_check_fiber_options(struct e1000_adapter *adapter);
298static void e1000_check_copper_options(struct e1000_adapter *adapter);
299
300/**
301 * e1000_check_options - Range Checking for Command Line Parameters
302 * @adapter: board private structure
303 *
304 * This routine checks all command line parameters for valid user
305 * input. If an invalid value is given, or if no user specified
306 * value exists, a default value is used. The final value is stored
307 * in a variable in the adapter structure.
308 **/
309
310void __devinit
311e1000_check_options(struct e1000_adapter *adapter)
312{
313 int bd = adapter->bd_number;
Jesse Brandeburg96838a42006-01-18 13:01:39 -0800314 if (bd >= E1000_MAX_NIC) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 DPRINTK(PROBE, NOTICE,
316 "Warning: no configuration for board #%i\n", bd);
317 DPRINTK(PROBE, NOTICE, "Using defaults for all values\n");
Auke Kok17231712006-06-27 09:06:59 -0700318 bd = E1000_MAX_NIC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 }
320
321 { /* Transmit Descriptor Count */
322 struct e1000_option opt = {
323 .type = range_option,
324 .name = "Transmit Descriptors",
325 .err = "using default of "
326 __MODULE_STRING(E1000_DEFAULT_TXD),
327 .def = E1000_DEFAULT_TXD,
328 .arg = { .r = { .min = E1000_MIN_TXD }}
329 };
Mallikarjuna R Chilakala581d7082005-10-04 07:01:55 -0400330 struct e1000_tx_ring *tx_ring = adapter->tx_ring;
331 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 e1000_mac_type mac_type = adapter->hw.mac_type;
333 opt.arg.r.max = mac_type < e1000_82544 ?
334 E1000_MAX_TXD : E1000_MAX_82544_TXD;
335
Auke Kok17231712006-06-27 09:06:59 -0700336 tx_ring->count = TxDescriptors[bd];
337 e1000_validate_option(&tx_ring->count, &opt, adapter);
338 E1000_ROUNDUP(tx_ring->count, REQ_TX_DESCRIPTOR_MULTIPLE);
Jeff Kirsherf56799e2006-01-12 16:50:39 -0800339 for (i = 0; i < adapter->num_tx_queues; i++)
Mallikarjuna R Chilakala581d7082005-10-04 07:01:55 -0400340 tx_ring[i].count = tx_ring->count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 }
342 { /* Receive Descriptor Count */
343 struct e1000_option opt = {
344 .type = range_option,
345 .name = "Receive Descriptors",
346 .err = "using default of "
347 __MODULE_STRING(E1000_DEFAULT_RXD),
348 .def = E1000_DEFAULT_RXD,
349 .arg = { .r = { .min = E1000_MIN_RXD }}
350 };
Mallikarjuna R Chilakala581d7082005-10-04 07:01:55 -0400351 struct e1000_rx_ring *rx_ring = adapter->rx_ring;
352 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 e1000_mac_type mac_type = adapter->hw.mac_type;
354 opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD :
355 E1000_MAX_82544_RXD;
356
Auke Kok17231712006-06-27 09:06:59 -0700357 rx_ring->count = RxDescriptors[bd];
358 e1000_validate_option(&rx_ring->count, &opt, adapter);
359 E1000_ROUNDUP(rx_ring->count, REQ_RX_DESCRIPTOR_MULTIPLE);
Jeff Kirsherf56799e2006-01-12 16:50:39 -0800360 for (i = 0; i < adapter->num_rx_queues; i++)
Mallikarjuna R Chilakala581d7082005-10-04 07:01:55 -0400361 rx_ring[i].count = rx_ring->count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 }
363 { /* Checksum Offload Enable/Disable */
364 struct e1000_option opt = {
365 .type = enable_option,
366 .name = "Checksum Offload",
367 .err = "defaulting to Enabled",
368 .def = OPTION_ENABLED
369 };
370
Auke Kok17231712006-06-27 09:06:59 -0700371 int rx_csum = XsumRX[bd];
372 e1000_validate_option(&rx_csum, &opt, adapter);
373 adapter->rx_csum = rx_csum;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 }
375 { /* Flow Control */
376
377 struct e1000_opt_list fc_list[] =
378 {{ e1000_fc_none, "Flow Control Disabled" },
379 { e1000_fc_rx_pause,"Flow Control Receive Only" },
380 { e1000_fc_tx_pause,"Flow Control Transmit Only" },
381 { e1000_fc_full, "Flow Control Enabled" },
382 { e1000_fc_default, "Flow Control Hardware Default" }};
383
384 struct e1000_option opt = {
385 .type = list_option,
386 .name = "Flow Control",
387 .err = "reading default settings from EEPROM",
388 .def = e1000_fc_default,
389 .arg = { .l = { .nr = ARRAY_SIZE(fc_list),
390 .p = fc_list }}
391 };
392
Auke Kok17231712006-06-27 09:06:59 -0700393 int fc = FlowControl[bd];
394 e1000_validate_option(&fc, &opt, adapter);
395 adapter->hw.fc = adapter->hw.original_fc = fc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 }
397 { /* Transmit Interrupt Delay */
398 struct e1000_option opt = {
399 .type = range_option,
400 .name = "Transmit Interrupt Delay",
401 .err = "using default of " __MODULE_STRING(DEFAULT_TIDV),
402 .def = DEFAULT_TIDV,
403 .arg = { .r = { .min = MIN_TXDELAY,
404 .max = MAX_TXDELAY }}
405 };
406
Auke Kok17231712006-06-27 09:06:59 -0700407 adapter->tx_int_delay = TxIntDelay[bd];
408 e1000_validate_option(&adapter->tx_int_delay, &opt, adapter);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 }
410 { /* Transmit Absolute Interrupt Delay */
411 struct e1000_option opt = {
412 .type = range_option,
413 .name = "Transmit Absolute Interrupt Delay",
414 .err = "using default of " __MODULE_STRING(DEFAULT_TADV),
415 .def = DEFAULT_TADV,
416 .arg = { .r = { .min = MIN_TXABSDELAY,
417 .max = MAX_TXABSDELAY }}
418 };
419
Auke Kok17231712006-06-27 09:06:59 -0700420 adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
421 e1000_validate_option(&adapter->tx_abs_int_delay, &opt,
422 adapter);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 }
424 { /* Receive Interrupt Delay */
425 struct e1000_option opt = {
426 .type = range_option,
427 .name = "Receive Interrupt Delay",
428 .err = "using default of " __MODULE_STRING(DEFAULT_RDTR),
429 .def = DEFAULT_RDTR,
430 .arg = { .r = { .min = MIN_RXDELAY,
431 .max = MAX_RXDELAY }}
432 };
433
Auke Kok17231712006-06-27 09:06:59 -0700434 adapter->rx_int_delay = RxIntDelay[bd];
435 e1000_validate_option(&adapter->rx_int_delay, &opt, adapter);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 }
437 { /* Receive Absolute Interrupt Delay */
438 struct e1000_option opt = {
439 .type = range_option,
440 .name = "Receive Absolute Interrupt Delay",
441 .err = "using default of " __MODULE_STRING(DEFAULT_RADV),
442 .def = DEFAULT_RADV,
443 .arg = { .r = { .min = MIN_RXABSDELAY,
444 .max = MAX_RXABSDELAY }}
445 };
446
Auke Kok17231712006-06-27 09:06:59 -0700447 adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
448 e1000_validate_option(&adapter->rx_abs_int_delay, &opt,
449 adapter);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 }
451 { /* Interrupt Throttling Rate */
452 struct e1000_option opt = {
453 .type = range_option,
454 .name = "Interrupt Throttling Rate (ints/sec)",
455 .err = "using default of " __MODULE_STRING(DEFAULT_ITR),
456 .def = DEFAULT_ITR,
457 .arg = { .r = { .min = MIN_ITR,
458 .max = MAX_ITR }}
459 };
460
Auke Kok17231712006-06-27 09:06:59 -0700461 adapter->itr = InterruptThrottleRate[bd];
462 switch (adapter->itr) {
463 case 0:
464 DPRINTK(PROBE, INFO, "%s turned off\n", opt.name);
465 break;
466 case 1:
467 DPRINTK(PROBE, INFO, "%s set to dynamic mode\n",
468 opt.name);
469 break;
470 default:
471 e1000_validate_option(&adapter->itr, &opt, adapter);
472 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 }
474 }
Auke Kok9a53a202006-06-27 09:06:45 -0700475 { /* Smart Power Down */
476 struct e1000_option opt = {
477 .type = enable_option,
478 .name = "PHY Smart Power Down",
479 .err = "defaulting to Disabled",
480 .def = OPTION_DISABLED
481 };
482
Auke Kok17231712006-06-27 09:06:59 -0700483 int spd = SmartPowerDownEnable[bd];
484 e1000_validate_option(&spd, &opt, adapter);
485 adapter->smart_power_down = spd;
Auke Kok9a53a202006-06-27 09:06:45 -0700486 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487
Jesse Brandeburg96838a42006-01-18 13:01:39 -0800488 switch (adapter->hw.media_type) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 case e1000_media_type_fiber:
490 case e1000_media_type_internal_serdes:
491 e1000_check_fiber_options(adapter);
492 break;
493 case e1000_media_type_copper:
494 e1000_check_copper_options(adapter);
495 break;
496 default:
497 BUG();
498 }
499}
500
501/**
502 * e1000_check_fiber_options - Range Checking for Link Options, Fiber Version
503 * @adapter: board private structure
504 *
505 * Handles speed and duplex options on fiber adapters
506 **/
507
508static void __devinit
509e1000_check_fiber_options(struct e1000_adapter *adapter)
510{
511 int bd = adapter->bd_number;
Auke Kok17231712006-06-27 09:06:59 -0700512 bd = bd > E1000_MAX_NIC ? E1000_MAX_NIC : bd;
513 if ((Speed[bd] != OPTION_UNSET)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 DPRINTK(PROBE, INFO, "Speed not valid for fiber adapters, "
515 "parameter ignored\n");
516 }
517
Auke Kok17231712006-06-27 09:06:59 -0700518 if ((Duplex[bd] != OPTION_UNSET)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 DPRINTK(PROBE, INFO, "Duplex not valid for fiber adapters, "
520 "parameter ignored\n");
521 }
522
Auke Kok17231712006-06-27 09:06:59 -0700523 if ((AutoNeg[bd] != OPTION_UNSET) && (AutoNeg[bd] != 0x20)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 DPRINTK(PROBE, INFO, "AutoNeg other than 1000/Full is "
525 "not valid for fiber adapters, "
526 "parameter ignored\n");
527 }
528}
529
530/**
531 * e1000_check_copper_options - Range Checking for Link Options, Copper Version
532 * @adapter: board private structure
533 *
534 * Handles speed and duplex options on copper adapters
535 **/
536
537static void __devinit
538e1000_check_copper_options(struct e1000_adapter *adapter)
539{
Kenji Kaneshige32a4ec92006-01-05 22:45:44 -0800540 int speed, dplx, an;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 int bd = adapter->bd_number;
Auke Kok17231712006-06-27 09:06:59 -0700542 bd = bd > E1000_MAX_NIC ? E1000_MAX_NIC : bd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543
544 { /* Speed */
545 struct e1000_opt_list speed_list[] = {{ 0, "" },
546 { SPEED_10, "" },
547 { SPEED_100, "" },
548 { SPEED_1000, "" }};
549
550 struct e1000_option opt = {
551 .type = list_option,
552 .name = "Speed",
553 .err = "parameter ignored",
554 .def = 0,
555 .arg = { .l = { .nr = ARRAY_SIZE(speed_list),
556 .p = speed_list }}
557 };
558
Auke Kok17231712006-06-27 09:06:59 -0700559 speed = Speed[bd];
560 e1000_validate_option(&speed, &opt, adapter);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 }
562 { /* Duplex */
563 struct e1000_opt_list dplx_list[] = {{ 0, "" },
564 { HALF_DUPLEX, "" },
565 { FULL_DUPLEX, "" }};
566
567 struct e1000_option opt = {
568 .type = list_option,
569 .name = "Duplex",
570 .err = "parameter ignored",
571 .def = 0,
572 .arg = { .l = { .nr = ARRAY_SIZE(dplx_list),
573 .p = dplx_list }}
574 };
575
Jeff Kirsher57128192006-01-12 16:50:28 -0800576 if (e1000_check_phy_reset_block(&adapter->hw)) {
577 DPRINTK(PROBE, INFO,
578 "Link active due to SoL/IDER Session. "
579 "Speed/Duplex/AutoNeg parameter ignored.\n");
580 return;
581 }
Auke Kok17231712006-06-27 09:06:59 -0700582 dplx = Duplex[bd];
583 e1000_validate_option(&dplx, &opt, adapter);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 }
585
Auke Kok17231712006-06-27 09:06:59 -0700586 if (AutoNeg[bd] != OPTION_UNSET && (speed != 0 || dplx != 0)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 DPRINTK(PROBE, INFO,
588 "AutoNeg specified along with Speed or Duplex, "
589 "parameter ignored\n");
590 adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT;
591 } else { /* Autoneg */
592 struct e1000_opt_list an_list[] =
593 #define AA "AutoNeg advertising "
594 {{ 0x01, AA "10/HD" },
595 { 0x02, AA "10/FD" },
596 { 0x03, AA "10/FD, 10/HD" },
597 { 0x04, AA "100/HD" },
598 { 0x05, AA "100/HD, 10/HD" },
599 { 0x06, AA "100/HD, 10/FD" },
600 { 0x07, AA "100/HD, 10/FD, 10/HD" },
601 { 0x08, AA "100/FD" },
602 { 0x09, AA "100/FD, 10/HD" },
603 { 0x0a, AA "100/FD, 10/FD" },
604 { 0x0b, AA "100/FD, 10/FD, 10/HD" },
605 { 0x0c, AA "100/FD, 100/HD" },
606 { 0x0d, AA "100/FD, 100/HD, 10/HD" },
607 { 0x0e, AA "100/FD, 100/HD, 10/FD" },
608 { 0x0f, AA "100/FD, 100/HD, 10/FD, 10/HD" },
609 { 0x20, AA "1000/FD" },
610 { 0x21, AA "1000/FD, 10/HD" },
611 { 0x22, AA "1000/FD, 10/FD" },
612 { 0x23, AA "1000/FD, 10/FD, 10/HD" },
613 { 0x24, AA "1000/FD, 100/HD" },
614 { 0x25, AA "1000/FD, 100/HD, 10/HD" },
615 { 0x26, AA "1000/FD, 100/HD, 10/FD" },
616 { 0x27, AA "1000/FD, 100/HD, 10/FD, 10/HD" },
617 { 0x28, AA "1000/FD, 100/FD" },
618 { 0x29, AA "1000/FD, 100/FD, 10/HD" },
619 { 0x2a, AA "1000/FD, 100/FD, 10/FD" },
620 { 0x2b, AA "1000/FD, 100/FD, 10/FD, 10/HD" },
621 { 0x2c, AA "1000/FD, 100/FD, 100/HD" },
622 { 0x2d, AA "1000/FD, 100/FD, 100/HD, 10/HD" },
623 { 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" },
624 { 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }};
625
626 struct e1000_option opt = {
627 .type = list_option,
628 .name = "AutoNeg",
629 .err = "parameter ignored",
630 .def = AUTONEG_ADV_DEFAULT,
631 .arg = { .l = { .nr = ARRAY_SIZE(an_list),
632 .p = an_list }}
633 };
634
Auke Kok17231712006-06-27 09:06:59 -0700635 an = AutoNeg[bd];
636 e1000_validate_option(&an, &opt, adapter);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 adapter->hw.autoneg_advertised = an;
638 }
639
640 switch (speed + dplx) {
641 case 0:
642 adapter->hw.autoneg = adapter->fc_autoneg = 1;
Auke Kok17231712006-06-27 09:06:59 -0700643 if (Speed[bd] != OPTION_UNSET || Duplex[bd] != OPTION_UNSET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 DPRINTK(PROBE, INFO,
645 "Speed and duplex autonegotiation enabled\n");
646 break;
647 case HALF_DUPLEX:
648 DPRINTK(PROBE, INFO, "Half Duplex specified without Speed\n");
649 DPRINTK(PROBE, INFO, "Using Autonegotiation at "
650 "Half Duplex only\n");
651 adapter->hw.autoneg = adapter->fc_autoneg = 1;
652 adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
653 ADVERTISE_100_HALF;
654 break;
655 case FULL_DUPLEX:
656 DPRINTK(PROBE, INFO, "Full Duplex specified without Speed\n");
657 DPRINTK(PROBE, INFO, "Using Autonegotiation at "
658 "Full Duplex only\n");
659 adapter->hw.autoneg = adapter->fc_autoneg = 1;
660 adapter->hw.autoneg_advertised = ADVERTISE_10_FULL |
661 ADVERTISE_100_FULL |
662 ADVERTISE_1000_FULL;
663 break;
664 case SPEED_10:
665 DPRINTK(PROBE, INFO, "10 Mbps Speed specified "
666 "without Duplex\n");
667 DPRINTK(PROBE, INFO, "Using Autonegotiation at 10 Mbps only\n");
668 adapter->hw.autoneg = adapter->fc_autoneg = 1;
669 adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
670 ADVERTISE_10_FULL;
671 break;
672 case SPEED_10 + HALF_DUPLEX:
673 DPRINTK(PROBE, INFO, "Forcing to 10 Mbps Half Duplex\n");
674 adapter->hw.autoneg = adapter->fc_autoneg = 0;
675 adapter->hw.forced_speed_duplex = e1000_10_half;
676 adapter->hw.autoneg_advertised = 0;
677 break;
678 case SPEED_10 + FULL_DUPLEX:
679 DPRINTK(PROBE, INFO, "Forcing to 10 Mbps Full Duplex\n");
680 adapter->hw.autoneg = adapter->fc_autoneg = 0;
681 adapter->hw.forced_speed_duplex = e1000_10_full;
682 adapter->hw.autoneg_advertised = 0;
683 break;
684 case SPEED_100:
685 DPRINTK(PROBE, INFO, "100 Mbps Speed specified "
686 "without Duplex\n");
687 DPRINTK(PROBE, INFO, "Using Autonegotiation at "
688 "100 Mbps only\n");
689 adapter->hw.autoneg = adapter->fc_autoneg = 1;
690 adapter->hw.autoneg_advertised = ADVERTISE_100_HALF |
691 ADVERTISE_100_FULL;
692 break;
693 case SPEED_100 + HALF_DUPLEX:
694 DPRINTK(PROBE, INFO, "Forcing to 100 Mbps Half Duplex\n");
695 adapter->hw.autoneg = adapter->fc_autoneg = 0;
696 adapter->hw.forced_speed_duplex = e1000_100_half;
697 adapter->hw.autoneg_advertised = 0;
698 break;
699 case SPEED_100 + FULL_DUPLEX:
700 DPRINTK(PROBE, INFO, "Forcing to 100 Mbps Full Duplex\n");
701 adapter->hw.autoneg = adapter->fc_autoneg = 0;
702 adapter->hw.forced_speed_duplex = e1000_100_full;
703 adapter->hw.autoneg_advertised = 0;
704 break;
705 case SPEED_1000:
706 DPRINTK(PROBE, INFO, "1000 Mbps Speed specified without "
707 "Duplex\n");
708 DPRINTK(PROBE, INFO,
709 "Using Autonegotiation at 1000 Mbps "
710 "Full Duplex only\n");
711 adapter->hw.autoneg = adapter->fc_autoneg = 1;
712 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
713 break;
714 case SPEED_1000 + HALF_DUPLEX:
715 DPRINTK(PROBE, INFO,
716 "Half Duplex is not supported at 1000 Mbps\n");
717 DPRINTK(PROBE, INFO,
718 "Using Autonegotiation at 1000 Mbps "
719 "Full Duplex only\n");
720 adapter->hw.autoneg = adapter->fc_autoneg = 1;
721 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
722 break;
723 case SPEED_1000 + FULL_DUPLEX:
724 DPRINTK(PROBE, INFO,
725 "Using Autonegotiation at 1000 Mbps Full Duplex only\n");
726 adapter->hw.autoneg = adapter->fc_autoneg = 1;
727 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
728 break;
729 default:
730 BUG();
731 }
732
733 /* Speed, AutoNeg and MDI/MDI-X must all play nice */
734 if (e1000_validate_mdi_setting(&(adapter->hw)) < 0) {
735 DPRINTK(PROBE, INFO,
736 "Speed, AutoNeg and MDI-X specifications are "
737 "incompatible. Setting MDI-X to a compatible value.\n");
738 }
739}
740