Beispiel #1
0
static void
ffec_harvest_stats(struct ffec_softc *sc)
{
	struct ifnet *ifp;

	/* We don't need to harvest too often. */
	if (++sc->stats_harvest_count < STATS_HARVEST_INTERVAL)
		return;

	/*
	 * Try to avoid harvesting unless the IDLE flag is on, but if it has
	 * been too long just go ahead and do it anyway, the worst that'll
	 * happen is we'll lose a packet count or two as we clear at the end.
	 */
	if (sc->stats_harvest_count < (2 * STATS_HARVEST_INTERVAL) &&
	    ((RD4(sc, FEC_MIBC_REG) & FEC_MIBC_IDLE) == 0))
		return;

	sc->stats_harvest_count = 0;
	ifp = sc->ifp;

	ifp->if_ipackets   += RD4(sc, FEC_RMON_R_PACKETS);
	ifp->if_imcasts    += RD4(sc, FEC_RMON_R_MC_PKT);
	ifp->if_ierrors    += RD4(sc, FEC_RMON_R_CRC_ALIGN);
	ifp->if_ierrors    += RD4(sc, FEC_RMON_R_UNDERSIZE);
	ifp->if_ierrors    += RD4(sc, FEC_RMON_R_OVERSIZE);
	ifp->if_ierrors    += RD4(sc, FEC_RMON_R_FRAG);
	ifp->if_ierrors    += RD4(sc, FEC_RMON_R_JAB);

	ifp->if_opackets   += RD4(sc, FEC_RMON_T_PACKETS);
	ifp->if_omcasts    += RD4(sc, FEC_RMON_T_MC_PKT);
	ifp->if_oerrors    += RD4(sc, FEC_RMON_T_CRC_ALIGN);
	ifp->if_oerrors    += RD4(sc, FEC_RMON_T_UNDERSIZE);
	ifp->if_oerrors    += RD4(sc, FEC_RMON_T_OVERSIZE );
	ifp->if_oerrors    += RD4(sc, FEC_RMON_T_FRAG);
	ifp->if_oerrors    += RD4(sc, FEC_RMON_T_JAB);

	ifp->if_collisions += RD4(sc, FEC_RMON_T_COL);

	ffec_clear_stats(sc);
}
Beispiel #2
0
static void
ffec_harvest_stats(struct ffec_softc *sc)
{
	struct ifnet *ifp;

	/* We don't need to harvest too often. */
	if (++sc->stats_harvest_count < STATS_HARVEST_INTERVAL)
		return;

	/*
	 * Try to avoid harvesting unless the IDLE flag is on, but if it has
	 * been too long just go ahead and do it anyway, the worst that'll
	 * happen is we'll lose a packet count or two as we clear at the end.
	 */
	if (sc->stats_harvest_count < (2 * STATS_HARVEST_INTERVAL) &&
	    ((RD4(sc, FEC_MIBC_REG) & FEC_MIBC_IDLE) == 0))
		return;

	sc->stats_harvest_count = 0;
	ifp = sc->ifp;

	if_inc_counter(ifp, IFCOUNTER_IPACKETS, RD4(sc, FEC_RMON_R_PACKETS));
	if_inc_counter(ifp, IFCOUNTER_IMCASTS, RD4(sc, FEC_RMON_R_MC_PKT));
	if_inc_counter(ifp, IFCOUNTER_IERRORS,
	    RD4(sc, FEC_RMON_R_CRC_ALIGN) + RD4(sc, FEC_RMON_R_UNDERSIZE) +
	    RD4(sc, FEC_RMON_R_OVERSIZE) + RD4(sc, FEC_RMON_R_FRAG) +
	    RD4(sc, FEC_RMON_R_JAB));

	if_inc_counter(ifp, IFCOUNTER_OPACKETS, RD4(sc, FEC_RMON_T_PACKETS));
	if_inc_counter(ifp, IFCOUNTER_OMCASTS, RD4(sc, FEC_RMON_T_MC_PKT));
	if_inc_counter(ifp, IFCOUNTER_OERRORS,
	    RD4(sc, FEC_RMON_T_CRC_ALIGN) + RD4(sc, FEC_RMON_T_UNDERSIZE) +
	    RD4(sc, FEC_RMON_T_OVERSIZE) + RD4(sc, FEC_RMON_T_FRAG) +
	    RD4(sc, FEC_RMON_T_JAB));

	if_inc_counter(ifp, IFCOUNTER_COLLISIONS, RD4(sc, FEC_RMON_T_COL));

	ffec_clear_stats(sc);
}