]>
Commit | Line | Data |
---|---|---|
dcbf469a YS |
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 | void *rdma_pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_addr_t plen) | |
19 | { | |
20 | void *p; | |
21 | hwaddr len = plen; | |
22 | ||
23 | if (!addr) { | |
24 | pr_dbg("addr is NULL\n"); | |
25 | return NULL; | |
26 | } | |
27 | ||
28 | p = pci_dma_map(dev, addr, &len, DMA_DIRECTION_TO_DEVICE); | |
29 | if (!p) { | |
30 | pr_dbg("Fail in pci_dma_map, addr=0x%llx, len=%ld\n", | |
31 | (long long unsigned int)addr, len); | |
32 | return NULL; | |
33 | } | |
34 | ||
35 | if (len != plen) { | |
36 | rdma_pci_dma_unmap(dev, p, len); | |
37 | return NULL; | |
38 | } | |
39 | ||
40 | pr_dbg("0x%llx -> %p (len=%ld)\n", (long long unsigned int)addr, p, len); | |
41 | ||
42 | return p; | |
43 | } | |
44 | ||
45 | void rdma_pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len) | |
46 | { | |
47 | pr_dbg("%p\n", buffer); | |
48 | if (buffer) { | |
49 | pci_dma_unmap(dev, buffer, len, DMA_DIRECTION_TO_DEVICE, 0); | |
50 | } | |
51 | } |