From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 4BFA2A00BE;
	Mon, 25 Apr 2022 15:39:08 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id E89EA41109;
	Mon, 25 Apr 2022 15:39:07 +0200 (CEST)
Received: from mga07.intel.com (mga07.intel.com [134.134.136.100])
 by mails.dpdk.org (Postfix) with ESMTP id 835F340E78
 for <dev@dpdk.org>; Mon, 25 Apr 2022 15:39:06 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1650893946; x=1682429946;
 h=from:to:cc:subject:date:message-id:references:
 in-reply-to:content-transfer-encoding:mime-version;
 bh=Iuzs5Gujp3b/8O2fFhATBNl/AqBJwcy9+INdBmzt9Ng=;
 b=Ap+L4ewtkeTpjw2ftffRxX+W57RCRfo+RTupHxQwVOnzXezxTtpExe29
 W08+F8GX+1ozQFG3oUB4t1nLjVtDwvElZA38XAV9mxjezQw50uHe+qDal
 pVpGYQBmpgNw9sazIy3r9TUlUmidShOeTQzKObqKqmfIBjOQz2pMPl0Un
 Wo4C/z9ZE+I4ejoNB/bbiGg2l6G0lz6pabNtem+ziAFfuk1LhzF6iwunN
 iCh4ALUObY65h7VsciAvO6fBbPTKLnjfLRKo+D8E3kGdAVRLEdoWNC5ux
 utrL0PiBp3ZwE6+bRGE+V7Pizalxtf50MdjMq33zbpW1mAdTkldJvhwBG w==;
X-IronPort-AV: E=McAfee;i="6400,9594,10327"; a="328187309"
X-IronPort-AV: E=Sophos;i="5.90,288,1643702400"; d="scan'208";a="328187309"
Received: from orsmga006.jf.intel.com ([10.7.209.51])
 by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 25 Apr 2022 06:39:00 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.90,288,1643702400"; d="scan'208";a="532115092"
Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15])
 by orsmga006.jf.intel.com with ESMTP; 25 Apr 2022 06:39:00 -0700
Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by
 ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2308.27; Mon, 25 Apr 2022 06:39:00 -0700
Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by
 ORSMSX608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2308.27; Mon, 25 Apr 2022 06:39:00 -0700
Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by
 orsmsx608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2308.27 via Frontend Transport; Mon, 25 Apr 2022 06:39:00 -0700
Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.176)
 by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.1.2308.27; Mon, 25 Apr 2022 06:38:59 -0700
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=HBO5n97bhqCs/Im55+G/wy/fClKU0c/OZM3dPhPvQQZ2FepM6/2q2rR+GL9sat3B3yJvsi+f/Gmq+YpuECFz53T6W2jkXtJ9ktrJ2qijijMcByzUaMsphcAA7/yancgO3fbDubcnVgjhVKUrZNULXXoqLMVi1VlX5e0e8CE+xQuEFNb+Kw+tV2C5K4eLJhB2qnMjdsip6PsBzgYrv2t9F/EMZtihe3T35W1HDHf+X9Y1DezmSzpJ7F9ZqJ1mldMkCIUHjyAWfXL1AOmGATzYPaOPQi/OR5ipFoymOo1AH8gDIPqLhPVciUlhj+iwPwEYQeHv6HIWJos7lBWM8GuazA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=fjRjaWyGwHdYc9byCtZVasgKWoTExANNmTL6YGIUB4c=;
 b=NacG/XKgPvgC/ZklZoj+H215p98Tl77FQHc1dpvUSnSoPC2fj2AwsIkuceuV4X9LYpIkD4pkduGrBMffIqm8K0IAht0+4fi+qgJ4t+iV1se8Z2q447zwZLdJVTAGvjaRJ1ZYJ04E4mDmPxHN3o/PB8p0neQOsbSMafqp+Woy+9HnGVlS8akrt4I1HXKlwmGWzdksefJ8GxMBA+uyCj3c+kX1ZEbZauy1VVl7MAbhRYsjBUcSLCHGncbgIduaChZOAMfbnP/QkaSy4bFn3pvJMJ6lYFJtpAdWGdZdcOpqJxeXgLjLRnGRLYo3NRYyyH75LnS6dA4+hsya5ZtWxvHLew==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com;
 dkim=pass header.d=intel.com; arc=none
Received: from SN6PR11MB3504.namprd11.prod.outlook.com (2603:10b6:805:d0::17)
 by PH7PR11MB5915.namprd11.prod.outlook.com (2603:10b6:510:13c::9)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Mon, 25 Apr
 2022 13:38:58 +0000
Received: from SN6PR11MB3504.namprd11.prod.outlook.com
 ([fe80::4d1d:6453:f00c:cf8a]) by SN6PR11MB3504.namprd11.prod.outlook.com
 ([fe80::4d1d:6453:f00c:cf8a%6]) with mapi id 15.20.5186.020; Mon, 25 Apr 2022
 13:38:58 +0000
From: "Xia, Chenbo" <chenbo.xia@intel.com>
To: "Pei, Andy" <andy.pei@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
CC: "maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>, "Cao, Gang"
 <gang.cao@intel.com>, "Liu, Changpeng" <changpeng.liu@intel.com>
Subject: RE: [PATCH v6 07/16] examples/vdpa: add vDPA blk support in example
Thread-Topic: [PATCH v6 07/16] examples/vdpa: add vDPA blk support in example
Thread-Index: AQHYVWD+zxtJ2lbyyEqxwOZglErt6q0ApY0w
Date: Mon, 25 Apr 2022 13:38:58 +0000
Message-ID: <SN6PR11MB3504AF8EC5743F2D9F078D079CF89@SN6PR11MB3504.namprd11.prod.outlook.com>
References: <1643093258-47258-2-git-send-email-andy.pei@intel.com>
 <1650530034-59744-1-git-send-email-andy.pei@intel.com>
 <1650530034-59744-8-git-send-email-andy.pei@intel.com>
In-Reply-To: <1650530034-59744-8-git-send-email-andy.pei@intel.com>
Accept-Language: en-US, zh-CN
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
dlp-product: dlpe-windows
dlp-reaction: no-action
dlp-version: 11.6.401.20
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=intel.com;
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 61456a0d-698b-49cc-8e78-08da26c0f355
x-ms-traffictypediagnostic: PH7PR11MB5915:EE_
x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr
x-microsoft-antispam-prvs: <PH7PR11MB59156827631F253D6D86AB019CF89@PH7PR11MB5915.namprd11.prod.outlook.com>
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: QvxyiEVztoZdxXvjBaj3vpMckDfviYydt8YTGdq5T7rA64VEwPphocVRK9qJjqyGoCoPhd78jnyjEis0+egblWreJr+GhLKd0BRJ7+ThMSeRRszQ0OtHaA2d1Nr/2dDQui39WZjnvcONePxQP91u8bLiFl462UDpO599d1xodIDfbrYm1trky8xri89HtNXxu2uzasgrEaDU2bkr1vmyufgiLncHQbsrjQtWSvQ0qrv33QSRzaAUruBJIBhCBMId/RO3M///06VhWx6ayCaqQxcBdlXsvtXzfYGfgy1t2fl1Pfp8poIgtldI7UeUFL5Av3enWhKHALgFwDxFUA050pElQKHur0xH/424v+nJ3A8WwQ9gi9HJDPpAIPc7I4JlGoVLGk6NnJFSNdKRnzLlHCfL6Ec9vHNS5W6bS0pQGTu+A3zdeU0fEOxJ44w91/26XLcZcuSEhunRtEHSwX+6qPrzd1Wlzi4UaapZWyYGH6RZRAHegayP1qXEvi/XkBNLNiKOFvyYZcOjiQyXLDyKq76/xdOw9YdPMO2KA3x8PozklXK7M0BhqH8ZpyAzIsRwNeDjnu1dhayZnu2K0wGJdE9Yxaaub9RGmaTTx6d/tfGZ4DmrcfKRlpIJbQyQRQY0Uj00894XA8OdP4GnMWK0iOXyUiQ6z8AGfoHcXdrZ9ZeErZGWjQr4DCmH70KLtT9ELy9dD2qRQccwenhFxJcuQQ==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:SN6PR11MB3504.namprd11.prod.outlook.com; PTR:; CAT:NONE;
 SFS:(13230001)(366004)(52536014)(8936002)(9686003)(83380400001)(107886003)(26005)(110136005)(54906003)(5660300002)(316002)(33656002)(186003)(6506007)(53546011)(7696005)(2906002)(30864003)(86362001)(508600001)(38070700005)(38100700002)(122000001)(71200400001)(82960400001)(55016003)(4326008)(66556008)(8676002)(76116006)(66946007)(66476007)(64756008)(66446008);
 DIR:OUT; SFP:1102; 
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?EOkwgNQaNqJCyr1Vc6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ZXu4nNzwy?=
 =?us-ascii?Q?uv4wv11YNA=3D=3D?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB3504.namprd11.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 61456a0d-698b-49cc-8e78-08da26c0f355
X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Apr 2022 13:38:58.3924 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: clWP4U5UjjPkCqg0MnySvKcW8mBtAA5HIbbpqIceeNE+JdNRXi6JcT2UTrqyIKtvPLDYhBXCQPGytJkqFMw4ow==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB5915
X-OriginatorOrg: intel.com
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Hi Andy,

> -----Original Message-----
> From: Pei, Andy <andy.pei@intel.com>
> Sent: Thursday, April 21, 2022 4:34 PM
> To: dev@dpdk.org
> Cc: Xia, Chenbo <chenbo.xia@intel.com>; maxime.coquelin@redhat.com; Cao,
> Gang <gang.cao@intel.com>; Liu, Changpeng <changpeng.liu@intel.com>
> Subject: [PATCH v6 07/16] examples/vdpa: add vDPA blk support in example
>=20
> Add virtio blk device support to vDPA example.
>=20
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> ---
>  examples/vdpa/main.c             |  61 +++++++++++++-
>  examples/vdpa/vdpa_blk_compact.h |  72 +++++++++++++++++
>  examples/vdpa/vhost_user.h       | 169
> +++++++++++++++++++++++++++++++++++++++
>  3 files changed, 301 insertions(+), 1 deletion(-)
>  create mode 100644 examples/vdpa/vdpa_blk_compact.h
>  create mode 100644 examples/vdpa/vhost_user.h
>=20
> diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c
> index 5ab0765..1c809ab 100644
> --- a/examples/vdpa/main.c
> +++ b/examples/vdpa/main.c
> @@ -20,6 +20,7 @@
>  #include <cmdline_parse_string.h>
>  #include <cmdline_parse_num.h>
>  #include <cmdline.h>
> +#include "vdpa_blk_compact.h"
>=20
>  #define MAX_PATH_LEN 128
>  #define MAX_VDPA_SAMPLE_PORTS 1024
> @@ -41,6 +42,7 @@ struct vdpa_port {
>  static int devcnt;
>  static int interactive;
>  static int client_mode;
> +static int isblk;
>=20
>  /* display usage */
>  static void
> @@ -49,7 +51,8 @@ struct vdpa_port {
>  	printf("Usage: %s [EAL options] -- "
>  				 "	--interactive|-i: run in interactive
> mode.\n"
>  				 "	--iface <path>: specify the path prefix of
> the socket files, e.g. /tmp/vhost-user-.\n"
> -				 "	--client: register a vhost-user socket as
> client mode.\n",
> +				 "	--client: register a vhost-user socket as
> client mode.\n"
> +				 "	--isblk: device is a block device, e.g.
> virtio_blk device.\n",
>  				 prgname);
>  }
>=20
> @@ -61,6 +64,7 @@ struct vdpa_port {
>  		{"iface", required_argument, NULL, 0},
>  		{"interactive", no_argument, &interactive, 1},
>  		{"client", no_argument, &client_mode, 1},
> +		{"isblk", no_argument, &isblk, 1},

I think a new API for get_device_type will be better than asking user to sp=
ecify the
device type.

>  		{NULL, 0, 0, 0},
>  	};
>  	int opt, idx;
> @@ -159,6 +163,52 @@ struct vdpa_port {
>  };
>=20
>  static int
> +vdpa_blk_device_set_features_and_protocol(const char *path)
> +{
> +	uint64_t protocol_features =3D 0;
> +	int ret;
> +
> +	ret =3D rte_vhost_driver_set_features(path, VHOST_BLK_FEATURES_BASE);
> +	if (ret !=3D 0) {
> +		RTE_LOG(ERR, VDPA,
> +			"rte_vhost_driver_set_features for %s failed.\n",
> +			path);
> +		goto out;
> +	}
> +
> +	ret =3D rte_vhost_driver_disable_features(path,
> +		VHOST_VDPA_BLK_DISABLED_FEATURES);
> +	if (ret !=3D 0) {
> +		RTE_LOG(ERR, VDPA,
> +			"rte_vhost_driver_disable_features for %s failed.\n",
> +			path);
> +		goto out;
> +	}
> +
> +	ret =3D rte_vhost_driver_get_protocol_features(path,
> &protocol_features);
> +	if (ret !=3D 0) {
> +		RTE_LOG(ERR, VDPA,
> +			"rte_vhost_driver_get_protocol_features for %s
> failed.\n",
> +			path);
> +		goto out;
> +	}
> +
> +	protocol_features |=3D (1ULL << VHOST_USER_PROTOCOL_F_CONFIG);
> +	protocol_features |=3D (1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD);
> +
> +	ret =3D rte_vhost_driver_set_protocol_features(path,
> protocol_features);
> +	if (ret !=3D 0) {
> +		RTE_LOG(ERR, VDPA,
> +			"rte_vhost_driver_set_protocol_features for %s
> failed.\n",
> +			path);
> +		goto out;
> +	}
> +
> +out:
> +	return ret;
> +}
> +
> +static int
>  start_vdpa(struct vdpa_port *vport)
>  {
>  	int ret;
> @@ -192,6 +242,15 @@ struct vdpa_port {
>  			"attach vdpa device failed: %s\n",
>  			socket_path);
>=20
> +	if (isblk) {
> +		RTE_LOG(NOTICE, VDPA, "is a blk device\n");
> +		ret =3D vdpa_blk_device_set_features_and_protocol(socket_path);
> +		if (ret !=3D 0)
> +			rte_exit(EXIT_FAILURE,
> +				"set vhost blk driver features and protocol
> features failed: %s\n",
> +				socket_path);
> +	}
> +
>  	if (rte_vhost_driver_start(socket_path) < 0)
>  		rte_exit(EXIT_FAILURE,
>  			"start vhost driver failed: %s\n",
> diff --git a/examples/vdpa/vdpa_blk_compact.h
> b/examples/vdpa/vdpa_blk_compact.h

Please remove unused definition in this header. I didn't check all, but it
seems at least VHOST_BLK_PROTOCOL_FEATURES is not used.

> new file mode 100644
> index 0000000..e7c0f22
> --- /dev/null
> +++ b/examples/vdpa/vdpa_blk_compact.h
> @@ -0,0 +1,72 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2022 Intel Corporation
> + */
> +
> +#ifndef _VDPA_BLK_COMPACT_H_
> +#define _VDPA_BLK_COMPACT_H_
> +
> +/**
> + * @file
> + *
> + * Device specific vhost lib
> + */
> +
> +#include <stdbool.h>
> +
> +#include <rte_pci.h>
> +#include <rte_vhost.h>
> +
> +/* Feature bits */
> +#define VIRTIO_BLK_F_SIZE_MAX     1    /* Indicates maximum segment size
> */
> +#define VIRTIO_BLK_F_SEG_MAX      2    /* Indicates maximum # of segment=
s
> */
> +#define VIRTIO_BLK_F_GEOMETRY     4    /* Legacy geometry available  */
> +#define VIRTIO_BLK_F_RO           5    /* Disk is read-only */
> +#define VIRTIO_BLK_F_BLK_SIZE     6    /* Block size of disk is availabl=
e
> */
> +#define VIRTIO_BLK_F_TOPOLOGY     10   /* Topology information is
> available */
> +#define VIRTIO_BLK_F_MQ           12   /* support more than one vq */
> +#define VIRTIO_BLK_F_DISCARD      13   /* DISCARD is supported */
> +#define VIRTIO_BLK_F_WRITE_ZEROES 14   /* WRITE ZEROES is supported */
> +
> +/* Legacy feature bits */
> +#ifndef VIRTIO_BLK_NO_LEGACY
> +#define VIRTIO_BLK_F_BARRIER      0    /* Does host support barriers? */
> +#define VIRTIO_BLK_F_SCSI         7    /* Supports scsi command passthru
> */
> +#define VIRTIO_BLK_F_FLUSH        9    /* Flush command supported */
> +#define VIRTIO_BLK_F_CONFIG_WCE   11   /* Writeback mode available in
> config */
> +
> +/* Old (deprecated) name for VIRTIO_BLK_F_FLUSH. */
> +#define VIRTIO_BLK_F_WCE VIRTIO_BLK_F_FLUSH
> +#endif /* !VIRTIO_BLK_NO_LEGACY */
> +
> +#ifndef VHOST_USER_F_PROTOCOL_FEATURES
> +#define VHOST_USER_F_PROTOCOL_FEATURES 30
> +#endif
> +
> +#define VHOST_BLK_FEATURES ((1ULL << VHOST_F_LOG_ALL) | \
> +	(1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | \
> +	(1ULL << VIRTIO_F_VERSION_1) | \
> +	(1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | \
> +	(1ULL << VIRTIO_RING_F_EVENT_IDX) | \
> +	(1ULL << VIRTIO_RING_F_INDIRECT_DESC))
> +
> +#define VHOST_BLK_DISABLED_FEATURES ((1ULL << VIRTIO_RING_F_EVENT_IDX) |
> \
> +	(1ULL << VIRTIO_F_NOTIFY_ON_EMPTY))
> +
> +#define VHOST_BLK_FEATURES_BASE (VHOST_BLK_FEATURES | \
> +	(1ULL << VIRTIO_BLK_F_SIZE_MAX) | (1ULL << VIRTIO_BLK_F_SEG_MAX) | \
> +	(1ULL << VIRTIO_BLK_F_GEOMETRY) | (1ULL << VIRTIO_BLK_F_BLK_SIZE) |
> \
> +	(1ULL << VIRTIO_BLK_F_TOPOLOGY) | (1ULL << VIRTIO_BLK_F_BARRIER)  |
> \
> +	(1ULL << VIRTIO_BLK_F_SCSI)     | (1ULL << VIRTIO_BLK_F_CONFIG_WCE)
> | \
> +	(1ULL << VIRTIO_BLK_F_MQ))
> +
> +/* Not supported features */
> +#define VHOST_VDPA_BLK_DISABLED_FEATURES (VHOST_BLK_DISABLED_FEATURES | =
\
> +	(1ULL << VIRTIO_BLK_F_GEOMETRY) | (1ULL << VIRTIO_BLK_F_CONFIG_WCE)
> | \
> +	(1ULL << VIRTIO_BLK_F_BARRIER)  | (1ULL << VIRTIO_BLK_F_SCSI))
> +
> +/* Vhost-blk support protocol features */
> +#define VHOST_BLK_PROTOCOL_FEATURES \
> +	((1ULL << VHOST_USER_PROTOCOL_F_CONFIG) | \
> +	(1ULL << VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD))
> +
> +#endif /* _VDPA_BLK_COMPACT_H_ */
> diff --git a/examples/vdpa/vhost_user.h b/examples/vdpa/vhost_user.h
> new file mode 100644
> index 0000000..137bbc2
> --- /dev/null
> +++ b/examples/vdpa/vhost_user.h

I don't understand, why introduce this header? It seems never used.

Thanks,
Chenbo

> @@ -0,0 +1,169 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2022 Intel Corporation
> + */
> +
> +#ifndef _VHOST_NET_USER_H
> +#define _VHOST_NET_USER_H
> +
> +#include <stdint.h>
> +#include <linux/vhost.h>
> +
> +#include "rte_vhost.h"
> +
> +/* refer to hw/virtio/vhost-user.c */
> +
> +#define VHOST_MEMORY_MAX_NREGIONS 8
> +
> +#ifndef VHOST_USER_MAX_CONFIG_SIZE
> +#define VHOST_USER_MAX_CONFIG_SIZE		256
> +#endif
> +
> +#define VHOST_USER_PROTOCOL_FEATURES	((1ULL <<
> VHOST_USER_PROTOCOL_F_MQ) | \
> +			(1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) |\
> +			(1ULL << VHOST_USER_PROTOCOL_F_RARP) | \
> +			(1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK) | \
> +			(1ULL << VHOST_USER_PROTOCOL_F_NET_MTU) | \
> +			(1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ) | \
> +			(1ULL << VHOST_USER_PROTOCOL_F_CRYPTO_SESSION) | \
> +			(1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) | \
> +			(1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER) | \
> +			(1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT))
> +
> +typedef enum VhostUserRequest {
> +	VHOST_USER_NONE =3D 0,
> +	VHOST_USER_GET_FEATURES =3D 1,
> +	VHOST_USER_SET_FEATURES =3D 2,
> +	VHOST_USER_SET_OWNER =3D 3,
> +	VHOST_USER_RESET_OWNER =3D 4,
> +	VHOST_USER_SET_MEM_TABLE =3D 5,
> +	VHOST_USER_SET_LOG_BASE =3D 6,
> +	VHOST_USER_SET_LOG_FD =3D 7,
> +	VHOST_USER_SET_VRING_NUM =3D 8,
> +	VHOST_USER_SET_VRING_ADDR =3D 9,
> +	VHOST_USER_SET_VRING_BASE =3D 10,
> +	VHOST_USER_GET_VRING_BASE =3D 11,
> +	VHOST_USER_SET_VRING_KICK =3D 12,
> +	VHOST_USER_SET_VRING_CALL =3D 13,
> +	VHOST_USER_SET_VRING_ERR =3D 14,
> +	VHOST_USER_GET_PROTOCOL_FEATURES =3D 15,
> +	VHOST_USER_SET_PROTOCOL_FEATURES =3D 16,
> +	VHOST_USER_GET_QUEUE_NUM =3D 17,
> +	VHOST_USER_SET_VRING_ENABLE =3D 18,
> +	VHOST_USER_SEND_RARP =3D 19,
> +	VHOST_USER_NET_SET_MTU =3D 20,
> +	VHOST_USER_SET_SLAVE_REQ_FD =3D 21,
> +	VHOST_USER_IOTLB_MSG =3D 22,
> +	VHOST_USER_CRYPTO_CREATE_SESS =3D 26,
> +	VHOST_USER_CRYPTO_CLOSE_SESS =3D 27,
> +	VHOST_USER_POSTCOPY_ADVISE =3D 28,
> +	VHOST_USER_POSTCOPY_LISTEN =3D 29,
> +	VHOST_USER_POSTCOPY_END =3D 30,
> +	VHOST_USER_GET_INFLIGHT_FD =3D 31,
> +	VHOST_USER_SET_INFLIGHT_FD =3D 32,
> +	VHOST_USER_MAX =3D 33
> +} VhostUserRequest;
> +
> +typedef enum VhostUserSlaveRequest {
> +	VHOST_USER_SLAVE_NONE =3D 0,
> +	VHOST_USER_SLAVE_IOTLB_MSG =3D 1,
> +	VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG =3D 3,
> +	VHOST_USER_SLAVE_MAX
> +} VhostUserSlaveRequest;
> +
> +typedef struct VhostUserMemoryRegion {
> +	uint64_t guest_phys_addr;
> +	uint64_t memory_size;
> +	uint64_t userspace_addr;
> +	uint64_t mmap_offset;
> +} VhostUserMemoryRegion;
> +
> +typedef struct VhostUserMemory {
> +	uint32_t nregions;
> +	uint32_t padding;
> +	VhostUserMemoryRegion regions[VHOST_MEMORY_MAX_NREGIONS];
> +} VhostUserMemory;
> +
> +typedef struct VhostUserLog {
> +	uint64_t mmap_size;
> +	uint64_t mmap_offset;
> +} VhostUserLog;
> +
> +/* Comply with Cryptodev-Linux */
> +#define VHOST_USER_CRYPTO_MAX_HMAC_KEY_LENGTH	512
> +#define VHOST_USER_CRYPTO_MAX_CIPHER_KEY_LENGTH	64
> +
> +/* Same structure as vhost-user backend session info */
> +typedef struct VhostUserCryptoSessionParam {
> +	int64_t session_id;
> +	uint32_t op_code;
> +	uint32_t cipher_algo;
> +	uint32_t cipher_key_len;
> +	uint32_t hash_algo;
> +	uint32_t digest_len;
> +	uint32_t auth_key_len;
> +	uint32_t aad_len;
> +	uint8_t op_type;
> +	uint8_t dir;
> +	uint8_t hash_mode;
> +	uint8_t chaining_dir;
> +	uint8_t *ciphe_key;
> +	uint8_t *auth_key;
> +	uint8_t cipher_key_buf[VHOST_USER_CRYPTO_MAX_CIPHER_KEY_LENGTH];
> +	uint8_t auth_key_buf[VHOST_USER_CRYPTO_MAX_HMAC_KEY_LENGTH];
> +} VhostUserCryptoSessionParam;
> +
> +typedef struct VhostUserVringArea {
> +	uint64_t u64;
> +	uint64_t size;
> +	uint64_t offset;
> +} VhostUserVringArea;
> +
> +typedef struct VhostUserInflight {
> +	uint64_t mmap_size;
> +	uint64_t mmap_offset;
> +	uint16_t num_queues;
> +	uint16_t queue_size;
> +} VhostUserInflight;
> +
> +/** 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 */
> +		uint32_t slave;  /* a VhostUserSlaveRequest value*/
> +	} request;
> +
> +#define VHOST_USER_VERSION_MASK     0x3
> +#define VHOST_USER_REPLY_MASK       (0x1 << 2)
> +#define VHOST_USER_NEED_REPLY		(0x1 << 3)
> +	uint32_t flags;
> +	uint32_t size; /* the following payload size */
> +	union {
> +#define VHOST_USER_VRING_IDX_MASK   0xff
> +#define VHOST_USER_VRING_NOFD_MASK  (0x1<<8)
> +		uint64_t u64;
> +		struct vhost_vring_state state;
> +		struct vhost_vring_addr addr;
> +		VhostUserMemory memory;
> +		VhostUserLog    log;
> +		struct vhost_iotlb_msg iotlb;
> +		VhostUserCryptoSessionParam crypto_session;
> +		VhostUserVringArea area;
> +		VhostUserInflight inflight;
> +		struct vhost_user_config cfg;
> +	} payload;
> +	int fds[VHOST_MEMORY_MAX_NREGIONS];
> +	int fd_num;
> +} __attribute((packed)) VhostUserMsg;
> +
> +#define VHOST_USER_HDR_SIZE offsetof(VhostUserMsg, payload.u64)
> +
> +/* The version of the protocol we support */
> +#define VHOST_USER_VERSION    0x1
> +#endif
> --
> 1.8.3.1