sfxge: access statistics buffers under port lock

Allow access to statistics data not only from sysctl handlers.

Submitted-by:   Boris Misenov <boris.mise...@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

_______________________________________________
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"

Reply via email to