xref: /wlan-driver/qca-wifi-host-cmn/qdf/inc/qdf_perf.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  *
4*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
5*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
6*5113495bSYour Name  * above copyright notice and this permission notice appear in all
7*5113495bSYour Name  * copies.
8*5113495bSYour Name  *
9*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
17*5113495bSYour Name  */
18*5113495bSYour Name 
19*5113495bSYour Name /**
20*5113495bSYour Name  * DOC: qdf_perf
21*5113495bSYour Name  * This file provides OS abstraction perf API's.
22*5113495bSYour Name  */
23*5113495bSYour Name 
24*5113495bSYour Name #ifndef _QDF_PERF_H
25*5113495bSYour Name #define _QDF_PERF_H
26*5113495bSYour Name 
27*5113495bSYour Name /* headers */
28*5113495bSYour Name #include <i_qdf_perf.h>
29*5113495bSYour Name 
30*5113495bSYour Name #ifdef QCA_PERF_PROFILING
31*5113495bSYour Name 
32*5113495bSYour Name /* Typedefs */
33*5113495bSYour Name typedef __qdf_perf_id_t  qdf_perf_id_t;
34*5113495bSYour Name 
35*5113495bSYour Name typedef int (*proc_read_t)(char *page, char **start, off_t off, int count,
36*5113495bSYour Name 		int *eof, void *data);
37*5113495bSYour Name typedef int (*proc_write_t)(struct file *file, const char *buf,
38*5113495bSYour Name 		unsigned long count, void *data);
39*5113495bSYour Name typedef void (*perf_sample_t)(struct qdf_perf_entry  *entry,
40*5113495bSYour Name 		uint8_t  done);
41*5113495bSYour Name 
42*5113495bSYour Name typedef void (*perf_init_t)(struct qdf_perf_entry *entry, uint32_t def_val);
43*5113495bSYour Name 
44*5113495bSYour Name /**
45*5113495bSYour Name  * typedef proc_api_tbl_t - contains functions to read, write to proc FS
46*5113495bSYour Name  * @proc_read: function pointer to read function
47*5113495bSYour Name  * @proc_write: function pointer to write function
48*5113495bSYour Name  * @sample: function pointer to sample function
49*5113495bSYour Name  * @init: function pointer to init function
50*5113495bSYour Name  * @def_val: int contains default value
51*5113495bSYour Name  */
52*5113495bSYour Name typedef struct proc_api_tbl {
53*5113495bSYour Name 	proc_read_t     proc_read;
54*5113495bSYour Name 	proc_write_t    proc_write;
55*5113495bSYour Name 	perf_sample_t   sample;
56*5113495bSYour Name 	perf_init_t     init;
57*5113495bSYour Name 	uint32_t        def_val;
58*5113495bSYour Name } proc_api_tbl_t;
59*5113495bSYour Name 
60*5113495bSYour Name proc_api_tbl_t          api_tbl[];
61*5113495bSYour Name 
62*5113495bSYour Name /* Macros */
63*5113495bSYour Name #define INIT_API(name, val)    {   \
64*5113495bSYour Name 	.proc_read  = read_##name,     \
65*5113495bSYour Name 	.proc_write = write_##name,    \
66*5113495bSYour Name 	.sample     = sample_event,    \
67*5113495bSYour Name 	.init       = init_##name,     \
68*5113495bSYour Name 	.def_val    = val,             \
69*5113495bSYour Name }
70*5113495bSYour Name 
71*5113495bSYour Name #define PERF_ENTRY(hdl) ((qdf_perf_entry_t *)hdl)
72*5113495bSYour Name 
73*5113495bSYour Name #define qdf_perf_init(_parent, _id, _ctr_type)   \
74*5113495bSYour Name 	__qdf_perf_init((_parent), (_id), (_ctr_type))
75*5113495bSYour Name 
76*5113495bSYour Name #define qdf_perf_destroy(_id) __qdf_perf_destroy((_id))
77*5113495bSYour Name 
78*5113495bSYour Name #define qdf_perf_start(_id) __qdf_perf_start((_id))
79*5113495bSYour Name 
80*5113495bSYour Name #define qdf_perf_end(_id)  __qdf_perf_end((_id))
81*5113495bSYour Name 
82*5113495bSYour Name /* Extern declarations */
83*5113495bSYour Name extern __qdf_perf_id_t
84*5113495bSYour Name 	__qdf_perf_init(qdf_perf_id_t parent,
85*5113495bSYour Name 			uint8_t *id_name,
86*5113495bSYour Name 			qdf_perf_cntr_t type)(__qdf_perf_id_t parent,
87*5113495bSYour Name 						uint8_t *id_name,
88*5113495bSYour Name 						uint32_t type);
89*5113495bSYour Name 
90*5113495bSYour Name extern bool __qdf_perf_destroy(qdf_perf_id_t id)(__qdf_perf_id_t     id);
91*5113495bSYour Name 
92*5113495bSYour Name extern void __qdf_perf_start(qdf_perf_id_t id)(__qdf_perf_id_t       id);
93*5113495bSYour Name extern void __qdf_perf_end(qdf_perf_id_t id)(__qdf_perf_id_t         id);
94*5113495bSYour Name 
95*5113495bSYour Name extern int
96*5113495bSYour Name qdf_perfmod_init(void);
97*5113495bSYour Name extern void
98*5113495bSYour Name qdf_perfmod_exit(void);
99*5113495bSYour Name 
100*5113495bSYour Name #else /* !QCA_PERF_PROFILING */
101*5113495bSYour Name 
102*5113495bSYour Name #define qdf_perfmod_init()
103*5113495bSYour Name #define qdf_perfmod_exit()
104*5113495bSYour Name #define DECLARE_N_EXPORT_PERF_CNTR(id)
105*5113495bSYour Name #define START_PERF_CNTR(_id, _name)
106*5113495bSYour Name #define END_PERF_CNTR(_id)
107*5113495bSYour Name 
108*5113495bSYour Name #endif /* QCA_PERF_PROFILING */
109*5113495bSYour Name 
110*5113495bSYour Name #endif /* end of _QDF_PERF_H */
111