NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
devemu_pci_common.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024 NVIDIA CORPORATION AND AFFILIATES. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification, are permitted
5  * provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright notice, this list of
9  * conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21  * STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  */
25 
26 #include "devemu_pci_common.h"
27 
28 #include <doca_dev.h>
29 
30 DOCA_LOG_REGISTER(DEVEMU_PCI_COMMON);
31 
32 doca_error_t parse_pci_address(const char *addr, char *parsed_addr)
33 {
34  int addr_len = strnlen(addr, DOCA_DEVINFO_PCI_ADDR_SIZE) + 1;
35 
36  /* Check using > to make static code analysis satisfied */
37  if (addr_len > DOCA_DEVINFO_PCI_ADDR_SIZE) {
38  DOCA_LOG_ERR("Entered device PCI address exceeding the maximum size of %d",
41  }
42 
43  if (addr_len != DOCA_DEVINFO_PCI_ADDR_SIZE && addr_len != DOCA_DEVINFO_PCI_BDF_SIZE) {
44  DOCA_LOG_ERR("Entered device PCI address does not match supported formats: XXXX:XX:XX.X or XX:XX.X");
46  }
47 
48  /* The string will be '\0' terminated due to the strnlen check above */
49  strncpy(parsed_addr, addr, addr_len);
50 
51  return DOCA_SUCCESS;
52 }
53 
55 {
56  struct doca_argp_param *param;
58 
59  /* Create and register PCI address param */
61  if (result != DOCA_SUCCESS) {
62  DOCA_LOG_ERR("Failed to create ARGP param: %s", doca_error_get_descr(result));
63  return result;
64  }
66  doca_argp_param_set_long_name(param, "pci-addr");
67  doca_argp_param_set_description(param, "The DOCA device PCI address. Format: XXXX:XX:XX.X or XX:XX.X");
71  if (result != DOCA_SUCCESS) {
72  DOCA_LOG_ERR("Failed to register program param: %s", doca_error_get_descr(result));
73  return result;
74  }
75 
76  return DOCA_SUCCESS;
77 }
78 
79 doca_error_t parse_vuid(const char *vuid, char *parsed_vuid)
80 {
81  int vuid_len = strnlen(vuid, DOCA_DEVINFO_REP_VUID_SIZE) + 1;
82 
83  /* Check using > to make static code analysis satisfied */
84  if (vuid_len > DOCA_DEVINFO_REP_VUID_SIZE) {
85  DOCA_LOG_ERR("Entered device VUID exceeding the maximum size of %d", DOCA_DEVINFO_REP_VUID_SIZE - 1);
87  }
88 
89  /* The string will be '\0' terminated due to the strnlen check above */
90  strncpy(parsed_vuid, vuid, vuid_len);
91 
92  return DOCA_SUCCESS;
93 }
94 
96 {
97  struct doca_argp_param *param;
99 
100  /* Create and register VUID param */
101  result = doca_argp_param_create(&param);
102  if (result != DOCA_SUCCESS) {
103  DOCA_LOG_ERR("Failed to create ARGP param: %s", doca_error_get_descr(result));
104  return result;
105  }
106  doca_argp_param_set_short_name(param, "u");
107  doca_argp_param_set_long_name(param, "vuid");
112  if (result != DOCA_SUCCESS) {
113  DOCA_LOG_ERR("Failed to register program param: %s", doca_error_get_descr(result));
114  return result;
115  }
116 
117  return DOCA_SUCCESS;
118 }
119 
120 doca_error_t find_supported_device(const char *pci_address,
121  const struct doca_devemu_pci_type *pci_type,
122  emulation_supported_cb_t has_support,
123  struct doca_dev **dev)
124 {
125  struct doca_devinfo **dev_list;
126  uint32_t nb_devs;
127  doca_error_t res;
128  size_t i;
129  uint8_t is_supported;
130  uint8_t is_equal;
131 
132  /* Set default return value */
133  *dev = NULL;
134 
135  res = doca_devinfo_create_list(&dev_list, &nb_devs);
136  if (res != DOCA_SUCCESS) {
137  DOCA_LOG_ERR("Failed to load doca devices list: %s", doca_error_get_descr(res));
138  return res;
139  }
140 
141  /* Search */
142  for (i = 0; i < nb_devs; i++) {
143  if (doca_devinfo_is_equal_pci_addr(dev_list[i], pci_address, &is_equal) != DOCA_SUCCESS ||
144  is_equal == 0)
145  continue;
146 
147  res = has_support(dev_list[i], pci_type, &is_supported);
148  if (res != DOCA_SUCCESS)
149  continue;
150 
151  if (is_supported == 0) {
153  "Found device with matching address, but does not have hotplug support. Make sure a physical function was provided, and running with root permission");
154  continue;
155  }
156 
157  res = doca_dev_open(dev_list[i], dev);
158  if (res == DOCA_SUCCESS) {
159  doca_devinfo_destroy_list(dev_list);
160  return res;
161  }
162  }
163 
164  DOCA_LOG_WARN("Matching device not found");
165 
166  doca_devinfo_destroy_list(dev_list);
167  return DOCA_ERROR_NOT_FOUND;
168 }
169 
170 doca_error_t find_emulated_device(struct doca_devemu_pci_type *pci_type, const char *vuid, struct doca_dev_rep **rep)
171 {
172  struct doca_devinfo_rep **rep_list;
173  uint32_t nb_devs;
174  uint32_t dev_idx;
175  char actual_vuid[DOCA_DEVINFO_REP_VUID_SIZE];
176  doca_error_t res;
177 
178  res = doca_devemu_pci_type_create_rep_list(pci_type, &rep_list, &nb_devs);
179  if (res != DOCA_SUCCESS) {
180  DOCA_LOG_ERR("Unable to create list of emulated devices: %s", doca_error_get_descr(res));
181  return res;
182  }
183 
184  /* Search */
185  for (dev_idx = 0; dev_idx < nb_devs; ++dev_idx) {
186  res = doca_devinfo_rep_get_vuid(rep_list[dev_idx], actual_vuid, DOCA_DEVINFO_REP_VUID_SIZE);
187  if (res != DOCA_SUCCESS || strncmp(actual_vuid, vuid, DOCA_DEVINFO_REP_VUID_SIZE) != 0)
188  continue;
189 
190  res = doca_dev_rep_open(rep_list[dev_idx], rep);
191  if (res == DOCA_SUCCESS) {
193  return res;
194  }
195  }
196 
197  DOCA_LOG_ERR("Matching emulated device not found");
198 
200  return DOCA_ERROR_NOT_FOUND;
201 }
202 
203 /*
204  * Sets the PCI configurations of the type
205  * Once device is hotplugged the configurations will be visible to the Host as part of the
206  * PCI configuration space of that device
207  *
208  * @pci_type [in]: The emulated PCI type
209  * @dev [in]: The device that manages the PCI type
210  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
211  */
212 static doca_error_t set_pci_type_configurations(struct doca_devemu_pci_type *pci_type, struct doca_dev *dev)
213 {
214  const struct bar_memory_layout_config *layout_config;
215  const struct bar_db_region_config *db_config;
216  const struct bar_region_config *region_config;
217  int idx;
218  doca_error_t res;
219 
220  res = doca_devemu_pci_type_set_dev(pci_type, dev);
221  if (res != DOCA_SUCCESS) {
222  DOCA_LOG_ERR("Unable to set device for PCI type: %s", doca_error_get_descr(res));
223  return res;
224  }
225 
227  if (res != DOCA_SUCCESS) {
228  DOCA_LOG_ERR("Unable to set device ID for PCI type: %s", doca_error_get_descr(res));
229  return res;
230  }
231 
233  if (res != DOCA_SUCCESS) {
234  DOCA_LOG_ERR("Unable to set vendor ID for PCI type: %s", doca_error_get_descr(res));
235  return res;
236  }
237 
239  if (res != DOCA_SUCCESS) {
240  DOCA_LOG_ERR("Unable to set subsystem ID for PCI type: %s", doca_error_get_descr(res));
241  return res;
242  }
243 
245  if (res != DOCA_SUCCESS) {
246  DOCA_LOG_ERR("Unable to set subsystem vendor ID for PCI type: %s", doca_error_get_descr(res));
247  return res;
248  }
249 
251  if (res != DOCA_SUCCESS) {
252  DOCA_LOG_ERR("Unable to set revision ID for PCI type: %s", doca_error_get_descr(res));
253  return res;
254  }
255 
257  if (res != DOCA_SUCCESS) {
258  DOCA_LOG_ERR("Unable to set class code for PCI type: %s", doca_error_get_descr(res));
259  return res;
260  }
261 
263  if (res != DOCA_SUCCESS) {
264  DOCA_LOG_ERR("Unable to set number of MSI-X for PCI type: %s", doca_error_get_descr(res));
265  return res;
266  }
267 
268  for (idx = 0; idx < PCI_TYPE_NUM_BAR_MEMORY_LAYOUT; ++idx) {
269  layout_config = &layout_configs[idx];
271  layout_config->bar_id,
272  layout_config->log_size,
273  layout_config->memory_type,
274  layout_config->prefetchable);
275  if (res != DOCA_SUCCESS) {
276  DOCA_LOG_ERR("Unable to set layout at index %d: %s", idx, doca_error_get_descr(res));
277  return res;
278  }
279  }
280 
281  for (idx = 0; idx < PCI_TYPE_NUM_BAR_DB_REGIONS; ++idx) {
282  db_config = &db_configs[idx];
283  if (db_config->with_data)
285  db_config->region.bar_id,
286  db_config->region.start_address,
287  db_config->region.size,
288  db_config->log_db_size,
289  db_config->db_id_msbyte,
290  db_config->db_id_lsbyte);
291  else
293  db_config->region.bar_id,
294  db_config->region.start_address,
295  db_config->region.size,
296  db_config->log_db_size,
297  db_config->log_db_stride_size);
298  if (res != DOCA_SUCCESS) {
299  DOCA_LOG_ERR("Unable to set DB region at index %d: %s", idx, doca_error_get_descr(res));
300  return res;
301  }
302  }
303 
304  for (idx = 0; idx < PCI_TYPE_NUM_BAR_MSIX_TABLE_REGIONS; ++idx) {
305  region_config = &msix_table_configs[idx];
307  region_config->bar_id,
308  region_config->start_address,
309  region_config->size);
310  if (res != DOCA_SUCCESS) {
311  DOCA_LOG_ERR("Unable to set MSI-X table region at index %d: %s",
312  idx,
313  doca_error_get_descr(res));
314  return res;
315  }
316  }
317 
318  for (idx = 0; idx < PCI_TYPE_NUM_BAR_MSIX_PBA_REGIONS; ++idx) {
319  region_config = &msix_pba_configs[idx];
321  region_config->bar_id,
322  region_config->start_address,
323  region_config->size);
324  if (res != DOCA_SUCCESS) {
325  DOCA_LOG_ERR("Unable to set MSI-X pending bit array region at index %d: %s",
326  idx,
327  doca_error_get_descr(res));
328  return res;
329  }
330  }
331 
332  for (idx = 0; idx < PCI_TYPE_NUM_BAR_STATEFUL_REGIONS; ++idx) {
333  region_config = &stateful_configs[idx];
335  region_config->bar_id,
336  region_config->start_address,
337  region_config->size);
338  if (res != DOCA_SUCCESS) {
339  DOCA_LOG_ERR("Unable to set Stateful region at index %d: %s", idx, doca_error_get_descr(res));
340  return res;
341  }
342  }
343 
344  return DOCA_SUCCESS;
345 }
346 
347 doca_error_t configure_and_start_pci_type(struct doca_devemu_pci_type *pci_type, struct doca_dev *dev)
348 {
350 
351  result = set_pci_type_configurations(pci_type, dev);
352  if (result != DOCA_SUCCESS)
353  return result;
354 
356  if (result != DOCA_SUCCESS) {
357  DOCA_LOG_ERR("Unable to start PCI type: %s", doca_error_get_descr(result));
358  return result;
359  }
360 
361  return DOCA_SUCCESS;
362 }
363 
364 void devemu_resources_cleanup(struct devemu_resources *resources, bool destroy_rep)
365 {
366  doca_error_t res;
367 
368  if (resources->data_path.msix != NULL) {
369  res = doca_devemu_pci_msix_destroy(resources->data_path.msix);
370  if (res != DOCA_SUCCESS)
371  DOCA_LOG_ERR("Failed to destroy DOCA Device Emulation MSI-X object: %s",
372  doca_error_get_descr(res));
373 
374  resources->data_path.msix = NULL;
375  }
376 
377  if (resources->data_path.db != NULL) {
378  res = doca_devemu_pci_db_stop(resources->data_path.db);
379  if (res != DOCA_SUCCESS)
380  DOCA_LOG_ERR("Failed to stop DOCA Device Emulation DB object: %s", doca_error_get_descr(res));
381  res = doca_devemu_pci_db_destroy(resources->data_path.db);
382  if (res != DOCA_SUCCESS)
383  DOCA_LOG_ERR("Failed to destroy DOCA Device Emulation DB object: %s",
384  doca_error_get_descr(res));
385 
386  resources->data_path.db = NULL;
387  }
388 
389  if (resources->db_comp != NULL) {
391  if (res != DOCA_SUCCESS)
392  DOCA_LOG_ERR("Failed to stop DOCA Device Emulation DB completion context: %s",
393  doca_error_get_descr(res));
395  if (res != DOCA_SUCCESS)
396  DOCA_LOG_ERR("Failed to destroy DOCA Device Emulation DB completion context: %s",
397  doca_error_get_descr(res));
398 
399  resources->db_comp = NULL;
400  }
401 
402  if (resources->dpa_thread) {
403  res = doca_dpa_thread_destroy(resources->dpa_thread);
404  if (res != DOCA_SUCCESS)
405  DOCA_LOG_ERR("Failed to destroy DOCA DPA thread: %s", doca_error_get_descr(res));
406 
407  resources->dpa_thread = NULL;
408  }
409 
410  if (resources->ctx != NULL) {
411  res = doca_ctx_stop(resources->ctx);
412  if (res != DOCA_SUCCESS)
413  DOCA_LOG_ERR("Failed to stop DOCA Emulated Device context: %s", doca_error_get_descr(res));
414 
415  resources->ctx = NULL;
416  }
417 
418  if (resources->stateful_region_values != NULL)
419  free(resources->stateful_region_values);
420 
421  if (resources->pci_dev != NULL) {
422  res = doca_devemu_pci_dev_destroy(resources->pci_dev);
423  if (res != DOCA_SUCCESS)
424  DOCA_LOG_ERR("Failed to destroy DOCA Emulated Device context: %s", doca_error_get_descr(res));
425 
426  resources->pci_dev = NULL;
427  }
428 
429  if (resources->rep != NULL) {
430  res = destroy_rep ? doca_devemu_pci_dev_destroy_rep(resources->rep) :
432  if (res != DOCA_SUCCESS)
433  DOCA_LOG_ERR("Failed to close DOCA Emulated Device representor: %s", doca_error_get_descr(res));
434 
435  resources->rep = NULL;
436  }
437 
438  if (resources->dpa != NULL) {
439  res = doca_dpa_destroy(resources->dpa);
440  if (res != DOCA_SUCCESS)
441  DOCA_LOG_ERR("Failed to destroy DOCA DPA: %s", doca_error_get_descr(res));
442 
443  resources->dpa = NULL;
444  }
445 
446  if (resources->pci_type != NULL) {
447  res = doca_devemu_pci_type_stop(resources->pci_type);
448  if (res != DOCA_SUCCESS)
449  DOCA_LOG_ERR("Failed to stop DOCA Emulated PCI Type: %s", doca_error_get_descr(res));
450  }
451 
452  if (resources->pci_type != NULL) {
453  res = doca_devemu_pci_type_destroy(resources->pci_type);
454  if (res != DOCA_SUCCESS)
455  DOCA_LOG_ERR("Failed to destroy DOCA Emulated PCI Type: %s", doca_error_get_descr(res));
456 
457  resources->pci_type = NULL;
458  }
459 
460  if (resources->pe != NULL) {
461  res = doca_pe_destroy(resources->pe);
462  if (res != DOCA_SUCCESS)
463  DOCA_LOG_ERR("Failed to destroy DOCA progress engine: %s", doca_error_get_descr(res));
464 
465  resources->pe = NULL;
466  }
467 
468  if (resources->dev != NULL) {
469  res = doca_dev_close(resources->dev);
470  if (res != DOCA_SUCCESS)
471  DOCA_LOG_ERR("Failed to close DOCA device: %s", doca_error_get_descr(res));
472 
473  resources->dev = NULL;
474  }
475 }
476 
478 {
479  switch (hotplug_state) {
481  return "DOCA_DEVEMU_PCI_HP_STATE_POWER_OFF";
483  return "DOCA_DEVEMU_PCI_HP_STATE_UNPLUG_IN_PROGRESS";
485  return "DOCA_DEVEMU_PCI_HP_STATE_PLUG_IN_PROGRESS";
487  return "DOCA_DEVEMU_PCI_HP_STATE_POWER_ON";
488  default:
489  return "UNKNOWN";
490  }
491 }
492 
493 doca_error_t init_dpa(struct devemu_resources *resources, struct doca_dpa_app *dpa_app)
494 {
495  doca_error_t ret = doca_dpa_create(resources->dev, &resources->dpa);
496  if (ret != DOCA_SUCCESS) {
497  DOCA_LOG_ERR("Failed to create DPA context");
498  return ret;
499  }
500 
501  ret = doca_dpa_set_app(resources->dpa, dpa_app);
502  if (ret != DOCA_SUCCESS) {
503  DOCA_LOG_ERR("Failed to set DPA app");
504  return ret;
505  }
506 
507  ret = doca_dpa_start(resources->dpa);
508  if (ret != DOCA_SUCCESS) {
509  DOCA_LOG_ERR("Failed to start DPA context");
510  return ret;
511  }
512 
513  return DOCA_SUCCESS;
514 }
#define NULL
Definition: __stddef_null.h:26
static doca_error_t vuid_callback(void *param, void *config)
int32_t result
doca_error_t configure_and_start_pci_type(struct doca_devemu_pci_type *pci_type, struct doca_dev *dev)
DOCA_LOG_REGISTER(DEVEMU_PCI_COMMON)
doca_error_t init_dpa(struct devemu_resources *resources, struct doca_dpa_app *dpa_app)
doca_error_t parse_pci_address(const char *addr, char *parsed_addr)
void devemu_resources_cleanup(struct devemu_resources *resources, bool destroy_rep)
const char * hotplug_state_to_string(enum doca_devemu_pci_hotplug_state hotplug_state)
doca_error_t register_vuid_param(const char *description, doca_argp_param_cb_t vuid_callback)
doca_error_t parse_vuid(const char *vuid, char *parsed_vuid)
static doca_error_t set_pci_type_configurations(struct doca_devemu_pci_type *pci_type, struct doca_dev *dev)
doca_error_t find_emulated_device(struct doca_devemu_pci_type *pci_type, const char *vuid, struct doca_dev_rep **rep)
doca_error_t register_pci_address_param(doca_argp_param_cb_t pci_callback)
doca_error_t find_supported_device(const char *pci_address, const struct doca_devemu_pci_type *pci_type, emulation_supported_cb_t has_support, struct doca_dev **dev)
static doca_error_t pci_callback(void *param, void *config)
uintptr_t addr
struct rdma_resources resources
DOCA_EXPERIMENTAL void doca_argp_param_set_description(struct doca_argp_param *param, const char *description)
Set the description of the program param, used during program usage.
DOCA_EXPERIMENTAL void doca_argp_param_set_long_name(struct doca_argp_param *param, const char *name)
Set the long name of the program param.
doca_error_t(* doca_argp_param_cb_t)(void *, void *)
Flag callback function type.
Definition: doca_argp.h:37
DOCA_EXPERIMENTAL void doca_argp_param_set_callback(struct doca_argp_param *param, doca_argp_param_cb_t callback)
Set the callback function of the program param.
DOCA_EXPERIMENTAL doca_error_t doca_argp_param_create(struct doca_argp_param **param)
Create new program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_type(struct doca_argp_param *param, enum doca_argp_type type)
Set the type of the param arguments.
DOCA_EXPERIMENTAL void doca_argp_param_set_short_name(struct doca_argp_param *param, const char *name)
Set the short name of the program param.
DOCA_EXPERIMENTAL doca_error_t doca_argp_register_param(struct doca_argp_param *input_param)
Register a program flag.
@ DOCA_ARGP_TYPE_STRING
Definition: doca_argp.h:56
DOCA_STABLE doca_error_t doca_ctx_stop(struct doca_ctx *ctx)
Stops the context allowing reconfiguration.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_bar_stateful_region_conf(struct doca_devemu_pci_type *pci_type, uint8_t id, uint64_t start_addr, uint64_t size)
Set a stateful BAR region configuration for a BAR layout in a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_start(struct doca_devemu_pci_type *pci_type)
Start a DOCA devemu PCI type.
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_type_set_memory_bar_conf(struct doca_devemu_pci_type *pci_type, uint8_t id, uint8_t log_sz, enum doca_devemu_pci_bar_mem_type memory_type, uint8_t prefetchable)
Set a memory BAR layout configuration for DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_stop(struct doca_devemu_pci_type *pci_type)
Stop a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_class_code(struct doca_devemu_pci_type *pci_type, uint32_t class_code)
Set the PCI Class Code of a DOCA devemu PCI type to identify generic operation.
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_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_revision_id(struct doca_devemu_pci_type *pci_type, uint8_t revision_id)
Set the PCI Revision ID of a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_device_id(struct doca_devemu_pci_type *pci_type, uint16_t device_id)
Set the PCI Device ID of a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_bar_db_region_by_offset_conf(struct doca_devemu_pci_type *pci_type, uint8_t id, uint64_t start_addr, uint64_t size, uint8_t log_db_size, uint8_t log_stride_size)
Set a doorbell BAR region configuration for a BAR layout in a DOCA devemu PCI type....
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_vendor_id(struct doca_devemu_pci_type *pci_type, uint16_t vendor_id)
Set the PCI Vendor ID of a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_bar_db_region_by_data_conf(struct doca_devemu_pci_type *pci_type, uint8_t id, uint64_t start_addr, uint64_t size, uint8_t log_db_size, uint16_t db_id_msbyte, uint16_t db_id_lsbyte)
Set a doorbell BAR region configuration for a BAR layout in a DOCA devemu PCI type....
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_num_msix(struct doca_devemu_pci_type *pci_type, uint16_t num_msix)
Set the size of the MSI-X Table from MSI-X Capability Registers (1 based) of a DOCA devemu PCI type....
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_subsystem_id(struct doca_devemu_pci_type *pci_type, uint16_t subsystem_id)
Set the PCI Subsystem ID of a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_destroy(struct doca_devemu_pci_type *pci_type)
Destroy a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_subsystem_vendor_id(struct doca_devemu_pci_type *pci_type, uint16_t subsystem_vid)
Set the PCI Subsystem Vendor ID of a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_bar_msix_pba_region_conf(struct doca_devemu_pci_type *pci_type, uint8_t id, uint64_t start_addr, uint64_t size)
Set a MSI-X PBA BAR region configuration for a BAR layout in a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_dev(struct doca_devemu_pci_type *pci_type, struct doca_dev *dev)
Set the DOCA device for a specific DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_bar_msix_table_region_conf(struct doca_devemu_pci_type *pci_type, uint8_t id, uint64_t start_addr, uint64_t size)
Set a MSI-X table BAR region configuration for a BAR layout in a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_completion_stop(struct doca_devemu_pci_db_completion *db_comp)
Stop DOCA devemu PCI device doorbell completion context.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_dev_destroy(struct doca_devemu_pci_dev *pci_dev)
Free a DOCA devemu PCI device.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_destroy(struct doca_devemu_pci_db *db)
Destroy the DOCA devemu PCI device doorbell.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_msix_destroy(struct doca_devemu_pci_msix *msix)
Destroy the DOCA devemu PCI device MSI-X.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_completion_destroy(struct doca_devemu_pci_db_completion *db_comp)
Destroy the DOCA devemu PCI device doorbell completion context.
doca_devemu_pci_hotplug_state
DOCA devemu pci hotplug state.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_stop(struct doca_devemu_pci_db *db)
Stop DOCA devemu PCI device doorbell. A stopped doorbell will not trigger completions on the associat...
@ DOCA_DEVEMU_PCI_HP_STATE_POWER_OFF
@ DOCA_DEVEMU_PCI_HP_STATE_UNPLUG_IN_PROGRESS
@ DOCA_DEVEMU_PCI_HP_STATE_PLUG_IN_PROGRESS
@ DOCA_DEVEMU_PCI_HP_STATE_POWER_ON
DOCA_STABLE doca_error_t doca_devinfo_is_equal_pci_addr(const struct doca_devinfo *devinfo, const char *pci_addr_str, uint8_t *is_equal)
Check if a PCI address belongs to a DOCA devinfo.
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_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.
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.
#define DOCA_DEVINFO_REP_VUID_SIZE
Buffer size to hold VUID. Including a null terminator.
Definition: doca_dev.h:661
#define DOCA_DEVINFO_PCI_BDF_SIZE
Buffer size to hold PCI BDF format: "XX:XX.X". Including a null terminator.
Definition: doca_dev.h:317
DOCA_STABLE doca_error_t doca_devinfo_destroy_list(struct doca_devinfo **dev_list)
Destroy list of local device info structures.
DOCA_STABLE doca_error_t doca_dev_open(struct doca_devinfo *devinfo, struct doca_dev **dev)
Initialize local device for use.
#define DOCA_DEVINFO_PCI_ADDR_SIZE
Buffer size to hold PCI BDF format: "XXXX:XX:XX.X". Including a null terminator.
Definition: doca_dev.h:313
DOCA_STABLE doca_error_t doca_dev_close(struct doca_dev *dev)
Destroy allocated local device instance.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_create(struct doca_dev *dev, struct doca_dpa **dpa)
Create a DOCA DPA Context.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_destroy(struct doca_dpa *dpa)
Destroy a DOCA DPA context.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_start(struct doca_dpa *dpa)
Start a DPA context.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_destroy(struct doca_dpa_thread *dpa_thread)
Destroy DPA thread.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_set_app(struct doca_dpa *dpa, struct doca_dpa_app *app)
Set program app for DPA context.
enum doca_error doca_error_t
DOCA API return codes.
DOCA_STABLE const char * doca_error_get_descr(doca_error_t error)
Returns the description string of an error code.
@ DOCA_ERROR_INVALID_VALUE
Definition: doca_error.h:44
@ DOCA_ERROR_NOT_FOUND
Definition: doca_error.h:54
@ DOCA_SUCCESS
Definition: doca_error.h:38
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
Definition: doca_log.h:466
#define DOCA_LOG_WARN(format,...)
Generates a WARNING application log message.
Definition: doca_log.h:476
DOCA_STABLE doca_error_t doca_pe_destroy(struct doca_pe *pe)
Destroy doca progress engine.
type description
doca_error_t(* emulation_supported_cb_t)(const struct doca_devinfo *, const struct doca_devemu_pci_type *pci_type, uint8_t *is_supported)
#define PCI_TYPE_NUM_BAR_MSIX_PBA_REGIONS
#define PCI_TYPE_SUBSYSTEM_VENDOR_ID
#define PCI_TYPE_NUM_BAR_MSIX_TABLE_REGIONS
static const struct bar_memory_layout_config layout_configs[PCI_TYPE_NUM_BAR_MEMORY_LAYOUT]
#define PCI_TYPE_NUM_BAR_MEMORY_LAYOUT
static const struct bar_db_region_config db_configs[PCI_TYPE_NUM_BAR_DB_REGIONS]
#define PCI_TYPE_SUBSYSTEM_ID
#define PCI_TYPE_VENDOR_ID
#define PCI_TYPE_DEVICE_ID
static const struct bar_region_config msix_pba_configs[PCI_TYPE_NUM_BAR_MSIX_PBA_REGIONS]
#define PCI_TYPE_NUM_BAR_DB_REGIONS
#define PCI_TYPE_NUM_BAR_STATEFUL_REGIONS
#define PCI_TYPE_REVISION_ID
static const struct bar_region_config msix_table_configs[PCI_TYPE_NUM_BAR_MSIX_TABLE_REGIONS]
#define PCI_TYPE_CLASS_CODE
static const struct bar_region_config stateful_configs[PCI_TYPE_NUM_BAR_STATEFUL_REGIONS]
#define PCI_TYPE_NUM_MSIX
struct bar_region_config region
enum doca_devemu_pci_bar_mem_type memory_type
struct doca_pe * pe
Definition: rdma_common.h:86