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 4EB85A00C5; Sun, 5 Jul 2020 15:15:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AACFF1DB2C; Sun, 5 Jul 2020 15:15:41 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 7444A1DAE4 for ; Sun, 5 Jul 2020 15:15:39 +0200 (CEST) IronPort-SDR: p8efYI1xTlerErszHMp5KvvZq2Njw4lQ8sdaD0LQGp2+t+ghFmc8zQtKbESpGb5215z+lmgxQi aeA73xTRPHSg== X-IronPort-AV: E=McAfee;i="6000,8403,9672"; a="147318330" X-IronPort-AV: E=Sophos;i="5.75,316,1589266800"; d="scan'208";a="147318330" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2020 06:15:38 -0700 IronPort-SDR: MRTeQ1pVgC6zLQNN4eG5TL9yFab9rkKvNdSQRhFp+t8ZdR8VMFY6BnVeu03TC/V/1nSPaVxROn qMd56pNQ929g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,316,1589266800"; d="scan'208";a="322157844" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by FMSMGA003.fm.intel.com with ESMTP; 05 Jul 2020 06:15:38 -0700 Received: from orsmsx605.amr.corp.intel.com (10.22.229.18) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sun, 5 Jul 2020 06:15:37 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Sun, 5 Jul 2020 06:15:37 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.173) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 5 Jul 2020 06:15:37 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YY26d6Cg6MN/K089T5NdK30x0m7Yh65p5J+M1mvdbuMe6FZvEogcCgLkGtcvJep99B9tK627hyZXLRywsKx1CKi+bI53ww0xh4cLyOElx8dHklV06D08cAFerYviJolv5rRotQ4jGmG9YP+mnqfQ5TN2DP9p/l1ngXrUIleU8AHh4hg5qnzeH9HhY5tHMexb0N5d+YL4fLSmxbvJKEWGG3f+6/UYooCX6T5UoaJqX/pIUfQUUvvsqxeWtghT9AROychFeR706bw4eP98HPMYu2sBXWTSBKtTB1LaXoLGsDuhtLp0RTX8D6iuwblaRoFZ/ZHh57JMkwgVcrVxfLj3qQ== 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=0fVAyyO+3JodB+gQKLeQC2xbDZcSpdVmB8mN10aVxLM=; b=kLBz+AmgD8SdYCIKLvLe+icF0t9h6qDccT3NI/xNMDqSLpt/HMPrCYSQq2pPRCy3vdoME90ckBdshorQjHGRe8+B9QfvHegouvRL0p78orpmmuekiV5IN8yTOv7gAoaNGrrN1pUIz5yoo6MEx8EnnadWEgMw5O59h5yiwNlzQ+dFIlgvi9c6/FbO+WE9a91rPjEJvT3DqpSPl6OH5gK/cLRTxdkCrjE1bGVxWTBodZTmCxtw3Jy4qkGHcFS65HcQPAGwlfJrTKCVQdqbAwQqK7R5QqPL7mM8Qd2TqrR2mp4u42uDHWJqdtYRElgkJjOMxILm8r+AlLnwhasVA4r5Tg== 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=0fVAyyO+3JodB+gQKLeQC2xbDZcSpdVmB8mN10aVxLM=; b=JYJySsTkJWjZ32AAMPPXZk42W3wjPh8WfDArFtUQRcqrq3tI+4eZR+NV1YrLVMFK4SpEtjJD7zPuRViuo51acGuF9/M2JQBDBZQ8ocRGvjhllun8H88s8C9HWx+e/uNudgb040qv4QDNwxg8hJk0zrcPP9IQE+nB9OyzXRgraYk= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) by MN2PR11MB3901.namprd11.prod.outlook.com (2603:10b6:208:138::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Sun, 5 Jul 2020 13:15:11 +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; Sun, 5 Jul 2020 13:15:11 +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: [dpdk-dev] [PATCH v2 6/8] vhost: add support for virtio get status message Thread-Index: AQHWUEuaCxX/zM8RxEympXeI3QU3E6j4+2bA Date: Sun, 5 Jul 2020 13:15:11 +0000 Message-ID: References: <20200702083237.1215652-1-amorenoz@redhat.com> <20200702083237.1215652-7-amorenoz@redhat.com> In-Reply-To: <20200702083237.1215652-7-amorenoz@redhat.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.2.0.6 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.195] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2a410041-928f-4967-3caf-08d820e572c3 x-ms-traffictypediagnostic: MN2PR11MB3901: 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:8882; x-forefront-prvs: 045584D28C x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: VwucOULvpg0Q6Gn94CCRXAu9+31MAINTo+Lwj0dazeQirv95oPqglUJvwoQMm9aQjLcRz9PQy74r0+aaJ4HFTjs3GQpqpwJVaYCfH3OTNAE/6v5QX3bleG1gehhnOeEmydfLWAvQiiXGxk4VWEujxLT4GRw4wlm3eQUVh1q3h81vgAr0jyfDn7Q+cgqaSpNQwWFM4fPAKM6/KOi5OdcZziyDvp8JjE/N698oKpxTKkjrrcUsj1fSu5gPKbML/RuDthAoFt1PzJWMIHYpg++1xsboUMlFSPzV6JvCMCPKZKbNZUmE8Cs4iu+0wA1/JVCIS3zwWPDL7qe0MOGb4BG5iGz1FsfsmACaF7ZSWuCC/BGnZT+8iFrtqX7O+jCPn9VH 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)(396003)(366004)(136003)(39860400002)(346002)(376002)(15650500001)(52536014)(76116006)(33656002)(66476007)(66556008)(64756008)(66946007)(66446008)(26005)(7696005)(4326008)(186003)(2906002)(6506007)(53546011)(83380400001)(86362001)(478600001)(110136005)(55016002)(8936002)(316002)(5660300002)(9686003)(54906003)(71200400001)(921003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: MhXD8Oc2yYTSJtLwgrVzK9AdvIQ/kk6xVfLKdDy+cRKD84D3jPjaCJb8FGJMBGptah0UVbgGNbSQvQRZgucCxWXvseZdgE6V583Slhi0JaRpJM2FlKIyHLCxO4xTAwtjBZo8vrqto6RsC8PWdNdTvnAu09Zawxmy0jAEFRiIrrkU7hVsaj1ZINL2hzSc0CnI2OWHQSWYN6rh5IZqwTVWQVlMvJphivA6O5Rn+2NHqzhASKxAe/UVURdEVcxLrpAGpzg6/yHSYs2jI0s7yTaS2ePK1scyLx1iuumYy9WZERh34aQBwV0eAZuk206hLDjXvgNbA40iBGHFQE7UqxEyUmWakvcfsO5c4+oad5pgIJf8OZGbV3bcgsw5tyeBAm+8Vn43+3nogbMYtN25ie4GS+gX77zSe4kgiT+T0yqymH9KdfzGle3H+03vxgjutXPQu2IxxIQx1G5pLtsKrb0oWR2nc+rIoVgrR+aC5bgT6FOC6SMl4KkHZD2Q6o8Ad5Sn 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: 2a410041-928f-4967-3caf-08d820e572c3 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jul 2020 13:15:11.6623 (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: MrN57xj36/Ml/dU4YGxLd4QAlzGw/oMIv+ilBNor4G0jj1moWNRit7VHLWmHucj0/6PoxxWfKqGcBRxkMfaWiw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3901 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v2 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" Hi Adrian, > -----Original Message----- > From: dev On Behalf Of Adrian Moreno > Sent: Thursday, July 2, 2020 4:33 PM > To: 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; Adrian Moreno > > Subject: [dpdk-dev] [PATCH v2 6/8] vhost: add support for virtio get stat= us > 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..00da7bf18 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_OK; Should this 'RESULT_OK' be 'RESULT_REPLY' since get_status msg needs a repl= y? Thanks! Chenbo > +} > + > 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