| 
									
										
										
										
											2014-02-04 01:56:06 +00:00
										 |  |  | /* Intel PRO/1000 Linux driver
 | 
					
						
							|  |  |  |  * Copyright(c) 1999 - 2014 Intel Corporation. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or modify it | 
					
						
							|  |  |  |  * under the terms and conditions of the GNU General Public License, | 
					
						
							|  |  |  |  * version 2, as published by the Free Software Foundation. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope it will be useful, but WITHOUT | 
					
						
							|  |  |  |  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 
					
						
							|  |  |  |  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | 
					
						
							|  |  |  |  * more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The full GNU General Public License is included in this distribution in | 
					
						
							|  |  |  |  * the file called "COPYING". | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contact Information: | 
					
						
							|  |  |  |  * Linux NICS <linux.nics@intel.com> | 
					
						
							|  |  |  |  * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> | 
					
						
							|  |  |  |  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <linux/netdevice.h>
 | 
					
						
							| 
									
										
										
										
											2011-07-03 15:21:01 -04:00
										 |  |  | #include <linux/module.h>
 | 
					
						
							| 
									
										
										
										
											2008-08-04 17:20:41 -07:00
										 |  |  | #include <linux/pci.h>
 | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "e1000.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | /* This is the only thing that needs to be changed to adjust the
 | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  |  * maximum number of ports that the driver can manage. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define E1000_MAX_NIC 32
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define OPTION_UNSET   -1
 | 
					
						
							|  |  |  | #define OPTION_DISABLED 0
 | 
					
						
							|  |  |  | #define OPTION_ENABLED  1
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define COPYBREAK_DEFAULT 256
 | 
					
						
							|  |  |  | unsigned int copybreak = COPYBREAK_DEFAULT; | 
					
						
							|  |  |  | module_param(copybreak, uint, 0644); | 
					
						
							|  |  |  | MODULE_PARM_DESC(copybreak, | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:01 +00:00
										 |  |  | 		 "Maximum size of packet that is copied to a new buffer on receive"); | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | /* All parameters are treated the same, as an integer array of values.
 | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  |  * This macro just reduces the need to repeat the same declaration code | 
					
						
							|  |  |  |  * over and over (plus this helps to avoid typo bugs). | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
 | 
					
						
							| 
									
										
										
										
											2007-10-29 10:46:05 -07:00
										 |  |  | #define E1000_PARAM(X, desc)					\
 | 
					
						
							| 
									
										
										
										
											2013-01-12 07:28:24 +00:00
										 |  |  | 	static int X[E1000_MAX_NIC+1] = E1000_PARAM_INIT;	\ | 
					
						
							| 
									
										
										
										
											2007-10-29 10:46:05 -07:00
										 |  |  | 	static unsigned int num_##X;				\ | 
					
						
							|  |  |  | 	module_param_array_named(X, X, int, &num_##X, 0);	\ | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 	MODULE_PARM_DESC(X, desc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | /* Transmit Interrupt Delay in units of 1.024 microseconds
 | 
					
						
							| 
									
										
										
										
											2010-12-31 06:10:01 +00:00
										 |  |  |  * Tx interrupt delay needs to typically be set to something non-zero | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Valid Range: 0-65535 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay"); | 
					
						
							|  |  |  | #define DEFAULT_TIDV 8
 | 
					
						
							|  |  |  | #define MAX_TXDELAY 0xFFFF
 | 
					
						
							|  |  |  | #define MIN_TXDELAY 0
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | /* Transmit Absolute Interrupt Delay in units of 1.024 microseconds
 | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Valid Range: 0-65535 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay"); | 
					
						
							|  |  |  | #define DEFAULT_TADV 32
 | 
					
						
							|  |  |  | #define MAX_TXABSDELAY 0xFFFF
 | 
					
						
							|  |  |  | #define MIN_TXABSDELAY 0
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | /* Receive Interrupt Delay in units of 1.024 microseconds
 | 
					
						
							| 
									
										
										
										
											2008-03-28 09:15:03 -07:00
										 |  |  |  * hardware will likely hang if you set this to anything but zero. | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Valid Range: 0-65535 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | E1000_PARAM(RxIntDelay, "Receive Interrupt Delay"); | 
					
						
							|  |  |  | #define MAX_RXDELAY 0xFFFF
 | 
					
						
							|  |  |  | #define MIN_RXDELAY 0
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | /* Receive Absolute Interrupt Delay in units of 1.024 microseconds
 | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Valid Range: 0-65535 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay"); | 
					
						
							|  |  |  | #define MAX_RXABSDELAY 0xFFFF
 | 
					
						
							|  |  |  | #define MIN_RXABSDELAY 0
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | /* Interrupt Throttle Rate (interrupts/sec)
 | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2012-04-20 08:51:45 +00:00
										 |  |  |  * Valid Range: 100-100000 or one of: 0=off, 1=dynamic, 3=dynamic conservative | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate"); | 
					
						
							|  |  |  | #define DEFAULT_ITR 3
 | 
					
						
							|  |  |  | #define MAX_ITR 100000
 | 
					
						
							|  |  |  | #define MIN_ITR 100
 | 
					
						
							| 
									
										
										
										
											2010-12-31 06:10:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | /* IntMode (Interrupt Mode)
 | 
					
						
							| 
									
										
										
										
											2011-12-16 00:45:56 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Valid Range: varies depending on kernel configuration & hardware support | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * legacy=0, MSI=1, MSI-X=2 | 
					
						
							| 
									
										
										
										
											2008-08-26 18:37:06 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2011-12-16 00:45:56 +00:00
										 |  |  |  * When MSI/MSI-X support is enabled in kernel- | 
					
						
							|  |  |  |  *   Default Value: 2 (MSI-X) when supported by hardware, 1 (MSI) otherwise | 
					
						
							|  |  |  |  * When MSI/MSI-X support is not enabled in kernel- | 
					
						
							|  |  |  |  *   Default Value: 0 (legacy) | 
					
						
							| 
									
										
										
										
											2008-08-26 18:37:06 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2011-12-16 00:45:56 +00:00
										 |  |  |  * When a mode is specified that is not allowed/supported, it will be | 
					
						
							|  |  |  |  * demoted to the most advanced interrupt mode available. | 
					
						
							| 
									
										
										
										
											2008-08-26 18:37:06 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | E1000_PARAM(IntMode, "Interrupt Mode"); | 
					
						
							|  |  |  | #define MAX_INTMODE	2
 | 
					
						
							|  |  |  | #define MIN_INTMODE	0
 | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | /* Enable Smart Power Down of the PHY
 | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Valid Range: 0, 1 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Default Value: 0 (disabled) | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | /* Enable Kumeran Lock Loss workaround
 | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Valid Range: 0, 1 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Default Value: 1 (enabled) | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | /* Write Protect NVM
 | 
					
						
							| 
									
										
										
										
											2008-10-01 17:18:35 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Valid Range: 0, 1 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Default Value: 1 (enabled) | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-02-20 04:05:50 +00:00
										 |  |  | E1000_PARAM(WriteProtectNVM, | 
					
						
							|  |  |  | 	    "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]"); | 
					
						
							| 
									
										
										
										
											2008-10-01 17:18:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | /* Enable CRC Stripping
 | 
					
						
							| 
									
										
										
										
											2008-11-14 06:45:23 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Valid Range: 0, 1 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Default Value: 1 (enabled) | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-04-12 05:47:09 +00:00
										 |  |  | E1000_PARAM(CrcStripping, | 
					
						
							|  |  |  | 	    "Enable CRC Stripping, disable if your BMC needs the CRC"); | 
					
						
							| 
									
										
										
										
											2008-11-14 06:45:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | struct e1000_option { | 
					
						
							|  |  |  | 	enum { enable_option, range_option, list_option } type; | 
					
						
							| 
									
										
										
										
											2007-10-29 10:46:05 -07:00
										 |  |  | 	const char *name; | 
					
						
							|  |  |  | 	const char *err; | 
					
						
							|  |  |  | 	int def; | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 	union { | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:16 +00:00
										 |  |  | 		/* range_option info */ | 
					
						
							|  |  |  | 		struct { | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 			int min; | 
					
						
							|  |  |  | 			int max; | 
					
						
							|  |  |  | 		} r; | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:16 +00:00
										 |  |  | 		/* list_option info */ | 
					
						
							|  |  |  | 		struct { | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 			int nr; | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:37 +00:00
										 |  |  | 			struct e1000_opt_list { | 
					
						
							|  |  |  | 				int i; | 
					
						
							|  |  |  | 				char *str; | 
					
						
							|  |  |  | 			} *p; | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 		} l; | 
					
						
							|  |  |  | 	} arg; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-03 09:24:25 -05:00
										 |  |  | static int e1000_validate_option(unsigned int *value, | 
					
						
							| 
									
										
										
										
											2012-12-06 14:30:56 +00:00
										 |  |  | 				 const struct e1000_option *opt, | 
					
						
							|  |  |  | 				 struct e1000_adapter *adapter) | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | { | 
					
						
							|  |  |  | 	if (*value == OPTION_UNSET) { | 
					
						
							|  |  |  | 		*value = opt->def; | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	switch (opt->type) { | 
					
						
							|  |  |  | 	case enable_option: | 
					
						
							|  |  |  | 		switch (*value) { | 
					
						
							|  |  |  | 		case OPTION_ENABLED: | 
					
						
							| 
									
										
										
										
											2012-06-07 02:23:37 +00:00
										 |  |  | 			dev_info(&adapter->pdev->dev, "%s Enabled\n", | 
					
						
							|  |  |  | 				 opt->name); | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 			return 0; | 
					
						
							|  |  |  | 		case OPTION_DISABLED: | 
					
						
							| 
									
										
										
										
											2012-06-07 02:23:37 +00:00
										 |  |  | 			dev_info(&adapter->pdev->dev, "%s Disabled\n", | 
					
						
							|  |  |  | 				 opt->name); | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 			return 0; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case range_option: | 
					
						
							|  |  |  | 		if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) { | 
					
						
							| 
									
										
										
										
											2012-06-07 02:23:37 +00:00
										 |  |  | 			dev_info(&adapter->pdev->dev, "%s set to %i\n", | 
					
						
							|  |  |  | 				 opt->name, *value); | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 			return 0; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case list_option: { | 
					
						
							|  |  |  | 		int i; | 
					
						
							|  |  |  | 		struct e1000_opt_list *ent; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (i = 0; i < opt->arg.l.nr; i++) { | 
					
						
							|  |  |  | 			ent = &opt->arg.l.p[i]; | 
					
						
							|  |  |  | 			if (*value == ent->i) { | 
					
						
							|  |  |  | 				if (ent->str[0] != '\0') | 
					
						
							| 
									
										
										
										
											2012-06-07 02:23:37 +00:00
										 |  |  | 					dev_info(&adapter->pdev->dev, "%s\n", | 
					
						
							|  |  |  | 						 ent->str); | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 				return 0; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		BUG(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-07 02:23:37 +00:00
										 |  |  | 	dev_info(&adapter->pdev->dev, "Invalid %s value specified (%i) %s\n", | 
					
						
							|  |  |  | 		 opt->name, *value, opt->err); | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 	*value = opt->def; | 
					
						
							|  |  |  | 	return -1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * e1000e_check_options - Range Checking for Command Line Parameters | 
					
						
							|  |  |  |  * @adapter: board private structure | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This routine checks all command line parameters for valid user | 
					
						
							|  |  |  |  * input.  If an invalid value is given, or if no user specified | 
					
						
							|  |  |  |  * value exists, a default value is used.  The final value is stored | 
					
						
							|  |  |  |  * in a variable in the adapter structure. | 
					
						
							|  |  |  |  **/ | 
					
						
							| 
									
										
										
										
											2012-12-03 09:24:25 -05:00
										 |  |  | void e1000e_check_options(struct e1000_adapter *adapter) | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct e1000_hw *hw = &adapter->hw; | 
					
						
							|  |  |  | 	int bd = adapter->bd_number; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (bd >= E1000_MAX_NIC) { | 
					
						
							| 
									
										
										
										
											2012-06-07 02:23:37 +00:00
										 |  |  | 		dev_notice(&adapter->pdev->dev, | 
					
						
							|  |  |  | 			   "Warning: no configuration for board #%i\n", bd); | 
					
						
							|  |  |  | 		dev_notice(&adapter->pdev->dev, | 
					
						
							|  |  |  | 			   "Using defaults for all values\n"); | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:16 +00:00
										 |  |  | 	/* Transmit Interrupt Delay */ | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2010-04-09 10:51:09 +00:00
										 |  |  | 		static const struct e1000_option opt = { | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 			.type = range_option, | 
					
						
							|  |  |  | 			.name = "Transmit Interrupt Delay", | 
					
						
							|  |  |  | 			.err  = "using default of " | 
					
						
							|  |  |  | 				__MODULE_STRING(DEFAULT_TIDV), | 
					
						
							|  |  |  | 			.def  = DEFAULT_TIDV, | 
					
						
							|  |  |  | 			.arg  = { .r = { .min = MIN_TXDELAY, | 
					
						
							|  |  |  | 					 .max = MAX_TXDELAY } } | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (num_TxIntDelay > bd) { | 
					
						
							|  |  |  | 			adapter->tx_int_delay = TxIntDelay[bd]; | 
					
						
							|  |  |  | 			e1000_validate_option(&adapter->tx_int_delay, &opt, | 
					
						
							|  |  |  | 					      adapter); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			adapter->tx_int_delay = opt.def; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:16 +00:00
										 |  |  | 	/* Transmit Absolute Interrupt Delay */ | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2010-04-09 10:51:09 +00:00
										 |  |  | 		static const struct e1000_option opt = { | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 			.type = range_option, | 
					
						
							|  |  |  | 			.name = "Transmit Absolute Interrupt Delay", | 
					
						
							|  |  |  | 			.err  = "using default of " | 
					
						
							|  |  |  | 				__MODULE_STRING(DEFAULT_TADV), | 
					
						
							|  |  |  | 			.def  = DEFAULT_TADV, | 
					
						
							|  |  |  | 			.arg  = { .r = { .min = MIN_TXABSDELAY, | 
					
						
							|  |  |  | 					 .max = MAX_TXABSDELAY } } | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (num_TxAbsIntDelay > bd) { | 
					
						
							|  |  |  | 			adapter->tx_abs_int_delay = TxAbsIntDelay[bd]; | 
					
						
							|  |  |  | 			e1000_validate_option(&adapter->tx_abs_int_delay, &opt, | 
					
						
							|  |  |  | 					      adapter); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			adapter->tx_abs_int_delay = opt.def; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:16 +00:00
										 |  |  | 	/* Receive Interrupt Delay */ | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2010-05-10 14:59:10 +00:00
										 |  |  | 		static struct e1000_option opt = { | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 			.type = range_option, | 
					
						
							|  |  |  | 			.name = "Receive Interrupt Delay", | 
					
						
							|  |  |  | 			.err  = "using default of " | 
					
						
							|  |  |  | 				__MODULE_STRING(DEFAULT_RDTR), | 
					
						
							|  |  |  | 			.def  = DEFAULT_RDTR, | 
					
						
							|  |  |  | 			.arg  = { .r = { .min = MIN_RXDELAY, | 
					
						
							|  |  |  | 					 .max = MAX_RXDELAY } } | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (num_RxIntDelay > bd) { | 
					
						
							|  |  |  | 			adapter->rx_int_delay = RxIntDelay[bd]; | 
					
						
							|  |  |  | 			e1000_validate_option(&adapter->rx_int_delay, &opt, | 
					
						
							|  |  |  | 					      adapter); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			adapter->rx_int_delay = opt.def; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:16 +00:00
										 |  |  | 	/* Receive Absolute Interrupt Delay */ | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2010-04-09 10:51:09 +00:00
										 |  |  | 		static const struct e1000_option opt = { | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 			.type = range_option, | 
					
						
							|  |  |  | 			.name = "Receive Absolute Interrupt Delay", | 
					
						
							|  |  |  | 			.err  = "using default of " | 
					
						
							|  |  |  | 				__MODULE_STRING(DEFAULT_RADV), | 
					
						
							|  |  |  | 			.def  = DEFAULT_RADV, | 
					
						
							|  |  |  | 			.arg  = { .r = { .min = MIN_RXABSDELAY, | 
					
						
							|  |  |  | 					 .max = MAX_RXABSDELAY } } | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (num_RxAbsIntDelay > bd) { | 
					
						
							|  |  |  | 			adapter->rx_abs_int_delay = RxAbsIntDelay[bd]; | 
					
						
							|  |  |  | 			e1000_validate_option(&adapter->rx_abs_int_delay, &opt, | 
					
						
							|  |  |  | 					      adapter); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			adapter->rx_abs_int_delay = opt.def; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:16 +00:00
										 |  |  | 	/* Interrupt Throttling Rate */ | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2010-04-09 10:51:09 +00:00
										 |  |  | 		static const struct e1000_option opt = { | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 			.type = range_option, | 
					
						
							|  |  |  | 			.name = "Interrupt Throttling Rate (ints/sec)", | 
					
						
							|  |  |  | 			.err  = "using default of " | 
					
						
							|  |  |  | 				__MODULE_STRING(DEFAULT_ITR), | 
					
						
							|  |  |  | 			.def  = DEFAULT_ITR, | 
					
						
							|  |  |  | 			.arg  = { .r = { .min = MIN_ITR, | 
					
						
							|  |  |  | 					 .max = MAX_ITR } } | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (num_InterruptThrottleRate > bd) { | 
					
						
							|  |  |  | 			adapter->itr = InterruptThrottleRate[bd]; | 
					
						
							| 
									
										
										
										
											2012-05-09 02:23:46 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | 			/* Make sure a message is printed for non-special
 | 
					
						
							| 
									
										
										
										
											2012-05-09 02:23:46 -07:00
										 |  |  | 			 * values. And in case of an invalid option, display | 
					
						
							|  |  |  | 			 * warning, use default and go through itr/itr_setting | 
					
						
							|  |  |  | 			 * adjustment logic below | 
					
						
							|  |  |  | 			 */ | 
					
						
							|  |  |  | 			if ((adapter->itr > 4) && | 
					
						
							|  |  |  | 			    e1000_validate_option(&adapter->itr, &opt, adapter)) | 
					
						
							|  |  |  | 				adapter->itr = opt.def; | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | 			/* If no option specified, use default value and go
 | 
					
						
							| 
									
										
										
										
											2012-04-20 08:51:45 +00:00
										 |  |  | 			 * through the logic below to adjust itr/itr_setting | 
					
						
							|  |  |  | 			 */ | 
					
						
							|  |  |  | 			adapter->itr = opt.def; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | 			/* Make sure a message is printed for non-special
 | 
					
						
							| 
									
										
										
										
											2012-04-20 08:51:45 +00:00
										 |  |  | 			 * default values | 
					
						
							|  |  |  | 			 */ | 
					
						
							| 
									
										
										
										
											2012-05-09 02:23:46 -07:00
										 |  |  | 			if (adapter->itr > 4) | 
					
						
							| 
									
										
										
										
											2012-06-07 02:23:37 +00:00
										 |  |  | 				dev_info(&adapter->pdev->dev, | 
					
						
							|  |  |  | 					 "%s set to default %d\n", opt.name, | 
					
						
							|  |  |  | 					 adapter->itr); | 
					
						
							| 
									
										
										
										
											2012-04-20 08:51:45 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		adapter->itr_setting = adapter->itr; | 
					
						
							|  |  |  | 		switch (adapter->itr) { | 
					
						
							|  |  |  | 		case 0: | 
					
						
							| 
									
										
										
										
											2012-06-07 02:23:37 +00:00
										 |  |  | 			dev_info(&adapter->pdev->dev, "%s turned off\n", | 
					
						
							|  |  |  | 				 opt.name); | 
					
						
							| 
									
										
										
										
											2012-04-20 08:51:45 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case 1: | 
					
						
							| 
									
										
										
										
											2012-06-07 02:23:37 +00:00
										 |  |  | 			dev_info(&adapter->pdev->dev, | 
					
						
							|  |  |  | 				 "%s set to dynamic mode\n", opt.name); | 
					
						
							| 
									
										
										
										
											2012-04-20 08:51:45 +00:00
										 |  |  | 			adapter->itr = 20000; | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2014-02-26 00:02:24 +00:00
										 |  |  | 		case 2: | 
					
						
							|  |  |  | 			dev_info(&adapter->pdev->dev, | 
					
						
							|  |  |  | 				 "%s Invalid mode - setting default\n", | 
					
						
							|  |  |  | 				 opt.name); | 
					
						
							|  |  |  | 			adapter->itr_setting = opt.def; | 
					
						
							|  |  |  | 			/* fall-through */ | 
					
						
							| 
									
										
										
										
											2012-04-20 08:51:45 +00:00
										 |  |  | 		case 3: | 
					
						
							| 
									
										
										
										
											2012-06-07 02:23:37 +00:00
										 |  |  | 			dev_info(&adapter->pdev->dev, | 
					
						
							|  |  |  | 				 "%s set to dynamic conservative mode\n", | 
					
						
							|  |  |  | 				 opt.name); | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 			adapter->itr = 20000; | 
					
						
							| 
									
										
										
										
											2012-04-20 08:51:45 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case 4: | 
					
						
							| 
									
										
										
										
											2012-06-07 02:23:37 +00:00
										 |  |  | 			dev_info(&adapter->pdev->dev, | 
					
						
							|  |  |  | 				 "%s set to simplified (2000-8000 ints) mode\n", | 
					
						
							|  |  |  | 				 opt.name); | 
					
						
							| 
									
										
										
										
											2012-04-20 08:51:45 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		default: | 
					
						
							| 
									
										
										
										
											2012-11-28 09:28:37 +00:00
										 |  |  | 			/* Save the setting, because the dynamic bits
 | 
					
						
							| 
									
										
										
										
											2012-04-20 08:51:45 +00:00
										 |  |  | 			 * change itr. | 
					
						
							|  |  |  | 			 * | 
					
						
							|  |  |  | 			 * Clear the lower two bits because | 
					
						
							|  |  |  | 			 * they are used as control. | 
					
						
							|  |  |  | 			 */ | 
					
						
							|  |  |  | 			adapter->itr_setting &= ~3; | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:16 +00:00
										 |  |  | 	/* Interrupt Mode */ | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2010-05-10 14:59:10 +00:00
										 |  |  | 		static struct e1000_option opt = { | 
					
						
							| 
									
										
										
										
											2008-08-26 18:37:06 -07:00
										 |  |  | 			.type = range_option, | 
					
						
							|  |  |  | 			.name = "Interrupt Mode", | 
					
						
							| 
									
										
										
										
											2011-12-16 00:45:56 +00:00
										 |  |  | #ifndef CONFIG_PCI_MSI
 | 
					
						
							|  |  |  | 			.err  = "defaulting to 0 (legacy)", | 
					
						
							|  |  |  | 			.def  = E1000E_INT_MODE_LEGACY, | 
					
						
							|  |  |  | 			.arg  = { .r = { .min = 0, | 
					
						
							|  |  |  | 					 .max = 0 } } | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2008-08-26 18:37:06 -07:00
										 |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-16 00:45:56 +00:00
										 |  |  | #ifdef CONFIG_PCI_MSI
 | 
					
						
							|  |  |  | 		if (adapter->flags & FLAG_HAS_MSIX) { | 
					
						
							|  |  |  | 			opt.err = kstrdup("defaulting to 2 (MSI-X)", | 
					
						
							|  |  |  | 					  GFP_KERNEL); | 
					
						
							|  |  |  | 			opt.def = E1000E_INT_MODE_MSIX; | 
					
						
							|  |  |  | 			opt.arg.r.max = E1000E_INT_MODE_MSIX; | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			opt.err = kstrdup("defaulting to 1 (MSI)", GFP_KERNEL); | 
					
						
							|  |  |  | 			opt.def = E1000E_INT_MODE_MSI; | 
					
						
							|  |  |  | 			opt.arg.r.max = E1000E_INT_MODE_MSI; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (!opt.err) { | 
					
						
							|  |  |  | 			dev_err(&adapter->pdev->dev, | 
					
						
							|  |  |  | 				"Failed to allocate memory\n"); | 
					
						
							|  |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-26 18:37:06 -07:00
										 |  |  | 		if (num_IntMode > bd) { | 
					
						
							|  |  |  | 			unsigned int int_mode = IntMode[bd]; | 
					
						
							| 
									
										
										
										
											2014-04-05 06:07:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-26 18:37:06 -07:00
										 |  |  | 			e1000_validate_option(&int_mode, &opt, adapter); | 
					
						
							|  |  |  | 			adapter->int_mode = int_mode; | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			adapter->int_mode = opt.def; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2011-12-16 00:45:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef CONFIG_PCI_MSI
 | 
					
						
							|  |  |  | 		kfree(opt.err); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2008-08-26 18:37:06 -07:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:16 +00:00
										 |  |  | 	/* Smart Power Down */ | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2010-04-09 10:51:09 +00:00
										 |  |  | 		static const struct e1000_option opt = { | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 			.type = enable_option, | 
					
						
							|  |  |  | 			.name = "PHY Smart Power Down", | 
					
						
							|  |  |  | 			.err  = "defaulting to Disabled", | 
					
						
							|  |  |  | 			.def  = OPTION_DISABLED | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (num_SmartPowerDownEnable > bd) { | 
					
						
							| 
									
										
										
										
											2007-10-29 10:46:05 -07:00
										 |  |  | 			unsigned int spd = SmartPowerDownEnable[bd]; | 
					
						
							| 
									
										
										
										
											2014-04-05 06:07:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 			e1000_validate_option(&spd, &opt, adapter); | 
					
						
							| 
									
										
										
										
											2012-12-05 06:26:40 +00:00
										 |  |  | 			if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) && spd) | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 				adapter->flags |= FLAG_SMART_POWER_DOWN; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:16 +00:00
										 |  |  | 	/* CRC Stripping */ | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2010-04-09 10:51:09 +00:00
										 |  |  | 		static const struct e1000_option opt = { | 
					
						
							| 
									
										
										
										
											2008-11-14 06:45:23 +00:00
										 |  |  | 			.type = enable_option, | 
					
						
							|  |  |  | 			.name = "CRC Stripping", | 
					
						
							| 
									
										
										
										
											2010-11-24 06:02:06 +00:00
										 |  |  | 			.err  = "defaulting to Enabled", | 
					
						
							| 
									
										
										
										
											2008-11-14 06:45:23 +00:00
										 |  |  | 			.def  = OPTION_ENABLED | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (num_CrcStripping > bd) { | 
					
						
							|  |  |  | 			unsigned int crc_stripping = CrcStripping[bd]; | 
					
						
							| 
									
										
										
										
											2014-04-05 06:07:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-14 06:45:23 +00:00
										 |  |  | 			e1000_validate_option(&crc_stripping, &opt, adapter); | 
					
						
							| 
									
										
										
										
											2012-02-11 15:39:25 +00:00
										 |  |  | 			if (crc_stripping == OPTION_ENABLED) { | 
					
						
							| 
									
										
										
										
											2008-11-14 06:45:23 +00:00
										 |  |  | 				adapter->flags2 |= FLAG2_CRC_STRIPPING; | 
					
						
							| 
									
										
										
										
											2012-02-11 15:39:25 +00:00
										 |  |  | 				adapter->flags2 |= FLAG2_DFLT_CRC_STRIPPING; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2009-06-02 11:28:01 +00:00
										 |  |  | 		} else { | 
					
						
							|  |  |  | 			adapter->flags2 |= FLAG2_CRC_STRIPPING; | 
					
						
							| 
									
										
										
										
											2012-02-11 15:39:25 +00:00
										 |  |  | 			adapter->flags2 |= FLAG2_DFLT_CRC_STRIPPING; | 
					
						
							| 
									
										
										
										
											2008-11-14 06:45:23 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:16 +00:00
										 |  |  | 	/* Kumeran Lock Loss Workaround */ | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2010-04-09 10:51:09 +00:00
										 |  |  | 		static const struct e1000_option opt = { | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 			.type = enable_option, | 
					
						
							|  |  |  | 			.name = "Kumeran Lock Loss Workaround", | 
					
						
							|  |  |  | 			.err  = "defaulting to Enabled", | 
					
						
							|  |  |  | 			.def  = OPTION_ENABLED | 
					
						
							|  |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:01 +00:00
										 |  |  | 		bool enabled = opt.def; | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if (num_KumeranLockLoss > bd) { | 
					
						
							| 
									
										
										
										
											2007-10-29 10:46:05 -07:00
										 |  |  | 			unsigned int kmrn_lock_loss = KumeranLockLoss[bd]; | 
					
						
							| 
									
										
										
										
											2014-04-05 06:07:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 			e1000_validate_option(&kmrn_lock_loss, &opt, adapter); | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:01 +00:00
										 |  |  | 			enabled = kmrn_lock_loss; | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if (hw->mac.type == e1000_ich8lan) | 
					
						
							|  |  |  | 			e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, | 
					
						
							|  |  |  | 								     enabled); | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-02-20 04:06:16 +00:00
										 |  |  | 	/* Write-protect NVM */ | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2010-04-09 10:51:09 +00:00
										 |  |  | 		static const struct e1000_option opt = { | 
					
						
							| 
									
										
										
										
											2008-10-01 17:18:35 -07:00
										 |  |  | 			.type = enable_option, | 
					
						
							|  |  |  | 			.name = "Write-protect NVM", | 
					
						
							|  |  |  | 			.err  = "defaulting to Enabled", | 
					
						
							|  |  |  | 			.def  = OPTION_ENABLED | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (adapter->flags & FLAG_IS_ICH) { | 
					
						
							|  |  |  | 			if (num_WriteProtectNVM > bd) { | 
					
						
							| 
									
										
										
										
											2013-02-20 04:05:50 +00:00
										 |  |  | 				unsigned int write_protect_nvm = | 
					
						
							|  |  |  | 				    WriteProtectNVM[bd]; | 
					
						
							| 
									
										
										
										
											2008-10-01 17:18:35 -07:00
										 |  |  | 				e1000_validate_option(&write_protect_nvm, &opt, | 
					
						
							|  |  |  | 						      adapter); | 
					
						
							|  |  |  | 				if (write_protect_nvm) | 
					
						
							|  |  |  | 					adapter->flags |= FLAG_READ_ONLY_NVM; | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				if (opt.def) | 
					
						
							|  |  |  | 					adapter->flags |= FLAG_READ_ONLY_NVM; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2007-09-17 12:30:59 -07:00
										 |  |  | } |