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