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 E850D1C16D for ; Fri, 13 Apr 2018 15:23:16 +0200 (CEST) Received: by mail-wr0-f193.google.com with SMTP id l13so7238371wrb.5 for ; Fri, 13 Apr 2018 06:23:16 -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=0tkaf6xMgEbAGp7V51PgGl+hae9tM5/7BI3V3BIpsqzrMHEoH5QiQVytaYFEfh1FfB N2ILIDPu3TuyqQLmD6395cZ9cDeQc4+B4K3VLrm4W2nq8UuYGqMVJaiu1yy4Jiw+LnNT MHCocI9aZPd6CTHpO95gD0eTeWj2J1MGjk0Xns2QCtUXNXky0EmFgC3bV2jfLKd77s+P aDnixidMinUzgGqoC4r453KiO0slLWIQP9FVXhuL5d07ijVUxyuz/jbjad3UR22pYIHi wSUVOK2nXVHC/PMYK1vqe06kDNAZwABRo21/y5kxDMIFtEZ4GWdo69otSZCeh3T1da89 hyzw== 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=jUc+QoUqb8SW+3BxkxhhgegOsWyXOdTbT4Km0I/Hfm7FeEpIffgXNn/gs9n/U3IIoB dMV9ApBAiRhOMu4vdMnDXAU77PxJb5VqwTT3mwEHDWDDnvoYDYZrazoA06+HQN27lb/Y ZGXFLifBpCh7gTt3labiEbpxdSDAbbhceR9fPEB9YWaKhzi92JNj+jit5nnNC+k85Fgb 0Sr5ulGHwqGgMsdlUEZhHkU7j/QmXdQi6pg6hx5hQktURueBsVZlXabigJmXHSzodFey rbruVk9U35ExegvpFOBz4SSkhVNu4nalOkfc2pL1XDQygnzmSBqFwQBoJihH0L6ukrbb TsPg== X-Gm-Message-State: ALQs6tAEZ/Z3IqPR5lHmJXpq4oWQ2V9nPK5tZxeTOqwV/LjXE4sui9pE g6261g+brkPplK4eod6HIECFiKRm X-Google-Smtp-Source: AIpwx48+l/6a8VkvhcnEkEm8BoACEGMyLB9SxnfBGXX0hGHwDU1pD0pY8HK4EC3GxEdwRCIT9o2Nnw== X-Received: by 10.223.173.42 with SMTP id p39mr4040249wrc.146.1523625796250; Fri, 13 Apr 2018 06:23:16 -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 r200sm2377244wmb.9.2018.04.13.06.23.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Apr 2018 06:23:15 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Fri, 13 Apr 2018 15:22:30 +0200 Message-Id: <6c39076dd5a58c96dad2e7f61689a7acfec8ca6d.1523625525.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 v6 15/22] 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: Fri, 13 Apr 2018 13:23:17 -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