cxgb3 - FW versioning
authorDivy Le Ray <divy@chelsio.com>
Wed, 31 Jan 2007 03:43:45 +0000 (19:43 -0800)
committerJeff Garzik <jeff@garzik.org>
Mon, 5 Feb 2007 21:58:49 +0000 (16:58 -0500)
Clean up FW version checking.
The supported FW version is now 3.1.

Signed-off-by: Divy Le Ray <divy@chelsio.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/cxgb3/cxgb3_main.c
drivers/net/cxgb3/firmware_exports.h
drivers/net/cxgb3/t3_hw.c

index 54c49acd86b4a001345d3e66d1df0555b1a93a14..804414637ec7564653dc17aef67d4b9bc0620009 100644 (file)
@@ -665,11 +665,8 @@ static int cxgb_up(struct adapter *adap)
 
        if (!(adap->flags & FULL_INIT_DONE)) {
                err = t3_check_fw_version(adap);
 
        if (!(adap->flags & FULL_INIT_DONE)) {
                err = t3_check_fw_version(adap);
-               if (err) {
-                       dev_err(&adap->pdev->dev,
-                               "adapter FW is not compatible with driver\n");
+               if (err)
                        goto out;
                        goto out;
-               }
 
                err = init_dummy_netdevs(adap);
                if (err)
 
                err = init_dummy_netdevs(adap);
                if (err)
@@ -1002,10 +999,14 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
        strcpy(info->bus_info, pci_name(adapter->pdev));
        if (!fw_vers)
                strcpy(info->fw_version, "N/A");
        strcpy(info->bus_info, pci_name(adapter->pdev));
        if (!fw_vers)
                strcpy(info->fw_version, "N/A");
-       else
+       else {
                snprintf(info->fw_version, sizeof(info->fw_version),
                snprintf(info->fw_version, sizeof(info->fw_version),
-                        "%s %u.%u", (fw_vers >> 24) ? "T" : "N",
-                        (fw_vers >> 12) & 0xfff, fw_vers & 0xfff);
+                        "%s %u.%u.%u",
+                        G_FW_VERSION_TYPE(fw_vers) ? "T" : "N",
+                        G_FW_VERSION_MAJOR(fw_vers),
+                        G_FW_VERSION_MINOR(fw_vers),
+                        G_FW_VERSION_MICRO(fw_vers));
+       }
 }
 
 static void get_strings(struct net_device *dev, u32 stringset, u8 * data)
 }
 
 static void get_strings(struct net_device *dev, u32 stringset, u8 * data)
index 3565f481801b67cded13b28356f537e1b75d8835..eea7d8940dc7b3d499d7fea411fc57dcf960b2be 100644 (file)
 #define FW_WRC_NUM                     \
     (65536 + FW_TUNNEL_NUM + FW_CTRL_NUM + FW_RI_NUM + FW_RX_PKT_NUM)
 
 #define FW_WRC_NUM                     \
     (65536 + FW_TUNNEL_NUM + FW_CTRL_NUM + FW_RI_NUM + FW_RX_PKT_NUM)
 
+/*
+ * FW type and version.
+ */
+#define S_FW_VERSION_TYPE              28
+#define M_FW_VERSION_TYPE              0xF
+#define V_FW_VERSION_TYPE(x)           ((x) << S_FW_VERSION_TYPE)
+#define G_FW_VERSION_TYPE(x)           \
+    (((x) >> S_FW_VERSION_TYPE) & M_FW_VERSION_TYPE)
+
+#define S_FW_VERSION_MAJOR             16
+#define M_FW_VERSION_MAJOR             0xFFF
+#define V_FW_VERSION_MAJOR(x)          ((x) << S_FW_VERSION_MAJOR)
+#define G_FW_VERSION_MAJOR(x)          \
+    (((x) >> S_FW_VERSION_MAJOR) & M_FW_VERSION_MAJOR)
+
+#define S_FW_VERSION_MINOR             8
+#define M_FW_VERSION_MINOR             0xFF
+#define V_FW_VERSION_MINOR(x)          ((x) << S_FW_VERSION_MINOR)
+#define G_FW_VERSION_MINOR(x)          \
+    (((x) >> S_FW_VERSION_MINOR) & M_FW_VERSION_MINOR)
+
+#define S_FW_VERSION_MICRO             0
+#define M_FW_VERSION_MICRO             0xFF
+#define V_FW_VERSION_MICRO(x)          ((x) << S_FW_VERSION_MICRO)
+#define G_FW_VERSION_MICRO(x)          \
+    (((x) >> S_FW_VERSION_MICRO) & M_FW_VERSION_MICRO)
+
 #endif                         /* _FIRMWARE_EXPORTS_H_ */
 #endif                         /* _FIRMWARE_EXPORTS_H_ */
index a4e2e57e14655d350f7fa9171a9605b4e515da44..4545acb3a2d5e27b2a8d686bf621f02b96957aef 100644 (file)
@@ -826,6 +826,11 @@ static int t3_write_flash(struct adapter *adapter, unsigned int addr,
        return 0;
 }
 
        return 0;
 }
 
+enum fw_version_type {
+       FW_VERSION_N3,
+       FW_VERSION_T3
+};
+
 /**
  *     t3_get_fw_version - read the firmware version
  *     @adapter: the adapter
 /**
  *     t3_get_fw_version - read the firmware version
  *     @adapter: the adapter
@@ -849,19 +854,21 @@ int t3_check_fw_version(struct adapter *adapter)
 {
        int ret;
        u32 vers;
 {
        int ret;
        u32 vers;
+       unsigned int type, major, minor;
 
        ret = t3_get_fw_version(adapter, &vers);
        if (ret)
                return ret;
 
 
        ret = t3_get_fw_version(adapter, &vers);
        if (ret)
                return ret;
 
-       /* Minor 0xfff means the FW is an internal development-only version. */
-       if ((vers & 0xfff) == 0xfff)
-               return 0;
+       type = G_FW_VERSION_TYPE(vers);
+       major = G_FW_VERSION_MAJOR(vers);
+       minor = G_FW_VERSION_MINOR(vers);
 
 
-       if (vers == 0x1002009)
+       if (type == FW_VERSION_T3 && major == 3 && minor == 1)
                return 0;
 
                return 0;
 
-       CH_ERR(adapter, "found wrong FW version, driver needs version 2.9\n");
+       CH_ERR(adapter, "found wrong FW version(%u.%u), "
+              "driver needs version 3.1\n", major, minor);
        return -EINVAL;
 }
 
        return -EINVAL;
 }