diff options
author | Krishna Gudipati <kgudipat@brocade.com> | 2010-03-05 22:37:57 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-03-07 02:37:00 -0500 |
commit | 0a4b1fc0b24fc7adbaf8413f2992ce1395991a78 (patch) | |
tree | 9a07aeee614e2e3f3191aee552effc467163fb33 /drivers/scsi/bfa/bfa_ioc.c | |
parent | f58e9ebbf78bd36c6cf1ca651280d39efe73a7c0 (diff) |
[SCSI] bfa: Replace bfa_get_attr() with specific APIs
bfa_ioc_attr_s is a big structure and some times could cause
stack overflow if defined locally, so add specific APIs that
are needed to replace the use of ioc_attr local var.
Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/bfa/bfa_ioc.c')
-rw-r--r-- | drivers/scsi/bfa/bfa_ioc.c | 155 |
1 files changed, 95 insertions, 60 deletions
diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c index 4d9a47ccffe9..e038bc9769f6 100644 --- a/drivers/scsi/bfa/bfa_ioc.c +++ b/drivers/scsi/bfa/bfa_ioc.c | |||
@@ -1679,46 +1679,28 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc, | |||
1679 | struct bfa_adapter_attr_s *ad_attr) | 1679 | struct bfa_adapter_attr_s *ad_attr) |
1680 | { | 1680 | { |
1681 | struct bfi_ioc_attr_s *ioc_attr; | 1681 | struct bfi_ioc_attr_s *ioc_attr; |
1682 | char model[BFA_ADAPTER_MODEL_NAME_LEN]; | ||
1683 | 1682 | ||
1684 | ioc_attr = ioc->attr; | 1683 | ioc_attr = ioc->attr; |
1685 | bfa_os_memcpy((void *)&ad_attr->serial_num, | 1684 | |
1686 | (void *)ioc_attr->brcd_serialnum, | 1685 | bfa_ioc_get_adapter_serial_num(ioc, ad_attr->serial_num); |
1687 | BFA_ADAPTER_SERIAL_NUM_LEN); | 1686 | bfa_ioc_get_adapter_fw_ver(ioc, ad_attr->fw_ver); |
1688 | 1687 | bfa_ioc_get_adapter_optrom_ver(ioc, ad_attr->optrom_ver); | |
1689 | bfa_os_memcpy(&ad_attr->fw_ver, ioc_attr->fw_version, BFA_VERSION_LEN); | 1688 | bfa_ioc_get_adapter_manufacturer(ioc, ad_attr->manufacturer); |
1690 | bfa_os_memcpy(&ad_attr->optrom_ver, ioc_attr->optrom_version, | ||
1691 | BFA_VERSION_LEN); | ||
1692 | bfa_os_memcpy(&ad_attr->manufacturer, BFA_MFG_NAME, | ||
1693 | BFA_ADAPTER_MFG_NAME_LEN); | ||
1694 | bfa_os_memcpy(&ad_attr->vpd, &ioc_attr->vpd, | 1689 | bfa_os_memcpy(&ad_attr->vpd, &ioc_attr->vpd, |
1695 | sizeof(struct bfa_mfg_vpd_s)); | 1690 | sizeof(struct bfa_mfg_vpd_s)); |
1696 | 1691 | ||
1697 | ad_attr->nports = BFI_ADAPTER_GETP(NPORTS, ioc_attr->adapter_prop); | 1692 | ad_attr->nports = bfa_ioc_get_nports(ioc); |
1698 | ad_attr->max_speed = BFI_ADAPTER_GETP(SPEED, ioc_attr->adapter_prop); | 1693 | ad_attr->max_speed = bfa_ioc_speed_sup(ioc); |
1699 | 1694 | ||
1700 | /** | 1695 | bfa_ioc_get_adapter_model(ioc, ad_attr->model); |
1701 | * model name | 1696 | /* For now, model descr uses same model string */ |
1702 | */ | 1697 | bfa_ioc_get_adapter_model(ioc, ad_attr->model_descr); |
1703 | if (BFI_ADAPTER_GETP(SPEED, ioc_attr->adapter_prop) == 10) { | ||
1704 | strcpy(model, "BR-10?0"); | ||
1705 | model[5] = '0' + ad_attr->nports; | ||
1706 | } else { | ||
1707 | strcpy(model, "Brocade-??5"); | ||
1708 | model[8] = | ||
1709 | '0' + BFI_ADAPTER_GETP(SPEED, ioc_attr->adapter_prop); | ||
1710 | model[9] = '0' + ad_attr->nports; | ||
1711 | } | ||
1712 | 1698 | ||
1713 | if (BFI_ADAPTER_IS_SPECIAL(ioc_attr->adapter_prop)) | 1699 | if (BFI_ADAPTER_IS_SPECIAL(ioc_attr->adapter_prop)) |
1714 | ad_attr->prototype = 1; | 1700 | ad_attr->prototype = 1; |
1715 | else | 1701 | else |
1716 | ad_attr->prototype = 0; | 1702 | ad_attr->prototype = 0; |
1717 | 1703 | ||
1718 | bfa_os_memcpy(&ad_attr->model, model, BFA_ADAPTER_MODEL_NAME_LEN); | ||
1719 | bfa_os_memcpy(&ad_attr->model_descr, &ad_attr->model, | ||
1720 | BFA_ADAPTER_MODEL_NAME_LEN); | ||
1721 | |||
1722 | ad_attr->pwwn = bfa_ioc_get_pwwn(ioc); | 1704 | ad_attr->pwwn = bfa_ioc_get_pwwn(ioc); |
1723 | ad_attr->mac = bfa_ioc_get_mac(ioc); | 1705 | ad_attr->mac = bfa_ioc_get_mac(ioc); |
1724 | 1706 | ||
@@ -1726,12 +1708,8 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc, | |||
1726 | ad_attr->pcie_lanes = ioc_attr->pcie_lanes; | 1708 | ad_attr->pcie_lanes = ioc_attr->pcie_lanes; |
1727 | ad_attr->pcie_lanes_orig = ioc_attr->pcie_lanes_orig; | 1709 | ad_attr->pcie_lanes_orig = ioc_attr->pcie_lanes_orig; |
1728 | ad_attr->asic_rev = ioc_attr->asic_rev; | 1710 | ad_attr->asic_rev = ioc_attr->asic_rev; |
1729 | ad_attr->hw_ver[0] = 'R'; | 1711 | |
1730 | ad_attr->hw_ver[1] = 'e'; | 1712 | bfa_ioc_get_pci_chip_rev(ioc, ad_attr->hw_ver); |
1731 | ad_attr->hw_ver[2] = 'v'; | ||
1732 | ad_attr->hw_ver[3] = '-'; | ||
1733 | ad_attr->hw_ver[4] = ioc_attr->asic_rev; | ||
1734 | ad_attr->hw_ver[5] = '\0'; | ||
1735 | 1713 | ||
1736 | ad_attr->cna_capable = ioc->cna; | 1714 | ad_attr->cna_capable = ioc->cna; |
1737 | } | 1715 | } |
@@ -1752,11 +1730,91 @@ bfa_ioc_get_type(struct bfa_ioc_s *ioc) | |||
1752 | } | 1730 | } |
1753 | 1731 | ||
1754 | void | 1732 | void |
1733 | bfa_ioc_get_adapter_serial_num(struct bfa_ioc_s *ioc, char *serial_num) | ||
1734 | { | ||
1735 | bfa_os_memset((void *)serial_num, 0, BFA_ADAPTER_SERIAL_NUM_LEN); | ||
1736 | bfa_os_memcpy((void *)serial_num, | ||
1737 | (void *)ioc->attr->brcd_serialnum, | ||
1738 | BFA_ADAPTER_SERIAL_NUM_LEN); | ||
1739 | } | ||
1740 | |||
1741 | void | ||
1742 | bfa_ioc_get_adapter_fw_ver(struct bfa_ioc_s *ioc, char *fw_ver) | ||
1743 | { | ||
1744 | bfa_os_memset((void *)fw_ver, 0, BFA_VERSION_LEN); | ||
1745 | bfa_os_memcpy(fw_ver, ioc->attr->fw_version, BFA_VERSION_LEN); | ||
1746 | } | ||
1747 | |||
1748 | void | ||
1749 | bfa_ioc_get_pci_chip_rev(struct bfa_ioc_s *ioc, char *chip_rev) | ||
1750 | { | ||
1751 | bfa_assert(chip_rev); | ||
1752 | |||
1753 | bfa_os_memset((void *)chip_rev, 0, BFA_IOC_CHIP_REV_LEN); | ||
1754 | |||
1755 | chip_rev[0] = 'R'; | ||
1756 | chip_rev[1] = 'e'; | ||
1757 | chip_rev[2] = 'v'; | ||
1758 | chip_rev[3] = '-'; | ||
1759 | chip_rev[4] = ioc->attr->asic_rev; | ||
1760 | chip_rev[5] = '\0'; | ||
1761 | } | ||
1762 | |||
1763 | void | ||
1764 | bfa_ioc_get_adapter_optrom_ver(struct bfa_ioc_s *ioc, char *optrom_ver) | ||
1765 | { | ||
1766 | bfa_os_memset((void *)optrom_ver, 0, BFA_VERSION_LEN); | ||
1767 | bfa_os_memcpy(optrom_ver, ioc->attr->optrom_version, | ||
1768 | BFA_VERSION_LEN); | ||
1769 | } | ||
1770 | |||
1771 | void | ||
1772 | bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc, char *manufacturer) | ||
1773 | { | ||
1774 | bfa_os_memset((void *)manufacturer, 0, BFA_ADAPTER_MFG_NAME_LEN); | ||
1775 | bfa_os_memcpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN); | ||
1776 | } | ||
1777 | |||
1778 | void | ||
1779 | bfa_ioc_get_adapter_model(struct bfa_ioc_s *ioc, char *model) | ||
1780 | { | ||
1781 | struct bfi_ioc_attr_s *ioc_attr; | ||
1782 | u8 nports; | ||
1783 | u8 max_speed; | ||
1784 | |||
1785 | bfa_assert(model); | ||
1786 | bfa_os_memset((void *)model, 0, BFA_ADAPTER_MODEL_NAME_LEN); | ||
1787 | |||
1788 | ioc_attr = ioc->attr; | ||
1789 | |||
1790 | nports = bfa_ioc_get_nports(ioc); | ||
1791 | max_speed = bfa_ioc_speed_sup(ioc); | ||
1792 | |||
1793 | /** | ||
1794 | * model name | ||
1795 | */ | ||
1796 | if (max_speed == 10) { | ||
1797 | strcpy(model, "BR-10?0"); | ||
1798 | model[5] = '0' + nports; | ||
1799 | } else { | ||
1800 | strcpy(model, "Brocade-??5"); | ||
1801 | model[8] = '0' + max_speed; | ||
1802 | model[9] = '0' + nports; | ||
1803 | } | ||
1804 | } | ||
1805 | |||
1806 | enum bfa_ioc_state | ||
1807 | bfa_ioc_get_state(struct bfa_ioc_s *ioc) | ||
1808 | { | ||
1809 | return bfa_sm_to_state(ioc_sm_table, ioc->fsm); | ||
1810 | } | ||
1811 | |||
1812 | void | ||
1755 | bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr) | 1813 | bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr) |
1756 | { | 1814 | { |
1757 | bfa_os_memset((void *)ioc_attr, 0, sizeof(struct bfa_ioc_attr_s)); | 1815 | bfa_os_memset((void *)ioc_attr, 0, sizeof(struct bfa_ioc_attr_s)); |
1758 | 1816 | ||
1759 | ioc_attr->state = bfa_sm_to_state(ioc_sm_table, ioc->fsm); | 1817 | ioc_attr->state = bfa_ioc_get_state(ioc); |
1760 | ioc_attr->port_id = ioc->port_id; | 1818 | ioc_attr->port_id = ioc->port_id; |
1761 | 1819 | ||
1762 | ioc_attr->ioc_type = bfa_ioc_get_type(ioc); | 1820 | ioc_attr->ioc_type = bfa_ioc_get_type(ioc); |
@@ -1765,12 +1823,7 @@ bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr) | |||
1765 | 1823 | ||
1766 | ioc_attr->pci_attr.device_id = ioc->pcidev.device_id; | 1824 | ioc_attr->pci_attr.device_id = ioc->pcidev.device_id; |
1767 | ioc_attr->pci_attr.pcifn = ioc->pcidev.pci_func; | 1825 | ioc_attr->pci_attr.pcifn = ioc->pcidev.pci_func; |
1768 | ioc_attr->pci_attr.chip_rev[0] = 'R'; | 1826 | bfa_ioc_get_pci_chip_rev(ioc, ioc_attr->pci_attr.chip_rev); |
1769 | ioc_attr->pci_attr.chip_rev[1] = 'e'; | ||
1770 | ioc_attr->pci_attr.chip_rev[2] = 'v'; | ||
1771 | ioc_attr->pci_attr.chip_rev[3] = '-'; | ||
1772 | ioc_attr->pci_attr.chip_rev[4] = ioc_attr->adapter_attr.asic_rev; | ||
1773 | ioc_attr->pci_attr.chip_rev[5] = '\0'; | ||
1774 | } | 1827 | } |
1775 | 1828 | ||
1776 | /** | 1829 | /** |
@@ -1877,25 +1930,7 @@ bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event) | |||
1877 | s32 inst_num = 0; | 1930 | s32 inst_num = 0; |
1878 | enum bfa_ioc_type_e ioc_type; | 1931 | enum bfa_ioc_type_e ioc_type; |
1879 | 1932 | ||
1880 | switch (event) { | 1933 | bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_IOC, event), inst_num); |
1881 | case BFA_IOC_AEN_HBGOOD: | ||
1882 | bfa_log(logmod, BFA_AEN_IOC_HBGOOD, inst_num); | ||
1883 | break; | ||
1884 | case BFA_IOC_AEN_HBFAIL: | ||
1885 | bfa_log(logmod, BFA_AEN_IOC_HBFAIL, inst_num); | ||
1886 | break; | ||
1887 | case BFA_IOC_AEN_ENABLE: | ||
1888 | bfa_log(logmod, BFA_AEN_IOC_ENABLE, inst_num); | ||
1889 | break; | ||
1890 | case BFA_IOC_AEN_DISABLE: | ||
1891 | bfa_log(logmod, BFA_AEN_IOC_DISABLE, inst_num); | ||
1892 | break; | ||
1893 | case BFA_IOC_AEN_FWMISMATCH: | ||
1894 | bfa_log(logmod, BFA_AEN_IOC_FWMISMATCH, inst_num); | ||
1895 | break; | ||
1896 | default: | ||
1897 | break; | ||
1898 | } | ||
1899 | 1934 | ||
1900 | memset(&aen_data.ioc.pwwn, 0, sizeof(aen_data.ioc.pwwn)); | 1935 | memset(&aen_data.ioc.pwwn, 0, sizeof(aen_data.ioc.pwwn)); |
1901 | memset(&aen_data.ioc.mac, 0, sizeof(aen_data.ioc.mac)); | 1936 | memset(&aen_data.ioc.mac, 0, sizeof(aen_data.ioc.mac)); |