From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f178.google.com (mail-wr0-f178.google.com [209.85.128.178]) by dpdk.org (Postfix) with ESMTP id 0DA8F532C for ; Wed, 5 Jul 2017 01:55:42 +0200 (CEST) Received: by mail-wr0-f178.google.com with SMTP id c11so255172187wrc.3 for ; Tue, 04 Jul 2017 16:55:42 -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=DcsLXfyJ14oqEHMHs3ELD8OQNUxKdU4D9y3YtxKG/NQ=; b=IoqZtJVh7pguq3KAtkd1rnxNmYtcM9PZ5InO4Xd069trlBaQ03eW+2gQJN/EOp7ojf 5Hegg6NbfX2VzV1yee1RoC7Rf4Ti9fFYE06q24KJ98WFaRhF6dPvFSLiTzcmuGVSaiVG rIbIrHX4azuhGFZk498ASU+JwiLc+P28d5KcHnhYsHZV2EOYzbGm48Entb29kXt4icAn i57xMoTpYFSk0ZOVJR4l3U6HYWtoWEx7GlgMa12TeAm5ZGd/+grlFMrN2PVc1vml8Lur hf07LhqrUfrwPYWWxMYTNbFkVAlHGZB/fVGLOXQTVllx3goygESqX9YSgcyI+SESnrWv OMjg== 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=DcsLXfyJ14oqEHMHs3ELD8OQNUxKdU4D9y3YtxKG/NQ=; b=UV8oir1/9ITCtTTTQg2scAQxZRrYQkREASddvWJVAnogxCAwSrWLhlT0Q9e4onNSvv dtH+Q/ITx71BEeq/VK+4GT9wGoS4N1XTDF8OFP+SDiL9U35FzKDXn37cdyz40BVbNNUH rzi8j3i2oZTo33u7E1oNMB8LvdHOmUrePpZc3V1KCJDOfRQuvupHffzZPSa1466cHpSM C18l2LeTh2LLYPTPAaXN+depBH2rO8hqbp3zMxnsptmARhsND+nD7S/lw4hgE+HaFkPI hyECGXDhBiyHJmOlixoO683grUykR/YPy4vA/u3pD+5C1O/41J+0kQKbXyIiD0BMGwyS TFfw== X-Gm-Message-State: AKS2vOzZGq5qk+Su8bNiDNesL7LnTmdtK3YjUH0qlzC59MsajLidOCpE MiSNMCFQqD97Jk7Lzxg= X-Received: by 10.223.176.124 with SMTP id g57mr34311708wra.190.1499212541525; Tue, 04 Jul 2017 16:55:41 -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 19sm23406533wrx.26.2017.07.04.16.55.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Jul 2017 16:55:40 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 5 Jul 2017 01:55:20 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v7 3/6] vdev: implement parse bus operation 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, 04 Jul 2017 23:55:42 -0000 Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_vdev.c | 58 ++++++++++++++++----------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 3bad0c4..6ecd1b5 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -102,6 +102,27 @@ static char *parse_driver_arg(const char *args) } static int +vdev_parse(const char *name, void *addr) +{ + struct rte_vdev_driver **out = addr; + struct rte_vdev_driver *driver = NULL; + + TAILQ_FOREACH(driver, &vdev_driver_list, next) { + if (strncmp(driver->driver.name, name, + strlen(driver->driver.name)) == 0) + break; + if (driver->driver.alias && + strncmp(driver->driver.alias, name, + strlen(driver->driver.alias)) == 0) + break; + } + if (driver != NULL && + addr != NULL) + *out = driver; + return driver == NULL; +} + +static int vdev_probe_all_drivers(struct rte_vdev_device *dev) { const char *name; @@ -115,36 +136,14 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev) RTE_LOG(DEBUG, EAL, "Search driver %s to probe device %s\n", name, rte_vdev_device_name(dev)); - TAILQ_FOREACH(driver, &vdev_driver_list, next) { - /* - * search a driver prefix in virtual device name. - * For example, if the driver is pcap PMD, driver->name - * will be "net_pcap", but "name" will be "net_pcapN". - * So use strncmp to compare. - */ - if (!strncmp(driver->driver.name, name, - strlen(driver->driver.name))) { - dev->device.driver = &driver->driver; - ret = driver->probe(dev); - if (ret) - dev->device.driver = NULL; - goto out; - } - } - - /* Give new names precedence over aliases. */ - TAILQ_FOREACH(driver, &vdev_driver_list, next) { - if (driver->driver.alias && - !strncmp(driver->driver.alias, name, - strlen(driver->driver.alias))) { - dev->device.driver = &driver->driver; - ret = driver->probe(dev); - if (ret) - dev->device.driver = NULL; - break; - } + if (vdev_parse(name, &driver)) { + ret = -1; + goto out; } - + dev->device.driver = &driver->driver; + ret = driver->probe(dev); + if (ret) + dev->device.driver = NULL; out: free(drv_name); return ret; @@ -372,6 +371,7 @@ static struct rte_bus rte_vdev_bus = { .find_device = vdev_find_device, /* .plug = NULL, see comment on vdev_unplug */ .unplug = vdev_unplug, + .parse = vdev_parse, }; RTE_REGISTER_BUS(vdev, rte_vdev_bus); -- 2.1.4