1 /*
2  * Copyright (c) 2014-2017, Cisco Systems, Inc. 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  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  */
36 #ifndef _USDF_DGRAM_H_
37 #define _USDF_DGRAM_H_
38 
39 #define USDF_DGRAM_MAX_SGE 8
40 #define USDF_DGRAM_DFLT_SGE 4
41 
42 #define USDF_DGRAM_CAPS (FI_MSG | FI_SOURCE | FI_SEND | FI_RECV)
43 
44 #define USDF_DGRAM_SUPP_MODE (FI_LOCAL_MR | FI_MSG_PREFIX)
45 
46 #define USDF_DGRAM_MSG_ORDER (FI_ORDER_NONE)
47 #define USDF_DGRAM_COMP_ORDER (FI_ORDER_NONE)
48 #define USDF_DGRAM_INJECT_SIZE                                                 \
49 	(USD_SEND_MAX_COPY - sizeof(struct usd_udp_hdr))
50 #define USDF_DGRAM_SUPP_SENDMSG_FLAGS                                          \
51 	(FI_INJECT | FI_COMPLETION | FI_INJECT_COMPLETE | FI_TRANSMIT_COMPLETE)
52 #define USDF_DGRAM_SUPP_RECVMSG_FLAGS (FI_COMPLETION)
53 #define USDF_DGRAM_IOV_LIMIT (USDF_DGRAM_DFLT_SGE)
54 #define USDF_DGRAM_RMA_IOV_LIMIT 0
55 #define USDF_DGRAM_CNTR_CNT 0
56 #define USDF_DGRAM_MR_IOV_LIMIT (USDF_MR_IOV_LIMIT)
57 #define USDF_DGRAM_MR_CNT (USDF_MR_CNT)
58 
59 
60 int usdf_dgram_fill_rx_attr(uint32_t version, const struct fi_info *hints,
61 		struct fi_info *fi, struct usd_device_attrs *dap);
62 int usdf_dgram_fill_tx_attr(uint32_t version, const struct fi_info *hints,
63 		struct fi_info *fi, struct usd_device_attrs *dap);
64 int usdf_dgram_fill_dom_attr(uint32_t version, const struct fi_info *hints,
65 			     struct fi_info *fi, struct usd_device_attrs *dap);
66 int usdf_dgram_fill_ep_attr(uint32_t version, const struct fi_info *hints,
67 		struct fi_info *fi, struct usd_device_attrs *dap);
68 
69 /* fi_ops_msg for DGRAM */
70 ssize_t usdf_dgram_recv(struct fid_ep *ep, void *buf, size_t len, void *desc,
71 	fi_addr_t src_addr, void *context);
72 ssize_t usdf_dgram_recvv(struct fid_ep *ep, const struct iovec *iov,
73 	void **desc, size_t count, fi_addr_t src_addr, void *context);
74 ssize_t usdf_dgram_recvmsg(struct fid_ep *ep, const struct fi_msg *msg,
75 	uint64_t flags);
76 ssize_t usdf_dgram_send(struct fid_ep *ep, const void *buf, size_t len,
77 	void *desc, fi_addr_t dest_addr, void *context);
78 ssize_t usdf_dgram_sendv(struct fid_ep *ep, const struct iovec *iov,
79 	void **desc, size_t count, fi_addr_t dest_addr, void *context);
80 ssize_t usdf_dgram_sendmsg(struct fid_ep *ep, const struct fi_msg *msg,
81 	uint64_t flags);
82 ssize_t usdf_dgram_inject(struct fid_ep *ep, const void *buf, size_t len,
83 	fi_addr_t dest_addr);
84 ssize_t usdf_dgram_rx_size_left(struct fid_ep *ep);
85 ssize_t usdf_dgram_tx_size_left(struct fid_ep *ep);
86 
87 ssize_t usdf_dgram_prefix_recv(struct fid_ep *ep, void *buf, size_t len,
88 	void *desc, fi_addr_t src_addr, void *context);
89 ssize_t usdf_dgram_prefix_recvv(struct fid_ep *ep, const struct iovec *iov,
90 	void **desc, size_t count, fi_addr_t src_addr, void *context);
91 ssize_t usdf_dgram_prefix_recvmsg(struct fid_ep *fep, const struct fi_msg *msg,
92 	uint64_t flags);
93 ssize_t usdf_dgram_prefix_send(struct fid_ep *ep, const void *buf, size_t len,
94 	void *desc, fi_addr_t dest_addr, void *context);
95 ssize_t usdf_dgram_prefix_sendv(struct fid_ep *fep, const struct iovec *iov,
96 	void **desc, size_t count, fi_addr_t dest_addr, void *context);
97 ssize_t usdf_dgram_prefix_sendmsg(struct fid_ep *ep, const struct fi_msg *msg,
98 	uint64_t flags);
99 ssize_t usdf_dgram_prefix_inject(struct fid_ep *ep, const void *buf, size_t len,
100 	fi_addr_t dest_addr);
101 ssize_t usdf_dgram_prefix_rx_size_left(struct fid_ep *ep);
102 ssize_t usdf_dgram_prefix_tx_size_left(struct fid_ep *ep);
103 
104 #endif /* _USDF_DGRAM_H_ */
105