LCOV - code coverage report
Current view: top level - spdk/module/accel/dpdk_compressdev - accel_dpdk_compressdev_rpc.c (source / functions) Hit Total Coverage
Test: Combined Lines: 9 16 56.2 %
Date: 2024-07-15 10:27:24 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 6 50.0 %

           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 "accel_dpdk_compressdev.h"
       7                 :            : #include "spdk/rpc.h"
       8                 :            : #include "spdk/util.h"
       9                 :            : #include "spdk/string.h"
      10                 :            : #include "spdk/log.h"
      11                 :            : 
      12                 :            : struct rpc_compressdev_scan_accel_module {
      13                 :            :         uint32_t pmd;
      14                 :            : };
      15                 :            : 
      16                 :            : static const struct spdk_json_object_decoder rpc_compressdev_scan_accel_module_decoder[] = {
      17                 :            :         {"pmd", offsetof(struct rpc_compressdev_scan_accel_module, pmd), spdk_json_decode_uint32},
      18                 :            : };
      19                 :            : 
      20                 :            : static void
      21                 :         12 : rpc_compressdev_scan_accel_module(struct spdk_jsonrpc_request *request,
      22                 :            :                                   const struct spdk_json_val *params)
      23                 :            : {
      24                 :            :         struct rpc_compressdev_scan_accel_module req;
      25                 :         12 :         int rc = 0;
      26                 :            : 
      27         [ -  + ]:         12 :         if (spdk_json_decode_object(params, rpc_compressdev_scan_accel_module_decoder,
      28                 :            :                                     SPDK_COUNTOF(rpc_compressdev_scan_accel_module_decoder),
      29                 :            :                                     &req)) {
      30                 :          0 :                 SPDK_ERRLOG("spdk_json_decode_object failed\n");
      31                 :          0 :                 spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_PARSE_ERROR,
      32                 :            :                                                  "spdk_json_decode_object failed");
      33                 :          0 :                 return;
      34                 :            :         }
      35                 :            : 
      36         [ -  + ]:         12 :         if (req.pmd >= COMPRESS_PMD_MAX) {
      37                 :          0 :                 spdk_jsonrpc_send_error_response_fmt(request, -EINVAL,
      38                 :            :                                                      "PMD value %d should be less than %d", req.pmd, COMPRESS_PMD_MAX);
      39                 :          0 :                 return;
      40                 :            :         }
      41                 :            : 
      42                 :         12 :         rc = accel_compressdev_enable_probe(&req.pmd);
      43         [ -  + ]:         12 :         if (rc) {
      44                 :          0 :                 spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
      45                 :          0 :                 return;
      46                 :            :         }
      47                 :            : 
      48                 :         12 :         accel_dpdk_compressdev_enable();
      49                 :         12 :         spdk_jsonrpc_send_bool_response(request, true);
      50                 :            : }
      51                 :        190 : SPDK_RPC_REGISTER("compressdev_scan_accel_module", rpc_compressdev_scan_accel_module,
      52                 :            :                   SPDK_RPC_STARTUP)

Generated by: LCOV version 1.14