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 111C4A0544 for ; Mon, 20 Jun 2022 08:36:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DD51640150; Mon, 20 Jun 2022 08:36:29 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2057.outbound.protection.outlook.com [40.107.93.57]) by mails.dpdk.org (Postfix) with ESMTP id 3281940150 for ; Mon, 20 Jun 2022 08:36:28 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Db40KMj2OAnsxNIQiuVFPUTPmqjn0gCWvHn+26A3kZ8ZosFK0WLsV3hhUACsW7CT+gu3EEHcZ6EA/r4tVg0QPkFXQwRUxK6XXLuUNPz4Zv+9Jq56IZ23rBNSnPdvdPExApT8nQWHP995mmjDwVqo3mrjn4IKWWMPExdju2zPrVSpXLUcXFa88b6ZFRykJvUkvf5Xm+bBlByMw812TsehJempTl9k8Pix5k4H95vDNXJ7IfkMf9cEFXPo8Wk2YOA+ZBHwoUvwQg3R93EMDoyskQgmAnoH9Y5+wFko98RIPuK1wZLO769XHKG0gHDRlnQWyOyQEAXJGA+jHuDhiGWyFg== 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=Iwh/Y+j/zR/ppNXpEKLWyPHkkuQa4Xy4DWGp3hjmYGw=; b=XkeyKwD2coMqsB0xYCjsTiTnuE1kZfZHO0WwBLMaHUS8JsvuPfJBl+KHrhHtRYybB4hueYaCkaXvANgodIF2xsBxO1r+FhLcH+uSnCz1VfKrmSdcfPTKRdZ4+xscwi2R4UfaU3ciaeWMEEJsQvNGpwnujMpL2XajYlRuoj/vHu8/mb661gyNrQJfCwjoz2mXm0JpZq6z7GXbwIyUBkxR9wNvjcfMCxRDyntXib66AskpLIw+COmxK8fen0RmYz4QEqDJcu4odsYQd7i5eOboAnNJzEs4ygONpxx+ARk6TdssnDBTI7chM4F+G98sJWAGPPW97T2vs4C0pwQ6KYijug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Iwh/Y+j/zR/ppNXpEKLWyPHkkuQa4Xy4DWGp3hjmYGw=; b=IyZBOvAvzarPPGdzZ1VSxmYJlQIJRvIZTIOAsg9Ex3FMiKdEa4p3h3MrNQP4dRYURo/Ylzkvm/cvyHzZWbBPcf7oVbS72kddnHCje1WalpqzKyC9f514oZLp4n4js31fOcPneFEYPAmN0NRrWR9yGlG9mBcGRcIwElZgXOMq8uIQs+i4faMCwg7YkBY7eOVwXX52AFhwS0j0utMoAZM5qIW957JrY+9d/6Dfmid2PebJA/dsp4ghIcN8f5+vYG1AeNH5QDNw6ZJnzluXtKNz00mtldohnqFmD9FfwQ+VtAN8zpQIB+PbVwtmfjlZy+wPISZqspm1hks0Cor4YFDd7g== Received: from DM4PR12MB5373.namprd12.prod.outlook.com (2603:10b6:5:39d::14) by MWHPR12MB1886.namprd12.prod.outlook.com (2603:10b6:300:10f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.16; Mon, 20 Jun 2022 06:36:25 +0000 Received: from DM4PR12MB5373.namprd12.prod.outlook.com ([fe80::9416:525c:ef8d:6bcd]) by DM4PR12MB5373.namprd12.prod.outlook.com ([fe80::9416:525c:ef8d:6bcd%8]) with mapi id 15.20.5353.022; Mon, 20 Jun 2022 06:36:25 +0000 From: "Xueming(Steven) Li" To: Wei Huang , "stable@dpdk.org" CC: "rosen.xu@intel.com" , "tianfei.zhang@intel.com" , "NBU-Contact-Thomas Monjalon (EXTERNAL)" Subject: RE: [PATCH 20.11] raw/ifpga: remove virtual devices on close Thread-Topic: [PATCH 20.11] raw/ifpga: remove virtual devices on close Thread-Index: AQHYgfqZaL2Ji53z7kakkbx4dmvzda1X3BNA Date: Mon, 20 Jun 2022 06:36:24 +0000 Message-ID: References: <1655437101-10248-1-git-send-email-wei.huang@intel.com> In-Reply-To: <1655437101-10248-1-git-send-email-wei.huang@intel.com> Accept-Language: en-US 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=nvidia.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: eeb50ff8-30ca-4ef8-0da3-08da528732a2 x-ms-traffictypediagnostic: MWHPR12MB1886:EE_ x-ld-processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr 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: d7BLUuBDxYixIgvNUzr59+NuSc+koxl7m78zvTCfQkvWcbwtA9bCk92ksxppL9Lstwq6Gca8c4aOAndDocFMmViSa5hG9JziEE7D9UG1F5MHg6earxcu0B2kTfFeSQ/1Jgu9J9iMJiNksC6aqFMzj/CAIzBo7AAsK4Hh0F6xJs3sm+tc/BwpNHec1H4IzaEnU2GZSB4n7c/qbep9pqepdlgchGPFHdpGFnYogXcdKf5uFA41egku4Jv/0j8LWXEkxlICkOpmGyRVlovp4LSgOyVdSZTdJu8FAcLc80vob3kWNtq6hLEMazoXw4E1a26rHf8OJwEGUGd7dEVy7eeCqjdmc21ZTbYT82HZ6xFVr2lb79wIFeuEbTBBgtRup7nX6aAnvnKNhSpbGL3sOr8s7QP85POMzZIh2LSxMSBM2TsKK3xwJjd+cOEc6ksGtnHgdLWBUPS+8ue6xhF+GUhbO9i/T5ry83M6zySs52eqO2WooN1gBAN7XEHvfqSVpYU/Mqbf1M2/uzVjdVnc7p/CjIWyZ8HUf8ufuYpyEzQpX3auw3cygRFCd0U5Q7UGR+mCpvr7OlZoAM3ILormKhySOaol+eBE0crgKTmr8QnAGhNHWiiPiHpgUP9IPsB0QJ4I8ziW0WeVB7JIfLXgWwHtE3/3if9fEp+IVW3m7LKR2rP/iCQ2MQsrmrAjRMSkC68poV4PIPY0iynXtEQNDbeGOA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR12MB5373.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(366004)(53546011)(8676002)(54906003)(4326008)(86362001)(110136005)(7696005)(6506007)(71200400001)(66556008)(64756008)(9686003)(66446008)(2906002)(66476007)(76116006)(38070700005)(66946007)(26005)(316002)(8936002)(5660300002)(52536014)(38100700002)(186003)(498600001)(83380400001)(33656002)(55016003)(122000001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?zGy8E5AWN42GisGbvsnp9pr77b1Q4bNPAgdDLoiELldm7DoU25/kqvaiAKJn?= =?us-ascii?Q?aPzniMXCiyM9ePX9B+ENYpfYPoIg4xamFR01b8XuVjb0oMMJRmOYdcrLMKfs?= =?us-ascii?Q?a2Nbl7yhwFvu2jzYI9ojWnkkCHP3AXjRHXjQzqcHtcdQpYvaw1UFD3OGTEYt?= =?us-ascii?Q?q1ZASgxLGhgGlOzCWEjs/A/f+bGpa7X/P1YxSJKXgDqx4NZOGbrXmT57o/P6?= =?us-ascii?Q?20pHdTp39uD0ZYC7SCn1tmTjkzX4qGWg0hUf/shI7xAOclHmw3CT35TJMfxK?= =?us-ascii?Q?mC+Jtb81KLUTl6ud8v0CsePb7dssndsBEjWIcxZJYYFxFA3Q/U5kmfYFERol?= =?us-ascii?Q?4HOsfOCxu7xeSyXROW0QFjr7KVu8eesb8gSBt9c58dA2v2meI0fkA7YkYuTU?= =?us-ascii?Q?Cq93VbWAEUvyeL1+7tW/pMT4klydkjrSX1OveP6YNrdINOUI6DN36+VrufeW?= =?us-ascii?Q?oQMax6emm7fHzYjsyTfMP3B50yvuiH67oVGaDjZgaPTOrMP7O4TBZY2IWOLU?= =?us-ascii?Q?8aRhpCBaVf/KFG1UAC/eRrZHbbQhloLW1Ly9bJdMAeQEfBPD0kUI7TljavRL?= =?us-ascii?Q?nY3pCzhM6yV4ih2KOs+qLmvWubSBQuhJ8ZyQt2pqZmrFyiQd1YIzSQYhZbs1?= =?us-ascii?Q?3ly+MYzsjlX92aw6MOkUQfhXatRpY6iNn7tc+oV4MpWhxefkWWFS2y3lq8/j?= =?us-ascii?Q?nXmvoF98dfsehVMIneL0Ya4qo+CJEnFW7mQoR34Vq7k0zhqE4ES2vBSrxMdS?= =?us-ascii?Q?WSrLM8Ldwf8csApm0CXFwWMh6TOR/H6+2MRefPMbWikBhSz0hudaeOjklC9i?= =?us-ascii?Q?ufOlTUrmrcHAcCEOlcEE6nd+VG01aUll2HzuS8hY8rIjaH0VJ0DOj7//Mhzi?= =?us-ascii?Q?SQ6xfuY1X9cSy6GWiGpGGFcz+OH3E8fBJQ/cH/uymuRPs/iSw55KVnUz0r06?= =?us-ascii?Q?DVv5N7Dh1qevFGahvc1rpGWPGOTQgPTNw6CLVCcCjKcNKtrqzrQgtX9Ti+UI?= =?us-ascii?Q?68i80cW0kVrTT9UwtklMW6eJCtgFrOcIKRo4FcRoyWLsuJWwlkUCEupZH4+C?= =?us-ascii?Q?Hhvb6kbBo1SLJ9+Yccnumv9qXo7l9+geV502nsF6DcFFNelx4djjuZZuL00s?= =?us-ascii?Q?D/FZ9hprR3cHpXY7hlTQWXrKads8RjU3hJdZnIaXrFPlPYpEYU0LF3LPtkgi?= =?us-ascii?Q?4xyteHexeJiX6D0SKN6rpPNxraaYeifKYCNpUcaBgeXvdVHAL0TpzU/ocy/V?= =?us-ascii?Q?dKilunm8TZxIV+YXFXBkDorgShdBhFUBS7+AWFT57DnBM9SlaUeKMWSczycR?= =?us-ascii?Q?v7C1+3e28D/MwNXJT+RX48joTcGXxIcxI2TNAmzkUtkAxK0FkCzILRXKBqPm?= =?us-ascii?Q?0cBjBnOk+NURKXLTRdEwNtvYqvTFXF0WePN0s4LviFww9EULDKf/nBy7Nfds?= =?us-ascii?Q?ISTx3X8PKYlsg+DwbL9vY7N3wZ4wsdhDCH+4/ffnQuQZ5NQf9VsdA+7soozu?= =?us-ascii?Q?ji/zVd+eQ8ED5W+kwsnZCfv+tmGThNmx4fmh33d9b9W75AKWuZ0ATzO/crpH?= =?us-ascii?Q?M0wkYmJ4avbvOr7hVF2vvUTFImQhSo0G1fkzq73N6LDxhVqEXHXde0ExREhu?= =?us-ascii?Q?BIPIDvmlz0jJLxJyyty9iJdjlUxkj33l3RLiEXqHfRsnxtxBuTmgfstzwrg+?= =?us-ascii?Q?AeaSTqcqWJFpxTGdseVCxX2cn5PFtSE6oXx8CtOIDef66nxX+jQXzZ2KK5rE?= =?us-ascii?Q?A2gLORRjgA=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: eeb50ff8-30ca-4ef8-0da3-08da528732a2 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jun 2022 06:36:24.9421 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: v4DLfqthwZjILI4weNL+OUhba6/VjOv1cOsxc2UJT/A+/la6gb9aZ8oUaT51RfxqWgoZOEn+JRwWaRdt+hsDuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1886 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 Thanks, queued into 20.11.6 LTS > -----Original Message----- > From: Wei Huang > Sent: Friday, June 17, 2022 11:38 AM > To: stable@dpdk.org > Cc: rosen.xu@intel.com; tianfei.zhang@intel.com; NBU-Contact-Thomas Monja= lon (EXTERNAL) ; Xueming(Steven) > Li ; Wei Huang > Subject: [PATCH 20.11] raw/ifpga: remove virtual devices on close >=20 > [ upstream commit ae835aba40349ee9631ef6b52e68a2893febe7e0 ] >=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 after the ifpga raw device closed. >=20 > Fixes: ef1e8ede3da5 ("raw/ifpga: add Intel FPGA bus rawdev driver") >=20 > Signed-off-by: Wei Huang > Acked-by: Tianfei Zhang > Reviewed-by: Rosen Xu > --- > drivers/raw/ifpga/ifpga_rawdev.c | 170 ++++++++++++++++++++++++++++++---= ------ > drivers/raw/ifpga/ifpga_rawdev.h | 8 ++ > 2 files changed, 138 insertions(+), 40 deletions(-) >=20 > diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_r= awdev.c > index 8e4030d..ee6589a 100644 > --- a/drivers/raw/ifpga/ifpga_rawdev.c > +++ b/drivers/raw/ifpga/ifpga_rawdev.c > @@ -135,6 +135,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; > } > @@ -737,12 +739,23 @@ 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; > struct opae_manager *mgr; > - int ret =3D 0; > + char *vdev_name =3D NULL; > + int i, ret =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) { > mgr =3D opae_adapter_get_mgr(adapter); @@ -1634,9 +1647,6 @@ static i= nt fme_clean_fme_error(struct > opae_manager *mgr) > if (ret) > IFPGA_RAWDEV_PMD_DEBUG("Device cleanup failed"); >=20 > - if (dev) > - dev->rawdev =3D NULL; > - > return ret; > } >=20 > @@ -1693,75 +1703,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: > - if (kvlist) > - rte_kvargs_free(kvlist); > - if (name) > - 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; > } > @@ -1769,10 +1822,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/driver= s/raw/ifpga/ifpga_rawdev.h b/drivers/raw/ifpga/ifpga_rawdev.h > index b3c7295..b4aaa15 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