diff options
author | Steve Wise <swise@opengridcomputing.com> | 2007-03-06 15:44:07 -0500 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2007-03-06 15:51:02 -0500 |
commit | e64518f3736971f22d5c22a6bab40891d2db337f (patch) | |
tree | a2ae27fac4f9630aa8f92d7e68e683e0a054b67f /drivers/infiniband/hw/cxgb3 | |
parent | 1f6a849b7ce6c3007088cd437dfc2b9c7cb5d21e (diff) |
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: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw/cxgb3')
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_provider.c | 24 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_provider.h | 33 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_qp.c | 2 |
3 files changed, 18 insertions, 41 deletions
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c index 9fe7dfeb7c8..f2774ae906b 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_provider.c +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c | |||
@@ -465,9 +465,6 @@ static struct ib_mr *iwch_register_phys_mem(struct ib_pd *pd, | |||
465 | php = to_iwch_pd(pd); | 465 | php = to_iwch_pd(pd); |
466 | rhp = php->rhp; | 466 | rhp = php->rhp; |
467 | 467 | ||
468 | acc = iwch_convert_access(acc); | ||
469 | |||
470 | |||
471 | mhp = kzalloc(sizeof(*mhp), GFP_KERNEL); | 468 | mhp = kzalloc(sizeof(*mhp), GFP_KERNEL); |
472 | if (!mhp) | 469 | if (!mhp) |
473 | return ERR_PTR(-ENOMEM); | 470 | return ERR_PTR(-ENOMEM); |
@@ -493,12 +490,7 @@ static struct ib_mr *iwch_register_phys_mem(struct ib_pd *pd, | |||
493 | mhp->attr.pdid = php->pdid; | 490 | mhp->attr.pdid = php->pdid; |
494 | mhp->attr.zbva = 0; | 491 | mhp->attr.zbva = 0; |
495 | 492 | ||
496 | /* NOTE: TPT perms are backwards from BIND WR perms! */ | 493 | mhp->attr.perms = iwch_ib_to_tpt_access(acc); |
497 | mhp->attr.perms = (acc & 0x1) << 3; | ||
498 | mhp->attr.perms |= (acc & 0x2) << 1; | ||
499 | mhp->attr.perms |= (acc & 0x4) >> 1; | ||
500 | mhp->attr.perms |= (acc & 0x8) >> 3; | ||
501 | |||
502 | mhp->attr.va_fbo = *iova_start; | 494 | mhp->attr.va_fbo = *iova_start; |
503 | mhp->attr.page_size = shift - 12; | 495 | mhp->attr.page_size = shift - 12; |
504 | 496 | ||
@@ -527,7 +519,6 @@ static int iwch_reregister_phys_mem(struct ib_mr *mr, | |||
527 | struct iwch_mr mh, *mhp; | 519 | struct iwch_mr mh, *mhp; |
528 | struct iwch_pd *php; | 520 | struct iwch_pd *php; |
529 | struct iwch_dev *rhp; | 521 | struct iwch_dev *rhp; |
530 | int new_acc; | ||
531 | __be64 *page_list = NULL; | 522 | __be64 *page_list = NULL; |
532 | int shift = 0; | 523 | int shift = 0; |
533 | u64 total_size; | 524 | u64 total_size; |
@@ -548,14 +539,12 @@ static int iwch_reregister_phys_mem(struct ib_mr *mr, | |||
548 | if (rhp != php->rhp) | 539 | if (rhp != php->rhp) |
549 | return -EINVAL; | 540 | return -EINVAL; |
550 | 541 | ||
551 | new_acc = mhp->attr.perms; | ||
552 | |||
553 | memcpy(&mh, mhp, sizeof *mhp); | 542 | memcpy(&mh, mhp, sizeof *mhp); |
554 | 543 | ||
555 | if (mr_rereg_mask & IB_MR_REREG_PD) | 544 | if (mr_rereg_mask & IB_MR_REREG_PD) |
556 | php = to_iwch_pd(pd); | 545 | php = to_iwch_pd(pd); |
557 | if (mr_rereg_mask & IB_MR_REREG_ACCESS) | 546 | if (mr_rereg_mask & IB_MR_REREG_ACCESS) |
558 | mh.attr.perms = iwch_convert_access(acc); | 547 | mh.attr.perms = iwch_ib_to_tpt_access(acc); |
559 | if (mr_rereg_mask & IB_MR_REREG_TRANS) | 548 | if (mr_rereg_mask & IB_MR_REREG_TRANS) |
560 | ret = build_phys_page_list(buffer_list, num_phys_buf, | 549 | ret = build_phys_page_list(buffer_list, num_phys_buf, |
561 | iova_start, | 550 | iova_start, |
@@ -570,7 +559,7 @@ static int iwch_reregister_phys_mem(struct ib_mr *mr, | |||
570 | if (mr_rereg_mask & IB_MR_REREG_PD) | 559 | if (mr_rereg_mask & IB_MR_REREG_PD) |
571 | mhp->attr.pdid = php->pdid; | 560 | mhp->attr.pdid = php->pdid; |
572 | if (mr_rereg_mask & IB_MR_REREG_ACCESS) | 561 | if (mr_rereg_mask & IB_MR_REREG_ACCESS) |
573 | mhp->attr.perms = acc; | 562 | mhp->attr.perms = iwch_ib_to_tpt_access(acc); |
574 | if (mr_rereg_mask & IB_MR_REREG_TRANS) { | 563 | if (mr_rereg_mask & IB_MR_REREG_TRANS) { |
575 | mhp->attr.zbva = 0; | 564 | mhp->attr.zbva = 0; |
576 | mhp->attr.va_fbo = *iova_start; | 565 | 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 | goto err; | 604 | goto err; |
616 | } | 605 | } |
617 | 606 | ||
618 | acc = iwch_convert_access(acc); | ||
619 | |||
620 | i = n = 0; | 607 | i = n = 0; |
621 | 608 | ||
622 | list_for_each_entry(chunk, ®ion->chunk_list, list) | 609 | list_for_each_entry(chunk, ®ion->chunk_list, list) |
@@ -632,10 +619,7 @@ static struct ib_mr *iwch_reg_user_mr(struct ib_pd *pd, struct ib_umem *region, | |||
632 | mhp->rhp = rhp; | 619 | mhp->rhp = rhp; |
633 | mhp->attr.pdid = php->pdid; | 620 | mhp->attr.pdid = php->pdid; |
634 | mhp->attr.zbva = 0; | 621 | mhp->attr.zbva = 0; |
635 | mhp->attr.perms = (acc & 0x1) << 3; | 622 | mhp->attr.perms = iwch_ib_to_tpt_access(acc); |
636 | mhp->attr.perms |= (acc & 0x2) << 1; | ||
637 | mhp->attr.perms |= (acc & 0x4) >> 1; | ||
638 | mhp->attr.perms |= (acc & 0x8) >> 3; | ||
639 | mhp->attr.va_fbo = region->virt_base; | 623 | mhp->attr.va_fbo = region->virt_base; |
640 | mhp->attr.page_size = shift - 12; | 624 | mhp->attr.page_size = shift - 12; |
641 | mhp->attr.len = (u32) region->length; | 625 | mhp->attr.len = (u32) region->length; |
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.h b/drivers/infiniband/hw/cxgb3/iwch_provider.h index de0fe1b93a0..93bcc56756b 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_provider.h +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.h | |||
@@ -286,27 +286,20 @@ static inline int iwch_convert_state(enum ib_qp_state ib_state) | |||
286 | } | 286 | } |
287 | } | 287 | } |
288 | 288 | ||
289 | enum iwch_mem_perms { | 289 | static inline u32 iwch_ib_to_tpt_access(int acc) |
290 | IWCH_MEM_ACCESS_LOCAL_READ = 1 << 0, | ||
291 | IWCH_MEM_ACCESS_LOCAL_WRITE = 1 << 1, | ||
292 | IWCH_MEM_ACCESS_REMOTE_READ = 1 << 2, | ||
293 | IWCH_MEM_ACCESS_REMOTE_WRITE = 1 << 3, | ||
294 | IWCH_MEM_ACCESS_ATOMICS = 1 << 4, | ||
295 | IWCH_MEM_ACCESS_BINDING = 1 << 5, | ||
296 | IWCH_MEM_ACCESS_LOCAL = | ||
297 | (IWCH_MEM_ACCESS_LOCAL_READ | IWCH_MEM_ACCESS_LOCAL_WRITE), | ||
298 | IWCH_MEM_ACCESS_REMOTE = | ||
299 | (IWCH_MEM_ACCESS_REMOTE_WRITE | IWCH_MEM_ACCESS_REMOTE_READ) | ||
300 | /* cannot go beyond 1 << 31 */ | ||
301 | } __attribute__ ((packed)); | ||
302 | |||
303 | static inline u32 iwch_convert_access(int acc) | ||
304 | { | 290 | { |
305 | return (acc & IB_ACCESS_REMOTE_WRITE ? IWCH_MEM_ACCESS_REMOTE_WRITE : 0) | 291 | return (acc & IB_ACCESS_REMOTE_WRITE ? TPT_REMOTE_WRITE : 0) | |
306 | | (acc & IB_ACCESS_REMOTE_READ ? IWCH_MEM_ACCESS_REMOTE_READ : 0) | | 292 | (acc & IB_ACCESS_REMOTE_READ ? TPT_REMOTE_READ : 0) | |
307 | (acc & IB_ACCESS_LOCAL_WRITE ? IWCH_MEM_ACCESS_LOCAL_WRITE : 0) | | 293 | (acc & IB_ACCESS_LOCAL_WRITE ? TPT_LOCAL_WRITE : 0) | |
308 | (acc & IB_ACCESS_MW_BIND ? IWCH_MEM_ACCESS_BINDING : 0) | | 294 | TPT_LOCAL_READ; |
309 | IWCH_MEM_ACCESS_LOCAL_READ; | 295 | } |
296 | |||
297 | static inline u32 iwch_ib_to_mwbind_access(int acc) | ||
298 | { | ||
299 | return (acc & IB_ACCESS_REMOTE_WRITE ? T3_MEM_ACCESS_REM_WRITE : 0) | | ||
300 | (acc & IB_ACCESS_REMOTE_READ ? T3_MEM_ACCESS_REM_READ : 0) | | ||
301 | (acc & IB_ACCESS_LOCAL_WRITE ? T3_MEM_ACCESS_LOCAL_WRITE : 0) | | ||
302 | T3_MEM_ACCESS_LOCAL_READ; | ||
310 | } | 303 | } |
311 | 304 | ||
312 | enum iwch_mmid_state { | 305 | enum iwch_mmid_state { |
diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c index 9ea00cc4a5f..0a472c9b44d 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_qp.c +++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c | |||
@@ -439,7 +439,7 @@ int iwch_bind_mw(struct ib_qp *qp, | |||
439 | wqe->bind.type = T3_VA_BASED_TO; | 439 | wqe->bind.type = T3_VA_BASED_TO; |
440 | 440 | ||
441 | /* TBD: check perms */ | 441 | /* TBD: check perms */ |
442 | wqe->bind.perms = iwch_convert_access(mw_bind->mw_access_flags); | 442 | wqe->bind.perms = iwch_ib_to_mwbind_access(mw_bind->mw_access_flags); |
443 | wqe->bind.mr_stag = cpu_to_be32(mw_bind->mr->lkey); | 443 | wqe->bind.mr_stag = cpu_to_be32(mw_bind->mr->lkey); |
444 | wqe->bind.mw_stag = cpu_to_be32(mw->rkey); | 444 | wqe->bind.mw_stag = cpu_to_be32(mw->rkey); |
445 | wqe->bind.mw_len = cpu_to_be32(mw_bind->length); | 445 | wqe->bind.mw_len = cpu_to_be32(mw_bind->length); |