DPDK 22.11.7
rte_gpudev.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2021 NVIDIA Corporation & Affiliates
3 */
4
5#ifndef RTE_GPUDEV_H
6#define RTE_GPUDEV_H
7
8#include <stddef.h>
9#include <stdint.h>
10#include <stdbool.h>
11
12#include <rte_mbuf.h>
13#include <rte_bitops.h>
14#include <rte_compat.h>
15
27#ifdef __cplusplus
28extern "C" {
29#endif
30
32#define RTE_GPU_DEFAULT_MAX 32
33
35#define RTE_GPU_ID_NONE -1
37#define RTE_GPU_ID_ANY INT16_MIN
38
40#define RTE_GPU_CALLBACK_ANY_DATA ((void *)-1)
41
43#define RTE_GPU_VOLATILE(x) (*(volatile typeof(x) *)&(x))
44
46#define RTE_GPU_COMM_LIST_PKTS_MAX 1024
47
51 const char *name;
53 uint64_t context;
55 int16_t dev_id;
57 int16_t parent;
63 size_t page_size;
65 int16_t numa_node;
66};
67
74};
75
77typedef void (rte_gpu_callback_t)(int16_t dev_id,
78 enum rte_gpu_event event, void *user_data);
79
84};
85
89 uint16_t dev_id;
91 uint32_t *ptr;
94};
95
99 uintptr_t addr;
101 size_t size;
102};
103
114};
115
122 uint16_t dev_id;
124 struct rte_mbuf **mbufs;
128 uint32_t num_pkts;
133};
134
151__rte_experimental
152int rte_gpu_init(size_t dev_max);
153
163__rte_experimental
164uint16_t rte_gpu_count_avail(void);
165
179__rte_experimental
180bool rte_gpu_is_valid(int16_t dev_id);
181
205__rte_experimental
206int16_t rte_gpu_add_child(const char *name,
207 int16_t parent, uint64_t child_context);
208
226__rte_experimental
227int16_t rte_gpu_find_next(int16_t dev_id, int16_t parent);
228
238#define RTE_GPU_FOREACH(dev_id) \
239 RTE_GPU_FOREACH_CHILD(dev_id, RTE_GPU_ID_ANY)
240
250#define RTE_GPU_FOREACH_PARENT(dev_id) \
251 RTE_GPU_FOREACH_CHILD(dev_id, RTE_GPU_ID_NONE)
252
264#define RTE_GPU_FOREACH_CHILD(dev_id, parent) \
265 for (dev_id = rte_gpu_find_next(0, parent); \
266 dev_id >= 0; \
267 dev_id = rte_gpu_find_next(dev_id + 1, parent))
268
284__rte_experimental
285int rte_gpu_close(int16_t dev_id);
286
310__rte_experimental
311int rte_gpu_callback_register(int16_t dev_id, enum rte_gpu_event event,
312 rte_gpu_callback_t *function, void *user_data);
313
336__rte_experimental
337int rte_gpu_callback_unregister(int16_t dev_id, enum rte_gpu_event event,
338 rte_gpu_callback_t *function, void *user_data);
339
357__rte_experimental
358int rte_gpu_info_get(int16_t dev_id, struct rte_gpu_info *info);
359
386__rte_experimental
387void *rte_gpu_mem_alloc(int16_t dev_id, size_t size, unsigned int align)
389
408__rte_experimental
409int rte_gpu_mem_free(int16_t dev_id, void *ptr);
410
435__rte_experimental
436int rte_gpu_mem_register(int16_t dev_id, size_t size, void *ptr);
437
456__rte_experimental
457int rte_gpu_mem_unregister(int16_t dev_id, void *ptr);
458
484__rte_experimental
485void *rte_gpu_mem_cpu_map(int16_t dev_id, size_t size, void *ptr);
486
505__rte_experimental
506int rte_gpu_mem_cpu_unmap(int16_t dev_id, void *ptr);
507
523__rte_experimental
524int rte_gpu_wmb(int16_t dev_id);
525
549__rte_experimental
550int rte_gpu_comm_create_flag(uint16_t dev_id,
551 struct rte_gpu_comm_flag *devflag,
552 enum rte_gpu_comm_flag_type mtype);
553
570__rte_experimental
572
590__rte_experimental
592 uint32_t val);
593
611__rte_experimental
613 uint32_t *val);
614
639__rte_experimental
641 uint32_t num_comm_items);
642
658__rte_experimental
660 uint32_t num_comm_items);
661
682__rte_experimental
684 struct rte_mbuf **mbufs, uint32_t num_mbufs);
685
701__rte_experimental
703 enum rte_gpu_comm_list_status status);
704
722__rte_experimental
724 enum rte_gpu_comm_list_status *status);
725
740__rte_experimental
742
743#ifdef __cplusplus
744}
745#endif
746
747#endif /* RTE_GPUDEV_H */
#define __rte_alloc_size(...)
Definition: rte_common.h:161
__rte_experimental int rte_gpu_callback_unregister(int16_t dev_id, enum rte_gpu_event event, rte_gpu_callback_t *function, void *user_data)
__rte_experimental int rte_gpu_comm_get_status(struct rte_gpu_comm_list *comm_list_item, enum rte_gpu_comm_list_status *status)
rte_gpu_comm_list_status
Definition: rte_gpudev.h:105
@ RTE_GPU_COMM_LIST_READY
Definition: rte_gpudev.h:109
@ RTE_GPU_COMM_LIST_FREE
Definition: rte_gpudev.h:107
@ RTE_GPU_COMM_LIST_DONE
Definition: rte_gpudev.h:111
@ RTE_GPU_COMM_LIST_ERROR
Definition: rte_gpudev.h:113
__rte_experimental uint16_t rte_gpu_count_avail(void)
__rte_experimental int rte_gpu_comm_destroy_flag(struct rte_gpu_comm_flag *devflag)
__rte_experimental int rte_gpu_wmb(int16_t dev_id)
__rte_experimental int rte_gpu_comm_create_flag(uint16_t dev_id, struct rte_gpu_comm_flag *devflag, enum rte_gpu_comm_flag_type mtype)
__rte_experimental int rte_gpu_close(int16_t dev_id)
__rte_experimental int rte_gpu_comm_populate_list_pkts(struct rte_gpu_comm_list *comm_list_item, struct rte_mbuf **mbufs, uint32_t num_mbufs)
__rte_experimental int rte_gpu_comm_set_status(struct rte_gpu_comm_list *comm_list_item, enum rte_gpu_comm_list_status status)
__rte_experimental int rte_gpu_comm_destroy_list(struct rte_gpu_comm_list *comm_list, uint32_t num_comm_items)
__rte_experimental int rte_gpu_info_get(int16_t dev_id, struct rte_gpu_info *info)
rte_gpu_comm_flag_type
Definition: rte_gpudev.h:81
@ RTE_GPU_COMM_FLAG_CPU
Definition: rte_gpudev.h:83
__rte_experimental int rte_gpu_mem_register(int16_t dev_id, size_t size, void *ptr)
rte_gpu_event
Definition: rte_gpudev.h:69
@ RTE_GPU_EVENT_NEW
Definition: rte_gpudev.h:71
@ RTE_GPU_EVENT_DEL
Definition: rte_gpudev.h:73
void() rte_gpu_callback_t(int16_t dev_id, enum rte_gpu_event event, void *user_data)
Definition: rte_gpudev.h:77
__rte_experimental int rte_gpu_comm_cleanup_list(struct rte_gpu_comm_list *comm_list_item)
__rte_experimental int rte_gpu_callback_register(int16_t dev_id, enum rte_gpu_event event, rte_gpu_callback_t *function, void *user_data)
__rte_experimental int rte_gpu_init(size_t dev_max)
__rte_experimental void * rte_gpu_mem_cpu_map(int16_t dev_id, size_t size, void *ptr)
__rte_experimental void * rte_gpu_mem_alloc(int16_t dev_id, size_t size, unsigned int align) __rte_alloc_size(2)
__rte_experimental int rte_gpu_mem_free(int16_t dev_id, void *ptr)
__rte_experimental struct rte_gpu_comm_list * rte_gpu_comm_create_list(uint16_t dev_id, uint32_t num_comm_items)
__rte_experimental int16_t rte_gpu_find_next(int16_t dev_id, int16_t parent)
__rte_experimental bool rte_gpu_is_valid(int16_t dev_id)
__rte_experimental int rte_gpu_comm_get_flag_value(struct rte_gpu_comm_flag *devflag, uint32_t *val)
__rte_experimental int rte_gpu_mem_unregister(int16_t dev_id, void *ptr)
__rte_experimental int rte_gpu_comm_set_flag(struct rte_gpu_comm_flag *devflag, uint32_t val)
__rte_experimental int rte_gpu_mem_cpu_unmap(int16_t dev_id, void *ptr)
__rte_experimental int16_t rte_gpu_add_child(const char *name, int16_t parent, uint64_t child_context)
enum rte_gpu_comm_flag_type mtype
Definition: rte_gpudev.h:93
uint32_t * ptr
Definition: rte_gpudev.h:91
uint16_t dev_id
Definition: rte_gpudev.h:89
enum rte_gpu_comm_list_status * status_h
Definition: rte_gpudev.h:130
struct rte_mbuf ** mbufs
Definition: rte_gpudev.h:124
enum rte_gpu_comm_list_status * status_d
Definition: rte_gpudev.h:132
uint32_t num_pkts
Definition: rte_gpudev.h:128
struct rte_gpu_comm_pkt * pkt_list
Definition: rte_gpudev.h:126
uintptr_t addr
Definition: rte_gpudev.h:99
int16_t dev_id
Definition: rte_gpudev.h:55
uint32_t processor_count
Definition: rte_gpudev.h:59
uint64_t context
Definition: rte_gpudev.h:53
int16_t parent
Definition: rte_gpudev.h:57
const char * name
Definition: rte_gpudev.h:51
size_t total_memory
Definition: rte_gpudev.h:61
int16_t numa_node
Definition: rte_gpudev.h:65
size_t page_size
Definition: rte_gpudev.h:63