From patchwork Tue Oct 17 04:09:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1849667 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=kyu0RzvJ; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S8gW10kFvz20cb for ; Tue, 17 Oct 2023 15:10:20 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qsbOw-0007OL-TC; Tue, 17 Oct 2023 00:09:50 -0400 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 1qsbOv-0007OB-BV for qemu-devel@nongnu.org; Tue, 17 Oct 2023 00:09:49 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsbOt-00046l-8E for qemu-devel@nongnu.org; Tue, 17 Oct 2023 00:09:48 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1c9b95943beso43838645ad.1 for ; Mon, 16 Oct 2023 21:09:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1697515785; x=1698120585; 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=g9DyJgfsNaywwdF+X+Mlrm7UwaxUF7X0EYzGFK3vXhg=; b=kyu0RzvJDNtOT6cEINd3CoHlClyiakx/88Cyca96/RM65R7EIuGKxYgbkZ88nS2dLf 14Nkoq1agqffAPkkihamw4yWUOPbGILwT++xbGWvprdeRwSu/iQrqfRNoo62YfDy78HJ ZBjxydYjNHRSIFHWgr4XcOWUTJHnaUL7ng7PPkuOky9fpezEcZslDSDp5wHBfoB16OG8 M3gZjGVIv0TrHRKakiOZbg1cx37airDhVTS8lu3I54lY9VY4sS+aiemLxll54Ncw6S1t LuCa7cjZp3Tk/q8/prNQ1Ki+FaoX3FsPau46d1KpAD6GfsxnliQZ95GZ5kF2f45aQoz9 1nvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697515785; x=1698120585; 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=g9DyJgfsNaywwdF+X+Mlrm7UwaxUF7X0EYzGFK3vXhg=; b=gavv6B3D5uDRuoswS8lHI2LSeQFBQWWvfmkeJogvN6z3Rr0g0g9cFjmCMHeBRcgrkE NPGzKIR33YEXE2zeF1wFcVHjWGfTh9GgUkD7sxxTzdkN0ihUQ2EcMnQpEqCH8jT//f43 CKiBGSwvNDeZZBtAow6JicjftAEY9jR1nx2nQZ5MPYZ2JLzvsPqz0FIpnhUjydxNxPgM 7UURTQqr6O86b/7I1ShzChmKPG8akATurv+7I6CrQrheoBB28+IG22ZEq5BD9d8dcxVo VefAaXZnAHrYt3MmMqqTgTNj+Z1Ju3KJIxNL95NOoc454bnobE2ehUYuQi69v0eCHFxc JLYA== X-Gm-Message-State: AOJu0YzNG6HzFyrtqsT1Ve9HzAw0tUmEONLUGLNUObIgdDA1ma8LZKWH Yzt8r0koLI6GXq7mrfd/YEY41KBl7qfUuryawOcoqw== X-Google-Smtp-Source: AGHT+IGeC35DrvD+sz9YMg09fWXUlM/tKLpics50RuRpnhFMSE2IdwCnzhLBkeP7/ImYNrytTQED9g== X-Received: by 2002:a17:903:808:b0:1c9:bf14:4f94 with SMTP id kr8-20020a170903080800b001c9bf144f94mr1054930plb.44.1697515784689; Mon, 16 Oct 2023 21:09:44 -0700 (PDT) Received: from localhost ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with UTF8SMTPSA id f6-20020a170902ce8600b001c74876f032sm391477plg.162.2023.10.16.21.09.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Oct 2023 21:09:44 -0700 (PDT) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, Yuri Benditovich , Andrew Melnychenko , "Michael S . Tsirkin" , Jason Wang , Akihiko Odaki , Dmitry Fleytman , Sriram Yagnaraman , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione Subject: [PATCH v5 02/21] tap: Remove qemu_using_vnet_hdr() Date: Tue, 17 Oct 2023 13:09:08 +0900 Message-ID: <20231017040932.62997-3-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231017040932.62997-1-akihiko.odaki@daynix.com> References: <20231017040932.62997-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::634; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x634.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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Since qemu_set_vnet_hdr_len() is always called when qemu_using_vnet_hdr() is called, we can merge them and save some code. For consistency, express that the virtio-net header is not in use by returning 0 with qemu_get_vnet_hdr_len() instead of having a dedicated function, qemu_get_using_vnet_hdr(). Signed-off-by: Akihiko Odaki --- include/net/net.h | 6 ------ hw/net/e1000e.c | 1 - hw/net/igb.c | 1 - hw/net/net_tx_pkt.c | 4 ++-- hw/net/virtio-net.c | 3 --- hw/net/vmxnet3.c | 2 -- net/dump.c | 4 +--- net/net.c | 18 ------------------ net/netmap.c | 5 ----- net/tap.c | 22 ++-------------------- 10 files changed, 5 insertions(+), 61 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 685ec58318..011031ef77 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -56,8 +56,6 @@ typedef RxFilterInfo *(QueryRxFilter)(NetClientState *); typedef bool (HasUfo)(NetClientState *); typedef bool (HasVnetHdr)(NetClientState *); typedef bool (HasVnetHdrLen)(NetClientState *, int); -typedef bool (GetUsingVnetHdr)(NetClientState *); -typedef void (UsingVnetHdr)(NetClientState *, bool); typedef void (SetOffload)(NetClientState *, int, int, int, int, int); typedef int (GetVnetHdrLen)(NetClientState *); typedef void (SetVnetHdrLen)(NetClientState *, int); @@ -86,8 +84,6 @@ typedef struct NetClientInfo { HasUfo *has_ufo; HasVnetHdr *has_vnet_hdr; HasVnetHdrLen *has_vnet_hdr_len; - GetUsingVnetHdr *get_using_vnet_hdr; - UsingVnetHdr *using_vnet_hdr; SetOffload *set_offload; GetVnetHdrLen *get_vnet_hdr_len; SetVnetHdrLen *set_vnet_hdr_len; @@ -191,8 +187,6 @@ void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6]); bool qemu_has_ufo(NetClientState *nc); bool qemu_has_vnet_hdr(NetClientState *nc); bool qemu_has_vnet_hdr_len(NetClientState *nc, int len); -bool qemu_get_using_vnet_hdr(NetClientState *nc); -void qemu_using_vnet_hdr(NetClientState *nc, bool enable); void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6, int ecn, int ufo); int qemu_get_vnet_hdr_len(NetClientState *nc); diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c index e41a6c1038..4edb58858e 100644 --- a/hw/net/e1000e.c +++ b/hw/net/e1000e.c @@ -352,7 +352,6 @@ e1000e_init_net_peer(E1000EState *s, PCIDevice *pci_dev, uint8_t *macaddr) for (i = 0; i < s->conf.peers.queues; i++) { nc = qemu_get_subqueue(s->nic, i); qemu_set_vnet_hdr_len(nc->peer, sizeof(struct virtio_net_hdr)); - qemu_using_vnet_hdr(nc->peer, true); } } diff --git a/hw/net/igb.c b/hw/net/igb.c index 8b713843d9..cfdb148051 100644 --- a/hw/net/igb.c +++ b/hw/net/igb.c @@ -339,7 +339,6 @@ igb_init_net_peer(IGBState *s, PCIDevice *pci_dev, uint8_t *macaddr) for (i = 0; i < s->conf.peers.queues; i++) { nc = qemu_get_subqueue(s->nic, i); qemu_set_vnet_hdr_len(nc->peer, sizeof(struct virtio_net_hdr)); - qemu_using_vnet_hdr(nc->peer, true); } } diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index 2e5f58b3c9..668871f8d8 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -578,7 +578,7 @@ static void net_tx_pkt_sendv( { NetClientState *nc = opaque; - if (qemu_get_using_vnet_hdr(nc->peer)) { + if (qemu_get_vnet_hdr_len(nc->peer)) { qemu_sendv_packet(nc, virt_iov, virt_iov_cnt); } else { qemu_sendv_packet(nc, iov, iov_cnt); @@ -808,7 +808,7 @@ static bool net_tx_pkt_do_sw_fragmentation(struct NetTxPkt *pkt, bool net_tx_pkt_send(struct NetTxPkt *pkt, NetClientState *nc) { - bool offload = qemu_get_using_vnet_hdr(nc->peer); + bool offload = !!qemu_get_vnet_hdr_len(nc->peer); return net_tx_pkt_send_custom(pkt, offload, net_tx_pkt_sendv, nc); } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 9a93a2df01..cab79f19cb 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3709,9 +3709,6 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) peer_test_vnet_hdr(n); if (peer_has_vnet_hdr(n)) { - for (i = 0; i < n->max_queue_pairs; i++) { - qemu_using_vnet_hdr(qemu_get_subqueue(n->nic, i)->peer, true); - } n->host_hdr_len = sizeof(struct virtio_net_hdr); } else { n->host_hdr_len = 0; diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 3df1d1b101..a9619108ca 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -2086,8 +2086,6 @@ static void vmxnet3_net_init(VMXNET3State *s) if (s->peer_has_vhdr) { qemu_set_vnet_hdr_len(qemu_get_queue(s->nic)->peer, sizeof(struct virtio_net_hdr)); - - qemu_using_vnet_hdr(qemu_get_queue(s->nic)->peer, 1); } qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); diff --git a/net/dump.c b/net/dump.c index 7d05f16ca7..d2defe4ed9 100644 --- a/net/dump.c +++ b/net/dump.c @@ -154,10 +154,8 @@ static ssize_t filter_dump_receive_iov(NetFilterState *nf, NetClientState *sndr, int iovcnt, NetPacketSent *sent_cb) { NetFilterDumpState *nfds = FILTER_DUMP(nf); - int offset = qemu_get_using_vnet_hdr(nf->netdev) ? - qemu_get_vnet_hdr_len(nf->netdev) : 0; - dump_receive_iov(&nfds->ds, iov, iovcnt, offset); + dump_receive_iov(&nfds->ds, iov, iovcnt, qemu_get_vnet_hdr_len(nf->netdev)); return 0; } diff --git a/net/net.c b/net/net.c index 3523cceafc..1bb4f33a63 100644 --- a/net/net.c +++ b/net/net.c @@ -515,24 +515,6 @@ bool qemu_has_vnet_hdr_len(NetClientState *nc, int len) return nc->info->has_vnet_hdr_len(nc, len); } -bool qemu_get_using_vnet_hdr(NetClientState *nc) -{ - if (!nc || !nc->info->get_using_vnet_hdr) { - return false; - } - - return nc->info->get_using_vnet_hdr(nc); -} - -void qemu_using_vnet_hdr(NetClientState *nc, bool enable) -{ - if (!nc || !nc->info->using_vnet_hdr) { - return; - } - - nc->info->using_vnet_hdr(nc, enable); -} - void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6, int ecn, int ufo) { diff --git a/net/netmap.c b/net/netmap.c index 9e0cec58d3..b7a669f862 100644 --- a/net/netmap.c +++ b/net/netmap.c @@ -351,10 +351,6 @@ static bool netmap_has_vnet_hdr(NetClientState *nc) return netmap_has_vnet_hdr_len(nc, sizeof(struct virtio_net_hdr)); } -static void netmap_using_vnet_hdr(NetClientState *nc, bool enable) -{ -} - static void netmap_set_vnet_hdr_len(NetClientState *nc, int len) { NetmapState *s = DO_UPCAST(NetmapState, nc, nc); @@ -393,7 +389,6 @@ static NetClientInfo net_netmap_info = { .has_ufo = netmap_has_vnet_hdr, .has_vnet_hdr = netmap_has_vnet_hdr, .has_vnet_hdr_len = netmap_has_vnet_hdr_len, - .using_vnet_hdr = netmap_using_vnet_hdr, .set_offload = netmap_set_offload, .set_vnet_hdr_len = netmap_set_vnet_hdr_len, }; diff --git a/net/tap.c b/net/tap.c index 0403729739..4667933ffe 100644 --- a/net/tap.c +++ b/net/tap.c @@ -255,7 +255,7 @@ static int tap_get_vnet_hdr_len(NetClientState *nc) { TAPState *s = DO_UPCAST(TAPState, nc, nc); - return s->host_vnet_hdr_len; + return s->using_vnet_hdr ? s->host_vnet_hdr_len : 0; } static void tap_set_vnet_hdr_len(NetClientState *nc, int len) @@ -269,23 +269,7 @@ static void tap_set_vnet_hdr_len(NetClientState *nc, int len) tap_fd_set_vnet_hdr_len(s->fd, len); s->host_vnet_hdr_len = len; -} - -static bool tap_get_using_vnet_hdr(NetClientState *nc) -{ - TAPState *s = DO_UPCAST(TAPState, nc, nc); - - return s->using_vnet_hdr; -} - -static void tap_using_vnet_hdr(NetClientState *nc, bool using_vnet_hdr) -{ - TAPState *s = DO_UPCAST(TAPState, nc, nc); - - assert(nc->info->type == NET_CLIENT_DRIVER_TAP); - assert(!!s->host_vnet_hdr_len == using_vnet_hdr); - - s->using_vnet_hdr = using_vnet_hdr; + s->using_vnet_hdr = true; } static int tap_set_vnet_le(NetClientState *nc, bool is_le) @@ -382,8 +366,6 @@ static NetClientInfo net_tap_info = { .has_ufo = tap_has_ufo, .has_vnet_hdr = tap_has_vnet_hdr, .has_vnet_hdr_len = tap_has_vnet_hdr_len, - .get_using_vnet_hdr = tap_get_using_vnet_hdr, - .using_vnet_hdr = tap_using_vnet_hdr, .set_offload = tap_set_offload, .get_vnet_hdr_len = tap_get_vnet_hdr_len, .set_vnet_hdr_len = tap_set_vnet_hdr_len,