Skip to content

Commit e3a5f98

Browse files
authored
[rdma]fix mtu (#957)
1 parent e090521 commit e3a5f98

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

include/ylt/coro_io/ibverbs/ib_device.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,30 @@ struct ib_deleter {
109109
}
110110
};
111111

112+
inline std::string mtu_str(ibv_mtu mtu) {
113+
std::string str;
114+
switch (mtu) {
115+
case IBV_MTU_256:
116+
str = "IBV_MTU_256";
117+
break;
118+
case IBV_MTU_512:
119+
str = "IBV_MTU_512";
120+
break;
121+
case IBV_MTU_1024:
122+
str = "IBV_MTU_1024";
123+
break;
124+
case IBV_MTU_2048:
125+
str = "IBV_MTU_2048";
126+
break;
127+
case IBV_MTU_4096:
128+
str = "IBV_MTU_4096";
129+
break;
130+
default:
131+
break;
132+
}
133+
return str;
134+
}
135+
112136
class ib_device_t {
113137
public:
114138
ib_device_t(const ib_config_t& conf) {
@@ -126,6 +150,9 @@ class ib_device_t {
126150
throw std::system_error(ec);
127151
}
128152

153+
ELOG_INFO << "Active MTU: " << mtu_str(attr_.active_mtu) << ", "
154+
<< "Max MTU: " << mtu_str(attr_.max_mtu);
155+
129156
find_best_gid_index();
130157

131158
ELOG_INFO << "IBDevice " << name_ << ", best gid index " << gid_index_;

include/ylt/coro_io/ibverbs/ib_socket.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ class ib_socket_t {
582582
void modify_qp_to_rtr(uint32_t remote_qpn, uint16_t dlid, uint8_t* dgid) {
583583
ibv_qp_attr attr{};
584584
attr.qp_state = IBV_QPS_RTR;
585-
attr.path_mtu = IBV_MTU_4096;
585+
attr.path_mtu = state_->device_->attr().active_mtu;
586586
attr.dest_qp_num = remote_qpn;
587587
attr.rq_psn = 0;
588588
attr.max_dest_rd_atomic = 1;

src/coro_io/tests/ibverbs/test_device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ TEST_CASE("test device") {
3232
auto pd = dev.pd();
3333
CHECK(pd);
3434
CHECK(dev.port() == 1);
35-
CHECK(dev.gid_index() == 1);
35+
CHECK(dev.gid_index() >= 0);
3636
auto& attr = dev.attr();
3737
}
3838

0 commit comments

Comments
 (0)