X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fnet%2Fixgb%2Fixgb_param.c;h=b27442a121f2fba05b388d0691c118c4170a0b78;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=9c66a259ee70aba021b02d43e20faac0b6444457;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/drivers/net/ixgb/ixgb_param.c b/drivers/net/ixgb/ixgb_param.c index 9c66a259e..b27442a12 100644 --- a/drivers/net/ixgb/ixgb_param.c +++ b/drivers/net/ixgb/ixgb_param.c @@ -1,27 +1,27 @@ /******************************************************************************* - - Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your option) - any later version. - - This program is distributed in the hope that 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 + Intel PRO/10GbE Linux driver + Copyright(c) 1999 - 2006 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., 59 - Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The full GNU General Public License is included in this distribution in the - file called LICENSE. - + 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 + e1000-devel Mailing List Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *******************************************************************************/ @@ -34,31 +34,21 @@ #define IXGB_MAX_NIC 8 -#define OPTION_UNSET -1 +#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 ixgb_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 IXGB_PARAM_INIT { [0 ... IXGB_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 IXGB_PARAM(X, S) \ -static const int __devinitdata X[IXGB_MAX_NIC + 1] = IXGB_PARAM_INIT; \ -MODULE_PARM(X, "1-" __MODULE_STRING(IXGB_MAX_NIC) "i"); \ -MODULE_PARM_DESC(X, S); +#define IXGB_PARAM_INIT { [0 ... IXGB_MAX_NIC] = OPTION_UNSET } +#define IXGB_PARAM(X, desc) \ + static int __devinitdata X[IXGB_MAX_NIC+1] = IXGB_PARAM_INIT; \ + static int num_##X = 0; \ + module_param_array_named(X, X, int, &num_##X, 0); \ + MODULE_PARM_DESC(X, desc); /* Transmit Descriptor Count * @@ -86,7 +76,7 @@ IXGB_PARAM(RxDescriptors, "Number of receive descriptors"); * - 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 + * Default Value: 2 - Tx only (silicon bug avoidance) */ IXGB_PARAM(FlowControl, "Flow Control setting"); @@ -121,15 +111,6 @@ IXGB_PARAM(TxIntDelay, "Transmit Interrupt Delay"); IXGB_PARAM(RxIntDelay, "Receive Interrupt Delay"); -/* Receive Interrupt Moderation enable (uses RxIntDelay too) - * - * Valid Range: 0,1 - * - * Default Value: 1 - */ - -IXGB_PARAM(RAIDC, "Disable or enable Receive Interrupt Moderation"); - /* Receive Flow control high threshold (when we send a pause frame) * (FCRTH) * @@ -156,7 +137,7 @@ IXGB_PARAM(RxFCLowThresh, "Receive Flow Control Low Threshold"); * * Valid Range: 1 - 65535 * - * Default Value: 256 (0x100) + * Default Value: 65535 (0xffff) (we'll send an xon if we recover) */ IXGB_PARAM(FCReqTimeout, "Flow Control Request Timeout"); @@ -173,13 +154,6 @@ IXGB_PARAM(FCReqTimeout, "Flow Control Request Timeout"); IXGB_PARAM(IntDelayEnable, "Transmit Interrupt Delay Enable"); -#define DEFAULT_TXD 256 -#define MAX_TXD 4096 -#define MIN_TXD 64 - -#define DEFAULT_RXD 1024 -#define MAX_RXD 4096 -#define MIN_RXD 64 #define DEFAULT_TIDV 32 #define MAX_TIDV 0xFFFF @@ -191,8 +165,6 @@ IXGB_PARAM(IntDelayEnable, "Transmit Interrupt Delay Enable"); #define XSUMRX_DEFAULT OPTION_ENABLED -#define FLOW_CONTROL_FULL ixgb_fc_full -#define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL #define DEFAULT_FCRTL 0x28000 #define DEFAULT_FCRTH 0x30000 #define MIN_FCRTL 0 @@ -200,9 +172,9 @@ IXGB_PARAM(IntDelayEnable, "Transmit Interrupt Delay Enable"); #define MIN_FCRTH 8 #define MAX_FCRTH 0x3FFF0 -#define DEFAULT_FCPAUSE 0x100 /* this may be too long */ #define MIN_FCPAUSE 1 #define MAX_FCPAUSE 0xffff +#define DEFAULT_FCPAUSE 0xFFFF /* this may be too long */ struct ixgb_option { enum { enable_option, range_option, list_option } type; @@ -224,9 +196,10 @@ struct ixgb_option { } arg; }; -static int __devinit ixgb_validate_option(int *value, struct ixgb_option *opt) +static int __devinit +ixgb_validate_option(int *value, struct ixgb_option *opt) { - if (*value == OPTION_UNSET) { + if(*value == OPTION_UNSET) { *value = opt->def; return 0; } @@ -243,32 +216,31 @@ static int __devinit ixgb_validate_option(int *value, struct ixgb_option *opt) } break; case range_option: - if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) { + 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 ixgb_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; - } + case list_option: { + int i; + struct ixgb_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); + opt->name, *value, opt->err); *value = opt->def; return -1; } @@ -285,198 +257,218 @@ static int __devinit ixgb_validate_option(int *value, struct ixgb_option *opt) * in a variable in the adapter structure. **/ -void __devinit ixgb_check_options(struct ixgb_adapter *adapter) +void __devinit +ixgb_check_options(struct ixgb_adapter *adapter) { int bd = adapter->bd_number; - if (bd >= IXGB_MAX_NIC) { + if(bd >= IXGB_MAX_NIC) { printk(KERN_NOTICE - "Warning: no configuration for board #%i\n", bd); + "Warning: no configuration for board #%i\n", bd); printk(KERN_NOTICE "Using defaults for all values\n"); - bd = IXGB_MAX_NIC; } - { /* Transmit Descriptor Count */ + { /* Transmit Descriptor Count */ struct ixgb_option opt = { .type = range_option, .name = "Transmit Descriptors", - .err = "using default of " __MODULE_STRING(DEFAULT_TXD), - .def = DEFAULT_TXD, - .arg = {.r = {.min = MIN_TXD, - .max = MAX_TXD}} + .err = "using default of " __MODULE_STRING(DEFAULT_TXD), + .def = DEFAULT_TXD, + .arg = { .r = { .min = MIN_TXD, + .max = MAX_TXD}} }; struct ixgb_desc_ring *tx_ring = &adapter->tx_ring; - tx_ring->count = TxDescriptors[bd]; - ixgb_validate_option(&tx_ring->count, &opt); + if(num_TxDescriptors > bd) { + tx_ring->count = TxDescriptors[bd]; + ixgb_validate_option(&tx_ring->count, &opt); + } else { + tx_ring->count = opt.def; + } IXGB_ROUNDUP(tx_ring->count, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE); } - { /* Receive Descriptor Count */ + { /* Receive Descriptor Count */ struct ixgb_option opt = { .type = range_option, .name = "Receive Descriptors", - .err = "using default of " __MODULE_STRING(DEFAULT_RXD), - .def = DEFAULT_RXD, - .arg = {.r = {.min = MIN_RXD, - .max = MAX_RXD}} + .err = "using default of " __MODULE_STRING(DEFAULT_RXD), + .def = DEFAULT_RXD, + .arg = { .r = { .min = MIN_RXD, + .max = MAX_RXD}} }; struct ixgb_desc_ring *rx_ring = &adapter->rx_ring; - rx_ring->count = RxDescriptors[bd]; - ixgb_validate_option(&rx_ring->count, &opt); + if(num_RxDescriptors > bd) { + rx_ring->count = RxDescriptors[bd]; + ixgb_validate_option(&rx_ring->count, &opt); + } else { + rx_ring->count = opt.def; + } IXGB_ROUNDUP(rx_ring->count, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE); } - { /* Receive Checksum Offload Enable */ + { /* Receive Checksum Offload Enable */ struct ixgb_option opt = { .type = enable_option, .name = "Receive Checksum Offload", - .err = "defaulting to Enabled", - .def = OPTION_ENABLED + .err = "defaulting to Enabled", + .def = OPTION_ENABLED }; - int rx_csum = XsumRX[bd]; - ixgb_validate_option(&rx_csum, &opt); - adapter->rx_csum = rx_csum; + if(num_XsumRX > bd) { + int rx_csum = XsumRX[bd]; + ixgb_validate_option(&rx_csum, &opt); + adapter->rx_csum = rx_csum; + } else { + adapter->rx_csum = opt.def; + } } - { /* Flow Control */ + { /* Flow Control */ struct ixgb_opt_list fc_list[] = - { {ixgb_fc_none, "Flow Control Disabled"}, - {ixgb_fc_rx_pause, "Flow Control Receive Only"}, - {ixgb_fc_tx_pause, "Flow Control Transmit Only"}, - {ixgb_fc_full, "Flow Control Enabled"}, - {ixgb_fc_default, "Flow Control Hardware Default"} - }; + {{ ixgb_fc_none, "Flow Control Disabled" }, + { ixgb_fc_rx_pause,"Flow Control Receive Only" }, + { ixgb_fc_tx_pause,"Flow Control Transmit Only" }, + { ixgb_fc_full, "Flow Control Enabled" }, + { ixgb_fc_default, "Flow Control Hardware Default" }}; struct ixgb_option opt = { .type = list_option, .name = "Flow Control", - .err = "reading default settings from EEPROM", - .def = ixgb_fc_full, - .arg = {.l = {.nr = LIST_LEN(fc_list), - .p = fc_list}} + .err = "reading default settings from EEPROM", + .def = ixgb_fc_tx_pause, + .arg = { .l = { .nr = LIST_LEN(fc_list), + .p = fc_list }} }; - int fc = FlowControl[bd]; - ixgb_validate_option(&fc, &opt); - adapter->hw.fc.type = fc; + if(num_FlowControl > bd) { + int fc = FlowControl[bd]; + ixgb_validate_option(&fc, &opt); + adapter->hw.fc.type = fc; + } else { + adapter->hw.fc.type = opt.def; + } } - { /* Receive Flow Control High Threshold */ + { /* Receive Flow Control High Threshold */ struct ixgb_option opt = { .type = range_option, .name = "Rx Flow Control High Threshold", - .err = - "using default of " __MODULE_STRING(DEFAULT_FCRTH), - .def = DEFAULT_FCRTH, - .arg = {.r = {.min = MIN_FCRTH, - .max = MAX_FCRTH}} + .err = "using default of " __MODULE_STRING(DEFAULT_FCRTH), + .def = DEFAULT_FCRTH, + .arg = { .r = { .min = MIN_FCRTH, + .max = MAX_FCRTH}} }; - adapter->hw.fc.high_water = RxFCHighThresh[bd]; - ixgb_validate_option(&adapter->hw.fc.high_water, &opt); - if (!(adapter->hw.fc.type & ixgb_fc_rx_pause)) - printk(KERN_INFO - "Ignoring RxFCHighThresh when no RxFC\n"); + if(num_RxFCHighThresh > bd) { + adapter->hw.fc.high_water = RxFCHighThresh[bd]; + ixgb_validate_option(&adapter->hw.fc.high_water, &opt); + } else { + adapter->hw.fc.high_water = opt.def; + } + if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) ) + printk (KERN_INFO + "Ignoring RxFCHighThresh when no RxFC\n"); } - { /* Receive Flow Control Low Threshold */ + { /* Receive Flow Control Low Threshold */ struct ixgb_option opt = { .type = range_option, .name = "Rx Flow Control Low Threshold", - .err = - "using default of " __MODULE_STRING(DEFAULT_FCRTL), - .def = DEFAULT_FCRTL, - .arg = {.r = {.min = MIN_FCRTL, - .max = MAX_FCRTL}} + .err = "using default of " __MODULE_STRING(DEFAULT_FCRTL), + .def = DEFAULT_FCRTL, + .arg = { .r = { .min = MIN_FCRTL, + .max = MAX_FCRTL}} }; - adapter->hw.fc.low_water = RxFCLowThresh[bd]; - ixgb_validate_option(&adapter->hw.fc.low_water, &opt); - if (!(adapter->hw.fc.type & ixgb_fc_rx_pause)) - printk(KERN_INFO - "Ignoring RxFCLowThresh when no RxFC\n"); + if(num_RxFCLowThresh > bd) { + adapter->hw.fc.low_water = RxFCLowThresh[bd]; + ixgb_validate_option(&adapter->hw.fc.low_water, &opt); + } else { + adapter->hw.fc.low_water = opt.def; + } + if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) ) + printk (KERN_INFO + "Ignoring RxFCLowThresh when no RxFC\n"); } - { /* Flow Control Pause Time Request */ + { /* Flow Control Pause Time Request*/ struct ixgb_option opt = { .type = range_option, .name = "Flow Control Pause Time Request", - .err = - "using default of " - __MODULE_STRING(DEFAULT_FCPAUSE), - .def = DEFAULT_FCPAUSE, - .arg = {.r = {.min = MIN_FCPAUSE, - .max = MAX_FCPAUSE}} + .err = "using default of "__MODULE_STRING(DEFAULT_FCPAUSE), + .def = DEFAULT_FCPAUSE, + .arg = { .r = { .min = MIN_FCPAUSE, + .max = MAX_FCPAUSE}} }; - int pause_time = FCReqTimeout[bd]; - - ixgb_validate_option(&pause_time, &opt); - if (!(adapter->hw.fc.type & ixgb_fc_rx_pause)) - printk(KERN_INFO - "Ignoring FCReqTimeout when no RxFC\n"); - adapter->hw.fc.pause_time = pause_time; + if(num_FCReqTimeout > bd) { + int pause_time = FCReqTimeout[bd]; + ixgb_validate_option(&pause_time, &opt); + adapter->hw.fc.pause_time = pause_time; + } else { + adapter->hw.fc.pause_time = opt.def; + } + if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) ) + printk (KERN_INFO + "Ignoring FCReqTimeout when no RxFC\n"); } /* high low and spacing check for rx flow control thresholds */ - if (adapter->hw.fc.type & ixgb_fc_rx_pause) { + if (adapter->hw.fc.type & ixgb_fc_tx_pause) { /* high must be greater than low */ if (adapter->hw.fc.high_water < (adapter->hw.fc.low_water + 8)) { /* set defaults */ - printk(KERN_INFO - "RxFCHighThresh must be >= (RxFCLowThresh + 8), " - "Using Defaults\n"); + printk (KERN_INFO + "RxFCHighThresh must be >= (RxFCLowThresh + 8), " + "Using Defaults\n"); adapter->hw.fc.high_water = DEFAULT_FCRTH; - adapter->hw.fc.low_water = DEFAULT_FCRTL; + adapter->hw.fc.low_water = DEFAULT_FCRTL; } } - { /* Receive Interrupt Delay */ + { /* Receive Interrupt Delay */ struct ixgb_option opt = { .type = range_option, .name = "Receive Interrupt Delay", - .err = - "using default of " __MODULE_STRING(DEFAULT_RDTR), - .def = DEFAULT_RDTR, - .arg = {.r = {.min = MIN_RDTR, - .max = MAX_RDTR}} + .err = "using default of " __MODULE_STRING(DEFAULT_RDTR), + .def = DEFAULT_RDTR, + .arg = { .r = { .min = MIN_RDTR, + .max = MAX_RDTR}} }; - adapter->rx_int_delay = RxIntDelay[bd]; - ixgb_validate_option(&adapter->rx_int_delay, &opt); - } - { /* Receive Interrupt Moderation */ - struct ixgb_option opt = { - .type = enable_option, - .name = "Advanced Receive Interrupt Moderation", - .err = "defaulting to Enabled", - .def = OPTION_ENABLED - }; - int raidc = RAIDC[bd]; - - ixgb_validate_option(&raidc, &opt); - adapter->raidc = raidc; + if(num_RxIntDelay > bd) { + adapter->rx_int_delay = RxIntDelay[bd]; + ixgb_validate_option(&adapter->rx_int_delay, &opt); + } else { + adapter->rx_int_delay = opt.def; + } } - { /* Transmit Interrupt Delay */ + { /* Transmit Interrupt Delay */ struct ixgb_option opt = { .type = range_option, .name = "Transmit Interrupt Delay", - .err = - "using default of " __MODULE_STRING(DEFAULT_TIDV), - .def = DEFAULT_TIDV, - .arg = {.r = {.min = MIN_TIDV, - .max = MAX_TIDV}} + .err = "using default of " __MODULE_STRING(DEFAULT_TIDV), + .def = DEFAULT_TIDV, + .arg = { .r = { .min = MIN_TIDV, + .max = MAX_TIDV}} }; - adapter->tx_int_delay = TxIntDelay[bd]; - ixgb_validate_option(&adapter->tx_int_delay, &opt); + if(num_TxIntDelay > bd) { + adapter->tx_int_delay = TxIntDelay[bd]; + ixgb_validate_option(&adapter->tx_int_delay, &opt); + } else { + adapter->tx_int_delay = opt.def; + } } - { /* Transmit Interrupt Delay Enable */ + { /* Transmit Interrupt Delay Enable */ struct ixgb_option opt = { .type = enable_option, .name = "Tx Interrupt Delay Enable", - .err = "defaulting to Enabled", - .def = OPTION_ENABLED + .err = "defaulting to Enabled", + .def = OPTION_ENABLED }; - int ide = IntDelayEnable[bd]; - ixgb_validate_option(&ide, &opt); - adapter->tx_int_delay_enable = ide; + if(num_IntDelayEnable > bd) { + int ide = IntDelayEnable[bd]; + ixgb_validate_option(&ide, &opt); + adapter->tx_int_delay_enable = ide; + } else { + adapter->tx_int_delay_enable = opt.def; + } } }