RDMA++
Loading...
Searching...
No Matches
device.h
1#pragma once
2
3#include <cstdint>
4#include <iterator>
5#include <string>
6
7#include <infiniband/verbs.h>
8
9#include "rdmapp/detail/noncopyable.h"
10
11namespace rdmapp {
12
17class device_list : public noncopyable {
18 struct ibv_device **devices_;
19 size_t nr_devices_;
20
21public:
23 : public std::iterator<std::forward_iterator_tag, struct ibv_device *> {
24 friend class device_list;
25 size_t i_;
26 struct ibv_device **devices_;
27 iterator(struct ibv_device **devices, size_t i);
28
29 public:
30 struct ibv_device *&operator*();
31 bool operator==(device_list::iterator const &other) const;
32 bool operator!=(device_list::iterator const &other) const;
33 device_list::iterator &operator++();
34 device_list::iterator &operator++(int);
35 };
37 size_t size();
38 struct ibv_device *at(size_t i);
39 iterator begin();
40 iterator end();
42};
43
48class device : public noncopyable {
49 struct ibv_device *device_;
50 struct ibv_context *ctx_;
51 struct ibv_port_attr port_attr_;
52 struct ibv_device_attr_ex device_attr_ex_;
53 union ibv_gid gid_;
54
55 int gid_index_;
56 uint16_t port_num_;
57 friend class pd;
58 friend class cq;
59 friend class qp;
60 friend class srq;
61 void open_device(struct ibv_device *target, uint16_t port_num);
62
63public:
70 device(struct ibv_device *target, uint16_t port_num = 1);
71
78 device(std::string const &device_name, uint16_t port_num = 1);
79
86 device(uint16_t device_num = 0, uint16_t port_num = 1);
87
93 uint16_t port_num() const;
94
100 uint16_t lid() const;
101
107 union ibv_gid gid() const;
108
115 bool is_fetch_and_add_supported() const;
116
124
125 int gid_index() const;
126
127 static std::string gid_hex_string(union ibv_gid const &gid);
128
129 ~device();
130};
131
132} // namespace rdmapp
This class is an abstraction of a Completion Queue.
Definition cq.h:22
Definition device.h:23
This class holds a list of devices available on the system.
Definition device.h:17
This class is an abstraction of an Infiniband device.
Definition device.h:48
union ibv_gid gid() const
Get the gid of the device.
Definition device.cc:137
bool is_fetch_and_add_supported() const
Checks if the device supports fetch and add.
Definition device.cc:147
bool is_compare_and_swap_supported() const
Checks if the device supports compare and swap.
Definition device.cc:143
uint16_t port_num() const
Get the device port number.
Definition device.cc:133
uint16_t lid() const
Get the lid of the device.
Definition device.cc:135
Definition noncopyable.h:5
This class is an abstraction of a Protection Domain.
Definition pd.h:20
This class is an abstraction of an Infiniband Queue Pair.
Definition qp.h:50
This class represents a Shared Receive Queue.
Definition srq.h:15