Deleted Added
full compact
if_sis.c (51533) if_sis.c (51583)
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_sis.c 51533 1999-09-22 06:08:11Z wpaul $
32 * $FreeBSD: head/sys/pci/if_sis.c 51583 1999-09-23 03:32:57Z wpaul $
33 */
34
35/*
36 * SiS 900/SiS 7016 fast ethernet PCI NIC driver. Datasheets are
37 * available from http://www.sis.com.tw.
38 *
39 * Written by Bill Paul <wpaul@ee.columbia.edu>
40 * Electrical Engineering Department

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

49 * transceiver while the 7016 requires an external transceiver chip.
50 * Both chips offer the standard bit-bang MII interface as well as
51 * an enchanced PHY interface which simplifies accessing MII registers.
52 *
53 * The only downside to this chipset is that RX descriptors must be
54 * longword aligned.
55 */
56
33 */
34
35/*
36 * SiS 900/SiS 7016 fast ethernet PCI NIC driver. Datasheets are
37 * available from http://www.sis.com.tw.
38 *
39 * Written by Bill Paul <wpaul@ee.columbia.edu>
40 * Electrical Engineering Department

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

49 * transceiver while the 7016 requires an external transceiver chip.
50 * Both chips offer the standard bit-bang MII interface as well as
51 * an enchanced PHY interface which simplifies accessing MII registers.
52 *
53 * The only downside to this chipset is that RX descriptors must be
54 * longword aligned.
55 */
56
57#include "bpf.h"
58
59#include <sys/param.h>
60#include <sys/systm.h>
61#include <sys/sockio.h>
62#include <sys/mbuf.h>
63#include <sys/malloc.h>
64#include <sys/kernel.h>
65#include <sys/socket.h>
66
67#include <net/if.h>
68#include <net/if_arp.h>
69#include <net/ethernet.h>
70#include <net/if_dl.h>
71#include <net/if_media.h>
72
57#include <sys/param.h>
58#include <sys/systm.h>
59#include <sys/sockio.h>
60#include <sys/mbuf.h>
61#include <sys/malloc.h>
62#include <sys/kernel.h>
63#include <sys/socket.h>
64
65#include <net/if.h>
66#include <net/if_arp.h>
67#include <net/ethernet.h>
68#include <net/if_dl.h>
69#include <net/if_media.h>
70
73#if NBPF > 0
74#include <net/bpf.h>
71#include <net/bpf.h>
75#endif
76
77#include <vm/vm.h> /* for vtophys */
78#include <vm/pmap.h> /* for vtophys */
79#include <machine/clock.h> /* for DELAY */
80#include <machine/bus_pio.h>
81#include <machine/bus_memio.h>
82#include <machine/bus.h>
83#include <machine/resource.h>

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

94
95#include <pci/if_sisreg.h>
96
97/* "controller miibus0" required. See GENERIC if you get errors here. */
98#include "miibus_if.h"
99
100#ifndef lint
101static const char rcsid[] =
72
73#include <vm/vm.h> /* for vtophys */
74#include <vm/pmap.h> /* for vtophys */
75#include <machine/clock.h> /* for DELAY */
76#include <machine/bus_pio.h>
77#include <machine/bus_memio.h>
78#include <machine/bus.h>
79#include <machine/resource.h>

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

90
91#include <pci/if_sisreg.h>
92
93/* "controller miibus0" required. See GENERIC if you get errors here. */
94#include "miibus_if.h"
95
96#ifndef lint
97static const char rcsid[] =
102 "$FreeBSD: head/sys/pci/if_sis.c 51533 1999-09-22 06:08:11Z wpaul $";
98 "$FreeBSD: head/sys/pci/if_sis.c 51583 1999-09-23 03:32:57Z wpaul $";
103#endif
104
105/*
106 * Various supported device vendors/types and their names.
107 */
108static struct sis_type sis_devs[] = {
109 { SIS_VENDORID, SIS_DEVICEID_900, "SiS 900 10/100BaseTX" },
110 { SIS_VENDORID, SIS_DEVICEID_7016, "SiS 7016 10/100BaseTX" },

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

700
701 /*
702 * Call MI attach routines.
703 */
704 if_attach(ifp);
705 ether_ifattach(ifp);
706 callout_handle_init(&sc->sis_stat_ch);
707
99#endif
100
101/*
102 * Various supported device vendors/types and their names.
103 */
104static struct sis_type sis_devs[] = {
105 { SIS_VENDORID, SIS_DEVICEID_900, "SiS 900 10/100BaseTX" },
106 { SIS_VENDORID, SIS_DEVICEID_7016, "SiS 7016 10/100BaseTX" },

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

696
697 /*
698 * Call MI attach routines.
699 */
700 if_attach(ifp);
701 ether_ifattach(ifp);
702 callout_handle_init(&sc->sis_stat_ch);
703
708#if NBPF > 0
709 bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
704 bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
710#endif
711
712fail:
713 splx(s);
714 return(error);
715}
716
717static int sis_detach(dev)
718 device_t dev;

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

906 ifp->if_ierrors++;
907 continue;
908 }
909 m_adj(m0, ETHER_ALIGN);
910 m = m0;
911
912 ifp->if_ipackets++;
913 eh = mtod(m, struct ether_header *);
705
706fail:
707 splx(s);
708 return(error);
709}
710
711static int sis_detach(dev)
712 device_t dev;

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

900 ifp->if_ierrors++;
901 continue;
902 }
903 m_adj(m0, ETHER_ALIGN);
904 m = m0;
905
906 ifp->if_ipackets++;
907 eh = mtod(m, struct ether_header *);
914#if NBPF > 0
908
915 /*
916 * Handle BPF listeners. Let the BPF user see the packet, but
917 * don't pass it up to the ether_input() layer unless it's
918 * a broadcast packet, multicast packet, matches our ethernet
919 * address or the interface is in promiscuous mode.
920 */
921 if (ifp->if_bpf) {
922 bpf_mtap(ifp, m);
923 if (ifp->if_flags & IFF_PROMISC &&
924 (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
925 ETHER_ADDR_LEN) && !(eh->ether_dhost[0] & 1))) {
926 m_freem(m);
927 continue;
928 }
929 }
909 /*
910 * Handle BPF listeners. Let the BPF user see the packet, but
911 * don't pass it up to the ether_input() layer unless it's
912 * a broadcast packet, multicast packet, matches our ethernet
913 * address or the interface is in promiscuous mode.
914 */
915 if (ifp->if_bpf) {
916 bpf_mtap(ifp, m);
917 if (ifp->if_flags & IFF_PROMISC &&
918 (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
919 ETHER_ADDR_LEN) && !(eh->ether_dhost[0] & 1))) {
920 m_freem(m);
921 continue;
922 }
923 }
930#endif
924
931 /* Remove header from mbuf and pass it on. */
932 m_adj(m, sizeof(struct ether_header));
933 ether_input(ifp, eh, m);
934 }
935
936 sc->sis_cdata.sis_rx_prod = i;
937
938 return;

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

1159 break;
1160
1161 if (sis_encap(sc, m_head, &idx)) {
1162 IF_PREPEND(&ifp->if_snd, m_head);
1163 ifp->if_flags |= IFF_OACTIVE;
1164 break;
1165 }
1166
925 /* Remove header from mbuf and pass it on. */
926 m_adj(m, sizeof(struct ether_header));
927 ether_input(ifp, eh, m);
928 }
929
930 sc->sis_cdata.sis_rx_prod = i;
931
932 return;

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

1153 break;
1154
1155 if (sis_encap(sc, m_head, &idx)) {
1156 IF_PREPEND(&ifp->if_snd, m_head);
1157 ifp->if_flags |= IFF_OACTIVE;
1158 break;
1159 }
1160
1167#if NBPF > 0
1168 /*
1169 * If there's a BPF listener, bounce a copy of this frame
1170 * to him.
1171 */
1172 if (ifp->if_bpf)
1173 bpf_mtap(ifp, m_head);
1161 /*
1162 * If there's a BPF listener, bounce a copy of this frame
1163 * to him.
1164 */
1165 if (ifp->if_bpf)
1166 bpf_mtap(ifp, m_head);
1174#endif
1167
1175 }
1176
1177 /* Transmit */
1178 sc->sis_cdata.sis_tx_prod = idx;
1179 SIS_SETBIT(sc, SIS_CSR, SIS_CSR_TX_ENABLE);
1180
1181 /*
1182 * Set a timeout in case the chip goes out to lunch.

--- 277 unchanged lines hidden ---
1168 }
1169
1170 /* Transmit */
1171 sc->sis_cdata.sis_tx_prod = idx;
1172 SIS_SETBIT(sc, SIS_CSR, SIS_CSR_TX_ENABLE);
1173
1174 /*
1175 * Set a timeout in case the chip goes out to lunch.

--- 277 unchanged lines hidden ---