e1000e: set bools to true/false instead of 1/0
[safe/jmp/linux-2.6] / drivers / net / e1000e / param.c
index a66b92e..2e39977 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel PRO/1000 Linux driver
-  Copyright(c) 1999 - 2008 Intel Corporation.
+  Copyright(c) 1999 - 2009 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,
@@ -27,6 +27,7 @@
 *******************************************************************************/
 
 #include <linux/netdevice.h>
+#include <linux/pci.h>
 
 #include "e1000.h"
 
@@ -113,6 +114,15 @@ 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
@@ -132,6 +142,25 @@ E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
  */
 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;
@@ -162,17 +191,16 @@ static int __devinit e1000_validate_option(unsigned int *value,
        case enable_option:
                switch (*value) {
                case OPTION_ENABLED:
-                       ndev_info(adapter->netdev, "%s Enabled\n", opt->name);
+                       e_info("%s Enabled\n", opt->name);
                        return 0;
                case OPTION_DISABLED:
-                       ndev_info(adapter->netdev, "%s Disabled\n", opt->name);
+                       e_info("%s Disabled\n", opt->name);
                        return 0;
                }
                break;
        case range_option:
                if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
-                       ndev_info(adapter->netdev,
-                                       "%s set to %i\n", opt->name, *value);
+                       e_info("%s set to %i\n", opt->name, *value);
                        return 0;
                }
                break;
@@ -184,8 +212,7 @@ static int __devinit e1000_validate_option(unsigned int *value,
                        ent = &opt->arg.l.p[i];
                        if (*value == ent->i) {
                                if (ent->str[0] != '\0')
-                                       ndev_info(adapter->netdev, "%s\n",
-                                                 ent->str);
+                                       e_info("%s\n", ent->str);
                                return 0;
                        }
                }
@@ -195,8 +222,8 @@ static int __devinit e1000_validate_option(unsigned int *value,
                BUG();
        }
 
-       ndev_info(adapter->netdev, "Invalid %s value specified (%i) %s\n",
-              opt->name, *value, opt->err);
+       e_info("Invalid %s value specified (%i) %s\n", opt->name, *value,
+              opt->err);
        *value = opt->def;
        return -1;
 }
@@ -213,13 +240,11 @@ static int __devinit e1000_validate_option(unsigned int *value,
 void __devinit e1000e_check_options(struct e1000_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
-       struct net_device *netdev = adapter->netdev;
        int bd = adapter->bd_number;
 
        if (bd >= E1000_MAX_NIC) {
-               ndev_notice(netdev,
-                      "Warning: no configuration for board #%i\n", bd);
-               ndev_notice(netdev, "Using defaults for all values\n");
+               e_notice("Warning: no configuration for board #%i\n", bd);
+               e_notice("Using defaults for all values\n");
        }
 
        { /* Transmit Interrupt Delay */
@@ -313,32 +338,41 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
                        adapter->itr = InterruptThrottleRate[bd];
                        switch (adapter->itr) {
                        case 0:
-                               ndev_info(netdev, "%s turned off\n",
-                                       opt.name);
+                               e_info("%s turned off\n", opt.name);
                                break;
                        case 1:
-                               ndev_info(netdev,
-                                         "%s set to dynamic mode\n",
-                                         opt.name);
+                               e_info("%s set to dynamic mode\n", opt.name);
                                adapter->itr_setting = adapter->itr;
                                adapter->itr = 20000;
                                break;
                        case 3:
-                               ndev_info(netdev,
-                                       "%s set to dynamic conservative mode\n",
+                               e_info("%s set to dynamic conservative mode\n",
                                        opt.name);
                                adapter->itr_setting = adapter->itr;
                                adapter->itr = 20000;
                                break;
                        default:
-                               e1000_validate_option(&adapter->itr, &opt,
-                                       adapter);
                                /*
-                                * save the setting, because the dynamic bits
-                                * change itr. clear the lower two bits
-                                * because they are used as control
+                                * Save the setting, because the dynamic bits
+                                * change itr.
                                 */
-                               adapter->itr_setting = adapter->itr & ~3;
+                               if (e1000_validate_option(&adapter->itr, &opt,
+                                                         adapter) &&
+                                   (adapter->itr == 3)) {
+                                       /*
+                                        * In case of invalid user value,
+                                        * default to conservative mode.
+                                        */
+                                       adapter->itr_setting = adapter->itr;
+                                       adapter->itr = 20000;
+                               } else {
+                                       /*
+                                        * Clear the lower two bits because
+                                        * they are used as control.
+                                        */
+                                       adapter->itr_setting =
+                                               adapter->itr & ~3;
+                               }
                                break;
                        }
                } else {
@@ -346,6 +380,24 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
                        adapter->itr = 20000;
                }
        }
+       { /* Interrupt Mode */
+               struct e1000_option opt = {
+                       .type = range_option,
+                       .name = "Interrupt Mode",
+                       .err  = "defaulting to 2 (MSI-X)",
+                       .def  = E1000E_INT_MODE_MSIX,
+                       .arg  = { .r = { .min = MIN_INTMODE,
+                                        .max = MAX_INTMODE } }
+               };
+
+               if (num_IntMode > bd) {
+                       unsigned int int_mode = IntMode[bd];
+                       e1000_validate_option(&int_mode, &opt, adapter);
+                       adapter->int_mode = int_mode;
+               } else {
+                       adapter->int_mode = opt.def;
+               }
+       }
        { /* Smart Power Down */
                const struct e1000_option opt = {
                        .type = enable_option,
@@ -362,6 +414,23 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
                                adapter->flags |= FLAG_SMART_POWER_DOWN;
                }
        }
+       { /* CRC Stripping */
+               const struct e1000_option opt = {
+                       .type = enable_option,
+                       .name = "CRC Stripping",
+                       .err  = "defaulting to enabled",
+                       .def  = OPTION_ENABLED
+               };
+
+               if (num_CrcStripping > bd) {
+                       unsigned int crc_stripping = CrcStripping[bd];
+                       e1000_validate_option(&crc_stripping, &opt, adapter);
+                       if (crc_stripping == OPTION_ENABLED)
+                               adapter->flags2 |= FLAG2_CRC_STRIPPING;
+               } else {
+                       adapter->flags2 |= FLAG2_CRC_STRIPPING;
+               }
+       }
        { /* Kumeran Lock Loss Workaround */
                const struct e1000_option opt = {
                        .type = enable_option,
@@ -382,4 +451,25 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
                                                                       opt.def);
                }
        }
+       { /* Write-protect NVM */
+               const struct e1000_option opt = {
+                       .type = enable_option,
+                       .name = "Write-protect NVM",
+                       .err  = "defaulting to Enabled",
+                       .def  = OPTION_ENABLED
+               };
+
+               if (adapter->flags & FLAG_IS_ICH) {
+                       if (num_WriteProtectNVM > bd) {
+                               unsigned int write_protect_nvm = WriteProtectNVM[bd];
+                               e1000_validate_option(&write_protect_nvm, &opt,
+                                                     adapter);
+                               if (write_protect_nvm)
+                                       adapter->flags |= FLAG_READ_ONLY_NVM;
+                       } else {
+                               if (opt.def)
+                                       adapter->flags |= FLAG_READ_ONLY_NVM;
+                       }
+               }
+       }
 }