Line data Source code
1 : /* SPDX-License-Identifier: BSD-3-Clause 2 : * Copyright (C) 2022 Intel Corporation. 3 : * All rights reserved. 4 : */ 5 : 6 : #include "spdk/stdinc.h" 7 : #include "spdk/bdev.h" 8 : #include "spdk/log.h" 9 : #include "spdk/thread.h" 10 : #include "spdk_internal/init.h" 11 : 12 : static void 13 0 : iobuf_subsystem_initialize(void) 14 : { 15 : int rc; 16 : 17 0 : rc = spdk_iobuf_initialize(); 18 0 : if (rc != 0) { 19 0 : SPDK_ERRLOG("Failed to initialize iobuf\n"); 20 : } 21 : 22 0 : spdk_subsystem_init_next(rc); 23 0 : } 24 : 25 : static void 26 0 : iobuf_finish_cb(void *ctx) 27 : { 28 0 : spdk_subsystem_fini_next(); 29 0 : } 30 : 31 : static void 32 0 : iobuf_subsystem_finish(void) 33 : { 34 0 : spdk_iobuf_finish(iobuf_finish_cb, NULL); 35 0 : } 36 : 37 : static void 38 0 : iobuf_write_config_json(struct spdk_json_write_ctx *w) 39 : { 40 0 : struct spdk_iobuf_opts opts; 41 : 42 0 : spdk_iobuf_get_opts(&opts, sizeof(opts)); 43 : 44 0 : spdk_json_write_array_begin(w); 45 : 46 0 : spdk_json_write_object_begin(w); 47 0 : spdk_json_write_named_string(w, "method", "iobuf_set_options"); 48 : 49 0 : spdk_json_write_named_object_begin(w, "params"); 50 0 : spdk_json_write_named_uint64(w, "small_pool_count", opts.small_pool_count); 51 0 : spdk_json_write_named_uint64(w, "large_pool_count", opts.large_pool_count); 52 0 : spdk_json_write_named_uint32(w, "small_bufsize", opts.small_bufsize); 53 0 : spdk_json_write_named_uint32(w, "large_bufsize", opts.large_bufsize); 54 0 : spdk_json_write_named_bool(w, "enable_numa", opts.enable_numa); 55 0 : spdk_json_write_object_end(w); 56 0 : spdk_json_write_object_end(w); 57 : 58 0 : spdk_json_write_array_end(w); 59 0 : } 60 : 61 : static struct spdk_subsystem g_subsystem_iobuf = { 62 : .name = "iobuf", 63 : .init = iobuf_subsystem_initialize, 64 : .fini = iobuf_subsystem_finish, 65 : .write_config_json = iobuf_write_config_json, 66 : }; 67 : 68 0 : SPDK_SUBSYSTEM_REGISTER(g_subsystem_iobuf);