From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by dpdk.org (Postfix) with ESMTP id D9D127CFA for ; Thu, 1 Jun 2017 12:12:14 +0200 (CEST) Received: by mail-wm0-f53.google.com with SMTP id d127so53628294wmf.0 for ; Thu, 01 Jun 2017 03:12:14 -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=3HeP/j0UUgu0ED8kJTBGD5Y+N7NNGdOLyDHyuenxlSo=; b=brJ+5gtkzcgy2S22YL+cMg56GCB+CzJA7T2nEd2G4Sm6SVSGx/aHyY7bPXjVHwkBx6 6r8SDJsi18sERGTCWqR/JVmZ372vLC4xbZott/xLFa79OgSA/rkCaP4PzBq26O1TYkdq fJzuXje3xDeNVcTKOje+4NxfoXrSrih1XhCmqt046HxWAyx9A8aQXqT6O0MtZsBzIpzn 7SuGHIljWtcufv5f6ihiqkWa76bNRjzs8RdLzGykMhz8ZB9QX4GgzI/2Z+MtZHAYD2Hf zT4WO/Zz77ICuh5AJ0mLdoRfr3gBCWuEiwMxqU+UicG+9VpJEnNnKHZhglCiCzNw7Z1Z Ze1g== 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=3HeP/j0UUgu0ED8kJTBGD5Y+N7NNGdOLyDHyuenxlSo=; b=uobZK1S9bSuTy5Tr/ASnHT/226Vmp/3/Qd/Cgky5zKen0PGSH7AckuQf3xmKUUpKQS VaNrc8xVcJ50+eYcwDb8JkcFsypY0innt0xL6+N1wsb6w5Dnhb0SiyPA5AlIY3EBhr8Q cgojjPAgh4XiwFW8ACALY1jQ+UgdpqHqQI8DVjpwPeBcVxF5q+RQTrrO/YmWSd5A27iY k4HbZr8XNMe2bSqpEv91X3mjDHQMXfCgKwrFPSc/5Z5oFozoNHpbfzMvkvzVGTLC0QrW pHOHBSMvO+5kD3BLCr71e2UieBtmaUrN36zn/TK0mLKjdnz+vrRhHF8f+wrRiSsGd8c1 q5sA== X-Gm-Message-State: AODbwcDMwYdU1719s7V34LkJMFZoc4GYmNaEFU1j7Omsc7+V/3dMbHc/ iKPAq3pOwPcLv1qLJTo= X-Received: by 10.223.163.153 with SMTP id l25mr827370wrb.34.1496311934293; Thu, 01 Jun 2017 03:12:14 -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 e83sm33697524wmc.28.2017.06.01.03.12.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Jun 2017 03:12:13 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 1 Jun 2017 12:12:01 +0200 Message-Id: <42654e975eee3b3a9650f1b1cfea26be08fa25d4.1496310671.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 v2 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: Thu, 01 Jun 2017 10:12:15 -0000 Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_dev.c | 49 +++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 968c66e..c286628 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -61,6 +61,7 @@ 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; int ret; if (name == NULL || devargs == NULL) { @@ -69,31 +70,35 @@ 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; - + if (dev) bus = rte_bus_find_by_device(dev); - if (!bus) { - RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n", - name); - return -EINVAL; - } - - if (!bus->plug) { - RTE_LOG(ERR, EAL, "Bus function not supported\n"); - return -ENOTSUP; - } - + else + bus = rte_bus_from_dev(name); + if (!bus) { + RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n", + name); + return -EINVAL; + } + if (!bus->plug) { + RTE_LOG(ERR, EAL, "Device hotplug not supported on this bus\n"); + return -ENOTSUP; + } + if (!dev) { + struct rte_devargs da; + 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) + return ret; + ret = bus->plug(&da); + } else { ret = bus->plug(dev->devargs); - goto out; } - - /* - * 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 (ret) RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", name); -- 2.1.4