1 /*
2  * Copyright (c) 2014-2016, 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_CQ_H_
37 #define _USDF_CQ_H_
38 
39 /* exponential backoff settings for fi_cq_sread */
40 #define SREAD_EXP_BASE 2
41 #define SREAD_INIT_SLEEP_TIME_US 1
42 #define SREAD_MAX_SLEEP_TIME_US 5000
43 
44 int usdf_cq_make_soft(struct usdf_cq *cq);
45 int usdf_cq_create_cq(struct usdf_cq *cq, struct usd_cq **ucq, int create_fd);
46 int usdf_check_empty_hard_cq(struct usdf_cq *cq);
47 int usdf_check_empty_soft_cq(struct usdf_cq *cq);
48 int usdf_cq_trywait(struct fid *fcq);
49 
50 void usdf_progress_hard_cq(struct usdf_cq_hard *hcq);
51 
52 void usdf_cq_post_soft(struct usdf_cq_hard *hcq, void *context,
53 		size_t len, int prov_errno, uint64_t flags);
54 
55 #endif /* _USDF_CQ_H_ */
56