if_ic.c (257176) | if_ic.c (271849) |
---|---|
1/*- 2 * Copyright (c) 1998, 2001 Nicolas Souchu 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 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1998, 2001 Nicolas Souchu 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 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/iicbus/if_ic.c 257176 2013-10-26 17:58:36Z glebius $"); | 28__FBSDID("$FreeBSD: head/sys/dev/iicbus/if_ic.c 271849 2014-09-19 03:51:26Z glebius $"); |
29 30/* 31 * I2C bus IP driver 32 */ 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/mbuf.h> --- 260 unchanged lines hidden (view full) --- 297 wakeup(&sc); 298 if (sc->ic_iferrs) 299 goto err; 300 if ((len = sc->ic_xfercnt) == 0) 301 break; /* ignore */ 302 if (len <= ICHDRLEN) 303 goto err; 304 len -= ICHDRLEN; | 29 30/* 31 * I2C bus IP driver 32 */ 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/mbuf.h> --- 260 unchanged lines hidden (view full) --- 297 wakeup(&sc); 298 if (sc->ic_iferrs) 299 goto err; 300 if ((len = sc->ic_xfercnt) == 0) 301 break; /* ignore */ 302 if (len <= ICHDRLEN) 303 goto err; 304 len -= ICHDRLEN; |
305 sc->ic_ifp->if_ipackets++; 306 sc->ic_ifp->if_ibytes += len; | 305 if_inc_counter(sc->ic_ifp, IFCOUNTER_IPACKETS, 1); 306 if_inc_counter(sc->ic_ifp, IFCOUNTER_IBYTES, len); |
307 BPF_TAP(sc->ic_ifp, sc->ic_ifbuf, len + ICHDRLEN); 308 top = m_devget(sc->ic_ifbuf + ICHDRLEN, len, 0, sc->ic_ifp, 0); 309 if (top) { 310 mtx_unlock(&sc->ic_lock); 311 M_SETFIB(top, sc->ic_ifp->if_fib); 312 netisr_dispatch(NETISR_IP, top); 313 mtx_lock(&sc->ic_lock); 314 } 315 break; 316 err: 317 if_printf(sc->ic_ifp, "errors (%d)!\n", sc->ic_iferrs); 318 sc->ic_iferrs = 0; /* reset error count */ | 307 BPF_TAP(sc->ic_ifp, sc->ic_ifbuf, len + ICHDRLEN); 308 top = m_devget(sc->ic_ifbuf + ICHDRLEN, len, 0, sc->ic_ifp, 0); 309 if (top) { 310 mtx_unlock(&sc->ic_lock); 311 M_SETFIB(top, sc->ic_ifp->if_fib); 312 netisr_dispatch(NETISR_IP, top); 313 mtx_lock(&sc->ic_lock); 314 } 315 break; 316 err: 317 if_printf(sc->ic_ifp, "errors (%d)!\n", sc->ic_iferrs); 318 sc->ic_iferrs = 0; /* reset error count */ |
319 sc->ic_ifp->if_ierrors++; | 319 if_inc_counter(sc->ic_ifp, IFCOUNTER_IERRORS, 1); |
320 break; 321 322 case INTR_RECEIVE: 323 if (sc->ic_xfercnt >= sc->ic_ifp->if_mtu + ICHDRLEN) { 324 sc->ic_iferrs++; 325 } else { 326 *sc->ic_cp++ = *ptr; 327 sc->ic_xfercnt++; --- 40 unchanged lines hidden (view full) --- 368 else 369 hdr = dst->sa_family; 370 371 mtx_lock(&sc->ic_lock); 372 ifp->if_drv_flags |= IFF_DRV_RUNNING; 373 374 /* already sending? */ 375 if (sc->ic_flags & IC_SENDING) { | 320 break; 321 322 case INTR_RECEIVE: 323 if (sc->ic_xfercnt >= sc->ic_ifp->if_mtu + ICHDRLEN) { 324 sc->ic_iferrs++; 325 } else { 326 *sc->ic_cp++ = *ptr; 327 sc->ic_xfercnt++; --- 40 unchanged lines hidden (view full) --- 368 else 369 hdr = dst->sa_family; 370 371 mtx_lock(&sc->ic_lock); 372 ifp->if_drv_flags |= IFF_DRV_RUNNING; 373 374 /* already sending? */ 375 if (sc->ic_flags & IC_SENDING) { |
376 ifp->if_oerrors++; | 376 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
377 goto error; 378 } 379 380 /* insert header */ 381 bcopy ((char *)&hdr, sc->ic_obuf, ICHDRLEN); 382 383 cp = sc->ic_obuf + ICHDRLEN; 384 len = 0; 385 mm = m; 386 do { 387 if (len + mm->m_len > sc->ic_ifp->if_mtu) { 388 /* packet too large */ | 377 goto error; 378 } 379 380 /* insert header */ 381 bcopy ((char *)&hdr, sc->ic_obuf, ICHDRLEN); 382 383 cp = sc->ic_obuf + ICHDRLEN; 384 len = 0; 385 mm = m; 386 do { 387 if (len + mm->m_len > sc->ic_ifp->if_mtu) { 388 /* packet too large */ |
389 ifp->if_oerrors++; | 389 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
390 goto error; 391 } 392 393 bcopy(mtod(mm,char *), cp, mm->m_len); 394 cp += mm->m_len; 395 len += mm->m_len; 396 397 } while ((mm = mm->m_next)); --- 4 unchanged lines hidden (view full) --- 402 403 m_freem(m); 404 mtx_unlock(&sc->ic_lock); 405 406 /* send the packet */ 407 if (iicbus_block_write(parent, sc->ic_addr, sc->ic_obuf, 408 len + ICHDRLEN, &sent)) 409 | 390 goto error; 391 } 392 393 bcopy(mtod(mm,char *), cp, mm->m_len); 394 cp += mm->m_len; 395 len += mm->m_len; 396 397 } while ((mm = mm->m_next)); --- 4 unchanged lines hidden (view full) --- 402 403 m_freem(m); 404 mtx_unlock(&sc->ic_lock); 405 406 /* send the packet */ 407 if (iicbus_block_write(parent, sc->ic_addr, sc->ic_obuf, 408 len + ICHDRLEN, &sent)) 409 |
410 ifp->if_oerrors++; | 410 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
411 else { | 411 else { |
412 ifp->if_opackets++; 413 ifp->if_obytes += len; | 412 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); 413 if_inc_counter(ifp, IFCOUNTER_OBYTES, len); |
414 } 415 416 mtx_lock(&sc->ic_lock); 417 sc->ic_flags &= ~(IC_SENDING | IC_OBUF_BUSY); 418 if ((sc->ic_flags & (IC_BUFFERS_BUSY | IC_BUFFER_WAITER)) == 419 IC_BUFFER_WAITER) 420 wakeup(&sc); 421 mtx_unlock(&sc->ic_lock); --- 13 unchanged lines hidden --- | 414 } 415 416 mtx_lock(&sc->ic_lock); 417 sc->ic_flags &= ~(IC_SENDING | IC_OBUF_BUSY); 418 if ((sc->ic_flags & (IC_BUFFERS_BUSY | IC_BUFFER_WAITER)) == 419 IC_BUFFER_WAITER) 420 wakeup(&sc); 421 mtx_unlock(&sc->ic_lock); --- 13 unchanged lines hidden --- |