Skip to content

Commit

Permalink
providers/rxe: Add new API ibv_wr_flush()
Browse files Browse the repository at this point in the history
Currently, we only implement it on rxe

Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
  • Loading branch information
zhijianli88 committed Jan 14, 2023
1 parent 16ac905 commit 20a37f3
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
1 change: 1 addition & 0 deletions libibverbs/man/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,5 @@ rdma_alias_man_pages(
ibv_wr_post.3 ibv_wr_set_sge_list.3
ibv_wr_post.3 ibv_wr_set_ud_addr.3
ibv_wr_post.3 ibv_wr_set_xrc_srqn.3
ibv_wr_post.3 ibv_wr_flush.3
)
5 changes: 4 additions & 1 deletion libibverbs/man/ibv_wr_post.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ibv_wr_atomic_cmp_swp, ibv_wr_atomic_fetch_add - Post remote atomic operation wo

ibv_wr_bind_mw, ibv_wr_local_inv - Post work requests for memory windows

ibv_wr_rdma_read, ibv_wr_rdma_write, ibv_wr_rdma_write_imm - Post RDMA work requests
ibv_wr_rdma_read, ibv_wr_rdma_write, ibv_wr_rdma_write_imm, ibv_wr_flush - Post RDMA work requests

ibv_wr_send, ibv_wr_send_imm, ibv_wr_send_inv - Post send work requests

Expand Down Expand Up @@ -73,6 +73,8 @@ void ibv_wr_set_sge_list(struct ibv_qp_ex *qp, size_t num_sge,
void ibv_wr_set_ud_addr(struct ibv_qp_ex *qp, struct ibv_ah *ah,
uint32_t remote_qpn, uint32_t remote_qkey);
void ibv_wr_set_xrc_srqn(struct ibv_qp_ex *qp, uint32_t remote_srqn);
void ibv_wr_flush(struct ibv_qp_ex *qp, uint32_t rkey, uint64_t remote_addr,
size_t len, uint8_t type, uint8_t level);
```
# DESCRIPTION
Expand Down Expand Up @@ -145,6 +147,7 @@ ibv_qp_init_attr_ex* (see the EXAMPLE below).
| LOCAL_INV | ibv_wr_local_inv() | UC, RC, XRC_SEND | NONE |
| RDMA_READ | ibv_wr_rdma_read() | RC, XRC_SEND | DATA, QP |
| RDMA_WRITE | ibv_wr_rdma_write() | UC, RC, XRC_SEND | DATA, QP |
| FLUSH | ibv_wr_flush() | RC, RD, XRC_SEND | DATA, QP |
| RDMA_WRITE_WITH_IMM | ibv_wr_rdma_write_imm() | UC, RC, XRC_SEND | DATA, QP |
| SEND | ibv_wr_send() | UD, UC, RC, XRC_SEND, RAW_PACKET | DATA, QP |
| SEND_WITH_IMM | ibv_wr_send_imm() | UD, UC, RC, SRC SEND | DATA, QP |
Expand Down
23 changes: 23 additions & 0 deletions libibverbs/verbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ enum ibv_wc_opcode {
IBV_WC_BIND_MW,
IBV_WC_LOCAL_INV,
IBV_WC_TSO,
IBV_WC_FLUSH,
IBV_WC_ATOMIC_WRITE = 9,
/*
* Set value of IBV_WC_RECV so consumers can test if a completion is a
Expand Down Expand Up @@ -951,6 +952,7 @@ enum ibv_qp_create_send_ops_flags {
IBV_QP_EX_WITH_BIND_MW = 1 << 8,
IBV_QP_EX_WITH_SEND_WITH_INV = 1 << 9,
IBV_QP_EX_WITH_TSO = 1 << 10,
IBV_QP_EX_WITH_FLUSH = 1 << 11,
IBV_QP_EX_WITH_ATOMIC_WRITE = 1 << 12,
};

Expand Down Expand Up @@ -1098,6 +1100,7 @@ enum ibv_wr_opcode {
IBV_WR_SEND_WITH_INV,
IBV_WR_TSO,
IBV_WR_DRIVER1,
IBV_WR_FLUSH = 14,
IBV_WR_ATOMIC_WRITE = 15,
};

Expand All @@ -1109,6 +1112,16 @@ enum ibv_send_flags {
IBV_SEND_IP_CSUM = 1 << 4
};

enum ibv_placement_type {
IBV_FLUSH_GLOBAL = 1U << 0,
IBV_FLUSH_PERSISTENT = 1U << 1,
};

enum ibv_selectivity_level {
IBV_FLUSH_RANGE = 0,
IBV_FLUSH_MR,
};

struct ibv_data_buf {
void *addr;
size_t length;
Expand Down Expand Up @@ -1318,6 +1331,9 @@ struct ibv_qp_ex {

void (*wr_atomic_write)(struct ibv_qp_ex *qp, uint32_t rkey,
uint64_t remote_addr, const void *atomic_wr);
void (*wr_flush)(struct ibv_qp_ex *qp, uint32_t rkey,
uint64_t remote_addr, size_t len, uint8_t type,
uint8_t level);
};

struct ibv_qp_ex *ibv_qp_to_qp_ex(struct ibv_qp *qp);
Expand Down Expand Up @@ -1360,6 +1376,13 @@ static inline void ibv_wr_rdma_write(struct ibv_qp_ex *qp, uint32_t rkey,
qp->wr_rdma_write(qp, rkey, remote_addr);
}

static inline void ibv_wr_flush(struct ibv_qp_ex *qp, uint32_t rkey,
uint64_t remote_addr, size_t len, uint8_t type,
uint8_t level)
{
qp->wr_flush(qp, rkey, remote_addr, len, type, level);
}

static inline void ibv_wr_rdma_write_imm(struct ibv_qp_ex *qp, uint32_t rkey,
uint64_t remote_addr, __be32 imm_data)
{
Expand Down
30 changes: 29 additions & 1 deletion providers/rxe/rxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,31 @@ static void wr_rdma_write(struct ibv_qp_ex *ibqp, uint32_t rkey,
advance_qp_cur_index(qp);
}

static void wr_flush(struct ibv_qp_ex *ibqp, uint32_t rkey,
uint64_t remote_addr, size_t length,
uint8_t type, uint8_t level)
{
struct rxe_qp *qp = container_of(ibqp, struct rxe_qp, vqp.qp_ex);
struct rxe_send_wqe *wqe = addr_from_index(qp->sq.queue, qp->cur_index);

if (check_qp_queue_full(qp))
return;

memset(wqe, 0, sizeof(*wqe));

wqe->wr.wr_id = qp->vqp.qp_ex.wr_id;
wqe->wr.opcode = IBV_WR_FLUSH;
wqe->wr.send_flags = qp->vqp.qp_ex.wr_flags;
wqe->wr.wr.flush.remote_addr = remote_addr;
wqe->wr.wr.flush.rkey = rkey;
wqe->wr.wr.flush.type = type;
wqe->wr.wr.flush.level = level;
wqe->iova = remote_addr;
wqe->ssn = qp->ssn++;

advance_qp_cur_index(qp);
}

static void wr_atomic_write(struct ibv_qp_ex *ibqp, uint32_t rkey,
uint64_t remote_addr, const void *atomic_wr)
{
Expand Down Expand Up @@ -1266,7 +1291,7 @@ enum {
IBV_QP_EX_WITH_RDMA_READ | IBV_QP_EX_WITH_ATOMIC_CMP_AND_SWP |
IBV_QP_EX_WITH_ATOMIC_FETCH_AND_ADD | IBV_QP_EX_WITH_LOCAL_INV |
IBV_QP_EX_WITH_BIND_MW | IBV_QP_EX_WITH_SEND_WITH_INV |
IBV_QP_EX_WITH_ATOMIC_WRITE,
IBV_QP_EX_WITH_FLUSH | IBV_QP_EX_WITH_ATOMIC_WRITE,

RXE_SUP_UC_QP_SEND_OPS_FLAGS =
IBV_QP_EX_WITH_RDMA_WRITE | IBV_QP_EX_WITH_RDMA_WRITE_WITH_IMM |
Expand Down Expand Up @@ -1334,6 +1359,9 @@ static void set_qp_send_ops(struct rxe_qp *qp, uint64_t flags)
if (flags & IBV_QP_EX_WITH_RDMA_WRITE)
qp->vqp.qp_ex.wr_rdma_write = wr_rdma_write;

if (flags & IBV_QP_EX_WITH_FLUSH)
qp->vqp.qp_ex.wr_flush = wr_flush;

if (flags & IBV_QP_EX_WITH_RDMA_WRITE_WITH_IMM)
qp->vqp.qp_ex.wr_rdma_write_imm = wr_rdma_write_imm;

Expand Down

0 comments on commit 20a37f3

Please sign in to comment.