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 8E865A0543; Wed, 25 May 2022 06:09:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 34892400EF; Wed, 25 May 2022 06:09:56 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 44A2F400D6; Wed, 25 May 2022 06:09:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653451793; x=1684987793; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=IDKxZ93sFqRbhqPm5pzWdok/Li36pnl/nO1xVjQuVwg=; b=a1+QTVd+eNzZGv8uDnFAwKlCvRBSLZdZ485uCFxPKNDwfUW+qw9fUvfo zqAmndMMAZYg8crJBw5HyJsIPAXD0FUSPd6o9gnSC1DXfH033DSSzLYF2 Y5W2056caZzWpkMNyijKJGc0Vo68H2q11bItd/d8iMS0pGG8N6RmAOc69 I4YARk38jJG98MrNbn1M9psGS4JsWwcChs1m76boQJopOC1n7VjbAw/la 0wa3sFCN9aI1jtsHLP166hsgK141b3wk8dImIk7WN53ER7JFOX+T/B+hW SyFnuRi1k2F6c8Yoh5gQX1xq9d1LyaYszYlpBA5C0kb1M4BPVScaHfLrR Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10357"; a="273707534" X-IronPort-AV: E=Sophos;i="5.91,250,1647327600"; d="scan'208";a="273707534" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2022 21:09:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,250,1647327600"; d="scan'208";a="703738861" Received: from orsmsx604.amr.corp.intel.com ([10.22.229.17]) by orsmga004.jf.intel.com with ESMTP; 24 May 2022 21:09:42 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Tue, 24 May 2022 21:09:42 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) 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; Tue, 24 May 2022 21:09:42 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.176) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Tue, 24 May 2022 21:09:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JmDRwmhgMMdufI0OF7cWKUbjwMXF4DJ7dqf0W3eBrQWbs2Ta9+A5IrywzAg3MATlGJIBqO9mUCKAVVX2949kekQWyf0185cD8cXQ7jLs1bkV8goGebPoCUAEedH3CDr8RcTF0dpNe8uvGBIb/pz30v81SugFPPtO+dNfjGbhtbtkwoM88aUJC5FfbEValD4GhL3e5eiHGGi95eoEq0mZ6bpiKciAkVR65dy2C49ZU3n2K1lNaaIZeVbazJrhtNfuhSU0WiCEbSJyJKHRAKrvWcnHcVo3NxrD/tSEFnxeyKwMKcipei+jZzwJoMzSSdAI1NlO7jFF9WA1wSaRnzNsOg== 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=lpser9RCZAI7iJQ+7bNd+8FybDfW+BcWQTuaxZtkHfU=; b=DyhjKcpQoksAKiKFavYVPmDsgtYRQYpG349u92x94Xld5UYQVGKF0gqol3Kspqf7R6AmN9Gnm4A9hku5C+AcjN0CHm2E7Lk5GB559oLwWYDZGH11rz1kt086yRhn606PJYTQ6fphAdwyLckpNc+OZ5WdjqnCEzxTUnpZacZxENONhyly7DOgty6AEMWyrUxA2yN84d64+Umurp4LUYcIFfBy7hTrNJsC0+9juB1f1iwdNqTr8cQ7OAROj2ur3wZtdfyVLl14zxv+t93d8TS6EUiejO/18ipJaL1eo6e2MYDsiGSOmEjAD2GDoVDSt4+BGLjuZcVc9JugMmVKUZUmww== 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 CY4PR11MB1429.namprd11.prod.outlook.com (2603:10b6:910:9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Wed, 25 May 2022 04:09:34 +0000 Received: from BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::4d94:5d8b:51d7:d8b4]) by BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::4d94:5d8b:51d7:d8b4%7]) with mapi id 15.20.5273.023; Wed, 25 May 2022 04:09:33 +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 v2 2/4] raw/ifpga: remove vdev when ifpga is closed Thread-Topic: [PATCH v2 2/4] raw/ifpga: remove vdev when ifpga is closed Thread-Index: AQHYapBragrUckKfOkCaJ3nSrJT3EK0u/KEA Date: Wed, 25 May 2022 04:09:33 +0000 Message-ID: References: <20220517062854.1161727-5-wei.huang@intel.com> <1652862549-13131-1-git-send-email-wei.huang@intel.com> <1652862549-13131-3-git-send-email-wei.huang@intel.com> In-Reply-To: <1652862549-13131-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: dfff2869-5532-446c-09da-08da3e045fec x-ms-traffictypediagnostic: CY4PR11MB1429: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: aZNphFXf0axKHtaIRDdj/kk+xWAMWg3R3ON/BOc0ETf8eYxYvouFLZWDXuWeQ22ry20mg1mDHIfNKrW3jdky2kz/xoRqoJl7vLrEZ5OMrcJ1rcR1HkI4SvW2TpX1V6MO7F7QOFVfXRGor8a+S9e0+nZqfEM+TRbVQskmEI9rgeGLTRlBIsm0ShHo1AFL/Jh5vrntK6zFc4FB0kpu0UCKoS79qjdGlIrJ97GHEQ8CzlEnJt2JWIm+Ry/ELXSdzJNUlVLngw2Z+szxP3zwcpR0/UZME/P161s5aYwcU5oa5yxUTRlg8PzOStf8Oj92mQaNGtzpUjmEFoa5SqA+FOuf9Tturwgy8d7T06jAj8gK1CywFkksnsKxcx8tQhCA9VmKHbQHApfXxpbbzPxAF2Pnu1dXilS/xngozZtdpvB+fMDThs/XiQ5F8Vrm7IGTQ7/INaNpC30JxGdF3jz7P0HueSYNugcqgAafZ3u1cE9lHVd/qTxpZ8ll5O/MhmzKg+xmQOKMpSFbrrBdjyJeCHDcCYDo4UWS314GUtxY/Gs+kd2waRORRh2Cw90KQri6wwFZ5U+Y46pitFdRMDK3V/Kivx4n1hLBjp/WPa8xLmzRzDmCwu5s2tchzwy4XCS+/NLFCYMSZBMByHrrMPFe5dvGvZ70ELfZQDHyIjlyKnULwiMnS5sHt3HEi/GHjoF8+S2GYun86VxWnPh/f/GbrY3Yng== 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)(508600001)(71200400001)(316002)(55016003)(4326008)(83380400001)(107886003)(186003)(38100700002)(54906003)(8676002)(66446008)(33656002)(66556008)(64756008)(66476007)(66946007)(76116006)(38070700005)(82960400001)(52536014)(5660300002)(8936002)(2906002)(6506007)(7696005)(9686003)(26005)(110136005)(53546011)(86362001)(122000001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?aeufMsAzAhy1AnLuCG0ujjAt0M5WQYvuViyloWtSWYF0axGcUojVk8MH0VwA?= =?us-ascii?Q?rWlKl4vJGrU3j+1HFuAXjh+mS43fwt3dvjNdenRx2ymp3NkADW8cZoJnRKkG?= =?us-ascii?Q?j3f3kDIcnd3K7KqTHQxIOxeUsf/z03qshpX9IwKkxSeqy6W7LncyqqteQnFN?= =?us-ascii?Q?BrxQgW7ROEpDO6UdptBSvpaG+/0hBgrecZSabI1dQmfo3Ej7BHl2faHUXHX7?= =?us-ascii?Q?6Elu4beqcvjE6SgYPZkLFD3H8stSM00TjZ3REx45fvjKsVTNsmw25WpH5pRX?= =?us-ascii?Q?wIDVDYnYUMBi2yW3tsE2w+6Z6exqabUGgCPDlOIH0J+uuNJArC3agN36upD3?= =?us-ascii?Q?p1a2iYD/EQt6BenotpbMyRxXf9DwP1l8F1dKZSxQhoQ0UtSPloWxXX+48Rdq?= =?us-ascii?Q?IYHRcOyIWbUxj/5SkXve2nvnLNRchu3cumRN3D9ZUum6FXXXDDByNlS3ibKp?= =?us-ascii?Q?LHFCq8KL0tOu7uPbBsdengl9KtuhGE/iIU0kLcVHjGnsWluB3oqYnggPzW36?= =?us-ascii?Q?P+XoXZCBgrXG5Q4SyuLIuN1bSZYOEi8KJh6cabWzxpUe0pdMGBxeHiLAQh10?= =?us-ascii?Q?idFMLtNFZxD49x5aSu99PZeye/7Gy2s7MLu7sgFA4nF9PXvewRwym7vQzAbp?= =?us-ascii?Q?85A2xxO8cTUgz9h0AxnrWXTmTRpXNf7/IxX1DKaLXUrduheWO+1Q3j3eTWfJ?= =?us-ascii?Q?NEbJAc5EnnX4XVpWKPnxjBx67UmNWW+LHM6QmLCLb6hzjHqmCFRtFGIv3BsY?= =?us-ascii?Q?Q1uV2FHCMMHO8vKXfyspvUAnKszCAU7X09VIdKWCAdQjAY4PFJljttS3pfPQ?= =?us-ascii?Q?W9k9OtTRHoiJuRQdRhb3TenN0RrSG5qOvQC9atUQWwiC6kRCFJyPerhd2fDP?= =?us-ascii?Q?5g+n1jVr63oLNVg/e2QgYoM0+VbO39gurdR/Qd34d/5CMCLSPPh5SxpoISWu?= =?us-ascii?Q?uHEQg0wYk15smOS51cbgf8qrJx5lokn7zOSAldajk5BypHSlgjM03NxCzx03?= =?us-ascii?Q?aPshvDxd6OFHhVIguCwXXC/UdEQDEOSGUoZdRnhE9Vgx70BMeCKWVcbeaAUJ?= =?us-ascii?Q?pqSvWhATJQzqrFJ1F7T+FoGQKnGdKfa4Ja+HcjHNWVTGuVvLYIhi7Vnq1Wpd?= =?us-ascii?Q?C5oP0ofuPp21j7yYSEiZn/ICbUZM7DK0HttkmCb8t6cLo27EOuHJ0MQ4+g3i?= =?us-ascii?Q?uvgCzfWlHDHTuwLVMdaPN7nBnJbW19V0LHcpz+8kuJQex697uee2fD9FHXuz?= =?us-ascii?Q?UVPQNCD0ZzsFb+7w47aIpxdS3FwwgDyEoxuOyYW/tbWF0w15AIEjC600L4OU?= =?us-ascii?Q?opNbrgW1N2SIYl6dJlD81Lnib+HMRV5fsYte4Al1qUk8DPjJR+6Kabh5JdFE?= =?us-ascii?Q?Uu1VBa0aPGrScIYCIGQBy8O+NQ2a5Kvf2oTkmDubczG9KSgsckkU5TvLfAYT?= =?us-ascii?Q?R5fGfL8xJo4N/roNczrcI7cnN13rNoCUP51JOnaDHIDJeKkuIbZ3KiimsJK0?= =?us-ascii?Q?cm5G7z9TSkozTJGEDP9GeF7jnNMskowmi35dZjQp7SIGBf8BORf1hY4kEXU8?= =?us-ascii?Q?t7pB2hTyoNUrScv6ahL6uj50uu+gdn8/6XLuJr9EKNk760khr5JfBcpByHi5?= =?us-ascii?Q?rtYC4j5kcxLHZrZ5XrE6R8do/YaAt7XRN6wnsQmcusLf4KP5t0U52rOuzQOs?= =?us-ascii?Q?ZiSjsA7CJUyRrDikeWbQMZ7PzTIM34rDON9YNCPm9zFfXhZ18a5K5kZQB3vc?= =?us-ascii?Q?RmAJSyT73Q=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: dfff2869-5532-446c-09da-08da3e045fec X-MS-Exchange-CrossTenant-originalarrivaltime: 25 May 2022 04:09:33.6129 (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: EPBqKAcR40bBGJoC4VnOil9RFeX7qxIgx8rGMas23BR69AVEJp0f8+O+qqLu0jByYPS9CxdLG82z+tGc0/TTZw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1429 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: Wednesday, May 18, 2022 4:29 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 v2 2/4] raw/ifpga: remove vdev when ifpga is closed >=20 > Virtual devices created on ifpga raw device are not removed when ifpga is > closed. To avoid such problem, ifpga virtual device remove function is > implemented, virtual device is removed in raw device close function. The git message can be changed as below: Virtual devices created on ifpga raw device will not be removed when ifpga = 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 r= aw device closed. >=20 > Fixes: ef1e8ede3da5 ("raw/ifpga: add Intel FPGA bus rawdev driver") > Cc: stable@dpdk.org >=20 > Signed-off-by: Wei Huang > Acked-by: Tianfei Zhang > Acked-by: Rosen Xu > --- > 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..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]; > + int port; > }; can we use a common macro definition for this immediate value 8? >=20 > struct ifpga_rawdev * > -- > 1.8.3.1