LCOV - code coverage report
Current view: top level - module/event/subsystems/iobuf - iobuf_rpc.c (source / functions) Hit Total Coverage
Test: ut_cov_unit.info Lines: 0 43 0.0 %
Date: 2024-11-20 03:11:48 Functions: 0 5 0.0 %

          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/thread.h"
       8             : #include "spdk/rpc.h"
       9             : #include "spdk/string.h"
      10             : #include "spdk_internal/init.h"
      11             : 
      12             : static const struct spdk_json_object_decoder rpc_iobuf_set_options_decoders[] = {
      13             :         {"small_pool_count", offsetof(struct spdk_iobuf_opts, small_pool_count), spdk_json_decode_uint64, true},
      14             :         {"large_pool_count", offsetof(struct spdk_iobuf_opts, large_pool_count), spdk_json_decode_uint64, true},
      15             :         {"small_bufsize", offsetof(struct spdk_iobuf_opts, small_bufsize), spdk_json_decode_uint32, true},
      16             :         {"large_bufsize", offsetof(struct spdk_iobuf_opts, large_bufsize), spdk_json_decode_uint32, true},
      17             :         {"enable_numa", offsetof(struct spdk_iobuf_opts, enable_numa), spdk_json_decode_bool, true},
      18             : };
      19             : 
      20             : static void
      21           0 : rpc_iobuf_set_options(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params)
      22             : {
      23             :         struct spdk_iobuf_opts opts;
      24             :         int rc;
      25             : 
      26           0 :         spdk_iobuf_get_opts(&opts, sizeof(opts));
      27           0 :         rc = spdk_json_decode_object(params, rpc_iobuf_set_options_decoders,
      28             :                                      SPDK_COUNTOF(rpc_iobuf_set_options_decoders), &opts);
      29           0 :         if (rc != 0) {
      30           0 :                 spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
      31             :                                                  "spdk_json_decode_object failed");
      32           0 :                 return;
      33             :         }
      34             : 
      35           0 :         rc = spdk_iobuf_set_opts(&opts);
      36           0 :         if (rc != 0) {
      37           0 :                 spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
      38           0 :                 return;
      39             :         }
      40             : 
      41           0 :         spdk_jsonrpc_send_bool_response(request, true);
      42           0 : }
      43           0 : SPDK_RPC_REGISTER("iobuf_set_options", rpc_iobuf_set_options, SPDK_RPC_STARTUP)
      44             : 
      45             : static void
      46           0 : rpc_iobuf_get_stats_done(struct spdk_iobuf_module_stats *modules, uint32_t num_modules,
      47             :                          void *cb_arg)
      48             : {
      49           0 :         struct spdk_jsonrpc_request *request = cb_arg;
      50             :         struct spdk_json_write_ctx *w;
      51             :         struct spdk_iobuf_module_stats *it;
      52             :         uint32_t i;
      53             : 
      54           0 :         w = spdk_jsonrpc_begin_result(request);
      55           0 :         spdk_json_write_array_begin(w);
      56             : 
      57           0 :         for (i = 0; i < num_modules; ++i) {
      58           0 :                 it = &modules[i];
      59             : 
      60           0 :                 spdk_json_write_object_begin(w);
      61           0 :                 spdk_json_write_named_string(w, "module", it->module);
      62             : 
      63           0 :                 spdk_json_write_named_object_begin(w, "small_pool");
      64           0 :                 spdk_json_write_named_uint64(w, "cache", it->small_pool.cache);
      65           0 :                 spdk_json_write_named_uint64(w, "main", it->small_pool.main);
      66           0 :                 spdk_json_write_named_uint64(w, "retry", it->small_pool.retry);
      67           0 :                 spdk_json_write_object_end(w);
      68             : 
      69           0 :                 spdk_json_write_named_object_begin(w, "large_pool");
      70           0 :                 spdk_json_write_named_uint64(w, "cache", it->large_pool.cache);
      71           0 :                 spdk_json_write_named_uint64(w, "main", it->large_pool.main);
      72           0 :                 spdk_json_write_named_uint64(w, "retry", it->large_pool.retry);
      73           0 :                 spdk_json_write_object_end(w);
      74             : 
      75           0 :                 spdk_json_write_object_end(w);
      76           0 :         }
      77             : 
      78           0 :         spdk_json_write_array_end(w);
      79           0 :         spdk_jsonrpc_end_result(request, w);
      80           0 : }
      81             : 
      82             : static void
      83           0 : rpc_iobuf_get_stats(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params)
      84             : {
      85             :         int rc;
      86             : 
      87           0 :         rc = spdk_iobuf_get_stats(rpc_iobuf_get_stats_done, request);
      88           0 :         if (rc != 0) {
      89           0 :                 spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
      90           0 :         }
      91           0 : }
      92           0 : SPDK_RPC_REGISTER("iobuf_get_stats", rpc_iobuf_get_stats, SPDK_RPC_RUNTIME)

Generated by: LCOV version 1.15