From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f169.google.com (mail-wr0-f169.google.com [209.85.128.169]) by dpdk.org (Postfix) with ESMTP id D09B54BE1 for ; Wed, 5 Jul 2017 01:57:23 +0200 (CEST) Received: by mail-wr0-f169.google.com with SMTP id 77so255078166wrb.1 for ; Tue, 04 Jul 2017 16:57:23 -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=SjVGk2N4btFH++NEnjcBrtpfw778ixLbv2QPS/easMc=; b=0H+8227U0gR3xAF5JYz7Dfdge8Wq1K4WHILWNdbcENqPH6ANgIO3G7TnWA1vGE/3Cs TP8K5koa+w/r7s/as0jDBYEtnXd9NNhcUUOoulSl3Tf4xaR0d/SBFNpZWgY+7MOZvp2R L5bSRYncup0R1tZCOH7PXjxw4RT0ecIkPKnXu3UbqucEVGLs6IXLc1BNoZFG5Hegl869 hC2cNjZ9TDYP6P2YNE6VudBSe+d2TAVG4BRHTqW6f1qhZxIYyH7pPPKdxSkbO4K7X05i EOsWfUOEIenXi6vBPXRQnh01XU4dJOcM+CPO7/iN+UgLD3L17K3OJ5zahaxDBKx1ok2A t3Gg== 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=SjVGk2N4btFH++NEnjcBrtpfw778ixLbv2QPS/easMc=; b=ILIUNYNaCANS0GDQhR3t1T2Xrjqt7bpj/ZtScN1Rc+gXzj3OytziwtHswAutbRt2T5 k2kemajYEqcMwxwuO/f9CP68RAXU7cTh7wPLh5yNuoD6UsTf6LSye3Ky760TZMrIf78T /tCIjgAXldj1qViuFbh9YeM5k5Hf+wgMyLQ/+MnoovNZ6/Vu/SgmX69XE8up0bBnGhP8 uoml88UCSwaKGLecgNlRIOJDrx14CWOXql2WBbqpJXV5cIIPBkiRf3i1dtH86UmtzT53 tFIowAf7HVlGzUpmA2v+Kbcl1sQbGR6oYZzH/SsIp912YziMNsntS8hf6GGj4/kWtBCH KW4g== X-Gm-Message-State: AKS2vOy5dyWw7IHpP07clg0ZSpIMN7qsiQ8ZnjfRnsdmXndPbL2gSflK I1eaupalsogmOjEL+O0= X-Received: by 10.223.169.145 with SMTP id b17mr23081932wrd.179.1499212643061; Tue, 04 Jul 2017 16:57:23 -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.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Jul 2017 16:57:22 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 5 Jul 2017 01:56:47 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v6 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, 04 Jul 2017 23:57:24 -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 | 19 +++++++++++++++++++ lib/librte_eal/common/include/rte_devargs.h | 12 ++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 33 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index cec3894..05e2475 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -200,6 +200,7 @@ DPDK_17.08 { rte_bus_find; rte_bus_find_by_device; rte_bus_find_by_name; + rte_eal_devargs_clone; rte_eal_devargs_parse; } DPDK_17.05; diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index 3ea070d..be8951d 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -185,6 +185,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 09b875a..e9ae497 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -205,6 +205,7 @@ DPDK_17.08 { rte_bus_find; rte_bus_find_by_device; rte_bus_find_by_name; + rte_eal_devargs_clone; rte_eal_devargs_parse; } DPDK_17.05; -- 2.1.4