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 E301EA0032; Thu, 12 May 2022 05:51:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CEE70410EF; Thu, 12 May 2022 05:51:02 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id CE9ED40E64 for ; Thu, 12 May 2022 05:51:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652327462; x=1683863462; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=4c2UD0m9ax5MhXCJfRWCDp2yZItljmxuV5qv/lcZ3Nc=; b=Q0dicSTDYDrPDtbPrdHNhFe4zwbh7tvXwhtaL5JFiqJ5Zahw9gEkGNNG zMQY6wsRHx7XaSYUDchGjc/U4qwJ0ydFS9bXAvWpTfx1KUzlGoRMX2NWB UOZWRYXa1Ym+LN6jIJrg0eI4/hU4cvTn5buwlUmNIdLtkoAxQje0FuqVH +WRY2E7j25lgwRXc/lXPU+9TnLBkq8d+R3IywA3C2ZN6592sGr3zHbaC4 rgiXiYB4bRh1xjVhc9QAskQ1AEz29MR5kntnFdKEh+Wo03nDTLIxkeGmV iKyCEvmZ9Io2BN7+8hYfMFm4SbKpCeE1rvTaBYFvG9G6OvTKranLKPmRU g==; X-IronPort-AV: E=McAfee;i="6400,9594,10344"; a="295126773" X-IronPort-AV: E=Sophos;i="5.91,218,1647327600"; d="scan'208";a="295126773" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2022 20:51:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,218,1647327600"; d="scan'208";a="697855450" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga004.jf.intel.com with ESMTP; 11 May 2022 20:51:00 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Wed, 11 May 2022 20:50:59 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Wed, 11 May 2022 20:50:58 -0700 Received: from orsmsx612.amr.corp.intel.com ([10.22.229.25]) by ORSMSX612.amr.corp.intel.com ([10.22.229.25]) with mapi id 15.01.2308.027; Wed, 11 May 2022 20:50:58 -0700 From: "Pei, Andy" To: "Xia, Chenbo" , "dev@dpdk.org" CC: "maxime.coquelin@redhat.com" , "Cao, Gang" , "Liu, Changpeng" Subject: RE: [PATCH v7 03/18] vhost: add vhost msg support Thread-Topic: [PATCH v7 03/18] vhost: add vhost msg support Thread-Index: AQHYWhd+zqLnkL0xmEqLVNBnH+IJJq0Z0EswgADiJ7A= Date: Thu, 12 May 2022 03:50:58 +0000 Message-ID: <5b8c366f74f64d89abdb41d9e5bc6d03@intel.com> References: <1643093258-47258-2-git-send-email-andy.pei@intel.com> <1651048206-282372-1-git-send-email-andy.pei@intel.com> <1651048206-282372-4-git-send-email-andy.pei@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.6.401.20 dlp-reaction: no-action x-originating-ip: [10.239.127.36] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 Hi Chenbo, Thanks for your reply. > -----Original Message----- > From: Xia, Chenbo > Sent: Wednesday, May 11, 2022 10:24 PM > To: Pei, Andy ; dev@dpdk.org > Cc: maxime.coquelin@redhat.com; Cao, Gang ; Liu, > Changpeng > Subject: RE: [PATCH v7 03/18] vhost: add vhost msg support >=20 > > -----Original Message----- > > From: Pei, Andy > > Sent: Wednesday, April 27, 2022 4:30 PM > > To: dev@dpdk.org > > Cc: Xia, Chenbo ; maxime.coquelin@redhat.com; > > Cao, Gang ; Liu, Changpeng > > > > Subject: [PATCH v7 03/18] vhost: add vhost msg support >=20 > Title better be: vhost: add vhost msg support for get/set config >=20 Sure.=20 > > > > Add support for VHOST_USER_GET_CONFIG and > VHOST_USER_SET_CONFIG. > > VHOST_USER_GET_CONFIG and VHOST_USER_SET_CONFIG message is only > > supported by virtio blk VDPA device. > > > > Signed-off-by: Andy Pei > > --- > > lib/vhost/vhost_user.c | 83 > > ++++++++++++++++++++++++++++++++++++++++++++++++++ > > lib/vhost/vhost_user.h | 13 ++++++++ > > 2 files changed, 96 insertions(+) > > > > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index > > 1d39067..e925428 100644 > > --- a/lib/vhost/vhost_user.c > > +++ b/lib/vhost/vhost_user.c > > @@ -80,6 +80,8 @@ > > [VHOST_USER_NET_SET_MTU] =3D "VHOST_USER_NET_SET_MTU", > > [VHOST_USER_SET_SLAVE_REQ_FD] =3D > "VHOST_USER_SET_SLAVE_REQ_FD", > > [VHOST_USER_IOTLB_MSG] =3D "VHOST_USER_IOTLB_MSG", > > + [VHOST_USER_GET_CONFIG] =3D "VHOST_USER_GET_CONFIG", > > + [VHOST_USER_SET_CONFIG] =3D "VHOST_USER_SET_CONFIG", > > [VHOST_USER_CRYPTO_CREATE_SESS] =3D > "VHOST_USER_CRYPTO_CREATE_SESS", > > [VHOST_USER_CRYPTO_CLOSE_SESS] =3D > "VHOST_USER_CRYPTO_CLOSE_SESS", > > [VHOST_USER_POSTCOPY_ADVISE] =3D > "VHOST_USER_POSTCOPY_ADVISE", @@ > > -2542,6 +2544,85 @@ 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 =3D *pdev; > > + struct rte_vdpa_device *vdpa_dev =3D dev->vdpa_dev; > > + int ret =3D 0; > > + > > + if (validate_msg_fds(dev, ctx, 0) !=3D 0) > > + return RTE_VHOST_MSG_RESULT_ERR; > > + > > + if (vdpa_dev->ops->get_config) { > > + ret =3D vdpa_dev->ops->get_config(dev->vid, > > + ctx->msg.payload.cfg.region, > > + ctx->msg.payload.cfg.size); > > + if (ret !=3D 0) { > > + ctx->msg.size =3D 0; > > + VHOST_LOG_CONFIG(ERR, > > + "(%s) get_config() return error!\n", > > + dev->ifname); > > + } > > + } else { > > + VHOST_LOG_CONFIG(ERR, "(%s) get_config() not > supported!\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 =3D *pdev; > > + struct rte_vdpa_device *vdpa_dev =3D dev->vdpa_dev; > > + int ret =3D 0; > > + > > + if (validate_msg_fds(dev, ctx, 0) !=3D 0) > > + return RTE_VHOST_MSG_RESULT_ERR; > > + > > + if (ctx->msg.size !=3D sizeof(struct vhost_user_config)) { > > + VHOST_LOG_CONFIG(ERR, > > + "(%s) invalid set config msg size: %"PRIu32" !=3D %d\n", > > + dev->ifname, ctx->msg.size, > > + (int)sizeof(struct vhost_user_config)); > > + goto out; > > + } >=20 > Sorry, I was wrong in v6, after double check, the size can be checked in > read_vhost_message (although not that accurate check). So we can remove > above. (btw, even we check, the logic should Be size <=3D sizeof(config)) >=20 > Rest of the patch seems good, thanks. >=20 > Chenbo >=20 OK. I will remove ctx->msg.size check here. > > + > > + if (ctx->msg.payload.cfg.size > VHOST_USER_MAX_CONFIG_SIZE) { > > + VHOST_LOG_CONFIG(ERR, > > + "(%s) vhost_user_config size: %"PRIu32", should not > be > > larger than %d\n", > > + dev->ifname, ctx->msg.payload.cfg.size, > > + VHOST_USER_MAX_CONFIG_SIZE); > > + goto out; > > + } > > + > > + if (vdpa_dev->ops->set_config) { > > + ret =3D vdpa_dev->ops->set_config(dev->vid, > > + ctx->msg.payload.cfg.region, > > + ctx->msg.payload.cfg.offset, > > + ctx->msg.payload.cfg.size, > > + ctx->msg.payload.cfg.flags); > > + if (ret) > > + VHOST_LOG_CONFIG(ERR, > > + "(%s) set_config() return error!\n", > > + dev->ifname); > > + } else { > > + VHOST_LOG_CONFIG(ERR, "(%s) set_config() not > supported!\n", > > + dev->ifname); > > + } > > + > > + return RTE_VHOST_MSG_RESULT_OK; > > + > > +out: > > + return RTE_VHOST_MSG_RESULT_ERR; > > +} > > + > > +static int > > vhost_user_iotlb_msg(struct virtio_net **pdev, > > struct vhu_msg_context *ctx, > > int main_fd __rte_unused) > > @@ -2782,6 +2863,8 @@ typedef int (*vhost_message_handler_t)(struct > > virtio_net **pdev, > > [VHOST_USER_NET_SET_MTU] =3D vhost_user_net_set_mtu, > > [VHOST_USER_SET_SLAVE_REQ_FD] =3D vhost_user_set_req_fd, > > [VHOST_USER_IOTLB_MSG] =3D vhost_user_iotlb_msg, > > + [VHOST_USER_GET_CONFIG] =3D vhost_user_get_config, > > + [VHOST_USER_SET_CONFIG] =3D vhost_user_set_config, > > [VHOST_USER_POSTCOPY_ADVISE] =3D > vhost_user_set_postcopy_advise, > > [VHOST_USER_POSTCOPY_LISTEN] =3D vhost_user_set_postcopy_listen, > > [VHOST_USER_POSTCOPY_END] =3D vhost_user_postcopy_end, diff -- > git > > a/lib/vhost/vhost_user.h b/lib/vhost/vhost_user.h index > > c946cc2..97cfb2f 100644 > > --- a/lib/vhost/vhost_user.h > > +++ b/lib/vhost/vhost_user.h > > @@ -50,6 +50,8 @@ > > VHOST_USER_NET_SET_MTU =3D 20, > > VHOST_USER_SET_SLAVE_REQ_FD =3D 21, > > VHOST_USER_IOTLB_MSG =3D 22, > > + VHOST_USER_GET_CONFIG =3D 24, > > + VHOST_USER_SET_CONFIG =3D 25, > > VHOST_USER_CRYPTO_CREATE_SESS =3D 26, > > VHOST_USER_CRYPTO_CLOSE_SESS =3D 27, > > VHOST_USER_POSTCOPY_ADVISE =3D 28, > > @@ -125,6 +127,16 @@ > > uint16_t queue_size; > > } VhostUserInflight; > > > > +#define VHOST_USER_MAX_CONFIG_SIZE 256 > > + > > +/** Get/set config msg payload */ > > +struct vhost_user_config { > > + uint32_t offset; > > + uint32_t size; > > + uint32_t flags; > > + uint8_t region[VHOST_USER_MAX_CONFIG_SIZE]; > > +}; > > + > > typedef struct VhostUserMsg { > > union { > > uint32_t master; /* a VhostUserRequest value */ @@ -148,6 > +160,7 @@ > > VhostUserCryptoSessionParam crypto_session; > > VhostUserVringArea area; > > VhostUserInflight inflight; > > + struct vhost_user_config cfg; > > } payload; > > /* Nothing should be added after the payload */ } __rte_packed > > VhostUserMsg; > > -- > > 1.8.3.1 >=20