svn commit: r279184 - head/sys/dev/sfxge
Andrew Rybchenko
arybchik at FreeBSD.org
Sun Feb 22 19:25:59 UTC 2015
Author: arybchik
Date: Sun Feb 22 19:25:57 2015
New Revision: 279184
URL: https://svnweb.freebsd.org/changeset/base/279184
Log:
sfxge: implement if_get_counter callback
Sponsored by: Solarflare Communications, Inc.
Approved by: gnn (mentor)
Modified:
head/sys/dev/sfxge/sfxge.c
head/sys/dev/sfxge/sfxge.h
head/sys/dev/sfxge/sfxge_port.c
head/sys/dev/sfxge/sfxge_tx.c
head/sys/dev/sfxge/sfxge_tx.h
Modified: head/sys/dev/sfxge/sfxge.c
==============================================================================
--- head/sys/dev/sfxge/sfxge.c Sun Feb 22 19:24:08 2015 (r279183)
+++ head/sys/dev/sfxge/sfxge.c Sun Feb 22 19:25:57 2015 (r279184)
@@ -61,10 +61,10 @@ __FBSDID("$FreeBSD$");
#define SFXGE_CAP (IFCAP_VLAN_MTU | \
IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM | IFCAP_TSO | \
IFCAP_JUMBO_MTU | IFCAP_LRO | \
- IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE)
+ IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE | IFCAP_HWSTATS)
#define SFXGE_CAP_ENABLE SFXGE_CAP
#define SFXGE_CAP_FIXED (IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM | \
- IFCAP_JUMBO_MTU | IFCAP_LINKSTATE)
+ IFCAP_JUMBO_MTU | IFCAP_LINKSTATE | IFCAP_HWSTATS)
MALLOC_DEFINE(M_SFXGE, "sfxge", "Solarflare 10GigE driver");
@@ -343,6 +343,8 @@ sfxge_ifnet_init(struct ifnet *ifp, stru
mtx_init(&sc->tx_lock, sc->tx_lock_name, NULL, MTX_DEF);
#endif
+ ifp->if_get_counter = sfxge_get_counter;
+
if ((rc = sfxge_port_ifmedia_init(sc)) != 0)
goto fail;
Modified: head/sys/dev/sfxge/sfxge.h
==============================================================================
--- head/sys/dev/sfxge/sfxge.h Sun Feb 22 19:24:08 2015 (r279183)
+++ head/sys/dev/sfxge/sfxge.h Sun Feb 22 19:25:57 2015 (r279184)
@@ -324,6 +324,7 @@ extern void sfxge_mac_link_update(struct
efx_link_mode_t mode);
extern int sfxge_mac_filter_set(struct sfxge_softc *sc);
extern int sfxge_port_ifmedia_init(struct sfxge_softc *sc);
+extern uint64_t sfxge_get_counter(struct ifnet *ifp, ift_counter c);
#define SFXGE_MAX_MTU (9 * 1024)
Modified: head/sys/dev/sfxge/sfxge_port.c
==============================================================================
--- head/sys/dev/sfxge/sfxge_port.c Sun Feb 22 19:24:08 2015 (r279183)
+++ head/sys/dev/sfxge/sfxge_port.c Sun Feb 22 19:25:57 2015 (r279184)
@@ -85,6 +85,68 @@ out:
return (rc);
}
+uint64_t
+sfxge_get_counter(struct ifnet *ifp, ift_counter c)
+{
+ struct sfxge_softc *sc = ifp->if_softc;
+ uint64_t *mac_stats;
+ uint64_t val;
+
+ SFXGE_PORT_LOCK(&sc->port);
+
+ /* Ignore error and use old values */
+ (void)sfxge_mac_stat_update(sc);
+
+ mac_stats = (uint64_t *)sc->port.mac_stats.decode_buf;
+
+ switch (c) {
+ case IFCOUNTER_IPACKETS:
+ val = mac_stats[EFX_MAC_RX_PKTS];
+ break;
+ case IFCOUNTER_IERRORS:
+ val = mac_stats[EFX_MAC_RX_ERRORS];
+ break;
+ case IFCOUNTER_OPACKETS:
+ val = mac_stats[EFX_MAC_TX_PKTS];
+ break;
+ case IFCOUNTER_OERRORS:
+ val = mac_stats[EFX_MAC_TX_ERRORS];
+ break;
+ case IFCOUNTER_COLLISIONS:
+ val = mac_stats[EFX_MAC_TX_SGL_COL_PKTS] +
+ mac_stats[EFX_MAC_TX_MULT_COL_PKTS] +
+ mac_stats[EFX_MAC_TX_EX_COL_PKTS] +
+ mac_stats[EFX_MAC_TX_LATE_COL_PKTS];
+ break;
+ case IFCOUNTER_IBYTES:
+ val = mac_stats[EFX_MAC_RX_OCTETS];
+ break;
+ case IFCOUNTER_OBYTES:
+ val = mac_stats[EFX_MAC_TX_OCTETS];
+ break;
+ case IFCOUNTER_OMCASTS:
+ val = mac_stats[EFX_MAC_TX_MULTICST_PKTS] +
+ mac_stats[EFX_MAC_TX_BRDCST_PKTS];
+ break;
+ case IFCOUNTER_OQDROPS:
+ SFXGE_PORT_UNLOCK(&sc->port);
+ return (sfxge_tx_get_drops(sc));
+ case IFCOUNTER_IMCASTS:
+ /* if_imcasts is maintained in net/if_ethersubr.c */
+ case IFCOUNTER_IQDROPS:
+ /* if_iqdrops is maintained in net/if_ethersubr.c */
+ case IFCOUNTER_NOPROTO:
+ /* if_noproto is maintained in net/if_ethersubr.c */
+ default:
+ SFXGE_PORT_UNLOCK(&sc->port);
+ return (if_get_counter_default(ifp, c));
+ }
+
+ SFXGE_PORT_UNLOCK(&sc->port);
+
+ return (val);
+}
+
static int
sfxge_mac_stat_handler(SYSCTL_HANDLER_ARGS)
{
Modified: head/sys/dev/sfxge/sfxge_tx.c
==============================================================================
--- head/sys/dev/sfxge/sfxge_tx.c Sun Feb 22 19:24:08 2015 (r279183)
+++ head/sys/dev/sfxge/sfxge_tx.c Sun Feb 22 19:25:57 2015 (r279184)
@@ -1566,6 +1566,29 @@ sfxge_tx_stat_init(struct sfxge_softc *s
}
}
+uint64_t
+sfxge_tx_get_drops(struct sfxge_softc *sc)
+{
+ unsigned int index;
+ uint64_t drops = 0;
+ struct sfxge_txq *txq;
+
+ /* Sum across all TX queues */
+ for (index = 0; index < sc->txq_count; index++) {
+ txq = sc->txq[index];
+ /*
+ * In theory, txq->put_overflow and txq->netdown_drops
+ * should use atomic operation and other should be
+ * obtained under txq lock, but it is just statistics.
+ */
+ drops += txq->drops + txq->get_overflow +
+ txq->get_non_tcp_overflow +
+ txq->put_overflow + txq->netdown_drops +
+ txq->tso_pdrop_too_many + txq->tso_pdrop_no_rsrc;
+ }
+ return (drops);
+}
+
void
sfxge_tx_fini(struct sfxge_softc *sc)
{
Modified: head/sys/dev/sfxge/sfxge_tx.h
==============================================================================
--- head/sys/dev/sfxge/sfxge_tx.h Sun Feb 22 19:24:08 2015 (r279183)
+++ head/sys/dev/sfxge/sfxge_tx.h Sun Feb 22 19:25:57 2015 (r279184)
@@ -217,6 +217,7 @@ struct sfxge_txq {
struct sfxge_evq;
extern int sfxge_tx_packet_add(struct sfxge_txq *, struct mbuf *);
+extern uint64_t sfxge_tx_get_drops(struct sfxge_softc *sc);
extern int sfxge_tx_init(struct sfxge_softc *sc);
extern void sfxge_tx_fini(struct sfxge_softc *sc);
More information about the svn-src-all
mailing list