if_ti.c (48645) | if_ti.c (49011) |
---|---|
1/* 2 * Copyright (c) 1997, 1998, 1999 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 --- 15 unchanged lines hidden (view full) --- 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 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 * | 1/* 2 * Copyright (c) 1997, 1998, 1999 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 --- 15 unchanged lines hidden (view full) --- 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 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 * $Id: if_ti.c,v 1.8 1999/07/05 20:19:41 wpaul Exp $ | 32 * $Id: if_ti.c,v 1.114 1999/07/05 19:20:31 wpaul Exp $ |
33 */ 34 35/* 36 * Alteon Networks Tigon PCI gigabit ethernet driver for FreeBSD. 37 * Manuals, sample driver and firmware source kits are available 38 * from http://www.alteon.com/support/openkits. 39 * 40 * Written by Bill Paul <wpaul@ctr.columbia.edu> --- 68 unchanged lines hidden (view full) --- 109#include <netinet/in.h> 110#include <netinet/ip.h> 111 112#include <vm/vm.h> /* for vtophys */ 113#include <vm/pmap.h> /* for vtophys */ 114#include <machine/clock.h> /* for DELAY */ 115#include <machine/bus_memio.h> 116#include <machine/bus.h> | 33 */ 34 35/* 36 * Alteon Networks Tigon PCI gigabit ethernet driver for FreeBSD. 37 * Manuals, sample driver and firmware source kits are available 38 * from http://www.alteon.com/support/openkits. 39 * 40 * Written by Bill Paul <wpaul@ctr.columbia.edu> --- 68 unchanged lines hidden (view full) --- 109#include <netinet/in.h> 110#include <netinet/ip.h> 111 112#include <vm/vm.h> /* for vtophys */ 113#include <vm/pmap.h> /* for vtophys */ 114#include <machine/clock.h> /* for DELAY */ 115#include <machine/bus_memio.h> 116#include <machine/bus.h> |
117#include <machine/resource.h> 118#include <sys/bus.h> 119#include <sys/rman.h> |
|
117 118#include <pci/pcireg.h> 119#include <pci/pcivar.h> 120 121#include <pci/if_tireg.h> 122#include <pci/ti_fw.h> 123#include <pci/ti_fw2.h> 124 125#ifdef M_HWCKSUM 126/*#define TI_CSUM_OFFLOAD*/ 127#endif 128 129#if !defined(lint) 130static const char rcsid[] = | 120 121#include <pci/pcireg.h> 122#include <pci/pcivar.h> 123 124#include <pci/if_tireg.h> 125#include <pci/ti_fw.h> 126#include <pci/ti_fw2.h> 127 128#ifdef M_HWCKSUM 129/*#define TI_CSUM_OFFLOAD*/ 130#endif 131 132#if !defined(lint) 133static const char rcsid[] = |
131 "$Id: if_ti.c,v 1.8 1999/07/05 20:19:41 wpaul Exp $"; | 134 "$Id: if_ti.c,v 1.114 1999/07/05 19:20:31 wpaul Exp $"; |
132#endif 133 134/* 135 * Various supported device vendors/types and their names. 136 */ 137 138static struct ti_type ti_devs[] = { 139 { ALT_VENDORID, ALT_DEVICEID_ACENIC, 140 "Alteon AceNIC Gigabit Ethernet" }, 141 { TC_VENDORID, TC_DEVICEID_3C985, 142 "3Com 3c985-SX Gigabit Ethernet" }, 143 { NG_VENDORID, NG_DEVICEID_GA620, 144 "Netgear GA620 Gigabit Ethernet" }, 145 { SGI_VENDORID, SGI_DEVICEID_TIGON, 146 "Silicon Graphics Gigabit Ethernet" }, 147 { 0, 0, NULL } 148}; 149 | 135#endif 136 137/* 138 * Various supported device vendors/types and their names. 139 */ 140 141static struct ti_type ti_devs[] = { 142 { ALT_VENDORID, ALT_DEVICEID_ACENIC, 143 "Alteon AceNIC Gigabit Ethernet" }, 144 { TC_VENDORID, TC_DEVICEID_3C985, 145 "3Com 3c985-SX Gigabit Ethernet" }, 146 { NG_VENDORID, NG_DEVICEID_GA620, 147 "Netgear GA620 Gigabit Ethernet" }, 148 { SGI_VENDORID, SGI_DEVICEID_TIGON, 149 "Silicon Graphics Gigabit Ethernet" }, 150 { 0, 0, NULL } 151}; 152 |
150static unsigned long ti_count; 151 152static const char *ti_probe __P((pcici_t, pcidi_t)); 153static void ti_attach __P((pcici_t, int)); | 153static int ti_probe __P((device_t)); 154static int ti_attach __P((device_t)); 155static int ti_detach __P((device_t)); |
154static void ti_txeof __P((struct ti_softc *)); 155static void ti_rxeof __P((struct ti_softc *)); 156 157static void ti_stats_update __P((struct ti_softc *)); 158static int ti_encap __P((struct ti_softc *, struct mbuf *, 159 u_int32_t *)); 160 161static void ti_intr __P((void *)); 162static void ti_start __P((struct ifnet *)); 163static int ti_ioctl __P((struct ifnet *, u_long, caddr_t)); 164static void ti_init __P((void *)); 165static void ti_init2 __P((struct ti_softc *)); 166static void ti_stop __P((struct ti_softc *)); 167static void ti_watchdog __P((struct ifnet *)); | 156static void ti_txeof __P((struct ti_softc *)); 157static void ti_rxeof __P((struct ti_softc *)); 158 159static void ti_stats_update __P((struct ti_softc *)); 160static int ti_encap __P((struct ti_softc *, struct mbuf *, 161 u_int32_t *)); 162 163static void ti_intr __P((void *)); 164static void ti_start __P((struct ifnet *)); 165static int ti_ioctl __P((struct ifnet *, u_long, caddr_t)); 166static void ti_init __P((void *)); 167static void ti_init2 __P((struct ti_softc *)); 168static void ti_stop __P((struct ti_softc *)); 169static void ti_watchdog __P((struct ifnet *)); |
168static void ti_shutdown __P((int, void *)); | 170static void ti_shutdown __P((device_t)); |
169static int ti_ifmedia_upd __P((struct ifnet *)); 170static void ti_ifmedia_sts __P((struct ifnet *, struct ifmediareq *)); 171 172static u_int32_t ti_eeprom_putbyte __P((struct ti_softc *, int)); 173static u_int8_t ti_eeprom_getbyte __P((struct ti_softc *, 174 int, u_int8_t *)); 175static int ti_read_eeprom __P((struct ti_softc *, caddr_t, int, int)); 176 --- 23 unchanged lines hidden (view full) --- 200static void ti_free_rx_ring_mini __P((struct ti_softc *)); 201static void ti_free_tx_ring __P((struct ti_softc *)); 202static int ti_init_tx_ring __P((struct ti_softc *)); 203 204static int ti_64bitslot_war __P((struct ti_softc *)); 205static int ti_chipinit __P((struct ti_softc *)); 206static int ti_gibinit __P((struct ti_softc *)); 207 | 171static int ti_ifmedia_upd __P((struct ifnet *)); 172static void ti_ifmedia_sts __P((struct ifnet *, struct ifmediareq *)); 173 174static u_int32_t ti_eeprom_putbyte __P((struct ti_softc *, int)); 175static u_int8_t ti_eeprom_getbyte __P((struct ti_softc *, 176 int, u_int8_t *)); 177static int ti_read_eeprom __P((struct ti_softc *, caddr_t, int, int)); 178 --- 23 unchanged lines hidden (view full) --- 202static void ti_free_rx_ring_mini __P((struct ti_softc *)); 203static void ti_free_tx_ring __P((struct ti_softc *)); 204static int ti_init_tx_ring __P((struct ti_softc *)); 205 206static int ti_64bitslot_war __P((struct ti_softc *)); 207static int ti_chipinit __P((struct ti_softc *)); 208static int ti_gibinit __P((struct ti_softc *)); 209 |
210static device_method_t ti_methods[] = { 211 /* Device interface */ 212 DEVMETHOD(device_probe, ti_probe), 213 DEVMETHOD(device_attach, ti_attach), 214 DEVMETHOD(device_detach, ti_detach), 215 DEVMETHOD(device_shutdown, ti_shutdown), 216 { 0, 0 } 217}; 218 219static driver_t ti_driver = { 220 "ti", 221 ti_methods, 222 sizeof(struct ti_softc) 223}; 224 225static devclass_t ti_devclass; 226 227DRIVER_MODULE(ti, pci, ti_driver, ti_devclass, 0, 0); 228 |
|
208/* 209 * Send an instruction or address to the EEPROM, check for ACK. 210 */ 211static u_int32_t ti_eeprom_putbyte(sc, byte) 212 struct ti_softc *sc; 213 int byte; 214{ 215 register int i, ack = 0; --- 1275 unchanged lines hidden (view full) --- 1491 1492 return(0); 1493} 1494 1495/* 1496 * Probe for a Tigon chip. Check the PCI vendor and device IDs 1497 * against our list and return its name if we find a match. 1498 */ | 229/* 230 * Send an instruction or address to the EEPROM, check for ACK. 231 */ 232static u_int32_t ti_eeprom_putbyte(sc, byte) 233 struct ti_softc *sc; 234 int byte; 235{ 236 register int i, ack = 0; --- 1275 unchanged lines hidden (view full) --- 1512 1513 return(0); 1514} 1515 1516/* 1517 * Probe for a Tigon chip. Check the PCI vendor and device IDs 1518 * against our list and return its name if we find a match. 1519 */ |
1499static const char * 1500ti_probe(config_id, device_id) 1501 pcici_t config_id; 1502 pcidi_t device_id; | 1520static int ti_probe(dev) 1521 device_t dev; |
1503{ 1504 struct ti_type *t; 1505 1506 t = ti_devs; 1507 1508 while(t->ti_name != NULL) { | 1522{ 1523 struct ti_type *t; 1524 1525 t = ti_devs; 1526 1527 while(t->ti_name != NULL) { |
1509 if ((device_id & 0xFFFF) == t->ti_vid && 1510 ((device_id >> 16) & 0xFFFF) == t->ti_did) 1511 return(t->ti_name); | 1528 if ((pci_get_vendor(dev) == t->ti_vid) && 1529 (pci_get_device(dev) == t->ti_did)) { 1530 device_set_desc(dev, t->ti_name); 1531 return(0); 1532 } |
1512 t++; 1513 } 1514 | 1533 t++; 1534 } 1535 |
1515 return(NULL); | 1536 return(ENXIO); |
1516} 1517 | 1537} 1538 |
1518 1519static void 1520ti_attach(config_id, unit) 1521 pcici_t config_id; 1522 int unit; | 1539static int ti_attach(dev) 1540 device_t dev; |
1523{ | 1541{ |
1524 vm_offset_t pbase, vbase; | |
1525 int s; 1526 u_int32_t command; 1527 struct ifnet *ifp; 1528 struct ti_softc *sc; | 1542 int s; 1543 u_int32_t command; 1544 struct ifnet *ifp; 1545 struct ti_softc *sc; |
1546 int unit, error = 0, rid; |
|
1529 1530 s = splimp(); 1531 | 1547 1548 s = splimp(); 1549 |
1532 /* First, allocate memory for the softc struct. */ 1533 sc = malloc(sizeof(struct ti_softc), M_DEVBUF, M_NOWAIT); 1534 if (sc == NULL) { 1535 printf("ti%d: no memory for softc struct!\n", unit); 1536 goto fail; 1537 } 1538 | 1550 sc = device_get_softc(dev); 1551 unit = device_get_unit(dev); |
1539 bzero(sc, sizeof(struct ti_softc)); 1540 1541 /* 1542 * Map control/status registers. 1543 */ | 1552 bzero(sc, sizeof(struct ti_softc)); 1553 1554 /* 1555 * Map control/status registers. 1556 */ |
1544 command = pci_conf_read(config_id, PCI_COMMAND_STATUS_REG); | 1557 command = pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4); |
1545 command |= (PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN); | 1558 command |= (PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN); |
1546 pci_conf_write(config_id, PCI_COMMAND_STATUS_REG, command); 1547 command = pci_conf_read(config_id, PCI_COMMAND_STATUS_REG); | 1559 pci_write_config(dev, PCI_COMMAND_STATUS_REG, command, 4); 1560 command = pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4); |
1548 1549 if (!(command & PCIM_CMD_MEMEN)) { 1550 printf("ti%d: failed to enable memory mapping!\n", unit); | 1561 1562 if (!(command & PCIM_CMD_MEMEN)) { 1563 printf("ti%d: failed to enable memory mapping!\n", unit); |
1551 free(sc, M_DEVBUF); | 1564 error = ENXIO; |
1552 goto fail; 1553 } 1554 | 1565 goto fail; 1566 } 1567 |
1555#ifdef __i386__ 1556 if (!pci_map_mem(config_id, TI_PCI_LOMEM, &vbase, &pbase)) { | 1568 rid = TI_PCI_LOMEM; 1569 sc->ti_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 1570 0, ~0, 1, RF_ACTIVE); 1571 1572 if (sc->ti_res == NULL) { |
1557 printf ("ti%d: couldn't map memory\n", unit); | 1573 printf ("ti%d: couldn't map memory\n", unit); |
1558 free(sc, M_DEVBUF); | 1574 error = ENXIO; |
1559 goto fail; 1560 } 1561 | 1575 goto fail; 1576 } 1577 |
1562 sc->ti_bhandle = vbase; 1563 sc->ti_btag = I386_BUS_SPACE_MEM; 1564#endif | 1578 /* Allocate interrupt */ 1579 rid = 0; 1580 sc->ti_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, 1581 RF_SHAREABLE | RF_ACTIVE); |
1565 | 1582 |
1566#ifdef __alpha__ 1567 if (!(pci_map_bwx(config_id, TI_PCI_LOMEM, &vbase, &pbase) || 1568 pci_map_dense(config_id, TI_PCI_LOMEM, &vbase, &pbase))){ 1569 printf ("ti%d: couldn't map memory\n", unit); 1570 free(sc, M_DEVBUF); | 1583 if (sc->ti_irq == NULL) { 1584 printf("ti%d: couldn't map interrupt\n", unit); 1585 error = ENXIO; |
1571 goto fail; 1572 } 1573 | 1586 goto fail; 1587 } 1588 |
1574 sc->ti_bhandle = pbase; 1575 sc->ti_vhandle = vbase; 1576 sc->ti_btag = ALPHA_BUS_SPACE_MEM; 1577#endif 1578 /* Allocate interrupt */ 1579 if (!pci_map_int(config_id, ti_intr, sc, &net_imask)) { 1580 printf("ti%d: couldn't map interrupt\n", unit); 1581 free(sc, M_DEVBUF); | 1589 error = bus_setup_intr(dev, sc->ti_irq, INTR_TYPE_NET, 1590 ti_intr, sc, &sc->ti_intrhand); 1591 1592 if (error) { 1593 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq); 1594 bus_release_resource(dev, SYS_RES_MEMORY, 1595 TI_PCI_LOMEM, sc->ti_res); 1596 printf("ti%d: couldn't set up irq\n", unit); |
1582 goto fail; 1583 } 1584 1585 sc->ti_unit = unit; 1586 1587 if (ti_chipinit(sc)) { 1588 printf("ti%d: chip initialization failed\n", sc->ti_unit); | 1597 goto fail; 1598 } 1599 1600 sc->ti_unit = unit; 1601 1602 if (ti_chipinit(sc)) { 1603 printf("ti%d: chip initialization failed\n", sc->ti_unit); |
1589 free(sc, M_DEVBUF); | 1604 bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand); 1605 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq); 1606 bus_release_resource(dev, SYS_RES_MEMORY, 1607 TI_PCI_LOMEM, sc->ti_res); 1608 error = ENXIO; |
1590 goto fail; 1591 } 1592 1593 /* Zero out the NIC's on-board SRAM. */ 1594 ti_mem(sc, 0x2000, 0x100000 - 0x2000, NULL); 1595 1596 /* Init again -- zeroing memory may have clobbered some registers. */ 1597 if (ti_chipinit(sc)) { 1598 printf("ti%d: chip initialization failed\n", sc->ti_unit); | 1609 goto fail; 1610 } 1611 1612 /* Zero out the NIC's on-board SRAM. */ 1613 ti_mem(sc, 0x2000, 0x100000 - 0x2000, NULL); 1614 1615 /* Init again -- zeroing memory may have clobbered some registers. */ 1616 if (ti_chipinit(sc)) { 1617 printf("ti%d: chip initialization failed\n", sc->ti_unit); |
1599 free(sc, M_DEVBUF); | 1618 bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand); 1619 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq); 1620 bus_release_resource(dev, SYS_RES_MEMORY, 1621 TI_PCI_LOMEM, sc->ti_res); 1622 error = ENXIO; |
1600 goto fail; 1601 } 1602 1603 /* 1604 * Get station address from the EEPROM. Note: the manual states 1605 * that the MAC address is at offset 0x8c, however the data is 1606 * stored as two longwords (since that's how it's loaded into 1607 * the NIC). This means the MAC address is actually preceeded 1608 * by two zero bytes. We need to skip over those. 1609 */ 1610 if (ti_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr, 1611 TI_EE_MAC_OFFSET + 2, ETHER_ADDR_LEN)) { 1612 printf("ti%d: failed to read station address\n", unit); | 1623 goto fail; 1624 } 1625 1626 /* 1627 * Get station address from the EEPROM. Note: the manual states 1628 * that the MAC address is at offset 0x8c, however the data is 1629 * stored as two longwords (since that's how it's loaded into 1630 * the NIC). This means the MAC address is actually preceeded 1631 * by two zero bytes. We need to skip over those. 1632 */ 1633 if (ti_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr, 1634 TI_EE_MAC_OFFSET + 2, ETHER_ADDR_LEN)) { 1635 printf("ti%d: failed to read station address\n", unit); |
1613 free(sc, M_DEVBUF); | 1636 bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand); 1637 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq); 1638 bus_release_resource(dev, SYS_RES_MEMORY, 1639 TI_PCI_LOMEM, sc->ti_res); 1640 error = ENXIO; |
1614 goto fail; 1615 } 1616 1617 /* 1618 * A Tigon chip was detected. Inform the world. 1619 */ 1620 printf("ti%d: Ethernet address: %6D\n", unit, 1621 sc->arpcom.ac_enaddr, ":"); 1622 1623 /* Allocate the general information block and ring buffers. */ | 1641 goto fail; 1642 } 1643 1644 /* 1645 * A Tigon chip was detected. Inform the world. 1646 */ 1647 printf("ti%d: Ethernet address: %6D\n", unit, 1648 sc->arpcom.ac_enaddr, ":"); 1649 1650 /* Allocate the general information block and ring buffers. */ |
1624 sc->ti_rdata_ptr = contigmalloc(sizeof(struct ti_ring_data), M_DEVBUF, | 1651 sc->ti_rdata = contigmalloc(sizeof(struct ti_ring_data), M_DEVBUF, |
1625 M_NOWAIT, 0x100000, 0xffffffff, PAGE_SIZE, 0); 1626 | 1652 M_NOWAIT, 0x100000, 0xffffffff, PAGE_SIZE, 0); 1653 |
1627 if (sc->ti_rdata_ptr == NULL) { 1628 free(sc, M_DEVBUF); | 1654 if (sc->ti_rdata == NULL) { 1655 bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand); 1656 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq); 1657 bus_release_resource(dev, SYS_RES_MEMORY, 1658 TI_PCI_LOMEM, sc->ti_res); 1659 error = ENXIO; |
1629 printf("ti%d: no memory for list buffers!\n", sc->ti_unit); 1630 goto fail; 1631 } 1632 | 1660 printf("ti%d: no memory for list buffers!\n", sc->ti_unit); 1661 goto fail; 1662 } 1663 |
1633 sc->ti_rdata = (struct ti_ring_data *)sc->ti_rdata_ptr; | |
1634 bzero(sc->ti_rdata, sizeof(struct ti_ring_data)); 1635 1636 /* Try to allocate memory for jumbo buffers. */ 1637 if (ti_alloc_jumbo_mem(sc)) { 1638 printf("ti%d: jumbo buffer allocation failed\n", sc->ti_unit); | 1664 bzero(sc->ti_rdata, sizeof(struct ti_ring_data)); 1665 1666 /* Try to allocate memory for jumbo buffers. */ 1667 if (ti_alloc_jumbo_mem(sc)) { 1668 printf("ti%d: jumbo buffer allocation failed\n", sc->ti_unit); |
1639 free(sc->ti_rdata_ptr, M_DEVBUF); 1640 free(sc, M_DEVBUF); | 1669 bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand); 1670 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq); 1671 bus_release_resource(dev, SYS_RES_MEMORY, 1672 TI_PCI_LOMEM, sc->ti_res); 1673 free(sc->ti_rdata, M_DEVBUF); 1674 error = ENXIO; |
1641 goto fail; 1642 } 1643 1644 /* Set default tuneable values. */ 1645 sc->ti_stat_ticks = 2 * TI_TICKS_PER_SEC; 1646 sc->ti_rx_coal_ticks = TI_TICKS_PER_SEC / 5000; 1647 sc->ti_tx_coal_ticks = TI_TICKS_PER_SEC / 500; 1648 sc->ti_rx_max_coal_bds = 64; --- 30 unchanged lines hidden (view full) --- 1679 */ 1680 if_attach(ifp); 1681 ether_ifattach(ifp); 1682 1683#if NBPF > 0 1684 bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); 1685#endif 1686 | 1675 goto fail; 1676 } 1677 1678 /* Set default tuneable values. */ 1679 sc->ti_stat_ticks = 2 * TI_TICKS_PER_SEC; 1680 sc->ti_rx_coal_ticks = TI_TICKS_PER_SEC / 5000; 1681 sc->ti_tx_coal_ticks = TI_TICKS_PER_SEC / 500; 1682 sc->ti_rx_max_coal_bds = 64; --- 30 unchanged lines hidden (view full) --- 1713 */ 1714 if_attach(ifp); 1715 ether_ifattach(ifp); 1716 1717#if NBPF > 0 1718 bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); 1719#endif 1720 |
1687 at_shutdown(ti_shutdown, sc, SHUTDOWN_POST_SYNC); 1688 | |
1689fail: 1690 splx(s); 1691 | 1721fail: 1722 splx(s); 1723 |
1692 return; | 1724 return(error); |
1693} 1694 | 1725} 1726 |
1727static int ti_detach(dev) 1728 device_t dev; 1729{ 1730 struct ti_softc *sc; 1731 struct ifnet *ifp; 1732 int s; 1733 1734 s = splimp(); 1735 1736 sc = device_get_softc(dev); 1737 ifp = &sc->arpcom.ac_if; 1738 1739 if_detach(ifp); 1740 ti_stop(sc); 1741 1742 bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand); 1743 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq); 1744 bus_release_resource(dev, SYS_RES_MEMORY, TI_PCI_LOMEM, sc->ti_res); 1745 1746 free(sc->ti_cdata.ti_jumbo_buf, M_DEVBUF); 1747 free(sc->ti_rdata, M_DEVBUF); 1748 ifmedia_removeall(&sc->ifmedia); 1749 1750 splx(s); 1751 1752 return(0); 1753} 1754 |
|
1695/* 1696 * Frame reception handling. This is called if there's a frame 1697 * on the receive return list. 1698 * 1699 * Note: we have to be able to handle three possibilities here: 1700 * 1) the frame is from the mini receive ring (can only happen) 1701 * on Tigon 2 boards) 1702 * 2) the frame is from the jumbo recieve ring --- 722 unchanged lines hidden (view full) --- 2425 2426 return; 2427} 2428 2429/* 2430 * Stop all chip I/O so that the kernel's probe routines don't 2431 * get confused by errant DMAs when rebooting. 2432 */ | 1755/* 1756 * Frame reception handling. This is called if there's a frame 1757 * on the receive return list. 1758 * 1759 * Note: we have to be able to handle three possibilities here: 1760 * 1) the frame is from the mini receive ring (can only happen) 1761 * on Tigon 2 boards) 1762 * 2) the frame is from the jumbo recieve ring --- 722 unchanged lines hidden (view full) --- 2485 2486 return; 2487} 2488 2489/* 2490 * Stop all chip I/O so that the kernel's probe routines don't 2491 * get confused by errant DMAs when rebooting. 2492 */ |
2433static void ti_shutdown(howto, xsc) 2434 int howto; 2435 void *xsc; | 2493static void ti_shutdown(dev) 2494 device_t dev; |
2436{ 2437 struct ti_softc *sc; 2438 | 2495{ 2496 struct ti_softc *sc; 2497 |
2439 sc = xsc; | 2498 sc = device_get_softc(dev); |
2440 2441 ti_chipinit(sc); 2442 2443 return; 2444} | 2499 2500 ti_chipinit(sc); 2501 2502 return; 2503} |
2445 2446static struct pci_device ti_device = { 2447 "ti", 2448 ti_probe, 2449 ti_attach, 2450 &ti_count, 2451 NULL 2452}; 2453COMPAT_PCI_DRIVER(ti, ti_device); | |