[openib-general] MAD receive work completion

Fab Tillier ftillier at infiniconsys.com
Thu Mar 10 15:54:15 PST 2005


> From: Sean Hefty [mailto:mshefty at ichips.intel.com]
> 
> I'm hitting an issue in the CM where I need to access work completion
> information about a received MAD.  The CM takes the received MAD and
> queues it to a CM owned work queue for processing.  It then accesses
> the wc field from ib_mad_recv_wc shown below.
> 
> struct ib_mad_recv_wc {
> 	struct ib_wc		*wc;
> 	struct ib_mad_recv_buf	recv_buf;
> 	int			mad_len;
> };
> 
> The ib_mad_recv_wc and referenced data buffers are owned by the CM
> until it calls ib_free_recv_mad(), however the wc field references an
> item that is declared on the stack.
> 
> I see two main solutions.  The CM can allocate its own ib_wc structure
> and copy the contents of the returned work completion.  Or the MAD
> layer can avoid allocating the work completion on the stack.  Thoughts?

I assume you need the WC information to help you reply, right?

I would say change the ib_wc embedded in ib_mad_recv_wc from a pointer to
the structure, and then use that when you poll.  That way you avoid an extra
allocation in the MAD layer, and avoid the data copy in the CM.

Note that I may have completely missed your point, in which case ignore me.

- Fab




More information about the general mailing list