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 09C2AA00C5; Mon, 6 Jul 2020 05:22:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C56241D53C; Mon, 6 Jul 2020 05:22:17 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 9261B1D539 for ; Mon, 6 Jul 2020 05:22:15 +0200 (CEST) IronPort-SDR: 59p7xiQCAWUMui3aCAUy0ZrfxCp1EiroOAxYiD1M0HHy2DLDn1Lk2vsH7oWWA+eAchBUsMM3FO EPDHrOWy67rQ== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="145460992" X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="145460992" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2020 20:22:14 -0700 IronPort-SDR: M79F47liUW7pI7oVV7Mn6NibtTeke2uO7UgfbJOCz0xnzBueE2RAwnixvpdBDUubevqrS9S3Sn ok9AfvGp3hmw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="266430277" Received: from orsmsx102.amr.corp.intel.com ([10.22.225.129]) by fmsmga007.fm.intel.com with ESMTP; 05 Jul 2020 20:22:14 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX102.amr.corp.intel.com (10.22.225.129) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 5 Jul 2020 20:22:14 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX609.amr.corp.intel.com (10.22.229.22) 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 20:22:13 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx609.amr.corp.intel.com (10.22.229.22) 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 20:22:13 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.176) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 5 Jul 2020 20:22:13 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=clf7Y28VkuXRjQCOxg3H9g/iz8DUCM8gsmhxnjFtcZg5dM9tKrkCvFzpo+zCsRsxGTrSaOFc7XyaF31l/mhDQG6Sjyl6Wn8rNY2CF5lfKG6XqUfofHDL+AIRk3ueuWWS7irEq9vntn/xdj+a+t1nl+iNG0DPnnLruBaqXJC4yQ0s6CJMMjHCkDSv+haR02+sWHzO0AuN1uq4xcFw6NrKjeH8irclxytQPNzi47unRe5r0MS3VKyOe2eqzQr5ObZBax2rXzO6eZnXfYj7VF0fS6CLjLgfaZCfEim8l8Gzb4qxz5F5+zKZyk3alxnws+/N5jFRTdU/AwyE4p6dLtg0vw== 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=c0nkLDjd2hf9K1yem3gq0Wbc8+60RJeaRSVpP63V0pA=; b=BdTqC3kDBoxNEiqFxmlPlKDxe0AUKQd/TDNAtm94YD6FS/PaVEAXXGXP9HPGMx183fIwkN8bMkyNnsmucxWBSvUtL2RQNVE0vWCenkyksN/oZ+UHCBU09Wp+08bvRQdGpHLRuJBBJRX4ZqHsZKmSP+pOMOPZiWcpPY4Yur5GPrWpk2b+2/sXhOgd8RnCHLsn7HEg/z5lniJut1qzGtfcJ+y4MolC0h5W+kWRAC0gcx9afL2e+MLF2WTzgpL29RgtFAkD5wQjJQOKLU4CiCnugsW0HvwpgesP7P8pyHkByfPxI2c3h4BQhT+WCZLEihujZ6BpX+tSeUECCSBGIoBrPQ== 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=c0nkLDjd2hf9K1yem3gq0Wbc8+60RJeaRSVpP63V0pA=; b=jjByGGRx2gtHvZ4hUGWhTSs44Mplybq3y3hFtETNE4DzyvjFXAfk88GCAqdZYSshU+wXvODbkb9UcZSfHxF36qrKgmksxteF67KJNw6EuL5wT0AQtaaCFyfR2M6ALxYgaxDE2dPHSPQFHFonwkY63rDnEqvFA9k7E4z82yi7aN4= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) by MN2PR11MB3886.namprd11.prod.outlook.com (2603:10b6:208:137::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24; Mon, 6 Jul 2020 03:22:12 +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; Mon, 6 Jul 2020 03:22:12 +0000 From: "Xia, Chenbo" To: Adrian Moreno , "dev@dpdk.org" , "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/zM8RxEympXeI3QU3E6j55TGQ Date: Mon, 6 Jul 2020 03:22: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: 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: bd54c624-ec83-4670-0497-08d8215bc614 x-ms-traffictypediagnostic: MN2PR11MB3886: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 04569283F9 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: AYj7DRSog5+BAn1Y/aZi+m6F8eoIOcUL3AX4mnA2Na9IN34w+G+TsiKnj33pBp1JecLy1TaSM9wimIpMxSORI1PG+5PxMiQZoC55rXqApmlQlcV4pErL7heN09+vE51G2znqld7B7um/PHEAe1fk+8rH8lrCQxNb5DVtJKfBGtq5S9kxaxSmV8cizUwZrNq6/AN/U4bohyYmWbx8k2jZ6j0PbjarRGJ4M5muoEqo5YzioNABFMvtzOs4ZA3vTFPg5SvAXC6peuumJQtEYlK7O7IkwMidq11Zk88VFysyoIIVACz57E03+QUWY5H8ugd6pR1eCfNw+nYV6OG5TMVJaQ== 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)(376002)(346002)(39860400002)(366004)(136003)(83380400001)(71200400001)(478600001)(110136005)(54906003)(316002)(7696005)(33656002)(52536014)(64756008)(66556008)(66476007)(66946007)(4326008)(8936002)(6506007)(66446008)(186003)(86362001)(26005)(5660300002)(15650500001)(53546011)(76116006)(2906002)(9686003)(55016002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: Nqc9VsSbMJaPeOhH0PM9a1k6L8pEp8wNU5Xbzhxc2LZshAZ9VMejr1tGZh3ZVh/j+mlBDaknqThcU4bK8e+h0W9piu0Q+R4Oh82ybzaCLJenKh34gSOhZT/CZp8RWK5u1FQgariCDV+quXDVcCisNGPvSmfvzaBn3mnOipxXMhMfyYurEPwFPM8iczHAiV6f58vkkS0j5iQ76tpn4sRhhywQEfIb4HJIgdQTnm5Whm8hSNvjzC/93gRecc6gtH8egCI9hiF2fvoHBOHWPc6Afs6g4ESzFHear1CBw5Hq1YoTIZepBDucrzzg4ORyr2WSkkBVfypkAgHzE3b7Kr8GOvnLTh8H3Rztt4UDzpZS1m1FI0YMK4nFIPDoomMthZyQ2KedKEFvTCRY/pQOgQOGqfqfcRaLnWemCKfh0isUK09VGTu18pomrF0cuK37wPynbAPrAlx2iK4bLW10ysgcwFiOqx/VjEpGrlwAi8xnDlvxcwb1b+xeIC+bA9XMhHKg 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: bd54c624-ec83-4670-0497-08d8215bc614 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jul 2020 03:22:11.9527 (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: pWyZAYo0QWOWDUc9KWUEygsdw23LuXtbJ4nwiK9UlZ3daXh6D2EXHEAv0SpDbip2rwg/BwXDEe4u2v3c5xzH4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3886 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; > +} > + > 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; > + } > + There's a coding style issue because of above '}' alignment. Could you fix = this? Another thing I'm not sure: if above condition happens, should it be treate= d as err? If set status is with replay-ack (this will happen, right?), would = QEMU like to know this status is not set? As QEMU should know it during SET_FEAT= URES, I'm not sure whether this will also need NACK when reply-ack enabled. What'= s your opinion? Thanks! Chenbo > 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