Elena Agostini 24c77594e0 gpu/cuda: map GPU memory with GDRCopy
To enable the gpudev rte_gpu_mem_cpu_map feature to expose
GPU memory to the CPU, the GPU CUDA driver library needs
the GDRCopy library and driver.

If DPDK is built without GDRCopy, the GPU CUDA driver returns
error if the is invoked rte_gpu_mem_cpu_map.

All the others GPU CUDA driver functionalities are not affected by
the absence of GDRCopy, thus this is an optional functionality
that can be enabled in the GPU CUDA driver.

CUDA driver documentation has been updated accordingly.

Signed-off-by: Elena Agostini <eagostini@nvidia.com>
2022-02-27 18:16:20 +01:00

39 lines
923 B
C

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2022 NVIDIA Corporation & Affiliates
*/
#ifndef CUDA_COMMON_H
#define CUDA_COMMON_H
#include <dlfcn.h>
#include <rte_common.h>
#include <rte_log.h>
#include <rte_errno.h>
extern int cuda_logtype;
/* Helper macro for logging */
#define rte_cuda_log(level, fmt, ...) \
rte_log(RTE_LOG_ ## level, cuda_logtype, fmt "\n", ##__VA_ARGS__)
#define rte_cuda_debug(fmt, ...) \
rte_cuda_log(DEBUG, RTE_STR(__LINE__) ":%s() " fmt, __func__, \
##__VA_ARGS__)
#ifdef DRIVERS_GPU_CUDA_GDRCOPY_H
#include <gdrapi.h>
#else
struct gdr;
typedef struct gdr *gdr_t;
struct gdr_mh_s { unsigned long h; };
typedef struct gdr_mh_s gdr_mh_t;
#endif
int gdrcopy_pin(gdr_t *gdrc_h, __rte_unused gdr_mh_t *mh,
uint64_t d_addr, size_t size, void **h_addr);
int gdrcopy_unpin(gdr_t gdrc_h, __rte_unused gdr_mh_t mh,
void *d_addr, size_t size);
#endif /* CUDA_COMMON_H */