[ofw] ibv_get_cq_event:: identifying send and receive CQ event
Prasanna Vv
prasanna.vv at oracle.com
Tue Sep 29 06:50:06 PDT 2009
Hi
I wish to know is it possible to wait for both send and receive CQ
notification at a given point of time.
Let me explain my query with a code snippet below:
1. create send and receive cq for a given channel as below:
+++++++++++++++++++++++++++++++++++++++++++++++
ctx->ch = ibv_create_comp_channel(ctx->context);
if (!ctx->ch) {
fprintf(stderr, "Couldn't create comp channel\n");
return NULL;
}
/* Recv CQ */
ctx->rcq = ibv_create_cq(ctx->context, 1, ctx, ctx->ch, 0);
if (!ctx->rcq) {
fprintf(stderr, "Couldn't create recv CQ\n");
return NULL;
}
/* Send CQ */
ctx->scq = ibv_create_cq(ctx->context, 1, ctx, ctx->ch, 0);
if (!ctx->scq) {
fprintf(stderr, "Couldn't create send CQ\n");
return NULL;
}
/* Request send notification before any completion can be created */
if (ibv_req_notify_cq(ctx->scq, 0)) {
fprintf(stderr, "Couldn't request CQ notification\n");
return 1;
}
/* Request receive notification before any completion can be created */
if (ibv_req_notify_cq(ctx->rcq, 0)) {
fprintf(stderr, "Couldn't request CQ notification\n");
return 1;
}
++++++++++++++++++++++++++++++++++++++++++++++
2. wait for a CQ event after concurrent post_send and post_recv
operation and identify if the CQ event is for send or receive
++++++++++++++++++++++++++++++++++++++++++++++++
/* Wait for the completion event */
if (ibv_get_cq_event(channel, &ev_cq, &ev_ctx)) {
fprintf(stderr, "Failed to get cq_event\n");
return 1;
}
if (ev_cq == ctx->rcq)
printf(" receive cq event ...");
else if (ev_cq == ctx->scq)
printf(" send cq event ...");
else
printf(" ERROR in identifying notification ...")
/* Ack the event */
ibv_ack_cq_events(ev_cq, 1);
+++++++++++++++++++++++++++++++++++++++++++++++++++++
Please let me know if the mechanism (shown in code snippet above) for
identifying the event posted on ibv_get_cq_event(..) is send or receive
is correct.
Also, i welcome any other suggestions for the same.
Regards,
Prasanna
More information about the ofw
mailing list