| 93 | } |
| 94 | |
| 95 | void RunIBTest(bool isClient, const char* serverName) { |
| 96 | TIntrusivePtr<TIBPort> port = GetIBDevice(); |
| 97 | if (port.Get() == nullptr) { |
| 98 | printf("No IB device found\n"); |
| 99 | return; |
| 100 | } |
| 101 | |
| 102 | const int IP_PORT = 13666; |
| 103 | const int WELCOME_QKEY = 0x1113013; |
| 104 | const int MAX_SRQ_WORK_REQUESTS = 100; |
| 105 | const int MAX_CQ_EVENTS = 1000; |
| 106 | const int QP_SEND_QUEUE_SIZE = 3; |
| 107 | |
| 108 | TIntrusivePtr<TComplectionQueue> cq = new TComplectionQueue(port->GetCtx(), MAX_CQ_EVENTS); |
| 109 | |
| 110 | TIBBufferPool bp(port->GetCtx(), MAX_SRQ_WORK_REQUESTS); |
| 111 | |
| 112 | if (!isClient) { |
| 113 | // server |
| 114 | TIPSocket ipSocket; |
| 115 | ipSocket.Init(IP_PORT); |
| 116 | if (!ipSocket.IsValid()) { |
| 117 | printf("UDP port %d is not available\n", IP_PORT); |
| 118 | return; |
| 119 | } |
| 120 | |
| 121 | TIntrusivePtr<TComplectionQueue> cqRC = new TComplectionQueue(port->GetCtx(), MAX_CQ_EVENTS); |
| 122 | |
| 123 | TIntrusivePtr<TUDQueuePair> welcomeQP = new TUDQueuePair(port, cq, bp.GetSRQ(), QP_SEND_QUEUE_SIZE); |
| 124 | welcomeQP->Init(WELCOME_QKEY); |
| 125 | |
| 126 | TWelcomeSocketAddr info; |
| 127 | info.LID = port->GetLID(); |
| 128 | info.QPN = welcomeQP->GetQPN(); |
| 129 | |
| 130 | for (;;) { |
| 131 | ipSocket.Respond(info); |
| 132 | // poll srq |
| 133 | ibv_wc wc; |
| 134 | if (cq->Poll(&wc, 1) == 1 && (wc.opcode & IBV_WC_RECV)) { |
| 135 | printf("Got IB handshake\n"); |
| 136 | |
| 137 | TRCQueuePairHandshake remoteHandshake; |
| 138 | ibv_ah_attr clientAddr; |
| 139 | { |
| 140 | TIBRecvPacketProcess pkt(bp, wc); |
| 141 | remoteHandshake = *(TRCQueuePairHandshake*)pkt.GetUDData(); |
| 142 | port->GetAHAttr(&wc, pkt.GetGRH(), &clientAddr); |
| 143 | } |
| 144 | |
| 145 | TIntrusivePtr<TAddressHandle> ahPeer; |
| 146 | ahPeer = new TAddressHandle(port->GetCtx(), &clientAddr); |
| 147 | |
| 148 | TIntrusivePtr<TRCQueuePair> rcTest = new TRCQueuePair(port->GetCtx(), cqRC, bp.GetSRQ(), QP_SEND_QUEUE_SIZE); |
| 149 | rcTest->Init(clientAddr, remoteHandshake.QPN, remoteHandshake.PSN); |
| 150 | |
| 151 | TRCQueuePairHandshake handshake; |
| 152 | handshake.PSN = rcTest->GetPSN(); |
nothing calls this directly
no test coverage detected