if_gx.c (270856) | if_gx.c (271849) |
---|---|
1/*- 2 * Copyright (c) 2008-2012 Juli Mallett <jmallett@FreeBSD.org> 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 --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * | 1/*- 2 * Copyright (c) 2008-2012 Juli Mallett <jmallett@FreeBSD.org> 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 --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * $FreeBSD: head/sys/dev/gxemul/ether/if_gx.c 270856 2014-08-30 19:55:54Z glebius $ | 26 * $FreeBSD: head/sys/dev/gxemul/ether/if_gx.c 271849 2014-09-19 03:51:26Z glebius $ |
27 */ 28 29#include "opt_inet.h" 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/bus.h> 34#include <sys/endian.h> --- 208 unchanged lines hidden (view full) --- 243 GXEMUL_ETHER_LOCK(sc); 244 GXEMUL_ETHER_DEV_WRITE(GXEMUL_ETHER_DEV_LENGTH, m->m_pkthdr.len); 245 m_copydata(m, 0, m->m_pkthdr.len, (void *)(uintptr_t)GXEMUL_ETHER_DEV_FUNCTION(GXEMUL_ETHER_DEV_BUFFER)); 246 GXEMUL_ETHER_DEV_WRITE(GXEMUL_ETHER_DEV_COMMAND, GXEMUL_ETHER_DEV_COMMAND_TX); 247 GXEMUL_ETHER_UNLOCK(sc); 248 249 ETHER_BPF_MTAP(ifp, m); 250 | 27 */ 28 29#include "opt_inet.h" 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/bus.h> 34#include <sys/endian.h> --- 208 unchanged lines hidden (view full) --- 243 GXEMUL_ETHER_LOCK(sc); 244 GXEMUL_ETHER_DEV_WRITE(GXEMUL_ETHER_DEV_LENGTH, m->m_pkthdr.len); 245 m_copydata(m, 0, m->m_pkthdr.len, (void *)(uintptr_t)GXEMUL_ETHER_DEV_FUNCTION(GXEMUL_ETHER_DEV_BUFFER)); 246 GXEMUL_ETHER_DEV_WRITE(GXEMUL_ETHER_DEV_COMMAND, GXEMUL_ETHER_DEV_COMMAND_TX); 247 GXEMUL_ETHER_UNLOCK(sc); 248 249 ETHER_BPF_MTAP(ifp, m); 250 |
251 ifp->if_opackets++; 252 ifp->if_obytes += m->m_pkthdr.len; | 251 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); 252 if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); |
253 254 m_freem(m); 255 256 return (0); 257} 258 259static int 260gx_medchange(struct ifnet *ifp) --- 100 unchanged lines hidden (view full) --- 361 if (status == GXEMUL_ETHER_DEV_STATUS_RX_MORE) { 362 GXEMUL_ETHER_DEV_WRITE(GXEMUL_ETHER_DEV_COMMAND, GXEMUL_ETHER_DEV_COMMAND_RX); 363 continue; 364 } 365 if (status != GXEMUL_ETHER_DEV_STATUS_RX_OK) 366 break; 367 length = GXEMUL_ETHER_DEV_READ(GXEMUL_ETHER_DEV_LENGTH); 368 if (length > MCLBYTES - ETHER_ALIGN) { | 253 254 m_freem(m); 255 256 return (0); 257} 258 259static int 260gx_medchange(struct ifnet *ifp) --- 100 unchanged lines hidden (view full) --- 361 if (status == GXEMUL_ETHER_DEV_STATUS_RX_MORE) { 362 GXEMUL_ETHER_DEV_WRITE(GXEMUL_ETHER_DEV_COMMAND, GXEMUL_ETHER_DEV_COMMAND_RX); 363 continue; 364 } 365 if (status != GXEMUL_ETHER_DEV_STATUS_RX_OK) 366 break; 367 length = GXEMUL_ETHER_DEV_READ(GXEMUL_ETHER_DEV_LENGTH); 368 if (length > MCLBYTES - ETHER_ALIGN) { |
369 sc->sc_ifp->if_ierrors++; | 369 if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1); |
370 continue; 371 } 372 373 m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); 374 if (m == NULL) { 375 device_printf(sc->sc_dev, "no memory for receive mbuf.\n"); | 370 continue; 371 } 372 373 m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); 374 if (m == NULL) { 375 device_printf(sc->sc_dev, "no memory for receive mbuf.\n"); |
376 sc->sc_ifp->if_iqdrops++; | 376 if_inc_counter(sc->sc_ifp, IFCOUNTER_IQDROPS, 1); |
377 GXEMUL_ETHER_UNLOCK(sc); 378 return; 379 } 380 381 /* Align incoming frame so IP headers are aligned. */ 382 m->m_data += ETHER_ALIGN; 383 384 memcpy(m->m_data, (const void *)(uintptr_t)GXEMUL_ETHER_DEV_FUNCTION(GXEMUL_ETHER_DEV_BUFFER), length); 385 386 m->m_pkthdr.rcvif = sc->sc_ifp; 387 m->m_pkthdr.len = m->m_len = length; 388 | 377 GXEMUL_ETHER_UNLOCK(sc); 378 return; 379 } 380 381 /* Align incoming frame so IP headers are aligned. */ 382 m->m_data += ETHER_ALIGN; 383 384 memcpy(m->m_data, (const void *)(uintptr_t)GXEMUL_ETHER_DEV_FUNCTION(GXEMUL_ETHER_DEV_BUFFER), length); 385 386 m->m_pkthdr.rcvif = sc->sc_ifp; 387 m->m_pkthdr.len = m->m_len = length; 388 |
389 sc->sc_ifp->if_ipackets++; | 389 if_inc_counter(sc->sc_ifp, IFCOUNTER_IPACKETS, 1); |
390 391 GXEMUL_ETHER_UNLOCK(sc); 392 393 (*sc->sc_ifp->if_input)(sc->sc_ifp, m); 394 395 GXEMUL_ETHER_LOCK(sc); 396 } 397 GXEMUL_ETHER_UNLOCK(sc); 398} | 390 391 GXEMUL_ETHER_UNLOCK(sc); 392 393 (*sc->sc_ifp->if_input)(sc->sc_ifp, m); 394 395 GXEMUL_ETHER_LOCK(sc); 396 } 397 GXEMUL_ETHER_UNLOCK(sc); 398} |