NewMadeleine

Documentation

« back to PM2 home.
nm_ibverbs.h
Go to the documentation of this file.
1/*
2 * NewMadeleine
3 * Copyright (C) 2010-2026 (see AUTHORS file)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 */
15
16#ifndef NM_IBVERBS_H
17#define NM_IBVERBS_H
18
19#include <nm_minidriver.h>
20#include <infiniband/verbs.h>
21#include <nm_public.h>
22#include <nm_private.h>
23#ifdef NMAD_PADICOTM
24#include <Padico/SysIO.h>
25#endif /* NMAD_PADICOTM*/
26
27/* *** global IB parameters ******************************** */
28
29#define NM_IBVERBS_UD_DEPTH 8192
30#define NM_IBVERBS_TX_DEPTH 256
31#define NM_IBVERBS_RX_DEPTH 1024
32#define NM_IBVERBS_SRQ_DEPTH 16384
33#define NM_IBVERBS_ATOMIC_DEPTH 4
34#define NM_IBVERBS_MAX_SG_SQ 16
35#define NM_IBVERBS_MAX_SG_RQ 16
36#define NM_IBVERBS_MAX_INLINE 256
37#define NM_IBVERBS_DEFAULT_MTU IBV_MTU_1024
38
40#define NM_IBVERBS_TIMEOUT_CONNECT (1000 * 1000) /* 1 s */
41
43#define NM_IBVERBS_TIMEOUT_WARN (8 * 1000 * 1000) /* 8 s */
44
46#define NM_IBVERBS_TIMEOUT_READY (16 * 1000 * 1000) /* 16 s */
47
49#define GRH_OFFSET 40 /* 40 */
50
51uint32_t nm_ibverbs_checksum(const char*data, nm_len_t len);
52uint32_t nm_ibverbs_memcpy_and_checksum(void*_dest, const void*_src, nm_len_t len);
54uint32_t nm_ibverbs_copy_from_and_checksum(void*dest, nm_data_slicer_t*p_slicer, const void*src, nm_len_t offset, nm_len_t len);
55uint32_t nm_ibverbs_copy_to_and_checksum(const void*src, nm_data_slicer_t*p_slicer, void*dest, nm_len_t offset, nm_len_t len);
56
57extern int nm_ibverbs_alignment;
58extern int nm_ibverbs_memalign;
59
84
88{
89 uint64_t raddr;
90 uint32_t rkey;
91};
92
93#define NM_IBVERBS_SEGMENT_NULL ((struct nm_ibverbs_segment_s){ .raddr = 0, .rkey = 0 })
94static inline int nm_ibverbs_segment_isnull(const struct nm_ibverbs_segment_s*p_seg)
95{
96 return (p_seg->raddr == 0);
97}
98
101{
102 uint16_t lid;
103 uint16_t cnx_id;
104 uint32_t qpn;
105 uint32_t psn;
106 union ibv_gid gid;
107};
108
109/* ** hash functions for QPN */
110
111static inline int nm_ibverbs_qpn_eq(const uint32_t*p_int1, const uint32_t*p_int2)
112{
113 return (*p_int1 == *p_int2);
114}
115static inline uint32_t nm_ibverbs_qpn_hash(const uint32_t*p_int)
116{
117 return *p_int;
118}
119
120/* ** hash functions for addresses */
121
122static inline int nm_ibverbs_addr_eq(const struct nm_ibverbs_addr_s*p_addr1, const struct nm_ibverbs_addr_s*p_addr2)
123{
124 return
125 (p_addr1->lid == p_addr2->lid) &&
126 (p_addr1->qpn == p_addr2->qpn) &&
127 (p_addr1->psn == p_addr2->psn) &&
128 (p_addr1->cnx_id == p_addr2->cnx_id);
129}
130static inline uint32_t nm_ibverbs_addr_hash(const struct nm_ibverbs_addr_s*p_addr)
131{
132 return puk_hash_default((const void*)p_addr, sizeof(struct nm_ibverbs_addr_s));
133}
134
142
145{
146 const char*device;
147 int port;
148 struct ibv_device*ib_dev;
149 uint16_t lid;
150 union ibv_gid gid;
151 int gidx ;
152 struct ibv_context*context;
153 struct ibv_pd*pd;
154 struct
155 {
156 int max_qp;
158 int max_cq;
160 int max_mr;
162 uint64_t max_mr_size;
163 uint64_t page_size_cap;
164 uint64_t max_msg_size;
167 struct
168 {
169#ifdef NMAD_PADICOTM
170 padico_sysio_t async_io;
171#endif /* NMAD_PADICOTM */
178};
179
180
181/* ** UD messaging ***************************************** */
182
185{
188 struct ibv_qp*qp;
189 struct ibv_cq*of_cq;
190 struct ibv_cq*if_cq;
191};
192
194{
196 struct ibv_mr*mr;
197};
198
200{
202 struct ibv_mr*mr;
203 void*buf;
204 size_t size;
205 int depth;
206};
207
209{
211 struct ibv_ah*ah;
212 struct ibv_mr*mr;
213};
214
215
216/* ** connection establishment ***************************** */
217
232
239
241PUK_LIST_TYPE(nm_ibverbs_cnx_addr_entry,
242 struct nm_ibverbs_cnx_addr_msg_s msg;
243 enum nm_ibverbs_cnx_addr_state_e local_state;
244 int local_timeout;
245 uint64_t local_oob;
246 struct nm_ibverbs_cnx_s*p_cnx;
247 double t_timeout;
248 );
249
250static void nm_ibverbs_cnx_addr_entry_destructor(struct nm_ibverbs_addr_s*p_addr, struct nm_ibverbs_cnx_addr_entry_s*p_entry)
251{
252 padico_free(p_entry);
253}
254
255PUK_HASHTABLE_TYPE(nm_ibverbs_cnx_addr_entry, struct nm_ibverbs_addr_s*, struct nm_ibverbs_cnx_addr_entry_s*,
257
258PUK_HASHTABLE_TYPE(nm_ibverbs_cnx_qpn, const uint32_t*, struct nm_ibverbs_cnx_s*,
260
261
262/* ** public structures ************************************ */
263
266{
269 struct
270 {
273 struct nm_ibverbs_cnx_addr_entry_hashtable_s addr_hash;
274 struct nm_ibverbs_cnx_qpn_hashtable_s cnx_by_qpn;
275 struct nm_ibverbs_cnx_addr_entry_list_s pending_entries;
280 struct
281 {
284 uint32_t rank;
287 struct
288 {
289 struct ibv_srq*p_srq;
290 struct ibv_cq*srq_cq;
291 struct ibv_comp_channel*comp_channel;
292 int cancel_fd[2];
293 volatile int waiting;
302};
303
306{
307 struct nm_ibverbs_cnx_addr_entry_s*p_addr_entry;
310 struct ibv_qp*qp;
311 struct ibv_cq*of_cq;
312 struct ibv_cq*if_cq;
315 struct
316 {
317 int total;
320 struct
321 {
324};
325
328{
329 struct nm_ibverbs_context_s*(*context_new)(puk_context_t, const struct nm_ibverbs_opts_s*);
330};
331PUK_IFACE_TYPE(NewMad_ibverbs, struct nm_ibverbs_iface_s);
332
333/* ** HCA ************************************************** */
334
335void nm_ibverbs_hca_open(struct nm_ibverbs_hca_s*p_hca, const char*device, int port, int gidx);
336
338
339/* ** IB cnx management ************************************ */
340
342
343void nm_ibverbs_cnx_close(struct nm_ibverbs_cnx_s*p_ibverbs_cnx);
344
345void nm_ibverbs_cnx_connect_async(struct nm_ibverbs_cnx_s*p_ibverbs_cnx, const void*p_url, size_t urlsize);
346
348
349/* ** vector connect *************************************** */
350
353 const void*p_remote_url, size_t url_size);
354
357
358/* ** lazy connect ***************************************** */
359
362
365 const void*p_remote_url, size_t url_size, int cnx_id);
366
368static inline int nm_ibverbs_cnx_lazy_ready(struct nm_ibverbs_cnx_s*p_ibverbs_cnx)
369{
370 return ( (p_ibverbs_cnx != NULL) &&
371 (p_ibverbs_cnx->p_addr_entry != NULL) &&
372 (p_ibverbs_cnx->p_addr_entry->msg.state == NM_IBVERBS_CNX_ADDR_CONNECTED) &&
373 (p_ibverbs_cnx->p_addr_entry->local_state == NM_IBVERBS_CNX_ADDR_CONNECTED) );
374}
375
377void nm_ibverbs_cnx_lazy_send_oob(struct nm_ibverbs_cnx_s*p_ibverbs_cnx, uint64_t oob);
378
380static inline uint64_t nm_ibverbs_cnx_lazy_get_oob(struct nm_ibverbs_cnx_s*p_ibverbs_cnx)
381{
382 assert(nm_ibverbs_cnx_lazy_ready(p_ibverbs_cnx));
383 return p_ibverbs_cnx->p_addr_entry->msg.oob_data;
384}
385
388
389static inline
391{
392 struct nm_ibverbs_cnx_s*p_cnx = nm_ibverbs_cnx_qpn_hashtable_lookup(&p_ibverbs_context->connect.cnx_by_qpn, &qpn);
393 return p_cnx;
394}
395
396/* ** IB context ******************************************* */
397
398struct nm_ibverbs_context_s*nm_ibverbs_context_resolve_opts(puk_context_t p_context, const struct nm_ibverbs_opts_s*p_opts);
399
400static inline void nm_ibverbs_context_default_opts(struct nm_ibverbs_opts_s*p_opts)
401{
402 p_opts->lazy_connect = 0;
403 p_opts->use_srq = 0;
404 p_opts->use_comp_channel = 0;
405 p_opts->mtu = IBV_MTU_1024;
406}
407
409static inline struct nm_ibverbs_context_s*nm_ibverbs_context_resolve(puk_context_t p_context)
410{
411 struct nm_ibverbs_opts_s opts = { 0 };
413 return nm_ibverbs_context_resolve_opts(p_context, &opts);
414}
415
417
419
420void nm_ibverbs_context_get_profile(struct nm_ibverbs_context_s*p_ibverbs_context, struct nm_drv_profile_s*p_profile);
421
423void nm_ibverbs_context_get_url(struct nm_ibverbs_context_s*p_ibverbs_context, const void**pp_url, size_t*p_urlsize);
424
426void nm_ibverbs_context_get_wide_url(struct nm_ibverbs_context_s*p_ibverbs_context, int session_size, int rank,
427 const void**pp_url, size_t*p_urlsize);
428
429void nm_ibverbs_context_delete(struct nm_ibverbs_context_s*p_ibverbs_context);
430
431void nm_ibverbs_context_set_srq_limit(struct nm_ibverbs_context_s*p_ibverbs_context, int srq_limit);
432
433struct ibv_mr*nm_ibverbs_reg_mr(struct nm_ibverbs_context_s*p_ibverbs_context, void*buf, size_t size,
434 struct nm_ibverbs_segment_s*p_segment);
435
436int nm_ibverbs_dereg_mr(struct nm_ibverbs_context_s*p_ibverbs_context, struct ibv_mr*p_mr);
437
438/* ** RDMA toolbox ***************************************** */
439
440
442static const char*const nm_ibverbs_status_strings[] =
443 {
444 [IBV_WC_SUCCESS] = "success",
445 [IBV_WC_LOC_LEN_ERR] = "local length error",
446 [IBV_WC_LOC_QP_OP_ERR] = "local QP op error",
447 [IBV_WC_LOC_EEC_OP_ERR] = "local EEC op error",
448 [IBV_WC_LOC_PROT_ERR] = "local protection error",
449 [IBV_WC_WR_FLUSH_ERR] = "write flush error",
450 [IBV_WC_MW_BIND_ERR] = "MW bind error",
451 [IBV_WC_BAD_RESP_ERR] = "bad response error",
452 [IBV_WC_LOC_ACCESS_ERR] = "local access error",
453 [IBV_WC_REM_INV_REQ_ERR] = "remote invalid request error",
454 [IBV_WC_REM_ACCESS_ERR] = "remote access error",
455 [IBV_WC_REM_OP_ERR] = "remote op error",
456 [IBV_WC_RETRY_EXC_ERR] = "retry exceded error",
457 [IBV_WC_RNR_RETRY_EXC_ERR] = "RNR retry exceded error",
458 [IBV_WC_LOC_RDD_VIOL_ERR] = "local RDD violation error",
459 [IBV_WC_REM_INV_RD_REQ_ERR] = "remote invalid read request error",
460 [IBV_WC_REM_ABORT_ERR] = "remote abort error",
461 [IBV_WC_INV_EECN_ERR] = "invalid EECN error",
462 [IBV_WC_INV_EEC_STATE_ERR] = "invalid EEC state error",
463 [IBV_WC_FATAL_ERR] = "fatal error",
464 [IBV_WC_RESP_TIMEOUT_ERR] = "response timeout error",
465 [IBV_WC_GENERAL_ERR] = "general error"
466 };
467
468static const int nm_ibverbs_mtu_values[] =
469 {
470 [ IBV_MTU_256 ] = 256,
471 [ IBV_MTU_512 ] = 512,
472 [ IBV_MTU_1024 ] = 1024,
473 [ IBV_MTU_2048 ] = 2048,
474 [ IBV_MTU_4096 ] = 4096
475 };
476
477int nm_ibverbs_do_rdma(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx,
478 const void*__restrict__ buf, int size, uint64_t raddr,
479 int opcode, int flags, uint32_t lkey, uint32_t rkey, uint64_t wrid)
480 __attribute__ ((warn_unused_result));
481
482
483int nm_ibverbs_rdma_send(struct nm_ibverbs_cnx_s*p_ibverbs_cnx, int size,
484 const void*__restrict__ ptr,
485 const void*__restrict__ _raddr,
486 const void*__restrict__ _lbase,
487 const struct nm_ibverbs_segment_s*p_seg,
488 const struct ibv_mr*__restrict__ mr,
489 int wrid)
490 __attribute__ ((warn_unused_result));
491
492int nm_ibverbs_rdma_poll_inout(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx, int inout)
493 __attribute__ ((warn_unused_result));
494
495static inline int nm_ibverbs_rdma_poll_send(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx)
496 __attribute__ ((warn_unused_result));
497static inline int nm_ibverbs_rdma_poll_send(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx)
498{
499 return nm_ibverbs_rdma_poll_inout(p_ibverbs_cnx, 0);
500}
501
502static inline int nm_ibverbs_rdma_poll_recv(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx)
503 __attribute__ ((warn_unused_result));
504static inline int nm_ibverbs_rdma_poll_recv(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx)
505{
506 return nm_ibverbs_rdma_poll_inout(p_ibverbs_cnx, 1);
507}
508
509
510static inline int nm_ibverbs_recv_poll(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx, uint64_t wrid)
511 __attribute__ ((warn_unused_result));
512static inline int nm_ibverbs_recv_poll(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx, uint64_t wrid)
513{
514 int rc = nm_ibverbs_rdma_poll_recv(p_ibverbs_cnx);
515 if(rc != NM_ESUCCESS)
516 return rc;
517 if(p_ibverbs_cnx->pending.wrids[wrid])
518 return -NM_EAGAIN;
519 return NM_ESUCCESS;
520}
521
522static inline int nm_ibverbs_send_poll(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx, uint64_t wrid)
523 __attribute__ ((warn_unused_result));
524static inline int nm_ibverbs_send_poll(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx, uint64_t wrid)
525{
526 int rc = nm_ibverbs_rdma_poll_send(p_ibverbs_cnx);
527 if(rc != NM_ESUCCESS)
528 return rc;
529 if(p_ibverbs_cnx->pending.wrids[wrid])
530 return -NM_EAGAIN;
531 return NM_ESUCCESS;
532}
533
534static inline int nm_ibverbs_send_flush(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx, uint64_t wrid)
535 __attribute__ ((warn_unused_result));
536static inline int nm_ibverbs_send_flush(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx, uint64_t wrid)
537{
538 while(p_ibverbs_cnx->pending.wrids[wrid])
539 {
540 int rc = nm_ibverbs_rdma_poll_send(p_ibverbs_cnx);
541 if(rc != NM_ESUCCESS)
542 return rc;
543 }
544 return NM_ESUCCESS;
545}
546
547static inline int nm_ibverbs_send_flushn_total(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx, int n)
548 __attribute__ ((warn_unused_result));
549static inline int nm_ibverbs_send_flushn_total(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx, int n)
550{
551 while(p_ibverbs_cnx->pending.total > n)
552 {
553 int rc = nm_ibverbs_rdma_poll_send(p_ibverbs_cnx);
554 if(rc != NM_ESUCCESS)
555 return rc;
556 }
557 return NM_ESUCCESS;
558}
559
560static inline int nm_ibverbs_send_flushn(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx, int wrid, int n)
561 __attribute__ ((warn_unused_result));
562static inline int nm_ibverbs_send_flushn(struct nm_ibverbs_cnx_s*__restrict__ p_ibverbs_cnx, int wrid, int n)
563{
564 while(p_ibverbs_cnx->pending.wrids[wrid] > n)
565 {
566 int rc = nm_ibverbs_rdma_poll_send(p_ibverbs_cnx);
567 if(rc != NM_ESUCCESS)
568 return rc;
569 }
570 return NM_ESUCCESS;
571}
572
573/* ** IB UD ************************************************ */
574
576
578
580 struct nm_ibverbs_ud_ep_s*p_ud_ep, void*buf, size_t size,
581 const struct nm_ibverbs_addr_s*p_remote_addr);
582
584
585void nm_ibverbs_ud_send(struct nm_ibverbs_ud_ep_s*p_ud_ep, void*buf, size_t size,
586 const struct nm_ibverbs_addr_s*p_remote_addr);
587
589 struct nm_ibverbs_ud_ep_s*p_ud_ep, void*buf, size_t size);
590
592
593void nm_ibverbs_ud_recv(struct nm_ibverbs_ud_ep_s*p_ud_ep, void*buf, size_t size);
594
596 struct nm_ibverbs_ud_ep_s*p_ud_ep, void*buf, size_t size, int depth);
597
599
601
603
604
605/* ** reg pool ********************************************* */
606
608{
609 void*p_ptr;
610 struct ibv_mr*p_mr;
611};
612
614static inline void nm_ibverbs_regpool_entry_segment(const struct nm_ibverbs_regpool_entry_s*p_entry, struct nm_ibverbs_segment_s*p_seg)
615{
616 p_seg->raddr = (uintptr_t)p_entry->p_ptr;
617 p_seg->rkey = p_entry->p_mr->rkey;
618}
619
620PUK_LFSTACK_TYPE(nm_ibverbs_regpool_block,
621 struct nm_ibverbs_regpool_entry_s entry;
622 );
623
624PUK_LFSTACK_TYPE(nm_ibverbs_regpool_slice,
625 void*p_ptr;
626 struct ibv_mr*p_mr;
627 struct nm_ibverbs_regpool_block_lfstack_cell_s*p_cells;
628 );
629
633{
634 struct nm_ibverbs_regpool_slice_lfstack_s slices;
635 struct nm_ibverbs_regpool_block_lfstack_s blocks;
639#ifdef NMAD_PROFILE
640 unsigned long long total_alloc;
641 unsigned long max_alloc;
642 unsigned long cur_alloc;
643#endif /* NMAD_PROFILE */
644};
645
646void nm_ibverbs_regpool_init(struct nm_ibverbs_regpool_s*p_regpool, struct nm_ibverbs_context_s*p_ibverbs_context, nm_len_t entry_size, nm_len_t slice_size);
647
649
651
653
654
655#endif /* NM_IBVERBS_H */
struct nm_core_event_s __attribute__
Definition nm_data.h:539
@ NM_EAGAIN
poll again
Definition nm_errno.h:39
@ NM_ESUCCESS
successful operation
Definition nm_errno.h:36
assert(p_data->ops.p_traversal !=NULL)
nm_len_t len
Definition nm_data.h:1007
static int nm_ibverbs_rdma_poll_recv(struct nm_ibverbs_cnx_s *__restrict__ p_ibverbs_cnx) __attribute__((warn_unused_result))
Definition nm_ibverbs.h:504
uint32_t nm_ibverbs_copy_from_and_checksum(void *dest, nm_data_slicer_t *p_slicer, const void *src, nm_len_t offset, nm_len_t len)
uint32_t nm_ibverbs_copy_to_and_checksum(const void *src, nm_data_slicer_t *p_slicer, void *dest, nm_len_t offset, nm_len_t len)
int nm_ibverbs_rdma_poll_inout(struct nm_ibverbs_cnx_s *__restrict__ p_ibverbs_cnx, int inout) __attribute__((warn_unused_result))
void nm_ibverbs_cnx_connect_wait(struct nm_ibverbs_cnx_s *p_ibverbs_cnx)
PUK_LIST_TYPE(nm_ibverbs_cnx_addr_entry, struct nm_ibverbs_cnx_addr_msg_s msg;enum nm_ibverbs_cnx_addr_state_e local_state;int local_timeout;uint64_t local_oob;struct nm_ibverbs_cnx_s *p_cnx;double t_timeout;)
an address entry used to store connection addresses
struct ibv_mr * nm_ibverbs_reg_mr(struct nm_ibverbs_context_s *p_ibverbs_context, void *buf, size_t size, struct nm_ibverbs_segment_s *p_segment)
static const char *const nm_ibverbs_status_strings[]
messages for Work Completion status
Definition nm_ibverbs.h:442
void nm_ibverbs_context_get_profile(struct nm_ibverbs_context_s *p_ibverbs_context, struct nm_drv_profile_s *p_profile)
static int nm_ibverbs_send_flushn(struct nm_ibverbs_cnx_s *__restrict__ p_ibverbs_cnx, int wrid, int n) __attribute__((warn_unused_result))
Definition nm_ibverbs.h:562
int nm_ibverbs_ud_recv_pool_poll(struct nm_ibverbs_ud_recv_pool_s *p_recv)
void nm_ibverbs_cnx_close(struct nm_ibverbs_cnx_s *p_ibverbs_cnx)
void nm_ibverbs_ud_send(struct nm_ibverbs_ud_ep_s *p_ud_ep, void *buf, size_t size, const struct nm_ibverbs_addr_s *p_remote_addr)
uint32_t nm_ibverbs_checksum(const char *data, nm_len_t len)
static void nm_ibverbs_cnx_addr_entry_destructor(struct nm_ibverbs_addr_s *p_addr, struct nm_ibverbs_cnx_addr_entry_s *p_entry)
Definition nm_ibverbs.h:250
int nm_ibverbs_do_rdma(struct nm_ibverbs_cnx_s *__restrict__ p_ibverbs_cnx, const void *__restrict__ buf, int size, uint64_t raddr, int opcode, int flags, uint32_t lkey, uint32_t rkey, uint64_t wrid) __attribute__((warn_unused_result))
int nm_ibverbs_context_wait_event(struct nm_ibverbs_context_s *p_ibverbs_context)
PUK_HASHTABLE_TYPE(nm_ibverbs_cnx_addr_entry, struct nm_ibverbs_addr_s *, struct nm_ibverbs_cnx_addr_entry_s *, &nm_ibverbs_addr_hash, &nm_ibverbs_addr_eq, &nm_ibverbs_cnx_addr_entry_destructor)
int nm_ibverbs_cnx_vector_enabled(void)
checks whether vector connect attribute is set
void nm_ibverbs_regpool_init(struct nm_ibverbs_regpool_s *p_regpool, struct nm_ibverbs_context_s *p_ibverbs_context, nm_len_t entry_size, nm_len_t slice_size)
static uint32_t nm_ibverbs_addr_hash(const struct nm_ibverbs_addr_s *p_addr)
Definition nm_ibverbs.h:130
int nm_ibverbs_ud_send_poll(struct nm_ibverbs_ud_send_s *p_send)
static uint64_t nm_ibverbs_cnx_lazy_get_oob(struct nm_ibverbs_cnx_s *p_ibverbs_cnx)
get latest oob data received
Definition nm_ibverbs.h:380
#define GRH_OFFSET
offset at the beginning of all messages to allow for GRH header to be inserted in UD mode
Definition nm_ibverbs.h:49
void nm_ibverbs_ud_recv_post(struct nm_ibverbs_ud_recv_s *p_recv, struct nm_ibverbs_ud_ep_s *p_ud_ep, void *buf, size_t size)
uint32_t nm_ibverbs_memcpy_and_checksum(void *_dest, const void *_src, nm_len_t len)
void nm_ibverbs_cnx_connect_async(struct nm_ibverbs_cnx_s *p_ibverbs_cnx, const void *p_url, size_t urlsize)
static int nm_ibverbs_segment_isnull(const struct nm_ibverbs_segment_s *p_seg)
Definition nm_ibverbs.h:94
static int nm_ibverbs_recv_poll(struct nm_ibverbs_cnx_s *__restrict__ p_ibverbs_cnx, uint64_t wrid) __attribute__((warn_unused_result))
Definition nm_ibverbs.h:512
void nm_ibverbs_regpool_destroy(struct nm_ibverbs_regpool_s *p_regpool)
void nm_ibverbs_regpool_free_entry(struct nm_ibverbs_regpool_s *p_regpool, const struct nm_ibverbs_regpool_entry_s *p_entry)
int nm_ibverbs_rdma_send(struct nm_ibverbs_cnx_s *p_ibverbs_cnx, int size, const void *__restrict__ ptr, const void *__restrict__ _raddr, const void *__restrict__ _lbase, const struct nm_ibverbs_segment_s *p_seg, const struct ibv_mr *__restrict__ mr, int wrid) __attribute__((warn_unused_result))
static void nm_ibverbs_regpool_entry_segment(const struct nm_ibverbs_regpool_entry_s *p_entry, struct nm_ibverbs_segment_s *p_seg)
fill segment from regpool entry
Definition nm_ibverbs.h:614
int nm_ibverbs_ud_recv_poll(struct nm_ibverbs_ud_recv_s *p_recv)
const struct nm_ibverbs_regpool_entry_s * nm_ibverbs_regpool_alloc_entry(struct nm_ibverbs_regpool_s *p_regpool)
static int nm_ibverbs_send_flushn_total(struct nm_ibverbs_cnx_s *__restrict__ p_ibverbs_cnx, int n) __attribute__((warn_unused_result))
Definition nm_ibverbs.h:549
static int nm_ibverbs_rdma_poll_send(struct nm_ibverbs_cnx_s *__restrict__ p_ibverbs_cnx) __attribute__((warn_unused_result))
Definition nm_ibverbs.h:497
static const int nm_ibverbs_mtu_values[]
Definition nm_ibverbs.h:468
int nm_ibverbs_cnx_lazy_enabled(void)
checks whether lazy connect attribute is set
static int nm_ibverbs_send_poll(struct nm_ibverbs_cnx_s *__restrict__ p_ibverbs_cnx, uint64_t wrid) __attribute__((warn_unused_result))
Definition nm_ibverbs.h:524
PUK_IFACE_TYPE(NewMad_ibverbs, struct nm_ibverbs_iface_s)
void nm_ibverbs_ud_recv_pool_reload(struct nm_ibverbs_ud_recv_pool_s *p_recv, int i)
static int nm_ibverbs_send_flush(struct nm_ibverbs_cnx_s *__restrict__ p_ibverbs_cnx, uint64_t wrid) __attribute__((warn_unused_result))
Definition nm_ibverbs.h:536
void nm_ibverbs_cnx_lazy_send_oob(struct nm_ibverbs_cnx_s *p_ibverbs_cnx, uint64_t oob)
send oob data to remote node
static struct nm_ibverbs_context_s * nm_ibverbs_context_resolve(puk_context_t p_context)
resolve context with default opts
Definition nm_ibverbs.h:409
void nm_ibverbs_cnx_lazy_create(struct nm_ibverbs_context_s *p_ibverbs_context, struct nm_ibverbs_cnx_s **pp_ibverbs_cnx, const void *p_remote_url, size_t url_size, int cnx_id)
dynamically create a lazy connection
void nm_ibverbs_ud_ep_open(struct nm_ibverbs_ud_ep_s *p_ud_ep, struct nm_ibverbs_hca_s *p_hca)
struct nm_ibverbs_cnx_s * nm_ibverbs_cnx_vector_connect(struct nm_ibverbs_context_s *p_ibverbs_context, const void *p_remote_url, size_t url_size)
return an already connected cnx, when vector connection is available
nm_ibverbs_wrid_e
list of WRIDs used in the driver.
Definition nm_ibverbs.h:62
@ NM_IBVERBS_WRID_SEG
segment for lr2
Definition nm_ibverbs.h:70
@ _NM_IBVERBS_WRID_NONE
Definition nm_ibverbs.h:63
@ NM_IBVERBS_WRID_RDV
rdv for rcache
Definition nm_ibverbs.h:66
@ NM_IBVERBS_WRID_HEADER
headers for rcache
Definition nm_ibverbs.h:68
@ _NM_IBVERBS_WRID_MAX
Definition nm_ibverbs.h:74
@ NM_IBVERBS_WRID_RTR
Definition nm_ibverbs.h:71
@ NM_IBVERBS_WRID_RECV
Definition nm_ibverbs.h:72
@ NM_IBVERBS_WRID_RDMA
data for bycopy
Definition nm_ibverbs.h:65
@ NM_IBVERBS_WRID_PACKET
packet for lr2
Definition nm_ibverbs.h:69
@ NM_IBVERBS_WRID_ACK
ACK for bycopy.
Definition nm_ibverbs.h:64
@ NM_IBVERBS_WRID_SEND
Definition nm_ibverbs.h:73
@ NM_IBVERBS_WRID_DATA
data for rcache
Definition nm_ibverbs.h:67
static void nm_ibverbs_context_default_opts(struct nm_ibverbs_opts_s *p_opts)
Definition nm_ibverbs.h:400
static int nm_ibverbs_qpn_eq(const uint32_t *p_int1, const uint32_t *p_int2)
Definition nm_ibverbs.h:111
void nm_ibverbs_ud_recv_pool_delete(struct nm_ibverbs_ud_recv_pool_s *p_recv)
void nm_ibverbs_cnx_lazy_progress(struct nm_ibverbs_context_s *p_ibverbs_context)
make progress on lazy connections
int nm_ibverbs_checksum_enabled(void)
static struct nm_ibverbs_cnx_s * nm_ibverbs_cnx_lazy_by_qpn(struct nm_ibverbs_context_s *p_ibverbs_context, uint32_t qpn)
Definition nm_ibverbs.h:390
PUK_LFSTACK_TYPE(nm_ibverbs_regpool_block, struct nm_ibverbs_regpool_entry_s entry;)
static int nm_ibverbs_addr_eq(const struct nm_ibverbs_addr_s *p_addr1, const struct nm_ibverbs_addr_s *p_addr2)
Definition nm_ibverbs.h:122
struct nm_ibverbs_context_s * nm_ibverbs_context_resolve_opts(puk_context_t p_context, const struct nm_ibverbs_opts_s *p_opts)
void nm_ibverbs_ud_send_post(struct nm_ibverbs_ud_send_s *p_send, struct nm_ibverbs_ud_ep_s *p_ud_ep, void *buf, size_t size, const struct nm_ibverbs_addr_s *p_remote_addr)
void nm_ibverbs_context_get_url(struct nm_ibverbs_context_s *p_ibverbs_context, const void **pp_url, size_t *p_urlsize)
get the address for this context
void nm_ibverbs_ud_recv(struct nm_ibverbs_ud_ep_s *p_ud_ep, void *buf, size_t size)
int nm_ibverbs_alignment
void nm_ibverbs_context_set_srq_limit(struct nm_ibverbs_context_s *p_ibverbs_context, int srq_limit)
void nm_ibverbs_hca_open(struct nm_ibverbs_hca_s *p_hca, const char *device, int port, int gidx)
struct nm_ibverbs_cnx_s * nm_ibverbs_cnx_create(struct nm_ibverbs_context_s *p_ibverbs_context, int cnx_id)
void nm_ibverbs_context_cancel_wait(struct nm_ibverbs_context_s *p_ibverbs_context)
void nm_ibverbs_hca_close(struct nm_ibverbs_hca_s *p_hca)
void nm_ibverbs_ud_ep_close(struct nm_ibverbs_ud_ep_s *p_ud_ep)
void nm_ibverbs_context_get_wide_url(struct nm_ibverbs_context_s *p_ibverbs_context, int session_size, int rank, const void **pp_url, size_t *p_urlsize)
get wide address for vector connect
static int nm_ibverbs_cnx_lazy_ready(struct nm_ibverbs_cnx_s *p_ibverbs_cnx)
returns whether the given lazy connection is ready for communication
Definition nm_ibverbs.h:368
static uint32_t nm_ibverbs_qpn_hash(const uint32_t *p_int)
Definition nm_ibverbs.h:115
void nm_ibverbs_ud_recv_pool_post(struct nm_ibverbs_ud_recv_pool_s *p_recv, struct nm_ibverbs_ud_ep_s *p_ud_ep, void *buf, size_t size, int depth)
#define NM_IBVERBS_UD_DEPTH
size of QP for send/recv on UD QP for connection establishment
Definition nm_ibverbs.h:29
void nm_ibverbs_context_delete(struct nm_ibverbs_context_s *p_ibverbs_context)
int nm_ibverbs_dereg_mr(struct nm_ibverbs_context_s *p_ibverbs_context, struct ibv_mr *p_mr)
int nm_ibverbs_memalign
nm_ibverbs_wrid_ud_e
list of WRIDs used on UD
Definition nm_ibverbs.h:78
@ NM_IBVERBS_WRID_UD_RECV_POOL_LAST
size of QP for send/recv on UD QP for connection establishment
Definition nm_ibverbs.h:82
@ NM_IBVERBS_WRID_UD_RECV
Definition nm_ibverbs.h:80
@ NM_IBVERBS_WRID_UD_RECV_POOL_FIRST
Definition nm_ibverbs.h:81
@ NM_IBVERBS_WRID_UD_SEND
Definition nm_ibverbs.h:79
Definition of the minidriver interface.
nm_len_t size
size of the onsided data (not incuding target-side completion)
nm_onesided_flag_t flags
main header for private nmad definitions.
This is the common public header for NewMad.
uint64_t nm_len_t
data length used by nmad
Definition nm_types.h:68
internal state of a data slicer.
Definition nm_data.h:772
Performance information for driver.
the addresse for a QP
Definition nm_ibverbs.h:101
union ibv_gid gid
Definition nm_ibverbs.h:106
an addresse entry used to exchange connection addresses
Definition nm_ibverbs.h:220
uint64_t oob_data
out-of-band data usable by the driver
Definition nm_ibverbs.h:230
struct nm_ibverbs_addr_s ud_addr
remote address of IB context (UD endpoint)
Definition nm_ibverbs.h:221
struct nm_ibverbs_cnx_addr_s cnx_addr
remote address of single connection
Definition nm_ibverbs.h:222
enum nm_ibverbs_cnx_addr_msg_s::nm_ibverbs_cnx_addr_state_e state
remote latest received state
int timeout
other side notified timeout
Definition nm_ibverbs.h:229
@ NM_IBVERBS_CNX_ADDR_NONE
invalid cnx addr
Definition nm_ibverbs.h:225
@ NM_IBVERBS_CNX_ADDR_CONNECTED
connection established
Definition nm_ibverbs.h:227
@ NM_IBVERBS_CNX_ADDR_OK
cnx addr ok
Definition nm_ibverbs.h:226
the address for a connection (one per track+gate).
Definition nm_ibverbs.h:138
struct nm_ibverbs_segment_s segment
Definition nm_ibverbs.h:140
struct nm_ibverbs_addr_s addr
Definition nm_ibverbs.h:139
a packet sent through UD for address exchange
Definition nm_ibverbs.h:235
struct nm_ibverbs_cnx_addr_msg_s addr_msg
Definition nm_ibverbs.h:237
an IB connection for a given destination (QP)
Definition nm_ibverbs.h:306
struct nm_ibverbs_cnx_addr_s remote_addr
Definition nm_ibverbs.h:309
struct ibv_cq * if_cq
CQ for incoming packets.
Definition nm_ibverbs.h:312
struct nm_ibverbs_cnx_s::@5 pending
count of pending packets
struct ibv_cq * of_cq
CQ for outgoing packets.
Definition nm_ibverbs.h:311
struct nm_ibverbs_cnx_addr_s local_addr
Definition nm_ibverbs.h:308
int wrids[_NM_IBVERBS_WRID_MAX]
Definition nm_ibverbs.h:318
struct nm_ibverbs_cnx_addr_entry_s * p_addr_entry
address entry for thix cnx
Definition nm_ibverbs.h:307
struct nm_ibverbs_cnx_s::@6 vector_connect
information only available when vectored connection is used.
int max_inline
max size of data for IBV inline RDMA
Definition nm_ibverbs.h:313
struct nm_ibverbs_context_s * p_ibverbs_context
Definition nm_ibverbs.h:314
struct ibv_qp * qp
QP for this connection.
Definition nm_ibverbs.h:310
int use_srq
whether QPs will actually use SRQs for receive
Definition nm_ibverbs.h:298
int mtu
MTU to use; IBV_MTU_1024, IBV_MTU_2048, IBV_MTU_4096.
Definition nm_ibverbs.h:300
int lazy_connect
whether lazy connect is enabled
Definition nm_ibverbs.h:297
int use_comp_channel
whether we will use completion channel (blocking syscalls)
Definition nm_ibverbs.h:299
a context for a HCA in RC mode
Definition nm_ibverbs.h:266
struct nm_ibverbs_ud_recv_pool_s recv_pool
Definition nm_ibverbs.h:276
struct nm_ibverbs_cnx_qpn_hashtable_s cnx_by_qpn
table of cnx hashed by their local QPN
Definition nm_ibverbs.h:274
struct nm_ibverbs_cnx_addr_entry_list_s pending_entries
list of entries currently in progress, sorted by timeout
Definition nm_ibverbs.h:275
struct nm_ibverbs_cnx_s ** pp_cached_cnxs
array of pre-allocated connections
Definition nm_ibverbs.h:285
nm_spinlock_t lock
lock to protect the connection-related fields
Definition nm_ibverbs.h:271
struct ibv_cq * srq_cq
CQ used for SRQs.
Definition nm_ibverbs.h:290
struct nm_ibverbs_ud_ep_s udep
UD endpoint for connection management.
Definition nm_ibverbs.h:272
struct ibv_comp_channel * comp_channel
completion channel for blocking calls
Definition nm_ibverbs.h:291
struct nm_ibverbs_context_s::nm_ibverbs_opts_s ib_opts
struct nm_ibverbs_context_s::@4 srq
struct nm_ibverbs_hca_s hca
global HCA attached to this context
Definition nm_ibverbs.h:267
struct nm_ibverbs_context_s::@2 connect
connection management using UD
int cancel_fd[2]
pipe used to cancel a wait event on comp channel
Definition nm_ibverbs.h:292
struct nm_ibverbs_cnx_addr_entry_hashtable_s addr_hash
cnx addresses, hashed by remote context address
Definition nm_ibverbs.h:273
struct ibv_srq * p_srq
shared receive queue (if supported by device)
Definition nm_ibverbs.h:289
volatile int waiting
whether we are in a blocking CQ event wait
Definition nm_ibverbs.h:293
void * p_wide_url
wide url containing both UD url & vector of pre-allocated cnxs
Definition nm_ibverbs.h:282
struct nm_ibverbs_cnx_connect_packet_s recv_packets[8192]
Definition nm_ibverbs.h:277
struct nm_ibverbs_context_s::@3 vector_connect
vectored connection, for launchers that support wide url and drivers with bare IB addr (no segment)
Global state of a HCA with its context.
Definition nm_ibverbs.h:145
uint64_t max_msg_size
maximum message size
Definition nm_ibverbs.h:164
uint16_t lid
local IB LID
Definition nm_ibverbs.h:149
struct nm_ibverbs_hca_s::@1 async_events
int max_mr
maximum number of MR
Definition nm_ibverbs.h:160
int max_cqe
maximum number of entries per CQ
Definition nm_ibverbs.h:159
uint64_t max_mr_size
maximum size for a MR
Definition nm_ibverbs.h:162
const char * device
Definition nm_ibverbs.h:146
long n_mem_reg
number of memory blocks registered in this HCA context
Definition nm_ibverbs.h:175
void(* p_reg_back_pressure)(void *, nm_len_t)
function to ask to reduce pressure on memory registration to rcache
Definition nm_ibverbs.h:176
int max_srq
maximum number of SRQs; 0 if not supported
Definition nm_ibverbs.h:161
nm_len_t size_mem_reg
total amount of memory registered in this HCA context
Definition nm_ibverbs.h:174
union ibv_gid gid
local IB GID
Definition nm_ibverbs.h:150
struct ibv_context * context
global IB context
Definition nm_ibverbs.h:152
struct ibv_pd * pd
global IB protection domain
Definition nm_ibverbs.h:153
int gidx
< index of the GID in table; -1 if none
Definition nm_ibverbs.h:151
int srq_limit_reached
an srq low level event was triggered
Definition nm_ibverbs.h:172
int max_qp
maximum number of QP
Definition nm_ibverbs.h:156
struct nm_ibverbs_hca_s::@0 ib_caps
int max_cq
maximum number of CQ
Definition nm_ibverbs.h:158
uint64_t page_size_cap
maximum page size for device
Definition nm_ibverbs.h:163
struct ibv_device * ib_dev
IB device.
Definition nm_ibverbs.h:148
int max_qp_wr
maximum number of WR per QP
Definition nm_ibverbs.h:157
void * _reg_back_pressure_status
data given to p_reg_back_pressure
Definition nm_ibverbs.h:177
common interface for ibverbs
Definition nm_ibverbs.h:328
Definition nm_ibverbs.h:608
void * p_ptr
Definition nm_ibverbs.h:609
struct ibv_mr * p_mr
Definition nm_ibverbs.h:610
a pool of pre-registered memory buffers
Definition nm_ibverbs.h:633
struct nm_ibverbs_regpool_slice_lfstack_s slices
Definition nm_ibverbs.h:634
struct nm_ibverbs_context_s * p_ibverbs_context
Definition nm_ibverbs.h:638
nm_len_t entry_size
size of allocated entries
Definition nm_ibverbs.h:636
struct nm_ibverbs_regpool_block_lfstack_s blocks
Definition nm_ibverbs.h:635
nm_len_t num_entries
number of entries in a slice
Definition nm_ibverbs.h:637
an RDMA segment.
Definition nm_ibverbs.h:88
uint64_t raddr
remote address
Definition nm_ibverbs.h:89
uint32_t rkey
key for the MR containing the segment
Definition nm_ibverbs.h:90
an endpoint for UD messaging
Definition nm_ibverbs.h:185
struct nm_ibverbs_hca_s * p_hca
pointer to the HCA descriptor
Definition nm_ibverbs.h:186
struct ibv_qp * qp
QP for this endpoint.
Definition nm_ibverbs.h:188
struct nm_ibverbs_addr_s local_addr
local address of this endpoint
Definition nm_ibverbs.h:187
struct ibv_cq * if_cq
CQ for incoming packets.
Definition nm_ibverbs.h:190
struct ibv_cq * of_cq
CQ for outgoing packets.
Definition nm_ibverbs.h:189
struct nm_ibverbs_ud_ep_s * p_ud_ep
Definition nm_ibverbs.h:201
struct nm_ibverbs_ud_ep_s * p_ud_ep
Definition nm_ibverbs.h:195
struct ibv_mr * mr
Definition nm_ibverbs.h:196
struct ibv_ah * ah
Definition nm_ibverbs.h:211
struct ibv_mr * mr
Definition nm_ibverbs.h:212
struct nm_ibverbs_ud_ep_s * p_ud_ep
Definition nm_ibverbs.h:210