Branch data 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 : 2681 : iobuf_subsystem_initialize(void) 14 : : { 15 : : int rc; 16 : : 17 : 2681 : rc = spdk_iobuf_initialize(); 18 [ - + ]: 2681 : if (rc != 0) { 19 : 0 : SPDK_ERRLOG("Failed to initialize iobuf\n"); 20 : : } 21 : : 22 : 2681 : spdk_subsystem_init_next(rc); 23 : 2681 : } 24 : : 25 : : static void 26 : 2681 : iobuf_finish_cb(void *ctx) 27 : : { 28 : 2681 : spdk_subsystem_fini_next(); 29 : 2681 : } 30 : : 31 : : static void 32 : 2681 : iobuf_subsystem_finish(void) 33 : : { 34 : 2681 : spdk_iobuf_finish(iobuf_finish_cb, NULL); 35 : 2681 : } 36 : : 37 : : static void 38 : 148 : iobuf_write_config_json(struct spdk_json_write_ctx *w) 39 : : { 40 : 148 : struct spdk_iobuf_opts opts; 41 : : 42 : 148 : spdk_iobuf_get_opts(&opts, sizeof(opts)); 43 : : 44 : 148 : spdk_json_write_array_begin(w); 45 : : 46 : 148 : spdk_json_write_object_begin(w); 47 : 148 : spdk_json_write_named_string(w, "method", "iobuf_set_options"); 48 : : 49 : 148 : spdk_json_write_named_object_begin(w, "params"); 50 : 148 : spdk_json_write_named_uint64(w, "small_pool_count", opts.small_pool_count); 51 : 148 : spdk_json_write_named_uint64(w, "large_pool_count", opts.large_pool_count); 52 : 148 : spdk_json_write_named_uint32(w, "small_bufsize", opts.small_bufsize); 53 : 148 : spdk_json_write_named_uint32(w, "large_bufsize", opts.large_bufsize); 54 : 148 : spdk_json_write_object_end(w); 55 : 148 : spdk_json_write_object_end(w); 56 : : 57 : 148 : spdk_json_write_array_end(w); 58 : 148 : } 59 : : 60 : : static struct spdk_subsystem g_subsystem_iobuf = { 61 : : .name = "iobuf", 62 : : .init = iobuf_subsystem_initialize, 63 : : .fini = iobuf_subsystem_finish, 64 : : .write_config_json = iobuf_write_config_json, 65 : : }; 66 : : 67 : 2863 : SPDK_SUBSYSTEM_REGISTER(g_subsystem_iobuf);