From owner-svn-src-all@FreeBSD.ORG Mon Mar 23 15:49:12 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 422BC698; Mon, 23 Mar 2015 15:49:12 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2D711FC8; Mon, 23 Mar 2015 15:49:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2NFnCFb046819; Mon, 23 Mar 2015 15:49:12 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2NFnCj5046818; Mon, 23 Mar 2015 15:49:12 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201503231549.t2NFnCj5046818@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Mon, 23 Mar 2015 15:49:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r280377 - head/sys/dev/sfxge X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Mar 2015 15:49:12 -0000 Author: arybchik Date: Mon Mar 23 15:49:11 2015 New Revision: 280377 URL: https://svnweb.freebsd.org/changeset/base/280377 Log: sfxge: add statistics for each Tx queue Sponsored by: Solarflare Communications, Inc. Differential Revision: https://reviews.freebsd.org/D2082 Modified: head/sys/dev/sfxge/sfxge_tx.c Modified: head/sys/dev/sfxge/sfxge_tx.c ============================================================================== --- head/sys/dev/sfxge/sfxge_tx.c Mon Mar 23 15:47:37 2015 (r280376) +++ head/sys/dev/sfxge/sfxge_tx.c Mon Mar 23 15:49:11 2015 (r280377) @@ -109,6 +109,26 @@ SYSCTL_INT(_hw_sfxge, OID_AUTO, tx_dpl_p "Maximum number of any packets in deferred packet put-list"); +static const struct { + const char *name; + size_t offset; +} sfxge_tx_stats[] = { +#define SFXGE_TX_STAT(name, member) \ + { #name, offsetof(struct sfxge_txq, member) } + SFXGE_TX_STAT(tso_bursts, tso_bursts), + SFXGE_TX_STAT(tso_packets, tso_packets), + SFXGE_TX_STAT(tso_long_headers, tso_long_headers), + SFXGE_TX_STAT(tso_pdrop_too_many, tso_pdrop_too_many), + SFXGE_TX_STAT(tso_pdrop_no_rsrc, tso_pdrop_no_rsrc), + SFXGE_TX_STAT(tx_collapses, collapses), + SFXGE_TX_STAT(tx_drops, drops), + SFXGE_TX_STAT(tx_get_overflow, get_overflow), + SFXGE_TX_STAT(tx_get_non_tcp_overflow, get_non_tcp_overflow), + SFXGE_TX_STAT(tx_put_overflow, put_overflow), + SFXGE_TX_STAT(tx_netdown_drops, netdown_drops), +}; + + /* Forward declarations. */ static void sfxge_tx_qdpl_service(struct sfxge_txq *txq); static void sfxge_tx_qlist_post(struct sfxge_txq *txq); @@ -1259,6 +1279,30 @@ fail: return (rc); } +static int +sfxge_txq_stat_init(struct sfxge_txq *txq, struct sysctl_oid *txq_node) +{ + struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(txq->sc->dev); + struct sysctl_oid *stat_node; + unsigned int id; + + stat_node = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(txq_node), OID_AUTO, + "stats", CTLFLAG_RD, NULL, + "Tx queue statistics"); + if (stat_node == NULL) + return (ENOMEM); + + for (id = 0; id < nitems(sfxge_tx_stats); id++) { + SYSCTL_ADD_ULONG( + ctx, SYSCTL_CHILDREN(stat_node), OID_AUTO, + sfxge_tx_stats[id].name, CTLFLAG_RD | CTLFLAG_STATS, + (unsigned long *)((caddr_t)txq + sfxge_tx_stats[id].offset), + ""); + } + + return (0); +} + /** * Destroy a transmit queue. */ @@ -1412,6 +1456,10 @@ sfxge_tx_qinit(struct sfxge_softc *sc, u "put_hiwat", CTLFLAG_RD | CTLFLAG_STATS, &stdp->std_put_hiwat, 0, ""); + rc = sfxge_txq_stat_init(txq, txq_node); + if (rc != 0) + goto fail_txq_stat_init; + txq->type = type; txq->evq_index = evq_index; txq->txq_index = txq_index; @@ -1419,6 +1467,7 @@ sfxge_tx_qinit(struct sfxge_softc *sc, u return (0); +fail_txq_stat_init: fail_dpl_node: fail_tx_dpl_put_max: fail_tx_dpl_get_max: @@ -1437,25 +1486,6 @@ fail: return (rc); } -static const struct { - const char *name; - size_t offset; -} sfxge_tx_stats[] = { -#define SFXGE_TX_STAT(name, member) \ - { #name, offsetof(struct sfxge_txq, member) } - SFXGE_TX_STAT(tso_bursts, tso_bursts), - SFXGE_TX_STAT(tso_packets, tso_packets), - SFXGE_TX_STAT(tso_long_headers, tso_long_headers), - SFXGE_TX_STAT(tso_pdrop_too_many, tso_pdrop_too_many), - SFXGE_TX_STAT(tso_pdrop_no_rsrc, tso_pdrop_no_rsrc), - SFXGE_TX_STAT(tx_collapses, collapses), - SFXGE_TX_STAT(tx_drops, drops), - SFXGE_TX_STAT(tx_get_overflow, get_overflow), - SFXGE_TX_STAT(tx_get_non_tcp_overflow, get_non_tcp_overflow), - SFXGE_TX_STAT(tx_put_overflow, put_overflow), - SFXGE_TX_STAT(tx_netdown_drops, netdown_drops), -}; - static int sfxge_tx_stat_handler(SYSCTL_HANDLER_ARGS) {