Motr  M0
lnet_core.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-2020 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_LNET_CORE_H__
26 #define __MOTR_NET_LNET_CORE_H__
27 
161 #include "net/lnet/lnet.h"
163 
181 static int nlx_core_dom_init(struct m0_net_domain *dom,
182  struct nlx_core_domain *lcdom);
183 
187 static void nlx_core_dom_fini(struct nlx_core_domain *lcdom);
188 
193 
198  struct nlx_core_domain *lcdom);
199 
203 static int32_t nlx_core_get_max_buffer_segments(struct nlx_core_domain *lcdom);
204 
214 static int nlx_core_buf_register(struct nlx_core_domain *lcdom,
215  nlx_core_opaque_ptr_t buffer_id,
216  const struct m0_bufvec *bvec,
217  struct nlx_core_buffer *lcbuf);
218 
224 static void nlx_core_buf_deregister(struct nlx_core_domain *lcdom,
225  struct nlx_core_buffer *lcbuf);
226 
246 static int nlx_core_buf_msg_recv(struct nlx_core_domain *lcdom,
247  struct nlx_core_transfer_mc *lctm,
248  struct nlx_core_buffer *lcbuf);
249 
268 static int nlx_core_buf_msg_send(struct nlx_core_domain *lcdom,
269  struct nlx_core_transfer_mc *lctm,
270  struct nlx_core_buffer *lcbuf);
271 
296 static int nlx_core_buf_active_recv(struct nlx_core_domain *lcdom,
297  struct nlx_core_transfer_mc *lctm,
298  struct nlx_core_buffer *lcbuf);
299 
321 static int nlx_core_buf_active_send(struct nlx_core_domain *lcdom,
322  struct nlx_core_transfer_mc *lctm,
323  struct nlx_core_buffer *lcbuf);
324 
342 static void nlx_core_buf_desc_encode(struct nlx_core_transfer_mc *lctm,
343  struct nlx_core_buffer *lcbuf,
344  struct nlx_core_buf_desc *cbd);
345 
370 static int nlx_core_buf_desc_decode(struct nlx_core_transfer_mc *lctm,
371  struct nlx_core_buffer *lcbuf,
372  struct nlx_core_buf_desc *cbd);
373 
397 static int nlx_core_buf_passive_recv(struct nlx_core_domain *lcdom,
398  struct nlx_core_transfer_mc *lctm,
399  struct nlx_core_buffer *lcbuf);
400 
423 static int nlx_core_buf_passive_send(struct nlx_core_domain *lcdom,
424  struct nlx_core_transfer_mc *lctm,
425  struct nlx_core_buffer *lcbuf);
426 
434 static int nlx_core_buf_del(struct nlx_core_domain *lcdom,
435  struct nlx_core_transfer_mc *lctm,
436  struct nlx_core_buffer *lcbuf);
437 
447 static int nlx_core_buf_event_wait(struct nlx_core_domain *lcdom,
448  struct nlx_core_transfer_mc *lctm,
450 
464 static bool nlx_core_buf_event_get(struct nlx_core_transfer_mc *lctm,
465  struct nlx_core_buffer_event *lcbe);
466 
475 static int nlx_core_ep_addr_decode(struct nlx_core_domain *lcdom,
476  const char *ep_addr,
477  struct nlx_core_ep_addr *cepa);
478 
487 static void nlx_core_ep_addr_encode(struct nlx_core_domain *lcdom,
488  const struct nlx_core_ep_addr *cepa,
490 
497 static int nlx_core_nidstrs_get(struct nlx_core_domain *lcdom,
498  char ***nidary);
499 
503 static void nlx_core_nidstrs_put(struct nlx_core_domain *lcdom,
504  char ***nidary);
505 
520 static int nlx_core_tm_start(struct nlx_core_domain *lcdom,
521  struct m0_net_transfer_mc *tm,
522  struct nlx_core_transfer_mc *lctm);
523 
531 static void nlx_core_tm_stop(struct nlx_core_domain *lcdom,
532  struct nlx_core_transfer_mc *lctm);
533 
537 static inline bool nlx_core_ep_eq(const struct nlx_core_ep_addr *cep1,
538  const struct nlx_core_ep_addr *cep2)
539 {
540  return cep1->cepa_nid == cep2->cepa_nid &&
541  cep1->cepa_pid == cep2->cepa_pid &&
542  cep1->cepa_portal == cep2->cepa_portal &&
543  cep1->cepa_tmid == cep2->cepa_tmid;
544 }
545 
564 static int nlx_core_bevq_provision(struct nlx_core_domain *lcdom,
565  struct nlx_core_transfer_mc *lctm,
566  size_t need);
567 
580 static void nlx_core_bevq_release(struct nlx_core_transfer_mc *lctm,
581  size_t release);
582 
598 static int nlx_core_new_blessed_bev(struct nlx_core_domain *lcdom,
599  struct nlx_core_transfer_mc *lctm,
600  struct nlx_core_buffer_event **bevp);
601 
610 static void *nlx_core_mem_alloc(size_t size, unsigned shift);
611 
615 static void nlx_core_mem_free(void *data, size_t size, unsigned shift);
616 
617 static void nlx_core_dom_set_debug(struct nlx_core_domain *lcdom, unsigned dbg);
618 static void nlx_core_tm_set_debug(struct nlx_core_transfer_mc *lctm,
619  unsigned dbg);
620 
626 #define NLX_PO2_SHIFT(n) \
627  (((n) <= 8) ? 3 : ((n) <= 16) ? 4 : ((n) <= 32) ? 5 : \
628  ((n) <= 64) ? 6 : ((n) <= 128) ? 7 : ((n) <= 256) ? 8 : \
629  ((n) <= 512) ? 9 : ((n) / 0))
630 #define NLX_ALLOC_ALIGNED_PTR(ptr) \
631  ((ptr) = nlx_core_mem_alloc(sizeof ((ptr)[0]), \
632  NLX_PO2_SHIFT(sizeof ((ptr)[0]))))
633 #define NLX_FREE_ALIGNED_PTR(ptr) \
634  nlx_core_mem_free((ptr), sizeof ((ptr)[0]), \
635  NLX_PO2_SHIFT(sizeof ((ptr)[0])))
636 
637 #define NLX_ALLOC(ptr, len) ({ ptr = m0_alloc(len); })
638 #define NLX_ALLOC_PTR(ptr) M0_ALLOC_PTR(ptr)
639 #define NLX_ALLOC_ARR(ptr, nr) M0_ALLOC_ARR(ptr, nr)
640  /* LNetCore */
642 
643 #endif /* __MOTR_NET_LNET_CORE_H__ */
644 
645 /*
646  * Local variables:
647  * c-indentation-style: "K&R"
648  * c-basic-offset: 8
649  * tab-width: 8
650  * fill-column: 79
651  * scroll-step: 1
652  * End:
653  */
static int nlx_core_buf_msg_recv(struct nlx_core_domain *lcdom, struct nlx_core_transfer_mc *lctm, struct nlx_core_buffer *lcbuf)
Definition: klnet_core.c:1373
static int nlx_core_buf_passive_send(struct nlx_core_domain *lcdom, struct nlx_core_transfer_mc *lctm, struct nlx_core_buffer *lcbuf)
Definition: klnet_core.c:1617
static const char * ep_addr
Definition: rpc_machine.c:35
static void nlx_core_buf_deregister(struct nlx_core_domain *lcdom, struct nlx_core_buffer *lcbuf)
Definition: klnet_core.c:1330
string release
Definition: conf.py:42
uint64_t m0_time_t
Definition: time.h:37
static void * nlx_core_mem_alloc(size_t size, unsigned shift)
Definition: klnet_core.c:1138
struct m0_bufvec data
Definition: di.c:40
static int32_t nlx_core_get_max_buffer_segments(struct nlx_core_domain *lcdom)
Definition: klnet_core.c:1237
uint64_t m0_bcount_t
Definition: types.h:77
static void nlx_core_nidstrs_put(struct nlx_core_domain *lcdom, char ***nidary)
Definition: klnet_core.c:1774
static void nlx_core_dom_fini(struct nlx_core_domain *lcdom)
Definition: klnet_core.c:1207
Definition: sock.c:887
M0_INTERNAL void nlx_core_dom_set_debug(struct nlx_core_domain *lcdom, unsigned dbg)
Definition: lnet_core.c:447
M0_INTERNAL void nlx_core_bevq_release(struct nlx_core_transfer_mc *lctm, size_t release)
Definition: lnet_core.c:204
uint64_t nlx_core_opaque_ptr_t
M0_INTERNAL void nlx_core_tm_set_debug(struct nlx_core_transfer_mc *lctm, unsigned dbg)
Definition: lnet_core.c:453
M0_INTERNAL int nlx_core_bevq_provision(struct nlx_core_domain *lcdom, struct nlx_core_transfer_mc *lctm, size_t need)
Definition: lnet_core.c:175
static int nlx_core_dom_init(struct m0_net_domain *dom, struct nlx_core_domain *lcdom)
Definition: klnet_core.c:1167
static struct m0_bufvec bvec
Definition: xcode.c:169
static struct m0_stob_domain * dom
Definition: storage.c:38
void nlx_core_ep_addr_encode(struct nlx_core_domain *lcdom, const struct nlx_core_ep_addr *cepa, char buf[M0_NET_LNET_XEP_ADDR_LEN])
Definition: lnet_core.c:427
static void nlx_core_mem_free(void *data, size_t size, unsigned shift)
Definition: klnet_core.c:1143
M0_INTERNAL bool nlx_core_buf_event_get(struct nlx_core_transfer_mc *lctm, struct nlx_core_buffer_event *lcbe)
Definition: lnet_core.c:215
static int nlx_core_buf_passive_recv(struct nlx_core_domain *lcdom, struct nlx_core_transfer_mc *lctm, struct nlx_core_buffer *lcbuf)
Definition: klnet_core.c:1566
static int nlx_core_nidstrs_get(struct nlx_core_domain *lcdom, char ***nidary)
Definition: klnet_core.c:1744
static int nlx_core_buf_register(struct nlx_core_domain *lcdom, nlx_core_opaque_ptr_t buffer_id, const struct m0_bufvec *bvec, struct nlx_core_buffer *lcbuf)
Definition: klnet_core.c:1295
static int nlx_core_buf_del(struct nlx_core_domain *lcdom, struct nlx_core_transfer_mc *lctm, struct nlx_core_buffer *lcbuf)
Definition: klnet_core.c:1631
static bool nlx_core_ep_eq(const struct nlx_core_ep_addr *cep1, const struct nlx_core_ep_addr *cep2)
Definition: lnet_core.h:537
static uint32_t timeout
Definition: console.c:52
int nlx_core_ep_addr_decode(struct nlx_core_domain *lcdom, const char *ep_addr, struct nlx_core_ep_addr *cepa)
Definition: lnet_core.c:386
M0_INTERNAL void nlx_core_buf_desc_encode(struct nlx_core_transfer_mc *lctm, struct nlx_core_buffer *lcbuf, struct nlx_core_buf_desc *cbd)
Definition: lnet_core.c:292
static int nlx_core_buf_active_send(struct nlx_core_domain *lcdom, struct nlx_core_transfer_mc *lctm, struct nlx_core_buffer *lcbuf)
Definition: klnet_core.c:1517
static int nlx_core_tm_start(struct nlx_core_domain *lcdom, struct m0_net_transfer_mc *tm, struct nlx_core_transfer_mc *lctm)
Definition: klnet_core.c:1942
m0_bcount_t size
Definition: di.c:39
static int nlx_core_buf_active_recv(struct nlx_core_domain *lcdom, struct nlx_core_transfer_mc *lctm, struct nlx_core_buffer *lcbuf)
Definition: klnet_core.c:1467
static m0_bcount_t nlx_core_get_max_buffer_segment_size(struct nlx_core_domain *lcdom)
Definition: klnet_core.c:1226
static int nlx_core_buf_event_wait(struct nlx_core_domain *lcdom, struct nlx_core_transfer_mc *lctm, m0_time_t timeout)
Definition: klnet_core.c:1685
static int nlx_core_buf_msg_send(struct nlx_core_domain *lcdom, struct nlx_core_transfer_mc *lctm, struct nlx_core_buffer *lcbuf)
Definition: klnet_core.c:1417
M0_INTERNAL int nlx_core_buf_desc_decode(struct nlx_core_transfer_mc *lctm, struct nlx_core_buffer *lcbuf, struct nlx_core_buf_desc *cbd)
Definition: lnet_core.c:330
static int nlx_core_new_blessed_bev(struct nlx_core_domain *lcdom, struct nlx_core_transfer_mc *lctm, struct nlx_core_buffer_event **bevp)
Definition: klnet_core.c:1785
Definition: vec.h:145
static m0_bcount_t nlx_core_get_max_buffer_size(struct nlx_core_domain *lcdom)
Definition: klnet_core.c:1220
static void nlx_core_tm_stop(struct nlx_core_domain *lcdom, struct nlx_core_transfer_mc *lctm)
Definition: klnet_core.c:1834