From f47025f83711d9af4a52470327fbd7411aafdafe Mon Sep 17 00:00:00 2001 From: Amir Vadai Date: Thu, 23 Mar 2017 10:39:08 +0200 Subject: [PATCH] msg/async/rdma: get_device() by ibv_context This function will be used by RDMAConnCM Issue: 995322 Change-Id: I52b684e8bbac14c1070801b2ba470c7c0dfe40b9 Signed-off-by: Amir Vadai --- src/msg/async/rdma/Device.cc | 15 +++++++++++++++ src/msg/async/rdma/Device.h | 1 + src/msg/async/rdma/Infiniband.cc | 5 +++++ src/msg/async/rdma/Infiniband.h | 1 + 4 files changed, 22 insertions(+) diff --git a/src/msg/async/rdma/Device.cc b/src/msg/async/rdma/Device.cc index ee5bbd73fd8..6f7df5b1133 100644 --- a/src/msg/async/rdma/Device.cc +++ b/src/msg/async/rdma/Device.cc @@ -456,6 +456,21 @@ Device* DeviceList::get_device(const char* device_name) return NULL; } + +Device* DeviceList::get_device(const struct ibv_context *ctxt) +{ + ibv_device *device = ctxt->device; + + assert(devices); + for (int i = 0; i < num; ++i) { + if (devices[i]->ctxt->device == device) { + return devices[i]; + } + } + + return NULL; +} + int DeviceList::poll_tx(int num_entries, Device **d, ibv_wc *wc) { int n = 0; diff --git a/src/msg/async/rdma/Device.h b/src/msg/async/rdma/Device.h index 5ba7d5ca4ef..148a7517437 100644 --- a/src/msg/async/rdma/Device.h +++ b/src/msg/async/rdma/Device.h @@ -153,6 +153,7 @@ class DeviceList { ~DeviceList(); Device* get_device(const char* device_name); + Device* get_device(const struct ibv_context *ctxt); void uninit(); diff --git a/src/msg/async/rdma/Infiniband.cc b/src/msg/async/rdma/Infiniband.cc index 0a87b04ed5a..1edb4ca71d6 100644 --- a/src/msg/async/rdma/Infiniband.cc +++ b/src/msg/async/rdma/Infiniband.cc @@ -612,6 +612,11 @@ Device* Infiniband::get_device(const char* device_name) return device_list->get_device(device_name); } +Device *Infiniband::get_device(const struct ibv_context *ctxt) +{ + return device_list->get_device(ctxt); +} + Infiniband::QueuePair::~QueuePair() { if (qp) { diff --git a/src/msg/async/rdma/Infiniband.h b/src/msg/async/rdma/Infiniband.h index a16b093ae3c..53850eda118 100644 --- a/src/msg/async/rdma/Infiniband.h +++ b/src/msg/async/rdma/Infiniband.h @@ -277,6 +277,7 @@ class Infiniband { void handle_pre_fork(); Device* get_device(const char* device_name); + Device* get_device(const struct ibv_context *ctxt); int poll_tx(int n, Device **d, ibv_wc *wc); int poll_rx(int n, Device **d, ibv_wc *wc); -- 2.39.5