linux-user: rename gettid() to sys_gettid() to avoid clash with glibc
[qemu/ar7.git] / hw / rdma / rdma_rm_defs.h
blobc200d311de3751e87594a04eede9a6dde012c4eb
1 /*
2 * RDMA device: Definitions of Resource Manager structures
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_DEFS_H
17 #define RDMA_RM_DEFS_H
19 #include "rdma_backend_defs.h"
21 #define MAX_PORTS 1 /* Do not change - we support only one port */
22 #define MAX_PORT_GIDS 255
23 #define MAX_GIDS MAX_PORT_GIDS
24 #define MAX_PORT_PKEYS 1
25 #define MAX_PKEYS MAX_PORT_PKEYS
26 #define MAX_UCS 512
27 #define MAX_MR_SIZE (1UL << 27)
28 #define MAX_QP 1024
29 #define MAX_SGE 4
30 #define MAX_CQ 2048
31 #define MAX_MR 1024
32 #define MAX_PD 1024
33 #define MAX_QP_RD_ATOM 16
34 #define MAX_QP_INIT_RD_ATOM 16
35 #define MAX_AH 64
37 #define MAX_RM_TBL_NAME 16
38 #define MAX_CONSEQ_EMPTY_POLL_CQ 4096 /* considered as error above this */
40 typedef struct RdmaRmResTbl {
41 char name[MAX_RM_TBL_NAME];
42 QemuMutex lock;
43 unsigned long *bitmap;
44 size_t tbl_sz;
45 size_t res_sz;
46 void *tbl;
47 uint32_t used; /* number of used entries in the table */
48 } RdmaRmResTbl;
50 typedef struct RdmaRmPD {
51 RdmaBackendPD backend_pd;
52 uint32_t ctx_handle;
53 } RdmaRmPD;
55 typedef enum CQNotificationType {
56 CNT_CLEAR,
57 CNT_ARM,
58 CNT_SET,
59 } CQNotificationType;
61 typedef struct RdmaRmCQ {
62 RdmaBackendCQ backend_cq;
63 void *opaque;
64 CQNotificationType notify;
65 } RdmaRmCQ;
67 /* MR (DMA region) */
68 typedef struct RdmaRmMR {
69 RdmaBackendMR backend_mr;
70 void *virt;
71 uint64_t start;
72 size_t length;
73 uint32_t pd_handle;
74 uint32_t lkey;
75 uint32_t rkey;
76 } RdmaRmMR;
78 typedef struct RdmaRmUC {
79 uint64_t uc_handle;
80 } RdmaRmUC;
82 typedef struct RdmaRmQP {
83 RdmaBackendQP backend_qp;
84 void *opaque;
85 uint32_t qp_type;
86 uint32_t qpn;
87 uint32_t send_cq_handle;
88 uint32_t recv_cq_handle;
89 enum ibv_qp_state qp_state;
90 } RdmaRmQP;
92 typedef struct RdmaRmGid {
93 union ibv_gid gid;
94 int backend_gid_index;
95 } RdmaRmGid;
97 typedef struct RdmaRmPort {
98 RdmaRmGid gid_tbl[MAX_PORT_GIDS];
99 enum ibv_port_state state;
100 } RdmaRmPort;
102 typedef struct RdmaRmStats {
103 uint64_t tx;
104 uint64_t tx_len;
105 uint64_t tx_err;
106 uint64_t rx_bufs;
107 uint64_t rx_bufs_len;
108 uint64_t rx_bufs_err;
109 uint64_t completions;
110 uint64_t mad_tx;
111 uint64_t mad_tx_err;
112 uint64_t mad_rx;
113 uint64_t mad_rx_err;
114 uint64_t mad_rx_bufs;
115 uint64_t mad_rx_bufs_err;
116 uint64_t poll_cq_from_bk;
117 uint64_t poll_cq_from_guest;
118 uint64_t poll_cq_from_guest_empty;
119 uint64_t poll_cq_ppoll_to;
120 uint32_t missing_cqe;
121 } RdmaRmStats;
123 struct RdmaDeviceResources {
124 RdmaRmPort port;
125 RdmaRmResTbl pd_tbl;
126 RdmaRmResTbl mr_tbl;
127 RdmaRmResTbl uc_tbl;
128 RdmaRmResTbl qp_tbl;
129 RdmaRmResTbl cq_tbl;
130 RdmaRmResTbl cqe_ctx_tbl;
131 GHashTable *qp_hash; /* Keeps mapping between real and emulated */
132 QemuMutex lock;
133 RdmaRmStats stats;
136 #endif