qdf_perf.h 3.4 KB

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