diff options
author | Roland Dreier <rolandd@cisco.com> | 2006-01-07 01:06:03 +0000 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-11-09 11:35:58 -0800 |
commit | 91f6faf31920e0823aa6cb98f22ec39dbe661891 (patch) | |
tree | d05b10ceb965549951ad5225381bac0f8617c7c2 | |
parent | 813f1bfc4df520f63698ace8c79635b2e08df291 (diff) | |
download | libibverbs-91f6faf31920e0823aa6cb98f22ec39dbe661891.tar.gz |
Fix ibv_srq_pingpong bug with many QPs when using CQ events
Fix SRQ example to avoid problems with many QPs and events. Based on
a patch from Dotan Barak (who also found the problem).
Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | examples/srq_pingpong.c | 17 |
2 files changed, 20 insertions, 3 deletions
@@ -1,3 +1,9 @@ +2006-01-06 Roland Dreier <rdreier@cisco.com> + + * examples/srq_pingpong.c (main): Fix SRQ example to avoid + problems with many QPs and events. Based on a patch from Dotan + Barak (who also found the problem). + 2006-01-06 Ralph Campbell <ralphc@pathscale.com> * examples/rc_pingpong.c (main), examples/srq_pingpong.c (main), diff --git a/examples/srq_pingpong.c b/examples/srq_pingpong.c index 70c59ab..836ddc9 100644 --- a/examples/srq_pingpong.c +++ b/examples/srq_pingpong.c @@ -511,6 +511,7 @@ int main(int argc, char *argv[]) { struct ibv_device **dev_list; struct ibv_device *ib_dev; + struct ibv_wc *wc; struct pingpong_context *ctx; struct pingpong_dest my_dest[MAX_QP]; struct pingpong_dest *rem_dest; @@ -526,6 +527,7 @@ int main(int argc, char *argv[]) int use_event = 0; int routs; int rcnt, scnt; + int num_wc; int i; srand48(getpid() * time(NULL)); @@ -603,6 +605,16 @@ int main(int argc, char *argv[]) return 1; } + if (num_qp > rx_depth) { + fprintf(stderr, "rx_depth %d is too small for %d QPs -- " + "must have at least one receive per QP.\n", + rx_depth, num_qp); + return 1; + } + + num_wc = num_qp + rx_depth; + wc = alloca(num_wc * sizeof *wc); + page_size = sysconf(_SC_PAGESIZE); dev_list = ibv_get_device_list(NULL); @@ -714,11 +726,10 @@ int main(int argc, char *argv[]) } { - struct ibv_wc wc[2]; int ne, qp_ind; do { - ne = ibv_poll_cq(ctx->cq, 2, wc); + ne = ibv_poll_cq(ctx->cq, num_wc, wc); if (ne < 0) { fprintf(stderr, "poll CQ failed %d\n", ne); return 1; @@ -745,7 +756,7 @@ int main(int argc, char *argv[]) break; case PINGPONG_RECV_WRID: - if (--routs <= 1) { + if (--routs <= num_qp) { routs += pp_post_recv(ctx, ctx->rx_depth - routs); if (routs < ctx->rx_depth) { fprintf(stderr, |