]> git.proxmox.com Git - mirror_qemu.git/blame - hw/rdma/rdma_utils.c
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20181220' into staging
[mirror_qemu.git] / hw / rdma / rdma_utils.c
CommitLineData
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 <yuval.shaia@oracle.com>
9 * Marcel Apfelbaum <marcel@redhat.com>
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
b7d89466 16#include "qemu/osdep.h"
dcbf469a
YS
17#include "rdma_utils.h"
18
ef846e02
YS
19#ifdef PVRDMA_DEBUG
20unsigned long pr_dbg_cnt;
21#endif
22
dcbf469a
YS
23void *rdma_pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_addr_t plen)
24{
25 void *p;
26 hwaddr len = plen;
27
28 if (!addr) {
29 pr_dbg("addr is NULL\n");
30 return NULL;
31 }
32
33 p = pci_dma_map(dev, addr, &len, DMA_DIRECTION_TO_DEVICE);
34 if (!p) {
6f559013
YS
35 pr_dbg("Fail in pci_dma_map, addr=0x%" PRIx64 ", len=%" PRId64 "\n",
36 addr, len);
dcbf469a
YS
37 return NULL;
38 }
39
40 if (len != plen) {
41 rdma_pci_dma_unmap(dev, p, len);
42 return NULL;
43 }
44
6f559013 45 pr_dbg("0x%" PRIx64 " -> %p (len=% " PRId64 ")\n", addr, p, len);
dcbf469a
YS
46
47 return p;
48}
49
50void rdma_pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len)
51{
52 pr_dbg("%p\n", buffer);
53 if (buffer) {
54 pci_dma_unmap(dev, buffer, len, DMA_DIRECTION_TO_DEVICE, 0);
55 }
56}