@@ -110,9 +110,27 @@ struct nvmf_args {
110110 const char * keyring ;
111111 const char * tls_key ;
112112 const char * tls_key_identity ;
113+ int queue_size ;
114+ int nr_io_queues ;
115+ int reconnect_delay ;
116+ int ctrl_loss_tmo ;
117+ int fast_io_fail_tmo ;
118+ int keep_alive_tmo ;
119+ int nr_write_queues ;
120+ int nr_poll_queues ;
121+ int tos ;
122+ long keyring_id ;
123+ long tls_key_id ;
124+ long tls_configured_key_id ;
125+ bool duplicate_connect ;
126+ bool disable_sqflow ;
127+ bool hdr_digest ;
128+ bool data_digest ;
129+ bool tls ;
130+ bool concat ;
113131};
114132
115- #define NVMF_ARGS (n , f , c , ...) \
133+ #define NVMF_ARGS (n , f , ...) \
116134 NVME_ARGS(n, \
117135 OPT_STRING("transport", 't', "STR", &f.transport, nvmf_tport), \
118136 OPT_STRING("nqn", 'n', "STR", &f.subsysnqn, nvmf_nqn), \
@@ -127,25 +145,31 @@ struct nvmf_args {
127145 OPT_STRING("keyring", 0, "STR", &f.keyring, nvmf_keyring), \
128146 OPT_STRING("tls-key", 0, "STR", &f.tls_key, nvmf_tls_key), \
129147 OPT_STRING("tls-key-identity", 0, "STR", &f.tls_key_identity, nvmf_tls_key_identity), \
130- OPT_INT("nr-io-queues", 'i', &c .nr_io_queues, nvmf_nr_io_queues), \
131- OPT_INT("nr-write-queues", 'W', &c .nr_write_queues, nvmf_nr_write_queues), \
132- OPT_INT("nr-poll-queues", 'P', &c .nr_poll_queues, nvmf_nr_poll_queues), \
133- OPT_INT("queue-size", 'Q', &c .queue_size, nvmf_queue_size), \
134- OPT_INT("keep-alive-tmo", 'k', &c .keep_alive_tmo, nvmf_keep_alive_tmo), \
135- OPT_INT("reconnect-delay", 'c', &c .reconnect_delay, nvmf_reconnect_delay), \
136- OPT_INT("ctrl-loss-tmo", 'l', &c .ctrl_loss_tmo, nvmf_ctrl_loss_tmo), \
137- OPT_INT("fast_io_fail_tmo", 'F', &c .fast_io_fail_tmo, nvmf_fast_io_fail_tmo),\
138- OPT_INT("tos", 'T', &c .tos, nvmf_tos), \
139- OPT_INT("tls_key", 0, &c .tls_key_id, nvmf_tls_key_legacy), \
140- OPT_FLAG("duplicate-connect", 'D', &c .duplicate_connect, nvmf_dup_connect), \
141- OPT_FLAG("disable-sqflow", 0, &c .disable_sqflow, nvmf_disable_sqflow), \
142- OPT_FLAG("hdr-digest", 'g', &c .hdr_digest, nvmf_hdr_digest), \
143- OPT_FLAG("data-digest", 'G', &c .data_digest, nvmf_data_digest), \
144- OPT_FLAG("tls", 0, &c .tls, nvmf_tls), \
145- OPT_FLAG("concat", 0, &c .concat, nvmf_concat), \
148+ OPT_INT("nr-io-queues", 'i', &f .nr_io_queues, nvmf_nr_io_queues), \
149+ OPT_INT("nr-write-queues", 'W', &f .nr_write_queues, nvmf_nr_write_queues), \
150+ OPT_INT("nr-poll-queues", 'P', &f .nr_poll_queues, nvmf_nr_poll_queues), \
151+ OPT_INT("queue-size", 'Q', &f .queue_size, nvmf_queue_size), \
152+ OPT_INT("keep-alive-tmo", 'k', &f .keep_alive_tmo, nvmf_keep_alive_tmo), \
153+ OPT_INT("reconnect-delay", 'c', &f .reconnect_delay, nvmf_reconnect_delay), \
154+ OPT_INT("ctrl-loss-tmo", 'l', &f .ctrl_loss_tmo, nvmf_ctrl_loss_tmo), \
155+ OPT_INT("fast_io_fail_tmo", 'F', &f .fast_io_fail_tmo, nvmf_fast_io_fail_tmo),\
156+ OPT_INT("tos", 'T', &f .tos, nvmf_tos), \
157+ OPT_INT("tls_key", 0, &f .tls_key_id, nvmf_tls_key_legacy), \
158+ OPT_FLAG("duplicate-connect", 'D', &f .duplicate_connect, nvmf_dup_connect), \
159+ OPT_FLAG("disable-sqflow", 0, &f .disable_sqflow, nvmf_disable_sqflow), \
160+ OPT_FLAG("hdr-digest", 'g', &f .hdr_digest, nvmf_hdr_digest), \
161+ OPT_FLAG("data-digest", 'G', &f .data_digest, nvmf_data_digest), \
162+ OPT_FLAG("tls", 0, &f .tls, nvmf_tls), \
163+ OPT_FLAG("concat", 0, &f .concat, nvmf_concat), \
146164 ##__VA_ARGS__ \
147165 )
148166
167+ static void nvmf_default_args (struct nvmf_args * fa )
168+ {
169+ memset (fa , 0 , sizeof (* fa ));
170+ fa -> tos = -1 ;
171+ fa -> ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO ;
172+ }
149173
150174static void save_discovery_log (char * raw , struct nvmf_discovery_log * log )
151175{
@@ -174,7 +198,7 @@ static int setup_common_context(struct libnvmf_context *fctx,
174198 struct nvmf_args * fa );
175199
176200struct cb_fabrics_data {
177- struct libnvme_fabrics_config * cfg ;
201+ struct nvmf_args * fa ;
178202 nvme_print_flags_t flags ;
179203 bool quiet ;
180204 char * raw ;
@@ -274,20 +298,46 @@ static void cb_parser_cleanup(struct libnvmf_context *fctx, void *user_data)
274298 fclose (cfd -> f );
275299}
276300
301+ static int set_fabrics_options (struct libnvmf_context * fctx ,
302+ struct nvmf_args * fa )
303+ {
304+ struct libnvme_fabrics_config fcfg ;
305+
306+ fcfg .queue_size = fa -> queue_size ;
307+ fcfg .nr_io_queues = fa -> nr_io_queues ;
308+ fcfg .reconnect_delay = fa -> reconnect_delay ;
309+ fcfg .ctrl_loss_tmo = fa -> ctrl_loss_tmo ;
310+ fcfg .fast_io_fail_tmo = fa -> fast_io_fail_tmo ;
311+ fcfg .keep_alive_tmo = fa -> keep_alive_tmo ;
312+ fcfg .nr_write_queues = fa -> nr_write_queues ;
313+ fcfg .nr_poll_queues = fa -> nr_poll_queues ;
314+ fcfg .tos = fa -> tos ;
315+ fcfg .keyring_id = fa -> keyring_id ;
316+ fcfg .tls_key_id = fa -> tls_key_id ;
317+ fcfg .tls_configured_key_id = fa -> tls_configured_key_id ;
318+ fcfg .duplicate_connect = fa -> duplicate_connect ;
319+ fcfg .disable_sqflow = fa -> disable_sqflow ;
320+ fcfg .hdr_digest = fa -> hdr_digest ;
321+ fcfg .data_digest = fa -> data_digest ;
322+ fcfg .tls = fa -> tls ;
323+ fcfg .concat = fa -> concat ;
324+
325+ return libnvmf_context_set_fabrics_config (fctx , & fcfg );
326+ }
327+
277328static int cb_parser_next_line (struct libnvmf_context * fctx , void * user_data )
278329{
279330 struct cb_fabrics_data * cfd = user_data ;
280- struct libnvme_fabrics_config cfg ;
281- struct nvmf_args fa = {};
331+ struct nvmf_args fa ;
282332 char * ptr , * p , line [4096 ];
283333 int argc , ret = 0 ;
284334 bool force = false;
285335
286- NVMF_ARGS (opts , fa , cfg ,
336+ NVMF_ARGS (opts , fa ,
287337 OPT_FLAG ("persistent" , 'p' , & persistent , "persistent discovery connection" ),
288338 OPT_FLAG ("force" , 0 , & force , "Force persistent discovery controller creation" ));
289339
290- memcpy (& cfg , cfd -> cfg , sizeof (cfg ));
340+ memcpy (& fa , cfd -> fa , sizeof (fa ));
291341next :
292342 if (fgets (line , sizeof (line ), cfd -> f ) == NULL )
293343 return - EOF ;
@@ -315,7 +365,7 @@ static int cb_parser_next_line(struct libnvmf_context *fctx, void *user_data)
315365 if (ret )
316366 return ret ;
317367
318- ret = libnvmf_context_set_fabrics_config (fctx , & cfg );
368+ ret = set_fabrics_options (fctx , & fa );
319369 if (ret )
320370 return ret ;
321371
@@ -351,7 +401,6 @@ static int setup_common_context(struct libnvmf_context *fctx,
351401
352402static int create_common_context (struct libnvme_global_ctx * ctx ,
353403 bool persistent , struct nvmf_args * fa ,
354- struct libnvme_fabrics_config * cfg ,
355404 void * user_data , struct libnvmf_context * * fctxp )
356405{
357406 struct libnvmf_context * fctx ;
@@ -372,7 +421,7 @@ static int create_common_context(struct libnvme_global_ctx *ctx,
372421 if (err )
373422 goto err ;
374423
375- err = libnvmf_context_set_fabrics_config (fctx , cfg );
424+ err = set_fabrics_options (fctx , fa );
376425 if (err )
377426 goto err ;
378427
@@ -397,13 +446,12 @@ static int create_common_context(struct libnvme_global_ctx *ctx,
397446static int create_discovery_context (struct libnvme_global_ctx * ctx ,
398447 bool persistent , const char * device ,
399448 struct nvmf_args * fa ,
400- struct libnvme_fabrics_config * cfg ,
401449 void * user_data , struct libnvmf_context * * fctxp )
402450{
403451 struct libnvmf_context * fctx ;
404452 int err ;
405453
406- err = create_common_context (ctx , persistent , fa , cfg , user_data ,
454+ err = create_common_context (ctx , persistent , fa , user_data ,
407455 & fctx );
408456 if (err )
409457 return err ;
@@ -527,15 +575,14 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect)
527575 __cleanup_nvme_global_ctx struct libnvme_global_ctx * ctx = NULL ;
528576 __cleanup_nvmf_context struct libnvmf_context * fctx = NULL ;
529577 int ret ;
530- struct libnvme_fabrics_config cfg ;
531578 struct nvmf_args fa = { .subsysnqn = NVME_DISC_SUBSYS_NAME };
532579 char * device = NULL ;
533580 bool force = false;
534581 bool json_config = false;
535582 bool nbft = false, nonbft = false;
536583 char * nbft_path = NBFT_SYSFS_PATH ;
537584
538- NVMF_ARGS (opts , fa , cfg ,
585+ NVMF_ARGS (opts , fa ,
539586 OPT_STRING ("device" , 'd' , "DEV" , & device , "use existing discovery controller device" ),
540587 OPT_FILE ("raw" , 'r' , & raw , "save raw output to file" ),
541588 OPT_FLAG ("persistent" , 'p' , & persistent , "persistent discovery connection" ),
@@ -548,7 +595,7 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect)
548595 OPT_STRING ("nbft-path" , 0 , "STR" , & nbft_path , "user-defined path for NBFT tables" ),
549596 OPT_STRING ("context" , 0 , "STR" , & context , nvmf_context ));
550597
551- libnvmf_default_config ( & cfg );
598+ nvmf_default_args ( & fa );
552599
553600 load_nvme_fabrics_module ();
554601
@@ -597,12 +644,12 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect)
597644 }
598645
599646 struct cb_fabrics_data dld = {
600- .cfg = & cfg ,
647+ .fa = & fa ,
601648 .flags = flags ,
602649 .raw = raw ,
603650 };
604651 ret = create_discovery_context (ctx , persistent , device , & fa ,
605- & cfg , & dld , & fctx );
652+ & dld , & fctx );
606653 if (ret )
607654 return ret ;
608655
@@ -643,15 +690,14 @@ int fabrics_connect(const char *desc, int argc, char **argv)
643690 __cleanup_nvme_ctrl libnvme_ctrl_t c = NULL ;
644691 int ret ;
645692 nvme_print_flags_t flags ;
646- struct libnvme_fabrics_config cfg = { 0 };
647693 struct nvmf_args fa = { 0 };
648694
649- NVMF_ARGS (opts , fa , cfg ,
695+ NVMF_ARGS (opts , fa ,
650696 OPT_STRING ("config" , 'J' , "FILE" , & config_file , nvmf_config_file ),
651697 OPT_FLAG ("dump-config" , 'O' , & dump_config , "Dump JSON configuration to stdout" ),
652698 OPT_STRING ("context" , 0 , "STR" , & context , nvmf_context ));
653699
654- libnvmf_default_config ( & cfg );
700+ nvmf_default_args ( & fa );
655701
656702 load_nvme_fabrics_module ();
657703
@@ -717,8 +763,7 @@ int fabrics_connect(const char *desc, int argc, char **argv)
717763 .quiet = dump_config ,
718764 .raw = raw ,
719765 };
720- ret = create_common_context (ctx , persistent , & fa ,
721- & cfg , & cfd , & fctx );
766+ ret = create_common_context (ctx , persistent , & fa , & cfd , & fctx );
722767 if (ret )
723768 return ret ;
724769
@@ -938,18 +983,17 @@ int fabrics_config(const char *desc, int argc, char **argv)
938983 bool scan_tree = false, modify_config = false, update_config = false;
939984 __cleanup_nvme_global_ctx struct libnvme_global_ctx * ctx = NULL ;
940985 char * config_file = PATH_NVMF_CONFIG ;
941- struct libnvme_fabrics_config cfg ;
942986 struct nvmf_args fa = { };
943987 int ret ;
944988
945- NVMF_ARGS (opts , fa , cfg ,
989+ NVMF_ARGS (opts , fa ,
946990 OPT_STRING ("config" , 'J' , "FILE" , & config_file , nvmf_config_file ),
947991 OPT_FLAG ("scan" , 'R' , & scan_tree , "Scan current NVMeoF topology" ),
948992 OPT_FLAG ("modify" , 'M' , & modify_config , "Modify JSON configuration file" ),
949993 OPT_FLAG ("dump" , 'O' , & dump_config , "Dump JSON configuration to stdout" ),
950994 OPT_FLAG ("update" , 'U' , & update_config , "Update JSON configuration file" ));
951995
952- libnvmf_default_config ( & cfg );
996+ nvmf_default_args ( & fa );
953997
954998 ret = argconfig_parse (argc , argv , desc , opts );
955999 if (ret )
@@ -994,8 +1038,7 @@ int fabrics_config(const char *desc, int argc, char **argv)
9941038 return - EINVAL ;
9951039 }
9961040
997- ret = create_common_context (ctx , persistent , & fa ,
998- & cfg , NULL , & fctx );
1041+ ret = create_common_context (ctx , persistent , & fa , NULL , & fctx );
9991042 if (ret )
10001043 return ret ;
10011044
0 commit comments