stats.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // SPDX-License-Identifier: Apache-2.0
  2. // Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. #ifndef __STATS__H
  16. #define __STATS__H
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #include "common.h"
  21. #include "esp_hosted_config.h"
  22. /* Stats CONFIG:
  23. *
  24. * 1. TEST_RAW_TP
  25. * These are debug stats which show the raw throughput
  26. * performance of transport like SPI or SDIO
  27. * (a) TEST_RAW_TP__ESP_TO_HOST
  28. * When this enabled, throughput will be measured from ESP to Host
  29. *
  30. * (b) TEST_RAW_TP__HOST_TO_ESP
  31. * This is opposite of TEST_RAW_TP__ESP_TO_HOST. when (a) TEST_RAW_TP__ESP_TO_HOST
  32. * is disabled, it will automatically mean throughput to be measured from host to ESP
  33. */
  34. #define TEST_RAW_TP H_TEST_RAW_TP
  35. /* TEST_RAW_TP is disabled on production.
  36. * This is only to test the throughout over transport
  37. * like SPI or SDIO. In this testing, dummy task will
  38. * push the packets over transport.
  39. * Currently this testing is possible on one direction
  40. * at a time
  41. */
  42. #if TEST_RAW_TP
  43. #include "os_wrapper.h"
  44. /* Raw throughput is supported only one direction
  45. * at a time
  46. * i.e. ESP to Host OR
  47. * Host to ESP
  48. */
  49. #if 0
  50. #define TEST_RAW_TP__ESP_TO_HOST 1
  51. #define TEST_RAW_TP__HOST_TO_ESP !TEST_RAW_TP__ESP_TO_HOST
  52. #endif
  53. #define TEST_RAW_TP__TIMEOUT H_ESP_RAW_TP_REPORT_INTERVAL
  54. void update_test_raw_tp_rx_len(uint16_t len);
  55. void process_test_capabilities(uint8_t cap);
  56. /* Please note, this size is to assess transport speed,
  57. * so kept maximum possible for that transport
  58. *
  59. * If you want to compare maximum network throughput and
  60. * relevance with max transport speed, Plz lower this value to
  61. * UDP: 1460 - H_ESP_PAYLOAD_HEADER_OFFSET = 1460-12=1448
  62. * TCP: Find MSS in nodes
  63. * H_ESP_PAYLOAD_HEADER_OFFSET is header size, which is not included in calcs
  64. */
  65. #define TEST_RAW_TP__BUF_SIZE H_ESP_RAW_TP_HOST_TO_ESP_PKT_LEN
  66. #endif
  67. #ifdef CONFIG_ESP_PKT_STATS
  68. #define ESP_PKT_STATS 1
  69. #endif
  70. #if H_MEM_STATS
  71. struct mempool_stats
  72. {
  73. uint32_t num_fresh_alloc;
  74. uint32_t num_reuse;
  75. uint32_t num_free;
  76. };
  77. struct spi_stats
  78. {
  79. int rx_alloc;
  80. int rx_freed;
  81. int tx_alloc;
  82. int tx_dummy_alloc;
  83. int tx_freed;
  84. };
  85. struct nw_stats
  86. {
  87. int tx_alloc;
  88. int tx_freed;
  89. };
  90. struct others_stats {
  91. int tx_others_freed;
  92. };
  93. struct mem_stats {
  94. struct mempool_stats mp_stats;
  95. struct spi_stats spi_mem_stats;
  96. struct nw_stats nw_mem_stats;
  97. struct others_stats others;
  98. };
  99. extern struct mem_stats h_stats_g;
  100. #endif
  101. #if ESP_PKT_STATS
  102. #define ESP_PKT_STATS_REPORT_INTERVAL 10
  103. struct pkt_stats_t {
  104. uint32_t sta_rx_in;
  105. uint32_t sta_rx_out;
  106. uint32_t sta_tx_in_pass;
  107. uint32_t sta_tx_in_drop;
  108. uint32_t sta_tx_out;
  109. };
  110. extern struct pkt_stats_t pkt_stats;
  111. #endif
  112. #ifdef __cplusplus
  113. }
  114. #endif
  115. void create_debugging_tasks(void);
  116. #endif