From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id ED227A00BE; Mon, 25 Apr 2022 15:05:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CA0A741109; Mon, 25 Apr 2022 15:05:03 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id AC54B40E78 for ; Mon, 25 Apr 2022 15:05:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650891901; 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: in-reply-to:in-reply-to:references:references; bh=cMEoC34BXU8+t4rQ6h07b1JM7XkMe1M0Ng8sQnic9Sc=; b=fn/qKWKHwtln5M3JOwmmb+cKeQM4gDEuDd9de0CXwlgT2yYutlZB7a836tHcWCFCLinw0Y 56OoGet6E82HnnvsaS2q0TU05VHRVKPYVu+LgWy9hJxg6aYpLIXhEKGTsCUOEzY4EjpCso OPlctPokJoo9P+l0Weo/+281St/R9So= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-635-hul_kgn7MnWmRscxe-7x3Q-1; Mon, 25 Apr 2022 09:04:58 -0400 X-MC-Unique: hul_kgn7MnWmRscxe-7x3Q-1 Received: by mail-lf1-f70.google.com with SMTP id x17-20020a19e011000000b004713b5759fcso6273172lfg.20 for ; Mon, 25 Apr 2022 06:04:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cMEoC34BXU8+t4rQ6h07b1JM7XkMe1M0Ng8sQnic9Sc=; b=Wj+iZZQShx8h7Cms+oq3MjM5Hbyqu77O55LJOpfAHwio6TkHN4rGIa72+6FJgqlGxh FnERONAzeu4CIHPay4xdCaQLsOzOvNbKklRaM82M1IrmwnzX9wSXfODg1ocF3hJRpMzd GR1AQGY2AmMTA8+agf/lAE5XhfdD2Xx+wf12DgIN5uKV2kffSoQay1y78e6IQuFyysit KVYQPke87PTD00rKoYP5WDa6Y5F7PQXtOx9IhGqdlvLagEwurxaJ5ns1DdvifiuQYc7e E7/+DOrr+aOAU3yXVU3qlf1HD1OeXFVDPzszAoHFmQ1qttmSSdSXOItEucuWYmS6NQAa CjrA== X-Gm-Message-State: AOAM531HaxC95kolN13vYuzBaJ1uA3yB/4fcg9g1YFA2Ua5sk3ynf5OS vtqJ8tKt7u8dZQxWl8QNOsmOxl490fO5Y+BHo41Cy1AVwvS2qirmpQ0pZnGiUkyjpEwXCIFWtwl 1fBrPICDIxrgp4lrNt9U= X-Received: by 2002:a05:6512:250d:b0:472:816:f613 with SMTP id be13-20020a056512250d00b004720816f613mr3105537lfb.265.1650891896377; Mon, 25 Apr 2022 06:04:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRaHhzanyLAtGrZnItWyIlD79uMfDcvOyhT4irdCy6uu+8EY9sBZLpsJUNec2WLralC8AV8t825rKQyN7BuzE= X-Received: by 2002:a05:6512:250d:b0:472:816:f613 with SMTP id be13-20020a056512250d00b004720816f613mr3105514lfb.265.1650891896117; Mon, 25 Apr 2022 06:04:56 -0700 (PDT) MIME-Version: 1.0 References: <1643093258-47258-2-git-send-email-andy.pei@intel.com> <1650530034-59744-1-git-send-email-andy.pei@intel.com> <1650530034-59744-4-git-send-email-andy.pei@intel.com> In-Reply-To: <1650530034-59744-4-git-send-email-andy.pei@intel.com> From: David Marchand Date: Mon, 25 Apr 2022 15:04:45 +0200 Message-ID: Subject: Re: [PATCH v6 03/16] vhost: add vhost msg support To: Andy Pei Cc: dev , "Xia, Chenbo" , Maxime Coquelin , gang.cao@intel.com, "Liu, Changpeng" Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Thu, Apr 21, 2022 at 11:20 AM Andy Pei wrote: > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c > index 1d39067..3780804 100644 > --- a/lib/vhost/vhost_user.c > +++ b/lib/vhost/vhost_user.c > @@ -80,6 +80,8 @@ > [VHOST_USER_NET_SET_MTU] = "VHOST_USER_NET_SET_MTU", > [VHOST_USER_SET_SLAVE_REQ_FD] = "VHOST_USER_SET_SLAVE_REQ_FD", > [VHOST_USER_IOTLB_MSG] = "VHOST_USER_IOTLB_MSG", > + [VHOST_USER_GET_CONFIG] = "VHOST_USER_GET_CONFIG", > + [VHOST_USER_SET_CONFIG] = "VHOST_USER_SET_CONFIG", > [VHOST_USER_CRYPTO_CREATE_SESS] = "VHOST_USER_CRYPTO_CREATE_SESS", > [VHOST_USER_CRYPTO_CLOSE_SESS] = "VHOST_USER_CRYPTO_CLOSE_SESS", > [VHOST_USER_POSTCOPY_ADVISE] = "VHOST_USER_POSTCOPY_ADVISE", > @@ -2542,6 +2544,71 @@ static int is_vring_iotlb(struct virtio_net *dev, > } > > static int > +vhost_user_get_config(struct virtio_net **pdev, > + struct vhu_msg_context *ctx, > + int main_fd __rte_unused) > +{ > + struct virtio_net *dev = *pdev; > + struct rte_vdpa_device *vdpa_dev = dev->vdpa_dev; > + int ret = 0; You must check if there is any fd attached to this message. > + > + if (vdpa_dev->ops->get_config) { > + ret = vdpa_dev->ops->get_config(dev->vid, > + ctx->msg.payload.cfg.region, > + ctx->msg.payload.cfg.size); > + if (ret != 0) { > + ctx->msg.size = 0; > + VHOST_LOG_CONFIG(ERR, > + "(%s) get_config() return error!\n", > + dev->ifname); > + } > + } else { > + VHOST_LOG_CONFIG(ERR, "(%s) get_config() not supportted!\n", > + dev->ifname); > + } > + > + return RTE_VHOST_MSG_RESULT_REPLY; > +} > + > +static int > +vhost_user_set_config(struct virtio_net **pdev, > + struct vhu_msg_context *ctx, > + int main_fd __rte_unused) > +{ > + struct virtio_net *dev = *pdev; > + struct rte_vdpa_device *vdpa_dev = dev->vdpa_dev; > + int ret = 0; Idem. > + > + if (ctx->msg.size != sizeof(struct vhost_user_config)) { > + VHOST_LOG_CONFIG(ERR, > + "(%s) invalid set config msg size: %"PRId32" != %d\n", > + dev->ifname, ctx->msg.size, > + (int)sizeof(struct vhost_user_config)); > + goto OUT; > + } For info, I posted a series to make this kind of check more systematic. See: https://patchwork.dpdk.org/project/dpdk/patch/20220425125431.26464-2-david.marchand@redhat.com/ -- David Marchand