From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by dpdk.org (Postfix) with ESMTP id 6F4F9A84C for ; Tue, 27 Mar 2018 01:19:22 +0200 (CEST) Received: by mail-wr0-f193.google.com with SMTP id c24so20511424wrc.6 for ; Mon, 26 Mar 2018 16:19:22 -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=9un7AgnwYiAs1erV3Id8Dw1pS1MYfMazv6jDEONH07Q=; b=1vcgb1DIgjhZWY/ZdQHZyK5FJwVAvchCHzJzzJo+LTLF4qUziLbxgorXIFGVFjCPlq Ej9HnOH4pFKzOH1nzU1dgm0aX2gNYY+GLzvtYiR0E0bXkDDtWICZN5y5yFAmZKPJ9xe/ GN+2GiqhLwxLDXgfznpW7ZZDSpR8aej/5xQ4MdIWmmmqTKK+OD+NH57rqAqLNAG9pG4W nFvUSSqXtv1ERBLfeg/I895v6Gc3WGhMgvJhSIL/CjnErfu0V375EOInHct5jF+6KMO3 xnql/8IbrxXKEugjqSU68qMBJDpt9OcvBO07aRQNkYMWLcWHrH89FnZ5U0TxhRTv1s7M Wh7A== 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=9un7AgnwYiAs1erV3Id8Dw1pS1MYfMazv6jDEONH07Q=; b=hEKX5tERmD9TUhZ1+f3j/AdHsdkD4zAs44UqGBaDYj92rnyIU7+PRSGWC3+OcyjLhR 2Ufj3hqbiI0arz9nZiScMR2TqVl5ro88mmgvejfZsvytEWV2Ppo6QzHfqGVrTNwKqmCl bC1GtKtGNp0zMFRhMxyueABht/yJeS0eMsKRuuFfCxSlKoi9VuL16rajjvaPOxR9oRZu o6JV/EBOVM1xedn6t6c92bDpaKZKI/BqWGBGigjJ9fse5Ku4KiEr4zg4qvzbFbtp6fIh NzwaPP0ameoUFMgDspHSNWoF+lYuJ8jEEoWEhKLOkdRVnDy9LuXCcHePW4LnzgzaxYLs QrsQ== X-Gm-Message-State: AElRT7GXihK3qpLHtG8VBGaBPAKc06L83UmqEQqJpOgAcn1UO+oOLZ3P BOTZagoWEr9+VTpUg2//M539QkTJ X-Google-Smtp-Source: AG47ELtxWLqxGn2Z1ZKLxKQYgIHv3fz5IxxDVlA4cki8QGlWf1cRDUN66oH4IFfWWMUWXPL53ipH/A== X-Received: by 10.223.132.230 with SMTP id 93mr21598253wrg.242.1522106361747; Mon, 26 Mar 2018 16:19:21 -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 67sm343712wra.9.2018.03.26.16.19.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Mar 2018 16:19:20 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Tue, 27 Mar 2018 01:18:38 +0200 Message-Id: <06d84baadf57591e6898315b5232215915342803.1522105876.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 14/20] bus/pci: add device matching field id 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, 26 Mar 2018 23:19:22 -0000 The PCI bus can now parse a matching field "id" as follows: "bus=pci,id=0000:00:00.0" or "bus=pci,id=00:00.0" Signed-off-by: Gaetan Rivet --- drivers/bus/pci/pci_common.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index 59a776305..af5b48287 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -499,13 +499,35 @@ pci_unplug(struct rte_device *dev) } static int +pci_addr_kv_cmp(const char *key __rte_unused, + const char *value, + void *_addr2) +{ + struct rte_pci_addr _addr1; + struct rte_pci_addr *addr1 = &_addr1; + struct rte_pci_addr *addr2 = _addr2; + + if (rte_pci_addr_parse(value, addr1)) + return -1; + return rte_pci_addr_cmp(addr1, addr2); +} + +static int pci_dev_match(const struct rte_device *dev, const void *_kvlist) { const struct rte_kvargs *kvlist = _kvlist; + const struct rte_pci_device *pdev; - (void) dev; - (void) kvlist; + if (kvlist == NULL) + /* Empty string matches everything. */ + return 0; + pdev = RTE_DEV_TO_PCI_CONST(dev); + /* if any field does not match. */ + if (rte_kvargs_process(kvlist, "id", + &pci_addr_kv_cmp, + (void *)(intptr_t)&pdev->addr)) + return 1; return 0; } -- 2.11.0