Date: Tue, 18 Mar 2014 13:59:48 +0400 From: Andrew Rybchenko <Andrew.Rybchenko@oktetlabs.ru> To: net@FreeBSD.org Subject: [PATCH 5/6] sfxge: access statistics buffers under port lock Message-ID: <53281914.1000309@oktetlabs.ru>
next in thread | raw e-mail | index | archive | help
sfxge: access statistics buffers under port lock Allow access to statistics data not only from sysctl handlers. Submitted-by: Boris Misenov <Boris.Misenov@oktetlabs.ru> Sponsored by: Solarflare Communications, Inc. diff -r af2586a023d8 -r 7f58b1a5ea60 src/driver/freebsd/sfxge_port.c --- a/head/sys/dev/sfxge/sfxge_port.c Mon Mar 10 11:37:12 2014 +0400 +++ b/head/sys/dev/sfxge/sfxge_port.c Mon Mar 10 11:37:12 2014 +0400 @@ -48,7 +48,7 @@ unsigned int count; int rc; - mtx_lock(&port->lock); + mtx_assert(&port->lock, MA_OWNED); if (port->init_state != SFXGE_PORT_STARTED) { rc = 0; @@ -82,7 +82,6 @@ rc = ETIMEDOUT; out: - mtx_unlock(&port->lock); return rc; } @@ -93,12 +92,16 @@ unsigned int id = arg2; int rc; + mtx_lock(&sc->port.lock); if ((rc = sfxge_mac_stat_update(sc)) != 0) - return rc; + goto out; - return SYSCTL_OUT(req, + rc = SYSCTL_OUT(req, (uint64_t *)sc->port.mac_stats.decode_buf + id, sizeof(uint64_t)); +out: + mtx_unlock(&sc->port.lock); + return rc; } static void @@ -442,7 +445,7 @@ unsigned int count; int rc; - mtx_lock(&port->lock); + mtx_assert(&port->lock, MA_OWNED); if (port->init_state != SFXGE_PORT_STARTED) { rc = 0; @@ -476,7 +479,6 @@ rc = ETIMEDOUT; out: - mtx_unlock(&port->lock); return rc; } @@ -487,12 +489,16 @@ unsigned int id = arg2; int rc; + mtx_lock(&sc->port.lock); if ((rc = sfxge_phy_stat_update(sc)) != 0) - return rc; + goto out; - return SYSCTL_OUT(req, + rc = SYSCTL_OUT(req, (uint32_t *)sc->port.phy_stats.decode_buf + id, sizeof(uint32_t)); +out: + mtx_unlock(&sc->port.lock); + return rc; } static void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53281914.1000309>