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 255CBA0542; Mon, 6 Jun 2022 08:46:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0D47D40A7F; Mon, 6 Jun 2022 08:46:26 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id A9DD540150; Mon, 6 Jun 2022 08:46:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654497984; x=1686033984; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=dtHeExGGXE1WbKbwHUtjW3b/SpboHBvBaM1kDi/4GTY=; b=NI4whf20ZcPLQxydUqxaED1zeqhIegCqPiUjNCoX+fN6JfJh364GRfJe rzgjbOp9Osk3Zm0KRqfJjq3g7FPeYPRsZrE0kxI/BmWxP2pT/nEIws9AD hgeByawGhztSxEYXMKAhUqC+B6jZ/hxLzd4Yx1NebAEnpn1m8kUjFS1FB KjAlV2O5Z3i4GIiQa50ZpjRZx8xTN2XNUamOVslIgsnJ3rEyuu6+Y2MOA M/3+Ir5TjlyANQJrEbHtkTBcJh+bt3demV3DJOFnIyp6mFAM93xx8JyBP JaHk2b1XXp0rDF+8N9356xzLqfzn17dkfWqhKxug8eTeqYnjkm6noJb6h A==; X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="275409416" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="275409416" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2022 23:46:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="669340253" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by FMSMGA003.fm.intel.com with ESMTP; 05 Jun 2022 23:46:22 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Sun, 5 Jun 2022 23:46:21 -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.2308.27 via Frontend Transport; Sun, 5 Jun 2022 23:46:21 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.177) 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; Sun, 5 Jun 2022 23:46:21 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K9c7F5kHR2Z3gGgESHrlEA1OsHJBbaYb7HMB3P0U/g9EiJ1u/id5qTE9alDTZJ5V5/q2YeBFyry4AkS7dfRlfPmnxV89tv8dTFHPL/Sd6UrVQtvkRfG+T8lrpNjaIzOQTRAebUiQUohTf4xdDCbZDPxyPGQ/GUlsloIZl47NAA/P+N0N9yDTzA018ytwD0boqW/PH6h8GcFLkFjI7/dJCDJXePnZS067xQFjtOd8V6VRkehSSvxFYoGtjEPupDcGufKQ6XRcOeyQQzTt5LaRp7pnENgut52BOnI3RzyYZYWSbJqFa7Daz9LHUm6sd9HalfCzUIxZxlbwayd2ZouHRg== 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=lCQ6Cjnib0wWe1gBsHu96bjuPqX0BmPdtB5tsTlu0zg=; b=dbVJPa6LYbincHod+OzLYqVl+qhjOwgNIXfwo/FY1PcjfqtyyV7GADuOPCsUWYQAqyuJkIKowdY24ZCpbTUzbEzWAOI+dOKhrG8z44Bwv8MzCl9Rm5vg3V1ZDR5bVsJwhfoMouXlbWOBgq6R04eJXlrpf9x0hoAA3QOxhO9RnnFqbo6CIBABbvehRlcoybOcivxFltovrkfKn2t+AR6q7EFgxdoMQRNppS26wCPULEOkAwpaa/glB8Jn7gUP8dk8nrK6I5VTFyyirzHnEk+B9wraxfWd+AqpkO7kE+O2HIQphtx6JoxT9M5xPVJi//x1PSoW12D9TEpOBko/iVbR7g== 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 BN9PR11MB5483.namprd11.prod.outlook.com (2603:10b6:408:104::10) by MN2PR11MB4464.namprd11.prod.outlook.com (2603:10b6:208:188::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12; Mon, 6 Jun 2022 06:46:20 +0000 Received: from BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::4d94:5d8b:51d7:d8b4]) by BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::4d94:5d8b:51d7:d8b4%9]) with mapi id 15.20.5314.019; Mon, 6 Jun 2022 06:46:20 +0000 From: "Zhang, Tianfei" To: "Huang, Wei" , "dev@dpdk.org" , "thomas@monjalon.net" , "nipun.gupta@nxp.com" , "hemant.agrawal@nxp.com" CC: "stable@dpdk.org" , "Xu, Rosen" , "Zhang, Qi Z" Subject: RE: [PATCH v4 2/5] raw/ifpga: remove vdev when ifpga is closed Thread-Topic: [PATCH v4 2/5] raw/ifpga: remove vdev when ifpga is closed Thread-Index: AQHYcaOHzZe+vbQIzUuxUHhrPWiyda1B/sfg Date: Mon, 6 Jun 2022 06:46:20 +0000 Message-ID: References: <1653535974-1379-1-git-send-email-wei.huang@intel.com> <1653640433-5066-1-git-send-email-wei.huang@intel.com> <1653640433-5066-3-git-send-email-wei.huang@intel.com> In-Reply-To: <1653640433-5066-3-git-send-email-wei.huang@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.6.500.17 dlp-reaction: no-action 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: 699d6bc8-e211-40b2-0788-08da478843a0 x-ms-traffictypediagnostic: MN2PR11MB4464:EE_ 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: uR3DsFcOmpypznMIOER9Ov86QKlpkIrUVp0Ahz6X0XL5cAZt9hrwcYy4o65erRQtfP91y7WDaa+8xOH/xlXtNj8yPBig+VMN88MvJDgzSMBGZWg0asn3N6TqA3diVz2/GYHXtH2WFKLWoUJ1yAIdg1nPwoYXYR+od9cTyaruY3RrYNhg+aBmV51loyJzdXsWq05xlIPzBHr04DChS6Oar0n1eBc305p4Puedy9CLnc7Ui72AKqsI5r+ySsqFhpAgqDKwG1Xf74NsyhSGpkgeKlUxHHBUcXvskWG/V2Vrc5HOEs7LDcpP4vsbgKnbjpNz8nbrG1W3R3zhiGy9TKuDtNwZrDwLE0GRzMQEFdqr2zm9Tml0yIOF0tL1nn613Zg8R6uqb/05PFpUUAEUEGbbrxgZVllHFsqxSptOKH6lK+SRq3q4xfKcOmlFH5oCTjMR2VcItJX0pM9YR+QWmvdS8cJyBTZAABcWRtEHaYidPKUS+AGboGPs8ESnq2X7xbpVAYr/wT/2RBNUQtIeFlMjeeOgRP6bYKVEuWuddnXAmRUC6jkTlWMMxhRZwlLh1TlZXa2foiFjnioE46hDJ/OIsLyOLS1TBWM56dcdcQG0nKBQ6gpnCGlclaqaVNhJ/EG86BxTwpXJ9X7GBJsXbzfcCZaYN2nRlLri8gcyKSmGVRCsAMLbp48ew8oz5I52xfBQl7mxWA0Po/C53sAnRmjJog== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN9PR11MB5483.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(66946007)(66476007)(4326008)(64756008)(66556008)(66446008)(76116006)(82960400001)(107886003)(53546011)(8936002)(8676002)(52536014)(122000001)(71200400001)(7696005)(26005)(83380400001)(9686003)(110136005)(508600001)(54906003)(38100700002)(5660300002)(33656002)(316002)(55016003)(38070700005)(2906002)(186003)(6506007)(86362001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?j7Uc1FyAIFdARki9UG2Iyd0cYZ2Q0LiEp2c8CCNOGPuOt1BxTgDeT0Rff9YF?= =?us-ascii?Q?GrE3wNtYgxMNwBhZDfc+moH2245WkTgHWunlq0fwE48Q0ceAeWH4y3tFZmgc?= =?us-ascii?Q?8kSQcf51UgYglwxdsQhEJTESrEh/DueD/aoC9iN1SzbUG0bcrCyRhs7J6BYc?= =?us-ascii?Q?Gw/SJUejIWe3NbB/M7Y1/CwYjjrzmEAeoL34LgceGiUp2btIhNwEWcuZy+4w?= =?us-ascii?Q?Dfqsp8QAZ8nuNple6NFAJBB13YhdEwefYpeyiThDTFlmAUUwrHUGC59nwnfe?= =?us-ascii?Q?whmpvaYAvRNogV445NbrfUM1D2m57xNeqdIWnCYWCHIjjpUodWebcUqCZsO9?= =?us-ascii?Q?JQ5de/nXuvXNWq8uzNIUdVg8Sv/BiXbeZ9KXt/Ld32pxNWVuJuruE+RyFXkq?= =?us-ascii?Q?xdqJ/8phAaEnJqAtoUAYVbqRt7JWA9Lz3kjYYePzAXuGXzs9RfU3NmSjIK6k?= =?us-ascii?Q?pNluC5ReOVjt5lZqOnunTGdbDwnlId40VnISsK5e2AWwUL4G9YfqLwlhC/8o?= =?us-ascii?Q?O1Wi+zlW0zXtu6J6aWBFa+EqMgJbSZCHTmExzcdKN3HKjfYWcTBduBJxAcoy?= =?us-ascii?Q?U/FovuuU7TCtfVhm/3EOrgf2ZIXAH8w0H34WCR2jZ01L5eRV1B57A4Z4ZUi6?= =?us-ascii?Q?/KCYbDJsM6bxzGHCXwpFM4ZZKMmbktX8RsWFFbn9eG5/reyffn/F2sXM9QGm?= =?us-ascii?Q?DD1ci1VE/MrkGMOjyrk1y9/ug2OVWUrjJYlB0pj/sH5p8GUUFZ3vVvbgh2MZ?= =?us-ascii?Q?xft0v4QVkwTRx3PBsPdLG4lZ8VVLO/EitP9WYamCdS2o0LUoIqcQOeaJUACy?= =?us-ascii?Q?ve4W5kbbYUZUbMEIVyrNHvYYHhJEuA8SrZgrYUvSfjuNlakVv0Tlchf+pgWI?= =?us-ascii?Q?NRDmJ3fmT6oqrqe6FFmG2i2xUjXy8jCCKJB9yewYX6jZ4h1TsAQW8UdSt+Su?= =?us-ascii?Q?Pcz7pDFCI768bto+NJPK9uy3RI4Zo5dEo0w5suxFLUhzBQ3VbID7BLHcBYBF?= =?us-ascii?Q?Ifbj+sHJ7j49QDuYjZ490YMzvcH8wBSGLl6bNfwIwMK2rrf1pI2zICI6bsFD?= =?us-ascii?Q?GfhHvFSMwf3MOX072KAvvFterdcZbEc6NRsu1gZipMKomLjYX0pS0h/5/KUh?= =?us-ascii?Q?rukB41rghhr7Hoyro/GZVhUDd3+PNrZ3ooP/NXXn2mWFa+OsQsjuRTR2LlQ1?= =?us-ascii?Q?FnE3rUacxJhDvjL+17iu7bmaTO9uUW2GFqx2ZcPgkR3M/CPbvzC2A9G+rW0x?= =?us-ascii?Q?7bwshSFqaptiMC+7n//2eFKeouMAW1WO8Nz6FAjUzp9MnHd0nFp5ZNc9qpxT?= =?us-ascii?Q?GFaWUppZARqvyFAevCsWctA5hPLSiBIkEKUh5+UCzP6YfWXWZgfCpPNRJPUN?= =?us-ascii?Q?n7WZ52Vdn7rEICYU5/13DiQYraOP5P50LfNKP9pEnfYmYoIOugKual+19px4?= =?us-ascii?Q?3XKJAPxg0iUg8fPhxI2xqIl+N6/RjxU4zdR2owipHv6/PLJsa8cUkWpAo1oH?= =?us-ascii?Q?l10i9YfjDQub/fOnN8pVXcYVI+D+UkteHahxB0kpU1LaftHxdejzo1NoiSuH?= =?us-ascii?Q?e5uEzaSAJqkofBGCsFmAAkEpdDJ6egU2u7AdT/mh1INUrTZQAjEydsCpPQ2J?= =?us-ascii?Q?cHVahho11VETn1PP1xsCMwqtk6WAegOU6I/tkBFdX6pwm/DoljZGagM+KQq/?= =?us-ascii?Q?KCcmEzOOQ7v/m5FKC82nRkfpyTjacHvx7utwY60nBVimET6v/aX8uJRLrj78?= =?us-ascii?Q?8Gz/jsn2ow=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: BN9PR11MB5483.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 699d6bc8-e211-40b2-0788-08da478843a0 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jun 2022 06:46:20.1874 (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: PWQEmtm1H5dt95+llfa+ZnhoAv5FLtWgqPZX5iWLxlmFElKRBRq92d+tUpHoGAsUoIud59Wd7SESRgVxHR5b9g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4464 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: Huang, Wei > Sent: Friday, May 27, 2022 4:34 PM > To: dev@dpdk.org; thomas@monjalon.net; nipun.gupta@nxp.com; > hemant.agrawal@nxp.com > Cc: stable@dpdk.org; Xu, Rosen ; Zhang, Tianfei > ; Zhang, Qi Z ; Huang, Wei > > Subject: [PATCH v4 2/5] raw/ifpga: remove vdev when ifpga is closed >=20 > Virtual devices created on ifpga raw device will not be removed when ifpg= a > device has closed. To avoid resource leak problem, this patch introduces = an > ifpga virtual device remove function, virtual devices will be destroyed a= fter the > ifpga raw device closed. >=20 > Fixes: ef1e8ede3da5 ("raw/ifpga: add Intel FPGA bus rawdev driver") > Cc: stable@dpdk.org >=20 > Signed-off-by: Wei Huang > --- > v2: update commit log with Tianfei's comment > --- > v3: replace constant with PCI_PRI_STR_SIZE per Rosen's comment > --- > drivers/raw/ifpga/ifpga_rawdev.c | 166 ++++++++++++++++++++++++++++++--- > ------ > drivers/raw/ifpga/ifpga_rawdev.h | 8 ++ > 2 files changed, 138 insertions(+), 36 deletions(-) >=20 > diff --git a/drivers/raw/ifpga/ifpga_rawdev.c > b/drivers/raw/ifpga/ifpga_rawdev.c > index 6d4117c..fe3fc43 100644 > --- a/drivers/raw/ifpga/ifpga_rawdev.c > +++ b/drivers/raw/ifpga/ifpga_rawdev.c > @@ -134,6 +134,8 @@ struct ifpga_rawdev * > for (i =3D 0; i < IFPGA_MAX_IRQ; i++) > dev->intr_handle[i] =3D NULL; > dev->poll_enabled =3D 0; > + for (i =3D 0; i < IFPGA_MAX_VDEV; i++) > + dev->vdev_name[i] =3D NULL; >=20 > return dev; > } > @@ -736,10 +738,22 @@ static int set_surprise_link_check_aer( static int > ifpga_rawdev_close(struct rte_rawdev *dev) { > + struct ifpga_rawdev *ifpga_rdev =3D NULL; > struct opae_adapter *adapter; > + char *vdev_name =3D NULL; > + int i =3D 0; >=20 > if (dev) { > - ifpga_monitor_stop_func(ifpga_rawdev_get(dev)); > + ifpga_rdev =3D ifpga_rawdev_get(dev); > + if (ifpga_rdev) { > + for (i =3D 0; i < IFPGA_MAX_VDEV; i++) { > + vdev_name =3D ifpga_rdev->vdev_name[i]; > + if (vdev_name) > + rte_vdev_uninit(vdev_name); > + } > + ifpga_monitor_stop_func(ifpga_rdev); > + ifpga_rdev->rawdev =3D NULL; > + } > adapter =3D ifpga_rawdev_get_priv(dev); > if (adapter) { > opae_adapter_destroy(adapter); > @@ -1638,8 +1652,6 @@ static int fme_clean_fme_error(struct opae_manager > *mgr) > return -EINVAL; > } > dev =3D ifpga_rawdev_get(rawdev); > - if (dev) > - dev->rawdev =3D NULL; >=20 > adapter =3D ifpga_rawdev_get_priv(rawdev); > if (!adapter) > @@ -1714,73 +1726,118 @@ static int ifpga_rawdev_get_string_arg(const cha= r > *key __rte_unused, >=20 > return 0; > } > + > static int > -ifpga_cfg_probe(struct rte_vdev_device *dev) > +ifpga_vdev_parse_devargs(struct rte_devargs *devargs, > + struct ifpga_vdev_args *args) > { > - struct rte_devargs *devargs; > - struct rte_kvargs *kvlist =3D NULL; > - struct rte_rawdev *rawdev =3D NULL; > - struct ifpga_rawdev *ifpga_dev; > - int port; > + struct rte_kvargs *kvlist; > char *name =3D NULL; > - char dev_name[RTE_RAWDEV_NAME_MAX_LEN]; > - int ret =3D -1; > + int port =3D 0; > + int ret =3D -EINVAL; >=20 > - devargs =3D dev->device.devargs; > + if (!devargs || !args) > + return ret; >=20 > kvlist =3D rte_kvargs_parse(devargs->args, valid_args); > if (!kvlist) { > - IFPGA_RAWDEV_PMD_LOG(ERR, "error when parsing param"); > - goto end; > + IFPGA_RAWDEV_PMD_ERR("error when parsing devargs"); > + return ret; > } >=20 > if (rte_kvargs_count(kvlist, IFPGA_ARG_NAME) =3D=3D 1) { > if (rte_kvargs_process(kvlist, IFPGA_ARG_NAME, > - &ifpga_rawdev_get_string_arg, > - &name) < 0) { > + &ifpga_rawdev_get_string_arg, &name) < 0) { > IFPGA_RAWDEV_PMD_ERR("error to parse %s", > - IFPGA_ARG_NAME); > + IFPGA_ARG_NAME); > goto end; > + } else { > + strlcpy(args->bdf, name, sizeof(args->bdf)); > + rte_free(name); > } > } else { > IFPGA_RAWDEV_PMD_ERR("arg %s is mandatory for ifpga bus", > - IFPGA_ARG_NAME); > + IFPGA_ARG_NAME); > goto end; > } >=20 > if (rte_kvargs_count(kvlist, IFPGA_ARG_PORT) =3D=3D 1) { > - if (rte_kvargs_process(kvlist, > - IFPGA_ARG_PORT, > - &rte_ifpga_get_integer32_arg, > - &port) < 0) { > + if (rte_kvargs_process(kvlist, IFPGA_ARG_PORT, > + &rte_ifpga_get_integer32_arg, &port) < 0) { > IFPGA_RAWDEV_PMD_ERR("error to parse %s", > IFPGA_ARG_PORT); > goto end; > + } else { > + args->port =3D port; > } > } else { > IFPGA_RAWDEV_PMD_ERR("arg %s is mandatory for ifpga bus", > - IFPGA_ARG_PORT); > + IFPGA_ARG_PORT); > goto end; > } >=20 > + ret =3D 0; > + > +end: > + if (kvlist) > + rte_kvargs_free(kvlist); > + > + return ret; > +} > + > +static int > +ifpga_cfg_probe(struct rte_vdev_device *vdev) { > + struct rte_rawdev *rawdev =3D NULL; > + struct ifpga_rawdev *ifpga_dev; > + struct ifpga_vdev_args args; > + char dev_name[RTE_RAWDEV_NAME_MAX_LEN]; > + const char *vdev_name =3D NULL; > + int i, n, ret =3D 0; > + > + vdev_name =3D rte_vdev_device_name(vdev); > + if (!vdev_name) > + return -EINVAL; > + > + IFPGA_RAWDEV_PMD_INFO("probe ifpga virtual device %s", > vdev_name); > + > + ret =3D ifpga_vdev_parse_devargs(vdev->device.devargs, &args); > + if (ret) > + return ret; > + > memset(dev_name, 0, sizeof(dev_name)); > - snprintf(dev_name, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%s", > name); > + snprintf(dev_name, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%s", > args.bdf); > rawdev =3D rte_rawdev_pmd_get_named_dev(dev_name); > if (!rawdev) > - goto end; > + return -ENODEV; > ifpga_dev =3D ifpga_rawdev_get(rawdev); > if (!ifpga_dev) > - goto end; > + return -ENODEV; >=20 > - memset(dev_name, 0, sizeof(dev_name)); > - snprintf(dev_name, RTE_RAWDEV_NAME_MAX_LEN, "%d|%s", > - port, name); > + for (i =3D 0; i < IFPGA_MAX_VDEV; i++) { > + if (ifpga_dev->vdev_name[i] =3D=3D NULL) { > + n =3D strlen(vdev_name) + 1; > + ifpga_dev->vdev_name[i] =3D rte_malloc(NULL, n, 0); > + if (ifpga_dev->vdev_name[i] =3D=3D NULL) > + return -ENOMEM; > + strlcpy(ifpga_dev->vdev_name[i], vdev_name, n); > + break; > + } > + } >=20 > + if (i >=3D IFPGA_MAX_VDEV) { > + IFPGA_RAWDEV_PMD_ERR("Can't create more virtual device!"); > + return -ENOENT; > + } > + > + snprintf(dev_name, RTE_RAWDEV_NAME_MAX_LEN, "%d|%s", > + args.port, args.bdf); > ret =3D rte_eal_hotplug_add(RTE_STR(IFPGA_BUS_NAME), > - dev_name, devargs->args); > -end: > - rte_kvargs_free(kvlist); > - free(name); > + dev_name, vdev->device.devargs->args); > + if (ret) { > + rte_free(ifpga_dev->vdev_name[i]); > + ifpga_dev->vdev_name[i] =3D NULL; > + } >=20 > return ret; > } > @@ -1788,10 +1845,47 @@ static int ifpga_rawdev_get_string_arg(const char > *key __rte_unused, static int ifpga_cfg_remove(struct rte_vdev_device *= vdev) > { > - IFPGA_RAWDEV_PMD_INFO("Remove ifpga_cfg %p", > - vdev); > + struct rte_rawdev *rawdev =3D NULL; > + struct ifpga_rawdev *ifpga_dev; > + struct ifpga_vdev_args args; > + char dev_name[RTE_RAWDEV_NAME_MAX_LEN]; > + const char *vdev_name =3D NULL; > + char *tmp_vdev =3D NULL; > + int i, ret =3D 0; >=20 > - return 0; > + vdev_name =3D rte_vdev_device_name(vdev); > + if (!vdev_name) > + return -EINVAL; > + > + IFPGA_RAWDEV_PMD_INFO("remove ifpga virtual device %s", > vdev_name); > + > + ret =3D ifpga_vdev_parse_devargs(vdev->device.devargs, &args); > + if (ret) > + return ret; > + > + memset(dev_name, 0, sizeof(dev_name)); > + snprintf(dev_name, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%s", > args.bdf); > + rawdev =3D rte_rawdev_pmd_get_named_dev(dev_name); > + if (!rawdev) > + return -ENODEV; > + ifpga_dev =3D ifpga_rawdev_get(rawdev); > + if (!ifpga_dev) > + return -ENODEV; > + > + snprintf(dev_name, RTE_RAWDEV_NAME_MAX_LEN, "%d|%s", > + args.port, args.bdf); > + ret =3D rte_eal_hotplug_remove(RTE_STR(IFPGA_BUS_NAME), > dev_name); > + > + for (i =3D 0; i < IFPGA_MAX_VDEV; i++) { > + tmp_vdev =3D ifpga_dev->vdev_name[i]; > + if (tmp_vdev && !strcmp(tmp_vdev, vdev_name)) { > + free(tmp_vdev); > + ifpga_dev->vdev_name[i] =3D NULL; > + break; > + } > + } > + > + return ret; > } >=20 > static struct rte_vdev_driver ifpga_cfg_driver =3D { diff --git > a/drivers/raw/ifpga/ifpga_rawdev.h b/drivers/raw/ifpga/ifpga_rawdev.h > index 857b734..4c19119 100644 > --- a/drivers/raw/ifpga/ifpga_rawdev.h > +++ b/drivers/raw/ifpga/ifpga_rawdev.h > @@ -50,6 +50,7 @@ enum ifpga_rawdev_device_state { >=20 > #define IFPGA_RAWDEV_MSIX_IRQ_NUM 7 > #define IFPGA_RAWDEV_NUM 32 > +#define IFPGA_MAX_VDEV 4 > #define IFPGA_MAX_IRQ 12 >=20 > struct ifpga_rawdev { > @@ -64,6 +65,13 @@ struct ifpga_rawdev { > void *intr_handle[IFPGA_MAX_IRQ]; > /* enable monitor thread poll device's sensors or not */ > int poll_enabled; > + /* name of virtual devices created on raw device */ > + char *vdev_name[IFPGA_MAX_VDEV]; > +}; > + > +struct ifpga_vdev_args { > + char bdf[PCI_PRI_STR_SIZE]; > + int port; > }; >=20 > struct ifpga_rawdev * > -- It looks good for me, you can add: Acked-by: Tianfei Zhang