Commit e64518f3 authored by Steve Wise's avatar Steve Wise Committed by Roland Dreier

RDMA/cxgb3: Fix MR permission problems


Fix memory region permission problems:

- remove useless and redundant iwch_mem_perms enum.

- create ib_to_tpt_access_rights() for mapping ib access rights
  to T3 TPT permissions.

- create ib_to_mwbind_access_rights() for mapping ib access rights
  to T3 MWBIND WR permissions.

- fix up the mem reg code to utilize the new functions.
Signed-off-by: default avatarSteve Wise <swise@opengridcomputing.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 1f6a849b
...@@ -465,9 +465,6 @@ static struct ib_mr *iwch_register_phys_mem(struct ib_pd *pd, ...@@ -465,9 +465,6 @@ static struct ib_mr *iwch_register_phys_mem(struct ib_pd *pd,
php = to_iwch_pd(pd); php = to_iwch_pd(pd);
rhp = php->rhp; rhp = php->rhp;
acc = iwch_convert_access(acc);
mhp = kzalloc(sizeof(*mhp), GFP_KERNEL); mhp = kzalloc(sizeof(*mhp), GFP_KERNEL);
if (!mhp) if (!mhp)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -493,12 +490,7 @@ static struct ib_mr *iwch_register_phys_mem(struct ib_pd *pd, ...@@ -493,12 +490,7 @@ static struct ib_mr *iwch_register_phys_mem(struct ib_pd *pd,
mhp->attr.pdid = php->pdid; mhp->attr.pdid = php->pdid;
mhp->attr.zbva = 0; mhp->attr.zbva = 0;
/* NOTE: TPT perms are backwards from BIND WR perms! */ mhp->attr.perms = iwch_ib_to_tpt_access(acc);
mhp->attr.perms = (acc & 0x1) << 3;
mhp->attr.perms |= (acc & 0x2) << 1;
mhp->attr.perms |= (acc & 0x4) >> 1;
mhp->attr.perms |= (acc & 0x8) >> 3;
mhp->attr.va_fbo = *iova_start; mhp->attr.va_fbo = *iova_start;
mhp->attr.page_size = shift - 12; mhp->attr.page_size = shift - 12;
...@@ -527,7 +519,6 @@ static int iwch_reregister_phys_mem(struct ib_mr *mr, ...@@ -527,7 +519,6 @@ static int iwch_reregister_phys_mem(struct ib_mr *mr,
struct iwch_mr mh, *mhp; struct iwch_mr mh, *mhp;
struct iwch_pd *php; struct iwch_pd *php;
struct iwch_dev *rhp; struct iwch_dev *rhp;
int new_acc;
__be64 *page_list = NULL; __be64 *page_list = NULL;
int shift = 0; int shift = 0;
u64 total_size; u64 total_size;
...@@ -548,14 +539,12 @@ static int iwch_reregister_phys_mem(struct ib_mr *mr, ...@@ -548,14 +539,12 @@ static int iwch_reregister_phys_mem(struct ib_mr *mr,
if (rhp != php->rhp) if (rhp != php->rhp)
return -EINVAL; return -EINVAL;
new_acc = mhp->attr.perms;
memcpy(&mh, mhp, sizeof *mhp); memcpy(&mh, mhp, sizeof *mhp);
if (mr_rereg_mask & IB_MR_REREG_PD) if (mr_rereg_mask & IB_MR_REREG_PD)
php = to_iwch_pd(pd); php = to_iwch_pd(pd);
if (mr_rereg_mask & IB_MR_REREG_ACCESS) if (mr_rereg_mask & IB_MR_REREG_ACCESS)
mh.attr.perms = iwch_convert_access(acc); mh.attr.perms = iwch_ib_to_tpt_access(acc);
if (mr_rereg_mask & IB_MR_REREG_TRANS) if (mr_rereg_mask & IB_MR_REREG_TRANS)
ret = build_phys_page_list(buffer_list, num_phys_buf, ret = build_phys_page_list(buffer_list, num_phys_buf,
iova_start, iova_start,
...@@ -570,7 +559,7 @@ static int iwch_reregister_phys_mem(struct ib_mr *mr, ...@@ -570,7 +559,7 @@ static int iwch_reregister_phys_mem(struct ib_mr *mr,
if (mr_rereg_mask & IB_MR_REREG_PD) if (mr_rereg_mask & IB_MR_REREG_PD)
mhp->attr.pdid = php->pdid; mhp->attr.pdid = php->pdid;
if (mr_rereg_mask & IB_MR_REREG_ACCESS) if (mr_rereg_mask & IB_MR_REREG_ACCESS)
mhp->attr.perms = acc; mhp->attr.perms = iwch_ib_to_tpt_access(acc);
if (mr_rereg_mask & IB_MR_REREG_TRANS) { if (mr_rereg_mask & IB_MR_REREG_TRANS) {
mhp->attr.zbva = 0; mhp->attr.zbva = 0;
mhp->attr.va_fbo = *iova_start; mhp->attr.va_fbo = *iova_start;
...@@ -615,8 +604,6 @@ static struct ib_mr *iwch_reg_user_mr(struct ib_pd *pd, struct ib_umem *region, ...@@ -615,8 +604,6 @@ static struct ib_mr *iwch_reg_user_mr(struct ib_pd *pd, struct ib_umem *region,
goto err; goto err;
} }
acc = iwch_convert_access(acc);
i = n = 0; i = n = 0;
list_for_each_entry(chunk, &region->chunk_list, list) list_for_each_entry(chunk, &region->chunk_list, list)
...@@ -632,10 +619,7 @@ static struct ib_mr *iwch_reg_user_mr(struct ib_pd *pd, struct ib_umem *region, ...@@ -632,10 +619,7 @@ static struct ib_mr *iwch_reg_user_mr(struct ib_pd *pd, struct ib_umem *region,
mhp->rhp = rhp; mhp->rhp = rhp;
mhp->attr.pdid = php->pdid; mhp->attr.pdid = php->pdid;
mhp->attr.zbva = 0; mhp->attr.zbva = 0;
mhp->attr.perms = (acc & 0x1) << 3; mhp->attr.perms = iwch_ib_to_tpt_access(acc);
mhp->attr.perms |= (acc & 0x2) << 1;
mhp->attr.perms |= (acc & 0x4) >> 1;
mhp->attr.perms |= (acc & 0x8) >> 3;
mhp->attr.va_fbo = region->virt_base; mhp->attr.va_fbo = region->virt_base;
mhp->attr.page_size = shift - 12; mhp->attr.page_size = shift - 12;
mhp->attr.len = (u32) region->length; mhp->attr.len = (u32) region->length;
......
...@@ -286,27 +286,20 @@ static inline int iwch_convert_state(enum ib_qp_state ib_state) ...@@ -286,27 +286,20 @@ static inline int iwch_convert_state(enum ib_qp_state ib_state)
} }
} }
enum iwch_mem_perms { static inline u32 iwch_ib_to_tpt_access(int acc)
IWCH_MEM_ACCESS_LOCAL_READ = 1 << 0,
IWCH_MEM_ACCESS_LOCAL_WRITE = 1 << 1,
IWCH_MEM_ACCESS_REMOTE_READ = 1 << 2,
IWCH_MEM_ACCESS_REMOTE_WRITE = 1 << 3,
IWCH_MEM_ACCESS_ATOMICS = 1 << 4,
IWCH_MEM_ACCESS_BINDING = 1 << 5,
IWCH_MEM_ACCESS_LOCAL =
(IWCH_MEM_ACCESS_LOCAL_READ | IWCH_MEM_ACCESS_LOCAL_WRITE),
IWCH_MEM_ACCESS_REMOTE =
(IWCH_MEM_ACCESS_REMOTE_WRITE | IWCH_MEM_ACCESS_REMOTE_READ)
/* cannot go beyond 1 << 31 */
} __attribute__ ((packed));
static inline u32 iwch_convert_access(int acc)
{ {
return (acc & IB_ACCESS_REMOTE_WRITE ? IWCH_MEM_ACCESS_REMOTE_WRITE : 0) return (acc & IB_ACCESS_REMOTE_WRITE ? TPT_REMOTE_WRITE : 0) |
| (acc & IB_ACCESS_REMOTE_READ ? IWCH_MEM_ACCESS_REMOTE_READ : 0) | (acc & IB_ACCESS_REMOTE_READ ? TPT_REMOTE_READ : 0) |
(acc & IB_ACCESS_LOCAL_WRITE ? IWCH_MEM_ACCESS_LOCAL_WRITE : 0) | (acc & IB_ACCESS_LOCAL_WRITE ? TPT_LOCAL_WRITE : 0) |
(acc & IB_ACCESS_MW_BIND ? IWCH_MEM_ACCESS_BINDING : 0) | TPT_LOCAL_READ;
IWCH_MEM_ACCESS_LOCAL_READ; }
static inline u32 iwch_ib_to_mwbind_access(int acc)
{
return (acc & IB_ACCESS_REMOTE_WRITE ? T3_MEM_ACCESS_REM_WRITE : 0) |
(acc & IB_ACCESS_REMOTE_READ ? T3_MEM_ACCESS_REM_READ : 0) |
(acc & IB_ACCESS_LOCAL_WRITE ? T3_MEM_ACCESS_LOCAL_WRITE : 0) |
T3_MEM_ACCESS_LOCAL_READ;
} }
enum iwch_mmid_state { enum iwch_mmid_state {
......
...@@ -439,7 +439,7 @@ int iwch_bind_mw(struct ib_qp *qp, ...@@ -439,7 +439,7 @@ int iwch_bind_mw(struct ib_qp *qp,
wqe->bind.type = T3_VA_BASED_TO; wqe->bind.type = T3_VA_BASED_TO;
/* TBD: check perms */ /* TBD: check perms */
wqe->bind.perms = iwch_convert_access(mw_bind->mw_access_flags); wqe->bind.perms = iwch_ib_to_mwbind_access(mw_bind->mw_access_flags);
wqe->bind.mr_stag = cpu_to_be32(mw_bind->mr->lkey); wqe->bind.mr_stag = cpu_to_be32(mw_bind->mr->lkey);
wqe->bind.mw_stag = cpu_to_be32(mw->rkey); wqe->bind.mw_stag = cpu_to_be32(mw->rkey);
wqe->bind.mw_len = cpu_to_be32(mw_bind->length); wqe->bind.mw_len = cpu_to_be32(mw_bind->length);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment