fp@2395: /******************************************************************************* fp@2395: fp@2395: Intel PRO/1000 Linux driver fp@2395: Copyright(c) 1999 - 2006 Intel Corporation. fp@2395: fp@2395: This program is free software; you can redistribute it and/or modify it fp@2395: under the terms and conditions of the GNU General Public License, fp@2395: version 2, as published by the Free Software Foundation. fp@2395: fp@2395: This program is distributed in the hope it will be useful, but WITHOUT fp@2395: ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or fp@2395: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for fp@2395: more details. fp@2395: fp@2395: You should have received a copy of the GNU General Public License along with fp@2395: this program; if not, write to the Free Software Foundation, Inc., fp@2395: 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. fp@2395: fp@2395: The full GNU General Public License is included in this distribution in fp@2395: the file called "COPYING". fp@2395: fp@2395: Contact Information: fp@2395: Linux NICS <linux.nics@intel.com> fp@2395: e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> fp@2395: Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 fp@2395: fp@2395: *******************************************************************************/ fp@2395: fp@2395: #include "e1000.h" fp@2395: fp@2395: /* This is the only thing that needs to be changed to adjust the fp@2395: * maximum number of ports that the driver can manage. fp@2395: */ fp@2395: fp@2395: #define E1000_MAX_NIC 32 fp@2395: fp@2395: #define OPTION_UNSET -1 fp@2395: #define OPTION_DISABLED 0 fp@2395: #define OPTION_ENABLED 1 fp@2395: fp@2395: /* All parameters are treated the same, as an integer array of values. fp@2395: * This macro just reduces the need to repeat the same declaration code fp@2395: * over and over (plus this helps to avoid typo bugs). fp@2395: */ fp@2395: fp@2395: #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET } fp@2395: #define E1000_PARAM(X, desc) \ fp@2395: static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \ fp@2395: static unsigned int num_##X; \ fp@2395: module_param_array_named(X, X, int, &num_##X, 0); \ fp@2395: MODULE_PARM_DESC(X, desc); fp@2395: fp@2395: /* Transmit Descriptor Count fp@2395: * fp@2395: * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers fp@2395: * Valid Range: 80-4096 for 82544 and newer fp@2395: * fp@2395: * Default Value: 256 fp@2395: */ fp@2395: E1000_PARAM(TxDescriptors, "Number of transmit descriptors"); fp@2395: fp@2395: /* Receive Descriptor Count fp@2395: * fp@2395: * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers fp@2395: * Valid Range: 80-4096 for 82544 and newer fp@2395: * fp@2395: * Default Value: 256 fp@2395: */ fp@2395: E1000_PARAM(RxDescriptors, "Number of receive descriptors"); fp@2395: fp@2395: /* User Specified Speed Override fp@2395: * fp@2395: * Valid Range: 0, 10, 100, 1000 fp@2395: * - 0 - auto-negotiate at all supported speeds fp@2395: * - 10 - only link at 10 Mbps fp@2395: * - 100 - only link at 100 Mbps fp@2395: * - 1000 - only link at 1000 Mbps fp@2395: * fp@2395: * Default Value: 0 fp@2395: */ fp@2395: E1000_PARAM(Speed, "Speed setting"); fp@2395: fp@2395: /* User Specified Duplex Override fp@2395: * fp@2395: * Valid Range: 0-2 fp@2395: * - 0 - auto-negotiate for duplex fp@2395: * - 1 - only link at half duplex fp@2395: * - 2 - only link at full duplex fp@2395: * fp@2395: * Default Value: 0 fp@2395: */ fp@2395: E1000_PARAM(Duplex, "Duplex setting"); fp@2395: fp@2395: /* Auto-negotiation Advertisement Override fp@2395: * fp@2395: * Valid Range: 0x01-0x0F, 0x20-0x2F (copper); 0x20 (fiber) fp@2395: * fp@2395: * The AutoNeg value is a bit mask describing which speed and duplex fp@2395: * combinations should be advertised during auto-negotiation. fp@2395: * The supported speed and duplex modes are listed below fp@2395: * fp@2395: * Bit 7 6 5 4 3 2 1 0 fp@2395: * Speed (Mbps) N/A N/A 1000 N/A 100 100 10 10 fp@2395: * Duplex Full Full Half Full Half fp@2395: * fp@2395: * Default Value: 0x2F (copper); 0x20 (fiber) fp@2395: */ fp@2395: E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting"); fp@2395: #define AUTONEG_ADV_DEFAULT 0x2F fp@2395: #define AUTONEG_ADV_MASK 0x2F fp@2395: fp@2395: /* User Specified Flow Control Override fp@2395: * fp@2395: * Valid Range: 0-3 fp@2395: * - 0 - No Flow Control fp@2395: * - 1 - Rx only, respond to PAUSE frames but do not generate them fp@2395: * - 2 - Tx only, generate PAUSE frames but ignore them on receive fp@2395: * - 3 - Full Flow Control Support fp@2395: * fp@2395: * Default Value: Read flow control settings from the EEPROM fp@2395: */ fp@2395: E1000_PARAM(FlowControl, "Flow Control setting"); fp@2395: #define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL fp@2395: fp@2395: /* XsumRX - Receive Checksum Offload Enable/Disable fp@2395: * fp@2395: * Valid Range: 0, 1 fp@2395: * - 0 - disables all checksum offload fp@2395: * - 1 - enables receive IP/TCP/UDP checksum offload fp@2395: * on 82543 and newer -based NICs fp@2395: * fp@2395: * Default Value: 1 fp@2395: */ fp@2395: E1000_PARAM(XsumRX, "Disable or enable Receive Checksum offload"); fp@2395: fp@2395: /* Transmit Interrupt Delay in units of 1.024 microseconds fp@2395: * Tx interrupt delay needs to typically be set to something non zero fp@2395: * fp@2395: * Valid Range: 0-65535 fp@2395: */ fp@2395: E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay"); fp@2395: #define DEFAULT_TIDV 8 fp@2395: #define MAX_TXDELAY 0xFFFF fp@2395: #define MIN_TXDELAY 0 fp@2395: fp@2395: /* Transmit Absolute Interrupt Delay in units of 1.024 microseconds fp@2395: * fp@2395: * Valid Range: 0-65535 fp@2395: */ fp@2395: E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay"); fp@2395: #define DEFAULT_TADV 32 fp@2395: #define MAX_TXABSDELAY 0xFFFF fp@2395: #define MIN_TXABSDELAY 0 fp@2395: fp@2395: /* Receive Interrupt Delay in units of 1.024 microseconds fp@2395: * hardware will likely hang if you set this to anything but zero. fp@2395: * fp@2395: * Valid Range: 0-65535 fp@2395: */ fp@2395: E1000_PARAM(RxIntDelay, "Receive Interrupt Delay"); fp@2395: #define DEFAULT_RDTR 0 fp@2395: #define MAX_RXDELAY 0xFFFF fp@2395: #define MIN_RXDELAY 0 fp@2395: fp@2395: /* Receive Absolute Interrupt Delay in units of 1.024 microseconds fp@2395: * fp@2395: * Valid Range: 0-65535 fp@2395: */ fp@2395: E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay"); fp@2395: #define DEFAULT_RADV 8 fp@2395: #define MAX_RXABSDELAY 0xFFFF fp@2395: #define MIN_RXABSDELAY 0 fp@2395: fp@2395: /* Interrupt Throttle Rate (interrupts/sec) fp@2395: * fp@2395: * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative) fp@2395: */ fp@2395: E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate"); fp@2395: #define DEFAULT_ITR 3 fp@2395: #define MAX_ITR 100000 fp@2395: #define MIN_ITR 100 fp@2395: fp@2395: /* Enable Smart Power Down of the PHY fp@2395: * fp@2395: * Valid Range: 0, 1 fp@2395: * fp@2395: * Default Value: 0 (disabled) fp@2395: */ fp@2395: E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down"); fp@2395: fp@2395: struct e1000_option { fp@2395: enum { enable_option, range_option, list_option } type; fp@2395: const char *name; fp@2395: const char *err; fp@2395: int def; fp@2395: union { fp@2395: struct { /* range_option info */ fp@2395: int min; fp@2395: int max; fp@2395: } r; fp@2395: struct { /* list_option info */ fp@2395: int nr; fp@2395: const struct e1000_opt_list { int i; char *str; } *p; fp@2395: } l; fp@2395: } arg; fp@2395: }; fp@2395: fp@2395: static int __devinit e1000_validate_option(unsigned int *value, fp@2395: const struct e1000_option *opt, fp@2395: struct e1000_adapter *adapter) fp@2395: { fp@2395: if (*value == OPTION_UNSET) { fp@2395: *value = opt->def; fp@2395: return 0; fp@2395: } fp@2395: fp@2395: switch (opt->type) { fp@2395: case enable_option: fp@2395: switch (*value) { fp@2395: case OPTION_ENABLED: fp@2395: e_dev_info("%s Enabled\n", opt->name); fp@2395: return 0; fp@2395: case OPTION_DISABLED: fp@2395: e_dev_info("%s Disabled\n", opt->name); fp@2395: return 0; fp@2395: } fp@2395: break; fp@2395: case range_option: fp@2395: if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) { fp@2395: e_dev_info("%s set to %i\n", opt->name, *value); fp@2395: return 0; fp@2395: } fp@2395: break; fp@2395: case list_option: { fp@2395: int i; fp@2395: const struct e1000_opt_list *ent; fp@2395: fp@2395: for (i = 0; i < opt->arg.l.nr; i++) { fp@2395: ent = &opt->arg.l.p[i]; fp@2395: if (*value == ent->i) { fp@2395: if (ent->str[0] != '\0') fp@2395: e_dev_info("%s\n", ent->str); fp@2395: return 0; fp@2395: } fp@2395: } fp@2395: } fp@2395: break; fp@2395: default: fp@2395: BUG(); fp@2395: } fp@2395: fp@2395: e_dev_info("Invalid %s value specified (%i) %s\n", fp@2395: opt->name, *value, opt->err); fp@2395: *value = opt->def; fp@2395: return -1; fp@2395: } fp@2395: fp@2395: static void e1000_check_fiber_options(struct e1000_adapter *adapter); fp@2395: static void e1000_check_copper_options(struct e1000_adapter *adapter); fp@2395: fp@2395: /** fp@2395: * e1000_check_options - Range Checking for Command Line Parameters fp@2395: * @adapter: board private structure fp@2395: * fp@2395: * This routine checks all command line parameters for valid user fp@2395: * input. If an invalid value is given, or if no user specified fp@2395: * value exists, a default value is used. The final value is stored fp@2395: * in a variable in the adapter structure. fp@2395: **/ fp@2395: fp@2395: void __devinit e1000_check_options(struct e1000_adapter *adapter) fp@2395: { fp@2395: struct e1000_option opt; fp@2395: int bd = adapter->bd_number; fp@2395: fp@2395: if (bd >= E1000_MAX_NIC) { fp@2395: e_dev_warn("Warning: no configuration for board #%i " fp@2395: "using defaults for all values\n", bd); fp@2395: } fp@2395: fp@2395: { /* Transmit Descriptor Count */ fp@2395: struct e1000_tx_ring *tx_ring = adapter->tx_ring; fp@2395: int i; fp@2395: e1000_mac_type mac_type = adapter->hw.mac_type; fp@2395: fp@2395: opt = (struct e1000_option) { fp@2395: .type = range_option, fp@2395: .name = "Transmit Descriptors", fp@2395: .err = "using default of " fp@2395: __MODULE_STRING(E1000_DEFAULT_TXD), fp@2395: .def = E1000_DEFAULT_TXD, fp@2395: .arg = { .r = { fp@2395: .min = E1000_MIN_TXD, fp@2395: .max = mac_type < e1000_82544 ? E1000_MAX_TXD : E1000_MAX_82544_TXD fp@2395: }} fp@2395: }; fp@2395: fp@2395: if (num_TxDescriptors > bd) { fp@2395: tx_ring->count = TxDescriptors[bd]; fp@2395: e1000_validate_option(&tx_ring->count, &opt, adapter); fp@2395: tx_ring->count = ALIGN(tx_ring->count, fp@2395: REQ_TX_DESCRIPTOR_MULTIPLE); fp@2395: } else { fp@2395: tx_ring->count = opt.def; fp@2395: } fp@2395: for (i = 0; i < adapter->num_tx_queues; i++) fp@2395: tx_ring[i].count = tx_ring->count; fp@2395: } fp@2395: { /* Receive Descriptor Count */ fp@2395: struct e1000_rx_ring *rx_ring = adapter->rx_ring; fp@2395: int i; fp@2395: e1000_mac_type mac_type = adapter->hw.mac_type; fp@2395: fp@2395: opt = (struct e1000_option) { fp@2395: .type = range_option, fp@2395: .name = "Receive Descriptors", fp@2395: .err = "using default of " fp@2395: __MODULE_STRING(E1000_DEFAULT_RXD), fp@2395: .def = E1000_DEFAULT_RXD, fp@2395: .arg = { .r = { fp@2395: .min = E1000_MIN_RXD, fp@2395: .max = mac_type < e1000_82544 ? E1000_MAX_RXD : E1000_MAX_82544_RXD fp@2395: }} fp@2395: }; fp@2395: fp@2395: if (num_RxDescriptors > bd) { fp@2395: rx_ring->count = RxDescriptors[bd]; fp@2395: e1000_validate_option(&rx_ring->count, &opt, adapter); fp@2395: rx_ring->count = ALIGN(rx_ring->count, fp@2395: REQ_RX_DESCRIPTOR_MULTIPLE); fp@2395: } else { fp@2395: rx_ring->count = opt.def; fp@2395: } fp@2395: for (i = 0; i < adapter->num_rx_queues; i++) fp@2395: rx_ring[i].count = rx_ring->count; fp@2395: } fp@2395: { /* Checksum Offload Enable/Disable */ fp@2395: opt = (struct e1000_option) { fp@2395: .type = enable_option, fp@2395: .name = "Checksum Offload", fp@2395: .err = "defaulting to Enabled", fp@2395: .def = OPTION_ENABLED fp@2395: }; fp@2395: fp@2395: if (num_XsumRX > bd) { fp@2395: unsigned int rx_csum = XsumRX[bd]; fp@2395: e1000_validate_option(&rx_csum, &opt, adapter); fp@2395: adapter->rx_csum = rx_csum; fp@2395: } else { fp@2395: adapter->rx_csum = opt.def; fp@2395: } fp@2395: } fp@2395: { /* Flow Control */ fp@2395: fp@2395: static const struct e1000_opt_list fc_list[] = { fp@2395: { E1000_FC_NONE, "Flow Control Disabled" }, fp@2395: { E1000_FC_RX_PAUSE, "Flow Control Receive Only" }, fp@2395: { E1000_FC_TX_PAUSE, "Flow Control Transmit Only" }, fp@2395: { E1000_FC_FULL, "Flow Control Enabled" }, fp@2395: { E1000_FC_DEFAULT, "Flow Control Hardware Default" } fp@2395: }; fp@2395: fp@2395: opt = (struct e1000_option) { fp@2395: .type = list_option, fp@2395: .name = "Flow Control", fp@2395: .err = "reading default settings from EEPROM", fp@2395: .def = E1000_FC_DEFAULT, fp@2395: .arg = { .l = { .nr = ARRAY_SIZE(fc_list), fp@2395: .p = fc_list }} fp@2395: }; fp@2395: fp@2395: if (num_FlowControl > bd) { fp@2395: unsigned int fc = FlowControl[bd]; fp@2395: e1000_validate_option(&fc, &opt, adapter); fp@2395: adapter->hw.fc = adapter->hw.original_fc = fc; fp@2395: } else { fp@2395: adapter->hw.fc = adapter->hw.original_fc = opt.def; fp@2395: } fp@2395: } fp@2395: { /* Transmit Interrupt Delay */ fp@2395: opt = (struct e1000_option) { fp@2395: .type = range_option, fp@2395: .name = "Transmit Interrupt Delay", fp@2395: .err = "using default of " __MODULE_STRING(DEFAULT_TIDV), fp@2395: .def = DEFAULT_TIDV, fp@2395: .arg = { .r = { .min = MIN_TXDELAY, fp@2395: .max = MAX_TXDELAY }} fp@2395: }; fp@2395: fp@2395: if (num_TxIntDelay > bd) { fp@2395: adapter->tx_int_delay = TxIntDelay[bd]; fp@2395: e1000_validate_option(&adapter->tx_int_delay, &opt, fp@2395: adapter); fp@2395: } else { fp@2395: adapter->tx_int_delay = opt.def; fp@2395: } fp@2395: } fp@2395: { /* Transmit Absolute Interrupt Delay */ fp@2395: opt = (struct e1000_option) { fp@2395: .type = range_option, fp@2395: .name = "Transmit Absolute Interrupt Delay", fp@2395: .err = "using default of " __MODULE_STRING(DEFAULT_TADV), fp@2395: .def = DEFAULT_TADV, fp@2395: .arg = { .r = { .min = MIN_TXABSDELAY, fp@2395: .max = MAX_TXABSDELAY }} fp@2395: }; fp@2395: fp@2395: if (num_TxAbsIntDelay > bd) { fp@2395: adapter->tx_abs_int_delay = TxAbsIntDelay[bd]; fp@2395: e1000_validate_option(&adapter->tx_abs_int_delay, &opt, fp@2395: adapter); fp@2395: } else { fp@2395: adapter->tx_abs_int_delay = opt.def; fp@2395: } fp@2395: } fp@2395: { /* Receive Interrupt Delay */ fp@2395: opt = (struct e1000_option) { fp@2395: .type = range_option, fp@2395: .name = "Receive Interrupt Delay", fp@2395: .err = "using default of " __MODULE_STRING(DEFAULT_RDTR), fp@2395: .def = DEFAULT_RDTR, fp@2395: .arg = { .r = { .min = MIN_RXDELAY, fp@2395: .max = MAX_RXDELAY }} fp@2395: }; fp@2395: fp@2395: if (num_RxIntDelay > bd) { fp@2395: adapter->rx_int_delay = RxIntDelay[bd]; fp@2395: e1000_validate_option(&adapter->rx_int_delay, &opt, fp@2395: adapter); fp@2395: } else { fp@2395: adapter->rx_int_delay = opt.def; fp@2395: } fp@2395: } fp@2395: { /* Receive Absolute Interrupt Delay */ fp@2395: opt = (struct e1000_option) { fp@2395: .type = range_option, fp@2395: .name = "Receive Absolute Interrupt Delay", fp@2395: .err = "using default of " __MODULE_STRING(DEFAULT_RADV), fp@2395: .def = DEFAULT_RADV, fp@2395: .arg = { .r = { .min = MIN_RXABSDELAY, fp@2395: .max = MAX_RXABSDELAY }} fp@2395: }; fp@2395: fp@2395: if (num_RxAbsIntDelay > bd) { fp@2395: adapter->rx_abs_int_delay = RxAbsIntDelay[bd]; fp@2395: e1000_validate_option(&adapter->rx_abs_int_delay, &opt, fp@2395: adapter); fp@2395: } else { fp@2395: adapter->rx_abs_int_delay = opt.def; fp@2395: } fp@2395: } fp@2395: { /* Interrupt Throttling Rate */ fp@2395: opt = (struct e1000_option) { fp@2395: .type = range_option, fp@2395: .name = "Interrupt Throttling Rate (ints/sec)", fp@2395: .err = "using default of " __MODULE_STRING(DEFAULT_ITR), fp@2395: .def = DEFAULT_ITR, fp@2395: .arg = { .r = { .min = MIN_ITR, fp@2395: .max = MAX_ITR }} fp@2395: }; fp@2395: fp@2395: if (num_InterruptThrottleRate > bd) { fp@2395: adapter->itr = InterruptThrottleRate[bd]; fp@2395: switch (adapter->itr) { fp@2395: case 0: fp@2395: e_dev_info("%s turned off\n", opt.name); fp@2395: break; fp@2395: case 1: fp@2395: e_dev_info("%s set to dynamic mode\n", fp@2395: opt.name); fp@2395: adapter->itr_setting = adapter->itr; fp@2395: adapter->itr = 20000; fp@2395: break; fp@2395: case 3: fp@2395: e_dev_info("%s set to dynamic conservative " fp@2395: "mode\n", opt.name); fp@2395: adapter->itr_setting = adapter->itr; fp@2395: adapter->itr = 20000; fp@2395: break; fp@2395: case 4: fp@2395: e_dev_info("%s set to simplified " fp@2395: "(2000-8000) ints mode\n", opt.name); fp@2395: adapter->itr_setting = adapter->itr; fp@2395: break; fp@2395: default: fp@2395: e1000_validate_option(&adapter->itr, &opt, fp@2395: adapter); fp@2395: /* save the setting, because the dynamic bits fp@2395: * change itr. fp@2395: * clear the lower two bits because they are fp@2395: * used as control */ fp@2395: adapter->itr_setting = adapter->itr & ~3; fp@2395: break; fp@2395: } fp@2395: } else { fp@2395: adapter->itr_setting = opt.def; fp@2395: adapter->itr = 20000; fp@2395: } fp@2395: } fp@2395: { /* Smart Power Down */ fp@2395: opt = (struct e1000_option) { fp@2395: .type = enable_option, fp@2395: .name = "PHY Smart Power Down", fp@2395: .err = "defaulting to Disabled", fp@2395: .def = OPTION_DISABLED fp@2395: }; fp@2395: fp@2395: if (num_SmartPowerDownEnable > bd) { fp@2395: unsigned int spd = SmartPowerDownEnable[bd]; fp@2395: e1000_validate_option(&spd, &opt, adapter); fp@2395: adapter->smart_power_down = spd; fp@2395: } else { fp@2395: adapter->smart_power_down = opt.def; fp@2395: } fp@2395: } fp@2395: fp@2395: switch (adapter->hw.media_type) { fp@2395: case e1000_media_type_fiber: fp@2395: case e1000_media_type_internal_serdes: fp@2395: e1000_check_fiber_options(adapter); fp@2395: break; fp@2395: case e1000_media_type_copper: fp@2395: e1000_check_copper_options(adapter); fp@2395: break; fp@2395: default: fp@2395: BUG(); fp@2395: } fp@2395: } fp@2395: fp@2395: /** fp@2395: * e1000_check_fiber_options - Range Checking for Link Options, Fiber Version fp@2395: * @adapter: board private structure fp@2395: * fp@2395: * Handles speed and duplex options on fiber adapters fp@2395: **/ fp@2395: fp@2395: static void __devinit e1000_check_fiber_options(struct e1000_adapter *adapter) fp@2395: { fp@2395: int bd = adapter->bd_number; fp@2395: if (num_Speed > bd) { fp@2395: e_dev_info("Speed not valid for fiber adapters, parameter " fp@2395: "ignored\n"); fp@2395: } fp@2395: fp@2395: if (num_Duplex > bd) { fp@2395: e_dev_info("Duplex not valid for fiber adapters, parameter " fp@2395: "ignored\n"); fp@2395: } fp@2395: fp@2395: if ((num_AutoNeg > bd) && (AutoNeg[bd] != 0x20)) { fp@2395: e_dev_info("AutoNeg other than 1000/Full is not valid for fiber" fp@2395: "adapters, parameter ignored\n"); fp@2395: } fp@2395: } fp@2395: fp@2395: /** fp@2395: * e1000_check_copper_options - Range Checking for Link Options, Copper Version fp@2395: * @adapter: board private structure fp@2395: * fp@2395: * Handles speed and duplex options on copper adapters fp@2395: **/ fp@2395: fp@2395: static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter) fp@2395: { fp@2395: struct e1000_option opt; fp@2395: unsigned int speed, dplx, an; fp@2395: int bd = adapter->bd_number; fp@2395: fp@2395: { /* Speed */ fp@2395: static const struct e1000_opt_list speed_list[] = { fp@2395: { 0, "" }, fp@2395: { SPEED_10, "" }, fp@2395: { SPEED_100, "" }, fp@2395: { SPEED_1000, "" }}; fp@2395: fp@2395: opt = (struct e1000_option) { fp@2395: .type = list_option, fp@2395: .name = "Speed", fp@2395: .err = "parameter ignored", fp@2395: .def = 0, fp@2395: .arg = { .l = { .nr = ARRAY_SIZE(speed_list), fp@2395: .p = speed_list }} fp@2395: }; fp@2395: fp@2395: if (num_Speed > bd) { fp@2395: speed = Speed[bd]; fp@2395: e1000_validate_option(&speed, &opt, adapter); fp@2395: } else { fp@2395: speed = opt.def; fp@2395: } fp@2395: } fp@2395: { /* Duplex */ fp@2395: static const struct e1000_opt_list dplx_list[] = { fp@2395: { 0, "" }, fp@2395: { HALF_DUPLEX, "" }, fp@2395: { FULL_DUPLEX, "" }}; fp@2395: fp@2395: opt = (struct e1000_option) { fp@2395: .type = list_option, fp@2395: .name = "Duplex", fp@2395: .err = "parameter ignored", fp@2395: .def = 0, fp@2395: .arg = { .l = { .nr = ARRAY_SIZE(dplx_list), fp@2395: .p = dplx_list }} fp@2395: }; fp@2395: fp@2395: if (num_Duplex > bd) { fp@2395: dplx = Duplex[bd]; fp@2395: e1000_validate_option(&dplx, &opt, adapter); fp@2395: } else { fp@2395: dplx = opt.def; fp@2395: } fp@2395: } fp@2395: fp@2395: if ((num_AutoNeg > bd) && (speed != 0 || dplx != 0)) { fp@2395: e_dev_info("AutoNeg specified along with Speed or Duplex, " fp@2395: "parameter ignored\n"); fp@2395: adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT; fp@2395: } else { /* Autoneg */ fp@2395: static const struct e1000_opt_list an_list[] = fp@2395: #define AA "AutoNeg advertising " fp@2395: {{ 0x01, AA "10/HD" }, fp@2395: { 0x02, AA "10/FD" }, fp@2395: { 0x03, AA "10/FD, 10/HD" }, fp@2395: { 0x04, AA "100/HD" }, fp@2395: { 0x05, AA "100/HD, 10/HD" }, fp@2395: { 0x06, AA "100/HD, 10/FD" }, fp@2395: { 0x07, AA "100/HD, 10/FD, 10/HD" }, fp@2395: { 0x08, AA "100/FD" }, fp@2395: { 0x09, AA "100/FD, 10/HD" }, fp@2395: { 0x0a, AA "100/FD, 10/FD" }, fp@2395: { 0x0b, AA "100/FD, 10/FD, 10/HD" }, fp@2395: { 0x0c, AA "100/FD, 100/HD" }, fp@2395: { 0x0d, AA "100/FD, 100/HD, 10/HD" }, fp@2395: { 0x0e, AA "100/FD, 100/HD, 10/FD" }, fp@2395: { 0x0f, AA "100/FD, 100/HD, 10/FD, 10/HD" }, fp@2395: { 0x20, AA "1000/FD" }, fp@2395: { 0x21, AA "1000/FD, 10/HD" }, fp@2395: { 0x22, AA "1000/FD, 10/FD" }, fp@2395: { 0x23, AA "1000/FD, 10/FD, 10/HD" }, fp@2395: { 0x24, AA "1000/FD, 100/HD" }, fp@2395: { 0x25, AA "1000/FD, 100/HD, 10/HD" }, fp@2395: { 0x26, AA "1000/FD, 100/HD, 10/FD" }, fp@2395: { 0x27, AA "1000/FD, 100/HD, 10/FD, 10/HD" }, fp@2395: { 0x28, AA "1000/FD, 100/FD" }, fp@2395: { 0x29, AA "1000/FD, 100/FD, 10/HD" }, fp@2395: { 0x2a, AA "1000/FD, 100/FD, 10/FD" }, fp@2395: { 0x2b, AA "1000/FD, 100/FD, 10/FD, 10/HD" }, fp@2395: { 0x2c, AA "1000/FD, 100/FD, 100/HD" }, fp@2395: { 0x2d, AA "1000/FD, 100/FD, 100/HD, 10/HD" }, fp@2395: { 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" }, fp@2395: { 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }}; fp@2395: fp@2395: opt = (struct e1000_option) { fp@2395: .type = list_option, fp@2395: .name = "AutoNeg", fp@2395: .err = "parameter ignored", fp@2395: .def = AUTONEG_ADV_DEFAULT, fp@2395: .arg = { .l = { .nr = ARRAY_SIZE(an_list), fp@2395: .p = an_list }} fp@2395: }; fp@2395: fp@2395: if (num_AutoNeg > bd) { fp@2395: an = AutoNeg[bd]; fp@2395: e1000_validate_option(&an, &opt, adapter); fp@2395: } else { fp@2395: an = opt.def; fp@2395: } fp@2395: adapter->hw.autoneg_advertised = an; fp@2395: } fp@2395: fp@2395: switch (speed + dplx) { fp@2395: case 0: fp@2395: adapter->hw.autoneg = adapter->fc_autoneg = 1; fp@2395: if ((num_Speed > bd) && (speed != 0 || dplx != 0)) fp@2395: e_dev_info("Speed and duplex autonegotiation " fp@2395: "enabled\n"); fp@2395: break; fp@2395: case HALF_DUPLEX: fp@2395: e_dev_info("Half Duplex specified without Speed\n"); fp@2395: e_dev_info("Using Autonegotiation at Half Duplex only\n"); fp@2395: adapter->hw.autoneg = adapter->fc_autoneg = 1; fp@2395: adapter->hw.autoneg_advertised = ADVERTISE_10_HALF | fp@2395: ADVERTISE_100_HALF; fp@2395: break; fp@2395: case FULL_DUPLEX: fp@2395: e_dev_info("Full Duplex specified without Speed\n"); fp@2395: e_dev_info("Using Autonegotiation at Full Duplex only\n"); fp@2395: adapter->hw.autoneg = adapter->fc_autoneg = 1; fp@2395: adapter->hw.autoneg_advertised = ADVERTISE_10_FULL | fp@2395: ADVERTISE_100_FULL | fp@2395: ADVERTISE_1000_FULL; fp@2395: break; fp@2395: case SPEED_10: fp@2395: e_dev_info("10 Mbps Speed specified without Duplex\n"); fp@2395: e_dev_info("Using Autonegotiation at 10 Mbps only\n"); fp@2395: adapter->hw.autoneg = adapter->fc_autoneg = 1; fp@2395: adapter->hw.autoneg_advertised = ADVERTISE_10_HALF | fp@2395: ADVERTISE_10_FULL; fp@2395: break; fp@2395: case SPEED_10 + HALF_DUPLEX: fp@2395: e_dev_info("Forcing to 10 Mbps Half Duplex\n"); fp@2395: adapter->hw.autoneg = adapter->fc_autoneg = 0; fp@2395: adapter->hw.forced_speed_duplex = e1000_10_half; fp@2395: adapter->hw.autoneg_advertised = 0; fp@2395: break; fp@2395: case SPEED_10 + FULL_DUPLEX: fp@2395: e_dev_info("Forcing to 10 Mbps Full Duplex\n"); fp@2395: adapter->hw.autoneg = adapter->fc_autoneg = 0; fp@2395: adapter->hw.forced_speed_duplex = e1000_10_full; fp@2395: adapter->hw.autoneg_advertised = 0; fp@2395: break; fp@2395: case SPEED_100: fp@2395: e_dev_info("100 Mbps Speed specified without Duplex\n"); fp@2395: e_dev_info("Using Autonegotiation at 100 Mbps only\n"); fp@2395: adapter->hw.autoneg = adapter->fc_autoneg = 1; fp@2395: adapter->hw.autoneg_advertised = ADVERTISE_100_HALF | fp@2395: ADVERTISE_100_FULL; fp@2395: break; fp@2395: case SPEED_100 + HALF_DUPLEX: fp@2395: e_dev_info("Forcing to 100 Mbps Half Duplex\n"); fp@2395: adapter->hw.autoneg = adapter->fc_autoneg = 0; fp@2395: adapter->hw.forced_speed_duplex = e1000_100_half; fp@2395: adapter->hw.autoneg_advertised = 0; fp@2395: break; fp@2395: case SPEED_100 + FULL_DUPLEX: fp@2395: e_dev_info("Forcing to 100 Mbps Full Duplex\n"); fp@2395: adapter->hw.autoneg = adapter->fc_autoneg = 0; fp@2395: adapter->hw.forced_speed_duplex = e1000_100_full; fp@2395: adapter->hw.autoneg_advertised = 0; fp@2395: break; fp@2395: case SPEED_1000: fp@2395: e_dev_info("1000 Mbps Speed specified without Duplex\n"); fp@2395: goto full_duplex_only; fp@2395: case SPEED_1000 + HALF_DUPLEX: fp@2395: e_dev_info("Half Duplex is not supported at 1000 Mbps\n"); fp@2395: /* fall through */ fp@2395: case SPEED_1000 + FULL_DUPLEX: fp@2395: full_duplex_only: fp@2395: e_dev_info("Using Autonegotiation at 1000 Mbps Full Duplex " fp@2395: "only\n"); fp@2395: adapter->hw.autoneg = adapter->fc_autoneg = 1; fp@2395: adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL; fp@2395: break; fp@2395: default: fp@2395: BUG(); fp@2395: } fp@2395: fp@2395: /* Speed, AutoNeg and MDI/MDI-X must all play nice */ fp@2395: if (e1000_validate_mdi_setting(&(adapter->hw)) < 0) { fp@2395: e_dev_info("Speed, AutoNeg and MDI-X specs are incompatible. " fp@2395: "Setting MDI-X to a compatible value.\n"); fp@2395: } fp@2395: } fp@2395: