diff options
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/cxlflash/main.c | 11 | ||||
-rw-r--r-- | drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 10 | ||||
-rw-r--r-- | drivers/scsi/isci/request.c | 14 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_disc.c | 2 | ||||
-rw-r--r-- | drivers/scsi/qedf/qedf_main.c | 2 | ||||
-rw-r--r-- | drivers/scsi/qedi/qedi.h | 17 | ||||
-rw-r--r-- | drivers/scsi/qedi/qedi_fw.c | 2 | ||||
-rw-r--r-- | drivers/scsi/qedi/qedi_main.c | 419 | ||||
-rw-r--r-- | drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h | 210 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_target.c | 2 | ||||
-rw-r--r-- | drivers/scsi/sg.c | 5 | ||||
-rw-r--r-- | drivers/scsi/virtio_scsi.c | 1 |
12 files changed, 674 insertions, 21 deletions
diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 077f62e208aa..6a4367cc9caa 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c | |||
@@ -3401,9 +3401,10 @@ static int cxlflash_afu_debug(struct cxlflash_cfg *cfg, | |||
3401 | if (is_write) { | 3401 | if (is_write) { |
3402 | req_flags |= SISL_REQ_FLAGS_HOST_WRITE; | 3402 | req_flags |= SISL_REQ_FLAGS_HOST_WRITE; |
3403 | 3403 | ||
3404 | rc = copy_from_user(kbuf, ubuf, ulen); | 3404 | if (copy_from_user(kbuf, ubuf, ulen)) { |
3405 | if (unlikely(rc)) | 3405 | rc = -EFAULT; |
3406 | goto out; | 3406 | goto out; |
3407 | } | ||
3407 | } | 3408 | } |
3408 | } | 3409 | } |
3409 | 3410 | ||
@@ -3431,8 +3432,10 @@ static int cxlflash_afu_debug(struct cxlflash_cfg *cfg, | |||
3431 | goto out; | 3432 | goto out; |
3432 | } | 3433 | } |
3433 | 3434 | ||
3434 | if (ulen && !is_write) | 3435 | if (ulen && !is_write) { |
3435 | rc = copy_to_user(ubuf, kbuf, ulen); | 3436 | if (copy_to_user(ubuf, kbuf, ulen)) |
3437 | rc = -EFAULT; | ||
3438 | } | ||
3436 | out: | 3439 | out: |
3437 | kfree(buf); | 3440 | kfree(buf); |
3438 | dev_dbg(dev, "%s: returning rc=%d\n", __func__, rc); | 3441 | dev_dbg(dev, "%s: returning rc=%d\n", __func__, rc); |
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 551d103c27f1..2bfea7082e3a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | |||
@@ -1693,7 +1693,7 @@ static int prep_ssp_v2_hw(struct hisi_hba *hisi_hba, | |||
1693 | 1693 | ||
1694 | static int parse_trans_tx_err_code_v2_hw(u32 err_msk) | 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 | TRANS_TX_OPEN_FAIL_WITH_IT_NEXUS_LOSS, | 1697 | TRANS_TX_OPEN_FAIL_WITH_IT_NEXUS_LOSS, |
1698 | TRANS_TX_ERR_PHY_NOT_ENABLE, | 1698 | TRANS_TX_ERR_PHY_NOT_ENABLE, |
1699 | TRANS_TX_OPEN_CNX_ERR_WRONG_DESTINATION, | 1699 | TRANS_TX_OPEN_CNX_ERR_WRONG_DESTINATION, |
@@ -1738,7 +1738,7 @@ static int parse_trans_tx_err_code_v2_hw(u32 err_msk) | |||
1738 | 1738 | ||
1739 | static int parse_trans_rx_err_code_v2_hw(u32 err_msk) | 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 | TRANS_RX_ERR_WITH_RXFRAME_CRC_ERR, | 1742 | TRANS_RX_ERR_WITH_RXFRAME_CRC_ERR, |
1743 | TRANS_RX_ERR_WITH_RXFIS_8B10B_DISP_ERR, | 1743 | TRANS_RX_ERR_WITH_RXFIS_8B10B_DISP_ERR, |
1744 | TRANS_RX_ERR_WITH_RXFRAME_HAVE_ERRPRM, | 1744 | TRANS_RX_ERR_WITH_RXFRAME_HAVE_ERRPRM, |
@@ -1784,7 +1784,7 @@ static int parse_trans_rx_err_code_v2_hw(u32 err_msk) | |||
1784 | 1784 | ||
1785 | static int parse_dma_tx_err_code_v2_hw(u32 err_msk) | 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 | DMA_TX_UNEXP_XFER_ERR, | 1788 | DMA_TX_UNEXP_XFER_ERR, |
1789 | DMA_TX_UNEXP_RETRANS_ERR, | 1789 | DMA_TX_UNEXP_RETRANS_ERR, |
1790 | DMA_TX_XFER_LEN_OVERFLOW, | 1790 | DMA_TX_XFER_LEN_OVERFLOW, |
@@ -1810,7 +1810,7 @@ static int parse_dma_tx_err_code_v2_hw(u32 err_msk) | |||
1810 | 1810 | ||
1811 | static int parse_sipc_rx_err_code_v2_hw(u32 err_msk) | 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 | SIPC_RX_FIS_STATUS_ERR_BIT_VLD, | 1814 | SIPC_RX_FIS_STATUS_ERR_BIT_VLD, |
1815 | SIPC_RX_PIO_WRSETUP_STATUS_DRQ_ERR, | 1815 | SIPC_RX_PIO_WRSETUP_STATUS_DRQ_ERR, |
1816 | SIPC_RX_FIS_STATUS_BSY_BIT_ERR, | 1816 | SIPC_RX_FIS_STATUS_BSY_BIT_ERR, |
@@ -1836,7 +1836,7 @@ static int parse_sipc_rx_err_code_v2_hw(u32 err_msk) | |||
1836 | 1836 | ||
1837 | static int parse_dma_rx_err_code_v2_hw(u32 err_msk) | 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 | DMA_RX_UNKNOWN_FRM_ERR, | 1840 | DMA_RX_UNKNOWN_FRM_ERR, |
1841 | DMA_RX_DATA_LEN_OVERFLOW, | 1841 | DMA_RX_DATA_LEN_OVERFLOW, |
1842 | DMA_RX_DATA_LEN_UNDERFLOW, | 1842 | DMA_RX_DATA_LEN_UNDERFLOW, |
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c index 47f66e949745..ed197bc8e801 100644 --- a/drivers/scsi/isci/request.c +++ b/drivers/scsi/isci/request.c | |||
@@ -213,7 +213,7 @@ static void sci_task_request_build_ssp_task_iu(struct isci_request *ireq) | |||
213 | * @task_context: | 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 | struct isci_request *ireq, | 217 | struct isci_request *ireq, |
218 | struct scu_task_context *task_context) | 218 | struct scu_task_context *task_context) |
219 | { | 219 | { |
@@ -425,7 +425,7 @@ static void scu_ssp_io_request_construct_task_context(struct isci_request *ireq, | |||
425 | u8 prot_type = scsi_get_prot_type(scmd); | 425 | u8 prot_type = scsi_get_prot_type(scmd); |
426 | u8 prot_op = scsi_get_prot_op(scmd); | 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 | task_context->ssp_command_iu_length = | 430 | task_context->ssp_command_iu_length = |
431 | sizeof(struct ssp_cmd_iu) / sizeof(u32); | 431 | sizeof(struct ssp_cmd_iu) / sizeof(u32); |
@@ -472,7 +472,7 @@ static void scu_ssp_task_request_construct_task_context(struct isci_request *ire | |||
472 | { | 472 | { |
473 | struct scu_task_context *task_context = ireq->tc; | 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 | task_context->control_frame = 1; | 477 | task_context->control_frame = 1; |
478 | task_context->priority = SCU_TASK_PRIORITY_HIGH; | 478 | task_context->priority = SCU_TASK_PRIORITY_HIGH; |
@@ -495,7 +495,7 @@ static void scu_ssp_task_request_construct_task_context(struct isci_request *ire | |||
495 | * the command buffer is complete. none Revisit task context construction to | 495 | * the command buffer is complete. none Revisit task context construction to |
496 | * determine what is common for SSP/SMP/STP task context structures. | 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 | struct isci_request *ireq, | 499 | struct isci_request *ireq, |
500 | struct scu_task_context *task_context) | 500 | struct scu_task_context *task_context) |
501 | { | 501 | { |
@@ -562,7 +562,7 @@ static void scu_stp_raw_request_construct_task_context(struct isci_request *ireq | |||
562 | { | 562 | { |
563 | struct scu_task_context *task_context = ireq->tc; | 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 | task_context->control_frame = 0; | 567 | task_context->control_frame = 0; |
568 | task_context->priority = SCU_TASK_PRIORITY_NORMAL; | 568 | task_context->priority = SCU_TASK_PRIORITY_NORMAL; |
@@ -613,7 +613,7 @@ static void sci_stp_optimized_request_construct(struct isci_request *ireq, | |||
613 | struct scu_task_context *task_context = ireq->tc; | 613 | struct scu_task_context *task_context = ireq->tc; |
614 | 614 | ||
615 | /* Build the STP task context structure */ | 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 | /* Copy over the SGL elements */ | 618 | /* Copy over the SGL elements */ |
619 | sci_request_build_sgl(ireq); | 619 | sci_request_build_sgl(ireq); |
@@ -1401,7 +1401,7 @@ static enum sci_status sci_stp_request_pio_data_out_transmit_data(struct isci_re | |||
1401 | * @data_buffer: The buffer of data to be copied. | 1401 | * @data_buffer: The buffer of data to be copied. |
1402 | * @length: The length of the data transfer. | 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 | * specified data region. enum sci_status | 1405 | * specified data region. enum sci_status |
1406 | */ | 1406 | */ |
1407 | static enum sci_status | 1407 | static enum sci_status |
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c index fd501f8dbb11..8660f923ace0 100644 --- a/drivers/scsi/libfc/fc_disc.c +++ b/drivers/scsi/libfc/fc_disc.c | |||
@@ -573,7 +573,7 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
573 | event = DISC_EV_FAILED; | 573 | event = DISC_EV_FAILED; |
574 | } | 574 | } |
575 | if (error) | 575 | if (error) |
576 | fc_disc_error(disc, fp); | 576 | fc_disc_error(disc, ERR_PTR(error)); |
577 | else if (event != DISC_EV_NONE) | 577 | else if (event != DISC_EV_NONE) |
578 | fc_disc_done(disc, event); | 578 | fc_disc_done(disc, event); |
579 | fc_frame_free(fp); | 579 | fc_frame_free(fp); |
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index b58bba4604e8..7786c97e033f 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c | |||
@@ -1227,7 +1227,7 @@ static void qedf_rport_event_handler(struct fc_lport *lport, | |||
1227 | 1227 | ||
1228 | if (rdata->spp_type != FC_TYPE_FCP) { | 1228 | if (rdata->spp_type != FC_TYPE_FCP) { |
1229 | QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, | 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 | break; | 1231 | break; |
1232 | } | 1232 | } |
1233 | if (!(rdata->ids.roles & FC_RPORT_ROLE_FCP_TARGET)) { | 1233 | if (!(rdata->ids.roles & FC_RPORT_ROLE_FCP_TARGET)) { |
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_fw.c b/drivers/scsi/qedi/qedi_fw.c index 19254bd739d9..93d54acd4a22 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c | |||
@@ -1411,7 +1411,7 @@ static void qedi_tmf_work(struct work_struct *work) | |||
1411 | 1411 | ||
1412 | list_work = kzalloc(sizeof(*list_work), GFP_ATOMIC); | 1412 | list_work = kzalloc(sizeof(*list_work), GFP_ATOMIC); |
1413 | if (!list_work) { | 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 | goto abort_ret; | 1415 | goto abort_ret; |
1416 | } | 1416 | } |
1417 | 1417 | ||
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 | ||
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index c2dc836dc484..e101cd3043b9 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c | |||
@@ -3727,7 +3727,7 @@ static struct qla_tgt_cmd *qlt_ctio_to_cmd(struct scsi_qla_host *vha, | |||
3727 | h &= QLA_CMD_HANDLE_MASK; | 3727 | h &= QLA_CMD_HANDLE_MASK; |
3728 | 3728 | ||
3729 | if (h != QLA_TGT_NULL_HANDLE) { | 3729 | if (h != QLA_TGT_NULL_HANDLE) { |
3730 | if (unlikely(h > req->num_outstanding_cmds)) { | 3730 | if (unlikely(h >= req->num_outstanding_cmds)) { |
3731 | ql_dbg(ql_dbg_tgt, vha, 0xe052, | 3731 | ql_dbg(ql_dbg_tgt, vha, 0xe052, |
3732 | "qla_target(%d): Wrong handle %x received\n", | 3732 | "qla_target(%d): Wrong handle %x received\n", |
3733 | vha->vp_idx, handle); | 3733 | vha->vp_idx, handle); |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 21225d62b0c1..1e82d4128a84 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -758,8 +758,11 @@ static bool sg_is_valid_dxfer(sg_io_hdr_t *hp) | |||
758 | if (hp->dxferp || hp->dxfer_len > 0) | 758 | if (hp->dxferp || hp->dxfer_len > 0) |
759 | return false; | 759 | return false; |
760 | return true; | 760 | return true; |
761 | case SG_DXFER_TO_DEV: | ||
762 | case SG_DXFER_FROM_DEV: | 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 | case SG_DXFER_TO_FROM_DEV: | 766 | case SG_DXFER_TO_FROM_DEV: |
764 | if (!hp->dxferp || hp->dxfer_len == 0) | 767 | if (!hp->dxferp || hp->dxfer_len == 0) |
765 | return false; | 768 | return false; |
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 8b93197daefe..9be211d68b15 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c | |||
@@ -837,6 +837,7 @@ static struct scsi_host_template virtscsi_host_template_multi = { | |||
837 | .eh_abort_handler = virtscsi_abort, | 837 | .eh_abort_handler = virtscsi_abort, |
838 | .eh_device_reset_handler = virtscsi_device_reset, | 838 | .eh_device_reset_handler = virtscsi_device_reset, |
839 | .eh_timed_out = virtscsi_eh_timed_out, | 839 | .eh_timed_out = virtscsi_eh_timed_out, |
840 | .slave_alloc = virtscsi_device_alloc, | ||
840 | 841 | ||
841 | .can_queue = 1024, | 842 | .can_queue = 1024, |
842 | .dma_boundary = UINT_MAX, | 843 | .dma_boundary = UINT_MAX, |