From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gaetan Rivet Subject: [PATCH v1 11/18] ethdev: add device matching field name Date: Thu, 15 Mar 2018 18:49:41 +0100 Message-ID: <9b203729de19bdcf406102627694227b4dc6c624.1521124599.git.gaetan.rivet@6wind.com> References: Cc: Gaetan Rivet To: dev@dpdk.org Return-path: Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by dpdk.org (Postfix) with ESMTP id 54FADAAD0 for ; Thu, 15 Mar 2018 18:50:25 +0100 (CET) Received: by mail-wr0-f194.google.com with SMTP id o8so9238136wra.1 for ; Thu, 15 Mar 2018 10:50:25 -0700 (PDT) In-Reply-To: In-Reply-To: References: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The eth device class can now parse a field name, matching the eth_dev name with one passed as "class=eth,name=xxxxxx" Signed-off-by: Gaetan Rivet --- lib/librte_ether/rte_class_eth.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/librte_ether/rte_class_eth.c b/lib/librte_ether/rte_class_eth.c index bfa821d09..2f362ebcc 100644 --- a/lib/librte_ether/rte_class_eth.c +++ b/lib/librte_ether/rte_class_eth.c @@ -14,11 +14,25 @@ #include "rte_ethdev_core.h" static int +eth_dev_str_cmp(const char *key __rte_unused, + const char *value, + void *_str) +{ + const char *str = _str; + + return strcmp(str, value); +} + +static int eth_dev_match(struct rte_eth_dev *edev, struct rte_kvargs *kvlist) { - (void) kvlist; - (void) edev; + struct rte_eth_dev_data *data; + + data = edev->data; + if (rte_kvargs_process(kvlist, "name", + ð_dev_str_cmp, data->name)) + return 1; return 0; } -- 2.11.0