From nobody Mon Feb 9 08:56:57 2026 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=1712142757; cv=none; d=zohomail.com; s=zohoarc; b=k0pZggl5SZ3dmzmwuCdcf9szn6R+UQUpxZg8RY8VLju62EH/N7Bqx9/VZH8lxU89iTwGP3B5akYO7+TEY8JjMnSsyv2hURAuyunO2BBEMam+wTotOYB6ZaPr8VlOJzbSGoaz2gPa3LmdQIbOmP4OJiQqDTnWMoig0a5NzDpnnac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1712142757; h=Content-Type: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:To:To:Message-Id:Reply-To; bh=PP1VMTN+jVSPtgMQdki4VwFIT3uS9VG0fb4mIDFGQVE=; b=e5QfbBhXuJN+JyNKEyoY+bGhZJ7eU57aTsupFdQFQ0zDlV3ADMcLvEnB7Mp0sRf7S5gaZiKAbjOp/qcJvIHcMT8hqxzdMxqO1gWqTOOIjiHz6jMhxrLyUt6yTJ629E5BQc63RuZMFnGSFgH4f9Y07Tdu1olzPS5+VogMtY4iJFc= 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 1712142757732798.2904317841055; Wed, 3 Apr 2024 04:12:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rryWM-0007Lu-JY; Wed, 03 Apr 2024 07:11:10 -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 1rryWJ-0007Kj-6o for qemu-devel@nongnu.org; Wed, 03 Apr 2024 07:11:08 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rryWG-0007EP-HN for qemu-devel@nongnu.org; Wed, 03 Apr 2024 07:11:06 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1e2178b2cf2so47875825ad.0 for ; Wed, 03 Apr 2024 04:11:04 -0700 (PDT) Received: from localhost ([157.82.200.213]) by smtp.gmail.com with UTF8SMTPSA id w9-20020a1709026f0900b001e245d90d6fsm9030310plk.59.2024.04.03.04.11.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Apr 2024 04:11:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1712142663; x=1712747463; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=PP1VMTN+jVSPtgMQdki4VwFIT3uS9VG0fb4mIDFGQVE=; b=fRKm3AEBej1HhmVoHVCRJWyjyXUSUWBOtbx/Y8VYDdK2tdSemUzX6EUhMHVf5k+kEn zj7IPnLsgT26/XxEdPZWu6/y11bqARmd+RDaDaALoodYaS54TByg4vvxg3bQe08PHt1o pWZc8g0e1c7GAMAcyNjWUNFuJIFZU2ZFV4PSS8ttVHnr576hNlHdFmuvoHLFJoW4Uu75 C6hvINBfLJy9jgGTnG25sTfoI9hRhx3cI7tsQhyKE+fvQulGYDn6A1liAUaGPqK9oJys stKlAc3WA1Z2PtCehlsx5CR6Mzo6DWaP8jeSRu0EsFSj2MIWEEwf04s4514EtDAL79Nm CdWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712142663; x=1712747463; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PP1VMTN+jVSPtgMQdki4VwFIT3uS9VG0fb4mIDFGQVE=; b=wERyrNj7qSg5VZIdmvHD/1o9hK1KI/LCdGFgi7iNoQQ2+sE2m9f0gqinyr6z0n7hXD y2QE3JaPqQw4FYTEbVhxPVshGNXS20SZI/kmYChWrymWrM/xob3qyuSFs991BngTJK30 RGXdww/S/QMNzcfVP34JDgXL3DeWw01DlmpttxO6hn/7wZOX75Vt9NWVVdxbCpbMZRIX cO1muDC/q8M9yTDLicbc3Z+q4yekzHFKgTzw/ulkqlcEj+w3CyydYIzq6iBGE6T2qyiA B0w5GEwu3cpNV1CX161LVF7DcKjahdHXOJwDGcaP0ICPTASeSjtCAZO/mh/z16VJrw/Z dy0g== X-Gm-Message-State: AOJu0YzNtH+iCETx7/PYmjFpt26tHZMd2AE7/JcizZMh3DMIHYx6ylpl AOnaSGYILkNHBwUSL99n3wKxx7WXC7QLs1bdydaAtu+cbA5TuUF5SHn7ICauZhs= X-Google-Smtp-Source: AGHT+IGd1TH9xCIrF7FX4jOnAsEY1bQxW6R5GL4nDLuty+kdFdJhxXLhkc/Vs1seryTNsTbA6Vn9Kg== X-Received: by 2002:a17:903:2311:b0:1e2:8d7f:109a with SMTP id d17-20020a170903231100b001e28d7f109amr2109978plh.43.1712142662972; Wed, 03 Apr 2024 04:11:02 -0700 (PDT) From: Akihiko Odaki Date: Wed, 03 Apr 2024 20:10:50 +0900 Subject: [PATCH v9 02/20] tap: Remove qemu_using_vnet_hdr() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240403-rss-v9-2-c6d87e69d38b@daynix.com> References: <20240403-rss-v9-0-c6d87e69d38b@daynix.com> In-Reply-To: <20240403-rss-v9-0-c6d87e69d38b@daynix.com> To: Jason Wang , Dmitry Fleytman , Sriram Yagnaraman , "Michael S. Tsirkin" , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Andrew Melnychenko , Yuri Benditovich Cc: qemu-devel@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev 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::62a; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62a.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+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: 1712142758454100001 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 | 7 ------- 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 | 24 +----------------------- net/netmap.c | 5 ----- net/tap.c | 28 +--------------------------- 10 files changed, 5 insertions(+), 74 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index b1f9b35fcca1..6fe5a0aee833 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -57,8 +57,6 @@ typedef bool (HasUfo)(NetClientState *); typedef bool (HasUso)(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, int, = int); typedef int (GetVnetHdrLen)(NetClientState *); typedef void (SetVnetHdrLen)(NetClientState *, int); @@ -88,10 +86,7 @@ typedef struct NetClientInfo { HasUso *has_uso; 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; SetVnetLE *set_vnet_le; SetVnetBE *set_vnet_be; @@ -194,8 +189,6 @@ bool qemu_has_ufo(NetClientState *nc); bool qemu_has_uso(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 uso4, int uso6); int qemu_get_vnet_hdr_len(NetClientState *nc); diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c index 7c6f6029518c..d0dde767f6aa 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 =3D 0; i < s->conf.peers.queues; i++) { nc =3D 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); } } =20 diff --git a/hw/net/igb.c b/hw/net/igb.c index 9b37523d6df8..1224c7ba8e38 100644 --- a/hw/net/igb.c +++ b/hw/net/igb.c @@ -349,7 +349,6 @@ igb_init_net_peer(IGBState *s, PCIDevice *pci_dev, uint= 8_t *macaddr) for (i =3D 0; i < s->conf.peers.queues; i++) { nc =3D 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); } } =20 diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index 2134a18c4c90..903238dca24d 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 =3D opaque; =20 - 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 NetTx= Pkt *pkt, =20 bool net_tx_pkt_send(struct NetTxPkt *pkt, NetClientState *nc) { - bool offload =3D qemu_get_using_vnet_hdr(nc->peer); + bool offload =3D qemu_get_vnet_hdr_len(nc->peer); return net_tx_pkt_send_custom(pkt, offload, net_tx_pkt_sendv, nc); } =20 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 58014a92ad19..f6112c0ac97d 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3794,9 +3794,6 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) =20 peer_test_vnet_hdr(n); if (peer_has_vnet_hdr(n)) { - for (i =3D 0; i < n->max_queue_pairs; i++) { - qemu_using_vnet_hdr(qemu_get_subqueue(n->nic, i)->peer, true); - } n->host_hdr_len =3D sizeof(struct virtio_net_hdr); } else { n->host_hdr_len =3D 0; diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 707487c63666..63a91877730d 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -2091,8 +2091,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); } =20 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 16073f245828..956e34a123c0 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 =3D FILTER_DUMP(nf); - int offset =3D qemu_get_using_vnet_hdr(nf->netdev) ? - qemu_get_vnet_hdr_len(nf->netdev) : 0; =20 - dump_receive_iov(&nfds->ds, iov, iovcnt, offset); + dump_receive_iov(&nfds->ds, iov, iovcnt, qemu_get_vnet_hdr_len(nf->net= dev)); return 0; } =20 diff --git a/net/net.c b/net/net.c index a2f0c828bbf2..bd51037ebfb0 100644 --- a/net/net.c +++ b/net/net.c @@ -529,24 +529,6 @@ bool qemu_has_vnet_hdr_len(NetClientState *nc, int len) return nc->info->has_vnet_hdr_len(nc, len); } =20 -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, int uso4, int uso6) { @@ -559,11 +541,7 @@ void qemu_set_offload(NetClientState *nc, int csum, in= t tso4, int tso6, =20 int qemu_get_vnet_hdr_len(NetClientState *nc) { - if (!nc || !nc->info->get_vnet_hdr_len) { - return 0; - } - - return nc->info->get_vnet_hdr_len(nc); + return nc->vnet_hdr_len; } =20 void qemu_set_vnet_hdr_len(NetClientState *nc, int len) diff --git a/net/netmap.c b/net/netmap.c index 241b27c8e973..297510e19088 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)); } =20 -static void netmap_using_vnet_hdr(NetClientState *nc, bool enable) -{ -} - static void netmap_set_vnet_hdr_len(NetClientState *nc, int len) { NetmapState *s =3D DO_UPCAST(NetmapState, nc, nc); @@ -393,7 +389,6 @@ static NetClientInfo net_netmap_info =3D { .has_ufo =3D netmap_has_vnet_hdr, .has_vnet_hdr =3D netmap_has_vnet_hdr, .has_vnet_hdr_len =3D netmap_has_vnet_hdr_len, - .using_vnet_hdr =3D netmap_using_vnet_hdr, .set_offload =3D netmap_set_offload, .set_vnet_hdr_len =3D netmap_set_vnet_hdr_len, }; diff --git a/net/tap.c b/net/tap.c index 72ae95894ff1..c848844955df 100644 --- a/net/tap.c +++ b/net/tap.c @@ -262,13 +262,6 @@ static bool tap_has_vnet_hdr_len(NetClientState *nc, i= nt len) return tap_has_vnet_hdr(nc); } =20 -static int tap_get_vnet_hdr_len(NetClientState *nc) -{ - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); - - return s->host_vnet_hdr_len; -} - static void tap_set_vnet_hdr_len(NetClientState *nc, int len) { TAPState *s =3D DO_UPCAST(TAPState, nc, nc); @@ -280,23 +273,7 @@ static void tap_set_vnet_hdr_len(NetClientState *nc, i= nt len) =20 tap_fd_set_vnet_hdr_len(s->fd, len); s->host_vnet_hdr_len =3D len; -} - -static bool tap_get_using_vnet_hdr(NetClientState *nc) -{ - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); - - return s->using_vnet_hdr; -} - -static void tap_using_vnet_hdr(NetClientState *nc, bool using_vnet_hdr) -{ - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); - - assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); - assert(!!s->host_vnet_hdr_len =3D=3D using_vnet_hdr); - - s->using_vnet_hdr =3D using_vnet_hdr; + s->using_vnet_hdr =3D true; } =20 static int tap_set_vnet_le(NetClientState *nc, bool is_le) @@ -394,10 +371,7 @@ static NetClientInfo net_tap_info =3D { .has_uso =3D tap_has_uso, .has_vnet_hdr =3D tap_has_vnet_hdr, .has_vnet_hdr_len =3D tap_has_vnet_hdr_len, - .get_using_vnet_hdr =3D tap_get_using_vnet_hdr, - .using_vnet_hdr =3D tap_using_vnet_hdr, .set_offload =3D tap_set_offload, - .get_vnet_hdr_len =3D tap_get_vnet_hdr_len, .set_vnet_hdr_len =3D tap_set_vnet_hdr_len, .set_vnet_le =3D tap_set_vnet_le, .set_vnet_be =3D tap_set_vnet_be, --=20 2.44.0