From patchwork Wed Mar 3 09:21:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1446522 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=mTIVxTAu; 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 4Dr7nK52q4z9sSC for ; Wed, 3 Mar 2021 20:22:29 +1100 (AEDT) Received: from localhost ([::1]:36408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHNi7-0004gQ-KQ for incoming@patchwork.ozlabs.org; Wed, 03 Mar 2021 04:22:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHNhk-0004du-QL for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:04 -0500 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]:39741) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHNhj-0001AQ-5t for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:04 -0500 Received: by mail-ej1-x62a.google.com with SMTP id gt32so29231964ejc.6 for ; Wed, 03 Mar 2021 01:22:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0+CZ8WOKhev/ZPPlzfY1zFK9B6RBx6AffPAAbYJrUAU=; b=mTIVxTAubhk4ZC4pZfZU+jC0QuBrFxE0VmtTIWVyoZVLA2ORuFcQsdw8VAbFF5Ir7P 4QrFvPiM8exiYF5qs9DvrTLU5vwG9q9Fe1QSzCCHDzTqJX9l5mu1Ta0o244AVo9mibd3 tP189TyDqRh9DRy14LZGSLLaA4VAIs8i/ZD2oKm+OawG47OkNzObVcs67JnUYYnw0DMi FH1gwytAwma7HW/iZJ3Gmvzio8KuSY214/RT6RELtqhXgPzWZLTdW6hK/BwTPkJDFYNs aARrKOKV7maKsiPlmUFmC6+lkXBQClxQ59HVrM+IZMVsUWKz73Tg/G8+6ZV/pL/xeEms y+HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0+CZ8WOKhev/ZPPlzfY1zFK9B6RBx6AffPAAbYJrUAU=; b=FWRnAtGc2DVf4UtGHRLXVZWIXJzxtsbbjKBbbGvT+IAlqZy5E4N9cTGt7Jwd+Jjq42 owcdLRb0MumjF5Oonmm2+BJcZsMUuohmFxv9TKez/SHYlU58FeSGnIooquTVswCVXImg 1n0Uf2T3Xb7NXjqMC+lSW7zyNvVl4+rFtO4pPgusowKXrk4OCG19uEomIro7YVxAjyxe ZKzQ8oUheaF6VpMFwQER9im8DhUIavh5LLpJAXYh+WrZFkMwvn/K0c8EersLwWdudI+r YdgyX48Owea2qaQAgDOYETcgovxcA2aUrvy+03bjcHF9nnMGvQNN+BFq4tPOm1c8XEMk fLLA== X-Gm-Message-State: AOAM530ieCtbtSJfnrXkGJ2OIl0K5Kh+xm+8gcq09ajcFQy8Adkf9OAm PMFdZx8agVycYWlovtLzg3k= X-Google-Smtp-Source: ABdhPJzCPANAzkKA+TMonr4AAR8qKdsErcV9to2Ysy8B6LFjTUccbwWAGhc0dBKT48ShxMf9wXiDtw== X-Received: by 2002:a17:906:5453:: with SMTP id d19mr24232370ejp.150.1614763321199; Wed, 03 Mar 2021 01:22:01 -0800 (PST) Received: from pek-vx-bsp2.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id i6sm16614865ejz.95.2021.03.03.01.21.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Mar 2021 01:22:00 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [RFC PATCH v2 1/9] net: Pad short frames to minimum size before send from SLiRP/TAP Date: Wed, 3 Mar 2021 17:21:38 +0800 Message-Id: <1614763306-18026-2-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> References: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=bmeng.cn@gmail.com; helo=mail-ej1-x62a.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: , Cc: Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 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 SLiRP/TAP, we change to pad short frames before sending it out to the other end. This ensures SLiRP/TAP as an Ethernet sender do 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 are still supported and short frames can still pass through SLiRP/TAP interfaces. 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 --- Changes in v2: - only pad short frames for SLiRP/TAP interfaces include/net/eth.h | 1 + net/net.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/net/eth.h b/include/net/eth.h index 0671be6..7c825ec 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 32d71c1..27c3b25 100644 --- a/net/net.c +++ b/net/net.c @@ -638,6 +638,7 @@ static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender, NetPacketSent *sent_cb) { NetQueue *queue; + uint8_t min_buf[ETH_ZLEN]; int ret; #ifdef DEBUG_NET @@ -649,6 +650,17 @@ static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender, return size; } + /* Pad to minimum Ethernet frame length for SLiRP and TAP */ + if (sender->info->type == NET_CLIENT_DRIVER_USER || + sender->info->type == NET_CLIENT_DRIVER_TAP) { + if (size < ETH_ZLEN) { + memcpy(min_buf, buf, size); + memset(&min_buf[size], 0, ETH_ZLEN - size); + buf = min_buf; + size = ETH_ZLEN; + } + } + /* Let filters handle the packet first */ ret = filter_receive(sender, NET_FILTER_DIRECTION_TX, sender, flags, buf, size, sent_cb); From patchwork Wed Mar 3 09:21:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1446525 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=fzYbKDxt; 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 4Dr7q86cmXz9sVS for ; Wed, 3 Mar 2021 20:24:04 +1100 (AEDT) Received: from localhost ([::1]:42844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHNje-0007Mh-TX for incoming@patchwork.ozlabs.org; Wed, 03 Mar 2021 04:24:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHNhn-0004hs-Nk for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:07 -0500 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]:32913) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHNhm-0001BK-96 for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:07 -0500 Received: by mail-ej1-x62a.google.com with SMTP id jt13so40836760ejb.0 for ; Wed, 03 Mar 2021 01:22:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qvjoH8Av1aiwoBjs4TpFm49HM6EV85fk5Z2xHbHZ2/0=; b=fzYbKDxt6X2Rw5PEsc0lG+JMATnx/KplYK0WrFLFA+b/6sbI9sol6VxVYfxyBjOMu2 cuPiSQKRuhI/Ii/pufMRLvpv/RRtreOjComrr2cSY/UsQ/eitQ4lV8A4N9vkihXGfAXC jocIMcj4nZNfaoliBOzYCuvg07IrPpwYxejfdq0rP9aBjsz+GCs2v9UWvWp74NK8xysm I+MiJPlWe7ku5LF2LmQ2XRLZz3XUS2zcuRsG+0YhoBLd8bVGYHiJeMr9+xvHK2lfp7qX TjY2QHLWSBX0Xh/nPYNKoC00rDegSERPF0opJOSf9PQygeQEqXOh8DBnQIosWOmroEKv gRaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qvjoH8Av1aiwoBjs4TpFm49HM6EV85fk5Z2xHbHZ2/0=; b=KQd+1OwXilzcPnaMABTTFysdHoHTo4617NUSzxt34U5QS78BLrv4oWRex65J2eg0F/ ZjayKhC88bHyZWZpIYnDVA5HGekylF9ZLPqgkIAPCRmM1wu7zBkt0/LCjmxCciM2Ei3H +ge9tu9wvCu1cdg3CXe/wp8WEiTzbeR3OwQyKW3GHE+ekz/4KlEaAh3Ph1QYm56tiVid dClqJFjVqahX9eYWUpl79rTm17Uish2BsgEoZxY4GU3DCiM2c9R1jxqwNFiluf10/dL6 ept85P2+1jM/Y1XZZK0LHGC7QRbIo2PNYiiiTbbqTUCSHLQypW8r6+IVojcM28pmvXqN 8GyQ== X-Gm-Message-State: AOAM5323pg0IB/y6NMjpZD61epPAkh+Q495OtyeI57t/6aIvJWqMgpP0 XI2YBR7bDWhZzQ5gMx4HshY= X-Google-Smtp-Source: ABdhPJxDj6V7p1mg49Gk9lRZQdvAU66BzRIX02ieR1lokjcap8hmT0h8WxzGD3Dl3puao3c2m4T0Fg== X-Received: by 2002:a17:906:26c9:: with SMTP id u9mr25945431ejc.166.1614763325167; Wed, 03 Mar 2021 01:22:05 -0800 (PST) Received: from pek-vx-bsp2.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id i6sm16614865ejz.95.2021.03.03.01.22.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Mar 2021 01:22:04 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [RFC PATCH v2 2/9] hw/net: e1000: Remove the logic of padding short frames in the receive path Date: Wed, 3 Mar 2021 17:21:39 +0800 Message-Id: <1614763306-18026-3-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> References: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=bmeng.cn@gmail.com; helo=mail-ej1-x62a.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: , Cc: Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 --- (no changes since v1) 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 d8da2f6..a53ba90 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 3 09:21:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1446523 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=ptRjWwjj; 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 4Dr7nV1cfvz9sVw for ; Wed, 3 Mar 2021 20:22:38 +1100 (AEDT) Received: from localhost ([::1]:36860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHNiG-0004sc-5W for incoming@patchwork.ozlabs.org; Wed, 03 Mar 2021 04:22:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHNhr-0004p4-QZ for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:11 -0500 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]:46036) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHNhq-0001Cj-1d for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:11 -0500 Received: by mail-ej1-x62f.google.com with SMTP id mm21so40474231ejb.12 for ; Wed, 03 Mar 2021 01:22:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Q2tkJ8NbxeX4ElZp8NKBaqHSprq+lBbv+U0LcxD9Tt4=; b=ptRjWwjjPE78kPMqBpkboNVI+hwpJmq88d9vzooyP2GD59VYm9n8Fasij0/JxWjxXE 5yObEmTyDlndLf65qIK8uTS29bwbdY2i/en+Lj8Zj6kem3Gcgi167a3AS8PgzKuOH/Wp Fr8D9MTw4z5YLpsYgl0x39GDcogWFfamDCxAxEaMW+whPWIxyWQT1zqRyQMBAQ6rCDHU sLpyUCJVB9jl+e8R/DN2XyIP519r+9Uc0i9P+BYAfe9qC0fRF/Utfx7v+TpAOYDlPeZ+ 6pLDUL/9uVyxFt8hRMMRmn+8TWTNFKT5crPLlcgZKlhX/8GWNKqktikx6Nr3isKFZl7r hRbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Q2tkJ8NbxeX4ElZp8NKBaqHSprq+lBbv+U0LcxD9Tt4=; b=Zrayltp4kpY4HebvlD2IsYcVhE7QxWGujvDcOO855dNlpOwQhSBr6+z3HheTV7PqQa Wg0oyUe2g5L2MbQp1b2wNg1RNH89bdzOq7z5pvgB+aV0IBeemtY6tQBiyW1kzixe4smI yos/9MwxmCTtCZ03sQMZnkM+GJPpLIyl2ihrw9xIOJVy6Ob4hIPkdRlzUuLRlZFGKujD UlVXnP0Kr4sOfwPMO1lTpFevjm+rcNuJv2cDYxTrzyeSQAQVN9657I2+MMKABkZAVKmw 2bGGCiIC/85lTmg5UuttHwemVQ4hJnmnQ5IYv1tLvjzLdVuJCI+N5NjRRSqV8i+qK0H1 AYzA== X-Gm-Message-State: AOAM530wBIjqvFyjqbiA6c7wu52BOnYFpM04y8j+NRDughID6T2L4Nzd Jp9S2X+DuW70HpHURj7Xutc= X-Google-Smtp-Source: ABdhPJyZaU34GWDmBkFLsCPKfyPe/SlfoQ9NU5vkFppdpgvPNbYL4KHRcwZbqL3ZVfHtv/d7yAD9mQ== X-Received: by 2002:a17:906:85b:: with SMTP id f27mr18104506ejd.414.1614763328829; Wed, 03 Mar 2021 01:22:08 -0800 (PST) Received: from pek-vx-bsp2.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id i6sm16614865ejz.95.2021.03.03.01.22.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Mar 2021 01:22:08 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [RFC PATCH v2 3/9] hw/net: vmxnet3: Remove the logic of padding short frames in the receive path Date: Wed, 3 Mar 2021 17:21:40 +0800 Message-Id: <1614763306-18026-4-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> References: <1614763306-18026-1-git-send-email-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: , Cc: Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 --- (no changes since v1) hw/net/vmxnet3.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index eff299f..d993cce 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 3 09:21:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1446527 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=jQFfMBfI; 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 4Dr7qT4WHtz9sW4 for ; Wed, 3 Mar 2021 20:24:21 +1100 (AEDT) Received: from localhost ([::1]:44608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHNjv-00086t-KO for incoming@patchwork.ozlabs.org; Wed, 03 Mar 2021 04:24:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHNhv-0004x1-R5 for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:15 -0500 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:40409) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHNhu-0001Et-7n for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:15 -0500 Received: by mail-ej1-x633.google.com with SMTP id ci14so21769549ejc.7 for ; Wed, 03 Mar 2021 01:22:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IL5kg/255ghUpuIDJ0cd9ttgop2j3ymVFsi5sBFcIZo=; b=jQFfMBfIBH+hNtFdc0YaqKgIP7DjDDZvZyHc8DpSaIG0Pu7lKbAgxqURpjdYVbcFNU 5GlKWtbmNdALqAK/D5ZqMcWSkDZYyZAK6+AXkUIK+oxHIdiL67KTwO9qYYIGYG3v0Z5I jYKif+gKhkqxzS9F69ESew4srEaWNr2xD5+rynGVHcxirLdhFJXE+SCfcVePhJqGUNYe e4jw+aI+bwuhzaClbVxkOCK5g7CbiIalHtclkva7FBLsDWrKUDFkdNJ4YKt3uuyeotuo OWQ4t/JZVPyCFDnOgSo96UYW+dAbVTkz7moGL2xnMXEvP10+PQxsH6Bheu3Kzno/HihR BJsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IL5kg/255ghUpuIDJ0cd9ttgop2j3ymVFsi5sBFcIZo=; b=hbTrzF0qj5dW8tvsLO7tkzmImVjpxHqs0i/rCnzXEMn3vMnDq+Hh8Qi7ERN83qd85A Ng8c6UyQRbSWUOy1fz+FDsaAiw97SaZM3vYTK79G53Go8xARUXqXWgxd7ptfHf9MQYHV VmIjWIe5KqatcalZxzXpY3mfb8R+wmLfZR32YAM6qipvlMFOG6S2BaR3s/A86xShCr5j UrG9mw4Dy/CMp4eStjbqkpLcf18cDS1LXw3wi5GS+Fp2L3Vva4AWYGibIm5Ha5O/aZs2 +zlXnwNP3S73kI1D/F6MiJevk+idyHUVmEQRpPZUBZUkzhmr4OViXoWuV7f6vqyFtyqt tgkw== X-Gm-Message-State: AOAM530/mdmpI/Nj9YixqMsVA9ZSRwXEVkPgUkkEWt/XdxSPH3UQfTln hvEcx4GvvFBcaBibglLCFtY= X-Google-Smtp-Source: ABdhPJxiIPf3UHl9LhkYffHyhoLlKKcHIaeaJLKRTFDTHQNnf4kEWJmrfeYnqOoc4olqlugqLPPpCA== X-Received: by 2002:a17:906:c102:: with SMTP id do2mr24924430ejc.305.1614763332878; Wed, 03 Mar 2021 01:22:12 -0800 (PST) Received: from pek-vx-bsp2.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id i6sm16614865ejz.95.2021.03.03.01.22.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Mar 2021 01:22:12 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [RFC PATCH v2 4/9] hw/net: i82596: Remove the logic of padding short frames in the receive path Date: Wed, 3 Mar 2021 17:21:41 +0800 Message-Id: <1614763306-18026-5-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> References: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=bmeng.cn@gmail.com; helo=mail-ej1-x633.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: , Cc: Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 --- (no changes since v1) hw/net/i82596.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/hw/net/i82596.c b/hw/net/i82596.c index 055c3a1..1eca2e2 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 3 09:21:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1446529 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=m9FgBYjM; 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 4Dr7tf2D3Jz9sRN for ; Wed, 3 Mar 2021 20:27:06 +1100 (AEDT) Received: from localhost ([::1]:51444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHNma-0002YP-9U for incoming@patchwork.ozlabs.org; Wed, 03 Mar 2021 04:27:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHNhz-00055T-SS for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:19 -0500 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]:33950) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHNhy-0001Fy-A0 for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:19 -0500 Received: by mail-ej1-x634.google.com with SMTP id hs11so40801059ejc.1 for ; Wed, 03 Mar 2021 01:22:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AxfVTl/O/O7xm6Fzak9sqeNRKzbxNKHXeCTAnBNykLo=; b=m9FgBYjM0Tddk9H2igLIpVfwI9GQxkNqLsTzB1DrG4ruN1MejeAM940N8Wfw/cw/qV js4jUvm/1C8LzP7Tkaxl8+vCDxVAfbTnVOlPKUYxo54KYPDpAP3YvOTsTvty8h8BZF5R 2n0Lc5wVkAKpaF6D+MR+KgZ6HMfalAs38lNAzpWGtWfnTjec8K/3Cr5mjnE3ncrFKeS7 FO5mcTez1rrTiQ/MjRPqiE2YLDimF278RivrpRWZj9gRQHL+UnvXl+Es04qgJ2AnZgXh 5Md11knD2fUTP6Rc1cXupnWl/FNXYomT8ZGIdQREo4v0FAUd802lrFMwuh+Jk0vJ6N7m tODw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AxfVTl/O/O7xm6Fzak9sqeNRKzbxNKHXeCTAnBNykLo=; b=kqXojR8PM1v1ntHGzoJh7o/M/nyhY4xvDfZnASysW8XN86wVZuuiFYIWRrOD3nZ9CQ 5WG3edvLXBSBRXPqkpj+YnWCMWdfYWlvXU+MbLVf4VjUcfLq39Uw9jxAChgDOnxfXyox Tgs4RjLT9xblU34raP0MZOUEoE2OtA+L0b+DBVFqg0iBvuGfFF0RD8oMlUMraulcmJ8S rrWUXi2TOgUs9HRHWUHdug7MezBOCFWEuJXKccVuQvvDQ9JNg2NP/NBf6VtqHLThwgwt Ml18uvkjP0Wp8XHGsc/i4oLkES2Uq32HKiIPsZVN227vttUone6xb20K5Owf7Q+OMD09 MuMg== X-Gm-Message-State: AOAM531MGhz7boZFiyOAduCWAYzvsgIBj+m4InSA/2kBhlMopRfknl4K nGRa+JPJE/8cEgj1mTVKcywo+Wm+rCw= X-Google-Smtp-Source: ABdhPJxBAKIK2y1f5GMaFxAHnsvXlUiliua0e0fQlI0F3+sJ8kO2GN1pqW9mySlyMfE4sWa76KbQ5Q== X-Received: by 2002:a17:906:4349:: with SMTP id z9mr25096924ejm.471.1614763337014; Wed, 03 Mar 2021 01:22:17 -0800 (PST) Received: from pek-vx-bsp2.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id i6sm16614865ejz.95.2021.03.03.01.22.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Mar 2021 01:22:16 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [RFC PATCH v2 5/9] hw/net: ne2000: Remove the logic of padding short frames in the receive path Date: Wed, 3 Mar 2021 17:21:42 +0800 Message-Id: <1614763306-18026-6-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> References: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=bmeng.cn@gmail.com; helo=mail-ej1-x634.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: , Cc: Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 --- (no changes since v1) hw/net/ne2000.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c index 6c17ee1..b0a120e 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 3 09:21:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1446528 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=siHaRYii; 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 4Dr7sb2qNfz9sRN for ; Wed, 3 Mar 2021 20:26:11 +1100 (AEDT) Received: from localhost ([::1]:50146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHNlh-0001zp-B4 for incoming@patchwork.ozlabs.org; Wed, 03 Mar 2021 04:26:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHNi3-0005Dd-Se for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:23 -0500 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]:43053) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHNi2-0001Ha-AH for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:23 -0500 Received: by mail-ej1-x635.google.com with SMTP id p8so14456283ejb.10 for ; Wed, 03 Mar 2021 01:22:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IE0qfuFnzVIK6DZCDqQ7WbPvxJH1wtTUaIMLDrAARCM=; b=siHaRYiiplNh3AUV31jT3ytO2Qo+bokilsI6NL8oadSYEfYpP57/23bpAiMmWzPYuz c9BgNGmKML9xslxcQZRRvEhrQFypj/9y05VcPfp4rBDoSbFUNPVOEusngWZQLdoZisuZ pnCVC/FbfDWy3k585FqbcUgSBi6J9XWUrCXiPOF1h57bRsj1LeWSODxZ3NDQ35D4M17w 9E6swDMpFHiwAj7y32+lQi3a/XMBiXfhay6esI0BTOltVcijUKyilNzPepygt6cxeI4x QYPfXcKUqSFDHDtVYklUnQbSEJ7j3pd/wpIhkcEPr8OAQU4D0c4oKqcVwSYoZtoMob/u cB7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IE0qfuFnzVIK6DZCDqQ7WbPvxJH1wtTUaIMLDrAARCM=; b=qQu2L3KufUeeb+jdVWtkPSKy95c1sOqLnCJt4YeHbaKwUDffsw8lWUWs9YNwdxI8MJ xfBPGG8cvo9eWQ4wbxEE6WewpsGkALYSAt5qXt/87hAHlyfrrb7bcfCnhWV+Zpt5VrJC FWBTvltudhiK4LFQrlWbtr9T4d05fPzDZThgbCjtoOj5gtMOiDdYsIH1Uxz891+BC4RK cxTQ2pveCTUb271zw+T990/WVWgSHNWvkrlknQw7c36ujzrGL8yXdqN7cXjMgM0hyQ4e yRzbaKhzUzuInruZf2DAHcRAQxRotAfX8zXN0gAs72zMqGf5GTLm+H20AKBta5OGSAB6 dRIw== X-Gm-Message-State: AOAM530adn1Au1DxaS/DA9E0QzFSvYZ/x2GCQR3T0ZIoBWlW2ouDI2K0 gtR100pYPYG2CY+GxhqCyYg= X-Google-Smtp-Source: ABdhPJyNIgVG/q3xAbHFI93W5Kl+A1oV42x5zb0VowUnW74tLupRDQMo9z7XgcOIABz74JGVPwNbsg== X-Received: by 2002:a17:906:a0d3:: with SMTP id bh19mr25402126ejb.199.1614763341113; Wed, 03 Mar 2021 01:22:21 -0800 (PST) Received: from pek-vx-bsp2.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id i6sm16614865ejz.95.2021.03.03.01.22.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Mar 2021 01:22:20 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [RFC PATCH v2 6/9] hw/net: pcnet: Remove the logic of padding short frames in the receive path Date: Wed, 3 Mar 2021 17:21:43 +0800 Message-Id: <1614763306-18026-7-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> References: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=bmeng.cn@gmail.com; helo=mail-ej1-x635.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: , Cc: Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 --- (no changes since v1) hw/net/pcnet.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c index f3f18d8..1633033 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 3 09:21:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1446526 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=hn0XoO+C; 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 4Dr7qK63gcz9sVS for ; Wed, 3 Mar 2021 20:24:13 +1100 (AEDT) Received: from localhost ([::1]:43764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHNjn-0007lE-Qh for incoming@patchwork.ozlabs.org; Wed, 03 Mar 2021 04:24:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHNi7-0005LU-LB for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:27 -0500 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]:43046) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHNi6-0001IW-4R for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:27 -0500 Received: by mail-ej1-x62c.google.com with SMTP id p8so14456652ejb.10 for ; Wed, 03 Mar 2021 01:22:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CNwg80BJ3VhdZvmEZy6PuVx6Js+7N8Qb8ukEX4lRJGI=; b=hn0XoO+CozBIQuCXj2obdftmOgaYGCoFTOF5pOF//ICgHhvYo2ttueHnhqlu+PdJin UIWFLrNAluUCdLpfbKaFM+qpldAyHs3wwH+w6QPoh/uXS4QiZHrDVpa0m9ZqGUcG5Vnx UlG8NrQzeHYVl2LHat3X1xd4QCo+uxfw3FPz1xyoAZM/GpiKrkLcpEQn3v/jguJvZC// oMl6BartjBRbsfcFIajp1WWtwXLcpfpfieOXaoDRBedjx4HS7BlK25lLMoj+wTjd9CnS qrZU5MDIZwfc0egmA/etEj0lGAMg+TLpPssXZJHq2SIrzbXEWF2j4m3pJpFzqNMenfJ/ rALg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CNwg80BJ3VhdZvmEZy6PuVx6Js+7N8Qb8ukEX4lRJGI=; b=tHAOoEHX/MrFVqcTG/hvAqzfBMFZ3MSAlbnkLScyNLLwY/NE/2Jalamz2mU655w7DH +0bgqcZrluDm2Xo/Aw1fyvkQOrowLGfM7NKOXPjz2F4klo9oCVwdSnBKgv2XhED7cHxh gXPmma7nnKT1u0mjSKI8Klz9AI5pk43yzjye20Zvz5WsGc8v/bdlMwTFJEHenAjlvaQZ Q4IuajpaupakTosr6+RSwcBqfUOj32eTdZuqpwbQaJD3mK8RCxiLYyJfVSUBviW4qYXD Dud4CIGSXawQiwH/Pkc3b0FCiQLP4EqQgT2UvFPXA/nXSSDL5ySj+oLJ60hirkf/vfMJ 8CDA== X-Gm-Message-State: AOAM53174OPkKh01/Kc9o1j/4MkW6UQKkUHYHhexLDqzI4F9CSprvH0L e0qcMUTaxw36nyQjzZLNC1I= X-Google-Smtp-Source: ABdhPJxxCZ1SEaDxfIW2zTg2q6Kzrs1tf6tsUuLi9kcyI0e9ENb26bWdtzvDjQ2jAIISnWf1AEMKXQ== X-Received: by 2002:a17:906:d1d5:: with SMTP id bs21mr24997039ejb.242.1614763344892; Wed, 03 Mar 2021 01:22:24 -0800 (PST) Received: from pek-vx-bsp2.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id i6sm16614865ejz.95.2021.03.03.01.22.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Mar 2021 01:22:24 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [RFC PATCH v2 7/9] hw/net: rtl8139: Remove the logic of padding short frames in the receive path Date: Wed, 3 Mar 2021 17:21:44 +0800 Message-Id: <1614763306-18026-8-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> References: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::62c; envelope-from=bmeng.cn@gmail.com; helo=mail-ej1-x62c.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: , Cc: Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 --- (no changes since v1) hw/net/rtl8139.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index 4675ac8..cbfe29a 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 3 09:21:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1446524 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=gj3EfG92; 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 4Dr7p14MpTz9rx6 for ; Wed, 3 Mar 2021 20:23:05 +1100 (AEDT) Received: from localhost ([::1]:38440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHNih-0005Xs-JM for incoming@patchwork.ozlabs.org; Wed, 03 Mar 2021 04:23:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHNiB-0005U8-QY for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:31 -0500 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]:35789) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHNiA-0001JT-AF for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:31 -0500 Received: by mail-ej1-x634.google.com with SMTP id dx17so13213772ejb.2 for ; Wed, 03 Mar 2021 01:22:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4P+95OIQONEnAIsxo8Qi33XehTlY7Zdbpw889iDd7IA=; b=gj3EfG92bCsx1KdBXZkq11vPwoAAp70hUfPlxGYAFRbCUYlxH7zDtQzY2iDdB5XZj/ GLLRtbaND8hN1C4/plxEMj09a60ZS9TDA46yHGs/Q2myHyXld0J9NfrmNfYeHjVzKeFd VdLwfBc8ojahWG4VbgW2xJ37RPHr61/7Exv6mwVTrqhO5bTvGYfUevbc3Qe9Ox2vYNKE 98hL2c3cFCJO5ae0hIIZkPF4hJlG79j9GIdv/o2U0Fm+TZ06MoP1JYyei8iCXLWtzIcm v/uw1B4k7NzxPSICbVGdK0wv2nsSht51oHTod6ApEdnZXjk0aN6RbZVAzgXuXCuxczmX M5Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4P+95OIQONEnAIsxo8Qi33XehTlY7Zdbpw889iDd7IA=; b=hgM1MqLn1qJXU167fWam/tU+Rgx4UBrDt7T9dWgt0gcexxtLxFA8qn9fHePjTrIaQj qbzFfPC4JRL1gHBVla4gomRB3FTKu2qq2EnCY2qhrAt6tMtMqQ+g/b8Mn51I3vu7VOsQ q22vy+AKHZyqTtL2DSgE0JalqaWOv67aE/PPyYDcfMIjz9x5Bw2tMkb9krOF7kTmrV75 mQAlj74Ar9HqRyUhk8jMEuNRc6V1OJ7iMrzAmHS+xfzzfO750c8mnfUsaEKdekV5/Vef v3K212MieLj+hzPrV0cuXgVvQ7T5aiWbVw7RYFZG4UdPhhMaucdpjp37xrk2shUNM/aS 6vow== X-Gm-Message-State: AOAM5303pmW4z3nGwUyxVF04U1MFLvNuK4S6gUF1siq6uYu4jVisXYTU q7e7M9fcxtp+m0AEAdR9Yh8= X-Google-Smtp-Source: ABdhPJzmiNm3p05BCaE7+KywbYwpYWIwi5RQvFqoMbDQEPAv4Kk3IyWzAVBKHf8Lwyhy0aVNpFAlcA== X-Received: by 2002:a17:906:23e9:: with SMTP id j9mr15744794ejg.78.1614763349011; Wed, 03 Mar 2021 01:22:29 -0800 (PST) Received: from pek-vx-bsp2.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id i6sm16614865ejz.95.2021.03.03.01.22.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Mar 2021 01:22:28 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [RFC PATCH v2 8/9] hw/net: sungem: Remove the logic of padding short frames in the receive path Date: Wed, 3 Mar 2021 17:21:45 +0800 Message-Id: <1614763306-18026-9-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> References: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=bmeng.cn@gmail.com; helo=mail-ej1-x634.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: , Cc: Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 --- (no changes since v1) hw/net/sungem.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/hw/net/sungem.c b/hw/net/sungem.c index 33c3722..3fa8316 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 3 09:21:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1446530 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=B1pK4gC9; 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 4Dr7wt4FcYz9sRN for ; Wed, 3 Mar 2021 20:29:02 +1100 (AEDT) Received: from localhost ([::1]:57794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHNoS-0005I5-5i for incoming@patchwork.ozlabs.org; Wed, 03 Mar 2021 04:29:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHNiG-0005ed-JC for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:36 -0500 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]:46464) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHNiF-0001Kv-4R for qemu-devel@nongnu.org; Wed, 03 Mar 2021 04:22:36 -0500 Received: by mail-ej1-x62e.google.com with SMTP id r17so40731320ejy.13 for ; Wed, 03 Mar 2021 01:22:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bynr5MYFkB5Fb/MRZdPHIqg8W5OekBTrWbuXoxt0cro=; b=B1pK4gC9kGZ/s3n484HZMnOLJuSAbnw5JHnDDY7GiYkFnAQzjoKMU08ZNSzwncc613 iOi5IUa6JY7F2/VbhhcdEgxXd9d5F3GWQKc7XmOnfWW4gjQ+HU1ZBvum6O1ybF5GvVUh DR2OA1/omcmiNlTfsbL7XND3ivehshTEOKmKhKgarvFgf1LVrHfIVgJfUsyQ0aJFXxG7 RlAEuk2/hWAc4iepOqlXJ44wmcSl3k5ZoW/xk2C9gOXHFBs5J6sJnVGIVKhnLZg7OTsN 6pYAxj2LPlgSO+mSh+FKfNxMHKsD2wgm2rtWDkuG3GME+cXGd0DJv1XqoVCEUBzjjMU4 n+IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bynr5MYFkB5Fb/MRZdPHIqg8W5OekBTrWbuXoxt0cro=; b=B0HPhByVPF5BpRDiihkWDlfNE/DNsGpmuH/Aj/zGmvzB9zlak0An2eNIOB4aKKsi4t MR/BJ0EqHMdsUwz4brQGV9XmGzK4ZWxPTNMvaG0hvSUy1hjqx2RkwFg4zMGhRJZewrJ8 GlR0GQho0ivH3kT2fxRw0JI5F1eLPZ5LYcJV3IdkmV0xccgvhyu3vX9sJ4d8yqjnscQJ cfXSMIV+OlsuHkDQrJfAzXHhf1qOHyyoTyMVoqNwO+wJeVwuDdKweSOPlXj7brGYvtJ5 woU/w3v/L2lt9DKUSvhcN9UttJiuB2UCK3jCejamtQbqdMVcdyb8URhiHjucRkaCvHW3 hcfA== X-Gm-Message-State: AOAM532e9Pzlj+Ba5Va6t5HP5SzGPS+BOIkLXzLxXl/rMuhk1gTnllMw PnW0mnOwfnNUqDojIZ9dpBY= X-Google-Smtp-Source: ABdhPJxrgiFPAsx9oZSXVdacuG8Gr6ApWvAKy4+Z792h/PhFN3aAtSZzyzFcz6m2ARjS6NpaRYTWDA== X-Received: by 2002:a17:907:3e1b:: with SMTP id hp27mr23709236ejc.506.1614763353883; Wed, 03 Mar 2021 01:22:33 -0800 (PST) Received: from pek-vx-bsp2.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id i6sm16614865ejz.95.2021.03.03.01.22.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Mar 2021 01:22:33 -0800 (PST) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [RFC PATCH v2 9/9] hw/net: sunhme: Remove the logic of padding short frames in the receive path Date: Wed, 3 Mar 2021 17:21:46 +0800 Message-Id: <1614763306-18026-10-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> References: <1614763306-18026-1-git-send-email-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=bmeng.cn@gmail.com; helo=mail-ej1-x62e.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: , Cc: Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 --- (no changes since v1) hw/net/sunhme.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/hw/net/sunhme.c b/hw/net/sunhme.c index fc34905..6971796 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);