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 0F88D1B590 for ; Wed, 11 Jul 2018 23:45:56 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id v128-v6so3681767wme.5 for ; Wed, 11 Jul 2018 14:45:56 -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=LVskmLOkKzfvRWoYmiGOcs3Kqk6t7ITOF5Nap0TUZD125cqBoaSn6NZCJaxG3rE0lw w/Jxm8iLQtE/RBuxQna5fqI1H6DPp9HlAR3vCtJzURjPRDMgCoECJFIqrqWh9RYQ069/ WQXgPcWjnE3O0rXqrIBuPcvly4e8EwtEoD4x4WxXs3cu3rVHaABeEFSrdOOOE+AOVfnu 4b+uszkEFQIsie0fOqQ5kZVGkGaRPQvTnkQS186kduoOLpOpabptMLWP4eg0Orjqn6BN HKEAI9d0K7Y0fvL8IrboKLqrPCmb9hd/dXRLW/V5nTmXFBvfslMCB3H6FmhOSOvsFBpW 0E0A== 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=cqBMEARwtSjtSchiqjLJoDzHPaEIV/Gkc/0ytq7sK2UcpYxhKE+mlMA5o9qcFEqDzT T/ANCDYZdFvHlQ3cRZ+q5wqt1ISZhBC2fHOr5UWfrCUbiFqyQhNihGKMifvzJFvCFmMG X5+VxyjeXldxrzU65iWibtSuXNvzTsMC1nCzht2EZsAeMiRIROveE75/3a5uXnXSO0Jp SY6lbSoIS8JCIiIAtaIsLNFlX//4qkR55b+yopiSlgrw0fTsEYOY378KxmClxzHg7LoB MFFPvMkvV2uBozXOkieNn5MvF5ohp5oTrBwIFB2OgE44Xh2tTZwFMVuJXmRchrfTihEj iCUA== X-Gm-Message-State: AOUpUlH3jP0lj1spBJGPq7n51RP92ZZoR/8GPuUXABXUhBM8G92aBS5u b7Xom3D3R/x5he7Fjc7/qv3tyFC4 X-Google-Smtp-Source: AAOMgpfVAv9iNQG0NMclByyBIpnwxwWHGvAFkWqE+5Gr+raQNTDXNsc8pkGODy9jm7tsplyZQb1ipQ== X-Received: by 2002:a1c:497:: with SMTP id 145-v6mr131590wme.157.1531345555392; Wed, 11 Jul 2018 14:45:55 -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 h5-v6sm10550936wrr.19.2018.07.11.14.45.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jul 2018 14:45:54 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 11 Jul 2018 23:45:04 +0200 Message-Id: <27d2d89061a08c12c8ef4a0cb95527df914b3976.1531345404.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v11 14/25] 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 Jul 2018 21:45:56 -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