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 EEB34A00BE; Tue, 7 Jul 2020 05:22:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D6FED1DD3C; Tue, 7 Jul 2020 05:22:39 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 4B99E1DC3E for ; Tue, 7 Jul 2020 05:22:38 +0200 (CEST) IronPort-SDR: iFS2/zcgkVznDAqSzgvCdAdyZMwUvEbE+m5HGNieYCCb65B5LYNOZbS1eIdn1qaHvWSp6zocLA M9mG4em7tJfg== X-IronPort-AV: E=McAfee;i="6000,8403,9674"; a="149043666" X-IronPort-AV: E=Sophos;i="5.75,321,1589266800"; d="scan'208";a="149043666" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 20:22:37 -0700 IronPort-SDR: 0Ofw694HfsT9yeMhS1tAFN9Wv5a/GqW4pfgY58ANyaN9qCkpQZViwotw1o0dMeOvJI5HAJCumJ m0u5xt3YfGkg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,321,1589266800"; d="scan'208";a="388371987" Received: from orsmsx104.amr.corp.intel.com ([10.22.225.131]) by fmsmga001.fm.intel.com with ESMTP; 06 Jul 2020 20:22:36 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by ORSMSX104.amr.corp.intel.com (10.22.225.131) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 6 Jul 2020 20:22:36 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.171) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 6 Jul 2020 20:22:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MhHA64paUKq5VGhUGyek/Dnh4Z8z9w9EjRRUFzTZb+UsVtErddr84Kjn/cRQ4mZ66z7gFlof+tt6kfACpTdU8+xC86RTVHANO5F/ytDq+jI29S4cg68vzyhWV52WIoVcnPt7VnYK9zq1zT11PZsvPTE6IEd4r9qUOCr2edT3p2Q5iwLPhW5E4iT+1t1EFj8sFkXa3DDj9F9BgB2WrK0gtVtjWHXPHu4yViEBLV3AnI7fSe0CbitFcAdsnamPMjLO7QZut1+3UOMiOAxurUP8ALKSFGXZIzS3i1cYg7mrPzm0lBzMysijeqFH0AFp3bsZTWY5GO0IlDdwCRDHg6FVlw== 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=+RrS3pBftpW+rYNv9y4Q74Mu4XrZWh0ENyzEwr8Pieg=; b=FM9y9Pb3067UBv+QKb7tvJ5tyi3L7VnihKh10tkbprq5yPhzwSBc6XVMNPDdtDuSIWhxQlqFQ6PuHqgzqsNqGYxyowHcB2wbnXCuigei7zKG/VAo4pNDFipg6Vk01JeHmXbytGvZGTkwDLnq4x/dRYYBPwUPPoP7bB1ixn45JRJ0XOt9BcpfiaRIuHJ7q5fIolwsN9al9TaexVsfDvUML3fOrNDimxSQES32A/48mlKBkJG8bDKOPvcp1BibpvGUiZTUisjTHkXbJ4icHc3VK+ODD5oEOUGjFK8YtWShvHBI4AzpjW0BkbVF1EhX3J/trDE32SrHoar3cuJ8CKn+3Q== 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=+RrS3pBftpW+rYNv9y4Q74Mu4XrZWh0ENyzEwr8Pieg=; b=IaUxVTdXK8R6e9I37hWH52iiWbpZKxyxZ13C8U2ul5m0bWic9sb5NVqu1aCv5VcC9jtICLJOtC4nSnvPvjpX21ixLPDV+2TliebaseBvvmbEjKUpKkEcWcQKwEEy/IIBQxSSxcXZCBOSkyDSEy7PaIxcuWtZiwlJOdsW4sFvaOI= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) by MN2PR11MB3709.namprd11.prod.outlook.com (2603:10b6:208:f3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.21; Tue, 7 Jul 2020 03:22:34 +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.3153.029; Tue, 7 Jul 2020 03:22:34 +0000 From: "Xia, Chenbo" To: Adrian Moreno , "dev@dpdk.org" , "Ye, Xiaolong" , "shahafs@mellanox.com" , "matan@mellanox.com" , "maxime.coquelin@redhat.com" , "Wang, Xiao W" , "viacheslavo@mellanox.com" CC: "jasowang@redhat.com" , "lulu@redhat.com" Thread-Topic: [PATCH v3 5/8] vhost: add support for virtio status Thread-Index: AQHWU4g67X29v8YtsEOioMcjvzKvEaj7dJeQ Date: Tue, 7 Jul 2020 03:22:34 +0000 Message-ID: References: <20200706112452.1474533-1-amorenoz@redhat.com> <20200706112452.1474533-6-amorenoz@redhat.com> In-Reply-To: <20200706112452.1474533-6-amorenoz@redhat.com> Accept-Language: zh-CN, 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.198.147.218] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 926a232c-21af-4ed0-4f25-08d82224fe10 x-ms-traffictypediagnostic: MN2PR11MB3709: 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:5797; x-forefront-prvs: 0457F11EAF x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PQV53SgLT4JzTlWyyWZgq8Ud2PQEo0UbPtMjLbomkAq2WLbGUZ6GAKS4PvZSOmqNLuZgDCIbdRwV2lrQgZRp8PMqIT6cM3AdJcmiiRA+ttiaWo4tNe9GZpJS+7+3zR6ZxidtSMV8pI5810VsAYd4BXeWg/lmd4D4M+/LYcW3vjtrUX/ditYPvr1MhHlP/fdx9sITzRVPkTJdQFpfpn4hj7gH401KU3hvOsnNAAcSgGOcLtTQKTrWdCGVpAOdr/bPkDOFgSvA2HObLqJ2FNeKFnaSRYXGHKImd5X7Q4EcewR9JPtqtmETwzubj+bbWMTjINQ+XO/lLQKdZoz15V0sH9PEeGIxXhuRHwe98gaW52jxUoBKl1VVfWRqFIIrXbYB 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:(4636009)(376002)(366004)(346002)(39860400002)(136003)(396003)(83380400001)(8936002)(478600001)(4326008)(316002)(33656002)(110136005)(5660300002)(54906003)(52536014)(2906002)(9686003)(55016002)(8676002)(53546011)(7696005)(6506007)(76116006)(86362001)(66446008)(64756008)(66556008)(186003)(66476007)(71200400001)(26005)(66946007)(921003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: lvwqWnlV+19X5IbB8eHUW+edhnHBF0Q/lGPhI6mmj8GvyP1zWZd7yaCxq8VvjlYxRBYR4IQ6VDQavdZ2eurUBBHT+cJxXrNY9S40oHSBnpDaiA7dFp6N5O194fLwdwWcUHLZHoXrodMmV6aU9JEqizjAqaw69eKrMPRCuK+aqXp9vf62jekQGJB8uGebnp0VzdpDRtEYP5AfdG0t61RnNj63vRlTkocgttnF4gGwXagwtbjqnBNs81tqYel+hsL69CZulDDMAS8OM9rNxvEKUas2U46SIRjDYUa6sh6eA7z5e1sGAj6m1KB99EbWKHgrdvh+2L+zeC9xzV+D9WRg2sj+K5OXVJ8WGpZHn+ZD6l1ylR/9pggQmzk4I4CpgyjxiRE6+SBenl7Vmo55pT21sex+rzjhpcc+T8RYBRblplfH8FlNc3gYI7C4IsplCi/ORvmoyzb9MM6EX2uK4tZlq+B0E1MI1zbioFozKZ8jENy1NHAKfrqClvfHxbTeeSUU 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: MN2PR11MB4063.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 926a232c-21af-4ed0-4f25-08d82224fe10 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jul 2020 03:22:34.7764 (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: DqDe4fQ8M3Ci0hHAPKyFzvi70vZUA4lo+7AXNPG/lfCmFbPjUzkW4Pjlj4FDpW4TCZ161zu03rqKDIu+s4Pkhg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3709 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v3 5/8] 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" > -----Original Message----- > From: Adrian Moreno > Sent: Monday, July 6, 2020 7:25 PM > To: dev@dpdk.org; Xia, Chenbo ; Ye, Xiaolong > ; shahafs@mellanox.com; matan@mellanox.com; > maxime.coquelin@redhat.com; Wang, Xiao W ; > viacheslavo@mellanox.com > Cc: jasowang@redhat.com; lulu@redhat.com > Subject: [PATCH v3 5/8] vhost: add support for virtio status >=20 > From: Maxime Coquelin >=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 | 45 ++++++++++++++++++++++++++++++++++- > lib/librte_vhost/vhost_user.h | 6 +++-- > 4 files changed, 61 insertions(+), 3 deletions(-) >=20 > diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h = index > 8a5c332c8..104e2e869 100644 > --- a/lib/librte_vhost/rte_vhost.h > +++ b/lib/librte_vhost/rte_vhost.h > @@ -102,6 +102,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 16 #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 > 034463699..25d31c71b 100644 > --- a/lib/librte_vhost/vhost.h > +++ b/lib/librte_vhost/vhost.h > @@ -204,6 +204,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 > + > #define VHOST_MAX_VRING 0x100 > #define VHOST_MAX_QUEUE_PAIRS 0x80 >=20 > @@ -349,6 +357,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 > bf079c914..8d3d13913 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= 350,6 > +1351,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 > if (!(dev->flags & VIRTIO_DEV_RUNNING)) @@ -2452,6 +2458,42 @@ > vhost_user_postcopy_end(struct virtio_net **pdev, struct VhostUserMsg *ms= g, > 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; > + > + if (validate_msg_fds(msg, 0) !=3D 0) > + return RTE_VHOST_MSG_RESULT_ERR; > + > + /* 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); > @@ -2484,6 +2526,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. */ @@ -2= 851,7 > +2894,7 @@ vhost_user_msg_handler(int vid, int fd) > if (!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED)) { > if (vdpa_dev->ops->dev_conf(dev->vid)) > VHOST_LOG_CONFIG(ERR, > - "Failed to configure vDPA device\n") > + "Failed to configure vDPA device\n"); > else > dev->flags |=3D VIRTIO_DEV_VDPA_CONFIGURED; > } > diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.= h index > 1f65efa4a..82885ab5e 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 39, > + VHOST_USER_MAX =3D 41 > } VhostUserRequest; >=20 > typedef enum VhostUserSlaveRequest { > -- > 2.26.2 Reviewed-by: Chenbo Xia