From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id AB47A4C99 for ; Thu, 30 Aug 2018 15:42:35 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id 207-v6so2061347wme.5 for ; Thu, 30 Aug 2018 06:42:35 -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=ctVKM/EGNz3n8OwbQE9xetXtxbxAAGFdW86zSx64nSTI4Tm+9V0uVDQIbikd89Y3e+ nH6CxT1jkhVfF3lieG42QGvdRe6SECoXmwBv1AbVbpZ5uja0ucDXDgSU5fCcSo+83+NQ rX1MJvUYdg1+ejlbS+Fb27WNyGMdrsRlPCAjxL3K0EZIF2aEl0W70kWkbVE+jJDV4xaq zByZ0vjpA6kArp84VTKO5vHG2FTV63nSqgyFTc4ZKn3PqZ9To23cKipqhZYu8/ahN/Yt PiFobReWSKpXTWhK9TKuC7xkNYn+v+IrH5nLGq6/fnOFoPdf3C0l67//HQ64JdWyLmPN kOcQ== 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=mQf1tNbH+3JxhWo2FUlq5EwtCrjRokoO81gz1Arq5knq85/6Q61GB3GX0cmBlNFwo6 62hxcf2DaJoRJv35L5kQZ5V1oCAAJCRPrdlw4RqPTsYdi9tv92uVMRHacGWd9qJoWLIb MohweGcTey7AixjgYIIyinzXl8eppHqmFcPen24/jkjyLakpF7B/iPsa7lEzc7M4bFAJ hht/+ieObzo9kVuvwirG8TAqzW7MjmBW+WcDYINmuOpWssFGZiyCxo0hUW7Adz+BfEUp OrXet2v8mdp2A43BvIrIkUHOMEjx1mabPQ3A1aZqq+WHVsnu+An7jnMJFbpFJESLr9tn tOUQ== X-Gm-Message-State: APzg51D1qNz8GffV4sT2paU6VB0G/iKZ9jHtPPC0yVz0ydSCYulgNiss HnRf4XOVJ0xJvZRark+8flMH0g2Kf1o= X-Google-Smtp-Source: ANB0VdYXzVNfXb8saFeB79X2NnpXJDvykqzDGZ/2h/QUAJVpIgjVY2anDQi7eTYLvSt5xHAt2pOAvw== X-Received: by 2002:a1c:9550:: with SMTP id x77-v6mr1779120wmd.135.1535636554861; Thu, 30 Aug 2018 06:42:34 -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 w10-v6sm5247731wrp.31.2018.08.30.06.42.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 06:42:33 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 30 Aug 2018 15:41:53 +0200 Message-Id: <826b5fdf55228723141a0d75d576a262c9759e5b.1535633784.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v1 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: Thu, 30 Aug 2018 13:42:36 -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