From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f177.google.com (mail-wr0-f177.google.com [209.85.128.177]) by dpdk.org (Postfix) with ESMTP id AF00F2C72 for ; Wed, 21 Jun 2017 01:30:54 +0200 (CEST) Received: by mail-wr0-f177.google.com with SMTP id 77so111492266wrb.1 for ; Tue, 20 Jun 2017 16:30:54 -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=7H6TwwQD3GsngBS+79UIxjXzkzJ6Irz7By+8f7c8pNg=; b=ggGscYXYzsQFLB/y9FsTrUr3kshnrcen+kVQ8aAuNyAWdTDYOh7XmHFearyleIvUSX hl/Pock3UrhmURS4yV2VZ08+BhH50ah5gpwtWF1p6muUJVq+1TcZ5CEZdGNZr9rKXTrm B2SeFhDXYSQq8BpSH5oRsT8N4kCymLc+6Dh/OHTkgLDHmNS84R7i7XrLwfIu45AAS+Ef /rrtYJ9KOgBXixs0Pw9jUTHeUzJ22dQq97/J3lpQWUf7tY+L60N+t6DnKGa4vwtYsfXa mMRSDQv2y6vxrq8jIDhNlZL7h06/SqcUStsPYSUgmGEo/qVL9u+ZBJ3c1q4wYIjD+TTO 9KAg== 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=7H6TwwQD3GsngBS+79UIxjXzkzJ6Irz7By+8f7c8pNg=; b=QORTJZCLoKSEFB/UNwf0u4zMdVDwpdAXEnwSlgbGJ4saw7j0V0VyMqqG/RlqcVjA5h vROD/dMkKnoEX2KMZJZ2NeodymunLqbqNS7s0Rjng1H0AgfJp7ebkyCEXHgWCU31pE9A 8DhLAYCHdYumygJxeMY3I+31XrfZxyL5Fwe0lZAr8YbZmngMvqAgJW/QQgGkioQtqhZ6 lV5R3yYR7hdfQ65oCOIuXRn/owXwuoRltUjPUH/a5tmv8K/rcUYOfMo+pg9Qy+/TXbTP GG841uFxOzxAzDzwrtCT510Qh348th9JXr82Mj4+Iz586jPEN2sBJ5GLQJond9G2uJAR Xg1Q== X-Gm-Message-State: AKS2vOxlUjNsVvCCpy+xawwt0QyY4+bBirmA9XnOkcFsF+vhDWlOmSFf flDnx4mKSaRo39Kf9AE= X-Received: by 10.28.178.198 with SMTP id b189mr4453060wmf.8.1498001453972; Tue, 20 Jun 2017 16:30:53 -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 w30sm17593338wrb.49.2017.06.20.16.30.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 16:30:53 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 21 Jun 2017 01:30:33 +0200 Message-Id: <519fc66238ba3ee80b44e63547d105ca7689db16.1497999826.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 v5 4/7] pci: implement parse bus operation 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, 20 Jun 2017 23:30:55 -0000 Signed-off-by: Gaetan Rivet --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 7 +++++++ lib/librte_eal/common/eal_common_bus.c | 16 ++++++++++++++++ lib/librte_eal/common/eal_common_pci.c | 19 +++++++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 14 ++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 7 +++++++ 5 files changed, 63 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 150b0f7..3517d74 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -197,3 +197,10 @@ DPDK_17.05 { vfio_get_group_no; } DPDK_17.02; + +DPDK_17.08 { + global: + + rte_bus_from_name; + +} DPDK_17.05; diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index b6bf57e..e69ce38 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -215,3 +215,19 @@ rte_bus_find_device(const struct rte_device *start, } return dev; } + +static int +bus_cmp_name(const struct rte_bus *bus, const void *_name) +{ + const char *name = _name; + + return strncmp(bus->name, name, + strlen(bus->name)); +} + +/* find a bus by its name */ +struct rte_bus * +rte_bus_from_name(const char *str) +{ + return rte_bus_find(bus_cmp_name, str, NULL); +} diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 00d48d9..0f3ecdb 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -450,6 +450,24 @@ rte_pci_dump(FILE *f) } } +/* + * Parse a device entry + * typeof(addr): (struct rte_pci_addr *) + */ +static int +pci_parse(const char *name, void *addr) +{ + struct rte_pci_addr *out = addr; + struct rte_pci_addr pci_addr; + int parse; + + parse = (eal_parse_pci_BDF(name, &pci_addr) == 0 || + eal_parse_pci_DomBDF(name, &pci_addr) == 0); + if (parse && addr) + *out = pci_addr; + return !parse; +} + /* register a driver */ void rte_pci_register(struct rte_pci_driver *driver) @@ -505,6 +523,7 @@ struct rte_pci_bus rte_pci_bus = { .scan = rte_pci_scan, .probe = rte_pci_probe, .find_device = pci_find_device, + .parse = pci_parse, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list), .driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list), diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 05503ea..da8b8a1 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -268,6 +268,20 @@ rte_bus_find_device(const struct rte_device *start, */ struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev); +/* + * Find a bus handle by its name. + * Compares the name of each bus up until any invalid character + * in the matched pattern. + * + * @param str + * A null terminated character string. + * + * @return + * A pointer to a bus if found. + * NULL if no bus matches. + */ +struct rte_bus *rte_bus_from_name(const char *str); + /** * Helper for Bus registration. * The constructor has higher priority than PMD constructors. diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index e0a056d..6607acc 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -201,3 +201,10 @@ DPDK_17.05 { vfio_get_group_no; } DPDK_17.02; + +DPDK_17.08 { + global: + + rte_bus_from_name; + +} DPDK_17.05; -- 2.1.4