diff options
author | Nilesh Javali <nilesh.javali@cavium.com> | 2017-06-27 05:26:56 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2017-07-12 16:52:27 -0400 |
commit | c57ec8fb7c025322f25a077afc94e0ef18cc3d89 (patch) | |
tree | 523a4d946829253cd1a82f3b68d97247359ef161 | |
parent | 130568d5eac5537cbd64cfb12103550af90edb79 (diff) |
scsi: qedi: Add support for Boot from SAN over iSCSI offload
This patch adds support for Boot from SAN over iSCSI offload. The iSCSI
boot information in the NVRAM is populated under
/sys/firmware/iscsi_bootX/ using qed NVM-image reading API and further
exported to open-iscsi to perform iSCSI login enabling boot over offload
iSCSI interface in a Boot from SAN environment.
Signed-off-by: Arun Easi <arun.easi@cavium.com>
Signed-off-by: Andrew Vasquez <andrew.vasquez@cavium.com>
Signed-off-by: Manish Rangankar <manish.rangankar@cavium.com>
Signed-off-by: Nilesh Javali <nilesh.javali@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/qedi/qedi.h | 17 | ||||
-rw-r--r-- | drivers/scsi/qedi/qedi_main.c | 419 | ||||
-rw-r--r-- | drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h | 210 |
3 files changed, 646 insertions, 0 deletions
diff --git a/drivers/scsi/qedi/qedi.h b/drivers/scsi/qedi/qedi.h index 32632c9b2276..91d2f51c351b 100644 --- a/drivers/scsi/qedi/qedi.h +++ b/drivers/scsi/qedi/qedi.h | |||
@@ -23,11 +23,17 @@ | |||
23 | #include <linux/qed/qed_iscsi_if.h> | 23 | #include <linux/qed/qed_iscsi_if.h> |
24 | #include <linux/qed/qed_ll2_if.h> | 24 | #include <linux/qed/qed_ll2_if.h> |
25 | #include "qedi_version.h" | 25 | #include "qedi_version.h" |
26 | #include "qedi_nvm_iscsi_cfg.h" | ||
26 | 27 | ||
27 | #define QEDI_MODULE_NAME "qedi" | 28 | #define QEDI_MODULE_NAME "qedi" |
28 | 29 | ||
29 | struct qedi_endpoint; | 30 | struct qedi_endpoint; |
30 | 31 | ||
32 | #ifndef GET_FIELD2 | ||
33 | #define GET_FIELD2(value, name) \ | ||
34 | (((value) & (name ## _MASK)) >> (name ## _OFFSET)) | ||
35 | #endif | ||
36 | |||
31 | /* | 37 | /* |
32 | * PCI function probe defines | 38 | * PCI function probe defines |
33 | */ | 39 | */ |
@@ -66,6 +72,11 @@ struct qedi_endpoint; | |||
66 | #define QEDI_HW_DMA_BOUNDARY 0xfff | 72 | #define QEDI_HW_DMA_BOUNDARY 0xfff |
67 | #define QEDI_PATH_HANDLE 0xFE0000000UL | 73 | #define QEDI_PATH_HANDLE 0xFE0000000UL |
68 | 74 | ||
75 | enum qedi_nvm_tgts { | ||
76 | QEDI_NVM_TGT_PRI, | ||
77 | QEDI_NVM_TGT_SEC, | ||
78 | }; | ||
79 | |||
69 | struct qedi_uio_ctrl { | 80 | struct qedi_uio_ctrl { |
70 | /* meta data */ | 81 | /* meta data */ |
71 | u32 uio_hsi_version; | 82 | u32 uio_hsi_version; |
@@ -283,6 +294,8 @@ struct qedi_ctx { | |||
283 | void *bdq_pbl_list; | 294 | void *bdq_pbl_list; |
284 | dma_addr_t bdq_pbl_list_dma; | 295 | dma_addr_t bdq_pbl_list_dma; |
285 | u8 bdq_pbl_list_num_entries; | 296 | u8 bdq_pbl_list_num_entries; |
297 | struct nvm_iscsi_cfg *iscsi_cfg; | ||
298 | dma_addr_t nvm_buf_dma; | ||
286 | void __iomem *bdq_primary_prod; | 299 | void __iomem *bdq_primary_prod; |
287 | void __iomem *bdq_secondary_prod; | 300 | void __iomem *bdq_secondary_prod; |
288 | u16 bdq_prod_idx; | 301 | u16 bdq_prod_idx; |
@@ -337,6 +350,10 @@ struct qedi_ctx { | |||
337 | bool use_fast_sge; | 350 | bool use_fast_sge; |
338 | 351 | ||
339 | atomic_t num_offloads; | 352 | atomic_t num_offloads; |
353 | #define SYSFS_FLAG_FW_SEL_BOOT 2 | ||
354 | #define IPV6_LEN 41 | ||
355 | #define IPV4_LEN 17 | ||
356 | struct iscsi_boot_kset *boot_kset; | ||
340 | }; | 357 | }; |
341 | 358 | ||
342 | struct qedi_work { | 359 | struct qedi_work { |
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index 5f5a4ef2e529..2c3783684815 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
20 | #include <linux/if_vlan.h> | 20 | #include <linux/if_vlan.h> |
21 | #include <linux/cpu.h> | 21 | #include <linux/cpu.h> |
22 | #include <linux/iscsi_boot_sysfs.h> | ||
22 | 23 | ||
23 | #include <scsi/scsi_cmnd.h> | 24 | #include <scsi/scsi_cmnd.h> |
24 | #include <scsi/scsi_device.h> | 25 | #include <scsi/scsi_device.h> |
@@ -1143,6 +1144,30 @@ exit_setup_int: | |||
1143 | return rc; | 1144 | return rc; |
1144 | } | 1145 | } |
1145 | 1146 | ||
1147 | static void qedi_free_nvm_iscsi_cfg(struct qedi_ctx *qedi) | ||
1148 | { | ||
1149 | if (qedi->iscsi_cfg) | ||
1150 | dma_free_coherent(&qedi->pdev->dev, | ||
1151 | sizeof(struct nvm_iscsi_cfg), | ||
1152 | qedi->iscsi_cfg, qedi->nvm_buf_dma); | ||
1153 | } | ||
1154 | |||
1155 | static int qedi_alloc_nvm_iscsi_cfg(struct qedi_ctx *qedi) | ||
1156 | { | ||
1157 | qedi->iscsi_cfg = dma_zalloc_coherent(&qedi->pdev->dev, | ||
1158 | sizeof(struct nvm_iscsi_cfg), | ||
1159 | &qedi->nvm_buf_dma, GFP_KERNEL); | ||
1160 | if (!qedi->iscsi_cfg) { | ||
1161 | QEDI_ERR(&qedi->dbg_ctx, "Could not allocate NVM BUF.\n"); | ||
1162 | return -ENOMEM; | ||
1163 | } | ||
1164 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, | ||
1165 | "NVM BUF addr=0x%p dma=0x%llx.\n", qedi->iscsi_cfg, | ||
1166 | qedi->nvm_buf_dma); | ||
1167 | |||
1168 | return 0; | ||
1169 | } | ||
1170 | |||
1146 | static void qedi_free_bdq(struct qedi_ctx *qedi) | 1171 | static void qedi_free_bdq(struct qedi_ctx *qedi) |
1147 | { | 1172 | { |
1148 | int i; | 1173 | int i; |
@@ -1183,6 +1208,7 @@ static void qedi_free_global_queues(struct qedi_ctx *qedi) | |||
1183 | kfree(gl[i]); | 1208 | kfree(gl[i]); |
1184 | } | 1209 | } |
1185 | qedi_free_bdq(qedi); | 1210 | qedi_free_bdq(qedi); |
1211 | qedi_free_nvm_iscsi_cfg(qedi); | ||
1186 | } | 1212 | } |
1187 | 1213 | ||
1188 | static int qedi_alloc_bdq(struct qedi_ctx *qedi) | 1214 | static int qedi_alloc_bdq(struct qedi_ctx *qedi) |
@@ -1309,6 +1335,11 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi) | |||
1309 | if (rc) | 1335 | if (rc) |
1310 | goto mem_alloc_failure; | 1336 | goto mem_alloc_failure; |
1311 | 1337 | ||
1338 | /* Allocate DMA coherent buffers for NVM_ISCSI_CFG */ | ||
1339 | rc = qedi_alloc_nvm_iscsi_cfg(qedi); | ||
1340 | if (rc) | ||
1341 | goto mem_alloc_failure; | ||
1342 | |||
1312 | /* Allocate a CQ and an associated PBL for each MSI-X | 1343 | /* Allocate a CQ and an associated PBL for each MSI-X |
1313 | * vector. | 1344 | * vector. |
1314 | */ | 1345 | */ |
@@ -1671,6 +1702,387 @@ void qedi_reset_host_mtu(struct qedi_ctx *qedi, u16 mtu) | |||
1671 | qedi_ops->ll2->start(qedi->cdev, ¶ms); | 1702 | qedi_ops->ll2->start(qedi->cdev, ¶ms); |
1672 | } | 1703 | } |
1673 | 1704 | ||
1705 | /** | ||
1706 | * qedi_get_nvram_block: - Scan through the iSCSI NVRAM block (while accounting | ||
1707 | * for gaps) for the matching absolute-pf-id of the QEDI device. | ||
1708 | */ | ||
1709 | static struct nvm_iscsi_block * | ||
1710 | qedi_get_nvram_block(struct qedi_ctx *qedi) | ||
1711 | { | ||
1712 | int i; | ||
1713 | u8 pf; | ||
1714 | u32 flags; | ||
1715 | struct nvm_iscsi_block *block; | ||
1716 | |||
1717 | pf = qedi->dev_info.common.abs_pf_id; | ||
1718 | block = &qedi->iscsi_cfg->block[0]; | ||
1719 | for (i = 0; i < NUM_OF_ISCSI_PF_SUPPORTED; i++, block++) { | ||
1720 | flags = ((block->id) & NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK) >> | ||
1721 | NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET; | ||
1722 | if (flags & (NVM_ISCSI_CFG_BLK_CTRL_FLAG_IS_NOT_EMPTY | | ||
1723 | NVM_ISCSI_CFG_BLK_CTRL_FLAG_PF_MAPPED) && | ||
1724 | (pf == (block->id & NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_MASK) | ||
1725 | >> NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_OFFSET)) | ||
1726 | return block; | ||
1727 | } | ||
1728 | return NULL; | ||
1729 | } | ||
1730 | |||
1731 | static ssize_t qedi_show_boot_eth_info(void *data, int type, char *buf) | ||
1732 | { | ||
1733 | struct qedi_ctx *qedi = data; | ||
1734 | struct nvm_iscsi_initiator *initiator; | ||
1735 | char *str = buf; | ||
1736 | int rc = 1; | ||
1737 | u32 ipv6_en, dhcp_en, ip_len; | ||
1738 | struct nvm_iscsi_block *block; | ||
1739 | char *fmt, *ip, *sub, *gw; | ||
1740 | |||
1741 | block = qedi_get_nvram_block(qedi); | ||
1742 | if (!block) | ||
1743 | return 0; | ||
1744 | |||
1745 | initiator = &block->initiator; | ||
1746 | ipv6_en = block->generic.ctrl_flags & | ||
1747 | NVM_ISCSI_CFG_GEN_IPV6_ENABLED; | ||
1748 | dhcp_en = block->generic.ctrl_flags & | ||
1749 | NVM_ISCSI_CFG_GEN_DHCP_TCPIP_CONFIG_ENABLED; | ||
1750 | /* Static IP assignments. */ | ||
1751 | fmt = ipv6_en ? "%pI6\n" : "%pI4\n"; | ||
1752 | ip = ipv6_en ? initiator->ipv6.addr.byte : initiator->ipv4.addr.byte; | ||
1753 | ip_len = ipv6_en ? IPV6_LEN : IPV4_LEN; | ||
1754 | sub = ipv6_en ? initiator->ipv6.subnet_mask.byte : | ||
1755 | initiator->ipv4.subnet_mask.byte; | ||
1756 | gw = ipv6_en ? initiator->ipv6.gateway.byte : | ||
1757 | initiator->ipv4.gateway.byte; | ||
1758 | /* DHCP IP adjustments. */ | ||
1759 | fmt = dhcp_en ? "%s\n" : fmt; | ||
1760 | if (dhcp_en) { | ||
1761 | ip = ipv6_en ? "0::0" : "0.0.0.0"; | ||
1762 | sub = ip; | ||
1763 | gw = ip; | ||
1764 | ip_len = ipv6_en ? 5 : 8; | ||
1765 | } | ||
1766 | |||
1767 | switch (type) { | ||
1768 | case ISCSI_BOOT_ETH_IP_ADDR: | ||
1769 | rc = snprintf(str, ip_len, fmt, ip); | ||
1770 | break; | ||
1771 | case ISCSI_BOOT_ETH_SUBNET_MASK: | ||
1772 | rc = snprintf(str, ip_len, fmt, sub); | ||
1773 | break; | ||
1774 | case ISCSI_BOOT_ETH_GATEWAY: | ||
1775 | rc = snprintf(str, ip_len, fmt, gw); | ||
1776 | break; | ||
1777 | case ISCSI_BOOT_ETH_FLAGS: | ||
1778 | rc = snprintf(str, 3, "%hhd\n", | ||
1779 | SYSFS_FLAG_FW_SEL_BOOT); | ||
1780 | break; | ||
1781 | case ISCSI_BOOT_ETH_INDEX: | ||
1782 | rc = snprintf(str, 3, "0\n"); | ||
1783 | break; | ||
1784 | case ISCSI_BOOT_ETH_MAC: | ||
1785 | rc = sysfs_format_mac(str, qedi->mac, ETH_ALEN); | ||
1786 | break; | ||
1787 | case ISCSI_BOOT_ETH_VLAN: | ||
1788 | rc = snprintf(str, 12, "%d\n", | ||
1789 | GET_FIELD2(initiator->generic_cont0, | ||
1790 | NVM_ISCSI_CFG_INITIATOR_VLAN)); | ||
1791 | break; | ||
1792 | case ISCSI_BOOT_ETH_ORIGIN: | ||
1793 | if (dhcp_en) | ||
1794 | rc = snprintf(str, 3, "3\n"); | ||
1795 | break; | ||
1796 | default: | ||
1797 | rc = 0; | ||
1798 | break; | ||
1799 | } | ||
1800 | |||
1801 | return rc; | ||
1802 | } | ||
1803 | |||
1804 | static umode_t qedi_eth_get_attr_visibility(void *data, int type) | ||
1805 | { | ||
1806 | int rc = 1; | ||
1807 | |||
1808 | switch (type) { | ||
1809 | case ISCSI_BOOT_ETH_FLAGS: | ||
1810 | case ISCSI_BOOT_ETH_MAC: | ||
1811 | case ISCSI_BOOT_ETH_INDEX: | ||
1812 | case ISCSI_BOOT_ETH_IP_ADDR: | ||
1813 | case ISCSI_BOOT_ETH_SUBNET_MASK: | ||
1814 | case ISCSI_BOOT_ETH_GATEWAY: | ||
1815 | case ISCSI_BOOT_ETH_ORIGIN: | ||
1816 | case ISCSI_BOOT_ETH_VLAN: | ||
1817 | rc = 0444; | ||
1818 | break; | ||
1819 | default: | ||
1820 | rc = 0; | ||
1821 | break; | ||
1822 | } | ||
1823 | return rc; | ||
1824 | } | ||
1825 | |||
1826 | static ssize_t qedi_show_boot_ini_info(void *data, int type, char *buf) | ||
1827 | { | ||
1828 | struct qedi_ctx *qedi = data; | ||
1829 | struct nvm_iscsi_initiator *initiator; | ||
1830 | char *str = buf; | ||
1831 | int rc; | ||
1832 | struct nvm_iscsi_block *block; | ||
1833 | |||
1834 | block = qedi_get_nvram_block(qedi); | ||
1835 | if (!block) | ||
1836 | return 0; | ||
1837 | |||
1838 | initiator = &block->initiator; | ||
1839 | |||
1840 | switch (type) { | ||
1841 | case ISCSI_BOOT_INI_INITIATOR_NAME: | ||
1842 | rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", | ||
1843 | initiator->initiator_name.byte); | ||
1844 | break; | ||
1845 | default: | ||
1846 | rc = 0; | ||
1847 | break; | ||
1848 | } | ||
1849 | return rc; | ||
1850 | } | ||
1851 | |||
1852 | static umode_t qedi_ini_get_attr_visibility(void *data, int type) | ||
1853 | { | ||
1854 | int rc; | ||
1855 | |||
1856 | switch (type) { | ||
1857 | case ISCSI_BOOT_INI_INITIATOR_NAME: | ||
1858 | rc = 0444; | ||
1859 | break; | ||
1860 | default: | ||
1861 | rc = 0; | ||
1862 | break; | ||
1863 | } | ||
1864 | return rc; | ||
1865 | } | ||
1866 | |||
1867 | static ssize_t | ||
1868 | qedi_show_boot_tgt_info(struct qedi_ctx *qedi, int type, | ||
1869 | char *buf, enum qedi_nvm_tgts idx) | ||
1870 | { | ||
1871 | char *str = buf; | ||
1872 | int rc = 1; | ||
1873 | u32 ctrl_flags, ipv6_en, chap_en, mchap_en, ip_len; | ||
1874 | struct nvm_iscsi_block *block; | ||
1875 | char *chap_name, *chap_secret; | ||
1876 | char *mchap_name, *mchap_secret; | ||
1877 | |||
1878 | block = qedi_get_nvram_block(qedi); | ||
1879 | if (!block) | ||
1880 | goto exit_show_tgt_info; | ||
1881 | |||
1882 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_EVT, | ||
1883 | "Port:%d, tgt_idx:%d\n", | ||
1884 | GET_FIELD2(block->id, NVM_ISCSI_CFG_BLK_MAPPED_PF_ID), idx); | ||
1885 | |||
1886 | ctrl_flags = block->target[idx].ctrl_flags & | ||
1887 | NVM_ISCSI_CFG_TARGET_ENABLED; | ||
1888 | |||
1889 | if (!ctrl_flags) { | ||
1890 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_EVT, | ||
1891 | "Target disabled\n"); | ||
1892 | goto exit_show_tgt_info; | ||
1893 | } | ||
1894 | |||
1895 | ipv6_en = block->generic.ctrl_flags & | ||
1896 | NVM_ISCSI_CFG_GEN_IPV6_ENABLED; | ||
1897 | ip_len = ipv6_en ? IPV6_LEN : IPV4_LEN; | ||
1898 | chap_en = block->generic.ctrl_flags & | ||
1899 | NVM_ISCSI_CFG_GEN_CHAP_ENABLED; | ||
1900 | chap_name = chap_en ? block->initiator.chap_name.byte : NULL; | ||
1901 | chap_secret = chap_en ? block->initiator.chap_password.byte : NULL; | ||
1902 | |||
1903 | mchap_en = block->generic.ctrl_flags & | ||
1904 | NVM_ISCSI_CFG_GEN_CHAP_MUTUAL_ENABLED; | ||
1905 | mchap_name = mchap_en ? block->target[idx].chap_name.byte : NULL; | ||
1906 | mchap_secret = mchap_en ? block->target[idx].chap_password.byte : NULL; | ||
1907 | |||
1908 | switch (type) { | ||
1909 | case ISCSI_BOOT_TGT_NAME: | ||
1910 | rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", | ||
1911 | block->target[idx].target_name.byte); | ||
1912 | break; | ||
1913 | case ISCSI_BOOT_TGT_IP_ADDR: | ||
1914 | if (ipv6_en) | ||
1915 | rc = snprintf(str, ip_len, "%pI6\n", | ||
1916 | block->target[idx].ipv6_addr.byte); | ||
1917 | else | ||
1918 | rc = snprintf(str, ip_len, "%pI4\n", | ||
1919 | block->target[idx].ipv4_addr.byte); | ||
1920 | break; | ||
1921 | case ISCSI_BOOT_TGT_PORT: | ||
1922 | rc = snprintf(str, 12, "%d\n", | ||
1923 | GET_FIELD2(block->target[idx].generic_cont0, | ||
1924 | NVM_ISCSI_CFG_TARGET_TCP_PORT)); | ||
1925 | break; | ||
1926 | case ISCSI_BOOT_TGT_LUN: | ||
1927 | rc = snprintf(str, 22, "%.*d\n", | ||
1928 | block->target[idx].lun.value[1], | ||
1929 | block->target[idx].lun.value[0]); | ||
1930 | break; | ||
1931 | case ISCSI_BOOT_TGT_CHAP_NAME: | ||
1932 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", | ||
1933 | chap_name); | ||
1934 | break; | ||
1935 | case ISCSI_BOOT_TGT_CHAP_SECRET: | ||
1936 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", | ||
1937 | chap_secret); | ||
1938 | break; | ||
1939 | case ISCSI_BOOT_TGT_REV_CHAP_NAME: | ||
1940 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", | ||
1941 | mchap_name); | ||
1942 | break; | ||
1943 | case ISCSI_BOOT_TGT_REV_CHAP_SECRET: | ||
1944 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", | ||
1945 | mchap_secret); | ||
1946 | break; | ||
1947 | case ISCSI_BOOT_TGT_FLAGS: | ||
1948 | rc = snprintf(str, 3, "%hhd\n", SYSFS_FLAG_FW_SEL_BOOT); | ||
1949 | break; | ||
1950 | case ISCSI_BOOT_TGT_NIC_ASSOC: | ||
1951 | rc = snprintf(str, 3, "0\n"); | ||
1952 | break; | ||
1953 | default: | ||
1954 | rc = 0; | ||
1955 | break; | ||
1956 | } | ||
1957 | |||
1958 | exit_show_tgt_info: | ||
1959 | return rc; | ||
1960 | } | ||
1961 | |||
1962 | static ssize_t qedi_show_boot_tgt_pri_info(void *data, int type, char *buf) | ||
1963 | { | ||
1964 | struct qedi_ctx *qedi = data; | ||
1965 | |||
1966 | return qedi_show_boot_tgt_info(qedi, type, buf, QEDI_NVM_TGT_PRI); | ||
1967 | } | ||
1968 | |||
1969 | static ssize_t qedi_show_boot_tgt_sec_info(void *data, int type, char *buf) | ||
1970 | { | ||
1971 | struct qedi_ctx *qedi = data; | ||
1972 | |||
1973 | return qedi_show_boot_tgt_info(qedi, type, buf, QEDI_NVM_TGT_SEC); | ||
1974 | } | ||
1975 | |||
1976 | static umode_t qedi_tgt_get_attr_visibility(void *data, int type) | ||
1977 | { | ||
1978 | int rc; | ||
1979 | |||
1980 | switch (type) { | ||
1981 | case ISCSI_BOOT_TGT_NAME: | ||
1982 | case ISCSI_BOOT_TGT_IP_ADDR: | ||
1983 | case ISCSI_BOOT_TGT_PORT: | ||
1984 | case ISCSI_BOOT_TGT_LUN: | ||
1985 | case ISCSI_BOOT_TGT_CHAP_NAME: | ||
1986 | case ISCSI_BOOT_TGT_CHAP_SECRET: | ||
1987 | case ISCSI_BOOT_TGT_REV_CHAP_NAME: | ||
1988 | case ISCSI_BOOT_TGT_REV_CHAP_SECRET: | ||
1989 | case ISCSI_BOOT_TGT_NIC_ASSOC: | ||
1990 | case ISCSI_BOOT_TGT_FLAGS: | ||
1991 | rc = 0444; | ||
1992 | break; | ||
1993 | default: | ||
1994 | rc = 0; | ||
1995 | break; | ||
1996 | } | ||
1997 | return rc; | ||
1998 | } | ||
1999 | |||
2000 | static void qedi_boot_release(void *data) | ||
2001 | { | ||
2002 | struct qedi_ctx *qedi = data; | ||
2003 | |||
2004 | scsi_host_put(qedi->shost); | ||
2005 | } | ||
2006 | |||
2007 | static int qedi_get_boot_info(struct qedi_ctx *qedi) | ||
2008 | { | ||
2009 | int ret = 1; | ||
2010 | u16 len; | ||
2011 | |||
2012 | len = sizeof(struct nvm_iscsi_cfg); | ||
2013 | |||
2014 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, | ||
2015 | "Get NVM iSCSI CFG image\n"); | ||
2016 | ret = qedi_ops->common->nvm_get_image(qedi->cdev, | ||
2017 | QED_NVM_IMAGE_ISCSI_CFG, | ||
2018 | (char *)qedi->iscsi_cfg, len); | ||
2019 | if (ret) | ||
2020 | QEDI_ERR(&qedi->dbg_ctx, | ||
2021 | "Could not get NVM image. ret = %d\n", ret); | ||
2022 | |||
2023 | return ret; | ||
2024 | } | ||
2025 | |||
2026 | static int qedi_setup_boot_info(struct qedi_ctx *qedi) | ||
2027 | { | ||
2028 | struct iscsi_boot_kobj *boot_kobj; | ||
2029 | |||
2030 | if (qedi_get_boot_info(qedi)) | ||
2031 | return -EPERM; | ||
2032 | |||
2033 | qedi->boot_kset = iscsi_boot_create_host_kset(qedi->shost->host_no); | ||
2034 | if (!qedi->boot_kset) | ||
2035 | goto kset_free; | ||
2036 | |||
2037 | if (!scsi_host_get(qedi->shost)) | ||
2038 | goto kset_free; | ||
2039 | |||
2040 | boot_kobj = iscsi_boot_create_target(qedi->boot_kset, 0, qedi, | ||
2041 | qedi_show_boot_tgt_pri_info, | ||
2042 | qedi_tgt_get_attr_visibility, | ||
2043 | qedi_boot_release); | ||
2044 | if (!boot_kobj) | ||
2045 | goto put_host; | ||
2046 | |||
2047 | if (!scsi_host_get(qedi->shost)) | ||
2048 | goto kset_free; | ||
2049 | |||
2050 | boot_kobj = iscsi_boot_create_target(qedi->boot_kset, 1, qedi, | ||
2051 | qedi_show_boot_tgt_sec_info, | ||
2052 | qedi_tgt_get_attr_visibility, | ||
2053 | qedi_boot_release); | ||
2054 | if (!boot_kobj) | ||
2055 | goto put_host; | ||
2056 | |||
2057 | if (!scsi_host_get(qedi->shost)) | ||
2058 | goto kset_free; | ||
2059 | |||
2060 | boot_kobj = iscsi_boot_create_initiator(qedi->boot_kset, 0, qedi, | ||
2061 | qedi_show_boot_ini_info, | ||
2062 | qedi_ini_get_attr_visibility, | ||
2063 | qedi_boot_release); | ||
2064 | if (!boot_kobj) | ||
2065 | goto put_host; | ||
2066 | |||
2067 | if (!scsi_host_get(qedi->shost)) | ||
2068 | goto kset_free; | ||
2069 | |||
2070 | boot_kobj = iscsi_boot_create_ethernet(qedi->boot_kset, 0, qedi, | ||
2071 | qedi_show_boot_eth_info, | ||
2072 | qedi_eth_get_attr_visibility, | ||
2073 | qedi_boot_release); | ||
2074 | if (!boot_kobj) | ||
2075 | goto put_host; | ||
2076 | |||
2077 | return 0; | ||
2078 | |||
2079 | put_host: | ||
2080 | scsi_host_put(qedi->shost); | ||
2081 | kset_free: | ||
2082 | iscsi_boot_destroy_kset(qedi->boot_kset); | ||
2083 | return -ENOMEM; | ||
2084 | } | ||
2085 | |||
1674 | static void __qedi_remove(struct pci_dev *pdev, int mode) | 2086 | static void __qedi_remove(struct pci_dev *pdev, int mode) |
1675 | { | 2087 | { |
1676 | struct qedi_ctx *qedi = pci_get_drvdata(pdev); | 2088 | struct qedi_ctx *qedi = pci_get_drvdata(pdev); |
@@ -1724,6 +2136,9 @@ static void __qedi_remove(struct pci_dev *pdev, int mode) | |||
1724 | qedi->ll2_recv_thread = NULL; | 2136 | qedi->ll2_recv_thread = NULL; |
1725 | } | 2137 | } |
1726 | qedi_ll2_free_skbs(qedi); | 2138 | qedi_ll2_free_skbs(qedi); |
2139 | |||
2140 | if (qedi->boot_kset) | ||
2141 | iscsi_boot_destroy_kset(qedi->boot_kset); | ||
1727 | } | 2142 | } |
1728 | } | 2143 | } |
1729 | 2144 | ||
@@ -1967,6 +2382,10 @@ static int __qedi_probe(struct pci_dev *pdev, int mode) | |||
1967 | /* F/w needs 1st task context memory entry for performance */ | 2382 | /* F/w needs 1st task context memory entry for performance */ |
1968 | set_bit(QEDI_RESERVE_TASK_ID, qedi->task_idx_map); | 2383 | set_bit(QEDI_RESERVE_TASK_ID, qedi->task_idx_map); |
1969 | atomic_set(&qedi->num_offloads, 0); | 2384 | atomic_set(&qedi->num_offloads, 0); |
2385 | |||
2386 | if (qedi_setup_boot_info(qedi)) | ||
2387 | QEDI_ERR(&qedi->dbg_ctx, | ||
2388 | "No iSCSI boot target configured\n"); | ||
1970 | } | 2389 | } |
1971 | 2390 | ||
1972 | return 0; | 2391 | return 0; |
diff --git a/drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h b/drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h new file mode 100644 index 000000000000..df39b69b366d --- /dev/null +++ b/drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h | |||
@@ -0,0 +1,210 @@ | |||
1 | /* | ||
2 | * QLogic iSCSI Offload Driver | ||
3 | * Copyright (c) 2016 Cavium Inc. | ||
4 | * | ||
5 | * This software is available under the terms of the GNU General Public License | ||
6 | * (GPL) Version 2, available from the file COPYING in the main directory of | ||
7 | * this source tree. | ||
8 | */ | ||
9 | |||
10 | #ifndef NVM_ISCSI_CFG_H | ||
11 | #define NVM_ISCSI_CFG_H | ||
12 | |||
13 | #define NUM_OF_ISCSI_TARGET_PER_PF 4 /* Defined as per the | ||
14 | * ISCSI IBFT constraint | ||
15 | */ | ||
16 | #define NUM_OF_ISCSI_PF_SUPPORTED 4 /* One PF per Port - | ||
17 | * assuming 4 port card | ||
18 | */ | ||
19 | |||
20 | #define NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN 256 | ||
21 | |||
22 | union nvm_iscsi_dhcp_vendor_id { | ||
23 | u32 value[NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN / 4]; | ||
24 | u8 byte[NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN]; | ||
25 | }; | ||
26 | |||
27 | #define NVM_ISCSI_IPV4_ADDR_BYTE_LEN 4 | ||
28 | union nvm_iscsi_ipv4_addr { | ||
29 | u32 addr; | ||
30 | u8 byte[NVM_ISCSI_IPV4_ADDR_BYTE_LEN]; | ||
31 | }; | ||
32 | |||
33 | #define NVM_ISCSI_IPV6_ADDR_BYTE_LEN 16 | ||
34 | union nvm_iscsi_ipv6_addr { | ||
35 | u32 addr[4]; | ||
36 | u8 byte[NVM_ISCSI_IPV6_ADDR_BYTE_LEN]; | ||
37 | }; | ||
38 | |||
39 | struct nvm_iscsi_initiator_ipv4 { | ||
40 | union nvm_iscsi_ipv4_addr addr; /* 0x0 */ | ||
41 | union nvm_iscsi_ipv4_addr subnet_mask; /* 0x4 */ | ||
42 | union nvm_iscsi_ipv4_addr gateway; /* 0x8 */ | ||
43 | union nvm_iscsi_ipv4_addr primary_dns; /* 0xC */ | ||
44 | union nvm_iscsi_ipv4_addr secondary_dns; /* 0x10 */ | ||
45 | union nvm_iscsi_ipv4_addr dhcp_addr; /* 0x14 */ | ||
46 | |||
47 | union nvm_iscsi_ipv4_addr isns_server; /* 0x18 */ | ||
48 | union nvm_iscsi_ipv4_addr slp_server; /* 0x1C */ | ||
49 | union nvm_iscsi_ipv4_addr primay_radius_server; /* 0x20 */ | ||
50 | union nvm_iscsi_ipv4_addr secondary_radius_server; /* 0x24 */ | ||
51 | |||
52 | union nvm_iscsi_ipv4_addr rsvd[4]; /* 0x28 */ | ||
53 | }; | ||
54 | |||
55 | struct nvm_iscsi_initiator_ipv6 { | ||
56 | union nvm_iscsi_ipv6_addr addr; /* 0x0 */ | ||
57 | union nvm_iscsi_ipv6_addr subnet_mask; /* 0x10 */ | ||
58 | union nvm_iscsi_ipv6_addr gateway; /* 0x20 */ | ||
59 | union nvm_iscsi_ipv6_addr primary_dns; /* 0x30 */ | ||
60 | union nvm_iscsi_ipv6_addr secondary_dns; /* 0x40 */ | ||
61 | union nvm_iscsi_ipv6_addr dhcp_addr; /* 0x50 */ | ||
62 | |||
63 | union nvm_iscsi_ipv6_addr isns_server; /* 0x60 */ | ||
64 | union nvm_iscsi_ipv6_addr slp_server; /* 0x70 */ | ||
65 | union nvm_iscsi_ipv6_addr primay_radius_server; /* 0x80 */ | ||
66 | union nvm_iscsi_ipv6_addr secondary_radius_server; /* 0x90 */ | ||
67 | |||
68 | union nvm_iscsi_ipv6_addr rsvd[3]; /* 0xA0 */ | ||
69 | |||
70 | u32 config; /* 0xD0 */ | ||
71 | #define NVM_ISCSI_CFG_INITIATOR_IPV6_SUBNET_MASK_PREFIX_MASK 0x000000FF | ||
72 | #define NVM_ISCSI_CFG_INITIATOR_IPV6_SUBNET_MASK_PREFIX_OFFSET 0 | ||
73 | |||
74 | u32 rsvd_1[3]; | ||
75 | }; | ||
76 | |||
77 | #define NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN 256 | ||
78 | union nvm_iscsi_name { | ||
79 | u32 value[NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN / 4]; | ||
80 | u8 byte[NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN]; | ||
81 | }; | ||
82 | |||
83 | #define NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN 256 | ||
84 | union nvm_iscsi_chap_name { | ||
85 | u32 value[NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN / 4]; | ||
86 | u8 byte[NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN]; | ||
87 | }; | ||
88 | |||
89 | #define NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN 16 /* md5 need per RFC1996 | ||
90 | * is 16 octets | ||
91 | */ | ||
92 | union nvm_iscsi_chap_password { | ||
93 | u32 value[NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN / 4]; | ||
94 | u8 byte[NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN]; | ||
95 | }; | ||
96 | |||
97 | union nvm_iscsi_lun { | ||
98 | u8 byte[8]; | ||
99 | u32 value[2]; | ||
100 | }; | ||
101 | |||
102 | struct nvm_iscsi_generic { | ||
103 | u32 ctrl_flags; /* 0x0 */ | ||
104 | #define NVM_ISCSI_CFG_GEN_CHAP_ENABLED BIT(0) | ||
105 | #define NVM_ISCSI_CFG_GEN_DHCP_TCPIP_CONFIG_ENABLED BIT(1) | ||
106 | #define NVM_ISCSI_CFG_GEN_DHCP_ISCSI_CONFIG_ENABLED BIT(2) | ||
107 | #define NVM_ISCSI_CFG_GEN_IPV6_ENABLED BIT(3) | ||
108 | #define NVM_ISCSI_CFG_GEN_IPV4_FALLBACK_ENABLED BIT(4) | ||
109 | #define NVM_ISCSI_CFG_GEN_ISNS_WORLD_LOGIN BIT(5) | ||
110 | #define NVM_ISCSI_CFG_GEN_ISNS_SELECTIVE_LOGIN BIT(6) | ||
111 | #define NVM_ISCSI_CFG_GEN_ADDR_REDIRECT_ENABLED BIT(7) | ||
112 | #define NVM_ISCSI_CFG_GEN_CHAP_MUTUAL_ENABLED BIT(8) | ||
113 | |||
114 | u32 timeout; /* 0x4 */ | ||
115 | #define NVM_ISCSI_CFG_GEN_DHCP_REQUEST_TIMEOUT_MASK 0x0000FFFF | ||
116 | #define NVM_ISCSI_CFG_GEN_DHCP_REQUEST_TIMEOUT_OFFSET 0 | ||
117 | #define NVM_ISCSI_CFG_GEN_PORT_LOGIN_TIMEOUT_MASK 0xFFFF0000 | ||
118 | #define NVM_ISCSI_CFG_GEN_PORT_LOGIN_TIMEOUT_OFFSET 16 | ||
119 | |||
120 | union nvm_iscsi_dhcp_vendor_id dhcp_vendor_id; /* 0x8 */ | ||
121 | u32 rsvd[62]; /* 0x108 */ | ||
122 | }; | ||
123 | |||
124 | struct nvm_iscsi_initiator { | ||
125 | struct nvm_iscsi_initiator_ipv4 ipv4; /* 0x0 */ | ||
126 | struct nvm_iscsi_initiator_ipv6 ipv6; /* 0x38 */ | ||
127 | |||
128 | union nvm_iscsi_name initiator_name; /* 0x118 */ | ||
129 | union nvm_iscsi_chap_name chap_name; /* 0x218 */ | ||
130 | union nvm_iscsi_chap_password chap_password; /* 0x318 */ | ||
131 | |||
132 | u32 generic_cont0; /* 0x398 */ | ||
133 | #define NVM_ISCSI_CFG_INITIATOR_VLAN_MASK 0x0000FFFF | ||
134 | #define NVM_ISCSI_CFG_INITIATOR_VLAN_OFFSET 0 | ||
135 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_MASK 0x00030000 | ||
136 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_OFFSET 16 | ||
137 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_4 1 | ||
138 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_6 2 | ||
139 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_4_AND_6 3 | ||
140 | |||
141 | u32 ctrl_flags; | ||
142 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_PRIORITY_V6 BIT(0) | ||
143 | #define NVM_ISCSI_CFG_INITIATOR_VLAN_ENABLED BIT(1) | ||
144 | |||
145 | u32 rsvd[116]; /* 0x32C */ | ||
146 | }; | ||
147 | |||
148 | struct nvm_iscsi_target { | ||
149 | u32 ctrl_flags; /* 0x0 */ | ||
150 | #define NVM_ISCSI_CFG_TARGET_ENABLED BIT(0) | ||
151 | #define NVM_ISCSI_CFG_BOOT_TIME_LOGIN_STATUS BIT(1) | ||
152 | |||
153 | u32 generic_cont0; /* 0x4 */ | ||
154 | #define NVM_ISCSI_CFG_TARGET_TCP_PORT_MASK 0x0000FFFF | ||
155 | #define NVM_ISCSI_CFG_TARGET_TCP_PORT_OFFSET 0 | ||
156 | |||
157 | u32 ip_ver; | ||
158 | #define NVM_ISCSI_CFG_IPv4 4 | ||
159 | #define NVM_ISCSI_CFG_IPv6 6 | ||
160 | |||
161 | u32 rsvd_1[7]; /* 0x24 */ | ||
162 | union nvm_iscsi_ipv4_addr ipv4_addr; /* 0x28 */ | ||
163 | union nvm_iscsi_ipv6_addr ipv6_addr; /* 0x2C */ | ||
164 | union nvm_iscsi_lun lun; /* 0x3C */ | ||
165 | |||
166 | union nvm_iscsi_name target_name; /* 0x44 */ | ||
167 | union nvm_iscsi_chap_name chap_name; /* 0x144 */ | ||
168 | union nvm_iscsi_chap_password chap_password; /* 0x244 */ | ||
169 | |||
170 | u32 rsvd_2[107]; /* 0x2C4 */ | ||
171 | }; | ||
172 | |||
173 | struct nvm_iscsi_block { | ||
174 | u32 id; /* 0x0 */ | ||
175 | #define NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_MASK 0x0000000F | ||
176 | #define NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_OFFSET 0 | ||
177 | #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK 0x00000FF0 | ||
178 | #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET 4 | ||
179 | #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_IS_NOT_EMPTY BIT(0) | ||
180 | #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_PF_MAPPED BIT(1) | ||
181 | |||
182 | u32 rsvd_1[5]; /* 0x4 */ | ||
183 | |||
184 | struct nvm_iscsi_generic generic; /* 0x18 */ | ||
185 | struct nvm_iscsi_initiator initiator; /* 0x218 */ | ||
186 | struct nvm_iscsi_target target[NUM_OF_ISCSI_TARGET_PER_PF]; | ||
187 | /* 0x718 */ | ||
188 | |||
189 | u32 rsvd_2[58]; /* 0x1718 */ | ||
190 | /* total size - 0x1800 - 6K block */ | ||
191 | }; | ||
192 | |||
193 | struct nvm_iscsi_cfg { | ||
194 | u32 id; /* 0x0 */ | ||
195 | #define NVM_ISCSI_CFG_BLK_VERSION_MINOR_MASK 0x000000FF | ||
196 | #define NVM_ISCSI_CFG_BLK_VERSION_MAJOR_MASK 0x0000FF00 | ||
197 | #define NVM_ISCSI_CFG_BLK_SIGNATURE_MASK 0xFFFF0000 | ||
198 | #define NVM_ISCSI_CFG_BLK_SIGNATURE 0x49430000 /* IC - Iscsi | ||
199 | * Config | ||
200 | */ | ||
201 | |||
202 | #define NVM_ISCSI_CFG_BLK_VERSION_MAJOR 0 | ||
203 | #define NVM_ISCSI_CFG_BLK_VERSION_MINOR 10 | ||
204 | #define NVM_ISCSI_CFG_BLK_VERSION ((NVM_ISCSI_CFG_BLK_VERSION_MAJOR << 8) | \ | ||
205 | NVM_ISCSI_CFG_BLK_VERSION_MINOR) | ||
206 | |||
207 | struct nvm_iscsi_block block[NUM_OF_ISCSI_PF_SUPPORTED]; /* 0x4 */ | ||
208 | }; | ||
209 | |||
210 | #endif | ||