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