summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libnetworking/rtems/rtems_showmbuf.c
blob: 41c7f4c6a1ff8a5505eba1babb5ace97c584202b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
#include <sys/mbuf.h>

/*
 * Display MBUF statistics
 * Don't lock the rest of the network tasks out while printing.
 * It's no big deal if the values change while being printed.
 */
void
rtems_bsdnet_show_mbuf_stats (void)
{
	int i;
	int printed = 0;
	char *cp;

	printf ("************ MBUF STATISTICS ************\n");
	printf ("mbufs:%4lu    clusters:%4lu    free:%4lu\n",
			mbstat.m_mbufs, mbstat.m_clusters, mbstat.m_clfree);
	printf ("drops:%4lu       waits:%4lu  drains:%4lu\n",
			mbstat.m_drops, mbstat.m_wait, mbstat.m_drain);
	for (i = 0 ; i < 20 ; i++) {
		switch (i) {
		case MT_FREE:		cp = "free";		break;
		case MT_DATA:		cp = "data";		break;
		case MT_HEADER:		cp = "header";		break;
		case MT_SOCKET:		cp = "socket";		break;
		case MT_PCB:		cp = "pcb";		break;
		case MT_RTABLE:		cp = "rtable";		break;
		case MT_HTABLE:		cp = "htable";		break;
		case MT_ATABLE:		cp = "atable";		break;
		case MT_SONAME:		cp = "soname";		break;
		case MT_SOOPTS:		cp = "soopts";		break;
		case MT_FTABLE:		cp = "ftable";		break;
		case MT_RIGHTS:		cp = "rights";		break;
		case MT_IFADDR:		cp = "ifaddr";		break;
		case MT_CONTROL:	cp = "control";		break;
		case MT_OOBDATA:	cp = "oobdata";		break;
		default:		cp = NULL;		break;
		}
		if ((cp != NULL) || (mbstat.m_mtypes[i] != 0)) {
			char cbuf[16];
			if (cp == NULL) {
				sprintf (cbuf, "Type %d", i);
				cp = cbuf;
			}
			printf ("%10s:%-8u", cp, mbstat.m_mtypes[i]);
			if (++printed == 4) {
				printf ("\n");
				printed = 0;
			}
		}
	}
	if (printed)
		printf ("\n");
	printf ("\n");
}