[openib-general] is wc valid if ib_poll_cq() returns zero

Rimmer, Todd trimmer at silverstorm.com
Fri Jul 14 10:50:42 PDT 2006


> From: somenath [mailto:somenath at veritas.com]
> Rimmer, Todd wrote:
> 
> >Be aware that an IB completion handler should be coded as:
> >
> >while poll_cq returns a completion
> >	process completion
> >rearm CQ
> >
> >
> 
> that's what I am doing, to be more specific:
> 
> rearm CQ;
> while (ib_poll_cq(cq, 1, &wc) > 0) {
>      process completion();
> }
> 
> is that what you meant?
> 
> >while poll_cq returns a completion
> >	process completion
> >
> in my case, poll_cq() always returns 0, so I never get a valid wc
entry...
> 

I'm not sure why you are never getting a valid wc entry, however by
coding it as you have, on mellanox hardware, you will always get an
extra completion event.

You should code it as:

while (ib_poll_cq(cq, 1, &wc) > 0) {
     process completion();
}
rearm CQ
while (ib_poll_cq(cq, 1, &wc) > 0) {
     process completion();
}

If you do the rearm CQ first, mellanox HCAs will find there are CQEs
still on the CQ, and generate another completion event.

Hence you should always poll 1st, then rearm, then poll again to make
sure there were no CQEs arriving racing with the rearm.

Todd Rimmer




More information about the general mailing list