From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by dpdk.org (Postfix) with ESMTP id CD0D11B648 for ; Sun, 15 Apr 2018 17:08:30 +0200 (CEST) Received: by mail-wr0-f193.google.com with SMTP id w3so2669343wrg.2 for ; Sun, 15 Apr 2018 08:08:30 -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=92WXlTV7tP9Bcqf0JD/O5rkTSJreSbNwQkGAXS0FzL4=; b=lhAkVeF5mDYpUoLlLuACo+9gykh46uPyVmy6vtw2qsTcbj3WuBISCFfwW97N/wRXFG 2756QVfSida7+5HgcWWkFenk8mpJQ/9VEuQ2GqsrG0VlvHopv6Rp+liXYvZi1qf8w01l Al6X2lFGXRjsCzWcGaO/7cVKpl88sdFr40e6E65dwb6tg+cqGPaBTLpgizphGVtFPKv5 Cb22D0PiHIVVrIC8DwGIJcPogNk8mQU5/bvhaRgmJxqY3Pv9qKOSUNnuR/xp8Af3OH1/ tTd52N8WB2dZkscKtszc1tc1qUdgLeZ4WO8JPfoJBgNgG6H8NIFmWJM0y2vCAF4TKrSa 1INA== 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=92WXlTV7tP9Bcqf0JD/O5rkTSJreSbNwQkGAXS0FzL4=; b=K8TcgtkhyTIqAz3+Ottfs2dlNQ154KcOxVun0/GCx074cNSr/hX9rRI58bOxUhnRMK y47YZsv39AaASzxgsPJxIy4WOI7Upykvhly1d24T6+0HmopcA7mfDClSLIB4j2yu/UoB YPkWrU4Audzhs7SynCYRFY8u3H4HwfrEOacU9aMZ+ytme9obkNAJztB1FFN4VgMnJfs0 Xb4Nkg+tat0SDUf26LzdmM3J56gOseMqsvSdmUZakKFZxlEjSeU0UNCCFRGKXfNxySOW n7t/d21OS4Qo0+4NzWRJjbzoduEdGpSPwd38R/VyjbGFBxE+OytVOi9UTuTCKtp9t4ZB Atfg== X-Gm-Message-State: ALQs6tAytGQzawfg6kkWTwR/jwF5QZkxQd+sSw5RpotItciab/DJnewM msGSywlpIZtPxyWXGTkbxWWywXib X-Google-Smtp-Source: AIpwx4/xpZLU8936MReYGmRyeddAvEPVRBKeeR2Tcgo5JWVdDIw75XShKfS0BXwUgvSXT/JEjrooJw== X-Received: by 10.223.158.6 with SMTP id u6mr8353208wre.142.1523804909171; Sun, 15 Apr 2018 08:08: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 r200sm13673438wmb.39.2018.04.15.08.08.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Apr 2018 08:08:28 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Sun, 15 Apr 2018 17:07:44 +0200 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v7 15/22] 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: Sun, 15 Apr 2018 15:08:31 -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 bd9ecddc6..3666e4caa 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 * 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 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