blob: 0b55be35038d6d09f90a2538415fbf65168ac051 [file] [log] [blame]
Yuval Shaiab3a92272018-02-09 15:00:59 +02001/*
2 * RDMA device: Definitions of Backend Device structures
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
16#ifndef RDMA_BACKEND_DEFS_H
17#define RDMA_BACKEND_DEFS_H
18
Michael S. Tsirkin0efc9512018-03-21 17:22:07 +020019#include "qemu/thread.h"
Yuval Shaia605ec162018-12-21 16:40:19 +020020#include "chardev/char-fe.h"
21#include <infiniband/verbs.h>
Yuval Shaia2b057052018-12-21 16:40:25 +020022#include "contrib/rdmacm-mux/rdmacm-mux.h"
Yuval Shaiab20fc792019-03-11 03:29:06 -070023#include "rdma_utils.h"
Yuval Shaiab3a92272018-02-09 15:00:59 +020024
25typedef struct RdmaDeviceResources RdmaDeviceResources;
26
27typedef struct RdmaBackendThread {
28 QemuThread thread;
Yuval Shaia75152222018-08-05 18:35:06 +030029 bool run; /* Set by thread manager to let thread know it should exit */
30 bool is_running; /* Set by the thread to report its status */
Yuval Shaiab3a92272018-02-09 15:00:59 +020031} RdmaBackendThread;
32
Yuval Shaia2b057052018-12-21 16:40:25 +020033typedef struct RdmaCmMux {
34 CharBackend *chr_be;
35 int can_receive;
36} RdmaCmMux;
37
Yuval Shaiab3a92272018-02-09 15:00:59 +020038typedef struct RdmaBackendDev {
Yuval Shaiab3a92272018-02-09 15:00:59 +020039 RdmaBackendThread comp_thread;
Yuval Shaiab3a92272018-02-09 15:00:59 +020040 PCIDevice *dev;
41 RdmaDeviceResources *rdma_dev_res;
42 struct ibv_device *ib_dev;
43 struct ibv_context *context;
44 struct ibv_comp_channel *channel;
45 uint8_t port_num;
Yuval Shaiab20fc792019-03-11 03:29:06 -070046 RdmaProtectedQList recv_mads_list;
Yuval Shaia2b057052018-12-21 16:40:25 +020047 RdmaCmMux rdmacm_mux;
Yuval Shaiab3a92272018-02-09 15:00:59 +020048} RdmaBackendDev;
49
50typedef struct RdmaBackendPD {
51 struct ibv_pd *ibpd;
52} RdmaBackendPD;
53
54typedef struct RdmaBackendMR {
55 struct ibv_pd *ibpd;
56 struct ibv_mr *ibmr;
57} RdmaBackendMR;
58
59typedef struct RdmaBackendCQ {
60 RdmaBackendDev *backend_dev;
61 struct ibv_cq *ibcq;
62} RdmaBackendCQ;
63
64typedef struct RdmaBackendQP {
65 struct ibv_pd *ibpd;
66 struct ibv_qp *ibqp;
Yuval Shaia2b057052018-12-21 16:40:25 +020067 uint8_t sgid_idx;
Yuval Shaiabf441452019-03-11 03:29:11 -070068 RdmaProtectedGSList cqe_ctx_list;
Yuval Shaiab3a92272018-02-09 15:00:59 +020069} RdmaBackendQP;
70
Kamal Heibe926c9f2019-04-03 14:33:40 +030071typedef struct RdmaBackendSRQ {
72 struct ibv_srq *ibsrq;
73 RdmaProtectedGSList cqe_ctx_list;
74} RdmaBackendSRQ;
75
Yuval Shaiab3a92272018-02-09 15:00:59 +020076#endif