blockjob: Propagate AioContext change to all job nodes
[qemu/ar7.git] / hw / rdma / rdma_rm.h
blobe8639909cd344f54e2808846a7e095c98ed64f58
1 /*
2 * RDMA device: Definitions of Resource Manager functions
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 #ifndef RDMA_RM_H
17 #define RDMA_RM_H
19 #include "qapi/error.h"
20 #include "rdma_backend_defs.h"
21 #include "rdma_rm_defs.h"
23 int rdma_rm_init(RdmaDeviceResources *dev_res,
24 struct ibv_device_attr *dev_attr);
25 void rdma_rm_fini(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev,
26 const char *ifname);
28 int rdma_rm_alloc_pd(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev,
29 uint32_t *pd_handle, uint32_t ctx_handle);
30 RdmaRmPD *rdma_rm_get_pd(RdmaDeviceResources *dev_res, uint32_t pd_handle);
31 void rdma_rm_dealloc_pd(RdmaDeviceResources *dev_res, uint32_t pd_handle);
33 int rdma_rm_alloc_mr(RdmaDeviceResources *dev_res, uint32_t pd_handle,
34 uint64_t guest_start, uint64_t guest_length,
35 void *host_virt, int access_flags, uint32_t *mr_handle,
36 uint32_t *lkey, uint32_t *rkey);
37 RdmaRmMR *rdma_rm_get_mr(RdmaDeviceResources *dev_res, uint32_t mr_handle);
38 void rdma_rm_dealloc_mr(RdmaDeviceResources *dev_res, uint32_t mr_handle);
40 int rdma_rm_alloc_uc(RdmaDeviceResources *dev_res, uint32_t pfn,
41 uint32_t *uc_handle);
42 RdmaRmUC *rdma_rm_get_uc(RdmaDeviceResources *dev_res, uint32_t uc_handle);
43 void rdma_rm_dealloc_uc(RdmaDeviceResources *dev_res, uint32_t uc_handle);
45 int rdma_rm_alloc_cq(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev,
46 uint32_t cqe, uint32_t *cq_handle, void *opaque);
47 RdmaRmCQ *rdma_rm_get_cq(RdmaDeviceResources *dev_res, uint32_t cq_handle);
48 void rdma_rm_req_notify_cq(RdmaDeviceResources *dev_res, uint32_t cq_handle,
49 bool notify);
50 void rdma_rm_dealloc_cq(RdmaDeviceResources *dev_res, uint32_t cq_handle);
52 int rdma_rm_alloc_qp(RdmaDeviceResources *dev_res, uint32_t pd_handle,
53 uint8_t qp_type, uint32_t max_send_wr,
54 uint32_t max_send_sge, uint32_t send_cq_handle,
55 uint32_t max_recv_wr, uint32_t max_recv_sge,
56 uint32_t recv_cq_handle, void *opaque, uint32_t *qpn,
57 uint8_t is_srq, uint32_t srq_handle);
58 RdmaRmQP *rdma_rm_get_qp(RdmaDeviceResources *dev_res, uint32_t qpn);
59 int rdma_rm_modify_qp(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev,
60 uint32_t qp_handle, uint32_t attr_mask, uint8_t sgid_idx,
61 union ibv_gid *dgid, uint32_t dqpn,
62 enum ibv_qp_state qp_state, uint32_t qkey,
63 uint32_t rq_psn, uint32_t sq_psn);
64 int rdma_rm_query_qp(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev,
65 uint32_t qp_handle, struct ibv_qp_attr *attr,
66 int attr_mask, struct ibv_qp_init_attr *init_attr);
67 void rdma_rm_dealloc_qp(RdmaDeviceResources *dev_res, uint32_t qp_handle);
69 RdmaRmSRQ *rdma_rm_get_srq(RdmaDeviceResources *dev_res, uint32_t srq_handle);
70 int rdma_rm_alloc_srq(RdmaDeviceResources *dev_res, uint32_t pd_handle,
71 uint32_t max_wr, uint32_t max_sge, uint32_t srq_limit,
72 uint32_t *srq_handle, void *opaque);
73 int rdma_rm_query_srq(RdmaDeviceResources *dev_res, uint32_t srq_handle,
74 struct ibv_srq_attr *srq_attr);
75 int rdma_rm_modify_srq(RdmaDeviceResources *dev_res, uint32_t srq_handle,
76 struct ibv_srq_attr *srq_attr, int srq_attr_mask);
77 void rdma_rm_dealloc_srq(RdmaDeviceResources *dev_res, uint32_t srq_handle);
79 int rdma_rm_alloc_cqe_ctx(RdmaDeviceResources *dev_res, uint32_t *cqe_ctx_id,
80 void *ctx);
81 void *rdma_rm_get_cqe_ctx(RdmaDeviceResources *dev_res, uint32_t cqe_ctx_id);
82 void rdma_rm_dealloc_cqe_ctx(RdmaDeviceResources *dev_res, uint32_t cqe_ctx_id);
84 int rdma_rm_add_gid(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev,
85 const char *ifname, union ibv_gid *gid, int gid_idx);
86 int rdma_rm_del_gid(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev,
87 const char *ifname, int gid_idx);
88 int rdma_rm_get_backend_gid_index(RdmaDeviceResources *dev_res,
89 RdmaBackendDev *backend_dev, int sgid_idx);
90 static inline union ibv_gid *rdma_rm_get_gid(RdmaDeviceResources *dev_res,
91 int sgid_idx)
93 return &dev_res->port.gid_tbl[sgid_idx].gid;
95 void rdma_dump_device_counters(Monitor *mon, RdmaDeviceResources *dev_res);
97 #endif