From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by dpdk.org (Postfix) with ESMTP id 9D3161BE35 for ; Tue, 26 Jun 2018 18:57:10 +0200 (CEST) Received: by mail-wr0-f196.google.com with SMTP id h10-v6so17957357wrq.8 for ; Tue, 26 Jun 2018 09:57:10 -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=GDAM0+BY9zdzKzqAvSmkL7Cyo+VOwFhWZYWz8JjTZ8Y=; b=NKWNB+YBiahRQ5JviHwIGTIcPPFspQuHUYeTZV/QkDuy9pJrrsOnqI9Yz81KtzaQHU UYx+MDz6Pwc6/M4zNF/VJ67HX607ykVAuHeE6jD99sh8EH3fvYbexC8WSWpc94BgkR9z snoGHjf+aT/JLsrs5FNU0mLVvAvgwap34ccI4J//psHHmrj1YNJ7MUhEGd8SIHEXazC6 fSwMRyxNyrQXkVFWAyvJYVU6KfHzry2vI8cDwuOINdDuLX4LyL07bU1qERFg+Tq2q+eE MZitUJ2nlkJNEwSu7czZfkzQDjqke1UY5lIdl5FxKNk9+6arh4mDbaHyR6Nm2+1ZDslX ADUA== 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=GDAM0+BY9zdzKzqAvSmkL7Cyo+VOwFhWZYWz8JjTZ8Y=; b=q39Qi6ozzB4TYmi1nXZWWnvPsZqcjtx9kVlfMemmU74asu9mBpGppIEo+G0678BhT2 77kaLkN5yTcvaZysAkEs9fsnpy3hD663ddWrpFlbxlCIHo4gxXKqzvPvl5Ou7YLHGQY1 /3KZX+Dyr19f97I/MpexufoCoZD2mYUd93UroqDbP1nRHaKa/60EWI/mDmLUEQ8DMEtz +lmzQPtM2+vDhgkaDP74vORbTjzPx7FHbm47EzsLosOxCJlqc9VIKsTdXk6UmZILMGs3 y6lUqqZYDrv1lMkTPyq9iMuIJ9Q380gO7pFeIaiEonvNJ5HXIzTjSyvNROFDbleBISXf AlwQ== X-Gm-Message-State: APt69E2IVAWMx7b3d+2GmR6K//d8qcSpTMh1HcCjDnDOsiRuNzeHPtnt PAHxuX3Fe9eZYlp2KFecemN9slVC X-Google-Smtp-Source: AAOMgpeaIf/SI2vEzXQqSwTJEmdrLz/i8ixjpvR2wqToWHDkmqCXW5iXnCtIOKfkcHWHuR8iaHYclg== X-Received: by 2002:adf:9562:: with SMTP id 89-v6mr2084748wrs.99.1530032229883; Tue, 26 Jun 2018 09:57:09 -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 p5-v6sm2680880wre.83.2018.06.26.09.57.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jun 2018 09:57:08 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Tue, 26 Jun 2018 18:56:18 +0200 Message-Id: <5cd7358f94dd18f4861df37df97148e21ec8b293.1530031921.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 v8 15/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: Tue, 26 Jun 2018 16:57:11 -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.11.0