diff options
author | harti <harti@FreeBSD.org> | 2003-06-04 15:38:32 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2003-06-04 15:38:32 +0000 |
commit | 3380919baf2c0622334f6eda518c4e4f8d67af05 (patch) | |
tree | 24734625988746d7df82228008c12f03f8273535 /sys | |
parent | 07c361bdc3020b9458c712297498bd1276d38973 (diff) | |
download | FreeBSD-src-3380919baf2c0622334f6eda518c4e4f8d67af05.zip FreeBSD-src-3380919baf2c0622334f6eda518c4e4f8d67af05.tar.gz |
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().
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/en/midway.c | 43 |
1 files changed, 10 insertions, 33 deletions
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 <sys/socket.h> #include <sys/mbuf.h> #include <sys/endian.h> -#include <sys/sbuf.h> #include <sys/stdint.h> #include <vm/uma.h> @@ -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; |