Deleted Added
full compact
if_wb.c (155671) if_wb.c (162315)
1/*-
2 * Copyright (c) 1997, 1998
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1997, 1998
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/pci/if_wb.c 155671 2006-02-14 12:44:56Z glebius $");
34__FBSDID("$FreeBSD: head/sys/pci/if_wb.c 162315 2006-09-15 10:40:54Z glebius $");
35
36/*
37 * Winbond fast ethernet PCI NIC driver
38 *
39 * Supports various cheap network adapters based on the Winbond W89C840F
40 * fast ethernet controller chip. This includes adapters manufactured by
41 * Winbond itself and some made by Linksys.
42 *

--- 607 unchanged lines hidden (view full) ---

650 for (i = 0; i < WB_TIMEOUT; i++) {
651 DELAY(10);
652 if ((CSR_READ_4(sc, WB_ISR) & WB_ISR_TX_IDLE) &&
653 (CSR_READ_4(sc, WB_ISR) & WB_ISR_RX_IDLE))
654 break;
655 }
656
657 if (i == WB_TIMEOUT)
35
36/*
37 * Winbond fast ethernet PCI NIC driver
38 *
39 * Supports various cheap network adapters based on the Winbond W89C840F
40 * fast ethernet controller chip. This includes adapters manufactured by
41 * Winbond itself and some made by Linksys.
42 *

--- 607 unchanged lines hidden (view full) ---

650 for (i = 0; i < WB_TIMEOUT; i++) {
651 DELAY(10);
652 if ((CSR_READ_4(sc, WB_ISR) & WB_ISR_TX_IDLE) &&
653 (CSR_READ_4(sc, WB_ISR) & WB_ISR_RX_IDLE))
654 break;
655 }
656
657 if (i == WB_TIMEOUT)
658 if_printf(sc->wb_ifp,
658 device_printf(sc->wb_dev,
659 "failed to force tx and rx to idle state\n");
660 }
661
662 if (IFM_SUBTYPE(media) == IFM_10_T)
663 WB_CLRBIT(sc, WB_NETCFG, WB_NETCFG_100MBPS);
664 else
665 WB_SETBIT(sc, WB_NETCFG, WB_NETCFG_100MBPS);
666

--- 24 unchanged lines hidden (view full) ---

691 WB_SETBIT(sc, WB_BUSCTL, WB_BUSCTL_RESET);
692
693 for (i = 0; i < WB_TIMEOUT; i++) {
694 DELAY(10);
695 if (!(CSR_READ_4(sc, WB_BUSCTL) & WB_BUSCTL_RESET))
696 break;
697 }
698 if (i == WB_TIMEOUT)
659 "failed to force tx and rx to idle state\n");
660 }
661
662 if (IFM_SUBTYPE(media) == IFM_10_T)
663 WB_CLRBIT(sc, WB_NETCFG, WB_NETCFG_100MBPS);
664 else
665 WB_SETBIT(sc, WB_NETCFG, WB_NETCFG_100MBPS);
666

--- 24 unchanged lines hidden (view full) ---

691 WB_SETBIT(sc, WB_BUSCTL, WB_BUSCTL_RESET);
692
693 for (i = 0; i < WB_TIMEOUT; i++) {
694 DELAY(10);
695 if (!(CSR_READ_4(sc, WB_BUSCTL) & WB_BUSCTL_RESET))
696 break;
697 }
698 if (i == WB_TIMEOUT)
699 if_printf(sc->wb_ifp, "reset never completed!\n");
699 device_printf(sc->wb_dev, "reset never completed!\n");
700
701 /* Wait a little while for the chip to get its brains in order. */
702 DELAY(1000);
703
704 if (sc->wb_miibus == NULL)
705 return;
706
707 mii = device_get_softc(sc->wb_miibus);

--- 71 unchanged lines hidden (view full) ---

779 device_t dev;
780{
781 u_char eaddr[ETHER_ADDR_LEN];
782 struct wb_softc *sc;
783 struct ifnet *ifp;
784 int error = 0, rid;
785
786 sc = device_get_softc(dev);
700
701 /* Wait a little while for the chip to get its brains in order. */
702 DELAY(1000);
703
704 if (sc->wb_miibus == NULL)
705 return;
706
707 mii = device_get_softc(sc->wb_miibus);

--- 71 unchanged lines hidden (view full) ---

779 device_t dev;
780{
781 u_char eaddr[ETHER_ADDR_LEN];
782 struct wb_softc *sc;
783 struct ifnet *ifp;
784 int error = 0, rid;
785
786 sc = device_get_softc(dev);
787 sc->wb_dev = dev;
787
788 mtx_init(&sc->wb_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
789 MTX_DEF);
790 callout_init_mtx(&sc->wb_stat_callout, &sc->wb_mtx, 0);
791
792 /*
793 * Map control/status registers.
794 */

--- 287 unchanged lines hidden (view full) ---

1082
1083 if ((rxstat & WB_RXSTAT_MIIERR) ||
1084 (WB_RXBYTES(cur_rx->wb_ptr->wb_status) < WB_MIN_FRAMELEN) ||
1085 (WB_RXBYTES(cur_rx->wb_ptr->wb_status) > 1536) ||
1086 !(rxstat & WB_RXSTAT_LASTFRAG) ||
1087 !(rxstat & WB_RXSTAT_RXCMP)) {
1088 ifp->if_ierrors++;
1089 wb_newbuf(sc, cur_rx, m);
788
789 mtx_init(&sc->wb_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
790 MTX_DEF);
791 callout_init_mtx(&sc->wb_stat_callout, &sc->wb_mtx, 0);
792
793 /*
794 * Map control/status registers.
795 */

--- 287 unchanged lines hidden (view full) ---

1083
1084 if ((rxstat & WB_RXSTAT_MIIERR) ||
1085 (WB_RXBYTES(cur_rx->wb_ptr->wb_status) < WB_MIN_FRAMELEN) ||
1086 (WB_RXBYTES(cur_rx->wb_ptr->wb_status) > 1536) ||
1087 !(rxstat & WB_RXSTAT_LASTFRAG) ||
1088 !(rxstat & WB_RXSTAT_RXCMP)) {
1089 ifp->if_ierrors++;
1090 wb_newbuf(sc, cur_rx, m);
1090 if_printf(ifp, "receiver babbling: possible chip "
1091 "bug, forcing reset\n");
1091 device_printf(sc->wb_dev,
1092 "receiver babbling: possible chip bug,"
1093 " forcing reset\n");
1092 wb_fixmedia(sc);
1093 wb_reset(sc);
1094 wb_init_locked(sc);
1095 return;
1096 }
1097
1098 if (rxstat & WB_RXSTAT_RXERR) {
1099 ifp->if_ierrors++;

--- 497 unchanged lines hidden (view full) ---

1597
1598 /* Init our MAC address */
1599 for (i = 0; i < ETHER_ADDR_LEN; i++) {
1600 CSR_WRITE_1(sc, WB_NODE0 + i, IF_LLADDR(sc->wb_ifp)[i]);
1601 }
1602
1603 /* Init circular RX list. */
1604 if (wb_list_rx_init(sc) == ENOBUFS) {
1094 wb_fixmedia(sc);
1095 wb_reset(sc);
1096 wb_init_locked(sc);
1097 return;
1098 }
1099
1100 if (rxstat & WB_RXSTAT_RXERR) {
1101 ifp->if_ierrors++;

--- 497 unchanged lines hidden (view full) ---

1599
1600 /* Init our MAC address */
1601 for (i = 0; i < ETHER_ADDR_LEN; i++) {
1602 CSR_WRITE_1(sc, WB_NODE0 + i, IF_LLADDR(sc->wb_ifp)[i]);
1603 }
1604
1605 /* Init circular RX list. */
1606 if (wb_list_rx_init(sc) == ENOBUFS) {
1605 if_printf(ifp,
1607 device_printf(sc->wb_dev,
1606 "initialization failed: no memory for rx buffers\n");
1607 wb_stop(sc);
1608 return;
1609 }
1610
1611 /* Init TX descriptors. */
1612 wb_list_tx_init(sc);
1613

--- 233 unchanged lines hidden ---
1608 "initialization failed: no memory for rx buffers\n");
1609 wb_stop(sc);
1610 return;
1611 }
1612
1613 /* Init TX descriptors. */
1614 wb_list_tx_init(sc);
1615

--- 233 unchanged lines hidden ---