return c;
}
-struct smb_direct_connection *smb_direct_connection_complete_alloc(struct smb_direct_connection *c)
+NTSTATUS smb_direct_connection_complete_alloc(struct smb_direct_connection *c)
{
int ret;
uint16_t i;
//DEBUG(0,("%s:%s: here...\n", __location__, __func__));
c->ibv.pd = ibv_alloc_pd(c->rdma.cm_id->verbs);
if (c->ibv.pd == NULL) {
- TALLOC_FREE(c);
DEBUG(0,("%s:%s: here...\n", __location__, __func__));
- return NULL;
+ return NT_STATUS_NO_MEMORY;
}
c->ibv.comp_channel = ibv_create_comp_channel(c->rdma.cm_id->verbs);
if (c->ibv.comp_channel == NULL) {
- TALLOC_FREE(c);
DEBUG(0,("%s:%s: here...\n", __location__, __func__));
- return NULL;
+ return NT_STATUS_NO_MEMORY;
}
smb_set_close_on_exec(c->ibv.comp_channel->fd);
set_blocking(c->ibv.comp_channel->fd, false);
c->ibv.init_attr.cap.max_send_wr,
c, c->ibv.comp_channel, 0);
if (c->ibv.send_cq == NULL) {
- TALLOC_FREE(c);
DEBUG(0,("%s:%s: here...\n", __location__, __func__));
- return NULL;
+ return NT_STATUS_NO_MEMORY;
}
c->ibv.init_attr.send_cq = c->ibv.send_cq;
c->ibv.init_attr.cap.max_recv_wr,
c, c->ibv.comp_channel, 0);
if (c->ibv.recv_cq == NULL) {
- TALLOC_FREE(c);
DEBUG(0,("%s:%s: here...\n", __location__, __func__));
- return NULL;
+ return NT_STATUS_NO_MEMORY;
}
c->ibv.init_attr.recv_cq = c->ibv.recv_cq;
ret = ibv_req_notify_cq(c->ibv.send_cq, 0);
if (ret != 0) {
- TALLOC_FREE(c);
DEBUG(0,("%s:%s: here...\n", __location__, __func__));
- return NULL;
}
ret = ibv_req_notify_cq(c->ibv.recv_cq, 0);
if (ret != 0) {
- TALLOC_FREE(c);
DEBUG(0,("%s:%s: here...\n", __location__, __func__));
- return NULL;
+ return NT_STATUS_NO_MEMORY;
}
ret = rdma_create_qp(c->rdma.cm_id, c->ibv.pd, &c->ibv.init_attr);
if (ret != 0) {
- TALLOC_FREE(c);
DEBUG(0,("%s:%s: here...\n", __location__, __func__));
- return NULL;
+ return NT_STATUS_NO_MEMORY;
}
c->ibv.qp = c->rdma.cm_id->qp;
c->io_mem_ctx = talloc_named_const(c, 0, "io_mem_ctx");
if (c->io_mem_ctx == NULL) {
- TALLOC_FREE(c);
DEBUG(0,("%s:%s: here...\n", __location__, __func__));
- return NULL;
+ return NT_STATUS_NO_MEMORY;
}
for (i = 0; i < c->state.receive_credit_max; i++) {
io = smb_direct_io_create(c);
if (io == NULL) {
- TALLOC_FREE(c);
DEBUG(0,("%s:%s: SETUP r2s here...\n", __location__, __func__));
- return NULL;
+ return NT_STATUS_NO_MEMORY;
}
DLIST_ADD_END(c->r2s.idle, io);
//DEBUG(0,("%s:%s: SETUP r2s here...\n", __location__, __func__));
io = smb_direct_io_create(c);
if (io == NULL) {
- TALLOC_FREE(c);
DEBUG(0,("%s:%s: SETUP s2r here...\n", __location__, __func__));
- return NULL;
+ return NT_STATUS_NO_MEMORY;
}
DLIST_ADD_END(c->s2r.idle, io);
//DEBUG(0,("%s:%s: SETUP s2r here...\n", __location__, __func__));
}
//DEBUG(0,("%s:%s: here...\n", __location__, __func__));
- return c;
+ return NT_STATUS_OK;
}
static void smb_direct_connection_debug_credits(struct smb_direct_connection *c,
case RDMA_CM_EVENT_ROUTE_RESOLVED:
errno = 0;
ret = 0;
- c = smb_direct_connection_complete_alloc(c);
- if (c == NULL) {
- status = map_nt_error_from_unix_common(errno);
- DEBUG(0,("%s:%s: ret[%d] errno[%d] status[%s]\n",
- __location__, __FUNCTION__, ret, errno, nt_errstr(status)));
- tevent_req_nterror(req, status);
- return;
- }
-#if 0
- c->ibv.pd = ibv_alloc_pd(c->rdma.cm_id->verbs);
- if (c->ibv.pd == NULL) {
- status = map_nt_error_from_unix_common(errno);
- DEBUG(0,("%s:%s: ret[%d] errno[%d] status[%s]\n",
- __location__, __FUNCTION__, ret, errno, nt_errstr(status)));
- tevent_req_nterror(req, status);
- return;
- }
-
- c->ibv.comp_channel = ibv_create_comp_channel(c->rdma.cm_id->verbs);
- if (c->ibv.comp_channel == NULL) {
- status = map_nt_error_from_unix_common(errno);
- DEBUG(0,("%s:%s: ret[%d] errno[%d] status[%s]\n",
- __location__, __FUNCTION__, ret, errno, nt_errstr(status)));
- tevent_req_nterror(req, status);
- return;
- }
-
- set_blocking(c->ibv.comp_channel->fd, false);
- smb_set_close_on_exec(c->ibv.comp_channel->fd);
-
- ZERO_STRUCT(init_attr);
- init_attr.cap.max_send_wr = 2;
- init_attr.cap.max_recv_wr = 2;
- init_attr.cap.max_recv_sge = 2;
- init_attr.cap.max_send_sge = 2;
- init_attr.qp_type = IBV_QPT_RC;
- init_attr.sq_sig_all = 1;
-
- c->ibv.send_cq = ibv_create_cq(c->rdma.cm_id->verbs,
- init_attr.cap.max_send_wr,
- c,
- c->ibv.comp_channel,
- 0);
- if (c->ibv.send_cq == NULL) {
- status = map_nt_error_from_unix_common(errno);
- DEBUG(0,("%s:%s: ret[%d] errno[%d] status[%s]\n",
- __location__, __FUNCTION__, ret, errno, nt_errstr(status)));
- tevent_req_nterror(req, status);
- return;
- }
- init_attr.send_cq = c->ibv.send_cq;
- c->ibv.recv_cq = ibv_create_cq(c->rdma.cm_id->verbs,
- init_attr.cap.max_recv_wr,
- c,
- c->ibv.comp_channel,
- 0);
- if (c->ibv.recv_cq == NULL) {
- status = map_nt_error_from_unix_common(errno);
- DEBUG(0,("%s:%s: ret[%d] errno[%d] status[%s]\n",
- __location__, __FUNCTION__, ret, errno, nt_errstr(status)));
- tevent_req_nterror(req, status);
- return;
- }
- init_attr.recv_cq = c->ibv.recv_cq;
-
- errno = 0;
- ret = ibv_req_notify_cq(c->ibv.send_cq, 0);
- if (ret != 0) {
- status = map_nt_error_from_unix_common(errno);
- DEBUG(0,("%s:%s: ret[%d] errno[%d] status[%s]\n",
- __location__, __FUNCTION__, ret, errno, nt_errstr(status)));
- tevent_req_nterror(req, status);
- return;
- }
-
- errno = 0;
- ret = ibv_req_notify_cq(c->ibv.recv_cq, 0);
- if (ret != 0) {
- status = map_nt_error_from_unix_common(errno);
+ status = smb_direct_connection_complete_alloc(c);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("%s:%s: ret[%d] errno[%d] status[%s]\n",
__location__, __FUNCTION__, ret, errno, nt_errstr(status)));
tevent_req_nterror(req, status);
return;
}
- errno = 0;
- ret = rdma_create_qp(c->rdma.cm_id, c->ibv.pd,
- &init_attr);
- if (ret != 0) {
- status = map_nt_error_from_unix_common(errno);
- DEBUG(0,("%s:%s: ret[%d] errno[%d] status[%s]\n",
- __location__, __FUNCTION__, ret, errno, nt_errstr(status)));
- tevent_req_nterror(req, status);
- return;
- }
- c->ibv.qp = c->rdma.cm_id->qp;
-#endif
RSIVAL(ird_ord_hdr, 0, 16);
RSIVAL(ird_ord_hdr, 4, 0);