]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bnx2x: Loaded Firmware Version Validation
authorAriel Elior <ariele@broadcom.com>
Thu, 26 Jan 2012 06:01:49 +0000 (06:01 +0000)
committerJoe Jin <joe.jin@oracle.com>
Wed, 16 May 2012 14:41:20 +0000 (22:41 +0800)
In a virtualized environment it is possible for a loading driver to discover
that Firmware is already loaded to the device, and that this FW does not match
its own. This can happen for example if different Physical Functions are
Assigned to different VMs in which different driver versions are loaded. The
code in this patch ensures that only drivers with matching FW are loaded over
the device, and that in the case described above where the Firmware version
doesn't match the driver load is aborted.

(cherry picked from commit d1e2d9660e6bca2f06606b4bc65ea669bf669b0a)
Signed-off-by: Ariel Elior <ariele@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Joe Jin <joe.jin@oracle.com>
drivers/net/bnx2x/bnx2x_cmn.c

index cf46e23f1b7bb44967752821ccf65cacdec83d1c..abfb7cb3a66731be0fb3a7d84d3b2bd569c98b65 100644 (file)
@@ -1749,6 +1749,29 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
                        rc = -EBUSY; /* other port in diagnostic mode */
                        LOAD_ERROR_EXIT(bp, load_error1);
                }
+               if (load_code != FW_MSG_CODE_DRV_LOAD_COMMON_CHIP &&
+                   load_code != FW_MSG_CODE_DRV_LOAD_COMMON) {
+                       /* build FW version dword */
+                       u32 my_fw = (BCM_5710_FW_MAJOR_VERSION) +
+                                       (BCM_5710_FW_MINOR_VERSION << 8) +
+                                       (BCM_5710_FW_REVISION_VERSION << 16) +
+                                       (BCM_5710_FW_ENGINEERING_VERSION << 24);
+
+                       /* read loaded FW from chip */
+                       u32 loaded_fw = REG_RD(bp, XSEM_REG_PRAM);
+
+                       DP(BNX2X_MSG_SP, "loaded fw %x, my fw %x",
+                          loaded_fw, my_fw);
+
+                       /* abort nic load if version mismatch */
+                       if (my_fw != loaded_fw) {
+                               BNX2X_ERR("bnx2x with FW %x already loaded, "
+                                         "which mismatches my %x FW. aborting",
+                                         loaded_fw, my_fw);
+                               rc = -EBUSY;
+                               LOAD_ERROR_EXIT(bp, load_error2);
+                       }
+               }
 
        } else {
                int path = BP_PATH(bp);