From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gaetan.rivet@6wind.com>
Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53])
 by dpdk.org (Postfix) with ESMTP id 84D771B53
 for <dev@dpdk.org>; Wed, 31 May 2017 15:18:15 +0200 (CEST)
Received: by mail-wm0-f53.google.com with SMTP id e127so19924275wmg.1
 for <dev@dpdk.org>; Wed, 31 May 2017 06:18:15 -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=pUpLPxT5tI+h1YtThNCcM5il2u3lWzXwPUuy13rub6U=;
 b=vNhE3XpcEq6+QoWMF0VR51vHEITn9J4loO9f2ZAERM6yvG8syGfH7PYwaRtRE/DrS6
 Wu7hnsXjrV5UPbaYhVjyhpeFljugydNzv3M24j/DXm4vSMXQroIQxKXyp6LBzDy8E5sL
 dKo2UiBtF4OX0Omhy7FdW6wqltTaoHv5z1v6kJAcwGn4jOEI7LHBorW3O2waODAZ9P5f
 gCKEhb7HusZ0T3xuX7sjaCwO/cxWQXrO3PWfrmV2fkxzJSrittHnq2KblS6hj1gxHVDE
 2B7yaJZhI2VWlyyW0ZNCUEN3K5ygwu+vgOLymYVyJFAcU0z5vIUV/tQ0w9j8ZggHL1e9
 0+5A==
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=pUpLPxT5tI+h1YtThNCcM5il2u3lWzXwPUuy13rub6U=;
 b=tBwNSS43cHlkomwaB6ycleQjvtqDDvoUR5KMYbsdsG1gt9XG2kvk/S+Dhlnogx3QFo
 o2GxAgIRP8zAkId/IB4Kf/kuo0MiC/YsA9GL3bqUISAMeXmdL7ETutGhfbZ3A4ML2Twk
 ZDfe/4dfuRnsvlotFBwbPexFw+UxzorDYBA+2GvuE7vIIJGJOJvqgzlXka101kgfJf4y
 +FK0YJ6yl0GLmI/qVM6bMB3YIEmrpFuTsOuiJGamCGHS2ty6v8ZuLTej6RbipcguIrpQ
 G5QhgWW+udlxevMWADXedUvJGdKe8JyxungaAsla+pz2u+pnlYRjOTD9nzo2fzh+95CT
 WSlQ==
X-Gm-Message-State: AODbwcDSrdBuxtQOXDs5Y1yogtrZZWj9NcwgdxEzPopVntDn7qANT7Zk
 60jIAZYl0Jh0D6Rm7j0=
X-Received: by 10.223.167.76 with SMTP id e12mr18140369wrd.177.1496236694899; 
 Wed, 31 May 2017 06:18: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 g77sm10045744wmd.19.2017.05.31.06.18.13
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
 Wed, 31 May 2017 06:18:13 -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: Wed, 31 May 2017 15:17:50 +0200
Message-Id: <1ed679ff10dac583512a74ae55698d40e5654bfe.1496235017.git.gaetan.rivet@6wind.com>
X-Mailer: git-send-email 2.1.4
In-Reply-To: <cover.1496235017.git.gaetan.rivet@6wind.com>
References: <cover.1495637723.git.gaetan.rivet@6wind.com>
 <cover.1496235017.git.gaetan.rivet@6wind.com>
In-Reply-To: <cover.1496235017.git.gaetan.rivet@6wind.com>
References: <cover.1496235017.git.gaetan.rivet@6wind.com>
Subject: [dpdk-dev] [PATCH v2 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: Wed, 31 May 2017 13:18:15 -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  |  3 +++
 lib/librte_eal/common/include/rte_bus.h | 20 ++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index 632a6e7..4063897 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -51,6 +51,9 @@ rte_bus_register(struct rte_bus *bus)
 	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 b56018f..3c59fc2 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -88,6 +88,24 @@ typedef struct rte_device * (*rte_bus_find_device_t)(rte_dev_match_t match,
 						     const void *data);
 
 /**
+ * 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.
+ */
+typedef int (*rte_bus_plug_t)(struct rte_devargs *da);
+
+/**
+ * Implementation specific remove function which is responsible for unlinking
+ * devices on that bus from assigned driver.
+ * Some buses will expect the same device to be plugged-back in eventually.
+ * The decision to release the associated meta-data (full-fledged bus-specific
+ * device representation) is left to the discretion of the bus.
+ */
+typedef int (*rte_bus_unplug_t)(struct rte_devargs *da);
+
+/**
  * A structure describing a generic bus.
  */
 struct rte_bus {
@@ -96,6 +114,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 device on bus */
+	rte_bus_plug_t plug;         /**< Probe single device for drivers */
+	rte_bus_unplug_t unplug;     /**< Remove single device from driver */
 };
 
 /**
-- 
2.1.4