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 AADFEA00C2; Tue, 27 Sep 2022 09:34:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9D86D427FF; Tue, 27 Sep 2022 09:34:31 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 2D44441143 for ; Tue, 27 Sep 2022 09:34:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664264070; x=1695800070; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=6KBuK4SrM7495mLiWkvzPJSy13RUSQ6cDwFdu0OuYuw=; b=m5rMjMMnnFCZUxzn3AKiDlcjnPmZiseJcnR5JZWDu9fEAQWScKt4vrjF eMw3tZ2cV1ZBBAJy0muEFvsWztiq6C5oFv3JI8HLln/+ghdKeHT0PjLqe qqACizqHa0ze7hoYvazHewqbpNGOlV7ma5AeyGKcwQ6zW44f00zn0R7hA ftait5oq+zLW+JGqRqjaYcr4d5PL0t/QD6mzNGoRDVfOwzIOrJVJygZZK p6n/MCL38xZupwIpkS+mCiJjSktEq0vApLEfgaTeuSN0VOTGLigYD4LAH fzU+BR4oKF9A2FeGVdOetB/nWZN5+94sg9TLrWatDeOwI/fJugXguyn8M A==; X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="288397438" X-IronPort-AV: E=Sophos;i="5.93,348,1654585200"; d="scan'208";a="288397438" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 00:34:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="866470386" X-IronPort-AV: E=Sophos;i="5.93,348,1654585200"; d="scan'208";a="866470386" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga006.fm.intel.com with ESMTP; 27 Sep 2022 00:34:25 -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.2375.31; Tue, 27 Sep 2022 00:34:24 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) 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.2375.31; Tue, 27 Sep 2022 00:34:24 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Tue, 27 Sep 2022 00:34:24 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Tue, 27 Sep 2022 00:34:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l7kbCL8aaOof16digEYtyLOCxVhiChzIukSGBwvZePw9PiVJEh/QZ0XzySC18YaCNqakT+QjvjBUYrmAj1xvbOPUHDLWzJFDYFXcGVpQQN90qrZtbyChrfeTHPI2vvykt/3T1gA+QG3k/vC80aHJreiy7A2bCNpUDPlXrAszblLmGePgnDXQ3+d7D3el7DvjxLlnDIGiw3v5/JSds9Rwv6OYkYhx8rAeki3ag2QlweApv/M9tFs/VqTAuaqhzz0yvSN2Pq+mcv+k63PGmdnhFPjj9xDzj/JjFSQIuITbLIKvZBV7ifgWVZgV3BNpSON/6MS/Z9zuVMGU6v5rqemmIQ== 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=tGghG8aRDkA6m+dS7Zd7YotONYc4UC0PDK11B2E2ZYA=; b=UP4K5FzsSegMK0pzFSWy8zOdfO2rpQ0DDF+wrx5W93ebrxLAlpe0QkzBPypNqqkse8aH1CNPvEXV2wdLUEhWDJEpRuCBXECVZil8wKVkWkt8sVihkk+V5k/+61fHvB5STC8TSNC2B8V0PIT5FQqC8X+vyRZfYzoI18h61+nAYW2ofxH2oDzhChf04+YjSTZ/hBj4c5hO/f5UJe8XwsiFthf7z0Mg3lyoA2e/ow24fDQ8F0Utj118sasSfYKt6Xvpo1+U4vY6D/KWvcBsjD2FXsMqmVweEwkGINWryTvrJ42fp/8bHTQS3wJKerCW/WdoaTlhA7695cVacwuN6P4Hnw== 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 PH7PR11MB6953.namprd11.prod.outlook.com (2603:10b6:510:204::6) by SN7PR11MB6701.namprd11.prod.outlook.com (2603:10b6:806:26b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.26; Tue, 27 Sep 2022 07:34:21 +0000 Received: from PH7PR11MB6953.namprd11.prod.outlook.com ([fe80::b4ae:1525:a457:6ad6]) by PH7PR11MB6953.namprd11.prod.outlook.com ([fe80::b4ae:1525:a457:6ad6%9]) with mapi id 15.20.5654.020; Tue, 27 Sep 2022 07:34:21 +0000 From: "Wang, YuanX" To: "Xia, Chenbo" , "maxime.coquelin@redhat.com" , "dev@dpdk.org" CC: "Hu, Jiayu" , "He, Xingguang" , "Jiang, Cheng1" , "Ma, WenwuX" Subject: RE: [PATCH v3] net/vhost: support asynchronous data path Thread-Topic: [PATCH v3] net/vhost: support asynchronous data path Thread-Index: AQHYts0YZ5z+s+YGGk64pVXf4xJKWK3xfEaAgAF3aEA= Date: Tue, 27 Sep 2022 07:34:21 +0000 Message-ID: References: <20220814150636.2260317-1-jiayu.hu@intel.com> <20220823163534.947869-1-yuanx.wang@intel.com> In-Reply-To: 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-traffictypediagnostic: PH7PR11MB6953:EE_|SN7PR11MB6701:EE_ x-ms-office365-filtering-correlation-id: 42c0b8c9-67bc-4d2e-69a4-08daa05ab1c2 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 21tWqiqSW6T+Lhc3VwfkkjYRy85m/eWfGTi09+DNdbgaYUCoiaPFMeEPXbbRGIhQaSm/L3ISSo3wyw6UscTfKRlz34JjZaBNz5OrQz5fLNx0GsUcJvs/Yljh071XitR1rt89lo/Y9VYR8i6QbzhVwzUHbCO7C6ZtRkpujXVD928ubmIy8OzD/Jf2+8mOZJkX/lSEjtRjoiSut84N/oZWGNntYWjmvGGEiY296cdJKVz0JVhDelKVmqD+C2woLGZ9l+GVv18Fuad6LBfuJG3x6ZGOMPZJIQ0WPO2cIGIsP7GLTF0G6zucPDx2AlSKp+qXvf/Caf6c8O9xrV4xg8Dgo5DAWZfmHHTK0PgDI5XM6rS6n4jpaKq8Zyx3IthTzXnhTW9Q0nlDZMx0/AJeK1MFKvd0C8LTmPu/NcrqjS3uKP8Fhqd+y+N960nDAnHg4IYWr+LZ5PkOMCgOx0r7Scf2EvhpND2EahSS7rLmJrRQgnCdWyaB0QdVcf0wCxLpmgPfo9Gw0HOt5J/F9YxDfH+XGJ9OncBz9n1Bfh61fIFF0izkHFHoM7nKwYSHy2HYnn2mmK5VUtxsTBnx1Jxaj++NE1jZqgbFDjDc7x6JLJm7eiMkQ29gWjls/r22Ux8D6Ba2jfKtpx+mv7r+ORgrrmSZ73MjNFygHHR/KLRoqWpLaqW76GCdOuMUaQ46nnvxi1jpvTUYMtOF7I14W7UZ7VNXn0EPdYARhMJFVVSzappB7zEDN8vfDtksL1M8qyB8wAQKEY28Rq6CVHhmHu913iSfZg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH7PR11MB6953.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(39860400002)(136003)(396003)(346002)(366004)(376002)(451199015)(2906002)(122000001)(53546011)(66946007)(30864003)(76116006)(83380400001)(41300700001)(7696005)(6506007)(82960400001)(52536014)(478600001)(5660300002)(9686003)(107886003)(38100700002)(8936002)(71200400001)(26005)(38070700005)(186003)(55016003)(110136005)(54906003)(33656002)(86362001)(8676002)(66556008)(66476007)(4326008)(64756008)(66446008)(316002)(559001)(579004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?DqlAW2ziEIDdVI3ebeddYpvwraephGV+Ea8FEPz5FvrGI3TNhE0368INtac3?= =?us-ascii?Q?E4pvYBNqSOXb4lr3Vf1xjD1qqLiu9SgYt7GlGa3VMvyCYG9Ckq+NVu3glD5n?= =?us-ascii?Q?RixE3d82vTk4jELmYwNMV7NnjKMH1omaY7v3a3A72RCssj1dYC7tkSdV+lwT?= =?us-ascii?Q?hsDFIKmzx7H0+iTpqEjkt/0t0TYX6Wli5O6RUEtMt2Feq7Wod1GmGm1BDEpf?= =?us-ascii?Q?KJxxQPccD+CyXDxOCsrVo+7IIq5CF0alZczXD4rS04OsesNwYd9ronU510MX?= =?us-ascii?Q?moH12UQurebtMFCqza7X7UyXGHjYk4gQ+gsPIXAyvf6cF9XGULMVuW+cGCks?= =?us-ascii?Q?wFNqCnIZA7Kyfkr9VQue/2x41J0HJioMttU+6gXpa5bQjpL9UN3xP3Mc5Qd4?= =?us-ascii?Q?7HGTVjtjjgyQ8xMxkxqc/e7B0Wjr+146yZl3HgQZ6HEaVXsDAn8TN3/Ed5dG?= =?us-ascii?Q?KC9omfTCo2skVlsqmz3KeXnnvPpmamAcUUMnwysaVvD5ZNL0vb75ujxCguBQ?= =?us-ascii?Q?DFA2zwBsiX55zcFzgbjSmB/WTg3gPxCmpFr4jdjPBpwQq+GtPfcUgGZyhfUb?= =?us-ascii?Q?L7hWhy2IttzFY5jKq8dudRkQdOVUaXgAorPAQaizCvVwVQKoMaQMS+cs3Ash?= =?us-ascii?Q?Qud4umuONkKLt9H5493U1xdsa2Enxe81JVFEnWudXuYeX6E93YK0+5IeRhWl?= =?us-ascii?Q?jTi4Ir5LIvWBydvJd2GK1twKZZyc4JoCLqMCYYgALaw6Zgxt7thYRJaBwt1N?= =?us-ascii?Q?HYJ65k+mmY75WkRRptmO0nOknkE9S1CgY+GCJXQRDIEOLHhkwt9I42kvjM1i?= =?us-ascii?Q?tcBac/TPv67KJpjdz2+D6b8gb6c5C5agyKVplpNlat64VPL4al/WcwMfBq52?= =?us-ascii?Q?CpDBsV+7vSiDzQ8b9xxkJAywL1aSxfh4HQ8PDY01czSzQCM+sda3qZ3+Heau?= =?us-ascii?Q?PdFe0vjjs5Mf8ywxV3W5zmO8xlw1F+GWR5TxaNEHr/OakmCD4LcjhgP8nNTB?= =?us-ascii?Q?lLanyMCWhjfLqa7fUUrbmvUtO3ks5+2UU5zvSOUnF9RurkrEMavSHOeWjnOw?= =?us-ascii?Q?dbKPE39GaXFl9SIStkWMmN2efJQg5W4cJuQxLPE2LtcQJSCYRzHkgWIU34/j?= =?us-ascii?Q?s14Ma0iRJrqIlXZUN/x4gziubfBA1LPFxcU5haZXaMBLkeltpHDi2+Qrog4F?= =?us-ascii?Q?htI348kcNCNrHlpQKjKYP7Ne1f0mGfDMdlPPUcI/IYFYzBToBlfOegXzce2A?= =?us-ascii?Q?w9+vW1gejXFgp4r0gchdbccE3igu8QjQ9Mv1uFsQPqhyEYJT3D5+J9MMOyS0?= =?us-ascii?Q?3FSxSsPStqJXoh4tpzzrzVsm9OM/0Jb8aJEEfdrLonpGp5VSaX4RxMelAgSk?= =?us-ascii?Q?pf0DV0M+5Tx0dB8RQU9dqjTwJU5WouA+/IeO871I2iAf14U9k3uJuGv6U45a?= =?us-ascii?Q?w2ipUb8OdNQdepzqk5JaPYp4vcPs8qXUCguk42GLUcIRVYPmqnk6QkWl4f6v?= =?us-ascii?Q?RD1NGdw36sAB9Le9zAxwALx8Updo82tJdG/2omhgQhAtCyIE4tcKbZDCzA8m?= =?us-ascii?Q?HU+Sqk8c9Kb+a2TXZdxpn1IjQWjsRN8T7u5e0mFJ?= 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: PH7PR11MB6953.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42c0b8c9-67bc-4d2e-69a4-08daa05ab1c2 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Sep 2022 07:34:21.5530 (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: d3oHCYVYkvWxX27Bxd923jM2KMX7aJkKK/7rJcPyanhg4OBepj3GyeRfCuFkG3R3lrjybDzILJVMIlGFNM4myA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR11MB6701 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 Chenbo, > -----Original Message----- > From: Xia, Chenbo > Sent: Monday, September 26, 2022 2:55 PM > To: Wang, YuanX ; maxime.coquelin@redhat.com; > dev@dpdk.org > Cc: Hu, Jiayu ; He, Xingguang > ; Jiang, Cheng1 ; Ma, > WenwuX > Subject: RE: [PATCH v3] net/vhost: support asynchronous data path >=20 > > -----Original Message----- > > From: Wang, YuanX > > Sent: Wednesday, August 24, 2022 12:36 AM > > To: maxime.coquelin@redhat.com; Xia, Chenbo ; > > dev@dpdk.org > > Cc: Hu, Jiayu ; He, Xingguang > > ; Jiang, Cheng1 ; > > Wang, YuanX ; Ma, WenwuX > > > Subject: [PATCH v3] net/vhost: support asynchronous data path >=20 > How many % will this patch impact the sync data path perf? > It should be minor, right? We did some performance checks, the gap between the with and no patch is 0.= 01% to 4.19%. We think the performance decline is very slight. >=20 > Maxime, should we plan to remove vhost example now? Maintaining vhost > example/PMD that have the same functionalities, does not make sense to > me. We should send deprecation notice in 22.11 and also get to know tech- > board opinion? >=20 > > > > Vhost asynchronous data-path offloads packet copy from the CPU to the > > DMA engine. As a result, large packet copy can be accelerated by the > > DMA engine, and vhost can free CPU cycles for higher level functions. > > > > In this patch, we enable asynchronous data-path for vhostpmd. > > Asynchronous data path is enabled per tx/rx queue, and users need to > > specify the DMA device used by the tx/rx queue. Each tx/rx queue only > > supports to use one DMA device, but one DMA device can be shared > among > > multiple tx/rx queues of different vhostpmd ports. >=20 > Vhostpmd -> vhost PMD Thanks for your catch. >=20 > > > > Two PMD parameters are added: > > - dmas: specify the used DMA device for a tx/rx queue. > > (Default: no queues enable asynchronous data path) > > - dma-ring-size: DMA ring size. > > (Default: 4096). > > > > Here is an example: > > --vdev > > > 'eth_vhost0,iface=3D./s0,dmas=3D[txq0@0000:00.01.0;rxq0@0000:00.01.1],dma= - > > ring-size=3D4096' > > > > Signed-off-by: Jiayu Hu > > Signed-off-by: Yuan Wang > > Signed-off-by: Wenwu Ma > > --- > > v3: > > - add the API to version.map > > > > v2: > > - add missing file > > - hide async_tx_poll_completed > > - change default DMA ring size to 4096 > > --- > > drivers/net/vhost/meson.build | 1 + > > drivers/net/vhost/rte_eth_vhost.c | 494 > > ++++++++++++++++++++++++++++-- drivers/net/vhost/rte_eth_vhost.h > | 15 + > > drivers/net/vhost/version.map | 7 + > > drivers/net/vhost/vhost_testpmd.c | 65 ++++ > > 5 files changed, 549 insertions(+), 33 deletions(-) create mode > > 100644 drivers/net/vhost/vhost_testpmd.c > > > > diff --git a/drivers/net/vhost/meson.build > > b/drivers/net/vhost/meson.build index f481a3a4b8..22a0ab3a58 100644 > > --- a/drivers/net/vhost/meson.build > > +++ b/drivers/net/vhost/meson.build > > @@ -9,4 +9,5 @@ endif > > > > deps +=3D 'vhost' > > sources =3D files('rte_eth_vhost.c') > > +testpmd_sources =3D files('vhost_testpmd.c') > > headers =3D files('rte_eth_vhost.h') > > diff --git a/drivers/net/vhost/rte_eth_vhost.c > > b/drivers/net/vhost/rte_eth_vhost.c > > index 7e512d94bf..aa069c6b68 100644 > > --- a/drivers/net/vhost/rte_eth_vhost.c > > +++ b/drivers/net/vhost/rte_eth_vhost.c > > @@ -17,6 +17,8 @@ > > #include > > #include > > #include > > +#include > > +#include > > > > #include "rte_eth_vhost.h" > > > > @@ -36,8 +38,13 @@ enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM}; > > #define ETH_VHOST_LINEAR_BUF "linear-buffer" > > #define ETH_VHOST_EXT_BUF "ext-buffer" > > #define ETH_VHOST_LEGACY_OL_FLAGS "legacy-ol-flags" > > +#define ETH_VHOST_DMA_ARG "dmas" > > +#define ETH_VHOST_DMA_RING_SIZE "dma-ring-size" > > #define VHOST_MAX_PKT_BURST 32 > > > > +#define INVALID_DMA_ID -1 > > +#define DEFAULT_DMA_RING_SIZE 4096 > > + > > static const char *valid_arguments[] =3D { > > ETH_VHOST_IFACE_ARG, > > ETH_VHOST_QUEUES_ARG, > > @@ -48,6 +55,8 @@ static const char *valid_arguments[] =3D { > > ETH_VHOST_LINEAR_BUF, > > ETH_VHOST_EXT_BUF, > > ETH_VHOST_LEGACY_OL_FLAGS, > > + ETH_VHOST_DMA_ARG, > > + ETH_VHOST_DMA_RING_SIZE, > > NULL > > }; > > > > @@ -79,8 +88,39 @@ struct vhost_queue { > > struct vhost_stats stats; > > int intr_enable; > > rte_spinlock_t intr_lock; > > + > > + /* Flag of enabling async data path */ > > + bool async_register; > > + /* DMA device ID */ > > + int16_t dma_id; > > + /** > > + * For a Rx queue, "txq" points to its peer Tx queue. > > + * For a Tx queue, "txq" is never used. > > + */ > > + struct vhost_queue *txq; > > + /* Array to keep DMA completed packets */ > > + struct rte_mbuf *cmpl_pkts[VHOST_MAX_PKT_BURST]; > > }; > > > > +struct dma_input_info { > > + int16_t dmas[RTE_MAX_QUEUES_PER_PORT * 2]; > > + uint16_t dma_ring_size; > > +}; > > + > > +static int16_t configured_dmas[RTE_DMADEV_DEFAULT_MAX]; > > +static int dma_count; > > + > > +/** > > + * By default, its Rx path to call rte_vhost_poll_enqueue_completed() > > +for > > enqueue operations. > > + * However, Rx function is never been called in testpmd "txonly" > > + mode, > > thus causing virtio > > + * cannot receive DMA completed packets. To make txonly mode work > > correctly, we provide a > > + * command in testpmd to call rte_vhost_poll_enqueue_completed() in > > + Tx > > path. > > + * > > + * When set async_tx_poll_completed to true, Tx path calls > > rte_vhost_poll_enqueue_completed(); > > + * otherwise, Rx path calls it. > > + */ > > +bool async_tx_poll_completed; > > + > > struct pmd_internal { > > rte_atomic32_t dev_attached; > > char *iface_name; > > @@ -93,6 +133,10 @@ struct pmd_internal { > > bool vlan_strip; > > bool rx_sw_csum; > > bool tx_sw_csum; > > + struct { > > + int16_t dma_id; > > + bool async_register; > > + } queue_dmas[RTE_MAX_QUEUES_PER_PORT * 2]; > > }; > > > > struct internal_list { > > @@ -123,6 +167,17 @@ struct rte_vhost_vring_state { > > > > static struct rte_vhost_vring_state *vring_states[RTE_MAX_ETHPORTS]; > > > > +static bool > > +dma_is_configured(int16_t dma_id) > > +{ > > + int i; > > + > > + for (i =3D 0; i < dma_count; i++) > > + if (configured_dmas[i] =3D=3D dma_id) > > + return true; > > + return false; > > +} > > + > > static int > > vhost_dev_xstats_reset(struct rte_eth_dev *dev) { @@ -395,6 +450,17 > > @@ vhost_dev_rx_sw_csum(struct rte_mbuf *mbuf) > > mbuf->ol_flags |=3D RTE_MBUF_F_RX_L4_CKSUM_GOOD; } > > > > +static inline void > > +vhost_tx_free_completed(uint16_t vid, uint16_t virtqueue_id, int16_t > > dma_id, > > + struct rte_mbuf **pkts, uint16_t count) { > > + uint16_t i, ret; > > + > > + ret =3D rte_vhost_poll_enqueue_completed(vid, virtqueue_id, pkts, > > count, dma_id, 0); > > + for (i =3D 0; likely(i < ret); i++) > > + rte_pktmbuf_free(pkts[i]); > > +} > > + > > static uint16_t > > eth_vhost_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) { @@ > > -403,7 +469,7 @@ eth_vhost_rx(void *q, struct rte_mbuf **bufs, > > uint16_t > > nb_bufs) > > uint16_t nb_receive =3D nb_bufs; > > > > if (unlikely(rte_atomic32_read(&r->allow_queuing) =3D=3D 0)) > > - return 0; > > + goto tx_poll; > > > > rte_atomic32_set(&r->while_queuing, 1); > > > > @@ -411,19 +477,36 @@ eth_vhost_rx(void *q, struct rte_mbuf **bufs, > > uint16_t nb_bufs) > > goto out; > > > > /* Dequeue packets from guest TX queue */ > > - while (nb_receive) { > > - uint16_t nb_pkts; > > - uint16_t num =3D (uint16_t)RTE_MIN(nb_receive, > > - VHOST_MAX_PKT_BURST); > > - > > - nb_pkts =3D rte_vhost_dequeue_burst(r->vid, r->virtqueue_id, > > - r->mb_pool, &bufs[nb_rx], > > - num); > > - > > - nb_rx +=3D nb_pkts; > > - nb_receive -=3D nb_pkts; > > - if (nb_pkts < num) > > - break; > > + if (!r->async_register) { > > + while (nb_receive) { > > + uint16_t nb_pkts; > > + uint16_t num =3D (uint16_t)RTE_MIN(nb_receive, > > + > VHOST_MAX_PKT_BURST); > > + > > + nb_pkts =3D rte_vhost_dequeue_burst(r->vid, r- > > >virtqueue_id, > > + r->mb_pool, &bufs[nb_rx], > > + num); > > + > > + nb_rx +=3D nb_pkts; > > + nb_receive -=3D nb_pkts; > > + if (nb_pkts < num) > > + break; > > + } > > + } else { > > + while (nb_receive) { > > + uint16_t nb_pkts; > > + uint16_t num =3D (uint16_t)RTE_MIN(nb_receive, > > VHOST_MAX_PKT_BURST); >=20 > Some variables like nb_pkts and num, which will anyway be used. We don't > need to define them in every loop. Good catch, Will put them out of the loop. >=20 > > + int nr_inflight; > > + > > + nb_pkts =3D rte_vhost_async_try_dequeue_burst(r- > >vid, r- > > >virtqueue_id, > > + r->mb_pool, &bufs[nb_rx], > num, > > &nr_inflight, > > + r->dma_id, 0); > > + > > + nb_rx +=3D nb_pkts; > > + nb_receive -=3D nb_pkts; > > + if (nb_pkts < num) > > + break; > > + } > > } > > > > r->stats.pkts +=3D nb_rx; > > @@ -444,6 +527,17 @@ eth_vhost_rx(void *q, struct rte_mbuf **bufs, > > uint16_t nb_bufs) > > out: > > rte_atomic32_set(&r->while_queuing, 0); > > > > +tx_poll: > > + /** > > + * Poll and free completed packets for the virtqueue of Tx queue. > > + * Note that we access Tx queue's virtqueue, which is protected > > + * by vring lock. > > + */ > > + if (!async_tx_poll_completed && r->txq->async_register) { >=20 > Logically we should check async_register first. Sure, will update in v4. >=20 > > + vhost_tx_free_completed(r->vid, r->txq->virtqueue_id, r- > >txq- > > >dma_id, > > + r->cmpl_pkts, VHOST_MAX_PKT_BURST); > > + } > > + > > return nb_rx; > > } > > > > @@ -485,31 +579,53 @@ eth_vhost_tx(void *q, struct rte_mbuf **bufs, > > uint16_t nb_bufs) > > } > > > > /* Enqueue packets to guest RX queue */ > > - while (nb_send) { > > - uint16_t nb_pkts; > > - uint16_t num =3D (uint16_t)RTE_MIN(nb_send, > > - VHOST_MAX_PKT_BURST); > > + if (!r->async_register) { > > + while (nb_send) { > > + uint16_t nb_pkts; > > + uint16_t num =3D (uint16_t)RTE_MIN(nb_send, > > VHOST_MAX_PKT_BURST); > > + > > + nb_pkts =3D rte_vhost_enqueue_burst(r->vid, r- > > >virtqueue_id, > > + &bufs[nb_tx], num); > > + > > + nb_tx +=3D nb_pkts; > > + nb_send -=3D nb_pkts; > > + if (nb_pkts < num) > > + break; > > + } > > > > - nb_pkts =3D rte_vhost_enqueue_burst(r->vid, r->virtqueue_id, > > - &bufs[nb_tx], num); > > + for (i =3D 0; likely(i < nb_tx); i++) { > > + nb_bytes +=3D bufs[i]->pkt_len; > > + rte_pktmbuf_free(bufs[i]); > > + } > > > > - nb_tx +=3D nb_pkts; > > - nb_send -=3D nb_pkts; > > - if (nb_pkts < num) > > - break; > > - } > > + } else { > > + while (nb_send) { > > + uint16_t nb_pkts; > > + uint16_t num =3D (uint16_t)RTE_MIN(nb_send, > > VHOST_MAX_PKT_BURST); > > > > - for (i =3D 0; likely(i < nb_tx); i++) > > - nb_bytes +=3D bufs[i]->pkt_len; > > + nb_pkts =3D rte_vhost_submit_enqueue_burst(r->vid, > r- > > >virtqueue_id, > > + &bufs[nb_tx], num, > r->dma_id, 0); > > > > - nb_missed =3D nb_bufs - nb_tx; > > + nb_tx +=3D nb_pkts; > > + nb_send -=3D nb_pkts; > > + if (nb_pkts < num) > > + break; > > + } > > > > + for (i =3D 0; likely(i < nb_tx); i++) > > + nb_bytes +=3D bufs[i]->pkt_len; > > + > > + if (unlikely(async_tx_poll_completed)) { > > + vhost_tx_free_completed(r->vid, r->virtqueue_id, r- > > >dma_id, r->cmpl_pkts, > > + VHOST_MAX_PKT_BURST); > > + } > > + } > > + > > + nb_missed =3D nb_bufs - nb_tx; > > r->stats.pkts +=3D nb_tx; > > r->stats.bytes +=3D nb_bytes; > > r->stats.missed_pkts +=3D nb_missed; > > > > - for (i =3D 0; likely(i < nb_tx); i++) > > - rte_pktmbuf_free(bufs[i]); > > out: > > rte_atomic32_set(&r->while_queuing, 0); > > > > @@ -797,6 +913,8 @@ queue_setup(struct rte_eth_dev *eth_dev, struct > > pmd_internal *internal) > > vq->vid =3D internal->vid; > > vq->internal =3D internal; > > vq->port =3D eth_dev->data->port_id; > > + if (i < eth_dev->data->nb_tx_queues) > > + vq->txq =3D eth_dev->data->tx_queues[i]; > > } > > for (i =3D 0; i < eth_dev->data->nb_tx_queues; i++) { > > vq =3D eth_dev->data->tx_queues[i]; > > @@ -982,6 +1100,9 @@ vring_state_changed(int vid, uint16_t vring, int > > enable) > > struct rte_vhost_vring_state *state; > > struct rte_eth_dev *eth_dev; > > struct internal_list *list; > > + struct vhost_queue *queue; > > + struct pmd_internal *internal; > > + int qid; > > char ifname[PATH_MAX]; > > > > rte_vhost_get_ifname(vid, ifname, sizeof(ifname)); @@ -1010,6 > > +1131,65 @@ vring_state_changed(int vid, uint16_t vring, int > > enable) > > > > update_queuing_status(eth_dev, false); > > > > + qid =3D vring / VIRTIO_QNUM; > > + if (vring % VIRTIO_QNUM =3D=3D VIRTIO_RXQ) > > + queue =3D eth_dev->data->tx_queues[qid]; > > + else > > + queue =3D eth_dev->data->rx_queues[qid]; > > + > > + if (!queue) > > + goto skip; > > + > > + internal =3D eth_dev->data->dev_private; > > + > > + /* Register async data path for the queue assigned valid DMA device > > */ > > + if (internal->queue_dmas[queue->virtqueue_id].dma_id =3D=3D > > INVALID_DMA_ID) > > + goto skip; > > + > > + if (enable && !queue->async_register) { > > + if (rte_vhost_async_channel_register_thread_unsafe(vid, > vring)) > > { > > + VHOST_LOG(ERR, "Failed to register async for vid-%u > > vring-%u!\n", vid, > > + vring); > > + return -1; > > + } > > + > > + queue->async_register =3D true; > > + internal->queue_dmas[vring].async_register =3D true; > > + > > + VHOST_LOG(INFO, "Succeed to register async for vid-%u > vring- > > %u\n", vid, vring); > > + } > > + > > + if (!enable && queue->async_register) { > > + struct rte_mbuf *pkts[VHOST_MAX_PKT_BURST]; > > + uint16_t ret, i, nr_done =3D 0; > > + uint16_t dma_id =3D queue->dma_id; > > + > > + while (rte_vhost_async_get_inflight_thread_unsafe(vid, > vring) > > > 0) { > > + ret =3D rte_vhost_clear_queue_thread_unsafe(vid, > vring, > > pkts, > > + VHOST_MAX_PKT_BURST, dma_id, > 0); > > + > > + for (i =3D 0; i < ret ; i++) > > + rte_pktmbuf_free(pkts[i]); > > + > > + nr_done +=3D ret; > > + } > > + > > + VHOST_LOG(INFO, "Completed %u in-flight pkts for vid-%u > vring- > > %u\n", nr_done, vid, > > + vring); > > + > > + if (rte_vhost_async_channel_unregister_thread_unsafe(vid, > > vring)) { > > + VHOST_LOG(ERR, "Failed to unregister async for vid- > %u > > vring-%u\n", vid, > > + vring); > > + return -1; > > + } > > + > > + queue->async_register =3D false; > > + internal->queue_dmas[vring].async_register =3D false; > > + > > + VHOST_LOG(INFO, "Succeed to unregister async for vid-%u > vring- > > %u\n", vid, vring); > > + } > > + > > +skip: > > VHOST_LOG(INFO, "vring%u is %s\n", > > vring, enable ? "enabled" : "disabled"); > > > > @@ -1158,6 +1338,12 @@ rte_eth_vhost_get_vid_from_port_id(uint16_t > port_id) > > return vid; > > } > > > > +void > > +rte_eth_vhost_async_tx_poll_completed(bool enable) { > > + async_tx_poll_completed =3D enable; > > +} > > + > > static int > > eth_dev_configure(struct rte_eth_dev *dev) { @@ -1214,11 +1400,37 > @@ > > eth_dev_stop(struct rte_eth_dev *dev) > > return 0; > > } > > > > +static inline int > > +async_clear_virtqueue(uint16_t vid, uint16_t virtqueue_id, int16_t > > +dma_id) { > > + struct rte_mbuf *pkts[VHOST_MAX_PKT_BURST]; > > + uint16_t i, ret, nr_done =3D 0; > > + > > + while (rte_vhost_async_get_inflight(vid, virtqueue_id) > 0) { > > + ret =3D rte_vhost_clear_queue(vid, virtqueue_id, pkts, > > VHOST_MAX_PKT_BURST, dma_id, > > + 0); > > + for (i =3D 0; i < ret ; i++) > > + rte_pktmbuf_free(pkts[i]); > > + > > + nr_done +=3D ret; > > + } > > + VHOST_LOG(INFO, "Completed %u pkts for vid-%u vring-%u\n", > nr_done, > > vid, virtqueue_id); > > + > > + if (rte_vhost_async_channel_unregister(vid, virtqueue_id)) { > > + VHOST_LOG(ERR, "Failed to unregister async for vid-%u > vring- > > %u\n", vid, > > + virtqueue_id); > > + return -1; > > + } > > + > > + return nr_done; > > +} >=20 > If you don't need to check the return value, make it return void. Sure, return void is better, will fix it. >=20 > > + > > static int > > eth_dev_close(struct rte_eth_dev *dev) { > > struct pmd_internal *internal; > > struct internal_list *list; > > + struct vhost_queue *queue; > > unsigned int i, ret; > > > > if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY) @@ -1232,6 > +1444,27 > > @@ eth_dev_close(struct rte_eth_dev *dev) > > > > list =3D find_internal_resource(internal->iface_name); > > if (list) { > > + /* Make sure all in-flight packets are completed before > > destroy virtio */ >=20 > Virtio -> vhost Thanks for the correction. >=20 > > + if (dev->data->rx_queues) { > > + for (i =3D 0; i < dev->data->nb_rx_queues; i++) { > > + queue =3D dev->data->rx_queues[i]; > > + if (queue->async_register) { > > + async_clear_virtqueue(queue->vid, > queue- > > >virtqueue_id, > > + queue->dma_id); > > + } > > + } > > + } > > + > > + if (dev->data->tx_queues) { > > + for (i =3D 0; i < dev->data->nb_tx_queues; i++) { > > + queue =3D dev->data->tx_queues[i]; > > + if (queue->async_register) { > > + async_clear_virtqueue(queue->vid, > queue- > > >virtqueue_id, > > + queue->dma_id); > > + } > > + } > > + } > > + > > rte_vhost_driver_unregister(internal->iface_name); > > pthread_mutex_lock(&internal_list_lock); > > TAILQ_REMOVE(&internal_list, list, next); @@ -1266,6 > +1499,7 @@ > > eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id, > > struct rte_mempool *mb_pool) > > { > > struct vhost_queue *vq; > > + struct pmd_internal *internal =3D dev->data->dev_private; > > > > vq =3D rte_zmalloc_socket(NULL, sizeof(struct vhost_queue), > > RTE_CACHE_LINE_SIZE, socket_id); > > @@ -1276,6 +1510,8 @@ eth_rx_queue_setup(struct rte_eth_dev *dev, > > uint16_t rx_queue_id, > > > > vq->mb_pool =3D mb_pool; > > vq->virtqueue_id =3D rx_queue_id * VIRTIO_QNUM + VIRTIO_TXQ; > > + vq->async_register =3D internal->queue_dmas[vq- > > >virtqueue_id].async_register; > > + vq->dma_id =3D internal->queue_dmas[vq->virtqueue_id].dma_id; > > rte_spinlock_init(&vq->intr_lock); > > dev->data->rx_queues[rx_queue_id] =3D vq; > > > > @@ -1289,6 +1525,7 @@ eth_tx_queue_setup(struct rte_eth_dev *dev, > > uint16_t tx_queue_id, > > const struct rte_eth_txconf *tx_conf __rte_unused) { > > struct vhost_queue *vq; > > + struct pmd_internal *internal =3D dev->data->dev_private; > > > > vq =3D rte_zmalloc_socket(NULL, sizeof(struct vhost_queue), > > RTE_CACHE_LINE_SIZE, socket_id); > > @@ -1298,6 +1535,8 @@ eth_tx_queue_setup(struct rte_eth_dev *dev, > > uint16_t tx_queue_id, > > } > > > > vq->virtqueue_id =3D tx_queue_id * VIRTIO_QNUM + VIRTIO_RXQ; > > + vq->async_register =3D internal->queue_dmas[vq- > > >virtqueue_id].async_register; > > + vq->dma_id =3D internal->queue_dmas[vq->virtqueue_id].dma_id; > > rte_spinlock_init(&vq->intr_lock); > > dev->data->tx_queues[tx_queue_id] =3D vq; > > > > @@ -1508,13 +1747,14 @@ static const struct eth_dev_ops ops =3D { > > static int eth_dev_vhost_create(struct rte_vdev_device *dev, char > > *iface_name, > > int16_t queues, const unsigned int numa_node, uint64_t flags, > > - uint64_t disable_flags) > > + uint64_t disable_flags, struct dma_input_info *dma_input) > > { > > const char *name =3D rte_vdev_device_name(dev); > > struct rte_eth_dev_data *data; > > struct pmd_internal *internal =3D NULL; > > struct rte_eth_dev *eth_dev =3D NULL; > > struct rte_ether_addr *eth_addr =3D NULL; > > + int i; > > > > VHOST_LOG(INFO, "Creating VHOST-USER backend on numa > socket %u\n", > > numa_node); > > @@ -1563,6 +1803,12 @@ eth_dev_vhost_create(struct rte_vdev_device > > *dev, char *iface_name, > > eth_dev->rx_pkt_burst =3D eth_vhost_rx; > > eth_dev->tx_pkt_burst =3D eth_vhost_tx; > > > > + for (i =3D 0; i < RTE_MAX_QUEUES_PER_PORT * 2; i++) { > > + /* Invalid DMA ID indicates the queue does not want to > enable > > async data path */ > > + internal->queue_dmas[i].dma_id =3D dma_input->dmas[i]; > > + internal->queue_dmas[i].async_register =3D false; > > + } > > + > > rte_eth_dev_probing_finish(eth_dev); > > return 0; > > > > @@ -1602,6 +1848,153 @@ open_int(const char *key __rte_unused, const > > char *value, void *extra_args) > > return 0; > > } > > > > +static int > > +init_dma(int16_t dma_id, uint16_t ring_size) { > > + struct rte_dma_info info; > > + struct rte_dma_conf dev_config =3D { .nb_vchans =3D 1 }; > > + struct rte_dma_vchan_conf qconf =3D { > > + .direction =3D RTE_DMA_DIR_MEM_TO_MEM, > > + }; > > + int ret =3D 0; > > + > > + if (dma_is_configured(dma_id)) > > + goto out; > > + > > + if (rte_dma_info_get(dma_id, &info) !=3D 0) { > > + VHOST_LOG(ERR, "dma %u get info failed\n", dma_id); > > + ret =3D -1; > > + goto out; > > + } > > + > > + if (info.max_vchans < 1) { > > + VHOST_LOG(ERR, "No channels available on dma %d\n", > dma_id); > > + ret =3D -1; > > + goto out; > > + } > > + > > + if (rte_dma_configure(dma_id, &dev_config) !=3D 0) { > > + VHOST_LOG(ERR, "dma %u configure failed\n", dma_id); > > + ret =3D -1; > > + goto out; > > + } > > + > > + rte_dma_info_get(dma_id, &info); > > + if (info.nb_vchans !=3D 1) { > > + VHOST_LOG(ERR, "dma %u has no queues\n", dma_id); > > + ret =3D -1; > > + goto out; > > + } > > + > > + qconf.nb_desc =3D RTE_MIN(ring_size, info.max_desc); > > + if (rte_dma_vchan_setup(dma_id, 0, &qconf) !=3D 0) { > > + VHOST_LOG(ERR, "dma %u queue setup failed\n", dma_id); > > + ret =3D -1; > > + goto out; > > + } > > + > > + if (rte_dma_start(dma_id) !=3D 0) { > > + VHOST_LOG(ERR, "dma %u start failed\n", dma_id); > > + ret =3D -1; > > + goto out; > > + } > > + > > + configured_dmas[dma_count++] =3D dma_id; > > + > > +out: > > + return ret; > > +} > > + > > +static int > > +open_dma(const char *key __rte_unused, const char *value, void > > *extra_args) > > +{ > > + struct dma_input_info *dma_input =3D extra_args; > > + char *input =3D strndup(value, strlen(value) + 1); > > + char *addrs =3D input; > > + char *ptrs[2]; > > + char *start, *end, *substr; > > + uint16_t qid, virtqueue_id; > > + int16_t dma_id; > > + int i, ret =3D 0; > > + > > + while (isblank(*addrs)) > > + addrs++; > > + if (*addrs =3D=3D '\0') { > > + VHOST_LOG(ERR, "No input DMA addresses\n"); > > + ret =3D -1; > > + goto out; > > + } > > + > > + /* process DMA devices within bracket. */ > > + addrs++; > > + substr =3D strtok(addrs, ";]"); > > + if (!substr) { > > + VHOST_LOG(ERR, "No input DMA addresse\n"); > > + ret =3D -1; > > + goto out; > > + } > > + > > + do { > > + rte_strsplit(substr, strlen(substr), ptrs, 2, '@'); > > + > > + char *txq, *rxq; > > + bool is_txq; > > + > > + txq =3D strstr(ptrs[0], "txq"); > > + rxq =3D strstr(ptrs[0], "rxq"); > > + if (txq =3D=3D NULL && rxq =3D=3D NULL) { > > + VHOST_LOG(ERR, "Illegal queue\n"); > > + ret =3D -1; > > + goto out; > > + } else if (txq) { > > + is_txq =3D true; > > + start =3D txq; > > + } else { > > + is_txq =3D false; > > + start =3D rxq; > > + } > > + > > + start +=3D 3; > > + qid =3D strtol(start, &end, 0); > > + if (end =3D=3D start) { > > + VHOST_LOG(ERR, "No input queue ID\n"); > > + ret =3D -1; > > + goto out; > > + } > > + > > + virtqueue_id =3D is_txq ? qid * 2 + VIRTIO_RXQ : qid * 2 + > > VIRTIO_TXQ; > > + > > + dma_id =3D rte_dma_get_dev_id_by_name(ptrs[1]); > > + if (dma_id < 0) { > > + VHOST_LOG(ERR, "Fail to find DMA device %s.\n", > ptrs[1]); > > + ret =3D -1; > > + goto out; > > + } > > + > > + ret =3D init_dma(dma_id, dma_input->dma_ring_size); > > + if (ret !=3D 0) { > > + VHOST_LOG(ERR, "Fail to initialize DMA %u\n", > dma_id); > > + ret =3D -1; > > + break; > > + } > > + > > + dma_input->dmas[virtqueue_id] =3D dma_id; > > + > > + substr =3D strtok(NULL, ";]"); > > + } while (substr); > > + > > + for (i =3D 0; i < dma_count; i++) { > > + if (rte_vhost_async_dma_configure(configured_dmas[i], 0) < > 0) > > { > > + VHOST_LOG(ERR, "Fail to configure DMA %u to > vhost\n", > > configured_dmas[i]); > > + ret =3D -1; > > + } > > + } > > + > > +out: > > + free(input); > > + return ret; > > +} > > + > > static int > > rte_pmd_vhost_probe(struct rte_vdev_device *dev) { @@ -1620,6 > > +2013,10 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev) > > int legacy_ol_flags =3D 0; > > struct rte_eth_dev *eth_dev; > > const char *name =3D rte_vdev_device_name(dev); > > + struct dma_input_info dma_input; > > + > > + memset(dma_input.dmas, INVALID_DMA_ID, > sizeof(dma_input.dmas)); > > + dma_input.dma_ring_size =3D DEFAULT_DMA_RING_SIZE; > > > > VHOST_LOG(INFO, "Initializing pmd_vhost for %s\n", name); > > > > @@ -1735,6 +2132,35 @@ rte_pmd_vhost_probe(struct rte_vdev_device > *dev) > > goto out_free; > > } > > > > + if (rte_kvargs_count(kvlist, ETH_VHOST_DMA_RING_SIZE) =3D=3D 1) { > > + ret =3D rte_kvargs_process(kvlist, > ETH_VHOST_DMA_RING_SIZE, > > + &open_int, &dma_input.dma_ring_size); > > + if (ret < 0) > > + goto out_free; > > + > > + if (!rte_is_power_of_2(dma_input.dma_ring_size)) { > > + dma_input.dma_ring_size =3D > > rte_align32pow2(dma_input.dma_ring_size); > > + VHOST_LOG(INFO, "Convert dma_ring_size to the > power of > > two %u\n", > > + dma_input.dma_ring_size); > > + } > > + } > > + > > + if (rte_kvargs_count(kvlist, ETH_VHOST_DMA_ARG) =3D=3D 1) { > > + ret =3D rte_kvargs_process(kvlist, ETH_VHOST_DMA_ARG, > > + &open_dma, &dma_input); > > + if (ret < 0) { > > + VHOST_LOG(ERR, "Failed to parse %s\n", > > ETH_VHOST_DMA_ARG); > > + goto out_free; > > + } > > + > > + flags |=3D RTE_VHOST_USER_ASYNC_COPY; > > + /** > > + * Don't support live migration when enable > > + * DMA acceleration. > > + */ > > + disable_flags |=3D (1ULL << VHOST_F_LOG_ALL); > > + } >=20 > I think we should at least give a warning if some user only specify the d= ma > ring size but does not specify 'dmas' >=20 > Similarly, only configuring dmas case, we can give a info to user it's us= ing > default value. Good idea, I will add check and log in the next version. >=20 > > + > > if (legacy_ol_flags =3D=3D 0) > > flags |=3D RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS; > > > > @@ -1742,7 +2168,7 @@ rte_pmd_vhost_probe(struct rte_vdev_device > *dev) > > dev->device.numa_node =3D rte_socket_id(); > > > > ret =3D eth_dev_vhost_create(dev, iface_name, queues, > > - dev->device.numa_node, flags, > disable_flags); > > + dev->device.numa_node, flags, disable_flags, > &dma_input); > > if (ret =3D=3D -1) > > VHOST_LOG(ERR, "Failed to create %s\n", name); > > > > @@ -1786,4 +2212,6 @@ RTE_PMD_REGISTER_PARAM_STRING(net_vhost, > > "postcopy-support=3D<0|1> " > > "tso=3D<0|1> " > > "linear-buffer=3D<0|1> " > > - "ext-buffer=3D<0|1>"); > > + "ext-buffer=3D<0|1> " > > + "dma-ring-size=3D" >=20 > Missing a space before " >=20 > IIUC, only the last one does not need that space. Thanks for your catch, will fix it in v4. >=20 > > + "dmas=3D[txq0@dma_addr;rxq0@dma_addr] "); > > diff --git a/drivers/net/vhost/rte_eth_vhost.h > > b/drivers/net/vhost/rte_eth_vhost.h > > index 0e68b9f668..146c98803d 100644 > > --- a/drivers/net/vhost/rte_eth_vhost.h > > +++ b/drivers/net/vhost/rte_eth_vhost.h > > @@ -52,6 +52,21 @@ int rte_eth_vhost_get_queue_event(uint16_t > port_id, > > */ > > int rte_eth_vhost_get_vid_from_port_id(uint16_t port_id); > > > > +/** > > + * @warning > > + * @b EXPERIMENTAL: this API may change, or be removed, without prior > > notice > > + * > > + * By default, rte_vhost_poll_enqueue_completed() is called in Rx path= . > > + * This function enables Tx path, rather than Rx path, to poll > > +completed > > + * packets for vhost async enqueue operations. Note that virtio may > > +never > > + * receive DMA completed packets if there are no more Tx operations. > > + * > > + * @param enable > > + * True indicates Tx path to call rte_vhost_poll_enqueue_completed(). > > + */ > > +__rte_experimental > > +void rte_eth_vhost_async_tx_poll_completed(bool enable); > > + > > #ifdef __cplusplus > > } > > #endif > > diff --git a/drivers/net/vhost/version.map > > b/drivers/net/vhost/version.map index e42c89f1eb..0a40441227 100644 > > --- a/drivers/net/vhost/version.map > > +++ b/drivers/net/vhost/version.map > > @@ -6,3 +6,10 @@ DPDK_23 { > > > > local: *; > > }; > > + > > +EXPERIMENTAL { > > + global: > > + > > + # added in 22.11 > > + rte_eth_vhost_async_tx_poll_completed; > > +}; > > diff --git a/drivers/net/vhost/vhost_testpmd.c > > b/drivers/net/vhost/vhost_testpmd.c > > new file mode 100644 > > index 0000000000..b8227d1086 > > --- /dev/null > > +++ b/drivers/net/vhost/vhost_testpmd.c > > @@ -0,0 +1,65 @@ > > +/* SPDX-License-Identifier: BSD-3-Clause > > + * Copyright(c) 2022 Intel Corporation. > > + */ > > +#include > > +#include > > +#include > > + > > +#include "testpmd.h" > > + > > +struct cmd_tx_poll_result { > > + cmdline_fixed_string_t async_vhost; > > + cmdline_fixed_string_t tx; > > + cmdline_fixed_string_t poll; > > + cmdline_fixed_string_t completed; > > + cmdline_fixed_string_t what; > > +}; > > + > > +static cmdline_parse_token_string_t cmd_tx_async_vhost =3D > > + TOKEN_STRING_INITIALIZER(struct cmd_tx_poll_result, async_vhost, > > "async_vhost"); > > +static cmdline_parse_token_string_t cmd_tx_tx =3D > > + TOKEN_STRING_INITIALIZER(struct cmd_tx_poll_result, tx, "tx"); > > +static cmdline_parse_token_string_t cmd_tx_poll =3D > > + TOKEN_STRING_INITIALIZER(struct cmd_tx_poll_result, poll, "poll"); > > +static cmdline_parse_token_string_t cmd_tx_completed =3D > > + TOKEN_STRING_INITIALIZER(struct cmd_tx_poll_result, completed, > > "completed"); > > +static cmdline_parse_token_string_t cmd_tx_what =3D > > + TOKEN_STRING_INITIALIZER(struct cmd_tx_poll_result, what, > "on#off"); > > + > > +static void > > +cmd_tx_poll_parsed(void *parsed_result, __rte_unused struct cmdline > > +*cl, > > __rte_unused void *data) > > +{ > > + struct cmd_tx_poll_result *res =3D parsed_result; > > + > > + if (!strcmp(res->what, "on")) > > + rte_eth_vhost_async_tx_poll_completed(true); > > + else if (!strcmp(res->what, "off")) > > + rte_eth_vhost_async_tx_poll_completed(false); >=20 > We should print log when the user input is not on/off. Thanks for your suggestion, will add the log in v4. Thanks, Yuan >=20 > Thanks, > Chenbo >=20 > > +} > > + > > +static cmdline_parse_inst_t async_vhost_cmd_tx_poll =3D { > > + .f =3D cmd_tx_poll_parsed, > > + .data =3D NULL, > > + .help_str =3D "async-vhost tx poll completed on|off", > > + .tokens =3D { > > + (void *)&cmd_tx_async_vhost, > > + (void *)&cmd_tx_tx, > > + (void *)&cmd_tx_poll, > > + (void *)&cmd_tx_completed, > > + (void *)&cmd_tx_what, > > + NULL, > > + }, > > +}; > > + > > +static struct testpmd_driver_commands async_vhost_cmds =3D { > > + .commands =3D { > > + { > > + &async_vhost_cmd_tx_poll, > > + "async_vhost tx poll completed (on|off)\n" > > + " Poll and free DMA completed packets in Tx path.\n", > > + }, > > + { NULL, NULL }, > > + }, > > +}; > > + > > +TESTPMD_ADD_DRIVER_COMMANDS(async_vhost_cmds) > > -- > > 2.25.1