1 /*******************************************************************************
4 Copyright(c) 1999 - 2006 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 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
26 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
28 *******************************************************************************/
32 /* This is the only thing that needs to be changed to adjust the
33 * maximum number of ports that the driver can manage.
36 #define E1000_MAX_NIC 32
38 #define OPTION_UNSET -1
39 #define OPTION_DISABLED 0
40 #define OPTION_ENABLED 1
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).
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);
54 /* Transmit Descriptor Count
56 * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers
57 * Valid Range: 80-4096 for 82544 and newer
62 E1000_PARAM(TxDescriptors, "Number of transmit descriptors");
64 /* Receive Descriptor Count
66 * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers
67 * Valid Range: 80-4096 for 82544 and newer
72 E1000_PARAM(RxDescriptors, "Number of receive descriptors");
74 /* User Specified Speed Override
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
85 E1000_PARAM(Speed, "Speed setting");
87 /* User Specified Duplex Override
90 * - 0 - auto-negotiate for duplex
91 * - 1 - only link at half duplex
92 * - 2 - only link at full duplex
97 E1000_PARAM(Duplex, "Duplex setting");
99 /* Auto-negotiation Advertisement Override
101 * Valid Range: 0x01-0x0F, 0x20-0x2F (copper); 0x20 (fiber)
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
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
111 * Default Value: 0x2F (copper); 0x20 (fiber)
114 E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting");
116 /* User Specified Flow Control Override
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
124 * Default Value: Read flow control settings from the EEPROM
127 E1000_PARAM(FlowControl, "Flow Control setting");
129 /* XsumRX - Receive Checksum Offload Enable/Disable
132 * - 0 - disables all checksum offload
133 * - 1 - enables receive IP/TCP/UDP checksum offload
134 * on 82543 and newer -based NICs
139 E1000_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
141 /* Transmit Interrupt Delay in units of 1.024 microseconds
143 * Valid Range: 0-65535
148 E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
150 /* Transmit Absolute Interrupt Delay in units of 1.024 microseconds
152 * Valid Range: 0-65535
157 E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
159 /* Receive Interrupt Delay in units of 1.024 microseconds
161 * Valid Range: 0-65535
166 E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
168 /* Receive Absolute Interrupt Delay in units of 1.024 microseconds
170 * Valid Range: 0-65535
175 E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
177 /* Interrupt Throttle Rate (interrupts/sec)
179 * Valid Range: 100-100000 (0=off, 1=dynamic)
181 * Default Value: 8000
184 E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
186 #define AUTONEG_ADV_DEFAULT 0x2F
187 #define AUTONEG_ADV_MASK 0x2F
188 #define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
190 #define DEFAULT_RDTR 0
191 #define MAX_RXDELAY 0xFFFF
192 #define MIN_RXDELAY 0
194 #define DEFAULT_RADV 128
195 #define MAX_RXABSDELAY 0xFFFF
196 #define MIN_RXABSDELAY 0
198 #define DEFAULT_TIDV 64
199 #define MAX_TXDELAY 0xFFFF
200 #define MIN_TXDELAY 0
202 #define DEFAULT_TADV 64
203 #define MAX_TXABSDELAY 0xFFFF
204 #define MIN_TXABSDELAY 0
206 #define DEFAULT_ITR 8000
207 #define MAX_ITR 100000
210 struct e1000_option {
211 enum { enable_option, range_option, list_option } type;
216 struct { /* range_option info */
220 struct { /* list_option info */
222 struct e1000_opt_list { int i; char *str; } *p;
228 e1000_validate_option(int *value, struct e1000_option *opt,
229 struct e1000_adapter *adapter)
231 if (*value == OPTION_UNSET) {
240 DPRINTK(PROBE, INFO, "%s Enabled\n", opt->name);
242 case OPTION_DISABLED:
243 DPRINTK(PROBE, INFO, "%s Disabled\n", opt->name);
248 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
250 "%s set to %i\n", opt->name, *value);
256 struct e1000_opt_list *ent;
258 for (i = 0; i < opt->arg.l.nr; i++) {
259 ent = &opt->arg.l.p[i];
260 if (*value == ent->i) {
261 if (ent->str[0] != '\0')
262 DPRINTK(PROBE, INFO, "%s\n", ent->str);
272 DPRINTK(PROBE, INFO, "Invalid %s value specified (%i) %s\n",
273 opt->name, *value, opt->err);
278 static void e1000_check_fiber_options(struct e1000_adapter *adapter);
279 static void e1000_check_copper_options(struct e1000_adapter *adapter);
282 * e1000_check_options - Range Checking for Command Line Parameters
283 * @adapter: board private structure
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.
292 e1000_check_options(struct e1000_adapter *adapter)
294 int bd = adapter->bd_number;
295 if (bd >= E1000_MAX_NIC) {
296 DPRINTK(PROBE, NOTICE,
297 "Warning: no configuration for board #%i\n", bd);
298 DPRINTK(PROBE, NOTICE, "Using defaults for all values\n");
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 }}
310 struct e1000_tx_ring *tx_ring = adapter->tx_ring;
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;
316 if (num_TxDescriptors > bd) {
317 tx_ring->count = TxDescriptors[bd];
318 e1000_validate_option(&tx_ring->count, &opt, adapter);
319 E1000_ROUNDUP(tx_ring->count,
320 REQ_TX_DESCRIPTOR_MULTIPLE);
322 tx_ring->count = opt.def;
324 for (i = 0; i < adapter->num_tx_queues; i++)
325 tx_ring[i].count = tx_ring->count;
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 }}
336 struct e1000_rx_ring *rx_ring = adapter->rx_ring;
338 e1000_mac_type mac_type = adapter->hw.mac_type;
339 opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD :
342 if (num_RxDescriptors > bd) {
343 rx_ring->count = RxDescriptors[bd];
344 e1000_validate_option(&rx_ring->count, &opt, adapter);
345 E1000_ROUNDUP(rx_ring->count,
346 REQ_RX_DESCRIPTOR_MULTIPLE);
348 rx_ring->count = opt.def;
350 for (i = 0; i < adapter->num_rx_queues; i++)
351 rx_ring[i].count = rx_ring->count;
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
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;
366 adapter->rx_csum = opt.def;
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" }};
378 struct e1000_option opt = {
380 .name = "Flow Control",
381 .err = "reading default settings from EEPROM",
382 .def = e1000_fc_default,
383 .arg = { .l = { .nr = ARRAY_SIZE(fc_list),
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;
392 adapter->hw.fc = adapter->hw.original_fc = opt.def;
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),
401 .arg = { .r = { .min = MIN_TXDELAY,
402 .max = MAX_TXDELAY }}
405 if (num_TxIntDelay > bd) {
406 adapter->tx_int_delay = TxIntDelay[bd];
407 e1000_validate_option(&adapter->tx_int_delay, &opt,
410 adapter->tx_int_delay = opt.def;
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),
419 .arg = { .r = { .min = MIN_TXABSDELAY,
420 .max = MAX_TXABSDELAY }}
423 if (num_TxAbsIntDelay > bd) {
424 adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
425 e1000_validate_option(&adapter->tx_abs_int_delay, &opt,
428 adapter->tx_abs_int_delay = opt.def;
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),
437 .arg = { .r = { .min = MIN_RXDELAY,
438 .max = MAX_RXDELAY }}
441 if (num_RxIntDelay > bd) {
442 adapter->rx_int_delay = RxIntDelay[bd];
443 e1000_validate_option(&adapter->rx_int_delay, &opt,
446 adapter->rx_int_delay = opt.def;
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),
455 .arg = { .r = { .min = MIN_RXABSDELAY,
456 .max = MAX_RXABSDELAY }}
459 if (num_RxAbsIntDelay > bd) {
460 adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
461 e1000_validate_option(&adapter->rx_abs_int_delay, &opt,
464 adapter->rx_abs_int_delay = opt.def;
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),
473 .arg = { .r = { .min = MIN_ITR,
477 if (num_InterruptThrottleRate > bd) {
478 adapter->itr = InterruptThrottleRate[bd];
479 switch (adapter->itr) {
481 DPRINTK(PROBE, INFO, "%s turned off\n",
485 DPRINTK(PROBE, INFO, "%s set to dynamic mode\n",
489 e1000_validate_option(&adapter->itr, &opt,
494 adapter->itr = opt.def;
498 switch (adapter->hw.media_type) {
499 case e1000_media_type_fiber:
500 case e1000_media_type_internal_serdes:
501 e1000_check_fiber_options(adapter);
503 case e1000_media_type_copper:
504 e1000_check_copper_options(adapter);
512 * e1000_check_fiber_options - Range Checking for Link Options, Fiber Version
513 * @adapter: board private structure
515 * Handles speed and duplex options on fiber adapters
518 static void __devinit
519 e1000_check_fiber_options(struct e1000_adapter *adapter)
521 int bd = adapter->bd_number;
522 if (num_Speed > bd) {
523 DPRINTK(PROBE, INFO, "Speed not valid for fiber adapters, "
524 "parameter ignored\n");
527 if (num_Duplex > bd) {
528 DPRINTK(PROBE, INFO, "Duplex not valid for fiber adapters, "
529 "parameter ignored\n");
532 if ((num_AutoNeg > bd) && (AutoNeg[bd] != 0x20)) {
533 DPRINTK(PROBE, INFO, "AutoNeg other than 1000/Full is "
534 "not valid for fiber adapters, "
535 "parameter ignored\n");
540 * e1000_check_copper_options - Range Checking for Link Options, Copper Version
541 * @adapter: board private structure
543 * Handles speed and duplex options on copper adapters
546 static void __devinit
547 e1000_check_copper_options(struct e1000_adapter *adapter)
550 int bd = adapter->bd_number;
553 struct e1000_opt_list speed_list[] = {{ 0, "" },
558 struct e1000_option opt = {
561 .err = "parameter ignored",
563 .arg = { .l = { .nr = ARRAY_SIZE(speed_list),
567 if (num_Speed > bd) {
569 e1000_validate_option(&speed, &opt, adapter);
575 struct e1000_opt_list dplx_list[] = {{ 0, "" },
577 { FULL_DUPLEX, "" }};
579 struct e1000_option opt = {
582 .err = "parameter ignored",
584 .arg = { .l = { .nr = ARRAY_SIZE(dplx_list),
588 if (e1000_check_phy_reset_block(&adapter->hw)) {
590 "Link active due to SoL/IDER Session. "
591 "Speed/Duplex/AutoNeg parameter ignored.\n");
594 if (num_Duplex > bd) {
596 e1000_validate_option(&dplx, &opt, adapter);
602 if ((num_AutoNeg > bd) && (speed != 0 || dplx != 0)) {
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" }};
642 struct e1000_option opt = {
645 .err = "parameter ignored",
646 .def = AUTONEG_ADV_DEFAULT,
647 .arg = { .l = { .nr = ARRAY_SIZE(an_list),
651 if (num_AutoNeg > bd) {
653 e1000_validate_option(&an, &opt, adapter);
657 adapter->hw.autoneg_advertised = an;
660 switch (speed + dplx) {
662 adapter->hw.autoneg = adapter->fc_autoneg = 1;
663 if ((num_Speed > bd) && (speed != 0 || dplx != 0))
665 "Speed and duplex autonegotiation enabled\n");
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 |
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 |
685 DPRINTK(PROBE, INFO, "10 Mbps Speed specified "
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 |
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;
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;
705 DPRINTK(PROBE, INFO, "100 Mbps Speed specified "
707 DPRINTK(PROBE, INFO, "Using Autonegotiation at "
709 adapter->hw.autoneg = adapter->fc_autoneg = 1;
710 adapter->hw.autoneg_advertised = ADVERTISE_100_HALF |
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;
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;
726 DPRINTK(PROBE, INFO, "1000 Mbps Speed specified without "
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;
734 case SPEED_1000 + HALF_DUPLEX:
736 "Half Duplex is not supported at 1000 Mbps\n");
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;
743 case SPEED_1000 + FULL_DUPLEX:
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;
753 /* Speed, AutoNeg and MDI/MDI-X must all play nice */
754 if (e1000_validate_mdi_setting(&(adapter->hw)) < 0) {
756 "Speed, AutoNeg and MDI-X specifications are "
757 "incompatible. Setting MDI-X to a compatible value.\n");