qdf_perf.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. * DOC: qdf_perf
  20. * This file provides OS abstraction perf API's.
  21. */
  22. #ifndef _QDF_PERF_H
  23. #define _QDF_PERF_H
  24. /* headers */
  25. #include <i_qdf_perf.h>
  26. #ifdef QCA_PERF_PROFILING
  27. /* Typedefs */
  28. typedef __qdf_perf_id_t qdf_perf_id_t;
  29. typedef int (*proc_read_t)(char *page, char **start, off_t off, int count,
  30. int *eof, void *data);
  31. typedef int (*proc_write_t)(struct file *file, const char *buf,
  32. unsigned long count, void *data);
  33. typedef void (*perf_sample_t)(struct qdf_perf_entry *entry,
  34. uint8_t done);
  35. typedef void (*perf_init_t)(struct qdf_perf_entry *entry, uint32_t def_val);
  36. /**
  37. * typedef proc_api_tbl_t - contains functions to read, write to proc FS
  38. * @proc_read: function pointer to read function
  39. * @proc_write: function pointer to write function
  40. * @sample: function pointer to sample function
  41. * @init: function pointer to init function
  42. * @def_val: int contains default value
  43. */
  44. typedef struct proc_api_tbl {
  45. proc_read_t proc_read;
  46. proc_write_t proc_write;
  47. perf_sample_t sample;
  48. perf_init_t init;
  49. uint32_t def_val;
  50. } proc_api_tbl_t;
  51. proc_api_tbl_t api_tbl[];
  52. /* Macros */
  53. #define INIT_API(name, val) { \
  54. .proc_read = read_##name, \
  55. .proc_write = write_##name, \
  56. .sample = sample_event, \
  57. .init = init_##name, \
  58. .def_val = val, \
  59. }
  60. #define PERF_ENTRY(hdl) ((qdf_perf_entry_t *)hdl)
  61. #define qdf_perf_init(_parent, _id, _ctr_type) \
  62. __qdf_perf_init((_parent), (_id), (_ctr_type))
  63. #define qdf_perf_destroy(_id) __qdf_perf_destroy((_id))
  64. #define qdf_perf_start(_id) __qdf_perf_start((_id))
  65. #define qdf_perf_end(_id) __qdf_perf_end((_id))
  66. /* Extern declarations */
  67. extern __qdf_perf_id_t
  68. __qdf_perf_init(qdf_perf_id_t parent,
  69. uint8_t *id_name,
  70. qdf_perf_cntr_t type)(__qdf_perf_id_t parent,
  71. uint8_t *id_name,
  72. uint32_t type);
  73. extern bool __qdf_perf_destroy(qdf_perf_id_t id)(__qdf_perf_id_t id);
  74. extern void __qdf_perf_start(qdf_perf_id_t id)(__qdf_perf_id_t id);
  75. extern void __qdf_perf_end(qdf_perf_id_t id)(__qdf_perf_id_t id);
  76. extern int
  77. qdf_perfmod_init(void);
  78. extern void
  79. qdf_perfmod_exit(void);
  80. #else /* !QCA_PERF_PROFILING */
  81. #define qdf_perfmod_init()
  82. #define qdf_perfmod_exit()
  83. #define DECLARE_N_EXPORT_PERF_CNTR(id)
  84. #define START_PERF_CNTR(_id, _name)
  85. #define END_PERF_CNTR(_id)
  86. #endif /* QCA_PERF_PROFILING */
  87. #endif /* end of _QDF_PERF_H */