From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f173.google.com (mail-wr0-f173.google.com [209.85.128.173]) by dpdk.org (Postfix) with ESMTP id DE1807D0B for ; Fri, 25 Aug 2017 18:08:23 +0200 (CEST) Received: by mail-wr0-f173.google.com with SMTP id a47so694126wra.4 for ; Fri, 25 Aug 2017 09:08: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=xjVYmK06KZPFgwKPYAvAYNlLQ3LhqxKZ7J3pHqiOZVs=; b=OWTHtOIXRKTEsfk00/79PfK2rx0+eonPQu/cIRMeeNdNPaC9Z8W3JkaNhMdRfS6Jq3 Z0B18rdZcvug4DnoO1svClpKo2iKB1S7xiVf+a/N0MDJvx0g9PaocQDpNTpn4NrwDQ6V N8mzvh7BXmhMqBAFKjgHyOZQj0I8G8r7qImmgc/BSiRu9pbNaXCfdx+jFxN90cgd/HvW 9MuIxSdURLL6/IZa1ZrAa3XhyrL1pQD4T6YiE+RyTek+Q1Y9cu0b6ySBhD/O3wk88Az+ v/Qr6dh8FyuxOKiu9aRkzvs8L2dE6Fr+S8XE44Gc2QOCq/fx8dUa3xaUssoX8+ua96Qc hSKQ== 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=xjVYmK06KZPFgwKPYAvAYNlLQ3LhqxKZ7J3pHqiOZVs=; b=SdlCsR7yOcg1n/sLWYYC/b1ElCoLYMJnmU1dXQ9/+k96W8wRlIWOQ7HVQxA0v856Rp Qi7M7ojt0E3yE1LED9muUkxefTYTHGDFTE1QU7M1EpxJkOmRsdguHc06aR+phd+6uwRf w7Q+d4srvx3uKvOJ6kvZvrROMN2nb8zumJ3vZlaPRDJhRTQUBEHwpLpW/Eua1P2oCAN2 dFpXmuFOidRX5CuCkWKSZuAcA0Vv4ZFaD9T+ESL3tBZi+2qqCdltXaCTLDGf+uoUhFJ+ +erVvebYoFyaqt8sNOzCJNVBihn1zbueXMAp/FFOTILVbXEjPmtvpDrTWYi66InRYkJ7 TD5A== X-Gm-Message-State: AHYfb5jujrJBqW3bUAXrDPCg6CTp7dByFQWpKZvR/YzK6+YLXt+cYPyh YwAr8nrg9P5vpXwiAHg= X-Received: by 10.223.131.197 with SMTP id 63mr6216264wre.161.1503677303125; Fri, 25 Aug 2017 09:08: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 h190sm1351661wmd.4.2017.08.25.09.08.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 Aug 2017 09:08:22 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Fri, 25 Aug 2017 18:07:21 +0200 Message-Id: <631f1a5f8efc5062c317e41199dc2ecb2b19c7c8.1503676587.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 1/6] devargs: introduce iterator 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, 25 Aug 2017 16:08:24 -0000 In preparation to making devargs_list private. Bus drivers generally need to access rte_devargs pertaining to their operations. This match is a common operation for bus drivers. Add a new accessor for the rte_devargs list. 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 | 18 ++++++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 39 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index aac6fd7..610db67 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -208,6 +208,7 @@ EXPERIMENTAL { global: rte_eal_devargs_insert; + rte_eal_devargs_next; rte_eal_devargs_parse; rte_eal_devargs_remove; rte_eal_hotplug_add; diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index 6ac88d6..e0e47e8 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -234,3 +234,22 @@ rte_eal_devargs_dump(FILE *f) devargs->name, devargs->args); } } + +/* bus-aware rte_devargs iterator. */ +struct rte_devargs * +rte_eal_devargs_next(const char *busname, const struct rte_devargs *start) +{ + struct rte_devargs *da; + + if (start != NULL) + da = TAILQ_NEXT(start, next); + else + da = TAILQ_FIRST(&devargs_list); + while (da != NULL) { + if (busname == NULL || + (strcmp(busname, da->bus->name) == 0)) + return da; + da = TAILQ_NEXT(da, next); + } + return NULL; +} diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h index 58d585d..226a082 100644 --- a/lib/librte_eal/common/include/rte_devargs.h +++ b/lib/librte_eal/common/include/rte_devargs.h @@ -215,6 +215,24 @@ rte_eal_devargs_type_count(enum rte_devtype devtype); */ void rte_eal_devargs_dump(FILE *f); +/** + * Find next rte_devargs matching the provided bus name. + * + * @param busname + * Limit the iteration to bus matching this name. + * Will return any next rte_devargs if NULL. + * + * @param start + * Starting iteration point. The iteration will start at + * the first rte_devargs if NULL. + * + * @return + * Next rte_devargs entry matching the requested bus, + * NULL if there is none. + */ +struct rte_devargs * +rte_eal_devargs_next(const char *busname, const struct rte_devargs *start); + #ifdef __cplusplus } #endif diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 5cfd934..c1bc704 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -214,6 +214,7 @@ EXPERIMENTAL { global: rte_eal_devargs_insert; + rte_eal_devargs_next; rte_eal_devargs_parse; rte_eal_devargs_remove; rte_eal_hotplug_add; -- 2.1.4