cxl/mbox: Add variable output size validation for internal commands
authorDan Williams <dan.j.williams@intel.com>
Tue, 6 Dec 2022 04:22:39 +0000 (20:22 -0800)
committerDan Williams <dan.j.williams@intel.com>
Tue, 6 Dec 2022 22:36:02 +0000 (14:36 -0800)
commit2aeaf663b85e436dc6287692b7561ffbf0aa4381
treef22c62b322bca595061d2104c69cfb4ba2c78927
parent5331cdf44dc389ac56f7ba5c24ca52d13eaad8d7
cxl/mbox: Add variable output size validation for internal commands

cxl_internal_send_cmd() skips output size validation for variable output
commands which is not ideal. Most of the time internal usages want to
fail if the output size does not match what was requested. For other
commands where the caller cannot predict the size there is usually a
a header that conveys how much vaild data is in the payload. For those
cases add @min_out as a parameter to specify what the minimum response
payload needs to be for the caller to parse the rest of the payload.

In this patch only Get Supported Logs has that behavior, but going
forward records retrieval commands like Get Poison List and Get Event
Records can use @min_out to retrieve a variable amount of records.

Critically, this validation scheme skips the needs to interrogate the
cxl_mem_commands array which in turn frees up the implementation to
support internal command enabling without also enabling external / user
commands.

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/167030055918.4044561.10339573829837910505.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/core/mbox.c
drivers/cxl/cxlmem.h