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:
22 class iterator {
23 friend class device_list;
24 size_t i_;
25 struct ibv_device **devices_;
26 iterator(struct ibv_device **devices, size_t i);
27
28 public:
29 using iterator_category = std::forward_iterator_tag;
30 using value_type = struct ibv_device *;
31 using difference_type = std::ptrdiff_t;
32 using pointer = value_type *;
33 using reference = value_type &;
34
35 struct ibv_device *&operator*();
36 bool operator==(device_list::iterator const &other) const;
37 bool operator!=(device_list::iterator const &other) const;
38 device_list::iterator &operator++();
39 device_list::iterator &operator++(int);
40 };
42 size_t size();
43 struct ibv_device *at(size_t i);
44 iterator begin();
45 iterator end();
47};
48
53class device : public noncopyable {
54 struct ibv_device *device_;
55 struct ibv_context *ctx_;
56 struct ibv_port_attr port_attr_;
57 struct ibv_device_attr_ex device_attr_ex_;
58 union ibv_gid gid_;
59
60 int gid_index_;
61 uint16_t port_num_;
62 friend class pd;
63 friend class cq;
64 friend class qp;
65 friend class srq;
66 void open_device(struct ibv_device *target, uint16_t port_num);
67
68public:
75 device(struct ibv_device *target, uint16_t port_num = 1);
76
83 device(std::string const &device_name, uint16_t port_num = 1);
84
91 device(uint16_t device_num = 0, uint16_t port_num = 1);
92
98 uint16_t port_num() const;
99
105 uint16_t lid() const;
106
112 union ibv_gid gid() const;
113
120 bool is_fetch_and_add_supported() const;
121
129
130 int gid_index() const;
131
132 static std::string gid_hex_string(union ibv_gid const &gid);
133
134 ~device();
135};
136
137} // namespace rdmapp
This class is an abstraction of a Completion Queue.
Definition cq.h:22
Definition device.h:22
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:53
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
device(struct ibv_device *target, uint16_t port_num=1)
Construct a new device object.
Definition device.cc:103
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