From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gaetan.rivet@6wind.com>
Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44])
 by dpdk.org (Postfix) with ESMTP id 2C0F52BE1
 for <dev@dpdk.org>; Tue, 27 Jun 2017 18:11:39 +0200 (CEST)
Received: by mail-wm0-f44.google.com with SMTP id 62so29302285wmw.1
 for <dev@dpdk.org>; Tue, 27 Jun 2017 09:11:39 -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=duxSWFTF9uoUShsoDmEW1Jo/+ZNBgpdn9QAkSCGx4BM=;
 b=Hl4xd6xKNqglfUHIOe+HXT7DpH3q32LKO1onaRgki0ecuLm3VzTEDMKamLJBYAM1Rd
 8T1ji+KxcP0734HVR+uC2oa1myOMaphYY5cAI9GXDw4+LMpYOU9HirstHv1juq45eQZy
 7lwvmBFFiNyjkjndiHS0BXGn6/FJWFpa2JakTHnSOWW4pEMpws4AuF5x+9qrNXBWZ3aH
 CkAIcYvDdNcwM76AmiK9CiMKuujLSorakRPcxV3JZ7Iynjd1fDAmjvwCp84Y1pZauW6z
 VQoNnFt8IqO2JL4x+2YTkq2kOPmMCjgDKwcDnjgfF9SHVcC4vYGoli7tFQH25ZNAl0Yw
 fmdw==
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=duxSWFTF9uoUShsoDmEW1Jo/+ZNBgpdn9QAkSCGx4BM=;
 b=IffYBKBuz2I/PyC4m2xijib1M3rGiU64u/TXSsLABNUftiTI9O6YMxBQrgMkL+6dr3
 vMH5ESV60GpkciPWGz5ctZWokRCQrSxcDswtz/4/WKOHKeOWnapcOCqThQHCraAxNYqe
 Lrk1OcCqpObOOZyBLRPmeaOiT1gJk4Bv3DLb2C4/2AXL/lONg5pfutZ+mrLWxMOcZY8H
 2AlQwgwaWlxG9xjV8L9ny+UXM6P78hNDL0slpjgxjBfrJ/hnNRld04aVvAhf3u6cJ/fn
 Apr5yEzMsJBiG1cioEkkH8cAL0OFp7NCzdXyUqfz9kwbJLIsP4BWA1EC5Rmn83vevwL0
 9hjA==
X-Gm-Message-State: AKS2vOzwuw9QydLA1r41OgsjqRTtuDk6EfcUPtv3CHNxcOYZ3SeOUoPZ
 2nY2jnuylx4huui3Ud0=
X-Received: by 10.28.88.3 with SMTP id m3mr4132679wmb.28.1498579898495;
 Tue, 27 Jun 2017 09:11:38 -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 v13sm4080465wmd.5.2017.06.27.09.11.37
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
 Tue, 27 Jun 2017 09:11:37 -0700 (PDT)
From: Gaetan Rivet <gaetan.rivet@6wind.com>
To: dev@dpdk.org
Cc: Jan Blunck <jblunck@infradead.org>, Gaetan Rivet <gaetan.rivet@6wind.com>
Date: Tue, 27 Jun 2017 18:11:12 +0200
Message-Id: <fabc9b2279828ad2ebde64747198d206ad591c84.1498577192.git.gaetan.rivet@6wind.com>
X-Mailer: git-send-email 2.1.4
In-Reply-To: <cover.1498577192.git.gaetan.rivet@6wind.com>
References: <cover.1498436062.git.gaetan.rivet@6wind.com>
 <cover.1498577192.git.gaetan.rivet@6wind.com>
In-Reply-To: <cover.1498577192.git.gaetan.rivet@6wind.com>
References: <cover.1498577192.git.gaetan.rivet@6wind.com>
Subject: [dpdk-dev] [PATCH v6 05/11] bus: introduce hotplug functionality
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Tue, 27 Jun 2017 16:11:39 -0000

From: Jan Blunck <jblunck@infradead.org>

Signed-off-by: Jan Blunck <jblunck@infradead.org>
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/eal_common_bus.c  |  2 ++
 lib/librte_eal/common/include/rte_bus.h | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index dde6c83..83d9c07 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -50,6 +50,8 @@ rte_bus_register(struct rte_bus *bus)
 	/* A bus should mandatorily have the scan implemented */
 	RTE_VERIFY(bus->scan);
 	RTE_VERIFY(bus->probe);
+	/* Buses supporting hotplug also require unplug. */
+	RTE_VERIFY(!bus->plug || bus->unplug);
 
 	TAILQ_INSERT_TAIL(&rte_bus_list, bus, next);
 	RTE_LOG(DEBUG, EAL, "Registered [%s] bus.\n", bus->name);
diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
index 9aa047d..8c2d19c 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -109,6 +109,35 @@ typedef struct rte_device *
 			 const struct rte_device *start);
 
 /**
+ * Implementation specific probe function which is responsible for linking
+ * devices on that bus with applicable drivers.
+ * The plugged device might already have been used previously by the bus,
+ * in which case some buses might prefer to detect and re-use the relevant
+ * information pertaining to this device.
+ *
+ * @param da
+ *	Device declaration.
+ *
+ * @return
+ *	The pointer to a valid rte_device usable by the bus on success.
+ *	NULL on error. rte_errno is then set.
+ */
+typedef struct rte_device * (*rte_bus_plug_t)(struct rte_devargs *da);
+
+/**
+ * Implementation specific remove function which is responsible for unlinking
+ * devices on that bus from assigned driver.
+ *
+ * @param dev
+ *	Device pointer that was returned by a previous device plug call.
+ *
+ * @return
+ *	0 on success.
+ *	!0 on error. rte_errno is then set.
+ */
+typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
+
+/**
  * A structure describing a generic bus.
  */
 struct rte_bus {
@@ -117,6 +146,8 @@ struct rte_bus {
 	rte_bus_scan_t scan;         /**< Scan for devices attached to bus */
 	rte_bus_probe_t probe;       /**< Probe devices on bus */
 	rte_bus_find_device_t find_device; /**< Find a device on the bus */
+	rte_bus_plug_t plug;         /**< Probe single device for drivers */
+	rte_bus_unplug_t unplug;     /**< Remove single device from driver */
 };
 
 /**
-- 
2.1.4