Deleted Added
full compact
if_ti.c (227505) if_ti.c (227509)
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>
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 227505 2011-11-14 18:40:04Z yongari $");
80__FBSDID("$FreeBSD: head/sys/dev/ti/if_ti.c 227509 2011-11-14 19:10:20Z yongari $");
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>

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

120#include <dev/pci/pcireg.h>
121#include <dev/pci/pcivar.h>
122
123#include <sys/tiio.h>
124#include <dev/ti/if_tireg.h>
125#include <dev/ti/ti_fw.h>
126#include <dev/ti/ti_fw2.h>
127
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>

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

120#include <dev/pci/pcireg.h>
121#include <dev/pci/pcivar.h>
122
123#include <sys/tiio.h>
124#include <dev/ti/if_tireg.h>
125#include <dev/ti/ti_fw.h>
126#include <dev/ti/ti_fw2.h>
127
128#include <sys/sysctl.h>
129
128#define TI_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_IP_FRAGS)
129/*
130 * We can only turn on header splitting if we're using extended receive
131 * BDs.
132 */
133#if defined(TI_JUMBO_HDRSPLIT) && !defined(TI_SF_BUF_JUMBO)
134#error "options TI_JUMBO_HDRSPLIT requires TI_SF_BUF_JUMBO"
135#endif /* TI_JUMBO_HDRSPLIT && !TI_SF_BUF_JUMBO */

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

242static int ti_chipinit(struct ti_softc *);
243static int ti_gibinit(struct ti_softc *);
244
245#ifdef TI_JUMBO_HDRSPLIT
246static __inline void ti_hdr_split(struct mbuf *top, int hdr_len, int pkt_len,
247 int idx);
248#endif /* TI_JUMBO_HDRSPLIT */
249
130#define TI_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_IP_FRAGS)
131/*
132 * We can only turn on header splitting if we're using extended receive
133 * BDs.
134 */
135#if defined(TI_JUMBO_HDRSPLIT) && !defined(TI_SF_BUF_JUMBO)
136#error "options TI_JUMBO_HDRSPLIT requires TI_SF_BUF_JUMBO"
137#endif /* TI_JUMBO_HDRSPLIT && !TI_SF_BUF_JUMBO */

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

244static int ti_chipinit(struct ti_softc *);
245static int ti_gibinit(struct ti_softc *);
246
247#ifdef TI_JUMBO_HDRSPLIT
248static __inline void ti_hdr_split(struct mbuf *top, int hdr_len, int pkt_len,
249 int idx);
250#endif /* TI_JUMBO_HDRSPLIT */
251
252static void ti_sysctl_node(struct ti_softc *);
253
250static device_method_t ti_methods[] = {
251 /* Device interface */
252 DEVMETHOD(device_probe, ti_probe),
253 DEVMETHOD(device_attach, ti_attach),
254 DEVMETHOD(device_detach, ti_detach),
255 DEVMETHOD(device_shutdown, ti_shutdown),
256 { 0, 0 }
257};

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

2078 else
2079 TI_HOSTADDR(rcb->ti_hostaddr) = rdphys + TI_RD_OFF(ti_tx_ring);
2080 TI_HOSTADDR(sc->ti_rdata->ti_info.ti_tx_considx_ptr) =
2081 rdphys + TI_RD_OFF(ti_tx_considx_r);
2082
2083 bus_dmamap_sync(sc->ti_rdata_dmat, sc->ti_rdata_dmamap,
2084 BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
2085
254static device_method_t ti_methods[] = {
255 /* Device interface */
256 DEVMETHOD(device_probe, ti_probe),
257 DEVMETHOD(device_attach, ti_attach),
258 DEVMETHOD(device_detach, ti_detach),
259 DEVMETHOD(device_shutdown, ti_shutdown),
260 { 0, 0 }
261};

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

2082 else
2083 TI_HOSTADDR(rcb->ti_hostaddr) = rdphys + TI_RD_OFF(ti_tx_ring);
2084 TI_HOSTADDR(sc->ti_rdata->ti_info.ti_tx_considx_ptr) =
2085 rdphys + TI_RD_OFF(ti_tx_considx_r);
2086
2087 bus_dmamap_sync(sc->ti_rdata_dmat, sc->ti_rdata_dmamap,
2088 BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
2089
2086 /* Set up tuneables */
2090 /* Set up tunables */
2087#if 0
2088 if (ifp->if_mtu > (ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN))
2089 CSR_WRITE_4(sc, TI_GCR_RX_COAL_TICKS,
2090 (sc->ti_rx_coal_ticks / 10));
2091 else
2092#endif
2093 CSR_WRITE_4(sc, TI_GCR_RX_COAL_TICKS, sc->ti_rx_coal_ticks);
2094 CSR_WRITE_4(sc, TI_GCR_TX_COAL_TICKS, sc->ti_tx_coal_ticks);

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

2347 if (pci_get_vendor(dev) == ALT_VENDORID &&
2348 pci_get_device(dev) == ALT_DEVICEID_ACENIC_COPPER)
2349 sc->ti_copper = 1;
2350 /* Ok, it's not the only copper card available. */
2351 if (pci_get_vendor(dev) == NG_VENDORID &&
2352 pci_get_device(dev) == NG_DEVICEID_GA620T)
2353 sc->ti_copper = 1;
2354
2091#if 0
2092 if (ifp->if_mtu > (ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN))
2093 CSR_WRITE_4(sc, TI_GCR_RX_COAL_TICKS,
2094 (sc->ti_rx_coal_ticks / 10));
2095 else
2096#endif
2097 CSR_WRITE_4(sc, TI_GCR_RX_COAL_TICKS, sc->ti_rx_coal_ticks);
2098 CSR_WRITE_4(sc, TI_GCR_TX_COAL_TICKS, sc->ti_tx_coal_ticks);

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

2351 if (pci_get_vendor(dev) == ALT_VENDORID &&
2352 pci_get_device(dev) == ALT_DEVICEID_ACENIC_COPPER)
2353 sc->ti_copper = 1;
2354 /* Ok, it's not the only copper card available. */
2355 if (pci_get_vendor(dev) == NG_VENDORID &&
2356 pci_get_device(dev) == NG_DEVICEID_GA620T)
2357 sc->ti_copper = 1;
2358
2355 /* Set default tuneable values. */
2356 sc->ti_stat_ticks = 2 * TI_TICKS_PER_SEC;
2357#if 0
2358 sc->ti_rx_coal_ticks = TI_TICKS_PER_SEC / 5000;
2359#endif
2360 sc->ti_rx_coal_ticks = 170;
2361 sc->ti_tx_coal_ticks = TI_TICKS_PER_SEC / 500;
2362 sc->ti_rx_max_coal_bds = 64;
2363#if 0
2364 sc->ti_tx_max_coal_bds = 128;
2365#endif
2366 sc->ti_tx_max_coal_bds = 32;
2367 sc->ti_tx_buf_ratio = 21;
2359 /* Set default tunable values. */
2360 ti_sysctl_node(sc);
2368
2369 /* Set up ifnet structure */
2370 ifp->if_softc = sc;
2371 if_initname(ifp, device_get_name(dev), device_get_unit(dev));
2372 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
2373 ifp->if_ioctl = ti_ioctl;
2374 ifp->if_start = ti_start;
2375 ifp->if_init = ti_init;

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

3853
3854 sc = device_get_softc(dev);
3855 TI_LOCK(sc);
3856 ti_chipinit(sc);
3857 TI_UNLOCK(sc);
3858
3859 return (0);
3860}
2361
2362 /* Set up ifnet structure */
2363 ifp->if_softc = sc;
2364 if_initname(ifp, device_get_name(dev), device_get_unit(dev));
2365 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
2366 ifp->if_ioctl = ti_ioctl;
2367 ifp->if_start = ti_start;
2368 ifp->if_init = ti_init;

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

3846
3847 sc = device_get_softc(dev);
3848 TI_LOCK(sc);
3849 ti_chipinit(sc);
3850 TI_UNLOCK(sc);
3851
3852 return (0);
3853}
3854
3855static void
3856ti_sysctl_node(struct ti_softc *sc)
3857{
3858 struct sysctl_ctx_list *ctx;
3859 struct sysctl_oid_list *child;
3860
3861 ctx = device_get_sysctl_ctx(sc->ti_dev);
3862 child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->ti_dev));
3863
3864 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "rx_coal_ticks", CTLFLAG_RW,
3865 &sc->ti_rx_coal_ticks, 0, "Receive coalcesced ticks");
3866 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "rx_max_coal_bds", CTLFLAG_RW,
3867 &sc->ti_rx_max_coal_bds, 0, "Receive max coalcesced BDs");
3868
3869 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "tx_coal_ticks", CTLFLAG_RW,
3870 &sc->ti_tx_coal_ticks, 0, "Send coalcesced ticks");
3871 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "tx_max_coal_bds", CTLFLAG_RW,
3872 &sc->ti_tx_max_coal_bds, 0, "Send max coalcesced BDs");
3873 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "tx_buf_ratio", CTLFLAG_RW,
3874 &sc->ti_tx_buf_ratio, 0,
3875 "Ratio of NIC memory devoted to TX buffer");
3876
3877 SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "stat_ticks", CTLFLAG_RW,
3878 &sc->ti_stat_ticks, 0,
3879 "Number of clock ticks for statistics update interval");
3880
3881 /* Pull in device tunables. */
3882 sc->ti_rx_coal_ticks = 170;
3883 resource_int_value(device_get_name(sc->ti_dev),
3884 device_get_unit(sc->ti_dev), "rx_coal_ticks",
3885 &sc->ti_rx_coal_ticks);
3886 sc->ti_rx_max_coal_bds = 64;
3887 resource_int_value(device_get_name(sc->ti_dev),
3888 device_get_unit(sc->ti_dev), "rx_max_coal_bds",
3889 &sc->ti_rx_max_coal_bds);
3890
3891 sc->ti_tx_coal_ticks = TI_TICKS_PER_SEC / 500;
3892 resource_int_value(device_get_name(sc->ti_dev),
3893 device_get_unit(sc->ti_dev), "tx_coal_ticks",
3894 &sc->ti_tx_coal_ticks);
3895 sc->ti_tx_max_coal_bds = 32;
3896 resource_int_value(device_get_name(sc->ti_dev),
3897 device_get_unit(sc->ti_dev), "tx_max_coal_bds",
3898 &sc->ti_tx_max_coal_bds);
3899 sc->ti_tx_buf_ratio = 21;
3900 resource_int_value(device_get_name(sc->ti_dev),
3901 device_get_unit(sc->ti_dev), "tx_buf_ratio",
3902 &sc->ti_tx_buf_ratio);
3903
3904 sc->ti_stat_ticks = 2 * TI_TICKS_PER_SEC;
3905 resource_int_value(device_get_name(sc->ti_dev),
3906 device_get_unit(sc->ti_dev), "stat_ticks",
3907 &sc->ti_stat_ticks);
3908}