diff options
author | Himanshu Madhani <hmadhani@marvell.com> | 2020-02-12 13:44:26 -0800 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2020-02-24 12:34:29 -0500 |
commit | 84f7d2e7b1f5203050b47cfa65e284182d32f203 (patch) | |
tree | 3ffdf43dd1136bf50f019a770fb4ac22e9fae587 /drivers/scsi/qla2xxx | |
parent | 4879237cd28eebb9350a7e6d970677997abe2b9d (diff) |
scsi: qla2xxx: Fix RDP response size
This patch fixes RDP length in case when driver needs to reduce length of
RDP response
Link: https://lore.kernel.org/r/20200212214436.25532-16-hmadhani@marvell.com
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/qla2xxx')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_os.c | 53 |
1 files changed, 19 insertions, 34 deletions
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 0e6bad0e4c21..f5a264f0afd6 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -5775,6 +5775,7 @@ qla25xx_rdp_rsp_reduce_size(struct scsi_qla_host *vha, { char fwstr[16]; u32 sid = purex->s_id[2] << 16 | purex->s_id[1] << 8 | purex->s_id[0]; + struct port_database_24xx *pdb; /* Domain Controller is always logged-out. */ /* if RDP request is not from Domain Controller: */ @@ -5783,6 +5784,24 @@ qla25xx_rdp_rsp_reduce_size(struct scsi_qla_host *vha, ql_dbg(ql_dbg_init, vha, 0x0181, "%s: s_id=%#x\n", __func__, sid); + pdb = kzalloc(sizeof(*pdb), GFP_KERNEL); + if (!pdb) { + ql_dbg(ql_dbg_init, vha, 0x0181, + "%s: Failed allocate pdb\n", __func__); + } else if (qla24xx_get_port_database(vha, purex->nport_handle, pdb)) { + ql_dbg(ql_dbg_init, vha, 0x0181, + "%s: Failed get pdb sid=%x\n", __func__, sid); + } else if (pdb->current_login_state != PDS_PLOGI_COMPLETE && + pdb->current_login_state != PDS_PRLI_COMPLETE) { + ql_dbg(ql_dbg_init, vha, 0x0181, + "%s: Port not logged in sid=%#x\n", __func__, sid); + } else { + /* RDP request is from logged in port */ + kfree(pdb); + return false; + } + kfree(pdb); + vha->hw->isp_ops->fw_version_str(vha, fwstr, sizeof(fwstr)); fwstr[strcspn(fwstr, " ")] = 0; /* if FW version allows RDP response length upto 2048 bytes: */ @@ -5901,7 +5920,6 @@ void qla24xx_process_purex_rdp(struct scsi_qla_host *vha, void *pkt) { struct qla_hw_data *ha = vha->hw; struct purex_entry_24xx *purex = pkt; - struct port_database_24xx *pdb = NULL; dma_addr_t rsp_els_dma; dma_addr_t rsp_payload_dma; dma_addr_t stat_dma; @@ -5986,34 +6004,6 @@ void qla24xx_process_purex_rdp(struct scsi_qla_host *vha, void *pkt) rsp_els->rx_address = 0; rsp_els->rx_len = 0; - if (sizeof(*rsp_payload) <= 0x100) - goto accept; - - pdb = kzalloc(sizeof(*pdb), GFP_KERNEL); - if (!pdb) - goto reduce; - - rval = qla24xx_get_port_database(vha, purex->nport_handle, pdb); - if (rval) - goto reduce; - - if (pdb->port_id[0] != purex->s_id[2] || - pdb->port_id[1] != purex->s_id[1] || - pdb->port_id[2] != purex->s_id[0]) - goto reduce; - - if (pdb->current_login_state == PDS_PLOGI_COMPLETE || - pdb->current_login_state == PDS_PRLI_COMPLETE) - goto accept; - -reduce: - ql_dbg(ql_dbg_init, vha, 0x016e, "Requesting port is not logged in.\n"); - rsp_els->tx_byte_count = rsp_els->tx_len = - offsetof(struct rdp_rsp_payload, buffer_credit_desc); - ql_dbg(ql_dbg_init, vha, 0x016f, "Reduced response payload size %u.\n", - rsp_els->tx_byte_count); - -accept: /* Prepare Response Payload */ rsp_payload->hdr.cmd = cpu_to_be32(0x2 << 24); /* LS_ACC */ rsp_payload->hdr.len = cpu_to_be32( @@ -6131,9 +6121,6 @@ accept: vha->fabric_port_name, sizeof(rsp_payload->port_name_direct_desc.WWPN)); - if (rsp_els->tx_byte_count < sizeof(*rsp_payload)) - goto send; - if (bbc) { memset(bbc, 0, sizeof(*bbc)); rval = qla24xx_get_buffer_credits(vha, bbc, bbc_dma); @@ -6333,8 +6320,6 @@ send: } dealloc: - kfree(pdb); - if (bbc) dma_free_coherent(&ha->pdev->dev, sizeof(*bbc), bbc, bbc_dma); |