From patchwork Tue Mar 16 12:04:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1453846 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=aJmJvQvq; 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 4F0BnC0Y3pz9sRf for ; Tue, 16 Mar 2021 23:05:19 +1100 (AEDT) Received: from localhost ([::1]:39332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lM8Rp-0002OM-1t for incoming@patchwork.ozlabs.org; Tue, 16 Mar 2021 08:05:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8R8-0002NA-V3 for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:34 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:40180) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lM8R7-0003iO-5c for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:34 -0400 Received: by mail-pg1-x535.google.com with SMTP id n9so21490420pgi.7 for ; Tue, 16 Mar 2021 05:04:32 -0700 (PDT) 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=lZ8TOS5Tq+UzkmQqVTu7P3gHHIXPHi7LoHFpHXM9B6U=; b=aJmJvQvq3bO/DIYAZDw/0h7SB7Remz5sZfhjmO2t0oaHrHo14coOBF3mJCm05mn7UL BACY7osa2SkLUz7B2LYPl66XxnOIJvZnAcp/wLId2fZ1JvtdERIPZ+Z8Yc2VmO20krLA Mg3JkkgZ7CYwHQ3l6hCjzPa1BCRMgYGQr611b06TVhSfEpmzXGdBSCTcKlZsIyStImfY MuJc2mifm63rGMVCshcn6qrG9auDl1uWYauemAMNbRqX4H8EqrVdjympPcbqnHaaPrcR kwHQuEBFEVHBJ30WuC9gGAkwwSPbxqn0TGA9oSLtwSnlZsJXXvvftXm9+5M3nTdtb4Jl qiqw== 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=lZ8TOS5Tq+UzkmQqVTu7P3gHHIXPHi7LoHFpHXM9B6U=; b=QYbIf9M6Fp5GKpckbIUg2NHP2X//bu0StcE3rlm1yAMY9Rz8kfCHW8t7gj7/Nknfm3 uX9VT7AwOYjwRM98dyN5M9m+HFZotxMukLLgPS/51sn6aEBuHEUp2PoEc+0gHVfTi0sF BTBd5dCuhFeBojQ9cG+KrT5hx+VxkagXDACFNH8E6pUgk3Tp98OygT0fnhmAbGDU+3wt fTiTyMrlaQ9VfzauctXVmQAx+yBFn+RBik5okhBpox7h+rZkuiuqEAAqs4RmNj92dzjI G+lzhtDzIq/x9UHtXJvTtKvqdg8FMvXZsVicNluXUzqkHrTdNCJ13G1XUNwDj2gSbi7X vNjQ== X-Gm-Message-State: AOAM531tihzHpsOYoZWIzQPns6oqJVxSO6pW5cYG6DAwGW9ujBVQGeqU aEcth6JhNoil5dnYRADj6c8= X-Google-Smtp-Source: ABdhPJznph3JEihJVDPqBHZ1sj7PnQvNYi6IBfpCUuDYDyVDsuYGMyWxzqggNCQqcD/Xm0SgbSBA4A== X-Received: by 2002:a63:d211:: with SMTP id a17mr3628848pgg.225.1615896271803; Tue, 16 Mar 2021 05:04:31 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d5sm2722166pjo.12.2021.03.16.05.04.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 05:04:31 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v4 01/12] net: eth: Add a helper to pad a short Ethernet frame Date: Tue, 16 Mar 2021 20:04:09 +0800 Message-Id: <20210316120420.19658-2-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316120420.19658-1-bmeng.cn@gmail.com> References: <20210316120420.19658-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x535.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" Add a helper to pad a short Ethernet frame to the minimum required length, which can be used by backend codes. Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé --- 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..6aabbdd0d3 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: buffer length of @padded_pkt. If the frame is padded, it is + * written to ETH_ZLEN, otherwise it remains unchanged. + * @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 Tue Mar 16 12:04:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1453848 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=SbE4Q2dP; 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 4F0BnN4ddMz9sSC for ; Tue, 16 Mar 2021 23:05:28 +1100 (AEDT) Received: from localhost ([::1]:39622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lM8Ry-0002WQ-NM for incoming@patchwork.ozlabs.org; Tue, 16 Mar 2021 08:05:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8RA-0002P9-RL for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:36 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:51947) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lM8R9-0003kS-DO for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:36 -0400 Received: by mail-pj1-x102e.google.com with SMTP id s21so10500908pjq.1 for ; Tue, 16 Mar 2021 05:04:35 -0700 (PDT) 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=SUVnzLTZo8cDNw3kuYw8/iZ4P4ckVc4s55CpMIGoa1Y=; b=SbE4Q2dPreAuICJdcIzakjPcGzitkj0JQE9qbty5+dLDcNWhH6EttxcleMtNCAWabK q9iHTVtUBhfwe5iHX5Z2n1Ed5Mwp9FlvooFK1fzLBWLDaxjGNTTIUzUTxu9FKdb/cseK Zb3gvG+9uGPqNQ19qN5MKVYAOgbuFMMjD7odYbirUykcroMbkB3S7/b4A44Z2vHTuSjv +GkTftDr5Q8No3jLwOMjeme4Zr5NFWU2zFYDBYHf9uU7Mi80PSmcK1yMg02McdUYWgjv O8iOzKqGjWqvjwEsfa2Yk2YxJI2bMzkxP1aOn1QgcIwpvktJzV7slEPQ+Uwsme7JbBPN b2SQ== 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=SUVnzLTZo8cDNw3kuYw8/iZ4P4ckVc4s55CpMIGoa1Y=; b=XkqPeI+vGbWgKNGMomGeN2u0KK6/cTL7OvHvAkAv7EOLFo9MeZkr/cG2lg5k74S5qA E+w/FIXpnimewhCrlmoASPv7bY9dnOw/lR+w1NgaWRYaXqlKTsuclg2Z6MeP72AqUL9h H/oZIrk46w4IdXL7DKBHhshnj9j737c5eYkywwRZMyeuZdqUMNE5pWWwLATTz1d8VH8P Du6R61YKCGUJeV8xypRdiLZShEmjnn6xZY99EccaRy22oG2S9toh86dnXS/+wYCLPLjD KKwVB+KvHn/ZHp4iP810lunZ7D+3immMCub83cWZtS1WkeE/QuV5z68bjArflzK8ThVC Xx9w== X-Gm-Message-State: AOAM53138wR2FgvqQcTVPTF25ZI2WIcXaiziEKsXRWThdYjjJyRgT2Gl RRdQr8dDjreh8TdfB2Qo924= X-Google-Smtp-Source: ABdhPJxf5gapI5aCBn0k4VmvhCZXpTG85dVk67lQwF7/nYZDp4GNDj66jGpkjFvLHneAohxqB60/ew== X-Received: by 2002:a17:902:8bcb:b029:e6:a4a1:9d7e with SMTP id r11-20020a1709028bcbb02900e6a4a19d7emr13258102plo.25.1615896274186; Tue, 16 Mar 2021 05:04:34 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d5sm2722166pjo.12.2021.03.16.05.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 05:04: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 v4 02/12] net: Add a 'do_not_pad" to NetClientState Date: Tue, 16 Mar 2021 20:04:10 +0800 Message-Id: <20210316120420.19658-3-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316120420.19658-1-bmeng.cn@gmail.com> References: <20210316120420.19658-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102e.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" 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 919facaad2..f944731c18 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -100,6 +100,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 Tue Mar 16 12:04:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1453850 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=RqS4QMgv; 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 4F0BrR27q5z9sRf for ; Tue, 16 Mar 2021 23:08:07 +1100 (AEDT) Received: from localhost ([::1]:47672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lM8UX-00062W-1G for incoming@patchwork.ozlabs.org; Tue, 16 Mar 2021 08:08:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8RD-0002Ue-O5 for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:39 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:45256) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lM8RB-0003lf-Q4 for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:39 -0400 Received: by mail-pg1-x532.google.com with SMTP id p21so22444747pgl.12 for ; Tue, 16 Mar 2021 05:04:37 -0700 (PDT) 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=/9LsfiXpwV9uYopdvb7Wgrlne4+iqiaA7iS+ccLjExg=; b=RqS4QMgv63Ez2V0FShuOBWpbuwxO6bMwPmNOHrVxiemCSoauGtSCYqg0Wlo26gkkhQ sHiyC2riBnr4N8otJUZqQlN0p/Tm61VoruChKhNT/fnDU1SH1TzhnukzO9xbtk45ewIc iPBsDCB85+hEatcDnE/42AEGEGJYL0H/QIbp2aPObogPGFPwkBIM1Apz8x2/CQAJd4Be x8B2a9wq3K97HH8Wy2I05PjZFMZl73waWUCPdq+tybjQTF+G5rSCUm2vTiRQk4Uu290L wg0xUkYpjpnX5mwJ00Qa4X7fchVj2YKOBmC1/rOIjv8c/5ApPExMsAaZo0S1mf2FdLzT x69w== 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=/9LsfiXpwV9uYopdvb7Wgrlne4+iqiaA7iS+ccLjExg=; b=Q+nKygPMenJB0gDU+JDg/cLdrkXijARWP20EvlOrjrGTterbAYDQBkfKkStRW+rT5q 25MpxzwGwZbOiux2jtx09mrt/7wxmJo5q7h9NBAwNO3zZ8ocm91TyYUlNC4u60OaNxhZ FZ/3rimnfM4y5w+bIXv82vjY2vQhfx2bmy1j2YZ7l6cAdbWplyQ6oXz8h+BpzuxFE+R8 4VKeRcinoZOHZal07DVs8rH+PjM4YGFkjonOJdjgvnSLjibxvohNu1iyE2ZaSQ8D3rP5 DCYtfdnxJz2uqvORYgeQuPtZQYS74/hII3Xhw+i6q5Yza1wArZ3sPXEtMLlzP3/a1EBd lQyg== X-Gm-Message-State: AOAM532sZFwiWKKA0NQILGvSayPAiklnKUpF1lIMqcwqQDq49wDJ5P5m fURFF9XoO4f8xEnzrxHDFLFsgdgjfl0= X-Google-Smtp-Source: ABdhPJygYPQAXOOZc2IiGw1BwUYCzhEbfdIxx1uY5CnjmR9rTnve2t81hNee3Dc77iAZ+cp6ulRG4w== X-Received: by 2002:aa7:8488:0:b029:1fc:f312:b24e with SMTP id u8-20020aa784880000b02901fcf312b24emr14437426pfn.55.1615896276548; Tue, 16 Mar 2021 05:04:36 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d5sm2722166pjo.12.2021.03.16.05.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 05:04:36 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v4 03/12] net: Pad short frames to minimum size before sending from SLiRP/TAP Date: Tue, 16 Mar 2021 20:04:11 +0800 Message-Id: <20210316120420.19658-4-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316120420.19658-1-bmeng.cn@gmail.com> References: <20210316120420.19658-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bin Meng 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é --- 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 be914c0be0..a01a0fccd3 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 2b5dcda36e..fb92b55768 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 b7512853f4..dd42ac6134 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 Tue Mar 16 12:04:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1453851 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=ac0CWFwr; 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 4F0BrR4xm4z9sSC for ; Tue, 16 Mar 2021 23:08:07 +1100 (AEDT) Received: from localhost ([::1]:47800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lM8UX-00065Y-MR for incoming@patchwork.ozlabs.org; Tue, 16 Mar 2021 08:08:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8RG-0002Zb-7p for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:42 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:44179) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lM8RE-0003mo-Ft for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:41 -0400 Received: by mail-pf1-x42e.google.com with SMTP id o3so4002880pfh.11 for ; Tue, 16 Mar 2021 05:04:40 -0700 (PDT) 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=KAEqWNhqz0EAtqpGifC8nwC4RjGAER1nHSghOCdWhgs=; b=ac0CWFwrvqDpgsIpyhHZkpv0gCcfi2un1++FMfYqKR/OB9EbD9Ew2PfLJ4c1Yzjmj6 14gEHviCG9XSUSb/xqMFZkPac7yzoAReKxWbr2jOeK36zMsMIYSOx/B+HdQdeYhN0/eq ldhCWlIcqhN+BXgz0CofVKiDge+eXWEm/iLWDClM4zKHMyoX2LQaIGlDhbjVT+hJfR/d oC/5ueZEi+SC/aK/ASJj0b/y+LiNEQ+dJj/w7IJyLyaAIKas8Fj/dvmnoKm+DC0nKdTV dpiKHoJOJRpKtSA0t6ZSh9yz+F0UHBjv4tB1Iz64ltY3L0qiihItglL5WyfBBuhJ2rWS R1yg== 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=KAEqWNhqz0EAtqpGifC8nwC4RjGAER1nHSghOCdWhgs=; b=DP454WgLjdq8Zewel5PeUIk+7Hvdexflh3jkl+ah5ZZBdSeBwt98p9yGWwZ99PfYRa poH/KzOkKomm1Bs4nuribdsJUFApH6gz6Xe8UHfptXfR2xKgaD/ALLXuw311K0FLXaXK NPo6Fpa5e0EndzmKwIEIinLX0R4ixIie4ByHlwGLyDujZyDhWDliPipSOHpzfPDtYSkm q464gV+t8gV76702WCWvdAPzrzUkn3129RNrBJizT+BYvO1gnVCFXsCzN6Bbnfqo1P5R CMJWOHX85jifZYm54PfZEBNiPtmj31MbtBaHHhRAIVsXPfhAufgz0EQGNBnZomXCHyAA J4vQ== X-Gm-Message-State: AOAM530ANhCSYzGsLz5PKA+9QH61B06Krg9vgfmK5VCbylclAJT+stop 5/4swqqSJlrU5mJhBqkKiCM= X-Google-Smtp-Source: ABdhPJw8C+ikbQKcrsHAGu0aet6pzFoAGPeDqRXSpzhya5drhdVp5xSnM2VFDwgL2jFRAiFE//p5qA== X-Received: by 2002:aa7:9154:0:b029:1ee:fa0d:24dd with SMTP id 20-20020aa791540000b02901eefa0d24ddmr14731261pfi.17.1615896279233; Tue, 16 Mar 2021 05:04:39 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d5sm2722166pjo.12.2021.03.16.05.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 05:04:38 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v4 04/12] hw/net: virtio-net: Initialize nc->do_not_pad to true Date: Tue, 16 Mar 2021 20:04:12 +0800 Message-Id: <20210316120420.19658-5-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316120420.19658-1-bmeng.cn@gmail.com> References: <20210316120420.19658-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x42e.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" 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 Tue Mar 16 12:04:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1453852 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=sCB5aGXf; 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 4F0BwH35DFz9sSC for ; Tue, 16 Mar 2021 23:11:27 +1100 (AEDT) Received: from localhost ([::1]:53700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lM8Xl-0000BY-Aa for incoming@patchwork.ozlabs.org; Tue, 16 Mar 2021 08:11:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8RK-0002iV-9r for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:46 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]:54114) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lM8RH-0003oY-Dn for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:45 -0400 Received: by mail-pj1-x102f.google.com with SMTP id t18so10497670pjs.3 for ; Tue, 16 Mar 2021 05:04:42 -0700 (PDT) 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=eObphcBqxSpSO7OGp8OS0zOxW+vIFNobRqmgIn159yQ=; b=sCB5aGXfbD5aFoRL14sT9xxBXGXbF2Mlr1Rn4WpYRvCevct99oGLnnILrDoiWbBq25 cFKWrwOLJgoc8Hjd4oClqrlKxyMMmoJ2BJl7ed+88zdRHjgohglj12+/9+O0xy2S45aH uHyLuXxPnNZg/RtVAzA/R7TyQGEaozJLBTlOWN87KNYP1ZJI57FBSuabdWTmOLWfIvTq 2OgAtb1xzIOcV/WANYfD8R6npFPbuQDwJKFjw2mYBTosWZ5vTlA1Omkv9H0CQ0SlDah8 cIr/OBcNdfPUVT21OAmNhlv+K+ETJnfMBn/r6ZLqfHK9UwD5GUtcRKMjCtPznueTOXyI joGA== 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=eObphcBqxSpSO7OGp8OS0zOxW+vIFNobRqmgIn159yQ=; b=YteNunRJ5292RgVUDckZUsHZQbQ91dPWE26orumhwEdtMWJkUoXH2Oc8OWTZPvq64O Xn5CEEch0ksbXW6tilLMh742fNc6ojhtFLNHgpksmg5P06R9+i1M4wtv07crBl4oy+pk q01snxLoZrx1GPOlNvAXoLT0lM3G+xx3NiEu3hCM6G06LGRLaazupTSwgak8Qwez8Lj+ pUJrCS/DNl+I3cKvbgqYhY3WzBDxdpGQ40iJfK+t5DkewyqCDXTV3kr34Dmnuc7ss01O PYiQjJ8aLgwQO1oAAehFS9LW7YlIQvSVy1l4iOl2iQf9ytlCjLGi6W9SjDxCMz0ScHFn A7DQ== X-Gm-Message-State: AOAM533ZcUnoRefa2L6s1pu8w0Q3uYPNLuRVd4mRHX/EISv+WIVU8Qmn Tz29gP0FCMJTnuBiVGhZ0WU= X-Google-Smtp-Source: ABdhPJxcjl1f1BalyOCrmCGnR9ajVvXNnvihqhY+IZLn8HZQYHaHZ3Gk1jEhrxK5Oeb4DSzb31REWQ== X-Received: by 2002:a17:903:31ca:b029:e6:65f:ca87 with SMTP id v10-20020a17090331cab02900e6065fca87mr16130402ple.85.1615896281725; Tue, 16 Mar 2021 05:04:41 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d5sm2722166pjo.12.2021.03.16.05.04.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 05:04:41 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v4 05/12] hw/net: e1000: Remove the logic of padding short frames in the receive path Date: Tue, 16 Mar 2021 20:04:13 +0800 Message-Id: <20210316120420.19658-6-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316120420.19658-1-bmeng.cn@gmail.com> References: <20210316120420.19658-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102f.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" 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 d8da2f6528..a53ba9052b 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -882,7 +882,6 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt) uint16_t vlan_special = 0; uint8_t vlan_status = 0; uint8_t min_buf[MIN_BUF_SIZE]; - struct iovec min_iov; uint8_t *filter_buf = iov->iov_base; size_t size = iov_size(iov, iovcnt); size_t iov_ofs = 0; @@ -898,15 +897,7 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt) return 0; } - /* Pad to minimum Ethernet frame length */ - if (size < sizeof(min_buf)) { - iov_to_buf(iov, iovcnt, 0, min_buf, size); - memset(&min_buf[size], 0, sizeof(min_buf) - size); - min_iov.iov_base = filter_buf = min_buf; - min_iov.iov_len = size = sizeof(min_buf); - iovcnt = 1; - iov = &min_iov; - } else if (iov->iov_len < MAXIMUM_ETHERNET_HDR_LEN) { + if (iov->iov_len < MAXIMUM_ETHERNET_HDR_LEN) { /* This is very unlikely, but may happen. */ iov_to_buf(iov, iovcnt, 0, min_buf, MAXIMUM_ETHERNET_HDR_LEN); filter_buf = min_buf; From patchwork Tue Mar 16 12:04:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1453854 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=TLD4FyGJ; 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 4F0ByT1fvWz9sRf for ; Tue, 16 Mar 2021 23:13:21 +1100 (AEDT) Received: from localhost ([::1]:58056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lM8Zb-00029O-9F for incoming@patchwork.ozlabs.org; Tue, 16 Mar 2021 08:13:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8RL-0002mb-S5 for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:47 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:42637) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lM8RJ-0003pJ-G2 for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:47 -0400 Received: by mail-pj1-x102a.google.com with SMTP id j6-20020a17090adc86b02900cbfe6f2c96so1318915pjv.1 for ; Tue, 16 Mar 2021 05:04:45 -0700 (PDT) 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=eDY5/g/gC6eo84W4qmxfF87Ec8RE7ffVUvzKqUw02Ic=; b=TLD4FyGJIdh2bByTMMpkDrKZ172HjyBixggGwtjgBVj6QtWtyNx7tPX44+gvumkveZ NuBxy5r/UPZ0bL8mJal1bGrZE8y8ZIcrhCwBtx1pPqd9oFhLwFxrys8/KBU3f4ZtrmnH X075SO4UeoQH2RggNZdf9dsNg0/AqLydqgRIa9GQTMDBxzHly6zQyxkELknrl1gAODfl HxJDdqVzuxKT/3LAj1vtc1MTtZGp07F/1wDaT0ph6JcFhEgMQBKSPMVP0SgqBD8BZZPV 4oWe0PQkNT9LoXaAsfW3sTU6TaOimR6NzmxG+ujrqBAFHpwzN4C2RKJaXm6t8VVMk4SW 2yog== 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=eDY5/g/gC6eo84W4qmxfF87Ec8RE7ffVUvzKqUw02Ic=; b=a+GJgiOuO5yGNGpDEoCe0FQzKn4bYOiIVs8THXUA21woFlKlvBEUzwWevjcKgNcnjW v4GS/b4cTt9IMFR6kF5myLtvnfNn6OIAhZDnShi0Tpc42hR5QP8btS5McqDFx/h3vrG7 +JUkNWgT5waXRMtv44Yc+KDRzx1NLrUOY0ORWMykd10o5QqE9AX1NEW4/uaPUWouxUVX YlYEY/JrLblWTHJbI034XSoOyt6DwNwI+4ooW91aOekEPX/ECsbcXMeXwtMlQ+pOb04f Q9aXMm5Kn9JkWsJdGoGU70OBBHFVzVyX1mZwxLLkBVtUDds+T9Ek7N/WBQG45zRvSBty RZhg== X-Gm-Message-State: AOAM530fc78beXlMtVTQ47TYpMdVhRLjwtZsuuff+Qx/J3is5FnY1ZMM KQmeLID+GGQWaRnYaLRKMAI= X-Google-Smtp-Source: ABdhPJzXmg1iGsqaPcb31KYM6j8ltb4o6SuIkOt1ikLMQiNs4/sOpgUf5x1YYKCxOyPPsZhwYO66NA== X-Received: by 2002:a17:90b:33c7:: with SMTP id lk7mr4565744pjb.95.1615896284094; Tue, 16 Mar 2021 05:04:44 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d5sm2722166pjo.12.2021.03.16.05.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 05:04:43 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v4 06/12] hw/net: vmxnet3: Remove the logic of padding short frames in the receive path Date: Tue, 16 Mar 2021 20:04:14 +0800 Message-Id: <20210316120420.19658-7-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316120420.19658-1-bmeng.cn@gmail.com> References: <20210316120420.19658-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102a.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" 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 Tue Mar 16 12:04:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1453849 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=YmK32doG; 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 4F0BpK6Rflz9sWF for ; Tue, 16 Mar 2021 23:06:17 +1100 (AEDT) Received: from localhost ([::1]:42222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lM8Sl-0003hM-SK for incoming@patchwork.ozlabs.org; Tue, 16 Mar 2021 08:06:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8RN-0002qS-QV for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:49 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:36373) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lM8RL-0003qg-Pd for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:49 -0400 Received: by mail-pj1-x1034.google.com with SMTP id f2-20020a17090a4a82b02900c67bf8dc69so1252740pjh.1 for ; Tue, 16 Mar 2021 05:04:47 -0700 (PDT) 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=svdZ6C5bAvGavGpnuoz2cwWAJZeGvVoFj9lKmaXb4lg=; b=YmK32doGj6Hghj/2bx7qiTnY1OIx4WeNmsEwX/ydnjxuGgPjWgdx2aa1ni/V/nrTlo MsIb1b9ZdPPDxxFt6xQrQArEeu1Fd9T+yQmNXCUAaBvUmZemrZdyFqHil/BcGg1mzBmz wSxXh0rJnS2A/Glkq50NNkX8Ff4Am4Sk4EWk8/5Q1owkVfgfG3zbMT9AEJHXT4kTAon8 VZ7N2ndIj2s6G1f26IzN6uL4KMLr4yqfrFV31MA8g6BiqacYr9oXVloBuCFaDK2wQbPl cojfRoqjXZu7lcbFxBMkWdYNSF9p53Ozf9T+3cOpAgvZjG7vZ2go0+1Vo0ZZZOLZ3hNd fVsQ== 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=svdZ6C5bAvGavGpnuoz2cwWAJZeGvVoFj9lKmaXb4lg=; b=ZF/NDuti6S8Shg1xR5dX84NJvovPsVcXYTdXIds4kX1BWA31teIyH9nLyGWtoBlh+i 6+BXz3qeGrsdoWFhapxSyHr3kF2Yxc+jdlevGZeAJVTpPI/Eal2F3Oczlb6Q7/V2zcu6 T202UXFjjYUOwlMdM/XqU6etm5OZbgn8h5OTyyaEwp3Y+G/RXizHLW9PRlKC9/KKlyBY Su+iZxJzZAVOlECf5tg6ez5/WFe0jue8ixrrtmxAtCWllc+xgDM+cZEFCKPsDujCL2kJ qXObtDbp9EN7NvjZWCy4ufHS6FSf3Tk8X9SJsx6wkb/xRb04Mecs7B2NywCO9dIZ2oUR 7LVA== X-Gm-Message-State: AOAM530/KG/jzhWaJBeGLkzJaI/Dv3WXU+3eIMG/CS1wgzhwKslR5z4o Bx7t6/7sqKv/mnYOwYZqKdo= X-Google-Smtp-Source: ABdhPJx2m6EbRwfCm2aRFvHN9jwja3SBcFSouVIuGQ7r96re23icQ+szizM3W9x4xT3Kzmb5hpCQLQ== X-Received: by 2002:a17:902:74cb:b029:e4:7a16:9925 with SMTP id f11-20020a17090274cbb02900e47a169925mr16799724plt.39.1615896286566; Tue, 16 Mar 2021 05:04:46 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d5sm2722166pjo.12.2021.03.16.05.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 05:04:46 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v4 07/12] hw/net: i82596: Remove the logic of padding short frames in the receive path Date: Tue, 16 Mar 2021 20:04:15 +0800 Message-Id: <20210316120420.19658-8-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316120420.19658-1-bmeng.cn@gmail.com> References: <20210316120420.19658-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1034.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" 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 Tue Mar 16 12:04:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1453856 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=M5Z6PiZG; 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 4F0C2261vWz9sRf for ; Tue, 16 Mar 2021 23:16:26 +1100 (AEDT) Received: from localhost ([::1]:34178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lM8ca-00041B-Su for incoming@patchwork.ozlabs.org; Tue, 16 Mar 2021 08:16:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8RQ-0002v5-3Z for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:52 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:35342) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lM8RO-0003s0-FF for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:51 -0400 Received: by mail-pj1-x102a.google.com with SMTP id ga23-20020a17090b0397b02900c0b81bbcd4so1267814pjb.0 for ; Tue, 16 Mar 2021 05:04:50 -0700 (PDT) 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=McNoncbKLzrHCgZek44ykiwoAiw4bXEBjPK5hVmhdvs=; b=M5Z6PiZGeXHQgVut/atPHMCG7k7lIS6f0Qix4PJ4U6XO6JklhHNCtrFSc/F67Irq1P tIREBfQHS3FO1SG+51C8B9D9mZrGvEfoZZNMxDpk6SLtlZvC0x8CAVCyeVEzg5ov8iN5 Q84EK1GhEb9SafqYNdNtXVzm2yeEP8ART2t0/K7/0LITaU52M9/PqYOEz3xOy0p5vB7J yn8z0EPF6vleqzTARlNsSCdFROFZXZWrqqa3Qx9hK0jdolh7/orx4yh4MF7EqOL7W7pP hgd3ZgFOVtc+VMaKWYgz6F4XQa9kSrQMXWp7KOOl8vS6DHh3nVoFeCKIdi/yFaTJm8bj a96A== 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=McNoncbKLzrHCgZek44ykiwoAiw4bXEBjPK5hVmhdvs=; b=UJxezpEoym8QFcIfDxz/PGhqWx0CPYcvi/M78YMCbR0sOu9Wyfx9K1rtLEqMQ+UP7V f1Gz20mSSCQGLT7rJNciZN6D8au/+roj/aWpv+0R5gamz/eh3/sr9yOFcnNmPrP7Vb8t exQfkqSeZjlXHnvjjxGoYpIKwwnyBuO/xQEUuKNCr/cEnjZVzKw9MIZM9vnVFuWi14u9 oy8YlnOHnvPqRBFRZS1twLY+nFnWNvOwb2C6EYVD4dX1oJDqqp/FMYGRKT74K9sRENIo U7GtzpScJUm73a2Zw29144bRBpxGvQSMJJK8/d0mOWkAlRm/TKWsX/CzZpzZ1mpY6nQU UvJQ== X-Gm-Message-State: AOAM532Egph8qtcYzeE952q+7SSLRnP1lmY+yWRVnoqPDbOJdidqjUvf 4BDAE/e00bzRCP5fel3r1Eo= X-Google-Smtp-Source: ABdhPJwSp/wyH4lQcz38xrUXU04T/XN4pdQ4GhZpwGXG5kNPik4rX+dONAHWomhNnageXyCq0hjtLw== X-Received: by 2002:a17:902:24d:b029:e3:cfa7:e308 with SMTP id 71-20020a170902024db02900e3cfa7e308mr16438703plc.82.1615896289265; Tue, 16 Mar 2021 05:04:49 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d5sm2722166pjo.12.2021.03.16.05.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 05:04:48 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v4 08/12] hw/net: ne2000: Remove the logic of padding short frames in the receive path Date: Tue, 16 Mar 2021 20:04:16 +0800 Message-Id: <20210316120420.19658-9-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316120420.19658-1-bmeng.cn@gmail.com> References: <20210316120420.19658-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102a.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" 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 Tue Mar 16 12:04:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1453859 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=sONk49lx; 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 4F0C7P3M96z9sRf for ; Tue, 16 Mar 2021 23:21:05 +1100 (AEDT) Received: from localhost ([::1]:39624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lM8h4-0006S3-NE for incoming@patchwork.ozlabs.org; Tue, 16 Mar 2021 08:21:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8RT-00031i-7v for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:55 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:39922) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lM8RR-0003tY-Gz for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:54 -0400 Received: by mail-pg1-x534.google.com with SMTP id x29so22448504pgk.6 for ; Tue, 16 Mar 2021 05:04:53 -0700 (PDT) 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=E+R5IJqe5IDW0hjNBWmorKuSmHDcQ7ADX024vNepPJw=; b=sONk49lxQm405fRAInIuax4SptbCegNCsXSt39ltg3687iOrJnyBlcGuEdmgMUaoQ5 2DYdc4OiM9+1T2h5souKq+NtWCGidmoK3Gz9fcx/oNfDk3rfoTTqgK+4RXW00hcnLTYf tdkKibF8M0hqhb/LQq/YfQJL+o6mPoa0ANeCKWcXJCvP2KOhgyvMQnS/OsJiz+jLKczL Ck1V4C11WFtczNuhAsmLV49gx42GzuwnDqpn2EA3z+ZRFKoxFLVuu5AX1/9DRuLGeeec EokzORvrPsFy20/yKPTH53r0vW3eS2BQWfAG2dnnDTcmMGz8yavwGi3Qnonbj4yg6QYn QqzA== 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=E+R5IJqe5IDW0hjNBWmorKuSmHDcQ7ADX024vNepPJw=; b=d0y3HqATGK+VRK9VAxKZbIp/f/OxP+RANkuqoH5lxj//i/Z2YmvT/PYZ/kj6jOFGlB tbk8nryVP7HhqzP0mGSd6prp+/WdAb/UVwd2uV7DkOrPRzxikiQf6DOylWb2hi334fwT 9AR10VznDGnOD3m5Bgb76hz6YMPyQRDuJahdtQ/RlRyjrO69Vuc98KlpxQOXRHO+/hxQ EsEWJdUbIG15No/h+GSHyUfXlpLWBX40UPhq85vsupFR1xn4sfa5jctg6/30LluVR15v A3fgM/pSxJzPEzeEFtCe9Q6CpRTxfgiRbSk8md9HIQsmX6yTeLO+QZ+nxrQUfZj1WrQQ pnEw== X-Gm-Message-State: AOAM531JKy+IAB2hHxyrlwTtAG3eU68RiQLgWdRy6weIDO2VDXDys/Ge egA6++068cP4N/xM6oo1t1M= X-Google-Smtp-Source: ABdhPJxruAJyoJNMLAWrW/SqXD/Gsgaoq5npfij9fOBitWWa/zp5B2eu0kqi4XRUS4/O3t8/FBxVqw== X-Received: by 2002:a63:1350:: with SMTP id 16mr3658538pgt.85.1615896292226; Tue, 16 Mar 2021 05:04:52 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d5sm2722166pjo.12.2021.03.16.05.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 05:04:51 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v4 09/12] hw/net: pcnet: Remove the logic of padding short frames in the receive path Date: Tue, 16 Mar 2021 20:04:17 +0800 Message-Id: <20210316120420.19658-10-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316120420.19658-1-bmeng.cn@gmail.com> References: <20210316120420.19658-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-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: , Cc: Bin Meng 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 f3f18d8598..16330335cd 100644 --- a/hw/net/pcnet.c +++ b/hw/net/pcnet.c @@ -987,7 +987,6 @@ ssize_t pcnet_receive(NetClientState *nc, const uint8_t *buf, size_t size_) { PCNetState *s = qemu_get_nic_opaque(nc); int is_padr = 0, is_bcast = 0, is_ladr = 0; - uint8_t buf1[60]; int remaining; int crc_err = 0; size_t size = size_; @@ -1000,14 +999,6 @@ ssize_t pcnet_receive(NetClientState *nc, const uint8_t *buf, size_t size_) printf("pcnet_receive size=%zu\n", size); #endif - /* if too small buffer, then expand it */ - if (size < MIN_BUF_SIZE) { - memcpy(buf1, buf, size); - memset(buf1 + size, 0, MIN_BUF_SIZE - size); - buf = buf1; - size = MIN_BUF_SIZE; - } - if (CSR_PROM(s) || (is_padr=padr_match(s, buf, size)) || (is_bcast=padr_bcast(s, buf, size)) From patchwork Tue Mar 16 12:04:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1453853 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=DxF0tGes; 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 4F0BxY4sPSz9sRf for ; Tue, 16 Mar 2021 23:12:33 +1100 (AEDT) Received: from localhost ([::1]:55050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lM8Yp-0000rW-6O for incoming@patchwork.ozlabs.org; Tue, 16 Mar 2021 08:12:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8RX-00038Q-Bo for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:05:00 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:42647) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lM8RT-0003vk-SW for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:04:59 -0400 Received: by mail-pj1-x1034.google.com with SMTP id j6-20020a17090adc86b02900cbfe6f2c96so1319170pjv.1 for ; Tue, 16 Mar 2021 05:04:55 -0700 (PDT) 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=CubR3Co6U6Ex+8IytfhrvWse7tMl3MTMhUWaYan/XpQ=; b=DxF0tGesjfExnMWgFZ3vmGs6XNKf5AOM4o7lA0zTu2aqhvvbSpwi5dHi9aLvDFgwrH Ki3zOpVgLgc5cV+J0wprS2/81jhR/WzSJxKPD+iCoTRAGzM0AQPCX/l/s0mJHWM7Z/82 1+94IffRF1W8+1MLQkO/vuQbqPt+LeE8CJoZt24kAv1Av89QWwddd3dsEa9ou0D5yeWI a5F/tEEwHTtovnz4dugktkS4bFw1ODXen6r3TD1/HyceC0mOtI02tdLLtRymk2rXu3aM nJ4/DHOqYEGk4XJ5sjvp4sLdvflWAv2jIXwtLmgpez2cUMtie8DxuatXVuIAw6NZTueC iRwg== 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=CubR3Co6U6Ex+8IytfhrvWse7tMl3MTMhUWaYan/XpQ=; b=BbbFPn6DbEg0hOFSRnaaH5+qr9I6I2Zb6mnBzoHKiQWP2IE2+4MIJdNT1Hv+1I4tkz a+TtGMi7cGgvBFTCtx1fPpTWQbyltYwkBDaihAWV6pc3DNHwJLNWmXXcvtxcCJe/VGVo OnTrOcnOCOCGrY72/dKZAoxfgZV0JKem/f8nB9//iVCvpwrAXYX47zE8SZDhwVfK0Hfh hSJNyh/lMBiSWstCuE6pXit8mtYr0KOAm6qahbWWPaNGbwcLQ5KUm32uDZLIr9sLVhmF cnpWz4jFPGSU0+DvZYZY2k6rxOZP3deKek/YkxfnUhC6m0f5udXWQfFTaQ9tghy+4Ts3 4i/w== X-Gm-Message-State: AOAM530pki6JpUwpeEk/D85JlqdkWDlox4wyrdJ5NG5VFKS1q0IL+yVI i8ZKW+4btZ6G8ssaju4l0zc= X-Google-Smtp-Source: ABdhPJy7MqZSNaHlxKi+S3K9HkhDrtvT25f+RevA+vUo6fyd3NYHRoOP+J/AVzJsA5AwYbo5r0F7Gw== X-Received: by 2002:a17:902:369:b029:e4:b5f1:cfb4 with SMTP id 96-20020a1709020369b02900e4b5f1cfb4mr16174663pld.60.1615896294626; Tue, 16 Mar 2021 05:04:54 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d5sm2722166pjo.12.2021.03.16.05.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 05:04: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 v4 10/12] hw/net: rtl8139: Remove the logic of padding short frames in the receive path Date: Tue, 16 Mar 2021 20:04:18 +0800 Message-Id: <20210316120420.19658-11-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316120420.19658-1-bmeng.cn@gmail.com> References: <20210316120420.19658-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1034.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" 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 4675ac878e..cbfe29a286 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -827,7 +827,6 @@ static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t uint32_t packet_header = 0; - uint8_t buf1[MIN_BUF_SIZE + VLAN_HLEN]; static const uint8_t broadcast_macaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; @@ -939,17 +938,6 @@ static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t } } - /* if too small buffer, then expand it - * Include some tailroom in case a vlan tag is later removed. */ - if (size < MIN_BUF_SIZE + VLAN_HLEN) { - memcpy(buf1, buf, size); - memset(buf1 + size, 0, MIN_BUF_SIZE + VLAN_HLEN - size); - buf = buf1; - if (size < MIN_BUF_SIZE) { - size = MIN_BUF_SIZE; - } - } - if (rtl8139_cp_receiver_enabled(s)) { if (!rtl8139_cp_rx_valid(s)) { From patchwork Tue Mar 16 12:04:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1453855 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=M26o6+/g; 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 4F0Bzk3Djtz9sRf for ; Tue, 16 Mar 2021 23:14:26 +1100 (AEDT) Received: from localhost ([::1]:59422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lM8ae-0002ib-Ft for incoming@patchwork.ozlabs.org; Tue, 16 Mar 2021 08:14:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8RZ-00038a-5i for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:05:02 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:33013) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lM8RX-0003xo-3L for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:05:00 -0400 Received: by mail-pg1-x52c.google.com with SMTP id g4so22466011pgj.0 for ; Tue, 16 Mar 2021 05:04:58 -0700 (PDT) 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=m4a685HUG50oDycdiMz8MX8zwTLJNRbcKkuniaQymBg=; b=M26o6+/gIoVWq1yhrwPviF3LbgG2XPyKRaYJDYEGXBPfKWm4kqGh+b2ucaZGDQA8Q3 zSOBSRdV9KpRsT+lyfUT6rTfEq14e3ln5YrnZ/B09e438sKaoeW5LAKeNu5TRc0SGfMb mqDQBWpHzmtd+GFqvqT+ZowGfq3Pwkjdix5KxcNFH4I0JQUsUgCbxQO9mLj4hUQqCpcC gH2lNaazG1kDAkKgSc5wbQnrvqycTkB/8tCwcVc0sC8oxnvcyvhh79NsToyw/ePp1qol eW7XUNyEWJI/rued2KPJkUBd0IB/wMyPwW9xrGeyflyoLzpRn3w9+ogT+xpSP9yQwpvk 78cw== 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=m4a685HUG50oDycdiMz8MX8zwTLJNRbcKkuniaQymBg=; b=b4OQQRoYvlbjZ9i1QHqTh5TOlQ9+iWvpyy7kEfT76EcgVS0axER+2CrxYIT8tE0MQn nwTKT5U3wDSUMoEwxFO7lC+1YtfH33oSmmrRJM9gS76RbJARWo/JzGc6b9/IG1finSTs iKt2gEzn0WglgXqnVM623FPVgtuBQ88fAdqd4QS8mSUquG8LZHEjNV+P//Nt9c7mZk37 rmIV5JDSvVBFcO4llr9mQZpeYSxSsrusRHwEzbIRE1rokxj6yZblc3fOtRwC64cqRgwI w30U+q35E66mzsnc5zqBswqDlpzwSPGtIMi8cZezMkMVrmpuuj6mrw+ZjET9PIhev4CT qIIA== X-Gm-Message-State: AOAM532i8keEYeaNV5fumearhfBzUOuAbCGhaD8uEwD6Ig/iyJES5WfO il1Ml6tiF3wQFpmA9wNKrADJwwMBejU= X-Google-Smtp-Source: ABdhPJwItLozJEM/PSo39Kr1OzMeR5J+B7pUINjjCzGDndlLp+Bs4RbaeX5nZ1BzGIvLGzrow0yfqQ== X-Received: by 2002:aa7:9d1c:0:b029:1f1:53b2:a5b0 with SMTP id k28-20020aa79d1c0000b02901f153b2a5b0mr14392083pfp.13.1615896297451; Tue, 16 Mar 2021 05:04:57 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d5sm2722166pjo.12.2021.03.16.05.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 05:04:56 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v4 11/12] hw/net: sungem: Remove the logic of padding short frames in the receive path Date: Tue, 16 Mar 2021 20:04:19 +0800 Message-Id: <20210316120420.19658-12-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316120420.19658-1-bmeng.cn@gmail.com> References: <20210316120420.19658-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x52c.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" 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 33c3722df6..3fa83168db 100644 --- a/hw/net/sungem.c +++ b/hw/net/sungem.c @@ -550,7 +550,6 @@ static ssize_t sungem_receive(NetClientState *nc, const uint8_t *buf, PCIDevice *d = PCI_DEVICE(s); uint32_t mac_crc, done, kick, max_fsize; uint32_t fcs_size, ints, rxdma_cfg, rxmac_cfg, csum, coff; - uint8_t smallbuf[60]; struct gem_rxd desc; uint64_t dbase, baddr; unsigned int rx_cond; @@ -584,19 +583,6 @@ static ssize_t sungem_receive(NetClientState *nc, const uint8_t *buf, return size; } - /* We don't drop too small frames since we get them in qemu, we pad - * them instead. We should probably use the min frame size register - * but I don't want to use a variable size staging buffer and I - * know both MacOS and Linux use the default 64 anyway. We use 60 - * here to account for the non-existent FCS. - */ - if (size < 60) { - memcpy(smallbuf, buf, size); - memset(&smallbuf[size], 0, 60 - size); - buf = smallbuf; - size = 60; - } - /* Get MAC crc */ mac_crc = net_crc32_le(buf, ETH_ALEN); From patchwork Tue Mar 16 12:04:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1453857 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=gta/VsId; 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 4F0C4Q3kHwz9sRf for ; Tue, 16 Mar 2021 23:18:30 +1100 (AEDT) Received: from localhost ([::1]:35570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lM8ea-0004hp-9i for incoming@patchwork.ozlabs.org; Tue, 16 Mar 2021 08:18:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM8Rc-0003C9-96 for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:05:04 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:38488) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lM8Ra-0003yH-Ex for qemu-devel@nongnu.org; Tue, 16 Mar 2021 08:05:04 -0400 Received: by mail-pj1-x1036.google.com with SMTP id k23-20020a17090a5917b02901043e35ad4aso1197941pji.3 for ; Tue, 16 Mar 2021 05:05:00 -0700 (PDT) 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=Jyb/b1jyASe9wzHMIMHOmxI51zIjBjecJDfrWL1qudA=; b=gta/VsIdvuM0fEqL00ANq/JWY/iA7KV3kk6aDOgUeglu6CffZih6MP3sGIiHe8JGqs 5Zftg9TxZ583lCJgRTGizdQH/NupmBQrS53SQdhI4SAIpTmsVWn3BdQa/8Rxgp5MZSK3 f2E6yr0U6bsuQZeD26fJUJf8czWKKWxjsx8jIHnLYVRQ5wUMTU1luWc9FOGPrFyVts+E axKDWjbjOAZL3VlcU1BQeqAyA51bxeFlBL6/Mr/kTMKIBOVE+v6pyqREQhBVx0D+YK79 3DA3LkhXpVeBm+b/TP/YRDmVvRMdGlRaQJrk8U5yzDjLPgadTVe3faeCgDOwobDdP9R3 QeMA== 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=Jyb/b1jyASe9wzHMIMHOmxI51zIjBjecJDfrWL1qudA=; b=PmWK8P8ztvLvpD5GtrcJtIUEey/U6TjVRb07af/vFQ+zJiSYSK+dvIreo9KJ7dgvKD 14a+bv9vYsM20rMGTh0te5YQtD2mOcBVEqcyovyOZeMtOgEe40zOPrwooB7nwHLv0pLj pOytpQyNI//dfpT8bLqO1/n7A9Iio5iO/eiwERVSWDHGfqyeGqYN0kkffEjtgyHzaVQV ufo5Sd2UQy+Yl8vBGMzG7nTAVv+PNHN0y4GH5r9eDtp/NSRmNNcv8urHM8Fu9rws5pOG ek266Ao3CmCyLVtTp3IA0EaZ2rO8P3Au9j1kTjgYgXwLKaOjgmwVvyz0vr52NBiGxqaD p4XQ== X-Gm-Message-State: AOAM530JyXrOj5x9ruqGP3UjoHmgThqZ5/VqwXeX5bkXo8j+kOncqUIQ IVgsJhOUvdNqY8EYQpCeLQ8= X-Google-Smtp-Source: ABdhPJwXxUZM4YpHeNGYvBpb/U8IZhYT79NepLlEPT9UovLk7qFoZ32gbyYxfY4yKF6OIpQlsWQynQ== X-Received: by 2002:a17:902:8303:b029:e6:4ef3:4f17 with SMTP id bd3-20020a1709028303b02900e64ef34f17mr16056972plb.22.1615896300211; Tue, 16 Mar 2021 05:05:00 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id d5sm2722166pjo.12.2021.03.16.05.04.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 05:04:59 -0700 (PDT) From: Bin Meng To: Jason Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH v4 12/12] hw/net: sunhme: Remove the logic of padding short frames in the receive path Date: Tue, 16 Mar 2021 20:04:20 +0800 Message-Id: <20210316120420.19658-13-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316120420.19658-1-bmeng.cn@gmail.com> References: <20210316120420.19658-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1036.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" 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);