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 34AE6A0558 for ; Thu, 26 May 2022 08:34:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2DF3E42684; Thu, 26 May 2022 08:34:11 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 5C86E40DF7; Thu, 26 May 2022 08:34:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653546848; x=1685082848; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=CizlRxbuJhdfhviDciySTxF58Cwus4mOMOIONXNTktc=; b=LZOtm67y5IxQ91FaLoguGWOzO+4UEMTdnxq5vIvZy2HDIOgG+mYWS7tX 6wXkhDxJn0jqflJkMy+GfsmlbnXYI5oFgxrg+LS+6LEku/nXKWDDz2vXp UPZgub1HDuWqqXojZ+npv1EsdziYW3GAwHTngYkVql36pp2AlXevuc6aU ikUx1IS60G4U/2oJPnethFinLe0BBGyJdF3U3agCgGBlUEItNvSKSdZCH ARgkA7zUPumzsjmBMmhnU03U+dqeXoYxf8Mr/c0LBkeS8h1sT5gS4MQ6j oUtPVmWeQxPMdbSzILZHW1VPHOA8KZX7U96Wd8NZjwgP0Nd0kCcEMcH65 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10358"; a="271624631" X-IronPort-AV: E=Sophos;i="5.91,252,1647327600"; d="scan'208";a="271624631" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2022 23:34:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,252,1647327600"; d="scan'208";a="746156550" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga005.jf.intel.com with ESMTP; 25 May 2022 23:34:06 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) 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.2308.27; Wed, 25 May 2022 23:34:06 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Wed, 25 May 2022 23:34:05 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) 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.2308.27 via Frontend Transport; Wed, 25 May 2022 23:34:05 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.108) 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; Wed, 25 May 2022 23:34:05 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BI+eAVuwlX/0bxA7Pj2OKo/SzXPKTyTy6HatFjpmTTrOTvTTXSR+KphwTVGIY6y+E3YtmYsw/hAeXEn/WccH5upAh6/WfzMejULqrqn3ncMv6tJdqGHMkDHqn3FVXeE5YS9XwHMk0PWEL1k0ukX95U/QuAr5pzbvX0lpgWcNDdf2xej3hX4arxg7D1KB/hkJ/1YpcbgeGErHZNhgBNRJEB92f1g9gquE4jcR4SN51Gp803KxeRE2VDRoNxZNpUBM93LdIizXUMdxotonG5iyANWAr9mS/a8LrCpDz+vtexEdJfp57/VQkStgei22aGf1vHJAyuJMqhSBs6+meGZNTQ== 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=UKh/LBrfWHRzL6MF0dfaXru6IJNGE0qBD4SzpXa+E6M=; b=hW8HKl87KDbKnDqu+kjjkGK3V2uR5lTUH32ovalJeSWRHEAT5oioxjBdSD/AwFl3RAEyYMVMljyC2USTn4Zp2uZGvdZERwZBKVvPsUGjIDjWLZzruD6jY28mZK9RBSNQOItHl1TNji7660j1k3gYA4lOnUcMWt7/b6udtprHCx1IXeCnunqVhbc5xrTr01h1H4kS9Ape7gA2zwik58WqnAok/+d7/T2eLmNdYjpNsnLrAvvZyeNi7SqqqVxVy95eCe0BIWjQWaT0IMQjBGHJcuT04hLf8vD81L53H1qO1vJisksUBx8ju07zHleymOjdGIsaM18LpryoVGmx2wsPwA== 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 SA2PR11MB5068.namprd11.prod.outlook.com (2603:10b6:806:116::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Thu, 26 May 2022 06:34:03 +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.5293.013; Thu, 26 May 2022 06:34:03 +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 v3 2/5] raw/ifpga: remove vdev when ifpga is closed Thread-Topic: [PATCH v3 2/5] raw/ifpga: remove vdev when ifpga is closed Thread-Index: AQHYcLBUoK/Ixbzsj0CukARrJjI4UK0ws2qw Date: Thu, 26 May 2022 06:34:03 +0000 Message-ID: References: <1652862549-13131-1-git-send-email-wei.huang@intel.com> <1653535974-1379-1-git-send-email-wei.huang@intel.com> <1653535974-1379-3-git-send-email-wei.huang@intel.com> In-Reply-To: <1653535974-1379-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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTA3M2JhZDEtYTJhYi00YWE2LWE3MzAtMWFjZjQ3Zjc1MTA5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiVnBYZ25ZMDZRdlhaV2JuckNKTmc5Q1dGZ3gzbnUwK1daelhoSFZwQ2lUaGJ3bDdoXC9vcUpFNXVRUjRpbWhZTVkifQ== 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: 86d86ad8-03ef-42d3-c3d3-08da3ee1b9ff x-ms-traffictypediagnostic: SA2PR11MB5068: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: xFd0njK5V121bAvJ+XJi6KPoPWqVWrfdct9W8RTPIYs70aquULdI5oCb6mLrp/urqsgOBHFL77+QBc+xSs1QkybVVMEtnSlM5B0IDuEsbyExQM9OHssaElMsjsDCji5CKeC7tL06M9Sf+4VSydWHMEbneX8CtdU89SDJFw1cQ6DLfCd6pa0aXZspMouUj3GMex1i1LM5MQxpvD/Pk6RNgzLHKj2ikz5LEQVNkTZrkpTgLFag9Lera1z1kURKhoWeTZ/EIAh5/xOtaVQWTUBLRtDUohudAv92RtGpxt0f9B1sONClBfiJLi8TfVG9wSLkH9DlbUn32oDb++S6BvqB5324G+O5+3ochMOiRHBTu4RvS/PndP4pbbG9QkXFxTi6dfk+oSWKq55fP83lE9lOqbj4cqu6EF+v+8bSvcxcmxxuG/95t+zT/IuOvfL92OItPc3gFJnPE03Tf24MmLqtOHVezJNIF4SiVug1e7kbWsgOJlKxDnYczDCJz6TGzcGOE/va/x4hgfV4cZ9s9A47BCgurrrxO89DqzLU1vQnITgPjyHEO6cQuBq8qEPeG9cndg1zWlmX/lAyNKQtDZ+0UgZosvBkf/PRDHebW3Uu7cHQs9H62rkqYfCVYMzJ2IvVr954721ma3kOCyd/SPuLMxvnorMDJ9ODTy35ONO4zapZzNZV2KQn517cpKhYT4gltNJY/zwkIQmH+A2+hQ6InA== 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)(38100700002)(52536014)(122000001)(110136005)(54906003)(316002)(7696005)(8676002)(26005)(9686003)(33656002)(6506007)(508600001)(71200400001)(53546011)(64756008)(107886003)(186003)(66476007)(66946007)(86362001)(66556008)(66446008)(76116006)(4326008)(2906002)(55016003)(8936002)(82960400001)(38070700005)(5660300002)(83380400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =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ascii?Q?TnoeiXsvwA=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: 86d86ad8-03ef-42d3-c3d3-08da3ee1b9ff X-MS-Exchange-CrossTenant-originalarrivaltime: 26 May 2022 06:34:03.4832 (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: kZU/HmVK3uHILK0OQD2rIW0XiMHgqyqjquMxK29RZAD6sN7XjxsXmFci16to/wAbXuKuhyeQxP8j6/r4RX+Z2w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5068 X-OriginatorOrg: intel.com X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi Wei, My comments. Thanks, Rosen > -----Original Message----- > From: Huang, Wei > Sent: Thursday, May 26, 2022 11:33 > 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 v3 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, use macro to replace immediate value. > --- > 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..eb9a9a5 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[8]; It seems like a PCIe bdf name, can you replace the constant with PCI_PRI_ST= R_SIZE? > + int port; > }; >=20 > struct ifpga_rawdev * > -- > 1.8.3.1