xref: /spdk/module/accel/dsa/accel_dsa_rpc.c (revision a6dbe3721eb3b5990707fc3e378c95e505dd8ab5)
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 
14 struct rpc_dsa_scan_accel_module {
15 	bool config_kernel_mode;
16 };
17 
18 static const struct spdk_json_object_decoder rpc_dsa_scan_accel_module_decoder[] = {
19 	{"config_kernel_mode", offsetof(struct rpc_dsa_scan_accel_module, config_kernel_mode), spdk_json_decode_bool, true},
20 };
21 
22 static void
23 rpc_dsa_scan_accel_module(struct spdk_jsonrpc_request *request,
24 			  const struct spdk_json_val *params)
25 {
26 	struct rpc_dsa_scan_accel_module req = {};
27 
28 	if (params != NULL) {
29 		if (spdk_json_decode_object(params, rpc_dsa_scan_accel_module_decoder,
30 					    SPDK_COUNTOF(rpc_dsa_scan_accel_module_decoder),
31 					    &req)) {
32 			SPDK_ERRLOG("spdk_json_decode_object() failed\n");
33 			spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
34 							 "Invalid parameters");
35 			return;
36 		}
37 	}
38 
39 	if (req.config_kernel_mode) {
40 		SPDK_NOTICELOG("Enabling DSA kernel-mode\n");
41 	} else {
42 		SPDK_NOTICELOG("Enabling DSA user-mode\n");
43 	}
44 
45 	accel_dsa_enable_probe(req.config_kernel_mode);
46 	spdk_jsonrpc_send_bool_response(request, true);
47 }
48 SPDK_RPC_REGISTER("dsa_scan_accel_module", rpc_dsa_scan_accel_module, SPDK_RPC_STARTUP)
49 SPDK_RPC_REGISTER_ALIAS_DEPRECATED(dsa_scan_accel_module, dsa_scan_accel_engine)
50