From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by dpdk.org (Postfix) with ESMTP id DFD107CBC for ; Thu, 8 Jun 2017 01:58:44 +0200 (CEST) Received: by mail-wm0-f49.google.com with SMTP id m7so35446391wmg.0 for ; Wed, 07 Jun 2017 16:58: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=Akzm6AGqUDND4tSKlhZlVRh5X6Vtu7FJlbF3hfiWRKk=; b=wQmULBSxXrDvKuSTCga+vPeo7VEKYssUSjbd0or9ghc//2rEge6XWyHfE6ezZJC7aI ZpbhTK3ChwOq2HHzQC5bn7UbsLAb1ByU8PFg0DfaosXcmx+mgeShrA4x986FM5eW6zCu xUEtg4zn7iJKSbqeiJhJRdaTVe5ar3EG9tS2oqv0+x4vNttr3Q+Mxo/W9jYIY5M/PSpC L1VyDQOsEPwAyFYCJYu7SPUEMnCmY6Z8gt74ScQ31cbx3XJ2skP6lQTsJL0gPwmDufhB gF9RSamF7cD9KLCKfYNIaRS/TTDrpykpUCQuOcQ2Pnk9hLNkGt7kqL+RGbsrEnJ4w/MZ oDig== 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=Akzm6AGqUDND4tSKlhZlVRh5X6Vtu7FJlbF3hfiWRKk=; b=FVoz8q3x1Bttrgw4l23bS9whYMFr1eyEFHovC5FVpiN9lIIqVIvaar84G7rnCuYhxl OB5f6yxgU72FuCax8wfr/aN5fBF0ufO6sZyPG4DwZGuUq1c40NAlEd/1EZejHJ1z+B6S SYzT5SwQvfesKH5tO7yZcgaLYvOxzXEzQ+Fx1dLPAkK/AcZv0Qj5TG7XR4xIk36Ci9/P lCgSdlRH7R2xYDoT+6ffRhbHP+GTt3QlVwedxWD/31HHIDa8R0StgRFY3paW64fq04X+ 5RbmdGeHFNVuFe6gWsEKLEznsugzE45kHAY3MmV/jVMJ6e8bgWef9/wWweNk0YXeJIF0 UM4Q== X-Gm-Message-State: AODbwcAvA0UEgVrAs+oC1m+WEn4WEL4qF5GywuiTAAoARGVTzEc/z86/ +r8DFId1i63j4sH0W0I= X-Received: by 10.28.8.3 with SMTP id 3mr1326353wmi.38.1496879924172; Wed, 07 Jun 2017 16:58:44 -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 p65sm5098653wrb.64.2017.06.07.16.58.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jun 2017 16:58:43 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 8 Jun 2017 01:58:29 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 2/3] dev: remove vdev function dependency 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: Wed, 07 Jun 2017 23:58:45 -0000 Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_dev.c | 50 ++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 8ef9b98..247c9c1 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "eal_private.h" @@ -61,6 +62,8 @@ static int cmp_detached_dev_name(const struct rte_device *dev, int rte_eal_dev_attach(const char *name, const char *devargs) { struct rte_device *dev; + struct rte_bus *bus; + struct rte_devargs da; int ret; if (name == NULL || devargs == NULL) { @@ -70,30 +73,37 @@ int rte_eal_dev_attach(const char *name, const char *devargs) dev = rte_bus_find_device(NULL, cmp_detached_dev_name, name); if (dev) { - struct rte_bus *bus; - bus = rte_bus_find_by_device(dev); - if (!bus) { - RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n", + } else { + char da_str[snprintf(NULL, 0, "%s,%s", name, devargs) + 1]; + + /* + * If we haven't found a bus device the user meant to hotplug + * a device instead. + */ + snprintf(da_str, sizeof(da_str), "%s,%s", name, devargs); + ret = rte_eal_devargs_parse(da_str, &da); + if (ret) { + RTE_LOG(ERR, EAL, "Could not parse device (%s)\n", name); - return -EINVAL; - } - - if (!bus->plug) { - RTE_LOG(ERR, EAL, "Bus function not supported\n"); - return -ENOTSUP; + return ret; } - - ret = (bus->plug(dev->devargs) == NULL); - goto out; + bus = da.bus; } - - /* - * If we haven't found a bus device the user meant to "hotplug" a - * virtual device instead. - */ - ret = rte_vdev_init(name, devargs); -out: + if (bus == NULL) { + RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n", + name); + return -EINVAL; + } + if (bus->plug == NULL) { + RTE_LOG(ERR, EAL, "Device hotplug not supported on this bus\n"); + return -ENOTSUP; + } + if (dev == NULL) + dev = bus->plug(&da); + else + dev = bus->plug(dev->devargs); + ret = dev ? 0 : -rte_errno; if (ret) RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", name); -- 2.1.4