From patchwork Wed Mar 10 10:11:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1450430 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Rg6KB72/; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DwSjn4L6qz9sR4 for ; Wed, 10 Mar 2021 21:19:25 +1100 (AEDT) Received: from localhost ([::1]:58614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJvw3-0006cv-KU for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2021 05:19:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJvp9-0000qD-U0 for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:15 -0500 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]:40456) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJvp7-0006md-Ti for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:15 -0500 Received: by mail-ej1-x632.google.com with SMTP id ci14so37434023ejc.7 for ; Wed, 10 Mar 2021 02:12:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=lkRZyfD9QooRn1+sjjF0FxwBKOhdL98WsYjA2hcSBME=; b=Rg6KB72/zM9bDZISWRtAjiKON4Vy8QJGZ1pU2sUXHXsbMmPus6g6oY5LQABxqR8Imf ORmfWTN4SEEgndXT5eRLqymzQ68GpR6bh4iExTOhJixERQAYJfQ/EAhHDpbpuJj9QvaT r4tfOINTfBHFZWeOXxXbbOPmR+WArjJEw8nQdMOG+HAlWpNMSm80Vj6XQKR11fC7Uxb4 bELOQcbbkxuqR0O/ir0Dy8MO1An85ZCTIF2hxSkDpUyNJizdgUJuLgEMTdbqq+6z2eyo t6cQ0VCZPVR0T3SH293VOdJhYxm+iMmkHuMo6WR8SqUazZDV/BfuyZP9NEgjYxWzro8L by3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lkRZyfD9QooRn1+sjjF0FxwBKOhdL98WsYjA2hcSBME=; b=EGtb0CtmJ4dGsAboudTWf2W2FsZBP2rI8li9ccxFWwzSQlISRuymXu3/2bWQoDUnmk 6ya6+kLRIsNf92mJRREqyNJneuJbjNMB4T23CKWLysYkBbnfXjqB1JffzGyoOAZITsjM W19ZxRDUNHLjmS6AqtBuyWLolWLRfKlqDAXt1Z+A2429p8EV1yaTfr1b6ukgOIxhB/Rc pmYPQrQFsJIIZIOWj72OcDvZoD15an5L/fV8GQXpZLBb+4CK5njQHfMX6G9MkwTQWMKJ KoZ3tEHB09cr9YHBe+YrSvlUMINetfV0vdsOrhRjTmmUwjeF/quMiKjmsnNWu5N7dd26 eHLA== X-Gm-Message-State: AOAM5319PK056fZGj5MbqgVGlYJSSA+4PTV9uduTYI/ebuMM0lmIB/3h 9hZKWAQlHgZBifa0uXIWFrSSCywFtT0= X-Google-Smtp-Source: ABdhPJyOrP9gc1Ik0L0BmVMsg2L/PRepO2fvcCklEqkx8UQM4sGr4dLrnbcbh5JUx6s6IAzJmIcICQ== X-Received: by 2002:a17:906:2710:: with SMTP id z16mr2887292ejc.176.1615371131890; Wed, 10 Mar 2021 02:12:11 -0800 (PST) Received: from pek-vx-bsp9.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id n26sm5966864eds.22.2021.03.10.02.12.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 02:12:11 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH 01/10] net: Use 'struct iovec' in qemu_send_packet_async_with_flags() Date: Wed, 10 Mar 2021 18:11:48 +0800 Message-Id: <20210310101157.15136-2-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210310101157.15136-1-bmeng.cn@gmail.com> References: <20210310101157.15136-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::632; envelope-from=bmeng.cn@gmail.com; helo=mail-ej1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Directly use iovec structure in qemu_send_packet_async_with_flags() by inlining filter_receive() and using qemu_net_queue_send_iov() instead of qemu_net_queue_send(). Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20210303191205.1656980-2-philmd@redhat.com> Signed-off-by: Bin Meng --- net/net.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/net/net.c b/net/net.c index 32d71c1172..bb1d455005 100644 --- a/net/net.c +++ b/net/net.c @@ -582,22 +582,6 @@ static ssize_t filter_receive_iov(NetClientState *nc, return ret; } -static ssize_t filter_receive(NetClientState *nc, - NetFilterDirection direction, - NetClientState *sender, - unsigned flags, - const uint8_t *data, - size_t size, - NetPacketSent *sent_cb) -{ - struct iovec iov = { - .iov_base = (void *)data, - .iov_len = size - }; - - return filter_receive_iov(nc, direction, sender, flags, &iov, 1, sent_cb); -} - void qemu_purge_queued_packets(NetClientState *nc) { if (!nc->peer) { @@ -639,6 +623,13 @@ static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender, { NetQueue *queue; int ret; + int iovcnt = 1; + struct iovec iov[] = { + [0] = { + .iov_base = (void *)buf, + .iov_len = size, + }, + }; #ifdef DEBUG_NET printf("qemu_send_packet_async:\n"); @@ -650,21 +641,21 @@ static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender, } /* Let filters handle the packet first */ - ret = filter_receive(sender, NET_FILTER_DIRECTION_TX, - sender, flags, buf, size, sent_cb); + ret = filter_receive_iov(sender, NET_FILTER_DIRECTION_TX, + sender, flags, iov, iovcnt, sent_cb); if (ret) { return ret; } - ret = filter_receive(sender->peer, NET_FILTER_DIRECTION_RX, - sender, flags, buf, size, sent_cb); + ret = filter_receive_iov(sender->peer, NET_FILTER_DIRECTION_RX, + sender, flags, iov, iovcnt, sent_cb); if (ret) { return ret; } queue = sender->peer->incoming_queue; - return qemu_net_queue_send(queue, sender, flags, buf, size, sent_cb); + return qemu_net_queue_send_iov(queue, sender, flags, iov, iovcnt, sent_cb); } ssize_t qemu_send_packet_async(NetClientState *sender, From patchwork Wed Mar 10 10:11:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1450424 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=ZpNRBJ1V; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DwSb41PGxz9sRN for ; Wed, 10 Mar 2021 21:13:36 +1100 (AEDT) Received: from localhost ([::1]:49074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJvqQ-0001vg-7Z for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2021 05:13:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJvpD-0000r1-2p for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:19 -0500 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]:41902) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJvpB-0006os-07 for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:18 -0500 Received: by mail-ed1-x529.google.com with SMTP id b7so27200376edz.8 for ; Wed, 10 Mar 2021 02:12:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=HxFFXAbZcWSQYuiy3ELtMKaSRJK0/t+aYYLt3NELl6I=; b=ZpNRBJ1VrVBG31idwVgJKuFl9JhtzyEv1AvAdknhbGunrYW715ursxwhCL1NF/NZwB YrQM2exkcp0AbtLDYVlRf63YJIqYBC6NL3KzB9ScG2J5HlS2isrqRhgpzwqwy4XXASww LmoRxnyU8BR+QNqpFKpXkwjTiX/GBAPQkK1Tt0ERjGLMdsG7TnR0ylGGo0vXv2Sd59Lc JaW9FF+OlU02K+EhM06YdIcAR8xC78GWzk1LqdmDK1CYEDdL9yjFE1njri7Q7itw42Jm MisGxtrqcP7F3u0MmhzKlLoouybm2lV0vjgMKHZnuvjfeI/fhfnfsP6ijmBBhvBvpJmF TpLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HxFFXAbZcWSQYuiy3ELtMKaSRJK0/t+aYYLt3NELl6I=; b=oIyqmBZCOX25227o8+dIoN8LOTLAi1Dd0+G8NLaGoi/u1+9e3KVQ8vXLCmzBBo8k7z 5quN01TtnqkAXCSvzwcAD4rKozgXKeEt7k+bzXvw0Sn9lKq7w4QKFWNIgnxVjhdKXO0x 9H7Y7M1Ep+K1EsksDgsoFDdsPhvGo5U1vCoiAuGpFno6whTv3/K+CaXovyYjsUm5zwdA 04CFg4Krih3fBpGJrKEU/YYe8405r55ByMuzxqtCViUiCv7SYyYgMt8Hw1i5fv9q83uB gWJ7fJGRfGZa2xmv9SLzNGeWaNbzDwFv+zvRhYXYcvmGd4hmjAO6MXXQ5sbKqdPvLR7g a9OQ== X-Gm-Message-State: AOAM532G1nLXLkpNL5r7PMp38C5MAyO020P8Xqy3MUOz9VvneDZD9zr+ wZlekw/nnM+SyIZAYFr8EtY= X-Google-Smtp-Source: ABdhPJwvgvPEQo5Thrg8S340Cwp2ItEYNUgBT9IbyrtoBJ8UYCajYhGRMuM7ppazxf2hlHSWtpjegQ== X-Received: by 2002:a05:6402:13ca:: with SMTP id a10mr2393163edx.320.1615371135509; Wed, 10 Mar 2021 02:12:15 -0800 (PST) Received: from pek-vx-bsp9.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id n26sm5966864eds.22.2021.03.10.02.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 02:12:15 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH 02/10] net: Pad short frames to minimum size before send Date: Wed, 10 Mar 2021 18:11:49 +0800 Message-Id: <20210310101157.15136-3-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210310101157.15136-1-bmeng.cn@gmail.com> References: <20210310101157.15136-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=bmeng.cn@gmail.com; helo=mail-ed1-x529.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The minimum Ethernet frame length is 60 bytes. For short frames with smaller length like ARP packets (only 42 bytes), on a real world NIC it can choose either padding its length to the minimum required 60 bytes, or sending it out directly to the wire. Such behavior can be hardcoded or controled by a register bit. Similarly on the receive path, NICs can choose either dropping such short frames directly or handing them over to software to handle. On the other hand, for the network backends like SLiRP/TAP, they don't expose a way to control the short frame behavior. As of today they just send/receive data from/to the other end connected to them, which means any sized packet is acceptable. So they can send and receive short frames without any problem. It is observed that ARP packets sent from SLiRP/TAP are 42 bytes, and SLiRP/TAP just send these ARP packets to the other end which might be a NIC model that does not allow short frames to pass through. To provide better compatibility, for packets sent from QEMU network backends, we change to pad short frames before sending it out to the other end. This ensures a backend as an Ethernet sender does not violate the spec. But with this change, the behavior of dropping short frames in the NIC model cannot be emulated because it always receives a packet that is spec complaint. The capability of sending short frames from NIC models cannot be supported as well. This commit should be able to fix the issue as reported with some NIC models before, that ARP requests get dropped, preventing the guest from becoming visible on the network. It was workarounded in these NIC models on the receive path, that when a short frame is received, it is padded up to 60 bytes. The following 2 commits seem to be the one to workaround this issue in e1000 and vmxenet3 before, and should probably be reverted. commit 78aeb23eded2 ("e1000: Pad short frames to minimum size (60 bytes)") commit 40a87c6c9b11 ("vmxnet3: Pad short frames to minimum size (60 bytes)") Signed-off-by: Bin Meng [PMD: Use struct iovec for zero-copy] Signed-off-by: Philippe Mathieu-Daudé --- include/net/eth.h | 1 + net/net.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/net/eth.h b/include/net/eth.h index 0671be6916..7c825ecb2f 100644 --- a/include/net/eth.h +++ b/include/net/eth.h @@ -31,6 +31,7 @@ #define ETH_ALEN 6 #define ETH_HLEN 14 +#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ struct eth_header { uint8_t h_dest[ETH_ALEN]; /* destination eth addr */ diff --git a/net/net.c b/net/net.c index bb1d455005..96a6d30474 100644 --- a/net/net.c +++ b/net/net.c @@ -621,6 +621,7 @@ static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender, const uint8_t *buf, int size, NetPacketSent *sent_cb) { + static const uint8_t null_buf[ETH_ZLEN] = { }; NetQueue *queue; int ret; int iovcnt = 1; @@ -629,6 +630,10 @@ static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender, .iov_base = (void *)buf, .iov_len = size, }, + [1] = { + .iov_base = (void *)null_buf, + .iov_len = ETH_ZLEN, + }, }; #ifdef DEBUG_NET @@ -640,6 +645,12 @@ static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender, return size; } + /* Pad to minimum Ethernet frame length */ + if (size < ETH_ZLEN) { + iov[1].iov_len = ETH_ZLEN - size; + iovcnt = 2; + } + /* Let filters handle the packet first */ ret = filter_receive_iov(sender, NET_FILTER_DIRECTION_TX, sender, flags, iov, iovcnt, sent_cb); From patchwork Wed Mar 10 10:11:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1450442 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=AlSSY7Hl; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DwT743cFqz9sSC for ; Wed, 10 Mar 2021 21:37:52 +1100 (AEDT) Received: from localhost ([::1]:52082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJwDu-0002Us-H0 for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2021 05:37:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJvpG-0000un-Lb for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:23 -0500 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]:39063) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJvpE-0006qp-77 for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:22 -0500 Received: by mail-ej1-x62f.google.com with SMTP id p7so26139161eju.6 for ; Wed, 10 Mar 2021 02:12:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=+ErR6Z+Y2Il/k73obafgKyiBO/JmeOnY663d8gWjCYE=; b=AlSSY7HlJeJfVLKshOQ1NY9d92pE882xv2ApzNwSnETFI6z1YzQkLlV4AKLDlZ9cpE xQhxQ7OMG+XDQrb06yBiv9UMlszUO1zNNuadh13VtWgO+b+w1JmBkkzp7AUwIvG/GdXP sm/tnPTP9jAEE9D/9T0nHiTwr5+5YrE5U9n33NVib25OFupM0OcgMIe+Tzi5i2f29m77 HMXU/qEFeplFznszwxjySybTcM9D7CwKXI8syAWdkpaMUhg7jI6E8w8mjGTDiD3/pUY4 7ryEiy+hFMQtp3u6g36awtEuXMBQtLQtgZbJOx0i6FxU9A/AzIKm1wqMt0D5omWRn9BZ YESg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=+ErR6Z+Y2Il/k73obafgKyiBO/JmeOnY663d8gWjCYE=; b=iMQjVQhG2zla5rQtpQV6NlAPk2YrtpFdblFjxJxkC43agWwwF4e2t4I5gD9T+4nwCb ZUTxHg3uRmzJ+zsMsUBdadLE7Oeg3KDgrgXmgdwJoINNR2ru641HTU1yJCI6Lmeym6fd ZTThv0oUPKDnWAN70LFU6wFyZA+3SApApQc7qJ6OU1O5gcLccVdyNeK6lxPDCnHfk16z K1jo4dYij9wQbRm3wgCUIFsnJjkgd1DhB8M1/LegTEBBaymqm0FE9TFx44+LnAH4LDZ8 t/y1mqsrVfc3nLpCpf3NYtF2EAPpNEK3nt1DLyBUChXMGYevJgqqngsnehHXi+Mwx5SP hsWA== X-Gm-Message-State: AOAM531j2eQzr4jWkwyzquiNDC9mWDkhyiNbRjnd/qLqmessgKIPYQzS /2KmaeMJNBGOdafWpwI/rSM= X-Google-Smtp-Source: ABdhPJz39INgveqXVjVQ6v1teFFb8sZgJo8hPHdkHBuWQon9PPQsVRsxB5uMbge854tT5Ml3SGDisw== X-Received: by 2002:a17:906:b2cd:: with SMTP id cf13mr2825782ejb.181.1615371138865; Wed, 10 Mar 2021 02:12:18 -0800 (PST) Received: from pek-vx-bsp9.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id n26sm5966864eds.22.2021.03.10.02.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 02:12:18 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH 03/10] hw/net: e1000: Remove the logic of padding short frames in the receive path Date: Wed, 10 Mar 2021 18:11:50 +0800 Message-Id: <20210310101157.15136-4-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210310101157.15136-1-bmeng.cn@gmail.com> References: <20210310101157.15136-1-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=bmeng.cn@gmail.com; helo=mail-ej1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Now that we have implemented unified short frames padding in the QEMU networking codes, remove the same logic in the NIC codes. This actually reverts commit 78aeb23eded2d0b765bf9145c71f80025b568acd. Signed-off-by: Bin Meng --- hw/net/e1000.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index d8da2f6528..a53ba9052b 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -882,7 +882,6 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt) uint16_t vlan_special = 0; uint8_t vlan_status = 0; uint8_t min_buf[MIN_BUF_SIZE]; - struct iovec min_iov; uint8_t *filter_buf = iov->iov_base; size_t size = iov_size(iov, iovcnt); size_t iov_ofs = 0; @@ -898,15 +897,7 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt) return 0; } - /* Pad to minimum Ethernet frame length */ - if (size < sizeof(min_buf)) { - iov_to_buf(iov, iovcnt, 0, min_buf, size); - memset(&min_buf[size], 0, sizeof(min_buf) - size); - min_iov.iov_base = filter_buf = min_buf; - min_iov.iov_len = size = sizeof(min_buf); - iovcnt = 1; - iov = &min_iov; - } else if (iov->iov_len < MAXIMUM_ETHERNET_HDR_LEN) { + if (iov->iov_len < MAXIMUM_ETHERNET_HDR_LEN) { /* This is very unlikely, but may happen. */ iov_to_buf(iov, iovcnt, 0, min_buf, MAXIMUM_ETHERNET_HDR_LEN); filter_buf = min_buf; From patchwork Wed Mar 10 10:11:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1450439 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=OVY0S84g; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DwSvy5597z9sCD for ; Wed, 10 Mar 2021 21:28:14 +1100 (AEDT) Received: from localhost ([::1]:56224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJw4a-0000mc-Oi for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2021 05:28:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJvpJ-0000vv-7E for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:25 -0500 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:45448) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJvpH-0006so-ME for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:24 -0500 Received: by mail-ed1-x536.google.com with SMTP id dm26so27097036edb.12 for ; Wed, 10 Mar 2021 02:12:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=8uMScMInLLrhbLvH0rTF7XrH2CwqIBpkKtpIern7QYI=; b=OVY0S84goTKr1zxytdNcf41mCz477BvDKyJ6S8tCtE1XdO/MJa9Vw+CfORqixh7xYS pn7GjeEwOJJgUguHfQyxRWwAQ8hXZ2QEwx9nwPLul5nXobKex4dAc7nV5sW21A47jRGw m2X8ifnKSGI0DFbmtrh8DNhoS+P5X2DbpazV1nqlwoC7hmS5gn4cIMyWJGhOXLtThk1w VVC4+xRl+uA9DpZs3uaUqF0s34Ep4ghCSJfQo1lPpx+Tl2KVpIyCY+ifR7zExEp7X5Hf IRGvpBOiba9/oLmAuRY6/XJjgCMHSOmbnATrv4bLgfOZ54SrVivJ26eZHc5le1cZOzCO E0yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=8uMScMInLLrhbLvH0rTF7XrH2CwqIBpkKtpIern7QYI=; b=DRE1anvnrdEyu7trGdYAjQWHC45JJ0jFSJCGEU0s0FOfouH37SsZze3QFluRTs6uDP kTDiMxCFlr+JvF5UuUkNASanHuXiRdLt9fQG5fPu7+SiYI1JXd4b4JaLGlD/5gl9A1x/ xtf1dTnLrnpT3c0jkcwhaZ6zSTAvmf5C1G8ALDe/31mO2ckOCm3GBenlcL4/VU1DecWX C0xmTFCj8GUFDoRJxuv4xMwPGYOZ/kT9FaXo/0aDFPyLcWgMB4u4klb1xgLDXk2vj/4Q TCnLhYh+sdRst5objPoovYxAkB7H4WarSM3Ll9aYUmbXGvEo3dHZgi29cYsFMFWxJ8Ht 3j0g== X-Gm-Message-State: AOAM530+VYBREr7tKyLu7dlBKf5ZEpZ7PZ1uBf+WZLNvIz98tA7owOgN NVFOZfBMyzmLvgYlwhbzTmA= X-Google-Smtp-Source: ABdhPJzRiWmi71P3S6vzs81ecqxahjy7EwPkCcsTObktXWhEJi/EpthC8R+HU0GKigWOUfUWKbRgXw== X-Received: by 2002:aa7:da46:: with SMTP id w6mr2429489eds.40.1615371142440; Wed, 10 Mar 2021 02:12:22 -0800 (PST) Received: from pek-vx-bsp9.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id n26sm5966864eds.22.2021.03.10.02.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 02:12:22 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH 04/10] hw/net: vmxnet3: Remove the logic of padding short frames in the receive path Date: Wed, 10 Mar 2021 18:11:51 +0800 Message-Id: <20210310101157.15136-5-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210310101157.15136-1-bmeng.cn@gmail.com> References: <20210310101157.15136-1-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=bmeng.cn@gmail.com; helo=mail-ed1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Now that we have implemented unified short frames padding in the QEMU networking codes, remove the same logic in the NIC codes. This actually reverts commit 40a87c6c9b11ef9c14e0301f76abf0eb2582f08e. Signed-off-by: Bin Meng --- hw/net/vmxnet3.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index eff299f629..d993cce097 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -39,7 +39,6 @@ #define PCI_DEVICE_ID_VMWARE_VMXNET3_REVISION 0x1 #define VMXNET3_MSIX_BAR_SIZE 0x2000 -#define MIN_BUF_SIZE 60 /* Compatibility flags for migration */ #define VMXNET3_COMPAT_FLAG_OLD_MSI_OFFSETS_BIT 0 @@ -1951,7 +1950,6 @@ vmxnet3_receive(NetClientState *nc, const uint8_t *buf, size_t size) { VMXNET3State *s = qemu_get_nic_opaque(nc); size_t bytes_indicated; - uint8_t min_buf[MIN_BUF_SIZE]; if (!vmxnet3_can_receive(nc)) { VMW_PKPRN("Cannot receive now"); @@ -1964,14 +1962,6 @@ vmxnet3_receive(NetClientState *nc, const uint8_t *buf, size_t size) size -= sizeof(struct virtio_net_hdr); } - /* Pad to minimum Ethernet frame length */ - if (size < sizeof(min_buf)) { - memcpy(min_buf, buf, size); - memset(&min_buf[size], 0, sizeof(min_buf) - size); - buf = min_buf; - size = sizeof(min_buf); - } - net_rx_pkt_set_packet_type(s->rx_pkt, get_eth_packet_type(PKT_GET_ETH_HDR(buf))); From patchwork Wed Mar 10 10:11:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1450443 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Oti8FuJj; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DwT9M3FLYz9sRN for ; Wed, 10 Mar 2021 21:39:51 +1100 (AEDT) Received: from localhost ([::1]:57468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJwFp-0004jY-CS for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2021 05:39:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJvpM-00011S-L6 for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:28 -0500 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]:45305) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJvpL-0006uv-4U for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:28 -0500 Received: by mail-ej1-x632.google.com with SMTP id mm21so37465162ejb.12 for ; Wed, 10 Mar 2021 02:12:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=O9yrkVVHqbfS1wxTV5lf3YHG4sWif/zskA4hK5tu15U=; b=Oti8FuJjvU+FA5rJvKdbQJQRVztMP7zyDQr0Z2+GDvxMaVU4RE8Gwl9ts+8K19ZJ9x NT1lRaNJ6zgSzUjUzEovD14MLMmBoa67OB4MT3KFcRUvNRsTKlinSC1l5xmNi/kCa3js CXaLpK0GPQp7al37dj88AdMmgd+Xv2H3MiA0J4gz55hmpY3uRW0sxVTWRZivDH/iTVy/ S5L9u9eK74ZHUdZNAvkZfHS0xAshugjjy9whAInHS/mm8T+yvy2ud2TsZhzhk9vMoIKj Y7uKpRUxx7tBgZeCgSHu7AyE86GgadHHv/uYJNow8E1CIeh3sz+WBiiUobCKW+4q4CO7 L55w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=O9yrkVVHqbfS1wxTV5lf3YHG4sWif/zskA4hK5tu15U=; b=tx6rk20rYpvzUQ1WuGLmfbFYXNcisDHsISPCSvecBBa0PeX8jqIaGIp51x33d8pY/F p9AuqoSU3EZicVDZosD4yjcqvWQqjCpSDU1yXsAaeBAQOBC5nUv+pmWXIYy5QaqXAmQF oEKaC7Mc2YJaYq2mhAc2Ji+DTRTN+aXTOA8rYOwgqItzH3rNtBUq9ZV0UQ6BPKPq6qGd kxMRQkP5nuFQP5do6edsKE8YUN3WDwk9NgLBgMnwcvU6bXPBDKCv1uUxCm0V/pXZnLc5 6i9/tbhK+JbAdNa3qnq1D/Hl0l7ayX8TgEEnm4vFAnzzdrqeUlHGnUTmeEgtHcd/tFlk +AVQ== X-Gm-Message-State: AOAM530F8qD9d+us3hYS42fHoTJoVujQv8kyP7dl5q3ftDLV6RDisVG/ 2xEtNMcQqgoCx59Z1S4vyrM= X-Google-Smtp-Source: ABdhPJy+HrUevT9GNbqGYjUnbHPP/X6/rsSretogl+z7y6Sqbg3zql3xakhV66VDuQrbk/oZskxIMQ== X-Received: by 2002:a17:906:68c5:: with SMTP id y5mr2841681ejr.371.1615371146008; Wed, 10 Mar 2021 02:12:26 -0800 (PST) Received: from pek-vx-bsp9.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id n26sm5966864eds.22.2021.03.10.02.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 02:12:25 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH 05/10] hw/net: i82596: Remove the logic of padding short frames in the receive path Date: Wed, 10 Mar 2021 18:11:52 +0800 Message-Id: <20210310101157.15136-6-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210310101157.15136-1-bmeng.cn@gmail.com> References: <20210310101157.15136-1-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::632; envelope-from=bmeng.cn@gmail.com; helo=mail-ej1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Now that we have implemented unified short frames padding in the QEMU networking codes, remove the same logic in the NIC codes. Signed-off-by: Bin Meng --- hw/net/i82596.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/hw/net/i82596.c b/hw/net/i82596.c index 055c3a1470..1eca2e2d81 100644 --- a/hw/net/i82596.c +++ b/hw/net/i82596.c @@ -73,10 +73,6 @@ enum commands { #define I596_EOF 0x8000 #define SIZE_MASK 0x3fff -#define ETHER_TYPE_LEN 2 -#define VLAN_TCI_LEN 2 -#define VLAN_HLEN (ETHER_TYPE_LEN + VLAN_TCI_LEN) - /* various flags in the chip config registers */ #define I596_PREFETCH (s->config[0] & 0x80) #define I596_PROMISC (s->config[8] & 0x01) @@ -489,8 +485,6 @@ bool i82596_can_receive(NetClientState *nc) return true; } -#define MIN_BUF_SIZE 60 - ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz) { I82596State *s = qemu_get_nic_opaque(nc); @@ -501,7 +495,6 @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz) size_t bufsz = sz; /* length of data in buf */ uint32_t crc; uint8_t *crc_ptr; - uint8_t buf1[MIN_BUF_SIZE + VLAN_HLEN]; static const uint8_t broadcast_macaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; @@ -584,17 +577,6 @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz) } } - /* if too small buffer, then expand it */ - if (len < MIN_BUF_SIZE + VLAN_HLEN) { - memcpy(buf1, buf, len); - memset(buf1 + len, 0, MIN_BUF_SIZE + VLAN_HLEN - len); - buf = buf1; - if (len < MIN_BUF_SIZE) { - len = MIN_BUF_SIZE; - } - bufsz = len; - } - /* Calculate the ethernet checksum (4 bytes) */ len += 4; crc = cpu_to_be32(crc32(~0, buf, sz)); From patchwork Wed Mar 10 10:11:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1450433 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=XpyDhRpI; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DwSlC6KXkz9sRN for ; Wed, 10 Mar 2021 21:20:39 +1100 (AEDT) Received: from localhost ([::1]:33770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJvxF-00085s-Vn for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2021 05:20:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJvpQ-000179-93 for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:32 -0500 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]:46656) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJvpO-0006xe-Nl for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:32 -0500 Received: by mail-ed1-x533.google.com with SMTP id w9so27082626edt.13 for ; Wed, 10 Mar 2021 02:12:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=w85G2CUiwE1GHjdDwyuM2cqZc0OcAHDLs6RNahlZj9g=; b=XpyDhRpIe4hKWdzxTZ2v5bRa6qJxtQ7NziXXPwGzBA5oUOVl4ht6VOy3zRebfcGurb xQo4lyZgRYqWStZv0eaYxr7qataBsBxgeU+35mm9y6Uef0MAoR1p1ZV2/mqdUJoN4weX UmpdzE4HTJtRw8p6XTHHzm86MRwCi9ZYWDHii8hczji4dMzbyIUdZOhrgd5Ky4ynhATB cJ18YO0MvkInwPsEwTQCUm69r4/rSxvt2bhuezHljx3Zyh+9Oq2FboCQ6c0sN2Q8PQng w8cam0X2Yy/TQ4QEswLlj0Rsa4EzsLMRYDb0DQd1DERRdY2+DHz8//EotZS0Nz2sGZxl hWkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=w85G2CUiwE1GHjdDwyuM2cqZc0OcAHDLs6RNahlZj9g=; b=pPBptZOAkT1FcoWucs/Jz62AbJEKNNLmjXuDf4DiuBBYmLN/COy/0em4XWOa32dieg qT2GWplgPohdI2s8x+wIX8cSKjiy+GlGdgoCequJI3Twk/hvI0HXyI/uYlY8wQoQQTFc nR8+1+db1xwpb49qB58GKmV9GinNn1tF/yeeLa+S1GFl2Cqe+vF5uPVsycSuglqMOJoQ 8Nlrt/okBsFId9+dtKWr+kdDbDWZh0mcT2N64JWaVdfCLNJEMWVCvAoUAYrJ7C/NpNmA 54D9UvJhe1oO3fVAA84iTs7pJQWrOQrRNdME/BRvt+QeGLT1j6nkFS7+k1P3RsQpJA+U jV5Q== X-Gm-Message-State: AOAM530gis/if2OGezYTCJA8lwC4oF4Y1/SLmuskIo3oosB6lVEO36Sa GmAJ9VYlJ55i1DjoGZzSDY4= X-Google-Smtp-Source: ABdhPJyBMil+FfABXktP+nNQL6S9MXQOG19IjpC4I9u7TrpbtaTV8/AaKW1iiJybgcDZ/6jLquJ1Rw== X-Received: by 2002:a50:ec0e:: with SMTP id g14mr2437318edr.264.1615371149481; Wed, 10 Mar 2021 02:12:29 -0800 (PST) Received: from pek-vx-bsp9.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id n26sm5966864eds.22.2021.03.10.02.12.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 02:12:29 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH 06/10] hw/net: ne2000: Remove the logic of padding short frames in the receive path Date: Wed, 10 Mar 2021 18:11:53 +0800 Message-Id: <20210310101157.15136-7-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210310101157.15136-1-bmeng.cn@gmail.com> References: <20210310101157.15136-1-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=bmeng.cn@gmail.com; helo=mail-ed1-x533.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Now that we have implemented unified short frames padding in the QEMU networking codes, remove the same logic in the NIC codes. Signed-off-by: Bin Meng --- hw/net/ne2000.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c index 6c17ee1ae2..b0a120ece6 100644 --- a/hw/net/ne2000.c +++ b/hw/net/ne2000.c @@ -167,15 +167,12 @@ static int ne2000_buffer_full(NE2000State *s) return 0; } -#define MIN_BUF_SIZE 60 - ssize_t ne2000_receive(NetClientState *nc, const uint8_t *buf, size_t size_) { NE2000State *s = qemu_get_nic_opaque(nc); size_t size = size_; uint8_t *p; unsigned int total_len, next, avail, len, index, mcast_idx; - uint8_t buf1[60]; static const uint8_t broadcast_macaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; @@ -213,15 +210,6 @@ ssize_t ne2000_receive(NetClientState *nc, const uint8_t *buf, size_t size_) } } - - /* if too small buffer, then expand it */ - if (size < MIN_BUF_SIZE) { - memcpy(buf1, buf, size); - memset(buf1 + size, 0, MIN_BUF_SIZE - size); - buf = buf1; - size = MIN_BUF_SIZE; - } - index = s->curpag << 8; if (index >= NE2000_PMEM_END) { index = s->start; From patchwork Wed Mar 10 10:11:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1450440 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=KFinxy9f; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DwSxC6mG9z9sCD for ; Wed, 10 Mar 2021 21:29:19 +1100 (AEDT) Received: from localhost ([::1]:32792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJw5d-0002iz-Vj for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2021 05:29:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJvpT-0001D7-PI for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:35 -0500 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]:35148) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJvpS-0006zz-4l for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:35 -0500 Received: by mail-ej1-x631.google.com with SMTP id dx17so37544996ejb.2 for ; Wed, 10 Mar 2021 02:12:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=WWiBc7WA3O2AVkpTLFlp8tq2hPGcdq5p9G8byDecpz8=; b=KFinxy9fkf4RtTGdQqrrmuzJ+5v8L/NxL9Z9YyWsYu4DWA6mpdHA1KUvm/UwCgp5Q7 rvyI0ZaNJv4A5MedHOtdRU28EqdWBJg7lRSEjKzoBHZPWBwbhfgBDGCeMZVjJMpKPNki AawNkmRpRbXxrDxYaPBO7MfD/z4ZTpw6s5e/vwdXKCNQibWiXfr6hnM7GixwnHrTBoUF 1IXFV3j/w5dQIcvvFD0uZc6m0LGExkR+JEBC591z2Q1vuEZmG5RuRL7+VEVdNSrIs8+d uJkFEgOdoySfi+tokTllSYuf5xGASXJoTOK+bR1Y/gKCJKq3DFnc05xiuyFELzDQ7Hu3 SjGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=WWiBc7WA3O2AVkpTLFlp8tq2hPGcdq5p9G8byDecpz8=; b=J0EUBjHhTS/CSVawtHsyyjE3sIEXu6KrqdvMnLGa8l3Z17teBW9zILuyoMVwnVOpln kW4eyg7pul5WRbF61gIUDcjRO+zuXTVIrL3Tjg8wpqu/7Wg3+O8EF3k8HbuytUyavIDO A/U/vVkjatKammILXL8PhyMhBK/wPHxpJB87tdUxubZEGKCH4DtPhAuPCTSnEvdpSzX2 f1mzFf4uTcK8YQRrD3naM1Y97ahi2rDWjFhB87VxmOTOvmuVDRtmzD8vVW6jlIGhnoWD FwhepWRjC0R74WK6SLygH7O1B4VCO8MV0kCoagcVXC3gQDwzy2VeWfGe3I0KFGkmTL07 6Ihw== X-Gm-Message-State: AOAM533BUxsbYQwcqkQjwumPBKi8gNp6yw83LEL862ac5QoeL8K7JzS1 QEehfllrE31UBKwULfyGIxI= X-Google-Smtp-Source: ABdhPJzRqWoxoEaxPvWiOnnKfuNzIy1Fve2IdZ3ok/+o0JEzjsL+sUpHGAIm3VmEuu7jiqUKUIswIw== X-Received: by 2002:a17:907:162b:: with SMTP id hb43mr2887031ejc.41.1615371152884; Wed, 10 Mar 2021 02:12:32 -0800 (PST) Received: from pek-vx-bsp9.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id n26sm5966864eds.22.2021.03.10.02.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 02:12:32 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH 07/10] hw/net: pcnet: Remove the logic of padding short frames in the receive path Date: Wed, 10 Mar 2021 18:11:54 +0800 Message-Id: <20210310101157.15136-8-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210310101157.15136-1-bmeng.cn@gmail.com> References: <20210310101157.15136-1-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=bmeng.cn@gmail.com; helo=mail-ej1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Now that we have implemented unified short frames padding in the QEMU networking codes, remove the same logic in the NIC codes. Signed-off-by: Bin Meng --- hw/net/pcnet.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c index f3f18d8598..16330335cd 100644 --- a/hw/net/pcnet.c +++ b/hw/net/pcnet.c @@ -987,7 +987,6 @@ ssize_t pcnet_receive(NetClientState *nc, const uint8_t *buf, size_t size_) { PCNetState *s = qemu_get_nic_opaque(nc); int is_padr = 0, is_bcast = 0, is_ladr = 0; - uint8_t buf1[60]; int remaining; int crc_err = 0; size_t size = size_; @@ -1000,14 +999,6 @@ ssize_t pcnet_receive(NetClientState *nc, const uint8_t *buf, size_t size_) printf("pcnet_receive size=%zu\n", size); #endif - /* if too small buffer, then expand it */ - if (size < MIN_BUF_SIZE) { - memcpy(buf1, buf, size); - memset(buf1 + size, 0, MIN_BUF_SIZE - size); - buf = buf1; - size = MIN_BUF_SIZE; - } - if (CSR_PROM(s) || (is_padr=padr_match(s, buf, size)) || (is_bcast=padr_bcast(s, buf, size)) From patchwork Wed Mar 10 10:11:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1450441 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=B0jXGmUe; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DwSzc2GlLz9sCD for ; Wed, 10 Mar 2021 21:31:24 +1100 (AEDT) Received: from localhost ([::1]:37690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJw7d-0004qi-U6 for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2021 05:31:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJvpW-0001Hb-Sj for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:38 -0500 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]:42003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJvpV-00071f-Dr for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:38 -0500 Received: by mail-ed1-x52a.google.com with SMTP id v13so27147238edw.9 for ; Wed, 10 Mar 2021 02:12:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=T3ctX4Zss8EX9is1InNFvRPjfz7K3KaTlyGjPD5l1Sk=; b=B0jXGmUev96EpafhUJZ1Ml+OpG6a70RKeozIhx21697hb7XYE7oDjoO7EMCToqcLqN wywiwXHMHraN86959ij9UBn9fSD6V9mnsl59+UmUP//ecDPxqrSpUX8lR2zJl37XqVXZ VHsEeo5iw2xuzi26EFYIbF/tuLCvSsz1Pj7+cGwrYOc44KvtRvdVSiItCwxxTv54tei6 X5blEAK3NiKLOgflU1jMXqBmxaZ9Z9X0CLiYY1s72lbruaG8huVu+hZ2WtR2nxpJHlW3 b5BYY+YdvohwJZY/hmUPIAh+mgUMf+d84YwEPlCJ9iOnKny/x0svVyXVjUkTSYiew1rQ Jsnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=T3ctX4Zss8EX9is1InNFvRPjfz7K3KaTlyGjPD5l1Sk=; b=CWrix3wm+JxGXQjmKE1wxbzJ2nQPL1FiRy9BxcLRmIVHkIq6P2i7bMAZtDKReGD4zR lEzSyhbmMf91bVd/TxDizrDnAFHzsB7ji8jlzteuGMDZbqBc8q2pzKqKb5t9eMrqQXMM cXXN7zkkcr9lJyuYIfj4DDBetcl5bgIgZaiX/NQWPm8IOstJlsW4sPLzuOJFu+GlI2qj YBbxFCwxgzifw+RURijmv7/i7Ncxu8PJdBgTnfuHb3gc01sEAsyPr474V+zOh0drgYqa NzueRBD5aXXzDtjSBK7uD+B7/iTouqvdJOHIFaqKbMW9OGQKKFXVzNBmiLgrO8mx6Sus JIvg== X-Gm-Message-State: AOAM531PASSuxawxPPm6qlGJD15YFmOH6xV04ABh/c5LpuPq2hJd0PUx xKWvDY45oKs8hOAQb3ieacU= X-Google-Smtp-Source: ABdhPJxQ1pDBIRCMz82vliTr6tTXYTcLaRe+2qR2ZMtpKRY7+BsR3Wc2BEit5eO9p2FU7yHIjSfqxA== X-Received: by 2002:aa7:d54a:: with SMTP id u10mr2430264edr.316.1615371156174; Wed, 10 Mar 2021 02:12:36 -0800 (PST) Received: from pek-vx-bsp9.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id n26sm5966864eds.22.2021.03.10.02.12.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 02:12:35 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH 08/10] hw/net: rtl8139: Remove the logic of padding short frames in the receive path Date: Wed, 10 Mar 2021 18:11:55 +0800 Message-Id: <20210310101157.15136-9-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210310101157.15136-1-bmeng.cn@gmail.com> References: <20210310101157.15136-1-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::52a; envelope-from=bmeng.cn@gmail.com; helo=mail-ed1-x52a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Now that we have implemented unified short frames padding in the QEMU networking codes, remove the same logic in the NIC codes. Signed-off-by: Bin Meng --- hw/net/rtl8139.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index 4675ac878e..cbfe29a286 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -827,7 +827,6 @@ static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t uint32_t packet_header = 0; - uint8_t buf1[MIN_BUF_SIZE + VLAN_HLEN]; static const uint8_t broadcast_macaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; @@ -939,17 +938,6 @@ static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t } } - /* if too small buffer, then expand it - * Include some tailroom in case a vlan tag is later removed. */ - if (size < MIN_BUF_SIZE + VLAN_HLEN) { - memcpy(buf1, buf, size); - memset(buf1 + size, 0, MIN_BUF_SIZE + VLAN_HLEN - size); - buf = buf1; - if (size < MIN_BUF_SIZE) { - size = MIN_BUF_SIZE; - } - } - if (rtl8139_cp_receiver_enabled(s)) { if (!rtl8139_cp_rx_valid(s)) { From patchwork Wed Mar 10 10:11:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1450434 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=fceYT15F; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DwSnP0klWz9sR4 for ; Wed, 10 Mar 2021 21:22:33 +1100 (AEDT) Received: from localhost ([::1]:37938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJvz5-0001Wh-4O for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2021 05:22:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJvpa-0001OM-8r for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:42 -0500 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]:45442) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJvpY-00073a-LB for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:41 -0500 Received: by mail-ed1-x52a.google.com with SMTP id dm26so27098413edb.12 for ; Wed, 10 Mar 2021 02:12:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=+blp/Z6sDaZhi7CWJcTK5u4ylxWQZLR1Fg3/VNTa5MU=; b=fceYT15FKdVYNOY7+CFEHQEPVjb9UZJgHwktWhcfhMmPBTSeNOvkHDAj+9pVZ7yAmK VMnmD49VRVdU0M+8X69F4rc3t01K6rS5Lkanfq7tTLNHPr6WIRVy0oylM6p63Z/+K3WV 2ZIjMymPFWQm5GaqzIj/LOqCxLuX4jZ3GYxmDtrI6vQq2mwz4Klec9iStPiZepki5/SD UwZM4dxLBzcFiMloukeHlx6tzGWybnAkxOXUttrQfEBh+sS9Gt27yRz7zxJYPRLIUAsx a0brbOrvYStJsUb8mpXLpAS0tQ2Qmbi1Wcdv/l/JLvilgelNmjWsqPB+XJHSkxD5539u Md/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=+blp/Z6sDaZhi7CWJcTK5u4ylxWQZLR1Fg3/VNTa5MU=; b=Na/nkELhJGH871asHd/TzKWtKFDhvr1rtH3HnlHOY/JyTxJMkOtegB1nFU5V7dqM+s Uyqn1AoHw8iU/oDRHB26Z8+ewu2L98/dEoyeIIJuyMfltJZFteAhcWaheRxk2Z+/Gcp3 9wf28KPSHy68daFTjuk2LnuefuYf08N5Er7K52bZXXx2/Un5DFOEFao0BNiCP2ldiFM/ nbdoqFMQfWK29I1jnfpRemlReYmhxWxjwmpVRfXPt2j80L340OLtUYwS9AGubKIfQjIU kfRCEtmWcfrqaLEjsEFW8bEVxGH0jTzbTjbz89Z9KuTDYZgnG+u5q0t5FsYdLEopLGeX PrBQ== X-Gm-Message-State: AOAM530oIlU48gAvDlW9GcGL/bSrYY6jtHt+kG2+PRRX9taUVF7IEpce CyHx4L8Fia6PFdM7noH2vLkuy4asGEA= X-Google-Smtp-Source: ABdhPJwZ6JL7YjS0Lt3YUizkH2OcblBvszvbVRZExnLg92YaKlA96RR5tPy5hBUUB38k0HUgeS6H9Q== X-Received: by 2002:aa7:dc0b:: with SMTP id b11mr2447574edu.124.1615371159562; Wed, 10 Mar 2021 02:12:39 -0800 (PST) Received: from pek-vx-bsp9.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id n26sm5966864eds.22.2021.03.10.02.12.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 02:12:39 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH 09/10] hw/net: sungem: Remove the logic of padding short frames in the receive path Date: Wed, 10 Mar 2021 18:11:56 +0800 Message-Id: <20210310101157.15136-10-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210310101157.15136-1-bmeng.cn@gmail.com> References: <20210310101157.15136-1-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::52a; envelope-from=bmeng.cn@gmail.com; helo=mail-ed1-x52a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Now that we have implemented unified short frames padding in the QEMU networking codes, remove the same logic in the NIC codes. Signed-off-by: Bin Meng --- hw/net/sungem.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/hw/net/sungem.c b/hw/net/sungem.c index 33c3722df6..3fa83168db 100644 --- a/hw/net/sungem.c +++ b/hw/net/sungem.c @@ -550,7 +550,6 @@ static ssize_t sungem_receive(NetClientState *nc, const uint8_t *buf, PCIDevice *d = PCI_DEVICE(s); uint32_t mac_crc, done, kick, max_fsize; uint32_t fcs_size, ints, rxdma_cfg, rxmac_cfg, csum, coff; - uint8_t smallbuf[60]; struct gem_rxd desc; uint64_t dbase, baddr; unsigned int rx_cond; @@ -584,19 +583,6 @@ static ssize_t sungem_receive(NetClientState *nc, const uint8_t *buf, return size; } - /* We don't drop too small frames since we get them in qemu, we pad - * them instead. We should probably use the min frame size register - * but I don't want to use a variable size staging buffer and I - * know both MacOS and Linux use the default 64 anyway. We use 60 - * here to account for the non-existent FCS. - */ - if (size < 60) { - memcpy(smallbuf, buf, size); - memset(&smallbuf[size], 0, 60 - size); - buf = smallbuf; - size = 60; - } - /* Get MAC crc */ mac_crc = net_crc32_le(buf, ETH_ALEN); From patchwork Wed Mar 10 10:11:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1450444 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=mJbv9EQC; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DwTD10vgSz9sRN for ; Wed, 10 Mar 2021 21:42:09 +1100 (AEDT) Received: from localhost ([::1]:33404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJwI3-0006Wo-5k for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2021 05:42:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJvpf-0001Wz-Bz for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:47 -0500 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:33180) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJvpc-00075f-BQ for qemu-devel@nongnu.org; Wed, 10 Mar 2021 05:12:47 -0500 Received: by mail-ed1-x532.google.com with SMTP id x9so27140248edd.0 for ; Wed, 10 Mar 2021 02:12:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0iiOMnMZhhPH5hS1v6PwOOCna3BJGccVCrXKXmjrMKc=; b=mJbv9EQC5huEQ13sJ0YQHlnIBRtKheDs5CLCySrMPFtkj3n11t2zF6mjyX7QfkmtR7 fSe/hvUccQUHpUOv9APF0YM1TySTDLkEai4/oa10ck/ayDAkvgHSmlNeNHAI8G8vdu/U kRpqcz0wIrKPZ3JToCYV8l7rG4d1QxVvsTgNCZM7qPl8IS6kU678Cw85n1iYcr8IrRju yThqy4zRhTvq4HHNUYCqeOQZDN15HTF8BRZqEMqqVpGs4jBbUYLYM034BGRTqo3PTVi+ APFGDOn0ZTeIaJm4KtpRKm7MaLvlOGWVd8brR+ydVdBXPoEYmg6sZqLT6C/foQLjpVtM v7PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0iiOMnMZhhPH5hS1v6PwOOCna3BJGccVCrXKXmjrMKc=; b=ky3NJGQuMA0eBzxgUL1xnNnDICSqz6P4DnuW1+DPtqVHntfekz92xYNqF2RJfmtfmk YUZe08uxVlLkyMv0VJH0BVdw/iw+EFsKflnl9XKxA1yHWZbcMlQZ+GMTgWO1Ohs52oeY s0SSa4eJbj4xguljQ6KP+dEW84TR3PosPZz5q87EAENqGIGG6wvuakl5BuR3Y0YQAjUM oMIfgoVHvZyiLeqaBmutQGxMQ+iDeptbYGXEXBuCti5+LgWmVQjzuTj58GmyqNUU2fl+ c0GWal17jgzFFnl3c+spmy7B+2bwK+/AmsPvEV3n1IoZYY8xa6ss8sqGrN9sf6bkjH5A Ej7g== X-Gm-Message-State: AOAM5321dH1VuOm/JikWFacUy316RQul1APSWMvnju9UjbX0yDQdAQ0R J5yY3UVncuXnwlhphh+a560= X-Google-Smtp-Source: ABdhPJyy/E8Yt9W3PqtRntwuOAmEWlUGwdabiZFSXC5ntg1OuS/9rAPTpMB8eN6gC6Pya8EzR8hHnA== X-Received: by 2002:a05:6402:34c8:: with SMTP id w8mr2453600edc.235.1615371162951; Wed, 10 Mar 2021 02:12:42 -0800 (PST) Received: from pek-vx-bsp9.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id n26sm5966864eds.22.2021.03.10.02.12.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 02:12:42 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH 10/10] hw/net: sunhme: Remove the logic of padding short frames in the receive path Date: Wed, 10 Mar 2021 18:11:57 +0800 Message-Id: <20210310101157.15136-11-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210310101157.15136-1-bmeng.cn@gmail.com> References: <20210310101157.15136-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=bmeng.cn@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Now that we have implemented unified short frames padding in the QEMU networking codes, remove the same logic in the NIC codes. Signed-off-by: Bin Meng --- hw/net/sunhme.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/hw/net/sunhme.c b/hw/net/sunhme.c index fc34905f87..6971796e57 100644 --- a/hw/net/sunhme.c +++ b/hw/net/sunhme.c @@ -714,8 +714,6 @@ static inline void sunhme_set_rx_ring_nr(SunHMEState *s, int i) s->erxregs[HME_ERXI_RING >> 2] = ring; } -#define MIN_BUF_SIZE 60 - static ssize_t sunhme_receive(NetClientState *nc, const uint8_t *buf, size_t size) { @@ -724,7 +722,6 @@ static ssize_t sunhme_receive(NetClientState *nc, const uint8_t *buf, dma_addr_t rb, addr; uint32_t intstatus, status, buffer, buffersize, sum; uint16_t csum; - uint8_t buf1[60]; int nr, cr, len, rxoffset, csum_offset; trace_sunhme_rx_incoming(size); @@ -775,14 +772,6 @@ static ssize_t sunhme_receive(NetClientState *nc, const uint8_t *buf, trace_sunhme_rx_filter_accept(); - /* If too small buffer, then expand it */ - if (size < MIN_BUF_SIZE) { - memcpy(buf1, buf, size); - memset(buf1 + size, 0, MIN_BUF_SIZE - size); - buf = buf1; - size = MIN_BUF_SIZE; - } - rb = s->erxregs[HME_ERXI_RING >> 2] & HME_ERXI_RING_ADDR; nr = sunhme_get_rx_ring_count(s); cr = sunhme_get_rx_ring_nr(s);