diff --git a/qla2x00t-32gbit/qla_bsg.c b/qla2x00t-32gbit/qla_bsg.c index 17d42658a..850ac4114 100644 --- a/qla2x00t-32gbit/qla_bsg.c +++ b/qla2x00t-32gbit/qla_bsg.c @@ -11,12 +11,36 @@ #include #include +#ifndef NEW_LIBFC_API +static inline struct Scsi_Host *fc_bsg_to_shost(struct fc_bsg_job *job) +{ + return job->shost; +} + +static inline struct fc_rport *fc_bsg_to_rport(struct fc_bsg_job *job) +{ + return job->rport; +} + +static inline void bsg_job_done_backport(struct fc_bsg_job *job, int result, + unsigned int reply_payload_rcv_len) +{ + job->job_done(job); +} + +#define bsg_job_done bsg_job_done_backport +#endif + /* BSG support for ELS/CT pass through */ void qla2x00_bsg_job_done(void *ptr, int res) { srb_t *sp = ptr; +#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 struct fc_bsg_reply *bsg_reply = bsg_job->reply; bsg_reply->result = res; @@ -30,7 +54,11 @@ qla2x00_bsg_sp_free(void *ptr) { srb_t *sp = ptr; struct qla_hw_data *ha = sp->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 struct fc_bsg_request *bsg_request = bsg_job->request; struct qla_mt_iocb_rqst_fx00 *piocb_rqst; @@ -117,8 +145,11 @@ qla24xx_fcp_prio_cfg_valid(scsi_qla_host_t *vha, return ret; } -static int -qla24xx_proc_fcp_prio_cfg_cmd(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla24xx_proc_fcp_prio_cfg_cmd(struct fc_bsg_job *bsg_job) +#else +static int qla24xx_proc_fcp_prio_cfg_cmd(struct bsg_job *bsg_job) +#endif { struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); struct fc_bsg_request *bsg_request = bsg_job->request; @@ -246,8 +277,11 @@ exit_fcp_prio_cfg: return ret; } -static int -qla2x00_process_els(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla2x00_process_els(struct fc_bsg_job *bsg_job) +#else +static int qla2x00_process_els(struct bsg_job *bsg_job) +#endif { struct fc_bsg_request *bsg_request = bsg_job->request; struct fc_rport *rport; @@ -425,8 +459,11 @@ qla24xx_calc_ct_iocbs(uint16_t dsds) return iocbs; } -static int -qla2x00_process_ct(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla2x00_process_ct(struct fc_bsg_job *bsg_job) +#else +static int qla2x00_process_ct(struct bsg_job *bsg_job) +#endif { srb_t *sp; struct fc_bsg_request *bsg_request = bsg_job->request; @@ -703,8 +740,11 @@ done_set_internal: return rval; } -static int -qla2x00_process_loopback(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla2x00_process_loopback(struct fc_bsg_job *bsg_job) +#else +static int qla2x00_process_loopback(struct bsg_job *bsg_job) +#endif { struct fc_bsg_request *bsg_request = bsg_job->request; struct fc_bsg_reply *bsg_reply = bsg_job->reply; @@ -919,7 +959,7 @@ qla2x00_process_loopback(struct bsg_job *bsg_job) bsg_job->reply_len = sizeof(struct fc_bsg_reply) + sizeof(response) + sizeof(uint8_t); - fw_sts_ptr = bsg_job->reply + sizeof(struct fc_bsg_reply); + fw_sts_ptr = bsg_job_sense(bsg_job) + sizeof(struct fc_bsg_reply); memcpy(bsg_job->reply + sizeof(struct fc_bsg_reply), response, sizeof(response)); fw_sts_ptr += sizeof(response); @@ -945,8 +985,11 @@ done_unmap_req_sg: return rval; } -static int -qla84xx_reset(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla84xx_reset(struct fc_bsg_job *bsg_job) +#else +static int qla84xx_reset(struct bsg_job *bsg_job) +#endif { struct fc_bsg_request *bsg_request = bsg_job->request; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -981,8 +1024,11 @@ qla84xx_reset(struct bsg_job *bsg_job) return rval; } -static int -qla84xx_updatefw(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla84xx_updatefw(struct fc_bsg_job *bsg_job) +#else +static int qla84xx_updatefw(struct bsg_job *bsg_job) +#endif { struct fc_bsg_request *bsg_request = bsg_job->request; struct fc_bsg_reply *bsg_reply = bsg_job->reply; @@ -1092,8 +1138,11 @@ done_unmap_sg: return rval; } -static int -qla84xx_mgmt_cmd(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job) +#else +static int qla84xx_mgmt_cmd(struct bsg_job *bsg_job) +#endif { struct fc_bsg_request *bsg_request = bsg_job->request; struct fc_bsg_reply *bsg_reply = bsg_job->reply; @@ -1289,8 +1338,11 @@ exit_mgmt: return rval; } -static int -qla24xx_iidma(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla24xx_iidma(struct fc_bsg_job *bsg_job) +#else +static int qla24xx_iidma(struct bsg_job *bsg_job) +#endif { struct fc_bsg_request *bsg_request = bsg_job->request; struct fc_bsg_reply *bsg_reply = bsg_job->reply; @@ -1378,9 +1430,13 @@ qla24xx_iidma(struct bsg_job *bsg_job) return rval; } -static int -qla2x00_optrom_setup(struct bsg_job *bsg_job, scsi_qla_host_t *vha, - uint8_t is_update) +#ifndef NEW_LIBFC_API +static int qla2x00_optrom_setup(struct fc_bsg_job *bsg_job, + scsi_qla_host_t *vha, uint8_t is_update) +#else +static int qla2x00_optrom_setup(struct bsg_job *bsg_job, + scsi_qla_host_t *vha, uint8_t is_update) +#endif { struct fc_bsg_request *bsg_request = bsg_job->request; uint32_t start = 0; @@ -1447,8 +1503,11 @@ qla2x00_optrom_setup(struct bsg_job *bsg_job, scsi_qla_host_t *vha, return 0; } -static int -qla2x00_read_optrom(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla2x00_read_optrom(struct fc_bsg_job *bsg_job) +#else +static int qla2x00_read_optrom(struct bsg_job *bsg_job) +#endif { struct fc_bsg_reply *bsg_reply = bsg_job->reply; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -1484,8 +1543,11 @@ qla2x00_read_optrom(struct bsg_job *bsg_job) return rval; } -static int -qla2x00_update_optrom(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla2x00_update_optrom(struct fc_bsg_job *bsg_job) +#else +static int qla2x00_update_optrom(struct bsg_job *bsg_job) +#endif { struct fc_bsg_reply *bsg_reply = bsg_job->reply; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -1520,8 +1582,11 @@ qla2x00_update_optrom(struct bsg_job *bsg_job) return rval; } -static int -qla2x00_update_fru_versions(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla2x00_update_fru_versions(struct fc_bsg_job *bsg_job) +#else +static int qla2x00_update_fru_versions(struct bsg_job *bsg_job) +#endif { struct fc_bsg_reply *bsg_reply = bsg_job->reply; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -1572,8 +1637,11 @@ done: return 0; } -static int -qla2x00_read_fru_status(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla2x00_read_fru_status(struct fc_bsg_job *bsg_job) +#else +static int qla2x00_read_fru_status(struct bsg_job *bsg_job) +#endif { struct fc_bsg_reply *bsg_reply = bsg_job->reply; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -1622,8 +1690,11 @@ done: return 0; } -static int -qla2x00_write_fru_status(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla2x00_write_fru_status(struct fc_bsg_job *bsg_job) +#else +static int qla2x00_write_fru_status(struct bsg_job *bsg_job) +#endif { struct fc_bsg_reply *bsg_reply = bsg_job->reply; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -1668,8 +1739,11 @@ done: return 0; } -static int -qla2x00_write_i2c(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla2x00_write_i2c(struct fc_bsg_job *bsg_job) +#else +static int qla2x00_write_i2c(struct bsg_job *bsg_job) +#endif { struct fc_bsg_reply *bsg_reply = bsg_job->reply; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -1713,8 +1787,11 @@ done: return 0; } -static int -qla2x00_read_i2c(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla2x00_read_i2c(struct fc_bsg_job *bsg_job) +#else +static int qla2x00_read_i2c(struct bsg_job *bsg_job) +#endif { struct fc_bsg_reply *bsg_reply = bsg_job->reply; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -1762,8 +1839,11 @@ done: return 0; } -static int -qla24xx_process_bidir_cmd(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla24xx_process_bidir_cmd(struct fc_bsg_job *bsg_job) +#else +static int qla24xx_process_bidir_cmd(struct bsg_job *bsg_job) +#endif { struct fc_bsg_reply *bsg_reply = bsg_job->reply; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -1941,8 +2021,11 @@ done: return 0; } -static int -qlafx00_mgmt_cmd(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qlafx00_mgmt_cmd(struct fc_bsg_job *bsg_job) +#else +static int qlafx00_mgmt_cmd(struct bsg_job *bsg_job) +#endif { struct fc_bsg_request *bsg_request = bsg_job->request; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -2064,8 +2147,11 @@ done: return rval; } -static int -qla26xx_serdes_op(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla26xx_serdes_op(struct fc_bsg_job *bsg_job) +#else +static int qla26xx_serdes_op(struct bsg_job *bsg_job) +#endif { struct fc_bsg_reply *bsg_reply = bsg_job->reply; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -2106,8 +2192,11 @@ qla26xx_serdes_op(struct bsg_job *bsg_job) return 0; } -static int -qla8044_serdes_op(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla8044_serdes_op(struct fc_bsg_job *bsg_job) +#else +static int qla8044_serdes_op(struct bsg_job *bsg_job) +#endif { struct fc_bsg_reply *bsg_reply = bsg_job->reply; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -2148,8 +2237,11 @@ qla8044_serdes_op(struct bsg_job *bsg_job) return 0; } -static int -qla27xx_get_flash_upd_cap(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla27xx_get_flash_upd_cap(struct fc_bsg_job *bsg_job) +#else +static int qla27xx_get_flash_upd_cap(struct bsg_job *bsg_job) +#endif { struct fc_bsg_reply *bsg_reply = bsg_job->reply; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -2180,8 +2272,11 @@ qla27xx_get_flash_upd_cap(struct bsg_job *bsg_job) return 0; } -static int -qla27xx_set_flash_upd_cap(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla27xx_set_flash_upd_cap(struct fc_bsg_job *bsg_job) +#else +static int qla27xx_set_flash_upd_cap(struct bsg_job *bsg_job) +#endif { struct fc_bsg_reply *bsg_reply = bsg_job->reply; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -2226,8 +2321,11 @@ qla27xx_set_flash_upd_cap(struct bsg_job *bsg_job) return 0; } -static int -qla27xx_get_bbcr_data(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla27xx_get_bbcr_data(struct fc_bsg_job *bsg_job) +#else +static int qla27xx_get_bbcr_data(struct bsg_job *bsg_job) +#endif { struct fc_bsg_reply *bsg_reply = bsg_job->reply; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -2285,8 +2383,11 @@ done: return 0; } -static int -qla2x00_get_priv_stats(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla2x00_get_priv_stats(struct fc_bsg_job *bsg_job) +#else +static int qla2x00_get_priv_stats(struct bsg_job *bsg_job) +#endif { struct fc_bsg_request *bsg_request = bsg_job->request; struct fc_bsg_reply *bsg_reply = bsg_job->reply; @@ -2344,8 +2445,11 @@ qla2x00_get_priv_stats(struct bsg_job *bsg_job) return 0; } -static int -qla2x00_do_dport_diagnostics(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla2x00_do_dport_diagnostics(struct fc_bsg_job *bsg_job) +#else +static int qla2x00_do_dport_diagnostics(struct bsg_job *bsg_job) +#endif { struct fc_bsg_reply *bsg_reply = bsg_job->reply; struct Scsi_Host *host = fc_bsg_to_shost(bsg_job); @@ -2387,8 +2491,11 @@ qla2x00_do_dport_diagnostics(struct bsg_job *bsg_job) return 0; } -static int -qla2x00_process_vendor_specific(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +static int qla2x00_process_vendor_specific(struct fc_bsg_job *bsg_job) +#else +static int qla2x00_process_vendor_specific(struct bsg_job *bsg_job) +#endif { struct fc_bsg_request *bsg_request = bsg_job->request; @@ -2465,8 +2572,11 @@ qla2x00_process_vendor_specific(struct bsg_job *bsg_job) } } -int -qla24xx_bsg_request(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +int qla24xx_bsg_request(struct fc_bsg_job *bsg_job) +#else +int qla24xx_bsg_request(struct bsg_job *bsg_job) +#endif { struct fc_bsg_request *bsg_request = bsg_job->request; struct fc_bsg_reply *bsg_reply = bsg_job->reply; @@ -2518,8 +2628,11 @@ qla24xx_bsg_request(struct bsg_job *bsg_job) return ret; } -int -qla24xx_bsg_timeout(struct bsg_job *bsg_job) +#ifndef NEW_LIBFC_API +int qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job) +#else +int qla24xx_bsg_timeout(struct bsg_job *bsg_job) +#endif { struct fc_bsg_reply *bsg_reply = bsg_job->reply; scsi_qla_host_t *vha = shost_priv(fc_bsg_to_shost(bsg_job)); diff --git a/qla2x00t-32gbit/qla_def.h b/qla2x00t-32gbit/qla_def.h index 3d46975a5..68d816fe4 100644 --- a/qla2x00t-32gbit/qla_def.h +++ b/qla2x00t-32gbit/qla_def.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -34,6 +35,12 @@ #include #include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) || \ + defined(CONFIG_SUSE_KERNEL) && \ + LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) +#define NEW_LIBFC_API +#endif + #include "qla_bsg.h" #include "qla_nx.h" #include "qla_nx2.h" @@ -548,7 +555,11 @@ typedef struct srb { struct completion comp; union { struct srb_iocb iocb_cmd; +#ifndef NEW_LIBFC_API + struct fc_bsg_job *bsg_job; +#else struct bsg_job *bsg_job; +#endif struct srb_cmd scmd; } u; void (*done)(void *, int); diff --git a/qla2x00t-32gbit/qla_gbl.h b/qla2x00t-32gbit/qla_gbl.h index 4eefe69ca..20d12ac2e 100644 --- a/qla2x00t-32gbit/qla_gbl.h +++ b/qla2x00t-32gbit/qla_gbl.h @@ -833,8 +833,13 @@ extern int qla8044_read_temperature(scsi_qla_host_t *); extern int qla2x00_read_sfp_dev(struct scsi_qla_host *, char *, int); /* BSG related functions */ +#ifndef NEW_LIBFC_API +extern int qla24xx_bsg_request(struct fc_bsg_job *); +extern int qla24xx_bsg_timeout(struct fc_bsg_job *); +#else extern int qla24xx_bsg_request(struct bsg_job *); extern int qla24xx_bsg_timeout(struct bsg_job *); +#endif 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-32gbit/qla_iocb.c b/qla2x00t-32gbit/qla_iocb.c index 456a41d2e..b00012a87 100644 --- a/qla2x00t-32gbit/qla_iocb.c +++ b/qla2x00t-32gbit/qla_iocb.c @@ -2949,7 +2949,11 @@ done: 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; +#endif struct fc_bsg_request *bsg_request = bsg_job->request; els_iocb->entry_type = ELS_IOCB_TYPE; @@ -3003,7 +3007,11 @@ qla2x00_ct_iocb(srb_t *sp, ms_iocb_entry_t *ct_iocb) uint16_t tot_dsds; scsi_qla_host_t *vha = sp->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 int loop_iterartion = 0; int entry_count = 1; @@ -3080,7 +3088,11 @@ qla24xx_ct_iocb(srb_t *sp, struct ct_entry_24xx *ct_iocb) uint16_t cmd_dsds, rsp_dsds; scsi_qla_host_t *vha = sp->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 int entry_count = 1; cont_a64_entry_t *cont_pkt = NULL; @@ -3743,7 +3755,11 @@ qla25xx_build_bidir_iocb(srb_t *sp, struct scsi_qla_host *vha, struct scatterlist *sg; int index; int entry_count = 1; +#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 /*Update entry type to indicate bidir command */ *((uint32_t *)(&cmd_pkt->entry_type)) = diff --git a/qla2x00t-32gbit/qla_isr.c b/qla2x00t-32gbit/qla_isr.c index 69bbea923..3a416068e 100644 --- a/qla2x00t-32gbit/qla_isr.c +++ b/qla2x00t-32gbit/qla_isr.c @@ -10,7 +10,17 @@ #include #include #include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0) #include +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) +/* + * From commit 128b6f9fdd9a ("t10-pi: Move opencoded contants to common header") + * # v4.13. + */ +#define T10_PI_APP_ESCAPE cpu_to_be16(0xffff) +#define T10_PI_REF_ESCAPE cpu_to_be32(0xffffffff) +#endif #include #include #include @@ -1473,7 +1483,11 @@ 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; +#endif struct fc_bsg_reply *bsg_reply; uint16_t comp_status; int res = 0; @@ -1545,7 +1559,11 @@ 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; +#endif struct fc_bsg_reply *bsg_reply; uint16_t comp_status; uint32_t fw_status[3]; @@ -2082,7 +2100,7 @@ qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t par_sense_len, if (sense_len) { ql_dbg(ql_dbg_io + ql_dbg_buffer, vha, 0x301c, "Check condition Sense data, nexus%ld:%d:%llu cmd=%p.\n", - sp->vha->host_no, cp->device->id, cp->device->lun, + sp->vha->host_no, cp->device->id, (u64)cp->device->lun, cp); ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x302b, cp->sense_buffer, sense_len); @@ -2233,7 +2251,11 @@ qla25xx_process_bidir_status_iocb(scsi_qla_host_t *vha, void *pkt, uint16_t scsi_status; uint16_t thread_id; uint32_t rval = EXT_STATUS_OK; +#ifndef NEW_LIBFC_API + struct fc_bsg_job *bsg_job = NULL; +#else struct bsg_job *bsg_job = NULL; +#endif struct fc_bsg_request *bsg_request; struct fc_bsg_reply *bsg_reply; sts_entry_t *sts; @@ -2739,7 +2761,7 @@ check_scsi_status: ql_log(ql_log_info, fcport->vha, 0x3022, "CS_DMA error: 0x%x-0x%x (0x%x) nexus=%ld:%d:%llu portid=%06x oxid=0x%x cdb=%10phN len=0x%x rsp_info=0x%x resid=0x%x fw_resid=0x%x sp=%p cp=%p.\n", comp_status, scsi_status, res, vha->host_no, - cp->device->id, cp->device->lun, fcport->d_id.b24, + cp->device->id, (u64)cp->device->lun, fcport->d_id.b24, ox_id, cp->cmnd, scsi_bufflen(cp), rsp_info_len, resid_len, fw_resid_len, sp, cp); ql_dump_buffer(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe0ee, @@ -2758,7 +2780,7 @@ out: "portid=%02x%02x%02x oxid=0x%x cdb=%10phN len=0x%x " "rsp_info=0x%x resid=0x%x fw_resid=0x%x sp=%p cp=%p.\n", comp_status, scsi_status, res, vha->host_no, - cp->device->id, cp->device->lun, fcport->d_id.b.domain, + cp->device->id, (u64)cp->device->lun, fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa, ox_id, cp->cmnd, scsi_bufflen(cp), rsp_info_len, resid_len, fw_resid_len, sp, cp); diff --git a/qla2x00t-32gbit/qla_mr.c b/qla2x00t-32gbit/qla_mr.c index 60f964c53..7d4caab81 100644 --- a/qla2x00t-32gbit/qla_mr.c +++ b/qla2x00t-32gbit/qla_mr.c @@ -1804,6 +1804,16 @@ qla2x00_fxdisc_sp_done(void *ptr, int res) complete(&lio->u.fxiocb.fxiocb_comp); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) +static u64 ktime_get_real_seconds(void) +{ + struct timeval tv; + + do_gettimeofday(&tv); + return tv.tv_sec; +} +#endif + int qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint16_t fx_type) { @@ -2164,7 +2174,7 @@ qlafx00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t par_sense_len, if (sense_len) { ql_dbg(ql_dbg_io + ql_dbg_buffer, vha, 0x3039, "Check condition Sense data, nexus%ld:%d:%llu cmd=%p.\n", - sp->vha->host_no, cp->device->id, cp->device->lun, + sp->vha->host_no, cp->device->id, (u64)cp->device->lun, cp); ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x3049, cp->sense_buffer, sense_len); @@ -2209,7 +2219,11 @@ qlafx00_ioctl_iosb_entry(scsi_qla_host_t *vha, struct req_que *req, { const char func[] = "IOSB_IOCB"; srb_t *sp; +#ifndef NEW_LIBFC_API + struct fc_bsg_job *bsg_job; +#else struct bsg_job *bsg_job; +#endif struct fc_bsg_reply *bsg_reply; struct srb_iocb *iocb_job; int res = 0; @@ -2246,7 +2260,8 @@ qlafx00_ioctl_iosb_entry(scsi_qla_host_t *vha, struct req_que *req, memcpy(fstatus.reserved_3, pkt->reserved_2, 20 * sizeof(uint8_t)); - fw_sts_ptr = bsg_job->reply + sizeof(struct fc_bsg_reply); + fw_sts_ptr = bsg_job_sense(bsg_job) + + sizeof(struct fc_bsg_reply); memcpy(fw_sts_ptr, (uint8_t *)&fstatus, sizeof(struct qla_mt_iocb_rsp_fx00)); @@ -2533,7 +2548,7 @@ check_scsi_status: "rsp_info=%p resid=0x%x fw_resid=0x%x sense_len=0x%x, " "par_sense_len=0x%x, rsp_info_len=0x%x\n", comp_status, scsi_status, res, vha->host_no, - cp->device->id, cp->device->lun, fcport->tgt_id, + cp->device->id, (u64)cp->device->lun, fcport->tgt_id, lscsi_status, cp->cmnd, scsi_bufflen(cp), rsp_info, resid_len, fw_resid_len, sense_len, par_sense_len, rsp_info_len); @@ -3259,7 +3274,11 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) { struct srb_iocb *fxio = &sp->u.iocb_cmd; struct qla_mt_iocb_rqst_fx00 *piocb_rqst; +#ifndef NEW_LIBFC_API + struct fc_bsg_job *bsg_job; +#else struct bsg_job *bsg_job; +#endif struct fc_bsg_request *bsg_request; struct fxdisc_entry_fx00 fx_iocb; uint8_t entry_cnt = 1; diff --git a/qla2x00t-32gbit/qla_nvme.c b/qla2x00t-32gbit/qla_nvme.c index 9ebdc12e7..26cf748f7 100644 --- a/qla2x00t-32gbit/qla_nvme.c +++ b/qla2x00t-32gbit/qla_nvme.c @@ -4,11 +4,12 @@ * * See LICENSE.qla2xxx for copyright and licensing details. */ -#include "qla_nvme.h" + #include #include #include #include +#include "qla_nvme.h" static struct nvme_fc_port_template qla_nvme_fc_transport; diff --git a/qla2x00t-32gbit/qla_nx.h b/qla2x00t-32gbit/qla_nx.h index 71a410935..422c08dad 100644 --- a/qla2x00t-32gbit/qla_nx.h +++ b/qla2x00t-32gbit/qla_nx.h @@ -7,7 +7,14 @@ #ifndef __QLA_NX_H #define __QLA_NX_H +#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) +/* + * See also commit 2f8e2c877784 ("move io-64-nonatomic*.h out of asm-generic") + * # v4.4. + */ #include +#endif /* * Following are the states of the Phantom. Phantom will set them and diff --git a/qla2x00t-32gbit/qla_os.c b/qla2x00t-32gbit/qla_os.c index 376ba0695..31e4fe280 100644 --- a/qla2x00t-32gbit/qla_os.c +++ b/qla2x00t-32gbit/qla_os.c @@ -322,9 +322,15 @@ static int qla2xxx_eh_target_reset(struct scsi_cmnd *); static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); static int qla2xxx_eh_host_reset(struct scsi_cmnd *); +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) +static int +qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason); +#endif static void qla2x00_clear_drv_active(struct qla_hw_data *); static void qla2x00_free_device(scsi_qla_host_t *); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) static int qla2xxx_map_queues(struct Scsi_Host *shost); +#endif static void qla2x00_destroy_deferred_work(struct qla_hw_data *); @@ -333,7 +339,9 @@ struct scsi_host_template qla2xxx_driver_template = { .name = QLA2XXX_DRIVER_NAME, .queuecommand = qla2xxx_queuecommand, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) .eh_timed_out = fc_eh_timed_out, +#endif .eh_abort_handler = qla2xxx_eh_abort, .eh_device_reset_handler = qla2xxx_eh_device_reset, .eh_target_reset_handler = qla2xxx_eh_target_reset, @@ -346,8 +354,14 @@ struct scsi_host_template qla2xxx_driver_template = { .slave_destroy = qla2xxx_slave_destroy, .scan_finished = qla2xxx_scan_finished, .scan_start = qla2xxx_scan_start, +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) + .change_queue_depth = qla2x00_change_queue_depth, +#else .change_queue_depth = scsi_change_queue_depth, +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) .map_queues = qla2xxx_map_queues, +#endif .this_id = -1, .cmd_per_lun = 3, .sg_tablesize = SG_ALL, @@ -356,7 +370,9 @@ struct scsi_host_template qla2xxx_driver_template = { .shost_attrs = qla2x00_host_attrs, .supported_mode = MODE_INITIATOR, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) .track_queue_depth = 1, +#endif }; static struct scsi_transport_template *qla2xxx_transport_template = NULL; @@ -1509,7 +1525,7 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, ql_log(ql_log_info, vha, 0x8009, "%s RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", name, vha->host_no, - cmd->device->id, cmd->device->lun, cmd); + cmd->device->id, (u64)cmd->device->lun, cmd); err = 0; if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { @@ -1534,15 +1550,15 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, ql_log(ql_log_info, vha, 0x800e, "%s RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", name, - vha->host_no, cmd->device->id, cmd->device->lun, cmd); + vha->host_no, cmd->device->id, (u64)cmd->device->lun, cmd); return SUCCESS; eh_reset_failed: ql_log(ql_log_info, vha, 0x800f, "%s RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", name, - reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, - cmd); + reset_errors[err], vha->host_no, cmd->device->id, + (u64)cmd->device->lun, cmd); return FAILED; } @@ -1932,7 +1948,11 @@ qla2xxx_slave_configure(struct scsi_device *sdev) if (IS_T10_PI_CAPABLE(vha->hw)) blk_queue_update_dma_alignment(sdev->request_queue, 0x7); +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) + scsi_adjust_queue_depth(sdev, 0, req->max_q_depth); +#else scsi_change_queue_depth(sdev, req->max_q_depth); +#endif return 0; } @@ -3194,7 +3214,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) "cmd_per_len=%d unique_id=%d max_cmd_len=%d max_channel=%d " "max_lun=%llu transportt=%p, vendor_id=%llu.\n", host->max_id, host->this_id, host->cmd_per_lun, host->unique_id, - host->max_cmd_len, host->max_channel, host->max_lun, + host->max_cmd_len, host->max_channel, (u64)host->max_lun, host->transportt, sht->vendor_id); INIT_WORK(&base_vha->iocb_work, qla2x00_iocb_work_fn); @@ -6153,7 +6173,7 @@ qla2x00_do_dpc(void *data) ha = (struct qla_hw_data *)data; base_vha = pci_get_drvdata(ha->pdev); - set_user_nice(current, MIN_NICE); + set_user_nice(current, -20); set_current_state(TASK_INTERRUPTIBLE); while (!kthread_should_stop()) { @@ -7125,6 +7145,7 @@ qla2xxx_pci_resume(struct pci_dev *pdev) ha->flags.eeh_busy = 0; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0) static void qla_pci_reset_prepare(struct pci_dev *pdev) { @@ -7175,7 +7196,18 @@ qla_pci_reset_done(struct pci_dev *pdev) ha->isp_ops->abort_isp(base_vha); clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); } +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) +static int +qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) +{ + scsi_adjust_queue_depth(sdev, 0, qdepth); + return sdev->queue_depth; +} +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) static int qla2xxx_map_queues(struct Scsi_Host *shost) { int rc; @@ -7203,14 +7235,31 @@ static int qla2xxx_map_queues(struct Scsi_Host *shost) #endif return rc; } +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) +static void qla_pci_reset_notify(struct pci_dev *dev, bool prepare) +{ + if (prepare) + qla_pci_reset_prepare(dev); + else + qla_pci_reset_done(dev); +} +#endif static const struct pci_error_handlers qla2xxx_err_handler = { .error_detected = qla2xxx_pci_error_detected, .mmio_enabled = qla2xxx_pci_mmio_enabled, .slot_reset = qla2xxx_pci_slot_reset, .resume = qla2xxx_pci_resume, +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) + .reset_notify = qla_pci_reset_notify, +#else .reset_prepare = qla_pci_reset_prepare, .reset_done = qla_pci_reset_done, +#endif }; static struct pci_device_id qla2xxx_pci_tbl[] = { diff --git a/qla2x00t-32gbit/qla_target.h b/qla2x00t-32gbit/qla_target.h index 72051fdce..6d1475efe 100644 --- a/qla2x00t-32gbit/qla_target.h +++ b/qla2x00t-32gbit/qla_target.h @@ -28,6 +28,7 @@ #ifndef __QLA_TARGET_H #define __QLA_TARGET_H +#include #include "qla_def.h" /*