#include #include #include #include #include #include #include #include #include #include #include #include #include #include class hdRDMA{ public: hdRDMA(); ~hdRDMA(); void CreateQP(void); void Listen(int port); void StopListening(void); void Connect(std::string host, int port); uint32_t GetNpeers(void); void GetBuffers( std::vector &buffers, int Nrequested=4 ); void ReturnBuffers( std::vector &buffers ); void SendFile(std::string srcfilename, std::string dstfilename, bool delete_after_send=false, bool calculate_checksum=false, bool makeparentdirs=false); void Poll(void); struct ibv_device *dev = nullptr; struct ibv_context *ctx = nullptr; int port_num = 1; struct ibv_device_attr attr; struct ibv_port_attr port_attr; ibv_pd *pd = nullptr; uint64_t buff_len = 0; uint8_t *buff = nullptr; uint64_t num_buff_sections = 0; uint64_t buff_section_len = 0; struct ibv_mr *mr = nullptr; std::deque buffer_pool; std::mutex buffer_pool_mutex; bool done = false; int server_sockfd = 0; std::thread *server_thread = nullptr; uint32_t Nconnections = 0; hdRDMAThread *hdthr_client = nullptr; std::map threads; std::mutex threads_mtx; std::atomic Ntransferred; uint64_t Ntransferred_last = 0; std::chrono::high_resolution_clock::time_point t_last; };