From nobody Wed Nov 27 07:29:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1700299227; cv=none; d=zohomail.com; s=zohoarc; b=gpDsbAwN/BtwECmuEHWynKuj6JVBPMquK8DdaC1DbiOMvNVnqpahcOHJT3wJIshHeNeOt+wpGQWbPRyKjRsOZSO3eaUx265CI9uz2tuavKedDEwRPGm6D++EtBrcQRg47xBkagBVDb3usv5KyKgqGSOMaCYGlhwFKGDMyoIv6ns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700299227; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:Message-Id:Reply-To:To; bh=NH4z8c4GQjAouNwfLwfScwCiclvcDQ3b58PlUlrM6zA=; b=TPU5Qx/lTY8OZ7acL57cF2w+N/IZzKxZyzFimBAvUTulSPblb6Lw0KCEkaWKQ8/7r19N8t2R8vRXCldXUfq4NsUOnBCWc0H285UwYfKCCbFsugIIaIMb8oxUsRN9iZSvmh7YdMLNVGtxhNWcNjzk1mw3dAX3Lvh1WKSos+1I9hw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700299227637723.9660238517457; Sat, 18 Nov 2023 01:20:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r4HTz-0002V1-3Q; Sat, 18 Nov 2023 04:19:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r4HTx-0002Uq-I4 for qemu-devel@nongnu.org; Sat, 18 Nov 2023 04:19:17 -0500 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r4HTw-00056L-0B for qemu-devel@nongnu.org; Sat, 18 Nov 2023 04:19:17 -0500 Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3b56b618217so1793322b6e.0 for ; Sat, 18 Nov 2023 01:19:15 -0800 (PST) Received: from localhost ([157.82.205.15]) by smtp.gmail.com with UTF8SMTPSA id w6-20020aa78586000000b006cb3a30f75csm1452818pfn.220.2023.11.18.01.19.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 18 Nov 2023 01:19:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1700299155; x=1700903955; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NH4z8c4GQjAouNwfLwfScwCiclvcDQ3b58PlUlrM6zA=; b=hqup4Fg1cEowKgNtK4mOFvvxVF+v4dn2Uaw7lZwoYX67yOiGBmfJ4um4MwX6+PVzSG hjOu54wnlIdEvSI6Xm7CQI5WA7NF/dANpGUTQHFhpGUY0uou1+675JKD74evV0SkWbOd n+qRecZnMQ0VL8Q+ww/97LeR/HjynFk2JZdJzrzvzm1+HmhdDjuks+yGNSF/7YNHBDFJ fvKSINfeaCMMbHNOq9ZALRztWa2i/FoGZxEMBytivsAiVALhAyCONFapvnDktewFm4xf V4IZUqHJAN4/adsBAESLsi5m4VHE4zJuVEiHLG2a6ry/z1APFTdHxcYbQyxOjLKncgVP UHbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700299155; x=1700903955; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NH4z8c4GQjAouNwfLwfScwCiclvcDQ3b58PlUlrM6zA=; b=gRRUsO9RBy9RujAef0w31hwokcCeI7g7Zd3NOq8dLjIY0rtEBBo+1gothK5BuXAuBG gGfvxntsyFsZL07BYhCE8k1tjmyCiZcvL74Ge3oCJdMFHg/JA9QcbwJeqtHUciHieiLY WF4CTDI4N5ZghUqjFT/JCGlMEwRWJJhCrAh0nOm5JFjijOYA4XmzYIyCM4ZyOyT8D6Eg /d0SSn78eYLEXRk/muIzvlwk6L18b2Tr2uYbvfJtBShv8LGjTSDgDf0MTazgAm2NCY2q s4zeLMaKafLvoOh6PNIpdgJ+P/F+qTl/pm7hTCqdWhzm/QNah+XI3DBIutSZd9DrRN8e ECgw== X-Gm-Message-State: AOJu0YyHjeLM/PreFt44JQ4GfeegAi94FNYT/aJJa74xHVZ/kN++RT1H mTD3PsxtE35Dm8zkvnZbcf6sQYYMKtgcgC0x1GQ= X-Google-Smtp-Source: AGHT+IGJMLyOxlQidLehkZaLrtbqrC56xH0PclYmr7GGwc89JmrVAZ+AyrP2oyuuiNHuctljQsXzcA== X-Received: by 2002:a05:6808:3a0e:b0:3b6:b9db:ea1c with SMTP id gr14-20020a0568083a0e00b003b6b9dbea1cmr2811809oib.42.1700299154724; Sat, 18 Nov 2023 01:19:14 -0800 (PST) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, Yuri Benditovich , Andrew Melnychenko , "Michael S . Tsirkin" , Jason Wang , "Zhang, Chen" , Akihiko Odaki Subject: [PATCH v7 04/19] net: Remove receive_raw() Date: Sat, 18 Nov 2023 18:18:18 +0900 Message-ID: <20231118091837.5758-5-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231118091837.5758-1-akihiko.odaki@daynix.com> References: <20231118091837.5758-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::231; envelope-from=akihiko.odaki@daynix.com; helo=mail-oi1-x231.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1700299228307100009 Content-Type: text/plain; charset="utf-8" While netmap implements virtio-net header, it does not implement receive_raw(). Instead of implementing receive_raw for netmap, add virtio-net headers in the common code and use receive_iov()/receive() instead. This also fixes the buffer size for the virtio-net header. Fixes: fbbdbddec0 ("tap: allow extended virtio header with hash info") Signed-off-by: Akihiko Odaki --- include/net/net.h | 1 - net/net.c | 18 ++++++++++++------ net/tap.c | 1 - 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 374a827190..899ed63047 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -72,7 +72,6 @@ typedef struct NetClientInfo { NetClientDriver type; size_t size; NetReceive *receive; - NetReceive *receive_raw; NetReceiveIOV *receive_iov; NetCanReceive *can_receive; NetStart *start; diff --git a/net/net.c b/net/net.c index 2e7c3fcc2a..66258ce92f 100644 --- a/net/net.c +++ b/net/net.c @@ -782,11 +782,7 @@ static ssize_t nc_sendv_compat(NetClientState *nc, con= st struct iovec *iov, offset =3D iov_to_buf(iov, iovcnt, 0, buf, offset); } =20 - if (flags & QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) { - ret =3D nc->info->receive_raw(nc, buffer, offset); - } else { - ret =3D nc->info->receive(nc, buffer, offset); - } + ret =3D nc->info->receive(nc, buffer, offset); =20 g_free(buf); return ret; @@ -801,6 +797,8 @@ static ssize_t qemu_deliver_packet_iov(NetClientState *= sender, MemReentrancyGuard *owned_reentrancy_guard; NetClientState *nc =3D opaque; int ret; + struct virtio_net_hdr_v1_hash vnet_hdr =3D { }; + g_autofree struct iovec *iov_copy =3D NULL; =20 =20 if (nc->link_down) { @@ -819,7 +817,15 @@ static ssize_t qemu_deliver_packet_iov(NetClientState = *sender, owned_reentrancy_guard->engaged_in_io =3D true; } =20 - if (nc->info->receive_iov && !(flags & QEMU_NET_PACKET_FLAG_RAW)) { + if ((flags & QEMU_NET_PACKET_FLAG_RAW) && nc->vnet_hdr_len) { + iov_copy =3D g_new(struct iovec, iovcnt + 1); + iov_copy[0].iov_base =3D &vnet_hdr; + iov_copy[0].iov_len =3D nc->vnet_hdr_len; + memcpy(&iov_copy[1], iov, iovcnt * sizeof(*iov)); + iov =3D iov_copy; + } + + if (nc->info->receive_iov) { ret =3D nc->info->receive_iov(nc, iov, iovcnt); } else { ret =3D nc_sendv_compat(nc, iov, iovcnt, flags); diff --git a/net/tap.c b/net/tap.c index f2021b699c..09ad8ae255 100644 --- a/net/tap.c +++ b/net/tap.c @@ -360,7 +360,6 @@ static NetClientInfo net_tap_info =3D { .type =3D NET_CLIENT_DRIVER_TAP, .size =3D sizeof(TAPState), .receive =3D tap_receive, - .receive_raw =3D tap_receive_raw, .receive_iov =3D tap_receive_iov, .poll =3D tap_poll, .cleanup =3D tap_cleanup, --=20 2.42.1