1 /*
2  * Copyright (c) 2019 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 _HOOK_DEBUG_H_
34 #define _HOOK_DEBUG_H_
35 
36 #include "ofi_hook.h"
37 #include "ofi.h"
38 
39 #define HOOK_DEBUG_EAGAIN_LOG 10000000
40 #define HOOK_DEBUG_EQ_EVENT_MAX (FI_JOIN_COMPLETE + 1)
41 
42 extern struct hook_prov_ctx hook_debug_ctx;
43 
44 struct hook_debug_config {
45 	uint64_t trace_exit : 1;
46 	uint64_t trace_cq_entry : 1;
47 	uint64_t track_sends : 1;
48 	uint64_t track_recvs : 1;
49 };
50 
51 struct hook_debug_eq {
52 	struct hook_eq hook_eq;
53 	ofi_atomic64_t event_cntr[HOOK_DEBUG_EQ_EVENT_MAX];
54 	size_t eagain_count;
55 };
56 
57 struct hook_debug_cq {
58 	struct hook_cq hook_cq;
59 	enum fi_cq_format format;
60 	size_t entry_size;
61 	size_t eagain_count;
62 };
63 
64 struct hook_debug_txrx_entry {
65 	uint64_t 		magic;
66 	struct hook_debug_ep 	*ep;
67 	uint64_t 		op_flags;
68 	void 			*context;
69 };
70 
71 struct hook_debug_ep {
72 	struct hook_ep hook_ep;
73 	uint64_t tx_op_flags;
74 	uint64_t rx_op_flags;
75 	struct ofi_bufpool *tx_pool;
76 	struct ofi_bufpool *rx_pool;
77 	size_t tx_outs;
78 	size_t rx_outs;
79 	size_t tx_eagain_count;
80 	size_t rx_eagain_count;
81 };
82 
83 #endif /* _HOOK_DEBUG_H_ */
84