]> Git Repo - qemu.git/blob - hw/rdma/rdma_utils.c
Merge remote-tracking branch 'remotes/marcel/tags/rdma-pull-request' into staging
[qemu.git] / hw / rdma / rdma_utils.c
1 /*
2  * QEMU paravirtual RDMA - Generic RDMA backend
3  *
4  * Copyright (C) 2018 Oracle
5  * Copyright (C) 2018 Red Hat Inc
6  *
7  * Authors:
8  *     Yuval Shaia <[email protected]>
9  *     Marcel Apfelbaum <[email protected]>
10  *
11  * This work is licensed under the terms of the GNU GPL, version 2 or later.
12  * See the COPYING file in the top-level directory.
13  *
14  */
15
16 #include "rdma_utils.h"
17
18 #ifdef PVRDMA_DEBUG
19 unsigned long pr_dbg_cnt;
20 #endif
21
22 void *rdma_pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_addr_t plen)
23 {
24     void *p;
25     hwaddr len = plen;
26
27     if (!addr) {
28         pr_dbg("addr is NULL\n");
29         return NULL;
30     }
31
32     p = pci_dma_map(dev, addr, &len, DMA_DIRECTION_TO_DEVICE);
33     if (!p) {
34         pr_dbg("Fail in pci_dma_map, addr=0x%" PRIx64 ", len=%" PRId64 "\n",
35                addr, len);
36         return NULL;
37     }
38
39     if (len != plen) {
40         rdma_pci_dma_unmap(dev, p, len);
41         return NULL;
42     }
43
44     pr_dbg("0x%" PRIx64 " -> %p (len=% " PRId64 ")\n", addr, p, len);
45
46     return p;
47 }
48
49 void rdma_pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len)
50 {
51     pr_dbg("%p\n", buffer);
52     if (buffer) {
53         pci_dma_unmap(dev, buffer, len, DMA_DIRECTION_TO_DEVICE, 0);
54     }
55 }
This page took 0.026957 seconds and 4 git commands to generate.