diff options
author | Roland Dreier <rolandd@cisco.com> | 2005-07-07 20:57:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-07 21:23:49 -0400 |
commit | 99264c1ee2ce908f95c075cce97698758a793b58 (patch) | |
tree | d6ce99ee31aa1da65531f67268695f89d9e876d2 /drivers/infiniband/hw | |
parent | 53b8b3ffd5e0b10f3c683096a663d0cc22179c43 (diff) |
[PATCH] IB uverbs: add mthca user PD support
Add support for userspace protection domains (PDs) to mthca.
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/infiniband/hw')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_dev.h | 3 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_main.c | 2 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_pd.c | 24 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_provider.c | 10 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_provider.h | 1 |
5 files changed, 28 insertions, 12 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h index 4127f09dc5ec..3801facf6f1f 100644 --- a/drivers/infiniband/hw/mthca/mthca_dev.h +++ b/drivers/infiniband/hw/mthca/mthca_dev.h | |||
@@ -1,6 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. | 2 | * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. |
3 | * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. | 3 | * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. |
4 | * Copyright (c) 2005 Cisco Systems. All rights reserved. | ||
4 | * | 5 | * |
5 | * This software is available to you under a choice of one of two | 6 | * This software is available to you under a choice of one of two |
6 | * licenses. You may choose to be licensed under the terms of the GNU | 7 | * licenses. You may choose to be licensed under the terms of the GNU |
@@ -378,7 +379,7 @@ void mthca_unregister_device(struct mthca_dev *dev); | |||
378 | int mthca_uar_alloc(struct mthca_dev *dev, struct mthca_uar *uar); | 379 | int mthca_uar_alloc(struct mthca_dev *dev, struct mthca_uar *uar); |
379 | void mthca_uar_free(struct mthca_dev *dev, struct mthca_uar *uar); | 380 | void mthca_uar_free(struct mthca_dev *dev, struct mthca_uar *uar); |
380 | 381 | ||
381 | int mthca_pd_alloc(struct mthca_dev *dev, struct mthca_pd *pd); | 382 | int mthca_pd_alloc(struct mthca_dev *dev, int privileged, struct mthca_pd *pd); |
382 | void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd); | 383 | void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd); |
383 | 384 | ||
384 | struct mthca_mtt *mthca_alloc_mtt(struct mthca_dev *dev, int size); | 385 | struct mthca_mtt *mthca_alloc_mtt(struct mthca_dev *dev, int size); |
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c index 09519b604c08..2ef916859e17 100644 --- a/drivers/infiniband/hw/mthca/mthca_main.c +++ b/drivers/infiniband/hw/mthca/mthca_main.c | |||
@@ -665,7 +665,7 @@ static int __devinit mthca_setup_hca(struct mthca_dev *dev) | |||
665 | goto err_pd_table_free; | 665 | goto err_pd_table_free; |
666 | } | 666 | } |
667 | 667 | ||
668 | err = mthca_pd_alloc(dev, &dev->driver_pd); | 668 | err = mthca_pd_alloc(dev, 1, &dev->driver_pd); |
669 | if (err) { | 669 | if (err) { |
670 | mthca_err(dev, "Failed to create driver PD, " | 670 | mthca_err(dev, "Failed to create driver PD, " |
671 | "aborting.\n"); | 671 | "aborting.\n"); |
diff --git a/drivers/infiniband/hw/mthca/mthca_pd.c b/drivers/infiniband/hw/mthca/mthca_pd.c index ea66847e4ea3..c2c899844e98 100644 --- a/drivers/infiniband/hw/mthca/mthca_pd.c +++ b/drivers/infiniband/hw/mthca/mthca_pd.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2004 Topspin Communications. All rights reserved. | 2 | * Copyright (c) 2004 Topspin Communications. All rights reserved. |
3 | * Copyright (c) 2005 Cisco Systems. All rights reserved. | ||
3 | * | 4 | * |
4 | * This software is available to you under a choice of one of two | 5 | * This software is available to you under a choice of one of two |
5 | * licenses. You may choose to be licensed under the terms of the GNU | 6 | * licenses. You may choose to be licensed under the terms of the GNU |
@@ -37,23 +38,27 @@ | |||
37 | 38 | ||
38 | #include "mthca_dev.h" | 39 | #include "mthca_dev.h" |
39 | 40 | ||
40 | int mthca_pd_alloc(struct mthca_dev *dev, struct mthca_pd *pd) | 41 | int mthca_pd_alloc(struct mthca_dev *dev, int privileged, struct mthca_pd *pd) |
41 | { | 42 | { |
42 | int err; | 43 | int err = 0; |
43 | 44 | ||
44 | might_sleep(); | 45 | might_sleep(); |
45 | 46 | ||
47 | pd->privileged = privileged; | ||
48 | |||
46 | atomic_set(&pd->sqp_count, 0); | 49 | atomic_set(&pd->sqp_count, 0); |
47 | pd->pd_num = mthca_alloc(&dev->pd_table.alloc); | 50 | pd->pd_num = mthca_alloc(&dev->pd_table.alloc); |
48 | if (pd->pd_num == -1) | 51 | if (pd->pd_num == -1) |
49 | return -ENOMEM; | 52 | return -ENOMEM; |
50 | 53 | ||
51 | err = mthca_mr_alloc_notrans(dev, pd->pd_num, | 54 | if (privileged) { |
52 | MTHCA_MPT_FLAG_LOCAL_READ | | 55 | err = mthca_mr_alloc_notrans(dev, pd->pd_num, |
53 | MTHCA_MPT_FLAG_LOCAL_WRITE, | 56 | MTHCA_MPT_FLAG_LOCAL_READ | |
54 | &pd->ntmr); | 57 | MTHCA_MPT_FLAG_LOCAL_WRITE, |
55 | if (err) | 58 | &pd->ntmr); |
56 | mthca_free(&dev->pd_table.alloc, pd->pd_num); | 59 | if (err) |
60 | mthca_free(&dev->pd_table.alloc, pd->pd_num); | ||
61 | } | ||
57 | 62 | ||
58 | return err; | 63 | return err; |
59 | } | 64 | } |
@@ -61,7 +66,8 @@ int mthca_pd_alloc(struct mthca_dev *dev, struct mthca_pd *pd) | |||
61 | void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd) | 66 | void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd) |
62 | { | 67 | { |
63 | might_sleep(); | 68 | might_sleep(); |
64 | mthca_free_mr(dev, &pd->ntmr); | 69 | if (pd->privileged) |
70 | mthca_free_mr(dev, &pd->ntmr); | ||
65 | mthca_free(&dev->pd_table.alloc, pd->pd_num); | 71 | mthca_free(&dev->pd_table.alloc, pd->pd_num); |
66 | } | 72 | } |
67 | 73 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 9acb8c54ce4f..318356c19abe 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c | |||
@@ -368,12 +368,20 @@ static struct ib_pd *mthca_alloc_pd(struct ib_device *ibdev, | |||
368 | if (!pd) | 368 | if (!pd) |
369 | return ERR_PTR(-ENOMEM); | 369 | return ERR_PTR(-ENOMEM); |
370 | 370 | ||
371 | err = mthca_pd_alloc(to_mdev(ibdev), pd); | 371 | err = mthca_pd_alloc(to_mdev(ibdev), !context, pd); |
372 | if (err) { | 372 | if (err) { |
373 | kfree(pd); | 373 | kfree(pd); |
374 | return ERR_PTR(err); | 374 | return ERR_PTR(err); |
375 | } | 375 | } |
376 | 376 | ||
377 | if (context) { | ||
378 | if (ib_copy_to_udata(udata, &pd->pd_num, sizeof (__u32))) { | ||
379 | mthca_pd_free(to_mdev(ibdev), pd); | ||
380 | kfree(pd); | ||
381 | return ERR_PTR(-EFAULT); | ||
382 | } | ||
383 | } | ||
384 | |||
377 | return &pd->ibpd; | 385 | return &pd->ibpd; |
378 | } | 386 | } |
379 | 387 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.h b/drivers/infiniband/hw/mthca/mthca_provider.h index 27cd43cadd48..579d10cd1426 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.h +++ b/drivers/infiniband/hw/mthca/mthca_provider.h | |||
@@ -92,6 +92,7 @@ struct mthca_pd { | |||
92 | u32 pd_num; | 92 | u32 pd_num; |
93 | atomic_t sqp_count; | 93 | atomic_t sqp_count; |
94 | struct mthca_mr ntmr; | 94 | struct mthca_mr ntmr; |
95 | int privileged; | ||
95 | }; | 96 | }; |
96 | 97 | ||
97 | struct mthca_eq { | 98 | struct mthca_eq { |