From 8d9ecd49426c95ccb986d8111bbbf19920a231fe Mon Sep 17 00:00:00 2001 From: Jitendra Bhivare Date: Tue, 10 Oct 2017 16:18:11 +0530 Subject: scsi: be2iscsi: Fix boot flags in sysfs The boot flags exported through sysfs was wrongly reverted to 2. Use boot flag 3 required per spec. Bit 0 Block valid flag Bit 1 Firmware booting selected Signed-off-by: Jitendra Bhivare Signed-off-by: Martin K. Petersen --- drivers/scsi/be2iscsi/be_main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'drivers/scsi/be2iscsi') diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index b4542e7e2ad5..56ae0f4a4923 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -4917,6 +4917,13 @@ void beiscsi_start_boot_work(struct beiscsi_hba *phba, unsigned int s_handle) schedule_work(&phba->boot_work); } +/** + * Boot flag info for iscsi-utilities + * Bit 0 Block valid flag + * Bit 1 Firmware booting selected + */ +#define BEISCSI_SYSFS_ISCSI_BOOT_FLAGS 3 + static ssize_t beiscsi_show_boot_tgt_info(void *data, int type, char *buf) { struct beiscsi_hba *phba = data; @@ -4972,7 +4979,7 @@ static ssize_t beiscsi_show_boot_tgt_info(void *data, int type, char *buf) auth_data.chap.intr_secret); break; case ISCSI_BOOT_TGT_FLAGS: - rc = sprintf(str, "2\n"); + rc = sprintf(str, "%d\n", BEISCSI_SYSFS_ISCSI_BOOT_FLAGS); break; case ISCSI_BOOT_TGT_NIC_ASSOC: rc = sprintf(str, "0\n"); @@ -5004,7 +5011,7 @@ static ssize_t beiscsi_show_boot_eth_info(void *data, int type, char *buf) switch (type) { case ISCSI_BOOT_ETH_FLAGS: - rc = sprintf(str, "2\n"); + rc = sprintf(str, "%d\n", BEISCSI_SYSFS_ISCSI_BOOT_FLAGS); break; case ISCSI_BOOT_ETH_INDEX: rc = sprintf(str, "0\n"); -- cgit From 8dd998e6e94ed6b94f001f4ed37ca9c9120ee257 Mon Sep 17 00:00:00 2001 From: Jitendra Bhivare Date: Tue, 10 Oct 2017 16:18:12 +0530 Subject: scsi: be2iscsi: Fix return value in mgmt_open_connection mgmt_open_connection is expected to return tag not errno. In error case, just return invalid tag 0. Signed-off-by: Jitendra Bhivare Signed-off-by: Martin K. Petersen --- drivers/scsi/be2iscsi/be_mgmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi/be2iscsi') diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c index c73775368d09..af6ee43c2f2e 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.c +++ b/drivers/scsi/be2iscsi/be_mgmt.c @@ -156,7 +156,7 @@ int mgmt_open_connection(struct beiscsi_hba *phba, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, "BG_%d : unknown addr family %d\n", dst_addr->sa_family); - return -EINVAL; + return 0; } phwi_ctrlr = phba->phwi_ctrlr; -- cgit From 45371aa398c6473a722e4a3800d9fea5a53e080f Mon Sep 17 00:00:00 2001 From: Jitendra Bhivare Date: Tue, 10 Oct 2017 16:18:13 +0530 Subject: scsi: be2iscsi: Free msi_name and disable HW intr In beiscsi_dev_probe, allocated msi_name does not get freed and enabled HW interrupts are not disabled in iscsi_host_add error case. Add beiscsi_free_irqs fn to handle the cleanup in probe and disable port. Signed-off-by: Jitendra Bhivare Signed-off-by: Martin K. Petersen --- drivers/scsi/be2iscsi/be_main.c | 47 ++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'drivers/scsi/be2iscsi') diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 56ae0f4a4923..8f7e394ec964 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -790,6 +790,24 @@ static irqreturn_t be_isr(int irq, void *dev_id) return IRQ_HANDLED; } +static void beiscsi_free_irqs(struct beiscsi_hba *phba) +{ + struct hwi_context_memory *phwi_context; + int i; + + if (!phba->pcidev->msix_enabled) { + if (phba->pcidev->irq) + free_irq(phba->pcidev->irq, phba); + return; + } + + phwi_context = phba->phwi_ctrlr->phwi_ctxt; + for (i = 0; i <= phba->num_cpus; i++) { + free_irq(pci_irq_vector(phba->pcidev, i), + &phwi_context->be_eq[i]); + kfree(phba->msi_name[i]); + } +} static int beiscsi_init_irqs(struct beiscsi_hba *phba) { @@ -5396,15 +5414,7 @@ static void beiscsi_disable_port(struct beiscsi_hba *phba, int unload) phwi_ctrlr = phba->phwi_ctrlr; phwi_context = phwi_ctrlr->phwi_ctxt; hwi_disable_intr(phba); - if (phba->pcidev->msix_enabled) { - for (i = 0; i <= phba->num_cpus; i++) { - free_irq(pci_irq_vector(phba->pcidev, i), - &phwi_context->be_eq[i]); - kfree(phba->msi_name[i]); - } - } else - if (phba->pcidev->irq) - free_irq(phba->pcidev->irq, phba); + beiscsi_free_irqs(phba); pci_free_irq_vectors(phba->pcidev); for (i = 0; i < phba->num_cpus; i++) { @@ -5595,12 +5605,12 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, if (ret) { beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, "BM_%d : be_ctrl_init failed\n"); - goto hba_free; + goto free_hba; } ret = beiscsi_init_sliport(phba); if (ret) - goto hba_free; + goto free_hba; spin_lock_init(&phba->io_sgl_lock); spin_lock_init(&phba->mgmt_sgl_lock); @@ -5680,13 +5690,13 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, "BM_%d : beiscsi_dev_probe-" "Failed to beiscsi_init_irqs\n"); - goto free_blkenbld; + goto disable_iopoll; } hwi_enable_intr(phba); ret = iscsi_host_add(phba->shost, &phba->pcidev->dev); if (ret) - goto free_blkenbld; + goto free_irqs; /* set online bit after port is operational */ set_bit(BEISCSI_HBA_ONLINE, &phba->state); @@ -5724,12 +5734,15 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, "\n\n\n BM_%d : SUCCESS - DRIVER LOADED\n\n\n"); return 0; -free_blkenbld: - destroy_workqueue(phba->wq); +free_irqs: + hwi_disable_intr(phba); + beiscsi_free_irqs(phba); +disable_iopoll: for (i = 0; i < phba->num_cpus; i++) { pbe_eq = &phwi_context->be_eq[i]; irq_poll_disable(&pbe_eq->iopoll); } + destroy_workqueue(phba->wq); free_twq: hwi_cleanup_port(phba); beiscsi_cleanup_port(phba); @@ -5738,9 +5751,9 @@ free_port: pci_free_consistent(phba->pcidev, phba->ctrl.mbox_mem_alloced.size, phba->ctrl.mbox_mem_alloced.va, - phba->ctrl.mbox_mem_alloced.dma); + phba->ctrl.mbox_mem_alloced.dma); beiscsi_unmap_pci_function(phba); -hba_free: +free_hba: pci_disable_msix(phba->pcidev); pci_dev_put(phba->pcidev); iscsi_host_free(phba->shost); -- cgit From a39e9f71e5ed718256681f73740e866c8e572ec6 Mon Sep 17 00:00:00 2001 From: Jitendra Bhivare Date: Tue, 10 Oct 2017 16:18:14 +0530 Subject: scsi: be2iscsi: Fix _modify_eq_delay buffer overflow beiscsi_modify_eq_delay is using embedded command to send request of 788 bytes in 236 bytes buffer. Non-embedded command needs to be used in such cases. Use mgmt_alloc_cmd_data fn modified to allow passing of subsystem. Use mgmt_exec_nonemb_cmd fn modified to allow setting of callback. Signed-off-by: Jitendra Bhivare Signed-off-by: Martin K. Petersen --- drivers/scsi/be2iscsi/be_cmds.c | 6 +- drivers/scsi/be2iscsi/be_cmds.h | 4 +- drivers/scsi/be2iscsi/be_mgmt.c | 212 ++++++++++++++++++++++------------------ 3 files changed, 124 insertions(+), 98 deletions(-) (limited to 'drivers/scsi/be2iscsi') diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c index a79a5e72c777..6af448d69126 100644 --- a/drivers/scsi/be2iscsi/be_cmds.c +++ b/drivers/scsi/be2iscsi/be_cmds.c @@ -675,8 +675,8 @@ static int be_mbox_notify(struct be_ctrl_info *ctrl) return status; } -void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len, - bool embedded, u8 sge_cnt) +void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, u32 payload_len, + bool embedded, u8 sge_cnt) { if (embedded) wrb->emb_sgecnt_special |= MCC_WRB_EMBEDDED_MASK; @@ -688,7 +688,7 @@ void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len, } void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr, - u8 subsystem, u8 opcode, int cmd_len) + u8 subsystem, u8 opcode, u32 cmd_len) { req_hdr->opcode = opcode; req_hdr->subsystem = subsystem; diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h index d9b6773facdb..22ddfe918cfd 100644 --- a/drivers/scsi/be2iscsi/be_cmds.h +++ b/drivers/scsi/be2iscsi/be_cmds.h @@ -1444,9 +1444,9 @@ struct be_cmd_get_port_name { * the cxn */ -void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len, +void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, u32 payload_len, bool embedded, u8 sge_cnt); void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr, - u8 subsystem, u8 opcode, int cmd_len); + u8 subsystem, u8 opcode, u32 cmd_len); #endif /* !BEISCSI_CMDS_H */ diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c index af6ee43c2f2e..2117ac08382a 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.c +++ b/drivers/scsi/be2iscsi/be_mgmt.c @@ -19,43 +19,6 @@ #include "be_iscsi.h" #include "be_main.h" -int beiscsi_modify_eq_delay(struct beiscsi_hba *phba, - struct be_set_eqd *set_eqd, - int num) -{ - struct be_ctrl_info *ctrl = &phba->ctrl; - struct be_mcc_wrb *wrb; - struct be_cmd_req_modify_eq_delay *req; - unsigned int tag; - int i; - - mutex_lock(&ctrl->mbox_lock); - wrb = alloc_mcc_wrb(phba, &tag); - if (!wrb) { - mutex_unlock(&ctrl->mbox_lock); - return 0; - } - - req = embedded_payload(wrb); - be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); - be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, - OPCODE_COMMON_MODIFY_EQ_DELAY, sizeof(*req)); - - req->num_eq = cpu_to_le32(num); - for (i = 0; i < num; i++) { - req->delay[i].eq_id = cpu_to_le32(set_eqd[i].eq_id); - req->delay[i].phase = 0; - req->delay[i].delay_multiplier = - cpu_to_le32(set_eqd[i].delay_multiplier); - } - - /* ignore the completion of this mbox command */ - set_bit(MCC_TAG_STATE_IGNORE, &ctrl->ptag_state[tag].tag_state); - be_mcc_notify(phba, tag); - mutex_unlock(&ctrl->mbox_lock); - return tag; -} - unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba, struct bsg_job *job, @@ -236,16 +199,19 @@ int mgmt_open_connection(struct beiscsi_hba *phba, } /* - * mgmt_exec_nonemb_cmd()- Execute Non Embedded MBX Cmd - * @phba: Driver priv structure - * @nonemb_cmd: Address of the MBX command issued - * @resp_buf: Buffer to copy the MBX cmd response - * @resp_buf_len: respone lenght to be copied + * beiscsi_exec_nemb_cmd()- execute non-embedded MBX cmd + * @phba: driver priv structure + * @nonemb_cmd: DMA address of the MBX command to be issued + * @cbfn: callback func on MCC completion + * @resp_buf: buffer to copy the MBX cmd response + * @resp_buf_len: response length to be copied * **/ -static int mgmt_exec_nonemb_cmd(struct beiscsi_hba *phba, - struct be_dma_mem *nonemb_cmd, void *resp_buf, - int resp_buf_len) +static int beiscsi_exec_nemb_cmd(struct beiscsi_hba *phba, + struct be_dma_mem *nonemb_cmd, + void (*cbfn)(struct beiscsi_hba *, + unsigned int), + void *resp_buf, u32 resp_buf_len) { struct be_ctrl_info *ctrl = &phba->ctrl; struct be_mcc_wrb *wrb; @@ -267,36 +233,54 @@ static int mgmt_exec_nonemb_cmd(struct beiscsi_hba *phba, sge->pa_lo = cpu_to_le32(lower_32_bits(nonemb_cmd->dma)); sge->len = cpu_to_le32(nonemb_cmd->size); + if (cbfn) { + struct be_dma_mem *tag_mem; + + set_bit(MCC_TAG_STATE_ASYNC, &ctrl->ptag_state[tag].tag_state); + ctrl->ptag_state[tag].cbfn = cbfn; + tag_mem = &phba->ctrl.ptag_state[tag].tag_mem_state; + + /* store DMA mem to be freed in callback */ + tag_mem->size = nonemb_cmd->size; + tag_mem->va = nonemb_cmd->va; + tag_mem->dma = nonemb_cmd->dma; + } be_mcc_notify(phba, tag); mutex_unlock(&ctrl->mbox_lock); + /* with cbfn set, its async cmd, don't wait */ + if (cbfn) + return 0; + rc = beiscsi_mccq_compl_wait(phba, tag, NULL, nonemb_cmd); + /* copy the response, if any */ if (resp_buf) memcpy(resp_buf, nonemb_cmd->va, resp_buf_len); + /** + * This is special case of NTWK_GET_IF_INFO where the size of + * response is not known. beiscsi_if_get_info checks the return + * value to free DMA buffer. + */ + if (rc == -EAGAIN) + return rc; - if (rc) { - /* Check if the MBX Cmd needs to be re-issued */ - if (rc == -EAGAIN) - return rc; - - beiscsi_log(phba, KERN_WARNING, - BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, - "BG_%d : mgmt_exec_nonemb_cmd Failed status\n"); + /** + * If FW is busy that is driver timed out, DMA buffer is saved with + * the tag, only when the cmd completes this buffer is freed. + */ + if (rc == -EBUSY) + return rc; - if (rc != -EBUSY) - goto free_cmd; - else - return rc; - } free_cmd: pci_free_consistent(ctrl->pdev, nonemb_cmd->size, nonemb_cmd->va, nonemb_cmd->dma); return rc; } -static int mgmt_alloc_cmd_data(struct beiscsi_hba *phba, struct be_dma_mem *cmd, - int iscsi_cmd, int size) +static int beiscsi_prep_nemb_cmd(struct beiscsi_hba *phba, + struct be_dma_mem *cmd, + u8 subsystem, u8 opcode, u32 size) { cmd->va = pci_zalloc_consistent(phba->ctrl.pdev, size, &cmd->dma); if (!cmd->va) { @@ -305,13 +289,52 @@ static int mgmt_alloc_cmd_data(struct beiscsi_hba *phba, struct be_dma_mem *cmd, return -ENOMEM; } cmd->size = size; - be_cmd_hdr_prepare(cmd->va, CMD_SUBSYSTEM_ISCSI, iscsi_cmd, size); + be_cmd_hdr_prepare(cmd->va, subsystem, opcode, size); beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, - "BG_%d : subsystem iSCSI cmd %d size %d\n", - iscsi_cmd, size); + "BG_%d : subsystem %u cmd %u size %u\n", + subsystem, opcode, size); return 0; } +static void __beiscsi_eq_delay_compl(struct beiscsi_hba *phba, unsigned int tag) +{ + struct be_dma_mem *tag_mem; + + /* status is ignored */ + __beiscsi_mcc_compl_status(phba, tag, NULL, NULL); + tag_mem = &phba->ctrl.ptag_state[tag].tag_mem_state; + if (tag_mem->size) { + pci_free_consistent(phba->pcidev, tag_mem->size, + tag_mem->va, tag_mem->dma); + tag_mem->size = 0; + } +} + +int beiscsi_modify_eq_delay(struct beiscsi_hba *phba, + struct be_set_eqd *set_eqd, int num) +{ + struct be_cmd_req_modify_eq_delay *req; + struct be_dma_mem nonemb_cmd; + int i, rc; + + rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_COMMON, + OPCODE_COMMON_MODIFY_EQ_DELAY, sizeof(*req)); + if (rc) + return rc; + + req = nonemb_cmd.va; + req->num_eq = cpu_to_le32(num); + for (i = 0; i < num; i++) { + req->delay[i].eq_id = cpu_to_le32(set_eqd[i].eq_id); + req->delay[i].phase = 0; + req->delay[i].delay_multiplier = + cpu_to_le32(set_eqd[i].delay_multiplier); + } + + return beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, + __beiscsi_eq_delay_compl, NULL, 0); +} + unsigned int beiscsi_if_get_handle(struct beiscsi_hba *phba) { struct be_ctrl_info *ctrl = &phba->ctrl; @@ -368,9 +391,9 @@ static int beiscsi_if_mod_gw(struct beiscsi_hba *phba, struct be_dma_mem nonemb_cmd; int rt_val; - rt_val = mgmt_alloc_cmd_data(phba, &nonemb_cmd, - OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY, - sizeof(*req)); + rt_val = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI, + OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY, + sizeof(*req)); if (rt_val) return rt_val; @@ -379,7 +402,7 @@ static int beiscsi_if_mod_gw(struct beiscsi_hba *phba, req->ip_addr.ip_type = ip_type; memcpy(req->ip_addr.addr, gw, (ip_type < BEISCSI_IP_TYPE_V6) ? IP_V4_LEN : IP_V6_LEN); - return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); + return beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, NULL, 0); } int beiscsi_if_set_gw(struct beiscsi_hba *phba, u32 ip_type, u8 *gw) @@ -420,17 +443,17 @@ int beiscsi_if_get_gw(struct beiscsi_hba *phba, u32 ip_type, struct be_dma_mem nonemb_cmd; int rc; - rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, - OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY, - sizeof(*resp)); + rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI, + OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY, + sizeof(*resp)); if (rc) return rc; req = nonemb_cmd.va; req->ip_type = ip_type; - return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, resp, - sizeof(*resp)); + return beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, + resp, sizeof(*resp)); } static int @@ -441,9 +464,9 @@ beiscsi_if_clr_ip(struct beiscsi_hba *phba, struct be_dma_mem nonemb_cmd; int rc; - rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, - OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR, - sizeof(*req)); + rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI, + OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR, + sizeof(*req)); if (rc) return rc; @@ -461,7 +484,7 @@ beiscsi_if_clr_ip(struct beiscsi_hba *phba, memcpy(req->ip_params.ip_record.ip_addr.subnet_mask, if_info->ip_addr.subnet_mask, sizeof(if_info->ip_addr.subnet_mask)); - rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); + rc = beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, NULL, 0); if (rc < 0 || req->ip_params.ip_record.status) { beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, "BG_%d : failed to clear IP: rc %d status %d\n", @@ -479,9 +502,9 @@ beiscsi_if_set_ip(struct beiscsi_hba *phba, u8 *ip, uint32_t ip_len; int rc; - rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, - OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR, - sizeof(*req)); + rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI, + OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR, + sizeof(*req)); if (rc) return rc; @@ -499,7 +522,7 @@ beiscsi_if_set_ip(struct beiscsi_hba *phba, u8 *ip, memcpy(req->ip_params.ip_record.ip_addr.subnet_mask, subnet, ip_len); - rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); + rc = beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, NULL, 0); /** * In some cases, host needs to look into individual record status * even though FW reported success for that IOCTL. @@ -527,7 +550,8 @@ int beiscsi_if_en_static(struct beiscsi_hba *phba, u32 ip_type, return rc; if (if_info->dhcp_state) { - rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, + rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, + CMD_SUBSYSTEM_ISCSI, OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR, sizeof(*reldhcp)); if (rc) @@ -536,7 +560,7 @@ int beiscsi_if_en_static(struct beiscsi_hba *phba, u32 ip_type, reldhcp = nonemb_cmd.va; reldhcp->interface_hndl = phba->interface_handle; reldhcp->ip_type = ip_type; - rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); + rc = beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, NULL, 0); if (rc < 0) { beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, "BG_%d : failed to release existing DHCP: %d\n", @@ -606,7 +630,7 @@ int beiscsi_if_en_dhcp(struct beiscsi_hba *phba, u32 ip_type) } } - rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, + rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI, OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR, sizeof(*dhcpreq)); if (rc) @@ -617,7 +641,7 @@ int beiscsi_if_en_dhcp(struct beiscsi_hba *phba, u32 ip_type) dhcpreq->retry_count = 1; dhcpreq->interface_hndl = phba->interface_handle; dhcpreq->ip_type = ip_type; - rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); + rc = beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, NULL, 0); exit: kfree(if_info); @@ -673,9 +697,10 @@ int beiscsi_if_get_info(struct beiscsi_hba *phba, int ip_type, return rc; do { - rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, - OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO, - ioctl_size); + rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, + CMD_SUBSYSTEM_ISCSI, + OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO, + ioctl_size); if (rc) return rc; @@ -698,8 +723,8 @@ int beiscsi_if_get_info(struct beiscsi_hba *phba, int ip_type, return -ENOMEM; } - rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, *if_info, - ioctl_size); + rc = beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, *if_info, + ioctl_size); /* Check if the error is because of Insufficent_Buffer */ if (rc == -EAGAIN) { @@ -728,13 +753,14 @@ int mgmt_get_nic_conf(struct beiscsi_hba *phba, struct be_dma_mem nonemb_cmd; int rc; - rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, - OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG, - sizeof(*nic)); + rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI, + OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG, + sizeof(*nic)); if (rc) return rc; - return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, nic, sizeof(*nic)); + return beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, + nic, sizeof(*nic)); } -- cgit From c5905bf82287a9aada3e4b0b1d3425c6e1a91828 Mon Sep 17 00:00:00 2001 From: Jitendra Bhivare Date: Tue, 10 Oct 2017 16:18:15 +0530 Subject: scsi: be2iscsi: Fix _get_initname buffer overflow be_cmd_get_initname pulls GET_HBA_NAME response of 276 bytes in embedded WRB buffer of 236 bytes. Use non-embedded functions to issue the IOCTL. Signed-off-by: Jitendra Bhivare Signed-off-by: Martin K. Petersen --- drivers/scsi/be2iscsi/be_cmds.h | 2 -- drivers/scsi/be2iscsi/be_iscsi.c | 44 +++---------------------------- drivers/scsi/be2iscsi/be_mgmt.c | 57 ++++++++++++++++++++-------------------- drivers/scsi/be2iscsi/be_mgmt.h | 2 ++ 4 files changed, 35 insertions(+), 70 deletions(-) (limited to 'drivers/scsi/be2iscsi') diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h index 22ddfe918cfd..4f1ac97d9921 100644 --- a/drivers/scsi/be2iscsi/be_cmds.h +++ b/drivers/scsi/be2iscsi/be_cmds.h @@ -793,8 +793,6 @@ int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba, struct be_queue_info *mccq, struct be_queue_info *cq); -unsigned int be_cmd_get_initname(struct beiscsi_hba *phba); - void free_mcc_wrb(struct be_ctrl_info *ctrl, unsigned int tag); int beiscsi_modify_eq_delay(struct beiscsi_hba *phba, struct be_set_eqd *, diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c index 43a80ce5ce6a..512c52aecb33 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.c +++ b/drivers/scsi/be2iscsi/be_iscsi.c @@ -683,41 +683,6 @@ int beiscsi_set_param(struct iscsi_cls_conn *cls_conn, return 0; } -/** - * beiscsi_get_initname - Read Initiator Name from flash - * @buf: buffer bointer - * @phba: The device priv structure instance - * - * returns number of bytes - */ -static int beiscsi_get_initname(char *buf, struct beiscsi_hba *phba) -{ - int rc; - unsigned int tag; - struct be_mcc_wrb *wrb; - struct be_cmd_hba_name *resp; - - tag = be_cmd_get_initname(phba); - if (!tag) { - beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, - "BS_%d : Getting Initiator Name Failed\n"); - - return -EBUSY; - } - - rc = beiscsi_mccq_compl_wait(phba, tag, &wrb, NULL); - if (rc) { - beiscsi_log(phba, KERN_ERR, - BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, - "BS_%d : Initiator Name MBX Failed\n"); - return rc; - } - - resp = embedded_payload(wrb); - rc = sprintf(buf, "%s\n", resp->initiator_name); - return rc; -} - /** * beiscsi_get_port_state - Get the Port State * @shost : pointer to scsi_host structure @@ -772,7 +737,6 @@ static void beiscsi_get_port_speed(struct Scsi_Host *shost) * @param: parameter type identifier * @buf: buffer pointer * - * returns host parameter */ int beiscsi_get_host_param(struct Scsi_Host *shost, enum iscsi_host_param param, char *buf) @@ -783,7 +747,7 @@ int beiscsi_get_host_param(struct Scsi_Host *shost, if (!beiscsi_hba_is_online(phba)) { beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, "BS_%d : HBA in error 0x%lx\n", phba->state); - return -EBUSY; + return 0; } beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, "BS_%d : In beiscsi_get_host_param, param = %d\n", param); @@ -794,15 +758,15 @@ int beiscsi_get_host_param(struct Scsi_Host *shost, if (status < 0) { beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, "BS_%d : beiscsi_get_macaddr Failed\n"); - return status; + return 0; } break; case ISCSI_HOST_PARAM_INITIATOR_NAME: - status = beiscsi_get_initname(buf, phba); + status = beiscsi_get_initiator_name(phba, buf); if (status < 0) { beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, "BS_%d : Retreiving Initiator Name Failed\n"); - return status; + return 0; } break; case ISCSI_HOST_PARAM_PORT_STATE: diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c index 2117ac08382a..0c25c105e44f 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.c +++ b/drivers/scsi/be2iscsi/be_mgmt.c @@ -335,6 +335,35 @@ int beiscsi_modify_eq_delay(struct beiscsi_hba *phba, __beiscsi_eq_delay_compl, NULL, 0); } +/** + * beiscsi_get_initiator_name - read initiator name from flash + * @phba: device priv structure + * @name: buffer pointer + * + */ +int beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name) +{ + struct be_dma_mem nonemb_cmd; + struct be_cmd_hba_name resp; + int rc; + + rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI_INI, + OPCODE_ISCSI_INI_CFG_GET_HBA_NAME, sizeof(resp)); + if (rc) + return rc; + + rc = beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, + &resp, sizeof(resp)); + if (rc) { + beiscsi_log(phba, KERN_ERR, + BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, + "BS_%d : Initiator Name MBX Failed\n"); + return rc; + } + rc = sprintf(name, "%s\n", resp.initiator_name); + return rc; +} + unsigned int beiscsi_if_get_handle(struct beiscsi_hba *phba) { struct be_ctrl_info *ctrl = &phba->ctrl; @@ -763,34 +792,6 @@ int mgmt_get_nic_conf(struct beiscsi_hba *phba, nic, sizeof(*nic)); } - - -unsigned int be_cmd_get_initname(struct beiscsi_hba *phba) -{ - unsigned int tag; - struct be_mcc_wrb *wrb; - struct be_cmd_hba_name *req; - struct be_ctrl_info *ctrl = &phba->ctrl; - - if (mutex_lock_interruptible(&ctrl->mbox_lock)) - return 0; - wrb = alloc_mcc_wrb(phba, &tag); - if (!wrb) { - mutex_unlock(&ctrl->mbox_lock); - return 0; - } - - req = embedded_payload(wrb); - be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); - be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, - OPCODE_ISCSI_INI_CFG_GET_HBA_NAME, - sizeof(*req)); - - be_mcc_notify(phba, tag); - mutex_unlock(&ctrl->mbox_lock); - return tag; -} - static void beiscsi_boot_process_compl(struct beiscsi_hba *phba, unsigned int tag) { diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h index 06ddc5ad6874..665fd893509f 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.h +++ b/drivers/scsi/be2iscsi/be_mgmt.h @@ -178,6 +178,8 @@ int beiscsi_mgmt_invalidate_icds(struct beiscsi_hba *phba, struct invldt_cmd_tbl *inv_tbl, unsigned int nents); +int beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name); + int beiscsi_if_en_dhcp(struct beiscsi_hba *phba, u32 ip_type); int beiscsi_if_en_static(struct beiscsi_hba *phba, u32 ip_type, -- cgit From 4788e732c39120e55762a7e296cf7dbdf366f44c Mon Sep 17 00:00:00 2001 From: Jitendra Bhivare Date: Tue, 10 Oct 2017 16:18:16 +0530 Subject: scsi: be2iscsi: Modify IOCTL to fetch user configured IQN Add version 1 of GET_HBA_NAME to fetch port specific IQN first. If it fails use version 0 to get the IQN. To use this old IQN names of interfaces needs to be cleared from the iscsiadm database. Signed-off-by: Jitendra Bhivare Signed-off-by: Martin K. Petersen --- drivers/scsi/be2iscsi/be_iscsi.c | 12 ++++++++---- drivers/scsi/be2iscsi/be_mgmt.c | 7 ++++++- drivers/scsi/be2iscsi/be_mgmt.h | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'drivers/scsi/be2iscsi') diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c index 512c52aecb33..aef97649eb7d 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.c +++ b/drivers/scsi/be2iscsi/be_iscsi.c @@ -762,11 +762,15 @@ int beiscsi_get_host_param(struct Scsi_Host *shost, } break; case ISCSI_HOST_PARAM_INITIATOR_NAME: - status = beiscsi_get_initiator_name(phba, buf); + /* try fetching user configured name first */ + status = beiscsi_get_initiator_name(phba, buf, true); if (status < 0) { - beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, - "BS_%d : Retreiving Initiator Name Failed\n"); - return 0; + status = beiscsi_get_initiator_name(phba, buf, false); + if (status < 0) { + beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, + "BS_%d : Retreiving Initiator Name Failed\n"); + status = 0; + } } break; case ISCSI_HOST_PARAM_PORT_STATE: diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c index 0c25c105e44f..713c7de0ea2f 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.c +++ b/drivers/scsi/be2iscsi/be_mgmt.c @@ -339,12 +339,14 @@ int beiscsi_modify_eq_delay(struct beiscsi_hba *phba, * beiscsi_get_initiator_name - read initiator name from flash * @phba: device priv structure * @name: buffer pointer + * @cfg: fetch user configured * */ -int beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name) +int beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name, bool cfg) { struct be_dma_mem nonemb_cmd; struct be_cmd_hba_name resp; + struct be_cmd_hba_name *req; int rc; rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI_INI, @@ -352,6 +354,9 @@ int beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name) if (rc) return rc; + req = nonemb_cmd.va; + if (cfg) + req->hdr.version = 1; rc = beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, &resp, sizeof(resp)); if (rc) { diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h index 665fd893509f..8d886f834819 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.h +++ b/drivers/scsi/be2iscsi/be_mgmt.h @@ -178,7 +178,7 @@ int beiscsi_mgmt_invalidate_icds(struct beiscsi_hba *phba, struct invldt_cmd_tbl *inv_tbl, unsigned int nents); -int beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name); +int beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name, bool cfg); int beiscsi_if_en_dhcp(struct beiscsi_hba *phba, u32 ip_type); -- cgit From 1cb3c3fd60361f0e900af8e7ecdcd65bed70ab08 Mon Sep 17 00:00:00 2001 From: Jitendra Bhivare Date: Tue, 10 Oct 2017 16:18:17 +0530 Subject: scsi: be2iscsi: Add cmd to set host data Provide driver version in host data to FW. Signed-off-by: Jitendra Bhivare Signed-off-by: Martin K. Petersen --- drivers/scsi/be2iscsi/be_cmds.c | 46 +++++++++++++++++++++++++++++++++++++++++ drivers/scsi/be2iscsi/be_cmds.h | 26 +++++++++++++++++++++++ drivers/scsi/be2iscsi/be_main.c | 2 ++ 3 files changed, 74 insertions(+) (limited to 'drivers/scsi/be2iscsi') diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c index 6af448d69126..04996665e608 100644 --- a/drivers/scsi/be2iscsi/be_cmds.c +++ b/drivers/scsi/be2iscsi/be_cmds.c @@ -1522,6 +1522,52 @@ int beiscsi_get_port_name(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba) return ret; } +int beiscsi_set_host_data(struct beiscsi_hba *phba) +{ + struct be_ctrl_info *ctrl = &phba->ctrl; + struct be_cmd_set_host_data *ioctl; + struct be_mcc_wrb *wrb; + int ret = 0; + + if (is_chip_be2_be3r(phba)) + return ret; + + mutex_lock(&ctrl->mbox_lock); + wrb = wrb_from_mbox(&ctrl->mbox_mem); + memset(wrb, 0, sizeof(*wrb)); + ioctl = embedded_payload(wrb); + + be_wrb_hdr_prepare(wrb, sizeof(*ioctl), true, 0); + be_cmd_hdr_prepare(&ioctl->h.req_hdr, CMD_SUBSYSTEM_COMMON, + OPCODE_COMMON_SET_HOST_DATA, + EMBED_MBX_MAX_PAYLOAD_SIZE); + ioctl->param.req.param_id = BE_CMD_SET_HOST_PARAM_ID; + ioctl->param.req.param_len = + snprintf((char *)ioctl->param.req.param_data, + sizeof(ioctl->param.req.param_data), + "Linux iSCSI v%s", BUILD_STR); + ioctl->param.req.param_len = ALIGN(ioctl->param.req.param_len, 4); + if (ioctl->param.req.param_len > BE_CMD_MAX_DRV_VERSION) + ioctl->param.req.param_len = BE_CMD_MAX_DRV_VERSION; + ret = be_mbox_notify(ctrl); + if (!ret) { + beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, + "BG_%d : HBA set host driver version\n"); + } else { + /** + * Check "MCC_STATUS_INVALID_LENGTH" for SKH. + * Older FW versions return this error. + */ + if (ret == MCC_STATUS_ILLEGAL_REQUEST || + ret == MCC_STATUS_INVALID_LENGTH) + __beiscsi_log(phba, KERN_INFO, + "BG_%d : HBA failed to set host driver version\n"); + } + + mutex_unlock(&ctrl->mbox_lock); + return ret; +} + int beiscsi_set_uer_feature(struct beiscsi_hba *phba) { struct be_ctrl_info *ctrl = &phba->ctrl; diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h index 4f1ac97d9921..5d5e8fbd9a57 100644 --- a/drivers/scsi/be2iscsi/be_cmds.h +++ b/drivers/scsi/be2iscsi/be_cmds.h @@ -230,6 +230,7 @@ struct be_mcc_mailbox { #define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG 58 #define OPCODE_COMMON_FUNCTION_RESET 61 #define OPCODE_COMMON_GET_PORT_NAME 77 +#define OPCODE_COMMON_SET_HOST_DATA 93 #define OPCODE_COMMON_SET_FEATURES 191 /** @@ -737,6 +738,30 @@ struct be_cmd_hba_name { u8 initiator_alias[BE_INI_ALIAS_LEN]; } __packed; +/******************** COMMON SET HOST DATA *******************/ +#define BE_CMD_SET_HOST_PARAM_ID 0x2 +#define BE_CMD_MAX_DRV_VERSION 0x30 +struct be_sethost_req { + u32 param_id; + u32 param_len; + u32 param_data[32]; +}; + +struct be_sethost_resp { + u32 rsvd0; +}; + +struct be_cmd_set_host_data { + union { + struct be_cmd_req_hdr req_hdr; + struct be_cmd_resp_hdr resp_hdr; + } h; + union { + struct be_sethost_req req; + struct be_sethost_resp resp; + } param; +} __packed; + /******************** COMMON SET Features *******************/ #define BE_CMD_SET_FEATURE_UER 0x10 #define BE_CMD_UER_SUPP_BIT 0x1 @@ -845,6 +870,7 @@ int beiscsi_get_fw_config(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba); int beiscsi_get_port_name(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba); int beiscsi_set_uer_feature(struct beiscsi_hba *phba); +int beiscsi_set_host_data(struct beiscsi_hba *phba); struct be_default_pdu_context { u32 dw[4]; diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 8f7e394ec964..02144c5a2b93 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -5325,6 +5325,7 @@ static int beiscsi_enable_port(struct beiscsi_hba *phba) be2iscsi_enable_msix(phba); beiscsi_get_params(phba); + beiscsi_set_host_data(phba); /* Re-enable UER. If different TPE occurs then it is recoverable. */ beiscsi_set_uer_feature(phba); @@ -5623,6 +5624,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, } beiscsi_get_port_name(&phba->ctrl, phba); beiscsi_get_params(phba); + beiscsi_set_host_data(phba); beiscsi_set_uer_feature(phba); be2iscsi_enable_msix(phba); -- cgit From 45efc940678ec813f2e6bc4fc45f9f19e686a3b8 Mon Sep 17 00:00:00 2001 From: Jitendra Bhivare Date: Tue, 10 Oct 2017 16:18:18 +0530 Subject: scsi: be2iscsi: Fix misc static analysis errors The patch fixes errors reported by tools like smatch: - removes unused structure fields - removes dead code - fixes code identation Signed-off-by: Jitendra Bhivare Signed-off-by: Martin K. Petersen --- drivers/scsi/be2iscsi/be.h | 17 ++++++++-------- drivers/scsi/be2iscsi/be_cmds.c | 1 - drivers/scsi/be2iscsi/be_cmds.h | 14 ++----------- drivers/scsi/be2iscsi/be_main.c | 40 ++++++++++++++++-------------------- drivers/scsi/be2iscsi/be_main.h | 45 ++--------------------------------------- drivers/scsi/be2iscsi/be_mgmt.h | 6 ------ 6 files changed, 29 insertions(+), 94 deletions(-) (limited to 'drivers/scsi/be2iscsi') diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h index 55e3f8b40eb3..1310fbf20072 100644 --- a/drivers/scsi/be2iscsi/be.h +++ b/drivers/scsi/be2iscsi/be.h @@ -81,12 +81,12 @@ static inline void queue_tail_inc(struct be_queue_info *q) /*ISCSI */ struct be_aic_obj { /* Adaptive interrupt coalescing (AIC) info */ - u32 min_eqd; /* in usecs */ - u32 max_eqd; /* in usecs */ - u32 prev_eqd; /* in usecs */ - u32 et_eqd; /* configured val when aic is off */ - ulong jiffies; - u64 eq_prev; /* Used to calculate eqe */ + unsigned long jiffies; + u32 eq_prev; /* Used to calculate eqe */ + u32 prev_eqd; +#define BEISCSI_EQ_DELAY_MIN 0 +#define BEISCSI_EQ_DELAY_DEF 32 +#define BEISCSI_EQ_DELAY_MAX 128 }; struct be_eq_obj { @@ -148,9 +148,8 @@ struct be_ctrl_info { /* TAG is from 1...MAX_MCC_CMD, MASK includes MAX_MCC_CMD */ #define MCC_Q_CMD_TAG_MASK ((MAX_MCC_CMD << 1) - 1) -#define PAGE_SHIFT_4K 12 -#define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K) -#define mcc_timeout 120000 /* 12s timeout */ +#define PAGE_SHIFT_4K 12 +#define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K) /* Returns number of pages spanned by the data starting at the given addr */ #define PAGES_4K_SPANNED(_address, size) \ diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c index 04996665e608..7d633ddbc668 100644 --- a/drivers/scsi/be2iscsi/be_cmds.c +++ b/drivers/scsi/be2iscsi/be_cmds.c @@ -947,7 +947,6 @@ int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q, default: mutex_unlock(&ctrl->mbox_lock); BUG(); - return -ENXIO; } be_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req)); if (queue_type != QTYPE_SGL) diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h index 5d5e8fbd9a57..fc252de21eba 100644 --- a/drivers/scsi/be2iscsi/be_cmds.h +++ b/drivers/scsi/be2iscsi/be_cmds.h @@ -1298,19 +1298,9 @@ struct be_cmd_get_port_name { * a read command */ #define TGT_CTX_UPDT_CMD 7 /* Target context update */ -#define TGT_STS_CMD 8 /* Target R2T and other BHS - * where only the status number - * need to be updated - */ -#define TGT_DATAIN_CMD 9 /* Target Data-Ins in response - * to read command - */ -#define TGT_SOS_PDU 10 /* Target:standalone status - * response - */ #define TGT_DM_CMD 11 /* Indicates that the bhs - * preparedby - * driver should not be touched + * prepared by driver should not + * be touched. */ /* Returns the number of items in the field array. */ diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 02144c5a2b93..f8123ad5aef9 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -455,14 +455,12 @@ static int beiscsi_map_pci_bars(struct beiscsi_hba *phba, return -ENOMEM; phba->ctrl.csr = addr; phba->csr_va = addr; - phba->csr_pa.u.a64.address = pci_resource_start(pcidev, 2); addr = ioremap_nocache(pci_resource_start(pcidev, 4), 128 * 1024); if (addr == NULL) goto pci_map_err; phba->ctrl.db = addr; phba->db_va = addr; - phba->db_pa.u.a64.address = pci_resource_start(pcidev, 4); if (phba->generation == BE_GEN2) pcicfg_reg = 1; @@ -476,7 +474,6 @@ static int beiscsi_map_pci_bars(struct beiscsi_hba *phba, goto pci_map_err; phba->ctrl.pcicfg = addr; phba->pci_va = addr; - phba->pci_pa.u.a64.address = pci_resource_start(pcidev, pcicfg_reg); return 0; pci_map_err: @@ -942,12 +939,11 @@ free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) * this can happen if clean_task is called on a task that * failed in xmit_task or alloc_pdu. */ - beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, - "BM_%d : Double Free in IO SGL io_sgl_free_index=%d," - "value there=%p\n", phba->io_sgl_free_index, - phba->io_sgl_hndl_base - [phba->io_sgl_free_index]); - spin_unlock_irqrestore(&phba->io_sgl_lock, flags); + beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, + "BM_%d : Double Free in IO SGL io_sgl_free_index=%d, value there=%p\n", + phba->io_sgl_free_index, + phba->io_sgl_hndl_base[phba->io_sgl_free_index]); + spin_unlock_irqrestore(&phba->io_sgl_lock, flags); return; } phba->io_sgl_hndl_base[phba->io_sgl_free_index] = psgl_handle; @@ -1882,8 +1878,8 @@ unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq, int budget) be_dws_le_to_cpu(sol, sizeof(struct sol_cqe)); - code = (sol->dw[offsetof(struct amap_sol_cqe, code) / - 32] & CQE_CODE_MASK); + code = (sol->dw[offsetof(struct amap_sol_cqe, code) / 32] & + CQE_CODE_MASK); /* Get the CID */ if (is_chip_be2_be3r(phba)) { @@ -3042,7 +3038,7 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba, mem->dma = paddr; ret = beiscsi_cmd_eq_create(&phba->ctrl, eq, - phwi_context->cur_eqd); + BEISCSI_EQ_DELAY_DEF); if (ret) { beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, "BM_%d : beiscsi_cmd_eq_create" @@ -3526,13 +3522,14 @@ static int be_mcc_queues_create(struct beiscsi_hba *phba, goto err; /* Ask BE to create MCC compl queue; */ if (phba->pcidev->msix_enabled) { - if (beiscsi_cmd_cq_create(ctrl, cq, &phwi_context->be_eq - [phba->num_cpus].q, false, true, 0)) - goto mcc_cq_free; + if (beiscsi_cmd_cq_create(ctrl, cq, + &phwi_context->be_eq[phba->num_cpus].q, + false, true, 0)) + goto mcc_cq_free; } else { if (beiscsi_cmd_cq_create(ctrl, cq, &phwi_context->be_eq[0].q, false, true, 0)) - goto mcc_cq_free; + goto mcc_cq_free; } /* Alloc MCC queue */ @@ -3707,9 +3704,6 @@ static int hwi_init_port(struct beiscsi_hba *phba) phwi_ctrlr = phba->phwi_ctrlr; phwi_context = phwi_ctrlr->phwi_ctxt; - phwi_context->max_eqd = 128; - phwi_context->min_eqd = 0; - phwi_context->cur_eqd = 32; /* set port optic state to unknown */ phba->optic_state = 0xff; @@ -4810,10 +4804,10 @@ static int beiscsi_task_xmit(struct iscsi_task *task) sg = scsi_sglist(sc); if (sc->sc_data_direction == DMA_TO_DEVICE) writedir = 1; - else + else writedir = 0; - return phba->iotask_fn(task, sg, num_sg, xferlen, writedir); + return phba->iotask_fn(task, sg, num_sg, xferlen, writedir); } /** @@ -5234,8 +5228,8 @@ static void beiscsi_eqd_update_work(struct work_struct *work) if (eqd < 8) eqd = 0; - eqd = min_t(u32, eqd, phwi_context->max_eqd); - eqd = max_t(u32, eqd, phwi_context->min_eqd); + eqd = min_t(u32, eqd, BEISCSI_EQ_DELAY_MAX); + eqd = max_t(u32, eqd, BEISCSI_EQ_DELAY_MIN); aic->jiffies = now; aic->eq_prev = pbe_eq->cq_count; diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h index 81ce3ffda968..6d8f819ec617 100644 --- a/drivers/scsi/be2iscsi/be_main.h +++ b/drivers/scsi/be2iscsi/be_main.h @@ -59,7 +59,7 @@ #define BE2_DEFPDU_DATA_SZ 8192 #define BE2_MAX_NUM_CQ_PROC 512 -#define MAX_CPUS 64 +#define MAX_CPUS 64U #define BEISCSI_MAX_NUM_CPUS 7 #define BEISCSI_VER_STRLEN 32 @@ -77,9 +77,7 @@ #define BEISCSI_MAX_CMD_LEN 16 /* scsi_host->max_cmd_len */ #define BEISCSI_NUM_MAX_LUN 256 /* scsi_host->max_lun */ -#define BEISCSI_NUM_DEVICES_SUPPORTED 0x01 #define BEISCSI_MAX_FRAGS_INIT 192 -#define BE_NUM_MSIX_ENTRIES 1 #define BE_SENSE_INFO_SIZE 258 #define BE_ISCSI_PDU_HEADER_SIZE 64 @@ -209,13 +207,8 @@ struct mem_array { }; struct be_mem_descriptor { - unsigned int index; /* Index of this memory parameter */ - unsigned int category; /* type indicates cached/non-cached */ - unsigned int num_elements; /* number of elements in this - * descriptor - */ - unsigned int alignment_mask; /* Alignment mask for this block */ unsigned int size_in_bytes; /* Size required by memory block */ + unsigned int num_elements; struct mem_array *mem_array; }; @@ -238,32 +231,12 @@ struct hba_parameters { unsigned int num_eq_entries; unsigned int wrbs_per_cxn; unsigned int hwi_ws_sz; - /** - * These are calculated from other params. They're here - * for debug purposes - */ - unsigned int num_mcc_pages; - unsigned int num_mcc_cq_pages; - unsigned int num_cq_pages; - unsigned int num_eq_pages; - - unsigned int num_async_pdu_buf_pages; - unsigned int num_async_pdu_buf_sgl_pages; - unsigned int num_async_pdu_buf_cq_pages; - - unsigned int num_async_pdu_hdr_pages; - unsigned int num_async_pdu_hdr_sgl_pages; - unsigned int num_async_pdu_hdr_cq_pages; - - unsigned int num_sge; }; #define BEISCSI_GET_ULP_FROM_CRI(phwi_ctrlr, cri) \ (phwi_ctrlr->wrb_context[cri].ulp_num) struct hwi_wrb_context { spinlock_t wrb_lock; - struct list_head wrb_handle_list; - struct list_head wrb_handle_drvr_list; struct wrb_handle **pwrb_handle_base; struct wrb_handle **pwrb_handle_basestd; struct iscsi_wrb *plast_wrb; @@ -272,8 +245,6 @@ struct hwi_wrb_context { unsigned short wrb_handles_available; unsigned short cid; uint8_t ulp_num; /* ULP to which CID binded */ - uint16_t register_set; - uint16_t doorbell_format; uint32_t doorbell_offset; }; @@ -310,9 +281,6 @@ struct beiscsi_hba { u8 __iomem *csr_va; /* CSR */ u8 __iomem *db_va; /* Door Bell */ u8 __iomem *pci_va; /* PCI Config */ - struct be_bus_address csr_pa; /* CSR */ - struct be_bus_address db_pa; /* CSR */ - struct be_bus_address pci_pa; /* CSR */ /* PCI representation of our HBA */ struct pci_dev *pcidev; unsigned int num_cpus; @@ -324,7 +292,6 @@ struct beiscsi_hba { unsigned short io_sgl_free_index; unsigned short io_sgl_hndl_avbl; struct sgl_handle **io_sgl_hndl_base; - struct sgl_handle **sgl_hndl_array; unsigned short eh_sgl_alloc_index; unsigned short eh_sgl_free_index; @@ -1009,10 +976,6 @@ struct be_ring { }; struct hwi_controller { - struct list_head io_sgl_list; - struct list_head eh_sgl_list; - struct sgl_handle *psgl_handle_base; - struct hwi_wrb_context *wrb_context; struct be_ring default_pdu_hdr[BEISCSI_ULP_COUNT]; struct be_ring default_pdu_data[BEISCSI_ULP_COUNT]; @@ -1036,10 +999,6 @@ struct wrb_handle { }; struct hwi_context_memory { - /* Adaptive interrupt coalescing (AIC) info */ - u16 min_eqd; /* in usecs */ - u16 max_eqd; /* in usecs */ - u16 cur_eqd; /* in usecs */ struct be_eq_obj be_eq[MAX_CPUS]; struct be_queue_info be_cq[MAX_CPUS - 1]; diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h index 8d886f834819..b310c24949cc 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.h +++ b/drivers/scsi/be2iscsi/be_mgmt.h @@ -157,7 +157,6 @@ struct be_bsg_vendor_cmd { struct beiscsi_endpoint { struct beiscsi_hba *phba; - struct beiscsi_sess *sess; struct beiscsi_conn *conn; struct iscsi_endpoint *openiscsi_ep; unsigned short ip_type; @@ -169,11 +168,6 @@ struct beiscsi_endpoint { u16 cid_vld; }; -unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba, - struct beiscsi_endpoint *beiscsi_ep, - unsigned short cid, - unsigned short issue_reset, - unsigned short savecfg_flag); int beiscsi_mgmt_invalidate_icds(struct beiscsi_hba *phba, struct invldt_cmd_tbl *inv_tbl, unsigned int nents); -- cgit From 0172dc65623e037c90d7dd50d0168e75984427a9 Mon Sep 17 00:00:00 2001 From: Jitendra Bhivare Date: Tue, 10 Oct 2017 16:18:19 +0530 Subject: scsi: be2iscsi: Remove A-circumflex character in copyright marking Signed-off-by: Jitendra Bhivare Signed-off-by: Martin K. Petersen --- drivers/scsi/be2iscsi/be.h | 2 +- drivers/scsi/be2iscsi/be_cmds.c | 2 +- drivers/scsi/be2iscsi/be_cmds.h | 2 +- drivers/scsi/be2iscsi/be_iscsi.c | 2 +- drivers/scsi/be2iscsi/be_iscsi.h | 2 +- drivers/scsi/be2iscsi/be_main.c | 2 +- drivers/scsi/be2iscsi/be_main.h | 2 +- drivers/scsi/be2iscsi/be_mgmt.c | 2 +- drivers/scsi/be2iscsi/be_mgmt.h | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/scsi/be2iscsi') diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h index 1310fbf20072..e035acf56652 100644 --- a/drivers/scsi/be2iscsi/be.h +++ b/drivers/scsi/be2iscsi/be.h @@ -1,5 +1,5 @@ /* - * Copyright 2017 Broadcom. All Rights Reserved. + * Copyright 2017 Broadcom. All Rights Reserved. * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c index 7d633ddbc668..2eb66df3e3d6 100644 --- a/drivers/scsi/be2iscsi/be_cmds.c +++ b/drivers/scsi/be2iscsi/be_cmds.c @@ -1,5 +1,5 @@ /* - * Copyright 2017 Broadcom. All Rights Reserved. + * Copyright 2017 Broadcom. All Rights Reserved. * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h index fc252de21eba..6f05d1dfa10a 100644 --- a/drivers/scsi/be2iscsi/be_cmds.h +++ b/drivers/scsi/be2iscsi/be_cmds.h @@ -1,5 +1,5 @@ /* - * Copyright 2017 Broadcom. All Rights Reserved. + * Copyright 2017 Broadcom. All Rights Reserved. * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c index aef97649eb7d..a398c54139aa 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.c +++ b/drivers/scsi/be2iscsi/be_iscsi.c @@ -1,5 +1,5 @@ /* - * Copyright 2017 Broadcom. All Rights Reserved. + * Copyright 2017 Broadcom. All Rights Reserved. * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/be2iscsi/be_iscsi.h b/drivers/scsi/be2iscsi/be_iscsi.h index b9d459a21f25..f41dfda97e17 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.h +++ b/drivers/scsi/be2iscsi/be_iscsi.h @@ -1,5 +1,5 @@ /* - * Copyright 2017 Broadcom. All Rights Reserved. + * Copyright 2017 Broadcom. All Rights Reserved. * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index f8123ad5aef9..7561e1332257 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -1,5 +1,5 @@ /* - * Copyright 2017 Broadcom. All Rights Reserved. + * Copyright 2017 Broadcom. All Rights Reserved. * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h index 6d8f819ec617..3d21849c1602 100644 --- a/drivers/scsi/be2iscsi/be_main.h +++ b/drivers/scsi/be2iscsi/be_main.h @@ -1,5 +1,5 @@ /* - * Copyright 2017 Broadcom. All Rights Reserved. + * Copyright 2017 Broadcom. All Rights Reserved. * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c index 713c7de0ea2f..66ca967f2850 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.c +++ b/drivers/scsi/be2iscsi/be_mgmt.c @@ -1,5 +1,5 @@ /* - * Copyright 2017 Broadcom. All Rights Reserved. + * Copyright 2017 Broadcom. All Rights Reserved. * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h index b310c24949cc..0b22c99a7a22 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.h +++ b/drivers/scsi/be2iscsi/be_mgmt.h @@ -1,5 +1,5 @@ /* - * Copyright 2017 Broadcom. All Rights Reserved. + * Copyright 2017 Broadcom. All Rights Reserved. * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. * * This program is free software; you can redistribute it and/or -- cgit From 27aa292e3e621d72e49a3392dfa54a4152325407 Mon Sep 17 00:00:00 2001 From: Jitendra Bhivare Date: Tue, 10 Oct 2017 16:18:20 +0530 Subject: scsi: be2iscsi: Update driver version Version 11.4.0.1 Signed-off-by: Jitendra Bhivare Signed-off-by: Martin K. Petersen --- drivers/scsi/be2iscsi/be_main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi/be2iscsi') diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h index 3d21849c1602..9bc7ef973ee1 100644 --- a/drivers/scsi/be2iscsi/be_main.h +++ b/drivers/scsi/be2iscsi/be_main.h @@ -31,7 +31,7 @@ #include #define DRV_NAME "be2iscsi" -#define BUILD_STR "11.4.0.0" +#define BUILD_STR "11.4.0.1" #define BE_NAME "Emulex OneConnect" \ "Open-iSCSI Driver version" BUILD_STR #define DRV_DESC BE_NAME " " "Driver" -- cgit From d38c9a803b42d19d125aff586dfaac77b5702d05 Mon Sep 17 00:00:00 2001 From: Himanshu Jha Date: Wed, 11 Oct 2017 21:06:14 +0530 Subject: scsi: be2iscsi: Use kasprintf Use kasprintf instead of combination of kmalloc and sprintf. Also, remove BEISCSI_MSI_NAME macro used to specify size of string as kasprintf handles size computations. Signed-off-by: Himanshu Jha Reviewed-by: Kyle Fortin Reviewed-by: Jitendra Bhivare Signed-off-by: Martin K. Petersen --- drivers/scsi/be2iscsi/be_main.c | 12 +++++------- drivers/scsi/be2iscsi/be_main.h | 2 -- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'drivers/scsi/be2iscsi') diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 7561e1332257..1db21b657800 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -818,15 +818,14 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba) if (pcidev->msix_enabled) { for (i = 0; i < phba->num_cpus; i++) { - phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, - GFP_KERNEL); + phba->msi_name[i] = kasprintf(GFP_KERNEL, + "beiscsi_%02x_%02x", + phba->shost->host_no, i); if (!phba->msi_name[i]) { ret = -ENOMEM; goto free_msix_irqs; } - sprintf(phba->msi_name[i], "beiscsi_%02x_%02x", - phba->shost->host_no, i); ret = request_irq(pci_irq_vector(pcidev, i), be_isr_msix, 0, phba->msi_name[i], &phwi_context->be_eq[i]); @@ -839,13 +838,12 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba) goto free_msix_irqs; } } - phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, GFP_KERNEL); + phba->msi_name[i] = kasprintf(GFP_KERNEL, "beiscsi_mcc_%02x", + phba->shost->host_no); if (!phba->msi_name[i]) { ret = -ENOMEM; goto free_msix_irqs; } - sprintf(phba->msi_name[i], "beiscsi_mcc_%02x", - phba->shost->host_no); ret = request_irq(pci_irq_vector(pcidev, i), be_isr_mcc, 0, phba->msi_name[i], &phwi_context->be_eq[i]); if (ret) { diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h index 9bc7ef973ee1..42bb6bdb68bd 100644 --- a/drivers/scsi/be2iscsi/be_main.h +++ b/drivers/scsi/be2iscsi/be_main.h @@ -153,8 +153,6 @@ #define PAGES_REQUIRED(x) \ ((x < PAGE_SIZE) ? 1 : ((x + PAGE_SIZE - 1) / PAGE_SIZE)) -#define BEISCSI_MSI_NAME 20 /* size of msi_name string */ - #define MEM_DESCR_OFFSET 8 #define BEISCSI_DEFQ_HDR 1 #define BEISCSI_DEFQ_DATA 0 -- cgit