⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e1000_param.c

📁 linux系统的网卡驱动包
💻 C
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************************  Intel PRO/1000 Linux driver  Copyright(c) 1999 - 2008 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.  You should have received a copy of the GNU General Public License along with  this program; if not, write to the Free Software Foundation, Inc.,  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.  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*******************************************************************************/#include <linux/netdevice.h>#include "e1000.h"/* This is the only thing that needs to be changed to adjust the * 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/* All parameters are treated the same, as an integer array of values. * 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 }#ifndef module_param_array/* Module Parameters are always initialized to -1, so that the driver * can tell the difference between no user specified value or the * user asking for the default value. * The true default values are loaded in when e1000_check_options is called. * * This is a GCC extension to ANSI C. * See the item "Labeled Elements in Initializers" in the section * "Extensions to the C Language Family" of the GCC documentation. */#define E1000_PARAM(X, desc) \	static const int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \	MODULE_PARM(X, "1-" __MODULE_STRING(E1000_MAX_NIC) "i"); \	MODULE_PARM_DESC(X, desc);#else#define E1000_PARAM(X, desc) \	static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \	static unsigned int num_##X = 0; \	module_param_array_named(X, X, int, &num_##X, 0); \	MODULE_PARM_DESC(X, desc);#endif/* Transmit Descriptor Count * * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers * Valid Range: 80-4096 for 82544 and newer * * Default Value: 256 */E1000_PARAM(TxDescriptors, "Number of transmit descriptors");/* Receive Descriptor Count * * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers * Valid Range: 80-4096 for 82544 and newer * * Default Value: 256 */E1000_PARAM(RxDescriptors, "Number of receive descriptors");/* User Specified Speed Override * * Valid Range: 0, 10, 100, 1000 *  - 0    - auto-negotiate at all supported speeds *  - 10   - only link at 10 Mbps *  - 100  - only link at 100 Mbps *  - 1000 - only link at 1000 Mbps * * Default Value: 0 */E1000_PARAM(Speed, "Speed setting");/* User Specified Duplex Override * * Valid Range: 0-2 *  - 0 - auto-negotiate for duplex *  - 1 - only link at half duplex *  - 2 - only link at full duplex * * Default Value: 0 */E1000_PARAM(Duplex, "Duplex setting");/* Auto-negotiation Advertisement Override * * Valid Range: 0x01-0x0F, 0x20-0x2F (copper); 0x20 (fiber) * * The AutoNeg value is a bit mask describing which speed and duplex * combinations should be advertised during auto-negotiation. * The supported speed and duplex modes are listed below * * Bit           7     6     5      4      3     2     1      0 * Speed (Mbps)  N/A   N/A   1000   N/A    100   100   10     10 * Duplex                    Full          Full  Half  Full   Half * * Default Value: 0x2F (copper); 0x20 (fiber) */E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting");#define AUTONEG_ADV_DEFAULT  0x2F#define AUTONEG_ADV_MASK     0x2F/* User Specified Flow Control Override * * Valid Range: 0-3 *  - 0 - No Flow Control *  - 1 - Rx only, respond to PAUSE frames but do not generate them *  - 2 - Tx only, generate PAUSE frames but ignore them on receive *  - 3 - Full Flow Control Support * * Default Value: Read flow control settings from the EEPROM */E1000_PARAM(FlowControl, "Flow Control setting");#define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL/* XsumRX - Receive Checksum Offload Enable/Disable * * Valid Range: 0, 1 *  - 0 - disables all checksum offload *  - 1 - enables receive IP/TCP/UDP checksum offload *        on 82543 and newer -based NICs * * Default Value: 1 */E1000_PARAM(XsumRX, "Disable or enable Receive Checksum offload");/* Transmit Interrupt Delay in units of 1.024 microseconds *  Tx interrupt delay needs to typically be set to something non zero * * Valid Range: 0-65535 */E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");#define DEFAULT_TIDV                   8#define MAX_TXDELAY               0xFFFF#define MIN_TXDELAY                    0/* Transmit Absolute Interrupt Delay in units of 1.024 microseconds * * Valid Range: 0-65535 */E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");#define DEFAULT_TADV                  32#define MAX_TXABSDELAY            0xFFFF#define MIN_TXABSDELAY                 0/* Receive Interrupt Delay in units of 1.024 microseconds *   hardware will likely hang if you set this to anything but zero. * * Valid Range: 0-65535 */E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");#define DEFAULT_RDTR                   0#define MAX_RXDELAY               0xFFFF#define MIN_RXDELAY                    0/* Receive Absolute Interrupt Delay in units of 1.024 microseconds * * Valid Range: 0-65535 */E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");#define DEFAULT_RADV                   8#define MAX_RXABSDELAY            0xFFFF#define MIN_RXABSDELAY                 0/* Interrupt Throttle Rate (interrupts/sec) * * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative) */E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");#define DEFAULT_ITR                    3#define MAX_ITR                   100000#define MIN_ITR                      100/* Enable Smart Power Down of the PHY * * Valid Range: 0, 1 * * Default Value: 0 (disabled) */E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");/* Enable Kumeran Lock Loss workaround * * Valid Range: 0, 1 * * Default Value: 1 (enabled) */E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");struct e1000_option {	enum { enable_option, range_option, list_option } type;	const char *name;	const char *err;	int def;	union {		struct { /* range_option info */			int min;			int max;		} r;		struct { /* list_option info */			int nr;			struct e1000_opt_list { int i; char *str; } *p;		} l;	} arg;};static int __devinit e1000_validate_option(unsigned int *value,                                           const struct e1000_option *opt,                                           struct e1000_adapter *adapter){	if (*value == OPTION_UNSET) {		*value = opt->def;		return 0;	}	switch (opt->type) {	case enable_option:		switch (*value) {		case OPTION_ENABLED:			DPRINTK(PROBE, INFO, "%s Enabled\n", opt->name);			return 0;		case OPTION_DISABLED:			DPRINTK(PROBE, INFO, "%s Disabled\n", opt->name);			return 0;		}		break;	case range_option:		if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {			DPRINTK(PROBE, INFO,					"%s set to %i\n", opt->name, *value);			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')					DPRINTK(PROBE, INFO, "%s\n", ent->str);				return 0;			}		}	}		break;	default:		BUG();	}	DPRINTK(PROBE, INFO, "Invalid %s value specified (%i) %s\n",	       opt->name, *value, opt->err);	*value = opt->def;	return -1;}static void e1000_check_fiber_options(struct e1000_adapter *adapter);static void e1000_check_copper_options(struct e1000_adapter *adapter);/** * e1000_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. **/void __devinit e1000_check_options(struct e1000_adapter *adapter){	struct e1000_hw *hw = &adapter->hw;	int bd = adapter->bd_number;	if (bd >= E1000_MAX_NIC) {		DPRINTK(PROBE, NOTICE,		       "Warning: no configuration for board #%i\n", bd);		DPRINTK(PROBE, NOTICE, "Using defaults for all values\n");#ifndef module_param_array		bd = E1000_MAX_NIC;#endif	}	{ /* Transmit Descriptor Count */		struct e1000_option opt = {			.type = range_option,			.name = "Transmit Descriptors",			.err  = "using default of "				__MODULE_STRING(E1000_DEFAULT_TXD),			.def  = E1000_DEFAULT_TXD,			.arg  = { .r = { .min = E1000_MIN_TXD }}		};		struct e1000_tx_ring *tx_ring = adapter->tx_ring;		int i;		opt.arg.r.max = hw->mac.type < e1000_82544 ?			E1000_MAX_TXD : E1000_MAX_82544_TXD;#ifdef module_param_array		if (num_TxDescriptors > bd) {#endif			tx_ring->count = TxDescriptors[bd];			e1000_validate_option(&tx_ring->count, &opt, adapter);			tx_ring->count = ALIGN(tx_ring->count,			                       REQ_TX_DESCRIPTOR_MULTIPLE);#ifdef module_param_array		} else {			tx_ring->count = opt.def;		}#endif		for (i = 0; i < adapter->num_tx_queues; i++)			tx_ring[i].count = tx_ring->count;	}	{ /* Receive Descriptor Count */		struct e1000_option opt = {			.type = range_option,			.name = "Receive Descriptors",			.err  = "using default of "				__MODULE_STRING(E1000_DEFAULT_RXD),			.def  = E1000_DEFAULT_RXD,			.arg  = { .r = { .min = E1000_MIN_RXD }}		};		struct e1000_rx_ring *rx_ring = adapter->rx_ring;		int i;		opt.arg.r.max = hw->mac.type < e1000_82544 ? E1000_MAX_RXD :			E1000_MAX_82544_RXD;#ifdef module_param_array		if (num_RxDescriptors > bd) {#endif			rx_ring->count = RxDescriptors[bd];			e1000_validate_option(&rx_ring->count, &opt, adapter);			rx_ring->count = ALIGN(rx_ring->count,			                       REQ_RX_DESCRIPTOR_MULTIPLE);#ifdef module_param_array		} else {			rx_ring->count = opt.def;		}#endif		for (i = 0; i < adapter->num_rx_queues; i++)			rx_ring[i].count = rx_ring->count;	}	{ /* Checksum Offload Enable/Disable */		struct e1000_option opt = {			.type = enable_option,			.name = "Checksum Offload",			.err  = "defaulting to Enabled",			.def  = OPTION_ENABLED		};#ifdef module_param_array		if (num_XsumRX > bd) {#endif			unsigned int rx_csum = XsumRX[bd];			e1000_validate_option(&rx_csum, &opt, adapter);			adapter->rx_csum = rx_csum;#ifdef module_param_array		} else {			adapter->rx_csum = opt.def;		}#endif	}	{ /* Flow Control */		struct e1000_opt_list fc_list[] =			{{ e1000_fc_none,    "Flow Control Disabled" },			 { e1000_fc_rx_pause,"Flow Control Receive Only" },			 { e1000_fc_tx_pause,"Flow Control Transmit Only" },			 { e1000_fc_full,    "Flow Control Enabled" },			 { e1000_fc_default, "Flow Control Hardware Default" }};		struct e1000_option opt = {			.type = list_option,			.name = "Flow Control",			.err  = "reading default settings from EEPROM",			.def  = e1000_fc_default,			.arg  = { .l = { .nr = ARRAY_SIZE(fc_list),					 .p = fc_list }}		};#ifdef module_param_array		if (num_FlowControl > bd) {#endif			unsigned int fc = FlowControl[bd];			e1000_validate_option(&fc, &opt, adapter);			hw->fc.original_type = fc;			hw->fc.type = fc;#ifdef module_param_array		} else {			hw->fc.original_type = opt.def;			hw->fc.type = opt.def;		}#endif	}	{ /* Transmit Interrupt Delay */		struct e1000_option opt = {			.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 }}		};#ifdef module_param_array		if (num_TxIntDelay > bd) {#endif			adapter->tx_int_delay = TxIntDelay[bd];			e1000_validate_option(&adapter->tx_int_delay, &opt,			                      adapter);#ifdef module_param_array		} else {			adapter->tx_int_delay = opt.def;		}#endif	}	{ /* Transmit Absolute Interrupt Delay */		struct e1000_option opt = {			.type = range_option,			.name = "Transmit Absolute Interrupt Delay",			.err  = "using default of " __MODULE_STRING(DEFAULT_TADV),			.def  = DEFAULT_TADV,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -