From patchwork Tue Jul 11 23:25:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 26833 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id CB4B17CF5; Wed, 12 Jul 2017 01:26:14 +0200 (CEST) Received: from mail-wr0-f178.google.com (mail-wr0-f178.google.com [209.85.128.178]) by dpdk.org (Postfix) with ESMTP id AA1A67CC6 for ; Wed, 12 Jul 2017 01:26:00 +0200 (CEST) Received: by mail-wr0-f178.google.com with SMTP id k67so9800021wrc.2 for ; Tue, 11 Jul 2017 16:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=wFexy0TjWuZJ6peWbD+EhxRdp9oO55b6+FeG+BFq+VM=; b=QZ3nEq98wz9OcoDeu/4sl/0ODGhgtd36HuIXGBRPCZ3il4U3BC9bWHSjoeqA6pyOi0 CBX5PP6OKREz3ug0cgH+GBt/M68g4I+1ZN90NP4Mkc3OkC9ju+tRu54RvGNMVayf2jF7 DBqnVx/D2Stf15uoBJXeGBDWGOIiIze9T8rBZWjHnxJ++a0PUnr2ld+9cIJ3M74LsMvX 7iEeOVU4h7O+/fOoOL13RmNjhYDGjhbirmDtQ0utV+nTCRrfiRMLpR0PHNk6LJpBY5Nu 3BzPTFLZTji35Iwu45/0MvBfAXO8GIuKaQskNHbAWnpLcrw4VEwLzfETcxXSwaAHyukQ kHyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=wFexy0TjWuZJ6peWbD+EhxRdp9oO55b6+FeG+BFq+VM=; b=Ph0GaZuXfPGCEK1DjqwaLldFfrv1X3CMzDK+JpHCqsjc/wGe0M8CY+kz8wXxuZMjI5 n54VMmol9NhQrjokS+XCAG2kOyMdOHs14EA5c6BPkuqhDK+845+xQrz6A2+xZOnGuP8C RA2zBP6fguj4ctVP8k+/50uBTSQeNuGt9ix48uGOjlSxypRLcPLczSu9gChh9ztYQ5h+ ElSpdqBeAv74Gq5hEGev2BoU8DvSLBCVHiN3Xn4VjH/44qlDFOE+lAbDWyEXGaEn8fct JNxpaBvQCn+3zAPxOP6IZCdx2C4eeTWsTyUnwhj7Z7i5gtMhoIJBANQk792glnFm7Elc x/Yw== X-Gm-Message-State: AIVw110QXDbBdoL+W5sMXTfJ5PZeKsd4CBt7RctZdmuIag6qMsIJQDCe Be7HFn7SzY+c/ZKt5QM= X-Received: by 10.28.213.205 with SMTP id m196mr380985wmg.109.1499815559898; Tue, 11 Jul 2017 16:25:59 -0700 (PDT) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id 66sm407576wmj.29.2017.07.11.16.25.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Jul 2017 16:25:59 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 12 Jul 2017 01:25:36 +0200 Message-Id: <7d819b3f9666620afa3324e47de7698a7e203328.1499814957.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 2/8] devargs: introduce removal function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hotplug support introduces the possibility of removing devices from the system. Allocated resources must be freed. Extend the rte_devargs API to allow freeing allocated resources. This API is experimental and bound to change. It is currently designed as a symetrical to rte_eal_devargs_add(), but the latter will evolve shortly anyway. Its DEVTYPE parameter is currently only used to specify scan policies, and those will evolve in the next release. This evolution should rationalize the rte_devargs API. As such, the proposed API here is not the most convenient, but is taylored to follow the current design and integrate easily with its main use within rte_eal_hotplug_* functions. Signed-off-by: Gaetan Rivet --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_devargs.c | 19 +++++++++++++++++++ lib/librte_eal/common/include/rte_devargs.h | 18 ++++++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 39 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 381f895..40cd523 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -207,6 +207,7 @@ EXPERIMENTAL { global: rte_eal_devargs_parse; + rte_eal_devargs_remove; rte_eal_hotplug_add; rte_eal_hotplug_remove; diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index 49d43a3..bcdee13 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -41,6 +41,7 @@ #include #include +#include #include "eal_private.h" /** Global list of user devices */ @@ -182,6 +183,24 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) return -1; } +int +rte_eal_devargs_remove(const char *busname, const char *devname) +{ + struct rte_devargs *d; + void *tmp; + + TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) { + if (strcmp(d->bus->name, busname) == 0 && + strcmp(d->name, devname) == 0) { + TAILQ_REMOVE(&devargs_list, d, next); + free(d->args); + free(d); + return 0; + } + } + return 1; +} + /* count the number of devices of a specified type */ unsigned int rte_eal_devargs_type_count(enum rte_devtype devtype) diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h index a0427cd..36453b6 100644 --- a/lib/librte_eal/common/include/rte_devargs.h +++ b/lib/librte_eal/common/include/rte_devargs.h @@ -163,6 +163,24 @@ rte_eal_devargs_parse(const char *dev, int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str); /** + * Remove a device from the user device list. + * Its resources are freed. + * If the devargs cannot be found, nothing happens. + * + * @param busname + * bus name of the devargs to remove. + * + * @param devname + * device name of the devargs to remove. + * + * @return + * 0 on success. + * <0 on error. + * >0 if the devargs was not within the user device list. + */ +int rte_eal_devargs_remove(const char *busname, const char *devname); + +/** * Count the number of user devices of a specified type * * @param devtype diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 0f9e009..a8ee349 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -212,6 +212,7 @@ EXPERIMENTAL { global: rte_eal_devargs_parse; + rte_eal_devargs_remove; rte_eal_hotplug_add; rte_eal_hotplug_remove;