aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/etherswitch/felix
diff options
context:
space:
mode:
authorKornel Duleba <mindal@semihalf.com>2021-10-25 13:18:27 +0000
committerWojciech Macek <wma@FreeBSD.org>2021-10-29 08:08:26 +0000
commitd88aecce69c82e9312c4e5e4e9eab4c56284925f (patch)
tree527ef94258df0bc74e532d844856a4bbac5c4348 /sys/dev/etherswitch/felix
parent8c5fead105905ffb8cdcf255c08a63ee440b223e (diff)
Diffstat (limited to 'sys/dev/etherswitch/felix')
-rw-r--r--sys/dev/etherswitch/felix/felix.c38
-rw-r--r--sys/dev/etherswitch/felix/felix_var.h2
2 files changed, 39 insertions, 1 deletions
diff --git a/sys/dev/etherswitch/felix/felix.c b/sys/dev/etherswitch/felix/felix.c
index f57a6e1daa0c..a80f4f8d15ae 100644
--- a/sys/dev/etherswitch/felix/felix.c
+++ b/sys/dev/etherswitch/felix/felix.c
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/socket.h>
#include <sys/sockio.h>
+#include <sys/sysctl.h>
#include <sys/rman.h>
#include <machine/bus.h>
@@ -326,6 +327,33 @@ felix_setup(felix_softc_t sc)
}
static int
+felix_timer_rate(SYSCTL_HANDLER_ARGS)
+{
+ felix_softc_t sc;
+ int error, value, old;
+
+ sc = arg1;
+
+ old = value = sc->timer_ticks;
+ error = sysctl_handle_int(oidp, &value, 0, req);
+ if (error != 0 || req->newptr == NULL)
+ return (error);
+
+ if (value < 0)
+ return (EINVAL);
+
+ if (value == old)
+ return (0);
+
+ FELIX_LOCK(sc);
+ sc->timer_ticks = value;
+ callout_reset(&sc->tick_callout, sc->timer_ticks, felix_tick, sc);
+ FELIX_UNLOCK(sc);
+
+ return (0);
+}
+
+static int
felix_attach(device_t dev)
{
phandle_t child, ports, node;
@@ -426,6 +454,13 @@ felix_attach(device_t dev)
if (error != 0)
goto out_fail;
+ sc->timer_ticks = hz; /* Default to 1s. */
+ SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
+ SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+ OID_AUTO, "timer_ticks", CTLTYPE_INT | CTLFLAG_RW,
+ sc, 0, felix_timer_rate, "I",
+ "Number of ticks between timer invocations");
+
/* The tick routine has to be called with the lock held. */
FELIX_LOCK(sc);
felix_tick(sc);
@@ -922,7 +957,8 @@ felix_tick(void *arg)
MPASS(mii != NULL);
mii_tick(mii);
}
- callout_reset(&sc->tick_callout, hz, felix_tick, sc);
+ if (sc->timer_ticks != 0)
+ callout_reset(&sc->tick_callout, sc->timer_ticks, felix_tick, sc);
}
static int
diff --git a/sys/dev/etherswitch/felix/felix_var.h b/sys/dev/etherswitch/felix/felix_var.h
index d891419793b7..15f43ec6a3d2 100644
--- a/sys/dev/etherswitch/felix/felix_var.h
+++ b/sys/dev/etherswitch/felix/felix_var.h
@@ -102,6 +102,8 @@ typedef struct felix_softc {
int vlan_mode;
int vlans[FELIX_NUM_VLANS];
+
+ uint32_t timer_ticks;
} *felix_softc_t;
#endif