Commit f0d8396e authored by Alexey Marchuk's avatar Alexey Marchuk Committed by Tomasz Zawadzki
Browse files

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: default avatarAlexey Marchuk <alexeymar@mellanox.com>
Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4210


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent a910bc64
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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;
};

/**
+9 −0
Original line number Diff line number Diff line
@@ -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 *
+1 −1
Original line number Diff line number Diff line
@@ -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;