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 141C52C72 for ; Wed, 21 Jun 2017 01:36:25 +0200 (CEST) Received: by mail-wr0-f175.google.com with SMTP id 77so111605210wrb.1 for ; Tue, 20 Jun 2017 16:36:25 -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=X23fbcPptL5RtAz2FI5zecLX0On0+7x9wupXylkFqrQ=; b=qxM8P9PTwN3A/0yrJFS/BNRHk23n0wtdjbKRDJHg0vAB+oDE+zvdSBsd8VqliiaGvE X4vEOrUEhSl3gGRBrFifxrsaK49NxJBEy7wKOuTs2X3D4U7e8Si+JwwHYmgTdu80IFDc N1rrIyU8J+SpIF5+LL0RATSueXUbIY4PRxo5oBL5UILNl9xur757W/0VmxQH3PfOmRMC Nq0hf8EVUy1f2Visjy1SQWVwkpweFo4rTpsIsUOFBB1dHOaDrkoZH7WO63DeMgupGtG2 w+0vdRp9HUDC/XfeoKySeRTmuktGhyEb+ebZku+tkh0yx25krlngLwpCPKXq602lWdVi Vg5A== 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=X23fbcPptL5RtAz2FI5zecLX0On0+7x9wupXylkFqrQ=; b=W2dQxJZK8sMd773j8WcdD3atPKUEAyxGX8UqCu181tzQNzvKWy0Yz+MG/G+J9jLGfW 2zSgFn92KfBjjshudtRdzfjma+XZLFhxWryM5I3zguurA0ku6nW9Q9DwZ3bt7GwoozJ+ 8LdxFHuue1cQsjKMcn5oAauTBpiDWajLpb+tIan4ElhqUl7z2dzcehmhiQ2b34M5iDMY N3tEV5ri/4XS6yQ2wllgPr6eQT3/B7lS2P5moVs3i0HL4UYMT2C6qbX8DMratBhI4mv4 jvD8KzRrDDjQNDNU6bG37HCPRpQy0pIrsVgd9DKAuwzkMkuG6qwJFhmxPbQrgDFeI3I9 kl+A== X-Gm-Message-State: AKS2vOyrBFwhQ5omS8qEGF+HxeTp04khRkmfsrxHPS+QcT88fohHscWW ftiFZnlWOfYIPB7pWg0= X-Received: by 10.223.142.143 with SMTP id q15mr17561345wrb.180.1498001784493; Tue, 20 Jun 2017 16:36: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 f45sm6463684wrf.2.2017.06.20.16.36.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 16:36:23 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 21 Jun 2017 01:35:51 +0200 Message-Id: <274181cac46c610a8c9d10efd0fc17e5cd86c021.1498001626.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 v5 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: Tue, 20 Jun 2017 23:36:25 -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 f2e11f9..10009fa 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