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