From edc518050dd563b50a4797cde77d0d0d30ff73c3 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Wed, 16 Jun 2021 11:06:18 +0200 Subject: [PATCH] nvme: split off nvme-private.h header file Split off a private header file from nvme.h to contain all definitions being replaced by libnvme. Signed-off-by: Hannes Reinecke --- nvme-ioctl.h | 2 + nvme-print.c | 2 + nvme-print.h | 1 - nvme-private.h | 71 ++++++++++++++++++++++++++++++ nvme-rpmb.c | 2 + nvme-status.c | 2 + nvme.c | 3 ++ nvme.h | 69 +---------------------------- plugins/amzn/amzn-nvme.c | 2 + plugins/dera/dera-nvme.c | 2 + plugins/huawei/huawei-nvme.c | 2 + plugins/intel/intel-nvme.c | 2 + plugins/memblaze/memblaze-nvme.c | 2 + plugins/micron/micron-nvme.c | 2 + plugins/netapp/netapp-nvme.c | 2 + plugins/nvidia/nvidia-nvme.c | 2 + plugins/scaleflux/sfx-nvme.c | 2 + plugins/seagate/seagate-nvme.c | 2 + plugins/shannon/shannon-nvme.c | 2 + plugins/toshiba/toshiba-nvme.c | 2 + plugins/transcend/transcend-nvme.c | 2 + plugins/virtium/virtium-nvme.c | 2 + plugins/wdc/wdc-nvme.c | 2 + plugins/ymtc/ymtc-nvme.c | 2 + plugins/zns/zns.c | 2 + 25 files changed, 117 insertions(+), 69 deletions(-) create mode 100644 nvme-private.h diff --git a/nvme-ioctl.h b/nvme-ioctl.h index 09aa0bbd..18e49f0d 100644 --- a/nvme-ioctl.h +++ b/nvme-ioctl.h @@ -5,6 +5,8 @@ #include #include "linux/nvme_ioctl.h" #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #define NVME_IOCTL_TIMEOUT 120000 /* in milliseconds */ diff --git a/nvme-print.c b/nvme-print.c index 533e588a..57ae7fc7 100755 --- a/nvme-print.c +++ b/nvme-print.c @@ -6,6 +6,8 @@ #include #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-models.h" #include "util/suffix.h" diff --git a/nvme-print.h b/nvme-print.h index 46abc0ba..97076636 100644 --- a/nvme-print.h +++ b/nvme-print.h @@ -1,7 +1,6 @@ #ifndef NVME_PRINT_H #define NVME_PRINT_H -#include "nvme.h" #include void d(unsigned char *buf, int len, int width, int group); diff --git a/nvme-private.h b/nvme-private.h new file mode 100644 index 00000000..1fd4eb26 --- /dev/null +++ b/nvme-private.h @@ -0,0 +1,71 @@ +#ifndef _NVME_PRIVATE_H +#define _NVME_PRIVATE_H + +struct nvme_subsystem; +struct nvme_ctrl; + +struct nvme_namespace { + char *name; + struct nvme_ctrl *ctrl; + + unsigned nsid; + struct nvme_id_ns ns; +}; + +struct nvme_ctrl { + char *name; + char *path; + struct nvme_subsystem *subsys; + + char *address; + char *transport; + char *state; + char *ana_state; + char *traddr; + char *trsvcid; + char *host_traddr; + char *host_iface; + char *hostnqn; + char *hostid; + + struct nvme_id_ctrl id; + + int nr_namespaces; + struct nvme_namespace *namespaces; +}; + +struct nvme_subsystem { + char *name; + char *subsysnqn; + + int nr_ctrls; + struct nvme_ctrl *ctrls; + + int nr_namespaces; + struct nvme_namespace *namespaces; +}; + +struct nvme_topology { + int nr_subsystems; + struct nvme_subsystem *subsystems; +}; + +void *mmap_registers(const char *dev); + +int scan_ctrl_namespace_filter(const struct dirent *d); +int scan_namespace_filter(const struct dirent *d); +int scan_ctrl_paths_filter(const struct dirent *d); +int scan_ctrls_filter(const struct dirent *d); +int scan_subsys_filter(const struct dirent *d); +int scan_dev_filter(const struct dirent *d); + +int scan_subsystems(struct nvme_topology *t, const char *subsysnqn, + __u32 ns_instance, int nsid, char *dev_dir); +void free_topology(struct nvme_topology *t); +char *get_nvme_subsnqn(char *path); +char *nvme_get_ctrl_attr(const char *path, const char *attr); + +int uuid_from_dmi(char *uuid); +int uuid_from_systemd(char *uuid); + +#endif /* _NVME_PRIVATE_H */ diff --git a/nvme-rpmb.c b/nvme-rpmb.c index 0e11ef33..0b55391f 100644 --- a/nvme-rpmb.c +++ b/nvme-rpmb.c @@ -27,6 +27,8 @@ #include #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" diff --git a/nvme-status.c b/nvme-status.c index 270eb063..d82a6d5b 100644 --- a/nvme-status.c +++ b/nvme-status.c @@ -3,6 +3,8 @@ #include #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-status.h" static inline __u8 nvme_generic_status_to_errno(__u16 status) diff --git a/nvme.c b/nvme.c index d327a9c9..4f985046 100644 --- a/nvme.c +++ b/nvme.c @@ -49,6 +49,9 @@ #include #include "common.h" +#include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" #include "nvme-status.h" diff --git a/nvme.h b/nvme.h index 3b733675..592ba52f 100644 --- a/nvme.h +++ b/nvme.h @@ -49,7 +49,6 @@ #include "util/json.h" #endif #include "util/argconfig.h" -#include "linux/nvme.h" enum nvme_print_flags { NORMAL = 0, @@ -59,55 +58,6 @@ enum nvme_print_flags { BINARY = 1 << 3, /* binary dump raw bytes */ }; -struct nvme_subsystem; -struct nvme_ctrl; - -struct nvme_namespace { - char *name; - struct nvme_ctrl *ctrl; - - unsigned nsid; - struct nvme_id_ns ns; -}; - -struct nvme_ctrl { - char *name; - char *path; - struct nvme_subsystem *subsys; - - char *address; - char *transport; - char *state; - char *ana_state; - char *traddr; - char *trsvcid; - char *host_traddr; - char *host_iface; - char *hostnqn; - char *hostid; - - struct nvme_id_ctrl id; - - int nr_namespaces; - struct nvme_namespace *namespaces; -}; - -struct nvme_subsystem { - char *name; - char *subsysnqn; - - int nr_ctrls; - struct nvme_ctrl *ctrls; - - int nr_namespaces; - struct nvme_namespace *namespaces; -}; - -struct nvme_topology { - int nr_subsystems; - struct nvme_subsystem *subsystems; -}; - #define SYS_NVME "/sys/class/nvme" void register_extension(struct plugin *plugin); @@ -119,30 +69,13 @@ extern const char *output_format; enum nvme_print_flags validate_output_format(const char *format); int __id_ctrl(int argc, char **argv, struct command *cmd, - struct plugin *plugin, void (*vs)(__u8 *vs, struct json_object *root)); + struct plugin *plugin, void (*vs)(uint8_t *vs, struct json_object *root)); char *nvme_char_from_block(char *block); -void *mmap_registers(const char *dev); extern int current_index; -int scan_ctrl_namespace_filter(const struct dirent *d); -int scan_namespace_filter(const struct dirent *d); -int scan_ctrl_paths_filter(const struct dirent *d); -int scan_ctrls_filter(const struct dirent *d); -int scan_subsys_filter(const struct dirent *d); -int scan_dev_filter(const struct dirent *d); - -int scan_subsystems(struct nvme_topology *t, const char *subsysnqn, - __u32 ns_instance, int nsid, char *dev_dir); -void free_topology(struct nvme_topology *t); -char *get_nvme_subsnqn(char *path); -char *nvme_get_ctrl_attr(const char *path, const char *attr); - void *nvme_alloc(size_t len, bool *huge); void nvme_free(void *p, bool huge); -int uuid_from_dmi(char *uuid); -int uuid_from_systemd(char *uuid); - unsigned long long elapsed_utime(struct timeval start_time, struct timeval end_time); #endif /* _NVME_H */ diff --git a/plugins/amzn/amzn-nvme.c b/plugins/amzn/amzn-nvme.c index 47a2d82f..9217586c 100644 --- a/plugins/amzn/amzn-nvme.c +++ b/plugins/amzn/amzn-nvme.c @@ -9,6 +9,8 @@ #include "common.h" #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" #include "plugin.h" diff --git a/plugins/dera/dera-nvme.c b/plugins/dera/dera-nvme.c index be789307..a91d658b 100644 --- a/plugins/dera/dera-nvme.c +++ b/plugins/dera/dera-nvme.c @@ -10,6 +10,8 @@ #include #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" #include "plugin.h" diff --git a/plugins/huawei/huawei-nvme.c b/plugins/huawei/huawei-nvme.c index b39d8615..05c6336f 100644 --- a/plugins/huawei/huawei-nvme.c +++ b/plugins/huawei/huawei-nvme.c @@ -29,6 +29,8 @@ #include "linux/nvme_ioctl.h" #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" #include "plugin.h" diff --git a/plugins/intel/intel-nvme.c b/plugins/intel/intel-nvme.c index 8f8d54d8..59fbd945 100644 --- a/plugins/intel/intel-nvme.c +++ b/plugins/intel/intel-nvme.c @@ -9,6 +9,8 @@ #include "common.h" #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" #include "plugin.h" diff --git a/plugins/memblaze/memblaze-nvme.c b/plugins/memblaze/memblaze-nvme.c index e3807f13..f6fbc802 100644 --- a/plugins/memblaze/memblaze-nvme.c +++ b/plugins/memblaze/memblaze-nvme.c @@ -8,6 +8,8 @@ #include "linux/nvme_ioctl.h" #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" #include "plugin.h" diff --git a/plugins/micron/micron-nvme.c b/plugins/micron/micron-nvme.c index d3f2dc47..32cecbb8 100644 --- a/plugins/micron/micron-nvme.c +++ b/plugins/micron/micron-nvme.c @@ -10,6 +10,8 @@ #include #include #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-status.h" #include "nvme-ioctl.h" diff --git a/plugins/netapp/netapp-nvme.c b/plugins/netapp/netapp-nvme.c index 15c39231..0fe2bedb 100644 --- a/plugins/netapp/netapp-nvme.c +++ b/plugins/netapp/netapp-nvme.c @@ -24,6 +24,8 @@ #include #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-ioctl.h" #include "suffix.h" diff --git a/plugins/nvidia/nvidia-nvme.c b/plugins/nvidia/nvidia-nvme.c index cdf51ab2..cb080d7b 100644 --- a/plugins/nvidia/nvidia-nvme.c +++ b/plugins/nvidia/nvidia-nvme.c @@ -9,6 +9,8 @@ #include "common.h" #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" #include "plugin.h" diff --git a/plugins/scaleflux/sfx-nvme.c b/plugins/scaleflux/sfx-nvme.c index df7f9a3e..31b88523 100644 --- a/plugins/scaleflux/sfx-nvme.c +++ b/plugins/scaleflux/sfx-nvme.c @@ -14,6 +14,8 @@ #include "linux/nvme_ioctl.h" #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" #include "nvme-status.h" diff --git a/plugins/seagate/seagate-nvme.c b/plugins/seagate/seagate-nvme.c index 9512cda6..844594d8 100644 --- a/plugins/seagate/seagate-nvme.c +++ b/plugins/seagate/seagate-nvme.c @@ -31,6 +31,8 @@ #include #include "linux/nvme_ioctl.h" #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" #include "plugin.h" diff --git a/plugins/shannon/shannon-nvme.c b/plugins/shannon/shannon-nvme.c index 1909e458..fac29b46 100644 --- a/plugins/shannon/shannon-nvme.c +++ b/plugins/shannon/shannon-nvme.c @@ -9,6 +9,8 @@ #include "common.h" #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" #include "plugin.h" diff --git a/plugins/toshiba/toshiba-nvme.c b/plugins/toshiba/toshiba-nvme.c index cba1af8c..5a167d59 100644 --- a/plugins/toshiba/toshiba-nvme.c +++ b/plugins/toshiba/toshiba-nvme.c @@ -9,6 +9,8 @@ #include "linux/nvme_ioctl.h" #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" #include "plugin.h" diff --git a/plugins/transcend/transcend-nvme.c b/plugins/transcend/transcend-nvme.c index dbb56be3..e7d021c7 100644 --- a/plugins/transcend/transcend-nvme.c +++ b/plugins/transcend/transcend-nvme.c @@ -7,6 +7,8 @@ #include "linux/nvme_ioctl.h" #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" #include "plugin.h" diff --git a/plugins/virtium/virtium-nvme.c b/plugins/virtium/virtium-nvme.c index a194a5fa..249a7a8e 100644 --- a/plugins/virtium/virtium-nvme.c +++ b/plugins/virtium/virtium-nvme.c @@ -11,6 +11,8 @@ #include "linux/nvme_ioctl.h" #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" #include "plugin.h" diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index 585bc10e..cdf77069 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -34,6 +34,8 @@ #include "common.h" #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" #include "plugin.h" diff --git a/plugins/ymtc/ymtc-nvme.c b/plugins/ymtc/ymtc-nvme.c index 91e52bef..d599f231 100644 --- a/plugins/ymtc/ymtc-nvme.c +++ b/plugins/ymtc/ymtc-nvme.c @@ -7,6 +7,8 @@ #include "linux/nvme_ioctl.h" #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-print.h" #include "nvme-ioctl.h" #include "plugin.h" diff --git a/plugins/zns/zns.c b/plugins/zns/zns.c index 5c5ed92a..70959a35 100644 --- a/plugins/zns/zns.c +++ b/plugins/zns/zns.c @@ -8,6 +8,8 @@ #include #include "nvme.h" +#include "linux/nvme.h" +#include "nvme-private.h" #include "nvme-ioctl.h" #include "nvme-print.h" #include "nvme-status.h" -- 2.50.1