| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_shmem.c,v 1.55 2013/06/14 05:56:29 pooka Exp $ */ | | 1 | /* $NetBSD: if_shmem.c,v 1.56 2013/06/14 05:59:50 pooka Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. | | 4 | * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. |
5 | * | | 5 | * |
6 | * Development of this software was supported by The Nokia Foundation. | | 6 | * Development of this software was supported by The Nokia Foundation. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -18,27 +18,27 @@ | | | @@ -18,27 +18,27 @@ |
18 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | | 18 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | | 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
20 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | | 20 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | | 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
27 | * SUCH DAMAGE. | | 27 | * SUCH DAMAGE. |
28 | */ | | 28 | */ |
29 | | | 29 | |
30 | #include <sys/cdefs.h> | | 30 | #include <sys/cdefs.h> |
31 | __KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.55 2013/06/14 05:56:29 pooka Exp $"); | | 31 | __KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.56 2013/06/14 05:59:50 pooka Exp $"); |
32 | | | 32 | |
33 | #include <sys/param.h> | | 33 | #include <sys/param.h> |
34 | #include <sys/atomic.h> | | 34 | #include <sys/atomic.h> |
35 | #include <sys/fcntl.h> | | 35 | #include <sys/fcntl.h> |
36 | #include <sys/kmem.h> | | 36 | #include <sys/kmem.h> |
37 | #include <sys/kthread.h> | | 37 | #include <sys/kthread.h> |
38 | #include <sys/lock.h> | | 38 | #include <sys/lock.h> |
39 | #include <sys/vmem.h> | | 39 | #include <sys/vmem.h> |
40 | #include <sys/cprng.h> | | 40 | #include <sys/cprng.h> |
41 | | | 41 | |
42 | #include <net/bpf.h> | | 42 | #include <net/bpf.h> |
43 | #include <net/if.h> | | 43 | #include <net/if.h> |
44 | #include <net/if_dl.h> | | 44 | #include <net/if_dl.h> |
| @@ -714,26 +714,30 @@ shmif_rcv(void *arg) | | | @@ -714,26 +714,30 @@ shmif_rcv(void *arg) |
714 | | | 714 | |
715 | DPRINTF(("shmif_rcv: read packet of length %d at %d\n", | | 715 | DPRINTF(("shmif_rcv: read packet of length %d at %d\n", |
716 | sp.sp_len, nextpkt)); | | 716 | sp.sp_len, nextpkt)); |
717 | | | 717 | |
718 | sc->sc_nextpacket = nextpkt; | | 718 | sc->sc_nextpacket = nextpkt; |
719 | shmif_unlockbus(sc->sc_busmem); | | 719 | shmif_unlockbus(sc->sc_busmem); |
720 | | | 720 | |
721 | if (wrap) { | | 721 | if (wrap) { |
722 | sc->sc_devgen++; | | 722 | sc->sc_devgen++; |
723 | DPRINTF(("dev %p generation now %" PRIu64 "\n", | | 723 | DPRINTF(("dev %p generation now %" PRIu64 "\n", |
724 | sc, sc->sc_devgen)); | | 724 | sc, sc->sc_devgen)); |
725 | } | | 725 | } |
726 | | | 726 | |
| | | 727 | /* |
| | | 728 | * Ignore packets too short to possibly be valid. |
| | | 729 | * This is hit at least for the first frame on a new bus. |
| | | 730 | */ |
727 | if (__predict_false(sp.sp_len < ETHER_HDR_LEN)) { | | 731 | if (__predict_false(sp.sp_len < ETHER_HDR_LEN)) { |
728 | DPRINTF(("shmif read packet len %d < ETHER_HDR_LEN\n", | | 732 | DPRINTF(("shmif read packet len %d < ETHER_HDR_LEN\n", |
729 | sp.sp_len)); | | 733 | sp.sp_len)); |
730 | continue; | | 734 | continue; |
731 | } | | 735 | } |
732 | | | 736 | |
733 | m->m_len = m->m_pkthdr.len = sp.sp_len; | | 737 | m->m_len = m->m_pkthdr.len = sp.sp_len; |
734 | m->m_pkthdr.rcvif = ifp; | | 738 | m->m_pkthdr.rcvif = ifp; |
735 | | | 739 | |
736 | /* | | 740 | /* |
737 | * Test if we want to pass the packet upwards | | 741 | * Test if we want to pass the packet upwards |
738 | */ | | 742 | */ |
739 | eth = mtod(m, struct ether_header *); | | 743 | eth = mtod(m, struct ether_header *); |