svn commit: r227509 - head/sys/dev/ti
Pyun YongHyeon
yongari at FreeBSD.org
Mon Nov 14 19:10:21 UTC 2011
Author: yongari
Date: Mon Nov 14 19:10:20 2011
New Revision: 227509
URL: http://svn.freebsd.org/changeset/base/227509
Log:
Export sysctl node for various interrupt moderation parameters and
have administrators control them. ti(4) provides a character
device to control various other features of driver via ioctls but
users had to write their own code to manipulate these parameters.
It seems some default values for these parameters are not optimal
on today's system but leave it as it was and let administrators
change them. The following parameters could be changed:
dev.ti.%d.rx_coal_ticks
dev.ti.%d.rx_max_coal_bds
dev.ti.%d.tx_coal_ticks
dev.ti.%d.tx_max_coal_bds
dev.ti.%d.tx_buf_ratio
dev.ti.%d.stat_ticks
The interface has to be brought down and up again before a change
takes effect.
ti(4) controller supports hardware MAC counters with additional
DMA statistics. So it's doable to export these counters via
sysctl interface. Unfortunately, these counters are cumulative
such that driver have to either send an explicit clear command to
controller after extracting them or have to maintain internal
counters to get actual changes. Neither look good to me so
counters were not exported via sysctl.
Modified:
head/sys/dev/ti/if_ti.c
Modified: head/sys/dev/ti/if_ti.c
==============================================================================
--- head/sys/dev/ti/if_ti.c Mon Nov 14 19:06:28 2011 (r227508)
+++ head/sys/dev/ti/if_ti.c Mon Nov 14 19:10:20 2011 (r227509)
@@ -125,6 +125,8 @@ __FBSDID("$FreeBSD$");
#include <dev/ti/ti_fw.h>
#include <dev/ti/ti_fw2.h>
+#include <sys/sysctl.h>
+
#define TI_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_IP_FRAGS)
/*
* We can only turn on header splitting if we're using extended receive
@@ -247,6 +249,8 @@ static __inline void ti_hdr_split(struct
int idx);
#endif /* TI_JUMBO_HDRSPLIT */
+static void ti_sysctl_node(struct ti_softc *);
+
static device_method_t ti_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, ti_probe),
@@ -2083,7 +2087,7 @@ ti_gibinit(struct ti_softc *sc)
bus_dmamap_sync(sc->ti_rdata_dmat, sc->ti_rdata_dmamap,
BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
- /* Set up tuneables */
+ /* Set up tunables */
#if 0
if (ifp->if_mtu > (ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN))
CSR_WRITE_4(sc, TI_GCR_RX_COAL_TICKS,
@@ -2352,19 +2356,8 @@ ti_attach(device_t dev)
pci_get_device(dev) == NG_DEVICEID_GA620T)
sc->ti_copper = 1;
- /* Set default tuneable values. */
- sc->ti_stat_ticks = 2 * TI_TICKS_PER_SEC;
-#if 0
- sc->ti_rx_coal_ticks = TI_TICKS_PER_SEC / 5000;
-#endif
- sc->ti_rx_coal_ticks = 170;
- sc->ti_tx_coal_ticks = TI_TICKS_PER_SEC / 500;
- sc->ti_rx_max_coal_bds = 64;
-#if 0
- sc->ti_tx_max_coal_bds = 128;
-#endif
- sc->ti_tx_max_coal_bds = 32;
- sc->ti_tx_buf_ratio = 21;
+ /* Set default tunable values. */
+ ti_sysctl_node(sc);
/* Set up ifnet structure */
ifp->if_softc = sc;
@@ -3858,3 +3851,58 @@ ti_shutdown(device_t dev)
return (0);
}
+
+static void
+ti_sysctl_node(struct ti_softc *sc)
+{
+ struct sysctl_ctx_list *ctx;
+ struct sysctl_oid_list *child;
+
+ ctx = device_get_sysctl_ctx(sc->ti_dev);
+ child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->ti_dev));
+
+ SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "rx_coal_ticks", CTLFLAG_RW,
+ &sc->ti_rx_coal_ticks, 0, "Receive coalcesced ticks");
+ SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "rx_max_coal_bds", CTLFLAG_RW,
+ &sc->ti_rx_max_coal_bds, 0, "Receive max coalcesced BDs");
+
+ SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "tx_coal_ticks", CTLFLAG_RW,
+ &sc->ti_tx_coal_ticks, 0, "Send coalcesced ticks");
+ SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "tx_max_coal_bds", CTLFLAG_RW,
+ &sc->ti_tx_max_coal_bds, 0, "Send max coalcesced BDs");
+ SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "tx_buf_ratio", CTLFLAG_RW,
+ &sc->ti_tx_buf_ratio, 0,
+ "Ratio of NIC memory devoted to TX buffer");
+
+ SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "stat_ticks", CTLFLAG_RW,
+ &sc->ti_stat_ticks, 0,
+ "Number of clock ticks for statistics update interval");
+
+ /* Pull in device tunables. */
+ sc->ti_rx_coal_ticks = 170;
+ resource_int_value(device_get_name(sc->ti_dev),
+ device_get_unit(sc->ti_dev), "rx_coal_ticks",
+ &sc->ti_rx_coal_ticks);
+ sc->ti_rx_max_coal_bds = 64;
+ resource_int_value(device_get_name(sc->ti_dev),
+ device_get_unit(sc->ti_dev), "rx_max_coal_bds",
+ &sc->ti_rx_max_coal_bds);
+
+ sc->ti_tx_coal_ticks = TI_TICKS_PER_SEC / 500;
+ resource_int_value(device_get_name(sc->ti_dev),
+ device_get_unit(sc->ti_dev), "tx_coal_ticks",
+ &sc->ti_tx_coal_ticks);
+ sc->ti_tx_max_coal_bds = 32;
+ resource_int_value(device_get_name(sc->ti_dev),
+ device_get_unit(sc->ti_dev), "tx_max_coal_bds",
+ &sc->ti_tx_max_coal_bds);
+ sc->ti_tx_buf_ratio = 21;
+ resource_int_value(device_get_name(sc->ti_dev),
+ device_get_unit(sc->ti_dev), "tx_buf_ratio",
+ &sc->ti_tx_buf_ratio);
+
+ sc->ti_stat_ticks = 2 * TI_TICKS_PER_SEC;
+ resource_int_value(device_get_name(sc->ti_dev),
+ device_get_unit(sc->ti_dev), "stat_ticks",
+ &sc->ti_stat_ticks);
+}
More information about the svn-src-all
mailing list