Untitled

mail@pastecode.io avatar
unknown
plain_text
25 days ago
1.1 kB
2
Indexable
Never
#ifndef RDMA_COMMON_H
#define RDMA_COMMON_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <infiniband/verbs.h>

#define MAX_POLL_CQ_TIMEOUT 2000
#define MSG_SIZE 64
#define TCP_PORT 18515

struct qp_info {
    uint32_t qp_num;
    uint16_t lid;
    uint8_t gid[16];
};

struct connection {
    struct ibv_context *context;
    struct ibv_pd *pd;
    struct ibv_cq *cq;
    struct ibv_qp *qp;
    struct ibv_mr *mr;
    char *buf;
    int size;
    int sock;
    struct qp_info local_qp_info;
    struct qp_info remote_qp_info;
    int ib_port;
};

int setup_connection(struct connection *conn, const char *dev_name, int ib_port);
int modify_qp_to_init(struct ibv_qp *qp, int ib_port);
int modify_qp_to_rtr(struct ibv_qp *qp, int ib_port, uint32_t remote_qpn, uint16_t dlid, uint8_t *dgid);
int modify_qp_to_rts(struct ibv_qp *qp);
int post_send(struct connection *conn);
int post_recv(struct connection *conn);

#endif // RDMA_COMMON_H
Leave a Comment