Skip to content

Commit

Permalink
isert-scst: Fix CentOS 7.3 build
Browse files Browse the repository at this point in the history
  • Loading branch information
bvassche committed Dec 27, 2016
1 parent 0a44df2 commit d3f3716
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 24 deletions.
34 changes: 32 additions & 2 deletions iscsi-scst/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,38 @@ else
endif
endif

CREATE_CQ_FLAG = $(shell $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/conftest/create_cq PRE_CFLAGS="$(OFED_CFLAGS) -Werror" >/dev/null 2>&1 && echo -DIB_CREATE_CQ_HAS_INIT_ATTR)
PRE_CFLAGS=$(OFED_CFLAGS) $(CREATE_CQ_FLAG) -DOFED_FLAVOR=$(OFED_FLAVOR)
GOALS:=$(if $(MAKECMDGOALS),$(MAKECMDGOALS),all)
OTHER_GOALS:=$(foreach goal,$(MAKECMDGOALS),$(subst all,,$(goal)))
# echo:=$(shell echo 'GOALS = $(GOALS)' >&2)
# echo:=$(shell echo 'OTHER_GOALS = $(OTHER_GOALS)' >&2)
ifneq ("$(GOALS)","$(OTHER_GOALS)")
run_conftest = $(shell if [ "0$(V)" -gt 0 ]; then output=/dev/stdout; else output=/dev/null; fi; if $(MAKE) -C $(KDIR) V=$(V) SUBDIRS="$(shell pwd)/conftest/$1" PRE_CFLAGS="-Werror $(OFED_CFLAGS)" 1>&2 2>$${output}; then echo "$2"; else echo "$3"; fi)
USE_PRE_440_WR_STRUCTURE := $(call run_conftest,use_pre_440_wr_structure,-DUSE_PRE_440_WR_STRUCTURE)
CREATE_CQ_FLAG := $(call run_conftest,create_cq,-DIB_CREATE_CQ_HAS_INIT_ATTR)
CLIENT_REMOVE := $(call run_conftest,ib_client_remove,-DIB_CLIENT_REMOVE_TAKES_TWO_ARGS)
HAVE_IB_DMA_MAP_OPS := $(call run_conftest,ib_dma_map_ops,-DHAVE_IB_DMA_MAP_OPS)
HAVE_IB_SET_CPI_RESP_TIME := $(call run_conftest,ib_set_cpi_resp_time,-DHAVE_IB_SET_CPI_RESP_TIME)
GID_CHANGE_FLAG := $(call run_conftest,gid_change,-DHAVE_IB_EVENT_GID_CHANGE)
PD_HAS_LOCAL_DMA_LKEY := $(call run_conftest,pd_has_local_dma_lkey,-DIB_PD_HAS_LOCAL_DMA_LKEY)
RDMA_CREATE_ID := $(call run_conftest,rdma_create_id_net,-DRDMA_CREATE_ID_TAKES_NET_ARG=1,-DRDMA_CREATE_ID_TAKES_NET_ARG=0)
QUERY_DEVICE := $(call run_conftest,query_device,-DHAVE_IB_QUERY_DEVICE)
QUERY_DEVICE_HAS_ATTR_ARG := $(call run_conftest,query_device_attr_arg,-DIB_QUERY_DEVICE_HAS_ATTR_ARG)
QUERY_GID_FLAG := $(call run_conftest,query_gid,-DIB_QUERY_GID_HAS_ATTR_ARG)
PRE_CFLAGS=$(OFED_CFLAGS) \
$(USE_PRE_440_WR_STRUCTURE) \
$(CLIENT_REMOVE) \
$(CREATE_CQ_FLAG) \
$(IB_CLIENT_REMOVE_TAKES_TWO_ARGS) \
$(HAVE_IB_DMA_MAP_OPS) \
$(HAVE_IB_SET_CPI_RESP_TIME) \
$(GID_CHANGE_FLAG) \
$(PD_HAS_LOCAL_DMA_LKEY) \
$(RDMA_CREATE_ID) \
$(QUERY_GID_FLAG) \
$(QUERY_DEVICE) \
$(QUERY_DEVICE_HAS_ATTR_ARG) \
-DOFED_FLAVOR=$(OFED_FLAVOR)
endif

mods: include/iscsi_scst_itf_ver.h Modules.symvers Module.symvers
$(MAKE) -C $(KDIR) SCST_INC_DIR=$(SCST_INC_DIR) SUBDIRS=$(KMOD) modules
Expand Down
4 changes: 2 additions & 2 deletions iscsi-scst/kernel/isert-scst/iser.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct isert_wr {
struct ib_sge *sge_list;
union {
struct ib_recv_wr recv_wr;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR)
#ifdef USE_PRE_440_WR_STRUCTURE
struct ib_send_wr send_wr;
#else
struct ib_rdma_wr send_wr;
Expand Down Expand Up @@ -233,7 +233,7 @@ struct isert_connection {
struct isert_device {
struct ib_device *ib_dev;
struct ib_pd *pd;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
#ifndef IB_PD_HAS_LOCAL_DMA_LKEY
struct ib_mr *mr;
#endif
u32 lkey;
Expand Down
6 changes: 3 additions & 3 deletions iscsi-scst/kernel/isert-scst/iser_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ int isert_wr_init(struct isert_wr *wr,
buff_offset = -EFAULT;
goto out;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR)
#ifdef USE_PRE_440_WR_STRUCTURE
wr->send_wr.wr.rdma.remote_addr = pdu->rem_write_va +
buff_offset;
wr->send_wr.wr.rdma.rkey = pdu->rem_write_stag;
Expand All @@ -255,7 +255,7 @@ int isert_wr_init(struct isert_wr *wr,
buff_offset = -EFAULT;
goto out;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR)
#ifdef USE_PRE_440_WR_STRUCTURE
wr->send_wr.wr.rdma.remote_addr = pdu->rem_read_va +
buff_offset;
wr->send_wr.wr.rdma.rkey = pdu->rem_read_stag;
Expand Down Expand Up @@ -288,7 +288,7 @@ int isert_wr_init(struct isert_wr *wr,
wr->recv_wr.sg_list = wr->sge_list;
wr->recv_wr.num_sge = sg_cnt;
} else {
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR)
#ifdef USE_PRE_440_WR_STRUCTURE
wr->send_wr.next = NULL;
wr->send_wr.wr_id = _ptr_to_u64(wr);
wr->send_wr.sg_list = wr->sge_list;
Expand Down
10 changes: 5 additions & 5 deletions iscsi-scst/kernel/isert-scst/iser_pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static int isert_alloc_for_rdma(struct isert_cmnd *pdu, int sge_cnt,
static inline void isert_link_send_wrs(struct isert_wr *from_wr,
struct isert_wr *to_wr)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR)
#ifdef USE_PRE_440_WR_STRUCTURE
from_wr->send_wr.next = &to_wr->send_wr;
#else
from_wr->send_wr.wr.next = &to_wr->send_wr.wr;
Expand All @@ -226,7 +226,7 @@ static inline void isert_link_send_pdu_wrs(struct isert_cmnd *from_pdu,
int wr_cnt)
{
isert_link_send_wrs(&from_pdu->wr[wr_cnt - 1], &to_pdu->wr[0]);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR)
#ifdef USE_PRE_440_WR_STRUCTURE
to_pdu->wr[0].send_wr.next = NULL;
#else
to_pdu->wr[0].send_wr.wr.next = NULL;
Expand Down Expand Up @@ -289,7 +289,7 @@ int isert_prepare_rdma(struct isert_cmnd *isert_pdu,
isert_link_send_wrs(&isert_pdu->wr[i - 1], &isert_pdu->wr[i]);

if (op == ISER_WR_RDMA_READ) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR)
#ifdef USE_PRE_440_WR_STRUCTURE
isert_pdu->wr[wr_cnt - 1].send_wr.send_flags = IB_SEND_SIGNALED;
isert_pdu->wr[wr_cnt - 1].send_wr.next = NULL;
#else
Expand Down Expand Up @@ -588,7 +588,7 @@ int isert_pdu_send(struct isert_connection *isert_conn,
#endif

wr = &tx_pdu->wr[0];
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR)
#ifdef USE_PRE_440_WR_STRUCTURE
wr->send_wr.num_sge = isert_pdu_prepare_send(isert_conn, tx_pdu);
#else
wr->send_wr.wr.num_sge = isert_pdu_prepare_send(isert_conn, tx_pdu);
Expand All @@ -613,7 +613,7 @@ int isert_pdu_post_rdma_write(struct isert_connection *isert_conn,

TRACE_ENTRY();

#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR)
#ifdef USE_PRE_440_WR_STRUCTURE
isert_rsp->wr[0].send_wr.num_sge = isert_pdu_prepare_send(isert_conn,
isert_rsp);
#else
Expand Down
23 changes: 11 additions & 12 deletions iscsi-scst/kernel/isert-scst/iser_rdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int isert_post_send(struct isert_connection *isert_conn,
struct isert_wr *first_wr,
int num_wr)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR)
#ifdef USE_PRE_440_WR_STRUCTURE
struct ib_send_wr *first_ib_wr = &first_wr->send_wr;
#else
struct ib_send_wr *first_ib_wr = &first_wr->send_wr.wr;
Expand Down Expand Up @@ -150,7 +150,7 @@ static void isert_post_drain_sq(struct isert_connection *isert_conn)

isert_wr_set_fields(drain_wr_sq, isert_conn, NULL);
drain_wr_sq->wr_op = ISER_WR_SEND;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR)
#ifdef USE_PRE_440_WR_STRUCTURE
drain_wr_sq->send_wr.wr_id = _ptr_to_u64(drain_wr_sq);
drain_wr_sq->send_wr.opcode = IB_WR_SEND;
err = ib_post_send(isert_conn->qp,
Expand Down Expand Up @@ -704,7 +704,7 @@ static void isert_handle_wc_error(struct ib_wc *wc)

switch (wr->wr_op) {
case ISER_WR_SEND:
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR)
#ifdef USE_PRE_440_WR_STRUCTURE
num_sge = wr->send_wr.num_sge;
#else
num_sge = wr->send_wr.wr.num_sge;
Expand Down Expand Up @@ -951,7 +951,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
struct isert_device *isert_dev;
int cqe_num, err;
struct ib_pd *pd;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
#ifndef IB_PD_HAS_LOCAL_DMA_LKEY
struct ib_mr *mr;
#endif
struct ib_cq *cq;
Expand All @@ -967,7 +967,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
goto out;
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) || defined(MOFED_MAJOR)
#ifdef HAVE_IB_QUERY_DEVICE
err = ib_query_device(ib_dev, &isert_dev->device_attr);
if (unlikely(err)) {
PRINT_ERROR("Failed to query device, err: %d", err);
Expand Down Expand Up @@ -1005,7 +1005,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
goto fail_pd;
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
#ifndef IB_PD_HAS_LOCAL_DMA_LKEY
mr = ib_get_dma_mr(pd, IB_ACCESS_LOCAL_WRITE);
if (unlikely(IS_ERR(mr))) {
err = PTR_ERR(mr);
Expand Down Expand Up @@ -1054,8 +1054,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
goto fail_cq;
}

#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) || defined(MOFED_MAJOR)) && \
!defined(IB_CREATE_CQ_HAS_INIT_ATTR)
#ifndef IB_CREATE_CQ_HAS_INIT_ATTR
cq = ib_create_cq(ib_dev,
isert_cq_comp_handler,
isert_async_evt_handler,
Expand Down Expand Up @@ -1095,7 +1094,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)

isert_dev->ib_dev = ib_dev;
isert_dev->pd = pd;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
#ifndef IB_PD_HAS_LOCAL_DMA_LKEY
isert_dev->mr = mr;
isert_dev->lkey = mr->lkey;
#else
Expand All @@ -1118,7 +1117,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
if (isert_dev->cq_desc[j].cq_workqueue)
destroy_workqueue(isert_dev->cq_desc[j].cq_workqueue);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
#ifndef IB_PD_HAS_LOCAL_DMA_LKEY
ib_dereg_mr(mr);
fail_mr:
#endif
Expand Down Expand Up @@ -1164,7 +1163,7 @@ static void isert_device_release(struct isert_device *isert_dev)
destroy_workqueue(cq_desc->cq_workqueue);
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
#ifndef IB_PD_HAS_LOCAL_DMA_LKEY
err = ib_dereg_mr(isert_dev->mr);
if (unlikely(err))
PRINT_ERROR("Failed to destroy mr, err:%d", err);
Expand Down Expand Up @@ -1796,7 +1795,7 @@ struct isert_portal *isert_portal_create(void)
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) && \
(!defined(RHEL_MAJOR) || RHEL_MAJOR -0 <= 5)
cm_id = rdma_create_id(isert_cm_evt_handler, portal, RDMA_PS_TCP);
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR)
#elif !RDMA_CREATE_ID_TAKES_NET_ARG
cm_id = rdma_create_id(isert_cm_evt_handler, portal, RDMA_PS_TCP,
IB_QPT_RC);
#else
Expand Down

0 comments on commit d3f3716

Please sign in to comment.