Commit 090fa24b authored by Bart Van Assche's avatar Bart Van Assche Committed by Doug Ledford

IB/srpt: Preparations for adding RDMA/CM support

Introduce a union in struct srpt_rdma_ch for member variables that
depend on the type of connection manager. Avoid that error messages
report the IB/CM ID.
Signed-off-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent fcf58936
...@@ -215,12 +215,12 @@ static const char *get_ch_state_name(enum rdma_ch_state s) ...@@ -215,12 +215,12 @@ static const char *get_ch_state_name(enum rdma_ch_state s)
*/ */
static void srpt_qp_event(struct ib_event *event, struct srpt_rdma_ch *ch) static void srpt_qp_event(struct ib_event *event, struct srpt_rdma_ch *ch)
{ {
pr_debug("QP event %d on cm_id=%p sess_name=%s state=%d\n", pr_debug("QP event %d on ch=%p sess_name=%s state=%d\n",
event->event, ch->cm_id, ch->sess_name, ch->state); event->event, ch, ch->sess_name, ch->state);
switch (event->event) { switch (event->event) {
case IB_EVENT_COMM_EST: case IB_EVENT_COMM_EST:
ib_cm_notify(ch->cm_id, event->event); ib_cm_notify(ch->ib_cm.cm_id, event->event);
break; break;
case IB_EVENT_QP_LAST_WQE_REACHED: case IB_EVENT_QP_LAST_WQE_REACHED:
pr_debug("%s-%d, state %s: received Last WQE event.\n", pr_debug("%s-%d, state %s: received Last WQE event.\n",
...@@ -1097,7 +1097,7 @@ static int srpt_ch_qp_rtr(struct srpt_rdma_ch *ch, struct ib_qp *qp) ...@@ -1097,7 +1097,7 @@ static int srpt_ch_qp_rtr(struct srpt_rdma_ch *ch, struct ib_qp *qp)
int ret; int ret;
qp_attr.qp_state = IB_QPS_RTR; qp_attr.qp_state = IB_QPS_RTR;
ret = ib_cm_init_qp_attr(ch->cm_id, &qp_attr, &attr_mask); ret = ib_cm_init_qp_attr(ch->ib_cm.cm_id, &qp_attr, &attr_mask);
if (ret) if (ret)
goto out; goto out;
...@@ -1127,7 +1127,7 @@ static int srpt_ch_qp_rts(struct srpt_rdma_ch *ch, struct ib_qp *qp) ...@@ -1127,7 +1127,7 @@ static int srpt_ch_qp_rts(struct srpt_rdma_ch *ch, struct ib_qp *qp)
int ret; int ret;
qp_attr.qp_state = IB_QPS_RTS; qp_attr.qp_state = IB_QPS_RTS;
ret = ib_cm_init_qp_attr(ch->cm_id, &qp_attr, &attr_mask); ret = ib_cm_init_qp_attr(ch->ib_cm.cm_id, &qp_attr, &attr_mask);
if (ret) if (ret)
goto out; goto out;
...@@ -1509,9 +1509,9 @@ static void srpt_handle_tsk_mgmt(struct srpt_rdma_ch *ch, ...@@ -1509,9 +1509,9 @@ static void srpt_handle_tsk_mgmt(struct srpt_rdma_ch *ch,
srp_tsk = recv_ioctx->ioctx.buf; srp_tsk = recv_ioctx->ioctx.buf;
cmd = &send_ioctx->cmd; cmd = &send_ioctx->cmd;
pr_debug("recv tsk_mgmt fn %d for task_tag %lld and cmd tag %lld" pr_debug("recv tsk_mgmt fn %d for task_tag %lld and cmd tag %lld ch %p sess %p\n",
" cm_id %p sess %p\n", srp_tsk->tsk_mgmt_func, srp_tsk->tsk_mgmt_func, srp_tsk->task_tag, srp_tsk->tag, ch,
srp_tsk->task_tag, srp_tsk->tag, ch->cm_id, ch->sess); ch->sess);
srpt_set_cmd_state(send_ioctx, SRPT_STATE_MGMT); srpt_set_cmd_state(send_ioctx, SRPT_STATE_MGMT);
send_ioctx->cmd.tag = srp_tsk->tag; send_ioctx->cmd.tag = srp_tsk->tag;
...@@ -1762,9 +1762,9 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch) ...@@ -1762,9 +1762,9 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch)
atomic_set(&ch->sq_wr_avail, qp_init->cap.max_send_wr); atomic_set(&ch->sq_wr_avail, qp_init->cap.max_send_wr);
pr_debug("%s: max_cqe= %d max_sge= %d sq_size = %d cm_id= %p\n", pr_debug("%s: max_cqe= %d max_sge= %d sq_size = %d ch= %p\n",
__func__, ch->cq->cqe, qp_init->cap.max_send_sge, __func__, ch->cq->cqe, qp_init->cap.max_send_sge,
qp_init->cap.max_send_wr, ch->cm_id); qp_init->cap.max_send_wr, ch);
ret = srpt_init_ch_qp(ch, ch->qp); ret = srpt_init_ch_qp(ch, ch->qp);
if (ret) if (ret)
...@@ -1849,9 +1849,9 @@ static int srpt_disconnect_ch(struct srpt_rdma_ch *ch) ...@@ -1849,9 +1849,9 @@ static int srpt_disconnect_ch(struct srpt_rdma_ch *ch)
if (!srpt_set_ch_state(ch, CH_DISCONNECTING)) if (!srpt_set_ch_state(ch, CH_DISCONNECTING))
return -ENOTCONN; return -ENOTCONN;
ret = ib_send_cm_dreq(ch->cm_id, NULL, 0); ret = ib_send_cm_dreq(ch->ib_cm.cm_id, NULL, 0);
if (ret < 0) if (ret < 0)
ret = ib_send_cm_drep(ch->cm_id, NULL, 0); ret = ib_send_cm_drep(ch->ib_cm.cm_id, NULL, 0);
if (ret < 0 && srpt_close_ch(ch)) if (ret < 0 && srpt_close_ch(ch))
ret = 0; ret = 0;
...@@ -2003,7 +2003,7 @@ static void srpt_release_channel_work(struct work_struct *w) ...@@ -2003,7 +2003,7 @@ static void srpt_release_channel_work(struct work_struct *w)
transport_deregister_session(se_sess); transport_deregister_session(se_sess);
ch->sess = NULL; ch->sess = NULL;
ib_destroy_cm_id(ch->cm_id); ib_destroy_cm_id(ch->ib_cm.cm_id);
srpt_destroy_ch_ib(ch); srpt_destroy_ch_ib(ch);
...@@ -2118,7 +2118,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, ...@@ -2118,7 +2118,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
ch->zw_cqe.done = srpt_zerolength_write_done; ch->zw_cqe.done = srpt_zerolength_write_done;
INIT_WORK(&ch->release_work, srpt_release_channel_work); INIT_WORK(&ch->release_work, srpt_release_channel_work);
ch->sport = &sdev->port[param->port - 1]; ch->sport = &sdev->port[param->port - 1];
ch->cm_id = cm_id; ch->ib_cm.cm_id = cm_id;
cm_id->context = ch; cm_id->context = ch;
/* /*
* ch->rq_size should be at least as large as the initiator queue * ch->rq_size should be at least as large as the initiator queue
...@@ -2239,8 +2239,8 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, ...@@ -2239,8 +2239,8 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
goto destroy_ib; goto destroy_ib;
} }
pr_debug("Establish connection sess=%p name=%s cm_id=%p\n", ch->sess, pr_debug("Establish connection sess=%p name=%s ch=%p\n", ch->sess,
ch->sess_name, ch->cm_id); ch->sess_name, ch);
/* create srp_login_response */ /* create srp_login_response */
rsp->opcode = SRP_LOGIN_RSP; rsp->opcode = SRP_LOGIN_RSP;
......
...@@ -243,8 +243,8 @@ enum rdma_ch_state { ...@@ -243,8 +243,8 @@ enum rdma_ch_state {
/** /**
* struct srpt_rdma_ch - RDMA channel * struct srpt_rdma_ch - RDMA channel
* @nexus: I_T nexus this channel is associated with. * @nexus: I_T nexus this channel is associated with.
* @cm_id: IB CM ID associated with the channel.
* @qp: IB queue pair used for communicating over this channel. * @qp: IB queue pair used for communicating over this channel.
* @cm_id: IB CM ID associated with the channel.
* @cq: IB completion queue for this channel. * @cq: IB completion queue for this channel.
* @zw_cqe: Zero-length write CQE. * @zw_cqe: Zero-length write CQE.
* @rcu: RCU head. * @rcu: RCU head.
...@@ -275,8 +275,12 @@ enum rdma_ch_state { ...@@ -275,8 +275,12 @@ enum rdma_ch_state {
*/ */
struct srpt_rdma_ch { struct srpt_rdma_ch {
struct srpt_nexus *nexus; struct srpt_nexus *nexus;
struct ib_cm_id *cm_id;
struct ib_qp *qp; struct ib_qp *qp;
union {
struct {
struct ib_cm_id *cm_id;
} ib_cm;
};
struct ib_cq *cq; struct ib_cq *cq;
struct ib_cqe zw_cqe; struct ib_cqe zw_cqe;
struct rcu_head rcu; struct rcu_head rcu;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment