From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 879282566D9 for ; Tue, 8 Jul 2025 07:09:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751958599; cv=none; b=kA5LOwiokw6csE3h4SO/Msw3W0ojx1fbaUJ29jotzU+4vcbPWoBMiN93abgUt+pwcCiCJE8MTTI4tFZtwHurYZG+sd4WFDmVqRzz+4QFYwcajBNbyOylfxXdwADCABUNZMP3PB24GC+o38TwX64NvPvVjlb5TcFSJhBGwyJtrDE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751958599; c=relaxed/simple; bh=RfiVbzd4N84I4zYTlWrLhkzX3qnBzcKJsoMC0Ta6iqg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LO9ChtA19RdXBThH+yWvMC/Z3hjF1kLZf2SdCivjJLxqcvDqPTZjagNg/RBFvxY0Ua9C9lVu2XvCMKQrkS+f0bCfIyZ5Gk79KTMSZmG0QcDS6MpnAaDL94ZD4Zg3P3rm/gKu8SHfCVotJAB+ZBy37qxeFDOQ3xoPBlGAWNod4/Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Y0SEty5Q; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Y0SEty5Q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751958596; 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=ME3Sp0L5kybzZSCfVybZkMKTEWiUzAhs5CYz2hx18n8=; b=Y0SEty5QGw889wIliv4IQBGiIRtuM819Noww6CWRTIikS90S26h15cJE0NghF+s/YK52qc nq360EnnZTlFL1R+FXcQPDylAQvQlH2VVqg2k68DSqSxxogkD0UmK6upzkeHKfB6PSdTYu oXQna/Gp4+RLQYKsoS/jyoBPOKqcGJs= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-_mxu0o7NM2uZOoLjVxyWBg-1; Tue, 08 Jul 2025 03:09:53 -0400 X-MC-Unique: _mxu0o7NM2uZOoLjVxyWBg-1 X-Mimecast-MFC-AGG-ID: _mxu0o7NM2uZOoLjVxyWBg_1751958591 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0DAD7180A8FF; Tue, 8 Jul 2025 07:09:51 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.44.32.252]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 233D1195608F; Tue, 8 Jul 2025 07:09:45 +0000 (UTC) From: Paolo Abeni To: netdev@vger.kernel.org Cc: Willem de Bruijn , Jason Wang , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Michael S. Tsirkin" , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Yuri Benditovich , Akihiko Odaki , Jonathan Corbet , kvm@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v7 net-next 5/9] virtio_net: add supports for extended offloads Date: Tue, 8 Jul 2025 09:09:01 +0200 Message-ID: <82a5589e753192a82c69d74ec32938e385a44680.1751874094.git.pabeni@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 The virtio_net driver needs it to implement GSO over UDP tunnel offload. The only missing piece is mapping them to/from the extended features. Acked-by: Jason Wang Signed-off-by: Paolo Abeni --- v4 -> v5: - avoid lines longer than 80 chars v2 -> v3: - offload to feature conversion is now an inline function v1 -> v2: - drop unused macro - restrict the offload remap range as per latest spec update --- drivers/net/virtio_net.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 9f6e0153ed2d..6f86a8edc981 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -35,6 +35,23 @@ module_param(csum, bool, 0444); module_param(gso, bool, 0444); module_param(napi_tx, bool, 0644); +#define VIRTIO_OFFLOAD_MAP_MIN 46 +#define VIRTIO_OFFLOAD_MAP_MAX 47 +#define VIRTIO_FEATURES_MAP_MIN 65 +#define VIRTIO_O2F_DELTA (VIRTIO_FEATURES_MAP_MIN - \ + VIRTIO_OFFLOAD_MAP_MIN) + +static bool virtio_is_mapped_offload(unsigned int obit) +{ + return obit >= VIRTIO_OFFLOAD_MAP_MIN && + obit <= VIRTIO_OFFLOAD_MAP_MAX; +} + +static unsigned int virtio_offload_to_feature(unsigned int obit) +{ + return virtio_is_mapped_offload(obit) ? obit + VIRTIO_O2F_DELTA : obit; +} + /* FIXME: MTU in config. */ #define GOOD_PACKET_LEN (ETH_HLEN + VLAN_HLEN + ETH_DATA_LEN) #define GOOD_COPY_LEN 128 @@ -7055,9 +7072,13 @@ static int virtnet_probe(struct virtio_device *vdev) netif_carrier_on(dev); } - for (i = 0; i < ARRAY_SIZE(guest_offloads); i++) - if (virtio_has_feature(vi->vdev, guest_offloads[i])) + for (i = 0; i < ARRAY_SIZE(guest_offloads); i++) { + unsigned int fbit; + + fbit = virtio_offload_to_feature(guest_offloads[i]); + if (virtio_has_feature(vi->vdev, fbit)) set_bit(guest_offloads[i], &vi->guest_offloads); + } vi->guest_offloads_capable = vi->guest_offloads; rtnl_unlock(); -- 2.49.0