if_ste.c (106696) | if_ste.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_ste.c 106696 2002-11-09 12:55:07Z alfred $ | 32 * $FreeBSD: head/sys/pci/if_ste.c 106936 2002-11-14 23:49:09Z sam $ |
33 */ 34 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> --- 29 unchanged lines hidden (view full) --- 70#define STE_USEIOSPACE 71 72#include <pci/if_stereg.h> 73 74MODULE_DEPEND(ste, miibus, 1, 1, 1); 75 76#if !defined(lint) 77static const char rcsid[] = | 33 */ 34 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> --- 29 unchanged lines hidden (view full) --- 70#define STE_USEIOSPACE 71 72#include <pci/if_stereg.h> 73 74MODULE_DEPEND(ste, miibus, 1, 1, 1); 75 76#if !defined(lint) 77static const char rcsid[] = |
78 "$FreeBSD: head/sys/pci/if_ste.c 106696 2002-11-09 12:55:07Z alfred $"; | 78 "$FreeBSD: head/sys/pci/if_ste.c 106936 2002-11-14 23:49:09Z sam $"; |
79#endif 80 81/* 82 * Various supported device vendors/types and their names. 83 */ 84static struct ste_type ste_devs[] = { 85 { ST_VENDORID, ST_DEVICEID_ST201, "Sundance ST201 10/100BaseTX" }, 86 { DL_VENDORID, DL_DEVICEID_550TX, "D-Link DFE-550TX 10/100BaseTX" }, --- 599 unchanged lines hidden (view full) --- 686/* 687 * A frame has been uploaded: pass the resulting mbuf chain up to 688 * the higher level protocols. 689 */ 690static void 691ste_rxeof(sc) 692 struct ste_softc *sc; 693{ | 79#endif 80 81/* 82 * Various supported device vendors/types and their names. 83 */ 84static struct ste_type ste_devs[] = { 85 { ST_VENDORID, ST_DEVICEID_ST201, "Sundance ST201 10/100BaseTX" }, 86 { DL_VENDORID, DL_DEVICEID_550TX, "D-Link DFE-550TX 10/100BaseTX" }, --- 599 unchanged lines hidden (view full) --- 686/* 687 * A frame has been uploaded: pass the resulting mbuf chain up to 688 * the higher level protocols. 689 */ 690static void 691ste_rxeof(sc) 692 struct ste_softc *sc; 693{ |
694 struct ether_header *eh; | |
695 struct mbuf *m; 696 struct ifnet *ifp; 697 struct ste_chain_onefrag *cur_rx; 698 int total_len = 0, count=0; 699 u_int32_t rxstat; 700 701 ifp = &sc->arpcom.ac_if; 702 --- 43 unchanged lines hidden (view full) --- 746 * can do in this situation. 747 */ 748 if (ste_newbuf(sc, cur_rx, NULL) == ENOBUFS) { 749 ifp->if_ierrors++; 750 cur_rx->ste_ptr->ste_status = 0; 751 continue; 752 } 753 | 694 struct mbuf *m; 695 struct ifnet *ifp; 696 struct ste_chain_onefrag *cur_rx; 697 int total_len = 0, count=0; 698 u_int32_t rxstat; 699 700 ifp = &sc->arpcom.ac_if; 701 --- 43 unchanged lines hidden (view full) --- 745 * can do in this situation. 746 */ 747 if (ste_newbuf(sc, cur_rx, NULL) == ENOBUFS) { 748 ifp->if_ierrors++; 749 cur_rx->ste_ptr->ste_status = 0; 750 continue; 751 } 752 |
754 ifp->if_ipackets++; 755 eh = mtod(m, struct ether_header *); | |
756 m->m_pkthdr.rcvif = ifp; 757 m->m_pkthdr.len = m->m_len = total_len; 758 | 753 m->m_pkthdr.rcvif = ifp; 754 m->m_pkthdr.len = m->m_len = total_len; 755 |
759 /* Remove header from mbuf and pass it on. */ 760 m_adj(m, sizeof(struct ether_header)); 761 ether_input(ifp, eh, m); | 756 ifp->if_ipackets++; 757 (*ifp->if_input)(ifp, m); |
762 763 cur_rx->ste_ptr->ste_status = 0; 764 count++; 765 } 766 767 return; 768} 769 --- 316 unchanged lines hidden (view full) --- 1086 ifp->if_baudrate = 10000000; 1087 ifp->if_snd.ifq_maxlen = STE_TX_LIST_CNT - 1; 1088 1089 sc->ste_tx_thresh = STE_TXSTART_THRESH; 1090 1091 /* 1092 * Call MI attach routine. 1093 */ | 758 759 cur_rx->ste_ptr->ste_status = 0; 760 count++; 761 } 762 763 return; 764} 765 --- 316 unchanged lines hidden (view full) --- 1082 ifp->if_baudrate = 10000000; 1083 ifp->if_snd.ifq_maxlen = STE_TX_LIST_CNT - 1; 1084 1085 sc->ste_tx_thresh = STE_TXSTART_THRESH; 1086 1087 /* 1088 * Call MI attach routine. 1089 */ |
1094 ether_ifattach(ifp, ETHER_BPF_SUPPORTED); | 1090 ether_ifattach(ifp, sc->arpcom.ac_enaddr); |
1095 1096 /* 1097 * Tell the upper layer(s) we support long frames. 1098 */ 1099 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); | 1091 1092 /* 1093 * Tell the upper layer(s) we support long frames. 1094 */ 1095 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); |
1096 ifp->if_capabilities |= IFCAP_VLAN_MTU; |
|
1100 1101 STE_UNLOCK(sc); 1102 return(0); 1103 1104fail: 1105 STE_UNLOCK(sc); 1106 mtx_destroy(&sc->ste_mtx); 1107 return(error); --- 6 unchanged lines hidden (view full) --- 1114 struct ste_softc *sc; 1115 struct ifnet *ifp; 1116 1117 sc = device_get_softc(dev); 1118 STE_LOCK(sc); 1119 ifp = &sc->arpcom.ac_if; 1120 1121 ste_stop(sc); | 1097 1098 STE_UNLOCK(sc); 1099 return(0); 1100 1101fail: 1102 STE_UNLOCK(sc); 1103 mtx_destroy(&sc->ste_mtx); 1104 return(error); --- 6 unchanged lines hidden (view full) --- 1111 struct ste_softc *sc; 1112 struct ifnet *ifp; 1113 1114 sc = device_get_softc(dev); 1115 STE_LOCK(sc); 1116 ifp = &sc->arpcom.ac_if; 1117 1118 ste_stop(sc); |
1122 ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); | 1119 ether_ifdetach(ifp); |
1123 1124 bus_generic_detach(dev); 1125 device_delete_child(dev, sc->ste_miibus); 1126 1127 bus_teardown_intr(dev, sc->ste_irq, sc->ste_intrhand); 1128 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ste_irq); 1129 bus_release_resource(dev, STE_RES, STE_RID, sc->ste_res); 1130 --- 29 unchanged lines hidden (view full) --- 1160 m_new->m_data = m_new->m_ext.ext_buf; 1161 } 1162 1163 m_adj(m_new, ETHER_ALIGN); 1164 1165 c->ste_mbuf = m_new; 1166 c->ste_ptr->ste_status = 0; 1167 c->ste_ptr->ste_frag.ste_addr = vtophys(mtod(m_new, caddr_t)); | 1120 1121 bus_generic_detach(dev); 1122 device_delete_child(dev, sc->ste_miibus); 1123 1124 bus_teardown_intr(dev, sc->ste_irq, sc->ste_intrhand); 1125 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ste_irq); 1126 bus_release_resource(dev, STE_RES, STE_RID, sc->ste_res); 1127 --- 29 unchanged lines hidden (view full) --- 1157 m_new->m_data = m_new->m_ext.ext_buf; 1158 } 1159 1160 m_adj(m_new, ETHER_ALIGN); 1161 1162 c->ste_mbuf = m_new; 1163 c->ste_ptr->ste_status = 0; 1164 c->ste_ptr->ste_frag.ste_addr = vtophys(mtod(m_new, caddr_t)); |
1168 c->ste_ptr->ste_frag.ste_len = (1536 + EVL_ENCAPLEN) | STE_FRAG_LAST; | 1165 c->ste_ptr->ste_frag.ste_len = (1536 + ETHER_VLAN_ENCAP_LEN) | STE_FRAG_LAST; |
1169 1170 return(0); 1171} 1172 1173static int 1174ste_init_rx_list(sc) 1175 struct ste_softc *sc; 1176{ --- 156 unchanged lines hidden (view full) --- 1333 /* Enable stats counters. */ 1334 STE_SETBIT2(sc, STE_MACCTL1, STE_MACCTL1_STATS_ENABLE); 1335 1336 /* Enable interrupts. */ 1337 CSR_WRITE_2(sc, STE_ISR, 0xFFFF); 1338 CSR_WRITE_2(sc, STE_IMR, STE_INTRS); 1339 1340 /* Accept VLAN length packets */ | 1166 1167 return(0); 1168} 1169 1170static int 1171ste_init_rx_list(sc) 1172 struct ste_softc *sc; 1173{ --- 156 unchanged lines hidden (view full) --- 1330 /* Enable stats counters. */ 1331 STE_SETBIT2(sc, STE_MACCTL1, STE_MACCTL1_STATS_ENABLE); 1332 1333 /* Enable interrupts. */ 1334 CSR_WRITE_2(sc, STE_ISR, 0xFFFF); 1335 CSR_WRITE_2(sc, STE_IMR, STE_INTRS); 1336 1337 /* Accept VLAN length packets */ |
1341 CSR_WRITE_2(sc, STE_MAX_FRAMELEN, ETHER_MAX_LEN + EVL_ENCAPLEN); | 1338 CSR_WRITE_2(sc, STE_MAX_FRAMELEN, ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN); |
1342 1343 ste_ifmedia_upd(ifp); 1344 1345 ifp->if_flags |= IFF_RUNNING; 1346 ifp->if_flags &= ~IFF_OACTIVE; 1347 1348 sc->ste_stat_ch = timeout(ste_stats_update, sc, hz); 1349 STE_UNLOCK(sc); --- 87 unchanged lines hidden (view full) --- 1437 struct mii_data *mii; 1438 int error = 0; 1439 1440 sc = ifp->if_softc; 1441 STE_LOCK(sc); 1442 ifr = (struct ifreq *)data; 1443 1444 switch(command) { | 1339 1340 ste_ifmedia_upd(ifp); 1341 1342 ifp->if_flags |= IFF_RUNNING; 1343 ifp->if_flags &= ~IFF_OACTIVE; 1344 1345 sc->ste_stat_ch = timeout(ste_stats_update, sc, hz); 1346 STE_UNLOCK(sc); --- 87 unchanged lines hidden (view full) --- 1434 struct mii_data *mii; 1435 int error = 0; 1436 1437 sc = ifp->if_softc; 1438 STE_LOCK(sc); 1439 ifr = (struct ifreq *)data; 1440 1441 switch(command) { |
1445 case SIOCSIFADDR: 1446 case SIOCGIFADDR: 1447 case SIOCSIFMTU: 1448 error = ether_ioctl(ifp, command, data); 1449 break; | |
1450 case SIOCSIFFLAGS: 1451 if (ifp->if_flags & IFF_UP) { 1452 if (ifp->if_flags & IFF_RUNNING && 1453 ifp->if_flags & IFF_PROMISC && 1454 !(sc->ste_if_flags & IFF_PROMISC)) { 1455 STE_SETBIT1(sc, STE_RX_MODE, 1456 STE_RXMODE_PROMISC); 1457 } else if (ifp->if_flags & IFF_RUNNING && --- 19 unchanged lines hidden (view full) --- 1477 error = 0; 1478 break; 1479 case SIOCGIFMEDIA: 1480 case SIOCSIFMEDIA: 1481 mii = device_get_softc(sc->ste_miibus); 1482 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); 1483 break; 1484 default: | 1442 case SIOCSIFFLAGS: 1443 if (ifp->if_flags & IFF_UP) { 1444 if (ifp->if_flags & IFF_RUNNING && 1445 ifp->if_flags & IFF_PROMISC && 1446 !(sc->ste_if_flags & IFF_PROMISC)) { 1447 STE_SETBIT1(sc, STE_RX_MODE, 1448 STE_RXMODE_PROMISC); 1449 } else if (ifp->if_flags & IFF_RUNNING && --- 19 unchanged lines hidden (view full) --- 1469 error = 0; 1470 break; 1471 case SIOCGIFMEDIA: 1472 case SIOCSIFMEDIA: 1473 mii = device_get_softc(sc->ste_miibus); 1474 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); 1475 break; 1476 default: |
1485 error = EINVAL; | 1477 error = ether_ioctl(ifp, command, data); |
1486 break; 1487 } 1488 1489 STE_UNLOCK(sc); 1490 1491 return(error); 1492} 1493 --- 125 unchanged lines hidden (view full) --- 1619 } 1620 1621 sc->ste_tx_prev_idx=idx; 1622 1623 /* 1624 * If there's a BPF listener, bounce a copy of this frame 1625 * to him. 1626 */ | 1478 break; 1479 } 1480 1481 STE_UNLOCK(sc); 1482 1483 return(error); 1484} 1485 --- 125 unchanged lines hidden (view full) --- 1611 } 1612 1613 sc->ste_tx_prev_idx=idx; 1614 1615 /* 1616 * If there's a BPF listener, bounce a copy of this frame 1617 * to him. 1618 */ |
1627 if (ifp->if_bpf) 1628 bpf_mtap(ifp, cur_tx->ste_mbuf); | 1619 BPF_MTAP(ifp, cur_tx->ste_mbuf); |
1629 1630 STE_INC(idx, STE_TX_LIST_CNT); 1631 sc->ste_cdata.ste_tx_cnt++; 1632 ifp->if_timer = 5; 1633 sc->ste_cdata.ste_tx_prod = idx; 1634 } 1635 1636 STE_UNLOCK(sc); --- 41 unchanged lines hidden --- | 1620 1621 STE_INC(idx, STE_TX_LIST_CNT); 1622 sc->ste_cdata.ste_tx_cnt++; 1623 ifp->if_timer = 5; 1624 sc->ste_cdata.ste_tx_prod = idx; 1625 } 1626 1627 STE_UNLOCK(sc); --- 41 unchanged lines hidden --- |