From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by dpdk.org (Postfix) with ESMTP id AF43F5592 for ; Wed, 19 Sep 2018 18:04:07 +0200 (CEST) Received: by mail-wm1-f65.google.com with SMTP id o18-v6so7641583wmc.0 for ; Wed, 19 Sep 2018 09:04:07 -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; bh=r4ztlloUtcLCOt/o1+wTBrXUXycouEUdDNJOvdSjiec=; b=EibSwO7jYOx/pdmJ/20uILuf//pfyRkn5kSHi3EfUExmSkC679MK3fCrStWxuXCqxJ VbwEO4B2rt4KY5TW23KrYNQbXDZ88mvl78RwlPq8mo3ohybMI6ZSSv7f6tyUQ3tgo6zN /F5Qsdpyg9F0B1nZd9BadXqwvN4MB73Zout89DlENEk7julecP79iCcKkA6X8SWGIHxh yf8fnVfanGd/TCXC6/Yz69zxrUWljvu6wU8ptmwx94vtsfPZm/19HTcahrNUZNqj6e9J nuE0SewUhBmT0N4Y6V/WOHitiSWWPJ74GOBX9UCznIUraMb3zLPbmBL8bv58/MTrKilC GJKg== 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; bh=r4ztlloUtcLCOt/o1+wTBrXUXycouEUdDNJOvdSjiec=; b=ofXodSgSdOKjWTv1E06nMsdoACCaTZjJvF0hSGyInp7q8qq21ECRewDLDsDFq7MIcn qPqdUeUjiDot5BdWgALxItlh8+nO7dzQSs8DoIc53h2VItvG0YUNRWeGQG/4/myztR0i Z6jdMinPGUlXysf2BDiwCnDSHa45s4ztE1eV+tRKTFipgq35OYoBf7fFX2FXM06ygQZX FZNAHUocKMyU3SlSwjw4SKv0L0IMDsFty1A4ZgeqCbXT0WWeZ+c64hrQoy/Ar+wwcn7s UXbDhAunGI1tYT1X2TA7gOzgl5oty5Mo8Z9r5Q/mclvpdOTPf5iGnZcgEFgxJLECtS0z Ce5Q== X-Gm-Message-State: APzg51BcKsW56nDz0q8jl3KHWu1Sy0k1nq7aWl9OYql/2h+ggiDCZlnT e29+Ji/1eVIjVDvztp6wamNiKi+eP8I= X-Google-Smtp-Source: ANB0Vdat2EMsDLl2pEpOAxUs96AaIyDkZZyX+bCbanR1doTf5m3vfIC1dUgvBIYMe7zTWSWRLUNshA== X-Received: by 2002:a1c:8153:: with SMTP id c80-v6mr19289088wmd.123.1537373046861; Wed, 19 Sep 2018 09:04:06 -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 x24-v6sm34983671wrd.13.2018.09.19.09.04.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 09:04:06 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 19 Sep 2018 18:03:32 +0200 Message-Id: <6a580c90394a57d1ce9e24976d02bf09ddda6a87.1537372746.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 02/13] 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, 19 Sep 2018 16:04:08 -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_params.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/bus/pci/pci_params.c b/drivers/bus/pci/pci_params.c index 0fde75803..7630d4845 100644 --- a/drivers/bus/pci/pci_params.c +++ b/drivers/bus/pci/pci_params.c @@ -3,6 +3,7 @@ */ #include +#include #include #include #include @@ -11,21 +12,45 @@ #include "private.h" enum pci_params { + RTE_PCI_PARAMS_ID, RTE_PCI_PARAMS_MAX, }; static const char * const pci_params_keys[] = { + [RTE_PCI_PARAMS_ID] = "id", [RTE_PCI_PARAMS_MAX] = NULL, }; +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 -abs(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.18.0