File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717#include "mi.h"
1818#include "private.h"
1919
20+ static const int default_timeout = 1000 ; /* milliseconds; endpoints may
21+ override */
22+
2023/* MI-equivalent of nvme_create_root, but avoids clashing symbol names
2124 * when linking against both libnvme and libnvme-mi.
2225 */
@@ -57,13 +60,32 @@ struct nvme_mi_ep *nvme_mi_init_ep(nvme_root_t root)
5760 list_node_init (& ep -> root_entry );
5861 ep -> root = root ;
5962 ep -> controllers_scanned = false;
63+ ep -> timeout = default_timeout ;
6064 list_head_init (& ep -> controllers );
6165
6266 list_add (& root -> endpoints , & ep -> root_entry );
6367
6468 return ep ;
6569}
6670
71+ int nvme_mi_ep_set_timeout (nvme_mi_ep_t ep , unsigned int timeout_ms )
72+ {
73+ if (ep -> transport -> check_timeout ) {
74+ int rc ;
75+ rc = ep -> transport -> check_timeout (ep , timeout_ms );
76+ if (rc )
77+ return rc ;
78+ }
79+
80+ ep -> timeout = timeout_ms ;
81+ return 0 ;
82+ }
83+
84+ unsigned int nvme_mi_ep_get_timeout (nvme_mi_ep_t ep )
85+ {
86+ return ep -> timeout ;
87+ }
88+
6789struct nvme_mi_ctrl * nvme_mi_init_ctrl (nvme_mi_ep_t ep , __u16 ctrl_id )
6890{
6991 struct nvme_mi_ctrl * ctrl ;
Original file line number Diff line number Diff line change @@ -451,6 +451,21 @@ nvme_mi_ep_t nvme_mi_next_endpoint(nvme_root_t m, nvme_mi_ep_t e);
451451 e != NULL; \
452452 e = _e, _e = nvme_mi_next_endpoint(m, e))
453453
454+ /**
455+ * nvme_mi_ep_set_timeout - set a timeout for NVMe-MI responses
456+ * @ep: MI endpoint object
457+ * @timeout_ms: Timeout for MI responses, given in milliseconds
458+ */
459+ int nvme_mi_ep_set_timeout (nvme_mi_ep_t ep , unsigned int timeout_ms );
460+
461+ /**
462+ * nvme_mi_ep_get_timeout - get the current timeout value for NVMe-MI responses
463+ * @ep: MI endpoint object
464+ *
465+ * Returns the current timeout value, in milliseconds, for this endpoint.
466+ */
467+ unsigned int nvme_mi_ep_get_timeout (nvme_mi_ep_t ep );
468+
454469struct nvme_mi_ctrl ;
455470
456471/**
Original file line number Diff line number Diff line change @@ -183,6 +183,7 @@ struct nvme_mi_transport {
183183 struct nvme_mi_resp * resp );
184184 void (* close )(struct nvme_mi_ep * ep );
185185 int (* desc_ep )(struct nvme_mi_ep * ep , char * buf , size_t len );
186+ int (* check_timeout )(struct nvme_mi_ep * ep , unsigned int timeout );
186187};
187188
188189struct nvme_mi_ep {
@@ -192,6 +193,7 @@ struct nvme_mi_ep {
192193 struct list_node root_entry ;
193194 struct list_head controllers ;
194195 bool controllers_scanned ;
196+ unsigned int timeout ;
195197};
196198
197199struct nvme_mi_ctrl {
You can’t perform that action at this time.
0 commit comments