aboutsummaryrefslogtreecommitdiffstats
path: root/include/rdma
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2016-09-05 06:56:17 -0400
committerDoug Ledford <dledford@redhat.com>2016-09-23 13:47:44 -0400
commited082d36a7b2c27d1cda55fdfb28af18040c4a89 (patch)
tree6af4a8de8bb358866c8b1267ef24765b498a6b5e /include/rdma
parent50d46335b03baa9767e79a6f4757df7bd31eba21 (diff)
IB/core: add support to create a unsafe global rkey to ib_create_pd
Instead of exposing ib_get_dma_mr to ULPs and letting them use it more or less unchecked, this moves the capability of creating a global rkey into the RDMA core, where it can be easily audited. It also prints a warning everytime this feature is used as well. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> Reviewed-by: Steve Wise <swise@opengridcomputing.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'include/rdma')
-rw-r--r--include/rdma/ib_verbs.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 38a08dae49c4..4bdd898697cf 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1370,10 +1370,13 @@ struct ib_udata {
1370 1370
1371struct ib_pd { 1371struct ib_pd {
1372 u32 local_dma_lkey; 1372 u32 local_dma_lkey;
1373 u32 flags;
1373 struct ib_device *device; 1374 struct ib_device *device;
1374 struct ib_uobject *uobject; 1375 struct ib_uobject *uobject;
1375 atomic_t usecnt; /* count all resources */ 1376 atomic_t usecnt; /* count all resources */
1376 1377
1378 u32 unsafe_global_rkey;
1379
1377 /* 1380 /*
1378 * Implementation details of the RDMA core, don't use in drivers: 1381 * Implementation details of the RDMA core, don't use in drivers:
1379 */ 1382 */
@@ -2506,8 +2509,23 @@ int ib_find_gid(struct ib_device *device, union ib_gid *gid,
2506int ib_find_pkey(struct ib_device *device, 2509int ib_find_pkey(struct ib_device *device,
2507 u8 port_num, u16 pkey, u16 *index); 2510 u8 port_num, u16 pkey, u16 *index);
2508 2511
2509struct ib_pd *ib_alloc_pd(struct ib_device *device); 2512enum ib_pd_flags {
2513 /*
2514 * Create a memory registration for all memory in the system and place
2515 * the rkey for it into pd->unsafe_global_rkey. This can be used by
2516 * ULPs to avoid the overhead of dynamic MRs.
2517 *
2518 * This flag is generally considered unsafe and must only be used in
2519 * extremly trusted environments. Every use of it will log a warning
2520 * in the kernel log.
2521 */
2522 IB_PD_UNSAFE_GLOBAL_RKEY = 0x01,
2523};
2510 2524
2525struct ib_pd *__ib_alloc_pd(struct ib_device *device, unsigned int flags,
2526 const char *caller);
2527#define ib_alloc_pd(device, flags) \
2528 __ib_alloc_pd((device), (flags), __func__)
2511void ib_dealloc_pd(struct ib_pd *pd); 2529void ib_dealloc_pd(struct ib_pd *pd);
2512 2530
2513/** 2531/**