if_ste.c (51533) | if_ste.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_ste.c 51533 1999-09-22 06:08:11Z wpaul $ | 32 * $FreeBSD: head/sys/pci/if_ste.c 51583 1999-09-23 03:32:57Z wpaul $ |
33 */ 34 | 33 */ 34 |
35 36#include "bpf.h" 37 | |
38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/sockio.h> 41#include <sys/mbuf.h> 42#include <sys/malloc.h> 43#include <sys/kernel.h> 44#include <sys/socket.h> 45 46#include <net/if.h> 47#include <net/if_arp.h> 48#include <net/ethernet.h> 49#include <net/if_dl.h> 50#include <net/if_media.h> 51 | 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/sockio.h> 38#include <sys/mbuf.h> 39#include <sys/malloc.h> 40#include <sys/kernel.h> 41#include <sys/socket.h> 42 43#include <net/if.h> 44#include <net/if_arp.h> 45#include <net/ethernet.h> 46#include <net/if_dl.h> 47#include <net/if_media.h> 48 |
52#if NBPF > 0 | |
53#include <net/bpf.h> | 49#include <net/bpf.h> |
54#endif | |
55 56#include "opt_bdg.h" 57#ifdef BRIDGE 58#include <net/bridge.h> 59#endif 60 61#include <vm/vm.h> /* for vtophys */ 62#include <vm/pmap.h> /* for vtophys */ --- 15 unchanged lines hidden (view full) --- 78#include "miibus_if.h" 79 80#define STE_USEIOSPACE 81 82#include <pci/if_stereg.h> 83 84#if !defined(lint) 85static const char rcsid[] = | 50 51#include "opt_bdg.h" 52#ifdef BRIDGE 53#include <net/bridge.h> 54#endif 55 56#include <vm/vm.h> /* for vtophys */ 57#include <vm/pmap.h> /* for vtophys */ --- 15 unchanged lines hidden (view full) --- 73#include "miibus_if.h" 74 75#define STE_USEIOSPACE 76 77#include <pci/if_stereg.h> 78 79#if !defined(lint) 80static const char rcsid[] = |
86 "$FreeBSD: head/sys/pci/if_ste.c 51533 1999-09-22 06:08:11Z wpaul $"; | 81 "$FreeBSD: head/sys/pci/if_ste.c 51583 1999-09-23 03:32:57Z wpaul $"; |
87#endif 88 89/* 90 * Various supported device vendors/types and their names. 91 */ 92static struct ste_type ste_devs[] = { 93 { ST_VENDORID, ST_DEVICEID_ST201, "Sundance ST201 10/100BaseTX" }, 94 { DL_VENDORID, DL_DEVICEID_550TX, "D-Link DFE-550TX 10/100BaseTX" }, --- 626 unchanged lines hidden (view full) --- 721 continue; 722 } 723 724 ifp->if_ipackets++; 725 eh = mtod(m, struct ether_header *); 726 m->m_pkthdr.rcvif = ifp; 727 m->m_pkthdr.len = m->m_len = total_len; 728 | 82#endif 83 84/* 85 * Various supported device vendors/types and their names. 86 */ 87static struct ste_type ste_devs[] = { 88 { ST_VENDORID, ST_DEVICEID_ST201, "Sundance ST201 10/100BaseTX" }, 89 { DL_VENDORID, DL_DEVICEID_550TX, "D-Link DFE-550TX 10/100BaseTX" }, --- 626 unchanged lines hidden (view full) --- 716 continue; 717 } 718 719 ifp->if_ipackets++; 720 eh = mtod(m, struct ether_header *); 721 m->m_pkthdr.rcvif = ifp; 722 m->m_pkthdr.len = m->m_len = total_len; 723 |
729#if NBPF > 0 | |
730 /* Handle BPF listeners. Let the BPF user see the packet. */ 731 if (ifp->if_bpf) 732 bpf_mtap(ifp, m); | 724 /* Handle BPF listeners. Let the BPF user see the packet. */ 725 if (ifp->if_bpf) 726 bpf_mtap(ifp, m); |
733#endif | |
734 735#ifdef BRIDGE 736 if (do_bridge) { 737 struct ifnet *bdg_ifp ; 738 bdg_ifp = bridge_in(m); 739 if (bdg_ifp != BDG_LOCAL && bdg_ifp != BDG_DROP) 740 bdg_forward(&m, bdg_ifp); 741 if (((bdg_ifp != BDG_LOCAL) && (bdg_ifp != BDG_BCAST) && 742 (bdg_ifp != BDG_MCAST)) || bdg_ifp == BDG_DROP) { 743 m_freem(m); 744 continue; 745 } 746 } 747#endif 748 | 727 728#ifdef BRIDGE 729 if (do_bridge) { 730 struct ifnet *bdg_ifp ; 731 bdg_ifp = bridge_in(m); 732 if (bdg_ifp != BDG_LOCAL && bdg_ifp != BDG_DROP) 733 bdg_forward(&m, bdg_ifp); 734 if (((bdg_ifp != BDG_LOCAL) && (bdg_ifp != BDG_BCAST) && 735 (bdg_ifp != BDG_MCAST)) || bdg_ifp == BDG_DROP) { 736 m_freem(m); 737 continue; 738 } 739 } 740#endif 741 |
749#if NBPF > 0 | |
750 /* 751 * Don't pass packet up to the ether_input() layer unless it's 752 * a broadcast packet, multicast packet, matches our ethernet 753 * address or the interface is in promiscuous mode. 754 */ 755 if (ifp->if_bpf) { 756 if (ifp->if_flags & IFF_PROMISC && 757 (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, 758 ETHER_ADDR_LEN) && (eh->ether_dhost[0] & 1) == 0)){ 759 m_freem(m); 760 continue; 761 } 762 } | 742 /* 743 * Don't pass packet up to the ether_input() layer unless it's 744 * a broadcast packet, multicast packet, matches our ethernet 745 * address or the interface is in promiscuous mode. 746 */ 747 if (ifp->if_bpf) { 748 if (ifp->if_flags & IFF_PROMISC && 749 (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, 750 ETHER_ADDR_LEN) && (eh->ether_dhost[0] & 1) == 0)){ 751 m_freem(m); 752 continue; 753 } 754 } |
763#endif | |
764 765 /* Remove header from mbuf and pass it on. */ 766 m_adj(m, sizeof(struct ether_header)); 767 ether_input(ifp, eh, m); 768 } 769 770 /* 771 * Handle the 'end of channel' condition. When the upload --- 330 unchanged lines hidden (view full) --- 1102 1103 /* 1104 * Call MI attach routines. 1105 */ 1106 1107 if_attach(ifp); 1108 ether_ifattach(ifp); 1109 | 755 756 /* Remove header from mbuf and pass it on. */ 757 m_adj(m, sizeof(struct ether_header)); 758 ether_input(ifp, eh, m); 759 } 760 761 /* 762 * Handle the 'end of channel' condition. When the upload --- 330 unchanged lines hidden (view full) --- 1093 1094 /* 1095 * Call MI attach routines. 1096 */ 1097 1098 if_attach(ifp); 1099 ether_ifattach(ifp); 1100 |
1110#if NBPF > 0 | |
1111 bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); | 1101 bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); |
1112#endif | |
1113 1114fail: 1115 splx(s); 1116 return(error); 1117} 1118 1119static int ste_detach(dev) 1120 device_t dev; --- 440 unchanged lines hidden (view full) --- 1561 ste_encap(sc, cur_tx, m_head); 1562 1563 if (prev != NULL) { 1564 prev->ste_next = cur_tx; 1565 prev->ste_ptr->ste_next = vtophys(cur_tx->ste_ptr); 1566 } 1567 prev = cur_tx; 1568 | 1102 1103fail: 1104 splx(s); 1105 return(error); 1106} 1107 1108static int ste_detach(dev) 1109 device_t dev; --- 440 unchanged lines hidden (view full) --- 1550 ste_encap(sc, cur_tx, m_head); 1551 1552 if (prev != NULL) { 1553 prev->ste_next = cur_tx; 1554 prev->ste_ptr->ste_next = vtophys(cur_tx->ste_ptr); 1555 } 1556 prev = cur_tx; 1557 |
1569#if NBPF > 0 | |
1570 /* 1571 * If there's a BPF listener, bounce a copt of this frame 1572 * to him. 1573 */ 1574 if (ifp->if_bpf) 1575 bpf_mtap(ifp, cur_tx->ste_mbuf); | 1558 /* 1559 * If there's a BPF listener, bounce a copt of this frame 1560 * to him. 1561 */ 1562 if (ifp->if_bpf) 1563 bpf_mtap(ifp, cur_tx->ste_mbuf); |
1576#endif | |
1577 } 1578 1579 if (cur_tx == NULL) 1580 return; 1581 1582 cur_tx->ste_ptr->ste_ctl |= STE_TXCTL_DMAINTR; 1583 1584 STE_SETBIT4(sc, STE_DMACTL, STE_DMACTL_TXDMA_STALL); --- 65 unchanged lines hidden --- | 1564 } 1565 1566 if (cur_tx == NULL) 1567 return; 1568 1569 cur_tx->ste_ptr->ste_ctl |= STE_TXCTL_DMAINTR; 1570 1571 STE_SETBIT4(sc, STE_DMACTL, STE_DMACTL_TXDMA_STALL); --- 65 unchanged lines hidden --- |