1 /*
2  * Copyright (c) 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 
37 #ifndef _USDF_WAIT_H_
38 #define _USDF_WAIT_H_
39 
40 #include "ofi_list.h"
41 
42 struct usdf_wait {
43 	struct fid_wait		wait_fid;
44 	struct usdf_fabric	*wait_fabric;
45 
46 	enum fi_wait_obj	wait_obj;
47 	union {
48 		ofi_epoll_t epfd;
49 		struct fi_mutex_cond mutex_cond;
50 	} object;
51 
52 	ofi_atomic32_t		wait_refcnt;
53 
54 	fastlock_t		lock;
55 	struct dlist_entry	list;
56 };
57 
58 #define wait_ftou(FWT) container_of(FWT, struct usdf_wait, wait_fid)
59 #define wait_fidtou(FWT) container_of(FWT, struct usdf_wait, wait_fid.fid)
60 
61 int usdf_wait_open(struct fid_fabric *fabric, struct fi_wait_attr *attr,
62 		struct fid_wait **waitset);
63 int usdf_trywait(struct fid_fabric *fabric, struct fid **fids, int count);
64 
65 #endif
66