changeset 829:639f0c464be5

* src/ecos/support.c: Added function cyg_net_show_mbufs() and code in cyg_net_mbuf_alloc() to accumulate and optionally display information about the current set of mbufs. This is mostly a debugging feature and is disabled by default. * include/sys/mbuf.h: Added prototype for cyg_net_show_mbufs().
author nickg
date Mon, 17 Mar 2003 18:38:18 +0000
parents a6926bb063e1
children 5fbe5042a140
files packages/net/bsd_tcpip/current/ChangeLog packages/net/bsd_tcpip/current/include/sys/mbuf.h packages/net/bsd_tcpip/current/src/ecos/support.c
diffstat 3 files changed, 62 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/packages/net/bsd_tcpip/current/ChangeLog
+++ b/packages/net/bsd_tcpip/current/ChangeLog
@@ -1,3 +1,12 @@
+2003-03-14  Nick Garnett  <nickg@balti.calivar.com>
+
+	* src/ecos/support.c: Added function cyg_net_show_mbufs() and code
+	in cyg_net_mbuf_alloc() to accumulate and optionally display
+	information about the current set of mbufs. This is mostly a
+	debugging feature and is disabled by default.
+
+	* include/sys/mbuf.h: Added prototype for cyg_net_show_mbufs().
+
 2003-03-14  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* src/sys/net/if.c (if_attach): Removed printf which causes the
--- a/packages/net/bsd_tcpip/current/include/sys/mbuf.h
+++ b/packages/net/bsd_tcpip/current/include/sys/mbuf.h
@@ -634,6 +634,9 @@ void	m_aux_delete __P((struct mbuf *, st
 extern void *cyg_net_mbuf_alloc(int type, int flags);
 extern void cyg_net_mbuf_free(caddr_t addr, int type);
 extern void *cyg_net_cluster_alloc(void );
+#ifdef CYGDBG_NET_SHOW_MBUFS                
+extern void cyg_net_show_mbufs(void);
+#endif
 #endif /* _KERNEL */
 
 #endif /* !_SYS_MBUF_H_ */
--- a/packages/net/bsd_tcpip/current/src/ecos/support.c
+++ b/packages/net/bsd_tcpip/current/src/ecos/support.c
@@ -214,6 +214,45 @@ cyg_net_free(caddr_t addr, int type)
     FINISH_STATS(stats_free);
 }
 
+#ifdef CYGDBG_NET_SHOW_MBUFS
+
+struct mbuf *mbinfo[300];
+
+void cyg_net_show_mbufs(void)
+{
+    int i;
+    diag_printf(" MBUF   : TYPE FLGS     DATA[LEN]   NEXT    NEXTPKT\n");
+    for( i = 0; i < 300; i++ )
+    {
+        struct mbuf *m = mbinfo[i];
+        char *type;
+        if( m == 0 ) continue;
+
+        switch( m->m_hdr.mh_type )
+        {
+        case MT_FREE: type="FREE"; break;
+        case MT_DATA: type="DATA"; break;
+        case MT_HEADER: type="HEADER"; break;
+        case MT_SONAME: type="SONAME"; break;
+        case MT_FTABLE: type="FTABLE"; break;
+        case MT_CONTROL: type="CONTROL"; break;
+        case MT_OOBDATA: type="OOBDATA"; break;
+        default: type="UNKNOWN"; break;
+        }
+
+        diag_printf("%08x: %s %04x %08x[%03d] %08x %08x\n",
+                    m, type,
+                    m->m_hdr.mh_flags,
+                    m->m_hdr.mh_data,
+                    m->m_hdr.mh_len,
+                    m->m_hdr.mh_next,
+                    m->m_hdr.mh_nextpkt);
+    }
+    diag_printf(" MBUF   : TYPE FLGS     DATA[LEN]   NEXT    NEXTPKT\n");    
+}
+
+#endif
+
 void *
 cyg_net_mbuf_alloc(int type, int flags)
 {
@@ -228,6 +267,17 @@ cyg_net_mbuf_alloc(int type, int flags)
         res = cyg_mempool_fix_alloc(net_mbufs);
     }
     FINISH_STATS(stats_mbuf_alloc);
+#ifdef CYGDBG_NET_SHOW_MBUFS    
+    {
+        int i;
+        for( i = 0; i < (sizeof(mbinfo)/sizeof(mbinfo[0])); i++ )
+            if( mbinfo[i] == 0 )
+            {
+                mbinfo[i] = (struct mbuf *)res;
+                break;
+            }
+    }
+#endif
     // Check that this nastiness works OK
     CYG_ASSERT( dtom(res) == res, "dtom failed, base of mbuf" );
     CYG_ASSERT( dtom((char *)res + MSIZE/2) == res, "dtom failed, mid mbuf" );