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 C36C441E77 for ; Fri, 17 Mar 2023 02:44:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B8E7542F9E; Fri, 17 Mar 2023 02:44:01 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 2B08B42F90; Fri, 17 Mar 2023 02:43:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679017439; x=1710553439; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=2g1vsUiAG4xqDUc4mGJMH2Nr2EI87tWbV9CkSLFYpYI=; b=JIKISCG9/3zY+uJNIZHfOxMZAYYS24dtucb4MWS6bBOxgeQRHKwdN+yW AjeXzOSpVLbh3BEymSsTLeNz94f6/4dxy/ogXycEUo6Fq1wl5IMt4RkkJ tzmN+x4dMuuKTTKaNqxHnAa2e120WmrILbfLvu5T7F/4TsN0iKRwau0Y3 6/1jguUPSjhlybh3ujZnCOnqUHsDDUgIrcZknB+kIvSKEYkMS7P1hfnlo cMqfzJhgPNF2xaTId2zmN3RatyvGJSHm6jWvMFvGgYzMpFeOJwjUZsw2a lieGEktJhN+bPECauRQX7aUW1ZSnTo2k+CfrGMw3uz3nf6d6EL3kFw8nP g==; X-IronPort-AV: E=McAfee;i="6600,9927,10651"; a="326522096" X-IronPort-AV: E=Sophos;i="5.98,267,1673942400"; d="scan'208";a="326522096" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2023 18:43:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10651"; a="630117928" X-IronPort-AV: E=Sophos;i="5.98,267,1673942400"; d="scan'208";a="630117928" Received: from sh_lab5_1.sh.intel.com (HELO ocsbesrhlrepo01.sh.intel.com) ([10.238.175.110]) by orsmga003.jf.intel.com with ESMTP; 16 Mar 2023 18:43:43 -0700 From: Wei Huang To: dev@dpdk.org, thomas@monjalon.net, david.marchand@redhat.com Cc: stable@dpdk.org, rosen.xu@intel.com, tianfei.zhang@intel.com, qi.z.zhang@intel.com, Wei Huang Subject: [PATCH v1] raw/ifpga: remove virtual device unplug operation Date: Thu, 16 Mar 2023 16:44:45 -0400 Message-Id: <20230316204445.360330-1-wei.huang@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 VDEV bus has implemented cleanup() function to perform cleanup for devices on the bus during eal_cleanup(), so there is no need for ifpga driver to record virtual devices and unplug them. Signed-off-by: Wei Huang --- drivers/raw/ifpga/ifpga_rawdev.c | 99 ++++------------------------------------ drivers/raw/ifpga/ifpga_rawdev.h | 2 - 2 files changed, 9 insertions(+), 92 deletions(-) diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c index 1020adc..8e6e70f 100644 --- a/drivers/raw/ifpga/ifpga_rawdev.c +++ b/drivers/raw/ifpga/ifpga_rawdev.c @@ -140,8 +140,6 @@ struct ifpga_rawdev * for (i = 0; i < IFPGA_MAX_IRQ; i++) dev->intr_handle[i] = NULL; dev->poll_enabled = 0; - for (i = 0; i < IFPGA_MAX_VDEV; i++) - dev->vdev_name[i] = NULL; return dev; } @@ -749,17 +747,11 @@ static int set_surprise_link_check_aer( struct ifpga_rawdev *ifpga_rdev = NULL; struct opae_adapter *adapter; struct opae_manager *mgr; - char *vdev_name = NULL; - int i, ret = 0; + int ret = 0; if (dev) { ifpga_rdev = ifpga_rawdev_get(dev); if (ifpga_rdev) { - for (i = 0; i < IFPGA_MAX_VDEV; i++) { - vdev_name = ifpga_rdev->vdev_name[i]; - if (vdev_name) - rte_vdev_uninit(vdev_name); - } ifpga_monitor_stop_func(ifpga_rdev); ifpga_rdev->rawdev = NULL; } @@ -1778,104 +1770,31 @@ static int ifpga_rawdev_get_string_arg(const char *key __rte_unused, static int ifpga_cfg_probe(struct rte_vdev_device *vdev) { - struct rte_rawdev *rawdev = NULL; - struct ifpga_rawdev *ifpga_dev; struct ifpga_vdev_args args; char dev_name[RTE_RAWDEV_NAME_MAX_LEN]; - const char *vdev_name = NULL; - int i, n, ret = 0; - - vdev_name = rte_vdev_device_name(vdev); - if (!vdev_name) - return -EINVAL; + int ret = 0; - IFPGA_RAWDEV_PMD_INFO("probe ifpga virtual device %s", vdev_name); + IFPGA_RAWDEV_PMD_INFO("probe ifpga virtual device %s", + rte_vdev_device_name(vdev)); ret = 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 = rte_rawdev_pmd_get_named_dev(dev_name); - if (!rawdev) - return -ENODEV; - ifpga_dev = ifpga_rawdev_get(rawdev); - if (!ifpga_dev) - return -ENODEV; - - for (i = 0; i < IFPGA_MAX_VDEV; i++) { - if (ifpga_dev->vdev_name[i] == NULL) { - n = strlen(vdev_name) + 1; - ifpga_dev->vdev_name[i] = rte_malloc(NULL, n, 0); - if (ifpga_dev->vdev_name[i] == NULL) - return -ENOMEM; - strlcpy(ifpga_dev->vdev_name[i], vdev_name, n); - break; - } - } - - if (i >= 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 = rte_eal_hotplug_add(RTE_STR(IFPGA_BUS_NAME), - dev_name, vdev->device.devargs->args); - if (ret) { - rte_free(ifpga_dev->vdev_name[i]); - ifpga_dev->vdev_name[i] = NULL; - } - - return ret; + return rte_eal_hotplug_add(RTE_STR(IFPGA_BUS_NAME), dev_name, + vdev->device.devargs->args); } static int ifpga_cfg_remove(struct rte_vdev_device *vdev) { - struct rte_rawdev *rawdev = NULL; - struct ifpga_rawdev *ifpga_dev; - struct ifpga_vdev_args args; - char dev_name[RTE_RAWDEV_NAME_MAX_LEN]; - const char *vdev_name = NULL; - char *tmp_vdev = NULL; - int i, ret = 0; - - vdev_name = rte_vdev_device_name(vdev); - if (!vdev_name) - return -EINVAL; + IFPGA_RAWDEV_PMD_INFO("remove ifpga virtual device %s", + rte_vdev_device_name(vdev)); - IFPGA_RAWDEV_PMD_INFO("remove ifpga virtual device %s", vdev_name); - - ret = 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 = rte_rawdev_pmd_get_named_dev(dev_name); - if (!rawdev) - return -ENODEV; - ifpga_dev = ifpga_rawdev_get(rawdev); - if (!ifpga_dev) - return -ENODEV; - - snprintf(dev_name, RTE_RAWDEV_NAME_MAX_LEN, "%d|%s", - args.port, args.bdf); - ret = rte_eal_hotplug_remove(RTE_STR(IFPGA_BUS_NAME), dev_name); - - for (i = 0; i < IFPGA_MAX_VDEV; i++) { - tmp_vdev = ifpga_dev->vdev_name[i]; - if (tmp_vdev && !strcmp(tmp_vdev, vdev_name)) { - free(tmp_vdev); - ifpga_dev->vdev_name[i] = NULL; - break; - } - } - - return ret; + return 0; } static struct rte_vdev_driver ifpga_cfg_driver = { diff --git a/drivers/raw/ifpga/ifpga_rawdev.h b/drivers/raw/ifpga/ifpga_rawdev.h index 0fb66cb..1c128c7 100644 --- a/drivers/raw/ifpga/ifpga_rawdev.h +++ b/drivers/raw/ifpga/ifpga_rawdev.h @@ -65,8 +65,6 @@ 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 { -- 1.8.3.1