2018-02-09 16:00:59 +03:00
|
|
|
/*
|
|
|
|
* RDMA device: Definitions of Resource Manager structures
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Oracle
|
|
|
|
* Copyright (C) 2018 Red Hat Inc
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Yuval Shaia <yuval.shaia@oracle.com>
|
|
|
|
* Marcel Apfelbaum <marcel@redhat.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RDMA_RM_DEFS_H
|
|
|
|
#define RDMA_RM_DEFS_H
|
|
|
|
|
|
|
|
#include "rdma_backend_defs.h"
|
|
|
|
|
2018-12-21 17:40:32 +03:00
|
|
|
#define MAX_PORTS 1 /* Do not change - we support only one port */
|
2018-12-21 17:40:25 +03:00
|
|
|
#define MAX_PORT_GIDS 255
|
2018-04-30 23:02:20 +03:00
|
|
|
#define MAX_GIDS MAX_PORT_GIDS
|
2018-02-09 16:00:59 +03:00
|
|
|
#define MAX_PORT_PKEYS 1
|
2018-04-30 23:02:19 +03:00
|
|
|
#define MAX_PKEYS MAX_PORT_PKEYS
|
2018-02-09 16:00:59 +03:00
|
|
|
#define MAX_UCS 512
|
|
|
|
#define MAX_MR_SIZE (1UL << 27)
|
|
|
|
#define MAX_QP 1024
|
|
|
|
#define MAX_SGE 4
|
|
|
|
#define MAX_CQ 2048
|
|
|
|
#define MAX_MR 1024
|
|
|
|
#define MAX_PD 1024
|
|
|
|
#define MAX_QP_RD_ATOM 16
|
|
|
|
#define MAX_QP_INIT_RD_ATOM 16
|
|
|
|
#define MAX_AH 64
|
|
|
|
|
2019-03-11 13:29:08 +03:00
|
|
|
#define MAX_RM_TBL_NAME 16
|
|
|
|
#define MAX_CONSEQ_EMPTY_POLL_CQ 4096 /* considered as error above this */
|
|
|
|
|
2018-02-09 16:00:59 +03:00
|
|
|
typedef struct RdmaRmResTbl {
|
2018-04-30 23:02:22 +03:00
|
|
|
char name[MAX_RM_TBL_NAME];
|
2018-02-09 16:00:59 +03:00
|
|
|
QemuMutex lock;
|
|
|
|
unsigned long *bitmap;
|
|
|
|
size_t tbl_sz;
|
|
|
|
size_t res_sz;
|
|
|
|
void *tbl;
|
2019-03-11 13:29:08 +03:00
|
|
|
uint32_t used; /* number of used entries in the table */
|
2018-02-09 16:00:59 +03:00
|
|
|
} RdmaRmResTbl;
|
|
|
|
|
|
|
|
typedef struct RdmaRmPD {
|
|
|
|
RdmaBackendPD backend_pd;
|
|
|
|
uint32_t ctx_handle;
|
|
|
|
} RdmaRmPD;
|
|
|
|
|
2018-12-21 17:40:16 +03:00
|
|
|
typedef enum CQNotificationType {
|
|
|
|
CNT_CLEAR,
|
|
|
|
CNT_ARM,
|
|
|
|
CNT_SET,
|
|
|
|
} CQNotificationType;
|
|
|
|
|
2018-02-09 16:00:59 +03:00
|
|
|
typedef struct RdmaRmCQ {
|
|
|
|
RdmaBackendCQ backend_cq;
|
|
|
|
void *opaque;
|
2018-12-21 17:40:16 +03:00
|
|
|
CQNotificationType notify;
|
2018-02-09 16:00:59 +03:00
|
|
|
} RdmaRmCQ;
|
|
|
|
|
|
|
|
/* MR (DMA region) */
|
|
|
|
typedef struct RdmaRmMR {
|
|
|
|
RdmaBackendMR backend_mr;
|
2018-08-05 18:35:11 +03:00
|
|
|
void *virt;
|
|
|
|
uint64_t start;
|
|
|
|
size_t length;
|
2018-02-09 16:00:59 +03:00
|
|
|
uint32_t pd_handle;
|
|
|
|
uint32_t lkey;
|
|
|
|
uint32_t rkey;
|
|
|
|
} RdmaRmMR;
|
|
|
|
|
|
|
|
typedef struct RdmaRmUC {
|
|
|
|
uint64_t uc_handle;
|
|
|
|
} RdmaRmUC;
|
|
|
|
|
|
|
|
typedef struct RdmaRmQP {
|
|
|
|
RdmaBackendQP backend_qp;
|
|
|
|
void *opaque;
|
|
|
|
uint32_t qp_type;
|
|
|
|
uint32_t qpn;
|
|
|
|
uint32_t send_cq_handle;
|
|
|
|
uint32_t recv_cq_handle;
|
|
|
|
enum ibv_qp_state qp_state;
|
|
|
|
} RdmaRmQP;
|
|
|
|
|
2018-12-21 17:40:25 +03:00
|
|
|
typedef struct RdmaRmGid {
|
|
|
|
union ibv_gid gid;
|
|
|
|
int backend_gid_index;
|
|
|
|
} RdmaRmGid;
|
|
|
|
|
2018-02-09 16:00:59 +03:00
|
|
|
typedef struct RdmaRmPort {
|
2018-12-21 17:40:25 +03:00
|
|
|
RdmaRmGid gid_tbl[MAX_PORT_GIDS];
|
2018-02-09 16:00:59 +03:00
|
|
|
enum ibv_port_state state;
|
|
|
|
} RdmaRmPort;
|
|
|
|
|
2019-03-11 13:29:08 +03:00
|
|
|
typedef struct RdmaRmStats {
|
|
|
|
uint64_t tx;
|
|
|
|
uint64_t tx_len;
|
|
|
|
uint64_t tx_err;
|
|
|
|
uint64_t rx_bufs;
|
|
|
|
uint64_t rx_bufs_len;
|
|
|
|
uint64_t rx_bufs_err;
|
|
|
|
uint64_t completions;
|
|
|
|
uint64_t mad_tx;
|
|
|
|
uint64_t mad_tx_err;
|
|
|
|
uint64_t mad_rx;
|
|
|
|
uint64_t mad_rx_err;
|
|
|
|
uint64_t mad_rx_bufs;
|
|
|
|
uint64_t mad_rx_bufs_err;
|
|
|
|
uint64_t poll_cq_from_bk;
|
|
|
|
uint64_t poll_cq_from_guest;
|
|
|
|
uint64_t poll_cq_from_guest_empty;
|
|
|
|
uint64_t poll_cq_ppoll_to;
|
|
|
|
uint32_t missing_cqe;
|
|
|
|
} RdmaRmStats;
|
|
|
|
|
2019-02-14 18:40:53 +03:00
|
|
|
struct RdmaDeviceResources {
|
2018-12-21 17:40:32 +03:00
|
|
|
RdmaRmPort port;
|
2018-02-09 16:00:59 +03:00
|
|
|
RdmaRmResTbl pd_tbl;
|
|
|
|
RdmaRmResTbl mr_tbl;
|
|
|
|
RdmaRmResTbl uc_tbl;
|
|
|
|
RdmaRmResTbl qp_tbl;
|
|
|
|
RdmaRmResTbl cq_tbl;
|
|
|
|
RdmaRmResTbl cqe_ctx_tbl;
|
|
|
|
GHashTable *qp_hash; /* Keeps mapping between real and emulated */
|
2019-03-11 13:29:07 +03:00
|
|
|
QemuMutex lock;
|
2019-03-11 13:29:08 +03:00
|
|
|
RdmaRmStats stats;
|
2019-02-14 18:40:53 +03:00
|
|
|
};
|
2018-02-09 16:00:59 +03:00
|
|
|
|
|
|
|
#endif
|