From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 142B3A0544; Wed, 15 Jun 2022 01:56:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A6B6940222; Wed, 15 Jun 2022 01:56:45 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id B41FD40220 for ; Wed, 15 Jun 2022 01:56:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655251003; x=1686787003; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=arAHyY4b96Om1RET7lKqWGWbL+UJaLmx+CwmPo8ZACM=; b=HPp/EZwFsr2xvC48MtJ353EyE3U0hvmjgb0Xce/n/zkjG6UT6tN5U22/ O7VEv0iOX0dd/GVfCpS4Y8E5Q6t+wig963so/ahWow1lpnufaCiooAnzF li1BkorHUL/wt7WhfWJnqn47QNpkgEQW4nJUdCEUtKhEp6aDxdmzGh2ET qwiKeJ2Y7yZLWssRLV8l+w/j6zT8oEJdHzR5J7atYWAM3DIx1e53gs66N uI6LuPDPEVPgk8yhITKeRW/nQkECUabpB9SrBcHnOKQdpzg/nAjJmI6T+ KeUzpMnkA7qcddxrRA/TRz+ijO5Ik3MUpzJOKg7/JJPOB/KQVzMKWnloE Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10378"; a="261804614" X-IronPort-AV: E=Sophos;i="5.91,300,1647327600"; d="scan'208";a="261804614" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2022 16:56:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,300,1647327600"; d="scan'208";a="727079956" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga001.fm.intel.com with ESMTP; 14 Jun 2022 16:56:40 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Tue, 14 Jun 2022 16:56:40 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Tue, 14 Jun 2022 16:56:39 -0700 Received: from fmsmsx612.amr.corp.intel.com ([10.18.126.92]) by fmsmsx612.amr.corp.intel.com ([10.18.126.92]) with mapi id 15.01.2308.027; Tue, 14 Jun 2022 16:56:39 -0700 From: "Hu, Jiayu" To: "Wang, YuanX" , "maxime.coquelin@redhat.com" , "Xia, Chenbo" , "dev@dpdk.org" CC: "Ding, Xuan" , "Pai G, Sunil" Subject: RE: [PATCH v5 2/2] example/vhost: support to clear in-flight packets for async dequeue Thread-Topic: [PATCH v5 2/2] example/vhost: support to clear in-flight packets for async dequeue Thread-Index: AQHYe+W92ClUmpftikyPwyWQy6439q1PnO3g Date: Tue, 14 Jun 2022 23:56:39 +0000 Message-ID: <39e6cea169af4ccfafa97bd74d6af739@intel.com> References: <20220413182742.860659-1-yuanx.wang@intel.com> <20220609173404.1769210-1-yuanx.wang@intel.com> <20220609173404.1769210-3-yuanx.wang@intel.com> In-Reply-To: <20220609173404.1769210-3-yuanx.wang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.6.500.17 dlp-product: dlpe-windows x-originating-ip: [10.239.127.36] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Reviewed-by: Jiayu Hu Thanks, Jiayu > -----Original Message----- > From: Wang, YuanX > Sent: Friday, June 10, 2022 1:34 AM > To: maxime.coquelin@redhat.com; Xia, Chenbo ; > dev@dpdk.org > Cc: Hu, Jiayu ; Ding, Xuan ; Pai > G, Sunil ; Wang, YuanX > Subject: [PATCH v5 2/2] example/vhost: support to clear in-flight packets= for > async dequeue >=20 > This patch allows vring_state_changed() to clear in-flight dequeue packet= s. It > also clears the in-flight packets in a thread-safe way in destroy_device(= ). >=20 > Signed-off-by: Yuan Wang > --- > examples/vhost/main.c | 26 +++++++++++++++++++++----- > 1 file changed, 21 insertions(+), 5 deletions(-) >=20 > diff --git a/examples/vhost/main.c b/examples/vhost/main.c index > e7fee5aa1b..a679ef738c 100644 > --- a/examples/vhost/main.c > +++ b/examples/vhost/main.c > @@ -1543,6 +1543,25 @@ vhost_clear_queue_thread_unsafe(struct > vhost_dev *vdev, uint16_t queue_id) > } > } >=20 > +static void > +vhost_clear_queue(struct vhost_dev *vdev, uint16_t queue_id) { > + uint16_t n_pkt =3D 0; > + int pkts_inflight; > + > + int16_t dma_id =3D dma_bind[vid2socketid[vdev- > >vid]].dmas[queue_id].dev_id; > + pkts_inflight =3D rte_vhost_async_get_inflight(vdev->vid, queue_id); > + > + struct rte_mbuf *m_cpl[pkts_inflight]; > + > + while (pkts_inflight) { > + n_pkt =3D rte_vhost_clear_queue(vdev->vid, queue_id, m_cpl, > + pkts_inflight, dma_id, 0); > + free_pkts(m_cpl, n_pkt); > + pkts_inflight =3D rte_vhost_async_get_inflight(vdev->vid, > queue_id); > + } > +} > + > /* > * Remove a device from the specific data core linked list and from the > * main linked list. Synchronization occurs through the use of the @@ - > 1600,13 +1619,13 @@ destroy_device(int vid) > vdev->vid); >=20 > if (dma_bind[vid].dmas[VIRTIO_RXQ].async_enabled) { > - vhost_clear_queue_thread_unsafe(vdev, VIRTIO_RXQ); > + vhost_clear_queue(vdev, VIRTIO_RXQ); > rte_vhost_async_channel_unregister(vid, VIRTIO_RXQ); > dma_bind[vid].dmas[VIRTIO_RXQ].async_enabled =3D false; > } >=20 > if (dma_bind[vid].dmas[VIRTIO_TXQ].async_enabled) { > - vhost_clear_queue_thread_unsafe(vdev, VIRTIO_TXQ); > + vhost_clear_queue(vdev, VIRTIO_TXQ); > rte_vhost_async_channel_unregister(vid, VIRTIO_TXQ); > dma_bind[vid].dmas[VIRTIO_TXQ].async_enabled =3D false; > } > @@ -1765,9 +1784,6 @@ vring_state_changed(int vid, uint16_t queue_id, int > enable) > if (!vdev) > return -1; >=20 > - if (queue_id !=3D VIRTIO_RXQ) > - return 0; > - > if (dma_bind[vid2socketid[vid]].dmas[queue_id].async_enabled) { > if (!enable) > vhost_clear_queue_thread_unsafe(vdev, queue_id); > -- > 2.25.1