From patchwork Wed Mar 17 06:26:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1454449 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=WFKQFlYP; 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 4F0gFZ5l2sz9sWH for ; Wed, 17 Mar 2021 17:28:02 +1100 (AEDT) Received: from localhost ([::1]:54832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMPey-0003aI-HO for incoming@patchwork.ozlabs.org; Wed, 17 Mar 2021 02:28:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMPe1-0003YK-C7 for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:01 -0400 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]:39344) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMPdz-0008Ui-Kz for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:01 -0400 Received: by mail-ej1-x62e.google.com with SMTP id p7so738719eju.6 for ; Tue, 16 Mar 2021 23:26:56 -0700 (PDT) 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=ofNCt4IqFempV2fS5VLJE6TwBn3PW2075cIcAlj7O8c=; b=WFKQFlYPPwSKaqtAJ6Gz/Bnxc0nSJ+TEh+IZSXq7LjPm3RgQ4yCnurKsUPN5rrSNT5 8PJwdKU58ftiG6KrA5LvADPYMH7a5342XxwgqDt+BKzug/91Eyt81Gkq0Ey2KTozsaaB 2iIgTnku3EaHzYZrMKJWoNSW4hv9nktjXhyixQ9HzTF2L3CYMlGVm3rIzflYC2Z7ySfv NviZ9s0+EqFj0iDeYg8Uoc1z6GR61i7+jtFClstTXXX7Ct5U47CwmlvYpGcBWfmYtSNj QR5IBlUGAEB+RlaVZUbnTibPPJMEJ/lCmDLtJeUaUqhDXQbMT8CJrl663A9bomah+Xgv Xwmg== 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=ofNCt4IqFempV2fS5VLJE6TwBn3PW2075cIcAlj7O8c=; b=dEWf7hZCrcjP6AIM/ZbyR6dALF7U9/lTMdEoxrD2HUffbCzPxEu0yHuq2VLulWOnWm pVRdJszvCd0IctuD6CJStD+uvwqsNa3sFdEuqDLIlwv+BvVN8s45WcmB61Bc6Z11uBJe ss03NWs2neuLdODpQ1/r+5sDLk+ik2KDX5BZCRiNdUd6eVCaclqVP5ES4/cSSBa7t591 rJ3ZyYvYEePyQhzav/RFy//dKW4sn9u13Sjgk+hL4sM90wG/zMmQasIo5olQyDpb0kM7 HlrHdG2stGuFLG5Mr1DQx2DIiFhOSbtHTrS8gXAyIKSsK2lIqB3mMhl499lb85DZOMLm nTIQ== X-Gm-Message-State: AOAM533w8pxQVobLKBc5AnnhcqH/Inru32yEoHomwKS03pk+7pzKli9z 0eUi6G92UyNZbLXTXKtmTA8= X-Google-Smtp-Source: ABdhPJwVCRGujPH7Gbn6FkrgIaXpIZvnLQrRh6S8te0RlPXTYt4jwULvyjMps5MAM1KC4JEjgd1KMw== X-Received: by 2002:a17:906:5949:: with SMTP id g9mr1798906ejr.518.1615962415174; Tue, 16 Mar 2021 23:26:55 -0700 (PDT) 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 d1sm10751349eje.26.2021.03.16.23.26.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:26:54 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v5 01/12] net: eth: Add a helper to pad a short Ethernet frame Date: Wed, 17 Mar 2021 14:26:27 +0800 Message-Id: <20210317062638.72626-2-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210317062638.72626-1-bmeng.cn@gmail.com> References: <20210317062638.72626-1-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: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add a helper to pad a short Ethernet frame to the minimum required length, which can be used by backends' code. Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé --- Changes in v5: - minor update on commit message - update the eth_pad_short_frame() comment Changes in v4: - change 'ethernet' to 'Ethernet' - do not inline the helper - check the padded buffer size to avoid buffer overflow Changes in v3: - use 'without' instead of 'sans' - add a helper to pad short frames include/net/eth.h | 17 +++++++++++++++++ net/eth.c | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/net/eth.h b/include/net/eth.h index 0671be6916..7767ae880e 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 without FCS */ struct eth_header { uint8_t h_dest[ETH_ALEN]; /* destination eth addr */ @@ -422,4 +423,20 @@ bool eth_parse_ipv6_hdr(const struct iovec *pkt, int pkt_frags, size_t ip6hdr_off, eth_ip6_hdr_info *info); +/** + * eth_pad_short_frame - pad a short frame to the minimum Ethernet frame length + * + * If the Ethernet frame size is shorter than 60 bytes, it will be padded to + * 60 bytes at the address @padded_pkt. + * + * @padded_pkt: buffer address to hold the padded frame + * @padded_buflen: pointer holding length of @padded_pkt. If the frame is + * padded, the length will be updated to the padded one. + * @pkt: address to hold the original Ethernet frame + * @pkt_size: size of the original Ethernet frame + * @return true if the frame is padded, otherwise false + */ +bool eth_pad_short_frame(uint8_t *padded_pkt, size_t *padded_buflen, + const void *pkt, size_t pkt_size); + #endif diff --git a/net/eth.c b/net/eth.c index 1e0821c5f8..f913e4396f 100644 --- a/net/eth.c +++ b/net/eth.c @@ -548,3 +548,20 @@ bool eth_parse_ipv6_hdr(const struct iovec *pkt, int pkt_frags, info->l4proto = ext_hdr.ip6r_nxt; return true; } + +bool eth_pad_short_frame(uint8_t *padded_pkt, size_t *padded_buflen, + const void *pkt, size_t pkt_size) +{ + assert(padded_buflen && *padded_buflen >= ETH_ZLEN); + + if (pkt_size >= ETH_ZLEN) { + return false; + } + + /* pad to minimum Ethernet frame length */ + memcpy(padded_pkt, pkt, pkt_size); + memset(&padded_pkt[pkt_size], 0, ETH_ZLEN - pkt_size); + *padded_buflen = ETH_ZLEN; + + return true; +} From patchwork Wed Mar 17 06:26:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1454448 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=Nh9rto9i; 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 4F0gFZ2zm5z9sVm for ; Wed, 17 Mar 2021 17:28:02 +1100 (AEDT) Received: from localhost ([::1]:54872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMPey-0003bi-A6 for incoming@patchwork.ozlabs.org; Wed, 17 Mar 2021 02:28:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMPe1-0003Yq-SS for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:01 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:38535) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMPe0-0008Up-CX for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:01 -0400 Received: by mail-ed1-x530.google.com with SMTP id h13so849602eds.5 for ; Tue, 16 Mar 2021 23:26:59 -0700 (PDT) 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=KBK+oSYyQ3izYCwDMZ0s2I8Z5y9obtyOlXBYftAXE6U=; b=Nh9rto9iku5u/XBSpnOEoYGZWur+QG6pLt+lqm28LdQUVP4u9PQc9djBTBATlFrkFR Ylx9GqYaIHpG6uH4M2nbXqxGVN6saHjOvyI3/ZyZ7Jfp5lUTRJNdZylTkK5fuDZn/Hxe 8MvH1HatceWbykfw3xwqLeVW/39K0UQZPxqri+J+vdFVVfgAgqGxW7VyjK+LkfHJ971Z KKqHD0LnwdIukbBnDb6Hhtyst29fj4FCXDMs2u6H9fBfXTvdFjdhVDGHI6vuiuAYi/fo UbNSqIBLHJTz1GWWPax3PTVM5z/BEY4RFo9+2MkZN+A2HUEOtXDeWEfxJ9dZmxsvGl8s 0zXw== 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=KBK+oSYyQ3izYCwDMZ0s2I8Z5y9obtyOlXBYftAXE6U=; b=IiXAzLFVFxDm6hvzitSnIH86yo6gbQ967nKKLC90yIEWmEDdFKekkNlrmbTqlR+XUr LN+H6Tsm5tZ4q3yDtQM+8rwKmF1LaWhOkj+dSlc01F8+wsGY3QftHtI0hkTydZMYOPLo Ul7brwZPk/2KjXKe0lr9MRmM8nsTFAo+U6H38kZEw0SKyPeUZ2HnMp5/VuG26cH7js4S kX/93SN5ScUhv0He05pAZcEOrTqdZY/fLTm9kASFGlXLdfzuBQRc7DZGC7FIw/5WQUMW sbcEIpvlGtaKcBFm/isI14q1vZ61h/hMBTT/nTQLuAvIBPAVft93DgxC1O73p7jxw6fC 7mcw== X-Gm-Message-State: AOAM530RGrFYc5Uh1yr1QqGxzrzDfzzEQGClQDMe+iY9YhDUh9F4Qwq2 ijb8zNW/8d6+1vBaao+ITmI= X-Google-Smtp-Source: ABdhPJwFfhS7qaII+uRT90b2ivEznNxRwA5CPW8uhg0FsvkKRTxJbzymYZJUPg5fGENxSrJPOSDw/w== X-Received: by 2002:a05:6402:2ce:: with SMTP id b14mr40183437edx.13.1615962419043; Tue, 16 Mar 2021 23:26:59 -0700 (PDT) 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 d1sm10751349eje.26.2021.03.16.23.26.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:26:58 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v5 02/12] net: Add a 'do_not_pad" to NetClientState Date: Wed, 17 Mar 2021 14:26:28 +0800 Message-Id: <20210317062638.72626-3-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210317062638.72626-1-bmeng.cn@gmail.com> References: <20210317062638.72626-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=bmeng.cn@gmail.com; helo=mail-ed1-x530.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" This adds a flag in NetClientState, so that a net client can tell its peer that the packets do not need to be padded to the minimum size of an Ethernet frame (60 bytes) before sending to it. Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé --- (no changes since v3) Changes in v3: - add a comment to 'do_not_pad' include/net/net.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/net/net.h b/include/net/net.h index a02949f6db..3559f3ca19 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -103,6 +103,7 @@ struct NetClientState { int vring_enable; int vnet_hdr_len; bool is_netdev; + bool do_not_pad; /* do not pad to the minimum ethernet frame length */ QTAILQ_HEAD(, NetFilterState) filters; }; From patchwork Wed Mar 17 06:26:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1454450 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=UFv6XZy8; 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 4F0gFg3rHwz9sWH for ; Wed, 17 Mar 2021 17:28:07 +1100 (AEDT) Received: from localhost ([::1]:55202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMPf3-0003jw-Gy for incoming@patchwork.ozlabs.org; Wed, 17 Mar 2021 02:28:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMPe6-0003gl-1O for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:06 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]:36007) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMPe4-000056-5y for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:05 -0400 Received: by mail-ej1-x62b.google.com with SMTP id e19so749803ejt.3 for ; Tue, 16 Mar 2021 23:27:03 -0700 (PDT) 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=rDQdQ31Ek+KqitukNgsTl2vL/K22ucZcSt0OxTt5Mtc=; b=UFv6XZy8hbJWJkW/XKJHaZmV806toP4HnbN9h5mv9CQfH83/SHxz3kBFv/6+5q17Fe 8rLnpmYp8s5ebxW4CjmZX/p4dctx4aUIOHa8V0eKa4AE6bAdx3YAgUn4g6PFJoEwknZa wi7Dqy1Ghmg93fXnlIcMvKrtO7uqTv8xe/d7pzpfJFWwdjcldOThraEYWixrRfVmS2bW yQSKDt4qOBH5fCuBpk4U8+eiNAwq9l4davuuntX3Z4FODn4OeqbWcQFSehssSz5XY2FD DPLTenQR8rb8b1nPQBcAMxbwAgEW9JUrdBCZUKpSg5aqMvrgGTBdTecDjHDr4lw6yjMd WQjA== 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=rDQdQ31Ek+KqitukNgsTl2vL/K22ucZcSt0OxTt5Mtc=; b=KqoJBXg3XIZiBbLzfoPoxGV+d7fjqYMrOpFhZIzIMXIvYq/MA3Zp05ng9Rq4yduwDj w+I5EQxgjIFXwwq3hT/kds10oeCpAC1OaX5UIe3Q903CmHmkyFwSASVAsHQMwdv9KiPH 2FmuQrl8F/0N3CAX2sWVpcW61US/ifyg3BtKeNVXPX39IR73rjsE2+xwiAA7d3XsxxF/ e+G4XDFlicTJ77U2hgP+3oHuG06jQTNA8EheT7lcK5PH9tqUoKkOpAZhNkTF7Dmvp9Jq B1S5zJAXjjrb6AAxs9Rca2Q9q/PIsUeC+mEnwhIo9ghR5MlqtIrqPGa2b7JdYqb26ZqL Bhiw== X-Gm-Message-State: AOAM533L2eJKpAd5Y2okRcPlwFILcuAG/9R1uE+bvulB69sJrWTSdhXb O0o0hOAFjTZ+xZkycwjvw8Y= X-Google-Smtp-Source: ABdhPJw9nET9Ic5ETRK2ZZ4p0PGY6iqp6nrIC2QUlLcadY2ZRHQZnCLIYiKkpjx9SytDWEfY7SCyQw== X-Received: by 2002:a17:907:7664:: with SMTP id kk4mr34725278ejc.352.1615962422820; Tue, 16 Mar 2021 23:27:02 -0700 (PDT) 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 d1sm10751349eje.26.2021.03.16.23.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:27:02 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v5 03/12] net: Pad short frames to minimum size before sending from SLiRP/TAP Date: Wed, 17 Mar 2021 14:26:29 +0800 Message-Id: <20210317062638.72626-4-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210317062638.72626-1-bmeng.cn@gmail.com> References: <20210317062638.72626-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=bmeng.cn@gmail.com; helo=mail-ej1-x62b.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 like SLiRP/TAP, we change to pad short frames before sending it out to the other end, if the other end does not forbid it via the nc->do_not_pad flag. This ensures a backend as an Ethernet sender does not violate the spec. But with this change, the behavior of dropping short frames from SLiRP/TAP interfaces 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 is still supported and short frames can still pass through SLiRP/TAP. 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 Reviewed-by: Philippe Mathieu-Daudé --- (no changes since v4) Changes in v4: - squash slirp/tap commits into one Changes in v3: - use the pad_short_frame() helper net/slirp.c | 10 ++++++++++ net/tap-win32.c | 10 ++++++++++ net/tap.c | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/net/slirp.c b/net/slirp.c index 9454a673d6..a9fdc7a08f 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -31,6 +31,7 @@ #include #include #endif +#include "net/eth.h" #include "net/net.h" #include "clients.h" #include "hub.h" @@ -115,6 +116,15 @@ static ssize_t net_slirp_send_packet(const void *pkt, size_t pkt_len, void *opaque) { SlirpState *s = opaque; + uint8_t min_pkt[ETH_ZLEN]; + size_t min_pktsz = sizeof(min_pkt); + + if (!s->nc.peer->do_not_pad) { + if (eth_pad_short_frame(min_pkt, &min_pktsz, pkt, pkt_len)) { + pkt = min_pkt; + pkt_len = min_pktsz; + } + } return qemu_send_packet(&s->nc, pkt, pkt_len); } diff --git a/net/tap-win32.c b/net/tap-win32.c index 21e451107b..d7c2a8759c 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -31,6 +31,7 @@ #include "qemu-common.h" #include "clients.h" /* net_init_tap */ +#include "net/eth.h" #include "net/net.h" #include "net/tap.h" /* tap_has_ufo, ... */ #include "qemu/error-report.h" @@ -688,9 +689,18 @@ static void tap_win32_send(void *opaque) uint8_t *buf; int max_size = 4096; int size; + uint8_t min_pkt[ETH_ZLEN]; + size_t min_pktsz = sizeof(min_pkt); size = tap_win32_read(s->handle, &buf, max_size); if (size > 0) { + if (!s->nc.peer->do_not_pad) { + if (eth_pad_short_frame(min_pkt, &min_pktsz, buf, size)) { + buf = min_pkt; + size = min_pktsz; + } + } + qemu_send_packet(&s->nc, buf, size); tap_win32_free_buffer(s->handle, buf); } diff --git a/net/tap.c b/net/tap.c index 12a08d54fe..d6d8456188 100644 --- a/net/tap.c +++ b/net/tap.c @@ -32,6 +32,7 @@ #include #include +#include "net/eth.h" #include "net/net.h" #include "clients.h" #include "monitor/monitor.h" @@ -189,6 +190,8 @@ static void tap_send(void *opaque) while (true) { uint8_t *buf = s->buf; + uint8_t min_pkt[ETH_ZLEN]; + size_t min_pktsz = sizeof(min_pkt); size = tap_read_packet(s->fd, s->buf, sizeof(s->buf)); if (size <= 0) { @@ -200,6 +203,13 @@ static void tap_send(void *opaque) size -= s->host_vnet_hdr_len; } + if (!s->nc.peer->do_not_pad) { + if (eth_pad_short_frame(min_pkt, &min_pktsz, buf, size)) { + buf = min_pkt; + size = min_pktsz; + } + } + size = qemu_send_packet_async(&s->nc, buf, size, tap_send_completed); if (size == 0) { tap_read_poll(s, false); From patchwork Wed Mar 17 06:26:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1454453 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=ac81lsF3; 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 4F0gL84rM3z9sVm for ; Wed, 17 Mar 2021 17:32:00 +1100 (AEDT) Received: from localhost ([::1]:34896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMPio-00073n-LH for incoming@patchwork.ozlabs.org; Wed, 17 Mar 2021 02:31:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMPe9-0003mA-06 for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:09 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:39700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMPe7-00007Y-Eu for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:08 -0400 Received: by mail-ed1-x530.google.com with SMTP id bf3so848315edb.6 for ; Tue, 16 Mar 2021 23:27:07 -0700 (PDT) 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=p/MLTxeMfbETxV9ik8tSzu3enBcQaEzeh7XBZdElKyw=; b=ac81lsF39C6zWWoNcl1GlU0y1qy2QJA5z8flh/m75x/O8CjfH2/lFPJNW5SG/+FxyH GB/AmZkz78y1fLJVq7lwHPuBmPomdamBeWMig6BsPMTCxQWDv3IglxZBshRgIU//xN2g 3o29bre0b9RhL2CC5S9Iov0e7CPkvEk/TrGtiDqNH3O4iHXy3Vz2qFccVC4ya87NCzlx OhZgjkzzyvGPIofTbKfsIZapmdNAFN1sI0hbM4miC4+9jGaozzbEwyPMdhfVPJ5zCj9R vse0d7UUwekveXHkn1RJCtrqhqSQBfnkf8pkdy+pDVa+fk3LL8LsfsRgf9+ba7nGE7zn L6IA== 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=p/MLTxeMfbETxV9ik8tSzu3enBcQaEzeh7XBZdElKyw=; b=PesXYL2DyJuaSIZXvTe7sl6JaFo2HfL2Nr538xg/0sL9WaQNoVaIxxAVPtmghYvQyB ShBlAXSTvq83XqvdaESn4rOz10LqzvDSyEMMqKJXceLYGaYpfNPpr6qryuFOjuUDe11c bM1cY0c2H0bWQLy+K6jODS0y4i45mgNpryfgrEHdzTbrUOLdVccServcibgZQBbuebMx scPG4glYpD0+ypTjSScLgcUGnp+mXh+yWfBNTeLpn2prl2E3otN7GO9IfHOUv0SfxOsx Sef/rmGnt7SAajkKgZURVIUHfsoYFCQq/fs4m1+OuCKmoeduysX4kbo0mcVw28F/0Ctt 5y5A== X-Gm-Message-State: AOAM532tIWYJ1Mc4hjmJeQx5Cd4R7Qmnd76RMNBk1IRwaiiE+b+ezvgo qTRS2qTGz53c0M5FXzfJOy4= X-Google-Smtp-Source: ABdhPJytTjzVoklcyp5+MN3BrKkr/y+gWNzl2oabBklAgEyqY0aIwbedalNWokV7WJKSm0jt0VfvLQ== X-Received: by 2002:aa7:db95:: with SMTP id u21mr39909160edt.152.1615962426369; Tue, 16 Mar 2021 23:27:06 -0700 (PDT) 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 d1sm10751349eje.26.2021.03.16.23.27.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:27:06 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v5 04/12] hw/net: virtio-net: Initialize nc->do_not_pad to true Date: Wed, 17 Mar 2021 14:26:30 +0800 Message-Id: <20210317062638.72626-5-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210317062638.72626-1-bmeng.cn@gmail.com> References: <20210317062638.72626-1-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=bmeng.cn@gmail.com; helo=mail-ed1-x530.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" For virtio-net, there is no need to pad the Ethernet frame size to 60 bytes before sending to it. Signed-off-by: Bin Meng --- (no changes since v1) hw/net/virtio-net.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 96a3cc8357..66b9ff4511 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3314,6 +3314,10 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) object_get_typename(OBJECT(dev)), dev->id, n); } + for (i = 0; i < n->max_queues; i++) { + n->nic->ncs[i].do_not_pad = true; + } + peer_test_vnet_hdr(n); if (peer_has_vnet_hdr(n)) { for (i = 0; i < n->max_queues; i++) { From patchwork Wed Mar 17 06:26:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1454454 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=FnfDC8DW; 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 4F0gLx41Bhz9sVm for ; Wed, 17 Mar 2021 17:32:41 +1100 (AEDT) Received: from localhost ([::1]:35600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMPjK-0007Ko-1Q for incoming@patchwork.ozlabs.org; Wed, 17 Mar 2021 02:32:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMPeH-0003qN-FZ for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:18 -0400 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]:41675) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMPeB-0000AN-F0 for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:17 -0400 Received: by mail-ed1-x529.google.com with SMTP id z1so840408edb.8 for ; Tue, 16 Mar 2021 23:27:11 -0700 (PDT) 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=iPwxQg/lwVJvMXW1l0nau/UtyXDrLqEwDqu+e37f5Nw=; b=FnfDC8DW6JIpKCSKbe5X+czGwIq0LfVuj76pfgkSvil1AQr2cGXWnY9F3SnO0tSGwg xe0VDRpr6JjTlMOkr75DerTtmYwAJTuTj54U4BT2S/dfHOIZeDustW44HZisVa0WmO4F eYnpAFjY8T/UgwSYCM6D6NNrbs8mv04roNC/2j3kail5I7N1kBD5lHoHQkLVt4N9w4Li p0vYoOYMVO+aKcxqwsZvRDDkGwoARy8u2BbforNPncAsBKcEPaaxlK89zu+oRy3wRpEg U3XeMFNb3V5AsSBacEeJq2cRcdTvqllTmTSIxej9ieNCy1feDt3fal0K18CR6mHfRmNK f2yg== 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=iPwxQg/lwVJvMXW1l0nau/UtyXDrLqEwDqu+e37f5Nw=; b=siD3PmyNVU9Oq68DQpL9o6ic35F/OUFSem8+LzA+Nq5YdzpmS09PndeY2eUHLLFwYo sYZJdARaMy2rYaM4NZy9LBOUWsxWbpa5+gKr95XFpF1Qp2UR85ZYE70p7JsGXPU8kuEg 6jBgOZaZMk9nYMiG9TBOmsxrRAlxJsUPMpomyfygC3tRPMBL/5xwFRw4U0B4270eWMIU njY7g96JoS4vg6xcRsZkW8lojnEYrdncAAcdec+eJDK2/Cjz8yN6kLZ18UBC5mOI7GEK ecZqTq3RJwtTLZEKlS4Eim0nxQ7UG9p+YMuqzdtv336pSyv7sJh3SAMDVx0G4BFABqu9 HZ9w== X-Gm-Message-State: AOAM530QV1wq5g3gLAzWtcoZvdrp/HAkbVMiAtGglybrKxwNSbZpjtK/ d+XyYOCofxygSUBti1i+cRo= X-Google-Smtp-Source: ABdhPJw4LqXUE8gN9sxTapAIkTdycuLxwZ76mbSxjykZFUkYLwBo/EXmdFcN/nHgEsXCRoWOP6dDhw== X-Received: by 2002:a05:6402:46:: with SMTP id f6mr40222341edu.252.1615962430232; Tue, 16 Mar 2021 23:27:10 -0700 (PDT) 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 d1sm10751349eje.26.2021.03.16.23.27.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:27:09 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v5 05/12] hw/net: e1000: Remove the logic of padding short frames in the receive path Date: Wed, 17 Mar 2021 14:26:31 +0800 Message-Id: <20210317062638.72626-6-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210317062638.72626-1-bmeng.cn@gmail.com> References: <20210317062638.72626-1-bmeng.cn@gmail.com> 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" 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 4f75b44cfc..4587b28176 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -886,7 +886,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; @@ -902,15 +901,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 17 06:26:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1454471 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=rsjCm1p4; 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 4F0gRw004Wz9sVm for ; Wed, 17 Mar 2021 17:36:59 +1100 (AEDT) Received: from localhost ([::1]:43906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMPnc-0002Vn-Qk for incoming@patchwork.ozlabs.org; Wed, 17 Mar 2021 02:36:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMPeN-0003rr-DT for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:28 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:45210) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMPeG-0000Au-2A for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:18 -0400 Received: by mail-ej1-x633.google.com with SMTP id mm21so704909ejb.12 for ; Tue, 16 Mar 2021 23:27:15 -0700 (PDT) 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=fYxXpZBSx/3UmjTv+pgNgyANPy1MdJ+W91DIofp+gdA=; b=rsjCm1p4oSaT/NrcdRais0wAaXOi8NWgu60uAYdQ7nDkABJvdk6iuSDHW6ordlQDtD QnEilhSqaQOmnEor0V6fGtDc4h3I1qdpbhwDPIVx+w9u7oWidG8S2lffYFXxmwxAbkwM eN0pFPXYuvGIMgXi3AytMThpamVAHHLIJ/eWLPDv6ZcO+/MPKQhGWkP5qE411dZwLvWa 1PlggwZ4tGzB0Ci4e1qKBObf9o9HoEuss9Gur0ut5rCmjanQZMoS1xcoes9RLWHqHGun 7Ly0iucbMmoSnHRGpjQyAXjSr7klNZHzBJRS3SUOWRYpUmtzD4zidZrnZmMR1vEJ0258 Dc+w== 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=fYxXpZBSx/3UmjTv+pgNgyANPy1MdJ+W91DIofp+gdA=; b=kqVyiIe+rFztFFgGbqWyLqlWIiHMm/ifGquZ0SuxWvUB4Qghq4yPQHvpvqNWEK+Z9W SNn/GpyTvMbAQi6Boti783P8jSuqCELzN+ap7ZIZYr4uPx6eQV3r6vjfBK6QjQwpYEwx UBl6e4uAT5G+G5tZCJOQFvP2UoJsMfPL3G/hoNyqzYr2452AI9FXsvHj4Jhn5LZLDcTv rn+MmghmS6xKObwuZ5W21RmhYBfiu2u1qRRQMBbiO47T7Y+eSHCC7E6bT1iQNWKFKvs1 hwrIEm53XwH/0S61zcEgvQxvzkkSvdZlxCYMaIc3KENCXnDFOKWJXNTnz/0O7RIR0mFI /bnQ== X-Gm-Message-State: AOAM532FHvGqD9kqtPyvjbqx9YvhH+RrLVPXDzJz1njRwfmrUwb3cmBR of8AsPF14qfyOdXceucsd9BuUPEglOc= X-Google-Smtp-Source: ABdhPJyP5r9iC9iQZaJn62Cuj7ymKoimIrhsOHc9hIaOOGojXGBMvyJC/YDYFt4q38T9whQGkwiJ7Q== X-Received: by 2002:a17:906:4a50:: with SMTP id a16mr34271487ejv.256.1615962434210; Tue, 16 Mar 2021 23:27:14 -0700 (PDT) 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 d1sm10751349eje.26.2021.03.16.23.27.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:27:13 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v5 06/12] hw/net: vmxnet3: Remove the logic of padding short frames in the receive path Date: Wed, 17 Mar 2021 14:26:32 +0800 Message-Id: <20210317062638.72626-7-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210317062638.72626-1-bmeng.cn@gmail.com> References: <20210317062638.72626-1-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: , 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 --- (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 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 17 06:26:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1454451 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=WZ5d4RZn; 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 4F0gL55zQzz9sVm for ; Wed, 17 Mar 2021 17:31:57 +1100 (AEDT) Received: from localhost ([::1]:34680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMPil-0006xv-O9 for incoming@patchwork.ozlabs.org; Wed, 17 Mar 2021 02:31:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMPeU-0003y3-Fk for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:30 -0400 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]:42345) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMPeL-0000Cj-Ie for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:30 -0400 Received: by mail-ej1-x62e.google.com with SMTP id c10so719638ejx.9 for ; Tue, 16 Mar 2021 23:27:18 -0700 (PDT) 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=6g2fqKS4zXXBGv4/b0aMoziWaN2OpwusnZLdMFaob9Y=; b=WZ5d4RZnhj/I+wE6HFgD0GoX9myoCnPGqSBF7xXwAAL8VOFeCd/Rn2ZE7WWAA8EiBj 3RqbZcp9Xb33WykZ0ENfjLVBfLi8so33J9FmpgvzWdwL97UhGvBT4RRLHOJv8OnXG95m u7Ah/NDyCZ2/wwtgRatYaFs3AbPtYRSj7us3M/fYyG//uGzh96cnI+OtPm4f6NPpGYSV RPhLkR6paPn7Ol0/A0QZsrdYrcjmj5cUhS3yXMZDhVXwAJmHsPfB6ZmFxoWIeABuhLO/ GR1X6mOG529xkFxUIkXKpDi2wKtZxD4tQ45LekhLxOwHM/mOzW0oHX6aw7wHnjxGOl6T VO9w== 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=6g2fqKS4zXXBGv4/b0aMoziWaN2OpwusnZLdMFaob9Y=; b=rJ4ZEYGCvB//cIop9QOkyWuan9+lXkgVPv+Cts5TuWh6ww+v1yeOfB25H+x5vlg0AP uHjxTFmNR+2a1r6uQjgLIf/RLDzVkGbVRAUB/fjngCZFgn1650cDkB1JfyE/l79W1Y7p cW5Ke7+YQyWWE20GY4lDcUyD4RnX9VMHJv4dFAEoH1W0psGuaxGFYmt5eQ6Axzf3GuZj 6V2xX8JUAMIxLCw/RBpvlmqJGX/abKiDbbXKtACKUv0BtxKJAGtbTALPX/QnpyWSjV5e tnjy0vfOQ3GxqdjuBR9vG0vd2o+ATA0tRr3b7IhjrscEC8igDpdlRn88FudJw5oAW2bk DecA== X-Gm-Message-State: AOAM5335lD04ALlUQd6yWha98v9ZALrT9W4M1oM1mqS53s46dpNnMi+I 8MCe1u4Cw27g03Ws/wKFfk8= X-Google-Smtp-Source: ABdhPJzN08UjEbB07QRi38GGBJczNjZX0joiYMKgpx8mkAVnl51CTWUIwwJiHfYll+9XE1ffJEz4KQ== X-Received: by 2002:a17:906:9be1:: with SMTP id de33mr34946540ejc.320.1615962437901; Tue, 16 Mar 2021 23:27:17 -0700 (PDT) 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 d1sm10751349eje.26.2021.03.16.23.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:27:17 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v5 07/12] hw/net: i82596: Remove the logic of padding short frames in the receive path Date: Wed, 17 Mar 2021 14:26:33 +0800 Message-Id: <20210317062638.72626-8-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210317062638.72626-1-bmeng.cn@gmail.com> References: <20210317062638.72626-1-bmeng.cn@gmail.com> 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: , 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 --- (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 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 17 06:26:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1454472 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=ceg7KbNK; 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 4F0gVy223wz9sWH for ; Wed, 17 Mar 2021 17:39:37 +1100 (AEDT) Received: from localhost ([::1]:50204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMPq9-00057r-I8 for incoming@patchwork.ozlabs.org; Wed, 17 Mar 2021 02:39:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMPeT-0003vq-No for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:29 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:46406) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMPeN-0000DY-5d for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:29 -0400 Received: by mail-ej1-x633.google.com with SMTP id r17so698036ejy.13 for ; Tue, 16 Mar 2021 23:27:22 -0700 (PDT) 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=+3JML/eQ0iQLfY9F7pZALIkT5ONsUMtEeW41N50tDXU=; b=ceg7KbNKVjy5VmNRidLWYXeJcfy08eSsvLrRNfk7mQkMEwhPUhgHt2+jKEgJukdcVZ WlBOkwrgOiqz1KjpUmdO0yhDtr36dRZdmrg6+MrVtAD8x7mNsuW1gosxEZAydXzJ3Ja/ dL4AoL3hpN+9CeU5AFJqcz1VM3Rv77Zye+ENXtRprlZ8kc4gRvKmKaGoehJ2rR6M3A9i oCyiay/zhVe4cSAWNwWKACZv1WgRzbg5WFrSVqPi77t41Wh9sC8H6sh3K40RNex7rVgf Qi/XcvgYjNoEyhtf/dgOHkUKWsEde4cBy+psyI/qylxpBP5jnh5TnG5QGSJJZ1OUzD23 0NCQ== 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=+3JML/eQ0iQLfY9F7pZALIkT5ONsUMtEeW41N50tDXU=; b=WOP5GF8Tdxu8swAqXHxIpT72IcdxRNbA7ChosdvdnSRwPUSO5psZlUjchY1inowWex HpX/FH16jNkKUiGdGhM+gjqE3GHSVGhid/4cPRYsyfvospYgoAOOV8bIV+LK1KQ10/h/ 7CTfBaYuWy1fq27vavCule9ffWXuT/sNulFf5ytz4ObgZC5GISLO2ZQlC1syZ5FZIdvr HYfRoEMqcPPJPW2LreLdg+l3SINUZL6SE2HSdzxKZ4BH4SfW+LMQv47WZC6faCtQpU4X 2ohltPVFh0nt4OnGrRZVKtLcfDXE8jGCv1O6rYwG9SWhUuID4F28Jic+m6mh1MhwZr37 2+fg== X-Gm-Message-State: AOAM531AhZOdFRwFNDxxFiOKTtPGhWnlIY1va7gFOAgLEITEBQI/YOh8 OX+4rTYBxYHV+B7yJS0bdPs= X-Google-Smtp-Source: ABdhPJxel28YzKErqIDhuYYBKjfZqtna3Iflef8TMnycOGyiJkmSQllOASsDWx6OCJitTbgkg3JcdA== X-Received: by 2002:a17:906:c9c2:: with SMTP id hk2mr33908679ejb.244.1615962441781; Tue, 16 Mar 2021 23:27:21 -0700 (PDT) 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 d1sm10751349eje.26.2021.03.16.23.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:27:21 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v5 08/12] hw/net: ne2000: Remove the logic of padding short frames in the receive path Date: Wed, 17 Mar 2021 14:26:34 +0800 Message-Id: <20210317062638.72626-9-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210317062638.72626-1-bmeng.cn@gmail.com> References: <20210317062638.72626-1-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: , 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 --- (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 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 17 06:26:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1454474 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=JGTucIWK; 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 4F0gZ95nNtz9sWH for ; Wed, 17 Mar 2021 17:42:25 +1100 (AEDT) Received: from localhost ([::1]:55754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMPst-0007Uu-IM for incoming@patchwork.ozlabs.org; Wed, 17 Mar 2021 02:42:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMPeV-0003zv-5T for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:31 -0400 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]:44262) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMPeS-0000EZ-Bu for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:30 -0400 Received: by mail-ej1-x629.google.com with SMTP id ox4so706070ejb.11 for ; Tue, 16 Mar 2021 23:27:27 -0700 (PDT) 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=PP+55yH3XMS6A6pGNsy7hHqHBcvps0qODKJPfFXkSco=; b=JGTucIWKcwIoshy+XYmN2uP3+gnf8Cg3z5xPbYIzl3oUY+hjxDNVL/FIzqMAvaAq9l TUlcYr+Q71Ht6zRqzXleklOQ6rjqXSGQQ6qeD7LughOR2DMn37oyYBg54kTZe6PIl1nu 1qupzaKJEmflvR6JrknJaNRP0MCUWv5B5Ea5HgF6fMapXw3gTgHE2K3Wzn7HXRUG+gpH suAua6qUzVd5Rk9+P4by/fWIaBG0XvM75RbYdY7eDWhz2dy4Z5rOgPDizJG7n1CQXJXv xZV6+80Twu3Qd48PuUvrFHCy+iFmaG5OLoE4bd0QXMdAfgt7Xfob/GMUobe422+Cw6mY DVfQ== 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=PP+55yH3XMS6A6pGNsy7hHqHBcvps0qODKJPfFXkSco=; b=nDc8vD157iOAzHqvLj2wbvi3AlrajQhlG3BaspNpUzWhxcD7EDbccN+pv8GdMatZ2V CmmbapYh1d/ExnGNIsQ38rlkvFH2YhuoNhp9HSptH5zjgxvknDbY5ve31kbaim0XdyRn HwTeZ3xDGccC+pSuZUNtDBY3D/o0BxBMqTTdQF/i5D4xeCyRRFvWRcAHzo2mfwQKKdiq Yyx2lTWfS2/5LBld51YdeI7GGIbqBL/X2V9HkMXZ/ie1zKmtsfvVv7CckdzJzH/z86UN bPC2+MHvPUosJsjY6hoV/WPIOGATzjKsmeMXkDxA9ZPcqN/SBLthZM9+6zvcQKbW7nMy Az3Q== X-Gm-Message-State: AOAM532Gd8sQj6v83FcbacIVgxsdcPWEQvYUxgRralI0fFY9FKDq8KNr ehJ7Ki77sHizighg99YQwLW+dGDrpvM= X-Google-Smtp-Source: ABdhPJwNLHghG2wD2exe1a9x1ey0ES6NdxlbA5Mwr2Vr4w6RApfM+yzASllRrOPuhfmtmNbVj1pOyg== X-Received: by 2002:a17:906:eb4e:: with SMTP id mc14mr32842800ejb.169.1615962446330; Tue, 16 Mar 2021 23:27:26 -0700 (PDT) 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 d1sm10751349eje.26.2021.03.16.23.27.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:27:25 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v5 09/12] hw/net: pcnet: Remove the logic of padding short frames in the receive path Date: Wed, 17 Mar 2021 14:26:35 +0800 Message-Id: <20210317062638.72626-10-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210317062638.72626-1-bmeng.cn@gmail.com> References: <20210317062638.72626-1-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::629; envelope-from=bmeng.cn@gmail.com; helo=mail-ej1-x629.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 --- (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 dcd3fc4948..044528385e 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 17 06:26:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1454475 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=KXl2g7x6; 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 4F0gbw0nhhz9sVm for ; Wed, 17 Mar 2021 17:43:56 +1100 (AEDT) Received: from localhost ([::1]:60010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMPuM-0000pc-5O for incoming@patchwork.ozlabs.org; Wed, 17 Mar 2021 02:43:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMPeX-00044q-58 for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:33 -0400 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]:47032) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMPeV-0000Gv-JG for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:32 -0400 Received: by mail-ed1-x534.google.com with SMTP id h10so818198edt.13 for ; Tue, 16 Mar 2021 23:27:31 -0700 (PDT) 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=SddBPwredzwocA1Fr7ONOu1Dbgzb8rE0mV84rYBDhV4=; b=KXl2g7x6sC788HqUCgPRLDVL3Wd95qQsejF1ivAaA6t6Qb+vlnbPbDddmKZtHDjzuJ at/v2DnTTdwxMuZrPJ4IQvtHFWWtCjl6lzRNx67fy+F1RtheVaus3+kU7mvaPDJ6/u5Y L3wJpYag66RyAqWcKBsbzBiW0cpQUDxGrn5fInKPDUhUzJqo5iNTcCZxtX5uOx13l+gJ MJjSEXmLdDZsbBoMy/HAak3aMecfa+VFYyDBOVZZuQrBPo4lxRWMI2lmtiHEe8GmpHzY nzRFC9OZ7Rr3iOCDEv4CKYYiiumDRT8hwYxRuva0nfM1LW45fpQcOx2IAEq90cgyKQ9R iSwA== 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=SddBPwredzwocA1Fr7ONOu1Dbgzb8rE0mV84rYBDhV4=; b=oNfRq3ceezVNeaTnJbSgHS7wHcm6v2WGiNzGxmbO+BRUa1/NVmegAagPAwDptx/S1p j+5hzwiRyOjbanRCX8IDIyTr7nECNoDPjdQnPlp4RYBk8s1jJ6Up15CKC3Zx0Fs2q+lJ 7lFGnBeoD4yJyK1L2slmBNM8D9xKFUSj5S4J0dYXm/i50FRA+fD2JBuNL+5a7HMjo4Yl zdtPGg/FpsKWrdHPZXFrGqu3wTM3qShJvz+HsrBLrk2tgIjzdmHgfZZif6TVmgOefBJJ wEiasG1yoHvznYseC7ZVihOKOlrVnKnIWAUM3G0IGccp5KiaeuECKuYV97olyucRJwK8 I2Hw== X-Gm-Message-State: AOAM530jARObLOPpArh2/xU/tti7QdZ9xF8HZoL6IBt8eTbQTOOJwK94 GMaEbZilgZkbSOUt01OodmU= X-Google-Smtp-Source: ABdhPJxuTpDYyUIghQV1glaANvX3stuJQCatSLkKHYA4BHtkNQZtG6Gaatecj82rJEpiaS8yFsfG1A== X-Received: by 2002:a05:6402:408:: with SMTP id q8mr39352872edv.201.1615962450321; Tue, 16 Mar 2021 23:27:30 -0700 (PDT) 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 d1sm10751349eje.26.2021.03.16.23.27.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:27:29 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v5 10/12] hw/net: rtl8139: Remove the logic of padding short frames in the receive path Date: Wed, 17 Mar 2021 14:26:36 +0800 Message-Id: <20210317062638.72626-11-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210317062638.72626-1-bmeng.cn@gmail.com> References: <20210317062638.72626-1-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=bmeng.cn@gmail.com; helo=mail-ed1-x534.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 --- (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 90b4fc63ce..ae4c756924 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 17 06:26:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1454452 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=rw8u3H88; 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 4F0gL72rlYz9sVm for ; Wed, 17 Mar 2021 17:31:59 +1100 (AEDT) Received: from localhost ([::1]:34828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMPin-000724-DE for incoming@patchwork.ozlabs.org; Wed, 17 Mar 2021 02:31:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMPek-0004H3-My for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:48 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]:36023) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMPeZ-0000J6-3q for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:43 -0400 Received: by mail-ej1-x636.google.com with SMTP id e19so751285ejt.3 for ; Tue, 16 Mar 2021 23:27:34 -0700 (PDT) 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=LVIjQbumBhLPw9k7hJ7IdwoWD2eM32N030BAj0m1X34=; b=rw8u3H88A/aq/lkqMzcOYmmVI2JWG+gz4nmSwKsev0NiDSJVTG8+QcJpk3xZI6uLL1 /z0JELUcqlqHvtauNDt6ytLiATF3XnkG7DzLJFeZCCAo+Or79uiJaDctQyVsZq/Y43tu m5KtZBAfKR1zIPvLq0caHe/3jBTlZPfDr40AGNLYE/rDLYZgJxCvg1BTKyef483kaFZT HDh0Sgmb326jGnB5ym3NRSGptb2hSXmkztNAGOSEsVvbknUTHNaF+c/vC/mx5JKt+nzn cpV7IUVRuvxXLbUXSTgBLluaifK43U6HB+BAjkVRe/GPA+Ge19on4OPfbl9eddJGHZlh QdfA== 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=LVIjQbumBhLPw9k7hJ7IdwoWD2eM32N030BAj0m1X34=; b=ZqYHTVpSV+u2yjuJC01SNfC587l1kZZFRSxa7G0UTIYJxjm11omktKtmg9uxw6dBWt IwhDyrpB2CffD1WukE5SZW1QBgizNAuqHcngcffbJakGtpGf56kmjCjs+ug7AfhFalhO A9HoeCM6o3brdljNPDR7frAcRMaD/hepCFDa+rNgDQIupxKJz30nn0vYy7Cz+IgoMkTb hHgFuYi6DP/tnMBI3I0xhmWzAJir63tBTTXxb3gwx+GmGC7IerjvWIawKAtikNHcdUCc erTgQQTfNEU1qtEowrMD4V33DxRPnhPctRw2mgVaxYnu9EdpVwATdM80EVn18tmUclH9 8FdQ== X-Gm-Message-State: AOAM531IyEmkN8UP3+AbXz6ElVrjFRBz35gaPm5RQM/LFocBd6NDEDoE eXFDW8jMgz8eFLSyeVswSqI= X-Google-Smtp-Source: ABdhPJw/dy2JxSNH6BFKaRywynV3Dx7x2Voh7TiGpBGNTBQNs705nuoZjWYf1J9PHkGWymuEXbVxWA== X-Received: by 2002:a17:906:314f:: with SMTP id e15mr33154300eje.30.1615962453873; Tue, 16 Mar 2021 23:27:33 -0700 (PDT) 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 d1sm10751349eje.26.2021.03.16.23.27.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:27:33 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v5 11/12] hw/net: sungem: Remove the logic of padding short frames in the receive path Date: Wed, 17 Mar 2021 14:26:37 +0800 Message-Id: <20210317062638.72626-12-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210317062638.72626-1-bmeng.cn@gmail.com> References: <20210317062638.72626-1-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=bmeng.cn@gmail.com; helo=mail-ej1-x636.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=unavailable 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 --- (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 3684a4d733..cb3593153c 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 17 06:26: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: 1454470 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=EmRku6Gu; 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 4F0gRY6TxBz9sWH for ; Wed, 17 Mar 2021 17:36:41 +1100 (AEDT) Received: from localhost ([::1]:43178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMPnL-0002A8-V0 for incoming@patchwork.ozlabs.org; Wed, 17 Mar 2021 02:36:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMPem-0004JR-KH for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:48 -0400 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:42751) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMPed-0000KQ-1M for qemu-devel@nongnu.org; Wed, 17 Mar 2021 02:27:46 -0400 Received: by mail-ed1-x52f.google.com with SMTP id u4so834421edv.9 for ; Tue, 16 Mar 2021 23:27:38 -0700 (PDT) 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=UoAb4yJF98pSKNLLX7tPArXkVMkWUA3vT/8Fn5PTXcw=; b=EmRku6GuMCYMjwqM3UBQ7pwnPj6RNkEM0F7IendWpsUbBWiV9FQXFHFlXQ6o6639Iu G67rOS17wnh3dWcmqMg36glpgnU8yXrow1KhxuK/mkbtfjPyiBuZsJRCajPlAWklBJzG gk2n3epOGfRZMbBNLO73w5904PPrtcU7x44VC2qoX65PZoDQvixR4WmMd5mUJ0Furq2L cvNPrbhxsQOZao4hTcpCebjIIzm33ehIR0A03dXmrFp26RQ/F3rLyE+ihsFBWbZSh0yo adyh+6/erOEQa7wlYflOTu5rDuvg1PB5v8EkdZfqjCeerLTrTc1B8bnPbQNswtkPCX5L C8dg== 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=UoAb4yJF98pSKNLLX7tPArXkVMkWUA3vT/8Fn5PTXcw=; b=N1HUM4MQdM79FAVusQPu0dXudg7Z1tHeanzWr0IzeRnxMJ+0Ktlx2McvTknd/AUY9s II7KiiIRw2nr30qKFnrcvcXmCaJxOwHFEnHRTHb+h9jhw3lIhzld4k5Oq+6ExGpiOj6k 4GXvXZSODPKcdhbzaNNh+ojx9xMePrPRW2+o98bKYRi+Kn6WvvegEFGmrWDSAQRFbivM NXCy4JFzqBGc0WqEcPit1EkKYue/wBn8GncD4dSG0lQUyV13hbqu4VrRD9hhDLEtNRd+ 19m7iR3I4BShAia+4Ldq5zsEVjinBht3g7l8VOdOkRZZrIjvibkZYnymWOLjfscFtey4 ktWA== X-Gm-Message-State: AOAM531KwBx88nkCgZuMk/vp3SbikZURO7CozdpLxTyUL9B8Ih4KBTtw xoFjkk8kRLsbhYfTeZHaoyUjWF3kCvc= X-Google-Smtp-Source: ABdhPJyeWpyJkJBwBgXmO2uWO7K1LsFzOL++vIdW9x60eos5FqOLXdojkCCMlaE/qKePd4rjQKWkyg== X-Received: by 2002:a05:6402:4415:: with SMTP id y21mr20835438eda.70.1615962457490; Tue, 16 Mar 2021 23:27:37 -0700 (PDT) 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 d1sm10751349eje.26.2021.03.16.23.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:27:37 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v5 12/12] hw/net: sunhme: Remove the logic of padding short frames in the receive path Date: Wed, 17 Mar 2021 14:26:38 +0800 Message-Id: <20210317062638.72626-13-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210317062638.72626-1-bmeng.cn@gmail.com> References: <20210317062638.72626-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52f; envelope-from=bmeng.cn@gmail.com; helo=mail-ed1-x52f.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 --- (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 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);