1 /**
2 * Copyright (C) Mellanox Technologies Ltd. 2001-2019. ALL RIGHTS RESERVED.
3 * See file LICENSE for terms.
4 */
5
6 #ifdef HAVE_CONFIG_H
7 # include "config.h"
8 #endif
9
10 #include "tcp.h"
11 #include "tcp_sockcm.h"
12 #include <uct/base/uct_md.h>
13
14
uct_tcp_md_query(uct_md_h md,uct_md_attr_t * attr)15 static ucs_status_t uct_tcp_md_query(uct_md_h md, uct_md_attr_t *attr)
16 {
17 /* Dummy memory registration provided. No real memory handling exists */
18 attr->cap.flags = UCT_MD_FLAG_REG |
19 UCT_MD_FLAG_NEED_RKEY; /* TODO ignore rkey in rma/amo ops */
20 attr->cap.max_alloc = 0;
21 attr->cap.reg_mem_types = UCS_MEMORY_TYPES_CPU_ACCESSIBLE;
22 attr->cap.access_mem_type = UCS_MEMORY_TYPE_HOST;
23 attr->cap.detect_mem_types = 0;
24 attr->cap.max_reg = ULONG_MAX;
25 attr->rkey_packed_size = 0;
26 attr->reg_cost = ucs_linear_func_make(0, 0);
27 memset(&attr->local_cpus, 0xff, sizeof(attr->local_cpus));
28 return UCS_OK;
29 }
30
uct_tcp_md_mem_reg(uct_md_h md,void * address,size_t length,unsigned flags,uct_mem_h * memh_p)31 static ucs_status_t uct_tcp_md_mem_reg(uct_md_h md, void *address, size_t length,
32 unsigned flags, uct_mem_h *memh_p)
33 {
34 /* We have to emulate memory registration. Return dummy pointer */
35 *memh_p = (void*)0xdeadbeef;
36 return UCS_OK;
37 }
38
39 static ucs_status_t
uct_tcp_md_open(uct_component_t * component,const char * md_name,const uct_md_config_t * md_config,uct_md_h * md_p)40 uct_tcp_md_open(uct_component_t *component, const char *md_name,
41 const uct_md_config_t *md_config, uct_md_h *md_p)
42 {
43 static uct_md_ops_t md_ops = {
44 .close = ucs_empty_function,
45 .query = uct_tcp_md_query,
46 .mkey_pack = ucs_empty_function_return_success,
47 .mem_reg = uct_tcp_md_mem_reg,
48 .mem_dereg = ucs_empty_function_return_success,
49 .detect_memory_type = ucs_empty_function_return_unsupported
50 };
51 static uct_md_t md = {
52 .ops = &md_ops,
53 .component = &uct_tcp_component
54 };
55
56 *md_p = &md;
57 return UCS_OK;
58 }
59
uct_tcp_md_rkey_unpack(uct_component_t * component,const void * rkey_buffer,uct_rkey_t * rkey_p,void ** handle_p)60 static ucs_status_t uct_tcp_md_rkey_unpack(uct_component_t *component,
61 const void *rkey_buffer,
62 uct_rkey_t *rkey_p, void **handle_p)
63 {
64 /**
65 * Pseudo stub function for the key unpacking
66 * Need rkey == 0 due to work with same process to reuse uct_base_[put|get|atomic]*
67 */
68 *rkey_p = 0;
69 *handle_p = NULL;
70 return UCS_OK;
71 }
72
73 uct_component_t uct_tcp_component = {
74 .query_md_resources = uct_md_query_single_md_resource,
75 .md_open = uct_tcp_md_open,
76 .cm_open = UCS_CLASS_NEW_FUNC_NAME(uct_tcp_sockcm_t),
77 .rkey_unpack = uct_tcp_md_rkey_unpack,
78 .rkey_ptr = ucs_empty_function_return_unsupported,
79 .rkey_release = ucs_empty_function_return_success,
80 .name = UCT_TCP_NAME,
81 .md_config = UCT_MD_DEFAULT_CONFIG_INITIALIZER,
82 .cm_config = {
83 .name = "TCP-SOCKCM connection manager",
84 .prefix = "TCP_CM_",
85 .table = uct_tcp_sockcm_config_table,
86 .size = sizeof(uct_tcp_sockcm_config_t),
87 },
88 .tl_list = UCT_COMPONENT_TL_LIST_INITIALIZER(&uct_tcp_component),
89 .flags = UCT_COMPONENT_FLAG_CM
90 };
91 UCT_COMPONENT_REGISTER(&uct_tcp_component)
92