On 4/21/21 4:36 AM, Zhu Yanjun wrote: > On Wed, Apr 21, 2021 at 1:20 PM Bob Pearson <rpearsonhpe@xxxxxxxxx> wrote: >> >> Add support for bind MW work requests from user space. >> Since rdma/core does not support bind mw in ib_send_wr >> there is no way to support bind mw in kernel space. >> >> Added bind_mw local operation in rxe_req.c >> Added bind_mw WR operation in rxe_opcode.c >> Added bind_mw WC in rxe_comp.c >> Added additional fields to rxe_mw in rxe_verbs.h >> Added do_dealloc_mw() subroutine to cleanup an mw >> when rxe_dealloc_mw is called. >> Added code to implement bind_mw operation in rxe_mw.c >> >> Signed-off-by: Bob Pearson <rpearson@xxxxxxx> >> --- >> v3: >> do_bind_mw() in rxe_mw.c is changed to be a void instead of >> returning an int. >> v2: >> Dropped kernel support for bind_mw in rxe_mw.c >> Replaced umw with mw in struct rxe_send_wr >> --- >> drivers/infiniband/sw/rxe/rxe_comp.c | 1 + >> drivers/infiniband/sw/rxe/rxe_loc.h | 1 + >> drivers/infiniband/sw/rxe/rxe_mw.c | 202 ++++++++++++++++++++++++- >> drivers/infiniband/sw/rxe/rxe_opcode.c | 7 + >> drivers/infiniband/sw/rxe/rxe_req.c | 9 ++ >> drivers/infiniband/sw/rxe/rxe_verbs.h | 15 +- >> 6 files changed, 230 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c >> index 2af26737d32d..bc5488af5f55 100644 >> --- a/drivers/infiniband/sw/rxe/rxe_comp.c >> +++ b/drivers/infiniband/sw/rxe/rxe_comp.c >> @@ -103,6 +103,7 @@ static enum ib_wc_opcode wr_to_wc_opcode(enum ib_wr_opcode opcode) >> case IB_WR_RDMA_READ_WITH_INV: return IB_WC_RDMA_READ; >> case IB_WR_LOCAL_INV: return IB_WC_LOCAL_INV; >> case IB_WR_REG_MR: return IB_WC_REG_MR; >> + case IB_WR_BIND_MW: return IB_WC_BIND_MW; >> >> default: >> return 0xff; >> diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h >> index edf575930a98..e6f574973298 100644 >> --- a/drivers/infiniband/sw/rxe/rxe_loc.h >> +++ b/drivers/infiniband/sw/rxe/rxe_loc.h >> @@ -110,6 +110,7 @@ int advance_dma_data(struct rxe_dma_info *dma, unsigned int length); >> /* rxe_mw.c */ >> int rxe_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata); >> int rxe_dealloc_mw(struct ib_mw *ibmw); >> +int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe); >> void rxe_mw_cleanup(struct rxe_pool_entry *arg); >> >> /* rxe_net.c */ >> diff --git a/drivers/infiniband/sw/rxe/rxe_mw.c b/drivers/infiniband/sw/rxe/rxe_mw.c >> index 69128e298d44..c018e8865876 100644 >> --- a/drivers/infiniband/sw/rxe/rxe_mw.c >> +++ b/drivers/infiniband/sw/rxe/rxe_mw.c >> @@ -29,6 +29,29 @@ int rxe_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata) >> return 0; >> } >> >> +static void do_dealloc_mw(struct rxe_mw *mw) >> +{ >> + if (mw->mr) { >> + struct rxe_mr *mr = mw->mr; >> + >> + mw->mr = NULL; >> + atomic_dec(&mr->num_mw); > > What is the usage of this num_mw? > > Zhu Yanjun > I added a 10th patch to the series as v4 to address this. The other 9 are identical to v3. Just checked if mr->num_mw > 0 and return -EINVAL if so for dereg MR and invalidate MR. Bob