ch1010832@1992: /*******************************************************************************
ch1010832@1992: 
ch1010832@1992:   Intel PRO/1000 Linux driver
ch1010832@1992:   Copyright(c) 1999 - 2006 Intel Corporation.
ch1010832@1992: 
ch1010832@1992:   This program is free software; you can redistribute it and/or modify it
ch1010832@1992:   under the terms and conditions of the GNU General Public License,
ch1010832@1992:   version 2, as published by the Free Software Foundation.
ch1010832@1992: 
ch1010832@1992:   This program is distributed in the hope it will be useful, but WITHOUT
ch1010832@1992:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ch1010832@1992:   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
ch1010832@1992:   more details.
ch1010832@1992: 
ch1010832@1992:   You should have received a copy of the GNU General Public License along with
ch1010832@1992:   this program; if not, write to the Free Software Foundation, Inc.,
ch1010832@1992:   51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
ch1010832@1992: 
ch1010832@1992:   The full GNU General Public License is included in this distribution in
ch1010832@1992:   the file called "COPYING".
ch1010832@1992: 
ch1010832@1992:   Contact Information:
ch1010832@1992:   Linux NICS <linux.nics@intel.com>
ch1010832@1992:   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
ch1010832@1992:   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
ch1010832@1992: 
ch1010832@1992: *******************************************************************************/
ch1010832@1992: 
ch1010832@1992: #include "e1000-2.6.33-ethercat.h"
ch1010832@1992: 
ch1010832@1992: /* This is the only thing that needs to be changed to adjust the
ch1010832@1992:  * maximum number of ports that the driver can manage.
ch1010832@1992:  */
ch1010832@1992: 
ch1010832@1992: #define E1000_MAX_NIC 32
ch1010832@1992: 
ch1010832@1992: #define OPTION_UNSET   -1
ch1010832@1992: #define OPTION_DISABLED 0
ch1010832@1992: #define OPTION_ENABLED  1
ch1010832@1992: 
ch1010832@1992: /* All parameters are treated the same, as an integer array of values.
ch1010832@1992:  * This macro just reduces the need to repeat the same declaration code
ch1010832@1992:  * over and over (plus this helps to avoid typo bugs).
ch1010832@1992:  */
ch1010832@1992: 
ch1010832@1992: #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
ch1010832@1992: #define E1000_PARAM(X, desc) \
ch1010832@1992: 	static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
ch1010832@1992: 	static unsigned int num_##X; \
ch1010832@1992: 	module_param_array_named(X, X, int, &num_##X, 0); \
ch1010832@1992: 	MODULE_PARM_DESC(X, desc);
ch1010832@1992: 
ch1010832@1992: /* Transmit Descriptor Count
ch1010832@1992:  *
ch1010832@1992:  * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers
ch1010832@1992:  * Valid Range: 80-4096 for 82544 and newer
ch1010832@1992:  *
ch1010832@1992:  * Default Value: 256
ch1010832@1992:  */
ch1010832@1992: E1000_PARAM(TxDescriptors, "Number of transmit descriptors");
ch1010832@1992: 
ch1010832@1992: /* Receive Descriptor Count
ch1010832@1992:  *
ch1010832@1992:  * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers
ch1010832@1992:  * Valid Range: 80-4096 for 82544 and newer
ch1010832@1992:  *
ch1010832@1992:  * Default Value: 256
ch1010832@1992:  */
ch1010832@1992: E1000_PARAM(RxDescriptors, "Number of receive descriptors");
ch1010832@1992: 
ch1010832@1992: /* User Specified Speed Override
ch1010832@1992:  *
ch1010832@1992:  * Valid Range: 0, 10, 100, 1000
ch1010832@1992:  *  - 0    - auto-negotiate at all supported speeds
ch1010832@1992:  *  - 10   - only link at 10 Mbps
ch1010832@1992:  *  - 100  - only link at 100 Mbps
ch1010832@1992:  *  - 1000 - only link at 1000 Mbps
ch1010832@1992:  *
ch1010832@1992:  * Default Value: 0
ch1010832@1992:  */
ch1010832@1992: E1000_PARAM(Speed, "Speed setting");
ch1010832@1992: 
ch1010832@1992: /* User Specified Duplex Override
ch1010832@1992:  *
ch1010832@1992:  * Valid Range: 0-2
ch1010832@1992:  *  - 0 - auto-negotiate for duplex
ch1010832@1992:  *  - 1 - only link at half duplex
ch1010832@1992:  *  - 2 - only link at full duplex
ch1010832@1992:  *
ch1010832@1992:  * Default Value: 0
ch1010832@1992:  */
ch1010832@1992: E1000_PARAM(Duplex, "Duplex setting");
ch1010832@1992: 
ch1010832@1992: /* Auto-negotiation Advertisement Override
ch1010832@1992:  *
ch1010832@1992:  * Valid Range: 0x01-0x0F, 0x20-0x2F (copper); 0x20 (fiber)
ch1010832@1992:  *
ch1010832@1992:  * The AutoNeg value is a bit mask describing which speed and duplex
ch1010832@1992:  * combinations should be advertised during auto-negotiation.
ch1010832@1992:  * The supported speed and duplex modes are listed below
ch1010832@1992:  *
ch1010832@1992:  * Bit           7     6     5      4      3     2     1      0
ch1010832@1992:  * Speed (Mbps)  N/A   N/A   1000   N/A    100   100   10     10
ch1010832@1992:  * Duplex                    Full          Full  Half  Full   Half
ch1010832@1992:  *
ch1010832@1992:  * Default Value: 0x2F (copper); 0x20 (fiber)
ch1010832@1992:  */
ch1010832@1992: E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting");
ch1010832@1992: #define AUTONEG_ADV_DEFAULT  0x2F
ch1010832@1992: #define AUTONEG_ADV_MASK     0x2F
ch1010832@1992: 
ch1010832@1992: /* User Specified Flow Control Override
ch1010832@1992:  *
ch1010832@1992:  * Valid Range: 0-3
ch1010832@1992:  *  - 0 - No Flow Control
ch1010832@1992:  *  - 1 - Rx only, respond to PAUSE frames but do not generate them
ch1010832@1992:  *  - 2 - Tx only, generate PAUSE frames but ignore them on receive
ch1010832@1992:  *  - 3 - Full Flow Control Support
ch1010832@1992:  *
ch1010832@1992:  * Default Value: Read flow control settings from the EEPROM
ch1010832@1992:  */
ch1010832@1992: E1000_PARAM(FlowControl, "Flow Control setting");
ch1010832@1992: #define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
ch1010832@1992: 
ch1010832@1992: /* XsumRX - Receive Checksum Offload Enable/Disable
ch1010832@1992:  *
ch1010832@1992:  * Valid Range: 0, 1
ch1010832@1992:  *  - 0 - disables all checksum offload
ch1010832@1992:  *  - 1 - enables receive IP/TCP/UDP checksum offload
ch1010832@1992:  *        on 82543 and newer -based NICs
ch1010832@1992:  *
ch1010832@1992:  * Default Value: 1
ch1010832@1992:  */
ch1010832@1992: E1000_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
ch1010832@1992: 
ch1010832@1992: /* Transmit Interrupt Delay in units of 1.024 microseconds
ch1010832@1992:  *  Tx interrupt delay needs to typically be set to something non zero
ch1010832@1992:  *
ch1010832@1992:  * Valid Range: 0-65535
ch1010832@1992:  */
ch1010832@1992: E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
ch1010832@1992: #define DEFAULT_TIDV                   8
ch1010832@1992: #define MAX_TXDELAY               0xFFFF
ch1010832@1992: #define MIN_TXDELAY                    0
ch1010832@1992: 
ch1010832@1992: /* Transmit Absolute Interrupt Delay in units of 1.024 microseconds
ch1010832@1992:  *
ch1010832@1992:  * Valid Range: 0-65535
ch1010832@1992:  */
ch1010832@1992: E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
ch1010832@1992: #define DEFAULT_TADV                  32
ch1010832@1992: #define MAX_TXABSDELAY            0xFFFF
ch1010832@1992: #define MIN_TXABSDELAY                 0
ch1010832@1992: 
ch1010832@1992: /* Receive Interrupt Delay in units of 1.024 microseconds
ch1010832@1992:  *   hardware will likely hang if you set this to anything but zero.
ch1010832@1992:  *
ch1010832@1992:  * Valid Range: 0-65535
ch1010832@1992:  */
ch1010832@1992: E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
ch1010832@1992: #define DEFAULT_RDTR                   0
ch1010832@1992: #define MAX_RXDELAY               0xFFFF
ch1010832@1992: #define MIN_RXDELAY                    0
ch1010832@1992: 
ch1010832@1992: /* Receive Absolute Interrupt Delay in units of 1.024 microseconds
ch1010832@1992:  *
ch1010832@1992:  * Valid Range: 0-65535
ch1010832@1992:  */
ch1010832@1992: E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
ch1010832@1992: #define DEFAULT_RADV                   8
ch1010832@1992: #define MAX_RXABSDELAY            0xFFFF
ch1010832@1992: #define MIN_RXABSDELAY                 0
ch1010832@1992: 
ch1010832@1992: /* Interrupt Throttle Rate (interrupts/sec)
ch1010832@1992:  *
ch1010832@1992:  * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative)
ch1010832@1992:  */
ch1010832@1992: E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
ch1010832@1992: #define DEFAULT_ITR                    3
ch1010832@1992: #define MAX_ITR                   100000
ch1010832@1992: #define MIN_ITR                      100
ch1010832@1992: 
ch1010832@1992: /* Enable Smart Power Down of the PHY
ch1010832@1992:  *
ch1010832@1992:  * Valid Range: 0, 1
ch1010832@1992:  *
ch1010832@1992:  * Default Value: 0 (disabled)
ch1010832@1992:  */
ch1010832@1992: E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
ch1010832@1992: 
ch1010832@1992: /* Enable Kumeran Lock Loss workaround
ch1010832@1992:  *
ch1010832@1992:  * Valid Range: 0, 1
ch1010832@1992:  *
ch1010832@1992:  * Default Value: 1 (enabled)
ch1010832@1992:  */
ch1010832@1992: E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");
ch1010832@1992: 
ch1010832@1992: struct e1000_option {
ch1010832@1992: 	enum { enable_option, range_option, list_option } type;
ch1010832@1992: 	const char *name;
ch1010832@1992: 	const char *err;
ch1010832@1992: 	int def;
ch1010832@1992: 	union {
ch1010832@1992: 		struct { /* range_option info */
ch1010832@1992: 			int min;
ch1010832@1992: 			int max;
ch1010832@1992: 		} r;
ch1010832@1992: 		struct { /* list_option info */
ch1010832@1992: 			int nr;
ch1010832@1992: 			const struct e1000_opt_list { int i; char *str; } *p;
ch1010832@1992: 		} l;
ch1010832@1992: 	} arg;
ch1010832@1992: };
ch1010832@1992: 
ch1010832@1992: static int __devinit e1000_validate_option(unsigned int *value,
ch1010832@1992: 					   const struct e1000_option *opt,
ch1010832@1992: 					   struct e1000_adapter *adapter)
ch1010832@1992: {
ch1010832@1992: 	if (*value == OPTION_UNSET) {
ch1010832@1992: 		*value = opt->def;
ch1010832@1992: 		return 0;
ch1010832@1992: 	}
ch1010832@1992: 
ch1010832@1992: 	switch (opt->type) {
ch1010832@1992: 	case enable_option:
ch1010832@1992: 		switch (*value) {
ch1010832@1992: 		case OPTION_ENABLED:
ch1010832@1992: 			DPRINTK(PROBE, INFO, "%s Enabled\n", opt->name);
ch1010832@1992: 			return 0;
ch1010832@1992: 		case OPTION_DISABLED:
ch1010832@1992: 			DPRINTK(PROBE, INFO, "%s Disabled\n", opt->name);
ch1010832@1992: 			return 0;
ch1010832@1992: 		}
ch1010832@1992: 		break;
ch1010832@1992: 	case range_option:
ch1010832@1992: 		if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
ch1010832@1992: 			DPRINTK(PROBE, INFO,
ch1010832@1992: 					"%s set to %i\n", opt->name, *value);
ch1010832@1992: 			return 0;
ch1010832@1992: 		}
ch1010832@1992: 		break;
ch1010832@1992: 	case list_option: {
ch1010832@1992: 		int i;
ch1010832@1992: 		const struct e1000_opt_list *ent;
ch1010832@1992: 
ch1010832@1992: 		for (i = 0; i < opt->arg.l.nr; i++) {
ch1010832@1992: 			ent = &opt->arg.l.p[i];
ch1010832@1992: 			if (*value == ent->i) {
ch1010832@1992: 				if (ent->str[0] != '\0')
ch1010832@1992: 					DPRINTK(PROBE, INFO, "%s\n", ent->str);
ch1010832@1992: 				return 0;
ch1010832@1992: 			}
ch1010832@1992: 		}
ch1010832@1992: 	}
ch1010832@1992: 		break;
ch1010832@1992: 	default:
ch1010832@1992: 		BUG();
ch1010832@1992: 	}
ch1010832@1992: 
ch1010832@1992: 	DPRINTK(PROBE, INFO, "Invalid %s value specified (%i) %s\n",
ch1010832@1992: 	       opt->name, *value, opt->err);
ch1010832@1992: 	*value = opt->def;
ch1010832@1992: 	return -1;
ch1010832@1992: }
ch1010832@1992: 
ch1010832@1992: static void e1000_check_fiber_options(struct e1000_adapter *adapter);
ch1010832@1992: static void e1000_check_copper_options(struct e1000_adapter *adapter);
ch1010832@1992: 
ch1010832@1992: /**
ch1010832@1992:  * e1000_check_options - Range Checking for Command Line Parameters
ch1010832@1992:  * @adapter: board private structure
ch1010832@1992:  *
ch1010832@1992:  * This routine checks all command line parameters for valid user
ch1010832@1992:  * input.  If an invalid value is given, or if no user specified
ch1010832@1992:  * value exists, a default value is used.  The final value is stored
ch1010832@1992:  * in a variable in the adapter structure.
ch1010832@1992:  **/
ch1010832@1992: 
ch1010832@1992: void __devinit e1000_check_options(struct e1000_adapter *adapter)
ch1010832@1992: {
ch1010832@1992: 	struct e1000_option opt;
ch1010832@1992: 	int bd = adapter->bd_number;
ch1010832@1992: 
ch1010832@1992: 	if (bd >= E1000_MAX_NIC) {
ch1010832@1992: 		DPRINTK(PROBE, NOTICE,
ch1010832@1992: 		       "Warning: no configuration for board #%i\n", bd);
ch1010832@1992: 		DPRINTK(PROBE, NOTICE, "Using defaults for all values\n");
ch1010832@1992: 	}
ch1010832@1992: 
ch1010832@1992: 	{ /* Transmit Descriptor Count */
ch1010832@1992: 		struct e1000_tx_ring *tx_ring = adapter->tx_ring;
ch1010832@1992: 		int i;
ch1010832@1992: 		e1000_mac_type mac_type = adapter->hw.mac_type;
ch1010832@1992: 
ch1010832@1992: 		opt = (struct e1000_option) {
ch1010832@1992: 			.type = range_option,
ch1010832@1992: 			.name = "Transmit Descriptors",
ch1010832@1992: 			.err  = "using default of "
ch1010832@1992: 				__MODULE_STRING(E1000_DEFAULT_TXD),
ch1010832@1992: 			.def  = E1000_DEFAULT_TXD,
ch1010832@1992: 			.arg  = { .r = {
ch1010832@1992: 				.min = E1000_MIN_TXD,
ch1010832@1992: 				.max = mac_type < e1000_82544 ? E1000_MAX_TXD : E1000_MAX_82544_TXD
ch1010832@1992: 				}}
ch1010832@1992: 		};
ch1010832@1992: 
ch1010832@1992: 		if (num_TxDescriptors > bd) {
ch1010832@1992: 			tx_ring->count = TxDescriptors[bd];
ch1010832@1992: 			e1000_validate_option(&tx_ring->count, &opt, adapter);
ch1010832@1992: 			tx_ring->count = ALIGN(tx_ring->count,
ch1010832@1992: 						REQ_TX_DESCRIPTOR_MULTIPLE);
ch1010832@1992: 		} else {
ch1010832@1992: 			tx_ring->count = opt.def;
ch1010832@1992: 		}
ch1010832@1992: 		for (i = 0; i < adapter->num_tx_queues; i++)
ch1010832@1992: 			tx_ring[i].count = tx_ring->count;
ch1010832@1992: 	}
ch1010832@1992: 	{ /* Receive Descriptor Count */
ch1010832@1992: 		struct e1000_rx_ring *rx_ring = adapter->rx_ring;
ch1010832@1992: 		int i;
ch1010832@1992: 		e1000_mac_type mac_type = adapter->hw.mac_type;
ch1010832@1992: 
ch1010832@1992: 		opt = (struct e1000_option) {
ch1010832@1992: 			.type = range_option,
ch1010832@1992: 			.name = "Receive Descriptors",
ch1010832@1992: 			.err  = "using default of "
ch1010832@1992: 				__MODULE_STRING(E1000_DEFAULT_RXD),
ch1010832@1992: 			.def  = E1000_DEFAULT_RXD,
ch1010832@1992: 			.arg  = { .r = {
ch1010832@1992: 				.min = E1000_MIN_RXD,
ch1010832@1992: 				.max = mac_type < e1000_82544 ? E1000_MAX_RXD : E1000_MAX_82544_RXD
ch1010832@1992: 			}}
ch1010832@1992: 		};
ch1010832@1992: 
ch1010832@1992: 		if (num_RxDescriptors > bd) {
ch1010832@1992: 			rx_ring->count = RxDescriptors[bd];
ch1010832@1992: 			e1000_validate_option(&rx_ring->count, &opt, adapter);
ch1010832@1992: 			rx_ring->count = ALIGN(rx_ring->count,
ch1010832@1992: 						REQ_RX_DESCRIPTOR_MULTIPLE);
ch1010832@1992: 		} else {
ch1010832@1992: 			rx_ring->count = opt.def;
ch1010832@1992: 		}
ch1010832@1992: 		for (i = 0; i < adapter->num_rx_queues; i++)
ch1010832@1992: 			rx_ring[i].count = rx_ring->count;
ch1010832@1992: 	}
ch1010832@1992: 	{ /* Checksum Offload Enable/Disable */
ch1010832@1992: 		opt = (struct e1000_option) {
ch1010832@1992: 			.type = enable_option,
ch1010832@1992: 			.name = "Checksum Offload",
ch1010832@1992: 			.err  = "defaulting to Enabled",
ch1010832@1992: 			.def  = OPTION_ENABLED
ch1010832@1992: 		};
ch1010832@1992: 
ch1010832@1992: 		if (num_XsumRX > bd) {
ch1010832@1992: 			unsigned int rx_csum = XsumRX[bd];
ch1010832@1992: 			e1000_validate_option(&rx_csum, &opt, adapter);
ch1010832@1992: 			adapter->rx_csum = rx_csum;
ch1010832@1992: 		} else {
ch1010832@1992: 			adapter->rx_csum = opt.def;
ch1010832@1992: 		}
ch1010832@1992: 	}
ch1010832@1992: 	{ /* Flow Control */
ch1010832@1992: 
ch1010832@1992: 		struct e1000_opt_list fc_list[] =
ch1010832@1992: 			{{ E1000_FC_NONE,    "Flow Control Disabled" },
ch1010832@1992: 			 { E1000_FC_RX_PAUSE,"Flow Control Receive Only" },
ch1010832@1992: 			 { E1000_FC_TX_PAUSE,"Flow Control Transmit Only" },
ch1010832@1992: 			 { E1000_FC_FULL,    "Flow Control Enabled" },
ch1010832@1992: 			 { E1000_FC_DEFAULT, "Flow Control Hardware Default" }};
ch1010832@1992: 
ch1010832@1992: 		opt = (struct e1000_option) {
ch1010832@1992: 			.type = list_option,
ch1010832@1992: 			.name = "Flow Control",
ch1010832@1992: 			.err  = "reading default settings from EEPROM",
ch1010832@1992: 			.def  = E1000_FC_DEFAULT,
ch1010832@1992: 			.arg  = { .l = { .nr = ARRAY_SIZE(fc_list),
ch1010832@1992: 					 .p = fc_list }}
ch1010832@1992: 		};
ch1010832@1992: 
ch1010832@1992: 		if (num_FlowControl > bd) {
ch1010832@1992: 			unsigned int fc = FlowControl[bd];
ch1010832@1992: 			e1000_validate_option(&fc, &opt, adapter);
ch1010832@1992: 			adapter->hw.fc = adapter->hw.original_fc = fc;
ch1010832@1992: 		} else {
ch1010832@1992: 			adapter->hw.fc = adapter->hw.original_fc = opt.def;
ch1010832@1992: 		}
ch1010832@1992: 	}
ch1010832@1992: 	{ /* Transmit Interrupt Delay */
ch1010832@1992: 		opt = (struct e1000_option) {
ch1010832@1992: 			.type = range_option,
ch1010832@1992: 			.name = "Transmit Interrupt Delay",
ch1010832@1992: 			.err  = "using default of " __MODULE_STRING(DEFAULT_TIDV),
ch1010832@1992: 			.def  = DEFAULT_TIDV,
ch1010832@1992: 			.arg  = { .r = { .min = MIN_TXDELAY,
ch1010832@1992: 					 .max = MAX_TXDELAY }}
ch1010832@1992: 		};
ch1010832@1992: 
ch1010832@1992: 		if (num_TxIntDelay > bd) {
ch1010832@1992: 			adapter->tx_int_delay = TxIntDelay[bd];
ch1010832@1992: 			e1000_validate_option(&adapter->tx_int_delay, &opt,
ch1010832@1992: 			                      adapter);
ch1010832@1992: 		} else {
ch1010832@1992: 			adapter->tx_int_delay = opt.def;
ch1010832@1992: 		}
ch1010832@1992: 	}
ch1010832@1992: 	{ /* Transmit Absolute Interrupt Delay */
ch1010832@1992: 		opt = (struct e1000_option) {
ch1010832@1992: 			.type = range_option,
ch1010832@1992: 			.name = "Transmit Absolute Interrupt Delay",
ch1010832@1992: 			.err  = "using default of " __MODULE_STRING(DEFAULT_TADV),
ch1010832@1992: 			.def  = DEFAULT_TADV,
ch1010832@1992: 			.arg  = { .r = { .min = MIN_TXABSDELAY,
ch1010832@1992: 					 .max = MAX_TXABSDELAY }}
ch1010832@1992: 		};
ch1010832@1992: 
ch1010832@1992: 		if (num_TxAbsIntDelay > bd) {
ch1010832@1992: 			adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
ch1010832@1992: 			e1000_validate_option(&adapter->tx_abs_int_delay, &opt,
ch1010832@1992: 			                      adapter);
ch1010832@1992: 		} else {
ch1010832@1992: 			adapter->tx_abs_int_delay = opt.def;
ch1010832@1992: 		}
ch1010832@1992: 	}
ch1010832@1992: 	{ /* Receive Interrupt Delay */
ch1010832@1992: 		opt = (struct e1000_option) {
ch1010832@1992: 			.type = range_option,
ch1010832@1992: 			.name = "Receive Interrupt Delay",
ch1010832@1992: 			.err  = "using default of " __MODULE_STRING(DEFAULT_RDTR),
ch1010832@1992: 			.def  = DEFAULT_RDTR,
ch1010832@1992: 			.arg  = { .r = { .min = MIN_RXDELAY,
ch1010832@1992: 					 .max = MAX_RXDELAY }}
ch1010832@1992: 		};
ch1010832@1992: 
ch1010832@1992: 		if (num_RxIntDelay > bd) {
ch1010832@1992: 			adapter->rx_int_delay = RxIntDelay[bd];
ch1010832@1992: 			e1000_validate_option(&adapter->rx_int_delay, &opt,
ch1010832@1992: 			                      adapter);
ch1010832@1992: 		} else {
ch1010832@1992: 			adapter->rx_int_delay = opt.def;
ch1010832@1992: 		}
ch1010832@1992: 	}
ch1010832@1992: 	{ /* Receive Absolute Interrupt Delay */
ch1010832@1992: 		opt = (struct e1000_option) {
ch1010832@1992: 			.type = range_option,
ch1010832@1992: 			.name = "Receive Absolute Interrupt Delay",
ch1010832@1992: 			.err  = "using default of " __MODULE_STRING(DEFAULT_RADV),
ch1010832@1992: 			.def  = DEFAULT_RADV,
ch1010832@1992: 			.arg  = { .r = { .min = MIN_RXABSDELAY,
ch1010832@1992: 					 .max = MAX_RXABSDELAY }}
ch1010832@1992: 		};
ch1010832@1992: 
ch1010832@1992: 		if (num_RxAbsIntDelay > bd) {
ch1010832@1992: 			adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
ch1010832@1992: 			e1000_validate_option(&adapter->rx_abs_int_delay, &opt,
ch1010832@1992: 			                      adapter);
ch1010832@1992: 		} else {
ch1010832@1992: 			adapter->rx_abs_int_delay = opt.def;
ch1010832@1992: 		}
ch1010832@1992: 	}
ch1010832@1992: 	{ /* Interrupt Throttling Rate */
ch1010832@1992: 		opt = (struct e1000_option) {
ch1010832@1992: 			.type = range_option,
ch1010832@1992: 			.name = "Interrupt Throttling Rate (ints/sec)",
ch1010832@1992: 			.err  = "using default of " __MODULE_STRING(DEFAULT_ITR),
ch1010832@1992: 			.def  = DEFAULT_ITR,
ch1010832@1992: 			.arg  = { .r = { .min = MIN_ITR,
ch1010832@1992: 					 .max = MAX_ITR }}
ch1010832@1992: 		};
ch1010832@1992: 
ch1010832@1992: 		if (num_InterruptThrottleRate > bd) {
ch1010832@1992: 			adapter->itr = InterruptThrottleRate[bd];
ch1010832@1992: 			switch (adapter->itr) {
ch1010832@1992: 			case 0:
ch1010832@1992: 				DPRINTK(PROBE, INFO, "%s turned off\n",
ch1010832@1992: 				        opt.name);
ch1010832@1992: 				break;
ch1010832@1992: 			case 1:
ch1010832@1992: 				DPRINTK(PROBE, INFO, "%s set to dynamic mode\n",
ch1010832@1992: 					opt.name);
ch1010832@1992: 				adapter->itr_setting = adapter->itr;
ch1010832@1992: 				adapter->itr = 20000;
ch1010832@1992: 				break;
ch1010832@1992: 			case 3:
ch1010832@1992: 				DPRINTK(PROBE, INFO,
ch1010832@1992: 				        "%s set to dynamic conservative mode\n",
ch1010832@1992: 					opt.name);
ch1010832@1992: 				adapter->itr_setting = adapter->itr;
ch1010832@1992: 				adapter->itr = 20000;
ch1010832@1992: 				break;
ch1010832@1992: 			default:
ch1010832@1992: 				e1000_validate_option(&adapter->itr, &opt,
ch1010832@1992: 				        adapter);
ch1010832@1992: 				/* save the setting, because the dynamic bits change itr */
ch1010832@1992: 				/* clear the lower two bits because they are
ch1010832@1992: 				 * used as control */
ch1010832@1992: 				adapter->itr_setting = adapter->itr & ~3;
ch1010832@1992: 				break;
ch1010832@1992: 			}
ch1010832@1992: 		} else {
ch1010832@1992: 			adapter->itr_setting = opt.def;
ch1010832@1992: 			adapter->itr = 20000;
ch1010832@1992: 		}
ch1010832@1992: 	}
ch1010832@1992: 	{ /* Smart Power Down */
ch1010832@1992: 		opt = (struct e1000_option) {
ch1010832@1992: 			.type = enable_option,
ch1010832@1992: 			.name = "PHY Smart Power Down",
ch1010832@1992: 			.err  = "defaulting to Disabled",
ch1010832@1992: 			.def  = OPTION_DISABLED
ch1010832@1992: 		};
ch1010832@1992: 
ch1010832@1992: 		if (num_SmartPowerDownEnable > bd) {
ch1010832@1992: 			unsigned int spd = SmartPowerDownEnable[bd];
ch1010832@1992: 			e1000_validate_option(&spd, &opt, adapter);
ch1010832@1992: 			adapter->smart_power_down = spd;
ch1010832@1992: 		} else {
ch1010832@1992: 			adapter->smart_power_down = opt.def;
ch1010832@1992: 		}
ch1010832@1992: 	}
ch1010832@1992: 
ch1010832@1992: 	switch (adapter->hw.media_type) {
ch1010832@1992: 	case e1000_media_type_fiber:
ch1010832@1992: 	case e1000_media_type_internal_serdes:
ch1010832@1992: 		e1000_check_fiber_options(adapter);
ch1010832@1992: 		break;
ch1010832@1992: 	case e1000_media_type_copper:
ch1010832@1992: 		e1000_check_copper_options(adapter);
ch1010832@1992: 		break;
ch1010832@1992: 	default:
ch1010832@1992: 		BUG();
ch1010832@1992: 	}
ch1010832@1992: }
ch1010832@1992: 
ch1010832@1992: /**
ch1010832@1992:  * e1000_check_fiber_options - Range Checking for Link Options, Fiber Version
ch1010832@1992:  * @adapter: board private structure
ch1010832@1992:  *
ch1010832@1992:  * Handles speed and duplex options on fiber adapters
ch1010832@1992:  **/
ch1010832@1992: 
ch1010832@1992: static void __devinit e1000_check_fiber_options(struct e1000_adapter *adapter)
ch1010832@1992: {
ch1010832@1992: 	int bd = adapter->bd_number;
ch1010832@1992: 	if (num_Speed > bd) {
ch1010832@1992: 		DPRINTK(PROBE, INFO, "Speed not valid for fiber adapters, "
ch1010832@1992: 		       "parameter ignored\n");
ch1010832@1992: 	}
ch1010832@1992: 
ch1010832@1992: 	if (num_Duplex > bd) {
ch1010832@1992: 		DPRINTK(PROBE, INFO, "Duplex not valid for fiber adapters, "
ch1010832@1992: 		       "parameter ignored\n");
ch1010832@1992: 	}
ch1010832@1992: 
ch1010832@1992: 	if ((num_AutoNeg > bd) && (AutoNeg[bd] != 0x20)) {
ch1010832@1992: 		DPRINTK(PROBE, INFO, "AutoNeg other than 1000/Full is "
ch1010832@1992: 				 "not valid for fiber adapters, "
ch1010832@1992: 				 "parameter ignored\n");
ch1010832@1992: 	}
ch1010832@1992: }
ch1010832@1992: 
ch1010832@1992: /**
ch1010832@1992:  * e1000_check_copper_options - Range Checking for Link Options, Copper Version
ch1010832@1992:  * @adapter: board private structure
ch1010832@1992:  *
ch1010832@1992:  * Handles speed and duplex options on copper adapters
ch1010832@1992:  **/
ch1010832@1992: 
ch1010832@1992: static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter)
ch1010832@1992: {
ch1010832@1992: 	struct e1000_option opt;
ch1010832@1992: 	unsigned int speed, dplx, an;
ch1010832@1992: 	int bd = adapter->bd_number;
ch1010832@1992: 
ch1010832@1992: 	{ /* Speed */
ch1010832@1992: 		static const struct e1000_opt_list speed_list[] = {
ch1010832@1992: 			{          0, "" },
ch1010832@1992: 			{   SPEED_10, "" },
ch1010832@1992: 			{  SPEED_100, "" },
ch1010832@1992: 			{ SPEED_1000, "" }};
ch1010832@1992: 
ch1010832@1992: 		opt = (struct e1000_option) {
ch1010832@1992: 			.type = list_option,
ch1010832@1992: 			.name = "Speed",
ch1010832@1992: 			.err  = "parameter ignored",
ch1010832@1992: 			.def  = 0,
ch1010832@1992: 			.arg  = { .l = { .nr = ARRAY_SIZE(speed_list),
ch1010832@1992: 					 .p = speed_list }}
ch1010832@1992: 		};
ch1010832@1992: 
ch1010832@1992: 		if (num_Speed > bd) {
ch1010832@1992: 			speed = Speed[bd];
ch1010832@1992: 			e1000_validate_option(&speed, &opt, adapter);
ch1010832@1992: 		} else {
ch1010832@1992: 			speed = opt.def;
ch1010832@1992: 		}
ch1010832@1992: 	}
ch1010832@1992: 	{ /* Duplex */
ch1010832@1992: 		static const struct e1000_opt_list dplx_list[] = {
ch1010832@1992: 			{           0, "" },
ch1010832@1992: 			{ HALF_DUPLEX, "" },
ch1010832@1992: 			{ FULL_DUPLEX, "" }};
ch1010832@1992: 
ch1010832@1992: 		opt = (struct e1000_option) {
ch1010832@1992: 			.type = list_option,
ch1010832@1992: 			.name = "Duplex",
ch1010832@1992: 			.err  = "parameter ignored",
ch1010832@1992: 			.def  = 0,
ch1010832@1992: 			.arg  = { .l = { .nr = ARRAY_SIZE(dplx_list),
ch1010832@1992: 					 .p = dplx_list }}
ch1010832@1992: 		};
ch1010832@1992: 
ch1010832@1992: 		if (num_Duplex > bd) {
ch1010832@1992: 			dplx = Duplex[bd];
ch1010832@1992: 			e1000_validate_option(&dplx, &opt, adapter);
ch1010832@1992: 		} else {
ch1010832@1992: 			dplx = opt.def;
ch1010832@1992: 		}
ch1010832@1992: 	}
ch1010832@1992: 
ch1010832@1992: 	if ((num_AutoNeg > bd) && (speed != 0 || dplx != 0)) {
ch1010832@1992: 		DPRINTK(PROBE, INFO,
ch1010832@1992: 		       "AutoNeg specified along with Speed or Duplex, "
ch1010832@1992: 		       "parameter ignored\n");
ch1010832@1992: 		adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT;
ch1010832@1992: 	} else { /* Autoneg */
ch1010832@1992: 		static const struct e1000_opt_list an_list[] =
ch1010832@1992: 			#define AA "AutoNeg advertising "
ch1010832@1992: 			{{ 0x01, AA "10/HD" },
ch1010832@1992: 			 { 0x02, AA "10/FD" },
ch1010832@1992: 			 { 0x03, AA "10/FD, 10/HD" },
ch1010832@1992: 			 { 0x04, AA "100/HD" },
ch1010832@1992: 			 { 0x05, AA "100/HD, 10/HD" },
ch1010832@1992: 			 { 0x06, AA "100/HD, 10/FD" },
ch1010832@1992: 			 { 0x07, AA "100/HD, 10/FD, 10/HD" },
ch1010832@1992: 			 { 0x08, AA "100/FD" },
ch1010832@1992: 			 { 0x09, AA "100/FD, 10/HD" },
ch1010832@1992: 			 { 0x0a, AA "100/FD, 10/FD" },
ch1010832@1992: 			 { 0x0b, AA "100/FD, 10/FD, 10/HD" },
ch1010832@1992: 			 { 0x0c, AA "100/FD, 100/HD" },
ch1010832@1992: 			 { 0x0d, AA "100/FD, 100/HD, 10/HD" },
ch1010832@1992: 			 { 0x0e, AA "100/FD, 100/HD, 10/FD" },
ch1010832@1992: 			 { 0x0f, AA "100/FD, 100/HD, 10/FD, 10/HD" },
ch1010832@1992: 			 { 0x20, AA "1000/FD" },
ch1010832@1992: 			 { 0x21, AA "1000/FD, 10/HD" },
ch1010832@1992: 			 { 0x22, AA "1000/FD, 10/FD" },
ch1010832@1992: 			 { 0x23, AA "1000/FD, 10/FD, 10/HD" },
ch1010832@1992: 			 { 0x24, AA "1000/FD, 100/HD" },
ch1010832@1992: 			 { 0x25, AA "1000/FD, 100/HD, 10/HD" },
ch1010832@1992: 			 { 0x26, AA "1000/FD, 100/HD, 10/FD" },
ch1010832@1992: 			 { 0x27, AA "1000/FD, 100/HD, 10/FD, 10/HD" },
ch1010832@1992: 			 { 0x28, AA "1000/FD, 100/FD" },
ch1010832@1992: 			 { 0x29, AA "1000/FD, 100/FD, 10/HD" },
ch1010832@1992: 			 { 0x2a, AA "1000/FD, 100/FD, 10/FD" },
ch1010832@1992: 			 { 0x2b, AA "1000/FD, 100/FD, 10/FD, 10/HD" },
ch1010832@1992: 			 { 0x2c, AA "1000/FD, 100/FD, 100/HD" },
ch1010832@1992: 			 { 0x2d, AA "1000/FD, 100/FD, 100/HD, 10/HD" },
ch1010832@1992: 			 { 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" },
ch1010832@1992: 			 { 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }};
ch1010832@1992: 
ch1010832@1992: 		opt = (struct e1000_option) {
ch1010832@1992: 			.type = list_option,
ch1010832@1992: 			.name = "AutoNeg",
ch1010832@1992: 			.err  = "parameter ignored",
ch1010832@1992: 			.def  = AUTONEG_ADV_DEFAULT,
ch1010832@1992: 			.arg  = { .l = { .nr = ARRAY_SIZE(an_list),
ch1010832@1992: 					 .p = an_list }}
ch1010832@1992: 		};
ch1010832@1992: 
ch1010832@1992: 		if (num_AutoNeg > bd) {
ch1010832@1992: 			an = AutoNeg[bd];
ch1010832@1992: 			e1000_validate_option(&an, &opt, adapter);
ch1010832@1992: 		} else {
ch1010832@1992: 			an = opt.def;
ch1010832@1992: 		}
ch1010832@1992: 		adapter->hw.autoneg_advertised = an;
ch1010832@1992: 	}
ch1010832@1992: 
ch1010832@1992: 	switch (speed + dplx) {
ch1010832@1992: 	case 0:
ch1010832@1992: 		adapter->hw.autoneg = adapter->fc_autoneg = 1;
ch1010832@1992: 		if ((num_Speed > bd) && (speed != 0 || dplx != 0))
ch1010832@1992: 			DPRINTK(PROBE, INFO,
ch1010832@1992: 			       "Speed and duplex autonegotiation enabled\n");
ch1010832@1992: 		break;
ch1010832@1992: 	case HALF_DUPLEX:
ch1010832@1992: 		DPRINTK(PROBE, INFO, "Half Duplex specified without Speed\n");
ch1010832@1992: 		DPRINTK(PROBE, INFO, "Using Autonegotiation at "
ch1010832@1992: 			"Half Duplex only\n");
ch1010832@1992: 		adapter->hw.autoneg = adapter->fc_autoneg = 1;
ch1010832@1992: 		adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
ch1010832@1992: 		                                 ADVERTISE_100_HALF;
ch1010832@1992: 		break;
ch1010832@1992: 	case FULL_DUPLEX:
ch1010832@1992: 		DPRINTK(PROBE, INFO, "Full Duplex specified without Speed\n");
ch1010832@1992: 		DPRINTK(PROBE, INFO, "Using Autonegotiation at "
ch1010832@1992: 			"Full Duplex only\n");
ch1010832@1992: 		adapter->hw.autoneg = adapter->fc_autoneg = 1;
ch1010832@1992: 		adapter->hw.autoneg_advertised = ADVERTISE_10_FULL |
ch1010832@1992: 		                                 ADVERTISE_100_FULL |
ch1010832@1992: 		                                 ADVERTISE_1000_FULL;
ch1010832@1992: 		break;
ch1010832@1992: 	case SPEED_10:
ch1010832@1992: 		DPRINTK(PROBE, INFO, "10 Mbps Speed specified "
ch1010832@1992: 			"without Duplex\n");
ch1010832@1992: 		DPRINTK(PROBE, INFO, "Using Autonegotiation at 10 Mbps only\n");
ch1010832@1992: 		adapter->hw.autoneg = adapter->fc_autoneg = 1;
ch1010832@1992: 		adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
ch1010832@1992: 		                                 ADVERTISE_10_FULL;
ch1010832@1992: 		break;
ch1010832@1992: 	case SPEED_10 + HALF_DUPLEX:
ch1010832@1992: 		DPRINTK(PROBE, INFO, "Forcing to 10 Mbps Half Duplex\n");
ch1010832@1992: 		adapter->hw.autoneg = adapter->fc_autoneg = 0;
ch1010832@1992: 		adapter->hw.forced_speed_duplex = e1000_10_half;
ch1010832@1992: 		adapter->hw.autoneg_advertised = 0;
ch1010832@1992: 		break;
ch1010832@1992: 	case SPEED_10 + FULL_DUPLEX:
ch1010832@1992: 		DPRINTK(PROBE, INFO, "Forcing to 10 Mbps Full Duplex\n");
ch1010832@1992: 		adapter->hw.autoneg = adapter->fc_autoneg = 0;
ch1010832@1992: 		adapter->hw.forced_speed_duplex = e1000_10_full;
ch1010832@1992: 		adapter->hw.autoneg_advertised = 0;
ch1010832@1992: 		break;
ch1010832@1992: 	case SPEED_100:
ch1010832@1992: 		DPRINTK(PROBE, INFO, "100 Mbps Speed specified "
ch1010832@1992: 			"without Duplex\n");
ch1010832@1992: 		DPRINTK(PROBE, INFO, "Using Autonegotiation at "
ch1010832@1992: 			"100 Mbps only\n");
ch1010832@1992: 		adapter->hw.autoneg = adapter->fc_autoneg = 1;
ch1010832@1992: 		adapter->hw.autoneg_advertised = ADVERTISE_100_HALF |
ch1010832@1992: 		                                 ADVERTISE_100_FULL;
ch1010832@1992: 		break;
ch1010832@1992: 	case SPEED_100 + HALF_DUPLEX:
ch1010832@1992: 		DPRINTK(PROBE, INFO, "Forcing to 100 Mbps Half Duplex\n");
ch1010832@1992: 		adapter->hw.autoneg = adapter->fc_autoneg = 0;
ch1010832@1992: 		adapter->hw.forced_speed_duplex = e1000_100_half;
ch1010832@1992: 		adapter->hw.autoneg_advertised = 0;
ch1010832@1992: 		break;
ch1010832@1992: 	case SPEED_100 + FULL_DUPLEX:
ch1010832@1992: 		DPRINTK(PROBE, INFO, "Forcing to 100 Mbps Full Duplex\n");
ch1010832@1992: 		adapter->hw.autoneg = adapter->fc_autoneg = 0;
ch1010832@1992: 		adapter->hw.forced_speed_duplex = e1000_100_full;
ch1010832@1992: 		adapter->hw.autoneg_advertised = 0;
ch1010832@1992: 		break;
ch1010832@1992: 	case SPEED_1000:
ch1010832@1992: 		DPRINTK(PROBE, INFO, "1000 Mbps Speed specified without "
ch1010832@1992: 			"Duplex\n");
ch1010832@1992: 		goto full_duplex_only;
ch1010832@1992: 	case SPEED_1000 + HALF_DUPLEX:
ch1010832@1992: 		DPRINTK(PROBE, INFO,
ch1010832@1992: 			"Half Duplex is not supported at 1000 Mbps\n");
ch1010832@1992: 		/* fall through */
ch1010832@1992: 	case SPEED_1000 + FULL_DUPLEX:
ch1010832@1992: full_duplex_only:
ch1010832@1992: 		DPRINTK(PROBE, INFO,
ch1010832@1992: 		       "Using Autonegotiation at 1000 Mbps Full Duplex only\n");
ch1010832@1992: 		adapter->hw.autoneg = adapter->fc_autoneg = 1;
ch1010832@1992: 		adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
ch1010832@1992: 		break;
ch1010832@1992: 	default:
ch1010832@1992: 		BUG();
ch1010832@1992: 	}
ch1010832@1992: 
ch1010832@1992: 	/* Speed, AutoNeg and MDI/MDI-X must all play nice */
ch1010832@1992: 	if (e1000_validate_mdi_setting(&(adapter->hw)) < 0) {
ch1010832@1992: 		DPRINTK(PROBE, INFO,
ch1010832@1992: 			"Speed, AutoNeg and MDI-X specifications are "
ch1010832@1992: 			"incompatible. Setting MDI-X to a compatible value.\n");
ch1010832@1992: 	}
ch1010832@1992: }
ch1010832@1992: