if_my.c (95807) | if_my.c (95939) |
---|---|
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 95807 2002-04-30 16:43:51Z julian $ | 28 * $FreeBSD: head/sys/dev/my/if_my.c 95939 2002-05-02 15:58:04Z julian $ |
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> --- 1139 unchanged lines hidden (view full) --- 1176{ 1177 struct mbuf *m_new = NULL; 1178 1179 MY_LOCK(sc); 1180 MGETHDR(m_new, M_DONTWAIT, MT_DATA); 1181 if (m_new == NULL) { 1182 printf("my%d: no memory for rx list -- packet dropped!\n", 1183 sc->my_unit); | 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> --- 1139 unchanged lines hidden (view full) --- 1176{ 1177 struct mbuf *m_new = NULL; 1178 1179 MY_LOCK(sc); 1180 MGETHDR(m_new, M_DONTWAIT, MT_DATA); 1181 if (m_new == NULL) { 1182 printf("my%d: no memory for rx list -- packet dropped!\n", 1183 sc->my_unit); |
1184 MY_UNLOCK(sc); |
|
1184 return (ENOBUFS); 1185 } 1186 MCLGET(m_new, M_DONTWAIT); 1187 if (!(m_new->m_flags & M_EXT)) { 1188 printf("my%d: no memory for rx list -- packet dropped!\n", 1189 sc->my_unit); 1190 m_freem(m_new); | 1185 return (ENOBUFS); 1186 } 1187 MCLGET(m_new, M_DONTWAIT); 1188 if (!(m_new->m_flags & M_EXT)) { 1189 printf("my%d: no memory for rx list -- packet dropped!\n", 1190 sc->my_unit); 1191 m_freem(m_new); |
1192 MY_UNLOCK(sc); |
|
1191 return (ENOBUFS); 1192 } 1193 c->my_mbuf = m_new; 1194 c->my_ptr->my_data = vtophys(mtod(m_new, caddr_t)); 1195 c->my_ptr->my_ctl = (MCLBYTES - 1) << MY_RBSShift; 1196 c->my_ptr->my_status = MY_OWNByNIC; 1197 MY_UNLOCK(sc); 1198 return (0); --- 92 unchanged lines hidden (view full) --- 1291{ 1292 struct my_chain *cur_tx; 1293 struct ifnet *ifp; 1294 1295 MY_LOCK(sc); 1296 ifp = &sc->arpcom.ac_if; 1297 /* Clear the timeout timer. */ 1298 ifp->if_timer = 0; | 1193 return (ENOBUFS); 1194 } 1195 c->my_mbuf = m_new; 1196 c->my_ptr->my_data = vtophys(mtod(m_new, caddr_t)); 1197 c->my_ptr->my_ctl = (MCLBYTES - 1) << MY_RBSShift; 1198 c->my_ptr->my_status = MY_OWNByNIC; 1199 MY_UNLOCK(sc); 1200 return (0); --- 92 unchanged lines hidden (view full) --- 1293{ 1294 struct my_chain *cur_tx; 1295 struct ifnet *ifp; 1296 1297 MY_LOCK(sc); 1298 ifp = &sc->arpcom.ac_if; 1299 /* Clear the timeout timer. */ 1300 ifp->if_timer = 0; |
1299 if (sc->my_cdata.my_tx_head == NULL) | 1301 if (sc->my_cdata.my_tx_head == NULL) { 1302 MY_UNLOCK(sc); |
1300 return; | 1303 return; |
1304 } |
|
1301 /* 1302 * Go through our tx list and free mbufs for those frames that have 1303 * been transmitted. 1304 */ 1305 while (sc->my_cdata.my_tx_head->my_mbuf != NULL) { 1306 u_int32_t txstat; 1307 1308 cur_tx = sc->my_cdata.my_tx_head; --- 136 unchanged lines hidden (view full) --- 1445 * Start packing the mbufs in this chain into the fragment pointers. 1446 * Stop when we run out of fragments or hit the end of the mbuf 1447 * chain. 1448 */ 1449 m = m_head; 1450 MGETHDR(m_new, M_DONTWAIT, MT_DATA); 1451 if (m_new == NULL) { 1452 printf("my%d: no memory for tx list", sc->my_unit); | 1305 /* 1306 * Go through our tx list and free mbufs for those frames that have 1307 * been transmitted. 1308 */ 1309 while (sc->my_cdata.my_tx_head->my_mbuf != NULL) { 1310 u_int32_t txstat; 1311 1312 cur_tx = sc->my_cdata.my_tx_head; --- 136 unchanged lines hidden (view full) --- 1449 * Start packing the mbufs in this chain into the fragment pointers. 1450 * Stop when we run out of fragments or hit the end of the mbuf 1451 * chain. 1452 */ 1453 m = m_head; 1454 MGETHDR(m_new, M_DONTWAIT, MT_DATA); 1455 if (m_new == NULL) { 1456 printf("my%d: no memory for tx list", sc->my_unit); |
1457 MY_UNLOCK(sc); |
|
1453 return (1); 1454 } 1455 if (m_head->m_pkthdr.len > MHLEN) { 1456 MCLGET(m_new, M_DONTWAIT); 1457 if (!(m_new->m_flags & M_EXT)) { 1458 m_freem(m_new); 1459 printf("my%d: no memory for tx list", sc->my_unit); | 1458 return (1); 1459 } 1460 if (m_head->m_pkthdr.len > MHLEN) { 1461 MCLGET(m_new, M_DONTWAIT); 1462 if (!(m_new->m_flags & M_EXT)) { 1463 m_freem(m_new); 1464 printf("my%d: no memory for tx list", sc->my_unit); |
1465 MY_UNLOCK(sc); |
|
1460 return (1); 1461 } 1462 } 1463 m_copydata(m_head, 0, m_head->m_pkthdr.len, mtod(m_new, caddr_t)); 1464 m_new->m_pkthdr.len = m_new->m_len = m_head->m_pkthdr.len; 1465 m_freem(m_head); 1466 m_head = m_new; 1467 f = &c->my_ptr->my_frag[0]; --- 398 unchanged lines hidden (view full) --- 1866my_shutdown(device_t dev) 1867{ 1868 struct my_softc *sc; 1869 1870 sc = device_get_softc(dev); 1871 my_stop(sc); 1872 return; 1873} | 1466 return (1); 1467 } 1468 } 1469 m_copydata(m_head, 0, m_head->m_pkthdr.len, mtod(m_new, caddr_t)); 1470 m_new->m_pkthdr.len = m_new->m_len = m_head->m_pkthdr.len; 1471 m_freem(m_head); 1472 m_head = m_new; 1473 f = &c->my_ptr->my_frag[0]; --- 398 unchanged lines hidden (view full) --- 1872my_shutdown(device_t dev) 1873{ 1874 struct my_softc *sc; 1875 1876 sc = device_get_softc(dev); 1877 my_stop(sc); 1878 return; 1879} |
1880 1881 |
|