2023-09-04 12:21:37 +02:00
|
|
|
/* Node type: infiniband.
|
2018-06-21 11:56:28 +02:00
|
|
|
*
|
|
|
|
* Author: Dennis Potter <dennis@dennispotter.eu>
|
2022-03-15 09:28:57 -04:00
|
|
|
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
2022-07-04 18:20:03 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2018-06-21 11:56:28 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
#include <rdma/rdma_cma.h>
|
2023-09-07 14:21:24 +02:00
|
|
|
|
2021-05-10 00:12:30 +02:00
|
|
|
#include <villas/format.hpp>
|
2023-09-07 11:46:39 +02:00
|
|
|
#include <villas/pool.hpp>
|
2018-06-21 11:56:28 +02:00
|
|
|
#include <villas/queue_signalled.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 {
|
2023-09-07 11:46:39 +02:00
|
|
|
// IBV/RDMA CM structs
|
|
|
|
struct context_s {
|
|
|
|
struct rdma_cm_id *listen_id;
|
|
|
|
struct rdma_cm_id *id;
|
|
|
|
struct rdma_event_channel *ec;
|
2018-07-03 11:13:59 +02:00
|
|
|
|
2023-09-07 11:46:39 +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
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// Queue Pair init variables
|
|
|
|
struct ibv_qp_init_attr qp_init;
|
2018-07-19 18:31:47 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// Size of receive and send completion queue
|
|
|
|
int recv_cq_size;
|
|
|
|
int send_cq_size;
|
2018-07-19 18:31:47 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// Bool, set if threads should be aborted
|
|
|
|
int stopThreads;
|
2018-07-07 14:36:23 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// When most messages are sent inline, once every <X> cycles a signal must be sent.
|
|
|
|
unsigned signaling_counter;
|
|
|
|
unsigned periodic_signaling;
|
2018-10-21 12:35:21 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// Connection specific variables
|
|
|
|
struct connection_s {
|
|
|
|
struct addrinfo *src_addr;
|
|
|
|
struct addrinfo *dst_addr;
|
2018-07-19 18:31:47 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// RDMA_PS_TCP or RDMA_PS_UDP
|
|
|
|
enum rdma_port_space port_space;
|
2018-07-19 18:31:47 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// Timeout for rdma_resolve_route
|
|
|
|
int timeout;
|
2018-07-03 11:13:59 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// Thread to monitor RDMA CM Event threads
|
|
|
|
pthread_t rdma_cm_event_thread;
|
2018-07-03 11:13:59 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// Bool, should data be send inline if possible?
|
|
|
|
int send_inline;
|
2018-07-13 12:21:59 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// Bool, should node have a fallback if it can't connect to a remote host?
|
|
|
|
int use_fallback;
|
2018-08-02 10:41:37 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// Counter to keep track of available recv. WRs
|
|
|
|
unsigned available_recv_wrs;
|
2018-07-19 18:31:47 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
/* Fixed number to substract from min. number available
|
2024-02-29 21:47:13 +01:00
|
|
|
* WRs in receive queue */
|
2023-09-07 11:46:39 +02:00
|
|
|
unsigned buffer_subtraction;
|
2018-07-15 13:51:18 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// Unrealiable connectionless data
|
|
|
|
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
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
} conn;
|
2018-07-03 11:13:59 +02:00
|
|
|
|
2023-09-07 11:46:39 +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);
|
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
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
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
int ib_read(NodeCompat *n, struct Sample *const smps[], unsigned cnt);
|
2018-06-21 11:56:28 +02:00
|
|
|
|
2023-09-07 11:46:39 +02: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
|