| 14 | static bool IBWasInitialized; |
| 15 | |
| 16 | TIntrusivePtr<TIBPort> GetIBDevice() { |
| 17 | TGuard<TMutex> gg(IBPortMutex); |
| 18 | if (IBWasInitialized) { |
| 19 | return IBPort; |
| 20 | } |
| 21 | IBWasInitialized = true; |
| 22 | |
| 23 | try { |
| 24 | int rv = ibv_fork_init(); |
| 25 | if (rv != 0) { |
| 26 | //printf("ibv_fork_init() failed"); |
| 27 | return nullptr; |
| 28 | } |
| 29 | } catch (...) { |
| 30 | //we can not load ib interface, so no ib |
| 31 | return nullptr; |
| 32 | } |
| 33 | |
| 34 | TIntrusivePtr<TIBContext> ctx; |
| 35 | TIntrusivePtr<TIBPort> resPort; |
| 36 | int numDevices{0}; |
| 37 | ibv_device** deviceList = ibv_get_device_list(&numDevices); |
| 38 | //for (int i = 0; i < numDevices; ++i) { |
| 39 | // ibv_device *dev = deviceList[i]; |
| 40 | |
| 41 | // printf("Dev %d\n", i); |
| 42 | // printf("name:%s\ndev_name:%s\ndev_path:%s\nibdev_path:%s\n", |
| 43 | // dev->name, |
| 44 | // dev->dev_name, |
| 45 | // dev->dev_path, |
| 46 | // dev->ibdev_path); |
| 47 | // printf("get_device_name(): %s\n", ibv_get_device_name(dev)); |
| 48 | // ui64 devGuid = ibv_get_device_guid(dev); |
| 49 | // printf("ibv_get_device_guid: %" PRIx64 "\n", devGuid); |
| 50 | // printf("node type: %s\n", ibv_node_type_str(dev->node_type)); |
| 51 | // printf("\n"); |
| 52 | //} |
| 53 | if (numDevices == 1) { |
| 54 | ctx = new TIBContext(deviceList[0]); |
| 55 | TIBContext::TLock ibContext(ctx); |
| 56 | ibv_device_attr devAttrs; |
| 57 | CHECK_Z(ibv_query_device(ibContext.GetContext(), &devAttrs)); |
| 58 | |
| 59 | for (int port = 1; port <= devAttrs.phys_port_cnt; ++port) { |
| 60 | ibv_port_attr portAttrs; |
| 61 | CHECK_Z(ibv_query_port(ibContext.GetContext(), port, &portAttrs)); |
| 62 | //ibv_gid myAddress; // ipv6 address of this port; |
| 63 | //CHECK_Z(ibv_query_gid(ibContext.GetContext(), port, 0, &myAddress)); |
| 64 | //{ |
| 65 | // ibv_gid p = myAddress; |
| 66 | // for (int k = 0; k < 4; ++k) { |
| 67 | // DoSwap(p.raw[k], p.raw[7 - k]); |
| 68 | // DoSwap(p.raw[8 + k], p.raw[15 - k]); |
| 69 | // } |
| 70 | // printf("Port %d, address %" PRIx64 ":%" PRIx64 "\n", |
| 71 | // port, |
| 72 | // p.global.subnet_prefix, |
| 73 | // p.global.interface_id); |
nothing calls this directly
no test coverage detected