1 /*******************************************************************************
4 Copyright(c) 1999 - 2002 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
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
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
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
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 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
172 * Default Value: 0/128
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 #define AUTONEG_ADV_DEFAULT 0x2F
187 #define AUTONEG_ADV_MASK 0x2F
188 #define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
190 #define DEFAULT_TXD 256
193 #define MAX_82544_TXD 4096
195 #define DEFAULT_RXD 80
198 #define MAX_82544_RXD 4096
200 #define DEFAULT_RDTR 0
201 #define MAX_RXDELAY 0xFFFF
202 #define MIN_RXDELAY 0
204 #define DEFAULT_RADV 128
205 #define MAX_RXABSDELAY 0xFFFF
206 #define MIN_RXABSDELAY 0
208 #define DEFAULT_TIDV 64
209 #define MAX_TXDELAY 0xFFFF
210 #define MIN_TXDELAY 0
212 #define DEFAULT_TADV 64
213 #define MAX_TXABSDELAY 0xFFFF
214 #define MIN_TXABSDELAY 0
216 struct e1000_option {
217 enum { enable_option, range_option, list_option } type;
222 struct { /* range_option info */
226 struct { /* list_option info */
228 struct e1000_opt_list { int i; char *str; } *p;
234 e1000_validate_option(int *value, struct e1000_option *opt)
236 if(*value == OPTION_UNSET) {
245 printk(KERN_INFO "%s Enabled\n", opt->name);
247 case OPTION_DISABLED:
248 printk(KERN_INFO "%s Disabled\n", opt->name);
253 if(*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
254 printk(KERN_INFO "%s set to %i\n", opt->name, *value);
260 struct e1000_opt_list *ent;
262 for(i = 0; i < opt->arg.l.nr; i++) {
263 ent = &opt->arg.l.p[i];
264 if(*value == ent->i) {
265 if(ent->str[0] != '\0')
266 printk(KERN_INFO "%s\n", ent->str);
276 printk(KERN_INFO "Invalid %s specified (%i) %s\n",
277 opt->name, *value, opt->err);
282 static void e1000_check_fiber_options(struct e1000_adapter *adapter);
283 static void e1000_check_copper_options(struct e1000_adapter *adapter);
286 * e1000_check_options - Range Checking for Command Line Parameters
287 * @adapter: board private structure
289 * This routine checks all command line paramters for valid user
290 * input. If an invalid value is given, or if no user specified
291 * value exists, a default value is used. The final value is stored
292 * in a variable in the adapter structure.
296 e1000_check_options(struct e1000_adapter *adapter)
298 int bd = adapter->bd_number;
299 if(bd >= E1000_MAX_NIC) {
301 "Warning: no configuration for board #%i\n", bd);
302 printk(KERN_NOTICE "Using defaults for all values\n");
306 { /* Transmit Descriptor Count */
307 struct e1000_option opt = {
308 .type = range_option,
309 .name = "Transmit Descriptors",
310 .err = "using default of " __MODULE_STRING(DEFAULT_TXD),
312 .arg = { .r = { .min = MIN_TXD }}
314 struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
315 e1000_mac_type mac_type = adapter->hw.mac_type;
316 opt.arg.r.max = mac_type < e1000_82544 ?
317 MAX_TXD : MAX_82544_TXD;
319 tx_ring->count = TxDescriptors[bd];
320 e1000_validate_option(&tx_ring->count, &opt);
321 E1000_ROUNDUP(tx_ring->count, REQ_TX_DESCRIPTOR_MULTIPLE);
323 { /* Receive Descriptor Count */
324 struct e1000_option opt = {
325 .type = range_option,
326 .name = "Receive Descriptors",
327 .err = "using default of " __MODULE_STRING(DEFAULT_RXD),
329 .arg = { .r = { .min = MIN_RXD }}
331 struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
332 e1000_mac_type mac_type = adapter->hw.mac_type;
333 opt.arg.r.max = mac_type < e1000_82544 ? MAX_RXD : MAX_82544_RXD;
335 rx_ring->count = RxDescriptors[bd];
336 e1000_validate_option(&rx_ring->count, &opt);
337 E1000_ROUNDUP(rx_ring->count, REQ_RX_DESCRIPTOR_MULTIPLE);
339 { /* Checksum Offload Enable/Disable */
340 struct e1000_option opt = {
341 .type = enable_option,
342 .name = "Checksum Offload",
343 .err = "defaulting to Enabled",
344 .def = OPTION_ENABLED
347 int rx_csum = XsumRX[bd];
348 e1000_validate_option(&rx_csum, &opt);
349 adapter->rx_csum = rx_csum;
353 struct e1000_opt_list fc_list[] =
354 {{ e1000_fc_none, "Flow Control Disabled" },
355 { e1000_fc_rx_pause,"Flow Control Receive Only" },
356 { e1000_fc_tx_pause,"Flow Control Transmit Only" },
357 { e1000_fc_full, "Flow Control Enabled" },
358 { e1000_fc_default, "Flow Control Hardware Default" }};
360 struct e1000_option opt = {
362 .name = "Flow Control",
363 .err = "reading default settings from EEPROM",
364 .def = e1000_fc_default,
365 .arg = { .l = { .nr = ARRAY_SIZE(fc_list), .p = fc_list }}
368 int fc = FlowControl[bd];
369 e1000_validate_option(&fc, &opt);
370 adapter->hw.fc = adapter->hw.original_fc = fc;
372 { /* Transmit Interrupt Delay */
373 char *tidv = "using default of " __MODULE_STRING(DEFAULT_TIDV);
374 struct e1000_option opt = {
375 .type = range_option,
376 .name = "Transmit Interrupt Delay",
377 .arg = { .r = { .min = MIN_TXDELAY, .max = MAX_TXDELAY }}
379 opt.def = DEFAULT_TIDV;
382 adapter->tx_int_delay = TxIntDelay[bd];
383 e1000_validate_option(&adapter->tx_int_delay, &opt);
385 { /* Transmit Absolute Interrupt Delay */
386 char *tadv = "using default of " __MODULE_STRING(DEFAULT_TADV);
387 struct e1000_option opt = {
388 .type = range_option,
389 .name = "Transmit Absolute Interrupt Delay",
390 .arg = { .r = { .min = MIN_TXABSDELAY, .max = MAX_TXABSDELAY }}
392 opt.def = DEFAULT_TADV;
395 adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
396 e1000_validate_option(&adapter->tx_abs_int_delay, &opt);
398 { /* Receive Interrupt Delay */
399 char *rdtr = "using default of " __MODULE_STRING(DEFAULT_RDTR);
400 struct e1000_option opt = {
401 .type = range_option,
402 .name = "Receive Interrupt Delay",
403 .arg = { .r = { .min = MIN_RXDELAY, .max = MAX_RXDELAY }}
405 opt.def = DEFAULT_RDTR;
408 adapter->rx_int_delay = RxIntDelay[bd];
409 e1000_validate_option(&adapter->rx_int_delay, &opt);
411 { /* Receive Absolute Interrupt Delay */
412 char *radv = "using default of " __MODULE_STRING(DEFAULT_RADV);
413 struct e1000_option opt = {
414 .type = range_option,
415 .name = "Receive Absolute Interrupt Delay",
416 .arg = { .r = { .min = MIN_RXABSDELAY, .max = MAX_RXABSDELAY }}
418 opt.def = DEFAULT_RADV;
421 adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
422 e1000_validate_option(&adapter->rx_abs_int_delay, &opt);
425 switch(adapter->hw.media_type) {
426 case e1000_media_type_fiber:
427 e1000_check_fiber_options(adapter);
429 case e1000_media_type_copper:
430 e1000_check_copper_options(adapter);
438 * e1000_check_fiber_options - Range Checking for Link Options, Fiber Version
439 * @adapter: board private structure
441 * Handles speed and duplex options on fiber adapters
444 static void __devinit
445 e1000_check_fiber_options(struct e1000_adapter *adapter)
447 int bd = adapter->bd_number;
448 bd = bd > E1000_MAX_NIC ? E1000_MAX_NIC : bd;
450 if((Speed[bd] != OPTION_UNSET)) {
451 printk(KERN_INFO "Speed not valid for fiber adapters, "
452 "parameter ignored\n");
454 if((Duplex[bd] != OPTION_UNSET)) {
455 printk(KERN_INFO "Duplex not valid for fiber adapters, "
456 "parameter ignored\n");
458 if((AutoNeg[bd] != OPTION_UNSET)) {
459 printk(KERN_INFO "AutoNeg not valid for fiber adapters, "
460 "parameter ignored\n");
465 * e1000_check_copper_options - Range Checking for Link Options, Copper Version
466 * @adapter: board private structure
468 * Handles speed and duplex options on copper adapters
471 static void __devinit
472 e1000_check_copper_options(struct e1000_adapter *adapter)
475 int bd = adapter->bd_number;
476 bd = bd > E1000_MAX_NIC ? E1000_MAX_NIC : bd;
479 struct e1000_opt_list speed_list[] = {{ 0, "" },
484 struct e1000_option opt = {
487 .err = "parameter ignored",
489 .arg = { .l = { .nr = ARRAY_SIZE(speed_list), .p = speed_list }}
493 e1000_validate_option(&speed, &opt);
496 struct e1000_opt_list dplx_list[] = {{ 0, "" },
498 { FULL_DUPLEX, "" }};
500 struct e1000_option opt = {
503 .err = "parameter ignored",
505 .arg = { .l = { .nr = ARRAY_SIZE(dplx_list), .p = dplx_list }}
509 e1000_validate_option(&dplx, &opt);
512 if(AutoNeg[bd] != OPTION_UNSET && (speed != 0 || dplx != 0)) {
514 "AutoNeg specified along with Speed or Duplex, "
515 "parameter ignored\n");
516 adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT;
517 } else { /* Autoneg */
518 struct e1000_opt_list an_list[] =
519 #define AA "AutoNeg advertising "
520 {{ 0x01, AA "10/HD" },
521 { 0x02, AA "10/FD" },
522 { 0x03, AA "10/FD, 10/HD" },
523 { 0x04, AA "100/HD" },
524 { 0x05, AA "100/HD, 10/HD" },
525 { 0x06, AA "100/HD, 10/FD" },
526 { 0x07, AA "100/HD, 10/FD, 10/HD" },
527 { 0x08, AA "100/FD" },
528 { 0x09, AA "100/FD, 10/HD" },
529 { 0x0a, AA "100/FD, 10/FD" },
530 { 0x0b, AA "100/FD, 10/FD, 10/HD" },
531 { 0x0c, AA "100/FD, 100/HD" },
532 { 0x0d, AA "100/FD, 100/HD, 10/HD" },
533 { 0x0e, AA "100/FD, 100/HD, 10/FD" },
534 { 0x0f, AA "100/FD, 100/HD, 10/FD, 10/HD" },
535 { 0x20, AA "1000/FD" },
536 { 0x21, AA "1000/FD, 10/HD" },
537 { 0x22, AA "1000/FD, 10/FD" },
538 { 0x23, AA "1000/FD, 10/FD, 10/HD" },
539 { 0x24, AA "1000/FD, 100/HD" },
540 { 0x25, AA "1000/FD, 100/HD, 10/HD" },
541 { 0x26, AA "1000/FD, 100/HD, 10/FD" },
542 { 0x27, AA "1000/FD, 100/HD, 10/FD, 10/HD" },
543 { 0x28, AA "1000/FD, 100/FD" },
544 { 0x29, AA "1000/FD, 100/FD, 10/HD" },
545 { 0x2a, AA "1000/FD, 100/FD, 10/FD" },
546 { 0x2b, AA "1000/FD, 100/FD, 10/FD, 10/HD" },
547 { 0x2c, AA "1000/FD, 100/FD, 100/HD" },
548 { 0x2d, AA "1000/FD, 100/FD, 100/HD, 10/HD" },
549 { 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" },
550 { 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }};
552 struct e1000_option opt = {
555 .err = "parameter ignored",
556 .def = AUTONEG_ADV_DEFAULT,
557 .arg = { .l = { .nr = ARRAY_SIZE(an_list), .p = an_list }}
560 int an = AutoNeg[bd];
561 e1000_validate_option(&an, &opt);
562 adapter->hw.autoneg_advertised = an;
565 switch (speed + dplx) {
567 adapter->hw.autoneg = 1;
568 if(Speed[bd] != OPTION_UNSET || Duplex[bd] != OPTION_UNSET)
570 "Speed and duplex autonegotiation enabled\n");
573 printk(KERN_INFO "Half Duplex specified without Speed\n");
574 printk(KERN_INFO "Using Autonegotiation at Half Duplex only\n");
575 adapter->hw.autoneg = 1;
576 adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
580 printk(KERN_INFO "Full Duplex specified without Speed\n");
581 printk(KERN_INFO "Using Autonegotiation at Full Duplex only\n");
582 adapter->hw.autoneg = 1;
583 adapter->hw.autoneg_advertised = ADVERTISE_10_FULL |
588 printk(KERN_INFO "10 Mbps Speed specified without Duplex\n");
589 printk(KERN_INFO "Using Autonegotiation at 10 Mbps only\n");
590 adapter->hw.autoneg = 1;
591 adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
594 case SPEED_10 + HALF_DUPLEX:
595 printk(KERN_INFO "Forcing to 10 Mbps Half Duplex\n");
596 adapter->hw.autoneg = 0;
597 adapter->hw.forced_speed_duplex = e1000_10_half;
598 adapter->hw.autoneg_advertised = 0;
600 case SPEED_10 + FULL_DUPLEX:
601 printk(KERN_INFO "Forcing to 10 Mbps Full Duplex\n");
602 adapter->hw.autoneg = 0;
603 adapter->hw.forced_speed_duplex = e1000_10_full;
604 adapter->hw.autoneg_advertised = 0;
607 printk(KERN_INFO "100 Mbps Speed specified without Duplex\n");
608 printk(KERN_INFO "Using Autonegotiation at 100 Mbps only\n");
609 adapter->hw.autoneg = 1;
610 adapter->hw.autoneg_advertised = ADVERTISE_100_HALF |
613 case SPEED_100 + HALF_DUPLEX:
614 printk(KERN_INFO "Forcing to 100 Mbps Half Duplex\n");
615 adapter->hw.autoneg = 0;
616 adapter->hw.forced_speed_duplex = e1000_100_half;
617 adapter->hw.autoneg_advertised = 0;
619 case SPEED_100 + FULL_DUPLEX:
620 printk(KERN_INFO "Forcing to 100 Mbps Full Duplex\n");
621 adapter->hw.autoneg = 0;
622 adapter->hw.forced_speed_duplex = e1000_100_full;
623 adapter->hw.autoneg_advertised = 0;
626 printk(KERN_INFO "1000 Mbps Speed specified without Duplex\n");
628 "Using Autonegotiation at 1000 Mbps Full Duplex only\n");
629 adapter->hw.autoneg = 1;
630 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
632 case SPEED_1000 + HALF_DUPLEX:
633 printk(KERN_INFO "Half Duplex is not supported at 1000 Mbps\n");
635 "Using Autonegotiation at 1000 Mbps Full Duplex only\n");
636 adapter->hw.autoneg = 1;
637 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
639 case SPEED_1000 + FULL_DUPLEX:
641 "Using Autonegotiation at 1000 Mbps Full Duplex only\n");
642 adapter->hw.autoneg = 1;
643 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
649 /* Speed, AutoNeg and MDI/MDI-X must all play nice */
650 if (e1000_validate_mdi_setting(&(adapter->hw)) < 0) {
651 printk(KERN_INFO "Speed, AutoNeg and MDI-X specifications are "
652 "incompatible. Setting MDI-X to a compatible value.\n");