Adopt <net/if_stats.h>.diff -r1.37 -r1.38 src/sys/dev/pci/if_cas.c
(thorpej)
--- src/sys/dev/pci/if_cas.c 2019/12/26 17:51:08 1.37
+++ src/sys/dev/pci/if_cas.c 2020/01/30 05:24:53 1.38
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_cas.c,v 1.37 2019/12/26 17:51:08 msaitoh Exp $ */ | 1 | /* $NetBSD: if_cas.c,v 1.38 2020/01/30 05:24:53 thorpej Exp $ */ | |
2 | /* $OpenBSD: if_cas.c,v 1.29 2009/11/29 16:19:38 kettenis Exp $ */ | 2 | /* $OpenBSD: if_cas.c,v 1.29 2009/11/29 16:19:38 kettenis Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * | 5 | * | |
6 | * Copyright (C) 2007 Mark Kettenis. | 6 | * Copyright (C) 2007 Mark Kettenis. | |
7 | * Copyright (C) 2001 Eduardo Horvath. | 7 | * Copyright (C) 2001 Eduardo Horvath. | |
8 | * All rights reserved. | 8 | * All rights reserved. | |
9 | * | 9 | * | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -34,27 +34,27 @@ | @@ -34,27 +34,27 @@ | |||
34 | /* | 34 | /* | |
35 | * Driver for Sun Cassini ethernet controllers. | 35 | * Driver for Sun Cassini ethernet controllers. | |
36 | * | 36 | * | |
37 | * There are basically two variants of this chip: Cassini and | 37 | * There are basically two variants of this chip: Cassini and | |
38 | * Cassini+. We can distinguish between the two by revision: 0x10 and | 38 | * Cassini+. We can distinguish between the two by revision: 0x10 and | |
39 | * up are Cassini+. The most important difference is that Cassini+ | 39 | * up are Cassini+. The most important difference is that Cassini+ | |
40 | * has a second RX descriptor ring. Cassini+ will not work without | 40 | * has a second RX descriptor ring. Cassini+ will not work without | |
41 | * configuring that second ring. However, since we don't use it we | 41 | * configuring that second ring. However, since we don't use it we | |
42 | * don't actually fill the descriptors, and only hand off the first | 42 | * don't actually fill the descriptors, and only hand off the first | |
43 | * four to the chip. | 43 | * four to the chip. | |
44 | */ | 44 | */ | |
45 | 45 | |||
46 | #include <sys/cdefs.h> | 46 | #include <sys/cdefs.h> | |
47 | __KERNEL_RCSID(0, "$NetBSD: if_cas.c,v 1.37 2019/12/26 17:51:08 msaitoh Exp $"); | 47 | __KERNEL_RCSID(0, "$NetBSD: if_cas.c,v 1.38 2020/01/30 05:24:53 thorpej Exp $"); | |
48 | 48 | |||
49 | #ifndef _MODULE | 49 | #ifndef _MODULE | |
50 | #include "opt_inet.h" | 50 | #include "opt_inet.h" | |
51 | #endif | 51 | #endif | |
52 | 52 | |||
53 | #include <sys/param.h> | 53 | #include <sys/param.h> | |
54 | #include <sys/systm.h> | 54 | #include <sys/systm.h> | |
55 | #include <sys/callout.h> | 55 | #include <sys/callout.h> | |
56 | #include <sys/mbuf.h> | 56 | #include <sys/mbuf.h> | |
57 | #include <sys/syslog.h> | 57 | #include <sys/syslog.h> | |
58 | #include <sys/malloc.h> | 58 | #include <sys/malloc.h> | |
59 | #include <sys/kernel.h> | 59 | #include <sys/kernel.h> | |
60 | #include <sys/socket.h> | 60 | #include <sys/socket.h> | |
@@ -832,40 +832,44 @@ cas_partial_detach(struct cas_softc *sc, | @@ -832,40 +832,44 @@ cas_partial_detach(struct cas_softc *sc, | |||
832 | (*ca->ca_detach)(sc->sc_dev, 0); | 832 | (*ca->ca_detach)(sc->sc_dev, 0); | |
833 | } | 833 | } | |
834 | 834 | |||
835 | void | 835 | void | |
836 | cas_tick(void *arg) | 836 | cas_tick(void *arg) | |
837 | { | 837 | { | |
838 | struct cas_softc *sc = arg; | 838 | struct cas_softc *sc = arg; | |
839 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | 839 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | |
840 | bus_space_tag_t t = sc->sc_memt; | 840 | bus_space_tag_t t = sc->sc_memt; | |
841 | bus_space_handle_t mac = sc->sc_memh; | 841 | bus_space_handle_t mac = sc->sc_memh; | |
842 | int s; | 842 | int s; | |
843 | uint32_t v; | 843 | uint32_t v; | |
844 | 844 | |||
845 | net_stat_ref_t nsr = IF_STAT_GETREF(ifp); | |||
846 | ||||
845 | /* unload collisions counters */ | 847 | /* unload collisions counters */ | |
846 | v = bus_space_read_4(t, mac, CAS_MAC_EXCESS_COLL_CNT) + | 848 | v = bus_space_read_4(t, mac, CAS_MAC_EXCESS_COLL_CNT) + | |
847 | bus_space_read_4(t, mac, CAS_MAC_LATE_COLL_CNT); | 849 | bus_space_read_4(t, mac, CAS_MAC_LATE_COLL_CNT); | |
848 | ifp->if_collisions += v + | 850 | if_statadd_ref(nsr, if_collisions, v + | |
849 | bus_space_read_4(t, mac, CAS_MAC_NORM_COLL_CNT) + | 851 | bus_space_read_4(t, mac, CAS_MAC_NORM_COLL_CNT) + | |
850 | bus_space_read_4(t, mac, CAS_MAC_FIRST_COLL_CNT); | 852 | bus_space_read_4(t, mac, CAS_MAC_FIRST_COLL_CNT)); | |
851 | ifp->if_oerrors += v; | 853 | if_statadd_ref(nsr, if_oerrors, v); | |
852 | 854 | |||
853 | /* read error counters */ | 855 | /* read error counters */ | |
854 | ifp->if_ierrors += | 856 | if_statadd_ref(nsr, if_ierrors, | |
855 | bus_space_read_4(t, mac, CAS_MAC_RX_LEN_ERR_CNT) + | 857 | bus_space_read_4(t, mac, CAS_MAC_RX_LEN_ERR_CNT) + | |
856 | bus_space_read_4(t, mac, CAS_MAC_RX_ALIGN_ERR) + | 858 | bus_space_read_4(t, mac, CAS_MAC_RX_ALIGN_ERR) + | |
857 | bus_space_read_4(t, mac, CAS_MAC_RX_CRC_ERR_CNT) + | 859 | bus_space_read_4(t, mac, CAS_MAC_RX_CRC_ERR_CNT) + | |
858 | bus_space_read_4(t, mac, CAS_MAC_RX_CODE_VIOL); | 860 | bus_space_read_4(t, mac, CAS_MAC_RX_CODE_VIOL)); | |
861 | ||||
862 | IF_STAT_PUTREF(ifp); | |||
859 | 863 | |||
860 | /* clear the hardware counters */ | 864 | /* clear the hardware counters */ | |
861 | bus_space_write_4(t, mac, CAS_MAC_NORM_COLL_CNT, 0); | 865 | bus_space_write_4(t, mac, CAS_MAC_NORM_COLL_CNT, 0); | |
862 | bus_space_write_4(t, mac, CAS_MAC_FIRST_COLL_CNT, 0); | 866 | bus_space_write_4(t, mac, CAS_MAC_FIRST_COLL_CNT, 0); | |
863 | bus_space_write_4(t, mac, CAS_MAC_EXCESS_COLL_CNT, 0); | 867 | bus_space_write_4(t, mac, CAS_MAC_EXCESS_COLL_CNT, 0); | |
864 | bus_space_write_4(t, mac, CAS_MAC_LATE_COLL_CNT, 0); | 868 | bus_space_write_4(t, mac, CAS_MAC_LATE_COLL_CNT, 0); | |
865 | bus_space_write_4(t, mac, CAS_MAC_RX_LEN_ERR_CNT, 0); | 869 | bus_space_write_4(t, mac, CAS_MAC_RX_LEN_ERR_CNT, 0); | |
866 | bus_space_write_4(t, mac, CAS_MAC_RX_ALIGN_ERR, 0); | 870 | bus_space_write_4(t, mac, CAS_MAC_RX_ALIGN_ERR, 0); | |
867 | bus_space_write_4(t, mac, CAS_MAC_RX_CRC_ERR_CNT, 0); | 871 | bus_space_write_4(t, mac, CAS_MAC_RX_CRC_ERR_CNT, 0); | |
868 | bus_space_write_4(t, mac, CAS_MAC_RX_CODE_VIOL, 0); | 872 | bus_space_write_4(t, mac, CAS_MAC_RX_CODE_VIOL, 0); | |
869 | 873 | |||
870 | s = splnet(); | 874 | s = splnet(); | |
871 | mii_tick(&sc->sc_mii); | 875 | mii_tick(&sc->sc_mii); | |
@@ -1406,27 +1410,27 @@ cas_rint(struct cas_softc *sc) | @@ -1406,27 +1410,27 @@ cas_rint(struct cas_softc *sc) | |||
1406 | 1410 | |||
1407 | if (word[0] & CAS_RC0_RELEASE_HDR) | 1411 | if (word[0] & CAS_RC0_RELEASE_HDR) | |
1408 | cas_add_rxbuf(sc, idx); | 1412 | cas_add_rxbuf(sc, idx); | |
1409 | 1413 | |||
1410 | if (m != NULL) { | 1414 | if (m != NULL) { | |
1411 | 1415 | |||
1412 | /* | 1416 | /* | |
1413 | * Pass this up to any BPF listeners, but only | 1417 | * Pass this up to any BPF listeners, but only | |
1414 | * pass it up the stack if its for us. | 1418 | * pass it up the stack if its for us. | |
1415 | */ | 1419 | */ | |
1416 | m->m_pkthdr.csum_flags = 0; | 1420 | m->m_pkthdr.csum_flags = 0; | |
1417 | if_percpuq_enqueue(ifp->if_percpuq, m); | 1421 | if_percpuq_enqueue(ifp->if_percpuq, m); | |
1418 | } else | 1422 | } else | |
1419 | ifp->if_ierrors++; | 1423 | if_statinc(ifp, if_ierrors); | |
1420 | } | 1424 | } | |
1421 | 1425 | |||
1422 | len = CAS_RC0_DATA_LEN(word[0]); | 1426 | len = CAS_RC0_DATA_LEN(word[0]); | |
1423 | if (len > 0) { | 1427 | if (len > 0) { | |
1424 | off = CAS_RC0_DATA_OFF(word[0]); | 1428 | off = CAS_RC0_DATA_OFF(word[0]); | |
1425 | idx = CAS_RC0_DATA_IDX(word[0]); | 1429 | idx = CAS_RC0_DATA_IDX(word[0]); | |
1426 | rxs = &sc->sc_rxsoft[idx]; | 1430 | rxs = &sc->sc_rxsoft[idx]; | |
1427 | 1431 | |||
1428 | DPRINTF(sc, ("data at idx %d, off %d, len %d\n", | 1432 | DPRINTF(sc, ("data at idx %d, off %d, len %d\n", | |
1429 | idx, off, len)); | 1433 | idx, off, len)); | |
1430 | 1434 | |||
1431 | bus_dmamap_sync(sc->sc_dmatag, rxs->rxs_dmamap, 0, | 1435 | bus_dmamap_sync(sc->sc_dmatag, rxs->rxs_dmamap, 0, | |
1432 | rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); | 1436 | rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); | |
@@ -1436,27 +1440,27 @@ cas_rint(struct cas_softc *sc) | @@ -1436,27 +1440,27 @@ cas_rint(struct cas_softc *sc) | |||
1436 | m = m_devget(cp, len, 0, ifp); | 1440 | m = m_devget(cp, len, 0, ifp); | |
1437 | 1441 | |||
1438 | if (word[0] & CAS_RC0_RELEASE_DATA) | 1442 | if (word[0] & CAS_RC0_RELEASE_DATA) | |
1439 | cas_add_rxbuf(sc, idx); | 1443 | cas_add_rxbuf(sc, idx); | |
1440 | 1444 | |||
1441 | if (m != NULL) { | 1445 | if (m != NULL) { | |
1442 | /* | 1446 | /* | |
1443 | * Pass this up to any BPF listeners, but only | 1447 | * Pass this up to any BPF listeners, but only | |
1444 | * pass it up the stack if its for us. | 1448 | * pass it up the stack if its for us. | |
1445 | */ | 1449 | */ | |
1446 | m->m_pkthdr.csum_flags = 0; | 1450 | m->m_pkthdr.csum_flags = 0; | |
1447 | if_percpuq_enqueue(ifp->if_percpuq, m); | 1451 | if_percpuq_enqueue(ifp->if_percpuq, m); | |
1448 | } else | 1452 | } else | |
1449 | ifp->if_ierrors++; | 1453 | if_statinc(ifp, if_ierrors); | |
1450 | } | 1454 | } | |
1451 | 1455 | |||
1452 | if (word[0] & CAS_RC0_SPLIT) | 1456 | if (word[0] & CAS_RC0_SPLIT) | |
1453 | aprint_error_dev(sc->sc_dev, "split packet\n"); | 1457 | aprint_error_dev(sc->sc_dev, "split packet\n"); | |
1454 | 1458 | |||
1455 | skip = CAS_RC0_SKIP(word[0]); | 1459 | skip = CAS_RC0_SKIP(word[0]); | |
1456 | } | 1460 | } | |
1457 | 1461 | |||
1458 | while (sc->sc_rxptr != i) { | 1462 | while (sc->sc_rxptr != i) { | |
1459 | sc->sc_rxcomps[sc->sc_rxptr].cc_word[0] = 0; | 1463 | sc->sc_rxcomps[sc->sc_rxptr].cc_word[0] = 0; | |
1460 | sc->sc_rxcomps[sc->sc_rxptr].cc_word[1] = 0; | 1464 | sc->sc_rxcomps[sc->sc_rxptr].cc_word[1] = 0; | |
1461 | sc->sc_rxcomps[sc->sc_rxptr].cc_word[2] = 0; | 1465 | sc->sc_rxcomps[sc->sc_rxptr].cc_word[2] = 0; | |
1462 | sc->sc_rxcomps[sc->sc_rxptr].cc_word[3] = | 1466 | sc->sc_rxcomps[sc->sc_rxptr].cc_word[3] = | |
@@ -1576,53 +1580,53 @@ cas_intr(void *v) | @@ -1576,53 +1580,53 @@ cas_intr(void *v) | |||
1576 | } | 1580 | } | |
1577 | if (status & CAS_INTR_RX_MAC) { | 1581 | if (status & CAS_INTR_RX_MAC) { | |
1578 | int rxstat = bus_space_read_4(t, seb, CAS_MAC_RX_STATUS); | 1582 | int rxstat = bus_space_read_4(t, seb, CAS_MAC_RX_STATUS); | |
1579 | #ifdef CAS_DEBUG | 1583 | #ifdef CAS_DEBUG | |
1580 | if (rxstat & ~CAS_MAC_RX_DONE) | 1584 | if (rxstat & ~CAS_MAC_RX_DONE) | |
1581 | printf("%s: MAC rx fault, status %x\n", | 1585 | printf("%s: MAC rx fault, status %x\n", | |
1582 | device_xname(sc->sc_dev), rxstat); | 1586 | device_xname(sc->sc_dev), rxstat); | |
1583 | #endif | 1587 | #endif | |
1584 | /* | 1588 | /* | |
1585 | * On some chip revisions CAS_MAC_RX_OVERFLOW happen often | 1589 | * On some chip revisions CAS_MAC_RX_OVERFLOW happen often | |
1586 | * due to a silicon bug so handle them silently. | 1590 | * due to a silicon bug so handle them silently. | |
1587 | */ | 1591 | */ | |
1588 | if (rxstat & CAS_MAC_RX_OVERFLOW) { | 1592 | if (rxstat & CAS_MAC_RX_OVERFLOW) { | |
1589 | ifp->if_ierrors++; | 1593 | if_statinc(ifp, if_ierrors); | |
1590 | cas_init(ifp); | 1594 | cas_init(ifp); | |
1591 | } | 1595 | } | |
1592 | #ifdef CAS_DEBUG | 1596 | #ifdef CAS_DEBUG | |
1593 | else if (rxstat & ~(CAS_MAC_RX_DONE | CAS_MAC_RX_FRAME_CNT)) | 1597 | else if (rxstat & ~(CAS_MAC_RX_DONE | CAS_MAC_RX_FRAME_CNT)) | |
1594 | printf("%s: MAC rx fault, status %x\n", | 1598 | printf("%s: MAC rx fault, status %x\n", | |
1595 | device_xname(sc->sc_dev), rxstat); | 1599 | device_xname(sc->sc_dev), rxstat); | |
1596 | #endif | 1600 | #endif | |
1597 | } | 1601 | } | |
1598 | rnd_add_uint32(&sc->rnd_source, status); | 1602 | rnd_add_uint32(&sc->rnd_source, status); | |
1599 | return (r); | 1603 | return (r); | |
1600 | } | 1604 | } | |
1601 | 1605 | |||
1602 | 1606 | |||
1603 | void | 1607 | void | |
1604 | cas_watchdog(struct ifnet *ifp) | 1608 | cas_watchdog(struct ifnet *ifp) | |
1605 | { | 1609 | { | |
1606 | struct cas_softc *sc = ifp->if_softc; | 1610 | struct cas_softc *sc = ifp->if_softc; | |
1607 | 1611 | |||
1608 | DPRINTF(sc, ("cas_watchdog: CAS_RX_CONFIG %x CAS_MAC_RX_STATUS %x " | 1612 | DPRINTF(sc, ("cas_watchdog: CAS_RX_CONFIG %x CAS_MAC_RX_STATUS %x " | |
1609 | "CAS_MAC_RX_CONFIG %x\n", | 1613 | "CAS_MAC_RX_CONFIG %x\n", | |
1610 | bus_space_read_4(sc->sc_memt, sc->sc_memh, CAS_RX_CONFIG), | 1614 | bus_space_read_4(sc->sc_memt, sc->sc_memh, CAS_RX_CONFIG), | |
1611 | bus_space_read_4(sc->sc_memt, sc->sc_memh, CAS_MAC_RX_STATUS), | 1615 | bus_space_read_4(sc->sc_memt, sc->sc_memh, CAS_MAC_RX_STATUS), | |
1612 | bus_space_read_4(sc->sc_memt, sc->sc_memh, CAS_MAC_RX_CONFIG))); | 1616 | bus_space_read_4(sc->sc_memt, sc->sc_memh, CAS_MAC_RX_CONFIG))); | |
1613 | 1617 | |||
1614 | log(LOG_ERR, "%s: device timeout\n", device_xname(sc->sc_dev)); | 1618 | log(LOG_ERR, "%s: device timeout\n", device_xname(sc->sc_dev)); | |
1615 | ++ifp->if_oerrors; | 1619 | if_statinc(ifp, if_oerrors); | |
1616 | 1620 | |||
1617 | /* Try to get more packets going. */ | 1621 | /* Try to get more packets going. */ | |
1618 | cas_init(ifp); | 1622 | cas_init(ifp); | |
1619 | } | 1623 | } | |
1620 | 1624 | |||
1621 | /* | 1625 | /* | |
1622 | * Initialize the MII Management Interface | 1626 | * Initialize the MII Management Interface | |
1623 | */ | 1627 | */ | |
1624 | void | 1628 | void | |
1625 | cas_mifinit(struct cas_softc *sc) | 1629 | cas_mifinit(struct cas_softc *sc) | |
1626 | { | 1630 | { | |
1627 | bus_space_tag_t t = sc->sc_memt; | 1631 | bus_space_tag_t t = sc->sc_memt; | |
1628 | bus_space_handle_t mif = sc->sc_memh; | 1632 | bus_space_handle_t mif = sc->sc_memh; | |
@@ -2121,27 +2125,27 @@ cas_tint(struct cas_softc *sc, uint32_t | @@ -2121,27 +2125,27 @@ cas_tint(struct cas_softc *sc, uint32_t | |||
2121 | struct cas_sxd *sd; | 2125 | struct cas_sxd *sd; | |
2122 | uint32_t cons, comp; | 2126 | uint32_t cons, comp; | |
2123 | 2127 | |||
2124 | comp = bus_space_read_4(sc->sc_memt, sc->sc_memh, CAS_TX_COMPLETION); | 2128 | comp = bus_space_read_4(sc->sc_memt, sc->sc_memh, CAS_TX_COMPLETION); | |
2125 | cons = sc->sc_tx_cons; | 2129 | cons = sc->sc_tx_cons; | |
2126 | while (cons != comp) { | 2130 | while (cons != comp) { | |
2127 | sd = &sc->sc_txd[cons]; | 2131 | sd = &sc->sc_txd[cons]; | |
2128 | if (sd->sd_mbuf != NULL) { | 2132 | if (sd->sd_mbuf != NULL) { | |
2129 | bus_dmamap_sync(sc->sc_dmatag, sd->sd_map, 0, | 2133 | bus_dmamap_sync(sc->sc_dmatag, sd->sd_map, 0, | |
2130 | sd->sd_map->dm_mapsize, BUS_DMASYNC_POSTWRITE); | 2134 | sd->sd_map->dm_mapsize, BUS_DMASYNC_POSTWRITE); | |
2131 | bus_dmamap_unload(sc->sc_dmatag, sd->sd_map); | 2135 | bus_dmamap_unload(sc->sc_dmatag, sd->sd_map); | |
2132 | m_freem(sd->sd_mbuf); | 2136 | m_freem(sd->sd_mbuf); | |
2133 | sd->sd_mbuf = NULL; | 2137 | sd->sd_mbuf = NULL; | |
2134 | ifp->if_opackets++; | 2138 | if_statinc(ifp, if_opackets); | |
2135 | } | 2139 | } | |
2136 | sc->sc_tx_cnt--; | 2140 | sc->sc_tx_cnt--; | |
2137 | if (++cons == CAS_NTXDESC) | 2141 | if (++cons == CAS_NTXDESC) | |
2138 | cons = 0; | 2142 | cons = 0; | |
2139 | } | 2143 | } | |
2140 | sc->sc_tx_cons = cons; | 2144 | sc->sc_tx_cons = cons; | |
2141 | 2145 | |||
2142 | if (sc->sc_tx_cnt < CAS_NTXDESC - 2) | 2146 | if (sc->sc_tx_cnt < CAS_NTXDESC - 2) | |
2143 | ifp->if_flags &= ~IFF_OACTIVE; | 2147 | ifp->if_flags &= ~IFF_OACTIVE; | |
2144 | if (sc->sc_tx_cnt == 0) | 2148 | if (sc->sc_tx_cnt == 0) | |
2145 | ifp->if_timer = 0; | 2149 | ifp->if_timer = 0; | |
2146 | 2150 | |||
2147 | if_schedule_deferred_start(ifp); | 2151 | if_schedule_deferred_start(ifp); |
--- src/sys/dev/pci/if_dge.c 2019/11/10 21:16:36 1.56
+++ src/sys/dev/pci/if_dge.c 2020/01/30 05:24:53 1.57
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_dge.c,v 1.56 2019/11/10 21:16:36 chs Exp $ */ | 1 | /* $NetBSD: if_dge.c,v 1.57 2020/01/30 05:24:53 thorpej Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2004, SUNET, Swedish University Computer Network. | 4 | * Copyright (c) 2004, SUNET, Swedish University Computer Network. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Anders Magnusson for SUNET, Swedish University Computer Network. | 7 | * Written by Anders Magnusson for SUNET, Swedish University Computer Network. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -70,27 +70,27 @@ | @@ -70,27 +70,27 @@ | |||
70 | */ | 70 | */ | |
71 | 71 | |||
72 | /* | 72 | /* | |
73 | * Device driver for the Intel 82597EX Ten Gigabit Ethernet controller. | 73 | * Device driver for the Intel 82597EX Ten Gigabit Ethernet controller. | |
74 | * | 74 | * | |
75 | * TODO (in no specific order): | 75 | * TODO (in no specific order): | |
76 | * HW VLAN support. | 76 | * HW VLAN support. | |
77 | * TSE offloading (needs kernel changes...) | 77 | * TSE offloading (needs kernel changes...) | |
78 | * RAIDC (receive interrupt delay adaptation) | 78 | * RAIDC (receive interrupt delay adaptation) | |
79 | * Use memory > 4GB. | 79 | * Use memory > 4GB. | |
80 | */ | 80 | */ | |
81 | 81 | |||
82 | #include <sys/cdefs.h> | 82 | #include <sys/cdefs.h> | |
83 | __KERNEL_RCSID(0, "$NetBSD: if_dge.c,v 1.56 2019/11/10 21:16:36 chs Exp $"); | 83 | __KERNEL_RCSID(0, "$NetBSD: if_dge.c,v 1.57 2020/01/30 05:24:53 thorpej Exp $"); | |
84 | 84 | |||
85 | 85 | |||
86 | 86 | |||
87 | #include <sys/param.h> | 87 | #include <sys/param.h> | |
88 | #include <sys/systm.h> | 88 | #include <sys/systm.h> | |
89 | #include <sys/callout.h> | 89 | #include <sys/callout.h> | |
90 | #include <sys/mbuf.h> | 90 | #include <sys/mbuf.h> | |
91 | #include <sys/malloc.h> | 91 | #include <sys/malloc.h> | |
92 | #include <sys/kernel.h> | 92 | #include <sys/kernel.h> | |
93 | #include <sys/socket.h> | 93 | #include <sys/socket.h> | |
94 | #include <sys/ioctl.h> | 94 | #include <sys/ioctl.h> | |
95 | #include <sys/errno.h> | 95 | #include <sys/errno.h> | |
96 | #include <sys/device.h> | 96 | #include <sys/device.h> | |
@@ -1415,27 +1415,27 @@ dge_watchdog(struct ifnet *ifp) | @@ -1415,27 +1415,27 @@ dge_watchdog(struct ifnet *ifp) | |||
1415 | { | 1415 | { | |
1416 | struct dge_softc *sc = ifp->if_softc; | 1416 | struct dge_softc *sc = ifp->if_softc; | |
1417 | 1417 | |||
1418 | /* | 1418 | /* | |
1419 | * Since we're using delayed interrupts, sweep up | 1419 | * Since we're using delayed interrupts, sweep up | |
1420 | * before we report an error. | 1420 | * before we report an error. | |
1421 | */ | 1421 | */ | |
1422 | dge_txintr(sc); | 1422 | dge_txintr(sc); | |
1423 | 1423 | |||
1424 | if (sc->sc_txfree != DGE_NTXDESC) { | 1424 | if (sc->sc_txfree != DGE_NTXDESC) { | |
1425 | printf("%s: device timeout (txfree %d txsfree %d txnext %d)\n", | 1425 | printf("%s: device timeout (txfree %d txsfree %d txnext %d)\n", | |
1426 | device_xname(sc->sc_dev), sc->sc_txfree, sc->sc_txsfree, | 1426 | device_xname(sc->sc_dev), sc->sc_txfree, sc->sc_txsfree, | |
1427 | sc->sc_txnext); | 1427 | sc->sc_txnext); | |
1428 | ifp->if_oerrors++; | 1428 | if_statinc(ifp, if_oerrors); | |
1429 | 1429 | |||
1430 | /* Reset the interface. */ | 1430 | /* Reset the interface. */ | |
1431 | (void) dge_init(ifp); | 1431 | (void) dge_init(ifp); | |
1432 | } | 1432 | } | |
1433 | 1433 | |||
1434 | /* Try to get more packets going. */ | 1434 | /* Try to get more packets going. */ | |
1435 | dge_start(ifp); | 1435 | dge_start(ifp); | |
1436 | } | 1436 | } | |
1437 | 1437 | |||
1438 | /* | 1438 | /* | |
1439 | * dge_ioctl: [ifnet interface function] | 1439 | * dge_ioctl: [ifnet interface function] | |
1440 | * | 1440 | * | |
1441 | * Handle control requests from the operator. | 1441 | * Handle control requests from the operator. | |
@@ -1612,27 +1612,27 @@ dge_txintr(struct dge_softc *sc) | @@ -1612,27 +1612,27 @@ dge_txintr(struct dge_softc *sc) | |||
1612 | status = | 1612 | status = | |
1613 | sc->sc_txdescs[txs->txs_lastdesc].dt_status; | 1613 | sc->sc_txdescs[txs->txs_lastdesc].dt_status; | |
1614 | if ((status & TDESC_STA_DD) == 0) { | 1614 | if ((status & TDESC_STA_DD) == 0) { | |
1615 | DGE_CDTXSYNC(sc, txs->txs_lastdesc, 1, | 1615 | DGE_CDTXSYNC(sc, txs->txs_lastdesc, 1, | |
1616 | BUS_DMASYNC_PREREAD); | 1616 | BUS_DMASYNC_PREREAD); | |
1617 | break; | 1617 | break; | |
1618 | } | 1618 | } | |
1619 | 1619 | |||
1620 | DPRINTF(DGE_DEBUG_TX, | 1620 | DPRINTF(DGE_DEBUG_TX, | |
1621 | ("%s: TX: job %d done: descs %d..%d\n", | 1621 | ("%s: TX: job %d done: descs %d..%d\n", | |
1622 | device_xname(sc->sc_dev), i, txs->txs_firstdesc, | 1622 | device_xname(sc->sc_dev), i, txs->txs_firstdesc, | |
1623 | txs->txs_lastdesc)); | 1623 | txs->txs_lastdesc)); | |
1624 | 1624 | |||
1625 | ifp->if_opackets++; | 1625 | if_statinc(ifp, if_opackets); | |
1626 | sc->sc_txfree += txs->txs_ndesc; | 1626 | sc->sc_txfree += txs->txs_ndesc; | |
1627 | bus_dmamap_sync(sc->sc_dmat, txs->txs_dmamap, | 1627 | bus_dmamap_sync(sc->sc_dmat, txs->txs_dmamap, | |
1628 | 0, txs->txs_dmamap->dm_mapsize, BUS_DMASYNC_POSTWRITE); | 1628 | 0, txs->txs_dmamap->dm_mapsize, BUS_DMASYNC_POSTWRITE); | |
1629 | bus_dmamap_unload(sc->sc_dmat, txs->txs_dmamap); | 1629 | bus_dmamap_unload(sc->sc_dmat, txs->txs_dmamap); | |
1630 | m_freem(txs->txs_mbuf); | 1630 | m_freem(txs->txs_mbuf); | |
1631 | txs->txs_mbuf = NULL; | 1631 | txs->txs_mbuf = NULL; | |
1632 | } | 1632 | } | |
1633 | 1633 | |||
1634 | /* Update the dirty transmit buffer pointer. */ | 1634 | /* Update the dirty transmit buffer pointer. */ | |
1635 | sc->sc_txsdirty = i; | 1635 | sc->sc_txsdirty = i; | |
1636 | DPRINTF(DGE_DEBUG_TX, | 1636 | DPRINTF(DGE_DEBUG_TX, | |
1637 | ("%s: TX: txsdirty -> %d\n", device_xname(sc->sc_dev), i)); | 1637 | ("%s: TX: txsdirty -> %d\n", device_xname(sc->sc_dev), i)); | |
1638 | 1638 | |||
@@ -1696,27 +1696,27 @@ dge_rxintr(struct dge_softc *sc) | @@ -1696,27 +1696,27 @@ dge_rxintr(struct dge_softc *sc) | |||
1696 | bus_dmamap_sync(sc->sc_dmat, rxs->rxs_dmamap, 0, | 1696 | bus_dmamap_sync(sc->sc_dmat, rxs->rxs_dmamap, 0, | |
1697 | rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); | 1697 | rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); | |
1698 | 1698 | |||
1699 | m = rxs->rxs_mbuf; | 1699 | m = rxs->rxs_mbuf; | |
1700 | 1700 | |||
1701 | /* | 1701 | /* | |
1702 | * Add a new receive buffer to the ring. | 1702 | * Add a new receive buffer to the ring. | |
1703 | */ | 1703 | */ | |
1704 | if (dge_add_rxbuf(sc, i) != 0) { | 1704 | if (dge_add_rxbuf(sc, i) != 0) { | |
1705 | /* | 1705 | /* | |
1706 | * Failed, throw away what we've done so | 1706 | * Failed, throw away what we've done so | |
1707 | * far, and discard the rest of the packet. | 1707 | * far, and discard the rest of the packet. | |
1708 | */ | 1708 | */ | |
1709 | ifp->if_ierrors++; | 1709 | if_statinc(ifp, if_ierrors); | |
1710 | bus_dmamap_sync(sc->sc_dmat, rxs->rxs_dmamap, 0, | 1710 | bus_dmamap_sync(sc->sc_dmat, rxs->rxs_dmamap, 0, | |
1711 | rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD); | 1711 | rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD); | |
1712 | DGE_INIT_RXDESC(sc, i); | 1712 | DGE_INIT_RXDESC(sc, i); | |
1713 | if ((status & RDESC_STS_EOP) == 0) | 1713 | if ((status & RDESC_STS_EOP) == 0) | |
1714 | sc->sc_rxdiscard = 1; | 1714 | sc->sc_rxdiscard = 1; | |
1715 | if (sc->sc_rxhead != NULL) | 1715 | if (sc->sc_rxhead != NULL) | |
1716 | m_freem(sc->sc_rxhead); | 1716 | m_freem(sc->sc_rxhead); | |
1717 | DGE_RXCHAIN_RESET(sc); | 1717 | DGE_RXCHAIN_RESET(sc); | |
1718 | DPRINTF(DGE_DEBUG_RX, | 1718 | DPRINTF(DGE_DEBUG_RX, | |
1719 | ("%s: RX: Rx buffer allocation failed, " | 1719 | ("%s: RX: Rx buffer allocation failed, " | |
1720 | "dropping packet%s\n", device_xname(sc->sc_dev), | 1720 | "dropping packet%s\n", device_xname(sc->sc_dev), | |
1721 | sc->sc_rxdiscard ? " (discard)" : "")); | 1721 | sc->sc_rxdiscard ? " (discard)" : "")); | |
1722 | continue; | 1722 | continue; | |
@@ -1751,27 +1751,27 @@ dge_rxintr(struct dge_softc *sc) | @@ -1751,27 +1751,27 @@ dge_rxintr(struct dge_softc *sc) | |||
1751 | len += sc->sc_rxlen; | 1751 | len += sc->sc_rxlen; | |
1752 | 1752 | |||
1753 | DGE_RXCHAIN_RESET(sc); | 1753 | DGE_RXCHAIN_RESET(sc); | |
1754 | 1754 | |||
1755 | DPRINTF(DGE_DEBUG_RX, | 1755 | DPRINTF(DGE_DEBUG_RX, | |
1756 | ("%s: RX: have entire packet, len -> %d\n", | 1756 | ("%s: RX: have entire packet, len -> %d\n", | |
1757 | device_xname(sc->sc_dev), len)); | 1757 | device_xname(sc->sc_dev), len)); | |
1758 | 1758 | |||
1759 | /* | 1759 | /* | |
1760 | * If an error occurred, update stats and drop the packet. | 1760 | * If an error occurred, update stats and drop the packet. | |
1761 | */ | 1761 | */ | |
1762 | if (errors & (RDESC_ERR_CE | RDESC_ERR_SE | RDESC_ERR_P | | 1762 | if (errors & (RDESC_ERR_CE | RDESC_ERR_SE | RDESC_ERR_P | | |
1763 | RDESC_ERR_RXE)) { | 1763 | RDESC_ERR_RXE)) { | |
1764 | ifp->if_ierrors++; | 1764 | if_statinc(ifp, if_ierrors); | |
1765 | if (errors & RDESC_ERR_SE) | 1765 | if (errors & RDESC_ERR_SE) | |
1766 | printf("%s: symbol error\n", | 1766 | printf("%s: symbol error\n", | |
1767 | device_xname(sc->sc_dev)); | 1767 | device_xname(sc->sc_dev)); | |
1768 | else if (errors & RDESC_ERR_P) | 1768 | else if (errors & RDESC_ERR_P) | |
1769 | printf("%s: parity error\n", | 1769 | printf("%s: parity error\n", | |
1770 | device_xname(sc->sc_dev)); | 1770 | device_xname(sc->sc_dev)); | |
1771 | else if (errors & RDESC_ERR_CE) | 1771 | else if (errors & RDESC_ERR_CE) | |
1772 | printf("%s: CRC error\n", | 1772 | printf("%s: CRC error\n", | |
1773 | device_xname(sc->sc_dev)); | 1773 | device_xname(sc->sc_dev)); | |
1774 | m_freem(m); | 1774 | m_freem(m); | |
1775 | continue; | 1775 | continue; | |
1776 | } | 1776 | } | |
1777 | 1777 |
--- src/sys/dev/pci/if_ste.c 2019/11/02 21:11:55 1.58
+++ src/sys/dev/pci/if_ste.c 2020/01/30 05:24:53 1.59
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_ste.c,v 1.58 2019/11/02 21:11:55 tnn Exp $ */ | 1 | /* $NetBSD: if_ste.c,v 1.59 2020/01/30 05:24:53 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * Device driver for the Sundance Tech. ST-201 10/100 | 33 | * Device driver for the Sundance Tech. ST-201 10/100 | |
34 | * Ethernet controller. | 34 | * Ethernet controller. | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: if_ste.c,v 1.58 2019/11/02 21:11:55 tnn Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: if_ste.c,v 1.59 2020/01/30 05:24:53 thorpej Exp $"); | |
39 | 39 | |||
40 | 40 | |||
41 | #include <sys/param.h> | 41 | #include <sys/param.h> | |
42 | #include <sys/systm.h> | 42 | #include <sys/systm.h> | |
43 | #include <sys/callout.h> | 43 | #include <sys/callout.h> | |
44 | #include <sys/mbuf.h> | 44 | #include <sys/mbuf.h> | |
45 | #include <sys/malloc.h> | 45 | #include <sys/malloc.h> | |
46 | #include <sys/kernel.h> | 46 | #include <sys/kernel.h> | |
47 | #include <sys/socket.h> | 47 | #include <sys/socket.h> | |
48 | #include <sys/ioctl.h> | 48 | #include <sys/ioctl.h> | |
49 | #include <sys/errno.h> | 49 | #include <sys/errno.h> | |
50 | #include <sys/device.h> | 50 | #include <sys/device.h> | |
51 | #include <sys/queue.h> | 51 | #include <sys/queue.h> | |
@@ -770,27 +770,27 @@ ste_start(struct ifnet *ifp) | @@ -770,27 +770,27 @@ ste_start(struct ifnet *ifp) | |||
770 | } | 770 | } | |
771 | 771 | |||
772 | /* | 772 | /* | |
773 | * ste_watchdog: [ifnet interface function] | 773 | * ste_watchdog: [ifnet interface function] | |
774 | * | 774 | * | |
775 | * Watchdog timer handler. | 775 | * Watchdog timer handler. | |
776 | */ | 776 | */ | |
777 | static void | 777 | static void | |
778 | ste_watchdog(struct ifnet *ifp) | 778 | ste_watchdog(struct ifnet *ifp) | |
779 | { | 779 | { | |
780 | struct ste_softc *sc = ifp->if_softc; | 780 | struct ste_softc *sc = ifp->if_softc; | |
781 | 781 | |||
782 | printf("%s: device timeout\n", device_xname(sc->sc_dev)); | 782 | printf("%s: device timeout\n", device_xname(sc->sc_dev)); | |
783 | ifp->if_oerrors++; | 783 | if_statinc(ifp, if_oerrors); | |
784 | 784 | |||
785 | ste_txintr(sc); | 785 | ste_txintr(sc); | |
786 | ste_rxintr(sc); | 786 | ste_rxintr(sc); | |
787 | (void) ste_init(ifp); | 787 | (void) ste_init(ifp); | |
788 | 788 | |||
789 | /* Try to get more packets going. */ | 789 | /* Try to get more packets going. */ | |
790 | ste_start(ifp); | 790 | ste_start(ifp); | |
791 | } | 791 | } | |
792 | 792 | |||
793 | /* | 793 | /* | |
794 | * ste_ioctl: [ifnet interface function] | 794 | * ste_ioctl: [ifnet interface function] | |
795 | * | 795 | * | |
796 | * Handle control requests from the operator. | 796 | * Handle control requests from the operator. | |
@@ -1029,27 +1029,27 @@ ste_rxintr(struct ste_softc *sc) | @@ -1029,27 +1029,27 @@ ste_rxintr(struct ste_softc *sc) | |||
1029 | if (m == NULL) | 1029 | if (m == NULL) | |
1030 | goto dropit; | 1030 | goto dropit; | |
1031 | m->m_data += 2; | 1031 | m->m_data += 2; | |
1032 | memcpy(mtod(m, void *), | 1032 | memcpy(mtod(m, void *), | |
1033 | mtod(ds->ds_mbuf, void *), len); | 1033 | mtod(ds->ds_mbuf, void *), len); | |
1034 | STE_INIT_RXDESC(sc, i); | 1034 | STE_INIT_RXDESC(sc, i); | |
1035 | bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0, | 1035 | bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0, | |
1036 | ds->ds_dmamap->dm_mapsize, | 1036 | ds->ds_dmamap->dm_mapsize, | |
1037 | BUS_DMASYNC_PREREAD); | 1037 | BUS_DMASYNC_PREREAD); | |
1038 | } else { | 1038 | } else { | |
1039 | m = ds->ds_mbuf; | 1039 | m = ds->ds_mbuf; | |
1040 | if (ste_add_rxbuf(sc, i) != 0) { | 1040 | if (ste_add_rxbuf(sc, i) != 0) { | |
1041 | dropit: | 1041 | dropit: | |
1042 | ifp->if_ierrors++; | 1042 | if_statinc(ifp, if_ierrors); | |
1043 | STE_INIT_RXDESC(sc, i); | 1043 | STE_INIT_RXDESC(sc, i); | |
1044 | bus_dmamap_sync(sc->sc_dmat, | 1044 | bus_dmamap_sync(sc->sc_dmat, | |
1045 | ds->ds_dmamap, 0, | 1045 | ds->ds_dmamap, 0, | |
1046 | ds->ds_dmamap->dm_mapsize, | 1046 | ds->ds_dmamap->dm_mapsize, | |
1047 | BUS_DMASYNC_PREREAD); | 1047 | BUS_DMASYNC_PREREAD); | |
1048 | continue; | 1048 | continue; | |
1049 | } | 1049 | } | |
1050 | } | 1050 | } | |
1051 | 1051 | |||
1052 | m_set_rcvif(m, ifp); | 1052 | m_set_rcvif(m, ifp); | |
1053 | m->m_pkthdr.len = m->m_len = len; | 1053 | m->m_pkthdr.len = m->m_len = len; | |
1054 | 1054 | |||
1055 | /* Pass it on. */ | 1055 | /* Pass it on. */ | |
@@ -1087,45 +1087,49 @@ ste_tick(void *arg) | @@ -1087,45 +1087,49 @@ ste_tick(void *arg) | |||
1087 | static void | 1087 | static void | |
1088 | ste_stats_update(struct ste_softc *sc) | 1088 | ste_stats_update(struct ste_softc *sc) | |
1089 | { | 1089 | { | |
1090 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | 1090 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | |
1091 | bus_space_tag_t st = sc->sc_st; | 1091 | bus_space_tag_t st = sc->sc_st; | |
1092 | bus_space_handle_t sh = sc->sc_sh; | 1092 | bus_space_handle_t sh = sc->sc_sh; | |
1093 | 1093 | |||
1094 | (void) bus_space_read_2(st, sh, STE_OctetsReceivedOk0); | 1094 | (void) bus_space_read_2(st, sh, STE_OctetsReceivedOk0); | |
1095 | (void) bus_space_read_2(st, sh, STE_OctetsReceivedOk1); | 1095 | (void) bus_space_read_2(st, sh, STE_OctetsReceivedOk1); | |
1096 | 1096 | |||
1097 | (void) bus_space_read_2(st, sh, STE_OctetsTransmittedOk0); | 1097 | (void) bus_space_read_2(st, sh, STE_OctetsTransmittedOk0); | |
1098 | (void) bus_space_read_2(st, sh, STE_OctetsTransmittedOk1); | 1098 | (void) bus_space_read_2(st, sh, STE_OctetsTransmittedOk1); | |
1099 | 1099 | |||
1100 | ifp->if_opackets += | 1100 | net_stat_ref_t nsr = IF_STAT_GETREF(ifp); | |
1101 | (u_int) bus_space_read_2(st, sh, STE_FramesTransmittedOK); | 1101 | ||
1102 | if_statadd_ref(nsr, if_opackets, | |||
1103 | (u_int) bus_space_read_2(st, sh, STE_FramesTransmittedOK)); | |||
1102 | 1104 | |||
1103 | (void) bus_space_read_2(st, sh, STE_FramesReceivedOK); | 1105 | (void) bus_space_read_2(st, sh, STE_FramesReceivedOK); | |
1104 | 1106 | |||
1105 | ifp->if_collisions += | 1107 | if_statadd_ref(nsr, if_collisions, | |
1106 | (u_int) bus_space_read_1(st, sh, STE_LateCollisions) + | 1108 | (u_int) bus_space_read_1(st, sh, STE_LateCollisions) + | |
1107 | (u_int) bus_space_read_1(st, sh, STE_MultipleColFrames) + | 1109 | (u_int) bus_space_read_1(st, sh, STE_MultipleColFrames) + | |
1108 | (u_int) bus_space_read_1(st, sh, STE_SingleColFrames); | 1110 | (u_int) bus_space_read_1(st, sh, STE_SingleColFrames)); | |
1109 | 1111 | |||
1110 | (void) bus_space_read_1(st, sh, STE_FramesWDeferredXmt); | 1112 | (void) bus_space_read_1(st, sh, STE_FramesWDeferredXmt); | |
1111 | 1113 | |||
1112 | ifp->if_ierrors += | 1114 | if_statadd_ref(nsr, if_ierrors, | |
1113 | (u_int) bus_space_read_1(st, sh, STE_FramesLostRxErrors); | 1115 | (u_int) bus_space_read_1(st, sh, STE_FramesLostRxErrors)); | |
1114 | 1116 | |||
1115 | ifp->if_oerrors += | 1117 | if_statadd_ref(nsr, if_oerrors, | |
1116 | (u_int) bus_space_read_1(st, sh, STE_FramesWExDeferral) + | 1118 | (u_int) bus_space_read_1(st, sh, STE_FramesWExDeferral) + | |
1117 | (u_int) bus_space_read_1(st, sh, STE_FramesXbortXSColls) + | 1119 | (u_int) bus_space_read_1(st, sh, STE_FramesXbortXSColls) + | |
1118 | bus_space_read_1(st, sh, STE_CarrierSenseErrors); | 1120 | bus_space_read_1(st, sh, STE_CarrierSenseErrors)); | |
1121 | ||||
1122 | IF_STAT_PUTREF(ifp); | |||
1119 | 1123 | |||
1120 | (void) bus_space_read_1(st, sh, STE_BcstFramesXmtdOk); | 1124 | (void) bus_space_read_1(st, sh, STE_BcstFramesXmtdOk); | |
1121 | (void) bus_space_read_1(st, sh, STE_BcstFramesRcvdOk); | 1125 | (void) bus_space_read_1(st, sh, STE_BcstFramesRcvdOk); | |
1122 | (void) bus_space_read_1(st, sh, STE_McstFramesXmtdOk); | 1126 | (void) bus_space_read_1(st, sh, STE_McstFramesXmtdOk); | |
1123 | (void) bus_space_read_1(st, sh, STE_McstFramesRcvdOk); | 1127 | (void) bus_space_read_1(st, sh, STE_McstFramesRcvdOk); | |
1124 | } | 1128 | } | |
1125 | 1129 | |||
1126 | /* | 1130 | /* | |
1127 | * ste_reset: | 1131 | * ste_reset: | |
1128 | * | 1132 | * | |
1129 | * Perform a soft reset on the ST-201. | 1133 | * Perform a soft reset on the ST-201. | |
1130 | */ | 1134 | */ | |
1131 | static void | 1135 | static void |
--- src/sys/dev/pci/if_stge.c 2020/01/14 09:49:26 1.77
+++ src/sys/dev/pci/if_stge.c 2020/01/30 05:24:53 1.78
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_stge.c,v 1.77 2020/01/14 09:49:26 msaitoh Exp $ */ | 1 | /* $NetBSD: if_stge.c,v 1.78 2020/01/30 05:24:53 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * Device driver for the Sundance Tech. TC9021 10/100/1000 | 33 | * Device driver for the Sundance Tech. TC9021 10/100/1000 | |
34 | * Ethernet controller. | 34 | * Ethernet controller. | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: if_stge.c,v 1.77 2020/01/14 09:49:26 msaitoh Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: if_stge.c,v 1.78 2020/01/30 05:24:53 thorpej Exp $"); | |
39 | 39 | |||
40 | 40 | |||
41 | #include <sys/param.h> | 41 | #include <sys/param.h> | |
42 | #include <sys/systm.h> | 42 | #include <sys/systm.h> | |
43 | #include <sys/callout.h> | 43 | #include <sys/callout.h> | |
44 | #include <sys/mbuf.h> | 44 | #include <sys/mbuf.h> | |
45 | #include <sys/malloc.h> | 45 | #include <sys/malloc.h> | |
46 | #include <sys/kernel.h> | 46 | #include <sys/kernel.h> | |
47 | #include <sys/socket.h> | 47 | #include <sys/socket.h> | |
48 | #include <sys/ioctl.h> | 48 | #include <sys/ioctl.h> | |
49 | #include <sys/errno.h> | 49 | #include <sys/errno.h> | |
50 | #include <sys/device.h> | 50 | #include <sys/device.h> | |
51 | #include <sys/queue.h> | 51 | #include <sys/queue.h> | |
@@ -1018,27 +1018,27 @@ stge_start(struct ifnet *ifp) | @@ -1018,27 +1018,27 @@ stge_start(struct ifnet *ifp) | |||
1018 | * Watchdog timer handler. | 1018 | * Watchdog timer handler. | |
1019 | */ | 1019 | */ | |
1020 | static void | 1020 | static void | |
1021 | stge_watchdog(struct ifnet *ifp) | 1021 | stge_watchdog(struct ifnet *ifp) | |
1022 | { | 1022 | { | |
1023 | struct stge_softc *sc = ifp->if_softc; | 1023 | struct stge_softc *sc = ifp->if_softc; | |
1024 | 1024 | |||
1025 | /* | 1025 | /* | |
1026 | * Sweep up first, since we don't interrupt every frame. | 1026 | * Sweep up first, since we don't interrupt every frame. | |
1027 | */ | 1027 | */ | |
1028 | stge_txintr(sc); | 1028 | stge_txintr(sc); | |
1029 | if (sc->sc_txpending != 0) { | 1029 | if (sc->sc_txpending != 0) { | |
1030 | printf("%s: device timeout\n", device_xname(sc->sc_dev)); | 1030 | printf("%s: device timeout\n", device_xname(sc->sc_dev)); | |
1031 | ifp->if_oerrors++; | 1031 | if_statinc(ifp, if_oerrors); | |
1032 | 1032 | |||
1033 | (void) stge_init(ifp); | 1033 | (void) stge_init(ifp); | |
1034 | 1034 | |||
1035 | /* Try to get more packets going. */ | 1035 | /* Try to get more packets going. */ | |
1036 | stge_start(ifp); | 1036 | stge_start(ifp); | |
1037 | } | 1037 | } | |
1038 | } | 1038 | } | |
1039 | 1039 | |||
1040 | /* | 1040 | /* | |
1041 | * stge_ioctl: [ifnet interface function] | 1041 | * stge_ioctl: [ifnet interface function] | |
1042 | * | 1042 | * | |
1043 | * Handle control requests from the operator. | 1043 | * Handle control requests from the operator. | |
1044 | */ | 1044 | */ | |
@@ -1251,27 +1251,27 @@ stge_rxintr(struct stge_softc *sc) | @@ -1251,27 +1251,27 @@ stge_rxintr(struct stge_softc *sc) | |||
1251 | bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0, | 1251 | bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0, | |
1252 | ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); | 1252 | ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); | |
1253 | 1253 | |||
1254 | m = ds->ds_mbuf; | 1254 | m = ds->ds_mbuf; | |
1255 | 1255 | |||
1256 | /* | 1256 | /* | |
1257 | * Add a new receive buffer to the ring. | 1257 | * Add a new receive buffer to the ring. | |
1258 | */ | 1258 | */ | |
1259 | if (stge_add_rxbuf(sc, i) != 0) { | 1259 | if (stge_add_rxbuf(sc, i) != 0) { | |
1260 | /* | 1260 | /* | |
1261 | * Failed, throw away what we've done so | 1261 | * Failed, throw away what we've done so | |
1262 | * far, and discard the rest of the packet. | 1262 | * far, and discard the rest of the packet. | |
1263 | */ | 1263 | */ | |
1264 | ifp->if_ierrors++; | 1264 | if_statinc(ifp, if_ierrors); | |
1265 | bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0, | 1265 | bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0, | |
1266 | ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); | 1266 | ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); | |
1267 | STGE_INIT_RXDESC(sc, i); | 1267 | STGE_INIT_RXDESC(sc, i); | |
1268 | if ((status & RFD_FrameEnd) == 0) | 1268 | if ((status & RFD_FrameEnd) == 0) | |
1269 | sc->sc_rxdiscard = 1; | 1269 | sc->sc_rxdiscard = 1; | |
1270 | if (sc->sc_rxhead != NULL) | 1270 | if (sc->sc_rxhead != NULL) | |
1271 | m_freem(sc->sc_rxhead); | 1271 | m_freem(sc->sc_rxhead); | |
1272 | STGE_RXCHAIN_RESET(sc); | 1272 | STGE_RXCHAIN_RESET(sc); | |
1273 | continue; | 1273 | continue; | |
1274 | } | 1274 | } | |
1275 | 1275 | |||
1276 | #ifdef DIAGNOSTIC | 1276 | #ifdef DIAGNOSTIC | |
1277 | if (status & RFD_FrameStart) { | 1277 | if (status & RFD_FrameStart) { | |
@@ -1321,27 +1321,27 @@ stge_rxintr(struct stge_softc *sc) | @@ -1321,27 +1321,27 @@ stge_rxintr(struct stge_softc *sc) | |||
1321 | tailm->m_len = len - sc->sc_rxlen; | 1321 | tailm->m_len = len - sc->sc_rxlen; | |
1322 | 1322 | |||
1323 | /* | 1323 | /* | |
1324 | * If the packet is small enough to fit in a | 1324 | * If the packet is small enough to fit in a | |
1325 | * single header mbuf, allocate one and copy | 1325 | * single header mbuf, allocate one and copy | |
1326 | * the data into it. This greatly reduces | 1326 | * the data into it. This greatly reduces | |
1327 | * memory consumption when we receive lots | 1327 | * memory consumption when we receive lots | |
1328 | * of small packets. | 1328 | * of small packets. | |
1329 | */ | 1329 | */ | |
1330 | if (stge_copy_small != 0 && len <= (MHLEN - 2)) { | 1330 | if (stge_copy_small != 0 && len <= (MHLEN - 2)) { | |
1331 | struct mbuf *nm; | 1331 | struct mbuf *nm; | |
1332 | MGETHDR(nm, M_DONTWAIT, MT_DATA); | 1332 | MGETHDR(nm, M_DONTWAIT, MT_DATA); | |
1333 | if (nm == NULL) { | 1333 | if (nm == NULL) { | |
1334 | ifp->if_ierrors++; | 1334 | if_statinc(ifp, if_ierrors); | |
1335 | m_freem(m); | 1335 | m_freem(m); | |
1336 | continue; | 1336 | continue; | |
1337 | } | 1337 | } | |
1338 | nm->m_data += 2; | 1338 | nm->m_data += 2; | |
1339 | nm->m_pkthdr.len = nm->m_len = len; | 1339 | nm->m_pkthdr.len = nm->m_len = len; | |
1340 | m_copydata(m, 0, len, mtod(nm, void *)); | 1340 | m_copydata(m, 0, len, mtod(nm, void *)); | |
1341 | m_freem(m); | 1341 | m_freem(m); | |
1342 | m = nm; | 1342 | m = nm; | |
1343 | } | 1343 | } | |
1344 | 1344 | |||
1345 | /* | 1345 | /* | |
1346 | * Set the incoming checksum information for the packet. | 1346 | * Set the incoming checksum information for the packet. | |
1347 | */ | 1347 | */ | |
@@ -1423,42 +1423,46 @@ stge_tick(void *arg) | @@ -1423,42 +1423,46 @@ stge_tick(void *arg) | |||
1423 | * stge_stats_update: | 1423 | * stge_stats_update: | |
1424 | * | 1424 | * | |
1425 | * Read the TC9021 statistics counters. | 1425 | * Read the TC9021 statistics counters. | |
1426 | */ | 1426 | */ | |
1427 | static void | 1427 | static void | |
1428 | stge_stats_update(struct stge_softc *sc) | 1428 | stge_stats_update(struct stge_softc *sc) | |
1429 | { | 1429 | { | |
1430 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | 1430 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | |
1431 | 1431 | |||
1432 | (void) CSR_READ_4(sc, STGE_OctetRcvOk); | 1432 | (void) CSR_READ_4(sc, STGE_OctetRcvOk); | |
1433 | 1433 | |||
1434 | (void) CSR_READ_4(sc, STGE_FramesRcvdOk); | 1434 | (void) CSR_READ_4(sc, STGE_FramesRcvdOk); | |
1435 | 1435 | |||
1436 | ifp->if_ierrors += | 1436 | net_stat_ref_t nsr = IF_STAT_GETREF(ifp); | |
1437 | (u_int) CSR_READ_2(sc, STGE_FramesLostRxErrors); | 1437 | ||
1438 | if_statadd_ref(nsr, if_ierrors, | |||
1439 | (u_int) CSR_READ_2(sc, STGE_FramesLostRxErrors)); | |||
1438 | 1440 | |||
1439 | (void) CSR_READ_4(sc, STGE_OctetXmtdOk); | 1441 | (void) CSR_READ_4(sc, STGE_OctetXmtdOk); | |
1440 | 1442 | |||
1441 | ifp->if_opackets += | 1443 | if_statadd_ref(nsr, if_opackets, | |
1442 | CSR_READ_4(sc, STGE_FramesXmtdOk); | 1444 | CSR_READ_4(sc, STGE_FramesXmtdOk)); | |
1443 | 1445 | |||
1444 | ifp->if_collisions += | 1446 | if_statadd_ref(nsr, if_collisions, | |
1445 | CSR_READ_4(sc, STGE_LateCollisions) + | 1447 | CSR_READ_4(sc, STGE_LateCollisions) + | |
1446 | CSR_READ_4(sc, STGE_MultiColFrames) + | 1448 | CSR_READ_4(sc, STGE_MultiColFrames) + | |
1447 | CSR_READ_4(sc, STGE_SingleColFrames); | 1449 | CSR_READ_4(sc, STGE_SingleColFrames)); | |
1448 | 1450 | |||
1449 | ifp->if_oerrors += | 1451 | if_statadd_ref(nsr, if_oerrors, | |
1450 | (u_int) CSR_READ_2(sc, STGE_FramesAbortXSColls) + | 1452 | (u_int) CSR_READ_2(sc, STGE_FramesAbortXSColls) + | |
1451 | (u_int) CSR_READ_2(sc, STGE_FramesWEXDeferal); | 1453 | (u_int) CSR_READ_2(sc, STGE_FramesWEXDeferal)); | |
1454 | ||||
1455 | IF_STAT_PUTREF(ifp); | |||
1452 | } | 1456 | } | |
1453 | 1457 | |||
1454 | /* | 1458 | /* | |
1455 | * stge_reset: | 1459 | * stge_reset: | |
1456 | * | 1460 | * | |
1457 | * Perform a soft reset on the TC9021. | 1461 | * Perform a soft reset on the TC9021. | |
1458 | */ | 1462 | */ | |
1459 | static void | 1463 | static void | |
1460 | stge_reset(struct stge_softc *sc) | 1464 | stge_reset(struct stge_softc *sc) | |
1461 | { | 1465 | { | |
1462 | uint32_t ac; | 1466 | uint32_t ac; | |
1463 | int i; | 1467 | int i; | |
1464 | 1468 |
--- src/sys/dev/pci/if_tl.c 2019/12/22 23:23:32 1.118
+++ src/sys/dev/pci/if_tl.c 2020/01/30 05:24:53 1.119
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_tl.c,v 1.118 2019/12/22 23:23:32 thorpej Exp $ */ | 1 | /* $NetBSD: if_tl.c,v 1.119 2020/01/30 05:24:53 thorpej Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1997 Manuel Bouyer. All rights reserved. | 4 | * Copyright (c) 1997 Manuel Bouyer. All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
@@ -21,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 | */ | 25 | */ | |
26 | 26 | |||
27 | /* | 27 | /* | |
28 | * Texas Instruments ThunderLAN ethernet controller | 28 | * Texas Instruments ThunderLAN ethernet controller | |
29 | * ThunderLAN Programmer's Guide (TI Literature Number SPWU013A) | 29 | * ThunderLAN Programmer's Guide (TI Literature Number SPWU013A) | |
30 | * available from www.ti.com | 30 | * available from www.ti.com | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | __KERNEL_RCSID(0, "$NetBSD: if_tl.c,v 1.118 2019/12/22 23:23:32 thorpej Exp $"); | 34 | __KERNEL_RCSID(0, "$NetBSD: if_tl.c,v 1.119 2020/01/30 05:24:53 thorpej Exp $"); | |
35 | 35 | |||
36 | #undef TLDEBUG | 36 | #undef TLDEBUG | |
37 | #define TL_PRIV_STATS | 37 | #define TL_PRIV_STATS | |
38 | #undef TLDEBUG_RX | 38 | #undef TLDEBUG_RX | |
39 | #undef TLDEBUG_TX | 39 | #undef TLDEBUG_TX | |
40 | #undef TLDEBUG_ADDR | 40 | #undef TLDEBUG_ADDR | |
41 | 41 | |||
42 | #include "opt_inet.h" | 42 | #include "opt_inet.h" | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <sys/systm.h> | 45 | #include <sys/systm.h> | |
46 | #include <sys/mbuf.h> | 46 | #include <sys/mbuf.h> | |
47 | #include <sys/protosw.h> | 47 | #include <sys/protosw.h> | |
@@ -1399,27 +1399,27 @@ bad: | @@ -1399,27 +1399,27 @@ bad: | |||
1399 | #endif | 1399 | #endif | |
1400 | Tx->next = sc->Free_Tx; | 1400 | Tx->next = sc->Free_Tx; | |
1401 | sc->Free_Tx = Tx; | 1401 | sc->Free_Tx = Tx; | |
1402 | } | 1402 | } | |
1403 | 1403 | |||
1404 | static void | 1404 | static void | |
1405 | tl_ifwatchdog(struct ifnet *ifp) | 1405 | tl_ifwatchdog(struct ifnet *ifp) | |
1406 | { | 1406 | { | |
1407 | tl_softc_t *sc = ifp->if_softc; | 1407 | tl_softc_t *sc = ifp->if_softc; | |
1408 | 1408 | |||
1409 | if ((ifp->if_flags & IFF_RUNNING) == 0) | 1409 | if ((ifp->if_flags & IFF_RUNNING) == 0) | |
1410 | return; | 1410 | return; | |
1411 | printf("%s: device timeout\n", device_xname(sc->sc_dev)); | 1411 | printf("%s: device timeout\n", device_xname(sc->sc_dev)); | |
1412 | ifp->if_oerrors++; | 1412 | if_statinc(ifp, if_oerrors); | |
1413 | tl_init(ifp); | 1413 | tl_init(ifp); | |
1414 | } | 1414 | } | |
1415 | 1415 | |||
1416 | static int | 1416 | static int | |
1417 | tl_mediachange(struct ifnet *ifp) | 1417 | tl_mediachange(struct ifnet *ifp) | |
1418 | { | 1418 | { | |
1419 | 1419 | |||
1420 | if (ifp->if_flags & IFF_UP) | 1420 | if (ifp->if_flags & IFF_UP) | |
1421 | tl_init(ifp); | 1421 | tl_init(ifp); | |
1422 | return 0; | 1422 | return 0; | |
1423 | } | 1423 | } | |
1424 | 1424 | |||
1425 | static int | 1425 | static int | |
@@ -1494,52 +1494,54 @@ tl_read_stats(tl_softc_t *sc) | @@ -1494,52 +1494,54 @@ tl_read_stats(tl_softc_t *sc) | |||
1494 | uint32_t reg; | 1494 | uint32_t reg; | |
1495 | int ierr_overr; | 1495 | int ierr_overr; | |
1496 | int ierr_code; | 1496 | int ierr_code; | |
1497 | int ierr_crc; | 1497 | int ierr_crc; | |
1498 | int oerr_underr; | 1498 | int oerr_underr; | |
1499 | int oerr_deferred; | 1499 | int oerr_deferred; | |
1500 | int oerr_coll; | 1500 | int oerr_coll; | |
1501 | int oerr_multicoll; | 1501 | int oerr_multicoll; | |
1502 | int oerr_exesscoll; | 1502 | int oerr_exesscoll; | |
1503 | int oerr_latecoll; | 1503 | int oerr_latecoll; | |
1504 | int oerr_carrloss; | 1504 | int oerr_carrloss; | |
1505 | struct ifnet *ifp = &sc->tl_if; | 1505 | struct ifnet *ifp = &sc->tl_if; | |
1506 | 1506 | |||
1507 | net_stat_ref_t nsr = IF_STAT_GETREF(ifp); | |||
1508 | ||||
1507 | reg = tl_intreg_read(sc, TL_INT_STATS_TX); | 1509 | reg = tl_intreg_read(sc, TL_INT_STATS_TX); | |
1508 | ifp->if_opackets += reg & 0x00ffffff; | 1510 | if_statadd_ref(nsr, if_opackets, reg & 0x00ffffff); | |
1509 | oerr_underr = reg >> 24; | 1511 | oerr_underr = reg >> 24; | |
1510 | 1512 | |||
1511 | reg = tl_intreg_read(sc, TL_INT_STATS_RX); | 1513 | reg = tl_intreg_read(sc, TL_INT_STATS_RX); | |
1512 | ierr_overr = reg >> 24; | 1514 | ierr_overr = reg >> 24; | |
1513 | 1515 | |||
1514 | reg = tl_intreg_read(sc, TL_INT_STATS_FERR); | 1516 | reg = tl_intreg_read(sc, TL_INT_STATS_FERR); | |
1515 | ierr_crc = (reg & TL_FERR_CRC) >> 16; | 1517 | ierr_crc = (reg & TL_FERR_CRC) >> 16; | |
1516 | ierr_code = (reg & TL_FERR_CODE) >> 24; | 1518 | ierr_code = (reg & TL_FERR_CODE) >> 24; | |
1517 | oerr_deferred = (reg & TL_FERR_DEF); | 1519 | oerr_deferred = (reg & TL_FERR_DEF); | |
1518 | 1520 | |||
1519 | reg = tl_intreg_read(sc, TL_INT_STATS_COLL); | 1521 | reg = tl_intreg_read(sc, TL_INT_STATS_COLL); | |
1520 | oerr_multicoll = (reg & TL_COL_MULTI); | 1522 | oerr_multicoll = (reg & TL_COL_MULTI); | |
1521 | oerr_coll = (reg & TL_COL_SINGLE) >> 16; | 1523 | oerr_coll = (reg & TL_COL_SINGLE) >> 16; | |
1522 | 1524 | |||
1523 | reg = tl_intreg_read(sc, TL_INT_LERR); | 1525 | reg = tl_intreg_read(sc, TL_INT_LERR); | |
1524 | oerr_exesscoll = (reg & TL_LERR_ECOLL); | 1526 | oerr_exesscoll = (reg & TL_LERR_ECOLL); | |
1525 | oerr_latecoll = (reg & TL_LERR_LCOLL) >> 8; | 1527 | oerr_latecoll = (reg & TL_LERR_LCOLL) >> 8; | |
1526 | oerr_carrloss = (reg & TL_LERR_CL) >> 16; | 1528 | oerr_carrloss = (reg & TL_LERR_CL) >> 16; | |
1527 | 1529 | |||
1528 | 1530 | if_statadd_ref(nsr, if_oerrors, | ||
1529 | ifp->if_oerrors += oerr_underr + oerr_exesscoll + oerr_latecoll + | 1531 | oerr_underr + oerr_exesscoll + oerr_latecoll + oerr_carrloss); | |
1530 | oerr_carrloss; | 1532 | if_statadd_ref(nsr, if_collisions, oerr_coll + oerr_multicoll); | |
1531 | ifp->if_collisions += oerr_coll + oerr_multicoll; | 1533 | if_statadd_ref(nsr, if_ierrors, ierr_overr + ierr_code + ierr_crc); | |
1532 | ifp->if_ierrors += ierr_overr + ierr_code + ierr_crc; | 1534 | IF_STAT_PUTREF(ifp); | |
1533 | 1535 | |||
1534 | if (ierr_overr) | 1536 | if (ierr_overr) | |
1535 | printf("%s: receiver ring buffer overrun\n", | 1537 | printf("%s: receiver ring buffer overrun\n", | |
1536 | device_xname(sc->sc_dev)); | 1538 | device_xname(sc->sc_dev)); | |
1537 | if (oerr_underr) | 1539 | if (oerr_underr) | |
1538 | printf("%s: transmit buffer underrun\n", | 1540 | printf("%s: transmit buffer underrun\n", | |
1539 | device_xname(sc->sc_dev)); | 1541 | device_xname(sc->sc_dev)); | |
1540 | #ifdef TL_PRIV_STATS | 1542 | #ifdef TL_PRIV_STATS | |
1541 | sc->ierr_overr += ierr_overr; | 1543 | sc->ierr_overr += ierr_overr; | |
1542 | sc->ierr_code += ierr_code; | 1544 | sc->ierr_code += ierr_code; | |
1543 | sc->ierr_crc += ierr_crc; | 1545 | sc->ierr_crc += ierr_crc; | |
1544 | sc->oerr_underr += oerr_underr; | 1546 | sc->oerr_underr += oerr_underr; | |
1545 | sc->oerr_deferred += oerr_deferred; | 1547 | sc->oerr_deferred += oerr_deferred; |
--- src/sys/dev/pci/if_vge.c 2019/12/27 07:41:23 1.78
+++ src/sys/dev/pci/if_vge.c 2020/01/30 05:24:53 1.79
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_vge.c,v 1.78 2019/12/27 07:41:23 msaitoh Exp $ */ | 1 | /* $NetBSD: if_vge.c,v 1.79 2020/01/30 05:24:53 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2004 | 4 | * Copyright (c) 2004 | |
5 | * Bill Paul <wpaul@windriver.com>. All rights reserved. | 5 | * Bill Paul <wpaul@windriver.com>. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD | |
26 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 26 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
32 | * THE POSSIBILITY OF SUCH DAMAGE. | 32 | * THE POSSIBILITY OF SUCH DAMAGE. | |
33 | * | 33 | * | |
34 | * FreeBSD: src/sys/dev/vge/if_vge.c,v 1.5 2005/02/07 19:39:29 glebius Exp | 34 | * FreeBSD: src/sys/dev/vge/if_vge.c,v 1.5 2005/02/07 19:39:29 glebius Exp | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.78 2019/12/27 07:41:23 msaitoh Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.79 2020/01/30 05:24:53 thorpej Exp $"); | |
39 | 39 | |||
40 | /* | 40 | /* | |
41 | * VIA Networking Technologies VT612x PCI gigabit ethernet NIC driver. | 41 | * VIA Networking Technologies VT612x PCI gigabit ethernet NIC driver. | |
42 | * | 42 | * | |
43 | * Written by Bill Paul <wpaul@windriver.com> | 43 | * Written by Bill Paul <wpaul@windriver.com> | |
44 | * Senior Networking Software Engineer | 44 | * Senior Networking Software Engineer | |
45 | * Wind River Systems | 45 | * Wind River Systems | |
46 | */ | 46 | */ | |
47 | 47 | |||
48 | /* | 48 | /* | |
49 | * The VIA Networking VT6122 is a 32bit, 33/66 MHz PCI device that | 49 | * The VIA Networking VT6122 is a 32bit, 33/66 MHz PCI device that | |
50 | * combines a tri-speed ethernet MAC and PHY, with the following | 50 | * combines a tri-speed ethernet MAC and PHY, with the following | |
51 | * features: | 51 | * features: | |
@@ -1221,46 +1221,46 @@ vge_rxeof(struct vge_softc *sc) | @@ -1221,46 +1221,46 @@ vge_rxeof(struct vge_softc *sc) | |||
1221 | 1221 | |||
1222 | /* | 1222 | /* | |
1223 | * Bad/error frames will have the RXOK bit cleared. | 1223 | * Bad/error frames will have the RXOK bit cleared. | |
1224 | * However, there's one error case we want to allow: | 1224 | * However, there's one error case we want to allow: | |
1225 | * if a VLAN tagged frame arrives and the chip can't | 1225 | * if a VLAN tagged frame arrives and the chip can't | |
1226 | * match it against the CAM filter, it considers this | 1226 | * match it against the CAM filter, it considers this | |
1227 | * a 'VLAN CAM filter miss' and clears the 'RXOK' bit. | 1227 | * a 'VLAN CAM filter miss' and clears the 'RXOK' bit. | |
1228 | * We don't want to drop the frame though: our VLAN | 1228 | * We don't want to drop the frame though: our VLAN | |
1229 | * filtering is done in software. | 1229 | * filtering is done in software. | |
1230 | */ | 1230 | */ | |
1231 | if ((rxstat & VGE_RDSTS_RXOK) == 0 && | 1231 | if ((rxstat & VGE_RDSTS_RXOK) == 0 && | |
1232 | (rxstat & VGE_RDSTS_VIDM) == 0 && | 1232 | (rxstat & VGE_RDSTS_VIDM) == 0 && | |
1233 | (rxstat & VGE_RDSTS_CSUMERR) == 0) { | 1233 | (rxstat & VGE_RDSTS_CSUMERR) == 0) { | |
1234 | ifp->if_ierrors++; | 1234 | if_statinc(ifp, if_ierrors); | |
1235 | /* | 1235 | /* | |
1236 | * If this is part of a multi-fragment packet, | 1236 | * If this is part of a multi-fragment packet, | |
1237 | * discard all the pieces. | 1237 | * discard all the pieces. | |
1238 | */ | 1238 | */ | |
1239 | if (sc->sc_rx_mhead != NULL) { | 1239 | if (sc->sc_rx_mhead != NULL) { | |
1240 | m_freem(sc->sc_rx_mhead); | 1240 | m_freem(sc->sc_rx_mhead); | |
1241 | sc->sc_rx_mhead = sc->sc_rx_mtail = NULL; | 1241 | sc->sc_rx_mhead = sc->sc_rx_mtail = NULL; | |
1242 | } | 1242 | } | |
1243 | vge_newbuf(sc, idx, m); | 1243 | vge_newbuf(sc, idx, m); | |
1244 | continue; | 1244 | continue; | |
1245 | } | 1245 | } | |
1246 | 1246 | |||
1247 | /* | 1247 | /* | |
1248 | * If allocating a replacement mbuf fails, | 1248 | * If allocating a replacement mbuf fails, | |
1249 | * reload the current one. | 1249 | * reload the current one. | |
1250 | */ | 1250 | */ | |
1251 | 1251 | |||
1252 | if (vge_newbuf(sc, idx, NULL)) { | 1252 | if (vge_newbuf(sc, idx, NULL)) { | |
1253 | ifp->if_ierrors++; | 1253 | if_statinc(ifp, if_ierrors); | |
1254 | if (sc->sc_rx_mhead != NULL) { | 1254 | if (sc->sc_rx_mhead != NULL) { | |
1255 | m_freem(sc->sc_rx_mhead); | 1255 | m_freem(sc->sc_rx_mhead); | |
1256 | sc->sc_rx_mhead = sc->sc_rx_mtail = NULL; | 1256 | sc->sc_rx_mhead = sc->sc_rx_mtail = NULL; | |
1257 | } | 1257 | } | |
1258 | vge_newbuf(sc, idx, m); | 1258 | vge_newbuf(sc, idx, m); | |
1259 | continue; | 1259 | continue; | |
1260 | } | 1260 | } | |
1261 | 1261 | |||
1262 | if (sc->sc_rx_mhead != NULL) { | 1262 | if (sc->sc_rx_mhead != NULL) { | |
1263 | m->m_len = total_len % VGE_RX_BUFSIZE; | 1263 | m->m_len = total_len % VGE_RX_BUFSIZE; | |
1264 | /* | 1264 | /* | |
1265 | * Special case: if there's 4 bytes or less | 1265 | * Special case: if there's 4 bytes or less | |
1266 | * in this buffer, the mbuf can be discarded: | 1266 | * in this buffer, the mbuf can be discarded: | |
@@ -1353,32 +1353,34 @@ vge_txeof(struct vge_softc *sc) | @@ -1353,32 +1353,34 @@ vge_txeof(struct vge_softc *sc) | |||
1353 | BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); | 1353 | BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); | |
1354 | txstat = le32toh(sc->sc_txdescs[idx].td_sts); | 1354 | txstat = le32toh(sc->sc_txdescs[idx].td_sts); | |
1355 | VGE_TXDESCSYNC(sc, idx, BUS_DMASYNC_PREREAD); | 1355 | VGE_TXDESCSYNC(sc, idx, BUS_DMASYNC_PREREAD); | |
1356 | if (txstat & VGE_TDSTS_OWN) { | 1356 | if (txstat & VGE_TDSTS_OWN) { | |
1357 | break; | 1357 | break; | |
1358 | } | 1358 | } | |
1359 | 1359 | |||
1360 | txs = &sc->sc_txsoft[idx]; | 1360 | txs = &sc->sc_txsoft[idx]; | |
1361 | m_freem(txs->txs_mbuf); | 1361 | m_freem(txs->txs_mbuf); | |
1362 | txs->txs_mbuf = NULL; | 1362 | txs->txs_mbuf = NULL; | |
1363 | bus_dmamap_sync(sc->sc_dmat, txs->txs_dmamap, 0, | 1363 | bus_dmamap_sync(sc->sc_dmat, txs->txs_dmamap, 0, | |
1364 | txs->txs_dmamap->dm_mapsize, BUS_DMASYNC_POSTWRITE); | 1364 | txs->txs_dmamap->dm_mapsize, BUS_DMASYNC_POSTWRITE); | |
1365 | bus_dmamap_unload(sc->sc_dmat, txs->txs_dmamap); | 1365 | bus_dmamap_unload(sc->sc_dmat, txs->txs_dmamap); | |
1366 | net_stat_ref_t nsr = IF_STAT_GETREF(ifp); | |||
1366 | if (txstat & (VGE_TDSTS_EXCESSCOLL | VGE_TDSTS_COLL)) | 1367 | if (txstat & (VGE_TDSTS_EXCESSCOLL | VGE_TDSTS_COLL)) | |
1367 | ifp->if_collisions++; | 1368 | if_statinc_ref(nsr, if_collisions); | |
1368 | if (txstat & VGE_TDSTS_TXERR) | 1369 | if (txstat & VGE_TDSTS_TXERR) | |
1369 | ifp->if_oerrors++; | 1370 | if_statinc_ref(nsr, if_oerrors); | |
1370 | else | 1371 | else | |
1371 | ifp->if_opackets++; | 1372 | if_statinc_ref(nsr, if_opackets); | |
1373 | IF_STAT_PUTREF(ifp); | |||
1372 | } | 1374 | } | |
1373 | 1375 | |||
1374 | sc->sc_tx_considx = idx; | 1376 | sc->sc_tx_considx = idx; | |
1375 | 1377 | |||
1376 | if (sc->sc_tx_free > 0) { | 1378 | if (sc->sc_tx_free > 0) { | |
1377 | ifp->if_flags &= ~IFF_OACTIVE; | 1379 | ifp->if_flags &= ~IFF_OACTIVE; | |
1378 | } | 1380 | } | |
1379 | 1381 | |||
1380 | /* | 1382 | /* | |
1381 | * If not all descriptors have been released reaped yet, | 1383 | * If not all descriptors have been released reaped yet, | |
1382 | * reload the timer so that we will eventually get another | 1384 | * reload the timer so that we will eventually get another | |
1383 | * interrupt that will cause us to re-enter this routine. | 1385 | * interrupt that will cause us to re-enter this routine. | |
1384 | * This is done in case the transmitter has gone idle. | 1386 | * This is done in case the transmitter has gone idle. | |
@@ -2009,27 +2011,27 @@ vge_ioctl(struct ifnet *ifp, u_long comm | @@ -2009,27 +2011,27 @@ vge_ioctl(struct ifnet *ifp, u_long comm | |||
2009 | splx(s); | 2011 | splx(s); | |
2010 | return error; | 2012 | return error; | |
2011 | } | 2013 | } | |
2012 | 2014 | |||
2013 | static void | 2015 | static void | |
2014 | vge_watchdog(struct ifnet *ifp) | 2016 | vge_watchdog(struct ifnet *ifp) | |
2015 | { | 2017 | { | |
2016 | struct vge_softc *sc; | 2018 | struct vge_softc *sc; | |
2017 | int s; | 2019 | int s; | |
2018 | 2020 | |||
2019 | sc = ifp->if_softc; | 2021 | sc = ifp->if_softc; | |
2020 | s = splnet(); | 2022 | s = splnet(); | |
2021 | printf("%s: watchdog timeout\n", device_xname(sc->sc_dev)); | 2023 | printf("%s: watchdog timeout\n", device_xname(sc->sc_dev)); | |
2022 | ifp->if_oerrors++; | 2024 | if_statinc(ifp, if_oerrors); | |
2023 | 2025 | |||
2024 | vge_txeof(sc); | 2026 | vge_txeof(sc); | |
2025 | vge_rxeof(sc); | 2027 | vge_rxeof(sc); | |
2026 | 2028 | |||
2027 | vge_init(ifp); | 2029 | vge_init(ifp); | |
2028 | 2030 | |||
2029 | splx(s); | 2031 | splx(s); | |
2030 | } | 2032 | } | |
2031 | 2033 | |||
2032 | /* | 2034 | /* | |
2033 | * Stop the adapter and free any mbufs allocated to the | 2035 | * Stop the adapter and free any mbufs allocated to the | |
2034 | * RX and TX lists. | 2036 | * RX and TX lists. | |
2035 | */ | 2037 | */ |
--- src/sys/dev/pci/if_vr.c 2019/09/13 07:55:07 1.131
+++ src/sys/dev/pci/if_vr.c 2020/01/30 05:24:53 1.132
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_vr.c,v 1.131 2019/09/13 07:55:07 msaitoh Exp $ */ | 1 | /* $NetBSD: if_vr.c,v 1.132 2020/01/30 05:24:53 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center. | 9 | * NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -87,27 +87,27 @@ | @@ -87,27 +87,27 @@ | |||
87 | * The Rhine has a serious flaw in its transmit DMA mechanism: | 87 | * The Rhine has a serious flaw in its transmit DMA mechanism: | |
88 | * transmit buffers must be longword aligned. Unfortunately, | 88 | * transmit buffers must be longword aligned. Unfortunately, | |
89 | * the kernel doesn't guarantee that mbufs will be filled in starting | 89 | * the kernel doesn't guarantee that mbufs will be filled in starting | |
90 | * at longword boundaries, so we have to do a buffer copy before | 90 | * at longword boundaries, so we have to do a buffer copy before | |
91 | * transmission. | 91 | * transmission. | |
92 | * | 92 | * | |
93 | * Apparently, the receive DMA mechanism also has the same flaw. This | 93 | * Apparently, the receive DMA mechanism also has the same flaw. This | |
94 | * means that on systems with struct alignment requirements, incoming | 94 | * means that on systems with struct alignment requirements, incoming | |
95 | * frames must be copied to a new buffer which shifts the data forward | 95 | * frames must be copied to a new buffer which shifts the data forward | |
96 | * 2 bytes so that the payload is aligned on a 4-byte boundary. | 96 | * 2 bytes so that the payload is aligned on a 4-byte boundary. | |
97 | */ | 97 | */ | |
98 | 98 | |||
99 | #include <sys/cdefs.h> | 99 | #include <sys/cdefs.h> | |
100 | __KERNEL_RCSID(0, "$NetBSD: if_vr.c,v 1.131 2019/09/13 07:55:07 msaitoh Exp $"); | 100 | __KERNEL_RCSID(0, "$NetBSD: if_vr.c,v 1.132 2020/01/30 05:24:53 thorpej Exp $"); | |
101 | 101 | |||
102 | 102 | |||
103 | 103 | |||
104 | #include <sys/param.h> | 104 | #include <sys/param.h> | |
105 | #include <sys/systm.h> | 105 | #include <sys/systm.h> | |
106 | #include <sys/callout.h> | 106 | #include <sys/callout.h> | |
107 | #include <sys/sockio.h> | 107 | #include <sys/sockio.h> | |
108 | #include <sys/mbuf.h> | 108 | #include <sys/mbuf.h> | |
109 | #include <sys/malloc.h> | 109 | #include <sys/malloc.h> | |
110 | #include <sys/kernel.h> | 110 | #include <sys/kernel.h> | |
111 | #include <sys/socket.h> | 111 | #include <sys/socket.h> | |
112 | #include <sys/device.h> | 112 | #include <sys/device.h> | |
113 | 113 | |||
@@ -615,27 +615,27 @@ vr_rxeof(struct vr_softc *sc) | @@ -615,27 +615,27 @@ vr_rxeof(struct vr_softc *sc) | |||
615 | */ | 615 | */ | |
616 | break; | 616 | break; | |
617 | } | 617 | } | |
618 | 618 | |||
619 | /* | 619 | /* | |
620 | * If an error occurs, update stats, clear the | 620 | * If an error occurs, update stats, clear the | |
621 | * status word and leave the mbuf cluster in place: | 621 | * status word and leave the mbuf cluster in place: | |
622 | * it should simply get re-used next time this descriptor | 622 | * it should simply get re-used next time this descriptor | |
623 | * comes up in the ring. | 623 | * comes up in the ring. | |
624 | */ | 624 | */ | |
625 | if (rxstat & VR_RXSTAT_RXERR) { | 625 | if (rxstat & VR_RXSTAT_RXERR) { | |
626 | const char *errstr; | 626 | const char *errstr; | |
627 | 627 | |||
628 | ifp->if_ierrors++; | 628 | if_statinc(ifp, if_ierrors); | |
629 | switch (rxstat & 0x000000FF) { | 629 | switch (rxstat & 0x000000FF) { | |
630 | case VR_RXSTAT_CRCERR: | 630 | case VR_RXSTAT_CRCERR: | |
631 | errstr = "crc error"; | 631 | errstr = "crc error"; | |
632 | break; | 632 | break; | |
633 | case VR_RXSTAT_FRAMEALIGNERR: | 633 | case VR_RXSTAT_FRAMEALIGNERR: | |
634 | errstr = "frame alignment error"; | 634 | errstr = "frame alignment error"; | |
635 | break; | 635 | break; | |
636 | case VR_RXSTAT_FIFOOFLOW: | 636 | case VR_RXSTAT_FIFOOFLOW: | |
637 | errstr = "FIFO overflow"; | 637 | errstr = "FIFO overflow"; | |
638 | break; | 638 | break; | |
639 | case VR_RXSTAT_GIANT: | 639 | case VR_RXSTAT_GIANT: | |
640 | errstr = "received giant packet"; | 640 | errstr = "received giant packet"; | |
641 | break; | 641 | break; | |
@@ -655,51 +655,51 @@ vr_rxeof(struct vr_softc *sc) | @@ -655,51 +655,51 @@ vr_rxeof(struct vr_softc *sc) | |||
655 | aprint_error_dev(sc->vr_dev, "receive error: %s\n", | 655 | aprint_error_dev(sc->vr_dev, "receive error: %s\n", | |
656 | errstr); | 656 | errstr); | |
657 | 657 | |||
658 | VR_INIT_RXDESC(sc, i); | 658 | VR_INIT_RXDESC(sc, i); | |
659 | 659 | |||
660 | continue; | 660 | continue; | |
661 | } else if (!(rxstat & VR_RXSTAT_FIRSTFRAG) || | 661 | } else if (!(rxstat & VR_RXSTAT_FIRSTFRAG) || | |
662 | !(rxstat & VR_RXSTAT_LASTFRAG)) { | 662 | !(rxstat & VR_RXSTAT_LASTFRAG)) { | |
663 | /* | 663 | /* | |
664 | * This driver expects to receive whole packets every | 664 | * This driver expects to receive whole packets every | |
665 | * time. In case we receive a fragment that is not | 665 | * time. In case we receive a fragment that is not | |
666 | * a complete packet, we discard it. | 666 | * a complete packet, we discard it. | |
667 | */ | 667 | */ | |
668 | ifp->if_ierrors++; | 668 | if_statinc(ifp, if_ierrors); | |
669 | 669 | |||
670 | aprint_error_dev(sc->vr_dev, | 670 | aprint_error_dev(sc->vr_dev, | |
671 | "receive error: incomplete frame; " | 671 | "receive error: incomplete frame; " | |
672 | "size = %d, status = 0x%x\n", | 672 | "size = %d, status = 0x%x\n", | |
673 | VR_RXBYTES(le32toh(d->vr_status)), rxstat); | 673 | VR_RXBYTES(le32toh(d->vr_status)), rxstat); | |
674 | 674 | |||
675 | VR_INIT_RXDESC(sc, i); | 675 | VR_INIT_RXDESC(sc, i); | |
676 | 676 | |||
677 | continue; | 677 | continue; | |
678 | } | 678 | } | |
679 | 679 | |||
680 | bus_dmamap_sync(sc->vr_dmat, ds->ds_dmamap, 0, | 680 | bus_dmamap_sync(sc->vr_dmat, ds->ds_dmamap, 0, | |
681 | ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); | 681 | ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); | |
682 | 682 | |||
683 | /* No errors; receive the packet. */ | 683 | /* No errors; receive the packet. */ | |
684 | total_len = VR_RXBYTES(le32toh(d->vr_status)); | 684 | total_len = VR_RXBYTES(le32toh(d->vr_status)); | |
685 | #ifdef DIAGNOSTIC | 685 | #ifdef DIAGNOSTIC | |
686 | if (total_len == 0) { | 686 | if (total_len == 0) { | |
687 | /* | 687 | /* | |
688 | * If we receive a zero-length packet, we probably | 688 | * If we receive a zero-length packet, we probably | |
689 | * missed to handle an error condition above. | 689 | * missed to handle an error condition above. | |
690 | * Discard it to avoid a later crash. | 690 | * Discard it to avoid a later crash. | |
691 | */ | 691 | */ | |
692 | ifp->if_ierrors++; | 692 | if_statinc(ifp, if_ierrors); | |
693 | 693 | |||
694 | aprint_error_dev(sc->vr_dev, | 694 | aprint_error_dev(sc->vr_dev, | |
695 | "receive error: zero-length packet; " | 695 | "receive error: zero-length packet; " | |
696 | "status = 0x%x\n", rxstat); | 696 | "status = 0x%x\n", rxstat); | |
697 | 697 | |||
698 | VR_INIT_RXDESC(sc, i); | 698 | VR_INIT_RXDESC(sc, i); | |
699 | 699 | |||
700 | continue; | 700 | continue; | |
701 | } | 701 | } | |
702 | #endif | 702 | #endif | |
703 | 703 | |||
704 | /* | 704 | /* | |
705 | * The Rhine chip includes the CRC with every packet. | 705 | * The Rhine chip includes the CRC with every packet. | |
@@ -723,46 +723,46 @@ vr_rxeof(struct vr_softc *sc) | @@ -723,46 +723,46 @@ vr_rxeof(struct vr_softc *sc) | |||
723 | MGETHDR(m, M_DONTWAIT, MT_DATA); | 723 | MGETHDR(m, M_DONTWAIT, MT_DATA); | |
724 | if (m == NULL) | 724 | if (m == NULL) | |
725 | goto dropit; | 725 | goto dropit; | |
726 | memcpy(mtod(m, void *), | 726 | memcpy(mtod(m, void *), | |
727 | mtod(ds->ds_mbuf, void *), total_len); | 727 | mtod(ds->ds_mbuf, void *), total_len); | |
728 | VR_INIT_RXDESC(sc, i); | 728 | VR_INIT_RXDESC(sc, i); | |
729 | bus_dmamap_sync(sc->vr_dmat, ds->ds_dmamap, 0, | 729 | bus_dmamap_sync(sc->vr_dmat, ds->ds_dmamap, 0, | |
730 | ds->ds_dmamap->dm_mapsize, | 730 | ds->ds_dmamap->dm_mapsize, | |
731 | BUS_DMASYNC_PREREAD); | 731 | BUS_DMASYNC_PREREAD); | |
732 | } else { | 732 | } else { | |
733 | m = ds->ds_mbuf; | 733 | m = ds->ds_mbuf; | |
734 | if (vr_add_rxbuf(sc, i) == ENOBUFS) { | 734 | if (vr_add_rxbuf(sc, i) == ENOBUFS) { | |
735 | dropit: | 735 | dropit: | |
736 | ifp->if_ierrors++; | 736 | if_statinc(ifp, if_ierrors); | |
737 | VR_INIT_RXDESC(sc, i); | 737 | VR_INIT_RXDESC(sc, i); | |
738 | bus_dmamap_sync(sc->vr_dmat, | 738 | bus_dmamap_sync(sc->vr_dmat, | |
739 | ds->ds_dmamap, 0, | 739 | ds->ds_dmamap, 0, | |
740 | ds->ds_dmamap->dm_mapsize, | 740 | ds->ds_dmamap->dm_mapsize, | |
741 | BUS_DMASYNC_PREREAD); | 741 | BUS_DMASYNC_PREREAD); | |
742 | continue; | 742 | continue; | |
743 | } | 743 | } | |
744 | } | 744 | } | |
745 | #else | 745 | #else | |
746 | /* | 746 | /* | |
747 | * The Rhine's packet buffers must be 4-byte aligned. | 747 | * The Rhine's packet buffers must be 4-byte aligned. | |
748 | * But this means that the data after the Ethernet header | 748 | * But this means that the data after the Ethernet header | |
749 | * is misaligned. We must allocate a new buffer and | 749 | * is misaligned. We must allocate a new buffer and | |
750 | * copy the data, shifted forward 2 bytes. | 750 | * copy the data, shifted forward 2 bytes. | |
751 | */ | 751 | */ | |
752 | MGETHDR(m, M_DONTWAIT, MT_DATA); | 752 | MGETHDR(m, M_DONTWAIT, MT_DATA); | |
753 | if (m == NULL) { | 753 | if (m == NULL) { | |
754 | dropit: | 754 | dropit: | |
755 | ifp->if_ierrors++; | 755 | if_statinc(ifp, if_ierrors); | |
756 | VR_INIT_RXDESC(sc, i); | 756 | VR_INIT_RXDESC(sc, i); | |
757 | bus_dmamap_sync(sc->vr_dmat, ds->ds_dmamap, 0, | 757 | bus_dmamap_sync(sc->vr_dmat, ds->ds_dmamap, 0, | |
758 | ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD); | 758 | ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD); | |
759 | continue; | 759 | continue; | |
760 | } | 760 | } | |
761 | if (total_len > (MHLEN - 2)) { | 761 | if (total_len > (MHLEN - 2)) { | |
762 | MCLGET(m, M_DONTWAIT); | 762 | MCLGET(m, M_DONTWAIT); | |
763 | if ((m->m_flags & M_EXT) == 0) { | 763 | if ((m->m_flags & M_EXT) == 0) { | |
764 | m_freem(m); | 764 | m_freem(m); | |
765 | goto dropit; | 765 | goto dropit; | |
766 | } | 766 | } | |
767 | } | 767 | } | |
768 | m->m_data += 2; | 768 | m->m_data += 2; | |
@@ -788,27 +788,27 @@ vr_rxeof(struct vr_softc *sc) | @@ -788,27 +788,27 @@ vr_rxeof(struct vr_softc *sc) | |||
788 | 788 | |||
789 | /* Update the receive pointer. */ | 789 | /* Update the receive pointer. */ | |
790 | sc->vr_rxptr = i; | 790 | sc->vr_rxptr = i; | |
791 | } | 791 | } | |
792 | 792 | |||
793 | void | 793 | void | |
794 | vr_rxeoc(struct vr_softc *sc) | 794 | vr_rxeoc(struct vr_softc *sc) | |
795 | { | 795 | { | |
796 | struct ifnet *ifp; | 796 | struct ifnet *ifp; | |
797 | int i; | 797 | int i; | |
798 | 798 | |||
799 | ifp = &sc->vr_ec.ec_if; | 799 | ifp = &sc->vr_ec.ec_if; | |
800 | 800 | |||
801 | ifp->if_ierrors++; | 801 | if_statinc(ifp, if_ierrors); | |
802 | 802 | |||
803 | VR_CLRBIT16(sc, VR_COMMAND, VR_CMD_RX_ON); | 803 | VR_CLRBIT16(sc, VR_COMMAND, VR_CMD_RX_ON); | |
804 | for (i = 0; i < VR_TIMEOUT; i++) { | 804 | for (i = 0; i < VR_TIMEOUT; i++) { | |
805 | DELAY(10); | 805 | DELAY(10); | |
806 | if ((CSR_READ_2(sc, VR_COMMAND) & VR_CMD_RX_ON) == 0) | 806 | if ((CSR_READ_2(sc, VR_COMMAND) & VR_CMD_RX_ON) == 0) | |
807 | break; | 807 | break; | |
808 | } | 808 | } | |
809 | if (i == VR_TIMEOUT) { | 809 | if (i == VR_TIMEOUT) { | |
810 | /* XXX need reset? */ | 810 | /* XXX need reset? */ | |
811 | aprint_error_dev(sc->vr_dev, "RX shutdown never completed\n"); | 811 | aprint_error_dev(sc->vr_dev, "RX shutdown never completed\n"); | |
812 | } | 812 | } | |
813 | 813 | |||
814 | vr_rxeof(sc); | 814 | vr_rxeof(sc); | |
@@ -864,36 +864,39 @@ vr_txeof(struct vr_softc *sc) | @@ -864,36 +864,39 @@ vr_txeof(struct vr_softc *sc) | |||
864 | CSR_WRITE_4(sc, VR_TXADDR, VR_CDTXADDR(sc, i)); | 864 | CSR_WRITE_4(sc, VR_TXADDR, VR_CDTXADDR(sc, i)); | |
865 | break; | 865 | break; | |
866 | } | 866 | } | |
867 | 867 | |||
868 | if (txstat & VR_TXSTAT_OWN) | 868 | if (txstat & VR_TXSTAT_OWN) | |
869 | break; | 869 | break; | |
870 | 870 | |||
871 | bus_dmamap_sync(sc->vr_dmat, ds->ds_dmamap, | 871 | bus_dmamap_sync(sc->vr_dmat, ds->ds_dmamap, | |
872 | 0, ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_POSTWRITE); | 872 | 0, ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_POSTWRITE); | |
873 | bus_dmamap_unload(sc->vr_dmat, ds->ds_dmamap); | 873 | bus_dmamap_unload(sc->vr_dmat, ds->ds_dmamap); | |
874 | m_freem(ds->ds_mbuf); | 874 | m_freem(ds->ds_mbuf); | |
875 | ds->ds_mbuf = NULL; | 875 | ds->ds_mbuf = NULL; | |
876 | 876 | |||
877 | net_stat_ref_t nsr = IF_STAT_GETREF(ifp); | |||
877 | if (txstat & VR_TXSTAT_ERRSUM) { | 878 | if (txstat & VR_TXSTAT_ERRSUM) { | |
878 | ifp->if_oerrors++; | 879 | if_statinc_ref(nsr, if_oerrors); | |
879 | if (txstat & VR_TXSTAT_DEFER) | 880 | if (txstat & VR_TXSTAT_DEFER) | |
880 | ifp->if_collisions++; | 881 | if_statinc_ref(nsr, if_collisions); | |
881 | if (txstat & VR_TXSTAT_LATECOLL) | 882 | if (txstat & VR_TXSTAT_LATECOLL) | |
882 | ifp->if_collisions++; | 883 | if_statinc_ref(nsr, if_collisions); | |
883 | } | 884 | } | |
884 | 885 | |||
885 | ifp->if_collisions += (txstat & VR_TXSTAT_COLLCNT) >> 3; | 886 | if_statadd_ref(nsr, if_collisions, | |
886 | ifp->if_opackets++; | 887 | (txstat & VR_TXSTAT_COLLCNT) >> 3); | |
888 | if_statinc_ref(nsr, if_opackets); | |||
889 | IF_STAT_PUTREF(ifp); | |||
887 | } | 890 | } | |
888 | 891 | |||
889 | /* Update the dirty transmit buffer pointer. */ | 892 | /* Update the dirty transmit buffer pointer. */ | |
890 | sc->vr_txdirty = i; | 893 | sc->vr_txdirty = i; | |
891 | 894 | |||
892 | /* | 895 | /* | |
893 | * Cancel the watchdog timer if there are no pending | 896 | * Cancel the watchdog timer if there are no pending | |
894 | * transmissions. | 897 | * transmissions. | |
895 | */ | 898 | */ | |
896 | if (sc->vr_txpending == 0) | 899 | if (sc->vr_txpending == 0) | |
897 | ifp->if_timer = 0; | 900 | ifp->if_timer = 0; | |
898 | } | 901 | } | |
899 | 902 | |||
@@ -924,27 +927,27 @@ vr_intr(void *arg) | @@ -924,27 +927,27 @@ vr_intr(void *arg) | |||
924 | 927 | |||
925 | if ((status & VR_INTRS) == 0) | 928 | if ((status & VR_INTRS) == 0) | |
926 | break; | 929 | break; | |
927 | 930 | |||
928 | handled = 1; | 931 | handled = 1; | |
929 | 932 | |||
930 | rnd_add_uint32(&sc->rnd_source, status); | 933 | rnd_add_uint32(&sc->rnd_source, status); | |
931 | 934 | |||
932 | if (status & VR_ISR_RX_OK) | 935 | if (status & VR_ISR_RX_OK) | |
933 | vr_rxeof(sc); | 936 | vr_rxeof(sc); | |
934 | 937 | |||
935 | if (status & VR_ISR_RX_DROPPED) { | 938 | if (status & VR_ISR_RX_DROPPED) { | |
936 | aprint_error_dev(sc->vr_dev, "rx packet lost\n"); | 939 | aprint_error_dev(sc->vr_dev, "rx packet lost\n"); | |
937 | ifp->if_ierrors++; | 940 | if_statinc(ifp, if_ierrors); | |
938 | } | 941 | } | |
939 | 942 | |||
940 | if (status & | 943 | if (status & | |
941 | (VR_ISR_RX_ERR | VR_ISR_RX_NOBUF | VR_ISR_RX_OFLOW)) | 944 | (VR_ISR_RX_ERR | VR_ISR_RX_NOBUF | VR_ISR_RX_OFLOW)) | |
942 | vr_rxeoc(sc); | 945 | vr_rxeoc(sc); | |
943 | 946 | |||
944 | 947 | |||
945 | if (status & (VR_ISR_BUSERR | VR_ISR_TX_UNDERRUN)) { | 948 | if (status & (VR_ISR_BUSERR | VR_ISR_TX_UNDERRUN)) { | |
946 | if (status & VR_ISR_BUSERR) | 949 | if (status & VR_ISR_BUSERR) | |
947 | aprint_error_dev(sc->vr_dev, "PCI bus error\n"); | 950 | aprint_error_dev(sc->vr_dev, "PCI bus error\n"); | |
948 | if (status & VR_ISR_TX_UNDERRUN) | 951 | if (status & VR_ISR_TX_UNDERRUN) | |
949 | aprint_error_dev(sc->vr_dev, | 952 | aprint_error_dev(sc->vr_dev, | |
950 | "transmit underrun\n"); | 953 | "transmit underrun\n"); | |
@@ -957,27 +960,27 @@ vr_intr(void *arg) | @@ -957,27 +960,27 @@ vr_intr(void *arg) | |||
957 | if (status & VR_ISR_TX_OK) { | 960 | if (status & VR_ISR_TX_OK) { | |
958 | dotx = 1; | 961 | dotx = 1; | |
959 | vr_txeof(sc); | 962 | vr_txeof(sc); | |
960 | } | 963 | } | |
961 | 964 | |||
962 | if (status & | 965 | if (status & | |
963 | (VR_ISR_TX_ABRT | VR_ISR_TX_ABRT2 | VR_ISR_TX_UDFI)) { | 966 | (VR_ISR_TX_ABRT | VR_ISR_TX_ABRT2 | VR_ISR_TX_UDFI)) { | |
964 | if (status & (VR_ISR_TX_ABRT | VR_ISR_TX_ABRT2)) | 967 | if (status & (VR_ISR_TX_ABRT | VR_ISR_TX_ABRT2)) | |
965 | aprint_error_dev(sc->vr_dev, | 968 | aprint_error_dev(sc->vr_dev, | |
966 | "transmit aborted\n"); | 969 | "transmit aborted\n"); | |
967 | if (status & VR_ISR_TX_UDFI) | 970 | if (status & VR_ISR_TX_UDFI) | |
968 | aprint_error_dev(sc->vr_dev, | 971 | aprint_error_dev(sc->vr_dev, | |
969 | "transmit underflow\n"); | 972 | "transmit underflow\n"); | |
970 | ifp->if_oerrors++; | 973 | if_statinc(ifp, if_oerrors); | |
971 | dotx = 1; | 974 | dotx = 1; | |
972 | vr_txeof(sc); | 975 | vr_txeof(sc); | |
973 | if (sc->vr_txpending) { | 976 | if (sc->vr_txpending) { | |
974 | VR_SETBIT16(sc, VR_COMMAND, VR_CMD_TX_ON); | 977 | VR_SETBIT16(sc, VR_COMMAND, VR_CMD_TX_ON); | |
975 | VR_SETBIT16(sc, VR_COMMAND, VR_CMD_TX_GO); | 978 | VR_SETBIT16(sc, VR_COMMAND, VR_CMD_TX_GO); | |
976 | } | 979 | } | |
977 | } | 980 | } | |
978 | } | 981 | } | |
979 | 982 | |||
980 | /* Re-enable interrupts. */ | 983 | /* Re-enable interrupts. */ | |
981 | CSR_WRITE_2(sc, VR_IMR, VR_INTRS); | 984 | CSR_WRITE_2(sc, VR_IMR, VR_INTRS); | |
982 | 985 | |||
983 | if (dotx) | 986 | if (dotx) | |
@@ -1320,27 +1323,27 @@ vr_ioctl(struct ifnet *ifp, u_long comma | @@ -1320,27 +1323,27 @@ vr_ioctl(struct ifnet *ifp, u_long comma | |||
1320 | vr_setmulti(sc); | 1323 | vr_setmulti(sc); | |
1321 | } | 1324 | } | |
1322 | splx(s); | 1325 | splx(s); | |
1323 | 1326 | |||
1324 | return error; | 1327 | return error; | |
1325 | } | 1328 | } | |
1326 | 1329 | |||
1327 | static void | 1330 | static void | |
1328 | vr_watchdog(struct ifnet *ifp) | 1331 | vr_watchdog(struct ifnet *ifp) | |
1329 | { | 1332 | { | |
1330 | struct vr_softc *sc = ifp->if_softc; | 1333 | struct vr_softc *sc = ifp->if_softc; | |
1331 | 1334 | |||
1332 | aprint_error_dev(sc->vr_dev, "device timeout\n"); | 1335 | aprint_error_dev(sc->vr_dev, "device timeout\n"); | |
1333 | ifp->if_oerrors++; | 1336 | if_statinc(ifp, if_oerrors); | |
1334 | 1337 | |||
1335 | (void) vr_init(ifp); | 1338 | (void) vr_init(ifp); | |
1336 | } | 1339 | } | |
1337 | 1340 | |||
1338 | /* | 1341 | /* | |
1339 | * One second timer, used to tick MII. | 1342 | * One second timer, used to tick MII. | |
1340 | */ | 1343 | */ | |
1341 | static void | 1344 | static void | |
1342 | vr_tick(void *arg) | 1345 | vr_tick(void *arg) | |
1343 | { | 1346 | { | |
1344 | struct vr_softc *sc = arg; | 1347 | struct vr_softc *sc = arg; | |
1345 | int s; | 1348 | int s; | |
1346 | 1349 |