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 0B9A91BE8E for ; Wed, 4 Jul 2018 00:15:56 +0200 (CEST) Received: by mail-wr0-f196.google.com with SMTP id f16-v6so3389884wrm.3 for ; Tue, 03 Jul 2018 15:15: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 :in-reply-to:references; bh=GDAM0+BY9zdzKzqAvSmkL7Cyo+VOwFhWZYWz8JjTZ8Y=; b=J81o7hGl3KRGSLMCzyMnwtq11DbCzdK0gHKcRjgQLxzY3xxi+3iZkr71O/9MxjDObM cGo0uy9ftc1RtW6g94OrEUNqIKrWKOEHbFOmao/TQWpczlsywopEiF72E9ZmAbvJn1AM SMMcSQNUTeeE59Xb9oSOWFdUrlKQr3CzaM3vSzD4WY0EorCnQ/lhFVN4YsKKWFl+2NCy U0jVMmz+HCsCl+jq8c7M9HXrTZqG7RwLLVAv+qVAIAEhrtR7RIYpZ3NjKEFMuGXt7pCe gSzLoMPETJCY9I5CYDTQEWWkAQYdpn1MMyLi5ZtRfZ1p7cUYa2p9pitRH9fcHHdgslL6 n/QA== 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=NzilLaMdPncBspxR7Udx0bzjOl0Nrl+tN266eYPFmA2/2zhQloj+8ZjFUB4xGGCM6B kFTUUj+DgLsID97v3kIJP79d7T4HY+eLsSkwzhUiZikDpQf7kQPN5wuxyKLJGLbLO3T7 tppUAPjtpMeQC6Ke5LnFTKzgVIGqyY/LUHyI3L+BwoJnXCKX+U+eX3IaUENuA6WIONrK 8cYWQFmjUA7i+kQ8/0feFjIAuEA0I7g+Gaq0SRASUVwJkj2NO2iv8o+HrndSK/UsKKPb 9uKnb/PIuGx42aCoOsbXqOGLvT/y7TnSx3QKsccFY35ZmjNJHvgwpexyKrme/Kx+QTeA 9SQw== X-Gm-Message-State: APt69E2cCrZWppZHuG8APf/W/x3TUfbQz5FIVAEsym69V1Y0K2EevEsl 5TpscCxhBeaVlIsTka7GRVXJuT4J X-Google-Smtp-Source: AAOMgpezoRpdPiadokZcA54FqAkgXPcyF3MeFmGLbafHjG0jrGw53jXXZ8b20RF0pcMnFSzKM67+pw== X-Received: by 2002:adf:a211:: with SMTP id p17-v6mr2709737wra.196.1530656155414; Tue, 03 Jul 2018 15:15: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 i190-v6sm3771084wmd.33.2018.07.03.15.15.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jul 2018 15:15:54 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 4 Jul 2018 00:14:59 +0200 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v9 16/27] 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, 03 Jul 2018 22:15: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.11.0