From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 14B41C77B7A for ; Mon, 29 May 2023 16:23:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3feK-0000Yw-37; Mon, 29 May 2023 12:23:12 -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 1q3feH-0000Yn-SN for qemu-devel@nongnu.org; Mon, 29 May 2023 12:23:09 -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 1q3feF-0004Vs-Ak for qemu-devel@nongnu.org; Mon, 29 May 2023 12:23:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685377385; 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=wEXWBeXPsVG7W0oNxPvQcfM6uN38qZ1qgEkgwug1mGU=; b=DMzyPfHIxMssW2vXR/iDU18VWvzU6DO6RhwhAgh/cuJfnaltl0TT28i5y5glALxTHlX3hp dqrlprwtRYKIhCFe0Iyn3AdqhqgwNfQiMJqasE8Rj/kLzjeZCbwSZk6mmDe3HKhsPcdnr+ 5JMgiYxcUWbzDnFjegQxTxD6pKGkF9k= Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-649-L8oDfL5yMdydL5amJhPH4w-1; Mon, 29 May 2023 12:19:36 -0400 X-MC-Unique: L8oDfL5yMdydL5amJhPH4w-1 Received: by mail-yb1-f198.google.com with SMTP id 3f1490d57ef6-ba802c775caso7118620276.2 for ; Mon, 29 May 2023 09:19:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685377176; x=1687969176; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wEXWBeXPsVG7W0oNxPvQcfM6uN38qZ1qgEkgwug1mGU=; b=V8Atav5FXOtSlVynxbDtpa/mUzUB+N3lwlwD0vo4P0jSk2WYoT5HCWlu/Mr3MSL6ka KGG+VtAWKo0V5yUved++CrvemDHKrZOUf6BgVQKIHgmfKacZuj/AayyaAL4Nc76tLXJW 4y6zQvtMQ/aUBZskxdbhSXxdXd+OwG7md2+x0t1hjFFUTUOaH/IpOVOXNeBJhruvE8CV IH6g5g7xxxFwt4nxau0y8h0YYlaRBmAui7K21JVo3CbV7rKXJOZlifK4XNxWOIR3QAbG jYG5tUAjPfj00eZg6PBv+g3nqfD6rtF7SUT87eB5cZR2JWAUoODGhc4mOq+D9uM/2O54 nc+w== X-Gm-Message-State: AC+VfDzlC2+57KztdUqFGyanVkAb9RGKDPp1C4kfcZHX5NnDveZFos4s PFmN3C9HHvi2uNQN847HLmwS94VMsioP0HjjSqFWGwsnZo9KWk/ifykN1AB7y5/gbTO1jCgvjA2 9R0ue47B7KPzb7L3ap7YtnYu47M8nuI4= X-Received: by 2002:a25:b84b:0:b0:ba1:d8a6:d2b2 with SMTP id b11-20020a25b84b000000b00ba1d8a6d2b2mr11923642ybm.7.1685377176484; Mon, 29 May 2023 09:19:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5b4emE8b70LqbTuL7zL+E+WiClNthfxFqIPTysBxgLG2uWqFWLy2nuGFz7neAQ8SZeEiD+xPzSbjcp54IhUt4= X-Received: by 2002:a25:b84b:0:b0:ba1:d8a6:d2b2 with SMTP id b11-20020a25b84b000000b00ba1d8a6d2b2mr11923629ybm.7.1685377176247; Mon, 29 May 2023 09:19:36 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Eugenio Perez Martin Date: Mon, 29 May 2023 18:19:00 +0200 Message-ID: Subject: Re: [PATCH 1/2] vdpa: Add vhost_vdpa_net_load_offloads To: Hawkins Jiawei Cc: Jason Wang , 18801353760@163.com, qemu-devel@nongnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.16, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On Mon, May 29, 2023 at 3:18=E2=80=AFPM Hawkins Jiawei = wrote: > > This patch introduces vhost_vdpa_net_load_offloads() to > restore offloads state at device's startup. > > Signed-off-by: Hawkins Jiawei > --- > net/vhost-vdpa.c | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c > index 37cdc84562..682c749b19 100644 > --- a/net/vhost-vdpa.c > +++ b/net/vhost-vdpa.c > @@ -680,6 +680,28 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s, > return *s->status !=3D VIRTIO_NET_OK; > } > > +static int vhost_vdpa_net_load_offloads(VhostVDPAState *s, > + const VirtIONet *n) > +{ > + uint64_t features, offloads; > + ssize_t dev_written; > + > + features =3D n->parent_obj.guest_features; > + if (!(features & BIT_ULL(VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))) { > + return 0; > + } > + Maybe we can avoid sending this CVQ command if the guest already uses the default values? By default all features are enabled if I'm not wrong. I think the best way is to expose virtio_net_supported_guest_offloads or virtio_net_guest_offloads_by_features and then check if n->curr_guest_offloads is the same. We should do the same with vhost_vdpa_net_load_mq, but that is out of the scope of this series. Thanks! > + offloads =3D cpu_to_le64(n->curr_guest_offloads); > + dev_written =3D vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_GUEST_OFF= LOADS, > + VIRTIO_NET_CTRL_GUEST_OFFLOADS= _SET, > + &offloads, sizeof(offloads)); > + if (unlikely(dev_written < 0)) { > + return dev_written; > + } > + > + return *s->status !=3D VIRTIO_NET_OK; > +} > + > static int vhost_vdpa_net_load(NetClientState *nc) > { > VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); > @@ -702,6 +724,10 @@ static int vhost_vdpa_net_load(NetClientState *nc) > if (unlikely(r)) { > return r; > } > + r =3D vhost_vdpa_net_load_offloads(s, n); > + if (unlikely(r)) { > + return r; > + } > > return 0; > } > -- > 2.25.1 >