From: Valentine Fatiev <valentinef@nvidia.com>
Subject: [PATCH] BACKPORT: drivers/infiniband/ulp/srp/ib_srp.h

Change-Id: Ic69527700e22be62075fa72adb459bb66a96be8c
---
 drivers/infiniband/ulp/srp/ib_srp.h | 50 +++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -91,6 +91,38 @@ enum srp_iu_type {
 	SRP_IU_RSP,
 };
 
+#if !(defined(RHEL_MAJOR) && RHEL_MAJOR -0 == 7 && \
+      !defined(HAVE_SCSI_HOST_TEMPLATE_USE_HOST_WIDE_TAGS))
+#define HAVE_BLK_TAGS 1
+#endif
+
+#if defined(HAVE_BLK_QUEUE_VIRT_BOUNDARY) &&                                   \
+	!defined(HAVE_SCSI_HOST_VIRT_BOUNDARY_MASK)
+#define USE_SLAVE_ALLOC_HANDLER 1
+#endif
+
+#if defined(HAVE_BLK_QUEUE_VIRT_BOUNDARY) ||                                   \
+	defined(HAVE_SCSI_HOST_VIRT_BOUNDARY_MASK)
+#define HAVE_VIRT_BOUNDARY 1
+#endif
+
+#ifndef HAVE_BLK_TAGS
+static inline u32 build_srp_tag(u16 ch, u16 req_idx)
+{
+	return ch << 16 | req_idx;
+}
+
+static inline u16 srp_tag_ch(u32 tag)
+{
+	return tag >> 16;
+}
+
+static inline u16 srp_tag_idx(u32 tag)
+{
+	return tag & ((1 << 16) - 1);
+}
+#endif
+
 /*
  * @mr_page_mask: HCA memory registration page mask.
  * @mr_page_size: HCA memory registration page size.
@@ -121,12 +153,18 @@ struct srp_host {
 };
 
 struct srp_request {
+#ifndef HAVE_BLK_TAGS
+	struct list_head        list;
+#endif
 	struct scsi_cmnd       *scmnd;
 	struct srp_iu	       *cmd;
 	struct srp_fr_desc     **fr_list;
 	struct srp_direct_buf  *indirect_desc;
 	dma_addr_t		indirect_dma_addr;
 	short			nmdesc;
+#ifndef HAVE_BLK_TAGS
+	uint32_t		tag;
+#endif
 	struct ib_cqe		reg_cqe;
 };
 
@@ -139,6 +177,9 @@ struct srp_request {
 struct srp_rdma_ch {
 	/* These are RW in the hot path, and commonly used together */
 	struct list_head	free_tx;
+#ifndef HAVE_BLK_TAGS
+	struct list_head        free_reqs;
+#endif
 	spinlock_t		lock;
 	s32			req_lim;
 
@@ -174,6 +215,9 @@ struct srp_rdma_ch {
 
 	struct srp_iu	      **tx_ring;
 	struct srp_iu	      **rx_ring;
+#ifndef HAVE_SCSI_HOST_TEMPLATE_INIT_CMD_PRIV
+	struct srp_request     *req_ring;
+#endif
 	int			comp_vector;
 
 	u64			tsk_mgmt_tag;
@@ -195,6 +239,9 @@ struct srp_target_port {
 	u32			global_rkey;
 	struct srp_rdma_ch	*ch;
 	struct net		*net;
+#ifndef HAVE_BLK_TAGS
+	int 			*mq_map;
+#endif
 	u32			ch_count;
 	u32			lkey;
 	enum srp_target_state	state;
@@ -219,6 +266,9 @@ struct srp_target_port {
 	int			mr_pool_size;
 	int			mr_per_cmd;
 	int			queue_size;
+#ifndef HAVE_SCSI_HOST_TEMPLATE_INIT_CMD_PRIV
+	int			req_ring_size;
+#endif
 	int			comp_vector;
 	int			tl_retry_count;
 
