From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by dpdk.org (Postfix) with ESMTP id 00CB84C57 for ; Thu, 12 Oct 2017 10:21:45 +0200 (CEST) Received: by mail-wm0-f47.google.com with SMTP id f4so11028603wme.0 for ; Thu, 12 Oct 2017 01:21:44 -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=DdxhBDlsbo6QurLNun3zzcRA1tMyPIbHhcKDPm9cZkc=; b=p5yORhnQmevYaIjyG2TPM+lk10PXOAYDlVaF36vTQdwPITo4bnH08lmLCSRU8ZnQUO OD4QUBWAyQjWgAJTfnX7CS2EmkN4eJMIagVMGjugPElXmBDhRlb7tV0NYLJ63MBVPnWZ lTbo23XPnYMg0drbvxVVVYcp0RCF1NehsORU583FWVnMtwjpu2+AdOlIBY32P+azE7j5 jQHoYDhzCnvau3nvuA8BsJKmgkYNRDJretjn+yboGq1j3Wm6LTWoX5QeFD7sSYFbfznR f72eVHyqePibtIfsOJi10dhjD/JBhx78I8zMNUa0laq/TAIP1ax3vK3HDHhNaFzdjodh qRNw== 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=DdxhBDlsbo6QurLNun3zzcRA1tMyPIbHhcKDPm9cZkc=; b=Eefj6HVb6fZYPY4i1vmjAbNt1ZBAblFxG7nPAG/OKLKNjK6EnnCRCqqBXcoNwzlMLH g2a5nGStFrDiNpxPkBXSoxx1hSoNkX1WoxYvGQCaQQ4VfGONBEjMh/jTcS7slaYl9EqQ 1/q5jreglurW9GHcCdeR6obTeG3YRN4EghH5oq/sL/tgrYtEo+b5WpORoHneJPh3RYl2 VsKmU0YgevPBy7TwOVH4avUL9Y2ApCALYDwOj304Ks7CMGbumFk5GGhpzO7JFuS3GY2n F8oS9ZS2FyxC7Y74/mVd+cfGxBA/x6ES7GIcB5UR+GKNZE6bQ34lNzc6Gpq/Ff68Ownn QN4A== X-Gm-Message-State: AMCzsaWidj/Puev38bZf/oM2n3YnUgq5d2k223R8lowgMqvWLXvNN2aw oX1SeRxLbKGwM7+m/tQCWSf6Tdxt X-Google-Smtp-Source: AOwi7QBcXoXIu+Fk2ruTTd0TVtJgD5FD3TyetwUOm9zr3i9c98nYnCKSrxT+1mPQWsZsakH5AfVAug== X-Received: by 10.28.107.66 with SMTP id g63mr1069681wmc.38.1507796504302; Thu, 12 Oct 2017 01:21:44 -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 200sm19424728wmu.44.2017.10.12.01.21.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Oct 2017 01:21:43 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 12 Oct 2017 10:21:10 +0200 Message-Id: <66c91e49f7d9fb3c6faa642a5a4462048190bcf9.1507796100.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 v2 03/18] 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: Thu, 12 Oct 2017 08:21:45 -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 47416a5..01ae0c7 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -189,6 +189,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 2fddbfa..614f1c5 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -208,3 +208,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 e50c166..0eec406 100644 --- a/lib/librte_eal/common/include/rte_devargs.h +++ b/lib/librte_eal/common/include/rte_devargs.h @@ -188,6 +188,24 @@ int rte_eal_devargs_remove(const char *busname, const char *devname); */ 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 e1e2a50..576de56 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -193,6 +193,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