<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=US-ASCII">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2654.45">
<TITLE>[PATCH] query-cq</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Hello Fab,</FONT>
</P>
<P><FONT SIZE=2>Attached is a patch for query cq, the patch also includes few checks to the alts test. </FONT>
<BR><FONT SIZE=2>Our verification team found that the return size in query_cq is different from the size that was return in create_cq VERB.</FONT></P>
<P><FONT SIZE=2>The reason is that when creating cq the THH layer allocate some spare cqes (for DB coalsing) and return the size that was requested by the user </FONT></P>
<P><FONT SIZE=2>But the query_cq IOCTL use the kernel tables for the size which use the actual size (usually a bigger size).</FONT>
<BR><FONT SIZE=2>The patch simply finish the query in UL without calling the IOCTL so the UL always get the same size .</FONT>
<BR><FONT SIZE=2>(its very similar to the query_av )</FONT>
</P>
<P><FONT SIZE=2>Thanks, </FONT>
<BR><FONT SIZE=2>Yossi</FONT>
</P>
<BR>
<P><FONT SIZE=2>Signed-off-by: Yossi Leybovich <sleybo@mellanox.co.il></FONT>
</P>
<P><FONT SIZE=2>Index: core/al/user/ual_cq.c ===================================================================</FONT>
<BR><FONT SIZE=2>--- core/al/user/ual_cq.c (revision 346)</FONT>
<BR><FONT SIZE=2>+++ core/al/user/ual_cq.c (working copy)</FONT>
<BR><FONT SIZE=2>@@ -306,13 +306,24 @@</FONT>
<BR><FONT SIZE=2> {</FONT>
<BR><FONT SIZE=2> /* Pre call to the UVP library */</FONT>
<BR><FONT SIZE=2> status = uvp_intf.pre_query_cq( h_cq->h_ci_cq, &cq_ioctl.in.umv_buf );</FONT>
<BR><FONT SIZE=2>- if( status != IB_SUCCESS )</FONT>
<BR><FONT SIZE=2>+ if( status == IB_VERBS_PROCESSING_DONE )</FONT>
<BR><FONT SIZE=2> {</FONT>
<BR><FONT SIZE=2>+ /* Creation is done entirely in user mode. Issue the post call */</FONT>
<BR><FONT SIZE=2>+ if( uvp_intf.post_query_cq)</FONT>
<BR><FONT SIZE=2>+ {</FONT>
<BR><FONT SIZE=2>+ uvp_intf.post_query_cq( h_cq->h_ci_cq,</FONT>
<BR><FONT SIZE=2>+ IB_SUCCESS, p_size, &cq_ioctl.out.umv_buf );</FONT>
<BR><FONT SIZE=2>+ }</FONT>
<BR><FONT SIZE=2> AL_EXIT( AL_DBG_CQ );</FONT>
<BR><FONT SIZE=2>+ return IB_SUCCESS;</FONT>
<BR><FONT SIZE=2>+ }</FONT>
<BR><FONT SIZE=2>+ else if( status != IB_SUCCESS )</FONT>
<BR><FONT SIZE=2>+ {</FONT>
<BR><FONT SIZE=2>+ AL_EXIT( AL_DBG_CQ );</FONT>
<BR><FONT SIZE=2> return status;</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2>-</FONT>
<BR><FONT SIZE=2>+ </FONT>
<BR><FONT SIZE=2> cq_ioctl.in.h_cq = h_cq->obj.hdl;</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> cl_status = do_al_dev_ioctl( UAL_QUERY_CQ,</FONT>
<BR><FONT SIZE=2>@@ -329,17 +340,18 @@</FONT>
<BR><FONT SIZE=2> else</FONT>
<BR><FONT SIZE=2> {</FONT>
<BR><FONT SIZE=2> status = cq_ioctl.out.status;</FONT>
<BR><FONT SIZE=2>- if( status == IB_SUCCESS )</FONT>
<BR><FONT SIZE=2>- *p_size = cq_ioctl.out.size;</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> /* Post uvp call */</FONT>
<BR><FONT SIZE=2> if( h_cq->h_ci_cq && uvp_intf.post_query_cq )</FONT>
<BR><FONT SIZE=2> {</FONT>
<BR><FONT SIZE=2> uvp_intf.post_query_cq( h_cq->h_ci_cq,</FONT>
<BR><FONT SIZE=2>- status, cq_ioctl.out.size, &cq_ioctl.out.umv_buf );</FONT>
<BR><FONT SIZE=2>+ status, &cq_ioctl.out.size, &cq_ioctl.out.umv_buf );</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2>+ if( status == IB_SUCCESS )</FONT>
<BR><FONT SIZE=2>+ *p_size = cq_ioctl.out.size;</FONT>
<BR><FONT SIZE=2>+ </FONT>
<BR><FONT SIZE=2> AL_EXIT( AL_DBG_CQ );</FONT>
<BR><FONT SIZE=2> return status;</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2>Index: hw/mt23108/user/mlnx_ual_cq.c ===================================================================</FONT>
<BR><FONT SIZE=2>--- hw/mt23108/user/mlnx_ual_cq.c (revision 346)</FONT>
<BR><FONT SIZE=2>+++ hw/mt23108/user/mlnx_ual_cq.c (working copy)</FONT>
<BR><FONT SIZE=2>@@ -48,8 +48,8 @@</FONT>
<BR><FONT SIZE=2> p_uvp->pre_create_cq = mlnx_pre_create_cq;</FONT>
<BR><FONT SIZE=2> p_uvp->post_create_cq = mlnx_post_create_cq;</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2>- p_uvp->pre_query_cq = NULL;</FONT>
<BR><FONT SIZE=2>- p_uvp->post_query_cq = NULL;</FONT>
<BR><FONT SIZE=2>+ p_uvp->pre_query_cq = mlnx_pre_query_cq;</FONT>
<BR><FONT SIZE=2>+ p_uvp->post_query_cq = mlnx_post_query_cq;</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> p_uvp->pre_resize_cq = mlnx_pre_resize_cq;</FONT>
<BR><FONT SIZE=2> p_uvp->post_resize_cq = mlnx_post_resize_cq;</FONT>
<BR><FONT SIZE=2>@@ -441,22 +441,37 @@</FONT>
<BR><FONT SIZE=2> CL_ASSERT(p_umv_buf);</FONT>
<BR><FONT SIZE=2> p_umv_buf->command = TRUE;</FONT>
<BR><FONT SIZE=2> FUNC_EXIT;</FONT>
<BR><FONT SIZE=2>- return IB_SUCCESS;</FONT>
<BR><FONT SIZE=2>+ return IB_VERBS_PROCESSING_DONE;</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> void</FONT>
<BR><FONT SIZE=2> mlnx_post_query_cq (</FONT>
<BR><FONT SIZE=2>- IN const ib_cq_handle_t h_uvp_cq,</FONT>
<BR><FONT SIZE=2>- IN ib_api_status_t ioctl_status,</FONT>
<BR><FONT SIZE=2>- IN OUT ci_umv_buf_t *p_umv_buf)</FONT>
<BR><FONT SIZE=2>+ IN const ib_cq_handle_t h_uvp_cq,</FONT>
<BR><FONT SIZE=2>+ IN ib_api_status_t ioctl_status,</FONT>
<BR><FONT SIZE=2>+ IN OUT uint32_t* const p_size,</FONT>
<BR><FONT SIZE=2>+ IN ci_umv_buf_t *p_umv_buf)</FONT>
<BR><FONT SIZE=2> {</FONT>
<BR><FONT SIZE=2>+ ib_api_status_t status;</FONT>
<BR><FONT SIZE=2>+ mlnx_ual_cq_info_t *p_cq_info = (mlnx_ual_cq_info_t *)((void*) </FONT>
<BR><FONT SIZE=2>+ h_uvp_cq);</FONT>
<BR><FONT SIZE=2>+</FONT>
<BR><FONT SIZE=2> FUNC_ENTER;</FONT>
<BR><FONT SIZE=2>+ CL_ASSERT(p_umv_buf);</FONT>
<BR><FONT SIZE=2>+ CL_ASSERT(p_cq_info);</FONT>
<BR><FONT SIZE=2>+</FONT>
<BR><FONT SIZE=2>+ status = ioctl_status;</FONT>
<BR><FONT SIZE=2>+ if (status == IB_SUCCESS)</FONT>
<BR><FONT SIZE=2>+ {</FONT>
<BR><FONT SIZE=2>+ *p_size = p_cq_info->cq_size;</FONT>
<BR><FONT SIZE=2>+</FONT>
<BR><FONT SIZE=2>+ status = IB_VERBS_PROCESSING_DONE;</FONT>
<BR><FONT SIZE=2>+ }</FONT>
<BR><FONT SIZE=2>+ </FONT>
<BR><FONT SIZE=2> FUNC_EXIT;</FONT>
<BR><FONT SIZE=2>- return;</FONT>
<BR><FONT SIZE=2>+ return; </FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2>+ </FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2>-</FONT>
<BR><FONT SIZE=2> ib_api_status_t</FONT>
<BR><FONT SIZE=2> mlnx_pre_destroy_cq (</FONT>
<BR><FONT SIZE=2> IN const ib_cq_handle_t h_uvp_cq)</FONT>
<BR><FONT SIZE=2>Index: hw/mt23108/user/mlnx_ual_main.c ===================================================================</FONT>
<BR><FONT SIZE=2>--- hw/mt23108/user/mlnx_ual_main.c (revision 346)</FONT>
<BR><FONT SIZE=2>+++ hw/mt23108/user/mlnx_ual_main.c (working copy)</FONT>
<BR><FONT SIZE=2>@@ -32,7 +32,7 @@</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> #include "mlnx_ual_main.h"</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2>-u_int32_t mlnx_dbg_lvl = 0; // MLNX_TRACE_LVL_8;</FONT>
<BR><FONT SIZE=2>+u_int32_t mlnx_dbg_lvl = MLNX_TRACE_LVL_8;</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> static void uvp_init();</FONT>
<BR><FONT SIZE=2>Index: hw/mt23108/user/mlnx_ual_main.h ===================================================================</FONT>
<BR><FONT SIZE=2>--- hw/mt23108/user/mlnx_ual_main.h (revision 346)</FONT>
<BR><FONT SIZE=2>+++ hw/mt23108/user/mlnx_ual_main.h (working copy)</FONT>
<BR><FONT SIZE=2>@@ -257,6 +257,7 @@</FONT>
<BR><FONT SIZE=2> mlnx_post_query_cq (</FONT>
<BR><FONT SIZE=2> IN const ib_cq_handle_t h_uvp_cq,</FONT>
<BR><FONT SIZE=2> IN ib_api_status_t ioctl_status,</FONT>
<BR><FONT SIZE=2>+ IN OUT uint32_t* const p_size,</FONT>
<BR><FONT SIZE=2> IN OUT ci_umv_buf_t *p_umv_buf);</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> ib_api_status_t </FONT>
<BR><FONT SIZE=2>Index: inc/user/iba/ib_uvp.h ===================================================================</FONT>
<BR><FONT SIZE=2>--- inc/user/iba/ib_uvp.h (revision 346)</FONT>
<BR><FONT SIZE=2>+++ inc/user/iba/ib_uvp.h (working copy)</FONT>
<BR><FONT SIZE=2>@@ -1789,7 +1789,7 @@</FONT>
<BR><FONT SIZE=2> (AL_API *uvp_post_query_cq_t) (</FONT>
<BR><FONT SIZE=2> IN const ib_cq_handle_t h_uvp_cq,</FONT>
<BR><FONT SIZE=2> IN ib_api_status_t ioctl_status,</FONT>
<BR><FONT SIZE=2>- IN const uint32_t size,</FONT>
<BR><FONT SIZE=2>+ IN OUT uint32_t *size,</FONT>
<BR><FONT SIZE=2> IN ci_umv_buf_t *p_umv_buf );</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> /*</FONT>
<BR><FONT SIZE=2>@@ -1803,7 +1803,7 @@</FONT>
<BR><FONT SIZE=2> * ioctl_status</FONT>
<BR><FONT SIZE=2> * [in] The ioctl status of the AL API.</FONT>
<BR><FONT SIZE=2> * size</FONT>
<BR><FONT SIZE=2>-* [in] The size of the CQ retuned by the IOCTL.</FONT>
<BR><FONT SIZE=2>+* [in out] On input size of the CQ retuned by the IOCTL.</FONT>
<BR><FONT SIZE=2> * p_umv_buf</FONT>
<BR><FONT SIZE=2> * [in out] On input, it contains any vendor-specific private information</FONT>
<BR><FONT SIZE=2> * exchanged with the vendor's Verbs Provider Driver (uvp_pre_query_cq).</FONT>
<BR><FONT SIZE=2>Index: tests/alts/createanddestroycq.c ===================================================================</FONT>
<BR><FONT SIZE=2>--- tests/alts/createanddestroycq.c (revision 346)</FONT>
<BR><FONT SIZE=2>+++ tests/alts/createanddestroycq.c (working copy)</FONT>
<BR><FONT SIZE=2>@@ -210,8 +210,8 @@</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2> CL_ASSERT(h_cq);</FONT>
<BR><FONT SIZE=2> ALTS_PRINT( ALTS_DBG_INFO,\</FONT>
<BR><FONT SIZE=2>- ("ib_create_cq successful status = %s\n",</FONT>
<BR><FONT SIZE=2>- ib_get_err_str(ib_status)) );</FONT>
<BR><FONT SIZE=2>+ ("ib_create_cq successful size = 0x%x status = %s\n",</FONT>
<BR><FONT SIZE=2>+ cq_create.size, ib_get_err_str(ib_status)) );</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> while( modify_cq_attr == TRUE )</FONT>
<BR><FONT SIZE=2> {</FONT>
<BR><FONT SIZE=2>@@ -229,10 +229,20 @@</FONT>
<BR><FONT SIZE=2> ib_get_err_str(ib_status)) );</FONT>
<BR><FONT SIZE=2> break;</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2>+</FONT>
<BR><FONT SIZE=2>+ if(cq_size != cq_create.size)</FONT>
<BR><FONT SIZE=2>+ {</FONT>
<BR><FONT SIZE=2>+ ALTS_PRINT( ALTS_DBG_ERROR,</FONT>
<BR><FONT SIZE=2>+ ("ib_query_cq failed cq_size=0x%x cq_create.cq_size=0x%x\n",</FONT>
<BR><FONT SIZE=2>+ cq_size,cq_create.size));</FONT>
<BR><FONT SIZE=2>+ ib_status = IB_INVALID_CQ_SIZE;</FONT>
<BR><FONT SIZE=2>+ break;</FONT>
<BR><FONT SIZE=2>+ }</FONT>
<BR><FONT SIZE=2>+ </FONT>
<BR><FONT SIZE=2> ALTS_PRINT( ALTS_DBG_INFO,</FONT>
<BR><FONT SIZE=2>- ("ib_query_cq cq_size = %d\n", cq_size) );</FONT>
<BR><FONT SIZE=2>+ ("ib_query_cq cq_size = 0x%x\n", cq_size) );</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2>- cq_size = 0x50;</FONT>
<BR><FONT SIZE=2>+ cq_size = 0x90;</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> ib_status = ib_modify_cq(h_cq,&cq_size);</FONT>
<BR><FONT SIZE=2> if(ib_status != IB_SUCCESS)</FONT>
<BR><FONT SIZE=2>@@ -243,8 +253,8 @@</FONT>
<BR><FONT SIZE=2> break;</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2>- ALTS_PRINT( ALTS_DBG_INFO,</FONT>
<BR><FONT SIZE=2>- ("ib_modify_cq passed for cq_size = %d\n", cq_size) );</FONT>
<BR><FONT SIZE=2>+ ALTS_PRINT( ALTS_DBG_INFO,</FONT>
<BR><FONT SIZE=2>+ ("ib_modify_cq passed for cq_size = 0x%x\n", cq_size) );</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2> break; //Break for the while</FONT>
<BR><FONT SIZE=2> }</FONT>
</P>
<P><FONT FACE="Arial" SIZE=2 COLOR="#000000"></FONT>
</BODY>
</HTML>