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 2E7DEA00BE; Tue, 7 Jul 2020 05:22:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 120B41DD67; Tue, 7 Jul 2020 05:22:55 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id ED7AC1DD37 for ; Tue, 7 Jul 2020 05:22:52 +0200 (CEST) IronPort-SDR: FLBbE0hrIjd1X/rKkY17r+Ra1oJAPOZnLVrMgl8LdU9CSyNKQRt1C1MyqitdrIacMpBKVytx05 SJ/EcuGqdArw== X-IronPort-AV: E=McAfee;i="6000,8403,9674"; a="149043712" X-IronPort-AV: E=Sophos;i="5.75,321,1589266800"; d="scan'208";a="149043712" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 20:22:52 -0700 IronPort-SDR: lmGSqoAsks0eMGaS4Qw1LxUcpVHSKV3E7x2OX44TtKFMm5IUlyo2Abibf8GoulgH+IDsJeIKuT fz5Scrm/t1Ig== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,321,1589266800"; d="scan'208";a="297209964" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga002.jf.intel.com with ESMTP; 06 Jul 2020 20:22:51 -0700 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 6 Jul 2020 20:22:51 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 6 Jul 2020 20:22:51 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.172) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 6 Jul 2020 20:22:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b6ccjJ1hqE1uIgWNPoIC55leaJ158oZiVuYDuCH1kO0fXvL6dfkwkF3D9ko3IOhAJYBLNprbH9xHiXcPjrpvO002x1EdsJ4MoW2Kd3wqH+i9chNFd7Npv4U0hWhwQyrg58FK2F/p2mb7FZHw2ru1KrEI0BdiCoymgQeWmzt6qvovGwsffTt7UoVAMMiQtqSe+EKMHvh8P909ooNfHlK68A+KZMBqC9DLgaD28HQayKT3MbkHyM9ErWjA2REsrzDLBZt1toPjVVIYiYPjXKal+95vuk8Z/xANNsL0rnoT2oAIZvhTwVlgX9aYwNs/m8TFpF941HXW4BsGhI2fW9sOhw== 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=APf9vQ75zF12/aB2nM/GzWq3z3VfeAnGnhufi+6kaLc=; b=FGnRXUtHG7P1nXDTSpFiatUzR7HN9bF04RSU76i20wgqDa0CKf23nkuOFBZX7ph2j5U4g8QHgZfLrDE5hc6JQfMlBOb2Q3MuiJCUGHg0eC5Cuialq93Fg29JFkuZXzAmGqo+NRETnq8P/CG6AaF8fBf9IV+SM0ppdjNqu+tlyRf43q00Ed/qYW0El3b+Xe1SZ87X+1awWMmh001Y+MksAE7YpiY3ulKaDnlEeq4WnbOlTFBgf+56iiHBwoOf7WPTqsgb6rMADmEURphgBJ2xP2XLsvJjt6FDEpiuCts9Iqx2c9kMIsgIo2nYmTHOcjQ9eiZm6IqK7k6YbztqcEoE7w== 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=APf9vQ75zF12/aB2nM/GzWq3z3VfeAnGnhufi+6kaLc=; b=E0NidKS31SvkEwGgI2P3XUtayHXjejbuI/3+jWrT5jPJZEGhWp4Zcef0PjoQbvFa18pRBzIKn7VeG8GcqcFCiMBf9IVqYGCJGNiJSWZc3BvACitAFAJXJ2d8WgdbztAlEMVKu0EPSNr1mwKBhCzTVwQ+NuLTZexy6ReFlbijBbw= 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:49 +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:49 +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 6/8] vhost: add support for virtio get status message Thread-Index: AQHWU4g+kcM12972rkKUPsgQIREpNaj7dKdQ Date: Tue, 7 Jul 2020 03:22:48 +0000 Message-ID: References: <20200706112452.1474533-1-amorenoz@redhat.com> <20200706112452.1474533-7-amorenoz@redhat.com> In-Reply-To: <20200706112452.1474533-7-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: 07516ca7-7ab7-42d5-96ad-08d82225067b 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:7691; x-forefront-prvs: 0457F11EAF x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: gbSWn3A91RteSy81d+5NRx8AJV0vtZCbe1iQn7tNnELpMXbBtSwojUVOoZRo0k7YyWAjUAHJp2EtmgqcOBSm7zgm9ro6d3aaJbjnSvn2HStyb7svwo2toY0P8ix6GkjK/CwFRZodU/sBgBQzqre+1N8ec1bSYB881+k3qkllKwBdSjVc0VNmeEdcYPrvkHOe//nhkfFWC48KfvVXbTw1Dt0xR/m9cc3CKCA2Gb/+6S9NM++TM4YJ7xw6sUsypLSa+6MwefAmVxk5tTh4LimZiv2FDgkXCTAppBs1LAyfTdmW/v/P+IyGUzQ9orEu5GX0e6V+Cht7DVwKVKI1TvuBEuEc6yYYXPHQYvGTUiP2LpikvRzvAuMBvVPihqzqpyso 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)(15650500001)(71200400001)(26005)(66946007)(921003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: P68LWyzPRXc7ybeb/ytU1KQyB0Rfqq6veV5kOQd+VtBo++7rjbYrvSTPtVkWvM015kzX2HxXCfJwODiCGm5JL6tAoGngrVSA0s4fZwHWVz3xkhhbbd1d+ZTnYNhng8KrgESoQvuQ6ei45y4+HtyNR7W0OdoYFt37wrS8zYy8GmSzw9+LNUMOWSqodxOwxwSKMlnGL7HK8N/0G3iPnnAbNztHrXr+wk6BwoPw2/9N8e7HVudXqJfPquyXe+Xan5pbAsuhP0mpxsOFNxb+ToGPItBEdOxq0kAgf9YuErK2wLQ/E47qi2K5JJCZBrR1Kl1cX/T23sZjE7LEJWWU2sMtA4Lzh+8gTP3x551fboXnHoAfwQP+btnP4ICzyKXzrT2OvIuOEyXSA8KDv3tbA/1n1Wmm4TDkDHaKkEsCMqOkTHhWjIcu1jPQQwW+kU3e7pB01RSUm8ur69voyeo1dNyx2ogZSxb+3uMDmHF1lDDuwq63+jjj2pZ4tsvZ2VW4jrtg 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: 07516ca7-7ab7-42d5-96ad-08d82225067b X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jul 2020 03:22:48.8923 (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: ZljzT2yMePssCCl6Iz5WIQeuGAXpD3pEI62iwYej2lvJWo4gH/dD9c2hRkweXaMtpsnA3ka4o/AuV1mOMpvlEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3709 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v3 6/8] vhost: add support for virtio get status message 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; Adrian Moreno > > Subject: [PATCH v3 6/8] vhost: add support for virtio get status message >=20 > This patch adds support to the new Virtio device get status Vhost-user me= ssage. >=20 > The driver can send this new message to read the device status. >=20 > One of the uses of this message is to ensure the feature negotiation has > succeded. According to the virtio spec, after completing the feature neg= otiation, > the driver sets the FEATURE_OK status bit and re-reads it to ensure the d= evice > has accepted the features. >=20 > This patch also clears the FEATURE_OK status bit if the feature negotiati= on has > failed to let the driver know about his failure. >=20 > Signed-off-by: Adrian Moreno > --- > lib/librte_vhost/vhost.h | 2 ++ > lib/librte_vhost/vhost_user.c | 32 ++++++++++++++++++++++++++++++++ > lib/librte_vhost/vhost_user.h | 1 + > 3 files changed, 35 insertions(+) >=20 > diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index > 25d31c71b..e743821cc 100644 > --- a/lib/librte_vhost/vhost.h > +++ b/lib/librte_vhost/vhost.h > @@ -32,6 +32,8 @@ > #define VIRTIO_DEV_BUILTIN_VIRTIO_NET 4 > /* Used to indicate that the device has its own data path and configured= */ > #define VIRTIO_DEV_VDPA_CONFIGURED 8 > +/* Used to indicate that the feature negotiation failed */ #define > +VIRTIO_DEV_FEATURES_FAILED 16 >=20 > /* Backend value set by guest. */ > #define VIRTIO_DEV_STOPPED -1 > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.= c index > 8d3d13913..5b6f4fb62 100644 > --- a/lib/librte_vhost/vhost_user.c > +++ b/lib/librte_vhost/vhost_user.c > @@ -88,6 +88,7 @@ static const char *vhost_message_str[VHOST_USER_MAX] > =3D { > [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", > + [VHOST_USER_GET_STATUS] =3D "VHOST_USER_GET_STATUS", > }; >=20 > static int send_vhost_reply(int sockfd, struct VhostUserMsg *msg); @@ -3= 39,6 > +340,9 @@ vhost_user_set_features(struct virtio_net **pdev, struct > VhostUserMsg *msg, > VHOST_LOG_CONFIG(ERR, > "(%d) received invalid negotiated features.\n", > dev->vid); > + dev->flags |=3D VIRTIO_DEV_FEATURES_FAILED; > + dev->status &=3D ~VIRTIO_DEVICE_STATUS_FEATURES_OK; > + > return RTE_VHOST_MSG_RESULT_ERR; > } >=20 > @@ -402,6 +406,7 @@ vhost_user_set_features(struct virtio_net **pdev, str= uct > VhostUserMsg *msg, > if (vdpa_dev) > vdpa_dev->ops->set_features(dev->vid); >=20 > + dev->flags &=3D ~VIRTIO_DEV_FEATURES_FAILED; > return RTE_VHOST_MSG_RESULT_OK; > } >=20 > @@ -2458,6 +2463,22 @@ vhost_user_postcopy_end(struct virtio_net **pdev, > struct VhostUserMsg *msg, > return RTE_VHOST_MSG_RESULT_REPLY; > } >=20 > +static int > +vhost_user_get_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; > + > + msg->payload.u64 =3D dev->status; > + msg->size =3D sizeof(msg->payload.u64); > + msg->fd_num =3D 0; > + > + return RTE_VHOST_MSG_RESULT_REPLY; > +} > + > static int > vhost_user_set_status(struct virtio_net **pdev, struct VhostUserMsg *msg= , > int main_fd __rte_unused) > @@ -2476,6 +2497,16 @@ vhost_user_set_status(struct virtio_net **pdev, > struct VhostUserMsg *msg, >=20 > dev->status =3D msg->payload.u64; >=20 > + if ((dev->status & VIRTIO_DEVICE_STATUS_FEATURES_OK) && > + (dev->flags & VIRTIO_DEV_FEATURES_FAILED)) { > + VHOST_LOG_CONFIG(ERR, "FEATURES_OK bit is set but feature > negotiation failed\n"); > + /* > + * Clear the bit to let the driver know about the feature > + * negotiation failure > + */ > + dev->status &=3D ~VIRTIO_DEVICE_STATUS_FEATURES_OK; > + } > + > VHOST_LOG_CONFIG(INFO, "New device status(0x%08x):\n" > "\t-ACKNOWLEDGE: %u\n" > "\t-DRIVER: %u\n" > @@ -2527,6 +2558,7 @@ static vhost_message_handler_t > vhost_message_handlers[VHOST_USER_MAX] =3D { > [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, > + [VHOST_USER_GET_STATUS] =3D vhost_user_get_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 > 82885ab5e..16fe03f88 100644 > --- a/lib/librte_vhost/vhost_user.h > +++ b/lib/librte_vhost/vhost_user.h > @@ -58,6 +58,7 @@ typedef enum VhostUserRequest { > VHOST_USER_GET_INFLIGHT_FD =3D 31, > VHOST_USER_SET_INFLIGHT_FD =3D 32, > VHOST_USER_SET_STATUS =3D 39, > + VHOST_USER_GET_STATUS =3D 40, > VHOST_USER_MAX =3D 41 > } VhostUserRequest; >=20 > -- > 2.26.2 Reviewed-by: Chenbo Xia