From owner-svn-src-head@FreeBSD.ORG Mon Nov 14 19:10:21 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 52E08106566B; Mon, 14 Nov 2011 19:10:21 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 08B8D8FC17; Mon, 14 Nov 2011 19:10:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAEJAKKb062564; Mon, 14 Nov 2011 19:10:20 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAEJAKoK062562; Mon, 14 Nov 2011 19:10:20 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201111141910.pAEJAKoK062562@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 14 Nov 2011 19:10:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227509 - head/sys/dev/ti X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Mon, 14 Nov 2011 19:10:21 -0000 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 #include +#include + #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); +}