1 /*
2  * Copyright (c) 2015-2016 Intel Corporation. All rights reserved.
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and/or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32 
33 #include "rxm.h"
34 
35 #define RXM_TX_CAPS (OFI_TX_MSG_CAPS | FI_TAGGED | OFI_TX_RMA_CAPS | FI_ATOMICS)
36 #define RXM_RX_CAPS (FI_SOURCE | OFI_RX_MSG_CAPS | FI_TAGGED | \
37 		     OFI_RX_RMA_CAPS | FI_ATOMICS | FI_DIRECTED_RECV | \
38 		     FI_MULTI_RECV)
39 #define RXM_DOMAIN_CAPS (FI_LOCAL_COMM | FI_REMOTE_COMM)
40 
41 // TODO have a separate "check info" against which app hints would be checked.
42 
43 /* Since we are a layering provider, the attributes for which we rely on the
44  * core provider are set to full capability. This ensures that ofix_getinfo
45  * check hints succeeds and the core provider can accept / reject any capability
46  * requested by the app. */
47 
48 struct fi_tx_attr rxm_tx_attr = {
49 	.caps = RXM_TX_CAPS,
50 	.op_flags = RXM_PASSTHRU_TX_OP_FLAGS | RXM_TX_OP_FLAGS,
51 	.msg_order = ~0x0ULL,
52 	.comp_order = FI_ORDER_NONE,
53 	.size = 1024,
54 	.iov_limit = RXM_IOV_LIMIT,
55 	.rma_iov_limit = RXM_IOV_LIMIT,
56 };
57 
58 struct fi_rx_attr rxm_rx_attr = {
59 	.caps = RXM_RX_CAPS,
60 	.op_flags = RXM_PASSTHRU_RX_OP_FLAGS | RXM_RX_OP_FLAGS,
61 	.msg_order = ~0x0ULL,
62 	.comp_order = FI_ORDER_NONE,
63 	.size = 1024,
64 	.iov_limit= RXM_IOV_LIMIT,
65 };
66 
67 struct fi_ep_attr rxm_ep_attr = {
68 	.type = FI_EP_RDM,
69 	.protocol = FI_PROTO_RXM,
70 	.protocol_version = 1,
71 	.max_msg_size = SIZE_MAX,
72 	.tx_ctx_cnt = 1,
73 	.rx_ctx_cnt = 1,
74 	.max_order_raw_size = SIZE_MAX,
75 	.max_order_war_size = SIZE_MAX,
76 	.max_order_waw_size = SIZE_MAX,
77 	.mem_tag_format = FI_TAG_GENERIC,
78 };
79 
80 struct fi_domain_attr rxm_domain_attr = {
81 	.caps = RXM_DOMAIN_CAPS,
82 	.threading = FI_THREAD_SAFE,
83 	.control_progress = FI_PROGRESS_AUTO,
84 	.data_progress = FI_PROGRESS_AUTO,
85 	.resource_mgmt = FI_RM_ENABLED,
86 	.av_type = FI_AV_UNSPEC,
87 	/* Advertise support for FI_MR_BASIC so that ofi_check_info call
88 	 * doesn't fail at RxM level. If an app requires FI_MR_BASIC, it
89 	 * would be passed down to core provider. */
90 	.mr_mode = FI_MR_BASIC | FI_MR_SCALABLE,
91 	.cq_data_size = sizeof_field(struct ofi_op_hdr, data),
92 	.cq_cnt = (1 << 16),
93 	.ep_cnt = (1 << 15),
94 	.tx_ctx_cnt = 1,
95 	.rx_ctx_cnt = 1,
96 	.max_ep_tx_ctx = 1,
97 	.max_ep_rx_ctx = 1,
98 	.mr_iov_limit = 1,
99 };
100 
101 struct fi_fabric_attr rxm_fabric_attr = {
102 	.prov_version = OFI_VERSION_DEF_PROV,
103 };
104 
105 struct fi_info rxm_info = {
106 	.caps = RXM_TX_CAPS | RXM_RX_CAPS | RXM_DOMAIN_CAPS | FI_COLLECTIVE,
107 	.addr_format = FI_SOCKADDR,
108 	.tx_attr = &rxm_tx_attr,
109 	.rx_attr = &rxm_rx_attr,
110 	.ep_attr = &rxm_ep_attr,
111 	.domain_attr = &rxm_domain_attr,
112 	.fabric_attr = &rxm_fabric_attr
113 };
114 
115 struct util_prov rxm_util_prov = {
116 	.prov = &rxm_prov,
117 	.flags = 0,
118 };
119