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 09DDEAA90 for ; Wed, 21 Mar 2018 18:16:14 +0100 (CET) Received: by mail-wr0-f196.google.com with SMTP id c24so5988337wrc.6 for ; Wed, 21 Mar 2018 10:16:14 -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=dchTtgQaq+B6IZeIK8jcqVayZknTD1wPRQfo7JaM2lb1lWje3OsQr52j94Mv+2moPt iRlfViPuovYmaKO2GqBaAQJ/gcx3/11V65swtGYtrRp1vwuBGAhoJQRYyw/ke21qadSe ZiN7xMRkINzKv3z6J3kPVQpWakjZv6CGJxW6XCLuuV5gbMrnPnx7HukrAXtZ1/iKVqG0 ake9LId/rIxJibCrT3Gip1kh1KYMJ7QCdQacY54a0Y2gmEbBT6ADMxQTCzJdFT7jLpnl ZWtpPx0ziPI9JnYSLMBCutq7QSZ0aRDd/8FHFEkWav1cSsPItu+RahPn4EaGatDEFvgc vunw== 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=P2HKDYMkcCt585z3TWmQFVuMMAPq0dgY2w67aUqVJnzjLgpihIWYcbJpA6OXVSht+t 8vJOtbaoPlEm1XJY3YdV+e/8WcwqhFymHGrnz9RX1XBD9dugr7S5tcj/WP8SQHzMo/Y1 wiodSMToC/4+imhCLVvUhKTcSXwTsZQGV5tz1HYzZpDvfF4XUv038FB2hReyMh6TdFwc /NDpbPd1Lv7hQKGUDkPILt/TJGW85yUNXDxDtot8EYMDlFdfgrY7UzSNFCZQ1uPkPW+f IMHR3qyDAxkL2Qf6UHgHlI2HOCgkMBFPn1nMlsB+oZEZf98r4+ekAl8Aldqcd0zNmGSR 1InQ== X-Gm-Message-State: AElRT7HoqCF75TpM+SfHA7l4XCBttcoDUVhJSZV/5wQevwrueAE2RLVi IAvKnl4UXEeCbhZ8S2B3A2ySuWWY X-Google-Smtp-Source: AG47ELvKPqaAOA4ijZ/IqLF/EAtJ0lsJmSLMRrucFQU6yUuXf+y0FPUgnjFjj5+xPFj+U9uoqGmI/A== X-Received: by 10.223.167.153 with SMTP id j25mr18117493wrc.118.1521652574168; Wed, 21 Mar 2018 10:16:14 -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 l10sm4224101wrf.37.2018.03.21.10.16.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Mar 2018 10:16:13 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 21 Mar 2018 18:15:33 +0100 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 12/18] 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: Wed, 21 Mar 2018 17:16:15 -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