Deleted Added
full compact
if_xl.c (105675) if_xl.c (106936)
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 * $FreeBSD: head/sys/pci/if_xl.c 105675 2002-10-22 02:33:50Z silby $
32 * $FreeBSD: head/sys/pci/if_xl.c 106936 2002-11-14 23:49:09Z sam $
33 */
34
35/*
36 * 3Com 3c90x Etherlink XL PCI NIC driver
37 *
38 * Supports the 3Com "boomerang", "cyclone" and "hurricane" PCI
39 * bus-master chips (3c90x cards and embedded controllers) including
40 * the following:

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

147 * might not work on some devices.
148 */
149#define XL_USEIOSPACE
150
151#include <pci/if_xlreg.h>
152
153#if !defined(lint)
154static const char rcsid[] =
33 */
34
35/*
36 * 3Com 3c90x Etherlink XL PCI NIC driver
37 *
38 * Supports the 3Com "boomerang", "cyclone" and "hurricane" PCI
39 * bus-master chips (3c90x cards and embedded controllers) including
40 * the following:

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

147 * might not work on some devices.
148 */
149#define XL_USEIOSPACE
150
151#include <pci/if_xlreg.h>
152
153#if !defined(lint)
154static const char rcsid[] =
155 "$FreeBSD: head/sys/pci/if_xl.c 105675 2002-10-22 02:33:50Z silby $";
155 "$FreeBSD: head/sys/pci/if_xl.c 106936 2002-11-14 23:49:09Z sam $";
156#endif
157
158#define XL905B_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP)
159
160/*
161 * Various supported device vendors/types and their names.
162 */
163static struct xl_type xl_devs[] = {

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

1628 if (sc->xl_flags & XL_FLAG_NO_XCVR_PWR) {
1629 XL_SEL_WIN(0);
1630 CSR_WRITE_2(sc, XL_W0_MFG_ID, XL_NO_XCVR_PWR_MAGICBITS);
1631 }
1632
1633 /*
1634 * Call MI attach routine.
1635 */
156#endif
157
158#define XL905B_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP)
159
160/*
161 * Various supported device vendors/types and their names.
162 */
163static struct xl_type xl_devs[] = {

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

1628 if (sc->xl_flags & XL_FLAG_NO_XCVR_PWR) {
1629 XL_SEL_WIN(0);
1630 CSR_WRITE_2(sc, XL_W0_MFG_ID, XL_NO_XCVR_PWR_MAGICBITS);
1631 }
1632
1633 /*
1634 * Call MI attach routine.
1635 */
1636 ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
1636 ether_ifattach(ifp, eaddr);
1637 XL_UNLOCK(sc);
1638 return(0);
1639
1640fail:
1641 XL_UNLOCK(sc);
1642 mtx_destroy(&sc->xl_mtx);
1643
1644 return(error);

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

1652 struct ifnet *ifp;
1653
1654 sc = device_get_softc(dev);
1655 XL_LOCK(sc);
1656 ifp = &sc->arpcom.ac_if;
1657
1658 xl_reset(sc);
1659 xl_stop(sc);
1637 XL_UNLOCK(sc);
1638 return(0);
1639
1640fail:
1641 XL_UNLOCK(sc);
1642 mtx_destroy(&sc->xl_mtx);
1643
1644 return(error);

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

1652 struct ifnet *ifp;
1653
1654 sc = device_get_softc(dev);
1655 XL_LOCK(sc);
1656 ifp = &sc->arpcom.ac_if;
1657
1658 xl_reset(sc);
1659 xl_stop(sc);
1660 ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
1660 ether_ifdetach(ifp);
1661
1662 /* Delete any miibus and phy devices attached to this interface */
1663 if (sc->xl_miibus != NULL) {
1664 bus_generic_detach(dev);
1665 device_delete_child(dev, sc->xl_miibus);
1666 }
1667
1668 bus_teardown_intr(dev, sc->xl_irq, sc->xl_intrhand);

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

1842/*
1843 * A frame has been uploaded: pass the resulting mbuf chain up to
1844 * the higher level protocols.
1845 */
1846static void
1847xl_rxeof(sc)
1848 struct xl_softc *sc;
1849{
1661
1662 /* Delete any miibus and phy devices attached to this interface */
1663 if (sc->xl_miibus != NULL) {
1664 bus_generic_detach(dev);
1665 device_delete_child(dev, sc->xl_miibus);
1666 }
1667
1668 bus_teardown_intr(dev, sc->xl_irq, sc->xl_intrhand);

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

1842/*
1843 * A frame has been uploaded: pass the resulting mbuf chain up to
1844 * the higher level protocols.
1845 */
1846static void
1847xl_rxeof(sc)
1848 struct xl_softc *sc;
1849{
1850 struct ether_header *eh;
1851 struct mbuf *m;
1852 struct ifnet *ifp;
1853 struct xl_chain_onefrag *cur_rx;
1854 int total_len = 0;
1855 u_int32_t rxstat;
1856
1857 ifp = &sc->arpcom.ac_if;
1858

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

1900 */
1901 if (xl_newbuf(sc, cur_rx) == ENOBUFS) {
1902 ifp->if_ierrors++;
1903 cur_rx->xl_ptr->xl_status = 0;
1904 continue;
1905 }
1906
1907 ifp->if_ipackets++;
1850 struct mbuf *m;
1851 struct ifnet *ifp;
1852 struct xl_chain_onefrag *cur_rx;
1853 int total_len = 0;
1854 u_int32_t rxstat;
1855
1856 ifp = &sc->arpcom.ac_if;
1857

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

1899 */
1900 if (xl_newbuf(sc, cur_rx) == ENOBUFS) {
1901 ifp->if_ierrors++;
1902 cur_rx->xl_ptr->xl_status = 0;
1903 continue;
1904 }
1905
1906 ifp->if_ipackets++;
1908 eh = mtod(m, struct ether_header *);
1909 m->m_pkthdr.rcvif = ifp;
1910 m->m_pkthdr.len = m->m_len = total_len;
1911
1907 m->m_pkthdr.rcvif = ifp;
1908 m->m_pkthdr.len = m->m_len = total_len;
1909
1912 /* Remove header from mbuf and pass it on. */
1913 m_adj(m, sizeof(struct ether_header));
1914
1915 if (sc->xl_type == XL_TYPE_905B) {
1916 /* Do IP checksum checking. */
1917 if (rxstat & XL_RXSTAT_IPCKOK)
1918 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED;
1919 if (!(rxstat & XL_RXSTAT_IPCKERR))
1920 m->m_pkthdr.csum_flags |= CSUM_IP_VALID;
1921 if ((rxstat & XL_RXSTAT_TCPCOK &&
1922 !(rxstat & XL_RXSTAT_TCPCKERR)) ||
1923 (rxstat & XL_RXSTAT_UDPCKOK &&
1924 !(rxstat & XL_RXSTAT_UDPCKERR))) {
1925 m->m_pkthdr.csum_flags |=
1926 CSUM_DATA_VALID|CSUM_PSEUDO_HDR;
1927 m->m_pkthdr.csum_data = 0xffff;
1928 }
1929 }
1910 if (sc->xl_type == XL_TYPE_905B) {
1911 /* Do IP checksum checking. */
1912 if (rxstat & XL_RXSTAT_IPCKOK)
1913 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED;
1914 if (!(rxstat & XL_RXSTAT_IPCKERR))
1915 m->m_pkthdr.csum_flags |= CSUM_IP_VALID;
1916 if ((rxstat & XL_RXSTAT_TCPCOK &&
1917 !(rxstat & XL_RXSTAT_TCPCKERR)) ||
1918 (rxstat & XL_RXSTAT_UDPCKOK &&
1919 !(rxstat & XL_RXSTAT_UDPCKERR))) {
1920 m->m_pkthdr.csum_flags |=
1921 CSUM_DATA_VALID|CSUM_PSEUDO_HDR;
1922 m->m_pkthdr.csum_data = 0xffff;
1923 }
1924 }
1930 ether_input(ifp, eh, m);
1925
1926 (*ifp->if_input)(ifp, m);
1931 }
1932
1933 /*
1934 * Handle the 'end of channel' condition. When the upload
1935 * engine hits the end of the RX ring, it will stall. This
1936 * is our cue to flush the RX ring, reload the uplist pointer
1937 * register and unstall the engine.
1938 * XXX This is actually a little goofy. With the ThunderLAN

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

2359 prev->xl_ptr->xl_next = vtophys(cur_tx->xl_ptr);
2360 }
2361 prev = cur_tx;
2362
2363 /*
2364 * If there's a BPF listener, bounce a copy of this frame
2365 * to him.
2366 */
1927 }
1928
1929 /*
1930 * Handle the 'end of channel' condition. When the upload
1931 * engine hits the end of the RX ring, it will stall. This
1932 * is our cue to flush the RX ring, reload the uplist pointer
1933 * register and unstall the engine.
1934 * XXX This is actually a little goofy. With the ThunderLAN

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

2355 prev->xl_ptr->xl_next = vtophys(cur_tx->xl_ptr);
2356 }
2357 prev = cur_tx;
2358
2359 /*
2360 * If there's a BPF listener, bounce a copy of this frame
2361 * to him.
2362 */
2367 if (ifp->if_bpf)
2368 bpf_mtap(ifp, cur_tx->xl_mbuf);
2363 BPF_MTAP(ifp, cur_tx->xl_mbuf);
2369 }
2370
2371 /*
2372 * If there are no packets queued, bail.
2373 */
2374 if (cur_tx == NULL) {
2375 XL_UNLOCK(sc);
2376 return;

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

2521 if (prev != NULL)
2522 prev->xl_ptr->xl_next = cur_tx->xl_phys;
2523 prev = cur_tx;
2524
2525 /*
2526 * If there's a BPF listener, bounce a copy of this frame
2527 * to him.
2528 */
2364 }
2365
2366 /*
2367 * If there are no packets queued, bail.
2368 */
2369 if (cur_tx == NULL) {
2370 XL_UNLOCK(sc);
2371 return;

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

2516 if (prev != NULL)
2517 prev->xl_ptr->xl_next = cur_tx->xl_phys;
2518 prev = cur_tx;
2519
2520 /*
2521 * If there's a BPF listener, bounce a copy of this frame
2522 * to him.
2523 */
2529 if (ifp->if_bpf)
2530 bpf_mtap(ifp, cur_tx->xl_mbuf);
2524 BPF_MTAP(ifp, cur_tx->xl_mbuf);
2531
2532 XL_INC(idx, XL_TX_LIST_CNT);
2533 sc->xl_cdata.xl_tx_cnt++;
2534 }
2535
2536 /*
2537 * If there are no packets queued, bail.
2538 */

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

2890 struct ifreq *ifr = (struct ifreq *) data;
2891 int error = 0;
2892 struct mii_data *mii = NULL;
2893 u_int8_t rxfilt;
2894
2895 XL_LOCK(sc);
2896
2897 switch(command) {
2525
2526 XL_INC(idx, XL_TX_LIST_CNT);
2527 sc->xl_cdata.xl_tx_cnt++;
2528 }
2529
2530 /*
2531 * If there are no packets queued, bail.
2532 */

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

2884 struct ifreq *ifr = (struct ifreq *) data;
2885 int error = 0;
2886 struct mii_data *mii = NULL;
2887 u_int8_t rxfilt;
2888
2889 XL_LOCK(sc);
2890
2891 switch(command) {
2898 case SIOCSIFADDR:
2899 case SIOCGIFADDR:
2900 case SIOCSIFMTU:
2901 error = ether_ioctl(ifp, command, data);
2902 break;
2903 case SIOCSIFFLAGS:
2904 XL_SEL_WIN(5);
2905 rxfilt = CSR_READ_1(sc, XL_W5_RX_FILTER);
2906 if (ifp->if_flags & IFF_UP) {
2907 if (ifp->if_flags & IFF_RUNNING &&
2908 ifp->if_flags & IFF_PROMISC &&
2909 !(sc->xl_if_flags & IFF_PROMISC)) {
2910 rxfilt |= XL_RXFILTER_ALLFRAMES;

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

2942 if (mii == NULL)
2943 error = ifmedia_ioctl(ifp, ifr,
2944 &sc->ifmedia, command);
2945 else
2946 error = ifmedia_ioctl(ifp, ifr,
2947 &mii->mii_media, command);
2948 break;
2949 default:
2892 case SIOCSIFFLAGS:
2893 XL_SEL_WIN(5);
2894 rxfilt = CSR_READ_1(sc, XL_W5_RX_FILTER);
2895 if (ifp->if_flags & IFF_UP) {
2896 if (ifp->if_flags & IFF_RUNNING &&
2897 ifp->if_flags & IFF_PROMISC &&
2898 !(sc->xl_if_flags & IFF_PROMISC)) {
2899 rxfilt |= XL_RXFILTER_ALLFRAMES;

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

2931 if (mii == NULL)
2932 error = ifmedia_ioctl(ifp, ifr,
2933 &sc->ifmedia, command);
2934 else
2935 error = ifmedia_ioctl(ifp, ifr,
2936 &mii->mii_media, command);
2937 break;
2938 default:
2950 error = EINVAL;
2939 error = ether_ioctl(ifp, command, data);
2951 break;
2952 }
2953
2954 XL_UNLOCK(sc);
2955
2956 return(error);
2957}
2958

--- 156 unchanged lines hidden ---
2940 break;
2941 }
2942
2943 XL_UNLOCK(sc);
2944
2945 return(error);
2946}
2947

--- 156 unchanged lines hidden ---