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 7B2CC7F0C for ; Thu, 29 Mar 2018 23:24:32 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id r131so13901563wmb.2 for ; Thu, 29 Mar 2018 14:24:32 -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=LGpkB1CbNNxrfDXPRVdCtXQ9WFnk6SrH4V7QmPITrLw=; b=P1pMPXFx6xzO2gW6+1YQ5utCnBqQbP/UQBXgHH16bzDA0VST4lToousjX3kQ2LU+M4 3UJ1/XVrTbepbFyIcWz/7jqniV2VyR661lT0fDNo1ph9gga8ypiTQtJRtV90SJdJciIN xo0EZLf8fui8kAj2SiH7jXmTMDJUQLGazj0r7yqGUTcqWnzDLb7/ZcAOzNmSp9kWyLsR D3UeK3uFTFo1ogFOIZlZMUD3cCoqhUwIxL6noLAMfh6fecBMj6+cA2Rhk+wyzoJpossR 4jjFcnis9fSEccgbpX0/xFcXET14BJ98gUMbi++iSW3zQ5PVZwl7dzUGgOn+YfjYPTW3 ++aw== 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=LGpkB1CbNNxrfDXPRVdCtXQ9WFnk6SrH4V7QmPITrLw=; b=R/2GD3sHAA2RYJCEW5U+9COKZjnckMTSGOirNPEVnb42+JMwLo3OhiWu1P/ZmhSoYk bq7kJ8DKhRt4xQUmDStw0EbwEsLGmmnDFW8gjcrWcnPMnvBNlesLYivDKLS2Mpn/NB3L UpQG7oEWkAQh9ss+XXxIWHpqVlCHQlGHJS5R4HKMs0LWLjDegfu/RabHN2yVWy95pP5e haDQ8IPx3RkgNOHOTQpsDW5arqyIoU0y1INtGcly26rwLb9VTjwKYJtJd4+fElWmqL4Q sB8g9uAqj6lzEFieEdwnz6HLi3jXjQqAOZXpxaWdqW0Er46XgQ5rwsSunlkGVeQvMzpJ zXcQ== X-Gm-Message-State: ALQs6tA59LjpiMKumPO6Ck2gYzRqtrefrwm61h11QOfJH3w1+awqt2qq vlT6wOZjUVD88neGgBnhZc0otRKC X-Google-Smtp-Source: AIpwx49Re4GfuHVQLmsft+NhTyC5QunGCUslqoBNzPjrjRJgkqUOg3+sfMULHku7jm+0o3T9iBSfkQ== X-Received: by 10.28.146.71 with SMTP id u68mr424139wmd.107.1522358669785; Thu, 29 Mar 2018 14:24:29 -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 m35sm11907457wrm.59.2018.03.29.14.24.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Mar 2018 14:24:28 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 29 Mar 2018 23:23:38 +0200 Message-Id: <4a15beee34653deadb8bf8b8141b31adf6cb3321.1522358422.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 v4 14/20] 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, 29 Mar 2018 21:24:33 -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 5ce2e5733..3ccc2941d 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 *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