From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f180.google.com (mail-wr0-f180.google.com [209.85.128.180]) by dpdk.org (Postfix) with ESMTP id 83DA23254 for ; Fri, 7 Jul 2017 02:03:44 +0200 (CEST) Received: by mail-wr0-f180.google.com with SMTP id k67so24089691wrc.2 for ; Thu, 06 Jul 2017 17:03:44 -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=ywLiIzq3n8x1xPllhRwmcFRcH+uDTvmhl3FXW0CQx+4=; b=AMBYOMChMuzejOP5g1XLznErkNr86lEj7DU4CdLPe+O5NUkkEXwb22AHMuL3/WBkOn Iww/qI95FyBLAhF1oVa4kfx/bhVy8ByDhyDEgbVn5ZledfMuPN4uJtwVs7lRKLQ5ry3u 21qR+wAtEfbUF5RvuzIF095MABJVHm1fATeNzC+Aqjr19t2X/fuKAp6m53u+WRRua+CE yZ0+PhZk4t45GbRfUikJmOQRto2wYNUdvFzMe9GCn+Ns1lFISP4lk+l5Z1AhLlWHOs2a hwy1RWkzpKM+PMnl3lJWKANjpxgaQFLExLcbdW8w2c5fMRSdkiQmG8DXUKEslvlaIOCD nB0w== 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=ywLiIzq3n8x1xPllhRwmcFRcH+uDTvmhl3FXW0CQx+4=; b=fRnkxlgiF+SGiLwVGMUT34nHkND54omJbqh30ACOV59klKmkHiS4Ou9AOihCrBtBFE oui9W7D25Pd+uoQSOXq60lAn8vSBZYTEbI7iDJnXoE/wPDc8jvl2cjdJVW+xg4xT3clw 3pFBqu4Dxz3DNpmviqtWVaOwxEZBjEfg2Vw9cGrGDybcXn1O7wD5q+Gm3oczBeqksAPh I2uuYab7FM3m1ghxRhbfPAQBUtxRZbGa0cF37iec2b8Qz5HrxBcb50KFzhpbHLTHKvY4 WIUa07fzwnxPmdErIqXvzrKCiC5h62Lc4dXrrs/8gtaBVdUfEbY012vmAMd1AKZV5cwg 0Hqw== X-Gm-Message-State: AKS2vOw9M7TGkd51mVlXShOX3egs1xX4TUbHVMmTJCUVrPweC63HmmAE naImJvmh3Ws+A0Mywd8= X-Received: by 10.223.135.29 with SMTP id a29mr44611355wra.138.1499385823922; Thu, 06 Jul 2017 17:03:43 -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 p7sm2364921wmf.11.2017.07.06.17.03.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Jul 2017 17:03:43 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Fri, 7 Jul 2017 02:03:09 +0200 Message-Id: <8e7cfd34ae9a3b5989f2abc383f8e6231177428c.1499384335.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v8 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: Fri, 07 Jul 2017 00:03:44 -0000 Signed-off-by: Gaetan Rivet Acked-by: Bruce Richardson --- 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