Skip to content

Commit 262b5b7

Browse files
committed
fabrics: add nvmf_default_config()
'struct nvme_fabrics_config' has some default values, and the output functions key off these values to filter the values being printed. So to avoid applications having to know these default values this patch introduces a function nvmf_default_config() to ensure that every application is using the same defaults. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent e5b7b74 commit 262b5b7

5 files changed

Lines changed: 19 additions & 4 deletions

File tree

examples/discover-loop.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ int main()
5353
nvme_host_t h;
5454
nvme_ctrl_t c;
5555
int ret;
56+
struct nvme_fabrics_config cfg;
5657

57-
struct nvme_fabrics_config cfg = {
58-
.tos = -1,
59-
};
58+
nvmf_default_config(&cfg);
6059

6160
r = nvme_scan(NULL);
6261
h = nvme_default_host(r);

src/libnvme.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ LIBNVME_1_0 {
305305
nvmf_adrfam_str;
306306
nvmf_cms_str;
307307
nvmf_connect_disc_entry;
308+
nvmf_default_config;
308309
nvmf_get_discovery_log;
309310
nvmf_hostid_from_file;
310311
nvmf_hostnqn_from_file;

src/nvme/fabrics.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ const char *nvmf_cms_str(__u8 cm)
155155
return arg_str(cms, ARRAY_SIZE(cms), cm);
156156
}
157157

158+
void nvmf_default_config(struct nvme_fabrics_config *cfg)
159+
{
160+
memset(cfg, 0, sizeof(*cfg));
161+
cfg->tos = -1;
162+
cfg->ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO;
163+
}
164+
158165
#define UPDATE_CFG_OPTION(c, n, o, d) \
159166
if ((c)->o == d) (c)->o = (n)->o
160167
static struct nvme_fabrics_config *merge_config(nvme_ctrl_t c,

src/nvme/fabrics.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ const char *nvmf_qptype_str(__u8 qptype);
124124
*/
125125
const char *nvmf_cms_str(__u8 cms);
126126

127+
/**
128+
* nvmf_default_config - Default values for fabrics configuration
129+
* @cfg: config values to set
130+
*
131+
* Initializes @cfg with default values.
132+
*/
133+
void nvmf_default_config(struct nvme_fabrics_config *cfg);
134+
127135
/**
128136
* nvmf_add_ctrl_opts() -
129137
* @c:

src/nvme/tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ struct nvme_ctrl *nvme_create_ctrl(const char *subsysnqn, const char *transport,
942942
return NULL;
943943
}
944944
c->fd = -1;
945-
c->cfg.tos = -1;
945+
nvmf_default_config(&c->cfg);
946946
list_head_init(&c->namespaces);
947947
list_head_init(&c->paths);
948948
list_node_init(&c->entry);

0 commit comments

Comments
 (0)