From bd5b6fad83ba282e94cc1a8252f5cb71dc0e1c9d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 5 Sep 2021 03:08:01 +0000 Subject: [PATCH] qla2x00t: Simplify the backwards compatibility code This patch does not change any functionality. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9509 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t/qla_bsg.c | 133 +++++++------------------------------------- qla2x00t/qla_def.h | 3 + qla2x00t/qla_gbl.h | 9 +-- qla2x00t/qla_iocb.c | 23 +------- qla2x00t/qla_isr.c | 52 +---------------- 5 files changed, 30 insertions(+), 190 deletions(-) diff --git a/qla2x00t/qla_bsg.c b/qla2x00t/qla_bsg.c index 284747c54..c8ff3432e 100644 --- a/qla2x00t/qla_bsg.c +++ b/qla2x00t/qla_bsg.c @@ -64,11 +64,7 @@ qla2x00_bsg_job_done(void *data, void *ptr, int res) { srb_t *sp = ptr; struct scsi_qla_host *vha = (scsi_qla_host_t *)data; -#ifndef NEW_LIBFC_API - struct fc_bsg_job *bsg_job = sp->u.bsg_job; -#else - struct bsg_job *bsg_job = sp->u.bsg_job; -#endif + BSG_JOB_TYPE *bsg_job = sp->u.bsg_job; struct fc_bsg_reply *bsg_reply = bsg_job->reply; bsg_reply->result = res; @@ -81,11 +77,7 @@ qla2x00_bsg_sp_free(void *data, void *ptr) { srb_t *sp = ptr; struct scsi_qla_host *vha = (scsi_qla_host_t *)data; -#ifndef NEW_LIBFC_API - struct fc_bsg_job *bsg_job = sp->u.bsg_job; -#else - struct bsg_job *bsg_job = sp->u.bsg_job; -#endif + BSG_JOB_TYPE *bsg_job = sp->u.bsg_job; struct qla_hw_data *ha = vha->hw; dma_unmap_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list, @@ -155,12 +147,7 @@ qla24xx_fcp_prio_cfg_valid(scsi_qla_host_t *vha, return ret; } -static int -#ifndef NEW_LIBFC_API -qla24xx_proc_fcp_prio_cfg_cmd(struct fc_bsg_job *bsg_job) -#else -qla24xx_proc_fcp_prio_cfg_cmd(struct bsg_job *bsg_job) -#endif +static int qla24xx_proc_fcp_prio_cfg_cmd(BSG_JOB_TYPE *bsg_job) { struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); struct fc_bsg_request *bsg_request = bsg_job->request; @@ -292,12 +279,7 @@ exit_fcp_prio_cfg: return ret; } -static int -#ifndef NEW_LIBFC_API -qla2x00_process_els(struct fc_bsg_job *bsg_job) -#else -qla2x00_process_els(struct bsg_job *bsg_job) -#endif +static int qla2x00_process_els(BSG_JOB_TYPE *bsg_job) { struct fc_bsg_request *bsg_request = bsg_job->request; struct fc_rport *rport; @@ -479,12 +461,7 @@ static uint16_t qla24xx_calc_ct_iocbs(uint16_t dsds) return iocbs; } -static int -#ifndef NEW_LIBFC_API -qla2x00_process_ct(struct fc_bsg_job *bsg_job) -#else -qla2x00_process_ct(struct bsg_job *bsg_job) -#endif +static int qla2x00_process_ct(BSG_JOB_TYPE *bsg_job) { srb_t *sp; #ifndef NEW_LIBFC_API @@ -708,12 +685,7 @@ done_reset_internal: return rval; } -static int -#ifndef NEW_LIBFC_API -qla2x00_process_loopback(struct fc_bsg_job *bsg_job) -#else -qla2x00_process_loopback(struct bsg_job *bsg_job) -#endif +static int qla2x00_process_loopback(BSG_JOB_TYPE *bsg_job) { #ifndef NEW_LIBFC_API struct Scsi_Host *host = bsg_job->shost; @@ -949,12 +921,7 @@ done_unmap_req_sg: return rval; } -static int -#ifndef NEW_LIBFC_API -qla84xx_reset(struct fc_bsg_job *bsg_job) -#else -qla84xx_reset(struct bsg_job *bsg_job) -#endif +static int qla84xx_reset(BSG_JOB_TYPE *bsg_job) { struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); struct fc_bsg_request *bsg_request = bsg_job->request; @@ -994,12 +961,7 @@ qla84xx_reset(struct bsg_job *bsg_job) return rval; } -static int -#ifndef NEW_LIBFC_API -qla84xx_updatefw(struct fc_bsg_job *bsg_job) -#else -qla84xx_updatefw(struct bsg_job *bsg_job) -#endif +static int qla84xx_updatefw(BSG_JOB_TYPE *bsg_job) { struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); struct fc_bsg_request *bsg_request = bsg_job->request; @@ -1115,12 +1077,7 @@ done_unmap_sg: return rval; } -static int -#ifndef NEW_LIBFC_API -qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job) -#else -qla84xx_mgmt_cmd(struct bsg_job *bsg_job) -#endif +static int qla84xx_mgmt_cmd(BSG_JOB_TYPE *bsg_job) { struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); struct fc_bsg_request *bsg_request = bsg_job->request; @@ -1324,12 +1281,7 @@ exit_mgmt: return rval; } -static int -#ifndef NEW_LIBFC_API -qla24xx_iidma(struct fc_bsg_job *bsg_job) -#else -qla24xx_iidma(struct bsg_job *bsg_job) -#endif +static int qla24xx_iidma(BSG_JOB_TYPE *bsg_job) { struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); struct fc_bsg_request *bsg_request = bsg_job->request; @@ -1423,13 +1375,8 @@ qla24xx_iidma(struct bsg_job *bsg_job) return rval; } -static int -#ifndef NEW_LIBFC_API -qla2x00_optrom_setup(struct fc_bsg_job *bsg_job, scsi_qla_host_t *vha, -#else -qla2x00_optrom_setup(struct bsg_job *bsg_job, scsi_qla_host_t *vha, -#endif - uint8_t is_update) +static int qla2x00_optrom_setup(BSG_JOB_TYPE *bsg_job, scsi_qla_host_t *vha, + uint8_t is_update) { struct fc_bsg_request *bsg_request = bsg_job->request; uint32_t start = 0; @@ -1497,12 +1444,7 @@ qla2x00_optrom_setup(struct bsg_job *bsg_job, scsi_qla_host_t *vha, return 0; } -static int -#ifndef NEW_LIBFC_API -qla2x00_read_optrom(struct fc_bsg_job *bsg_job) -#else -qla2x00_read_optrom(struct bsg_job *bsg_job) -#endif +static int qla2x00_read_optrom(BSG_JOB_TYPE *bsg_job) { struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); struct fc_bsg_reply *bsg_reply = bsg_job->reply; @@ -1534,12 +1476,7 @@ qla2x00_read_optrom(struct bsg_job *bsg_job) return rval; } -static int -#ifndef NEW_LIBFC_API -qla2x00_update_optrom(struct fc_bsg_job *bsg_job) -#else -qla2x00_update_optrom(struct bsg_job *bsg_job) -#endif +static int qla2x00_update_optrom(BSG_JOB_TYPE *bsg_job) { struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); struct fc_bsg_reply *bsg_reply = bsg_job->reply; @@ -1570,12 +1507,7 @@ qla2x00_update_optrom(struct bsg_job *bsg_job) return rval; } -static int -#ifndef NEW_LIBFC_API -qla2x00_update_fru_versions(struct fc_bsg_job *bsg_job) -#else -qla2x00_update_fru_versions(struct bsg_job *bsg_job) -#endif +static int qla2x00_update_fru_versions(BSG_JOB_TYPE *bsg_job) { struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); struct fc_bsg_reply *bsg_reply = bsg_job->reply; @@ -1626,12 +1558,7 @@ done: return 0; } -static int -#ifndef NEW_LIBFC_API -qla2x00_read_fru_status(struct fc_bsg_job *bsg_job) -#else -qla2x00_read_fru_status(struct bsg_job *bsg_job) -#endif +static int qla2x00_read_fru_status(BSG_JOB_TYPE *bsg_job) { struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); struct fc_bsg_reply *bsg_reply = bsg_job->reply; @@ -1680,12 +1607,7 @@ done: return 0; } -static int -#ifndef NEW_LIBFC_API -qla2x00_write_fru_status(struct fc_bsg_job *bsg_job) -#else -qla2x00_write_fru_status(struct bsg_job *bsg_job) -#endif +static int qla2x00_write_fru_status(BSG_JOB_TYPE *bsg_job) { struct fc_bsg_reply *bsg_reply = bsg_job->reply; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -1730,12 +1652,7 @@ done: return 0; } -static int -#ifndef NEW_LIBFC_API -qla2x00_process_vendor_specific(struct fc_bsg_job *bsg_job) -#else -qla2x00_process_vendor_specific(struct bsg_job *bsg_job) -#endif +static int qla2x00_process_vendor_specific(BSG_JOB_TYPE *bsg_job) { struct fc_bsg_request *bsg_request = bsg_job->request; struct fc_bsg_reply *bsg_reply = bsg_job->reply; @@ -1783,12 +1700,7 @@ qla2x00_process_vendor_specific(struct bsg_job *bsg_job) } } -int -#ifndef NEW_LIBFC_API -qla24xx_bsg_request(struct fc_bsg_job *bsg_job) -#else -qla24xx_bsg_request(struct bsg_job *bsg_job) -#endif +int qla24xx_bsg_request(BSG_JOB_TYPE *bsg_job) { struct fc_bsg_request *bsg_request = bsg_job->request; struct fc_bsg_reply *bsg_reply = bsg_job->reply; @@ -1849,12 +1761,7 @@ qla24xx_bsg_request(struct bsg_job *bsg_job) return ret; } -int -#ifndef NEW_LIBFC_API -qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job) -#else -qla24xx_bsg_timeout(struct bsg_job *bsg_job) -#endif +int qla24xx_bsg_timeout(BSG_JOB_TYPE *bsg_job) { struct fc_bsg_request *bsg_request = bsg_job->request; struct fc_bsg_reply *bsg_reply = bsg_job->reply; diff --git a/qla2x00t/qla_def.h b/qla2x00t/qla_def.h index 049cacab8..f29441a52 100644 --- a/qla2x00t/qla_def.h +++ b/qla2x00t/qla_def.h @@ -31,6 +31,9 @@ defined(CONFIG_SUSE_KERNEL) && \ LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) #define NEW_LIBFC_API +#define BSG_JOB_TYPE struct bsg_job +#else +#define BSG_JOB_TYPE struct fc_bsg_job #endif #ifdef NEW_LIBFC_API diff --git a/qla2x00t/qla_gbl.h b/qla2x00t/qla_gbl.h index 7b94d6093..0bd4d3360 100644 --- a/qla2x00t/qla_gbl.h +++ b/qla2x00t/qla_gbl.h @@ -605,13 +605,8 @@ extern int qla82xx_mbx_beacon_ctl(scsi_qla_host_t *, int); extern void qla82xx_clear_pending_mbx(scsi_qla_host_t *); /* BSG related functions */ -#ifdef NEW_LIBFC_API -extern int qla24xx_bsg_request(struct bsg_job *); -extern int qla24xx_bsg_timeout(struct bsg_job *); -#else -extern int qla24xx_bsg_request(struct fc_bsg_job *); -extern int qla24xx_bsg_timeout(struct fc_bsg_job *); -#endif +extern int qla24xx_bsg_request(BSG_JOB_TYPE *); +extern int qla24xx_bsg_timeout(BSG_JOB_TYPE *); extern int qla84xx_reset_chip(scsi_qla_host_t *, uint16_t); extern int qla2x00_issue_iocb_timeout(scsi_qla_host_t *, void *, dma_addr_t, size_t, uint32_t); diff --git a/qla2x00t/qla_iocb.c b/qla2x00t/qla_iocb.c index fe327ea4f..528094ca0 100644 --- a/qla2x00t/qla_iocb.c +++ b/qla2x00t/qla_iocb.c @@ -2099,12 +2099,8 @@ qla24xx_tm_iocb(srb_t *sp, struct tsk_mgmt_entry *tsk) static void qla24xx_els_iocb(srb_t *sp, struct els_entry_24xx *els_iocb) { -#ifndef NEW_LIBFC_API - struct fc_bsg_job *bsg_job = sp->u.bsg_job; -#else - struct bsg_job *bsg_job = sp->u.bsg_job; + BSG_JOB_TYPE *bsg_job = sp->u.bsg_job; struct fc_bsg_request *bsg_request = bsg_job->request; -#endif els_iocb->entry_type = ELS_IOCB_TYPE; els_iocb->entry_count = 1; @@ -2119,13 +2115,8 @@ qla24xx_els_iocb(srb_t *sp, struct els_entry_24xx *els_iocb) els_iocb->opcode = sp->type == SRB_ELS_CMD_RPT ? -#ifndef NEW_LIBFC_API - bsg_job->request->rqst_data.r_els.els_code : - bsg_job->request->rqst_data.h_els.command_code; -#else bsg_request->rqst_data.r_els.els_code : bsg_request->rqst_data.h_els.command_code; -#endif els_iocb->port_id[0] = sp->fcport->d_id.b.al_pa; els_iocb->port_id[1] = sp->fcport->d_id.b.area; els_iocb->port_id[2] = sp->fcport->d_id.b.domain; @@ -2160,11 +2151,7 @@ qla2x00_ct_iocb(srb_t *sp, ms_iocb_entry_t *ct_iocb) uint16_t tot_dsds; scsi_qla_host_t *vha = sp->fcport->vha; struct qla_hw_data *ha = vha->hw; -#ifndef NEW_LIBFC_API - struct fc_bsg_job *bsg_job = sp->u.bsg_job; -#else - struct bsg_job *bsg_job = sp->u.bsg_job; -#endif + BSG_JOB_TYPE *bsg_job = sp->u.bsg_job; int loop_iterartion = 0; int entry_count = 1; @@ -2239,11 +2226,7 @@ qla24xx_ct_iocb(srb_t *sp, struct ct_entry_24xx *ct_iocb) uint16_t tot_dsds; scsi_qla_host_t *vha = sp->fcport->vha; struct qla_hw_data *ha = vha->hw; -#ifndef NEW_LIBFC_API - struct fc_bsg_job *bsg_job = sp->u.bsg_job; -#else - struct bsg_job *bsg_job = sp->u.bsg_job; -#endif + BSG_JOB_TYPE *bsg_job = sp->u.bsg_job; int loop_iterartion = 0; int entry_count = 1; diff --git a/qla2x00t/qla_isr.c b/qla2x00t/qla_isr.c index f591b0efa..d5b11813a 100644 --- a/qla2x00t/qla_isr.c +++ b/qla2x00t/qla_isr.c @@ -1083,12 +1083,8 @@ qla2x00_ct_entry(scsi_qla_host_t *vha, struct req_que *req, const char func[] = "CT_IOCB"; const char *type; srb_t *sp; -#ifndef NEW_LIBFC_API - struct fc_bsg_job *bsg_job; -#else - struct bsg_job *bsg_job; + BSG_JOB_TYPE *bsg_job; struct fc_bsg_reply *bsg_reply; -#endif uint16_t comp_status; int res; @@ -1097,9 +1093,7 @@ qla2x00_ct_entry(scsi_qla_host_t *vha, struct req_que *req, return; bsg_job = sp->u.bsg_job; -#ifdef NEW_LIBFC_API bsg_reply = bsg_job->reply; -#endif type = "ct pass-through"; @@ -1108,52 +1102,32 @@ qla2x00_ct_entry(scsi_qla_host_t *vha, struct req_que *req, /* return FC_CTELS_STATUS_OK and leave the decoding of the ELS/CT * fc payload to the caller */ -#ifndef NEW_LIBFC_API - bsg_job->reply->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK; -#else bsg_reply->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK; -#endif bsg_job->reply_len = sizeof(struct fc_bsg_reply); if (comp_status != CS_COMPLETE) { if (comp_status == CS_DATA_UNDERRUN) { res = DID_OK << 16; -#ifndef NEW_LIBFC_API - bsg_job->reply->reply_payload_rcv_len = -#else bsg_reply->reply_payload_rcv_len = -#endif le16_to_cpu(((sts_entry_t *)pkt)->rsp_info_len); ql_log(ql_log_warn, vha, 0x5048, "CT pass-through-%s error " "comp_status-status=0x%x total_byte = 0x%x.\n", type, comp_status, -#ifndef NEW_LIBFC_API - bsg_job->reply->reply_payload_rcv_len); -#else bsg_reply->reply_payload_rcv_len); -#endif } else { ql_log(ql_log_warn, vha, 0x5049, "CT pass-through-%s error " "comp_status-status=0x%x.\n", type, comp_status); res = DID_ERROR << 16; -#ifndef NEW_LIBFC_API - bsg_job->reply->reply_payload_rcv_len = 0; -#else bsg_reply->reply_payload_rcv_len = 0; -#endif } ql_dump_buffer(ql_dbg_async + ql_dbg_buffer, vha, 0x5035, (uint8_t *)pkt, sizeof(*pkt)); } else { res = DID_OK << 16; -#ifndef NEW_LIBFC_API - bsg_job->reply->reply_payload_rcv_len = -#else bsg_reply->reply_payload_rcv_len = -#endif bsg_job->reply_payload.payload_len; bsg_job->reply_len = 0; } @@ -1167,12 +1141,8 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req, const char func[] = "ELS_CT_IOCB"; const char *type; srb_t *sp; -#ifndef NEW_LIBFC_API - struct fc_bsg_job *bsg_job; -#else - struct bsg_job *bsg_job; + BSG_JOB_TYPE *bsg_job; struct fc_bsg_reply *bsg_reply; -#endif uint16_t comp_status; uint32_t fw_status[3]; uint8_t *fw_sts_ptr; @@ -1181,9 +1151,7 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req, if (!sp) return; bsg_job = sp->u.bsg_job; -#ifdef NEW_LIBFC_API bsg_reply = bsg_job->reply; -#endif type = NULL; switch (sp->type) { @@ -1207,20 +1175,12 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req, /* return FC_CTELS_STATUS_OK and leave the decoding of the ELS/CT * fc payload to the caller */ -#ifndef NEW_LIBFC_API - bsg_job->reply->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK; -#else bsg_reply->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK; -#endif bsg_job->reply_len = sizeof(struct fc_bsg_reply) + sizeof(fw_status); if (comp_status != CS_COMPLETE) { if (comp_status == CS_DATA_UNDERRUN) { -#ifndef NEW_LIBFC_API - bsg_job->reply->reply_payload_rcv_len = -#else bsg_reply->reply_payload_rcv_len = -#endif le16_to_cpu(((struct els_sts_entry_24xx *)pkt)->total_byte_count); ql_dbg(ql_dbg_user, vha, 0x503f, @@ -1241,11 +1201,7 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req, pkt)->error_subcode_1), le16_to_cpu(((struct els_sts_entry_24xx *) pkt)->error_subcode_2)); -#ifndef NEW_LIBFC_API - bsg_job->reply->reply_payload_rcv_len = 0; -#else bsg_reply->reply_payload_rcv_len = 0; -#endif fw_sts_ptr = bsg_job_sense(bsg_job) + sizeof(struct fc_bsg_reply); memcpy(fw_sts_ptr, fw_status, sizeof(fw_status)); @@ -1253,11 +1209,7 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req, ql_dump_buffer(ql_dbg_user + ql_dbg_buffer, vha, 0x5056, (uint8_t *)pkt, sizeof(*pkt)); } else { -#ifndef NEW_LIBFC_API - bsg_job->reply->reply_payload_rcv_len = bsg_job->reply_payload.payload_len; -#else bsg_reply->reply_payload_rcv_len = bsg_job->reply_payload.payload_len; -#endif bsg_job->reply_len = 0; } sp->done(vha, sp, 0);