From owner-svn-src-head@FreeBSD.ORG Thu Feb 5 11:37:08 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3AC56209; Thu, 5 Feb 2015 11:37:08 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0D873C40; Thu, 5 Feb 2015 11:37:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t15Bb7Ia070447; Thu, 5 Feb 2015 11:37:07 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t15Bb7K7070446; Thu, 5 Feb 2015 11:37:07 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201502051137.t15Bb7K7070446@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Thu, 5 Feb 2015 11:37:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278248 - head/sys/dev/sfxge X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Feb 2015 11:37:08 -0000 Author: arybchik Date: Thu Feb 5 11:37:07 2015 New Revision: 278248 URL: https://svnweb.freebsd.org/changeset/base/278248 Log: sfxge: access statistics buffers under port lock Allow access to statistics data not only from sysctl handlers. Submitted by: Boris Misenov Sponsored by: Solarflare Communications, Inc. Approved by: gnn (mentor) Modified: head/sys/dev/sfxge/sfxge_port.c Modified: head/sys/dev/sfxge/sfxge_port.c ============================================================================== --- head/sys/dev/sfxge/sfxge_port.c Thu Feb 5 10:50:51 2015 (r278247) +++ head/sys/dev/sfxge/sfxge_port.c Thu Feb 5 11:37:07 2015 (r278248) @@ -48,7 +48,7 @@ sfxge_mac_stat_update(struct sfxge_softc unsigned int count; int rc; - SFXGE_PORT_LOCK(port); + SFXGE_PORT_LOCK_ASSERT_OWNED(port); if (port->init_state != SFXGE_PORT_STARTED) { rc = 0; @@ -82,7 +82,6 @@ sfxge_mac_stat_update(struct sfxge_softc rc = ETIMEDOUT; out: - SFXGE_PORT_UNLOCK(port); return (rc); } @@ -93,12 +92,16 @@ sfxge_mac_stat_handler(SYSCTL_HANDLER_AR unsigned int id = arg2; int rc; + SFXGE_PORT_LOCK(&sc->port); if ((rc = sfxge_mac_stat_update(sc)) != 0) - return (rc); + goto out; - return (SYSCTL_OUT(req, - (uint64_t *)sc->port.mac_stats.decode_buf + id, - sizeof(uint64_t))); + rc = SYSCTL_OUT(req, + (uint64_t *)sc->port.mac_stats.decode_buf + id, + sizeof(uint64_t)); +out: + SFXGE_PORT_UNLOCK(&sc->port); + return (rc); } static void @@ -453,7 +456,7 @@ sfxge_phy_stat_update(struct sfxge_softc unsigned int count; int rc; - SFXGE_PORT_LOCK(port); + SFXGE_PORT_LOCK_ASSERT_OWNED(port); if (port->init_state != SFXGE_PORT_STARTED) { rc = 0; @@ -487,7 +490,6 @@ sfxge_phy_stat_update(struct sfxge_softc rc = ETIMEDOUT; out: - SFXGE_PORT_UNLOCK(port); return (rc); } @@ -498,12 +500,16 @@ sfxge_phy_stat_handler(SYSCTL_HANDLER_AR unsigned int id = arg2; int rc; + SFXGE_PORT_LOCK(&sc->port); if ((rc = sfxge_phy_stat_update(sc)) != 0) - return (rc); + goto out; - return (SYSCTL_OUT(req, - (uint32_t *)sc->port.phy_stats.decode_buf + id, - sizeof(uint32_t))); + rc = SYSCTL_OUT(req, + (uint32_t *)sc->port.phy_stats.decode_buf + id, + sizeof(uint32_t)); +out: + SFXGE_PORT_UNLOCK(&sc->port); + return (rc); } static void