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_dsa.h" 7 : : 8 : : #include "spdk/rpc.h" 9 : : #include "spdk/util.h" 10 : : #include "spdk/event.h" 11 : : #include "spdk/stdinc.h" 12 : : #include "spdk/env.h" 13 : : #include "spdk/string.h" 14 : : 15 : : struct rpc_dsa_scan_accel_module { 16 : : bool config_kernel_mode; 17 : : }; 18 : : 19 : : static const struct spdk_json_object_decoder rpc_dsa_scan_accel_module_decoder[] = { 20 : : {"config_kernel_mode", offsetof(struct rpc_dsa_scan_accel_module, config_kernel_mode), spdk_json_decode_bool, true}, 21 : : }; 22 : : 23 : : static void 24 : 0 : rpc_dsa_scan_accel_module(struct spdk_jsonrpc_request *request, 25 : : const struct spdk_json_val *params) 26 : : { 27 : 0 : struct rpc_dsa_scan_accel_module req = {}; 28 : : int rc; 29 : : 30 [ # # ]: 0 : if (params != NULL) { 31 [ # # ]: 0 : if (spdk_json_decode_object(params, rpc_dsa_scan_accel_module_decoder, 32 : : SPDK_COUNTOF(rpc_dsa_scan_accel_module_decoder), 33 : : &req)) { 34 : 0 : SPDK_ERRLOG("spdk_json_decode_object() failed\n"); 35 : 0 : spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, 36 : : "Invalid parameters"); 37 : 0 : return; 38 : : } 39 : : } 40 : : 41 [ # # ]: 0 : rc = accel_dsa_enable_probe(req.config_kernel_mode); 42 [ # # ]: 0 : if (rc != 0) { 43 : 0 : spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc)); 44 : 0 : return; 45 : : } 46 : : 47 [ # # # # ]: 0 : if (req.config_kernel_mode) { 48 : 0 : SPDK_NOTICELOG("Enabled DSA kernel-mode\n"); 49 : : } else { 50 : 0 : SPDK_NOTICELOG("Enabled DSA user-mode\n"); 51 : : } 52 : : 53 : 0 : spdk_jsonrpc_send_bool_response(request, true); 54 : : } 55 : 3030 : SPDK_RPC_REGISTER("dsa_scan_accel_module", rpc_dsa_scan_accel_module, SPDK_RPC_STARTUP) 56 : 3030 : SPDK_RPC_REGISTER_ALIAS_DEPRECATED(dsa_scan_accel_module, dsa_scan_accel_engine)