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 7814942A69; Fri, 5 May 2023 07:08:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 66DE3410EA; Fri, 5 May 2023 07:08:31 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 75FEA40ED7 for ; Fri, 5 May 2023 07:08: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=1683263309; x=1714799309; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=ZDDUMtQHwdJqwxFlGYC6quq3Qfubx07ST7Pa/Od8WKI=; b=K/gW+x95px4mkT97Bubl8VAwj37lQd9ATuujkbb6y6UvFnOAocEM7Sch efn+EP3UWIdHnIbfyjS9oAYDDiiFDaMQB/VQQNz8MOcOcChQlH3M2quQ/ dAslETE3CLdvc3V3oujjzA180iZn9++MQmqgyKM3EF8A8hM0lu0OcdukF +I90JPjDJSw4KRYCTkNVjnFVQR7oFj3flR8p/0nuV1PbDPP2aYrLaMKtI YDkK0SUZlsw7XWQHyoLkvuYOClV1bCh0UNGLOo0HdiMK3XJBU2NMtCf+w LKkAhiAERsEKrW1ykP3G0MVrZFZ2kUAKfm8nFXYb216iu2ObS5X2HPAoL A==; X-IronPort-AV: E=McAfee;i="6600,9927,10700"; a="377205762" X-IronPort-AV: E=Sophos;i="5.99,250,1677571200"; d="scan'208";a="377205762" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2023 22:07:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10700"; a="697375554" X-IronPort-AV: E=Sophos;i="5.99,250,1677571200"; d="scan'208";a="697375554" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga002.jf.intel.com with ESMTP; 04 May 2023 22:07:54 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) 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.2507.23; Thu, 4 May 2023 22:07:53 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) 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.2507.23; Thu, 4 May 2023 22:07:53 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Thu, 4 May 2023 22:07:53 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) 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.2507.23; Thu, 4 May 2023 22:07:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XT8CGebPat344fVDcNn+ORm3LxGos7MZhtjdtnv780oNzPQ1Zl7F9cFk3HlqtntPDp0RcxHYSFGL4IEHeN282GUysWmeB99aauKPACT2CzTj/1rguJ+BdmYblnMJaz9p2QMwrKmrFXmsqp34JLqFpJQYyTo7Kc341uLXbC5WpW4wzTEL5T4C0dKipnRjELciPJYGtKXyAmBm9E9YakQLWaEvD9A4qhn4Lp1t5Y92N46msj3XJzvfvhvEe194Dka4kgvF9GfrmCfHq2muuH+bMAgQDSw6XKBl1CSyszLfC2asU8h8nfi6H0bLKi6PLn8M4TT9URJSOcLkU9k7uOcr/Q== 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=asPnBbddPTtx0Fi2pxYO+Td+97s2p0h3t6bweHiym/g=; b=Kj83xyFmRYXVjbIyg7G6W4/3+aiFUyehmDWsheEeRbUCTgSpZdNAtB8y4AGPTPDwJQCJ/bGLvQsjJJOZIMv1CPKaMJVq8b+BldT2+m26y2Vx7rsZ9UjbRrHtobnfYvn5xkPkc1V9E0RHDqvJD/vWfNAI9QAmrakv2xO1sWV2wwvs0tOhCSpPYTfZyITynOQRiTphRrZd2d7OhNG5M6FumDvbIhPMNHxUyxwC1NDZJzrS6LjhABC2RXQFkwifD5+4Caf5UzRe5gEZ8w7Fiw3SaAU8dCeuUXoLZZk3bFMq7MuXO4QVp1n2D6BKUDcTTdwDh2n07j4cKT4N2xe2X+FPvA== 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 IA1PR11MB6444.namprd11.prod.outlook.com (2603:10b6:208:3a7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.22; Fri, 5 May 2023 05:07:48 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::5797:849:7a10:560d]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::5797:849:7a10:560d%6]) with mapi id 15.20.6363.022; Fri, 5 May 2023 05:07:48 +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" Subject: RE: [RFC 15/27] vhost: add API to set max queue pairs Thread-Topic: [RFC 15/27] vhost: add API to set max queue pairs Thread-Index: AQHZY+ec9k1T7VuBTUmFqj6U8xYAn69LNcxw Date: Fri, 5 May 2023 05:07:47 +0000 Message-ID: References: <20230331154259.1447831-1-maxime.coquelin@redhat.com> <20230331154259.1447831-16-maxime.coquelin@redhat.com> In-Reply-To: <20230331154259.1447831-16-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_|IA1PR11MB6444:EE_ x-ms-office365-filtering-correlation-id: 30aa342d-96f2-4d12-720d-08db4d26ab36 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: xCMLNqcbcfpM3K1VyFiYovJlaIoqh/e1Id2UqakIT/Lu99f3JUb3Ybh50vFTzVl80ZWKIGZKah+TR1bZgkstz0StQf6MOTKVC9I8b8pTBqHFScbnYNlZnHIgDfvJv7/tpOzQ7M/Pwc0Mr9UaijBMhz/RGKpqB9MzjsI6wpoEqVvJ6Y/Nvqr+bL411eCBINsHxwEG9mkkhyDRGzaLVCVpzuOVY/KUAphKS/ZoCVJzVs6OawLijlZTtLvVvCzYexXZblEkZcPkHcrgDRFNIp9YR7bY/OTSapUJ7JS9bsjT6Ng5eql6l5/VwdOKlBDHL9ZlxW8l/aDhp70vb1UTX8oJPN3Whtq+3I/WfMurJzY68cQKTeQLZop8xOempnM8BvbctAmoTJPZsb9vn5ELGt7FtMpeHY5lECIiJPDKYD6DqdHrKwldMHfcob/dFQFLsOzWohGeDNEqkKQACQ1Z4uBKDopPMeHyJtkJjPQRAK6/KO/XAyvSCqDx/W4InO+rj1EV9moa6Dfa/AL8/UKNqMTHwwbpavfldlkxasvAF5oLAeGeq7RJkqD4zxXdQBvjvy7iV43puZouAwm3XTTI5WGYzY+Ugl4VsdIDLdp/ay7Q6JM/lYOktKdWGfdHlWmBmQaQRa8VP9o27fRpjFHHojGySw== 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)(39860400002)(396003)(376002)(366004)(346002)(451199021)(921005)(55016003)(8676002)(26005)(6506007)(9686003)(8936002)(7416002)(53546011)(52536014)(76116006)(316002)(66556008)(110136005)(66476007)(66946007)(64756008)(66446008)(71200400001)(41300700001)(478600001)(5660300002)(7696005)(122000001)(33656002)(38100700002)(82960400001)(86362001)(38070700005)(186003)(2906002)(83380400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?dfHUw9QG1u+8tpNyPl5BMk+NYfydF/wR12S39oT+B2aoEaaQV4VpFMSycA/T?= =?us-ascii?Q?6sEpnsQCTVxYXQL5wedT1EPu46bNr01lrRXPIsz1csCAGCAJ8rVU3KVZxIis?= =?us-ascii?Q?8lCEULc7Y8s17/iqguEgGrWY5Ha0MayeybVjbj9nAkwpETB8++XxsEzwXeeB?= =?us-ascii?Q?O/0fcBsOxu0r9MS+vI1O1mFja5e9GPvWJTayhBLSzAAvrowIzq4eZlb5Z3Pi?= =?us-ascii?Q?UOjt2OMlkKh8KsGPr59El0eA7ND+iyDJL/UNztKgrZPly8YplV5XrZoFbhhk?= =?us-ascii?Q?Q0qnS6kcRbtKGK5EGFoXIK7raqsmrTzvn8fXf75loc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q?wbBstKHoJeBuhCwMjH+G8X6ubwTmJJpI7661JoaMA88yhJbrPZij6hHndMqu?= =?us-ascii?Q?DruMEd2ILDcdbTDK1yKT/kFefcBZKYAvzbgR6tr69SrLQGubptQ5D6T8E+v2?= =?us-ascii?Q?lpqL4BpwnzZXFrnrU/8QE9ltIXTc22j58GueJZsg9FAKuH6OyYjtn8m9kChk?= =?us-ascii?Q?rGur4aQcg/codoDbiUTQ0gWnOF+kd45QFmzxKH9nL0ADB896LDC7B8uAoP78?= =?us-ascii?Q?UYLm4WKNhW0NUeLyKonyDgor9Z+hNdHJOZqUgpciYjo1bm0MakhotG/4FK6M?= =?us-ascii?Q?zjJM/DLquZG+K6UcuZqN//QDk3z3tCDOa4lUmGkEEDgKPEhHBrqTpMs8AwZ/?= =?us-ascii?Q?Lf7UY+rJ65z9n9dQKNrTy+gjDEHCL6I4pcVs9dT2?= 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: 30aa342d-96f2-4d12-720d-08db4d26ab36 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 May 2023 05:07:47.9051 (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: cyYq8fwdsQcLa7q29OXzcx+eHiS3UjZZdBn9B4Dnsj+pU7iawgbAQhXpfR1bTQdVhsqcdOa1dWer7oU8r/ryPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR11MB6444 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 Maxime, > -----Original Message----- > From: Maxime Coquelin > Sent: Friday, March 31, 2023 11:43 PM > To: dev@dpdk.org; david.marchand@redhat.com; Xia, Chenbo > ; mkp@redhat.com; fbl@redhat.com; > jasowang@redhat.com; Liang, Cunming ; Xie, Yongj= i > ; echaudro@redhat.com; eperezma@redhat.com; > amorenoz@redhat.com > Cc: Maxime Coquelin > Subject: [RFC 15/27] 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 ++++ > lib/vhost/rte_vhost.h | 17 ++++++++++++++ > lib/vhost/socket.c | 36 +++++++++++++++++++++++++++-- > lib/vhost/version.map | 3 +++ > 4 files changed, 58 insertions(+), 2 deletions(-) Also add changes in release notes? Btw: somewhere we should also mention vd= use support is added in release notes. Thanks, Chenbo >=20 > diff --git a/doc/guides/prog_guide/vhost_lib.rst > b/doc/guides/prog_guide/vhost_lib.rst > index e8bb8c9b7b..cd4b109139 100644 > --- a/doc/guides/prog_guide/vhost_lib.rst > +++ b/doc/guides/prog_guide/vhost_lib.rst > @@ -334,6 +334,10 @@ The following is an overview of some key Vhost API > functions: > Clean DMA vChannel finished to use. After this function is called, > the specified DMA vChannel should no longer be used by the Vhost > library. >=20 > +* ``rte_vhost_driver_set_max_queue_num(path, max_queue_pairs)`` > + > + Set the maximum number of queue pairs supported by the device. > + > Vhost-user Implementations > -------------------------- >=20 > diff --git a/lib/vhost/rte_vhost.h b/lib/vhost/rte_vhost.h > index 58a5d4be92..44cbfcb469 100644 > --- a/lib/vhost/rte_vhost.h > +++ b/lib/vhost/rte_vhost.h > @@ -588,6 +588,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 ba54263824..e95c3ffeac 100644 > --- a/lib/vhost/socket.c > +++ b/lib/vhost/socket.c > @@ -56,6 +56,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; > @@ -821,7 +823,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 > @@ -831,7 +833,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); > @@ -890,6 +921,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 d322a4a888..dffb126aa8 100644 > --- a/lib/vhost/version.map > +++ b/lib/vhost/version.map > @@ -98,6 +98,9 @@ EXPERIMENTAL { > # added in 22.11 > rte_vhost_async_dma_unconfigure; > rte_vhost_vring_call_nonblock; > + > + # added in 23.07 > + rte_vhost_driver_set_max_queue_num; > }; >=20 > INTERNAL { > -- > 2.39.2