- Provide igb_get_counter() to return counters that are not collected,
but taken from hardware. - Mechanically convert to if_inc_counter() the rest of counters.
This commit is contained in:
parent
7b8455ae34
commit
c13dc68743
@ -104,6 +104,7 @@ static int et_watchdog(struct et_softc *);
|
|||||||
static int et_ifmedia_upd_locked(struct ifnet *);
|
static int et_ifmedia_upd_locked(struct ifnet *);
|
||||||
static int et_ifmedia_upd(struct ifnet *);
|
static int et_ifmedia_upd(struct ifnet *);
|
||||||
static void et_ifmedia_sts(struct ifnet *, struct ifmediareq *);
|
static void et_ifmedia_sts(struct ifnet *, struct ifmediareq *);
|
||||||
|
static uint64_t et_get_counter(struct ifnet *, ift_counter);
|
||||||
|
|
||||||
static void et_add_sysctls(struct et_softc *);
|
static void et_add_sysctls(struct et_softc *);
|
||||||
static int et_sysctl_rx_intr_npkts(SYSCTL_HANDLER_ARGS);
|
static int et_sysctl_rx_intr_npkts(SYSCTL_HANDLER_ARGS);
|
||||||
@ -324,6 +325,7 @@ et_attach(device_t dev)
|
|||||||
ifp->if_init = et_init;
|
ifp->if_init = et_init;
|
||||||
ifp->if_ioctl = et_ioctl;
|
ifp->if_ioctl = et_ioctl;
|
||||||
ifp->if_start = et_start;
|
ifp->if_start = et_start;
|
||||||
|
ifp->if_get_counter = et_get_counter;
|
||||||
ifp->if_capabilities = IFCAP_TXCSUM | IFCAP_VLAN_MTU;
|
ifp->if_capabilities = IFCAP_TXCSUM | IFCAP_VLAN_MTU;
|
||||||
ifp->if_capenable = ifp->if_capabilities;
|
ifp->if_capenable = ifp->if_capabilities;
|
||||||
ifp->if_snd.ifq_drv_maxlen = ET_TX_NDESC - 1;
|
ifp->if_snd.ifq_drv_maxlen = ET_TX_NDESC - 1;
|
||||||
@ -1413,7 +1415,7 @@ et_start_locked(struct ifnet *ifp)
|
|||||||
|
|
||||||
if (et_encap(sc, &m_head)) {
|
if (et_encap(sc, &m_head)) {
|
||||||
if (m_head == NULL) {
|
if (m_head == NULL) {
|
||||||
ifp->if_oerrors++;
|
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
|
IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
|
||||||
@ -1465,7 +1467,7 @@ et_watchdog(struct et_softc *sc)
|
|||||||
if_printf(sc->ifp, "watchdog timed out (0x%08x) -- resetting\n",
|
if_printf(sc->ifp, "watchdog timed out (0x%08x) -- resetting\n",
|
||||||
status);
|
status);
|
||||||
|
|
||||||
sc->ifp->if_oerrors++;
|
if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1);
|
||||||
sc->ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
sc->ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||||
et_init_locked(sc);
|
et_init_locked(sc);
|
||||||
return (EJUSTRETURN);
|
return (EJUSTRETURN);
|
||||||
@ -2093,12 +2095,12 @@ et_rxeof(struct et_softc *sc)
|
|||||||
CSR_WRITE_4(sc, ET_RXSTAT_POS, rxstat_pos);
|
CSR_WRITE_4(sc, ET_RXSTAT_POS, rxstat_pos);
|
||||||
|
|
||||||
if (ring_idx >= ET_RX_NRING) {
|
if (ring_idx >= ET_RX_NRING) {
|
||||||
ifp->if_ierrors++;
|
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
|
||||||
if_printf(ifp, "invalid ring index %d\n", ring_idx);
|
if_printf(ifp, "invalid ring index %d\n", ring_idx);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (buf_idx >= ET_RX_NDESC) {
|
if (buf_idx >= ET_RX_NDESC) {
|
||||||
ifp->if_ierrors++;
|
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
|
||||||
if_printf(ifp, "invalid buf index %d\n", buf_idx);
|
if_printf(ifp, "invalid buf index %d\n", buf_idx);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -2110,13 +2112,13 @@ et_rxeof(struct et_softc *sc)
|
|||||||
rbd->rbd_discard(rbd, buf_idx);
|
rbd->rbd_discard(rbd, buf_idx);
|
||||||
} else if (rbd->rbd_newbuf(rbd, buf_idx) != 0) {
|
} else if (rbd->rbd_newbuf(rbd, buf_idx) != 0) {
|
||||||
/* No available mbufs, discard it. */
|
/* No available mbufs, discard it. */
|
||||||
ifp->if_iqdrops++;
|
if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
|
||||||
rbd->rbd_discard(rbd, buf_idx);
|
rbd->rbd_discard(rbd, buf_idx);
|
||||||
} else {
|
} else {
|
||||||
buflen -= ETHER_CRC_LEN;
|
buflen -= ETHER_CRC_LEN;
|
||||||
if (buflen < ETHER_HDR_LEN) {
|
if (buflen < ETHER_HDR_LEN) {
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
ifp->if_ierrors++;
|
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
|
||||||
} else {
|
} else {
|
||||||
m->m_pkthdr.len = m->m_len = buflen;
|
m->m_pkthdr.len = m->m_len = buflen;
|
||||||
m->m_pkthdr.rcvif = ifp;
|
m->m_pkthdr.rcvif = ifp;
|
||||||
@ -2625,7 +2627,6 @@ back:
|
|||||||
static void
|
static void
|
||||||
et_stats_update(struct et_softc *sc)
|
et_stats_update(struct et_softc *sc)
|
||||||
{
|
{
|
||||||
struct ifnet *ifp;
|
|
||||||
struct et_hw_stats *stats;
|
struct et_hw_stats *stats;
|
||||||
|
|
||||||
stats = &sc->sc_stats;
|
stats = &sc->sc_stats;
|
||||||
@ -2675,18 +2676,35 @@ et_stats_update(struct et_softc *sc)
|
|||||||
stats->tx_oversize += CSR_READ_4(sc, ET_STAT_TX_OVERSIZE);
|
stats->tx_oversize += CSR_READ_4(sc, ET_STAT_TX_OVERSIZE);
|
||||||
stats->tx_undersize += CSR_READ_4(sc, ET_STAT_TX_UNDERSIZE);
|
stats->tx_undersize += CSR_READ_4(sc, ET_STAT_TX_UNDERSIZE);
|
||||||
stats->tx_fragments += CSR_READ_4(sc, ET_STAT_TX_FRAG);
|
stats->tx_fragments += CSR_READ_4(sc, ET_STAT_TX_FRAG);
|
||||||
|
}
|
||||||
|
|
||||||
/* Update ifnet counters. */
|
static uint64_t
|
||||||
ifp = sc->ifp;
|
et_get_counter(struct ifnet *ifp, ift_counter cnt)
|
||||||
ifp->if_opackets = (u_long)stats->tx_frames;
|
{
|
||||||
ifp->if_collisions = stats->tx_total_colls;
|
struct et_softc *sc;
|
||||||
ifp->if_oerrors = stats->tx_drop + stats->tx_jabbers +
|
struct et_hw_stats *stats;
|
||||||
stats->tx_crcerrs + stats->tx_excess_deferred +
|
|
||||||
stats->tx_late_colls;
|
sc = if_getsoftc(ifp);
|
||||||
ifp->if_ipackets = (u_long)stats->rx_frames;
|
stats = &sc->sc_stats;
|
||||||
ifp->if_ierrors = stats->rx_crcerrs + stats->rx_alignerrs +
|
|
||||||
stats->rx_lenerrs + stats->rx_codeerrs + stats->rx_cserrs +
|
switch (cnt) {
|
||||||
stats->rx_runts + stats->rx_jabbers + stats->rx_drop;
|
case IFCOUNTER_OPACKETS:
|
||||||
|
return (stats->tx_frames);
|
||||||
|
case IFCOUNTER_COLLISIONS:
|
||||||
|
return (stats->tx_total_colls);
|
||||||
|
case IFCOUNTER_OERRORS:
|
||||||
|
return (stats->tx_drop + stats->tx_jabbers +
|
||||||
|
stats->tx_crcerrs + stats->tx_excess_deferred +
|
||||||
|
stats->tx_late_colls);
|
||||||
|
case IFCOUNTER_IPACKETS:
|
||||||
|
return (stats->rx_frames);
|
||||||
|
case IFCOUNTER_IERRORS:
|
||||||
|
return (stats->rx_crcerrs + stats->rx_alignerrs +
|
||||||
|
stats->rx_lenerrs + stats->rx_codeerrs + stats->rx_cserrs +
|
||||||
|
stats->rx_runts + stats->rx_jabbers + stats->rx_drop);
|
||||||
|
default:
|
||||||
|
return (if_get_counter_default(ifp, cnt));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user