1 /*
2  * Copyright (c) 2013-2017 Intel Corporation. All rights reserved.
3  * Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
4  *
5  * This software is available to you under a choice of one of two
6  * licenses.  You may choose to be licensed under the terms of the GNU
7  * General Public License (GPL) Version 2, available from the file
8  * COPYING in the main directory of this source tree, or the
9  * BSD license below:
10  *
11  *     Redistribution and use in source and binary forms, with or
12  *     without modification, are permitted provided that the following
13  *     conditions are met:
14  *
15  *      - Redistributions of source code must retain the above
16  *        copyright notice, this list of conditions and the following
17  *        disclaimer.
18  *
19  *      - Redistributions in binary form must reproduce the above
20  *        copyright notice, this list of conditions and the following
21  *        disclaimer in the documentation and/or other materials
22  *        provided with the distribution.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31  * SOFTWARE.
32  */
33 
34 #ifndef FABRIC_H
35 #define FABRIC_H
36 
37 #include <stdint.h>
38 #include <stddef.h>
39 #include <sys/types.h>
40 #include <sys/uio.h>
41 
42 #ifdef __GNUC__
43 #define FI_DEPRECATED_FUNC __attribute__((deprecated))
44 #define FI_DEPRECATED_FIELD __attribute__((deprecated))
45 #elif defined(_MSC_VER)
46 #define FI_DEPRECATED_FUNC __declspec(deprecated)
47 #define FI_DEPRECATED_FIELD
48 #else
49 #define FI_DEPRECATED_FUNC
50 #define FI_DEPRECATED_FIELD
51 #endif
52 
53 #if defined(__GNUC__) && !defined(__clang__)
54 #define EXTERNALLY_VISIBLE externally_visible
55 #else
56 #define EXTERNALLY_VISIBLE
57 #endif
58 
59 #if defined(_WIN32)
60 #include <BaseTsd.h>
61 #include <windows.h>
62 typedef SSIZE_T ssize_t;
63 #endif
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 #ifndef container_of
70 #define container_of(ptr, type, field) \
71 	((type *) ((char *)ptr - offsetof(type, field)))
72 #endif
73 
74 #ifndef count_of
75 #define count_of(x) 	\
76 	((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
77 #endif
78 
79 #define FI_MAJOR_VERSION 1
80 #define FI_MINOR_VERSION 10
81 #define FI_REVISION_VERSION 1
82 
83 enum {
84 	FI_PATH_MAX		= 256,
85 	FI_NAME_MAX		= 64,
86 	FI_VERSION_MAX		= 64
87 };
88 
89 #define FI_VERSION(major, minor) (((major) << 16) | (minor))
90 #define FI_MAJOR(version)	(version >> 16)
91 #define FI_MINOR(version)	(version & 0xFFFF)
92 #define FI_VERSION_GE(v1, v2)   ((FI_MAJOR(v1) > FI_MAJOR(v2)) || \
93 				 (FI_MAJOR(v1) == FI_MAJOR(v2) && \
94 				  FI_MINOR(v1) == FI_MINOR(v2)) || \
95 				 (FI_MAJOR(v1) == FI_MAJOR(v2) && \
96 				  FI_MINOR(v1) > FI_MINOR(v2)))
97 #define FI_VERSION_LT(v1, v2)	((FI_MAJOR(v1) < FI_MAJOR(v2)) || \
98 				 (FI_MAJOR(v1) == FI_MAJOR(v2) && \
99 				  FI_MINOR(v1) < FI_MINOR(v2)))
100 
101 uint32_t fi_version(void);
102 
103 struct fid;
104 struct fid_fabric;
105 struct fid_domain;
106 struct fid_av;
107 struct fid_wait;
108 struct fid_poll;
109 struct fid_eq;
110 struct fid_cq;
111 struct fid_cntr;
112 struct fid_ep;
113 struct fid_pep;
114 struct fid_stx;
115 struct fid_mr;
116 struct fid_nic;
117 
118 typedef struct fid *fid_t;
119 
120 /*
121  * Provider specific values are indicated by setting the high-order bit.
122  */
123 #define FI_PROV_SPECIFIC	(1U << 31)
124 
125 /*
126  * Flags
127  * The 64-bit flag field is used as follows:
128  * 1-grow up    common (usable with multiple operations)
129  * 59-grow down operation specific (used for single call/class)
130  * 60 - 63      provider specific
131  */
132 
133 #define FI_MSG			(1ULL << 1)
134 #define FI_RMA			(1ULL << 2)
135 #define FI_TAGGED		(1ULL << 3)
136 #define FI_ATOMIC		(1ULL << 4)
137 #define FI_ATOMICS		FI_ATOMIC
138 #define FI_MULTICAST		(1ULL << 5)
139 #define FI_COLLECTIVE		(1ULL << 6)
140 
141 #define FI_READ			(1ULL << 8)
142 #define FI_WRITE		(1ULL << 9)
143 #define FI_RECV			(1ULL << 10)
144 #define FI_SEND			(1ULL << 11)
145 #define FI_TRANSMIT		FI_SEND
146 #define FI_REMOTE_READ		(1ULL << 12)
147 #define FI_REMOTE_WRITE		(1ULL << 13)
148 
149 #define FI_MULTI_RECV		(1ULL << 16)
150 #define FI_REMOTE_CQ_DATA	(1ULL << 17)
151 #define FI_MORE			(1ULL << 18)
152 #define FI_PEEK			(1ULL << 19)
153 #define FI_TRIGGER		(1ULL << 20)
154 #define FI_FENCE		(1ULL << 21)
155 
156 #define FI_COMPLETION		(1ULL << 24)
157 #define FI_EVENT		FI_COMPLETION
158 #define FI_INJECT		(1ULL << 25)
159 #define FI_INJECT_COMPLETE	(1ULL << 26)
160 #define FI_TRANSMIT_COMPLETE	(1ULL << 27)
161 #define FI_DELIVERY_COMPLETE	(1ULL << 28)
162 #define FI_AFFINITY		(1ULL << 29)
163 #define FI_COMMIT_COMPLETE	(1ULL << 30)
164 #define FI_MATCH_COMPLETE	(1ULL << 31)
165 
166 #define FI_HMEM			(1ULL << 47)
167 #define FI_VARIABLE_MSG		(1ULL << 48)
168 #define FI_RMA_PMEM		(1ULL << 49)
169 #define FI_SOURCE_ERR		(1ULL << 50)
170 #define FI_LOCAL_COMM		(1ULL << 51)
171 #define FI_REMOTE_COMM		(1ULL << 52)
172 #define FI_SHARED_AV		(1ULL << 53)
173 #define FI_PROV_ATTR_ONLY	(1ULL << 54)
174 #define FI_NUMERICHOST		(1ULL << 55)
175 #define FI_RMA_EVENT		(1ULL << 56)
176 #define FI_SOURCE		(1ULL << 57)
177 #define FI_NAMED_RX_CTX		(1ULL << 58)
178 #define FI_DIRECTED_RECV	(1ULL << 59)
179 
180 
181 /* Tagged messages, buffered receives, CQ flags */
182 #define FI_CLAIM		(1ULL << 59)
183 #define FI_DISCARD		(1ULL << 58)
184 
185 
186 struct fi_ioc {
187 	void			*addr;
188 	size_t			count;
189 };
190 
191 /*
192  * Format for transport addresses to insert into address vectors
193  */
194 enum {
195 	FI_FORMAT_UNSPEC,	/* void * */
196 	FI_SOCKADDR,		/* struct sockaddr */
197 	FI_SOCKADDR_IN,		/* struct sockaddr_in */
198 	FI_SOCKADDR_IN6,	/* struct sockaddr_in6 */
199 	FI_SOCKADDR_IB,		/* struct sockaddr_ib */
200 	FI_ADDR_PSMX,		/* uint64_t */
201 	FI_ADDR_GNI,
202 	FI_ADDR_BGQ,
203 	FI_ADDR_MLX,
204 	FI_ADDR_STR,		/* formatted char * */
205 	FI_ADDR_PSMX2,		/* uint64_t[2] */
206 	FI_ADDR_IB_UD,		/* uint64_t[4] */
207 	FI_ADDR_EFA,
208 };
209 
210 #define FI_ADDR_UNSPEC		((uint64_t) -1)
211 #define FI_ADDR_NOTAVAIL	((uint64_t) -1)
212 #define FI_KEY_NOTAVAIL		((uint64_t) -1)
213 #define FI_SHARED_CONTEXT	SIZE_MAX
214 typedef uint64_t		fi_addr_t;
215 
216 enum fi_av_type {
217 	FI_AV_UNSPEC,
218 	FI_AV_MAP,
219 	FI_AV_TABLE
220 };
221 
222 /* Named enum for backwards compatibility */
223 enum fi_mr_mode {
224 	FI_MR_UNSPEC,
225 	FI_MR_BASIC,	     /* (1 << 0) */
226 	FI_MR_SCALABLE,	     /* (1 << 1) */
227 };
228 #define FI_MR_LOCAL		(1 << 2)
229 #define FI_MR_RAW		(1 << 3)
230 #define FI_MR_VIRT_ADDR		(1 << 4)
231 #define FI_MR_ALLOCATED		(1 << 5)
232 #define FI_MR_PROV_KEY		(1 << 6)
233 #define FI_MR_MMU_NOTIFY	(1 << 7)
234 #define FI_MR_RMA_EVENT		(1 << 8)
235 #define FI_MR_ENDPOINT		(1 << 9)
236 #define FI_MR_HMEM		(1 << 10)
237 
238 enum fi_progress {
239 	FI_PROGRESS_UNSPEC,
240 	FI_PROGRESS_AUTO,
241 	FI_PROGRESS_MANUAL
242 };
243 
244 enum fi_threading {
245 	FI_THREAD_UNSPEC,
246 	FI_THREAD_SAFE,
247 	FI_THREAD_FID,
248 	FI_THREAD_DOMAIN,
249 	FI_THREAD_COMPLETION,
250 	FI_THREAD_ENDPOINT,
251 };
252 
253 enum fi_resource_mgmt {
254 	FI_RM_UNSPEC,
255 	FI_RM_DISABLED,
256 	FI_RM_ENABLED
257 };
258 
259 #define FI_ORDER_NONE		0ULL
260 #define FI_ORDER_RAR		(1ULL << 0)
261 #define FI_ORDER_RAW		(1ULL << 1)
262 #define FI_ORDER_RAS		(1ULL << 2)
263 #define FI_ORDER_WAR		(1ULL << 3)
264 #define FI_ORDER_WAW		(1ULL << 4)
265 #define FI_ORDER_WAS		(1ULL << 5)
266 #define FI_ORDER_SAR		(1ULL << 6)
267 #define FI_ORDER_SAW		(1ULL << 7)
268 #define FI_ORDER_SAS		(1ULL << 8)
269 #define FI_ORDER_STRICT		0x1FF
270 
271 #define FI_ORDER_RMA_RAR	(1ULL << 32)
272 #define FI_ORDER_RMA_RAW	(1ULL << 33)
273 #define FI_ORDER_RMA_WAR	(1ULL << 34)
274 #define FI_ORDER_RMA_WAW	(1ULL << 35)
275 #define FI_ORDER_ATOMIC_RAR	(1ULL << 36)
276 #define FI_ORDER_ATOMIC_RAW	(1ULL << 37)
277 #define FI_ORDER_ATOMIC_WAR	(1ULL << 38)
278 #define FI_ORDER_ATOMIC_WAW	(1ULL << 39)
279 
280 #define FI_ORDER_DATA		(1ULL << 16)
281 
282 enum fi_ep_type {
283 	FI_EP_UNSPEC,
284 	FI_EP_MSG,
285 	FI_EP_DGRAM,
286 	FI_EP_RDM,
287 	FI_EP_SOCK_STREAM,
288 	FI_EP_SOCK_DGRAM,
289 };
290 
291 /* Endpoint protocol
292  * If two providers support the same protocol, then they shall interoperate
293  * when the protocol capabilities match.
294  */
295 enum {
296 	FI_PROTO_UNSPEC,
297 	FI_PROTO_RDMA_CM_IB_RC,
298 	FI_PROTO_IWARP,
299 	FI_PROTO_IB_UD,
300 	FI_PROTO_PSMX,
301 	FI_PROTO_UDP,
302 	FI_PROTO_SOCK_TCP,
303 	/*  MXM provider is deprecated.
304 	 *  We will keep  this value in order to save binary compatibility.
305 	 */
306 	FI_PROTO_MXM,
307 	FI_PROTO_IWARP_RDM,
308 	FI_PROTO_IB_RDM,
309 	FI_PROTO_GNI,
310 	FI_PROTO_RXM,
311 	FI_PROTO_RXD,
312 	FI_PROTO_MLX,
313 	FI_PROTO_NETWORKDIRECT,
314 	FI_PROTO_PSMX2,
315 	FI_PROTO_SHM,
316 	FI_PROTO_MRAIL,
317 	FI_PROTO_RSTREAM,
318 	FI_PROTO_RDMA_CM_IB_XRC,
319 	FI_PROTO_EFA
320 };
321 
322 enum {
323 	FI_TC_UNSPEC = 0,
324 	FI_TC_DSCP = 0x100,
325 	FI_TC_LABEL = 0x200,
326 	FI_TC_BEST_EFFORT = FI_TC_LABEL,
327 	FI_TC_LOW_LATENCY,
328 	FI_TC_DEDICATED_ACCESS,
329 	FI_TC_BULK_DATA,
330 	FI_TC_SCAVENGER,
331 	FI_TC_NETWORK_CTRL,
332 };
333 
fi_tc_dscp_set(uint8_t dscp)334 static inline uint32_t fi_tc_dscp_set(uint8_t dscp)
335 {
336 	return ((uint32_t) dscp) | FI_TC_DSCP;
337 }
338 
fi_tc_dscp_get(uint32_t tclass)339 static inline uint8_t fi_tc_dscp_get(uint32_t tclass)
340 {
341 	return tclass & FI_TC_DSCP ? (uint8_t) tclass : 0;
342 }
343 
344 /* Mode bits */
345 #define FI_CONTEXT		(1ULL << 59)
346 #define FI_MSG_PREFIX		(1ULL << 58)
347 #define FI_ASYNC_IOV		(1ULL << 57)
348 #define FI_RX_CQ_DATA		(1ULL << 56)
349 #define FI_LOCAL_MR		(1ULL << 55)
350 #define FI_NOTIFY_FLAGS_ONLY	(1ULL << 54)
351 #define FI_RESTRICTED_COMP	(1ULL << 53)
352 #define FI_CONTEXT2		(1ULL << 52)
353 #define FI_BUFFERED_RECV	(1ULL << 51)
354 
355 struct fi_tx_attr {
356 	uint64_t		caps;
357 	uint64_t		mode;
358 	uint64_t		op_flags;
359 	uint64_t		msg_order;
360 	uint64_t		comp_order;
361 	size_t			inject_size;
362 	size_t			size;
363 	size_t			iov_limit;
364 	size_t			rma_iov_limit;
365 	uint32_t		tclass;
366 };
367 
368 struct fi_rx_attr {
369 	uint64_t		caps;
370 	uint64_t		mode;
371 	uint64_t		op_flags;
372 	uint64_t		msg_order;
373 	uint64_t		comp_order;
374 	size_t			total_buffered_recv;
375 	size_t			size;
376 	size_t			iov_limit;
377 };
378 
379 struct fi_ep_attr {
380 	enum fi_ep_type		type;
381 	uint32_t		protocol;
382 	uint32_t		protocol_version;
383 	size_t			max_msg_size;
384 	size_t			msg_prefix_size;
385 	size_t			max_order_raw_size;
386 	size_t			max_order_war_size;
387 	size_t			max_order_waw_size;
388 	uint64_t		mem_tag_format;
389 	size_t			tx_ctx_cnt;
390 	size_t			rx_ctx_cnt;
391 	size_t			auth_key_size;
392 	uint8_t			*auth_key;
393 };
394 
395 struct fi_domain_attr {
396 	struct fid_domain	*domain;
397 	char			*name;
398 	enum fi_threading	threading;
399 	enum fi_progress	control_progress;
400 	enum fi_progress	data_progress;
401 	enum fi_resource_mgmt	resource_mgmt;
402 	enum fi_av_type		av_type;
403 	int			mr_mode;
404 	size_t			mr_key_size;
405 	size_t			cq_data_size;
406 	size_t			cq_cnt;
407 	size_t			ep_cnt;
408 	size_t			tx_ctx_cnt;
409 	size_t			rx_ctx_cnt;
410 	size_t			max_ep_tx_ctx;
411 	size_t			max_ep_rx_ctx;
412 	size_t			max_ep_stx_ctx;
413 	size_t			max_ep_srx_ctx;
414 	size_t			cntr_cnt;
415 	size_t			mr_iov_limit;
416 	uint64_t		caps;
417 	uint64_t		mode;
418 	uint8_t			*auth_key;
419 	size_t 			auth_key_size;
420 	size_t			max_err_data;
421 	size_t			mr_cnt;
422 	uint32_t		tclass;
423 };
424 
425 struct fi_fabric_attr {
426 	struct fid_fabric	*fabric;
427 	char			*name;
428 	char			*prov_name;
429 	uint32_t		prov_version;
430 	uint32_t		api_version;
431 };
432 
433 struct fi_info {
434 	struct fi_info		*next;
435 	uint64_t		caps;
436 	uint64_t		mode;
437 	uint32_t		addr_format;
438 	size_t			src_addrlen;
439 	size_t			dest_addrlen;
440 	void			*src_addr;
441 	void			*dest_addr;
442 	fid_t			handle;
443 	struct fi_tx_attr	*tx_attr;
444 	struct fi_rx_attr	*rx_attr;
445 	struct fi_ep_attr	*ep_attr;
446 	struct fi_domain_attr	*domain_attr;
447 	struct fi_fabric_attr	*fabric_attr;
448 	struct fid_nic		*nic;
449 };
450 
451 struct fi_device_attr {
452 	char			*name;
453 	char			*device_id;
454 	char			*device_version;
455 	char			*vendor_id;
456 	char			*driver;
457 	char			*firmware;
458 };
459 
460 enum fi_bus_type {
461 	FI_BUS_UNSPEC,
462 	FI_BUS_UNKNOWN = FI_BUS_UNSPEC,
463 	FI_BUS_PCI,
464 };
465 
466 struct fi_pci_attr {
467 	uint16_t		domain_id;
468 	uint8_t			bus_id;
469 	uint8_t			device_id;
470 	uint8_t			function_id;
471 };
472 
473 struct fi_bus_attr {
474 	enum fi_bus_type	bus_type;
475 	union {
476 		struct fi_pci_attr	pci;
477 	} attr;
478 };
479 
480 enum fi_link_state {
481 	FI_LINK_UNKNOWN,
482 	FI_LINK_DOWN,
483 	FI_LINK_UP,
484 };
485 
486 struct fi_link_attr {
487 	char			*address;
488 	size_t			mtu;
489 	size_t			speed;
490 	enum fi_link_state	state;
491 	char			*network_type;
492 };
493 
494 enum {
495 	FI_CLASS_UNSPEC,
496 	FI_CLASS_FABRIC,
497 	FI_CLASS_DOMAIN,
498 	FI_CLASS_EP,
499 	FI_CLASS_SEP,
500 	FI_CLASS_RX_CTX,
501 	FI_CLASS_SRX_CTX,
502 	FI_CLASS_TX_CTX,
503 	FI_CLASS_STX_CTX,
504 	FI_CLASS_PEP,
505 	FI_CLASS_INTERFACE,
506 	FI_CLASS_AV,
507 	FI_CLASS_MR,
508 	FI_CLASS_EQ,
509 	FI_CLASS_CQ,
510 	FI_CLASS_CNTR,
511 	FI_CLASS_WAIT,
512 	FI_CLASS_POLL,
513 	FI_CLASS_CONNREQ,
514 	FI_CLASS_MC,
515 	FI_CLASS_NIC,
516 	FI_CLASS_AV_SET,
517 };
518 
519 struct fi_eq_attr;
520 struct fi_wait_attr;
521 
522 /* fi_bind()-specific flags */
523 #define FI_SELECTIVE_COMPLETION	(1ULL << 59)
524 
525 struct fi_ops {
526 	size_t	size;
527 	int	(*close)(struct fid *fid);
528 	int	(*bind)(struct fid *fid, struct fid *bfid, uint64_t flags);
529 	int	(*control)(struct fid *fid, int command, void *arg);
530 	int	(*ops_open)(struct fid *fid, const char *name,
531 			    uint64_t flags, void **ops, void *context);
532 	int	(*tostr)(const struct fid *fid, char *buf, size_t len);
533 };
534 
535 /* All fabric interface descriptors must start with this structure */
536 struct fid {
537 	size_t			fclass;
538 	void			*context;
539 	struct fi_ops		*ops;
540 };
541 
542 int fi_getinfo(uint32_t version, const char *node, const char *service,
543 	       uint64_t flags, const struct fi_info *hints,
544 	       struct fi_info **info);
545 void fi_freeinfo(struct fi_info *info);
546 struct fi_info *fi_dupinfo(const struct fi_info *info);
547 
fi_allocinfo(void)548 static inline struct fi_info *fi_allocinfo(void)
549 {
550 	return fi_dupinfo(NULL);
551 }
552 
553 struct fi_ops_fabric {
554 	size_t	size;
555 	int	(*domain)(struct fid_fabric *fabric, struct fi_info *info,
556 			struct fid_domain **dom, void *context);
557 	int	(*passive_ep)(struct fid_fabric *fabric, struct fi_info *info,
558 			struct fid_pep **pep, void *context);
559 	int	(*eq_open)(struct fid_fabric *fabric, struct fi_eq_attr *attr,
560 			struct fid_eq **eq, void *context);
561 	int	(*wait_open)(struct fid_fabric *fabric, struct fi_wait_attr *attr,
562 			struct fid_wait **waitset);
563 	int	(*trywait)(struct fid_fabric *fabric, struct fid **fids,
564 			int count);
565 };
566 
567 struct fid_fabric {
568 	struct fid		fid;
569 	struct fi_ops_fabric	*ops;
570 	uint32_t		api_version;
571 };
572 
573 int fi_fabric(struct fi_fabric_attr *attr, struct fid_fabric **fabric, void *context);
574 
575 struct fid_nic {
576 	struct fid		fid;
577 	struct fi_device_attr	*device_attr;
578 	struct fi_bus_attr	*bus_attr;
579 	struct fi_link_attr	*link_attr;
580 	void			*prov_attr;
581 };
582 
583 #define FI_CHECK_OP(ops, opstype, op) \
584 	(ops && (ops->size > offsetof(opstype, op)) && ops->op)
585 
fi_close(struct fid * fid)586 static inline int fi_close(struct fid *fid)
587 {
588 	return fid->ops->close(fid);
589 }
590 
591 struct fi_alias {
592 	struct fid 		**fid;
593 	uint64_t		flags;
594 };
595 
596 struct fi_mr_raw_attr {
597 	uint64_t	flags;
598 	uint64_t	*base_addr;
599 	uint8_t		*raw_key;
600 	size_t		*key_size;
601 };
602 
603 struct fi_mr_map_raw {
604 	uint64_t	flags;
605 	uint64_t	base_addr;
606 	uint8_t		*raw_key;
607 	size_t		key_size;
608 	uint64_t	*key;
609 };
610 
611 /* control commands */
612 enum {
613 	FI_GETFIDFLAG,		/* uint64_t flags */
614 	FI_SETFIDFLAG,		/* uint64_t flags */
615 	FI_GETOPSFLAG,		/* uint64_t flags */
616 	FI_SETOPSFLAG,		/* uint64_t flags */
617 	FI_ALIAS,		/* struct fi_alias * */
618 	FI_GETWAIT,		/* void * wait object */
619 	FI_ENABLE,		/* NULL */
620 	FI_BACKLOG,		/* integer * */
621 	FI_GET_RAW_MR,		/* fi_mr_raw_attr */
622 	FI_MAP_RAW_MR,		/* fi_mr_map_raw */
623 	FI_UNMAP_KEY,		/* uint64_t key */
624 	FI_QUEUE_WORK,		/* struct fi_deferred_work */
625 	FI_CANCEL_WORK,		/* struct fi_deferred_work */
626 	FI_FLUSH_WORK,		/* NULL */
627 	FI_REFRESH,		/* mr: fi_mr_modify */
628 	FI_DUP,			/* struct fid ** */
629 	FI_GETWAITOBJ,		/*enum fi_wait_obj * */
630 };
631 
fi_control(struct fid * fid,int command,void * arg)632 static inline int fi_control(struct fid *fid, int command, void *arg)
633 {
634 	return fid->ops->control(fid, command, arg);
635 }
636 
fi_alias(struct fid * fid,struct fid ** alias_fid,uint64_t flags)637 static inline int fi_alias(struct fid *fid, struct fid **alias_fid, uint64_t flags)
638 {
639 	struct fi_alias alias;
640 	alias.fid = alias_fid;
641 	alias.flags = flags;
642 	return fi_control(fid, FI_ALIAS, &alias);
643 }
644 
645 static inline int
fi_open_ops(struct fid * fid,const char * name,uint64_t flags,void ** ops,void * context)646 fi_open_ops(struct fid *fid, const char *name, uint64_t flags,
647 	    void **ops, void *context)
648 {
649 	return fid->ops->ops_open(fid, name, flags, ops, context);
650 }
651 
652 enum fi_type {
653 	FI_TYPE_INFO,
654 	FI_TYPE_EP_TYPE,
655 	FI_TYPE_CAPS,
656 	FI_TYPE_OP_FLAGS,
657 	FI_TYPE_ADDR_FORMAT,
658 	FI_TYPE_TX_ATTR,
659 	FI_TYPE_RX_ATTR,
660 	FI_TYPE_EP_ATTR,
661 	FI_TYPE_DOMAIN_ATTR,
662 	FI_TYPE_FABRIC_ATTR,
663 	FI_TYPE_THREADING,
664 	FI_TYPE_PROGRESS,
665 	FI_TYPE_PROTOCOL,
666 	FI_TYPE_MSG_ORDER,
667 	FI_TYPE_MODE,
668 	FI_TYPE_AV_TYPE,
669 	FI_TYPE_ATOMIC_TYPE,
670 	FI_TYPE_ATOMIC_OP,
671 	FI_TYPE_VERSION,
672 	FI_TYPE_EQ_EVENT,
673 	FI_TYPE_CQ_EVENT_FLAGS,
674 	FI_TYPE_MR_MODE,
675 	FI_TYPE_OP_TYPE,
676 	FI_TYPE_FID,
677 	FI_TYPE_COLLECTIVE_OP,
678 };
679 
680 char *fi_tostr(const void *data, enum fi_type datatype);
681 
682 enum fi_param_type {
683 	FI_PARAM_STRING,
684 	FI_PARAM_INT,
685 	FI_PARAM_BOOL,
686 	FI_PARAM_SIZE_T,
687 };
688 
689 struct fi_param {
690 	const char *name;
691 	enum fi_param_type type;
692 	const char *help_string;
693 	const char *value;
694 };
695 
696 int fi_getparams(struct fi_param **params, int *count);
697 void fi_freeparams(struct fi_param *params);
698 
699 #ifdef FABRIC_DIRECT
700 #include <rdma/fi_direct.h>
701 #endif	/* FABRIC_DIRECT */
702 
703 #ifndef FABRIC_DIRECT_
704 struct fi_context {
705 	void			*internal[4];
706 };
707 
708 struct fi_context2 {
709 	void			*internal[8];
710 };
711 #endif
712 
713 struct fi_recv_context {
714 	struct fid_ep		*ep;
715 	void			*context;
716 };
717 
718 #ifdef __cplusplus
719 }
720 #endif
721 
722 #endif /* FABRIC_H */
723