DPDK  24.07.0
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
28 extern "C" {
29 #endif
30 
32 #define RTE_GPU_DEFAULT_MAX 32
33 
35 #define RTE_GPU_ID_NONE -1
36 
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 
49 struct rte_gpu_info {
51  const char *name;
53  uint64_t context;
55  int16_t dev_id;
57  int16_t parent;
59  uint32_t processor_count;
61  size_t total_memory;
63  size_t page_size;
65  int16_t numa_node;
66 };
67 
74 };
75 
77 typedef 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
152 int rte_gpu_init(size_t dev_max);
153 
163 __rte_experimental
164 uint16_t rte_gpu_count_avail(void);
165 
179 __rte_experimental
180 bool rte_gpu_is_valid(int16_t dev_id);
181 
205 __rte_experimental
206 int16_t rte_gpu_add_child(const char *name,
207  int16_t parent, uint64_t child_context);
208 
226 __rte_experimental
227 int16_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
285 int rte_gpu_close(int16_t dev_id);
286 
310 __rte_experimental
311 int 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
337 int 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
358 int rte_gpu_info_get(int16_t dev_id, struct rte_gpu_info *info);
359 
386 __rte_experimental
387 void *rte_gpu_mem_alloc(int16_t dev_id, size_t size, unsigned int align)
389 
408 __rte_experimental
409 int rte_gpu_mem_free(int16_t dev_id, void *ptr);
410 
435 __rte_experimental
436 int rte_gpu_mem_register(int16_t dev_id, size_t size, void *ptr);
437 
456 __rte_experimental
457 int rte_gpu_mem_unregister(int16_t dev_id, void *ptr);
458 
484 __rte_experimental
485 void *rte_gpu_mem_cpu_map(int16_t dev_id, size_t size, void *ptr);
486 
505 __rte_experimental
506 int rte_gpu_mem_cpu_unmap(int16_t dev_id, void *ptr);
507 
523 __rte_experimental
524 int rte_gpu_wmb(int16_t dev_id);
525 
549 __rte_experimental
550 int 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
571 int rte_gpu_comm_destroy_flag(struct rte_gpu_comm_flag *devflag);
572 
590 __rte_experimental
591 int rte_gpu_comm_set_flag(struct rte_gpu_comm_flag *devflag,
592  uint32_t val);
593 
611 __rte_experimental
613  uint32_t *val);
614 
639 __rte_experimental
640 struct rte_gpu_comm_list *rte_gpu_comm_create_list(uint16_t dev_id,
641  uint32_t num_comm_items);
642 
658 __rte_experimental
659 int rte_gpu_comm_destroy_list(struct rte_gpu_comm_list *comm_list,
660  uint32_t num_comm_items);
661 
682 __rte_experimental
683 int rte_gpu_comm_populate_list_pkts(struct rte_gpu_comm_list *comm_list_item,
684  struct rte_mbuf **mbufs, uint32_t num_mbufs);
685 
701 __rte_experimental
702 int rte_gpu_comm_set_status(struct rte_gpu_comm_list *comm_list_item,
703  enum rte_gpu_comm_list_status status);
704 
722 __rte_experimental
723 int rte_gpu_comm_get_status(struct rte_gpu_comm_list *comm_list_item,
724  enum rte_gpu_comm_list_status *status);
725 
740 __rte_experimental
741 int rte_gpu_comm_cleanup_list(struct rte_gpu_comm_list *comm_list_item);
742 
743 #ifdef __cplusplus
744 }
745 #endif
746 
747 #endif /* RTE_GPUDEV_H */
__rte_experimental int rte_gpu_wmb(int16_t dev_id)
__rte_experimental int rte_gpu_init(size_t dev_max)
int16_t dev_id
Definition: rte_gpudev.h:55
__rte_experimental int16_t rte_gpu_find_next(int16_t dev_id, int16_t parent)
enum rte_gpu_comm_list_status * status_d
Definition: rte_gpudev.h:132
__rte_experimental int rte_gpu_mem_register(int16_t dev_id, size_t size, void *ptr)
__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_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_create_flag(uint16_t dev_id, struct rte_gpu_comm_flag *devflag, enum rte_gpu_comm_flag_type mtype)
__rte_experimental int16_t rte_gpu_add_child(const char *name, int16_t parent, uint64_t child_context)
rte_gpu_comm_list_status
Definition: rte_gpudev.h:105
const char * name
Definition: rte_gpudev.h:51
size_t total_memory
Definition: rte_gpudev.h:61
enum rte_gpu_comm_list_status * status_h
Definition: rte_gpudev.h:130
uint32_t num_pkts
Definition: rte_gpudev.h:128
__rte_experimental void * rte_gpu_mem_cpu_map(int16_t dev_id, size_t size, void *ptr)
__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_mem_cpu_unmap(int16_t dev_id, void *ptr)
__rte_experimental int rte_gpu_mem_free(int16_t dev_id, void *ptr)
__rte_experimental int rte_gpu_comm_cleanup_list(struct rte_gpu_comm_list *comm_list_item)
uint16_t dev_id
Definition: rte_gpudev.h:89
__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_close(int16_t dev_id)
#define __rte_alloc_size(...)
Definition: rte_common.h:228
__rte_experimental int rte_gpu_comm_destroy_flag(struct rte_gpu_comm_flag *devflag)
struct rte_mbuf ** mbufs
Definition: rte_gpudev.h:124
__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_unregister(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 int rte_gpu_comm_get_flag_value(struct rte_gpu_comm_flag *devflag, uint32_t *val)
void() rte_gpu_callback_t(int16_t dev_id, enum rte_gpu_event event, void *user_data)
Definition: rte_gpudev.h:77
__rte_experimental bool rte_gpu_is_valid(int16_t dev_id)
__rte_experimental int rte_gpu_info_get(int16_t dev_id, struct rte_gpu_info *info)
__rte_experimental uint16_t rte_gpu_count_avail(void)
__rte_experimental int rte_gpu_comm_set_flag(struct rte_gpu_comm_flag *devflag, uint32_t val)
size_t page_size
Definition: rte_gpudev.h:63
rte_gpu_event
Definition: rte_gpudev.h:69
__rte_experimental int rte_gpu_comm_get_status(struct rte_gpu_comm_list *comm_list_item, enum rte_gpu_comm_list_status *status)
struct rte_gpu_comm_pkt * pkt_list
Definition: rte_gpudev.h:126
rte_gpu_comm_flag_type
Definition: rte_gpudev.h:81
int16_t parent
Definition: rte_gpudev.h:57
__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)
uintptr_t addr
Definition: rte_gpudev.h:99
uint32_t processor_count
Definition: rte_gpudev.h:59
uint64_t context
Definition: rte_gpudev.h:53
uint32_t * ptr
Definition: rte_gpudev.h:91
int16_t numa_node
Definition: rte_gpudev.h:65