Deleted Added
sdiff udiff text old ( 142407 ) new ( 143903 )
full compact
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

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

72 * - Raymond Lee of Netgear, for providing a pair of Netgear
73 * GA620 Tigon 2 boards for testing
74 * - Ulf Zimmermann, for bringing the GA260 to my attention and
75 * convincing me to write this driver.
76 * - Andrew Gallatin for providing FreeBSD/Alpha support.
77 */
78
79#include <sys/cdefs.h>
80__FBSDID("$FreeBSD: head/sys/dev/ti/if_ti.c 142407 2005-02-24 22:33:05Z imp $");
81
82#include "opt_ti.h"
83
84#include <sys/param.h>
85#include <sys/systm.h>
86#include <sys/sockio.h>
87#include <sys/mbuf.h>
88#include <sys/malloc.h>

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

1823 printf("ti%d: bios thinks we're in a 64 bit slot, "
1824 "but we aren't", sc->ti_unit);
1825 return (EINVAL);
1826 }
1827
1828 return (0);
1829}
1830
1831/*
1832 * Initialize the general information block and firmware, and
1833 * start the CPU(s) running.
1834 */
1835static int
1836ti_gibinit(sc)
1837 struct ti_softc *sc;
1838{
1839 struct ti_rcb *rcb;
1840 int i;
1841 struct ifnet *ifp;
1842
1843 ifp = &sc->arpcom.ac_if;
1844
1845 /* Disable interrupts for now. */
1846 CSR_WRITE_4(sc, TI_MB_HOSTINTR, 1);
1847
1848 /* Tell the chip where to find the general information block. */
1849 CSR_WRITE_4(sc, TI_GCR_GENINFO_HI, 0);
1850 CSR_WRITE_4(sc, TI_GCR_GENINFO_LO, vtophys(&sc->ti_rdata->ti_info));
1851
1852 /* Load the firmware into SRAM. */
1853 ti_loadfw(sc);
1854
1855 /* Set up the contents of the general info and ring control blocks. */
1856
1857 /* Set up the event ring and producer pointer. */
1858 rcb = &sc->ti_rdata->ti_info.ti_ev_rcb;
1859
1860 TI_HOSTADDR(rcb->ti_hostaddr) = vtophys(&sc->ti_rdata->ti_event_ring);
1861 rcb->ti_flags = 0;
1862 TI_HOSTADDR(sc->ti_rdata->ti_info.ti_ev_prodidx_ptr) =
1863 vtophys(&sc->ti_ev_prodidx);
1864 sc->ti_ev_prodidx.ti_idx = 0;
1865 CSR_WRITE_4(sc, TI_GCR_EVENTCONS_IDX, 0);
1866 sc->ti_ev_saved_considx = 0;
1867
1868 /* Set up the command ring and producer mailbox. */
1869 rcb = &sc->ti_rdata->ti_info.ti_cmd_rcb;
1870
1871 sc->ti_rdata->ti_cmd_ring =

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

1881 sc->ti_cmd_saved_prodidx = 0;
1882
1883 /*
1884 * Assign the address of the stats refresh buffer.
1885 * We re-use the current stats buffer for this to
1886 * conserve memory.
1887 */
1888 TI_HOSTADDR(sc->ti_rdata->ti_info.ti_refresh_stats_ptr) =
1889 vtophys(&sc->ti_rdata->ti_info.ti_stats);
1890
1891 /* Set up the standard receive ring. */
1892 rcb = &sc->ti_rdata->ti_info.ti_std_rx_rcb;
1893 TI_HOSTADDR(rcb->ti_hostaddr) = vtophys(&sc->ti_rdata->ti_rx_std_ring);
1894 rcb->ti_max_len = TI_FRAMELEN;
1895 rcb->ti_flags = 0;
1896 if (sc->arpcom.ac_if.if_hwassist)
1897 rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM |
1898 TI_RCB_FLAG_IP_CKSUM | TI_RCB_FLAG_NO_PHDR_CKSUM;
1899 rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
1900
1901 /* Set up the jumbo receive ring. */
1902 rcb = &sc->ti_rdata->ti_info.ti_jumbo_rx_rcb;
1903 TI_HOSTADDR(rcb->ti_hostaddr) =
1904 vtophys(&sc->ti_rdata->ti_rx_jumbo_ring);
1905
1906#ifdef TI_PRIVATE_JUMBOS
1907 rcb->ti_max_len = TI_JUMBO_FRAMELEN;
1908 rcb->ti_flags = 0;
1909#else
1910 rcb->ti_max_len = PAGE_SIZE;
1911 rcb->ti_flags = TI_RCB_FLAG_USE_EXT_RX_BD;
1912#endif
1913 if (sc->arpcom.ac_if.if_hwassist)
1914 rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM |
1915 TI_RCB_FLAG_IP_CKSUM | TI_RCB_FLAG_NO_PHDR_CKSUM;
1916 rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
1917
1918 /*
1919 * Set up the mini ring. Only activated on the
1920 * Tigon 2 but the slot in the config block is
1921 * still there on the Tigon 1.
1922 */
1923 rcb = &sc->ti_rdata->ti_info.ti_mini_rx_rcb;
1924 TI_HOSTADDR(rcb->ti_hostaddr) =
1925 vtophys(&sc->ti_rdata->ti_rx_mini_ring);
1926 rcb->ti_max_len = MHLEN - ETHER_ALIGN;
1927 if (sc->ti_hwrev == TI_HWREV_TIGON)
1928 rcb->ti_flags = TI_RCB_FLAG_RING_DISABLED;
1929 else
1930 rcb->ti_flags = 0;
1931 if (sc->arpcom.ac_if.if_hwassist)
1932 rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM |
1933 TI_RCB_FLAG_IP_CKSUM | TI_RCB_FLAG_NO_PHDR_CKSUM;
1934 rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
1935
1936 /*
1937 * Set up the receive return ring.
1938 */
1939 rcb = &sc->ti_rdata->ti_info.ti_return_rcb;
1940 TI_HOSTADDR(rcb->ti_hostaddr) =
1941 vtophys(&sc->ti_rdata->ti_rx_return_ring);
1942 rcb->ti_flags = 0;
1943 rcb->ti_max_len = TI_RETURN_RING_CNT;
1944 TI_HOSTADDR(sc->ti_rdata->ti_info.ti_return_prodidx_ptr) =
1945 vtophys(&sc->ti_return_prodidx);
1946
1947 /*
1948 * Set up the tx ring. Note: for the Tigon 2, we have the option
1949 * of putting the transmit ring in the host's address space and
1950 * letting the chip DMA it instead of leaving the ring in the NIC's
1951 * memory and accessing it through the shared memory region. We
1952 * do this for the Tigon 2, but it doesn't work on the Tigon 1,
1953 * so we have to revert to the shared memory scheme if we detect

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

1968 rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
1969 if (sc->arpcom.ac_if.if_hwassist)
1970 rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM |
1971 TI_RCB_FLAG_IP_CKSUM | TI_RCB_FLAG_NO_PHDR_CKSUM;
1972 rcb->ti_max_len = TI_TX_RING_CNT;
1973 if (sc->ti_hwrev == TI_HWREV_TIGON)
1974 TI_HOSTADDR(rcb->ti_hostaddr) = TI_TX_RING_BASE;
1975 else
1976 TI_HOSTADDR(rcb->ti_hostaddr) =
1977 vtophys(&sc->ti_rdata->ti_tx_ring);
1978 TI_HOSTADDR(sc->ti_rdata->ti_info.ti_tx_considx_ptr) =
1979 vtophys(&sc->ti_tx_considx);
1980
1981 /* Set up tuneables */
1982#if 0
1983 if (ifp->if_mtu > (ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN))
1984 CSR_WRITE_4(sc, TI_GCR_RX_COAL_TICKS,
1985 (sc->ti_rx_coal_ticks / 10));
1986 else
1987#endif

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

1997 CSR_WRITE_4(sc, TI_MB_HOSTINTR, 0);
1998
1999 /* Start CPU. */
2000 TI_CLRBIT(sc, TI_CPU_STATE, (TI_CPUSTATE_HALT|TI_CPUSTATE_STEP));
2001
2002 return (0);
2003}
2004
2005/*
2006 * Probe for a Tigon chip. Check the PCI vendor and device IDs
2007 * against our list and return its name if we find a match.
2008 */
2009static int
2010ti_probe(dev)
2011 device_t dev;
2012{

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

2103 if (ti_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr,
2104 TI_EE_MAC_OFFSET + 2, ETHER_ADDR_LEN)) {
2105 printf("ti%d: failed to read station address\n", unit);
2106 error = ENXIO;
2107 goto fail;
2108 }
2109
2110 /* Allocate the general information block and ring buffers. */
2111 sc->ti_rdata = contigmalloc(sizeof(struct ti_ring_data), M_DEVBUF,
2112 M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
2113
2114 if (sc->ti_rdata == NULL) {
2115 printf("ti%d: no memory for list buffers!\n", sc->ti_unit);
2116 error = ENXIO;
2117 goto fail;
2118 }
2119
2120 bzero(sc->ti_rdata, sizeof(struct ti_ring_data));
2121
2122 /* Try to allocate memory for jumbo buffers. */
2123#ifdef TI_PRIVATE_JUMBOS
2124 if (ti_alloc_jumbo_mem(sc)) {
2125 printf("ti%d: jumbo buffer allocation failed\n", sc->ti_unit);
2126 error = ENXIO;
2127 goto fail;

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

2255 /* These should only be active if attach succeeded */
2256 if (device_is_attached(dev)) {
2257 ti_stop(sc);
2258 ether_ifdetach(ifp);
2259 bus_generic_detach(dev);
2260 }
2261 ifmedia_removeall(&sc->ifmedia);
2262
2263 if (sc->ti_intrhand)
2264 bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);
2265 if (sc->ti_irq)
2266 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
2267 if (sc->ti_res) {
2268 bus_release_resource(dev, SYS_RES_MEMORY, TI_PCI_LOMEM,
2269 sc->ti_res);
2270 }

--- 1200 unchanged lines hidden ---