From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by dpdk.org (Postfix) with ESMTP id C19F3377A for ; Tue, 4 Jul 2017 02:58:52 +0200 (CEST) Received: by mail-wm0-f49.google.com with SMTP id w126so181566651wme.0 for ; Mon, 03 Jul 2017 17:58:52 -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=cEPmICazrDFDBzrFRoVsVwX538BVZnyi461DoUS5bb0=; b=CVjsf8IDWn1SwZGp9qztZBWGWGVrPYshWCVO5jjbmU++ti4PkkHQdaCW1Gc5hoRbFY uw+ojpJmEqoPMFT2ckcNFI2x0obgNkx2D2hYsMmrkpjtDsbDFXB94Gwxofnp9hhEqmpX NJuOTQUlO96r+TU1A5wrX6iHOq9VzLan52EuLXTQsaewz1AGQPbd3frGLwrnqtyQW6FH yzJlyljE8MybNnvdxv6jxablnQamVsVsJAxusIel1rWOijfra6kU8PLb7+qzI83IvQUG Eye+7XlqEoVA4ApicVnCIFSwS/Mi0g1nlRY7ZCWgZ0BgW9z+brvrDltSDGsE4QjwpAqy UhyQ== 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=cEPmICazrDFDBzrFRoVsVwX538BVZnyi461DoUS5bb0=; b=aH29NIye4CMBJpxKEBqWqh6lSs2tI9sLvPzGhCMfCIx6tBLQ18iIcoqMpicBIkcggV ZqBJZOskiJVkv1oSgc61WxLKa9LwQ/k668ITfpOPPvZZIOSU8b2fLz63UCNs9yGXd+Bu sUiTPDvnxax4Btqaob93b62JonEbCEp/tXyaN82rTt77kzlkYDEedHG4qUTeGizFh3Xg vVULlZZ9ESiGQ5GMOB+Ttoihm0heVTZmTQzjmpkdgjSVa1NTLzBfhaQS61Ru1AuAVQK8 p6VR5NbFqARVRLjxZeh26qevugLDieKRLJOtBXRPSI/t6v3D/CJ32O+o7ucWBXdHRsmb xzgA== X-Gm-Message-State: AIVw112J2VVHQX4f4Yjv5xsRrHyvoUWIs49jDYLvLrM42owoNHINZwRJ 8cWvURh4uEWgsbnGTUw= X-Received: by 10.28.170.194 with SMTP id t185mr17428015wme.114.1499129932257; Mon, 03 Jul 2017 17:58:52 -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 n189sm15162731wmd.0.2017.07.03.17.58.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Jul 2017 17:58:51 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Tue, 4 Jul 2017 02:58:32 +0200 Message-Id: <69856355c46d84d0e0d992afdd2e1dc07ee49c19.1499127915.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 v6 5/6] bus: add helper to find a bus from a device name 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 00:58:53 -0000 Find which bus should be able to parse this device name into an internal device representation. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_bus.c | 15 +++++++++++++++ lib/librte_eal/common/eal_private.h | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index 87b0c6e..b143f21 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -204,3 +204,18 @@ rte_bus_find_by_name(const char *busname) { return rte_bus_find(NULL, cmp_bus_name, (const void *)busname); } + +static int +bus_can_parse(const struct rte_bus *bus, const void *_name) +{ + const char *name = _name; + + return !(bus->parse && bus->parse(name, NULL) == 0); +} + +/* find a bus capable of parsing a device description */ +struct rte_bus * +rte_bus_find_by_device_name(const char *str) +{ + return rte_bus_find(NULL, bus_can_parse, str); +} diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index 6cacce0..0836339 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -338,4 +338,16 @@ int rte_eal_hugepage_attach(void); */ bool rte_eal_using_phys_addrs(void); +/** + * Find a bus capable of identifying a device. + * + * @param str + * A device identifier (PCI address, virtual PMD name, ...). + * + * @return + * A valid bus handle if found. + * NULL if no bus is able to parse this device. + */ +struct rte_bus *rte_bus_find_by_device_name(const char *str); + #endif /* _EAL_PRIVATE_H_ */ -- 2.1.4