From: Valentine Fatiev <valentinef@nvidia.com>
Subject: [PATCH] BACKPORT: drivers/nvme/target/rdma.c

---
 drivers/nvme/target/rdma.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -8,7 +8,9 @@
 #endif
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 #include <linux/atomic.h>
+#ifdef HAVE_BLK_INTEGRITY_H
 #include <linux/blk-integrity.h>
+#endif
 #include <linux/ctype.h>
 #include <linux/delay.h>
 #include <linux/err.h>
@@ -233,6 +235,13 @@ static int srq_size_set(const char *val,
 	return param_set_int(val, kp);
 }
 
+#if !defined HAVE_PUT_UNALIGNED_LE24 && !defined HAVE_PUT_UNALIGNED_LE24_ASM_GENERIC && !defined(HAVE_LINUX_UNALIGNED_H)
+static inline u32 get_unaligned_le24(const u8 *p)
+{
+	return (u32)p[0] | (u32)p[1] << 8 | (u32)p[2] << 16;
+}
+#endif
+
 static int num_pages(int len)
 {
 	return 1 + (((len - 1) & PAGE_MASK) >> PAGE_SHIFT);
@@ -632,7 +641,9 @@ static void nvmet_rdma_set_sig_domain(st
 {
 	domain->sig_type = IB_SIG_TYPE_T10_DIF;
 	domain->sig.dif.bg_type = IB_T10DIF_CRC;
+#ifdef CONFIG_BLK_DEV_INTEGRITY
 	domain->sig.dif.pi_interval = 1 << bi->interval_exp;
+#endif
 	domain->sig.dif.ref_tag = le32_to_cpu(cmd->rw.reftag);
 	if (control & NVME_RW_PRINFO_PRCHK_REF)
 		domain->sig.dif.ref_remap = true;
@@ -1436,7 +1447,11 @@ static void nvmet_rdma_free_queue(struct
 	}
 	nvmet_rdma_free_rsps(queue);
 	cancel_work_sync(&queue->disconnect_work);
+#ifdef HAVE_IDA_FREE
 	ida_free(&nvmet_rdma_queue_ida, queue->idx);
+#else
+	ida_simple_remove(&nvmet_rdma_queue_ida, queue->idx);
+#endif
 	kfree(queue);
 }
 
@@ -1550,7 +1565,11 @@ nvmet_rdma_alloc_queue(struct nvmet_rdma
 	spin_lock_init(&queue->rsps_lock);
 	INIT_LIST_HEAD(&queue->queue_list);
 
+#ifdef HAVE_IDA_ALLOC
 	queue->idx = ida_alloc(&nvmet_rdma_queue_ida, GFP_KERNEL);
+#else
+	queue->idx = ida_simple_get(&nvmet_rdma_queue_ida, 0, 0, GFP_KERNEL);
+#endif
 	if (queue->idx < 0) {
 		ret = NVME_RDMA_CM_NO_RSC;
 		goto out_destroy_sq;
@@ -1601,7 +1620,11 @@ out_free_cmds:
 out_free_responses:
 	nvmet_rdma_free_rsps(queue);
 out_ida_remove:
+#ifdef HAVE_IDA_FREE
 	ida_free(&nvmet_rdma_queue_ida, queue->idx);
+#else
+	ida_simple_remove(&nvmet_rdma_queue_ida, queue->idx);
+#endif
 out_destroy_sq:
 	nvmet_sq_destroy(&queue->nvme_sq);
 out_free_queue:
@@ -2293,6 +2316,9 @@ module_exit(nvmet_rdma_exit);
 
 MODULE_DESCRIPTION("NVMe target RDMA transport driver");
 MODULE_LICENSE("GPL v2");
+#ifdef RETPOLINE_MLNX
+MODULE_INFO(retpoline, "Y");
+#endif
 MODULE_ALIAS("nvmet-transport-1"); /* 1 == NVMF_TRTYPE_RDMA */
 
 #include "rdma_offload.c"
