
/* Copyright 2019 SKA South Africa
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @file
 *
 * This file is automatically generated. Do not edit.
 */
#ifndef SPEAD2_COMMON_IBV_LOADER_H
#define SPEAD2_COMMON_IBV_LOADER_H

#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#include <spead2/common_features.h>

#if SPEAD2_USE_IBV

#include <infiniband/verbs.h>
#include <rdma/rdma_cma.h>

namespace spead2
{

extern void (*ibv_ack_cq_events)(struct ibv_cq *cq, unsigned int nevents);
extern struct ibv_pd *(*ibv_alloc_pd)(struct ibv_context *context);
extern int (*ibv_close_device)(struct ibv_context *context);
extern struct ibv_comp_channel *(*ibv_create_comp_channel)(struct ibv_context *context);
extern struct ibv_cq *(*ibv_create_cq)(struct ibv_context *context, int cqe, void *cq_context, struct ibv_comp_channel *channel, int comp_vector);
extern struct ibv_qp *(*ibv_create_qp)(struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr);
extern int (*ibv_dealloc_pd)(struct ibv_pd *pd);
extern int (*ibv_dereg_mr)(struct ibv_mr *mr);
extern int (*ibv_destroy_comp_channel)(struct ibv_comp_channel *channel);
extern int (*ibv_destroy_cq)(struct ibv_cq *cq);
extern int (*ibv_destroy_qp)(struct ibv_qp *qp);
extern void (*ibv_free_device_list)(struct ibv_device **list);
extern int (*ibv_get_cq_event)(struct ibv_comp_channel *channel, struct ibv_cq **cq, void **cq_context);
extern uint64_t (*ibv_get_device_guid)(struct ibv_device *device);
extern struct ibv_device **(*ibv_get_device_list)(int *num_devices);
extern struct ibv_context *(*ibv_open_device)(struct ibv_device *device);
extern int (*ibv_modify_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask);
extern int (*ibv_query_device)(struct ibv_context *context, struct ibv_device_attr *device_attr);
extern struct ibv_mr *(*ibv_reg_mr)(struct ibv_pd *pd, void *addr, size_t length, int access);
extern int (*rdma_bind_addr)(struct rdma_cm_id *id, struct sockaddr *addr);
extern struct rdma_event_channel *(*rdma_create_event_channel)(void);
extern int (*rdma_create_id)(struct rdma_event_channel *channel, struct rdma_cm_id **id, void *context, enum rdma_port_space ps);
extern void (*rdma_destroy_event_channel)(struct rdma_event_channel *channel);
extern int (*rdma_destroy_id)(struct rdma_cm_id *id);

// Load ibverbs. If it could not be loaded, throws std::system_error
void ibv_loader_init();

} // namespace spead2

#endif // SPEAD2_USE_IBV
#endif // SPEAD2_COMMON_IBV_LOADER_H
