From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 005A91BAE0 for ; Wed, 11 Apr 2018 02:04:58 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id t67so622438wmt.0 for ; Tue, 10 Apr 2018 17:04:58 -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=92WXlTV7tP9Bcqf0JD/O5rkTSJreSbNwQkGAXS0FzL4=; b=E9ajR0YPXciWREkMwjJdL9EGjXZAlFvAN7PVeMJiEcgVGNr+ULK1IxL+qf4xsOzila XftBAeMaIPQzGc4ZR6k8PNvn4M7Pw+yttLZG3XxuZPtUeNDsw5z+PFOx1xb1GoSgA61J XDHm2Bp8reEILtFbpzzkF4dPmE6vYQU8cWmEYwTb09dHvdS8T0EiTMQGJ/UcnLblvcLs TX2Z3C/p8PAwqDs8/8zpM5f5NUppwJWvrJRd0STx2ZM3NCNRG+OqgJX4xJjkyJK2vuh+ LwancCFkI6Q42iu/77Q1wPw84kGhKiXEmMnWdhL0PDURuBCKPpIcp3+kJL27r1Stgqyi kuzQ== 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=92WXlTV7tP9Bcqf0JD/O5rkTSJreSbNwQkGAXS0FzL4=; b=TAXR5XN9sLbixf56H/APvfXkn4u1BDheowZgKBgTVHviiu6foCXR7grLs1G8WnPb4I 5NoNiA77HwTbaKxHh1g6Tyrq9roIR8OlMxlEjFIMdQ+xsjW6R5Y56LSJYutIX0pmT+8v Hf7VuwtdLRHTZIXVYciHGI9xq3U2K8e9VWRQBp79/fDs8AG+QMgwC1dezXVTi/7uFZd8 MRSNxMGB96hsi0QL3KrCbNfLbXp2yS8ZceFZUW8trKbTBdlwDMGfsSRHTEQTWS2lb3tn 25X4fEgsrItGlFrn70RL69mKv+EsWI7yJu2q/nKiEKuQRJ9V8AJAR96mQ+6n/XWLqJKn OYow== X-Gm-Message-State: ALQs6tAa4TlwJN4lb8pU795tv0HJso0cPQnbeM6q1tiu5DZAiewwuxim Tgj+AWGo5wPWky38LDdxQF1fwZlg X-Google-Smtp-Source: AIpwx4/TI6WTj+sRz2pnI2Ugor7X2EXxy0Ik9RGo+80cj4KkhTO0ZGDy4At9W0Whx/g9KoWS/LpFbA== X-Received: by 10.28.14.9 with SMTP id 9mr862641wmo.127.1523405098342; Tue, 10 Apr 2018 17:04:58 -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 39sm7626563wry.89.2018.04.10.17.04.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 17:04:57 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 11 Apr 2018 02:04:15 +0200 Message-Id: <4c54df03eba2c16e9fd06112931067cf0500263f.1523404469.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 v5 14/21] 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, 11 Apr 2018 00:04:59 -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 | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index bd9ecddc6..3666e4caa 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -499,21 +499,45 @@ pci_unplug(struct rte_device *dev) } 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 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