Commit db9638c7 authored by Titouan Soulard's avatar Titouan Soulard

Allow client to query RDMA informations

Merge together the UDP exchange example with the server side of the
RDMA example.
parent 6e7743f4
......@@ -15,8 +15,11 @@ int main(void) {
struct ibv_cq *ibv_dev_cq;
struct ibv_qp *ibv_dev_qp;
struct ibv_mr *ibv_dev_mr;
struct ibv_port_attr ibv_dev_attr;
struct udp_rdma_parameters local_params;
void *memory_buffer;
int result;
int allocated_size = 16384 * sizeof(char);
int page_size = sysconf(_SC_PAGESIZE);
......@@ -67,7 +70,34 @@ int main(void) {
return -1;
}
// Global cleanup
/******************************
**** Exchange informations ***
******************************/
result = ibv_query_port(ibv_dev_ctx, 1, &ibv_dev_attr);
if(result) {
perror("Query port failed");
return -1;
}
// Setup a server for sending RDMA parameters
local_params.lid = ibv_dev_attr.lid;
local_params.qpn = ibv_dev_qp->qp_num;
local_params.psn = lrand48() & 0xffffff;
local_params.addr = ibv_dev_mr->addr;
local_params.size = ibv_dev_mr->length;
local_params.key = ibv_dev_mr->rkey;
printf("LID: %d | QPN: %d | PSN: %d\n", local_params.lid, local_params.qpn, local_params.psn);
if(!serve_rdma_udp_parameters(&local_params)) {
return -1;
}
printf("Parameters sent to peer\n");
/******************************
******* Global cleanup *******
******************************/
ibv_destroy_qp(ibv_dev_qp);
ibv_destroy_cq(ibv_dev_cq);
ibv_dereg_mr(ibv_dev_mr);
......
......@@ -22,6 +22,7 @@ struct udp_query_parameters {
struct udp_rdma_parameters {
uint16_t lid;
uint32_t qpn;
uint32_t psn;
void *addr;
size_t size;
uint32_t key;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment