<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7226.0">
<TITLE>srq_pingpong with many QPs and events may never ends</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Courier New">here is a patch to solve this problem:</FONT>
</P>
<BR>
<BR>
<P><FONT SIZE=2 FACE="Courier New">Empty the CQ on each event (there can be more than 1 QP connected to a CQ in</FONT>
<BR><FONT SIZE=2 FACE="Courier New">this test) before arm. Make sure there is a receive work request per each QP.</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">Signed-off-by: Dotan Barak <dotanb@mellanox.co.il></FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">Index: last_stable/src/userspace/libibverbs/examples/srq_pingpong.c</FONT>
<BR><FONT SIZE=2 FACE="Courier New">===================================================================</FONT>
<BR><FONT SIZE=2 FACE="Courier New">--- last_stable.orig/src/userspace/libibverbs/examples/srq_pingpong.c</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+++ last_stable/src/userspace/libibverbs/examples/srq_pingpong.c</FONT>
<BR><FONT SIZE=2 FACE="Courier New">@@ -514,9 +514,11 @@ int main(int argc, char *argv[])</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> struct pingpong_context *ctx;</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> struct pingpong_dest my_dest[MAX_QP];</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> struct pingpong_dest *rem_dest;</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ struct ibv_wc *wc_arr;</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> struct timeval start, end;</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> char *ib_devname = NULL;</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> char *servername = NULL;</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ int num_of_wc;</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> int port = 18515;</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> int ib_port = 1;</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> int size = 4096;</FONT>
<BR><FONT SIZE=2 FACE="Courier New">@@ -603,6 +605,13 @@ int main(int argc, char *argv[])</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> return 1;</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> }</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ num_of_wc = num_qp + rx_depth;</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ wc_arr = malloc(num_of_wc * sizeof *wc_arr);</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ if (!wc_arr) {</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ fprintf(stderr, "Failed to allocate memory\n");</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ return 1;</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ }</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> page_size = sysconf(_SC_PAGESIZE);</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New"> dev_list = ibv_get_device_list(NULL);</FONT>
<BR><FONT SIZE=2 FACE="Courier New">@@ -714,11 +723,10 @@ int main(int argc, char *argv[])</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> }</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New"> {</FONT>
<BR><FONT SIZE=2 FACE="Courier New">- struct ibv_wc wc[2];</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> int ne, qp_ind;</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New"> do {</FONT>
<BR><FONT SIZE=2 FACE="Courier New">- ne = ibv_poll_cq(ctx->cq, 2, wc);</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ ne = ibv_poll_cq(ctx->cq, num_of_wc, wc_arr);</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> } while (!use_event && ne < 1);</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New"> if (ne < 0) {</FONT>
<BR><FONT SIZE=2 FACE="Courier New">@@ -727,26 +735,26 @@ int main(int argc, char *argv[])</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> }</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New"> for (i = 0; i < ne; ++i) {</FONT>
<BR><FONT SIZE=2 FACE="Courier New">- if (wc[i].status != IBV_WC_SUCCESS) {</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ if (wc_arr[i].status != IBV_WC_SUCCESS) {</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> fprintf(stderr, "Failed status %d for wr_id %d\n",</FONT>
<BR><FONT SIZE=2 FACE="Courier New">- wc[i].status, (int) wc[i].wr_id);</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ wc_arr[i].status, (int) wc_arr[i].wr_id);</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> return 1;</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> }</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">- qp_ind = find_qp(wc[i].qp_num, ctx, num_qp);</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ qp_ind = find_qp(wc_arr[i].qp_num, ctx, num_qp);</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> if (qp_ind < 0) {</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> fprintf(stderr, "Couldn't find QPN %06x\n",</FONT>
<BR><FONT SIZE=2 FACE="Courier New">- wc[i].qp_num);</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ wc_arr[i].qp_num);</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> return 1;</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> }</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">- switch ((int) wc[i].wr_id) {</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ switch ((int) wc_arr[i].wr_id) {</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> case PINGPONG_SEND_WRID:</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> ++scnt;</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> break;</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New"> case PINGPONG_RECV_WRID:</FONT>
<BR><FONT SIZE=2 FACE="Courier New">- if (--routs <= 1) {</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ if (--routs <= num_qp) {</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> routs += pp_post_recv(ctx, ctx->rx_depth - routs);</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> if (routs < ctx->rx_depth) {</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> fprintf(stderr,</FONT>
<BR><FONT SIZE=2 FACE="Courier New">@@ -761,11 +769,11 @@ int main(int argc, char *argv[])</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New"> default:</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> fprintf(stderr, "Completion for unknown wr_id %d\n",</FONT>
<BR><FONT SIZE=2 FACE="Courier New">- (int) wc[i].wr_id);</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ (int) wc_arr[i].wr_id);</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> return 1;</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> }</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">- ctx->pending[qp_ind] &= ~(int) wc[i].wr_id;</FONT>
<BR><FONT SIZE=2 FACE="Courier New">+ ctx->pending[qp_ind] &= ~(int) wc_arr[i].wr_id;</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> if (scnt < iters && !ctx->pending[qp_ind]) {</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> if (pp_post_send(ctx, qp_ind)) {</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> fprintf(stderr, "Couldn't post send\n");</FONT>
</P>
<BR>
<BR>
<BR>
<P><B><I><FONT COLOR="#008080" SIZE=6 FACE="Script">Dotan Barak</FONT></I></B>
<BR><FONT FACE="Times New Roman">Software Verification Engineer</FONT>
<BR><FONT FACE="Times New Roman">Mellanox Technologies LTD</FONT>
<BR><FONT FACE="Times New Roman">Tel: +972-4-9097200 Ext: 231 Fax: +972-4-9593245</FONT>
<BR><FONT FACE="Times New Roman">P.O. Box 86 Yokneam 20692 ISRAEL.</FONT>
<BR><FONT FACE="Times New Roman">Home: +972-77-8841095 Cell: 0</FONT><FONT SIZE=2 FACE="Arial">52-4222383</FONT>
</P>
<P><FONT COLOR="#008080" SIZE=2 FACE="Arial">[ May the fork be with you ]</FONT>
</P>
</BODY>
</HTML>