Skip to content

Commit

Permalink
RDMA/rxe: Remove duplicate entries in struct rxe_mr
Browse files Browse the repository at this point in the history
Struct rxe_mem had pd, lkey and rkey values both in itself and in the
struct ib_mr which is also included in rxe_mem.

Delete these entries and replace references with the ones in ibmr.Add
mr_pd, mr_lkey and mr_rkey macros which extract these values from mr.

Link: https://lore.kernel.org/r/20201008212818.265303-1-rpearson@hpe.com
Signed-off-by: Bob Pearson <rpearson@hpe.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
  • Loading branch information
Bob Pearson authored and Jason Gunthorpe committed Oct 8, 2020
1 parent f2e7449 commit 1858d98
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
25 changes: 10 additions & 15 deletions drivers/infiniband/sw/rxe/rxe_mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,8 @@ static void rxe_mem_init(int access, struct rxe_mem *mem)
u32 lkey = mem->pelem.index << 8 | rxe_get_key();
u32 rkey = (access & IB_ACCESS_REMOTE) ? lkey : 0;

if (mem->pelem.pool->type == RXE_TYPE_MR) {
mem->ibmr.lkey = lkey;
mem->ibmr.rkey = rkey;
}

mem->lkey = lkey;
mem->rkey = rkey;
mem->ibmr.lkey = lkey;
mem->ibmr.rkey = rkey;
mem->state = RXE_MEM_STATE_INVALID;
mem->type = RXE_MEM_TYPE_NONE;
mem->map_shift = ilog2(RXE_BUF_PER_MAP);
Expand Down Expand Up @@ -122,7 +117,7 @@ void rxe_mem_init_dma(struct rxe_pd *pd,
{
rxe_mem_init(access, mem);

mem->pd = pd;
mem->ibmr.pd = &pd->ibpd;
mem->access = access;
mem->state = RXE_MEM_STATE_VALID;
mem->type = RXE_MEM_TYPE_DMA;
Expand Down Expand Up @@ -191,7 +186,7 @@ int rxe_mem_init_user(struct rxe_pd *pd, u64 start,
}
}

mem->pd = pd;
mem->ibmr.pd = &pd->ibpd;
mem->umem = umem;
mem->access = access;
mem->length = length;
Expand Down Expand Up @@ -221,7 +216,7 @@ int rxe_mem_init_fast(struct rxe_pd *pd,
if (err)
goto err1;

mem->pd = pd;
mem->ibmr.pd = &pd->ibpd;
mem->max_buf = max_pages;
mem->state = RXE_MEM_STATE_FREE;
mem->type = RXE_MEM_TYPE_MR;
Expand Down Expand Up @@ -341,7 +336,7 @@ int rxe_mem_copy(struct rxe_mem *mem, u64 iova, void *addr, int length,
memcpy(dest, src, length);

if (crcp)
*crcp = rxe_crc32(to_rdev(mem->pd->ibpd.device),
*crcp = rxe_crc32(to_rdev(mem->ibmr.device),
*crcp, dest, length);

return 0;
Expand Down Expand Up @@ -375,7 +370,7 @@ int rxe_mem_copy(struct rxe_mem *mem, u64 iova, void *addr, int length,
memcpy(dest, src, bytes);

if (crcp)
crc = rxe_crc32(to_rdev(mem->pd->ibpd.device),
crc = rxe_crc32(to_rdev(mem->ibmr.device),
crc, dest, bytes);

length -= bytes;
Expand Down Expand Up @@ -548,9 +543,9 @@ struct rxe_mem *lookup_mem(struct rxe_pd *pd, int access, u32 key,
if (!mem)
return NULL;

if (unlikely((type == lookup_local && mem->lkey != key) ||
(type == lookup_remote && mem->rkey != key) ||
mem->pd != pd ||
if (unlikely((type == lookup_local && mr_lkey(mem) != key) ||
(type == lookup_remote && mr_rkey(mem) != key) ||
mr_pd(mem) != pd ||
(access && !(access & mem->access)) ||
mem->state != RXE_MEM_STATE_VALID)) {
rxe_drop_ref(mem);
Expand Down
4 changes: 2 additions & 2 deletions drivers/infiniband/sw/rxe/rxe_req.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,8 @@ int rxe_requester(void *arg)

rmr->state = RXE_MEM_STATE_VALID;
rmr->access = wqe->wr.wr.reg.access;
rmr->lkey = wqe->wr.wr.reg.key;
rmr->rkey = wqe->wr.wr.reg.key;
rmr->ibmr.lkey = wqe->wr.wr.reg.key;
rmr->ibmr.rkey = wqe->wr.wr.reg.key;
rmr->iova = wqe->wr.wr.reg.mr->iova;
wqe->state = wqe_state_done;
wqe->status = IB_WC_SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/sw/rxe/rxe_verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ static int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
struct rxe_mem *mr = to_rmr(ibmr);

mr->state = RXE_MEM_STATE_ZOMBIE;
rxe_drop_ref(mr->pd);
rxe_drop_ref(mr_pd(mr));
rxe_drop_index(mr);
rxe_drop_ref(mr);
return 0;
Expand Down
19 changes: 15 additions & 4 deletions drivers/infiniband/sw/rxe/rxe_verbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,8 @@ struct rxe_mem {
struct ib_mw ibmw;
};

struct rxe_pd *pd;
struct ib_umem *umem;

u32 lkey;
u32 rkey;

enum rxe_mem_state state;
enum rxe_mem_type type;
u64 va;
Expand Down Expand Up @@ -438,6 +434,21 @@ static inline struct rxe_mem *to_rmw(struct ib_mw *mw)
return mw ? container_of(mw, struct rxe_mem, ibmw) : NULL;
}

static inline struct rxe_pd *mr_pd(struct rxe_mem *mr)
{
return to_rpd(mr->ibmr.pd);
}

static inline u32 mr_lkey(struct rxe_mem *mr)
{
return mr->ibmr.lkey;
}

static inline u32 mr_rkey(struct rxe_mem *mr)
{
return mr->ibmr.rkey;
}

int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name);

void rxe_mc_cleanup(struct rxe_pool_entry *arg);
Expand Down

0 comments on commit 1858d98

Please sign in to comment.