]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/module/accel/idxd/accel_engine_idxd_rpc.c
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / module / accel / idxd / accel_engine_idxd_rpc.c
CommitLineData
7c673cae
FG
1/*-
2 * BSD LICENSE
3 *
4 * Copyright (c) Intel Corporation.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
f67539c2 34#include "accel_engine_idxd.h"
11fdf7f2 35
f67539c2
TL
36#include "spdk/rpc.h"
37#include "spdk/util.h"
38#include "spdk/event.h"
39#include "spdk/stdinc.h"
40#include "spdk/env.h"
7c673cae 41
f67539c2
TL
42struct rpc_idxd_scan_accel_engine {
43 uint32_t config_number;
11fdf7f2
TL
44};
45
f67539c2
TL
46static const struct spdk_json_object_decoder rpc_idxd_scan_accel_engine_decoder[] = {
47 {"config_number", offsetof(struct rpc_idxd_scan_accel_engine, config_number), spdk_json_decode_uint32},
48};
11fdf7f2
TL
49
50static void
f67539c2
TL
51rpc_idxd_scan_accel_engine(struct spdk_jsonrpc_request *request,
52 const struct spdk_json_val *params)
7c673cae 53{
f67539c2
TL
54 struct rpc_idxd_scan_accel_engine req = {};
55 struct spdk_json_write_ctx *w;
11fdf7f2 56
f67539c2
TL
57 if (params != NULL) {
58 if (spdk_json_decode_object(params, rpc_idxd_scan_accel_engine_decoder,
59 SPDK_COUNTOF(rpc_idxd_scan_accel_engine_decoder),
60 &req)) {
61 SPDK_ERRLOG("spdk_json_decode_object() failed\n");
62 spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
63 "Invalid parameters");
64 return;
65 }
66 }
11fdf7f2 67
f67539c2
TL
68 SPDK_NOTICELOG("Enabling IDXD with config #%u\n", req.config_number);
69 accel_engine_idxd_enable_probe(req.config_number);
7c673cae 70
f67539c2
TL
71 w = spdk_jsonrpc_begin_result(request);
72 spdk_json_write_bool(w, true);
73 spdk_jsonrpc_end_result(request, w);
7c673cae 74}
f67539c2 75SPDK_RPC_REGISTER("idxd_scan_accel_engine", rpc_idxd_scan_accel_engine, SPDK_RPC_STARTUP)