[PATCH 10/35] fabrics: export do_discover(), build_options() and config

mwilck
2021-01-26T20:35:03Z

From: Martin Wilck <mwilck@suse.com>

These functions will be called by the monitor code.
Also export BUF_SIZE as the size of argstr.

Being able to access struct config and the "cfg" variable
from fabrics.c is essential for the monitor to leverage the existing,
well tested code as much as possible.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
fabrics.c | 33 ++++-----------------------------
fabrics.h | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 29 deletions(-)

diff --git a/fabrics.c b/fabrics.c
index 555b6b4..c1a4bb5 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -69,31 +69,7 @@ const char *conarg_traddr = "traddr";
const char *conarg_trsvcid = "trsvcid";
const char *conarg_host_traddr = "host_traddr";

-static struct config {
- char *nqn;
- char *transport;
- char *traddr;
- char *trsvcid;
- char *host_traddr;
- char *hostnqn;
- char *hostid;
- int nr_io_queues;
- int nr_write_queues;
- int nr_poll_queues;
- int queue_size;
- int keep_alive_tmo;
- int reconnect_delay;
- int ctrl_loss_tmo;
- int tos;
- char *raw;
- char *device;
- int duplicate_connect;
- int disable_sqflow;
- int hdr_digest;
- int data_digest;
- bool persistent;
- bool matching_only;
-} cfg = { .ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO };
+struct config cfg = { .ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO };

struct connect_args {
char *subsysnqn;
@@ -107,7 +83,6 @@ struct connect_args {

struct connect_args *tracked_ctrls;

-#define BUF_SIZE 4096
#define PATH_NVME_FABRICS "/dev/nvme-fabrics"
#define PATH_NVMF_DISC "/etc/nvme/discovery.conf"
#define PATH_NVMF_HOSTNQN "/etc/nvme/hostnqn"
@@ -226,7 +201,7 @@ static const char *cms_str(__u8 cm)
return arg_str(cms, ARRAY_SIZE(cms), cm);
}

-static int do_discover(char *argstr, bool connect);
+int do_discover(char *argstr, bool connect);

/*
* parse strings with connect arguments to find a particular field.
@@ -855,7 +830,7 @@ add_argument(char **argstr, int *max_len, char *arg_str, char *arg)
return 0;
}

-static int build_options(char *argstr, int max_len, bool discover)
+int build_options(char *argstr, int max_len, bool discover)
{
int len;

@@ -1264,7 +1239,7 @@ static void nvmf_get_host_identifiers(int ctrl_instance)
cfg.hostid = nvme_get_ctrl_attr(path, "hostid");
}

-static int do_discover(char *argstr, bool connect)
+int do_discover(char *argstr, bool connect)
{
struct nvmf_disc_rsp_page_hdr *log = NULL;
char *dev_name;
diff --git a/fabrics.h b/fabrics.h
index f5b8eaf..ce965a3 100644
--- a/fabrics.h
+++ b/fabrics.h
@@ -10,4 +10,38 @@ extern int fabrics_connect(const char *desc, int argc, char **argv);
extern int fabrics_disconnect(const char *desc, int argc, char **argv);
extern int fabrics_disconnect_all(const char *desc, int argc, char **argv);

+/* Symbols used by monitor.c */
+
+struct config {
+ char *nqn;
+ char *transport;
+ char *traddr;
+ char *trsvcid;
+ char *host_traddr;
+ char *hostnqn;
+ char *hostid;
+ int nr_io_queues;
+ int nr_write_queues;
+ int nr_poll_queues;
+ int queue_size;
+ int keep_alive_tmo;
+ int reconnect_delay;
+ int ctrl_loss_tmo;
+ int tos;
+ char *raw;
+ char *device;
+ int duplicate_connect;
+ int disable_sqflow;
+ int hdr_digest;
+ int data_digest;
+ bool persistent;
+ bool matching_only;
+};
+extern struct config cfg;
+
+#define BUF_SIZE 4096
+
+int build_options(char *argstr, int max_len, bool discover);
+int do_discover(char *argstr, bool connect);
+
#endif
--
2.29.2