if_tl.c (158471) | if_tl.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_tl.c 158471 2006-05-12 05:04:46Z jhb $"); | 34__FBSDID("$FreeBSD: head/sys/pci/if_tl.c 162315 2006-09-15 10:40:54Z glebius $"); |
35 36/* 37 * Texas Instruments ThunderLAN driver for FreeBSD 2.2.6 and 3.x. 38 * Supports many Compaq PCI NICs based on the ThunderLAN ethernet controller, 39 * the National Semiconductor DP83840A physical interface and the 40 * Microchip Technology 24Cxx series serial EEPROM. 41 * 42 * Written using the following four documents: --- 478 unchanged lines hidden (view full) --- 521 */ 522static u_int8_t tl_eeprom_getbyte(sc, addr, dest) 523 struct tl_softc *sc; 524 int addr; 525 u_int8_t *dest; 526{ 527 register int i; 528 u_int8_t byte = 0; | 35 36/* 37 * Texas Instruments ThunderLAN driver for FreeBSD 2.2.6 and 3.x. 38 * Supports many Compaq PCI NICs based on the ThunderLAN ethernet controller, 39 * the National Semiconductor DP83840A physical interface and the 40 * Microchip Technology 24Cxx series serial EEPROM. 41 * 42 * Written using the following four documents: --- 478 unchanged lines hidden (view full) --- 521 */ 522static u_int8_t tl_eeprom_getbyte(sc, addr, dest) 523 struct tl_softc *sc; 524 int addr; 525 u_int8_t *dest; 526{ 527 register int i; 528 u_int8_t byte = 0; |
529 struct ifnet *ifp = sc->tl_ifp; | 529 device_t tl_dev = sc->tl_dev; |
530 531 tl_dio_write8(sc, TL_NETSIO, 0); 532 533 EEPROM_START; 534 535 /* 536 * Send write control code to EEPROM. 537 */ 538 if (tl_eeprom_putbyte(sc, EEPROM_CTL_WRITE)) { | 530 531 tl_dio_write8(sc, TL_NETSIO, 0); 532 533 EEPROM_START; 534 535 /* 536 * Send write control code to EEPROM. 537 */ 538 if (tl_eeprom_putbyte(sc, EEPROM_CTL_WRITE)) { |
539 if_printf(ifp, "failed to send write command, status: %x\n", | 539 device_printf(tl_dev, "failed to send write command, status: %x\n", |
540 tl_dio_read8(sc, TL_NETSIO)); 541 return(1); 542 } 543 544 /* 545 * Send address of byte we want to read. 546 */ 547 if (tl_eeprom_putbyte(sc, addr)) { | 540 tl_dio_read8(sc, TL_NETSIO)); 541 return(1); 542 } 543 544 /* 545 * Send address of byte we want to read. 546 */ 547 if (tl_eeprom_putbyte(sc, addr)) { |
548 if_printf(ifp, "failed to send address, status: %x\n", | 548 device_printf(tl_dev, "failed to send address, status: %x\n", |
549 tl_dio_read8(sc, TL_NETSIO)); 550 return(1); 551 } 552 553 EEPROM_STOP; 554 EEPROM_START; 555 /* 556 * Send read control code to EEPROM. 557 */ 558 if (tl_eeprom_putbyte(sc, EEPROM_CTL_READ)) { | 549 tl_dio_read8(sc, TL_NETSIO)); 550 return(1); 551 } 552 553 EEPROM_STOP; 554 EEPROM_START; 555 /* 556 * Send read control code to EEPROM. 557 */ 558 if (tl_eeprom_putbyte(sc, EEPROM_CTL_READ)) { |
559 if_printf(ifp, "failed to send write command, status: %x\n", | 559 device_printf(tl_dev, "failed to send write command, status: %x\n", |
560 tl_dio_read8(sc, TL_NETSIO)); 561 return(1); 562 } 563 564 /* 565 * Start reading bits from EEPROM. 566 */ 567 tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_ETXEN); --- 542 unchanged lines hidden (view full) --- 1110 struct ifnet *ifp; 1111 struct tl_softc *sc; 1112 int unit, error = 0, rid; 1113 u_char eaddr[6]; 1114 1115 vid = pci_get_vendor(dev); 1116 did = pci_get_device(dev); 1117 sc = device_get_softc(dev); | 560 tl_dio_read8(sc, TL_NETSIO)); 561 return(1); 562 } 563 564 /* 565 * Start reading bits from EEPROM. 566 */ 567 tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_ETXEN); --- 542 unchanged lines hidden (view full) --- 1110 struct ifnet *ifp; 1111 struct tl_softc *sc; 1112 int unit, error = 0, rid; 1113 u_char eaddr[6]; 1114 1115 vid = pci_get_vendor(dev); 1116 did = pci_get_device(dev); 1117 sc = device_get_softc(dev); |
1118 sc->tl_dev = dev; |
|
1118 unit = device_get_unit(dev); 1119 1120 t = tl_devs; 1121 while(t->tl_name != NULL) { 1122 if (vid == t->tl_vid && did == t->tl_did) 1123 break; 1124 t++; 1125 } --- 538 unchanged lines hidden (view full) --- 1664 void *xsc; 1665 u_int32_t type; 1666{ 1667 struct tl_softc *sc; 1668 1669 sc = xsc; 1670 1671 if (type) | 1119 unit = device_get_unit(dev); 1120 1121 t = tl_devs; 1122 while(t->tl_name != NULL) { 1123 if (vid == t->tl_vid && did == t->tl_did) 1124 break; 1125 t++; 1126 } --- 538 unchanged lines hidden (view full) --- 1665 void *xsc; 1666 u_int32_t type; 1667{ 1668 struct tl_softc *sc; 1669 1670 sc = xsc; 1671 1672 if (type) |
1672 if_printf(sc->tl_ifp, "adapter check: %x\n", | 1673 device_printf(sc->tl_dev, "adapter check: %x\n", |
1673 (unsigned int)CSR_READ_4(sc, TL_CH_PARM)); 1674 1675 tl_softreset(sc, 1); 1676 tl_stop(sc); 1677 tl_init_locked(sc); 1678 CMD_SET(sc, TL_CMD_INTSON); 1679 1680 return(0); --- 7 unchanged lines hidden (view full) --- 1688 struct tl_softc *sc; 1689 u_int16_t netsts; 1690 1691 sc = xsc; 1692 1693 netsts = tl_dio_read16(sc, TL_NETSTS); 1694 tl_dio_write16(sc, TL_NETSTS, netsts); 1695 | 1674 (unsigned int)CSR_READ_4(sc, TL_CH_PARM)); 1675 1676 tl_softreset(sc, 1); 1677 tl_stop(sc); 1678 tl_init_locked(sc); 1679 CMD_SET(sc, TL_CMD_INTSON); 1680 1681 return(0); --- 7 unchanged lines hidden (view full) --- 1689 struct tl_softc *sc; 1690 u_int16_t netsts; 1691 1692 sc = xsc; 1693 1694 netsts = tl_dio_read16(sc, TL_NETSTS); 1695 tl_dio_write16(sc, TL_NETSTS, netsts); 1696 |
1696 if_printf(sc->tl_ifp, "network status: %x\n", netsts); | 1697 device_printf(sc->tl_dev, "network status: %x\n", netsts); |
1697 1698 return(1); 1699} 1700 1701static void 1702tl_intr(xsc) 1703 void *xsc; 1704{ --- 14 unchanged lines hidden (view full) --- 1719 ivec = (ints & TL_VEC_MASK) >> 5; 1720 ints = (ints & TL_INT_MASK) >> 2; 1721 1722 ifp = sc->tl_ifp; 1723 1724 switch(ints) { 1725 case (TL_INTR_INVALID): 1726#ifdef DIAGNOSTIC | 1698 1699 return(1); 1700} 1701 1702static void 1703tl_intr(xsc) 1704 void *xsc; 1705{ --- 14 unchanged lines hidden (view full) --- 1720 ivec = (ints & TL_VEC_MASK) >> 5; 1721 ints = (ints & TL_INT_MASK) >> 2; 1722 1723 ifp = sc->tl_ifp; 1724 1725 switch(ints) { 1726 case (TL_INTR_INVALID): 1727#ifdef DIAGNOSTIC |
1727 if_printf(ifp, "got an invalid interrupt!\n"); | 1728 device_printf(sc->tl_dev, "got an invalid interrupt!\n"); |
1728#endif 1729 /* Re-enable interrupts but don't ack this one. */ 1730 CMD_PUT(sc, type); 1731 r = 0; 1732 break; 1733 case (TL_INTR_TXEOF): 1734 r = tl_intvec_txeof((void *)sc, type); 1735 break; 1736 case (TL_INTR_TXEOC): 1737 r = tl_intvec_txeoc((void *)sc, type); 1738 break; 1739 case (TL_INTR_STATOFLOW): 1740 tl_stats_update(sc); 1741 r = 1; 1742 break; 1743 case (TL_INTR_RXEOF): 1744 r = tl_intvec_rxeof((void *)sc, type); 1745 break; 1746 case (TL_INTR_DUMMY): | 1729#endif 1730 /* Re-enable interrupts but don't ack this one. */ 1731 CMD_PUT(sc, type); 1732 r = 0; 1733 break; 1734 case (TL_INTR_TXEOF): 1735 r = tl_intvec_txeof((void *)sc, type); 1736 break; 1737 case (TL_INTR_TXEOC): 1738 r = tl_intvec_txeoc((void *)sc, type); 1739 break; 1740 case (TL_INTR_STATOFLOW): 1741 tl_stats_update(sc); 1742 r = 1; 1743 break; 1744 case (TL_INTR_RXEOF): 1745 r = tl_intvec_rxeof((void *)sc, type); 1746 break; 1747 case (TL_INTR_DUMMY): |
1747 if_printf(ifp, "got a dummy interrupt\n"); | 1748 device_printf(sc->tl_dev, "got a dummy interrupt\n"); |
1748 r = 1; 1749 break; 1750 case (TL_INTR_ADCHK): 1751 if (ivec) 1752 r = tl_intvec_adchk((void *)sc, type); 1753 else 1754 r = tl_intvec_netsts((void *)sc, type); 1755 break; 1756 case (TL_INTR_RXEOC): 1757 r = tl_intvec_rxeoc((void *)sc, type); 1758 break; 1759 default: | 1749 r = 1; 1750 break; 1751 case (TL_INTR_ADCHK): 1752 if (ivec) 1753 r = tl_intvec_adchk((void *)sc, type); 1754 else 1755 r = tl_intvec_netsts((void *)sc, type); 1756 break; 1757 case (TL_INTR_RXEOC): 1758 r = tl_intvec_rxeoc((void *)sc, type); 1759 break; 1760 default: |
1760 if_printf(ifp, "bogus interrupt type\n"); | 1761 device_printf(sc->tl_dev, "bogus interrupt type\n"); |
1761 break; 1762 } 1763 1764 /* Re-enable interrupts */ 1765 if (r) { 1766 CMD_PUT(sc, TL_CMD_ACK | r | type); 1767 } 1768 --- 39 unchanged lines hidden (view full) --- 1808 ifp->if_oerrors += tl_tx_underrun(tl_stats); 1809 1810 if (tl_tx_underrun(tl_stats)) { 1811 u_int8_t tx_thresh; 1812 tx_thresh = tl_dio_read8(sc, TL_ACOMMIT) & TL_AC_TXTHRESH; 1813 if (tx_thresh != TL_AC_TXTHRESH_WHOLEPKT) { 1814 tx_thresh >>= 4; 1815 tx_thresh++; | 1762 break; 1763 } 1764 1765 /* Re-enable interrupts */ 1766 if (r) { 1767 CMD_PUT(sc, TL_CMD_ACK | r | type); 1768 } 1769 --- 39 unchanged lines hidden (view full) --- 1809 ifp->if_oerrors += tl_tx_underrun(tl_stats); 1810 1811 if (tl_tx_underrun(tl_stats)) { 1812 u_int8_t tx_thresh; 1813 tx_thresh = tl_dio_read8(sc, TL_ACOMMIT) & TL_AC_TXTHRESH; 1814 if (tx_thresh != TL_AC_TXTHRESH_WHOLEPKT) { 1815 tx_thresh >>= 4; 1816 tx_thresh++; |
1816 if_printf(ifp, "tx underrun -- increasing " | 1817 device_printf(sc->tl_dev, "tx underrun -- increasing " |
1817 "tx threshold to %d bytes\n", 1818 (64 * (tx_thresh * 4))); 1819 tl_dio_clrbit(sc, TL_ACOMMIT, TL_AC_TXTHRESH); 1820 tl_dio_setbit(sc, TL_ACOMMIT, tx_thresh << 4); 1821 } 1822 } 1823 1824 callout_reset(&sc->tl_stat_callout, hz, tl_stats_update, sc); --- 264 unchanged lines hidden (view full) --- 2089 /* Init our MAC address */ 2090 tl_setfilt(sc, IF_LLADDR(sc->tl_ifp), 0); 2091 2092 /* Init multicast filter, if needed. */ 2093 tl_setmulti(sc); 2094 2095 /* Init circular RX list. */ 2096 if (tl_list_rx_init(sc) == ENOBUFS) { | 1818 "tx threshold to %d bytes\n", 1819 (64 * (tx_thresh * 4))); 1820 tl_dio_clrbit(sc, TL_ACOMMIT, TL_AC_TXTHRESH); 1821 tl_dio_setbit(sc, TL_ACOMMIT, tx_thresh << 4); 1822 } 1823 } 1824 1825 callout_reset(&sc->tl_stat_callout, hz, tl_stats_update, sc); --- 264 unchanged lines hidden (view full) --- 2090 /* Init our MAC address */ 2091 tl_setfilt(sc, IF_LLADDR(sc->tl_ifp), 0); 2092 2093 /* Init multicast filter, if needed. */ 2094 tl_setmulti(sc); 2095 2096 /* Init circular RX list. */ 2097 if (tl_list_rx_init(sc) == ENOBUFS) { |
2097 if_printf(ifp, | 2098 device_printf(sc->tl_dev, |
2098 "initialization failed: no memory for rx buffers\n"); 2099 tl_stop(sc); 2100 return; 2101 } 2102 2103 /* Init TX pointers. */ 2104 tl_list_tx_init(sc); 2105 --- 255 unchanged lines hidden --- | 2099 "initialization failed: no memory for rx buffers\n"); 2100 tl_stop(sc); 2101 return; 2102 } 2103 2104 /* Init TX pointers. */ 2105 tl_list_tx_init(sc); 2106 --- 255 unchanged lines hidden --- |