From: Jeremy Kerr Date: Mon, 18 Jul 2022 06:33:58 +0000 (+0800) Subject: mi: Add maximum More Processing Required limit API X-Git-Tag: v1.1~11^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2ce960822cd88e5d23f68083a8a62e26245698bf;p=users%2Fsagi%2Flibnvme.git mi: Add maximum More Processing Required limit API This change adds a function to set the maximum time we're prepared to wait for a response after a More Processing Required message. Signed-off-by: Jeremy Kerr --- diff --git a/src/nvme/mi.c b/src/nvme/mi.c index 8ece73ce..afac5f73 100644 --- a/src/nvme/mi.c +++ b/src/nvme/mi.c @@ -61,6 +61,7 @@ struct nvme_mi_ep *nvme_mi_init_ep(nvme_root_t root) ep->root = root; ep->controllers_scanned = false; ep->timeout = default_timeout; + ep->mprt_max = 0; list_head_init(&ep->controllers); list_add(&root->endpoints, &ep->root_entry); @@ -81,6 +82,11 @@ int nvme_mi_ep_set_timeout(nvme_mi_ep_t ep, unsigned int timeout_ms) return 0; } +void nvme_mi_ep_set_mprt_max(nvme_mi_ep_t ep, unsigned int mprt_max_ms) +{ + ep->mprt_max = mprt_max_ms; +} + unsigned int nvme_mi_ep_get_timeout(nvme_mi_ep_t ep) { return ep->timeout; diff --git a/src/nvme/mi.h b/src/nvme/mi.h index 7f427b3a..a02ff89f 100644 --- a/src/nvme/mi.h +++ b/src/nvme/mi.h @@ -458,6 +458,24 @@ nvme_mi_ep_t nvme_mi_next_endpoint(nvme_root_t m, nvme_mi_ep_t e); */ int nvme_mi_ep_set_timeout(nvme_mi_ep_t ep, unsigned int timeout_ms); +/** + * nvme_mi_ep_set_mprt_max - set the maximum wait time for a More Processing + * Required response + * @ep: MI endpoint object + * @mprt_max_ms: Maximum more processing required wait time + * + * NVMe-MI endpoints may respond to a request with a "More Processing Required" + * response; this also includes a hint on the worst-case processing time for + * the eventual response data, with a specification-defined maximum of 65.535 + * seconds. + * + * This function provides a way to limit the maximum time we're prepared to + * wait for the final response. Specify zero in @mprt_max_ms for no limit. + * This should be larger than the command/response timeout set in + * &nvme_mi_ep_set_timeout(). + */ +void nvme_mi_ep_set_mprt_max(nvme_mi_ep_t ep, unsigned int mprt_max_ms); + /** * nvme_mi_ep_get_timeout - get the current timeout value for NVMe-MI responses * @ep: MI endpoint object diff --git a/src/nvme/private.h b/src/nvme/private.h index 283b27b4..4e0f75dd 100644 --- a/src/nvme/private.h +++ b/src/nvme/private.h @@ -194,6 +194,7 @@ struct nvme_mi_ep { struct list_head controllers; bool controllers_scanned; unsigned int timeout; + unsigned int mprt_max; }; struct nvme_mi_ctrl {