Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Jan 2017 15:26:24 +0000 (UTC)
From:      Andrew Rybchenko <arybchik@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r311983 - in head: share/man/man4 sys/dev/sfxge
Message-ID:  <201701121526.v0CFQOTD025502@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: arybchik
Date: Thu Jan 12 15:26:23 2017
New Revision: 311983
URL: https://svnweb.freebsd.org/changeset/base/311983

Log:
  sfxge(4): add sysctl to change MAC stats update period
  
  The sysctl controls the period per interface.
  
  Reviewed by:    gnn
  Sponsored by:   Solarflare Communications, Inc.
  MFC after:      2 days
  Differential Revision:  https://reviews.freebsd.org/D9153

Modified:
  head/share/man/man4/sfxge.4
  head/sys/dev/sfxge/sfxge_port.c

Modified: head/share/man/man4/sfxge.4
==============================================================================
--- head/share/man/man4/sfxge.4	Thu Jan 12 14:47:44 2017	(r311982)
+++ head/share/man/man4/sfxge.4	Thu Jan 12 15:26:23 2017	(r311983)
@@ -166,6 +166,8 @@ Supported on SFN8xxx series adapters wit
 SFN5xxx and SFN6xxx series adapters.
 SFN7xxx series adapters and SFN8xxx series with earlier firmware use a
 fixed 1000 milliseconds statistics update period.
+The period may also be changed after the driver is loaded using the sysctl
+.Va dev.sfxge.%d.stats_update_period_ms .
 .El
 .Sh SUPPORT
 For general information and support,

Modified: head/sys/dev/sfxge/sfxge_port.c
==============================================================================
--- head/sys/dev/sfxge/sfxge_port.c	Thu Jan 12 14:47:44 2017	(r311982)
+++ head/sys/dev/sfxge/sfxge_port.c	Thu Jan 12 15:26:23 2017	(r311983)
@@ -702,6 +702,48 @@ sfxge_port_stats_update_period_ms(struct
 	return period_ms;
 }
 
+static int
+sfxge_port_stats_update_period_ms_handler(SYSCTL_HANDLER_ARGS)
+{
+	struct sfxge_softc *sc;
+	struct sfxge_port *port;
+	unsigned int period_ms;
+	int error;
+
+	sc = arg1;
+	port = &sc->port;
+
+	if (req->newptr != NULL) {
+		error = SYSCTL_IN(req, &period_ms, sizeof(period_ms));
+		if (error != 0)
+			return (error);
+
+		if (period_ms > UINT16_MAX)
+			return (EINVAL);
+
+		SFXGE_PORT_LOCK(port);
+
+		if (port->stats_update_period_ms != period_ms) {
+			if (port->init_state == SFXGE_PORT_STARTED)
+				error = efx_mac_stats_periodic(sc->enp,
+						&port->mac_stats.dma_buf,
+						period_ms, B_FALSE);
+			if (error == 0)
+				port->stats_update_period_ms = period_ms;
+		}
+
+		SFXGE_PORT_UNLOCK(port);
+	} else {
+		SFXGE_PORT_LOCK(port);
+		period_ms = port->stats_update_period_ms;
+		SFXGE_PORT_UNLOCK(port);
+
+		error = SYSCTL_OUT(req, &period_ms, sizeof(period_ms));
+	}
+
+	return (error);
+}
+
 int
 sfxge_port_init(struct sfxge_softc *sc)
 {
@@ -753,6 +795,11 @@ sfxge_port_init(struct sfxge_softc *sc)
 	port->stats_update_period_ms = sfxge_port_stats_update_period_ms(sc);
 	sfxge_mac_stat_init(sc);
 
+	SYSCTL_ADD_PROC(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO,
+	    "stats_update_period_ms", CTLTYPE_UINT|CTLFLAG_RW, sc, 0,
+	    sfxge_port_stats_update_period_ms_handler, "IU",
+	    "interface statistics refresh period");
+
 	port->init_state = SFXGE_PORT_INITIALIZED;
 
 	DBGPRINT(sc->dev, "success");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701121526.v0CFQOTD025502>