[openib-general] error return values from userspace calls

Pete Wyckoff pw at osc.edu
Sat Aug 5 15:39:30 PDT 2006


mst at mellanox.co.il wrote on Sat, 05 Aug 2006 23:46 +0300:
> Quoting r. Pete Wyckoff <pw at osc.edu>:
> > Then there's ibv_poll_cq that  returns +npolled on sucess, -1 on
> > empty, -2 on error.  Why not EAGAIN instead of these custom codes?
> 
> Seems like thre's some mistake.
> Should be 0 on empty, -1 on error (I'm not sure there *can* be an error from
> ibv_poll_cq, need to look it up).

Oh, you're right of course.  0 on empty, but perhaps -2 on error.
I saw this in libmthca/src/cq.c and jumped to the conclusion that
empty == -1:

enum {
        CQ_OK           =  0,
        CQ_EMPTY        = -1,
        CQ_POLL_ERR     = -2
};

But CQ_EMPTY never propagates back to the user.  However,
mthca_poll_cq does:

        return err == CQ_POLL_ERR ? err : npolled;

which returns the -2.

amso_poll_cq uses ibv_cmd_poll_cq, which returns -1 on failed
userspace malloc (but nothing in errno), -1 and errno for some
kernel interface problem, 0 for empty, or +npolled on success.

		-- Pete




More information about the general mailing list