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 A6576A0543; Tue, 7 Jun 2022 08:02:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 925304021D; Tue, 7 Jun 2022 08:02:58 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 5112840156; Tue, 7 Jun 2022 08:02:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654581777; x=1686117777; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=0gC45lXmhkXuzjWV68XsREg9zKvuMhoa+tXKnx3KD7k=; b=d+OTBas1Fg3wlwWqUKqqdzI75ER4simSNFNiLX5Ti/AXJdFsEzrSUmwv Sh9mHsi8c5f7GF2mVKHiXZ/D/n/byGIZu1bJwjgCZTsDQ8BDfaqzvwySN VVLp0YnEw7p+4ja24ylfZW5YdNHN+RBm+uAgGk38tCxuVcYtKi3MG4RIs lllqQ/rIYvj/8crb8cEpSkr/uKlL8UftfOdujppoXNXQ4gklVx093Jwsz kJdtjBQeAtQvKEHyOvdSFJxQmFMfZfTIZyduNsWq/x8mnWSpDawm791ys Ju3dQCD0xIpAw+IpcOGqiu7BJvgMoW9sqe0UgMWUlzpYxFX+IfsaP/7Gf A==; X-IronPort-AV: E=McAfee;i="6400,9594,10370"; a="275483625" X-IronPort-AV: E=Sophos;i="5.91,282,1647327600"; d="scan'208";a="275483625" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2022 23:02:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,282,1647327600"; d="scan'208";a="647884040" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by fmsmga004.fm.intel.com with ESMTP; 06 Jun 2022 23:02:55 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Mon, 6 Jun 2022 23:02:54 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Mon, 6 Jun 2022 23:02:54 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.177) 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.2308.27; Mon, 6 Jun 2022 23:02:54 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QtroTDMpGCETvgLQEUQqUX01jsn5amYCISTq1Lb0ZlQCYQquDLTtADGPX9DpCYNdQQxsnp8iX/ubrUutqqZ89KF3tsy/bVWYzTOOpXkbW6v0mRwNx+hLoBMhUqEs+4C2ywc0LGVfu1DZLPfauTMq01Ml1LCNXuKH/r0nq91Ja9RIxNGLSPhBqi5ZvyxPscz7eIRqvk73xcTUogHqvMzFuqRDt8QuPMR/V2QK84vVjz8QLQhkfVaDU5sIPmGAGMR2KnIf7KqK/E27Mvw6T9oHyreuISipUDNxT0Yq7+z3zAR9BWj60Dkgfi9J79L718+rhrPHePP7plSGsVTtt4GCXA== 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=+UV3RPF4Vj/8JMIDvgO299WuVxfj64tvL19pXOOHvgw=; b=nNfpNEbfPXkUGmkPgP/TOeT+xrgMS6X918sOo77RGbTD8w+yvzwHPLxCDbzevFwst+u2EAoANeoA/qREeqhVeMl55D1ITGGZLmQNQC9qb7oWZOAt1Qow7vVJECRo9dTCEF7pdclT14GvBGzmSD/PGgDW71Tv3twskH+RN6RFElfII84In3XjQB6jHE4RJ4yI9NRwZDD8pGLyPAlBVmLCaA+hTemYTOszzmVIYG7sr8nTsXjB4LU144MGWv1qaOBJy8OYsDd3gDXjEvdbCeY3QKcqtN+PMxdOCAoQ/oTUxlMAXJa3UP3ZmrQyvb4SCJWoAoyNy5fEaDRTsUsAUseoig== 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 DM6PR11MB4252.namprd11.prod.outlook.com (2603:10b6:5:201::26) by BYAPR11MB3685.namprd11.prod.outlook.com (2603:10b6:a03:fa::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.15; Tue, 7 Jun 2022 06:02:52 +0000 Received: from DM6PR11MB4252.namprd11.prod.outlook.com ([fe80::b9d5:600c:9f13:bc96]) by DM6PR11MB4252.namprd11.prod.outlook.com ([fe80::b9d5:600c:9f13:bc96%7]) with mapi id 15.20.5314.019; Tue, 7 Jun 2022 06:02:52 +0000 From: "Xu, Rosen" To: "Huang, Wei" , "dev@dpdk.org" , "thomas@monjalon.net" , "nipun.gupta@nxp.com" , "hemant.agrawal@nxp.com" CC: "stable@dpdk.org" , "Zhang, Tianfei" , "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: AQHYcaOHOklnIqw4jkS6vU8dzItPxa1DhRdg Date: Tue, 7 Jun 2022 06:02:52 +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: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzA3YTVjNDItY2M3Yi00ZTdkLTk0M2EtZDEwM2ZmODQ5ZDFlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiZVllSUdHY093aGEzNkM4VzM0SXRpWXdCaHVUcWR1YnF5RlZcL3F0NjZWejgreTRzVXhnSHRVU05DWmFXTEZKYlgifQ== x-ctpclassification: CTP_NT 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: 9c484274-0a5f-4a95-0a67-08da484b5ba1 x-ms-traffictypediagnostic: BYAPR11MB3685: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: FaG2BDfWjMa7btmVeID9qBADmBUVS2Vdcx/qoYoCbt+SRkQ/MDbVqUxH4mC892XM0Wx/gNB4X8ZMZmJIHNj0PM2FB+k4IFpNGAtoIH9SPHsUp1TOvKuVOnpm2M/yB9XKyJHd857D5sKmGUStx37uk3zGRaL3quKY4OZJi6l5qn7e5JKOGHI11KxHX/v8oXHzpISQojJJemCJM+CvuQE7Oi6kzMmmqjQ9A7rLjHtCW2nzF+2vC/ed5rXM5ff7c3elT1IYR5/SAHZo6aWyvfDcfwPZ2vXJib1Jm6fA2t5DsyEDkEgV5VQu2A6iIlxgnWKOoj3gTo8GCXhumi2qfUQ8pX+UKDU/+gdkciy6KLrJ6yJg/B5Mdkf5u3cGL96r22jVQ5SeBC7JoNrF5aRIH6Meli+nzEPwgLSZorwLJsyg3CGIvRpDbHLlMEGfkr0Xw8NSjSwLaGCU9mZz8nydiJzhvVhQ8AnBRllwFWv4Ut2Z89XZxAYAuy6KIG7Vl06fffoUlzSAbt2OAygIR2O/kLA+N8Q95av11e+y5RDmViDVz3nbkoMKROFQhWnFkqkVd4mIkgAPOfISbHObE15Si7rmOhuNOjFFbFj9KUQYgi/gfifSWiFrIworPo+O35BOy1UHBPw+5cJFiCbL5hRrZlkzXRorqA1QHc70WDSkx7nZb5f0lBAe9O6Yq+psFby/b5UCTlv5Qmd0tkHWiIZs2B0Qtw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB4252.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(8676002)(4326008)(76116006)(5660300002)(52536014)(53546011)(66946007)(66556008)(64756008)(66446008)(66476007)(71200400001)(38070700005)(508600001)(83380400001)(8936002)(7696005)(82960400001)(26005)(86362001)(9686003)(122000001)(6506007)(186003)(107886003)(110136005)(316002)(54906003)(55016003)(38100700002)(33656002)(2906002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?L88IpnUGhk6D31HXW+CIxYmntRLulypTxiA/DbyG3RXF44uL9406VI4po9F4?= =?us-ascii?Q?puvfdR0wI0K2lFdmA3W7uW2EvGyJWL8t+oOt67zM+1qqp+uwaQpPedVhePkm?= =?us-ascii?Q?VvxgYKACrxuiL4bSaUz262hNmxi0l4rmNNYFQfVpCgZOXmtkKIDMydWS4951?= =?us-ascii?Q?BFaqvH8JW6rvARh95QzuKT+yEeHGYRYp06IdUe2346cSZNaWfj0RqOCv0u/Z?= =?us-ascii?Q?AYYhcTYOupJKxZWg2sGaAjwK2sW3fBiGgW+JJbPqtpdALNnKERmSsmGGnAYE?= =?us-ascii?Q?C0PIHvJHXypmXkADeuz6mokdgHEJHaMMsndA28DUkOI2AYDowMQLOmqsamdU?= =?us-ascii?Q?1TUF3AsxITm601OnAjFSryknm1ut/FPtT7LNoUzVcvm3u/U7klta7VYfIb9m?= =?us-ascii?Q?14v2FUxxWa7iGWdfdUcWuByM+T3GJWF/j8sepQ6B+fKwS5VDaqUOVcUvHefC?= =?us-ascii?Q?4TKnK+dG7154wwZ9uuBHCg4iSjluUZrZrG2uXv9M+pqaZGFsGR54NkSgLDA0?= =?us-ascii?Q?tUe4BSdtMgio5BWRzp5bBXX2FIojCVgeCAlxuElLde3kGvtMkbwWnT6aIyrb?= =?us-ascii?Q?uUarqhd3n/2ivDeL2tZnmZILNOraN/XYB5TJ5zlHJnrQx3sdwOt/aMqj1rML?= =?us-ascii?Q?7yEBXUG2Rq35iZ0QmUnRtcjhZZ5sas5BZhlX6bW/RWz5Xn3zNnlyi+8mWjgS?= =?us-ascii?Q?HEYytlz1t2aQd3qXmuRG+h7xy4dCPpejGCv5+kv6Pe37kYkLQ91NyTjuavWs?= =?us-ascii?Q?x+gjEn/JHVZsKk3rwRUmkD9KmkDQYhywC7hAqki78xm4ZI6mxBQ+an3PVpqx?= =?us-ascii?Q?gnW0xXZoXJk9h3Jy+A/0/RCwOg5Th9MZFiVJfw75blkSFBsQZHPLgl6vrCGY?= =?us-ascii?Q?gzeWHPlF0pLBn57xwTtWemTKqSOv92r5NhXwMlOJPqbDCT1jCEa8vXli95mL?= =?us-ascii?Q?MZsH4qpNUQSfzuYKzVcubuJOrRkrrum2mkn7tuVZ5qvVDyl4V/RKEXJEgL8p?= =?us-ascii?Q?LNcsh4VVAuk+DqfRrYfUvXjbufK6OvGRzpWuGVzut6HNfNGKZ47E3lpZf3DQ?= =?us-ascii?Q?2E3RAy2ZgifUcKY+w2/2dMkeMf3843Z7KrrZ7L/QaW3L+QIr1vWDIu04tFBI?= =?us-ascii?Q?GeB8NMjgkh+HI8MyeQ6AVSaykXdNF2JMfgJ41dj/AWEU2Q9zzrPCTKnlVsKn?= =?us-ascii?Q?z861ka9BVTs9ZPudVPP0+gxGP3pMwnUGcV5p9W7dr5x6xJnJSjMnlWGVFwvz?= =?us-ascii?Q?XWnezRcxkKPtvMzEf7TDl9Jlv07fq3VoaSXQMpVZ8j//6gF7fch4vfHs8JwY?= =?us-ascii?Q?1tT9iLCFFxUd2EeS0mKC0cFSNDWkYpymAtCDe20SGTIC7ptj0XbgZjf9JvaQ?= =?us-ascii?Q?OjEGs4kvRzMcun/uYkl/HLUSCZ/j1gBJuhdNHnue1nNG9htzJMk1zhJzZ4cD?= =?us-ascii?Q?+7Nt8me/2C28+yP2Kylh73LcnFDS+c2DXuNp7XnqCkXXCKZbsNldr9gw5d3v?= =?us-ascii?Q?21Utj4GMP3jzIoq+cCZyRUVdUey0exqegYieW5v7K6YeFSBFbsgv3Yw7q5lB?= =?us-ascii?Q?5ur6fnFQwvYqC7S8VCRSzhKJmcvWDuSmVKjhnqviyNALJVIw3QYfXoW/B7H6?= =?us-ascii?Q?OnCCPwCwISVqVNn5gdnS4X6pB7ZtLD19CPPal5WRCPKj9S7L7m8YpOyczbly?= =?us-ascii?Q?QR4iPhz4pZ035vkDLAoPOeAuBbnAQliSFKTe9EW+70Cyreghtpu4XRTZ6Wg2?= =?us-ascii?Q?y2daaKSdxQ=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: DM6PR11MB4252.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c484274-0a5f-4a95-0a67-08da484b5ba1 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jun 2022 06:02:52.2905 (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: UjyBpqbeWbPNqW4/YQdynsY4QY/nw2AbRF7uRgt7VSl6kxDzvjzRK6gumwYpoPQaaWeNruqV4PWsLeYnceTvvQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3685 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, > -----Original Message----- > From: Huang, Wei > Sent: Friday, May 27, 2022 16:34 > 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 > char *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 * > -- > 1.8.3.1 Reviewed-by: Rosen Xu