Error in RDMA Atomic operations

845 views Asked by At

I have a problem with executing RDMA atomic operations (FETCH_ADD and CMP_AND_SWAP). When I try to submit an atomic RDMA request, the ibv_post_send() function fails, with Errno set to "Invalid argument". I have no such problems with RDMA READ/WRITE.

I register the memory addresses as follows:

local_buffer = new uint64_t[1];   // so the memory region is byte-aligned
local_mr = ibv_reg_mr(pd, local_buffer, sizeof(uint64_t),
    IBV_ACCESS_LOCAL_WRITE
    | IBV_ACCESS_REMOTE_READ
    | IBV_ACCESS_REMOTE_ATOMIC));

I build the queue pairs as follows:

memset(qp_attr, 0, sizeof(*qp_attr));
qp_attr->send_cq = s_ctx->cq;
qp_attr->recv_cq = s_ctx->cq;
qp_attr->qp_type = IBV_QPT_RC;
qp_attr->cap.max_send_wr = 10;
qp_attr->cap.max_recv_wr = 10;
qp_attr->cap.max_send_sge = 1;
qp_attr->cap.max_recv_sge = 1;
TEST_NZ(rdma_create_qp(id, s_ctx->pd, qp_attr));

And finally submit the RDMA operation with atomic opcode as follows:

struct ibv_send_wr wr, *bad_wr = NULL;
struct ibv_sge sge;
memset(&sge, 0, sizeof(sge));
sge.addr        = (uintptr_t)conn->local_buffer;
sge.length      = 8;
sge.lkey        = conn->local_mr->lkey;
memset(&wr, 0, sizeof(wr));
wr.wr_id                    = 0;
wr.opcode                   = IBV_WR_ATOMIC_FETCH_AND_ADD;
wr.sg_list                  = &sge;
wr.num_sge                  = 1;
wr.send_flags               = IBV_SEND_SIGNALED;
wr.wr.atomic.remote_addr    = (uintptr_t)conn->peer_mr.addr;
wr.wr.atomic.rkey           = conn->peer_mr.rkey;
wr.wr.atomic.compare_add    = 1ULL; /* value to be added to the remote address content */
if (ibv_post_send(conn->qp, &wr, &bad_wr)) {
    fprintf(stderr, "Error, ibv_post_send() failed\n");
    die("");
}   

P.S. since I'm using librdmacm, the transition of the queue pairs between INIT and RTR and RTS are done automatically, so I cannot manually set qp_attr->qp_access_flags , qp_attr->max_rd_atomic and qp_attr->max_dest_rd_atomic using ibv_modify_qp(). However, I wrote a small code in libibcm with atomic operations, and set those attributes when transitioning the queue manually. Still, no luck.

0

There are 0 answers