Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
"This is actually just a small set of mainly bug fixes for the original
merge window code plus a few trivial updates and qedi boot from SAN
support feature patch"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
scsi: libfc: pass an error pointer to fc_disc_error()
scsi: hisi_sas: make several const arrays static
scsi: qla2xxx: Off by one in qlt_ctio_to_cmd()
scsi: sg: fix SG_DXFER_FROM_DEV transfers
scsi: virtio_scsi: always read VPD pages for multiqueue too
scsi: qedf: fix spelling mistake: "offlading" -> "offloading"
scsi: qedi: fix another spelling mistake: "alloction" -> "allocation"
scsi: isci: fix typo in function names
scsi: cxlflash: return -EFAULT if copy_from_user() fails
scsi: qedi: Add support for Boot from SAN over iSCSI offload

+674 -21
+7 -4
drivers/scsi/cxlflash/main.c
··· 3401 3401 if (is_write) { 3402 3402 req_flags |= SISL_REQ_FLAGS_HOST_WRITE; 3403 3403 3404 - rc = copy_from_user(kbuf, ubuf, ulen); 3405 - if (unlikely(rc)) 3404 + if (copy_from_user(kbuf, ubuf, ulen)) { 3405 + rc = -EFAULT; 3406 3406 goto out; 3407 + } 3407 3408 } 3408 3409 } 3409 3410 ··· 3432 3431 goto out; 3433 3432 } 3434 3433 3435 - if (ulen && !is_write) 3436 - rc = copy_to_user(ubuf, kbuf, ulen); 3434 + if (ulen && !is_write) { 3435 + if (copy_to_user(ubuf, kbuf, ulen)) 3436 + rc = -EFAULT; 3437 + } 3437 3438 out: 3438 3439 kfree(buf); 3439 3440 dev_dbg(dev, "%s: returning rc=%d\n", __func__, rc);
+5 -5
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
··· 1693 1693 1694 1694 static int parse_trans_tx_err_code_v2_hw(u32 err_msk) 1695 1695 { 1696 - const u8 trans_tx_err_code_prio[] = { 1696 + static const u8 trans_tx_err_code_prio[] = { 1697 1697 TRANS_TX_OPEN_FAIL_WITH_IT_NEXUS_LOSS, 1698 1698 TRANS_TX_ERR_PHY_NOT_ENABLE, 1699 1699 TRANS_TX_OPEN_CNX_ERR_WRONG_DESTINATION, ··· 1738 1738 1739 1739 static int parse_trans_rx_err_code_v2_hw(u32 err_msk) 1740 1740 { 1741 - const u8 trans_rx_err_code_prio[] = { 1741 + static const u8 trans_rx_err_code_prio[] = { 1742 1742 TRANS_RX_ERR_WITH_RXFRAME_CRC_ERR, 1743 1743 TRANS_RX_ERR_WITH_RXFIS_8B10B_DISP_ERR, 1744 1744 TRANS_RX_ERR_WITH_RXFRAME_HAVE_ERRPRM, ··· 1784 1784 1785 1785 static int parse_dma_tx_err_code_v2_hw(u32 err_msk) 1786 1786 { 1787 - const u8 dma_tx_err_code_prio[] = { 1787 + static const u8 dma_tx_err_code_prio[] = { 1788 1788 DMA_TX_UNEXP_XFER_ERR, 1789 1789 DMA_TX_UNEXP_RETRANS_ERR, 1790 1790 DMA_TX_XFER_LEN_OVERFLOW, ··· 1810 1810 1811 1811 static int parse_sipc_rx_err_code_v2_hw(u32 err_msk) 1812 1812 { 1813 - const u8 sipc_rx_err_code_prio[] = { 1813 + static const u8 sipc_rx_err_code_prio[] = { 1814 1814 SIPC_RX_FIS_STATUS_ERR_BIT_VLD, 1815 1815 SIPC_RX_PIO_WRSETUP_STATUS_DRQ_ERR, 1816 1816 SIPC_RX_FIS_STATUS_BSY_BIT_ERR, ··· 1836 1836 1837 1837 static int parse_dma_rx_err_code_v2_hw(u32 err_msk) 1838 1838 { 1839 - const u8 dma_rx_err_code_prio[] = { 1839 + static const u8 dma_rx_err_code_prio[] = { 1840 1840 DMA_RX_UNKNOWN_FRM_ERR, 1841 1841 DMA_RX_DATA_LEN_OVERFLOW, 1842 1842 DMA_RX_DATA_LEN_UNDERFLOW,
+7 -7
drivers/scsi/isci/request.c
··· 213 213 * @task_context: 214 214 * 215 215 */ 216 - static void scu_ssp_reqeust_construct_task_context( 216 + static void scu_ssp_request_construct_task_context( 217 217 struct isci_request *ireq, 218 218 struct scu_task_context *task_context) 219 219 { ··· 425 425 u8 prot_type = scsi_get_prot_type(scmd); 426 426 u8 prot_op = scsi_get_prot_op(scmd); 427 427 428 - scu_ssp_reqeust_construct_task_context(ireq, task_context); 428 + scu_ssp_request_construct_task_context(ireq, task_context); 429 429 430 430 task_context->ssp_command_iu_length = 431 431 sizeof(struct ssp_cmd_iu) / sizeof(u32); ··· 472 472 { 473 473 struct scu_task_context *task_context = ireq->tc; 474 474 475 - scu_ssp_reqeust_construct_task_context(ireq, task_context); 475 + scu_ssp_request_construct_task_context(ireq, task_context); 476 476 477 477 task_context->control_frame = 1; 478 478 task_context->priority = SCU_TASK_PRIORITY_HIGH; ··· 495 495 * the command buffer is complete. none Revisit task context construction to 496 496 * determine what is common for SSP/SMP/STP task context structures. 497 497 */ 498 - static void scu_sata_reqeust_construct_task_context( 498 + static void scu_sata_request_construct_task_context( 499 499 struct isci_request *ireq, 500 500 struct scu_task_context *task_context) 501 501 { ··· 562 562 { 563 563 struct scu_task_context *task_context = ireq->tc; 564 564 565 - scu_sata_reqeust_construct_task_context(ireq, task_context); 565 + scu_sata_request_construct_task_context(ireq, task_context); 566 566 567 567 task_context->control_frame = 0; 568 568 task_context->priority = SCU_TASK_PRIORITY_NORMAL; ··· 613 613 struct scu_task_context *task_context = ireq->tc; 614 614 615 615 /* Build the STP task context structure */ 616 - scu_sata_reqeust_construct_task_context(ireq, task_context); 616 + scu_sata_request_construct_task_context(ireq, task_context); 617 617 618 618 /* Copy over the SGL elements */ 619 619 sci_request_build_sgl(ireq); ··· 1401 1401 * @data_buffer: The buffer of data to be copied. 1402 1402 * @length: The length of the data transfer. 1403 1403 * 1404 - * Copy the data from the buffer for the length specified to the IO reqeust SGL 1404 + * Copy the data from the buffer for the length specified to the IO request SGL 1405 1405 * specified data region. enum sci_status 1406 1406 */ 1407 1407 static enum sci_status
+1 -1
drivers/scsi/libfc/fc_disc.c
··· 573 573 event = DISC_EV_FAILED; 574 574 } 575 575 if (error) 576 - fc_disc_error(disc, fp); 576 + fc_disc_error(disc, ERR_PTR(error)); 577 577 else if (event != DISC_EV_NONE) 578 578 fc_disc_done(disc, event); 579 579 fc_frame_free(fp);
+1 -1
drivers/scsi/qedf/qedf_main.c
··· 1227 1227 1228 1228 if (rdata->spp_type != FC_TYPE_FCP) { 1229 1229 QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, 1230 - "Not offlading since since spp type isn't FCP\n"); 1230 + "Not offloading since spp type isn't FCP\n"); 1231 1231 break; 1232 1232 } 1233 1233 if (!(rdata->ids.roles & FC_RPORT_ROLE_FCP_TARGET)) {
+17
drivers/scsi/qedi/qedi.h
··· 23 23 #include <linux/qed/qed_iscsi_if.h> 24 24 #include <linux/qed/qed_ll2_if.h> 25 25 #include "qedi_version.h" 26 + #include "qedi_nvm_iscsi_cfg.h" 26 27 27 28 #define QEDI_MODULE_NAME "qedi" 28 29 29 30 struct qedi_endpoint; 31 + 32 + #ifndef GET_FIELD2 33 + #define GET_FIELD2(value, name) \ 34 + (((value) & (name ## _MASK)) >> (name ## _OFFSET)) 35 + #endif 30 36 31 37 /* 32 38 * PCI function probe defines ··· 71 65 #define QEDI_PAGE_SIZE 4096 72 66 #define QEDI_HW_DMA_BOUNDARY 0xfff 73 67 #define QEDI_PATH_HANDLE 0xFE0000000UL 68 + 69 + enum qedi_nvm_tgts { 70 + QEDI_NVM_TGT_PRI, 71 + QEDI_NVM_TGT_SEC, 72 + }; 74 73 75 74 struct qedi_uio_ctrl { 76 75 /* meta data */ ··· 294 283 void *bdq_pbl_list; 295 284 dma_addr_t bdq_pbl_list_dma; 296 285 u8 bdq_pbl_list_num_entries; 286 + struct nvm_iscsi_cfg *iscsi_cfg; 287 + dma_addr_t nvm_buf_dma; 297 288 void __iomem *bdq_primary_prod; 298 289 void __iomem *bdq_secondary_prod; 299 290 u16 bdq_prod_idx; ··· 350 337 bool use_fast_sge; 351 338 352 339 atomic_t num_offloads; 340 + #define SYSFS_FLAG_FW_SEL_BOOT 2 341 + #define IPV6_LEN 41 342 + #define IPV4_LEN 17 343 + struct iscsi_boot_kset *boot_kset; 353 344 }; 354 345 355 346 struct qedi_work {
+1 -1
drivers/scsi/qedi/qedi_fw.c
··· 1411 1411 1412 1412 list_work = kzalloc(sizeof(*list_work), GFP_ATOMIC); 1413 1413 if (!list_work) { 1414 - QEDI_ERR(&qedi->dbg_ctx, "Memory alloction failed\n"); 1414 + QEDI_ERR(&qedi->dbg_ctx, "Memory allocation failed\n"); 1415 1415 goto abort_ret; 1416 1416 } 1417 1417
+419
drivers/scsi/qedi/qedi_main.c
··· 19 19 #include <linux/mm.h> 20 20 #include <linux/if_vlan.h> 21 21 #include <linux/cpu.h> 22 + #include <linux/iscsi_boot_sysfs.h> 22 23 23 24 #include <scsi/scsi_cmnd.h> 24 25 #include <scsi/scsi_device.h> ··· 1144 1143 return rc; 1145 1144 } 1146 1145 1146 + static void qedi_free_nvm_iscsi_cfg(struct qedi_ctx *qedi) 1147 + { 1148 + if (qedi->iscsi_cfg) 1149 + dma_free_coherent(&qedi->pdev->dev, 1150 + sizeof(struct nvm_iscsi_cfg), 1151 + qedi->iscsi_cfg, qedi->nvm_buf_dma); 1152 + } 1153 + 1154 + static int qedi_alloc_nvm_iscsi_cfg(struct qedi_ctx *qedi) 1155 + { 1156 + qedi->iscsi_cfg = dma_zalloc_coherent(&qedi->pdev->dev, 1157 + sizeof(struct nvm_iscsi_cfg), 1158 + &qedi->nvm_buf_dma, GFP_KERNEL); 1159 + if (!qedi->iscsi_cfg) { 1160 + QEDI_ERR(&qedi->dbg_ctx, "Could not allocate NVM BUF.\n"); 1161 + return -ENOMEM; 1162 + } 1163 + QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, 1164 + "NVM BUF addr=0x%p dma=0x%llx.\n", qedi->iscsi_cfg, 1165 + qedi->nvm_buf_dma); 1166 + 1167 + return 0; 1168 + } 1169 + 1147 1170 static void qedi_free_bdq(struct qedi_ctx *qedi) 1148 1171 { 1149 1172 int i; ··· 1208 1183 kfree(gl[i]); 1209 1184 } 1210 1185 qedi_free_bdq(qedi); 1186 + qedi_free_nvm_iscsi_cfg(qedi); 1211 1187 } 1212 1188 1213 1189 static int qedi_alloc_bdq(struct qedi_ctx *qedi) ··· 1332 1306 1333 1307 /* Allocate DMA coherent buffers for BDQ */ 1334 1308 rc = qedi_alloc_bdq(qedi); 1309 + if (rc) 1310 + goto mem_alloc_failure; 1311 + 1312 + /* Allocate DMA coherent buffers for NVM_ISCSI_CFG */ 1313 + rc = qedi_alloc_nvm_iscsi_cfg(qedi); 1335 1314 if (rc) 1336 1315 goto mem_alloc_failure; 1337 1316 ··· 1702 1671 qedi_ops->ll2->start(qedi->cdev, &params); 1703 1672 } 1704 1673 1674 + /** 1675 + * qedi_get_nvram_block: - Scan through the iSCSI NVRAM block (while accounting 1676 + * for gaps) for the matching absolute-pf-id of the QEDI device. 1677 + */ 1678 + static struct nvm_iscsi_block * 1679 + qedi_get_nvram_block(struct qedi_ctx *qedi) 1680 + { 1681 + int i; 1682 + u8 pf; 1683 + u32 flags; 1684 + struct nvm_iscsi_block *block; 1685 + 1686 + pf = qedi->dev_info.common.abs_pf_id; 1687 + block = &qedi->iscsi_cfg->block[0]; 1688 + for (i = 0; i < NUM_OF_ISCSI_PF_SUPPORTED; i++, block++) { 1689 + flags = ((block->id) & NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK) >> 1690 + NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET; 1691 + if (flags & (NVM_ISCSI_CFG_BLK_CTRL_FLAG_IS_NOT_EMPTY | 1692 + NVM_ISCSI_CFG_BLK_CTRL_FLAG_PF_MAPPED) && 1693 + (pf == (block->id & NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_MASK) 1694 + >> NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_OFFSET)) 1695 + return block; 1696 + } 1697 + return NULL; 1698 + } 1699 + 1700 + static ssize_t qedi_show_boot_eth_info(void *data, int type, char *buf) 1701 + { 1702 + struct qedi_ctx *qedi = data; 1703 + struct nvm_iscsi_initiator *initiator; 1704 + char *str = buf; 1705 + int rc = 1; 1706 + u32 ipv6_en, dhcp_en, ip_len; 1707 + struct nvm_iscsi_block *block; 1708 + char *fmt, *ip, *sub, *gw; 1709 + 1710 + block = qedi_get_nvram_block(qedi); 1711 + if (!block) 1712 + return 0; 1713 + 1714 + initiator = &block->initiator; 1715 + ipv6_en = block->generic.ctrl_flags & 1716 + NVM_ISCSI_CFG_GEN_IPV6_ENABLED; 1717 + dhcp_en = block->generic.ctrl_flags & 1718 + NVM_ISCSI_CFG_GEN_DHCP_TCPIP_CONFIG_ENABLED; 1719 + /* Static IP assignments. */ 1720 + fmt = ipv6_en ? "%pI6\n" : "%pI4\n"; 1721 + ip = ipv6_en ? initiator->ipv6.addr.byte : initiator->ipv4.addr.byte; 1722 + ip_len = ipv6_en ? IPV6_LEN : IPV4_LEN; 1723 + sub = ipv6_en ? initiator->ipv6.subnet_mask.byte : 1724 + initiator->ipv4.subnet_mask.byte; 1725 + gw = ipv6_en ? initiator->ipv6.gateway.byte : 1726 + initiator->ipv4.gateway.byte; 1727 + /* DHCP IP adjustments. */ 1728 + fmt = dhcp_en ? "%s\n" : fmt; 1729 + if (dhcp_en) { 1730 + ip = ipv6_en ? "0::0" : "0.0.0.0"; 1731 + sub = ip; 1732 + gw = ip; 1733 + ip_len = ipv6_en ? 5 : 8; 1734 + } 1735 + 1736 + switch (type) { 1737 + case ISCSI_BOOT_ETH_IP_ADDR: 1738 + rc = snprintf(str, ip_len, fmt, ip); 1739 + break; 1740 + case ISCSI_BOOT_ETH_SUBNET_MASK: 1741 + rc = snprintf(str, ip_len, fmt, sub); 1742 + break; 1743 + case ISCSI_BOOT_ETH_GATEWAY: 1744 + rc = snprintf(str, ip_len, fmt, gw); 1745 + break; 1746 + case ISCSI_BOOT_ETH_FLAGS: 1747 + rc = snprintf(str, 3, "%hhd\n", 1748 + SYSFS_FLAG_FW_SEL_BOOT); 1749 + break; 1750 + case ISCSI_BOOT_ETH_INDEX: 1751 + rc = snprintf(str, 3, "0\n"); 1752 + break; 1753 + case ISCSI_BOOT_ETH_MAC: 1754 + rc = sysfs_format_mac(str, qedi->mac, ETH_ALEN); 1755 + break; 1756 + case ISCSI_BOOT_ETH_VLAN: 1757 + rc = snprintf(str, 12, "%d\n", 1758 + GET_FIELD2(initiator->generic_cont0, 1759 + NVM_ISCSI_CFG_INITIATOR_VLAN)); 1760 + break; 1761 + case ISCSI_BOOT_ETH_ORIGIN: 1762 + if (dhcp_en) 1763 + rc = snprintf(str, 3, "3\n"); 1764 + break; 1765 + default: 1766 + rc = 0; 1767 + break; 1768 + } 1769 + 1770 + return rc; 1771 + } 1772 + 1773 + static umode_t qedi_eth_get_attr_visibility(void *data, int type) 1774 + { 1775 + int rc = 1; 1776 + 1777 + switch (type) { 1778 + case ISCSI_BOOT_ETH_FLAGS: 1779 + case ISCSI_BOOT_ETH_MAC: 1780 + case ISCSI_BOOT_ETH_INDEX: 1781 + case ISCSI_BOOT_ETH_IP_ADDR: 1782 + case ISCSI_BOOT_ETH_SUBNET_MASK: 1783 + case ISCSI_BOOT_ETH_GATEWAY: 1784 + case ISCSI_BOOT_ETH_ORIGIN: 1785 + case ISCSI_BOOT_ETH_VLAN: 1786 + rc = 0444; 1787 + break; 1788 + default: 1789 + rc = 0; 1790 + break; 1791 + } 1792 + return rc; 1793 + } 1794 + 1795 + static ssize_t qedi_show_boot_ini_info(void *data, int type, char *buf) 1796 + { 1797 + struct qedi_ctx *qedi = data; 1798 + struct nvm_iscsi_initiator *initiator; 1799 + char *str = buf; 1800 + int rc; 1801 + struct nvm_iscsi_block *block; 1802 + 1803 + block = qedi_get_nvram_block(qedi); 1804 + if (!block) 1805 + return 0; 1806 + 1807 + initiator = &block->initiator; 1808 + 1809 + switch (type) { 1810 + case ISCSI_BOOT_INI_INITIATOR_NAME: 1811 + rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", 1812 + initiator->initiator_name.byte); 1813 + break; 1814 + default: 1815 + rc = 0; 1816 + break; 1817 + } 1818 + return rc; 1819 + } 1820 + 1821 + static umode_t qedi_ini_get_attr_visibility(void *data, int type) 1822 + { 1823 + int rc; 1824 + 1825 + switch (type) { 1826 + case ISCSI_BOOT_INI_INITIATOR_NAME: 1827 + rc = 0444; 1828 + break; 1829 + default: 1830 + rc = 0; 1831 + break; 1832 + } 1833 + return rc; 1834 + } 1835 + 1836 + static ssize_t 1837 + qedi_show_boot_tgt_info(struct qedi_ctx *qedi, int type, 1838 + char *buf, enum qedi_nvm_tgts idx) 1839 + { 1840 + char *str = buf; 1841 + int rc = 1; 1842 + u32 ctrl_flags, ipv6_en, chap_en, mchap_en, ip_len; 1843 + struct nvm_iscsi_block *block; 1844 + char *chap_name, *chap_secret; 1845 + char *mchap_name, *mchap_secret; 1846 + 1847 + block = qedi_get_nvram_block(qedi); 1848 + if (!block) 1849 + goto exit_show_tgt_info; 1850 + 1851 + QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_EVT, 1852 + "Port:%d, tgt_idx:%d\n", 1853 + GET_FIELD2(block->id, NVM_ISCSI_CFG_BLK_MAPPED_PF_ID), idx); 1854 + 1855 + ctrl_flags = block->target[idx].ctrl_flags & 1856 + NVM_ISCSI_CFG_TARGET_ENABLED; 1857 + 1858 + if (!ctrl_flags) { 1859 + QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_EVT, 1860 + "Target disabled\n"); 1861 + goto exit_show_tgt_info; 1862 + } 1863 + 1864 + ipv6_en = block->generic.ctrl_flags & 1865 + NVM_ISCSI_CFG_GEN_IPV6_ENABLED; 1866 + ip_len = ipv6_en ? IPV6_LEN : IPV4_LEN; 1867 + chap_en = block->generic.ctrl_flags & 1868 + NVM_ISCSI_CFG_GEN_CHAP_ENABLED; 1869 + chap_name = chap_en ? block->initiator.chap_name.byte : NULL; 1870 + chap_secret = chap_en ? block->initiator.chap_password.byte : NULL; 1871 + 1872 + mchap_en = block->generic.ctrl_flags & 1873 + NVM_ISCSI_CFG_GEN_CHAP_MUTUAL_ENABLED; 1874 + mchap_name = mchap_en ? block->target[idx].chap_name.byte : NULL; 1875 + mchap_secret = mchap_en ? block->target[idx].chap_password.byte : NULL; 1876 + 1877 + switch (type) { 1878 + case ISCSI_BOOT_TGT_NAME: 1879 + rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", 1880 + block->target[idx].target_name.byte); 1881 + break; 1882 + case ISCSI_BOOT_TGT_IP_ADDR: 1883 + if (ipv6_en) 1884 + rc = snprintf(str, ip_len, "%pI6\n", 1885 + block->target[idx].ipv6_addr.byte); 1886 + else 1887 + rc = snprintf(str, ip_len, "%pI4\n", 1888 + block->target[idx].ipv4_addr.byte); 1889 + break; 1890 + case ISCSI_BOOT_TGT_PORT: 1891 + rc = snprintf(str, 12, "%d\n", 1892 + GET_FIELD2(block->target[idx].generic_cont0, 1893 + NVM_ISCSI_CFG_TARGET_TCP_PORT)); 1894 + break; 1895 + case ISCSI_BOOT_TGT_LUN: 1896 + rc = snprintf(str, 22, "%.*d\n", 1897 + block->target[idx].lun.value[1], 1898 + block->target[idx].lun.value[0]); 1899 + break; 1900 + case ISCSI_BOOT_TGT_CHAP_NAME: 1901 + rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", 1902 + chap_name); 1903 + break; 1904 + case ISCSI_BOOT_TGT_CHAP_SECRET: 1905 + rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", 1906 + chap_secret); 1907 + break; 1908 + case ISCSI_BOOT_TGT_REV_CHAP_NAME: 1909 + rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", 1910 + mchap_name); 1911 + break; 1912 + case ISCSI_BOOT_TGT_REV_CHAP_SECRET: 1913 + rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", 1914 + mchap_secret); 1915 + break; 1916 + case ISCSI_BOOT_TGT_FLAGS: 1917 + rc = snprintf(str, 3, "%hhd\n", SYSFS_FLAG_FW_SEL_BOOT); 1918 + break; 1919 + case ISCSI_BOOT_TGT_NIC_ASSOC: 1920 + rc = snprintf(str, 3, "0\n"); 1921 + break; 1922 + default: 1923 + rc = 0; 1924 + break; 1925 + } 1926 + 1927 + exit_show_tgt_info: 1928 + return rc; 1929 + } 1930 + 1931 + static ssize_t qedi_show_boot_tgt_pri_info(void *data, int type, char *buf) 1932 + { 1933 + struct qedi_ctx *qedi = data; 1934 + 1935 + return qedi_show_boot_tgt_info(qedi, type, buf, QEDI_NVM_TGT_PRI); 1936 + } 1937 + 1938 + static ssize_t qedi_show_boot_tgt_sec_info(void *data, int type, char *buf) 1939 + { 1940 + struct qedi_ctx *qedi = data; 1941 + 1942 + return qedi_show_boot_tgt_info(qedi, type, buf, QEDI_NVM_TGT_SEC); 1943 + } 1944 + 1945 + static umode_t qedi_tgt_get_attr_visibility(void *data, int type) 1946 + { 1947 + int rc; 1948 + 1949 + switch (type) { 1950 + case ISCSI_BOOT_TGT_NAME: 1951 + case ISCSI_BOOT_TGT_IP_ADDR: 1952 + case ISCSI_BOOT_TGT_PORT: 1953 + case ISCSI_BOOT_TGT_LUN: 1954 + case ISCSI_BOOT_TGT_CHAP_NAME: 1955 + case ISCSI_BOOT_TGT_CHAP_SECRET: 1956 + case ISCSI_BOOT_TGT_REV_CHAP_NAME: 1957 + case ISCSI_BOOT_TGT_REV_CHAP_SECRET: 1958 + case ISCSI_BOOT_TGT_NIC_ASSOC: 1959 + case ISCSI_BOOT_TGT_FLAGS: 1960 + rc = 0444; 1961 + break; 1962 + default: 1963 + rc = 0; 1964 + break; 1965 + } 1966 + return rc; 1967 + } 1968 + 1969 + static void qedi_boot_release(void *data) 1970 + { 1971 + struct qedi_ctx *qedi = data; 1972 + 1973 + scsi_host_put(qedi->shost); 1974 + } 1975 + 1976 + static int qedi_get_boot_info(struct qedi_ctx *qedi) 1977 + { 1978 + int ret = 1; 1979 + u16 len; 1980 + 1981 + len = sizeof(struct nvm_iscsi_cfg); 1982 + 1983 + QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, 1984 + "Get NVM iSCSI CFG image\n"); 1985 + ret = qedi_ops->common->nvm_get_image(qedi->cdev, 1986 + QED_NVM_IMAGE_ISCSI_CFG, 1987 + (char *)qedi->iscsi_cfg, len); 1988 + if (ret) 1989 + QEDI_ERR(&qedi->dbg_ctx, 1990 + "Could not get NVM image. ret = %d\n", ret); 1991 + 1992 + return ret; 1993 + } 1994 + 1995 + static int qedi_setup_boot_info(struct qedi_ctx *qedi) 1996 + { 1997 + struct iscsi_boot_kobj *boot_kobj; 1998 + 1999 + if (qedi_get_boot_info(qedi)) 2000 + return -EPERM; 2001 + 2002 + qedi->boot_kset = iscsi_boot_create_host_kset(qedi->shost->host_no); 2003 + if (!qedi->boot_kset) 2004 + goto kset_free; 2005 + 2006 + if (!scsi_host_get(qedi->shost)) 2007 + goto kset_free; 2008 + 2009 + boot_kobj = iscsi_boot_create_target(qedi->boot_kset, 0, qedi, 2010 + qedi_show_boot_tgt_pri_info, 2011 + qedi_tgt_get_attr_visibility, 2012 + qedi_boot_release); 2013 + if (!boot_kobj) 2014 + goto put_host; 2015 + 2016 + if (!scsi_host_get(qedi->shost)) 2017 + goto kset_free; 2018 + 2019 + boot_kobj = iscsi_boot_create_target(qedi->boot_kset, 1, qedi, 2020 + qedi_show_boot_tgt_sec_info, 2021 + qedi_tgt_get_attr_visibility, 2022 + qedi_boot_release); 2023 + if (!boot_kobj) 2024 + goto put_host; 2025 + 2026 + if (!scsi_host_get(qedi->shost)) 2027 + goto kset_free; 2028 + 2029 + boot_kobj = iscsi_boot_create_initiator(qedi->boot_kset, 0, qedi, 2030 + qedi_show_boot_ini_info, 2031 + qedi_ini_get_attr_visibility, 2032 + qedi_boot_release); 2033 + if (!boot_kobj) 2034 + goto put_host; 2035 + 2036 + if (!scsi_host_get(qedi->shost)) 2037 + goto kset_free; 2038 + 2039 + boot_kobj = iscsi_boot_create_ethernet(qedi->boot_kset, 0, qedi, 2040 + qedi_show_boot_eth_info, 2041 + qedi_eth_get_attr_visibility, 2042 + qedi_boot_release); 2043 + if (!boot_kobj) 2044 + goto put_host; 2045 + 2046 + return 0; 2047 + 2048 + put_host: 2049 + scsi_host_put(qedi->shost); 2050 + kset_free: 2051 + iscsi_boot_destroy_kset(qedi->boot_kset); 2052 + return -ENOMEM; 2053 + } 2054 + 1705 2055 static void __qedi_remove(struct pci_dev *pdev, int mode) 1706 2056 { 1707 2057 struct qedi_ctx *qedi = pci_get_drvdata(pdev); ··· 2136 1724 qedi->ll2_recv_thread = NULL; 2137 1725 } 2138 1726 qedi_ll2_free_skbs(qedi); 1727 + 1728 + if (qedi->boot_kset) 1729 + iscsi_boot_destroy_kset(qedi->boot_kset); 2139 1730 } 2140 1731 } 2141 1732 ··· 2382 1967 /* F/w needs 1st task context memory entry for performance */ 2383 1968 set_bit(QEDI_RESERVE_TASK_ID, qedi->task_idx_map); 2384 1969 atomic_set(&qedi->num_offloads, 0); 1970 + 1971 + if (qedi_setup_boot_info(qedi)) 1972 + QEDI_ERR(&qedi->dbg_ctx, 1973 + "No iSCSI boot target configured\n"); 2385 1974 } 2386 1975 2387 1976 return 0;
+210
drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h
··· 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
+1 -1
drivers/scsi/qla2xxx/qla_target.c
··· 3727 3727 h &= QLA_CMD_HANDLE_MASK; 3728 3728 3729 3729 if (h != QLA_TGT_NULL_HANDLE) { 3730 - if (unlikely(h > req->num_outstanding_cmds)) { 3730 + if (unlikely(h >= req->num_outstanding_cmds)) { 3731 3731 ql_dbg(ql_dbg_tgt, vha, 0xe052, 3732 3732 "qla_target(%d): Wrong handle %x received\n", 3733 3733 vha->vp_idx, handle);
+4 -1
drivers/scsi/sg.c
··· 758 758 if (hp->dxferp || hp->dxfer_len > 0) 759 759 return false; 760 760 return true; 761 - case SG_DXFER_TO_DEV: 762 761 case SG_DXFER_FROM_DEV: 762 + if (hp->dxfer_len < 0) 763 + return false; 764 + return true; 765 + case SG_DXFER_TO_DEV: 763 766 case SG_DXFER_TO_FROM_DEV: 764 767 if (!hp->dxferp || hp->dxfer_len == 0) 765 768 return false;
+1
drivers/scsi/virtio_scsi.c
··· 837 837 .eh_abort_handler = virtscsi_abort, 838 838 .eh_device_reset_handler = virtscsi_device_reset, 839 839 .eh_timed_out = virtscsi_eh_timed_out, 840 + .slave_alloc = virtscsi_device_alloc, 840 841 841 842 .can_queue = 1024, 842 843 .dma_boundary = UINT_MAX,