if_sis.c (101340) | if_sis.c (101464) |
---|---|
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 101340 2002-08-04 21:52:05Z luigi $ | 32 * $FreeBSD: head/sys/pci/if_sis.c 101464 2002-08-07 16:08:54Z luigi $ |
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 * This driver also supports the NatSemi DP83815. Datasheets are 40 * available from http://www.national.com. --- 54 unchanged lines hidden (view full) --- 95 96MODULE_DEPEND(sis, miibus, 1, 1, 1); 97 98/* "controller miibus0" required. See GENERIC if you get errors here. */ 99#include "miibus_if.h" 100 101#ifndef lint 102static const char rcsid[] = | 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 * This driver also supports the NatSemi DP83815. Datasheets are 40 * available from http://www.national.com. --- 54 unchanged lines hidden (view full) --- 95 96MODULE_DEPEND(sis, miibus, 1, 1, 1); 97 98/* "controller miibus0" required. See GENERIC if you get errors here. */ 99#include "miibus_if.h" 100 101#ifndef lint 102static const char rcsid[] = |
103 "$FreeBSD: head/sys/pci/if_sis.c 101340 2002-08-04 21:52:05Z luigi $"; | 103 "$FreeBSD: head/sys/pci/if_sis.c 101464 2002-08-07 16:08:54Z luigi $"; |
104#endif 105 106/* 107 * Various supported device vendors/types and their names. 108 */ 109static struct sis_type sis_devs[] = { 110 { SIS_VENDORID, SIS_DEVICEID_900, "SiS 900 10/100BaseTX" }, 111 { SIS_VENDORID, SIS_DEVICEID_7016, "SiS 7016 10/100BaseTX" }, --- 1136 unchanged lines hidden (view full) --- 1248 return(EINVAL); 1249 1250 if (m == NULL) { 1251 m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); 1252 if (m == NULL) 1253 return(ENOBUFS); 1254 } else 1255 m->m_data = m->m_ext.ext_buf; | 104#endif 105 106/* 107 * Various supported device vendors/types and their names. 108 */ 109static struct sis_type sis_devs[] = { 110 { SIS_VENDORID, SIS_DEVICEID_900, "SiS 900 10/100BaseTX" }, 111 { SIS_VENDORID, SIS_DEVICEID_7016, "SiS 7016 10/100BaseTX" }, --- 1136 unchanged lines hidden (view full) --- 1248 return(EINVAL); 1249 1250 if (m == NULL) { 1251 m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); 1252 if (m == NULL) 1253 return(ENOBUFS); 1254 } else 1255 m->m_data = m->m_ext.ext_buf; |
1256 m->m_len = m->m_pkthdr.len = MCLBYTES; | |
1257 | 1256 |
1258 m_adj(m, sizeof(u_int64_t)); 1259 | |
1260 c->sis_mbuf = m; 1261 c->sis_ctl = SIS_RXLEN; 1262 1263 bus_dmamap_create(sc->sis_tag, 0, &c->sis_map); 1264 bus_dmamap_load(sc->sis_tag, c->sis_map, | 1257 c->sis_mbuf = m; 1258 c->sis_ctl = SIS_RXLEN; 1259 1260 bus_dmamap_create(sc->sis_tag, 0, &c->sis_map); 1261 bus_dmamap_load(sc->sis_tag, c->sis_map, |
1265 mtod(m, void *), m->m_len, | 1262 mtod(m, void *), MCLBYTES, |
1266 sis_dma_map_desc_ptr, c, 0); 1267 bus_dmamap_sync(sc->sis_tag, c->sis_map, BUS_DMASYNC_PREWRITE); 1268 1269 return(0); 1270} 1271 1272/* 1273 * A frame has been uploaded: pass the resulting mbuf chain up to 1274 * the higher level protocols. 1275 */ 1276static void sis_rxeof(sc) 1277 struct sis_softc *sc; 1278{ | 1263 sis_dma_map_desc_ptr, c, 0); 1264 bus_dmamap_sync(sc->sis_tag, c->sis_map, BUS_DMASYNC_PREWRITE); 1265 1266 return(0); 1267} 1268 1269/* 1270 * A frame has been uploaded: pass the resulting mbuf chain up to 1271 * the higher level protocols. 1272 */ 1273static void sis_rxeof(sc) 1274 struct sis_softc *sc; 1275{ |
1279 struct ether_header *eh; | |
1280 struct mbuf *m; 1281 struct ifnet *ifp; 1282 struct sis_desc *cur_rx; 1283 int i, total_len = 0; 1284 u_int32_t rxstat; 1285 1286 ifp = &sc->arpcom.ac_if; 1287 i = sc->sis_cdata.sis_rx_prod; --- 38 unchanged lines hidden (view full) --- 1326 * On the x86 we do not have alignment problems, so try to 1327 * allocate a new buffer for the receive ring, and pass up 1328 * the one where the packet is already, saving the expensive 1329 * copy done in m_devget(). 1330 * If we are on an architecture with alignment problems, or 1331 * if the allocation fails, then use m_devget and leave the 1332 * existing buffer in the receive ring. 1333 */ | 1276 struct mbuf *m; 1277 struct ifnet *ifp; 1278 struct sis_desc *cur_rx; 1279 int i, total_len = 0; 1280 u_int32_t rxstat; 1281 1282 ifp = &sc->arpcom.ac_if; 1283 i = sc->sis_cdata.sis_rx_prod; --- 38 unchanged lines hidden (view full) --- 1322 * On the x86 we do not have alignment problems, so try to 1323 * allocate a new buffer for the receive ring, and pass up 1324 * the one where the packet is already, saving the expensive 1325 * copy done in m_devget(). 1326 * If we are on an architecture with alignment problems, or 1327 * if the allocation fails, then use m_devget and leave the 1328 * existing buffer in the receive ring. 1329 */ |
1334 if (sis_newbuf(sc, cur_rx, NULL) == 0) { 1335 m->m_pkthdr.rcvif = ifp; | 1330 if (sis_newbuf(sc, cur_rx, NULL) == 0) |
1336 m->m_pkthdr.len = m->m_len = total_len; | 1331 m->m_pkthdr.len = m->m_len = total_len; |
1337 } else | 1332 else |
1338#endif 1339 { 1340 struct mbuf *m0; 1341 m0 = m_devget(mtod(m, char *), total_len, 1342 ETHER_ALIGN, ifp, NULL); 1343 sis_newbuf(sc, cur_rx, m); 1344 if (m0 == NULL) { 1345 ifp->if_ierrors++; 1346 continue; 1347 } 1348 m = m0; 1349 } 1350 1351 ifp->if_ipackets++; | 1333#endif 1334 { 1335 struct mbuf *m0; 1336 m0 = m_devget(mtod(m, char *), total_len, 1337 ETHER_ALIGN, ifp, NULL); 1338 sis_newbuf(sc, cur_rx, m); 1339 if (m0 == NULL) { 1340 ifp->if_ierrors++; 1341 continue; 1342 } 1343 m = m0; 1344 } 1345 1346 ifp->if_ipackets++; |
1352 eh = mtod(m, struct ether_header *); 1353 1354 /* Remove header from mbuf and pass it on. */ 1355 m_adj(m, sizeof(struct ether_header)); 1356 ether_input(ifp, eh, m); | 1347 ether_input(ifp, NULL, m); |
1357 } 1358 1359 sc->sis_cdata.sis_rx_prod = i; 1360 1361 return; 1362} 1363 1364void sis_rxeoc(sc) --- 697 unchanged lines hidden --- | 1348 } 1349 1350 sc->sis_cdata.sis_rx_prod = i; 1351 1352 return; 1353} 1354 1355void sis_rxeoc(sc) --- 697 unchanged lines hidden --- |