1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2021 NVIDIA Corporation & Affiliates
6 * This header file must be included only by drivers.
7 * It is considered internal, i.e. hidden for the application.
8 * The prefix rte_ is used to avoid namespace clash in drivers.
11 #ifndef RTE_GPUDEV_DRIVER_H
12 #define RTE_GPUDEV_DRIVER_H
15 #include <sys/queue.h>
19 #include "rte_gpudev.h"
21 /* Flags indicate current state of device. */
23 RTE_GPU_STATE_UNUSED, /* not initialized */
24 RTE_GPU_STATE_INITIALIZED, /* initialized */
28 typedef int (rte_gpu_close_t)(struct rte_gpu *dev);
29 typedef int (rte_gpu_info_get_t)(struct rte_gpu *dev, struct rte_gpu_info *info);
32 /* Get device info. If NULL, info is just copied. */
33 rte_gpu_info_get_t *dev_info_get;
35 rte_gpu_close_t *dev_close;
40 struct rte_device *device;
41 /* Unique identifier name. */
42 char name[RTE_DEV_NAME_MAX_LEN]; /* Updated by this library. */
43 /* Device info structure. */
44 struct rte_gpu_info info;
45 /* Driver functions. */
46 struct rte_gpu_ops ops;
47 /* Event callback list. */
48 TAILQ_HEAD(rte_gpu_callback_list, rte_gpu_callback) callbacks;
49 /* Current state (used or not) in the running process. */
50 enum rte_gpu_state state; /* Updated by this library. */
51 /* Driver-specific private data for the running process. */
52 void *process_private;
53 } __rte_cache_aligned;
56 struct rte_gpu *rte_gpu_get_by_name(const char *name);
58 /* First step of initialization */
60 struct rte_gpu *rte_gpu_allocate(const char *name);
62 /* Last step of initialization. */
64 void rte_gpu_complete_new(struct rte_gpu *dev);
66 /* Last step of removal. */
68 int rte_gpu_release(struct rte_gpu *dev);
70 /* Call registered callbacks. No multi-process event. */
72 void rte_gpu_notify(struct rte_gpu *dev, enum rte_gpu_event);
74 #endif /* RTE_GPUDEV_DRIVER_H */