#ifndef _FI_PROTO_H_
#define _FI_PROTO_H_
#include "config.h"
#include <stdint.h>
#include <stddef.h>
#include <rdma/fi_rma.h>
#ifdef __cplusplus
extern "C" {
#endif
#define OFI_CTRL_VERSION 2
enum {
ofi_ctrl_connreq,
ofi_ctrl_connresp,
ofi_ctrl_start_data,
ofi_ctrl_data,
ofi_ctrl_large_data,
ofi_ctrl_ack,
ofi_ctrl_nack,
ofi_ctrl_discard,
};
struct ofi_ctrl_hdr {
uint8_t version;
uint8_t type;
uint16_t seg_size;
uint32_t seg_no;
uint64_t conn_id;
uint64_t msg_id;
union {
uint64_t conn_data;
uint64_t rx_key;
};
};
#define OFI_OP_VERSION 2
enum {
ofi_op_msg,
ofi_op_tagged,
ofi_op_read_req,
ofi_op_read_rsp,
ofi_op_write,
ofi_op_atomic,
};
#define OFI_REMOTE_CQ_DATA (1 << 0)
#define OFI_TRANSMIT_COMPLETE (1 << 1)
#define OFI_DELIVERY_COMPLETE (1 << 2)
struct ofi_op_hdr {
uint8_t version;
uint8_t rx_index;
uint8_t op;
uint8_t op_data;
uint32_t flags;
uint64_t size;
uint64_t data;
union {
uint64_t tag;
uint8_t iov_count;
struct {
uint8_t datatype;
uint8_t op;
uint8_t ioc_count;
} atomic;
uint64_t remote_idx;
uint64_t resv;
};
};
struct ofi_iov {
uint64_t addr;
uint64_t len;
};
struct ofi_rma_iov {
uint64_t addr;
uint64_t len;
uint64_t key;
};
struct ofi_rma_ioc {
uint64_t addr;
uint64_t count;
uint64_t key;
};
#define OFI_CMD_SIZE 64
#define OFI_CMD_DATA_LEN (OFI_CMD_SIZE - sizeof(struct ofi_ctrl_hdr))
enum {
shm_ctrl_inline,
shm_ctrl_inject,
shm_ctrl_iov,
};
struct shm_cmd {
struct ofi_ctrl_hdr hdr;
uint32_t cmd_id;
uint32_t conn_id;
uint64_t resv;
union {
uint8_t data[OFI_CMD_DATA_LEN];
uint64_t buf;
struct iovec iov[OFI_CMD_DATA_LEN / sizeof(struct iovec)];
};
};
union shm_cmd_data {
uint8_t msg[OFI_CMD_SIZE];
struct iovec iov[OFI_CMD_SIZE / sizeof(struct iovec)];
struct ofi_rma_iov rma_iov[OFI_CMD_SIZE / sizeof(struct ofi_rma_iov)];
struct ofi_rma_ioc rma_ioc[OFI_CMD_SIZE / sizeof(struct ofi_rma_ioc)];
};
#ifdef __cplusplus
}
#endif
#endif