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 4490CA00C3; Fri, 13 May 2022 10:16:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2DFFA40E64; Fri, 13 May 2022 10:16:05 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 683AF40DDE for ; Fri, 13 May 2022 10:16:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652429763; x=1683965763; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=s5SCFnUHEkeuA/1lpyEfLwhOEp8BBu/nsAr7dnGw9og=; b=UXavns+SGiskbFUhlbFbEwYa7lo31bVRczuGDV9eJ/d2KLaJHdW0sa7o sOlTLShO/tjtQJLIbAXuqpF3x3vz3sm49VySlEf5lHLhpQBIqWfRwGd1L kmARI52TlywTE+OQieaS/xcE2uA0K6CDkA2TSew1wkstdvqLQ7QcTaBnj OdEKgp5VumMib/59Q5B77KXstm6ShGXT1HBirlH8bNZm9uzjE0njHx0Kf w5ZWNw74xopuwSO2vrc6Q1SFhR0olgIaGXY3u4er2Co1Mjz3zgBLBlxlV ZhH60K6dkNporDXVLq9uNHavHCiTaoudCVlKMGFpR7P7ejr0MbEZQMIiW g==; X-IronPort-AV: E=McAfee;i="6400,9594,10345"; a="269920463" X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="269920463" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 01:16:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="543166334" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga006.jf.intel.com with ESMTP; 13 May 2022 01:16:02 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Fri, 13 May 2022 01:16:01 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Fri, 13 May 2022 01:16:01 -0700 Received: from fmsmsx612.amr.corp.intel.com ([10.18.126.92]) by fmsmsx612.amr.corp.intel.com ([10.18.126.92]) with mapi id 15.01.2308.027; Fri, 13 May 2022 01:16:01 -0700 From: "Pei, Andy" To: "Xia, Chenbo" , "dev@dpdk.org" CC: "maxime.coquelin@redhat.com" , "Cao, Gang" , "Liu, Changpeng" Subject: RE: [PATCH v7 09/18] examples/vdpa: add vDPA blk support in example Thread-Topic: [PATCH v7 09/18] examples/vdpa: add vDPA blk support in example Thread-Index: AQHYWheFciAJRm+xPEiEnk5kGsKxWa0bU0UggAE2+VA= Date: Fri, 13 May 2022 08:16:00 +0000 Message-ID: <7a7f87179df146ba8e7019da008650f6@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-10-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. My reply is inline. > -----Original Message----- > From: Xia, Chenbo > Sent: Thursday, May 12, 2022 9:34 PM > To: Pei, Andy ; dev@dpdk.org > Cc: maxime.coquelin@redhat.com; Cao, Gang ; Liu, > Changpeng > Subject: RE: [PATCH v7 09/18] examples/vdpa: add vDPA blk support in > example >=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 09/18] examples/vdpa: add vDPA blk support in > > example >=20 > Better be: examples/vdpa: add virtio blk support >=20 Sure. > > > > Add virtio blk device support to vDPA example. > > > > Signed-off-by: Andy Pei > > --- > > examples/vdpa/main.c | 57 > +++++++++++++++++++++++++++++++++++ > > examples/vdpa/vdpa_blk_compact.h | 65 > > ++++++++++++++++++++++++++++++++++++++++ > > 2 files changed, 122 insertions(+) > > create mode 100644 examples/vdpa/vdpa_blk_compact.h > > > > diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c index > > 5ab0765..2544141 100644 > > --- a/examples/vdpa/main.c > > +++ b/examples/vdpa/main.c > > @@ -20,6 +20,7 @@ > > #include > > #include > > #include > > +#include "vdpa_blk_compact.h" > > > > #define MAX_PATH_LEN 128 > > #define MAX_VDPA_SAMPLE_PORTS 1024 > > @@ -159,8 +160,54 @@ struct vdpa_port { }; > > > > 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); > > + 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_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 VHOST_BLK_PROTOCOL_FEATURES; > > + > > + 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; >=20 > This goto is not needed. >=20 Yes, you are right. I will fix it. > > + } > > + > > +out: > > + return ret; > > +} > > + > > +static int > > start_vdpa(struct vdpa_port *vport) > > { > > + uint32_t device_type =3D 0; > > int ret; > > char *socket_path =3D vport->ifname; > > > > @@ -192,6 +239,16 @@ struct vdpa_port { > > "attach vdpa device failed: %s\n", > > socket_path); > > > > + ret =3D rte_vhost_driver_get_vdpa_dev_type(socket_path, > &device_type); > > + if (ret =3D=3D 0 && device_type =3D=3D VDPA_DEVICE_TYPE_BLK) { > > + RTE_LOG(NOTICE, VDPA, "is a blk device\n"); >=20 > Should add info of socket path >=20 Yes, you are right. I will fix it. > > + 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 > > new file mode 100644 > > index 0000000..136c3f6 > > --- /dev/null > > +++ b/examples/vdpa/vdpa_blk_compact.h > > @@ -0,0 +1,65 @@ > > +/* 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 > > + > > +#include >=20 > above two headers are not used in this file? >=20 I will remove these two include. > > +#include > > + > > +/* Feature bits */ > > +#define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment > size > > */ > > +#define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of > segments > > */ > > +#define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available *= / > > +#define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is availa= ble > > */ > > +#define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is > > available */ > > +#define VIRTIO_BLK_F_MQ 12 /* support more than one vq */ > > + > > +/* 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 passth= ru > > */ > > +#define VIRTIO_BLK_F_CONFIG_WCE 11 /* Writeback mode available in > > config */ > > +#endif /* !VIRTIO_BLK_NO_LEGACY */ > > + > > +#ifndef VHOST_USER_F_PROTOCOL_FEATURES #define > > +VHOST_USER_F_PROTOCOL_FEATURES 30 #endif >=20 > It's already in rte_vhost.h, so no need to re-define. >=20 > Thanks, > Chenbo >=20 Yes, you are right. I will fix it. > > + > > +#define VHOST_BLK_FEATURES_BASE ((1ULL << VHOST_F_LOG_ALL) | \ > > + (1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | \ > > + (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \ > > + (1ULL << VIRTIO_RING_F_EVENT_IDX) | \ > > + (1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | \ > > + (1ULL << VIRTIO_F_VERSION_1)) > > + > > +#define VHOST_BLK_DISABLED_FEATURES_BASE ((1ULL << > > VIRTIO_F_NOTIFY_ON_EMPTY) | \ > > + (1ULL << VIRTIO_RING_F_EVENT_IDX)) > > + > > +#define VHOST_BLK_FEATURES (VHOST_BLK_FEATURES_BASE | \ > > + (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_BLK_DISABLED_FEATURES > (VHOST_BLK_DISABLED_FEATURES_BASE | \ > > + (1ULL << VIRTIO_BLK_F_GEOMETRY) | (1ULL << > VIRTIO_BLK_F_BARRIER) | \ > > + (1ULL << VIRTIO_BLK_F_SCSI) | (1ULL << > VIRTIO_BLK_F_CONFIG_WCE)) > > + > > +/* Vhost-blk support protocol features */ #define > > +VHOST_BLK_PROTOCOL_FEATURES \ > > + ((1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) | \ > > + (1ULL << VHOST_USER_PROTOCOL_F_CONFIG)) > > + > > +#endif /* _VDPA_BLK_COMPACT_H_ */ > > -- > > 1.8.3.1 >=20