28 #include "spdk/util.h"
53 struct doca_devinfo **dev_list;
56 uint8_t is_hotplug_manager;
58 struct spdk_json_write_ctx *w;
62 spdk_jsonrpc_send_error_response(request,
63 SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
64 "doca_devinfo_create_list failed\n");
68 w = spdk_jsonrpc_begin_result(request);
69 spdk_json_write_array_begin(w);
70 for (uint32_t idx = 0; idx < nb_devs; idx++) {
75 spdk_json_write_object_begin(w);
76 spdk_json_write_named_string(w,
"name", name);
77 spdk_json_write_object_end(w);
79 SPDK_ERRLOG(
"failed to get ibdev name %d\n", ret);
82 spdk_json_write_array_end(w);
84 spdk_jsonrpc_end_result(request, w);
115 struct doca_dev_rep *dev_rep;
117 struct spdk_json_write_ctx *w;
118 struct doca_devemu_pci_type *pci_type = {0};
119 struct doca_dev *dev = {0};
122 if (params ==
NULL || spdk_json_decode_object(params,
126 spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"Invalid parameters");
132 spdk_jsonrpc_send_error_response(request,
133 SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
134 "Couldn't find supported devices");
140 spdk_jsonrpc_send_error_response(request,
141 SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
142 "Couldn't create the device representor\n");
143 goto destroy_pci_resources;
148 spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
"Couldnt get device VUID");
149 goto destroy_dev_rep;
154 spdk_jsonrpc_send_error_response(request,
155 SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
156 "Unable to cloes the device");
157 goto destroy_dev_rep;
160 w = spdk_jsonrpc_begin_result(request);
162 spdk_json_write_object_begin(w);
163 spdk_json_write_named_string(w,
"Created a function with vuid", buf);
164 spdk_json_write_object_end(w);
166 spdk_jsonrpc_end_result(request, w);
168 goto destroy_pci_resources;
172 destroy_pci_resources:
209 struct doca_devinfo_rep **devinfo_rep_list;
210 uint32_t nb_devs_reps;
211 struct doca_dev_rep *dev_rep;
214 struct doca_devemu_pci_type *pci_type = {0};
215 struct doca_dev *dev = {0};
217 if (params ==
NULL || spdk_json_decode_object(params,
221 spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"Invalid parameters");
227 spdk_jsonrpc_send_error_response(request,
228 SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
229 "Couldn't find supported devices");
235 spdk_jsonrpc_send_error_response(request,
236 SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
237 "Couldn't create the device representors list\n");
242 for (uint32_t i = 0; i < nb_devs_reps; i++) {
247 spdk_jsonrpc_send_error_response(request,
248 SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
249 "Couldn't open the device representor");
255 spdk_jsonrpc_send_error_response(request,
256 SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
257 "Couldn't destroy device representor");
263 spdk_jsonrpc_send_bool_response(request,
true);
270 spdk_jsonrpc_send_error_response(request,
271 SPDK_JSONRPC_ERROR_INVALID_PARAMS,
272 "device representor with requested vuid doesn't exist");
306 struct doca_devinfo_rep **devinfo_rep_list;
307 struct spdk_json_write_ctx *w;
308 uint32_t nb_devs_reps;
309 struct doca_devemu_pci_type *pci_type = {0};
310 struct doca_dev *dev = {0};
314 if (params ==
NULL || spdk_json_decode_object(params,
318 spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"Invalid parameters");
324 spdk_jsonrpc_send_error_response(request,
325 SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
326 "Couldn't find supported devices");
332 spdk_jsonrpc_send_error_response(request,
333 SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
334 "Couldn't create the device representors list\n");
339 w = spdk_jsonrpc_begin_result(request);
340 spdk_json_write_array_begin(w);
342 for (uint32_t i = 0; i < nb_devs_reps; i++) {
345 spdk_json_write_object_begin(w);
349 spdk_jsonrpc_send_error_response(request,
350 SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
351 "Couldnt get device VUID");
358 spdk_jsonrpc_send_error_response(request,
359 SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
360 "Couldnt get PCI address");
366 spdk_json_write_named_string(w,
"Function VUID: ", buf);
367 spdk_json_write_named_string(w,
"PCI Address: ", rep_pci);
368 spdk_json_write_object_end(w);
371 spdk_json_write_array_end(w);
374 spdk_jsonrpc_end_result(request, w);
static void cleanup(struct cache_invalidate_sample_state *state)
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_create_rep_list(struct doca_devemu_pci_type *pci_type, struct doca_devinfo_rep ***dev_list_rep, uint32_t *nb_devs_rep)
Create list of available representor devices for a given DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_dev_create_rep(const struct doca_devemu_pci_type *pci_type, struct doca_dev_rep **dev_rep)
Create a new representor device for a given DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_dev_destroy_rep(struct doca_dev_rep *rep_dev)
Destroy a representor device created by doca_devemu_pci_dev_create_rep().
DOCA_STABLE doca_error_t doca_dev_rep_open(struct doca_devinfo_rep *devinfo, struct doca_dev_rep **dev_rep)
Initialize representor device for use.
DOCA_STABLE doca_error_t doca_devinfo_cap_is_hotplug_manager_supported(const struct doca_devinfo *devinfo, uint8_t *is_hotplug_manager)
Get the hotplug manager capability of a DOCA devinfo.
DOCA_STABLE doca_error_t doca_devinfo_rep_destroy_list(struct doca_devinfo_rep **dev_list_rep)
Destroy list of representor device info structures.
DOCA_STABLE doca_error_t doca_devinfo_create_list(struct doca_devinfo ***dev_list, uint32_t *nb_devs)
Creates list of all available local devices.
#define DOCA_DEVINFO_REP_PCI_ADDR_SIZE
Buffer size to hold PCI BDF format: "XXXX:XX:XX.X". Including a null terminator.
DOCA_STABLE doca_error_t doca_dev_rep_close(struct doca_dev_rep *dev)
Destroy allocated representor device instance.
DOCA_STABLE doca_error_t doca_devinfo_rep_get_vuid(const struct doca_devinfo_rep *devinfo_rep, char *rep_vuid, uint32_t size)
Get the Vendor Unique ID of a representor DOCA devinfo.
DOCA_STABLE doca_error_t doca_devinfo_rep_get_pci_addr_str(const struct doca_devinfo_rep *devinfo_rep, char *pci_addr_str)
Get the PCI address of a DOCA devinfo_rep.
DOCA_STABLE doca_error_t doca_devinfo_get_ibdev_name(const struct doca_devinfo *devinfo, char *ibdev_name, uint32_t size)
Get the name of the IB device represented by a DOCA devinfo.
#define DOCA_DEVINFO_IBDEV_NAME_SIZE
Buffer size to hold Infiniband/RoCE device name. Including a null terminator.
#define DOCA_DEVINFO_REP_VUID_SIZE
Buffer size to hold VUID. Including a null terminator.
DOCA_STABLE doca_error_t doca_devinfo_destroy_list(struct doca_devinfo **dev_list)
Destroy list of local device info structures.
DOCA_STABLE struct doca_devinfo_rep * doca_dev_rep_as_devinfo(struct doca_dev_rep *dev_rep)
Get representor device info from device. This should be useful when wanting to query information abou...
enum doca_error doca_error_t
DOCA API return codes.
void cleanup_pci_resources(struct doca_devemu_pci_type *pci_type, struct doca_dev *dev)
doca_error_t create_find_start_pci_type(char *dev_name, struct doca_devemu_pci_type **pci_type, struct doca_dev **dev)
static void rpc_nvmf_doca_get_managers(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params)
static void free_rpc_nvmf_doca_create_function(struct nvmf_doca_create_function_in *in)
static void rpc_nvmf_doca_destroy_function(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params)
static void rpc_nvmf_doca_list_functions(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params)
static const struct spdk_json_object_decoder nvmf_doca_destroy_function_decoder[]
static void free_rpc_nvmf_doca_destroy_function(struct nvmf_doca_destroy_function_in *in)
static const struct spdk_json_object_decoder nvmf_doca_create_function_decoder[]
static void free_rpc_nvmf_doca_list_functions(struct nvmf_doca_list_functions_in *in)
static const struct spdk_json_object_decoder nvmf_doca_list_functions_decoder[]
SPDK_RPC_REGISTER("nvmf_doca_get_managers", rpc_nvmf_doca_get_managers, SPDK_RPC_RUNTIME)
static void rpc_nvmf_doca_create_function(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params)