From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MCgP2-0001Ra-Cr for qemu-devel@nongnu.org; Fri, 05 Jun 2009 16:52:40 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MCgOx-0001M0-Po for qemu-devel@nongnu.org; Fri, 05 Jun 2009 16:52:39 -0400 Received: from [199.232.76.173] (port=38242 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MCgOx-0001Lk-Fi for qemu-devel@nongnu.org; Fri, 05 Jun 2009 16:52:35 -0400 Received: from g5t0006.atlanta.hp.com ([15.192.0.43]:32083) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MCgOx-0005t2-3v for qemu-devel@nongnu.org; Fri, 05 Jun 2009 16:52:35 -0400 Received: from g4t0018.houston.hp.com (g4t0018.houston.hp.com [16.234.32.27]) by g5t0006.atlanta.hp.com (Postfix) with ESMTP id 0A6DEC1A5 for ; Fri, 5 Jun 2009 20:52:34 +0000 (UTC) From: Alex Williamson Date: Fri, 05 Jun 2009 14:47:02 -0600 Message-ID: <20090605204702.3355.43207.stgit@kvm.aw> In-Reply-To: <20090605204647.3355.81929.stgit@kvm.aw> References: <20090605204647.3355.81929.stgit@kvm.aw> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 3/7] virtio-net: reorganize receive_filter() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: alex.williamson@hp.com Reorganize receive_filter to better handle the split between unicast and multicast filtering. This allows us to skip the broadcast check on unicast packets and leads to more opportunities for optimization. Signed-off-by: Alex Williamson --- hw/virtio-net.c | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index de5a59f..395b735 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -344,14 +344,17 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size) return 0; } - if ((ptr[0] & 1) && n->allmulti) - return 1; - - if (!memcmp(ptr, bcast, sizeof(bcast))) - return 1; - - if (!memcmp(ptr, n->mac, ETH_ALEN)) - return 1; + if (ptr[0] & 1) { // multicast + if (!memcmp(ptr, bcast, sizeof(bcast))) { + return 1; + } else if (n->allmulti) { + return 1; + } + } else { // unicast + if (!memcmp(ptr, n->mac, ETH_ALEN)) { + return 1; + } + } for (i = 0; i < n->mac_table.in_use; i++) { if (!memcmp(ptr, &n->mac_table.macs[i * ETH_ALEN], ETH_ALEN))