diff options
author | Sarveshwar Bandi <sarveshwarb@serverengines.com> | 2009-11-20 17:23:47 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-20 17:23:47 -0500 |
commit | fa9a6fed87df1b50804405e700f8d30251d3aaf1 (patch) | |
tree | 6ff36c19f7fb6f68084f5c7d6f737d7a14c9bd16 /drivers/net | |
parent | eb6d02133cf5451fece3a37ccccf2ce7c09a09c1 (diff) |
be2net: Patch to flash redboot section while firmware update.
Please apply patch to update redboot section while firmware update. Code
checks if section needs to be updated before actually doing it.
Signed-off-by: Sarveshwar Bandi <sarveshwarb@serverengines.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/benet/be_cmds.c | 29 | ||||
-rw-r--r-- | drivers/net/benet/be_cmds.h | 2 | ||||
-rw-r--r-- | drivers/net/benet/be_hw.h | 5 | ||||
-rw-r--r-- | drivers/net/benet/be_main.c | 31 |
4 files changed, 67 insertions, 0 deletions
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c index cc75dd0df0d8..808ad0dd4115 100644 --- a/drivers/net/benet/be_cmds.c +++ b/drivers/net/benet/be_cmds.c | |||
@@ -1251,3 +1251,32 @@ int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd, | |||
1251 | spin_unlock_bh(&adapter->mcc_lock); | 1251 | spin_unlock_bh(&adapter->mcc_lock); |
1252 | return status; | 1252 | return status; |
1253 | } | 1253 | } |
1254 | |||
1255 | int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc) | ||
1256 | { | ||
1257 | struct be_mcc_wrb *wrb; | ||
1258 | struct be_cmd_write_flashrom *req; | ||
1259 | int status; | ||
1260 | |||
1261 | spin_lock_bh(&adapter->mcc_lock); | ||
1262 | |||
1263 | wrb = wrb_from_mccq(adapter); | ||
1264 | req = embedded_payload(wrb); | ||
1265 | |||
1266 | be_wrb_hdr_prepare(wrb, sizeof(*req)+4, true, 0); | ||
1267 | |||
1268 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | ||
1269 | OPCODE_COMMON_READ_FLASHROM, sizeof(*req)+4); | ||
1270 | |||
1271 | req->params.op_type = cpu_to_le32(FLASHROM_TYPE_REDBOOT); | ||
1272 | req->params.op_code = cpu_to_le32(FLASHROM_OPER_REPORT); | ||
1273 | req->params.offset = 0x3FFFC; | ||
1274 | req->params.data_buf_size = 0x4; | ||
1275 | |||
1276 | status = be_mcc_notify_wait(adapter); | ||
1277 | if (!status) | ||
1278 | memcpy(flashed_crc, req->params.data_buf, 4); | ||
1279 | |||
1280 | spin_unlock_bh(&adapter->mcc_lock); | ||
1281 | return status; | ||
1282 | } | ||
diff --git a/drivers/net/benet/be_cmds.h b/drivers/net/benet/be_cmds.h index 69dc017c814b..6a430e4d1755 100644 --- a/drivers/net/benet/be_cmds.h +++ b/drivers/net/benet/be_cmds.h | |||
@@ -118,6 +118,7 @@ struct be_mcc_mailbox { | |||
118 | #define OPCODE_COMMON_NTWK_MULTICAST_SET 3 | 118 | #define OPCODE_COMMON_NTWK_MULTICAST_SET 3 |
119 | #define OPCODE_COMMON_NTWK_VLAN_CONFIG 4 | 119 | #define OPCODE_COMMON_NTWK_VLAN_CONFIG 4 |
120 | #define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5 | 120 | #define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5 |
121 | #define OPCODE_COMMON_READ_FLASHROM 6 | ||
121 | #define OPCODE_COMMON_WRITE_FLASHROM 7 | 122 | #define OPCODE_COMMON_WRITE_FLASHROM 7 |
122 | #define OPCODE_COMMON_CQ_CREATE 12 | 123 | #define OPCODE_COMMON_CQ_CREATE 12 |
123 | #define OPCODE_COMMON_EQ_CREATE 13 | 124 | #define OPCODE_COMMON_EQ_CREATE 13 |
@@ -846,3 +847,4 @@ extern int be_cmd_read_port_type(struct be_adapter *adapter, u32 port, | |||
846 | extern int be_cmd_write_flashrom(struct be_adapter *adapter, | 847 | extern int be_cmd_write_flashrom(struct be_adapter *adapter, |
847 | struct be_dma_mem *cmd, u32 flash_oper, | 848 | struct be_dma_mem *cmd, u32 flash_oper, |
848 | u32 flash_opcode, u32 buf_size); | 849 | u32 flash_opcode, u32 buf_size); |
850 | extern int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc); | ||
diff --git a/drivers/net/benet/be_hw.h b/drivers/net/benet/be_hw.h index a3394b4aa14a..f53d5ca2da9e 100644 --- a/drivers/net/benet/be_hw.h +++ b/drivers/net/benet/be_hw.h | |||
@@ -225,6 +225,7 @@ struct be_eth_rx_compl { | |||
225 | #define NUM_FLASHDIR_ENTRIES 32 | 225 | #define NUM_FLASHDIR_ENTRIES 32 |
226 | 226 | ||
227 | #define FLASHROM_TYPE_ISCSI_ACTIVE 0 | 227 | #define FLASHROM_TYPE_ISCSI_ACTIVE 0 |
228 | #define FLASHROM_TYPE_REDBOOT 1 | ||
228 | #define FLASHROM_TYPE_BIOS 2 | 229 | #define FLASHROM_TYPE_BIOS 2 |
229 | #define FLASHROM_TYPE_PXE_BIOS 3 | 230 | #define FLASHROM_TYPE_PXE_BIOS 3 |
230 | #define FLASHROM_TYPE_FCOE_BIOS 8 | 231 | #define FLASHROM_TYPE_FCOE_BIOS 8 |
@@ -234,9 +235,11 @@ struct be_eth_rx_compl { | |||
234 | 235 | ||
235 | #define FLASHROM_OPER_FLASH 1 | 236 | #define FLASHROM_OPER_FLASH 1 |
236 | #define FLASHROM_OPER_SAVE 2 | 237 | #define FLASHROM_OPER_SAVE 2 |
238 | #define FLASHROM_OPER_REPORT 4 | ||
237 | 239 | ||
238 | #define FLASH_IMAGE_MAX_SIZE (1310720) /* Max firmware image size */ | 240 | #define FLASH_IMAGE_MAX_SIZE (1310720) /* Max firmware image size */ |
239 | #define FLASH_BIOS_IMAGE_MAX_SIZE (262144) /* Max OPTION ROM image sz */ | 241 | #define FLASH_BIOS_IMAGE_MAX_SIZE (262144) /* Max OPTION ROM image sz */ |
242 | #define FLASH_REDBOOT_IMAGE_MAX_SIZE (262144) /* Max redboot image sz */ | ||
240 | 243 | ||
241 | /* Offsets for components on Flash. */ | 244 | /* Offsets for components on Flash. */ |
242 | #define FLASH_iSCSI_PRIMARY_IMAGE_START (1048576) | 245 | #define FLASH_iSCSI_PRIMARY_IMAGE_START (1048576) |
@@ -246,6 +249,8 @@ struct be_eth_rx_compl { | |||
246 | #define FLASH_iSCSI_BIOS_START (7340032) | 249 | #define FLASH_iSCSI_BIOS_START (7340032) |
247 | #define FLASH_PXE_BIOS_START (7864320) | 250 | #define FLASH_PXE_BIOS_START (7864320) |
248 | #define FLASH_FCoE_BIOS_START (524288) | 251 | #define FLASH_FCoE_BIOS_START (524288) |
252 | #define FLASH_REDBOOT_START (32768) | ||
253 | #define FLASH_REDBOOT_ISM_START (0) | ||
249 | 254 | ||
250 | struct controller_id { | 255 | struct controller_id { |
251 | u32 vendor; | 256 | u32 vendor; |
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c index c0bd20356eaf..921103c40195 100644 --- a/drivers/net/benet/be_main.c +++ b/drivers/net/benet/be_main.c | |||
@@ -1721,6 +1721,31 @@ static int be_close(struct net_device *netdev) | |||
1721 | #define FW_FILE_HDR_SIGN "ServerEngines Corp. " | 1721 | #define FW_FILE_HDR_SIGN "ServerEngines Corp. " |
1722 | char flash_cookie[2][16] = {"*** SE FLAS", | 1722 | char flash_cookie[2][16] = {"*** SE FLAS", |
1723 | "H DIRECTORY *** "}; | 1723 | "H DIRECTORY *** "}; |
1724 | |||
1725 | static bool be_flash_redboot(struct be_adapter *adapter, | ||
1726 | const u8 *p) | ||
1727 | { | ||
1728 | u32 crc_offset; | ||
1729 | u8 flashed_crc[4]; | ||
1730 | int status; | ||
1731 | crc_offset = FLASH_REDBOOT_START + FLASH_REDBOOT_IMAGE_MAX_SIZE - 4 | ||
1732 | + sizeof(struct flash_file_hdr) - 32*1024; | ||
1733 | p += crc_offset; | ||
1734 | status = be_cmd_get_flash_crc(adapter, flashed_crc); | ||
1735 | if (status) { | ||
1736 | dev_err(&adapter->pdev->dev, | ||
1737 | "could not get crc from flash, not flashing redboot\n"); | ||
1738 | return false; | ||
1739 | } | ||
1740 | |||
1741 | /*update redboot only if crc does not match*/ | ||
1742 | if (!memcmp(flashed_crc, p, 4)) | ||
1743 | return false; | ||
1744 | else | ||
1745 | return true; | ||
1746 | |||
1747 | } | ||
1748 | |||
1724 | static int be_flash_image(struct be_adapter *adapter, | 1749 | static int be_flash_image(struct be_adapter *adapter, |
1725 | const struct firmware *fw, | 1750 | const struct firmware *fw, |
1726 | struct be_dma_mem *flash_cmd, u32 flash_type) | 1751 | struct be_dma_mem *flash_cmd, u32 flash_type) |
@@ -1760,6 +1785,12 @@ static int be_flash_image(struct be_adapter *adapter, | |||
1760 | image_offset = FLASH_PXE_BIOS_START; | 1785 | image_offset = FLASH_PXE_BIOS_START; |
1761 | image_size = FLASH_BIOS_IMAGE_MAX_SIZE; | 1786 | image_size = FLASH_BIOS_IMAGE_MAX_SIZE; |
1762 | break; | 1787 | break; |
1788 | case FLASHROM_TYPE_REDBOOT: | ||
1789 | if (!be_flash_redboot(adapter, fw->data)) | ||
1790 | return 0; | ||
1791 | image_offset = FLASH_REDBOOT_ISM_START; | ||
1792 | image_size = FLASH_REDBOOT_IMAGE_MAX_SIZE; | ||
1793 | break; | ||
1763 | default: | 1794 | default: |
1764 | return 0; | 1795 | return 0; |
1765 | } | 1796 | } |