diff --git a/include/villas/memory/ib.h b/include/villas/memory/ib.h index 2f4597657..4b9996b67 100644 --- a/include/villas/memory/ib.h +++ b/include/villas/memory/ib.h @@ -28,4 +28,4 @@ struct memory_ib { struct memory_type *parent; }; -struct ibv_mr * memory_ib_get_mr(struct sample *smps); +struct ibv_mr * memory_ib_get_mr(void *ptr); diff --git a/include/villas/pool.h b/include/villas/pool.h index 047ba0341..cb2ed0bbf 100644 --- a/include/villas/pool.h +++ b/include/villas/pool.h @@ -50,6 +50,7 @@ struct pool { }; #define INLINE static inline __attribute__((unused)) +#define pool_buffer(p) ((char *) (p) + (p)->buffer_off) /** Initiazlize a pool * diff --git a/lib/memory/ib.c b/lib/memory/ib.c index 3a5f24da6..cae97f1ec 100644 --- a/lib/memory/ib.c +++ b/lib/memory/ib.c @@ -27,16 +27,14 @@ #include #include -struct ibv_mr * memory_ib_get_mr(struct sample *smps) +struct ibv_mr * memory_ib_get_mr(void *ptr) { struct memory_allocation *ma; - struct pool *p; struct ibv_mr *mr; - p = sample_pool(smps); - - ma = memory_get_allocation((char *) (p) + p->buffer_off); + ma = memory_get_allocation(ptr); mr = ma->ib.mr; + return mr; } diff --git a/lib/nodes/infiniband.c b/lib/nodes/infiniband.c index 258d0517c..f16d7ae05 100644 --- a/lib/nodes/infiniband.c +++ b/lib/nodes/infiniband.c @@ -803,7 +803,7 @@ int ib_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned *relea } // Get Memory Region - mr = memory_ib_get_mr(smps[0]); + mr = memory_ib_get_mr( pool_buffer( sample_pool(smps[0]) ) ); for (int i = 0; i < max_wr_post; i++) { int j = 0; @@ -915,7 +915,7 @@ int ib_write(struct node *n, struct sample *smps[], unsigned cnt, unsigned *rele // First, write // Get Memory Region - mr = memory_ib_get_mr(smps[0]); + mr = memory_ib_get_mr( pool_buffer( sample_pool(smps[0]) ) ); for (sent = 0; sent < cnt; sent++) { int j = 0;