sock: Save socket subsystem configuration in JSON format
Signed-off-by: Evgeniy Kochetov <evgeniik@mellanox.com> Change-Id: I32c25e6410c418ffa00a76559aa7b6999e2269ba Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/617 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
140a772746
commit
35429c9b5d
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -157,6 +157,10 @@ def clear_vmd_subsystem(args, vmd_config):
|
||||
pass
|
||||
|
||||
|
||||
def clear_sock_subsystem(args, sock_config):
|
||||
pass
|
||||
|
||||
|
||||
def call_test_cmd(func):
|
||||
def rpc_test_cmd(*args, **kwargs):
|
||||
try:
|
||||
|
@ -31,6 +31,7 @@ def filter_methods(do_remove_global_rpcs):
|
||||
'bdev_set_options',
|
||||
'bdev_nvme_set_options',
|
||||
'bdev_nvme_set_hotplug',
|
||||
'sock_impl_set_options',
|
||||
]
|
||||
|
||||
data = json.loads(sys.stdin.read())
|
||||
|
Loading…
Reference in New Issue
Block a user