4 * Copyright (c) Intel Corporation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include <rte_config.h>
39 #include <rte_lcore.h>
42 #include "spdk/event.h"
43 #include "iscsi/iscsi.h"
48 spdk_sigusr1(int signo
__attribute__((__unused__
)))
50 char *config_str
= NULL
;
51 if (spdk_app_get_running_config(&config_str
, "iscsi.conf") < 0)
52 fprintf(stderr
, "Error getting config\n");
54 fprintf(stdout
, "============================\n");
55 fprintf(stdout
, " iSCSI target running config\n");
56 fprintf(stdout
, "=============================\n");
57 fprintf(stdout
, "%s", config_str
);
63 usage(char *executable_name
)
65 struct spdk_app_opts opts
;
67 spdk_app_opts_init(&opts
);
69 printf("%s [options]\n", executable_name
);
71 printf(" -c config config file (default %s)\n", SPDK_ISCSI_DEFAULT_CONFIG
);
72 printf(" -e mask tracepoint group mask for spdk trace buffers (default 0x0)\n");
73 printf(" -m mask core mask for DPDK\n");
74 printf(" -i shared memory ID (optional)\n");
75 printf(" -l facility use specific syslog facility (default %s)\n",
77 printf(" -n channel number of memory channels used for DPDK\n");
78 printf(" -p core master (primary) core for DPDK\n");
79 printf(" -s size memory size in MB for DPDK\n");
80 spdk_tracelog_usage(stdout
, "-t");
81 printf(" -H show this usage\n");
82 printf(" -b run iscsi target background, the default is foreground\n");
83 printf(" -d disable coredump file enabling\n");
84 printf(" -q disable notice level logging to stderr\n");
88 spdk_startup(void *arg1
, void *arg2
)
90 if (getenv("MEMZONE_DUMP") != NULL
) {
91 spdk_memzone_dump(stdout
);
97 main(int argc
, char **argv
)
102 struct spdk_app_opts opts
= {};
104 /* default value in opts structure */
105 spdk_app_opts_init(&opts
);
107 opts
.config_file
= SPDK_ISCSI_DEFAULT_CONFIG
;
110 while ((ch
= getopt(argc
, argv
, "bc:de:i:l:m:n:p:qs:t:H")) != -1) {
113 opts
.enable_coredump
= false;
116 opts
.config_file
= optarg
;
119 opts
.shm_id
= atoi(optarg
);
122 opts
.log_facility
= optarg
;
125 rc
= spdk_log_set_trace_flag(optarg
);
127 fprintf(stderr
, "unknown flag\n");
132 fprintf(stderr
, "%s must be built with CONFIG_DEBUG=y for -t flag\n",
139 opts
.tpoint_group_mask
= optarg
;
142 spdk_g_notice_stderr_flag
= 0;
145 opts
.reactor_mask
= optarg
;
148 opts
.dpdk_mem_channel
= atoi(optarg
);
151 opts
.dpdk_master_core
= atoi(optarg
);
154 opts
.dpdk_mem_size
= atoi(optarg
);
167 if (daemon(1, 0) < 0) {
168 SPDK_ERRLOG("Start iscsi target daemon faild.\n");
173 if (spdk_g_notice_stderr_flag
== 1 &&
174 isatty(STDERR_FILENO
) &&
175 !strncmp(ttyname(STDERR_FILENO
), "/dev/tty", strlen("/dev/tty"))) {
176 printf("Warning: printing stderr to console terminal without -q option specified.\n");
177 printf("Suggest using -q to disable logging to stderr and monitor syslog, or\n");
178 printf("redirect stderr to a file.\n");
179 printf("(Delaying for 10 seconds...)\n");
183 optind
= 1; /* reset the optind */
185 opts
.shutdown_cb
= spdk_iscsi_shutdown
;
186 opts
.usr1_handler
= spdk_sigusr1
;
187 spdk_app_init(&opts
);
189 printf("Total cores available: %d\n", rte_lcore_count());
190 printf("Using net framework %s\n", spdk_net_framework_get_name());
191 /* Blocks until the application is exiting */
192 app_rc
= spdk_app_start(spdk_startup
, NULL
, NULL
);
194 rc
= spdk_app_fini();
196 return app_rc
? app_rc
: rc
;