From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f171.google.com (mail-wr0-f171.google.com [209.85.128.171]) by dpdk.org (Postfix) with ESMTP id 459E5293B for ; Mon, 26 Jun 2017 02:22:31 +0200 (CEST) Received: by mail-wr0-f171.google.com with SMTP id c11so131614601wrc.3 for ; Sun, 25 Jun 2017 17:22:31 -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=ZsWjw5LniSTVV1D2gGR2gVLh5Orpw0U0HkRZC4lj8Sk=; b=mhELVxEbpDXU+I6YcEwXisOHDHLg+p1rRlMHoXOfPt2VC8aZOl1x7XuOqFTETsGPtz Zbt7Z46XAHD9iflcnqGM/tMM0jHUf6cMoKOwrzawxGBBMJNSbwDnflgwILGokaNfosdS wyE3GrZAvpU2L02gFzGrL2VRi882JT0fOQX9V5qbM12i6f6v6nm7tASAuptBNr9i8//Y kuJOMwAKS9d2yFMsE9YvGQSQQhgv68/0hrWnuIgAv4o0nLWE8wmzk1JpMMIS2M0XOC2y uN/G3giQ2qeGPIbC8VrpN7clwCexRbDieXZoth/8ojYCRwDMLQN8meRj8HWHLyO1HofO xWNw== 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=ZsWjw5LniSTVV1D2gGR2gVLh5Orpw0U0HkRZC4lj8Sk=; b=mteCa32aNh48Nr83ddI23T/tL+M8Ky05HJRQPkaOaaPs9Q7yKNVNyZ2md2aLAXKZEi k9HZO5AevNObZkGGlO86c9CkUn/9/BuW+Xi273HbYtLYMJyjhg+BEF2HbORz1awlqBPk JJQ4YVL0GoxTFpXJcNGV9BkZz70HX3lSyMxSDldgERanwab+fHtPEqZ7UUF/IDQ3rS6h lSSkzP7qK5OOS2yPCBia0YNOtRLrAfMSn0XT/knFhXdM8q9l7ON4rYI6s0PAPdoTRqVA hmHv1XtdMzK0jL/O+uxtBh5c9/RJMNan/yMiF3P7a+6Hl76R8RG/1KdUG9reHUv82uij HQDQ== X-Gm-Message-State: AKS2vOyFLIS5N71MIBkpOubIJjPQqLuLekO9WV4M2voZd2VeMdNRdvCj UB+BcnQ19hblcDQJN8c= X-Received: by 10.28.211.132 with SMTP id k126mr11258443wmg.109.1498436550550; Sun, 25 Jun 2017 17:22:30 -0700 (PDT) Received: from bidouze.dev.6wind.com ([62.23.145.78]) by smtp.gmail.com with ESMTPSA id 19sm16061626wrx.26.2017.06.25.17.22.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Jun 2017 17:22:29 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Mon, 26 Jun 2017 02:22:03 +0200 Message-Id: <372deed99d7ba7fc23fbd9b97b0c4ab6abbde755.1498436062.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 v5 05/12] bus: introduce hotplug functionality 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: Mon, 26 Jun 2017 00:22:31 -0000 From: Jan Blunck Signed-off-by: Jan Blunck Signed-off-by: Gaetan Rivet --- 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 63fd9f1..0035da0 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 3e83227..187c37e 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -100,6 +100,35 @@ typedef struct rte_device * (*rte_bus_find_device_t)(rte_dev_cmp_t cmp, 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. + * + * @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 { @@ -108,6 +137,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 bus */ + rte_bus_plug_t plug; /**< Probe single device for drivers */ + rte_bus_unplug_t unplug; /**< Remove single device from driver */ }; /** -- 2.1.4