2 * RDMA device: Definitions of Resource Manager structures
4 * Copyright (C) 2018 Oracle
5 * Copyright (C) 2018 Red Hat Inc
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
27 #define MAX_MR_SIZE (1UL << 27)
33 #define MAX_QP_RD_ATOM 16
34 #define MAX_QP_INIT_RD_ATOM 16
38 #define MAX_RM_TBL_NAME 16
39 #define MAX_CONSEQ_EMPTY_POLL_CQ 4096 /* considered as error above this */
41 typedef struct RdmaRmResTbl {
42 char name[MAX_RM_TBL_NAME];
44 unsigned long *bitmap;
48 uint32_t used; /* number of used entries in the table */
51 typedef struct RdmaRmPD {
52 RdmaBackendPD backend_pd;
56 typedef enum CQNotificationType {
62 typedef struct RdmaRmCQ {
63 RdmaBackendCQ backend_cq;
65 CQNotificationType notify;
69 typedef struct RdmaRmMR {
70 RdmaBackendMR backend_mr;
79 typedef struct RdmaRmUC {
83 typedef struct RdmaRmQP {
84 RdmaBackendQP backend_qp;
88 uint32_t send_cq_handle;
89 uint32_t recv_cq_handle;
90 enum ibv_qp_state qp_state;
94 typedef struct RdmaRmSRQ {
95 RdmaBackendSRQ backend_srq;
96 uint32_t recv_cq_handle;
100 typedef struct RdmaRmGid {
102 int backend_gid_index;
105 typedef struct RdmaRmPort {
106 RdmaRmGid gid_tbl[MAX_PORT_GIDS];
107 enum ibv_port_state state;
110 typedef struct RdmaRmStats {
115 uint64_t rx_bufs_len;
116 uint64_t rx_bufs_err;
118 uint64_t completions;
123 uint64_t mad_rx_bufs;
124 uint64_t mad_rx_bufs_err;
125 uint64_t poll_cq_from_bk;
126 uint64_t poll_cq_from_guest;
127 uint64_t poll_cq_from_guest_empty;
128 uint64_t poll_cq_ppoll_to;
129 uint32_t missing_cqe;
132 struct RdmaDeviceResources {
139 RdmaRmResTbl cqe_ctx_tbl;
140 RdmaRmResTbl srq_tbl;
141 GHashTable *qp_hash; /* Keeps mapping between real and emulated */