[openib-general] user_mad: Support RMPP on receive side
Hal Rosenstock
halr at voltaire.com
Mon Jun 27 11:44:52 PDT 2005
Hi,
I am in the process of enabling receive side RMPP in user_mad. There is
an open issue about read (length returned when supplied buffer is too
small) and failing doing it that way, there would be an additional
ioctl.
I would prefer to do it the read way as that seems more optimal in that
a mad agent doing receives can do a normal MAD sized read and if a
larger RMPP size packet comes in, he just does a read with the larger
size. With the ioctl, the user would need to do an ioctl to get the size
for the read if any RMPPs are possible.
Any objections ? Thanks.
-- Hal
-----Forwarded Message-----
From: Hal Rosenstock <halr at voltaire.com>
To: Roland Dreier <roland at topspin.com>
Cc: openib-general at openib.org
Subject: [openib-general] Re: [RFC] [PATCH] user_mad: Support RMPP on send side
Date: 20 May 2005 09:23:00 -0400
On Wed, 2005-05-18 at 19:04, Roland Dreier wrote:
> This looks OK to check in with one small comment on the following:
>
> - if (copy_to_user(buf, &packet->mad, sizeof packet->mad))
> + if (copy_to_user(buf, &packet->mad,
> + min(count, packet->length +
> + sizeof (struct ib_user_mad))))
> ret = -EFAULT;
> else
> - ret = sizeof packet->mad;
> + ret = count;
>
> This code will truncate a received MAD that is bigger than the buffer
> passed into read(), but return the full size of the packet. I don't
> think read() is allowed to do this: the return value can be at most
> the count value passed in by the user.
>
> I think we have two options: truncate and return the actual amount of
> data read to the user, or return an error if the user's buffer is too
> small.
The man page for read states:
read() attempts to read up to count bytes from file descriptor fd into
the buffer starting at buf.
RETURN VALUE
On success, the number of bytes read is returned (zero indicates end of
file), and the file position is advanced by this number.
For RMPP reads (next set of changes to this), it would eliminate an
additional call (ioctl) if on a read that a return length larger than
the count supplied indicates that the read did not occur and the count
(buffer size) to be used for the next read to get the entire packet.
It appears to me that there is nothing that enforces the man page
behavior above in Linux so this is a "convention". Is this something we
can take advantage of or do we need to require the additional call to
get the buffer length ?
-- Hal
_______________________________________________
openib-general mailing list
openib-general at openib.org
http://openib.org/mailman/listinfo/openib-general
To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
More information about the general
mailing list