1 /*******************************************************************************
4 Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved.
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)
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
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.
20 The full GNU General Public License is included in this distribution in the
24 Linux NICS <linux.nics@intel.com>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *******************************************************************************/
31 /* This is the only thing that needs to be changed to adjust the
32 * maximum number of ports that the driver can manage.
35 #define E1000_MAX_NIC 32
37 #define OPTION_UNSET -1
38 #define OPTION_DISABLED 0
39 #define OPTION_ENABLED 1
41 /* Module Parameters are always initialized to -1, so that the driver
42 * can tell the difference between no user specified value or the
43 * user asking for the default value.
44 * The true default values are loaded in when e1000_check_options is called.
46 * This is a GCC extension to ANSI C.
47 * See the item "Labeled Elements in Initializers" in the section
48 * "Extensions to the C Language Family" of the GCC documentation.
51 #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
53 /* All parameters are treated the same, as an integer array of values.
54 * This macro just reduces the need to repeat the same declaration code
55 * over and over (plus this helps to avoid typo bugs).
58 #define E1000_PARAM(X, S) \
59 static const int __devinitdata X[E1000_MAX_NIC + 1] = E1000_PARAM_INIT; \
60 MODULE_PARM(X, "1-" __MODULE_STRING(E1000_MAX_NIC) "i"); \
61 MODULE_PARM_DESC(X, S);
63 /* Transmit Descriptor Count
65 * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers
66 * Valid Range: 80-4096 for 82544 and newer
71 E1000_PARAM(TxDescriptors, "Number of transmit descriptors");
73 /* Receive Descriptor Count
75 * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers
76 * Valid Range: 80-4096 for 82544 and newer
81 E1000_PARAM(RxDescriptors, "Number of receive descriptors");
83 /* User Specified Speed Override
85 * Valid Range: 0, 10, 100, 1000
86 * - 0 - auto-negotiate at all supported speeds
87 * - 10 - only link at 10 Mbps
88 * - 100 - only link at 100 Mbps
89 * - 1000 - only link at 1000 Mbps
94 E1000_PARAM(Speed, "Speed setting");
96 /* User Specified Duplex Override
99 * - 0 - auto-negotiate for duplex
100 * - 1 - only link at half duplex
101 * - 2 - only link at full duplex
106 E1000_PARAM(Duplex, "Duplex setting");
108 /* Auto-negotiation Advertisement Override
110 * Valid Range: 0x01-0x0F, 0x20-0x2F (copper); 0x20 (fiber)
112 * The AutoNeg value is a bit mask describing which speed and duplex
113 * combinations should be advertised during auto-negotiation.
114 * The supported speed and duplex modes are listed below
116 * Bit 7 6 5 4 3 2 1 0
117 * Speed (Mbps) N/A N/A 1000 N/A 100 100 10 10
118 * Duplex Full Full Half Full Half
120 * Default Value: 0x2F (copper); 0x20 (fiber)
123 E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting");
125 /* User Specified Flow Control Override
128 * - 0 - No Flow Control
129 * - 1 - Rx only, respond to PAUSE frames but do not generate them
130 * - 2 - Tx only, generate PAUSE frames but ignore them on receive
131 * - 3 - Full Flow Control Support
133 * Default Value: Read flow control settings from the EEPROM
136 E1000_PARAM(FlowControl, "Flow Control setting");
138 /* XsumRX - Receive Checksum Offload Enable/Disable
141 * - 0 - disables all checksum offload
142 * - 1 - enables receive IP/TCP/UDP checksum offload
143 * on 82543 and newer -based NICs
148 E1000_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
150 /* Transmit Interrupt Delay in units of 1.024 microseconds
152 * Valid Range: 0-65535
157 E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
159 /* Transmit Absolute Interrupt Delay in units of 1.024 microseconds
161 * Valid Range: 0-65535
166 E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
168 /* Receive Interrupt Delay in units of 1.024 microseconds
170 * Valid Range: 0-65535
175 E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
177 /* Receive Absolute Interrupt Delay in units of 1.024 microseconds
179 * Valid Range: 0-65535
184 E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
186 /* Interrupt Throttle Rate (interrupts/sec)
188 * Valid Range: 100-100000 (0=off, 1=dynamic)
193 E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
195 #define AUTONEG_ADV_DEFAULT 0x2F
196 #define AUTONEG_ADV_MASK 0x2F
197 #define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
199 #define DEFAULT_RDTR 0
200 #define MAX_RXDELAY 0xFFFF
201 #define MIN_RXDELAY 0
203 #define DEFAULT_RADV 128
204 #define MAX_RXABSDELAY 0xFFFF
205 #define MIN_RXABSDELAY 0
207 #define DEFAULT_TIDV 64
208 #define MAX_TXDELAY 0xFFFF
209 #define MIN_TXDELAY 0
211 #define DEFAULT_TADV 64
212 #define MAX_TXABSDELAY 0xFFFF
213 #define MIN_TXABSDELAY 0
215 #define DEFAULT_ITR 1
216 #define MAX_ITR 100000
219 struct e1000_option {
220 enum { enable_option, range_option, list_option } type;
225 struct { /* range_option info */
229 struct { /* list_option info */
231 struct e1000_opt_list { int i; char *str; } *p;
237 e1000_validate_option(int *value, struct e1000_option *opt,
238 struct e1000_adapter *adapter)
240 if(*value == OPTION_UNSET) {
249 DPRINTK(PROBE, INFO, "%s Enabled\n", opt->name);
251 case OPTION_DISABLED:
252 DPRINTK(PROBE, INFO, "%s Disabled\n", opt->name);
257 if(*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
259 "%s set to %i\n", opt->name, *value);
265 struct e1000_opt_list *ent;
267 for(i = 0; i < opt->arg.l.nr; i++) {
268 ent = &opt->arg.l.p[i];
269 if(*value == ent->i) {
270 if(ent->str[0] != '\0')
271 DPRINTK(PROBE, INFO, "%s\n", ent->str);
281 DPRINTK(PROBE, INFO, "Invalid %s specified (%i) %s\n",
282 opt->name, *value, opt->err);
287 static void e1000_check_fiber_options(struct e1000_adapter *adapter);
288 static void e1000_check_copper_options(struct e1000_adapter *adapter);
291 * e1000_check_options - Range Checking for Command Line Parameters
292 * @adapter: board private structure
294 * This routine checks all command line parameters for valid user
295 * input. If an invalid value is given, or if no user specified
296 * value exists, a default value is used. The final value is stored
297 * in a variable in the adapter structure.
301 e1000_check_options(struct e1000_adapter *adapter)
303 int bd = adapter->bd_number;
304 if(bd >= E1000_MAX_NIC) {
305 DPRINTK(PROBE, NOTICE,
306 "Warning: no configuration for board #%i\n", bd);
307 DPRINTK(PROBE, NOTICE, "Using defaults for all values\n");
311 { /* Transmit Descriptor Count */
312 struct e1000_option opt = {
313 .type = range_option,
314 .name = "Transmit Descriptors",
315 .err = "using default of "
316 __MODULE_STRING(E1000_DEFAULT_TXD),
317 .def = E1000_DEFAULT_TXD,
318 .arg = { .r = { .min = E1000_MIN_TXD }}
320 struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
321 e1000_mac_type mac_type = adapter->hw.mac_type;
322 opt.arg.r.max = mac_type < e1000_82544 ?
323 E1000_MAX_TXD : E1000_MAX_82544_TXD;
325 tx_ring->count = TxDescriptors[bd];
326 e1000_validate_option(&tx_ring->count, &opt, adapter);
327 E1000_ROUNDUP(tx_ring->count, REQ_TX_DESCRIPTOR_MULTIPLE);
329 { /* Receive Descriptor Count */
330 struct e1000_option opt = {
331 .type = range_option,
332 .name = "Receive Descriptors",
333 .err = "using default of "
334 __MODULE_STRING(E1000_DEFAULT_RXD),
335 .def = E1000_DEFAULT_RXD,
336 .arg = { .r = { .min = E1000_MIN_RXD }}
338 struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
339 e1000_mac_type mac_type = adapter->hw.mac_type;
340 opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD :
343 rx_ring->count = RxDescriptors[bd];
344 e1000_validate_option(&rx_ring->count, &opt, adapter);
345 E1000_ROUNDUP(rx_ring->count, REQ_RX_DESCRIPTOR_MULTIPLE);
347 { /* Checksum Offload Enable/Disable */
348 struct e1000_option opt = {
349 .type = enable_option,
350 .name = "Checksum Offload",
351 .err = "defaulting to Enabled",
352 .def = OPTION_ENABLED
355 int rx_csum = XsumRX[bd];
356 e1000_validate_option(&rx_csum, &opt, adapter);
357 adapter->rx_csum = rx_csum;
361 struct e1000_opt_list fc_list[] =
362 {{ e1000_fc_none, "Flow Control Disabled" },
363 { e1000_fc_rx_pause,"Flow Control Receive Only" },
364 { e1000_fc_tx_pause,"Flow Control Transmit Only" },
365 { e1000_fc_full, "Flow Control Enabled" },
366 { e1000_fc_default, "Flow Control Hardware Default" }};
368 struct e1000_option opt = {
370 .name = "Flow Control",
371 .err = "reading default settings from EEPROM",
372 .def = e1000_fc_default,
373 .arg = { .l = { .nr = ARRAY_SIZE(fc_list),
377 int fc = FlowControl[bd];
378 e1000_validate_option(&fc, &opt, adapter);
379 adapter->hw.fc = adapter->hw.original_fc = fc;
381 { /* Transmit Interrupt Delay */
382 struct e1000_option opt = {
383 .type = range_option,
384 .name = "Transmit Interrupt Delay",
385 .err = "using default of " __MODULE_STRING(DEFAULT_TIDV),
387 .arg = { .r = { .min = MIN_TXDELAY,
388 .max = MAX_TXDELAY }}
391 adapter->tx_int_delay = TxIntDelay[bd];
392 e1000_validate_option(&adapter->tx_int_delay, &opt, adapter);
394 { /* Transmit Absolute Interrupt Delay */
395 struct e1000_option opt = {
396 .type = range_option,
397 .name = "Transmit Absolute Interrupt Delay",
398 .err = "using default of " __MODULE_STRING(DEFAULT_TADV),
400 .arg = { .r = { .min = MIN_TXABSDELAY,
401 .max = MAX_TXABSDELAY }}
404 adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
405 e1000_validate_option(&adapter->tx_abs_int_delay, &opt, adapter);
407 { /* Receive Interrupt Delay */
408 struct e1000_option opt = {
409 .type = range_option,
410 .name = "Receive Interrupt Delay",
411 .err = "using default of " __MODULE_STRING(DEFAULT_RDTR),
413 .arg = { .r = { .min = MIN_RXDELAY,
414 .max = MAX_RXDELAY }}
417 adapter->rx_int_delay = RxIntDelay[bd];
418 e1000_validate_option(&adapter->rx_int_delay, &opt, adapter);
420 { /* Receive Absolute Interrupt Delay */
421 struct e1000_option opt = {
422 .type = range_option,
423 .name = "Receive Absolute Interrupt Delay",
424 .err = "using default of " __MODULE_STRING(DEFAULT_RADV),
426 .arg = { .r = { .min = MIN_RXABSDELAY,
427 .max = MAX_RXABSDELAY }}
430 adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
431 e1000_validate_option(&adapter->rx_abs_int_delay, &opt, adapter);
433 { /* Interrupt Throttling Rate */
434 struct e1000_option opt = {
435 .type = range_option,
436 .name = "Interrupt Throttling Rate (ints/sec)",
437 .err = "using default of " __MODULE_STRING(DEFAULT_ITR),
439 .arg = { .r = { .min = MIN_ITR,
443 adapter->itr = InterruptThrottleRate[bd];
444 switch(adapter->itr) {
449 DPRINTK(PROBE, INFO, "%s turned off\n", opt.name);
453 "%s set to dynamic mode\n", opt.name);
456 e1000_validate_option(&adapter->itr, &opt, adapter);
461 switch(adapter->hw.media_type) {
462 case e1000_media_type_fiber:
463 case e1000_media_type_internal_serdes:
464 e1000_check_fiber_options(adapter);
466 case e1000_media_type_copper:
467 e1000_check_copper_options(adapter);
475 * e1000_check_fiber_options - Range Checking for Link Options, Fiber Version
476 * @adapter: board private structure
478 * Handles speed and duplex options on fiber adapters
481 static void __devinit
482 e1000_check_fiber_options(struct e1000_adapter *adapter)
484 int bd = adapter->bd_number;
485 bd = bd > E1000_MAX_NIC ? E1000_MAX_NIC : bd;
487 if((Speed[bd] != OPTION_UNSET)) {
488 DPRINTK(PROBE, INFO, "Speed not valid for fiber adapters, "
489 "parameter ignored\n");
491 if((Duplex[bd] != OPTION_UNSET)) {
492 DPRINTK(PROBE, INFO, "Duplex not valid for fiber adapters, "
493 "parameter ignored\n");
495 if((AutoNeg[bd] != OPTION_UNSET) && (AutoNeg[bd] != 0x20)) {
496 DPRINTK(PROBE, INFO, "AutoNeg other than Full/1000 is "
497 "not valid for fiber adapters, parameter ignored\n");
502 * e1000_check_copper_options - Range Checking for Link Options, Copper Version
503 * @adapter: board private structure
505 * Handles speed and duplex options on copper adapters
508 static void __devinit
509 e1000_check_copper_options(struct e1000_adapter *adapter)
512 int bd = adapter->bd_number;
513 bd = bd > E1000_MAX_NIC ? E1000_MAX_NIC : bd;
516 struct e1000_opt_list speed_list[] = {{ 0, "" },
521 struct e1000_option opt = {
524 .err = "parameter ignored",
526 .arg = { .l = { .nr = ARRAY_SIZE(speed_list),
531 e1000_validate_option(&speed, &opt, adapter);
534 struct e1000_opt_list dplx_list[] = {{ 0, "" },
536 { FULL_DUPLEX, "" }};
538 struct e1000_option opt = {
541 .err = "parameter ignored",
543 .arg = { .l = { .nr = ARRAY_SIZE(dplx_list),
548 e1000_validate_option(&dplx, &opt, adapter);
551 if(AutoNeg[bd] != OPTION_UNSET && (speed != 0 || dplx != 0)) {
553 "AutoNeg specified along with Speed or Duplex, "
554 "parameter ignored\n");
555 adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT;
556 } else { /* Autoneg */
557 struct e1000_opt_list an_list[] =
558 #define AA "AutoNeg advertising "
559 {{ 0x01, AA "10/HD" },
560 { 0x02, AA "10/FD" },
561 { 0x03, AA "10/FD, 10/HD" },
562 { 0x04, AA "100/HD" },
563 { 0x05, AA "100/HD, 10/HD" },
564 { 0x06, AA "100/HD, 10/FD" },
565 { 0x07, AA "100/HD, 10/FD, 10/HD" },
566 { 0x08, AA "100/FD" },
567 { 0x09, AA "100/FD, 10/HD" },
568 { 0x0a, AA "100/FD, 10/FD" },
569 { 0x0b, AA "100/FD, 10/FD, 10/HD" },
570 { 0x0c, AA "100/FD, 100/HD" },
571 { 0x0d, AA "100/FD, 100/HD, 10/HD" },
572 { 0x0e, AA "100/FD, 100/HD, 10/FD" },
573 { 0x0f, AA "100/FD, 100/HD, 10/FD, 10/HD" },
574 { 0x20, AA "1000/FD" },
575 { 0x21, AA "1000/FD, 10/HD" },
576 { 0x22, AA "1000/FD, 10/FD" },
577 { 0x23, AA "1000/FD, 10/FD, 10/HD" },
578 { 0x24, AA "1000/FD, 100/HD" },
579 { 0x25, AA "1000/FD, 100/HD, 10/HD" },
580 { 0x26, AA "1000/FD, 100/HD, 10/FD" },
581 { 0x27, AA "1000/FD, 100/HD, 10/FD, 10/HD" },
582 { 0x28, AA "1000/FD, 100/FD" },
583 { 0x29, AA "1000/FD, 100/FD, 10/HD" },
584 { 0x2a, AA "1000/FD, 100/FD, 10/FD" },
585 { 0x2b, AA "1000/FD, 100/FD, 10/FD, 10/HD" },
586 { 0x2c, AA "1000/FD, 100/FD, 100/HD" },
587 { 0x2d, AA "1000/FD, 100/FD, 100/HD, 10/HD" },
588 { 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" },
589 { 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }};
591 struct e1000_option opt = {
594 .err = "parameter ignored",
595 .def = AUTONEG_ADV_DEFAULT,
596 .arg = { .l = { .nr = ARRAY_SIZE(an_list),
600 int an = AutoNeg[bd];
601 e1000_validate_option(&an, &opt, adapter);
602 adapter->hw.autoneg_advertised = an;
605 switch (speed + dplx) {
607 adapter->hw.autoneg = adapter->fc_autoneg = 1;
608 if(Speed[bd] != OPTION_UNSET || Duplex[bd] != OPTION_UNSET)
610 "Speed and duplex autonegotiation enabled\n");
613 DPRINTK(PROBE, INFO, "Half Duplex specified without Speed\n");
615 "Using Autonegotiation at Half Duplex only\n");
616 adapter->hw.autoneg = adapter->fc_autoneg = 1;
617 adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
621 DPRINTK(PROBE, INFO, "Full Duplex specified without Speed\n");
623 "Using Autonegotiation at Full Duplex only\n");
624 adapter->hw.autoneg = adapter->fc_autoneg = 1;
625 adapter->hw.autoneg_advertised = ADVERTISE_10_FULL |
631 "10 Mbps Speed specified without Duplex\n");
632 DPRINTK(PROBE, INFO, "Using Autonegotiation at 10 Mbps only\n");
633 adapter->hw.autoneg = adapter->fc_autoneg = 1;
634 adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
637 case SPEED_10 + HALF_DUPLEX:
638 DPRINTK(PROBE, INFO, "Forcing to 10 Mbps Half Duplex\n");
639 adapter->hw.autoneg = adapter->fc_autoneg = 0;
640 adapter->hw.forced_speed_duplex = e1000_10_half;
641 adapter->hw.autoneg_advertised = 0;
643 case SPEED_10 + FULL_DUPLEX:
644 DPRINTK(PROBE, INFO, "Forcing to 10 Mbps Full Duplex\n");
645 adapter->hw.autoneg = adapter->fc_autoneg = 0;
646 adapter->hw.forced_speed_duplex = e1000_10_full;
647 adapter->hw.autoneg_advertised = 0;
651 "100 Mbps Speed specified without Duplex\n");
653 "Using Autonegotiation at 100 Mbps only\n");
654 adapter->hw.autoneg = adapter->fc_autoneg = 1;
655 adapter->hw.autoneg_advertised = ADVERTISE_100_HALF |
658 case SPEED_100 + HALF_DUPLEX:
659 DPRINTK(PROBE, INFO, "Forcing to 100 Mbps Half Duplex\n");
660 adapter->hw.autoneg = adapter->fc_autoneg = 0;
661 adapter->hw.forced_speed_duplex = e1000_100_half;
662 adapter->hw.autoneg_advertised = 0;
664 case SPEED_100 + FULL_DUPLEX:
665 DPRINTK(PROBE, INFO, "Forcing to 100 Mbps Full Duplex\n");
666 adapter->hw.autoneg = adapter->fc_autoneg = 0;
667 adapter->hw.forced_speed_duplex = e1000_100_full;
668 adapter->hw.autoneg_advertised = 0;
672 "1000 Mbps Speed specified without Duplex\n");
674 "Using Autonegotiation at 1000 Mbps Full Duplex only\n");
675 adapter->hw.autoneg = adapter->fc_autoneg = 1;
676 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
678 case SPEED_1000 + HALF_DUPLEX:
680 "Half Duplex is not supported at 1000 Mbps\n");
682 "Using Autonegotiation at 1000 Mbps Full Duplex only\n");
683 adapter->hw.autoneg = adapter->fc_autoneg = 1;
684 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
686 case SPEED_1000 + FULL_DUPLEX:
688 "Using Autonegotiation at 1000 Mbps Full Duplex only\n");
689 adapter->hw.autoneg = adapter->fc_autoneg = 1;
690 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
696 /* Speed, AutoNeg and MDI/MDI-X must all play nice */
697 if (e1000_validate_mdi_setting(&(adapter->hw)) < 0) {
699 "Speed, AutoNeg and MDI-X specifications are "
700 "incompatible. Setting MDI-X to a compatible value.\n");