@@ -106,9 +106,27 @@ struct nvmf_args {
106106 const char * keyring ;
107107 const char * tls_key ;
108108 const char * tls_key_identity ;
109+ int queue_size ;
110+ int nr_io_queues ;
111+ int reconnect_delay ;
112+ int ctrl_loss_tmo ;
113+ int fast_io_fail_tmo ;
114+ int keep_alive_tmo ;
115+ int nr_write_queues ;
116+ int nr_poll_queues ;
117+ int tos ;
118+ long keyring_id ;
119+ long tls_key_id ;
120+ long tls_configured_key_id ;
121+ bool duplicate_connect ;
122+ bool disable_sqflow ;
123+ bool hdr_digest ;
124+ bool data_digest ;
125+ bool tls ;
126+ bool concat ;
109127};
110128
111- #define NVMF_ARGS (n , f , c , ...) \
129+ #define NVMF_ARGS (n , f , ...) \
112130 NVME_ARGS(n, \
113131 OPT_STRING("transport", 't', "STR", &f.transport, nvmf_tport), \
114132 OPT_STRING("nqn", 'n', "STR", &f.subsysnqn, nvmf_nqn), \
@@ -123,25 +141,31 @@ struct nvmf_args {
123141 OPT_STRING("keyring", 0, "STR", &f.keyring, nvmf_keyring), \
124142 OPT_STRING("tls-key", 0, "STR", &f.tls_key, nvmf_tls_key), \
125143 OPT_STRING("tls-key-identity", 0, "STR", &f.tls_key_identity, nvmf_tls_key_identity), \
126- OPT_INT("nr-io-queues", 'i', &c .nr_io_queues, nvmf_nr_io_queues), \
127- OPT_INT("nr-write-queues", 'W', &c .nr_write_queues, nvmf_nr_write_queues), \
128- OPT_INT("nr-poll-queues", 'P', &c .nr_poll_queues, nvmf_nr_poll_queues), \
129- OPT_INT("queue-size", 'Q', &c .queue_size, nvmf_queue_size), \
130- OPT_INT("keep-alive-tmo", 'k', &c .keep_alive_tmo, nvmf_keep_alive_tmo), \
131- OPT_INT("reconnect-delay", 'c', &c .reconnect_delay, nvmf_reconnect_delay), \
132- OPT_INT("ctrl-loss-tmo", 'l', &c .ctrl_loss_tmo, nvmf_ctrl_loss_tmo), \
133- OPT_INT("fast_io_fail_tmo", 'F', &c .fast_io_fail_tmo, nvmf_fast_io_fail_tmo),\
134- OPT_INT("tos", 'T', &c .tos, nvmf_tos), \
135- OPT_INT("tls_key", 0, &c .tls_key_id, nvmf_tls_key_legacy), \
136- OPT_FLAG("duplicate-connect", 'D', &c .duplicate_connect, nvmf_dup_connect), \
137- OPT_FLAG("disable-sqflow", 0, &c .disable_sqflow, nvmf_disable_sqflow), \
138- OPT_FLAG("hdr-digest", 'g', &c .hdr_digest, nvmf_hdr_digest), \
139- OPT_FLAG("data-digest", 'G', &c .data_digest, nvmf_data_digest), \
140- OPT_FLAG("tls", 0, &c .tls, nvmf_tls), \
141- OPT_FLAG("concat", 0, &c .concat, nvmf_concat), \
144+ OPT_INT("nr-io-queues", 'i', &f .nr_io_queues, nvmf_nr_io_queues), \
145+ OPT_INT("nr-write-queues", 'W', &f .nr_write_queues, nvmf_nr_write_queues), \
146+ OPT_INT("nr-poll-queues", 'P', &f .nr_poll_queues, nvmf_nr_poll_queues), \
147+ OPT_INT("queue-size", 'Q', &f .queue_size, nvmf_queue_size), \
148+ OPT_INT("keep-alive-tmo", 'k', &f .keep_alive_tmo, nvmf_keep_alive_tmo), \
149+ OPT_INT("reconnect-delay", 'c', &f .reconnect_delay, nvmf_reconnect_delay), \
150+ OPT_INT("ctrl-loss-tmo", 'l', &f .ctrl_loss_tmo, nvmf_ctrl_loss_tmo), \
151+ OPT_INT("fast_io_fail_tmo", 'F', &f .fast_io_fail_tmo, nvmf_fast_io_fail_tmo),\
152+ OPT_INT("tos", 'T', &f .tos, nvmf_tos), \
153+ OPT_INT("tls_key", 0, &f .tls_key_id, nvmf_tls_key_legacy), \
154+ OPT_FLAG("duplicate-connect", 'D', &f .duplicate_connect, nvmf_dup_connect), \
155+ OPT_FLAG("disable-sqflow", 0, &f .disable_sqflow, nvmf_disable_sqflow), \
156+ OPT_FLAG("hdr-digest", 'g', &f .hdr_digest, nvmf_hdr_digest), \
157+ OPT_FLAG("data-digest", 'G', &f .data_digest, nvmf_data_digest), \
158+ OPT_FLAG("tls", 0, &f .tls, nvmf_tls), \
159+ OPT_FLAG("concat", 0, &f .concat, nvmf_concat), \
142160 ##__VA_ARGS__ \
143161 )
144162
163+ static void nvmf_default_args (struct nvmf_args * fa )
164+ {
165+ memset (fa , 0 , sizeof (* fa ));
166+ fa -> tos = -1 ;
167+ fa -> ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO ;
168+ }
145169
146170static void save_discovery_log (char * raw , struct nvmf_discovery_log * log )
147171{
@@ -170,7 +194,7 @@ static int setup_common_context(struct libnvmf_context *fctx,
170194 struct nvmf_args * fa );
171195
172196struct cb_fabrics_data {
173- struct libnvme_fabrics_config * cfg ;
197+ struct nvmf_args * fa ;
174198 nvme_print_flags_t flags ;
175199 bool quiet ;
176200 char * raw ;
@@ -270,20 +294,46 @@ static void cb_parser_cleanup(struct libnvmf_context *fctx, void *user_data)
270294 fclose (cfd -> f );
271295}
272296
297+ static int set_fabrics_options (struct libnvmf_context * fctx ,
298+ struct nvmf_args * fa )
299+ {
300+ struct libnvme_fabrics_config fcfg ;
301+
302+ fcfg .queue_size = fa -> queue_size ;
303+ fcfg .nr_io_queues = fa -> nr_io_queues ;
304+ fcfg .reconnect_delay = fa -> reconnect_delay ;
305+ fcfg .ctrl_loss_tmo = fa -> ctrl_loss_tmo ;
306+ fcfg .fast_io_fail_tmo = fa -> fast_io_fail_tmo ;
307+ fcfg .keep_alive_tmo = fa -> keep_alive_tmo ;
308+ fcfg .nr_write_queues = fa -> nr_write_queues ;
309+ fcfg .nr_poll_queues = fa -> nr_poll_queues ;
310+ fcfg .tos = fa -> tos ;
311+ fcfg .keyring_id = fa -> keyring_id ;
312+ fcfg .tls_key_id = fa -> tls_key_id ;
313+ fcfg .tls_configured_key_id = fa -> tls_configured_key_id ;
314+ fcfg .duplicate_connect = fa -> duplicate_connect ;
315+ fcfg .disable_sqflow = fa -> disable_sqflow ;
316+ fcfg .hdr_digest = fa -> hdr_digest ;
317+ fcfg .data_digest = fa -> data_digest ;
318+ fcfg .tls = fa -> tls ;
319+ fcfg .concat = fa -> concat ;
320+
321+ return libnvmf_context_set_fabrics_config (fctx , & fcfg );
322+ }
323+
273324static int cb_parser_next_line (struct libnvmf_context * fctx , void * user_data )
274325{
275326 struct cb_fabrics_data * cfd = user_data ;
276- struct libnvme_fabrics_config cfg ;
277- struct nvmf_args fa = {};
327+ struct nvmf_args fa ;
278328 char * ptr , * p , line [4096 ];
279329 int argc , ret = 0 ;
280330 bool force = false;
281331
282- NVMF_ARGS (opts , fa , cfg ,
332+ NVMF_ARGS (opts , fa ,
283333 OPT_FLAG ("persistent" , 'p' , & persistent , "persistent discovery connection" ),
284334 OPT_FLAG ("force" , 0 , & force , "Force persistent discovery controller creation" ));
285335
286- memcpy (& cfg , cfd -> cfg , sizeof (cfg ));
336+ memcpy (& fa , cfd -> fa , sizeof (fa ));
287337next :
288338 if (fgets (line , sizeof (line ), cfd -> f ) == NULL )
289339 return - EOF ;
@@ -311,7 +361,7 @@ static int cb_parser_next_line(struct libnvmf_context *fctx, void *user_data)
311361 if (ret )
312362 return ret ;
313363
314- ret = libnvmf_context_set_fabrics_config (fctx , & cfg );
364+ ret = set_fabrics_options (fctx , & fa );
315365 if (ret )
316366 return ret ;
317367
@@ -347,7 +397,6 @@ static int setup_common_context(struct libnvmf_context *fctx,
347397
348398static int create_common_context (struct libnvme_global_ctx * ctx ,
349399 bool persistent , struct nvmf_args * fa ,
350- struct libnvme_fabrics_config * cfg ,
351400 void * user_data , struct libnvmf_context * * fctxp )
352401{
353402 struct libnvmf_context * fctx ;
@@ -368,7 +417,7 @@ static int create_common_context(struct libnvme_global_ctx *ctx,
368417 if (err )
369418 goto err ;
370419
371- err = libnvmf_context_set_fabrics_config (fctx , cfg );
420+ err = set_fabrics_options (fctx , fa );
372421 if (err )
373422 goto err ;
374423
@@ -393,13 +442,12 @@ static int create_common_context(struct libnvme_global_ctx *ctx,
393442static int create_discovery_context (struct libnvme_global_ctx * ctx ,
394443 bool persistent , const char * device ,
395444 struct nvmf_args * fa ,
396- struct libnvme_fabrics_config * cfg ,
397445 void * user_data , struct libnvmf_context * * fctxp )
398446{
399447 struct libnvmf_context * fctx ;
400448 int err ;
401449
402- err = create_common_context (ctx , persistent , fa , cfg , user_data ,
450+ err = create_common_context (ctx , persistent , fa , user_data ,
403451 & fctx );
404452 if (err )
405453 return err ;
@@ -479,15 +527,14 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect)
479527 __cleanup_nvme_global_ctx struct libnvme_global_ctx * ctx = NULL ;
480528 __cleanup_nvmf_context struct libnvmf_context * fctx = NULL ;
481529 int ret ;
482- struct libnvme_fabrics_config cfg ;
483530 struct nvmf_args fa = { .subsysnqn = NVME_DISC_SUBSYS_NAME };
484531 char * device = NULL ;
485532 bool force = false;
486533 bool json_config = false;
487534 bool nbft = false, nonbft = false;
488535 char * nbft_path = NBFT_SYSFS_PATH ;
489536
490- NVMF_ARGS (opts , fa , cfg ,
537+ NVMF_ARGS (opts , fa ,
491538 OPT_STRING ("device" , 'd' , "DEV" , & device , "use existing discovery controller device" ),
492539 OPT_FILE ("raw" , 'r' , & raw , "save raw output to file" ),
493540 OPT_FLAG ("persistent" , 'p' , & persistent , "persistent discovery connection" ),
@@ -500,7 +547,7 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect)
500547 OPT_STRING ("nbft-path" , 0 , "STR" , & nbft_path , "user-defined path for NBFT tables" ),
501548 OPT_STRING ("context" , 0 , "STR" , & context , nvmf_context ));
502549
503- libnvmf_default_config ( & cfg );
550+ nvmf_default_args ( & fa );
504551
505552 ret = argconfig_parse (argc , argv , desc , opts );
506553 if (ret )
@@ -547,12 +594,12 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect)
547594 }
548595
549596 struct cb_fabrics_data dld = {
550- .cfg = & cfg ,
597+ .fa = & fa ,
551598 .flags = flags ,
552599 .raw = raw ,
553600 };
554601 ret = create_discovery_context (ctx , persistent , device , & fa ,
555- & cfg , & dld , & fctx );
602+ & dld , & fctx );
556603 if (ret )
557604 return ret ;
558605
@@ -593,15 +640,14 @@ int fabrics_connect(const char *desc, int argc, char **argv)
593640 __cleanup_nvme_ctrl libnvme_ctrl_t c = NULL ;
594641 int ret ;
595642 nvme_print_flags_t flags ;
596- struct libnvme_fabrics_config cfg = { 0 };
597643 struct nvmf_args fa = { 0 };
598644
599- NVMF_ARGS (opts , fa , cfg ,
645+ NVMF_ARGS (opts , fa ,
600646 OPT_STRING ("config" , 'J' , "FILE" , & config_file , nvmf_config_file ),
601647 OPT_FLAG ("dump-config" , 'O' , & dump_config , "Dump JSON configuration to stdout" ),
602648 OPT_STRING ("context" , 0 , "STR" , & context , nvmf_context ));
603649
604- libnvmf_default_config ( & cfg );
650+ nvmf_default_args ( & fa );
605651
606652 ret = argconfig_parse (argc , argv , desc , opts );
607653 if (ret )
@@ -665,8 +711,7 @@ int fabrics_connect(const char *desc, int argc, char **argv)
665711 .quiet = dump_config ,
666712 .raw = raw ,
667713 };
668- ret = create_common_context (ctx , persistent , & fa ,
669- & cfg , & cfd , & fctx );
714+ ret = create_common_context (ctx , persistent , & fa , & cfd , & fctx );
670715 if (ret )
671716 return ret ;
672717
@@ -886,18 +931,17 @@ int fabrics_config(const char *desc, int argc, char **argv)
886931 bool scan_tree = false, modify_config = false, update_config = false;
887932 __cleanup_nvme_global_ctx struct libnvme_global_ctx * ctx = NULL ;
888933 char * config_file = PATH_NVMF_CONFIG ;
889- struct libnvme_fabrics_config cfg ;
890934 struct nvmf_args fa = { };
891935 int ret ;
892936
893- NVMF_ARGS (opts , fa , cfg ,
937+ NVMF_ARGS (opts , fa ,
894938 OPT_STRING ("config" , 'J' , "FILE" , & config_file , nvmf_config_file ),
895939 OPT_FLAG ("scan" , 'R' , & scan_tree , "Scan current NVMeoF topology" ),
896940 OPT_FLAG ("modify" , 'M' , & modify_config , "Modify JSON configuration file" ),
897941 OPT_FLAG ("dump" , 'O' , & dump_config , "Dump JSON configuration to stdout" ),
898942 OPT_FLAG ("update" , 'U' , & update_config , "Update JSON configuration file" ));
899943
900- libnvmf_default_config ( & cfg );
944+ nvmf_default_args ( & fa );
901945
902946 ret = argconfig_parse (argc , argv , desc , opts );
903947 if (ret )
@@ -942,8 +986,7 @@ int fabrics_config(const char *desc, int argc, char **argv)
942986 return - EINVAL ;
943987 }
944988
945- ret = create_common_context (ctx , persistent , & fa ,
946- & cfg , NULL , & fctx );
989+ ret = create_common_context (ctx , persistent , & fa , NULL , & fctx );
947990 if (ret )
948991 return ret ;
949992
0 commit comments