From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by dpdk.org (Postfix) with ESMTP id E71BF187 for ; Tue, 24 Apr 2018 01:55:15 +0200 (CEST) Received: by mail-wr0-f196.google.com with SMTP id p5-v6so17953842wre.12 for ; Mon, 23 Apr 2018 16:55:15 -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=NXzeh4IPdp2ddvdN9jydShStWgkIsO74co6K94nyP/w=; b=u3/XImiXjM+6bnxgnO+zRS9hnvD4bYRsKYWL9Q+PimNd6g9zwI3Aid9veHG/tBpQ6r 6CYXWPLeOEuv2mJjszpShzT0vZjDbfi4EntJ1GJkfFxTZ78ynCV7tmGbJNaMj1YooalG YncFzNi8jIHFwgsj5zcZ5jcxECrIGn7ahdFBubx3TwW7Zc6mNqN9FdSXtSQiVOH9Ptke CgFxNWxb+YP/1STWBlyZZVfusLwV1RBu+MwZisg9rncctrLASzigXxgpEqcIi5qIvuol Q40VqWgkc767LmZ54Hilyk//km1JAp2i45+rAgIGn4IRLuzYp4HnRzrzY+rwI2c5ugMO uC8A== 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=NXzeh4IPdp2ddvdN9jydShStWgkIsO74co6K94nyP/w=; b=ten9/6g5SGjS5GbW/kHBrS1Z8lzripuJ2bHD4ouDoASXGwNhafVeRjprWnkB9Ke71V 84Mv5kGBvBE+UDUAwXshi2Z5KJ4jI8fy2XYympvb7yHWor1HBuUrS13dY9E71vwtVETj dXz3loJxPFxouNOL00XnYEuGmTvdJf3kiP2lugM3pG+YFSIWpxEzG03icq10wn0NRusS MwxM3AtjDvYd1ncOB9uxCg/gF5gAWJPpHkGY45pvNTXEWvdNIHcBKg5CswQH/JCKQBR9 NGOS/UToTxOrjyBAUeMNlDq0+h+u0U0b8rQXTeF2Ky9XMmwaYCsiIU6EOcKeDjozbFts CzNw== X-Gm-Message-State: ALQs6tB1rX6drP99MXfTER1WZPHDfoP9aZqtHNnquY9al/y92wducMr4 oSHgsC1OFYdnr22//r5A/dFQpgYE X-Google-Smtp-Source: AIpwx49UTstNN/tG6KwLh4Pb60md/tiBuNhx+KOLxWtfACZH7vFbrXO7Izp3cvNSvCyj/mq67uYWWg== X-Received: by 2002:adf:8584:: with SMTP id 4-v6mr19351426wrt.15.1524527715273; Mon, 23 Apr 2018 16:55:15 -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 55-v6sm28922279wrw.52.2018.04.23.16.55.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 16:55:14 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Tue, 24 Apr 2018 01:54:43 +0200 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v5 01/10] 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: Mon, 23 Apr 2018 23:55:16 -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 Acked-by: Thomas Monjalon --- lib/librte_eal/common/eal_common_devargs.c | 20 ++++++++++++++++++++ lib/librte_eal/common/include/rte_devargs.h | 28 ++++++++++++++++++++++++++++ lib/librte_eal/rte_eal_version.map | 1 + 3 files changed, 49 insertions(+) diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index 810b3e18f..c6c5eabcf 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -207,3 +207,23 @@ rte_eal_devargs_dump(FILE *f) devargs->name, devargs->args); } } + +/* bus-aware rte_devargs iterator. */ +__rte_experimental +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 84e5e23c4..aba31481b 100644 --- a/lib/librte_eal/common/include/rte_devargs.h +++ b/lib/librte_eal/common/include/rte_devargs.h @@ -189,6 +189,34 @@ 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 devargs related to buses + * 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. + */ +__rte_experimental +struct rte_devargs * +rte_eal_devargs_next(const char *busname, const struct rte_devargs *start); + +/** + * Iterate over all rte_devargs for a specific bus. + */ +#define RTE_EAL_DEVARGS_FOREACH(busname, da) \ + for (da = rte_eal_devargs_next(busname, NULL); \ + da != NULL; \ + da = rte_eal_devargs_next(busname, da)) \ + #ifdef __cplusplus } #endif diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index d02d80b8a..74c779068 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -219,6 +219,7 @@ EXPERIMENTAL { rte_dev_event_monitor_stop; rte_eal_cleanup; rte_eal_devargs_insert; + rte_eal_devargs_next; rte_eal_devargs_parse; rte_eal_devargs_remove; rte_eal_hotplug_add; -- 2.11.0