diff options
Diffstat (limited to 'drivers/scsi/csiostor/csio_hw.c')
| -rw-r--r-- | drivers/scsi/csiostor/csio_hw.c | 342 |
1 files changed, 126 insertions, 216 deletions
diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c index 35c5f83b08a0..c81b06bcf827 100644 --- a/drivers/scsi/csiostor/csio_hw.c +++ b/drivers/scsi/csiostor/csio_hw.c | |||
| @@ -636,7 +636,7 @@ csio_hw_print_fw_version(struct csio_hw *hw, char *str) | |||
| 636 | static int | 636 | static int |
| 637 | csio_hw_get_fw_version(struct csio_hw *hw, uint32_t *vers) | 637 | csio_hw_get_fw_version(struct csio_hw *hw, uint32_t *vers) |
| 638 | { | 638 | { |
| 639 | return csio_hw_read_flash(hw, FW_IMG_START + | 639 | return csio_hw_read_flash(hw, FLASH_FW_START + |
| 640 | offsetof(struct fw_hdr, fw_ver), 1, | 640 | offsetof(struct fw_hdr, fw_ver), 1, |
| 641 | vers, 0); | 641 | vers, 0); |
| 642 | } | 642 | } |
| @@ -696,9 +696,9 @@ csio_hw_fw_dload(struct csio_hw *hw, uint8_t *fw_data, uint32_t size) | |||
| 696 | return -EINVAL; | 696 | return -EINVAL; |
| 697 | } | 697 | } |
| 698 | 698 | ||
| 699 | if (size > FW_MAX_SIZE) { | 699 | if (size > FLASH_FW_MAX_SIZE) { |
| 700 | csio_err(hw, "FW image too large, max is %u bytes\n", | 700 | csio_err(hw, "FW image too large, max is %u bytes\n", |
| 701 | FW_MAX_SIZE); | 701 | FLASH_FW_MAX_SIZE); |
| 702 | return -EINVAL; | 702 | return -EINVAL; |
| 703 | } | 703 | } |
| 704 | 704 | ||
| @@ -714,10 +714,10 @@ csio_hw_fw_dload(struct csio_hw *hw, uint8_t *fw_data, uint32_t size) | |||
| 714 | i = DIV_ROUND_UP(size, sf_sec_size); /* # of sectors spanned */ | 714 | i = DIV_ROUND_UP(size, sf_sec_size); /* # of sectors spanned */ |
| 715 | 715 | ||
| 716 | csio_dbg(hw, "Erasing sectors... start:%d end:%d\n", | 716 | csio_dbg(hw, "Erasing sectors... start:%d end:%d\n", |
| 717 | FW_START_SEC, FW_START_SEC + i - 1); | 717 | FLASH_FW_START_SEC, FLASH_FW_START_SEC + i - 1); |
| 718 | 718 | ||
| 719 | ret = csio_hw_flash_erase_sectors(hw, FW_START_SEC, | 719 | ret = csio_hw_flash_erase_sectors(hw, FLASH_FW_START_SEC, |
| 720 | FW_START_SEC + i - 1); | 720 | FLASH_FW_START_SEC + i - 1); |
| 721 | if (ret) { | 721 | if (ret) { |
| 722 | csio_err(hw, "Flash Erase failed\n"); | 722 | csio_err(hw, "Flash Erase failed\n"); |
| 723 | goto out; | 723 | goto out; |
| @@ -730,14 +730,14 @@ csio_hw_fw_dload(struct csio_hw *hw, uint8_t *fw_data, uint32_t size) | |||
| 730 | */ | 730 | */ |
| 731 | memcpy(first_page, fw_data, SF_PAGE_SIZE); | 731 | memcpy(first_page, fw_data, SF_PAGE_SIZE); |
| 732 | ((struct fw_hdr *)first_page)->fw_ver = htonl(0xffffffff); | 732 | ((struct fw_hdr *)first_page)->fw_ver = htonl(0xffffffff); |
| 733 | ret = csio_hw_write_flash(hw, FW_IMG_START, SF_PAGE_SIZE, first_page); | 733 | ret = csio_hw_write_flash(hw, FLASH_FW_START, SF_PAGE_SIZE, first_page); |
| 734 | if (ret) | 734 | if (ret) |
| 735 | goto out; | 735 | goto out; |
| 736 | 736 | ||
| 737 | csio_dbg(hw, "Writing Flash .. start:%d end:%d\n", | 737 | csio_dbg(hw, "Writing Flash .. start:%d end:%d\n", |
| 738 | FW_IMG_START, FW_IMG_START + size); | 738 | FW_IMG_START, FW_IMG_START + size); |
| 739 | 739 | ||
| 740 | addr = FW_IMG_START; | 740 | addr = FLASH_FW_START; |
| 741 | for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) { | 741 | for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) { |
| 742 | addr += SF_PAGE_SIZE; | 742 | addr += SF_PAGE_SIZE; |
| 743 | fw_data += SF_PAGE_SIZE; | 743 | fw_data += SF_PAGE_SIZE; |
| @@ -747,7 +747,7 @@ csio_hw_fw_dload(struct csio_hw *hw, uint8_t *fw_data, uint32_t size) | |||
| 747 | } | 747 | } |
| 748 | 748 | ||
| 749 | ret = csio_hw_write_flash(hw, | 749 | ret = csio_hw_write_flash(hw, |
| 750 | FW_IMG_START + | 750 | FLASH_FW_START + |
| 751 | offsetof(struct fw_hdr, fw_ver), | 751 | offsetof(struct fw_hdr, fw_ver), |
| 752 | sizeof(hdr->fw_ver), | 752 | sizeof(hdr->fw_ver), |
| 753 | (const uint8_t *)&hdr->fw_ver); | 753 | (const uint8_t *)&hdr->fw_ver); |
| @@ -1250,116 +1250,6 @@ csio_hw_fw_upgrade(struct csio_hw *hw, uint32_t mbox, | |||
| 1250 | return csio_hw_fw_restart(hw, mbox, reset); | 1250 | return csio_hw_fw_restart(hw, mbox, reset); |
| 1251 | } | 1251 | } |
| 1252 | 1252 | ||
| 1253 | |||
| 1254 | /* | ||
| 1255 | * csio_hw_fw_config_file - setup an adapter via a Configuration File | ||
| 1256 | * @hw: the HW module | ||
| 1257 | * @mbox: mailbox to use for the FW command | ||
| 1258 | * @mtype: the memory type where the Configuration File is located | ||
| 1259 | * @maddr: the memory address where the Configuration File is located | ||
| 1260 | * @finiver: return value for CF [fini] version | ||
| 1261 | * @finicsum: return value for CF [fini] checksum | ||
| 1262 | * @cfcsum: return value for CF computed checksum | ||
| 1263 | * | ||
| 1264 | * Issue a command to get the firmware to process the Configuration | ||
| 1265 | * File located at the specified mtype/maddress. If the Configuration | ||
| 1266 | * File is processed successfully and return value pointers are | ||
| 1267 | * provided, the Configuration File "[fini] section version and | ||
| 1268 | * checksum values will be returned along with the computed checksum. | ||
| 1269 | * It's up to the caller to decide how it wants to respond to the | ||
| 1270 | * checksums not matching but it recommended that a prominant warning | ||
| 1271 | * be emitted in order to help people rapidly identify changed or | ||
| 1272 | * corrupted Configuration Files. | ||
| 1273 | * | ||
| 1274 | * Also note that it's possible to modify things like "niccaps", | ||
| 1275 | * "toecaps",etc. between processing the Configuration File and telling | ||
| 1276 | * the firmware to use the new configuration. Callers which want to | ||
| 1277 | * do this will need to "hand-roll" their own CAPS_CONFIGS commands for | ||
| 1278 | * Configuration Files if they want to do this. | ||
| 1279 | */ | ||
| 1280 | static int | ||
| 1281 | csio_hw_fw_config_file(struct csio_hw *hw, | ||
| 1282 | unsigned int mtype, unsigned int maddr, | ||
| 1283 | uint32_t *finiver, uint32_t *finicsum, uint32_t *cfcsum) | ||
| 1284 | { | ||
| 1285 | struct csio_mb *mbp; | ||
| 1286 | struct fw_caps_config_cmd *caps_cmd; | ||
| 1287 | int rv = -EINVAL; | ||
| 1288 | enum fw_retval ret; | ||
| 1289 | |||
| 1290 | mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); | ||
| 1291 | if (!mbp) { | ||
| 1292 | CSIO_INC_STATS(hw, n_err_nomem); | ||
| 1293 | return -ENOMEM; | ||
| 1294 | } | ||
| 1295 | /* | ||
| 1296 | * Tell the firmware to process the indicated Configuration File. | ||
| 1297 | * If there are no errors and the caller has provided return value | ||
| 1298 | * pointers for the [fini] section version, checksum and computed | ||
| 1299 | * checksum, pass those back to the caller. | ||
| 1300 | */ | ||
| 1301 | caps_cmd = (struct fw_caps_config_cmd *)(mbp->mb); | ||
| 1302 | CSIO_INIT_MBP(mbp, caps_cmd, CSIO_MB_DEFAULT_TMO, hw, NULL, 1); | ||
| 1303 | caps_cmd->op_to_write = | ||
| 1304 | htonl(FW_CMD_OP_V(FW_CAPS_CONFIG_CMD) | | ||
| 1305 | FW_CMD_REQUEST_F | | ||
| 1306 | FW_CMD_READ_F); | ||
| 1307 | caps_cmd->cfvalid_to_len16 = | ||
| 1308 | htonl(FW_CAPS_CONFIG_CMD_CFVALID_F | | ||
| 1309 | FW_CAPS_CONFIG_CMD_MEMTYPE_CF_V(mtype) | | ||
| 1310 | FW_CAPS_CONFIG_CMD_MEMADDR64K_CF_V(maddr >> 16) | | ||
| 1311 | FW_LEN16(*caps_cmd)); | ||
| 1312 | |||
| 1313 | if (csio_mb_issue(hw, mbp)) { | ||
| 1314 | csio_err(hw, "Issue of FW_CAPS_CONFIG_CMD failed!\n"); | ||
| 1315 | goto out; | ||
| 1316 | } | ||
| 1317 | |||
| 1318 | ret = csio_mb_fw_retval(mbp); | ||
| 1319 | if (ret != FW_SUCCESS) { | ||
| 1320 | csio_dbg(hw, "FW_CAPS_CONFIG_CMD returned %d!\n", rv); | ||
| 1321 | goto out; | ||
| 1322 | } | ||
| 1323 | |||
| 1324 | if (finiver) | ||
| 1325 | *finiver = ntohl(caps_cmd->finiver); | ||
| 1326 | if (finicsum) | ||
| 1327 | *finicsum = ntohl(caps_cmd->finicsum); | ||
| 1328 | if (cfcsum) | ||
| 1329 | *cfcsum = ntohl(caps_cmd->cfcsum); | ||
| 1330 | |||
| 1331 | /* Validate device capabilities */ | ||
| 1332 | if (csio_hw_validate_caps(hw, mbp)) { | ||
| 1333 | rv = -ENOENT; | ||
| 1334 | goto out; | ||
| 1335 | } | ||
| 1336 | |||
| 1337 | /* | ||
| 1338 | * And now tell the firmware to use the configuration we just loaded. | ||
| 1339 | */ | ||
| 1340 | caps_cmd->op_to_write = | ||
| 1341 | htonl(FW_CMD_OP_V(FW_CAPS_CONFIG_CMD) | | ||
| 1342 | FW_CMD_REQUEST_F | | ||
| 1343 | FW_CMD_WRITE_F); | ||
| 1344 | caps_cmd->cfvalid_to_len16 = htonl(FW_LEN16(*caps_cmd)); | ||
| 1345 | |||
| 1346 | if (csio_mb_issue(hw, mbp)) { | ||
| 1347 | csio_err(hw, "Issue of FW_CAPS_CONFIG_CMD failed!\n"); | ||
| 1348 | goto out; | ||
| 1349 | } | ||
| 1350 | |||
| 1351 | ret = csio_mb_fw_retval(mbp); | ||
| 1352 | if (ret != FW_SUCCESS) { | ||
| 1353 | csio_dbg(hw, "FW_CAPS_CONFIG_CMD returned %d!\n", rv); | ||
| 1354 | goto out; | ||
| 1355 | } | ||
| 1356 | |||
| 1357 | rv = 0; | ||
| 1358 | out: | ||
| 1359 | mempool_free(mbp, hw->mb_mempool); | ||
| 1360 | return rv; | ||
| 1361 | } | ||
| 1362 | |||
| 1363 | /* | 1253 | /* |
| 1364 | * csio_get_device_params - Get device parameters. | 1254 | * csio_get_device_params - Get device parameters. |
| 1365 | * @hw: HW module | 1255 | * @hw: HW module |
| @@ -1762,11 +1652,13 @@ leave: | |||
| 1762 | static int | 1652 | static int |
| 1763 | csio_hw_use_fwconfig(struct csio_hw *hw, int reset, u32 *fw_cfg_param) | 1653 | csio_hw_use_fwconfig(struct csio_hw *hw, int reset, u32 *fw_cfg_param) |
| 1764 | { | 1654 | { |
| 1655 | struct csio_mb *mbp = NULL; | ||
| 1656 | struct fw_caps_config_cmd *caps_cmd; | ||
| 1765 | unsigned int mtype, maddr; | 1657 | unsigned int mtype, maddr; |
| 1766 | int rv; | 1658 | int rv = -EINVAL; |
| 1767 | uint32_t finiver = 0, finicsum = 0, cfcsum = 0; | 1659 | uint32_t finiver = 0, finicsum = 0, cfcsum = 0; |
| 1768 | int using_flash; | ||
| 1769 | char path[64]; | 1660 | char path[64]; |
| 1661 | char *config_name = NULL; | ||
| 1770 | 1662 | ||
| 1771 | /* | 1663 | /* |
| 1772 | * Reset device if necessary | 1664 | * Reset device if necessary |
| @@ -1786,51 +1678,106 @@ csio_hw_use_fwconfig(struct csio_hw *hw, int reset, u32 *fw_cfg_param) | |||
| 1786 | rv = csio_hw_flash_config(hw, fw_cfg_param, path); | 1678 | rv = csio_hw_flash_config(hw, fw_cfg_param, path); |
| 1787 | spin_lock_irq(&hw->lock); | 1679 | spin_lock_irq(&hw->lock); |
| 1788 | if (rv != 0) { | 1680 | if (rv != 0) { |
| 1789 | if (rv == -ENOENT) { | 1681 | /* |
| 1790 | /* | 1682 | * config file was not found. Use default |
| 1791 | * config file was not found. Use default | 1683 | * config file from flash. |
| 1792 | * config file from flash. | 1684 | */ |
| 1793 | */ | 1685 | config_name = "On FLASH"; |
| 1794 | mtype = FW_MEMTYPE_CF_FLASH; | 1686 | mtype = FW_MEMTYPE_CF_FLASH; |
| 1795 | maddr = hw->chip_ops->chip_flash_cfg_addr(hw); | 1687 | maddr = hw->chip_ops->chip_flash_cfg_addr(hw); |
| 1796 | using_flash = 1; | ||
| 1797 | } else { | ||
| 1798 | /* | ||
| 1799 | * we revert back to the hardwired config if | ||
| 1800 | * flashing failed. | ||
| 1801 | */ | ||
| 1802 | goto bye; | ||
| 1803 | } | ||
| 1804 | } else { | 1688 | } else { |
| 1689 | config_name = path; | ||
| 1805 | mtype = FW_PARAMS_PARAM_Y_G(*fw_cfg_param); | 1690 | mtype = FW_PARAMS_PARAM_Y_G(*fw_cfg_param); |
| 1806 | maddr = FW_PARAMS_PARAM_Z_G(*fw_cfg_param) << 16; | 1691 | maddr = FW_PARAMS_PARAM_Z_G(*fw_cfg_param) << 16; |
| 1807 | using_flash = 0; | ||
| 1808 | } | 1692 | } |
| 1809 | 1693 | ||
| 1810 | hw->cfg_store = (uint8_t)mtype; | 1694 | mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); |
| 1695 | if (!mbp) { | ||
| 1696 | CSIO_INC_STATS(hw, n_err_nomem); | ||
| 1697 | return -ENOMEM; | ||
| 1698 | } | ||
| 1699 | /* | ||
| 1700 | * Tell the firmware to process the indicated Configuration File. | ||
| 1701 | * If there are no errors and the caller has provided return value | ||
| 1702 | * pointers for the [fini] section version, checksum and computed | ||
| 1703 | * checksum, pass those back to the caller. | ||
| 1704 | */ | ||
| 1705 | caps_cmd = (struct fw_caps_config_cmd *)(mbp->mb); | ||
| 1706 | CSIO_INIT_MBP(mbp, caps_cmd, CSIO_MB_DEFAULT_TMO, hw, NULL, 1); | ||
| 1707 | caps_cmd->op_to_write = | ||
| 1708 | htonl(FW_CMD_OP_V(FW_CAPS_CONFIG_CMD) | | ||
| 1709 | FW_CMD_REQUEST_F | | ||
| 1710 | FW_CMD_READ_F); | ||
| 1711 | caps_cmd->cfvalid_to_len16 = | ||
| 1712 | htonl(FW_CAPS_CONFIG_CMD_CFVALID_F | | ||
| 1713 | FW_CAPS_CONFIG_CMD_MEMTYPE_CF_V(mtype) | | ||
| 1714 | FW_CAPS_CONFIG_CMD_MEMADDR64K_CF_V(maddr >> 16) | | ||
| 1715 | FW_LEN16(*caps_cmd)); | ||
| 1716 | |||
| 1717 | if (csio_mb_issue(hw, mbp)) { | ||
| 1718 | rv = -EINVAL; | ||
| 1719 | goto bye; | ||
| 1720 | } | ||
| 1721 | |||
| 1722 | rv = csio_mb_fw_retval(mbp); | ||
| 1723 | /* If the CAPS_CONFIG failed with an ENOENT (for a Firmware | ||
| 1724 | * Configuration File in FLASH), our last gasp effort is to use the | ||
| 1725 | * Firmware Configuration File which is embedded in the | ||
| 1726 | * firmware. A very few early versions of the firmware didn't | ||
| 1727 | * have one embedded but we can ignore those. | ||
| 1728 | */ | ||
| 1729 | if (rv == ENOENT) { | ||
| 1730 | CSIO_INIT_MBP(mbp, caps_cmd, CSIO_MB_DEFAULT_TMO, hw, NULL, 1); | ||
| 1731 | caps_cmd->op_to_write = htonl(FW_CMD_OP_V(FW_CAPS_CONFIG_CMD) | | ||
| 1732 | FW_CMD_REQUEST_F | | ||
| 1733 | FW_CMD_READ_F); | ||
| 1734 | caps_cmd->cfvalid_to_len16 = htonl(FW_LEN16(*caps_cmd)); | ||
| 1735 | |||
| 1736 | if (csio_mb_issue(hw, mbp)) { | ||
| 1737 | rv = -EINVAL; | ||
| 1738 | goto bye; | ||
| 1739 | } | ||
| 1740 | |||
| 1741 | rv = csio_mb_fw_retval(mbp); | ||
| 1742 | config_name = "Firmware Default"; | ||
| 1743 | } | ||
| 1744 | if (rv != FW_SUCCESS) | ||
| 1745 | goto bye; | ||
| 1746 | |||
| 1747 | finiver = ntohl(caps_cmd->finiver); | ||
| 1748 | finicsum = ntohl(caps_cmd->finicsum); | ||
| 1749 | cfcsum = ntohl(caps_cmd->cfcsum); | ||
| 1811 | 1750 | ||
| 1812 | /* | 1751 | /* |
| 1813 | * Issue a Capability Configuration command to the firmware to get it | 1752 | * And now tell the firmware to use the configuration we just loaded. |
| 1814 | * to parse the Configuration File. | ||
| 1815 | */ | 1753 | */ |
| 1816 | rv = csio_hw_fw_config_file(hw, mtype, maddr, &finiver, | 1754 | caps_cmd->op_to_write = |
| 1817 | &finicsum, &cfcsum); | 1755 | htonl(FW_CMD_OP_V(FW_CAPS_CONFIG_CMD) | |
| 1818 | if (rv != 0) | 1756 | FW_CMD_REQUEST_F | |
| 1757 | FW_CMD_WRITE_F); | ||
| 1758 | caps_cmd->cfvalid_to_len16 = htonl(FW_LEN16(*caps_cmd)); | ||
| 1759 | |||
| 1760 | if (csio_mb_issue(hw, mbp)) { | ||
| 1761 | rv = -EINVAL; | ||
| 1819 | goto bye; | 1762 | goto bye; |
| 1763 | } | ||
| 1820 | 1764 | ||
| 1821 | hw->cfg_finiver = finiver; | 1765 | rv = csio_mb_fw_retval(mbp); |
| 1822 | hw->cfg_finicsum = finicsum; | 1766 | if (rv != FW_SUCCESS) { |
| 1823 | hw->cfg_cfcsum = cfcsum; | 1767 | csio_dbg(hw, "FW_CAPS_CONFIG_CMD returned %d!\n", rv); |
| 1824 | hw->cfg_csum_status = true; | 1768 | goto bye; |
| 1769 | } | ||
| 1825 | 1770 | ||
| 1771 | mempool_free(mbp, hw->mb_mempool); | ||
| 1826 | if (finicsum != cfcsum) { | 1772 | if (finicsum != cfcsum) { |
| 1827 | csio_warn(hw, | 1773 | csio_warn(hw, |
| 1828 | "Config File checksum mismatch: csum=%#x, computed=%#x\n", | 1774 | "Config File checksum mismatch: csum=%#x, computed=%#x\n", |
| 1829 | finicsum, cfcsum); | 1775 | finicsum, cfcsum); |
| 1830 | |||
| 1831 | hw->cfg_csum_status = false; | ||
| 1832 | } | 1776 | } |
| 1833 | 1777 | ||
| 1778 | /* Validate device capabilities */ | ||
| 1779 | if (csio_hw_validate_caps(hw, mbp)) | ||
| 1780 | goto bye; | ||
| 1834 | /* | 1781 | /* |
| 1835 | * Note that we're operating with parameters | 1782 | * Note that we're operating with parameters |
| 1836 | * not supplied by the driver, rather than from hard-wired | 1783 | * not supplied by the driver, rather than from hard-wired |
| @@ -1853,55 +1800,19 @@ csio_hw_use_fwconfig(struct csio_hw *hw, int reset, u32 *fw_cfg_param) | |||
| 1853 | /* Post event to notify completion of configuration */ | 1800 | /* Post event to notify completion of configuration */ |
| 1854 | csio_post_event(&hw->sm, CSIO_HWE_INIT); | 1801 | csio_post_event(&hw->sm, CSIO_HWE_INIT); |
| 1855 | 1802 | ||
| 1856 | csio_info(hw, | 1803 | csio_info(hw, "Successfully configure using Firmware " |
| 1857 | "Firmware Configuration File %s, version %#x, computed checksum %#x\n", | 1804 | "Configuration File %s, version %#x, computed checksum %#x\n", |
| 1858 | (using_flash ? "in device FLASH" : path), finiver, cfcsum); | 1805 | config_name, finiver, cfcsum); |
| 1859 | |||
| 1860 | return 0; | 1806 | return 0; |
| 1861 | 1807 | ||
| 1862 | /* | 1808 | /* |
| 1863 | * Something bad happened. Return the error ... | 1809 | * Something bad happened. Return the error ... |
| 1864 | */ | 1810 | */ |
| 1865 | bye: | 1811 | bye: |
| 1812 | if (mbp) | ||
| 1813 | mempool_free(mbp, hw->mb_mempool); | ||
| 1866 | hw->flags &= ~CSIO_HWF_USING_SOFT_PARAMS; | 1814 | hw->flags &= ~CSIO_HWF_USING_SOFT_PARAMS; |
| 1867 | csio_dbg(hw, "Configuration file error %d\n", rv); | 1815 | csio_warn(hw, "Configuration file error %d\n", rv); |
| 1868 | return rv; | ||
| 1869 | } | ||
| 1870 | |||
| 1871 | /* | ||
| 1872 | * Attempt to initialize the adapter via hard-coded, driver supplied | ||
| 1873 | * parameters ... | ||
| 1874 | */ | ||
| 1875 | static int | ||
| 1876 | csio_hw_no_fwconfig(struct csio_hw *hw, int reset) | ||
| 1877 | { | ||
| 1878 | int rv; | ||
| 1879 | /* | ||
| 1880 | * Reset device if necessary | ||
| 1881 | */ | ||
| 1882 | if (reset) { | ||
| 1883 | rv = csio_do_reset(hw, true); | ||
| 1884 | if (rv != 0) | ||
| 1885 | goto out; | ||
| 1886 | } | ||
| 1887 | |||
| 1888 | /* Get and set device capabilities */ | ||
| 1889 | rv = csio_config_device_caps(hw); | ||
| 1890 | if (rv != 0) | ||
| 1891 | goto out; | ||
| 1892 | |||
| 1893 | /* device parameters */ | ||
| 1894 | rv = csio_get_device_params(hw); | ||
| 1895 | if (rv != 0) | ||
| 1896 | goto out; | ||
| 1897 | |||
| 1898 | /* Configure SGE */ | ||
| 1899 | csio_wr_sge_init(hw); | ||
| 1900 | |||
| 1901 | /* Post event to notify completion of configuration */ | ||
| 1902 | csio_post_event(&hw->sm, CSIO_HWE_INIT); | ||
| 1903 | |||
| 1904 | out: | ||
| 1905 | return rv; | 1816 | return rv; |
| 1906 | } | 1817 | } |
| 1907 | 1818 | ||
| @@ -2101,7 +2012,9 @@ csio_hw_flash_fw(struct csio_hw *hw, int *reset) | |||
| 2101 | if (request_firmware(&fw, FW_FNAME_T5, dev) < 0) { | 2012 | if (request_firmware(&fw, FW_FNAME_T5, dev) < 0) { |
| 2102 | csio_err(hw, "could not find firmware image %s, err: %d\n", | 2013 | csio_err(hw, "could not find firmware image %s, err: %d\n", |
| 2103 | FW_FNAME_T5, ret); | 2014 | FW_FNAME_T5, ret); |
| 2104 | return -EINVAL; | 2015 | } else { |
| 2016 | fw_data = fw->data; | ||
| 2017 | fw_size = fw->size; | ||
| 2105 | } | 2018 | } |
| 2106 | 2019 | ||
| 2107 | /* allocate memory to read the header of the firmware on the | 2020 | /* allocate memory to read the header of the firmware on the |
| @@ -2109,9 +2022,6 @@ csio_hw_flash_fw(struct csio_hw *hw, int *reset) | |||
| 2109 | */ | 2022 | */ |
| 2110 | card_fw = kmalloc(sizeof(*card_fw), GFP_KERNEL); | 2023 | card_fw = kmalloc(sizeof(*card_fw), GFP_KERNEL); |
| 2111 | 2024 | ||
| 2112 | fw_data = fw->data; | ||
| 2113 | fw_size = fw->size; | ||
| 2114 | |||
| 2115 | /* upgrade FW logic */ | 2025 | /* upgrade FW logic */ |
| 2116 | ret = csio_hw_prep_fw(hw, fw_info, fw_data, fw_size, card_fw, | 2026 | ret = csio_hw_prep_fw(hw, fw_info, fw_data, fw_size, card_fw, |
| 2117 | hw->fw_state, reset); | 2027 | hw->fw_state, reset); |
| @@ -2190,31 +2100,31 @@ csio_hw_configure(struct csio_hw *hw) | |||
| 2190 | if (rv != 0) | 2100 | if (rv != 0) |
| 2191 | goto out; | 2101 | goto out; |
| 2192 | 2102 | ||
| 2193 | /* | 2103 | /* If the firmware doesn't support Configuration Files, |
| 2194 | * If the firmware doesn't support Configuration | 2104 | * return an error. |
| 2195 | * Files, use the old Driver-based, hard-wired | ||
| 2196 | * initialization. Otherwise, try using the | ||
| 2197 | * Configuration File support and fall back to the | ||
| 2198 | * Driver-based initialization if there's no | ||
| 2199 | * Configuration File found. | ||
| 2200 | */ | 2105 | */ |
| 2201 | if (csio_hw_check_fwconfig(hw, param) == 0) { | 2106 | rv = csio_hw_check_fwconfig(hw, param); |
| 2202 | rv = csio_hw_use_fwconfig(hw, reset, param); | 2107 | if (rv != 0) { |
| 2203 | if (rv == -ENOENT) | 2108 | csio_info(hw, "Firmware doesn't support " |
| 2204 | goto out; | 2109 | "Firmware Configuration files\n"); |
| 2205 | if (rv != 0) { | 2110 | goto out; |
| 2206 | csio_info(hw, | ||
| 2207 | "No Configuration File present " | ||
| 2208 | "on adapter. Using hard-wired " | ||
| 2209 | "configuration parameters.\n"); | ||
| 2210 | rv = csio_hw_no_fwconfig(hw, reset); | ||
| 2211 | } | ||
| 2212 | } else { | ||
| 2213 | rv = csio_hw_no_fwconfig(hw, reset); | ||
| 2214 | } | 2111 | } |
| 2215 | 2112 | ||
| 2216 | if (rv != 0) | 2113 | /* The firmware provides us with a memory buffer where we can |
| 2114 | * load a Configuration File from the host if we want to | ||
| 2115 | * override the Configuration File in flash. | ||
| 2116 | */ | ||
| 2117 | rv = csio_hw_use_fwconfig(hw, reset, param); | ||
| 2118 | if (rv == -ENOENT) { | ||
| 2119 | csio_info(hw, "Could not initialize " | ||
| 2120 | "adapter, error%d\n", rv); | ||
| 2217 | goto out; | 2121 | goto out; |
| 2122 | } | ||
| 2123 | if (rv != 0) { | ||
| 2124 | csio_info(hw, "Could not initialize " | ||
| 2125 | "adapter, error%d\n", rv); | ||
| 2126 | goto out; | ||
| 2127 | } | ||
| 2218 | 2128 | ||
| 2219 | } else { | 2129 | } else { |
| 2220 | if (hw->fw_state == CSIO_DEV_STATE_INIT) { | 2130 | if (hw->fw_state == CSIO_DEV_STATE_INIT) { |
