Motr  M0
libfab_internal.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2021 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #pragma once
24 
25 #ifndef __MOTR_NET_LIBFAB_LIBFAB_INTERNAL_H__
26 #define __MOTR_NET_LIBFAB_LIBFAB_INTERNAL_H__
27 
28 #ifdef ENABLE_LIBFAB
29 
30 #include <netinet/in.h> /* INET_ADDRSTRLEN */
31 
32 #include "rdma/fabric.h"
33 #include "rdma/fi_cm.h"
34 #include "rdma/fi_domain.h"
35 #include "rdma/fi_eq.h"
36 #include "rdma/fi_endpoint.h"
37 #include "rdma/fi_rma.h"
38 
39 extern struct m0_net_xprt m0_net_libfab_xprt;
40 
47 #define LIBFAB_VERSION FI_VERSION(1,11)
48 
49 #define LIBFAB_ADDR_LEN_MAX INET6_ADDRSTRLEN
50 #define LIBFAB_PORT_LEN_MAX 6
51 
55 enum m0_fab__libfab_params {
57  FAB_MR_ACCESS = (FI_READ | FI_WRITE | FI_RECV |
58  FI_SEND | FI_REMOTE_READ |
59  FI_REMOTE_WRITE),
61  FAB_MR_OFFSET = 0,
63  FAB_MR_FLAG = 0,
65  FAB_MR_KEY = 0xABCD,
67  FAB_VERBS_IOV_MAX = 16,
69  FAB_VERBS_MAX_BULK_SEG_SIZE = 131072,
71  FAB_VERBS_MAX_QUEUE_SIZE = 224,
72 
75  FAB_TCP_SOCK_IOV_MAX = 256,
78  FAB_TCP_SOCK_MAX_BULK_SEG_SIZE = 4096,
80  FAB_TCP_SOCK_MAX_QUEUE_SIZE = 1024,
81 
83  FAB_MAX_RPC_SEG_SIZE = (1 << 20),
85  FAB_MAX_RPC_SEG_NR = 1,
87  FAB_MAX_RPC_RECV_MSG_NR = 1,
89  FAB_DUMMY_DATA = 0xFABC0DE,
91  FAB_MAX_COMP_READ = 256,
93  FAB_WAIT_FD_TMOUT = 1000,
95  FAB_MAX_AEP_EQ_EV = 8,
97  FAB_MAX_PEP_EQ_EV = 256,
99  FAB_MAX_TX_CQ_EV = 1024,
101  FAB_MAX_RX_CQ_EV = 256,
103  FAB_MAX_SRX_SIZE = 4096,
105  FAB_NUM_BUCKETS_PER_QTYPE = 128,
107  FAB_BUF_TMOUT_CHK_INTERVAL = 1,
109  FAB_CONNECTING_TMOUT = 5,
111  FAB_TM_FID_MALLOC_STEP = 1024
112 };
113 
118 enum m0_fab__prov_type {
119  FAB_FABRIC_PROV_VERBS,
120  FAB_FABRIC_PROV_TCP,
121  FAB_FABRIC_PROV_SOCK,
122  /* Add all supported fabric providers above this line */
123  FAB_FABRIC_PROV_MAX
124 };
125 
129 enum m0_fab__conn_status {
130  FAB_NOT_CONNECTED,
131  FAB_CONNECTING,
132  FAB_CONNECTED
133 };
134 
138 enum m0_fab__tm_state {
139  FAB_TM_INIT,
140  FAB_TM_STARTED,
141  FAB_TM_SHUTDOWN
142 };
143 
147 enum m0_fab__buf_state {
148  FAB_BUF_INITIALIZED,
149  FAB_BUF_REGISTERED,
150  FAB_BUF_QUEUED,
151  FAB_BUF_CANCELED,
152  FAB_BUF_TIMEDOUT,
153  FAB_BUF_DEREGISTERED
154 };
155 
159 enum m0_fab__event_type {
160  FAB_COMMON_Q_EVENT,
161  FAB_PRIVATE_Q_EVENT
162 };
163 
167 enum m0_fab__connlink_status {
168  FAB_CONNLINK_DOWN = 0x00,
169  FAB_CONNLINK_TXEP_RDY = 0x01,
170  FAB_CONNLINK_RXEP_RDY = 0x02,
171  FAB_CONNLINK_RDY_TO_SEND = 0x03,
172  FAB_CONNLINK_PENDING_SEND_DONE = 0x07
173 };
174 
178 enum m0_fab__ep_iface {
179  FAB_LO,
180  FAB_TCP,
181  FAB_O2IB
182 };
183 
184 union m0_fab__token
185 {
186  uint32_t t_val;
187  struct {
188  /* m0_log2(roundup_power2(M0_NET_QT_NR+1)) */
189  uint32_t tf_queue_id : 4;
190  /* m0_log2(LIBFAB_AL_NUM_HASH_Q_PER_QUEUE) */
191  uint32_t tf_queue_num : 8;
192  /* 32 - m0_log2(LIBFAB_AL_NUM_HASH_Q_PER_QUEUE) - m0_log2(roundup_power2(M0_NET_QT_NR+1)) */
193  uint32_t tf_tag : 20;
194  } t_Fields;
195 };
196 
200 struct m0_fab__ev_ctx {
201  /* Type of event (common queue/ private queue). */
202  enum m0_fab__event_type evctx_type;
203 
204  /* Endpoint context associated for event. */
205  void *evctx_ep;
206 
207  /* Debug data. */
208  char *evctx_dbg;
209 
210  /* Position in array of fids. */
211  uint32_t evctx_pos;
212 };
213 
217 struct m0_fab__bufht {
219  uint64_t bht_magic;
220 
222  struct m0_htable bht_hash;
223 };
224 
228 struct m0_fab__ndom {
229 
231  struct m0_net_domain *fnd_ndom;
232 
234  struct m0_mutex fnd_lock;
235 
237  struct m0_tl fnd_fabrics;
238 
240  char fnd_loc_ip[INET_ADDRSTRLEN];
241 
243  uint32_t fnd_seg_nr;
244 
246  uint32_t fnd_seg_size;
247 };
248 
252 struct m0_fab__fab {
254  uint64_t fab_magic;
255 
257  struct fi_info *fab_fi;
258 
260  struct fid_fabric *fab_fab;
261 
263  struct fid_domain *fab_dom;
264 
266  struct m0_tlink fab_link;
267 
269  enum m0_fab__prov_type fab_prov;
270 
272  uint32_t fab_max_iov;
273 };
274 
278 struct m0_fab__pep_res{
280  struct fid_eq *fpr_eq;
281 
283  struct m0_fab__ev_ctx fpr_ctx;
284 };
285 
289 struct m0_fab__tx_res{
290  /* Event queue for transmit endpoint */
291  struct fid_eq *ftr_eq;
292 
294  struct m0_fab__ev_ctx ftr_ctx;
295 };
296 
300 struct m0_fab__rx_res{
302  struct fid_eq *frr_eq;
303 
305  struct fid_cq *frr_cq;
306 
308  struct m0_fab__ev_ctx frr_cq_ctx;
309 
311  struct m0_fab__ev_ctx frr_eq_ctx;
312 };
313 
317 struct m0_fab__active_ep {
319  struct fid_ep *aep_txep;
320 
322  struct fid_ep *aep_rxep;
323 
325  struct m0_fab__tx_res aep_tx_res;
326 
328  struct m0_fab__rx_res aep_rx_res;
329 
331  enum m0_fab__conn_status aep_tx_state;
332 
334  enum m0_fab__conn_status aep_rx_state;
335 
337  volatile uint32_t aep_bulk_cnt;
338 
340  bool aep_txq_full;
341 
346  m0_time_t aep_connecting_tmout;
347 };
348 
352 struct m0_fab__passive_ep {
354  struct fid_pep *pep_pep;
355 
357  struct m0_fab__active_ep *pep_aep;
358 
360  struct m0_fab__pep_res pep_res;
361 };
362 
366 struct m0_fab__ep {
368  struct m0_net_end_point fep_nep;
369 
371  struct m0_net_ip_addr fep_name;
372 
374  uint64_t fep_name_n;
375 
377  struct m0_fab__active_ep *fep_aep;
378 
380  struct m0_fab__passive_ep *fep_listen;
381 
383  struct m0_tl fep_sndbuf;
384 
386  uint8_t fep_connlink;
387 };
388 
393 struct m0_fab__tm_fids {
394  /* Pointer to the head of the list (array in this case) */
395  struct fid **ftf_head;
396 
397  /* Pointer to the ctx which is stored in this array */
398  struct m0_fab__ev_ctx **ftf_ctx;
399 
400  /* Size of array used for storing fids */
401  uint32_t ftf_arr_size;
402 
403  /* Count of fids in the array */
404  volatile uint32_t ftf_cnt;
405 };
406 
410 struct m0_fab__tm {
412  struct m0_net_transfer_mc *ftm_ntm;
413 
426  struct m0_thread ftm_poller;
427 
429  int ftm_epfd;
430 
432  struct m0_fab__tm_fids ftm_fids;
433 
435  struct m0_fab__fab *ftm_fab;
436 
438  struct m0_fab__ep *ftm_pep;
439 
441  struct fid_ep *ftm_rctx;
442 
444  struct fid_cq *ftm_tx_cq;
445 
447  struct m0_fab__ev_ctx ftm_txcq_ctx;
448 
450  volatile enum m0_fab__tm_state ftm_state;
451 
453  struct m0_tl ftm_done;
454 
456  struct m0_mutex ftm_endlock;
457 
459  struct m0_mutex ftm_evpost;
460 
462  struct m0_tl ftm_bulk;
463 
465  struct fi_rma_iov *ftm_rem_iov;
466 
468  struct iovec *ftm_loc_iov;
469 
471  m0_time_t ftm_tmout_check;
472 
474  struct m0_fab__bufht ftm_bufhash;
475 
477  uint64_t ftm_mr_key_idx;
478 
480  uint32_t ftm_rr_qt[M0_NET_QT_NR+1];
481 
483  uint32_t ftm_op_id;
484 };
485 
489 struct m0_fab__buf_mr {
491  void **bm_desc;
492 
494  struct fid_mr **bm_mr;
495 };
496 
501 struct m0_fab__bdesc {
503  struct m0_net_ip_params fbd_netaddr;
504 
506  uint32_t fbd_iov_cnt;
507 
509  uint32_t fbd_buftoken;
510 };
511 
515 struct m0_fab__buf_xfer_params {
517  uint32_t bxp_loc_sidx;
518 
520  uint32_t bxp_rem_sidx;
521 
523  uint32_t bxp_xfer_len;
524 
526  uint32_t bxp_rem_soff;
527 
529  uint32_t bxp_loc_soff;
530 };
531 
535 struct m0_fab__buf {
537  uint64_t fb_magic;
538 
540  uint64_t fb_sndmagic;
541 
543  uint64_t fb_htmagic;
544 
546  uint32_t fb_dummy[2];
547 
549  struct m0_fab__bdesc *fb_rbd;
550 
552  struct fi_rma_iov *fb_riov;
553 
555  struct m0_fab__buf_mr fb_mr;
556 
558  struct fid_domain *fb_dp;
559 
561  struct m0_net_buffer *fb_nb;
562 
564  struct m0_fab__ep *fb_ev_ep;
565 
567  struct m0_fab__ep *fb_txctx;
568 
570  struct m0_tlink fb_linkage;
571 
573  struct m0_tlink fb_snd_link;
574 
576  struct m0_hlink fb_htlink;
577 
579  int32_t fb_status;
580 
582  m0_bindex_t fb_length;
583 
585  volatile uint32_t fb_wr_cnt;
586 
588  struct m0_fab__buf_xfer_params fb_xfer_params;
589 
590 
592  void* fb_bulk_op;
593 
595  volatile enum m0_fab__buf_state fb_state;
596 
598  uint32_t fb_token;
599 };
600 
604 struct m0_fab__conn_data {
606  struct m0_net_ip_params fcd_addr;
607 };
608 
613 struct m0_fab__bulk_op {
615  uint64_t fbl_magic;
616 
618  struct m0_fab__buf *fbl_buf;
619 
621  struct m0_fab__active_ep *fbl_aep;
622 
624  struct m0_tlink fbl_link;
625 };
626 
627 #endif /* ENABLE_LIBFAB */
628 
630 #endif /* __MOTR_NET_LIBFAB_LIBFAB_INTERNAL_H__ */
631 
632 /*
633  * Local variables:
634  * c-indentation-style: "K&R"
635  * c-basic-offset: 8
636  * tab-width: 8
637  * fill-column: 80
638  * scroll-step: 1
639  * End:
640  */
641 /*
642  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
643  */
644 
uint64_t m0_time_t
Definition: time.h:37
uint64_t m0_bindex_t
Definition: types.h:80
struct m0_fid fid
Definition: di.c:46
Definition: tlist.h:251
Definition: mutex.h:47