From nobody Sun Sep 28 17:03:42 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758550986; cv=none; d=zohomail.com; s=zohoarc; b=Pt4QaeYHy7lNGgwbtlAj32bLPFRtrjOFoB1PYsh66CdpWnea+XKe3uPRiZb3/z8A1i5sAA4wxjgNCrxUY2BgQjT55jN3FwqnfJaXPSn7FSkKsmfLvJmCdF0UjTbp/Zf0hHWl32lr/1IkvplRiRWfjR5UyzZV2+Taz8ibdIUxA2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758550986; 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:To:To:Message-Id:Reply-To; bh=Z31nwF1cKJcq+lWkszR6AbE0BKO6doG/YoXdsVETYI4=; b=HN9YUwZ6KmGS+ZB4O9ZdCE8NwszgmR3tMBhqLjis2z9dubT+reToc4Zz9wQLtDSOiVFKfUpqIfnnlRi/mhfcDQO0aBKweJcY+MMLWPRGPiecwxF6DM4D/pyXlRkr+PtHS+PoBxMWm7bKWaJAvNPus8HCPF5YbvWv83IkdLlAWNc= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758550986716454.7235619626714; Mon, 22 Sep 2025 07:23:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0hOU-0006aZ-J3; Mon, 22 Sep 2025 10:19:54 -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 1v0hOM-0006XD-4d for qemu-devel@nongnu.org; Mon, 22 Sep 2025 10:19:47 -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 1v0hOC-0006ix-Li for qemu-devel@nongnu.org; Mon, 22 Sep 2025 10:19:45 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-0xmdVWivNjG-QxeQaMFXng-1; Mon, 22 Sep 2025 10:19:18 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2D82E19560B0; Mon, 22 Sep 2025 14:19:15 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.44.32.247]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1594119560BB; Mon, 22 Sep 2025 14:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758550762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z31nwF1cKJcq+lWkszR6AbE0BKO6doG/YoXdsVETYI4=; b=Vjv27YDc0IQANoUfrNJqDpRPEfRLseAPJvpKqEq5oBWD9H8wYSQZnN/uMSd2XNPw2PgVbv PWqO4/hz+ohQ2UyXa+GMt3/05adbmm4MY0lRjLxxR7qn5sdSt8qeEG/+ZecyFgC+rvrzCr htlkfslCJsZdYwD205XcqWtpBlc3cTo= X-MC-Unique: 0xmdVWivNjG-QxeQaMFXng-1 X-Mimecast-MFC-AGG-ID: 0xmdVWivNjG-QxeQaMFXng_1758550756 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH v7 01/14] net: bundle all offloads in a single struct Date: Mon, 22 Sep 2025 16:18:15 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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.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: 1758550988898116600 Content-Type: text/plain; charset="utf-8" The set_offload() argument list is already pretty long and we are going to introduce soon a bunch of additional offloads. Replace the offload arguments with a single struct and update all the relevant call-sites. No functional changes intended. Signed-off-by: Paolo Abeni --- v5 -> v6: - re-included into the main series v4 -> v5: - sent as standalone patch v3 -> v4: - style fix for NetOffloads init v1 -> v2: - drop unneeded 'struct' keywords - moved to series start --- hw/net/e1000e_core.c | 5 +++-- hw/net/igb_core.c | 5 +++-- hw/net/virtio-net.c | 19 +++++++++++-------- hw/net/vmxnet3.c | 13 +++++-------- include/net/net.h | 15 ++++++++++++--- net/net.c | 5 ++--- net/netmap.c | 3 +-- net/tap-bsd.c | 3 +-- net/tap-linux.c | 21 ++++++++++++--------- net/tap-solaris.c | 4 ++-- net/tap-stub.c | 3 +-- net/tap.c | 8 ++++---- net/tap_int.h | 4 ++-- 13 files changed, 59 insertions(+), 49 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 06657bb3ac..8fef598b49 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -2822,8 +2822,9 @@ e1000e_update_rx_offloads(E1000ECore *core) trace_e1000e_rx_set_cso(cso_state); =20 if (core->has_vnet) { - qemu_set_offload(qemu_get_queue(core->owner_nic)->peer, - cso_state, 0, 0, 0, 0, 0, 0); + NetOffloads ol =3D { .csum =3D cso_state }; + + qemu_set_offload(qemu_get_queue(core->owner_nic)->peer, &ol); } } =20 diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 39e3ce1c8f..45d8fd795b 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -3058,8 +3058,9 @@ igb_update_rx_offloads(IGBCore *core) trace_e1000e_rx_set_cso(cso_state); =20 if (core->has_vnet) { - qemu_set_offload(qemu_get_queue(core->owner_nic)->peer, - cso_state, 0, 0, 0, 0, 0, 0); + NetOffloads ol =3D {.csum =3D cso_state }; + + qemu_set_offload(qemu_get_queue(core->owner_nic)->peer, &ol); } } =20 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 6b5b5dace3..b86ba1fd27 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -773,14 +773,17 @@ static uint64_t virtio_net_bad_features(VirtIODevice = *vdev) =20 static void virtio_net_apply_guest_offloads(VirtIONet *n) { - qemu_set_offload(qemu_get_queue(n->nic)->peer, - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_CSUM)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_TSO4)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_TSO6)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_ECN)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_UFO)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_USO4)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_USO6))= ); + NetOffloads ol =3D { + .csum =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_C= SUM)), + .tso4 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_T= SO4)), + .tso6 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_T= SO6)), + .ecn =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_E= CN)), + .ufo =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_U= FO)), + .uso4 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_U= SO4)), + .uso6 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_U= SO6)), + }; + + qemu_set_offload(qemu_get_queue(n->nic)->peer, &ol); } =20 static uint64_t virtio_net_guest_offloads_by_features(uint64_t features) diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index af73aa8ef2..03732375a7 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -1322,14 +1322,11 @@ static void vmxnet3_update_features(VMXNET3State *s) s->lro_supported, rxcso_supported, s->rx_vlan_stripping); if (s->peer_has_vhdr) { - qemu_set_offload(qemu_get_queue(s->nic)->peer, - rxcso_supported, - s->lro_supported, - s->lro_supported, - 0, - 0, - 0, - 0); + NetOffloads ol =3D { .csum =3D rxcso_supported, + .tso4 =3D s->lro_supported, + .tso6 =3D s->lro_supported }; + + qemu_set_offload(qemu_get_queue(s->nic)->peer, &ol); } } =20 diff --git a/include/net/net.h b/include/net/net.h index 84ee18e0f9..48ba333d02 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -35,6 +35,16 @@ typedef struct NICConf { int32_t bootindex; } NICConf; =20 +typedef struct NetOffloads { + bool csum; + bool tso4; + bool tso6; + bool ecn; + bool ufo; + bool uso4; + bool uso6; +} NetOffloads; + #define DEFINE_NIC_PROPERTIES(_state, _conf) \ DEFINE_PROP_MACADDR("mac", _state, _conf.macaddr), \ DEFINE_PROP_NETDEV("netdev", _state, _conf.peers) @@ -57,7 +67,7 @@ typedef bool (HasUfo)(NetClientState *); typedef bool (HasUso)(NetClientState *); typedef bool (HasVnetHdr)(NetClientState *); typedef bool (HasVnetHdrLen)(NetClientState *, int); -typedef void (SetOffload)(NetClientState *, int, int, int, int, int, int, = int); +typedef void (SetOffload)(NetClientState *, const NetOffloads *); typedef int (GetVnetHdrLen)(NetClientState *); typedef void (SetVnetHdrLen)(NetClientState *, int); typedef bool (GetVnetHashSupportedTypes)(NetClientState *, uint32_t *); @@ -189,8 +199,7 @@ 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); -void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6, - int ecn, int ufo, int uso4, int uso6); +void qemu_set_offload(NetClientState *nc, const NetOffloads *ol); int qemu_get_vnet_hdr_len(NetClientState *nc); void qemu_set_vnet_hdr_len(NetClientState *nc, int len); bool qemu_get_vnet_hash_supported_types(NetClientState *nc, uint32_t *type= s); diff --git a/net/net.c b/net/net.c index da275db86e..63872b6855 100644 --- a/net/net.c +++ b/net/net.c @@ -540,14 +540,13 @@ bool qemu_has_vnet_hdr_len(NetClientState *nc, int le= n) return nc->info->has_vnet_hdr_len(nc, len); } =20 -void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6, - int ecn, int ufo, int uso4, int uso6) +void qemu_set_offload(NetClientState *nc, const NetOffloads *ol) { if (!nc || !nc->info->set_offload) { return; } =20 - nc->info->set_offload(nc, csum, tso4, tso6, ecn, ufo, uso4, uso6); + nc->info->set_offload(nc, ol); } =20 int qemu_get_vnet_hdr_len(NetClientState *nc) diff --git a/net/netmap.c b/net/netmap.c index 297510e190..6cd8f2bdc5 100644 --- a/net/netmap.c +++ b/net/netmap.c @@ -366,8 +366,7 @@ static void netmap_set_vnet_hdr_len(NetClientState *nc,= int len) } } =20 -static void netmap_set_offload(NetClientState *nc, int csum, int tso4, int= tso6, - int ecn, int ufo, int uso4, int uso6) +static void netmap_set_offload(NetClientState *nc, const NetOffloads *ol) { NetmapState *s =3D DO_UPCAST(NetmapState, nc, nc); =20 diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 3f98d0ea82..38eb28cb58 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -239,8 +239,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) return -EINVAL; } =20 -void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo, int uso4, int uso6) +void tap_fd_set_offload(int fd, const NetOffloads *ol) { } =20 diff --git a/net/tap-linux.c b/net/tap-linux.c index e832810665..79a9dd0da0 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -244,8 +244,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) abort(); } =20 -void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo, int uso4, int uso6) +void tap_fd_set_offload(int fd, const NetOffloads *ol) { unsigned int offload =3D 0; =20 @@ -254,20 +253,24 @@ void tap_fd_set_offload(int fd, int csum, int tso4, return; } =20 - if (csum) { + if (ol->csum) { offload |=3D TUN_F_CSUM; - if (tso4) + if (ol->tso4) { offload |=3D TUN_F_TSO4; - if (tso6) + } + if (ol->tso6) { offload |=3D TUN_F_TSO6; - if ((tso4 || tso6) && ecn) + } + if ((ol->tso4 || ol->tso6) && ol->ecn) { offload |=3D TUN_F_TSO_ECN; - if (ufo) + } + if (ol->ufo) { offload |=3D TUN_F_UFO; - if (uso4) { + } + if (ol->uso4) { offload |=3D TUN_F_USO4; } - if (uso6) { + if (ol->uso6) { offload |=3D TUN_F_USO6; } } diff --git a/net/tap-solaris.c b/net/tap-solaris.c index af2ebb16f5..ef8e0feeb0 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -27,6 +27,7 @@ #include "tap_int.h" #include "qemu/ctype.h" #include "qemu/cutils.h" +#include "net/net.h" =20 #include #include @@ -240,8 +241,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) return -EINVAL; } =20 -void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo, int uso4, int uso6) +void tap_fd_set_offload(int fd, const NetOffloads *ol) { } =20 diff --git a/net/tap-stub.c b/net/tap-stub.c index 38673434cb..67d14ad4d5 100644 --- a/net/tap-stub.c +++ b/net/tap-stub.c @@ -66,8 +66,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) return -EINVAL; } =20 -void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo, int uso4, int uso6) +void tap_fd_set_offload(int fd, const NetOffloads *ol) { } =20 diff --git a/net/tap.c b/net/tap.c index f37133e301..df23283744 100644 --- a/net/tap.c +++ b/net/tap.c @@ -285,15 +285,14 @@ static int tap_set_vnet_be(NetClientState *nc, bool i= s_be) return tap_fd_set_vnet_be(s->fd, is_be); } =20 -static void tap_set_offload(NetClientState *nc, int csum, int tso4, - int tso6, int ecn, int ufo, int uso4, int uso6) +static void tap_set_offload(NetClientState *nc, const NetOffloads *ol) { TAPState *s =3D DO_UPCAST(TAPState, nc, nc); if (s->fd < 0) { return; } =20 - tap_fd_set_offload(s->fd, csum, tso4, tso6, ecn, ufo, uso4, uso6); + tap_fd_set_offload(s->fd, ol); } =20 static void tap_exit_notify(Notifier *notifier, void *data) @@ -391,6 +390,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer, int fd, int vnet_hdr) { + NetOffloads ol =3D {}; NetClientState *nc; TAPState *s; =20 @@ -404,7 +404,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer, s->has_ufo =3D tap_probe_has_ufo(s->fd); s->has_uso =3D tap_probe_has_uso(s->fd); s->enabled =3D true; - tap_set_offload(&s->nc, 0, 0, 0, 0, 0, 0, 0); + tap_set_offload(&s->nc, &ol); /* * Make sure host header length is set correctly in tap: * it might have been modified by another instance of qemu. diff --git a/net/tap_int.h b/net/tap_int.h index 8857ff299d..f8bbe1cb0c 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -27,6 +27,7 @@ #define NET_TAP_INT_H =20 #include "qapi/qapi-types-net.h" +#include "net/net.h" =20 int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required, int mq_required, Error **errp); @@ -37,8 +38,7 @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, = Error **errp); int tap_probe_vnet_hdr(int fd, Error **errp); int tap_probe_has_ufo(int fd); int tap_probe_has_uso(int fd); -void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int= ufo, - int uso4, int uso6); +void tap_fd_set_offload(int fd, const NetOffloads *ol); void tap_fd_set_vnet_hdr_len(int fd, int len); int tap_fd_set_vnet_le(int fd, int vnet_is_le); int tap_fd_set_vnet_be(int fd, int vnet_is_be); --=20 2.51.0