Lines Matching +full:rx +full:- +full:ts +full:- +full:max

14  *      - Redistributions of source code must retain the above
18 * - Redistributions in binary form must reproduce the above
83 return use_ts ? ibv_cq_ex_to_cq(ctx->cq_s.cq_ex) : in pp_cq()
84 ctx->cq_s.cq; in pp_cq()
101 .dest_qp_num = dest->qpn, in pp_connect_ctx()
102 .rq_psn = dest->psn, in pp_connect_ctx()
107 .dlid = dest->lid, in pp_connect_ctx()
114 if (dest->gid.global.interface_id) { in pp_connect_ctx()
117 attr.ah_attr.grh.dgid = dest->gid; in pp_connect_ctx()
120 if (ibv_modify_qp(ctx->qp, &attr, in pp_connect_ctx()
138 if (ibv_modify_qp(ctx->qp, &attr, in pp_connect_ctx()
163 int sockfd = -1; in pp_client_exch_dest()
178 for (t = res; t; t = t->ai_next) { in pp_client_exch_dest()
179 sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); in pp_client_exch_dest()
181 if (!connect(sockfd, t->ai_addr, t->ai_addrlen)) in pp_client_exch_dest()
184 sockfd = -1; in pp_client_exch_dest()
196 gid_to_wire_gid(&my_dest->gid, gid); in pp_client_exch_dest()
197 sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, in pp_client_exch_dest()
198 my_dest->psn, gid); in pp_client_exch_dest()
215 sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, in pp_client_exch_dest()
216 &rem_dest->psn, gid); in pp_client_exch_dest()
217 wire_gid_to_gid(gid, &rem_dest->gid); in pp_client_exch_dest()
239 int sockfd = -1, connfd; in pp_server_exch_dest()
254 for (t = res; t; t = t->ai_next) { in pp_server_exch_dest()
255 sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); in pp_server_exch_dest()
261 if (!bind(sockfd, t->ai_addr, t->ai_addrlen)) in pp_server_exch_dest()
264 sockfd = -1; in pp_server_exch_dest()
299 sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, in pp_server_exch_dest()
300 &rem_dest->psn, gid); in pp_server_exch_dest()
301 wire_gid_to_gid(gid, &rem_dest->gid); in pp_server_exch_dest()
303 if (pp_connect_ctx(ctx, ib_port, my_dest->psn, mtu, sl, rem_dest, in pp_server_exch_dest()
312 gid_to_wire_gid(&my_dest->gid, gid); in pp_server_exch_dest()
313 sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, in pp_server_exch_dest()
314 my_dest->psn, gid); in pp_server_exch_dest()
340 ctx->size = size; in pp_init_ctx()
341 ctx->send_flags = IBV_SEND_SIGNALED; in pp_init_ctx()
342 ctx->rx_depth = rx_depth; in pp_init_ctx()
344 ctx->buf = memalign(page_size, size); in pp_init_ctx()
345 if (!ctx->buf) { in pp_init_ctx()
350 /* FIXME memset(ctx->buf, 0, size); */ in pp_init_ctx()
351 memset(ctx->buf, 0x7b, size); in pp_init_ctx()
353 ctx->context = ibv_open_device(ib_dev); in pp_init_ctx()
354 if (!ctx->context) { in pp_init_ctx()
361 ctx->channel = ibv_create_comp_channel(ctx->context); in pp_init_ctx()
362 if (!ctx->channel) { in pp_init_ctx()
367 ctx->channel = NULL; in pp_init_ctx()
369 ctx->pd = ibv_alloc_pd(ctx->context); in pp_init_ctx()
370 if (!ctx->pd) { in pp_init_ctx()
380 if (ibv_query_device_ex(ctx->context, NULL, &attrx)) { in pp_init_ctx()
399 ctx->completion_timestamp_mask = attrx.completion_timestamp_mask; in pp_init_ctx()
402 ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, size, access_flags); in pp_init_ctx()
404 if (!ctx->mr) { in pp_init_ctx()
413 .channel = ctx->channel, in pp_init_ctx()
418 ctx->cq_s.cq_ex = ibv_create_cq_ex(ctx->context, &attr_ex); in pp_init_ctx()
420 ctx->cq_s.cq = ibv_create_cq(ctx->context, rx_depth + 1, NULL, in pp_init_ctx()
421 ctx->channel, 0); in pp_init_ctx()
443 ctx->qp = ibv_create_qp(ctx->pd, &init_attr); in pp_init_ctx()
444 if (!ctx->qp) { in pp_init_ctx()
449 ibv_query_qp(ctx->qp, &attr, IBV_QP_CAP, &init_attr); in pp_init_ctx()
451 ctx->send_flags |= IBV_SEND_INLINE; in pp_init_ctx()
463 if (ibv_modify_qp(ctx->qp, &attr, in pp_init_ctx()
476 ibv_destroy_qp(ctx->qp); in pp_init_ctx()
482 ibv_dereg_mr(ctx->mr); in pp_init_ctx()
485 ibv_dealloc_pd(ctx->pd); in pp_init_ctx()
488 if (ctx->channel) in pp_init_ctx()
489 ibv_destroy_comp_channel(ctx->channel); in pp_init_ctx()
492 ibv_close_device(ctx->context); in pp_init_ctx()
495 free(ctx->buf); in pp_init_ctx()
505 if (ibv_destroy_qp(ctx->qp)) { in pp_close_ctx()
515 if (ibv_dereg_mr(ctx->mr)) { in pp_close_ctx()
520 if (ibv_dealloc_pd(ctx->pd)) { in pp_close_ctx()
525 if (ctx->channel) { in pp_close_ctx()
526 if (ibv_destroy_comp_channel(ctx->channel)) { in pp_close_ctx()
532 if (ibv_close_device(ctx->context)) { in pp_close_ctx()
537 free(ctx->buf); in pp_close_ctx()
546 .addr = (uintptr_t) ctx->buf, in pp_post_recv()
547 .length = ctx->size, in pp_post_recv()
548 .lkey = ctx->mr->lkey in pp_post_recv()
559 if (ibv_post_recv(ctx->qp, &wr, &bad_wr)) in pp_post_recv()
568 .addr = (uintptr_t) ctx->buf, in pp_post_send()
569 .length = ctx->size, in pp_post_send()
570 .lkey = ctx->mr->lkey in pp_post_send()
577 .send_flags = ctx->send_flags, in pp_post_send()
581 return ibv_post_send(ctx->qp, &wr, &bad_wr); in pp_post_send()
597 struct ts_params *ts) in parse_single_wc() argument
612 if (--(*routs) <= 1) { in parse_single_wc()
613 *routs += pp_post_recv(ctx, ctx->rx_depth - *routs); in parse_single_wc()
614 if (*routs < ctx->rx_depth) { in parse_single_wc()
624 if (ts->last_comp_with_ts) { in parse_single_wc()
628 if (completion_timestamp >= ts->comp_recv_prev_time) in parse_single_wc()
629 delta = completion_timestamp - ts->comp_recv_prev_time; in parse_single_wc()
631 delta = ctx->completion_timestamp_mask - ts->comp_recv_prev_time + in parse_single_wc()
634 ts->comp_recv_max_time_delta = MAX(ts->comp_recv_max_time_delta, delta); in parse_single_wc()
635 ts->comp_recv_min_time_delta = MIN(ts->comp_recv_min_time_delta, delta); in parse_single_wc()
636 ts->comp_recv_total_time_delta += delta; in parse_single_wc()
637 ts->comp_with_time_iters++; in parse_single_wc()
640 ts->comp_recv_prev_time = completion_timestamp; in parse_single_wc()
641 ts->last_comp_with_ts = 1; in parse_single_wc()
643 ts->last_comp_with_ts = 0; in parse_single_wc()
654 ctx->pending &= ~(int)wr_id; in parse_single_wc()
655 if (*scnt < iters && !ctx->pending) { in parse_single_wc()
660 ctx->pending = PINGPONG_RECV_WRID | in parse_single_wc()
674 printf(" -p, --port=<port> listen on/connect to port <port> (default 18515)\n"); in usage()
675 printf(" -d, --ib-dev=<dev> use IB device <dev> (default first device found)\n"); in usage()
676 printf(" -i, --ib-port=<port> use port <port> of IB device (default 1)\n"); in usage()
677 printf(" -s, --size=<size> size of message to exchange (default 4096)\n"); in usage()
678 printf(" -m, --mtu=<size> path MTU (default 1024)\n"); in usage()
679 printf(" -r, --rx-depth=<dep> number of receives to post at a time (default 500)\n"); in usage()
680 printf(" -n, --iters=<iters> number of exchanges (default 1000)\n"); in usage()
681 printf(" -l, --sl=<sl> service level value\n"); in usage()
682 printf(" -e, --events sleep on CQ events (default poll)\n"); in usage()
683 printf(" -g, --gid-idx=<gid index> local port gid index\n"); in usage()
684 printf(" -o, --odp use on demand paging\n"); in usage()
685 printf(" -t, --ts get CQE with timestamp\n"); in usage()
709 int gidx = -1; in main()
711 struct ts_params ts; in main() local
720 { .name = "ib-dev", .has_arg = 1, .val = 'd' }, in main()
721 { .name = "ib-port", .has_arg = 1, .val = 'i' }, in main()
724 { .name = "rx-depth", .has_arg = 1, .val = 'r' }, in main()
728 { .name = "gid-idx", .has_arg = 1, .val = 'g' }, in main()
730 { .name = "ts", .has_arg = 0, .val = 't' }, in main()
737 if (c == -1) in main()
806 if (optind == argc - 1) in main()
814 ts.comp_recv_max_time_delta = 0; in main()
815 ts.comp_recv_min_time_delta = 0xffffffff; in main()
816 ts.comp_recv_total_time_delta = 0; in main()
817 ts.comp_recv_prev_time = 0; in main()
818 ts.last_comp_with_ts = 0; in main()
819 ts.comp_with_time_iters = 0; in main()
852 routs = pp_post_recv(ctx, ctx->rx_depth); in main()
853 if (routs < ctx->rx_depth) { in main()
865 if (pp_get_port_info(ctx->context, ib_port, &ctx->portinfo)) { in main()
870 my_dest.lid = ctx->portinfo.lid; in main()
871 if (ctx->portinfo.link_layer != IBV_LINK_LAYER_ETHERNET && in main()
878 if (ibv_query_gid(ctx->context, ib_port, gidx, &my_dest.gid)) { in main()
885 my_dest.qpn = ctx->qp->qp_num; in main()
901 inet_ntop(AF_INET6, &rem_dest->gid, gid, sizeof gid); in main()
903 rem_dest->lid, rem_dest->qpn, rem_dest->psn, gid); in main()
910 ctx->pending = PINGPONG_RECV_WRID; in main()
917 ctx->pending |= PINGPONG_SEND_WRID; in main()
933 if (ibv_get_cq_event(ctx->channel, &ev_cq, &ev_ctx)) { in main()
955 ret = ibv_start_poll(ctx->cq_s.cq_ex, &attr); in main()
964 ctx->cq_s.cq_ex->wr_id, in main()
965 ctx->cq_s.cq_ex->status, in main()
966 ibv_wc_read_completion_ts(ctx->cq_s.cq_ex), in main()
967 &ts); in main()
969 ibv_end_poll(ctx->cq_s.cq_ex); in main()
972 ret = ibv_next_poll(ctx->cq_s.cq_ex); in main()
976 ctx->cq_s.cq_ex->wr_id, in main()
977 ctx->cq_s.cq_ex->status, in main()
978 ibv_wc_read_completion_ts(ctx->cq_s.cq_ex), in main()
979 &ts); in main()
980 ibv_end_poll(ctx->cq_s.cq_ex); in main()
1002 0, &ts); in main()
1017 float usec = (end.tv_sec - start.tv_sec) * 1000000 + in main()
1018 (end.tv_usec - start.tv_usec); in main()
1026 if (use_ts && ts.comp_with_time_iters) { in main()
1027 printf("Max receive completion clock cycles = %" PRIu64 "\n", in main()
1028 ts.comp_recv_max_time_delta); in main()
1030 ts.comp_recv_min_time_delta); in main()
1032 (double)ts.comp_recv_total_time_delta / ts.comp_with_time_iters); in main()