static const uint32_t TCP_MSG_LEN = sizeof("0000:00000000:00000000:00000000:00000000000000000000000000000000");
static const uint32_t CQ_DEPTH = 30000;
-Port::Port(CephContext *cct, struct ibv_context* ictxt, uint8_t ipn): ctxt(ictxt), port_num(ipn), port_attr(new ibv_port_attr), gid_idx(0)
+Port::Port(CephContext *cct, struct ibv_context* ictxt, uint8_t ipn): ctxt(ictxt), port_num(ipn), gid_idx(0)
{
+ int r = ibv_query_port(ctxt, port_num, &port_attr);
+ if (r == -1) {
+ lderr(cct) << __func__ << " query port failed " << cpp_strerror(errno) << dendl;
+ ceph_abort();
+ }
+
+ lid = port_attr.lid;
+
#ifdef HAVE_IBV_EXP
union ibv_gid cgid;
struct ibv_exp_gid_attr gid_attr;
bool malformed = false;
ldout(cct,1) << __func__ << " using experimental verbs for gid" << dendl;
- int r = ibv_query_port(ctxt, port_num, port_attr);
- if (r == -1) {
- lderr(cct) << __func__ << " query port failed " << cpp_strerror(errno) << dendl;
- ceph_abort();
- }
- lid = port_attr->lid;
// search for requested GID in GIDs table
ldout(cct, 1) << __func__ << " looking for local GID " << (cct->_conf->ms_async_rdma_local_gid)
gid_attr.comp_mask = IBV_EXP_QUERY_GID_ATTR_TYPE;
- for (gid_idx = 0; gid_idx < port_attr->gid_tbl_len; gid_idx++) {
+ for (gid_idx = 0; gid_idx < port_attr.gid_tbl_len; gid_idx++) {
r = ibv_query_gid(ctxt, port_num, gid_idx, &gid);
if (r) {
lderr(cct) << __func__ << " query gid of port " << port_num << " index " << gid_idx << " failed " << cpp_strerror(errno) << dendl;
}
}
- if (gid_idx == port_attr->gid_tbl_len) {
+ if (gid_idx == port_attr.gid_tbl_len) {
lderr(cct) << __func__ << " Requested local GID was not found in GID table" << dendl;
ceph_abort();
}
#else
- int r = ibv_query_port(ctxt, port_num, port_attr);
- if (r == -1) {
- lderr(cct) << __func__ << " query port failed " << cpp_strerror(errno) << dendl;
- ceph_abort();
- }
-
- lid = port_attr->lid;
r = ibv_query_gid(ctxt, port_num, 0, &gid);
if (r) {
lderr(cct) << __func__ << " query gid failed " << cpp_strerror(errno) << dendl;
class Port {
struct ibv_context* ctxt;
int port_num;
- struct ibv_port_attr* port_attr;
+ struct ibv_port_attr port_attr;
uint16_t lid;
int gid_idx = 0;
union ibv_gid gid;
uint16_t get_lid() { return lid; }
ibv_gid get_gid() { return gid; }
int get_port_num() { return port_num; }
- ibv_port_attr* get_port_attr() { return port_attr; }
+ ibv_port_attr* get_port_attr() { return &port_attr; }
int get_gid_idx() { return gid_idx; }
};