From nobody Mon Nov 25 07:23:34 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717487269; cv=none; d=zohomail.com; s=zohoarc; b=I5lJOuLCfcKl/GTvRmRcxYJTOHYZULNJykioDjCdcv2d++bJtlWIcQOO/33wYCd/wu/xN1qmmBLauPzJ7J40d2qs+avrNV+pkkjov0iHiRDNE1XyqGIlgfW6Vnj5BoIMcaEXni1ULxoHNrUbePn1ifxfWNijU2alzKIgTc1rGyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717487269; 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=d8X6Nyk8+Dn1Q8zQAFgea9T4Cp9NTY+ndTyEpP0tuBE=; b=mx8jGnMiExCYzIy4h5gGuNDnjN3EX+D0bHRekhx2Srv6cxgtj3vY7P3anAOQj5/xbagCFOxO7IbC8PhRckqfy60S8E4ZOys9YGeDvvFYX3jHq8MjsmCQWqeDfeGnO6s2UNw2qabulYcjT/sv0aaskRd3n8poZhQat4DtVoJnOok= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717487269233193.20721264038752; Tue, 4 Jun 2024 00:47:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEOt8-00059p-Oz; Tue, 04 Jun 2024 03:47:22 -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 1sEOt6-00059Y-Hd for qemu-devel@nongnu.org; Tue, 04 Jun 2024 03:47:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEOt3-0007v0-Co for qemu-devel@nongnu.org; Tue, 04 Jun 2024 03:47:20 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-275-8qra3K2eN4S6nBumGvdFpg-1; Tue, 04 Jun 2024 03:47:13 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 173E785A5BA; Tue, 4 Jun 2024 07:47:13 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A763492BD2; Tue, 4 Jun 2024 07:38:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717487236; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d8X6Nyk8+Dn1Q8zQAFgea9T4Cp9NTY+ndTyEpP0tuBE=; b=fmc/OlTorBBU8C9rPT76z/b7mWrL3QREN3U4699TFJFkRMNwjPaEYxOW4XjA2KktsC3ZIN 2WnPvWRKKwYRyXLVfOBRO5mezej584jCe8q5QniY/LVb6bApdWxDz2+xkbaYvsIb2gmSaB 4cXN6qqcSx/nnBZVemY2WmIbVpJ9TH0= X-MC-Unique: 8qra3K2eN4S6nBumGvdFpg-1 From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Cc: Akihiko Odaki , Jason Wang Subject: [PULL 02/20] tap: Remove qemu_using_vnet_hdr() Date: Tue, 4 Jun 2024 15:37:37 +0800 Message-ID: <20240604073755.1859-3-jasowang@redhat.com> In-Reply-To: <20240604073755.1859-1-jasowang@redhat.com> References: <20240604073755.1859-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 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: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1717487270630100003 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki 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 Signed-off-by: Jason Wang --- 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 -- include/net/net.h | 7 ------- 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/hw/net/e1000e.c b/hw/net/e1000e.c index edc101eaf6..843892ce09 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 1ef6170465..b92bba402e 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 b7b1de816d..1f79b82b77 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -582,7 +582,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); @@ -812,7 +812,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 24e5e7d347..ff600b3002 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3778,9 +3778,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 707487c636..63a9187773 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/include/net/net.h b/include/net/net.h index b1f9b35fcc..6fe5a0aee8 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/net/dump.c b/net/dump.c index 16073f2458..956e34a123 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 a2f0c828bb..bd51037ebf 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 241b27c8e9..297510e190 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 72ae95894f..c848844955 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.42.0