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 3888BA04A3; Tue, 16 Jun 2020 06:29:41 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 275C029C6; Tue, 16 Jun 2020 06:29:40 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 1437C25B3 for ; Tue, 16 Jun 2020 06:29:37 +0200 (CEST) IronPort-SDR: Ef23AeK42QXPijhtJbaKzj047Igl5V/M7rmn1K9ALVtc0cLlMDb9C7/1O/mpJftAqn1kujvl+k UdE7NRxv77fg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2020 21:29:36 -0700 IronPort-SDR: OvSm59M396P0jR1vWFsFRdCdk2CBysrTpyeKC00CfeXn271pou2UFMLX78klvl7RZDf3cXMiCI 3CxsoL+xb/3A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,517,1583222400"; d="scan'208";a="476270461" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga006.fm.intel.com with ESMTP; 15 Jun 2020 21:29:36 -0700 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 15 Jun 2020 21:29:36 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 15 Jun 2020 21:29:36 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.175) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 15 Jun 2020 21:29:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HCOMEtTn9z5VSdoCUKX0lssBB6cLa2X23eJwTqEx0bhcEnf7T9hDYqEp3R7emaMdCJwgq76HsM8bBs1T/NkGXLfjsIrKZQDzwttw6QrjmA+OJLOAsb7klHTQYET/tm31gU/Gx1ZVDbGF9ta/H0a/lHaB1EjzH9UJgdGy6n06sNfW3mwPV/OQaHYAC1i4Gb19/EnSR7C83I816WRsj4a99+ZUwzw4odEBvol+n4d1d2TfEMvigv0hsdtEJiBxsf1Suy3eHj8/siY6SzNw8NTcjhlVhan352EpAB/3EeKNtX0zAkZ6uWq8LXfhJR4C/yNVXZiVPDnV0c6/YCKbj9fhOw== 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=X7B0AKWzY+yhzyE/Trz+AO0I48uQR39/Zall+gIrVog=; b=YmXSjgEzMa8ypekQ45DMayGstdNJRBdW1yUiFDZSp2frMAosoy3AHzHbKmd55ktAspWouaondVWH9YJ3qVtuhSp5mv4IjsKeQPIvutMlfIc0foXU6gp8llkB4x5uo0Mg+pLJIrDxjOs90dPhGN6Z6GK7PM12I5Uw8JhfB22twJf0LePrTgIqBEyaZ/yNTZ3ZA5wIIoHsc+ak5ZJKUrlZTRfHnlyQkxNIV9ELZLYyxBk5LZ7YDisTUCE7OUbWNpL5K88I1IEejyYIZIGKAZJm7oXqq4XhIDQzVTlC59sP19esDpVQPHmkWOmxbYsB83eY1xKfI4KRMncGnNj8PSbXHg== 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=X7B0AKWzY+yhzyE/Trz+AO0I48uQR39/Zall+gIrVog=; b=AXyTIXiyvDu1uCV65KfayChCznLu9gjxWtDP1muyDxFdnrHHe882rmDYnrjoATNHYtRx5wWQbrniZLWmC9bb/9XbfHoXUP/7srB1vrGLJtePf9owtCrTIYutYGIkEJGyfh4vkPIB4dSymnpFRhAOJgH9KELrvsaV9VDlQulT9Bo= 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; Tue, 16 Jun 2020 04:29: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.3088.028; Tue, 16 Jun 2020 04:29:34 +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: AQHWKcZfIj7EohmpPEWIeBQ96BO3A6ja2HAw Date: Tue, 16 Jun 2020 04:29:33 +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: 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.55.46.36] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 18f3929c-c577-4c34-a2a7-08d811addef9 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:9508; x-forefront-prvs: 04362AC73B x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: T3p5yx1UyZNGgVOjqfvO6ML/KZuNZN3+zv1v7gk4VIfMXSYPwXR3ufreAD6LJ4pkks9V0WtzpvpLRKpoweZir9576bsSkyzd5rzzbmegACg4N6c7vNqUyoSVDN2G81Xc/knukviq/cKmsecKcPiDbOyUmJ8vvtBpBZV2RaIOSD0LiCnxOfn8Zt5b6Wlq9dO9fSU75pf7cwT2l2ELzFU16P4NPlnnazg8NEMGO0Mlg9m2HHm12LVbqAXk3PeWOLu/UjlrSQGAG52rO6kqs/7JACl19oYNOypHLkLduCPs8QFzbfcc7wyVV/miL/54zY4jFKK6DjcBjk6FFJHqvDd5Q2xbD72R6sDqrfdnC7LHdJ4hPEF3+m08xNuvaN4FtUEcUqoYpXZHnr/iRW53SHas5orkN7P+f78imPKqbQHKXKIrRKYwLzLPEHTN0nxxZWsjWbbI24TztiHQ2bVytvyucA== 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)(366004)(136003)(396003)(39860400002)(346002)(55016002)(9686003)(83380400001)(71200400001)(66556008)(66946007)(66476007)(86362001)(52536014)(33656002)(66446008)(64756008)(2906002)(76116006)(6506007)(54906003)(7696005)(316002)(26005)(478600001)(186003)(110136005)(8676002)(53546011)(5660300002)(8936002)(4326008)(921003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: xYbbJ/dc8/cArv+9bmk738KaJHc8cFeKLe7iNq4CR2mCrXhBViKLLuXn/KYAPuzC4TeU90HKdzaN2dolrttyLQzXn+2f4FR0BHbUTJajcoWqgV6f+TdJg0QhrAdv2yqGr069Rq4LyuFR9tAhVs/wToLf5KmotrXuopSfyTQhrjKGhKDB+zujwrhcGF0yjGAzAsWiMWd7GiW4Nt2GHmHHh3xcshFRyKYdKvMNlmKiKFtP5nuf6whLfyyS+9kWdxQYbMYGX1qTHI03OfINgFOBbteTADKb/ZHedHTq6Ge0hD9c0rQ4jbzsR/d8cLeHkpI9wMW0b3TvvgcYePA5zCVyjirD2HWPvNuWs5dcSPOKKLjxOr9HDP4356LxVoFo1Wt/bscc5Om7KkjYWPE3Yjkd+9jvM1h+93/Dl/DnBSOEJLI//mQWitVAEfvrdLbMQ2i9o7B6kCnWzhQSFmz2XAcHcUtYKP3DAfcNNpI8AWknQEU= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 18f3929c-c577-4c34-a2a7-08d811addef9 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jun 2020 04:29:33.8523 (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: /oqJbibFU1Bqtj4vzbVW1rX8mE9NE9edBpiCKF405pi9efupHM/j3lNzN6BUzxAkD0vSp4mxMpPtgvA/+OUeXw== 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; > + > + /* 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; I see in your patch for virtio-user SET_STATUS support (http://patchwork.dp= dk.org/patch/70677/), the=20 VHOST_USER_SET_STATUS msg may request a reply, but this func does not handl= e this case. If we don't handle here, vhost_user_msg_handler will return RTE_VHOST_MSG_RESULT_ERR l= ater. So should we handle the case here? Thanks, Chenbo > +} > + > 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