From 9253bf3fad6e12917dfc52ecbad4b74f4b07bf07 Mon Sep 17 00:00:00 2001 From: visa Date: Sat, 6 Aug 2016 04:32:24 +0000 Subject: [PATCH] Log RX errors only when the interface's debug flag is set. While here, remove unused PIP error code aliases. --- sys/arch/octeon/dev/cn30xxpipreg.h | 7 +---- sys/arch/octeon/dev/if_cnmac.c | 46 ++++++++---------------------- sys/arch/octeon/dev/if_cnmacvar.h | 5 ++-- 3 files changed, 15 insertions(+), 43 deletions(-) diff --git a/sys/arch/octeon/dev/cn30xxpipreg.h b/sys/arch/octeon/dev/cn30xxpipreg.h index 08adf5ec237..60de58d7645 100644 --- a/sys/arch/octeon/dev/cn30xxpipreg.h +++ b/sys/arch/octeon/dev/cn30xxpipreg.h @@ -3,7 +3,7 @@ * DONT EDIT THIS FILE */ -/* $OpenBSD: cn30xxpipreg.h,v 1.5 2016/05/30 15:41:28 visa Exp $ */ +/* $OpenBSD: cn30xxpipreg.h,v 1.6 2016/08/06 04:32:24 visa Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -618,9 +618,4 @@ #define PIP_WQE_WORD2_RE_OPCODE_SKIP 17ULL #define PIP_WQE_WORD2_RE_OPCODE_L2MAL 18ULL -/* XXX backward compatibility */ -#define PIP_OVER_ERR PIP_WQE_WORD2_RE_OPCODE_OVRRUN -#define PIP_GMX_FCS_ERR PIP_WQE_WORD2_RE_OPCODE_GMXFCS -#define PIP_ALIGN_ERR PIP_WQE_WORD2_RE_OPCODE_ALIGN - #endif /* _CN30XXPIPREG_H_ */ diff --git a/sys/arch/octeon/dev/if_cnmac.c b/sys/arch/octeon/dev/if_cnmac.c index 74cd247dc39..cb5985cc0ad 100644 --- a/sys/arch/octeon/dev/if_cnmac.c +++ b/sys/arch/octeon/dev/if_cnmac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_cnmac.c,v 1.56 2016/08/05 13:18:27 visa Exp $ */ +/* $OpenBSD: if_cnmac.c,v 1.57 2016/08/06 04:32:24 visa Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -164,7 +164,6 @@ void octeon_eth_tick_misc(void *); int octeon_eth_recv_mbuf(struct octeon_eth_softc *, uint64_t *, struct mbuf **, int *); -int octeon_eth_recv_check_code(struct octeon_eth_softc *, uint64_t); int octeon_eth_recv_check(struct octeon_eth_softc *, uint64_t); int octeon_eth_recv(struct octeon_eth_softc *, uint64_t *); void octeon_eth_recv_intr(void *, uint64_t *); @@ -323,9 +322,6 @@ octeon_eth_attach(struct device *parent, struct device *self, void *aux) memcpy(sc->sc_arpcom.ac_enaddr, enaddr, ETHER_ADDR_LEN); ether_ifattach(ifp); - /* XXX */ - sc->sc_rate_recv_check_code_cap.tv_sec = 1; - #if 1 octeon_eth_buf_init(sc); #endif @@ -1226,45 +1222,27 @@ octeon_eth_recv_mbuf(struct octeon_eth_softc *sc, uint64_t *work, } int -octeon_eth_recv_check_code(struct octeon_eth_softc *sc, uint64_t word2) +octeon_eth_recv_check(struct octeon_eth_softc *sc, uint64_t word2) { - uint64_t opecode = word2 & PIP_WQE_WORD2_NOIP_OPECODE; + static struct timeval rxerr_log_interval = { 0, 250000 }; + uint64_t opecode; if (__predict_true(!ISSET(word2, PIP_WQE_WORD2_NOIP_RE))) return 0; - /* this error is harmless */ - if (opecode == PIP_OVER_ERR) + opecode = word2 & PIP_WQE_WORD2_NOIP_OPECODE; + if ((sc->sc_arpcom.ac_if.if_flags & IFF_DEBUG) && + ratecheck(&sc->sc_rxerr_log_last, &rxerr_log_interval)) + log(LOG_DEBUG, "%s: rx error (%lld)\n", sc->sc_dev.dv_xname, + opecode); + + /* XXX harmless error? */ + if (opecode == PIP_WQE_WORD2_RE_OPCODE_OVRRUN) return 0; return 1; } -int -octeon_eth_recv_check(struct octeon_eth_softc *sc, uint64_t word2) -{ - if (__predict_false(octeon_eth_recv_check_code(sc, word2)) != 0) { - if ((word2 & PIP_WQE_WORD2_NOIP_OPECODE) == PIP_WQE_WORD2_RE_OPCODE_LENGTH) { - /* no logging */ - /* XXX inclement special error count */ - } else if ((word2 & PIP_WQE_WORD2_NOIP_OPECODE) == - PIP_WQE_WORD2_RE_OPCODE_PARTIAL) { - /* not an error. it's because of overload */ - } - else { - if (ratecheck(&sc->sc_rate_recv_check_code_last, - &sc->sc_rate_recv_check_code_cap)) - log(LOG_WARNING, - "%s: a reception error occured, " - "the packet was dropped (error code = %lld)\n", - sc->sc_dev.dv_xname, word2 & PIP_WQE_WORD2_NOIP_OPECODE); - } - return 1; - } - - return 0; -} - int octeon_eth_recv(struct octeon_eth_softc *sc, uint64_t *work) { diff --git a/sys/arch/octeon/dev/if_cnmacvar.h b/sys/arch/octeon/dev/if_cnmacvar.h index b15526b6299..b9708209d1c 100644 --- a/sys/arch/octeon/dev/if_cnmacvar.h +++ b/sys/arch/octeon/dev/if_cnmacvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_cnmacvar.h,v 1.15 2016/08/05 13:18:27 visa Exp $ */ +/* $OpenBSD: if_cnmacvar.h,v 1.16 2016/08/06 04:32:24 visa Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -106,6 +106,5 @@ struct octeon_eth_softc { size_t sc_ip_offset; - struct timeval sc_rate_recv_check_code_last; - struct timeval sc_rate_recv_check_code_cap; + struct timeval sc_rxerr_log_last; }; -- 2.20.1