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 081D4A053A; Mon, 27 Jul 2020 15:46:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 958AE1BFDD; Mon, 27 Jul 2020 15:46:42 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id D399A1BFCF for ; Mon, 27 Jul 2020 15:46:40 +0200 (CEST) IronPort-SDR: pPPMdmf7Eaezz7hg4a0luPyrHVvrFQTNV7x+mSoWjqaCm/2yVgaO3AOdF8mpuYzqgjpeCunYJb OpXtSZrPq20w== X-IronPort-AV: E=McAfee;i="6000,8403,9694"; a="235875683" X-IronPort-AV: E=Sophos;i="5.75,402,1589266800"; d="scan'208";a="235875683" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2020 06:46:39 -0700 IronPort-SDR: q3tAemZ0ETT2iGZ792eP0DnabC0uY/GCzoqDheTDYNCtTyOJJAfr8l0fZ4tAaJRTiFlNUaCCjo F/pZU08xzrjg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,402,1589266800"; d="scan'208";a="321805935" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga002.fm.intel.com with ESMTP; 27 Jul 2020 06:46:39 -0700 Received: from orsmsx605.amr.corp.intel.com (10.22.229.18) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 27 Jul 2020 06:46:39 -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; Mon, 27 Jul 2020 06:46:39 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.169) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 27 Jul 2020 06:46:37 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=msG0Bj9LCWMAGPEpb/aEHy75EcQeJ3qOoF06W/tkEt+oPlMRWiuRV9c2C3PDyOvksqzfitBAQX5JRtqa6B8DJe0msyEXCTdwdwnJgUCDDBupfavW2F1qU9Ou3DzEdjqBZTrCZgz+ZArVvbOsaEoLH1LaAhVfGJI1gdQNBLcEpum+heQlKKMCVRuDQFxLTRuBSJE9wS8W+b7qSuLiBprGGRnDbK+stBOQSvMI4Hidm30F1oZ1R/36lLHFv/a5DxR9iCSERefjPz1AI6QH97Pl8nQ4SSpOSOFJFulo3A9B8SbcjqTVx2nS5lZAi010x8/h7d2rFPjN/aI6HqhVMfwO2A== 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=Dlqzm4n7Nz959Lu220GBL86YgxTJsOe1ya+EKSlY240=; b=N5BqqpH52L3QVDAJDtvSnN8s/1xqYxwAzYOBQD7T0zzT9JqhYZQ1JUYeaHVx29Kn+O1E0OarLN8Z9MvFtxQzxULz/kJUSgRhQ4TwkJYvAz0u3p0A7vH7Woae/MiFgCJAVM+jSRMaTy4mI4Faxzrf++Ji1EsYyqldvsXXxFFFBWl/65pvQr1Qhj0r49meKCh5V6VHx3cDR0CWTi/hHOXpUujztqZbXFtTF06kMBi0SJyS7ZQ+vVGF3Mceyxik585oyD9K9ha5USJ5Ld4WP9MFnfUw3G2Gq4a+ILtdJR4XE5yddML13M4Bks5VRfgUlt/SL7vJB2YIiELdSAGXOjN3LA== 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=Dlqzm4n7Nz959Lu220GBL86YgxTJsOe1ya+EKSlY240=; b=lGLwivTYZbF5TT+GSkp7wGEFfp8wMlAXylKuiWlSvEm0GOPH4qQPlrQpA+8K8kczPu2oXQXioRlDXcodGji0TBg6ObIqB2iInem9Efy88JvzHBV/wDPhBXFkTbga0vWJ58HGbmwnZRvFmjQiZwfxJOkx+9XpMQ+hIfdpqn6PiAA= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) by MN2PR11MB3662.namprd11.prod.outlook.com (2603:10b6:208:ee::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.26; Mon, 27 Jul 2020 13:46:35 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::b898:36f5:61cb:42ca]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::b898:36f5:61cb:42ca%7]) with mapi id 15.20.3216.033; Mon, 27 Jul 2020 13:46:35 +0000 From: "Xia, Chenbo" To: Maxime Coquelin , "dev@dpdk.org" , "matan@mellanox.com" , "Liu, Yong" , "Wang, Yinan" CC: "thomas@monjalon.net" , "Yigit, Ferruh" , "david.marchand@redhat.com" Thread-Topic: [PATCH 1/2] vhost: fix guest notification setting Thread-Index: AQHWYPKFu0Vb7SeyC0Of168f2g9NkqkbdpqQ Date: Mon, 27 Jul 2020 13:46:34 +0000 Message-ID: References: <20200723130854.322771-1-maxime.coquelin@redhat.com> <20200723130854.322771-2-maxime.coquelin@redhat.com> In-Reply-To: <20200723130854.322771-2-maxime.coquelin@redhat.com> Accept-Language: en-US, zh-CN 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.193] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2467d71a-1c4c-43b6-d5d5-08d832337a54 x-ms-traffictypediagnostic: MN2PR11MB3662: 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:1201; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 57XQXYGvew/7LDKhSzFZGjNOX8i6i6FoU5Wz2dpNwwM0Uop5wNB5a2FDPuhXZHdH6IVQiV27m8oZJ89T0SVh+wAiprTGtkK3k2kE11uiS6ZPaJsHKo6PrRL9WYTvAGvArgtkbQRw5MiPCVgQEWR2wqzKPaLNEoLbD5SQG7W3M8kaafnkG7q1jk8kt7YnSg4AHQj/r9vfBQw4oSQ598j/X/bjFxqJc0knK4Mt9U0pArcgBYOUx0pKmD3Esvff8rh1UuXWSd2Z4zEoEbSQjHTMscPtqzwboiQCXjRB31rDLAr444Vx+NmeMfPzpjBO0Hsa1q4QxjNeprQwXBrmCTOB9Q== 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)(346002)(366004)(39860400002)(376002)(396003)(136003)(53546011)(52536014)(6506007)(33656002)(110136005)(7696005)(54906003)(86362001)(316002)(186003)(26005)(6636002)(5660300002)(478600001)(71200400001)(2906002)(76116006)(66556008)(66476007)(8936002)(64756008)(66446008)(66946007)(9686003)(4326008)(8676002)(83380400001)(15650500001)(55016002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: ZYkQGm4sss/g6Ee2xiIEeZxAxEThToYu0cDljXt43e8SIB8zGCok522dyYq5cu21kwRZvOdNwG2LDolB9che+GHb7ZqpwkvdeUFLNFI1hXjmYIMzFcEldB2aft2B4gNjCOlsH/VB1uHm0A+nDnC1APg3diWQmde+RFQSOeo9Z9RO58xj3cqImFbAAaiWUNQ9M1EPt1yJxvLLoVgVUg0fhuoFhy1ig2u9n4fRaNi6t8vYilvqACFFJ5GX6sxZMRXtE3rPp6bsOIolLeOiOEqQsxkLFv/87Gev7p+xZqfrhzd9cc0mbza86YDZhe7MBKsUDDVhNruunPc4zWfwE7dyf5tT8yobbOpOYnDynXA+EMreqgIStPjsDUnsGpOJz3uNVDJfwqF2ICKjCitfC6mvfDMOmRnCvqHbNBRNgtCxwLhPtnQUDpNWcJ25Sd4efpALU+1bhdmG/bYsdYBtKjs6Ar1xa0fpQCmaDu++9PvBBXhHdNfv7m24hCgYpUab3yOF 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: 2467d71a-1c4c-43b6-d5d5-08d832337a54 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jul 2020 13:46:34.9306 (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: 7uQ87oFwbaHz7mUB5+pq/D71gtYiQJiXZ3BQW6EYIohQy0WdsgfrFjSOX/A+3D68YNjawxVE/f67CfwblO3GQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3662 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 1/2] vhost: fix guest notification setting 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: Maxime Coquelin > Sent: Thursday, July 23, 2020 9:09 PM > To: dev@dpdk.org; matan@mellanox.com; Xia, Chenbo > ; Liu, Yong ; Wang, Yinan > > Cc: thomas@monjalon.net; Yigit, Ferruh ; > david.marchand@redhat.com; Maxime Coquelin > > Subject: [PATCH 1/2] vhost: fix guest notification setting >=20 > If rte_vhost_enable_guest_notification is called before the virtqueue is = ready, > the configuration is lost. >=20 > This patch fixes this by saving the guest notification enablement value r= equested > by the application, and apply it before the virtqueue is made ready to th= e > application. >=20 > Fixes: 604052ae5395 ("net/vhost: support queue update") >=20 > Reported-by: Yinan Wang > Signed-off-by: Maxime Coquelin > --- > lib/librte_vhost/vhost.c | 24 ++++++++++++++++++++---- > lib/librte_vhost/vhost.h | 5 +++++ > lib/librte_vhost/vhost_user.c | 11 ++++++++--- > 3 files changed, 33 insertions(+), 7 deletions(-) >=20 > diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index > 14b3e253e8..8f20a0818f 100644 > --- a/lib/librte_vhost/vhost.c > +++ b/lib/librte_vhost/vhost.c > @@ -534,6 +534,7 @@ init_vring_queue(struct virtio_net *dev, uint32_t > vring_idx) >=20 > vq->kickfd =3D VIRTIO_UNINITIALIZED_EVENTFD; > vq->callfd =3D VIRTIO_UNINITIALIZED_EVENTFD; > + vq->notif_enable =3D VIRTIO_UNINITIALIZED_NOTIF; >=20 > vhost_user_iotlb_init(dev, vring_idx); > /* Backends are set to -1 indicating an inactive device. */ @@ -1311,6 > +1312,23 @@ vhost_enable_notify_packed(struct virtio_net *dev, > return 0; > } >=20 > +int > +vhost_enable_guest_notification(struct virtio_net *dev, > + struct vhost_virtqueue *vq, int enable) { > + /* > + * If the virtqueue is not ready yet, it will be applied > + * when it will become ready. > + */ > + if (!vq->ready) > + return 0; > + > + if (vq_is_packed(dev)) > + return vhost_enable_notify_packed(dev, vq, enable); > + else > + return vhost_enable_notify_split(dev, vq, enable); } > + > int > rte_vhost_enable_guest_notification(int vid, uint16_t queue_id, int enab= le) > { @@ -1325,10 +1343,8 @@ rte_vhost_enable_guest_notification(int vid, > uint16_t queue_id, int enable) >=20 > rte_spinlock_lock(&vq->access_lock); >=20 > - if (vq_is_packed(dev)) > - ret =3D vhost_enable_notify_packed(dev, vq, enable); > - else > - ret =3D vhost_enable_notify_split(dev, vq, enable); > + vq->notif_enable =3D enable; > + ret =3D vhost_enable_guest_notification(dev, vq, enable); >=20 > rte_spinlock_unlock(&vq->access_lock); >=20 > diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index > 0f7212f888..a29c6638e2 100644 > --- a/lib/librte_vhost/vhost.h > +++ b/lib/librte_vhost/vhost.h > @@ -164,6 +164,9 @@ struct vhost_virtqueue { > int enabled; > int access_ok; > int ready; > + int notif_enable; > +#define VIRTIO_UNINITIALIZED_NOTIF (-1) > + > rte_spinlock_t access_lock; >=20 > /* Used to notify the guest (trigger interrupt) */ @@ -668,6 +671,8 @@ > void vhost_enable_dequeue_zero_copy(int vid); void > vhost_set_builtin_virtio_net(int vid, bool enable); void vhost_enable_ex= tbuf(int > vid); void vhost_enable_linearbuf(int vid); > +int vhost_enable_guest_notification(struct virtio_net *dev, > + struct vhost_virtqueue *vq, int enable); >=20 > struct vhost_device_ops const *vhost_driver_callback_get(const char *pat= h); >=20 > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.= c index > 9ddeae3622..c3c924faec 100644 > --- a/lib/librte_vhost/vhost_user.c > +++ b/lib/librte_vhost/vhost_user.c > @@ -235,6 +235,11 @@ vhost_user_notify_queue_state(struct virtio_net *dev= , > uint16_t index, > int enable) > { > struct rte_vdpa_device *vdpa_dev =3D dev->vdpa_dev; > + struct vhost_virtqueue *vq =3D dev->virtqueue[index]; > + > + /* Configure guest notifications on enable */ > + if (enable && vq->notif_enable !=3D VIRTIO_UNINITIALIZED_NOTIF) > + vhost_enable_guest_notification(dev, vq, vq->notif_enable); >=20 > if (vdpa_dev && vdpa_dev->ops->set_vring_state) > vdpa_dev->ops->set_vring_state(dev->vid, index, enable); @@ - > 1640,8 +1645,8 @@ vhost_user_set_vring_call(struct virtio_net **pdev, str= uct > VhostUserMsg *msg, > vq =3D dev->virtqueue[file.index]; >=20 > if (vq->ready) { > - vhost_user_notify_queue_state(dev, file.index, 0); > vq->ready =3D 0; > + vhost_user_notify_queue_state(dev, file.index, 0); > } >=20 > if (vq->callfd >=3D 0) > @@ -1903,8 +1908,8 @@ vhost_user_set_vring_kick(struct virtio_net **pdev, > struct VhostUserMsg *msg, > } >=20 > if (vq->ready) { > - vhost_user_notify_queue_state(dev, file.index, 0); > vq->ready =3D 0; > + vhost_user_notify_queue_state(dev, file.index, 0); > } >=20 > if (vq->kickfd >=3D 0) > @@ -2917,8 +2922,8 @@ vhost_user_msg_handler(int vid, int fd) > bool cur_ready =3D vq_is_ready(dev, vq); >=20 > if (cur_ready !=3D (vq && vq->ready)) { > - vhost_user_notify_queue_state(dev, i, cur_ready); > vq->ready =3D cur_ready; > + vhost_user_notify_queue_state(dev, i, cur_ready); > } > } >=20 > -- > 2.26.2 Reviewed-by: Chenbo Xia