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 75118199B6 for ; Thu, 15 Mar 2018 18:50:29 +0100 (CET) Received: by mail-wr0-f193.google.com with SMTP id l8so9193728wrg.5 for ; Thu, 15 Mar 2018 10:50:29 -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=HPgZXRJGT08wZVcwo3/VwVrNcmMXOpXRIQWuoKoRi1w=; b=K9f7k03ocAYEJo0Q42+4x+CTFnn/WFvKtU7YRGtOotlBf9olgamJD/3oRxx6nAP2WJ etYd9TVxnvsH2vIU8YCF1Yv2qX6KNJ/QXlW8OIsJdq5oW/VheROqDxHyexIHzavP5xrz aE11y+PCv3tZzVyxtWvmScjzo6jkHQ1dJ5pF5wTetQTwt0tkXeSIgcynY6ntdhSGzqZm NmQDaJHkqS4eO9jlVC8xSTgKLhcgOouquvRSGsjWb8NWRigIsVSEAj5r7UBk1krMy6Sy TzHu6szcp6CYWkpu4JesO8aQ4B5jX8vzlpEWVc2jsHK3O0EB7TnBCXP7M57VEAOPWMbb nSww== 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=HPgZXRJGT08wZVcwo3/VwVrNcmMXOpXRIQWuoKoRi1w=; b=QLGKcvrJ/O2kGqoUDab7JK3CmxRcoZtCwSmYrGc3GJlYdgl0OXiIILh5veJVT/REqc bRfKWY5yAqu+CcyCLW0JW3Mb/LadrtTt/gTU1Uc9SrvUpMSFYVjOFdoQpCv/kKfAER+E Ivw+9dAtI4EsS8vjPO7oGJsdrMTJiKanoTRxFiY6Vo8uoLINXbIn3o6dJHGdutRVykrJ 24xccpPb4E5KMhKZPY7yCUnd4ymuWY8OdcaAIXSPvm2C5QufV0pDVMUghjWXJ905Xr3i s31FVeYvogHaLzo0H14yf1JLYanEf0C1RhJ32PjPWCTD4WkNzOiTa54QJ+udZ9L7J/t9 BBxg== X-Gm-Message-State: AElRT7EpD5auAFn/ZbVo/bcgzUxo+dbYep0gy6WfgTppnlsH7tDcep19 d1X/NiIo8QbDEocnlp4XvVp/Wln0 X-Google-Smtp-Source: AG47ELs2lbqyBVd3FcKKS1dI9Inp0DOza0h2C3NWLDi1IpgR0+cb3wDqow+ynBOAQdRPW++u3GcfFg== X-Received: by 10.223.182.174 with SMTP id j46mr8234897wre.43.1521136228282; Thu, 15 Mar 2018 10:50:28 -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 69sm4756596wmp.36.2018.03.15.10.50.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 10:50:27 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 15 Mar 2018 18:49:44 +0100 Message-Id: <9a16b44d32884d0aadf07960099edf58cb227a97.1521124599.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 v1 14/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: Thu, 15 Mar 2018 17:50:29 -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 482c96df2..6cf1279c3 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