From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id D275F7CB9 for ; Fri, 30 Jun 2017 20:20:17 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id p204so9336768wmg.1 for ; Fri, 30 Jun 2017 11:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Fyq8LGMV2FdmO30UhFjjqhVYz/GFyi9QdS56y4IseRo=; b=PRoBnvB7pakgSGVbm0ut8UU0iJY7WE0UwfKsKO3rbP9LUKkoYgiU/xbt+xNjCFM79g NbayzGxNxQOzpFKHGciy2tr+30qTBEWTleH31INXKjkiDEouKKLHxQwCAcDYw3PW1BqL ezF9guNK9CbTXmZXrrQ2ebEr+IaRhJwc8d3ikt5VSLBdIybSwmvsvt6UH7BwsQNSIzWY TejJhUk01K3ujun7cF8C4HaIPfmXF5FgKfxZ2hYuiLgYb9Khg0LFrsO3DS6J93n/e1CG 4t7gy84kC/IKDYk11zg0HHK0QNOhUJkqvNMFMxZGMcgVjiEASaf4hvqT5PFsocZe8DFC /CBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Fyq8LGMV2FdmO30UhFjjqhVYz/GFyi9QdS56y4IseRo=; b=Z1vVGL5CsplsWLq+6hwMzec01ltaoonn6XHRWjP6s3xgAp48R+xTmvsr7DcMmn7eh9 kXjvIKuJ8w8y9yS1VlACT3XDVN22AkWcrThGocgHw3UbL22Ejf5AS3sUx9fD/MPkVVEt P9WsKcSuRH4JKEzJp16wswqohdoKEgISt6tjzfaPfI2lsLuy1pZZmsa81gbgPCrJrS2J E9yzBNkxHQRrOBvemBIIwQLn+29NLkRWVq2YcTTD8p8Cy80+SD9MSTImk1e8EswVIcZl h7NUdR8tyWnTOpBzg4OglwbEu3RLBDSZdqJekU0m08HebWcgmlIDJUO2aIRwBjO5uhi1 pnIQ== X-Gm-Message-State: AKS2vOxSzjPkSUjzQ7L32ALuMf9drtynsBvojCFfvJBMPwOyDKJh6RNw SQXfRTi67DNynCzk X-Received: by 10.80.136.129 with SMTP id d1mr6350566edd.130.1498846817468; Fri, 30 Jun 2017 11:20:17 -0700 (PDT) Received: from weierstrass.local ([91.200.110.13]) by smtp.gmail.com with ESMTPSA id r28sm2826940edd.33.2017.06.30.11.20.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 11:20:16 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, shreyansh.jain@nxp.com Date: Fri, 30 Jun 2017 20:19:43 +0200 Message-Id: <20170630181943.23929-15-jblunck@infradead.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170630181943.23929-1-jblunck@infradead.org> References: <20170629182206.1072-1-jblunck@infradead.org> <20170630181943.23929-1-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v8 14/14] dev: use new hotplug API in attach 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, 30 Jun 2017 18:20:18 -0000 Using the new hotplug API allows attach to be backwards compatible while decoupling it from the concrete bus implementations. Signed-off-by: Jan Blunck --- lib/librte_eal/common/eal_common_dev.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index ede68e4..4ee52fd 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -67,27 +67,26 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name) int rte_eal_dev_attach(const char *name, const char *devargs) { - struct rte_pci_addr addr; + int ret; if (name == NULL || devargs == NULL) { RTE_LOG(ERR, EAL, "Invalid device or arguments provided\n"); return -EINVAL; } - if (eal_parse_pci_DomBDF(name, &addr) == 0) { - if (rte_pci_probe_one(&addr) < 0) - goto err; - - } else { - if (rte_vdev_init(name, devargs)) - goto err; - } - - return 0; + ret = rte_eal_hotplug_add("PCI", name, devargs); + if (ret && ret != -EINVAL) + return ret; -err: - RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", name); - return -EINVAL; + /* + * If we haven't found a bus device the user meant to "hotplug" a + * virtual device instead. + */ + ret = rte_vdev_init(name, devargs); + if (ret) + RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", + name); + return ret; } int rte_eal_dev_detach(struct rte_device *dev) -- 2.9.4