21#include <infiniband/verbs.h>
33 #include <boost/python.hpp>
34namespace bp = boost::python;
38rpr::Core::Core(
const std::string& deviceName,
44 deviceName_(deviceName),
47 maxPayload_(maxPayload) {
62 struct ibv_device** devList = ibv_get_device_list(&numDevices);
63 if (!devList || numDevices == 0) {
64 if (devList) ibv_free_device_list(devList);
66 "No RDMA devices found on this host"));
69 struct ibv_device* dev =
nullptr;
70 for (
int i = 0; i < numDevices; ++i) {
71 if (
deviceName_ == ibv_get_device_name(devList[i])) {
78 ibv_free_device_list(devList);
80 "RDMA device '%s' not found",
84 ctx_ = ibv_open_device(dev);
85 ibv_free_device_list(devList);
89 "Failed to open RDMA device '%s'",
100 ibv_close_device(
ctx_);
103 "Failed to allocate protection domain"));
106 log_->info(
"Opened RoCEv2 device '%s', port %u, GID index %u",
120 if (pd_) ibv_dealloc_pd(pd_);
121 if (ctx_) ibv_close_device(ctx_);
124void rpr::Core::setup_python() {
126 bp::class_<rpr::Core, rpr::CorePtr, boost::noncopyable>(
"Core", bp::no_init)
127 .def(
"maxPayload", &rpr::Core::maxPayload);
static GeneralError create(std::string src, const char *fmt,...)
Creates a formatted error instance.
RAII helper that releases the Python GIL for a scope.
static std::shared_ptr< rogue::Logging > create(const std::string &name, bool quiet=false)
Creates a logger instance.
std::shared_ptr< rogue::Logging > log_
struct ibv_context * ctx_
static const uint32_t DefaultMaxPayload
static const uint32_t DefaultRxQueueDepth