From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f173.google.com (mail-wr0-f173.google.com [209.85.128.173]) by dpdk.org (Postfix) with ESMTP id 19982374F for ; Fri, 7 Jul 2017 02:09:58 +0200 (CEST) Received: by mail-wr0-f173.google.com with SMTP id c11so24287356wrc.3 for ; Thu, 06 Jul 2017 17:09:58 -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=9nu7SF0rl78hDFi+KbIfRfleYEPi8NIiEpnxhkAzhFg=; b=aK+joysOTceNK8L1QV9Wi+IbTVSmjQ9oe3647Jpo4c0GBLfIcZLXPCSLEmbundrUS8 GBRJSj8vykGepXNwxHSbGtlYMq7Cgh5RhxUik9ItgWtKRptwfGrp1a+f3ySZBtDOsWtQ M+TLUaV00avCQETUz19wDbInMvj9K7p5PDskv/K6JO9/+xhVwsIo8bRfddzCm0Ap3RVr sSD7j1Y1zu0u2AGWCMSzgHmSbu1LQh9GHdsZ8zJQFGsQdoDfIyjlq5+TwzkgRPolelLm iXoT6OVaoGKVIFs+7+RAOb9VLxIc++JfHL+WXiSY/kZGZXlSbY+SrsuZvtYSV90jubb6 DaUA== 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=9nu7SF0rl78hDFi+KbIfRfleYEPi8NIiEpnxhkAzhFg=; b=umVLTB9khPQ0rm6DlTjz7wfJ1f9+jacq4kBJdttkTMBlv4iQTY+Bqb9KFY9+UqkLTl qUeQkQ4wndmCXHiIRZKbnF4KORdUmp1sDabIKCkSr/cBC6w1Mrd0DYaM4rQDkRoGBnQx 2RQNESlWJypNxexpjSLAVnH4/j8Swyt4NnHYR0qQqIs6TQJIFrWve8zFDzoy8AtVdoq8 jCnDC8yvE/qMyR4cQXzuaJjzNK/DvwaljnPWB8pyaL5Dskv8cJcY3prQmkiqQFiVVW1d dIB41Qn3TSZKsL2V7WMQ2j3Wqq2pLbHqcZIRetnQrK0TGzDqPj5im6AcVC/10pbfkxE3 /QGw== X-Gm-Message-State: AIVw113laYk7Q82JLDijIBxrK2fanrtzBsB1/6pFRZY0P9FBI51r7UIw bVWMsUX2LTFK0mk8KQg= X-Received: by 10.28.7.18 with SMTP id 18mr280393wmh.20.1499386197449; Thu, 06 Jul 2017 17:09:57 -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 f45sm2391166wrf.2.2017.07.06.17.09.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Jul 2017 17:09:56 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Fri, 7 Jul 2017 02:09:09 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v6 02/22] eal: fix hotplug add 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:09:58 -0000 New device should be represented by an rte_devarg prior to being plugged. Fixes: a3ee360f4440 ("eal: add hotplug add/remove device") Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_dev.c | 43 +++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 292fefe..708c8e9 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -120,12 +120,32 @@ int rte_eal_dev_detach(struct rte_device *dev) return ret; } +static char * +full_dev_name(const char *bus, const char *dev, const char *args) +{ + char *name; + size_t len; + + len = strlen(bus) + 1 + + strlen(dev) + 1 + + strlen(args) + 1; + name = calloc(1, len); + if (name == NULL) { + RTE_LOG(ERR, EAL, "Could not allocate full device name\n"); + return NULL; + } + snprintf(name, len, "%s:%s,%s", bus, dev, + args ? args : ""); + return name; +} + struct rte_device * rte_eal_hotplug_add(const char *busname, const char *devname, const char *devargs) { struct rte_bus *bus; struct rte_device *dev; + char *name; int ret; bus = rte_bus_find_by_name(busname); @@ -142,10 +162,22 @@ rte_eal_hotplug_add(const char *busname, const char *devname, return NULL; } + name = full_dev_name(busname, devname, devargs); + if (name == NULL) { + rte_errno = ENOMEM; + return NULL; + } + + ret = rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, name); + if (ret) { + rte_errno = EINVAL; + goto err_name; + } + ret = bus->scan(); if (ret) { rte_errno = -ret; - return NULL; + goto err_name; } dev = bus->find_device(NULL, cmp_detached_dev_name, devname); @@ -153,7 +185,7 @@ rte_eal_hotplug_add(const char *busname, const char *devname, RTE_LOG(ERR, EAL, "Cannot find unplugged device (%s)\n", devname); rte_errno = EINVAL; - return NULL; + goto err_name; } ret = bus->plug(dev, devargs); @@ -161,9 +193,14 @@ rte_eal_hotplug_add(const char *busname, const char *devname, RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", dev->name); rte_errno = -ret; - return NULL; + goto err_name; } + free(name); return dev; + +err_name: + free(name); + return NULL; } int rte_eal_hotplug_remove(const char *busname, const char *devname) -- 2.1.4