stats.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /**
  2. * @file
  3. * Statistics module
  4. *
  5. */
  6. /*
  7. * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without modification,
  11. * are permitted provided that the following conditions are met:
  12. *
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. The name of the author may not be used to endorse or promote products
  19. * derived from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  22. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  23. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
  24. * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  25. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
  26. * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  29. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  30. * OF SUCH DAMAGE.
  31. *
  32. * This file is part of the lwIP TCP/IP stack.
  33. *
  34. * Author: Adam Dunkels <adam@sics.se>
  35. *
  36. */
  37. #include "lwip/opt.h"
  38. #if LWIP_STATS /* don't build if not configured for use in lwipopts.h */
  39. #include "lwip/def.h"
  40. #include "lwip/stats.h"
  41. #include "lwip/mem.h"
  42. #include <string.h>
  43. struct stats_ lwip_stats;
  44. #if LWIP_STATS_DISPLAY
  45. void
  46. stats_display_proto(struct stats_proto *proto, char *name)
  47. {
  48. LWIP_PLATFORM_DIAG(("\n%s\n\t", name));
  49. LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit));
  50. LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv));
  51. LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw));
  52. LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop));
  53. LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr));
  54. LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr));
  55. LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr));
  56. LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr));
  57. LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr));
  58. LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr));
  59. LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err));
  60. LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit));
  61. }
  62. #if IGMP_STATS
  63. void
  64. stats_display_igmp(struct stats_igmp *igmp)
  65. {
  66. LWIP_PLATFORM_DIAG(("\nIGMP\n\t"));
  67. LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr));
  68. LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr));
  69. LWIP_PLATFORM_DIAG(("v1_rxed: %"STAT_COUNTER_F"\n\t", igmp->v1_rxed));
  70. LWIP_PLATFORM_DIAG(("join_sent: %"STAT_COUNTER_F"\n\t", igmp->join_sent));
  71. LWIP_PLATFORM_DIAG(("leave_sent: %"STAT_COUNTER_F"\n\t", igmp->leave_sent));
  72. LWIP_PLATFORM_DIAG(("unicast_query: %"STAT_COUNTER_F"\n\t", igmp->unicast_query));
  73. LWIP_PLATFORM_DIAG(("report_sent: %"STAT_COUNTER_F"\n\t", igmp->report_sent));
  74. LWIP_PLATFORM_DIAG(("report_rxed: %"STAT_COUNTER_F"\n\t", igmp->report_rxed));
  75. LWIP_PLATFORM_DIAG(("group_query_rxed: %"STAT_COUNTER_F"\n", igmp->group_query_rxed));
  76. }
  77. #endif /* IGMP_STATS */
  78. #if MEM_STATS || MEMP_STATS
  79. void
  80. stats_display_mem(struct stats_mem *mem, char *name)
  81. {
  82. LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name));
  83. LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail));
  84. LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used));
  85. LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max));
  86. LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err));
  87. }
  88. #if MEMP_STATS
  89. void
  90. stats_display_memp(struct stats_mem *mem, int index)
  91. {
  92. char * memp_names[] = {
  93. #define LWIP_MEMPOOL(name,num,size,desc) desc,
  94. #include "lwip/memp_std.h"
  95. };
  96. if(index < MEMP_MAX) {
  97. stats_display_mem(mem, memp_names[index]);
  98. }
  99. }
  100. #endif /* MEMP_STATS */
  101. #endif /* MEM_STATS || MEMP_STATS */
  102. #if SYS_STATS
  103. void
  104. stats_display_sys(struct stats_sys *sys)
  105. {
  106. LWIP_PLATFORM_DIAG(("\nSYS\n\t"));
  107. LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used));
  108. LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max));
  109. LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err));
  110. LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used));
  111. LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max));
  112. LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n\t", (u32_t)sys->mbox.err));
  113. }
  114. #endif /* SYS_STATS */
  115. void
  116. stats_display(void)
  117. {
  118. s16_t i;
  119. LINK_STATS_DISPLAY();
  120. ETHARP_STATS_DISPLAY();
  121. IPFRAG_STATS_DISPLAY();
  122. IP_STATS_DISPLAY();
  123. IGMP_STATS_DISPLAY();
  124. ICMP_STATS_DISPLAY();
  125. UDP_STATS_DISPLAY();
  126. TCP_STATS_DISPLAY();
  127. MEM_STATS_DISPLAY();
  128. for (i = 0; i < MEMP_MAX; i++) {
  129. MEMP_STATS_DISPLAY(i);
  130. }
  131. SYS_STATS_DISPLAY();
  132. }
  133. #endif /* LWIP_STATS_DISPLAY */
  134. #endif /* LWIP_STATS */