diff options
Diffstat (limited to 'examples/ud_pingpong.c')
-rw-r--r-- | examples/ud_pingpong.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/examples/ud_pingpong.c b/examples/ud_pingpong.c index 21c551d..9102241 100644 --- a/examples/ud_pingpong.c +++ b/examples/ud_pingpong.c @@ -66,6 +66,7 @@ struct pingpong_context { struct ibv_ah *ah; void *buf; int size; + int send_flags; int rx_depth; int pending; struct ibv_port_attr portinfo; @@ -305,8 +306,9 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, if (!ctx) return NULL; - ctx->size = size; - ctx->rx_depth = rx_depth; + ctx->size = size; + ctx->send_flags = IBV_SEND_SIGNALED; + ctx->rx_depth = rx_depth; ctx->buf = memalign(page_size, size + 40); if (!ctx->buf) { @@ -368,7 +370,8 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, } { - struct ibv_qp_init_attr attr = { + struct ibv_qp_attr attr; + struct ibv_qp_init_attr init_attr = { .send_cq = ctx->cq, .recv_cq = ctx->cq, .cap = { @@ -380,11 +383,16 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size, .qp_type = IBV_QPT_UD, }; - ctx->qp = ibv_create_qp(ctx->pd, &attr); + ctx->qp = ibv_create_qp(ctx->pd, &init_attr); if (!ctx->qp) { fprintf(stderr, "Couldn't create QP\n"); goto clean_cq; } + + ibv_query_qp(ctx->qp, &attr, IBV_QP_CAP, &init_attr); + if (init_attr.cap.max_inline_data >= size) { + ctx->send_flags |= IBV_SEND_INLINE; + } } { @@ -514,7 +522,7 @@ static int pp_post_send(struct pingpong_context *ctx, uint32_t qpn) .sg_list = &list, .num_sge = 1, .opcode = IBV_WR_SEND, - .send_flags = IBV_SEND_SIGNALED, + .send_flags = ctx->send_flags, .wr = { .ud = { .ah = ctx->ah, |