From 9ecff41dd11e920286f9be670a0ec3a668371d1d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 26 Jul 2022 07:25:28 +0200 Subject: Merging upstream version 1.1~rc0. Signed-off-by: Daniel Baumann --- src/nvme/private.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) (limited to 'src/nvme/private.h') diff --git a/src/nvme/private.h b/src/nvme/private.h index bea1ae9..da699ba 100644 --- a/src/nvme/private.h +++ b/src/nvme/private.h @@ -10,10 +10,12 @@ #define _LIBNVME_PRIVATE_H #include +#include #include "fabrics.h" +#include "mi.h" -#include +#include extern const char *nvme_ctrl_sysfs_dir; @@ -117,6 +119,7 @@ struct nvme_host { struct nvme_root { char *config_file; struct list_head hosts; + struct list_head endpoints; /* MI endpoints */ FILE *fp; int log_level; bool log_pid; @@ -132,6 +135,11 @@ int json_update_config(nvme_root_t r, const char *config_file); int json_dump_tree(nvme_root_t r); +nvme_ctrl_t __nvme_lookup_ctrl(nvme_subsystem_t s, const char *transport, + const char *traddr, const char *host_traddr, + const char *host_iface, const char *trsvcid, + nvme_ctrl_t p); + #if (LOG_FUNCNAME == 1) #define __nvme_log_func __func__ #else @@ -148,4 +156,65 @@ __nvme_msg(nvme_root_t r, int lvl, const char *func, const char *format, ...); format, ##__VA_ARGS__); \ } while (0) +/* mi internal headers */ + +/* internal transport API */ +struct nvme_mi_req { + struct nvme_mi_msg_hdr *hdr; + size_t hdr_len; + void *data; + size_t data_len; + __u32 mic; +}; + +struct nvme_mi_resp { + struct nvme_mi_msg_hdr *hdr; + size_t hdr_len; + void *data; + size_t data_len; + __u32 mic; +}; + +struct nvme_mi_transport { + const char *name; + bool mic_enabled; + int (*submit)(struct nvme_mi_ep *ep, + struct nvme_mi_req *req, + struct nvme_mi_resp *resp); + void (*close)(struct nvme_mi_ep *ep); + int (*desc_ep)(struct nvme_mi_ep *ep, char *buf, size_t len); +}; + +struct nvme_mi_ep { + struct nvme_root *root; + const struct nvme_mi_transport *transport; + void *transport_data; + struct list_node root_entry; + struct list_head controllers; + bool controllers_scanned; +}; + +struct nvme_mi_ctrl { + struct nvme_mi_ep *ep; + __u16 id; + struct list_node ep_entry; +}; + +struct nvme_mi_ep *nvme_mi_init_ep(struct nvme_root *root); + +/* for tests, we need to calculate the correct MICs */ +__u32 nvme_mi_crc32_update(__u32 crc, void *data, size_t len); + +/* we have a facility to mock MCTP socket operations in the mi-mctp transport, + * using this ops type. This should only be used for test, and isn't exposed + * in the shared lib */; +struct mctp_ioc_tag_ctl; +struct __mi_mctp_socket_ops { + int (*socket)(int, int, int); + ssize_t (*sendmsg)(int, const struct msghdr *, int); + ssize_t (*recvmsg)(int, struct msghdr *, int); + int (*ioctl_tag)(int, unsigned long, struct mctp_ioc_tag_ctl *); +}; +void __nvme_mi_mctp_set_ops(const struct __mi_mctp_socket_ops *newops); + #endif /* _LIBNVME_PRIVATE_H */ -- cgit v1.2.3