From 3380919baf2c0622334f6eda518c4e4f8d67af05 Mon Sep 17 00:00:00 2001 From: harti Date: Wed, 4 Jun 2003 15:38:32 +0000 Subject: Make the internal statistics sysctl an array of integers rather than a string. While a string is readable without a tool, an array is easier to process for a monitoring application. This also prevents the extra hoops we need with sbufs and locking. Move the mtx_init() in en_attach() higher before the first failure point so that we can unconditionally destroy it in en_destroy(). --- sys/dev/en/midway.c | 43 ++++++++++--------------------------------- 1 file changed, 10 insertions(+), 33 deletions(-) (limited to 'sys/dev/en') diff --git a/sys/dev/en/midway.c b/sys/dev/en/midway.c index 24e51b5..88639b5 100644 --- a/sys/dev/en/midway.c +++ b/sys/dev/en/midway.c @@ -132,7 +132,6 @@ enum { #include #include #include -#include #include #include @@ -1553,40 +1552,18 @@ static int en_sysctl_istats(SYSCTL_HANDLER_ARGS) { struct en_softc *sc = arg1; - struct sbuf *sb; + uint32_t *ret; int error; - sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND); - sbuf_clear(sb); + ret = malloc(sizeof(sc->stats), M_TEMP, M_WAITOK); EN_LOCK(sc); - -#define DO(NAME) sbuf_printf(sb, #NAME": %u\n", sc->stats.NAME) - DO(vtrash); - DO(otrash); - DO(ttrash); - DO(mfixaddr); - DO(mfixlen); - DO(mfixfail); - DO(txmbovr); - DO(dmaovr); - DO(txoutspace); - DO(txdtqout); - DO(launch); - DO(hwpull); - DO(swadd); - DO(rxqnotus); - DO(rxqus); - DO(rxdrqout); - DO(rxmbufout); - DO(txnomap); -#undef DO - + bcopy(&sc->stats, ret, sizeof(sc->stats)); EN_UNLOCK(sc); - sbuf_finish(sb); - error = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1); - sbuf_delete(sb); + error = SYSCTL_OUT(req, ret, sizeof(sc->stats)); + free(ret, M_TEMP); + return (error); } @@ -2786,6 +2763,9 @@ en_attach(struct en_softc *sc) ifp->if_ioctl = en_ioctl; ifp->if_start = en_start; + mtx_init(&sc->en_mtx, device_get_nameunit(sc->dev), + MTX_NETWORK_LOCK, MTX_DEF); + /* * Make the sysctl tree */ @@ -2798,7 +2778,7 @@ en_attach(struct en_softc *sc) if (SYSCTL_ADD_PROC(&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "istats", CTLFLAG_RD, sc, 0, en_sysctl_istats, - "A", "internal statistics") == NULL) + "S", "internal statistics") == NULL) goto fail; #ifdef EN_DEBUG @@ -2807,9 +2787,6 @@ en_attach(struct en_softc *sc) goto fail; #endif - mtx_init(&sc->en_mtx, device_get_nameunit(sc->dev), - MTX_NETWORK_LOCK, MTX_DEF); - MGET(sc->padbuf, M_TRYWAIT, MT_DATA); if (sc->padbuf == NULL) goto fail; -- cgit v1.1