From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f175.google.com (mail-wr0-f175.google.com [209.85.128.175]) by dpdk.org (Postfix) with ESMTP id 4886837B4 for ; Fri, 7 Jul 2017 02:09:59 +0200 (CEST) Received: by mail-wr0-f175.google.com with SMTP id r103so24419946wrb.0 for ; Thu, 06 Jul 2017 17:09:59 -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=MTYGxBa1BlxXxo2r1bGuF6yVUKPCq0EGTTjSh981H2c=; b=q0B5st4fzWclYJRbPyWWYjzpP+RJuQcSdvCPu/XsZK5488Fl35gU6I+Hn4COAN5cqB zFqtzGRXe3NAb0Zu0DEtbh9dCI0v6AVsWQsJw005BY9YIps6+qhhvcHv88X7w8BPuLbb 7Z488NxNScqzbpQRq0yigtwiw4KiJlMQehJDGyxzGUcfAFhou/17c2Mc5wHUcix9KZ54 /9m+OEzaHPvhKJwMJItvaK9x2fOQq6gSQG8JyM5xPT0oIvYllqh7V10ZKVyGC3dlhuJO EA51vXiSqN5neczYU69RNAT89xKBLfEh2H3jqxdygIDYYoGvcaKT25oU2vk0e8cdryok AKMA== 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=MTYGxBa1BlxXxo2r1bGuF6yVUKPCq0EGTTjSh981H2c=; b=Jzbbc16MKy+HaBUVEBvt/Q0KRITXifSI6nUemK2xaPu8AEu/a3LrVjwG5gWSh1O2Rt E5nsSghT5nxwFhz4H7glu84wqQnEoBLmwT/q7/qd1N0mXWdEnMnC242QYTj8BLGBzju/ 3OI/Z+U44BOTUpSK7/pV0oMAtIyYouyrjvjw5apH09pVcbNv9drGl98suKqFptDOjv0a 23NIwYuCGWxrXsoNApMyoWQ1lDSX9bwwLCsqMzLW6ooo5/u00GQr+zeJEpLiYzwKAUmz eTTdVH2bKDOmeJjn21FfR035pbm2VWZ2R+qWQtMOGoPOWljGGmjeElF9m6m1JOuklc5C zo/w== X-Gm-Message-State: AIVw113qaleOSXL2aQnPj5qV1LXvG1pJpwHiR2JDYMrAWhzZKUBSGHH3 iLZrY3O5Q5RCzPQWu4g= X-Received: by 10.28.66.153 with SMTP id k25mr261582wmi.129.1499386198615; Thu, 06 Jul 2017 17:09:58 -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 f45sm2391166wrf.2.2017.07.06.17.09.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Jul 2017 17:09:57 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Fri, 7 Jul 2017 02:09:10 +0200 Message-Id: <03f08f23012c00840935e9ed248d0e02e742d9d1.1499385282.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 v6 03/22] 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: , X-List-Received-Date: Fri, 07 Jul 2017 00:09:59 -0000 Hotplug support introduces the possibility of removing devices from the system. Allocated resources must be freed. Signed-off-by: Gaetan Rivet --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_devargs.c | 18 ++++++++++++++++++ lib/librte_eal/common/include/rte_devargs.h | 18 ++++++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 38 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..d3cf1ae 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_rmv; 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 3ea070d..2f29e89 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 */ @@ -185,6 +186,23 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) return -1; } +int +rte_eal_devargs_rmv(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 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..89679bb 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_rmv(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..d59308a 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_rmv; rte_eal_hotplug_add; rte_eal_hotplug_remove; -- 2.1.4