hello_sock: Add cli params to enable/disable zcopy
Similar to examples/nvme/perf/perf.c Usage: -z disable zcopy -Z enable zcopy Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com> Change-Id: I56f1b0d9c79cbfdba57d0e132a18cb5dce0b7904 Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12435 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
25aa27b9d1
commit
31a8a83c64
@ -51,6 +51,7 @@ static char *g_host;
|
||||
static char *g_sock_impl_name;
|
||||
static int g_port;
|
||||
static bool g_is_server;
|
||||
static int g_zcopy;
|
||||
static bool g_verbose;
|
||||
|
||||
/*
|
||||
@ -62,6 +63,7 @@ struct hello_context_t {
|
||||
char *host;
|
||||
char *sock_impl_name;
|
||||
int port;
|
||||
int zcopy;
|
||||
|
||||
bool verbose;
|
||||
int bytes_in;
|
||||
@ -88,6 +90,8 @@ hello_sock_usage(void)
|
||||
printf(" -N sock_impl socket implementation, e.g., -N posix or -N uring\n");
|
||||
printf(" -S start in server mode\n");
|
||||
printf(" -V print out additional informations\n");
|
||||
printf(" -z disable zero copy send for the given sock implementation\n");
|
||||
printf(" -Z enable zero copy send for the given sock implementation\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -115,6 +119,12 @@ static int hello_sock_parse_arg(int ch, char *arg)
|
||||
case 'V':
|
||||
g_verbose = true;
|
||||
break;
|
||||
case 'Z':
|
||||
g_zcopy = 1;
|
||||
break;
|
||||
case 'z':
|
||||
g_zcopy = 0;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -215,11 +225,16 @@ hello_sock_connect(struct hello_context_t *ctx)
|
||||
int rc;
|
||||
char saddr[ADDR_STR_LEN], caddr[ADDR_STR_LEN];
|
||||
uint16_t cport, sport;
|
||||
struct spdk_sock_opts opts;
|
||||
|
||||
opts.opts_size = sizeof(opts);
|
||||
spdk_sock_get_default_opts(&opts);
|
||||
opts.zcopy = ctx->zcopy;
|
||||
|
||||
SPDK_NOTICELOG("Connecting to the server on %s:%d with sock_impl(%s)\n", ctx->host, ctx->port,
|
||||
ctx->sock_impl_name);
|
||||
|
||||
ctx->sock = spdk_sock_connect(ctx->host, ctx->port, ctx->sock_impl_name);
|
||||
ctx->sock = spdk_sock_connect_ext(ctx->host, ctx->port, ctx->sock_impl_name, &opts);
|
||||
if (ctx->sock == NULL) {
|
||||
SPDK_ERRLOG("connect error(%d): %s\n", errno, spdk_strerror(errno));
|
||||
return -1;
|
||||
@ -346,7 +361,13 @@ hello_sock_group_poll(void *arg)
|
||||
static int
|
||||
hello_sock_listen(struct hello_context_t *ctx)
|
||||
{
|
||||
ctx->sock = spdk_sock_listen(ctx->host, ctx->port, ctx->sock_impl_name);
|
||||
struct spdk_sock_opts opts;
|
||||
|
||||
opts.opts_size = sizeof(opts);
|
||||
spdk_sock_get_default_opts(&opts);
|
||||
opts.zcopy = ctx->zcopy;
|
||||
|
||||
ctx->sock = spdk_sock_listen_ext(ctx->host, ctx->port, ctx->sock_impl_name, &opts);
|
||||
if (ctx->sock == NULL) {
|
||||
SPDK_ERRLOG("Cannot create server socket\n");
|
||||
return -1;
|
||||
@ -413,7 +434,7 @@ main(int argc, char **argv)
|
||||
opts.name = "hello_sock";
|
||||
opts.shutdown_cb = hello_sock_shutdown_cb;
|
||||
|
||||
if ((rc = spdk_app_parse_args(argc, argv, &opts, "H:N:P:SV", NULL, hello_sock_parse_arg,
|
||||
if ((rc = spdk_app_parse_args(argc, argv, &opts, "H:N:P:SVzZ", NULL, hello_sock_parse_arg,
|
||||
hello_sock_usage)) != SPDK_APP_PARSE_ARGS_SUCCESS) {
|
||||
exit(rc);
|
||||
}
|
||||
@ -421,6 +442,7 @@ main(int argc, char **argv)
|
||||
hello_context.host = g_host;
|
||||
hello_context.sock_impl_name = g_sock_impl_name;
|
||||
hello_context.port = g_port;
|
||||
hello_context.zcopy = g_zcopy;
|
||||
hello_context.verbose = g_verbose;
|
||||
|
||||
rc = spdk_app_start(&opts, hello_start, &hello_context);
|
||||
|
@ -88,6 +88,22 @@ if ! echo "$response" | grep -q "$message"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# send message using hello_sock client with zero copy disabled
|
||||
message="**MESSAGE:This is a test message from the client with zero copy disabled**"
|
||||
response=$(echo $message | $HELLO_SOCK_APP -H $INITIATOR_IP -P $ISCSI_PORT -N "posix" -z)
|
||||
|
||||
if ! echo "$response" | grep -q "$message"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# send message using hello_sock client with zero copy enabled
|
||||
message="**MESSAGE:This is a test message from the client with zero copy enabled**"
|
||||
response=$(echo $message | $HELLO_SOCK_APP -H $INITIATOR_IP -P $ISCSI_PORT -N "posix" -Z)
|
||||
|
||||
if ! echo "$response" | grep -q "$message"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
trap '-' SIGINT SIGTERM EXIT
|
||||
# NOTE: socat returns code 143 on SIGINT
|
||||
killprocess $server_pid || true
|
||||
|
Loading…
Reference in New Issue
Block a user