sock: Add option to configure zero copy per socket

A preparation step for enabling zero copy in NVMEoF TCP initiator.
This option will be used to disable zero copy
for admin qpair. This is needed since the admin
qpair's socket is not connected to socket poll group
and we can't receive buffer reclaim notification.

Change-Id: Ibfbb8a156aafcd7ba8975a50f790da7fbd37d96f
Signed-off-by: Alexey Marchuk <alexeymar@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4210
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Alexey Marchuk 2020-09-01 12:06:03 +03:00 committed by Tomasz Zawadzki
parent a910bc647d
commit f0d8396e7a
3 changed files with 15 additions and 1 deletions

View File

@ -138,6 +138,11 @@ struct spdk_sock_opts {
* The priority on the socket and default value is zero.
*/
int priority;
/**
* Used to enable or disable zero copy on socket layer.
*/
bool zcopy;
};
/**

View File

@ -39,6 +39,7 @@
#include "spdk/queue.h"
#define SPDK_SOCK_DEFAULT_PRIORITY 0
#define SPDK_SOCK_DEFAULT_ZCOPY true
#define SPDK_SOCK_OPTS_FIELD_OK(opts, field) (offsetof(struct spdk_sock_opts, field) + sizeof(opts->field) <= (opts->opts_size))
static STAILQ_HEAD(, spdk_net_impl) g_net_impls = STAILQ_HEAD_INITIALIZER(g_net_impls);
@ -191,6 +192,10 @@ spdk_sock_get_default_opts(struct spdk_sock_opts *opts)
if (SPDK_SOCK_OPTS_FIELD_OK(opts, priority)) {
opts->priority = SPDK_SOCK_DEFAULT_PRIORITY;
}
if (SPDK_SOCK_OPTS_FIELD_OK(opts, zcopy)) {
opts->zcopy = SPDK_SOCK_DEFAULT_ZCOPY;
}
}
/*
@ -211,6 +216,10 @@ sock_init_opts(struct spdk_sock_opts *opts, struct spdk_sock_opts *opts_user)
if (SPDK_SOCK_OPTS_FIELD_OK(opts, priority)) {
opts->priority = opts_user->priority;
}
if (SPDK_SOCK_OPTS_FIELD_OK(opts, zcopy)) {
opts->zcopy = opts_user->zcopy;
}
}
struct spdk_sock *

View File

@ -556,7 +556,7 @@ retry:
if (type == SPDK_SOCK_CREATE_LISTEN) {
/* Only enable zero copy for non-loopback sockets. */
enable_zero_copy = !sock_is_loopback(fd);
enable_zero_copy = opts->zcopy && !sock_is_loopback(fd);
} else if (type == SPDK_SOCK_CREATE_CONNECT) {
/* Disable zero copy for client sockets until support is added */
enable_zero_copy = false;