Commit 35429c9b authored by Evgeniy Kochetov's avatar Evgeniy Kochetov Committed by Tomasz Zawadzki
Browse files

sock: Save socket subsystem configuration in JSON format



Signed-off-by: default avatarEvgeniy Kochetov <evgeniik@mellanox.com>
Change-Id: I32c25e6410c418ffa00a76559aa7b6999e2269ba
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/617


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 140a7727
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
#include "spdk/stdinc.h"

#include "spdk/queue.h"
#include "spdk/json.h"

#ifdef __cplusplus
extern "C" {
@@ -450,6 +451,13 @@ int spdk_sock_impl_get_opts(const char *impl_name, struct spdk_sock_impl_opts *o
int spdk_sock_impl_set_opts(const char *impl_name, const struct spdk_sock_impl_opts *opts,
			    size_t len);

/**
 * Write socket subsystem configuration into provided JSON context.
 *
 * \param w JSON write context
 */
void spdk_sock_write_config_json(struct spdk_json_write_ctx *w);

#ifdef __cplusplus
}
#endif
+34 −0
Original line number Diff line number Diff line
@@ -751,6 +751,40 @@ spdk_sock_impl_set_opts(const char *impl_name, const struct spdk_sock_impl_opts
	return impl->set_opts(opts, len);
}

void
spdk_sock_write_config_json(struct spdk_json_write_ctx *w)
{
	struct spdk_net_impl *impl;
	struct spdk_sock_impl_opts opts;
	size_t len;

	assert(w != NULL);

	spdk_json_write_array_begin(w);

	STAILQ_FOREACH(impl, &g_net_impls, link) {
		if (!impl->get_opts) {
			continue;
		}

		len = sizeof(opts);
		if (impl->get_opts(&opts, &len) == 0) {
			spdk_json_write_object_begin(w);
			spdk_json_write_named_string(w, "method", "sock_impl_set_options");
			spdk_json_write_named_object_begin(w, "params");
			spdk_json_write_named_string(w, "impl_name", impl->name);
			spdk_json_write_named_uint32(w, "recv_buf_size", opts.recv_buf_size);
			spdk_json_write_named_uint32(w, "send_buf_size", opts.send_buf_size);
			spdk_json_write_object_end(w);
			spdk_json_write_object_end(w);
		} else {
			SPDK_ERRLOG("Failed to get socket options for socket implementation %s\n", impl->name);
		}
	}

	spdk_json_write_array_end(w);
}

void
spdk_net_impl_register(struct spdk_net_impl *impl, int priority)
{
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
	spdk_sock_get_optimal_sock_group;
	spdk_sock_impl_get_opts;
	spdk_sock_impl_set_opts;
	spdk_sock_write_config_json;

	# public functions in spdk/net.h
	spdk_net_framework_register;
+1 −1
Original line number Diff line number Diff line
@@ -171,4 +171,4 @@ DEPDIRS-event_scsi := event scsi event_bdev

DEPDIRS-event_iscsi := event iscsi event_scsi event_sock
DEPDIRS-event_vhost := event vhost event_scsi
DEPDIRS-event_sock := event
DEPDIRS-event_sock := event sock
+7 −0
Original line number Diff line number Diff line
@@ -46,10 +46,17 @@ sock_subsystem_fini(void)
	spdk_subsystem_fini_next();
}

static void
sock_subsystem_write_config_json(struct spdk_json_write_ctx *w)
{
	spdk_sock_write_config_json(w);
}

static struct spdk_subsystem g_spdk_subsystem_sock = {
	.name = "sock",
	.init = sock_subsystem_init,
	.fini = sock_subsystem_fini,
	.write_config_json = sock_subsystem_write_config_json,
};

SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_sock);
Loading