e1000_param.c
来自「是关于linux2.5.1的完全源码」· C语言 代码 · 共 686 行 · 第 1/2 页
C
686 行
/******************************************************************************* This software program is available to you under a choice of one of two licenses. You may choose to be licensed under either the GNU General Public License 2.0, June 1991, available at http://www.fsf.org/copyleft/gpl.html, or the Intel BSD + Patent License, the text of which follows: Recipient has requested a license and Intel Corporation ("Intel") is willing to grant a license for the software entitled Linux Base Driver for the Intel(R) PRO/1000 Family of Adapters (e1000) (the "Software") being provided by Intel Corporation. The following definitions apply to this license: "Licensed Patents" means patent claims licensable by Intel Corporation which are necessarily infringed by the use of sale of the Software alone or when combined with the operating system referred to below. "Recipient" means the party to whom Intel delivers this Software. "Licensee" means Recipient and those third parties that receive a license to any operating system available under the GNU General Public License 2.0 or later. Copyright (c) 1999 - 2002 Intel Corporation. All rights reserved. The license is provided to Recipient and Recipient's Licensees under the following terms. Redistribution and use in source and binary forms of the Software, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code of the Software may retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form of the Software may reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or materials provided with the distribution. Neither the name of Intel Corporation nor the names of its contributors shall be used to endorse or promote products derived from this Software without specific prior written permission. Intel hereby grants Recipient and Licensees a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Software, if any, in source code and object code form. This license shall include changes to the Software that are error corrections or other minor changes to the Software that do not add functionality or features when the Software is incorporated in any version of an operating system that has been distributed under the GNU General Public License 2.0 or later. This patent license shall apply to the combination of the Software and any operating system licensed under the GNU General Public License 2.0 or later if, at the time Intel provides the Software to Recipient, such addition of the Software to the then publicly available versions of such operating systems available under the GNU General Public License 2.0 or later (whether in gold, beta or alpha form) causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Software. NO hardware per se is licensed hereunder. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MECHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR IT CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ANY LOSS OF USE; DATA, OR PROFITS; OR BUSINESS INTERUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*******************************************************************************/#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/* 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_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }/* 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(X, S) \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, S);/* Transmit Descriptor Count * * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers * Valid Range: 80-4096 for 82544 * * 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 * * Default Value: 80 */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 * * 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 */E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting");/* 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");/* 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 based NICs * * Default Value: 1 */E1000_PARAM(XsumRX, "Disable or enable Receive Checksum offload");/* Receive Interrupt Delay in units of 1.024 microseconds * * Valid Range: 0-65535 * * Default Value: 64/128 */E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");/* MDI-X Support Enable/Disable - Applies only to Copper PHY * * Valid Range: 0, 3 * - 0 - Auto in all modes * - 1 - MDI * - 2 - MDI-X * - 3 - Auto in 1000 Base-T mode (MDI in 10 Base-T and 100 Base-T) * * Default Value: 0 (Auto) */E1000_PARAM(MdiX, "Set MDI/MDI-X Mode");/* Automatic Correction of Reversed Cable Polarity Enable/Disable * This setting applies only to Copper PHY * * Valid Range: 0, 1 * - 0 - Disabled * - 1 - Enabled * * Default Value: 1 (Enabled) */E1000_PARAM(DisablePolarityCorrection, "Disable or enable Automatic Correction for Reversed Cable Polarity");#define AUTONEG_ADV_DEFAULT 0x2F#define AUTONEG_ADV_MASK 0x2F#define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL#define DEFAULT_TXD 256#define MAX_TXD 256#define MIN_TXD 80#define MAX_82544_TXD 4096#define DEFAULT_RXD 80#define MAX_RXD 256#define MIN_RXD 80#define MAX_82544_RXD 4096#define DEFAULT_RDTR 64#define DEFAULT_RADV 128#define MAX_RXDELAY 0xFFFF#define MIN_RXDELAY 0#define DEFAULT_MDIX 0#define MAX_MDIX 3#define MIN_MDIX 0struct e1000_option { enum { enable_option, range_option, list_option } type; char *name; 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 __devinite1000_validate_option(int *value, struct e1000_option *opt){ if(*value == OPTION_UNSET) { *value = opt->def; return 0; } switch (opt->type) { case enable_option: switch (*value) { case OPTION_ENABLED: printk(KERN_INFO "%s Enabled\n", opt->name); return 0; case OPTION_DISABLED: printk(KERN_INFO "%s Disabled\n", opt->name); return 0; } break; case range_option: if(*value >= opt->arg.r.min && *value <= opt->arg.r.max) { printk(KERN_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') printk(KERN_INFO "%s\n", ent->str); return 0; } } } break; default: BUG(); } printk(KERN_INFO "Invalid %s 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 paramters 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 __devinite1000_check_options(struct e1000_adapter *adapter){ int bd = adapter->bd_number; if(bd >= E1000_MAX_NIC) { printk(KERN_NOTICE "Warning: no configuration for board #%i\n", bd); printk(KERN_NOTICE "Using defaults for all values\n"); bd = E1000_MAX_NIC;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?