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 E45ED42C31; Mon, 5 Jun 2023 09:56:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D6CB240A7F; Mon, 5 Jun 2023 09:56:30 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 9509C4003C for ; Mon, 5 Jun 2023 09:56:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685951789; x=1717487789; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=DFnmSOl0v3PxG+rThbvGTCa9hbg7dwig7ndAeWP33lM=; b=YlkbYLpx//Kg9rw3XspjulTuxJyUWLHnsA1Nd9vufEUIBTOcMYlSQFij YmcbPg8kS8y/Ooo3f6dSrmXUZ77hxoL2n+TxX+chsfanZXOjfVSNgVtYm 3JzE0ukmSeexI9Y6+z5aA6451olQ+qxVagSmMAwhXnlKJlXs7Im4u0QXV Bi2Qr70sRfK6yfaZW0sJGDHc6fNkIN2GwmBl0YHTlqAC+AjSCbY1KbJsh z+96gn38sFd3PI6uQjna3mZDAHA4yx4GxbFbO9Rzfq2T8QIqMwBU7y2Z+ DEaTWZ5EYsF/fFXJuR1DNd83egEqpiIQ0Z2eoE/nHFoFzvEV8pxRs4Yxo w==; X-IronPort-AV: E=McAfee;i="6600,9927,10731"; a="358755943" X-IronPort-AV: E=Sophos;i="6.00,217,1681196400"; d="scan'208";a="358755943" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2023 00:56:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10731"; a="658982055" X-IronPort-AV: E=Sophos;i="6.00,217,1681196400"; d="scan'208";a="658982055" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga003.jf.intel.com with ESMTP; 05 Jun 2023 00:56:27 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 5 Jun 2023 00:56:27 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 5 Jun 2023 00:56:26 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Mon, 5 Jun 2023 00:56:26 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.43) 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.2507.23; Mon, 5 Jun 2023 00:56:25 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SsVEXFcpZM1fkbgCtXu7ktoOAiQ/41zZ6OkQFxr8hok7zcFFCQMStGmgAU5uBcRR3lSBWWLQug2i3/Pgf/4AEDlQxizrBuISTC3egELm5Fw46Tq6Um2aiImZK3xKZsb7VwqS/2s1q3Cw8GehaEdta81f5JkSXIJNe6y0ncIlcf/v/dCxfOyOn9+HHKtwmI4xOSeSB23YAe/Vys7M9mdN11xRvnuav/fODyOghnxXQmJRspXAwy5jvmxosasRRpqMU7b80QPgsUJkGgoUVZUbh1J5n5Pp6AHV37uJwe4Vd3qXMvITDNX0rvYdDw3gJwsJBr64/7N3F7tfuivPix8ZNg== 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=z43XdtxOfesSmE38n9fiPhDqXBAQggC/pk/KxvMycAA=; b=mb7OnfchDlhTunTT/EbYL/gOhz5yFjf1i/eyHDwnjoGVcGQVgdAArMRts/TpuHhgsVNVjQDiSodTemOCXZnIDhmXmNwKTSv9ptkFefH/sZ/JU8YdzQzdkbQWXzrxGI+Z1mVguVQglRjIXvQ+/rBB52VQyWqgV1Ygtg35c14uFQD1l1E5Gyss5LYV8qqd+wPaQ9lMRtkP18WexKRmZKcsZwPOBw+EQYfF81a34oUjCZwflCCrVF1RIt3s5sWFL5JYCoUGY4nPCWGo9l7FuyQaSajhOfigqLj5vtX9/cLvhvs5VzKJHmaNjku8H7jGFGTklQknpkfTKQ4sU9481BtbMQ== 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 SN6PR11MB3504.namprd11.prod.outlook.com (2603:10b6:805:d0::17) by PH7PR11MB6859.namprd11.prod.outlook.com (2603:10b6:510:1ef::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Mon, 5 Jun 2023 07:56:23 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::e508:44ff:3d34:60bc]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::e508:44ff:3d34:60bc%4]) with mapi id 15.20.6455.030; Mon, 5 Jun 2023 07:56:23 +0000 From: "Xia, Chenbo" To: Maxime Coquelin , "dev@dpdk.org" , "david.marchand@redhat.com" , "mkp@redhat.com" , "fbl@redhat.com" , "jasowang@redhat.com" , "Liang, Cunming" , "Xie, Yongji" , "echaudro@redhat.com" , "eperezma@redhat.com" , "amorenoz@redhat.com" , "lulu@redhat.com" Subject: RE: [PATCH v4 13/26] vhost: add API to set max queue pairs Thread-Topic: [PATCH v4 13/26] vhost: add API to set max queue pairs Thread-Index: AQHZlMTzekl7ufRg0UK1KpBdrC2abK973FbQ Date: Mon, 5 Jun 2023 07:56:23 +0000 Message-ID: References: <20230601200812.672233-1-maxime.coquelin@redhat.com> <20230601200812.672233-14-maxime.coquelin@redhat.com> In-Reply-To: <20230601200812.672233-14-maxime.coquelin@redhat.com> Accept-Language: en-US, zh-CN 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: SN6PR11MB3504:EE_|PH7PR11MB6859:EE_ x-ms-office365-filtering-correlation-id: 1c172859-9f2d-4e3e-136c-08db659a5b3e x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: s7X0hscxC79JCCjk27saYoWhaLDo40qWfIa/wPBLtgqoM+FYuC6k7wD6DIjPk/6ZuT6p8YGKvqn7gLKswTt+h0ppDkiG6wyZ2l6rLWSH8qYB+Q+qd/BIiTrc1nvwjZQLrND3HSr+BDw3z/dn1k/4myrGNjeC2lWEC+/xcduSf9aeAsryN78yvoKQVqxvRzJ436+NRXzji4Y/fuxwqvX+039iEO+18n/3KSVWftupsCHq/0LBpMO3q+2oODDOLrvsjqowIpAoa20Es0qRTVsfRCX8il73n4kiLapChO2LrfGduQacdVMdAzrJppv/weiMmkDm/RQ5/tZ4Zu9hQQnlbNTx9YVXXe8C6H/Im3l7SEY72QjiSVRHsfk678Abym6kzeenKnhz/IB+AARqCWltRF+MTQzmrKJszCKccRyPe6GpYgf4+WPXnrtV1g4nzt5ZfpPhwJmkfDWCs5+NfYbVtSIosaF27leQUeBRTJfS7nzfbCc1XQx/HCZEq1X864Rpovv23uTFBaJEO/jSkuUk4pRen1z4AlsBioQmBt0wDiTRhIvrUXA4+Lxl1ndGk9mHGNduRfpJe6tNAYmn4dlro20BK5qpZcxjnExTwPouipripQ/bCCqMQkthYoFj2wsl0GaFCMV+SPh4Uc8j6Vd2oA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB3504.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(136003)(346002)(39860400002)(366004)(376002)(396003)(451199021)(6506007)(9686003)(186003)(26005)(53546011)(83380400001)(7416002)(7696005)(71200400001)(2906002)(8676002)(8936002)(82960400001)(110136005)(55016003)(478600001)(33656002)(5660300002)(38100700002)(122000001)(86362001)(316002)(38070700005)(41300700001)(66446008)(52536014)(66556008)(921005)(64756008)(66476007)(66946007)(76116006); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?qvawTQnLwT56k8/zYaFeBABSfoq8gSCvbAUwHpQswroSZDDv4YoQqxtdGJsz?= =?us-ascii?Q?UJrecj8Ib3+VIzK2s4/shTTCibWYHdC9AT3F7rvULjoDfuXtXgSFv8wKyW4l?= =?us-ascii?Q?fkxuEeY+nNxRD1JlfNHwjQxAk0JzSZEqHXG9cw6yy2eRMs/7gpy/J+yO3Lpx?= =?us-ascii?Q?rTGiqWyJWp7uQDOXIcWuIROhPE1t57Y+nEvlmMTV18Xix33lSPYgXQoCu7cg?= =?us-ascii?Q?Vu1lqSp1lDeGxr+XcI3BV4Q59kB7+LQGhg1w0/TFo2W9OI7S24GXg7eKG9P/?= =?us-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PfF02yI+6Iopns8qbT7kKOaSMARA5XPlDbj?= =?us-ascii?Q?Dl4rMlM40oV97mn+3Wt76WPq2camJ5RnCRhEP9kIS/RtWwATDKTmdm0R9y5I?= =?us-ascii?Q?wQf7yZlz95E6DDbrxKBrqp1Bo6HiIvxvVpkNYwUqIplw93DleNBOgvEVfaVw?= =?us-ascii?Q?Wic54sLrUTfKXYeX14YFd6WkVu+TmdRd5/vmeZoWddQrszN3iC/HBL3VMMBx?= =?us-ascii?Q?pDa7QWhu5dVqQk3XeA7tCtKuNV2G8DkkzEyFjF7ODeDvtHozD7NS/zTvO+/W?= =?us-ascii?Q?YFgmq1voZhERePHjA8hvuKS478ngLJyTx+PuKDeeE6PQ5pLzCP78TbeT0HkC?= =?us-ascii?Q?iuL9z1EMWwP780wHH5uRYgW7yFAR/wB2JGCNWwNdXw5wfqnoNG2UEfusqofx?= =?us-ascii?Q?gxhn2ygZ5d5vcJQ70cHUKOI8p9kNAg+8Qhyx7Znj?= 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: SN6PR11MB3504.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c172859-9f2d-4e3e-136c-08db659a5b3e X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jun 2023 07:56:23.2857 (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: XO31eC1JSUBmAlMHl8Os3bvM7PL55VZ/NbhDGkLrcn0u7VjfdTMXZOvf1wq28vtlVj8K2Hry2xFhNeh4A80H4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6859 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 > -----Original Message----- > From: Maxime Coquelin > Sent: Friday, June 2, 2023 4:08 AM > To: dev@dpdk.org; Xia, Chenbo ; > david.marchand@redhat.com; mkp@redhat.com; fbl@redhat.com; > jasowang@redhat.com; Liang, Cunming ; Xie, Yongj= i > ; echaudro@redhat.com; eperezma@redhat.com; > amorenoz@redhat.com; lulu@redhat.com > Cc: Maxime Coquelin > Subject: [PATCH v4 13/26] vhost: add API to set max queue pairs >=20 > This patch introduces a new rte_vhost_driver_set_max_queues > API as preliminary work for multiqueue support with VDUSE. >=20 > Indeed, with VDUSE we need to pre-allocate the vrings at > device creation time, so we need such API not to allocate > the 128 queue pairs supported by the Vhost library. >=20 > Calling the API is optional, 128 queue pairs remaining the > default. >=20 > Signed-off-by: Maxime Coquelin > --- > doc/guides/prog_guide/vhost_lib.rst | 4 +++ > doc/guides/rel_notes/release_23_07.rst | 5 ++++ > lib/vhost/rte_vhost.h | 17 ++++++++++++ > lib/vhost/socket.c | 36 ++++++++++++++++++++++++-- > lib/vhost/version.map | 1 + > 5 files changed, 61 insertions(+), 2 deletions(-) >=20 > diff --git a/doc/guides/prog_guide/vhost_lib.rst > b/doc/guides/prog_guide/vhost_lib.rst > index 0f964d7a4a..0c2b4d020a 100644 > --- a/doc/guides/prog_guide/vhost_lib.rst > +++ b/doc/guides/prog_guide/vhost_lib.rst > @@ -339,6 +339,10 @@ The following is an overview of some key Vhost API > functions: > Inject the offloaded interrupt received by the 'guest_notify' callback= , > into the vhost device's queue. >=20 > +* ``rte_vhost_driver_set_max_queue_num(const char *path, uint32_t > max_queue_pairs)`` > + > + Set the maximum number of queue pairs supported by the device. > + > Vhost-user Implementations > -------------------------- >=20 > diff --git a/doc/guides/rel_notes/release_23_07.rst > b/doc/guides/rel_notes/release_23_07.rst > index 3eed8ac561..7034fb664c 100644 > --- a/doc/guides/rel_notes/release_23_07.rst > +++ b/doc/guides/rel_notes/release_23_07.rst > @@ -62,6 +62,11 @@ New Features > rte_vhost_notify_guest(), is added to raise the interrupt outside of > the > fast path. >=20 > +* **Added Vhost API to set maximum queue pairs supported.** > + > + Introduced ``rte_vhost_driver_set_max_queue_num()`` to be able to limi= t > the > + maximum number of supported queue pairs, required for VDUSE support. > + >=20 > Removed Items > ------------- > diff --git a/lib/vhost/rte_vhost.h b/lib/vhost/rte_vhost.h > index 7a10bc36cf..7844c9f142 100644 > --- a/lib/vhost/rte_vhost.h > +++ b/lib/vhost/rte_vhost.h > @@ -609,6 +609,23 @@ rte_vhost_driver_get_protocol_features(const char > *path, > int > rte_vhost_driver_get_queue_num(const char *path, uint32_t *queue_num); >=20 > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change, or be removed, without prior > notice. > + * > + * Set the maximum number of queue pairs supported by the device. > + * > + * @param path > + * The vhost-user socket file path > + * @param max_queue_pairs > + * The maximum number of queue pairs > + * @return > + * 0 on success, -1 on failure > + */ > +__rte_experimental > +int > +rte_vhost_driver_set_max_queue_num(const char *path, uint32_t > max_queue_pairs); > + > /** > * Get the feature bits after negotiation > * > diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c > index 407d0011c3..29f7a8cece 100644 > --- a/lib/vhost/socket.c > +++ b/lib/vhost/socket.c > @@ -57,6 +57,8 @@ struct vhost_user_socket { >=20 > uint64_t protocol_features; >=20 > + uint32_t max_queue_pairs; > + > struct rte_vdpa_device *vdpa_dev; >=20 > struct rte_vhost_device_ops const *notify_ops; > @@ -823,7 +825,7 @@ rte_vhost_driver_get_queue_num(const char *path, > uint32_t *queue_num) >=20 > vdpa_dev =3D vsocket->vdpa_dev; > if (!vdpa_dev) { > - *queue_num =3D VHOST_MAX_QUEUE_PAIRS; > + *queue_num =3D vsocket->max_queue_pairs; > goto unlock_exit; > } >=20 > @@ -833,7 +835,36 @@ rte_vhost_driver_get_queue_num(const char *path, > uint32_t *queue_num) > goto unlock_exit; > } >=20 > - *queue_num =3D RTE_MIN((uint32_t)VHOST_MAX_QUEUE_PAIRS, > vdpa_queue_num); > + *queue_num =3D RTE_MIN(vsocket->max_queue_pairs, vdpa_queue_num); > + > +unlock_exit: > + pthread_mutex_unlock(&vhost_user.mutex); > + return ret; > +} > + > +int > +rte_vhost_driver_set_max_queue_num(const char *path, uint32_t > max_queue_pairs) > +{ > + struct vhost_user_socket *vsocket; > + int ret =3D 0; > + > + VHOST_LOG_CONFIG(path, INFO, "Setting max queue pairs to %u\n", > max_queue_pairs); > + > + if (max_queue_pairs > VHOST_MAX_QUEUE_PAIRS) { > + VHOST_LOG_CONFIG(path, ERR, "Library only supports up to %u > queue pairs\n", > + VHOST_MAX_QUEUE_PAIRS); > + return -1; > + } > + > + pthread_mutex_lock(&vhost_user.mutex); > + vsocket =3D find_vhost_user_socket(path); > + if (!vsocket) { > + VHOST_LOG_CONFIG(path, ERR, "socket file is not registered > yet.\n"); > + ret =3D -1; > + goto unlock_exit; > + } > + > + vsocket->max_queue_pairs =3D max_queue_pairs; >=20 > unlock_exit: > pthread_mutex_unlock(&vhost_user.mutex); > @@ -889,6 +920,7 @@ rte_vhost_driver_register(const char *path, uint64_t > flags) > goto out_free; > } > vsocket->vdpa_dev =3D NULL; > + vsocket->max_queue_pairs =3D VHOST_MAX_QUEUE_PAIRS; > vsocket->extbuf =3D flags & RTE_VHOST_USER_EXTBUF_SUPPORT; > vsocket->linearbuf =3D flags & RTE_VHOST_USER_LINEARBUF_SUPPORT; > vsocket->async_copy =3D flags & RTE_VHOST_USER_ASYNC_COPY; > diff --git a/lib/vhost/version.map b/lib/vhost/version.map > index 7bcbfd12cf..5051c29022 100644 > --- a/lib/vhost/version.map > +++ b/lib/vhost/version.map > @@ -107,6 +107,7 @@ EXPERIMENTAL { >=20 > # added in 23.07 > rte_vhost_notify_guest; > + rte_vhost_driver_set_max_queue_num; > }; >=20 > INTERNAL { > -- > 2.40.1 Reviewed-by: Chenbo Xia =20