sfxge: implement if_get_counter callback
Sponsored by: Solarflare Communications, Inc. Approved by: gnn (mentor)
This commit is contained in:
parent
2fc13da641
commit
3d8fce2701
@ -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, struct sfxge_softc *sc)
|
||||
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;
|
||||
|
||||
|
@ -324,6 +324,7 @@ extern void sfxge_mac_link_update(struct sfxge_softc *sc,
|
||||
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)
|
||||
|
||||
|
@ -85,6 +85,68 @@ sfxge_mac_stat_update(struct sfxge_softc *sc)
|
||||
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)
|
||||
{
|
||||
|
@ -1566,6 +1566,29 @@ sfxge_tx_stat_init(struct sfxge_softc *sc)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user