scripts/qemu.py: introduce set_console() method
[qemu/ar7.git] / hw / rdma / rdma_backend.h
blob3cd636dd888caddbc41cebd82692a0d230ab8976
1 /*
2 * RDMA device: Definitions of Backend Device 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_BACKEND_H
17 #define RDMA_BACKEND_H
19 #include "qapi/error.h"
20 #include "rdma_rm_defs.h"
21 #include "rdma_backend_defs.h"
23 /* Add definition for QP0 and QP1 as there is no userspace enums for them */
24 enum ibv_special_qp_type {
25 IBV_QPT_SMI = 0,
26 IBV_QPT_GSI = 1,
29 static inline union ibv_gid *rdma_backend_gid(RdmaBackendDev *dev)
31 return &dev->gid;
34 static inline uint32_t rdma_backend_qpn(const RdmaBackendQP *qp)
36 return qp->ibqp ? qp->ibqp->qp_num : 0;
39 static inline uint32_t rdma_backend_mr_lkey(const RdmaBackendMR *mr)
41 return mr->ibmr ? mr->ibmr->lkey : 0;
44 static inline uint32_t rdma_backend_mr_rkey(const RdmaBackendMR *mr)
46 return mr->ibmr ? mr->ibmr->rkey : 0;
49 int rdma_backend_init(RdmaBackendDev *backend_dev,
50 RdmaDeviceResources *rdma_dev_res,
51 const char *backend_device_name, uint8_t port_num,
52 uint8_t backend_gid_idx, struct ibv_device_attr *dev_attr,
53 Error **errp);
54 void rdma_backend_fini(RdmaBackendDev *backend_dev);
55 void rdma_backend_register_comp_handler(void (*handler)(int status,
56 unsigned int vendor_err, void *ctx));
57 void rdma_backend_unregister_comp_handler(void);
59 int rdma_backend_query_port(RdmaBackendDev *backend_dev,
60 struct ibv_port_attr *port_attr);
61 int rdma_backend_create_pd(RdmaBackendDev *backend_dev, RdmaBackendPD *pd);
62 void rdma_backend_destroy_pd(RdmaBackendPD *pd);
64 int rdma_backend_create_mr(RdmaBackendMR *mr, RdmaBackendPD *pd, void *addr,
65 size_t length, int access);
66 void rdma_backend_destroy_mr(RdmaBackendMR *mr);
68 int rdma_backend_create_cq(RdmaBackendDev *backend_dev, RdmaBackendCQ *cq,
69 int cqe);
70 void rdma_backend_destroy_cq(RdmaBackendCQ *cq);
71 void rdma_backend_poll_cq(RdmaDeviceResources *rdma_dev_res, RdmaBackendCQ *cq);
73 int rdma_backend_create_qp(RdmaBackendQP *qp, uint8_t qp_type,
74 RdmaBackendPD *pd, RdmaBackendCQ *scq,
75 RdmaBackendCQ *rcq, uint32_t max_send_wr,
76 uint32_t max_recv_wr, uint32_t max_send_sge,
77 uint32_t max_recv_sge);
78 int rdma_backend_qp_state_init(RdmaBackendDev *backend_dev, RdmaBackendQP *qp,
79 uint8_t qp_type, uint32_t qkey);
80 int rdma_backend_qp_state_rtr(RdmaBackendDev *backend_dev, RdmaBackendQP *qp,
81 uint8_t qp_type, union ibv_gid *dgid,
82 uint32_t dqpn, uint32_t rq_psn, uint32_t qkey,
83 bool use_qkey);
84 int rdma_backend_qp_state_rts(RdmaBackendQP *qp, uint8_t qp_type,
85 uint32_t sq_psn, uint32_t qkey, bool use_qkey);
86 int rdma_backend_query_qp(RdmaBackendQP *qp, struct ibv_qp_attr *attr,
87 int attr_mask, struct ibv_qp_init_attr *init_attr);
88 void rdma_backend_destroy_qp(RdmaBackendQP *qp);
90 void rdma_backend_post_send(RdmaBackendDev *backend_dev,
91 RdmaBackendQP *qp, uint8_t qp_type,
92 struct ibv_sge *sge, uint32_t num_sge,
93 union ibv_gid *dgid, uint32_t dqpn, uint32_t dqkey,
94 void *ctx);
95 void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
96 RdmaDeviceResources *rdma_dev_res,
97 RdmaBackendQP *qp, uint8_t qp_type,
98 struct ibv_sge *sge, uint32_t num_sge, void *ctx);
100 #endif