From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by dpdk.org (Postfix) with ESMTP id 2B6961BF03 for ; Thu, 5 Jul 2018 13:49:18 +0200 (CEST) Received: by mail-wr1-f65.google.com with SMTP id s11-v6so1013028wra.13 for ; Thu, 05 Jul 2018 04:49:18 -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=I/1ZAKgkd6jpRMcC8BN8bFPo1NO+N/XzKffF3owwJ7zNr+LG48iBH3vRYdB2sOJuXe ilIRVjSRXzq2O+Hf3674W1Bl9beakpCPKG7AxM9volR+9rUxj71YkL49R8B4NzlLvsiB 3AfLV4bto0UE5ZyagkqrzhyFpPJo3o49fMwqOsLSa/67Yj1oTonRS3WY9KBGdLI3LZj6 Gvj2mGYidvfk2A/k7RhNE7/SDdNw4MrfguSgRL0limmrxNFvBBIIJteVvPmgSwPAw0PC fhANMwAjdgRKhcdRGXJXfmomz35rQxZERlcm/NvbXzfzreuJsJ9YW1UMs655pKBQpzuK 2L0g== 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=D4rYO6YvQ/oMs04jQmrdqSa7BNrkMWwM5XT0S2yJp3AdGQfCw4BJrHylhFOUOJLwTG IU1oaRPCxnQdr0D5Q/ALqkdyGprz1oSsrH7o6TT/hLwfllRw4fdDqjOTYC82drFgry2a QSQcRl6IGZ0qTiKEjhoM4VbsFw7I37EzldQq0bbmsLOvFwjAKs5/SWOYOkqqenEJbmGe Do3Vs2/e1V0++k/A1GVUYD4sPfF4cpoDCdNgT9/T1iOZvJddqWD3JPidNCfNLP6Zc9QK mMlRl+rt+jo9KXR3jjc3q6oWtRuEN7bM/ym/Nd+o5AyZcA1MztHj6E2YxM5O5Y6mjCyT B9Bw== X-Gm-Message-State: APt69E2Sc78XfGeXVKDTiXplAtpTSV+qmZJnkk+03la4c4/lyxjUCIrl RS4MH0w5eIDij3RLb9oARKCo09bM X-Google-Smtp-Source: AAOMgpfRruEA7QSNZH16OgSkASft03SztAJ64/hKeugD9w1ORf46H0TBaIzGdgBH0g9tizZPpGiNPQ== X-Received: by 2002:adf:9ed0:: with SMTP id b16-v6mr4006989wrf.170.1530791357548; Thu, 05 Jul 2018 04:49:17 -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 o42-v6sm15809183wrc.50.2018.07.05.04.49.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 04:49:16 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 5 Jul 2018 13:48:23 +0200 Message-Id: <90d3bf3311162e3a0a8932a802e721ee7fe6349a.1530791217.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v10 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: Thu, 05 Jul 2018 11:49:18 -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