NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
devemu_pci_device_db_dpu_sample.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 <signal.h>
27 #include <stdbool.h>
28 #include <stdint.h>
29 #include <string.h>
30 #include <time.h>
31 
32 #include <doca_ctx.h>
33 #include <doca_devemu_pci.h>
34 #include <doca_dev.h>
35 #include <doca_error.h>
36 #include <doca_log.h>
37 #include <doca_dpa.h>
38 
39 #include <common.h>
40 #include <devemu_pci_common.h>
41 
42 DOCA_LOG_REGISTER(DEVEMU_PCI_DEVICE_DB_DPU);
43 
44 /*
45  * A struct that includes all needed info on registered kernels and is initialized during linkage by DPACC.
46  * Variable name should be the token passed to DPACC with --app-name parameter.
47  */
48 extern struct doca_dpa_app *devemu_pci_sample_app;
49 
54 
63 
64 static bool force_quit; /* Shared variable to allow for a proper shutdown */
65 
66 /*
67  * Signal handler
68  *
69  * @signum [in]: Signal number to handle
70  */
71 static void signal_handler(int signum)
72 {
73  if (signum == SIGINT || signum == SIGTERM) {
74  DOCA_LOG_INFO("Signal %d received, preparing to exit", signum);
75  force_quit = true;
76  }
77 }
78 
79 /*
80  * Create a DPA thread that can be used to listen on DBs
81  *
82  * @resources [in]: The sample resources
83  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
84  */
86 {
87  doca_error_t ret = doca_dpa_thread_create(resources->dpa, &resources->dpa_thread);
88  if (ret != DOCA_SUCCESS) {
89  DOCA_LOG_ERR("Failed to create DPA thread: %s", doca_error_get_descr(ret));
90  return ret;
91  }
92 
93  ret = doca_dpa_thread_set_func_arg(resources->dpa_thread, db_handler, 0);
94  if (ret != DOCA_SUCCESS) {
95  DOCA_LOG_ERR("Failed to set DPA thread func arg: %s", doca_error_get_descr(ret));
96  return ret;
97  }
98 
99  ret = doca_dpa_thread_start(resources->dpa_thread);
100  if (ret != DOCA_SUCCESS) {
101  DOCA_LOG_ERR("Failed to start DPA thread: %s", doca_error_get_descr(ret));
102  return ret;
103  }
104 
105  return DOCA_SUCCESS;
106 }
107 
108 /*
109  * Create a DB DPA completion context
110  *
111  * @resources [in]: The sample resources
112  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
113  */
115 {
117 
119  if (result != DOCA_SUCCESS) {
120  DOCA_LOG_ERR("Failed to create DB completion context to be used in DPA: %s",
122  return result;
123  }
124 
126  if (result != DOCA_SUCCESS) {
127  DOCA_LOG_ERR("Failed to start DB completion context: %s", doca_error_get_descr(result));
128  return result;
129  }
130 
132  if (result != DOCA_SUCCESS) {
133  DOCA_LOG_ERR("Failed to get DB completion context DPA handle: %s", doca_error_get_descr(result));
134  return result;
135  }
136 
137  return DOCA_SUCCESS;
138 }
139 
140 /*
141  * Initialize DPA app context
142  *
143  * @resources [in]: The sample resources
144  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
145  */
147 {
149  uint64_t rpc_ret;
152  &rpc_ret,
153  resources->db_comp_handle,
154  resources->data_path.db_handle);
155  if (result != DOCA_SUCCESS) {
156  DOCA_LOG_ERR("Failed to send RPC to initialize DPA app context: %s", doca_error_get_descr(result));
157  return result;
158  }
159  if (rpc_ret != 0) {
160  DOCA_LOG_ERR("RPC to initialize DPA app context has failed");
162  }
163 
164  return DOCA_SUCCESS;
165 }
166 
167 /*
168  * Uninitialize DPA app context
169  *
170  * @resources [in]: The sample resources
171  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
172  */
174 {
176  uint64_t rpc_ret;
179  &rpc_ret,
180  resources->db_comp_handle,
181  resources->data_path.db_handle);
182  if (result != DOCA_SUCCESS) {
183  DOCA_LOG_ERR("Failed to send RPC to uninitialize DPA app context: %s", doca_error_get_descr(result));
184  return result;
185  }
186  if (rpc_ret != 0) {
187  DOCA_LOG_ERR("RPC to uninitialize DPA app context has failed");
189  }
190 
191  return DOCA_SUCCESS;
192 }
193 
194 /*
195  * Create a DB object for the given resource ID and initialize it on DPA
196  *
197  * @resources [in]: The sample resources
198  * @db_region_idx [in]: Index of the configured DB region
199  * @db_id [in]: The DB ID of the DB
200  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
201  */
202 doca_error_t create_db_object(struct devemu_resources *resources, uint16_t db_region_idx, uint32_t db_id)
203 {
205 
206  const struct bar_db_region_config *db_region_cfg = &db_configs[db_region_idx];
207 
209  resources->db_comp,
210  db_region_cfg->region.bar_id,
211  db_region_cfg->region.start_address,
212  db_id,
213  0,
214  &resources->data_path.db);
215  if (result != DOCA_SUCCESS) {
216  DOCA_LOG_ERR("Failed to create DB for use in DPA: %s", doca_error_get_descr(result));
217  return result;
218  }
219 
220  result = doca_devemu_pci_db_get_dpa_handle(resources->data_path.db, &resources->data_path.db_handle);
221  if (result != DOCA_SUCCESS) {
222  DOCA_LOG_ERR("Failed to get DB DPA handle: %s", doca_error_get_descr(result));
223  return result;
224  }
225 
226  /* To prevent DBs from reaching DB completion before binding, need to first bind the DB and then start the DB */
228  if (result != DOCA_SUCCESS)
229  return result;
230 
231  result = doca_devemu_pci_db_start(resources->data_path.db);
232  if (result != DOCA_SUCCESS) {
233  DOCA_LOG_ERR("Failed to start DB: %s", doca_error_get_descr(result));
234  return result;
235  }
236 
237  return DOCA_SUCCESS;
238 }
239 
240 /*
241  * Destroy the DB object and uninitialize it on DPA
242  *
243  * @resources [in]: The sample resources
244  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
245  */
247 {
249 
250  result = doca_devemu_pci_db_stop(resources->data_path.db);
251  if (result != DOCA_SUCCESS) {
252  DOCA_LOG_ERR("Failed to stop DB: %s", doca_error_get_descr(result));
253  return result;
254  }
255 
257  if (result != DOCA_SUCCESS)
258  return result;
259 
261  if (result != DOCA_SUCCESS) {
262  DOCA_LOG_ERR("Failed to destroy DB: %s", doca_error_get_descr(result));
263  return result;
264  }
265  resources->data_path.db = NULL;
266 
267  return DOCA_SUCCESS;
268 }
269 
270 /*
271  * PCI FLR event handler callback
272  *
273  * @pci_dev [in]: The PCI device affected by the FLR
274  * @user_data [in]: The same user_data that was provided on registration
275  */
276 static void flr_event_handler_cb(struct doca_devemu_pci_dev *pci_dev, union doca_data user_data)
277 {
278  struct devemu_resources *resources = (struct devemu_resources *)user_data.ptr;
279 
280  DOCA_LOG_INFO("FLR has occurred destroying PCI device and recreating it");
282  if (result != DOCA_SUCCESS)
283  goto abort;
284 
286  if (result != DOCA_SUCCESS) {
287  DOCA_LOG_ERR("Failed to stop PCI device during FLR event");
288  goto abort;
289  }
290 
291  /* During FLR the context may transition to starting. DB recreation is deferred until context is running */
294  DOCA_LOG_ERR("Failed to start PCI device during FLR event");
295  goto abort;
296  }
297 
298  return;
299 abort:
300  resources->error = result;
301  force_quit = true;
302 }
303 
304 /*
305  * Register to PCI Function Level Reset events
306  *
307  * @resources [in]: The sample resources
308  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
309  */
311 {
312  union doca_data user_data;
313  doca_error_t res;
314 
315  user_data.ptr = (void *)resources;
317  if (res != DOCA_SUCCESS) {
318  DOCA_LOG_ERR("Unable to register to FLR event: %s", doca_error_get_descr(res));
319  return res;
320  }
321 
322  return DOCA_SUCCESS;
323 }
324 
325 /*
326  * Context state change event handler callback
327  *
328  * @user_data [in]: The user_data associated with the context
329  * @ctx [in]: The PCI device context that went through state change
330  * @prev_state [in]: The state of the context before the change
331  * @next_state [in]: The state of the context after the change
332  */
333 static void state_change_event_handler_cb(const union doca_data user_data,
334  struct doca_ctx *ctx,
335  enum doca_ctx_states prev_state,
336  enum doca_ctx_states next_state)
337 {
338  (void)prev_state;
339  (void)ctx;
340 
342  struct devemu_resources *resources = (struct devemu_resources *)user_data.ptr;
343 
344  switch (next_state) {
345  case DOCA_CTX_STATE_IDLE:
347  break;
349  result = create_db_object(resources, resources->db_region_idx, resources->db_id);
350  if (result != DOCA_SUCCESS) {
351  DOCA_LOG_INFO("Failed to create DB object: %s", doca_error_get_descr(result));
352  resources->error = result;
353  force_quit = true;
354  }
355  break;
357  DOCA_LOG_ERR(
358  "Devemu device has entered into stopping state. This happens only when attempting to stop before destroying doorbell");
360  break;
361  default:
362  break;
363  }
364 }
365 
366 /*
367  * Register to context state change events
368  *
369  * @resources [in]: The sample resources
370  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
371  */
373 {
374  union doca_data user_data;
376 
377  struct doca_ctx *ctx = doca_devemu_pci_dev_as_ctx(resources->pci_dev);
378 
379  user_data.ptr = (void *)resources;
380  result = doca_ctx_set_user_data(ctx, user_data);
381  if (result != DOCA_SUCCESS) {
382  DOCA_LOG_ERR("Unable to set ctx user data: %s", doca_error_get_descr(result));
383  return result;
384  }
385 
387  if (result != DOCA_SUCCESS) {
388  DOCA_LOG_ERR("Unable to register to context state change event: %s", doca_error_get_descr(result));
389  return result;
390  }
391 
392  return DOCA_SUCCESS;
393 }
394 
395 /*
396  * Run DOCA Device Emulation DB DPU sample
397  *
398  * @pci_address [in]: Device PCI address
399  * @emulated_dev_vuid [in]: VUID of the emulated device
400  * @db_region_idx [in]: Index of the DB region
401  * @db_id [in]: DB ID of the DB
402  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
403  */
404 doca_error_t devemu_pci_device_db_dpu(const char *pci_address,
405  const char *emulated_dev_vuid,
406  uint16_t db_region_idx,
407  uint32_t db_id)
408 {
410  struct timespec ts = {
411  .tv_sec = 0,
412  .tv_nsec = SLEEP_IN_NANOS,
413  };
414  struct devemu_resources resources = {0};
415  const char pci_type_name[DOCA_DEVEMU_PCI_TYPE_NAME_LEN] = PCI_TYPE_NAME;
416  bool destroy_rep = false;
417  uint16_t max_num_db = 0;
418 
419  resources.error = DOCA_SUCCESS;
420  resources.db_region_idx = db_region_idx;
421  resources.db_id = db_id;
422 
423  /* Signal the while loop to stop */
424  force_quit = false;
425  signal(SIGINT, signal_handler);
426  signal(SIGTERM, signal_handler);
427 
429  if (result != DOCA_SUCCESS) {
430  DOCA_LOG_ERR("Unable to create progress engine: %s", doca_error_get_descr(result));
431  return result;
432  }
433 
434  result = doca_devemu_pci_type_create(pci_type_name, &resources.pci_type);
435  if (result != DOCA_SUCCESS) {
436  DOCA_LOG_ERR("Unable to create PCI type: %s", doca_error_get_descr(result));
437  devemu_resources_cleanup(&resources, destroy_rep);
438  return result;
439  }
440 
441  result = find_supported_device(pci_address,
442  resources.pci_type,
444  &resources.dev);
445  if (result != DOCA_SUCCESS) {
446  devemu_resources_cleanup(&resources, destroy_rep);
447  return result;
448  }
449 
450  /* Check that DB ID is supported */
452  if (result != DOCA_SUCCESS) {
453  devemu_resources_cleanup(&resources, destroy_rep);
454  DOCA_LOG_ERR("Unable to get max num DBs per PCI type: %s", doca_error_get_descr(result));
455  return result;
456  }
457  if (max_num_db == 0) {
458  devemu_resources_cleanup(&resources, destroy_rep);
459  DOCA_LOG_ERR("Device does not support DBs");
461  }
462  if (db_id >= (uint32_t)max_num_db) {
463  devemu_resources_cleanup(&resources, destroy_rep);
464  DOCA_LOG_ERR(
465  "DB ID must not exceed the maximum number of DBs per PCI type: expected DB ID less than %u but received %u",
466  max_num_db,
467  db_id);
469  }
470 
471  /* Set PCIe configuration space values */
473  if (result != DOCA_SUCCESS) {
474  devemu_resources_cleanup(&resources, destroy_rep);
475  return result;
476  }
477 
478  /* Initialize DPA context */
480  if (result != DOCA_SUCCESS) {
481  devemu_resources_cleanup(&resources, destroy_rep);
482  return result;
483  }
484 
486  if (result != DOCA_SUCCESS) {
487  devemu_resources_cleanup(&resources, destroy_rep);
488  return result;
489  }
490 
492  if (result != DOCA_SUCCESS) {
493  devemu_resources_cleanup(&resources, destroy_rep);
494  return result;
495  }
496 
497  result = doca_dpa_thread_run(resources.dpa_thread);
498  if (result != DOCA_SUCCESS) {
499  DOCA_LOG_ERR("Failed to run DPA thread: %s", doca_error_get_descr(result));
500  devemu_resources_cleanup(&resources, destroy_rep);
501  return result;
502  }
503 
504  /* Find existing emulated device */
505  result = find_emulated_device(resources.pci_type, emulated_dev_vuid, &resources.rep);
506  if (result != DOCA_SUCCESS) {
507  DOCA_LOG_ERR("Unable to find PCI emulated device representor: %s", doca_error_get_descr(result));
508  devemu_resources_cleanup(&resources, destroy_rep);
509  return result;
510  }
511 
512  /* Create emulated device context */
514  if (result != DOCA_SUCCESS) {
515  DOCA_LOG_ERR("Unable to create PCI emulated device context: %s", doca_error_get_descr(result));
516  devemu_resources_cleanup(&resources, destroy_rep);
517  return result;
518  }
519 
521  if (result != DOCA_SUCCESS) {
522  DOCA_LOG_ERR("Failed to set PCI emulated device context datapath on DPA: %s",
524  devemu_resources_cleanup(&resources, destroy_rep);
525  return result;
526  }
527 
529  if (result != DOCA_SUCCESS) {
530  devemu_resources_cleanup(&resources, destroy_rep);
531  return result;
532  }
533 
535  if (result != DOCA_SUCCESS) {
536  devemu_resources_cleanup(&resources, destroy_rep);
537  return result;
538  }
539 
541  if (result != DOCA_SUCCESS) {
542  DOCA_LOG_ERR("Unable to start PCI emulated device context: %s", doca_error_get_descr(result));
543  devemu_resources_cleanup(&resources, destroy_rep);
544  return result;
545  }
546 
547  /* Defer assignment so that cleanup does not stop the context in case it was not started */
549 
551  if (result != DOCA_SUCCESS) {
552  DOCA_LOG_ERR("Unable to get hotplug state: %s", doca_error_get_descr(result));
553  devemu_resources_cleanup(&resources, destroy_rep);
554  return result;
555  }
556 
557  if (resources.hotplug_state != DOCA_DEVEMU_PCI_HP_STATE_POWER_ON) {
558  DOCA_LOG_ERR(
559  "Expected hotplug state to be DOCA_DEVEMU_PCI_HP_STATE_POWER_ON instead current state is %s",
560  hotplug_state_to_string(resources.hotplug_state));
561  devemu_resources_cleanup(&resources, destroy_rep);
562  return DOCA_ERROR_BAD_STATE;
563  }
564 
565  DOCA_LOG_INFO("Listening on DB with ID %u", db_id);
566 
567  /* Listen on FLR events while DPA listens on DBs */
568  while (!force_quit) {
569  if (doca_pe_progress(resources.pe) == 0)
570  nanosleep(&ts, &ts);
571  }
572 
573  if (resources.error != DOCA_SUCCESS) {
574  DOCA_LOG_ERR("Some error occurred during progress: %s", doca_error_get_descr(resources.error));
575  devemu_resources_cleanup(&resources, destroy_rep);
576  return resources.error;
577  }
578 
580  if (result != DOCA_SUCCESS) {
581  devemu_resources_cleanup(&resources, destroy_rep);
582  return result;
583  }
584 
585  /* Clean and destroy all relevant objects */
586  devemu_resources_cleanup(&resources, destroy_rep);
587 
588  return result;
589 }
#define NULL
Definition: __stddef_null.h:26
int32_t result
#define SLEEP_IN_NANOS
Definition: comch_utils.c:40
doca_error_t init_dpa(struct devemu_resources *resources, struct doca_dpa_app *dpa_app)
void devemu_resources_cleanup(struct devemu_resources *resources, bool destroy_rep)
doca_dpa_func_t db_handler
static void flr_event_handler_cb(struct doca_devemu_pci_dev *pci_dev, union doca_data user_data)
struct doca_dpa_app * devemu_pci_sample_app
doca_error_t init_dpa_app_ctx(struct devemu_resources *resources)
doca_error_t destroy_db_object(struct devemu_resources *resources)
doca_error_t devemu_pci_device_db_dpu(const char *pci_address, const char *emulated_dev_vuid, uint16_t db_region_idx, uint32_t db_id)
doca_error_t uninit_dpa_app_ctx(struct devemu_resources *resources)
static void state_change_event_handler_cb(const union doca_data user_data, struct doca_ctx *ctx, enum doca_ctx_states prev_state, enum doca_ctx_states next_state)
static doca_error_t register_to_ctx_state_change_events(struct devemu_resources *resources)
doca_dpa_func_t init_app_ctx_rpc
doca_error_t create_db_object(struct devemu_resources *resources, uint16_t db_region_idx, uint32_t db_id)
static bool force_quit
doca_error_t create_db_dpa_comp(struct devemu_resources *resources)
DOCA_LOG_REGISTER(DEVEMU_PCI_DEVICE_DB_DPU)
static doca_error_t register_to_flr_events(struct devemu_resources *resources)
doca_error_t init_dpa_db_thread(struct devemu_resources *resources)
static void signal_handler(int signum)
doca_dpa_func_t uninit_app_ctx_rpc
#define PCI_TYPE_NAME
struct rdma_resources resources
DOCA_STABLE doca_error_t doca_ctx_start(struct doca_ctx *ctx)
Finalizes all configurations, and starts the DOCA CTX.
DOCA_EXPERIMENTAL doca_error_t doca_ctx_set_datapath_on_dpa(struct doca_ctx *ctx, struct doca_dpa *dpa_dev)
This function binds the DOCA context to a dpa device.
DOCA_STABLE doca_error_t doca_ctx_set_state_changed_cb(struct doca_ctx *ctx, doca_ctx_state_changed_callback_t cb)
Set state changed callback.
DOCA_STABLE doca_error_t doca_ctx_set_user_data(struct doca_ctx *ctx, union doca_data user_data)
set user data to context
DOCA_STABLE doca_error_t doca_ctx_stop(struct doca_ctx *ctx)
Stops the context allowing reconfiguration.
doca_ctx_states
This enum defines the states of a context.
Definition: doca_ctx.h:83
@ DOCA_CTX_STATE_STARTING
Definition: doca_ctx.h:93
@ DOCA_CTX_STATE_STOPPING
Definition: doca_ctx.h:106
@ DOCA_CTX_STATE_IDLE
Definition: doca_ctx.h:88
@ DOCA_CTX_STATE_RUNNING
Definition: doca_ctx.h:98
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_cap_type_get_max_num_db(const struct doca_devinfo *devinfo, uint16_t *num_db)
Get the maximal number of doorbells that can be configured for any PCI type that was created using do...
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_create(const char *name, struct doca_devemu_pci_type **pci_type)
Create a stopped DOCA devemu PCI type.
#define DOCA_DEVEMU_PCI_TYPE_NAME_LEN
Maximal length for the NULL terminated string that describe the name of the emulated PCI device type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_cap_type_is_hotplug_supported(const struct doca_devinfo *devinfo, const struct doca_devemu_pci_type *pci_type, uint8_t *supported)
Get the hotplug capability of the device for a given DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_completion_create(struct doca_dpa_thread *th, struct doca_devemu_pci_db_completion **db_comp)
Allocate DOCA devemu PCI device doorbell completion context on DPA. The created completion context wi...
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_dev_event_flr_register(struct doca_devemu_pci_dev *pci_dev, doca_devemu_pci_dev_event_flr_handler_cb_t handler, union doca_data user_data)
Register to PCI FLR (Function Level Reset) event.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_get_dpa_handle(struct doca_devemu_pci_db *db, doca_dpa_dev_devemu_pci_db_t *db_handle)
Get the DPA handle for the DOCA devemu PCI device doorbell.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_dev_get_hotplug_state(struct doca_devemu_pci_dev *pci_dev, enum doca_devemu_pci_hotplug_state *state)
Get the hotplug state of the 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_dev_create(struct doca_devemu_pci_type *pci_type, struct doca_dev_rep *dev_rep, struct doca_pe *progress_engine, struct doca_devemu_pci_dev **pci_dev)
Allocate DOCA devemu PCI device.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_completion_get_dpa_handle(struct doca_devemu_pci_db_completion *db_comp, doca_dpa_dev_devemu_pci_db_completion_t *db_comp_handle)
Get the DPA handle for the DOCA devemu PCI device doorbell completion context.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_completion_start(struct doca_devemu_pci_db_completion *db_comp)
Start DOCA devemu PCI device doorbell completion context.
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_EXPERIMENTAL doca_error_t doca_devemu_pci_db_create_on_dpa(struct doca_devemu_pci_dev *pci_dev, struct doca_devemu_pci_db_completion *db_comp, uint8_t bar_id, uint64_t bar_start_addr, uint32_t db_id, uint64_t user_data_on_dpa, struct doca_devemu_pci_db **db)
Allocate DOCA devemu PCI device doorbell on DPA. The created doorbell will be associated with a singl...
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_start(struct doca_devemu_pci_db *db)
Start DOCA devemu PCI device doorbell. A started doorbell will be able to trigger completions on the ...
DOCA_EXPERIMENTAL struct doca_ctx * doca_devemu_pci_dev_as_ctx(struct doca_devemu_pci_dev *pci_dev)
Convert DOCA devemu PCI device instance into DOCA context.
@ DOCA_DEVEMU_PCI_HP_STATE_POWER_ON
DOCA_STABLE struct doca_devinfo * doca_dev_as_devinfo(const struct doca_dev *dev)
Get local device info from device. This should be useful when wanting to query information about devi...
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_run(struct doca_dpa_thread *dpa_thread)
Run DPA thread.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_create(struct doca_dpa *dpa, struct doca_dpa_thread **dpa_thread)
Create DPA thread.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_rpc(struct doca_dpa *dpa, doca_dpa_func_t *func, uint64_t *retval,...)
RPC to run DPA kernel.
void() doca_dpa_func_t(void)
Generic function pointer type.
Definition: doca_dpa.h:118
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_set_func_arg(struct doca_dpa_thread *dpa_thread, doca_dpa_func_t *func, uint64_t arg)
Set DPA thread entry point and its argument.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_start(struct doca_dpa_thread *dpa_thread)
Start DPA thread.
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_BAD_STATE
Definition: doca_error.h:56
@ DOCA_ERROR_NOT_SUPPORTED
Definition: doca_error.h:42
@ DOCA_SUCCESS
Definition: doca_error.h:38
@ DOCA_ERROR_IN_PROGRESS
Definition: doca_error.h:64
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
Definition: doca_log.h:466
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
Definition: doca_log.h:486
DOCA_STABLE uint8_t doca_pe_progress(struct doca_pe *pe)
Run the progress engine.
DOCA_STABLE doca_error_t doca_pe_create(struct doca_pe **pe)
Creates DOCA progress engine.
doca_error_t configure_and_start_pci_type(struct doca_devemu_pci_type *pci_type, struct doca_dev *dev)
const char * hotplug_state_to_string(enum doca_devemu_pci_hotplug_state hotplug_state)
doca_error_t find_emulated_device(struct doca_devemu_pci_type *pci_type, const char *vuid, struct doca_dev_rep **rep)
doca_error_t find_supported_device(const char *dev_name, const struct doca_devemu_pci_type *pci_type, emulation_supported_cb_t has_support, struct doca_dev **dev)
static const struct bar_db_region_config db_configs[PCI_TYPE_NUM_BAR_DB_REGIONS]
struct bar_region_config region
struct doca_devemu_pci_dev * pci_dev
struct doca_pe * pe
Definition: rdma_common.h:86
Convenience type for representing opaque data.
Definition: doca_types.h:56
void * ptr
Definition: doca_types.h:57
struct upf_accel_ctx * ctx