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 1464DA0557; Thu, 9 Jun 2022 09:51:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 07D374069C; Thu, 9 Jun 2022 09:51:35 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id C317340689 for ; Thu, 9 Jun 2022 09:51:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654761093; x=1686297093; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=a+c8znNhgAoFgA/Io93vsE1UDXPJ7sJm37PEseVaoIU=; b=aCyqaYUQKjA0Nr+in6d0KqHBCS3asHSG81KIxzkWLqEHImNvDrWI1R1k VK9E+/G9CYvsJPMh2VtwgphIMBT2KMw764TQ/W8ipUfbxrh8qH1V0iCKz C8wiIzyacBQLq+Lgp+B4slU/lHQWfKp5EuTlJI7RQDvuc7jKZajDm4IcY 1R0DFdwWCVQkRnor+x931H0zfEV+i5nBp58pZ2kJoOELrvwvSZnSEpYNG Kl+XQL/EyWFeaqX5NpAcM5baLiFCdnIAYAYLWXuPtosH6Po6LGeZnHYOm qB3H24aAHhyGB6Pm6nEZRVSJMoi9OPcglZb8J5ZjseBY9VYAucXA0YzTo A==; X-IronPort-AV: E=McAfee;i="6400,9594,10372"; a="278005999" X-IronPort-AV: E=Sophos;i="5.91,287,1647327600"; d="scan'208";a="278005999" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2022 00:51:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,287,1647327600"; d="scan'208";a="759910617" Received: from orsmsx604.amr.corp.intel.com ([10.22.229.17]) by orsmga005.jf.intel.com with ESMTP; 09 Jun 2022 00:51:31 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 9 Jun 2022 00:51:31 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 9 Jun 2022 00:51:31 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Thu, 9 Jun 2022 00:51:31 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.47) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Thu, 9 Jun 2022 00:51:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OBj6UaXt0B9XkTCCY5/3Otww0yR2p8gcBP56PjDoExQSahrcw7HCUtht56Mzd2kEgNQp3BCZ2JwedTOdEOaVYq0zZG6GzL08jSdrlCsq1xq6tb/qY0q1aYrBE2EuD0LNkrvT6cJ68bf/5LP2g8e91wAaVWRA9ZlahmapzFArDY8KTU6L1PGiZa2ptUkjyRpzRbi72TVVFiqO4rxehpOxiACE31bNsSlyh2XHPxTDnpwFbqvpPH3lDRNhHhZJ7fZWOBRVvB43/ucp2M1amMIsYEUZT+MvnsA9vIs1cJ6bkRaTBPiHLiIqxdKs2XNeVk1nGNQ/+dber5w+wuDd8Mxjyg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gkFBFYR00+FZVyTuZxWYoNVtqyvOejNk33BXeGIp/ag=; b=eJexYaf2rXC+tOMG9Sf41hdcHKDT7IsaeucIVEQNiiBpGeOwzEo6Sle2T0Yn5jgfKFwc7Jkc6h5vhZQZ9Zx3UF763bV3V/wMhip5LrmTLsiLvMQVPX4vWMhxq9Y42IufgoFyGsvme/PihQYW26opbAqMQQqkmYiU2YTXlZGJAq6gegZgYpIUP60FLWGz53OcCqjL2upTyTRIzahmLOmpFyuloY/lTLrkVZPSK2xSmOp4gagbHNmH2zmuhpik1cB3vWG1bhTi0f2L/Xti177djzT8lw3VomoZ4g8llWXgWrMhT4ivv87jA04BIBxnSCFTD6N6Z6pipYcW/FogQhZzMg== 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 Received: from CO1PR11MB4897.namprd11.prod.outlook.com (2603:10b6:303:97::20) by BL1PR11MB6004.namprd11.prod.outlook.com (2603:10b6:208:390::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Thu, 9 Jun 2022 07:51:28 +0000 Received: from CO1PR11MB4897.namprd11.prod.outlook.com ([fe80::a824:370f:1af5:3f57]) by CO1PR11MB4897.namprd11.prod.outlook.com ([fe80::a824:370f:1af5:3f57%7]) with mapi id 15.20.5332.013; Thu, 9 Jun 2022 07:51:28 +0000 From: "Wang, YuanX" To: "Hu, Jiayu" , "maxime.coquelin@redhat.com" , "Xia, Chenbo" , "dev@dpdk.org" CC: "Ding, Xuan" , "Pai G, Sunil" Subject: RE: [PATCH v4 1/2] vhost: support clear in-flight packets for async dequeue Thread-Topic: [PATCH v4 1/2] vhost: support clear in-flight packets for async dequeue Thread-Index: AQHYeYvVcilF6EGLo0mLM+z+zkn3PK1Gq8YAgAAJ4OA= Date: Thu, 9 Jun 2022 07:51:28 +0000 Message-ID: References: <20220413182742.860659-1-yuanx.wang@intel.com> <20220606174507.1272360-1-yuanx.wang@intel.com> <20220606174507.1272360-2-yuanx.wang@intel.com> <799af9123f6d40c3ad3ddc5c889278be@intel.com> In-Reply-To: <799af9123f6d40c3ad3ddc5c889278be@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: cc655053-4d1d-46a8-e7d6-08da49ecdc53 x-ms-traffictypediagnostic: BL1PR11MB6004:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: SvHamrzgav9dNsKPuXLt0VQJ73KXC4iWreQgctVG0Ils9kWUVNLOerCOecOmI3v790o+gQZUIlpVUNYxeuvHzKYMn960RfEqV3aB/jJkO663qxrcGSIdrUdRbMEYFJpgIT9iTh4sfxrONCJucI9hoMo94BtCPInoAZjSFbAdfdD5SarKgTdldkRLyEVsBt/RWUToOJRc8hKjwIV9jlB2SxkoslFfUbCx39IaKKNHzKoQrXo6tcK+FAwDiOq4snv0ZKeMdvpWA4b4vQkbgEoKqX1ODoLSqgkxrmsweisTkWGRxhtyFFAn6Y+UDfIBE90z0UJ5sQV/XLPuEharudcvaetdlMEefxFVtZLUQth17RvAQRknTxcZweSAWF3nRPcz7TlnRQY/JtblFMd+D29reJOk/qPAdm0Wra1Q8eK0+b67s7sz8yOCJL3o+kqXaTqWgNUNriZcEZDObNYnWSckKXjPlWLJCwjYF/O+Zs2WVU3GD2N8E7LTe+ga8K1aZb9jYaY0HlQM9SZL+UdNqTJbfiRuUBEnVVf73/FhXCU1iWawFoMRYbgvC+Qm58eKBF3HtKrubUOd/Q4fzKmSPdPZdJk/VlXTewBGtiRlQHsyf56OW9grkFWDXmGqkyZ1V0BgrWlKS8FNTmk5hY7A+F8z1KCIUP9teJDVoHC/cPNBD7L94Dwh9IpRuWTUpnt9wvUW5+GT3eD8zFjd6MwK1I4IuA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO1PR11MB4897.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(107886003)(52536014)(8676002)(66476007)(83380400001)(2906002)(66946007)(33656002)(66556008)(66446008)(4326008)(64756008)(76116006)(110136005)(5660300002)(71200400001)(86362001)(38100700002)(508600001)(53546011)(7696005)(26005)(9686003)(6506007)(55016003)(186003)(54906003)(8936002)(38070700005)(316002)(122000001)(82960400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?lgBKTZH35qh+/+Sz9kccQ9bhKrOs6Fk8WUFVgUv9M7/oD8ETvG1KnrTMHofY?= =?us-ascii?Q?0YJtB2xnEX/l1mGl7FXInWJxDqX+fHcDXjURRcaA5ZCS9z8OaCQlfmuVTPcQ?= =?us-ascii?Q?NPvqMiybXLgUh+BQXAlHpRNyNxB4mUwqDR4dLRr7Qj7HVVc5wBM9RhnkuN6e?= =?us-ascii?Q?R3PKEdswPCUvhjGotivS/dSwBgh1lPw7A8s5MMmRqWlzK6T92ATkAwMGxtCm?= =?us-ascii?Q?87/3v21mV9+HWscdpdW4VydDtjK9LhUltKTTfoxTMTDaHZbknrVBkNWS/xhs?= =?us-ascii?Q?XuTVDkqNEKuYj9qI9B7vsK5Qy3jrfQ01A0PfTi1IbWh1VqKAZMcIiffVEd8t?= =?us-ascii?Q?FQON/3vDg080LIGKfJ4wIkdYMiEevzZcacPKKODG6xtdqCf3t21slzwhAyX/?= =?us-ascii?Q?zCI3fic+p8DndtGFy5kviGH50qST/R5RFw/ti2GHCuXUaytYitIM1U7vkPfe?= =?us-ascii?Q?+SB3TCM3agixW0ijH3uM92pJRwLSOEbIVGoYyENiLUyl1A3BL3F4IQ9eObs3?= =?us-ascii?Q?Pz8Fb3F6SX3p8gV6bnRiKvuufKe5W+WO14XT+7uydVVo1KL8RCv8Y5qF2DW8?= =?us-ascii?Q?wbUdO9vseM7bhy74pCh/OneB0wKPnBQv6v2pJiiqBdLr08qTtbnXvBhX7ulT?= =?us-ascii?Q?jV2PMO6urNRhwWnmsKRMo1vn2chQ6aevypJbpfI4Iy6+4UauUqvNm0k42PN0?= =?us-ascii?Q?k0vi7t5ckID2uS4t8weo874exE0aAxrY+Y8d53b6OcKo6WJEXw3CjMvso6Uz?= =?us-ascii?Q?5rKrE1tR2IhIvZLs5JmpkhQmwlfoBg5DfMhMMoQYE13saxNRmzHHjPoJJjtb?= =?us-ascii?Q?Zsnx74DtEWEwNvIGXEcmDnDwIY7UOQHANUC5t96EeqymkNAMaQJzzqHQFMKb?= =?us-ascii?Q?qX6X5MRnqnCe5uxIRWcDjXf4BYs0iYAFgKt+Y/Et8MbDR8ytWs4s4MVlHHeO?= =?us-ascii?Q?g/A5wMOwh+Fh/hL9MDHn6zmnX52lIzRC/0oEe0MOzZVRmfJWBlojTobrgc20?= =?us-ascii?Q?Gz0kN9uYOvwXdSmfqyv9ttai8YmjlJs2w4FZ8JLIS76/cZ3HMUmOFPApch5C?= =?us-ascii?Q?wCHfb56R6VAHB6gY+B9vd36S4U0AXspNsok+rx8715og0zmXvqwuGnofUTb4?= =?us-ascii?Q?BNbbBj2thS+mvpz1JInEI6Tfige+J+LNq5viXHcCicpeC23wqfw5+7D9YH4C?= =?us-ascii?Q?ZlV1G6keI4QcZrthFwe1+NK4Ss3enh2ihQia4vXiDN+RYVCKkMvmiBXZ2xDy?= =?us-ascii?Q?QQjyyDrWuQFRH3As/IXETEPImMbELVi8UNBt7QWLyY51wRtUqkOueRxWTw8X?= =?us-ascii?Q?LjGkqUTUhs3uAjI7LcdQwKX4jprSxMyllGBYGWeJZ0j7Eddqkt/IPnzqfiwB?= =?us-ascii?Q?ilCBKG6hoSAX3zpkYeoMDCkm7E6+NIL4wHJ62VnaeyVnt6hel/tGDS2zggFX?= =?us-ascii?Q?FaiEzXTYme+ot2A3W1NsMFmydQHmr+ya9ovEp90VCXvfD3pTjU/ivbxbC221?= =?us-ascii?Q?DQKEr+wbqQXYcBSLqdkZh+8e2CZOX/kdRfsmPXGfcLFat8m5pkM3G1Fw+/zK?= =?us-ascii?Q?i42kTAQF3pMss/Ij9WlDyo3xZGwXD1WsjbeaLKrM8toxfaN3QorByrEPnjbr?= =?us-ascii?Q?vn1xR6CFWXBV4qOa71h9wpEIuOfgzZ3KXEHuuGaMdN+ZLUPn1xp9AG9N5c8b?= =?us-ascii?Q?b0EmKj54vonlDn7/4Z5+WOxr2RnuSWSPVBenzPQt4VFXbmGr6kQaQfm8BJrZ?= =?us-ascii?Q?7EYiEcoPzA=3D=3D?= 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: CO1PR11MB4897.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc655053-4d1d-46a8-e7d6-08da49ecdc53 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jun 2022 07:51:28.3317 (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: IEfw0PZ1qJ9LjVXKekEGNEoW2V0FS7EymiLAep5tOjtnPI31jUxQGn81tndZpVX4q0Dz07ngbozDWvPyRyWSAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6004 X-OriginatorOrg: intel.com 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 Hi Jiayu, > -----Original Message----- > From: Hu, Jiayu > Sent: Thursday, June 9, 2022 3:06 PM > To: Wang, YuanX ; maxime.coquelin@redhat.com; > Xia, Chenbo ; dev@dpdk.org > Cc: Ding, Xuan ; Pai G, Sunil > Subject: RE: [PATCH v4 1/2] vhost: support clear in-flight packets for as= ync > dequeue >=20 > Hi Yuan, >=20 > > -----Original Message----- > > From: Wang, YuanX > > Sent: Tuesday, June 7, 2022 1:45 AM > > To: maxime.coquelin@redhat.com; Xia, Chenbo ; > > dev@dpdk.org > > Cc: Hu, Jiayu ; Ding, Xuan ; > > Pai G, Sunil ; Wang, YuanX > > > > Subject: [PATCH v4 1/2] vhost: support clear in-flight packets for > > async dequeue > > > > rte_vhost_clear_queue_thread_unsafe() supports to clear in-flight > > packets for async enqueue only. But after supporting async dequeue, > > this API should support async dequeue too. > > > > This patch also adds the thread-safe version of this API, the > > difference between the two API is that thread safety uses lock. > > > > These APIs maybe used to clean up packets in the async channel to > > prevent packet loss when the device state changes or when the device is > destroyed. > > > > Signed-off-by: Yuan Wang > > --- > > doc/guides/prog_guide/vhost_lib.rst | 8 ++- > > doc/guides/rel_notes/release_22_07.rst | 5 ++ > > lib/vhost/rte_vhost_async.h | 25 ++++++++ > > lib/vhost/version.map | 1 + > > lib/vhost/virtio_net.c | 82 +++++++++++++++++++++++++- > > 5 files changed, 118 insertions(+), 3 deletions(-) > > > > diff --git a/doc/guides/prog_guide/vhost_lib.rst > > b/doc/guides/prog_guide/vhost_lib.rst > > index cd3f6caa9a..b9545770d0 100644 > > --- a/doc/guides/prog_guide/vhost_lib.rst > > +++ b/doc/guides/prog_guide/vhost_lib.rst > > @@ -288,7 +288,13 @@ The following is an overview of some key Vhost > > API > > functions: > > > > * ``rte_vhost_clear_queue_thread_unsafe(vid, queue_id, **pkts, count, > > dma_id, vchan_id)`` > > > > - Clear inflight packets which are submitted to DMA engine in vhost > > async data > > + Clear in-flight packets which are submitted to async channel in > > + vhost async data path without performing any locking. Completed > > + packets are >=20 > Better specify "without performing locking on virtqueue". >=20 > > + returned to applications through ``pkts``. > > + > > +* ``rte_vhost_clear_queue(vid, queue_id, **pkts, count, dma_id, > > +vchan_id)`` > > + > > + Clear in-flight packets which are submitted to async channel in > > + vhost async data > > path. Completed packets are returned to applications through ``pkts`= `. > > > > * ``rte_vhost_vring_stats_get_names(int vid, uint16_t queue_id, > > struct rte_vhost_stat_name *names, unsigned int size)`` diff --git > > a/doc/guides/rel_notes/release_22_07.rst > > b/doc/guides/rel_notes/release_22_07.rst > > index c81383f4a3..2ca06b543c 100644 > > --- a/doc/guides/rel_notes/release_22_07.rst > > +++ b/doc/guides/rel_notes/release_22_07.rst > > @@ -147,6 +147,11 @@ New Features > > Added vhost async dequeue API which can leverage DMA devices to > > accelerate receiving pkts from guest. > > > > +* **Added thread-safe version of inflight packet clear API in vhost > > +library.** > > + > > + Added an API which can clear the inflight packets submitted to the > > + async channel in a thread-safe manner in the vhost async data path. > > + > > Removed Items > > ------------- > > > > diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h > > index > > a1e7f674ed..1db2a10124 100644 > > --- a/lib/vhost/rte_vhost_async.h > > +++ b/lib/vhost/rte_vhost_async.h > > @@ -183,6 +183,31 @@ uint16_t > rte_vhost_clear_queue_thread_unsafe(int > > vid, uint16_t queue_id, > > struct rte_mbuf **pkts, uint16_t count, int16_t dma_id, uint16_t > > vchan_id); > > > > +/** > > + * This function checks async completion status and clear packets for > > + * a specific vhost device queue. Packets which are inflight will be > > + * returned in an array. > > + * > > + * @param vid > > + * ID of vhost device to clear data > > + * @param queue_id > > + * Queue id to clear data > > + * @param pkts > > + * Blank array to get return packet pointer > > + * @param count > > + * Size of the packet array > > + * @param dma_id > > + * The identifier of the DMA device > > + * @param vchan_id > > + * The identifier of virtual DMA channel > > + * @return > > + * Number of packets returned > > + */ > > +__rte_experimental > > +uint16_t rte_vhost_clear_queue(int vid, uint16_t queue_id, struct > > +rte_mbuf **pkts, uint16_t count, int16_t dma_id, uint16_t vchan_id); > > + > > /** > > * The DMA vChannels used in asynchronous data path must be configured > > * first. So this function needs to be called before enabling DMA > > diff --git a/lib/vhost/version.map b/lib/vhost/version.map index > > 4880b9a422..9329f88e79 100644 > > --- a/lib/vhost/version.map > > +++ b/lib/vhost/version.map > > @@ -95,6 +95,7 @@ EXPERIMENTAL { > > rte_vhost_vring_stats_reset; > > rte_vhost_async_try_dequeue_burst; > > rte_vhost_driver_get_vdpa_dev_type; > > +rte_vhost_clear_queue; > > }; > > > > INTERNAL { > > diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index > > 68a26eb17d..a90ae3cb96 100644 > > --- a/lib/vhost/virtio_net.c > > +++ b/lib/vhost/virtio_net.c > > @@ -26,6 +26,11 @@ > > > > #define MAX_BATCH_LEN 256 > > > > +static __rte_always_inline uint16_t > > +async_poll_dequeue_completed_split(struct virtio_net *dev, struct > > vhost_virtqueue *vq, > > +struct rte_mbuf **pkts, uint16_t count, int16_t dma_id, uint16_t > > +vchan_id, bool legacy_ol_flags); > > + > > /* DMA device copy operation tracking array. */ struct > > async_dma_info dma_copy_track[RTE_DMADEV_DEFAULT_MAX]; > > > > @@ -2155,7 +2160,7 @@ rte_vhost_clear_queue_thread_unsafe(int vid, > > uint16_t queue_id, return 0; > > > > VHOST_LOG_DATA(DEBUG, "(%s) %s\n", dev->ifname, __func__); -if > > (unlikely(!is_valid_virt_queue_idx(queue_id, 0, dev->nr_vring))) { > > +if (unlikely(queue_id >=3D dev->nr_vring)) { > > VHOST_LOG_DATA(ERR, "(%s) %s: invalid virtqueue idx %d.\n", > > dev->ifname, __func__, queue_id); return 0; @@ -2182,7 +2187,18 @@ > > rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id, > > return 0; } > > > > -n_pkts_cpl =3D vhost_poll_enqueue_completed(dev, queue_id, pkts, count= , > > dma_id, vchan_id); > > +if (queue_id % 2 =3D=3D 0) >=20 > Replace "%" with "&" should help the performance a bit. >=20 > > +n_pkts_cpl =3D vhost_poll_enqueue_completed(dev, queue_id, pkts, > count, > > +dma_id, vchan_id); else { if (unlikely(vq_is_packed(dev))) > > +VHOST_LOG_DATA(ERR, > > +"(%d) %s: async dequeue does not > > support packed ring.\n", > > +dev->vid, __func__); > > +else > > +n_pkts_cpl =3D > > async_poll_dequeue_completed_split(dev, vq, pkts, count, > > +dma_id, vchan_id, dev->flags & > > VIRTIO_DEV_LEGACY_OL_FLAGS); > > +} > > > > vhost_queue_stats_update(dev, vq, pkts, n_pkts_cpl); > > vq->stats.inflight_completed +=3D n_pkts_cpl; @@ -2190,6 +2206,68 @@ > > rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id, > > return n_pkts_cpl; } > > > > +uint16_t > > +rte_vhost_clear_queue(int vid, uint16_t queue_id, struct rte_mbuf > > +**pkts, uint16_t count, int16_t dma_id, uint16_t vchan_id) { struct > > +virtio_net *dev =3D get_device(vid); struct vhost_virtqueue *vq; > > +uint16_t n_pkts_cpl =3D 0; > > + > > +if (!dev) > > +return 0; > > + > > +VHOST_LOG_DATA(DEBUG, "(%s) %s\n", dev->ifname, __func__); if > > +(unlikely(queue_id >=3D dev->nr_vring)) { VHOST_LOG_DATA(ERR, > "(%s) %s: > > +invalid virtqueue > > idx %d.\n", > > +dev->ifname, __func__, queue_id); > > +return 0; > > +} > > + > > +vq =3D dev->virtqueue[queue_id]; > > + > > +if (!rte_spinlock_trylock(&vq->access_lock)) { VHOST_LOG_DATA(ERR, > > +"(%d) %s: failed to clear async queue id %d, > > virtqueue busy.\n", > > +dev->vid, __func__, queue_id); > > +return 0; > > +} >=20 > Failing to acquire the lock shouldn't be treated as an error. >=20 > > + > > +if (unlikely(!vq->async)) { > > +VHOST_LOG_DATA(ERR, "(%s) %s: async not registered for > > queue id %d.\n", > > +dev->ifname, __func__, queue_id); > > +goto out_access_unlock; > > +} > > + > > +if (unlikely(!dma_copy_track[dma_id].vchans || > > + > > !dma_copy_track[dma_id].vchans[vchan_id].pkts_cmpl_flag_addr)) { > > +VHOST_LOG_DATA(ERR, "(%s) %s: invalid channel %d:%u.\n", > > dev->ifname, __func__, > > +dma_id, vchan_id); > > +goto out_access_unlock; > > +} >=20 > Also need to check if dma_id is valid. >=20 > > + > > +if (queue_id % 2 =3D=3D 0) >=20 > Ditto. Thanks, will fix them soon. Regards, Yuan >=20 > Thanks, > Jiayu >=20