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 32252A0505 for ; Tue, 29 Mar 2022 03:56:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1DE794114E; Tue, 29 Mar 2022 03:56:03 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 2865C4068E; Tue, 29 Mar 2022 03:55:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648518960; x=1680054960; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=BqHeK1hMr06HvCmfKrmVXXuGx5oNmbIgF5J7PNgawpk=; b=ckV/ETgl+uJGCx4Df+U2DkfBoqILIqaD60JnKjA1jzQJSBHAgNEtuoPc sq/l1kBfyFWbxOXrhzXJkQYS7WW0+lm5YLP8WUGDTBttSS21oFyTBaYsG yDkurkP0mp2dTWTjQdsbovEDL5J5XdqW/cfgS9xEpO5HF1OzdlDs+/xCi EIF3uQraq6ekeP8NxwWBqH6Q7M3xiAJEGENi+upkTdmhdYZLKgaiEswnc N+Pm/sjkePAX11NbREocyKSmQhQYtU0dReXLjKHr2Oa6l3id1dl++3qiO hx/Olp3x4pbclbyeW/DY+E+Sc1+NE4gB8fyqJI/ZyWf4ih59EJCBqiO0G w==; X-IronPort-AV: E=McAfee;i="6200,9189,10300"; a="259326695" X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="259326695" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 18:55:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="652535526" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga004.jf.intel.com with ESMTP; 28 Mar 2022 18:55:58 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) 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; Mon, 28 Mar 2022 18:55:57 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx607.amr.corp.intel.com (10.18.126.87) 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, 28 Mar 2022 18:55:57 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.44) 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.21; Mon, 28 Mar 2022 18:55:57 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UUgx4W1200DMC0p5mKVfV7uaW8WBtw3+hArigZudlVFDSKMlN+Wu2IfM7o7CbukP2dZkD5UyLWCSUlq395RxubovkClmE1TGkWj/Xo5MLJRn4/65zRTBAzexqZ/pOe9trQaGxSvO9qX7qCdMctalEioVdrHL4rR1p/J77YEwP+wsyB4JGwSWymUjzJghkmNV0v2F51Ly3WvorVezI037flZUpfoO7m280JMK4oH7CkzHfLigs57/avIZJMuFhxV5BnNKNSjhW9QmBJUpYkJ3dmz9py9/dbE0UHmBufZzReaQN3KCAxDNlH2cfEbUMA778gV84VvvDCPOL71z7cS+SA== 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=45s6qHItov7bldQOHLrpo2Q9rcYrvxxY42CklC6OGNU=; b=AJwBtNvSm47/1kk+UUPEQcndIT7RSTXmkhIiusA1FwsxpEI3N30myyna+Xy7/KYUvUEFLaci3m5Tm8W2hq+NnYWPInEpreOC6jK+xJqUH7n2ofsbAWR6i9C5efVLLog0KMEWvS4gZNyFBt3pwOXPL+JX7ykHHKRyersmIQHceBEf7am8KNstE04wgnM9Df3O3OiVBYYaEAg0ntLd48Hxe2E5mkvOkQaUsOqTHTd6WXRpzX9sO3TGv8Y4whI63sEEJBOKZjdTBnwh33aHB4mVdou3YyQ0sTOFvq5bmYKONYmNST3ldgPcvbKC3u8seOzbCiRNWpkwZhm0RAGzBtn+Cw== 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 DM6PR11MB3530.namprd11.prod.outlook.com (2603:10b6:5:72::19) by MW4PR11MB5824.namprd11.prod.outlook.com (2603:10b6:303:187::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Tue, 29 Mar 2022 01:55:53 +0000 Received: from DM6PR11MB3530.namprd11.prod.outlook.com ([fe80::5853:b0ff:380:7dd4]) by DM6PR11MB3530.namprd11.prod.outlook.com ([fe80::5853:b0ff:380:7dd4%2]) with mapi id 15.20.5102.023; Tue, 29 Mar 2022 01:55:53 +0000 From: "Huang, Wei" To: "dev@dpdk.org" , "thomas@monjalon.net" , "Xu, Rosen" , "nipun.gupta@nxp.com" , "hemant.agrawal@nxp.com" CC: "stable@dpdk.org" , "Zhang, Tianfei" , "Zhang, Qi Z" , "Yigit, Ferruh" Subject: RE: [PATCH v3] raw/ifpga: remove vdev when ifpga is closed Thread-Topic: [PATCH v3] raw/ifpga: remove vdev when ifpga is closed Thread-Index: AQHYOqbI72u8Ik1aO0e5YRnEPIgAl6zVqnjA Date: Tue, 29 Mar 2022 01:55:52 +0000 Message-ID: References: <20220315011755.1588005-1-wei.huang@intel.com> <20220318085755.2134030-1-wei.huang@intel.com> In-Reply-To: <20220318085755.2134030-1-wei.huang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.401.20 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: 9f74be67-80ac-453c-8dc5-08da112741c2 x-ms-traffictypediagnostic: MW4PR11MB5824:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,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: SDc0jwsCFfP5HEpahogibQGklGlW1JBnZhuVsdQ8NVdc+BZGYsFP34A6S7OJA0XooaPIHtdG6DcYQK3aBaZ/nexwef0pINizE50wL8M4DGK+gaIw8B+ofbhjakG+ZU8P9OUZTbAsUCGc6jYqUqyTbt8QXkOiRFDq1RuTN6ToCg7xwXAjbCdUjHpbLXtwangtPPpSuk0suCo+69w4MJkSXbVYGmRPqHQeTxeMp/5W+MFb68UGh63/gczW2F0u3us6m9aoHqFmWJ6XHMmAmXWMVIo2foB3uJNJxobUUGqOHpgPRL+n7yDE7xd1MKw30F5+2u6gqP+0AKbMy0xZtEqGMkCN3vI+VJ9uWdeMHbsfg9dJP23MlDmOpwz/QBZ2OTLCqTceHI6vXEBPygF+Ot025n3D53xy2H7U2ML+wE4kLLAyqW+apCoFcZlwkuOqA6ZhOdIIigzPscCbs6w4GEM46isL9G59SXTUOcyl2vaPa8USBb5fmxYZVnW6BOYtyIv6AwQJ90SXL9LTtIu4/fyAgHSpx4CsG/DmRZextZNcgBm4GxLNEqO25rvoT9XuGlGIYa4c7oSUVn2DHEwDhcgSkeVPShk1mZcrmYG/4xSx3krXDp56/CyqjXUjvjZrXhFwPLHljxVYQWzbi9dp3OtIZa2Ni29ttHQp7cpX9k8bsFzayWq/XqftKxajeJk6gktZXYA9jp0DwHEQ2NKnLzjU9Q== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB3530.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(8936002)(52536014)(316002)(107886003)(122000001)(66556008)(33656002)(53546011)(2906002)(6506007)(5660300002)(54906003)(64756008)(9686003)(38100700002)(66476007)(66446008)(66946007)(82960400001)(7696005)(83380400001)(55016003)(76116006)(38070700005)(86362001)(508600001)(110136005)(8676002)(71200400001)(186003)(26005)(4326008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Xy43B3slmaZhb04prgU8dEbXV3wpNuUyIDskDf1rzdA0+pZGzqaI/Dk9JXdM?= =?us-ascii?Q?a7PwsUnjHahHwRciQmBeey3yqPjxYTpWJoioKL6nbAuhVLsA2S1hzoBMzkQC?= =?us-ascii?Q?nKokBSy9vopaKybfGvra+wQVy6JQaJGUn+V8vebRVux1thWtQfZRHtqmOv/z?= =?us-ascii?Q?Ul376/cg0ty4dyy80nSAFXXppvAi5cT9FbF++ko/XM/7sWsFVaK70Rib+EtW?= =?us-ascii?Q?4Vl69Id7OibDTUhajsOVv/7HmccbJIlKU1tghk/RaX58811i8CSun0Fq/c5R?= =?us-ascii?Q?ZXxZzUcbsmfCAoCMadyN9YCZK+UW6Ah3/rW8Zpn49LmKVndim06d+XP/KT0K?= =?us-ascii?Q?/TU/TZGrrRWknyctAyGxnWwsEtrpeo7PT6Jr3xG6MNDfMeFPoGreocmaoXG8?= =?us-ascii?Q?3KqDInn3qNY4lXYdUk5uTRBL4N3C7Y/89HFshVfPxQzn+N4EXDzYcUgnq+MC?= =?us-ascii?Q?hplgyPwx/LBPZQsPBVYff0vfz0V6bPCXrONBnsqKrOicpGlBHrn8u+ueR3jm?= =?us-ascii?Q?mguMZgufxepDAZLehbVcrk5BO4YpEfV61k6kPQUk1xHCaYpJTsVpMftB7iMO?= =?us-ascii?Q?IWMfajy18EGBtxN1QDTPqBnKPsN9zYXKX4Tg48yl+nF4F/aMO+OZ0xuqAGQP?= =?us-ascii?Q?aHgyn4bSoapiOJpdQiwWq7VxJFjfyGJ27zEnTQPJGEcNiHmGkug3Z/W2etBm?= =?us-ascii?Q?cyh6HMaBZ2ueKe6lglTnlxU+BU25oiojli+CW2S1wtl0cPZujMI8UBoGvURw?= =?us-ascii?Q?Ymd5usI5m3dhq8xQOwDkIBQkw05CzJeZsZA+ozm+q1CdM9sEGeCX9gcIADlx?= =?us-ascii?Q?Wp51fDnIwaewdHkNpdRHWM7ix1cPzyePHpEpK/P6wKRELv84CHuVIf3wfi4g?= =?us-ascii?Q?eN54NRubWtXTzr9zmYYKtwfMQ9PuYEXMtv9M1Hl3nL8QsZImCtVmsAEBQInE?= =?us-ascii?Q?iVSkayi4KgOYrYRUAZAdqjr2WkVhFYvWGPNUZxo7wSJrCDuMTH2WZXufUg+F?= =?us-ascii?Q?jYaRk25wartHSwQ5Wk1Jv4bMygNW6rKZfDHF6QmwkAO/b49w6bF0C4f+Z7eU?= =?us-ascii?Q?Scb6Mr8Hx6Zlw82psJ3LSLcxSggS4xekVCgFi8E/TSB1eK3FIJ1x95KLb6UE?= =?us-ascii?Q?KyjrocsTltVPpoK2FeBHqlU6vSZn7IS0bzx38NfMY/JMWcnxLsMpAGcZ9VH8?= =?us-ascii?Q?LsyOUVTSV41Jzk2fLPt7+KfQ9tYwD/vOOKjHfjRGBk6QJo+n5av7FeWzayZu?= =?us-ascii?Q?NzJFcKNP5AhfGfgqi3b7xTFf1O+ZuxD+XXQ3W2hWl119wEuKBBObefqcy1lR?= =?us-ascii?Q?dXo2k0PK/sjmXr6+sNwcGF+E5QB+ZBTfTz2bD770HhiXqDt7p+p2flcxdd4U?= =?us-ascii?Q?ucDSofP2MsMbgkzcsXvd28qV1ODeKUf2bixF7yG3TbhuqVa+F0z73nQCehFv?= =?us-ascii?Q?8A61WXFeY9wCKZbmY6uOjsuQvkWrgllr8LIap+/MqXFNCxibUAGrXfLBRtn0?= =?us-ascii?Q?iW2rkW2KsdhQQFbAi/M4HqP28bH4StqOID6BwW30el1h7BiewIN7fu/vE4+9?= =?us-ascii?Q?FHP1bZyGs+2yhRxkBqEIVq1gJwQCD2w42bXwdP/TMhSsba4TVBZN8neNmPiE?= =?us-ascii?Q?Yx4amft3S0beLqvzllFENwVdjHfdQWV82rsawf0Zyj49OmBrj1UO6VGJG8V3?= =?us-ascii?Q?axm+hbh1KDLIcmGZDnjLT30V3/8eQjtNiLCYQ3XGL3vGx0CkwZlUbqC1d8aI?= =?us-ascii?Q?NDD45oLXLg=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: DM6PR11MB3530.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f74be67-80ac-453c-8dc5-08da112741c2 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Mar 2022 01:55:52.9762 (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: a7eEG9+Ok3s/80b5kAw5Xae0qhCancGYg4ssJ+2+9ccHbKX/O2ENdB2PtrjWxj34h6N27JqpzmHvJHfreN7xUQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB5824 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 Thomas, Would you please check this patch is acceptable ? > -----Original Message----- > From: Huang, Wei > Sent: Friday, March 18, 2022 16:58 > To: dev@dpdk.org; thomas@monjalon.net; Xu, Rosen > ; nipun.gupta@nxp.com; hemant.agrawal@nxp.com > Cc: stable@dpdk.org; Zhang, Tianfei ; Zhang, Qi = Z > ; Yigit, Ferruh ; Huang, We= i > > Subject: [PATCH v3] 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. >=20 > Signed-off-by: Wei Huang > Acked-by: Tianfei Zhang > Acked-by: Rosen Xu > --- > v2: cleanup vdev_name no matter rte_vdev_uninit succeed or not > --- > v3: cleanup vdev_name in ifpga_cfg_remove > --- > 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]; > + int port; > }; >=20 > struct ifpga_rawdev * > -- > 1.8.3.1