From c99f217431fa926003f015b83e60d5de72305388 Mon Sep 17 00:00:00 2001 From: Yuval Shaia Date: Tue, 20 Mar 2018 21:00:22 +0200 Subject: hw/rdma: Add Query QP operation This operation is needed by rdma devices - implement it. Signed-off-by: Yuval Shaia Reviewed-by: Marcel Apfelbaum Signed-off-by: Marcel Apfelbaum --- hw/rdma/rdma_backend.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'hw/rdma/rdma_backend.h') diff --git a/hw/rdma/rdma_backend.h b/hw/rdma/rdma_backend.h index 68f2b05ca7..36218d1990 100644 --- a/hw/rdma/rdma_backend.h +++ b/hw/rdma/rdma_backend.h @@ -83,6 +83,8 @@ int rdma_backend_qp_state_rtr(RdmaBackendDev *backend_dev, RdmaBackendQP *qp, bool use_qkey); int rdma_backend_qp_state_rts(RdmaBackendQP *qp, uint8_t qp_type, uint32_t sq_psn, uint32_t qkey, bool use_qkey); +int rdma_backend_query_qp(RdmaBackendQP *qp, struct ibv_qp_attr *attr, + int attr_mask, struct ibv_qp_init_attr *init_attr); void rdma_backend_destroy_qp(RdmaBackendQP *qp); void rdma_backend_post_send(RdmaBackendDev *backend_dev, -- cgit 1.4.1 From 0efc9511aaa1bacb9dd9868a5f463180af5aa782 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 21 Mar 2018 17:22:07 +0200 Subject: rdma: fix up include directives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our rule right now is to use <> for external headers only. RDMA code violates that, fix it up. Signed-off-by: Michael S. Tsirkin Reviewed-by: Daniel P. Berrangé Reviewed-by: Marcel Apfelbaum Signed-off-by: Marcel Apfelbaum --- hw/rdma/rdma_backend.c | 6 +++--- hw/rdma/rdma_backend.h | 2 +- hw/rdma/rdma_backend_defs.h | 2 +- hw/rdma/rdma_rm.c | 6 +++--- hw/rdma/rdma_rm.h | 2 +- hw/rdma/rdma_utils.h | 6 +++--- hw/rdma/vmw/pvrdma.h | 8 ++++---- hw/rdma/vmw/pvrdma_cmd.c | 8 ++++---- hw/rdma/vmw/pvrdma_dev_ring.c | 8 ++++---- hw/rdma/vmw/pvrdma_dev_ring.h | 2 +- hw/rdma/vmw/pvrdma_main.c | 24 ++++++++++++------------ hw/rdma/vmw/pvrdma_qp_ops.c | 4 ++-- 12 files changed, 39 insertions(+), 39 deletions(-) (limited to 'hw/rdma/rdma_backend.h') diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c index 0beed77c27..57f40d99a3 100644 --- a/hw/rdma/rdma_backend.c +++ b/hw/rdma/rdma_backend.c @@ -13,9 +13,9 @@ * */ -#include -#include -#include +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "qapi/error.h" #include diff --git a/hw/rdma/rdma_backend.h b/hw/rdma/rdma_backend.h index 36218d1990..505cad7e0e 100644 --- a/hw/rdma/rdma_backend.h +++ b/hw/rdma/rdma_backend.h @@ -16,7 +16,7 @@ #ifndef RDMA_BACKEND_H #define RDMA_BACKEND_H -#include +#include "qapi/error.h" #include "rdma_rm_defs.h" #include "rdma_backend_defs.h" diff --git a/hw/rdma/rdma_backend_defs.h b/hw/rdma/rdma_backend_defs.h index 837e32419c..ff5cfc26eb 100644 --- a/hw/rdma/rdma_backend_defs.h +++ b/hw/rdma/rdma_backend_defs.h @@ -17,7 +17,7 @@ #define RDMA_BACKEND_DEFS_H #include -#include +#include "qemu/thread.h" typedef struct RdmaDeviceResources RdmaDeviceResources; diff --git a/hw/rdma/rdma_rm.c b/hw/rdma/rdma_rm.c index 43f73adecf..6d88ac5d23 100644 --- a/hw/rdma/rdma_rm.c +++ b/hw/rdma/rdma_rm.c @@ -13,9 +13,9 @@ * */ -#include -#include -#include +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "cpu.h" #include "rdma_utils.h" #include "rdma_backend.h" diff --git a/hw/rdma/rdma_rm.h b/hw/rdma/rdma_rm.h index 0528c1972b..b4e04cc7b4 100644 --- a/hw/rdma/rdma_rm.h +++ b/hw/rdma/rdma_rm.h @@ -16,7 +16,7 @@ #ifndef RDMA_RM_H #define RDMA_RM_H -#include +#include "qapi/error.h" #include "rdma_backend_defs.h" #include "rdma_rm_defs.h" diff --git a/hw/rdma/rdma_utils.h b/hw/rdma/rdma_utils.h index cdac910e24..3dc07891bc 100644 --- a/hw/rdma/rdma_utils.h +++ b/hw/rdma/rdma_utils.h @@ -17,9 +17,9 @@ #ifndef RDMA_UTILS_H #define RDMA_UTILS_H -#include -#include -#include +#include "qemu/osdep.h" +#include "hw/pci/pci.h" +#include "sysemu/dma.h" #define pr_info(fmt, ...) \ fprintf(stdout, "%s: %-20s (%3d): " fmt, "pvrdma", __func__, __LINE__,\ diff --git a/hw/rdma/vmw/pvrdma.h b/hw/rdma/vmw/pvrdma.h index b05f94a473..8c173cb824 100644 --- a/hw/rdma/vmw/pvrdma.h +++ b/hw/rdma/vmw/pvrdma.h @@ -16,14 +16,14 @@ #ifndef PVRDMA_PVRDMA_H #define PVRDMA_PVRDMA_H -#include -#include +#include "hw/pci/pci.h" +#include "hw/pci/msix.h" #include "../rdma_backend_defs.h" #include "../rdma_rm_defs.h" -#include -#include +#include "standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h" +#include "standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h" #include "pvrdma_dev_ring.h" /* BARs */ diff --git a/hw/rdma/vmw/pvrdma_cmd.c b/hw/rdma/vmw/pvrdma_cmd.c index cf8c50af31..0646f87ff2 100644 --- a/hw/rdma/vmw/pvrdma_cmd.c +++ b/hw/rdma/vmw/pvrdma_cmd.c @@ -13,9 +13,9 @@ * */ -#include -#include -#include +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "cpu.h" #include #include "hw/hw.h" #include "hw/pci/pci.h" @@ -26,7 +26,7 @@ #include "../rdma_utils.h" #include "pvrdma.h" -#include +#include "standard-headers/rdma/vmw_pvrdma-abi.h" static void *pvrdma_map_to_pdir(PCIDevice *pdev, uint64_t pdir_dma, uint32_t nchunks, size_t length) diff --git a/hw/rdma/vmw/pvrdma_dev_ring.c b/hw/rdma/vmw/pvrdma_dev_ring.c index ec309dad55..ff19a9ea16 100644 --- a/hw/rdma/vmw/pvrdma_dev_ring.c +++ b/hw/rdma/vmw/pvrdma_dev_ring.c @@ -13,12 +13,12 @@ * */ -#include -#include -#include +#include "qemu/osdep.h" +#include "hw/pci/pci.h" +#include "cpu.h" #include "../rdma_utils.h" -#include +#include "standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h" #include "pvrdma_dev_ring.h" int pvrdma_ring_init(PvrdmaRing *ring, const char *name, PCIDevice *dev, diff --git a/hw/rdma/vmw/pvrdma_dev_ring.h b/hw/rdma/vmw/pvrdma_dev_ring.h index 02a590b86d..2d0461f367 100644 --- a/hw/rdma/vmw/pvrdma_dev_ring.h +++ b/hw/rdma/vmw/pvrdma_dev_ring.h @@ -16,7 +16,7 @@ #ifndef PVRDMA_DEV_RING_H #define PVRDMA_DEV_RING_H -#include +#include "qemu/typedefs.h" #define MAX_RING_NAME_SZ 32 diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c index 99787812ba..25ea02af62 100644 --- a/hw/rdma/vmw/pvrdma_main.c +++ b/hw/rdma/vmw/pvrdma_main.c @@ -13,16 +13,16 @@ * */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/hw.h" +#include "hw/pci/pci.h" +#include "hw/pci/pci_ids.h" +#include "hw/pci/msi.h" +#include "hw/pci/msix.h" +#include "hw/qdev-core.h" +#include "hw/qdev-properties.h" +#include "cpu.h" #include "trace.h" #include "../rdma_rm.h" @@ -31,8 +31,8 @@ #include #include "pvrdma.h" -#include -#include +#include "standard-headers/rdma/vmw_pvrdma-abi.h" +#include "standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h" #include "pvrdma_qp_ops.h" static Property pvrdma_dev_properties[] = { diff --git a/hw/rdma/vmw/pvrdma_qp_ops.c b/hw/rdma/vmw/pvrdma_qp_ops.c index f0a1f9eb02..a693c06a11 100644 --- a/hw/rdma/vmw/pvrdma_qp_ops.c +++ b/hw/rdma/vmw/pvrdma_qp_ops.c @@ -13,14 +13,14 @@ * */ -#include +#include "qemu/osdep.h" #include "../rdma_utils.h" #include "../rdma_rm.h" #include "../rdma_backend.h" #include "pvrdma.h" -#include +#include "standard-headers/rdma/vmw_pvrdma-abi.h" #include "pvrdma_qp_ops.h" typedef struct CompHandlerCtx { -- cgit 1.4.1 From 9bbb8d3577fe302802bfc7e4cf832a39aaa75692 Mon Sep 17 00:00:00 2001 From: Yuval Shaia Date: Thu, 22 Mar 2018 11:52:18 +0200 Subject: hw/rdma: Change host_virt to void * MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To avoid compilation warnings on 32-bit machines: rdma_backend.c: In function 'rdma_backend_create_mr': rdma_backend.c:409:37: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] mr->ibmr = ibv_reg_mr(pd->ibpd, (void *)addr, length, access); Reported-by: Eric Blake Signed-off-by: Yuval Shaia Reviewed-by: Eric Blake Tested-by: Eric Blake Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20180322095220.9976-2-yuval.shaia@oracle.com> Signed-off-by: Marcel Apfelbaum --- hw/rdma/rdma_backend.c | 8 ++++---- hw/rdma/rdma_backend.h | 2 +- hw/rdma/rdma_rm.c | 10 +++++----- hw/rdma/rdma_rm_defs.h | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'hw/rdma/rdma_backend.h') diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c index 57f40d99a3..b1d2913b2c 100644 --- a/hw/rdma/rdma_backend.c +++ b/hw/rdma/rdma_backend.c @@ -222,7 +222,7 @@ static int build_host_sge_array(RdmaDeviceResources *rdma_dev_res, return VENDOR_ERR_INVLKEY | ssge[ssge_idx].lkey; } - dsge->addr = mr->user_mr.host_virt + ssge[ssge_idx].addr - + dsge->addr = (uintptr_t)mr->user_mr.host_virt + ssge[ssge_idx].addr - mr->user_mr.guest_start; dsge->length = ssge[ssge_idx].length; dsge->lkey = rdma_backend_mr_lkey(&mr->backend_mr); @@ -401,12 +401,12 @@ void rdma_backend_destroy_pd(RdmaBackendPD *pd) } } -int rdma_backend_create_mr(RdmaBackendMR *mr, RdmaBackendPD *pd, uint64_t addr, +int rdma_backend_create_mr(RdmaBackendMR *mr, RdmaBackendPD *pd, void *addr, size_t length, int access) { - pr_dbg("addr=0x%lx\n", addr); + pr_dbg("addr=0x%p\n", addr); pr_dbg("len=%ld\n", length); - mr->ibmr = ibv_reg_mr(pd->ibpd, (void *)addr, length, access); + mr->ibmr = ibv_reg_mr(pd->ibpd, addr, length, access); if (mr->ibmr) { pr_dbg("lkey=0x%x\n", mr->ibmr->lkey); pr_dbg("rkey=0x%x\n", mr->ibmr->rkey); diff --git a/hw/rdma/rdma_backend.h b/hw/rdma/rdma_backend.h index 505cad7e0e..3cd636dd88 100644 --- a/hw/rdma/rdma_backend.h +++ b/hw/rdma/rdma_backend.h @@ -61,7 +61,7 @@ int rdma_backend_query_port(RdmaBackendDev *backend_dev, int rdma_backend_create_pd(RdmaBackendDev *backend_dev, RdmaBackendPD *pd); void rdma_backend_destroy_pd(RdmaBackendPD *pd); -int rdma_backend_create_mr(RdmaBackendMR *mr, RdmaBackendPD *pd, uint64_t addr, +int rdma_backend_create_mr(RdmaBackendMR *mr, RdmaBackendPD *pd, void *addr, size_t length, int access); void rdma_backend_destroy_mr(RdmaBackendMR *mr); diff --git a/hw/rdma/rdma_rm.c b/hw/rdma/rdma_rm.c index 6d88ac5d23..b4938169b6 100644 --- a/hw/rdma/rdma_rm.c +++ b/hw/rdma/rdma_rm.c @@ -146,7 +146,7 @@ int rdma_rm_alloc_mr(RdmaDeviceResources *dev_res, uint32_t pd_handle, RdmaRmMR *mr; int ret = 0; RdmaRmPD *pd; - uint64_t addr; + void *addr; size_t length; pd = rdma_rm_get_pd(dev_res, pd_handle); @@ -165,10 +165,10 @@ int rdma_rm_alloc_mr(RdmaDeviceResources *dev_res, uint32_t pd_handle, /* TODO: This is my guess but not so sure that this needs to be * done */ length = TARGET_PAGE_SIZE; - addr = (uint64_t)g_malloc(length); + addr = g_malloc(length); } else { - mr->user_mr.host_virt = (uint64_t) host_virt; - pr_dbg("host_virt=0x%lx\n", mr->user_mr.host_virt); + mr->user_mr.host_virt = host_virt; + pr_dbg("host_virt=0x%p\n", mr->user_mr.host_virt); mr->user_mr.length = guest_length; pr_dbg("length=0x%lx\n", guest_length); mr->user_mr.guest_start = guest_start; @@ -216,7 +216,7 @@ void rdma_rm_dealloc_mr(RdmaDeviceResources *dev_res, uint32_t mr_handle) if (mr) { rdma_backend_destroy_mr(&mr->backend_mr); - munmap((void *)mr->user_mr.host_virt, mr->user_mr.length); + munmap(mr->user_mr.host_virt, mr->user_mr.length); res_tbl_dealloc(&dev_res->mr_tbl, mr_handle); } } diff --git a/hw/rdma/rdma_rm_defs.h b/hw/rdma/rdma_rm_defs.h index 6522dca68f..fc646da61f 100644 --- a/hw/rdma/rdma_rm_defs.h +++ b/hw/rdma/rdma_rm_defs.h @@ -56,7 +56,7 @@ typedef struct RdmaRmCQ { } RdmaRmCQ; typedef struct RdmaRmUserMR { - uint64_t host_virt; + void *host_virt; uint64_t guest_start; size_t length; } RdmaRmUserMR; -- cgit 1.4.1