From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AB8F1A04FA; Thu, 11 Jun 2020 04:45:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DCD4D1023; Thu, 11 Jun 2020 04:45:28 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 7F3ABB62 for ; Thu, 11 Jun 2020 04:45:26 +0200 (CEST) IronPort-SDR: khDi+Rm7ZpF3RhNLg2CaB4om8m5oeU2ShLo+Xj4xBDDhqGrufnZ22/qxS6E4P7Sg4KG6qDAG0K d/cqPvTsH96w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2020 19:45:25 -0700 IronPort-SDR: 2ynBApqDSoXtsUwlin+OiuR2IzEnE2EgLTe0HmicNIHDXP8oDL7dlzEaJqVlebcFBBvI+yUM+U oVYsM3BIxftw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,498,1583222400"; d="scan'208";a="275183406" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga006.jf.intel.com with ESMTP; 10 Jun 2020 19:45:25 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 10 Jun 2020 19:45:24 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.169) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 10 Jun 2020 19:45:24 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NW2+aESGfRokI7FAhtBYp461wI7AipxIs9RJ9ZIlKwPMk0N5rbUi3J3uHahV5gznLcfg0xyrT2v9Rvsg687iaKEe2Ogp23JWdaWbXyftNfnq+piogvRUXHtzBlqChLNrg8JXw4H0MC77t9IzFR84X5OzWE8PW9DmYq6S3OM/EMy0guSMvm9JG2hQcAiWctdcyCY1ZxmncpgpylXckYOaUglJqxujZKumj//JcjdeS0NbCwn0G1YjrZ0RGmODm3F9ehfS7V8r8TfssoB6Ox/E3ElVBfmVCi/0gvRH1AneIvTPKVBUWGp7GYlYU96QlnKGE1W+Ihy2TJF9j6hFlPRUMg== 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-SenderADCheck; bh=NSEe8EKedM3lFPQoqxm66pSiY+RJla68ixyCzk3lYlw=; b=fXWmYfj/k/UCSWjsB1TCQzGD1mG7HPPE1+F302VgIjczT4dJEqzEsptjdnl6hz7pZ6GiLQ2X0cfKpqQiPR9dFwkKKCy6WhhVhr7LfCO2J4b2+93SIR6cOkXrflBtthT+xOZnucO3SVCY5WmnynVfPcvBpgisTLjPmrbL7fY3fXmdIGyCDvccCJyVleQQdRkoklx97BXOiyzQmCZFxn7SLn93AgpgCEwaMl4ZT299VCiIo66HV035WFBByvzZXpyu3fQtqgDcIGengy5nHg0eGvpboJnge2zDCoL1BXx41PwbrdMO6S92OiAOrOe7Kgd8QBKxfv0+WdOeuSA4Pn16/g== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NSEe8EKedM3lFPQoqxm66pSiY+RJla68ixyCzk3lYlw=; b=pvlhcz1/smrxlFwDhTh9i/1EogtpD6mOEu+YbNiJlVXHurBYp0FKPJpg9U7zxdV2QL9uZoc1xZVuCxZQN6r0byzuu+0SmdOjyW7/niTnFwRrBIqZEKP+bTN30GchWPRPjXdLE2db7xzFWElfW/x195UoTfxJV6eWnVDUEDp/28k= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) by MN2PR11MB4015.namprd11.prod.outlook.com (2603:10b6:208:154::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.18; Thu, 11 Jun 2020 02:45:22 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::7cde:8326:5010:c47e]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::7cde:8326:5010:c47e%7]) with mapi id 15.20.3066.023; Thu, 11 Jun 2020 02:45:22 +0000 From: "Xia, Chenbo" To: Maxime Coquelin , "Ye, Xiaolong" , "shahafs@mellanox.com" , "matan@mellanox.com" , "amorenoz@redhat.com" , "Wang, Xiao W" , "viacheslavo@mellanox.com" , "dev@dpdk.org" CC: "jasowang@redhat.com" , "lulu@redhat.com" Thread-Topic: [dpdk-dev] [PATCH 6/9] vhost: add support for virtio status Thread-Index: AQHWKcZfIj7EohmpPEWIeBQ96BO3A6jS3evQ Date: Thu, 11 Jun 2020 02:45:22 +0000 Message-ID: References: <20200514080218.1435344-1-maxime.coquelin@redhat.com> <20200514080218.1435344-7-maxime.coquelin@redhat.com> In-Reply-To: <20200514080218.1435344-7-maxime.coquelin@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.46.36] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 90246121-3959-48d1-00fe-08d80db17ceb x-ms-traffictypediagnostic: MN2PR11MB4015: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 0431F981D8 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: JdNIJF8lDEUOAZtfYhwflV15kVjTG0Tperq6KyL45sLhTKfrfTuNk8/N4Lz3JFEqL+3Bwi4E9UqjD//AHHD2MIZIfiKCUCDqKnxP7062nHPglCQb6/V+GymyIRJoXV2ZhG9o9tejjQyYnzc3gNPNqZprom/RtWIqWM/W0FONNhk485YRnPLDW2QcWEaBZ5sQyxIzRY+P/nsI9tSmOV5P86BG1gyxsmTRrT+718sxUy0aZHlmR7F/fM2TBSuVlcC9ANHFyTAJIL8ovalIJX2PSrCHSaBdfgi9dAJvUXNitFaFQZeDWwcXIYyMr7cLkuRKkch79+SdL2vzFZLbzPpKtWDXcCQuYb+eNeJ9NsfW9Q6pwhljJFM19ijOUh+pRC3/ x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR11MB4063.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(376002)(136003)(396003)(39860400002)(346002)(366004)(8936002)(8676002)(76116006)(66946007)(66556008)(55016002)(2906002)(9686003)(64756008)(66476007)(86362001)(66446008)(33656002)(4326008)(83380400001)(54906003)(478600001)(7696005)(186003)(110136005)(6506007)(316002)(26005)(5660300002)(52536014)(53546011)(71200400001)(921003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: ygDYyzs3p7bdkonkU5wJdh9eaUjtOlizc9Nl3Hw1b1L8Slr5PEnXKGXBwAl54U/GWw4K9Vdw77sAfHqB8UymEhdpowmhOeqU9XeduoN0oTGYnPrYCzHADZB1XhPRXV9uGtceODylDU6FoTOP48x/kIwDcWqhypGj5hm1tlKll1Ettq846kFWLrcy2g6Plv+oqNSKNgNpApquGflgAlSkAtA667OMcVXK0LuxUcJPrtr10FAdhAmoi3lQNqO1WCmSaqHzBCCnPxnAvbqeQ+B2H8GiAQaaBA9ohXW4IabIKfY65VKJ6TCkMrL6kgpnjnnewYSqcvlkMdg0ymXR3TfJZBiUazwEdloFGEdmVcddhkde1wkkStkDmWgo1GIO75SC2VbYO7Kw6ye983kSE0X7CxKlwUz3/dl/zhH3AaYgJDexOcQ8JDJgMozEScCLmZBOn2tXzoZybjifkhNAu/Zq+zIM5NEIX+F6WO+RN/CmUkM= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 90246121-3959-48d1-00fe-08d80db17ceb X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jun 2020 02:45:22.8464 (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: IljlaQMYReAGM+Mr7XhAjc0rVsoWCAxDBuoFgAmnYOscYsxOPgwncdnY9SUFuFLFF8NfU5KxUJySbKoQIoudiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4015 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 6/9] vhost: add support for virtio status X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Maxime, > -----Original Message----- > From: dev On Behalf Of Maxime Coquelin > Sent: Thursday, May 14, 2020 4:02 PM > To: Ye, Xiaolong ; shahafs@mellanox.com; > matan@mellanox.com; amorenoz@redhat.com; Wang, Xiao W > ; viacheslavo@mellanox.com; dev@dpdk.org > Cc: jasowang@redhat.com; lulu@redhat.com; Maxime Coquelin > > Subject: [dpdk-dev] [PATCH 6/9] vhost: add support for virtio status >=20 > This patch adds support to the new Virtio device status Vhost-user protoc= ol > feature. >=20 > Getting such information in the backend helps to know when the driver is = done > with the device configuration and so makes the initialization phase more = robust. >=20 > Signed-off-by: Maxime Coquelin > --- > lib/librte_vhost/rte_vhost.h | 4 ++++ > lib/librte_vhost/vhost.h | 9 ++++++++ > lib/librte_vhost/vhost_user.c | 40 +++++++++++++++++++++++++++++++++++ > lib/librte_vhost/vhost_user.h | 6 ++++-- > 4 files changed, 57 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h = index > 5c72fba797..b4b7aa1928 100644 > --- a/lib/librte_vhost/rte_vhost.h > +++ b/lib/librte_vhost/rte_vhost.h > @@ -85,6 +85,10 @@ extern "C" { > #define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12 #endif >=20 > +#ifndef VHOST_USER_PROTOCOL_F_STATUS > +#define VHOST_USER_PROTOCOL_F_STATUS 15 #endif > + > /** Indicate whether protocol features negotiation is supported. */ #if= ndef > VHOST_USER_F_PROTOCOL_FEATURES > #define VHOST_USER_F_PROTOCOL_FEATURES 30 > diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index > df98d15de6..9a9c0a98f5 100644 > --- a/lib/librte_vhost/vhost.h > +++ b/lib/librte_vhost/vhost.h > @@ -202,6 +202,14 @@ struct vhost_virtqueue { > TAILQ_HEAD(, vhost_iotlb_entry) iotlb_pending_list; } > __rte_cache_aligned; >=20 > +/* Virtio device status as per Virtio specification */ > +#define VIRTIO_DEVICE_STATUS_ACK 0x01 > +#define VIRTIO_DEVICE_STATUS_DRIVER 0x02 > +#define VIRTIO_DEVICE_STATUS_DRIVER_OK 0x04 > +#define VIRTIO_DEVICE_STATUS_FEATURES_OK 0x08 > +#define VIRTIO_DEVICE_STATUS_DEV_NEED_RESET 0x40 > +#define VIRTIO_DEVICE_STATUS_FAILED 0x80 > + > /* Old kernels have no such macros defined */ #ifndef > VIRTIO_NET_F_GUEST_ANNOUNCE > #define VIRTIO_NET_F_GUEST_ANNOUNCE 21 @@ -364,6 +372,7 @@ struct > virtio_net { > uint64_t log_addr; > struct rte_ether_addr mac; > uint16_t mtu; > + uint8_t status; >=20 > struct vhost_device_ops const *notify_ops; >=20 > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.= c index > 4a847f368c..e5a44be58d 100644 > --- a/lib/librte_vhost/vhost_user.c > +++ b/lib/librte_vhost/vhost_user.c > @@ -87,6 +87,7 @@ static const char *vhost_message_str[VHOST_USER_MAX] > =3D { > [VHOST_USER_POSTCOPY_END] =3D "VHOST_USER_POSTCOPY_END", > [VHOST_USER_GET_INFLIGHT_FD] =3D "VHOST_USER_GET_INFLIGHT_FD", > [VHOST_USER_SET_INFLIGHT_FD] =3D "VHOST_USER_SET_INFLIGHT_FD", > + [VHOST_USER_SET_STATUS] =3D "VHOST_USER_SET_STATUS", > }; >=20 > static int send_vhost_reply(int sockfd, struct VhostUserMsg *msg); @@ -1= 328,6 > +1329,11 @@ virtio_is_ready(struct virtio_net *dev) > return 0; > } >=20 > + /* If supported, ensure the frontend is really done with config */ > + if (dev->protocol_features & (1ULL << > VHOST_USER_PROTOCOL_F_STATUS)) > + if (!(dev->status & VIRTIO_DEVICE_STATUS_DRIVER_OK)) > + return 0; > + > dev->flags |=3D VIRTIO_DEV_READY; >=20 > VHOST_LOG_CONFIG(INFO, > @@ -2425,6 +2431,39 @@ vhost_user_postcopy_end(struct virtio_net **pdev, > struct VhostUserMsg *msg, > return RTE_VHOST_MSG_RESULT_REPLY; > } >=20 > +static int > +vhost_user_set_status(struct virtio_net **pdev, struct VhostUserMsg *msg= , > + int main_fd __rte_unused) > +{ > + struct virtio_net *dev =3D *pdev; > + Should we do 'validate_msg_fds' to avoid malicious messages as it is done i= n every message handler? Thanks, Chenbo > + /* As per Virtio specification, the device status is 8bits long */ > + if (msg->payload.u64 > UINT8_MAX) { > + VHOST_LOG_CONFIG(ERR, "Invalid VHOST_USER_SET_STATUS > payload 0x%" PRIx64 "\n", > + msg->payload.u64); > + return RTE_VHOST_MSG_RESULT_ERR; > + } > + > + dev->status =3D msg->payload.u64; > + > + VHOST_LOG_CONFIG(INFO, "New device status(0x%08x):\n" > + "\t-ACKNOWLEDGE: %u\n" > + "\t-DRIVER: %u\n" > + "\t-FEATURES_OK: %u\n" > + "\t-DRIVER_OK: %u\n" > + "\t-DEVICE_NEED_RESET: %u\n" > + "\t-FAILED: %u\n", > + dev->status, > + !!(dev->status & VIRTIO_DEVICE_STATUS_ACK), > + !!(dev->status & VIRTIO_DEVICE_STATUS_DRIVER), > + !!(dev->status & > VIRTIO_DEVICE_STATUS_FEATURES_OK), > + !!(dev->status & VIRTIO_DEVICE_STATUS_DRIVER_OK), > + !!(dev->status & > VIRTIO_DEVICE_STATUS_DEV_NEED_RESET), > + !!(dev->status & VIRTIO_DEVICE_STATUS_FAILED)); > + > + return RTE_VHOST_MSG_RESULT_OK; > +} > + > typedef int (*vhost_message_handler_t)(struct virtio_net **pdev, > struct VhostUserMsg *msg, > int main_fd); > @@ -2457,6 +2496,7 @@ static vhost_message_handler_t > vhost_message_handlers[VHOST_USER_MAX] =3D { > [VHOST_USER_POSTCOPY_END] =3D vhost_user_postcopy_end, > [VHOST_USER_GET_INFLIGHT_FD] =3D vhost_user_get_inflight_fd, > [VHOST_USER_SET_INFLIGHT_FD] =3D vhost_user_set_inflight_fd, > + [VHOST_USER_SET_STATUS] =3D vhost_user_set_status, > }; >=20 > /* return bytes# of read on success or negative val on failure. */ diff = --git > a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h index > 1f65efa4a9..74fd361e3a 100644 > --- a/lib/librte_vhost/vhost_user.h > +++ b/lib/librte_vhost/vhost_user.h > @@ -23,7 +23,8 @@ > (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)) > + (1ULL << > VHOST_USER_PROTOCOL_F_PAGEFAULT) | \ > + (1ULL << > VHOST_USER_PROTOCOL_F_STATUS)) >=20 > typedef enum VhostUserRequest { > VHOST_USER_NONE =3D 0, > @@ -56,7 +57,8 @@ typedef enum VhostUserRequest { > 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 > + VHOST_USER_SET_STATUS =3D 36, > + VHOST_USER_MAX =3D 37 > } VhostUserRequest; >=20 > typedef enum VhostUserSlaveRequest { > -- > 2.25.4