2018-06-21 11:56:28 +02:00
|
|
|
/** Node type: infiniband
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @author Dennis Potter <dennis@dennispotter.eu>
|
2022-03-15 09:28:57 -04:00
|
|
|
* @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC
|
2022-07-04 18:20:03 +02:00
|
|
|
* @license Apache 2.0
|
2018-06-21 11:56:28 +02:00
|
|
|
*********************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
#include <villas/pool.hpp>
|
2021-05-10 00:12:30 +02:00
|
|
|
#include <villas/format.hpp>
|
2018-06-21 11:56:28 +02:00
|
|
|
#include <villas/queue_signalled.h>
|
|
|
|
#include <rdma/rdma_cma.h>
|
2018-08-01 18:26:42 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
|
|
|
|
2021-06-21 16:11:42 -04:00
|
|
|
/* Forward declarations */
|
2021-08-10 10:12:48 -04:00
|
|
|
class NodeCompat;
|
2021-06-21 16:11:42 -04:00
|
|
|
|
2018-08-01 18:26:42 +02:00
|
|
|
/* Constants */
|
2018-10-11 14:18:30 +02:00
|
|
|
#define META_SIZE 24
|
2018-08-01 18:26:42 +02:00
|
|
|
#define GRH_SIZE 40
|
|
|
|
#define META_GRH_SIZE META_SIZE + GRH_SIZE
|
|
|
|
#define CHK_PER_ITER 2048
|
|
|
|
|
2018-06-21 11:56:28 +02:00
|
|
|
struct infiniband {
|
2018-07-03 11:13:59 +02:00
|
|
|
/* IBV/RDMA CM structs */
|
|
|
|
struct context_s {
|
|
|
|
struct rdma_cm_id *listen_id;
|
|
|
|
struct rdma_cm_id *id;
|
2018-07-07 12:49:22 +02:00
|
|
|
struct rdma_event_channel *ec;
|
2018-07-03 11:13:59 +02:00
|
|
|
|
|
|
|
struct ibv_pd *pd;
|
|
|
|
struct ibv_cq *recv_cq;
|
|
|
|
struct ibv_cq *send_cq;
|
|
|
|
struct ibv_comp_channel *comp_channel;
|
|
|
|
} ctx;
|
2018-07-04 19:04:08 +02:00
|
|
|
|
2018-07-19 18:31:47 +02:00
|
|
|
/* Queue Pair init variables */
|
|
|
|
struct ibv_qp_init_attr qp_init;
|
|
|
|
|
|
|
|
/* Size of receive and send completion queue */
|
|
|
|
int recv_cq_size;
|
|
|
|
int send_cq_size;
|
|
|
|
|
|
|
|
/* Bool, set if threads should be aborted */
|
2018-07-07 14:36:23 +02:00
|
|
|
int stopThreads;
|
|
|
|
|
2018-10-21 12:35:21 +02:00
|
|
|
/* When most messages are sent inline, once every <X> cycles a signal must be sent. */
|
2018-11-02 12:46:12 +01:00
|
|
|
unsigned signaling_counter;
|
|
|
|
unsigned periodic_signaling;
|
2018-10-21 12:35:21 +02:00
|
|
|
|
2018-07-03 11:13:59 +02:00
|
|
|
/* Connection specific variables */
|
|
|
|
struct connection_s {
|
|
|
|
struct addrinfo *src_addr;
|
|
|
|
struct addrinfo *dst_addr;
|
2018-07-19 18:31:47 +02:00
|
|
|
|
|
|
|
/* RDMA_PS_TCP or RDMA_PS_UDP */
|
2018-07-03 11:13:59 +02:00
|
|
|
enum rdma_port_space port_space;
|
2018-07-19 18:31:47 +02:00
|
|
|
|
|
|
|
/* Timeout for rdma_resolve_route */
|
2018-07-03 11:13:59 +02:00
|
|
|
int timeout;
|
|
|
|
|
2018-07-19 18:31:47 +02:00
|
|
|
/* Thread to monitor RDMA CM Event threads */
|
2018-07-07 12:49:22 +02:00
|
|
|
pthread_t rdma_cm_event_thread;
|
2018-07-03 11:13:59 +02:00
|
|
|
|
2018-07-19 18:31:47 +02:00
|
|
|
/* Bool, should data be send inline if possible? */
|
2018-07-15 13:51:18 +02:00
|
|
|
int send_inline;
|
2018-07-13 12:21:59 +02:00
|
|
|
|
2018-08-02 10:41:37 +02:00
|
|
|
/* Bool, should node have a fallback if it can't connect to a remote host? */
|
|
|
|
int use_fallback;
|
|
|
|
|
2018-07-19 18:31:47 +02:00
|
|
|
/* Counter to keep track of available recv. WRs */
|
2019-04-22 23:43:46 +02:00
|
|
|
unsigned available_recv_wrs;
|
2018-07-19 18:31:47 +02:00
|
|
|
|
|
|
|
/* Fixed number to substract from min. number available
|
|
|
|
* WRs in receive queue */
|
2019-04-22 23:43:46 +02:00
|
|
|
unsigned buffer_subtraction;
|
2018-07-15 13:51:18 +02:00
|
|
|
|
2018-07-19 18:31:47 +02:00
|
|
|
/* Unrealiable connectionless data */
|
2018-07-25 18:53:11 +02:00
|
|
|
struct ud_s {
|
|
|
|
struct rdma_ud_param ud;
|
|
|
|
struct ibv_ah *ah;
|
|
|
|
void *grh_ptr;
|
|
|
|
struct ibv_mr *grh_mr;
|
|
|
|
} ud;
|
2018-07-03 11:13:59 +02:00
|
|
|
|
2018-07-19 18:31:47 +02:00
|
|
|
} conn;
|
2018-07-03 11:13:59 +02:00
|
|
|
|
|
|
|
/* Misc settings */
|
|
|
|
int is_source;
|
2018-06-21 11:56:28 +02:00
|
|
|
};
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int ib_reverse(NodeCompat *n);
|
|
|
|
|
|
|
|
char * ib_print(NodeCompat *n);
|
2018-06-21 11:56:28 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int ib_parse(NodeCompat *n, json_t *json);
|
2018-06-21 11:56:28 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int ib_check(NodeCompat *n);
|
2018-06-21 11:56:28 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int ib_start(NodeCompat *n);
|
2018-06-21 11:56:28 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int ib_destroy(NodeCompat *n);
|
2018-06-21 11:56:28 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int ib_stop(NodeCompat *n);
|
2018-06-21 11:56:28 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int ib_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
2018-06-21 11:56:28 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int ib_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
2018-06-21 11:56:28 +02:00
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace node
|
|
|
|
} // namespace villas
|