1 /*
2  * Copyright (c) 2013-2014 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 #ifndef FI_TAGGED_H
34 #define FI_TAGGED_H
35 
36 #include <rdma/fabric.h>
37 #include <rdma/fi_endpoint.h>
38 
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 
45 struct fi_msg_tagged {
46 	const struct iovec	*msg_iov;
47 	void			**desc;
48 	size_t			iov_count;
49 	fi_addr_t		addr;
50 	uint64_t		tag;
51 	uint64_t		ignore;
52 	void			*context;
53 	uint64_t		data;
54 };
55 
56 struct fi_ops_tagged {
57 	size_t	size;
58 	ssize_t (*recv)(struct fid_ep *ep, void *buf, size_t len, void *desc,
59 			fi_addr_t src_addr,
60 			uint64_t tag, uint64_t ignore, void *context);
61 	ssize_t (*recvv)(struct fid_ep *ep, const struct iovec *iov, void **desc,
62 			size_t count, fi_addr_t src_addr,
63 			uint64_t tag, uint64_t ignore, void *context);
64 	ssize_t (*recvmsg)(struct fid_ep *ep, const struct fi_msg_tagged *msg,
65 			uint64_t flags);
66 	ssize_t (*send)(struct fid_ep *ep, const void *buf, size_t len, void *desc,
67 			fi_addr_t dest_addr, uint64_t tag, void *context);
68 	ssize_t (*sendv)(struct fid_ep *ep, const struct iovec *iov, void **desc,
69 			size_t count, fi_addr_t dest_addr, uint64_t tag, void *context);
70 	ssize_t (*sendmsg)(struct fid_ep *ep, const struct fi_msg_tagged *msg,
71 			uint64_t flags);
72 	ssize_t	(*inject)(struct fid_ep *ep, const void *buf, size_t len,
73 			fi_addr_t dest_addr, uint64_t tag);
74 	ssize_t (*senddata)(struct fid_ep *ep, const void *buf, size_t len, void *desc,
75 			uint64_t data, fi_addr_t dest_addr, uint64_t tag, void *context);
76 	ssize_t	(*injectdata)(struct fid_ep *ep, const void *buf, size_t len,
77 			uint64_t data, fi_addr_t dest_addr, uint64_t tag);
78 };
79 
80 
81 #ifdef FABRIC_DIRECT
82 #include <rdma/fi_direct_tagged.h>
83 #endif	/* FABRIC_DIRECT */
84 
85 #ifndef FABRIC_DIRECT_TAGGED
86 
87 static inline ssize_t
fi_trecv(struct fid_ep * ep,void * buf,size_t len,void * desc,fi_addr_t src_addr,uint64_t tag,uint64_t ignore,void * context)88 fi_trecv(struct fid_ep *ep, void *buf, size_t len, void *desc,
89 	 fi_addr_t src_addr, uint64_t tag, uint64_t ignore, void *context)
90 {
91 	return ep->tagged->recv(ep, buf, len, desc, src_addr, tag, ignore,
92 				context);
93 }
94 
95 static inline ssize_t
fi_trecvv(struct fid_ep * ep,const struct iovec * iov,void ** desc,size_t count,fi_addr_t src_addr,uint64_t tag,uint64_t ignore,void * context)96 fi_trecvv(struct fid_ep *ep, const struct iovec *iov, void **desc,
97 	  size_t count, fi_addr_t src_addr, uint64_t tag, uint64_t ignore,
98 	  void *context)
99 {
100 	return ep->tagged->recvv(ep, iov, desc, count, src_addr, tag, ignore,
101 				 context);
102 }
103 
104 static inline ssize_t
fi_trecvmsg(struct fid_ep * ep,const struct fi_msg_tagged * msg,uint64_t flags)105 fi_trecvmsg(struct fid_ep *ep, const struct fi_msg_tagged *msg, uint64_t flags)
106 {
107 	return ep->tagged->recvmsg(ep, msg, flags);
108 }
109 
110 static inline ssize_t
fi_tsend(struct fid_ep * ep,const void * buf,size_t len,void * desc,fi_addr_t dest_addr,uint64_t tag,void * context)111 fi_tsend(struct fid_ep *ep, const void *buf, size_t len, void *desc,
112 	 fi_addr_t dest_addr, uint64_t tag, void *context)
113 {
114 	return ep->tagged->send(ep, buf, len, desc, dest_addr, tag, context);
115 }
116 
117 static inline ssize_t
fi_tsendv(struct fid_ep * ep,const struct iovec * iov,void ** desc,size_t count,fi_addr_t dest_addr,uint64_t tag,void * context)118 fi_tsendv(struct fid_ep *ep, const struct iovec *iov, void **desc,
119 	  size_t count, fi_addr_t dest_addr, uint64_t tag, void *context)
120 {
121 	return ep->tagged->sendv(ep, iov, desc, count, dest_addr,tag, context);
122 }
123 
124 static inline ssize_t
fi_tsendmsg(struct fid_ep * ep,const struct fi_msg_tagged * msg,uint64_t flags)125 fi_tsendmsg(struct fid_ep *ep, const struct fi_msg_tagged *msg, uint64_t flags)
126 {
127 	return ep->tagged->sendmsg(ep, msg, flags);
128 }
129 
130 static inline ssize_t
fi_tinject(struct fid_ep * ep,const void * buf,size_t len,fi_addr_t dest_addr,uint64_t tag)131 fi_tinject(struct fid_ep *ep, const void *buf, size_t len,
132 	   fi_addr_t dest_addr, uint64_t tag)
133 {
134 	return ep->tagged->inject(ep, buf, len, dest_addr, tag);
135 }
136 
137 static inline ssize_t
fi_tsenddata(struct fid_ep * ep,const void * buf,size_t len,void * desc,uint64_t data,fi_addr_t dest_addr,uint64_t tag,void * context)138 fi_tsenddata(struct fid_ep *ep, const void *buf, size_t len, void *desc,
139 	     uint64_t data, fi_addr_t dest_addr, uint64_t tag, void *context)
140 {
141 	return ep->tagged->senddata(ep, buf, len, desc, data,
142 				    dest_addr, tag, context);
143 }
144 
145 static inline ssize_t
fi_tinjectdata(struct fid_ep * ep,const void * buf,size_t len,uint64_t data,fi_addr_t dest_addr,uint64_t tag)146 fi_tinjectdata(struct fid_ep *ep, const void *buf, size_t len,
147 		uint64_t data, fi_addr_t dest_addr, uint64_t tag)
148 {
149 	return ep->tagged->injectdata(ep, buf, len, data, dest_addr, tag);
150 }
151 
152 #endif
153 
154 #ifdef __cplusplus
155 }
156 #endif
157 
158 #endif /* FI_TAGGED_H */
159