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
This commit is contained in:
Andrew Rybchenko 2017-01-12 15:26:23 +00:00
parent 653e35e69f
commit a0e88689f0
2 changed files with 49 additions and 0 deletions

View File

@ -166,6 +166,8 @@ Supported on SFN8xxx series adapters with firmware v6.2.1.1033 and later and
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,

View File

@ -702,6 +702,48 @@ sfxge_port_stats_update_period_ms(struct sfxge_softc *sc)
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");