From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by dpdk.org (Postfix) with ESMTP id AA8797CE7 for ; Wed, 5 Jul 2017 01:57:24 +0200 (CEST) Received: by mail-wm0-f41.google.com with SMTP id w126so207224694wme.0 for ; Tue, 04 Jul 2017 16:57:24 -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=YFIPTzNIX3Xfpx0CxvzqWWN4ZFj/l8gmD8qGeEw+vzI=; b=12JU5zRBiIvc/vgwZbN9qMMVHrGAw2OdrwOpimz8GzCqblWoK9eO7VhGk/VhPTtpPL L+p/jxy/1f+rt9vfELDIdL7+sHnxqOCyxKA8vUvBRvHq/UXKsuh3VBlIAA1ufQRX8Zn4 uhG+KTTdvIaUOo2wLVop7W8SfYvEokNDTQvCG2KB6TgB3fNfwR2lllOvYYpZAmBnejAq 2z61grLVLXdoUzKskpohlZ4bZQLsyeN3T7+uByXerv/b0SVZLBLJhN1exI6+MtbdCxxd PKSrBUEsJuLg0Fen3ToGWyeiVas1E1UPdV6v4ChjzphXJcAjCatbNDrAEiQbCGYLst+d rDDA== 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=YFIPTzNIX3Xfpx0CxvzqWWN4ZFj/l8gmD8qGeEw+vzI=; b=qw+9b8I1LL8DkjqmzNWEfyc/FTO7nXXwQfs0C/RprYdlQApCnVsx9DNxIL6y61Vl5Y oXWWctI8uKnk18zCGObwSiry0X69WogGJTYpB9aLepbpWuUnYVTq3Nffw8Gng3aOeYRI DtthFyrl4o6+uBMk3QKLyg1rCI3Cfzm4Y7x4VQTCmrMiBydFMxMelgybBThZik1gIEEt J4t18PbTsBbO+CYDo5wwjg5Z+iifW+Hu9C54Gqqj6x6VCZXa32K5kFROclaBCS7MbSEi O9SUAgNTwjrpwvijAN7D0hUpNJ+ObQ9RQTn3wUmbKXL6ZKWK/VWFj8YCh3IsHXAEM40+ A7tA== X-Gm-Message-State: AIVw111nAFl+24igxyUQ0IY9gjzFl/1Y0DfTGr2jrAUhhFwFTNNR+9u4 x52zTVa16r6VUa4vhCg= X-Received: by 10.28.184.87 with SMTP id i84mr11854444wmf.22.1499212644018; Tue, 04 Jul 2017 16:57:24 -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 w197sm27273899wme.20.2017.07.04.16.57.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Jul 2017 16:57:23 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 5 Jul 2017 01:56:48 +0200 Message-Id: <9bd5ff9991daa419ce3479bbaa15c3d50561b201.1499211959.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 18/19] devargs: remove 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: Tue, 04 Jul 2017 23:57:25 -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 | 19 +++++++++++++++++++ lib/librte_eal/common/include/rte_devargs.h | 14 ++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 35 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 05e2475..299b27f 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -202,6 +202,7 @@ DPDK_17.08 { rte_bus_find_by_name; rte_eal_devargs_clone; rte_eal_devargs_parse; + rte_eal_devargs_rmv; } DPDK_17.05; diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index be8951d..7388122 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,24 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) return -1; } +/* Remove and free an rte_devargs. */ +int +rte_eal_devargs_rmv(struct rte_devargs *da) +{ + struct rte_devargs *d; + void *tmp; + + TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) { + if (d == da) { + TAILQ_REMOVE(&devargs_list, d, next); + free(d->args); + free(d); + return 0; + } + } + return 1; +} + /* Deep-copy of an rte_devargs. */ struct rte_devargs * rte_eal_devargs_clone(struct rte_devargs *da) diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h index 892b035..f61707c 100644 --- a/lib/librte_eal/common/include/rte_devargs.h +++ b/lib/librte_eal/common/include/rte_devargs.h @@ -163,6 +163,20 @@ 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. + * The devargs is then freed. + * + * @param da + * 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(struct rte_devargs *da); + +/** * Deep copy an rte_devargs. * * @param da diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index e9ae497..6d73e0e 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -207,6 +207,7 @@ DPDK_17.08 { rte_bus_find_by_name; rte_eal_devargs_clone; rte_eal_devargs_parse; + rte_eal_devargs_rmv; } DPDK_17.05; -- 2.1.4