From patchwork Tue Aug 9 17:39:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 12939836 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 F25AAC19F2D for ; Tue, 9 Aug 2022 17:46:43 +0000 (UTC) Received: from localhost ([::1]:58204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLTJS-0003ZD-Sl for qemu-devel@archiver.kernel.org; Tue, 09 Aug 2022 13:46:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTD6-00036M-Rd for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:40:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48037) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTD5-0007qd-Ar for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:40:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660066806; 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=fVKNcUCud4Rn+/eE64g6UY4J13Lxx1ahKJKtYI7cMUc=; b=iWPEG1kG1cVIwBBuCUYzXeBQaC48wM2bO+4Rv3X0Gk+k1fQycxk+zXU1ZCes2naa3kUGOR 0pnRnDaMr1KGfeH9qMYqBI8ldwq15PgDIVdX+7x7QFuGlo76Arl2EF/Wh9k5o84c080wZ9 AWZMdQDpmZvSExpXwANKnwgFiPnXXG8= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-76-yndjwKe6Md-072m24C2OWA-1; Tue, 09 Aug 2022 13:40:05 -0400 X-MC-Unique: yndjwKe6Md-072m24C2OWA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CEE621C06EDF; Tue, 9 Aug 2022 17:40:03 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62CAE9457F; Tue, 9 Aug 2022 17:40:00 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Gautam Dawar , Laurent Vivier , Liuxiangdong , Jason Wang , Cindy Lu , "Gonglei (Arei)" , Zhu Lingshan , Eric Blake , Cornelia Huck , Eli Cohen , Paolo Bonzini , Stefano Garzarella , Markus Armbruster , "Michael S. Tsirkin" , Stefan Hajnoczi , Parav Pandit Subject: [PATCH v8 10/12] vhost_net: add NetClientState->load() callback Date: Tue, 9 Aug 2022 19:39:24 +0200 Message-Id: <20220809173926.1695280-11-eperezma@redhat.com> In-Reply-To: <20220809173926.1695280-1-eperezma@redhat.com> References: <20220809173926.1695280-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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" It allows per-net client operations right after device's successful start. In particular, to load the device status. Vhost-vdpa net will use it to add the CVQ buffers to restore the device status. Signed-off-by: Eugenio PĂ©rez Acked-by: Jason Wang --- v5: Rename start / load, naming it more specifically. --- include/net/net.h | 2 ++ hw/net/vhost_net.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index 476ad45b9a..81d0b21def 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -45,6 +45,7 @@ typedef struct NICConf { typedef void (NetPoll)(NetClientState *, bool enable); typedef bool (NetCanReceive)(NetClientState *); typedef int (NetStart)(NetClientState *); +typedef int (NetLoad)(NetClientState *); typedef void (NetStop)(NetClientState *); typedef ssize_t (NetReceive)(NetClientState *, const uint8_t *, size_t); typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, int); @@ -74,6 +75,7 @@ typedef struct NetClientInfo { NetReceiveIOV *receive_iov; NetCanReceive *can_receive; NetStart *start; + NetLoad *load; NetStop *stop; NetCleanup *cleanup; LinkStatusChanged *link_status_changed; diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 9d4b334453..d28f8b974b 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -281,6 +281,13 @@ static int vhost_net_start_one(struct vhost_net *net, } } } + + if (net->nc->info->load) { + r = net->nc->info->load(net->nc); + if (r < 0) { + goto fail; + } + } return 0; fail: file.fd = -1;