/drivers/net/e1000e/param.c
C | 478 lines | 324 code | 36 blank | 118 comment | 46 complexity | ee4ee17cf96b8e6dc34c0f270bd322f6 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
- /*******************************************************************************
- Intel PRO/1000 Linux driver
- Copyright(c) 1999 - 2011 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 <linux/pci.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
- #define COPYBREAK_DEFAULT 256
- unsigned int copybreak = COPYBREAK_DEFAULT;
- module_param(copybreak, uint, 0644);
- MODULE_PARM_DESC(copybreak,
- "Maximum size of packet that is copied to a new buffer on receive");
- /*
- * 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 }
- #define E1000_PARAM(X, desc) \
- static int __devinitdata X[E1000_MAX_NIC+1] \
- = E1000_PARAM_INIT; \
- static unsigned int num_##X; \
- module_param_array_named(X, X, int, &num_##X, 0); \
- MODULE_PARM_DESC(X, desc);
- /*
- * 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 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 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
- /* IntMode (Interrupt Mode)
- *
- * Valid Range: 0 - 2
- *
- * Default Value: 2 (MSI-X)
- */
- E1000_PARAM(IntMode, "Interrupt Mode");
- #define MAX_INTMODE 2
- #define MIN_INTMODE 0
- /*
- * 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");
- /*
- * Write Protect NVM
- *
- * Valid Range: 0, 1
- *
- * Default Value: 1 (enabled)
- */
- E1000_PARAM(WriteProtectNVM, "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]");
- /*
- * Enable CRC Stripping
- *
- * Valid Range: 0, 1
- *
- * Default Value: 1 (enabled)
- */
- E1000_PARAM(CrcStripping, "Enable CRC Stripping, disable if your BMC needs " \
- "the CRC");
- 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:
- e_info("%s Enabled\n", opt->name);
- return 0;
- case OPTION_DISABLED:
- e_info("%s Disabled\n", opt->name);
- return 0;
- }
- break;
- case range_option:
- if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
- e_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')
- e_info("%s\n", ent->str);
- return 0;
- }
- }
- }
- break;
- default:
- BUG();
- }
- e_info("Invalid %s value specified (%i) %s\n", opt->name, *value,
- opt->err);
- *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.
- **/
- void __devinit e1000e_check_options(struct e1000_adapter *adapter)
- {
- struct e1000_hw *hw = &adapter->hw;
- int bd = adapter->bd_number;
- if (bd >= E1000_MAX_NIC) {
- e_notice("Warning: no configuration for board #%i\n", bd);
- e_notice("Using defaults for all values\n");
- }
-