diff options
author | Mark Johnston <markj@FreeBSD.org> | 2021-01-04 13:22:21 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2021-01-04 13:32:54 +0000 |
commit | caf552a607191ffc798e3edb697ae99d5b15711a (patch) | |
tree | 04322991d3312c575a488c3186c4842718372ed9 /sys/dev/neta | |
parent | c4cceb1d0d6f59789524feab3ddf7e3110d10d75 (diff) | |
download | src-caf552a607191ffc798e3edb697ae99d5b15711a.tar.gz src-caf552a607191ffc798e3edb697ae99d5b15711a.zip |
Diffstat (limited to 'sys/dev/neta')
-rw-r--r-- | sys/dev/neta/if_mvneta.c | 36 | ||||
-rw-r--r-- | sys/dev/neta/if_mvnetavar.h | 4 |
2 files changed, 19 insertions, 21 deletions
diff --git a/sys/dev/neta/if_mvneta.c b/sys/dev/neta/if_mvneta.c index c5cdf8bcb9ee..da364900f120 100644 --- a/sys/dev/neta/if_mvneta.c +++ b/sys/dev/neta/if_mvneta.c @@ -186,6 +186,7 @@ STATIC void sysctl_mvneta_init(struct mvneta_softc *); /* MIB */ STATIC void mvneta_clear_mib(struct mvneta_softc *); +STATIC uint64_t mvneta_read_mib(struct mvneta_softc *, int); STATIC void mvneta_update_mib(struct mvneta_softc *); /* Switch */ @@ -1102,7 +1103,7 @@ STATIC int mvneta_initreg(struct ifnet *ifp) { struct mvneta_softc *sc; - int q, i; + int q; uint32_t reg; sc = ifp->if_softc; @@ -1189,14 +1190,7 @@ mvneta_initreg(struct ifnet *ifp) MVNETA_WRITE(sc, MVNETA_PXCX, reg); /* clear MIB counter registers(clear by read) */ - for (i = 0; i < nitems(mvneta_mib_list); i++) { - if (mvneta_mib_list[i].reg64) - MVNETA_READ_MIB_8(sc, mvneta_mib_list[i].regnum); - else - MVNETA_READ_MIB_4(sc, mvneta_mib_list[i].regnum); - } - MVNETA_READ(sc, MVNETA_PDFC); - MVNETA_READ(sc, MVNETA_POFC); + mvneta_clear_mib(sc); /* Set SDC register except IPGINT bits */ reg = MVNETA_SDC_RXBSZ_16_64BITWORDS; @@ -3538,6 +3532,19 @@ sysctl_mvneta_init(struct mvneta_softc *sc) /* * MIB */ +STATIC uint64_t +mvneta_read_mib(struct mvneta_softc *sc, int index) +{ + struct mvneta_mib_def *mib; + uint64_t val; + + mib = &mvneta_mib_list[index]; + val = MVNETA_READ_MIB(sc, mib->regnum); + if (mib->reg64) + val |= (uint64_t)MVNETA_READ_MIB(sc, mib->regnum + 4) << 32; + return (val); +} + STATIC void mvneta_clear_mib(struct mvneta_softc *sc) { @@ -3546,10 +3553,7 @@ mvneta_clear_mib(struct mvneta_softc *sc) KASSERT_SC_MTX(sc); for (i = 0; i < nitems(mvneta_mib_list); i++) { - if (mvneta_mib_list[i].reg64) - MVNETA_READ_MIB_8(sc, mvneta_mib_list[i].regnum); - else - MVNETA_READ_MIB_4(sc, mvneta_mib_list[i].regnum); + (void)mvneta_read_mib(sc, i); sc->sysctl_mib[i].counter = 0; } MVNETA_READ(sc, MVNETA_PDFC); @@ -3569,11 +3573,7 @@ mvneta_update_mib(struct mvneta_softc *sc) for (i = 0; i < nitems(mvneta_mib_list); i++) { - if (mvneta_mib_list[i].reg64) - val = MVNETA_READ_MIB_8(sc, mvneta_mib_list[i].regnum); - else - val = MVNETA_READ_MIB_4(sc, mvneta_mib_list[i].regnum); - + val = mvneta_read_mib(sc, i); if (val == 0) continue; diff --git a/sys/dev/neta/if_mvnetavar.h b/sys/dev/neta/if_mvnetavar.h index e78a9ca0f3ee..00bfd1f0848c 100644 --- a/sys/dev/neta/if_mvnetavar.h +++ b/sys/dev/neta/if_mvnetavar.h @@ -69,10 +69,8 @@ #define MVNETA_WRITE_REGION(sc, reg, val, c) \ bus_write_region_4((sc)->res[0], (reg), (val), (c)) -#define MVNETA_READ_MIB_4(sc, reg) \ +#define MVNETA_READ_MIB(sc, reg) \ bus_read_4((sc)->res[0], MVNETA_PORTMIB_BASE + (reg)) -#define MVNETA_READ_MIB_8(sc, reg) \ - bus_read_8((sc)->res[0], MVNETA_PORTMIB_BASE + (reg)) #define MVNETA_IS_LINKUP(sc) \ (MVNETA_READ((sc), MVNETA_PSR) & MVNETA_PSR_LINKUP) |