if_my.c (106696) | if_my.c (106937) |
---|---|
1/* 2 * Copyright (c) 2002 Myson Technology Inc. 3 * 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 --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * Written by: yen_cw@myson.com.tw available at: http://www.myson.com.tw/ 27 * | 1/* 2 * Copyright (c) 2002 Myson Technology Inc. 3 * 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 --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * Written by: yen_cw@myson.com.tw available at: http://www.myson.com.tw/ 27 * |
28 * $FreeBSD: head/sys/dev/my/if_my.c 106696 2002-11-09 12:55:07Z alfred $ | 28 * $FreeBSD: head/sys/dev/my/if_my.c 106937 2002-11-14 23:54:55Z sam $ |
29 * 30 * Myson fast ethernet PCI NIC driver 31 */ 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/sockio.h> 35#include <sys/mbuf.h> 36#include <sys/malloc.h> --- 1014 unchanged lines hidden (view full) --- 1051 /* Do ifmedia setup. */ 1052 ifmedia_init(&sc->ifmedia, 0, my_ifmedia_upd, my_ifmedia_sts); 1053 my_getmode_mii(sc); 1054 my_autoneg_mii(sc, MY_FLAG_FORCEDELAY, 1); 1055 media = sc->ifmedia.ifm_media; 1056 my_stop(sc); 1057 ifmedia_set(&sc->ifmedia, media); 1058 | 29 * 30 * Myson fast ethernet PCI NIC driver 31 */ 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/sockio.h> 35#include <sys/mbuf.h> 36#include <sys/malloc.h> --- 1014 unchanged lines hidden (view full) --- 1051 /* Do ifmedia setup. */ 1052 ifmedia_init(&sc->ifmedia, 0, my_ifmedia_upd, my_ifmedia_sts); 1053 my_getmode_mii(sc); 1054 my_autoneg_mii(sc, MY_FLAG_FORCEDELAY, 1); 1055 media = sc->ifmedia.ifm_media; 1056 my_stop(sc); 1057 ifmedia_set(&sc->ifmedia, media); 1058 |
1059 ether_ifattach(ifp, ETHER_BPF_SUPPORTED); | 1059 ether_ifattach(ifp, eaddr); |
1060 1061#if 0 1062 at_shutdown(my_shutdown, sc, SHUTDOWN_POST_SYNC); 1063 shutdownhook_establish(my_shutdown, sc); 1064#endif 1065 1066 MY_UNLOCK(sc); 1067 return (0); --- 11 unchanged lines hidden (view full) --- 1079 struct my_softc *sc; 1080 struct ifnet *ifp; 1081 int s; 1082 1083 s = splimp(); 1084 sc = device_get_softc(dev); 1085 MY_LOCK(sc); 1086 ifp = &sc->arpcom.ac_if; | 1060 1061#if 0 1062 at_shutdown(my_shutdown, sc, SHUTDOWN_POST_SYNC); 1063 shutdownhook_establish(my_shutdown, sc); 1064#endif 1065 1066 MY_UNLOCK(sc); 1067 return (0); --- 11 unchanged lines hidden (view full) --- 1079 struct my_softc *sc; 1080 struct ifnet *ifp; 1081 int s; 1082 1083 s = splimp(); 1084 sc = device_get_softc(dev); 1085 MY_LOCK(sc); 1086 ifp = &sc->arpcom.ac_if; |
1087 ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); | 1087 ether_ifdetach(ifp); |
1088 my_stop(sc); 1089 1090#if 0 1091 bus_generic_detach(dev); 1092 device_delete_child(dev, sc->rl_miibus); 1093#endif 1094 1095 bus_teardown_intr(dev, sc->my_irq, sc->my_intrhand); --- 166 unchanged lines hidden (view full) --- 1262#if NBPFILTER > 0 1263 /* 1264 * Handle BPF listeners. Let the BPF user see the packet, but 1265 * don't pass it up to the ether_input() layer unless it's a 1266 * broadcast packet, multicast packet, matches our ethernet 1267 * address or the interface is in promiscuous mode. 1268 */ 1269 if (ifp->if_bpf) { | 1088 my_stop(sc); 1089 1090#if 0 1091 bus_generic_detach(dev); 1092 device_delete_child(dev, sc->rl_miibus); 1093#endif 1094 1095 bus_teardown_intr(dev, sc->my_irq, sc->my_intrhand); --- 166 unchanged lines hidden (view full) --- 1262#if NBPFILTER > 0 1263 /* 1264 * Handle BPF listeners. Let the BPF user see the packet, but 1265 * don't pass it up to the ether_input() layer unless it's a 1266 * broadcast packet, multicast packet, matches our ethernet 1267 * address or the interface is in promiscuous mode. 1268 */ 1269 if (ifp->if_bpf) { |
1270 bpf_mtap(ifp, m); | 1270 BPF_MTAP(ifp, m); |
1271 if (ifp->if_flags & IFF_PROMISC && 1272 (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, 1273 ETHER_ADDR_LEN) && 1274 (eh->ether_dhost[0] & 1) == 0)) { 1275 m_freem(m); 1276 continue; 1277 } 1278 } 1279#endif | 1271 if (ifp->if_flags & IFF_PROMISC && 1272 (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, 1273 ETHER_ADDR_LEN) && 1274 (eh->ether_dhost[0] & 1) == 0)) { 1275 m_freem(m); 1276 continue; 1277 } 1278 } 1279#endif |
1280 /* Remove header from mbuf and pass it on. */ 1281 m_adj(m, sizeof(struct ether_header)); 1282 ether_input(ifp, eh, m); | 1280 (*ifp->if_input)(ifp, m); |
1283 } 1284 MY_UNLOCK(sc); 1285 return; 1286} 1287 1288 1289/* 1290 * A frame was downloaded to the chip. It's safe for us to clean up the list --- 241 unchanged lines hidden (view full) --- 1532 1533 if (cur_tx != start_tx) 1534 MY_TXOWN(cur_tx) = MY_OWNByNIC; 1535#if NBPFILTER > 0 1536 /* 1537 * If there's a BPF listener, bounce a copy of this frame to 1538 * him. 1539 */ | 1281 } 1282 MY_UNLOCK(sc); 1283 return; 1284} 1285 1286 1287/* 1288 * A frame was downloaded to the chip. It's safe for us to clean up the list --- 241 unchanged lines hidden (view full) --- 1530 1531 if (cur_tx != start_tx) 1532 MY_TXOWN(cur_tx) = MY_OWNByNIC; 1533#if NBPFILTER > 0 1534 /* 1535 * If there's a BPF listener, bounce a copy of this frame to 1536 * him. 1537 */ |
1540 if (ifp->if_bpf) 1541 bpf_mtap(ifp, cur_tx->my_mbuf); | 1538 BPF_MTAP(ifp, cur_tx->my_mbuf); |
1542#endif 1543 } 1544 /* 1545 * If there are no packets queued, bail. 1546 */ 1547 if (cur_tx == NULL) { 1548 MY_UNLOCK(sc); 1549 return; --- 209 unchanged lines hidden (view full) --- 1759{ 1760 struct my_softc *sc = ifp->if_softc; 1761 struct ifreq *ifr = (struct ifreq *) data; 1762 int s, error = 0; 1763 1764 s = splimp(); 1765 MY_LOCK(sc); 1766 switch (command) { | 1539#endif 1540 } 1541 /* 1542 * If there are no packets queued, bail. 1543 */ 1544 if (cur_tx == NULL) { 1545 MY_UNLOCK(sc); 1546 return; --- 209 unchanged lines hidden (view full) --- 1756{ 1757 struct my_softc *sc = ifp->if_softc; 1758 struct ifreq *ifr = (struct ifreq *) data; 1759 int s, error = 0; 1760 1761 s = splimp(); 1762 MY_LOCK(sc); 1763 switch (command) { |
1767 case SIOCSIFADDR: 1768 case SIOCGIFADDR: 1769 case SIOCSIFMTU: 1770 error = ether_ioctl(ifp, command, data); 1771 break; | |
1772 case SIOCSIFFLAGS: 1773 if (ifp->if_flags & IFF_UP) 1774 my_init(sc); 1775 else if (ifp->if_flags & IFF_RUNNING) 1776 my_stop(sc); 1777 error = 0; 1778 break; 1779 case SIOCADDMULTI: 1780 case SIOCDELMULTI: 1781 my_setmulti(sc); 1782 error = 0; 1783 break; 1784 case SIOCGIFMEDIA: 1785 case SIOCSIFMEDIA: 1786 error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, command); 1787 break; 1788 default: | 1764 case SIOCSIFFLAGS: 1765 if (ifp->if_flags & IFF_UP) 1766 my_init(sc); 1767 else if (ifp->if_flags & IFF_RUNNING) 1768 my_stop(sc); 1769 error = 0; 1770 break; 1771 case SIOCADDMULTI: 1772 case SIOCDELMULTI: 1773 my_setmulti(sc); 1774 error = 0; 1775 break; 1776 case SIOCGIFMEDIA: 1777 case SIOCSIFMEDIA: 1778 error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, command); 1779 break; 1780 default: |
1789 error = EINVAL; | 1781 error = ether_ioctl(ifp, command, data); |
1790 break; 1791 } 1792 MY_UNLOCK(sc); 1793 (void)splx(s); 1794 return (error); 1795} 1796 1797static void --- 86 unchanged lines hidden --- | 1782 break; 1783 } 1784 MY_UNLOCK(sc); 1785 (void)splx(s); 1786 return (error); 1787} 1788 1789static void --- 86 unchanged lines hidden --- |