qla2x00t: Port to Linux kernel v4.17

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7439 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2018-07-23 04:29:35 +00:00
parent eb2b6f6ccf
commit 1c1693d06b
3 changed files with 42 additions and 5 deletions

View File

@@ -25,11 +25,16 @@ static inline void set_bsg_result(struct bsg_job *job, int result)
{
job->req->errors = result;
}
#else
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0)
static inline void set_bsg_result(struct bsg_job *job, int result)
{
scsi_req(job->req)->result = result;
}
#else
static inline void set_bsg_result(struct bsg_job *job, int result)
{
scsi_req(blk_mq_rq_from_pdu(job))->result = result;
}
#endif
#ifndef NEW_LIBFC_API
@@ -893,7 +898,7 @@ qla2x00_process_loopback(struct bsg_job *bsg_job)
ql_log(ql_log_warn, vha, 0x702c,
"Vendor request %s failed.\n", type);
fw_sts_ptr = ((uint8_t *)scsi_req(bsg_job->req)->sense) +
fw_sts_ptr = bsg_job_sense(bsg_job) +
sizeof(struct fc_bsg_reply);
memcpy(fw_sts_ptr, response, sizeof(response));
@@ -909,7 +914,7 @@ qla2x00_process_loopback(struct bsg_job *bsg_job)
sizeof(response) + sizeof(uint8_t);
bsg_reply->reply_payload_rcv_len =
bsg_job->reply_payload.payload_len;
fw_sts_ptr = ((uint8_t *)scsi_req(bsg_job->req)->sense) +
fw_sts_ptr = bsg_job_sense(bsg_job) +
sizeof(struct fc_bsg_reply);
memcpy(fw_sts_ptr, response, sizeof(response));
fw_sts_ptr += sizeof(response);

View File

@@ -1228,7 +1228,7 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req,
type, sp->handle, comp_status, fw_status[1], fw_status[2],
le16_to_cpu(((struct els_sts_entry_24xx *)
pkt)->total_byte_count));
fw_sts_ptr = ((uint8_t*)scsi_req(bsg_job->req)->sense) +
fw_sts_ptr = bsg_job_sense(bsg_job) +
sizeof(struct fc_bsg_reply);
memcpy( fw_sts_ptr, fw_status, sizeof(fw_status));
}
@@ -1246,7 +1246,7 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req,
#else
bsg_reply->reply_payload_rcv_len = 0;
#endif
fw_sts_ptr = ((uint8_t*)scsi_req(bsg_job->req)->sense) +
fw_sts_ptr = bsg_job_sense(bsg_job) +
sizeof(struct fc_bsg_reply);
memcpy( fw_sts_ptr, fw_status, sizeof(fw_status));
}

View File

@@ -22,6 +22,9 @@
#include <linux/bio.h>
#include <linux/blkdev.h> /* struct request_queue */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
#include <linux/bsg-lib.h> /* struct bsg_job */
#endif
#include <linux/scatterlist.h> /* struct scatterlist */
#include <linux/slab.h> /* kmalloc() */
#include <linux/timer.h>
@@ -29,6 +32,7 @@
#include <linux/writeback.h> /* sync_page_range() */
#include <rdma/ib_verbs.h>
#include <scsi/scsi_cmnd.h> /* struct scsi_cmnd */
#include <scsi/scsi_transport_fc.h> /* struct fc_bsg_job */
/* <asm-generic/barrier.h> */
@@ -90,6 +94,34 @@ static inline unsigned int queue_max_hw_sectors(struct request_queue *q)
}
#endif
/* <linux/bsg-lib.h> */
/*
* Note: the function bsg_job_sense() exists only in SCST but not in any
* upstream kernel.
*/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31) && \
((LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) && \
!defined(CONFIG_SUSE_KERNEL)) || \
(LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) && \
defined(CONFIG_SUSE_KERNEL)))
static inline void *bsg_job_sense(struct fc_bsg_job *job)
{
return job->req->sense;
}
#else
static inline void *bsg_job_sense(struct bsg_job *job)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
return job->req->sense;
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0)
return scsi_req(job->req)->sense;
#else
return scsi_req(blk_mq_rq_from_pdu(job))->sense;
#endif
}
#endif
/* <linux/compiler.h> */
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 20)