USB Storage: unusual_devs.h entry for Sony Ericsson P990i
[safe/jmp/linux-2.6] / drivers / net / e1000 / e1000_param.c
index ccbbe5a..2128427 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   
-  Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
+  Copyright(c) 1999 - 2006 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 
@@ -22,6 +22,7 @@
   
   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
 
 *******************************************************************************/
  */
 
 #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
+/* 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(X, desc) \
        static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
        static int num_##X = 0; \
@@ -177,11 +188,29 @@ E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
  *
  * Valid Range: 100-100000 (0=off, 1=dynamic)
  *
- * Default Value: 1
+ * Default Value: 8000
  */
 
 E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
 
+/* 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");
+
 #define AUTONEG_ADV_DEFAULT  0x2F
 #define AUTONEG_ADV_MASK     0x2F
 #define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
@@ -227,7 +256,7 @@ static int __devinit
 e1000_validate_option(int *value, struct e1000_option *opt,
                struct e1000_adapter *adapter)
 {
-       if(*value == OPTION_UNSET) {
+       if (*value == OPTION_UNSET) {
                *value = opt->def;
                return 0;
        }
@@ -244,7 +273,7 @@ e1000_validate_option(int *value, struct e1000_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) {
                        DPRINTK(PROBE, INFO,
                                        "%s set to %i\n", opt->name, *value);
                        return 0;
@@ -254,10 +283,10 @@ e1000_validate_option(int *value, struct e1000_option *opt,
                int i;
                struct e1000_opt_list *ent;
 
-               for(i = 0; i < opt->arg.l.nr; i++) {
+               for (i = 0; i < opt->arg.l.nr; i++) {
                        ent = &opt->arg.l.p[i];
-                       if(*value == ent->i) {
-                               if(ent->str[0] != '\0')
+                       if (*value == ent->i) {
+                               if (ent->str[0] != '\0')
                                        DPRINTK(PROBE, INFO, "%s\n", ent->str);
                                return 0;
                        }
@@ -268,7 +297,7 @@ e1000_validate_option(int *value, struct e1000_option *opt,
                BUG();
        }
 
-       DPRINTK(PROBE, INFO, "Invalid %s specified (%i) %s\n",
+       DPRINTK(PROBE, INFO, "Invalid %s value specified (%i) %s\n",
               opt->name, *value, opt->err);
        *value = opt->def;
        return -1;
@@ -291,7 +320,7 @@ void __devinit
 e1000_check_options(struct e1000_adapter *adapter)
 {
        int bd = adapter->bd_number;
-       if(bd >= E1000_MAX_NIC) {
+       if (bd >= E1000_MAX_NIC) {
                DPRINTK(PROBE, NOTICE,
                       "Warning: no configuration for board #%i\n", bd);
                DPRINTK(PROBE, NOTICE, "Using defaults for all values\n");
@@ -315,12 +344,12 @@ e1000_check_options(struct e1000_adapter *adapter)
                if (num_TxDescriptors > bd) {
                        tx_ring->count = TxDescriptors[bd];
                        e1000_validate_option(&tx_ring->count, &opt, adapter);
-                       E1000_ROUNDUP(tx_ring->count, 
+                       E1000_ROUNDUP(tx_ring->count,
                                                REQ_TX_DESCRIPTOR_MULTIPLE);
                } else {
                        tx_ring->count = opt.def;
                }
-               for (i = 0; i < adapter->num_queues; i++)
+               for (i = 0; i < adapter->num_tx_queues; i++)
                        tx_ring[i].count = tx_ring->count;
        }
        { /* Receive Descriptor Count */
@@ -341,12 +370,12 @@ e1000_check_options(struct e1000_adapter *adapter)
                if (num_RxDescriptors > bd) {
                        rx_ring->count = RxDescriptors[bd];
                        e1000_validate_option(&rx_ring->count, &opt, adapter);
-                       E1000_ROUNDUP(rx_ring->count, 
+                       E1000_ROUNDUP(rx_ring->count,
                                                REQ_RX_DESCRIPTOR_MULTIPLE);
                } else {
                        rx_ring->count = opt.def;
                }
-               for (i = 0; i < adapter->num_queues; i++)
+               for (i = 0; i < adapter->num_rx_queues; i++)
                        rx_ring[i].count = rx_ring->count;
        }
        { /* Checksum Offload Enable/Disable */
@@ -388,7 +417,7 @@ e1000_check_options(struct e1000_adapter *adapter)
                        e1000_validate_option(&fc, &opt, adapter);
                        adapter->hw.fc = adapter->hw.original_fc = fc;
                } else {
-                       adapter->hw.fc = opt.def;
+                       adapter->hw.fc = adapter->hw.original_fc = opt.def;
                }
        }
        { /* Transmit Interrupt Delay */
@@ -403,8 +432,8 @@ e1000_check_options(struct e1000_adapter *adapter)
 
                if (num_TxIntDelay > bd) {
                        adapter->tx_int_delay = TxIntDelay[bd];
-                       e1000_validate_option(&adapter->tx_int_delay, &opt, 
-                                                               adapter);
+                       e1000_validate_option(&adapter->tx_int_delay, &opt,
+                                             adapter);
                } else {
                        adapter->tx_int_delay = opt.def;
                }
@@ -421,8 +450,8 @@ e1000_check_options(struct e1000_adapter *adapter)
 
                if (num_TxAbsIntDelay > bd) {
                        adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
-                       e1000_validate_option(&adapter->tx_abs_int_delay, &opt, 
-                                                               adapter);
+                       e1000_validate_option(&adapter->tx_abs_int_delay, &opt,
+                                             adapter);
                } else {
                        adapter->tx_abs_int_delay = opt.def;
                }
@@ -439,8 +468,8 @@ e1000_check_options(struct e1000_adapter *adapter)
 
                if (num_RxIntDelay > bd) {
                        adapter->rx_int_delay = RxIntDelay[bd];
-                       e1000_validate_option(&adapter->rx_int_delay, &opt, 
-                                                               adapter);
+                       e1000_validate_option(&adapter->rx_int_delay, &opt,
+                                             adapter);
                } else {
                        adapter->rx_int_delay = opt.def;
                }
@@ -457,8 +486,8 @@ e1000_check_options(struct e1000_adapter *adapter)
 
                if (num_RxAbsIntDelay > bd) {
                        adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
-                       e1000_validate_option(&adapter->rx_abs_int_delay, &opt, 
-                                                               adapter);
+                       e1000_validate_option(&adapter->rx_abs_int_delay, &opt,
+                                             adapter);
                } else {
                        adapter->rx_abs_int_delay = opt.def;
                }
@@ -475,26 +504,58 @@ e1000_check_options(struct e1000_adapter *adapter)
 
                if (num_InterruptThrottleRate > bd) {
                        adapter->itr = InterruptThrottleRate[bd];
-                       switch(adapter->itr) {
+                       switch (adapter->itr) {
                        case 0:
-                               DPRINTK(PROBE, INFO, "%s turned off\n", 
-                                       opt.name);
+                               DPRINTK(PROBE, INFO, "%s turned off\n",
+                                       opt.name);
                                break;
                        case 1:
-                               DPRINTK(PROBE, INFO, "%s set to dynamic mode\n", 
-                                       opt.name);
+                               DPRINTK(PROBE, INFO, "%s set to dynamic mode\n",
+                                       opt.name);
                                break;
                        default:
-                               e1000_validate_option(&adapter->itr, &opt, 
-                                       adapter);
+                               e1000_validate_option(&adapter->itr, &opt,
+                                                     adapter);
                                break;
                        }
                } else {
                        adapter->itr = opt.def;
                }
        }
+       { /* Smart Power Down */
+               struct e1000_option opt = {
+                       .type = enable_option,
+                       .name = "PHY Smart Power Down",
+                       .err  = "defaulting to Disabled",
+                       .def  = OPTION_DISABLED
+               };
+
+               if (num_SmartPowerDownEnable > bd) {
+                       int spd = SmartPowerDownEnable[bd];
+                       e1000_validate_option(&spd, &opt, adapter);
+                       adapter->smart_power_down = spd;
+               } else {
+                       adapter->smart_power_down = opt.def;
+               }
+       }
+       { /* Kumeran Lock Loss Workaround */
+               struct e1000_option opt = {
+                       .type = enable_option,
+                       .name = "Kumeran Lock Loss Workaround",
+                       .err  = "defaulting to Enabled",
+                       .def  = OPTION_ENABLED
+               };
+
+               if (num_KumeranLockLoss > bd) {
+                       int kmrn_lock_loss = KumeranLockLoss[bd];
+                       e1000_validate_option(&kmrn_lock_loss, &opt, adapter);
+                       adapter->hw.kmrn_lock_loss_workaround_disabled = !kmrn_lock_loss;
+               } else {
+                       adapter->hw.kmrn_lock_loss_workaround_disabled = !opt.def;
+               }
+       }
 
-       switch(adapter->hw.media_type) {
+       switch (adapter->hw.media_type) {
        case e1000_media_type_fiber:
        case e1000_media_type_internal_serdes:
                e1000_check_fiber_options(adapter);
@@ -518,17 +579,17 @@ static void __devinit
 e1000_check_fiber_options(struct e1000_adapter *adapter)
 {
        int bd = adapter->bd_number;
-       if(num_Speed > bd) {
+       if (num_Speed > bd) {
                DPRINTK(PROBE, INFO, "Speed not valid for fiber adapters, "
                       "parameter ignored\n");
        }
 
-       if(num_Duplex > bd) {
+       if (num_Duplex > bd) {
                DPRINTK(PROBE, INFO, "Duplex not valid for fiber adapters, "
                       "parameter ignored\n");
        }
 
-       if((num_AutoNeg > bd) && (AutoNeg[bd] != 0x20)) {
+       if ((num_AutoNeg > bd) && (AutoNeg[bd] != 0x20)) {
                DPRINTK(PROBE, INFO, "AutoNeg other than 1000/Full is "
                                 "not valid for fiber adapters, "
                                 "parameter ignored\n");
@@ -584,6 +645,12 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
                                         .p = dplx_list }}
                };
 
+               if (e1000_check_phy_reset_block(&adapter->hw)) {
+                       DPRINTK(PROBE, INFO,
+                               "Link active due to SoL/IDER Session. "
+                               "Speed/Duplex/AutoNeg parameter ignored.\n");
+                       return;
+               }
                if (num_Duplex > bd) {
                        dplx = Duplex[bd];
                        e1000_validate_option(&dplx, &opt, adapter);
@@ -592,7 +659,7 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
                }
        }
 
-       if((num_AutoNeg > bd) && (speed != 0 || dplx != 0)) {
+       if ((num_AutoNeg > bd) && (speed != 0 || dplx != 0)) {
                DPRINTK(PROBE, INFO,
                       "AutoNeg specified along with Speed or Duplex, "
                       "parameter ignored\n");
@@ -653,7 +720,7 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
        switch (speed + dplx) {
        case 0:
                adapter->hw.autoneg = adapter->fc_autoneg = 1;
-               if((num_Speed > bd) && (speed != 0 || dplx != 0))
+               if ((num_Speed > bd) && (speed != 0 || dplx != 0))
                        DPRINTK(PROBE, INFO,
                               "Speed and duplex autonegotiation enabled\n");
                break;