DPDK 21.11.9
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;
62 /* Local NUMA memory ID. -1 if unknown. */
63 int16_t numa_node;
64};
65
72};
73
75typedef void (rte_gpu_callback_t)(int16_t dev_id,
76 enum rte_gpu_event event, void *user_data);
77
82};
83
87 uint16_t dev_id;
89 uint32_t *ptr;
92};
93
97 uintptr_t addr;
99 size_t size;
100};
101
112};
113
120 uint16_t dev_id;
122 struct rte_mbuf **mbufs;
126 uint32_t num_pkts;
129};
130
147__rte_experimental
148int rte_gpu_init(size_t dev_max);
149
159__rte_experimental
160uint16_t rte_gpu_count_avail(void);
161
175__rte_experimental
176bool rte_gpu_is_valid(int16_t dev_id);
177
201__rte_experimental
202int16_t rte_gpu_add_child(const char *name,
203 int16_t parent, uint64_t child_context);
204
222__rte_experimental
223int16_t rte_gpu_find_next(int16_t dev_id, int16_t parent);
224
234#define RTE_GPU_FOREACH(dev_id) \
235 RTE_GPU_FOREACH_CHILD(dev_id, RTE_GPU_ID_ANY)
236
246#define RTE_GPU_FOREACH_PARENT(dev_id) \
247 RTE_GPU_FOREACH_CHILD(dev_id, RTE_GPU_ID_NONE)
248
260#define RTE_GPU_FOREACH_CHILD(dev_id, parent) \
261 for (dev_id = rte_gpu_find_next(0, parent); \
262 dev_id >= 0; \
263 dev_id = rte_gpu_find_next(dev_id + 1, parent))
264
280__rte_experimental
281int rte_gpu_close(int16_t dev_id);
282
306__rte_experimental
307int rte_gpu_callback_register(int16_t dev_id, enum rte_gpu_event event,
308 rte_gpu_callback_t *function, void *user_data);
309
332__rte_experimental
333int rte_gpu_callback_unregister(int16_t dev_id, enum rte_gpu_event event,
334 rte_gpu_callback_t *function, void *user_data);
335
353__rte_experimental
354int rte_gpu_info_get(int16_t dev_id, struct rte_gpu_info *info);
355
377__rte_experimental
378void *rte_gpu_mem_alloc(int16_t dev_id, size_t size)
380
399__rte_experimental
400int rte_gpu_mem_free(int16_t dev_id, void *ptr);
401
426__rte_experimental
427int rte_gpu_mem_register(int16_t dev_id, size_t size, void *ptr);
428
447__rte_experimental
448int rte_gpu_mem_unregister(int16_t dev_id, void *ptr);
449
465__rte_experimental
466int rte_gpu_wmb(int16_t dev_id);
467
491__rte_experimental
492int rte_gpu_comm_create_flag(uint16_t dev_id,
493 struct rte_gpu_comm_flag *devflag,
494 enum rte_gpu_comm_flag_type mtype);
495
512__rte_experimental
514
532__rte_experimental
534 uint32_t val);
535
553__rte_experimental
555 uint32_t *val);
556
581__rte_experimental
583 uint32_t num_comm_items);
584
600__rte_experimental
602 uint32_t num_comm_items);
603
624__rte_experimental
626 struct rte_mbuf **mbufs, uint32_t num_mbufs);
627
642__rte_experimental
644
645#ifdef __cplusplus
646}
647#endif
648
649#endif /* RTE_GPUDEV_H */
#define __rte_alloc_size(...)
Definition: rte_common.h:164
__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_gpu_comm_list_status
Definition: rte_gpudev.h:103
@ RTE_GPU_COMM_LIST_READY
Definition: rte_gpudev.h:107
@ RTE_GPU_COMM_LIST_FREE
Definition: rte_gpudev.h:105
@ RTE_GPU_COMM_LIST_DONE
Definition: rte_gpudev.h:109
@ RTE_GPU_COMM_LIST_ERROR
Definition: rte_gpudev.h:111
__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 void * rte_gpu_mem_alloc(int16_t dev_id, size_t size) __rte_alloc_size(2)
__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_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:79
@ RTE_GPU_COMM_FLAG_CPU
Definition: rte_gpudev.h:81
__rte_experimental int rte_gpu_mem_register(int16_t dev_id, size_t size, void *ptr)
rte_gpu_event
Definition: rte_gpudev.h:67
@ RTE_GPU_EVENT_NEW
Definition: rte_gpudev.h:69
@ RTE_GPU_EVENT_DEL
Definition: rte_gpudev.h:71
void() rte_gpu_callback_t(int16_t dev_id, enum rte_gpu_event event, void *user_data)
Definition: rte_gpudev.h:75
__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 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 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:91
uint32_t * ptr
Definition: rte_gpudev.h:89
uint16_t dev_id
Definition: rte_gpudev.h:87
enum rte_gpu_comm_list_status status
Definition: rte_gpudev.h:128
struct rte_mbuf ** mbufs
Definition: rte_gpudev.h:122
uint32_t num_pkts
Definition: rte_gpudev.h:126
struct rte_gpu_comm_pkt * pkt_list
Definition: rte_gpudev.h:124
uintptr_t addr
Definition: rte_gpudev.h:97
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