nvdimm: convert "unarmed" into a static property
[qemu.git] / hw / rdma / rdma_utils.c
blobd713f635f1acdf4817544895d710a6974ef66d2a
1 /*
2 * QEMU paravirtual RDMA - Generic RDMA backend
4 * Copyright (C) 2018 Oracle
5 * Copyright (C) 2018 Red Hat Inc
7 * Authors:
8 * Yuval Shaia <yuval.shaia@oracle.com>
9 * Marcel Apfelbaum <marcel@redhat.com>
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.
16 #include "rdma_utils.h"
18 void *rdma_pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_addr_t plen)
20 void *p;
21 hwaddr len = plen;
23 if (!addr) {
24 pr_dbg("addr is NULL\n");
25 return NULL;
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%" PRIx64 ", len=%" PRId64 "\n",
31 addr, len);
32 return NULL;
35 if (len != plen) {
36 rdma_pci_dma_unmap(dev, p, len);
37 return NULL;
40 pr_dbg("0x%" PRIx64 " -> %p (len=% " PRId64 ")\n", addr, p, len);
42 return p;
45 void rdma_pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len)
47 pr_dbg("%p\n", buffer);
48 if (buffer) {
49 pci_dma_unmap(dev, buffer, len, DMA_DIRECTION_TO_DEVICE, 0);