From patchwork Tue Jan 11 17:39:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Agostini X-Patchwork-Id: 105726 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8B525A034D; Tue, 11 Jan 2022 10:29:52 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 86CF9426D3; Tue, 11 Jan 2022 10:29:48 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2067.outbound.protection.outlook.com [40.107.244.67]) by mails.dpdk.org (Postfix) with ESMTP id 3204841C3B for ; Tue, 11 Jan 2022 10:29:47 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I0v3SYW17vxSz7fpOEOVWnu6CBnkLTI5Y8+pEkdKv8lRhdMqV1krIesCJKQ17BF3U/ATkRDM+qklt2sVEsAvgQSjpcQG/SmSr4bI1V/JtEG3hvKRCo6AQZI5Z8wm6PazGACiJOqK3uI7FXZhq1EGl0xfYgUgbjUoxyhOpR7q/6QXzibSbGMcCWe3QnaYmKYRxtKloIPjYrd5Rp31/wZxXbELDw5zS5HyiMi6M5qwVl6+1qPxlJkC50KwOHtnI+1TMsy7vv2z84IGHHvAVa3J2VMeVk6dPeUix0NQeiZVEjz/91l4MhN9m/+3/rz1qIG2tnkJ1FqXESQhptzdzq155A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=y43FUHzelIi8CmSfwrKUWwoj1UFfzrkGc/H+uUoxfuU=; b=JjAOonMzjNGL5U1TEevNHA8ic4Hit3fQiqpNcrHs7eXphrp0F46/Z5p2oLaS1fIMa3yDuWU6HlRvG4ZcRGR0rjRFPalfeyIawIcZIppyKFfta7IO6qsb+4Ffit440TgA/gbmHsOg19GuhK2GFnYRmTkJ32MaCZpiBDdFuzRsHHqVj+d8/l78dnLLVvR+rr1F0eX9ecJ/T0bYJ+PqE/KRaPhCb6zBFAnoJ7bdIqauyQOKQ7sgfPd292e8F9RasmSRd40YPEpPfgbV6Drv7bfQTB4Si2DNWem85oGiWmmde/voTVUk7woeB08rp5L6qNOLIbm7ZJEVF6Dq5wxvU6YFjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=y43FUHzelIi8CmSfwrKUWwoj1UFfzrkGc/H+uUoxfuU=; b=sCf34B568kjyBWGEqrscn3O7Lgfe999H351Mgij2lKd2sFuooG0Ao0Mk63yjF5bXKrprpclmf3UPA0d11RCd28pcqvF7Cm8599dypKWxBPLzpyFoD4c2bDmMV1JQu7Qpm2E99tUfSEPeGVNxx/PXCy59MRZ0PxSC9Ai+9gbzQUj+0R62V5+qrArNbI09ERwXceIS8K2xxDsG/LnriiIfMMckajV+Glj/qaokPfQr5630oiTq7eyjyRyqrI1Di1NOsO8shqzq6po9SDtiJlBzk4T14eVN8o6gLvr8yk1OzfWd116J4G5A0T9/GB2aTZ4kSSIRca+SR1FAdpP+PvfvKQ== Received: from BN9PR03CA0770.namprd03.prod.outlook.com (2603:10b6:408:13a::25) by BN6PR12MB1667.namprd12.prod.outlook.com (2603:10b6:405:4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.7; Tue, 11 Jan 2022 09:29:43 +0000 Received: from BN8NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13a:cafe::9e) by BN9PR03CA0770.outlook.office365.com (2603:10b6:408:13a::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.9 via Frontend Transport; Tue, 11 Jan 2022 09:29:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by BN8NAM11FT003.mail.protection.outlook.com (10.13.177.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4867.7 via Frontend Transport; Tue, 11 Jan 2022 09:29:43 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 11 Jan 2022 09:29:41 +0000 Received: from nvidia.com (10.127.8.10) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.986.9; Tue, 11 Jan 2022 01:29:41 -0800 From: To: CC: Elena Agostini Subject: [PATCH v1 1/1] gpu/cuda: expose GPU memory with GDRCopy Date: Tue, 11 Jan 2022 17:39:29 +0000 Message-ID: <20220111173929.28746-2-eagostini@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220111173929.28746-1-eagostini@nvidia.com> References: <20220111173929.28746-1-eagostini@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.127.8.10] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6e22d9d6-cd95-4218-2617-08d9d4e4e657 X-MS-TrafficTypeDiagnostic: BN6PR12MB1667:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1265; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q6YDKD+EMseGGpG1JsMIxVIk7RBDZnv8faVRQ5uRvKqTqywi30rrA40MMs+l5Hzyk7f+t8RLN23OGvgIeleNSVc+op3GTTbwHXcSb5A3ZG6ICyqSI8+7M73Ur3Idz9GnxLH89u0up4hUNJeqvFqbQSGtL/p1dTWEINuniNctxQ95+kPm85z1oIr49SP26iWUnM1+MwrgulucUVwkENeAd0/6uRxkZIlEIlT5GVm39FPx0Y5X8zjhaGrgpR2+cJ0BQYPgeAs5V/V7zTxQwPXuuhCDYVHA3OvpgWLinZQwg9pyWjc0Fpn0/ZHMnwJVkYw9uJw10cvDwS9a/p76PH0Kga1HiZkKFLdKBsTMWjtqfv+KfwX+aYphEq87J0uuASo1wijVJEjqGZaLSqcFPLJj3oRyIMD6G+d6rz0j8uub93SvmbaWK6CZF8TpIr/eMjU1ZXZRPyf+xj+CO6lfPXMKzZJ0k9B7hJ9idZe993ZSoeRxgmWKpwvfgQyWC0k9vZ4uvmPhdJQJoRx1nSKoxUkLPLHq/ntkihY8PXXVeCQcPQKxZMkBXUKxrzE5I8etLpoE8+wNNcf4LfkVHNaOlBlNG8yid28z6UKjne3LQJiwNRxK4JjvLIphZL7X+DYcwC9IjOpL7zbh/AcvaxIsmhJ7Y0NkkmYy34ALne8K+p7VDO/z5ukQAq20WWSFHFRqfv95bpg4ERB4jWyIP9HxGCOPG94DyQPf4dvzrZ0ybwHRRRwa04qc+zdqRRrv9pEpeue1litCPnENKSCSXpah3T6lbKInEUXVqnd7nYVzhATrIEoPPNfvTe8nWTxUGZPYTug+vP+CqGqZVSEb7cPUfRmeYz35wbhKA1YTfLhNi7x7gila4g4YxCq7BEfqtJhsOsNj X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(40470700002)(2616005)(426003)(40460700001)(83380400001)(81166007)(356005)(2876002)(5660300002)(508600001)(47076005)(55016003)(4326008)(966005)(6666004)(36860700001)(86362001)(316002)(2906002)(16526019)(186003)(70206006)(336012)(70586007)(8936002)(82310400004)(6916009)(36756003)(8676002)(107886003)(6286002)(7696005)(26005)(1076003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2022 09:29:43.0176 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e22d9d6-cd95-4218-2617-08d9d4e4e657 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1667 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Elena Agostini GPU CUDA implementation of the new gpudev functions to expose GPU memory to the CPU. Today GDRCopy library is required to pin and DMA map the GPU memory through the BAR1 of the GPU and expose it to the CPU. Goal here is to hide technical details GDRCopy library and expose the functionality through the generic gpudev layer. GDRCopy can be found here: https://github.com/NVIDIA/gdrcopy To build GPU CUDA driver with GDRCopy, you need to build DPDK indicating the gdrapi.h header file with -Dc_args="-I/path/to/gdrapi/". To execute you need to indicate the path to libgdrapi.so library with the environment variable GDRCOPY_PATH_L=/path/to/gdrcopy/lib/ If GDRCopy is not built with GPU CUDA driver, the GPU expose functionality will not be supported by the driver. This is an indipendent feature. All the other GPU CUDA driver capabilities are not affected if GDRCopy is not built. Signed-off-by: Elena Agostini --- Dependency on https://patches.dpdk.org/project/dpdk/patch/20220108000457.31104-1-eagostini@nvidia.com/ --- drivers/gpu/cuda/cuda.c | 101 +++++++++++++++++++++++++ drivers/gpu/cuda/gdrcopy.c | 139 +++++++++++++++++++++++++++++++++++ drivers/gpu/cuda/gdrcopy.h | 29 ++++++++ drivers/gpu/cuda/meson.build | 6 +- 4 files changed, 274 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/cuda/gdrcopy.c create mode 100644 drivers/gpu/cuda/gdrcopy.h diff --git a/drivers/gpu/cuda/cuda.c b/drivers/gpu/cuda/cuda.c index 882df08e56..d66d6b76b9 100644 --- a/drivers/gpu/cuda/cuda.c +++ b/drivers/gpu/cuda/cuda.c @@ -17,6 +17,8 @@ #include #include +#include "gdrcopy.h" + #define CUDA_DRIVER_MIN_VERSION 11040 #define CUDA_API_MIN_VERSION 3020 @@ -52,6 +54,8 @@ static void *cudalib; static unsigned int cuda_api_version; static int cuda_driver_version; +static gdr_t gdrc_h; + /* NVIDIA GPU vendor */ #define NVIDIA_GPU_VENDOR_ID (0x10de) @@ -144,6 +148,7 @@ struct mem_entry { struct rte_gpu *dev; CUcontext ctx; cuda_ptr_key pkey; + gdr_mh_t mh; enum mem_type mtype; struct mem_entry *prev; struct mem_entry *next; @@ -943,6 +948,87 @@ cuda_wmb(struct rte_gpu *dev) return 0; } +static int +cuda_mem_expose(struct rte_gpu *dev, __rte_unused size_t size, void *ptr_in, void **ptr_out) +{ + struct mem_entry *mem_item; + cuda_ptr_key hk; + + if (dev == NULL) + return -ENODEV; + + if (gdrc_h == NULL) { + rte_cuda_log(ERR, "GDRCopy not built or loaded. Can't expose GPU memory."); + rte_errno = ENOTSUP; + return -rte_errno; + } + + hk = get_hash_from_ptr((void *)ptr_in); + + mem_item = mem_list_find_item(hk); + if (mem_item == NULL) { + rte_cuda_log(ERR, "Memory address 0x%p not found in driver memory.", ptr_in); + rte_errno = EPERM; + return -rte_errno; + } + + if (mem_item->mtype == GPU_MEM) { + rte_cuda_log(ERR, "Memory address 0x%p is not GPU memory type.", ptr_in); + rte_errno = EPERM; + return -rte_errno; + } + + if (mem_item->size != size) + rte_cuda_log(WARNING, + "Can't expose memory area with size (%zd) different from original size (%zd).", + size, mem_item->size); + + if (gdrcopy_pin(gdrc_h, &(mem_item->mh), (uint64_t)mem_item->ptr_d, + mem_item->size, &(mem_item->ptr_h))) { + rte_cuda_log(ERR, "Error exposing GPU memory address 0x%p.", ptr_in); + rte_errno = EPERM; + return -rte_errno; + } + + *ptr_out = mem_item->ptr_h; + + return 0; +} + +static int +cuda_mem_unexpose(struct rte_gpu *dev, void *ptr_in) +{ + struct mem_entry *mem_item; + cuda_ptr_key hk; + + if (dev == NULL) + return -ENODEV; + + if (gdrc_h == NULL) { + rte_cuda_log(ERR, "GDRCopy not built or loaded. Can't unexpose GPU memory."); + rte_errno = ENOTSUP; + return -rte_errno; + } + + hk = get_hash_from_ptr((void *)ptr_in); + + mem_item = mem_list_find_item(hk); + if (mem_item == NULL) { + rte_cuda_log(ERR, "Memory address 0x%p not found in driver memory.", ptr_in); + rte_errno = EPERM; + return -rte_errno; + } + + if (gdrcopy_unpin(gdrc_h, mem_item->mh, (void *)mem_item->ptr_d, + mem_item->size)) { + rte_cuda_log(ERR, "Error unexposing GPU memory address 0x%p.", ptr_in); + rte_errno = EPERM; + return -rte_errno; + } + + return 0; +} + static int cuda_gpu_probe(__rte_unused struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) { @@ -1018,6 +1104,19 @@ cuda_gpu_probe(__rte_unused struct rte_pci_driver *pci_drv, struct rte_pci_devic rte_errno = ENOTSUP; return -rte_errno; } + + gdrc_h = NULL; + + #ifdef DRIVERS_GPU_CUDA_GDRCOPY_H + if (gdrcopy_loader()) + rte_cuda_log(ERR, "GDRCopy shared library not found.\n"); + else { + if (gdrcopy_open(&gdrc_h)) + rte_cuda_log(ERR, "GDRCopy handler can't be created. Is gdrdrv driver installed and loaded?\n"); + } + #else + gdrc_h = NULL; + #endif } /* Fill HW specific part of device structure */ @@ -1160,6 +1259,8 @@ cuda_gpu_probe(__rte_unused struct rte_pci_driver *pci_drv, struct rte_pci_devic dev->ops.mem_free = cuda_mem_free; dev->ops.mem_register = cuda_mem_register; dev->ops.mem_unregister = cuda_mem_unregister; + dev->ops.mem_expose = cuda_mem_expose; + dev->ops.mem_unexpose = cuda_mem_unexpose; dev->ops.wmb = cuda_wmb; rte_gpu_complete_new(dev); diff --git a/drivers/gpu/cuda/gdrcopy.c b/drivers/gpu/cuda/gdrcopy.c new file mode 100644 index 0000000000..1dc6b676e5 --- /dev/null +++ b/drivers/gpu/cuda/gdrcopy.c @@ -0,0 +1,139 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2022 NVIDIA Corporation & Affiliates + */ + +#include "gdrcopy.h" + +static void *gdrclib; + +static gdr_t (*sym_gdr_open)(void); +static int (*sym_gdr_close)(gdr_t g); +static int (*sym_gdr_pin_buffer)(gdr_t g, unsigned long addr, size_t size, uint64_t p2p_token, uint32_t va_space, gdr_mh_t *handle); +static int (*sym_gdr_unpin_buffer)(gdr_t g, gdr_mh_t handle); +static int (*sym_gdr_map)(gdr_t g, gdr_mh_t handle, void **va, size_t size); +static int (*sym_gdr_unmap)(gdr_t g, gdr_mh_t handle, void *va, size_t size); + +int +gdrcopy_loader(void) +{ + char gdrcopy_path[1024]; + + if (getenv("GDRCOPY_PATH_L") == NULL) + snprintf(gdrcopy_path, 1024, "%s", "libgdrapi.so"); + else + snprintf(gdrcopy_path, 1024, "%s%s", getenv("GDRCOPY_PATH_L"), "libgdrapi.so"); + + gdrclib = dlopen(gdrcopy_path, RTLD_LAZY); + if (gdrclib == NULL) { + fprintf(stderr, "Failed to find GDRCopy library in %s (GDRCOPY_PATH_L=%s)\n", + gdrcopy_path, getenv("GDRCOPY_PATH_L")); + return -1; + } + + sym_gdr_open = dlsym(gdrclib, "gdr_open"); + if (sym_gdr_open == NULL) { + fprintf(stderr, "Failed to load GDRCopy symbols\n"); + return -1; + } + + sym_gdr_close = dlsym(gdrclib, "gdr_close"); + if (sym_gdr_close == NULL) { + fprintf(stderr, "Failed to load GDRCopy symbols\n"); + return -1; + } + + sym_gdr_pin_buffer = dlsym(gdrclib, "gdr_pin_buffer"); + if (sym_gdr_pin_buffer == NULL) { + fprintf(stderr, "Failed to load GDRCopy symbols\n"); + return -1; + } + + sym_gdr_unpin_buffer = dlsym(gdrclib, "gdr_unpin_buffer"); + if (sym_gdr_unpin_buffer == NULL) { + fprintf(stderr, "Failed to load GDRCopy symbols\n"); + return -1; + } + + sym_gdr_map = dlsym(gdrclib, "gdr_map"); + if (sym_gdr_map == NULL) { + fprintf(stderr, "Failed to load GDRCopy symbols\n"); + return -1; + } + + sym_gdr_unmap = dlsym(gdrclib, "gdr_unmap"); + if (sym_gdr_unmap == NULL) { + fprintf(stderr, "Failed to load GDRCopy symbols\n"); + return -1; + } + + return 0; +} + +int +gdrcopy_open(gdr_t *g) +{ +#ifdef DRIVERS_GPU_CUDA_GDRCOPY_H + gdr_t g_; + + g_ = sym_gdr_open(); + if (!g_) + return -1; + + *g = g_; +#else + *g = NULL; +#endif + return 0; +} + +int +gdrcopy_close(__rte_unused gdr_t *g) +{ +#ifdef DRIVERS_GPU_CUDA_GDRCOPY_H + sym_gdr_close(*g); +#endif + return 0; +} + +int +gdrcopy_pin(gdr_t g, __rte_unused gdr_mh_t *mh, uint64_t d_addr, size_t size, void **h_addr) +{ + if (g == NULL) + return -ENOTSUP; + +#ifdef DRIVERS_GPU_CUDA_GDRCOPY_H + /* Pin the device buffer */ + if (sym_gdr_pin_buffer(g, d_addr, size, 0, 0, mh) != 0) { + fprintf(stderr, "sym_gdr_pin_buffer\n"); + return -1; + } + + /* Map the buffer to user space */ + if (sym_gdr_map(g, *mh, h_addr, size) != 0) { + fprintf(stderr, "sym_gdr_map\n"); + sym_gdr_unpin_buffer(g, *mh); + return -1; + } +#endif + return 0; +} + +int +gdrcopy_unpin(gdr_t g, __rte_unused gdr_mh_t mh, void *d_addr, size_t size) +{ + if (g == NULL) + return -ENOTSUP; + +#ifdef DRIVERS_GPU_CUDA_GDRCOPY_H + /* Unmap the buffer from user space */ + if (sym_gdr_unmap(g, mh, d_addr, size) != 0) + fprintf(stderr, "sym_gdr_unmap\n"); + + /* Pin the device buffer */ + if (sym_gdr_unpin_buffer(g, mh) != 0) { + fprintf(stderr, "sym_gdr_pin_buffer\n"); + return -11; + } +#endif + return 0; +} diff --git a/drivers/gpu/cuda/gdrcopy.h b/drivers/gpu/cuda/gdrcopy.h new file mode 100644 index 0000000000..e5c1997731 --- /dev/null +++ b/drivers/gpu/cuda/gdrcopy.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2022 NVIDIA Corporation & Affiliates + */ + +#ifndef _CUDA_GDRCOPY_H_ +#define _CUDA_GDRCOPY_H_ + +#include + +#include +#include +#include + +#ifdef DRIVERS_GPU_CUDA_GDRCOPY_H + #include +#else + struct gdr; + typedef struct gdr *gdr_t; + struct gdr_mh_s; + typedef struct gdr_mh_s gdr_mh_t; +#endif + +int gdrcopy_loader(void); +int gdrcopy_open(gdr_t *g); +int gdrcopy_close(gdr_t *g); +int gdrcopy_pin(gdr_t g, gdr_mh_t *mh, uint64_t d_addr, size_t size, void **h_addr); +int gdrcopy_unpin(gdr_t g, gdr_mh_t mh, void *d_addr, size_t size); + +#endif diff --git a/drivers/gpu/cuda/meson.build b/drivers/gpu/cuda/meson.build index 3fe20929fa..784fa8bf0d 100644 --- a/drivers/gpu/cuda/meson.build +++ b/drivers/gpu/cuda/meson.build @@ -17,5 +17,9 @@ if not cc.has_header('cudaTypedefs.h') subdir_done() endif +if cc.has_header('gdrapi.h') + dpdk_conf.set('DRIVERS_GPU_CUDA_GDRCOPY_H', 1) +endif + deps += ['gpudev', 'pci', 'bus_pci'] -sources = files('cuda.c') +sources = files('cuda.c', 'gdrcopy.c')