From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f180.google.com (mail-wr0-f180.google.com [209.85.128.180]) by dpdk.org (Postfix) with ESMTP id E1A5D7CD6 for ; Thu, 8 Jun 2017 01:57:39 +0200 (CEST) Received: by mail-wr0-f180.google.com with SMTP id g76so11985762wrd.1 for ; Wed, 07 Jun 2017 16:57:39 -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=7Wo4WIiqdw18jiaGiPNUlBohQFkSvWp/yY7h8dTnxFA=; b=VBG9idqoa5i5QVWshKYIvnsPO84DPTe5yU41VszNdJgJ89t+SW/npQqm8TIK99+3jC 7CnfR7SRZo/gLUL2Tt1l2M4mjJmH2ggHBIWxIQDg4yfi/Cq33xP6Up5Ucw78A2oOAyFz JA9+kINEhlU997lSdnnNkSivCw8IQ1un0OxFupCFlKQc+l3qwMa9j/kx1cVDdUAvObza qWNAkd/n14Qb4q+ajfUI7rgpSKwuELiS52GPGqjOqbxJDWCz14xDNJG/A8RqHgiv5LMV V5bcUlGuCCVLYOlRxWi/brnbvJprzdyeys2e8YVMW/zbOW5ZIy8MIFdgdDaK0+tpvuN1 HVCw== 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=7Wo4WIiqdw18jiaGiPNUlBohQFkSvWp/yY7h8dTnxFA=; b=FrBn1N6eNESwRiDWQinNJ8iI7HFzyulh6yWEDKjHjj3lkjRCbIPCANsGLrGkzUMWz9 2h1s0HRW+Bzqxm/lwxWNRki4yIixbLor26JZsg29dMiWD0UCs78Qrp0tKrZ9FEKU/pGb SiDT8yKCsrKCcd6qBOLXVxU2ps0YVyND7yUOKBx0QW9CPY3wU1Qw8LYzZpYtvLMtyssp YRiDZIQZl0lsa86UTqGcX2ZS45dJKaVdZGzCtBagEcI6qjXkxAYwYc46xWHrh4VaRoAY eqwnp/8xG9LOqRN2G0U9YCyD7cAj8lk2lyj+H5FV7KZaALfk9MPfgmHzLVLMoxTFfrs2 +mWQ== X-Gm-Message-State: AODbwcBQybWeD5c8/jXjEmDI1XwxvGGfRWsz5/NzFtQe5wrhSk/N2l+k /1o8/ggI27Hz4ncRQIA= X-Received: by 10.223.155.141 with SMTP id d13mr16786217wrc.117.1496879859298; Wed, 07 Jun 2017 16:57:39 -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 185sm22397056wmp.1.2017.06.07.16.57.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jun 2017 16:57:38 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 8 Jun 2017 01:57:03 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v4 17/19] devargs: clone 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: Wed, 07 Jun 2017 23:57:40 -0000 This function returns a deep copy of an rte_devargs. Signed-off-by: Gaetan Rivet --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_devargs.c | 20 ++++++++++++++++++++ lib/librte_eal/common/include/rte_devargs.h | 12 ++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 34 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 04fa882..a506968 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -203,5 +203,6 @@ DPDK_17.08 { rte_bus_from_name; rte_bus_from_dev; + rte_eal_devargs_clone; } DPDK_17.05; diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index b69a2b2..07b89ef 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,25 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) return -1; } +/* Deep-copy of an rte_devargs. */ +struct rte_devargs * +rte_eal_devargs_clone(struct rte_devargs *da) +{ + struct rte_devargs *clone; + + clone = calloc(1, sizeof(*clone)); + if (clone == NULL) + return NULL; + snprintf(clone->name, sizeof(clone->name), "%s", da->name); + clone->args = strdup(da->args ? da->args : ""); + clone->bus = da->bus; + if (clone->args == NULL) { + free(clone); + return NULL; + } + return clone; +} + /* 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 2ab8864..892b035 100644 --- a/lib/librte_eal/common/include/rte_devargs.h +++ b/lib/librte_eal/common/include/rte_devargs.h @@ -163,6 +163,18 @@ rte_eal_devargs_parse(const char *dev, int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str); /** + * Deep copy an rte_devargs. + * + * @param da + * Source devargs. + * + * @return + * The pointer to the new rte_devargs on success. + * NULL on error. + */ +struct rte_devargs *rte_eal_devargs_clone(struct rte_devargs *da); + +/** * 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 a5127d6..6e6638a 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -207,5 +207,6 @@ DPDK_17.08 { rte_bus_from_name; rte_bus_from_dev; + rte_eal_devargs_clone; } DPDK_17.05; -- 2.1.4