]> www.infradead.org Git - users/sagi/libnvme.git/commit
mi-mctp: use a linear response buffer
authorJeremy Kerr <jk@codeconstruct.com.au>
Mon, 3 Jul 2023 08:06:34 +0000 (16:06 +0800)
committerDaniel Wagner <wagi@monom.org>
Thu, 20 Jul 2023 08:40:38 +0000 (10:40 +0200)
commitdea640be8d325399ed3d4fb73f404ca4f89bf8bc
tree19c4ddeacf60626520f84bc88a327a9115ee7ee2
parentac95df01ce6c8b729095c36073e4d54c3d26bc5f
mi-mctp: use a linear response buffer

Currently, we're passing a 3-entry iovec to the MCTP resvmsg()
interface:

 - header
 - payload
 - MIC

This is fine if the response comes back eaxctly the size we expect, but
causes complexity if we get a smaller response (for example, as an error
or a More Processing Required response), as we need to extract the MIC
from somewhere in those buffers.

At the moment, since we're enforcing 4-byte alignment, that isn't too
complex - we know the MIC will be entirely in one of the buffers. The
MPR code is a bit awkward, but still manageable.

However: we now want to allow unaligned responses from MI messages,
which is about to make that a lot more complex; in the worst case, the
MIC could be split over all three buffers!

This change uses a fixed linear buffer for the MCTP response instead. We
allocate 4k for this by default, but expand if necessary. We use this as
the sendmsg() buffer, so get a linear message back from the MCTP
endpoint. Once we have verified the format (and extracted the MIC), we
copy this into the actual response header/payload buffers as required.

This makes the response handing code simpler, at the cost of one extra
response buffer per endpoint.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
src/nvme/mi-mctp.c