Deleted Added
sdiff udiff text old ( 106627 ) new ( 106936 )
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

--- 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 * $FreeBSD: head/sys/dev/ti/if_ti.c 106936 2002-11-14 23:49:09Z sam $
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>

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

147 * BDs.
148 */
149#if defined(TI_JUMBO_HDRSPLIT) && defined(TI_PRIVATE_JUMBOS)
150#error "options TI_JUMBO_HDRSPLIT and TI_PRIVATE_JUMBOS are mutually exclusive"
151#endif /* TI_JUMBO_HDRSPLIT && TI_JUMBO_HDRSPLIT */
152
153#if !defined(lint)
154static const char rcsid[] =
155 "$FreeBSD: head/sys/dev/ti/if_ti.c 106936 2002-11-14 23:49:09Z sam $";
156#endif
157
158struct ti_softc *tis[8];
159
160typedef enum {
161 TI_SWAP_HTON,
162 TI_SWAP_NTOH
163} ti_swap_type;

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

2122#endif
2123
2124 sc = device_get_softc(dev);
2125 unit = device_get_unit(dev);
2126 bzero(sc, sizeof(struct ti_softc));
2127
2128 mtx_init(&sc->ti_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
2129 MTX_DEF | MTX_RECURSE);
2130 sc->arpcom.ac_if.if_capabilities = IFCAP_HWCSUM | IFCAP_VLAN_HWTAGGING;
2131 sc->arpcom.ac_if.if_capenable = sc->arpcom.ac_if.if_capabilities;
2132
2133 /*
2134 * Map control/status registers.
2135 */
2136 pci_enable_busmaster(dev);
2137 pci_enable_io(dev, SYS_RES_MEMORY);
2138 command = pci_read_config(dev, PCIR_COMMAND, 4);

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

2361
2362 /* Register the device */
2363 sc->dev = make_dev(&ti_cdevsw, sc->ti_unit, UID_ROOT, GID_OPERATOR,
2364 0600, "ti%d", sc->ti_unit);
2365
2366 /*
2367 * Call MI attach routine.
2368 */
2369 ether_ifattach(ifp, sc->arpcom.ac_enaddr);
2370 return(0);
2371
2372fail:
2373 mtx_destroy(&sc->ti_mtx);
2374 return(error);
2375}
2376
2377/*

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

2411
2412 if (ti_unref_special(dev))
2413 return EBUSY;
2414
2415 sc = device_get_softc(dev);
2416 TI_LOCK(sc);
2417 ifp = &sc->arpcom.ac_if;
2418
2419 ether_ifdetach(ifp);
2420 ti_stop(sc);
2421
2422 bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);
2423 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
2424 bus_release_resource(dev, SYS_RES_MEMORY, TI_PCI_LOMEM, sc->ti_res);
2425
2426#ifdef TI_PRIVATE_JUMBOS
2427 contigfree(sc->ti_cdata.ti_jumbo_buf, TI_JMEM, M_DEVBUF);

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

2588 m->m_len = cur_rx->ti_len;
2589 }
2590
2591 m->m_pkthdr.len = cur_rx->ti_len;
2592 ifp->if_ipackets++;
2593 eh = mtod(m, struct ether_header *);
2594 m->m_pkthdr.rcvif = ifp;
2595
2596 if (ifp->if_hwassist) {
2597 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED |
2598 CSUM_DATA_VALID;
2599 if ((cur_rx->ti_ip_cksum ^ 0xffff) == 0)
2600 m->m_pkthdr.csum_flags |= CSUM_IP_VALID;
2601 m->m_pkthdr.csum_data = cur_rx->ti_tcp_udp_cksum;
2602 }
2603
2604 /*
2605 * If we received a packet with a vlan tag,
2606 * tag it before passing the packet upward.
2607 */
2608 if (have_tag)
2609 VLAN_INPUT_TAG(ifp, m, vlan_tag, continue);
2610 (*ifp->if_input)(ifp, m);
2611 }
2612
2613 /* Only necessary on the Tigon 1. */
2614 if (sc->ti_hwrev == TI_HWREV_TIGON)
2615 CSR_WRITE_4(sc, TI_GCR_RXRETURNCONS_IDX,
2616 sc->ti_rx_saved_considx);
2617
2618 TI_UPDATE_STDPROD(sc, sc->ti_std);

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

2743 struct ti_softc *sc;
2744 struct mbuf *m_head;
2745 u_int32_t *txidx;
2746{
2747 struct ti_tx_desc *f = NULL;
2748 struct mbuf *m;
2749 u_int32_t frag, cur, cnt = 0;
2750 u_int16_t csum_flags = 0;
2751 struct m_tag *mtag;
2752
2753 m = m_head;
2754 cur = frag = *txidx;
2755
2756 if (m_head->m_pkthdr.csum_flags) {
2757 if (m_head->m_pkthdr.csum_flags & CSUM_IP)
2758 csum_flags |= TI_BDFLAG_IP_CKSUM;
2759 if (m_head->m_pkthdr.csum_flags & (CSUM_TCP | CSUM_UDP))
2760 csum_flags |= TI_BDFLAG_TCP_UDP_CKSUM;
2761 if (m_head->m_flags & M_LASTFRAG)
2762 csum_flags |= TI_BDFLAG_IP_FRAG_END;
2763 else if (m_head->m_flags & M_FRAG)
2764 csum_flags |= TI_BDFLAG_IP_FRAG;
2765 }
2766
2767 mtag = VLAN_OUTPUT_TAG(&sc->arpcom.ac_if, m);
2768
2769 /*
2770 * Start packing the mbufs in this chain into
2771 * the fragment pointers. Stop when we run out
2772 * of fragments or hit the end of the mbuf chain.
2773 */
2774 for (m = m_head; m != NULL; m = m->m_next) {
2775 if (m->m_len != 0) {
2776 if (sc->ti_hwrev == TI_HWREV_TIGON) {

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

2790 } else
2791 f = &sc->ti_rdata->ti_tx_ring[frag];
2792 if (sc->ti_cdata.ti_tx_chain[frag] != NULL)
2793 break;
2794 TI_HOSTADDR(f->ti_addr) = vtophys(mtod(m, vm_offset_t));
2795 f->ti_len = m->m_len;
2796 f->ti_flags = csum_flags;
2797
2798 if (mtag != NULL) {
2799 f->ti_flags |= TI_BDFLAG_VLAN_TAG;
2800 f->ti_vlan_tag = VLAN_TAG_VALUE(mtag) & 0xfff;
2801 } else {
2802 f->ti_vlan_tag = 0;
2803 }
2804
2805 /*
2806 * Sanity check: avoid coming within 16 descriptors
2807 * of the end of the ring.
2808 */

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

2883 ifp->if_flags |= IFF_OACTIVE;
2884 break;
2885 }
2886
2887 /*
2888 * If there's a BPF listener, bounce a copy of this frame
2889 * to him.
2890 */
2891 BPF_MTAP(ifp, m_head);
2892 }
2893
2894 /* Transmit */
2895 CSR_WRITE_4(sc, TI_MB_SENDPROD_IDX, prodidx);
2896
2897 /*
2898 * Set a timeout in case the chip goes out to lunch.
2899 */

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

3174 struct ti_softc *sc = ifp->if_softc;
3175 struct ifreq *ifr = (struct ifreq *) data;
3176 int mask, error = 0;
3177 struct ti_cmd_desc cmd;
3178
3179 TI_LOCK(sc);
3180
3181 switch(command) {
3182 case SIOCSIFMTU:
3183 if (ifr->ifr_mtu > TI_JUMBO_MTU)
3184 error = EINVAL;
3185 else {
3186 ifp->if_mtu = ifr->ifr_mtu;
3187 ti_init(sc);
3188 }
3189 break;

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

3236 else
3237 ifp->if_capenable |= IFCAP_HWCSUM;
3238 if (ifp->if_flags & IFF_RUNNING)
3239 ti_init(sc);
3240 }
3241 error = 0;
3242 break;
3243 default:
3244 error = ether_ioctl(ifp, command, data);
3245 break;
3246 }
3247
3248 TI_UNLOCK(sc);
3249
3250 return(error);
3251}
3252

--- 403 unchanged lines hidden ---