1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 */ 4 5 #include "spdk/rpc.h" 6 #include "spdk/util.h" 7 #include "spdk/log.h" 8 9 #include "accel_mlx5.h" 10 11 static const struct spdk_json_object_decoder rpc_mlx5_module_decoder[] = { 12 {"qp_size", offsetof(struct accel_mlx5_attr, qp_size), spdk_json_decode_uint16, true}, 13 {"num_requests", offsetof(struct accel_mlx5_attr, num_requests), spdk_json_decode_uint32, true}, 14 }; 15 16 static void 17 rpc_mlx5_scan_accel_module(struct spdk_jsonrpc_request *request, 18 const struct spdk_json_val *params) 19 { 20 struct accel_mlx5_attr attr; 21 int rc; 22 23 accel_mlx5_get_default_attr(&attr); 24 25 if (params != NULL) { 26 if (spdk_json_decode_object(params, rpc_mlx5_module_decoder, 27 SPDK_COUNTOF(rpc_mlx5_module_decoder), 28 &attr)) { 29 SPDK_ERRLOG("spdk_json_decode_object() failed\n"); 30 spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_PARSE_ERROR, 31 "spdk_json_decode_object failed"); 32 return; 33 } 34 } 35 36 rc = accel_mlx5_enable(&attr); 37 if (rc) { 38 spdk_jsonrpc_send_error_response_fmt(request, rc, "mlx5 scan failed with %d\n", rc); 39 } else { 40 spdk_jsonrpc_send_bool_response(request, true); 41 } 42 } 43 SPDK_RPC_REGISTER("mlx5_scan_accel_module", rpc_mlx5_scan_accel_module, SPDK_RPC_STARTUP) 44